homegames-client 0.2.2 → 0.2.3

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.
@@ -104,7 +104,7 @@ SOFTWARE.
104
104
 
105
105
  ----------------------------------------
106
106
 
107
- homegames-client@0.2.2 (MIT)
107
+ homegames-client@0.2.3 (MIT)
108
108
 
109
109
  MIT License
110
110
 
@@ -130,7 +130,7 @@ SOFTWARE.
130
130
 
131
131
  ----------------------------------------
132
132
 
133
- homegames-common@1.7.5 (MIT)
133
+ homegames-common@1.7.6 (MIT)
134
134
 
135
135
  MIT License
136
136
 
@@ -284,4 +284,4 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
284
284
  SOFTWARE.
285
285
  */
286
286
  /*! For license information please see homegames-client.js.LICENSE.txt */
287
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.HomegamesClient=t():e.HomegamesClient=t()}(this,()=>(()=>{var e={8630(e,t){!function(e){"use strict";var t=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,7,9,32,4,318,1,31,4,33,15,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,199,7,137,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,55,9,7,0,259,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,481,1,61,4,4,5,9,7,3,6,31,3,149,2,12,2,9,1,3,0,33,1,1357,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,233,0,3,0,8,1,6,0,475,6,110,6,6,9,4759,9,787719,239],s=[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,13,65,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,7,25,39,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,5,18,21,18,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,18,0,182,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,24,43,22,0,239,18,16,0,2,12,2,33,125,0,80,921,103,111,6,206,13,310,2314,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,33,24,3,24,45,74,6,0,67,12,65,1,2,0,15,4,10,7386,37,33,96,114,14,913,15,50,7710,3,2,6,2,1,2,296,10,0,30,2,3,0,15,4,8,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,340,2,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,129,15,6,55,50,49,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,208,30,2,2,2,1,2,6,3,4,10,1,225,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4382,2,5773,3,7472,16,621,2467,541,1507,4938,6,8489,39815,11327],r="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆ՘ՙՠ-ֈ֋֌א-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-࢏ࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚ౜ౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽ೜-ೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-ᲊᲐ-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿ₏-₟ℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-꟝꟢꟱-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩ꭬꭭ꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",i={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"},n="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",o={5:n,"5module":n+" export import",6:n+" const class extends export import super"},a=/^in(stanceof)?$/,h=new RegExp("["+r+"]"),l=new RegExp("["+r+"‌‍·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄ-׉ؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࢗ-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୓-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-᫰ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‌‍‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・]");function c(e,t){for(var s=65536,r=0;r<t.length;r+=2){if((s+=t[r])>e)return!1;if((s+=t[r+1])>=e)return!0}return!1}function d(e,t){return e<65?36===e:e<91||(e<97?95===e:e<123||(e<=65535?e>=170&&h.test(String.fromCharCode(e)):!1!==t&&c(e,s)))}function u(e,r){return e<48?36===e:e<58||!(e<65)&&(e<91||(e<97?95===e:e<123||(e<=65535?e>=170&&l.test(String.fromCharCode(e)):!1!==r&&(c(e,s)||c(e,t)))))}var p=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 f(e,t){return new p(e,{beforeExpr:!0,binop:t})}var m={beforeExpr:!0},g={startsExpr:!0},y={};function v(e,t){return void 0===t&&(t={}),t.keyword=e,y[e]=new p(e,t)}var w={num:new p("num",g),regexp:new p("regexp",g),string:new p("string",g),name:new p("name",g),privateId:new p("privateId",g),eof:new p("eof"),bracketL:new p("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new p("]"),braceL:new p("{",{beforeExpr:!0,startsExpr:!0}),braceR:new p("}"),parenL:new p("(",{beforeExpr:!0,startsExpr:!0}),parenR:new p(")"),comma:new p(",",m),semi:new p(";",m),colon:new p(":",m),dot:new p("."),question:new p("?",m),questionDot:new p("?."),arrow:new p("=>",m),template:new p("template"),invalidTemplate:new p("invalidTemplate"),ellipsis:new p("...",m),backQuote:new p("`",g),dollarBraceL:new p("${",{beforeExpr:!0,startsExpr:!0}),eq:new p("=",{beforeExpr:!0,isAssign:!0}),assign:new p("_=",{beforeExpr:!0,isAssign:!0}),incDec:new p("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new p("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:f("||",1),logicalAND:f("&&",2),bitwiseOR:f("|",3),bitwiseXOR:f("^",4),bitwiseAND:f("&",5),equality:f("==/!=/===/!==",6),relational:f("</>/<=/>=",7),bitShift:f("<</>>/>>>",8),plusMin:new p("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:f("%",10),star:f("*",10),slash:f("/",10),starstar:new p("**",{beforeExpr:!0}),coalesce:f("??",1),_break:v("break"),_case:v("case",m),_catch:v("catch"),_continue:v("continue"),_debugger:v("debugger"),_default:v("default",m),_do:v("do",{isLoop:!0,beforeExpr:!0}),_else:v("else",m),_finally:v("finally"),_for:v("for",{isLoop:!0}),_function:v("function",g),_if:v("if"),_return:v("return",m),_switch:v("switch"),_throw:v("throw",m),_try:v("try"),_var:v("var"),_const:v("const"),_while:v("while",{isLoop:!0}),_with:v("with"),_new:v("new",{beforeExpr:!0,startsExpr:!0}),_this:v("this",g),_super:v("super",g),_class:v("class",g),_extends:v("extends",m),_export:v("export"),_import:v("import",g),_null:v("null",g),_true:v("true",g),_false:v("false",g),_in:v("in",{beforeExpr:!0,binop:7}),_instanceof:v("instanceof",{beforeExpr:!0,binop:7}),_typeof:v("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:v("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:v("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},x=/\r\n?|\n|\u2028|\u2029/,b=new RegExp(x.source,"g");function E(e){return 10===e||13===e||8232===e||8233===e}function S(e,t,s){void 0===s&&(s=e.length);for(var r=t;r<s;r++){var i=e.charCodeAt(r);if(E(i))return r<s-1&&13===i&&10===e.charCodeAt(r+1)?r+2:r+1}return-1}var k=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,_=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,C=Object.prototype,A=C.hasOwnProperty,I=C.toString,T=Object.hasOwn||function(e,t){return A.call(e,t)},P=Array.isArray||function(e){return"[object Array]"===I.call(e)},L=Object.create(null);function M(e){return L[e]||(L[e]=new RegExp("^(?:"+e.replace(/ /g,"|")+")$"))}function R(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10),56320+(1023&e)))}var N=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,O=function(e,t){this.line=e,this.column=t};O.prototype.offset=function(e){return new O(this.line,this.column+e)};var U=function(e,t,s){this.start=t,this.end=s,null!==e.sourceFile&&(this.source=e.sourceFile)};function B(e,t){for(var s=1,r=0;;){var i=S(e,r,t);if(i<0)return new O(s,t-r);++s,r=i}}var D={ecmaVersion:null,sourceType:"script",strict:!1,onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowAwaitOutsideFunction:null,allowSuperOutsideMethod:null,allowHashBang:!1,checkPrivateFields:!0,locations:!1,startLocation:null,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},j=!1;function q(e){var t={};for(var s in D)t[s]=e&&T(e,s)?e[s]:D[s];if("latest"===t.ecmaVersion?t.ecmaVersion=1e8:null==t.ecmaVersion?(!j&&"object"==typeof console&&console.warn&&(j=!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),P(t.onToken)){var r=t.onToken;t.onToken=function(e){return r.push(e)}}if(P(t.onComment)&&(t.onComment=function(e,t){return function(s,r,i,n,o,a){var h={type:s?"Block":"Line",value:r,start:i,end:n};e.locations&&(h.loc=new U(this,o,a)),e.ranges&&(h.range=[i,n]),t.push(h)}}(t,t.onComment)),"commonjs"===t.sourceType&&t.allowAwaitOutsideFunction)throw new Error("Cannot use allowAwaitOutsideFunction with sourceType: commonjs");return t}var H=256,V=259;function z(e,t){return 2|(e?4:0)|(t?8:0)}var F=function(e,t,s){this.options=e=q(e),this.sourceFile=e.sourceFile,this.keywords=M(o[e.ecmaVersion>=6?6:"module"===e.sourceType?"5module":5]);var r="";!0!==e.allowReserved&&(r=i[e.ecmaVersion>=6?6:5===e.ecmaVersion?5:3],"module"===e.sourceType&&(r+=" await")),this.reservedWords=M(r);var n=(r?r+" ":"")+i.strict;this.reservedWordsStrict=M(n),this.reservedWordsStrictBind=M(n+" "+i.strictBind),this.input=String(t),this.containsEsc=!1,this.pos=s||0,this.curLine=1,e.startLocation?(this.lineStart=this.pos-e.startLocation.column,this.curLine=e.startLocation.line):s?(this.lineStart=this.input.lastIndexOf("\n",s-1)+1,this.options.locations&&(this.curLine=this.input.slice(0,this.lineStart).split(x).length)):this.lineStart=0,this.type=w.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||!0===e.strict||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("commonjs"===this.options.sourceType?2:1),this.regexpState=null,this.privateNameStack=[]},G={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowReturn:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},allowUsing:{configurable:!0},inClassStaticBlock:{configurable:!0}};F.prototype.parse=function(){var e=this,t=this.options.program||this.startNode();return this.nextToken(),this.catchStackOverflow(function(){return e.parseTopLevel(t)})},G.inFunction.get=function(){return(2&this.currentVarScope().flags)>0},G.inGenerator.get=function(){return(8&this.currentVarScope().flags)>0},G.inAsync.get=function(){return(4&this.currentVarScope().flags)>0},G.canAwait.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(768&t)return!1;if(2&t)return(4&t)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction},G.allowReturn.get=function(){return!!this.inFunction||!!(this.options.allowReturnOutsideFunction&&1&this.currentVarScope().flags)},G.allowSuper.get=function(){return(64&this.currentThisScope().flags)>0||this.options.allowSuperOutsideMethod},G.allowDirectSuper.get=function(){return(128&this.currentThisScope().flags)>0},G.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())},G.allowNewDotTarget.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(768&t||2&t&&!(16&t))return!0}return!1},G.allowUsing.get=function(){var e=this.currentScope().flags;return!(1024&e||!this.inModule&&1&e)},G.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&H)>0},F.extend=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];for(var s=this,r=0;r<e.length;r++)s=e[r](s);return s},F.parse=function(e,t){return new this(t,e).parse()},F.parseExpressionAt=function(e,t,s){var r=new this(s,e,t);return r.nextToken(),r.parseExpression()},F.tokenizer=function(e,t){return new this(t,e)},Object.defineProperties(F.prototype,G);var $=F.prototype,K=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;function W(e,t){for(var s=t+1,r=Math.min(e.input.length,t+11);s<r;){var i=e.fullCharCodeAt(s);if(!u(i,!0))break;s+=i<=65535?1:2}return s===t+2&&"in"===e.input.slice(t,s)||s===t+10&&"instanceof"===e.input.slice(t,s)}$.strictDirective=function(e){if(this.options.ecmaVersion<5)return!1;for(;;){_.lastIndex=e,e+=_.exec(this.input)[0].length;var t=K.exec(this.input.slice(e));if(!t)return!1;if("use strict"===(t[1]||t[2])){_.lastIndex=e+t[0].length;var s=_.exec(this.input),r=s.index+s[0].length,i=this.input.charAt(r);return";"===i||"}"===i||x.test(s[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(i)||"!"===i&&"="===this.input.charAt(r+1)||"i"===i&&W(this,r))}e+=t[0].length,_.lastIndex=e,e+=_.exec(this.input)[0].length,";"===this.input[e]&&e++}},$.eat=function(e){return this.type===e&&(this.next(),!0)},$.isContextual=function(e){return this.type===w.name&&this.value===e&&!this.containsEsc},$.eatContextual=function(e){return!!this.isContextual(e)&&(this.next(),!0)},$.catchStackOverflow=function(e){try{return e()}catch(e){if(!(e instanceof Error&&(/\bstack\b.*\b(exceeded|overflow)\b/i.test(e.message)||/\btoo much recursion\b/i.test(e.message))))throw e;this.raise(this.start,"Not enough stack space to parse input")}},$.expectContextual=function(e){this.eatContextual(e)||this.unexpected()},$.canInsertSemicolon=function(){return this.type===w.eof||this.type===w.braceR||x.test(this.input.slice(this.lastTokEnd,this.start))},$.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},$.semicolon=function(){this.eat(w.semi)||this.insertSemicolon()||this.unexpected()},$.afterTrailingComma=function(e,t){if(this.type===e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),t||this.next(),!0},$.expect=function(e){this.eat(e)||this.unexpected()},$.unexpected=function(e){this.raise(null!=e?e:this.start,"Unexpected token")};var Y=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};$.checkPatternErrors=function(e,t){if(e){e.trailingComma>-1&&this.raiseRecoverable(e.trailingComma,"Comma is not permitted after the rest element");var s=t?e.parenthesizedAssign:e.parenthesizedBind;s>-1&&this.raiseRecoverable(s,t?"Assigning to rvalue":"Parenthesized pattern")}},$.checkExpressionErrors=function(e,t){if(!e)return!1;var s=e.shorthandAssign,r=e.doubleProto;if(!t)return s>=0||r>=0;s>=0&&this.raise(s,"Shorthand property assignments are valid only in destructuring patterns"),r>=0&&this.raiseRecoverable(r,"Redefinition of __proto__ property")},$.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")},$.isSimpleAssignTarget=function(e){return"ParenthesizedExpression"===e.type?this.isSimpleAssignTarget(e.expression):"Identifier"===e.type||"MemberExpression"===e.type};var J=F.prototype;J.parseTopLevel=function(e){var t=Object.create(null);for(e.body||(e.body=[]);this.type!==w.eof;){var s=this.parseStatement(null,!0,t);e.body.push(s)}if(this.inModule)for(var r=0,i=Object.keys(this.undefinedExports);r<i.length;r+=1){var n=i[r];this.raiseRecoverable(this.undefinedExports[n].start,"Export '"+n+"' is not defined")}return this.adaptDirectivePrologue(e.body),this.next(),e.sourceType="commonjs"===this.options.sourceType?"script":this.options.sourceType,this.finishNode(e,"Program")};var X={kind:"loop"},Z={kind:"switch"};J.isLet=function(e){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;_.lastIndex=this.pos;var t=_.exec(this.input),s=this.pos+t[0].length,r=this.fullCharCodeAt(s);if(91===r||92===r)return!0;if(e)return!1;if(123===r)return!0;if(d(r)){var i=s;do{s+=r<=65535?1:2}while(u(r=this.fullCharCodeAt(s)));if(92===r)return!0;var n=this.input.slice(i,s);if(!a.test(n))return!0}return!1},J.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;_.lastIndex=this.pos;var e,t=_.exec(this.input),s=this.pos+t[0].length;return!(x.test(this.input.slice(this.pos,s))||"function"!==this.input.slice(s,s+8)||s+8!==this.input.length&&(u(e=this.fullCharCodeAt(s+8))||92===e))},J.isUsingKeyword=function(e,t){if(this.options.ecmaVersion<17||!this.isContextual(e?"await":"using"))return!1;_.lastIndex=this.pos;var s=_.exec(this.input),r=this.pos+s[0].length;if(x.test(this.input.slice(this.pos,r)))return!1;if(e){var i,n=r+5;if("using"!==this.input.slice(r,n)||n===this.input.length||u(i=this.fullCharCodeAt(n))||92===i)return!1;_.lastIndex=n;var o=_.exec(this.input);if(r=n+o[0].length,o&&x.test(this.input.slice(n,r)))return!1}var h=this.fullCharCodeAt(r);if(!d(h)&&92!==h)return!1;var l=r;do{r+=h<=65535?1:2}while(u(h=this.fullCharCodeAt(r)));if(92===h)return!0;var c=this.input.slice(l,r);return!(a.test(c)||t&&!e&&"of"===c&&(_.lastIndex=r,r+=_.exec(this.input)[0].length,61!==this.input.charCodeAt(r)||61===(h=this.input.charCodeAt(r+1))||62===h))},J.isAwaitUsing=function(e){return this.isUsingKeyword(!0,e)},J.isUsing=function(e){return this.isUsingKeyword(!1,e)},J.parseStatement=function(e,t,s){var r,i=this.type,n=this.startNode();switch(this.isLet(e)&&(i=w._var,r="let"),i){case w._break:case w._continue:return this.parseBreakContinueStatement(n,i.keyword);case w._debugger:return this.parseDebuggerStatement(n);case w._do:return this.parseDoStatement(n);case w._for:return this.parseForStatement(n);case w._function:return e&&(this.strict||"if"!==e&&"label"!==e)&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(n,!1,!e);case w._class:return e&&this.unexpected(),this.parseClass(n,!0);case w._if:return this.parseIfStatement(n);case w._return:return this.parseReturnStatement(n);case w._switch:return this.parseSwitchStatement(n);case w._throw:return this.parseThrowStatement(n);case w._try:return this.parseTryStatement(n);case w._const:case w._var:return r=r||this.value,e&&"var"!==r&&this.unexpected(),this.parseVarStatement(n,r);case w._while:return this.parseWhileStatement(n);case w._with:return this.parseWithStatement(n);case w.braceL:return this.parseBlock(!0,n);case w.semi:return this.parseEmptyStatement(n);case w._export:case w._import:if(this.options.ecmaVersion>10&&i===w._import){_.lastIndex=this.pos;var o=_.exec(this.input),a=this.pos+o[0].length,h=this.input.charCodeAt(a);if(40===h||46===h)return this.parseExpressionStatement(n,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===w._import?this.parseImport(n):this.parseExport(n,s);default:if(this.isAsyncFunction())return e&&this.unexpected(),this.next(),this.parseFunctionStatement(n,!0,!e);var l=this.isAwaitUsing(!1)?"await using":this.isUsing(!1)?"using":null;if(l)return this.allowUsing||this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script` or in the bare case statement"),e&&this.raise(this.start,"Using declaration is not allowed in single-statement positions"),"await using"===l&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.next(),this.parseVar(n,!1,l),this.semicolon(),this.finishNode(n,"VariableDeclaration");var c=this.value,d=this.parseExpression();return i===w.name&&"Identifier"===d.type&&this.eat(w.colon)?this.parseLabeledStatement(n,c,d,e):this.parseExpressionStatement(n,d)}},J.parseBreakContinueStatement=function(e,t){var s="break"===t;this.next(),this.eat(w.semi)||this.insertSemicolon()?e.label=null:this.type!==w.name?this.unexpected():(e.label=this.parseIdent(),this.semicolon());for(var r=0;r<this.labels.length;++r){var i=this.labels[r];if(null==e.label||i.name===e.label.name){if(null!=i.kind&&(s||"loop"===i.kind))break;if(e.label&&s)break}}return r===this.labels.length&&this.raise(e.start,"Unsyntactic "+t),this.finishNode(e,s?"BreakStatement":"ContinueStatement")},J.parseDebuggerStatement=function(e){return this.next(),this.semicolon(),this.finishNode(e,"DebuggerStatement")},J.parseDoStatement=function(e){return this.next(),this.labels.push(X),e.body=this.parseStatement("do"),this.labels.pop(),this.expect(w._while),e.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(w.semi):this.semicolon(),this.finishNode(e,"DoWhileStatement")},J.parseForStatement=function(e){this.next();var t=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(X),this.enterScope(0),this.expect(w.parenL),this.type===w.semi)return t>-1&&this.unexpected(t),this.parseFor(e,null);var s=this.isLet();if(this.type===w._var||this.type===w._const||s){var r=this.startNode(),i=s?"let":this.value;return this.next(),this.parseVar(r,!0,i),this.finishNode(r,"VariableDeclaration"),this.parseForAfterInit(e,r,t)}var n=this.isContextual("let"),o=!1,a=this.isUsing(!0)?"using":this.isAwaitUsing(!0)?"await using":null;if(a){var h=this.startNode();return this.next(),"await using"===a&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.parseVar(h,!0,a),this.finishNode(h,"VariableDeclaration"),this.parseForAfterInit(e,h,t)}var l=this.containsEsc,c=new Y,d=this.start,u=t>-1?this.parseExprSubscripts(c,"await"):this.parseExpression(!0,c);return this.type===w._in||(o=this.options.ecmaVersion>=6&&this.isContextual("of"))?(t>-1?(this.type===w._in&&this.unexpected(t),e.await=!0):o&&this.options.ecmaVersion>=8&&(u.start!==d||l||"Identifier"!==u.type||"async"!==u.name?this.options.ecmaVersion>=9&&(e.await=!1):this.unexpected()),n&&o&&this.raise(u.start,"The left-hand side of a for-of loop may not start with 'let'."),this.toAssignable(u,!1,c),this.checkLValPattern(u),this.parseForIn(e,u)):(this.checkExpressionErrors(c,!0),t>-1&&this.unexpected(t),this.parseFor(e,u))},J.parseForAfterInit=function(e,t,s){return(this.type===w._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&1===t.declarations.length?(this.type===w._in?("using"!==t.kind&&"await using"!==t.kind||t.declarations[0].init||this.raise(this.start,"Using declaration is not allowed in for-in loops"),this.options.ecmaVersion>=9&&s>-1&&this.unexpected(s)):this.options.ecmaVersion>=9&&(e.await=s>-1),this.parseForIn(e,t)):(s>-1&&this.unexpected(s),this.parseFor(e,t))},J.parseFunctionStatement=function(e,t,s){return this.next(),this.parseFunction(e,ee|(s?0:te),!1,t)},J.parseIfStatement=function(e){return this.next(),e.test=this.parseParenExpression(),e.consequent=this.parseStatement("if"),e.alternate=this.eat(w._else)?this.parseStatement("if"):null,this.finishNode(e,"IfStatement")},J.parseReturnStatement=function(e){return this.allowReturn||this.raise(this.start,"'return' outside of function"),this.next(),this.eat(w.semi)||this.insertSemicolon()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,"ReturnStatement")},J.parseSwitchStatement=function(e){var t;this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(w.braceL),this.labels.push(Z),this.enterScope(1024);for(var s=!1;this.type!==w.braceR;)if(this.type===w._case||this.type===w._default){var r=this.type===w._case;t&&this.finishNode(t,"SwitchCase"),e.cases.push(t=this.startNode()),t.consequent=[],this.next(),r?t.test=this.parseExpression():(s&&this.raiseRecoverable(this.lastTokStart,"Multiple default clauses"),s=!0,t.test=null),this.expect(w.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")},J.parseThrowStatement=function(e){return this.next(),x.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 Q=[];J.parseCatchClauseParam=function(){var e=this.parseBindingAtom(),t="Identifier"===e.type;return this.enterScope(t?32:0),this.checkLValPattern(e,t?4:2),this.expect(w.parenR),e},J.parseTryStatement=function(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.type===w._catch){var t=this.startNode();this.next(),this.eat(w.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(w._finally)?this.parseBlock():null,e.handler||e.finalizer||this.raise(e.start,"Missing catch or finally clause"),this.finishNode(e,"TryStatement")},J.parseVarStatement=function(e,t,s){return this.next(),this.parseVar(e,!1,t,s),this.semicolon(),this.finishNode(e,"VariableDeclaration")},J.parseWhileStatement=function(e){return this.next(),e.test=this.parseParenExpression(),this.labels.push(X),e.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(e,"WhileStatement")},J.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")},J.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,"EmptyStatement")},J.parseLabeledStatement=function(e,t,s,r){for(var i=0,n=this.labels;i<n.length;i+=1)n[i].name===t&&this.raise(s.start,"Label '"+t+"' is already declared");for(var o=this.type.isLoop?"loop":this.type===w._switch?"switch":null,a=this.labels.length-1;a>=0;a--){var h=this.labels[a];if(h.statementStart!==e.start)break;h.statementStart=this.start,h.kind=o}return this.labels.push({name:t,kind:o,statementStart:this.start}),e.body=this.parseStatement(r?-1===r.indexOf("label")?r+"label":r:"label"),this.labels.pop(),e.label=s,this.finishNode(e,"LabeledStatement")},J.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,"ExpressionStatement")},J.parseBlock=function(e,t,s){for(void 0===e&&(e=!0),void 0===t&&(t=this.startNode()),t.body=[],this.expect(w.braceL),e&&this.enterScope(0);this.type!==w.braceR;){var r=this.parseStatement(null);t.body.push(r)}return s&&(this.strict=!1),this.next(),e&&this.exitScope(),this.finishNode(t,"BlockStatement")},J.parseFor=function(e,t){return e.init=t,this.expect(w.semi),e.test=this.type===w.semi?null:this.parseExpression(),this.expect(w.semi),e.update=this.type===w.parenR?null:this.parseExpression(),this.expect(w.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,"ForStatement")},J.parseForIn=function(e,t){var s=this.type===w._in;return this.next(),"VariableDeclaration"===t.type&&null!=t.declarations[0].init&&(!s||this.options.ecmaVersion<8||this.strict||"var"!==t.kind||"Identifier"!==t.declarations[0].id.type)&&this.raise(t.start,(s?"for-in":"for-of")+" loop variable declaration may not have an initializer"),e.left=t,e.right=s?this.parseExpression():this.parseMaybeAssign(),this.expect(w.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,s?"ForInStatement":"ForOfStatement")},J.parseVar=function(e,t,s,r){for(e.declarations=[],e.kind=s;;){var i=this.startNode();if(this.parseVarId(i,s),this.eat(w.eq)?i.init=this.parseMaybeAssign(t):r||"const"!==s||this.type===w._in||this.options.ecmaVersion>=6&&this.isContextual("of")?r||"using"!==s&&"await using"!==s||!(this.options.ecmaVersion>=17)||this.type===w._in||this.isContextual("of")?r||"Identifier"===i.id.type||t&&(this.type===w._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 "+s+" declaration"):this.unexpected(),e.declarations.push(this.finishNode(i,"VariableDeclarator")),!this.eat(w.comma))break}return e},J.parseVarId=function(e,t){e.id="using"===t||"await using"===t?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(e.id,"var"===t?1:2,!1)};var ee=1,te=2;function se(e,t){var s=t.key.name,r=e[s],i="true";return"MethodDefinition"!==t.type||"get"!==t.kind&&"set"!==t.kind||(i=(t.static?"s":"i")+t.kind),"iget"===r&&"iset"===i||"iset"===r&&"iget"===i||"sget"===r&&"sset"===i||"sset"===r&&"sget"===i?(e[s]="true",!1):!!r||(e[s]=i,!1)}function re(e,t){var s=e.computed,r=e.key;return!s&&("Identifier"===r.type&&r.name===t||"Literal"===r.type&&r.value===t)}J.parseFunction=function(e,t,s,r,i){this.initFunction(e),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!r)&&(this.type===w.star&&t&te&&this.unexpected(),e.generator=this.eat(w.star)),this.options.ecmaVersion>=8&&(e.async=!!r),t&ee&&(e.id=4&t&&this.type!==w.name?null:this.parseIdent(),!e.id||t&te||this.checkLValSimple(e.id,this.strict||e.generator||e.async?this.treatFunctionsAsVar?1:2:3));var n=this.yieldPos,o=this.awaitPos,a=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(z(e.async,e.generator)),t&ee||(e.id=this.type===w.name?this.parseIdent():null),this.parseFunctionParams(e),this.parseFunctionBody(e,s,!1,i),this.yieldPos=n,this.awaitPos=o,this.awaitIdentPos=a,this.finishNode(e,t&ee?"FunctionDeclaration":"FunctionExpression")},J.parseFunctionParams=function(e){this.expect(w.parenL),e.params=this.parseBindingList(w.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},J.parseClass=function(e,t){this.next();var s=this.strict;this.strict=!0,this.parseClassId(e,t),this.parseClassSuper(e);var r=this.enterClassBody(),i=this.startNode(),n=!1;for(i.body=[],this.expect(w.braceL);this.type!==w.braceR;){var o=this.parseClassElement(null!==e.superClass);o&&(i.body.push(o),"MethodDefinition"===o.type&&"constructor"===o.kind?(n&&this.raiseRecoverable(o.start,"Duplicate constructor in the same class"),n=!0):o.key&&"PrivateIdentifier"===o.key.type&&se(r,o)&&this.raiseRecoverable(o.key.start,"Identifier '#"+o.key.name+"' has already been declared"))}return this.strict=s,this.next(),e.body=this.finishNode(i,"ClassBody"),this.exitClassBody(),this.finishNode(e,t?"ClassDeclaration":"ClassExpression")},J.parseClassElement=function(e){if(this.eat(w.semi))return null;var t=this.options.ecmaVersion,s=this.startNode(),r="",i=!1,n=!1,o="method",a=!1;if(this.eatContextual("static")){if(t>=13&&this.eat(w.braceL))return this.parseClassStaticBlock(s),s;this.isClassElementNameStart()||this.type===w.star?a=!0:r="static"}if(s.static=a,!r&&t>=8&&this.eatContextual("async")&&(!this.isClassElementNameStart()&&this.type!==w.star||this.canInsertSemicolon()?r="async":n=!0),!r&&(t>=9||!n)&&this.eat(w.star)&&(i=!0),!r&&!n&&!i){var h=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?o=h:r=h)}if(r?(s.computed=!1,s.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),s.key.name=r,this.finishNode(s.key,"Identifier")):this.parseClassElementName(s),t<13||this.type===w.parenL||"method"!==o||i||n){var l=!s.static&&re(s,"constructor"),c=l&&e;l&&"method"!==o&&this.raise(s.key.start,"Constructor can't have get/set modifier"),s.kind=l?"constructor":o,this.parseClassMethod(s,i,n,c)}else this.parseClassField(s);return s},J.isClassElementNameStart=function(){return this.type===w.name||this.type===w.privateId||this.type===w.num||this.type===w.string||this.type===w.bracketL||this.type.keyword},J.parseClassElementName=function(e){this.type===w.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)},J.parseClassMethod=function(e,t,s,r){var i=e.key;"constructor"===e.kind?(t&&this.raise(i.start,"Constructor can't be a generator"),s&&this.raise(i.start,"Constructor can't be an async method")):e.static&&re(e,"prototype")&&this.raise(i.start,"Classes may not have a static property named prototype");var n=e.value=this.parseMethod(t,s,r);return"get"===e.kind&&0!==n.params.length&&this.raiseRecoverable(n.start,"getter should have no params"),"set"===e.kind&&1!==n.params.length&&this.raiseRecoverable(n.start,"setter should have exactly one param"),"set"===e.kind&&"RestElement"===n.params[0].type&&this.raiseRecoverable(n.params[0].start,"Setter cannot use rest params"),this.finishNode(e,"MethodDefinition")},J.parseClassField=function(e){return re(e,"constructor")?this.raise(e.key.start,"Classes can't have a field named 'constructor'"):e.static&&re(e,"prototype")&&this.raise(e.key.start,"Classes can't have a static field named 'prototype'"),this.eat(w.eq)?(this.enterScope(576),e.value=this.parseMaybeAssign(),this.exitScope()):e.value=null,this.semicolon(),this.finishNode(e,"PropertyDefinition")},J.parseClassStaticBlock=function(e){e.body=[];var t=this.labels;for(this.labels=[],this.enterScope(320);this.type!==w.braceR;){var s=this.parseStatement(null);e.body.push(s)}return this.next(),this.exitScope(),this.labels=t,this.finishNode(e,"StaticBlock")},J.parseClassId=function(e,t){this.type===w.name?(e.id=this.parseIdent(),t&&this.checkLValSimple(e.id,2,!1)):(!0===t&&this.unexpected(),e.id=null)},J.parseClassSuper=function(e){e.superClass=this.eat(w._extends)?this.parseExprSubscripts(null,!1):null},J.enterClassBody=function(){var e={declared:Object.create(null),used:[]};return this.privateNameStack.push(e),e.declared},J.exitClassBody=function(){var e=this.privateNameStack.pop(),t=e.declared,s=e.used;if(this.options.checkPrivateFields)for(var r=this.privateNameStack.length,i=0===r?null:this.privateNameStack[r-1],n=0;n<s.length;++n){var o=s[n];T(t,o.name)||(i?i.used.push(o):this.raiseRecoverable(o.start,"Private field '#"+o.name+"' must be declared in an enclosing class"))}},J.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!==w.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ExportAllDeclaration")},J.parseExport=function(e,t){if(this.next(),this.eat(w.star))return this.parseExportAllDeclaration(e,t);if(this.eat(w._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!==w.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause());else{for(var s=0,r=e.specifiers;s<r.length;s+=1){var i=r[s];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")},J.parseExportDeclaration=function(e){return this.parseStatement(null)},J.parseExportDefaultDeclaration=function(){var e;if(this.type===w._function||(e=this.isAsyncFunction())){var t=this.startNode();return this.next(),e&&this.next(),this.parseFunction(t,4|ee,!1,e)}if(this.type===w._class){var s=this.startNode();return this.parseClass(s,"nullableID")}var r=this.parseMaybeAssign();return this.semicolon(),r},J.checkExport=function(e,t,s){e&&("string"!=typeof t&&(t="Identifier"===t.type?t.name:t.value),T(e,t)&&this.raiseRecoverable(s,"Duplicate export '"+t+"'"),e[t]=!0)},J.checkPatternExport=function(e,t){var s=t.type;if("Identifier"===s)this.checkExport(e,t,t.start);else if("ObjectPattern"===s)for(var r=0,i=t.properties;r<i.length;r+=1){var n=i[r];this.checkPatternExport(e,n)}else if("ArrayPattern"===s)for(var o=0,a=t.elements;o<a.length;o+=1){var h=a[o];h&&this.checkPatternExport(e,h)}else"Property"===s?this.checkPatternExport(e,t.value):"AssignmentPattern"===s?this.checkPatternExport(e,t.left):"RestElement"===s&&this.checkPatternExport(e,t.argument)},J.checkVariableExport=function(e,t){if(e)for(var s=0,r=t;s<r.length;s+=1){var i=r[s];this.checkPatternExport(e,i.id)}},J.shouldParseExportStatement=function(){return"var"===this.type.keyword||"const"===this.type.keyword||"class"===this.type.keyword||"function"===this.type.keyword||this.isLet()||this.isAsyncFunction()},J.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")},J.parseExportSpecifiers=function(e){var t=[],s=!0;for(this.expect(w.braceL);!this.eat(w.braceR);){if(s)s=!1;else if(this.expect(w.comma),this.afterTrailingComma(w.braceR))break;t.push(this.parseExportSpecifier(e))}return t},J.parseImport=function(e){return this.next(),this.type===w.string?(e.specifiers=Q,e.source=this.parseExprAtom()):(e.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),e.source=this.type===w.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ImportDeclaration")},J.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,2),this.finishNode(e,"ImportSpecifier")},J.parseImportDefaultSpecifier=function(){var e=this.startNode();return e.local=this.parseIdent(),this.checkLValSimple(e.local,2),this.finishNode(e,"ImportDefaultSpecifier")},J.parseImportNamespaceSpecifier=function(){var e=this.startNode();return this.next(),this.expectContextual("as"),e.local=this.parseIdent(),this.checkLValSimple(e.local,2),this.finishNode(e,"ImportNamespaceSpecifier")},J.parseImportSpecifiers=function(){var e=[],t=!0;if(this.type===w.name&&(e.push(this.parseImportDefaultSpecifier()),!this.eat(w.comma)))return e;if(this.type===w.star)return e.push(this.parseImportNamespaceSpecifier()),e;for(this.expect(w.braceL);!this.eat(w.braceR);){if(t)t=!1;else if(this.expect(w.comma),this.afterTrailingComma(w.braceR))break;e.push(this.parseImportSpecifier())}return e},J.parseWithClause=function(){var e=[];if(!this.eat(w._with))return e;this.expect(w.braceL);for(var t={},s=!0;!this.eat(w.braceR);){if(s)s=!1;else if(this.expect(w.comma),this.afterTrailingComma(w.braceR))break;var r=this.parseImportAttribute(),i="Identifier"===r.key.type?r.key.name:r.key.value;T(t,i)&&this.raiseRecoverable(r.key.start,"Duplicate attribute key '"+i+"'"),t[i]=!0,e.push(r)}return e},J.parseImportAttribute=function(){var e=this.startNode();return e.key=this.type===w.string?this.parseExprAtom():this.parseIdent("never"!==this.options.allowReserved),this.expect(w.colon),this.type!==w.string&&this.unexpected(),e.value=this.parseExprAtom(),this.finishNode(e,"ImportAttribute")},J.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===w.string){var e=this.parseLiteral(this.value);return N.test(e.value)&&this.raise(e.start,"An export name cannot include a lone surrogate."),e}return this.parseIdent(!0)},J.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)},J.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=F.prototype;ie.toAssignable=function(e,t,s){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",s&&this.checkPatternErrors(s,!0);for(var r=0,i=e.properties;r<i.length;r+=1){var n=i[r];this.toAssignable(n,t),"RestElement"!==n.type||"ArrayPattern"!==n.argument.type&&"ObjectPattern"!==n.argument.type||this.raise(n.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",s&&this.checkPatternErrors(s,!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,s);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 s&&this.checkPatternErrors(s,!0);return e},ie.toAssignableList=function(e,t){for(var s=e.length,r=0;r<s;r++){var i=e[r];i&&this.toAssignable(i,t)}if(s){var n=e[s-1];6===this.options.ecmaVersion&&t&&n&&"RestElement"===n.type&&"Identifier"!==n.argument.type&&this.unexpected(n.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!==w.name&&this.unexpected(),e.argument=this.parseBindingAtom(),this.finishNode(e,"RestElement")},ie.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case w.bracketL:var e=this.startNode();return this.next(),e.elements=this.parseBindingList(w.bracketR,!0,!0),this.finishNode(e,"ArrayPattern");case w.braceL:return this.parseObj(!0)}return this.parseIdent()},ie.parseBindingList=function(e,t,s,r){for(var i=[],n=!0;!this.eat(e);)if(n?n=!1:this.expect(w.comma),t&&this.type===w.comma)i.push(null);else{if(s&&this.afterTrailingComma(e))break;if(this.type===w.ellipsis){var o=this.parseRestBinding();this.parseBindingListItem(o),i.push(o),this.type===w.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.expect(e);break}i.push(this.parseAssignableListItem(r))}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,s){if(s=s||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(w.eq))return s;var r=this.startNodeAt(e,t);return r.left=s,r.right=this.parseMaybeAssign(),this.finishNode(r,"AssignmentPattern")},ie.checkLValSimple=function(e,t,s){void 0===t&&(t=0);var r=0!==t;switch(e.type){case"Identifier":this.strict&&this.reservedWordsStrictBind.test(e.name)&&this.raiseRecoverable(e.start,(r?"Binding ":"Assigning to ")+e.name+" in strict mode"),r&&(2===t&&"let"===e.name&&this.raiseRecoverable(e.start,"let is disallowed as a lexically bound name"),s&&(T(s,e.name)&&this.raiseRecoverable(e.start,"Argument name clash"),s[e.name]=!0),5!==t&&this.declareName(e.name,t,e.start));break;case"ChainExpression":this.raiseRecoverable(e.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":r&&this.raiseRecoverable(e.start,"Binding member expression");break;case"ParenthesizedExpression":return r&&this.raiseRecoverable(e.start,"Binding parenthesized expression"),this.checkLValSimple(e.expression,t,s);default:this.raise(e.start,(r?"Binding":"Assigning to")+" rvalue")}},ie.checkLValPattern=function(e,t,s){switch(void 0===t&&(t=0),e.type){case"ObjectPattern":for(var r=0,i=e.properties;r<i.length;r+=1){var n=i[r];this.checkLValInnerPattern(n,t,s)}break;case"ArrayPattern":for(var o=0,a=e.elements;o<a.length;o+=1){var h=a[o];h&&this.checkLValInnerPattern(h,t,s)}break;default:this.checkLValSimple(e,t,s)}},ie.checkLValInnerPattern=function(e,t,s){switch(void 0===t&&(t=0),e.type){case"Property":this.checkLValInnerPattern(e.value,t,s);break;case"AssignmentPattern":this.checkLValPattern(e.left,t,s);break;case"RestElement":this.checkLValPattern(e.argument,t,s);break;default:this.checkLValPattern(e,t,s)}};var ne=function(e,t,s,r,i){this.token=e,this.isExpr=!!t,this.preserveSpace=!!s,this.override=r,this.generator=!!i},oe={b_stat:new ne("{",!1),b_expr:new ne("{",!0),b_tmpl:new ne("${",!1),p_stat:new ne("(",!1),p_expr:new ne("(",!0),q_tmpl:new ne("`",!0,!0,function(e){return e.tryReadTemplateToken()}),f_stat:new ne("function",!1),f_expr:new ne("function",!0),f_expr_gen:new ne("function",!0,!1,null,!0),f_gen:new ne("function",!1,!1,null,!0)},ae=F.prototype;ae.initialContext=function(){return[oe.b_stat]},ae.curContext=function(){return this.context[this.context.length-1]},ae.braceIsBlock=function(e){var t=this.curContext();return t===oe.f_expr||t===oe.f_stat||(e!==w.colon||t!==oe.b_stat&&t!==oe.b_expr?e===w._return||e===w.name&&this.exprAllowed?x.test(this.input.slice(this.lastTokEnd,this.start)):e===w._else||e===w.semi||e===w.eof||e===w.parenR||e===w.arrow||(e===w.braceL?t===oe.b_stat:e!==w._var&&e!==w._const&&e!==w.name&&!this.exprAllowed):!t.isExpr)},ae.inGeneratorContext=function(){for(var e=this.context.length-1;e>=1;e--){var t=this.context[e];if("function"===t.token)return t.generator}return!1},ae.updateContext=function(e){var t,s=this.type;s.keyword&&e===w.dot?this.exprAllowed=!1:(t=s.updateContext)?t.call(this,e):this.exprAllowed=s.beforeExpr},ae.overrideContext=function(e){this.curContext()!==e&&(this.context[this.context.length-1]=e)},w.parenR.updateContext=w.braceR.updateContext=function(){if(1!==this.context.length){var e=this.context.pop();e===oe.b_stat&&"function"===this.curContext().token&&(e=this.context.pop()),this.exprAllowed=!e.isExpr}else this.exprAllowed=!0},w.braceL.updateContext=function(e){this.context.push(this.braceIsBlock(e)?oe.b_stat:oe.b_expr),this.exprAllowed=!0},w.dollarBraceL.updateContext=function(){this.context.push(oe.b_tmpl),this.exprAllowed=!0},w.parenL.updateContext=function(e){var t=e===w._if||e===w._for||e===w._with||e===w._while;this.context.push(t?oe.p_stat:oe.p_expr),this.exprAllowed=!0},w.incDec.updateContext=function(){},w._function.updateContext=w._class.updateContext=function(e){!e.beforeExpr||e===w._else||e===w.semi&&this.curContext()!==oe.p_stat||e===w._return&&x.test(this.input.slice(this.lastTokEnd,this.start))||(e===w.colon||e===w.braceL)&&this.curContext()===oe.b_stat?this.context.push(oe.f_stat):this.context.push(oe.f_expr),this.exprAllowed=!1},w.colon.updateContext=function(){"function"===this.curContext().token&&this.context.pop(),this.exprAllowed=!0},w.backQuote.updateContext=function(){this.curContext()===oe.q_tmpl?this.context.pop():this.context.push(oe.q_tmpl),this.exprAllowed=!1},w.star.updateContext=function(e){if(e===w._function){var t=this.context.length-1;this.context[t]===oe.f_expr?this.context[t]=oe.f_expr_gen:this.context[t]=oe.f_gen}this.exprAllowed=!0},w.name.updateContext=function(e){var t=!1;this.options.ecmaVersion>=6&&e!==w.dot&&("of"===this.value&&!this.exprAllowed||"yield"===this.value&&this.inGeneratorContext())&&(t=!0),this.exprAllowed=t};var he=F.prototype;function le(e){return"Identifier"===e.type||"ParenthesizedExpression"===e.type&&le(e.expression)}function ce(e){return"MemberExpression"===e.type&&"PrivateIdentifier"===e.property.type||"ChainExpression"===e.type&&ce(e.expression)||"ParenthesizedExpression"===e.type&&ce(e.expression)}he.checkPropClash=function(e,t,s){if(!(this.options.ecmaVersion>=9&&"SpreadElement"===e.type||this.options.ecmaVersion>=6&&(e.computed||e.method||e.shorthand))){var r,i=e.key;switch(i.type){case"Identifier":r=i.name;break;case"Literal":r=String(i.value);break;default:return}var n=e.kind;if(this.options.ecmaVersion>=6)"__proto__"===r&&"init"===n&&(t.proto&&(s?s.doubleProto<0&&(s.doubleProto=i.start):this.raiseRecoverable(i.start,"Redefinition of __proto__ property")),t.proto=!0);else{var o=t[r="$"+r];o?("init"===n?this.strict&&o.init||o.get||o.set:o.init||o[n])&&this.raiseRecoverable(i.start,"Redefinition of property"):o=t[r]={init:!1,get:!1,set:!1},o[n]=!0}}},he.parseExpression=function(e,t){var s=this;return this.catchStackOverflow(function(){var r=s.start,i=s.startLoc,n=s.parseMaybeAssign(e,t);if(s.type===w.comma){var o=s.startNodeAt(r,i);for(o.expressions=[n];s.eat(w.comma);)o.expressions.push(s.parseMaybeAssign(e,t));return s.finishNode(o,"SequenceExpression")}return n})},he.parseMaybeAssign=function(e,t,s){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(e);this.exprAllowed=!1}var r=!1,i=-1,n=-1,o=-1;t?(i=t.parenthesizedAssign,n=t.trailingComma,o=t.doubleProto,t.parenthesizedAssign=t.trailingComma=-1):(t=new Y,r=!0);var a=this.start,h=this.startLoc;this.type!==w.parenL&&this.type!==w.name||(this.potentialArrowAt=this.start,this.potentialArrowInForAwait="await"===e);var l=this.parseMaybeConditional(e,t);if(s&&(l=s.call(this,l,a,h)),this.type.isAssign){var c=this.startNodeAt(a,h);return c.operator=this.value,this.type===w.eq&&(l=this.toAssignable(l,!1,t)),r||(t.parenthesizedAssign=t.trailingComma=-1,t.shorthandAssign>=l.start&&(t.shorthandAssign=-1),t.doubleProto>=l.start&&(t.doubleProto=-1)),this.type===w.eq?this.checkLValPattern(l):this.checkLValSimple(l),c.left=l,this.next(),c.right=this.parseMaybeAssign(e),o>-1&&(t.doubleProto=o),this.finishNode(c,"AssignmentExpression")}return r&&this.checkExpressionErrors(t,!0),i>-1&&(t.parenthesizedAssign=i),n>-1&&(t.trailingComma=n),l},he.parseMaybeConditional=function(e,t){var s=this.start,r=this.startLoc,i=this.parseExprOps(e,t);if(this.checkExpressionErrors(t))return i;if(("ArrowFunctionExpression"!==i.type||i.start!==s)&&this.eat(w.question)){var n=this.startNodeAt(s,r);return n.test=i,n.consequent=this.parseMaybeAssign(),this.expect(w.colon),n.alternate=this.parseMaybeAssign(e),this.finishNode(n,"ConditionalExpression")}return i},he.parseExprOps=function(e,t){var s=this.start,r=this.startLoc,i=this.parseMaybeUnary(t,!1,!1,e);return this.checkExpressionErrors(t)||i.start===s&&"ArrowFunctionExpression"===i.type?i:this.parseExprOp(i,s,r,-1,e)},he.parseExprOp=function(e,t,s,r,i){var n=this.type.binop;if(null!=n&&(!i||this.type!==w._in)&&n>r){var o=this.type===w.logicalOR||this.type===w.logicalAND,a=this.type===w.coalesce;a&&(n=w.logicalAND.binop);var h=this.value;this.next();var l=this.start,c=this.startLoc,d=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,i),l,c,n,i),u=this.buildBinary(t,s,e,d,h,o||a);return(o&&this.type===w.coalesce||a&&(this.type===w.logicalOR||this.type===w.logicalAND))&&this.raiseRecoverable(this.start,"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"),this.parseExprOp(u,t,s,r,i)}return e},he.buildBinary=function(e,t,s,r,i,n){"PrivateIdentifier"===r.type&&this.raise(r.start,"Private identifier can only be left side of binary expression");var o=this.startNodeAt(e,t);return o.left=s,o.operator=i,o.right=r,this.finishNode(o,n?"LogicalExpression":"BinaryExpression")},he.parseMaybeUnary=function(e,t,s,r){var i,n=this.start,o=this.startLoc;if(this.isContextual("await")&&this.canAwait)i=this.parseAwait(r),t=!0;else if(this.type.prefix){var a=this.startNode(),h=this.type===w.incDec;a.operator=this.value,a.prefix=!0,this.next(),a.argument=this.parseMaybeUnary(null,!0,h,r),this.checkExpressionErrors(e,!0),h?this.checkLValSimple(a.argument):this.strict&&"delete"===a.operator&&le(a.argument)?this.raiseRecoverable(a.start,"Deleting local variable in strict mode"):"delete"===a.operator&&ce(a.argument)?this.raiseRecoverable(a.start,"Private fields can not be deleted"):t=!0,i=this.finishNode(a,h?"UpdateExpression":"UnaryExpression")}else if(t||this.type!==w.privateId){if(i=this.parseExprSubscripts(e,r),this.checkExpressionErrors(e))return i;for(;this.type.postfix&&!this.canInsertSemicolon();){var l=this.startNodeAt(n,o);l.operator=this.value,l.prefix=!1,l.argument=i,this.checkLValSimple(i),this.next(),i=this.finishNode(l,"UpdateExpression")}}else(r||0===this.privateNameStack.length)&&this.options.checkPrivateFields&&this.unexpected(),i=this.parsePrivateIdent(),this.type!==w._in&&this.unexpected();return s||"ArrowFunctionExpression"===i.type&&i.start===n||!this.eat(w.starstar)?i:t?void this.unexpected(this.lastTokStart):this.buildBinary(n,o,i,this.parseMaybeUnary(null,!1,!1,r),"**",!1)},he.parseExprSubscripts=function(e,t){var s=this.start,r=this.startLoc,i=-1,n=-1;e&&(i=e.doubleProto,n=e.shorthandAssign,e.doubleProto=e.shorthandAssign=-1);var o=this.parseExprAtom(e,t);if("ArrowFunctionExpression"===o.type&&")"!==this.input.slice(this.lastTokStart,this.lastTokEnd))return o;var a=this.parseSubscripts(o,s,r,!1,t);return e&&(a.end>o.end&&(this.checkExpressionErrors(e,!0),e.parenthesizedAssign>=a.start&&(e.parenthesizedAssign=-1),e.parenthesizedBind>=a.start&&(e.parenthesizedBind=-1),e.trailingComma>=a.start&&(e.trailingComma=-1)),i>-1&&(e.doubleProto=i),n>-1&&(e.shorthandAssign=n)),a},he.parseSubscripts=function(e,t,s,r,i){for(var n=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,o=!1;;){var a=this.parseSubscript(e,t,s,r,n,o,i);if(a.optional&&(o=!0),a.end===e.end||"ArrowFunctionExpression"===a.type){if(o){var h=this.startNodeAt(t,s);h.expression=a,a=this.finishNode(h,"ChainExpression")}return a}e=a,n=!1}},he.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(w.arrow)},he.parseSubscriptAsyncArrow=function(e,t,s,r){return this.parseArrowExpression(this.startNodeAt(e,t),s,!0,r)},he.parseSubscript=function(e,t,s,r,i,n,o){var a=this.options.ecmaVersion>=11,h=a&&this.eat(w.questionDot);r&&h&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var l=this.eat(w.bracketL);if(l||h&&this.type!==w.parenL&&this.type!==w.backQuote||this.eat(w.dot)){var c=this.startNodeAt(t,s);c.object=e,l?(c.property=this.parseExpression(),this.expect(w.bracketR)):this.type===w.privateId&&"Super"!==e.type?c.property=this.parsePrivateIdent():c.property=this.parseIdent("never"!==this.options.allowReserved),c.computed=!!l,a&&(c.optional=h),e=this.finishNode(c,"MemberExpression")}else if(!r&&this.eat(w.parenL)){var d=new Y,u=this.yieldPos,p=this.awaitPos,f=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var m=this.parseExprList(w.parenR,this.options.ecmaVersion>=8,!1,d);if(i&&!h&&this.shouldParseAsyncArrow())return this.checkPatternErrors(d,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,"Cannot use 'await' as identifier inside an async function"),this.yieldPos=u,this.awaitPos=p,this.awaitIdentPos=f,this.parseSubscriptAsyncArrow(t,s,m,o);this.checkExpressionErrors(d,!0),this.yieldPos=u||this.yieldPos,this.awaitPos=p||this.awaitPos,this.awaitIdentPos=f||this.awaitIdentPos;var g=this.startNodeAt(t,s);g.callee=e,g.arguments=m,a&&(g.optional=h),e=this.finishNode(g,"CallExpression")}else if(this.type===w.backQuote){(h||n)&&this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var y=this.startNodeAt(t,s);y.tag=e,y.quasi=this.parseTemplate({isTagged:!0}),e=this.finishNode(y,"TaggedTemplateExpression")}return e},he.parseExprAtom=function(e,t,s){this.type===w.slash&&this.readRegexp();var r,i=this.potentialArrowAt===this.start;switch(this.type){case w._super:return this.allowSuper||this.raise(this.start,"'super' keyword outside a method"),r=this.startNode(),this.next(),this.type!==w.parenL||this.allowDirectSuper||this.raise(r.start,"super() call outside constructor of a subclass"),this.type!==w.dot&&this.type!==w.bracketL&&this.type!==w.parenL&&this.unexpected(),this.finishNode(r,"Super");case w._this:return r=this.startNode(),this.next(),this.finishNode(r,"ThisExpression");case w.name:var n=this.start,o=this.startLoc,a=this.containsEsc,h=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!a&&"async"===h.name&&!this.canInsertSemicolon()&&this.eat(w._function))return this.overrideContext(oe.f_expr),this.parseFunction(this.startNodeAt(n,o),0,!1,!0,t);if(i&&!this.canInsertSemicolon()){if(this.eat(w.arrow))return this.parseArrowExpression(this.startNodeAt(n,o),[h],!1,t);if(this.options.ecmaVersion>=8&&"async"===h.name&&this.type===w.name&&!a&&(!this.potentialArrowInForAwait||"of"!==this.value||this.containsEsc))return h=this.parseIdent(!1),!this.canInsertSemicolon()&&this.eat(w.arrow)||this.unexpected(),this.parseArrowExpression(this.startNodeAt(n,o),[h],!0,t)}return h;case w.regexp:var l=this.value;return(r=this.parseLiteral(l.value)).regex={pattern:l.pattern,flags:l.flags},r;case w.num:case w.string:return this.parseLiteral(this.value);case w._null:case w._true:case w._false:return(r=this.startNode()).value=this.type===w._null?null:this.type===w._true,r.raw=this.type.keyword,this.next(),this.finishNode(r,"Literal");case w.parenL:var c=this.start,d=this.parseParenAndDistinguishExpression(i,t);return e&&(e.parenthesizedAssign<0&&!this.isSimpleAssignTarget(d)&&(e.parenthesizedAssign=c),e.parenthesizedBind<0&&(e.parenthesizedBind=c)),d;case w.bracketL:return r=this.startNode(),this.next(),r.elements=this.parseExprList(w.bracketR,!0,!0,e),this.finishNode(r,"ArrayExpression");case w.braceL:return this.overrideContext(oe.b_expr),this.parseObj(!1,e);case w._function:return r=this.startNode(),this.next(),this.parseFunction(r,0);case w._class:return this.parseClass(this.startNode(),!1);case w._new:return this.parseNew();case w.backQuote:return this.parseTemplate();case w._import:return this.options.ecmaVersion>=11?this.parseExprImport(s):this.unexpected();default:return this.parseExprAtomDefault()}},he.parseExprAtomDefault=function(){this.unexpected()},he.parseExprImport=function(e){var t=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import"),this.next(),this.type===w.parenL&&!e)return this.parseDynamicImport(t);if(this.type===w.dot){var s=this.startNodeAt(t.start,t.loc&&t.loc.start);return s.name="import",t.meta=this.finishNode(s,"Identifier"),this.parseImportMeta(t)}this.unexpected()},he.parseDynamicImport=function(e){if(this.next(),e.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(w.parenR)?e.options=null:(this.expect(w.comma),this.afterTrailingComma(w.parenR)?e.options=null:(e.options=this.parseMaybeAssign(),this.eat(w.parenR)||(this.expect(w.comma),this.afterTrailingComma(w.parenR)||this.unexpected())));else if(!this.eat(w.parenR)){var t=this.start;this.eat(w.comma)&&this.eat(w.parenR)?this.raiseRecoverable(t,"Trailing comma is not allowed in import()"):this.unexpected(t)}return this.finishNode(e,"ImportExpression")},he.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")},he.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")},he.parseParenExpression=function(){this.expect(w.parenL);var e=this.parseExpression();return this.expect(w.parenR),e},he.shouldParseArrow=function(e){return!this.canInsertSemicolon()},he.parseParenAndDistinguishExpression=function(e,t){var s,r=this.start,i=this.startLoc,n=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var o,a=this.start,h=this.startLoc,l=[],c=!0,d=!1,u=new Y,p=this.yieldPos,f=this.awaitPos;for(this.yieldPos=0,this.awaitPos=0;this.type!==w.parenR;){if(c?c=!1:this.expect(w.comma),n&&this.afterTrailingComma(w.parenR,!0)){d=!0;break}if(this.type===w.ellipsis){o=this.start,l.push(this.parseParenItem(this.parseRestBinding())),this.type===w.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}l.push(this.parseMaybeAssign(!1,u,this.parseParenItem))}var m=this.lastTokEnd,g=this.lastTokEndLoc;if(this.expect(w.parenR),e&&this.shouldParseArrow(l)&&this.eat(w.arrow))return this.checkPatternErrors(u,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=p,this.awaitPos=f,this.parseParenArrowList(r,i,l,t);l.length&&!d||this.unexpected(this.lastTokStart),o&&this.unexpected(o),this.checkExpressionErrors(u,!0),this.yieldPos=p||this.yieldPos,this.awaitPos=f||this.awaitPos,l.length>1?((s=this.startNodeAt(a,h)).expressions=l,this.finishNodeAt(s,"SequenceExpression",m,g)):s=l[0]}else s=this.parseParenExpression();if(this.options.preserveParens){var y=this.startNodeAt(r,i);return y.expression=s,this.finishNode(y,"ParenthesizedExpression")}return s},he.parseParenItem=function(e){return e},he.parseParenArrowList=function(e,t,s,r){return this.parseArrowExpression(this.startNodeAt(e,t),s,!1,r)};var de=[];he.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===w.dot){var t=this.startNodeAt(e.start,e.loc&&e.loc.start);t.name="new",e.meta=this.finishNode(t,"Identifier"),this.next();var s=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'"),s&&this.raiseRecoverable(e.start,"'new.target' must not contain escaped characters"),this.allowNewDotTarget||this.raiseRecoverable(e.start,"'new.target' can only be used in functions and class static block"),this.finishNode(e,"MetaProperty")}var r=this.start,i=this.startLoc;return e.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),r,i,!0,!1),"Super"===e.callee.type&&this.raiseRecoverable(r,"Invalid use of 'super'"),this.eat(w.parenL)?e.arguments=this.parseExprList(w.parenR,this.options.ecmaVersion>=8,!1):e.arguments=de,this.finishNode(e,"NewExpression")},he.parseTemplateElement=function(e){var t=e.isTagged,s=this.startNode();return this.type===w.invalidTemplate?(t||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),s.value={raw:this.value.replace(/\r\n?/g,"\n"),cooked:null}):s.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,"\n"),cooked:this.value},this.next(),s.tail=this.type===w.backQuote,this.finishNode(s,"TemplateElement")},he.parseTemplate=function(e){void 0===e&&(e={});var t=e.isTagged;void 0===t&&(t=!1);var s=this.startNode();this.next(),s.expressions=[];var r=this.parseTemplateElement({isTagged:t});for(s.quasis=[r];!r.tail;)this.type===w.eof&&this.raise(this.pos,"Unterminated template literal"),this.expect(w.dollarBraceL),s.expressions.push(this.parseExpression()),this.expect(w.braceR),s.quasis.push(r=this.parseTemplateElement({isTagged:t}));return this.next(),this.finishNode(s,"TemplateLiteral")},he.isAsyncProp=function(e){return!e.computed&&"Identifier"===e.key.type&&"async"===e.key.name&&(this.type===w.name||this.type===w.num||this.type===w.string||this.type===w.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===w.star)&&!x.test(this.input.slice(this.lastTokEnd,this.start))},he.parseObj=function(e,t){var s=this.startNode(),r=!0,i={};for(s.properties=[],this.next();!this.eat(w.braceR);){if(r)r=!1;else if(this.expect(w.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(w.braceR))break;var n=this.parseProperty(e,t);e||this.checkPropClash(n,i,t),s.properties.push(n)}return this.finishNode(s,e?"ObjectPattern":"ObjectExpression")},he.parseProperty=function(e,t){var s,r,i,n,o=this.startNode();if(this.options.ecmaVersion>=9&&this.eat(w.ellipsis))return e?(o.argument=this.parseIdent(!1),this.type===w.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.finishNode(o,"RestElement")):(o.argument=this.parseMaybeAssign(!1,t),this.type===w.comma&&t&&t.trailingComma<0&&(t.trailingComma=this.start),this.finishNode(o,"SpreadElement"));this.options.ecmaVersion>=6&&(o.method=!1,o.shorthand=!1,(e||t)&&(i=this.start,n=this.startLoc),e||(s=this.eat(w.star)));var a=this.containsEsc;return this.parsePropertyName(o),!e&&!a&&this.options.ecmaVersion>=8&&!s&&this.isAsyncProp(o)?(r=!0,s=this.options.ecmaVersion>=9&&this.eat(w.star),this.parsePropertyName(o)):r=!1,this.parsePropertyValue(o,e,s,r,i,n,t,a),this.finishNode(o,"Property")},he.parseGetterSetter=function(e){var t=e.key.name;this.parsePropertyName(e),e.value=this.parseMethod(!1),e.kind=t;var s="get"===e.kind?0:1;if(e.value.params.length!==s){var r=e.value.start;"get"===e.kind?this.raiseRecoverable(r,"getter should have no params"):this.raiseRecoverable(r,"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")},he.parsePropertyValue=function(e,t,s,r,i,n,o,a){(s||r)&&this.type===w.colon&&this.unexpected(),this.eat(w.colon)?(e.value=t?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,o),e.kind="init"):this.options.ecmaVersion>=6&&this.type===w.parenL?(t&&this.unexpected(),e.method=!0,e.value=this.parseMethod(s,r),e.kind="init"):t||a||!(this.options.ecmaVersion>=5)||e.computed||"Identifier"!==e.key.type||"get"!==e.key.name&&"set"!==e.key.name||this.type===w.comma||this.type===w.braceR||this.type===w.eq?this.options.ecmaVersion>=6&&!e.computed&&"Identifier"===e.key.type?((s||r)&&this.unexpected(),this.checkUnreserved(e.key),"await"!==e.key.name||this.awaitIdentPos||(this.awaitIdentPos=i),t?e.value=this.parseMaybeDefault(i,n,this.copyNode(e.key)):this.type===w.eq&&o?(o.shorthandAssign<0&&(o.shorthandAssign=this.start),e.value=this.parseMaybeDefault(i,n,this.copyNode(e.key))):e.value=this.copyNode(e.key),e.kind="init",e.shorthand=!0):this.unexpected():((s||r)&&this.unexpected(),this.parseGetterSetter(e))},he.parsePropertyName=function(e){if(this.options.ecmaVersion>=6){if(this.eat(w.bracketL))return e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(w.bracketR),e.key;e.computed=!1}return e.key=this.type===w.num||this.type===w.string?this.parseExprAtom():this.parseIdent("never"!==this.options.allowReserved)},he.initFunction=function(e){e.id=null,this.options.ecmaVersion>=6&&(e.generator=e.expression=!1),this.options.ecmaVersion>=8&&(e.async=!1)},he.parseMethod=function(e,t,s){var r=this.startNode(),i=this.yieldPos,n=this.awaitPos,o=this.awaitIdentPos;return this.initFunction(r),this.options.ecmaVersion>=6&&(r.generator=e),this.options.ecmaVersion>=8&&(r.async=!!t),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(64|z(t,r.generator)|(s?128:0)),this.expect(w.parenL),r.params=this.parseBindingList(w.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(r,!1,!0,!1),this.yieldPos=i,this.awaitPos=n,this.awaitIdentPos=o,this.finishNode(r,"FunctionExpression")},he.parseArrowExpression=function(e,t,s,r){var i=this.yieldPos,n=this.awaitPos,o=this.awaitIdentPos;return this.enterScope(16|z(s,!1)),this.initFunction(e),this.options.ecmaVersion>=8&&(e.async=!!s),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,e.params=this.toAssignableList(t,!0),this.parseFunctionBody(e,!0,!1,r),this.yieldPos=i,this.awaitPos=n,this.awaitIdentPos=o,this.finishNode(e,"ArrowFunctionExpression")},he.parseFunctionBody=function(e,t,s,r){var i=t&&this.type!==w.braceL,n=this.strict,o=!1;if(i)e.body=this.parseMaybeAssign(r),e.expression=!0,this.checkParams(e,!1);else{var a=this.options.ecmaVersion>=7&&!this.isSimpleParamList(e.params);n&&!a||(o=this.strictDirective(this.end))&&a&&this.raiseRecoverable(e.start,"Illegal 'use strict' directive in function with non-simple parameter list");var h=this.labels;this.labels=[],o&&(this.strict=!0),this.checkParams(e,!n&&!o&&!t&&!s&&this.isSimpleParamList(e.params)),this.strict&&e.id&&this.checkLValSimple(e.id,5),e.body=this.parseBlock(!1,void 0,o&&!n),e.expression=!1,this.adaptDirectivePrologue(e.body.body),this.labels=h}this.exitScope()},he.isSimpleParamList=function(e){for(var t=0,s=e;t<s.length;t+=1)if("Identifier"!==s[t].type)return!1;return!0},he.checkParams=function(e,t){for(var s=Object.create(null),r=0,i=e.params;r<i.length;r+=1){var n=i[r];this.checkLValInnerPattern(n,1,t?null:s)}},he.parseExprList=function(e,t,s,r){for(var i=[],n=!0;!this.eat(e);){if(n)n=!1;else if(this.expect(w.comma),t&&this.afterTrailingComma(e))break;var o=void 0;s&&this.type===w.comma?o=null:this.type===w.ellipsis?(o=this.parseSpread(r),r&&this.type===w.comma&&r.trailingComma<0&&(r.trailingComma=this.start)):o=this.parseMaybeAssign(!1,r),i.push(o)}return i},he.checkUnreserved=function(e){var t=e.start,s=e.end,r=e.name;this.inGenerator&&"yield"===r&&this.raiseRecoverable(t,"Cannot use 'yield' as identifier inside a generator"),this.inAsync&&"await"===r&&this.raiseRecoverable(t,"Cannot use 'await' as identifier inside an async function"),this.currentThisScope().flags&V||"arguments"!==r||this.raiseRecoverable(t,"Cannot use 'arguments' in class field initializer"),!this.inClassStaticBlock||"arguments"!==r&&"await"!==r||this.raise(t,"Cannot use "+r+" in class static initialization block"),this.keywords.test(r)&&this.raise(t,"Unexpected keyword '"+r+"'"),this.options.ecmaVersion<6&&-1!==this.input.slice(t,s).indexOf("\\")||(this.strict?this.reservedWordsStrict:this.reservedWords).test(r)&&(this.inAsync||"await"!==r||this.raiseRecoverable(t,"Cannot use keyword 'await' outside an async function"),this.raiseRecoverable(t,"The keyword '"+r+"' is reserved"))},he.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},he.parseIdentNode=function(){var e=this.startNode();return this.type===w.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=w.name):this.unexpected(),e},he.parsePrivateIdent=function(){var e=this.startNode();return this.type===w.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},he.parseYield=function(e){this.yieldPos||(this.yieldPos=this.start);var t=this.startNode();return this.next(),this.type===w.semi||this.canInsertSemicolon()||this.type!==w.star&&!this.type.startsExpr?(t.delegate=!1,t.argument=null):(t.delegate=this.eat(w.star),t.argument=this.parseMaybeAssign(e)),this.finishNode(t,"YieldExpression")},he.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 ue=F.prototype;ue.raise=function(e,t){var s=B(this.input,e);t+=" ("+s.line+":"+s.column+")",this.sourceFile&&(t+=" in "+this.sourceFile);var r=new SyntaxError(t);throw r.pos=e,r.loc=s,r.raisedAt=this.pos,r},ue.raiseRecoverable=ue.raise,ue.curPosition=function(){if(this.options.locations)return new O(this.curLine,this.pos-this.lineStart)};var pe=F.prototype,fe=function(e){this.flags=e,this.var=[],this.lexical=[],this.functions=[]};pe.enterScope=function(e){this.scopeStack.push(new fe(e))},pe.exitScope=function(){this.scopeStack.pop()},pe.treatFunctionsAsVarInScope=function(e){return 2&e.flags||!this.inModule&&1&e.flags},pe.declareName=function(e,t,s){var r=!1;if(2===t){var i=this.currentScope();r=i.lexical.indexOf(e)>-1||i.functions.indexOf(e)>-1||i.var.indexOf(e)>-1,i.lexical.push(e),this.inModule&&1&i.flags&&delete this.undefinedExports[e]}else if(4===t)this.currentScope().lexical.push(e);else if(3===t){var n=this.currentScope();r=this.treatFunctionsAsVar?n.lexical.indexOf(e)>-1:n.lexical.indexOf(e)>-1||n.var.indexOf(e)>-1,n.functions.push(e)}else for(var o=this.scopeStack.length-1;o>=0;--o){var a=this.scopeStack[o];if(a.lexical.indexOf(e)>-1&&!(32&a.flags&&a.lexical[0]===e)||!this.treatFunctionsAsVarInScope(a)&&a.functions.indexOf(e)>-1){r=!0;break}if(a.var.push(e),this.inModule&&1&a.flags&&delete this.undefinedExports[e],a.flags&V)break}r&&this.raiseRecoverable(s,"Identifier '"+e+"' has already been declared")},pe.checkLocalExport=function(e){-1===this.scopeStack[0].lexical.indexOf(e.name)&&-1===this.scopeStack[0].var.indexOf(e.name)&&(this.undefinedExports[e.name]=e)},pe.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]},pe.currentVarScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(771&t.flags)return t}},pe.currentThisScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(771&t.flags&&!(16&t.flags))return t}};var me=function(e,t,s){this.type="",this.start=t,this.end=0,e.options.locations&&(this.loc=new U(e,s)),e.options.directSourceFile&&(this.sourceFile=e.options.directSourceFile),e.options.ranges&&(this.range=[t,0])},ge=F.prototype;function ye(e,t,s,r){return e.type=t,e.end=s,this.options.locations&&(e.loc.end=r),this.options.ranges&&(e.range[1]=s),e}ge.startNode=function(){return new me(this,this.start,this.startLoc)},ge.startNodeAt=function(e,t){return new me(this,e,t)},ge.finishNode=function(e,t){return ye.call(this,e,t,this.lastTokEnd,this.lastTokEndLoc)},ge.finishNodeAt=function(e,t,s,r){return ye.call(this,e,t,s,r)},ge.copyNode=function(e){var t=new me(this,e.start,this.startLoc);for(var s in e)t[s]=e[s];return t};var ve="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",we=ve+" Extended_Pictographic",xe=we+" EBase EComp EMod EPres ExtPict",be={9:ve,10:we,11:we,12:xe,13:xe,14:xe},Ee={9:"",10:"",11:"",12:"",13:"",14:"Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji"},Se="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",ke="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",_e=ke+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",Ce=_e+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",Ae=Ce+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",Ie=Ae+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",Te={9:ke,10:_e,11:Ce,12:Ae,13:Ie,14:Ie+" Berf Beria_Erfe Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sidetic Sidt Sunu Sunuwar Tai_Yo Tayo Todhri Todr Tolong_Siki Tols Tulu_Tigalari Tutg Unknown Zzzz"},Pe={};function Le(e){var t=Pe[e]={binary:M(be[e]+" "+Se),binaryOfStrings:M(Ee[e]),nonBinary:{General_Category:M(Se),Script:M(Te[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 Me=0,Re=[9,10,11,12,13,14];Me<Re.length;Me+=1)Le(Re[Me]);var Ne=F.prototype,Oe=function(e,t){this.parent=e,this.base=t||this};Oe.prototype.separatedFrom=function(e){for(var t=this;t;t=t.parent)for(var s=e;s;s=s.parent)if(t.base===s.base&&t!==s)return!0;return!1},Oe.prototype.sibling=function(){return new Oe(this.parent,this.base)};var Ue=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=Pe[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 Be(e){return 105===e||109===e||115===e}function De(e){return 36===e||e>=40&&e<=43||46===e||63===e||e>=91&&e<=94||e>=123&&e<=125}function je(e){return e>=65&&e<=90||e>=97&&e<=122}Ue.prototype.reset=function(e,t,s){var r=-1!==s.indexOf("v"),i=-1!==s.indexOf("u");this.start=0|e,this.source=t+"",this.flags=s,r&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=i&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=i&&this.parser.options.ecmaVersion>=9)},Ue.prototype.raise=function(e){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+e)},Ue.prototype.at=function(e,t){void 0===t&&(t=!1);var s=this.source,r=s.length;if(e>=r)return-1;var i=s.charCodeAt(e);if(!t&&!this.switchU||i<=55295||i>=57344||e+1>=r)return i;var n=s.charCodeAt(e+1);return n>=56320&&n<=57343?(i<<10)+n-56613888:i},Ue.prototype.nextIndex=function(e,t){void 0===t&&(t=!1);var s=this.source,r=s.length;if(e>=r)return r;var i,n=s.charCodeAt(e);return!t&&!this.switchU||n<=55295||n>=57344||e+1>=r||(i=s.charCodeAt(e+1))<56320||i>57343?e+1:e+2},Ue.prototype.current=function(e){return void 0===e&&(e=!1),this.at(this.pos,e)},Ue.prototype.lookahead=function(e){return void 0===e&&(e=!1),this.at(this.nextIndex(this.pos,e),e)},Ue.prototype.advance=function(e){void 0===e&&(e=!1),this.pos=this.nextIndex(this.pos,e)},Ue.prototype.eat=function(e,t){return void 0===t&&(t=!1),this.current(t)===e&&(this.advance(t),!0)},Ue.prototype.eatChars=function(e,t){void 0===t&&(t=!1);for(var s=this.pos,r=0,i=e;r<i.length;r+=1){var n=i[r],o=this.at(s,t);if(-1===o||o!==n)return!1;s=this.nextIndex(s,t)}return this.pos=s,!0},Ne.validateRegExpFlags=function(e){for(var t=e.validFlags,s=e.flags,r=!1,i=!1,n=0;n<s.length;n++){var o=s.charAt(n);-1===t.indexOf(o)&&this.raise(e.start,"Invalid regular expression flag"),s.indexOf(o,n+1)>-1&&this.raise(e.start,"Duplicate regular expression flag"),"u"===o&&(r=!0),"v"===o&&(i=!0)}this.options.ecmaVersion>=15&&r&&i&&this.raise(e.start,"Invalid regular expression flag")},Ne.validateRegExpPattern=function(e){this.regexp_pattern(e),!e.switchN&&this.options.ecmaVersion>=9&&function(e){for(var t in e)return!0;return!1}(e.groupNames)&&(e.switchN=!0,this.regexp_pattern(e))},Ne.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,s=e.backReferenceNames;t<s.length;t+=1){var r=s[t];e.groupNames[r]||e.raise("Invalid named capture referenced")}},Ne.regexp_disjunction=function(e){var t=this.options.ecmaVersion>=16;for(t&&(e.branchID=new Oe(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")},Ne.regexp_alternative=function(e){for(;e.pos<e.source.length&&this.regexp_eatTerm(e););},Ne.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)},Ne.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 s=!1;if(this.options.ecmaVersion>=9&&(s=e.eat(60)),e.eat(61)||e.eat(33))return this.regexp_disjunction(e),e.eat(41)||e.raise("Unterminated group"),e.lastAssertionIsQuantifiable=!s,!0}return e.pos=t,!1},Ne.regexp_eatQuantifier=function(e,t){return void 0===t&&(t=!1),!!this.regexp_eatQuantifierPrefix(e,t)&&(e.eat(63),!0)},Ne.regexp_eatQuantifierPrefix=function(e,t){return e.eat(42)||e.eat(43)||e.eat(63)||this.regexp_eatBracedQuantifier(e,t)},Ne.regexp_eatBracedQuantifier=function(e,t){var s=e.pos;if(e.eat(123)){var r=0,i=-1;if(this.regexp_eatDecimalDigits(e)&&(r=e.lastIntValue,e.eat(44)&&this.regexp_eatDecimalDigits(e)&&(i=e.lastIntValue),e.eat(125)))return-1!==i&&i<r&&!t&&e.raise("numbers out of order in {} quantifier"),!0;e.switchU&&!t&&e.raise("Incomplete quantifier"),e.pos=s}return!1},Ne.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)},Ne.regexp_eatReverseSolidusAtomEscape=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatAtomEscape(e))return!0;e.pos=t}return!1},Ne.regexp_eatUncapturingGroup=function(e){var t=e.pos;if(e.eat(40)){if(e.eat(63)){if(this.options.ecmaVersion>=16){var s=this.regexp_eatModifiers(e),r=e.eat(45);if(s||r){for(var i=0;i<s.length;i++){var n=s.charAt(i);s.indexOf(n,i+1)>-1&&e.raise("Duplicate regular expression modifiers")}if(r){var o=this.regexp_eatModifiers(e);s||o||58!==e.current()||e.raise("Invalid regular expression modifiers");for(var a=0;a<o.length;a++){var h=o.charAt(a);(o.indexOf(h,a+1)>-1||s.indexOf(h)>-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},Ne.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},Ne.regexp_eatModifiers=function(e){for(var t="",s=0;-1!==(s=e.current())&&Be(s);)t+=R(s),e.advance();return t},Ne.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)},Ne.regexp_eatInvalidBracedQuantifier=function(e){return this.regexp_eatBracedQuantifier(e,!0)&&e.raise("Nothing to repeat"),!1},Ne.regexp_eatSyntaxCharacter=function(e){var t=e.current();return!!De(t)&&(e.lastIntValue=t,e.advance(),!0)},Ne.regexp_eatPatternCharacters=function(e){for(var t=e.pos,s=0;-1!==(s=e.current())&&!De(s);)e.advance();return e.pos!==t},Ne.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))},Ne.regexp_groupSpecifier=function(e){if(e.eat(63)){this.regexp_eatGroupName(e)||e.raise("Invalid group");var t=this.options.ecmaVersion>=16,s=e.groupNames[e.lastStringValue];if(s)if(t)for(var r=0,i=s;r<i.length;r+=1)i[r].separatedFrom(e.branchID)||e.raise("Duplicate capture group name");else e.raise("Duplicate capture group name");t?(s||(e.groupNames[e.lastStringValue]=[])).push(e.branchID):e.groupNames[e.lastStringValue]=!0}},Ne.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},Ne.regexp_eatRegExpIdentifierName=function(e){if(e.lastStringValue="",this.regexp_eatRegExpIdentifierStart(e)){for(e.lastStringValue+=R(e.lastIntValue);this.regexp_eatRegExpIdentifierPart(e);)e.lastStringValue+=R(e.lastIntValue);return!0}return!1},Ne.regexp_eatRegExpIdentifierStart=function(e){var t=e.pos,s=this.options.ecmaVersion>=11,r=e.current(s);return e.advance(s),92===r&&this.regexp_eatRegExpUnicodeEscapeSequence(e,s)&&(r=e.lastIntValue),function(e){return d(e,!0)||36===e||95===e}(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)},Ne.regexp_eatRegExpIdentifierPart=function(e){var t=e.pos,s=this.options.ecmaVersion>=11,r=e.current(s);return e.advance(s),92===r&&this.regexp_eatRegExpUnicodeEscapeSequence(e,s)&&(r=e.lastIntValue),function(e){return u(e,!0)||36===e||95===e||8204===e||8205===e}(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)},Ne.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)},Ne.regexp_eatBackReference=function(e){var t=e.pos;if(this.regexp_eatDecimalEscape(e)){var s=e.lastIntValue;if(e.switchU)return s>e.maxBackReference&&(e.maxBackReference=s),!0;if(s<=e.numCapturingParens)return!0;e.pos=t}return!1},Ne.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},Ne.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)},Ne.regexp_eatCControlLetter=function(e){var t=e.pos;if(e.eat(99)){if(this.regexp_eatControlLetter(e))return!0;e.pos=t}return!1},Ne.regexp_eatZero=function(e){return 48===e.current()&&!Ve(e.lookahead())&&(e.lastIntValue=0,e.advance(),!0)},Ne.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)},Ne.regexp_eatControlLetter=function(e){var t=e.current();return!!je(t)&&(e.lastIntValue=t%32,e.advance(),!0)},Ne.regexp_eatRegExpUnicodeEscapeSequence=function(e,t){void 0===t&&(t=!1);var s,r=e.pos,i=t||e.switchU;if(e.eat(117)){if(this.regexp_eatFixedHexDigits(e,4)){var n=e.lastIntValue;if(i&&n>=55296&&n<=56319){var o=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*(n-55296)+(a-56320)+65536,!0}e.pos=o,e.lastIntValue=n}return!0}if(i&&e.eat(123)&&this.regexp_eatHexDigits(e)&&e.eat(125)&&((s=e.lastIntValue)>=0&&s<=1114111))return!0;i&&e.raise("Invalid unicode escape"),e.pos=r}return!1},Ne.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))},Ne.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};function qe(e){return je(e)||95===e}function He(e){return qe(e)||Ve(e)}function Ve(e){return e>=48&&e<=57}function ze(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function Fe(e){return e>=65&&e<=70?e-65+10:e>=97&&e<=102?e-97+10:e-48}function Ge(e){return e>=48&&e<=55}Ne.regexp_eatCharacterClassEscape=function(e){var t=e.current();if(function(e){return 100===e||68===e||115===e||83===e||119===e||87===e}(t))return e.lastIntValue=-1,e.advance(),1;var s=!1;if(e.switchU&&this.options.ecmaVersion>=9&&((s=80===t)||112===t)){var r;if(e.lastIntValue=-1,e.advance(),e.eat(123)&&(r=this.regexp_eatUnicodePropertyValueExpression(e))&&e.eat(125))return s&&2===r&&e.raise("Invalid property name"),r;e.raise("Invalid property name")}return 0},Ne.regexp_eatUnicodePropertyValueExpression=function(e){var t=e.pos;if(this.regexp_eatUnicodePropertyName(e)&&e.eat(61)){var s=e.lastStringValue;if(this.regexp_eatUnicodePropertyValue(e)){var r=e.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(e,s,r),1}}if(e.pos=t,this.regexp_eatLoneUnicodePropertyNameOrValue(e)){var i=e.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(e,i)}return 0},Ne.regexp_validateUnicodePropertyNameAndValue=function(e,t,s){T(e.unicodeProperties.nonBinary,t)||e.raise("Invalid property name"),e.unicodeProperties.nonBinary[t].test(s)||e.raise("Invalid property value")},Ne.regexp_validateUnicodePropertyNameOrValue=function(e,t){return e.unicodeProperties.binary.test(t)?1:e.switchV&&e.unicodeProperties.binaryOfStrings.test(t)?2:void e.raise("Invalid property name")},Ne.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue="";qe(t=e.current());)e.lastStringValue+=R(t),e.advance();return""!==e.lastStringValue},Ne.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue="";He(t=e.current());)e.lastStringValue+=R(t),e.advance();return""!==e.lastStringValue},Ne.regexp_eatLoneUnicodePropertyNameOrValue=function(e){return this.regexp_eatUnicodePropertyValue(e)},Ne.regexp_eatCharacterClass=function(e){if(e.eat(91)){var t=e.eat(94),s=this.regexp_classContents(e);return e.eat(93)||e.raise("Unterminated character class"),t&&2===s&&e.raise("Negated character class may contain strings"),!0}return!1},Ne.regexp_classContents=function(e){return 93===e.current()?1:e.switchV?this.regexp_classSetExpression(e):(this.regexp_nonEmptyClassRanges(e),1)},Ne.regexp_nonEmptyClassRanges=function(e){for(;this.regexp_eatClassAtom(e);){var t=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassAtom(e)){var s=e.lastIntValue;!e.switchU||-1!==t&&-1!==s||e.raise("Invalid character class"),-1!==t&&-1!==s&&t>s&&e.raise("Range out of order in character class")}}},Ne.regexp_eatClassAtom=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatClassEscape(e))return!0;if(e.switchU){var s=e.current();(99===s||Ge(s))&&e.raise("Invalid class escape"),e.raise("Invalid escape")}e.pos=t}var r=e.current();return 93!==r&&(e.lastIntValue=r,e.advance(),!0)},Ne.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)},Ne.regexp_classSetExpression=function(e){var t,s=1;if(this.regexp_eatClassSetRange(e));else if(t=this.regexp_eatClassSetOperand(e)){2===t&&(s=2);for(var r=e.pos;e.eatChars([38,38]);)38!==e.current()&&(t=this.regexp_eatClassSetOperand(e))?2!==t&&(s=1):e.raise("Invalid character in character class");if(r!==e.pos)return s;for(;e.eatChars([45,45]);)this.regexp_eatClassSetOperand(e)||e.raise("Invalid character in character class");if(r!==e.pos)return s}else e.raise("Invalid character in character class");for(;;)if(!this.regexp_eatClassSetRange(e)){if(!(t=this.regexp_eatClassSetOperand(e)))return s;2===t&&(s=2)}},Ne.regexp_eatClassSetRange=function(e){var t=e.pos;if(this.regexp_eatClassSetCharacter(e)){var s=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassSetCharacter(e)){var r=e.lastIntValue;return-1!==s&&-1!==r&&s>r&&e.raise("Range out of order in character class"),!0}e.pos=t}return!1},Ne.regexp_eatClassSetOperand=function(e){return this.regexp_eatClassSetCharacter(e)?1:this.regexp_eatClassStringDisjunction(e)||this.regexp_eatNestedClass(e)},Ne.regexp_eatNestedClass=function(e){var t=e.pos;if(e.eat(91)){var s=e.eat(94),r=this.regexp_classContents(e);if(e.eat(93))return s&&2===r&&e.raise("Negated character class may contain strings"),r;e.pos=t}if(e.eat(92)){var i=this.regexp_eatCharacterClassEscape(e);if(i)return i;e.pos=t}return null},Ne.regexp_eatClassStringDisjunction=function(e){var t=e.pos;if(e.eatChars([92,113])){if(e.eat(123)){var s=this.regexp_classStringDisjunctionContents(e);if(e.eat(125))return s}else e.raise("Invalid escape");e.pos=t}return null},Ne.regexp_classStringDisjunctionContents=function(e){for(var t=this.regexp_classString(e);e.eat(124);)2===this.regexp_classString(e)&&(t=2);return t},Ne.regexp_classString=function(e){for(var t=0;this.regexp_eatClassSetCharacter(e);)t++;return 1===t?1:2},Ne.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 s=e.current();return!(s<0||s===e.lookahead()&&function(e){return 33===e||e>=35&&e<=38||e>=42&&e<=44||46===e||e>=58&&e<=64||94===e||96===e||126===e}(s)||function(e){return 40===e||41===e||45===e||47===e||e>=91&&e<=93||e>=123&&e<=125}(s)||(e.advance(),e.lastIntValue=s,0))},Ne.regexp_eatClassSetReservedPunctuator=function(e){var t=e.current();return!!function(e){return 33===e||35===e||37===e||38===e||44===e||45===e||e>=58&&e<=62||64===e||96===e||126===e}(t)&&(e.lastIntValue=t,e.advance(),!0)},Ne.regexp_eatClassControlLetter=function(e){var t=e.current();return!(!Ve(t)&&95!==t||(e.lastIntValue=t%32,e.advance(),0))},Ne.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},Ne.regexp_eatDecimalDigits=function(e){var t=e.pos,s=0;for(e.lastIntValue=0;Ve(s=e.current());)e.lastIntValue=10*e.lastIntValue+(s-48),e.advance();return e.pos!==t},Ne.regexp_eatHexDigits=function(e){var t=e.pos,s=0;for(e.lastIntValue=0;ze(s=e.current());)e.lastIntValue=16*e.lastIntValue+Fe(s),e.advance();return e.pos!==t},Ne.regexp_eatLegacyOctalEscapeSequence=function(e){if(this.regexp_eatOctalDigit(e)){var t=e.lastIntValue;if(this.regexp_eatOctalDigit(e)){var s=e.lastIntValue;t<=3&&this.regexp_eatOctalDigit(e)?e.lastIntValue=64*t+8*s+e.lastIntValue:e.lastIntValue=8*t+s}else e.lastIntValue=t;return!0}return!1},Ne.regexp_eatOctalDigit=function(e){var t=e.current();return Ge(t)?(e.lastIntValue=t-48,e.advance(),!0):(e.lastIntValue=0,!1)},Ne.regexp_eatFixedHexDigits=function(e,t){var s=e.pos;e.lastIntValue=0;for(var r=0;r<t;++r){var i=e.current();if(!ze(i))return e.pos=s,!1;e.lastIntValue=16*e.lastIntValue+Fe(i),e.advance()}return!0};var $e=function(e){this.type=e.type,this.value=e.value,this.start=e.start,this.end=e.end,e.options.locations&&(this.loc=new U(e,e.startLoc,e.endLoc)),e.options.ranges&&(this.range=[e.start,e.end])},Ke=F.prototype;function We(e){return"function"!=typeof BigInt?null:BigInt(e.replace(/_/g,""))}Ke.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 $e(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()},Ke.getToken=function(){return this.next(),new $e(this)},"undefined"!=typeof Symbol&&(Ke[Symbol.iterator]=function(){var e=this;return{next:function(){var t=e.getToken();return{done:t.type===w.eof,value:t}}}}),Ke.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(w.eof):e.override?e.override(this):void this.readToken(this.fullCharCodeAtPos())},Ke.readToken=function(e){return d(e,this.options.ecmaVersion>=6)||92===e?this.readWord():this.getTokenFromCode(e)},Ke.fullCharCodeAt=function(e){var t=this.input.charCodeAt(e);if(t<=55295||t>=56320)return t;var s=this.input.charCodeAt(e+1);return s<=56319||s>=57344?t:(t<<10)+s-56613888},Ke.fullCharCodeAtPos=function(){return this.fullCharCodeAt(this.pos)},Ke.skipBlockComment=function(){var e=this.options.onComment&&this.curPosition(),t=this.pos,s=this.input.indexOf("*/",this.pos+=2);if(-1===s&&this.raise(this.pos-2,"Unterminated comment"),this.pos=s+2,this.options.locations)for(var r=void 0,i=t;(r=S(this.input,i,this.pos))>-1;)++this.curLine,i=this.lineStart=r;this.options.onComment&&this.options.onComment(!0,this.input.slice(t+2,s),t,this.pos,e,this.curPosition())},Ke.skipLineComment=function(e){for(var t=this.pos,s=this.options.onComment&&this.curPosition(),r=this.input.charCodeAt(this.pos+=e);this.pos<this.input.length&&!E(r);)r=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(t+e,this.pos),t,this.pos,s,this.curPosition())},Ke.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&&k.test(String.fromCharCode(e))))break e;++this.pos}}},Ke.finishToken=function(e,t){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var s=this.type;this.type=e,this.value=t,this.updateContext(s)},Ke.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(w.ellipsis)):(++this.pos,this.finishToken(w.dot))},Ke.readToken_slash=function(){var e=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):61===e?this.finishOp(w.assign,2):this.finishOp(w.slash,1)},Ke.readToken_mult_modulo_exp=function(e){var t=this.input.charCodeAt(this.pos+1),s=1,r=42===e?w.star:w.modulo;return this.options.ecmaVersion>=7&&42===e&&42===t&&(++s,r=w.starstar,t=this.input.charCodeAt(this.pos+2)),61===t?this.finishOp(w.assign,s+1):this.finishOp(r,s)},Ke.readToken_pipe_amp=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?this.options.ecmaVersion>=12&&61===this.input.charCodeAt(this.pos+2)?this.finishOp(w.assign,3):this.finishOp(124===e?w.logicalOR:w.logicalAND,2):61===t?this.finishOp(w.assign,2):this.finishOp(124===e?w.bitwiseOR:w.bitwiseAND,1)},Ke.readToken_caret=function(){return 61===this.input.charCodeAt(this.pos+1)?this.finishOp(w.assign,2):this.finishOp(w.bitwiseXOR,1)},Ke.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&&!x.test(this.input.slice(this.lastTokEnd,this.pos))?this.finishOp(w.incDec,2):(this.skipLineComment(3),this.skipSpace(),this.nextToken()):61===t?this.finishOp(w.assign,2):this.finishOp(w.plusMin,1)},Ke.readToken_lt_gt=function(e){var t=this.input.charCodeAt(this.pos+1),s=1;return t===e?(s=62===e&&62===this.input.charCodeAt(this.pos+2)?3:2,61===this.input.charCodeAt(this.pos+s)?this.finishOp(w.assign,s+1):this.finishOp(w.bitShift,s)):33!==t||60!==e||this.inModule||45!==this.input.charCodeAt(this.pos+2)||45!==this.input.charCodeAt(this.pos+3)?(61===t&&(s=2),this.finishOp(w.relational,s)):(this.skipLineComment(4),this.skipSpace(),this.nextToken())},Ke.readToken_eq_excl=function(e){var t=this.input.charCodeAt(this.pos+1);return 61===t?this.finishOp(w.equality,61===this.input.charCodeAt(this.pos+2)?3:2):61===e&&62===t&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(w.arrow)):this.finishOp(61===e?w.eq:w.prefix,1)},Ke.readToken_question=function(){var e=this.options.ecmaVersion;if(e>=11){var t=this.input.charCodeAt(this.pos+1);if(46===t){var s=this.input.charCodeAt(this.pos+2);if(s<48||s>57)return this.finishOp(w.questionDot,2)}if(63===t)return e>=12&&61===this.input.charCodeAt(this.pos+2)?this.finishOp(w.assign,3):this.finishOp(w.coalesce,2)}return this.finishOp(w.question,1)},Ke.readToken_numberSign=function(){var e=35;if(this.options.ecmaVersion>=13&&(++this.pos,d(e=this.fullCharCodeAtPos(),!0)||92===e))return this.finishToken(w.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+R(e)+"'")},Ke.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(w.parenL);case 41:return++this.pos,this.finishToken(w.parenR);case 59:return++this.pos,this.finishToken(w.semi);case 44:return++this.pos,this.finishToken(w.comma);case 91:return++this.pos,this.finishToken(w.bracketL);case 93:return++this.pos,this.finishToken(w.bracketR);case 123:return++this.pos,this.finishToken(w.braceL);case 125:return++this.pos,this.finishToken(w.braceR);case 58:return++this.pos,this.finishToken(w.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(w.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(w.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+R(e)+"'")},Ke.finishOp=function(e,t){var s=this.input.slice(this.pos,this.pos+t);return this.pos+=t,this.finishToken(e,s)},Ke.readRegexp=function(){for(var e,t,s=this.pos;;){this.pos>=this.input.length&&this.raise(s,"Unterminated regular expression");var r=this.input.charAt(this.pos);if(x.test(r)&&this.raise(s,"Unterminated regular expression"),e)e=!1;else{if("["===r)t=!0;else if("]"===r&&t)t=!1;else if("/"===r&&!t)break;e="\\"===r}++this.pos}var i=this.input.slice(s,this.pos);++this.pos;var n=this.pos,o=this.readWord1();this.containsEsc&&this.unexpected(n);var a=this.regexpState||(this.regexpState=new Ue(this));a.reset(s,i,o),this.validateRegExpFlags(a),this.validateRegExpPattern(a);var h=null;try{h=new RegExp(i,o)}catch(e){}return this.finishToken(w.regexp,{pattern:i,flags:o,value:h})},Ke.readInt=function(e,t,s){for(var r=this.options.ecmaVersion>=12&&void 0===t,i=s&&48===this.input.charCodeAt(this.pos),n=this.pos,o=0,a=0,h=0,l=t??1/0;h<l;++h,++this.pos){var c=this.input.charCodeAt(this.pos),d=void 0;if(r&&95===c)i&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed in legacy octal numeric literals"),95===a&&this.raiseRecoverable(this.pos,"Numeric separator must be exactly one underscore"),0===h&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed at the first of digits"),a=c;else{if((d=c>=97?c-97+10:c>=65?c-65+10:c>=48&&c<=57?c-48:1/0)>=e)break;a=c,o=o*e+d}}return r&&95===a&&this.raiseRecoverable(this.pos-1,"Numeric separator is not allowed at the last of digits"),this.pos===n||null!=t&&this.pos-n!==t?null:o},Ke.readRadixNumber=function(e){var t=this.pos;this.pos+=2;var s=this.readInt(e);return null==s&&this.raise(this.start+2,"Expected number in radix "+e),this.options.ecmaVersion>=11&&110===this.input.charCodeAt(this.pos)?(s=We(this.input.slice(t,this.pos)),++this.pos):d(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(w.num,s)},Ke.readNumber=function(e){var t=this.pos;e||null!==this.readInt(10,void 0,!0)||this.raise(t,"Invalid number");var s=this.pos-t>=2&&48===this.input.charCodeAt(t);s&&this.strict&&this.raise(t,"Invalid number");var r=this.input.charCodeAt(this.pos);if(!s&&!e&&this.options.ecmaVersion>=11&&110===r){var i=We(this.input.slice(t,this.pos));return++this.pos,d(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(w.num,i)}s&&/[89]/.test(this.input.slice(t,this.pos))&&(s=!1),46!==r||s||(++this.pos,this.readInt(10),r=this.input.charCodeAt(this.pos)),69!==r&&101!==r||s||(43!==(r=this.input.charCodeAt(++this.pos))&&45!==r||++this.pos,null===this.readInt(10)&&this.raise(t,"Invalid number")),d(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var n,o=(n=this.input.slice(t,this.pos),s?parseInt(n,8):parseFloat(n.replace(/_/g,"")));return this.finishToken(w.num,o)},Ke.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},Ke.readString=function(e){for(var t="",s=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");var r=this.input.charCodeAt(this.pos);if(r===e)break;92===r?(t+=this.input.slice(s,this.pos),t+=this.readEscapedChar(!1),s=this.pos):8232===r||8233===r?(this.options.ecmaVersion<10&&this.raise(this.start,"Unterminated string constant"),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(E(r)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return t+=this.input.slice(s,this.pos++),this.finishToken(w.string,t)};var Ye={};Ke.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e!==Ye)throw e;this.readInvalidTemplateToken()}this.inTemplateElement=!1},Ke.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw Ye;this.raise(e,t)},Ke.readTmplToken=function(){for(var e="",t=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated template");var s=this.input.charCodeAt(this.pos);if(96===s||36===s&&123===this.input.charCodeAt(this.pos+1))return this.pos!==this.start||this.type!==w.template&&this.type!==w.invalidTemplate?(e+=this.input.slice(t,this.pos),this.finishToken(w.template,e)):36===s?(this.pos+=2,this.finishToken(w.dollarBraceL)):(++this.pos,this.finishToken(w.backQuote));if(92===s)e+=this.input.slice(t,this.pos),e+=this.readEscapedChar(!0),t=this.pos;else if(E(s)){switch(e+=this.input.slice(t,this.pos),++this.pos,s){case 13:10===this.input.charCodeAt(this.pos)&&++this.pos;case 10:e+="\n";break;default:e+=String.fromCharCode(s)}this.options.locations&&(++this.curLine,this.lineStart=this.pos),t=this.pos}else++this.pos}},Ke.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(w.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")},Ke.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 R(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 s=this.pos-1;this.invalidStringToken(s,"Invalid escape sequence in template string")}default:if(t>=48&&t<=55){var r=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],i=parseInt(r,8);return i>255&&(r=r.slice(0,-1),i=parseInt(r,8)),this.pos+=r.length-1,t=this.input.charCodeAt(this.pos),"0"===r&&56!==t&&57!==t||!this.strict&&!e||this.invalidStringToken(this.pos-1-r.length,e?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(i)}return E(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(t)}},Ke.readHexChar=function(e){var t=this.pos,s=this.readInt(16,e);return null===s&&this.invalidStringToken(t,"Bad character escape sequence"),s},Ke.readWord1=function(){this.containsEsc=!1;for(var e="",t=!0,s=this.pos,r=this.options.ecmaVersion>=6;this.pos<this.input.length;){var i=this.fullCharCodeAtPos();if(u(i,r))this.pos+=i<=65535?1:2;else{if(92!==i)break;this.containsEsc=!0,e+=this.input.slice(s,this.pos);var n=this.pos;117!==this.input.charCodeAt(++this.pos)&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var o=this.readCodePoint();(t?d:u)(o,r)||this.invalidStringToken(n,"Invalid Unicode escape"),e+=R(o),s=this.pos}t=!1}return e+this.input.slice(s,this.pos)},Ke.readWord=function(){var e=this.readWord1(),t=w.name;return this.keywords.test(e)&&(t=y[e]),this.finishToken(t,e)};var Je="8.19.0";F.acorn={Parser:F,version:Je,defaultOptions:D,Position:O,SourceLocation:U,getLineInfo:B,Node:me,TokenType:p,tokTypes:w,keywordTypes:y,TokContext:ne,tokContexts:oe,isIdentifierChar:u,isIdentifierStart:d,Token:$e,isNewLine:E,lineBreak:x,lineBreakG:b,nonASCIIwhitespace:k},e.Node=me,e.Parser=F,e.Position=O,e.SourceLocation=U,e.TokContext=ne,e.Token=$e,e.TokenType=p,e.defaultOptions=D,e.getLineInfo=B,e.isIdentifierChar=u,e.isIdentifierStart=d,e.isNewLine=E,e.keywordTypes=y,e.lineBreak=x,e.lineBreakG=b,e.nonASCIIwhitespace=k,e.parse=function(e,t){return F.parse(e,t)},e.parseExpressionAt=function(e,t,s){return F.parseExpressionAt(e,t,s)},e.tokContexts=oe,e.tokTypes=w,e.tokenizer=function(e,t){return F.tokenizer(e,t)},e.version=Je}(t)},7526(e,t){"use strict";t.toByteArray=function(e){var t,s,n=function(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var s=e.indexOf("=");return-1===s&&(s=t),[s,s===t?0:4-s%4]}(e),o=n[0],a=n[1],h=new i(function(e,t,s){return 3*(t+s)/4-s}(0,o,a)),l=0,c=a>0?o-4:o;for(s=0;s<c;s+=4)t=r[e.charCodeAt(s)]<<18|r[e.charCodeAt(s+1)]<<12|r[e.charCodeAt(s+2)]<<6|r[e.charCodeAt(s+3)],h[l++]=t>>16&255,h[l++]=t>>8&255,h[l++]=255&t;return 2===a&&(t=r[e.charCodeAt(s)]<<2|r[e.charCodeAt(s+1)]>>4,h[l++]=255&t),1===a&&(t=r[e.charCodeAt(s)]<<10|r[e.charCodeAt(s+1)]<<4|r[e.charCodeAt(s+2)]>>2,h[l++]=t>>8&255,h[l++]=255&t),h},t.fromByteArray=function(e){for(var t,r=e.length,i=r%3,n=[],o=16383,a=0,l=r-i;a<l;a+=o)n.push(h(e,a,a+o>l?l:a+o));return 1===i?(t=e[r-1],n.push(s[t>>2]+s[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],n.push(s[t>>10]+s[t>>4&63]+s[t<<2&63]+"=")),n.join("")};for(var s=[],r=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0;o<64;++o)s[o]=n[o],r[n.charCodeAt(o)]=o;function a(e){return s[e>>18&63]+s[e>>12&63]+s[e>>6&63]+s[63&e]}function h(e,t,s){for(var r,i=[],n=t;n<s;n+=3)r=(e[n]<<16&16711680)+(e[n+1]<<8&65280)+(255&e[n+2]),i.push(a(r));return i.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},8287(e,t,s){"use strict";const r=s(7526),i=s(251),n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.hp=h,t.IS=50;const o=2147483647;function a(e){if(e>o)throw new RangeError('The value "'+e+'" is invalid for option "size"');const t=new Uint8Array(e);return Object.setPrototypeOf(t,h.prototype),t}function h(e,t,s){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return d(e)}return l(e,t,s)}function l(e,t,s){if("string"==typeof e)return function(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!h.isEncoding(t))throw new TypeError("Unknown encoding: "+t);const s=0|m(e,t);let r=a(s);const i=r.write(e,t);return i!==s&&(r=r.slice(0,i)),r}(e,t);if(ArrayBuffer.isView(e))return function(e){if(Y(e,Uint8Array)){const t=new Uint8Array(e);return p(t.buffer,t.byteOffset,t.byteLength)}return u(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(Y(e,ArrayBuffer)||e&&Y(e.buffer,ArrayBuffer))return p(e,t,s);if("undefined"!=typeof SharedArrayBuffer&&(Y(e,SharedArrayBuffer)||e&&Y(e.buffer,SharedArrayBuffer)))return p(e,t,s);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');const r=e.valueOf&&e.valueOf();if(null!=r&&r!==e)return h.from(r,t,s);const i=function(e){if(h.isBuffer(e)){const t=0|f(e.length),s=a(t);return 0===s.length||e.copy(s,0,0,t),s}return void 0!==e.length?"number"!=typeof e.length||J(e.length)?a(0):u(e):"Buffer"===e.type&&Array.isArray(e.data)?u(e.data):void 0}(e);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return h.from(e[Symbol.toPrimitive]("string"),t,s);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function c(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function d(e){return c(e),a(e<0?0:0|f(e))}function u(e){const t=e.length<0?0:0|f(e.length),s=a(t);for(let r=0;r<t;r+=1)s[r]=255&e[r];return s}function p(e,t,s){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(s||0))throw new RangeError('"length" is outside of buffer bounds');let r;return r=void 0===t&&void 0===s?new Uint8Array(e):void 0===s?new Uint8Array(e,t):new Uint8Array(e,t,s),Object.setPrototypeOf(r,h.prototype),r}function f(e){if(e>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|e}function m(e,t){if(h.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||Y(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);const s=e.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===s)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return s;case"utf8":case"utf-8":return $(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*s;case"hex":return s>>>1;case"base64":return K(e).length;default:if(i)return r?-1:$(e).length;t=(""+t).toLowerCase(),i=!0}}function g(e,t,s){let r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===s||s>this.length)&&(s=this.length),s<=0)return"";if((s>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return P(this,t,s);case"utf8":case"utf-8":return C(this,t,s);case"ascii":return I(this,t,s);case"latin1":case"binary":return T(this,t,s);case"base64":return _(this,t,s);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L(this,t,s);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function y(e,t,s){const r=e[t];e[t]=e[s],e[s]=r}function v(e,t,s,r,i){if(0===e.length)return-1;if("string"==typeof s?(r=s,s=0):s>2147483647?s=2147483647:s<-2147483648&&(s=-2147483648),J(s=+s)&&(s=i?0:e.length-1),s<0&&(s=e.length+s),s>=e.length){if(i)return-1;s=e.length-1}else if(s<0){if(!i)return-1;s=0}if("string"==typeof t&&(t=h.from(t,r)),h.isBuffer(t))return 0===t.length?-1:w(e,t,s,r,i);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,s):Uint8Array.prototype.lastIndexOf.call(e,t,s):w(e,[t],s,r,i);throw new TypeError("val must be string, number or Buffer")}function w(e,t,s,r,i){let n,o=1,a=e.length,h=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;o=2,a/=2,h/=2,s/=2}function l(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(i){let r=-1;for(n=s;n<a;n++)if(l(e,n)===l(t,-1===r?0:n-r)){if(-1===r&&(r=n),n-r+1===h)return r*o}else-1!==r&&(n-=n-r),r=-1}else for(s+h>a&&(s=a-h),n=s;n>=0;n--){let s=!0;for(let r=0;r<h;r++)if(l(e,n+r)!==l(t,r)){s=!1;break}if(s)return n}return-1}function x(e,t,s,r){s=Number(s)||0;const i=e.length-s;r?(r=Number(r))>i&&(r=i):r=i;const n=t.length;let o;for(r>n/2&&(r=n/2),o=0;o<r;++o){const r=parseInt(t.substr(2*o,2),16);if(J(r))return o;e[s+o]=r}return o}function b(e,t,s,r){return W($(t,e.length-s),e,s,r)}function E(e,t,s,r){return W(function(e){const t=[];for(let s=0;s<e.length;++s)t.push(255&e.charCodeAt(s));return t}(t),e,s,r)}function S(e,t,s,r){return W(K(t),e,s,r)}function k(e,t,s,r){return W(function(e,t){let s,r,i;const n=[];for(let o=0;o<e.length&&!((t-=2)<0);++o)s=e.charCodeAt(o),r=s>>8,i=s%256,n.push(i),n.push(r);return n}(t,e.length-s),e,s,r)}function _(e,t,s){return 0===t&&s===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,s))}function C(e,t,s){s=Math.min(e.length,s);const r=[];let i=t;for(;i<s;){const t=e[i];let n=null,o=t>239?4:t>223?3:t>191?2:1;if(i+o<=s){let s,r,a,h;switch(o){case 1:t<128&&(n=t);break;case 2:s=e[i+1],128==(192&s)&&(h=(31&t)<<6|63&s,h>127&&(n=h));break;case 3:s=e[i+1],r=e[i+2],128==(192&s)&&128==(192&r)&&(h=(15&t)<<12|(63&s)<<6|63&r,h>2047&&(h<55296||h>57343)&&(n=h));break;case 4:s=e[i+1],r=e[i+2],a=e[i+3],128==(192&s)&&128==(192&r)&&128==(192&a)&&(h=(15&t)<<18|(63&s)<<12|(63&r)<<6|63&a,h>65535&&h<1114112&&(n=h))}}null===n?(n=65533,o=1):n>65535&&(n-=65536,r.push(n>>>10&1023|55296),n=56320|1023&n),r.push(n),i+=o}return function(e){const t=e.length;if(t<=A)return String.fromCharCode.apply(String,e);let s="",r=0;for(;r<t;)s+=String.fromCharCode.apply(String,e.slice(r,r+=A));return s}(r)}h.TYPED_ARRAY_SUPPORT=function(){try{const e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}(),h.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(h.prototype,"parent",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.buffer}}),Object.defineProperty(h.prototype,"offset",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.byteOffset}}),h.poolSize=8192,h.from=function(e,t,s){return l(e,t,s)},Object.setPrototypeOf(h.prototype,Uint8Array.prototype),Object.setPrototypeOf(h,Uint8Array),h.alloc=function(e,t,s){return function(e,t,s){return c(e),e<=0?a(e):void 0!==t?"string"==typeof s?a(e).fill(t,s):a(e).fill(t):a(e)}(e,t,s)},h.allocUnsafe=function(e){return d(e)},h.allocUnsafeSlow=function(e){return d(e)},h.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==h.prototype},h.compare=function(e,t){if(Y(e,Uint8Array)&&(e=h.from(e,e.offset,e.byteLength)),Y(t,Uint8Array)&&(t=h.from(t,t.offset,t.byteLength)),!h.isBuffer(e)||!h.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let s=e.length,r=t.length;for(let i=0,n=Math.min(s,r);i<n;++i)if(e[i]!==t[i]){s=e[i],r=t[i];break}return s<r?-1:r<s?1:0},h.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},h.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return h.alloc(0);let s;if(void 0===t)for(t=0,s=0;s<e.length;++s)t+=e[s].length;const r=h.allocUnsafe(t);let i=0;for(s=0;s<e.length;++s){let t=e[s];if(Y(t,Uint8Array))i+t.length>r.length?(h.isBuffer(t)||(t=h.from(t)),t.copy(r,i)):Uint8Array.prototype.set.call(r,t,i);else{if(!h.isBuffer(t))throw new TypeError('"list" argument must be an Array of Buffers');t.copy(r,i)}i+=t.length}return r},h.byteLength=m,h.prototype._isBuffer=!0,h.prototype.swap16=function(){const e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)y(this,t,t+1);return this},h.prototype.swap32=function(){const e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)y(this,t,t+3),y(this,t+1,t+2);return this},h.prototype.swap64=function(){const e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)y(this,t,t+7),y(this,t+1,t+6),y(this,t+2,t+5),y(this,t+3,t+4);return this},h.prototype.toString=function(){const e=this.length;return 0===e?"":0===arguments.length?C(this,0,e):g.apply(this,arguments)},h.prototype.toLocaleString=h.prototype.toString,h.prototype.equals=function(e){if(!h.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===h.compare(this,e)},h.prototype.inspect=function(){let e="";const s=t.IS;return e=this.toString("hex",0,s).replace(/(.{2})/g,"$1 ").trim(),this.length>s&&(e+=" ... "),"<Buffer "+e+">"},n&&(h.prototype[n]=h.prototype.inspect),h.prototype.compare=function(e,t,s,r,i){if(Y(e,Uint8Array)&&(e=h.from(e,e.offset,e.byteLength)),!h.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===s&&(s=e?e.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),t<0||s>e.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&t>=s)return 0;if(r>=i)return-1;if(t>=s)return 1;if(this===e)return 0;let n=(i>>>=0)-(r>>>=0),o=(s>>>=0)-(t>>>=0);const a=Math.min(n,o),l=this.slice(r,i),c=e.slice(t,s);for(let e=0;e<a;++e)if(l[e]!==c[e]){n=l[e],o=c[e];break}return n<o?-1:o<n?1:0},h.prototype.includes=function(e,t,s){return-1!==this.indexOf(e,t,s)},h.prototype.indexOf=function(e,t,s){return v(this,e,t,s,!0)},h.prototype.lastIndexOf=function(e,t,s){return v(this,e,t,s,!1)},h.prototype.write=function(e,t,s,r){if(void 0===t)r="utf8",s=this.length,t=0;else if(void 0===s&&"string"==typeof t)r=t,s=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(s)?(s>>>=0,void 0===r&&(r="utf8")):(r=s,s=void 0)}const i=this.length-t;if((void 0===s||s>i)&&(s=i),e.length>0&&(s<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");let n=!1;for(;;)switch(r){case"hex":return x(this,e,t,s);case"utf8":case"utf-8":return b(this,e,t,s);case"ascii":case"latin1":case"binary":return E(this,e,t,s);case"base64":return S(this,e,t,s);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,e,t,s);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),n=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const A=4096;function I(e,t,s){let r="";s=Math.min(e.length,s);for(let i=t;i<s;++i)r+=String.fromCharCode(127&e[i]);return r}function T(e,t,s){let r="";s=Math.min(e.length,s);for(let i=t;i<s;++i)r+=String.fromCharCode(e[i]);return r}function P(e,t,s){const r=e.length;(!t||t<0)&&(t=0),(!s||s<0||s>r)&&(s=r);let i="";for(let r=t;r<s;++r)i+=X[e[r]];return i}function L(e,t,s){const r=e.slice(t,s);let i="";for(let e=0;e<r.length-1;e+=2)i+=String.fromCharCode(r[e]+256*r[e+1]);return i}function M(e,t,s){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>s)throw new RangeError("Trying to access beyond buffer length")}function R(e,t,s,r,i,n){if(!h.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<n)throw new RangeError('"value" argument is out of bounds');if(s+r>e.length)throw new RangeError("Index out of range")}function N(e,t,s,r,i){V(t,r,i,e,s,7);let n=Number(t&BigInt(4294967295));e[s++]=n,n>>=8,e[s++]=n,n>>=8,e[s++]=n,n>>=8,e[s++]=n;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[s++]=o,o>>=8,e[s++]=o,o>>=8,e[s++]=o,o>>=8,e[s++]=o,s}function O(e,t,s,r,i){V(t,r,i,e,s,7);let n=Number(t&BigInt(4294967295));e[s+7]=n,n>>=8,e[s+6]=n,n>>=8,e[s+5]=n,n>>=8,e[s+4]=n;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[s+3]=o,o>>=8,e[s+2]=o,o>>=8,e[s+1]=o,o>>=8,e[s]=o,s+8}function U(e,t,s,r,i,n){if(s+r>e.length)throw new RangeError("Index out of range");if(s<0)throw new RangeError("Index out of range")}function B(e,t,s,r,n){return t=+t,s>>>=0,n||U(e,0,s,4),i.write(e,t,s,r,23,4),s+4}function D(e,t,s,r,n){return t=+t,s>>>=0,n||U(e,0,s,8),i.write(e,t,s,r,52,8),s+8}h.prototype.slice=function(e,t){const s=this.length;(e=~~e)<0?(e+=s)<0&&(e=0):e>s&&(e=s),(t=void 0===t?s:~~t)<0?(t+=s)<0&&(t=0):t>s&&(t=s),t<e&&(t=e);const r=this.subarray(e,t);return Object.setPrototypeOf(r,h.prototype),r},h.prototype.readUintLE=h.prototype.readUIntLE=function(e,t,s){e>>>=0,t>>>=0,s||M(e,t,this.length);let r=this[e],i=1,n=0;for(;++n<t&&(i*=256);)r+=this[e+n]*i;return r},h.prototype.readUintBE=h.prototype.readUIntBE=function(e,t,s){e>>>=0,t>>>=0,s||M(e,t,this.length);let r=this[e+--t],i=1;for(;t>0&&(i*=256);)r+=this[e+--t]*i;return r},h.prototype.readUint8=h.prototype.readUInt8=function(e,t){return e>>>=0,t||M(e,1,this.length),this[e]},h.prototype.readUint16LE=h.prototype.readUInt16LE=function(e,t){return e>>>=0,t||M(e,2,this.length),this[e]|this[e+1]<<8},h.prototype.readUint16BE=h.prototype.readUInt16BE=function(e,t){return e>>>=0,t||M(e,2,this.length),this[e]<<8|this[e+1]},h.prototype.readUint32LE=h.prototype.readUInt32LE=function(e,t){return e>>>=0,t||M(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},h.prototype.readUint32BE=h.prototype.readUInt32BE=function(e,t){return e>>>=0,t||M(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},h.prototype.readBigUInt64LE=Z(function(e){z(e>>>=0,"offset");const t=this[e],s=this[e+7];void 0!==t&&void 0!==s||F(e,this.length-8);const r=t+256*this[++e]+65536*this[++e]+this[++e]*2**24,i=this[++e]+256*this[++e]+65536*this[++e]+s*2**24;return BigInt(r)+(BigInt(i)<<BigInt(32))}),h.prototype.readBigUInt64BE=Z(function(e){z(e>>>=0,"offset");const t=this[e],s=this[e+7];void 0!==t&&void 0!==s||F(e,this.length-8);const r=t*2**24+65536*this[++e]+256*this[++e]+this[++e],i=this[++e]*2**24+65536*this[++e]+256*this[++e]+s;return(BigInt(r)<<BigInt(32))+BigInt(i)}),h.prototype.readIntLE=function(e,t,s){e>>>=0,t>>>=0,s||M(e,t,this.length);let r=this[e],i=1,n=0;for(;++n<t&&(i*=256);)r+=this[e+n]*i;return i*=128,r>=i&&(r-=Math.pow(2,8*t)),r},h.prototype.readIntBE=function(e,t,s){e>>>=0,t>>>=0,s||M(e,t,this.length);let r=t,i=1,n=this[e+--r];for(;r>0&&(i*=256);)n+=this[e+--r]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*t)),n},h.prototype.readInt8=function(e,t){return e>>>=0,t||M(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},h.prototype.readInt16LE=function(e,t){e>>>=0,t||M(e,2,this.length);const s=this[e]|this[e+1]<<8;return 32768&s?4294901760|s:s},h.prototype.readInt16BE=function(e,t){e>>>=0,t||M(e,2,this.length);const s=this[e+1]|this[e]<<8;return 32768&s?4294901760|s:s},h.prototype.readInt32LE=function(e,t){return e>>>=0,t||M(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},h.prototype.readInt32BE=function(e,t){return e>>>=0,t||M(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},h.prototype.readBigInt64LE=Z(function(e){z(e>>>=0,"offset");const t=this[e],s=this[e+7];void 0!==t&&void 0!==s||F(e,this.length-8);const r=this[e+4]+256*this[e+5]+65536*this[e+6]+(s<<24);return(BigInt(r)<<BigInt(32))+BigInt(t+256*this[++e]+65536*this[++e]+this[++e]*2**24)}),h.prototype.readBigInt64BE=Z(function(e){z(e>>>=0,"offset");const t=this[e],s=this[e+7];void 0!==t&&void 0!==s||F(e,this.length-8);const r=(t<<24)+65536*this[++e]+256*this[++e]+this[++e];return(BigInt(r)<<BigInt(32))+BigInt(this[++e]*2**24+65536*this[++e]+256*this[++e]+s)}),h.prototype.readFloatLE=function(e,t){return e>>>=0,t||M(e,4,this.length),i.read(this,e,!0,23,4)},h.prototype.readFloatBE=function(e,t){return e>>>=0,t||M(e,4,this.length),i.read(this,e,!1,23,4)},h.prototype.readDoubleLE=function(e,t){return e>>>=0,t||M(e,8,this.length),i.read(this,e,!0,52,8)},h.prototype.readDoubleBE=function(e,t){return e>>>=0,t||M(e,8,this.length),i.read(this,e,!1,52,8)},h.prototype.writeUintLE=h.prototype.writeUIntLE=function(e,t,s,r){e=+e,t>>>=0,s>>>=0,r||R(this,e,t,s,Math.pow(2,8*s)-1,0);let i=1,n=0;for(this[t]=255&e;++n<s&&(i*=256);)this[t+n]=e/i&255;return t+s},h.prototype.writeUintBE=h.prototype.writeUIntBE=function(e,t,s,r){e=+e,t>>>=0,s>>>=0,r||R(this,e,t,s,Math.pow(2,8*s)-1,0);let i=s-1,n=1;for(this[t+i]=255&e;--i>=0&&(n*=256);)this[t+i]=e/n&255;return t+s},h.prototype.writeUint8=h.prototype.writeUInt8=function(e,t,s){return e=+e,t>>>=0,s||R(this,e,t,1,255,0),this[t]=255&e,t+1},h.prototype.writeUint16LE=h.prototype.writeUInt16LE=function(e,t,s){return e=+e,t>>>=0,s||R(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},h.prototype.writeUint16BE=h.prototype.writeUInt16BE=function(e,t,s){return e=+e,t>>>=0,s||R(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},h.prototype.writeUint32LE=h.prototype.writeUInt32LE=function(e,t,s){return e=+e,t>>>=0,s||R(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},h.prototype.writeUint32BE=h.prototype.writeUInt32BE=function(e,t,s){return e=+e,t>>>=0,s||R(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},h.prototype.writeBigUInt64LE=Z(function(e,t=0){return N(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),h.prototype.writeBigUInt64BE=Z(function(e,t=0){return O(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),h.prototype.writeIntLE=function(e,t,s,r){if(e=+e,t>>>=0,!r){const r=Math.pow(2,8*s-1);R(this,e,t,s,r-1,-r)}let i=0,n=1,o=0;for(this[t]=255&e;++i<s&&(n*=256);)e<0&&0===o&&0!==this[t+i-1]&&(o=1),this[t+i]=(e/n|0)-o&255;return t+s},h.prototype.writeIntBE=function(e,t,s,r){if(e=+e,t>>>=0,!r){const r=Math.pow(2,8*s-1);R(this,e,t,s,r-1,-r)}let i=s-1,n=1,o=0;for(this[t+i]=255&e;--i>=0&&(n*=256);)e<0&&0===o&&0!==this[t+i+1]&&(o=1),this[t+i]=(e/n|0)-o&255;return t+s},h.prototype.writeInt8=function(e,t,s){return e=+e,t>>>=0,s||R(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},h.prototype.writeInt16LE=function(e,t,s){return e=+e,t>>>=0,s||R(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},h.prototype.writeInt16BE=function(e,t,s){return e=+e,t>>>=0,s||R(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},h.prototype.writeInt32LE=function(e,t,s){return e=+e,t>>>=0,s||R(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},h.prototype.writeInt32BE=function(e,t,s){return e=+e,t>>>=0,s||R(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},h.prototype.writeBigInt64LE=Z(function(e,t=0){return N(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),h.prototype.writeBigInt64BE=Z(function(e,t=0){return O(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),h.prototype.writeFloatLE=function(e,t,s){return B(this,e,t,!0,s)},h.prototype.writeFloatBE=function(e,t,s){return B(this,e,t,!1,s)},h.prototype.writeDoubleLE=function(e,t,s){return D(this,e,t,!0,s)},h.prototype.writeDoubleBE=function(e,t,s){return D(this,e,t,!1,s)},h.prototype.copy=function(e,t,s,r){if(!h.isBuffer(e))throw new TypeError("argument should be a Buffer");if(s||(s=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<s&&(r=s),r===s)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(s<0||s>=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-s&&(r=e.length-t+s);const i=r-s;return this===e&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(t,s,r):Uint8Array.prototype.set.call(e,this.subarray(s,r),t),i},h.prototype.fill=function(e,t,s,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,s=this.length):"string"==typeof s&&(r=s,s=this.length),void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!h.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(1===e.length){const t=e.charCodeAt(0);("utf8"===r&&t<128||"latin1"===r)&&(e=t)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<s)throw new RangeError("Out of range index");if(s<=t)return this;let i;if(t>>>=0,s=void 0===s?this.length:s>>>0,e||(e=0),"number"==typeof e)for(i=t;i<s;++i)this[i]=e;else{const n=h.isBuffer(e)?e:h.from(e,r),o=n.length;if(0===o)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(i=0;i<s-t;++i)this[i+t]=n[i%o]}return this};const j={};function q(e,t,s){j[e]=class extends s{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(e){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:e,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}function H(e){let t="",s=e.length;const r="-"===e[0]?1:0;for(;s>=r+4;s-=3)t=`_${e.slice(s-3,s)}${t}`;return`${e.slice(0,s)}${t}`}function V(e,t,s,r,i,n){if(e>s||e<t){const r="bigint"==typeof t?"n":"";let i;throw i=n>3?0===t||t===BigInt(0)?`>= 0${r} and < 2${r} ** ${8*(n+1)}${r}`:`>= -(2${r} ** ${8*(n+1)-1}${r}) and < 2 ** ${8*(n+1)-1}${r}`:`>= ${t}${r} and <= ${s}${r}`,new j.ERR_OUT_OF_RANGE("value",i,e)}!function(e,t,s){z(t,"offset"),void 0!==e[t]&&void 0!==e[t+s]||F(t,e.length-(s+1))}(r,i,n)}function z(e,t){if("number"!=typeof e)throw new j.ERR_INVALID_ARG_TYPE(t,"number",e)}function F(e,t,s){if(Math.floor(e)!==e)throw z(e,s),new j.ERR_OUT_OF_RANGE(s||"offset","an integer",e);if(t<0)throw new j.ERR_BUFFER_OUT_OF_BOUNDS;throw new j.ERR_OUT_OF_RANGE(s||"offset",`>= ${s?1:0} and <= ${t}`,e)}q("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),q("ERR_INVALID_ARG_TYPE",function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),q("ERR_OUT_OF_RANGE",function(e,t,s){let r=`The value of "${e}" is out of range.`,i=s;return Number.isInteger(s)&&Math.abs(s)>2**32?i=H(String(s)):"bigint"==typeof s&&(i=String(s),(s>BigInt(2)**BigInt(32)||s<-(BigInt(2)**BigInt(32)))&&(i=H(i)),i+="n"),r+=` It must be ${t}. Received ${i}`,r},RangeError);const G=/[^+/0-9A-Za-z-_]/g;function $(e,t){let s;t=t||1/0;const r=e.length;let i=null;const n=[];for(let o=0;o<r;++o){if(s=e.charCodeAt(o),s>55295&&s<57344){if(!i){if(s>56319){(t-=3)>-1&&n.push(239,191,189);continue}if(o+1===r){(t-=3)>-1&&n.push(239,191,189);continue}i=s;continue}if(s<56320){(t-=3)>-1&&n.push(239,191,189),i=s;continue}s=65536+(i-55296<<10|s-56320)}else i&&(t-=3)>-1&&n.push(239,191,189);if(i=null,s<128){if((t-=1)<0)break;n.push(s)}else if(s<2048){if((t-=2)<0)break;n.push(s>>6|192,63&s|128)}else if(s<65536){if((t-=3)<0)break;n.push(s>>12|224,s>>6&63|128,63&s|128)}else{if(!(s<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;n.push(s>>18|240,s>>12&63|128,s>>6&63|128,63&s|128)}}return n}function K(e){return r.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(G,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function W(e,t,s,r){let i;for(i=0;i<r&&!(i+s>=t.length||i>=e.length);++i)t[i+s]=e[i];return i}function Y(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function J(e){return e!=e}const X=function(){const e="0123456789abcdef",t=new Array(256);for(let s=0;s<16;++s){const r=16*s;for(let i=0;i<16;++i)t[r+i]=e[s]+e[i]}return t}();function Z(e){return"undefined"==typeof BigInt?Q:e}function Q(){throw new Error("BigInt not supported")}},5199(e){const t=e=>{if(null===e)return null;if(!e||"object"!=typeof e||Array.isArray(e)||"string"!=typeof e.assetKey||!/^[\x20-\x7e]{1,32}$/.test(e.assetKey)||!e.assetKey.trim())throw new TypeError("Cursor must be null or contain an ASCII assetKey of 1–32 characters");const t=void 0===e.hotspot?{x:0,y:0}:e.hotspot;if(!t||"object"!=typeof t||Array.isArray(t)||!Number.isInteger(t.x)||t.x<0||!Number.isInteger(t.y)||t.y<0)throw new TypeError("Cursor hotspot must contain nonnegative integer x and y coordinates");const s={assetKey:e.assetKey,hotspot:{x:t.x||0,y:t.y||0}};if(void 0!==e.pointerLock){if("boolean"!=typeof e.pointerLock)throw new TypeError("Cursor pointerLock must be a boolean");s.pointerLock=e.pointerLock}if(void 0!==e.size){const t=e.size;if(!t||"object"!=typeof t||Array.isArray(t)||!Number.isInteger(t.width)||t.width<1||t.width>128||!Number.isInteger(t.height)||t.height<1||t.height>128)throw new TypeError("Cursor size must contain integer width and height from 1 to 128");s.size={width:t.width,height:t.height}}return s};e.exports={CURSOR_OPCODE:13,normalizeCursor:t,encodeCursor:e=>{const s=(new TextEncoder).encode(JSON.stringify(t(e))),r=new Uint8Array(s.length+1);return r[0]=13,r.set(s,1),r},decodeCursor:e=>{const s=e instanceof ArrayBuffer?new Uint8Array(e):ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):null;if(!s||s.length<2||s.length>256||13!==s[0])throw new TypeError("Invalid cursor packet");try{return t(JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(s.subarray(1))))}catch(e){throw new TypeError("Invalid cursor packet: "+e.message)}}}},739(e){"use strict";e.exports={createExportStorage:function(e,{installationId:t,gameId:s,packageRevision:r="local",database:i,transaction:n}){if("string"!=typeof t||!t||"string"!=typeof s||!s)throw new Error("Export storage requires a host-selected game identity");const o=[t,s,r];let a;const h=()=>i?Promise.resolve(i):a||=new Promise((t,s)=>{const r=e.indexedDB.open("homegames-user-exports",1);r.onupgradeneeded=()=>r.result.createObjectStore("exports"),r.onerror=()=>s(r.error),r.onsuccess=()=>{r.result.onversionchange=()=>r.result.close(),t(r.result)}});function l(e){const t=Object.keys(e),s=new Set;let r=0;if(t.length>128)throw new Error("Too many exports");for(const i of t){if(!/^[A-Za-z0-9_][A-Za-z0-9_. -]{0,119}$/.test(i)||/[ .]$/.test(i)||/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(i)||["__proto__","constructor","prototype"].includes(i)||s.has(i.toLowerCase()))throw new Error("Invalid export name");s.add(i.toLowerCase());const t=e[i];if(!(t instanceof Uint8Array)||t.length>16777216||(r+=t.length)>67108864)throw new Error("Export size limit exceeded")}}return{async getExports(){const e=await h();return new Promise((t,s)=>{const r=e.transaction("exports","readonly"),i=r.objectStore("exports").get(o);r.oncomplete=()=>{try{const e=i.result||{};l(e),t(e)}catch(e){s(e)}},r.onabort=()=>s(r.error||new Error("Unable to read exports"))})},async putExport(e,t){l({[e]:t}),t=t.slice();const s=await h();return new Promise((r,i)=>{const a=n?n(["exports"]):s.transaction("exports","readwrite"),h=a.objectStore("exports"),c=h.get(o);let d;c.onsuccess=()=>{try{const s={...c.result,[e]:t};l(s),h.put(s,o)}catch(e){d=e,a.abort()}},a.oncomplete=()=>r(),a.onabort=()=>i(d||a.error||new Error("Unable to save export"))})}}}}},97(e){"use strict";e.exports={createExportsViewer:function(e,{list:t,read:s}){const r=e.document,i=(e,t,s)=>{const i=r.createElement(e);return t&&(i.textContent=t),s?.append(i),i},n=i("dialog");n.className="hg-exports",n.setAttribute("aria-label","Game exports"),i("style",null,n).textContent=".hg-exports{box-sizing:border-box;width:min(760px,calc(100vw - 24px));max-height:calc(100dvh - 24px);margin:auto;padding:20px;border:1px solid #4a5049;border-radius:16px;background:#202321;color:#f6f6ee;font:14px/1.5 system-ui,sans-serif;text-align:left;overflow:auto;box-shadow:0 24px 80px #0009}\n .hg-exports::backdrop{background:#080c0ac9}.hg-exports *{box-sizing:border-box}.hg-exports h2{font-size:22px;margin:0}.hg-exports p{margin:10px 0;color:#b7bfb5}.hg-exports button{min-height:44px;padding:8px 12px;border:1px solid #596157;border-radius:8px;background:#30372e;color:#f6f6ee;font:inherit;cursor:pointer;text-align:left}.hg-exports button:disabled{opacity:.5;cursor:wait}.hg-exports :focus-visible{outline:2px solid #fff78e;outline-offset:3px}.hg-exports-head{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.hg-exports-head h2{flex:1}.hg-exports-body{display:grid;grid-template-columns:minmax(140px,1fr) minmax(0,2fr);gap:16px}.hg-exports-files{display:flex;flex-direction:column;gap:6px;max-height:55dvh;overflow:auto}.hg-exports-files button{overflow-wrap:anywhere}.hg-exports-files button[aria-pressed=true]{border-color:#fff78e;background:#414530}.hg-exports-preview{min-width:0;overflow-wrap:anywhere}.hg-exports-preview h3{font-size:15px;margin:0 0 12px}.hg-exports-preview img,.hg-exports-preview video{display:block;max-width:100%;max-height:42dvh;background:#101211;margin:0 auto 12px}.hg-exports-preview audio{width:100%;margin-bottom:12px}.hg-exports-preview pre{white-space:pre-wrap;max-height:38dvh;overflow:auto;background:#101211;padding:12px;font:12px/1.5 monospace}.hg-exports-preview .hg-exports-save{background:#fff78e;color:#22261e;border-color:#fff78e}@media(max-width:520px){.hg-exports{padding:16px}.hg-exports-body{grid-template-columns:1fr}.hg-exports-files{max-height:150px}.hg-exports-preview img,.hg-exports-preview video{max-height:30dvh}}";const o=i("div",null,n);o.className="hg-exports-head",i("h2","Game exports",o);const a=i("button","Refresh",o),h=i("button","Close",o),l=i("p","Loading exports…",n);l.setAttribute("role","status");const c=i("div",null,n);c.className="hg-exports-body";const d=i("div",null,c);d.className="hg-exports-files",d.setAttribute("aria-label","Export files");const u=i("div",null,c);u.className="hg-exports-preview";let p,f,m=!1,g=!1;const y=new Promise(e=>{f=e});function v(){u.querySelectorAll("video,audio").forEach(e=>{e.pause(),e.removeAttribute("src"),e.load()}),u.replaceChildren(),p&&e.URL.revokeObjectURL(p),p=null}function w(){m||(m=!0,v(),n.close(),n.remove(),f())}const x=e=>e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`;function b(e){g=e,a.disabled=e,d.querySelectorAll("button").forEach(t=>{t.disabled=e})}async function E(t,n){if(!m&&!g){b(!0),v(),l.textContent=`Loading ${t.name}…`,d.querySelectorAll("button").forEach(e=>e.setAttribute("aria-pressed",String(e===n)));try{const n=await s(t.name);if(m)return;if(n.name!==t.name||!(n.bytes instanceof Uint8Array)||n.bytes.length>16777216)throw new Error("Invalid export file");const{name:o,bytes:a}=n,h=function(e,t){const s=(e,s)=>[...s].every((s,r)=>t[e+r]===s.charCodeAt(0));return s(0,"‰PNG\r\n\n")?"image/png":255===t[0]&&216===t[1]&&255===t[2]?"image/jpeg":s(0,"GIF87a")||s(0,"GIF89a")?"image/gif":s(0,"RIFF")&&s(8,"WEBP")?"image/webp":s(0,"RIFF")&&s(8,"WAVE")?"audio/wav":s(0,"Eߣ")?/\.(weba|opus)$/i.test(e)?"audio/webm":"video/webm":s(4,"ftyp")?/\.(m4a|aac)$/i.test(e)?"audio/mp4":"video/mp4":s(0,"OggS")?/\.ogv$/i.test(e)?"video/ogg":"audio/ogg":s(0,"ID3")||255===t[0]&&!(224&~t[1])?"audio/mpeg":"application/octet-stream"}(o,a);if(i("h3",o,u),l.textContent=`${x(a.length)} · Shared with everyone in this game`,p=e.URL.createObjectURL(new e.Blob([a],{type:h})),/^(image|audio|video)\//.test(h)){const e=i(h.startsWith("image/")?"img":h.split("/")[0],null,u);"IMG"===e.tagName?e.alt=o:(e.controls=!0,e.preload="metadata",e.setAttribute("playsinline","")),e.src=p,e.onerror=()=>{!m&&e.isConnected&&(l.textContent="This browser cannot preview this file. You can still save it.")}}else if(/\.(json|txt|csv|md|js|html|css|xml|svg|yaml|yml)$/i.test(o)){const t=(new e.TextDecoder).decode(a.subarray(0,65536));i("pre",t||"(Empty file)",u),a.length>65536&&i("p","Preview shows the first 64 KB. Save file includes all bytes.",u)}else i("p","No preview for this format. Save it to open in another app.",u);const c=i("button","Save file",u);c.className="hg-exports-save",c.onclick=()=>{const t=e.URL.createObjectURL(new e.Blob([a],{type:h})),s=i("a",null,r.body);s.href=t,s.download=o,s.click(),s.remove(),e.setTimeout(()=>e.URL.revokeObjectURL(t),3e4)}}catch(e){m||(l.textContent=e.message)}finally{m||b(!1)}}}async function S(){if(!m&&!g){b(!0),v(),d.replaceChildren(),l.textContent="Loading exports…";try{const e=await t();if(m)return;if(!Array.isArray(e)||e.length>128||e.some(e=>{return!("string"==typeof(t=e.name)&&/^[A-Za-z0-9_][A-Za-z0-9_. -]{0,119}$/.test(t)&&!/[ .]$/.test(t)&&Number.isSafeInteger(e.size))||e.size<0||e.size>16777216;var t}))throw new Error("Invalid export list");l.textContent=e.length?"Choose a file to preview and save. These files are shared with everyone in this game.":"No exports yet. Files saved by this game will appear here.";for(const t of e){const e=i("button",`${t.name} · ${x(t.size)}`,d);e.setAttribute("aria-pressed","false"),e.onclick=()=>E(t,e)}}catch(e){m||(l.textContent=e.message)}finally{m||b(!1)}}}return a.onclick=S,h.onclick=w,n.oncancel=e=>{e.preventDefault(),w()},r.body.append(n),n.showModal(),h.focus(),S(),{result:y,close:w}}}},5766(e,t,s){var r=s(8287).hp;const i=8388608,n=s(6862),o=(e,t)=>!e.playerIds?.length||e.playerIds.some(e=>e==t),a=e=>Object.values(e||{}).filter(e=>e?.root?.node),{describeMedia:h}=s(3947);e.exports=class{constructor(e,t={}){this.game=e,this.gameInput=new n(e),this._activePresses={},this.getLayers=t.getLayers||(()=>e.getLayers()),this.findNode=t.findNode||(t=>e.findNode(t)),this.findPointerNode=t.findPointerNode||this.findNode,this.toGameCoords=t.toGameCoords||((e,t)=>({x:e,y:t})),this.fileBuffers=!!t.fileBuffers,this.canControlGame=t.canControlGame||(()=>!0)}handleInput(e,t){if(!t||"object"!=typeof t||"string"!=typeof t.type)return;const s=Number(e);if(Number.isSafeInteger(s)&&!(s<=0))try{if("click"===t.type){const e=t.data;if(!e||"number"!=typeof e.x||"number"!=typeof e.y)return;this._handleClick(s,e)}else if("keydown"===t.type){if(!this.canControlGame(s)||"string"!=typeof t.key||t.key.length>20)return;this.gameInput.keyDown(s,t.key)}else if("keyup"===t.type){if(!this.canControlGame(s)||"string"!=typeof t.key||t.key.length>20)return;this.gameInput.keyUp(s,t.key)}else if("mouseup"===t.type)this.canControlGame(s)&&this.game.handleMouseUp?.(s,t.data),this.endPress(s,t.data);else if("mousemove"===t.type)this._handleDragMove(s,t.data);else if("pointermove"===t.type){const e=t.data;if(!this.canControlGame(s)||!e||!Number.isFinite(e.dx)||!Number.isFinite(e.dy)||Math.abs(e.dx)>4096||Math.abs(e.dy)>4096)return;this.game.handlePointerMove?.(s,{dx:e.dx,dy:e.dy})}else if("input"===t.type)if(t.gamepad)this.canControlGame(s)&&this.gameInput.gamepad(s,t);else{const e=this._findInputNode(t.nodeId,s);if(e&&e.node&&e.node.input)if("file"===e.node.input.type){const n=((e,t=!1)=>{if("string"==typeof e){if(e.length>4*Math.ceil(2796202.6666666665))return null;let s;if(!t&&"function"==typeof atob){if(s=atob(e),0===s.length||s.length>i)return null;const t=new Uint8Array(s.length);for(let e=0;e<s.length;e++)t[e]=s.charCodeAt(e);return t}const n=r.from(e,"base64");return 0===n.length||n.length>i?null:n}if(e&&"object"==typeof e){const s=Object.values(e);return 0===s.length||s.length>i||s.some(e=>!Number.isInteger(e)||e<0||e>255)?null:t?r.from(s):Uint8Array.from(s)}return null})(t.input,this.fileBuffers);n&&e.node.input.oninput(s,n,((e,t)=>({...h(e,t),contentType:"string"==typeof t.contentType&&t.contentType.length<=100?t.contentType:null}))(n,t))}else e.node.input.oninput(s,t.input)}else if("onhover"===t.type){const e=this._findInputNode(t.nodeId,s);e&&e.node&&e.node.onHover&&e.node.onHover(s)}else if("offhover"===t.type){const e=this._findInputNode(t.nodeId,s);e&&e.node&&e.node.offHover&&e.node.offHover(s)}}catch(e){console.error(`[GameDispatcher] Error handling input type="${t.type}":`,e)}}_findInputNode(e,t){if(!Number.isSafeInteger(e)||e<0)return null;const s=new Set,r=(i,n)=>{const a=i?.node;if(!a||n>100||s.has(a)||!o(a,t))return null;if(s.add(a),a.id===e)return i;for(const e of Object.values(a.children||{})){const t=r(e,n+1);if(t)return t}return null};for(const e of a(this.getLayers(void 0,void 0,t))){if(!1===e.interactive)continue;const t=r(e.root,0);if(t)return t}return null}_handleClick(e,t){if(!t||!Number.isFinite(t.x)||!Number.isFinite(t.y))return;if(t.x<0||t.y<0||t.x>=100||t.y>=100)return;const s=this._activePresses[e],r=!s||!0===t.press;s&&!0===t.press?this.endPress(e,null):s&&!r&&this._handleDragMove(e,t);const i=this._findClickTarget(t.x,t.y,e);if(r&&(this._activePresses[e]={node:i?.node||null,path:i?.path,x:t.x,y:t.y}),i?.node.handleClick){const{x:s,y:r}=this.toGameCoords(t.x,t.y);i.node.handleClick(e,s,r)}}_handleDragMove(e,t){if(!t||!Number.isFinite(t.x)||!Number.isFinite(t.y))return;if(t.x<0||t.y<0||t.x>=100||t.y>=100)return;this.checkActivePresses(e);const s=this._activePresses[e];s&&(s.x=t.x,s.y=t.y);const{x:r,y:i}=this.toGameCoords(t.x,t.y);try{this.canControlGame(e)&&this.game.handleMouseMove?.(e,{x:r,y:i})}catch(e){console.error("[GameDispatcher] game.handleMouseMove threw:",e)}if(s&&s.node&&"function"==typeof s.node.onDrag)try{s.node.onDrag(e,r,i)}catch(e){console.error("[GameDispatcher] node.onDrag threw:",e)}}endPress(e,t){const s=this._activePresses[e];if(s&&(delete this._activePresses[e],s.node&&"function"==typeof s.node.offClick)){const r=t&&Number.isFinite(t.x)&&Number.isFinite(t.y)?t:{x:s.x,y:s.y};try{const{x:t,y:i}=this.toGameCoords(r.x,r.y);s.node.offClick(e,t,i)}catch(e){console.error("[GameDispatcher] node.offClick threw:",e)}}}checkActivePresses(e){if(void 0===e){for(const e of Object.keys(this._activePresses))this.checkActivePresses(e);return}const t=this._activePresses[e];if(!t||!t.node)return;const s=t.path;s&&a(this.getLayers(void 0,void 0,e)).some(e=>!1!==e.interactive&&e.root.node===s[0])&&!s.some((t,r)=>!o(t,e)||r>0&&!Object.values(s[r-1].children||{}).some(e=>e?.node===t))||this.endPress(e,null)}_findClick(e,t,s){return this._findClickTarget(e,t,s)?.node||null}_findClickTarget(e,t,s){let r=null;for(const i of a(this.getLayers(e,t,s)))!1!==i.interactive&&(r=this._findClickHelper(e,t,s,i.root.node,null,i.scale||{x:1,y:1},0)||r);return r}_findClickHelper(e,t,s,r,i,n,a,h=[]){if(a>100)return i;if(!o(r,s))return i;if(h.push(r),r.coordinates2d&&r.coordinates2d.length>0){const s=[];for(let e=0;e<r.coordinates2d.length;e++){const t=100-100*n.x,i=100-100*n.y,o=r.coordinates2d[e][0]*((100-t)/100)+t/2,a=r.coordinates2d[e][1]*((100-i)/100)+i/2;s.push([o,a])}if(s.length>0){let n=!1,o=s[0][0],a=s[0][0],l=s[0][1],c=s[0][1];for(let e=1;e<s.length;e++)o=Math.min(s[e][0],o),a=Math.max(s[e][0],a),l=Math.min(s[e][1],l),c=Math.max(s[e][1],c);if(!(e<o||e>a||t<l||t>c)){let r=0,i=s.length-1;for(;r<s.length;i=r++)s[r][1]>t!=s[i][1]>t&&e<(s[i][0]-s[r][0])*(t-s[r][1])/(s[i][1]-s[r][1])+s[r][0]&&(n=!n)}n&&(i={node:r,path:h.slice()})}}if(r.children){const o=Object.keys(r.children);for(let l=0;l<o.length;l++){const c=r.children[o[l]];c&&c.node&&(i=this._findClickHelper(e,t,s,c.node,i,n,a+1,h))}}return h.pop(),i}}},6862(e,t,s){const{Buttons:r,mapInputs:i}=s(1011),n=s(6260),o=(e,t,s)=>Number.isFinite(e)?Math.max(t,Math.min(s,e)):0,a=()=>({buttons:Object.fromEntries(Object.values(r).map(e=>[e,{value:0,pressed:!1}])),sticks:Object.fromEntries(Object.keys(n.sticks).map(e=>[e,{value:0}]))});e.exports=class{constructor(e){this.game=e,this.bindings=e.constructor.metadata?.().gamepadBindings||{},this.players=new Map}_player(e){return this.players.has(e)||this.players.set(e,{keyboard:new Set,pads:new Map}),this.players.get(e)}_keys(e){return new Set([...e.keyboard,...Array.from(e.pads.values()).flatMap(e=>[...e.keys])])}keyDown(e,t){this._player(e).keyboard.add(t),this.game.handleKeyDown?.(e,t)}keyUp(e,t){const s=this._player(e);s.keyboard.delete(t),this._keys(s).has(t)||this.game.handleKeyUp?.(e,t)}gamepad(e,t){const s=t.gamepadIndex??0;if(!Number.isInteger(s)||s<0||s>15)return;if(!t.input||"object"!=typeof t.input)return;if(!(!1===t.connected||t.input.buttons&&t.input.sticks))return;const r=a();if(!1!==t.connected){for(const e of Object.keys(r.buttons)){const s=t.input.buttons[e];r.buttons[e]={value:o(s?.value,0,1),pressed:!0===s?.pressed}}for(const e of Object.keys(r.sticks))r.sticks[e].value=o(t.input.sticks[e]?.value,-1,1)}const n=this._player(e),h=this._keys(n),l=n.pads.get(s),c=Object.keys(r.buttons).filter(e=>r.buttons[e].pressed&&!l?.state.buttons[e].pressed),d=Object.keys(r.buttons).filter(e=>!r.buttons[e].pressed&&l?.state.buttons[e].pressed),u=new Set(Object.entries(i(r,this.bindings)).filter(([,e])=>e.pressed).map(([e])=>e));!1===t.connected?n.pads.delete(s):n.pads.set(s,{state:r,keys:u});const p=this._keys(n);for(const t of h)p.has(t)||this.game.handleKeyUp?.(e,t);for(const t of u){const r=[...n.pads].find(([,e])=>e.keys.has(t))?.[0];n.keyboard.has(t)||r!==s||this.game.handleKeyDown?.(e,t)}this.game.handleGamepadInput?.(e,{type:"input",gamepad:!0,gamepadIndex:s,connected:!1!==t.connected,deltaTime:!1===t.connected?0:o(t.deltaTime??1/30,0,.1),input:r,pressed:c,released:d})}removePlayer(e){const t=this.players.get(e);if(t){this.players.delete(e);for(const s of this._keys(t))this.game.handleKeyUp?.(e,s);for(const[s,r]of t.pads)this.game.handleGamepadInput?.(e,{type:"input",gamepad:!0,gamepadIndex:s,connected:!1,deltaTime:0,input:a(),pressed:[],released:Object.keys(r.state.buttons).filter(e=>r.state.buttons[e].pressed)})}}}},7821(e,t,s){"use strict";const r=s(8630),i=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n=e=>{throw new Error(e)};function o(e,t){if(e&&"string"==typeof e.type){t(e);for(const s of Object.values(e))Array.isArray(s)?s.forEach(e=>o(e,t)):s&&"string"==typeof s.type&&o(s,t)}}function a(e,t,s=new Map,r=new Set){e||n(`${t} must be declared as a literal`),(r.has(e)||r.size>64)&&n(`Circular or excessive constant expression in ${t}`),r=new Set(r).add(e);const o=e=>a(e,t,s,r),h=(e,r=new Set)=>{if((!e||r.has(e)||r.size>64)&&n(`Unresolved constant in ${t}`),r.add(e),"Identifier"===e.type&&s.has(e.name))return h(s.get(e.name),r);if("MemberExpression"===e.type){const t=h(e.object,r),s=e.computed?o(e.property):e.property.name;if("ObjectExpression"===t.type)return h(t.properties.find(e=>"Property"===e.type&&!e.computed&&(e.key.name??e.key.value)===s)?.value,r)}return e},l=h(e);if(l!==e)return o(l);if("Literal"===e.type&&!(e.value instanceof RegExp))return e.value;if("UnaryExpression"===e.type&&["-","+","!"].includes(e.operator)){const t=o(e.argument);return"!"===e.operator?!t:"-"===e.operator?-t:+t}if("ArrayExpression"===e.type)return e.elements.map(o);if("ObjectExpression"===e.type){const s=Object.create(null);for(const r of e.properties){("Property"!==r.type||r.computed||r.method||"init"!==r.kind)&&n(`${t} must use literal properties`);const e=r.key.name??r.key.value;i(s,e)&&n(`Duplicate ${t} property: ${e}`),s[e]=o(r.value)}return s}n(`${t} must be declared as a literal`)}function h(e,{strictAssets:t=!0,requireExport:s=!1}={}){const h=r.parse(e,{ecmaVersion:"latest",sourceType:"script"}),l=new Map;for(const e of h.body)if("ClassDeclaration"===e.type&&l.set(e.id?.name,e),"VariableDeclaration"===e.type)for(const t of e.declarations)"Identifier"===t.id.type&&"ClassExpression"===t.init?.type&&l.set(t.id.name,t.init);const c=h.body.filter(e=>"ExpressionStatement"===e.type).map(e=>e.expression).filter(e=>"AssignmentExpression"===e.type&&"="===e.operator&&"MemberExpression"===e.left.type&&"module"===e.left.object.name&&"exports"===(e.left.computed?e.left.property.value:e.left.property.name)),d=c[0]?.right,u="ClassExpression"===d?.type?d:"Identifier"===d?.type?l.get(d.name):null;!s||1===c.length&&u||n("Entry must export its Game class directly with module.exports");const p=[],f=e=>{"MethodDefinition"!==e.type||"method"!==e.kind||!e.static||e.computed||"PrivateIdentifier"===e.key.type||e.value.async||e.value.generator||"metadata"!==(e.key.name??e.key.value)||p.push(e)};s?u.body.body.forEach(f):o(h,f);const m=p[0]?.value.body.body;1===p.length&&1===m.length&&"ReturnStatement"===m[0].type&&"ObjectExpression"===m[0].argument?.type||n("Games need one static metadata() returning a literal object");const g=m[0].argument,y=new Map,v=Object.create(null),w=[];for(const e of h.body)if("VariableDeclaration"===e.type&&"const"===e.kind)for(const t of e.declarations)"Identifier"===t.id.type&&y.set(t.id.name,t.init);for(const e of g.properties){("Property"!==e.type||e.computed||e.method||"init"!==e.kind)&&n("Game metadata must use literal properties");const s=e.key.name??e.key.value;if(i(v,s)&&n(`Duplicate metadata property: ${s}`),"assets"===s){"ObjectExpression"!==e.value.type&&n("metadata.assets must be a literal object"),v.assets=Object.create(null);for(const s of e.value.properties){("Property"!==s.type||s.computed||s.method||"init"!==s.kind)&&n("Asset declarations must use literal keys");const e=s.key.name??s.key.value,r=s.value;let o;/^[A-Za-z0-9_-]{1,32}$/.test(e)&&!["__proto__","constructor","prototype"].includes(e)||n(`Invalid asset key: ${e}`),t&&i(v.assets,e)&&n(`Duplicate asset key: ${e}`),"NewExpression"===r.type&&"Asset"===r.callee.name&&1===r.arguments.length||n(`Asset ${e} must use new Asset({ path, type })`);try{o=a(r.arguments[0],`Asset ${e}`,y)}catch(e){if(t)throw e;continue}v.assets[e]=o,w.push({key:e,info:o,node:r})}}else v[s]=a(e.value,`metadata.${s}`,y)}const x=new Set;o(h,e=>{"CallExpression"===e.type&&"require"===e.callee.name&&"string"==typeof e.arguments[0]?.value&&/^squish-[0-9]+$/.test(e.arguments[0].value)&&x.add(e.arguments[0].value.slice(7))}),x.size>1&&n("Mixed Squish runtimes are unsupported");const b=[...x][0];return b&&void 0!==v.squishVersion&&b!==v.squishVersion&&n("metadata.squishVersion must match the Squish import"),{tree:h,object:g,bindings:y,metadata:v,assets:w,runtime:b}}e.exports={walk:o,literal:a,readSourceMetadata:h,rewriteMetadata:function(e,t,{remove:s=[],requireExport:i=!1}={}){const{object:o}=h(e,{requireExport:i}),a=new Set(s),l=[],c=new Set,d=[...r.tokenizer(e,{ecmaVersion:"latest"})],u=o.properties;for(let e=0;e<u.length;e++){const s=u[e],r=s.key.name??s.key.value;if(c.add(r),Object.hasOwn(t,r))l.push({start:s.start,end:s.end,value:`${r}: ${JSON.stringify(t[r])}`});else if(a.has(r)){const t=d.find(t=>","===t.type.label&&t.start>=s.end&&t.end<=(u[e+1]?.start??o.end));if(t)l.push({start:s.start,end:t.end,value:""});else{const t=d.find(t=>","===t.type.label&&t.start>=(u[e-1]?.end??o.start)&&t.end<=s.start);l.push({start:t?.start??s.start,end:s.end,value:""})}}}const p=Object.entries(t).filter(([e])=>!c.has(e));p.length&&(p.some(([e])=>!/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e))&&n("Invalid metadata property name"),l.push({start:o.start+1,end:o.start+1,value:"\n "+p.map(([e,t])=>`${e}: ${JSON.stringify(t)}`).join(",\n ")+(u.length?",":"")+"\n"}));const f=[];for(const e of l.sort((e,t)=>e.start-t.start||e.end-t.end)){const t=f[f.length-1];t&&!t.value&&!e.value&&e.start<=t.end?t.end=Math.max(t.end,e.end):f.push(e)}for(const t of f.reverse())e=e.slice(0,t.start)+t.value+e.slice(t.end);return e},...s(2439)}},2947(e,t,s){"use strict";const{createProject:r}=s(5110),{DIRECTORY:i,createUserExports:n}=s(5828),o=new WeakMap;function a(e){let t,s=e;for(;s&&!(t=o.get(s));)s=Object.getPrototypeOf(s);return t}e.exports={bindGameProject:function(e,t,s={},r={}){return o.set(e,{readProject:t,options:s,exports:r}),e},openGameExports:function(e,{saved:t={},persist:s}={}){const r=a(e);return r?.exports.open?r.exports.open():n({...r?.exports.files,...t},s)},exportGameProject:async function(e,t){const s=a(e.constructor);if(!s)throw new Error("This host has no portable source package for this game");const n=t&&await t.snapshot(),o=await s.readProject();if(!t)return o;const h=Object.fromEntries(o.reader.listFiles().map(e=>[e,o.reader.readFile(e)]));for(const[e,t]of Object.entries(n))h[i+"/"+e]=t;return r(h,s.options)}}},3735(e){const t=e=>{const t=[];for(const s of e.split("/"))s&&"."!==s&&(".."===s?t.pop():t.push(s));return t.join("/")},s={image:1,audio:2,font:3,video:4};new WeakMap,e.exports={normalizePath:t,resolveInFiles:(e,s,r)=>{for(const i of((e,s)=>{const r=t(e?e+"/"+s:s);return[r,r+".js",r+"/index.js"]})(s,r))if(Object.prototype.hasOwnProperty.call(e,i))return i;return null},packAssetBundle:e=>{const t=e.map(({key:e,type:t,data:r})=>{const i=new Uint8Array(44+r.length);i[0]=1,i[1]=s[t]||s.image;const n=(r.length+32).toString(36),o=10-n.length;for(let e=0;e<o;e++)i[2+e]=48;for(let e=0;e<n.length;e++)i[2+o+e]=n.charCodeAt(e);const a=Math.min(32,e.length);for(let t=0;t<a;t++)i[12+t]=e.charCodeAt(t);return i.set(r,44),i}),r=t.reduce((e,t)=>e+t.length,0),i=new Uint8Array(r);let n=0;for(const e of t)i.set(e,n),n+=e.length;return i},splitAssetBundle:(e,t=10485760)=>{const s=[];let r=0,i=0;for(;i<e.length;){const n=String.fromCharCode(...e.subarray(i+2,i+12)),o=parseInt(n,36)+12;if(1!==e[i]||!/^[0-9a-z]{10}$/.test(n)||o<44||i+o>e.length)throw new Error("Invalid asset bundle");if(o>t)throw new Error("An asset exceeds the RTC packet limit");i+o-r>t&&(s.push(e.subarray(r,i)),r=i),i+=o}return i>r&&s.push(e.subarray(r,i)),s}}},6620(e,t,s){var r=s(8287).hp;const{MAX_UPLOAD_BYTES:i,describeMedia:n}=s(3947);e.exports=class{constructor(){this.endpoints=new Map,this.streams=new Map,this.recordings=new Map,this.listeners=new Set,this.sequence=0}onChange(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notify(e,t){const s={...e.info,state:t};for(const e of this.listeners)try{e(s)}catch(e){console.error(e)}}join(e,t){this.endpoints.set(e,t);for(const s of this.streams.values())s.ready&&this.deliver(s,e,t)}request(e,t={}){const s=this.endpoints.get(Number(e));if(!s||this.closed||!1===s.live)return Promise.reject(new Error("This client connection does not support live media"));if(!t.audio&&!t.video)return Promise.reject(new Error("Request audio or video"));if(this.recordings.has(Number(e))||[...this.streams.values()].some(t=>t.info.playerId===Number(e)))return Promise.reject(new Error("Stop your current microphone/camera before enabling another"));const r="media-"+ ++this.sequence,i={id:r,playerId:Number(e),audio:!!t.audio,video:!!t.video,transmitting:!1!==t.transmitting,pushToTalk:!!t.pushToTalk};return new Promise((e,t)=>{const n={info:i,resolve:e,reject:t};n.timer=setTimeout(()=>this.stop(r,"Microphone/camera permission timed out"),6e4),this.streams.set(r,n),s.send({type:"media",action:"request",stream:i})})}record(e,t={}){e=Number(e);const s=this.endpoints.get(e);if(!s||this.closed)return Promise.reject(new Error("This client connection does not support recording"));if(!1===s.recording)return Promise.reject(new Error("This player needs the updated Homegames client to record."));if(this.recordings.has(e)||[...this.streams.values()].some(t=>t.info.playerId===e))return Promise.reject(new Error("Stop your current microphone/camera before recording"));const r="audio"===t.kind?"audio":"video";if("audio"===r&&!0!==s.audioRecording)return Promise.reject(new Error("This client does not support audio recording. Choose an audio file instead."));const n=Math.min(30,Math.max(1,Number(t.durationSeconds)||30)),o=Math.min(i,Math.max(131072,Math.floor(Number(t.maxBytes)||i))),a={id:"recording-"+ ++this.sequence,kind:r,durationSeconds:n,maxBytes:o,prompt:String(t.prompt||"").slice(0,120)};return new Promise((t,r)=>{const i={info:a,resolve:t,reject:r};i.timer=setTimeout(()=>this.cancelRecording(e,"Recording timed out. Please try again."),18e4),this.recordings.set(e,i),s.send({type:"media",action:"record",recording:a})})}cancelRecording(e,t="Recording cancelled"){const s=this.recordings.get(e);s&&(this.recordings.delete(e),clearTimeout(s.timer),this.endpoints.get(e)?.send({type:"media",action:"record-cancel",id:s.info.id}),s.reject(new Error(t)))}recordingResult(e,t){const s=this.recordings.get(e);if(s&&s.info.id===t.id)if(t.error)this.cancelRecording(e,String(t.error).slice(0,160));else try{if("string"!=typeof t.data||!t.data.length||t.data.length>4*Math.ceil(s.info.maxBytes/3)||!/^[A-Za-z0-9+/]*={0,2}$/.test(t.data))throw new Error("Invalid or oversized recording");const i=r.from(t.data,"base64"),o=n(i,{contentType:t.contentType,fileName:t.fileName});if(!i.length||i.length>s.info.maxBytes||o.kind!==s.info.kind)throw new Error("Recording must match the requested media kind and size limit");this.recordings.delete(e),clearTimeout(s.timer),s.resolve({bytes:i,meta:o,durationSeconds:s.info.durationSeconds})}catch(t){this.cancelRecording(e,t.message)}}handle(e,t){if("record-result"===t.action)return void this.recordingResult(e,t);const s=this.streams.get(t.id);if(s&&s.info.playerId===e)if("result"!==t.action||s.ready)"stopped"===t.action?this.stop(t.id):"released"===t.action&&this.setTransmitting(t.id,!1);else{if(t.error)return void this.stop(t.id,String(t.error).slice(0,160));if("string"!=typeof t.sourceId||t.sourceId.length>128)return;clearTimeout(s.timer),s.ready=!0,s.info.sourceId=t.sourceId,s.resolve({...s.info}),s.resolve=s.reject=null;for(const[e,t]of this.endpoints)this.deliver(s,e,t);this.notify(s,"ready")}}attach(e,t){const s=[...this.streams.values()].find(s=>s.ready&&s.info.playerId===e&&s.info.sourceId===t.id);if(!s)return!1;s.native=t;for(const[e,t]of this.endpoints)this.deliver(s,e,t);return!0}deliver(e,t,s){s.send({type:"media",action:"available",stream:{...e.info}}),e.native&&t!==e.info.playerId&&s.addMedia(e.info.id,e.native)}setTransmitting(e,t){const s=this.streams.get(e);if(s?.ready&&s.info.transmitting!==!!t){s.info.transmitting=!!t;for(const e of this.endpoints.values())e.send({type:"media",action:"state",stream:{...s.info}});this.notify(s,"changed")}}stop(e,t="Stream stopped"){const s=this.streams.get(e);if(s){this.streams.delete(e),clearTimeout(s.timer),s.reject?.(new Error(t));for(const t of this.endpoints.values())t.send({type:"media",action:"ended",id:e}),t.removeMedia(e);this.notify(s,"ended")}}leave(e){this.cancelRecording(e,"The player left");for(const[t,s]of this.streams)s.info.playerId===e&&this.stop(t,"The player left");this.endpoints.delete(e)}destroy(){if(!this.closed){this.closed=!0;for(const e of[...this.recordings.keys()])this.cancelRecording(e,"The session ended");for(const e of[...this.streams.keys()])this.stop(e,"The session ended");this.endpoints.clear(),this.listeners.clear()}}}},3947(e){const t=5242880,s=(e,t,s)=>String.fromCharCode(...e.subarray(t,t+s)),r=(e,t={})=>{const r="string"==typeof t.fileName?t.fileName.slice(0,128):null,i="string"==typeof t.contentType?t.contentType.toLowerCase().split(";")[0].slice(0,100):"";let n=null,o=null;const a=(e,t)=>{n=e,o=t};if(e.length>=4&&137===e[0]&&"PNG"===s(e,1,3))a("image","image/png");else if(e.length>=3&&255===e[0]&&216===e[1]&&255===e[2])a("image","image/jpeg");else if("GIF"===s(e,0,3))a("image","image/gif");else if("RIFF"===s(e,0,4)){const t=s(e,8,4);"WEBP"===t&&a("image","image/webp"),"WAVE"===t&&a("audio","audio/wav"),"AVI "===t&&a("video","video/x-msvideo")}else if("ID3"===s(e,0,3)||e.length>1&&255===e[0]&&!(224&~e[1]))a("audio","audio/mpeg");else if("fLaC"===s(e,0,4))a("audio","audio/flac");else if("OggS"===s(e,0,4)){const e="video/ogg"===i||/\.ogv$/i.test(r||"");a(e?"video":"audio",e?"video/ogg":"audio/ogg")}else if(e.length>=4&&26===e[0]&&69===e[1]&&223===e[2]&&163===e[3]){const e="audio/webm"===i||/\.weba$/i.test(r||"");a(e?"audio":"video",e?"audio/webm":"video/webm")}else if(e.length>=12&&"ftyp"===s(e,4,4)){const t=s(e,8,4);if(["avif","avis"].includes(t))a("image","image/avif");else{const e=/^M4[ABP] /.test(t)||i.startsWith("audio/")||/\.(m4a|m4b)$/i.test(r||"");a(e?"audio":"video",e?"audio/mp4":"video/mp4")}}return{kind:n,contentType:o,fileName:r}};e.exports={MAX_UPLOAD_BYTES:t,describeMedia:r,createFileUploadHandler:({Asset:e,registerAsset:s,isPlayerActive:i})=>{let n=0;const o=new Map;return async(a,h,l={},c={})=>{if(!i(Number(a)))throw new Error("The uploading player has left the session");const d=h instanceof ArrayBuffer?new Uint8Array(h):ArrayBuffer.isView(h)?new Uint8Array(h.buffer,h.byteOffset,h.byteLength):null;if(!d?.length||d.length>t)throw new Error("Choose an image, audio file or video up to 5 MB");const u=r(d,l);if(!u.kind)throw new Error("That file is not a supported image, audio file or video");if(null!=c.slot&&("string"!=typeof c.slot||!/^[a-zA-Z0-9_-]{1,32}$/.test(c.slot)))throw new Error("Invalid upload slot");const p=null==c.slot?null:`${Number(a)}:${c.slot}`,f=p&&o.get(p)||"upload-"+ ++n;p&&o.set(p,f);const m=new e({id:f,type:u.kind,contentType:u.contentType,fileName:u.fileName},d.slice());return m.key=f,await s(f,m),m}}}},4367(e){"use strict";function t(){const e=e=>{if("string"!=typeof e||/[\u0000-\u001f\u007f-\u009f\u202a-\u202e\u2066-\u2069]/.test(e))throw new Error("Use a name without control characters.");const t=e.normalize("NFC").trim().replace(/\s+/gu," ");if(!t||t.length>32)throw new Error("Choose a name between 1 and 32 characters.");return t},t=["chocolate","iguana","cardigan","enormous","gargantuan","orangutan","cookies","monstera","daisy","grapefruit","blueberry","mango","elephant","bamboo","sapphire","papaya","waffle","turquoise","aquatic","goblin","funky","hotdog","elegant","cascade","euphoria"],s=()=>Array.from({length:2},()=>t[Math.floor(Math.random()*t.length)]).join(" ");return{normalizeName:e,generateName:s,initialName:t=>{try{return e(t)}catch(e){return s()}},profile:function(t){const r="homegames-player-name";let i;try{i=e(t.localStorage.getItem(r))}catch(e){i=s()}const n=s=>{i=e(s);try{t.localStorage.setItem(r,i)}catch(e){}return i};return n(i),{get:()=>i,set:n}}}}e.exports={createPlayerIdentity:t,...t()}},8106(e){"use strict";e.exports={createPlayerToolbar:function(e,t={}){const s=e.document,r=new Map,i=new Set,n=(e,t,r)=>{const i=s.createElement(e);return i.className=t,r&&(i.textContent=r),i},o=(e,t)=>{const s=n("button",e,t);return s.type="button",s},a=n("header","hg-player-bar");a.setAttribute("aria-label","Game controls");const h=n("style","");h.textContent="\n.hg-player-bar,.hg-player-menu{box-sizing:border-box;color:#f6f6ee;font:14px/1.4 system-ui,sans-serif}\n.hg-player-bar *,.hg-player-menu *{box-sizing:border-box}\n.hg-player-bar{position:absolute;inset:0 0 auto;z-index:10;width:100%;height:0;pointer-events:none;--hg-safe-top:env(safe-area-inset-top,0px);--hg-safe-left:env(safe-area-inset-left,0px);--hg-safe-right:env(safe-area-inset-right,0px);--hg-safe-bottom:env(safe-area-inset-bottom,0px)}\n.hg-player-bar button,.hg-player-menu button,.hg-player-menu a{font:inherit;color:inherit;border:1px solid #4a5049;border-radius:12px;background:#252b25;cursor:pointer;text-decoration:none}\n.hg-player-bar button,.hg-player-menu button{min-height:44px;padding:10px 14px}\n.hg-player-bar .hg-player-home{position:absolute;top:calc(8px + var(--hg-safe-top));left:calc(8px + var(--hg-safe-left));width:44px;height:44px;padding:6px;background:#202820;pointer-events:auto;display:grid;place-items:center}\n.hg-player-home img{display:block;width:30px;height:30px;object-fit:contain}\n.hg-player-bar button:hover,.hg-player-menu button:hover,.hg-player-menu a:hover{background:#394036}\n.hg-player-bar :focus-visible,.hg-player-menu :focus-visible{outline:2px solid #fff78e;outline-offset:3px}\n.hg-player-bar [hidden],.hg-player-menu [hidden]{display:none!important}\n.hg-player-bar button:disabled,.hg-player-menu button:disabled{opacity:.45;cursor:default}\n.hg-player-menu{position:fixed;inset:0;margin:0;width:100%;height:100%;height:100dvh;max-width:none;max-height:none;overflow:auto;padding:max(24px,env(safe-area-inset-top)) max(20px,env(safe-area-inset-right)) max(24px,env(safe-area-inset-bottom)) max(20px,env(safe-area-inset-left));border:0;border-radius:0;background:#141b16}\n.hg-player-menu::backdrop{background:#080c0a}\n.hg-player-menu-content{width:100%;max-width:960px;margin:0 auto}\n.hg-player-menu-header{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:24px}\n.hg-player-menu-brand{display:flex;align-items:center;gap:10px;font-size:17px;font-weight:600}\n.hg-player-menu-brand img{width:28px;height:28px}\n.hg-player-menu .hg-player-menu-close{background:#fff78e;color:#22261e;border-color:#fff78e;flex:none}\n.hg-player-heading{margin:0 0 24px;text-align:center}.hg-player-title{margin:0;font-size:clamp(24px,4vw,36px);line-height:1.2;overflow-wrap:anywhere;font-weight:600}\n.hg-player-author{display:block;font-size:14px;font-weight:400;color:#b7bfb5;margin-top:8px}\n.hg-player-sharing{max-width:420px;margin:0 auto 32px;text-align:center}\n.hg-player-share-qr{width:min(224px,100%);aspect-ratio:1;margin:0 auto 16px;background:#fff;padding:8px;border-radius:8px}\n.hg-player-share-qr svg{display:block;width:100%;height:100%}\n.hg-player-share-caption{margin:0 0 12px;font-size:15px}\n.hg-player-share-status{margin:12px 0;color:#c4cec0;overflow-wrap:anywhere;min-height:20px}\n.hg-player-share-note{margin:12px 0 0;color:#b7bfb5;font-size:12px}\n.hg-player-share-actions{display:flex;justify-content:center;flex-wrap:wrap;gap:8px}\n.hg-player-menu .hg-player-share-toggle{background:#fff78e;color:#22261e;border-color:#fff78e}\n.hg-player-share-link{width:100%;min-height:44px;margin-top:12px;border:1px solid #4a5049;border-radius:8px;padding:10px;background:#0c110e;color:#f6f6ee;font:12px system-ui,sans-serif}\n.hg-player-sections{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:24px;padding-top:24px;border-top:1px solid #354235}\n.hg-player-section h2{margin:0 0 12px;font-size:15px;font-weight:500;color:#c4cec0}\n.hg-player-menu-actions{display:flex;flex-direction:column;gap:8px}\n.hg-player-menu-actions>button{width:100%;min-height:44px;text-align:left}\n.hg-player-action-help{display:block;color:#b7bfb5;font-size:12px;margin-top:4px}\n.hg-player-menu-footer{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:12px;margin-top:24px;padding-top:20px;border-top:1px solid #354235}\n.hg-player-menu .hg-player-leave{display:inline-flex;align-items:center;justify-content:center;min-height:44px;padding:10px 18px}\n.hg-player-status{color:#b7bfb5;white-space:pre-wrap;overflow-wrap:anywhere;margin:24px 0 0;font-size:12px}\n.hg-player-brand{display:inline-flex;align-items:center;min-height:44px;padding:10px 14px}\n.hg-player-name{max-width:420px;margin:0 auto 24px;display:flex;align-items:end;flex-wrap:wrap;gap:8px}.hg-player-name label{display:block;flex:1;min-width:160px}\n.hg-player-name input{display:block;width:100%;min-height:44px;margin-top:8px;padding:10px;font:inherit;font-size:16px;color:inherit;background:#0c110e;border:1px solid #4a5049;border-radius:10px}\n.hg-player-name p{width:100%;color:#c4cec0;margin:0;overflow-wrap:anywhere;font-size:12px}\n.hg-player-attention{position:absolute;top:calc(60px + var(--hg-safe-top));left:calc(8px + var(--hg-safe-left));max-width:min(420px,calc(100% - 16px - var(--hg-safe-left)));padding:14px;background:#352c20;border:1px solid #8a7855;border-radius:12px;pointer-events:auto;box-shadow:0 8px 32px #0006}\n.hg-player-attention p{margin:0 0 10px;overflow-wrap:anywhere}\n@media(max-width:640px){.hg-player-sections{grid-template-columns:1fr;gap:20px}.hg-player-menu-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr))}}\n@media(max-width:480px){.hg-player-menu{padding: max(16px,env(safe-area-inset-top)) max(16px,env(safe-area-inset-right)) max(16px,env(safe-area-inset-bottom)) max(16px,env(safe-area-inset-left))}.hg-player-menu-header{gap:8px;margin-bottom:24px}.hg-player-menu-brand{font-size:14px}.hg-player-menu-brand img{width:24px;height:24px}.hg-player-menu .hg-player-menu-close{padding:10px}.hg-player-share-qr{width:208px}.hg-player-share-link{font-size:16px}}\n";const l=o("hg-player-home","");l.setAttribute("aria-label","Open Homegames menu"),l.setAttribute("aria-haspopup","dialog"),l.setAttribute("aria-expanded","false"),l.title="Homegames menu";const c=n("img","");c.alt="",c.width=c.height=32,c.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAIbElEQVRYR7WXC1BU5xmGn7M3rgICYRHjBQSiBUIUTQQ0oEZTIRdTihcy04xO22mbSWKTTDQql2jNbdKk06S2TdqmaWrspMk0tHViiEpqEEyCGmhEq0gEXS4r7HJZll2WPX/nnLO7LEhsOp3+Mwxw9j//9/7v973v9620cOHCpKSkab9blJ2wSq/XGfh/LwFjsjx2usl6pLt7eLNUXHz7oTde/eadcbFhWmgBQgIJgUBC+h8BKacop00+p882wgPfPfSBVL7j257d5fkGbdv4EsL/qvbc/7ny++ssBTyyjKSTkKSpr1Gx57hHqiovFZU7V4EY8Z2rhdrwncMMDnlU7BPeVz+eDNdHne8KQoAsBCGhISSazdya7GTL1iWBC/rfrnq6HqmqfIOo3HUXyL2BFKCDbRXtHDt2gp6eHvUWCgVRRiODHo9GiSwIIAtiy/9MYVB5J2dxDsuT3Dy8twAM+gnk+QBsFJW77gbZOs6AJLH3BTvV1e9jsVjUgMqlf7W+kG3V9USajLy+ppDdJ0+xaFossyIjOdLdyS1JZowmwe6PTvpyJpGVmcnam0w8sud2MAXVuIDKZwIMKACuTgCwvaKdo7XHsXRatMIE9m8p5u0Pm1m5dC4mg57pYdEkRZuYPiDhjoYuvZ5+ay8PvFmDEFruMzMzKUo38dDeAiTjJAb2qgDWi8qd6xCiFwmvBkKCR7e3Unf8U40B5ZEkcfgHmxh1OegQLvqdHgpnmOmQBPMU9U4LZ8zl5d32L3j+T59qRStJ5Ofnk2t2snVvIUwGEKiB8m+B3AfCPQWAzgAzBx7cxO9rT3JHlpmspFTkkV4coZGkm4wMhoXy5fmLtPQN81zNiQDodevWMU9q58dPXw9ARSl4e8eVIMHWJ85T39AYYEA58b6FqbT09HJf3gJiB3X8yzRIavh02vtspMyMp/3MVdLzZvHIy4cCAMrKykh0tvDosyvAoAuIXRH5U083+FRQvkFTgRj2MSAovf8j2ju6AgDmL78DecyN5exZbi3ZQP3+18guXo+to5VLTadYtmkzXxyuJnPlvTTX/AVbj1VNgQLA7GzhsWdXIAx6TYo+HY7LsLxMCy73+KQouGd9Dd09fQEA237+E/qGvDSfOM3tKzKw2Vyk3LYMEZqArbmWcJMbXUQiMfE30FhTzYFX3lIVWVRURLrRwuPPrQySoWZnVeMM3A+yHYTN58aCH25t4dSppoAKVtxTTEFpCQdf+xlL79tE5k3zuNjayoz5GcToZa5YrZyr/RsRC4o4+FIllo6rKgNZWVmsSJZ44vlV1/hA5bgRlYKwBopQMZEdu7s5cuQoFkuXylnmslzyVq0m/Rtx1LxXy90bS+jquEzs/ExMDhtNdR9yutmKY2CYgrtW8VrFHhVARkYGBXP17PipBiDYQ30ANoqKnfciie5AcpQCeWzHJerq6rFYFBVI3PXQI+TnzuPsyVZuSE2lp7mO6NlpzLoplQt1h4nLXov70se445aQEnqZbd+rUoNlZWZRmKxju8LA1DJUnPCe8fz7klC2pZ6LFzvo6uxSfcFo1GFOiKCr28HcOTFcbLMTHx/OwIALvV5iekwo1t5hEm6IYNTt5WqvE51OR3Z2NoVzBI8pVhxi/CorngwASspqcDjGUD19ihWg0t8qfQam9nL17lqrSElOITO8iwefKmDEK2g+04t9SPF2He++06TIcFIv8J3c39iBo92O1yuPN2qdRN+QB48smBFtCjQvrXH7BeT/2wdEQHiogVr9bM5dTSI5bzV2lwe3vZeGd94cByBk64S+779F8OWVoxtOdJG3dMaUrEz10OsVvHjATbc8l9mLcjGGhuAntfbXLwa1Y8UJ/Wvy/OBj5czZPszmcOJ901PwXScH96fo8HE7ZxzL0CdnBAYTJTXKvFDzygu+ZrSrGGQbQ0OjnD9uBYNEzh1J14xkxxs6yc9N+tq3VzbuPxLDYEI+clikSqrX6cAQEYnD5eHYqy8pAJSJqAhEP22XBhj8bT8WSaZ499wJALyyzJkWGzdnxk0e3ib9r+Hr7RuhqcXBwaY4ZubfTWhkJMLj4kLDx8y8eTF2YeKff/yFH8BKhHDR0T5I2x/aabMNsOWlZRNmxI4rQ0RNCyHGX3xBnj6ZEoXJl2tuxDw3A5cxgguN9aQtX62qYqTfjtMQxpBrjJa39iFV7VIYyFPP8Hi8nG/t59x5GyX3pgWahpLPzxq7uXVx4qRYU82GcPQfl3mvczlExasF57S0kbHkNgwR0+hzuHF6xtTLqQB2bC8Rjz+8GJ1Oi6f8DDs8NJ62snhhAgajnk8/62bBgjgiwrWRSis+4avmoLFb0sbvY5/YsaQ8RPfwqDrKDVst6OUxwhLnqDYhZBnvqItzb/8G6dE1a8T3k5PVU9Vu7RuBlWPtzmGcHg8zY2PBaFDNwy9+oexTNikDq06nTs+qaY2OcmJ4BPuDFVgGXGpA2TNKV937xMxOQa/TodfriYoMp/nv7yDtLCoST6T56A64mS+OP4bJhBQZca01KCAUAJJOBS68MmLUTd2VK3yy+UmcsqZnr2cU0dbMjWnzYagfp1fGiJcTf/1zEIDrimvqXOuio8HpRFZG9aD1pWOIN1aXYTDPVp86Oi8h6fREJM6asO/sgV9OBHBtmKkDX98IBF4BVRHxuNJziJqTykD1G0TeWYo+LEJ9VTNpQcv+fUjb1671PJmWbvDPSl/3+6CS70C9BH1H8YPrGxjg4zFlBNCTO2Sn1RCCNSwcvceDwe0mZHSEalufR1qbl3do3y233BlrnNgq/5Pd/XfcjO/WvtkJbGNj/Ojzzz+QcnJyZiSEhLyeHRW1UidJX4kiuOteD5yfXlUVX7FRFsLTNDh41Op2b/43wV/aTZKTkWoAAAAASUVORK5CYII=",l.append(c);const d=n("div","hg-player-attention");d.hidden=!0;const u=n("p","");u.setAttribute("role","alert");const p=o("","Open menu");d.append(u,p),a.append(h,l,d);const f=n("dialog","hg-player-menu");f.setAttribute("aria-label","Homegames menu");const m=n("div","hg-player-menu-content"),g=n("div","hg-player-menu-header"),y=n("div","hg-player-menu-brand"),v=n("img","");v.src=c.src,v.alt="",y.append(v,n("span","","Homegames"));const w=o("hg-player-menu-close","Back to game");g.append(y,w);const x=n("div","hg-player-heading"),b=n("h1","hg-player-title"),E=n("span",""),S=n("span","hg-player-author");b.append(E,S),x.append(b);const k=n("div","hg-player-sections"),_=new Map;let C=!1,A=!1;const I=[["together","Session"],["downloads","Downloads"],["tools","Game tools"]];for(const[e,t]of I){const s=n("section","hg-player-section");s.setAttribute("aria-label",t);const r=n("h2","",t),i=n("div","hg-player-menu-actions");s.append(r,i),k.append(s),_.set(e,{panel:s,list:i})}const T=n("string"==typeof t.home?"a":"button","hg-player-leave","Leave game");T.hidden=!t.home,"string"==typeof t.home?T.href=t.home:(T.type="button",T.onclick=()=>{oe(),t.home?.()});const P=n("p","hg-player-status");P.setAttribute("role","status"),P.setAttribute("aria-atomic","true");const L=n("a","hg-player-brand","homegames.io");L.href="https://homegames.io/",L.target="_blank",L.rel="noopener noreferrer";const M=n("div","hg-player-menu-footer");M.append(L,T);const R=n("form","hg-player-name");R.hidden=!0;const N=n("label","","Your name"),O=n("input","");O.type="text",O.maxLength=32,O.required=!0,O.autocomplete="nickname",O.setAttribute("aria-label","Your name"),N.append(O);const U=o("","Save name");U.type="submit";const B=n("p","");B.setAttribute("role","status"),R.append(N,U,B);let D,j="",q=!1;O.oninput=()=>{q=!0},R.onsubmit=async e=>{if(e.preventDefault(),D&&!U.disabled){U.disabled=!0;try{j=await D(O.value),O.value=j,q=!1,B.textContent="Name updated for this session."}catch(e){B.textContent=e.message||String(e)}finally{U.disabled=!1}}};const H=n("section","hg-player-sharing");H.hidden=!0,H.setAttribute("aria-label","Invite and share");const V=n("div","hg-player-share-qr");V.hidden=!0;const z=n("p","hg-player-share-caption"),F=n("p","hg-player-share-status");F.setAttribute("role","status");const G=n("div","hg-player-share-actions"),$=o("hg-player-share-toggle","Share with friends"),K=o("","Copy link"),W=o("","Try again"),Y=n("input","hg-player-share-link");Y.readOnly=!0,Y.hidden=!0;const J=n("p","hg-player-share-note");G.append($,K,W),H.append(V,z,F,G,Y,J),m.append(g,x,H,R,k,P,M),f.append(m),s.body.append(f);let X,Z="session",Q=0,ee="",te=!1;const se={session:"",copy:""};function re(){const e=!1===X?.multiplayer,t=e&&!te;z.textContent=t?"Share a playable copy of this game with your friends.":"session"===Z?"Use the QR code to invite a friend to your multiplayer session":"Use the QR code to share a playable copy of this game with your friends.",$.textContent=e||"session"===Z?"Share with friends":"Invite to session",$.hidden=!1===X?.copy||e&&te,K.hidden=t,Y.setAttribute("aria-label","session"===Z?"Invitation link":"Game copy link"),J.textContent=t?"":"session"===Z?"Keep this game open while you play together.":"Keep this game open while they download."}async function ie(){if(!X||!f.open||A)return;const e=++Q,t=X,r=Z;if(ee="",V.hidden=!0,V.replaceChildren(),Y.value="",Y.hidden=!0,K.disabled=!0,W.hidden=!0,re(),!1!==X.multiplayer||te){F.textContent="session"===r?"Creating invitation…":"Preparing game copy…";try{const i=await t.getLink(r);if(e!==Q||!f.open||A)return;if("string"!=typeof i?.url||i.url.length>8192||!["http:","https:"].includes(new URL(i.url).protocol))throw new Error("Could not create a sharing link. Try again.");!function(e,t){const r=e?.length;if(!Array.isArray(e)||r<21||r>177||(r-21)%4||e.some(e=>"string"!=typeof e||e.length!==r||!/^[01]+$/.test(e)))throw new Error("Could not create the QR code. Try again.");const i=s.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("viewBox",`0 0 ${r+8} ${r+8}`),i.setAttribute("role","img"),i.setAttribute("aria-label","session"===t?"Join session QR code":"Share game copy QR code"),i.setAttribute("shape-rendering","crispEdges");const n=s.createElementNS(i.namespaceURI,"rect");n.setAttribute("width",r+8),n.setAttribute("height",r+8),n.setAttribute("fill","#fff");const o=s.createElementNS(i.namespaceURI,"path");o.setAttribute("fill","#000");let a="";e.forEach((e,t)=>{for(let s=0;s<r;s++)if("1"===e[s]){const i=s;for(;s+1<r&&"1"===e[s+1];)s++;const n=s-i+1;a+=`M${i+4} ${t+4}h${n}v1h-${n}z`}}),o.setAttribute("d",a),i.append(n,o),V.replaceChildren(i),V.hidden=!1}(i.qr,r),ee=i.url,Y.value=ee,Y.hidden=!1,K.disabled=!1,F.textContent=se[r]||""}catch(t){if(e!==Q||!f.open||A)return;F.textContent=t.message||String(t),W.hidden=!1}}else F.textContent=""}$.onclick=()=>{Z=!1===X?.multiplayer||"session"===Z?"copy":"session","copy"===Z&&(te=!0),ie()},W.onclick=()=>ie(),K.onclick=async()=>{if(!ee)return;const t=Q,s=ee;try{await e.navigator.clipboard.writeText(s),t===Q&&f.open&&(F.textContent="Link copied")}catch(e){if(t!==Q||!f.open)return;Y.focus(),Y.select(),F.textContent="Copy the selected link"}};const ne=()=>{C&&(C=!1,Q++,l.setAttribute("aria-expanded","false"),t.onClose?.())};function oe(){f.open&&f.close(),ne()}function ae(e){if(!A){if(!f.open){O.value=j,q=!1,B.textContent="",C=!0,Z=!1===X?.multiplayer?"copy":"session",l.setAttribute("aria-expanded","true"),t.onOpen?.();try{f.showModal()}catch(e){throw ne(),e}}("copy"===e&&!1!==X?.copy||"session"===e&&!1!==X?.multiplayer)&&(Z=e,"copy"===e&&(te=!0)),ie(),w.focus()}}function he(){for(const[e,t]of r)t.button.hidden=!!t.value.hidden||!!X&&["share","copy-share"].includes(e);for(const[e,t]of _)t.panel.hidden=!Array.from(r.values()).some(t=>t.group===e&&!t.button.hidden);k.hidden=Array.from(_.values()).every(e=>e.panel.hidden)}function le(e){d.hidden=!e||!P.textContent,u.textContent=d.hidden?"":P.textContent,p.textContent=r.has("retry")?r.get("retry").value.label:"Open menu"}let ce,de,ue,pe,fe;l.onclick=()=>ae(),w.onclick=oe,f.addEventListener("close",()=>{f.open||ne()}),p.onclick=()=>r.has("retry")?ve.runAction("retry"):ae();const me=(e,t,s)=>{const r=Math.min(e,t*s);return r*(r/s)};function ge(){if(!ce||!de||A)return;const t=de.clientWidth,s=de.clientHeight;if(!(t>0&&s>0))return;const r=e.getComputedStyle?.(a),i=e=>Math.max(0,parseFloat(r?.getPropertyValue("--hg-safe-"+e))||0),n=i("left"),o=i("top"),h=i("right"),l=i("bottom"),c=Math.max(1,t-n-h),d=Math.max(1,s-o-l),u=pe?pe.x/pe.y:c/d,p=Math.min(c,d*u);let f,m=n,g=o,y=c,v=d;(c-p)/2>=60?f="left-bar":(d-p/u)/2>=60?f="top-bar":me(Math.max(1,c-60),d,u)>=me(c,Math.max(1,d-60),u)?(m+=Math.min(60,c-1),y=Math.max(1,c-60),f="left-strip"):(g+=Math.min(60,d-1),v=Math.max(1,d-60),f="top-strip");const w={position:"absolute",left:m+"px",top:g+"px",width:y+"px",height:v+"px",minHeight:"0",minWidth:"0"};for(const[e,t]of Object.entries(w))ce.style[e]!==t&&(ce.style[e]=t);a.setAttribute("data-layout",f)}function ye(){if(ue?.disconnect(),ue=null,e.removeEventListener?.("resize",ge),e.visualViewport?.removeEventListener("resize",ge),fe){for(const[e,t]of Object.entries(fe.areaStyle))ce.style[e]=t;de.style.position=fe.position}fe=null,ce=de=null}const ve={bar:a,menu:f,statusElement:P,setGameArea(t,s=t?.parentElement){if(t!==ce||s!==de){if(ye(),t&&s&&!A){ce=t,de=s,fe={position:de.style.position,areaStyle:{}};for(const e of["position","left","top","width","height","minHeight","minWidth"])fe.areaStyle[e]=t.style[e];["relative","absolute","fixed"].includes(e.getComputedStyle?.(de)?.position)||(de.style.position="relative"),a.parentElement!==de&&de.append(a),e.ResizeObserver&&(ue=new e.ResizeObserver(ge),ue.observe(de)),e.addEventListener?.("resize",ge),e.visualViewport?.addEventListener("resize",ge),ge()}}else ge()},setAspectRatio(e){!e||!Number.isFinite(e.x)||!Number.isFinite(e.y)||e.x<=0||e.y<=0||!Number.isFinite(e.x/e.y)||e.x/e.y<=0||pe?.x===e.x&&pe?.y===e.y||(pe={x:e.x,y:e.y},ge())},setTitle(e){E.textContent=E.title=e||"Homegames"},setAuthor(e){S.textContent="string"==typeof e&&e.trim()?" by "+e.trim().slice(0,200):"",S.title=S.textContent.trim(),S.hidden=!S.textContent},setStatus(e,t={}){P.textContent=e||"",le(t.attention??r.has("retry"))},setPlayerName(e,t){j=e,D=t,R.hidden=!t,f.open&&q||(O.value=e)},setSharing(e){const s=!e||"function"!=typeof e.getLink||!1===e.multiplayer&&!1===e.copy?null:e,r=X?.getLink===s?.getLink,i=!1===X?.multiplayer,n=!1!==X?.copy;r||(Q++,X?.dispose?.(),te=!1,se.session=se.copy="",V.hidden=!0,Y.hidden=!0,ee=""),X=s,H.hidden=!X,he(),X&&((!r||"session"===Z&&!1===X.multiplayer||"copy"===Z&&!1===X.copy)&&(Z=!1===X.multiplayer?"copy":"session"),re(),!f.open||r&&i===(!1===X.multiplayer)&&n===(!1!==X.copy)||ie(),!1!==X.multiplayer&&t.onActionReady?.("share"),!1!==X.copy&&t.onActionReady?.("copy-share"))},setSharingStatus(e,t="copy"){["session","copy"].includes(t)&&(se[t]="string"==typeof e?e.slice(0,300):"",f.open&&Z===t&&ee&&(F.textContent=se[t]))},setAction(e,s){if(!s){const t=r.get(e);return t&&(t.button.hidden=!0,t.button.remove(),r.delete(e)),he(),void("retry"===e&&le(!1))}let a=r.get(e);a||(a={button:o("",s.label)},r.set(e,a));const h=a.button;a.value=s,a.group=_.has(s.group)?s.group:(e=>["share","copy-share","manual-connect","privacy"].includes(e)?"together":["install","download-html","download-zip"].includes(e)?"downloads":"retry"===e?"together":"tools")(e),_.get(a.group).list.append(h),h.textContent=s.label,h.title=s.title||"",s.id&&(h.id=s.id),h.hidden=!!s.hidden,h.disabled=!!s.disabled||i.has(e),h.setAttribute("data-action",e),s.title&&h.append(n("span","hg-player-action-help",s.title)),h.onclick=()=>{if(i.has(e)||h.disabled||A)return;if(X&&["share","copy-share"].includes(e))return void ae("share"===e?"session":"copy");f.open&&oe(),i.add(e),h.disabled=!0;const t=()=>{i.delete(e),h.disabled=!!r.get(e)?.value.disabled};try{Promise.resolve(s.run()).catch(e=>ve.setStatus(e.message||String(e),{attention:!0})).finally(t)}catch(e){t(),ve.setStatus(e.message||String(e),{attention:!0})}},he(),"retry"===e&&le(!0),t.onActionReady?.(e)},runAction(e){if(A)return!1;if(X&&["share","copy-share"].includes(e))return!("share"===e&&!1===X.multiplayer||"copy-share"===e&&!1===X.copy||(ae("share"===e?"session":"copy"),0));const t=r.get(e);return!(!t||t.button.disabled||(t.button.click(),0))},openMenu(){ae()},dispose(){A||(oe(),ye(),A=!0,Q++,X?.dispose?.(),f.remove(),a.remove())}};a.homegamesToolbar=ve,ve.setTitle(t.title),ve.setAuthor(t.author),ve.setStatus(t.status);for(const[e,s]of Object.entries(t.actions||{}))ve.setAction(e,s);return he(),ve}}},5564(e){"use strict";e.exports={attachClientHost:function(e,t,s,r,i,n,o,a={}){const h=e.document;let l,c,d,u,p=0,f=!1,m=a.toolbar,g=!1,y=a.title;const v=new Map,w=new Map;function x(e,t){return!l||f?Promise.reject(new Error("The player is not ready")):new Promise((s,r)=>{const i=++p,n=setTimeout(()=>{v.delete(i),r(new Error("Game download timed out"))},6e4);v.set(i,{resolve:s,reject:r,timer:n,format:e}),l.postMessage({type:"download-game",id:i,format:e,name:t})})}const b=(e,t={})=>{a.onPlayerStatus?a.onPlayerStatus(e,t):m?.setStatus(e,t)};function E(e,t){l&&!f&&l.postMessage({type:"player-control",action:e,value:t})}function S(e){if(!l||f)return Promise.reject(new Error("The player is not ready"));if(!["session","copy"].includes(e))return Promise.reject(new Error("Unknown sharing option"));if(w.has(e))return w.get(e);const t=new Promise((t,s)=>{const r=++p,i=setTimeout(()=>{v.delete(r),s(new Error("Creating an invitation timed out. Try again."))},35e3);v.set(r,{resolve:t,reject:s,timer:i,sharing:!0}),l.postMessage({type:"player-share",id:r,mode:e})});return w.set(e,t),t.finally(()=>{w.get(e)===t&&w.delete(e)}).catch(()=>{}),t}async function k(t){try{const s="function"==typeof a.downloadName?a.downloadName():a.downloadName;let r=String(s||y||"game").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)||"game";/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/.test(r)&&(r+="-game"),b("Preparing game download…");const i=await x(t),n=e.URL.createObjectURL(new Blob([i],{type:"html"===t?"text/html":"application/zip"})),o=h.createElement("a");o.href=n,o.download=r+"."+t,o.click(),setTimeout(()=>e.URL.revokeObjectURL(n),3e4),b("Game copy downloaded")}catch(e){b(e.message,{attention:!0})}}function _(h){if(f||l||h.source!==t.contentWindow||"null"!==h.origin||"homegames-client-connect-v1"!==h.data?.type)return;const p=new e.MessageChannel;l=p.port1,l.onmessage=t=>{const o=t.data;if(!f&&"player-state"===o?.type){"string"==typeof o.title&&(y=o.title.slice(0,200),m?.setTitle(y)),"string"==typeof o.author&&m?.setAuthor?.(o.author.slice(0,200));const e=o.aspectRatio;if(e&&Number.isFinite(e.x)&&Number.isFinite(e.y)&&e.x>0&&e.y>0&&m?.setAspectRatio?.({x:e.x,y:e.y}),"string"==typeof o.status&&b(o.status.slice(0,300),{attention:!0===o.statusAttention}),o.ready){m?.setPlayerName(a.profile?.get()||"",o.playerNames&&a.profile?e=>{if(f)throw new Error("This player has closed. Reopen the game to change your name.");const t=a.profile.set(e);return E("player-name",t),t}:null);for(const[e,t]of[["share","Invite"],["copy-share","Share a copy"],["manual-connect","Manual connection"],["exports","View exports"]]){const s="share"===e&&!1===o.multiplayer;m?.setAction(e,o.inlineSharing&&["share","copy-share"].includes(e)||"exports"!==e&&!o.sharing?null:{label:s?"Invite (solo)":t,disabled:s,title:s?"This is a solo game. Use Share a copy to send it to a friend.":"",run:()=>E(e)})}o.sharing&&o.inlineSharing?u&&u.multiplayer===(!1!==o.multiplayer)||(u={multiplayer:!1!==o.multiplayer,getLink:S,dispose:()=>E("dispose-sharing")},m?.setSharing?.(u)):u&&(m?.setSharing?.(null),u=null),m?.setAction("download-html",{label:"Download game HTML",id:a.htmlId,run:()=>k("html")}),m?.setAction("download-zip",{label:"Download game ZIP",id:a.zipId,run:()=>k("zip")}),a.editGame&&m?.setAction("edit-game",{label:"Edit this game",id:"edit-game",run:()=>a.editGame(()=>x("zip"))})}return}if(!f&&"player-share-status"===o?.type&&"string"==typeof o.status&&["session","copy"].includes(o.mode))return void m?.setSharingStatus?.(o.status.slice(0,300),o.mode);if(!f&&"player-share-result"===o?.type){const e=v.get(o.id);if(!e?.sharing)return;if(v.delete(o.id),clearTimeout(e.timer),o.error)e.reject(new Error(String(o.error).slice(0,300)));else{const{url:t,qr:s}=o;"string"!=typeof t||t.length>4096||!/^https?:\/\//.test(t)||!Array.isArray(s)||s.length<21||s.length>177||(s.length-21)%4!=0||s.some(e=>"string"!=typeof e||e.length!==s.length||!/^[01]+$/.test(e))?e.reject(new Error("Invalid invitation received from the player")):e.resolve({url:t,qr:s})}return}if(!f&&"close-exports"===o?.type)return void d?.close();if(!f&&"view-exports"===o?.type&&Number.isSafeInteger(o.id))return d||!i?void l.postMessage({type:"export-result",id:o.id,error:"Export viewer is unavailable or already open"}):(d=i(e,{list:()=>x("export-list"),read:e=>x("export-file",e)}),void d.result.finally(()=>{d=null,f||l.postMessage({type:"export-result",id:o.id})}));if(!f&&["get-exports","put-export"].includes(o?.type)&&Number.isSafeInteger(o.id))return void Promise.resolve().then(()=>{if(!r)throw new Error("Export storage is unavailable");return"get-exports"===o.type?r.getExports():r.putExport(o.name,o.bytes)}).then(e=>{f||l.postMessage({type:"export-result",id:o.id,value:e})},e=>{f||l.postMessage({type:"export-result",id:o.id,error:e.message})});if(!f&&"cancel-audio"===o?.type)return void(c?.requestId===o.id&&c.close());if(!f&&["record-audio","record-video"].includes(o?.type)&&Number.isSafeInteger(o.id)){if(c)return void l.postMessage({type:"audio-result",id:o.id,error:"A recording is already open"});const t="record-audio"===o.type?s:n;return t?(c=t(e,o.recording||{}),c.requestId=o.id,void c.result.then(e=>{c=null,f||l.postMessage({type:"audio-result",id:o.id,value:e})},e=>{c=null,f||l.postMessage({type:"audio-result",id:o.id,error:e.message})})):void l.postMessage({type:"audio-result",id:o.id,error:"Recording is unavailable"})}const h=v.get(o?.id);f||"game-download"!==o?.type||!h||h.sharing||(v.delete(o.id),clearTimeout(h.timer),o.error?h.reject(new Error(String(o.error).slice(0,300))):"export-list"===h.format||"export-file"===h.format?h.resolve(o.value):o.bytes instanceof Uint8Array&&o.bytes.length&&!(o.bytes.length>1024*("html"===h.format?220:65)*1024)?h.resolve(o.bytes):h.reject(new Error("Invalid game download")))},t.contentWindow.postMessage({type:"homegames-client-port-v1",playerName:a.profile?.get()},"*",[p.port2]),!m&&o&&(m=o(e,{title:a.title,author:a.author,home:a.home,status:"Starting game…",onOpen:()=>E("pause-input"),onClose:()=>E("resume-input")}),g=!0,t.before(m.bar)),m?.setGameArea?.(t,t.parentElement)}return e.addEventListener("message",_),{request:x,command:E,download:k,close(){E("dispose-sharing"),f=!0,u&&(m?.setSharing?.(null),u=null),e.removeEventListener("message",_),l?.close(),g&&m?.dispose(),c?.close(),d?.close();for(const e of v.values())clearTimeout(e.timer),e.reject(new Error("Player closed"));v.clear(),w.clear()}}},connectClientSource:function(e,t,s={},r={}){let i,n,o,a,h=!1,l=0;const c=new Map,d=new Promise(e=>{n=e}),u=setTimeout(n,15e3),p=l=>{!h&&l.source===e.parent&&"homegames-client-port-v1"===l.data?.type&&l.ports[0]&&(e.removeEventListener("message",p),i=l.ports[0],a=l.data.playerName,clearTimeout(u),n(),o&&i.postMessage({type:"player-state",...o}),i.onmessage=async e=>{const n=e.data;if(!h&&"player-share"===n?.type&&Number.isSafeInteger(n.id)&&["session","copy"].includes(n.mode))try{if("function"!=typeof r["sharing-link"])throw new Error("Inline sharing is unavailable");const e=await r["sharing-link"](n.mode);h||i.postMessage({type:"player-share-result",id:n.id,...e})}catch(e){h||i.postMessage({type:"player-share-result",id:n.id,error:e.message})}else if(h||"player-control"!==n?.type||!Object.hasOwn(r,n.action)){if("audio-result"===n?.type||"export-result"===n?.type){const e=c.get(n.id);if(!e)return;return c.delete(n.id),clearTimeout(e.timer),void(n.error?e.reject(new Error(n.error)):e.resolve(n.value))}if(!h&&"download-game"===n?.type&&Number.isSafeInteger(n.id)&&["html","zip","export-list","export-file"].includes(n.format))try{const e="export-list"===n.format?{value:await s.list()}:"export-file"===n.format?{value:await s.read(n.name)}:{bytes:await t(n.format)};h||i.postMessage({type:"game-download",id:n.id,...e})}catch(e){h||i.postMessage({type:"game-download",id:n.id,error:e.message})}}else try{"player-name"===n.action&&(a=n.value),await r[n.action](n.value)}catch(e){i.postMessage({type:"player-state",status:e.message,statusAttention:!0})}})};e.addEventListener("message",p),e.parent.postMessage({type:"homegames-client-connect-v1"},"*");const f=(e,t={})=>new Promise((s,r)=>{if(h||c.size>=128)return void r(new Error("Client adapter unavailable or busy"));const n=++l,o={resolve:s,reject:r,recordingId:t.recording?.id,type:e};o.timer="view-exports"===e?null:setTimeout(()=>{c.delete(n),"record-audio"!==e&&"record-video"!==e||i?.postMessage({type:"cancel-audio",id:n}),r(new Error("Client request timed out"))},9e4),c.set(n,o),d.then(()=>{if(c.has(n))return h||!i?(clearTimeout(o.timer),c.delete(n),void r(new Error("Client adapter is unavailable"))):void i.postMessage({type:e,id:n,...t})})});return{setState(e){o={...o,...e},h||i?.postMessage({type:"player-state",...o})},setSharingStatus(e,t="copy"){h||i?.postMessage({type:"player-share-status",status:e,mode:t})},getPlayerName:async()=>(await d,a),recordAudio:e=>f("record-audio",{recording:e}),recordVideo:e=>f("record-video",{recording:e}),viewExports:()=>f("view-exports"),closeExports(){i?.postMessage({type:"close-exports"})},cancelRecording(e){for(const[t,s]of c)["record-audio","record-video"].includes(s.type)&&s.recordingId===e&&(i?.postMessage({type:"cancel-audio",id:t}),clearTimeout(s.timer),c.delete(t),s.reject(new Error("Recording cancelled")))},getExports:()=>f("get-exports"),putExport:(e,t)=>f("put-export",{name:e,bytes:t}),close(){h=!0,clearTimeout(u),n(),e.removeEventListener("message",p);for(const[e,t]of c)t.recordingId&&i?.postMessage({type:"cancel-audio",id:e}),clearTimeout(t.timer),t.reject(new Error("Player closed"));c.clear(),i?.close()}}},recordAudio:function(e,t){const s=e.document;let r,i,n,o,a=!1;const h=Math.min(30,Math.max(1,Number(t.durationSeconds)||3)),l=Math.min(5242880,Math.max(131072,Number(t.maxBytes)||5242880)),c=s.createElement("dialog");c.setAttribute("aria-label","Record audio"),c.style.cssText="max-width:360px;padding:24px;border-radius:12px;background:#101820;color:white;font:16px/1.5 system-ui";const d=s.createElement("p");d.textContent=String(t.prompt||"Record audio for this game. The host receives the recording.").slice(0,120);const u=s.createElement("p");u.textContent=`Your microphone will record for ${h} seconds.`;const p=s.createElement("button"),f=s.createElement("button");p.textContent="Record audio",f.textContent="Cancel";for(const e of[p,f])e.style.cssText="padding:10px;margin:4px;font:inherit";const m=new Promise((e,t)=>{r=(r,h)=>{a||(a=!0,clearTimeout(o),"recording"===n?.state&&n.stop(),i?.getTracks().forEach(e=>e.stop()),s.removeEventListener("visibilitychange",g),c.close(),c.remove(),r?t(r):e(h))}});f.onclick=()=>r(new Error("Recording cancelled"));const g=()=>{s.hidden&&r(new Error("Recording cancelled because the page was hidden"))};return s.addEventListener("visibilitychange",g),c.oncancel=e=>{e.preventDefault(),f.onclick()},p.onclick=async()=>{p.disabled=!0;try{if(!e.navigator.mediaDevices?.getUserMedia||!e.MediaRecorder)throw new Error("This client cannot record here. Choose an audio file instead.");const s=await e.navigator.mediaDevices.getUserMedia({audio:!0,video:!1});if(a)return void s.getTracks().forEach(e=>e.stop());i=s,n=new e.MediaRecorder(i);const c=[];let d=0;n.ondataavailable=e=>{e.data.size&&(d+=e.data.size,d>5242880?r(new Error("Recording is too large")):c.push(e.data))},n.onstop=async()=>{if(a)return;let s;try{s=new(e.AudioContext||e.webkitAudioContext);const i=await s.decodeAudioData(await new Blob(c).arrayBuffer()),n=22050,o=Math.min(Math.floor(i.duration*n),h*n),a=new Uint8Array(44+2*o);if(!o||a.length>l)throw new Error("Recording is empty or too large");const d=new DataView(a.buffer),u=(e,t)=>{for(let s=0;s<t.length;s++)a[e+s]=t.charCodeAt(s)};u(0,"RIFF"),d.setUint32(4,a.length-8,!0),u(8,"WAVEfmt "),d.setUint32(16,16,!0),d.setUint16(20,1,!0),d.setUint16(22,1,!0),d.setUint32(24,n,!0),d.setUint32(28,2*n,!0),d.setUint16(32,2,!0),d.setUint16(34,16,!0),u(36,"data"),d.setUint32(40,2*o,!0);const p=i.getChannelData(0);for(let e=0;e<o;e++)d.setInt16(44+2*e,Math.round(32767*Math.max(-1,Math.min(1,p[Math.min(p.length-1,Math.floor(e*i.sampleRate/n))]))),!0);let f="";for(let e=0;e<a.length;e+=8192)f+=String.fromCharCode(...a.subarray(e,e+8192));r(null,{type:"media",action:"record-result",id:t.id,data:e.btoa(f),contentType:"audio/wav",fileName:"recording.wav"})}catch(e){r(e)}finally{await(s?.close())}},n.onerror=()=>r(new Error("Recording failed")),n.start(250),u.textContent="Recording…",o=setTimeout(()=>{n.stop(),i.getTracks().forEach(e=>e.stop())},1e3*h)}catch(e){r(e)}},c.append(d,u,p,f),s.body.append(c),c.showModal(),p.focus(),{result:m,close:()=>r(new Error("Recording cancelled"))}}}},5758(e,t,s){"use strict";const{exportArchive:r,LIMITS:i}=s(5110),{attachSaveHost:n}=s(5061),{attachClientHost:o,recordAudio:a}=s(5564),{createExportsViewer:h}=s(97),{recordVideo:l}=s(5900),{createExportStorage:c}=s(739),{createPlayerToolbar:d}=s(8106),{createPlayerIdentity:u}=s(4367),{openGameInStudio:p}=s(32),f=e=>JSON.stringify(e).replace(/</g,"\\u003c"),m=e=>String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),g=e=>{let t=String(e||"game").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)||"game";return/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/.test(t)&&(t+="-game"),`${t}.zip`},y=3*i.archiveBytes+8388608;function v(e){let t="";for(let s=0;s<e.length;s+=8192)t+=String.fromCharCode(...e.subarray(s,s+8192));return btoa(t)}function w(e){const t=atob(e),s=new Uint8Array(t.length);for(let e=0;e<s.length;e++)s[e]=t.charCodeAt(e);return s}function x(e,t,s){const r=()=>e.removeEventListener("message",i),i=e=>{const i=e.data;if(e.source===t.contentWindow&&"null"===e.origin&&"homegames-archive-ready-v1"===i?.type&&/^[a-zA-Z0-9-]{16,80}$/.test(i.nonce||"")){r();try{const e=s();if(!(e instanceof Uint8Array))throw new Error("Missing game archive");const r=new Uint8Array(e);t.contentWindow.postMessage({type:"homegames-archive-v1",nonce:i.nonce,bytes:r},"*",[r.buffer])}catch(e){t.contentWindow.postMessage({type:"homegames-archive-v1",nonce:i.nonce,error:e.message},"*")}}};return e.addEventListener("message",i),{close:r}}function b(e,t){return new Promise((s,r)=>{const i=e.crypto.randomUUID(),n=(t,i)=>{clearTimeout(h),e.removeEventListener("message",a),e.removeEventListener("pagehide",o),t?r(t):s(i)},o=()=>n(new Error("Player closed before receiving the game")),a=s=>{const r=s.data;if(s.source===e.parent&&"homegames-archive-v1"===r?.type&&r.nonce===i)return r.error||!(r.bytes instanceof Uint8Array)||r.bytes.length>t?n(new Error(r.error||"Invalid game archive")):void n(null,r.bytes)},h=setTimeout(()=>n(new Error("The player did not receive its game archive")),3e4);e.addEventListener("message",a),e.addEventListener("pagehide",o),e.parent.postMessage({type:"homegames-archive-ready-v1",nonce:i},"*")})}async function E(e,{clientBundleSource:t,installationId:s,sharing:n={},studioUrl:o,studioDebug:a=!1,externalArchive:h=!1}={}){if(!t?.includes("PortableProject"))throw new Error("Rebuild the Homegames client before playing portable projects");if(!/^[a-zA-Z0-9-]{16,80}$/.test(s||""))throw new Error("Missing local installation ID");const l=new URL(n.signalingUrl||"wss://api.homegames.io/rtc");if(!["ws:","wss:","http:","https:"].includes(l.protocol)||l.username||l.password)throw new Error("Invalid signaling URL");l.protocol="https:"===l.protocol?"wss:":"http:"===l.protocol?"ws:":l.protocol;const c=new URL(n.joinUrl||"https://homegames.io/play.html");if(!["http:","https:"].includes(c.protocol))throw new Error("Invalid invitation URL");const d=new URL(o||"/studio.html",c);if(!["http:","https:"].includes(d.protocol)||d.username||d.password)throw new Error("Invalid Studio URL");const u=new URL(n.receiveUrl||"/game-app.html",c);if(!["http:","https:"].includes(u.protocol))throw new Error("Invalid copy receiver URL");const p={archive:h?void 0:v(await r(e)),installationId:s,studioUrl:d.href,studioDebug:!0===a,sharing:!1!==n&&{signalingUrl:l.href,joinUrl:c.href,receiveUrl:u.href}},g=`default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval'; style-src 'unsafe-inline'; img-src data: blob:; media-src data: blob:; font-src data: blob:; worker-src blob:; connect-src ${!1===n?"'none'":l.origin+l.pathname}; base-uri 'none'; form-action 'none'; frame-src 'none'`;return`<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="${m(g)}"><meta name="viewport" content="width=device-width,initial-scale=1"><style>\nhtml,body{margin:0;height:100%;background:#101820;color:#f7fafc;font:14px system-ui}body{display:flex;flex-direction:column}#game{flex:1;min-height:0;display:flex;align-items:center;justify-content:center;overflow:hidden}#error{padding:16px;color:#ffbaba;white-space:pre-wrap}\n</style></head><body><div id="game"></div><div id="error" hidden></div>\n<script>${t.replace(/<\/script/gi,"<\\/script")}<\/script><script>\n(async()=>{\nconst payload=${f(p)};\nlet client,clientSource,pairing,debug;\nconst state=(status,details={})=>clientSource?.setState({status,statusAttention:details.attention===true});\nconst fail=error=>{document.getElementById('error').hidden=false;document.getElementById('error').textContent=error.message||String(error);state('Unable to play: '+(error.message||String(error)),{attention:true});};\ntry {\nconst project=await HomegamesClient.PortableProject.importArchive(payload.archive===undefined?await (${b.toString()})(window,${i.archiveBytes}):(${w.toString()})(payload.archive));\nconst saveError=error=>{state('Progress not saved: '+error.message,{attention:true});};\nconst saveStore=await HomegamesClient.PortableProject.connectSaveStore(window,{gameKey:'project:'+payload.installationId,versionId:'save-schema:'+project.manifest.saveSchemaVersion,onError:saveError,stop:()=>client?.stop()});\nclientSource=HomegamesClient.PortableProject.connectClientSource(window,async format=>{\nconst copy=await client.requestGameCopy();\nif(format==='zip')return copy.bytes;\nreturn new TextEncoder().encode(await HomegamesClient.PortableProject.buildIsolatedHtml(copy.project,{clientBundleSource:document.scripts[0].textContent,installationId:crypto.randomUUID(),sharing:payload.sharing,studioUrl:payload.studioUrl}));\n},{list:()=>client.listExports(),read:name=>client.readExport(name)}, {\nshare:()=>client.showShare(),exports:()=>client.viewExports(),'sharing-link':mode=>client.getSharingLink(mode),'dispose-sharing':()=>client.disposeSharing(),'manual-connect':()=>pairing?.show(),\n'pause-input':()=>client.setInputEnabled(false),'resume-input':()=>{client.setInputEnabled(true);if(payload.studioDebug)client._localSession?._updateInputAttachment();},'player-name':name=>client.setPlayerName(name)\n});\nconst ready=status=>clientSource.setState({title:project.metadata.name||'Homegame',author:project.metadata.author||project.metadata.createdBy||'',status,statusAttention:false,ready:true,sharing:!!payload.sharing,inlineSharing:true,multiplayer:client._localSession?client._localSession.maxPlayers>1:true,playerNames:typeof client.setPlayerName==='function'});\nclient=new HomegamesClient({containerId:'game',chrome:false,localHome:false,share:payload.sharing,saveStore,platform:clientSource,playerName:await clientSource.getPlayerName?.(),\nloadLocalGame:async()=>HomegamesClient.PortableProject.prepareTrustedLocalGame(project,{trusted:true,installationId:payload.installationId}),\nonReady:()=>{ready('Playing locally');debug?.ready();},onSessionStatus:state,onSharingStatus:(text,mode)=>clientSource.setSharingStatus(text,mode),onError:fail});\npairing=payload.sharing?HomegamesClient.createManualPairing({container:document.body,getSession:()=>client._localSession,\nonOpen:()=>client.setInputEnabled(false),onClose:()=>client.setInputEnabled(true),\njoin:async transport=>{client.stop();client=new HomegamesClient({containerId:'game',chrome:false,transport,share:payload.sharing,platform:clientSource,playerName:await clientSource.getPlayerName?.(),onSharingStatus:(text,mode)=>clientSource.setSharingStatus(text,mode),onReady:()=>{ready('Connected manually to host');debug?.ready();},onClose:()=>state('Host disconnected',{attention:true}),onError:fail});client.start();}}):null;\nif(payload.studioDebug)debug=HomegamesClient.PortableProject.connectStudioDebugSource(window,()=>client._localSession);\nwindow.addEventListener('pagehide',()=>{debug?.close();pairing?.dispose();client.stop();clientSource.close();});client.startLocalGame({});\n}catch(error){fail(error);}\n})();\n<\/script></body></html>`}function S(e,t){const s=e.createElement("iframe");return s.title="Game preview",s.setAttribute("sandbox","allow-scripts allow-pointer-lock"),s.setAttribute("allow","autoplay *; fullscreen *; gamepad *; camera 'none'; microphone 'none'; geolocation 'none'"),s.referrerPolicy="no-referrer",s.srcdoc=t,s}e.exports={runtimeDocument:E,createFrame:S,attachArchiveHost:x,buildIsolatedHtml:async function(e,t){const s=await E(e,{...t,externalArchive:!0}),i=new URL(t.studioUrl||"/studio.html",t.sharing?.joinUrl||"https://homegames.io/play.html").href,y=f({formatVersion:1,document:s,archive:v(await r(e)),name:g(e.metadata.name),title:e.metadata.name||"Homegame",author:e.metadata.author||e.metadata.createdBy||"",studioUrl:i,homeUrl:new URL("/catalog.html",i).href,saves:{packageRevision:e.revision,installationId:t.installationId,gameId:e.manifest.gameId,versionId:"save-schema:"+e.manifest.saveSchemaVersion,compatibility:e.metadata.saveCompatibility||[]}});return`<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover"><title>${m(e.metadata.name||"Homegame")}</title>\n<style>html,body{margin:0;width:100%;height:100%;overflow:hidden;background:#101820;color:#f7fafc;font:14px system-ui}body{position:relative}iframe{display:block;width:100%;height:100%;border:0}[hidden]{display:none!important}</style></head><body>\n<input id="portable-save-file" type="file" accept=".json,application/json" hidden>\n<script id="homegames-project" type="application/json">${y}<\/script>\n<script>const payload=JSON.parse(document.getElementById('homegames-project').textContent);\nconst originalHead=document.head.outerHTML,originalBody=Array.from(document.body.children);\nconst originalHtml=()=>'<!doctype html>\\n<html>'+originalHead+'<body>'+originalBody.map(node=>node.outerHTML).join('\\n')+'</body></html>';\nlet frame,saveHost,clientHost,archiveHost,archive;\nconst getArchive=()=>archive||(archive=(${w.toString()})(payload.archive));\nconst toolbar=(${d.toString()})(window,{title:payload.title,author:payload.author,home:payload.homeUrl,status:'Starting game…',onOpen:()=>clientHost?.command('pause-input'),onClose:()=>clientHost?.command('resume-input')});document.body.prepend(toolbar.bar);\nconst showSaveStatus=(message,details={})=>toolbar.setStatus(message,details);\nconst editGame=getArchive=>{showSaveStatus('Opening Studio…');return (${p.toString()})(window,getArchive,payload.studioUrl).then(()=>showSaveStatus('Editable copy saved in Studio'));};\nasync function mount(){archiveHost?.close();clientHost?.close();if(saveHost)await saveHost.close();frame?.remove();frame=(${S.toString()})(document,payload.document);archiveHost=(${x.toString()})(window,frame,getArchive);saveHost=(${n.toString()})(window,frame,{...payload.saves,onStatus:value=>showSaveStatus(value.message,{attention:value.state==='error'})});clientHost=(${o.toString()})(window,frame,(${a.toString()}),(${c.toString()})(window,payload.saves),(${h.toString()}),(${l.toString()}),(${d.toString()}),{toolbar,editGame,htmlId:'portable-html-copy',zipId:'portable-copy',profile:(${u.toString()})().profile(window)});document.body.appendChild(frame);toolbar.setGameArea(frame,document.body);}\nconst fallback=(bytes,type,name)=>{const url=URL.createObjectURL(new Blob([bytes],{type}));const a=document.createElement('a');a.href=url;a.download=name;a.click();setTimeout(()=>URL.revokeObjectURL(url),30000);};\ntoolbar.setAction('download-html',{label:'Download game HTML',id:'portable-html-copy',run:()=>fallback(originalHtml(),'text/html',payload.name.replace(/\\.zip$/,'.html'))});\ntoolbar.setAction('download-zip',{label:'Download game ZIP',id:'portable-copy',run:()=>fallback(getArchive(),'application/zip',payload.name)});\ntoolbar.setAction('edit-game',{label:'Edit this game',id:'edit-game',run:()=>editGame(getArchive)});\ntoolbar.setAction('save-download',{label:'Download save',id:'portable-save-download',run:()=>saveHost.downloadSave(payload.name.replace(/\\.zip$/,'-save.json'))});\ntoolbar.setAction('save-import',{label:'Load save',id:'portable-save-import',run:()=>document.getElementById('portable-save-file').click()});\nmount();\nwindow.addEventListener('pagehide',()=>archiveHost?.close());\ndocument.getElementById('portable-save-file').onchange=async event=>{const file=event.target.files[0];event.target.value='';if(!file)return;try{if(file.size>1024*1024+4096)throw Error('Save file is too large');const text=await file.text();if(!confirm('Load this save and replace the current progress for this game?'))return;await saveHost.importSave(text);await mount();}catch(error){if(saveHost.stopped)await mount();showSaveStatus(error.message,{attention:true});}};\n<\/script></body></html>`},filename:g,readHtmlArchive:function(e){if("string"!=typeof e||e.length>y)throw new Error("Game HTML is too large");const t=e.indexOf('<script id="homegames-project" type="application/json">'),s=e.indexOf("<\/script>",t+55);if(t<0||s<0)throw new Error("Choose a Homegames HTML bundle or project ZIP");const r=JSON.parse(e.slice(t+55,s));if(1!==r.formatVersion||"string"!=typeof r.archive||r.archive.length>4*Math.ceil(i.archiveBytes/3)||/[^A-Za-z0-9+/=]/.test(r.archive))throw new Error("Invalid game HTML archive");const n=w(r.archive);if(n.length>i.archiveBytes)throw new Error("Game archive is too large");return n},htmlBytesLimit:y}},4811(e,t,s){"use strict";const{describeMedia:r}=s(3947);function i(e,t){const s=r(e,{fileName:t});if(s.kind)return s;const i=String.fromCharCode(...e.subarray(0,4)),n={wOFF:"font/woff",wOF2:"font/woff2",OTTO:"font/otf","\0\0\0":"font/ttf"};if(e.length>=12&&n[i])return{kind:"font",contentType:n[i]};const o=(new TextDecoder).decode(e);return!/^\s*(?:<\?xml\b[^?]*\?>\s*)?<svg\b/i.test(o)||!/<\/svg>\s*$/i.test(o)||/<(?:[\w-]+:)?(?:script|foreignObject|style|animate\w*|set)\b|<!DOCTYPE|<!ENTITY|\bon[\w-]+\s*=/i.test(o)||/\b(?:href|src)\s*=\s*(?!["']#)["']/i.test(o)||/url\s*\(\s*(?!["']?#[\w-]+["']?\s*\))/i.test(o)?s:{kind:"image",contentType:"image/svg+xml"}}e.exports={describeAsset:i,validateAsset:function(e,t){if(!e||!["image","audio","video","font"].includes(e.type)||!(t instanceof Uint8Array)||!t.length||t.length>10485716||i(t,e.path).kind!==e.type)throw new Error("Unsupported, invalid or oversized game asset")}}},5110(e,t,s){"use strict";const{zipSync:r,unzipSync:i}=s(595),n=s(8630),{walk:o,literal:a,readSourceMetadata:h,rewriteMetadata:l,normalizeMetadata:c,validateGameId:d}=s(7821),{describeAsset:u}=s(4811),{packAssetBundle:p}=s(3735),f="homegame.json",m=".homegame/inventory.json",g=Object.freeze({files:512,fileBytes:16777216,totalBytes:67108864,archiveBytes:68157440,sourceBytes:1048576}),y=new TextEncoder,v=new TextDecoder("utf-8",{fatal:!0}),w=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),x=e=>{throw new Error(e)},b=e=>"string"==typeof e?y.encode(e):e instanceof Uint8Array?new Uint8Array(e):x("Project files must contain text or Uint8Array bytes"),E=e=>v.decode(e),S=e=>JSON.stringify(k(e));function k(e){if(Array.isArray(e))return e.map(k);if(e&&"object"==typeof e){const t=Object.create(null);for(const s of Object.keys(e).sort())t[s]=k(e[s]);return t}return e}function _(e){("string"!=typeof e||!e.length||e.length>240)&&x("Invalid project path");const t=e.startsWith("./")?e.slice(2):e;/^[A-Za-z0-9_. /-]+$/.test(t)||x(`Unsupported project path: ${e}`);for(const s of t.split("/"))(!s||"."===s||".."===s||/[ .]$/.test(s)||/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(s)||["__proto__","prototype","constructor"].includes(s))&&x(`Unsafe project path: ${e}`);return t}function C(e){const t=new Set;for(const s of e){_(s)!==s&&x(`Non-canonical project path: ${s}`);const e=s.toLowerCase();t.has(e)&&x(`Duplicate or case-colliding project path: ${s}`),t.add(e)}for(const e of t){const s=e.split("/");for(;s.length>1;)s.pop(),t.has(s.join("/"))&&x(`File/directory collision: ${e}`)}}function A(e,t){try{return JSON.parse(E(e))}catch(e){x(`Invalid JSON or UTF-8 in ${t}`)}}async function I(e,t){if(t.sha256)return t.sha256(e);globalThis.crypto?.subtle||x("This browser needs a secure context to validate a project");const s=new Uint8Array(await globalThis.crypto.subtle.digest("SHA-256",e));return Array.from(s,e=>e.toString(16).padStart(2,"0")).join("")}function T(e,t,s){"string"==typeof s&&/^\.\.?\//.test(s)||x(`Unsupported module in ${t}: ${s}`);const r=t.split("/").slice(0,-1);for(const e of s.split("/"))"."!==e&&(".."===e?(r.length||x(`Module escapes project root in ${t}: ${s}`),r.pop()):r.push(e));const i=_(r.join("/"));i.startsWith("user-exports/")&&x("User exports are bytes, not executable modules");const n=[i,`${i}.js`,`${i}.json`,`${i}/index.js`].find(t=>w(e,t));return n&&/\.(js|json)$/.test(n)||x(`Missing JavaScript module or JSON data in ${t}: ${s}`),n}function P(e,t){return e.endsWith(".js")?"text/javascript":e.endsWith(".json")?"application/json":u(t,e).contentType||"application/octet-stream"}async function L(e,t={}){const r=Object.keys(e);r.length>g.files&&x("Project contains too many files"),C(r);const i=Object.create(null);let l=0;for(const t of r){(".homegame"===t.toLowerCase()||t.toLowerCase().startsWith(".homegame/"))&&x("The .homegame directory is reserved for generated inventory");const s=e[t],r="string"==typeof s?y.encode(s).length:s?.byteLength;(!Number.isSafeInteger(r)||r>g.fileBytes||(l+=r)>g.totalBytes)&&x(`Project size limit exceeded at ${t}`),i[t]=b(s)}const p=Object.fromEntries(Object.entries(i).filter(([e])=>e.startsWith("user-exports/")).map(([e,t])=>[e.slice(13),t]));s(5828).validateFiles(p);const m=w(i,f)?A(i[f],f):{formatVersion:2,entry:"index.js"};w(i,f)&&1!==m?.formatVersion&&x(`Unsupported project format: ${m?.formatVersion}`),_(m.entry)===m.entry&&!m.entry.startsWith("user-exports/")&&m.entry.endsWith(".js")&&w(i,m.entry)||x(`Missing or invalid entry: ${m.entry}`);const{metadata:v,assets:k}=function(e,t){const s=Object.create(null);for(const[t,r]of Object.entries(e))if(t.endsWith(".js")&&!t.startsWith("user-exports/")){r.length>g.sourceBytes&&x(`JavaScript file exceeds 1 MiB: ${t}`);try{s[t]=n.parse(E(r),{ecmaVersion:"latest",sourceType:"script"})}catch(e){x(`Cannot parse ${t}: ${e.message}`)}}const r=h(E(e[t.entry]),{requireExport:2===t.formatVersion}),i=r.metadata,l=[],d=new Set,p=new Set;for(const e of Object.values(s))o(e,e=>{if("CallExpression"===e.type&&"require"===e.callee.name){const t=a(e.arguments[0],"require()");"string"==typeof t&&/^squish-[0-9]+$/.test(t)&&p.add(t.slice(7))}});(p.size>1||2===t.formatVersion&&1!==p.size)&&x("Project needs exactly one supported Squish runtime import");const f=[...p][0]||t.runtime?.squishVersion;1===t.formatVersion?(i.squishVersion!==t.runtime.squishVersion&&x("metadata.squishVersion must match homegame.json"),f!==t.runtime.squishVersion&&x("Runtime mismatch with homegame.json"),void 0!==i.gameId&&i.gameId!==t.gameId&&x("metadata.gameId must match homegame.json"),void 0!==i.saveSchemaVersion&&i.saveSchemaVersion!==t.saveSchemaVersion&&x("metadata.saveSchemaVersion must match homegame.json")):(t.gameId=i.gameId,t.saveSchemaVersion=i.saveSchemaVersion??1,t.runtime={squishVersion:f});const m=c(i,{runtime:f,legacy:1===t.formatVersion});for(const{key:t,info:s,node:i}of r.assets){void 0!==s.id&&x(`Asset ${t} still uses a hosted asset ID; convert it to a project path`);const r=_(s.path);w(e,r)||x(`Missing asset "${t}": ${r}`);const n=u(e[r],r);["image","audio","video","font"].includes(s.type)&&n.kind===s.type||x(`Unsupported or invalid ${s.type} asset "${t}": ${r}`),l.push({key:t,path:r,type:s.type}),d.add(i.start)}for(const[r,i]of Object.entries(s))o(i,s=>{if("NewExpression"!==s.type||"Asset"!==s.callee.name||r===t.entry&&d.has(s.start)||2===s.arguments.length||x(`Declare portable assets in the entry metadata.assets or supply bytes: ${r}`),"CallExpression"===s.type&&"require"===s.callee.name){const i=a(s.arguments[0],`require() in ${r}`);if(i===`squish-${t.runtime.squishVersion}`)return;"string"==typeof i&&i.startsWith("squish-")&&x(`Runtime mismatch in ${r}: ${i}`);const n=T(e,r,i);n.endsWith(".json")&&A(e[n],n)}});return{metadata:m,assets:l}}(i,m);d(m.gameId),(!Number.isSafeInteger(m.saveSchemaVersion)||m.saveSchemaVersion<1)&&x("Invalid saveSchemaVersion");const L=m.runtime?.squishVersion;Array.isArray(t.supportedRuntimes)&&t.supportedRuntimes.includes(L)||x(`Unsupported runtime: squish-${L}. Supported: ${(t.supportedRuntimes||[]).join(", ")}`),k.some(e=>44+i[e.path].length>10485760)&&x("An asset exceeds the current 10 MiB RTC packet limit");const M=[];for(const e of r.sort())M.push({path:e,byteLength:i[e].length,mediaType:P(e,i[e]),sha256:await I(i[e],t)});const R=await I(y.encode(S({manifest:m,files:M})),t),N=Object.freeze({listFiles:()=>[...r],readFile:e=>{const t=_(e);return w(i,t)||x(`Missing project file: ${t}`),i[t].slice()},stat:e=>{const t=_(e),s=M.find(e=>e.path===t);return s||x(`Missing project file: ${t}`),{...s}}});return{manifest:m,metadata:v,assets:k,revision:R,inventory:M,reader:N}}e.exports={checkSyntax:function(e){try{return n.parse(e,{ecmaVersion:"latest",sourceType:"script"}),null}catch(e){return{message:e.message,line:e.loc?.line||1}}},thumbnailPath:function(e){try{const t=w(e,f),s=t?_(A(b(e[f]),f).entry):"index.js",r=b(e[s]);if(r.length>g.sourceBytes)return null;if(!t){const{metadata:t}=h(E(r),{requireExport:!0,strictAssets:!1}),s=_(t.thumbnail);return w(e,s)?s:null}const i=n.parse(E(r),{ecmaVersion:"latest",sourceType:"script"}),l=[],c=new Map;o(i,e=>{"MethodDefinition"===e.type&&e.static&&!e.computed&&"metadata"===(e.key.name??e.key.value)&&l.push(e)});const d=l[0]?.value.body.body;if(1!==l.length||1!==d.length||"ReturnStatement"!==d[0].type||"ObjectExpression"!==d[0].argument?.type)return null;for(const e of i.body)if("VariableDeclaration"===e.type&&"const"===e.kind)for(const t of e.declarations)"Identifier"===t.id.type&&c.set(t.id.name,t.init);const u=d[0].argument.properties.find(e=>"Property"===e.type&&!e.computed&&!e.method&&"init"===e.kind&&"thumbnail"===(e.key.name??e.key.value));if(!u)return null;const p=_(a(u.value,"thumbnail",c));return w(e,p)?p:null}catch(e){return null}},LIMITS:g,normalizePath:_,resolveModule:T,createProject:L,exportArchive:async function(e){const t=Object.create(null);for(const s of e.reader.listFiles())t[s]=e.reader.readFile(s);return t[m]=y.encode(S({formatVersion:1,revision:e.revision,files:e.inventory})),r(t,{level:0,mtime:new Date(2020,0,1)})},importArchive:async function(e,t={}){let s,r;try{s=function(e,t=!1){(!(e instanceof Uint8Array)||e.length>g.archiveBytes||e.length<22)&&x("Invalid or oversized project archive");const s=new DataView(e.buffer,e.byteOffset,e.byteLength);let r=e.length-22;for(;r>=Math.max(0,e.length-65557)&&101010256!==s.getUint32(r,!0);)r--;r<Math.max(0,e.length-65557)&&x("Damaged ZIP: missing directory"),(r+22+s.getUint16(r+20,!0)!==e.length||s.getUint16(r+4,!0)||s.getUint16(r+6,!0)||s.getUint16(r+8,!0)!==s.getUint16(r+10,!0))&&x("Unsupported multi-volume or damaged ZIP");const i=s.getUint16(r+10,!0),n=s.getUint32(r+12,!0),o=s.getUint32(r+16,!0);(i>g.files+1||o+n!==r)&&x("Unsupported ZIP directory or too many files");let a=o,h=0;const l=[],c=[];for(let n=0;n<i;n++){(a+46>r||33639248!==s.getUint32(a,!0))&&x("Damaged ZIP directory");const i=s.getUint16(a+8,!0),n=s.getUint16(a+10,!0),d=s.getUint32(a+24,!0),u=s.getUint32(a+20,!0),p=s.getUint16(a+28,!0),f=s.getUint16(a+30,!0),m=s.getUint16(a+32,!0),y=s.getUint32(a+42,!0),v=s.getUint32(a+38,!0)>>>16;(1&i||![0,8].includes(n)||s.getUint16(a+34,!0)||![0,16384,32768].includes(61440&v))&&x("Encrypted files, links and this ZIP compression are unsupported"),(d>g.fileBytes||(h+=d)>g.totalBytes+g.fileBytes)&&x("Expanded ZIP exceeds project size limits"),(a+46+p+f+m>r||y+30>o)&&x("Damaged ZIP entry");const w=E(e.subarray(a+46,a+46+p));t&&w.endsWith("/")?(_(w.slice(0,-1))!==w.slice(0,-1)||d)&&x("Invalid ZIP directory"):l.push(w),67324752===s.getUint32(y,!0)&&s.getUint16(y+6,!0)===i&&s.getUint16(y+8,!0)===n||x("ZIP headers disagree");const b=s.getUint16(y+26,!0),S=y+30+b+s.getUint16(y+28,!0);(S+u>o||E(e.subarray(y+30,y+30+b))!==w)&&x("Damaged ZIP file bounds or name"),c.push({name:w,size:d,offset:y,end:S+u}),a+=46+p+f+m}a!==r&&x("Damaged ZIP directory length"),C(l),new Set(c.map(e=>e.name.toLowerCase())).size!==c.length&&x("Duplicate ZIP entry");for(const e of c.filter(e=>e.name.endsWith("/")))l.some(t=>e.name.toLowerCase().startsWith(t.toLowerCase()+"/")||t.toLowerCase()===e.name.slice(0,-1).toLowerCase())&&x("File/directory collision");return c.sort((e,t)=>e.offset-t.offset),c.some((e,t)=>t&&e.offset<c[t-1].end)&&x("Overlapping ZIP entries"),c}(e),r=i(e)}catch(e){x(`Cannot import project: ${e.message}`)}for(const e of s)r[e.name]?.length!==e.size&&x(`Damaged ZIP file: ${e.name}`);w(r,m)||x("Missing project inventory");const n=A(r[m],m);delete r[m];const o=await L(r,t);return 1===n?.formatVersion&&n.revision===o.revision&&S(n.files)===S(o.inventory)||x("Project integrity check failed: missing, changed or undeclared files"),o},assetBundle:function(e){return p(e.assets.map(t=>({key:t.key,type:t.type,data:e.reader.readFile(t.path)})))},withGameId:function(e,t){d(t);const s=Object.fromEntries(Object.entries(e).map(([e,t])=>[e,b(t)]));if(w(s,f)){const e=A(s[f],f);1!==e.formatVersion&&x("Unsupported legacy project format"),e.gameId=t,s[f]=y.encode(JSON.stringify(e,null,2)+"\n");const r=E(s[e.entry]);void 0!==h(r).metadata.gameId&&(s[e.entry]=y.encode(l(r,{gameId:t})))}else w(s,"index.js")||x("Missing index.js"),s["index.js"]=y.encode(l(E(s["index.js"]),{gameId:t},{requireExport:!0}));return s}}},7435(e,t,s){"use strict";const{normalizePath:r,resolveModule:i,assetBundle:n}=s(5110),o=new TextDecoder("utf-8",{fatal:!0});function a(e,t,{trusted:n=!1}={}){if(!n)throw new Error("Portable game execution requires explicit trust; importing does not run code");const a=e.manifest.runtime.squishVersion,h=t[a];if(!h)throw new Error(`Runtime squish-${a} is not installed`);class l extends s(5911).Asset{constructor(t,i){if(void 0!==i){if(!(i instanceof ArrayBuffer||ArrayBuffer.isView(i)||Array.isArray(i)))throw new Error("Generated assets need byte data");if((i.byteLength??i.length)>10485716)throw new Error("Generated asset exceeds the RTC packet limit");const e=i instanceof ArrayBuffer?new Uint8Array(i):ArrayBuffer.isView(i)?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):Uint8Array.from(i);return s(4811).validateAsset(t,e),void super(t,e)}if(!t||void 0!==t.id)throw new Error("Portable assets must use project paths, not hosted asset IDs");const n=r(t.path);if(!e.assets.some(e=>e.path===n&&e.type===t.type))throw new Error(`Undeclared project asset: ${n}`);const o=e.reader.readFile(n);super({...t,path:n},o)}}const c={...h,Asset:l},d=Object.create(null),u=Object.create(null);for(const t of e.reader.listFiles())/\.(js|json)$/.test(t)&&!t.startsWith("user-exports/")&&(d[t]=o.decode(e.reader.readFile(t)));const p=e=>{if(u[e])return u[e].exports;const t={exports:{}};if(u[e]=t,e.endsWith(".json"))return t.exports=JSON.parse(d[e]),t.exports;const s=t=>t===`squish-${a}`?c:p(i(d,e,t));try{new Function("module","exports","require","__filename","__dirname",d[e])(t,t.exports,s,e,e.split("/").slice(0,-1).join("/"))}catch(t){throw delete u[e],t}return t.exports},f=p(e.manifest.entry);if("function"!=typeof f||!(f.prototype instanceof h.Game))throw new Error("Project entry must export a Squish Game class");return s(2439).bindRuntimeMetadata(f,e.metadata),s(2947).bindGameProject(f,()=>e,{supportedRuntimes:Object.keys(t)},{files:s(5828).projectExports(e)})}e.exports={prepareTrustedLocalGame:function(e,t,{trusted:s=!1,installationId:r}={}){if("string"!=typeof r||!/^[a-zA-Z0-9-]{16,80}$/.test(r))throw new Error("A trusted local installation ID is required for project saves");return{name:e.metadata.name||"Homegame",author:e.metadata.author||e.metadata.createdBy,gameClass:a(e,t,{trusted:s}),assetBundle:e.assets.length?n(e):null,gameKey:`project:${r}`,versionId:`save-schema:${e.manifest.saveSchemaVersion}`,packageRevision:e.revision}}}},5061(e){"use strict";e.exports={attachSaveHost:function(e,t,s){const{installationId:r,gameId:i,versionId:n,compatibility:o=[],onStatus:a=()=>{}}=s;if(!/^[a-zA-Z0-9-]{16,80}$/.test(r)||"string"!=typeof i||!/^save-schema:\d+$/.test(n))throw new Error("Invalid save identity");const h="project:"+r,l=[n,...o.filter(e=>/^save-schema:\d+$/.test(e)).slice(0,32)].filter((e,t,s)=>s.indexOf(e)===t);let c,d,u,p,f,m,g,y=!1,v=0,w=!1,x=null,b=0,E=Promise.resolve();const S=(e,t)=>{try{a({state:e,message:t})}catch(e){}},k=e=>S("error","Progress not saved: "+e.message+" Download a save backup before closing."),_=e=>{const t=JSON.stringify(e);if(void 0===t||(new TextEncoder).encode(t).length>1048576)throw new Error("Save data must be JSON and at most 1 MiB");return JSON.parse(t)};function C(){return s.database?Promise.resolve(s.database):(c||(c=new Promise((t,s)=>{let r=!1;const i=e.indexedDB.open("homegames-portable-saves",1);i.onupgradeneeded=()=>i.result.createObjectStore("saves",{keyPath:["installationId","versionId"]}),i.onerror=()=>s(i.error),i.onblocked=()=>{r=!0,s(new Error("Close other game tabs and reload to update save storage."))},i.onsuccess=()=>{r?i.result.close():(i.result.onversionchange=()=>i.result.close(),t(i.result))}})),c)}function A(e){b++;const t=E.then(e);return E=t.catch(()=>{}).finally(()=>{b--}),t}async function I(){try{const e=await C(),t=await new Promise((t,s)=>{const i=e.transaction("saves","readonly"),n=[];l.forEach((e,t)=>{const s=i.objectStore("saves").get([r,e]);s.onsuccess=()=>{n[t]=s.result}}),i.oncomplete=()=>t(n),i.onabort=()=>s(i.error||new Error("Could not read game save"))});v=t[0]?.generation||0;const s=t.find(Boolean);if(s){if(s.envelope.gameId!==i||!l.includes(s.envelope.versionId))throw new Error("Saved game identity does not match this game");x={...s.envelope,data:_(s.envelope.data)}}return w=!0,S("ready",x?"Game progress restored from this browser":"Game saves stay in this browser"),x}catch(e){return w=!0,g=e,k(e),null}}async function T(e,t=n){if(!w)throw new Error("Load this game before saving");if(x=((e,t=n)=>({gameKey:h,gameId:i,versionId:t,savedAt:Date.now(),data:_(e)}))(e,t),g)throw g;const o=await C(),a=x;await new Promise((e,t)=>{const i=s.transaction?s.transaction(["saves"]):o.transaction("saves","readwrite"),h=i.objectStore("saves");let l;const c=h.get([r,n]);c.onsuccess=()=>{try{if((c.result?.generation||0)!==v)throw new Error("Another tab saved newer progress. Reload to use it, or download this session’s save.");h.put({installationId:r,versionId:n,generation:v+1,envelope:a})}catch(e){l=e,i.abort()}},i.oncomplete=()=>{v++,e()},i.onabort=()=>t(l||i.error||new Error("Browser storage could not save progress"))}),S("saved","Game progress saved in this browser")}const P=e=>{d&&!y&&d.postMessage(e)};function L(s){if(y||d||s.source!==t.contentWindow||"null"!==s.origin||"homegames-save-connect-v1"!==s.data?.type)return;const r=new e.MessageChannel;d=r.port1,d.onmessage=e=>{const t=e.data;if(y||!t||"object"!=typeof t)return;if("closed"===t.type)return void f?.();const{id:s,op:r}=t;if(!Number.isSafeInteger(s)||s<1||!["get","put"].includes(r))return;if(b>=64)return void P({id:s,error:"Too many pending save requests"});if(Object.keys(t).some(e=>!["id","op","data"].includes(e)))return void P({id:s,error:"Invalid save request"});let i;try{"put"===r&&(i=_(t.data))}catch(e){return P({id:s,error:e.message}),void k(e)}A(async()=>{if(y)throw new Error("Game session closed");return"get"===r?w?x:I():T(i)}).then(e=>P({id:s,value:e}),e=>{k(e),P({id:s,error:e.message})})},t.contentWindow.postMessage({type:"homegames-save-port-v1"},"*",[r.port2])}e.addEventListener("message",L);const M=e=>{b&&(e.preventDefault(),e.returnValue="")};function R(){y=!0,clearTimeout(m),d?.close(),e.removeEventListener("message",L),e.removeEventListener("beforeunload",M),c?.then(e=>e.close(),()=>{})}function N(){return u||(u=(async()=>{d&&!y&&await new Promise(e=>{f=e,m=setTimeout(e,3e3),P({type:"close"})}),await E})()),u}return e.addEventListener("beforeunload",M),{get pending(){return b>0},get stopped(){return Boolean(u)},close:async()=>p||(p=(async()=>{await N(),R()})(),p),dispose:R,async exportSave(){if(await E,!x)throw new Error("This game has not saved any progress yet");return JSON.stringify({...x,data:_(x.data)})},async importSave(e){if("string"!=typeof e||(new TextEncoder).encode(e).length>1052672)throw new Error("Save file is too large");const t=JSON.parse(e);if(t?.gameId!==i||!l.includes(t.versionId))throw new Error("This save is for a different game or an incompatible save version");const s=_(t.data);await N(),await A(async()=>{w||await I(),await T(s,t.versionId)})},downloadSave(t="game-save.json"){return this.exportSave().then(s=>{const r=e.URL.createObjectURL(new Blob([s],{type:"application/json"})),i=e.document.createElement("a");i.href=r,i.download=t,i.click(),setTimeout(()=>e.URL.revokeObjectURL(r),3e4)})}}},connectSaveStore:function(e,{gameKey:t,versionId:s,onError:r=()=>{},stop:i=()=>{}}){return new Promise((n,o)=>{let a,h=0,l=!1;const c=new Map,d=setTimeout(()=>{e.removeEventListener("message",u),o(new Error("Game save storage did not connect. Reload to try again."))},1e4);function u(o){function p(e,t){return l?Promise.reject(new Error("Game session closed")):c.size>=64?Promise.reject(new Error("Too many pending save requests")):new Promise((s,i)=>{const n=++h,o=setTimeout(()=>{c.delete(n);const e=new Error("Game save timed out");r(e),i(e)},1e4);c.set(n,{resolve:s,reject:i,timeout:o});try{a.postMessage(void 0===t?{id:n,op:e}:{id:n,op:e,data:t})}catch(e){clearTimeout(o),c.delete(n),i(e)}})}o.source===e.parent&&"homegames-save-port-v1"===o.data?.type&&o.ports[0]&&(clearTimeout(d),e.removeEventListener("message",u),a=o.ports[0],a.onmessage=e=>{const t=e.data;if("close"===t?.type){i(),l=!0;const e=()=>{c.size?setTimeout(e,10):(a.postMessage({type:"closed"}),a.close())};return void e()}const s=c.get(t?.id);if(s)if(c.delete(t.id),clearTimeout(s.timeout),t.error){const e=new Error(t.error);r(e),s.reject(e)}else s.resolve(t.value)},n({eager:!0,strict:!0,getSave:e=>e==="local:"+t?p("get"):Promise.reject(new Error("Wrong game save key")),putSave:(e,r)=>e!=="local:"+t||r?.gameKey!==t||r.versionId!==s?Promise.reject(new Error("Wrong game save identity")):p("put",r.data)}))}e.addEventListener("message",u),e.parent.postMessage({type:"homegames-save-connect-v1"},"*")})}}},4394(e,t,s){"use strict";const{exportArchive:r,LIMITS:i}=s(5110),{validateName:n,LIMITS:o}=s(5828),a=new TextEncoder,h=new TextDecoder("utf-8",{fatal:!0});function l(e){const t=a.encode(JSON.stringify(e)),s=new Uint8Array(1+t.length);return s[0]=14,s.set(t,1),s}e.exports={ProjectTransferHost:class{constructor({exportProject:e,listExports:t,readExport:s,timeoutMs:r=3e4}){Object.assign(this,{exportProject:e,listExports:t,readExport:s,timeoutMs:r}),this.transfers=new Map,this.closed=!1}async handle(e,t,s){if(this.closed||"project-transfer"!==t?.type||(i=t.id,!(Number.isInteger(i)&&i>0&&i<=4294967295)))return;var i;const a=this.transfers.get(e),h=e=>s(l({action:"error",id:t.id,message:e}));if("cancel"===t.action)return void(a?.id===t.id&&this.leave(e));if("request"===t.action){if(a||this.transfers.size>=4)return void h("A file transfer is already in progress. Try again shortly.");const i={id:t.id,offset:0,send:s};this.transfers.set(e,i),this.touch(e,i);try{let a,h;const c=t.kind||"project";if("export-list"===c){if(!this.listExports)throw new Error("This host does not support viewing exports");const t=await this.listExports(e);if(this.closed||this.transfers.get(e)!==i)return;return this.leave(e),void s(l({action:"exports",id:i.id,files:t}))}if("export"===c){if(n(t.name),!this.readExport)throw new Error("This host does not support viewing exports");if(a=await this.readExport(e,t.name),!(a instanceof Uint8Array)||a.length>o.fileBytes)throw new Error("Invalid export");h={kind:c,name:t.name}}else{if("project"!==c)throw new Error("Unknown file request");{const t=await this.exportProject(e);a=await r(t),h={gameId:t.manifest.gameId,revision:t.revision,name:String(t.metadata.name||"Game").slice(0,200)}}}if(this.closed||this.transfers.get(e)!==i)return;i.bytes=a,s(l({action:"offer",id:i.id,bytes:a.length,...h}))}catch(t){this.transfers.get(e)===i&&(this.leave(e),h(String(t.message).slice(0,200)))}return}if("ack"!==t.action||!a||a.id!==t.id)return;if(!a.bytes||t.offset!==a.offset)return this.leave(e),void h("Invalid game-copy acknowledgement");if(this.touch(e,a),a.offset===a.bytes.length)return this.leave(e),void s(l({action:"complete",id:a.id}));const c=Math.min(a.offset+65536,a.bytes.length),d=new Uint8Array(9+c-a.offset);d[0]=15;const u=new DataView(d.buffer);u.setUint32(1,a.id),u.setUint32(5,a.offset),d.set(a.bytes.subarray(a.offset,c),9),a.offset=c,s(d)}touch(e,t){clearTimeout(t.timer),t.timer=setTimeout(()=>{this.transfers.get(e)===t&&(this.leave(e),t.send(l({action:"error",id:t.id,message:"Game-copy transfer timed out"})))},this.timeoutMs)}leave(e){const t=this.transfers.get(e);t&&clearTimeout(t.timer),this.transfers.delete(e)}close(){this.closed=!0;for(const e of this.transfers.keys())this.leave(e)}},ProjectTransferClient:class{constructor({send:e,importArchive:t,timeoutMs:s=45e3}){Object.assign(this,{send:e,importArchive:t,timeoutMs:s}),this.sequence=Math.floor(16777215*Math.random())}request({kind:e="project",name:t}={}){if(this.closed)return Promise.reject(new Error("Session closed"));if(this.pending)return Promise.reject(new Error("A file transfer is already in progress"));if(!["project","export-list","export"].includes(e))return Promise.reject(new Error("Unknown file request"));if("export"===e)try{n(t)}catch(e){return Promise.reject(e)}return new Promise((s,r)=>{const i=this.sequence=this.sequence%4294967295+1;this.pending={id:i,resolve:s,reject:r,offset:0,kind:e,name:t},this.touch();try{this.send({type:"project-transfer",action:"request",id:i,kind:e,name:t})}catch(e){this.fail(e)}})}touch(){const e=this.pending;clearTimeout(e.timer),e.timer=setTimeout(()=>this.fail(new Error("Game-copy request timed out. The host may not support exporting.")),this.timeoutMs)}async receive(e){const t=this.pending;if(!t)return;const s=e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength);try{if(14===s[0]){if(s.length>("export-list"===t.kind?32768:4096))throw new Error("Oversized file-transfer control");const e=JSON.parse(h.decode(s.subarray(1)));if(e.id!==t.id)return;if("error"===e.action)throw new Error(String(e.message).slice(0,200));if("exports"===e.action){if("export-list"!==t.kind||!Array.isArray(e.files)||e.files.length>o.files)throw new Error("Invalid export list");const s=new Set;let r=0;const i=e.files.map(e=>{if(n(e.name),s.has(e.name.toLowerCase())||!Number.isSafeInteger(e.size)||e.size<0||e.size>o.fileBytes||(r+=e.size)>o.totalBytes)throw new Error("Invalid export list");return s.add(e.name.toLowerCase()),{name:e.name,size:e.size}});return this.pending=null,clearTimeout(t.timer),void t.resolve(i)}if("offer"===e.action){const s="export"===t.kind;if("export-list"===t.kind||t.bytes||!Number.isSafeInteger(e.bytes)||e.bytes<(s?0:1)||e.bytes>(s?o.fileBytes:i.archiveBytes)||(s?"export"!==e.kind||e.name!==t.name:"export"===e.kind||!/^[a-f0-9]{64}$/.test(e.revision)||"string"!=typeof e.gameId))throw new Error("Invalid file-transfer offer");return t.metadata=e,t.bytes=new Uint8Array(e.bytes),this.touch(),void this.send({type:"project-transfer",action:"ack",id:t.id,offset:0})}if("complete"!==e.action||!t.bytes||t.offset!==t.bytes.length||t.validating)throw new Error("Incomplete game copy");if(t.validating=!0,this.touch(),"export"===t.kind)return this.pending=null,clearTimeout(t.timer),void t.resolve({name:t.name,bytes:t.bytes});const r=await this.importArchive(t.bytes);if(this.pending!==t)return;if(r.revision!==t.metadata.revision||r.manifest.gameId!==t.metadata.gameId)throw new Error("Game-copy identity changed");return this.pending=null,clearTimeout(t.timer),void t.resolve({bytes:t.bytes,project:r})}if(15!==s[0]||s.length<10)throw new Error("Invalid game-copy packet");const e=new DataView(s.buffer,s.byteOffset,s.byteLength);if(e.getUint32(1)!==t.id)return;if(!t.bytes||t.validating||e.getUint32(5)!==t.offset||s.length-9!==Math.min(65536,t.bytes.length-t.offset))throw new Error("Invalid game-copy offset");t.bytes.set(s.subarray(9),t.offset),t.offset+=s.length-9,this.touch(),this.send({type:"project-transfer",action:"ack",id:t.id,offset:t.offset})}catch(e){this.pending===t&&this.fail(e)}}fail(e){const t=this.pending;if(t){this.pending=null,clearTimeout(t.timer);try{this.send({type:"project-transfer",action:"cancel",id:t.id})}catch(e){}t.reject(e)}}close(){this.fail(new Error("Session closed")),this.closed=!0}},CONTROL:14,CHUNK:15}},2439(e){"use strict";const t=new WeakMap;function s(e){if("string"!=typeof e||!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e))throw new Error("Game metadata needs a UUID gameId")}function r(e,{runtime:t,legacy:r=!0}={}){if(!e||"object"!=typeof e||Array.isArray(e))throw new Error("Invalid game metadata");if(void 0!==e.services&&(!Array.isArray(e.services)||e.services.some(e=>"multiplayer"!==e)))throw new Error("Unsupported legacy service: games requiring contentGenerator or other hosted services cannot run");if(!r){if(s(e.gameId),"string"!=typeof e.name||!e.name.trim()||e.name.length>100)throw new Error("Game metadata needs a name of 1–100 characters");if(void 0!==e.services)throw new Error("services is retired; declare maxPlayers instead");if(void 0!==e.squishVersion)throw new Error("Declare the runtime only in the Squish import, not metadata.squishVersion");if(void 0!==e.multiplayer)throw new Error("multiplayer is derived from maxPlayers");if(void 0!==e.tickRate&&(!Number.isFinite(e.tickRate)||e.tickRate<1||e.tickRate>120))throw new Error("tickRate must be between 1 and 120")}const i=e.maxPlayers??(r?64:void 0);if(!Number.isSafeInteger(i)||i<1||i>255)throw new Error("maxPlayers must be an integer from 1 to 255");if(void 0!==e.saveSchemaVersion&&(!Number.isSafeInteger(e.saveSchemaVersion)||e.saveSchemaVersion<1))throw new Error("Invalid saveSchemaVersion");if(t&&void 0!==e.squishVersion&&e.squishVersion!==t)throw new Error("metadata.squishVersion must match the Squish import");const n={...e,maxPlayers:i,multiplayer:i>1};return(t||e.squishVersion)&&(n.squishVersion=t||e.squishVersion),delete n.services,n}e.exports={normalizeMetadata:r,validateGameId:s,bindRuntimeMetadata:function(e,s){return t.set(e,s),e},runtimeMetadata:function(e){const s="function"==typeof e.metadata?e.metadata():{};let i,n=e;for(;n&&!(i=t.get(n));)n=Object.getPrototypeOf(n);return r({...s,...i?{maxPlayers:i.maxPlayers}:{}},{runtime:i?.squishVersion,legacy:!0})}}},9956(e,t,s){const{Squisher:r}=s(5911);e.exports={createSessionRuntime:(e,t,i={})=>{if("function"!=typeof e?.squish||"function"!=typeof e?.unsquish)throw new Error("Session needs an explicit Squish codec");const n=new r({...i,game:t,encodeNode:e.squish,decodeNode:e.unsquish});let o=!1;return{squisher:n,listExports:()=>o?Promise.reject(new Error("Session closed")):i.userExportsStore?.list()||Promise.resolve([]),readExport:e=>o?Promise.reject(new Error("Session closed")):i.userExportsStore?.read(e)||Promise.reject(new Error("Export not found")),exportProject:()=>o?Promise.reject(new Error("Session closed")):s(2947).exportGameProject(t,i.userExportsStore),stop(){o||(o=!0,n.close(),i.userExportsStore?.close())}}},playerFrame:(e,t)=>{const s=e.getPlayerFrame(t);let r=0;for(let e=0;e<s.length;e++){if(!(e in s))continue;const t=s[e];if(Array.isArray(t))for(let e=0;e<t.length;e++)e in t&&r++;else r++}const i=new Uint8Array(r);let n=0;for(let e=0;e<s.length;e++){if(!(e in s))continue;const t=s[e];if(Array.isArray(t))for(let e=0;e<t.length;e++)e in t&&(i[n++]=t[e]);else i[n++]=t}return i}}},2409(e){"use strict";function t(e){let t=0;const s=e=>Number.isFinite(e)?e:0,r=e=>({x:s(e?.x),y:s(e?.y)});function i(e,n){if(!e||"object"!=typeof e||n>48||++t>4e3)return null;const o={id:"number"==typeof e.id?e.id:String(e.id).slice(0,100),children:[]};if(Array.isArray(e.coordinates2d)&&(o.coordinates2d=e.coordinates2d.slice(0,512).filter(e=>Array.isArray(e)&&e.length>=2).map(e=>[s(e[0]),s(e[1])])),Array.isArray(e.fill)&&(o.fill=e.fill.slice(0,4).map(s)),e.text&&(o.text={...r(e.text),text:String(e.text.text||"").slice(0,2e3),size:s(e.text.size),align:String(e.text.align||"").slice(0,20)}),e.asset&&(o.asset={key:String(e.asset.key||"").slice(0,200),pos:r(e.asset.pos),size:r(e.asset.size)}),Array.isArray(e.playerIds)&&(o.playerIds=e.playerIds.slice(0,64).filter(Number.isFinite)),e.clickable&&(o.clickable=!0),e.input&&(o.input=String(e.input).slice(0,100)),Array.isArray(e.children))for(const s of e.children){if(t>=4e3)break;const e=i(s,n+1);e&&o.children.push(e)}return o}return Array.isArray(e)?e.slice(0,128).map(e=>i(e,0)).filter(Boolean):[]}e.exports={inspectorTree:t,attachStudioDebugHost:function(e,s,{onReady:r=()=>{},onError:i=()=>{},onLog:n=()=>{}}={}){let o,a,h,l,c=!1,d=0,u=1;const p=new Map;function f(e,t){return!o||c?Promise.reject(new Error("Preview debugger is not ready")):new Promise((s,r)=>{const i=++d,n=setTimeout(()=>{p.delete(i),r(new Error("Preview debugger timed out"))},5e3);p.set(i,{resolve:s,reject:r,timer:n}),o.postMessage({id:i,action:e,value:t})})}const m=(e,t)=>{f(e,t).catch(e=>{c||i(e)})};function g(i){if(c||o||i.source!==s.contentWindow||"null"!==i.origin||"homegames-studio-debug-v1"!==i.data?.type)return;const d=new e.MessageChannel;o=d.port1,o.onmessage=({data:e})=>{if(!c&&e)if("ready"===e.event)u=Number.isFinite(e.playerId)?e.playerId:1,r(!0===e.available);else if("snapshot"===e.event&&a&&Number.isFinite(e.time)&&Number.isSafeInteger(e.frame))a({time:e.time,buf:e.frame,tree:t(e.tree)});else if("input"===e.event&&h&&Number.isFinite(e.value?.time))h({time:e.value.time,type:String(e.value.type||"").slice(0,40),key:String(e.value.key||"").slice(0,80)});else if("pick"===e.event&&l){const t=null===e.x?null:Number(e.x),s=null===e.y?null:Number(e.y);if((null===t||Number.isFinite(t))&&(null===s||Number.isFinite(s)))if("select"===e.kind){const e=l.onPick;l=null,e?.(t,s)}else l.onMove?.(t,s)}else if("log"===e.event&&["log","warn","error"].includes(e.level))n(e.level,String(e.message).slice(0,4e3));else if("result"===e.event){const t=p.get(e.id);if(!t)return;p.delete(e.id),clearTimeout(t.timer),e.error?t.reject(new Error(String(e.error).slice(0,500))):t.resolve(e.value)}},s.contentWindow.postMessage({type:"homegames-studio-debug-port-v1"},"*",[d.port2])}return e.addEventListener("message",g),{embedded:!0,get playerId(){return u},enableInspector(e,t){a=e,h=t,m("inspect",!0)},disableInspector(){a=h=l=null,m("inspect",!1)},showFrame:e=>m("frame",e),resumeLive:()=>m("live"),setHighlight:e=>m("highlight",e),enablePick(e){l=e,m("pick",!0)},disablePick(){l=null,m("pick",!1)},addPlayer:()=>f("add-player"),removePlayer:e=>m("remove-player",e),freeze:()=>m("freeze"),stop(){if(!c){c=!0,e.removeEventListener("message",g),o?.close(),a=h=l=null;for(const e of p.values())clearTimeout(e.timer),e.reject(new Error("Preview closed"));p.clear()}}}},connectStudioDebugSource:function(e,s){const r=e.document,i=new Map;let n,o,a,h=!1,l=!1,c=0,d=0,u=null;const p=e=>{!h&&n&&n.postMessage(e)},f=()=>e.dispatchEvent(new e.Event("resize"));function m(e){null!==u&&e?.removePlayer(u),u=null,o?.remove(),o=null,a?.remove(),a=null,f()}const g=(e,t)=>{const s=r.createElement("span");return s.textContent=t,s.style.cssText="position:absolute;left:8px;top:6px;z-index:2;background:#101820cc;color:#fff;padding:3px 6px;border-radius:4px;font:12px system-ui;pointer-events:none",e.style.position="relative",e.append(s),s},y={inspect(e,s){i.clear(),d=0,s?e.enableInspector(e=>{if(!e.buf?.byteLength||e.buf.byteLength>8388608)return;const s=++c;for(i.set(s,e.buf.slice()),d+=e.buf.byteLength;i.size>600||d>67108864;){const e=i.keys().next().value;d-=i.get(e).byteLength,i.delete(e)}p({event:"snapshot",frame:s,time:e.time,tree:t(e.tree)})},e=>p({event:"input",value:e})):e.disableInspector()},frame(e,t){const s=i.get(t);if(!s)throw new Error("This recorded frame is no longer available");e.showFrame(s)},live:e=>e.resumeLive(),highlight:(e,t)=>e.setHighlight(t),pick(e,t){t?e.enablePick({onMove:(e,t)=>p({event:"pick",kind:"move",x:e,y:t}),onPick:(e,t)=>p({event:"pick",kind:"select",x:e,y:t})}):e.disablePick()},"add-player"(e){if(null!==u)return u;if(e.frozen)throw new Error("Restart the game before adding a player");const t=r.getElementById("game");if(o=r.createElement("div"),o.id="studio-debug-player-2",o.style.cssText="flex:1;min-height:0;display:flex;align-items:center;justify-content:center;overflow:hidden;border-top:1px solid #45546a",t.after(o),f(),u=e.addPlayer(o.id),null===u)throw m(e),new Error("Could not add a player");return a=g(t,"Player "+e.playerId),g(o,"Player "+u),f(),u},"remove-player":e=>m(e),freeze(e){m(e),e.freeze()}};function v(t){h||n||t.source!==e.parent||"homegames-studio-debug-port-v1"!==t.data?.type||!t.ports[0]||(e.removeEventListener("message",v),n=t.ports[0],n.onmessage=({data:e})=>{if(!h&&e&&Number.isSafeInteger(e.id))try{const t=s();if(!t)throw new Error("Debug tools require a local game");if(!Object.hasOwn(y,e.action))throw new Error("Unknown debug action");const r=y[e.action](t,e.value);p({event:"result",id:e.id,value:r})}catch(t){p({event:"result",id:e.id,error:t.message})}},p({event:"ready",available:l,playerId:s()?.playerId}))}e.addEventListener("message",v),e.parent.postMessage({type:"homegames-studio-debug-v1"},"*");const w={},x={};let b=0,E=0;for(const t of["log","warn","error"])w[t]=e.console[t],x[t]=(...s)=>{w[t].apply(e.console,s);const r=Date.now();if(r-b>1e3&&(E=0,b=r),++E>25)return;const i=s.map(e=>{try{return"string"==typeof e?e:JSON.stringify(e)}catch(t){return String(e)}}).join(" ").slice(0,4e3);p({event:"log",level:t,message:i})},e.console[t]=x[t];return{ready(){l=!!s(),p({event:"ready",available:l,playerId:s()?.playerId})},close(){if(!h){h=!0,e.removeEventListener("message",v),s()?.disableInspector(),m(s()),i.clear(),n?.close();for(const t of Object.keys(w))e.console[t]===x[t]&&(e.console[t]=w[t])}}}}}},32(e){"use strict";e.exports={openGameInStudio:function(e,t,s="https://homegames.io/studio.html"){const r=new URL(s);if(!["https:","http:"].includes(r.protocol)||r.username||r.password)throw new Error("Invalid Studio address");const i=e.crypto.randomUUID(),n=r.origin;return r.hash=new URLSearchParams({edit:i,from:"file:"===e.location.protocol?"file://":e.location.origin}).toString(),new Promise((s,o)=>{let a,h,l=!1,c=!1;const d=t=>{c||(c=!0,clearTimeout(f),clearInterval(m),e.removeEventListener("message",p),e.removeEventListener("pagehide",u),t?o(t):s())},u=()=>d(new Error("Keep the game open until Studio receives it.")),p=e=>{if(!c&&a&&e.source===a&&e.origin===n&&e.data?.token===i)return"homegames-studio-saved"===e.data.type?d():"homegames-studio-error"===e.data.type?d(new Error(String(e.data.error).slice(0,300))):void("homegames-studio-ready"!==e.data.type||l||(l=!0,h||=Promise.resolve().then(t).then(e=>{if(!(e instanceof Uint8Array)||!e.length||e.length>68157440)throw new Error("Invalid game archive");return e}),h.then(e=>{c||a.postMessage({type:"homegames-studio-game",token:i,bytes:e},n),l=!1}).catch(d)))},f=setTimeout(()=>d(new Error("Studio did not receive the game. Open Studio online once, or import the game HTML or ZIP there.")),9e4),m=setInterval(()=>{a?.closed&&d(new Error("Studio was closed before saving the copy."))},500);e.addEventListener("message",p),e.addEventListener("pagehide",u);try{a=e.open(r.href,"_blank"),a||d(new Error("Allow this game to open a Studio tab, or import its HTML or ZIP in Studio."))}catch(e){d(e)}})},receiveGameInStudio:function(e,t){const s=new URLSearchParams(e.location.hash.slice(1)),r=s.get("edit"),i=s.get("from"),n=e.opener,o="file://"===i;if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(r||"")||!n)return Promise.reject(new Error("Reopen Edit this game from the player, or import its HTML or ZIP."));try{if(!("null"===i||o||["http:","https:"].includes(new URL(i).protocol)&&new URL(i).origin===i))throw new Error}catch(e){return Promise.reject(new Error("Invalid game sender"))}return new Promise((s,a)=>{let h=!1,l=!1;const c=e=>{try{n.postMessage({...e,token:r},"null"===i||o?"*":i)}catch(e){}},d=(t,r)=>{l||(l=!0,clearTimeout(m),clearInterval(g),e.removeEventListener("message",p),e.removeEventListener("pagehide",u),t?(c({type:"homegames-studio-error",error:t.message}),a(t)):(c({type:"homegames-studio-saved"}),s(r)))},u=()=>d(new Error("Studio closed before receiving the game.")),p=e=>{if(l||h||e.source!==n||(o?!["null","file://"].includes(e.origin):e.origin!==i)||e.data?.token!==r||"homegames-studio-game"!==e.data.type)return;const s=e.data.bytes;if(!(s instanceof Uint8Array)||!s.length||s.length>68157440)return d(new Error("Invalid game archive"));h=!0,clearInterval(g),clearTimeout(m),Promise.resolve().then(()=>t(s)).then(e=>d(null,e),d)},f=()=>c({type:"homegames-studio-ready"}),m=setTimeout(()=>d(new Error("The game did not arrive. Keep its tab open and try Edit this game again.")),9e4),g=setInterval(f,500);e.addEventListener("message",p),e.addEventListener("pagehide",u),f()})}}},5828(e){"use strict";const t="user-exports",s=Object.freeze({files:128,fileBytes:16777216,totalBytes:67108864});function r(e){if("string"!=typeof e||!/^[A-Za-z0-9_][A-Za-z0-9_. -]{0,119}$/.test(e)||/[ .]$/.test(e)||/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(e)||["__proto__","prototype","constructor"].includes(e))throw new Error("Export name must be a portable file name, not a path");return e}function i(e){const t=Object.keys(e),i=new Set;let n=0;if(t.length>s.files)throw new Error("Too many user exports");for(const o of t){r(o);const t=o.toLowerCase();if(i.has(t))throw new Error("Export names must differ ignoring capitalization");i.add(t);const a=e[o];if(!(a instanceof Uint8Array)||a.length>s.fileBytes||(n+=a.length)>s.totalBytes)throw new Error("User export size limit exceeded")}}const n=e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e,new Uint8Array(t)]));e.exports={DIRECTORY:t,LIMITS:s,validateName:r,validateFiles:i,createUserExports:function(e={},t=async()=>{}){i(e);let o=n(e),a=Promise.resolve(),h=!1,l=0;const c=new Map;return{userExports:Object.freeze(n(o)),createExport:function(e,n){try{if(h)throw new Error("Game session closed");if(r(e),!(n instanceof Uint8Array))throw new Error("Export data must be Uint8Array bytes");if(n.length>s.fileBytes||l>=128)throw new Error("User export limit exceeded");n=new Uint8Array(n)}catch(e){return Promise.reject(e)}l++;const d=a.then(async()=>{const s={...o,[e]:n};i(s),await t(e,new Uint8Array(n)),o=s,c.delete(e)});return a=d.catch(t=>{c.set(e,t)}).finally(()=>{l--}),d},list:async()=>(await a,Object.entries(o).map(([e,t])=>({name:e,size:t.length}))),async read(e){if(r(e),await a,!Object.hasOwn(o,e))throw new Error("Export not found");return new Uint8Array(o[e])},async snapshot(){if(await a,c.size)throw c.values().next().value;return n(o)},close:()=>(h=!0,a)}},projectExports:function(e){const s=Object.create(null);for(const i of e.reader.listFiles())if(i.startsWith(t+"/")){const t=i.slice(13);r(t),s[t]=e.reader.readFile(i)}return i(s),s}}},5900(e){"use strict";e.exports={recordVideo:function(e,t){const{document:s,navigator:r,MediaRecorder:i,performance:n,Blob:o}=e,a=5242880;let h,l;const c=new Promise((e,t)=>{l=s=>{h.destroy(),s.error?t(new Error(s.error)):e(s)}});return h=new class{constructor(e){this.send=e,this.container=s.body,this.hidden=()=>{s.hidden&&this.fail("Recording cancelled because the page was hidden. Try again.")},s.addEventListener("visibilitychange",this.hidden)}request(e){const t=Math.min(30,Math.max(1,Number(e.durationSeconds)||30)),n=s.createElement("dialog");n.setAttribute("aria-label","Record video"),n.style.cssText="box-sizing:border-box;margin:auto;padding:20px;width:min(440px,94vw);max-height:94vh;overflow:auto;border:2px solid #30213e;border-radius:20px;background:#fff8eb;color:#30213e;font:16px system-ui;text-align:center";const o=s.createElement("h2");o.textContent="Record video",o.style.cssText="margin:0 0 8px";const h=s.createElement("p");h.textContent=String(e.prompt||"").slice(0,120),h.style.cssText="font-size:24px;font-weight:800;overflow-wrap:anywhere;margin:8px 0 16px";const l=s.createElement("video");l.muted=!0,l.autoplay=!0,l.playsInline=!0,l.style.cssText="display:none;width:100%;max-height:30vh;object-fit:contain;background:#30213e;border-radius:12px;transform:scaleX(-1)";const c=s.createElement("p");c.textContent=`Enable your camera and microphone. Your ${t}-second video will be shared with everyone in this game after recording.`,c.setAttribute("aria-live","polite");const d=s.createElement("button");d.textContent="Enable camera & microphone";const u=s.createElement("button");u.textContent="Cancel";for(const e of[d,u])e.style.cssText="padding:13px 16px;margin:5px;border:0;border-radius:10px;background:#30213e;color:#fff8eb;font:600 15px system-ui;cursor:pointer";u.style.background="#e8dfd2",u.style.color="#30213e",n.append(o,h,l,c,d,u),this.container.appendChild(n);const p=Math.min(a,Math.max(131072,Math.floor(Number(e.maxBytes)||a))),f=this.active={id:e.id,duration:t,maxBytes:p,dialog:n,preview:l,status:c,start:d,cancel:u,chunks:[],size:0};u.onclick=()=>this.fail("Recording cancelled. You can try again."),n.oncancel=e=>{e.preventDefault(),u.onclick()},d.onclick=async()=>{d.disabled=!0;try{if(void 0===i)throw new Error("This browser cannot record video. Try a current browser.");if(!r.mediaDevices?.getUserMedia)throw new Error("Camera recording needs HTTPS or localhost.");const e=await r.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0},video:{width:{ideal:640},height:{ideal:360},frameRate:{ideal:20,max:24},facingMode:"user"}});if(this.active!==f)return void e.getTracks().forEach(e=>e.stop());f.stream=e;for(const t of e.getTracks())t.onended=()=>this.fail("Camera or microphone disconnected. Please try again.");if(l.srcObject=e,l.style.display="block",await l.play(),this.active!==f)return;c.textContent="Check your framing, then start recording.",d.textContent=`Record ${t} seconds`,d.disabled=!1,d.onclick=()=>this.countdown(f)}catch(e){this.active===f&&this.fail(e.message||"Unable to access camera and microphone")}},n.showModal(),d.focus()}countdown(e){if(this.active!==e)return;e.start.disabled=!0;let t=3;e.status.textContent=`Get ready… ${t}`,e.countdown=setInterval(()=>{t--,t?e.status.textContent=`Get ready… ${t}`:(clearInterval(e.countdown),this.start(e))},1e3)}start(e){if(this.active===e)try{const t=["video/webm;codecs=vp8,opus","video/mp4","video/webm"].find(e=>i.isTypeSupported(e)),s=e.recorder=new i(e.stream,{...t?{mimeType:t}:{},videoBitsPerSecond:Math.min(65e4,Math.max(1e5,Math.floor(8*e.maxBytes/e.duration*.75)-64e3)),audioBitsPerSecond:64e3});s.ondataavailable=t=>{this.active===e&&t.data.size&&(e.size+=t.data.size,e.size>e.maxBytes?this.fail("This recording is too large. Please try again."):e.chunks.push(t.data))},s.onerror=()=>{this.active===e&&this.fail("The camera could not finish recording. Please try again.")},s.onstop=()=>this.finish(e),s.start(1e3);const r=n.now()+1e3*e.duration,o=()=>{e.status.textContent=`RECORDING · ${Math.max(0,Math.ceil((r-n.now())/1e3))} seconds left`};o(),e.clock=setInterval(o,200),e.timer=setTimeout(()=>{clearInterval(e.clock),e.status.textContent="Sending recording…",s.stop(),this.stopTracks(e)},1e3*e.duration)}catch(e){this.fail(e.message||"Unable to start recording")}}async finish(t){var s;if(this.active===t)try{const r=t.recorder.mimeType||t.chunks[0]?.type||"video/webm",i=new o(t.chunks,{type:r});if(!i.size||i.size>t.maxBytes)throw new Error("Recording was empty or too large. Please try again.");const n=new Uint8Array(await i.arrayBuffer());if(this.active!==t)return;let a="";for(let e=0;e<n.length;e+=8192)a+=String.fromCharCode(...n.subarray(e,e+8192));const h={type:"media",action:"record-result",id:t.id,data:(s=a,e.btoa(s)),contentType:r,fileName:r.includes("mp4")?"recording.mp4":"recording.webm"};this.cancel(t.id),this.send(h)}catch(e){this.active===t&&this.fail(e.message||"Unable to send recording")}}stopTracks(e){e.stream?.getTracks().forEach(e=>{e.onended=null,e.stop()}),e.preview.srcObject=null}cancel(e){const t=this.active;t&&t.id===e&&(this.active=null,clearTimeout(t.timer),clearInterval(t.clock),clearInterval(t.countdown),"inactive"!==t.recorder?.state&&t.recorder&&t.recorder.stop(),this.stopTracks(t),t.dialog.close(),t.dialog.remove(),t.chunks=[])}fail(e){const t=this.active?.id;t&&(this.cancel(t),this.send({type:"media",action:"record-result",id:t,error:e}))}destroy(){this.cancel(this.active?.id),s.removeEventListener("visibilitychange",this.hidden)}}(l),h.request(t),{result:c,close(){h.fail("Recording cancelled")}}}}},6866(e,t,s){const r=s(6260);e.exports={...r,name:"DUALSHOCK 4 Wireless Controller"}},6593(e,t,s){const r=s(6260);e.exports={...r,name:"DualSense Wireless Controller Extended Gamepad"}},7635(e,t,s){const r=s(6260);e.exports={...r,name:"Luna Gamepad Extended Gamepad"}},4255(e,t,s){const r=s(6260);e.exports={...r,name:"8Bitdo NES30 Arcade(x)"}},1085(e,t,s){const r=s(6260);e.exports={...r,name:"Stadia Controller Extended Gamepad"}},6260(e){e.exports={name:"standard",buttons:{FACE_1:0,FACE_2:1,FACE_3:2,FACE_4:3,LEFT_SHOULDER:4,RIGHT_SHOULDER:5,LEFT_TRIGGER:6,RIGHT_TRIGGER:7,SELECT:8,START:9,STICK_CLICK_1:10,STICK_CLICK_2:11,DIRECTION_UP:12,DIRECTION_DOWN:13,DIRECTION_LEFT:14,DIRECTION_RIGHT:15,HOME:16},sticks:{STICK_1_X:0,STICK_1_Y:1,STICK_2_X:2,STICK_2_Y:3}}},9075(e,t,s){const r=s(6260);e.exports={...r,name:"Pro Controller Extended Gamepad",deadzones:{STICK_1_X:.1,STICK_1_Y:.1,STICK_2_X:.1,STICK_2_Y:.1}}},1193(e,t,s){const r=s(6260);e.exports={...r,name:"Xbox Wireless Controller"}},1011(e,t,s){const{Buttons:r,Sticks:i}=s(9902),n=s(6636),o=s(6260),a={...o,name:"android-chromium"},h=s(9387),l=(e,t,s)=>Number.isFinite(e)?Math.max(t,Math.min(s,e)):0,c=(e,t)=>"string"==typeof e.name&&e.name.length>0&&t.includes(e.name);function d(e,t=[],s={}){if(!e)return null;const r=String(e.id||""),i=s.userAgent??("undefined"==typeof navigator?"":navigator.userAgent||""),h=""===e.mapping&&/\bAndroid\b/i.test(i)&&/\b(?:Chrome|Chromium)\//.test(i)&&4===e.axes?.length&&(16===e.buttons?.length||17===e.buttons?.length);return t.find(e=>c(e,r))||("standard"===e.mapping?o:null)||(h?a:null)||Object.values(n).find(e=>c(e,r))||null}function u(e,t=d(e),s={}){if(!e||!1===e.connected||!t)return null;const i={},n={};for(const s of new Set([...Object.values(r),...Object.keys(t.buttons||{})])){const r=e.buttons?.[t.buttons?.[s]],n=l("number"==typeof r?r:r?.value,0,1);i[s]={value:n,pressed:"boolean"==typeof r?.pressed?r.pressed:n>=.5}}for(const r of new Set([...Object.keys(o.sticks),...Object.keys(t.sticks||{})])){const i=l(e.axes?.[t.sticks?.[r]],-1,1),o=s.deadzone??t.deadzones?.[r]??.08;if(!Number.isFinite(o)||o<0||o>=1)throw new RangeError("Homepad deadzone must be between 0 (inclusive) and 1 (exclusive)");n[r]={value:Math.abs(i)<=o?0:Math.sign(i)*(Math.abs(i)-o)/(1-o)}}return{buttons:i,sticks:n}}e.exports={Homepad:class{constructor(e={}){this.options=e,this.error=null,this._read=e.getGamepads||(()=>"undefined"==typeof navigator||"function"!=typeof navigator.getGamepads?[]:navigator.getGamepads())}getGamepads(){let e;this.error=null;try{e=Array.from(this._read()||[])}catch(e){if("SecurityError"!==e.name)throw e;return this.error=e,[]}return e.filter(e=>e&&!1!==e.connected).flatMap(e=>{const t=d(e,this.options.mappings||[],this.options),s=u(e,t,this.options);return s?[{index:e.index,id:e.id,mapping:t,state:s}]:[]})}getGamepadState(e){return this.getGamepads().find(t=>t.index===e)?.state||null}},Buttons:r,mapGamepad:u,mapInputs:h}},9902(e){e.exports={Buttons:{DIRECTION_LEFT:"DIRECTION_LEFT",DIRECTION_RIGHT:"DIRECTION_RIGHT",DIRECTION_UP:"DIRECTION_UP",DIRECTION_DOWN:"DIRECTION_DOWN",LEFT_SHOULDER:"LEFT_SHOULDER",LEFT_TRIGGER:"LEFT_TRIGGER",RIGHT_SHOULDER:"RIGHT_SHOULDER",RIGHT_TRIGGER:"RIGHT_TRIGGER",FACE_1:"FACE_1",FACE_2:"FACE_2",FACE_3:"FACE_3",FACE_4:"FACE_4",START:"START",SELECT:"SELECT",STICK_CLICK_1:"STICK_CLICK_1",STICK_CLICK_2:"STICK_CLICK_2",HOME:"HOME"},Sticks:{STICK_1:"STICK_1",STICK_2:"STICK_2",STICK_1_X:"STICK_1_X",STICK_1_Y:"STICK_1_Y",STICK_2_X:"STICK_2_X",STICK_2_Y:"STICK_2_Y",STICK_1_LEFT:"STICK_1_LEFT",STICK_1_RIGHT:"STICK_1_RIGHT",STICK_1_UP:"STICK_1_UP",STICK_1_DOWN:"STICK_1_DOWN",STICK_2_LEFT:"STICK_2_LEFT",STICK_2_RIGHT:"STICK_2_RIGHT",STICK_2_UP:"STICK_2_UP",STICK_2_DOWN:"STICK_2_DOWN"}}},9387(e){e.exports=function(e,t,{threshold:s=.5}={}){if(!Number.isFinite(s)||s<=0||s>1)throw new RangeError("Input threshold must be greater than 0 and at most 1");const r=t=>{if("string"!=typeof t)throw new TypeError("Input bindings must be control names");const r=e?.buttons?.[t];if(r)return{value:r.value,pressed:r.pressed};const i=e?.sticks?.[t];if(i)return{value:i.value,pressed:Math.abs(i.value)>=s};const n=/^(STICK_[12])_(LEFT|RIGHT|UP|DOWN)$/.exec(t);if(n){const[,t,r]=n,i=t+("LEFT"===r||"RIGHT"===r?"_X":"_Y"),o="LEFT"===r||"UP"===r?-1:1,a=Math.max(0,(e?.sticks?.[i]?.value||0)*o);return{value:a,pressed:a>=s}}return{value:0,pressed:!1}};return Object.fromEntries(Object.entries(t).map(([e,t])=>{const s=(Array.isArray(t)?t:[t]).map(r);return[e,{value:s.reduce((e,t)=>Math.abs(t.value)>Math.abs(e.value)?t:e,{value:0}).value,pressed:s.some(e=>e.pressed)}]}))}},6636(e,t,s){const r=s(6866),i=s(1085),n=s(1193),o=s(7635),a=s(6593),h=s(9075),l=s(4255);e.exports={DUALSHOCK_4:r,STADIA:i,XBOX_ONE:n,LUNA:o,DUALSHOCK_5:a,SWITCH_PRO:h,NES_30:l}},251(e,t){t.read=function(e,t,s,r,i){var n,o,a=8*i-r-1,h=(1<<a)-1,l=h>>1,c=-7,d=s?i-1:0,u=s?-1:1,p=e[t+d];for(d+=u,n=p&(1<<-c)-1,p>>=-c,c+=a;c>0;n=256*n+e[t+d],d+=u,c-=8);for(o=n&(1<<-c)-1,n>>=-c,c+=r;c>0;o=256*o+e[t+d],d+=u,c-=8);if(0===n)n=1-l;else{if(n===h)return o?NaN:1/0*(p?-1:1);o+=Math.pow(2,r),n-=l}return(p?-1:1)*o*Math.pow(2,n-r)},t.write=function(e,t,s,r,i,n){var o,a,h,l=8*n-i-1,c=(1<<l)-1,d=c>>1,u=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:n-1,f=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=c):(o=Math.floor(Math.log(t)/Math.LN2),t*(h=Math.pow(2,-o))<1&&(o--,h*=2),(t+=o+d>=1?u/h:u*Math.pow(2,1-d))*h>=2&&(o++,h/=2),o+d>=c?(a=0,o=c):o+d>=1?(a=(t*h-1)*Math.pow(2,i),o+=d):(a=t*Math.pow(2,d-1)*Math.pow(2,i),o=0));i>=8;e[s+p]=255&a,p+=f,a/=256,i-=8);for(o=o<<i|a,l+=i;l>0;e[s+p]=255&o,p+=f,o/=256,l-=8);e[s+p-f]|=128*m}},3008(e,t){var s,r,i=function(){var e=function(e,t){var s=e,r=o[t],i=null,n=0,h=null,g=[],y={},w=function(e,t){i=function(e){for(var t=new Array(e),s=0;s<e;s+=1){t[s]=new Array(e);for(var r=0;r<e;r+=1)t[s][r]=null}return t}(n=4*s+17),x(0,0),x(n-7,0),x(0,n-7),E(),b(),k(e,t),s>=7&&S(e),null==h&&(h=C(s,r,g)),_(h,t)},x=function(e,t){for(var s=-1;s<=7;s+=1)if(!(e+s<=-1||n<=e+s))for(var r=-1;r<=7;r+=1)t+r<=-1||n<=t+r||(i[e+s][t+r]=0<=s&&s<=6&&(0==r||6==r)||0<=r&&r<=6&&(0==s||6==s)||2<=s&&s<=4&&2<=r&&r<=4)},b=function(){for(var e=8;e<n-8;e+=1)null==i[e][6]&&(i[e][6]=e%2==0);for(var t=8;t<n-8;t+=1)null==i[6][t]&&(i[6][t]=t%2==0)},E=function(){for(var e=a.getPatternPosition(s),t=0;t<e.length;t+=1)for(var r=0;r<e.length;r+=1){var n=e[t],o=e[r];if(null==i[n][o])for(var h=-2;h<=2;h+=1)for(var l=-2;l<=2;l+=1)i[n+h][o+l]=-2==h||2==h||-2==l||2==l||0==h&&0==l}},S=function(e){for(var t=a.getBCHTypeNumber(s),r=0;r<18;r+=1){var o=!e&&1==(t>>r&1);i[Math.floor(r/3)][r%3+n-8-3]=o}for(r=0;r<18;r+=1)o=!e&&1==(t>>r&1),i[r%3+n-8-3][Math.floor(r/3)]=o},k=function(e,t){for(var s=r<<3|t,o=a.getBCHTypeInfo(s),h=0;h<15;h+=1){var l=!e&&1==(o>>h&1);h<6?i[h][8]=l:h<8?i[h+1][8]=l:i[n-15+h][8]=l}for(h=0;h<15;h+=1)l=!e&&1==(o>>h&1),h<8?i[8][n-h-1]=l:h<9?i[8][15-h-1+1]=l:i[8][15-h-1]=l;i[n-8][8]=!e},_=function(e,t){for(var s=-1,r=n-1,o=7,h=0,l=a.getMaskFunction(t),c=n-1;c>0;c-=2)for(6==c&&(c-=1);;){for(var d=0;d<2;d+=1)if(null==i[r][c-d]){var u=!1;h<e.length&&(u=1==(e[h]>>>o&1)),l(r,c-d)&&(u=!u),i[r][c-d]=u,-1==(o-=1)&&(h+=1,o=7)}if((r+=s)<0||n<=r){r-=s,s=-s;break}}},C=function(e,t,s){for(var r=c.getRSBlocks(e,t),i=d(),n=0;n<s.length;n+=1){var o=s[n];i.put(o.getMode(),4),i.put(o.getLength(),a.getLengthInBits(o.getMode(),e)),o.write(i)}var h=0;for(n=0;n<r.length;n+=1)h+=r[n].dataCount;if(i.getLengthInBits()>8*h)throw"code length overflow. ("+i.getLengthInBits()+">"+8*h+")";for(i.getLengthInBits()+4<=8*h&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(!1);for(;!(i.getLengthInBits()>=8*h||(i.put(236,8),i.getLengthInBits()>=8*h));)i.put(17,8);return function(e,t){for(var s=0,r=0,i=0,n=new Array(t.length),o=new Array(t.length),h=0;h<t.length;h+=1){var c=t[h].dataCount,d=t[h].totalCount-c;r=Math.max(r,c),i=Math.max(i,d),n[h]=new Array(c);for(var u=0;u<n[h].length;u+=1)n[h][u]=255&e.getBuffer()[u+s];s+=c;var p=a.getErrorCorrectPolynomial(d),f=l(n[h],p.getLength()-1).mod(p);for(o[h]=new Array(p.getLength()-1),u=0;u<o[h].length;u+=1){var m=u+f.getLength()-o[h].length;o[h][u]=m>=0?f.getAt(m):0}}var g=0;for(u=0;u<t.length;u+=1)g+=t[u].totalCount;var y=new Array(g),v=0;for(u=0;u<r;u+=1)for(h=0;h<t.length;h+=1)u<n[h].length&&(y[v]=n[h][u],v+=1);for(u=0;u<i;u+=1)for(h=0;h<t.length;h+=1)u<o[h].length&&(y[v]=o[h][u],v+=1);return y}(i,r)};y.addData=function(e,t){var s=null;switch(t=t||"Byte"){case"Numeric":s=u(e);break;case"Alphanumeric":s=p(e);break;case"Byte":s=f(e);break;case"Kanji":s=m(e);break;default:throw"mode:"+t}g.push(s),h=null},y.isDark=function(e,t){if(e<0||n<=e||t<0||n<=t)throw e+","+t;return i[e][t]},y.getModuleCount=function(){return n},y.make=function(){if(s<1){for(var e=1;e<40;e++){for(var t=c.getRSBlocks(e,r),i=d(),n=0;n<g.length;n++){var o=g[n];i.put(o.getMode(),4),i.put(o.getLength(),a.getLengthInBits(o.getMode(),e)),o.write(i)}var h=0;for(n=0;n<t.length;n++)h+=t[n].dataCount;if(i.getLengthInBits()<=8*h)break}s=e}w(!1,function(){for(var e=0,t=0,s=0;s<8;s+=1){w(!0,s);var r=a.getLostPoint(y);(0==s||e>r)&&(e=r,t=s)}return t}())},y.createTableTag=function(e,t){e=e||2;var s="";s+='<table style="',s+=" border-width: 0px; border-style: none;",s+=" border-collapse: collapse;",s+=" padding: 0px; margin: "+(t=void 0===t?4*e:t)+"px;",s+='">',s+="<tbody>";for(var r=0;r<y.getModuleCount();r+=1){s+="<tr>";for(var i=0;i<y.getModuleCount();i+=1)s+='<td style="',s+=" border-width: 0px; border-style: none;",s+=" border-collapse: collapse;",s+=" padding: 0px; margin: 0px;",s+=" width: "+e+"px;",s+=" height: "+e+"px;",s+=" background-color: ",s+=y.isDark(r,i)?"#000000":"#ffffff",s+=";",s+='"/>';s+="</tr>"}return(s+="</tbody>")+"</table>"},y.createSvgTag=function(e,t,s,r){var i={};"object"==typeof arguments[0]&&(e=(i=arguments[0]).cellSize,t=i.margin,s=i.alt,r=i.title),e=e||2,t=void 0===t?4*e:t,(s="string"==typeof s?{text:s}:s||{}).text=s.text||null,s.id=s.text?s.id||"qrcode-description":null,(r="string"==typeof r?{text:r}:r||{}).text=r.text||null,r.id=r.text?r.id||"qrcode-title":null;var n,o,a,h,l=y.getModuleCount()*e+2*t,c="";for(h="l"+e+",0 0,"+e+" -"+e+",0 0,-"+e+"z ",c+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',c+=i.scalable?"":' width="'+l+'px" height="'+l+'px"',c+=' viewBox="0 0 '+l+" "+l+'" ',c+=' preserveAspectRatio="xMinYMin meet"',c+=r.text||s.text?' role="img" aria-labelledby="'+A([r.id,s.id].join(" ").trim())+'"':"",c+=">",c+=r.text?'<title id="'+A(r.id)+'">'+A(r.text)+"</title>":"",c+=s.text?'<description id="'+A(s.id)+'">'+A(s.text)+"</description>":"",c+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',c+='<path d="',o=0;o<y.getModuleCount();o+=1)for(a=o*e+t,n=0;n<y.getModuleCount();n+=1)y.isDark(o,n)&&(c+="M"+(n*e+t)+","+a+h);return(c+='" stroke="transparent" fill="black"/>')+"</svg>"},y.createDataURL=function(e,t){e=e||2,t=void 0===t?4*e:t;var s=y.getModuleCount()*e+2*t,r=t,i=s-t;return v(s,s,function(t,s){if(r<=t&&t<i&&r<=s&&s<i){var n=Math.floor((t-r)/e),o=Math.floor((s-r)/e);return y.isDark(o,n)?0:1}return 1})},y.createImgTag=function(e,t,s){e=e||2,t=void 0===t?4*e:t;var r=y.getModuleCount()*e+2*t,i="";return i+="<img",i+=' src="',i+=y.createDataURL(e,t),i+='"',i+=' width="',i+=r,i+='"',i+=' height="',i+=r,i+='"',s&&(i+=' alt="',i+=A(s),i+='"'),i+"/>"};var A=function(e){for(var t="",s=0;s<e.length;s+=1){var r=e.charAt(s);switch(r){case"<":t+="&lt;";break;case">":t+="&gt;";break;case"&":t+="&amp;";break;case'"':t+="&quot;";break;default:t+=r}}return t};return y.createASCII=function(e,t){if((e=e||1)<2)return function(e){e=void 0===e?2:e;var t,s,r,i,n,o=1*y.getModuleCount()+2*e,a=e,h=o-e,l={"██":"█","█ ":"▀"," █":"▄"," ":" "},c={"██":"▀","█ ":"▀"," █":" "," ":" "},d="";for(t=0;t<o;t+=2){for(r=Math.floor((t-a)/1),i=Math.floor((t+1-a)/1),s=0;s<o;s+=1)n="█",a<=s&&s<h&&a<=t&&t<h&&y.isDark(r,Math.floor((s-a)/1))&&(n=" "),a<=s&&s<h&&a<=t+1&&t+1<h&&y.isDark(i,Math.floor((s-a)/1))?n+=" ":n+="█",d+=e<1&&t+1>=h?c[n]:l[n];d+="\n"}return o%2&&e>0?d.substring(0,d.length-o-1)+Array(o+1).join("▀"):d.substring(0,d.length-1)}(t);e-=1,t=void 0===t?2*e:t;var s,r,i,n,o=y.getModuleCount()*e+2*t,a=t,h=o-t,l=Array(e+1).join("██"),c=Array(e+1).join(" "),d="",u="";for(s=0;s<o;s+=1){for(i=Math.floor((s-a)/e),u="",r=0;r<o;r+=1)n=1,a<=r&&r<h&&a<=s&&s<h&&y.isDark(i,Math.floor((r-a)/e))&&(n=0),u+=n?l:c;for(i=0;i<e;i+=1)d+=u+"\n"}return d.substring(0,d.length-1)},y.renderTo2dContext=function(e,t){t=t||2;for(var s=y.getModuleCount(),r=0;r<s;r++)for(var i=0;i<s;i++)e.fillStyle=y.isDark(r,i)?"black":"white",e.fillRect(i*t,r*t,t,t)},y};e.stringToBytes=(e.stringToBytesFuncs={default:function(e){for(var t=[],s=0;s<e.length;s+=1){var r=e.charCodeAt(s);t.push(255&r)}return t}}).default,e.createStringToBytes=function(e,t){var s=function(){for(var s=y(e),r=function(){var e=s.read();if(-1==e)throw"eof";return e},i=0,n={};;){var o=s.read();if(-1==o)break;var a=r(),h=r()<<8|r();n[String.fromCharCode(o<<8|a)]=h,i+=1}if(i!=t)throw i+" != "+t;return n}(),r="?".charCodeAt(0);return function(e){for(var t=[],i=0;i<e.length;i+=1){var n=e.charCodeAt(i);if(n<128)t.push(n);else{var o=s[e.charAt(i)];"number"==typeof o?(255&o)==o?t.push(o):(t.push(o>>>8),t.push(255&o)):t.push(r)}}return t}};var t,s,r,i,n,o={L:1,M:0,Q:3,H:2},a=(t=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],s=1335,r=7973,n=function(e){for(var t=0;0!=e;)t+=1,e>>>=1;return t},(i={}).getBCHTypeInfo=function(e){for(var t=e<<10;n(t)-n(s)>=0;)t^=s<<n(t)-n(s);return 21522^(e<<10|t)},i.getBCHTypeNumber=function(e){for(var t=e<<12;n(t)-n(r)>=0;)t^=r<<n(t)-n(r);return e<<12|t},i.getPatternPosition=function(e){return t[e-1]},i.getMaskFunction=function(e){switch(e){case 0:return function(e,t){return(e+t)%2==0};case 1:return function(e,t){return e%2==0};case 2:return function(e,t){return t%3==0};case 3:return function(e,t){return(e+t)%3==0};case 4:return function(e,t){return(Math.floor(e/2)+Math.floor(t/3))%2==0};case 5:return function(e,t){return e*t%2+e*t%3==0};case 6:return function(e,t){return(e*t%2+e*t%3)%2==0};case 7:return function(e,t){return(e*t%3+(e+t)%2)%2==0};default:throw"bad maskPattern:"+e}},i.getErrorCorrectPolynomial=function(e){for(var t=l([1],0),s=0;s<e;s+=1)t=t.multiply(l([1,h.gexp(s)],0));return t},i.getLengthInBits=function(e,t){if(1<=t&&t<10)switch(e){case 1:return 10;case 2:return 9;case 4:case 8:return 8;default:throw"mode:"+e}else if(t<27)switch(e){case 1:return 12;case 2:return 11;case 4:return 16;case 8:return 10;default:throw"mode:"+e}else{if(!(t<41))throw"type:"+t;switch(e){case 1:return 14;case 2:return 13;case 4:return 16;case 8:return 12;default:throw"mode:"+e}}},i.getLostPoint=function(e){for(var t=e.getModuleCount(),s=0,r=0;r<t;r+=1)for(var i=0;i<t;i+=1){for(var n=0,o=e.isDark(r,i),a=-1;a<=1;a+=1)if(!(r+a<0||t<=r+a))for(var h=-1;h<=1;h+=1)i+h<0||t<=i+h||0==a&&0==h||o==e.isDark(r+a,i+h)&&(n+=1);n>5&&(s+=3+n-5)}for(r=0;r<t-1;r+=1)for(i=0;i<t-1;i+=1){var l=0;e.isDark(r,i)&&(l+=1),e.isDark(r+1,i)&&(l+=1),e.isDark(r,i+1)&&(l+=1),e.isDark(r+1,i+1)&&(l+=1),0!=l&&4!=l||(s+=3)}for(r=0;r<t;r+=1)for(i=0;i<t-6;i+=1)e.isDark(r,i)&&!e.isDark(r,i+1)&&e.isDark(r,i+2)&&e.isDark(r,i+3)&&e.isDark(r,i+4)&&!e.isDark(r,i+5)&&e.isDark(r,i+6)&&(s+=40);for(i=0;i<t;i+=1)for(r=0;r<t-6;r+=1)e.isDark(r,i)&&!e.isDark(r+1,i)&&e.isDark(r+2,i)&&e.isDark(r+3,i)&&e.isDark(r+4,i)&&!e.isDark(r+5,i)&&e.isDark(r+6,i)&&(s+=40);var c=0;for(i=0;i<t;i+=1)for(r=0;r<t;r+=1)e.isDark(r,i)&&(c+=1);return s+Math.abs(100*c/t/t-50)/5*10},i),h=function(){for(var e=new Array(256),t=new Array(256),s=0;s<8;s+=1)e[s]=1<<s;for(s=8;s<256;s+=1)e[s]=e[s-4]^e[s-5]^e[s-6]^e[s-8];for(s=0;s<255;s+=1)t[e[s]]=s;return{glog:function(e){if(e<1)throw"glog("+e+")";return t[e]},gexp:function(t){for(;t<0;)t+=255;for(;t>=256;)t-=255;return e[t]}}}();function l(e,t){if(void 0===e.length)throw e.length+"/"+t;var s=function(){for(var s=0;s<e.length&&0==e[s];)s+=1;for(var r=new Array(e.length-s+t),i=0;i<e.length-s;i+=1)r[i]=e[i+s];return r}(),r={getAt:function(e){return s[e]},getLength:function(){return s.length},multiply:function(e){for(var t=new Array(r.getLength()+e.getLength()-1),s=0;s<r.getLength();s+=1)for(var i=0;i<e.getLength();i+=1)t[s+i]^=h.gexp(h.glog(r.getAt(s))+h.glog(e.getAt(i)));return l(t,0)},mod:function(e){if(r.getLength()-e.getLength()<0)return r;for(var t=h.glog(r.getAt(0))-h.glog(e.getAt(0)),s=new Array(r.getLength()),i=0;i<r.getLength();i+=1)s[i]=r.getAt(i);for(i=0;i<e.getLength();i+=1)s[i]^=h.gexp(h.glog(e.getAt(i))+t);return l(s,0).mod(e)}};return r}var c=function(){var e=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],t=function(e,t){var s={};return s.totalCount=e,s.dataCount=t,s},s={getRSBlocks:function(s,r){var i=function(t,s){switch(s){case o.L:return e[4*(t-1)+0];case o.M:return e[4*(t-1)+1];case o.Q:return e[4*(t-1)+2];case o.H:return e[4*(t-1)+3];default:return}}(s,r);if(void 0===i)throw"bad rs block @ typeNumber:"+s+"/errorCorrectionLevel:"+r;for(var n=i.length/3,a=[],h=0;h<n;h+=1)for(var l=i[3*h+0],c=i[3*h+1],d=i[3*h+2],u=0;u<l;u+=1)a.push(t(c,d));return a}};return s}(),d=function(){var e=[],t=0,s={getBuffer:function(){return e},getAt:function(t){var s=Math.floor(t/8);return 1==(e[s]>>>7-t%8&1)},put:function(e,t){for(var r=0;r<t;r+=1)s.putBit(1==(e>>>t-r-1&1))},getLengthInBits:function(){return t},putBit:function(s){var r=Math.floor(t/8);e.length<=r&&e.push(0),s&&(e[r]|=128>>>t%8),t+=1}};return s},u=function(e){var t=e,s={getMode:function(){return 1},getLength:function(e){return t.length},write:function(e){for(var s=t,i=0;i+2<s.length;)e.put(r(s.substring(i,i+3)),10),i+=3;i<s.length&&(s.length-i==1?e.put(r(s.substring(i,i+1)),4):s.length-i==2&&e.put(r(s.substring(i,i+2)),7))}},r=function(e){for(var t=0,s=0;s<e.length;s+=1)t=10*t+i(e.charAt(s));return t},i=function(e){if("0"<=e&&e<="9")return e.charCodeAt(0)-"0".charCodeAt(0);throw"illegal char :"+e};return s},p=function(e){var t=e,s={getMode:function(){return 2},getLength:function(e){return t.length},write:function(e){for(var s=t,i=0;i+1<s.length;)e.put(45*r(s.charAt(i))+r(s.charAt(i+1)),11),i+=2;i<s.length&&e.put(r(s.charAt(i)),6)}},r=function(e){if("0"<=e&&e<="9")return e.charCodeAt(0)-"0".charCodeAt(0);if("A"<=e&&e<="Z")return e.charCodeAt(0)-"A".charCodeAt(0)+10;switch(e){case" ":return 36;case"$":return 37;case"%":return 38;case"*":return 39;case"+":return 40;case"-":return 41;case".":return 42;case"/":return 43;case":":return 44;default:throw"illegal char :"+e}};return s},f=function(t){var s=e.stringToBytes(t);return{getMode:function(){return 4},getLength:function(e){return s.length},write:function(e){for(var t=0;t<s.length;t+=1)e.put(s[t],8)}}},m=function(t){var s=e.stringToBytesFuncs.SJIS;if(!s)throw"sjis not supported.";!function(){var e=s("友");if(2!=e.length||38726!=(e[0]<<8|e[1]))throw"sjis not supported."}();var r=s(t),i={getMode:function(){return 8},getLength:function(e){return~~(r.length/2)},write:function(e){for(var t=r,s=0;s+1<t.length;){var i=(255&t[s])<<8|255&t[s+1];if(33088<=i&&i<=40956)i-=33088;else{if(!(57408<=i&&i<=60351))throw"illegal char at "+(s+1)+"/"+i;i-=49472}i=192*(i>>>8&255)+(255&i),e.put(i,13),s+=2}if(s<t.length)throw"illegal char at "+(s+1)}};return i},g=function(){var e=[],t={writeByte:function(t){e.push(255&t)},writeShort:function(e){t.writeByte(e),t.writeByte(e>>>8)},writeBytes:function(e,s,r){s=s||0,r=r||e.length;for(var i=0;i<r;i+=1)t.writeByte(e[i+s])},writeString:function(e){for(var s=0;s<e.length;s+=1)t.writeByte(e.charCodeAt(s))},toByteArray:function(){return e},toString:function(){var t="";t+="[";for(var s=0;s<e.length;s+=1)s>0&&(t+=","),t+=e[s];return t+"]"}};return t},y=function(e){var t=e,s=0,r=0,i=0,n={read:function(){for(;i<8;){if(s>=t.length){if(0==i)return-1;throw"unexpected end of file./"+i}var e=t.charAt(s);if(s+=1,"="==e)return i=0,-1;e.match(/^\s$/)||(r=r<<6|o(e.charCodeAt(0)),i+=6)}var n=r>>>i-8&255;return i-=8,n}},o=function(e){if(65<=e&&e<=90)return e-65;if(97<=e&&e<=122)return e-97+26;if(48<=e&&e<=57)return e-48+52;if(43==e)return 62;if(47==e)return 63;throw"c:"+e};return n},v=function(e,t,s){for(var r=function(e,t){var s=e,r=t,i=new Array(e*t),n={setPixel:function(e,t,r){i[t*s+e]=r},write:function(e){e.writeString("GIF87a"),e.writeShort(s),e.writeShort(r),e.writeByte(128),e.writeByte(0),e.writeByte(0),e.writeByte(0),e.writeByte(0),e.writeByte(0),e.writeByte(255),e.writeByte(255),e.writeByte(255),e.writeString(","),e.writeShort(0),e.writeShort(0),e.writeShort(s),e.writeShort(r),e.writeByte(0);var t=o(2);e.writeByte(2);for(var i=0;t.length-i>255;)e.writeByte(255),e.writeBytes(t,i,255),i+=255;e.writeByte(t.length-i),e.writeBytes(t,i,t.length-i),e.writeByte(0),e.writeString(";")}},o=function(e){for(var t=1<<e,s=1+(1<<e),r=e+1,n=a(),o=0;o<t;o+=1)n.add(String.fromCharCode(o));n.add(String.fromCharCode(t)),n.add(String.fromCharCode(s));var h,l,c,d=g(),u=(h=d,l=0,c=0,{write:function(e,t){if(e>>>t!=0)throw"length over";for(;l+t>=8;)h.writeByte(255&(e<<l|c)),t-=8-l,e>>>=8-l,c=0,l=0;c|=e<<l,l+=t},flush:function(){l>0&&h.writeByte(c)}});u.write(t,r);var p=0,f=String.fromCharCode(i[p]);for(p+=1;p<i.length;){var m=String.fromCharCode(i[p]);p+=1,n.contains(f+m)?f+=m:(u.write(n.indexOf(f),r),n.size()<4095&&(n.size()==1<<r&&(r+=1),n.add(f+m)),f=m)}return u.write(n.indexOf(f),r),u.write(s,r),u.flush(),d.toByteArray()},a=function(){var e={},t=0,s={add:function(r){if(s.contains(r))throw"dup key:"+r;e[r]=t,t+=1},size:function(){return t},indexOf:function(t){return e[t]},contains:function(t){return void 0!==e[t]}};return s};return n}(e,t),i=0;i<t;i+=1)for(var n=0;n<e;n+=1)r.setPixel(n,i,s(n,i));var o=g();r.write(o);for(var a=function(){var e=0,t=0,s=0,r="",i={},n=function(e){r+=String.fromCharCode(o(63&e))},o=function(e){if(e<0);else{if(e<26)return 65+e;if(e<52)return e-26+97;if(e<62)return e-52+48;if(62==e)return 43;if(63==e)return 47}throw"n:"+e};return i.writeByte=function(r){for(e=e<<8|255&r,t+=8,s+=1;t>=6;)n(e>>>t-6),t-=6},i.flush=function(){if(t>0&&(n(e<<6-t),e=0,t=0),s%3!=0)for(var i=3-s%3,o=0;o<i;o+=1)r+="="},i.toString=function(){return r},i}(),h=o.toByteArray(),l=0;l<h.length;l+=1)a.writeByte(h[l]);return a.flush(),"data:image/gif;base64,"+a};return e}();i.stringToBytesFuncs["UTF-8"]=function(e){return function(e){for(var t=[],s=0;s<e.length;s++){var r=e.charCodeAt(s);r<128?t.push(r):r<2048?t.push(192|r>>6,128|63&r):r<55296||r>=57344?t.push(224|r>>12,128|r>>6&63,128|63&r):(s++,r=65536+((1023&r)<<10|1023&e.charCodeAt(s)),t.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|63&r))}return t}(e)},void 0===(r="function"==typeof(s=function(){return i})?s.apply(t,[]):s)||(e.exports=r)},5911(e,t,s){const{squish:r,unsquish:i}=s(8681),{gameNode:n,GameNode:o}=s(5198),a=(s(4063),s(7460)),h=s(1238),l=s(2435),c=s(8922),d=s(4857),u=s(2341),{terrainGenerator:p}=s(5256),f=s(7831),m=s(6682),g=s(402),y=s(2403),v=s(5331);e.exports={squish:r,unsquish:i,gameNode:n,subtypes:f,Game:h,ViewableGame:l,GameNode:o,Colors:a,Shapes:c,Squisher:m,ShapeUtils:d,ViewUtils:u,TerrainGenerator:p,GeometryUtils:y,Asset:g,Physics:v}},402(e){e.exports=class{constructor(e,t=null){this.info={...e},null!==t&&(this.data=new Uint8Array(t))}getData(){return this.data instanceof Uint8Array?Promise.resolve(this.data.slice()):Promise.reject(new Error("The host has not supplied bytes for this asset"))}}},1785(e,t,s){const r=s(4063),i=(e,t,s,i,n,o,a,h,l,c,d,u,p,f,m,g)=>new r(e,t,s,i,n,o,a,h,l,c,d,u,p,f,m,g);e.exports={gameNode:i,BaseNode:class{constructor({color:e,onClick:t,coordinates2d:s,border:r,fill:n,textInfo:o,assetInfo:a,playerIds:h,effects:l,input:c,subtype:d,node:u,id:p,onHover:f,offHover:m,onDrag:g,offClick:y}){this.node=u||i(e,t,s,r,n,o,a,h,l,c,d,p,f,m,g,y),this.id=this.node.id}showFor(e){const t=this.node.playerIds.indexOf(e),s=this.node.playerIds.indexOf(0);if(s>=0){const e=this.node.playerIds;e.splice(s,1),this.node.playerIds=e}if(t<0){const t=this.node.playerIds;t.push(e),this.node.playerIds=t}}hideFor(e){const t=this.node.playerIds.indexOf(e);if(t>=0){let e=this.node.playerIds;e.splice(t,1),0==e.length&&(e=[0]),this.node.playerIds=e}}addChild(e,t=!0){this.node.addChild(e),t&&this.node.onStateChange()}addChildren(...e){for(let t=0;t<e.length;t++)this.addChild(e[t],!1);this.node.onStateChange()}getChildren(){return this.node.children}removeChild(e,t=!0){this.node.removeChild(e),t&&this.node.onStateChange()}addListener(e){this.node.addListener(e)}findChild(e){return this.findChildHelper(e,this)}findChildHelper(e,t,s=null){t.node.id===e&&(s=t);for(const r in t.node.children){if(s)return s;s=this.findChildHelper(e,t.node.children[r],s)}return s}clearChildren(e){this.node.clearChildren(e),this.node.onStateChange()}update(e={}){e&&(e.fill&&(this.node.fill=e.fill),e.coordinates2d&&(this.node.coordinates2d=e.coordinates2d)),this.node.onStateChange()}clone(){throw new Error("Clone not implemented")}}}},7460(e){const t={ALMOST_BLACK:[16,16,16,255],ALMOST_WHITE:[238,238,238,255],ANTIQUE_WHITE:[250,235,215,255],AQUA:[188,212,230,255],AQUAMARINE:[127,255,212,255],BEIGE:[245,245,220,255],BIG_GRAY:[221,221,221,255],BLACK:[0,0,0,255],BLAY:[87,102,117,255],BLUE:[0,0,255,255],BLUE_WHISPER:[240,248,255,255],BLEEN:[19,51,55,255],BLOOD:[153,0,0,255],BOOGER:[186,218,85,255],BRIGHT_GRAY:[198,226,255,255],BRONZE:[227,151,17,255],BROWN:[145,97,11,255],CANDY_GREEN:[90,193,142,255],CANDY_PINK:[255,115,115,255],CANDY_RED:[246,84,106,255],CHARCOAL:[51,51,51,255],CALM_BLUE:[8,141,165,255],COOL_BLUE:[64,114,148,255],COOL_GREEN:[180,238,180,255],CORAL:[255,127,80,255],CORPORATE_BEIGE:[203,203,169,255],CREAM:[240,224,136,255],CREAMSICLE:[255,195,160,255],CYAN:[0,255,255,255],DARK_TURQUOISE:[0,206,209,255],DEEP_BLUE:[0,51,102,255],DEEP_PURPLE:[102,0,102,255],DEEP_RED:[139,0,0,255],DIM_GRAY:[105,105,105,255],DULL_BLUE:[192,214,228,255],EMERALD:[39,89,45,255],EVERGREEN:[6,85,53,255],FRIENDLY_BLUE:[70,132,153,255],FUCHSIA:[255,0,255,255],FUNNY_PURPLE:[128,0,128,255],GOLD:[255,215,0,255],GOLDMEMBER:[218,165,32,255],GRAY:[192,192,192,255],GREEN:[0,255,0,255],GUN_METAL_GRAY:[102,102,102,255],HARD_ORANGE_RED:[255,64,64,255],HARD_PINK:[247,52,122,255],HG_BLACK:[26,26,26,255],HG_BLUE:[148,210,230,255],HG_RED:[241,112,112,255],HG_YELLOW:[255,247,143,255],INTERIOR_RED:[255,102,102,255],INVITATION_BLUE:[104,151,187,255],KHAKI:[255,246,143,255],LAVENDER:[230,230,250,255],LIGHT_CORAL:[240,128,128,255],LIGHT_SEA_GREEN:[32,178,170,255],NAVY:[0,0,128,255],MAGENTA:[255,0,255,255],MAROON:[128,0,0,255],MEAN_SEA:[129,216,208,255],MERLOT:[66,4,32,255],MINT:[102,205,170,255],MUSTARD:[232,219,32,255],NEON_BOOGER:[204,255,0,255],NEON_PINK:[255,128,237,255],ORANGE:[255,165,0,255],ORANGE_RED:[255,69,0,255],PALE_TURQUOISE:[175,238,238,255],PEACH:[255,218,185,255],PERFUME_PINK:[255,228,225,255],PERRYWINKLE:[204,204,255,255],PINK:[255,192,203,255],POWDER_BLUE:[176,224,230,255],PURPLE:[128,0,128,255],REAL_ESTATE_BLUE:[14,47,68,255],RED:[255,0,0,255],RUST:[128,0,0,255],SALMON:[250,128,114,255],SEA_GREEN:[0,128,128,255],SHARP_YELLOW:[255,255,102,255],SILVER:[192,192,192,255],SIMPLE_GRAY:[204,204,204,255],SLEEPY_PINK:[255,182,193,255],SMOKE:[245,245,245,255],SMOOTH_BLUE:[76,163,221,255],SOFT_GREEN:[211,255,206,255],SOFT_MINT:[182,252,213,255],SOFT_PINK:[255,192,203,255],STRESSED_PURPLE:[138,43,226,255],SKY_BLUE:[127,229,240,255],STANDARD_GRAY:[128,128,128,255],STORM_GRAY:[105,105,102,255],SUCCESS_GREEN:[0,128,0,255],TEAL:[0,128,128,255],TENSE_SKY:[102,204,204,255],TERRACOTTA:[226,114,91,255],THICK_LUXURY:[195,151,151,255],TURQUOISE:[64,224,208,255],WALLPAPER_BEIGE:[203,190,181,255],WALLPAPER_GREEN:[220,237,193,255],WHITE:[255,255,255,255],YELLOW:[255,255,0,255]},s=Object.keys(t);e.exports={COLORS:t,randomColor:function(e=[]){const r=e.length?((e,t)=>e.length===t.length?["WHITE"]:e.filter(e=>{for(const s of t)if(e===s)return!1;return!0}))(s,e):s,i=Math.floor(Math.random()*r.length);return t[r[i]]}}},1238(e){e.exports=class{constructor(){this.listeners=new Set,this.intervals=[],this.timeouts=[],this.playerInfoMap={}}addStateListener(e){this.listeners.add(e)}removeStateListener(e){this.listeners.delete(e)}findNode(e){let t=null;if(this.getLayers){const s=this.getLayers();for(let r in s)if(t=s[r].root.findChild(e),t)break}return t}setInterval(e,t){const s=setInterval(e,t);return this.intervals.push(s),s}setTimeout(e,t){const s=setTimeout(e,t);return this.timeouts.push(s),s}close(){for(const e in this.timeouts){const t=this.timeouts[e];clearTimeout(t)}for(const e in this.intervals){const t=this.intervals[e];clearInterval(t)}}}},5198(e,t,s){const r=s(8922),i=s(7831),{gameNode:n,BaseNode:o}=s(1785),a={[r.CIRCLE]:i.SHAPE_2D_CIRCLE,[r.POLYGON]:i.SHAPE_2D_POLYGON,[r.LINE]:i.SHAPE_2D_LINE},h={[i.SHAPE_2D_CIRCLE]:r.CIRCLE,[i.SHAPE_2D_POLYGON]:r.POLYGON,[i.SHAPE_2D_LINE]:r.LINE};class l extends o{constructor({color:e,onClick:t,shapeType:s,coordinates2d:r,border:i,fill:n,playerIds:o,effects:h,input:l,node:c,id:d,onHover:u,offHover:p,onDrag:f,offClick:m}){if(!(r&&s||c))throw new Error("Shape requires coordinates2d and shapeType");super({color:e,onClick:t,coordinates2d:r,border:i,fill:n,playerIds:o,effects:h,input:l,node:c,subtype:a[s],id:d,onHover:u,offHover:p,onDrag:f,offClick:m})}clone({handleClick:e,input:t,id:s}){const r=Number(s)||null;return new l({color:this.node.color,onClick:e,shapeType:h[this.node.subType],coordinates2d:this.node.coordinates2d,border:this.node.border,fill:this.node.fill,playerIds:this.node.playerIds,effects:this.node.effects,input:t,id:r})}}class c extends o{constructor({textInfo:e,playerIds:t,input:s,node:r,id:n,onClick:o,onHover:a,offHover:h,onDrag:l,offClick:c}){if(!e&&!r)throw new Error("Text node requires textInfo");super({textInfo:e,playerIds:t,input:s,node:r,subtype:i.TEXT,id:n,onClick:o,onHover:a,offHover:h,onDrag:l,offClick:c})}clone({handleClick:e,input:t,id:s}){const r=s||null;return new c({textInfo:Object.assign({},this.node.text),playerIds:this.playerIds?.slice(),id:r})}}class d extends o{constructor({assetInfo:e,onClick:t,coordinates2d:s,playerIds:r,effects:n,node:o,id:a,onHover:h,offHover:l,onDrag:c,offClick:d}){if(!e&&!o)throw new Error("Asset node requires assetInfo");super({assetInfo:e,onClick:t,coordinates2d:s,playerIds:r,effects:n,node:o,subtype:i.ASSET,id:a,onHover:h,offHover:l,onDrag:c,offClick:d})}clone({handleClick:e,input:t,id:s}){const r=s||null;return new d({assetInfo:Object.assign({},this.node.asset),playerIds:this.playerIds?.slice(),id:r})}}const u={Stream:class extends o{constructor({streamId:e,pos:t={x:0,y:0},size:s={x:0,y:0},audio:r=!0,node:n,...o}){if(!n&&!/^[A-Za-z0-9-]{1,64}$/.test(e||""))throw new Error("Stream requires a valid streamId");super({...o,node:n,subtype:i.STREAM}),n||(this.node.stream={id:e,pos:t,size:s,audio:!!r})}},Asset:d,Shape:l,Text:c};e.exports={gameNode:n,GameNode:u}},4063(e){e.exports=class{constructor(e,t,s,r,i,n,o,a=[],h=null,l=null,c=null,d=null,u,p,f,m){this.id=d?Number(d):Math.floor(999999999*Math.random()),this.children=new Array,this.color=e,this.handleClick=t,this.coordinates2d=s,this.border=r,this.fill=i,this.text=n,this.asset=o,this.effects=h,this.input=l,this.listeners=new Set,!a||a instanceof Array||(a=[a]),this.playerIds=a||[],this.subType=c,this.onHover=u,this.offHover=p,this.onDrag=f,this.offClick=m}addChild(e){this.children.push(e)}addChildren(...e){for(let t=0;t<e.length;t++)this.addChild(e[t])}removeChild(e){const t=this.children.findIndex(t=>t.node.id==e);t>=0&&(this._animation&&clearInterval(this._animation),this.children.splice(t,1))}addListener(e){this.listeners.add(e)}onStateChange(){for(const e of this.listeners)e.handleStateChange(this)}clearChildren(e){if(e){const t=this.children.filter(t=>e.includes(t.id));this.children=t}else this.children=new Array}}},8922(e){e.exports={CIRCLE:1,POLYGON:2,LINE:3}},6682(e,t,s){const{squish:r,unsquish:i}=s(8681);e.exports=class{constructor({game:e,scale:t,customBottomLayer:s,customTopLayer:n,onAssetUpdate:o,encodeNode:a=r,decodeNode:h=i,autoTick:l=!0,loadAssets:c=!0,assetLoader:d}){if(this.encodeNode=a,this.decodeNode=h,this.loadAssets=c,this.assetLoader=d,this.observedNodes=new Set,this.closed=!1,this.ids=new Set,this.game=e,this.gameMetadata=e.constructor.metadata&&e.constructor.metadata(),this._assetBufferCache=Object.create(null),this.playerSettings={},this.customBottomLayer=s,this.customTopLayer=n,this.initialize(),this.onAssetUpdate=o,this.playerFrames={},this.listeners=new Set,this._dirty=!1,this._flushScheduled=!1,this.scale=t||{x:1,y:1},this.state=this.squish(this.game.getLayers()),l&&this.game.tick){const e=this.gameMetadata&&this.gameMetadata.tickRate?this.gameMetadata.tickRate:60;this._tickInterval=setInterval(this.game.tick.bind(this.game),1e3/e)}}addListener(e){const t={onEvent:e,remove:()=>this.removeListener(t)};this.listeners.add(t)}removeListener(e){this.listeners.delete(e)}unsquish(e){return this.decodeNode(e)}squish(e,t=null){this.records=[];const s=new Set,r=(e,t,i)=>{if(!e?.node)return;this.observedNodes.has(e)||(e.addListener(this),this.observedNodes.add(e)),s.add(e);const n=e.node.playerIds,o=n?.length?[...i,n.map(Number)]:i;this.records.push({root:e,scopes:o,bytes:this.encodeNode(e,t)});for(const s of e.node.children||[])r(s,t,o)};this.customBottomLayer&&r(this.customBottomLayer.root,this.customBottomLayer.scale||{x:1,y:1},[]);for(const s in e||[])r(e[s].root,e[s].scale||t||this.scale||{x:1,y:1},[]);this.customTopLayer&&r(this.customTopLayer.root,this.customTopLayer.scale||{x:1,y:1},[]);for(const e of this.observedNodes)s.has(e)||e.node.listeners.delete(this);return this.observedNodes=s,this.records.map(e=>e.bytes)}getPlayerFrame(e){this.flush();const t=Number(e),s=Number.isFinite(t)?this.records.filter(e=>e.scopes.every(e=>e.includes(t))&&!this._isAudioMutedFor(e.root,t)):[];return s.length?s.map(e=>e.bytes):[[3,0,0,5,0]]}close(){if(!this.closed){this.closed=!0,clearInterval(this._tickInterval),this.listeners.clear();for(const e of this.observedNodes)e.node.listeners.delete(this);this.observedNodes.clear()}}handleNewAsset(e,t){const s=(this._assetUpdates||this._assetsPending||Promise.resolve()).catch(()=>{}).then(()=>(delete this._assetBufferCache[e],this.initialize().then(e=>(this.closed||this.onAssetUpdate?.(e),e))));return this._assetUpdates=s,s.then(()=>{this._assetUpdates===s&&(this._assetUpdates=null)},()=>{this._assetUpdates===s&&(this._assetUpdates=null)}),s}_isAudioMutedFor(e,t){if(e.node.stream?.audio)return!1===this.playerSettings[t]?.SOUND?.enabled;if(!e.node.asset)return!1;const s=Object.keys(e.node.asset)[0],r=this.gameAssets&&this.gameAssets[s]&&this.gameAssets[s].info;if(!r||"audio"!==r.type)return!1;const i=this.playerSettings[t]&&this.playerSettings[t].SOUND;return!(!i||!1!==i.enabled)}getJson(){const e=this.game.layers,t=new Array(e.length);for(const s in e){const r=e[s].root;t[s]=r}return JSON.stringify(t)}initialize(){if(this.gameAssets=Object.assign({},this.game.constructor.metadata?.()?.assets,this.customBottomLayer?.assets,this.customTopLayer?.assets,this.game.getAssets?.()),!this.loadAssets)return this.assetBundle=new Uint8Array(0),Promise.resolve(this.assetBundle);if(this._assetsPending)return this._assetsPending;const e=this.assetLoader||s(1227).N,t=this.gameAssets,r=Promise.resolve().then(()=>e(t,this._assetBufferCache)).then(e=>this.assetBundle=e);return this._assetsPending=r,r.then(()=>{this._assetsPending=null},()=>{this._assetsPending=null}),r}handleStateChange(e,t){this.closed||(this._dirty=!0,this._flushScheduled||(this._flushScheduled=!0,("function"==typeof setImmediate?setImmediate:e=>setTimeout(e,0))(()=>this.flush())))}flush(){this._flushScheduled=!1,!this.closed&&this._dirty&&(this._dirty=!1,this.state=this.squish(this.game.getLayers()),this.broadcast())}broadcast(){for(const e of this.listeners)e.onEvent(this.state)}updatePlayerSettings(e,t){const s=Object.assign(this.playerSettings[e]||{},t);this.playerSettings[e]=s}deletePlayerSettings(e){delete this.playerSettings[e]}}},2435(e,t,s){const{GameNode:r}=s(5198),i=s(8922),n=s(4857),o=s(7460),a=s(1238);e.exports=class extends a{constructor(e){var t;super(),this.planeSize=e,this.plane=(t=this.planeSize,new r.Shape({shapeType:i.POLYGON,coordinates2d:n.rectangle(0,0,t,t)})),this.fakeRoot=new r.Shape({shapeType:i.POLYGON,coordinates2d:n.rectangle(0,0,0,0),fill:o.COLORS.BLACK}),this.layers=[{root:this.fakeRoot}]}updatePlaneSize(e){this.planeSize=e,this.plane.node.coordinates2d=n.rectangle(0,0,e,e)}getLayers(){return this.layers}getPlane(){return this.plane}getPlaneSize(){return this.planeSize}getViewRoot(){return this.fakeRoot}}},1227(e){const t={image:1,audio:2,font:3,video:4};e.exports={N:async function(e,s=Object.create(null)){const r=[];for(const[i,n]of Object.entries(e)){if(!t[n.info?.type]||!/^[\x20-\x7e]{1,32}$/.test(i))throw new Error("Invalid asset declaration: "+i);if(!Object.hasOwn(s,i)){const e=n.data;if(!(e instanceof Uint8Array))throw new Error("The host must supply local asset bytes: "+i);const r=new Uint8Array(44+e.length);r[0]=1,r[1]=t[n.info.type],r.set((new TextEncoder).encode((e.length+32).toString(36).padStart(10,"0")),2),r.set((new TextEncoder).encode(i),12),r.set(e,44),s[i]=r}r.push(s[i])}const i=new Uint8Array(r.reduce((e,t)=>e+t.length,0));let n=0;for(const e of r)i.set(e,n),n+=e.length;return i}}},6508(e,t,s){const{GameNode:r}=s(5198);e.exports={CONSTRUCTOR_TO_TYPE:{Asset:1,Shape:2,Text:3,Stream:4},TYPE_TO_CONSTRUCTOR:{1:r.Asset,2:r.Shape,3:r.Text,4:r.Stream}}},5331(e){e.exports={getPath:(e,t,s,r,i=100,n=100)=>{const o=[];let a=!0;for(;a;){const h=(0===o.length?e:o[o.length-1][0])+s,l=(0===o.length?t:o[o.length-1][1])+r;if(h<0||h>i||l<0||l>n){let e=h,t=l;h<0?e=0:h>i&&(e=i),l<0?t=0:l>n&&(t=n),o[o.length-1][0]!==e&&o[o.length-1][1]!==t&&o.push([e,t]),a=!1}else o.push([h,l])}return o}}},8681(e,t,s){const r=s(4063),{CONSTRUCTOR_TO_TYPE:i,TYPE_TO_CONSTRUCTOR:n}=s(6508),o=s(1718),{squishId:a}=s(8066),{squishColor:h}=s(7080),{squishPlayerIds:l}=s(7302),{squishPos:c}=s(833),{squishFill:d}=s(3934),{squishSize:u}=s(1902),{squishHandleClick:p}=s(4053),{squishOnHover:f}=s(8046),{squishBorder:m}=s(9421),{squishSubType:g}=s(4793),{squishInput:y}=s(2799),{squishCoordinates2d:v}=s(6758),{squishEffect:w}=s(8446),{squishText:x}=s(184),{squishAsset:b}=s(6867),{squishStream:E}=s(6323),S={stream:E,id:a,color:h,playerIds:l,pos:c,coordinates2d:v,fill:d,size:u,text:x,asset:b,effects:w,handleClick:p,onHover:f,border:m,subType:g,input:y},k={};for(const e in S)k[Number(S[e].type)]=e;e.exports={squish:(e,t=null)=>{let s=[];const r=e.node,n=(()=>{const e=Object.keys(S).filter(e=>S[e].dependsOn&&S[e].dependsOn.length>0);return[Object.keys(S).filter(e=>!S[e].dependsOn||0===S[e].dependsOn.length),e].flat()})();for(const e in n){const i=n[e];if(i in r){const e=r[i];if(null!=e){const n=S[i].squish(e,t,r),o=n.length+3,a=Math.min(255,o),h=Math.min(255,Math.max(0,o-255));s.push([S[i].type,h,a,...n])}}}let a=i[e.constructor.name];a||(a=i[o[r.subType]]);const h=s.flat(),l=h.length+5,c=Math.min(255,l),d=Math.min(255,Math.max(0,l-255));return[3,Math.min(255,Math.max(0,l-510)),d,c,a,...h]},unsquish:e=>{if(3!=e[0])throw new Error("Squished[0] isnt 3.");if(e.length!==e[1]+e[2]+e[3])throw new Error("Bad length value");let t=5,s=new r;for(;t<e.length;){const r=e[t],i=e[t+1]+e[t+2],n=e.slice(t+3,t+i);if(!k[r]){console.warn("Unknown sub frame type "+r);break}{const e=k[r],t=(0,S[e].unsquish)(n,Object.assign({},s));s[e]=t}t+=i}const i=n[e[4]];return i?new i({node:s}):{node:s}}}},6867(e,t,s){const{getFractional:r}=s(3751),i={type:48,squish:(e,t)=>{const s=Object.keys(e)[0],i=new Array(18+s.length),n=e[s],o=t?t.x*n.pos.x+Math.round(100*(1-t.x))/2:n.pos.x,a=t?t.y*n.pos.y+Math.round(100*(1-t.y))/2:n.pos.y,h=t?t.x*n.size.x:n.size.x,l=t?t.y*n.size.y:n.size.y,c=n.startTime||0,d=n.cropLeft||0,u=n.cropTop||0,p=n.cropRight||0,f=n.cropBottom||0;i[0]=Math.floor(o),i[1]=r(o),i[2]=Math.floor(a),i[3]=r(a),i[4]=Math.floor(h),i[5]=r(h),i[6]=Math.floor(l),i[7]=r(l),i[8]=Math.floor(c),i[9]=r(c),i[10]=Math.floor(d),i[11]=r(d),i[12]=Math.floor(u),i[13]=r(u),i[14]=Math.floor(p),i[15]=r(p),i[16]=Math.floor(f),i[17]=r(f);for(let e=0;e<s.length;e++)i[18+e]=s.codePointAt(e);return i},unsquish:e=>{const t=e[0]+e[1]/100,s=e[2]+e[3]/100,r=e[4]+e[5]/100,i=e[6]+e[7]/100,n=e[8]+e[9]/100,o=e[10]+e[11]/100,a=e[12]+e[13]/100,h=e[14]+e[15]/100,l=e[16]+e[17]/100,c=String.fromCodePoint.apply(null,e.slice(18));return{[c]:{pos:{x:t,y:s},size:{x:r,y:i},startTime:n,cropLeft:o,cropTop:a,cropRight:h,cropBottom:l}}}};e.exports={squishAsset:i}},9421(e){e.exports={squishBorder:{type:54,squish:e=>[e],unsquish:e=>e[0]}}},7080(e){e.exports={squishColor:{type:42,squish:e=>[e[0],e[1],e[2],e[3]],unsquish:e=>[e[0],e[1],e[2],e[3]]}}},6758(e,t,s){const{getFractional:r}=s(3751),i=s(7831),n=e=>e<0?0:e>255?255:e,o=(e,t)=>t>0&&t<1?Math.max(0,Math.min(100,e)):e,a=(e,t)=>e*o(t,e)+Math.round(100*(1-e))/2,h={type:52,squish:(e,t,s)=>{const h=e.flat(),l=new Array(2*h.length);if(s.subType==i.SHAPE_2D_CIRCLE)if(t){const e=n(a(t.x,h[0]));l[0]=Math.floor(e),l[1]=r(e);const s=n(a(t.y,h[1]));let i;l[2]=Math.floor(s),l[3]=r(s),i=t.x===t.y?t.x*h[2]:Math.sqrt(Math.pow(100*t.x,2)+Math.pow(100*t.y,2))*(h[2]/100),l[4]=Math.floor(i),l[5]=r(i)}else{const e=n(h[0]);l[0]=Math.floor(e),l[1]=r(e);const t=n(h[1]);l[2]=Math.floor(t),l[3]=r(t);const s=h[2];l[4]=Math.round(s),l[5]=r(s)}else for(const e in h)if(t){const s=e%2==0?t.x:t.y,i=s*o(h[e],s),a=Math.round(100*(1-s)),c=n(i+a/2);l[2*e]=Math.floor(c),l[2*e+1]=r(c)}else{const t=n(h[e]);l[2*e]=Math.floor(t),l[2*e+1]=Math.round(100*(t-Math.floor(t)))}return l},dependsOn:["subType"],unsquish:(e,{subType:t})=>{const s=new Array(e.length/2);for(let t=0;t<e.length;t+=2){const r=e[t]+e[t+1]/100;s[t/2]=r}if(t===i.SHAPE_2D_POLYGON||t===i.SHAPE_2D_LINE){const e=new Array(s.length/2);for(let t=0;t<s.length;t+=2)e[t/2]=[s[t],s[t+1]];return e}return s}};e.exports={squishCoordinates2d:h}},8446(e){const t={type:49,squish:e=>{if(e.shadow){const t="shadow";let s=t.length+4;e.shadow.blur&&(s+=2);const r=new Array(s);for(let e=0;e<t.length;e++)r[e]=t.codePointAt(e);return r[t.length]=e.shadow.color[0],r[t.length+1]=e.shadow.color[1],r[t.length+2]=e.shadow.color[2],r[t.length+3]=e.shadow.color[3],e.shadow.blur&&(r[t.length+4]=Math.floor(e.shadow.blur/10),r[t.length+5]=e.shadow.blur%10),r}},unsquish:e=>{const t=String.fromCodePoint.apply(null,e.slice(0,6)),s=e.slice(6,10);let r;e.length>10&&(r=10*e[10]+e[11]);const i={[t]:{color:s}};return r&&(i[t].blur=r),i}};e.exports={squishEffect:t}},3934(e){e.exports={squishFill:{type:53,squish:e=>[e[0],e[1],e[2],e[3]],unsquish:e=>[e[0],e[1],e[2],e[3]]}}},4053(e){e.exports={squishHandleClick:{type:50,squish:e=>e?[1]:[0],unsquish:e=>1===e[0]}}},8066(e){const t={type:43,squish:e=>{const t=e.toString();let s=new Array(12),r=0;for(;r<=12-t.length;r++)s[r]=0;for(let e=0;e<t.length;e++)s[e+r]=Number(t.charAt(e));return s},unsquish:e=>{let t=0;for(let s=0;s<e.length;s++)t+=e[s]*Math.pow(10,e.length-s-1);return Number(t)}};e.exports={squishId:t}},2799(e){const t={type:51,squish:e=>{const t=new Array(e.type.length);for(let s=0;s<e.type.length;s++)t[s]=e.type.codePointAt(s);return t},unsquish:e=>({type:String.fromCodePoint.apply(null,e)})};e.exports={squishInput:t}},8046(e){e.exports={squishOnHover:{type:56,squish:e=>e?[1]:[0],unsquish:e=>1===e[0]}}},7302(e){e.exports={squishPlayerIds:{type:44,squish:e=>e,unsquish:e=>e}}},833(e){const t=e=>Math.round(100*(e-Math.floor(e))),s={type:45,squish:e=>[Math.floor(e.x),t(e.x),Math.floor(e.y),t(e.y)],unsquish:e=>({x:e[0]+e[1]/100,y:e[2]+e[3]/100})};e.exports={squishPos:s}},1902(e){const t=e=>{Math.round(100*(e-Math.floor(e)))},s={type:46,squish:e=>[Math.floor(e.x),t(e.x),Math.floor(e.y),t(e.y)],unsquish:e=>({x:e[0]+e[1]/100,y:e[2]+e[3]/100})};e.exports={squishSize:s}},6323(e,t,s){const{squishAsset:r}=s(6867),i={type:57,squish(e,t){if(!/^[A-Za-z0-9-]{1,64}$/.test(e.id||""))throw new Error("Stream requires a valid streamId");return[!1===e.audio?0:1,...r.squish({[e.id]:{pos:e.pos,size:e.size}},t)]},unsquish(e){const t=r.unsquish(e.slice(1)),s=Object.keys(t)[0];return{id:s,audio:1===e[0],pos:t[s].pos,size:t[s].size}}};e.exports={squishStream:i}},4793(e){e.exports={squishSubType:{type:55,squish:e=>[e],unsquish:e=>e[0]}}},184(e,t,s){const{hypLength:r}=s(3751),i=s(7460),{squishColor:n}=s(7080),o={type:47,squish:(e,t)=>{const s=t?e.x*t.x+Math.round(100*(1-t.x))/2:e.x,o=t?e.y*t.y+Math.round(100*(1-t.y))/2:e.y,a=e.align||"left",h=e.font||"default",l=new Array(e.text.length+10+a.length+h.length);l[0]=Math.floor(s),l[1]=Math.round(100*(s-Math.floor(s))),l[2]=Math.floor(o),l[3]=Math.round(100*(o-Math.floor(o)));const c=e.size||1,d=t?c*r(t.x,t.y):c;l[4]=Math.floor(d),l[5]=Math.round(100*(d-Math.floor(d)));const u=e.color||i.BLACK,p=n.squish(u);for(let e=0;e<p.length;e++)l[6+e]=p[e];l[6+p.length]=3*[...a].length,l[6+p.length+1]=3*[...h].length;let f=0;for(let e=0;e<[...a].length;e++){const t=[...a][e].codePointAt(0).toString();let s;s=1==t.length?["00","00",`0${t}`]:2==t.length?["00","00",`${t}`]:3==t.length?["00",`0${t.charAt(0)}`,`${t.charAt(1)}${t.charAt(2)}`]:4==t.length?["00",`${t.charAt(0)}${t.charAt(1)}`,`${t.charAt(2)}${t.charAt(3)}`]:5==t.length?[`0${t.charAt(0)}`,`${t.charAt(1)}${t.charAt(2)}`,`${t.charAt(3)}${t.charAt(4)}`]:[`${t.charAt(0)}${t.charAt(1)}`,`${t.charAt(2)}${t.charAt(3)}`,`${t.charAt(4)}${t.charAt(5)}`],l[6+p.length+2+f]=Number(s[0]),l[6+p.length+2+f+1]=Number(s[1]),l[6+p.length+2+f+2]=Number(s[2]),f+=3}let m=0;for(let e=0;e<[...h].length;e++){const t=[...h][e].codePointAt(0).toString();let s;s=1==t.length?["00","00",`0${t}`]:2==t.length?["00","00",`${t}`]:3==t.length?["00",`0${t.charAt(0)}`,`${t.charAt(1)}${t.charAt(2)}`]:4==t.length?["00",`${t.charAt(0)}${t.charAt(1)}`,`${t.charAt(2)}${t.charAt(3)}`]:5==t.length?[`0${t.charAt(0)}`,`${t.charAt(1)}${t.charAt(2)}`,`${t.charAt(3)}${t.charAt(4)}`]:[`${t.charAt(0)}${t.charAt(1)}`,`${t.charAt(2)}${t.charAt(3)}`,`${t.charAt(4)}${t.charAt(5)}`];let r=6+p.length+2+3*[...a].length;l[r+m]=Number(s[0]),l[r+m+1]=Number(s[1]),l[r+m+2]=Number(s[2]),m+=3}let g=0;for(let t=0;t<[...e.text].length;t++){const s=[...e.text][t].codePointAt(0).toString();let r;r=1==s.length?["00","00",`0${s}`]:2==s.length?["00","00",`${s}`]:3==s.length?["00",`0${s.charAt(0)}`,`${s.charAt(1)}${s.charAt(2)}`]:4==s.length?["00",`${s.charAt(0)}${s.charAt(1)}`,`${s.charAt(2)}${s.charAt(3)}`]:5==s.length?[`0${s.charAt(0)}`,`${s.charAt(1)}${s.charAt(2)}`,`${s.charAt(3)}${s.charAt(4)}`]:[`${s.charAt(0)}${s.charAt(1)}`,`${s.charAt(2)}${s.charAt(3)}`,`${s.charAt(4)}${s.charAt(5)}`];let i=6+p.length+2+3*[...a].length+3*[...h].length;l[i+g]=Number(r[0]),l[i+g+1]=Number(r[1]),l[i+g+2]=Number(r[2]),g+=3}return l},unsquish:e=>{const t=e[0]+e[1]/100,s=e[2]+e[3]/100,r=e[4]+e[5]/100,i=e.slice(6,10),n=e[10],o=e[11],a=e.slice(12,12+n),h=e.slice(12+n,12+n+o),l=e.slice(12+n+o);let c=[];for(let e=0;e<a.length;e+=3){let t=a[e].toString();1==t.length&&(t=`0${t}`);let s=a[e+1].toString();1==s.length&&(s=`0${s}`);let r=a[e+2].toString();1==r.length&&(r=`0${r}`);const i=t+s+r;c.push(i)}const d=String.fromCodePoint.apply(null,c);let u=[];for(let e=0;e<h.length;e+=3){let t=h[e].toString();1==t.length&&(t=`0${t}`);let s=h[e+1].toString();1==s.length&&(s=`0${s}`);let r=h[e+2].toString();1==r.length&&(r=`0${r}`);const i=t+s+r;u.push(i)}const p=String.fromCodePoint.apply(null,u),f=[];for(let e=0;e<l.length;e+=3){let t=l[e].toString();1==t.length&&(t=`0${t}`);let s=l[e+1].toString();1==s.length&&(s=`0${s}`);let r=l[e+2].toString();1==r.length&&(r=`0${r}`);const i=t+s+r;f.push(i)}return{x:t,y:s,text:String.fromCodePoint.apply(null,f),size:r,color:i,align:d,font:p}}};e.exports={squishText:o}},1718(e,t,s){const{GameNode:r}=s(5198),i=s(7831);e.exports={[[i.STREAM]]:r.Stream,[[i.ASSET]]:r.Asset,[[i.TEXT]]:r.Text,[[i.SHAPE_2D_POLYGON]]:r.Shape,[[i.SHAPE_2D_CIRCLE]]:r.Shape,[[i.SHAPE_2D_LINE]]:r.Shape}},7831(e){e.exports={STREAM:6,ASSET:1,TEXT:2,SHAPE_2D_POLYGON:3,SHAPE_2D_CIRCLE:4,SHAPE_2D_LINE:5}},5256(e,t,s){const{getRandomTerrain:r,getRandomStartPoint:i}=s(5592),n=e=>{for(let t=0;t<e.length;t++)for(let s=0;s<e[t].length;s++)e[t][s]={filled:e[t][s].filled,north:e[t][s].north,south:e[t][s].south,east:e[t][s].east,west:e[t][s].west}},o=(e,t,s,a,h,l=0)=>{if(0===s||3===l)return e;const c=(e=>{const t=[];return e.forEach((e,s)=>{t[s]=[],e.forEach(e=>{t[s].push({...e})})}),t})(e);r()(c,i(a,h,t),a,h,t);const d=((e,t,s,r)=>{const i=[];for(let o=0;o<s;o++)for(let s=0;s<r;s++){const r=[],a={x:o,y:s};for(;;){const s=e[a.x][a.y];if(i.findIndex(e=>e.x===a.x&&e.y===a.y)>-1||a.x===t.x&&a.y===t.y||s.filled){i.push(...r);break}if((!s.north||s.wentNorth)&&(!s.south||s.wentSouth)&&(!s.east||s.wentEast)&&(!s.west||s.wentWest))return!1;if(r.push({...a}),s.south&&!s.wentSouth)s.wentSouth=!0,a.y=a.y+1;else if(s.east&&!s.wentEast)s.wentEast=!0,a.x=a.x+1;else if(s.north&&!s.wentNorth)s.wentNorth=!0,a.y=a.y-1;else{if(!s.west||s.wentWest)return!1;s.wentWest=!0,a.x=a.x-1}}n(e)}return!0})(c,t,a,h);return d?o(c,t,s-1,a,h,0):o(e,t,s,a,h,l+1)};e.exports={terrainGenerator:(e={x:100,y:100},t={x:5,y:5},s=5)=>{const{width:r,height:i}=((e,t)=>{const s=e.x,r=e.y,i=t.x,n=t.y;return{width:Math.floor(s/i),height:Math.floor(r/n)}})(e,t);let n=((e,t)=>{const s=[],r={filled:!1,north:!0,south:!0,east:!0,west:!0};for(let i=0;i<e;i++){s[i]=[];for(let n=0;n<t;n++){const o={...r};0===i?o.west=!1:i===e-1&&(o.east=!1),0===n?o.north=!1:n===t-1&&(o.south=!1),s[i].push(o)}}return s})(r,i);const a={x:Math.floor(Math.random()*r),y:Math.floor(Math.random()*i)};return n=o(n,a,s,r,i),n}}},5592(e){const t=(e,{x:t,y:s},r,i,n)=>{t<0||t>=r||s<0||s>=i||t===n.x&&s===n.y||e[t][s].filled||(e[t][s].north&&(e[t][s-1].south=!1),e[t][s].south&&(e[t][s+1].north=!1),e[t][s].east&&(e[t+1][s].west=!1),e[t][s].west&&(e[t-1][s].east=!1),e[t][s].filled=!0,e[t][s].north=!1,e[t][s].south=!1,e[t][s].east=!1,e[t][s].west=!1)},s=[(e,{x:s,y:r},i,n,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},i,n,o),0===a?(t(e,{x:s+1,y:r},i,n,o),t(e,{x:s,y:r+1},i,n,o),t(e,{x:s+1,y:r+1},i,n,o)):1===a?(t(e,{x:s-1,y:r},i,n,o),t(e,{x:s,y:r+1},i,n,o),t(e,{x:s-1,y:r+1},i,n,o)):2===a?(t(e,{x:s,y:r-1},i,n,o),t(e,{x:s+1,y:r},i,n,o),t(e,{x:s+1,y:r-1},i,n,o)):(t(e,{x:s,y:r-1},i,n,o),t(e,{x:s-1,y:r},i,n,o),t(e,{x:s-1,y:r-1},i,n,o))},(e,{x:s,y:r},i,n,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},i,n,o),0===a?(t(e,{x:s,y:r+1},i,n,o),t(e,{x:s,y:r+2},i,n,o),t(e,{x:s,y:r+3},i,n,o)):1===a?(t(e,{x:s+1,y:r},i,n,o),t(e,{x:s+2,y:r},i,n,o),t(e,{x:s+3,y:r},i,n,o)):2===a?(t(e,{x:s-1,y:r},i,n,o),t(e,{x:s-2,y:r},i,n,o),t(e,{x:s-3,y:r},i,n,o)):(t(e,{x:s,y:r-1},i,n,o),t(e,{x:s,y:r-2},i,n,o),t(e,{x:s,y:r-3},i,n,o))},(e,{x:s,y:r},i,n,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},i,n,o),0===a?(t(e,{x:s,y:r+1},i,n,o),t(e,{x:s,y:r+2},i,n,o),t(e,{x:s+1,y:r+2},i,n,o)):1===a?(t(e,{x:s+1,y:r},i,n,o),t(e,{x:s+2,y:r},i,n,o),t(e,{x:s+2,y:r-1},i,n,o)):2===a?(t(e,{x:s-1,y:r},i,n,o),t(e,{x:s-2,y:r},i,n,o),t(e,{x:s-2,y:r+1},i,n,o)):(t(e,{x:s,y:r-1},i,n,o),t(e,{x:s,y:r-2},i,n,o),t(e,{x:s-1,y:r-2},i,n,o))},(e,{x:s,y:r},i,n,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},i,n,o),0===a?(t(e,{x:s,y:r+1},i,n,o),t(e,{x:s-1,y:r+1},i,n,o),t(e,{x:s-1,y:r+2},i,n,o)):1===a?(t(e,{x:s+1,y:r},i,n,o),t(e,{x:s+1,y:r+1},i,n,o),t(e,{x:s+2,y:r+1},i,n,o)):2===a?(t(e,{x:s-1,y:r},i,n,o),t(e,{x:s-1,y:r+1},i,n,o),t(e,{x:s-2,y:r+1},i,n,o)):(t(e,{x:s,y:r-1},i,n,o),t(e,{x:s-1,y:r-1},i,n,o),t(e,{x:s-1,y:r-2},i,n,o))}];e.exports={getRandomTerrain:()=>s[Math.floor(Math.random()*s.length)],getRandomStartPoint:(e,t,s)=>{const r={x:Math.floor(Math.random()*e),y:Math.floor(Math.random()*t)};for(;r.x===s.x&&r.y===s.y;)r.x=Math.floor(Math.random()*e),r.y=Math.floor(Math.random()*t);return r}}},2403(e){const t=(e,s,r,i=[])=>{if(!r||r(e)&&e.node.id!==s.node.id){const t=e.node.text,r=e.node.coordinates2d||[[t.x,t.y],[t.x,t.y],[t.x,t.y],[t.x,t.y],[t.x,t.y]],n=s.node.coordinates2d,o=r[0][0],a=r[1][0],h=n[0][0],l=n[1][0],c=r[0][1],d=r[2][1],u=n[0][1],p=n[2][1];l<o||a<h||c>p||u>d||i.push(e)}for(const n in e.node.children)t(e.node.children[n],s,r,i);return i};e.exports={checkCollisions:(e,s,r=null)=>t(e,s,r)}},3751(e){e.exports={hypLength:(e,t)=>Math.sqrt(Math.pow(e,2)+Math.pow(t,2)),getFractional:e=>Math.round(100*(e-Math.floor(e)))}},4857(e){e.exports={triangle:(e,t,s,r,i,n)=>[[e,t],[s,r],[i,n],[e,t]],rectangle:(e,t,s,r)=>[[e,t],[e+s,t],[e+s,t+r],[e,t+r],[e,t]]}},2341(e,t,s){const{GameNode:r}=s(5198),i=s(8922),n=s(4857),o=s(2403),a=s(7460);e.exports={getView:(e,t,s,h={},l={})=>{const c=o.checkCollisions(e,{node:{coordinates2d:n.rectangle(t.x,t.y,t.w,t.h)}},t=>t.node.id!==e.node.id),d=new r.Shape({shapeType:i.POLYGON,coordinates2d:n.rectangle(0,0,0,0),fill:a.COLORS.BLACK}),u=[];return c.length>0&&c.forEach(e=>{const r=[],i=[],n=e.node.coordinates2d||[[e.node.text.x,e.node.text.y],[e.node.text.x,e.node.text.y],[e.node.text.x,e.node.text.y],[e.node.text.x,e.node.text.y],[e.node.text.x,e.node.text.y]];for(let s in n){const o=n[s],a=o[0],c=o[1];let d=Math.max(Math.min(a-t.x,100),0),u=Math.max(Math.min(c-t.y,100),0);d=(l.x||1)*d,u=(l.y||1)*u;const p=!h.filter||h.filter(e);p&&(h.x&&(d+=h.x),h.y&&(u+=h.y)),d<0?d=0:d>100&&(d=100),u<0?u=0:u>100&&(u=100),r.push([d,u]);let f=(l.x||1)*(a-t.x),m=(l.y||1)*(c-t.y);p&&(h.x&&(f+=h.x),h.y&&(m+=h.y)),i.push([f,m])}{const t=e.clone({handleClick:null===e.node.handleClick||void 0===e.node.handleClick?null:e.node.handleClick,id:e.node.id});if(r&&r.length&&(t.node.text&&(t.node.text.x=r[0][0],t.node.text.y=r[0][1]),r.length&&(t.node.coordinates2d=r),t.node.asset)){const e=t.node.coordinates2d[0],s=t.node.coordinates2d[1],r=t.node.coordinates2d[2],n=s[0]-e[0],o=r[1]-s[1],a=Object.values(t.node.asset)[0];a.pos.x=e[0],a.pos.y=e[1],a.size.x=n,a.size.y=o;const h=i[0],l=i[2],c=l[0]-h[0],d=l[1]-h[1];c>0&&(a.cropLeft=100*Math.max(0,(0-h[0])/c),a.cropRight=100*Math.max(0,(l[0]-100)/c)),d>0&&(a.cropTop=100*Math.max(0,(0-h[1])/d),a.cropBottom=100*Math.max(0,(l[1]-100)/d))}t.node.playerIds=s||[],u.push(t)}}),u.forEach(e=>d.addChild(e)),d}}},2416(e,t,s){const{squish:r,unsquish:i}=s(8824),{gameNode:n,GameNode:o}=s(51),a=(s(9798),s(3269)),h=s(2591),l=s(2358),c=s(683),d=s(8926),u=s(1924),{terrainGenerator:p}=s(6007),f=s(2714),m=s(4455),g=s(4497),y=s(8408),v=s(9512);e.exports={squish:r,unsquish:i,gameNode:n,subtypes:f,Game:h,ViewableGame:l,GameNode:o,Colors:a,Shapes:c,Squisher:m,ShapeUtils:d,ViewUtils:u,TerrainGenerator:p,GeometryUtils:y,Asset:g,Physics:v}},4497(e){e.exports=class{constructor(e,t=null){this.info={...e},null!==t&&(this.data=new Uint8Array(t))}getData(){return this.data instanceof Uint8Array?Promise.resolve(this.data.slice()):Promise.reject(new Error("The host has not supplied bytes for this asset"))}}},4732(e,t,s){const r=s(9798),i=(e,t,s,i,n,o,a,h,l,c,d,u,p,f,m,g)=>new r(e,t,s,i,n,o,a,h,l,c,d,u,p,f,m,g);e.exports={gameNode:i,BaseNode:class{constructor({color:e,onClick:t,coordinates2d:s,border:r,fill:n,textInfo:o,assetInfo:a,playerIds:h,effects:l,input:c,subtype:d,node:u,id:p,onHover:f,offHover:m,onDrag:g,offClick:y}){this.node=u||i(e,t,s,r,n,o,a,h,l,c,d,p,f,m,g,y),this.id=this.node.id}showFor(e){const t=this.node.playerIds.indexOf(e),s=this.node.playerIds.indexOf(0);if(s>=0){const e=this.node.playerIds;e.splice(s,1),this.node.playerIds=e}if(t<0){const t=this.node.playerIds;t.push(e),this.node.playerIds=t}}hideFor(e){const t=this.node.playerIds.indexOf(e);if(t>=0){let e=this.node.playerIds;e.splice(t,1),0==e.length&&(e=[0]),this.node.playerIds=e}}addChild(e,t=!0){this.node.addChild(e),t&&this.node.onStateChange()}addChildren(...e){for(let t=0;t<e.length;t++)this.addChild(e[t],!1);this.node.onStateChange()}getChildren(){return this.node.children}removeChild(e,t=!0){this.node.removeChild(e),t&&this.node.onStateChange()}addListener(e){this.node.addListener(e)}findChild(e){return this.findChildHelper(e,this)}findChildHelper(e,t,s=null){t.node.id===e&&(s=t);for(const r in t.node.children){if(s)return s;s=this.findChildHelper(e,t.node.children[r],s)}return s}clearChildren(e){this.node.clearChildren(e),this.node.onStateChange()}update(e={}){e&&(e.fill&&(this.node.fill=e.fill),e.coordinates2d&&(this.node.coordinates2d=e.coordinates2d)),this.node.onStateChange()}clone(){throw new Error("Clone not implemented")}}}},3269(e){const t={ALMOST_BLACK:[16,16,16,255],ALMOST_WHITE:[238,238,238,255],ANTIQUE_WHITE:[250,235,215,255],AQUA:[188,212,230,255],AQUAMARINE:[127,255,212,255],BEIGE:[245,245,220,255],BIG_GRAY:[221,221,221,255],BLACK:[0,0,0,255],BLAY:[87,102,117,255],BLUE:[0,0,255,255],BLUE_WHISPER:[240,248,255,255],BLEEN:[19,51,55,255],BLOOD:[153,0,0,255],BOOGER:[186,218,85,255],BRIGHT_GRAY:[198,226,255,255],BRONZE:[227,151,17,255],BROWN:[145,97,11,255],CANDY_GREEN:[90,193,142,255],CANDY_PINK:[255,115,115,255],CANDY_RED:[246,84,106,255],CHARCOAL:[51,51,51,255],CALM_BLUE:[8,141,165,255],COOL_BLUE:[64,114,148,255],COOL_GREEN:[180,238,180,255],CORAL:[255,127,80,255],CORPORATE_BEIGE:[203,203,169,255],CREAM:[240,224,136,255],CREAMSICLE:[255,195,160,255],CYAN:[0,255,255,255],DARK_TURQUOISE:[0,206,209,255],DEEP_BLUE:[0,51,102,255],DEEP_PURPLE:[102,0,102,255],DEEP_RED:[139,0,0,255],DIM_GRAY:[105,105,105,255],DULL_BLUE:[192,214,228,255],EMERALD:[39,89,45,255],EVERGREEN:[6,85,53,255],FRIENDLY_BLUE:[70,132,153,255],FUCHSIA:[255,0,255,255],FUNNY_PURPLE:[128,0,128,255],GOLD:[255,215,0,255],GOLDMEMBER:[218,165,32,255],GRAY:[192,192,192,255],GREEN:[0,255,0,255],GUN_METAL_GRAY:[102,102,102,255],HARD_ORANGE_RED:[255,64,64,255],HARD_PINK:[247,52,122,255],HG_BLACK:[26,26,26,255],HG_BLUE:[148,210,230,255],HG_RED:[241,112,112,255],HG_YELLOW:[255,247,143,255],INTERIOR_RED:[255,102,102,255],INVITATION_BLUE:[104,151,187,255],KHAKI:[255,246,143,255],LAVENDER:[230,230,250,255],LIGHT_CORAL:[240,128,128,255],LIGHT_SEA_GREEN:[32,178,170,255],NAVY:[0,0,128,255],MAGENTA:[255,0,255,255],MAROON:[128,0,0,255],MEAN_SEA:[129,216,208,255],MERLOT:[66,4,32,255],MINT:[102,205,170,255],MUSTARD:[232,219,32,255],NEON_BOOGER:[204,255,0,255],NEON_PINK:[255,128,237,255],ORANGE:[255,165,0,255],ORANGE_RED:[255,69,0,255],PALE_TURQUOISE:[175,238,238,255],PEACH:[255,218,185,255],PERFUME_PINK:[255,228,225,255],PERRYWINKLE:[204,204,255,255],PINK:[255,192,203,255],POWDER_BLUE:[176,224,230,255],PURPLE:[128,0,128,255],REAL_ESTATE_BLUE:[14,47,68,255],RED:[255,0,0,255],RUST:[128,0,0,255],SALMON:[250,128,114,255],SEA_GREEN:[0,128,128,255],SHARP_YELLOW:[255,255,102,255],SILVER:[192,192,192,255],SIMPLE_GRAY:[204,204,204,255],SLEEPY_PINK:[255,182,193,255],SMOKE:[245,245,245,255],SMOOTH_BLUE:[76,163,221,255],SOFT_GREEN:[211,255,206,255],SOFT_MINT:[182,252,213,255],SOFT_PINK:[255,192,203,255],STRESSED_PURPLE:[138,43,226,255],SKY_BLUE:[127,229,240,255],STANDARD_GRAY:[128,128,128,255],STORM_GRAY:[105,105,102,255],SUCCESS_GREEN:[0,128,0,255],TEAL:[0,128,128,255],TENSE_SKY:[102,204,204,255],TERRACOTTA:[226,114,91,255],THICK_LUXURY:[195,151,151,255],TURQUOISE:[64,224,208,255],WALLPAPER_BEIGE:[203,190,181,255],WALLPAPER_GREEN:[220,237,193,255],WHITE:[255,255,255,255],YELLOW:[255,255,0,255]},s=Object.keys(t);e.exports={COLORS:t,randomColor:function(e=[]){const r=e.length?((e,t)=>e.length===t.length?["WHITE"]:e.filter(e=>{for(const s of t)if(e===s)return!1;return!0}))(s,e):s,i=Math.floor(Math.random()*r.length);return t[r[i]]}}},2591(e){e.exports=class{constructor(){this.listeners=new Set,this.intervals=[],this.timeouts=[],this.playerInfoMap={}}addStateListener(e){this.listeners.add(e)}removeStateListener(e){this.listeners.delete(e)}findNode(e){let t=null;if(this.getLayers){const s=this.getLayers();for(let r in s)if(t=s[r].root.findChild(e),t)break}return t}setInterval(e,t){const s=setInterval(e,t);return this.intervals.push(s),s}setTimeout(e,t){const s=setTimeout(e,t);return this.timeouts.push(s),s}close(){for(const e in this.timeouts){const t=this.timeouts[e];clearTimeout(t)}for(const e in this.intervals){const t=this.intervals[e];clearInterval(t)}}}},51(e,t,s){const r=s(683),i=s(2714),{gameNode:n,BaseNode:o}=s(4732),a={[r.CIRCLE]:i.SHAPE_2D_CIRCLE,[r.POLYGON]:i.SHAPE_2D_POLYGON,[r.LINE]:i.SHAPE_2D_LINE},h={[i.SHAPE_2D_CIRCLE]:r.CIRCLE,[i.SHAPE_2D_POLYGON]:r.POLYGON,[i.SHAPE_2D_LINE]:r.LINE};class l extends o{constructor({color:e,onClick:t,shapeType:s,coordinates2d:r,border:i,fill:n,playerIds:o,effects:h,input:l,node:c,id:d,onHover:u,offHover:p,onDrag:f,offClick:m}){if(!(r&&s||c))throw new Error("Shape requires coordinates2d and shapeType");super({color:e,onClick:t,coordinates2d:r,border:i,fill:n,playerIds:o,effects:h,input:l,node:c,subtype:a[s],id:d,onHover:u,offHover:p,onDrag:f,offClick:m})}clone({handleClick:e,input:t,id:s}){const r=Number(s)||null;return new l({color:this.node.color,onClick:e,shapeType:h[this.node.subType],coordinates2d:this.node.coordinates2d,border:this.node.border,fill:this.node.fill,playerIds:this.node.playerIds,effects:this.node.effects,input:t,id:r})}}class c extends o{constructor({textInfo:e,playerIds:t,input:s,node:r,id:n,onClick:o,onHover:a,offHover:h,onDrag:l,offClick:c}){if(!e&&!r)throw new Error("Text node requires textInfo");super({textInfo:e,playerIds:t,input:s,node:r,subtype:i.TEXT,id:n,onClick:o,onHover:a,offHover:h,onDrag:l,offClick:c})}clone({handleClick:e,input:t,id:s}){const r=s||null;return new c({textInfo:Object.assign({},this.node.text),playerIds:this.playerIds?.slice(),id:r})}}class d extends o{constructor({assetInfo:e,onClick:t,coordinates2d:s,playerIds:r,effects:n,node:o,id:a,onHover:h,offHover:l,onDrag:c,offClick:d}){if(!e&&!o)throw new Error("Asset node requires assetInfo");super({assetInfo:e,onClick:t,coordinates2d:s,playerIds:r,effects:n,node:o,subtype:i.ASSET,id:a,onHover:h,offHover:l,onDrag:c,offClick:d})}clone({handleClick:e,input:t,id:s}){const r=s||null;return new d({assetInfo:Object.assign({},this.node.asset),playerIds:this.playerIds?.slice(),id:r})}}const u={Stream:class extends o{constructor({streamId:e,pos:t={x:0,y:0},size:s={x:0,y:0},audio:r=!0,node:n,...o}){if(!n&&!/^[A-Za-z0-9-]{1,64}$/.test(e||""))throw new Error("Stream requires a valid streamId");super({...o,node:n,subtype:i.STREAM}),n||(this.node.stream={id:e,pos:t,size:s,audio:!!r})}},Asset:d,Shape:l,Text:c};e.exports={gameNode:n,GameNode:u}},9798(e){e.exports=class{constructor(e,t,s,r,i,n,o,a=[],h=null,l=null,c=null,d=null,u,p,f,m){this.id=d?Number(d):Math.floor(999999999*Math.random()),this.children=new Array,this.color=e,this.handleClick=t,this.coordinates2d=s,this.border=r,this.fill=i,this.text=n,this.asset=o,this.effects=h,this.input=l,this.listeners=new Set,!a||a instanceof Array||(a=[a]),this.playerIds=a||[],this.subType=c,this.onHover=u,this.offHover=p,this.onDrag=f,this.offClick=m}addChild(e){this.children.push(e)}addChildren(...e){for(let t=0;t<e.length;t++)this.addChild(e[t])}removeChild(e){const t=this.children.findIndex(t=>t.node.id==e);t>=0&&(this._animation&&clearInterval(this._animation),this.children.splice(t,1))}addListener(e){this.listeners.add(e)}onStateChange(){for(const e of this.listeners)e.handleStateChange(this)}clearChildren(e){if(e){const t=this.children.filter(t=>e.includes(t.id));this.children=t}else this.children=new Array}}},683(e){e.exports={CIRCLE:1,POLYGON:2,LINE:3}},4455(e,t,s){const{squish:r,unsquish:i}=s(8824);e.exports=class{constructor({game:e,scale:t,customBottomLayer:s,customTopLayer:n,onAssetUpdate:o,encodeNode:a=r,decodeNode:h=i,autoTick:l=!0,loadAssets:c=!0,assetLoader:d}){if(this.encodeNode=a,this.decodeNode=h,this.loadAssets=c,this.assetLoader=d,this.observedNodes=new Set,this.closed=!1,this._nodeObservations=new Map,this._observationGeneration=0,this.ids=new Set,this.game=e,this.gameMetadata=e.constructor.metadata&&e.constructor.metadata(),this._assetBufferCache=Object.create(null),this.playerSettings={},this.customBottomLayer=s,this.customTopLayer=n,this.initialize(),this.onAssetUpdate=o,this.playerFrames={},this.listeners=new Set,this._dirty=!1,this._flushScheduled=!1,this.scale=t||{x:1,y:1},this.state=this.squish(this.game.getLayers()),l&&this.game.tick){const e=this.gameMetadata&&this.gameMetadata.tickRate?this.gameMetadata.tickRate:60;this._tickInterval=setInterval(this.game.tick.bind(this.game),1e3/e)}}addListener(e){const t={onEvent:e,remove:()=>this.removeListener(t)};this.listeners.add(t)}removeListener(e){this.listeners.delete(e)}unsquish(e){return this.decodeNode(e)}squish(e,t=null){this.records=[],this._publicRuns=[],this._playerRuns=new Map;const s=[],r=++this._observationGeneration;let i,n;const o=(e,t,a,h)=>{if(!e?.node)return;let l=this._nodeObservations.get(e);l?l.generation=r:(e.addListener(this),this.observedNodes.add(e),l={root:e,generation:r},this._nodeObservations.set(e,l));const c=e.node.playerIds,d=c?.length?[...a,c.map(Number)]:a;if(d!==a){const e=new Set;for(const t of d[d.length-1])Number.isFinite(t)&&(null===h||h.has(t))&&e.add(t);h=e}if(!n||h!==i){if(n={start:this.records.length,end:this.records.length},null===h)this._publicRuns.push(n);else for(const e of h){let t=this._playerRuns.get(e);t||this._playerRuns.set(e,t=[]),t.push(n)}i=h}const u=this.encodeNode(e,t);this.records.push({root:e,scopes:d,bytes:u}),s.push(u),n.end++;for(const s of e.node.children||[])o(s,t,d,h)};this.customBottomLayer&&o(this.customBottomLayer.root,this.customBottomLayer.scale||{x:1,y:1},[],null);for(const s in e||[])o(e[s].root,e[s].scale||t||this.scale||{x:1,y:1},[],null);this.customTopLayer&&o(this.customTopLayer.root,this.customTopLayer.scale||{x:1,y:1},[],null);for(const e of this._nodeObservations.values())if(e.generation!==r){const t=e.root;t.node.listeners.delete(this),this._nodeObservations.delete(t),this.observedNodes.delete(t)}return s}getPlayerFrame(e){this.flush();const t=Number(e);if(!Number.isFinite(t))return[[3,0,0,5,0]];const s=this._publicRuns,r=this._playerRuns.get(t)||[],i=!1===this.playerSettings[t]?.SOUND?.enabled,n=[];let o=0,a=0;for(;o<s.length||a<r.length;){const e=s[o],h=r[a],l=e&&(!h||e.start<h.start)?s[o++]:r[a++];for(let e=l.start;e<l.end;e++){const s=this.records[e];i&&this._isAudioMutedFor(s.root,t)||n.push(s.bytes)}}return n.length?n:[[3,0,0,5,0]]}close(){if(!this.closed){this.closed=!0,clearInterval(this._tickInterval),this.listeners.clear();for(const e of this.observedNodes)e.node.listeners.delete(this);this.observedNodes.clear(),this._nodeObservations.clear()}}handleNewAsset(e,t){const s=(this._assetUpdates||this._assetsPending||Promise.resolve()).catch(()=>{}).then(()=>(delete this._assetBufferCache[e],this.initialize().then(e=>(this.closed||this.onAssetUpdate?.(e),e))));return this._assetUpdates=s,s.then(()=>{this._assetUpdates===s&&(this._assetUpdates=null)},()=>{this._assetUpdates===s&&(this._assetUpdates=null)}),s}_isAudioMutedFor(e,t){if(e.node.stream?.audio)return!1===this.playerSettings[t]?.SOUND?.enabled;if(!e.node.asset)return!1;const s=Object.keys(e.node.asset)[0],r=this.gameAssets&&this.gameAssets[s]&&this.gameAssets[s].info;if(!r||"audio"!==r.type)return!1;const i=this.playerSettings[t]&&this.playerSettings[t].SOUND;return!(!i||!1!==i.enabled)}getJson(){const e=this.game.layers,t=new Array(e.length);for(const s in e){const r=e[s].root;t[s]=r}return JSON.stringify(t)}initialize(){if(this.gameAssets=Object.assign({},this.game.constructor.metadata?.()?.assets,this.customBottomLayer?.assets,this.customTopLayer?.assets,this.game.getAssets?.()),!this.loadAssets)return this.assetBundle=new Uint8Array(0),Promise.resolve(this.assetBundle);if(this._assetsPending)return this._assetsPending;const e=this.assetLoader||s(8826).N,t=this.gameAssets,r=Promise.resolve().then(()=>e(t,this._assetBufferCache)).then(e=>this.assetBundle=e);return this._assetsPending=r,r.then(()=>{this._assetsPending=null},()=>{this._assetsPending=null}),r}handleStateChange(e,t){this.closed||(this._dirty=!0,this._flushScheduled||(this._flushScheduled=!0,("function"==typeof setImmediate?setImmediate:e=>setTimeout(e,0))(()=>this.flush())))}flush(){this._flushScheduled=!1,!this.closed&&this._dirty&&(this._dirty=!1,this.state=this.squish(this.game.getLayers()),this.broadcast())}broadcast(){for(const e of this.listeners)e.onEvent(this.state)}updatePlayerSettings(e,t){const s=Object.assign(this.playerSettings[e]||{},t);this.playerSettings[e]=s}deletePlayerSettings(e){delete this.playerSettings[e]}}},2358(e,t,s){const{GameNode:r}=s(51),i=s(683),n=s(8926),o=s(3269),a=s(2591);e.exports=class extends a{constructor(e){var t;super(),this.planeSize=e,this.plane=(t=this.planeSize,new r.Shape({shapeType:i.POLYGON,coordinates2d:n.rectangle(0,0,t,t)})),this.fakeRoot=new r.Shape({shapeType:i.POLYGON,coordinates2d:n.rectangle(0,0,0,0),fill:o.COLORS.BLACK}),this.layers=[{root:this.fakeRoot}]}updatePlaneSize(e){this.planeSize=e,this.plane.node.coordinates2d=n.rectangle(0,0,e,e)}getLayers(){return this.layers}getPlane(){return this.plane}getPlaneSize(){return this.planeSize}getViewRoot(){return this.fakeRoot}}},8826(e){const t={image:1,audio:2,font:3,video:4};e.exports={N:async function(e,s=Object.create(null)){const r=[];for(const[i,n]of Object.entries(e)){if(!t[n.info?.type]||!/^[\x20-\x7e]{1,32}$/.test(i))throw new Error("Invalid asset declaration: "+i);if(!Object.hasOwn(s,i)){const e=n.data;if(!(e instanceof Uint8Array))throw new Error("The host must supply local asset bytes: "+i);const r=new Uint8Array(44+e.length);r[0]=1,r[1]=t[n.info.type],r.set((new TextEncoder).encode((e.length+32).toString(36).padStart(10,"0")),2),r.set((new TextEncoder).encode(i),12),r.set(e,44),s[i]=r}r.push(s[i])}const i=new Uint8Array(r.reduce((e,t)=>e+t.length,0));let n=0;for(const e of r)i.set(e,n),n+=e.length;return i}}},5889(e,t,s){const{GameNode:r}=s(51);e.exports={CONSTRUCTOR_TO_TYPE:{Asset:1,Shape:2,Text:3,Stream:4},TYPE_TO_CONSTRUCTOR:{1:r.Asset,2:r.Shape,3:r.Text,4:r.Stream}}},9512(e){e.exports={getPath:(e,t,s,r,i=100,n=100)=>{const o=[];let a=!0;for(;a;){const h=(0===o.length?e:o[o.length-1][0])+s,l=(0===o.length?t:o[o.length-1][1])+r;if(h<0||h>i||l<0||l>n){let e=h,t=l;h<0?e=0:h>i&&(e=i),l<0?t=0:l>n&&(t=n),o[o.length-1][0]!==e&&o[o.length-1][1]!==t&&o.push([e,t]),a=!1}else o.push([h,l])}return o}}},8824(e,t,s){const r=s(9798),{CONSTRUCTOR_TO_TYPE:i,TYPE_TO_CONSTRUCTOR:n}=s(5889),o=s(5791),{squishId:a}=s(9211),{squishColor:h}=s(8339),{squishPlayerIds:l}=s(9449),{squishPos:c}=s(3358),{squishFill:d}=s(2675),{squishSize:u}=s(303),{squishHandleClick:p}=s(6578),{squishOnHover:f}=s(4433),{squishBorder:m}=s(4928),{squishSubType:g}=s(1354),{squishInput:y}=s(828),{squishCoordinates2d:v}=s(4901),{squishEffect:w}=s(4167),{squishText:x}=s(421),{squishAsset:b}=s(9772),{squishStream:E}=s(6514),S={stream:E,id:a,color:h,playerIds:l,pos:c,coordinates2d:v,fill:d,size:u,text:x,asset:b,effects:w,handleClick:p,onHover:f,border:m,subType:g,input:y},k={};for(const e in S)k[Number(S[e].type)]=e;const _=(()=>{const e=Object.keys(S).filter(e=>S[e].dependsOn&&S[e].dependsOn.length>0);return[Object.keys(S).filter(e=>!S[e].dependsOn||0===S[e].dependsOn.length),e].flat()})();e.exports={squish:(e,t=null)=>{const s=[3,0,0,0,void 0];let r=5;const n=e.node;for(let e=0;e<_.length;e++){const i=_[e];if(i in n){const e=n[i];if(null!=e){const o=S[i],a=o.squish(e,t,n),h=a.length+3;r+=h,s.push(o.type,Math.min(255,Math.max(0,h-255)),Math.min(255,h));for(let e=0;e<a.length;e++)s.push(a[e])}}}let a=i[e.constructor.name];a||(a=i[o[n.subType]]);const h=Math.min(255,r),l=Math.min(255,Math.max(0,r-255)),c=Math.min(255,Math.max(0,r-510));return s[0]=3,s[1]=c,s[2]=l,s[3]=h,s[4]=a,s},unsquish:e=>{if(3!=e[0])throw new Error("Squished[0] isnt 3.");if(e.length!==e[1]+e[2]+e[3])throw new Error("Bad length value");let t=5,s=new r;for(;t<e.length;){const r=e[t],i=e[t+1]+e[t+2],n=e.subarray?e.subarray(t+3,t+i):e.slice(t+3,t+i);if(!k[r]){console.warn("Unknown sub frame type "+r);break}{const t=k[r],i=(0,S[t].unsquish)("playerIds"===t&&e.subarray?n.slice():n,s);s[t]=i}t+=i}const i=n[e[4]];return i?new i({node:s}):{node:s}}}},9772(e,t,s){const{getFractional:r}=s(6522),i={type:48,squish:(e,t)=>{const s=Object.keys(e)[0],i=new Array(18+s.length),n=e[s],o=t?t.x*n.pos.x+Math.round(100*(1-t.x))/2:n.pos.x,a=t?t.y*n.pos.y+Math.round(100*(1-t.y))/2:n.pos.y,h=t?t.x*n.size.x:n.size.x,l=t?t.y*n.size.y:n.size.y,c=n.startTime||0,d=n.cropLeft||0,u=n.cropTop||0,p=n.cropRight||0,f=n.cropBottom||0;i[0]=Math.floor(o),i[1]=r(o),i[2]=Math.floor(a),i[3]=r(a),i[4]=Math.floor(h),i[5]=r(h),i[6]=Math.floor(l),i[7]=r(l),i[8]=Math.floor(c),i[9]=r(c),i[10]=Math.floor(d),i[11]=r(d),i[12]=Math.floor(u),i[13]=r(u),i[14]=Math.floor(p),i[15]=r(p),i[16]=Math.floor(f),i[17]=r(f);for(let e=0;e<s.length;e++)i[18+e]=s.codePointAt(e);return i},unsquish:e=>{const t=e[0]+e[1]/100,s=e[2]+e[3]/100,r=e[4]+e[5]/100,i=e[6]+e[7]/100,n=e[8]+e[9]/100,o=e[10]+e[11]/100,a=e[12]+e[13]/100,h=e[14]+e[15]/100,l=e[16]+e[17]/100,c=String.fromCodePoint.apply(null,e.slice(18));return{[c]:{pos:{x:t,y:s},size:{x:r,y:i},startTime:n,cropLeft:o,cropTop:a,cropRight:h,cropBottom:l}}}};e.exports={squishAsset:i}},4928(e){e.exports={squishBorder:{type:54,squish:e=>[e],unsquish:e=>e[0]}}},8339(e){e.exports={squishColor:{type:42,squish:e=>[e[0],e[1],e[2],e[3]],unsquish:e=>[e[0],e[1],e[2],e[3]]}}},4901(e,t,s){const{getFractional:r}=s(6522),i=s(2714),n=e=>e<0?0:e>255?255:e,o=(e,t)=>t>0&&t<1?Math.max(0,Math.min(100,e)):e,a=(e,t)=>e*o(t,e)+Math.round(100*(1-e))/2,h={type:52,squish:(e,t,s)=>{if(s.subType===i.SHAPE_2D_POLYGON||s.subType===i.SHAPE_2D_LINE){const s=((e,t)=>{if(!Array.isArray(e))return null;let s,r;if(t&&(s=t.x,r=t.y,"number"!=typeof s||"number"!=typeof r))return null;for(let t=0;t<e.length;t++){const s=e[t];if(!Array.isArray(s)||2!==s.length||"number"!=typeof s[0]||"number"!=typeof s[1])return null}const i=new Array(4*e.length);if(t){const t=Math.round(100*(1-s))/2,o=Math.round(100*(1-r))/2,a=s>0&&s<1,h=r>0&&r<1;for(let l=0;l<e.length;l++){const c=e[l],d=n(s*(a?Math.max(0,Math.min(100,c[0])):c[0])+t),u=n(r*(h?Math.max(0,Math.min(100,c[1])):c[1])+o),p=Math.floor(d),f=Math.floor(u),m=4*l;i[m]=p,i[m+1]=Math.round(100*(d-p)),i[m+2]=f,i[m+3]=Math.round(100*(u-f))}}else for(let t=0;t<e.length;t++){const s=e[t],r=n(s[0]),o=n(s[1]),a=Math.floor(r),h=Math.floor(o),l=4*t;i[l]=a,i[l+1]=Math.round(100*(r-a)),i[l+2]=h,i[l+3]=Math.round(100*(o-h))}return i})(e,t);if(s)return s}const h=[];for(let t=0;t<e.length;t++){if(!(t in e))continue;const s=e[t];if(Array.isArray(s))for(let e=0;e<s.length;e++)e in s&&h.push(s[e]);else h.push(s)}const l=new Array(2*h.length);if(s.subType==i.SHAPE_2D_CIRCLE)if(t){const e=n(a(t.x,h[0]));l[0]=Math.floor(e),l[1]=r(e);const s=n(a(t.y,h[1]));let i;l[2]=Math.floor(s),l[3]=r(s),i=t.x===t.y?t.x*h[2]:Math.sqrt(Math.pow(100*t.x,2)+Math.pow(100*t.y,2))*(h[2]/100),l[4]=Math.floor(i),l[5]=r(i)}else{const e=n(h[0]);l[0]=Math.floor(e),l[1]=r(e);const t=n(h[1]);l[2]=Math.floor(t),l[3]=r(t);const s=h[2];l[4]=Math.round(s),l[5]=r(s)}else for(let e=0;e<h.length;e++)if(t){const s=e%2==0?t.x:t.y,i=s*o(h[e],s),a=Math.round(100*(1-s)),c=n(i+a/2);l[2*e]=Math.floor(c),l[2*e+1]=r(c)}else{const t=n(h[e]);l[2*e]=Math.floor(t),l[2*e+1]=Math.round(100*(t-Math.floor(t)))}return l},dependsOn:["subType"],unsquish:(e,{subType:t})=>{const s=new Array(e.length/2);for(let t=0;t<e.length;t+=2){const r=e[t]+e[t+1]/100;s[t/2]=r}if(t===i.SHAPE_2D_POLYGON||t===i.SHAPE_2D_LINE){const e=new Array(s.length/2);for(let t=0;t<s.length;t+=2)e[t/2]=[s[t],s[t+1]];return e}return s}};e.exports={squishCoordinates2d:h}},4167(e){const t={type:49,squish:e=>{if(e.shadow){const t="shadow";let s=t.length+4;e.shadow.blur&&(s+=2);const r=new Array(s);for(let e=0;e<t.length;e++)r[e]=t.codePointAt(e);return r[t.length]=e.shadow.color[0],r[t.length+1]=e.shadow.color[1],r[t.length+2]=e.shadow.color[2],r[t.length+3]=e.shadow.color[3],e.shadow.blur&&(r[t.length+4]=Math.floor(e.shadow.blur/10),r[t.length+5]=e.shadow.blur%10),r}},unsquish:e=>{const t=String.fromCodePoint.apply(null,e.slice(0,6)),s=e.slice(6,10);let r;e.length>10&&(r=10*e[10]+e[11]);const i={[t]:{color:s}};return r&&(i[t].blur=r),i}};e.exports={squishEffect:t}},2675(e){e.exports={squishFill:{type:53,squish:e=>[e[0],e[1],e[2],e[3]],unsquish:e=>[e[0],e[1],e[2],e[3]]}}},6578(e){e.exports={squishHandleClick:{type:50,squish:e=>e?[1]:[0],unsquish:e=>1===e[0]}}},9211(e){const t={type:43,squish:e=>{const t=e.toString();let s=new Array(12),r=0;for(;r<=12-t.length;r++)s[r]=0;for(let e=0;e<t.length;e++)s[e+r]=Number(t.charAt(e));return s},unsquish:e=>{let t=0;for(let s=0;s<e.length;s++)t+=e[s]*Math.pow(10,e.length-s-1);return Number(t)}};e.exports={squishId:t}},828(e){const t={type:51,squish:e=>{const t=new Array(e.type.length);for(let s=0;s<e.type.length;s++)t[s]=e.type.codePointAt(s);return t},unsquish:e=>({type:String.fromCodePoint.apply(null,e)})};e.exports={squishInput:t}},4433(e){e.exports={squishOnHover:{type:56,squish:e=>e?[1]:[0],unsquish:e=>1===e[0]}}},9449(e){e.exports={squishPlayerIds:{type:44,squish:e=>e,unsquish:e=>e}}},3358(e){const t=e=>Math.round(100*(e-Math.floor(e))),s={type:45,squish:e=>[Math.floor(e.x),t(e.x),Math.floor(e.y),t(e.y)],unsquish:e=>({x:e[0]+e[1]/100,y:e[2]+e[3]/100})};e.exports={squishPos:s}},303(e){const t=e=>{Math.round(100*(e-Math.floor(e)))},s={type:46,squish:e=>[Math.floor(e.x),t(e.x),Math.floor(e.y),t(e.y)],unsquish:e=>({x:e[0]+e[1]/100,y:e[2]+e[3]/100})};e.exports={squishSize:s}},6514(e,t,s){const{squishAsset:r}=s(9772),i={type:57,squish(e,t){if(!/^[A-Za-z0-9-]{1,64}$/.test(e.id||""))throw new Error("Stream requires a valid streamId");return[!1===e.audio?0:1,...r.squish({[e.id]:{pos:e.pos,size:e.size}},t)]},unsquish(e){const t=r.unsquish(e.slice(1)),s=Object.keys(t)[0];return{id:s,audio:1===e[0],pos:t[s].pos,size:t[s].size}}};e.exports={squishStream:i}},1354(e){e.exports={squishSubType:{type:55,squish:e=>[e],unsquish:e=>e[0]}}},421(e,t,s){const{hypLength:r}=s(6522),i=s(3269),{squishColor:n}=s(8339),o={type:47,squish:(e,t)=>{const s=t?e.x*t.x+Math.round(100*(1-t.x))/2:e.x,o=t?e.y*t.y+Math.round(100*(1-t.y))/2:e.y,a=[...e.align||"left"],h=[...e.font||"default"],l=[...e.text],c=new Array(12+3*(a.length+h.length+l.length));c[0]=Math.floor(s),c[1]=Math.round(100*(s-Math.floor(s))),c[2]=Math.floor(o),c[3]=Math.round(100*(o-Math.floor(o)));const d=e.size||1,u=t?d*r(t.x,t.y):d;c[4]=Math.floor(u),c[5]=Math.round(100*(u-Math.floor(u)));const p=e.color||i.BLACK,f=n.squish(p);for(let e=0;e<f.length;e++)c[6+e]=f[e];c[6+f.length]=3*a.length,c[6+f.length+1]=3*h.length;let m=0;for(let e=0;e<a.length;e++){const t=a[e].codePointAt(0).toString();let s;s=1==t.length?["00","00",`0${t}`]:2==t.length?["00","00",`${t}`]:3==t.length?["00",`0${t.charAt(0)}`,`${t.charAt(1)}${t.charAt(2)}`]:4==t.length?["00",`${t.charAt(0)}${t.charAt(1)}`,`${t.charAt(2)}${t.charAt(3)}`]:5==t.length?[`0${t.charAt(0)}`,`${t.charAt(1)}${t.charAt(2)}`,`${t.charAt(3)}${t.charAt(4)}`]:[`${t.charAt(0)}${t.charAt(1)}`,`${t.charAt(2)}${t.charAt(3)}`,`${t.charAt(4)}${t.charAt(5)}`],c[6+f.length+2+m]=Number(s[0]),c[6+f.length+2+m+1]=Number(s[1]),c[6+f.length+2+m+2]=Number(s[2]),m+=3}let g=0;for(let e=0;e<h.length;e++){const t=h[e].codePointAt(0).toString();let s;s=1==t.length?["00","00",`0${t}`]:2==t.length?["00","00",`${t}`]:3==t.length?["00",`0${t.charAt(0)}`,`${t.charAt(1)}${t.charAt(2)}`]:4==t.length?["00",`${t.charAt(0)}${t.charAt(1)}`,`${t.charAt(2)}${t.charAt(3)}`]:5==t.length?[`0${t.charAt(0)}`,`${t.charAt(1)}${t.charAt(2)}`,`${t.charAt(3)}${t.charAt(4)}`]:[`${t.charAt(0)}${t.charAt(1)}`,`${t.charAt(2)}${t.charAt(3)}`,`${t.charAt(4)}${t.charAt(5)}`];let r=6+f.length+2+3*a.length;c[r+g]=Number(s[0]),c[r+g+1]=Number(s[1]),c[r+g+2]=Number(s[2]),g+=3}let y=0;for(let e=0;e<l.length;e++){const t=l[e].codePointAt(0).toString();let s;s=1==t.length?["00","00",`0${t}`]:2==t.length?["00","00",`${t}`]:3==t.length?["00",`0${t.charAt(0)}`,`${t.charAt(1)}${t.charAt(2)}`]:4==t.length?["00",`${t.charAt(0)}${t.charAt(1)}`,`${t.charAt(2)}${t.charAt(3)}`]:5==t.length?[`0${t.charAt(0)}`,`${t.charAt(1)}${t.charAt(2)}`,`${t.charAt(3)}${t.charAt(4)}`]:[`${t.charAt(0)}${t.charAt(1)}`,`${t.charAt(2)}${t.charAt(3)}`,`${t.charAt(4)}${t.charAt(5)}`];let r=6+f.length+2+3*a.length+3*h.length;c[r+y]=Number(s[0]),c[r+y+1]=Number(s[1]),c[r+y+2]=Number(s[2]),y+=3}return c},unsquish:e=>{const t=e[0]+e[1]/100,s=e[2]+e[3]/100,r=e[4]+e[5]/100,i=e.slice(6,10),n=e[10],o=e[11],a=e.slice(12,12+n),h=e.slice(12+n,12+n+o),l=e.slice(12+n+o);let c=[];for(let e=0;e<a.length;e+=3){let t=a[e].toString();1==t.length&&(t=`0${t}`);let s=a[e+1].toString();1==s.length&&(s=`0${s}`);let r=a[e+2].toString();1==r.length&&(r=`0${r}`);const i=t+s+r;c.push(i)}const d=String.fromCodePoint.apply(null,c);let u=[];for(let e=0;e<h.length;e+=3){let t=h[e].toString();1==t.length&&(t=`0${t}`);let s=h[e+1].toString();1==s.length&&(s=`0${s}`);let r=h[e+2].toString();1==r.length&&(r=`0${r}`);const i=t+s+r;u.push(i)}const p=String.fromCodePoint.apply(null,u),f=[];for(let e=0;e<l.length;e+=3){let t=l[e].toString();1==t.length&&(t=`0${t}`);let s=l[e+1].toString();1==s.length&&(s=`0${s}`);let r=l[e+2].toString();1==r.length&&(r=`0${r}`);const i=t+s+r;f.push(i)}return{x:t,y:s,text:String.fromCodePoint.apply(null,f),size:r,color:i,align:d,font:p}}};e.exports={squishText:o}},5791(e,t,s){const{GameNode:r}=s(51),i=s(2714);e.exports={[[i.STREAM]]:r.Stream,[[i.ASSET]]:r.Asset,[[i.TEXT]]:r.Text,[[i.SHAPE_2D_POLYGON]]:r.Shape,[[i.SHAPE_2D_CIRCLE]]:r.Shape,[[i.SHAPE_2D_LINE]]:r.Shape}},2714(e){e.exports={STREAM:6,ASSET:1,TEXT:2,SHAPE_2D_POLYGON:3,SHAPE_2D_CIRCLE:4,SHAPE_2D_LINE:5}},6007(e,t,s){const{getRandomTerrain:r,getRandomStartPoint:i}=s(2553),n=e=>{for(let t=0;t<e.length;t++)for(let s=0;s<e[t].length;s++)e[t][s]={filled:e[t][s].filled,north:e[t][s].north,south:e[t][s].south,east:e[t][s].east,west:e[t][s].west}},o=(e,t,s,a,h,l=0)=>{if(0===s||3===l)return e;const c=(e=>{const t=[];return e.forEach((e,s)=>{t[s]=[],e.forEach(e=>{t[s].push({...e})})}),t})(e);r()(c,i(a,h,t),a,h,t);const d=((e,t,s,r)=>{const i=[];for(let o=0;o<s;o++)for(let s=0;s<r;s++){const r=[],a={x:o,y:s};for(;;){const s=e[a.x][a.y];if(i.findIndex(e=>e.x===a.x&&e.y===a.y)>-1||a.x===t.x&&a.y===t.y||s.filled){i.push(...r);break}if((!s.north||s.wentNorth)&&(!s.south||s.wentSouth)&&(!s.east||s.wentEast)&&(!s.west||s.wentWest))return!1;if(r.push({...a}),s.south&&!s.wentSouth)s.wentSouth=!0,a.y=a.y+1;else if(s.east&&!s.wentEast)s.wentEast=!0,a.x=a.x+1;else if(s.north&&!s.wentNorth)s.wentNorth=!0,a.y=a.y-1;else{if(!s.west||s.wentWest)return!1;s.wentWest=!0,a.x=a.x-1}}n(e)}return!0})(c,t,a,h);return d?o(c,t,s-1,a,h,0):o(e,t,s,a,h,l+1)};e.exports={terrainGenerator:(e={x:100,y:100},t={x:5,y:5},s=5)=>{const{width:r,height:i}=((e,t)=>{const s=e.x,r=e.y,i=t.x,n=t.y;return{width:Math.floor(s/i),height:Math.floor(r/n)}})(e,t);let n=((e,t)=>{const s=[],r={filled:!1,north:!0,south:!0,east:!0,west:!0};for(let i=0;i<e;i++){s[i]=[];for(let n=0;n<t;n++){const o={...r};0===i?o.west=!1:i===e-1&&(o.east=!1),0===n?o.north=!1:n===t-1&&(o.south=!1),s[i].push(o)}}return s})(r,i);const a={x:Math.floor(Math.random()*r),y:Math.floor(Math.random()*i)};return n=o(n,a,s,r,i),n}}},2553(e){const t=(e,{x:t,y:s},r,i,n)=>{t<0||t>=r||s<0||s>=i||t===n.x&&s===n.y||e[t][s].filled||(e[t][s].north&&(e[t][s-1].south=!1),e[t][s].south&&(e[t][s+1].north=!1),e[t][s].east&&(e[t+1][s].west=!1),e[t][s].west&&(e[t-1][s].east=!1),e[t][s].filled=!0,e[t][s].north=!1,e[t][s].south=!1,e[t][s].east=!1,e[t][s].west=!1)},s=[(e,{x:s,y:r},i,n,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},i,n,o),0===a?(t(e,{x:s+1,y:r},i,n,o),t(e,{x:s,y:r+1},i,n,o),t(e,{x:s+1,y:r+1},i,n,o)):1===a?(t(e,{x:s-1,y:r},i,n,o),t(e,{x:s,y:r+1},i,n,o),t(e,{x:s-1,y:r+1},i,n,o)):2===a?(t(e,{x:s,y:r-1},i,n,o),t(e,{x:s+1,y:r},i,n,o),t(e,{x:s+1,y:r-1},i,n,o)):(t(e,{x:s,y:r-1},i,n,o),t(e,{x:s-1,y:r},i,n,o),t(e,{x:s-1,y:r-1},i,n,o))},(e,{x:s,y:r},i,n,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},i,n,o),0===a?(t(e,{x:s,y:r+1},i,n,o),t(e,{x:s,y:r+2},i,n,o),t(e,{x:s,y:r+3},i,n,o)):1===a?(t(e,{x:s+1,y:r},i,n,o),t(e,{x:s+2,y:r},i,n,o),t(e,{x:s+3,y:r},i,n,o)):2===a?(t(e,{x:s-1,y:r},i,n,o),t(e,{x:s-2,y:r},i,n,o),t(e,{x:s-3,y:r},i,n,o)):(t(e,{x:s,y:r-1},i,n,o),t(e,{x:s,y:r-2},i,n,o),t(e,{x:s,y:r-3},i,n,o))},(e,{x:s,y:r},i,n,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},i,n,o),0===a?(t(e,{x:s,y:r+1},i,n,o),t(e,{x:s,y:r+2},i,n,o),t(e,{x:s+1,y:r+2},i,n,o)):1===a?(t(e,{x:s+1,y:r},i,n,o),t(e,{x:s+2,y:r},i,n,o),t(e,{x:s+2,y:r-1},i,n,o)):2===a?(t(e,{x:s-1,y:r},i,n,o),t(e,{x:s-2,y:r},i,n,o),t(e,{x:s-2,y:r+1},i,n,o)):(t(e,{x:s,y:r-1},i,n,o),t(e,{x:s,y:r-2},i,n,o),t(e,{x:s-1,y:r-2},i,n,o))},(e,{x:s,y:r},i,n,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},i,n,o),0===a?(t(e,{x:s,y:r+1},i,n,o),t(e,{x:s-1,y:r+1},i,n,o),t(e,{x:s-1,y:r+2},i,n,o)):1===a?(t(e,{x:s+1,y:r},i,n,o),t(e,{x:s+1,y:r+1},i,n,o),t(e,{x:s+2,y:r+1},i,n,o)):2===a?(t(e,{x:s-1,y:r},i,n,o),t(e,{x:s-1,y:r+1},i,n,o),t(e,{x:s-2,y:r+1},i,n,o)):(t(e,{x:s,y:r-1},i,n,o),t(e,{x:s-1,y:r-1},i,n,o),t(e,{x:s-1,y:r-2},i,n,o))}];e.exports={getRandomTerrain:()=>s[Math.floor(Math.random()*s.length)],getRandomStartPoint:(e,t,s)=>{const r={x:Math.floor(Math.random()*e),y:Math.floor(Math.random()*t)};for(;r.x===s.x&&r.y===s.y;)r.x=Math.floor(Math.random()*e),r.y=Math.floor(Math.random()*t);return r}}},8408(e){const t=(e,s,r,i=[])=>{if(!r||r(e)&&e.node.id!==s.node.id){const t=e.node.text,r=e.node.coordinates2d||[[t.x,t.y],[t.x,t.y],[t.x,t.y],[t.x,t.y],[t.x,t.y]],n=s.node.coordinates2d,o=r[0][0],a=r[1][0],h=n[0][0],l=n[1][0],c=r[0][1],d=r[2][1],u=n[0][1],p=n[2][1];l<o||a<h||c>p||u>d||i.push(e)}for(const n in e.node.children)t(e.node.children[n],s,r,i);return i};e.exports={checkCollisions:(e,s,r=null)=>t(e,s,r)}},6522(e){e.exports={hypLength:(e,t)=>Math.sqrt(Math.pow(e,2)+Math.pow(t,2)),getFractional:e=>Math.round(100*(e-Math.floor(e)))}},8926(e){e.exports={triangle:(e,t,s,r,i,n)=>[[e,t],[s,r],[i,n],[e,t]],rectangle:(e,t,s,r)=>[[e,t],[e+s,t],[e+s,t+r],[e,t+r],[e,t]]}},1924(e,t,s){const{GameNode:r}=s(51),i=s(683),n=s(8926),o=s(8408),a=s(3269);e.exports={getView:(e,t,s,h={},l={})=>{const c=o.checkCollisions(e,{node:{coordinates2d:n.rectangle(t.x,t.y,t.w,t.h)}},t=>t.node.id!==e.node.id),d=new r.Shape({shapeType:i.POLYGON,coordinates2d:n.rectangle(0,0,0,0),fill:a.COLORS.BLACK}),u=[];return c.length>0&&c.forEach(e=>{const r=[],i=[],n=e.node.coordinates2d||[[e.node.text.x,e.node.text.y],[e.node.text.x,e.node.text.y],[e.node.text.x,e.node.text.y],[e.node.text.x,e.node.text.y],[e.node.text.x,e.node.text.y]];for(let s in n){const o=n[s],a=o[0],c=o[1];let d=Math.max(Math.min(a-t.x,100),0),u=Math.max(Math.min(c-t.y,100),0);d=(l.x||1)*d,u=(l.y||1)*u;const p=!h.filter||h.filter(e);p&&(h.x&&(d+=h.x),h.y&&(u+=h.y)),d<0?d=0:d>100&&(d=100),u<0?u=0:u>100&&(u=100),r.push([d,u]);let f=(l.x||1)*(a-t.x),m=(l.y||1)*(c-t.y);p&&(h.x&&(f+=h.x),h.y&&(m+=h.y)),i.push([f,m])}{const t=e.clone({handleClick:null===e.node.handleClick||void 0===e.node.handleClick?null:e.node.handleClick,id:e.node.id});if(r&&r.length&&(t.node.text&&(t.node.text.x=r[0][0],t.node.text.y=r[0][1]),r.length&&(t.node.coordinates2d=r),t.node.asset)){const e=t.node.coordinates2d[0],s=t.node.coordinates2d[1],r=t.node.coordinates2d[2],n=s[0]-e[0],o=r[1]-s[1],a=Object.values(t.node.asset)[0];a.pos.x=e[0],a.pos.y=e[1],a.size.x=n,a.size.y=o;const h=i[0],l=i[2],c=l[0]-h[0],d=l[1]-h[1];c>0&&(a.cropLeft=100*Math.max(0,(0-h[0])/c),a.cropRight=100*Math.max(0,(l[0]-100)/c)),d>0&&(a.cropTop=100*Math.max(0,(0-h[1])/d),a.cropBottom=100*Math.max(0,(l[1]-100)/d))}t.node.playerIds=s||[],u.push(t)}}),u.forEach(e=>d.addChild(e)),d}}},5305(e,t,s){const{packAssetBundle:r}=s(3735);e.exports={packAssetBundle:r}},6899(e,t,s){const{describeMedia:r}=s(3947),i=e=>{let t="";for(let s=0;s<e.length;s+=32768)t+=String.fromCharCode.apply(null,e.slice(s,s+32768));return t};e.exports=class{constructor(){this.assets={},this.imageCache={},this.audioCtx=null,this.mediaPlayers=new Set,this.mediaUnlocked=!1,this.onAssetReady=null}_notifyReady(){"function"==typeof this.onAssetReady&&this.onAssetReady()}unlockAudio(){this.mediaUnlocked=!0;for(const e of this.mediaPlayers)e.unlock();this.audioCtx||(this.audioCtx=new(window.AudioContext||window.webkitAudioContext)),"suspended"===this.audioCtx.state&&this.audioCtx.resume();for(const e in this.assets){const t=this.assets[e];if("audio"===t.type&&!t.decoded&&!t.decoding){t.decoding=!0;const s=e=>{t.decoding=!1,console.warn("Unable to decode audio:",e)};try{this.audioCtx.decodeAudioData(t.data.slice(0),s=>{this.assets[e]===t&&(t.data=s,t.decoded=!0,t.decoding=!1,this._notifyReady())},s)}catch(e){s(e)}}}}storeAssets(e){let t=0;for(;e&&t<e.length&&1===e[t];){const s=e[t+1],r=String.fromCharCode.apply(null,e.slice(t+2,t+12)),i=parseInt(r,36);if(!Number.isFinite(i)||i<=0)break;const n=e.slice(t+12,t+12+32),o=String.fromCharCode.apply(null,n.filter(e=>e)),a=e.slice(t+12+32,t+12+i),h=1===s?"image":2===s?"audio":3===s?"font":4===s?"video":null;h&&this.storeRawAsset(o,h,a),t+=12+i}}storeRawAsset(e,t,s){const n=s instanceof Uint8Array||s instanceof Uint8ClampedArray?s:Uint8Array.from(s),o=this.assets[e];if(o?.url&&URL.revokeObjectURL(o.url),"image"===t){const t=r(n).contentType||(e=>{if(e.length>3&&137===e[0]&&80===e[1]&&78===e[2]&&71===e[3])return"image/png";if(e.length>2&&71===e[0]&&73===e[1]&&70===e[2])return"image/gif";if(e.length>11&&87===e[8]&&69===e[9]&&66===e[10]&&80===e[11])return"image/webp";const t=i(e.subarray(0,1024)).replace(/^\xEF\xBB\xBF/,"");return/^\s*(?:<\?xml\b[^?]*\?>\s*)?<svg\b/i.test(t)?"image/svg+xml":"image/jpeg"})(n);this.assets[e]={type:"image",data:`data:${t};base64,`+btoa(i(n))},delete this.imageCache[e],this._notifyReady()}else if("audio"===t)if(this.audioCtx)try{this.audioCtx.decodeAudioData(n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength),t=>{this.assets[e]={type:"audio",data:t,decoded:!0},this._notifyReady()},e=>{console.warn("Unable to decode audio:",e)})}catch(e){console.warn("Unable to decode audio:",e)}else this.assets[e]={type:"audio",data:n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength),decoded:!1};else if("video"===t){const t=r(n);this.assets[e]={type:"video",data:new Blob([n],{type:t.contentType||"video/mp4"}),url:null},this._notifyReady()}else if("font"===t)try{new FontFace(e,n).load().then(t=>{document.fonts.add(t),this.assets[e]={type:"font",data:t,name:e},this._notifyReady()}).catch(e=>{console.warn("Unable to load font:",e)})}catch(e){console.warn("Unable to load font:",e)}}getImage(e){if(this.imageCache[e]&&"loading"!==this.imageCache[e])return this.imageCache[e];if(!this.imageCache[e]&&this.assets[e]&&"image"===this.assets[e].type){const t=this.assets[e],s=new Image;this.imageCache[e]="loading",s.onload=()=>{this.assets[e]===t&&(this.imageCache[e]=s,this._notifyReady())},s.src=t.data}return null}destroy(){this.liveMedia?.destroy();for(const e of[...this.mediaPlayers])e.destroy();for(const e of Object.values(this.assets))e.url&&URL.revokeObjectURL(e.url);this.audioCtx&&(this.audioCtx.close().catch(()=>{}),this.audioCtx=null),this.assets={},this.imageCache={}}}},9630(e,t,s){const{squishMap:r,DEFAULT_VERSION:i}=s(9732),{normalizePath:n,resolveInFiles:o}=s(3735);e.exports={loadGameClass:({files:e,entryPoint:t})=>{if(!e||!t)throw new Error("loadGameClass requires { files, entryPoint }");const i={};for(const t of Object.keys(e))i[n(t)]=e[t];const a={},h=new Set,l=e=>{if(a[e])return a[e].exports;const t=e.includes("/")?e.slice(0,e.lastIndexOf("/")):"",s=s=>{const n=/^squish-(\d+)$/.exec(s);if(n){if(h.add(n[1]),h.size>1)throw new Error("Mixed Squish runtimes are unsupported");const e=r[n[1]];if(e)return e;throw new Error("Unsupported Squish runtime: "+s)}if(s.startsWith("./")||s.startsWith("../")){const r=o(i,t,s);if(r)return l(r);throw new Error("Cannot resolve require('"+s+"') from "+e+" — not in the game source map")}throw new Error("Game tried to require('"+s+"') — local games may only require their squish version and their own files")},n={exports:{}};a[e]=n;const c=i[e];if(e.endsWith(".json"))try{return n.exports=JSON.parse(c),n.exports}catch(t){throw delete a[e],new Error("Invalid JSON module "+e+": "+t.message)}const d=new Function("module","exports","require","__filename","__dirname",c);try{d(n,n.exports,s,e,t)}catch(t){throw delete a[e],t}return n.exports},c=n(t);if(!Object.prototype.hasOwnProperty.call(i,c))throw new Error('Entry point "'+t+'" not found in game source map');const d=l(c);if(h.size){const{normalizeMetadata:e,bindRuntimeMetadata:t}=s(2439),r="function"==typeof d.metadata?d.metadata():{};t(d,e(r,{runtime:[...h][0],legacy:!0}))}return d}}},1768(e,t,s){const r=s(6899),i=s(549),n=s(7868);e.exports={GameView:class{constructor({container:e,assetManager:t,send:s,gamepad:o,onAssetReady:a,onLayout:h,onResize:l}){this.container=e,this.onLayout=h,this.onResize=l,e.innerHTML="",Object.assign(e.style,{position:e.style.position||"relative",overflow:"hidden",background:"#000"}),this.canvas=document.createElement("canvas"),this.canvas.tabIndex=-1,Object.assign(this.canvas.style,{display:"block",position:"absolute",margin:"0",cursor:"default",webkitTapHighlightColor:"transparent",webkitTouchCallout:"none",webkitUserSelect:"none",userSelect:"none",touchAction:"none"}),this.cursor=null,this.cursorOverride=null,this._cursorRaster=null,e.appendChild(this.canvas),this.ownsAssets=!t,this.assetManager=t||new r,this.ownsAssets&&(this.assetManager.onAssetReady=a),this.renderer=new i(this.canvas,this.assetManager),this.inputHandler=new n(this.canvas,s,()=>this.renderer.thingIndices,this.assetManager,o),this.inputHandler.attach(),window.ResizeObserver&&(this._resizeObserver=new window.ResizeObserver(()=>{this.aspectRatio&&!this.destroyed&&this.resize(this.aspectRatio)}),this._resizeObserver.observe(e))}setCursor(e){this.destroyed||(this.cursor?.assetKey===e?.assetKey&&this.cursor?.size?.width===e?.size?.width&&this.cursor?.size?.height===e?.size?.height||(this._cursorRaster=null),this.cursor=e&&{assetKey:e.assetKey,hotspot:{...e.hotspot},...e.size?{size:{...e.size}}:{},...void 0!==e.pointerLock?{pointerLock:e.pointerLock}:{}},this.inputHandler.setPointerLockSuspended(!1===e?.pointerLock),this.refreshCursor())}setCursorOverride(e){this.destroyed||(this.cursorOverride=e,this.refreshCursor())}refreshCursor(){if(!this.destroyed)if(this._refreshingCursor)this._cursorRefreshPending=!0;else{this._refreshingCursor=!0;try{do{this._cursorRefreshPending=!1;let e=this.cursorOverride||"default";const t=this.cursor&&this.assetManager.assets[this.cursor.assetKey];if(this._cursorRaster?.data!==t?.data&&(this._cursorRaster=null),!this.cursorOverride&&"image"===t?.type&&"string"==typeof t.data){const s=this._cursorImageUrl(t);if(s){const{x:t,y:r}=this.cursor.hotspot;e=`url("${s}") ${t} ${r}, default`}}this.canvas.style.cursor!==e&&(this.canvas.style.cursor=e)}while(this._cursorRefreshPending&&!this.destroyed)}finally{this._refreshingCursor=!1}}}_cursorImageUrl(e){if(!this.cursor.size)return e.data;const t=this.assetManager.getImage(this.cursor.assetKey);if(!t)return null;const{width:s,height:r}=this.cursor.size,i=this._cursorRaster;if(i?.data===e.data&&i.image===t&&i.width===s&&i.height===r)return i.url;const n=this._cursorRaster={data:e.data,image:t,width:s,height:r,url:null};try{const e=document.createElement("canvas");e.width=s,e.height=r,e.getContext("2d").drawImage(t,0,0,s,r),n.url=e.toDataURL("image/png")}catch(e){}return n.url}resize(e){if(this.destroyed||!Number.isFinite(e?.x)||!Number.isFinite(e?.y)||e.x<=0||e.y<=0)return;const t=this.aspectRatio?.x!==e.x||this.aspectRatio?.y!==e.y;this.aspectRatio={x:e.x,y:e.y};const s=this.container.homegamesToolbar||this.container.closest?.(".hg-session-frame")?.querySelector?.(".hg-session-bar")?.homegamesToolbar;if(s?.setAspectRatio?.(this.aspectRatio),t&&this.onLayout?.({...this.aspectRatio}),this.destroyed)return;const r=this.container.clientWidth||window.innerWidth,i=this.container.clientHeight||window.innerHeight,n=r*e.y/e.x<=i,o=n?r:Math.floor(i*e.x/e.y),a=n?Math.floor(r*e.y/e.x):i,h=this.canvas.width!==2*o||this.canvas.height!==2*a;h&&(this.canvas.width=2*o,this.canvas.height=2*a),this.canvas.style.width=o+"px",this.canvas.style.height=a+"px",this.canvas.style.left=Math.floor((r-o)/2)+"px",this.canvas.style.top=Math.floor((i-a)/2)+"px",this.inputHandler.clientWidth=o,this.inputHandler.clientHeight=a,h&&this.onResize?.()}destroy(){this.destroyed||(this.destroyed=!0,this._resizeObserver?.disconnect(),this.cursor=null,this.cursorOverride=null,this._cursorRaster=null,this.canvas.style.cursor="default",this.inputHandler.detach(),this.renderer.stopAllSounds(),this.ownsAssets&&(this.assetManager.onAssetReady=null,this.assetManager.destroy()),this.canvas.remove())}},FrameLoop:class{constructor(e){this.paint=e,this.running=!1,this.id=null}start(){this.running||(this.running=!0,this.tick())}tick(){this.id=null,this.running&&(this.paint(),this.running&&(this.id=requestAnimationFrame(()=>this.tick())))}stop(){this.running=!1,null!==this.id&&cancelAnimationFrame(this.id),this.id=null}},getClientInfo:()=>{const e=navigator.userAgent;let t="desktop";/(tablet|ipad|playbook|silk)|(android(?!.*mobi))/i.test(e)?t="tablet":/Mobile|iP(hone|od)|Android|BlackBerry|IEMobile|Kindle|Silk-Accelerated|(hpw|web)OS|Opera M(obi|ini)/.test(e)?t="mobile":navigator.maxTouchPoints>2&&(t="tablet");const s={deviceType:t};return window.innerWidth&&window.innerHeight&&(s.aspectRatio=window.innerWidth/window.innerHeight),s}}},5562(e,t,s){const{Homepad:r,mapGamepad:i}=s(1011),n=s(6260);e.exports=class{constructor(e,t={}){this.send=e,this.index=t.index??null,this.homepad=new r(t),this.onError=t.onError||(e=>console.warn("Gamepad input:",e)),this.previous=new Map,this.nextPoll=0,this.lastPoll=null,this.errorMessage=null}tick(e=Date.now()){if(e+.001<this.nextPoll)return;const t=null===this.lastPoll?1/30:Math.min(.1,Math.max(0,(e-this.lastPoll)/1e3));let s;this.lastPoll=e;try{if(s=this.homepad.getGamepads().filter(e=>null===this.index||e.index===this.index),this.homepad.error)throw this.homepad.error;this.errorMessage=null}catch(e){return this.release(),this.errorMessage!==e.message&&this.onError(e),void(this.errorMessage=e.message)}const r=Math.max(1e3/30,1e3*s.length/60),i=Math.max(0,e-this.nextPoll);this.nextPoll=e+r-i%r;const n=new Map(s.map(e=>[e.index,e]));for(const[e,t]of this.previous)n.has(e)&&n.get(e).id===t.id||this._release(t);for(const e of s)this.send(JSON.stringify({type:"input",gamepad:!0,gamepadIndex:e.index,connected:!0,deltaTime:t,input:e.state}));this.previous=n}_release(e){this.send(JSON.stringify({type:"input",gamepad:!0,gamepadIndex:e.index,connected:!1,deltaTime:0,input:i({buttons:[],axes:[]},n)}))}release(){for(const e of this.previous.values())this._release(e);this.previous.clear(),this.nextPoll=0,this.lastPoll=null}setIndex(e){this.release(),this.index=e}}},9225(e){e.exports=function(e,t=()=>{}){let s=null,r=null,i=!1;const n=async e=>{const t=await fetch("/household-rooms",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),keepalive:!0});if(!t.ok)throw new Error("Unable to list this game on your home server");return t.json()};return{onRoom(o){i=!1;const a=new URLSearchParams(new URL(o).hash.slice(1)),h=r=n({gameKey:e.gameKey,versionId:e.versionId,roomId:a.get("room"),invite:a.get("invite")});h.then(e=>{i||r!==h?n({...e,remove:!0}).catch(()=>{}):s=e}).catch(t)},onHeartbeat(e){s&&n({...s,playerCount:e}).catch(e=>{s=null,t(e)})},onEnd(){i=!0,r=null,s&&n({...s,remove:!0}).catch(()=>{}),s=null}}}},9311(e){const t=["image/jpeg","image/webp"];let s=null;const r=(e,t)=>{if("function"==typeof OffscreenCanvas)return new OffscreenCanvas(e,t);const s=document.createElement("canvas");return s.width=e,s.height=t,s},i=(e,t,s)=>e.convertToBlob?e.convertToBlob({type:t,quality:s}):new Promise((r,i)=>{e.toBlob(e=>{e?r(e):i(new Error("Canvas encoding failed"))},t,s)}),n=(e,t)=>{if(!e)return e;const s="image/webp"===t?".webp":".jpg",r=e.lastIndexOf(".");return(r>0?e.slice(0,r):e)+s},o=(e,t,s)=>{const i=Math.max(16,Math.round(e.width*t)),n=Math.max(16,Math.round(e.height*t)),o=r(i,n),a=o.getContext("2d");return s&&(a.fillStyle="#ffffff",a.fillRect(0,0,i,n)),a.drawImage(e.source,0,0,i,n),o};e.exports={fitImageToSize:async(e,a,h={})=>{if(!e||"number"!=typeof e.size)throw new Error("Expected a Blob or File");if(!(a>0))throw new Error("maxBytes must be a positive number");const l=h.fileName||e.name||null,c=e.type||null;if(e.size<=a)return{blob:e,contentType:c,fileName:l,resized:!1};const d=await(async e=>{if("function"==typeof createImageBitmap)try{const t=await createImageBitmap(e);return{source:t,width:t.width,height:t.height,close:()=>t.close&&t.close()}}catch(e){}if("undefined"==typeof document)throw new Error("Not decodable as an image");return new Promise((t,s)=>{const r=URL.createObjectURL(e),i=new Image;i.onload=()=>{URL.revokeObjectURL(r),t({source:i,width:i.naturalWidth,height:i.naturalHeight,close:()=>{}})},i.onerror=()=>{URL.revokeObjectURL(r),s(new Error("Not decodable as an image"))},i.src=r})})(e);try{const e=-1!==t.indexOf(c),h=e?c:await(async()=>{if(null!==s)return s;const e=await i(r(1,1),"image/webp",.8).catch(()=>null);return s=!!e&&"image/webp"===e.type,s})()?"image/webp":"image/jpeg";let u=.85,p=1,f=null;for(let e=0;e<10;e++){const e=o(d,p,"image/jpeg"===h),t=await i(e,h,u);if((!f||t.size<f.size)&&(f=t),t.size<=a)break;if(u>.6)u=Math.max(.6,u-.15);else{if(Math.min(d.width,d.height)*p<=16)break;p*=Math.max(.3,.9*Math.sqrt(a/t.size))}}if(!f||f.size>a)throw new Error(`Could not fit image into ${a} bytes`);return{blob:f,contentType:h,fileName:e?l:n(l,h),resized:!0}}finally{d.close()}}}},44(e,t,s){const{ProjectTransferClient:r,CONTROL:i,CHUNK:n}=s(4394),o=s(1525),a=s(4849),{loadLocalGame:h,loadHomeGame:l}=s(7348),{GameView:c,FrameLoop:d,getClientInfo:u}=s(1768),p=s(4334),{squishMap:f,DEFAULT_VERSION:m}=s(9732),g=s(814),y=s(3598),{RtcHost:v,createRtcTransport:w,readInvitation:x}=s(4454),{createSaveStore:b}=s(7699),{CURSOR_OPCODE:E,decodeCursor:S}=s(5199);class k{constructor(e){this.containerId=e.containerId,this.wsUrl=e.wsUrl,this.workerUrl=e.workerUrl||null,this.transportFactory=e.transport||null,this.transport=null,this.onReady=e.onReady||(()=>{}),this.onClose=()=>{this._connectionFailed||this._setFrameStatus("Disconnected from the game.",{attention:!0}),e.onClose?.()},this.onError=t=>{this._connectionFailed=!0,this._setFrameStatus(t?.message||"Unable to connect to the game.",{attention:!0}),e.onError?.(t)},this.onAspectRatio=e.onAspectRatio||(()=>{}),this.onSharingStatus=e.onSharingStatus||(()=>{}),this._toolbarSharingLink=e=>this.getSharingLink(e),this.onSaveData=e.onSaveData||(()=>{}),this.onLocalPlayRedirect=e.onLocalPlayRedirect||null,this.spectating=e.spectating||!1,this.requestedGame=e.requestedGame||null,this.gamepadOptions=e.gamepad??{},this.saveStore=e.saveStore||b(),this.platform=e.platform,this._defaultShareOptions=e.share&&"object"==typeof e.share?e.share:null,this._playerProfile=s(4367).profile(window),this.playerName=void 0===e.playerName?this._playerProfile.get():this._playerProfile.set(e.playerName),this.showChrome=!1!==e.chrome,this.onSessionStatus=e.onSessionStatus||(()=>{}),this.localHome=e.localHome,this.ws=null,this.worker=null,this.view=null,this.playerId=null,this.aspectRatio=null,this.bezelInfo={x:0,y:0},this.squishVersion=null,this.unsquish=null,this.currentBuf=null,this._frameDirty=!1,this._loop=new d(()=>this._paintFrame()),this._resizeHandler=null,this._sessions=new o({remote:{start:()=>this._startRemote(),stop:()=>this._stopRemote()},loadLocal:e.loadLocalGame||l,mountLocal:t=>{if(this._shareOptions="function"==typeof e.share?e.share(t):e.share,!this.showChrome)return{containerId:this.containerId,dispose(){}};const s=a(this.containerId,t.name||t.gameKey,!1===e.localHome?null:"string"==typeof e.localHome?e.localHome:()=>this.exitLocalGame(),this._shareOptions?{getSharingLink:this._toolbarSharingLink,private:"public"!==this._shareOptions.visibility,onVisibility:this._shareOptions.room?e=>this._getRtcHost().setVisibility(e):null,onOpen:()=>this._localSession?.inputHandler?.detach(),onClose:()=>this._localSession?.inputHandler?.attach()}:null,{author:t.author,onExports:()=>this.viewExports(),onOpen:()=>this.setInputEnabled(!1),onClose:()=>this.setInputEnabled(!0)});return this._configureToolbar(s.toolbar),s},createLocal:t=>new g({...t,playerName:this.playerName,gamepad:this.gamepadOptions,platform:e.platform,saveStore:this.saveStore,onAspectRatio:this.onAspectRatio,onSaveData:this.onSaveData,onError:this.onError,onReady:e=>{const t=1===this._localSession?.maxPlayers;this._configureSharing(this._localChrome?.toolbar),this.onReady(e),this._shareOptions?.autoStart&&!t&&this._getRtcHost().share().catch(e=>this._localChrome?.setStatus?.(`Not available to join: ${e.message}. Use Invite to retry.`))}}),onError:this.onError})}start(){this._sessions.start()}stop(){this.disposeSharing(),this._shareDialog?.dispose(),this._shareDialog=null,this._switchingManual||(this._manualPairing?.dispose(),this._manualPairing=null),this._sessions.stop()}get _localSession(){return this._sessions.local}get _localChrome(){return this._sessions.chrome}_getRtcHost(){const e=this._localSession;if(!e)throw new Error("The game is still loading");return this._rtcHost&&this._rtcHost.session===e||(this._rtcHost=new v(e,{...this._shareOptions,onStatus:e=>{this._localChrome?.setStatus?.(e),this.onSessionStatus(e)}})),this._rtcHost}getNetworkStats(){return this._localSession&&this._rtcHost?.getStats()||this.transport?.getStats?.()||Promise.resolve(null)}requestGameCopy(){return this._requestFile()}listExports(){return this.spectating&&!this._localSession?Promise.reject(new Error("Join as a player to view exports")):this._requestFile({kind:"export-list"})}readExport(e){return this.spectating&&!this._localSession?Promise.reject(new Error("Join as a player to save exports")):this._requestFile({kind:"export",name:e})}async viewExports(){if(this._exportsOpen)return;this._exportsOpen=!0;const e=this._localSession?.inputHandler||this.inputHandler;e?.detach();try{this.platform?.viewExports?await this.platform.viewExports():(this._exportsViewer=s(97).createExportsViewer(window,{list:()=>this.listExports(),read:e=>this.readExport(e)}),await this._exportsViewer.result)}catch(e){this.onError(e)}finally{this._exportsViewer=null,this._exportsOpen=!1,e&&(e===this._localSession?.inputHandler||e===this.inputHandler&&this.rendering)&&e.attach()}}_requestFile(e){return this._projectTransfer||(this._projectTransfer=new r({importArchive:e=>k.PortableProject.importArchive(e),send:e=>{const t=this._localSession;if(t){if(!t.runtime||t.frozen||!t.players.some(e=>e.playerId===t.playerId&&e.dispatcher))throw new Error("The game is not ready. Try again once it has loaded.");const s=this._projectTransfer;queueMicrotask(()=>t.handleProjectMessage(t.playerId,e,e=>{queueMicrotask(()=>s.receive(e))}))}else this._send(JSON.stringify(e))}})),this._projectTransfer.request(e)}getShareLink(){if(this._localSession&&this._shareOptions)return this._getRtcHost().share();if(this.transport?.getShareLink)return this.transport.getShareLink();throw new Error("This session is not available to share")}getSharingLink(e){return this._localSession||this.view?(this._playerSharing||(this._playerSharing=p({...this._shareOptions,getInvitation:()=>this.getShareLink(),getProject:async()=>(await this.requestGameCopy()).project,onStatus:(e,t="copy")=>{this._playerToolbar()?.setSharingStatus?.(e,t),this.onSharingStatus(e,t)}})),this._playerSharing.getLink(e)):Promise.reject(new Error("The game is still loading. Try again once it is ready."))}disposeSharing(){this._playerSharing?.dispose(),this._playerSharing=null}_configureSharing(e){e&&(this._shareOptions||this.transport?.getShareLink?e.setSharing({multiplayer:1!==this._localSession?.maxPlayers,getLink:this._toolbarSharingLink}):e.setSharing?.(null))}setInputEnabled(e){const t=this._localSession?.inputHandler||this.inputHandler;e?(t?.attach(),t?.canvas.focus?.({preventScroll:!0})):t?.detach()}_playerToolbar(){return this._sessions?.chrome?.toolbar||this._remoteChrome?.toolbar||this.container?.closest?.(".hg-session-frame")?.querySelector?.(".hg-session-bar")?.homegamesToolbar}_setFrameStatus(e,t){this._playerToolbar()?.setStatus(e,t)}getPlayerName(){return this.playerName}setPlayerName(e){const t=this._playerProfile.set(e);return this.playerName=t,this._localSession?this._localSession.setPlayerName(this._localSession.playerId,t):this.spectating||this._send(JSON.stringify({type:"player-info",name:t})),this.platform?.setState?.({playerName:t}),t}showShare(){this._shareDialog||(this._shareDialog=s(172)({container:document.body,getLink:()=>this.getShareLink(),onOpen:()=>this.setInputEnabled(!1),onClose:()=>this.setInputEnabled(!0)})),this._shareDialog.show()}_configureToolbar(e){e&&(e.setPlayerName(this.playerName,e=>this.setPlayerName(e)),e.setAction("manual-connect",{label:"Manual connection",run:()=>{this._manualPairing||(this._manualPairing=k.createManualPairing({container:document.body,getSession:()=>this._localSession,onOpen:()=>this.setInputEnabled(!1),onClose:()=>this.setInputEnabled(!0),join:e=>{this._switchingManual=!0,this.stop(),this.transportFactory=e,this.start(),this._switchingManual=!1}})),this._manualPairing.show()}}))}get canvas(){return this.view?.canvas||null}get container(){return this.view?.container||null}get renderer(){return this.view?.renderer||null}get assetManager(){return this.view?.assetManager||null}get inputHandler(){return this.view?.inputHandler||null}get rendering(){return this._loop.running}_startRemote(){this._connectionFailed=!1,this._shareOptions=this._defaultShareOptions;let e=document.getElementById(this.containerId);if(!e)return void this.onError(new Error("Container element not found: #"+this.containerId));const t=e.closest(".hg-session-frame")?.querySelector(".hg-session-bar");this.showChrome&&t?this._removeExportsButton=a.addExportsButton(t,()=>this.viewExports()):this.showChrome&&(this._remoteChrome=a(this.containerId,"Homegames","string"==typeof this.localHome?this.localHome:null,null,{status:"Connected game",onExports:()=>this.viewExports(),onOpen:()=>this.setInputEnabled(!1),onClose:()=>this.setInputEnabled(!0)}),e=this._remoteChrome.gameArea),this.showChrome&&this._configureToolbar((t||this._remoteChrome?.bar)?.homegamesToolbar),this.view=new c({container:e,send:e=>this._send(e),gamepad:this.gamepadOptions,onAssetReady:()=>{this._frameDirty=!0,this.view?.refreshCursor()},onLayout:e=>{this.platform?.setState?.({aspectRatio:e}),this.onAspectRatio(e)},onResize:()=>{this._frameDirty=!0}}),this._resizeHandler=()=>{this._initCanvas(),this._sendClientInfo()},window.addEventListener("resize",this._resizeHandler);const s=this._mediaClient=new y({container:e,platform:this.platform,assets:this.assetManager,send:e=>this._send(JSON.stringify(e)),publish:(e,t)=>this.transport?.addMedia?.(e,t),unpublish:e=>this.transport?.removeMedia?.(e)});if(this.transportFactory){const e=this._transportGeneration=(this._transportGeneration||0)+1,t=()=>e===this._transportGeneration;this.transport=this.transportFactory({onOpen:()=>{t()&&this._send(JSON.stringify({type:"ready",playerName:this.playerName,media:1,recording:2,clientInfo:{clientInfo:u()}}))},onMessage:e=>{t()&&e instanceof ArrayBuffer&&this._handleBinaryMessage(new Uint8ClampedArray(e))},onMedia:e=>{t()&&s.receive(e)},onTrack:e=>{t()&&s.attach(e)},onError:e=>{t()&&this.onError(e)},onClose:()=>{t()&&(this._loop.stop(),this.view?.setCursor(null),this.inputHandler?.setPointerLockEnabled(!1),this.inputHandler?.detach(),this.renderer?.stopAllSounds(),s.destroy(),this.onClose())}})}else this.workerUrl?this._connectWorker():this._connectInline()}_stopRemote(){if(this._playerToolbar()?.setSharing?.(null),this.disposeSharing(),this._exportsViewer?.close(),this.platform?.closeExports?.(),this._removeExportsButton?.(),this._removeExportsButton=null,this._mediaClient?.destroy(),this._mediaClient=null,this._projectTransfer?.close(),this._projectTransfer=null,this._transportGeneration=(this._transportGeneration||0)+1,this.inputHandler?.setPointerLockEnabled(!1),this.transport?.close(),this.transport=null,this._loop.stop(),this.worker&&(this.worker.postMessage({type:"close"}),this.worker.terminate(),this.worker=null),this.ws){const e=this.ws;this.ws=null,e.onopen=e.onmessage=e.onclose=e.onerror=null,e.close()}this.view?.destroy(),this.view=null,this._remoteChrome?.dispose(),this._remoteChrome=null,this._resizeHandler&&(window.removeEventListener("resize",this._resizeHandler),this._resizeHandler=null)}_send(e){this.transport?this.transport.send(e):this.worker?this.worker.postMessage({type:"send",data:e}):this.ws&&this.ws.readyState===WebSocket.OPEN&&this.ws.send(e)}_sendClientInfo(){this._send(JSON.stringify({clientInfo:u()}))}_connectInline(){try{this.ws=new WebSocket(this.wsUrl),this.ws.binaryType="arraybuffer"}catch(e){return void this.onError(e)}const e=this.ws;this.ws.onopen=()=>{if(this.ws!==e)return;const t={type:"ready",playerName:this.playerName,spectating:this.spectating,clientInfo:{clientInfo:u()}};this.requestedGame&&(t.clientInfo.requestedGame=this.requestedGame),this.ws.send(JSON.stringify(t))},this.ws.onmessage=t=>{this.ws===e&&t.data instanceof ArrayBuffer&&this._handleBinaryMessage(new Uint8ClampedArray(t.data))},this.ws.onclose=()=>{this.ws===e&&(this._loop.stop(),this.view?.setCursor(null),this.inputHandler?.setPointerLockEnabled(!1),this.onClose())},this.ws.onerror=t=>{this.ws===e&&this.onError(t)}}_connectWorker(){try{this.worker=new Worker(this.workerUrl)}catch(e){return console.warn("Failed to create Web Worker, falling back to inline WebSocket:",e),void this._connectInline()}const e=this.worker;this.worker.onmessage=t=>{if(this.worker!==e)return;const s=t.data;s instanceof ArrayBuffer?this._handleBinaryMessage(new Uint8ClampedArray(s)):s&&"open"===s.type?this.worker.postMessage({type:"sendReady",playerName:this.playerName,id:this.playerId,spectating:this.spectating,clientInfo:{clientInfo:u()},requestedGame:this.requestedGame}):s&&"close"===s.type?(this._loop.stop(),this.view?.setCursor(null),this.inputHandler?.setPointerLockEnabled(!1),this.onClose()):s&&"error"===s.type&&this.onError(new Error(s.message))},this.worker.onerror=t=>{this.worker===e&&this.onError(t)},this.worker.postMessage({type:"connect",wsUrl:this.wsUrl})}_reconnect(e){this._playerToolbar()?.setSharing?.(null),this.disposeSharing(),this._connectionFailed=!1,this._exportsViewer?.close(),this.platform?.closeExports?.(),this._projectTransfer?.close(),this._projectTransfer=null,this.wsUrl=e,this._loop.stop(),this.currentBuf=null,this.view?.setCursor(null),this.inputHandler?.setPointerLockEnabled(!1),this.renderer&&(this.renderer.stopAllSounds(),this.renderer.thingIndices=[]),this.assetManager&&(this.assetManager.assets={},this.assetManager.imageCache={}),this.worker?this.worker.postMessage({type:"connect",wsUrl:e}):(this.ws&&(this.ws.onclose=null,this.ws.close()),this._connectInline())}_handleBinaryMessage(e){if(0!==e.length)switch(e[0]){case 16:try{this._mediaClient?.receive(JSON.parse((new TextDecoder).decode(e.subarray(1))))}catch(e){}break;case i:case n:this._projectTransfer?.receive(e);break;case 2:this._handleInit(e),this.transportFactory||this._send(JSON.stringify({type:"media",action:"hello",recording:2}));break;case 1:this.assetManager.storeAssets(e),this.view?.refreshCursor();break;case 3:this.currentBuf=e,this._frameDirty=!0,this._loop.start();break;case 5:this.spectating=!1,this._handlePortRedirect(e);break;case 6:this.spectating=!0,this._handlePortRedirect(e);break;case 9:this.aspectRatio={x:e[1],y:e[2]},this._initCanvas();break;case 10:this._handleSavePush(e);break;case 11:this._handleSaveRequest(e);break;case 12:this._handleLocalPlayRedirect(e);break;case E:try{this.view?.setCursor(S(e))}catch(e){}}}_handleLocalPlayRedirect(e){let t;try{t=JSON.parse((new TextDecoder).decode(e.slice(1)))}catch(e){return void console.error("Bad local play payload",e)}t&&(t.gameKey||t.invitation)&&(this.onLocalPlayRedirect?this.onLocalPlayRedirect(t):this.startLocalGame(t))}startLocalGame(e){return this._sessions.startLocal(e)}exitLocalGame(){this._sessions.start()}_saveKey(e){let t="";try{t=new URL(this.wsUrl).hostname}catch(e){}return t+":"+e}_decodeJsonPayload(e){try{const t=new Uint8Array(e.buffer,e.byteOffset+1,e.length-1),s="undefined"!=typeof TextDecoder?(new TextDecoder).decode(t):String.fromCharCode.apply(null,t);return JSON.parse(s)}catch(e){return null}}_handleSavePush(e){const t=this._decodeJsonPayload(e);if(t&&"string"==typeof t.gameKey){this.saveStore.putSave(this._saveKey(t.gameKey),t).catch(()=>{});try{this.onSaveData(t)}catch(e){console.error("[HomegamesClient] onSaveData callback threw:",e)}}}_handleSaveRequest(e){const t=this._decodeJsonPayload(e);if(!t||"string"!=typeof t.gameKey)return;const s=e=>{this._send(JSON.stringify({type:"saveData",gameKey:t.gameKey,save:e||null}))};this.saveStore.getSave(this._saveKey(t.gameKey)).then(s).catch(()=>s(null))}_handleInit(e){if(this.playerId=e[1],this.inputHandler?.setPointerLockEnabled(!1),e.length<=2)return;this.aspectRatio={x:e[2],y:e[3]},this.bezelInfo={x:e[4],y:e[5]};const t=e[6],s=String.fromCharCode.apply(null,e.slice(7,7+t));this.squishVersion=s;const r=f[s];if(!r)return this.stop(),void this.onError(new Error("Unsupported Squish runtime: squish-"+s));if(this.unsquish=r.unsquish,this.inputHandler){this.inputHandler.spectating=this.spectating,this.inputHandler.bezelInfo=this.bezelInfo,this.inputHandler.squishVersion=s;const r=e[7+t]||0;this.inputHandler.setPointerLockEnabled(!!(1&r))}this._initCanvas(),this._connectionFailed=!1,this._setFrameStatus("Connected game",{attention:!1}),this._configureSharing(this._playerToolbar()),this.onReady(this.playerId)}_handlePortRedirect(e){const t=String(e[1]),s=String(e[2]).length>1?String(e[2]):"0"+String(e[2]),r=Number(t+s),i=new URL(this.wsUrl);i.port=r,this._reconnect(i.toString())}_initCanvas(){this.aspectRatio&&this.container&&(this.view.resize(this.aspectRatio),this._frameDirty=!0)}_paintFrame(){this.rendering&&(this.inputHandler?.tick(),(this._frameDirty||this.renderer.needsRepaint())&&this.currentBuf&&this.currentBuf.length>1&&3===this.currentBuf[0]&&this.unsquish&&(this.renderer.renderFrame(this.currentBuf,this.unsquish),this._frameDirty=!1))}}const{packAssetBundle:_}=s(5305),{fitImageToSize:C}=s(9311),A=(e,t)=>{if(!e||"undefined"==typeof document)return;const s=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),r=document.createElement("a");r.href=URL.createObjectURL(s),r.download=t||(e.gameKey||"game")+"-save.json",document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(r.href),1e3)};k.LocalSession=g,k.loadLocalGame=h,k.packAssetBundle=_,k.fitImageToSize=C,k.downloadSave=A,k.createRtcTransport=w,k.readInvitation=x,k.RtcHost=v,k.createShareDialog=s(172),k.createPlayerSharing=p,k.GameCopies=s(2157),k.createSessionFrame=a,k.createPlayerToolbar=s(8106).createPlayerToolbar,k.householdRoom=s(9225),k.PortableProject=s(7237),k.ManualRtc=s(9742),k.createManualPairing=s(5880),e.exports&&(e.exports={default:k,HomegamesClient:k,LocalSession:g,loadLocalGame:h,packAssetBundle:_,fitImageToSize:C,downloadSave:A}),"undefined"!=typeof window&&(window.HomegamesClient=k,window.LocalSession=g)},7868(e,t,s){const r=s(5562),{fitImageToSize:i}=s(9311),{MAX_UPLOAD_BYTES:n}=s(3947),o=e=>{let t="";for(let s=0;s<e.length;s+=32768)t+=String.fromCharCode.apply(null,e.subarray(s,s+32768));return btoa(t)};e.exports=class{constructor(e,t,s,i,n={}){this.canvas=e,this.send=t,this.getThingIndices=s,this.assetManager=i,this.mouseDown=!1,this.mousePos=null,this._pressClickSent=!1,this._touchActive=!1,this._lastTouchTime=-1/0,this.squishVersion=null,this._lastClientPos=null,this.keysDown={},this._lastKeyRepeat={},this._keyRepeatIntervalMs=33,this.currentHover=null,this.clickStopper=null,this.spectating=!1,this.bezelInfo={x:0,y:0},this.clientWidth=0,this.clientHeight=0,this._boundHandlers={},this._attached=!1,this.gamepads=!1===n?null:new r(t,n),this._focused=!0,this.pointerLockEnabled=!1,this.pointerLockSuspended=!1,this._pointerLocked=!1,this._pointerLockPending=!1,this._pointerLockCancelled=!1,this._pointerLockOnRelease=!1,this._pointerDelta={dx:0,dy:0},this._lastPointerMove=0}setPointerLockEnabled(e){this.pointerLockEnabled=!0===e,this.pointerLockEnabled||this._releasePointerCapture()}setPointerLockSuspended(e){const t=!0===e;this.pointerLockSuspended!==t&&(this.pointerLockSuspended=t,t&&this._releasePointerCapture())}_canCapturePointer(){return this.pointerLockEnabled&&!this.pointerLockSuspended}attach(){if(this._attached)return;this._attached=!0,this._focused="function"!=typeof document.hasFocus||document.hasFocus();const e=this._boundHandlers;document.removeEventListener("pointerlockchange",e.pointerlockchange),document.removeEventListener("pointerlockerror",e.pointerlockerror),e.mousedown=e=>{if(this._isTouchMouseEvent(e))return;if(this._pointerLockOnRelease=!1,this._isControlEvent(e))return;clearTimeout(this.clickStopper),this.clickStopper=null,e.target===this.canvas&&this.assetManager.liveMedia?.hold("pointer"),this._touchActive=!1,this.mouseDown=!0,this._pressClickSent=!1,this.mousePos=this._hasPointerLock()?this._canvasCenter():[e.clientX,e.clientY],this._lastClientPos=this.mousePos.slice(),this._pressOrigin=this.mousePos.slice(),this.assetManager.unlockAudio();const t=this._canCapturePointer()&&!this.spectating&&e.target===this.canvas&&0===e.button&&!e.sourceCapabilities?.firesTouchEvents&&!this._hasPointerLock()&&!this._pointerLockPending&&"function"==typeof this.canvas.requestPointerLock;if(this._pointerLockOnRelease=t&&!this._focused,t&&this._focused){if(this._sendPendingClick(this._canClick(this.mousePos[0],this.mousePos[1])),!this._attached||!this._canCapturePointer()||!this._focused||this.spectating)return;this.clickStopper=setTimeout(()=>{this.clickStopper=null},30),this._requestPointerLock()}},e.mouseup=e=>{if(this._isTouchMouseEvent(e))return;this.assetManager.liveMedia?.release("pointer"),this.mousePos=this._hasPointerLock()?this._canvasCenter():[e.clientX,e.clientY],this._lastClientPos=this.mousePos.slice();const t=this.mousePos.slice();if(this._sendPendingClick(this._canClick(this.mousePos[0],this.mousePos[1])),!this._attached)return;this.mouseDown=!1,this._sendMouseUp(t[0],t[1]);const s=this._pointerLockOnRelease;this._pointerLockOnRelease=!1,!(s&&this._attached&&this._canCapturePointer()&&this._focused)||this.spectating||e.target!==this.canvas||0!==e.button||e.sourceCapabilities?.firesTouchEvents||this._hasPointerLock()||this._pointerLockPending||this._requestPointerLock()},e.mousemove=e=>{if(!this._isTouchMouseEvent(e)){if(this._hasPointerLock())return this.mouseDown&&0===e.buttons&&this._releasePointerPress(),void(Number.isFinite(e.movementX)&&Number.isFinite(e.movementY)&&(this._pointerDelta.dx=Math.max(-4096,Math.min(4096,this._pointerDelta.dx+e.movementX)),this._pointerDelta.dy=Math.max(-4096,Math.min(4096,this._pointerDelta.dy+e.movementY))));this.mouseDown&&0===e.buttons&&(this.assetManager.liveMedia?.release("pointer"),this.mouseDown=!1),this.mousePos=[e.clientX+window.scrollX,e.clientY+window.scrollY],this._lastClientPos=[e.clientX,e.clientY]}},e.touchstart=e=>{this._pointerLockOnRelease=!1,e.target===this.canvas?(e.preventDefault(),"function"==typeof this.canvas.focus&&(this.canvas.tabIndex<0&&(this.canvas.tabIndex=-1),this.canvas.focus({preventScroll:!0})),this._focused=!0,this._touchActive=!0,this._lastTouchTime=Date.now(),clearTimeout(this.clickStopper),this.clickStopper=null,this.assetManager.liveMedia?.hold("pointer"),this.mouseDown=!0,this._pressClickSent=!1,this.mousePos=[e.touches[0].clientX+window.scrollX,e.touches[0].clientY+window.scrollY],this._lastClientPos=[e.touches[0].clientX,e.touches[0].clientY],this._pressOrigin=this.mousePos.slice(),this.assetManager.unlockAudio()):this._touchActive=!1},e.touchmove=e=>{this._touchActive&&(e.preventDefault(),this._lastTouchTime=Date.now(),this.mouseDown=!0,this.mousePos=[e.touches[0].clientX+window.scrollX,e.touches[0].clientY+window.scrollY],this._lastClientPos=[e.touches[0].clientX,e.touches[0].clientY])},e.touchend=e=>{if(!this._touchActive)return;this.assetManager.liveMedia?.release("pointer"),this._lastTouchTime=Date.now(),!1!==e.cancelable&&e.preventDefault?.();const t=e.changedTouches&&e.changedTouches[0];if(t){const e=this._canClick(t.clientX+window.scrollX,t.clientY+window.scrollY);"file"===e.action?this._promptFileUpload(e.nodeId):(this.mousePos=[t.clientX,t.clientY],this._sendPendingClick(e)),this.mouseDown=!1,this._sendMouseUp(t.clientX,t.clientY)}this.mouseDown=!1,this._touchActive=!1},e.touchcancel=()=>{this._touchActive&&(this._lastTouchTime=Date.now(),this.assetManager.liveMedia?.release("pointer"),this.mouseDown&&this._lastClientPos&&this._sendMouseUp(this._lastClientPos[0],this._lastClientPos[1],!0),this.mouseDown=!1,this._touchActive=!1)},e.keydown=e=>{this._isControlEvent(e)||("Escape"===e.key&&(this._hasPointerLock()||this._pointerLockPending||this._pointerLockOnRelease)?this._releasePointerCapture():(" "===e.key&&this.assetManager.liveMedia?.hold("space"),this.assetManager.unlockAudio(),this._keyMatters(e)&&!this.keysDown.Meta&&(e.preventDefault(),this._keyUpTimers&&this._keyUpTimers[e.key]&&(clearTimeout(this._keyUpTimers[e.key]),delete this._keyUpTimers[e.key]),this.keysDown[e.key]||(this.send(JSON.stringify({type:"keydown",key:e.key})),this._lastKeyRepeat[e.key]=Date.now()),this.keysDown[e.key]=!0)))},e.keyup=e=>{" "===e.key&&this.assetManager.liveMedia?.release("space"),this._isControlEvent(e)?this.keysDown[e.key]&&(clearTimeout(this._keyUpTimers?.[e.key]),this._keyUpTimers&&delete this._keyUpTimers[e.key],delete this.keysDown[e.key],delete this._lastKeyRepeat[e.key],this.send(JSON.stringify({type:"keyup",key:e.key}))):this._keyMatters(e)&&(e.preventDefault(),this._keyUpTimers||(this._keyUpTimers={}),this._keyUpTimers[e.key]&&clearTimeout(this._keyUpTimers[e.key]),this._keyUpTimers[e.key]=setTimeout(()=>{this.keysDown[e.key]=!1,delete this._keyUpTimers[e.key],this.send(JSON.stringify({type:"keyup",key:e.key}))},50))},e.blur=()=>{this._focused=!1,this._releasePointerCapture()},e.focus=()=>{this._focused=!0},e.visibilitychange=()=>{document.hidden&&this._releasePointerCapture()},e.pointerlockchange=()=>{const e=this._pointerLocked;this._pointerLocked=this._hasPointerLock(),this._pointerLockPending=!1,this._clearPointerDelta(),!this._pointerLocked||this._attached&&this._canCapturePointer()&&!this._pointerLockCancelled&&!this.spectating&&this._focused?e&&!this._pointerLocked&&this._releasePointerCapture():this._releasePointerCapture(),this._removeDetachedPointerLockListeners()},e.pointerlockerror=()=>{this._pointerLockPending=!1,this._removeDetachedPointerLockListeners()},window.addEventListener("mousedown",e.mousedown),window.addEventListener("mouseup",e.mouseup),window.addEventListener("mousemove",e.mousemove),window.addEventListener("blur",e.blur),window.addEventListener("focus",e.focus),document.addEventListener("visibilitychange",e.visibilitychange),document.addEventListener("pointerlockchange",e.pointerlockchange),document.addEventListener("pointerlockerror",e.pointerlockerror),window.addEventListener("touchstart",e.touchstart,{passive:!1}),this.canvas.addEventListener("touchmove",e.touchmove,{passive:!1}),window.addEventListener("touchend",e.touchend,{passive:!1}),window.addEventListener("touchcancel",e.touchcancel),document.addEventListener("keydown",e.keydown),document.addEventListener("keyup",e.keyup)}detach(){if(this._textDialog?.close(),this._textDialog?.remove(),this._textDialog=null,!this._attached)return;this.assetManager.liveMedia?.release(),this._attached=!1,this._releasePointerCapture();const e=this._boundHandlers;window.removeEventListener("mousedown",e.mousedown),window.removeEventListener("mouseup",e.mouseup),window.removeEventListener("mousemove",e.mousemove),window.removeEventListener("blur",e.blur),window.removeEventListener("focus",e.focus),document.removeEventListener("visibilitychange",e.visibilitychange),this._removeDetachedPointerLockListeners(),window.removeEventListener("touchstart",e.touchstart),this.canvas.removeEventListener("touchmove",e.touchmove),window.removeEventListener("touchend",e.touchend),window.removeEventListener("touchcancel",e.touchcancel),document.removeEventListener("keydown",e.keydown),document.removeEventListener("keyup",e.keyup)}tick(){if(!this._attached)return;const e=Date.now();Object.keys(this.keysDown).filter(e=>this.keysDown[e]).forEach(t=>{e-(this._lastKeyRepeat[t]||0)>=this._keyRepeatIntervalMs&&(this.send(JSON.stringify({type:"keydown",key:t})),this._lastKeyRepeat[t]=e)}),!this._focused||document.hidden||this.spectating?this.gamepads?.release():this.gamepads?.tick();const t=1e3/60;if(this._canCapturePointer()&&this._hasPointerLock()&&this._focused&&!document.hidden&&!this.spectating&&e-this._lastPointerMove>=t-1&&(this._pointerDelta.dx||this._pointerDelta.dy)&&(this.send(JSON.stringify({type:"pointermove",data:{...this._pointerDelta}})),this._pointerDelta.dx=this._pointerDelta.dy=0,this._lastPointerMove=this._lastPointerMove&&e-this._lastPointerMove<2*t?this._lastPointerMove+t:e),!this.mousePos)return;const s=this._canClick(this.mousePos[0],this.mousePos[1]);this.mouseDown&&!this.clickStopper&&(this._pressClickSent?this._hasPointerLock()||(this._usesSingleClickContract()?this._sendMouseMove(this.mousePos[0],this.mousePos[1]):this._handleClick(s,!1)):this._sendPendingClick(s),this.clickStopper=setTimeout(()=>{this.clickStopper=null},30)),s.isClickable||s.action||s.isHoverable?this.currentHover&&Number(s.nodeId)===Number(this.currentHover)||(this.currentHover&&this._offHover(this.currentHover),this.currentHover=s.nodeId,this._onHover(s.nodeId)):this.currentHover&&(this._offHover(this.currentHover),this.currentHover=null),this.mousePos=null}_hasPointerLock(){return document.pointerLockElement===this.canvas}_canvasCenter(){const e=this.canvas.getBoundingClientRect();return[e.left+e.width/2,e.top+e.height/2]}_requestPointerLock(){if(this._canCapturePointer()){this._pointerLockCancelled=!1,this._pointerLockPending=!0;try{const e=this.canvas.requestPointerLock();e?.then&&e.then(()=>{this._boundHandlers.pointerlockchange()},()=>{this._boundHandlers.pointerlockerror()})}catch(e){this._boundHandlers.pointerlockerror()}}}_clearPointerDelta(){this._pointerDelta.dx=this._pointerDelta.dy=0,this._lastPointerMove=0}_releasePointerPress(){this._pointerLockOnRelease=!1,this.assetManager.liveMedia?.release("pointer"),this.mouseDown&&this._lastClientPos&&this._sendMouseUp(...this._lastClientPos,!0),this.mouseDown=!1,this._touchActive=!1,this._pressClickSent=!1,this.mousePos=null,this._lastClientPos=null,clearTimeout(this.clickStopper),this.clickStopper=null}_releasePointerCapture(){this._pointerLockCancelled=!0,this.assetManager.liveMedia?.release(),this.gamepads?.release(),this._releaseKeys(),this._releasePointerPress(),this._clearPointerDelta(),this._hasPointerLock()&&document.exitPointerLock?.()}_removeDetachedPointerLockListeners(){this._attached||this._pointerLockPending||(document.removeEventListener("pointerlockchange",this._boundHandlers.pointerlockchange),document.removeEventListener("pointerlockerror",this._boundHandlers.pointerlockerror))}_releaseKeys(){for(const e of Object.values(this._keyUpTimers||{}))clearTimeout(e);this._keyUpTimers={};for(const e of Object.keys(this.keysDown))this.keysDown[e]&&this.send(JSON.stringify({type:"keyup",key:e}));this.keysDown={},this._lastKeyRepeat={}}_isControlEvent(e){return!!e.target?.closest?.('button, a, input, select, textarea, [contenteditable="true"]')}_isTouchMouseEvent(e){const t=e.sourceCapabilities?.firesTouchEvents;return!0===t||!1!==t&&e.target===this.canvas&&(this._touchActive||Date.now()-this._lastTouchTime<800)}_keyMatters(e){return 1===e.key.length&&e.key>=" "&&e.key<="z"||e.keyCode>=36&&e.keyCode<=40||"Meta"===e.key||"Backspace"===e.key||"Enter"===e.key||"Escape"===e.key||"Shift"===e.key}_sendMouseUp(e,t,s=!1){const r=this.canvas.getBoundingClientRect(),i=(e-r.left)/r.width*100,n=(t-r.top)/r.height*100,o=Math.min(99.99,Math.max(0,i)),a=Math.min(99.99,Math.max(0,n)),h=this._pressOrigin;!s&&h&&this._pressClickSent&&!this._hasPointerLock()&&(Math.abs(e-h[0])>.5||Math.abs(t-h[1])>.5)&&this._sendMouseMove(e,t),this._pressOrigin=null,this.send(JSON.stringify({type:"mouseup",data:{x:o,y:a,...s?{cancelled:!0}:{}}}))}_usesSingleClickContract(){const e=this.squishVersion;return!(!e||!/^[1-9]\d{2}$/.test(e))&&Number(e)>=144}_sendMouseMove(e,t){const s=this.canvas.getBoundingClientRect(),r=(e-s.left)/s.width*100,i=(t-s.top)/s.height*100,n=Math.min(99.99,Math.max(0,r)),o=Math.min(99.99,Math.max(0,i));this.send(JSON.stringify({type:"mousemove",data:{x:n,y:o}}))}_onHover(e){this.send(JSON.stringify({type:"onhover",nodeId:e}))}_offHover(e){this.send(JSON.stringify({type:"offhover",nodeId:e}))}_sendPendingClick(e){if(!this.mouseDown||this._pressClickSent||this.spectating||!this._focused)return;this._pressClickSent=!0;const t=this.mousePos;this._pressOrigin&&(this.mousePos=this._pressOrigin.slice(),e=this._canClick(this.mousePos[0],this.mousePos[1])),this._handleClick(e,!0),this._attached&&(this.mousePos=t)}_promptTextInput(e){if(this._textDialog)return;const t=document.createElement("dialog"),s=document.createElement("div"),r=document.createElement("label"),i=document.createElement("input"),n=document.createElement("button"),o=document.createElement("button");t.setAttribute("aria-label","Input text"),t.style.cssText="max-width:90vw;padding:24px;border-radius:12px;background:#101820;color:white;font:16px system-ui",r.textContent="Input text",i.type="text",i.maxLength=4096,i.style.cssText="display:block;width:min(300px,65vw);padding:10px;margin:12px 0;font:inherit",r.append(i),n.textContent="Done",n.type="button",o.textContent="Cancel",o.type="button";for(const e of[n,o])e.style.cssText="padding:8px 16px;margin-right:8px;font:inherit";const a=()=>{t.close(),t.remove(),this._textDialog=null};n.onclick=t=>{t.preventDefault();const s=i.value;a(),this.send(JSON.stringify({type:"input",input:s,nodeId:e}))},i.onkeydown=e=>{"Enter"===e.key&&n.onclick(e)},o.onclick=a,t.oncancel=e=>{e.preventDefault(),a()},s.append(r,n,o),t.append(s),document.body.append(t),this._textDialog=t,t.showModal(),i.focus()}_handleClick(e,t){if(this.mousePos)if(e.action)"text"===e.action?(this.mouseDown=!1,this._promptTextInput(e.nodeId)):"file"===e.action&&(this.mouseDown=!1,this._touchActive||this._promptFileUpload(e.nodeId));else{const e=this.mousePos[0],s=this.mousePos[1],r=this.canvas.getBoundingClientRect(),i=(e-r.left)/r.width*100,n=(s-r.top)/r.height*100;if(i>=0&&i<=100&&n>=0&&n<=100){const e={x:i,y:n};t&&(e.press=!0),this.send(JSON.stringify({type:"click",data:e}))}}}_promptFileUpload(e){const t=document.createElement("input");t.type="file",t.accept="image/*,audio/*,video/*,application/json,.json",t.style.display="none",document.body.appendChild(t);const s=()=>{t.parentNode&&t.parentNode.removeChild(t)};t.onchange=async()=>{const r=t.files&&t.files[0];if(s(),!r)return;let a={blob:r,contentType:r.type||null,fileName:r.name||null};if(r.size>n)try{a=await i(r,n)}catch(e){const t=(r.size/1048576).toFixed(1);return void alert(`That file is ${t}MB — uploads are limited to ${n/1048576}MB, and it couldn't be resized automatically.`)}const h=new FileReader;h.onerror=()=>{alert("Could not read that file. Please try a different one.")},h.onload=()=>{this.send(JSON.stringify({type:"input",fileEncoding:"base64",contentType:a.contentType,fileName:a.fileName,input:o(new Uint8Array(h.result)),nodeId:e}))},h.readAsArrayBuffer(a.blob)},t.addEventListener("cancel",s),t.click()}_translateX(e,t=this.canvas.getBoundingClientRect()){return e*t.width/100+t.left}_translateY(e,t=this.canvas.getBoundingClientRect()){return e*t.height/100+t.top}_canClick(e,t){let s=!1,r=!1,i=null,n=null;const o=this.canvas.getBoundingClientRect();if(e<o.left||e>o.right||t<o.top||t>o.bottom)return{isClickable:s,isHoverable:r,action:i,nodeId:n};const a=this.getThingIndices();for(let h=a.length-1;h>=0;h--){const l=a[h];if(!l)continue;let c=l[3];if(!c||!c.length)continue;if(!c[0].length){const e=new Array(c.length/2);for(let t=0;t<c.length;t+=2)e[t/2]=[c[t],c[t+1]];c=e}let d=!1,u=this._translateX(c[0][0],o),p=u,f=this._translateY(c[0][1],o),m=f;for(let e=1;e<c.length;e++){const t=this._translateX(c[e][0],o),s=this._translateY(c[e][1],o);t<u&&(u=t),t>p&&(p=t),s<f&&(f=s),s>m&&(m=s)}if(!(e<u||e>p||t<f||t>m)){let s=0,r=c.length-1;for(;s<c.length;r=s++){const i=this._translateY(c[s][1],o),n=this._translateY(c[r][1],o),a=this._translateX(c[s][0],o),h=this._translateX(c[r][0],o);i>t!=n>t&&e<(h-a)*(t-i)/(n-i)+a&&(d=!d)}}if(d){s=l[0],i=l[1],n=l[2],r=!!l[4];break}}return{isClickable:s,isHoverable:r,action:i,nodeId:n}}}},7538(e,t,s){const r=s(5766);e.exports=class{constructor(e,t){this.playerId=Number(t),this.dispatcher=new r(e),this.gameInput=this.dispatcher.gameInput}handleMessage(e){let t;try{t=JSON.parse(e)}catch(e){return}this.handleInput(t)}handleInput(e){this.dispatcher.handleInput(this.playerId,e)}checkActivePresses(){this.dispatcher.checkActivePresses(this.playerId)}release(){this.gameInput.removePlayer(this.playerId),this.dispatcher.endPress(this.playerId,null)}}},4849(e,t,s){const r=s(7875),{createPlayerToolbar:i}=s(8106),n=(e,t,n,o=null,a={})=>{const h=document.getElementById(e);if(!h)throw new Error("Container element not found: #"+e);h.innerHTML="";const l=r(),c=document.createElement("div");c.className="hg-session-frame";const d=i(window,{title:t,author:a.author,home:n,status:a.status||"Playing locally",onOpen:a.onOpen||o?.onOpen,onClose:a.onClose||o?.onClose});d.bar.classList.add("hg-session-bar"),a.onExports&&d.setAction("exports",{label:"View exports",run:a.onExports});const u=document.createElement("div");let p;if(u.className="hg-session-game",u.id=`${e}-hg-local-area`,c.append(d.bar,u),h.append(c),u.homegamesToolbar=d,d.setGameArea(u,c),o&&(o.getSharingLink||(p=s(4334)({...o,getInvitation:o.getLink,onStatus:(e,t)=>d.setSharingStatus(e,t)})),d.setSharing({multiplayer:!1!==o.multiplayer,copy:!(!o.getSharingLink&&!o.getProject),getLink:o.getSharingLink||(e=>p.getLink(e)),dispose:p?()=>p.dispose():void 0}),o.onVisibility)){let e=o.private;const t=()=>d.setAction("privacy",{label:e?"Make session public":"Make session private",run:async()=>{await o.onVisibility(e?"public":"private"),e=!e,t()}});t()}let f=!1;return{bar:d.bar,toolbar:d,gameArea:u,containerId:u.id,setStatus:(e,t)=>d.setStatus(e,t),dispose(){f||(f=!0,p?.dispose(),d.dispose(),c.remove(),l())}}};n.addExportsButton=(e,t)=>{const s=e.homegamesToolbar;return s?.setAction("exports",{label:"View exports",run:t}),()=>s?.setAction("exports",null)},e.exports=n},7348(e){const t=async({manifestUrl:e,gameKey:t,versionId:s,baseUrl:r}={},{signal:i}={})=>{const n=await fetch(e,{signal:i});if(!n.ok)throw new Error("Manifest fetch failed: "+n.status);const o=await n.json();if(!o.localPlayable)throw new Error(o.reason||"This game cannot run locally");let a=null;if(o.assetCount>0){const t=new URL(e,r||window.location.href),s=await fetch(new URL(o.assetBundleUrl,t).href,{signal:i});if(!s.ok)throw new Error("Asset bundle fetch failed: "+s.status);a=new Uint8ClampedArray(await s.arrayBuffer())}return{name:o.name,author:o.author||o.createdBy,multiplayer:!0===o.multiplayer,files:o.files,entryPoint:o.entryPoint,assetBundle:a,gameKey:t||o.gameKey||o.gameId,versionId:s||o.versionId||o.commitSha}};e.exports={loadLocalGame:t,loadHomeGame:({gameKey:e,versionId:s=null},r)=>{const i=s?`?versionId=${encodeURIComponent(s)}`:"";return t({gameKey:e,versionId:s,manifestUrl:`/games/${encodeURIComponent(e)}/local-manifest${i}`},r)}}},9503(e,t,s){const{createSessionRuntime:r}=s(9956);e.exports=(e,t,s={})=>r(e,t,{...s,loadAssets:!1})},814(e,t,s){const{ProjectTransferHost:r}=s(4394),i=s(9503),{playerFrame:n}=s(9956),{packAssetBundle:o}=s(5305),{splitAssetBundle:a}=s(3735),{createFileUploadHandler:h}=s(3947),{normalizeCursor:l,encodeCursor:c}=s(5199),d=s(6620),u=s(3598),{GameView:p,FrameLoop:f,getClientInfo:m}=s(1768),{squishMap:g,DEFAULT_VERSION:y}=s(9732),v=s(7538),{loadGameClass:w}=s(9630),{createSaveStore:x,createDebouncedWriter:b,serializeSaveData:E,isCompatibleSave:S,DEFAULT_VERSION_ID:k}=s(7699),{generateName:_,initialName:C,normalizeName:A}=s(4367);e.exports=class{constructor(e){this.gamepadOptions=e.gamepad??{},this.platform=e.platform,this.packageRevision=e.packageRevision,this.containerId=e.containerId,this.gameClass=e.gameClass||null,this.files=e.files||null,this.entryPoint=e.entryPoint||"index.js",this.playerId=e.playerId||1,this.playerName=C(e.playerName),this.assetBundle=e.assetBundle||null,this.assetPackets=this.assetBundle?a(this.assetBundle):[],this.onReady=e.onReady||(()=>{}),this.onError=e.onError||(()=>{}),this.onAspectRatio=e.onAspectRatio||(()=>{}),this.gameKey=e.gameKey||null,this.versionId=e.versionId||k,this.onSaveData=e.onSaveData||null,this.saveStore=e.saveStore||x(),this.game=null,this.runtime=null,this.players=[],this.dynamicAssets=new Map,this.onStop=null,this.unsquish=null,this.aspectRatio=null,this.pointerLockEnabled=!1,this.frozen=!1,this._loop=new f(()=>this._paintFrame()),this._resizeHandler=null,this._inspector=null,this._onInput=null,this._inspectBuf=null,this._highlight=null,this._pick=null}get _primary(){return this.players[0]}get extraPlayers(){return this.players.slice(1)}get view(){return this._primary?.view||null}get container(){return this.view?.container||null}get canvas(){return this.view?.canvas||null}get renderer(){return this.view?.renderer||null}get assetManager(){return this.view?.assetManager||null}get inputHandler(){return this.game&&this.view?.inputHandler||null}get dispatcher(){return this._primary?.dispatcher||null}get currentBuf(){return this._primary?.currentBuf||null}get squisher(){return this.runtime?.squisher||null}get rendering(){return this._loop.running}start(){this.stop();const e=document.getElementById(this.containerId);if(!e)return void this.onError(new Error("Container element not found: #"+this.containerId));if(e.innerHTML="",!this.gameClass&&this.files)try{this.gameClass=w({files:this.files,entryPoint:this.entryPoint})}catch(e){return this.stop(),void this.onError(e)}if(!this.gameClass)return this.stop(),void this.onError(new Error("LocalSession needs either gameClass or files"));let t;try{t=s(2439).runtimeMetadata(this.gameClass)}catch(e){return this.stop(),void this.onError(e)}this.maxPlayers=t.maxPlayers,this.pointerLockEnabled=!0===t.pointerLock;const r=t.squishVersion||y;let i=g[r];if(!i)return void this.onError(new Error("Unsupported Squish runtime: squish-"+r));this.unsquish=i.unsquish,this.squishVersion=r,this.aspectRatio=t.aspectRatio||{x:16,y:9};const n=this.gameKey||this.gameClass.name||"local-game",o="local:"+n,a=Array.isArray(t.saveCompatibility)?t.saveCompatibility:[],h=this._bootGeneration;this.exportStorage=this.platform?.getExports?this.platform:s(739).createExportStorage(window,{installationId:n,gameId:n,packageRevision:this.packageRevision}),this.saveStore.getSave(o).catch(e=>{if(this.saveStore.strict)throw e;return null}).then(async t=>{if(h!==this._bootGeneration)return;const r=t&&S(t,this.versionId,a)?t.data:void 0,l=e=>this.saveStore.putSave(o,e).then(()=>{if(this.onSaveData)try{this.onSaveData(e)}catch(e){}}),c=this.saveStore.eager?l:b({intervalMs:1e3,write:l}),d=await this.exportStorage.getExports().catch(e=>(this.exportStorageError=e,{}));h===this._bootGeneration&&(this.userExportsStore=s(2947).openGameExports(this.gameClass,{saved:d,persist:(e,t)=>this.exportStorageError?Promise.reject(this.exportStorageError):this.exportStorage.putExport(e,t)}),this._boot({container:e,squishModule:i,saveGame:e=>{let t;try{t=JSON.parse(E(e))}catch(e){return Promise.reject(e)}return c({gameKey:n,versionId:this.versionId,savedAt:Date.now(),data:t})},saveData:r}))}).catch(e=>{h===this._bootGeneration&&this.onError(e)})}_boot({container:e,squishModule:t,saveGame:s,saveData:n}){const o=this._bootGeneration;this.media=new d;const a=h({Asset:t.Asset,registerAsset:(e,t)=>this._addLocalAsset(e,t),isPlayerActive:e=>!!this.game&&!this.frozen&&this.players.some(t=>t.playerId===e)});try{this.game=new this.gameClass({createExport:this.userExportsStore.createExport,userExports:this.userExportsStore.userExports,media:this.media,addAsset:(e,t)=>this._addLocalAsset(e,t),handleFileUpload:a,setCursor:(e,t)=>o===this._bootGeneration&&this.setCursor(e,t),saveGame:s,saveData:n}),this.runtime=i(t,this.game,{userExportsStore:this.userExportsStore}),this.projectTransfers=new r({exportProject:e=>this.exportProject(e),listExports:()=>this.runtime.listExports(),readExport:(e,t)=>this.runtime.readExport(t)});for(const[e,t]of Object.entries(this.game.getAssets?.()||{}))this._addLocalAsset(e,t)}catch(e){return this.stop(),void this.onError(e)}const l=this.runtime;this.squisher.addListener(()=>{this.runtime===l&&(this.players.forEach(e=>e.dispatcher?.checkActivePresses()),this._captureFrame())}),this._joinPlayer(e,this.playerId,this.playerName,this.gamepadOptions),this.assetBundle&&this.assetManager.storeAssets(this.assetBundle);for(const e of this.dynamicAssets.values())this.assetManager.storeRawAsset(e.key,e.type,e.data);this._resizeHandler=()=>this._initCanvas(),window.addEventListener("resize",this._resizeHandler),this._captureFrame(),this._loop.start(),this.onReady(this.playerId)}enableInspector(e,t){this._inspector=e,this._onInput=t||null,this._emitSnapshot()}disableInspector(){this._inspector=null,this._onInput=null,this.disablePick(),this.setHighlight(null),this.resumeLive()}showFrame(e){this.renderer&&this.unsquish&&e&&(this._inspectBuf=e,this._updateInputAttachment(),this._paintInspectedFrame())}resumeLive(){this._inspectBuf=null,this._updateInputAttachment(),this._primary&&(this._primary.frameDirty=!0)}enablePick({onMove:e,onPick:t}={}){if(!this.canvas)return;this.disablePick();const s=e=>{const t=this.canvas.getBoundingClientRect();return[(e.clientX-t.left)/t.width*100,(e.clientY-t.top)/t.height*100]};this._pick={move:t=>{e&&e(...s(t))},click:e=>{const[r,i]=s(e);this.disablePick(),t&&t(r,i)},leave:()=>{e&&e(null,null)}},this.canvas.addEventListener("mousemove",this._pick.move),this.canvas.addEventListener("click",this._pick.click),this.canvas.addEventListener("mouseleave",this._pick.leave),this.view.setCursorOverride("crosshair"),this._updateInputAttachment()}disablePick(){this._pick&&this.canvas?(this.canvas.removeEventListener("mousemove",this._pick.move),this.canvas.removeEventListener("click",this._pick.click),this.canvas.removeEventListener("mouseleave",this._pick.leave),this.view.setCursorOverride(null),this._pick=null,this._updateInputAttachment()):this._pick=null}_updateInputAttachment(){this.inputHandler&&(this._inspectBuf||this._pick?this.inputHandler.detach():this.inputHandler.attach())}_noteInput(e){if(this._onInput)try{const t=JSON.parse(e);if(!t||"string"!=typeof t.type)return;if("mousemove"===t.type||"onhover"===t.type||"offhover"===t.type)return;const s={time:performance.now(),type:t.type};"string"==typeof t.key&&(s.key=t.key),this._onInput(s)}catch(e){}}setHighlight(e){this._highlight=e&&e.length?e:null,this._inspectBuf?this._paintInspectedFrame():this._primary&&(this._primary.frameDirty=!0)}_paintInspectedFrame(){this._inspectBuf&&this.renderer&&(this.renderer.renderFrame(this._inspectBuf,this.unsquish,{muteAudio:!0,freezeMedia:!0}),this._drawHighlight())}_drawHighlight(){if(!this._highlight||!this.canvas)return;const e=this.canvas.getContext("2d"),{width:t,height:s}=this.canvas;e.save(),e.beginPath(),e.moveTo(this._highlight[0][0]*t/100,this._highlight[0][1]*s/100);for(let r=1;r<this._highlight.length;r++)e.lineTo(this._highlight[r][0]*t/100,this._highlight[r][1]*s/100);e.closePath(),e.shadowColor="rgba(148, 210, 229, 0.9)",e.shadowBlur=Math.max(12,.012*t),e.strokeStyle="rgba(148, 210, 229, 0.95)",e.lineWidth=Math.max(2,.003*t),e.stroke(),e.stroke(),e.restore()}_emitSnapshot(){if(!this._inspector||!this.currentBuf)return;let e=null;try{e=(this.game.getLayers()||[]).map(e=>this._serializeNode(e.root))}catch(e){}try{this._inspector({time:performance.now(),buf:this.currentBuf,tree:e})}catch(e){console.error("[LocalSession] inspector callback threw:",e)}}addPlayer(e,{gamepadIndex:t}={}){if(!this.game||!this.squisher)return null;const s=document.getElementById(e);if(!s)return console.error("[LocalSession] addPlayer: container not found: #"+e),null;const r=Math.max(...this.players.map(e=>e.playerId))+1,i=this.inputHandler?.gamepads;i&&null===i.index&&i.setIndex(0);const n=new Set(this.players.map(e=>e.view?.inputHandler.gamepads?.index));if(void 0===t)for(t=0;n.has(t);)t++;return this._joinPlayer(s,r,_(),!1!==this.gamepadOptions&&{...this.gamepadOptions,index:t}),this._captureFrame(),r}_joinPlayer(e,t,s,r){const i=new v(this.game,t),n=new p({container:e,assetManager:this.assetManager,gamepad:r,send:e=>{t===this.playerId&&this._noteInput(e),i.handleMessage(e)},onAssetReady:()=>this._invalidateFrames(),onLayout:e=>{t===this.playerId&&(this.platform?.setState?.({aspectRatio:e}),this.onAspectRatio(e))},onResize:()=>{this._invalidateFrames(),this._inspectBuf&&this._paintInspectedFrame()}});if(this.players.push({playerId:t,info:{name:s},settings:{SOUND:!0},view:n,dispatcher:i,cursor:null,currentBuf:null,frameDirty:!0}),t===this.playerId){const s=new u({container:e,platform:this.platform,assets:n.assetManager,send:e=>this.media.handle(t,e),publish:(e,s)=>this.media.attach(t,s)});this.media.join(t,{audioRecording:!0,send:e=>s.receive(e),addMedia:(e,t)=>s.attach(t),removeMedia:e=>s.remove(e)})}n.inputHandler.squishVersion=this.squishVersion,n.inputHandler.setPointerLockEnabled(this.pointerLockEnabled),n.resize(this.aspectRatio);try{this.game.handleNewPlayer?.({playerId:t,settings:{SOUND:!0},info:{name:s},clientInfo:m(),requestedGame:null})}catch(e){console.error("[LocalSession] game.handleNewPlayer threw:",e)}}_leavePlayer(e){this.projectTransfers?.leave(e.playerId),this.media?.leave(e.playerId);const t=e.dispatcher;if(t){if(e.dispatcher=null,e.view?.setCursor(null),e.cursor)try{e.send?.(c(null))}catch(e){}delete e.cursor,e.view?.inputHandler.setPointerLockEnabled(!1),e.view?.inputHandler.detach(),t.release();try{this.game?.handlePlayerDisconnect?.(e.playerId)}catch(e){}e.view?.renderer.stopAllSounds()}}removePlayer(e){const t=this.players.findIndex(t=>t.playerId===e);if(t<=0)return;const[s]=this.players.splice(t,1);this._leavePlayer(s),s.view?.destroy(),s.close?.()}addRemotePlayer({send:e,close:t,clientInfo:s={},playerName:r}){if(!this.game||this.frozen)throw new Error("The host game has ended");if(this.players.length>=this.maxPlayers)throw new Error("This game is full");let i=1;for(;this.players.some(e=>e.playerId===i);)i++;const n=Array.from(this.squishVersion,e=>e.charCodeAt(0));e(Uint8Array.from([2,i,this.aspectRatio.x,this.aspectRatio.y,0,0,n.length,...n,this.pointerLockEnabled?1:0]));for(const t of this.assetPackets)e(t);for(const t of this.dynamicAssets.values())e(o([t]));const a=new v(this.game,i),h={playerId:i,info:{name:C(r)},settings:{SOUND:!0},dispatcher:a,send:e,close:t,view:null,cursor:null,currentBuf:null,frameDirty:!0};this.players.push(h);try{this.game.handleNewPlayer?.({playerId:i,settings:{SOUND:!0},info:{...h.info},clientInfo:s,requestedGame:null}),this._captureFrame()}catch(e){throw this.removePlayer(i),e}return{playerId:i,handleMessage:t=>{if(!h.dispatcher)return;let s;try{s=JSON.parse(t)}catch(e){return}if("player-info"===s?.type)try{this.setPlayerName(i,s.name)}catch(e){}else"project-transfer"===s?.type?this.handleProjectMessage(i,s,e):h.dispatcher.handleInput(s)},leave:()=>this.removePlayer(i)}}setPlayerName(e,t){const s=A(t);e===this.playerId&&(this.playerName=s);const r=this.players.find(t=>t.playerId===e&&t.dispatcher);if(!r||!this.game||this.frozen)return!1;if(r.info.name===s)return s;r.info={...r.info,name:s};try{this.game.handlePlayerUpdate?.(e,{info:{...r.info},settings:{...r.settings}})}catch(e){console.error("[LocalSession] game.handlePlayerUpdate threw:",e)}return this._captureFrame(),s}exportProject(e){return this.runtime&&!this.frozen&&this.players.some(t=>t.playerId===Number(e)&&t.dispatcher)?this.runtime.exportProject(Number(e)):Promise.reject(new Error("Join the game before requesting a copy"))}handleProjectMessage(e,t,s){this.players.some(t=>t.playerId===Number(e)&&t.dispatcher)&&this.projectTransfers?.handle(Number(e),t,s)}setCursor(e,t){if(!this.game||!this.runtime||this.frozen)return!1;const s=this.players.find(t=>t.playerId===Number(e)&&t.dispatcher);if(!s)return!1;const r=l(t);return s.cursor=r,s.view?s.view.setCursor(r):s.send(c(r)),!0}_serializeNode(e){const t=e.node,s={id:t.id};if(t.subType&&(s.subType=t.subType),t.coordinates2d&&t.coordinates2d.length&&(s.coordinates2d=Array.from(t.coordinates2d,e=>[e[0],e[1]])),t.fill&&(s.fill=Array.from(t.fill)),t.color&&(s.color=Array.from(t.color)),null!==t.border&&void 0!==t.border&&(s.border=t.border),t.text&&(s.text={text:t.text.text,x:t.text.x,y:t.text.y,size:t.text.size,align:t.text.align}),t.asset){const e=Object.keys(t.asset)[0],r=t.asset[e]||{};s.asset={key:e},r.pos&&(s.asset.pos={x:r.pos.x,y:r.pos.y}),r.size&&(s.asset.size={x:r.size.x,y:r.size.y})}return t.playerIds&&t.playerIds.length&&(s.playerIds=t.playerIds.slice()),t.handleClick&&(s.clickable=!0),t.input&&t.input.type&&(s.input=t.input.type),s.children=t.children.map(e=>this._serializeNode(e)),s}freeze(){this.frozen||(this.frozen=!0,this._endGame())}_endGame(){this._bootGeneration=(this._bootGeneration||0)+1;const e=this.onStop;this.onStop=null,e?.(),this.media?.destroy(),this.projectTransfers?.close(),this.runtime?.stop(),this.runtime=null,this.players.forEach(e=>this._leavePlayer(e)),this.pointerLockEnabled=!1;try{this.game?.close?.()}catch(e){}try{this.game?.destroy?.()}catch(e){}this.game=null}stop(){this._endGame(),this._loop.stop(),this.disablePick(),this._inspector=null,this._onInput=null,this._inspectBuf=null,this._highlight=null,this.frozen=!1,[...this.players].reverse().forEach(e=>{e.view?.destroy(),e.close?.()}),this.players=[],this.dynamicAssets.clear(),this._resizeHandler&&(window.removeEventListener("resize",this._resizeHandler),this._resizeHandler=null)}_addLocalAsset(e,t){try{const s=t&&t.info&&t.info.type||"image",r=t&&t.data;if(r){this.dynamicAssets.set(e,{key:e,type:s,data:r}),this.assetManager?.storeRawAsset(e,s,r);const t=o([{key:e,type:s,data:r}]);this.players.forEach(e=>e.send?.(t)),this._invalidateFrames()}}catch(e){console.error("[LocalSession] addAsset failed:",e)}return Promise.resolve()}_captureFrame(){const e=this.squisher;if(e&&(e.flush?.(),this.squisher===e)){for(const t of this.players){const s=n(e,t.playerId);s?.length&&(t.view&&(t.currentBuf=s,t.frameDirty=!0),t.send?.(s,{transfer:!0}))}this._emitSnapshot()}}_invalidateFrames(){this.players.forEach(e=>{e.frameDirty=!0,e.view?.refreshCursor()})}_initCanvas(){this.players.forEach(e=>e.view?.resize(this.aspectRatio)),this._invalidateFrames(),this._inspectBuf&&this._paintInspectedFrame()}_paintFrame(){for(const e of this.players){const{view:t}=e;if(!t)continue;if(e.dispatcher&&t.inputHandler.tick(),t.destroyed)continue;const{currentBuf:s}=e;if(!e.frameDirty&&!t.renderer.needsRepaint()||!s||s.length<=1||3!==s[0])continue;const r=e===this._primary;r&&this._inspectBuf||(t.renderer.renderFrame(s,this.unsquish,{muteAudio:!r||this.frozen,freezeMedia:this.frozen}),r&&this._drawHighlight()),e.frameDirty=!1}}}},5880(e,t,s){const{ManualHost:r,createManualGuest:i,DEFAULT_ICE:n}=s(9742);e.exports=function({container:e,getSession:t,join:s,onOpen:o=()=>{},onClose:a=()=>{}}){const h=document.createElement("dialog");h.setAttribute("aria-label","Manual connection"),h.style.cssText="background:#172735;color:#f1f8fc;border:1px solid #547286;border-radius:8px;box-sizing:border-box;width:min(620px,calc(100vw - 24px));max-height:85vh;overflow:auto;padding:20px;font:14px/1.5 system-ui";const l=document.createElement("h2");l.textContent="Manual connection";const c=document.createElement("p");c.textContent="No Homegames service needed. Both players need a downloaded game HTML or an already-open player. Send the offer privately; your friend sends an answer back. Keep both tabs open.";const d=document.createElement("p");d.textContent="Direct connections can still be blocked by a network or firewall. This mode shares game scenes, assets and input; live camera/microphone streams are not supported.";const u=document.createElement("p");u.setAttribute("role","status");const p=document.createElement("label"),f=document.createElement("input");f.type="checkbox",f.checked=!0,p.append(f," Use public STUN for internet connections (Google). Turn off for LAN-only pairing.");const m=document.createElement("section"),g=document.createElement("section"),y=document.createElement("h3");y.textContent="Host a player",m.append(y);const v=document.createElement("h3");v.textContent="Join a host",g.append(v);let w=null,x=null,b=!1,E=!1;const S=[],k=e=>{b||(u.textContent=e)},_=(e,t,s)=>{const r=document.createElement("button");return r.textContent=t,r.style.cssText="padding:7px 10px;margin:4px;cursor:pointer",r.onclick=async()=>{if(!E){E=!0,S.forEach(e=>e.disabled=!0);try{await s()}catch(e){k(e.message)}finally{E=!1,S.forEach(e=>e.disabled=!1)}}},S.push(r),e.append(r),r},C=(e,t,s=!1)=>{const r=document.createElement("label");r.textContent=t;const i=document.createElement("textarea");return i.setAttribute("aria-label",t),i.readOnly=s,i.maxLength=131072,i.style.cssText="display:block;box-sizing:border-box;width:100%;height:90px;margin:5px 0 12px;background:#101820;color:#eef;border:1px solid #547286;padding:8px;font:11px monospace",r.append(i),e.append(r),i},A=C(m,"Offer to send",!0),I=C(m,"Answer from friend");_(m,"Create offer",async()=>{const e=t();if(!e?.game)throw new Error("Start a local game to host a player");w||(w=new r(e,{onStatus:k})),w.iceServers=f.checked?n:[],A.value="",I.value="",k("Collecting network addresses…"),A.value=await w.createOffer(),k("Send the entire offer to your friend. It expires in 10 minutes.")});const T=async e=>{if(!e.value)throw new Error("Create the handshake first");try{await navigator.clipboard.writeText(e.value),k("Handshake copied")}catch(t){e.focus(),e.select(),k("Copy the selected handshake text")}};_(m,"Copy offer",()=>T(A)),_(m,"Connect with answer",async()=>{if(!w)throw new Error("Create an offer first");await w.acceptAnswer(I.value),k("Connecting directly…")}),_(m,"Cancel offer",()=>{w?.cancelOffer(),A.value="",I.value="",k("Pending offer cancelled")});const P=C(g,"Offer from host"),L=C(g,"Answer to send",!0);_(g,"Create answer",async()=>{const e=i(P.value,{iceServers:f.checked?n:[],onStatus:k});w?.stop(),w=null,x?.close(),x=e,L.value="",k("Collecting network addresses…");try{s(e.transport),L.value=await e.answer(),k("Send the entire answer back to the host, then choose Done.")}catch(t){throw e.close(),t}}),_(g,"Copy answer",()=>T(L));const M=document.createElement("button");return M.textContent="Done",M.style.cssText="padding:8px 18px;margin-top:16px",M.onclick=()=>h.close(),h.append(l,c,p,m,g,d,u,M),e.append(h),h.onclose=a,{show(){b||h.open||(h.showModal(),o())},dispose(){b||(b=!0,w?.stop(),x?.close(),h.remove())}}}},3598(e,t,s){const r=s(7511);e.exports=class{constructor({container:e,assets:t,send:s,platform:i,publish:n=()=>{},unpublish:o=()=>{}}){Object.assign(this,{container:e,assets:t,send:s,publish:n,unpublish:o}),this.streams=new Map,this.received=new Map,this.pending=new Map,this.held=new Set,this.recorder=new r({container:e,send:s,platform:i,busy:()=>this.pending.size||[...this.streams.values()].some(e=>e.local)}),t.liveMedia=this,this.releaseAll=()=>this.release(),this.visibility=()=>{document.hidden&&this.release()},window.addEventListener("blur",this.releaseAll),document.addEventListener("visibilitychange",this.visibility)}hold(e){this.held.add(e)}release(e){if(e?this.held.delete(e):this.held.clear(),!this.held.size){for(const e of this.streams.values())e.local&&e.pushToTalk&&(e.transmitting=!1,e.data.getTracks().forEach(e=>{e.enabled=!1}),this.send({type:"media",action:"released",id:e.id}));this.assets._notifyReady()}}receive(e){if(!this.closed){if("record"===e.action)return this.recorder.request(e.recording);if("record-cancel"===e.action)return this.recorder.cancel(e.id);if("request"===e.action)return this.request(e.stream);if("ended"===e.action)return this.remove(e.id);if(["available","state"].includes(e.action)){const t=e.stream;if(!t||"string"!=typeof t.id)return;const s=this.streams.get(t.id);s?(Object.assign(s,t),s.local&&(t.pushToTalk&&!this.held.size&&t.transmitting&&(s.transmitting=!1,this.send({type:"media",action:"released",id:t.id})),s.data.getTracks().forEach(e=>{e.enabled=s.transmitting}))):this.streams.set(t.id,{...t,type:"stream",data:this.received.get(t.sourceId),local:!1}),this.assets._notifyReady()}}}attach(e){this.received.set(e.id,e);for(const t of this.streams.values())t.local||t.sourceId!==e.id||(t.data=e);this.assets._notifyReady()}request(e){if(!e||this.pending.has(e.id))return;if(this.recorder.active||this.pending.size||[...this.streams.values()].some(e=>e.local))return void this.send({type:"media",action:"result",id:e.id,error:"A microphone/camera is already active or awaiting permission"});const t=document.createElement("dialog");t.setAttribute("aria-label","Enable live media"),t.style.cssText="margin:auto;padding:24px;max-width:360px;border:1px solid #666;border-radius:16px;background:#202321;color:white;font:16px system-ui";const s=document.createElement("p");s.textContent=e.video?`Share your camera${e.audio?" and microphone":""} with this session?`:"Enable your microphone for this session?";const r=document.createElement("button");r.textContent=e.video?"Enable camera":"Enable microphone";const i=document.createElement("button");i.textContent="Cancel";for(const e of[r,i])e.style.cssText="padding:12px;margin:16px 8px 0 0;font:inherit";t.append(s,r,i),this.container.appendChild(t),this.pending.set(e.id,t);const n=t=>{this.remove(e.id),this.send({type:"media",action:"result",id:e.id,error:t})};t.oncancel=e=>{e.preventDefault(),n("Microphone/camera permission cancelled")},i.onclick=()=>n("Microphone/camera permission cancelled"),r.onclick=async()=>{r.disabled=!0;try{if(this.assets.unlockAudio?.(),!navigator.mediaDevices?.getUserMedia)throw new Error("Microphone/camera requires HTTPS or localhost");const s=await navigator.mediaDevices.getUserMedia({audio:!!e.audio&&{echoCancellation:!0,noiseSuppression:!0},video:!!e.video&&{width:{ideal:640},height:{ideal:360},frameRate:{ideal:20,max:30}}});if(this.closed||!this.pending.has(e.id))return void s.getTracks().forEach(e=>e.stop());this.pending.delete(e.id),t.close(),t.remove();const r={...e,sourceId:s.id,type:"stream",data:s,local:!0,transmitting:e.transmitting&&(!e.pushToTalk||this.held.size>0)};this.streams.set(e.id,r),s.getTracks().forEach(t=>{t.enabled=!!r.transmitting,t.onended=()=>this.stopLocal(e.id)}),this.send({type:"media",action:"result",id:e.id,sourceId:s.id}),this.publish(e.id,s),this.showStop(),this.assets._notifyReady(),r.pushToTalk&&!r.transmitting&&this.send({type:"media",action:"released",id:e.id})}catch(t){this.pending.has(e.id)&&n(t.message||"Unable to access microphone/camera")}},t.showModal(),r.focus()}showStop(){if(this.stopButton)return;const e=this.stopButton=document.createElement("button");e.textContent="Disconnect microphone / camera",e.style.cssText="position:absolute;right:12px;bottom:12px;padding:10px;border:1px solid #fff;border-radius:8px;background:#8b2525;color:white;z-index:10;font:13px system-ui",e.onclick=()=>{for(const e of[...this.streams.values()])e.local&&this.stopLocal(e.id)},this.container.appendChild(e)}stopLocal(e){this.remove(e),this.send({type:"media",action:"stopped",id:e})}remove(e){const t=this.pending.get(e);t&&(this.pending.delete(e),t.close(),t.remove());const s=this.streams.get(e);this.streams.delete(e),s?.local&&(this.unpublish(e),s.data.getTracks().forEach(e=>{e.onended=null,e.stop()}),this.stopButton?.remove(),this.stopButton=null),s&&this.received.delete(s.sourceId),this.assets._notifyReady()}destroy(){if(!this.closed){this.closed=!0,this.recorder.destroy();for(const e of[...this.pending.keys(),...this.streams.keys()])this.remove(e);this.received.clear(),this.held.clear(),window.removeEventListener("blur",this.releaseAll),document.removeEventListener("visibilitychange",this.visibility),this.assets.liveMedia===this&&(this.assets.liveMedia=null)}}}},4334(e,t,s){"use strict";const r=s(3008);e.exports=function({getInvitation:e,getProject:t,onStatus:i=()=>{},...n}){let o,a,h=!1,l=0;const c=new Set,d=()=>new Error("Sharing has stopped. Reopen the game to share it."),u=()=>{l++,o?.close(),o=null,a=null};return{getLink:p=>h?Promise.reject(d()):["session","copy"].includes(p)?new Promise((f,m)=>{const g={reject:m,timer:null};c.add(g);const y=(e,t)=>{c.delete(g)&&(clearTimeout(g.timer),e?m(e):f(t))};g.timer=setTimeout(()=>{"copy"===p&&u(),y(new Error("Creating an invitation timed out. Check your connection and try again."))},3e4),Promise.resolve().then(()=>{if("copy"===p)return function(){if(o?.closed&&u(),a)return a;const e=l,r=Promise.resolve().then(async()=>{if("function"!=typeof t)throw new Error("Sharing a copy is not available in this player.");const r=await t();if(h||l!==e)throw d();const{CopyHost:a}=s(2157),c=new a(r,{...n,onStatus:t=>{if(!h&&l===e)try{i(t,"copy")}catch(e){}}});o=c;const u=await c.share();if(h||l!==e)throw c.close(),d();return u});return a=r.catch(t=>{throw l===e&&u(),t}),a}();if("function"!=typeof e)throw new Error("This session is not available to join.");return e()}).then(e=>{if(h)throw d();if("string"!=typeof e||e.length>4096||!/^https?:\/\//.test(e))throw new Error("Invalid invitation link");const t=r(0,"M");t.addData(e),t.make();const s=t.getModuleCount(),i=Array.from({length:s},(e,r)=>Array.from({length:s},(e,s)=>t.isDark(r,s)?"1":"0").join(""));y(null,{url:e,qr:i})}).catch(e=>y(e))}):Promise.reject(new Error("Unknown sharing option")),dispose(){if(!h){h=!0,u();for(const e of c)clearTimeout(e.timer),e.reject(d());c.clear()}}}}},7237(e,t,s){const r=s(5110),{prepareTrustedLocalGame:i}=s(7435),{squishMap:n}=s(9732),o={supportedRuntimes:Object.keys(n)},a=s(5758),h=s(5061),l=s(5564);e.exports={...s(2409),...s(32),create:e=>r.createProject(e,o),importArchive:e=>r.importArchive(e,o),exportArchive:r.exportArchive,withGameId:r.withGameId,normalizePath:r.normalizePath,limits:r.LIMITS,buildIsolatedHtml:a.buildIsolatedHtml,runtimeDocument:a.runtimeDocument,createFrame:a.createFrame,attachArchiveHost:a.attachArchiveHost,attachSaveHost:h.attachSaveHost,attachPlayerHost:(e,t,r)=>{const i=h.attachSaveHost(e,t,r),n=s(739).createExportStorage(e,r),o=l.attachClientHost(e,t,l.recordAudio,n,s(97).createExportsViewer,s(5900).recordVideo,s(8106).createPlayerToolbar,{...r,profile:s(4367).profile(e)});return{...i,get stopped(){return i.stopped},command:o.command,downloadGame:o.download,close:async()=>{o.close(),await i.close()}}},connectClientSource:l.connectClientSource,connectSaveStore:h.connectSaveStore,filename:a.filename,readHtmlArchive:a.readHtmlArchive,htmlBytesLimit:a.htmlBytesLimit,checkSyntax:r.checkSyntax,thumbnailPath:r.thumbnailPath,prepareTrustedLocalGame:(e,t)=>i(e,n,t)}},7511(e,t,s){const{recordAudio:r}=s(5564),{recordVideo:i}=s(5900);e.exports=class{constructor({send:e,busy:t,platform:s}){Object.assign(this,{send:e,busy:t,platform:s})}request(e){if(!e||"string"!=typeof e.id||this.closed)return;if(this.active||this.busy())return void this.send({type:"media",action:"record-result",id:e.id,error:"A microphone/camera is already active"});const t="audio"===e.kind?"recordAudio":"recordVideo",s=this.active=this.platform?.[t]?{result:this.platform[t](e),close:()=>this.platform.cancelRecording?.(e.id)}:("audio"===e.kind?r:i)(window,e);s.id=e.id,s.result.then(e=>{this.active===s&&(this.active=null,this.closed||this.send(e))},t=>{this.active===s&&(this.active=null,this.closed||this.send({type:"media",action:"record-result",id:e.id,error:t.message}))})}cancel(e){if(this.active&&this.active.id===e){const e=this.active;this.active=null,e.close()}}destroy(){this.closed=!0,this.cancel(this.active?.id)}}},549(e,t,s){const r=s(5537);e.exports=class{constructor(e,t){this.canvas=e,this.ctx=e.getContext("2d",{alpha:!1}),this.assetManager=t,this.playingSounds={},this.videos=new Map,this.mediaDirty=!1,this.thingIndices=[]}renderFrame(e,t,s={}){const{canvas:i,ctx:n,assetManager:o}=this,a=new Set(Object.keys(this.playingSounds)),h=new Set,l=new Set;this.mediaDirty=!1,n.clearRect(0,0,i.width,i.height),this.thingIndices=[];let c=0,d=!1,u=!1;for(;e&&c<e.length;){e[c];const p=e[c+1]+e[c+2]+e[c+3];let f;try{f=t("function"==typeof e.subarray?e.subarray(c,c+p):e.slice(c,c+p)).node}catch(e){c+=p;continue}if(!f.coordinates2d&&f.input&&f.text){const e=Math.floor(i.width),t=f.text.size/100*e;n.font=t+"px sans-serif";const s=n.measureText(f.text.text);let r=f.text.x*i.width/100;f.text.align&&"center"===f.text.align&&(r-=s.width/2),r=r/i.width*100;const o=s.actualBoundingBoxDescent-s.actualBoundingBoxAscent,a=s.width/i.width*100,h=o/i.height*100;this.thingIndices.push([!!f.handleClick,f.input&&f.input.type,f.id,[r,f.text.y,r+a,f.text.y,r+a,f.text.y+h,r,f.text.y+h,r,f.text.y],!!f.onHover])}else if(null!==f.coordinates2d&&void 0!==f.coordinates2d){if(this.thingIndices.push([!!f.handleClick,f.input&&f.input.type,f.id,f.coordinates2d,!!f.onHover]),f.effects&&f.effects.shadow){const e=f.effects.shadow.color;n.shadowColor="rgba("+e[0]+","+e[1]+","+e[2]+","+e[3]+")",f.effects.shadow.blur&&(n.shadowBlur=f.effects.shadow.blur,d=!1)}f.color&&(n.globalAlpha=f.color[3]/255,u=!1),null!==f.fill&&void 0!==f.fill&&(n.fillStyle="rgba("+f.fill[0]+","+f.fill[1]+","+f.fill[2]+","+f.fill[3]+")"),void 0!==f.border&&null!==f.border&&(n.lineWidth=f.border/255*.1*i.width,n.strokeStyle="rgba("+f.color[0]+","+f.color[1]+","+f.color[2]+","+f.color[3]+")"),n.beginPath();const e=f.coordinates2d[0];n.moveTo(e[0]*i.width/100,e[1]*i.height/100);for(let e=1;e<f.coordinates2d.length;e++){const t=f.coordinates2d[e];n.lineTo(t[0]*i.width/100,t[1]*i.height/100)}void 0!==f.fill&&null!==f.fill&&n.fill(),void 0!==f.border&&null!==f.border&&n.stroke(),d||(n.shadowBlur=0,d=!0)}if(f.text){n.globalAlpha=f.text.color[3]/255,u=!1,n.fillStyle="rgba("+f.text.color[0]+","+f.text.color[1]+","+f.text.color[2]+","+f.text.color[3]+")";const e=Math.floor(i.width),t=f.text.size/100*e,s=f.text.font&&"default"!==f.text.font?f.text.font:"sans-serif";n.font=t+"px "+s,f.text.align&&(n.textAlign=f.text.align),n.textBaseline="top",n.fillText(f.text.text,f.text.x*i.width/100,f.text.y*i.height/100)}if(f.asset||f.stream){const e=f.stream,t=e?e.id:Object.keys(f.asset)[0],c=e?o.liveMedia?.streams.get(e.id):o.assets[t];if(c&&"audio"===c.type){const e=`${f.id}:${t}`;if(!s.muteAudio)if(h.add(e),!this.playingSounds[e]&&o.audioCtx&&c.decoded){const s=o.audioCtx.createBufferSource();s.connect(o.audioCtx.destination),s.buffer=c.data,s.start(0,f.asset[t].startTime||0),this.playingSounds[e]=s}else this.playingSounds[e]&&a.delete(e)}else if(c&&("image"===c.type||"video"===c.type||e&&c.data)){const a=e||f.asset[t];let h;if("video"===c.type||e){const d=`${f.id}:${t}`;l.add(d);let u=this.videos.get(d);u&&u.asset!==c&&(u.destroy(),u=null);const p={...s,muteAudio:!!s.muteAudio||!(!e||e.audio&&!c.local&&c.transmitting)};if(u||(u=new r(o,c,a.startTime||0,()=>{this.mediaDirty=!0},p),this.videos.set(d,u)),u.update(p.muteAudio,!!s.freezeMedia),h=(!e||c.video)&&!u.error&&u.element.readyState>=2?u.element:null,!h&&(!e||c.video)){const e=a.pos.x/100*i.width,t=a.pos.y/100*i.height;n.fillStyle="#202226",n.fillRect(e,t,a.size.x/100*i.width,a.size.y/100*i.height),n.fillStyle="#fff",n.font=`${Math.max(12,.015*i.width)}px sans-serif`,n.textAlign="center",n.textBaseline="middle",n.fillText(u.error?"Video format not supported":"Loading video…",e+a.size.x/200*i.width,t+a.size.y/200*i.height)}}else h=o.getImage(t);if(h){if(h.width=a.size.x/100*i.width,h.height=a.size.y/100*i.height,f.effects&&f.effects.shadow){const e=f.effects.shadow.color;n.shadowColor="rgba("+e[0]+","+e[1]+","+e[2]+","+e[3]+")",f.effects.shadow.blur&&(n.shadowBlur=f.effects.shadow.blur,d=!1)}const e=a.pos.x/100*i.width,t=a.pos.y/100*i.height;let s=a.cropLeft||0,r=a.cropTop||0,o=a.cropRight||0,l=a.cropBottom||0;if(s+o>=100&&(s=0,o=0),r+l>=100&&(r=0,l=0),s||r||o||l){let i=s/100*(h.videoWidth||h.naturalWidth),a=r/100*(h.videoHeight||h.naturalHeight),c=(1-(s+o)/100)*(h.videoWidth||h.naturalWidth),d=(1-(r+l)/100)*(h.videoHeight||h.naturalHeight);i=Math.max(0,Math.min(i,(h.videoWidth||h.naturalWidth)-1)),a=Math.max(0,Math.min(a,(h.videoHeight||h.naturalHeight)-1)),c=Math.min(c,(h.videoWidth||h.naturalWidth)-i),d=Math.min(d,(h.videoHeight||h.naturalHeight)-a),c>=1&&d>=1&&n.drawImage(h,i,a,c,d,e,t,h.width,h.height)}else n.drawImage(h,e,t,h.width,h.height)}}}c+=p,d||(n.shadowBlur=0,d=!0),u||(n.globalAlpha=1,u=!0)}for(const[e,t]of this.videos)l.has(e)||(t.destroy(),this.videos.delete(e));for(const e in this.playingSounds)if(!h.has(e)){try{this.playingSounds[e].stop()}catch(e){}delete this.playingSounds[e]}}needsRepaint(){return this.mediaDirty||[...this.videos.values()].some(e=>e.needsRepaint())}stopAllSounds(){for(const e of this.videos.values())e.destroy();this.videos.clear(),this.mediaDirty=!1;for(const e in this.playingSounds)try{this.playingSounds[e].stop()}catch(e){}this.playingSounds={}}}},8221(e){function t(){const e=16384,t=10485760,s=20971520;class r{constructor(e,{onMessage:t,onClose:s=()=>{},onError:r=()=>{}}){Object.assign(this,{channel:e,onMessage:t,onClose:s,onError:r}),this.queue=[],this.queuedBytes=0,this.pending=null,this.closed=!1,this.stats={sentPackets:0,receivedPackets:0,wireMessages:0,wireBytes:0,duplicateFrames:0,replacedFrames:0,maxBufferedBytes:0},this.lastFrame=null,e.binaryType="arraybuffer",e.bufferedAmountLowThreshold=16384,e.onbufferedamountlow=()=>this.flush(),e.onmessage=e=>{try{this.receive(e.data)}catch(e){this.fail(e)}},e.onclose=()=>this.close(),e.onerror=()=>this.fail(new Error("Game connection failed"))}send(e){if(this.closed)return;const r="string"==typeof e,i=r?(new TextEncoder).encode(e):e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength);if(!i.length||i.length>t)return this.fail(new Error("Game packet is too large"));const n=!r&&3===i[0];if(n){if(this.lastFrame&&i.length===this.lastFrame.length&&i.every((e,t)=>e===this.lastFrame[t]))return void this.stats.duplicateFrames++;this.lastFrame=i,this.queue=this.queue.filter(e=>!e.frame||null!==e.offset||(this.queuedBytes-=e.bytes.length,this.stats.replacedFrames++,!1))}if(this.queuedBytes+i.length>s)return this.fail(new Error("Guest connection is too slow"));this.queue.push({bytes:i,text:r,frame:n,offset:null}),this.queuedBytes+=i.length,this.flush()}flush(){try{for(;!this.closed&&"open"===this.channel.readyState&&this.queue.length&&this.channel.bufferedAmount<65536;){const t=this.queue[0];null===t.offset&&(this.write(JSON.stringify({bytes:t.bytes.length,text:t.text})),t.offset=0),this.write(t.bytes.subarray(t.offset,t.offset+e)),t.offset+=e,t.offset>=t.bytes.length&&(this.queue.shift(),this.queuedBytes-=t.bytes.length,this.stats.sentPackets++)}}catch(e){this.fail(e)}}write(e){this.channel.send(e),this.stats.wireMessages++,this.stats.wireBytes+="string"==typeof e?e.length:e.byteLength,this.stats.maxBufferedBytes=Math.max(this.stats.maxBufferedBytes,this.channel.bufferedAmount)}receive(s){if(this.closed)return;if("string"==typeof s){const e=JSON.parse(s);if(this.pending||!Number.isInteger(e.bytes)||e.bytes<1||e.bytes>t||"boolean"!=typeof e.text)throw new Error("Invalid game packet");return this.pending={bytes:new Uint8Array(e.bytes),text:e.text,offset:0},void(this.receiveTimer=setTimeout(()=>this.fail(new Error("Game packet timed out")),3e4))}const r=this.pending;if(!(s instanceof ArrayBuffer)||!r||!s.byteLength||s.byteLength>e||r.offset+s.byteLength>r.bytes.length)throw new Error("Invalid game packet");r.bytes.set(new Uint8Array(s),r.offset),r.offset+=s.byteLength,r.offset===r.bytes.length&&(clearTimeout(this.receiveTimer),this.pending=null,this.stats.receivedPackets++,this.onMessage(r.text?(new TextDecoder).decode(r.bytes):r.bytes.buffer))}fail(e){this.closed||(this.onError(e),this.close())}close(){this.closed||(this.closed=!0,clearTimeout(this.receiveTimer),this.queue=[],this.pending=null,this.queuedBytes=0,this.lastFrame=null,this.channel.onmessage=this.channel.onclose=this.channel.onerror=this.channel.onbufferedamountlow=null,this.channel.close(),this.onClose())}}return r.Mailbox=class{constructor(e,t){Object.assign(this,{deliver:e,fail:t}),this.queue=[],this.bytes=0,this.waiting=!1,this.closed=!1,this.replacedFrames=0}send(e,t=!1){if(this.closed)return;const r="string"==typeof e,i=r?null:e instanceof ArrayBuffer?new Uint8Array(e):e,n=3===i?.[0];n&&(this.queue=this.queue.filter(e=>!e.frame||(this.bytes-=e.size,this.replacedFrames++,!1)));const o=r?2*e.length:i.byteLength;this.bytes+o>s?this.fail(new Error("Game message queue is full")):(this.queue.push({data:e,transfer:t,frame:n,size:o}),this.bytes+=o,this.pump())}pump(){if(this.closed||this.waiting||!this.queue.length)return;const e=this.queue.shift();this.bytes-=e.size,this.waiting=!0;try{this.deliver(e.data,e.transfer)}catch(e){this.fail(e)}}ack(){this.waiting=!1,this.pump()}close(){this.closed=!0,this.queue=[],this.bytes=0}},r}const s=t();s.workerSource=()=>`(${t.toString()})()`,e.exports=s},8334(e,t,s){"use strict";const{LIMITS:r}=s(5110),i=async e=>Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",e)),e=>e.toString(16).padStart(2,"0")).join(""),n=e=>{if("string"!=typeof e||e.length>4096)throw new Error("Invalid game-copy message");const t=JSON.parse(e);if(!t||"object"!=typeof t||Array.isArray(t))throw new Error("Invalid game-copy message");return t};function o(e){if("copy-offer"!==e.type||1!==e.protocol||"string"!=typeof e.name||!e.name.length||e.name.length>200||!/^[a-f0-9]{64}$/.test(e.revision)||!/^[a-f0-9]{64}$/.test(e.sha256)||!/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i.test(e.gameId)||!Number.isSafeInteger(e.bytes)||e.bytes<1||e.bytes>r.archiveBytes)throw new Error("Invalid or oversized game copy");return{type:"copy-offer",protocol:1,name:e.name,revision:e.revision,sha256:e.sha256,gameId:e.gameId,bytes:e.bytes}}e.exports={Sender:class{constructor(e,t,s,r=()=>{}){if(this.bytes=e,this.send=s,this.progress=r,this.metadata=o(t),this.offset=0,this.accepted=!1,this.done=!1,e.length!==t.bytes)throw new Error("Game-copy size changed")}open(){this.send(JSON.stringify(this.metadata))}receive(e){const t=n(e);if("copy-accept"===t.type&&!this.accepted)return this.accepted=!0,void this.next();if("copy-ack"===t.type&&this.accepted&&!this.done&&t.offset===this.offset)return this.progress(this.offset,this.bytes.length),void(this.offset===this.bytes.length?(this.done=!0,this.send(JSON.stringify({type:"copy-complete"}))):this.next());if("copy-saved"!==t.type||!this.done)throw new Error("Unexpected game-copy acknowledgement")}next(){const e=Math.min(this.offset+65536,this.bytes.length),t=new Uint8Array(5+e-this.offset);t[0]=80,new DataView(t.buffer).setUint32(1,this.offset),t.set(this.bytes.subarray(this.offset,e),5),this.offset=e,this.send(t)}},Receiver:class{constructor(e,{onOffer:t=()=>{},onProgress:s=()=>{},importArchive:r,onComplete:i}){Object.assign(this,{send:e,onOffer:t,onProgress:s,importArchive:r,onComplete:i}),this.metadata=null,this.bytes=null,this.offset=0,this.state="offer"}accept(){if("waiting"!==this.state)throw new Error("Wait for the game details before receiving");this.bytes=new Uint8Array(this.metadata.bytes),this.state="receiving",this.send(JSON.stringify({type:"copy-accept"}))}async receive(e){if("closed"===this.state)return;if("string"==typeof e){const t=n(e);if("offer"===this.state)return this.metadata=o(t),this.state="waiting",void this.onOffer(this.metadata);if("copy-complete"!==t.type||"receiving"!==this.state||this.offset!==this.metadata.bytes)throw new Error("Incomplete game copy");this.state="validating";const s=this.bytes,r=this.metadata,a=await i(s);if("closed"===this.state)return;if(a!==r.sha256)throw new Error("The game copy was damaged during transfer. Try again.");const h=await this.importArchive(s);if(h.revision!==r.revision||h.manifest.gameId!==r.gameId)throw new Error("The received game does not match the offered copy");if("closed"===this.state)return;if(await this.onComplete({bytes:s,project:h}),"closed"===this.state)return;return this.state="done",this.bytes=null,void this.send(JSON.stringify({type:"copy-saved"}))}if("receiving"!==this.state)throw new Error("Unexpected game-copy data");const t=e instanceof ArrayBuffer?new Uint8Array(e):e,s=Math.min(65536,this.metadata.bytes-this.offset);if(!(t instanceof Uint8Array&&t.length===s+5&&s&&80===t[0]&&new DataView(t.buffer,t.byteOffset,t.byteLength).getUint32(1)===this.offset))throw new Error("Invalid game-copy chunk");this.bytes.set(t.subarray(5),this.offset),this.offset+=s,this.onProgress(this.offset,this.metadata.bytes),this.send(JSON.stringify({type:"copy-ack",offset:this.offset}))}close(){this.state="closed",this.bytes=null}},digest:i}},2157(e,t,s){"use strict";const r=s(1240),{Peer:i,signalUrl:n}=s(4454),o=s(8334),a=s(7237);class h{constructor(e,{signalingUrl:t="wss://api.homegames.io/rtc",receiveUrl:s="https://homegames.io/game-app.html",worker:r=!0,iceTransportPolicy:i="all",onStatus:n=()=>{}}={}){Object.assign(this,{project:e,signalingUrl:t,receiveUrl:s,worker:r,iceTransportPolicy:i,onStatus:n}),this.peers=new Map,this.closed=!1}share(){return this.closed?Promise.reject(new Error("Copy sharing has stopped. Open Share a copy again.")):this.pending||=this.start()}async start(){this.bytes=await a.exportArchive(this.project);const e=await o.digest(this.bytes);if(this.closed)throw new Error("Copy sharing stopped");return this.metadata={type:"copy-offer",protocol:1,name:String(this.project.metadata.name||"Homegame").slice(0,200),gameId:this.project.manifest.gameId,revision:this.project.revision,bytes:this.bytes.length,sha256:e},this.network=new r({worker:this.worker}),new Promise((e,t)=>{this.reject=t,this.signal=this.network.signal(n(this.signalingUrl),{type:"create",visibility:"private",maxPlayers:5},t=>{if("created"===t.type){const s=new URL(this.receiveUrl,window.location.href);if(!["http:","https:"].includes(s.protocol))throw new Error("Invalid game-copy destination");s.search=new URLSearchParams({game:this.metadata.gameId,revision:this.metadata.revision}),s.hash=new URLSearchParams({copy:"1",room:t.roomId,invite:t.invite,signal:n(this.signalingUrl)}),this.link=s.href,this.reject=null,t.heartbeatIntervalMs&&this.signal.startHeartbeat(t.heartbeatIntervalMs,{type:"heartbeat",playerCount:1}),this.onStatus("Ready to send a copy"),e(this.link)}else"peer-joined"===t.type?this.addPeer(t):"peer-left"===t.type?this.peers.get(t.peerId)?.close():"signal"===t.type&&this.peers.get(t.peerId)?.signal(t)},e=>{this.close(e),e&&this.onStatus(e.message)})})}addPeer({peerId:e,iceServers:t}){let s,r;const n=()=>{clearTimeout(r),r=setTimeout(()=>a.close(new Error("Copy transfer timed out. Open the invitation to try again.")),12e4)},a=new i({host:!0,network:this.network,iceServers:t,iceTransportPolicy:this.iceTransportPolicy,sendSignal:t=>this.signal?.send({type:"signal",peerId:e,...t}),onOpen:e=>{s=new o.Sender(this.bytes,this.metadata,t=>e.send(t),(e,t)=>this.onStatus(`Sending copy · ${Math.round(e/t*100)}%`)),n(),s.open()},onMessage:e=>{try{n(),s.receive(e)}catch(e){a.close(e)}},onEnd:t=>{clearTimeout(r),this.peers.delete(e),this.signal?.send({type:"remove",peerId:e}),this.closed||this.onStatus(t?t.message:"Ready to send another copy")}});this.peers.set(e,a),a.offer()}close(e){if(!this.closed){this.closed=!0,this.reject?.(e||new Error("Copy sharing stopped")),this.reject=null,this.signal?.close();for(const e of this.peers.values())e.close();this.peers.clear(),this.network?.close(),this.bytes=null}}}e.exports={CopyHost:h,receiveCopy:function(e,{onOffer:t,onProgress:s,onComplete:h,onError:l=()=>{},worker:c=!0,iceTransportPolicy:d="all"}){const u=new r({worker:c});let p,f,m,g,y=!1,v=!1,w=!1;const x=()=>{w||(w=!0,clearTimeout(g),p?.close(),f?.close(),u.close())},b=()=>{y||(y=!0,m?.close(),x())},E=e=>{y||(b(),v||l(e||new Error("The sender disconnected before the copy was saved. Open the invitation to try again.")))},S=e=>{w||y||("validating"===m?.state||v?x():E(e))},k=()=>{clearTimeout(g),g=setTimeout(()=>E(new Error("Copy transfer timed out. Open the invitation to try again.")),12e4)};return m=new o.Receiver(e=>{w||p.channel.send(e)},{onOffer:t,onProgress:s,importArchive:a.importArchive,onComplete:async e=>{clearTimeout(g),await h(e),v=!0,setTimeout(b,100)}}),f=u.signal(n(e.signalingUrl),{type:"join",roomId:e.roomId,invite:e.invite},e=>{"joined"===e.type?p=new i({network:u,iceServers:e.iceServers,iceTransportPolicy:d,sendSignal:e=>f.send({type:"signal",...e}),onOpen:k,onMessage:e=>{k(),m.receive(e).catch(E)},onEnd:S}):"signal"===e.type&&p?.signal(e)},S),{accept:()=>{if(y||!m)throw new Error("Reconnect to the sender to receive this game");k(),m.accept()},close:b}},readCopyInvitation:function(e){if("string"!=typeof e||e.length>4096)throw new Error("Paste a Share a copy invitation");const t=new URL(e,window.location.href),s=new URLSearchParams(t.hash.slice(1));if(!["http:","https:"].includes(t.protocol)||"1"!==s.get("copy")||!/^[A-Za-z0-9_-]{24}$/.test(s.get("room"))||!/^[A-Za-z0-9_-]{24}$/.test(s.get("invite")))throw new Error("Paste a Share a copy invitation");if(!/^wss?:\/\//.test(s.get("signal")||""))throw new Error("Invalid invitation service");const r=n(s.get("signal")),i=new URL(r);if(i.username||i.password||i.hash||i.search)throw new Error("Invalid invitation service");return{roomId:s.get("room"),invite:s.get("invite"),signalingUrl:r}},showCopyShare:function(e,t={}){let r,i=!1;const n=new h(e,{...t,onStatus:e=>r?.setStatus(e)}),o=()=>{i||(i=!0,n.close(),r.dispose(),t.onClose?.())};return r=s(172)({container:document.body,getLink:()=>n.share(),title:"Share a copy",hintText:"Your source, sounds and images are included. Keep this window open until the other person has saved their copy.",readyText:"Anyone with this link can keep an independent, editable copy.",closeLabel:"Stop sharing",onOpen:t.onOpen,onClose:o}),r.show(),{close:o}}}},9742(e,t,s){const r=s(1240),i=[{urls:"stun:stun.l.google.com:19302"}],n=131072;function o(e,t){if("string"!=typeof e||e.length>n)throw new Error("Handshake is missing or too large");let s;try{s=JSON.parse(e.trim())}catch(e){throw new Error("Paste the complete handshake text")}if("homegames-rtc"!==s?.format||1!==s.version||s.kind!==t||!/^[0-9a-f-]{36}$/i.test(s.id||"")||s.description?.type!==t||"string"!=typeof s.description.sdp||!s.description.sdp.startsWith("v=0")||(s.description.sdp.match(/^a=candidate:/gm)||[]).length>128||/^m=(audio|video) /m.test(s.description.sdp))throw new Error(`This is not a supported Homegames ${t}`);return s}function a(e,t){const s=JSON.stringify({format:"homegames-rtc",version:1,kind:t,id:e.id,description:e.pc.localDescription.toJSON()});if(s.length>n)throw new Error("Handshake is too large");return s}function h(e){return"complete"===e.pc.iceGatheringState?Promise.resolve():new Promise((t,s)=>{const r=r=>{clearTimeout(n),e.pc.removeEventListener("icegatheringstatechange",i),e.cancelGather=null,r?s(r):t()},i=()=>{"complete"===e.pc.iceGatheringState&&r()},n=setTimeout(()=>r(new Error("Network discovery timed out. Retry, or disable public STUN for a local-network connection.")),2e4);e.cancelGather=()=>r(new Error("Manual pairing cancelled")),e.pc.addEventListener("icegatheringstatechange",i),i()})}class l{constructor({id:e=crypto.randomUUID(),iceServers:t=i,onOpen:s=()=>{},onMessage:n=()=>{},onEnd:o=()=>{}}={}){Object.assign(this,{id:e,onEnd:o}),this.closed=!1,this.network=new r({worker:!1}),this.pc=new RTCPeerConnection({iceServers:t}),this.bind=e=>{this.channel||this.closed?e.close():this.channel=this.network.bind(e,{onOpen:()=>{clearTimeout(this.expiry),s()},onMessage:n,onClose:()=>this.close(),onError:e=>this.close(e)})},this.pc.ondatachannel=e=>this.bind(e.channel),this.pc.onconnectionstatechange=()=>{"failed"===this.pc.connectionState&&this.close(new Error("Could not connect directly. This network may require a TURN relay.")),clearTimeout(this.disconnected),"disconnected"===this.pc.connectionState&&(this.disconnected=setTimeout(()=>this.close(new Error("The other player disconnected")),1e4))},this.expiry=setTimeout(()=>this.close(new Error("Handshake expired. Create a fresh offer.")),6e5)}close(e){this.closed||(this.closed=!0,clearTimeout(this.expiry),clearTimeout(this.disconnected),this.cancelGather?.(),this.pc.ondatachannel=this.pc.onconnectionstatechange=null,this.network.close(),this.pc.close(),this.onEnd(e))}}e.exports={ManualHost:class{constructor(e,{iceServers:t=i,onStatus:s=()=>{}}={}){Object.assign(this,{session:e,iceServers:t,onStatus:s}),this.peers=new Set,this.pending=null}async createOffer(){if(!this.session.game)throw new Error("Start the game before creating an offer");this.cancelOffer();let e=null,t=Date.now(),s=0;const r=new l({iceServers:this.iceServers,onMessage:i=>{try{if("string"!=typeof i||i.length>65536)throw new Error("Invalid player input");if(Date.now()-t>1e3&&(t=Date.now(),s=0),++s>240)throw new Error("Too much player input");if(e)e.handleMessage(i);else{const t=JSON.parse(i);if("ready"!==t.type)throw new Error("Expected player handshake");e=this.session.addRemotePlayer({send:(e,t)=>r.channel.send(e,t),close:()=>r.close(),playerName:t.playerName,clientInfo:t.clientInfo?.clientInfo||{}}),this.onStatus("Manual player connected")}}catch(e){r.close(e)}},onEnd:t=>{this.peers.delete(r),this.pending===r&&(this.pending=null),e?.leave(),this.onStatus(t?.message||"Manual player disconnected")}});this.peers.add(r),this.pending=r,r.bind(r.pc.createDataChannel("homegames",{ordered:!0}));try{if(await r.pc.setLocalDescription(await r.pc.createOffer()),await h(r),r.closed)throw new Error("Offer cancelled");return a(r,"offer")}catch(e){throw r.close(),e}}async acceptAnswer(e){const t=o(e,"answer"),s=this.pending;if(!s||s.closed)throw new Error("Create an offer first");if(t.id!==s.id)throw new Error("This answer belongs to a different offer");if("have-local-offer"!==s.pc.signalingState)throw new Error("This offer has already been answered");await s.pc.setRemoteDescription(t.description),this.pending=null}cancelOffer(){this.pending?.close(),this.pending=null}stop(){for(const e of[...this.peers])e.close();this.pending=null}},createManualGuest:function(e,{iceServers:t=i,onStatus:s=()=>{}}={}){const r=o(e,"offer");let n=null,c=!1,d=!1;const u=new l({id:r.id,iceServers:t,onOpen:()=>{c=!0,n?.onOpen(),s("Connected to host")},onMessage:e=>{"string"!=typeof e&&n?.onMessage(e)},onEnd:e=>{d=!0,e&&n?.onError(e),n?.onClose(),s(e?.message||"Host disconnected")}});let p;return{transport:e=>(n=e,c&&queueMicrotask(()=>n.onOpen()),{send:e=>u.channel?.send(e),close:()=>u.close(),getStats:()=>u.network.getStats()}),answer:()=>p||(p=(async()=>{try{if(d)throw new Error("Connection closed");return await u.pc.setRemoteDescription(r.description),await u.pc.setLocalDescription(await u.pc.createAnswer()),await h(u),a(u,"answer")}catch(e){throw u.close(),e}})()),close:()=>u.close()}},readHandshake:o,DEFAULT_ICE:i}},1240(e,t,s){const r=s(8221),i=s(844),n=s(2402);e.exports=class{constructor({worker:e=!0}={}){if(this.channels=new Map,this.nextId=0,this.statsRequests=new Map,this.closed=!1,this.worker=null,e&&"undefined"!=typeof Worker&&"undefined"!=typeof Blob&&"function"==typeof URL.createObjectURL)try{this.workerUrl=URL.createObjectURL(new Blob([`(${n.toString()})(${r.workerSource()},${i.toString()});`],{type:"text/javascript"})),this.worker=new Worker(this.workerUrl,{name:"homegames-rtc"}),this.worker.onmessage=e=>this.receive(e.data),this.worker.onerror=e=>{e.preventDefault?.();const t=new Error(e.message||"RTC communication worker failed");this.onSignalEnd?.(t);for(const e of[...this.channels.values()])e.callbacks.onError(t);this.close()}}catch(e){this.worker?.terminate(),this.worker=null,this.workerUrl&&URL.revokeObjectURL(this.workerUrl),this.workerUrl=null}}signal(e,t,s,r,n){if(this.onSignalMessage=s,this.onSignalEnd=r,this.onHeartbeat=n,!this.worker)return this.inlineSignal=i(e,t,s,r,n);const o=(e,t={})=>{this.closed||this.worker.postMessage({type:e,...t})};return o("signal-open",{url:e,hello:t}),{send:e=>o("signal-send",{data:e}),startHeartbeat:(e,t)=>o("heartbeat-start",{interval:e,data:t}),heartbeat:e=>o("heartbeat-update",{data:e}),close:()=>{this.onSignalEnd=null,o("signal-close")}}}bind(e,t){const s=++this.nextId,i={callbacks:t,mode:"main-thread",protocol:null,mailbox:null};if(this.channels.set(s,i),this.worker)try{this.worker.postMessage({type:"bind",id:s,channel:e},[e]),i.mode="worker"}catch(e){}if("worker"===i.mode)i.mailbox=new r.Mailbox((e,t)=>{this.worker.postMessage({type:"send",id:s,data:e},t&&"string"!=typeof e?[e.buffer||e]:[])},e=>t.onError(e));else{i.protocol=new r(e,t);let s=!1;const n=()=>{s||i.protocol.closed||this.closed||(s=!0,i.protocol.flush(),t.onOpen())};e.onopen=n,"open"===e.readyState&&queueMicrotask(n)}return{send:(e,{transfer:t=!1}={})=>{!this.closed&&this.channels.has(s)&&(i.mailbox?i.mailbox.send(e,t):i.protocol.send(e))},close:()=>{this.channels.delete(s)&&(i.mailbox?.close(),i.protocol?.close(),"worker"!==i.mode||this.closed||this.worker.postMessage({type:"channel-close",id:s}))}}}receive(e){if(this.closed)return;const t=this.channels.get(e.id);switch(e.type){case"signal-message":try{this.onSignalMessage?.(e.data)}catch(e){this.onSignalEnd?.(e)}break;case"signal-end":this.onSignalEnd?.(e.message?new Error(e.message):null);break;case"heartbeat":this.onHeartbeat?.(e.data);break;case"channel-open":t?.callbacks.onOpen();break;case"channel-error":t?.callbacks.onError(new Error(e.message));break;case"channel-close":t?.callbacks.onClose();break;case"sent":t?.mailbox.ack();break;case"data":try{t?.callbacks.onMessage(e.data)}catch(e){t?.callbacks.onError(e)}this.closed||this.worker.postMessage({type:"received",id:e.id});break;case"stats":{const t=this.statsRequests.get(e.id);t&&(clearTimeout(t.timer),this.statsRequests.delete(e.id),t.resolve(e.channels));break}}}async getStats(){const e=[...this.channels].filter(([,e])=>e.protocol).map(([e,t])=>({id:e,mode:t.mode,...t.protocol.stats,queuedBytes:t.protocol.queuedBytes,bufferedBytes:t.protocol.channel.bufferedAmount}));let t=[];return this.worker&&!this.closed&&(t=await new Promise(e=>{const t=++this.nextId,s=setTimeout(()=>{this.statsRequests.delete(t),e([])},2e3);this.statsRequests.set(t,{resolve:e,timer:s}),this.worker.postMessage({type:"stats",id:t})})),{worker:!!this.worker&&!this.closed,channels:[...t,...e].map(e=>({...e,sendQueueBytes:this.channels.get(e.id)?.mailbox?.bytes||0,sendReplacedFrames:this.channels.get(e.id)?.mailbox?.replacedFrames||0}))}}close(){if(!this.closed){this.closed=!0;for(const e of this.channels.values())e.mailbox?.close(),e.protocol?.close();this.channels.clear(),this.inlineSignal?.close(),this.worker?.terminate(),this.workerUrl&&URL.revokeObjectURL(this.workerUrl),this.statsRequests.forEach(e=>{clearTimeout(e.timer),e.resolve([])}),this.statsRequests.clear()}}}},4454(e,t,s){const r=s(1240),i=e=>{const t=new URL(e,window.location.href);if("https:"===t.protocol&&(t.protocol="wss:"),"http:"===t.protocol&&(t.protocol="ws:"),!["ws:","wss:"].includes(t.protocol))throw new Error("Invalid signaling URL");return t.href};class n{constructor({iceServers:e,sendSignal:t,onOpen:s,onMessage:r,onEnd:i,onTrack:n=()=>{},network:o,host:a=!1,iceTransportPolicy:h="all"}){this.pc=new RTCPeerConnection({iceServers:e,iceTransportPolicy:h}),Object.assign(this,{sendSignal:t,onEnd:i}),this.pendingCandidates=[],this.work=Promise.resolve(),this.closed=!1,this.polite=!a,this.senders=new Map,this.receivedStreams=new Map,this.pc.onnegotiationneeded=()=>this.offer(),this.pc.ontrack=e=>{const t=e.streams[0];t&&(this.receivedStreams.set(t.id,t),this.receivedStreams.size>32&&this.receivedStreams.delete(this.receivedStreams.keys().next().value),n(t))},this.timer=setTimeout(()=>this.close(new Error("Could not connect to the other device. Check the network or TURN configuration.")),3e4),this.pc.onicecandidate=e=>{e.candidate&&t({candidate:e.candidate.toJSON()})},this.pc.onconnectionstatechange=()=>{"failed"===this.pc.connectionState&&this.close(new Error("The game connection failed")),clearTimeout(this.disconnectTimer),"disconnected"===this.pc.connectionState&&(this.disconnectTimer=setTimeout(()=>this.close(new Error("The other device disconnected")),1e4))};const l=e=>{this.closed||this.channel?e.close():this.channel=o.bind(e,{onMessage:r,onError:e=>this.close(e),onClose:()=>this.close(),onOpen:()=>{this.closed||(clearTimeout(this.timer),s(this.channel))}})};a?l(this.pc.createDataChannel("homegames",{ordered:!0})):this.pc.ondatachannel=e=>l(e.channel)}offer(){this.enqueue(async()=>{if("stable"===this.pc.signalingState){this.makingOffer=!0;try{await this.pc.setLocalDescription(await this.pc.createOffer()),this.closed||this.sendSignal({description:this.pc.localDescription.toJSON()})}finally{this.makingOffer=!1}}})}addMedia(e,t){const s=this.senders.get(e)||[];for(const e of t.getTracks())s.some(t=>t.track===e)||s.push(this.pc.addTrack(e,t));this.senders.set(e,s)}removeMedia(e){for(const t of this.senders.get(e)||[])this.closed||this.pc.removeTrack(t);this.senders.delete(e)}signal(e){this.enqueue(async()=>{if(e.description){const t="offer"===e.description.type&&(this.makingOffer||"stable"!==this.pc.signalingState);if(this.ignoreOffer=!this.polite&&t,this.ignoreOffer)return;if(await this.pc.setRemoteDescription(e.description),this.closed)return;for(const e of this.pendingCandidates.splice(0))await this.pc.addIceCandidate(e);if("offer"===e.description.type){const e=await this.pc.createAnswer();if(this.closed)return;await this.pc.setLocalDescription(e),this.closed||this.sendSignal({description:this.pc.localDescription.toJSON()})}}else if(e.candidate){if(this.ignoreOffer)return;if(this.pc.remoteDescription)await this.pc.addIceCandidate(e.candidate);else{if(!(this.pendingCandidates.length<128))throw new Error("Too many ICE candidates");this.pendingCandidates.push(e.candidate)}}})}enqueue(e){this.work=this.work.then(()=>{if(!this.closed)return e()}).catch(e=>this.close(e))}close(e){this.closed||(this.closed=!0,clearTimeout(this.timer),clearTimeout(this.disconnectTimer),this.pc.onicecandidate=this.pc.onconnectionstatechange=this.pc.ondatachannel=this.pc.ontrack=this.pc.onnegotiationneeded=null,this.senders.clear(),this.receivedStreams.clear(),this.channel?.close(),this.pc.close(),this.onEnd(e))}}const o=(e=window.location.hash)=>{const t=new URLSearchParams(e.replace(/^#/,""));return t.has("room")?{roomId:t.get("room"),invite:t.get("invite"),signalingUrl:t.get("signal")}:null};e.exports={RtcHost:class{constructor(e,{signalingUrl:t="wss://api.homegames.io/rtc",joinUrl:s="https://homegames.io/play.html",onStatus:r=()=>{},worker:i=!0,iceTransportPolicy:n="all",room:o=null,visibility:a="private",onRoom:h=()=>{},onHeartbeat:l=()=>{},onEnd:c=()=>{}}={}){Object.assign(this,{session:e,signalingUrl:t,joinUrl:s,onStatus:r,worker:i,iceTransportPolicy:n,room:o,visibility:a,onRoom:h,onHeartbeat:l,onEnd:c}),this.peers=new Map,this.link=null,this.pending=null,this.signal=null,e.onStop=()=>this.stop()}share(){return 1===this.session.maxPlayers?Promise.reject(new Error("This is a solo game. Use Share a copy to send it to a friend.")):this.link?Promise.resolve(this.link):this.pending?this.pending:this.session.game?"undefined"==typeof RTCPeerConnection?Promise.reject(new Error("This browser does not support WebRTC")):(this.pending=new Promise((e,t)=>{this.reject=t,this.network=new r({worker:this.worker}),this.signal=this.network.signal(i(this.signalingUrl),{type:"create",game:this.room,visibility:this.visibility,maxPlayers:this.session.maxPlayers},t=>{if("created"===t.type){if(this.room&&2!==t.protocol)throw new Error("The invitation service needs an update for public sessions");this.supportsHeartbeat=2===t.protocol;const s=new URL(this.joinUrl,window.location.href);s.hash=new URLSearchParams({room:t.roomId,invite:t.invite,signal:i(this.signalingUrl)}).toString(),this.link=s.href,this.reject=null,this.onRoom(this.link),this.visibility=t.visibility||this.visibility,t.heartbeatIntervalMs&&(this.signal.startHeartbeat(t.heartbeatIntervalMs,{type:"heartbeat",playerCount:this.session.players?.length||1}),this.heartbeat()),this.status(),e(this.link)}else if("peer-joined"===t.type)this.addPeer(t);else if("peer-left"===t.type)this.peers.get(t.peerId)?.close();else if("signal"===t.type)this.peers.get(t.peerId)?.signal(t);else if("visibility"===t.type){this.visibility=t.visibility,this.status();const e=this.visibilityPending;this.visibilityPending=null,e&&(clearTimeout(e.timer),e.resolve(t.visibility))}},e=>{this.stop(e),e&&this.onStatus(e.message)},e=>{this.link&&this.onHeartbeat(e.playerCount)})}),this.pending.catch(e=>{throw this.stop(e),e})):Promise.reject(new Error("The game is still loading"))}heartbeat(){const e=Math.min(17,this.session.players?.length||1);this.supportsHeartbeat&&this.signal?.heartbeat({type:"heartbeat",playerCount:e}),this.link&&this.onHeartbeat(e)}status(){const e=this.session.players?.length||1;this.onStatus(this.room?`${"public"===this.visibility?"Public":"Private"} game · ${e} ${1===e?"player":"players"}`:e>1?`${e} players connected`:"Waiting for a player")}async setVisibility(e){if(await this.share(),!this.room)throw new Error("Only catalog games can be listed publicly");if(this.visibilityPending)throw new Error("Visibility is still updating");return new Promise((t,s)=>{const r=setTimeout(()=>{this.visibilityPending=null,s(new Error("Unable to update visibility"))},1e4);this.visibilityPending={resolve:t,reject:s,timer:r},this.signal.send({type:"visibility",visibility:e})})}addPeer({peerId:e,iceServers:t}){let s=null,r=Date.now(),i=0;const o=new n({host:!0,network:this.network,iceServers:t,iceTransportPolicy:this.iceTransportPolicy,sendSignal:t=>this.signal?.send({type:"signal",peerId:e,...t}),onOpen:e=>e.send(JSON.stringify({type:"invitation",url:this.link})),onTrack:e=>{s&&this.session.media?.attach(s.playerId,e)&&o.receivedStreams.delete(e.id)},onMessage:e=>{try{if("string"!=typeof e)throw new Error("Expected player input");if(Date.now()-r>1e3&&(r=Date.now(),i=0),++i>240)throw new Error("Too much player input");if(s){const t=JSON.parse(e);if("media"===t.type){this.session.media?.handle(s.playerId,t);for(const e of o.receivedStreams.values())this.session.media?.attach(s.playerId,e)&&o.receivedStreams.delete(e.id)}else s.handleMessage(e)}else{const t=JSON.parse(e);if("ready"!==t.type)throw new Error("Expected player handshake");s=this.session.addRemotePlayer({send:(e,t)=>o.channel.send(e,t),close:()=>o.close(),playerName:t.playerName,clientInfo:t.clientInfo?.clientInfo||{}}),1===t.media&&this.session.media?.join(s.playerId,{recording:1===t.recording||2===t.recording,audioRecording:2===t.recording,send:e=>o.channel.send(JSON.stringify(e)),addMedia:(e,t)=>o.addMedia(e,t),removeMedia:e=>o.removeMedia(e)}),this.heartbeat(),this.status()}}catch(e){o.close(e)}},onEnd:t=>{this.peers.delete(e),s?.leave(),this.signal?.send({type:"remove",peerId:e}),this.heartbeat(),!s&&t?this.onStatus(t.message):this.status()}});this.peers.set(e,o),o.offer()}getStats(){return this.network?.getStats()||Promise.resolve({worker:!1,channels:[]})}stop(e=new Error("The invitation ended")){(this.link||this.pending)&&this.onEnd(),this.supportsHeartbeat=!1;const t=this.visibilityPending;this.visibilityPending=null,t&&(clearTimeout(t.timer),t.reject(e||new Error("The invitation ended")));const s=this.reject;this.reject=null,s?.(e||new Error("The invitation ended"));const r=this.signal;this.signal=null,r?.close();for(const e of[...this.peers.values()])e.close();this.peers.clear(),this.link=null,this.pending=null,this.network?.close(),this.network=null}},createRtcTransport:({roomId:e,invite:t,signalingUrl:s,joinUrl:a="https://homegames.io/play.html",worker:h=!0,iceTransportPolicy:l="all"})=>c=>{const d=new r({worker:h});let u,p=null,f=!1,m=!1,g=null;const y=t=>{if("string"==typeof t)try{const r=JSON.parse(t);if("media"===r.type)return void c.onMedia?.(r);if("invitation"!==r.type||"string"!=typeof r.url||r.url.length>4096)return;const n=new URL(r.url),a=o(n.hash);["http:","https:"].includes(n.protocol)&&!n.username&&!n.password&&a?.roomId===e&&a.invite&&i(a.signalingUrl)===i(s)&&(g=n.href)}catch(e){}else c.onMessage(t)},v=e=>{f||(f=!0,p?.close(),u?.close(),d.close(),e&&!m&&c.onError(e),c.onClose())};try{u=d.signal(i(s),{type:"join",roomId:e,invite:t},e=>{"joined"===e.type?p=new n({network:d,iceServers:e.iceServers,iceTransportPolicy:l,onTrack:e=>c.onTrack?.(e),sendSignal:e=>u.send({type:"signal",...e}),onOpen:()=>{m=!0,c.onOpen()},onMessage:y,onEnd:v}):"signal"===e.type&&p?.signal(e)},v)}catch(e){queueMicrotask(()=>v(e))}return{send:e=>p?.channel?.send(e),getStats:()=>d.getStats(),addMedia:(e,t)=>p?.addMedia(e,t),removeMedia:e=>p?.removeMedia(e),getShareLink:()=>{if(f)throw new Error("This session has ended");if(!m)throw new Error("Connect to the host before sharing this game");if(g)return g;const r=new URL(a,window.location.href),n=new URLSearchParams({room:e,signal:i(s)});return t&&n.set("invite",t),r.hash=n.toString(),r.href},close:()=>{f=!0,p?.close(),u?.close(),d.close()}}},readInvitation:o,Peer:n,signalUrl:i}},844(e){e.exports=function(e,t,s,r,i=()=>{}){const n=new WebSocket(e);let o=!1,a=null,h=null;const l=e=>{o||(o=!0,clearTimeout(c),clearInterval(a),n.onopen=n.onmessage=n.onerror=n.onclose=null,n.close(),r(e))},c=setTimeout(()=>l(new Error("Signaling connection timed out")),15e3),d=e=>{o||1!==n.readyState||n.send(JSON.stringify(e))};return n.onopen=()=>d(t),n.onmessage=e=>{try{const t=JSON.parse(e.data);if("error"===t.type)return l(new Error(t.message));if("ended"===t.type)return l(new Error("The host ended this game"));clearTimeout(c),s(t)}catch(e){l(e)}},n.onerror=()=>l(new Error("Cannot reach the invitation service")),n.onclose=()=>l(new Error("The invitation connection closed")),{send:d,startHeartbeat(e,t){clearInterval(a),h=t,!o&&Number.isFinite(e)&&e>0&&(a=setInterval(()=>{d(h),i(h)},e))},heartbeat(e){h=e,d(e)},close:()=>l(null)}}},2402(e){e.exports=function(e,t){const s=new Map;let r=null;const i=(e,t={},s=[])=>postMessage({type:e,...t},s),n=(e,t)=>i("channel-error",{id:e,message:t.message});onmessage=({data:o})=>{const{type:a,id:h,data:l}=o;if("signal-open"===a)r=t(o.url,o.hello,e=>i("signal-message",{data:e}),e=>i("signal-end",{message:e?.message}),e=>i("heartbeat",{data:e}));else if("signal-send"===a)r?.send(l);else if("heartbeat-start"===a)r?.startHeartbeat(o.interval,l);else if("heartbeat-update"===a)r?.heartbeat(l);else if("signal-close"===a)r?.close(),r=null;else if("bind"===a){const t=o.channel;let r=!1;const a=new e.Mailbox(e=>i("data",{id:h,data:e},"string"==typeof e?[]:[e.buffer||e]),e=>n(h,e)),l=new e(t,{onMessage:e=>a.send(e,!0),onError:e=>n(h,e),onClose:()=>{a.close(),s.delete(h),i("channel-close",{id:h})}});s.set(h,{protocol:l,mailbox:a});const c=()=>{r||l.closed||(r=!0,l.flush(),i("channel-open",{id:h}))};t.onopen=c,"open"===t.readyState&&c()}else if("send"===a)s.get(h)?.protocol.send(l),i("sent",{id:h});else if("received"===a)s.get(h)?.mailbox.ack();else if("channel-close"===a){const e=s.get(h);s.delete(h),e?.mailbox.close(),e?.protocol.close()}else"stats"===a&&i("stats",{id:h,channels:[...s].map(([e,{protocol:t,mailbox:s}])=>({id:e,mode:"worker",...t.stats,queuedBytes:t.queuedBytes,bufferedBytes:t.channel.bufferedAmount,receiveQueueBytes:s.bytes,receiveReplacedFrames:s.replacedFrames}))})}}},7699(e){const t="hg-save:",s=1048576;e.exports={createSaveStore:()=>{const e=(()=>{try{const e=t+"__test__";return window.localStorage.setItem(e,"1"),window.localStorage.removeItem(e),window.localStorage}catch(e){return null}})(),s={};return{getSave:r=>new Promise(i=>{try{const n=e?e.getItem(t+r):s[r];if(!n)return void i(null);const o=JSON.parse(n);i(o&&"object"==typeof o?o:null)}catch(e){i(null)}}),putSave:(r,i)=>new Promise((n,o)=>{let a;try{a=JSON.stringify(i)}catch(e){return void o(e)}if(e)try{return e.setItem(t+r,a),void n()}catch(e){}s[r]=a,n()}),deleteSave:r=>new Promise(i=>{try{e&&e.removeItem(t+r)}catch(e){}delete s[r],i()})}},createDebouncedWriter:({intervalMs:e,write:t})=>{let s=0,r=null;const i=()=>{const e=r;r=null,s=Date.now(),Promise.resolve().then(()=>t(e.value)).then(()=>e.resolvers.forEach(e=>e())).catch(t=>e.rejecters.forEach(e=>e(t)))};return t=>new Promise((n,o)=>{if(r)return r.value=t,r.resolvers.push(n),void r.rejecters.push(o);r={value:t,resolvers:[n],rejecters:[o]};const a=Math.max(0,e-(Date.now()-s));setTimeout(i,a)})},serializeSaveData:e=>{const t=JSON.stringify(e);if(void 0===t)throw new Error("Save data must be JSON-serializable");if((new TextEncoder).encode(t).length>s)throw new Error("Save data exceeds "+s+" bytes");return t},isCompatibleSave:(e,t,s)=>!(!e||"object"!=typeof e||void 0===e.data)&&(e.versionId===t||Array.isArray(s)&&-1!==s.indexOf(e.versionId)),DEFAULT_VERSION_ID:"local-game-version"}},1525(e){e.exports=class{constructor({remote:e,loadLocal:t,mountLocal:s,createLocal:r,onError:i}){Object.assign(this,{remote:e,loadLocal:t,mountLocal:s,createLocal:r,onError:i}),this.local=null,this.chrome=null,this.generation=0,this.pending=null}_cancelLoad(){this.generation++,this.pending?.abort(),this.pending=null}_disposeActive(){const e=this.local;this.local=null,e?.stop(),this.chrome?.dispose(),this.chrome=null,this.remote.stop()}start(){this.stop(),this.remote.start()}stop(){this._cancelLoad(),this._disposeActive()}async startLocal(e){this._cancelLoad();const t=this.generation,s=this.pending=new AbortController;try{const r=await this.loadLocal(e,{signal:s.signal});if(t!==this.generation)return;this.pending=null,this._disposeActive(),this.chrome=this.mountLocal(r),this.local=this.createLocal({...r,containerId:this.chrome.containerId}),this.local.start()}catch(e){if(t!==this.generation)return;this.pending=null,this.onError(e)}}}},7875(e){const t=new WeakMap;e.exports=()=>{let e=t.get(document);if(!e){const s=document.createElement("style");s.textContent="\n .hg-session-frame, .hg-share-dialog { font:14px/1.4 system-ui,-apple-system,BlinkMacSystemFont,sans-serif; color:#f6f6ee; }\n .hg-session-frame *, .hg-share-dialog * { box-sizing:border-box; }\n .hg-session-frame { width:100%; height:100%; position:relative; overflow:hidden; background:#000; container-type:inline-size; }\n .hg-session-game { flex:1; min-height:0; width:100%; position:relative; overflow:hidden; display:flex; align-items:center; background:#000; }\n .hg-share-dialog button { display:inline-flex; align-items:center; justify-content:center; gap:8px; min-height:44px; padding:0 18px; border:1px solid #4a5049; border-radius:10px; background:transparent; color:#f6f6ee; font:600 14px/1.2 system-ui,sans-serif; cursor:pointer; }\n .hg-share-dialog .hg-share-copy { background:#fff78e; color:#22261e; }\n .hg-share-dialog :focus-visible { outline:2px solid #fff78e; outline-offset:4px; }\n .hg-share-dialog { margin:auto; width:min(400px,calc(100vw - 32px)); max-height:calc(100dvh - 32px); padding:24px; border:1px solid #4a5049; border-radius:20px; background:#202321; box-sizing:border-box; overflow:auto; text-align:center; box-shadow:0 24px 80px #0009; }\n .hg-share-dialog::backdrop { background:#080c0ac9; }\n .hg-share-dialog h2 { margin:0 0 8px; font-size:22px; letter-spacing:-.5px; }\n .hg-share-hint { margin:0 0 20px; color:#b7bfb5; font-size:13px; }\n .hg-share-qr { width:100%; max-width:256px; aspect-ratio:1; padding:8px; margin:0 auto 16px; border-radius:12px; overflow:hidden; background:#fff; }\n .hg-share-qr[hidden] { display:none; }\n .hg-share-status { margin:16px 0; color:#cbd1c8; font-size:12px; overflow-wrap:anywhere; }\n .hg-share-link { width:100%; padding:12px; border:1px solid #4a5049; border-radius:8px; background:#111510; color:#cbd1c8; font:12px system-ui,sans-serif; }\n .hg-share-actions { display:flex; gap:10px; margin-top:16px; }\n .hg-share-actions button { flex:1; }\n .hg-share-dialog button:disabled { opacity:.4; cursor:wait; }\n ",(document.head||document.body).appendChild(s),e={style:s,count:0},t.set(document,e)}e.count++;const s=document;return()=>{0===--e.count&&(e.style.remove(),t.delete(s))}}},172(e,t,s){const r=s(3008);e.exports=function({container:e,getLink:t,onOpen:i,onClose:n,title:o="Share this game",readyText:a="Anyone with this link can join",closeLabel:h="Done",hintText:l="Scan to join. Keep this game tab open."}){const c=document.createElement("dialog"),d=s(7875)();c.className="hg-share-dialog",c.setAttribute("aria-label",o);const u=document.createElement("h2");u.textContent=o;const p=document.createElement("p");p.textContent=l,p.className="hg-share-hint";const f=document.createElement("div");f.className="hg-share-qr";const m=document.createElement("p");m.setAttribute("role","status"),m.className="hg-share-status";const g=document.createElement("input");g.readOnly=!0,g.setAttribute("aria-label","Invitation link"),g.className="hg-share-link";const y=document.createElement("div");y.className="hg-share-actions";const v=(e,t)=>{const s=document.createElement("button");return s.type="button",s.textContent=e,s.onclick=t,y.appendChild(s),s},w=v("Copy link",async()=>{try{await navigator.clipboard.writeText(g.value),m.textContent="Link copied"}catch(e){g.focus(),g.select(),m.textContent="Copy the selected invitation link"}});w.className="hg-share-copy";const x=v(h,()=>c.close());[u,p,f,m,g,y].forEach(e=>c.appendChild(e)),e.appendChild(c);let b=0,E=!1;return c.onclose=()=>{b++,n?.()},c.addEventListener("click",e=>{if(e.target===c){const t=c.getBoundingClientRect();(e.clientX<t.left||e.clientX>t.right||e.clientY<t.top||e.clientY>t.bottom)&&c.close()}}),{setStatus(e){E||(m.textContent=e)},async show(){if(E||c.open)return;const e=++b;f.innerHTML="",f.hidden=!0,g.value="",g.hidden=!0,w.disabled=!0,m.textContent="Creating invitation…",c.showModal(),i?.(),x.focus();try{const s=await t();if(e!==b)return;const i=r(0,"M");i.addData(s),i.make(),f.innerHTML=i.createSvgTag({cellSize:4,margin:16,scalable:!0}),f.firstChild.style.cssText="display:block;width:100%;height:100%;background:white",f.hidden=!1,g.value=s,g.hidden=!1,w.disabled=!1,m.textContent=a}catch(t){e===b&&(m.textContent=t.message)}},dispose(){E||(E=!0,b++,c.open&&c.close(),c.remove(),d())}}}},9732(e,t,s){const r={150:s(5911),151:s(2416)};e.exports={squishMap:r,DEFAULT_VERSION:"151"}},5537(e){e.exports=class{constructor(e,t,s,r,i={}){Object.assign(this,{assetManager:e,asset:t,invalidate:r,closed:!1,frozen:!1,forceMute:!1});const n=this.element=document.createElement("video");n.playsInline=!0,n.preload="auto",n.muted=!0,n.onloadedmetadata=()=>{s>0&&Number.isFinite(n.duration)&&(n.currentTime=Math.min(s,n.duration))},n.onloadeddata=n.onseeked=n.onended=()=>{this.closed||r()},n.onerror=()=>{this.closed||(this.error=!0,r())},"stream"===t.type?n.srcObject=t.data:(t.url||(t.url=URL.createObjectURL(t.data)),n.src=t.url),e.mediaPlayers.add(this),this.update(!!i.muteAudio,!!i.freezeMedia)}update(e,t){if(this.forceMute=e,t)return this.frozen=!0,void this.element.pause();const s=this.frozen;this.frozen=!1,this.element.muted=e||!this.assetManager.mediaUnlocked||!!this.blockedAudio,this.started&&!s||this.play()}play(){if(this.closed||this.frozen||this.error||this.starting||this.element.ended)return;this.starting=!0,this.started=!0;const e=this.element.muted;Promise.resolve(this.element.play()).then(()=>{this.closed||(this.starting=!1,this.scheduleFrame(),this.invalidate())}).catch(t=>{this.closed||(this.starting=!1,"NotAllowedError"===t.name?(this.blockedAudio=!0,e||this.frozen||(this.element.muted=!0,this.play())):"AbortError"!==t.name&&(this.error=!0),this.invalidate())})}unlock(){this.closed||this.frozen||this.forceMute||this.element.ended||(this.blockedAudio=!1,this.element.muted=!1,this.play())}scheduleFrame(){!this.closed&&null==this.frameCallback&&this.element.requestVideoFrameCallback&&(this.frameCallback=this.element.requestVideoFrameCallback(()=>{this.frameCallback=null,this.closed||(this.invalidate(),this.element.paused||this.element.ended||this.scheduleFrame())}))}needsRepaint(){return!this.closed&&!this.frozen&&!this.error&&!this.element.requestVideoFrameCallback&&!this.element.paused&&!this.element.ended&&this.element.readyState>=2}destroy(){this.closed||(this.closed=!0,null!=this.frameCallback&&this.element.cancelVideoFrameCallback?.(this.frameCallback),this.element.onloadedmetadata=this.element.onloadeddata=this.element.onseeked=this.element.onended=this.element.onerror=null,this.element.pause(),this.element.srcObject=null,this.element.removeAttribute("src"),this.element.load(),this.assetManager.mediaPlayers.delete(this))}}},595(e,t){"use strict";t.zipSync=function(e,t){t||(t={});var r={},i=[];ee(e,"",r,t);var n=0,o=0;for(var a in r){var h=r[a],l=h[0],c=h[1],d=0==c.level?0:8,u=(k=ie(a)).length,p=c.comment,f=p&&ie(p),m=f&&f.length,g=le(c.extra);u>65535&&L(11);var y=d?Z(l,c):l,v=y.length,w=G();w.p(l),i.push(K(c,{size:l.length,crc:w.d(),c:y,f:k,m:f,u:u!=a.length||f&&p.length!=m,o:n,compression:d})),n+=30+u+g+v,o+=76+2*(u+g)+(m||0)+v}for(var x=new s(o+22),b=n,E=o-n,S=0;S<i.length;++S){var k=i[S];ce(x,k.o,k,k.f,k.u,k.c.length);var _=30+k.f.length+le(k.extra);x.set(k.c,k.o+_),ce(x,n,k,k.f,k.u,k.c.length,k.o,k.m),n+=16+_+(k.m?k.m.length:0)}return de(x,n,i.length,E,b),x},t.unzipSync=function(e,t){for(var r={},i=e.length-22;101010256!=Y(e,i);--i)(!i||e.length-i>65558)&&L(13);var n=W(e,i+8);if(!n)return{};var o=Y(e,i+16),a=117853008==Y(e,i-20);if(a){var h=Y(e,i-12);(a=101075792==Y(e,h))&&(n=Y(e,h+32),o=Y(e,h+48))}for(var l=t&&t.filter,c=0;c<n;++c){var d=ae(e,o,a),u=d[0],p=d[1],f=d[2],m=d[3],g=d[4],y=d[5],v=oe(e,y);o=g,l&&!l({name:m,size:p,originalSize:f,compression:u})||(u?8==u?r[m]=Q(e.subarray(v,v+p),{out:new s(f)}):L(14,"unknown compression type "+u):r[m]=T(e,v,v+p))}return r};var s=Uint8Array,r=Uint16Array,i=Int32Array,n=new s([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),o=new s([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),a=new s([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),h=function(e,t){for(var s=new r(31),n=0;n<31;++n)s[n]=t+=1<<e[n-1];var o=new i(s[30]);for(n=1;n<30;++n)for(var a=s[n];a<s[n+1];++a)o[a]=a-s[n]<<5|n;return{b:s,r:o}},l=h(n,2),c=l.b,d=l.r;c[28]=258,d[258]=28;for(var u=h(o,0),p=u.b,f=u.r,m=new r(32768),g=0;g<32768;++g){var y=(43690&g)>>1|(21845&g)<<1;y=(61680&(y=(52428&y)>>2|(13107&y)<<2))>>4|(3855&y)<<4,m[g]=((65280&y)>>8|(255&y)<<8)>>1}var v=function(e,t,s){for(var i=e.length,n=0,o=new r(t);n<i;++n)e[n]&&++o[e[n]-1];var a,h=new r(t);for(n=1;n<t;++n)h[n]=h[n-1]+o[n-1]<<1;if(s){a=new r(1<<t);var l=15-t;for(n=0;n<i;++n)if(e[n])for(var c=n<<4|e[n],d=t-e[n],u=h[e[n]-1]++<<d,p=u|(1<<d)-1;u<=p;++u)a[m[u]>>l]=c}else for(a=new r(i),n=0;n<i;++n)e[n]&&(a[n]=m[h[e[n]-1]++]>>15-e[n]);return a},w=new s(288);for(g=0;g<144;++g)w[g]=8;for(g=144;g<256;++g)w[g]=9;for(g=256;g<280;++g)w[g]=7;for(g=280;g<288;++g)w[g]=8;var x=new s(32);for(g=0;g<32;++g)x[g]=5;var b=v(w,9,0),E=v(w,9,1),S=v(x,5,0),k=v(x,5,1),_=function(e){for(var t=e[0],s=1;s<e.length;++s)e[s]>t&&(t=e[s]);return t},C=function(e,t,s){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(7&t)&s},A=function(e,t){var s=t/8|0;return(e[s]|e[s+1]<<8|e[s+2]<<16)>>(7&t)},I=function(e){return(e+7)/8|0},T=function(e,t,r){return(null==t||t<0)&&(t=0),(null==r||r>e.length)&&(r=e.length),new s(e.subarray(t,r))},P=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],L=function(e,t,s){var r=new Error(t||P[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,L),!s)throw r;return r},M=function(e,t,r,i){var h=e.length,l=i?i.length:0;if(!h||t.f&&!t.l)return r||new s(0);var d=!r,u=d||2!=t.i,f=t.i;d&&(r=new s(3*h));var m=function(e){var t=r.length;if(e>t){var i=new s(Math.max(2*t,e));i.set(r),r=i}},g=t.f||0,y=t.p||0,w=t.b||0,x=t.l,b=t.d,S=t.m,P=t.n,M=8*h;do{if(!x){g=C(e,y,1);var R=C(e,y+1,3);if(y+=3,!R){var N=e[(G=I(y)+4)-4]|e[G-3]<<8,O=G+N;if(O>h){f&&L(0);break}u&&m(w+N),r.set(e.subarray(G,O),w),t.b=w+=N,t.p=y=8*O,t.f=g;continue}if(1==R)x=E,b=k,S=9,P=5;else if(2==R){var U=C(e,y,31)+257,B=C(e,y+10,15)+4,D=U+C(e,y+5,31)+1;y+=14;for(var j=new s(D),q=new s(19),H=0;H<B;++H)q[a[H]]=C(e,y+3*H,7);y+=3*B;var V=_(q),z=(1<<V)-1,F=v(q,V,1);for(H=0;H<D;){var G,$=F[C(e,y,z)];if(y+=15&$,(G=$>>4)<16)j[H++]=G;else{var K=0,W=0;for(16==G?(W=3+C(e,y,3),y+=2,K=j[H-1]):17==G?(W=3+C(e,y,7),y+=3):18==G&&(W=11+C(e,y,127),y+=7);W--;)j[H++]=K}}var Y=j.subarray(0,U),J=j.subarray(U);S=_(Y),P=_(J),x=v(Y,S,1),b=v(J,P,1)}else L(1);if(y>M){f&&L(0);break}}u&&m(w+131072);for(var X=(1<<S)-1,Z=(1<<P)-1,Q=y;;Q=y){var ee=(K=x[A(e,y)&X])>>4;if((y+=15&K)>M){f&&L(0);break}if(K||L(2),ee<256)r[w++]=ee;else{if(256==ee){Q=y,x=null;break}var te=ee-254;if(ee>264){var se=n[H=ee-257];te=C(e,y,(1<<se)-1)+c[H],y+=se}var re=b[A(e,y)&Z],ie=re>>4;if(re||L(3),y+=15&re,J=p[ie],ie>3&&(se=o[ie],J+=A(e,y)&(1<<se)-1,y+=se),y>M){f&&L(0);break}u&&m(w+131072);var ne=w+te;if(w<J){var oe=l-J,ae=Math.min(J,ne);for(oe+w<0&&L(3);w<ae;++w)r[w]=i[oe+w]}for(;w<ne;++w)r[w]=r[w-J]}}t.l=x,t.p=Q,t.b=w,t.f=g,x&&(g=1,t.m=S,t.d=b,t.n=P)}while(!g);return w!=r.length&&d?T(r,0,w):r.subarray(0,w)},R=function(e,t,s){s<<=7&t;var r=t/8|0;e[r]|=s,e[r+1]|=s>>8},N=function(e,t,s){s<<=7&t;var r=t/8|0;e[r]|=s,e[r+1]|=s>>8,e[r+2]|=s>>16},O=function(e,t){for(var i=[],n=0;n<e.length;++n)e[n]&&i.push({s:n,f:e[n]});var o=i.length,a=i.slice();if(!o)return{t:V,l:0};if(1==o){var h=new s(i[0].s+1);return h[i[0].s]=1,{t:h,l:1}}i.sort(function(e,t){return e.f-t.f}),i.push({s:-1,f:25001});var l=i[0],c=i[1],d=0,u=1,p=2;for(i[0]={s:-1,f:l.f+c.f,l,r:c};u!=o-1;)l=i[i[d].f<i[p].f?d++:p++],c=i[d!=u&&i[d].f<i[p].f?d++:p++],i[u++]={s:-1,f:l.f+c.f,l,r:c};var f=a[0].s;for(n=1;n<o;++n)a[n].s>f&&(f=a[n].s);var m=new r(f+1),g=U(i[u-1],m,0);if(g>t){n=0;var y=0,v=g-t,w=1<<v;for(a.sort(function(e,t){return m[t.s]-m[e.s]||e.f-t.f});n<o;++n){var x=a[n].s;if(!(m[x]>t))break;y+=w-(1<<g-m[x]),m[x]=t}for(y>>=v;y>0;){var b=a[n].s;m[b]<t?y-=1<<t-m[b]++-1:++n}for(;n>=0&&y;--n){var E=a[n].s;m[E]==t&&(--m[E],++y)}g=t}return{t:new s(m),l:g}},U=function(e,t,s){return-1==e.s?Math.max(U(e.l,t,s+1),U(e.r,t,s+1)):t[e.s]=s},B=function(e){for(var t=e.length;t&&!e[--t];);for(var s=new r(++t),i=0,n=e[0],o=1,a=function(e){s[i++]=e},h=1;h<=t;++h)if(e[h]==n&&h!=t)++o;else{if(!n&&o>2){for(;o>138;o-=138)a(32754);o>2&&(a(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(a(n),--o;o>6;o-=6)a(8304);o>2&&(a(o-3<<5|8208),o=0)}for(;o--;)a(n);o=1,n=e[h]}return{c:s.subarray(0,i),n:t}},D=function(e,t){for(var s=0,r=0;r<t.length;++r)s+=e[r]*t[r];return s},j=function(e,t,s){var r=s.length,i=I(t+2);e[i]=255&r,e[i+1]=r>>8,e[i+2]=255^e[i],e[i+3]=255^e[i+1];for(var n=0;n<r;++n)e[i+n+4]=s[n];return 8*(i+4+r)},q=function(e,t,s,i,h,l,c,d,u,p,f){R(t,f++,s),++h[256];for(var m=O(h,15),g=m.t,y=m.l,E=O(l,15),k=E.t,_=E.l,C=B(g),A=C.c,I=C.n,T=B(k),P=T.c,L=T.n,M=new r(19),U=0;U<A.length;++U)++M[31&A[U]];for(U=0;U<P.length;++U)++M[31&P[U]];for(var q=O(M,7),H=q.t,V=q.l,z=19;z>4&&!H[a[z-1]];--z);var F,G,$,K,W=p+5<<3,Y=D(h,w)+D(l,x)+c,J=D(h,g)+D(l,k)+c+14+3*z+D(M,H)+2*M[16]+3*M[17]+7*M[18];if(u>=0&&W<=Y&&W<=J)return j(t,f,e.subarray(u,u+p));if(R(t,f,1+(J<Y)),f+=2,J<Y){F=v(g,y,0),G=g,$=v(k,_,0),K=k;var X=v(H,V,0);for(R(t,f,I-257),R(t,f+5,L-1),R(t,f+10,z-4),f+=14,U=0;U<z;++U)R(t,f+3*U,H[a[U]]);f+=3*z;for(var Z=[A,P],Q=0;Q<2;++Q){var ee=Z[Q];for(U=0;U<ee.length;++U){var te=31&ee[U];R(t,f,X[te]),f+=H[te],te>15&&(R(t,f,ee[U]>>5&127),f+=ee[U]>>12)}}}else F=b,G=w,$=S,K=x;for(U=0;U<d;++U){var se=i[U];if(se>255){N(t,f,F[257+(te=se>>18&31)]),f+=G[te+257],te>7&&(R(t,f,se>>23&31),f+=n[te]);var re=31&se;N(t,f,$[re]),f+=K[re],re>3&&(N(t,f,se>>5&8191),f+=o[re])}else N(t,f,F[se]),f+=G[se]}return N(t,f,F[256]),f+G[256]},H=new i([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),V=new s(0),z=function(e,t,a,h,l,c){var u=c.z||e.length,p=new s(h+u+5*(1+Math.ceil(u/7e3))+l),m=p.subarray(h,p.length-l),g=c.l,y=7&(c.r||0);if(t){y&&(m[0]=c.r>>3);for(var v=H[t-1],w=v>>13,x=8191&v,b=(1<<a)-1,E=c.p||new r(32768),S=c.h||new r(b+1),k=Math.ceil(a/3),_=2*k,C=function(t){return(e[t]^e[t+1]<<k^e[t+2]<<_)&b},A=new i(25e3),P=new r(288),L=new r(32),M=0,R=0,N=c.i||0,O=0,U=c.w||0,B=0;N+2<u;++N){var D=C(N),V=32767&N,z=S[D];if(E[V]=z,S[D]=V,U<=N){var F=u-N;if((M>7e3||O>24576)&&(F>423||!g)){y=q(e,m,0,A,P,L,R,O,B,N-B,y),O=M=R=0,B=N;for(var G=0;G<286;++G)P[G]=0;for(G=0;G<30;++G)L[G]=0}var $=2,K=0,W=x,Y=V-z&32767;if(F>2&&D==C(N-Y))for(var J=Math.min(w,F)-1,X=Math.min(32767,N),Z=Math.min(258,F);Y<=X&&--W&&V!=z;){if(e[N+$]==e[N+$-Y]){for(var Q=0;Q<Z&&e[N+Q]==e[N+Q-Y];++Q);if(Q>$){if($=Q,K=Y,Q>J)break;var ee=Math.min(Y,Q-2),te=0;for(G=0;G<ee;++G){var se=N-Y+G&32767,re=se-E[se]&32767;re>te&&(te=re,z=se)}}}Y+=(V=z)-(z=E[V])&32767}if(K){A[O++]=268435456|d[$]<<18|f[K];var ie=31&d[$],ne=31&f[K];R+=n[ie]+o[ne],++P[257+ie],++L[ne],U=N+$,++M}else A[O++]=e[N],++P[e[N]]}}for(N=Math.max(N,U);N<u;++N)A[O++]=e[N],++P[e[N]];y=q(e,m,g,A,P,L,R,O,B,N-B,y),g||(c.r=7&y|m[y/8|0]<<3,y-=7,c.h=S,c.p=E,c.i=N,c.w=U)}else{for(N=c.w||0;N<u+g;N+=65535){var oe=N+65535;oe>=u&&(m[y/8|0]=g,oe=u),y=j(m,y+1,e.subarray(N,oe))}c.i=u}return T(p,0,h+I(y)+l)},F=function(){for(var e=new Int32Array(256),t=0;t<256;++t){for(var s=t,r=9;--r;)s=(1&s&&-306674912)^s>>>1;e[t]=s}return e}(),G=function(){var e=-1;return{p:function(t){for(var s=e,r=0;r<t.length;++r)s=F[255&s^t[r]]^s>>>8;e=s},d:function(){return~e}}},$=function(e,t,r,i,n){if(!n&&(n={l:1},t.dictionary)){var o=t.dictionary.subarray(-32768),a=new s(o.length+e.length);a.set(o),a.set(e,o.length),e=a,n.w=o.length}return z(e,null==t.level?6:t.level,null==t.mem?n.l?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):20:12+t.mem,r,i,n)},K=function(e,t){var s={};for(var r in e)s[r]=e[r];for(var r in t)s[r]=t[r];return s},W=function(e,t){return e[t]|e[t+1]<<8},Y=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},J=function(e,t){return Y(e,t)+4294967296*Y(e,t+4)},X=function(e,t,s){for(;s;++t)e[t]=s,s>>>=8};function Z(e,t){return $(e,t||{},0,0)}function Q(e,t){return M(e,{i:2},t&&t.out,t&&t.dictionary)}var ee=function(e,t,r,i){for(var n in e){var o=e[n],a=t+n,h=i;Array.isArray(o)&&(h=K(i,o[1]),o=o[0]),ArrayBuffer.isView(o)?r[a]=[o,h]:(r[a+="/"]=[new s(0),h],ee(o,a,r,i))}},te="undefined"!=typeof TextEncoder&&new TextEncoder,se="undefined"!=typeof TextDecoder&&new TextDecoder;try{se.decode(V,{stream:!0})}catch(e){}var re=function(e){for(var t="",s=0;;){var r=e[s++],i=(r>127)+(r>223)+(r>239);if(s+i>e.length)return{s:t,r:T(e,s-1)};i?3==i?(r=((15&r)<<18|(63&e[s++])<<12|(63&e[s++])<<6|63&e[s++])-65536,t+=String.fromCharCode(55296|r>>10,56320|1023&r)):t+=1&i?String.fromCharCode((31&r)<<6|63&e[s++]):String.fromCharCode((15&r)<<12|(63&e[s++])<<6|63&e[s++]):t+=String.fromCharCode(r)}};function ie(e,t){if(t){for(var r=new s(e.length),i=0;i<e.length;++i)r[i]=e.charCodeAt(i);return r}if(te)return te.encode(e);var n=e.length,o=new s(e.length+(e.length>>1)),a=0,h=function(e){o[a++]=e};for(i=0;i<n;++i){if(a+5>o.length){var l=new s(a+8+(n-i<<1));l.set(o),o=l}var c=e.charCodeAt(i);c<128||t?h(c):c<2048?(h(192|c>>6),h(128|63&c)):c>55295&&c<57344?(h(240|(c=65536+(1047552&c)|1023&e.charCodeAt(++i))>>18),h(128|c>>12&63),h(128|c>>6&63),h(128|63&c)):(h(224|c>>12),h(128|c>>6&63),h(128|63&c))}return T(o,0,a)}function ne(e,t){if(t){for(var s="",r=0;r<e.length;r+=16384)s+=String.fromCharCode.apply(null,e.subarray(r,r+16384));return s}if(se)return se.decode(e);var i=re(e),n=i.s;return(s=i.r).length&&L(8),n}var oe=function(e,t){return t+30+W(e,t+26)+W(e,t+28)},ae=function(e,t,s){var r=W(e,t+28),i=W(e,t+30),n=ne(e.subarray(t+46,t+46+r),!(2048&W(e,t+8))),o=t+46+r,a=he(e,o,i,s,Y(e,t+20),Y(e,t+24),Y(e,t+42)),h=a[0],l=a[1],c=a[2];return[W(e,t+10),h,l,n,o+i+W(e,t+32),c]},he=function(e,t,s,r,i,n,o){var a=4294967295==i,h=4294967295==n,l=4294967295==o,c=t+s;if(r&&a+h+l){for(;t+4<c;t+=4+W(e,t+2))if(1==W(e,t))return[a?J(e,t+4+8*h):i,h?J(e,t+4):n,l?J(e,t+4+8*(h+a)):o,1];r<2&&L(13)}return[i,n,o,0]},le=function(e){var t=0;if(e)for(var s in e){var r=e[s].length;r>65535&&L(9),t+=r+4}return t},ce=function(e,t,s,r,i,n,o,a){var h=r.length,l=s.extra,c=a&&a.length,d=le(l);X(e,t,null!=o?33639248:67324752),t+=4,null!=o&&(e[t++]=20,e[t++]=s.os),e[t]=20,t+=2,e[t++]=s.flag<<1|(n<0&&8),e[t++]=i&&8,e[t++]=255&s.compression,e[t++]=s.compression>>8;var u=new Date(null==s.mtime?Date.now():s.mtime),p=u.getFullYear()-1980;if((p<0||p>119)&&L(10),X(e,t,p<<25|u.getMonth()+1<<21|u.getDate()<<16|u.getHours()<<11|u.getMinutes()<<5|u.getSeconds()>>1),t+=4,-1!=n&&(X(e,t,s.crc),X(e,t+4,n<0?-n-2:n),X(e,t+8,s.size)),X(e,t+12,h),X(e,t+14,d),t+=16,null!=o&&(X(e,t,c),X(e,t+6,s.attrs),X(e,t+10,o),t+=14),e.set(r,t),t+=h,d)for(var f in l){var m=l[f],g=m.length;X(e,t,+f),X(e,t+2,g),e.set(m,t+4),t+=4+g}return c&&(e.set(a,t),t+=c),t},de=function(e,t,s,r,i){X(e,t,101010256),X(e,t+8,s),X(e,t+10,s),X(e,t+12,r),X(e,t+16,i)};"function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout&&setTimeout}};const t={};let s=function s(r){const i=t[r];if(void 0!==i)return i.exports;const n=t[r]={exports:{}};return e[r].call(n.exports,n,n.exports,s),n.exports}(44);return s=s.default,s})());
287
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.HomegamesClient=t():e.HomegamesClient=t()}(this,()=>(()=>{var e={8630(e,t){!function(e){"use strict";var t=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,7,9,32,4,318,1,31,4,33,15,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,199,7,137,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,55,9,7,0,259,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,481,1,61,4,4,5,9,7,3,6,31,3,149,2,12,2,9,1,3,0,33,1,1357,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,233,0,3,0,8,1,6,0,475,6,110,6,6,9,4759,9,787719,239],s=[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,13,65,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,7,25,39,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,5,18,21,18,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,18,0,182,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,24,43,22,0,239,18,16,0,2,12,2,33,125,0,80,921,103,111,6,206,13,310,2314,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,33,24,3,24,45,74,6,0,67,12,65,1,2,0,15,4,10,7386,37,33,96,114,14,913,15,50,7710,3,2,6,2,1,2,296,10,0,30,2,3,0,15,4,8,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,340,2,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,129,15,6,55,50,49,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,208,30,2,2,2,1,2,6,3,4,10,1,225,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4382,2,5773,3,7472,16,621,2467,541,1507,4938,6,8489,39815,11327],r="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆ՘ՙՠ-ֈ֋֌א-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-࢏ࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚ౜ౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽ೜-ೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-ᲊᲐ-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿ₏-₟ℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-꟝꟢꟱-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩ꭬꭭ꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",i={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"},n="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",o={5:n,"5module":n+" export import",6:n+" const class extends export import super"},a=/^in(stanceof)?$/,h=new RegExp("["+r+"]"),l=new RegExp("["+r+"‌‍·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄ-׉ؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࢗ-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୓-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-᫰ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‌‍‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・]");function c(e,t){for(var s=65536,r=0;r<t.length;r+=2){if((s+=t[r])>e)return!1;if((s+=t[r+1])>=e)return!0}return!1}function d(e,t){return e<65?36===e:e<91||(e<97?95===e:e<123||(e<=65535?e>=170&&h.test(String.fromCharCode(e)):!1!==t&&c(e,s)))}function u(e,r){return e<48?36===e:e<58||!(e<65)&&(e<91||(e<97?95===e:e<123||(e<=65535?e>=170&&l.test(String.fromCharCode(e)):!1!==r&&(c(e,s)||c(e,t)))))}var p=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 f(e,t){return new p(e,{beforeExpr:!0,binop:t})}var m={beforeExpr:!0},g={startsExpr:!0},y={};function v(e,t){return void 0===t&&(t={}),t.keyword=e,y[e]=new p(e,t)}var w={num:new p("num",g),regexp:new p("regexp",g),string:new p("string",g),name:new p("name",g),privateId:new p("privateId",g),eof:new p("eof"),bracketL:new p("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new p("]"),braceL:new p("{",{beforeExpr:!0,startsExpr:!0}),braceR:new p("}"),parenL:new p("(",{beforeExpr:!0,startsExpr:!0}),parenR:new p(")"),comma:new p(",",m),semi:new p(";",m),colon:new p(":",m),dot:new p("."),question:new p("?",m),questionDot:new p("?."),arrow:new p("=>",m),template:new p("template"),invalidTemplate:new p("invalidTemplate"),ellipsis:new p("...",m),backQuote:new p("`",g),dollarBraceL:new p("${",{beforeExpr:!0,startsExpr:!0}),eq:new p("=",{beforeExpr:!0,isAssign:!0}),assign:new p("_=",{beforeExpr:!0,isAssign:!0}),incDec:new p("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new p("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:f("||",1),logicalAND:f("&&",2),bitwiseOR:f("|",3),bitwiseXOR:f("^",4),bitwiseAND:f("&",5),equality:f("==/!=/===/!==",6),relational:f("</>/<=/>=",7),bitShift:f("<</>>/>>>",8),plusMin:new p("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:f("%",10),star:f("*",10),slash:f("/",10),starstar:new p("**",{beforeExpr:!0}),coalesce:f("??",1),_break:v("break"),_case:v("case",m),_catch:v("catch"),_continue:v("continue"),_debugger:v("debugger"),_default:v("default",m),_do:v("do",{isLoop:!0,beforeExpr:!0}),_else:v("else",m),_finally:v("finally"),_for:v("for",{isLoop:!0}),_function:v("function",g),_if:v("if"),_return:v("return",m),_switch:v("switch"),_throw:v("throw",m),_try:v("try"),_var:v("var"),_const:v("const"),_while:v("while",{isLoop:!0}),_with:v("with"),_new:v("new",{beforeExpr:!0,startsExpr:!0}),_this:v("this",g),_super:v("super",g),_class:v("class",g),_extends:v("extends",m),_export:v("export"),_import:v("import",g),_null:v("null",g),_true:v("true",g),_false:v("false",g),_in:v("in",{beforeExpr:!0,binop:7}),_instanceof:v("instanceof",{beforeExpr:!0,binop:7}),_typeof:v("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:v("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:v("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},x=/\r\n?|\n|\u2028|\u2029/,b=new RegExp(x.source,"g");function E(e){return 10===e||13===e||8232===e||8233===e}function S(e,t,s){void 0===s&&(s=e.length);for(var r=t;r<s;r++){var i=e.charCodeAt(r);if(E(i))return r<s-1&&13===i&&10===e.charCodeAt(r+1)?r+2:r+1}return-1}var k=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,_=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,C=Object.prototype,A=C.hasOwnProperty,I=C.toString,T=Object.hasOwn||function(e,t){return A.call(e,t)},P=Array.isArray||function(e){return"[object Array]"===I.call(e)},L=Object.create(null);function M(e){return L[e]||(L[e]=new RegExp("^(?:"+e.replace(/ /g,"|")+")$"))}function R(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10),56320+(1023&e)))}var N=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,O=function(e,t){this.line=e,this.column=t};O.prototype.offset=function(e){return new O(this.line,this.column+e)};var U=function(e,t,s){this.start=t,this.end=s,null!==e.sourceFile&&(this.source=e.sourceFile)};function B(e,t){for(var s=1,r=0;;){var i=S(e,r,t);if(i<0)return new O(s,t-r);++s,r=i}}var D={ecmaVersion:null,sourceType:"script",strict:!1,onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowAwaitOutsideFunction:null,allowSuperOutsideMethod:null,allowHashBang:!1,checkPrivateFields:!0,locations:!1,startLocation:null,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},j=!1;function q(e){var t={};for(var s in D)t[s]=e&&T(e,s)?e[s]:D[s];if("latest"===t.ecmaVersion?t.ecmaVersion=1e8:null==t.ecmaVersion?(!j&&"object"==typeof console&&console.warn&&(j=!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),P(t.onToken)){var r=t.onToken;t.onToken=function(e){return r.push(e)}}if(P(t.onComment)&&(t.onComment=function(e,t){return function(s,r,i,n,o,a){var h={type:s?"Block":"Line",value:r,start:i,end:n};e.locations&&(h.loc=new U(this,o,a)),e.ranges&&(h.range=[i,n]),t.push(h)}}(t,t.onComment)),"commonjs"===t.sourceType&&t.allowAwaitOutsideFunction)throw new Error("Cannot use allowAwaitOutsideFunction with sourceType: commonjs");return t}var H=256,V=259;function z(e,t){return 2|(e?4:0)|(t?8:0)}var F=function(e,t,s){this.options=e=q(e),this.sourceFile=e.sourceFile,this.keywords=M(o[e.ecmaVersion>=6?6:"module"===e.sourceType?"5module":5]);var r="";!0!==e.allowReserved&&(r=i[e.ecmaVersion>=6?6:5===e.ecmaVersion?5:3],"module"===e.sourceType&&(r+=" await")),this.reservedWords=M(r);var n=(r?r+" ":"")+i.strict;this.reservedWordsStrict=M(n),this.reservedWordsStrictBind=M(n+" "+i.strictBind),this.input=String(t),this.containsEsc=!1,this.pos=s||0,this.curLine=1,e.startLocation?(this.lineStart=this.pos-e.startLocation.column,this.curLine=e.startLocation.line):s?(this.lineStart=this.input.lastIndexOf("\n",s-1)+1,this.options.locations&&(this.curLine=this.input.slice(0,this.lineStart).split(x).length)):this.lineStart=0,this.type=w.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||!0===e.strict||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("commonjs"===this.options.sourceType?2:1),this.regexpState=null,this.privateNameStack=[]},G={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowReturn:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},allowUsing:{configurable:!0},inClassStaticBlock:{configurable:!0}};F.prototype.parse=function(){var e=this,t=this.options.program||this.startNode();return this.nextToken(),this.catchStackOverflow(function(){return e.parseTopLevel(t)})},G.inFunction.get=function(){return(2&this.currentVarScope().flags)>0},G.inGenerator.get=function(){return(8&this.currentVarScope().flags)>0},G.inAsync.get=function(){return(4&this.currentVarScope().flags)>0},G.canAwait.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(768&t)return!1;if(2&t)return(4&t)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction},G.allowReturn.get=function(){return!!this.inFunction||!!(this.options.allowReturnOutsideFunction&&1&this.currentVarScope().flags)},G.allowSuper.get=function(){return(64&this.currentThisScope().flags)>0||this.options.allowSuperOutsideMethod},G.allowDirectSuper.get=function(){return(128&this.currentThisScope().flags)>0},G.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())},G.allowNewDotTarget.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(768&t||2&t&&!(16&t))return!0}return!1},G.allowUsing.get=function(){var e=this.currentScope().flags;return!(1024&e||!this.inModule&&1&e)},G.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&H)>0},F.extend=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];for(var s=this,r=0;r<e.length;r++)s=e[r](s);return s},F.parse=function(e,t){return new this(t,e).parse()},F.parseExpressionAt=function(e,t,s){var r=new this(s,e,t);return r.nextToken(),r.parseExpression()},F.tokenizer=function(e,t){return new this(t,e)},Object.defineProperties(F.prototype,G);var $=F.prototype,K=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;function W(e,t){for(var s=t+1,r=Math.min(e.input.length,t+11);s<r;){var i=e.fullCharCodeAt(s);if(!u(i,!0))break;s+=i<=65535?1:2}return s===t+2&&"in"===e.input.slice(t,s)||s===t+10&&"instanceof"===e.input.slice(t,s)}$.strictDirective=function(e){if(this.options.ecmaVersion<5)return!1;for(;;){_.lastIndex=e,e+=_.exec(this.input)[0].length;var t=K.exec(this.input.slice(e));if(!t)return!1;if("use strict"===(t[1]||t[2])){_.lastIndex=e+t[0].length;var s=_.exec(this.input),r=s.index+s[0].length,i=this.input.charAt(r);return";"===i||"}"===i||x.test(s[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(i)||"!"===i&&"="===this.input.charAt(r+1)||"i"===i&&W(this,r))}e+=t[0].length,_.lastIndex=e,e+=_.exec(this.input)[0].length,";"===this.input[e]&&e++}},$.eat=function(e){return this.type===e&&(this.next(),!0)},$.isContextual=function(e){return this.type===w.name&&this.value===e&&!this.containsEsc},$.eatContextual=function(e){return!!this.isContextual(e)&&(this.next(),!0)},$.catchStackOverflow=function(e){try{return e()}catch(e){if(!(e instanceof Error&&(/\bstack\b.*\b(exceeded|overflow)\b/i.test(e.message)||/\btoo much recursion\b/i.test(e.message))))throw e;this.raise(this.start,"Not enough stack space to parse input")}},$.expectContextual=function(e){this.eatContextual(e)||this.unexpected()},$.canInsertSemicolon=function(){return this.type===w.eof||this.type===w.braceR||x.test(this.input.slice(this.lastTokEnd,this.start))},$.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},$.semicolon=function(){this.eat(w.semi)||this.insertSemicolon()||this.unexpected()},$.afterTrailingComma=function(e,t){if(this.type===e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),t||this.next(),!0},$.expect=function(e){this.eat(e)||this.unexpected()},$.unexpected=function(e){this.raise(null!=e?e:this.start,"Unexpected token")};var Y=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};$.checkPatternErrors=function(e,t){if(e){e.trailingComma>-1&&this.raiseRecoverable(e.trailingComma,"Comma is not permitted after the rest element");var s=t?e.parenthesizedAssign:e.parenthesizedBind;s>-1&&this.raiseRecoverable(s,t?"Assigning to rvalue":"Parenthesized pattern")}},$.checkExpressionErrors=function(e,t){if(!e)return!1;var s=e.shorthandAssign,r=e.doubleProto;if(!t)return s>=0||r>=0;s>=0&&this.raise(s,"Shorthand property assignments are valid only in destructuring patterns"),r>=0&&this.raiseRecoverable(r,"Redefinition of __proto__ property")},$.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")},$.isSimpleAssignTarget=function(e){return"ParenthesizedExpression"===e.type?this.isSimpleAssignTarget(e.expression):"Identifier"===e.type||"MemberExpression"===e.type};var J=F.prototype;J.parseTopLevel=function(e){var t=Object.create(null);for(e.body||(e.body=[]);this.type!==w.eof;){var s=this.parseStatement(null,!0,t);e.body.push(s)}if(this.inModule)for(var r=0,i=Object.keys(this.undefinedExports);r<i.length;r+=1){var n=i[r];this.raiseRecoverable(this.undefinedExports[n].start,"Export '"+n+"' is not defined")}return this.adaptDirectivePrologue(e.body),this.next(),e.sourceType="commonjs"===this.options.sourceType?"script":this.options.sourceType,this.finishNode(e,"Program")};var X={kind:"loop"},Z={kind:"switch"};J.isLet=function(e){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;_.lastIndex=this.pos;var t=_.exec(this.input),s=this.pos+t[0].length,r=this.fullCharCodeAt(s);if(91===r||92===r)return!0;if(e)return!1;if(123===r)return!0;if(d(r)){var i=s;do{s+=r<=65535?1:2}while(u(r=this.fullCharCodeAt(s)));if(92===r)return!0;var n=this.input.slice(i,s);if(!a.test(n))return!0}return!1},J.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;_.lastIndex=this.pos;var e,t=_.exec(this.input),s=this.pos+t[0].length;return!(x.test(this.input.slice(this.pos,s))||"function"!==this.input.slice(s,s+8)||s+8!==this.input.length&&(u(e=this.fullCharCodeAt(s+8))||92===e))},J.isUsingKeyword=function(e,t){if(this.options.ecmaVersion<17||!this.isContextual(e?"await":"using"))return!1;_.lastIndex=this.pos;var s=_.exec(this.input),r=this.pos+s[0].length;if(x.test(this.input.slice(this.pos,r)))return!1;if(e){var i,n=r+5;if("using"!==this.input.slice(r,n)||n===this.input.length||u(i=this.fullCharCodeAt(n))||92===i)return!1;_.lastIndex=n;var o=_.exec(this.input);if(r=n+o[0].length,o&&x.test(this.input.slice(n,r)))return!1}var h=this.fullCharCodeAt(r);if(!d(h)&&92!==h)return!1;var l=r;do{r+=h<=65535?1:2}while(u(h=this.fullCharCodeAt(r)));if(92===h)return!0;var c=this.input.slice(l,r);return!(a.test(c)||t&&!e&&"of"===c&&(_.lastIndex=r,r+=_.exec(this.input)[0].length,61!==this.input.charCodeAt(r)||61===(h=this.input.charCodeAt(r+1))||62===h))},J.isAwaitUsing=function(e){return this.isUsingKeyword(!0,e)},J.isUsing=function(e){return this.isUsingKeyword(!1,e)},J.parseStatement=function(e,t,s){var r,i=this.type,n=this.startNode();switch(this.isLet(e)&&(i=w._var,r="let"),i){case w._break:case w._continue:return this.parseBreakContinueStatement(n,i.keyword);case w._debugger:return this.parseDebuggerStatement(n);case w._do:return this.parseDoStatement(n);case w._for:return this.parseForStatement(n);case w._function:return e&&(this.strict||"if"!==e&&"label"!==e)&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(n,!1,!e);case w._class:return e&&this.unexpected(),this.parseClass(n,!0);case w._if:return this.parseIfStatement(n);case w._return:return this.parseReturnStatement(n);case w._switch:return this.parseSwitchStatement(n);case w._throw:return this.parseThrowStatement(n);case w._try:return this.parseTryStatement(n);case w._const:case w._var:return r=r||this.value,e&&"var"!==r&&this.unexpected(),this.parseVarStatement(n,r);case w._while:return this.parseWhileStatement(n);case w._with:return this.parseWithStatement(n);case w.braceL:return this.parseBlock(!0,n);case w.semi:return this.parseEmptyStatement(n);case w._export:case w._import:if(this.options.ecmaVersion>10&&i===w._import){_.lastIndex=this.pos;var o=_.exec(this.input),a=this.pos+o[0].length,h=this.input.charCodeAt(a);if(40===h||46===h)return this.parseExpressionStatement(n,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===w._import?this.parseImport(n):this.parseExport(n,s);default:if(this.isAsyncFunction())return e&&this.unexpected(),this.next(),this.parseFunctionStatement(n,!0,!e);var l=this.isAwaitUsing(!1)?"await using":this.isUsing(!1)?"using":null;if(l)return this.allowUsing||this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script` or in the bare case statement"),e&&this.raise(this.start,"Using declaration is not allowed in single-statement positions"),"await using"===l&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.next(),this.parseVar(n,!1,l),this.semicolon(),this.finishNode(n,"VariableDeclaration");var c=this.value,d=this.parseExpression();return i===w.name&&"Identifier"===d.type&&this.eat(w.colon)?this.parseLabeledStatement(n,c,d,e):this.parseExpressionStatement(n,d)}},J.parseBreakContinueStatement=function(e,t){var s="break"===t;this.next(),this.eat(w.semi)||this.insertSemicolon()?e.label=null:this.type!==w.name?this.unexpected():(e.label=this.parseIdent(),this.semicolon());for(var r=0;r<this.labels.length;++r){var i=this.labels[r];if(null==e.label||i.name===e.label.name){if(null!=i.kind&&(s||"loop"===i.kind))break;if(e.label&&s)break}}return r===this.labels.length&&this.raise(e.start,"Unsyntactic "+t),this.finishNode(e,s?"BreakStatement":"ContinueStatement")},J.parseDebuggerStatement=function(e){return this.next(),this.semicolon(),this.finishNode(e,"DebuggerStatement")},J.parseDoStatement=function(e){return this.next(),this.labels.push(X),e.body=this.parseStatement("do"),this.labels.pop(),this.expect(w._while),e.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(w.semi):this.semicolon(),this.finishNode(e,"DoWhileStatement")},J.parseForStatement=function(e){this.next();var t=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(X),this.enterScope(0),this.expect(w.parenL),this.type===w.semi)return t>-1&&this.unexpected(t),this.parseFor(e,null);var s=this.isLet();if(this.type===w._var||this.type===w._const||s){var r=this.startNode(),i=s?"let":this.value;return this.next(),this.parseVar(r,!0,i),this.finishNode(r,"VariableDeclaration"),this.parseForAfterInit(e,r,t)}var n=this.isContextual("let"),o=!1,a=this.isUsing(!0)?"using":this.isAwaitUsing(!0)?"await using":null;if(a){var h=this.startNode();return this.next(),"await using"===a&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.parseVar(h,!0,a),this.finishNode(h,"VariableDeclaration"),this.parseForAfterInit(e,h,t)}var l=this.containsEsc,c=new Y,d=this.start,u=t>-1?this.parseExprSubscripts(c,"await"):this.parseExpression(!0,c);return this.type===w._in||(o=this.options.ecmaVersion>=6&&this.isContextual("of"))?(t>-1?(this.type===w._in&&this.unexpected(t),e.await=!0):o&&this.options.ecmaVersion>=8&&(u.start!==d||l||"Identifier"!==u.type||"async"!==u.name?this.options.ecmaVersion>=9&&(e.await=!1):this.unexpected()),n&&o&&this.raise(u.start,"The left-hand side of a for-of loop may not start with 'let'."),this.toAssignable(u,!1,c),this.checkLValPattern(u),this.parseForIn(e,u)):(this.checkExpressionErrors(c,!0),t>-1&&this.unexpected(t),this.parseFor(e,u))},J.parseForAfterInit=function(e,t,s){return(this.type===w._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&1===t.declarations.length?(this.type===w._in?("using"!==t.kind&&"await using"!==t.kind||t.declarations[0].init||this.raise(this.start,"Using declaration is not allowed in for-in loops"),this.options.ecmaVersion>=9&&s>-1&&this.unexpected(s)):this.options.ecmaVersion>=9&&(e.await=s>-1),this.parseForIn(e,t)):(s>-1&&this.unexpected(s),this.parseFor(e,t))},J.parseFunctionStatement=function(e,t,s){return this.next(),this.parseFunction(e,ee|(s?0:te),!1,t)},J.parseIfStatement=function(e){return this.next(),e.test=this.parseParenExpression(),e.consequent=this.parseStatement("if"),e.alternate=this.eat(w._else)?this.parseStatement("if"):null,this.finishNode(e,"IfStatement")},J.parseReturnStatement=function(e){return this.allowReturn||this.raise(this.start,"'return' outside of function"),this.next(),this.eat(w.semi)||this.insertSemicolon()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,"ReturnStatement")},J.parseSwitchStatement=function(e){var t;this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(w.braceL),this.labels.push(Z),this.enterScope(1024);for(var s=!1;this.type!==w.braceR;)if(this.type===w._case||this.type===w._default){var r=this.type===w._case;t&&this.finishNode(t,"SwitchCase"),e.cases.push(t=this.startNode()),t.consequent=[],this.next(),r?t.test=this.parseExpression():(s&&this.raiseRecoverable(this.lastTokStart,"Multiple default clauses"),s=!0,t.test=null),this.expect(w.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")},J.parseThrowStatement=function(e){return this.next(),x.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 Q=[];J.parseCatchClauseParam=function(){var e=this.parseBindingAtom(),t="Identifier"===e.type;return this.enterScope(t?32:0),this.checkLValPattern(e,t?4:2),this.expect(w.parenR),e},J.parseTryStatement=function(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.type===w._catch){var t=this.startNode();this.next(),this.eat(w.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(w._finally)?this.parseBlock():null,e.handler||e.finalizer||this.raise(e.start,"Missing catch or finally clause"),this.finishNode(e,"TryStatement")},J.parseVarStatement=function(e,t,s){return this.next(),this.parseVar(e,!1,t,s),this.semicolon(),this.finishNode(e,"VariableDeclaration")},J.parseWhileStatement=function(e){return this.next(),e.test=this.parseParenExpression(),this.labels.push(X),e.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(e,"WhileStatement")},J.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")},J.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,"EmptyStatement")},J.parseLabeledStatement=function(e,t,s,r){for(var i=0,n=this.labels;i<n.length;i+=1)n[i].name===t&&this.raise(s.start,"Label '"+t+"' is already declared");for(var o=this.type.isLoop?"loop":this.type===w._switch?"switch":null,a=this.labels.length-1;a>=0;a--){var h=this.labels[a];if(h.statementStart!==e.start)break;h.statementStart=this.start,h.kind=o}return this.labels.push({name:t,kind:o,statementStart:this.start}),e.body=this.parseStatement(r?-1===r.indexOf("label")?r+"label":r:"label"),this.labels.pop(),e.label=s,this.finishNode(e,"LabeledStatement")},J.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,"ExpressionStatement")},J.parseBlock=function(e,t,s){for(void 0===e&&(e=!0),void 0===t&&(t=this.startNode()),t.body=[],this.expect(w.braceL),e&&this.enterScope(0);this.type!==w.braceR;){var r=this.parseStatement(null);t.body.push(r)}return s&&(this.strict=!1),this.next(),e&&this.exitScope(),this.finishNode(t,"BlockStatement")},J.parseFor=function(e,t){return e.init=t,this.expect(w.semi),e.test=this.type===w.semi?null:this.parseExpression(),this.expect(w.semi),e.update=this.type===w.parenR?null:this.parseExpression(),this.expect(w.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,"ForStatement")},J.parseForIn=function(e,t){var s=this.type===w._in;return this.next(),"VariableDeclaration"===t.type&&null!=t.declarations[0].init&&(!s||this.options.ecmaVersion<8||this.strict||"var"!==t.kind||"Identifier"!==t.declarations[0].id.type)&&this.raise(t.start,(s?"for-in":"for-of")+" loop variable declaration may not have an initializer"),e.left=t,e.right=s?this.parseExpression():this.parseMaybeAssign(),this.expect(w.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,s?"ForInStatement":"ForOfStatement")},J.parseVar=function(e,t,s,r){for(e.declarations=[],e.kind=s;;){var i=this.startNode();if(this.parseVarId(i,s),this.eat(w.eq)?i.init=this.parseMaybeAssign(t):r||"const"!==s||this.type===w._in||this.options.ecmaVersion>=6&&this.isContextual("of")?r||"using"!==s&&"await using"!==s||!(this.options.ecmaVersion>=17)||this.type===w._in||this.isContextual("of")?r||"Identifier"===i.id.type||t&&(this.type===w._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 "+s+" declaration"):this.unexpected(),e.declarations.push(this.finishNode(i,"VariableDeclarator")),!this.eat(w.comma))break}return e},J.parseVarId=function(e,t){e.id="using"===t||"await using"===t?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(e.id,"var"===t?1:2,!1)};var ee=1,te=2;function se(e,t){var s=t.key.name,r=e[s],i="true";return"MethodDefinition"!==t.type||"get"!==t.kind&&"set"!==t.kind||(i=(t.static?"s":"i")+t.kind),"iget"===r&&"iset"===i||"iset"===r&&"iget"===i||"sget"===r&&"sset"===i||"sset"===r&&"sget"===i?(e[s]="true",!1):!!r||(e[s]=i,!1)}function re(e,t){var s=e.computed,r=e.key;return!s&&("Identifier"===r.type&&r.name===t||"Literal"===r.type&&r.value===t)}J.parseFunction=function(e,t,s,r,i){this.initFunction(e),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!r)&&(this.type===w.star&&t&te&&this.unexpected(),e.generator=this.eat(w.star)),this.options.ecmaVersion>=8&&(e.async=!!r),t&ee&&(e.id=4&t&&this.type!==w.name?null:this.parseIdent(),!e.id||t&te||this.checkLValSimple(e.id,this.strict||e.generator||e.async?this.treatFunctionsAsVar?1:2:3));var n=this.yieldPos,o=this.awaitPos,a=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(z(e.async,e.generator)),t&ee||(e.id=this.type===w.name?this.parseIdent():null),this.parseFunctionParams(e),this.parseFunctionBody(e,s,!1,i),this.yieldPos=n,this.awaitPos=o,this.awaitIdentPos=a,this.finishNode(e,t&ee?"FunctionDeclaration":"FunctionExpression")},J.parseFunctionParams=function(e){this.expect(w.parenL),e.params=this.parseBindingList(w.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},J.parseClass=function(e,t){this.next();var s=this.strict;this.strict=!0,this.parseClassId(e,t),this.parseClassSuper(e);var r=this.enterClassBody(),i=this.startNode(),n=!1;for(i.body=[],this.expect(w.braceL);this.type!==w.braceR;){var o=this.parseClassElement(null!==e.superClass);o&&(i.body.push(o),"MethodDefinition"===o.type&&"constructor"===o.kind?(n&&this.raiseRecoverable(o.start,"Duplicate constructor in the same class"),n=!0):o.key&&"PrivateIdentifier"===o.key.type&&se(r,o)&&this.raiseRecoverable(o.key.start,"Identifier '#"+o.key.name+"' has already been declared"))}return this.strict=s,this.next(),e.body=this.finishNode(i,"ClassBody"),this.exitClassBody(),this.finishNode(e,t?"ClassDeclaration":"ClassExpression")},J.parseClassElement=function(e){if(this.eat(w.semi))return null;var t=this.options.ecmaVersion,s=this.startNode(),r="",i=!1,n=!1,o="method",a=!1;if(this.eatContextual("static")){if(t>=13&&this.eat(w.braceL))return this.parseClassStaticBlock(s),s;this.isClassElementNameStart()||this.type===w.star?a=!0:r="static"}if(s.static=a,!r&&t>=8&&this.eatContextual("async")&&(!this.isClassElementNameStart()&&this.type!==w.star||this.canInsertSemicolon()?r="async":n=!0),!r&&(t>=9||!n)&&this.eat(w.star)&&(i=!0),!r&&!n&&!i){var h=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?o=h:r=h)}if(r?(s.computed=!1,s.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),s.key.name=r,this.finishNode(s.key,"Identifier")):this.parseClassElementName(s),t<13||this.type===w.parenL||"method"!==o||i||n){var l=!s.static&&re(s,"constructor"),c=l&&e;l&&"method"!==o&&this.raise(s.key.start,"Constructor can't have get/set modifier"),s.kind=l?"constructor":o,this.parseClassMethod(s,i,n,c)}else this.parseClassField(s);return s},J.isClassElementNameStart=function(){return this.type===w.name||this.type===w.privateId||this.type===w.num||this.type===w.string||this.type===w.bracketL||this.type.keyword},J.parseClassElementName=function(e){this.type===w.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)},J.parseClassMethod=function(e,t,s,r){var i=e.key;"constructor"===e.kind?(t&&this.raise(i.start,"Constructor can't be a generator"),s&&this.raise(i.start,"Constructor can't be an async method")):e.static&&re(e,"prototype")&&this.raise(i.start,"Classes may not have a static property named prototype");var n=e.value=this.parseMethod(t,s,r);return"get"===e.kind&&0!==n.params.length&&this.raiseRecoverable(n.start,"getter should have no params"),"set"===e.kind&&1!==n.params.length&&this.raiseRecoverable(n.start,"setter should have exactly one param"),"set"===e.kind&&"RestElement"===n.params[0].type&&this.raiseRecoverable(n.params[0].start,"Setter cannot use rest params"),this.finishNode(e,"MethodDefinition")},J.parseClassField=function(e){return re(e,"constructor")?this.raise(e.key.start,"Classes can't have a field named 'constructor'"):e.static&&re(e,"prototype")&&this.raise(e.key.start,"Classes can't have a static field named 'prototype'"),this.eat(w.eq)?(this.enterScope(576),e.value=this.parseMaybeAssign(),this.exitScope()):e.value=null,this.semicolon(),this.finishNode(e,"PropertyDefinition")},J.parseClassStaticBlock=function(e){e.body=[];var t=this.labels;for(this.labels=[],this.enterScope(320);this.type!==w.braceR;){var s=this.parseStatement(null);e.body.push(s)}return this.next(),this.exitScope(),this.labels=t,this.finishNode(e,"StaticBlock")},J.parseClassId=function(e,t){this.type===w.name?(e.id=this.parseIdent(),t&&this.checkLValSimple(e.id,2,!1)):(!0===t&&this.unexpected(),e.id=null)},J.parseClassSuper=function(e){e.superClass=this.eat(w._extends)?this.parseExprSubscripts(null,!1):null},J.enterClassBody=function(){var e={declared:Object.create(null),used:[]};return this.privateNameStack.push(e),e.declared},J.exitClassBody=function(){var e=this.privateNameStack.pop(),t=e.declared,s=e.used;if(this.options.checkPrivateFields)for(var r=this.privateNameStack.length,i=0===r?null:this.privateNameStack[r-1],n=0;n<s.length;++n){var o=s[n];T(t,o.name)||(i?i.used.push(o):this.raiseRecoverable(o.start,"Private field '#"+o.name+"' must be declared in an enclosing class"))}},J.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!==w.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ExportAllDeclaration")},J.parseExport=function(e,t){if(this.next(),this.eat(w.star))return this.parseExportAllDeclaration(e,t);if(this.eat(w._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!==w.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause());else{for(var s=0,r=e.specifiers;s<r.length;s+=1){var i=r[s];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")},J.parseExportDeclaration=function(e){return this.parseStatement(null)},J.parseExportDefaultDeclaration=function(){var e;if(this.type===w._function||(e=this.isAsyncFunction())){var t=this.startNode();return this.next(),e&&this.next(),this.parseFunction(t,4|ee,!1,e)}if(this.type===w._class){var s=this.startNode();return this.parseClass(s,"nullableID")}var r=this.parseMaybeAssign();return this.semicolon(),r},J.checkExport=function(e,t,s){e&&("string"!=typeof t&&(t="Identifier"===t.type?t.name:t.value),T(e,t)&&this.raiseRecoverable(s,"Duplicate export '"+t+"'"),e[t]=!0)},J.checkPatternExport=function(e,t){var s=t.type;if("Identifier"===s)this.checkExport(e,t,t.start);else if("ObjectPattern"===s)for(var r=0,i=t.properties;r<i.length;r+=1){var n=i[r];this.checkPatternExport(e,n)}else if("ArrayPattern"===s)for(var o=0,a=t.elements;o<a.length;o+=1){var h=a[o];h&&this.checkPatternExport(e,h)}else"Property"===s?this.checkPatternExport(e,t.value):"AssignmentPattern"===s?this.checkPatternExport(e,t.left):"RestElement"===s&&this.checkPatternExport(e,t.argument)},J.checkVariableExport=function(e,t){if(e)for(var s=0,r=t;s<r.length;s+=1){var i=r[s];this.checkPatternExport(e,i.id)}},J.shouldParseExportStatement=function(){return"var"===this.type.keyword||"const"===this.type.keyword||"class"===this.type.keyword||"function"===this.type.keyword||this.isLet()||this.isAsyncFunction()},J.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")},J.parseExportSpecifiers=function(e){var t=[],s=!0;for(this.expect(w.braceL);!this.eat(w.braceR);){if(s)s=!1;else if(this.expect(w.comma),this.afterTrailingComma(w.braceR))break;t.push(this.parseExportSpecifier(e))}return t},J.parseImport=function(e){return this.next(),this.type===w.string?(e.specifiers=Q,e.source=this.parseExprAtom()):(e.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),e.source=this.type===w.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ImportDeclaration")},J.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,2),this.finishNode(e,"ImportSpecifier")},J.parseImportDefaultSpecifier=function(){var e=this.startNode();return e.local=this.parseIdent(),this.checkLValSimple(e.local,2),this.finishNode(e,"ImportDefaultSpecifier")},J.parseImportNamespaceSpecifier=function(){var e=this.startNode();return this.next(),this.expectContextual("as"),e.local=this.parseIdent(),this.checkLValSimple(e.local,2),this.finishNode(e,"ImportNamespaceSpecifier")},J.parseImportSpecifiers=function(){var e=[],t=!0;if(this.type===w.name&&(e.push(this.parseImportDefaultSpecifier()),!this.eat(w.comma)))return e;if(this.type===w.star)return e.push(this.parseImportNamespaceSpecifier()),e;for(this.expect(w.braceL);!this.eat(w.braceR);){if(t)t=!1;else if(this.expect(w.comma),this.afterTrailingComma(w.braceR))break;e.push(this.parseImportSpecifier())}return e},J.parseWithClause=function(){var e=[];if(!this.eat(w._with))return e;this.expect(w.braceL);for(var t={},s=!0;!this.eat(w.braceR);){if(s)s=!1;else if(this.expect(w.comma),this.afterTrailingComma(w.braceR))break;var r=this.parseImportAttribute(),i="Identifier"===r.key.type?r.key.name:r.key.value;T(t,i)&&this.raiseRecoverable(r.key.start,"Duplicate attribute key '"+i+"'"),t[i]=!0,e.push(r)}return e},J.parseImportAttribute=function(){var e=this.startNode();return e.key=this.type===w.string?this.parseExprAtom():this.parseIdent("never"!==this.options.allowReserved),this.expect(w.colon),this.type!==w.string&&this.unexpected(),e.value=this.parseExprAtom(),this.finishNode(e,"ImportAttribute")},J.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===w.string){var e=this.parseLiteral(this.value);return N.test(e.value)&&this.raise(e.start,"An export name cannot include a lone surrogate."),e}return this.parseIdent(!0)},J.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)},J.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=F.prototype;ie.toAssignable=function(e,t,s){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",s&&this.checkPatternErrors(s,!0);for(var r=0,i=e.properties;r<i.length;r+=1){var n=i[r];this.toAssignable(n,t),"RestElement"!==n.type||"ArrayPattern"!==n.argument.type&&"ObjectPattern"!==n.argument.type||this.raise(n.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",s&&this.checkPatternErrors(s,!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,s);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 s&&this.checkPatternErrors(s,!0);return e},ie.toAssignableList=function(e,t){for(var s=e.length,r=0;r<s;r++){var i=e[r];i&&this.toAssignable(i,t)}if(s){var n=e[s-1];6===this.options.ecmaVersion&&t&&n&&"RestElement"===n.type&&"Identifier"!==n.argument.type&&this.unexpected(n.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!==w.name&&this.unexpected(),e.argument=this.parseBindingAtom(),this.finishNode(e,"RestElement")},ie.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case w.bracketL:var e=this.startNode();return this.next(),e.elements=this.parseBindingList(w.bracketR,!0,!0),this.finishNode(e,"ArrayPattern");case w.braceL:return this.parseObj(!0)}return this.parseIdent()},ie.parseBindingList=function(e,t,s,r){for(var i=[],n=!0;!this.eat(e);)if(n?n=!1:this.expect(w.comma),t&&this.type===w.comma)i.push(null);else{if(s&&this.afterTrailingComma(e))break;if(this.type===w.ellipsis){var o=this.parseRestBinding();this.parseBindingListItem(o),i.push(o),this.type===w.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.expect(e);break}i.push(this.parseAssignableListItem(r))}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,s){if(s=s||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(w.eq))return s;var r=this.startNodeAt(e,t);return r.left=s,r.right=this.parseMaybeAssign(),this.finishNode(r,"AssignmentPattern")},ie.checkLValSimple=function(e,t,s){void 0===t&&(t=0);var r=0!==t;switch(e.type){case"Identifier":this.strict&&this.reservedWordsStrictBind.test(e.name)&&this.raiseRecoverable(e.start,(r?"Binding ":"Assigning to ")+e.name+" in strict mode"),r&&(2===t&&"let"===e.name&&this.raiseRecoverable(e.start,"let is disallowed as a lexically bound name"),s&&(T(s,e.name)&&this.raiseRecoverable(e.start,"Argument name clash"),s[e.name]=!0),5!==t&&this.declareName(e.name,t,e.start));break;case"ChainExpression":this.raiseRecoverable(e.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":r&&this.raiseRecoverable(e.start,"Binding member expression");break;case"ParenthesizedExpression":return r&&this.raiseRecoverable(e.start,"Binding parenthesized expression"),this.checkLValSimple(e.expression,t,s);default:this.raise(e.start,(r?"Binding":"Assigning to")+" rvalue")}},ie.checkLValPattern=function(e,t,s){switch(void 0===t&&(t=0),e.type){case"ObjectPattern":for(var r=0,i=e.properties;r<i.length;r+=1){var n=i[r];this.checkLValInnerPattern(n,t,s)}break;case"ArrayPattern":for(var o=0,a=e.elements;o<a.length;o+=1){var h=a[o];h&&this.checkLValInnerPattern(h,t,s)}break;default:this.checkLValSimple(e,t,s)}},ie.checkLValInnerPattern=function(e,t,s){switch(void 0===t&&(t=0),e.type){case"Property":this.checkLValInnerPattern(e.value,t,s);break;case"AssignmentPattern":this.checkLValPattern(e.left,t,s);break;case"RestElement":this.checkLValPattern(e.argument,t,s);break;default:this.checkLValPattern(e,t,s)}};var ne=function(e,t,s,r,i){this.token=e,this.isExpr=!!t,this.preserveSpace=!!s,this.override=r,this.generator=!!i},oe={b_stat:new ne("{",!1),b_expr:new ne("{",!0),b_tmpl:new ne("${",!1),p_stat:new ne("(",!1),p_expr:new ne("(",!0),q_tmpl:new ne("`",!0,!0,function(e){return e.tryReadTemplateToken()}),f_stat:new ne("function",!1),f_expr:new ne("function",!0),f_expr_gen:new ne("function",!0,!1,null,!0),f_gen:new ne("function",!1,!1,null,!0)},ae=F.prototype;ae.initialContext=function(){return[oe.b_stat]},ae.curContext=function(){return this.context[this.context.length-1]},ae.braceIsBlock=function(e){var t=this.curContext();return t===oe.f_expr||t===oe.f_stat||(e!==w.colon||t!==oe.b_stat&&t!==oe.b_expr?e===w._return||e===w.name&&this.exprAllowed?x.test(this.input.slice(this.lastTokEnd,this.start)):e===w._else||e===w.semi||e===w.eof||e===w.parenR||e===w.arrow||(e===w.braceL?t===oe.b_stat:e!==w._var&&e!==w._const&&e!==w.name&&!this.exprAllowed):!t.isExpr)},ae.inGeneratorContext=function(){for(var e=this.context.length-1;e>=1;e--){var t=this.context[e];if("function"===t.token)return t.generator}return!1},ae.updateContext=function(e){var t,s=this.type;s.keyword&&e===w.dot?this.exprAllowed=!1:(t=s.updateContext)?t.call(this,e):this.exprAllowed=s.beforeExpr},ae.overrideContext=function(e){this.curContext()!==e&&(this.context[this.context.length-1]=e)},w.parenR.updateContext=w.braceR.updateContext=function(){if(1!==this.context.length){var e=this.context.pop();e===oe.b_stat&&"function"===this.curContext().token&&(e=this.context.pop()),this.exprAllowed=!e.isExpr}else this.exprAllowed=!0},w.braceL.updateContext=function(e){this.context.push(this.braceIsBlock(e)?oe.b_stat:oe.b_expr),this.exprAllowed=!0},w.dollarBraceL.updateContext=function(){this.context.push(oe.b_tmpl),this.exprAllowed=!0},w.parenL.updateContext=function(e){var t=e===w._if||e===w._for||e===w._with||e===w._while;this.context.push(t?oe.p_stat:oe.p_expr),this.exprAllowed=!0},w.incDec.updateContext=function(){},w._function.updateContext=w._class.updateContext=function(e){!e.beforeExpr||e===w._else||e===w.semi&&this.curContext()!==oe.p_stat||e===w._return&&x.test(this.input.slice(this.lastTokEnd,this.start))||(e===w.colon||e===w.braceL)&&this.curContext()===oe.b_stat?this.context.push(oe.f_stat):this.context.push(oe.f_expr),this.exprAllowed=!1},w.colon.updateContext=function(){"function"===this.curContext().token&&this.context.pop(),this.exprAllowed=!0},w.backQuote.updateContext=function(){this.curContext()===oe.q_tmpl?this.context.pop():this.context.push(oe.q_tmpl),this.exprAllowed=!1},w.star.updateContext=function(e){if(e===w._function){var t=this.context.length-1;this.context[t]===oe.f_expr?this.context[t]=oe.f_expr_gen:this.context[t]=oe.f_gen}this.exprAllowed=!0},w.name.updateContext=function(e){var t=!1;this.options.ecmaVersion>=6&&e!==w.dot&&("of"===this.value&&!this.exprAllowed||"yield"===this.value&&this.inGeneratorContext())&&(t=!0),this.exprAllowed=t};var he=F.prototype;function le(e){return"Identifier"===e.type||"ParenthesizedExpression"===e.type&&le(e.expression)}function ce(e){return"MemberExpression"===e.type&&"PrivateIdentifier"===e.property.type||"ChainExpression"===e.type&&ce(e.expression)||"ParenthesizedExpression"===e.type&&ce(e.expression)}he.checkPropClash=function(e,t,s){if(!(this.options.ecmaVersion>=9&&"SpreadElement"===e.type||this.options.ecmaVersion>=6&&(e.computed||e.method||e.shorthand))){var r,i=e.key;switch(i.type){case"Identifier":r=i.name;break;case"Literal":r=String(i.value);break;default:return}var n=e.kind;if(this.options.ecmaVersion>=6)"__proto__"===r&&"init"===n&&(t.proto&&(s?s.doubleProto<0&&(s.doubleProto=i.start):this.raiseRecoverable(i.start,"Redefinition of __proto__ property")),t.proto=!0);else{var o=t[r="$"+r];o?("init"===n?this.strict&&o.init||o.get||o.set:o.init||o[n])&&this.raiseRecoverable(i.start,"Redefinition of property"):o=t[r]={init:!1,get:!1,set:!1},o[n]=!0}}},he.parseExpression=function(e,t){var s=this;return this.catchStackOverflow(function(){var r=s.start,i=s.startLoc,n=s.parseMaybeAssign(e,t);if(s.type===w.comma){var o=s.startNodeAt(r,i);for(o.expressions=[n];s.eat(w.comma);)o.expressions.push(s.parseMaybeAssign(e,t));return s.finishNode(o,"SequenceExpression")}return n})},he.parseMaybeAssign=function(e,t,s){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(e);this.exprAllowed=!1}var r=!1,i=-1,n=-1,o=-1;t?(i=t.parenthesizedAssign,n=t.trailingComma,o=t.doubleProto,t.parenthesizedAssign=t.trailingComma=-1):(t=new Y,r=!0);var a=this.start,h=this.startLoc;this.type!==w.parenL&&this.type!==w.name||(this.potentialArrowAt=this.start,this.potentialArrowInForAwait="await"===e);var l=this.parseMaybeConditional(e,t);if(s&&(l=s.call(this,l,a,h)),this.type.isAssign){var c=this.startNodeAt(a,h);return c.operator=this.value,this.type===w.eq&&(l=this.toAssignable(l,!1,t)),r||(t.parenthesizedAssign=t.trailingComma=-1,t.shorthandAssign>=l.start&&(t.shorthandAssign=-1),t.doubleProto>=l.start&&(t.doubleProto=-1)),this.type===w.eq?this.checkLValPattern(l):this.checkLValSimple(l),c.left=l,this.next(),c.right=this.parseMaybeAssign(e),o>-1&&(t.doubleProto=o),this.finishNode(c,"AssignmentExpression")}return r&&this.checkExpressionErrors(t,!0),i>-1&&(t.parenthesizedAssign=i),n>-1&&(t.trailingComma=n),l},he.parseMaybeConditional=function(e,t){var s=this.start,r=this.startLoc,i=this.parseExprOps(e,t);if(this.checkExpressionErrors(t))return i;if(("ArrowFunctionExpression"!==i.type||i.start!==s)&&this.eat(w.question)){var n=this.startNodeAt(s,r);return n.test=i,n.consequent=this.parseMaybeAssign(),this.expect(w.colon),n.alternate=this.parseMaybeAssign(e),this.finishNode(n,"ConditionalExpression")}return i},he.parseExprOps=function(e,t){var s=this.start,r=this.startLoc,i=this.parseMaybeUnary(t,!1,!1,e);return this.checkExpressionErrors(t)||i.start===s&&"ArrowFunctionExpression"===i.type?i:this.parseExprOp(i,s,r,-1,e)},he.parseExprOp=function(e,t,s,r,i){var n=this.type.binop;if(null!=n&&(!i||this.type!==w._in)&&n>r){var o=this.type===w.logicalOR||this.type===w.logicalAND,a=this.type===w.coalesce;a&&(n=w.logicalAND.binop);var h=this.value;this.next();var l=this.start,c=this.startLoc,d=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,i),l,c,n,i),u=this.buildBinary(t,s,e,d,h,o||a);return(o&&this.type===w.coalesce||a&&(this.type===w.logicalOR||this.type===w.logicalAND))&&this.raiseRecoverable(this.start,"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"),this.parseExprOp(u,t,s,r,i)}return e},he.buildBinary=function(e,t,s,r,i,n){"PrivateIdentifier"===r.type&&this.raise(r.start,"Private identifier can only be left side of binary expression");var o=this.startNodeAt(e,t);return o.left=s,o.operator=i,o.right=r,this.finishNode(o,n?"LogicalExpression":"BinaryExpression")},he.parseMaybeUnary=function(e,t,s,r){var i,n=this.start,o=this.startLoc;if(this.isContextual("await")&&this.canAwait)i=this.parseAwait(r),t=!0;else if(this.type.prefix){var a=this.startNode(),h=this.type===w.incDec;a.operator=this.value,a.prefix=!0,this.next(),a.argument=this.parseMaybeUnary(null,!0,h,r),this.checkExpressionErrors(e,!0),h?this.checkLValSimple(a.argument):this.strict&&"delete"===a.operator&&le(a.argument)?this.raiseRecoverable(a.start,"Deleting local variable in strict mode"):"delete"===a.operator&&ce(a.argument)?this.raiseRecoverable(a.start,"Private fields can not be deleted"):t=!0,i=this.finishNode(a,h?"UpdateExpression":"UnaryExpression")}else if(t||this.type!==w.privateId){if(i=this.parseExprSubscripts(e,r),this.checkExpressionErrors(e))return i;for(;this.type.postfix&&!this.canInsertSemicolon();){var l=this.startNodeAt(n,o);l.operator=this.value,l.prefix=!1,l.argument=i,this.checkLValSimple(i),this.next(),i=this.finishNode(l,"UpdateExpression")}}else(r||0===this.privateNameStack.length)&&this.options.checkPrivateFields&&this.unexpected(),i=this.parsePrivateIdent(),this.type!==w._in&&this.unexpected();return s||"ArrowFunctionExpression"===i.type&&i.start===n||!this.eat(w.starstar)?i:t?void this.unexpected(this.lastTokStart):this.buildBinary(n,o,i,this.parseMaybeUnary(null,!1,!1,r),"**",!1)},he.parseExprSubscripts=function(e,t){var s=this.start,r=this.startLoc,i=-1,n=-1;e&&(i=e.doubleProto,n=e.shorthandAssign,e.doubleProto=e.shorthandAssign=-1);var o=this.parseExprAtom(e,t);if("ArrowFunctionExpression"===o.type&&")"!==this.input.slice(this.lastTokStart,this.lastTokEnd))return o;var a=this.parseSubscripts(o,s,r,!1,t);return e&&(a.end>o.end&&(this.checkExpressionErrors(e,!0),e.parenthesizedAssign>=a.start&&(e.parenthesizedAssign=-1),e.parenthesizedBind>=a.start&&(e.parenthesizedBind=-1),e.trailingComma>=a.start&&(e.trailingComma=-1)),i>-1&&(e.doubleProto=i),n>-1&&(e.shorthandAssign=n)),a},he.parseSubscripts=function(e,t,s,r,i){for(var n=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,o=!1;;){var a=this.parseSubscript(e,t,s,r,n,o,i);if(a.optional&&(o=!0),a.end===e.end||"ArrowFunctionExpression"===a.type){if(o){var h=this.startNodeAt(t,s);h.expression=a,a=this.finishNode(h,"ChainExpression")}return a}e=a,n=!1}},he.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(w.arrow)},he.parseSubscriptAsyncArrow=function(e,t,s,r){return this.parseArrowExpression(this.startNodeAt(e,t),s,!0,r)},he.parseSubscript=function(e,t,s,r,i,n,o){var a=this.options.ecmaVersion>=11,h=a&&this.eat(w.questionDot);r&&h&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var l=this.eat(w.bracketL);if(l||h&&this.type!==w.parenL&&this.type!==w.backQuote||this.eat(w.dot)){var c=this.startNodeAt(t,s);c.object=e,l?(c.property=this.parseExpression(),this.expect(w.bracketR)):this.type===w.privateId&&"Super"!==e.type?c.property=this.parsePrivateIdent():c.property=this.parseIdent("never"!==this.options.allowReserved),c.computed=!!l,a&&(c.optional=h),e=this.finishNode(c,"MemberExpression")}else if(!r&&this.eat(w.parenL)){var d=new Y,u=this.yieldPos,p=this.awaitPos,f=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var m=this.parseExprList(w.parenR,this.options.ecmaVersion>=8,!1,d);if(i&&!h&&this.shouldParseAsyncArrow())return this.checkPatternErrors(d,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,"Cannot use 'await' as identifier inside an async function"),this.yieldPos=u,this.awaitPos=p,this.awaitIdentPos=f,this.parseSubscriptAsyncArrow(t,s,m,o);this.checkExpressionErrors(d,!0),this.yieldPos=u||this.yieldPos,this.awaitPos=p||this.awaitPos,this.awaitIdentPos=f||this.awaitIdentPos;var g=this.startNodeAt(t,s);g.callee=e,g.arguments=m,a&&(g.optional=h),e=this.finishNode(g,"CallExpression")}else if(this.type===w.backQuote){(h||n)&&this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var y=this.startNodeAt(t,s);y.tag=e,y.quasi=this.parseTemplate({isTagged:!0}),e=this.finishNode(y,"TaggedTemplateExpression")}return e},he.parseExprAtom=function(e,t,s){this.type===w.slash&&this.readRegexp();var r,i=this.potentialArrowAt===this.start;switch(this.type){case w._super:return this.allowSuper||this.raise(this.start,"'super' keyword outside a method"),r=this.startNode(),this.next(),this.type!==w.parenL||this.allowDirectSuper||this.raise(r.start,"super() call outside constructor of a subclass"),this.type!==w.dot&&this.type!==w.bracketL&&this.type!==w.parenL&&this.unexpected(),this.finishNode(r,"Super");case w._this:return r=this.startNode(),this.next(),this.finishNode(r,"ThisExpression");case w.name:var n=this.start,o=this.startLoc,a=this.containsEsc,h=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!a&&"async"===h.name&&!this.canInsertSemicolon()&&this.eat(w._function))return this.overrideContext(oe.f_expr),this.parseFunction(this.startNodeAt(n,o),0,!1,!0,t);if(i&&!this.canInsertSemicolon()){if(this.eat(w.arrow))return this.parseArrowExpression(this.startNodeAt(n,o),[h],!1,t);if(this.options.ecmaVersion>=8&&"async"===h.name&&this.type===w.name&&!a&&(!this.potentialArrowInForAwait||"of"!==this.value||this.containsEsc))return h=this.parseIdent(!1),!this.canInsertSemicolon()&&this.eat(w.arrow)||this.unexpected(),this.parseArrowExpression(this.startNodeAt(n,o),[h],!0,t)}return h;case w.regexp:var l=this.value;return(r=this.parseLiteral(l.value)).regex={pattern:l.pattern,flags:l.flags},r;case w.num:case w.string:return this.parseLiteral(this.value);case w._null:case w._true:case w._false:return(r=this.startNode()).value=this.type===w._null?null:this.type===w._true,r.raw=this.type.keyword,this.next(),this.finishNode(r,"Literal");case w.parenL:var c=this.start,d=this.parseParenAndDistinguishExpression(i,t);return e&&(e.parenthesizedAssign<0&&!this.isSimpleAssignTarget(d)&&(e.parenthesizedAssign=c),e.parenthesizedBind<0&&(e.parenthesizedBind=c)),d;case w.bracketL:return r=this.startNode(),this.next(),r.elements=this.parseExprList(w.bracketR,!0,!0,e),this.finishNode(r,"ArrayExpression");case w.braceL:return this.overrideContext(oe.b_expr),this.parseObj(!1,e);case w._function:return r=this.startNode(),this.next(),this.parseFunction(r,0);case w._class:return this.parseClass(this.startNode(),!1);case w._new:return this.parseNew();case w.backQuote:return this.parseTemplate();case w._import:return this.options.ecmaVersion>=11?this.parseExprImport(s):this.unexpected();default:return this.parseExprAtomDefault()}},he.parseExprAtomDefault=function(){this.unexpected()},he.parseExprImport=function(e){var t=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import"),this.next(),this.type===w.parenL&&!e)return this.parseDynamicImport(t);if(this.type===w.dot){var s=this.startNodeAt(t.start,t.loc&&t.loc.start);return s.name="import",t.meta=this.finishNode(s,"Identifier"),this.parseImportMeta(t)}this.unexpected()},he.parseDynamicImport=function(e){if(this.next(),e.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(w.parenR)?e.options=null:(this.expect(w.comma),this.afterTrailingComma(w.parenR)?e.options=null:(e.options=this.parseMaybeAssign(),this.eat(w.parenR)||(this.expect(w.comma),this.afterTrailingComma(w.parenR)||this.unexpected())));else if(!this.eat(w.parenR)){var t=this.start;this.eat(w.comma)&&this.eat(w.parenR)?this.raiseRecoverable(t,"Trailing comma is not allowed in import()"):this.unexpected(t)}return this.finishNode(e,"ImportExpression")},he.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")},he.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")},he.parseParenExpression=function(){this.expect(w.parenL);var e=this.parseExpression();return this.expect(w.parenR),e},he.shouldParseArrow=function(e){return!this.canInsertSemicolon()},he.parseParenAndDistinguishExpression=function(e,t){var s,r=this.start,i=this.startLoc,n=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var o,a=this.start,h=this.startLoc,l=[],c=!0,d=!1,u=new Y,p=this.yieldPos,f=this.awaitPos;for(this.yieldPos=0,this.awaitPos=0;this.type!==w.parenR;){if(c?c=!1:this.expect(w.comma),n&&this.afterTrailingComma(w.parenR,!0)){d=!0;break}if(this.type===w.ellipsis){o=this.start,l.push(this.parseParenItem(this.parseRestBinding())),this.type===w.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}l.push(this.parseMaybeAssign(!1,u,this.parseParenItem))}var m=this.lastTokEnd,g=this.lastTokEndLoc;if(this.expect(w.parenR),e&&this.shouldParseArrow(l)&&this.eat(w.arrow))return this.checkPatternErrors(u,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=p,this.awaitPos=f,this.parseParenArrowList(r,i,l,t);l.length&&!d||this.unexpected(this.lastTokStart),o&&this.unexpected(o),this.checkExpressionErrors(u,!0),this.yieldPos=p||this.yieldPos,this.awaitPos=f||this.awaitPos,l.length>1?((s=this.startNodeAt(a,h)).expressions=l,this.finishNodeAt(s,"SequenceExpression",m,g)):s=l[0]}else s=this.parseParenExpression();if(this.options.preserveParens){var y=this.startNodeAt(r,i);return y.expression=s,this.finishNode(y,"ParenthesizedExpression")}return s},he.parseParenItem=function(e){return e},he.parseParenArrowList=function(e,t,s,r){return this.parseArrowExpression(this.startNodeAt(e,t),s,!1,r)};var de=[];he.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===w.dot){var t=this.startNodeAt(e.start,e.loc&&e.loc.start);t.name="new",e.meta=this.finishNode(t,"Identifier"),this.next();var s=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'"),s&&this.raiseRecoverable(e.start,"'new.target' must not contain escaped characters"),this.allowNewDotTarget||this.raiseRecoverable(e.start,"'new.target' can only be used in functions and class static block"),this.finishNode(e,"MetaProperty")}var r=this.start,i=this.startLoc;return e.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),r,i,!0,!1),"Super"===e.callee.type&&this.raiseRecoverable(r,"Invalid use of 'super'"),this.eat(w.parenL)?e.arguments=this.parseExprList(w.parenR,this.options.ecmaVersion>=8,!1):e.arguments=de,this.finishNode(e,"NewExpression")},he.parseTemplateElement=function(e){var t=e.isTagged,s=this.startNode();return this.type===w.invalidTemplate?(t||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),s.value={raw:this.value.replace(/\r\n?/g,"\n"),cooked:null}):s.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,"\n"),cooked:this.value},this.next(),s.tail=this.type===w.backQuote,this.finishNode(s,"TemplateElement")},he.parseTemplate=function(e){void 0===e&&(e={});var t=e.isTagged;void 0===t&&(t=!1);var s=this.startNode();this.next(),s.expressions=[];var r=this.parseTemplateElement({isTagged:t});for(s.quasis=[r];!r.tail;)this.type===w.eof&&this.raise(this.pos,"Unterminated template literal"),this.expect(w.dollarBraceL),s.expressions.push(this.parseExpression()),this.expect(w.braceR),s.quasis.push(r=this.parseTemplateElement({isTagged:t}));return this.next(),this.finishNode(s,"TemplateLiteral")},he.isAsyncProp=function(e){return!e.computed&&"Identifier"===e.key.type&&"async"===e.key.name&&(this.type===w.name||this.type===w.num||this.type===w.string||this.type===w.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===w.star)&&!x.test(this.input.slice(this.lastTokEnd,this.start))},he.parseObj=function(e,t){var s=this.startNode(),r=!0,i={};for(s.properties=[],this.next();!this.eat(w.braceR);){if(r)r=!1;else if(this.expect(w.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(w.braceR))break;var n=this.parseProperty(e,t);e||this.checkPropClash(n,i,t),s.properties.push(n)}return this.finishNode(s,e?"ObjectPattern":"ObjectExpression")},he.parseProperty=function(e,t){var s,r,i,n,o=this.startNode();if(this.options.ecmaVersion>=9&&this.eat(w.ellipsis))return e?(o.argument=this.parseIdent(!1),this.type===w.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.finishNode(o,"RestElement")):(o.argument=this.parseMaybeAssign(!1,t),this.type===w.comma&&t&&t.trailingComma<0&&(t.trailingComma=this.start),this.finishNode(o,"SpreadElement"));this.options.ecmaVersion>=6&&(o.method=!1,o.shorthand=!1,(e||t)&&(i=this.start,n=this.startLoc),e||(s=this.eat(w.star)));var a=this.containsEsc;return this.parsePropertyName(o),!e&&!a&&this.options.ecmaVersion>=8&&!s&&this.isAsyncProp(o)?(r=!0,s=this.options.ecmaVersion>=9&&this.eat(w.star),this.parsePropertyName(o)):r=!1,this.parsePropertyValue(o,e,s,r,i,n,t,a),this.finishNode(o,"Property")},he.parseGetterSetter=function(e){var t=e.key.name;this.parsePropertyName(e),e.value=this.parseMethod(!1),e.kind=t;var s="get"===e.kind?0:1;if(e.value.params.length!==s){var r=e.value.start;"get"===e.kind?this.raiseRecoverable(r,"getter should have no params"):this.raiseRecoverable(r,"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")},he.parsePropertyValue=function(e,t,s,r,i,n,o,a){(s||r)&&this.type===w.colon&&this.unexpected(),this.eat(w.colon)?(e.value=t?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,o),e.kind="init"):this.options.ecmaVersion>=6&&this.type===w.parenL?(t&&this.unexpected(),e.method=!0,e.value=this.parseMethod(s,r),e.kind="init"):t||a||!(this.options.ecmaVersion>=5)||e.computed||"Identifier"!==e.key.type||"get"!==e.key.name&&"set"!==e.key.name||this.type===w.comma||this.type===w.braceR||this.type===w.eq?this.options.ecmaVersion>=6&&!e.computed&&"Identifier"===e.key.type?((s||r)&&this.unexpected(),this.checkUnreserved(e.key),"await"!==e.key.name||this.awaitIdentPos||(this.awaitIdentPos=i),t?e.value=this.parseMaybeDefault(i,n,this.copyNode(e.key)):this.type===w.eq&&o?(o.shorthandAssign<0&&(o.shorthandAssign=this.start),e.value=this.parseMaybeDefault(i,n,this.copyNode(e.key))):e.value=this.copyNode(e.key),e.kind="init",e.shorthand=!0):this.unexpected():((s||r)&&this.unexpected(),this.parseGetterSetter(e))},he.parsePropertyName=function(e){if(this.options.ecmaVersion>=6){if(this.eat(w.bracketL))return e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(w.bracketR),e.key;e.computed=!1}return e.key=this.type===w.num||this.type===w.string?this.parseExprAtom():this.parseIdent("never"!==this.options.allowReserved)},he.initFunction=function(e){e.id=null,this.options.ecmaVersion>=6&&(e.generator=e.expression=!1),this.options.ecmaVersion>=8&&(e.async=!1)},he.parseMethod=function(e,t,s){var r=this.startNode(),i=this.yieldPos,n=this.awaitPos,o=this.awaitIdentPos;return this.initFunction(r),this.options.ecmaVersion>=6&&(r.generator=e),this.options.ecmaVersion>=8&&(r.async=!!t),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(64|z(t,r.generator)|(s?128:0)),this.expect(w.parenL),r.params=this.parseBindingList(w.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(r,!1,!0,!1),this.yieldPos=i,this.awaitPos=n,this.awaitIdentPos=o,this.finishNode(r,"FunctionExpression")},he.parseArrowExpression=function(e,t,s,r){var i=this.yieldPos,n=this.awaitPos,o=this.awaitIdentPos;return this.enterScope(16|z(s,!1)),this.initFunction(e),this.options.ecmaVersion>=8&&(e.async=!!s),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,e.params=this.toAssignableList(t,!0),this.parseFunctionBody(e,!0,!1,r),this.yieldPos=i,this.awaitPos=n,this.awaitIdentPos=o,this.finishNode(e,"ArrowFunctionExpression")},he.parseFunctionBody=function(e,t,s,r){var i=t&&this.type!==w.braceL,n=this.strict,o=!1;if(i)e.body=this.parseMaybeAssign(r),e.expression=!0,this.checkParams(e,!1);else{var a=this.options.ecmaVersion>=7&&!this.isSimpleParamList(e.params);n&&!a||(o=this.strictDirective(this.end))&&a&&this.raiseRecoverable(e.start,"Illegal 'use strict' directive in function with non-simple parameter list");var h=this.labels;this.labels=[],o&&(this.strict=!0),this.checkParams(e,!n&&!o&&!t&&!s&&this.isSimpleParamList(e.params)),this.strict&&e.id&&this.checkLValSimple(e.id,5),e.body=this.parseBlock(!1,void 0,o&&!n),e.expression=!1,this.adaptDirectivePrologue(e.body.body),this.labels=h}this.exitScope()},he.isSimpleParamList=function(e){for(var t=0,s=e;t<s.length;t+=1)if("Identifier"!==s[t].type)return!1;return!0},he.checkParams=function(e,t){for(var s=Object.create(null),r=0,i=e.params;r<i.length;r+=1){var n=i[r];this.checkLValInnerPattern(n,1,t?null:s)}},he.parseExprList=function(e,t,s,r){for(var i=[],n=!0;!this.eat(e);){if(n)n=!1;else if(this.expect(w.comma),t&&this.afterTrailingComma(e))break;var o=void 0;s&&this.type===w.comma?o=null:this.type===w.ellipsis?(o=this.parseSpread(r),r&&this.type===w.comma&&r.trailingComma<0&&(r.trailingComma=this.start)):o=this.parseMaybeAssign(!1,r),i.push(o)}return i},he.checkUnreserved=function(e){var t=e.start,s=e.end,r=e.name;this.inGenerator&&"yield"===r&&this.raiseRecoverable(t,"Cannot use 'yield' as identifier inside a generator"),this.inAsync&&"await"===r&&this.raiseRecoverable(t,"Cannot use 'await' as identifier inside an async function"),this.currentThisScope().flags&V||"arguments"!==r||this.raiseRecoverable(t,"Cannot use 'arguments' in class field initializer"),!this.inClassStaticBlock||"arguments"!==r&&"await"!==r||this.raise(t,"Cannot use "+r+" in class static initialization block"),this.keywords.test(r)&&this.raise(t,"Unexpected keyword '"+r+"'"),this.options.ecmaVersion<6&&-1!==this.input.slice(t,s).indexOf("\\")||(this.strict?this.reservedWordsStrict:this.reservedWords).test(r)&&(this.inAsync||"await"!==r||this.raiseRecoverable(t,"Cannot use keyword 'await' outside an async function"),this.raiseRecoverable(t,"The keyword '"+r+"' is reserved"))},he.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},he.parseIdentNode=function(){var e=this.startNode();return this.type===w.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=w.name):this.unexpected(),e},he.parsePrivateIdent=function(){var e=this.startNode();return this.type===w.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},he.parseYield=function(e){this.yieldPos||(this.yieldPos=this.start);var t=this.startNode();return this.next(),this.type===w.semi||this.canInsertSemicolon()||this.type!==w.star&&!this.type.startsExpr?(t.delegate=!1,t.argument=null):(t.delegate=this.eat(w.star),t.argument=this.parseMaybeAssign(e)),this.finishNode(t,"YieldExpression")},he.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 ue=F.prototype;ue.raise=function(e,t){var s=B(this.input,e);t+=" ("+s.line+":"+s.column+")",this.sourceFile&&(t+=" in "+this.sourceFile);var r=new SyntaxError(t);throw r.pos=e,r.loc=s,r.raisedAt=this.pos,r},ue.raiseRecoverable=ue.raise,ue.curPosition=function(){if(this.options.locations)return new O(this.curLine,this.pos-this.lineStart)};var pe=F.prototype,fe=function(e){this.flags=e,this.var=[],this.lexical=[],this.functions=[]};pe.enterScope=function(e){this.scopeStack.push(new fe(e))},pe.exitScope=function(){this.scopeStack.pop()},pe.treatFunctionsAsVarInScope=function(e){return 2&e.flags||!this.inModule&&1&e.flags},pe.declareName=function(e,t,s){var r=!1;if(2===t){var i=this.currentScope();r=i.lexical.indexOf(e)>-1||i.functions.indexOf(e)>-1||i.var.indexOf(e)>-1,i.lexical.push(e),this.inModule&&1&i.flags&&delete this.undefinedExports[e]}else if(4===t)this.currentScope().lexical.push(e);else if(3===t){var n=this.currentScope();r=this.treatFunctionsAsVar?n.lexical.indexOf(e)>-1:n.lexical.indexOf(e)>-1||n.var.indexOf(e)>-1,n.functions.push(e)}else for(var o=this.scopeStack.length-1;o>=0;--o){var a=this.scopeStack[o];if(a.lexical.indexOf(e)>-1&&!(32&a.flags&&a.lexical[0]===e)||!this.treatFunctionsAsVarInScope(a)&&a.functions.indexOf(e)>-1){r=!0;break}if(a.var.push(e),this.inModule&&1&a.flags&&delete this.undefinedExports[e],a.flags&V)break}r&&this.raiseRecoverable(s,"Identifier '"+e+"' has already been declared")},pe.checkLocalExport=function(e){-1===this.scopeStack[0].lexical.indexOf(e.name)&&-1===this.scopeStack[0].var.indexOf(e.name)&&(this.undefinedExports[e.name]=e)},pe.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]},pe.currentVarScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(771&t.flags)return t}},pe.currentThisScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(771&t.flags&&!(16&t.flags))return t}};var me=function(e,t,s){this.type="",this.start=t,this.end=0,e.options.locations&&(this.loc=new U(e,s)),e.options.directSourceFile&&(this.sourceFile=e.options.directSourceFile),e.options.ranges&&(this.range=[t,0])},ge=F.prototype;function ye(e,t,s,r){return e.type=t,e.end=s,this.options.locations&&(e.loc.end=r),this.options.ranges&&(e.range[1]=s),e}ge.startNode=function(){return new me(this,this.start,this.startLoc)},ge.startNodeAt=function(e,t){return new me(this,e,t)},ge.finishNode=function(e,t){return ye.call(this,e,t,this.lastTokEnd,this.lastTokEndLoc)},ge.finishNodeAt=function(e,t,s,r){return ye.call(this,e,t,s,r)},ge.copyNode=function(e){var t=new me(this,e.start,this.startLoc);for(var s in e)t[s]=e[s];return t};var ve="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",we=ve+" Extended_Pictographic",xe=we+" EBase EComp EMod EPres ExtPict",be={9:ve,10:we,11:we,12:xe,13:xe,14:xe},Ee={9:"",10:"",11:"",12:"",13:"",14:"Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji"},Se="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",ke="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",_e=ke+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",Ce=_e+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",Ae=Ce+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",Ie=Ae+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",Te={9:ke,10:_e,11:Ce,12:Ae,13:Ie,14:Ie+" Berf Beria_Erfe Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sidetic Sidt Sunu Sunuwar Tai_Yo Tayo Todhri Todr Tolong_Siki Tols Tulu_Tigalari Tutg Unknown Zzzz"},Pe={};function Le(e){var t=Pe[e]={binary:M(be[e]+" "+Se),binaryOfStrings:M(Ee[e]),nonBinary:{General_Category:M(Se),Script:M(Te[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 Me=0,Re=[9,10,11,12,13,14];Me<Re.length;Me+=1)Le(Re[Me]);var Ne=F.prototype,Oe=function(e,t){this.parent=e,this.base=t||this};Oe.prototype.separatedFrom=function(e){for(var t=this;t;t=t.parent)for(var s=e;s;s=s.parent)if(t.base===s.base&&t!==s)return!0;return!1},Oe.prototype.sibling=function(){return new Oe(this.parent,this.base)};var Ue=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=Pe[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 Be(e){return 105===e||109===e||115===e}function De(e){return 36===e||e>=40&&e<=43||46===e||63===e||e>=91&&e<=94||e>=123&&e<=125}function je(e){return e>=65&&e<=90||e>=97&&e<=122}Ue.prototype.reset=function(e,t,s){var r=-1!==s.indexOf("v"),i=-1!==s.indexOf("u");this.start=0|e,this.source=t+"",this.flags=s,r&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=i&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=i&&this.parser.options.ecmaVersion>=9)},Ue.prototype.raise=function(e){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+e)},Ue.prototype.at=function(e,t){void 0===t&&(t=!1);var s=this.source,r=s.length;if(e>=r)return-1;var i=s.charCodeAt(e);if(!t&&!this.switchU||i<=55295||i>=57344||e+1>=r)return i;var n=s.charCodeAt(e+1);return n>=56320&&n<=57343?(i<<10)+n-56613888:i},Ue.prototype.nextIndex=function(e,t){void 0===t&&(t=!1);var s=this.source,r=s.length;if(e>=r)return r;var i,n=s.charCodeAt(e);return!t&&!this.switchU||n<=55295||n>=57344||e+1>=r||(i=s.charCodeAt(e+1))<56320||i>57343?e+1:e+2},Ue.prototype.current=function(e){return void 0===e&&(e=!1),this.at(this.pos,e)},Ue.prototype.lookahead=function(e){return void 0===e&&(e=!1),this.at(this.nextIndex(this.pos,e),e)},Ue.prototype.advance=function(e){void 0===e&&(e=!1),this.pos=this.nextIndex(this.pos,e)},Ue.prototype.eat=function(e,t){return void 0===t&&(t=!1),this.current(t)===e&&(this.advance(t),!0)},Ue.prototype.eatChars=function(e,t){void 0===t&&(t=!1);for(var s=this.pos,r=0,i=e;r<i.length;r+=1){var n=i[r],o=this.at(s,t);if(-1===o||o!==n)return!1;s=this.nextIndex(s,t)}return this.pos=s,!0},Ne.validateRegExpFlags=function(e){for(var t=e.validFlags,s=e.flags,r=!1,i=!1,n=0;n<s.length;n++){var o=s.charAt(n);-1===t.indexOf(o)&&this.raise(e.start,"Invalid regular expression flag"),s.indexOf(o,n+1)>-1&&this.raise(e.start,"Duplicate regular expression flag"),"u"===o&&(r=!0),"v"===o&&(i=!0)}this.options.ecmaVersion>=15&&r&&i&&this.raise(e.start,"Invalid regular expression flag")},Ne.validateRegExpPattern=function(e){this.regexp_pattern(e),!e.switchN&&this.options.ecmaVersion>=9&&function(e){for(var t in e)return!0;return!1}(e.groupNames)&&(e.switchN=!0,this.regexp_pattern(e))},Ne.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,s=e.backReferenceNames;t<s.length;t+=1){var r=s[t];e.groupNames[r]||e.raise("Invalid named capture referenced")}},Ne.regexp_disjunction=function(e){var t=this.options.ecmaVersion>=16;for(t&&(e.branchID=new Oe(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")},Ne.regexp_alternative=function(e){for(;e.pos<e.source.length&&this.regexp_eatTerm(e););},Ne.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)},Ne.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 s=!1;if(this.options.ecmaVersion>=9&&(s=e.eat(60)),e.eat(61)||e.eat(33))return this.regexp_disjunction(e),e.eat(41)||e.raise("Unterminated group"),e.lastAssertionIsQuantifiable=!s,!0}return e.pos=t,!1},Ne.regexp_eatQuantifier=function(e,t){return void 0===t&&(t=!1),!!this.regexp_eatQuantifierPrefix(e,t)&&(e.eat(63),!0)},Ne.regexp_eatQuantifierPrefix=function(e,t){return e.eat(42)||e.eat(43)||e.eat(63)||this.regexp_eatBracedQuantifier(e,t)},Ne.regexp_eatBracedQuantifier=function(e,t){var s=e.pos;if(e.eat(123)){var r=0,i=-1;if(this.regexp_eatDecimalDigits(e)&&(r=e.lastIntValue,e.eat(44)&&this.regexp_eatDecimalDigits(e)&&(i=e.lastIntValue),e.eat(125)))return-1!==i&&i<r&&!t&&e.raise("numbers out of order in {} quantifier"),!0;e.switchU&&!t&&e.raise("Incomplete quantifier"),e.pos=s}return!1},Ne.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)},Ne.regexp_eatReverseSolidusAtomEscape=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatAtomEscape(e))return!0;e.pos=t}return!1},Ne.regexp_eatUncapturingGroup=function(e){var t=e.pos;if(e.eat(40)){if(e.eat(63)){if(this.options.ecmaVersion>=16){var s=this.regexp_eatModifiers(e),r=e.eat(45);if(s||r){for(var i=0;i<s.length;i++){var n=s.charAt(i);s.indexOf(n,i+1)>-1&&e.raise("Duplicate regular expression modifiers")}if(r){var o=this.regexp_eatModifiers(e);s||o||58!==e.current()||e.raise("Invalid regular expression modifiers");for(var a=0;a<o.length;a++){var h=o.charAt(a);(o.indexOf(h,a+1)>-1||s.indexOf(h)>-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},Ne.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},Ne.regexp_eatModifiers=function(e){for(var t="",s=0;-1!==(s=e.current())&&Be(s);)t+=R(s),e.advance();return t},Ne.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)},Ne.regexp_eatInvalidBracedQuantifier=function(e){return this.regexp_eatBracedQuantifier(e,!0)&&e.raise("Nothing to repeat"),!1},Ne.regexp_eatSyntaxCharacter=function(e){var t=e.current();return!!De(t)&&(e.lastIntValue=t,e.advance(),!0)},Ne.regexp_eatPatternCharacters=function(e){for(var t=e.pos,s=0;-1!==(s=e.current())&&!De(s);)e.advance();return e.pos!==t},Ne.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))},Ne.regexp_groupSpecifier=function(e){if(e.eat(63)){this.regexp_eatGroupName(e)||e.raise("Invalid group");var t=this.options.ecmaVersion>=16,s=e.groupNames[e.lastStringValue];if(s)if(t)for(var r=0,i=s;r<i.length;r+=1)i[r].separatedFrom(e.branchID)||e.raise("Duplicate capture group name");else e.raise("Duplicate capture group name");t?(s||(e.groupNames[e.lastStringValue]=[])).push(e.branchID):e.groupNames[e.lastStringValue]=!0}},Ne.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},Ne.regexp_eatRegExpIdentifierName=function(e){if(e.lastStringValue="",this.regexp_eatRegExpIdentifierStart(e)){for(e.lastStringValue+=R(e.lastIntValue);this.regexp_eatRegExpIdentifierPart(e);)e.lastStringValue+=R(e.lastIntValue);return!0}return!1},Ne.regexp_eatRegExpIdentifierStart=function(e){var t=e.pos,s=this.options.ecmaVersion>=11,r=e.current(s);return e.advance(s),92===r&&this.regexp_eatRegExpUnicodeEscapeSequence(e,s)&&(r=e.lastIntValue),function(e){return d(e,!0)||36===e||95===e}(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)},Ne.regexp_eatRegExpIdentifierPart=function(e){var t=e.pos,s=this.options.ecmaVersion>=11,r=e.current(s);return e.advance(s),92===r&&this.regexp_eatRegExpUnicodeEscapeSequence(e,s)&&(r=e.lastIntValue),function(e){return u(e,!0)||36===e||95===e||8204===e||8205===e}(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)},Ne.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)},Ne.regexp_eatBackReference=function(e){var t=e.pos;if(this.regexp_eatDecimalEscape(e)){var s=e.lastIntValue;if(e.switchU)return s>e.maxBackReference&&(e.maxBackReference=s),!0;if(s<=e.numCapturingParens)return!0;e.pos=t}return!1},Ne.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},Ne.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)},Ne.regexp_eatCControlLetter=function(e){var t=e.pos;if(e.eat(99)){if(this.regexp_eatControlLetter(e))return!0;e.pos=t}return!1},Ne.regexp_eatZero=function(e){return 48===e.current()&&!Ve(e.lookahead())&&(e.lastIntValue=0,e.advance(),!0)},Ne.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)},Ne.regexp_eatControlLetter=function(e){var t=e.current();return!!je(t)&&(e.lastIntValue=t%32,e.advance(),!0)},Ne.regexp_eatRegExpUnicodeEscapeSequence=function(e,t){void 0===t&&(t=!1);var s,r=e.pos,i=t||e.switchU;if(e.eat(117)){if(this.regexp_eatFixedHexDigits(e,4)){var n=e.lastIntValue;if(i&&n>=55296&&n<=56319){var o=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*(n-55296)+(a-56320)+65536,!0}e.pos=o,e.lastIntValue=n}return!0}if(i&&e.eat(123)&&this.regexp_eatHexDigits(e)&&e.eat(125)&&((s=e.lastIntValue)>=0&&s<=1114111))return!0;i&&e.raise("Invalid unicode escape"),e.pos=r}return!1},Ne.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))},Ne.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};function qe(e){return je(e)||95===e}function He(e){return qe(e)||Ve(e)}function Ve(e){return e>=48&&e<=57}function ze(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function Fe(e){return e>=65&&e<=70?e-65+10:e>=97&&e<=102?e-97+10:e-48}function Ge(e){return e>=48&&e<=55}Ne.regexp_eatCharacterClassEscape=function(e){var t=e.current();if(function(e){return 100===e||68===e||115===e||83===e||119===e||87===e}(t))return e.lastIntValue=-1,e.advance(),1;var s=!1;if(e.switchU&&this.options.ecmaVersion>=9&&((s=80===t)||112===t)){var r;if(e.lastIntValue=-1,e.advance(),e.eat(123)&&(r=this.regexp_eatUnicodePropertyValueExpression(e))&&e.eat(125))return s&&2===r&&e.raise("Invalid property name"),r;e.raise("Invalid property name")}return 0},Ne.regexp_eatUnicodePropertyValueExpression=function(e){var t=e.pos;if(this.regexp_eatUnicodePropertyName(e)&&e.eat(61)){var s=e.lastStringValue;if(this.regexp_eatUnicodePropertyValue(e)){var r=e.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(e,s,r),1}}if(e.pos=t,this.regexp_eatLoneUnicodePropertyNameOrValue(e)){var i=e.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(e,i)}return 0},Ne.regexp_validateUnicodePropertyNameAndValue=function(e,t,s){T(e.unicodeProperties.nonBinary,t)||e.raise("Invalid property name"),e.unicodeProperties.nonBinary[t].test(s)||e.raise("Invalid property value")},Ne.regexp_validateUnicodePropertyNameOrValue=function(e,t){return e.unicodeProperties.binary.test(t)?1:e.switchV&&e.unicodeProperties.binaryOfStrings.test(t)?2:void e.raise("Invalid property name")},Ne.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue="";qe(t=e.current());)e.lastStringValue+=R(t),e.advance();return""!==e.lastStringValue},Ne.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue="";He(t=e.current());)e.lastStringValue+=R(t),e.advance();return""!==e.lastStringValue},Ne.regexp_eatLoneUnicodePropertyNameOrValue=function(e){return this.regexp_eatUnicodePropertyValue(e)},Ne.regexp_eatCharacterClass=function(e){if(e.eat(91)){var t=e.eat(94),s=this.regexp_classContents(e);return e.eat(93)||e.raise("Unterminated character class"),t&&2===s&&e.raise("Negated character class may contain strings"),!0}return!1},Ne.regexp_classContents=function(e){return 93===e.current()?1:e.switchV?this.regexp_classSetExpression(e):(this.regexp_nonEmptyClassRanges(e),1)},Ne.regexp_nonEmptyClassRanges=function(e){for(;this.regexp_eatClassAtom(e);){var t=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassAtom(e)){var s=e.lastIntValue;!e.switchU||-1!==t&&-1!==s||e.raise("Invalid character class"),-1!==t&&-1!==s&&t>s&&e.raise("Range out of order in character class")}}},Ne.regexp_eatClassAtom=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatClassEscape(e))return!0;if(e.switchU){var s=e.current();(99===s||Ge(s))&&e.raise("Invalid class escape"),e.raise("Invalid escape")}e.pos=t}var r=e.current();return 93!==r&&(e.lastIntValue=r,e.advance(),!0)},Ne.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)},Ne.regexp_classSetExpression=function(e){var t,s=1;if(this.regexp_eatClassSetRange(e));else if(t=this.regexp_eatClassSetOperand(e)){2===t&&(s=2);for(var r=e.pos;e.eatChars([38,38]);)38!==e.current()&&(t=this.regexp_eatClassSetOperand(e))?2!==t&&(s=1):e.raise("Invalid character in character class");if(r!==e.pos)return s;for(;e.eatChars([45,45]);)this.regexp_eatClassSetOperand(e)||e.raise("Invalid character in character class");if(r!==e.pos)return s}else e.raise("Invalid character in character class");for(;;)if(!this.regexp_eatClassSetRange(e)){if(!(t=this.regexp_eatClassSetOperand(e)))return s;2===t&&(s=2)}},Ne.regexp_eatClassSetRange=function(e){var t=e.pos;if(this.regexp_eatClassSetCharacter(e)){var s=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassSetCharacter(e)){var r=e.lastIntValue;return-1!==s&&-1!==r&&s>r&&e.raise("Range out of order in character class"),!0}e.pos=t}return!1},Ne.regexp_eatClassSetOperand=function(e){return this.regexp_eatClassSetCharacter(e)?1:this.regexp_eatClassStringDisjunction(e)||this.regexp_eatNestedClass(e)},Ne.regexp_eatNestedClass=function(e){var t=e.pos;if(e.eat(91)){var s=e.eat(94),r=this.regexp_classContents(e);if(e.eat(93))return s&&2===r&&e.raise("Negated character class may contain strings"),r;e.pos=t}if(e.eat(92)){var i=this.regexp_eatCharacterClassEscape(e);if(i)return i;e.pos=t}return null},Ne.regexp_eatClassStringDisjunction=function(e){var t=e.pos;if(e.eatChars([92,113])){if(e.eat(123)){var s=this.regexp_classStringDisjunctionContents(e);if(e.eat(125))return s}else e.raise("Invalid escape");e.pos=t}return null},Ne.regexp_classStringDisjunctionContents=function(e){for(var t=this.regexp_classString(e);e.eat(124);)2===this.regexp_classString(e)&&(t=2);return t},Ne.regexp_classString=function(e){for(var t=0;this.regexp_eatClassSetCharacter(e);)t++;return 1===t?1:2},Ne.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 s=e.current();return!(s<0||s===e.lookahead()&&function(e){return 33===e||e>=35&&e<=38||e>=42&&e<=44||46===e||e>=58&&e<=64||94===e||96===e||126===e}(s)||function(e){return 40===e||41===e||45===e||47===e||e>=91&&e<=93||e>=123&&e<=125}(s)||(e.advance(),e.lastIntValue=s,0))},Ne.regexp_eatClassSetReservedPunctuator=function(e){var t=e.current();return!!function(e){return 33===e||35===e||37===e||38===e||44===e||45===e||e>=58&&e<=62||64===e||96===e||126===e}(t)&&(e.lastIntValue=t,e.advance(),!0)},Ne.regexp_eatClassControlLetter=function(e){var t=e.current();return!(!Ve(t)&&95!==t||(e.lastIntValue=t%32,e.advance(),0))},Ne.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},Ne.regexp_eatDecimalDigits=function(e){var t=e.pos,s=0;for(e.lastIntValue=0;Ve(s=e.current());)e.lastIntValue=10*e.lastIntValue+(s-48),e.advance();return e.pos!==t},Ne.regexp_eatHexDigits=function(e){var t=e.pos,s=0;for(e.lastIntValue=0;ze(s=e.current());)e.lastIntValue=16*e.lastIntValue+Fe(s),e.advance();return e.pos!==t},Ne.regexp_eatLegacyOctalEscapeSequence=function(e){if(this.regexp_eatOctalDigit(e)){var t=e.lastIntValue;if(this.regexp_eatOctalDigit(e)){var s=e.lastIntValue;t<=3&&this.regexp_eatOctalDigit(e)?e.lastIntValue=64*t+8*s+e.lastIntValue:e.lastIntValue=8*t+s}else e.lastIntValue=t;return!0}return!1},Ne.regexp_eatOctalDigit=function(e){var t=e.current();return Ge(t)?(e.lastIntValue=t-48,e.advance(),!0):(e.lastIntValue=0,!1)},Ne.regexp_eatFixedHexDigits=function(e,t){var s=e.pos;e.lastIntValue=0;for(var r=0;r<t;++r){var i=e.current();if(!ze(i))return e.pos=s,!1;e.lastIntValue=16*e.lastIntValue+Fe(i),e.advance()}return!0};var $e=function(e){this.type=e.type,this.value=e.value,this.start=e.start,this.end=e.end,e.options.locations&&(this.loc=new U(e,e.startLoc,e.endLoc)),e.options.ranges&&(this.range=[e.start,e.end])},Ke=F.prototype;function We(e){return"function"!=typeof BigInt?null:BigInt(e.replace(/_/g,""))}Ke.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 $e(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()},Ke.getToken=function(){return this.next(),new $e(this)},"undefined"!=typeof Symbol&&(Ke[Symbol.iterator]=function(){var e=this;return{next:function(){var t=e.getToken();return{done:t.type===w.eof,value:t}}}}),Ke.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(w.eof):e.override?e.override(this):void this.readToken(this.fullCharCodeAtPos())},Ke.readToken=function(e){return d(e,this.options.ecmaVersion>=6)||92===e?this.readWord():this.getTokenFromCode(e)},Ke.fullCharCodeAt=function(e){var t=this.input.charCodeAt(e);if(t<=55295||t>=56320)return t;var s=this.input.charCodeAt(e+1);return s<=56319||s>=57344?t:(t<<10)+s-56613888},Ke.fullCharCodeAtPos=function(){return this.fullCharCodeAt(this.pos)},Ke.skipBlockComment=function(){var e=this.options.onComment&&this.curPosition(),t=this.pos,s=this.input.indexOf("*/",this.pos+=2);if(-1===s&&this.raise(this.pos-2,"Unterminated comment"),this.pos=s+2,this.options.locations)for(var r=void 0,i=t;(r=S(this.input,i,this.pos))>-1;)++this.curLine,i=this.lineStart=r;this.options.onComment&&this.options.onComment(!0,this.input.slice(t+2,s),t,this.pos,e,this.curPosition())},Ke.skipLineComment=function(e){for(var t=this.pos,s=this.options.onComment&&this.curPosition(),r=this.input.charCodeAt(this.pos+=e);this.pos<this.input.length&&!E(r);)r=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(t+e,this.pos),t,this.pos,s,this.curPosition())},Ke.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&&k.test(String.fromCharCode(e))))break e;++this.pos}}},Ke.finishToken=function(e,t){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var s=this.type;this.type=e,this.value=t,this.updateContext(s)},Ke.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(w.ellipsis)):(++this.pos,this.finishToken(w.dot))},Ke.readToken_slash=function(){var e=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):61===e?this.finishOp(w.assign,2):this.finishOp(w.slash,1)},Ke.readToken_mult_modulo_exp=function(e){var t=this.input.charCodeAt(this.pos+1),s=1,r=42===e?w.star:w.modulo;return this.options.ecmaVersion>=7&&42===e&&42===t&&(++s,r=w.starstar,t=this.input.charCodeAt(this.pos+2)),61===t?this.finishOp(w.assign,s+1):this.finishOp(r,s)},Ke.readToken_pipe_amp=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?this.options.ecmaVersion>=12&&61===this.input.charCodeAt(this.pos+2)?this.finishOp(w.assign,3):this.finishOp(124===e?w.logicalOR:w.logicalAND,2):61===t?this.finishOp(w.assign,2):this.finishOp(124===e?w.bitwiseOR:w.bitwiseAND,1)},Ke.readToken_caret=function(){return 61===this.input.charCodeAt(this.pos+1)?this.finishOp(w.assign,2):this.finishOp(w.bitwiseXOR,1)},Ke.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&&!x.test(this.input.slice(this.lastTokEnd,this.pos))?this.finishOp(w.incDec,2):(this.skipLineComment(3),this.skipSpace(),this.nextToken()):61===t?this.finishOp(w.assign,2):this.finishOp(w.plusMin,1)},Ke.readToken_lt_gt=function(e){var t=this.input.charCodeAt(this.pos+1),s=1;return t===e?(s=62===e&&62===this.input.charCodeAt(this.pos+2)?3:2,61===this.input.charCodeAt(this.pos+s)?this.finishOp(w.assign,s+1):this.finishOp(w.bitShift,s)):33!==t||60!==e||this.inModule||45!==this.input.charCodeAt(this.pos+2)||45!==this.input.charCodeAt(this.pos+3)?(61===t&&(s=2),this.finishOp(w.relational,s)):(this.skipLineComment(4),this.skipSpace(),this.nextToken())},Ke.readToken_eq_excl=function(e){var t=this.input.charCodeAt(this.pos+1);return 61===t?this.finishOp(w.equality,61===this.input.charCodeAt(this.pos+2)?3:2):61===e&&62===t&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(w.arrow)):this.finishOp(61===e?w.eq:w.prefix,1)},Ke.readToken_question=function(){var e=this.options.ecmaVersion;if(e>=11){var t=this.input.charCodeAt(this.pos+1);if(46===t){var s=this.input.charCodeAt(this.pos+2);if(s<48||s>57)return this.finishOp(w.questionDot,2)}if(63===t)return e>=12&&61===this.input.charCodeAt(this.pos+2)?this.finishOp(w.assign,3):this.finishOp(w.coalesce,2)}return this.finishOp(w.question,1)},Ke.readToken_numberSign=function(){var e=35;if(this.options.ecmaVersion>=13&&(++this.pos,d(e=this.fullCharCodeAtPos(),!0)||92===e))return this.finishToken(w.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+R(e)+"'")},Ke.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(w.parenL);case 41:return++this.pos,this.finishToken(w.parenR);case 59:return++this.pos,this.finishToken(w.semi);case 44:return++this.pos,this.finishToken(w.comma);case 91:return++this.pos,this.finishToken(w.bracketL);case 93:return++this.pos,this.finishToken(w.bracketR);case 123:return++this.pos,this.finishToken(w.braceL);case 125:return++this.pos,this.finishToken(w.braceR);case 58:return++this.pos,this.finishToken(w.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(w.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(w.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+R(e)+"'")},Ke.finishOp=function(e,t){var s=this.input.slice(this.pos,this.pos+t);return this.pos+=t,this.finishToken(e,s)},Ke.readRegexp=function(){for(var e,t,s=this.pos;;){this.pos>=this.input.length&&this.raise(s,"Unterminated regular expression");var r=this.input.charAt(this.pos);if(x.test(r)&&this.raise(s,"Unterminated regular expression"),e)e=!1;else{if("["===r)t=!0;else if("]"===r&&t)t=!1;else if("/"===r&&!t)break;e="\\"===r}++this.pos}var i=this.input.slice(s,this.pos);++this.pos;var n=this.pos,o=this.readWord1();this.containsEsc&&this.unexpected(n);var a=this.regexpState||(this.regexpState=new Ue(this));a.reset(s,i,o),this.validateRegExpFlags(a),this.validateRegExpPattern(a);var h=null;try{h=new RegExp(i,o)}catch(e){}return this.finishToken(w.regexp,{pattern:i,flags:o,value:h})},Ke.readInt=function(e,t,s){for(var r=this.options.ecmaVersion>=12&&void 0===t,i=s&&48===this.input.charCodeAt(this.pos),n=this.pos,o=0,a=0,h=0,l=t??1/0;h<l;++h,++this.pos){var c=this.input.charCodeAt(this.pos),d=void 0;if(r&&95===c)i&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed in legacy octal numeric literals"),95===a&&this.raiseRecoverable(this.pos,"Numeric separator must be exactly one underscore"),0===h&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed at the first of digits"),a=c;else{if((d=c>=97?c-97+10:c>=65?c-65+10:c>=48&&c<=57?c-48:1/0)>=e)break;a=c,o=o*e+d}}return r&&95===a&&this.raiseRecoverable(this.pos-1,"Numeric separator is not allowed at the last of digits"),this.pos===n||null!=t&&this.pos-n!==t?null:o},Ke.readRadixNumber=function(e){var t=this.pos;this.pos+=2;var s=this.readInt(e);return null==s&&this.raise(this.start+2,"Expected number in radix "+e),this.options.ecmaVersion>=11&&110===this.input.charCodeAt(this.pos)?(s=We(this.input.slice(t,this.pos)),++this.pos):d(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(w.num,s)},Ke.readNumber=function(e){var t=this.pos;e||null!==this.readInt(10,void 0,!0)||this.raise(t,"Invalid number");var s=this.pos-t>=2&&48===this.input.charCodeAt(t);s&&this.strict&&this.raise(t,"Invalid number");var r=this.input.charCodeAt(this.pos);if(!s&&!e&&this.options.ecmaVersion>=11&&110===r){var i=We(this.input.slice(t,this.pos));return++this.pos,d(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(w.num,i)}s&&/[89]/.test(this.input.slice(t,this.pos))&&(s=!1),46!==r||s||(++this.pos,this.readInt(10),r=this.input.charCodeAt(this.pos)),69!==r&&101!==r||s||(43!==(r=this.input.charCodeAt(++this.pos))&&45!==r||++this.pos,null===this.readInt(10)&&this.raise(t,"Invalid number")),d(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var n,o=(n=this.input.slice(t,this.pos),s?parseInt(n,8):parseFloat(n.replace(/_/g,"")));return this.finishToken(w.num,o)},Ke.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},Ke.readString=function(e){for(var t="",s=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");var r=this.input.charCodeAt(this.pos);if(r===e)break;92===r?(t+=this.input.slice(s,this.pos),t+=this.readEscapedChar(!1),s=this.pos):8232===r||8233===r?(this.options.ecmaVersion<10&&this.raise(this.start,"Unterminated string constant"),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(E(r)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return t+=this.input.slice(s,this.pos++),this.finishToken(w.string,t)};var Ye={};Ke.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e!==Ye)throw e;this.readInvalidTemplateToken()}this.inTemplateElement=!1},Ke.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw Ye;this.raise(e,t)},Ke.readTmplToken=function(){for(var e="",t=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated template");var s=this.input.charCodeAt(this.pos);if(96===s||36===s&&123===this.input.charCodeAt(this.pos+1))return this.pos!==this.start||this.type!==w.template&&this.type!==w.invalidTemplate?(e+=this.input.slice(t,this.pos),this.finishToken(w.template,e)):36===s?(this.pos+=2,this.finishToken(w.dollarBraceL)):(++this.pos,this.finishToken(w.backQuote));if(92===s)e+=this.input.slice(t,this.pos),e+=this.readEscapedChar(!0),t=this.pos;else if(E(s)){switch(e+=this.input.slice(t,this.pos),++this.pos,s){case 13:10===this.input.charCodeAt(this.pos)&&++this.pos;case 10:e+="\n";break;default:e+=String.fromCharCode(s)}this.options.locations&&(++this.curLine,this.lineStart=this.pos),t=this.pos}else++this.pos}},Ke.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(w.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")},Ke.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 R(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 s=this.pos-1;this.invalidStringToken(s,"Invalid escape sequence in template string")}default:if(t>=48&&t<=55){var r=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],i=parseInt(r,8);return i>255&&(r=r.slice(0,-1),i=parseInt(r,8)),this.pos+=r.length-1,t=this.input.charCodeAt(this.pos),"0"===r&&56!==t&&57!==t||!this.strict&&!e||this.invalidStringToken(this.pos-1-r.length,e?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(i)}return E(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(t)}},Ke.readHexChar=function(e){var t=this.pos,s=this.readInt(16,e);return null===s&&this.invalidStringToken(t,"Bad character escape sequence"),s},Ke.readWord1=function(){this.containsEsc=!1;for(var e="",t=!0,s=this.pos,r=this.options.ecmaVersion>=6;this.pos<this.input.length;){var i=this.fullCharCodeAtPos();if(u(i,r))this.pos+=i<=65535?1:2;else{if(92!==i)break;this.containsEsc=!0,e+=this.input.slice(s,this.pos);var n=this.pos;117!==this.input.charCodeAt(++this.pos)&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var o=this.readCodePoint();(t?d:u)(o,r)||this.invalidStringToken(n,"Invalid Unicode escape"),e+=R(o),s=this.pos}t=!1}return e+this.input.slice(s,this.pos)},Ke.readWord=function(){var e=this.readWord1(),t=w.name;return this.keywords.test(e)&&(t=y[e]),this.finishToken(t,e)};var Je="8.19.0";F.acorn={Parser:F,version:Je,defaultOptions:D,Position:O,SourceLocation:U,getLineInfo:B,Node:me,TokenType:p,tokTypes:w,keywordTypes:y,TokContext:ne,tokContexts:oe,isIdentifierChar:u,isIdentifierStart:d,Token:$e,isNewLine:E,lineBreak:x,lineBreakG:b,nonASCIIwhitespace:k},e.Node=me,e.Parser=F,e.Position=O,e.SourceLocation=U,e.TokContext=ne,e.Token=$e,e.TokenType=p,e.defaultOptions=D,e.getLineInfo=B,e.isIdentifierChar=u,e.isIdentifierStart=d,e.isNewLine=E,e.keywordTypes=y,e.lineBreak=x,e.lineBreakG=b,e.nonASCIIwhitespace=k,e.parse=function(e,t){return F.parse(e,t)},e.parseExpressionAt=function(e,t,s){return F.parseExpressionAt(e,t,s)},e.tokContexts=oe,e.tokTypes=w,e.tokenizer=function(e,t){return F.tokenizer(e,t)},e.version=Je}(t)},7526(e,t){"use strict";t.toByteArray=function(e){var t,s,n=function(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var s=e.indexOf("=");return-1===s&&(s=t),[s,s===t?0:4-s%4]}(e),o=n[0],a=n[1],h=new i(function(e,t,s){return 3*(t+s)/4-s}(0,o,a)),l=0,c=a>0?o-4:o;for(s=0;s<c;s+=4)t=r[e.charCodeAt(s)]<<18|r[e.charCodeAt(s+1)]<<12|r[e.charCodeAt(s+2)]<<6|r[e.charCodeAt(s+3)],h[l++]=t>>16&255,h[l++]=t>>8&255,h[l++]=255&t;return 2===a&&(t=r[e.charCodeAt(s)]<<2|r[e.charCodeAt(s+1)]>>4,h[l++]=255&t),1===a&&(t=r[e.charCodeAt(s)]<<10|r[e.charCodeAt(s+1)]<<4|r[e.charCodeAt(s+2)]>>2,h[l++]=t>>8&255,h[l++]=255&t),h},t.fromByteArray=function(e){for(var t,r=e.length,i=r%3,n=[],o=16383,a=0,l=r-i;a<l;a+=o)n.push(h(e,a,a+o>l?l:a+o));return 1===i?(t=e[r-1],n.push(s[t>>2]+s[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],n.push(s[t>>10]+s[t>>4&63]+s[t<<2&63]+"=")),n.join("")};for(var s=[],r=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0;o<64;++o)s[o]=n[o],r[n.charCodeAt(o)]=o;function a(e){return s[e>>18&63]+s[e>>12&63]+s[e>>6&63]+s[63&e]}function h(e,t,s){for(var r,i=[],n=t;n<s;n+=3)r=(e[n]<<16&16711680)+(e[n+1]<<8&65280)+(255&e[n+2]),i.push(a(r));return i.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},8287(e,t,s){"use strict";const r=s(7526),i=s(251),n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.hp=h,t.IS=50;const o=2147483647;function a(e){if(e>o)throw new RangeError('The value "'+e+'" is invalid for option "size"');const t=new Uint8Array(e);return Object.setPrototypeOf(t,h.prototype),t}function h(e,t,s){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return d(e)}return l(e,t,s)}function l(e,t,s){if("string"==typeof e)return function(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!h.isEncoding(t))throw new TypeError("Unknown encoding: "+t);const s=0|m(e,t);let r=a(s);const i=r.write(e,t);return i!==s&&(r=r.slice(0,i)),r}(e,t);if(ArrayBuffer.isView(e))return function(e){if(Y(e,Uint8Array)){const t=new Uint8Array(e);return p(t.buffer,t.byteOffset,t.byteLength)}return u(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(Y(e,ArrayBuffer)||e&&Y(e.buffer,ArrayBuffer))return p(e,t,s);if("undefined"!=typeof SharedArrayBuffer&&(Y(e,SharedArrayBuffer)||e&&Y(e.buffer,SharedArrayBuffer)))return p(e,t,s);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');const r=e.valueOf&&e.valueOf();if(null!=r&&r!==e)return h.from(r,t,s);const i=function(e){if(h.isBuffer(e)){const t=0|f(e.length),s=a(t);return 0===s.length||e.copy(s,0,0,t),s}return void 0!==e.length?"number"!=typeof e.length||J(e.length)?a(0):u(e):"Buffer"===e.type&&Array.isArray(e.data)?u(e.data):void 0}(e);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return h.from(e[Symbol.toPrimitive]("string"),t,s);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function c(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function d(e){return c(e),a(e<0?0:0|f(e))}function u(e){const t=e.length<0?0:0|f(e.length),s=a(t);for(let r=0;r<t;r+=1)s[r]=255&e[r];return s}function p(e,t,s){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(s||0))throw new RangeError('"length" is outside of buffer bounds');let r;return r=void 0===t&&void 0===s?new Uint8Array(e):void 0===s?new Uint8Array(e,t):new Uint8Array(e,t,s),Object.setPrototypeOf(r,h.prototype),r}function f(e){if(e>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|e}function m(e,t){if(h.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||Y(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);const s=e.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===s)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return s;case"utf8":case"utf-8":return $(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*s;case"hex":return s>>>1;case"base64":return K(e).length;default:if(i)return r?-1:$(e).length;t=(""+t).toLowerCase(),i=!0}}function g(e,t,s){let r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===s||s>this.length)&&(s=this.length),s<=0)return"";if((s>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return P(this,t,s);case"utf8":case"utf-8":return C(this,t,s);case"ascii":return I(this,t,s);case"latin1":case"binary":return T(this,t,s);case"base64":return _(this,t,s);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L(this,t,s);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function y(e,t,s){const r=e[t];e[t]=e[s],e[s]=r}function v(e,t,s,r,i){if(0===e.length)return-1;if("string"==typeof s?(r=s,s=0):s>2147483647?s=2147483647:s<-2147483648&&(s=-2147483648),J(s=+s)&&(s=i?0:e.length-1),s<0&&(s=e.length+s),s>=e.length){if(i)return-1;s=e.length-1}else if(s<0){if(!i)return-1;s=0}if("string"==typeof t&&(t=h.from(t,r)),h.isBuffer(t))return 0===t.length?-1:w(e,t,s,r,i);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,s):Uint8Array.prototype.lastIndexOf.call(e,t,s):w(e,[t],s,r,i);throw new TypeError("val must be string, number or Buffer")}function w(e,t,s,r,i){let n,o=1,a=e.length,h=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;o=2,a/=2,h/=2,s/=2}function l(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(i){let r=-1;for(n=s;n<a;n++)if(l(e,n)===l(t,-1===r?0:n-r)){if(-1===r&&(r=n),n-r+1===h)return r*o}else-1!==r&&(n-=n-r),r=-1}else for(s+h>a&&(s=a-h),n=s;n>=0;n--){let s=!0;for(let r=0;r<h;r++)if(l(e,n+r)!==l(t,r)){s=!1;break}if(s)return n}return-1}function x(e,t,s,r){s=Number(s)||0;const i=e.length-s;r?(r=Number(r))>i&&(r=i):r=i;const n=t.length;let o;for(r>n/2&&(r=n/2),o=0;o<r;++o){const r=parseInt(t.substr(2*o,2),16);if(J(r))return o;e[s+o]=r}return o}function b(e,t,s,r){return W($(t,e.length-s),e,s,r)}function E(e,t,s,r){return W(function(e){const t=[];for(let s=0;s<e.length;++s)t.push(255&e.charCodeAt(s));return t}(t),e,s,r)}function S(e,t,s,r){return W(K(t),e,s,r)}function k(e,t,s,r){return W(function(e,t){let s,r,i;const n=[];for(let o=0;o<e.length&&!((t-=2)<0);++o)s=e.charCodeAt(o),r=s>>8,i=s%256,n.push(i),n.push(r);return n}(t,e.length-s),e,s,r)}function _(e,t,s){return 0===t&&s===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,s))}function C(e,t,s){s=Math.min(e.length,s);const r=[];let i=t;for(;i<s;){const t=e[i];let n=null,o=t>239?4:t>223?3:t>191?2:1;if(i+o<=s){let s,r,a,h;switch(o){case 1:t<128&&(n=t);break;case 2:s=e[i+1],128==(192&s)&&(h=(31&t)<<6|63&s,h>127&&(n=h));break;case 3:s=e[i+1],r=e[i+2],128==(192&s)&&128==(192&r)&&(h=(15&t)<<12|(63&s)<<6|63&r,h>2047&&(h<55296||h>57343)&&(n=h));break;case 4:s=e[i+1],r=e[i+2],a=e[i+3],128==(192&s)&&128==(192&r)&&128==(192&a)&&(h=(15&t)<<18|(63&s)<<12|(63&r)<<6|63&a,h>65535&&h<1114112&&(n=h))}}null===n?(n=65533,o=1):n>65535&&(n-=65536,r.push(n>>>10&1023|55296),n=56320|1023&n),r.push(n),i+=o}return function(e){const t=e.length;if(t<=A)return String.fromCharCode.apply(String,e);let s="",r=0;for(;r<t;)s+=String.fromCharCode.apply(String,e.slice(r,r+=A));return s}(r)}h.TYPED_ARRAY_SUPPORT=function(){try{const e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}(),h.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(h.prototype,"parent",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.buffer}}),Object.defineProperty(h.prototype,"offset",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.byteOffset}}),h.poolSize=8192,h.from=function(e,t,s){return l(e,t,s)},Object.setPrototypeOf(h.prototype,Uint8Array.prototype),Object.setPrototypeOf(h,Uint8Array),h.alloc=function(e,t,s){return function(e,t,s){return c(e),e<=0?a(e):void 0!==t?"string"==typeof s?a(e).fill(t,s):a(e).fill(t):a(e)}(e,t,s)},h.allocUnsafe=function(e){return d(e)},h.allocUnsafeSlow=function(e){return d(e)},h.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==h.prototype},h.compare=function(e,t){if(Y(e,Uint8Array)&&(e=h.from(e,e.offset,e.byteLength)),Y(t,Uint8Array)&&(t=h.from(t,t.offset,t.byteLength)),!h.isBuffer(e)||!h.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let s=e.length,r=t.length;for(let i=0,n=Math.min(s,r);i<n;++i)if(e[i]!==t[i]){s=e[i],r=t[i];break}return s<r?-1:r<s?1:0},h.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},h.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return h.alloc(0);let s;if(void 0===t)for(t=0,s=0;s<e.length;++s)t+=e[s].length;const r=h.allocUnsafe(t);let i=0;for(s=0;s<e.length;++s){let t=e[s];if(Y(t,Uint8Array))i+t.length>r.length?(h.isBuffer(t)||(t=h.from(t)),t.copy(r,i)):Uint8Array.prototype.set.call(r,t,i);else{if(!h.isBuffer(t))throw new TypeError('"list" argument must be an Array of Buffers');t.copy(r,i)}i+=t.length}return r},h.byteLength=m,h.prototype._isBuffer=!0,h.prototype.swap16=function(){const e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)y(this,t,t+1);return this},h.prototype.swap32=function(){const e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)y(this,t,t+3),y(this,t+1,t+2);return this},h.prototype.swap64=function(){const e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)y(this,t,t+7),y(this,t+1,t+6),y(this,t+2,t+5),y(this,t+3,t+4);return this},h.prototype.toString=function(){const e=this.length;return 0===e?"":0===arguments.length?C(this,0,e):g.apply(this,arguments)},h.prototype.toLocaleString=h.prototype.toString,h.prototype.equals=function(e){if(!h.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===h.compare(this,e)},h.prototype.inspect=function(){let e="";const s=t.IS;return e=this.toString("hex",0,s).replace(/(.{2})/g,"$1 ").trim(),this.length>s&&(e+=" ... "),"<Buffer "+e+">"},n&&(h.prototype[n]=h.prototype.inspect),h.prototype.compare=function(e,t,s,r,i){if(Y(e,Uint8Array)&&(e=h.from(e,e.offset,e.byteLength)),!h.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===s&&(s=e?e.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),t<0||s>e.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&t>=s)return 0;if(r>=i)return-1;if(t>=s)return 1;if(this===e)return 0;let n=(i>>>=0)-(r>>>=0),o=(s>>>=0)-(t>>>=0);const a=Math.min(n,o),l=this.slice(r,i),c=e.slice(t,s);for(let e=0;e<a;++e)if(l[e]!==c[e]){n=l[e],o=c[e];break}return n<o?-1:o<n?1:0},h.prototype.includes=function(e,t,s){return-1!==this.indexOf(e,t,s)},h.prototype.indexOf=function(e,t,s){return v(this,e,t,s,!0)},h.prototype.lastIndexOf=function(e,t,s){return v(this,e,t,s,!1)},h.prototype.write=function(e,t,s,r){if(void 0===t)r="utf8",s=this.length,t=0;else if(void 0===s&&"string"==typeof t)r=t,s=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(s)?(s>>>=0,void 0===r&&(r="utf8")):(r=s,s=void 0)}const i=this.length-t;if((void 0===s||s>i)&&(s=i),e.length>0&&(s<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");let n=!1;for(;;)switch(r){case"hex":return x(this,e,t,s);case"utf8":case"utf-8":return b(this,e,t,s);case"ascii":case"latin1":case"binary":return E(this,e,t,s);case"base64":return S(this,e,t,s);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,e,t,s);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),n=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const A=4096;function I(e,t,s){let r="";s=Math.min(e.length,s);for(let i=t;i<s;++i)r+=String.fromCharCode(127&e[i]);return r}function T(e,t,s){let r="";s=Math.min(e.length,s);for(let i=t;i<s;++i)r+=String.fromCharCode(e[i]);return r}function P(e,t,s){const r=e.length;(!t||t<0)&&(t=0),(!s||s<0||s>r)&&(s=r);let i="";for(let r=t;r<s;++r)i+=X[e[r]];return i}function L(e,t,s){const r=e.slice(t,s);let i="";for(let e=0;e<r.length-1;e+=2)i+=String.fromCharCode(r[e]+256*r[e+1]);return i}function M(e,t,s){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>s)throw new RangeError("Trying to access beyond buffer length")}function R(e,t,s,r,i,n){if(!h.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<n)throw new RangeError('"value" argument is out of bounds');if(s+r>e.length)throw new RangeError("Index out of range")}function N(e,t,s,r,i){V(t,r,i,e,s,7);let n=Number(t&BigInt(4294967295));e[s++]=n,n>>=8,e[s++]=n,n>>=8,e[s++]=n,n>>=8,e[s++]=n;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[s++]=o,o>>=8,e[s++]=o,o>>=8,e[s++]=o,o>>=8,e[s++]=o,s}function O(e,t,s,r,i){V(t,r,i,e,s,7);let n=Number(t&BigInt(4294967295));e[s+7]=n,n>>=8,e[s+6]=n,n>>=8,e[s+5]=n,n>>=8,e[s+4]=n;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[s+3]=o,o>>=8,e[s+2]=o,o>>=8,e[s+1]=o,o>>=8,e[s]=o,s+8}function U(e,t,s,r,i,n){if(s+r>e.length)throw new RangeError("Index out of range");if(s<0)throw new RangeError("Index out of range")}function B(e,t,s,r,n){return t=+t,s>>>=0,n||U(e,0,s,4),i.write(e,t,s,r,23,4),s+4}function D(e,t,s,r,n){return t=+t,s>>>=0,n||U(e,0,s,8),i.write(e,t,s,r,52,8),s+8}h.prototype.slice=function(e,t){const s=this.length;(e=~~e)<0?(e+=s)<0&&(e=0):e>s&&(e=s),(t=void 0===t?s:~~t)<0?(t+=s)<0&&(t=0):t>s&&(t=s),t<e&&(t=e);const r=this.subarray(e,t);return Object.setPrototypeOf(r,h.prototype),r},h.prototype.readUintLE=h.prototype.readUIntLE=function(e,t,s){e>>>=0,t>>>=0,s||M(e,t,this.length);let r=this[e],i=1,n=0;for(;++n<t&&(i*=256);)r+=this[e+n]*i;return r},h.prototype.readUintBE=h.prototype.readUIntBE=function(e,t,s){e>>>=0,t>>>=0,s||M(e,t,this.length);let r=this[e+--t],i=1;for(;t>0&&(i*=256);)r+=this[e+--t]*i;return r},h.prototype.readUint8=h.prototype.readUInt8=function(e,t){return e>>>=0,t||M(e,1,this.length),this[e]},h.prototype.readUint16LE=h.prototype.readUInt16LE=function(e,t){return e>>>=0,t||M(e,2,this.length),this[e]|this[e+1]<<8},h.prototype.readUint16BE=h.prototype.readUInt16BE=function(e,t){return e>>>=0,t||M(e,2,this.length),this[e]<<8|this[e+1]},h.prototype.readUint32LE=h.prototype.readUInt32LE=function(e,t){return e>>>=0,t||M(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},h.prototype.readUint32BE=h.prototype.readUInt32BE=function(e,t){return e>>>=0,t||M(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},h.prototype.readBigUInt64LE=Z(function(e){z(e>>>=0,"offset");const t=this[e],s=this[e+7];void 0!==t&&void 0!==s||F(e,this.length-8);const r=t+256*this[++e]+65536*this[++e]+this[++e]*2**24,i=this[++e]+256*this[++e]+65536*this[++e]+s*2**24;return BigInt(r)+(BigInt(i)<<BigInt(32))}),h.prototype.readBigUInt64BE=Z(function(e){z(e>>>=0,"offset");const t=this[e],s=this[e+7];void 0!==t&&void 0!==s||F(e,this.length-8);const r=t*2**24+65536*this[++e]+256*this[++e]+this[++e],i=this[++e]*2**24+65536*this[++e]+256*this[++e]+s;return(BigInt(r)<<BigInt(32))+BigInt(i)}),h.prototype.readIntLE=function(e,t,s){e>>>=0,t>>>=0,s||M(e,t,this.length);let r=this[e],i=1,n=0;for(;++n<t&&(i*=256);)r+=this[e+n]*i;return i*=128,r>=i&&(r-=Math.pow(2,8*t)),r},h.prototype.readIntBE=function(e,t,s){e>>>=0,t>>>=0,s||M(e,t,this.length);let r=t,i=1,n=this[e+--r];for(;r>0&&(i*=256);)n+=this[e+--r]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*t)),n},h.prototype.readInt8=function(e,t){return e>>>=0,t||M(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},h.prototype.readInt16LE=function(e,t){e>>>=0,t||M(e,2,this.length);const s=this[e]|this[e+1]<<8;return 32768&s?4294901760|s:s},h.prototype.readInt16BE=function(e,t){e>>>=0,t||M(e,2,this.length);const s=this[e+1]|this[e]<<8;return 32768&s?4294901760|s:s},h.prototype.readInt32LE=function(e,t){return e>>>=0,t||M(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},h.prototype.readInt32BE=function(e,t){return e>>>=0,t||M(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},h.prototype.readBigInt64LE=Z(function(e){z(e>>>=0,"offset");const t=this[e],s=this[e+7];void 0!==t&&void 0!==s||F(e,this.length-8);const r=this[e+4]+256*this[e+5]+65536*this[e+6]+(s<<24);return(BigInt(r)<<BigInt(32))+BigInt(t+256*this[++e]+65536*this[++e]+this[++e]*2**24)}),h.prototype.readBigInt64BE=Z(function(e){z(e>>>=0,"offset");const t=this[e],s=this[e+7];void 0!==t&&void 0!==s||F(e,this.length-8);const r=(t<<24)+65536*this[++e]+256*this[++e]+this[++e];return(BigInt(r)<<BigInt(32))+BigInt(this[++e]*2**24+65536*this[++e]+256*this[++e]+s)}),h.prototype.readFloatLE=function(e,t){return e>>>=0,t||M(e,4,this.length),i.read(this,e,!0,23,4)},h.prototype.readFloatBE=function(e,t){return e>>>=0,t||M(e,4,this.length),i.read(this,e,!1,23,4)},h.prototype.readDoubleLE=function(e,t){return e>>>=0,t||M(e,8,this.length),i.read(this,e,!0,52,8)},h.prototype.readDoubleBE=function(e,t){return e>>>=0,t||M(e,8,this.length),i.read(this,e,!1,52,8)},h.prototype.writeUintLE=h.prototype.writeUIntLE=function(e,t,s,r){e=+e,t>>>=0,s>>>=0,r||R(this,e,t,s,Math.pow(2,8*s)-1,0);let i=1,n=0;for(this[t]=255&e;++n<s&&(i*=256);)this[t+n]=e/i&255;return t+s},h.prototype.writeUintBE=h.prototype.writeUIntBE=function(e,t,s,r){e=+e,t>>>=0,s>>>=0,r||R(this,e,t,s,Math.pow(2,8*s)-1,0);let i=s-1,n=1;for(this[t+i]=255&e;--i>=0&&(n*=256);)this[t+i]=e/n&255;return t+s},h.prototype.writeUint8=h.prototype.writeUInt8=function(e,t,s){return e=+e,t>>>=0,s||R(this,e,t,1,255,0),this[t]=255&e,t+1},h.prototype.writeUint16LE=h.prototype.writeUInt16LE=function(e,t,s){return e=+e,t>>>=0,s||R(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},h.prototype.writeUint16BE=h.prototype.writeUInt16BE=function(e,t,s){return e=+e,t>>>=0,s||R(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},h.prototype.writeUint32LE=h.prototype.writeUInt32LE=function(e,t,s){return e=+e,t>>>=0,s||R(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},h.prototype.writeUint32BE=h.prototype.writeUInt32BE=function(e,t,s){return e=+e,t>>>=0,s||R(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},h.prototype.writeBigUInt64LE=Z(function(e,t=0){return N(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),h.prototype.writeBigUInt64BE=Z(function(e,t=0){return O(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),h.prototype.writeIntLE=function(e,t,s,r){if(e=+e,t>>>=0,!r){const r=Math.pow(2,8*s-1);R(this,e,t,s,r-1,-r)}let i=0,n=1,o=0;for(this[t]=255&e;++i<s&&(n*=256);)e<0&&0===o&&0!==this[t+i-1]&&(o=1),this[t+i]=(e/n|0)-o&255;return t+s},h.prototype.writeIntBE=function(e,t,s,r){if(e=+e,t>>>=0,!r){const r=Math.pow(2,8*s-1);R(this,e,t,s,r-1,-r)}let i=s-1,n=1,o=0;for(this[t+i]=255&e;--i>=0&&(n*=256);)e<0&&0===o&&0!==this[t+i+1]&&(o=1),this[t+i]=(e/n|0)-o&255;return t+s},h.prototype.writeInt8=function(e,t,s){return e=+e,t>>>=0,s||R(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},h.prototype.writeInt16LE=function(e,t,s){return e=+e,t>>>=0,s||R(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},h.prototype.writeInt16BE=function(e,t,s){return e=+e,t>>>=0,s||R(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},h.prototype.writeInt32LE=function(e,t,s){return e=+e,t>>>=0,s||R(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},h.prototype.writeInt32BE=function(e,t,s){return e=+e,t>>>=0,s||R(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},h.prototype.writeBigInt64LE=Z(function(e,t=0){return N(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),h.prototype.writeBigInt64BE=Z(function(e,t=0){return O(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),h.prototype.writeFloatLE=function(e,t,s){return B(this,e,t,!0,s)},h.prototype.writeFloatBE=function(e,t,s){return B(this,e,t,!1,s)},h.prototype.writeDoubleLE=function(e,t,s){return D(this,e,t,!0,s)},h.prototype.writeDoubleBE=function(e,t,s){return D(this,e,t,!1,s)},h.prototype.copy=function(e,t,s,r){if(!h.isBuffer(e))throw new TypeError("argument should be a Buffer");if(s||(s=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<s&&(r=s),r===s)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(s<0||s>=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-s&&(r=e.length-t+s);const i=r-s;return this===e&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(t,s,r):Uint8Array.prototype.set.call(e,this.subarray(s,r),t),i},h.prototype.fill=function(e,t,s,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,s=this.length):"string"==typeof s&&(r=s,s=this.length),void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!h.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(1===e.length){const t=e.charCodeAt(0);("utf8"===r&&t<128||"latin1"===r)&&(e=t)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<s)throw new RangeError("Out of range index");if(s<=t)return this;let i;if(t>>>=0,s=void 0===s?this.length:s>>>0,e||(e=0),"number"==typeof e)for(i=t;i<s;++i)this[i]=e;else{const n=h.isBuffer(e)?e:h.from(e,r),o=n.length;if(0===o)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(i=0;i<s-t;++i)this[i+t]=n[i%o]}return this};const j={};function q(e,t,s){j[e]=class extends s{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(e){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:e,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}function H(e){let t="",s=e.length;const r="-"===e[0]?1:0;for(;s>=r+4;s-=3)t=`_${e.slice(s-3,s)}${t}`;return`${e.slice(0,s)}${t}`}function V(e,t,s,r,i,n){if(e>s||e<t){const r="bigint"==typeof t?"n":"";let i;throw i=n>3?0===t||t===BigInt(0)?`>= 0${r} and < 2${r} ** ${8*(n+1)}${r}`:`>= -(2${r} ** ${8*(n+1)-1}${r}) and < 2 ** ${8*(n+1)-1}${r}`:`>= ${t}${r} and <= ${s}${r}`,new j.ERR_OUT_OF_RANGE("value",i,e)}!function(e,t,s){z(t,"offset"),void 0!==e[t]&&void 0!==e[t+s]||F(t,e.length-(s+1))}(r,i,n)}function z(e,t){if("number"!=typeof e)throw new j.ERR_INVALID_ARG_TYPE(t,"number",e)}function F(e,t,s){if(Math.floor(e)!==e)throw z(e,s),new j.ERR_OUT_OF_RANGE(s||"offset","an integer",e);if(t<0)throw new j.ERR_BUFFER_OUT_OF_BOUNDS;throw new j.ERR_OUT_OF_RANGE(s||"offset",`>= ${s?1:0} and <= ${t}`,e)}q("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),q("ERR_INVALID_ARG_TYPE",function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),q("ERR_OUT_OF_RANGE",function(e,t,s){let r=`The value of "${e}" is out of range.`,i=s;return Number.isInteger(s)&&Math.abs(s)>2**32?i=H(String(s)):"bigint"==typeof s&&(i=String(s),(s>BigInt(2)**BigInt(32)||s<-(BigInt(2)**BigInt(32)))&&(i=H(i)),i+="n"),r+=` It must be ${t}. Received ${i}`,r},RangeError);const G=/[^+/0-9A-Za-z-_]/g;function $(e,t){let s;t=t||1/0;const r=e.length;let i=null;const n=[];for(let o=0;o<r;++o){if(s=e.charCodeAt(o),s>55295&&s<57344){if(!i){if(s>56319){(t-=3)>-1&&n.push(239,191,189);continue}if(o+1===r){(t-=3)>-1&&n.push(239,191,189);continue}i=s;continue}if(s<56320){(t-=3)>-1&&n.push(239,191,189),i=s;continue}s=65536+(i-55296<<10|s-56320)}else i&&(t-=3)>-1&&n.push(239,191,189);if(i=null,s<128){if((t-=1)<0)break;n.push(s)}else if(s<2048){if((t-=2)<0)break;n.push(s>>6|192,63&s|128)}else if(s<65536){if((t-=3)<0)break;n.push(s>>12|224,s>>6&63|128,63&s|128)}else{if(!(s<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;n.push(s>>18|240,s>>12&63|128,s>>6&63|128,63&s|128)}}return n}function K(e){return r.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(G,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function W(e,t,s,r){let i;for(i=0;i<r&&!(i+s>=t.length||i>=e.length);++i)t[i+s]=e[i];return i}function Y(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function J(e){return e!=e}const X=function(){const e="0123456789abcdef",t=new Array(256);for(let s=0;s<16;++s){const r=16*s;for(let i=0;i<16;++i)t[r+i]=e[s]+e[i]}return t}();function Z(e){return"undefined"==typeof BigInt?Q:e}function Q(){throw new Error("BigInt not supported")}},5199(e){const t=e=>{if(null===e)return null;if(!e||"object"!=typeof e||Array.isArray(e)||"string"!=typeof e.assetKey||!/^[\x20-\x7e]{1,32}$/.test(e.assetKey)||!e.assetKey.trim())throw new TypeError("Cursor must be null or contain an ASCII assetKey of 1–32 characters");const t=void 0===e.hotspot?{x:0,y:0}:e.hotspot;if(!t||"object"!=typeof t||Array.isArray(t)||!Number.isInteger(t.x)||t.x<0||!Number.isInteger(t.y)||t.y<0)throw new TypeError("Cursor hotspot must contain nonnegative integer x and y coordinates");const s={assetKey:e.assetKey,hotspot:{x:t.x||0,y:t.y||0}};if(void 0!==e.pointerLock){if("boolean"!=typeof e.pointerLock)throw new TypeError("Cursor pointerLock must be a boolean");s.pointerLock=e.pointerLock}if(void 0!==e.size){const t=e.size;if(!t||"object"!=typeof t||Array.isArray(t)||!Number.isInteger(t.width)||t.width<1||t.width>128||!Number.isInteger(t.height)||t.height<1||t.height>128)throw new TypeError("Cursor size must contain integer width and height from 1 to 128");s.size={width:t.width,height:t.height}}return s};e.exports={CURSOR_OPCODE:13,normalizeCursor:t,encodeCursor:e=>{const s=(new TextEncoder).encode(JSON.stringify(t(e))),r=new Uint8Array(s.length+1);return r[0]=13,r.set(s,1),r},decodeCursor:e=>{const s=e instanceof ArrayBuffer?new Uint8Array(e):ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):null;if(!s||s.length<2||s.length>256||13!==s[0])throw new TypeError("Invalid cursor packet");try{return t(JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(s.subarray(1))))}catch(e){throw new TypeError("Invalid cursor packet: "+e.message)}}}},739(e){"use strict";e.exports={createExportStorage:function(e,{installationId:t,gameId:s,packageRevision:r="local",database:i,transaction:n}){if("string"!=typeof t||!t||"string"!=typeof s||!s)throw new Error("Export storage requires a host-selected game identity");const o=[t,s,r];let a;const h=()=>i?Promise.resolve(i):a||=new Promise((t,s)=>{const r=e.indexedDB.open("homegames-user-exports",1);r.onupgradeneeded=()=>r.result.createObjectStore("exports"),r.onerror=()=>s(r.error),r.onsuccess=()=>{r.result.onversionchange=()=>r.result.close(),t(r.result)}});function l(e){const t=Object.keys(e),s=new Set;let r=0;if(t.length>128)throw new Error("Too many exports");for(const i of t){if(!/^[A-Za-z0-9_][A-Za-z0-9_. -]{0,119}$/.test(i)||/[ .]$/.test(i)||/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(i)||["__proto__","constructor","prototype"].includes(i)||s.has(i.toLowerCase()))throw new Error("Invalid export name");s.add(i.toLowerCase());const t=e[i];if(!(t instanceof Uint8Array)||t.length>16777216||(r+=t.length)>67108864)throw new Error("Export size limit exceeded")}}return{async getExports(){const e=await h();return new Promise((t,s)=>{const r=e.transaction("exports","readonly"),i=r.objectStore("exports").get(o);r.oncomplete=()=>{try{const e=i.result||{};l(e),t(e)}catch(e){s(e)}},r.onabort=()=>s(r.error||new Error("Unable to read exports"))})},async putExport(e,t){l({[e]:t}),t=t.slice();const s=await h();return new Promise((r,i)=>{const a=n?n(["exports"]):s.transaction("exports","readwrite"),h=a.objectStore("exports"),c=h.get(o);let d;c.onsuccess=()=>{try{const s={...c.result,[e]:t};l(s),h.put(s,o)}catch(e){d=e,a.abort()}},a.oncomplete=()=>r(),a.onabort=()=>i(d||a.error||new Error("Unable to save export"))})}}}}},97(e){"use strict";e.exports={createExportsViewer:function(e,{list:t,read:s}){const r=e.document,i=(e,t,s)=>{const i=r.createElement(e);return t&&(i.textContent=t),s?.append(i),i},n=i("dialog");n.className="hg-exports",n.setAttribute("aria-label","Game exports"),i("style",null,n).textContent=".hg-exports{box-sizing:border-box;width:min(760px,calc(100vw - 24px));max-height:calc(100dvh - 24px);margin:auto;padding:20px;border:1px solid #4a5049;border-radius:16px;background:#202321;color:#f6f6ee;font:14px/1.5 system-ui,sans-serif;text-align:left;overflow:auto;box-shadow:0 24px 80px #0009}\n .hg-exports::backdrop{background:#080c0ac9}.hg-exports *{box-sizing:border-box}.hg-exports h2{font-size:22px;margin:0}.hg-exports p{margin:10px 0;color:#b7bfb5}.hg-exports button{min-height:44px;padding:8px 12px;border:1px solid #596157;border-radius:8px;background:#30372e;color:#f6f6ee;font:inherit;cursor:pointer;text-align:left}.hg-exports button:disabled{opacity:.5;cursor:wait}.hg-exports :focus-visible{outline:2px solid #fff78e;outline-offset:3px}.hg-exports-head{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.hg-exports-head h2{flex:1}.hg-exports-body{display:grid;grid-template-columns:minmax(140px,1fr) minmax(0,2fr);gap:16px}.hg-exports-files{display:flex;flex-direction:column;gap:6px;max-height:55dvh;overflow:auto}.hg-exports-files button{overflow-wrap:anywhere}.hg-exports-files button[aria-pressed=true]{border-color:#fff78e;background:#414530}.hg-exports-preview{min-width:0;overflow-wrap:anywhere}.hg-exports-preview h3{font-size:15px;margin:0 0 12px}.hg-exports-preview img,.hg-exports-preview video{display:block;max-width:100%;max-height:42dvh;background:#101211;margin:0 auto 12px}.hg-exports-preview audio{width:100%;margin-bottom:12px}.hg-exports-preview pre{white-space:pre-wrap;max-height:38dvh;overflow:auto;background:#101211;padding:12px;font:12px/1.5 monospace}.hg-exports-preview .hg-exports-save{background:#fff78e;color:#22261e;border-color:#fff78e}@media(max-width:520px){.hg-exports{padding:16px}.hg-exports-body{grid-template-columns:1fr}.hg-exports-files{max-height:150px}.hg-exports-preview img,.hg-exports-preview video{max-height:30dvh}}";const o=i("div",null,n);o.className="hg-exports-head",i("h2","Game exports",o);const a=i("button","Refresh",o),h=i("button","Close",o),l=i("p","Loading exports…",n);l.setAttribute("role","status");const c=i("div",null,n);c.className="hg-exports-body";const d=i("div",null,c);d.className="hg-exports-files",d.setAttribute("aria-label","Export files");const u=i("div",null,c);u.className="hg-exports-preview";let p,f,m=!1,g=!1;const y=new Promise(e=>{f=e});function v(){u.querySelectorAll("video,audio").forEach(e=>{e.pause(),e.removeAttribute("src"),e.load()}),u.replaceChildren(),p&&e.URL.revokeObjectURL(p),p=null}function w(){m||(m=!0,v(),n.close(),n.remove(),f())}const x=e=>e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`;function b(e){g=e,a.disabled=e,d.querySelectorAll("button").forEach(t=>{t.disabled=e})}async function E(t,n){if(!m&&!g){b(!0),v(),l.textContent=`Loading ${t.name}…`,d.querySelectorAll("button").forEach(e=>e.setAttribute("aria-pressed",String(e===n)));try{const n=await s(t.name);if(m)return;if(n.name!==t.name||!(n.bytes instanceof Uint8Array)||n.bytes.length>16777216)throw new Error("Invalid export file");const{name:o,bytes:a}=n,h=function(e,t){const s=(e,s)=>[...s].every((s,r)=>t[e+r]===s.charCodeAt(0));return s(0,"‰PNG\r\n\n")?"image/png":255===t[0]&&216===t[1]&&255===t[2]?"image/jpeg":s(0,"GIF87a")||s(0,"GIF89a")?"image/gif":s(0,"RIFF")&&s(8,"WEBP")?"image/webp":s(0,"RIFF")&&s(8,"WAVE")?"audio/wav":s(0,"Eߣ")?/\.(weba|opus)$/i.test(e)?"audio/webm":"video/webm":s(4,"ftyp")?/\.(m4a|aac)$/i.test(e)?"audio/mp4":"video/mp4":s(0,"OggS")?/\.ogv$/i.test(e)?"video/ogg":"audio/ogg":s(0,"ID3")||255===t[0]&&!(224&~t[1])?"audio/mpeg":"application/octet-stream"}(o,a);if(i("h3",o,u),l.textContent=`${x(a.length)} · Shared with everyone in this game`,p=e.URL.createObjectURL(new e.Blob([a],{type:h})),/^(image|audio|video)\//.test(h)){const e=i(h.startsWith("image/")?"img":h.split("/")[0],null,u);"IMG"===e.tagName?e.alt=o:(e.controls=!0,e.preload="metadata",e.setAttribute("playsinline","")),e.src=p,e.onerror=()=>{!m&&e.isConnected&&(l.textContent="This browser cannot preview this file. You can still save it.")}}else if(/\.(json|txt|csv|md|js|html|css|xml|svg|yaml|yml)$/i.test(o)){const t=(new e.TextDecoder).decode(a.subarray(0,65536));i("pre",t||"(Empty file)",u),a.length>65536&&i("p","Preview shows the first 64 KB. Save file includes all bytes.",u)}else i("p","No preview for this format. Save it to open in another app.",u);const c=i("button","Save file",u);c.className="hg-exports-save",c.onclick=()=>{const t=e.URL.createObjectURL(new e.Blob([a],{type:h})),s=i("a",null,r.body);s.href=t,s.download=o,s.click(),s.remove(),e.setTimeout(()=>e.URL.revokeObjectURL(t),3e4)}}catch(e){m||(l.textContent=e.message)}finally{m||b(!1)}}}async function S(){if(!m&&!g){b(!0),v(),d.replaceChildren(),l.textContent="Loading exports…";try{const e=await t();if(m)return;if(!Array.isArray(e)||e.length>128||e.some(e=>{return!("string"==typeof(t=e.name)&&/^[A-Za-z0-9_][A-Za-z0-9_. -]{0,119}$/.test(t)&&!/[ .]$/.test(t)&&Number.isSafeInteger(e.size))||e.size<0||e.size>16777216;var t}))throw new Error("Invalid export list");l.textContent=e.length?"Choose a file to preview and save. These files are shared with everyone in this game.":"No exports yet. Files saved by this game will appear here.";for(const t of e){const e=i("button",`${t.name} · ${x(t.size)}`,d);e.setAttribute("aria-pressed","false"),e.onclick=()=>E(t,e)}}catch(e){m||(l.textContent=e.message)}finally{m||b(!1)}}}return a.onclick=S,h.onclick=w,n.oncancel=e=>{e.preventDefault(),w()},r.body.append(n),n.showModal(),h.focus(),S(),{result:y,close:w}}}},5766(e,t,s){var r=s(8287).hp;const i=8388608,n=s(6862),o=(e,t)=>!e.playerIds?.length||e.playerIds.some(e=>e==t),a=e=>Object.values(e||{}).filter(e=>e?.root?.node),{describeMedia:h}=s(3947);e.exports=class{constructor(e,t={}){this.game=e,this.gameInput=new n(e),this._activePresses={},this.getLayers=t.getLayers||(()=>e.getLayers()),this.findNode=t.findNode||(t=>e.findNode(t)),this.findPointerNode=t.findPointerNode||this.findNode,this.toGameCoords=t.toGameCoords||((e,t)=>({x:e,y:t})),this.fileBuffers=!!t.fileBuffers,this.canControlGame=t.canControlGame||(()=>!0)}handleInput(e,t){if(!t||"object"!=typeof t||"string"!=typeof t.type)return;const s=Number(e);if(Number.isSafeInteger(s)&&!(s<=0))try{if("click"===t.type){const e=t.data;if(!e||"number"!=typeof e.x||"number"!=typeof e.y)return;this._handleClick(s,e)}else if("keydown"===t.type){if(!this.canControlGame(s)||"string"!=typeof t.key||t.key.length>20)return;this.gameInput.keyDown(s,t.key)}else if("keyup"===t.type){if(!this.canControlGame(s)||"string"!=typeof t.key||t.key.length>20)return;this.gameInput.keyUp(s,t.key)}else if("mouseup"===t.type)this.canControlGame(s)&&this.game.handleMouseUp?.(s,t.data),this.endPress(s,t.data);else if("mousemove"===t.type)this._handleDragMove(s,t.data);else if("pointermove"===t.type){const e=t.data;if(!this.canControlGame(s)||!e||!Number.isFinite(e.dx)||!Number.isFinite(e.dy)||Math.abs(e.dx)>4096||Math.abs(e.dy)>4096)return;this.game.handlePointerMove?.(s,{dx:e.dx,dy:e.dy})}else if("input"===t.type)if(t.gamepad)this.canControlGame(s)&&this.gameInput.gamepad(s,t);else{const e=this._findInputNode(t.nodeId,s);if(e&&e.node&&e.node.input)if("file"===e.node.input.type){const n=((e,t=!1)=>{if("string"==typeof e){if(e.length>4*Math.ceil(2796202.6666666665))return null;let s;if(!t&&"function"==typeof atob){if(s=atob(e),0===s.length||s.length>i)return null;const t=new Uint8Array(s.length);for(let e=0;e<s.length;e++)t[e]=s.charCodeAt(e);return t}const n=r.from(e,"base64");return 0===n.length||n.length>i?null:n}if(e&&"object"==typeof e){const s=Object.values(e);return 0===s.length||s.length>i||s.some(e=>!Number.isInteger(e)||e<0||e>255)?null:t?r.from(s):Uint8Array.from(s)}return null})(t.input,this.fileBuffers);n&&e.node.input.oninput(s,n,((e,t)=>({...h(e,t),contentType:"string"==typeof t.contentType&&t.contentType.length<=100?t.contentType:null}))(n,t))}else e.node.input.oninput(s,t.input)}else if("onhover"===t.type){const e=this._findInputNode(t.nodeId,s);e&&e.node&&e.node.onHover&&e.node.onHover(s)}else if("offhover"===t.type){const e=this._findInputNode(t.nodeId,s);e&&e.node&&e.node.offHover&&e.node.offHover(s)}}catch(e){console.error(`[GameDispatcher] Error handling input type="${t.type}":`,e)}}_findInputNode(e,t){if(!Number.isSafeInteger(e)||e<0)return null;const s=new Set,r=(i,n)=>{const a=i?.node;if(!a||n>100||s.has(a)||!o(a,t))return null;if(s.add(a),a.id===e)return i;for(const e of Object.values(a.children||{})){const t=r(e,n+1);if(t)return t}return null};for(const e of a(this.getLayers(void 0,void 0,t))){if(!1===e.interactive)continue;const t=r(e.root,0);if(t)return t}return null}_handleClick(e,t){if(!t||!Number.isFinite(t.x)||!Number.isFinite(t.y))return;if(t.x<0||t.y<0||t.x>=100||t.y>=100)return;const s=this._activePresses[e],r=!s||!0===t.press;s&&!0===t.press?this.endPress(e,null):s&&!r&&this._handleDragMove(e,t);const i=this._findClickTarget(t.x,t.y,e);if(r&&(this._activePresses[e]={node:i?.node||null,path:i?.path,x:t.x,y:t.y}),i?.node.handleClick){const{x:s,y:r}=this.toGameCoords(t.x,t.y);i.node.handleClick(e,s,r)}}_handleDragMove(e,t){if(!t||!Number.isFinite(t.x)||!Number.isFinite(t.y))return;if(t.x<0||t.y<0||t.x>=100||t.y>=100)return;this.checkActivePresses(e);const s=this._activePresses[e];s&&(s.x=t.x,s.y=t.y);const{x:r,y:i}=this.toGameCoords(t.x,t.y);try{this.canControlGame(e)&&this.game.handleMouseMove?.(e,{x:r,y:i})}catch(e){console.error("[GameDispatcher] game.handleMouseMove threw:",e)}if(s&&s.node&&"function"==typeof s.node.onDrag)try{s.node.onDrag(e,r,i)}catch(e){console.error("[GameDispatcher] node.onDrag threw:",e)}}endPress(e,t){const s=this._activePresses[e];if(s&&(delete this._activePresses[e],s.node&&"function"==typeof s.node.offClick)){const r=t&&Number.isFinite(t.x)&&Number.isFinite(t.y)?t:{x:s.x,y:s.y};try{const{x:t,y:i}=this.toGameCoords(r.x,r.y);s.node.offClick(e,t,i)}catch(e){console.error("[GameDispatcher] node.offClick threw:",e)}}}checkActivePresses(e){if(void 0===e){for(const e of Object.keys(this._activePresses))this.checkActivePresses(e);return}const t=this._activePresses[e];if(!t||!t.node)return;const s=t.path;s&&a(this.getLayers(void 0,void 0,e)).some(e=>!1!==e.interactive&&e.root.node===s[0])&&!s.some((t,r)=>!o(t,e)||r>0&&!Object.values(s[r-1].children||{}).some(e=>e?.node===t))||this.endPress(e,null)}_findClick(e,t,s){return this._findClickTarget(e,t,s)?.node||null}_findClickTarget(e,t,s){let r=null;for(const i of a(this.getLayers(e,t,s)))!1!==i.interactive&&(r=this._findClickHelper(e,t,s,i.root.node,null,i.scale||{x:1,y:1},0)||r);return r}_findClickHelper(e,t,s,r,i,n,a,h=[]){if(a>100)return i;if(!o(r,s))return i;if(h.push(r),r.coordinates2d&&r.coordinates2d.length>0){const s=[];for(let e=0;e<r.coordinates2d.length;e++){const t=100-100*n.x,i=100-100*n.y,o=r.coordinates2d[e][0]*((100-t)/100)+t/2,a=r.coordinates2d[e][1]*((100-i)/100)+i/2;s.push([o,a])}if(s.length>0){let n=!1,o=s[0][0],a=s[0][0],l=s[0][1],c=s[0][1];for(let e=1;e<s.length;e++)o=Math.min(s[e][0],o),a=Math.max(s[e][0],a),l=Math.min(s[e][1],l),c=Math.max(s[e][1],c);if(!(e<o||e>a||t<l||t>c)){let r=0,i=s.length-1;for(;r<s.length;i=r++)s[r][1]>t!=s[i][1]>t&&e<(s[i][0]-s[r][0])*(t-s[r][1])/(s[i][1]-s[r][1])+s[r][0]&&(n=!n)}n&&(i={node:r,path:h.slice()})}}if(r.children){const o=Object.keys(r.children);for(let l=0;l<o.length;l++){const c=r.children[o[l]];c&&c.node&&(i=this._findClickHelper(e,t,s,c.node,i,n,a+1,h))}}return h.pop(),i}}},6862(e,t,s){const{Buttons:r,mapInputs:i}=s(1011),n=s(6260),o=(e,t,s)=>Number.isFinite(e)?Math.max(t,Math.min(s,e)):0,a=()=>({buttons:Object.fromEntries(Object.values(r).map(e=>[e,{value:0,pressed:!1}])),sticks:Object.fromEntries(Object.keys(n.sticks).map(e=>[e,{value:0}]))});e.exports=class{constructor(e){this.game=e,this.bindings=e.constructor.metadata?.().gamepadBindings||{},this.players=new Map}_player(e){return this.players.has(e)||this.players.set(e,{keyboard:new Set,pads:new Map}),this.players.get(e)}_keys(e){return new Set([...e.keyboard,...Array.from(e.pads.values()).flatMap(e=>[...e.keys])])}keyDown(e,t){this._player(e).keyboard.add(t),this.game.handleKeyDown?.(e,t)}keyUp(e,t){const s=this._player(e);s.keyboard.delete(t),this._keys(s).has(t)||this.game.handleKeyUp?.(e,t)}gamepad(e,t){const s=t.gamepadIndex??0;if(!Number.isInteger(s)||s<0||s>15)return;if(!t.input||"object"!=typeof t.input)return;if(!(!1===t.connected||t.input.buttons&&t.input.sticks))return;const r=a();if(!1!==t.connected){for(const e of Object.keys(r.buttons)){const s=t.input.buttons[e];r.buttons[e]={value:o(s?.value,0,1),pressed:!0===s?.pressed}}for(const e of Object.keys(r.sticks))r.sticks[e].value=o(t.input.sticks[e]?.value,-1,1)}const n=this._player(e),h=this._keys(n),l=n.pads.get(s),c=Object.keys(r.buttons).filter(e=>r.buttons[e].pressed&&!l?.state.buttons[e].pressed),d=Object.keys(r.buttons).filter(e=>!r.buttons[e].pressed&&l?.state.buttons[e].pressed),u=new Set(Object.entries(i(r,this.bindings)).filter(([,e])=>e.pressed).map(([e])=>e));!1===t.connected?n.pads.delete(s):n.pads.set(s,{state:r,keys:u});const p=this._keys(n);for(const t of h)p.has(t)||this.game.handleKeyUp?.(e,t);for(const t of u){const r=[...n.pads].find(([,e])=>e.keys.has(t))?.[0];n.keyboard.has(t)||r!==s||this.game.handleKeyDown?.(e,t)}this.game.handleGamepadInput?.(e,{type:"input",gamepad:!0,gamepadIndex:s,connected:!1!==t.connected,deltaTime:!1===t.connected?0:o(t.deltaTime??1/30,0,.1),input:r,pressed:c,released:d})}removePlayer(e){const t=this.players.get(e);if(t){this.players.delete(e);for(const s of this._keys(t))this.game.handleKeyUp?.(e,s);for(const[s,r]of t.pads)this.game.handleGamepadInput?.(e,{type:"input",gamepad:!0,gamepadIndex:s,connected:!1,deltaTime:0,input:a(),pressed:[],released:Object.keys(r.state.buttons).filter(e=>r.state.buttons[e].pressed)})}}}},7821(e,t,s){"use strict";const r=s(8630),i=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n=e=>{throw new Error(e)};function o(e,t){if(e&&"string"==typeof e.type){t(e);for(const s of Object.values(e))Array.isArray(s)?s.forEach(e=>o(e,t)):s&&"string"==typeof s.type&&o(s,t)}}function a(e,t,s=new Map,r=new Set){e||n(`${t} must be declared as a literal`),(r.has(e)||r.size>64)&&n(`Circular or excessive constant expression in ${t}`),r=new Set(r).add(e);const o=e=>a(e,t,s,r),h=(e,r=new Set)=>{if((!e||r.has(e)||r.size>64)&&n(`Unresolved constant in ${t}`),r.add(e),"Identifier"===e.type&&s.has(e.name))return h(s.get(e.name),r);if("MemberExpression"===e.type){const t=h(e.object,r),s=e.computed?o(e.property):e.property.name;if("ObjectExpression"===t.type)return h(t.properties.find(e=>"Property"===e.type&&!e.computed&&(e.key.name??e.key.value)===s)?.value,r)}return e},l=h(e);if(l!==e)return o(l);if("Literal"===e.type&&!(e.value instanceof RegExp))return e.value;if("UnaryExpression"===e.type&&["-","+","!"].includes(e.operator)){const t=o(e.argument);return"!"===e.operator?!t:"-"===e.operator?-t:+t}if("ArrayExpression"===e.type)return e.elements.map(o);if("ObjectExpression"===e.type){const s=Object.create(null);for(const r of e.properties){("Property"!==r.type||r.computed||r.method||"init"!==r.kind)&&n(`${t} must use literal properties`);const e=r.key.name??r.key.value;i(s,e)&&n(`Duplicate ${t} property: ${e}`),s[e]=o(r.value)}return s}n(`${t} must be declared as a literal`)}function h(e,{strictAssets:t=!0,requireExport:s=!1}={}){const h=r.parse(e,{ecmaVersion:"latest",sourceType:"script"}),l=new Map;for(const e of h.body)if("ClassDeclaration"===e.type&&l.set(e.id?.name,e),"VariableDeclaration"===e.type)for(const t of e.declarations)"Identifier"===t.id.type&&"ClassExpression"===t.init?.type&&l.set(t.id.name,t.init);const c=h.body.filter(e=>"ExpressionStatement"===e.type).map(e=>e.expression).filter(e=>"AssignmentExpression"===e.type&&"="===e.operator&&"MemberExpression"===e.left.type&&"module"===e.left.object.name&&"exports"===(e.left.computed?e.left.property.value:e.left.property.name)),d=c[0]?.right,u="ClassExpression"===d?.type?d:"Identifier"===d?.type?l.get(d.name):null;!s||1===c.length&&u||n("Entry must export its Game class directly with module.exports");const p=[],f=e=>{"MethodDefinition"!==e.type||"method"!==e.kind||!e.static||e.computed||"PrivateIdentifier"===e.key.type||e.value.async||e.value.generator||"metadata"!==(e.key.name??e.key.value)||p.push(e)};s?u.body.body.forEach(f):o(h,f);const m=p[0]?.value.body.body;1===p.length&&1===m.length&&"ReturnStatement"===m[0].type&&"ObjectExpression"===m[0].argument?.type||n("Games need one static metadata() returning a literal object");const g=m[0].argument,y=new Map,v=Object.create(null),w=[];for(const e of h.body)if("VariableDeclaration"===e.type&&"const"===e.kind)for(const t of e.declarations)"Identifier"===t.id.type&&y.set(t.id.name,t.init);for(const e of g.properties){("Property"!==e.type||e.computed||e.method||"init"!==e.kind)&&n("Game metadata must use literal properties");const s=e.key.name??e.key.value;if(i(v,s)&&n(`Duplicate metadata property: ${s}`),"assets"===s){"ObjectExpression"!==e.value.type&&n("metadata.assets must be a literal object"),v.assets=Object.create(null);for(const s of e.value.properties){("Property"!==s.type||s.computed||s.method||"init"!==s.kind)&&n("Asset declarations must use literal keys");const e=s.key.name??s.key.value,r=s.value;let o;/^[A-Za-z0-9_-]{1,32}$/.test(e)&&!["__proto__","constructor","prototype"].includes(e)||n(`Invalid asset key: ${e}`),t&&i(v.assets,e)&&n(`Duplicate asset key: ${e}`),"NewExpression"===r.type&&"Asset"===r.callee.name&&1===r.arguments.length||n(`Asset ${e} must use new Asset({ path, type })`);try{o=a(r.arguments[0],`Asset ${e}`,y)}catch(e){if(t)throw e;continue}v.assets[e]=o,w.push({key:e,info:o,node:r})}}else v[s]=a(e.value,`metadata.${s}`,y)}const x=new Set;o(h,e=>{"CallExpression"===e.type&&"require"===e.callee.name&&"string"==typeof e.arguments[0]?.value&&/^squish-[0-9]+$/.test(e.arguments[0].value)&&x.add(e.arguments[0].value.slice(7))}),x.size>1&&n("Mixed Squish runtimes are unsupported");const b=[...x][0];return b&&void 0!==v.squishVersion&&b!==v.squishVersion&&n("metadata.squishVersion must match the Squish import"),{tree:h,object:g,bindings:y,metadata:v,assets:w,runtime:b}}e.exports={walk:o,literal:a,readSourceMetadata:h,rewriteMetadata:function(e,t,{remove:s=[],requireExport:i=!1}={}){const{object:o}=h(e,{requireExport:i}),a=new Set(s),l=[],c=new Set,d=[...r.tokenizer(e,{ecmaVersion:"latest"})],u=o.properties;for(let e=0;e<u.length;e++){const s=u[e],r=s.key.name??s.key.value;if(c.add(r),Object.hasOwn(t,r))l.push({start:s.start,end:s.end,value:`${r}: ${JSON.stringify(t[r])}`});else if(a.has(r)){const t=d.find(t=>","===t.type.label&&t.start>=s.end&&t.end<=(u[e+1]?.start??o.end));if(t)l.push({start:s.start,end:t.end,value:""});else{const t=d.find(t=>","===t.type.label&&t.start>=(u[e-1]?.end??o.start)&&t.end<=s.start);l.push({start:t?.start??s.start,end:s.end,value:""})}}}const p=Object.entries(t).filter(([e])=>!c.has(e));p.length&&(p.some(([e])=>!/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e))&&n("Invalid metadata property name"),l.push({start:o.start+1,end:o.start+1,value:"\n "+p.map(([e,t])=>`${e}: ${JSON.stringify(t)}`).join(",\n ")+(u.length?",":"")+"\n"}));const f=[];for(const e of l.sort((e,t)=>e.start-t.start||e.end-t.end)){const t=f[f.length-1];t&&!t.value&&!e.value&&e.start<=t.end?t.end=Math.max(t.end,e.end):f.push(e)}for(const t of f.reverse())e=e.slice(0,t.start)+t.value+e.slice(t.end);return e},...s(2439)}},2947(e,t,s){"use strict";const{createProject:r}=s(5110),{DIRECTORY:i,createUserExports:n}=s(5828),o=new WeakMap;function a(e){let t,s=e;for(;s&&!(t=o.get(s));)s=Object.getPrototypeOf(s);return t}e.exports={bindGameProject:function(e,t,s={},r={}){return o.set(e,{readProject:t,options:s,exports:r}),e},openGameExports:function(e,{saved:t={},persist:s}={}){const r=a(e);return r?.exports.open?r.exports.open():n({...r?.exports.files,...t},s)},exportGameProject:async function(e,t){const s=a(e.constructor);if(!s)throw new Error("This host has no portable source package for this game");const n=t&&await t.snapshot(),o=await s.readProject();if(!t)return o;const h=Object.fromEntries(o.reader.listFiles().map(e=>[e,o.reader.readFile(e)]));for(const[e,t]of Object.entries(n))h[i+"/"+e]=t;return r(h,s.options)}}},3735(e){const t=e=>{const t=[];for(const s of e.split("/"))s&&"."!==s&&(".."===s?t.pop():t.push(s));return t.join("/")},s={image:1,audio:2,font:3,video:4};new WeakMap,e.exports={normalizePath:t,resolveInFiles:(e,s,r)=>{for(const i of((e,s)=>{const r=t(e?e+"/"+s:s);return[r,r+".js",r+"/index.js"]})(s,r))if(Object.prototype.hasOwnProperty.call(e,i))return i;return null},packAssetBundle:e=>{const t=e.map(({key:e,type:t,data:r})=>{const i=new Uint8Array(44+r.length);i[0]=1,i[1]=s[t]||s.image;const n=(r.length+32).toString(36),o=10-n.length;for(let e=0;e<o;e++)i[2+e]=48;for(let e=0;e<n.length;e++)i[2+o+e]=n.charCodeAt(e);const a=Math.min(32,e.length);for(let t=0;t<a;t++)i[12+t]=e.charCodeAt(t);return i.set(r,44),i}),r=t.reduce((e,t)=>e+t.length,0),i=new Uint8Array(r);let n=0;for(const e of t)i.set(e,n),n+=e.length;return i},splitAssetBundle:(e,t=10485760)=>{const s=[];let r=0,i=0;for(;i<e.length;){const n=String.fromCharCode(...e.subarray(i+2,i+12)),o=parseInt(n,36)+12;if(1!==e[i]||!/^[0-9a-z]{10}$/.test(n)||o<44||i+o>e.length)throw new Error("Invalid asset bundle");if(o>t)throw new Error("An asset exceeds the RTC packet limit");i+o-r>t&&(s.push(e.subarray(r,i)),r=i),i+=o}return i>r&&s.push(e.subarray(r,i)),s}}},6620(e,t,s){var r=s(8287).hp;const{MAX_UPLOAD_BYTES:i,describeMedia:n}=s(3947);e.exports=class{constructor(){this.endpoints=new Map,this.streams=new Map,this.recordings=new Map,this.listeners=new Set,this.sequence=0}onChange(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notify(e,t){const s={...e.info,state:t};for(const e of this.listeners)try{e(s)}catch(e){console.error(e)}}join(e,t){this.endpoints.set(e,t);for(const s of this.streams.values())s.ready&&this.deliver(s,e,t)}request(e,t={}){const s=this.endpoints.get(Number(e));if(!s||this.closed||!1===s.live)return Promise.reject(new Error("This client connection does not support live media"));if(!t.audio&&!t.video)return Promise.reject(new Error("Request audio or video"));if(this.recordings.has(Number(e))||[...this.streams.values()].some(t=>t.info.playerId===Number(e)))return Promise.reject(new Error("Stop your current microphone/camera before enabling another"));const r="media-"+ ++this.sequence,i={id:r,playerId:Number(e),audio:!!t.audio,video:!!t.video,transmitting:!1!==t.transmitting,pushToTalk:!!t.pushToTalk};return new Promise((e,t)=>{const n={info:i,resolve:e,reject:t};n.timer=setTimeout(()=>this.stop(r,"Microphone/camera permission timed out"),6e4),this.streams.set(r,n),s.send({type:"media",action:"request",stream:i})})}record(e,t={}){e=Number(e);const s=this.endpoints.get(e);if(!s||this.closed)return Promise.reject(new Error("This client connection does not support recording"));if(!1===s.recording)return Promise.reject(new Error("This player needs the updated Homegames client to record."));if(this.recordings.has(e)||[...this.streams.values()].some(t=>t.info.playerId===e))return Promise.reject(new Error("Stop your current microphone/camera before recording"));const r="audio"===t.kind?"audio":"video";if("audio"===r&&!0!==s.audioRecording)return Promise.reject(new Error("This client does not support audio recording. Choose an audio file instead."));const n=Math.min(30,Math.max(1,Number(t.durationSeconds)||30)),o=Math.min(i,Math.max(131072,Math.floor(Number(t.maxBytes)||i))),a={id:"recording-"+ ++this.sequence,kind:r,durationSeconds:n,maxBytes:o,prompt:String(t.prompt||"").slice(0,120)};return new Promise((t,r)=>{const i={info:a,resolve:t,reject:r};i.timer=setTimeout(()=>this.cancelRecording(e,"Recording timed out. Please try again."),18e4),this.recordings.set(e,i),s.send({type:"media",action:"record",recording:a})})}cancelRecording(e,t="Recording cancelled"){const s=this.recordings.get(e);s&&(this.recordings.delete(e),clearTimeout(s.timer),this.endpoints.get(e)?.send({type:"media",action:"record-cancel",id:s.info.id}),s.reject(new Error(t)))}recordingResult(e,t){const s=this.recordings.get(e);if(s&&s.info.id===t.id)if(t.error)this.cancelRecording(e,String(t.error).slice(0,160));else try{if("string"!=typeof t.data||!t.data.length||t.data.length>4*Math.ceil(s.info.maxBytes/3)||!/^[A-Za-z0-9+/]*={0,2}$/.test(t.data))throw new Error("Invalid or oversized recording");const i=r.from(t.data,"base64"),o=n(i,{contentType:t.contentType,fileName:t.fileName});if(!i.length||i.length>s.info.maxBytes||o.kind!==s.info.kind)throw new Error("Recording must match the requested media kind and size limit");this.recordings.delete(e),clearTimeout(s.timer),s.resolve({bytes:i,meta:o,durationSeconds:s.info.durationSeconds})}catch(t){this.cancelRecording(e,t.message)}}handle(e,t){if("record-result"===t.action)return void this.recordingResult(e,t);const s=this.streams.get(t.id);if(s&&s.info.playerId===e)if("result"!==t.action||s.ready)"stopped"===t.action?this.stop(t.id):"released"===t.action&&this.setTransmitting(t.id,!1);else{if(t.error)return void this.stop(t.id,String(t.error).slice(0,160));if("string"!=typeof t.sourceId||t.sourceId.length>128)return;clearTimeout(s.timer),s.ready=!0,s.info.sourceId=t.sourceId,s.resolve({...s.info}),s.resolve=s.reject=null;for(const[e,t]of this.endpoints)this.deliver(s,e,t);this.notify(s,"ready")}}attach(e,t){const s=[...this.streams.values()].find(s=>s.ready&&s.info.playerId===e&&s.info.sourceId===t.id);if(!s)return!1;s.native=t;for(const[e,t]of this.endpoints)this.deliver(s,e,t);return!0}deliver(e,t,s){s.send({type:"media",action:"available",stream:{...e.info}}),e.native&&t!==e.info.playerId&&s.addMedia(e.info.id,e.native)}setTransmitting(e,t){const s=this.streams.get(e);if(s?.ready&&s.info.transmitting!==!!t){s.info.transmitting=!!t;for(const e of this.endpoints.values())e.send({type:"media",action:"state",stream:{...s.info}});this.notify(s,"changed")}}stop(e,t="Stream stopped"){const s=this.streams.get(e);if(s){this.streams.delete(e),clearTimeout(s.timer),s.reject?.(new Error(t));for(const t of this.endpoints.values())t.send({type:"media",action:"ended",id:e}),t.removeMedia(e);this.notify(s,"ended")}}leave(e){this.cancelRecording(e,"The player left");for(const[t,s]of this.streams)s.info.playerId===e&&this.stop(t,"The player left");this.endpoints.delete(e)}destroy(){if(!this.closed){this.closed=!0;for(const e of[...this.recordings.keys()])this.cancelRecording(e,"The session ended");for(const e of[...this.streams.keys()])this.stop(e,"The session ended");this.endpoints.clear(),this.listeners.clear()}}}},3947(e){const t=5242880,s=(e,t,s)=>String.fromCharCode(...e.subarray(t,t+s)),r=(e,t={})=>{const r="string"==typeof t.fileName?t.fileName.slice(0,128):null,i="string"==typeof t.contentType?t.contentType.toLowerCase().split(";")[0].slice(0,100):"";let n=null,o=null;const a=(e,t)=>{n=e,o=t};if(e.length>=4&&137===e[0]&&"PNG"===s(e,1,3))a("image","image/png");else if(e.length>=3&&255===e[0]&&216===e[1]&&255===e[2])a("image","image/jpeg");else if("GIF"===s(e,0,3))a("image","image/gif");else if("RIFF"===s(e,0,4)){const t=s(e,8,4);"WEBP"===t&&a("image","image/webp"),"WAVE"===t&&a("audio","audio/wav"),"AVI "===t&&a("video","video/x-msvideo")}else if("ID3"===s(e,0,3)||e.length>1&&255===e[0]&&!(224&~e[1]))a("audio","audio/mpeg");else if("fLaC"===s(e,0,4))a("audio","audio/flac");else if("OggS"===s(e,0,4)){const e="video/ogg"===i||/\.ogv$/i.test(r||"");a(e?"video":"audio",e?"video/ogg":"audio/ogg")}else if(e.length>=4&&26===e[0]&&69===e[1]&&223===e[2]&&163===e[3]){const e="audio/webm"===i||/\.weba$/i.test(r||"");a(e?"audio":"video",e?"audio/webm":"video/webm")}else if(e.length>=12&&"ftyp"===s(e,4,4)){const t=s(e,8,4);if(["avif","avis"].includes(t))a("image","image/avif");else{const e=/^M4[ABP] /.test(t)||i.startsWith("audio/")||/\.(m4a|m4b)$/i.test(r||"");a(e?"audio":"video",e?"audio/mp4":"video/mp4")}}return{kind:n,contentType:o,fileName:r}};e.exports={MAX_UPLOAD_BYTES:t,describeMedia:r,createFileUploadHandler:({Asset:e,registerAsset:s,isPlayerActive:i})=>{let n=0;const o=new Map;return async(a,h,l={},c={})=>{if(!i(Number(a)))throw new Error("The uploading player has left the session");const d=h instanceof ArrayBuffer?new Uint8Array(h):ArrayBuffer.isView(h)?new Uint8Array(h.buffer,h.byteOffset,h.byteLength):null;if(!d?.length||d.length>t)throw new Error("Choose an image, audio file or video up to 5 MB");const u=r(d,l);if(!u.kind)throw new Error("That file is not a supported image, audio file or video");if(null!=c.slot&&("string"!=typeof c.slot||!/^[a-zA-Z0-9_-]{1,32}$/.test(c.slot)))throw new Error("Invalid upload slot");const p=null==c.slot?null:`${Number(a)}:${c.slot}`,f=p&&o.get(p)||"upload-"+ ++n;p&&o.set(p,f);const m=new e({id:f,type:u.kind,contentType:u.contentType,fileName:u.fileName},d.slice());return m.key=f,await s(f,m),m}}}},4367(e){"use strict";function t(){const e=e=>{if("string"!=typeof e||/[\u0000-\u001f\u007f-\u009f\u202a-\u202e\u2066-\u2069]/.test(e))throw new Error("Use a name without control characters.");const t=e.normalize("NFC").trim().replace(/\s+/gu," ");if(!t||t.length>32)throw new Error("Choose a name between 1 and 32 characters.");return t},t=["chocolate","iguana","cardigan","enormous","gargantuan","orangutan","cookies","monstera","daisy","grapefruit","blueberry","mango","elephant","bamboo","sapphire","papaya","waffle","turquoise","aquatic","goblin","funky","hotdog","elegant","cascade","euphoria"],s=()=>Array.from({length:2},()=>t[Math.floor(Math.random()*t.length)]).join(" ");return{normalizeName:e,generateName:s,initialName:t=>{try{return e(t)}catch(e){return s()}},profile:function(t){const r="homegames-player-name";let i;try{i=e(t.localStorage.getItem(r))}catch(e){i=s()}const n=s=>{i=e(s);try{t.localStorage.setItem(r,i)}catch(e){}return i};return n(i),{get:()=>i,set:n}}}}e.exports={createPlayerIdentity:t,...t()}},8106(e){"use strict";e.exports={createPlayerToolbar:function(e,t={}){const s=e.document,r=new Map,i=new Set,n=(e,t,r)=>{const i=s.createElement(e);return i.className=t,r&&(i.textContent=r),i},o=(e,t)=>{const s=n("button",e,t);return s.type="button",s},a=n("header","hg-player-bar");a.setAttribute("aria-label","Game controls");const h=n("style","");h.textContent="\n.hg-player-bar,.hg-player-menu{box-sizing:border-box;color:#f6f6ee;font:14px/1.4 system-ui,sans-serif}\n.hg-player-bar *,.hg-player-menu *{box-sizing:border-box}\n.hg-player-bar{position:absolute;inset:0 0 auto;z-index:10;width:100%;height:0;pointer-events:none;--hg-safe-top:env(safe-area-inset-top,0px);--hg-safe-left:env(safe-area-inset-left,0px);--hg-safe-right:env(safe-area-inset-right,0px);--hg-safe-bottom:env(safe-area-inset-bottom,0px)}\n.hg-player-bar button,.hg-player-menu button,.hg-player-menu a{font:inherit;color:inherit;border:1px solid #4a5049;border-radius:12px;background:#252b25;cursor:pointer;text-decoration:none}\n.hg-player-bar button,.hg-player-menu button{min-height:44px;padding:10px 14px}\n.hg-player-bar .hg-player-home{position:absolute;top:calc(8px + var(--hg-safe-top));left:calc(8px + var(--hg-safe-left));width:44px;height:44px;padding:6px;background:#202820;pointer-events:auto;display:grid;place-items:center}\n.hg-player-home img{display:block;width:30px;height:30px;object-fit:contain}\n.hg-player-bar button:hover,.hg-player-menu button:hover,.hg-player-menu a:hover{background:#394036}\n.hg-player-bar :focus-visible,.hg-player-menu :focus-visible{outline:2px solid #fff78e;outline-offset:3px}\n.hg-player-bar [hidden],.hg-player-menu [hidden]{display:none!important}\n.hg-player-bar button:disabled,.hg-player-menu button:disabled{opacity:.45;cursor:default}\n.hg-player-menu{position:fixed;inset:0;margin:0;width:100%;height:100%;height:100dvh;max-width:none;max-height:none;overflow:auto;padding:max(24px,env(safe-area-inset-top)) max(20px,env(safe-area-inset-right)) max(24px,env(safe-area-inset-bottom)) max(20px,env(safe-area-inset-left));border:0;border-radius:0;background:#141b16}\n.hg-player-menu::backdrop{background:#080c0a}\n.hg-player-menu-content{width:100%;max-width:960px;margin:0 auto}\n.hg-player-menu-header{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:24px}\n.hg-player-menu-brand{display:flex;align-items:center;gap:10px;font-size:17px;font-weight:600}\n.hg-player-menu-brand img{width:28px;height:28px}\n.hg-player-menu .hg-player-menu-close{background:#fff78e;color:#22261e;border-color:#fff78e;flex:none}\n.hg-player-heading{margin:0 0 24px;text-align:center}.hg-player-title{margin:0;font-size:clamp(24px,4vw,36px);line-height:1.2;overflow-wrap:anywhere;font-weight:600}\n.hg-player-author{display:block;font-size:14px;font-weight:400;color:#b7bfb5;margin-top:8px}\n.hg-player-sharing{max-width:420px;margin:0 auto 32px;text-align:center}\n.hg-player-share-qr{width:min(224px,100%);aspect-ratio:1;margin:0 auto 16px;background:#fff;padding:8px;border-radius:8px}\n.hg-player-share-qr svg{display:block;width:100%;height:100%}\n.hg-player-share-caption{margin:0 0 12px;font-size:15px}\n.hg-player-share-status{margin:12px 0;color:#c4cec0;overflow-wrap:anywhere;min-height:20px}\n.hg-player-share-note{margin:12px 0 0;color:#b7bfb5;font-size:12px}\n.hg-player-share-actions{display:flex;justify-content:center;flex-wrap:wrap;gap:8px}\n.hg-player-menu .hg-player-share-toggle{background:#fff78e;color:#22261e;border-color:#fff78e}\n.hg-player-share-link{width:100%;min-height:44px;margin-top:12px;border:1px solid #4a5049;border-radius:8px;padding:10px;background:#0c110e;color:#f6f6ee;font:12px system-ui,sans-serif}\n.hg-player-sections{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:24px;padding-top:24px;border-top:1px solid #354235}\n.hg-player-section h2{margin:0 0 12px;font-size:15px;font-weight:500;color:#c4cec0}\n.hg-player-menu-actions{display:flex;flex-direction:column;gap:8px}\n.hg-player-menu-actions>button{width:100%;min-height:44px;text-align:left}\n.hg-player-action-help{display:block;color:#b7bfb5;font-size:12px;margin-top:4px}\n.hg-player-menu-footer{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:12px;margin-top:24px;padding-top:20px;border-top:1px solid #354235}\n.hg-player-menu .hg-player-leave{display:inline-flex;align-items:center;justify-content:center;min-height:44px;padding:10px 18px}\n.hg-player-status{color:#b7bfb5;white-space:pre-wrap;overflow-wrap:anywhere;margin:24px 0 0;font-size:12px}\n.hg-player-brand{display:inline-flex;align-items:center;min-height:44px;padding:10px 14px}\n.hg-player-name{max-width:420px;margin:0 auto 24px;display:flex;align-items:end;flex-wrap:wrap;gap:8px}.hg-player-name label{display:block;flex:1;min-width:160px}\n.hg-player-name input{display:block;width:100%;min-height:44px;margin-top:8px;padding:10px;font:inherit;font-size:16px;color:inherit;background:#0c110e;border:1px solid #4a5049;border-radius:10px}\n.hg-player-name p{width:100%;color:#c4cec0;margin:0;overflow-wrap:anywhere;font-size:12px}\n.hg-player-attention{position:absolute;top:calc(60px + var(--hg-safe-top));left:calc(8px + var(--hg-safe-left));max-width:min(420px,calc(100% - 16px - var(--hg-safe-left)));padding:14px;background:#352c20;border:1px solid #8a7855;border-radius:12px;pointer-events:auto;box-shadow:0 8px 32px #0006}\n.hg-player-attention p{margin:0 0 10px;overflow-wrap:anywhere}\n@media(max-width:640px){.hg-player-sections{grid-template-columns:1fr;gap:20px}.hg-player-menu-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr))}}\n@media(max-width:480px){.hg-player-menu{padding: max(16px,env(safe-area-inset-top)) max(16px,env(safe-area-inset-right)) max(16px,env(safe-area-inset-bottom)) max(16px,env(safe-area-inset-left))}.hg-player-menu-header{gap:8px;margin-bottom:24px}.hg-player-menu-brand{font-size:14px}.hg-player-menu-brand img{width:24px;height:24px}.hg-player-menu .hg-player-menu-close{padding:10px}.hg-player-share-qr{width:208px}.hg-player-share-link{font-size:16px}}\n";const l=o("hg-player-home","");l.setAttribute("aria-label","Open Homegames menu"),l.setAttribute("aria-haspopup","dialog"),l.setAttribute("aria-expanded","false"),l.title="Homegames menu";const c=n("img","");c.alt="",c.width=c.height=32,c.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAIbElEQVRYR7WXC1BU5xmGn7M3rgICYRHjBQSiBUIUTQQ0oEZTIRdTihcy04xO22mbSWKTTDQql2jNbdKk06S2TdqmaWrspMk0tHViiEpqEEyCGmhEq0gEXS4r7HJZll2WPX/nnLO7LEhsOp3+Mwxw9j//9/7v973v9620cOHCpKSkab9blJ2wSq/XGfh/LwFjsjx2usl6pLt7eLNUXHz7oTde/eadcbFhWmgBQgIJgUBC+h8BKacop00+p882wgPfPfSBVL7j257d5fkGbdv4EsL/qvbc/7ny++ssBTyyjKSTkKSpr1Gx57hHqiovFZU7V4EY8Z2rhdrwncMMDnlU7BPeVz+eDNdHne8KQoAsBCGhISSazdya7GTL1iWBC/rfrnq6HqmqfIOo3HUXyL2BFKCDbRXtHDt2gp6eHvUWCgVRRiODHo9GiSwIIAtiy/9MYVB5J2dxDsuT3Dy8twAM+gnk+QBsFJW77gbZOs6AJLH3BTvV1e9jsVjUgMqlf7W+kG3V9USajLy+ppDdJ0+xaFossyIjOdLdyS1JZowmwe6PTvpyJpGVmcnam0w8sud2MAXVuIDKZwIMKACuTgCwvaKdo7XHsXRatMIE9m8p5u0Pm1m5dC4mg57pYdEkRZuYPiDhjoYuvZ5+ay8PvFmDEFruMzMzKUo38dDeAiTjJAb2qgDWi8qd6xCiFwmvBkKCR7e3Unf8U40B5ZEkcfgHmxh1OegQLvqdHgpnmOmQBPMU9U4LZ8zl5d32L3j+T59qRStJ5Ofnk2t2snVvIUwGEKiB8m+B3AfCPQWAzgAzBx7cxO9rT3JHlpmspFTkkV4coZGkm4wMhoXy5fmLtPQN81zNiQDodevWMU9q58dPXw9ARSl4e8eVIMHWJ85T39AYYEA58b6FqbT09HJf3gJiB3X8yzRIavh02vtspMyMp/3MVdLzZvHIy4cCAMrKykh0tvDosyvAoAuIXRH5U083+FRQvkFTgRj2MSAovf8j2ju6AgDmL78DecyN5exZbi3ZQP3+18guXo+to5VLTadYtmkzXxyuJnPlvTTX/AVbj1VNgQLA7GzhsWdXIAx6TYo+HY7LsLxMCy73+KQouGd9Dd09fQEA237+E/qGvDSfOM3tKzKw2Vyk3LYMEZqArbmWcJMbXUQiMfE30FhTzYFX3lIVWVRURLrRwuPPrQySoWZnVeMM3A+yHYTN58aCH25t4dSppoAKVtxTTEFpCQdf+xlL79tE5k3zuNjayoz5GcToZa5YrZyr/RsRC4o4+FIllo6rKgNZWVmsSJZ44vlV1/hA5bgRlYKwBopQMZEdu7s5cuQoFkuXylnmslzyVq0m/Rtx1LxXy90bS+jquEzs/ExMDhtNdR9yutmKY2CYgrtW8VrFHhVARkYGBXP17PipBiDYQ30ANoqKnfciie5AcpQCeWzHJerq6rFYFBVI3PXQI+TnzuPsyVZuSE2lp7mO6NlpzLoplQt1h4nLXov70se445aQEnqZbd+rUoNlZWZRmKxju8LA1DJUnPCe8fz7klC2pZ6LFzvo6uxSfcFo1GFOiKCr28HcOTFcbLMTHx/OwIALvV5iekwo1t5hEm6IYNTt5WqvE51OR3Z2NoVzBI8pVhxi/CorngwASspqcDjGUD19ihWg0t8qfQam9nL17lqrSElOITO8iwefKmDEK2g+04t9SPF2He++06TIcFIv8J3c39iBo92O1yuPN2qdRN+QB48smBFtCjQvrXH7BeT/2wdEQHiogVr9bM5dTSI5bzV2lwe3vZeGd94cByBk64S+779F8OWVoxtOdJG3dMaUrEz10OsVvHjATbc8l9mLcjGGhuAntfbXLwa1Y8UJ/Wvy/OBj5czZPszmcOJ901PwXScH96fo8HE7ZxzL0CdnBAYTJTXKvFDzygu+ZrSrGGQbQ0OjnD9uBYNEzh1J14xkxxs6yc9N+tq3VzbuPxLDYEI+clikSqrX6cAQEYnD5eHYqy8pAJSJqAhEP22XBhj8bT8WSaZ499wJALyyzJkWGzdnxk0e3ib9r+Hr7RuhqcXBwaY4ZubfTWhkJMLj4kLDx8y8eTF2YeKff/yFH8BKhHDR0T5I2x/aabMNsOWlZRNmxI4rQ0RNCyHGX3xBnj6ZEoXJl2tuxDw3A5cxgguN9aQtX62qYqTfjtMQxpBrjJa39iFV7VIYyFPP8Hi8nG/t59x5GyX3pgWahpLPzxq7uXVx4qRYU82GcPQfl3mvczlExasF57S0kbHkNgwR0+hzuHF6xtTLqQB2bC8Rjz+8GJ1Oi6f8DDs8NJ62snhhAgajnk8/62bBgjgiwrWRSis+4avmoLFb0sbvY5/YsaQ8RPfwqDrKDVst6OUxwhLnqDYhZBnvqItzb/8G6dE1a8T3k5PVU9Vu7RuBlWPtzmGcHg8zY2PBaFDNwy9+oexTNikDq06nTs+qaY2OcmJ4BPuDFVgGXGpA2TNKV937xMxOQa/TodfriYoMp/nv7yDtLCoST6T56A64mS+OP4bJhBQZca01KCAUAJJOBS68MmLUTd2VK3yy+UmcsqZnr2cU0dbMjWnzYagfp1fGiJcTf/1zEIDrimvqXOuio8HpRFZG9aD1pWOIN1aXYTDPVp86Oi8h6fREJM6asO/sgV9OBHBtmKkDX98IBF4BVRHxuNJziJqTykD1G0TeWYo+LEJ9VTNpQcv+fUjb1671PJmWbvDPSl/3+6CS70C9BH1H8YPrGxjg4zFlBNCTO2Sn1RCCNSwcvceDwe0mZHSEalufR1qbl3do3y233BlrnNgq/5Pd/XfcjO/WvtkJbGNj/Ojzzz+QcnJyZiSEhLyeHRW1UidJX4kiuOteD5yfXlUVX7FRFsLTNDh41Op2b/43wV/aTZKTkWoAAAAASUVORK5CYII=",l.append(c);const d=n("div","hg-player-attention");d.hidden=!0;const u=n("p","");u.setAttribute("role","alert");const p=o("","Open menu");d.append(u,p),a.append(h,l,d);const f=n("dialog","hg-player-menu");f.setAttribute("aria-label","Homegames menu");const m=n("div","hg-player-menu-content"),g=n("div","hg-player-menu-header"),y=n("div","hg-player-menu-brand"),v=n("img","");v.src=c.src,v.alt="",y.append(v,n("span","","Homegames"));const w=o("hg-player-menu-close","Back to game");g.append(y,w);const x=n("div","hg-player-heading"),b=n("h1","hg-player-title"),E=n("span",""),S=n("span","hg-player-author");b.append(E,S),x.append(b);const k=n("div","hg-player-sections"),_=new Map;let C=!1,A=!1;const I=[["together","Session"],["downloads","Downloads"],["tools","Game tools"]];for(const[e,t]of I){const s=n("section","hg-player-section");s.setAttribute("aria-label",t);const r=n("h2","",t),i=n("div","hg-player-menu-actions");s.append(r,i),k.append(s),_.set(e,{panel:s,list:i})}const T=n("string"==typeof t.home?"a":"button","hg-player-leave","Leave game");T.hidden=!t.home,"string"==typeof t.home?T.href=t.home:(T.type="button",T.onclick=()=>{oe(),t.home?.()});const P=n("p","hg-player-status");P.setAttribute("role","status"),P.setAttribute("aria-atomic","true");const L=n("a","hg-player-brand","homegames.io");L.href="https://homegames.io/",L.target="_blank",L.rel="noopener noreferrer";const M=n("div","hg-player-menu-footer");M.append(L,T);const R=n("form","hg-player-name");R.hidden=!0;const N=n("label","","Your name"),O=n("input","");O.type="text",O.maxLength=32,O.required=!0,O.autocomplete="nickname",O.setAttribute("aria-label","Your name"),N.append(O);const U=o("","Save name");U.type="submit";const B=n("p","");B.setAttribute("role","status"),R.append(N,U,B);let D,j="",q=!1;O.oninput=()=>{q=!0},R.onsubmit=async e=>{if(e.preventDefault(),D&&!U.disabled){U.disabled=!0;try{j=await D(O.value),O.value=j,q=!1,B.textContent="Name updated for this session."}catch(e){B.textContent=e.message||String(e)}finally{U.disabled=!1}}};const H=n("section","hg-player-sharing");H.hidden=!0,H.setAttribute("aria-label","Invite and share");const V=n("div","hg-player-share-qr");V.hidden=!0;const z=n("p","hg-player-share-caption"),F=n("p","hg-player-share-status");F.setAttribute("role","status");const G=n("div","hg-player-share-actions"),$=o("hg-player-share-toggle","Share with friends"),K=o("","Copy link"),W=o("","Try again"),Y=n("input","hg-player-share-link");Y.readOnly=!0,Y.hidden=!0;const J=n("p","hg-player-share-note");G.append($,K,W),H.append(V,z,F,G,Y,J),m.append(g,x,H,R,k,P,M),f.append(m),s.body.append(f);let X,Z="session",Q=0,ee="",te=!1;const se={session:"",copy:""};function re(){const e=!1===X?.multiplayer,t=e&&!te;z.textContent=t?"Share a playable copy of this game with your friends.":"session"===Z?"Use the QR code to invite a friend to your multiplayer session":"Use the QR code to share a playable copy of this game with your friends.",$.textContent=e||"session"===Z?"Share with friends":"Invite to session",$.hidden=!1===X?.copy||e&&te,K.hidden=t,Y.setAttribute("aria-label","session"===Z?"Invitation link":"Game copy link"),J.textContent=t?"":"session"===Z?"Keep this game open while you play together.":"Keep this game open while they download."}async function ie(){if(!X||!f.open||A)return;const e=++Q,t=X,r=Z;if(ee="",V.hidden=!0,V.replaceChildren(),Y.value="",Y.hidden=!0,K.disabled=!0,W.hidden=!0,re(),!1!==X.multiplayer||te){F.textContent="session"===r?"Creating invitation…":"Preparing game copy…";try{const i=await t.getLink(r);if(e!==Q||!f.open||A)return;if("string"!=typeof i?.url||i.url.length>8192||!["http:","https:"].includes(new URL(i.url).protocol))throw new Error("Could not create a sharing link. Try again.");!function(e,t){const r=e?.length;if(!Array.isArray(e)||r<21||r>177||(r-21)%4||e.some(e=>"string"!=typeof e||e.length!==r||!/^[01]+$/.test(e)))throw new Error("Could not create the QR code. Try again.");const i=s.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("viewBox",`0 0 ${r+8} ${r+8}`),i.setAttribute("role","img"),i.setAttribute("aria-label","session"===t?"Join session QR code":"Share game copy QR code"),i.setAttribute("shape-rendering","crispEdges");const n=s.createElementNS(i.namespaceURI,"rect");n.setAttribute("width",r+8),n.setAttribute("height",r+8),n.setAttribute("fill","#fff");const o=s.createElementNS(i.namespaceURI,"path");o.setAttribute("fill","#000");let a="";e.forEach((e,t)=>{for(let s=0;s<r;s++)if("1"===e[s]){const i=s;for(;s+1<r&&"1"===e[s+1];)s++;const n=s-i+1;a+=`M${i+4} ${t+4}h${n}v1h-${n}z`}}),o.setAttribute("d",a),i.append(n,o),V.replaceChildren(i),V.hidden=!1}(i.qr,r),ee=i.url,Y.value=ee,Y.hidden=!1,K.disabled=!1,F.textContent=se[r]||""}catch(t){if(e!==Q||!f.open||A)return;F.textContent=t.message||String(t),W.hidden=!1}}else F.textContent=""}$.onclick=()=>{Z=!1===X?.multiplayer||"session"===Z?"copy":"session","copy"===Z&&(te=!0),ie()},W.onclick=()=>ie(),K.onclick=async()=>{if(!ee)return;const t=Q,s=ee;try{await e.navigator.clipboard.writeText(s),t===Q&&f.open&&(F.textContent="Link copied")}catch(e){if(t!==Q||!f.open)return;Y.focus(),Y.select(),F.textContent="Copy the selected link"}};const ne=()=>{C&&(C=!1,Q++,l.setAttribute("aria-expanded","false"),t.onClose?.())};function oe(){f.open&&f.close(),ne()}function ae(e){if(!A){if(!f.open){O.value=j,q=!1,B.textContent="",C=!0,Z=!1===X?.multiplayer?"copy":"session",l.setAttribute("aria-expanded","true"),t.onOpen?.();try{f.showModal()}catch(e){throw ne(),e}}("copy"===e&&!1!==X?.copy||"session"===e&&!1!==X?.multiplayer)&&(Z=e,"copy"===e&&(te=!0)),ie(),w.focus()}}function he(){for(const[e,t]of r)t.button.hidden=!!t.value.hidden||!!X&&["share","copy-share"].includes(e);for(const[e,t]of _)t.panel.hidden=!Array.from(r.values()).some(t=>t.group===e&&!t.button.hidden);k.hidden=Array.from(_.values()).every(e=>e.panel.hidden)}function le(e){d.hidden=!e||!P.textContent,u.textContent=d.hidden?"":P.textContent,p.textContent=r.has("retry")?r.get("retry").value.label:"Open menu"}let ce,de,ue,pe,fe;l.onclick=()=>ae(),w.onclick=oe,f.addEventListener("close",()=>{f.open||ne()}),p.onclick=()=>r.has("retry")?ve.runAction("retry"):ae();const me=(e,t,s)=>{const r=Math.min(e,t*s);return r*(r/s)};function ge(){if(!ce||!de||A)return;const t=de.clientWidth,s=de.clientHeight;if(!(t>0&&s>0))return;const r=e.getComputedStyle?.(a),i=e=>Math.max(0,parseFloat(r?.getPropertyValue("--hg-safe-"+e))||0),n=i("left"),o=i("top"),h=i("right"),l=i("bottom"),c=Math.max(1,t-n-h),d=Math.max(1,s-o-l),u=pe?pe.x/pe.y:c/d,p=Math.min(c,d*u);let f,m=n,g=o,y=c,v=d;(c-p)/2>=60?f="left-bar":(d-p/u)/2>=60?f="top-bar":me(Math.max(1,c-60),d,u)>=me(c,Math.max(1,d-60),u)?(m+=Math.min(60,c-1),y=Math.max(1,c-60),f="left-strip"):(g+=Math.min(60,d-1),v=Math.max(1,d-60),f="top-strip");const w={position:"absolute",left:m+"px",top:g+"px",width:y+"px",height:v+"px",minHeight:"0",minWidth:"0"};for(const[e,t]of Object.entries(w))ce.style[e]!==t&&(ce.style[e]=t);a.setAttribute("data-layout",f)}function ye(){if(ue?.disconnect(),ue=null,e.removeEventListener?.("resize",ge),e.visualViewport?.removeEventListener("resize",ge),fe){for(const[e,t]of Object.entries(fe.areaStyle))ce.style[e]=t;de.style.position=fe.position}fe=null,ce=de=null}const ve={bar:a,menu:f,statusElement:P,setGameArea(t,s=t?.parentElement){if(t!==ce||s!==de){if(ye(),t&&s&&!A){ce=t,de=s,fe={position:de.style.position,areaStyle:{}};for(const e of["position","left","top","width","height","minHeight","minWidth"])fe.areaStyle[e]=t.style[e];["relative","absolute","fixed"].includes(e.getComputedStyle?.(de)?.position)||(de.style.position="relative"),a.parentElement!==de&&de.append(a),e.ResizeObserver&&(ue=new e.ResizeObserver(ge),ue.observe(de)),e.addEventListener?.("resize",ge),e.visualViewport?.addEventListener("resize",ge),ge()}}else ge()},setAspectRatio(e){!e||!Number.isFinite(e.x)||!Number.isFinite(e.y)||e.x<=0||e.y<=0||!Number.isFinite(e.x/e.y)||e.x/e.y<=0||pe?.x===e.x&&pe?.y===e.y||(pe={x:e.x,y:e.y},ge())},setTitle(e){E.textContent=E.title=e||"Homegames"},setAuthor(e){S.textContent="string"==typeof e&&e.trim()?" by "+e.trim().slice(0,200):"",S.title=S.textContent.trim(),S.hidden=!S.textContent},setStatus(e,t={}){P.textContent=e||"",le(t.attention??r.has("retry"))},setPlayerName(e,t){j=e,D=t,R.hidden=!t,f.open&&q||(O.value=e)},setSharing(e){const s=!e||"function"!=typeof e.getLink||!1===e.multiplayer&&!1===e.copy?null:e,r=X?.getLink===s?.getLink,i=!1===X?.multiplayer,n=!1!==X?.copy;r||(Q++,X?.dispose?.(),te=!1,se.session=se.copy="",V.hidden=!0,Y.hidden=!0,ee=""),X=s,H.hidden=!X,he(),X&&((!r||"session"===Z&&!1===X.multiplayer||"copy"===Z&&!1===X.copy)&&(Z=!1===X.multiplayer?"copy":"session"),re(),!f.open||r&&i===(!1===X.multiplayer)&&n===(!1!==X.copy)||ie(),!1!==X.multiplayer&&t.onActionReady?.("share"),!1!==X.copy&&t.onActionReady?.("copy-share"))},setSharingStatus(e,t="copy"){["session","copy"].includes(t)&&(se[t]="string"==typeof e?e.slice(0,300):"",f.open&&Z===t&&ee&&(F.textContent=se[t]))},setAction(e,s){if(!s){const t=r.get(e);return t&&(t.button.hidden=!0,t.button.remove(),r.delete(e)),he(),void("retry"===e&&le(!1))}let a=r.get(e);a||(a={button:o("",s.label)},r.set(e,a));const h=a.button;a.value=s,a.group=_.has(s.group)?s.group:(e=>["share","copy-share","manual-connect","privacy"].includes(e)?"together":["install","download-html","download-zip"].includes(e)?"downloads":"retry"===e?"together":"tools")(e),_.get(a.group).list.append(h),h.textContent=s.label,h.title=s.title||"",s.id&&(h.id=s.id),h.hidden=!!s.hidden,h.disabled=!!s.disabled||i.has(e),h.setAttribute("data-action",e),s.title&&h.append(n("span","hg-player-action-help",s.title)),h.onclick=()=>{if(i.has(e)||h.disabled||A)return;if(X&&["share","copy-share"].includes(e))return void ae("share"===e?"session":"copy");f.open&&oe(),i.add(e),h.disabled=!0;const t=()=>{i.delete(e),h.disabled=!!r.get(e)?.value.disabled};try{Promise.resolve(s.run()).catch(e=>ve.setStatus(e.message||String(e),{attention:!0})).finally(t)}catch(e){t(),ve.setStatus(e.message||String(e),{attention:!0})}},he(),"retry"===e&&le(!0),t.onActionReady?.(e)},runAction(e){if(A)return!1;if(X&&["share","copy-share"].includes(e))return!("share"===e&&!1===X.multiplayer||"copy-share"===e&&!1===X.copy||(ae("share"===e?"session":"copy"),0));const t=r.get(e);return!(!t||t.button.disabled||(t.button.click(),0))},openMenu(){ae()},dispose(){A||(oe(),ye(),A=!0,Q++,X?.dispose?.(),f.remove(),a.remove())}};a.homegamesToolbar=ve,ve.setTitle(t.title),ve.setAuthor(t.author),ve.setStatus(t.status);for(const[e,s]of Object.entries(t.actions||{}))ve.setAction(e,s);return he(),ve}}},5564(e){"use strict";e.exports={attachClientHost:function(e,t,s,r,i,n,o,a={}){const h=e.document;let l,c,d,u,p=0,f=!1,m=a.toolbar,g=!1,y=a.title;const v=new Map,w=new Map;function x(e,t){return!l||f?Promise.reject(new Error("The player is not ready")):new Promise((s,r)=>{const i=++p,n=setTimeout(()=>{v.delete(i),r(new Error("Game download timed out"))},6e4);v.set(i,{resolve:s,reject:r,timer:n,format:e}),l.postMessage({type:"download-game",id:i,format:e,name:t})})}const b=(e,t={})=>{a.onPlayerStatus?a.onPlayerStatus(e,t):m?.setStatus(e,t)};function E(e,t){l&&!f&&l.postMessage({type:"player-control",action:e,value:t})}function S(e){if(!l||f)return Promise.reject(new Error("The player is not ready"));if(!["session","copy"].includes(e))return Promise.reject(new Error("Unknown sharing option"));if(w.has(e))return w.get(e);const t=new Promise((t,s)=>{const r=++p,i=setTimeout(()=>{v.delete(r),s(new Error("Creating an invitation timed out. Try again."))},35e3);v.set(r,{resolve:t,reject:s,timer:i,sharing:!0}),l.postMessage({type:"player-share",id:r,mode:e})});return w.set(e,t),t.finally(()=>{w.get(e)===t&&w.delete(e)}).catch(()=>{}),t}async function k(t){try{const s="function"==typeof a.downloadName?a.downloadName():a.downloadName;let r=String(s||y||"game").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)||"game";/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/.test(r)&&(r+="-game"),b("Preparing game download…");const i=await x(t),n=e.URL.createObjectURL(new Blob([i],{type:"html"===t?"text/html":"application/zip"})),o=h.createElement("a");o.href=n,o.download=r+"."+t,o.click(),setTimeout(()=>e.URL.revokeObjectURL(n),3e4),b("Game copy downloaded")}catch(e){b(e.message,{attention:!0})}}function _(h){if(f||l||h.source!==t.contentWindow||"null"!==h.origin||"homegames-client-connect-v1"!==h.data?.type)return;const p=new e.MessageChannel;l=p.port1,l.onmessage=t=>{const o=t.data;if(!f&&"player-state"===o?.type){"string"==typeof o.title&&(y=o.title.slice(0,200),m?.setTitle(y)),"string"==typeof o.author&&m?.setAuthor?.(o.author.slice(0,200));const e=o.aspectRatio;if(e&&Number.isFinite(e.x)&&Number.isFinite(e.y)&&e.x>0&&e.y>0&&m?.setAspectRatio?.({x:e.x,y:e.y}),"string"==typeof o.status&&b(o.status.slice(0,300),{attention:!0===o.statusAttention}),o.ready){m?.setPlayerName(a.profile?.get()||"",o.playerNames&&a.profile?e=>{if(f)throw new Error("This player has closed. Reopen the game to change your name.");const t=a.profile.set(e);return E("player-name",t),t}:null);for(const[e,t]of[["share","Invite"],["copy-share","Share a copy"],["manual-connect","Manual connection"],["exports","View exports"]]){const s="share"===e&&!1===o.multiplayer;m?.setAction(e,o.inlineSharing&&["share","copy-share"].includes(e)||"exports"!==e&&!o.sharing?null:{label:s?"Invite (solo)":t,disabled:s,title:s?"This is a solo game. Use Share a copy to send it to a friend.":"",run:()=>E(e)})}o.sharing&&o.inlineSharing?u&&u.multiplayer===(!1!==o.multiplayer)||(u={multiplayer:!1!==o.multiplayer,getLink:S,dispose:()=>E("dispose-sharing")},m?.setSharing?.(u)):u&&(m?.setSharing?.(null),u=null),m?.setAction("download-html",{label:"Download game HTML",id:a.htmlId,run:()=>k("html")}),m?.setAction("download-zip",{label:"Download game ZIP",id:a.zipId,run:()=>k("zip")}),a.editGame&&m?.setAction("edit-game",{label:"Edit this game",id:"edit-game",run:()=>a.editGame(()=>x("zip"))})}return}if(!f&&"player-share-status"===o?.type&&"string"==typeof o.status&&["session","copy"].includes(o.mode))return void m?.setSharingStatus?.(o.status.slice(0,300),o.mode);if(!f&&"player-share-result"===o?.type){const e=v.get(o.id);if(!e?.sharing)return;if(v.delete(o.id),clearTimeout(e.timer),o.error)e.reject(new Error(String(o.error).slice(0,300)));else{const{url:t,qr:s}=o;"string"!=typeof t||t.length>4096||!/^https?:\/\//.test(t)||!Array.isArray(s)||s.length<21||s.length>177||(s.length-21)%4!=0||s.some(e=>"string"!=typeof e||e.length!==s.length||!/^[01]+$/.test(e))?e.reject(new Error("Invalid invitation received from the player")):e.resolve({url:t,qr:s})}return}if(!f&&"close-exports"===o?.type)return void d?.close();if(!f&&"view-exports"===o?.type&&Number.isSafeInteger(o.id))return d||!i?void l.postMessage({type:"export-result",id:o.id,error:"Export viewer is unavailable or already open"}):(d=i(e,{list:()=>x("export-list"),read:e=>x("export-file",e)}),void d.result.finally(()=>{d=null,f||l.postMessage({type:"export-result",id:o.id})}));if(!f&&["get-exports","put-export"].includes(o?.type)&&Number.isSafeInteger(o.id))return void Promise.resolve().then(()=>{if(!r)throw new Error("Export storage is unavailable");return"get-exports"===o.type?r.getExports():r.putExport(o.name,o.bytes)}).then(e=>{f||l.postMessage({type:"export-result",id:o.id,value:e})},e=>{f||l.postMessage({type:"export-result",id:o.id,error:e.message})});if(!f&&"cancel-audio"===o?.type)return void(c?.requestId===o.id&&c.close());if(!f&&["record-audio","record-video"].includes(o?.type)&&Number.isSafeInteger(o.id)){if(c)return void l.postMessage({type:"audio-result",id:o.id,error:"A recording is already open"});const t="record-audio"===o.type?s:n;return t?(c=t(e,o.recording||{}),c.requestId=o.id,void c.result.then(e=>{c=null,f||l.postMessage({type:"audio-result",id:o.id,value:e})},e=>{c=null,f||l.postMessage({type:"audio-result",id:o.id,error:e.message})})):void l.postMessage({type:"audio-result",id:o.id,error:"Recording is unavailable"})}const h=v.get(o?.id);f||"game-download"!==o?.type||!h||h.sharing||(v.delete(o.id),clearTimeout(h.timer),o.error?h.reject(new Error(String(o.error).slice(0,300))):"export-list"===h.format||"export-file"===h.format?h.resolve(o.value):o.bytes instanceof Uint8Array&&o.bytes.length&&!(o.bytes.length>1024*("html"===h.format?220:65)*1024)?h.resolve(o.bytes):h.reject(new Error("Invalid game download")))},t.contentWindow.postMessage({type:"homegames-client-port-v1",playerName:a.profile?.get()},"*",[p.port2]),!m&&o&&(m=o(e,{title:a.title,author:a.author,home:a.home,status:"Starting game…",onOpen:()=>E("pause-input"),onClose:()=>E("resume-input")}),g=!0,t.before(m.bar)),m?.setGameArea?.(t,t.parentElement)}return e.addEventListener("message",_),{request:x,command:E,download:k,close(){E("dispose-sharing"),f=!0,u&&(m?.setSharing?.(null),u=null),e.removeEventListener("message",_),l?.close(),g&&m?.dispose(),c?.close(),d?.close();for(const e of v.values())clearTimeout(e.timer),e.reject(new Error("Player closed"));v.clear(),w.clear()}}},connectClientSource:function(e,t,s={},r={}){let i,n,o,a,h=!1,l=0;const c=new Map,d=new Promise(e=>{n=e}),u=setTimeout(n,15e3),p=l=>{!h&&l.source===e.parent&&"homegames-client-port-v1"===l.data?.type&&l.ports[0]&&(e.removeEventListener("message",p),i=l.ports[0],a=l.data.playerName,clearTimeout(u),n(),o&&i.postMessage({type:"player-state",...o}),i.onmessage=async e=>{const n=e.data;if(!h&&"player-share"===n?.type&&Number.isSafeInteger(n.id)&&["session","copy"].includes(n.mode))try{if("function"!=typeof r["sharing-link"])throw new Error("Inline sharing is unavailable");const e=await r["sharing-link"](n.mode);h||i.postMessage({type:"player-share-result",id:n.id,...e})}catch(e){h||i.postMessage({type:"player-share-result",id:n.id,error:e.message})}else if(h||"player-control"!==n?.type||!Object.hasOwn(r,n.action)){if("audio-result"===n?.type||"export-result"===n?.type){const e=c.get(n.id);if(!e)return;return c.delete(n.id),clearTimeout(e.timer),void(n.error?e.reject(new Error(n.error)):e.resolve(n.value))}if(!h&&"download-game"===n?.type&&Number.isSafeInteger(n.id)&&["html","zip","export-list","export-file"].includes(n.format))try{const e="export-list"===n.format?{value:await s.list()}:"export-file"===n.format?{value:await s.read(n.name)}:{bytes:await t(n.format)};h||i.postMessage({type:"game-download",id:n.id,...e})}catch(e){h||i.postMessage({type:"game-download",id:n.id,error:e.message})}}else try{"player-name"===n.action&&(a=n.value),await r[n.action](n.value)}catch(e){i.postMessage({type:"player-state",status:e.message,statusAttention:!0})}})};e.addEventListener("message",p),e.parent.postMessage({type:"homegames-client-connect-v1"},"*");const f=(e,t={})=>new Promise((s,r)=>{if(h||c.size>=128)return void r(new Error("Client adapter unavailable or busy"));const n=++l,o={resolve:s,reject:r,recordingId:t.recording?.id,type:e};o.timer="view-exports"===e?null:setTimeout(()=>{c.delete(n),"record-audio"!==e&&"record-video"!==e||i?.postMessage({type:"cancel-audio",id:n}),r(new Error("Client request timed out"))},9e4),c.set(n,o),d.then(()=>{if(c.has(n))return h||!i?(clearTimeout(o.timer),c.delete(n),void r(new Error("Client adapter is unavailable"))):void i.postMessage({type:e,id:n,...t})})});return{setState(e){o={...o,...e},h||i?.postMessage({type:"player-state",...o})},setSharingStatus(e,t="copy"){h||i?.postMessage({type:"player-share-status",status:e,mode:t})},getPlayerName:async()=>(await d,a),recordAudio:e=>f("record-audio",{recording:e}),recordVideo:e=>f("record-video",{recording:e}),viewExports:()=>f("view-exports"),closeExports(){i?.postMessage({type:"close-exports"})},cancelRecording(e){for(const[t,s]of c)["record-audio","record-video"].includes(s.type)&&s.recordingId===e&&(i?.postMessage({type:"cancel-audio",id:t}),clearTimeout(s.timer),c.delete(t),s.reject(new Error("Recording cancelled")))},getExports:()=>f("get-exports"),putExport:(e,t)=>f("put-export",{name:e,bytes:t}),close(){h=!0,clearTimeout(u),n(),e.removeEventListener("message",p);for(const[e,t]of c)t.recordingId&&i?.postMessage({type:"cancel-audio",id:e}),clearTimeout(t.timer),t.reject(new Error("Player closed"));c.clear(),i?.close()}}},recordAudio:function(e,t){const s=e.document;let r,i,n,o,a=!1;const h=Math.min(30,Math.max(1,Number(t.durationSeconds)||3)),l=Math.min(5242880,Math.max(131072,Number(t.maxBytes)||5242880)),c=s.createElement("dialog");c.setAttribute("aria-label","Record audio"),c.style.cssText="max-width:360px;padding:24px;border-radius:12px;background:#101820;color:white;font:16px/1.5 system-ui";const d=s.createElement("p");d.textContent=String(t.prompt||"Record audio for this game. The host receives the recording.").slice(0,120);const u=s.createElement("p");u.textContent=`Your microphone will record for ${h} seconds.`;const p=s.createElement("button"),f=s.createElement("button");p.textContent="Record audio",f.textContent="Cancel";for(const e of[p,f])e.style.cssText="padding:10px;margin:4px;font:inherit";const m=new Promise((e,t)=>{r=(r,h)=>{a||(a=!0,clearTimeout(o),"recording"===n?.state&&n.stop(),i?.getTracks().forEach(e=>e.stop()),s.removeEventListener("visibilitychange",g),c.close(),c.remove(),r?t(r):e(h))}});f.onclick=()=>r(new Error("Recording cancelled"));const g=()=>{s.hidden&&r(new Error("Recording cancelled because the page was hidden"))};return s.addEventListener("visibilitychange",g),c.oncancel=e=>{e.preventDefault(),f.onclick()},p.onclick=async()=>{p.disabled=!0;try{if(!e.navigator.mediaDevices?.getUserMedia||!e.MediaRecorder)throw new Error("This client cannot record here. Choose an audio file instead.");const s=await e.navigator.mediaDevices.getUserMedia({audio:!0,video:!1});if(a)return void s.getTracks().forEach(e=>e.stop());i=s,n=new e.MediaRecorder(i);const c=[];let d=0;n.ondataavailable=e=>{e.data.size&&(d+=e.data.size,d>5242880?r(new Error("Recording is too large")):c.push(e.data))},n.onstop=async()=>{if(a)return;let s;try{s=new(e.AudioContext||e.webkitAudioContext);const i=await s.decodeAudioData(await new Blob(c).arrayBuffer()),n=22050,o=Math.min(Math.floor(i.duration*n),h*n),a=new Uint8Array(44+2*o);if(!o||a.length>l)throw new Error("Recording is empty or too large");const d=new DataView(a.buffer),u=(e,t)=>{for(let s=0;s<t.length;s++)a[e+s]=t.charCodeAt(s)};u(0,"RIFF"),d.setUint32(4,a.length-8,!0),u(8,"WAVEfmt "),d.setUint32(16,16,!0),d.setUint16(20,1,!0),d.setUint16(22,1,!0),d.setUint32(24,n,!0),d.setUint32(28,2*n,!0),d.setUint16(32,2,!0),d.setUint16(34,16,!0),u(36,"data"),d.setUint32(40,2*o,!0);const p=i.getChannelData(0);for(let e=0;e<o;e++)d.setInt16(44+2*e,Math.round(32767*Math.max(-1,Math.min(1,p[Math.min(p.length-1,Math.floor(e*i.sampleRate/n))]))),!0);let f="";for(let e=0;e<a.length;e+=8192)f+=String.fromCharCode(...a.subarray(e,e+8192));r(null,{type:"media",action:"record-result",id:t.id,data:e.btoa(f),contentType:"audio/wav",fileName:"recording.wav"})}catch(e){r(e)}finally{await(s?.close())}},n.onerror=()=>r(new Error("Recording failed")),n.start(250),u.textContent="Recording…",o=setTimeout(()=>{n.stop(),i.getTracks().forEach(e=>e.stop())},1e3*h)}catch(e){r(e)}},c.append(d,u,p,f),s.body.append(c),c.showModal(),p.focus(),{result:m,close:()=>r(new Error("Recording cancelled"))}}}},5758(e,t,s){"use strict";const{exportArchive:r,LIMITS:i}=s(5110),{attachSaveHost:n}=s(5061),{attachClientHost:o,recordAudio:a}=s(5564),{createExportsViewer:h}=s(97),{recordVideo:l}=s(5900),{createExportStorage:c}=s(739),{createPlayerToolbar:d}=s(8106),{createPlayerIdentity:u}=s(4367),{openGameInStudio:p}=s(32),f=e=>JSON.stringify(e).replace(/</g,"\\u003c"),m=e=>String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),g=e=>{let t=String(e||"game").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)||"game";return/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/.test(t)&&(t+="-game"),`${t}.zip`},y=3*i.archiveBytes+8388608;function v(e){let t="";for(let s=0;s<e.length;s+=8192)t+=String.fromCharCode(...e.subarray(s,s+8192));return btoa(t)}function w(e){const t=atob(e),s=new Uint8Array(t.length);for(let e=0;e<s.length;e++)s[e]=t.charCodeAt(e);return s}function x(e,t,s){const r=()=>e.removeEventListener("message",i),i=e=>{const i=e.data;if(e.source===t.contentWindow&&"null"===e.origin&&"homegames-archive-ready-v1"===i?.type&&/^[a-zA-Z0-9-]{16,80}$/.test(i.nonce||"")){r();try{const e=s();if(!(e instanceof Uint8Array))throw new Error("Missing game archive");const r=new Uint8Array(e);t.contentWindow.postMessage({type:"homegames-archive-v1",nonce:i.nonce,bytes:r},"*",[r.buffer])}catch(e){t.contentWindow.postMessage({type:"homegames-archive-v1",nonce:i.nonce,error:e.message},"*")}}};return e.addEventListener("message",i),{close:r}}function b(e,t){return new Promise((s,r)=>{const i=e.crypto.randomUUID(),n=(t,i)=>{clearTimeout(h),e.removeEventListener("message",a),e.removeEventListener("pagehide",o),t?r(t):s(i)},o=()=>n(new Error("Player closed before receiving the game")),a=s=>{const r=s.data;if(s.source===e.parent&&"homegames-archive-v1"===r?.type&&r.nonce===i)return r.error||!(r.bytes instanceof Uint8Array)||r.bytes.length>t?n(new Error(r.error||"Invalid game archive")):void n(null,r.bytes)},h=setTimeout(()=>n(new Error("The player did not receive its game archive")),3e4);e.addEventListener("message",a),e.addEventListener("pagehide",o),e.parent.postMessage({type:"homegames-archive-ready-v1",nonce:i},"*")})}async function E(e,{clientBundleSource:t,installationId:s,sharing:n={},studioUrl:o,studioDebug:a=!1,externalArchive:h=!1}={}){if(!t?.includes("PortableProject"))throw new Error("Rebuild the Homegames client before playing portable projects");if(!/^[a-zA-Z0-9-]{16,80}$/.test(s||""))throw new Error("Missing local installation ID");const l=new URL(n.signalingUrl||"wss://api.homegames.io/rtc");if(!["ws:","wss:","http:","https:"].includes(l.protocol)||l.username||l.password)throw new Error("Invalid signaling URL");l.protocol="https:"===l.protocol?"wss:":"http:"===l.protocol?"ws:":l.protocol;const c=new URL(n.joinUrl||"https://homegames.io/play.html");if(!["http:","https:"].includes(c.protocol))throw new Error("Invalid invitation URL");const d=new URL(o||"/studio.html",c);if(!["http:","https:"].includes(d.protocol)||d.username||d.password)throw new Error("Invalid Studio URL");const u=new URL(n.receiveUrl||"/game-app.html",c);if(!["http:","https:"].includes(u.protocol))throw new Error("Invalid copy receiver URL");const p={archive:h?void 0:v(await r(e)),installationId:s,studioUrl:d.href,studioDebug:!0===a,sharing:!1!==n&&{signalingUrl:l.href,joinUrl:c.href,receiveUrl:u.href}},g=`default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval'; style-src 'unsafe-inline'; img-src data: blob:; media-src data: blob:; font-src data: blob:; worker-src blob:; connect-src ${!1===n?"'none'":l.origin+l.pathname}; base-uri 'none'; form-action 'none'; frame-src 'none'`;return`<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="${m(g)}"><meta name="viewport" content="width=device-width,initial-scale=1"><style>\nhtml,body{margin:0;height:100%;background:#101820;color:#f7fafc;font:14px system-ui}body{display:flex;flex-direction:column}#game{flex:1;min-height:0;display:flex;align-items:center;justify-content:center;overflow:hidden}#error{padding:16px;color:#ffbaba;white-space:pre-wrap}\n</style></head><body><div id="game"></div><div id="error" hidden></div>\n<script>${t.replace(/<\/script/gi,"<\\/script")}<\/script><script>\n(async()=>{\nconst payload=${f(p)};\nlet client,clientSource,pairing,debug;\nconst state=(status,details={})=>clientSource?.setState({status,statusAttention:details.attention===true});\nconst fail=error=>{document.getElementById('error').hidden=false;document.getElementById('error').textContent=error.message||String(error);state('Unable to play: '+(error.message||String(error)),{attention:true});};\ntry {\nconst project=await HomegamesClient.PortableProject.importArchive(payload.archive===undefined?await (${b.toString()})(window,${i.archiveBytes}):(${w.toString()})(payload.archive));\nconst saveError=error=>{state('Progress not saved: '+error.message,{attention:true});};\nconst saveStore=await HomegamesClient.PortableProject.connectSaveStore(window,{gameKey:'project:'+payload.installationId,versionId:'save-schema:'+project.manifest.saveSchemaVersion,onError:saveError,stop:()=>client?.stop()});\nclientSource=HomegamesClient.PortableProject.connectClientSource(window,async format=>{\nconst copy=await client.requestGameCopy();\nif(format==='zip')return copy.bytes;\nreturn new TextEncoder().encode(await HomegamesClient.PortableProject.buildIsolatedHtml(copy.project,{clientBundleSource:document.scripts[0].textContent,installationId:crypto.randomUUID(),sharing:payload.sharing,studioUrl:payload.studioUrl}));\n},{list:()=>client.listExports(),read:name=>client.readExport(name)}, {\nshare:()=>client.showShare(),exports:()=>client.viewExports(),'sharing-link':mode=>client.getSharingLink(mode),'dispose-sharing':()=>client.disposeSharing(),'manual-connect':()=>pairing?.show(),\n'pause-input':()=>client.setInputEnabled(false),'resume-input':()=>{client.setInputEnabled(true);if(payload.studioDebug)client._localSession?._updateInputAttachment();},'player-name':name=>client.setPlayerName(name)\n});\nconst ready=status=>clientSource.setState({title:project.metadata.name||'Homegame',author:project.metadata.author||project.metadata.createdBy||'',status,statusAttention:false,ready:true,sharing:!!payload.sharing,inlineSharing:true,multiplayer:client._localSession?client._localSession.maxPlayers>1:true,playerNames:typeof client.setPlayerName==='function'});\nclient=new HomegamesClient({containerId:'game',chrome:false,localHome:false,share:payload.sharing,saveStore,platform:clientSource,playerName:await clientSource.getPlayerName?.(),\nloadLocalGame:async()=>HomegamesClient.PortableProject.prepareTrustedLocalGame(project,{trusted:true,installationId:payload.installationId}),\nonReady:()=>{ready('Playing locally');debug?.ready();},onSessionStatus:state,onSharingStatus:(text,mode)=>clientSource.setSharingStatus(text,mode),onError:fail});\npairing=payload.sharing?HomegamesClient.createManualPairing({container:document.body,getSession:()=>client._localSession,\nonOpen:()=>client.setInputEnabled(false),onClose:()=>client.setInputEnabled(true),\njoin:async transport=>{client.stop();client=new HomegamesClient({containerId:'game',chrome:false,transport,share:payload.sharing,platform:clientSource,playerName:await clientSource.getPlayerName?.(),onSharingStatus:(text,mode)=>clientSource.setSharingStatus(text,mode),onReady:()=>{ready('Connected manually to host');debug?.ready();},onClose:()=>state('Host disconnected',{attention:true}),onError:fail});client.start();}}):null;\nif(payload.studioDebug)debug=HomegamesClient.PortableProject.connectStudioDebugSource(window,()=>client._localSession);\nwindow.addEventListener('pagehide',()=>{debug?.close();pairing?.dispose();client.stop();clientSource.close();});client.startLocalGame({});\n}catch(error){fail(error);}\n})();\n<\/script></body></html>`}function S(e,t){const s=e.createElement("iframe");return s.title="Game preview",s.setAttribute("sandbox","allow-scripts allow-pointer-lock"),s.setAttribute("allow","autoplay *; fullscreen *; gamepad *; camera 'none'; microphone 'none'; geolocation 'none'"),s.referrerPolicy="no-referrer",s.srcdoc=t,s}e.exports={runtimeDocument:E,createFrame:S,attachArchiveHost:x,buildIsolatedHtml:async function(e,t){const s=await E(e,{...t,externalArchive:!0}),i=new URL(t.studioUrl||"/studio.html",t.sharing?.joinUrl||"https://homegames.io/play.html").href,y=f({formatVersion:1,document:s,archive:v(await r(e)),name:g(e.metadata.name),title:e.metadata.name||"Homegame",author:e.metadata.author||e.metadata.createdBy||"",studioUrl:i,homeUrl:new URL("/catalog.html",i).href,saves:{packageRevision:e.revision,installationId:t.installationId,gameId:e.manifest.gameId,versionId:"save-schema:"+e.manifest.saveSchemaVersion,compatibility:e.metadata.saveCompatibility||[]}});return`<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover"><title>${m(e.metadata.name||"Homegame")}</title>\n<style>html,body{margin:0;width:100%;height:100%;overflow:hidden;background:#101820;color:#f7fafc;font:14px system-ui}body{position:relative}iframe{display:block;width:100%;height:100%;border:0}[hidden]{display:none!important}</style></head><body>\n<input id="portable-save-file" type="file" accept=".json,application/json" hidden>\n<script id="homegames-project" type="application/json">${y}<\/script>\n<script>const payload=JSON.parse(document.getElementById('homegames-project').textContent);\nconst originalHead=document.head.outerHTML,originalBody=Array.from(document.body.children);\nconst originalHtml=()=>'<!doctype html>\\n<html>'+originalHead+'<body>'+originalBody.map(node=>node.outerHTML).join('\\n')+'</body></html>';\nlet frame,saveHost,clientHost,archiveHost,archive;\nconst getArchive=()=>archive||(archive=(${w.toString()})(payload.archive));\nconst toolbar=(${d.toString()})(window,{title:payload.title,author:payload.author,home:payload.homeUrl,status:'Starting game…',onOpen:()=>clientHost?.command('pause-input'),onClose:()=>clientHost?.command('resume-input')});document.body.prepend(toolbar.bar);\nconst showSaveStatus=(message,details={})=>toolbar.setStatus(message,details);\nconst editGame=getArchive=>{showSaveStatus('Opening Studio…');return (${p.toString()})(window,getArchive,payload.studioUrl).then(()=>showSaveStatus('Editable copy saved in Studio'));};\nasync function mount(){archiveHost?.close();clientHost?.close();if(saveHost)await saveHost.close();frame?.remove();frame=(${S.toString()})(document,payload.document);archiveHost=(${x.toString()})(window,frame,getArchive);saveHost=(${n.toString()})(window,frame,{...payload.saves,onStatus:value=>showSaveStatus(value.message,{attention:value.state==='error'})});clientHost=(${o.toString()})(window,frame,(${a.toString()}),(${c.toString()})(window,payload.saves),(${h.toString()}),(${l.toString()}),(${d.toString()}),{toolbar,editGame,htmlId:'portable-html-copy',zipId:'portable-copy',profile:(${u.toString()})().profile(window)});document.body.appendChild(frame);toolbar.setGameArea(frame,document.body);}\nconst fallback=(bytes,type,name)=>{const url=URL.createObjectURL(new Blob([bytes],{type}));const a=document.createElement('a');a.href=url;a.download=name;a.click();setTimeout(()=>URL.revokeObjectURL(url),30000);};\ntoolbar.setAction('download-html',{label:'Download game HTML',id:'portable-html-copy',run:()=>fallback(originalHtml(),'text/html',payload.name.replace(/\\.zip$/,'.html'))});\ntoolbar.setAction('download-zip',{label:'Download game ZIP',id:'portable-copy',run:()=>fallback(getArchive(),'application/zip',payload.name)});\ntoolbar.setAction('edit-game',{label:'Edit this game',id:'edit-game',run:()=>editGame(getArchive)});\ntoolbar.setAction('save-download',{label:'Download save',id:'portable-save-download',run:()=>saveHost.downloadSave(payload.name.replace(/\\.zip$/,'-save.json'))});\ntoolbar.setAction('save-import',{label:'Load save',id:'portable-save-import',run:()=>document.getElementById('portable-save-file').click()});\nmount();\nwindow.addEventListener('pagehide',()=>archiveHost?.close());\ndocument.getElementById('portable-save-file').onchange=async event=>{const file=event.target.files[0];event.target.value='';if(!file)return;try{if(file.size>1024*1024+4096)throw Error('Save file is too large');const text=await file.text();if(!confirm('Load this save and replace the current progress for this game?'))return;await saveHost.importSave(text);await mount();}catch(error){if(saveHost.stopped)await mount();showSaveStatus(error.message,{attention:true});}};\n<\/script></body></html>`},filename:g,readHtmlArchive:function(e){if("string"!=typeof e||e.length>y)throw new Error("Game HTML is too large");const t=e.indexOf('<script id="homegames-project" type="application/json">'),s=e.indexOf("<\/script>",t+55);if(t<0||s<0)throw new Error("Choose a Homegames HTML bundle or project ZIP");const r=JSON.parse(e.slice(t+55,s));if(1!==r.formatVersion||"string"!=typeof r.archive||r.archive.length>4*Math.ceil(i.archiveBytes/3)||/[^A-Za-z0-9+/=]/.test(r.archive))throw new Error("Invalid game HTML archive");const n=w(r.archive);if(n.length>i.archiveBytes)throw new Error("Game archive is too large");return n},htmlBytesLimit:y}},4811(e,t,s){"use strict";const{describeMedia:r}=s(3947);function i(e,t){const s=r(e,{fileName:t});if(s.kind)return s;const i=String.fromCharCode(...e.subarray(0,4)),n={wOFF:"font/woff",wOF2:"font/woff2",OTTO:"font/otf","\0\0\0":"font/ttf"};if(e.length>=12&&n[i])return{kind:"font",contentType:n[i]};const o=(new TextDecoder).decode(e);return!/^\s*(?:<\?xml\b[^?]*\?>\s*)?<svg\b/i.test(o)||!/<\/svg>\s*$/i.test(o)||/<(?:[\w-]+:)?(?:script|foreignObject|style|animate\w*|set)\b|<!DOCTYPE|<!ENTITY|\bon[\w-]+\s*=/i.test(o)||/\b(?:href|src)\s*=\s*(?!["']#)["']/i.test(o)||/url\s*\(\s*(?!["']?#[\w-]+["']?\s*\))/i.test(o)?s:{kind:"image",contentType:"image/svg+xml"}}e.exports={describeAsset:i,validateAsset:function(e,t){if(!e||!["image","audio","video","font"].includes(e.type)||!(t instanceof Uint8Array)||!t.length||t.length>10485716||i(t,e.path).kind!==e.type)throw new Error("Unsupported, invalid or oversized game asset")}}},5110(e,t,s){"use strict";const{zipSync:r,unzipSync:i}=s(595),n=s(8630),{walk:o,literal:a,readSourceMetadata:h,rewriteMetadata:l,normalizeMetadata:c,validateGameId:d}=s(7821),{describeAsset:u}=s(4811),{packAssetBundle:p}=s(3735),f="homegame.json",m=".homegame/inventory.json",g=Object.freeze({files:512,fileBytes:16777216,totalBytes:67108864,archiveBytes:68157440,sourceBytes:1048576}),y=new TextEncoder,v=new TextDecoder("utf-8",{fatal:!0}),w=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),x=e=>{throw new Error(e)},b=e=>"string"==typeof e?y.encode(e):e instanceof Uint8Array?new Uint8Array(e):x("Project files must contain text or Uint8Array bytes"),E=e=>v.decode(e),S=e=>JSON.stringify(k(e));function k(e){if(Array.isArray(e))return e.map(k);if(e&&"object"==typeof e){const t=Object.create(null);for(const s of Object.keys(e).sort())t[s]=k(e[s]);return t}return e}function _(e){("string"!=typeof e||!e.length||e.length>240)&&x("Invalid project path");const t=e.startsWith("./")?e.slice(2):e;/^[A-Za-z0-9_. /-]+$/.test(t)||x(`Unsupported project path: ${e}`);for(const s of t.split("/"))(!s||"."===s||".."===s||/[ .]$/.test(s)||/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(s)||["__proto__","prototype","constructor"].includes(s))&&x(`Unsafe project path: ${e}`);return t}function C(e){const t=new Set;for(const s of e){_(s)!==s&&x(`Non-canonical project path: ${s}`);const e=s.toLowerCase();t.has(e)&&x(`Duplicate or case-colliding project path: ${s}`),t.add(e)}for(const e of t){const s=e.split("/");for(;s.length>1;)s.pop(),t.has(s.join("/"))&&x(`File/directory collision: ${e}`)}}function A(e,t){try{return JSON.parse(E(e))}catch(e){x(`Invalid JSON or UTF-8 in ${t}`)}}async function I(e,t){if(t.sha256)return t.sha256(e);globalThis.crypto?.subtle||x("This browser needs a secure context to validate a project");const s=new Uint8Array(await globalThis.crypto.subtle.digest("SHA-256",e));return Array.from(s,e=>e.toString(16).padStart(2,"0")).join("")}function T(e,t,s){"string"==typeof s&&/^\.\.?\//.test(s)||x(`Unsupported module in ${t}: ${s}`);const r=t.split("/").slice(0,-1);for(const e of s.split("/"))"."!==e&&(".."===e?(r.length||x(`Module escapes project root in ${t}: ${s}`),r.pop()):r.push(e));const i=_(r.join("/"));i.startsWith("user-exports/")&&x("User exports are bytes, not executable modules");const n=[i,`${i}.js`,`${i}.json`,`${i}/index.js`].find(t=>w(e,t));return n&&/\.(js|json)$/.test(n)||x(`Missing JavaScript module or JSON data in ${t}: ${s}`),n}function P(e,t){return e.endsWith(".js")?"text/javascript":e.endsWith(".json")?"application/json":u(t,e).contentType||"application/octet-stream"}async function L(e,t={}){const r=Object.keys(e);r.length>g.files&&x("Project contains too many files"),C(r);const i=Object.create(null);let l=0;for(const t of r){(".homegame"===t.toLowerCase()||t.toLowerCase().startsWith(".homegame/"))&&x("The .homegame directory is reserved for generated inventory");const s=e[t],r="string"==typeof s?y.encode(s).length:s?.byteLength;(!Number.isSafeInteger(r)||r>g.fileBytes||(l+=r)>g.totalBytes)&&x(`Project size limit exceeded at ${t}`),i[t]=b(s)}const p=Object.fromEntries(Object.entries(i).filter(([e])=>e.startsWith("user-exports/")).map(([e,t])=>[e.slice(13),t]));s(5828).validateFiles(p);const m=w(i,f)?A(i[f],f):{formatVersion:2,entry:"index.js"};w(i,f)&&1!==m?.formatVersion&&x(`Unsupported project format: ${m?.formatVersion}`),_(m.entry)===m.entry&&!m.entry.startsWith("user-exports/")&&m.entry.endsWith(".js")&&w(i,m.entry)||x(`Missing or invalid entry: ${m.entry}`);const{metadata:v,assets:k}=function(e,t){const s=Object.create(null);for(const[t,r]of Object.entries(e))if(t.endsWith(".js")&&!t.startsWith("user-exports/")){r.length>g.sourceBytes&&x(`JavaScript file exceeds 1 MiB: ${t}`);try{s[t]=n.parse(E(r),{ecmaVersion:"latest",sourceType:"script"})}catch(e){x(`Cannot parse ${t}: ${e.message}`)}}const r=h(E(e[t.entry]),{requireExport:2===t.formatVersion}),i=r.metadata,l=[],d=new Set,p=new Set;for(const e of Object.values(s))o(e,e=>{if("CallExpression"===e.type&&"require"===e.callee.name){const t=a(e.arguments[0],"require()");"string"==typeof t&&/^squish-[0-9]+$/.test(t)&&p.add(t.slice(7))}});(p.size>1||2===t.formatVersion&&1!==p.size)&&x("Project needs exactly one supported Squish runtime import");const f=[...p][0]||t.runtime?.squishVersion;1===t.formatVersion?(i.squishVersion!==t.runtime.squishVersion&&x("metadata.squishVersion must match homegame.json"),f!==t.runtime.squishVersion&&x("Runtime mismatch with homegame.json"),void 0!==i.gameId&&i.gameId!==t.gameId&&x("metadata.gameId must match homegame.json"),void 0!==i.saveSchemaVersion&&i.saveSchemaVersion!==t.saveSchemaVersion&&x("metadata.saveSchemaVersion must match homegame.json")):(t.gameId=i.gameId,t.saveSchemaVersion=i.saveSchemaVersion??1,t.runtime={squishVersion:f});const m=c(i,{runtime:f,legacy:1===t.formatVersion});for(const{key:t,info:s,node:i}of r.assets){void 0!==s.id&&x(`Asset ${t} still uses a hosted asset ID; convert it to a project path`);const r=_(s.path);w(e,r)||x(`Missing asset "${t}": ${r}`);const n=u(e[r],r);["image","audio","video","font"].includes(s.type)&&n.kind===s.type||x(`Unsupported or invalid ${s.type} asset "${t}": ${r}`),l.push({key:t,path:r,type:s.type}),d.add(i.start)}for(const[r,i]of Object.entries(s))o(i,s=>{if("NewExpression"!==s.type||"Asset"!==s.callee.name||r===t.entry&&d.has(s.start)||2===s.arguments.length||x(`Declare portable assets in the entry metadata.assets or supply bytes: ${r}`),"CallExpression"===s.type&&"require"===s.callee.name){const i=a(s.arguments[0],`require() in ${r}`);if(i===`squish-${t.runtime.squishVersion}`)return;"string"==typeof i&&i.startsWith("squish-")&&x(`Runtime mismatch in ${r}: ${i}`);const n=T(e,r,i);n.endsWith(".json")&&A(e[n],n)}});return{metadata:m,assets:l}}(i,m);d(m.gameId),(!Number.isSafeInteger(m.saveSchemaVersion)||m.saveSchemaVersion<1)&&x("Invalid saveSchemaVersion");const L=m.runtime?.squishVersion;Array.isArray(t.supportedRuntimes)&&t.supportedRuntimes.includes(L)||x(`Unsupported runtime: squish-${L}. Supported: ${(t.supportedRuntimes||[]).join(", ")}`),k.some(e=>44+i[e.path].length>10485760)&&x("An asset exceeds the current 10 MiB RTC packet limit");const M=[];for(const e of r.sort())M.push({path:e,byteLength:i[e].length,mediaType:P(e,i[e]),sha256:await I(i[e],t)});const R=await I(y.encode(S({manifest:m,files:M})),t),N=Object.freeze({listFiles:()=>[...r],readFile:e=>{const t=_(e);return w(i,t)||x(`Missing project file: ${t}`),i[t].slice()},stat:e=>{const t=_(e),s=M.find(e=>e.path===t);return s||x(`Missing project file: ${t}`),{...s}}});return{manifest:m,metadata:v,assets:k,revision:R,inventory:M,reader:N}}e.exports={checkSyntax:function(e){try{return n.parse(e,{ecmaVersion:"latest",sourceType:"script"}),null}catch(e){return{message:e.message,line:e.loc?.line||1}}},thumbnailPath:function(e){try{const t=w(e,f),s=t?_(A(b(e[f]),f).entry):"index.js",r=b(e[s]);if(r.length>g.sourceBytes)return null;if(!t){const{metadata:t}=h(E(r),{requireExport:!0,strictAssets:!1}),s=_(t.thumbnail);return w(e,s)?s:null}const i=n.parse(E(r),{ecmaVersion:"latest",sourceType:"script"}),l=[],c=new Map;o(i,e=>{"MethodDefinition"===e.type&&e.static&&!e.computed&&"metadata"===(e.key.name??e.key.value)&&l.push(e)});const d=l[0]?.value.body.body;if(1!==l.length||1!==d.length||"ReturnStatement"!==d[0].type||"ObjectExpression"!==d[0].argument?.type)return null;for(const e of i.body)if("VariableDeclaration"===e.type&&"const"===e.kind)for(const t of e.declarations)"Identifier"===t.id.type&&c.set(t.id.name,t.init);const u=d[0].argument.properties.find(e=>"Property"===e.type&&!e.computed&&!e.method&&"init"===e.kind&&"thumbnail"===(e.key.name??e.key.value));if(!u)return null;const p=_(a(u.value,"thumbnail",c));return w(e,p)?p:null}catch(e){return null}},LIMITS:g,normalizePath:_,resolveModule:T,createProject:L,exportArchive:async function(e){const t=Object.create(null);for(const s of e.reader.listFiles())t[s]=e.reader.readFile(s);return t[m]=y.encode(S({formatVersion:1,revision:e.revision,files:e.inventory})),r(t,{level:0,mtime:new Date(2020,0,1)})},importArchive:async function(e,t={}){let s,r;try{s=function(e,t=!1){(!(e instanceof Uint8Array)||e.length>g.archiveBytes||e.length<22)&&x("Invalid or oversized project archive");const s=new DataView(e.buffer,e.byteOffset,e.byteLength);let r=e.length-22;for(;r>=Math.max(0,e.length-65557)&&101010256!==s.getUint32(r,!0);)r--;r<Math.max(0,e.length-65557)&&x("Damaged ZIP: missing directory"),(r+22+s.getUint16(r+20,!0)!==e.length||s.getUint16(r+4,!0)||s.getUint16(r+6,!0)||s.getUint16(r+8,!0)!==s.getUint16(r+10,!0))&&x("Unsupported multi-volume or damaged ZIP");const i=s.getUint16(r+10,!0),n=s.getUint32(r+12,!0),o=s.getUint32(r+16,!0);(i>g.files+1||o+n!==r)&&x("Unsupported ZIP directory or too many files");let a=o,h=0;const l=[],c=[];for(let n=0;n<i;n++){(a+46>r||33639248!==s.getUint32(a,!0))&&x("Damaged ZIP directory");const i=s.getUint16(a+8,!0),n=s.getUint16(a+10,!0),d=s.getUint32(a+24,!0),u=s.getUint32(a+20,!0),p=s.getUint16(a+28,!0),f=s.getUint16(a+30,!0),m=s.getUint16(a+32,!0),y=s.getUint32(a+42,!0),v=s.getUint32(a+38,!0)>>>16;(1&i||![0,8].includes(n)||s.getUint16(a+34,!0)||![0,16384,32768].includes(61440&v))&&x("Encrypted files, links and this ZIP compression are unsupported"),(d>g.fileBytes||(h+=d)>g.totalBytes+g.fileBytes)&&x("Expanded ZIP exceeds project size limits"),(a+46+p+f+m>r||y+30>o)&&x("Damaged ZIP entry");const w=E(e.subarray(a+46,a+46+p));t&&w.endsWith("/")?(_(w.slice(0,-1))!==w.slice(0,-1)||d)&&x("Invalid ZIP directory"):l.push(w),67324752===s.getUint32(y,!0)&&s.getUint16(y+6,!0)===i&&s.getUint16(y+8,!0)===n||x("ZIP headers disagree");const b=s.getUint16(y+26,!0),S=y+30+b+s.getUint16(y+28,!0);(S+u>o||E(e.subarray(y+30,y+30+b))!==w)&&x("Damaged ZIP file bounds or name"),c.push({name:w,size:d,offset:y,end:S+u}),a+=46+p+f+m}a!==r&&x("Damaged ZIP directory length"),C(l),new Set(c.map(e=>e.name.toLowerCase())).size!==c.length&&x("Duplicate ZIP entry");for(const e of c.filter(e=>e.name.endsWith("/")))l.some(t=>e.name.toLowerCase().startsWith(t.toLowerCase()+"/")||t.toLowerCase()===e.name.slice(0,-1).toLowerCase())&&x("File/directory collision");return c.sort((e,t)=>e.offset-t.offset),c.some((e,t)=>t&&e.offset<c[t-1].end)&&x("Overlapping ZIP entries"),c}(e),r=i(e)}catch(e){x(`Cannot import project: ${e.message}`)}for(const e of s)r[e.name]?.length!==e.size&&x(`Damaged ZIP file: ${e.name}`);w(r,m)||x("Missing project inventory");const n=A(r[m],m);delete r[m];const o=await L(r,t);return 1===n?.formatVersion&&n.revision===o.revision&&S(n.files)===S(o.inventory)||x("Project integrity check failed: missing, changed or undeclared files"),o},assetBundle:function(e){return p(e.assets.map(t=>({key:t.key,type:t.type,data:e.reader.readFile(t.path)})))},withGameId:function(e,t){d(t);const s=Object.fromEntries(Object.entries(e).map(([e,t])=>[e,b(t)]));if(w(s,f)){const e=A(s[f],f);1!==e.formatVersion&&x("Unsupported legacy project format"),e.gameId=t,s[f]=y.encode(JSON.stringify(e,null,2)+"\n");const r=E(s[e.entry]);void 0!==h(r).metadata.gameId&&(s[e.entry]=y.encode(l(r,{gameId:t})))}else w(s,"index.js")||x("Missing index.js"),s["index.js"]=y.encode(l(E(s["index.js"]),{gameId:t},{requireExport:!0}));return s}}},7435(e,t,s){"use strict";const{normalizePath:r,resolveModule:i,assetBundle:n}=s(5110),o=new TextDecoder("utf-8",{fatal:!0});function a(e,t,{trusted:n=!1}={}){if(!n)throw new Error("Portable game execution requires explicit trust; importing does not run code");const a=e.manifest.runtime.squishVersion,h=t[a];if(!h)throw new Error(`Runtime squish-${a} is not installed`);class l extends s(5911).Asset{constructor(t,i){if(void 0!==i){if(!(i instanceof ArrayBuffer||ArrayBuffer.isView(i)||Array.isArray(i)))throw new Error("Generated assets need byte data");if((i.byteLength??i.length)>10485716)throw new Error("Generated asset exceeds the RTC packet limit");const e=i instanceof ArrayBuffer?new Uint8Array(i):ArrayBuffer.isView(i)?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):Uint8Array.from(i);return s(4811).validateAsset(t,e),void super(t,e)}if(!t||void 0!==t.id)throw new Error("Portable assets must use project paths, not hosted asset IDs");const n=r(t.path);if(!e.assets.some(e=>e.path===n&&e.type===t.type))throw new Error(`Undeclared project asset: ${n}`);const o=e.reader.readFile(n);super({...t,path:n},o)}}const c={...h,Asset:l},d=Object.create(null),u=Object.create(null);for(const t of e.reader.listFiles())/\.(js|json)$/.test(t)&&!t.startsWith("user-exports/")&&(d[t]=o.decode(e.reader.readFile(t)));const p=e=>{if(u[e])return u[e].exports;const t={exports:{}};if(u[e]=t,e.endsWith(".json"))return t.exports=JSON.parse(d[e]),t.exports;const s=t=>t===`squish-${a}`?c:p(i(d,e,t));try{new Function("module","exports","require","__filename","__dirname",d[e])(t,t.exports,s,e,e.split("/").slice(0,-1).join("/"))}catch(t){throw delete u[e],t}return t.exports},f=p(e.manifest.entry);if("function"!=typeof f||!(f.prototype instanceof h.Game))throw new Error("Project entry must export a Squish Game class");return s(2439).bindRuntimeMetadata(f,e.metadata),s(2947).bindGameProject(f,()=>e,{supportedRuntimes:Object.keys(t)},{files:s(5828).projectExports(e)})}e.exports={prepareTrustedLocalGame:function(e,t,{trusted:s=!1,installationId:r}={}){if("string"!=typeof r||!/^[a-zA-Z0-9-]{16,80}$/.test(r))throw new Error("A trusted local installation ID is required for project saves");return{name:e.metadata.name||"Homegame",author:e.metadata.author||e.metadata.createdBy,gameClass:a(e,t,{trusted:s}),assetBundle:e.assets.length?n(e):null,gameKey:`project:${r}`,versionId:`save-schema:${e.manifest.saveSchemaVersion}`,packageRevision:e.revision}}}},5061(e){"use strict";e.exports={attachSaveHost:function(e,t,s){const{installationId:r,gameId:i,versionId:n,compatibility:o=[],onStatus:a=()=>{}}=s;if(!/^[a-zA-Z0-9-]{16,80}$/.test(r)||"string"!=typeof i||!/^save-schema:\d+$/.test(n))throw new Error("Invalid save identity");const h="project:"+r,l=[n,...o.filter(e=>/^save-schema:\d+$/.test(e)).slice(0,32)].filter((e,t,s)=>s.indexOf(e)===t);let c,d,u,p,f,m,g,y=!1,v=0,w=!1,x=null,b=0,E=Promise.resolve();const S=(e,t)=>{try{a({state:e,message:t})}catch(e){}},k=e=>S("error","Progress not saved: "+e.message+" Download a save backup before closing."),_=e=>{const t=JSON.stringify(e);if(void 0===t||(new TextEncoder).encode(t).length>1048576)throw new Error("Save data must be JSON and at most 1 MiB");return JSON.parse(t)};function C(){return s.database?Promise.resolve(s.database):(c||(c=new Promise((t,s)=>{let r=!1;const i=e.indexedDB.open("homegames-portable-saves",1);i.onupgradeneeded=()=>i.result.createObjectStore("saves",{keyPath:["installationId","versionId"]}),i.onerror=()=>s(i.error),i.onblocked=()=>{r=!0,s(new Error("Close other game tabs and reload to update save storage."))},i.onsuccess=()=>{r?i.result.close():(i.result.onversionchange=()=>i.result.close(),t(i.result))}})),c)}function A(e){b++;const t=E.then(e);return E=t.catch(()=>{}).finally(()=>{b--}),t}async function I(){try{const e=await C(),t=await new Promise((t,s)=>{const i=e.transaction("saves","readonly"),n=[];l.forEach((e,t)=>{const s=i.objectStore("saves").get([r,e]);s.onsuccess=()=>{n[t]=s.result}}),i.oncomplete=()=>t(n),i.onabort=()=>s(i.error||new Error("Could not read game save"))});v=t[0]?.generation||0;const s=t.find(Boolean);if(s){if(s.envelope.gameId!==i||!l.includes(s.envelope.versionId))throw new Error("Saved game identity does not match this game");x={...s.envelope,data:_(s.envelope.data)}}return w=!0,S("ready",x?"Game progress restored from this browser":"Game saves stay in this browser"),x}catch(e){return w=!0,g=e,k(e),null}}async function T(e,t=n){if(!w)throw new Error("Load this game before saving");if(x=((e,t=n)=>({gameKey:h,gameId:i,versionId:t,savedAt:Date.now(),data:_(e)}))(e,t),g)throw g;const o=await C(),a=x;await new Promise((e,t)=>{const i=s.transaction?s.transaction(["saves"]):o.transaction("saves","readwrite"),h=i.objectStore("saves");let l;const c=h.get([r,n]);c.onsuccess=()=>{try{if((c.result?.generation||0)!==v)throw new Error("Another tab saved newer progress. Reload to use it, or download this session’s save.");h.put({installationId:r,versionId:n,generation:v+1,envelope:a})}catch(e){l=e,i.abort()}},i.oncomplete=()=>{v++,e()},i.onabort=()=>t(l||i.error||new Error("Browser storage could not save progress"))}),S("saved","Game progress saved in this browser")}const P=e=>{d&&!y&&d.postMessage(e)};function L(s){if(y||d||s.source!==t.contentWindow||"null"!==s.origin||"homegames-save-connect-v1"!==s.data?.type)return;const r=new e.MessageChannel;d=r.port1,d.onmessage=e=>{const t=e.data;if(y||!t||"object"!=typeof t)return;if("closed"===t.type)return void f?.();const{id:s,op:r}=t;if(!Number.isSafeInteger(s)||s<1||!["get","put"].includes(r))return;if(b>=64)return void P({id:s,error:"Too many pending save requests"});if(Object.keys(t).some(e=>!["id","op","data"].includes(e)))return void P({id:s,error:"Invalid save request"});let i;try{"put"===r&&(i=_(t.data))}catch(e){return P({id:s,error:e.message}),void k(e)}A(async()=>{if(y)throw new Error("Game session closed");return"get"===r?w?x:I():T(i)}).then(e=>P({id:s,value:e}),e=>{k(e),P({id:s,error:e.message})})},t.contentWindow.postMessage({type:"homegames-save-port-v1"},"*",[r.port2])}e.addEventListener("message",L);const M=e=>{b&&(e.preventDefault(),e.returnValue="")};function R(){y=!0,clearTimeout(m),d?.close(),e.removeEventListener("message",L),e.removeEventListener("beforeunload",M),c?.then(e=>e.close(),()=>{})}function N(){return u||(u=(async()=>{d&&!y&&await new Promise(e=>{f=e,m=setTimeout(e,3e3),P({type:"close"})}),await E})()),u}return e.addEventListener("beforeunload",M),{get pending(){return b>0},get stopped(){return Boolean(u)},close:async()=>p||(p=(async()=>{await N(),R()})(),p),dispose:R,async exportSave(){if(await E,!x)throw new Error("This game has not saved any progress yet");return JSON.stringify({...x,data:_(x.data)})},async importSave(e){if("string"!=typeof e||(new TextEncoder).encode(e).length>1052672)throw new Error("Save file is too large");const t=JSON.parse(e);if(t?.gameId!==i||!l.includes(t.versionId))throw new Error("This save is for a different game or an incompatible save version");const s=_(t.data);await N(),await A(async()=>{w||await I(),await T(s,t.versionId)})},downloadSave(t="game-save.json"){return this.exportSave().then(s=>{const r=e.URL.createObjectURL(new Blob([s],{type:"application/json"})),i=e.document.createElement("a");i.href=r,i.download=t,i.click(),setTimeout(()=>e.URL.revokeObjectURL(r),3e4)})}}},connectSaveStore:function(e,{gameKey:t,versionId:s,onError:r=()=>{},stop:i=()=>{}}){return new Promise((n,o)=>{let a,h=0,l=!1;const c=new Map,d=setTimeout(()=>{e.removeEventListener("message",u),o(new Error("Game save storage did not connect. Reload to try again."))},1e4);function u(o){function p(e,t){return l?Promise.reject(new Error("Game session closed")):c.size>=64?Promise.reject(new Error("Too many pending save requests")):new Promise((s,i)=>{const n=++h,o=setTimeout(()=>{c.delete(n);const e=new Error("Game save timed out");r(e),i(e)},1e4);c.set(n,{resolve:s,reject:i,timeout:o});try{a.postMessage(void 0===t?{id:n,op:e}:{id:n,op:e,data:t})}catch(e){clearTimeout(o),c.delete(n),i(e)}})}o.source===e.parent&&"homegames-save-port-v1"===o.data?.type&&o.ports[0]&&(clearTimeout(d),e.removeEventListener("message",u),a=o.ports[0],a.onmessage=e=>{const t=e.data;if("close"===t?.type){i(),l=!0;const e=()=>{c.size?setTimeout(e,10):(a.postMessage({type:"closed"}),a.close())};return void e()}const s=c.get(t?.id);if(s)if(c.delete(t.id),clearTimeout(s.timeout),t.error){const e=new Error(t.error);r(e),s.reject(e)}else s.resolve(t.value)},n({eager:!0,strict:!0,getSave:e=>e==="local:"+t?p("get"):Promise.reject(new Error("Wrong game save key")),putSave:(e,r)=>e!=="local:"+t||r?.gameKey!==t||r.versionId!==s?Promise.reject(new Error("Wrong game save identity")):p("put",r.data)}))}e.addEventListener("message",u),e.parent.postMessage({type:"homegames-save-connect-v1"},"*")})}}},4394(e,t,s){"use strict";const{exportArchive:r,LIMITS:i}=s(5110),{validateName:n,LIMITS:o}=s(5828),a=new TextEncoder,h=new TextDecoder("utf-8",{fatal:!0});function l(e){const t=a.encode(JSON.stringify(e)),s=new Uint8Array(1+t.length);return s[0]=14,s.set(t,1),s}e.exports={ProjectTransferHost:class{constructor({exportProject:e,listExports:t,readExport:s,timeoutMs:r=3e4}){Object.assign(this,{exportProject:e,listExports:t,readExport:s,timeoutMs:r}),this.transfers=new Map,this.closed=!1}async handle(e,t,s){if(this.closed||"project-transfer"!==t?.type||(i=t.id,!(Number.isInteger(i)&&i>0&&i<=4294967295)))return;var i;const a=this.transfers.get(e),h=e=>s(l({action:"error",id:t.id,message:e}));if("cancel"===t.action)return void(a?.id===t.id&&this.leave(e));if("request"===t.action){if(a||this.transfers.size>=4)return void h("A file transfer is already in progress. Try again shortly.");const i={id:t.id,offset:0,send:s};this.transfers.set(e,i),this.touch(e,i);try{let a,h;const c=t.kind||"project";if("export-list"===c){if(!this.listExports)throw new Error("This host does not support viewing exports");const t=await this.listExports(e);if(this.closed||this.transfers.get(e)!==i)return;return this.leave(e),void s(l({action:"exports",id:i.id,files:t}))}if("export"===c){if(n(t.name),!this.readExport)throw new Error("This host does not support viewing exports");if(a=await this.readExport(e,t.name),!(a instanceof Uint8Array)||a.length>o.fileBytes)throw new Error("Invalid export");h={kind:c,name:t.name}}else{if("project"!==c)throw new Error("Unknown file request");{const t=await this.exportProject(e);a=await r(t),h={gameId:t.manifest.gameId,revision:t.revision,name:String(t.metadata.name||"Game").slice(0,200)}}}if(this.closed||this.transfers.get(e)!==i)return;i.bytes=a,s(l({action:"offer",id:i.id,bytes:a.length,...h}))}catch(t){this.transfers.get(e)===i&&(this.leave(e),h(String(t.message).slice(0,200)))}return}if("ack"!==t.action||!a||a.id!==t.id)return;if(!a.bytes||t.offset!==a.offset)return this.leave(e),void h("Invalid game-copy acknowledgement");if(this.touch(e,a),a.offset===a.bytes.length)return this.leave(e),void s(l({action:"complete",id:a.id}));const c=Math.min(a.offset+65536,a.bytes.length),d=new Uint8Array(9+c-a.offset);d[0]=15;const u=new DataView(d.buffer);u.setUint32(1,a.id),u.setUint32(5,a.offset),d.set(a.bytes.subarray(a.offset,c),9),a.offset=c,s(d)}touch(e,t){clearTimeout(t.timer),t.timer=setTimeout(()=>{this.transfers.get(e)===t&&(this.leave(e),t.send(l({action:"error",id:t.id,message:"Game-copy transfer timed out"})))},this.timeoutMs)}leave(e){const t=this.transfers.get(e);t&&clearTimeout(t.timer),this.transfers.delete(e)}close(){this.closed=!0;for(const e of this.transfers.keys())this.leave(e)}},ProjectTransferClient:class{constructor({send:e,importArchive:t,timeoutMs:s=45e3}){Object.assign(this,{send:e,importArchive:t,timeoutMs:s}),this.sequence=Math.floor(16777215*Math.random())}request({kind:e="project",name:t}={}){if(this.closed)return Promise.reject(new Error("Session closed"));if(this.pending)return Promise.reject(new Error("A file transfer is already in progress"));if(!["project","export-list","export"].includes(e))return Promise.reject(new Error("Unknown file request"));if("export"===e)try{n(t)}catch(e){return Promise.reject(e)}return new Promise((s,r)=>{const i=this.sequence=this.sequence%4294967295+1;this.pending={id:i,resolve:s,reject:r,offset:0,kind:e,name:t},this.touch();try{this.send({type:"project-transfer",action:"request",id:i,kind:e,name:t})}catch(e){this.fail(e)}})}touch(){const e=this.pending;clearTimeout(e.timer),e.timer=setTimeout(()=>this.fail(new Error("Game-copy request timed out. The host may not support exporting.")),this.timeoutMs)}async receive(e){const t=this.pending;if(!t)return;const s=e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength);try{if(14===s[0]){if(s.length>("export-list"===t.kind?32768:4096))throw new Error("Oversized file-transfer control");const e=JSON.parse(h.decode(s.subarray(1)));if(e.id!==t.id)return;if("error"===e.action)throw new Error(String(e.message).slice(0,200));if("exports"===e.action){if("export-list"!==t.kind||!Array.isArray(e.files)||e.files.length>o.files)throw new Error("Invalid export list");const s=new Set;let r=0;const i=e.files.map(e=>{if(n(e.name),s.has(e.name.toLowerCase())||!Number.isSafeInteger(e.size)||e.size<0||e.size>o.fileBytes||(r+=e.size)>o.totalBytes)throw new Error("Invalid export list");return s.add(e.name.toLowerCase()),{name:e.name,size:e.size}});return this.pending=null,clearTimeout(t.timer),void t.resolve(i)}if("offer"===e.action){const s="export"===t.kind;if("export-list"===t.kind||t.bytes||!Number.isSafeInteger(e.bytes)||e.bytes<(s?0:1)||e.bytes>(s?o.fileBytes:i.archiveBytes)||(s?"export"!==e.kind||e.name!==t.name:"export"===e.kind||!/^[a-f0-9]{64}$/.test(e.revision)||"string"!=typeof e.gameId))throw new Error("Invalid file-transfer offer");return t.metadata=e,t.bytes=new Uint8Array(e.bytes),this.touch(),void this.send({type:"project-transfer",action:"ack",id:t.id,offset:0})}if("complete"!==e.action||!t.bytes||t.offset!==t.bytes.length||t.validating)throw new Error("Incomplete game copy");if(t.validating=!0,this.touch(),"export"===t.kind)return this.pending=null,clearTimeout(t.timer),void t.resolve({name:t.name,bytes:t.bytes});const r=await this.importArchive(t.bytes);if(this.pending!==t)return;if(r.revision!==t.metadata.revision||r.manifest.gameId!==t.metadata.gameId)throw new Error("Game-copy identity changed");return this.pending=null,clearTimeout(t.timer),void t.resolve({bytes:t.bytes,project:r})}if(15!==s[0]||s.length<10)throw new Error("Invalid game-copy packet");const e=new DataView(s.buffer,s.byteOffset,s.byteLength);if(e.getUint32(1)!==t.id)return;if(!t.bytes||t.validating||e.getUint32(5)!==t.offset||s.length-9!==Math.min(65536,t.bytes.length-t.offset))throw new Error("Invalid game-copy offset");t.bytes.set(s.subarray(9),t.offset),t.offset+=s.length-9,this.touch(),this.send({type:"project-transfer",action:"ack",id:t.id,offset:t.offset})}catch(e){this.pending===t&&this.fail(e)}}fail(e){const t=this.pending;if(t){this.pending=null,clearTimeout(t.timer);try{this.send({type:"project-transfer",action:"cancel",id:t.id})}catch(e){}t.reject(e)}}close(){this.fail(new Error("Session closed")),this.closed=!0}},CONTROL:14,CHUNK:15}},2439(e){"use strict";const t=new WeakMap;function s(e){if("string"!=typeof e||!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e))throw new Error("Game metadata needs a UUID gameId")}function r(e,{runtime:t,legacy:r=!0}={}){if(!e||"object"!=typeof e||Array.isArray(e))throw new Error("Invalid game metadata");if(void 0!==e.services&&(!Array.isArray(e.services)||e.services.some(e=>"multiplayer"!==e)))throw new Error("Unsupported legacy service: games requiring contentGenerator or other hosted services cannot run");if(!r){if(s(e.gameId),"string"!=typeof e.name||!e.name.trim()||e.name.length>100)throw new Error("Game metadata needs a name of 1–100 characters");if(void 0!==e.services)throw new Error("services is retired; declare maxPlayers instead");if(void 0!==e.squishVersion)throw new Error("Declare the runtime only in the Squish import, not metadata.squishVersion");if(void 0!==e.multiplayer)throw new Error("multiplayer is derived from maxPlayers");if(void 0!==e.tickRate&&(!Number.isFinite(e.tickRate)||e.tickRate<1||e.tickRate>120))throw new Error("tickRate must be between 1 and 120")}const i=e.maxPlayers??(r?64:void 0);if(!Number.isSafeInteger(i)||i<1||i>255)throw new Error("maxPlayers must be an integer from 1 to 255");if(void 0!==e.saveSchemaVersion&&(!Number.isSafeInteger(e.saveSchemaVersion)||e.saveSchemaVersion<1))throw new Error("Invalid saveSchemaVersion");if(t&&void 0!==e.squishVersion&&e.squishVersion!==t)throw new Error("metadata.squishVersion must match the Squish import");const n={...e,maxPlayers:i,multiplayer:i>1};return(t||e.squishVersion)&&(n.squishVersion=t||e.squishVersion),delete n.services,n}e.exports={normalizeMetadata:r,validateGameId:s,bindRuntimeMetadata:function(e,s){return t.set(e,s),e},runtimeMetadata:function(e){const s="function"==typeof e.metadata?e.metadata():{};let i,n=e;for(;n&&!(i=t.get(n));)n=Object.getPrototypeOf(n);return r({...s,...i?{maxPlayers:i.maxPlayers}:{}},{runtime:i?.squishVersion,legacy:!0})}}},9956(e,t,s){const{Squisher:r}=s(2416);e.exports={createSessionRuntime:(e,t,i={})=>{if("function"!=typeof e?.squish||"function"!=typeof e?.unsquish)throw new Error("Session needs an explicit Squish codec");const n=new r({...i,game:t,encodeNode:e.squish,decodeNode:e.unsquish});let o=!1;return{squisher:n,listExports:()=>o?Promise.reject(new Error("Session closed")):i.userExportsStore?.list()||Promise.resolve([]),readExport:e=>o?Promise.reject(new Error("Session closed")):i.userExportsStore?.read(e)||Promise.reject(new Error("Export not found")),exportProject:()=>o?Promise.reject(new Error("Session closed")):s(2947).exportGameProject(t,i.userExportsStore),stop(){o||(o=!0,n.close(),i.userExportsStore?.close())}}},playerFrame:(e,t)=>{const s=e.getPlayerFrame(t);let r=0;for(let e=0;e<s.length;e++){if(!(e in s))continue;const t=s[e];if(Array.isArray(t))for(let e=0;e<t.length;e++)e in t&&r++;else r++}const i=new Uint8Array(r);let n=0;for(let e=0;e<s.length;e++){if(!(e in s))continue;const t=s[e];if(Array.isArray(t))for(let e=0;e<t.length;e++)e in t&&(i[n++]=t[e]);else i[n++]=t}return i}}},2409(e){"use strict";function t(e){let t=0;const s=e=>Number.isFinite(e)?e:0,r=e=>({x:s(e?.x),y:s(e?.y)});function i(e,n){if(!e||"object"!=typeof e||n>48||++t>4e3)return null;const o={id:"number"==typeof e.id?e.id:String(e.id).slice(0,100),children:[]};if(Array.isArray(e.coordinates2d)&&(o.coordinates2d=e.coordinates2d.slice(0,512).filter(e=>Array.isArray(e)&&e.length>=2).map(e=>[s(e[0]),s(e[1])])),Array.isArray(e.fill)&&(o.fill=e.fill.slice(0,4).map(s)),e.text&&(o.text={...r(e.text),text:String(e.text.text||"").slice(0,2e3),size:s(e.text.size),align:String(e.text.align||"").slice(0,20)}),e.asset&&(o.asset={key:String(e.asset.key||"").slice(0,200),pos:r(e.asset.pos),size:r(e.asset.size)}),Array.isArray(e.playerIds)&&(o.playerIds=e.playerIds.slice(0,64).filter(Number.isFinite)),e.clickable&&(o.clickable=!0),e.input&&(o.input=String(e.input).slice(0,100)),Array.isArray(e.children))for(const s of e.children){if(t>=4e3)break;const e=i(s,n+1);e&&o.children.push(e)}return o}return Array.isArray(e)?e.slice(0,128).map(e=>i(e,0)).filter(Boolean):[]}e.exports={inspectorTree:t,attachStudioDebugHost:function(e,s,{onReady:r=()=>{},onError:i=()=>{},onLog:n=()=>{}}={}){let o,a,h,l,c=!1,d=0,u=1;const p=new Map;function f(e,t){return!o||c?Promise.reject(new Error("Preview debugger is not ready")):new Promise((s,r)=>{const i=++d,n=setTimeout(()=>{p.delete(i),r(new Error("Preview debugger timed out"))},5e3);p.set(i,{resolve:s,reject:r,timer:n}),o.postMessage({id:i,action:e,value:t})})}const m=(e,t)=>{f(e,t).catch(e=>{c||i(e)})};function g(i){if(c||o||i.source!==s.contentWindow||"null"!==i.origin||"homegames-studio-debug-v1"!==i.data?.type)return;const d=new e.MessageChannel;o=d.port1,o.onmessage=({data:e})=>{if(!c&&e)if("ready"===e.event)u=Number.isFinite(e.playerId)?e.playerId:1,r(!0===e.available);else if("snapshot"===e.event&&a&&Number.isFinite(e.time)&&Number.isSafeInteger(e.frame))a({time:e.time,buf:e.frame,tree:t(e.tree)});else if("input"===e.event&&h&&Number.isFinite(e.value?.time))h({time:e.value.time,type:String(e.value.type||"").slice(0,40),key:String(e.value.key||"").slice(0,80)});else if("pick"===e.event&&l){const t=null===e.x?null:Number(e.x),s=null===e.y?null:Number(e.y);if((null===t||Number.isFinite(t))&&(null===s||Number.isFinite(s)))if("select"===e.kind){const e=l.onPick;l=null,e?.(t,s)}else l.onMove?.(t,s)}else if("log"===e.event&&["log","warn","error"].includes(e.level))n(e.level,String(e.message).slice(0,4e3));else if("result"===e.event){const t=p.get(e.id);if(!t)return;p.delete(e.id),clearTimeout(t.timer),e.error?t.reject(new Error(String(e.error).slice(0,500))):t.resolve(e.value)}},s.contentWindow.postMessage({type:"homegames-studio-debug-port-v1"},"*",[d.port2])}return e.addEventListener("message",g),{embedded:!0,get playerId(){return u},enableInspector(e,t){a=e,h=t,m("inspect",!0)},disableInspector(){a=h=l=null,m("inspect",!1)},showFrame:e=>m("frame",e),resumeLive:()=>m("live"),setHighlight:e=>m("highlight",e),enablePick(e){l=e,m("pick",!0)},disablePick(){l=null,m("pick",!1)},addPlayer:()=>f("add-player"),removePlayer:e=>m("remove-player",e),freeze:()=>m("freeze"),stop(){if(!c){c=!0,e.removeEventListener("message",g),o?.close(),a=h=l=null;for(const e of p.values())clearTimeout(e.timer),e.reject(new Error("Preview closed"));p.clear()}}}},connectStudioDebugSource:function(e,s){const r=e.document,i=new Map;let n,o,a,h=!1,l=!1,c=0,d=0,u=null;const p=e=>{!h&&n&&n.postMessage(e)},f=()=>e.dispatchEvent(new e.Event("resize"));function m(e){null!==u&&e?.removePlayer(u),u=null,o?.remove(),o=null,a?.remove(),a=null,f()}const g=(e,t)=>{const s=r.createElement("span");return s.textContent=t,s.style.cssText="position:absolute;left:8px;top:6px;z-index:2;background:#101820cc;color:#fff;padding:3px 6px;border-radius:4px;font:12px system-ui;pointer-events:none",e.style.position="relative",e.append(s),s},y={inspect(e,s){i.clear(),d=0,s?e.enableInspector(e=>{if(!e.buf?.byteLength||e.buf.byteLength>8388608)return;const s=++c;for(i.set(s,e.buf.slice()),d+=e.buf.byteLength;i.size>600||d>67108864;){const e=i.keys().next().value;d-=i.get(e).byteLength,i.delete(e)}p({event:"snapshot",frame:s,time:e.time,tree:t(e.tree)})},e=>p({event:"input",value:e})):e.disableInspector()},frame(e,t){const s=i.get(t);if(!s)throw new Error("This recorded frame is no longer available");e.showFrame(s)},live:e=>e.resumeLive(),highlight:(e,t)=>e.setHighlight(t),pick(e,t){t?e.enablePick({onMove:(e,t)=>p({event:"pick",kind:"move",x:e,y:t}),onPick:(e,t)=>p({event:"pick",kind:"select",x:e,y:t})}):e.disablePick()},"add-player"(e){if(null!==u)return u;if(e.frozen)throw new Error("Restart the game before adding a player");const t=r.getElementById("game");if(o=r.createElement("div"),o.id="studio-debug-player-2",o.style.cssText="flex:1;min-height:0;display:flex;align-items:center;justify-content:center;overflow:hidden;border-top:1px solid #45546a",t.after(o),f(),u=e.addPlayer(o.id),null===u)throw m(e),new Error("Could not add a player");return a=g(t,"Player "+e.playerId),g(o,"Player "+u),f(),u},"remove-player":e=>m(e),freeze(e){m(e),e.freeze()}};function v(t){h||n||t.source!==e.parent||"homegames-studio-debug-port-v1"!==t.data?.type||!t.ports[0]||(e.removeEventListener("message",v),n=t.ports[0],n.onmessage=({data:e})=>{if(!h&&e&&Number.isSafeInteger(e.id))try{const t=s();if(!t)throw new Error("Debug tools require a local game");if(!Object.hasOwn(y,e.action))throw new Error("Unknown debug action");const r=y[e.action](t,e.value);p({event:"result",id:e.id,value:r})}catch(t){p({event:"result",id:e.id,error:t.message})}},p({event:"ready",available:l,playerId:s()?.playerId}))}e.addEventListener("message",v),e.parent.postMessage({type:"homegames-studio-debug-v1"},"*");const w={},x={};let b=0,E=0;for(const t of["log","warn","error"])w[t]=e.console[t],x[t]=(...s)=>{w[t].apply(e.console,s);const r=Date.now();if(r-b>1e3&&(E=0,b=r),++E>25)return;const i=s.map(e=>{try{return"string"==typeof e?e:JSON.stringify(e)}catch(t){return String(e)}}).join(" ").slice(0,4e3);p({event:"log",level:t,message:i})},e.console[t]=x[t];return{ready(){l=!!s(),p({event:"ready",available:l,playerId:s()?.playerId})},close(){if(!h){h=!0,e.removeEventListener("message",v),s()?.disableInspector(),m(s()),i.clear(),n?.close();for(const t of Object.keys(w))e.console[t]===x[t]&&(e.console[t]=w[t])}}}}}},32(e){"use strict";e.exports={openGameInStudio:function(e,t,s="https://homegames.io/studio.html"){const r=new URL(s);if(!["https:","http:"].includes(r.protocol)||r.username||r.password)throw new Error("Invalid Studio address");const i=e.crypto.randomUUID(),n=r.origin;return r.hash=new URLSearchParams({edit:i,from:"file:"===e.location.protocol?"file://":e.location.origin}).toString(),new Promise((s,o)=>{let a,h,l=!1,c=!1;const d=t=>{c||(c=!0,clearTimeout(f),clearInterval(m),e.removeEventListener("message",p),e.removeEventListener("pagehide",u),t?o(t):s())},u=()=>d(new Error("Keep the game open until Studio receives it.")),p=e=>{if(!c&&a&&e.source===a&&e.origin===n&&e.data?.token===i)return"homegames-studio-saved"===e.data.type?d():"homegames-studio-error"===e.data.type?d(new Error(String(e.data.error).slice(0,300))):void("homegames-studio-ready"!==e.data.type||l||(l=!0,h||=Promise.resolve().then(t).then(e=>{if(!(e instanceof Uint8Array)||!e.length||e.length>68157440)throw new Error("Invalid game archive");return e}),h.then(e=>{c||a.postMessage({type:"homegames-studio-game",token:i,bytes:e},n),l=!1}).catch(d)))},f=setTimeout(()=>d(new Error("Studio did not receive the game. Open Studio online once, or import the game HTML or ZIP there.")),9e4),m=setInterval(()=>{a?.closed&&d(new Error("Studio was closed before saving the copy."))},500);e.addEventListener("message",p),e.addEventListener("pagehide",u);try{a=e.open(r.href,"_blank"),a||d(new Error("Allow this game to open a Studio tab, or import its HTML or ZIP in Studio."))}catch(e){d(e)}})},receiveGameInStudio:function(e,t){const s=new URLSearchParams(e.location.hash.slice(1)),r=s.get("edit"),i=s.get("from"),n=e.opener,o="file://"===i;if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(r||"")||!n)return Promise.reject(new Error("Reopen Edit this game from the player, or import its HTML or ZIP."));try{if(!("null"===i||o||["http:","https:"].includes(new URL(i).protocol)&&new URL(i).origin===i))throw new Error}catch(e){return Promise.reject(new Error("Invalid game sender"))}return new Promise((s,a)=>{let h=!1,l=!1;const c=e=>{try{n.postMessage({...e,token:r},"null"===i||o?"*":i)}catch(e){}},d=(t,r)=>{l||(l=!0,clearTimeout(m),clearInterval(g),e.removeEventListener("message",p),e.removeEventListener("pagehide",u),t?(c({type:"homegames-studio-error",error:t.message}),a(t)):(c({type:"homegames-studio-saved"}),s(r)))},u=()=>d(new Error("Studio closed before receiving the game.")),p=e=>{if(l||h||e.source!==n||(o?!["null","file://"].includes(e.origin):e.origin!==i)||e.data?.token!==r||"homegames-studio-game"!==e.data.type)return;const s=e.data.bytes;if(!(s instanceof Uint8Array)||!s.length||s.length>68157440)return d(new Error("Invalid game archive"));h=!0,clearInterval(g),clearTimeout(m),Promise.resolve().then(()=>t(s)).then(e=>d(null,e),d)},f=()=>c({type:"homegames-studio-ready"}),m=setTimeout(()=>d(new Error("The game did not arrive. Keep its tab open and try Edit this game again.")),9e4),g=setInterval(f,500);e.addEventListener("message",p),e.addEventListener("pagehide",u),f()})}}},5828(e){"use strict";const t="user-exports",s=Object.freeze({files:128,fileBytes:16777216,totalBytes:67108864});function r(e){if("string"!=typeof e||!/^[A-Za-z0-9_][A-Za-z0-9_. -]{0,119}$/.test(e)||/[ .]$/.test(e)||/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(e)||["__proto__","prototype","constructor"].includes(e))throw new Error("Export name must be a portable file name, not a path");return e}function i(e){const t=Object.keys(e),i=new Set;let n=0;if(t.length>s.files)throw new Error("Too many user exports");for(const o of t){r(o);const t=o.toLowerCase();if(i.has(t))throw new Error("Export names must differ ignoring capitalization");i.add(t);const a=e[o];if(!(a instanceof Uint8Array)||a.length>s.fileBytes||(n+=a.length)>s.totalBytes)throw new Error("User export size limit exceeded")}}const n=e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e,new Uint8Array(t)]));e.exports={DIRECTORY:t,LIMITS:s,validateName:r,validateFiles:i,createUserExports:function(e={},t=async()=>{}){i(e);let o=n(e),a=Promise.resolve(),h=!1,l=0;const c=new Map;return{userExports:Object.freeze(n(o)),createExport:function(e,n){try{if(h)throw new Error("Game session closed");if(r(e),!(n instanceof Uint8Array))throw new Error("Export data must be Uint8Array bytes");if(n.length>s.fileBytes||l>=128)throw new Error("User export limit exceeded");n=new Uint8Array(n)}catch(e){return Promise.reject(e)}l++;const d=a.then(async()=>{const s={...o,[e]:n};i(s),await t(e,new Uint8Array(n)),o=s,c.delete(e)});return a=d.catch(t=>{c.set(e,t)}).finally(()=>{l--}),d},list:async()=>(await a,Object.entries(o).map(([e,t])=>({name:e,size:t.length}))),async read(e){if(r(e),await a,!Object.hasOwn(o,e))throw new Error("Export not found");return new Uint8Array(o[e])},async snapshot(){if(await a,c.size)throw c.values().next().value;return n(o)},close:()=>(h=!0,a)}},projectExports:function(e){const s=Object.create(null);for(const i of e.reader.listFiles())if(i.startsWith(t+"/")){const t=i.slice(13);r(t),s[t]=e.reader.readFile(i)}return i(s),s}}},5900(e){"use strict";e.exports={recordVideo:function(e,t){const{document:s,navigator:r,MediaRecorder:i,performance:n,Blob:o}=e,a=5242880;let h,l;const c=new Promise((e,t)=>{l=s=>{h.destroy(),s.error?t(new Error(s.error)):e(s)}});return h=new class{constructor(e){this.send=e,this.container=s.body,this.hidden=()=>{s.hidden&&this.fail("Recording cancelled because the page was hidden. Try again.")},s.addEventListener("visibilitychange",this.hidden)}request(e){const t=Math.min(30,Math.max(1,Number(e.durationSeconds)||30)),n=s.createElement("dialog");n.setAttribute("aria-label","Record video"),n.style.cssText="box-sizing:border-box;margin:auto;padding:20px;width:min(440px,94vw);max-height:94vh;overflow:auto;border:2px solid #30213e;border-radius:20px;background:#fff8eb;color:#30213e;font:16px system-ui;text-align:center";const o=s.createElement("h2");o.textContent="Record video",o.style.cssText="margin:0 0 8px";const h=s.createElement("p");h.textContent=String(e.prompt||"").slice(0,120),h.style.cssText="font-size:24px;font-weight:800;overflow-wrap:anywhere;margin:8px 0 16px";const l=s.createElement("video");l.muted=!0,l.autoplay=!0,l.playsInline=!0,l.style.cssText="display:none;width:100%;max-height:30vh;object-fit:contain;background:#30213e;border-radius:12px;transform:scaleX(-1)";const c=s.createElement("p");c.textContent=`Enable your camera and microphone. Your ${t}-second video will be shared with everyone in this game after recording.`,c.setAttribute("aria-live","polite");const d=s.createElement("button");d.textContent="Enable camera & microphone";const u=s.createElement("button");u.textContent="Cancel";for(const e of[d,u])e.style.cssText="padding:13px 16px;margin:5px;border:0;border-radius:10px;background:#30213e;color:#fff8eb;font:600 15px system-ui;cursor:pointer";u.style.background="#e8dfd2",u.style.color="#30213e",n.append(o,h,l,c,d,u),this.container.appendChild(n);const p=Math.min(a,Math.max(131072,Math.floor(Number(e.maxBytes)||a))),f=this.active={id:e.id,duration:t,maxBytes:p,dialog:n,preview:l,status:c,start:d,cancel:u,chunks:[],size:0};u.onclick=()=>this.fail("Recording cancelled. You can try again."),n.oncancel=e=>{e.preventDefault(),u.onclick()},d.onclick=async()=>{d.disabled=!0;try{if(void 0===i)throw new Error("This browser cannot record video. Try a current browser.");if(!r.mediaDevices?.getUserMedia)throw new Error("Camera recording needs HTTPS or localhost.");const e=await r.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0},video:{width:{ideal:640},height:{ideal:360},frameRate:{ideal:20,max:24},facingMode:"user"}});if(this.active!==f)return void e.getTracks().forEach(e=>e.stop());f.stream=e;for(const t of e.getTracks())t.onended=()=>this.fail("Camera or microphone disconnected. Please try again.");if(l.srcObject=e,l.style.display="block",await l.play(),this.active!==f)return;c.textContent="Check your framing, then start recording.",d.textContent=`Record ${t} seconds`,d.disabled=!1,d.onclick=()=>this.countdown(f)}catch(e){this.active===f&&this.fail(e.message||"Unable to access camera and microphone")}},n.showModal(),d.focus()}countdown(e){if(this.active!==e)return;e.start.disabled=!0;let t=3;e.status.textContent=`Get ready… ${t}`,e.countdown=setInterval(()=>{t--,t?e.status.textContent=`Get ready… ${t}`:(clearInterval(e.countdown),this.start(e))},1e3)}start(e){if(this.active===e)try{const t=["video/webm;codecs=vp8,opus","video/mp4","video/webm"].find(e=>i.isTypeSupported(e)),s=e.recorder=new i(e.stream,{...t?{mimeType:t}:{},videoBitsPerSecond:Math.min(65e4,Math.max(1e5,Math.floor(8*e.maxBytes/e.duration*.75)-64e3)),audioBitsPerSecond:64e3});s.ondataavailable=t=>{this.active===e&&t.data.size&&(e.size+=t.data.size,e.size>e.maxBytes?this.fail("This recording is too large. Please try again."):e.chunks.push(t.data))},s.onerror=()=>{this.active===e&&this.fail("The camera could not finish recording. Please try again.")},s.onstop=()=>this.finish(e),s.start(1e3);const r=n.now()+1e3*e.duration,o=()=>{e.status.textContent=`RECORDING · ${Math.max(0,Math.ceil((r-n.now())/1e3))} seconds left`};o(),e.clock=setInterval(o,200),e.timer=setTimeout(()=>{clearInterval(e.clock),e.status.textContent="Sending recording…",s.stop(),this.stopTracks(e)},1e3*e.duration)}catch(e){this.fail(e.message||"Unable to start recording")}}async finish(t){var s;if(this.active===t)try{const r=t.recorder.mimeType||t.chunks[0]?.type||"video/webm",i=new o(t.chunks,{type:r});if(!i.size||i.size>t.maxBytes)throw new Error("Recording was empty or too large. Please try again.");const n=new Uint8Array(await i.arrayBuffer());if(this.active!==t)return;let a="";for(let e=0;e<n.length;e+=8192)a+=String.fromCharCode(...n.subarray(e,e+8192));const h={type:"media",action:"record-result",id:t.id,data:(s=a,e.btoa(s)),contentType:r,fileName:r.includes("mp4")?"recording.mp4":"recording.webm"};this.cancel(t.id),this.send(h)}catch(e){this.active===t&&this.fail(e.message||"Unable to send recording")}}stopTracks(e){e.stream?.getTracks().forEach(e=>{e.onended=null,e.stop()}),e.preview.srcObject=null}cancel(e){const t=this.active;t&&t.id===e&&(this.active=null,clearTimeout(t.timer),clearInterval(t.clock),clearInterval(t.countdown),"inactive"!==t.recorder?.state&&t.recorder&&t.recorder.stop(),this.stopTracks(t),t.dialog.close(),t.dialog.remove(),t.chunks=[])}fail(e){const t=this.active?.id;t&&(this.cancel(t),this.send({type:"media",action:"record-result",id:t,error:e}))}destroy(){this.cancel(this.active?.id),s.removeEventListener("visibilitychange",this.hidden)}}(l),h.request(t),{result:c,close(){h.fail("Recording cancelled")}}}}},6866(e,t,s){const r=s(6260);e.exports={...r,name:"DUALSHOCK 4 Wireless Controller"}},6593(e,t,s){const r=s(6260);e.exports={...r,name:"DualSense Wireless Controller Extended Gamepad"}},7635(e,t,s){const r=s(6260);e.exports={...r,name:"Luna Gamepad Extended Gamepad"}},4255(e,t,s){const r=s(6260);e.exports={...r,name:"8Bitdo NES30 Arcade(x)"}},1085(e,t,s){const r=s(6260);e.exports={...r,name:"Stadia Controller Extended Gamepad"}},6260(e){e.exports={name:"standard",buttons:{FACE_1:0,FACE_2:1,FACE_3:2,FACE_4:3,LEFT_SHOULDER:4,RIGHT_SHOULDER:5,LEFT_TRIGGER:6,RIGHT_TRIGGER:7,SELECT:8,START:9,STICK_CLICK_1:10,STICK_CLICK_2:11,DIRECTION_UP:12,DIRECTION_DOWN:13,DIRECTION_LEFT:14,DIRECTION_RIGHT:15,HOME:16},sticks:{STICK_1_X:0,STICK_1_Y:1,STICK_2_X:2,STICK_2_Y:3}}},9075(e,t,s){const r=s(6260);e.exports={...r,name:"Pro Controller Extended Gamepad",deadzones:{STICK_1_X:.1,STICK_1_Y:.1,STICK_2_X:.1,STICK_2_Y:.1}}},1193(e,t,s){const r=s(6260);e.exports={...r,name:"Xbox Wireless Controller"}},1011(e,t,s){const{Buttons:r,Sticks:i}=s(9902),n=s(6636),o=s(6260),a={...o,name:"android-chromium"},h=s(9387),l=(e,t,s)=>Number.isFinite(e)?Math.max(t,Math.min(s,e)):0,c=(e,t)=>"string"==typeof e.name&&e.name.length>0&&t.includes(e.name);function d(e,t=[],s={}){if(!e)return null;const r=String(e.id||""),i=s.userAgent??("undefined"==typeof navigator?"":navigator.userAgent||""),h=""===e.mapping&&/\bAndroid\b/i.test(i)&&/\b(?:Chrome|Chromium)\//.test(i)&&4===e.axes?.length&&(16===e.buttons?.length||17===e.buttons?.length);return t.find(e=>c(e,r))||("standard"===e.mapping?o:null)||(h?a:null)||Object.values(n).find(e=>c(e,r))||null}function u(e,t=d(e),s={}){if(!e||!1===e.connected||!t)return null;const i={},n={};for(const s of new Set([...Object.values(r),...Object.keys(t.buttons||{})])){const r=e.buttons?.[t.buttons?.[s]],n=l("number"==typeof r?r:r?.value,0,1);i[s]={value:n,pressed:"boolean"==typeof r?.pressed?r.pressed:n>=.5}}for(const r of new Set([...Object.keys(o.sticks),...Object.keys(t.sticks||{})])){const i=l(e.axes?.[t.sticks?.[r]],-1,1),o=s.deadzone??t.deadzones?.[r]??.08;if(!Number.isFinite(o)||o<0||o>=1)throw new RangeError("Homepad deadzone must be between 0 (inclusive) and 1 (exclusive)");n[r]={value:Math.abs(i)<=o?0:Math.sign(i)*(Math.abs(i)-o)/(1-o)}}return{buttons:i,sticks:n}}e.exports={Homepad:class{constructor(e={}){this.options=e,this.error=null,this._read=e.getGamepads||(()=>"undefined"==typeof navigator||"function"!=typeof navigator.getGamepads?[]:navigator.getGamepads())}getGamepads(){let e;this.error=null;try{e=Array.from(this._read()||[])}catch(e){if("SecurityError"!==e.name)throw e;return this.error=e,[]}return e.filter(e=>e&&!1!==e.connected).flatMap(e=>{const t=d(e,this.options.mappings||[],this.options),s=u(e,t,this.options);return s?[{index:e.index,id:e.id,mapping:t,state:s}]:[]})}getGamepadState(e){return this.getGamepads().find(t=>t.index===e)?.state||null}},Buttons:r,mapGamepad:u,mapInputs:h}},9902(e){e.exports={Buttons:{DIRECTION_LEFT:"DIRECTION_LEFT",DIRECTION_RIGHT:"DIRECTION_RIGHT",DIRECTION_UP:"DIRECTION_UP",DIRECTION_DOWN:"DIRECTION_DOWN",LEFT_SHOULDER:"LEFT_SHOULDER",LEFT_TRIGGER:"LEFT_TRIGGER",RIGHT_SHOULDER:"RIGHT_SHOULDER",RIGHT_TRIGGER:"RIGHT_TRIGGER",FACE_1:"FACE_1",FACE_2:"FACE_2",FACE_3:"FACE_3",FACE_4:"FACE_4",START:"START",SELECT:"SELECT",STICK_CLICK_1:"STICK_CLICK_1",STICK_CLICK_2:"STICK_CLICK_2",HOME:"HOME"},Sticks:{STICK_1:"STICK_1",STICK_2:"STICK_2",STICK_1_X:"STICK_1_X",STICK_1_Y:"STICK_1_Y",STICK_2_X:"STICK_2_X",STICK_2_Y:"STICK_2_Y",STICK_1_LEFT:"STICK_1_LEFT",STICK_1_RIGHT:"STICK_1_RIGHT",STICK_1_UP:"STICK_1_UP",STICK_1_DOWN:"STICK_1_DOWN",STICK_2_LEFT:"STICK_2_LEFT",STICK_2_RIGHT:"STICK_2_RIGHT",STICK_2_UP:"STICK_2_UP",STICK_2_DOWN:"STICK_2_DOWN"}}},9387(e){e.exports=function(e,t,{threshold:s=.5}={}){if(!Number.isFinite(s)||s<=0||s>1)throw new RangeError("Input threshold must be greater than 0 and at most 1");const r=t=>{if("string"!=typeof t)throw new TypeError("Input bindings must be control names");const r=e?.buttons?.[t];if(r)return{value:r.value,pressed:r.pressed};const i=e?.sticks?.[t];if(i)return{value:i.value,pressed:Math.abs(i.value)>=s};const n=/^(STICK_[12])_(LEFT|RIGHT|UP|DOWN)$/.exec(t);if(n){const[,t,r]=n,i=t+("LEFT"===r||"RIGHT"===r?"_X":"_Y"),o="LEFT"===r||"UP"===r?-1:1,a=Math.max(0,(e?.sticks?.[i]?.value||0)*o);return{value:a,pressed:a>=s}}return{value:0,pressed:!1}};return Object.fromEntries(Object.entries(t).map(([e,t])=>{const s=(Array.isArray(t)?t:[t]).map(r);return[e,{value:s.reduce((e,t)=>Math.abs(t.value)>Math.abs(e.value)?t:e,{value:0}).value,pressed:s.some(e=>e.pressed)}]}))}},6636(e,t,s){const r=s(6866),i=s(1085),n=s(1193),o=s(7635),a=s(6593),h=s(9075),l=s(4255);e.exports={DUALSHOCK_4:r,STADIA:i,XBOX_ONE:n,LUNA:o,DUALSHOCK_5:a,SWITCH_PRO:h,NES_30:l}},251(e,t){t.read=function(e,t,s,r,i){var n,o,a=8*i-r-1,h=(1<<a)-1,l=h>>1,c=-7,d=s?i-1:0,u=s?-1:1,p=e[t+d];for(d+=u,n=p&(1<<-c)-1,p>>=-c,c+=a;c>0;n=256*n+e[t+d],d+=u,c-=8);for(o=n&(1<<-c)-1,n>>=-c,c+=r;c>0;o=256*o+e[t+d],d+=u,c-=8);if(0===n)n=1-l;else{if(n===h)return o?NaN:1/0*(p?-1:1);o+=Math.pow(2,r),n-=l}return(p?-1:1)*o*Math.pow(2,n-r)},t.write=function(e,t,s,r,i,n){var o,a,h,l=8*n-i-1,c=(1<<l)-1,d=c>>1,u=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:n-1,f=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=c):(o=Math.floor(Math.log(t)/Math.LN2),t*(h=Math.pow(2,-o))<1&&(o--,h*=2),(t+=o+d>=1?u/h:u*Math.pow(2,1-d))*h>=2&&(o++,h/=2),o+d>=c?(a=0,o=c):o+d>=1?(a=(t*h-1)*Math.pow(2,i),o+=d):(a=t*Math.pow(2,d-1)*Math.pow(2,i),o=0));i>=8;e[s+p]=255&a,p+=f,a/=256,i-=8);for(o=o<<i|a,l+=i;l>0;e[s+p]=255&o,p+=f,o/=256,l-=8);e[s+p-f]|=128*m}},3008(e,t){var s,r,i=function(){var e=function(e,t){var s=e,r=o[t],i=null,n=0,h=null,g=[],y={},w=function(e,t){i=function(e){for(var t=new Array(e),s=0;s<e;s+=1){t[s]=new Array(e);for(var r=0;r<e;r+=1)t[s][r]=null}return t}(n=4*s+17),x(0,0),x(n-7,0),x(0,n-7),E(),b(),k(e,t),s>=7&&S(e),null==h&&(h=C(s,r,g)),_(h,t)},x=function(e,t){for(var s=-1;s<=7;s+=1)if(!(e+s<=-1||n<=e+s))for(var r=-1;r<=7;r+=1)t+r<=-1||n<=t+r||(i[e+s][t+r]=0<=s&&s<=6&&(0==r||6==r)||0<=r&&r<=6&&(0==s||6==s)||2<=s&&s<=4&&2<=r&&r<=4)},b=function(){for(var e=8;e<n-8;e+=1)null==i[e][6]&&(i[e][6]=e%2==0);for(var t=8;t<n-8;t+=1)null==i[6][t]&&(i[6][t]=t%2==0)},E=function(){for(var e=a.getPatternPosition(s),t=0;t<e.length;t+=1)for(var r=0;r<e.length;r+=1){var n=e[t],o=e[r];if(null==i[n][o])for(var h=-2;h<=2;h+=1)for(var l=-2;l<=2;l+=1)i[n+h][o+l]=-2==h||2==h||-2==l||2==l||0==h&&0==l}},S=function(e){for(var t=a.getBCHTypeNumber(s),r=0;r<18;r+=1){var o=!e&&1==(t>>r&1);i[Math.floor(r/3)][r%3+n-8-3]=o}for(r=0;r<18;r+=1)o=!e&&1==(t>>r&1),i[r%3+n-8-3][Math.floor(r/3)]=o},k=function(e,t){for(var s=r<<3|t,o=a.getBCHTypeInfo(s),h=0;h<15;h+=1){var l=!e&&1==(o>>h&1);h<6?i[h][8]=l:h<8?i[h+1][8]=l:i[n-15+h][8]=l}for(h=0;h<15;h+=1)l=!e&&1==(o>>h&1),h<8?i[8][n-h-1]=l:h<9?i[8][15-h-1+1]=l:i[8][15-h-1]=l;i[n-8][8]=!e},_=function(e,t){for(var s=-1,r=n-1,o=7,h=0,l=a.getMaskFunction(t),c=n-1;c>0;c-=2)for(6==c&&(c-=1);;){for(var d=0;d<2;d+=1)if(null==i[r][c-d]){var u=!1;h<e.length&&(u=1==(e[h]>>>o&1)),l(r,c-d)&&(u=!u),i[r][c-d]=u,-1==(o-=1)&&(h+=1,o=7)}if((r+=s)<0||n<=r){r-=s,s=-s;break}}},C=function(e,t,s){for(var r=c.getRSBlocks(e,t),i=d(),n=0;n<s.length;n+=1){var o=s[n];i.put(o.getMode(),4),i.put(o.getLength(),a.getLengthInBits(o.getMode(),e)),o.write(i)}var h=0;for(n=0;n<r.length;n+=1)h+=r[n].dataCount;if(i.getLengthInBits()>8*h)throw"code length overflow. ("+i.getLengthInBits()+">"+8*h+")";for(i.getLengthInBits()+4<=8*h&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(!1);for(;!(i.getLengthInBits()>=8*h||(i.put(236,8),i.getLengthInBits()>=8*h));)i.put(17,8);return function(e,t){for(var s=0,r=0,i=0,n=new Array(t.length),o=new Array(t.length),h=0;h<t.length;h+=1){var c=t[h].dataCount,d=t[h].totalCount-c;r=Math.max(r,c),i=Math.max(i,d),n[h]=new Array(c);for(var u=0;u<n[h].length;u+=1)n[h][u]=255&e.getBuffer()[u+s];s+=c;var p=a.getErrorCorrectPolynomial(d),f=l(n[h],p.getLength()-1).mod(p);for(o[h]=new Array(p.getLength()-1),u=0;u<o[h].length;u+=1){var m=u+f.getLength()-o[h].length;o[h][u]=m>=0?f.getAt(m):0}}var g=0;for(u=0;u<t.length;u+=1)g+=t[u].totalCount;var y=new Array(g),v=0;for(u=0;u<r;u+=1)for(h=0;h<t.length;h+=1)u<n[h].length&&(y[v]=n[h][u],v+=1);for(u=0;u<i;u+=1)for(h=0;h<t.length;h+=1)u<o[h].length&&(y[v]=o[h][u],v+=1);return y}(i,r)};y.addData=function(e,t){var s=null;switch(t=t||"Byte"){case"Numeric":s=u(e);break;case"Alphanumeric":s=p(e);break;case"Byte":s=f(e);break;case"Kanji":s=m(e);break;default:throw"mode:"+t}g.push(s),h=null},y.isDark=function(e,t){if(e<0||n<=e||t<0||n<=t)throw e+","+t;return i[e][t]},y.getModuleCount=function(){return n},y.make=function(){if(s<1){for(var e=1;e<40;e++){for(var t=c.getRSBlocks(e,r),i=d(),n=0;n<g.length;n++){var o=g[n];i.put(o.getMode(),4),i.put(o.getLength(),a.getLengthInBits(o.getMode(),e)),o.write(i)}var h=0;for(n=0;n<t.length;n++)h+=t[n].dataCount;if(i.getLengthInBits()<=8*h)break}s=e}w(!1,function(){for(var e=0,t=0,s=0;s<8;s+=1){w(!0,s);var r=a.getLostPoint(y);(0==s||e>r)&&(e=r,t=s)}return t}())},y.createTableTag=function(e,t){e=e||2;var s="";s+='<table style="',s+=" border-width: 0px; border-style: none;",s+=" border-collapse: collapse;",s+=" padding: 0px; margin: "+(t=void 0===t?4*e:t)+"px;",s+='">',s+="<tbody>";for(var r=0;r<y.getModuleCount();r+=1){s+="<tr>";for(var i=0;i<y.getModuleCount();i+=1)s+='<td style="',s+=" border-width: 0px; border-style: none;",s+=" border-collapse: collapse;",s+=" padding: 0px; margin: 0px;",s+=" width: "+e+"px;",s+=" height: "+e+"px;",s+=" background-color: ",s+=y.isDark(r,i)?"#000000":"#ffffff",s+=";",s+='"/>';s+="</tr>"}return(s+="</tbody>")+"</table>"},y.createSvgTag=function(e,t,s,r){var i={};"object"==typeof arguments[0]&&(e=(i=arguments[0]).cellSize,t=i.margin,s=i.alt,r=i.title),e=e||2,t=void 0===t?4*e:t,(s="string"==typeof s?{text:s}:s||{}).text=s.text||null,s.id=s.text?s.id||"qrcode-description":null,(r="string"==typeof r?{text:r}:r||{}).text=r.text||null,r.id=r.text?r.id||"qrcode-title":null;var n,o,a,h,l=y.getModuleCount()*e+2*t,c="";for(h="l"+e+",0 0,"+e+" -"+e+",0 0,-"+e+"z ",c+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',c+=i.scalable?"":' width="'+l+'px" height="'+l+'px"',c+=' viewBox="0 0 '+l+" "+l+'" ',c+=' preserveAspectRatio="xMinYMin meet"',c+=r.text||s.text?' role="img" aria-labelledby="'+A([r.id,s.id].join(" ").trim())+'"':"",c+=">",c+=r.text?'<title id="'+A(r.id)+'">'+A(r.text)+"</title>":"",c+=s.text?'<description id="'+A(s.id)+'">'+A(s.text)+"</description>":"",c+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',c+='<path d="',o=0;o<y.getModuleCount();o+=1)for(a=o*e+t,n=0;n<y.getModuleCount();n+=1)y.isDark(o,n)&&(c+="M"+(n*e+t)+","+a+h);return(c+='" stroke="transparent" fill="black"/>')+"</svg>"},y.createDataURL=function(e,t){e=e||2,t=void 0===t?4*e:t;var s=y.getModuleCount()*e+2*t,r=t,i=s-t;return v(s,s,function(t,s){if(r<=t&&t<i&&r<=s&&s<i){var n=Math.floor((t-r)/e),o=Math.floor((s-r)/e);return y.isDark(o,n)?0:1}return 1})},y.createImgTag=function(e,t,s){e=e||2,t=void 0===t?4*e:t;var r=y.getModuleCount()*e+2*t,i="";return i+="<img",i+=' src="',i+=y.createDataURL(e,t),i+='"',i+=' width="',i+=r,i+='"',i+=' height="',i+=r,i+='"',s&&(i+=' alt="',i+=A(s),i+='"'),i+"/>"};var A=function(e){for(var t="",s=0;s<e.length;s+=1){var r=e.charAt(s);switch(r){case"<":t+="&lt;";break;case">":t+="&gt;";break;case"&":t+="&amp;";break;case'"':t+="&quot;";break;default:t+=r}}return t};return y.createASCII=function(e,t){if((e=e||1)<2)return function(e){e=void 0===e?2:e;var t,s,r,i,n,o=1*y.getModuleCount()+2*e,a=e,h=o-e,l={"██":"█","█ ":"▀"," █":"▄"," ":" "},c={"██":"▀","█ ":"▀"," █":" "," ":" "},d="";for(t=0;t<o;t+=2){for(r=Math.floor((t-a)/1),i=Math.floor((t+1-a)/1),s=0;s<o;s+=1)n="█",a<=s&&s<h&&a<=t&&t<h&&y.isDark(r,Math.floor((s-a)/1))&&(n=" "),a<=s&&s<h&&a<=t+1&&t+1<h&&y.isDark(i,Math.floor((s-a)/1))?n+=" ":n+="█",d+=e<1&&t+1>=h?c[n]:l[n];d+="\n"}return o%2&&e>0?d.substring(0,d.length-o-1)+Array(o+1).join("▀"):d.substring(0,d.length-1)}(t);e-=1,t=void 0===t?2*e:t;var s,r,i,n,o=y.getModuleCount()*e+2*t,a=t,h=o-t,l=Array(e+1).join("██"),c=Array(e+1).join(" "),d="",u="";for(s=0;s<o;s+=1){for(i=Math.floor((s-a)/e),u="",r=0;r<o;r+=1)n=1,a<=r&&r<h&&a<=s&&s<h&&y.isDark(i,Math.floor((r-a)/e))&&(n=0),u+=n?l:c;for(i=0;i<e;i+=1)d+=u+"\n"}return d.substring(0,d.length-1)},y.renderTo2dContext=function(e,t){t=t||2;for(var s=y.getModuleCount(),r=0;r<s;r++)for(var i=0;i<s;i++)e.fillStyle=y.isDark(r,i)?"black":"white",e.fillRect(i*t,r*t,t,t)},y};e.stringToBytes=(e.stringToBytesFuncs={default:function(e){for(var t=[],s=0;s<e.length;s+=1){var r=e.charCodeAt(s);t.push(255&r)}return t}}).default,e.createStringToBytes=function(e,t){var s=function(){for(var s=y(e),r=function(){var e=s.read();if(-1==e)throw"eof";return e},i=0,n={};;){var o=s.read();if(-1==o)break;var a=r(),h=r()<<8|r();n[String.fromCharCode(o<<8|a)]=h,i+=1}if(i!=t)throw i+" != "+t;return n}(),r="?".charCodeAt(0);return function(e){for(var t=[],i=0;i<e.length;i+=1){var n=e.charCodeAt(i);if(n<128)t.push(n);else{var o=s[e.charAt(i)];"number"==typeof o?(255&o)==o?t.push(o):(t.push(o>>>8),t.push(255&o)):t.push(r)}}return t}};var t,s,r,i,n,o={L:1,M:0,Q:3,H:2},a=(t=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],s=1335,r=7973,n=function(e){for(var t=0;0!=e;)t+=1,e>>>=1;return t},(i={}).getBCHTypeInfo=function(e){for(var t=e<<10;n(t)-n(s)>=0;)t^=s<<n(t)-n(s);return 21522^(e<<10|t)},i.getBCHTypeNumber=function(e){for(var t=e<<12;n(t)-n(r)>=0;)t^=r<<n(t)-n(r);return e<<12|t},i.getPatternPosition=function(e){return t[e-1]},i.getMaskFunction=function(e){switch(e){case 0:return function(e,t){return(e+t)%2==0};case 1:return function(e,t){return e%2==0};case 2:return function(e,t){return t%3==0};case 3:return function(e,t){return(e+t)%3==0};case 4:return function(e,t){return(Math.floor(e/2)+Math.floor(t/3))%2==0};case 5:return function(e,t){return e*t%2+e*t%3==0};case 6:return function(e,t){return(e*t%2+e*t%3)%2==0};case 7:return function(e,t){return(e*t%3+(e+t)%2)%2==0};default:throw"bad maskPattern:"+e}},i.getErrorCorrectPolynomial=function(e){for(var t=l([1],0),s=0;s<e;s+=1)t=t.multiply(l([1,h.gexp(s)],0));return t},i.getLengthInBits=function(e,t){if(1<=t&&t<10)switch(e){case 1:return 10;case 2:return 9;case 4:case 8:return 8;default:throw"mode:"+e}else if(t<27)switch(e){case 1:return 12;case 2:return 11;case 4:return 16;case 8:return 10;default:throw"mode:"+e}else{if(!(t<41))throw"type:"+t;switch(e){case 1:return 14;case 2:return 13;case 4:return 16;case 8:return 12;default:throw"mode:"+e}}},i.getLostPoint=function(e){for(var t=e.getModuleCount(),s=0,r=0;r<t;r+=1)for(var i=0;i<t;i+=1){for(var n=0,o=e.isDark(r,i),a=-1;a<=1;a+=1)if(!(r+a<0||t<=r+a))for(var h=-1;h<=1;h+=1)i+h<0||t<=i+h||0==a&&0==h||o==e.isDark(r+a,i+h)&&(n+=1);n>5&&(s+=3+n-5)}for(r=0;r<t-1;r+=1)for(i=0;i<t-1;i+=1){var l=0;e.isDark(r,i)&&(l+=1),e.isDark(r+1,i)&&(l+=1),e.isDark(r,i+1)&&(l+=1),e.isDark(r+1,i+1)&&(l+=1),0!=l&&4!=l||(s+=3)}for(r=0;r<t;r+=1)for(i=0;i<t-6;i+=1)e.isDark(r,i)&&!e.isDark(r,i+1)&&e.isDark(r,i+2)&&e.isDark(r,i+3)&&e.isDark(r,i+4)&&!e.isDark(r,i+5)&&e.isDark(r,i+6)&&(s+=40);for(i=0;i<t;i+=1)for(r=0;r<t-6;r+=1)e.isDark(r,i)&&!e.isDark(r+1,i)&&e.isDark(r+2,i)&&e.isDark(r+3,i)&&e.isDark(r+4,i)&&!e.isDark(r+5,i)&&e.isDark(r+6,i)&&(s+=40);var c=0;for(i=0;i<t;i+=1)for(r=0;r<t;r+=1)e.isDark(r,i)&&(c+=1);return s+Math.abs(100*c/t/t-50)/5*10},i),h=function(){for(var e=new Array(256),t=new Array(256),s=0;s<8;s+=1)e[s]=1<<s;for(s=8;s<256;s+=1)e[s]=e[s-4]^e[s-5]^e[s-6]^e[s-8];for(s=0;s<255;s+=1)t[e[s]]=s;return{glog:function(e){if(e<1)throw"glog("+e+")";return t[e]},gexp:function(t){for(;t<0;)t+=255;for(;t>=256;)t-=255;return e[t]}}}();function l(e,t){if(void 0===e.length)throw e.length+"/"+t;var s=function(){for(var s=0;s<e.length&&0==e[s];)s+=1;for(var r=new Array(e.length-s+t),i=0;i<e.length-s;i+=1)r[i]=e[i+s];return r}(),r={getAt:function(e){return s[e]},getLength:function(){return s.length},multiply:function(e){for(var t=new Array(r.getLength()+e.getLength()-1),s=0;s<r.getLength();s+=1)for(var i=0;i<e.getLength();i+=1)t[s+i]^=h.gexp(h.glog(r.getAt(s))+h.glog(e.getAt(i)));return l(t,0)},mod:function(e){if(r.getLength()-e.getLength()<0)return r;for(var t=h.glog(r.getAt(0))-h.glog(e.getAt(0)),s=new Array(r.getLength()),i=0;i<r.getLength();i+=1)s[i]=r.getAt(i);for(i=0;i<e.getLength();i+=1)s[i]^=h.gexp(h.glog(e.getAt(i))+t);return l(s,0).mod(e)}};return r}var c=function(){var e=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],t=function(e,t){var s={};return s.totalCount=e,s.dataCount=t,s},s={getRSBlocks:function(s,r){var i=function(t,s){switch(s){case o.L:return e[4*(t-1)+0];case o.M:return e[4*(t-1)+1];case o.Q:return e[4*(t-1)+2];case o.H:return e[4*(t-1)+3];default:return}}(s,r);if(void 0===i)throw"bad rs block @ typeNumber:"+s+"/errorCorrectionLevel:"+r;for(var n=i.length/3,a=[],h=0;h<n;h+=1)for(var l=i[3*h+0],c=i[3*h+1],d=i[3*h+2],u=0;u<l;u+=1)a.push(t(c,d));return a}};return s}(),d=function(){var e=[],t=0,s={getBuffer:function(){return e},getAt:function(t){var s=Math.floor(t/8);return 1==(e[s]>>>7-t%8&1)},put:function(e,t){for(var r=0;r<t;r+=1)s.putBit(1==(e>>>t-r-1&1))},getLengthInBits:function(){return t},putBit:function(s){var r=Math.floor(t/8);e.length<=r&&e.push(0),s&&(e[r]|=128>>>t%8),t+=1}};return s},u=function(e){var t=e,s={getMode:function(){return 1},getLength:function(e){return t.length},write:function(e){for(var s=t,i=0;i+2<s.length;)e.put(r(s.substring(i,i+3)),10),i+=3;i<s.length&&(s.length-i==1?e.put(r(s.substring(i,i+1)),4):s.length-i==2&&e.put(r(s.substring(i,i+2)),7))}},r=function(e){for(var t=0,s=0;s<e.length;s+=1)t=10*t+i(e.charAt(s));return t},i=function(e){if("0"<=e&&e<="9")return e.charCodeAt(0)-"0".charCodeAt(0);throw"illegal char :"+e};return s},p=function(e){var t=e,s={getMode:function(){return 2},getLength:function(e){return t.length},write:function(e){for(var s=t,i=0;i+1<s.length;)e.put(45*r(s.charAt(i))+r(s.charAt(i+1)),11),i+=2;i<s.length&&e.put(r(s.charAt(i)),6)}},r=function(e){if("0"<=e&&e<="9")return e.charCodeAt(0)-"0".charCodeAt(0);if("A"<=e&&e<="Z")return e.charCodeAt(0)-"A".charCodeAt(0)+10;switch(e){case" ":return 36;case"$":return 37;case"%":return 38;case"*":return 39;case"+":return 40;case"-":return 41;case".":return 42;case"/":return 43;case":":return 44;default:throw"illegal char :"+e}};return s},f=function(t){var s=e.stringToBytes(t);return{getMode:function(){return 4},getLength:function(e){return s.length},write:function(e){for(var t=0;t<s.length;t+=1)e.put(s[t],8)}}},m=function(t){var s=e.stringToBytesFuncs.SJIS;if(!s)throw"sjis not supported.";!function(){var e=s("友");if(2!=e.length||38726!=(e[0]<<8|e[1]))throw"sjis not supported."}();var r=s(t),i={getMode:function(){return 8},getLength:function(e){return~~(r.length/2)},write:function(e){for(var t=r,s=0;s+1<t.length;){var i=(255&t[s])<<8|255&t[s+1];if(33088<=i&&i<=40956)i-=33088;else{if(!(57408<=i&&i<=60351))throw"illegal char at "+(s+1)+"/"+i;i-=49472}i=192*(i>>>8&255)+(255&i),e.put(i,13),s+=2}if(s<t.length)throw"illegal char at "+(s+1)}};return i},g=function(){var e=[],t={writeByte:function(t){e.push(255&t)},writeShort:function(e){t.writeByte(e),t.writeByte(e>>>8)},writeBytes:function(e,s,r){s=s||0,r=r||e.length;for(var i=0;i<r;i+=1)t.writeByte(e[i+s])},writeString:function(e){for(var s=0;s<e.length;s+=1)t.writeByte(e.charCodeAt(s))},toByteArray:function(){return e},toString:function(){var t="";t+="[";for(var s=0;s<e.length;s+=1)s>0&&(t+=","),t+=e[s];return t+"]"}};return t},y=function(e){var t=e,s=0,r=0,i=0,n={read:function(){for(;i<8;){if(s>=t.length){if(0==i)return-1;throw"unexpected end of file./"+i}var e=t.charAt(s);if(s+=1,"="==e)return i=0,-1;e.match(/^\s$/)||(r=r<<6|o(e.charCodeAt(0)),i+=6)}var n=r>>>i-8&255;return i-=8,n}},o=function(e){if(65<=e&&e<=90)return e-65;if(97<=e&&e<=122)return e-97+26;if(48<=e&&e<=57)return e-48+52;if(43==e)return 62;if(47==e)return 63;throw"c:"+e};return n},v=function(e,t,s){for(var r=function(e,t){var s=e,r=t,i=new Array(e*t),n={setPixel:function(e,t,r){i[t*s+e]=r},write:function(e){e.writeString("GIF87a"),e.writeShort(s),e.writeShort(r),e.writeByte(128),e.writeByte(0),e.writeByte(0),e.writeByte(0),e.writeByte(0),e.writeByte(0),e.writeByte(255),e.writeByte(255),e.writeByte(255),e.writeString(","),e.writeShort(0),e.writeShort(0),e.writeShort(s),e.writeShort(r),e.writeByte(0);var t=o(2);e.writeByte(2);for(var i=0;t.length-i>255;)e.writeByte(255),e.writeBytes(t,i,255),i+=255;e.writeByte(t.length-i),e.writeBytes(t,i,t.length-i),e.writeByte(0),e.writeString(";")}},o=function(e){for(var t=1<<e,s=1+(1<<e),r=e+1,n=a(),o=0;o<t;o+=1)n.add(String.fromCharCode(o));n.add(String.fromCharCode(t)),n.add(String.fromCharCode(s));var h,l,c,d=g(),u=(h=d,l=0,c=0,{write:function(e,t){if(e>>>t!=0)throw"length over";for(;l+t>=8;)h.writeByte(255&(e<<l|c)),t-=8-l,e>>>=8-l,c=0,l=0;c|=e<<l,l+=t},flush:function(){l>0&&h.writeByte(c)}});u.write(t,r);var p=0,f=String.fromCharCode(i[p]);for(p+=1;p<i.length;){var m=String.fromCharCode(i[p]);p+=1,n.contains(f+m)?f+=m:(u.write(n.indexOf(f),r),n.size()<4095&&(n.size()==1<<r&&(r+=1),n.add(f+m)),f=m)}return u.write(n.indexOf(f),r),u.write(s,r),u.flush(),d.toByteArray()},a=function(){var e={},t=0,s={add:function(r){if(s.contains(r))throw"dup key:"+r;e[r]=t,t+=1},size:function(){return t},indexOf:function(t){return e[t]},contains:function(t){return void 0!==e[t]}};return s};return n}(e,t),i=0;i<t;i+=1)for(var n=0;n<e;n+=1)r.setPixel(n,i,s(n,i));var o=g();r.write(o);for(var a=function(){var e=0,t=0,s=0,r="",i={},n=function(e){r+=String.fromCharCode(o(63&e))},o=function(e){if(e<0);else{if(e<26)return 65+e;if(e<52)return e-26+97;if(e<62)return e-52+48;if(62==e)return 43;if(63==e)return 47}throw"n:"+e};return i.writeByte=function(r){for(e=e<<8|255&r,t+=8,s+=1;t>=6;)n(e>>>t-6),t-=6},i.flush=function(){if(t>0&&(n(e<<6-t),e=0,t=0),s%3!=0)for(var i=3-s%3,o=0;o<i;o+=1)r+="="},i.toString=function(){return r},i}(),h=o.toByteArray(),l=0;l<h.length;l+=1)a.writeByte(h[l]);return a.flush(),"data:image/gif;base64,"+a};return e}();i.stringToBytesFuncs["UTF-8"]=function(e){return function(e){for(var t=[],s=0;s<e.length;s++){var r=e.charCodeAt(s);r<128?t.push(r):r<2048?t.push(192|r>>6,128|63&r):r<55296||r>=57344?t.push(224|r>>12,128|r>>6&63,128|63&r):(s++,r=65536+((1023&r)<<10|1023&e.charCodeAt(s)),t.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|63&r))}return t}(e)},void 0===(r="function"==typeof(s=function(){return i})?s.apply(t,[]):s)||(e.exports=r)},5911(e,t,s){const{squish:r,unsquish:i}=s(8681),{gameNode:n,GameNode:o}=s(5198),a=(s(4063),s(7460)),h=s(1238),l=s(2435),c=s(8922),d=s(4857),u=s(2341),{terrainGenerator:p}=s(5256),f=s(7831),m=s(6682),g=s(402),y=s(2403),v=s(5331);e.exports={squish:r,unsquish:i,gameNode:n,subtypes:f,Game:h,ViewableGame:l,GameNode:o,Colors:a,Shapes:c,Squisher:m,ShapeUtils:d,ViewUtils:u,TerrainGenerator:p,GeometryUtils:y,Asset:g,Physics:v}},402(e){e.exports=class{constructor(e,t=null){this.info={...e},null!==t&&(this.data=new Uint8Array(t))}getData(){return this.data instanceof Uint8Array?Promise.resolve(this.data.slice()):Promise.reject(new Error("The host has not supplied bytes for this asset"))}}},1785(e,t,s){const r=s(4063),i=(e,t,s,i,n,o,a,h,l,c,d,u,p,f,m,g)=>new r(e,t,s,i,n,o,a,h,l,c,d,u,p,f,m,g);e.exports={gameNode:i,BaseNode:class{constructor({color:e,onClick:t,coordinates2d:s,border:r,fill:n,textInfo:o,assetInfo:a,playerIds:h,effects:l,input:c,subtype:d,node:u,id:p,onHover:f,offHover:m,onDrag:g,offClick:y}){this.node=u||i(e,t,s,r,n,o,a,h,l,c,d,p,f,m,g,y),this.id=this.node.id}showFor(e){const t=this.node.playerIds.indexOf(e),s=this.node.playerIds.indexOf(0);if(s>=0){const e=this.node.playerIds;e.splice(s,1),this.node.playerIds=e}if(t<0){const t=this.node.playerIds;t.push(e),this.node.playerIds=t}}hideFor(e){const t=this.node.playerIds.indexOf(e);if(t>=0){let e=this.node.playerIds;e.splice(t,1),0==e.length&&(e=[0]),this.node.playerIds=e}}addChild(e,t=!0){this.node.addChild(e),t&&this.node.onStateChange()}addChildren(...e){for(let t=0;t<e.length;t++)this.addChild(e[t],!1);this.node.onStateChange()}getChildren(){return this.node.children}removeChild(e,t=!0){this.node.removeChild(e),t&&this.node.onStateChange()}addListener(e){this.node.addListener(e)}findChild(e){return this.findChildHelper(e,this)}findChildHelper(e,t,s=null){t.node.id===e&&(s=t);for(const r in t.node.children){if(s)return s;s=this.findChildHelper(e,t.node.children[r],s)}return s}clearChildren(e){this.node.clearChildren(e),this.node.onStateChange()}update(e={}){e&&(e.fill&&(this.node.fill=e.fill),e.coordinates2d&&(this.node.coordinates2d=e.coordinates2d)),this.node.onStateChange()}clone(){throw new Error("Clone not implemented")}}}},7460(e){const t={ALMOST_BLACK:[16,16,16,255],ALMOST_WHITE:[238,238,238,255],ANTIQUE_WHITE:[250,235,215,255],AQUA:[188,212,230,255],AQUAMARINE:[127,255,212,255],BEIGE:[245,245,220,255],BIG_GRAY:[221,221,221,255],BLACK:[0,0,0,255],BLAY:[87,102,117,255],BLUE:[0,0,255,255],BLUE_WHISPER:[240,248,255,255],BLEEN:[19,51,55,255],BLOOD:[153,0,0,255],BOOGER:[186,218,85,255],BRIGHT_GRAY:[198,226,255,255],BRONZE:[227,151,17,255],BROWN:[145,97,11,255],CANDY_GREEN:[90,193,142,255],CANDY_PINK:[255,115,115,255],CANDY_RED:[246,84,106,255],CHARCOAL:[51,51,51,255],CALM_BLUE:[8,141,165,255],COOL_BLUE:[64,114,148,255],COOL_GREEN:[180,238,180,255],CORAL:[255,127,80,255],CORPORATE_BEIGE:[203,203,169,255],CREAM:[240,224,136,255],CREAMSICLE:[255,195,160,255],CYAN:[0,255,255,255],DARK_TURQUOISE:[0,206,209,255],DEEP_BLUE:[0,51,102,255],DEEP_PURPLE:[102,0,102,255],DEEP_RED:[139,0,0,255],DIM_GRAY:[105,105,105,255],DULL_BLUE:[192,214,228,255],EMERALD:[39,89,45,255],EVERGREEN:[6,85,53,255],FRIENDLY_BLUE:[70,132,153,255],FUCHSIA:[255,0,255,255],FUNNY_PURPLE:[128,0,128,255],GOLD:[255,215,0,255],GOLDMEMBER:[218,165,32,255],GRAY:[192,192,192,255],GREEN:[0,255,0,255],GUN_METAL_GRAY:[102,102,102,255],HARD_ORANGE_RED:[255,64,64,255],HARD_PINK:[247,52,122,255],HG_BLACK:[26,26,26,255],HG_BLUE:[148,210,230,255],HG_RED:[241,112,112,255],HG_YELLOW:[255,247,143,255],INTERIOR_RED:[255,102,102,255],INVITATION_BLUE:[104,151,187,255],KHAKI:[255,246,143,255],LAVENDER:[230,230,250,255],LIGHT_CORAL:[240,128,128,255],LIGHT_SEA_GREEN:[32,178,170,255],NAVY:[0,0,128,255],MAGENTA:[255,0,255,255],MAROON:[128,0,0,255],MEAN_SEA:[129,216,208,255],MERLOT:[66,4,32,255],MINT:[102,205,170,255],MUSTARD:[232,219,32,255],NEON_BOOGER:[204,255,0,255],NEON_PINK:[255,128,237,255],ORANGE:[255,165,0,255],ORANGE_RED:[255,69,0,255],PALE_TURQUOISE:[175,238,238,255],PEACH:[255,218,185,255],PERFUME_PINK:[255,228,225,255],PERRYWINKLE:[204,204,255,255],PINK:[255,192,203,255],POWDER_BLUE:[176,224,230,255],PURPLE:[128,0,128,255],REAL_ESTATE_BLUE:[14,47,68,255],RED:[255,0,0,255],RUST:[128,0,0,255],SALMON:[250,128,114,255],SEA_GREEN:[0,128,128,255],SHARP_YELLOW:[255,255,102,255],SILVER:[192,192,192,255],SIMPLE_GRAY:[204,204,204,255],SLEEPY_PINK:[255,182,193,255],SMOKE:[245,245,245,255],SMOOTH_BLUE:[76,163,221,255],SOFT_GREEN:[211,255,206,255],SOFT_MINT:[182,252,213,255],SOFT_PINK:[255,192,203,255],STRESSED_PURPLE:[138,43,226,255],SKY_BLUE:[127,229,240,255],STANDARD_GRAY:[128,128,128,255],STORM_GRAY:[105,105,102,255],SUCCESS_GREEN:[0,128,0,255],TEAL:[0,128,128,255],TENSE_SKY:[102,204,204,255],TERRACOTTA:[226,114,91,255],THICK_LUXURY:[195,151,151,255],TURQUOISE:[64,224,208,255],WALLPAPER_BEIGE:[203,190,181,255],WALLPAPER_GREEN:[220,237,193,255],WHITE:[255,255,255,255],YELLOW:[255,255,0,255]},s=Object.keys(t);e.exports={COLORS:t,randomColor:function(e=[]){const r=e.length?((e,t)=>e.length===t.length?["WHITE"]:e.filter(e=>{for(const s of t)if(e===s)return!1;return!0}))(s,e):s,i=Math.floor(Math.random()*r.length);return t[r[i]]}}},1238(e){e.exports=class{constructor(){this.listeners=new Set,this.intervals=[],this.timeouts=[],this.playerInfoMap={}}addStateListener(e){this.listeners.add(e)}removeStateListener(e){this.listeners.delete(e)}findNode(e){let t=null;if(this.getLayers){const s=this.getLayers();for(let r in s)if(t=s[r].root.findChild(e),t)break}return t}setInterval(e,t){const s=setInterval(e,t);return this.intervals.push(s),s}setTimeout(e,t){const s=setTimeout(e,t);return this.timeouts.push(s),s}close(){for(const e in this.timeouts){const t=this.timeouts[e];clearTimeout(t)}for(const e in this.intervals){const t=this.intervals[e];clearInterval(t)}}}},5198(e,t,s){const r=s(8922),i=s(7831),{gameNode:n,BaseNode:o}=s(1785),a={[r.CIRCLE]:i.SHAPE_2D_CIRCLE,[r.POLYGON]:i.SHAPE_2D_POLYGON,[r.LINE]:i.SHAPE_2D_LINE},h={[i.SHAPE_2D_CIRCLE]:r.CIRCLE,[i.SHAPE_2D_POLYGON]:r.POLYGON,[i.SHAPE_2D_LINE]:r.LINE};class l extends o{constructor({color:e,onClick:t,shapeType:s,coordinates2d:r,border:i,fill:n,playerIds:o,effects:h,input:l,node:c,id:d,onHover:u,offHover:p,onDrag:f,offClick:m}){if(!(r&&s||c))throw new Error("Shape requires coordinates2d and shapeType");super({color:e,onClick:t,coordinates2d:r,border:i,fill:n,playerIds:o,effects:h,input:l,node:c,subtype:a[s],id:d,onHover:u,offHover:p,onDrag:f,offClick:m})}clone({handleClick:e,input:t,id:s}){const r=Number(s)||null;return new l({color:this.node.color,onClick:e,shapeType:h[this.node.subType],coordinates2d:this.node.coordinates2d,border:this.node.border,fill:this.node.fill,playerIds:this.node.playerIds,effects:this.node.effects,input:t,id:r})}}class c extends o{constructor({textInfo:e,playerIds:t,input:s,node:r,id:n,onClick:o,onHover:a,offHover:h,onDrag:l,offClick:c}){if(!e&&!r)throw new Error("Text node requires textInfo");super({textInfo:e,playerIds:t,input:s,node:r,subtype:i.TEXT,id:n,onClick:o,onHover:a,offHover:h,onDrag:l,offClick:c})}clone({handleClick:e,input:t,id:s}){const r=s||null;return new c({textInfo:Object.assign({},this.node.text),playerIds:this.playerIds?.slice(),id:r})}}class d extends o{constructor({assetInfo:e,onClick:t,coordinates2d:s,playerIds:r,effects:n,node:o,id:a,onHover:h,offHover:l,onDrag:c,offClick:d}){if(!e&&!o)throw new Error("Asset node requires assetInfo");super({assetInfo:e,onClick:t,coordinates2d:s,playerIds:r,effects:n,node:o,subtype:i.ASSET,id:a,onHover:h,offHover:l,onDrag:c,offClick:d})}clone({handleClick:e,input:t,id:s}){const r=s||null;return new d({assetInfo:Object.assign({},this.node.asset),playerIds:this.playerIds?.slice(),id:r})}}const u={Stream:class extends o{constructor({streamId:e,pos:t={x:0,y:0},size:s={x:0,y:0},audio:r=!0,node:n,...o}){if(!n&&!/^[A-Za-z0-9-]{1,64}$/.test(e||""))throw new Error("Stream requires a valid streamId");super({...o,node:n,subtype:i.STREAM}),n||(this.node.stream={id:e,pos:t,size:s,audio:!!r})}},Asset:d,Shape:l,Text:c};e.exports={gameNode:n,GameNode:u}},4063(e){e.exports=class{constructor(e,t,s,r,i,n,o,a=[],h=null,l=null,c=null,d=null,u,p,f,m){this.id=d?Number(d):Math.floor(999999999*Math.random()),this.children=new Array,this.color=e,this.handleClick=t,this.coordinates2d=s,this.border=r,this.fill=i,this.text=n,this.asset=o,this.effects=h,this.input=l,this.listeners=new Set,!a||a instanceof Array||(a=[a]),this.playerIds=a||[],this.subType=c,this.onHover=u,this.offHover=p,this.onDrag=f,this.offClick=m}addChild(e){this.children.push(e)}addChildren(...e){for(let t=0;t<e.length;t++)this.addChild(e[t])}removeChild(e){const t=this.children.findIndex(t=>t.node.id==e);t>=0&&(this._animation&&clearInterval(this._animation),this.children.splice(t,1))}addListener(e){this.listeners.add(e)}onStateChange(){for(const e of this.listeners)e.handleStateChange(this)}clearChildren(e){if(e){const t=this.children.filter(t=>e.includes(t.id));this.children=t}else this.children=new Array}}},8922(e){e.exports={CIRCLE:1,POLYGON:2,LINE:3}},6682(e,t,s){const{squish:r,unsquish:i}=s(8681);e.exports=class{constructor({game:e,scale:t,customBottomLayer:s,customTopLayer:n,onAssetUpdate:o,encodeNode:a=r,decodeNode:h=i,autoTick:l=!0,loadAssets:c=!0,assetLoader:d}){if(this.encodeNode=a,this.decodeNode=h,this.loadAssets=c,this.assetLoader=d,this.observedNodes=new Set,this.closed=!1,this.ids=new Set,this.game=e,this.gameMetadata=e.constructor.metadata&&e.constructor.metadata(),this._assetBufferCache=Object.create(null),this.playerSettings={},this.customBottomLayer=s,this.customTopLayer=n,this.initialize(),this.onAssetUpdate=o,this.playerFrames={},this.listeners=new Set,this._dirty=!1,this._flushScheduled=!1,this.scale=t||{x:1,y:1},this.state=this.squish(this.game.getLayers()),l&&this.game.tick){const e=this.gameMetadata&&this.gameMetadata.tickRate?this.gameMetadata.tickRate:60;this._tickInterval=setInterval(this.game.tick.bind(this.game),1e3/e)}}addListener(e){const t={onEvent:e,remove:()=>this.removeListener(t)};this.listeners.add(t)}removeListener(e){this.listeners.delete(e)}unsquish(e){return this.decodeNode(e)}squish(e,t=null){this.records=[];const s=new Set,r=(e,t,i)=>{if(!e?.node)return;this.observedNodes.has(e)||(e.addListener(this),this.observedNodes.add(e)),s.add(e);const n=e.node.playerIds,o=n?.length?[...i,n.map(Number)]:i;this.records.push({root:e,scopes:o,bytes:this.encodeNode(e,t)});for(const s of e.node.children||[])r(s,t,o)};this.customBottomLayer&&r(this.customBottomLayer.root,this.customBottomLayer.scale||{x:1,y:1},[]);for(const s in e||[])r(e[s].root,e[s].scale||t||this.scale||{x:1,y:1},[]);this.customTopLayer&&r(this.customTopLayer.root,this.customTopLayer.scale||{x:1,y:1},[]);for(const e of this.observedNodes)s.has(e)||e.node.listeners.delete(this);return this.observedNodes=s,this.records.map(e=>e.bytes)}getPlayerFrame(e){this.flush();const t=Number(e),s=Number.isFinite(t)?this.records.filter(e=>e.scopes.every(e=>e.includes(t))&&!this._isAudioMutedFor(e.root,t)):[];return s.length?s.map(e=>e.bytes):[[3,0,0,5,0]]}close(){if(!this.closed){this.closed=!0,clearInterval(this._tickInterval),this.listeners.clear();for(const e of this.observedNodes)e.node.listeners.delete(this);this.observedNodes.clear()}}handleNewAsset(e,t){const s=(this._assetUpdates||this._assetsPending||Promise.resolve()).catch(()=>{}).then(()=>(delete this._assetBufferCache[e],this.initialize().then(e=>(this.closed||this.onAssetUpdate?.(e),e))));return this._assetUpdates=s,s.then(()=>{this._assetUpdates===s&&(this._assetUpdates=null)},()=>{this._assetUpdates===s&&(this._assetUpdates=null)}),s}_isAudioMutedFor(e,t){if(e.node.stream?.audio)return!1===this.playerSettings[t]?.SOUND?.enabled;if(!e.node.asset)return!1;const s=Object.keys(e.node.asset)[0],r=this.gameAssets&&this.gameAssets[s]&&this.gameAssets[s].info;if(!r||"audio"!==r.type)return!1;const i=this.playerSettings[t]&&this.playerSettings[t].SOUND;return!(!i||!1!==i.enabled)}getJson(){const e=this.game.layers,t=new Array(e.length);for(const s in e){const r=e[s].root;t[s]=r}return JSON.stringify(t)}initialize(){if(this.gameAssets=Object.assign({},this.game.constructor.metadata?.()?.assets,this.customBottomLayer?.assets,this.customTopLayer?.assets,this.game.getAssets?.()),!this.loadAssets)return this.assetBundle=new Uint8Array(0),Promise.resolve(this.assetBundle);if(this._assetsPending)return this._assetsPending;const e=this.assetLoader||s(1227).N,t=this.gameAssets,r=Promise.resolve().then(()=>e(t,this._assetBufferCache)).then(e=>this.assetBundle=e);return this._assetsPending=r,r.then(()=>{this._assetsPending=null},()=>{this._assetsPending=null}),r}handleStateChange(e,t){this.closed||(this._dirty=!0,this._flushScheduled||(this._flushScheduled=!0,("function"==typeof setImmediate?setImmediate:e=>setTimeout(e,0))(()=>this.flush())))}flush(){this._flushScheduled=!1,!this.closed&&this._dirty&&(this._dirty=!1,this.state=this.squish(this.game.getLayers()),this.broadcast())}broadcast(){for(const e of this.listeners)e.onEvent(this.state)}updatePlayerSettings(e,t){const s=Object.assign(this.playerSettings[e]||{},t);this.playerSettings[e]=s}deletePlayerSettings(e){delete this.playerSettings[e]}}},2435(e,t,s){const{GameNode:r}=s(5198),i=s(8922),n=s(4857),o=s(7460),a=s(1238);e.exports=class extends a{constructor(e){var t;super(),this.planeSize=e,this.plane=(t=this.planeSize,new r.Shape({shapeType:i.POLYGON,coordinates2d:n.rectangle(0,0,t,t)})),this.fakeRoot=new r.Shape({shapeType:i.POLYGON,coordinates2d:n.rectangle(0,0,0,0),fill:o.COLORS.BLACK}),this.layers=[{root:this.fakeRoot}]}updatePlaneSize(e){this.planeSize=e,this.plane.node.coordinates2d=n.rectangle(0,0,e,e)}getLayers(){return this.layers}getPlane(){return this.plane}getPlaneSize(){return this.planeSize}getViewRoot(){return this.fakeRoot}}},1227(e){const t={image:1,audio:2,font:3,video:4};e.exports={N:async function(e,s=Object.create(null)){const r=[];for(const[i,n]of Object.entries(e)){if(!t[n.info?.type]||!/^[\x20-\x7e]{1,32}$/.test(i))throw new Error("Invalid asset declaration: "+i);if(!Object.hasOwn(s,i)){const e=n.data;if(!(e instanceof Uint8Array))throw new Error("The host must supply local asset bytes: "+i);const r=new Uint8Array(44+e.length);r[0]=1,r[1]=t[n.info.type],r.set((new TextEncoder).encode((e.length+32).toString(36).padStart(10,"0")),2),r.set((new TextEncoder).encode(i),12),r.set(e,44),s[i]=r}r.push(s[i])}const i=new Uint8Array(r.reduce((e,t)=>e+t.length,0));let n=0;for(const e of r)i.set(e,n),n+=e.length;return i}}},6508(e,t,s){const{GameNode:r}=s(5198);e.exports={CONSTRUCTOR_TO_TYPE:{Asset:1,Shape:2,Text:3,Stream:4},TYPE_TO_CONSTRUCTOR:{1:r.Asset,2:r.Shape,3:r.Text,4:r.Stream}}},5331(e){e.exports={getPath:(e,t,s,r,i=100,n=100)=>{const o=[];let a=!0;for(;a;){const h=(0===o.length?e:o[o.length-1][0])+s,l=(0===o.length?t:o[o.length-1][1])+r;if(h<0||h>i||l<0||l>n){let e=h,t=l;h<0?e=0:h>i&&(e=i),l<0?t=0:l>n&&(t=n),o[o.length-1][0]!==e&&o[o.length-1][1]!==t&&o.push([e,t]),a=!1}else o.push([h,l])}return o}}},8681(e,t,s){const r=s(4063),{CONSTRUCTOR_TO_TYPE:i,TYPE_TO_CONSTRUCTOR:n}=s(6508),o=s(1718),{squishId:a}=s(8066),{squishColor:h}=s(7080),{squishPlayerIds:l}=s(7302),{squishPos:c}=s(833),{squishFill:d}=s(3934),{squishSize:u}=s(1902),{squishHandleClick:p}=s(4053),{squishOnHover:f}=s(8046),{squishBorder:m}=s(9421),{squishSubType:g}=s(4793),{squishInput:y}=s(2799),{squishCoordinates2d:v}=s(6758),{squishEffect:w}=s(8446),{squishText:x}=s(184),{squishAsset:b}=s(6867),{squishStream:E}=s(6323),S={stream:E,id:a,color:h,playerIds:l,pos:c,coordinates2d:v,fill:d,size:u,text:x,asset:b,effects:w,handleClick:p,onHover:f,border:m,subType:g,input:y},k={};for(const e in S)k[Number(S[e].type)]=e;e.exports={squish:(e,t=null)=>{let s=[];const r=e.node,n=(()=>{const e=Object.keys(S).filter(e=>S[e].dependsOn&&S[e].dependsOn.length>0);return[Object.keys(S).filter(e=>!S[e].dependsOn||0===S[e].dependsOn.length),e].flat()})();for(const e in n){const i=n[e];if(i in r){const e=r[i];if(null!=e){const n=S[i].squish(e,t,r),o=n.length+3,a=Math.min(255,o),h=Math.min(255,Math.max(0,o-255));s.push([S[i].type,h,a,...n])}}}let a=i[e.constructor.name];a||(a=i[o[r.subType]]);const h=s.flat(),l=h.length+5,c=Math.min(255,l),d=Math.min(255,Math.max(0,l-255));return[3,Math.min(255,Math.max(0,l-510)),d,c,a,...h]},unsquish:e=>{if(3!=e[0])throw new Error("Squished[0] isnt 3.");if(e.length!==e[1]+e[2]+e[3])throw new Error("Bad length value");let t=5,s=new r;for(;t<e.length;){const r=e[t],i=e[t+1]+e[t+2],n=e.slice(t+3,t+i);if(!k[r]){console.warn("Unknown sub frame type "+r);break}{const e=k[r],t=(0,S[e].unsquish)(n,Object.assign({},s));s[e]=t}t+=i}const i=n[e[4]];return i?new i({node:s}):{node:s}}}},6867(e,t,s){const{getFractional:r}=s(3751),i={type:48,squish:(e,t)=>{const s=Object.keys(e)[0],i=new Array(18+s.length),n=e[s],o=t?t.x*n.pos.x+Math.round(100*(1-t.x))/2:n.pos.x,a=t?t.y*n.pos.y+Math.round(100*(1-t.y))/2:n.pos.y,h=t?t.x*n.size.x:n.size.x,l=t?t.y*n.size.y:n.size.y,c=n.startTime||0,d=n.cropLeft||0,u=n.cropTop||0,p=n.cropRight||0,f=n.cropBottom||0;i[0]=Math.floor(o),i[1]=r(o),i[2]=Math.floor(a),i[3]=r(a),i[4]=Math.floor(h),i[5]=r(h),i[6]=Math.floor(l),i[7]=r(l),i[8]=Math.floor(c),i[9]=r(c),i[10]=Math.floor(d),i[11]=r(d),i[12]=Math.floor(u),i[13]=r(u),i[14]=Math.floor(p),i[15]=r(p),i[16]=Math.floor(f),i[17]=r(f);for(let e=0;e<s.length;e++)i[18+e]=s.codePointAt(e);return i},unsquish:e=>{const t=e[0]+e[1]/100,s=e[2]+e[3]/100,r=e[4]+e[5]/100,i=e[6]+e[7]/100,n=e[8]+e[9]/100,o=e[10]+e[11]/100,a=e[12]+e[13]/100,h=e[14]+e[15]/100,l=e[16]+e[17]/100,c=String.fromCodePoint.apply(null,e.slice(18));return{[c]:{pos:{x:t,y:s},size:{x:r,y:i},startTime:n,cropLeft:o,cropTop:a,cropRight:h,cropBottom:l}}}};e.exports={squishAsset:i}},9421(e){e.exports={squishBorder:{type:54,squish:e=>[e],unsquish:e=>e[0]}}},7080(e){e.exports={squishColor:{type:42,squish:e=>[e[0],e[1],e[2],e[3]],unsquish:e=>[e[0],e[1],e[2],e[3]]}}},6758(e,t,s){const{getFractional:r}=s(3751),i=s(7831),n=e=>e<0?0:e>255?255:e,o=(e,t)=>t>0&&t<1?Math.max(0,Math.min(100,e)):e,a=(e,t)=>e*o(t,e)+Math.round(100*(1-e))/2,h={type:52,squish:(e,t,s)=>{const h=e.flat(),l=new Array(2*h.length);if(s.subType==i.SHAPE_2D_CIRCLE)if(t){const e=n(a(t.x,h[0]));l[0]=Math.floor(e),l[1]=r(e);const s=n(a(t.y,h[1]));let i;l[2]=Math.floor(s),l[3]=r(s),i=t.x===t.y?t.x*h[2]:Math.sqrt(Math.pow(100*t.x,2)+Math.pow(100*t.y,2))*(h[2]/100),l[4]=Math.floor(i),l[5]=r(i)}else{const e=n(h[0]);l[0]=Math.floor(e),l[1]=r(e);const t=n(h[1]);l[2]=Math.floor(t),l[3]=r(t);const s=h[2];l[4]=Math.round(s),l[5]=r(s)}else for(const e in h)if(t){const s=e%2==0?t.x:t.y,i=s*o(h[e],s),a=Math.round(100*(1-s)),c=n(i+a/2);l[2*e]=Math.floor(c),l[2*e+1]=r(c)}else{const t=n(h[e]);l[2*e]=Math.floor(t),l[2*e+1]=Math.round(100*(t-Math.floor(t)))}return l},dependsOn:["subType"],unsquish:(e,{subType:t})=>{const s=new Array(e.length/2);for(let t=0;t<e.length;t+=2){const r=e[t]+e[t+1]/100;s[t/2]=r}if(t===i.SHAPE_2D_POLYGON||t===i.SHAPE_2D_LINE){const e=new Array(s.length/2);for(let t=0;t<s.length;t+=2)e[t/2]=[s[t],s[t+1]];return e}return s}};e.exports={squishCoordinates2d:h}},8446(e){const t={type:49,squish:e=>{if(e.shadow){const t="shadow";let s=t.length+4;e.shadow.blur&&(s+=2);const r=new Array(s);for(let e=0;e<t.length;e++)r[e]=t.codePointAt(e);return r[t.length]=e.shadow.color[0],r[t.length+1]=e.shadow.color[1],r[t.length+2]=e.shadow.color[2],r[t.length+3]=e.shadow.color[3],e.shadow.blur&&(r[t.length+4]=Math.floor(e.shadow.blur/10),r[t.length+5]=e.shadow.blur%10),r}},unsquish:e=>{const t=String.fromCodePoint.apply(null,e.slice(0,6)),s=e.slice(6,10);let r;e.length>10&&(r=10*e[10]+e[11]);const i={[t]:{color:s}};return r&&(i[t].blur=r),i}};e.exports={squishEffect:t}},3934(e){e.exports={squishFill:{type:53,squish:e=>[e[0],e[1],e[2],e[3]],unsquish:e=>[e[0],e[1],e[2],e[3]]}}},4053(e){e.exports={squishHandleClick:{type:50,squish:e=>e?[1]:[0],unsquish:e=>1===e[0]}}},8066(e){const t={type:43,squish:e=>{const t=e.toString();let s=new Array(12),r=0;for(;r<=12-t.length;r++)s[r]=0;for(let e=0;e<t.length;e++)s[e+r]=Number(t.charAt(e));return s},unsquish:e=>{let t=0;for(let s=0;s<e.length;s++)t+=e[s]*Math.pow(10,e.length-s-1);return Number(t)}};e.exports={squishId:t}},2799(e){const t={type:51,squish:e=>{const t=new Array(e.type.length);for(let s=0;s<e.type.length;s++)t[s]=e.type.codePointAt(s);return t},unsquish:e=>({type:String.fromCodePoint.apply(null,e)})};e.exports={squishInput:t}},8046(e){e.exports={squishOnHover:{type:56,squish:e=>e?[1]:[0],unsquish:e=>1===e[0]}}},7302(e){e.exports={squishPlayerIds:{type:44,squish:e=>e,unsquish:e=>e}}},833(e){const t=e=>Math.round(100*(e-Math.floor(e))),s={type:45,squish:e=>[Math.floor(e.x),t(e.x),Math.floor(e.y),t(e.y)],unsquish:e=>({x:e[0]+e[1]/100,y:e[2]+e[3]/100})};e.exports={squishPos:s}},1902(e){const t=e=>{Math.round(100*(e-Math.floor(e)))},s={type:46,squish:e=>[Math.floor(e.x),t(e.x),Math.floor(e.y),t(e.y)],unsquish:e=>({x:e[0]+e[1]/100,y:e[2]+e[3]/100})};e.exports={squishSize:s}},6323(e,t,s){const{squishAsset:r}=s(6867),i={type:57,squish(e,t){if(!/^[A-Za-z0-9-]{1,64}$/.test(e.id||""))throw new Error("Stream requires a valid streamId");return[!1===e.audio?0:1,...r.squish({[e.id]:{pos:e.pos,size:e.size}},t)]},unsquish(e){const t=r.unsquish(e.slice(1)),s=Object.keys(t)[0];return{id:s,audio:1===e[0],pos:t[s].pos,size:t[s].size}}};e.exports={squishStream:i}},4793(e){e.exports={squishSubType:{type:55,squish:e=>[e],unsquish:e=>e[0]}}},184(e,t,s){const{hypLength:r}=s(3751),i=s(7460),{squishColor:n}=s(7080),o={type:47,squish:(e,t)=>{const s=t?e.x*t.x+Math.round(100*(1-t.x))/2:e.x,o=t?e.y*t.y+Math.round(100*(1-t.y))/2:e.y,a=e.align||"left",h=e.font||"default",l=new Array(e.text.length+10+a.length+h.length);l[0]=Math.floor(s),l[1]=Math.round(100*(s-Math.floor(s))),l[2]=Math.floor(o),l[3]=Math.round(100*(o-Math.floor(o)));const c=e.size||1,d=t?c*r(t.x,t.y):c;l[4]=Math.floor(d),l[5]=Math.round(100*(d-Math.floor(d)));const u=e.color||i.BLACK,p=n.squish(u);for(let e=0;e<p.length;e++)l[6+e]=p[e];l[6+p.length]=3*[...a].length,l[6+p.length+1]=3*[...h].length;let f=0;for(let e=0;e<[...a].length;e++){const t=[...a][e].codePointAt(0).toString();let s;s=1==t.length?["00","00",`0${t}`]:2==t.length?["00","00",`${t}`]:3==t.length?["00",`0${t.charAt(0)}`,`${t.charAt(1)}${t.charAt(2)}`]:4==t.length?["00",`${t.charAt(0)}${t.charAt(1)}`,`${t.charAt(2)}${t.charAt(3)}`]:5==t.length?[`0${t.charAt(0)}`,`${t.charAt(1)}${t.charAt(2)}`,`${t.charAt(3)}${t.charAt(4)}`]:[`${t.charAt(0)}${t.charAt(1)}`,`${t.charAt(2)}${t.charAt(3)}`,`${t.charAt(4)}${t.charAt(5)}`],l[6+p.length+2+f]=Number(s[0]),l[6+p.length+2+f+1]=Number(s[1]),l[6+p.length+2+f+2]=Number(s[2]),f+=3}let m=0;for(let e=0;e<[...h].length;e++){const t=[...h][e].codePointAt(0).toString();let s;s=1==t.length?["00","00",`0${t}`]:2==t.length?["00","00",`${t}`]:3==t.length?["00",`0${t.charAt(0)}`,`${t.charAt(1)}${t.charAt(2)}`]:4==t.length?["00",`${t.charAt(0)}${t.charAt(1)}`,`${t.charAt(2)}${t.charAt(3)}`]:5==t.length?[`0${t.charAt(0)}`,`${t.charAt(1)}${t.charAt(2)}`,`${t.charAt(3)}${t.charAt(4)}`]:[`${t.charAt(0)}${t.charAt(1)}`,`${t.charAt(2)}${t.charAt(3)}`,`${t.charAt(4)}${t.charAt(5)}`];let r=6+p.length+2+3*[...a].length;l[r+m]=Number(s[0]),l[r+m+1]=Number(s[1]),l[r+m+2]=Number(s[2]),m+=3}let g=0;for(let t=0;t<[...e.text].length;t++){const s=[...e.text][t].codePointAt(0).toString();let r;r=1==s.length?["00","00",`0${s}`]:2==s.length?["00","00",`${s}`]:3==s.length?["00",`0${s.charAt(0)}`,`${s.charAt(1)}${s.charAt(2)}`]:4==s.length?["00",`${s.charAt(0)}${s.charAt(1)}`,`${s.charAt(2)}${s.charAt(3)}`]:5==s.length?[`0${s.charAt(0)}`,`${s.charAt(1)}${s.charAt(2)}`,`${s.charAt(3)}${s.charAt(4)}`]:[`${s.charAt(0)}${s.charAt(1)}`,`${s.charAt(2)}${s.charAt(3)}`,`${s.charAt(4)}${s.charAt(5)}`];let i=6+p.length+2+3*[...a].length+3*[...h].length;l[i+g]=Number(r[0]),l[i+g+1]=Number(r[1]),l[i+g+2]=Number(r[2]),g+=3}return l},unsquish:e=>{const t=e[0]+e[1]/100,s=e[2]+e[3]/100,r=e[4]+e[5]/100,i=e.slice(6,10),n=e[10],o=e[11],a=e.slice(12,12+n),h=e.slice(12+n,12+n+o),l=e.slice(12+n+o);let c=[];for(let e=0;e<a.length;e+=3){let t=a[e].toString();1==t.length&&(t=`0${t}`);let s=a[e+1].toString();1==s.length&&(s=`0${s}`);let r=a[e+2].toString();1==r.length&&(r=`0${r}`);const i=t+s+r;c.push(i)}const d=String.fromCodePoint.apply(null,c);let u=[];for(let e=0;e<h.length;e+=3){let t=h[e].toString();1==t.length&&(t=`0${t}`);let s=h[e+1].toString();1==s.length&&(s=`0${s}`);let r=h[e+2].toString();1==r.length&&(r=`0${r}`);const i=t+s+r;u.push(i)}const p=String.fromCodePoint.apply(null,u),f=[];for(let e=0;e<l.length;e+=3){let t=l[e].toString();1==t.length&&(t=`0${t}`);let s=l[e+1].toString();1==s.length&&(s=`0${s}`);let r=l[e+2].toString();1==r.length&&(r=`0${r}`);const i=t+s+r;f.push(i)}return{x:t,y:s,text:String.fromCodePoint.apply(null,f),size:r,color:i,align:d,font:p}}};e.exports={squishText:o}},1718(e,t,s){const{GameNode:r}=s(5198),i=s(7831);e.exports={[[i.STREAM]]:r.Stream,[[i.ASSET]]:r.Asset,[[i.TEXT]]:r.Text,[[i.SHAPE_2D_POLYGON]]:r.Shape,[[i.SHAPE_2D_CIRCLE]]:r.Shape,[[i.SHAPE_2D_LINE]]:r.Shape}},7831(e){e.exports={STREAM:6,ASSET:1,TEXT:2,SHAPE_2D_POLYGON:3,SHAPE_2D_CIRCLE:4,SHAPE_2D_LINE:5}},5256(e,t,s){const{getRandomTerrain:r,getRandomStartPoint:i}=s(5592),n=e=>{for(let t=0;t<e.length;t++)for(let s=0;s<e[t].length;s++)e[t][s]={filled:e[t][s].filled,north:e[t][s].north,south:e[t][s].south,east:e[t][s].east,west:e[t][s].west}},o=(e,t,s,a,h,l=0)=>{if(0===s||3===l)return e;const c=(e=>{const t=[];return e.forEach((e,s)=>{t[s]=[],e.forEach(e=>{t[s].push({...e})})}),t})(e);r()(c,i(a,h,t),a,h,t);const d=((e,t,s,r)=>{const i=[];for(let o=0;o<s;o++)for(let s=0;s<r;s++){const r=[],a={x:o,y:s};for(;;){const s=e[a.x][a.y];if(i.findIndex(e=>e.x===a.x&&e.y===a.y)>-1||a.x===t.x&&a.y===t.y||s.filled){i.push(...r);break}if((!s.north||s.wentNorth)&&(!s.south||s.wentSouth)&&(!s.east||s.wentEast)&&(!s.west||s.wentWest))return!1;if(r.push({...a}),s.south&&!s.wentSouth)s.wentSouth=!0,a.y=a.y+1;else if(s.east&&!s.wentEast)s.wentEast=!0,a.x=a.x+1;else if(s.north&&!s.wentNorth)s.wentNorth=!0,a.y=a.y-1;else{if(!s.west||s.wentWest)return!1;s.wentWest=!0,a.x=a.x-1}}n(e)}return!0})(c,t,a,h);return d?o(c,t,s-1,a,h,0):o(e,t,s,a,h,l+1)};e.exports={terrainGenerator:(e={x:100,y:100},t={x:5,y:5},s=5)=>{const{width:r,height:i}=((e,t)=>{const s=e.x,r=e.y,i=t.x,n=t.y;return{width:Math.floor(s/i),height:Math.floor(r/n)}})(e,t);let n=((e,t)=>{const s=[],r={filled:!1,north:!0,south:!0,east:!0,west:!0};for(let i=0;i<e;i++){s[i]=[];for(let n=0;n<t;n++){const o={...r};0===i?o.west=!1:i===e-1&&(o.east=!1),0===n?o.north=!1:n===t-1&&(o.south=!1),s[i].push(o)}}return s})(r,i);const a={x:Math.floor(Math.random()*r),y:Math.floor(Math.random()*i)};return n=o(n,a,s,r,i),n}}},5592(e){const t=(e,{x:t,y:s},r,i,n)=>{t<0||t>=r||s<0||s>=i||t===n.x&&s===n.y||e[t][s].filled||(e[t][s].north&&(e[t][s-1].south=!1),e[t][s].south&&(e[t][s+1].north=!1),e[t][s].east&&(e[t+1][s].west=!1),e[t][s].west&&(e[t-1][s].east=!1),e[t][s].filled=!0,e[t][s].north=!1,e[t][s].south=!1,e[t][s].east=!1,e[t][s].west=!1)},s=[(e,{x:s,y:r},i,n,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},i,n,o),0===a?(t(e,{x:s+1,y:r},i,n,o),t(e,{x:s,y:r+1},i,n,o),t(e,{x:s+1,y:r+1},i,n,o)):1===a?(t(e,{x:s-1,y:r},i,n,o),t(e,{x:s,y:r+1},i,n,o),t(e,{x:s-1,y:r+1},i,n,o)):2===a?(t(e,{x:s,y:r-1},i,n,o),t(e,{x:s+1,y:r},i,n,o),t(e,{x:s+1,y:r-1},i,n,o)):(t(e,{x:s,y:r-1},i,n,o),t(e,{x:s-1,y:r},i,n,o),t(e,{x:s-1,y:r-1},i,n,o))},(e,{x:s,y:r},i,n,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},i,n,o),0===a?(t(e,{x:s,y:r+1},i,n,o),t(e,{x:s,y:r+2},i,n,o),t(e,{x:s,y:r+3},i,n,o)):1===a?(t(e,{x:s+1,y:r},i,n,o),t(e,{x:s+2,y:r},i,n,o),t(e,{x:s+3,y:r},i,n,o)):2===a?(t(e,{x:s-1,y:r},i,n,o),t(e,{x:s-2,y:r},i,n,o),t(e,{x:s-3,y:r},i,n,o)):(t(e,{x:s,y:r-1},i,n,o),t(e,{x:s,y:r-2},i,n,o),t(e,{x:s,y:r-3},i,n,o))},(e,{x:s,y:r},i,n,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},i,n,o),0===a?(t(e,{x:s,y:r+1},i,n,o),t(e,{x:s,y:r+2},i,n,o),t(e,{x:s+1,y:r+2},i,n,o)):1===a?(t(e,{x:s+1,y:r},i,n,o),t(e,{x:s+2,y:r},i,n,o),t(e,{x:s+2,y:r-1},i,n,o)):2===a?(t(e,{x:s-1,y:r},i,n,o),t(e,{x:s-2,y:r},i,n,o),t(e,{x:s-2,y:r+1},i,n,o)):(t(e,{x:s,y:r-1},i,n,o),t(e,{x:s,y:r-2},i,n,o),t(e,{x:s-1,y:r-2},i,n,o))},(e,{x:s,y:r},i,n,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},i,n,o),0===a?(t(e,{x:s,y:r+1},i,n,o),t(e,{x:s-1,y:r+1},i,n,o),t(e,{x:s-1,y:r+2},i,n,o)):1===a?(t(e,{x:s+1,y:r},i,n,o),t(e,{x:s+1,y:r+1},i,n,o),t(e,{x:s+2,y:r+1},i,n,o)):2===a?(t(e,{x:s-1,y:r},i,n,o),t(e,{x:s-1,y:r+1},i,n,o),t(e,{x:s-2,y:r+1},i,n,o)):(t(e,{x:s,y:r-1},i,n,o),t(e,{x:s-1,y:r-1},i,n,o),t(e,{x:s-1,y:r-2},i,n,o))}];e.exports={getRandomTerrain:()=>s[Math.floor(Math.random()*s.length)],getRandomStartPoint:(e,t,s)=>{const r={x:Math.floor(Math.random()*e),y:Math.floor(Math.random()*t)};for(;r.x===s.x&&r.y===s.y;)r.x=Math.floor(Math.random()*e),r.y=Math.floor(Math.random()*t);return r}}},2403(e){const t=(e,s,r,i=[])=>{if(!r||r(e)&&e.node.id!==s.node.id){const t=e.node.text,r=e.node.coordinates2d||[[t.x,t.y],[t.x,t.y],[t.x,t.y],[t.x,t.y],[t.x,t.y]],n=s.node.coordinates2d,o=r[0][0],a=r[1][0],h=n[0][0],l=n[1][0],c=r[0][1],d=r[2][1],u=n[0][1],p=n[2][1];l<o||a<h||c>p||u>d||i.push(e)}for(const n in e.node.children)t(e.node.children[n],s,r,i);return i};e.exports={checkCollisions:(e,s,r=null)=>t(e,s,r)}},3751(e){e.exports={hypLength:(e,t)=>Math.sqrt(Math.pow(e,2)+Math.pow(t,2)),getFractional:e=>Math.round(100*(e-Math.floor(e)))}},4857(e){e.exports={triangle:(e,t,s,r,i,n)=>[[e,t],[s,r],[i,n],[e,t]],rectangle:(e,t,s,r)=>[[e,t],[e+s,t],[e+s,t+r],[e,t+r],[e,t]]}},2341(e,t,s){const{GameNode:r}=s(5198),i=s(8922),n=s(4857),o=s(2403),a=s(7460);e.exports={getView:(e,t,s,h={},l={})=>{const c=o.checkCollisions(e,{node:{coordinates2d:n.rectangle(t.x,t.y,t.w,t.h)}},t=>t.node.id!==e.node.id),d=new r.Shape({shapeType:i.POLYGON,coordinates2d:n.rectangle(0,0,0,0),fill:a.COLORS.BLACK}),u=[];return c.length>0&&c.forEach(e=>{const r=[],i=[],n=e.node.coordinates2d||[[e.node.text.x,e.node.text.y],[e.node.text.x,e.node.text.y],[e.node.text.x,e.node.text.y],[e.node.text.x,e.node.text.y],[e.node.text.x,e.node.text.y]];for(let s in n){const o=n[s],a=o[0],c=o[1];let d=Math.max(Math.min(a-t.x,100),0),u=Math.max(Math.min(c-t.y,100),0);d=(l.x||1)*d,u=(l.y||1)*u;const p=!h.filter||h.filter(e);p&&(h.x&&(d+=h.x),h.y&&(u+=h.y)),d<0?d=0:d>100&&(d=100),u<0?u=0:u>100&&(u=100),r.push([d,u]);let f=(l.x||1)*(a-t.x),m=(l.y||1)*(c-t.y);p&&(h.x&&(f+=h.x),h.y&&(m+=h.y)),i.push([f,m])}{const t=e.clone({handleClick:null===e.node.handleClick||void 0===e.node.handleClick?null:e.node.handleClick,id:e.node.id});if(r&&r.length&&(t.node.text&&(t.node.text.x=r[0][0],t.node.text.y=r[0][1]),r.length&&(t.node.coordinates2d=r),t.node.asset)){const e=t.node.coordinates2d[0],s=t.node.coordinates2d[1],r=t.node.coordinates2d[2],n=s[0]-e[0],o=r[1]-s[1],a=Object.values(t.node.asset)[0];a.pos.x=e[0],a.pos.y=e[1],a.size.x=n,a.size.y=o;const h=i[0],l=i[2],c=l[0]-h[0],d=l[1]-h[1];c>0&&(a.cropLeft=100*Math.max(0,(0-h[0])/c),a.cropRight=100*Math.max(0,(l[0]-100)/c)),d>0&&(a.cropTop=100*Math.max(0,(0-h[1])/d),a.cropBottom=100*Math.max(0,(l[1]-100)/d))}t.node.playerIds=s||[],u.push(t)}}),u.forEach(e=>d.addChild(e)),d}}},2416(e,t,s){const{squish:r,unsquish:i}=s(8824),{gameNode:n,GameNode:o}=s(51),a=(s(9798),s(3269)),h=s(2591),l=s(2358),c=s(683),d=s(8926),u=s(1924),{terrainGenerator:p}=s(6007),f=s(2714),m=s(4455),g=s(4497),y=s(8408),v=s(9512);e.exports={squish:r,unsquish:i,gameNode:n,subtypes:f,Game:h,ViewableGame:l,GameNode:o,Colors:a,Shapes:c,Squisher:m,ShapeUtils:d,ViewUtils:u,TerrainGenerator:p,GeometryUtils:y,Asset:g,Physics:v}},4497(e){e.exports=class{constructor(e,t=null){this.info={...e},null!==t&&(this.data=new Uint8Array(t))}getData(){return this.data instanceof Uint8Array?Promise.resolve(this.data.slice()):Promise.reject(new Error("The host has not supplied bytes for this asset"))}}},4732(e,t,s){const r=s(9798),i=(e,t,s,i,n,o,a,h,l,c,d,u,p,f,m,g)=>new r(e,t,s,i,n,o,a,h,l,c,d,u,p,f,m,g);e.exports={gameNode:i,BaseNode:class{constructor({color:e,onClick:t,coordinates2d:s,border:r,fill:n,textInfo:o,assetInfo:a,playerIds:h,effects:l,input:c,subtype:d,node:u,id:p,onHover:f,offHover:m,onDrag:g,offClick:y}){this.node=u||i(e,t,s,r,n,o,a,h,l,c,d,p,f,m,g,y),this.id=this.node.id}showFor(e){const t=this.node.playerIds.indexOf(e),s=this.node.playerIds.indexOf(0);if(s>=0){const e=this.node.playerIds;e.splice(s,1),this.node.playerIds=e}if(t<0){const t=this.node.playerIds;t.push(e),this.node.playerIds=t}}hideFor(e){const t=this.node.playerIds.indexOf(e);if(t>=0){let e=this.node.playerIds;e.splice(t,1),0==e.length&&(e=[0]),this.node.playerIds=e}}addChild(e,t=!0){this.node.addChild(e),t&&this.node.onStateChange()}addChildren(...e){for(let t=0;t<e.length;t++)this.addChild(e[t],!1);this.node.onStateChange()}getChildren(){return this.node.children}removeChild(e,t=!0){this.node.removeChild(e),t&&this.node.onStateChange()}addListener(e){this.node.addListener(e)}findChild(e){return this.findChildHelper(e,this)}findChildHelper(e,t,s=null){t.node.id===e&&(s=t);for(const r in t.node.children){if(s)return s;s=this.findChildHelper(e,t.node.children[r],s)}return s}clearChildren(e){this.node.clearChildren(e),this.node.onStateChange()}update(e={}){e&&(e.fill&&(this.node.fill=e.fill),e.coordinates2d&&(this.node.coordinates2d=e.coordinates2d)),this.node.onStateChange()}clone(){throw new Error("Clone not implemented")}}}},3269(e){const t={ALMOST_BLACK:[16,16,16,255],ALMOST_WHITE:[238,238,238,255],ANTIQUE_WHITE:[250,235,215,255],AQUA:[188,212,230,255],AQUAMARINE:[127,255,212,255],BEIGE:[245,245,220,255],BIG_GRAY:[221,221,221,255],BLACK:[0,0,0,255],BLAY:[87,102,117,255],BLUE:[0,0,255,255],BLUE_WHISPER:[240,248,255,255],BLEEN:[19,51,55,255],BLOOD:[153,0,0,255],BOOGER:[186,218,85,255],BRIGHT_GRAY:[198,226,255,255],BRONZE:[227,151,17,255],BROWN:[145,97,11,255],CANDY_GREEN:[90,193,142,255],CANDY_PINK:[255,115,115,255],CANDY_RED:[246,84,106,255],CHARCOAL:[51,51,51,255],CALM_BLUE:[8,141,165,255],COOL_BLUE:[64,114,148,255],COOL_GREEN:[180,238,180,255],CORAL:[255,127,80,255],CORPORATE_BEIGE:[203,203,169,255],CREAM:[240,224,136,255],CREAMSICLE:[255,195,160,255],CYAN:[0,255,255,255],DARK_TURQUOISE:[0,206,209,255],DEEP_BLUE:[0,51,102,255],DEEP_PURPLE:[102,0,102,255],DEEP_RED:[139,0,0,255],DIM_GRAY:[105,105,105,255],DULL_BLUE:[192,214,228,255],EMERALD:[39,89,45,255],EVERGREEN:[6,85,53,255],FRIENDLY_BLUE:[70,132,153,255],FUCHSIA:[255,0,255,255],FUNNY_PURPLE:[128,0,128,255],GOLD:[255,215,0,255],GOLDMEMBER:[218,165,32,255],GRAY:[192,192,192,255],GREEN:[0,255,0,255],GUN_METAL_GRAY:[102,102,102,255],HARD_ORANGE_RED:[255,64,64,255],HARD_PINK:[247,52,122,255],HG_BLACK:[26,26,26,255],HG_BLUE:[148,210,230,255],HG_RED:[241,112,112,255],HG_YELLOW:[255,247,143,255],INTERIOR_RED:[255,102,102,255],INVITATION_BLUE:[104,151,187,255],KHAKI:[255,246,143,255],LAVENDER:[230,230,250,255],LIGHT_CORAL:[240,128,128,255],LIGHT_SEA_GREEN:[32,178,170,255],NAVY:[0,0,128,255],MAGENTA:[255,0,255,255],MAROON:[128,0,0,255],MEAN_SEA:[129,216,208,255],MERLOT:[66,4,32,255],MINT:[102,205,170,255],MUSTARD:[232,219,32,255],NEON_BOOGER:[204,255,0,255],NEON_PINK:[255,128,237,255],ORANGE:[255,165,0,255],ORANGE_RED:[255,69,0,255],PALE_TURQUOISE:[175,238,238,255],PEACH:[255,218,185,255],PERFUME_PINK:[255,228,225,255],PERRYWINKLE:[204,204,255,255],PINK:[255,192,203,255],POWDER_BLUE:[176,224,230,255],PURPLE:[128,0,128,255],REAL_ESTATE_BLUE:[14,47,68,255],RED:[255,0,0,255],RUST:[128,0,0,255],SALMON:[250,128,114,255],SEA_GREEN:[0,128,128,255],SHARP_YELLOW:[255,255,102,255],SILVER:[192,192,192,255],SIMPLE_GRAY:[204,204,204,255],SLEEPY_PINK:[255,182,193,255],SMOKE:[245,245,245,255],SMOOTH_BLUE:[76,163,221,255],SOFT_GREEN:[211,255,206,255],SOFT_MINT:[182,252,213,255],SOFT_PINK:[255,192,203,255],STRESSED_PURPLE:[138,43,226,255],SKY_BLUE:[127,229,240,255],STANDARD_GRAY:[128,128,128,255],STORM_GRAY:[105,105,102,255],SUCCESS_GREEN:[0,128,0,255],TEAL:[0,128,128,255],TENSE_SKY:[102,204,204,255],TERRACOTTA:[226,114,91,255],THICK_LUXURY:[195,151,151,255],TURQUOISE:[64,224,208,255],WALLPAPER_BEIGE:[203,190,181,255],WALLPAPER_GREEN:[220,237,193,255],WHITE:[255,255,255,255],YELLOW:[255,255,0,255]},s=Object.keys(t);e.exports={COLORS:t,randomColor:function(e=[]){const r=e.length?((e,t)=>e.length===t.length?["WHITE"]:e.filter(e=>{for(const s of t)if(e===s)return!1;return!0}))(s,e):s,i=Math.floor(Math.random()*r.length);return t[r[i]]}}},2591(e){e.exports=class{constructor(){this.listeners=new Set,this.intervals=[],this.timeouts=[],this.playerInfoMap={}}addStateListener(e){this.listeners.add(e)}removeStateListener(e){this.listeners.delete(e)}findNode(e){let t=null;if(this.getLayers){const s=this.getLayers();for(let r in s)if(t=s[r].root.findChild(e),t)break}return t}setInterval(e,t){const s=setInterval(e,t);return this.intervals.push(s),s}setTimeout(e,t){const s=setTimeout(e,t);return this.timeouts.push(s),s}close(){for(const e in this.timeouts){const t=this.timeouts[e];clearTimeout(t)}for(const e in this.intervals){const t=this.intervals[e];clearInterval(t)}}}},51(e,t,s){const r=s(683),i=s(2714),{gameNode:n,BaseNode:o}=s(4732),a={[r.CIRCLE]:i.SHAPE_2D_CIRCLE,[r.POLYGON]:i.SHAPE_2D_POLYGON,[r.LINE]:i.SHAPE_2D_LINE},h={[i.SHAPE_2D_CIRCLE]:r.CIRCLE,[i.SHAPE_2D_POLYGON]:r.POLYGON,[i.SHAPE_2D_LINE]:r.LINE};class l extends o{constructor({color:e,onClick:t,shapeType:s,coordinates2d:r,border:i,fill:n,playerIds:o,effects:h,input:l,node:c,id:d,onHover:u,offHover:p,onDrag:f,offClick:m}){if(!(r&&s||c))throw new Error("Shape requires coordinates2d and shapeType");super({color:e,onClick:t,coordinates2d:r,border:i,fill:n,playerIds:o,effects:h,input:l,node:c,subtype:a[s],id:d,onHover:u,offHover:p,onDrag:f,offClick:m})}clone({handleClick:e,input:t,id:s}){const r=Number(s)||null;return new l({color:this.node.color,onClick:e,shapeType:h[this.node.subType],coordinates2d:this.node.coordinates2d,border:this.node.border,fill:this.node.fill,playerIds:this.node.playerIds,effects:this.node.effects,input:t,id:r})}}class c extends o{constructor({textInfo:e,playerIds:t,input:s,node:r,id:n,onClick:o,onHover:a,offHover:h,onDrag:l,offClick:c}){if(!e&&!r)throw new Error("Text node requires textInfo");super({textInfo:e,playerIds:t,input:s,node:r,subtype:i.TEXT,id:n,onClick:o,onHover:a,offHover:h,onDrag:l,offClick:c})}clone({handleClick:e,input:t,id:s}){const r=s||null;return new c({textInfo:Object.assign({},this.node.text),playerIds:this.playerIds?.slice(),id:r})}}class d extends o{constructor({assetInfo:e,onClick:t,coordinates2d:s,playerIds:r,effects:n,node:o,id:a,onHover:h,offHover:l,onDrag:c,offClick:d}){if(!e&&!o)throw new Error("Asset node requires assetInfo");super({assetInfo:e,onClick:t,coordinates2d:s,playerIds:r,effects:n,node:o,subtype:i.ASSET,id:a,onHover:h,offHover:l,onDrag:c,offClick:d})}clone({handleClick:e,input:t,id:s}){const r=s||null;return new d({assetInfo:Object.assign({},this.node.asset),playerIds:this.playerIds?.slice(),id:r})}}const u={Stream:class extends o{constructor({streamId:e,pos:t={x:0,y:0},size:s={x:0,y:0},audio:r=!0,node:n,...o}){if(!n&&!/^[A-Za-z0-9-]{1,64}$/.test(e||""))throw new Error("Stream requires a valid streamId");super({...o,node:n,subtype:i.STREAM}),n||(this.node.stream={id:e,pos:t,size:s,audio:!!r})}},Asset:d,Shape:l,Text:c};e.exports={gameNode:n,GameNode:u}},9798(e){e.exports=class{constructor(e,t,s,r,i,n,o,a=[],h=null,l=null,c=null,d=null,u,p,f,m){this.id=d?Number(d):Math.floor(999999999*Math.random()),this.children=new Array,this.color=e,this.handleClick=t,this.coordinates2d=s,this.border=r,this.fill=i,this.text=n,this.asset=o,this.effects=h,this.input=l,this.listeners=new Set,!a||a instanceof Array||(a=[a]),this.playerIds=a||[],this.subType=c,this.onHover=u,this.offHover=p,this.onDrag=f,this.offClick=m}addChild(e){this.children.push(e)}addChildren(...e){for(let t=0;t<e.length;t++)this.addChild(e[t])}removeChild(e){const t=this.children.findIndex(t=>t.node.id==e);t>=0&&(this._animation&&clearInterval(this._animation),this.children.splice(t,1))}addListener(e){this.listeners.add(e)}onStateChange(){for(const e of this.listeners)e.handleStateChange(this)}clearChildren(e){if(e){const t=this.children.filter(t=>e.includes(t.id));this.children=t}else this.children=new Array}}},683(e){e.exports={CIRCLE:1,POLYGON:2,LINE:3}},4455(e,t,s){const{squish:r,unsquish:i}=s(8824);e.exports=class{constructor({game:e,scale:t,customBottomLayer:s,customTopLayer:n,onAssetUpdate:o,encodeNode:a=r,decodeNode:h=i,autoTick:l=!0,loadAssets:c=!0,assetLoader:d}){if(this.encodeNode=a,this.decodeNode=h,this.loadAssets=c,this.assetLoader=d,this.observedNodes=new Set,this.closed=!1,this._nodeObservations=new Map,this._observationGeneration=0,this.ids=new Set,this.game=e,this.gameMetadata=e.constructor.metadata&&e.constructor.metadata(),this._assetBufferCache=Object.create(null),this.playerSettings={},this.customBottomLayer=s,this.customTopLayer=n,this.initialize(),this.onAssetUpdate=o,this.playerFrames={},this.listeners=new Set,this._dirty=!1,this._flushScheduled=!1,this.scale=t||{x:1,y:1},this.state=this.squish(this.game.getLayers()),l&&this.game.tick){const e=this.gameMetadata&&this.gameMetadata.tickRate?this.gameMetadata.tickRate:60;this._tickInterval=setInterval(this.game.tick.bind(this.game),1e3/e)}}addListener(e){const t={onEvent:e,remove:()=>this.removeListener(t)};this.listeners.add(t)}removeListener(e){this.listeners.delete(e)}unsquish(e){return this.decodeNode(e)}squish(e,t=null){this.records=[],this._publicRuns=[],this._playerRuns=new Map;const s=[],r=++this._observationGeneration;let i,n;const o=(e,t,a,h)=>{if(!e?.node)return;let l=this._nodeObservations.get(e);l?l.generation=r:(e.addListener(this),this.observedNodes.add(e),l={root:e,generation:r},this._nodeObservations.set(e,l));const c=e.node.playerIds,d=c?.length?[...a,c.map(Number)]:a;if(d!==a){const e=new Set;for(const t of d[d.length-1])Number.isFinite(t)&&(null===h||h.has(t))&&e.add(t);h=e}if(!n||h!==i){if(n={start:this.records.length,end:this.records.length},null===h)this._publicRuns.push(n);else for(const e of h){let t=this._playerRuns.get(e);t||this._playerRuns.set(e,t=[]),t.push(n)}i=h}const u=this.encodeNode(e,t);this.records.push({root:e,scopes:d,bytes:u}),s.push(u),n.end++;for(const s of e.node.children||[])o(s,t,d,h)};this.customBottomLayer&&o(this.customBottomLayer.root,this.customBottomLayer.scale||{x:1,y:1},[],null);for(const s in e||[])o(e[s].root,e[s].scale||t||this.scale||{x:1,y:1},[],null);this.customTopLayer&&o(this.customTopLayer.root,this.customTopLayer.scale||{x:1,y:1},[],null);for(const e of this._nodeObservations.values())if(e.generation!==r){const t=e.root;t.node.listeners.delete(this),this._nodeObservations.delete(t),this.observedNodes.delete(t)}return s}getPlayerFrame(e){this.flush();const t=Number(e);if(!Number.isFinite(t))return[[3,0,0,5,0]];const s=this._publicRuns,r=this._playerRuns.get(t)||[],i=!1===this.playerSettings[t]?.SOUND?.enabled,n=[];let o=0,a=0;for(;o<s.length||a<r.length;){const e=s[o],h=r[a],l=e&&(!h||e.start<h.start)?s[o++]:r[a++];for(let e=l.start;e<l.end;e++){const s=this.records[e];i&&this._isAudioMutedFor(s.root,t)||n.push(s.bytes)}}return n.length?n:[[3,0,0,5,0]]}close(){if(!this.closed){this.closed=!0,clearInterval(this._tickInterval),this.listeners.clear();for(const e of this.observedNodes)e.node.listeners.delete(this);this.observedNodes.clear(),this._nodeObservations.clear()}}handleNewAsset(e,t){const s=(this._assetUpdates||this._assetsPending||Promise.resolve()).catch(()=>{}).then(()=>(delete this._assetBufferCache[e],this.initialize().then(e=>(this.closed||this.onAssetUpdate?.(e),e))));return this._assetUpdates=s,s.then(()=>{this._assetUpdates===s&&(this._assetUpdates=null)},()=>{this._assetUpdates===s&&(this._assetUpdates=null)}),s}_isAudioMutedFor(e,t){if(e.node.stream?.audio)return!1===this.playerSettings[t]?.SOUND?.enabled;if(!e.node.asset)return!1;const s=Object.keys(e.node.asset)[0],r=this.gameAssets&&this.gameAssets[s]&&this.gameAssets[s].info;if(!r||"audio"!==r.type)return!1;const i=this.playerSettings[t]&&this.playerSettings[t].SOUND;return!(!i||!1!==i.enabled)}getJson(){const e=this.game.layers,t=new Array(e.length);for(const s in e){const r=e[s].root;t[s]=r}return JSON.stringify(t)}initialize(){if(this.gameAssets=Object.assign({},this.game.constructor.metadata?.()?.assets,this.customBottomLayer?.assets,this.customTopLayer?.assets,this.game.getAssets?.()),!this.loadAssets)return this.assetBundle=new Uint8Array(0),Promise.resolve(this.assetBundle);if(this._assetsPending)return this._assetsPending;const e=this.assetLoader||s(8826).N,t=this.gameAssets,r=Promise.resolve().then(()=>e(t,this._assetBufferCache)).then(e=>this.assetBundle=e);return this._assetsPending=r,r.then(()=>{this._assetsPending=null},()=>{this._assetsPending=null}),r}handleStateChange(e,t){this.closed||(this._dirty=!0,this._flushScheduled||(this._flushScheduled=!0,("function"==typeof setImmediate?setImmediate:e=>setTimeout(e,0))(()=>this.flush())))}flush(){this._flushScheduled=!1,!this.closed&&this._dirty&&(this._dirty=!1,this.state=this.squish(this.game.getLayers()),this.broadcast())}broadcast(){for(const e of this.listeners)e.onEvent(this.state)}updatePlayerSettings(e,t){const s=Object.assign(this.playerSettings[e]||{},t);this.playerSettings[e]=s}deletePlayerSettings(e){delete this.playerSettings[e]}}},2358(e,t,s){const{GameNode:r}=s(51),i=s(683),n=s(8926),o=s(3269),a=s(2591);e.exports=class extends a{constructor(e){var t;super(),this.planeSize=e,this.plane=(t=this.planeSize,new r.Shape({shapeType:i.POLYGON,coordinates2d:n.rectangle(0,0,t,t)})),this.fakeRoot=new r.Shape({shapeType:i.POLYGON,coordinates2d:n.rectangle(0,0,0,0),fill:o.COLORS.BLACK}),this.layers=[{root:this.fakeRoot}]}updatePlaneSize(e){this.planeSize=e,this.plane.node.coordinates2d=n.rectangle(0,0,e,e)}getLayers(){return this.layers}getPlane(){return this.plane}getPlaneSize(){return this.planeSize}getViewRoot(){return this.fakeRoot}}},8826(e){const t={image:1,audio:2,font:3,video:4};e.exports={N:async function(e,s=Object.create(null)){const r=[];for(const[i,n]of Object.entries(e)){if(!t[n.info?.type]||!/^[\x20-\x7e]{1,32}$/.test(i))throw new Error("Invalid asset declaration: "+i);if(!Object.hasOwn(s,i)){const e=n.data;if(!(e instanceof Uint8Array))throw new Error("The host must supply local asset bytes: "+i);const r=new Uint8Array(44+e.length);r[0]=1,r[1]=t[n.info.type],r.set((new TextEncoder).encode((e.length+32).toString(36).padStart(10,"0")),2),r.set((new TextEncoder).encode(i),12),r.set(e,44),s[i]=r}r.push(s[i])}const i=new Uint8Array(r.reduce((e,t)=>e+t.length,0));let n=0;for(const e of r)i.set(e,n),n+=e.length;return i}}},5889(e,t,s){const{GameNode:r}=s(51);e.exports={CONSTRUCTOR_TO_TYPE:{Asset:1,Shape:2,Text:3,Stream:4},TYPE_TO_CONSTRUCTOR:{1:r.Asset,2:r.Shape,3:r.Text,4:r.Stream}}},9512(e){e.exports={getPath:(e,t,s,r,i=100,n=100)=>{const o=[];let a=!0;for(;a;){const h=(0===o.length?e:o[o.length-1][0])+s,l=(0===o.length?t:o[o.length-1][1])+r;if(h<0||h>i||l<0||l>n){let e=h,t=l;h<0?e=0:h>i&&(e=i),l<0?t=0:l>n&&(t=n),o[o.length-1][0]!==e&&o[o.length-1][1]!==t&&o.push([e,t]),a=!1}else o.push([h,l])}return o}}},8824(e,t,s){const r=s(9798),{CONSTRUCTOR_TO_TYPE:i,TYPE_TO_CONSTRUCTOR:n}=s(5889),o=s(5791),{squishId:a}=s(9211),{squishColor:h}=s(8339),{squishPlayerIds:l}=s(9449),{squishPos:c}=s(3358),{squishFill:d}=s(2675),{squishSize:u}=s(303),{squishHandleClick:p}=s(6578),{squishOnHover:f}=s(4433),{squishBorder:m}=s(4928),{squishSubType:g}=s(1354),{squishInput:y}=s(828),{squishCoordinates2d:v}=s(4901),{squishEffect:w}=s(4167),{squishText:x}=s(421),{squishAsset:b}=s(9772),{squishStream:E}=s(6514),S={stream:E,id:a,color:h,playerIds:l,pos:c,coordinates2d:v,fill:d,size:u,text:x,asset:b,effects:w,handleClick:p,onHover:f,border:m,subType:g,input:y},k={};for(const e in S)k[Number(S[e].type)]=e;const _=(()=>{const e=Object.keys(S).filter(e=>S[e].dependsOn&&S[e].dependsOn.length>0);return[Object.keys(S).filter(e=>!S[e].dependsOn||0===S[e].dependsOn.length),e].flat()})();e.exports={squish:(e,t=null)=>{const s=[3,0,0,0,void 0];let r=5;const n=e.node;for(let e=0;e<_.length;e++){const i=_[e];if(i in n){const e=n[i];if(null!=e){const o=S[i],a=o.squish(e,t,n),h=a.length+3;r+=h,s.push(o.type,Math.min(255,Math.max(0,h-255)),Math.min(255,h));for(let e=0;e<a.length;e++)s.push(a[e])}}}let a=i[e.constructor.name];a||(a=i[o[n.subType]]);const h=Math.min(255,r),l=Math.min(255,Math.max(0,r-255)),c=Math.min(255,Math.max(0,r-510));return s[0]=3,s[1]=c,s[2]=l,s[3]=h,s[4]=a,s},unsquish:e=>{if(3!=e[0])throw new Error("Squished[0] isnt 3.");if(e.length!==e[1]+e[2]+e[3])throw new Error("Bad length value");let t=5,s=new r;for(;t<e.length;){const r=e[t],i=e[t+1]+e[t+2],n=e.subarray?e.subarray(t+3,t+i):e.slice(t+3,t+i);if(!k[r]){console.warn("Unknown sub frame type "+r);break}{const t=k[r],i=(0,S[t].unsquish)("playerIds"===t&&e.subarray?n.slice():n,s);s[t]=i}t+=i}const i=n[e[4]];return i?new i({node:s}):{node:s}}}},9772(e,t,s){const{getFractional:r}=s(6522),i={type:48,squish:(e,t)=>{const s=Object.keys(e)[0],i=new Array(18+s.length),n=e[s],o=t?t.x*n.pos.x+Math.round(100*(1-t.x))/2:n.pos.x,a=t?t.y*n.pos.y+Math.round(100*(1-t.y))/2:n.pos.y,h=t?t.x*n.size.x:n.size.x,l=t?t.y*n.size.y:n.size.y,c=n.startTime||0,d=n.cropLeft||0,u=n.cropTop||0,p=n.cropRight||0,f=n.cropBottom||0;i[0]=Math.floor(o),i[1]=r(o),i[2]=Math.floor(a),i[3]=r(a),i[4]=Math.floor(h),i[5]=r(h),i[6]=Math.floor(l),i[7]=r(l),i[8]=Math.floor(c),i[9]=r(c),i[10]=Math.floor(d),i[11]=r(d),i[12]=Math.floor(u),i[13]=r(u),i[14]=Math.floor(p),i[15]=r(p),i[16]=Math.floor(f),i[17]=r(f);for(let e=0;e<s.length;e++)i[18+e]=s.codePointAt(e);return i},unsquish:e=>{const t=e[0]+e[1]/100,s=e[2]+e[3]/100,r=e[4]+e[5]/100,i=e[6]+e[7]/100,n=e[8]+e[9]/100,o=e[10]+e[11]/100,a=e[12]+e[13]/100,h=e[14]+e[15]/100,l=e[16]+e[17]/100,c=String.fromCodePoint.apply(null,e.slice(18));return{[c]:{pos:{x:t,y:s},size:{x:r,y:i},startTime:n,cropLeft:o,cropTop:a,cropRight:h,cropBottom:l}}}};e.exports={squishAsset:i}},4928(e){e.exports={squishBorder:{type:54,squish:e=>[e],unsquish:e=>e[0]}}},8339(e){e.exports={squishColor:{type:42,squish:e=>[e[0],e[1],e[2],e[3]],unsquish:e=>[e[0],e[1],e[2],e[3]]}}},4901(e,t,s){const{getFractional:r}=s(6522),i=s(2714),n=e=>e<0?0:e>255?255:e,o=(e,t)=>t>0&&t<1?Math.max(0,Math.min(100,e)):e,a=(e,t)=>e*o(t,e)+Math.round(100*(1-e))/2,h={type:52,squish:(e,t,s)=>{if(s.subType===i.SHAPE_2D_POLYGON||s.subType===i.SHAPE_2D_LINE){const s=((e,t)=>{if(!Array.isArray(e))return null;let s,r;if(t&&(s=t.x,r=t.y,"number"!=typeof s||"number"!=typeof r))return null;for(let t=0;t<e.length;t++){const s=e[t];if(!Array.isArray(s)||2!==s.length||"number"!=typeof s[0]||"number"!=typeof s[1])return null}const i=new Array(4*e.length);if(t){const t=Math.round(100*(1-s))/2,o=Math.round(100*(1-r))/2,a=s>0&&s<1,h=r>0&&r<1;for(let l=0;l<e.length;l++){const c=e[l],d=n(s*(a?Math.max(0,Math.min(100,c[0])):c[0])+t),u=n(r*(h?Math.max(0,Math.min(100,c[1])):c[1])+o),p=Math.floor(d),f=Math.floor(u),m=4*l;i[m]=p,i[m+1]=Math.round(100*(d-p)),i[m+2]=f,i[m+3]=Math.round(100*(u-f))}}else for(let t=0;t<e.length;t++){const s=e[t],r=n(s[0]),o=n(s[1]),a=Math.floor(r),h=Math.floor(o),l=4*t;i[l]=a,i[l+1]=Math.round(100*(r-a)),i[l+2]=h,i[l+3]=Math.round(100*(o-h))}return i})(e,t);if(s)return s}const h=[];for(let t=0;t<e.length;t++){if(!(t in e))continue;const s=e[t];if(Array.isArray(s))for(let e=0;e<s.length;e++)e in s&&h.push(s[e]);else h.push(s)}const l=new Array(2*h.length);if(s.subType==i.SHAPE_2D_CIRCLE)if(t){const e=n(a(t.x,h[0]));l[0]=Math.floor(e),l[1]=r(e);const s=n(a(t.y,h[1]));let i;l[2]=Math.floor(s),l[3]=r(s),i=t.x===t.y?t.x*h[2]:Math.sqrt(Math.pow(100*t.x,2)+Math.pow(100*t.y,2))*(h[2]/100),l[4]=Math.floor(i),l[5]=r(i)}else{const e=n(h[0]);l[0]=Math.floor(e),l[1]=r(e);const t=n(h[1]);l[2]=Math.floor(t),l[3]=r(t);const s=h[2];l[4]=Math.round(s),l[5]=r(s)}else for(let e=0;e<h.length;e++)if(t){const s=e%2==0?t.x:t.y,i=s*o(h[e],s),a=Math.round(100*(1-s)),c=n(i+a/2);l[2*e]=Math.floor(c),l[2*e+1]=r(c)}else{const t=n(h[e]);l[2*e]=Math.floor(t),l[2*e+1]=Math.round(100*(t-Math.floor(t)))}return l},dependsOn:["subType"],unsquish:(e,{subType:t})=>{const s=new Array(e.length/2);for(let t=0;t<e.length;t+=2){const r=e[t]+e[t+1]/100;s[t/2]=r}if(t===i.SHAPE_2D_POLYGON||t===i.SHAPE_2D_LINE){const e=new Array(s.length/2);for(let t=0;t<s.length;t+=2)e[t/2]=[s[t],s[t+1]];return e}return s}};e.exports={squishCoordinates2d:h}},4167(e){const t={type:49,squish:e=>{if(e.shadow){const t="shadow";let s=t.length+4;e.shadow.blur&&(s+=2);const r=new Array(s);for(let e=0;e<t.length;e++)r[e]=t.codePointAt(e);return r[t.length]=e.shadow.color[0],r[t.length+1]=e.shadow.color[1],r[t.length+2]=e.shadow.color[2],r[t.length+3]=e.shadow.color[3],e.shadow.blur&&(r[t.length+4]=Math.floor(e.shadow.blur/10),r[t.length+5]=e.shadow.blur%10),r}},unsquish:e=>{const t=String.fromCodePoint.apply(null,e.slice(0,6)),s=e.slice(6,10);let r;e.length>10&&(r=10*e[10]+e[11]);const i={[t]:{color:s}};return r&&(i[t].blur=r),i}};e.exports={squishEffect:t}},2675(e){e.exports={squishFill:{type:53,squish:e=>[e[0],e[1],e[2],e[3]],unsquish:e=>[e[0],e[1],e[2],e[3]]}}},6578(e){e.exports={squishHandleClick:{type:50,squish:e=>e?[1]:[0],unsquish:e=>1===e[0]}}},9211(e){const t={type:43,squish:e=>{const t=e.toString();let s=new Array(12),r=0;for(;r<=12-t.length;r++)s[r]=0;for(let e=0;e<t.length;e++)s[e+r]=Number(t.charAt(e));return s},unsquish:e=>{let t=0;for(let s=0;s<e.length;s++)t+=e[s]*Math.pow(10,e.length-s-1);return Number(t)}};e.exports={squishId:t}},828(e){const t={type:51,squish:e=>{const t=new Array(e.type.length);for(let s=0;s<e.type.length;s++)t[s]=e.type.codePointAt(s);return t},unsquish:e=>({type:String.fromCodePoint.apply(null,e)})};e.exports={squishInput:t}},4433(e){e.exports={squishOnHover:{type:56,squish:e=>e?[1]:[0],unsquish:e=>1===e[0]}}},9449(e){e.exports={squishPlayerIds:{type:44,squish:e=>e,unsquish:e=>e}}},3358(e){const t=e=>Math.round(100*(e-Math.floor(e))),s={type:45,squish:e=>[Math.floor(e.x),t(e.x),Math.floor(e.y),t(e.y)],unsquish:e=>({x:e[0]+e[1]/100,y:e[2]+e[3]/100})};e.exports={squishPos:s}},303(e){const t=e=>{Math.round(100*(e-Math.floor(e)))},s={type:46,squish:e=>[Math.floor(e.x),t(e.x),Math.floor(e.y),t(e.y)],unsquish:e=>({x:e[0]+e[1]/100,y:e[2]+e[3]/100})};e.exports={squishSize:s}},6514(e,t,s){const{squishAsset:r}=s(9772),i={type:57,squish(e,t){if(!/^[A-Za-z0-9-]{1,64}$/.test(e.id||""))throw new Error("Stream requires a valid streamId");return[!1===e.audio?0:1,...r.squish({[e.id]:{pos:e.pos,size:e.size}},t)]},unsquish(e){const t=r.unsquish(e.slice(1)),s=Object.keys(t)[0];return{id:s,audio:1===e[0],pos:t[s].pos,size:t[s].size}}};e.exports={squishStream:i}},1354(e){e.exports={squishSubType:{type:55,squish:e=>[e],unsquish:e=>e[0]}}},421(e,t,s){const{hypLength:r}=s(6522),i=s(3269),{squishColor:n}=s(8339),o={type:47,squish:(e,t)=>{const s=t?e.x*t.x+Math.round(100*(1-t.x))/2:e.x,o=t?e.y*t.y+Math.round(100*(1-t.y))/2:e.y,a=[...e.align||"left"],h=[...e.font||"default"],l=[...e.text],c=new Array(12+3*(a.length+h.length+l.length));c[0]=Math.floor(s),c[1]=Math.round(100*(s-Math.floor(s))),c[2]=Math.floor(o),c[3]=Math.round(100*(o-Math.floor(o)));const d=e.size||1,u=t?d*r(t.x,t.y):d;c[4]=Math.floor(u),c[5]=Math.round(100*(u-Math.floor(u)));const p=e.color||i.BLACK,f=n.squish(p);for(let e=0;e<f.length;e++)c[6+e]=f[e];c[6+f.length]=3*a.length,c[6+f.length+1]=3*h.length;let m=0;for(let e=0;e<a.length;e++){const t=a[e].codePointAt(0).toString();let s;s=1==t.length?["00","00",`0${t}`]:2==t.length?["00","00",`${t}`]:3==t.length?["00",`0${t.charAt(0)}`,`${t.charAt(1)}${t.charAt(2)}`]:4==t.length?["00",`${t.charAt(0)}${t.charAt(1)}`,`${t.charAt(2)}${t.charAt(3)}`]:5==t.length?[`0${t.charAt(0)}`,`${t.charAt(1)}${t.charAt(2)}`,`${t.charAt(3)}${t.charAt(4)}`]:[`${t.charAt(0)}${t.charAt(1)}`,`${t.charAt(2)}${t.charAt(3)}`,`${t.charAt(4)}${t.charAt(5)}`],c[6+f.length+2+m]=Number(s[0]),c[6+f.length+2+m+1]=Number(s[1]),c[6+f.length+2+m+2]=Number(s[2]),m+=3}let g=0;for(let e=0;e<h.length;e++){const t=h[e].codePointAt(0).toString();let s;s=1==t.length?["00","00",`0${t}`]:2==t.length?["00","00",`${t}`]:3==t.length?["00",`0${t.charAt(0)}`,`${t.charAt(1)}${t.charAt(2)}`]:4==t.length?["00",`${t.charAt(0)}${t.charAt(1)}`,`${t.charAt(2)}${t.charAt(3)}`]:5==t.length?[`0${t.charAt(0)}`,`${t.charAt(1)}${t.charAt(2)}`,`${t.charAt(3)}${t.charAt(4)}`]:[`${t.charAt(0)}${t.charAt(1)}`,`${t.charAt(2)}${t.charAt(3)}`,`${t.charAt(4)}${t.charAt(5)}`];let r=6+f.length+2+3*a.length;c[r+g]=Number(s[0]),c[r+g+1]=Number(s[1]),c[r+g+2]=Number(s[2]),g+=3}let y=0;for(let e=0;e<l.length;e++){const t=l[e].codePointAt(0).toString();let s;s=1==t.length?["00","00",`0${t}`]:2==t.length?["00","00",`${t}`]:3==t.length?["00",`0${t.charAt(0)}`,`${t.charAt(1)}${t.charAt(2)}`]:4==t.length?["00",`${t.charAt(0)}${t.charAt(1)}`,`${t.charAt(2)}${t.charAt(3)}`]:5==t.length?[`0${t.charAt(0)}`,`${t.charAt(1)}${t.charAt(2)}`,`${t.charAt(3)}${t.charAt(4)}`]:[`${t.charAt(0)}${t.charAt(1)}`,`${t.charAt(2)}${t.charAt(3)}`,`${t.charAt(4)}${t.charAt(5)}`];let r=6+f.length+2+3*a.length+3*h.length;c[r+y]=Number(s[0]),c[r+y+1]=Number(s[1]),c[r+y+2]=Number(s[2]),y+=3}return c},unsquish:e=>{const t=e[0]+e[1]/100,s=e[2]+e[3]/100,r=e[4]+e[5]/100,i=e.slice(6,10),n=e[10],o=e[11],a=e.slice(12,12+n),h=e.slice(12+n,12+n+o),l=e.slice(12+n+o);let c=[];for(let e=0;e<a.length;e+=3){let t=a[e].toString();1==t.length&&(t=`0${t}`);let s=a[e+1].toString();1==s.length&&(s=`0${s}`);let r=a[e+2].toString();1==r.length&&(r=`0${r}`);const i=t+s+r;c.push(i)}const d=String.fromCodePoint.apply(null,c);let u=[];for(let e=0;e<h.length;e+=3){let t=h[e].toString();1==t.length&&(t=`0${t}`);let s=h[e+1].toString();1==s.length&&(s=`0${s}`);let r=h[e+2].toString();1==r.length&&(r=`0${r}`);const i=t+s+r;u.push(i)}const p=String.fromCodePoint.apply(null,u),f=[];for(let e=0;e<l.length;e+=3){let t=l[e].toString();1==t.length&&(t=`0${t}`);let s=l[e+1].toString();1==s.length&&(s=`0${s}`);let r=l[e+2].toString();1==r.length&&(r=`0${r}`);const i=t+s+r;f.push(i)}return{x:t,y:s,text:String.fromCodePoint.apply(null,f),size:r,color:i,align:d,font:p}}};e.exports={squishText:o}},5791(e,t,s){const{GameNode:r}=s(51),i=s(2714);e.exports={[[i.STREAM]]:r.Stream,[[i.ASSET]]:r.Asset,[[i.TEXT]]:r.Text,[[i.SHAPE_2D_POLYGON]]:r.Shape,[[i.SHAPE_2D_CIRCLE]]:r.Shape,[[i.SHAPE_2D_LINE]]:r.Shape}},2714(e){e.exports={STREAM:6,ASSET:1,TEXT:2,SHAPE_2D_POLYGON:3,SHAPE_2D_CIRCLE:4,SHAPE_2D_LINE:5}},6007(e,t,s){const{getRandomTerrain:r,getRandomStartPoint:i}=s(2553),n=e=>{for(let t=0;t<e.length;t++)for(let s=0;s<e[t].length;s++)e[t][s]={filled:e[t][s].filled,north:e[t][s].north,south:e[t][s].south,east:e[t][s].east,west:e[t][s].west}},o=(e,t,s,a,h,l=0)=>{if(0===s||3===l)return e;const c=(e=>{const t=[];return e.forEach((e,s)=>{t[s]=[],e.forEach(e=>{t[s].push({...e})})}),t})(e);r()(c,i(a,h,t),a,h,t);const d=((e,t,s,r)=>{const i=[];for(let o=0;o<s;o++)for(let s=0;s<r;s++){const r=[],a={x:o,y:s};for(;;){const s=e[a.x][a.y];if(i.findIndex(e=>e.x===a.x&&e.y===a.y)>-1||a.x===t.x&&a.y===t.y||s.filled){i.push(...r);break}if((!s.north||s.wentNorth)&&(!s.south||s.wentSouth)&&(!s.east||s.wentEast)&&(!s.west||s.wentWest))return!1;if(r.push({...a}),s.south&&!s.wentSouth)s.wentSouth=!0,a.y=a.y+1;else if(s.east&&!s.wentEast)s.wentEast=!0,a.x=a.x+1;else if(s.north&&!s.wentNorth)s.wentNorth=!0,a.y=a.y-1;else{if(!s.west||s.wentWest)return!1;s.wentWest=!0,a.x=a.x-1}}n(e)}return!0})(c,t,a,h);return d?o(c,t,s-1,a,h,0):o(e,t,s,a,h,l+1)};e.exports={terrainGenerator:(e={x:100,y:100},t={x:5,y:5},s=5)=>{const{width:r,height:i}=((e,t)=>{const s=e.x,r=e.y,i=t.x,n=t.y;return{width:Math.floor(s/i),height:Math.floor(r/n)}})(e,t);let n=((e,t)=>{const s=[],r={filled:!1,north:!0,south:!0,east:!0,west:!0};for(let i=0;i<e;i++){s[i]=[];for(let n=0;n<t;n++){const o={...r};0===i?o.west=!1:i===e-1&&(o.east=!1),0===n?o.north=!1:n===t-1&&(o.south=!1),s[i].push(o)}}return s})(r,i);const a={x:Math.floor(Math.random()*r),y:Math.floor(Math.random()*i)};return n=o(n,a,s,r,i),n}}},2553(e){const t=(e,{x:t,y:s},r,i,n)=>{t<0||t>=r||s<0||s>=i||t===n.x&&s===n.y||e[t][s].filled||(e[t][s].north&&(e[t][s-1].south=!1),e[t][s].south&&(e[t][s+1].north=!1),e[t][s].east&&(e[t+1][s].west=!1),e[t][s].west&&(e[t-1][s].east=!1),e[t][s].filled=!0,e[t][s].north=!1,e[t][s].south=!1,e[t][s].east=!1,e[t][s].west=!1)},s=[(e,{x:s,y:r},i,n,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},i,n,o),0===a?(t(e,{x:s+1,y:r},i,n,o),t(e,{x:s,y:r+1},i,n,o),t(e,{x:s+1,y:r+1},i,n,o)):1===a?(t(e,{x:s-1,y:r},i,n,o),t(e,{x:s,y:r+1},i,n,o),t(e,{x:s-1,y:r+1},i,n,o)):2===a?(t(e,{x:s,y:r-1},i,n,o),t(e,{x:s+1,y:r},i,n,o),t(e,{x:s+1,y:r-1},i,n,o)):(t(e,{x:s,y:r-1},i,n,o),t(e,{x:s-1,y:r},i,n,o),t(e,{x:s-1,y:r-1},i,n,o))},(e,{x:s,y:r},i,n,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},i,n,o),0===a?(t(e,{x:s,y:r+1},i,n,o),t(e,{x:s,y:r+2},i,n,o),t(e,{x:s,y:r+3},i,n,o)):1===a?(t(e,{x:s+1,y:r},i,n,o),t(e,{x:s+2,y:r},i,n,o),t(e,{x:s+3,y:r},i,n,o)):2===a?(t(e,{x:s-1,y:r},i,n,o),t(e,{x:s-2,y:r},i,n,o),t(e,{x:s-3,y:r},i,n,o)):(t(e,{x:s,y:r-1},i,n,o),t(e,{x:s,y:r-2},i,n,o),t(e,{x:s,y:r-3},i,n,o))},(e,{x:s,y:r},i,n,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},i,n,o),0===a?(t(e,{x:s,y:r+1},i,n,o),t(e,{x:s,y:r+2},i,n,o),t(e,{x:s+1,y:r+2},i,n,o)):1===a?(t(e,{x:s+1,y:r},i,n,o),t(e,{x:s+2,y:r},i,n,o),t(e,{x:s+2,y:r-1},i,n,o)):2===a?(t(e,{x:s-1,y:r},i,n,o),t(e,{x:s-2,y:r},i,n,o),t(e,{x:s-2,y:r+1},i,n,o)):(t(e,{x:s,y:r-1},i,n,o),t(e,{x:s,y:r-2},i,n,o),t(e,{x:s-1,y:r-2},i,n,o))},(e,{x:s,y:r},i,n,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},i,n,o),0===a?(t(e,{x:s,y:r+1},i,n,o),t(e,{x:s-1,y:r+1},i,n,o),t(e,{x:s-1,y:r+2},i,n,o)):1===a?(t(e,{x:s+1,y:r},i,n,o),t(e,{x:s+1,y:r+1},i,n,o),t(e,{x:s+2,y:r+1},i,n,o)):2===a?(t(e,{x:s-1,y:r},i,n,o),t(e,{x:s-1,y:r+1},i,n,o),t(e,{x:s-2,y:r+1},i,n,o)):(t(e,{x:s,y:r-1},i,n,o),t(e,{x:s-1,y:r-1},i,n,o),t(e,{x:s-1,y:r-2},i,n,o))}];e.exports={getRandomTerrain:()=>s[Math.floor(Math.random()*s.length)],getRandomStartPoint:(e,t,s)=>{const r={x:Math.floor(Math.random()*e),y:Math.floor(Math.random()*t)};for(;r.x===s.x&&r.y===s.y;)r.x=Math.floor(Math.random()*e),r.y=Math.floor(Math.random()*t);return r}}},8408(e){const t=(e,s,r,i=[])=>{if(!r||r(e)&&e.node.id!==s.node.id){const t=e.node.text,r=e.node.coordinates2d||[[t.x,t.y],[t.x,t.y],[t.x,t.y],[t.x,t.y],[t.x,t.y]],n=s.node.coordinates2d,o=r[0][0],a=r[1][0],h=n[0][0],l=n[1][0],c=r[0][1],d=r[2][1],u=n[0][1],p=n[2][1];l<o||a<h||c>p||u>d||i.push(e)}for(const n in e.node.children)t(e.node.children[n],s,r,i);return i};e.exports={checkCollisions:(e,s,r=null)=>t(e,s,r)}},6522(e){e.exports={hypLength:(e,t)=>Math.sqrt(Math.pow(e,2)+Math.pow(t,2)),getFractional:e=>Math.round(100*(e-Math.floor(e)))}},8926(e){e.exports={triangle:(e,t,s,r,i,n)=>[[e,t],[s,r],[i,n],[e,t]],rectangle:(e,t,s,r)=>[[e,t],[e+s,t],[e+s,t+r],[e,t+r],[e,t]]}},1924(e,t,s){const{GameNode:r}=s(51),i=s(683),n=s(8926),o=s(8408),a=s(3269);e.exports={getView:(e,t,s,h={},l={})=>{const c=o.checkCollisions(e,{node:{coordinates2d:n.rectangle(t.x,t.y,t.w,t.h)}},t=>t.node.id!==e.node.id),d=new r.Shape({shapeType:i.POLYGON,coordinates2d:n.rectangle(0,0,0,0),fill:a.COLORS.BLACK}),u=[];return c.length>0&&c.forEach(e=>{const r=[],i=[],n=e.node.coordinates2d||[[e.node.text.x,e.node.text.y],[e.node.text.x,e.node.text.y],[e.node.text.x,e.node.text.y],[e.node.text.x,e.node.text.y],[e.node.text.x,e.node.text.y]];for(let s in n){const o=n[s],a=o[0],c=o[1];let d=Math.max(Math.min(a-t.x,100),0),u=Math.max(Math.min(c-t.y,100),0);d=(l.x||1)*d,u=(l.y||1)*u;const p=!h.filter||h.filter(e);p&&(h.x&&(d+=h.x),h.y&&(u+=h.y)),d<0?d=0:d>100&&(d=100),u<0?u=0:u>100&&(u=100),r.push([d,u]);let f=(l.x||1)*(a-t.x),m=(l.y||1)*(c-t.y);p&&(h.x&&(f+=h.x),h.y&&(m+=h.y)),i.push([f,m])}{const t=e.clone({handleClick:null===e.node.handleClick||void 0===e.node.handleClick?null:e.node.handleClick,id:e.node.id});if(r&&r.length&&(t.node.text&&(t.node.text.x=r[0][0],t.node.text.y=r[0][1]),r.length&&(t.node.coordinates2d=r),t.node.asset)){const e=t.node.coordinates2d[0],s=t.node.coordinates2d[1],r=t.node.coordinates2d[2],n=s[0]-e[0],o=r[1]-s[1],a=Object.values(t.node.asset)[0];a.pos.x=e[0],a.pos.y=e[1],a.size.x=n,a.size.y=o;const h=i[0],l=i[2],c=l[0]-h[0],d=l[1]-h[1];c>0&&(a.cropLeft=100*Math.max(0,(0-h[0])/c),a.cropRight=100*Math.max(0,(l[0]-100)/c)),d>0&&(a.cropTop=100*Math.max(0,(0-h[1])/d),a.cropBottom=100*Math.max(0,(l[1]-100)/d))}t.node.playerIds=s||[],u.push(t)}}),u.forEach(e=>d.addChild(e)),d}}},5305(e,t,s){const{packAssetBundle:r}=s(3735);e.exports={packAssetBundle:r}},6899(e,t,s){const{describeMedia:r}=s(3947),i=e=>{let t="";for(let s=0;s<e.length;s+=32768)t+=String.fromCharCode.apply(null,e.slice(s,s+32768));return t};e.exports=class{constructor(){this.assets={},this.imageCache={},this.audioCtx=null,this.mediaPlayers=new Set,this.mediaUnlocked=!1,this.onAssetReady=null}_notifyReady(){"function"==typeof this.onAssetReady&&this.onAssetReady()}unlockAudio(){this.mediaUnlocked=!0;for(const e of this.mediaPlayers)e.unlock();this.audioCtx||(this.audioCtx=new(window.AudioContext||window.webkitAudioContext)),"suspended"===this.audioCtx.state&&this.audioCtx.resume();for(const e in this.assets){const t=this.assets[e];if("audio"===t.type&&!t.decoded&&!t.decoding){t.decoding=!0;const s=e=>{t.decoding=!1,console.warn("Unable to decode audio:",e)};try{this.audioCtx.decodeAudioData(t.data.slice(0),s=>{this.assets[e]===t&&(t.data=s,t.decoded=!0,t.decoding=!1,this._notifyReady())},s)}catch(e){s(e)}}}}storeAssets(e){let t=0;for(;e&&t<e.length&&1===e[t];){const s=e[t+1],r=String.fromCharCode.apply(null,e.slice(t+2,t+12)),i=parseInt(r,36);if(!Number.isFinite(i)||i<=0)break;const n=e.slice(t+12,t+12+32),o=String.fromCharCode.apply(null,n.filter(e=>e)),a=e.slice(t+12+32,t+12+i),h=1===s?"image":2===s?"audio":3===s?"font":4===s?"video":null;h&&this.storeRawAsset(o,h,a),t+=12+i}}storeRawAsset(e,t,s){const n=s instanceof Uint8Array||s instanceof Uint8ClampedArray?s:Uint8Array.from(s),o=this.assets[e];if(o?.url&&URL.revokeObjectURL(o.url),"image"===t){const t=r(n).contentType||(e=>{if(e.length>3&&137===e[0]&&80===e[1]&&78===e[2]&&71===e[3])return"image/png";if(e.length>2&&71===e[0]&&73===e[1]&&70===e[2])return"image/gif";if(e.length>11&&87===e[8]&&69===e[9]&&66===e[10]&&80===e[11])return"image/webp";const t=i(e.subarray(0,1024)).replace(/^\xEF\xBB\xBF/,"");return/^\s*(?:<\?xml\b[^?]*\?>\s*)?<svg\b/i.test(t)?"image/svg+xml":"image/jpeg"})(n);this.assets[e]={type:"image",data:`data:${t};base64,`+btoa(i(n))},delete this.imageCache[e],this._notifyReady()}else if("audio"===t)if(this.audioCtx)try{this.audioCtx.decodeAudioData(n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength),t=>{this.assets[e]={type:"audio",data:t,decoded:!0},this._notifyReady()},e=>{console.warn("Unable to decode audio:",e)})}catch(e){console.warn("Unable to decode audio:",e)}else this.assets[e]={type:"audio",data:n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength),decoded:!1};else if("video"===t){const t=r(n);this.assets[e]={type:"video",data:new Blob([n],{type:t.contentType||"video/mp4"}),url:null},this._notifyReady()}else if("font"===t)try{new FontFace(e,n).load().then(t=>{document.fonts.add(t),this.assets[e]={type:"font",data:t,name:e},this._notifyReady()}).catch(e=>{console.warn("Unable to load font:",e)})}catch(e){console.warn("Unable to load font:",e)}}getImage(e){if(this.imageCache[e]&&"loading"!==this.imageCache[e])return this.imageCache[e];if(!this.imageCache[e]&&this.assets[e]&&"image"===this.assets[e].type){const t=this.assets[e],s=new Image;this.imageCache[e]="loading",s.onload=()=>{this.assets[e]===t&&(this.imageCache[e]=s,this._notifyReady())},s.src=t.data}return null}destroy(){this.liveMedia?.destroy();for(const e of[...this.mediaPlayers])e.destroy();for(const e of Object.values(this.assets))e.url&&URL.revokeObjectURL(e.url);this.audioCtx&&(this.audioCtx.close().catch(()=>{}),this.audioCtx=null),this.assets={},this.imageCache={}}}},9630(e,t,s){const{squishMap:r,DEFAULT_VERSION:i}=s(9732),{normalizePath:n,resolveInFiles:o}=s(3735);e.exports={loadGameClass:({files:e,entryPoint:t})=>{if(!e||!t)throw new Error("loadGameClass requires { files, entryPoint }");const i={};for(const t of Object.keys(e))i[n(t)]=e[t];const a={},h=new Set,l=e=>{if(a[e])return a[e].exports;const t=e.includes("/")?e.slice(0,e.lastIndexOf("/")):"",s=s=>{const n=/^squish-(\d+)$/.exec(s);if(n){if(h.add(n[1]),h.size>1)throw new Error("Mixed Squish runtimes are unsupported");const e=r[n[1]];if(e)return e;throw new Error("Unsupported Squish runtime: "+s)}if(s.startsWith("./")||s.startsWith("../")){const r=o(i,t,s);if(r)return l(r);throw new Error("Cannot resolve require('"+s+"') from "+e+" — not in the game source map")}throw new Error("Game tried to require('"+s+"') — local games may only require their squish version and their own files")},n={exports:{}};a[e]=n;const c=i[e];if(e.endsWith(".json"))try{return n.exports=JSON.parse(c),n.exports}catch(t){throw delete a[e],new Error("Invalid JSON module "+e+": "+t.message)}const d=new Function("module","exports","require","__filename","__dirname",c);try{d(n,n.exports,s,e,t)}catch(t){throw delete a[e],t}return n.exports},c=n(t);if(!Object.prototype.hasOwnProperty.call(i,c))throw new Error('Entry point "'+t+'" not found in game source map');const d=l(c);if(h.size){const{normalizeMetadata:e,bindRuntimeMetadata:t}=s(2439),r="function"==typeof d.metadata?d.metadata():{};t(d,e(r,{runtime:[...h][0],legacy:!0}))}return d}}},1768(e,t,s){const r=s(6899),i=s(549),n=s(7868);e.exports={GameView:class{constructor({container:e,assetManager:t,send:s,gamepad:o,onAssetReady:a,onLayout:h,onResize:l}){this.container=e,this.onLayout=h,this.onResize=l,e.innerHTML="",Object.assign(e.style,{position:e.style.position||"relative",overflow:"hidden",background:"#000"}),this.canvas=document.createElement("canvas"),this.canvas.tabIndex=-1,Object.assign(this.canvas.style,{display:"block",position:"absolute",margin:"0",cursor:"default",webkitTapHighlightColor:"transparent",webkitTouchCallout:"none",webkitUserSelect:"none",userSelect:"none",touchAction:"none"}),this.cursor=null,this.cursorOverride=null,this._cursorRaster=null,e.appendChild(this.canvas),this.ownsAssets=!t,this.assetManager=t||new r,this.ownsAssets&&(this.assetManager.onAssetReady=a),this.renderer=new i(this.canvas,this.assetManager),this.inputHandler=new n(this.canvas,s,()=>this.renderer.thingIndices,this.assetManager,o),this.inputHandler.attach(),window.ResizeObserver&&(this._resizeObserver=new window.ResizeObserver(()=>{this.aspectRatio&&!this.destroyed&&this.resize(this.aspectRatio)}),this._resizeObserver.observe(e))}setCursor(e){this.destroyed||(this.cursor?.assetKey===e?.assetKey&&this.cursor?.size?.width===e?.size?.width&&this.cursor?.size?.height===e?.size?.height||(this._cursorRaster=null),this.cursor=e&&{assetKey:e.assetKey,hotspot:{...e.hotspot},...e.size?{size:{...e.size}}:{},...void 0!==e.pointerLock?{pointerLock:e.pointerLock}:{}},this.inputHandler.setPointerLockSuspended(!1===e?.pointerLock),this.refreshCursor())}setCursorOverride(e){this.destroyed||(this.cursorOverride=e,this.refreshCursor())}refreshCursor(){if(!this.destroyed)if(this._refreshingCursor)this._cursorRefreshPending=!0;else{this._refreshingCursor=!0;try{do{this._cursorRefreshPending=!1;let e=this.cursorOverride||"default";const t=this.cursor&&this.assetManager.assets[this.cursor.assetKey];if(this._cursorRaster?.data!==t?.data&&(this._cursorRaster=null),!this.cursorOverride&&"image"===t?.type&&"string"==typeof t.data){const s=this._cursorImageUrl(t);if(s){const{x:t,y:r}=this.cursor.hotspot;e=`url("${s}") ${t} ${r}, default`}}this.canvas.style.cursor!==e&&(this.canvas.style.cursor=e)}while(this._cursorRefreshPending&&!this.destroyed)}finally{this._refreshingCursor=!1}}}_cursorImageUrl(e){if(!this.cursor.size)return e.data;const t=this.assetManager.getImage(this.cursor.assetKey);if(!t)return null;const{width:s,height:r}=this.cursor.size,i=this._cursorRaster;if(i?.data===e.data&&i.image===t&&i.width===s&&i.height===r)return i.url;const n=this._cursorRaster={data:e.data,image:t,width:s,height:r,url:null};try{const e=document.createElement("canvas");e.width=s,e.height=r,e.getContext("2d").drawImage(t,0,0,s,r),n.url=e.toDataURL("image/png")}catch(e){}return n.url}resize(e){if(this.destroyed||!Number.isFinite(e?.x)||!Number.isFinite(e?.y)||e.x<=0||e.y<=0)return;const t=this.aspectRatio?.x!==e.x||this.aspectRatio?.y!==e.y;this.aspectRatio={x:e.x,y:e.y};const s=this.container.homegamesToolbar||this.container.closest?.(".hg-session-frame")?.querySelector?.(".hg-session-bar")?.homegamesToolbar;if(s?.setAspectRatio?.(this.aspectRatio),t&&this.onLayout?.({...this.aspectRatio}),this.destroyed)return;const r=this.container.clientWidth||window.innerWidth,i=this.container.clientHeight||window.innerHeight,n=r*e.y/e.x<=i,o=n?r:Math.floor(i*e.x/e.y),a=n?Math.floor(r*e.y/e.x):i,h=this.canvas.width!==2*o||this.canvas.height!==2*a;h&&(this.canvas.width=2*o,this.canvas.height=2*a),this.canvas.style.width=o+"px",this.canvas.style.height=a+"px",this.canvas.style.left=Math.floor((r-o)/2)+"px",this.canvas.style.top=Math.floor((i-a)/2)+"px",this.inputHandler.clientWidth=o,this.inputHandler.clientHeight=a,h&&this.onResize?.()}destroy(){this.destroyed||(this.destroyed=!0,this._resizeObserver?.disconnect(),this.cursor=null,this.cursorOverride=null,this._cursorRaster=null,this.canvas.style.cursor="default",this.inputHandler.detach(),this.renderer.stopAllSounds(),this.ownsAssets&&(this.assetManager.onAssetReady=null,this.assetManager.destroy()),this.canvas.remove())}},FrameLoop:class{constructor(e){this.paint=e,this.running=!1,this.id=null}start(){this.running||(this.running=!0,this.tick())}tick(){this.id=null,this.running&&(this.paint(),this.running&&(this.id=requestAnimationFrame(()=>this.tick())))}stop(){this.running=!1,null!==this.id&&cancelAnimationFrame(this.id),this.id=null}},getClientInfo:()=>{const e=navigator.userAgent;let t="desktop";/(tablet|ipad|playbook|silk)|(android(?!.*mobi))/i.test(e)?t="tablet":/Mobile|iP(hone|od)|Android|BlackBerry|IEMobile|Kindle|Silk-Accelerated|(hpw|web)OS|Opera M(obi|ini)/.test(e)?t="mobile":navigator.maxTouchPoints>2&&(t="tablet");const s={deviceType:t};return window.innerWidth&&window.innerHeight&&(s.aspectRatio=window.innerWidth/window.innerHeight),s}}},5562(e,t,s){const{Homepad:r,mapGamepad:i}=s(1011),n=s(6260);e.exports=class{constructor(e,t={}){this.send=e,this.index=t.index??null,this.homepad=new r(t),this.onError=t.onError||(e=>console.warn("Gamepad input:",e)),this.previous=new Map,this.nextPoll=0,this.lastPoll=null,this.errorMessage=null}tick(e=Date.now()){if(e+.001<this.nextPoll)return;const t=null===this.lastPoll?1/30:Math.min(.1,Math.max(0,(e-this.lastPoll)/1e3));let s;this.lastPoll=e;try{if(s=this.homepad.getGamepads().filter(e=>null===this.index||e.index===this.index),this.homepad.error)throw this.homepad.error;this.errorMessage=null}catch(e){return this.release(),this.errorMessage!==e.message&&this.onError(e),void(this.errorMessage=e.message)}const r=Math.max(1e3/30,1e3*s.length/60),i=Math.max(0,e-this.nextPoll);this.nextPoll=e+r-i%r;const n=new Map(s.map(e=>[e.index,e]));for(const[e,t]of this.previous)n.has(e)&&n.get(e).id===t.id||this._release(t);for(const e of s)this.send(JSON.stringify({type:"input",gamepad:!0,gamepadIndex:e.index,connected:!0,deltaTime:t,input:e.state}));this.previous=n}_release(e){this.send(JSON.stringify({type:"input",gamepad:!0,gamepadIndex:e.index,connected:!1,deltaTime:0,input:i({buttons:[],axes:[]},n)}))}release(){for(const e of this.previous.values())this._release(e);this.previous.clear(),this.nextPoll=0,this.lastPoll=null}setIndex(e){this.release(),this.index=e}}},9225(e){e.exports=function(e,t=()=>{}){let s=null,r=null,i=!1;const n=async e=>{const t=await fetch("/household-rooms",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),keepalive:!0});if(!t.ok)throw new Error("Unable to list this game on your home server");return t.json()};return{onRoom(o){i=!1;const a=new URLSearchParams(new URL(o).hash.slice(1)),h=r=n({gameKey:e.gameKey,versionId:e.versionId,roomId:a.get("room"),invite:a.get("invite")});h.then(e=>{i||r!==h?n({...e,remove:!0}).catch(()=>{}):s=e}).catch(t)},onHeartbeat(e){s&&n({...s,playerCount:e}).catch(e=>{s=null,t(e)})},onEnd(){i=!0,r=null,s&&n({...s,remove:!0}).catch(()=>{}),s=null}}}},9311(e){const t=["image/jpeg","image/webp"];let s=null;const r=(e,t)=>{if("function"==typeof OffscreenCanvas)return new OffscreenCanvas(e,t);const s=document.createElement("canvas");return s.width=e,s.height=t,s},i=(e,t,s)=>e.convertToBlob?e.convertToBlob({type:t,quality:s}):new Promise((r,i)=>{e.toBlob(e=>{e?r(e):i(new Error("Canvas encoding failed"))},t,s)}),n=(e,t)=>{if(!e)return e;const s="image/webp"===t?".webp":".jpg",r=e.lastIndexOf(".");return(r>0?e.slice(0,r):e)+s},o=(e,t,s)=>{const i=Math.max(16,Math.round(e.width*t)),n=Math.max(16,Math.round(e.height*t)),o=r(i,n),a=o.getContext("2d");return s&&(a.fillStyle="#ffffff",a.fillRect(0,0,i,n)),a.drawImage(e.source,0,0,i,n),o};e.exports={fitImageToSize:async(e,a,h={})=>{if(!e||"number"!=typeof e.size)throw new Error("Expected a Blob or File");if(!(a>0))throw new Error("maxBytes must be a positive number");const l=h.fileName||e.name||null,c=e.type||null;if(e.size<=a)return{blob:e,contentType:c,fileName:l,resized:!1};const d=await(async e=>{if("function"==typeof createImageBitmap)try{const t=await createImageBitmap(e);return{source:t,width:t.width,height:t.height,close:()=>t.close&&t.close()}}catch(e){}if("undefined"==typeof document)throw new Error("Not decodable as an image");return new Promise((t,s)=>{const r=URL.createObjectURL(e),i=new Image;i.onload=()=>{URL.revokeObjectURL(r),t({source:i,width:i.naturalWidth,height:i.naturalHeight,close:()=>{}})},i.onerror=()=>{URL.revokeObjectURL(r),s(new Error("Not decodable as an image"))},i.src=r})})(e);try{const e=-1!==t.indexOf(c),h=e?c:await(async()=>{if(null!==s)return s;const e=await i(r(1,1),"image/webp",.8).catch(()=>null);return s=!!e&&"image/webp"===e.type,s})()?"image/webp":"image/jpeg";let u=.85,p=1,f=null;for(let e=0;e<10;e++){const e=o(d,p,"image/jpeg"===h),t=await i(e,h,u);if((!f||t.size<f.size)&&(f=t),t.size<=a)break;if(u>.6)u=Math.max(.6,u-.15);else{if(Math.min(d.width,d.height)*p<=16)break;p*=Math.max(.3,.9*Math.sqrt(a/t.size))}}if(!f||f.size>a)throw new Error(`Could not fit image into ${a} bytes`);return{blob:f,contentType:h,fileName:e?l:n(l,h),resized:!0}}finally{d.close()}}}},44(e,t,s){const{ProjectTransferClient:r,CONTROL:i,CHUNK:n}=s(4394),o=s(1525),a=s(4849),{loadLocalGame:h,loadHomeGame:l}=s(7348),{GameView:c,FrameLoop:d,getClientInfo:u}=s(1768),p=s(4334),{squishMap:f,DEFAULT_VERSION:m}=s(9732),g=s(814),y=s(3598),{RtcHost:v,createRtcTransport:w,readInvitation:x}=s(4454),{createSaveStore:b}=s(7699),{CURSOR_OPCODE:E,decodeCursor:S}=s(5199);class k{constructor(e){this.containerId=e.containerId,this.wsUrl=e.wsUrl,this.workerUrl=e.workerUrl||null,this.transportFactory=e.transport||null,this.transport=null,this.onReady=e.onReady||(()=>{}),this.onClose=()=>{this._connectionFailed||this._setFrameStatus("Disconnected from the game.",{attention:!0}),e.onClose?.()},this.onError=t=>{this._connectionFailed=!0,this._setFrameStatus(t?.message||"Unable to connect to the game.",{attention:!0}),e.onError?.(t)},this.onAspectRatio=e.onAspectRatio||(()=>{}),this.onSharingStatus=e.onSharingStatus||(()=>{}),this._toolbarSharingLink=e=>this.getSharingLink(e),this.onSaveData=e.onSaveData||(()=>{}),this.onLocalPlayRedirect=e.onLocalPlayRedirect||null,this.spectating=e.spectating||!1,this.requestedGame=e.requestedGame||null,this.gamepadOptions=e.gamepad??{},this.saveStore=e.saveStore||b(),this.platform=e.platform,this._defaultShareOptions=e.share&&"object"==typeof e.share?e.share:null,this._playerProfile=s(4367).profile(window),this.playerName=void 0===e.playerName?this._playerProfile.get():this._playerProfile.set(e.playerName),this.showChrome=!1!==e.chrome,this.onSessionStatus=e.onSessionStatus||(()=>{}),this.localHome=e.localHome,this.ws=null,this.worker=null,this.view=null,this.playerId=null,this.aspectRatio=null,this.bezelInfo={x:0,y:0},this.squishVersion=null,this.unsquish=null,this.currentBuf=null,this._frameDirty=!1,this._loop=new d(()=>this._paintFrame()),this._resizeHandler=null,this._sessions=new o({remote:{start:()=>this._startRemote(),stop:()=>this._stopRemote()},loadLocal:e.loadLocalGame||l,mountLocal:t=>{if(this._shareOptions="function"==typeof e.share?e.share(t):e.share,!this.showChrome)return{containerId:this.containerId,dispose(){}};const s=a(this.containerId,t.name||t.gameKey,!1===e.localHome?null:"string"==typeof e.localHome?e.localHome:()=>this.exitLocalGame(),this._shareOptions?{getSharingLink:this._toolbarSharingLink,private:"public"!==this._shareOptions.visibility,onVisibility:this._shareOptions.room?e=>this._getRtcHost().setVisibility(e):null,onOpen:()=>this._localSession?.inputHandler?.detach(),onClose:()=>this._localSession?.inputHandler?.attach()}:null,{author:t.author,onExports:()=>this.viewExports(),onOpen:()=>this.setInputEnabled(!1),onClose:()=>this.setInputEnabled(!0)});return this._configureToolbar(s.toolbar),s},createLocal:t=>new g({...t,playerName:this.playerName,gamepad:this.gamepadOptions,platform:e.platform,saveStore:this.saveStore,onAspectRatio:this.onAspectRatio,onSaveData:this.onSaveData,onError:this.onError,onReady:e=>{const t=1===this._localSession?.maxPlayers;this._configureSharing(this._localChrome?.toolbar),this.onReady(e),this._shareOptions?.autoStart&&!t&&this._getRtcHost().share().catch(e=>this._localChrome?.setStatus?.(`Not available to join: ${e.message}. Use Invite to retry.`))}}),onError:this.onError})}start(){this._sessions.start()}stop(){this.disposeSharing(),this._shareDialog?.dispose(),this._shareDialog=null,this._switchingManual||(this._manualPairing?.dispose(),this._manualPairing=null),this._sessions.stop()}get _localSession(){return this._sessions.local}get _localChrome(){return this._sessions.chrome}_getRtcHost(){const e=this._localSession;if(!e)throw new Error("The game is still loading");return this._rtcHost&&this._rtcHost.session===e||(this._rtcHost=new v(e,{...this._shareOptions,onStatus:e=>{this._localChrome?.setStatus?.(e),this.onSessionStatus(e)}})),this._rtcHost}getNetworkStats(){return this._localSession&&this._rtcHost?.getStats()||this.transport?.getStats?.()||Promise.resolve(null)}requestGameCopy(){return this._requestFile()}listExports(){return this.spectating&&!this._localSession?Promise.reject(new Error("Join as a player to view exports")):this._requestFile({kind:"export-list"})}readExport(e){return this.spectating&&!this._localSession?Promise.reject(new Error("Join as a player to save exports")):this._requestFile({kind:"export",name:e})}async viewExports(){if(this._exportsOpen)return;this._exportsOpen=!0;const e=this._localSession?.inputHandler||this.inputHandler;e?.detach();try{this.platform?.viewExports?await this.platform.viewExports():(this._exportsViewer=s(97).createExportsViewer(window,{list:()=>this.listExports(),read:e=>this.readExport(e)}),await this._exportsViewer.result)}catch(e){this.onError(e)}finally{this._exportsViewer=null,this._exportsOpen=!1,e&&(e===this._localSession?.inputHandler||e===this.inputHandler&&this.rendering)&&e.attach()}}_requestFile(e){return this._projectTransfer||(this._projectTransfer=new r({importArchive:e=>k.PortableProject.importArchive(e),send:e=>{const t=this._localSession;if(t){if(!t.runtime||t.frozen||!t.players.some(e=>e.playerId===t.playerId&&e.dispatcher))throw new Error("The game is not ready. Try again once it has loaded.");const s=this._projectTransfer;queueMicrotask(()=>t.handleProjectMessage(t.playerId,e,e=>{queueMicrotask(()=>s.receive(e))}))}else this._send(JSON.stringify(e))}})),this._projectTransfer.request(e)}getShareLink(){if(this._localSession&&this._shareOptions)return this._getRtcHost().share();if(this.transport?.getShareLink)return this.transport.getShareLink();throw new Error("This session is not available to share")}getSharingLink(e){return this._localSession||this.view?(this._playerSharing||(this._playerSharing=p({...this._shareOptions,getInvitation:()=>this.getShareLink(),getProject:async()=>(await this.requestGameCopy()).project,onStatus:(e,t="copy")=>{this._playerToolbar()?.setSharingStatus?.(e,t),this.onSharingStatus(e,t)}})),this._playerSharing.getLink(e)):Promise.reject(new Error("The game is still loading. Try again once it is ready."))}disposeSharing(){this._playerSharing?.dispose(),this._playerSharing=null}_configureSharing(e){e&&(this._shareOptions||this.transport?.getShareLink?e.setSharing({multiplayer:1!==this._localSession?.maxPlayers,getLink:this._toolbarSharingLink}):e.setSharing?.(null))}setInputEnabled(e){const t=this._localSession?.inputHandler||this.inputHandler;e?(t?.attach(),t?.canvas.focus?.({preventScroll:!0})):t?.detach()}_playerToolbar(){return this._sessions?.chrome?.toolbar||this._remoteChrome?.toolbar||this.container?.closest?.(".hg-session-frame")?.querySelector?.(".hg-session-bar")?.homegamesToolbar}_setFrameStatus(e,t){this._playerToolbar()?.setStatus(e,t)}getPlayerName(){return this.playerName}setPlayerName(e){const t=this._playerProfile.set(e);return this.playerName=t,this._localSession?this._localSession.setPlayerName(this._localSession.playerId,t):this.spectating||this._send(JSON.stringify({type:"player-info",name:t})),this.platform?.setState?.({playerName:t}),t}showShare(){this._shareDialog||(this._shareDialog=s(172)({container:document.body,getLink:()=>this.getShareLink(),onOpen:()=>this.setInputEnabled(!1),onClose:()=>this.setInputEnabled(!0)})),this._shareDialog.show()}_configureToolbar(e){e&&(e.setPlayerName(this.playerName,e=>this.setPlayerName(e)),e.setAction("manual-connect",{label:"Manual connection",run:()=>{this._manualPairing||(this._manualPairing=k.createManualPairing({container:document.body,getSession:()=>this._localSession,onOpen:()=>this.setInputEnabled(!1),onClose:()=>this.setInputEnabled(!0),join:e=>{this._switchingManual=!0,this.stop(),this.transportFactory=e,this.start(),this._switchingManual=!1}})),this._manualPairing.show()}}))}get canvas(){return this.view?.canvas||null}get container(){return this.view?.container||null}get renderer(){return this.view?.renderer||null}get assetManager(){return this.view?.assetManager||null}get inputHandler(){return this.view?.inputHandler||null}get rendering(){return this._loop.running}_startRemote(){this._connectionFailed=!1,this._shareOptions=this._defaultShareOptions;let e=document.getElementById(this.containerId);if(!e)return void this.onError(new Error("Container element not found: #"+this.containerId));const t=e.closest(".hg-session-frame")?.querySelector(".hg-session-bar");this.showChrome&&t?this._removeExportsButton=a.addExportsButton(t,()=>this.viewExports()):this.showChrome&&(this._remoteChrome=a(this.containerId,"Homegames","string"==typeof this.localHome?this.localHome:null,null,{status:"Connected game",onExports:()=>this.viewExports(),onOpen:()=>this.setInputEnabled(!1),onClose:()=>this.setInputEnabled(!0)}),e=this._remoteChrome.gameArea),this.showChrome&&this._configureToolbar((t||this._remoteChrome?.bar)?.homegamesToolbar),this.view=new c({container:e,send:e=>this._send(e),gamepad:this.gamepadOptions,onAssetReady:()=>{this._frameDirty=!0,this.view?.refreshCursor()},onLayout:e=>{this.platform?.setState?.({aspectRatio:e}),this.onAspectRatio(e)},onResize:()=>{this._frameDirty=!0}}),this._resizeHandler=()=>{this._initCanvas(),this._sendClientInfo()},window.addEventListener("resize",this._resizeHandler);const s=this._mediaClient=new y({container:e,platform:this.platform,assets:this.assetManager,send:e=>this._send(JSON.stringify(e)),publish:(e,t)=>this.transport?.addMedia?.(e,t),unpublish:e=>this.transport?.removeMedia?.(e)});if(this.transportFactory){const e=this._transportGeneration=(this._transportGeneration||0)+1,t=()=>e===this._transportGeneration;this.transport=this.transportFactory({onOpen:()=>{t()&&this._send(JSON.stringify({type:"ready",playerName:this.playerName,media:1,recording:2,clientInfo:{clientInfo:u()}}))},onMessage:e=>{t()&&e instanceof ArrayBuffer&&this._handleBinaryMessage(new Uint8ClampedArray(e))},onMedia:e=>{t()&&s.receive(e)},onTrack:e=>{t()&&s.attach(e)},onError:e=>{t()&&this.onError(e)},onClose:()=>{t()&&(this._loop.stop(),this.view?.setCursor(null),this.inputHandler?.setPointerLockEnabled(!1),this.inputHandler?.detach(),this.renderer?.stopAllSounds(),s.destroy(),this.onClose())}})}else this.workerUrl?this._connectWorker():this._connectInline()}_stopRemote(){if(this._playerToolbar()?.setSharing?.(null),this.disposeSharing(),this._exportsViewer?.close(),this.platform?.closeExports?.(),this._removeExportsButton?.(),this._removeExportsButton=null,this._mediaClient?.destroy(),this._mediaClient=null,this._projectTransfer?.close(),this._projectTransfer=null,this._transportGeneration=(this._transportGeneration||0)+1,this.inputHandler?.setPointerLockEnabled(!1),this.transport?.close(),this.transport=null,this._loop.stop(),this.worker&&(this.worker.postMessage({type:"close"}),this.worker.terminate(),this.worker=null),this.ws){const e=this.ws;this.ws=null,e.onopen=e.onmessage=e.onclose=e.onerror=null,e.close()}this.view?.destroy(),this.view=null,this._remoteChrome?.dispose(),this._remoteChrome=null,this._resizeHandler&&(window.removeEventListener("resize",this._resizeHandler),this._resizeHandler=null)}_send(e){this.transport?this.transport.send(e):this.worker?this.worker.postMessage({type:"send",data:e}):this.ws&&this.ws.readyState===WebSocket.OPEN&&this.ws.send(e)}_sendClientInfo(){this._send(JSON.stringify({clientInfo:u()}))}_connectInline(){try{this.ws=new WebSocket(this.wsUrl),this.ws.binaryType="arraybuffer"}catch(e){return void this.onError(e)}const e=this.ws;this.ws.onopen=()=>{if(this.ws!==e)return;const t={type:"ready",playerName:this.playerName,spectating:this.spectating,clientInfo:{clientInfo:u()}};this.requestedGame&&(t.clientInfo.requestedGame=this.requestedGame),this.ws.send(JSON.stringify(t))},this.ws.onmessage=t=>{this.ws===e&&t.data instanceof ArrayBuffer&&this._handleBinaryMessage(new Uint8ClampedArray(t.data))},this.ws.onclose=()=>{this.ws===e&&(this._loop.stop(),this.view?.setCursor(null),this.inputHandler?.setPointerLockEnabled(!1),this.onClose())},this.ws.onerror=t=>{this.ws===e&&this.onError(t)}}_connectWorker(){try{this.worker=new Worker(this.workerUrl)}catch(e){return console.warn("Failed to create Web Worker, falling back to inline WebSocket:",e),void this._connectInline()}const e=this.worker;this.worker.onmessage=t=>{if(this.worker!==e)return;const s=t.data;s instanceof ArrayBuffer?this._handleBinaryMessage(new Uint8ClampedArray(s)):s&&"open"===s.type?this.worker.postMessage({type:"sendReady",playerName:this.playerName,id:this.playerId,spectating:this.spectating,clientInfo:{clientInfo:u()},requestedGame:this.requestedGame}):s&&"close"===s.type?(this._loop.stop(),this.view?.setCursor(null),this.inputHandler?.setPointerLockEnabled(!1),this.onClose()):s&&"error"===s.type&&this.onError(new Error(s.message))},this.worker.onerror=t=>{this.worker===e&&this.onError(t)},this.worker.postMessage({type:"connect",wsUrl:this.wsUrl})}_reconnect(e){this._playerToolbar()?.setSharing?.(null),this.disposeSharing(),this._connectionFailed=!1,this._exportsViewer?.close(),this.platform?.closeExports?.(),this._projectTransfer?.close(),this._projectTransfer=null,this.wsUrl=e,this._loop.stop(),this.currentBuf=null,this.view?.setCursor(null),this.inputHandler?.setPointerLockEnabled(!1),this.renderer&&(this.renderer.stopAllSounds(),this.renderer.thingIndices=[]),this.assetManager&&(this.assetManager.assets={},this.assetManager.imageCache={}),this.worker?this.worker.postMessage({type:"connect",wsUrl:e}):(this.ws&&(this.ws.onclose=null,this.ws.close()),this._connectInline())}_handleBinaryMessage(e){if(0!==e.length)switch(e[0]){case 16:try{this._mediaClient?.receive(JSON.parse((new TextDecoder).decode(e.subarray(1))))}catch(e){}break;case i:case n:this._projectTransfer?.receive(e);break;case 2:this._handleInit(e),this.transportFactory||this._send(JSON.stringify({type:"media",action:"hello",recording:2}));break;case 1:this.assetManager.storeAssets(e),this.view?.refreshCursor();break;case 3:this.currentBuf=e,this._frameDirty=!0,this._loop.start();break;case 5:this.spectating=!1,this._handlePortRedirect(e);break;case 6:this.spectating=!0,this._handlePortRedirect(e);break;case 9:this.aspectRatio={x:e[1],y:e[2]},this._initCanvas();break;case 10:this._handleSavePush(e);break;case 11:this._handleSaveRequest(e);break;case 12:this._handleLocalPlayRedirect(e);break;case E:try{this.view?.setCursor(S(e))}catch(e){}}}_handleLocalPlayRedirect(e){let t;try{t=JSON.parse((new TextDecoder).decode(e.slice(1)))}catch(e){return void console.error("Bad local play payload",e)}t&&(t.gameKey||t.invitation)&&(this.onLocalPlayRedirect?this.onLocalPlayRedirect(t):this.startLocalGame(t))}startLocalGame(e){return this._sessions.startLocal(e)}exitLocalGame(){this._sessions.start()}_saveKey(e){let t="";try{t=new URL(this.wsUrl).hostname}catch(e){}return t+":"+e}_decodeJsonPayload(e){try{const t=new Uint8Array(e.buffer,e.byteOffset+1,e.length-1),s="undefined"!=typeof TextDecoder?(new TextDecoder).decode(t):String.fromCharCode.apply(null,t);return JSON.parse(s)}catch(e){return null}}_handleSavePush(e){const t=this._decodeJsonPayload(e);if(t&&"string"==typeof t.gameKey){this.saveStore.putSave(this._saveKey(t.gameKey),t).catch(()=>{});try{this.onSaveData(t)}catch(e){console.error("[HomegamesClient] onSaveData callback threw:",e)}}}_handleSaveRequest(e){const t=this._decodeJsonPayload(e);if(!t||"string"!=typeof t.gameKey)return;const s=e=>{this._send(JSON.stringify({type:"saveData",gameKey:t.gameKey,save:e||null}))};this.saveStore.getSave(this._saveKey(t.gameKey)).then(s).catch(()=>s(null))}_handleInit(e){if(this.playerId=e[1],this.inputHandler?.setPointerLockEnabled(!1),e.length<=2)return;this.aspectRatio={x:e[2],y:e[3]},this.bezelInfo={x:e[4],y:e[5]};const t=e[6],s=String.fromCharCode.apply(null,e.slice(7,7+t));this.squishVersion=s;const r=f[s];if(!r)return this.stop(),void this.onError(new Error("Unsupported Squish runtime: squish-"+s));if(this.unsquish=r.unsquish,this.inputHandler){this.inputHandler.spectating=this.spectating,this.inputHandler.bezelInfo=this.bezelInfo,this.inputHandler.squishVersion=s;const r=e[7+t]||0;this.inputHandler.setPointerLockEnabled(!!(1&r))}this._initCanvas(),this._connectionFailed=!1,this._setFrameStatus("Connected game",{attention:!1}),this._configureSharing(this._playerToolbar()),this.onReady(this.playerId)}_handlePortRedirect(e){const t=String(e[1]),s=String(e[2]).length>1?String(e[2]):"0"+String(e[2]),r=Number(t+s),i=new URL(this.wsUrl);i.port=r,this._reconnect(i.toString())}_initCanvas(){this.aspectRatio&&this.container&&(this.view.resize(this.aspectRatio),this._frameDirty=!0)}_paintFrame(){this.rendering&&(this.inputHandler?.tick(),(this._frameDirty||this.renderer.needsRepaint())&&this.currentBuf&&this.currentBuf.length>1&&3===this.currentBuf[0]&&this.unsquish&&(this.renderer.renderFrame(this.currentBuf,this.unsquish),this._frameDirty=!1))}}const{packAssetBundle:_}=s(5305),{fitImageToSize:C}=s(9311),A=(e,t)=>{if(!e||"undefined"==typeof document)return;const s=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),r=document.createElement("a");r.href=URL.createObjectURL(s),r.download=t||(e.gameKey||"game")+"-save.json",document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(r.href),1e3)};k.LocalSession=g,k.loadLocalGame=h,k.packAssetBundle=_,k.fitImageToSize=C,k.downloadSave=A,k.createRtcTransport=w,k.readInvitation=x,k.RtcHost=v,k.createShareDialog=s(172),k.createPlayerSharing=p,k.GameCopies=s(2157),k.createSessionFrame=a,k.createPlayerToolbar=s(8106).createPlayerToolbar,k.householdRoom=s(9225),k.PortableProject=s(7237),k.ManualRtc=s(9742),k.createManualPairing=s(5880),e.exports&&(e.exports={default:k,HomegamesClient:k,LocalSession:g,loadLocalGame:h,packAssetBundle:_,fitImageToSize:C,downloadSave:A}),"undefined"!=typeof window&&(window.HomegamesClient=k,window.LocalSession=g)},7868(e,t,s){const r=s(5562),{fitImageToSize:i}=s(9311),{MAX_UPLOAD_BYTES:n}=s(3947),o=e=>{let t="";for(let s=0;s<e.length;s+=32768)t+=String.fromCharCode.apply(null,e.subarray(s,s+32768));return btoa(t)};e.exports=class{constructor(e,t,s,i,n={}){this.canvas=e,this.send=t,this.getThingIndices=s,this.assetManager=i,this.mouseDown=!1,this.mousePos=null,this._pressClickSent=!1,this._touchActive=!1,this._lastTouchTime=-1/0,this.squishVersion=null,this._lastClientPos=null,this.keysDown={},this._lastKeyRepeat={},this._keyRepeatIntervalMs=33,this.currentHover=null,this.clickStopper=null,this.spectating=!1,this.bezelInfo={x:0,y:0},this.clientWidth=0,this.clientHeight=0,this._boundHandlers={},this._attached=!1,this.gamepads=!1===n?null:new r(t,n),this._focused=!0,this.pointerLockEnabled=!1,this.pointerLockSuspended=!1,this._pointerLocked=!1,this._pointerLockPending=!1,this._pointerLockCancelled=!1,this._pointerLockOnRelease=!1,this._pointerDelta={dx:0,dy:0},this._lastPointerMove=0}setPointerLockEnabled(e){this.pointerLockEnabled=!0===e,this.pointerLockEnabled||this._releasePointerCapture()}setPointerLockSuspended(e){const t=!0===e;this.pointerLockSuspended!==t&&(this.pointerLockSuspended=t,t&&this._releasePointerCapture())}_canCapturePointer(){return this.pointerLockEnabled&&!this.pointerLockSuspended}attach(){if(this._attached)return;this._attached=!0,this._focused="function"!=typeof document.hasFocus||document.hasFocus();const e=this._boundHandlers;document.removeEventListener("pointerlockchange",e.pointerlockchange),document.removeEventListener("pointerlockerror",e.pointerlockerror),e.mousedown=e=>{if(this._isTouchMouseEvent(e))return;if(this._pointerLockOnRelease=!1,this._isControlEvent(e))return;clearTimeout(this.clickStopper),this.clickStopper=null,e.target===this.canvas&&this.assetManager.liveMedia?.hold("pointer"),this._touchActive=!1,this.mouseDown=!0,this._pressClickSent=!1,this.mousePos=this._hasPointerLock()?this._canvasCenter():[e.clientX,e.clientY],this._lastClientPos=this.mousePos.slice(),this._pressOrigin=this.mousePos.slice(),this.assetManager.unlockAudio();const t=this._canCapturePointer()&&!this.spectating&&e.target===this.canvas&&0===e.button&&!e.sourceCapabilities?.firesTouchEvents&&!this._hasPointerLock()&&!this._pointerLockPending&&"function"==typeof this.canvas.requestPointerLock;if(this._pointerLockOnRelease=t&&!this._focused,t&&this._focused){if(this._sendPendingClick(this._canClick(this.mousePos[0],this.mousePos[1])),!this._attached||!this._canCapturePointer()||!this._focused||this.spectating)return;this.clickStopper=setTimeout(()=>{this.clickStopper=null},30),this._requestPointerLock()}},e.mouseup=e=>{if(this._isTouchMouseEvent(e))return;this.assetManager.liveMedia?.release("pointer"),this.mousePos=this._hasPointerLock()?this._canvasCenter():[e.clientX,e.clientY],this._lastClientPos=this.mousePos.slice();const t=this.mousePos.slice();if(this._sendPendingClick(this._canClick(this.mousePos[0],this.mousePos[1])),!this._attached)return;this.mouseDown=!1,this._sendMouseUp(t[0],t[1]);const s=this._pointerLockOnRelease;this._pointerLockOnRelease=!1,!(s&&this._attached&&this._canCapturePointer()&&this._focused)||this.spectating||e.target!==this.canvas||0!==e.button||e.sourceCapabilities?.firesTouchEvents||this._hasPointerLock()||this._pointerLockPending||this._requestPointerLock()},e.mousemove=e=>{if(!this._isTouchMouseEvent(e)){if(this._hasPointerLock())return this.mouseDown&&0===e.buttons&&this._releasePointerPress(),void(Number.isFinite(e.movementX)&&Number.isFinite(e.movementY)&&(this._pointerDelta.dx=Math.max(-4096,Math.min(4096,this._pointerDelta.dx+e.movementX)),this._pointerDelta.dy=Math.max(-4096,Math.min(4096,this._pointerDelta.dy+e.movementY))));this.mouseDown&&0===e.buttons&&(this.assetManager.liveMedia?.release("pointer"),this.mouseDown=!1),this.mousePos=[e.clientX+window.scrollX,e.clientY+window.scrollY],this._lastClientPos=[e.clientX,e.clientY]}},e.touchstart=e=>{this._pointerLockOnRelease=!1,e.target===this.canvas?(e.preventDefault(),"function"==typeof this.canvas.focus&&(this.canvas.tabIndex<0&&(this.canvas.tabIndex=-1),this.canvas.focus({preventScroll:!0})),this._focused=!0,this._touchActive=!0,this._lastTouchTime=Date.now(),clearTimeout(this.clickStopper),this.clickStopper=null,this.assetManager.liveMedia?.hold("pointer"),this.mouseDown=!0,this._pressClickSent=!1,this.mousePos=[e.touches[0].clientX+window.scrollX,e.touches[0].clientY+window.scrollY],this._lastClientPos=[e.touches[0].clientX,e.touches[0].clientY],this._pressOrigin=this.mousePos.slice(),this.assetManager.unlockAudio()):this._touchActive=!1},e.touchmove=e=>{this._touchActive&&(e.preventDefault(),this._lastTouchTime=Date.now(),this.mouseDown=!0,this.mousePos=[e.touches[0].clientX+window.scrollX,e.touches[0].clientY+window.scrollY],this._lastClientPos=[e.touches[0].clientX,e.touches[0].clientY])},e.touchend=e=>{if(!this._touchActive)return;this.assetManager.liveMedia?.release("pointer"),this._lastTouchTime=Date.now(),!1!==e.cancelable&&e.preventDefault?.();const t=e.changedTouches&&e.changedTouches[0];if(t){const e=this._canClick(t.clientX+window.scrollX,t.clientY+window.scrollY);"file"===e.action?this._promptFileUpload(e.nodeId):(this.mousePos=[t.clientX,t.clientY],this._sendPendingClick(e)),this.mouseDown=!1,this._sendMouseUp(t.clientX,t.clientY)}this.mouseDown=!1,this._touchActive=!1},e.touchcancel=()=>{this._touchActive&&(this._lastTouchTime=Date.now(),this.assetManager.liveMedia?.release("pointer"),this.mouseDown&&this._lastClientPos&&this._sendMouseUp(this._lastClientPos[0],this._lastClientPos[1],!0),this.mouseDown=!1,this._touchActive=!1)},e.keydown=e=>{this._isControlEvent(e)||("Escape"===e.key&&(this._hasPointerLock()||this._pointerLockPending||this._pointerLockOnRelease)?this._releasePointerCapture():(" "===e.key&&this.assetManager.liveMedia?.hold("space"),this.assetManager.unlockAudio(),this._keyMatters(e)&&!this.keysDown.Meta&&(e.preventDefault(),this._keyUpTimers&&this._keyUpTimers[e.key]&&(clearTimeout(this._keyUpTimers[e.key]),delete this._keyUpTimers[e.key]),this.keysDown[e.key]||(this.send(JSON.stringify({type:"keydown",key:e.key})),this._lastKeyRepeat[e.key]=Date.now()),this.keysDown[e.key]=!0)))},e.keyup=e=>{" "===e.key&&this.assetManager.liveMedia?.release("space"),this._isControlEvent(e)?this.keysDown[e.key]&&(clearTimeout(this._keyUpTimers?.[e.key]),this._keyUpTimers&&delete this._keyUpTimers[e.key],delete this.keysDown[e.key],delete this._lastKeyRepeat[e.key],this.send(JSON.stringify({type:"keyup",key:e.key}))):this._keyMatters(e)&&(e.preventDefault(),this._keyUpTimers||(this._keyUpTimers={}),this._keyUpTimers[e.key]&&clearTimeout(this._keyUpTimers[e.key]),this._keyUpTimers[e.key]=setTimeout(()=>{this.keysDown[e.key]=!1,delete this._keyUpTimers[e.key],this.send(JSON.stringify({type:"keyup",key:e.key}))},50))},e.blur=()=>{this._focused=!1,this._releasePointerCapture()},e.focus=()=>{this._focused=!0},e.visibilitychange=()=>{document.hidden&&this._releasePointerCapture()},e.pointerlockchange=()=>{const e=this._pointerLocked;this._pointerLocked=this._hasPointerLock(),this._pointerLockPending=!1,this._clearPointerDelta(),!this._pointerLocked||this._attached&&this._canCapturePointer()&&!this._pointerLockCancelled&&!this.spectating&&this._focused?e&&!this._pointerLocked&&this._releasePointerCapture():this._releasePointerCapture(),this._removeDetachedPointerLockListeners()},e.pointerlockerror=()=>{this._pointerLockPending=!1,this._removeDetachedPointerLockListeners()},window.addEventListener("mousedown",e.mousedown),window.addEventListener("mouseup",e.mouseup),window.addEventListener("mousemove",e.mousemove),window.addEventListener("blur",e.blur),window.addEventListener("focus",e.focus),document.addEventListener("visibilitychange",e.visibilitychange),document.addEventListener("pointerlockchange",e.pointerlockchange),document.addEventListener("pointerlockerror",e.pointerlockerror),window.addEventListener("touchstart",e.touchstart,{passive:!1}),this.canvas.addEventListener("touchmove",e.touchmove,{passive:!1}),window.addEventListener("touchend",e.touchend,{passive:!1}),window.addEventListener("touchcancel",e.touchcancel),document.addEventListener("keydown",e.keydown),document.addEventListener("keyup",e.keyup)}detach(){if(this._textDialog?.close(),this._textDialog?.remove(),this._textDialog=null,!this._attached)return;this.assetManager.liveMedia?.release(),this._attached=!1,this._releasePointerCapture();const e=this._boundHandlers;window.removeEventListener("mousedown",e.mousedown),window.removeEventListener("mouseup",e.mouseup),window.removeEventListener("mousemove",e.mousemove),window.removeEventListener("blur",e.blur),window.removeEventListener("focus",e.focus),document.removeEventListener("visibilitychange",e.visibilitychange),this._removeDetachedPointerLockListeners(),window.removeEventListener("touchstart",e.touchstart),this.canvas.removeEventListener("touchmove",e.touchmove),window.removeEventListener("touchend",e.touchend),window.removeEventListener("touchcancel",e.touchcancel),document.removeEventListener("keydown",e.keydown),document.removeEventListener("keyup",e.keyup)}tick(){if(!this._attached)return;const e=Date.now();Object.keys(this.keysDown).filter(e=>this.keysDown[e]).forEach(t=>{e-(this._lastKeyRepeat[t]||0)>=this._keyRepeatIntervalMs&&(this.send(JSON.stringify({type:"keydown",key:t})),this._lastKeyRepeat[t]=e)}),!this._focused||document.hidden||this.spectating?this.gamepads?.release():this.gamepads?.tick();const t=1e3/60;if(this._canCapturePointer()&&this._hasPointerLock()&&this._focused&&!document.hidden&&!this.spectating&&e-this._lastPointerMove>=t-1&&(this._pointerDelta.dx||this._pointerDelta.dy)&&(this.send(JSON.stringify({type:"pointermove",data:{...this._pointerDelta}})),this._pointerDelta.dx=this._pointerDelta.dy=0,this._lastPointerMove=this._lastPointerMove&&e-this._lastPointerMove<2*t?this._lastPointerMove+t:e),!this.mousePos)return;const s=this._canClick(this.mousePos[0],this.mousePos[1]);this.mouseDown&&!this.clickStopper&&(this._pressClickSent?this._hasPointerLock()||(this._usesSingleClickContract()?this._sendMouseMove(this.mousePos[0],this.mousePos[1]):this._handleClick(s,!1)):this._sendPendingClick(s),this.clickStopper=setTimeout(()=>{this.clickStopper=null},30)),s.isClickable||s.action||s.isHoverable?this.currentHover&&Number(s.nodeId)===Number(this.currentHover)||(this.currentHover&&this._offHover(this.currentHover),this.currentHover=s.nodeId,this._onHover(s.nodeId)):this.currentHover&&(this._offHover(this.currentHover),this.currentHover=null),this.mousePos=null}_hasPointerLock(){return document.pointerLockElement===this.canvas}_canvasCenter(){const e=this.canvas.getBoundingClientRect();return[e.left+e.width/2,e.top+e.height/2]}_requestPointerLock(){if(this._canCapturePointer()){this._pointerLockCancelled=!1,this._pointerLockPending=!0;try{const e=this.canvas.requestPointerLock();e?.then&&e.then(()=>{this._boundHandlers.pointerlockchange()},()=>{this._boundHandlers.pointerlockerror()})}catch(e){this._boundHandlers.pointerlockerror()}}}_clearPointerDelta(){this._pointerDelta.dx=this._pointerDelta.dy=0,this._lastPointerMove=0}_releasePointerPress(){this._pointerLockOnRelease=!1,this.assetManager.liveMedia?.release("pointer"),this.mouseDown&&this._lastClientPos&&this._sendMouseUp(...this._lastClientPos,!0),this.mouseDown=!1,this._touchActive=!1,this._pressClickSent=!1,this.mousePos=null,this._lastClientPos=null,clearTimeout(this.clickStopper),this.clickStopper=null}_releasePointerCapture(){this._pointerLockCancelled=!0,this.assetManager.liveMedia?.release(),this.gamepads?.release(),this._releaseKeys(),this._releasePointerPress(),this._clearPointerDelta(),this._hasPointerLock()&&document.exitPointerLock?.()}_removeDetachedPointerLockListeners(){this._attached||this._pointerLockPending||(document.removeEventListener("pointerlockchange",this._boundHandlers.pointerlockchange),document.removeEventListener("pointerlockerror",this._boundHandlers.pointerlockerror))}_releaseKeys(){for(const e of Object.values(this._keyUpTimers||{}))clearTimeout(e);this._keyUpTimers={};for(const e of Object.keys(this.keysDown))this.keysDown[e]&&this.send(JSON.stringify({type:"keyup",key:e}));this.keysDown={},this._lastKeyRepeat={}}_isControlEvent(e){return!!e.target?.closest?.('button, a, input, select, textarea, [contenteditable="true"]')}_isTouchMouseEvent(e){const t=e.sourceCapabilities?.firesTouchEvents;return!0===t||!1!==t&&e.target===this.canvas&&(this._touchActive||Date.now()-this._lastTouchTime<800)}_keyMatters(e){return 1===e.key.length&&e.key>=" "&&e.key<="z"||e.keyCode>=36&&e.keyCode<=40||"Meta"===e.key||"Backspace"===e.key||"Enter"===e.key||"Escape"===e.key||"Shift"===e.key}_sendMouseUp(e,t,s=!1){const r=this.canvas.getBoundingClientRect(),i=(e-r.left)/r.width*100,n=(t-r.top)/r.height*100,o=Math.min(99.99,Math.max(0,i)),a=Math.min(99.99,Math.max(0,n)),h=this._pressOrigin;!s&&h&&this._pressClickSent&&!this._hasPointerLock()&&(Math.abs(e-h[0])>.5||Math.abs(t-h[1])>.5)&&this._sendMouseMove(e,t),this._pressOrigin=null,this.send(JSON.stringify({type:"mouseup",data:{x:o,y:a,...s?{cancelled:!0}:{}}}))}_usesSingleClickContract(){const e=this.squishVersion;return!(!e||!/^[1-9]\d{2}$/.test(e))&&Number(e)>=144}_sendMouseMove(e,t){const s=this.canvas.getBoundingClientRect(),r=(e-s.left)/s.width*100,i=(t-s.top)/s.height*100,n=Math.min(99.99,Math.max(0,r)),o=Math.min(99.99,Math.max(0,i));this.send(JSON.stringify({type:"mousemove",data:{x:n,y:o}}))}_onHover(e){this.send(JSON.stringify({type:"onhover",nodeId:e}))}_offHover(e){this.send(JSON.stringify({type:"offhover",nodeId:e}))}_sendPendingClick(e){if(!this.mouseDown||this._pressClickSent||this.spectating||!this._focused)return;this._pressClickSent=!0;const t=this.mousePos;this._pressOrigin&&(this.mousePos=this._pressOrigin.slice(),e=this._canClick(this.mousePos[0],this.mousePos[1])),this._handleClick(e,!0),this._attached&&(this.mousePos=t)}_promptTextInput(e){if(this._textDialog)return;const t=document.createElement("dialog"),s=document.createElement("div"),r=document.createElement("label"),i=document.createElement("input"),n=document.createElement("button"),o=document.createElement("button");t.setAttribute("aria-label","Input text"),t.style.cssText="max-width:90vw;padding:24px;border-radius:12px;background:#101820;color:white;font:16px system-ui",r.textContent="Input text",i.type="text",i.maxLength=4096,i.style.cssText="display:block;width:min(300px,65vw);padding:10px;margin:12px 0;font:inherit",r.append(i),n.textContent="Done",n.type="button",o.textContent="Cancel",o.type="button";for(const e of[n,o])e.style.cssText="padding:8px 16px;margin-right:8px;font:inherit";const a=()=>{t.close(),t.remove(),this._textDialog=null};n.onclick=t=>{t.preventDefault();const s=i.value;a(),this.send(JSON.stringify({type:"input",input:s,nodeId:e}))},i.onkeydown=e=>{"Enter"===e.key&&n.onclick(e)},o.onclick=a,t.oncancel=e=>{e.preventDefault(),a()},s.append(r,n,o),t.append(s),document.body.append(t),this._textDialog=t,t.showModal(),i.focus()}_handleClick(e,t){if(this.mousePos)if(e.action)"text"===e.action?(this.mouseDown=!1,this._promptTextInput(e.nodeId)):"file"===e.action&&(this.mouseDown=!1,this._touchActive||this._promptFileUpload(e.nodeId));else{const e=this.mousePos[0],s=this.mousePos[1],r=this.canvas.getBoundingClientRect(),i=(e-r.left)/r.width*100,n=(s-r.top)/r.height*100;if(i>=0&&i<=100&&n>=0&&n<=100){const e={x:i,y:n};t&&(e.press=!0),this.send(JSON.stringify({type:"click",data:e}))}}}_promptFileUpload(e){const t=document.createElement("input");t.type="file",t.accept="image/*,audio/*,video/*,application/json,.json",t.style.display="none",document.body.appendChild(t);const s=()=>{t.parentNode&&t.parentNode.removeChild(t)};t.onchange=async()=>{const r=t.files&&t.files[0];if(s(),!r)return;let a={blob:r,contentType:r.type||null,fileName:r.name||null};if(r.size>n)try{a=await i(r,n)}catch(e){const t=(r.size/1048576).toFixed(1);return void alert(`That file is ${t}MB — uploads are limited to ${n/1048576}MB, and it couldn't be resized automatically.`)}const h=new FileReader;h.onerror=()=>{alert("Could not read that file. Please try a different one.")},h.onload=()=>{this.send(JSON.stringify({type:"input",fileEncoding:"base64",contentType:a.contentType,fileName:a.fileName,input:o(new Uint8Array(h.result)),nodeId:e}))},h.readAsArrayBuffer(a.blob)},t.addEventListener("cancel",s),t.click()}_translateX(e,t=this.canvas.getBoundingClientRect()){return e*t.width/100+t.left}_translateY(e,t=this.canvas.getBoundingClientRect()){return e*t.height/100+t.top}_canClick(e,t){let s=!1,r=!1,i=null,n=null;const o=this.canvas.getBoundingClientRect();if(e<o.left||e>o.right||t<o.top||t>o.bottom)return{isClickable:s,isHoverable:r,action:i,nodeId:n};const a=this.getThingIndices();for(let h=a.length-1;h>=0;h--){const l=a[h];if(!l)continue;let c=l[3];if(!c||!c.length)continue;if(!c[0].length){const e=new Array(c.length/2);for(let t=0;t<c.length;t+=2)e[t/2]=[c[t],c[t+1]];c=e}let d=!1,u=this._translateX(c[0][0],o),p=u,f=this._translateY(c[0][1],o),m=f;for(let e=1;e<c.length;e++){const t=this._translateX(c[e][0],o),s=this._translateY(c[e][1],o);t<u&&(u=t),t>p&&(p=t),s<f&&(f=s),s>m&&(m=s)}if(!(e<u||e>p||t<f||t>m)){let s=0,r=c.length-1;for(;s<c.length;r=s++){const i=this._translateY(c[s][1],o),n=this._translateY(c[r][1],o),a=this._translateX(c[s][0],o),h=this._translateX(c[r][0],o);i>t!=n>t&&e<(h-a)*(t-i)/(n-i)+a&&(d=!d)}}if(d){s=l[0],i=l[1],n=l[2],r=!!l[4];break}}return{isClickable:s,isHoverable:r,action:i,nodeId:n}}}},7538(e,t,s){const r=s(5766);e.exports=class{constructor(e,t){this.playerId=Number(t),this.dispatcher=new r(e),this.gameInput=this.dispatcher.gameInput}handleMessage(e){let t;try{t=JSON.parse(e)}catch(e){return}this.handleInput(t)}handleInput(e){this.dispatcher.handleInput(this.playerId,e)}checkActivePresses(){this.dispatcher.checkActivePresses(this.playerId)}release(){this.gameInput.removePlayer(this.playerId),this.dispatcher.endPress(this.playerId,null)}}},4849(e,t,s){const r=s(7875),{createPlayerToolbar:i}=s(8106),n=(e,t,n,o=null,a={})=>{const h=document.getElementById(e);if(!h)throw new Error("Container element not found: #"+e);h.innerHTML="";const l=r(),c=document.createElement("div");c.className="hg-session-frame";const d=i(window,{title:t,author:a.author,home:n,status:a.status||"Playing locally",onOpen:a.onOpen||o?.onOpen,onClose:a.onClose||o?.onClose});d.bar.classList.add("hg-session-bar"),a.onExports&&d.setAction("exports",{label:"View exports",run:a.onExports});const u=document.createElement("div");let p;if(u.className="hg-session-game",u.id=`${e}-hg-local-area`,c.append(d.bar,u),h.append(c),u.homegamesToolbar=d,d.setGameArea(u,c),o&&(o.getSharingLink||(p=s(4334)({...o,getInvitation:o.getLink,onStatus:(e,t)=>d.setSharingStatus(e,t)})),d.setSharing({multiplayer:!1!==o.multiplayer,copy:!(!o.getSharingLink&&!o.getProject),getLink:o.getSharingLink||(e=>p.getLink(e)),dispose:p?()=>p.dispose():void 0}),o.onVisibility)){let e=o.private;const t=()=>d.setAction("privacy",{label:e?"Make session public":"Make session private",run:async()=>{await o.onVisibility(e?"public":"private"),e=!e,t()}});t()}let f=!1;return{bar:d.bar,toolbar:d,gameArea:u,containerId:u.id,setStatus:(e,t)=>d.setStatus(e,t),dispose(){f||(f=!0,p?.dispose(),d.dispose(),c.remove(),l())}}};n.addExportsButton=(e,t)=>{const s=e.homegamesToolbar;return s?.setAction("exports",{label:"View exports",run:t}),()=>s?.setAction("exports",null)},e.exports=n},7348(e){const t=async({manifestUrl:e,gameKey:t,versionId:s,baseUrl:r}={},{signal:i}={})=>{const n=await fetch(e,{signal:i});if(!n.ok)throw new Error("Manifest fetch failed: "+n.status);const o=await n.json();if(!o.localPlayable)throw new Error(o.reason||"This game cannot run locally");let a=null;if(o.assetCount>0){const t=new URL(e,r||window.location.href),s=await fetch(new URL(o.assetBundleUrl,t).href,{signal:i});if(!s.ok)throw new Error("Asset bundle fetch failed: "+s.status);a=new Uint8ClampedArray(await s.arrayBuffer())}return{name:o.name,author:o.author||o.createdBy,multiplayer:!0===o.multiplayer,files:o.files,entryPoint:o.entryPoint,assetBundle:a,gameKey:t||o.gameKey||o.gameId,versionId:s||o.versionId||o.commitSha}};e.exports={loadLocalGame:t,loadHomeGame:({gameKey:e,versionId:s=null},r)=>{const i=s?`?versionId=${encodeURIComponent(s)}`:"";return t({gameKey:e,versionId:s,manifestUrl:`/games/${encodeURIComponent(e)}/local-manifest${i}`},r)}}},9503(e,t,s){const{createSessionRuntime:r}=s(9956);e.exports=(e,t,s={})=>r(e,t,{...s,loadAssets:!1})},814(e,t,s){const{ProjectTransferHost:r}=s(4394),i=s(9503),{playerFrame:n}=s(9956),{packAssetBundle:o}=s(5305),{splitAssetBundle:a}=s(3735),{createFileUploadHandler:h}=s(3947),{normalizeCursor:l,encodeCursor:c}=s(5199),d=s(6620),u=s(3598),{GameView:p,FrameLoop:f,getClientInfo:m}=s(1768),{squishMap:g,DEFAULT_VERSION:y}=s(9732),v=s(7538),{loadGameClass:w}=s(9630),{createSaveStore:x,createDebouncedWriter:b,serializeSaveData:E,isCompatibleSave:S,DEFAULT_VERSION_ID:k}=s(7699),{generateName:_,initialName:C,normalizeName:A}=s(4367);e.exports=class{constructor(e){this.gamepadOptions=e.gamepad??{},this.platform=e.platform,this.packageRevision=e.packageRevision,this.containerId=e.containerId,this.gameClass=e.gameClass||null,this.files=e.files||null,this.entryPoint=e.entryPoint||"index.js",this.playerId=e.playerId||1,this.playerName=C(e.playerName),this.assetBundle=e.assetBundle||null,this.assetPackets=this.assetBundle?a(this.assetBundle):[],this.onReady=e.onReady||(()=>{}),this.onError=e.onError||(()=>{}),this.onAspectRatio=e.onAspectRatio||(()=>{}),this.gameKey=e.gameKey||null,this.versionId=e.versionId||k,this.onSaveData=e.onSaveData||null,this.saveStore=e.saveStore||x(),this.game=null,this.runtime=null,this.players=[],this.dynamicAssets=new Map,this.onStop=null,this.unsquish=null,this.aspectRatio=null,this.pointerLockEnabled=!1,this.frozen=!1,this._loop=new f(()=>this._paintFrame()),this._resizeHandler=null,this._inspector=null,this._onInput=null,this._inspectBuf=null,this._highlight=null,this._pick=null}get _primary(){return this.players[0]}get extraPlayers(){return this.players.slice(1)}get view(){return this._primary?.view||null}get container(){return this.view?.container||null}get canvas(){return this.view?.canvas||null}get renderer(){return this.view?.renderer||null}get assetManager(){return this.view?.assetManager||null}get inputHandler(){return this.game&&this.view?.inputHandler||null}get dispatcher(){return this._primary?.dispatcher||null}get currentBuf(){return this._primary?.currentBuf||null}get squisher(){return this.runtime?.squisher||null}get rendering(){return this._loop.running}start(){this.stop();const e=document.getElementById(this.containerId);if(!e)return void this.onError(new Error("Container element not found: #"+this.containerId));if(e.innerHTML="",!this.gameClass&&this.files)try{this.gameClass=w({files:this.files,entryPoint:this.entryPoint})}catch(e){return this.stop(),void this.onError(e)}if(!this.gameClass)return this.stop(),void this.onError(new Error("LocalSession needs either gameClass or files"));let t;try{t=s(2439).runtimeMetadata(this.gameClass)}catch(e){return this.stop(),void this.onError(e)}this.maxPlayers=t.maxPlayers,this.pointerLockEnabled=!0===t.pointerLock;const r=t.squishVersion||y;let i=g[r];if(!i)return void this.onError(new Error("Unsupported Squish runtime: squish-"+r));this.unsquish=i.unsquish,this.squishVersion=r,this.aspectRatio=t.aspectRatio||{x:16,y:9};const n=this.gameKey||this.gameClass.name||"local-game",o="local:"+n,a=Array.isArray(t.saveCompatibility)?t.saveCompatibility:[],h=this._bootGeneration;this.exportStorage=this.platform?.getExports?this.platform:s(739).createExportStorage(window,{installationId:n,gameId:n,packageRevision:this.packageRevision}),this.saveStore.getSave(o).catch(e=>{if(this.saveStore.strict)throw e;return null}).then(async t=>{if(h!==this._bootGeneration)return;const r=t&&S(t,this.versionId,a)?t.data:void 0,l=e=>this.saveStore.putSave(o,e).then(()=>{if(this.onSaveData)try{this.onSaveData(e)}catch(e){}}),c=this.saveStore.eager?l:b({intervalMs:1e3,write:l}),d=await this.exportStorage.getExports().catch(e=>(this.exportStorageError=e,{}));h===this._bootGeneration&&(this.userExportsStore=s(2947).openGameExports(this.gameClass,{saved:d,persist:(e,t)=>this.exportStorageError?Promise.reject(this.exportStorageError):this.exportStorage.putExport(e,t)}),this._boot({container:e,squishModule:i,saveGame:e=>{let t;try{t=JSON.parse(E(e))}catch(e){return Promise.reject(e)}return c({gameKey:n,versionId:this.versionId,savedAt:Date.now(),data:t})},saveData:r}))}).catch(e=>{h===this._bootGeneration&&this.onError(e)})}_boot({container:e,squishModule:t,saveGame:s,saveData:n}){const o=this._bootGeneration;this.media=new d;const a=h({Asset:t.Asset,registerAsset:(e,t)=>this._addLocalAsset(e,t),isPlayerActive:e=>!!this.game&&!this.frozen&&this.players.some(t=>t.playerId===e)});try{this.game=new this.gameClass({createExport:this.userExportsStore.createExport,userExports:this.userExportsStore.userExports,media:this.media,addAsset:(e,t)=>this._addLocalAsset(e,t),handleFileUpload:a,setCursor:(e,t)=>o===this._bootGeneration&&this.setCursor(e,t),saveGame:s,saveData:n}),this.runtime=i(t,this.game,{userExportsStore:this.userExportsStore}),this.projectTransfers=new r({exportProject:e=>this.exportProject(e),listExports:()=>this.runtime.listExports(),readExport:(e,t)=>this.runtime.readExport(t)});for(const[e,t]of Object.entries(this.game.getAssets?.()||{}))this._addLocalAsset(e,t)}catch(e){return this.stop(),void this.onError(e)}const l=this.runtime;this.squisher.addListener(()=>{this.runtime===l&&(this.players.forEach(e=>e.dispatcher?.checkActivePresses()),this._captureFrame())}),this._joinPlayer(e,this.playerId,this.playerName,this.gamepadOptions),this.assetBundle&&this.assetManager.storeAssets(this.assetBundle);for(const e of this.dynamicAssets.values())this.assetManager.storeRawAsset(e.key,e.type,e.data);this._resizeHandler=()=>this._initCanvas(),window.addEventListener("resize",this._resizeHandler),this._captureFrame(),this._loop.start(),this.onReady(this.playerId)}enableInspector(e,t){this._inspector=e,this._onInput=t||null,this._emitSnapshot()}disableInspector(){this._inspector=null,this._onInput=null,this.disablePick(),this.setHighlight(null),this.resumeLive()}showFrame(e){this.renderer&&this.unsquish&&e&&(this._inspectBuf=e,this._updateInputAttachment(),this._paintInspectedFrame())}resumeLive(){this._inspectBuf=null,this._updateInputAttachment(),this._primary&&(this._primary.frameDirty=!0)}enablePick({onMove:e,onPick:t}={}){if(!this.canvas)return;this.disablePick();const s=e=>{const t=this.canvas.getBoundingClientRect();return[(e.clientX-t.left)/t.width*100,(e.clientY-t.top)/t.height*100]};this._pick={move:t=>{e&&e(...s(t))},click:e=>{const[r,i]=s(e);this.disablePick(),t&&t(r,i)},leave:()=>{e&&e(null,null)}},this.canvas.addEventListener("mousemove",this._pick.move),this.canvas.addEventListener("click",this._pick.click),this.canvas.addEventListener("mouseleave",this._pick.leave),this.view.setCursorOverride("crosshair"),this._updateInputAttachment()}disablePick(){this._pick&&this.canvas?(this.canvas.removeEventListener("mousemove",this._pick.move),this.canvas.removeEventListener("click",this._pick.click),this.canvas.removeEventListener("mouseleave",this._pick.leave),this.view.setCursorOverride(null),this._pick=null,this._updateInputAttachment()):this._pick=null}_updateInputAttachment(){this.inputHandler&&(this._inspectBuf||this._pick?this.inputHandler.detach():this.inputHandler.attach())}_noteInput(e){if(this._onInput)try{const t=JSON.parse(e);if(!t||"string"!=typeof t.type)return;if("mousemove"===t.type||"onhover"===t.type||"offhover"===t.type)return;const s={time:performance.now(),type:t.type};"string"==typeof t.key&&(s.key=t.key),this._onInput(s)}catch(e){}}setHighlight(e){this._highlight=e&&e.length?e:null,this._inspectBuf?this._paintInspectedFrame():this._primary&&(this._primary.frameDirty=!0)}_paintInspectedFrame(){this._inspectBuf&&this.renderer&&(this.renderer.renderFrame(this._inspectBuf,this.unsquish,{muteAudio:!0,freezeMedia:!0}),this._drawHighlight())}_drawHighlight(){if(!this._highlight||!this.canvas)return;const e=this.canvas.getContext("2d"),{width:t,height:s}=this.canvas;e.save(),e.beginPath(),e.moveTo(this._highlight[0][0]*t/100,this._highlight[0][1]*s/100);for(let r=1;r<this._highlight.length;r++)e.lineTo(this._highlight[r][0]*t/100,this._highlight[r][1]*s/100);e.closePath(),e.shadowColor="rgba(148, 210, 229, 0.9)",e.shadowBlur=Math.max(12,.012*t),e.strokeStyle="rgba(148, 210, 229, 0.95)",e.lineWidth=Math.max(2,.003*t),e.stroke(),e.stroke(),e.restore()}_emitSnapshot(){if(!this._inspector||!this.currentBuf)return;let e=null;try{e=(this.game.getLayers()||[]).map(e=>this._serializeNode(e.root))}catch(e){}try{this._inspector({time:performance.now(),buf:this.currentBuf,tree:e})}catch(e){console.error("[LocalSession] inspector callback threw:",e)}}addPlayer(e,{gamepadIndex:t}={}){if(!this.game||!this.squisher)return null;const s=document.getElementById(e);if(!s)return console.error("[LocalSession] addPlayer: container not found: #"+e),null;const r=Math.max(...this.players.map(e=>e.playerId))+1,i=this.inputHandler?.gamepads;i&&null===i.index&&i.setIndex(0);const n=new Set(this.players.map(e=>e.view?.inputHandler.gamepads?.index));if(void 0===t)for(t=0;n.has(t);)t++;return this._joinPlayer(s,r,_(),!1!==this.gamepadOptions&&{...this.gamepadOptions,index:t}),this._captureFrame(),r}_joinPlayer(e,t,s,r){const i=new v(this.game,t),n=new p({container:e,assetManager:this.assetManager,gamepad:r,send:e=>{t===this.playerId&&this._noteInput(e),i.handleMessage(e)},onAssetReady:()=>this._invalidateFrames(),onLayout:e=>{t===this.playerId&&(this.platform?.setState?.({aspectRatio:e}),this.onAspectRatio(e))},onResize:()=>{this._invalidateFrames(),this._inspectBuf&&this._paintInspectedFrame()}});if(this.players.push({playerId:t,info:{name:s},settings:{SOUND:!0},view:n,dispatcher:i,cursor:null,currentBuf:null,frameDirty:!0}),t===this.playerId){const s=new u({container:e,platform:this.platform,assets:n.assetManager,send:e=>this.media.handle(t,e),publish:(e,s)=>this.media.attach(t,s)});this.media.join(t,{audioRecording:!0,send:e=>s.receive(e),addMedia:(e,t)=>s.attach(t),removeMedia:e=>s.remove(e)})}n.inputHandler.squishVersion=this.squishVersion,n.inputHandler.setPointerLockEnabled(this.pointerLockEnabled),n.resize(this.aspectRatio);try{this.game.handleNewPlayer?.({playerId:t,settings:{SOUND:!0},info:{name:s},clientInfo:m(),requestedGame:null})}catch(e){console.error("[LocalSession] game.handleNewPlayer threw:",e)}}_leavePlayer(e){this.projectTransfers?.leave(e.playerId),this.media?.leave(e.playerId);const t=e.dispatcher;if(t){if(e.dispatcher=null,e.view?.setCursor(null),e.cursor)try{e.send?.(c(null))}catch(e){}delete e.cursor,e.view?.inputHandler.setPointerLockEnabled(!1),e.view?.inputHandler.detach(),t.release();try{this.game?.handlePlayerDisconnect?.(e.playerId)}catch(e){}e.view?.renderer.stopAllSounds()}}removePlayer(e){const t=this.players.findIndex(t=>t.playerId===e);if(t<=0)return;const[s]=this.players.splice(t,1);this._leavePlayer(s),s.view?.destroy(),s.close?.()}addRemotePlayer({send:e,close:t,clientInfo:s={},playerName:r}){if(!this.game||this.frozen)throw new Error("The host game has ended");if(this.players.length>=this.maxPlayers)throw new Error("This game is full");let i=1;for(;this.players.some(e=>e.playerId===i);)i++;const n=Array.from(this.squishVersion,e=>e.charCodeAt(0));e(Uint8Array.from([2,i,this.aspectRatio.x,this.aspectRatio.y,0,0,n.length,...n,this.pointerLockEnabled?1:0]));for(const t of this.assetPackets)e(t);for(const t of this.dynamicAssets.values())e(o([t]));const a=new v(this.game,i),h={playerId:i,info:{name:C(r)},settings:{SOUND:!0},dispatcher:a,send:e,close:t,view:null,cursor:null,currentBuf:null,frameDirty:!0};this.players.push(h);try{this.game.handleNewPlayer?.({playerId:i,settings:{SOUND:!0},info:{...h.info},clientInfo:s,requestedGame:null}),this._captureFrame()}catch(e){throw this.removePlayer(i),e}return{playerId:i,handleMessage:t=>{if(!h.dispatcher)return;let s;try{s=JSON.parse(t)}catch(e){return}if("player-info"===s?.type)try{this.setPlayerName(i,s.name)}catch(e){}else"project-transfer"===s?.type?this.handleProjectMessage(i,s,e):h.dispatcher.handleInput(s)},leave:()=>this.removePlayer(i)}}setPlayerName(e,t){const s=A(t);e===this.playerId&&(this.playerName=s);const r=this.players.find(t=>t.playerId===e&&t.dispatcher);if(!r||!this.game||this.frozen)return!1;if(r.info.name===s)return s;r.info={...r.info,name:s};try{this.game.handlePlayerUpdate?.(e,{info:{...r.info},settings:{...r.settings}})}catch(e){console.error("[LocalSession] game.handlePlayerUpdate threw:",e)}return this._captureFrame(),s}exportProject(e){return this.runtime&&!this.frozen&&this.players.some(t=>t.playerId===Number(e)&&t.dispatcher)?this.runtime.exportProject(Number(e)):Promise.reject(new Error("Join the game before requesting a copy"))}handleProjectMessage(e,t,s){this.players.some(t=>t.playerId===Number(e)&&t.dispatcher)&&this.projectTransfers?.handle(Number(e),t,s)}setCursor(e,t){if(!this.game||!this.runtime||this.frozen)return!1;const s=this.players.find(t=>t.playerId===Number(e)&&t.dispatcher);if(!s)return!1;const r=l(t);return s.cursor=r,s.view?s.view.setCursor(r):s.send(c(r)),!0}_serializeNode(e){const t=e.node,s={id:t.id};if(t.subType&&(s.subType=t.subType),t.coordinates2d&&t.coordinates2d.length&&(s.coordinates2d=Array.from(t.coordinates2d,e=>[e[0],e[1]])),t.fill&&(s.fill=Array.from(t.fill)),t.color&&(s.color=Array.from(t.color)),null!==t.border&&void 0!==t.border&&(s.border=t.border),t.text&&(s.text={text:t.text.text,x:t.text.x,y:t.text.y,size:t.text.size,align:t.text.align}),t.asset){const e=Object.keys(t.asset)[0],r=t.asset[e]||{};s.asset={key:e},r.pos&&(s.asset.pos={x:r.pos.x,y:r.pos.y}),r.size&&(s.asset.size={x:r.size.x,y:r.size.y})}return t.playerIds&&t.playerIds.length&&(s.playerIds=t.playerIds.slice()),t.handleClick&&(s.clickable=!0),t.input&&t.input.type&&(s.input=t.input.type),s.children=t.children.map(e=>this._serializeNode(e)),s}freeze(){this.frozen||(this.frozen=!0,this._endGame())}_endGame(){this._bootGeneration=(this._bootGeneration||0)+1;const e=this.onStop;this.onStop=null,e?.(),this.media?.destroy(),this.projectTransfers?.close(),this.runtime?.stop(),this.runtime=null,this.players.forEach(e=>this._leavePlayer(e)),this.pointerLockEnabled=!1;try{this.game?.close?.()}catch(e){}try{this.game?.destroy?.()}catch(e){}this.game=null}stop(){this._endGame(),this._loop.stop(),this.disablePick(),this._inspector=null,this._onInput=null,this._inspectBuf=null,this._highlight=null,this.frozen=!1,[...this.players].reverse().forEach(e=>{e.view?.destroy(),e.close?.()}),this.players=[],this.dynamicAssets.clear(),this._resizeHandler&&(window.removeEventListener("resize",this._resizeHandler),this._resizeHandler=null)}_addLocalAsset(e,t){try{const s=t&&t.info&&t.info.type||"image",r=t&&t.data;if(r){this.dynamicAssets.set(e,{key:e,type:s,data:r}),this.assetManager?.storeRawAsset(e,s,r);const t=o([{key:e,type:s,data:r}]);this.players.forEach(e=>e.send?.(t)),this._invalidateFrames()}}catch(e){console.error("[LocalSession] addAsset failed:",e)}return Promise.resolve()}_captureFrame(){const e=this.squisher;if(e&&(e.flush?.(),this.squisher===e)){for(const t of this.players){const s=n(e,t.playerId);s?.length&&(t.view&&(t.currentBuf=s,t.frameDirty=!0),t.send?.(s,{transfer:!0}))}this._emitSnapshot()}}_invalidateFrames(){this.players.forEach(e=>{e.frameDirty=!0,e.view?.refreshCursor()})}_initCanvas(){this.players.forEach(e=>e.view?.resize(this.aspectRatio)),this._invalidateFrames(),this._inspectBuf&&this._paintInspectedFrame()}_paintFrame(){for(const e of this.players){const{view:t}=e;if(!t)continue;if(e.dispatcher&&t.inputHandler.tick(),t.destroyed)continue;const{currentBuf:s}=e;if(!e.frameDirty&&!t.renderer.needsRepaint()||!s||s.length<=1||3!==s[0])continue;const r=e===this._primary;r&&this._inspectBuf||(t.renderer.renderFrame(s,this.unsquish,{muteAudio:!r||this.frozen,freezeMedia:this.frozen}),r&&this._drawHighlight()),e.frameDirty=!1}}}},5880(e,t,s){const{ManualHost:r,createManualGuest:i,DEFAULT_ICE:n}=s(9742);e.exports=function({container:e,getSession:t,join:s,onOpen:o=()=>{},onClose:a=()=>{}}){const h=document.createElement("dialog");h.setAttribute("aria-label","Manual connection"),h.style.cssText="background:#172735;color:#f1f8fc;border:1px solid #547286;border-radius:8px;box-sizing:border-box;width:min(620px,calc(100vw - 24px));max-height:85vh;overflow:auto;padding:20px;font:14px/1.5 system-ui";const l=document.createElement("h2");l.textContent="Manual connection";const c=document.createElement("p");c.textContent="No Homegames service needed. Both players need a downloaded game HTML or an already-open player. Send the offer privately; your friend sends an answer back. Keep both tabs open.";const d=document.createElement("p");d.textContent="Direct connections can still be blocked by a network or firewall. This mode shares game scenes, assets and input; live camera/microphone streams are not supported.";const u=document.createElement("p");u.setAttribute("role","status");const p=document.createElement("label"),f=document.createElement("input");f.type="checkbox",f.checked=!0,p.append(f," Use public STUN for internet connections (Google). Turn off for LAN-only pairing.");const m=document.createElement("section"),g=document.createElement("section"),y=document.createElement("h3");y.textContent="Host a player",m.append(y);const v=document.createElement("h3");v.textContent="Join a host",g.append(v);let w=null,x=null,b=!1,E=!1;const S=[],k=e=>{b||(u.textContent=e)},_=(e,t,s)=>{const r=document.createElement("button");return r.textContent=t,r.style.cssText="padding:7px 10px;margin:4px;cursor:pointer",r.onclick=async()=>{if(!E){E=!0,S.forEach(e=>e.disabled=!0);try{await s()}catch(e){k(e.message)}finally{E=!1,S.forEach(e=>e.disabled=!1)}}},S.push(r),e.append(r),r},C=(e,t,s=!1)=>{const r=document.createElement("label");r.textContent=t;const i=document.createElement("textarea");return i.setAttribute("aria-label",t),i.readOnly=s,i.maxLength=131072,i.style.cssText="display:block;box-sizing:border-box;width:100%;height:90px;margin:5px 0 12px;background:#101820;color:#eef;border:1px solid #547286;padding:8px;font:11px monospace",r.append(i),e.append(r),i},A=C(m,"Offer to send",!0),I=C(m,"Answer from friend");_(m,"Create offer",async()=>{const e=t();if(!e?.game)throw new Error("Start a local game to host a player");w||(w=new r(e,{onStatus:k})),w.iceServers=f.checked?n:[],A.value="",I.value="",k("Collecting network addresses…"),A.value=await w.createOffer(),k("Send the entire offer to your friend. It expires in 10 minutes.")});const T=async e=>{if(!e.value)throw new Error("Create the handshake first");try{await navigator.clipboard.writeText(e.value),k("Handshake copied")}catch(t){e.focus(),e.select(),k("Copy the selected handshake text")}};_(m,"Copy offer",()=>T(A)),_(m,"Connect with answer",async()=>{if(!w)throw new Error("Create an offer first");await w.acceptAnswer(I.value),k("Connecting directly…")}),_(m,"Cancel offer",()=>{w?.cancelOffer(),A.value="",I.value="",k("Pending offer cancelled")});const P=C(g,"Offer from host"),L=C(g,"Answer to send",!0);_(g,"Create answer",async()=>{const e=i(P.value,{iceServers:f.checked?n:[],onStatus:k});w?.stop(),w=null,x?.close(),x=e,L.value="",k("Collecting network addresses…");try{s(e.transport),L.value=await e.answer(),k("Send the entire answer back to the host, then choose Done.")}catch(t){throw e.close(),t}}),_(g,"Copy answer",()=>T(L));const M=document.createElement("button");return M.textContent="Done",M.style.cssText="padding:8px 18px;margin-top:16px",M.onclick=()=>h.close(),h.append(l,c,p,m,g,d,u,M),e.append(h),h.onclose=a,{show(){b||h.open||(h.showModal(),o())},dispose(){b||(b=!0,w?.stop(),x?.close(),h.remove())}}}},3598(e,t,s){const r=s(7511);e.exports=class{constructor({container:e,assets:t,send:s,platform:i,publish:n=()=>{},unpublish:o=()=>{}}){Object.assign(this,{container:e,assets:t,send:s,publish:n,unpublish:o}),this.streams=new Map,this.received=new Map,this.pending=new Map,this.held=new Set,this.recorder=new r({container:e,send:s,platform:i,busy:()=>this.pending.size||[...this.streams.values()].some(e=>e.local)}),t.liveMedia=this,this.releaseAll=()=>this.release(),this.visibility=()=>{document.hidden&&this.release()},window.addEventListener("blur",this.releaseAll),document.addEventListener("visibilitychange",this.visibility)}hold(e){this.held.add(e)}release(e){if(e?this.held.delete(e):this.held.clear(),!this.held.size){for(const e of this.streams.values())e.local&&e.pushToTalk&&(e.transmitting=!1,e.data.getTracks().forEach(e=>{e.enabled=!1}),this.send({type:"media",action:"released",id:e.id}));this.assets._notifyReady()}}receive(e){if(!this.closed){if("record"===e.action)return this.recorder.request(e.recording);if("record-cancel"===e.action)return this.recorder.cancel(e.id);if("request"===e.action)return this.request(e.stream);if("ended"===e.action)return this.remove(e.id);if(["available","state"].includes(e.action)){const t=e.stream;if(!t||"string"!=typeof t.id)return;const s=this.streams.get(t.id);s?(Object.assign(s,t),s.local&&(t.pushToTalk&&!this.held.size&&t.transmitting&&(s.transmitting=!1,this.send({type:"media",action:"released",id:t.id})),s.data.getTracks().forEach(e=>{e.enabled=s.transmitting}))):this.streams.set(t.id,{...t,type:"stream",data:this.received.get(t.sourceId),local:!1}),this.assets._notifyReady()}}}attach(e){this.received.set(e.id,e);for(const t of this.streams.values())t.local||t.sourceId!==e.id||(t.data=e);this.assets._notifyReady()}request(e){if(!e||this.pending.has(e.id))return;if(this.recorder.active||this.pending.size||[...this.streams.values()].some(e=>e.local))return void this.send({type:"media",action:"result",id:e.id,error:"A microphone/camera is already active or awaiting permission"});const t=document.createElement("dialog");t.setAttribute("aria-label","Enable live media"),t.style.cssText="margin:auto;padding:24px;max-width:360px;border:1px solid #666;border-radius:16px;background:#202321;color:white;font:16px system-ui";const s=document.createElement("p");s.textContent=e.video?`Share your camera${e.audio?" and microphone":""} with this session?`:"Enable your microphone for this session?";const r=document.createElement("button");r.textContent=e.video?"Enable camera":"Enable microphone";const i=document.createElement("button");i.textContent="Cancel";for(const e of[r,i])e.style.cssText="padding:12px;margin:16px 8px 0 0;font:inherit";t.append(s,r,i),this.container.appendChild(t),this.pending.set(e.id,t);const n=t=>{this.remove(e.id),this.send({type:"media",action:"result",id:e.id,error:t})};t.oncancel=e=>{e.preventDefault(),n("Microphone/camera permission cancelled")},i.onclick=()=>n("Microphone/camera permission cancelled"),r.onclick=async()=>{r.disabled=!0;try{if(this.assets.unlockAudio?.(),!navigator.mediaDevices?.getUserMedia)throw new Error("Microphone/camera requires HTTPS or localhost");const s=await navigator.mediaDevices.getUserMedia({audio:!!e.audio&&{echoCancellation:!0,noiseSuppression:!0},video:!!e.video&&{width:{ideal:640},height:{ideal:360},frameRate:{ideal:20,max:30}}});if(this.closed||!this.pending.has(e.id))return void s.getTracks().forEach(e=>e.stop());this.pending.delete(e.id),t.close(),t.remove();const r={...e,sourceId:s.id,type:"stream",data:s,local:!0,transmitting:e.transmitting&&(!e.pushToTalk||this.held.size>0)};this.streams.set(e.id,r),s.getTracks().forEach(t=>{t.enabled=!!r.transmitting,t.onended=()=>this.stopLocal(e.id)}),this.send({type:"media",action:"result",id:e.id,sourceId:s.id}),this.publish(e.id,s),this.showStop(),this.assets._notifyReady(),r.pushToTalk&&!r.transmitting&&this.send({type:"media",action:"released",id:e.id})}catch(t){this.pending.has(e.id)&&n(t.message||"Unable to access microphone/camera")}},t.showModal(),r.focus()}showStop(){if(this.stopButton)return;const e=this.stopButton=document.createElement("button");e.textContent="Disconnect microphone / camera",e.style.cssText="position:absolute;right:12px;bottom:12px;padding:10px;border:1px solid #fff;border-radius:8px;background:#8b2525;color:white;z-index:10;font:13px system-ui",e.onclick=()=>{for(const e of[...this.streams.values()])e.local&&this.stopLocal(e.id)},this.container.appendChild(e)}stopLocal(e){this.remove(e),this.send({type:"media",action:"stopped",id:e})}remove(e){const t=this.pending.get(e);t&&(this.pending.delete(e),t.close(),t.remove());const s=this.streams.get(e);this.streams.delete(e),s?.local&&(this.unpublish(e),s.data.getTracks().forEach(e=>{e.onended=null,e.stop()}),this.stopButton?.remove(),this.stopButton=null),s&&this.received.delete(s.sourceId),this.assets._notifyReady()}destroy(){if(!this.closed){this.closed=!0,this.recorder.destroy();for(const e of[...this.pending.keys(),...this.streams.keys()])this.remove(e);this.received.clear(),this.held.clear(),window.removeEventListener("blur",this.releaseAll),document.removeEventListener("visibilitychange",this.visibility),this.assets.liveMedia===this&&(this.assets.liveMedia=null)}}}},4334(e,t,s){"use strict";const r=s(3008);e.exports=function({getInvitation:e,getProject:t,onStatus:i=()=>{},...n}){let o,a,h=!1,l=0;const c=new Set,d=()=>new Error("Sharing has stopped. Reopen the game to share it."),u=()=>{l++,o?.close(),o=null,a=null};return{getLink:p=>h?Promise.reject(d()):["session","copy"].includes(p)?new Promise((f,m)=>{const g={reject:m,timer:null};c.add(g);const y=(e,t)=>{c.delete(g)&&(clearTimeout(g.timer),e?m(e):f(t))};g.timer=setTimeout(()=>{"copy"===p&&u(),y(new Error("Creating an invitation timed out. Check your connection and try again."))},3e4),Promise.resolve().then(()=>{if("copy"===p)return function(){if(o?.closed&&u(),a)return a;const e=l,r=Promise.resolve().then(async()=>{if("function"!=typeof t)throw new Error("Sharing a copy is not available in this player.");const r=await t();if(h||l!==e)throw d();const{CopyHost:a}=s(2157),c=new a(r,{...n,onStatus:t=>{if(!h&&l===e)try{i(t,"copy")}catch(e){}}});o=c;const u=await c.share();if(h||l!==e)throw c.close(),d();return u});return a=r.catch(t=>{throw l===e&&u(),t}),a}();if("function"!=typeof e)throw new Error("This session is not available to join.");return e()}).then(e=>{if(h)throw d();if("string"!=typeof e||e.length>4096||!/^https?:\/\//.test(e))throw new Error("Invalid invitation link");const t=r(0,"M");t.addData(e),t.make();const s=t.getModuleCount(),i=Array.from({length:s},(e,r)=>Array.from({length:s},(e,s)=>t.isDark(r,s)?"1":"0").join(""));y(null,{url:e,qr:i})}).catch(e=>y(e))}):Promise.reject(new Error("Unknown sharing option")),dispose(){if(!h){h=!0,u();for(const e of c)clearTimeout(e.timer),e.reject(d());c.clear()}}}}},7237(e,t,s){const r=s(5110),{prepareTrustedLocalGame:i}=s(7435),{squishMap:n}=s(9732),o={supportedRuntimes:Object.keys(n)},a=s(5758),h=s(5061),l=s(5564);e.exports={...s(2409),...s(32),create:e=>r.createProject(e,o),importArchive:e=>r.importArchive(e,o),exportArchive:r.exportArchive,withGameId:r.withGameId,normalizePath:r.normalizePath,limits:r.LIMITS,buildIsolatedHtml:a.buildIsolatedHtml,runtimeDocument:a.runtimeDocument,createFrame:a.createFrame,attachArchiveHost:a.attachArchiveHost,attachSaveHost:h.attachSaveHost,attachPlayerHost:(e,t,r)=>{const i=h.attachSaveHost(e,t,r),n=s(739).createExportStorage(e,r),o=l.attachClientHost(e,t,l.recordAudio,n,s(97).createExportsViewer,s(5900).recordVideo,s(8106).createPlayerToolbar,{...r,profile:s(4367).profile(e)});return{...i,get stopped(){return i.stopped},command:o.command,downloadGame:o.download,close:async()=>{o.close(),await i.close()}}},connectClientSource:l.connectClientSource,connectSaveStore:h.connectSaveStore,filename:a.filename,readHtmlArchive:a.readHtmlArchive,htmlBytesLimit:a.htmlBytesLimit,checkSyntax:r.checkSyntax,thumbnailPath:r.thumbnailPath,prepareTrustedLocalGame:(e,t)=>i(e,n,t)}},7511(e,t,s){const{recordAudio:r}=s(5564),{recordVideo:i}=s(5900);e.exports=class{constructor({send:e,busy:t,platform:s}){Object.assign(this,{send:e,busy:t,platform:s})}request(e){if(!e||"string"!=typeof e.id||this.closed)return;if(this.active||this.busy())return void this.send({type:"media",action:"record-result",id:e.id,error:"A microphone/camera is already active"});const t="audio"===e.kind?"recordAudio":"recordVideo",s=this.active=this.platform?.[t]?{result:this.platform[t](e),close:()=>this.platform.cancelRecording?.(e.id)}:("audio"===e.kind?r:i)(window,e);s.id=e.id,s.result.then(e=>{this.active===s&&(this.active=null,this.closed||this.send(e))},t=>{this.active===s&&(this.active=null,this.closed||this.send({type:"media",action:"record-result",id:e.id,error:t.message}))})}cancel(e){if(this.active&&this.active.id===e){const e=this.active;this.active=null,e.close()}}destroy(){this.closed=!0,this.cancel(this.active?.id)}}},549(e,t,s){const r=s(5537);e.exports=class{constructor(e,t){this.canvas=e,this.ctx=e.getContext("2d",{alpha:!1}),this.assetManager=t,this.playingSounds={},this.videos=new Map,this.mediaDirty=!1,this.thingIndices=[]}renderFrame(e,t,s={}){const{canvas:i,ctx:n,assetManager:o}=this,a=new Set(Object.keys(this.playingSounds)),h=new Set,l=new Set;this.mediaDirty=!1,n.clearRect(0,0,i.width,i.height),this.thingIndices=[];let c=0,d=!1,u=!1;for(;e&&c<e.length;){e[c];const p=e[c+1]+e[c+2]+e[c+3];let f;try{f=t("function"==typeof e.subarray?e.subarray(c,c+p):e.slice(c,c+p)).node}catch(e){c+=p;continue}if(!f.coordinates2d&&f.input&&f.text){const e=Math.floor(i.width),t=f.text.size/100*e;n.font=t+"px sans-serif";const s=n.measureText(f.text.text);let r=f.text.x*i.width/100;f.text.align&&"center"===f.text.align&&(r-=s.width/2),r=r/i.width*100;const o=s.actualBoundingBoxDescent-s.actualBoundingBoxAscent,a=s.width/i.width*100,h=o/i.height*100;this.thingIndices.push([!!f.handleClick,f.input&&f.input.type,f.id,[r,f.text.y,r+a,f.text.y,r+a,f.text.y+h,r,f.text.y+h,r,f.text.y],!!f.onHover])}else if(null!==f.coordinates2d&&void 0!==f.coordinates2d){if(this.thingIndices.push([!!f.handleClick,f.input&&f.input.type,f.id,f.coordinates2d,!!f.onHover]),f.effects&&f.effects.shadow){const e=f.effects.shadow.color;n.shadowColor="rgba("+e[0]+","+e[1]+","+e[2]+","+e[3]+")",f.effects.shadow.blur&&(n.shadowBlur=f.effects.shadow.blur,d=!1)}f.color&&(n.globalAlpha=f.color[3]/255,u=!1),null!==f.fill&&void 0!==f.fill&&(n.fillStyle="rgba("+f.fill[0]+","+f.fill[1]+","+f.fill[2]+","+f.fill[3]+")"),void 0!==f.border&&null!==f.border&&(n.lineWidth=f.border/255*.1*i.width,n.strokeStyle="rgba("+f.color[0]+","+f.color[1]+","+f.color[2]+","+f.color[3]+")"),n.beginPath();const e=f.coordinates2d[0];n.moveTo(e[0]*i.width/100,e[1]*i.height/100);for(let e=1;e<f.coordinates2d.length;e++){const t=f.coordinates2d[e];n.lineTo(t[0]*i.width/100,t[1]*i.height/100)}void 0!==f.fill&&null!==f.fill&&n.fill(),void 0!==f.border&&null!==f.border&&n.stroke(),d||(n.shadowBlur=0,d=!0)}if(f.text){n.globalAlpha=f.text.color[3]/255,u=!1,n.fillStyle="rgba("+f.text.color[0]+","+f.text.color[1]+","+f.text.color[2]+","+f.text.color[3]+")";const e=Math.floor(i.width),t=f.text.size/100*e,s=f.text.font&&"default"!==f.text.font?f.text.font:"sans-serif";n.font=t+"px "+s,f.text.align&&(n.textAlign=f.text.align),n.textBaseline="top",n.fillText(f.text.text,f.text.x*i.width/100,f.text.y*i.height/100)}if(f.asset||f.stream){const e=f.stream,t=e?e.id:Object.keys(f.asset)[0],c=e?o.liveMedia?.streams.get(e.id):o.assets[t];if(c&&"audio"===c.type){const e=`${f.id}:${t}`;if(!s.muteAudio)if(h.add(e),!this.playingSounds[e]&&o.audioCtx&&c.decoded){const s=o.audioCtx.createBufferSource();s.connect(o.audioCtx.destination),s.buffer=c.data,s.start(0,f.asset[t].startTime||0),this.playingSounds[e]=s}else this.playingSounds[e]&&a.delete(e)}else if(c&&("image"===c.type||"video"===c.type||e&&c.data)){const a=e||f.asset[t];let h;if("video"===c.type||e){const d=`${f.id}:${t}`;l.add(d);let u=this.videos.get(d);u&&u.asset!==c&&(u.destroy(),u=null);const p={...s,muteAudio:!!s.muteAudio||!(!e||e.audio&&!c.local&&c.transmitting)};if(u||(u=new r(o,c,a.startTime||0,()=>{this.mediaDirty=!0},p),this.videos.set(d,u)),u.update(p.muteAudio,!!s.freezeMedia),h=(!e||c.video)&&!u.error&&u.element.readyState>=2?u.element:null,!h&&(!e||c.video)){const e=a.pos.x/100*i.width,t=a.pos.y/100*i.height;n.fillStyle="#202226",n.fillRect(e,t,a.size.x/100*i.width,a.size.y/100*i.height),n.fillStyle="#fff",n.font=`${Math.max(12,.015*i.width)}px sans-serif`,n.textAlign="center",n.textBaseline="middle",n.fillText(u.error?"Video format not supported":"Loading video…",e+a.size.x/200*i.width,t+a.size.y/200*i.height)}}else h=o.getImage(t);if(h){if(h.width=a.size.x/100*i.width,h.height=a.size.y/100*i.height,f.effects&&f.effects.shadow){const e=f.effects.shadow.color;n.shadowColor="rgba("+e[0]+","+e[1]+","+e[2]+","+e[3]+")",f.effects.shadow.blur&&(n.shadowBlur=f.effects.shadow.blur,d=!1)}const e=a.pos.x/100*i.width,t=a.pos.y/100*i.height;let s=a.cropLeft||0,r=a.cropTop||0,o=a.cropRight||0,l=a.cropBottom||0;if(s+o>=100&&(s=0,o=0),r+l>=100&&(r=0,l=0),s||r||o||l){let i=s/100*(h.videoWidth||h.naturalWidth),a=r/100*(h.videoHeight||h.naturalHeight),c=(1-(s+o)/100)*(h.videoWidth||h.naturalWidth),d=(1-(r+l)/100)*(h.videoHeight||h.naturalHeight);i=Math.max(0,Math.min(i,(h.videoWidth||h.naturalWidth)-1)),a=Math.max(0,Math.min(a,(h.videoHeight||h.naturalHeight)-1)),c=Math.min(c,(h.videoWidth||h.naturalWidth)-i),d=Math.min(d,(h.videoHeight||h.naturalHeight)-a),c>=1&&d>=1&&n.drawImage(h,i,a,c,d,e,t,h.width,h.height)}else n.drawImage(h,e,t,h.width,h.height)}}}c+=p,d||(n.shadowBlur=0,d=!0),u||(n.globalAlpha=1,u=!0)}for(const[e,t]of this.videos)l.has(e)||(t.destroy(),this.videos.delete(e));for(const e in this.playingSounds)if(!h.has(e)){try{this.playingSounds[e].stop()}catch(e){}delete this.playingSounds[e]}}needsRepaint(){return this.mediaDirty||[...this.videos.values()].some(e=>e.needsRepaint())}stopAllSounds(){for(const e of this.videos.values())e.destroy();this.videos.clear(),this.mediaDirty=!1;for(const e in this.playingSounds)try{this.playingSounds[e].stop()}catch(e){}this.playingSounds={}}}},8221(e){function t(){const e=16384,t=10485760,s=20971520;class r{constructor(e,{onMessage:t,onClose:s=()=>{},onError:r=()=>{}}){Object.assign(this,{channel:e,onMessage:t,onClose:s,onError:r}),this.queue=[],this.queuedBytes=0,this.pending=null,this.closed=!1,this.stats={sentPackets:0,receivedPackets:0,wireMessages:0,wireBytes:0,duplicateFrames:0,replacedFrames:0,maxBufferedBytes:0},this.lastFrame=null,e.binaryType="arraybuffer",e.bufferedAmountLowThreshold=16384,e.onbufferedamountlow=()=>this.flush(),e.onmessage=e=>{try{this.receive(e.data)}catch(e){this.fail(e)}},e.onclose=()=>this.close(),e.onerror=()=>this.fail(new Error("Game connection failed"))}send(e){if(this.closed)return;const r="string"==typeof e,i=r?(new TextEncoder).encode(e):e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength);if(!i.length||i.length>t)return this.fail(new Error("Game packet is too large"));const n=!r&&3===i[0];if(n){if(this.lastFrame&&i.length===this.lastFrame.length&&i.every((e,t)=>e===this.lastFrame[t]))return void this.stats.duplicateFrames++;this.lastFrame=i,this.queue=this.queue.filter(e=>!e.frame||null!==e.offset||(this.queuedBytes-=e.bytes.length,this.stats.replacedFrames++,!1))}if(this.queuedBytes+i.length>s)return this.fail(new Error("Guest connection is too slow"));this.queue.push({bytes:i,text:r,frame:n,offset:null}),this.queuedBytes+=i.length,this.flush()}flush(){try{for(;!this.closed&&"open"===this.channel.readyState&&this.queue.length&&this.channel.bufferedAmount<65536;){const t=this.queue[0];null===t.offset&&(this.write(JSON.stringify({bytes:t.bytes.length,text:t.text})),t.offset=0),this.write(t.bytes.subarray(t.offset,t.offset+e)),t.offset+=e,t.offset>=t.bytes.length&&(this.queue.shift(),this.queuedBytes-=t.bytes.length,this.stats.sentPackets++)}}catch(e){this.fail(e)}}write(e){this.channel.send(e),this.stats.wireMessages++,this.stats.wireBytes+="string"==typeof e?e.length:e.byteLength,this.stats.maxBufferedBytes=Math.max(this.stats.maxBufferedBytes,this.channel.bufferedAmount)}receive(s){if(this.closed)return;if("string"==typeof s){const e=JSON.parse(s);if(this.pending||!Number.isInteger(e.bytes)||e.bytes<1||e.bytes>t||"boolean"!=typeof e.text)throw new Error("Invalid game packet");return this.pending={bytes:new Uint8Array(e.bytes),text:e.text,offset:0},void(this.receiveTimer=setTimeout(()=>this.fail(new Error("Game packet timed out")),3e4))}const r=this.pending;if(!(s instanceof ArrayBuffer)||!r||!s.byteLength||s.byteLength>e||r.offset+s.byteLength>r.bytes.length)throw new Error("Invalid game packet");r.bytes.set(new Uint8Array(s),r.offset),r.offset+=s.byteLength,r.offset===r.bytes.length&&(clearTimeout(this.receiveTimer),this.pending=null,this.stats.receivedPackets++,this.onMessage(r.text?(new TextDecoder).decode(r.bytes):r.bytes.buffer))}fail(e){this.closed||(this.onError(e),this.close())}close(){this.closed||(this.closed=!0,clearTimeout(this.receiveTimer),this.queue=[],this.pending=null,this.queuedBytes=0,this.lastFrame=null,this.channel.onmessage=this.channel.onclose=this.channel.onerror=this.channel.onbufferedamountlow=null,this.channel.close(),this.onClose())}}return r.Mailbox=class{constructor(e,t){Object.assign(this,{deliver:e,fail:t}),this.queue=[],this.bytes=0,this.waiting=!1,this.closed=!1,this.replacedFrames=0}send(e,t=!1){if(this.closed)return;const r="string"==typeof e,i=r?null:e instanceof ArrayBuffer?new Uint8Array(e):e,n=3===i?.[0];n&&(this.queue=this.queue.filter(e=>!e.frame||(this.bytes-=e.size,this.replacedFrames++,!1)));const o=r?2*e.length:i.byteLength;this.bytes+o>s?this.fail(new Error("Game message queue is full")):(this.queue.push({data:e,transfer:t,frame:n,size:o}),this.bytes+=o,this.pump())}pump(){if(this.closed||this.waiting||!this.queue.length)return;const e=this.queue.shift();this.bytes-=e.size,this.waiting=!0;try{this.deliver(e.data,e.transfer)}catch(e){this.fail(e)}}ack(){this.waiting=!1,this.pump()}close(){this.closed=!0,this.queue=[],this.bytes=0}},r}const s=t();s.workerSource=()=>`(${t.toString()})()`,e.exports=s},8334(e,t,s){"use strict";const{LIMITS:r}=s(5110),i=async e=>Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",e)),e=>e.toString(16).padStart(2,"0")).join(""),n=e=>{if("string"!=typeof e||e.length>4096)throw new Error("Invalid game-copy message");const t=JSON.parse(e);if(!t||"object"!=typeof t||Array.isArray(t))throw new Error("Invalid game-copy message");return t};function o(e){if("copy-offer"!==e.type||1!==e.protocol||"string"!=typeof e.name||!e.name.length||e.name.length>200||!/^[a-f0-9]{64}$/.test(e.revision)||!/^[a-f0-9]{64}$/.test(e.sha256)||!/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i.test(e.gameId)||!Number.isSafeInteger(e.bytes)||e.bytes<1||e.bytes>r.archiveBytes)throw new Error("Invalid or oversized game copy");return{type:"copy-offer",protocol:1,name:e.name,revision:e.revision,sha256:e.sha256,gameId:e.gameId,bytes:e.bytes}}e.exports={Sender:class{constructor(e,t,s,r=()=>{}){if(this.bytes=e,this.send=s,this.progress=r,this.metadata=o(t),this.offset=0,this.accepted=!1,this.done=!1,e.length!==t.bytes)throw new Error("Game-copy size changed")}open(){this.send(JSON.stringify(this.metadata))}receive(e){const t=n(e);if("copy-accept"===t.type&&!this.accepted)return this.accepted=!0,void this.next();if("copy-ack"===t.type&&this.accepted&&!this.done&&t.offset===this.offset)return this.progress(this.offset,this.bytes.length),void(this.offset===this.bytes.length?(this.done=!0,this.send(JSON.stringify({type:"copy-complete"}))):this.next());if("copy-saved"!==t.type||!this.done)throw new Error("Unexpected game-copy acknowledgement")}next(){const e=Math.min(this.offset+65536,this.bytes.length),t=new Uint8Array(5+e-this.offset);t[0]=80,new DataView(t.buffer).setUint32(1,this.offset),t.set(this.bytes.subarray(this.offset,e),5),this.offset=e,this.send(t)}},Receiver:class{constructor(e,{onOffer:t=()=>{},onProgress:s=()=>{},importArchive:r,onComplete:i}){Object.assign(this,{send:e,onOffer:t,onProgress:s,importArchive:r,onComplete:i}),this.metadata=null,this.bytes=null,this.offset=0,this.state="offer"}accept(){if("waiting"!==this.state)throw new Error("Wait for the game details before receiving");this.bytes=new Uint8Array(this.metadata.bytes),this.state="receiving",this.send(JSON.stringify({type:"copy-accept"}))}async receive(e){if("closed"===this.state)return;if("string"==typeof e){const t=n(e);if("offer"===this.state)return this.metadata=o(t),this.state="waiting",void this.onOffer(this.metadata);if("copy-complete"!==t.type||"receiving"!==this.state||this.offset!==this.metadata.bytes)throw new Error("Incomplete game copy");this.state="validating";const s=this.bytes,r=this.metadata,a=await i(s);if("closed"===this.state)return;if(a!==r.sha256)throw new Error("The game copy was damaged during transfer. Try again.");const h=await this.importArchive(s);if(h.revision!==r.revision||h.manifest.gameId!==r.gameId)throw new Error("The received game does not match the offered copy");if("closed"===this.state)return;if(await this.onComplete({bytes:s,project:h}),"closed"===this.state)return;return this.state="done",this.bytes=null,void this.send(JSON.stringify({type:"copy-saved"}))}if("receiving"!==this.state)throw new Error("Unexpected game-copy data");const t=e instanceof ArrayBuffer?new Uint8Array(e):e,s=Math.min(65536,this.metadata.bytes-this.offset);if(!(t instanceof Uint8Array&&t.length===s+5&&s&&80===t[0]&&new DataView(t.buffer,t.byteOffset,t.byteLength).getUint32(1)===this.offset))throw new Error("Invalid game-copy chunk");this.bytes.set(t.subarray(5),this.offset),this.offset+=s,this.onProgress(this.offset,this.metadata.bytes),this.send(JSON.stringify({type:"copy-ack",offset:this.offset}))}close(){this.state="closed",this.bytes=null}},digest:i}},2157(e,t,s){"use strict";const r=s(1240),{Peer:i,signalUrl:n}=s(4454),o=s(8334),a=s(7237);class h{constructor(e,{signalingUrl:t="wss://api.homegames.io/rtc",receiveUrl:s="https://homegames.io/game-app.html",worker:r=!0,iceTransportPolicy:i="all",onStatus:n=()=>{}}={}){Object.assign(this,{project:e,signalingUrl:t,receiveUrl:s,worker:r,iceTransportPolicy:i,onStatus:n}),this.peers=new Map,this.closed=!1}share(){return this.closed?Promise.reject(new Error("Copy sharing has stopped. Open Share a copy again.")):this.pending||=this.start()}async start(){this.bytes=await a.exportArchive(this.project);const e=await o.digest(this.bytes);if(this.closed)throw new Error("Copy sharing stopped");return this.metadata={type:"copy-offer",protocol:1,name:String(this.project.metadata.name||"Homegame").slice(0,200),gameId:this.project.manifest.gameId,revision:this.project.revision,bytes:this.bytes.length,sha256:e},this.network=new r({worker:this.worker}),new Promise((e,t)=>{this.reject=t,this.signal=this.network.signal(n(this.signalingUrl),{type:"create",visibility:"private",maxPlayers:5},t=>{if("created"===t.type){const s=new URL(this.receiveUrl,window.location.href);if(!["http:","https:"].includes(s.protocol))throw new Error("Invalid game-copy destination");s.search=new URLSearchParams({game:this.metadata.gameId,revision:this.metadata.revision}),s.hash=new URLSearchParams({copy:"1",room:t.roomId,invite:t.invite,signal:n(this.signalingUrl)}),this.link=s.href,this.reject=null,t.heartbeatIntervalMs&&this.signal.startHeartbeat(t.heartbeatIntervalMs,{type:"heartbeat",playerCount:1}),this.onStatus("Ready to send a copy"),e(this.link)}else"peer-joined"===t.type?this.addPeer(t):"peer-left"===t.type?this.peers.get(t.peerId)?.close():"signal"===t.type&&this.peers.get(t.peerId)?.signal(t)},e=>{this.close(e),e&&this.onStatus(e.message)})})}addPeer({peerId:e,iceServers:t}){let s,r;const n=()=>{clearTimeout(r),r=setTimeout(()=>a.close(new Error("Copy transfer timed out. Open the invitation to try again.")),12e4)},a=new i({host:!0,network:this.network,iceServers:t,iceTransportPolicy:this.iceTransportPolicy,sendSignal:t=>this.signal?.send({type:"signal",peerId:e,...t}),onOpen:e=>{s=new o.Sender(this.bytes,this.metadata,t=>e.send(t),(e,t)=>this.onStatus(`Sending copy · ${Math.round(e/t*100)}%`)),n(),s.open()},onMessage:e=>{try{n(),s.receive(e)}catch(e){a.close(e)}},onEnd:t=>{clearTimeout(r),this.peers.delete(e),this.signal?.send({type:"remove",peerId:e}),this.closed||this.onStatus(t?t.message:"Ready to send another copy")}});this.peers.set(e,a),a.offer()}close(e){if(!this.closed){this.closed=!0,this.reject?.(e||new Error("Copy sharing stopped")),this.reject=null,this.signal?.close();for(const e of this.peers.values())e.close();this.peers.clear(),this.network?.close(),this.bytes=null}}}e.exports={CopyHost:h,receiveCopy:function(e,{onOffer:t,onProgress:s,onComplete:h,onError:l=()=>{},worker:c=!0,iceTransportPolicy:d="all"}){const u=new r({worker:c});let p,f,m,g,y=!1,v=!1,w=!1;const x=()=>{w||(w=!0,clearTimeout(g),p?.close(),f?.close(),u.close())},b=()=>{y||(y=!0,m?.close(),x())},E=e=>{y||(b(),v||l(e||new Error("The sender disconnected before the copy was saved. Open the invitation to try again.")))},S=e=>{w||y||("validating"===m?.state||v?x():E(e))},k=()=>{clearTimeout(g),g=setTimeout(()=>E(new Error("Copy transfer timed out. Open the invitation to try again.")),12e4)};return m=new o.Receiver(e=>{w||p.channel.send(e)},{onOffer:t,onProgress:s,importArchive:a.importArchive,onComplete:async e=>{clearTimeout(g),await h(e),v=!0,setTimeout(b,100)}}),f=u.signal(n(e.signalingUrl),{type:"join",roomId:e.roomId,invite:e.invite},e=>{"joined"===e.type?p=new i({network:u,iceServers:e.iceServers,iceTransportPolicy:d,sendSignal:e=>f.send({type:"signal",...e}),onOpen:k,onMessage:e=>{k(),m.receive(e).catch(E)},onEnd:S}):"signal"===e.type&&p?.signal(e)},S),{accept:()=>{if(y||!m)throw new Error("Reconnect to the sender to receive this game");k(),m.accept()},close:b}},readCopyInvitation:function(e){if("string"!=typeof e||e.length>4096)throw new Error("Paste a Share a copy invitation");const t=new URL(e,window.location.href),s=new URLSearchParams(t.hash.slice(1));if(!["http:","https:"].includes(t.protocol)||"1"!==s.get("copy")||!/^[A-Za-z0-9_-]{24}$/.test(s.get("room"))||!/^[A-Za-z0-9_-]{24}$/.test(s.get("invite")))throw new Error("Paste a Share a copy invitation");if(!/^wss?:\/\//.test(s.get("signal")||""))throw new Error("Invalid invitation service");const r=n(s.get("signal")),i=new URL(r);if(i.username||i.password||i.hash||i.search)throw new Error("Invalid invitation service");return{roomId:s.get("room"),invite:s.get("invite"),signalingUrl:r}},showCopyShare:function(e,t={}){let r,i=!1;const n=new h(e,{...t,onStatus:e=>r?.setStatus(e)}),o=()=>{i||(i=!0,n.close(),r.dispose(),t.onClose?.())};return r=s(172)({container:document.body,getLink:()=>n.share(),title:"Share a copy",hintText:"Your source, sounds and images are included. Keep this window open until the other person has saved their copy.",readyText:"Anyone with this link can keep an independent, editable copy.",closeLabel:"Stop sharing",onOpen:t.onOpen,onClose:o}),r.show(),{close:o}}}},9742(e,t,s){const r=s(1240),i=[{urls:"stun:stun.l.google.com:19302"}],n=131072;function o(e,t){if("string"!=typeof e||e.length>n)throw new Error("Handshake is missing or too large");let s;try{s=JSON.parse(e.trim())}catch(e){throw new Error("Paste the complete handshake text")}if("homegames-rtc"!==s?.format||1!==s.version||s.kind!==t||!/^[0-9a-f-]{36}$/i.test(s.id||"")||s.description?.type!==t||"string"!=typeof s.description.sdp||!s.description.sdp.startsWith("v=0")||(s.description.sdp.match(/^a=candidate:/gm)||[]).length>128||/^m=(audio|video) /m.test(s.description.sdp))throw new Error(`This is not a supported Homegames ${t}`);return s}function a(e,t){const s=JSON.stringify({format:"homegames-rtc",version:1,kind:t,id:e.id,description:e.pc.localDescription.toJSON()});if(s.length>n)throw new Error("Handshake is too large");return s}function h(e){return"complete"===e.pc.iceGatheringState?Promise.resolve():new Promise((t,s)=>{const r=r=>{clearTimeout(n),e.pc.removeEventListener("icegatheringstatechange",i),e.cancelGather=null,r?s(r):t()},i=()=>{"complete"===e.pc.iceGatheringState&&r()},n=setTimeout(()=>r(new Error("Network discovery timed out. Retry, or disable public STUN for a local-network connection.")),2e4);e.cancelGather=()=>r(new Error("Manual pairing cancelled")),e.pc.addEventListener("icegatheringstatechange",i),i()})}class l{constructor({id:e=crypto.randomUUID(),iceServers:t=i,onOpen:s=()=>{},onMessage:n=()=>{},onEnd:o=()=>{}}={}){Object.assign(this,{id:e,onEnd:o}),this.closed=!1,this.network=new r({worker:!1}),this.pc=new RTCPeerConnection({iceServers:t}),this.bind=e=>{this.channel||this.closed?e.close():this.channel=this.network.bind(e,{onOpen:()=>{clearTimeout(this.expiry),s()},onMessage:n,onClose:()=>this.close(),onError:e=>this.close(e)})},this.pc.ondatachannel=e=>this.bind(e.channel),this.pc.onconnectionstatechange=()=>{"failed"===this.pc.connectionState&&this.close(new Error("Could not connect directly. This network may require a TURN relay.")),clearTimeout(this.disconnected),"disconnected"===this.pc.connectionState&&(this.disconnected=setTimeout(()=>this.close(new Error("The other player disconnected")),1e4))},this.expiry=setTimeout(()=>this.close(new Error("Handshake expired. Create a fresh offer.")),6e5)}close(e){this.closed||(this.closed=!0,clearTimeout(this.expiry),clearTimeout(this.disconnected),this.cancelGather?.(),this.pc.ondatachannel=this.pc.onconnectionstatechange=null,this.network.close(),this.pc.close(),this.onEnd(e))}}e.exports={ManualHost:class{constructor(e,{iceServers:t=i,onStatus:s=()=>{}}={}){Object.assign(this,{session:e,iceServers:t,onStatus:s}),this.peers=new Set,this.pending=null}async createOffer(){if(!this.session.game)throw new Error("Start the game before creating an offer");this.cancelOffer();let e=null,t=Date.now(),s=0;const r=new l({iceServers:this.iceServers,onMessage:i=>{try{if("string"!=typeof i||i.length>65536)throw new Error("Invalid player input");if(Date.now()-t>1e3&&(t=Date.now(),s=0),++s>240)throw new Error("Too much player input");if(e)e.handleMessage(i);else{const t=JSON.parse(i);if("ready"!==t.type)throw new Error("Expected player handshake");e=this.session.addRemotePlayer({send:(e,t)=>r.channel.send(e,t),close:()=>r.close(),playerName:t.playerName,clientInfo:t.clientInfo?.clientInfo||{}}),this.onStatus("Manual player connected")}}catch(e){r.close(e)}},onEnd:t=>{this.peers.delete(r),this.pending===r&&(this.pending=null),e?.leave(),this.onStatus(t?.message||"Manual player disconnected")}});this.peers.add(r),this.pending=r,r.bind(r.pc.createDataChannel("homegames",{ordered:!0}));try{if(await r.pc.setLocalDescription(await r.pc.createOffer()),await h(r),r.closed)throw new Error("Offer cancelled");return a(r,"offer")}catch(e){throw r.close(),e}}async acceptAnswer(e){const t=o(e,"answer"),s=this.pending;if(!s||s.closed)throw new Error("Create an offer first");if(t.id!==s.id)throw new Error("This answer belongs to a different offer");if("have-local-offer"!==s.pc.signalingState)throw new Error("This offer has already been answered");await s.pc.setRemoteDescription(t.description),this.pending=null}cancelOffer(){this.pending?.close(),this.pending=null}stop(){for(const e of[...this.peers])e.close();this.pending=null}},createManualGuest:function(e,{iceServers:t=i,onStatus:s=()=>{}}={}){const r=o(e,"offer");let n=null,c=!1,d=!1;const u=new l({id:r.id,iceServers:t,onOpen:()=>{c=!0,n?.onOpen(),s("Connected to host")},onMessage:e=>{"string"!=typeof e&&n?.onMessage(e)},onEnd:e=>{d=!0,e&&n?.onError(e),n?.onClose(),s(e?.message||"Host disconnected")}});let p;return{transport:e=>(n=e,c&&queueMicrotask(()=>n.onOpen()),{send:e=>u.channel?.send(e),close:()=>u.close(),getStats:()=>u.network.getStats()}),answer:()=>p||(p=(async()=>{try{if(d)throw new Error("Connection closed");return await u.pc.setRemoteDescription(r.description),await u.pc.setLocalDescription(await u.pc.createAnswer()),await h(u),a(u,"answer")}catch(e){throw u.close(),e}})()),close:()=>u.close()}},readHandshake:o,DEFAULT_ICE:i}},1240(e,t,s){const r=s(8221),i=s(844),n=s(2402);e.exports=class{constructor({worker:e=!0}={}){if(this.channels=new Map,this.nextId=0,this.statsRequests=new Map,this.closed=!1,this.worker=null,e&&"undefined"!=typeof Worker&&"undefined"!=typeof Blob&&"function"==typeof URL.createObjectURL)try{this.workerUrl=URL.createObjectURL(new Blob([`(${n.toString()})(${r.workerSource()},${i.toString()});`],{type:"text/javascript"})),this.worker=new Worker(this.workerUrl,{name:"homegames-rtc"}),this.worker.onmessage=e=>this.receive(e.data),this.worker.onerror=e=>{e.preventDefault?.();const t=new Error(e.message||"RTC communication worker failed");this.onSignalEnd?.(t);for(const e of[...this.channels.values()])e.callbacks.onError(t);this.close()}}catch(e){this.worker?.terminate(),this.worker=null,this.workerUrl&&URL.revokeObjectURL(this.workerUrl),this.workerUrl=null}}signal(e,t,s,r,n){if(this.onSignalMessage=s,this.onSignalEnd=r,this.onHeartbeat=n,!this.worker)return this.inlineSignal=i(e,t,s,r,n);const o=(e,t={})=>{this.closed||this.worker.postMessage({type:e,...t})};return o("signal-open",{url:e,hello:t}),{send:e=>o("signal-send",{data:e}),startHeartbeat:(e,t)=>o("heartbeat-start",{interval:e,data:t}),heartbeat:e=>o("heartbeat-update",{data:e}),close:()=>{this.onSignalEnd=null,o("signal-close")}}}bind(e,t){const s=++this.nextId,i={callbacks:t,mode:"main-thread",protocol:null,mailbox:null};if(this.channels.set(s,i),this.worker)try{this.worker.postMessage({type:"bind",id:s,channel:e},[e]),i.mode="worker"}catch(e){}if("worker"===i.mode)i.mailbox=new r.Mailbox((e,t)=>{this.worker.postMessage({type:"send",id:s,data:e},t&&"string"!=typeof e?[e.buffer||e]:[])},e=>t.onError(e));else{i.protocol=new r(e,t);let s=!1;const n=()=>{s||i.protocol.closed||this.closed||(s=!0,i.protocol.flush(),t.onOpen())};e.onopen=n,"open"===e.readyState&&queueMicrotask(n)}return{send:(e,{transfer:t=!1}={})=>{!this.closed&&this.channels.has(s)&&(i.mailbox?i.mailbox.send(e,t):i.protocol.send(e))},close:()=>{this.channels.delete(s)&&(i.mailbox?.close(),i.protocol?.close(),"worker"!==i.mode||this.closed||this.worker.postMessage({type:"channel-close",id:s}))}}}receive(e){if(this.closed)return;const t=this.channels.get(e.id);switch(e.type){case"signal-message":try{this.onSignalMessage?.(e.data)}catch(e){this.onSignalEnd?.(e)}break;case"signal-end":this.onSignalEnd?.(e.message?new Error(e.message):null);break;case"heartbeat":this.onHeartbeat?.(e.data);break;case"channel-open":t?.callbacks.onOpen();break;case"channel-error":t?.callbacks.onError(new Error(e.message));break;case"channel-close":t?.callbacks.onClose();break;case"sent":t?.mailbox.ack();break;case"data":try{t?.callbacks.onMessage(e.data)}catch(e){t?.callbacks.onError(e)}this.closed||this.worker.postMessage({type:"received",id:e.id});break;case"stats":{const t=this.statsRequests.get(e.id);t&&(clearTimeout(t.timer),this.statsRequests.delete(e.id),t.resolve(e.channels));break}}}async getStats(){const e=[...this.channels].filter(([,e])=>e.protocol).map(([e,t])=>({id:e,mode:t.mode,...t.protocol.stats,queuedBytes:t.protocol.queuedBytes,bufferedBytes:t.protocol.channel.bufferedAmount}));let t=[];return this.worker&&!this.closed&&(t=await new Promise(e=>{const t=++this.nextId,s=setTimeout(()=>{this.statsRequests.delete(t),e([])},2e3);this.statsRequests.set(t,{resolve:e,timer:s}),this.worker.postMessage({type:"stats",id:t})})),{worker:!!this.worker&&!this.closed,channels:[...t,...e].map(e=>({...e,sendQueueBytes:this.channels.get(e.id)?.mailbox?.bytes||0,sendReplacedFrames:this.channels.get(e.id)?.mailbox?.replacedFrames||0}))}}close(){if(!this.closed){this.closed=!0;for(const e of this.channels.values())e.mailbox?.close(),e.protocol?.close();this.channels.clear(),this.inlineSignal?.close(),this.worker?.terminate(),this.workerUrl&&URL.revokeObjectURL(this.workerUrl),this.statsRequests.forEach(e=>{clearTimeout(e.timer),e.resolve([])}),this.statsRequests.clear()}}}},4454(e,t,s){const r=s(1240),i=e=>{const t=new URL(e,window.location.href);if("https:"===t.protocol&&(t.protocol="wss:"),"http:"===t.protocol&&(t.protocol="ws:"),!["ws:","wss:"].includes(t.protocol))throw new Error("Invalid signaling URL");return t.href};class n{constructor({iceServers:e,sendSignal:t,onOpen:s,onMessage:r,onEnd:i,onTrack:n=()=>{},network:o,host:a=!1,iceTransportPolicy:h="all"}){this.pc=new RTCPeerConnection({iceServers:e,iceTransportPolicy:h}),Object.assign(this,{sendSignal:t,onEnd:i}),this.pendingCandidates=[],this.work=Promise.resolve(),this.closed=!1,this.polite=!a,this.senders=new Map,this.receivedStreams=new Map,this.pc.onnegotiationneeded=()=>this.offer(),this.pc.ontrack=e=>{const t=e.streams[0];t&&(this.receivedStreams.set(t.id,t),this.receivedStreams.size>32&&this.receivedStreams.delete(this.receivedStreams.keys().next().value),n(t))},this.timer=setTimeout(()=>this.close(new Error("Could not connect to the other device. Check the network or TURN configuration.")),3e4),this.pc.onicecandidate=e=>{e.candidate&&t({candidate:e.candidate.toJSON()})},this.pc.onconnectionstatechange=()=>{"failed"===this.pc.connectionState&&this.close(new Error("The game connection failed")),clearTimeout(this.disconnectTimer),"disconnected"===this.pc.connectionState&&(this.disconnectTimer=setTimeout(()=>this.close(new Error("The other device disconnected")),1e4))};const l=e=>{this.closed||this.channel?e.close():this.channel=o.bind(e,{onMessage:r,onError:e=>this.close(e),onClose:()=>this.close(),onOpen:()=>{this.closed||(clearTimeout(this.timer),s(this.channel))}})};a?l(this.pc.createDataChannel("homegames",{ordered:!0})):this.pc.ondatachannel=e=>l(e.channel)}offer(){this.enqueue(async()=>{if("stable"===this.pc.signalingState){this.makingOffer=!0;try{await this.pc.setLocalDescription(await this.pc.createOffer()),this.closed||this.sendSignal({description:this.pc.localDescription.toJSON()})}finally{this.makingOffer=!1}}})}addMedia(e,t){const s=this.senders.get(e)||[];for(const e of t.getTracks())s.some(t=>t.track===e)||s.push(this.pc.addTrack(e,t));this.senders.set(e,s)}removeMedia(e){for(const t of this.senders.get(e)||[])this.closed||this.pc.removeTrack(t);this.senders.delete(e)}signal(e){this.enqueue(async()=>{if(e.description){const t="offer"===e.description.type&&(this.makingOffer||"stable"!==this.pc.signalingState);if(this.ignoreOffer=!this.polite&&t,this.ignoreOffer)return;if(await this.pc.setRemoteDescription(e.description),this.closed)return;for(const e of this.pendingCandidates.splice(0))await this.pc.addIceCandidate(e);if("offer"===e.description.type){const e=await this.pc.createAnswer();if(this.closed)return;await this.pc.setLocalDescription(e),this.closed||this.sendSignal({description:this.pc.localDescription.toJSON()})}}else if(e.candidate){if(this.ignoreOffer)return;if(this.pc.remoteDescription)await this.pc.addIceCandidate(e.candidate);else{if(!(this.pendingCandidates.length<128))throw new Error("Too many ICE candidates");this.pendingCandidates.push(e.candidate)}}})}enqueue(e){this.work=this.work.then(()=>{if(!this.closed)return e()}).catch(e=>this.close(e))}close(e){this.closed||(this.closed=!0,clearTimeout(this.timer),clearTimeout(this.disconnectTimer),this.pc.onicecandidate=this.pc.onconnectionstatechange=this.pc.ondatachannel=this.pc.ontrack=this.pc.onnegotiationneeded=null,this.senders.clear(),this.receivedStreams.clear(),this.channel?.close(),this.pc.close(),this.onEnd(e))}}const o=(e=window.location.hash)=>{const t=new URLSearchParams(e.replace(/^#/,""));return t.has("room")?{roomId:t.get("room"),invite:t.get("invite"),signalingUrl:t.get("signal")}:null};e.exports={RtcHost:class{constructor(e,{signalingUrl:t="wss://api.homegames.io/rtc",joinUrl:s="https://homegames.io/play.html",onStatus:r=()=>{},worker:i=!0,iceTransportPolicy:n="all",room:o=null,visibility:a="private",onRoom:h=()=>{},onHeartbeat:l=()=>{},onEnd:c=()=>{}}={}){Object.assign(this,{session:e,signalingUrl:t,joinUrl:s,onStatus:r,worker:i,iceTransportPolicy:n,room:o,visibility:a,onRoom:h,onHeartbeat:l,onEnd:c}),this.peers=new Map,this.link=null,this.pending=null,this.signal=null,e.onStop=()=>this.stop()}share(){return 1===this.session.maxPlayers?Promise.reject(new Error("This is a solo game. Use Share a copy to send it to a friend.")):this.link?Promise.resolve(this.link):this.pending?this.pending:this.session.game?"undefined"==typeof RTCPeerConnection?Promise.reject(new Error("This browser does not support WebRTC")):(this.pending=new Promise((e,t)=>{this.reject=t,this.network=new r({worker:this.worker}),this.signal=this.network.signal(i(this.signalingUrl),{type:"create",game:this.room,visibility:this.visibility,maxPlayers:this.session.maxPlayers},t=>{if("created"===t.type){if(this.room&&2!==t.protocol)throw new Error("The invitation service needs an update for public sessions");this.supportsHeartbeat=2===t.protocol;const s=new URL(this.joinUrl,window.location.href);s.hash=new URLSearchParams({room:t.roomId,invite:t.invite,signal:i(this.signalingUrl)}).toString(),this.link=s.href,this.reject=null,this.onRoom(this.link),this.visibility=t.visibility||this.visibility,t.heartbeatIntervalMs&&(this.signal.startHeartbeat(t.heartbeatIntervalMs,{type:"heartbeat",playerCount:this.session.players?.length||1}),this.heartbeat()),this.status(),e(this.link)}else if("peer-joined"===t.type)this.addPeer(t);else if("peer-left"===t.type)this.peers.get(t.peerId)?.close();else if("signal"===t.type)this.peers.get(t.peerId)?.signal(t);else if("visibility"===t.type){this.visibility=t.visibility,this.status();const e=this.visibilityPending;this.visibilityPending=null,e&&(clearTimeout(e.timer),e.resolve(t.visibility))}},e=>{this.stop(e),e&&this.onStatus(e.message)},e=>{this.link&&this.onHeartbeat(e.playerCount)})}),this.pending.catch(e=>{throw this.stop(e),e})):Promise.reject(new Error("The game is still loading"))}heartbeat(){const e=Math.min(17,this.session.players?.length||1);this.supportsHeartbeat&&this.signal?.heartbeat({type:"heartbeat",playerCount:e}),this.link&&this.onHeartbeat(e)}status(){const e=this.session.players?.length||1;this.onStatus(this.room?`${"public"===this.visibility?"Public":"Private"} game · ${e} ${1===e?"player":"players"}`:e>1?`${e} players connected`:"Waiting for a player")}async setVisibility(e){if(await this.share(),!this.room)throw new Error("Only catalog games can be listed publicly");if(this.visibilityPending)throw new Error("Visibility is still updating");return new Promise((t,s)=>{const r=setTimeout(()=>{this.visibilityPending=null,s(new Error("Unable to update visibility"))},1e4);this.visibilityPending={resolve:t,reject:s,timer:r},this.signal.send({type:"visibility",visibility:e})})}addPeer({peerId:e,iceServers:t}){let s=null,r=Date.now(),i=0;const o=new n({host:!0,network:this.network,iceServers:t,iceTransportPolicy:this.iceTransportPolicy,sendSignal:t=>this.signal?.send({type:"signal",peerId:e,...t}),onOpen:e=>e.send(JSON.stringify({type:"invitation",url:this.link})),onTrack:e=>{s&&this.session.media?.attach(s.playerId,e)&&o.receivedStreams.delete(e.id)},onMessage:e=>{try{if("string"!=typeof e)throw new Error("Expected player input");if(Date.now()-r>1e3&&(r=Date.now(),i=0),++i>240)throw new Error("Too much player input");if(s){const t=JSON.parse(e);if("media"===t.type){this.session.media?.handle(s.playerId,t);for(const e of o.receivedStreams.values())this.session.media?.attach(s.playerId,e)&&o.receivedStreams.delete(e.id)}else s.handleMessage(e)}else{const t=JSON.parse(e);if("ready"!==t.type)throw new Error("Expected player handshake");s=this.session.addRemotePlayer({send:(e,t)=>o.channel.send(e,t),close:()=>o.close(),playerName:t.playerName,clientInfo:t.clientInfo?.clientInfo||{}}),1===t.media&&this.session.media?.join(s.playerId,{recording:1===t.recording||2===t.recording,audioRecording:2===t.recording,send:e=>o.channel.send(JSON.stringify(e)),addMedia:(e,t)=>o.addMedia(e,t),removeMedia:e=>o.removeMedia(e)}),this.heartbeat(),this.status()}}catch(e){o.close(e)}},onEnd:t=>{this.peers.delete(e),s?.leave(),this.signal?.send({type:"remove",peerId:e}),this.heartbeat(),!s&&t?this.onStatus(t.message):this.status()}});this.peers.set(e,o),o.offer()}getStats(){return this.network?.getStats()||Promise.resolve({worker:!1,channels:[]})}stop(e=new Error("The invitation ended")){(this.link||this.pending)&&this.onEnd(),this.supportsHeartbeat=!1;const t=this.visibilityPending;this.visibilityPending=null,t&&(clearTimeout(t.timer),t.reject(e||new Error("The invitation ended")));const s=this.reject;this.reject=null,s?.(e||new Error("The invitation ended"));const r=this.signal;this.signal=null,r?.close();for(const e of[...this.peers.values()])e.close();this.peers.clear(),this.link=null,this.pending=null,this.network?.close(),this.network=null}},createRtcTransport:({roomId:e,invite:t,signalingUrl:s,joinUrl:a="https://homegames.io/play.html",worker:h=!0,iceTransportPolicy:l="all"})=>c=>{const d=new r({worker:h});let u,p=null,f=!1,m=!1,g=null;const y=t=>{if("string"==typeof t)try{const r=JSON.parse(t);if("media"===r.type)return void c.onMedia?.(r);if("invitation"!==r.type||"string"!=typeof r.url||r.url.length>4096)return;const n=new URL(r.url),a=o(n.hash);["http:","https:"].includes(n.protocol)&&!n.username&&!n.password&&a?.roomId===e&&a.invite&&i(a.signalingUrl)===i(s)&&(g=n.href)}catch(e){}else c.onMessage(t)},v=e=>{f||(f=!0,p?.close(),u?.close(),d.close(),e&&!m&&c.onError(e),c.onClose())};try{u=d.signal(i(s),{type:"join",roomId:e,invite:t},e=>{"joined"===e.type?p=new n({network:d,iceServers:e.iceServers,iceTransportPolicy:l,onTrack:e=>c.onTrack?.(e),sendSignal:e=>u.send({type:"signal",...e}),onOpen:()=>{m=!0,c.onOpen()},onMessage:y,onEnd:v}):"signal"===e.type&&p?.signal(e)},v)}catch(e){queueMicrotask(()=>v(e))}return{send:e=>p?.channel?.send(e),getStats:()=>d.getStats(),addMedia:(e,t)=>p?.addMedia(e,t),removeMedia:e=>p?.removeMedia(e),getShareLink:()=>{if(f)throw new Error("This session has ended");if(!m)throw new Error("Connect to the host before sharing this game");if(g)return g;const r=new URL(a,window.location.href),n=new URLSearchParams({room:e,signal:i(s)});return t&&n.set("invite",t),r.hash=n.toString(),r.href},close:()=>{f=!0,p?.close(),u?.close(),d.close()}}},readInvitation:o,Peer:n,signalUrl:i}},844(e){e.exports=function(e,t,s,r,i=()=>{}){const n=new WebSocket(e);let o=!1,a=null,h=null;const l=e=>{o||(o=!0,clearTimeout(c),clearInterval(a),n.onopen=n.onmessage=n.onerror=n.onclose=null,n.close(),r(e))},c=setTimeout(()=>l(new Error("Signaling connection timed out")),15e3),d=e=>{o||1!==n.readyState||n.send(JSON.stringify(e))};return n.onopen=()=>d(t),n.onmessage=e=>{try{const t=JSON.parse(e.data);if("error"===t.type)return l(new Error(t.message));if("ended"===t.type)return l(new Error("The host ended this game"));clearTimeout(c),s(t)}catch(e){l(e)}},n.onerror=()=>l(new Error("Cannot reach the invitation service")),n.onclose=()=>l(new Error("The invitation connection closed")),{send:d,startHeartbeat(e,t){clearInterval(a),h=t,!o&&Number.isFinite(e)&&e>0&&(a=setInterval(()=>{d(h),i(h)},e))},heartbeat(e){h=e,d(e)},close:()=>l(null)}}},2402(e){e.exports=function(e,t){const s=new Map;let r=null;const i=(e,t={},s=[])=>postMessage({type:e,...t},s),n=(e,t)=>i("channel-error",{id:e,message:t.message});onmessage=({data:o})=>{const{type:a,id:h,data:l}=o;if("signal-open"===a)r=t(o.url,o.hello,e=>i("signal-message",{data:e}),e=>i("signal-end",{message:e?.message}),e=>i("heartbeat",{data:e}));else if("signal-send"===a)r?.send(l);else if("heartbeat-start"===a)r?.startHeartbeat(o.interval,l);else if("heartbeat-update"===a)r?.heartbeat(l);else if("signal-close"===a)r?.close(),r=null;else if("bind"===a){const t=o.channel;let r=!1;const a=new e.Mailbox(e=>i("data",{id:h,data:e},"string"==typeof e?[]:[e.buffer||e]),e=>n(h,e)),l=new e(t,{onMessage:e=>a.send(e,!0),onError:e=>n(h,e),onClose:()=>{a.close(),s.delete(h),i("channel-close",{id:h})}});s.set(h,{protocol:l,mailbox:a});const c=()=>{r||l.closed||(r=!0,l.flush(),i("channel-open",{id:h}))};t.onopen=c,"open"===t.readyState&&c()}else if("send"===a)s.get(h)?.protocol.send(l),i("sent",{id:h});else if("received"===a)s.get(h)?.mailbox.ack();else if("channel-close"===a){const e=s.get(h);s.delete(h),e?.mailbox.close(),e?.protocol.close()}else"stats"===a&&i("stats",{id:h,channels:[...s].map(([e,{protocol:t,mailbox:s}])=>({id:e,mode:"worker",...t.stats,queuedBytes:t.queuedBytes,bufferedBytes:t.channel.bufferedAmount,receiveQueueBytes:s.bytes,receiveReplacedFrames:s.replacedFrames}))})}}},7699(e){const t="hg-save:",s=1048576;e.exports={createSaveStore:()=>{const e=(()=>{try{const e=t+"__test__";return window.localStorage.setItem(e,"1"),window.localStorage.removeItem(e),window.localStorage}catch(e){return null}})(),s={};return{getSave:r=>new Promise(i=>{try{const n=e?e.getItem(t+r):s[r];if(!n)return void i(null);const o=JSON.parse(n);i(o&&"object"==typeof o?o:null)}catch(e){i(null)}}),putSave:(r,i)=>new Promise((n,o)=>{let a;try{a=JSON.stringify(i)}catch(e){return void o(e)}if(e)try{return e.setItem(t+r,a),void n()}catch(e){}s[r]=a,n()}),deleteSave:r=>new Promise(i=>{try{e&&e.removeItem(t+r)}catch(e){}delete s[r],i()})}},createDebouncedWriter:({intervalMs:e,write:t})=>{let s=0,r=null;const i=()=>{const e=r;r=null,s=Date.now(),Promise.resolve().then(()=>t(e.value)).then(()=>e.resolvers.forEach(e=>e())).catch(t=>e.rejecters.forEach(e=>e(t)))};return t=>new Promise((n,o)=>{if(r)return r.value=t,r.resolvers.push(n),void r.rejecters.push(o);r={value:t,resolvers:[n],rejecters:[o]};const a=Math.max(0,e-(Date.now()-s));setTimeout(i,a)})},serializeSaveData:e=>{const t=JSON.stringify(e);if(void 0===t)throw new Error("Save data must be JSON-serializable");if((new TextEncoder).encode(t).length>s)throw new Error("Save data exceeds "+s+" bytes");return t},isCompatibleSave:(e,t,s)=>!(!e||"object"!=typeof e||void 0===e.data)&&(e.versionId===t||Array.isArray(s)&&-1!==s.indexOf(e.versionId)),DEFAULT_VERSION_ID:"local-game-version"}},1525(e){e.exports=class{constructor({remote:e,loadLocal:t,mountLocal:s,createLocal:r,onError:i}){Object.assign(this,{remote:e,loadLocal:t,mountLocal:s,createLocal:r,onError:i}),this.local=null,this.chrome=null,this.generation=0,this.pending=null}_cancelLoad(){this.generation++,this.pending?.abort(),this.pending=null}_disposeActive(){const e=this.local;this.local=null,e?.stop(),this.chrome?.dispose(),this.chrome=null,this.remote.stop()}start(){this.stop(),this.remote.start()}stop(){this._cancelLoad(),this._disposeActive()}async startLocal(e){this._cancelLoad();const t=this.generation,s=this.pending=new AbortController;try{const r=await this.loadLocal(e,{signal:s.signal});if(t!==this.generation)return;this.pending=null,this._disposeActive(),this.chrome=this.mountLocal(r),this.local=this.createLocal({...r,containerId:this.chrome.containerId}),this.local.start()}catch(e){if(t!==this.generation)return;this.pending=null,this.onError(e)}}}},7875(e){const t=new WeakMap;e.exports=()=>{let e=t.get(document);if(!e){const s=document.createElement("style");s.textContent="\n .hg-session-frame, .hg-share-dialog { font:14px/1.4 system-ui,-apple-system,BlinkMacSystemFont,sans-serif; color:#f6f6ee; }\n .hg-session-frame *, .hg-share-dialog * { box-sizing:border-box; }\n .hg-session-frame { width:100%; height:100%; position:relative; overflow:hidden; background:#000; container-type:inline-size; }\n .hg-session-game { flex:1; min-height:0; width:100%; position:relative; overflow:hidden; display:flex; align-items:center; background:#000; }\n .hg-share-dialog button { display:inline-flex; align-items:center; justify-content:center; gap:8px; min-height:44px; padding:0 18px; border:1px solid #4a5049; border-radius:10px; background:transparent; color:#f6f6ee; font:600 14px/1.2 system-ui,sans-serif; cursor:pointer; }\n .hg-share-dialog .hg-share-copy { background:#fff78e; color:#22261e; }\n .hg-share-dialog :focus-visible { outline:2px solid #fff78e; outline-offset:4px; }\n .hg-share-dialog { margin:auto; width:min(400px,calc(100vw - 32px)); max-height:calc(100dvh - 32px); padding:24px; border:1px solid #4a5049; border-radius:20px; background:#202321; box-sizing:border-box; overflow:auto; text-align:center; box-shadow:0 24px 80px #0009; }\n .hg-share-dialog::backdrop { background:#080c0ac9; }\n .hg-share-dialog h2 { margin:0 0 8px; font-size:22px; letter-spacing:-.5px; }\n .hg-share-hint { margin:0 0 20px; color:#b7bfb5; font-size:13px; }\n .hg-share-qr { width:100%; max-width:256px; aspect-ratio:1; padding:8px; margin:0 auto 16px; border-radius:12px; overflow:hidden; background:#fff; }\n .hg-share-qr[hidden] { display:none; }\n .hg-share-status { margin:16px 0; color:#cbd1c8; font-size:12px; overflow-wrap:anywhere; }\n .hg-share-link { width:100%; padding:12px; border:1px solid #4a5049; border-radius:8px; background:#111510; color:#cbd1c8; font:12px system-ui,sans-serif; }\n .hg-share-actions { display:flex; gap:10px; margin-top:16px; }\n .hg-share-actions button { flex:1; }\n .hg-share-dialog button:disabled { opacity:.4; cursor:wait; }\n ",(document.head||document.body).appendChild(s),e={style:s,count:0},t.set(document,e)}e.count++;const s=document;return()=>{0===--e.count&&(e.style.remove(),t.delete(s))}}},172(e,t,s){const r=s(3008);e.exports=function({container:e,getLink:t,onOpen:i,onClose:n,title:o="Share this game",readyText:a="Anyone with this link can join",closeLabel:h="Done",hintText:l="Scan to join. Keep this game tab open."}){const c=document.createElement("dialog"),d=s(7875)();c.className="hg-share-dialog",c.setAttribute("aria-label",o);const u=document.createElement("h2");u.textContent=o;const p=document.createElement("p");p.textContent=l,p.className="hg-share-hint";const f=document.createElement("div");f.className="hg-share-qr";const m=document.createElement("p");m.setAttribute("role","status"),m.className="hg-share-status";const g=document.createElement("input");g.readOnly=!0,g.setAttribute("aria-label","Invitation link"),g.className="hg-share-link";const y=document.createElement("div");y.className="hg-share-actions";const v=(e,t)=>{const s=document.createElement("button");return s.type="button",s.textContent=e,s.onclick=t,y.appendChild(s),s},w=v("Copy link",async()=>{try{await navigator.clipboard.writeText(g.value),m.textContent="Link copied"}catch(e){g.focus(),g.select(),m.textContent="Copy the selected invitation link"}});w.className="hg-share-copy";const x=v(h,()=>c.close());[u,p,f,m,g,y].forEach(e=>c.appendChild(e)),e.appendChild(c);let b=0,E=!1;return c.onclose=()=>{b++,n?.()},c.addEventListener("click",e=>{if(e.target===c){const t=c.getBoundingClientRect();(e.clientX<t.left||e.clientX>t.right||e.clientY<t.top||e.clientY>t.bottom)&&c.close()}}),{setStatus(e){E||(m.textContent=e)},async show(){if(E||c.open)return;const e=++b;f.innerHTML="",f.hidden=!0,g.value="",g.hidden=!0,w.disabled=!0,m.textContent="Creating invitation…",c.showModal(),i?.(),x.focus();try{const s=await t();if(e!==b)return;const i=r(0,"M");i.addData(s),i.make(),f.innerHTML=i.createSvgTag({cellSize:4,margin:16,scalable:!0}),f.firstChild.style.cssText="display:block;width:100%;height:100%;background:white",f.hidden=!1,g.value=s,g.hidden=!1,w.disabled=!1,m.textContent=a}catch(t){e===b&&(m.textContent=t.message)}},dispose(){E||(E=!0,b++,c.open&&c.close(),c.remove(),d())}}}},9732(e,t,s){const r={150:s(5911),151:s(2416)};e.exports={squishMap:r,DEFAULT_VERSION:"151"}},5537(e){e.exports=class{constructor(e,t,s,r,i={}){Object.assign(this,{assetManager:e,asset:t,invalidate:r,closed:!1,frozen:!1,forceMute:!1});const n=this.element=document.createElement("video");n.playsInline=!0,n.preload="auto",n.muted=!0,n.onloadedmetadata=()=>{s>0&&Number.isFinite(n.duration)&&(n.currentTime=Math.min(s,n.duration))},n.onloadeddata=n.onseeked=n.onended=()=>{this.closed||r()},n.onerror=()=>{this.closed||(this.error=!0,r())},"stream"===t.type?n.srcObject=t.data:(t.url||(t.url=URL.createObjectURL(t.data)),n.src=t.url),e.mediaPlayers.add(this),this.update(!!i.muteAudio,!!i.freezeMedia)}update(e,t){if(this.forceMute=e,t)return this.frozen=!0,void this.element.pause();const s=this.frozen;this.frozen=!1,this.element.muted=e||!this.assetManager.mediaUnlocked||!!this.blockedAudio,this.started&&!s||this.play()}play(){if(this.closed||this.frozen||this.error||this.starting||this.element.ended)return;this.starting=!0,this.started=!0;const e=this.element.muted;Promise.resolve(this.element.play()).then(()=>{this.closed||(this.starting=!1,this.scheduleFrame(),this.invalidate())}).catch(t=>{this.closed||(this.starting=!1,"NotAllowedError"===t.name?(this.blockedAudio=!0,e||this.frozen||(this.element.muted=!0,this.play())):"AbortError"!==t.name&&(this.error=!0),this.invalidate())})}unlock(){this.closed||this.frozen||this.forceMute||this.element.ended||(this.blockedAudio=!1,this.element.muted=!1,this.play())}scheduleFrame(){!this.closed&&null==this.frameCallback&&this.element.requestVideoFrameCallback&&(this.frameCallback=this.element.requestVideoFrameCallback(()=>{this.frameCallback=null,this.closed||(this.invalidate(),this.element.paused||this.element.ended||this.scheduleFrame())}))}needsRepaint(){return!this.closed&&!this.frozen&&!this.error&&!this.element.requestVideoFrameCallback&&!this.element.paused&&!this.element.ended&&this.element.readyState>=2}destroy(){this.closed||(this.closed=!0,null!=this.frameCallback&&this.element.cancelVideoFrameCallback?.(this.frameCallback),this.element.onloadedmetadata=this.element.onloadeddata=this.element.onseeked=this.element.onended=this.element.onerror=null,this.element.pause(),this.element.srcObject=null,this.element.removeAttribute("src"),this.element.load(),this.assetManager.mediaPlayers.delete(this))}}},595(e,t){"use strict";t.zipSync=function(e,t){t||(t={});var r={},i=[];ee(e,"",r,t);var n=0,o=0;for(var a in r){var h=r[a],l=h[0],c=h[1],d=0==c.level?0:8,u=(k=ie(a)).length,p=c.comment,f=p&&ie(p),m=f&&f.length,g=le(c.extra);u>65535&&L(11);var y=d?Z(l,c):l,v=y.length,w=G();w.p(l),i.push(K(c,{size:l.length,crc:w.d(),c:y,f:k,m:f,u:u!=a.length||f&&p.length!=m,o:n,compression:d})),n+=30+u+g+v,o+=76+2*(u+g)+(m||0)+v}for(var x=new s(o+22),b=n,E=o-n,S=0;S<i.length;++S){var k=i[S];ce(x,k.o,k,k.f,k.u,k.c.length);var _=30+k.f.length+le(k.extra);x.set(k.c,k.o+_),ce(x,n,k,k.f,k.u,k.c.length,k.o,k.m),n+=16+_+(k.m?k.m.length:0)}return de(x,n,i.length,E,b),x},t.unzipSync=function(e,t){for(var r={},i=e.length-22;101010256!=Y(e,i);--i)(!i||e.length-i>65558)&&L(13);var n=W(e,i+8);if(!n)return{};var o=Y(e,i+16),a=117853008==Y(e,i-20);if(a){var h=Y(e,i-12);(a=101075792==Y(e,h))&&(n=Y(e,h+32),o=Y(e,h+48))}for(var l=t&&t.filter,c=0;c<n;++c){var d=ae(e,o,a),u=d[0],p=d[1],f=d[2],m=d[3],g=d[4],y=d[5],v=oe(e,y);o=g,l&&!l({name:m,size:p,originalSize:f,compression:u})||(u?8==u?r[m]=Q(e.subarray(v,v+p),{out:new s(f)}):L(14,"unknown compression type "+u):r[m]=T(e,v,v+p))}return r};var s=Uint8Array,r=Uint16Array,i=Int32Array,n=new s([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),o=new s([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),a=new s([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),h=function(e,t){for(var s=new r(31),n=0;n<31;++n)s[n]=t+=1<<e[n-1];var o=new i(s[30]);for(n=1;n<30;++n)for(var a=s[n];a<s[n+1];++a)o[a]=a-s[n]<<5|n;return{b:s,r:o}},l=h(n,2),c=l.b,d=l.r;c[28]=258,d[258]=28;for(var u=h(o,0),p=u.b,f=u.r,m=new r(32768),g=0;g<32768;++g){var y=(43690&g)>>1|(21845&g)<<1;y=(61680&(y=(52428&y)>>2|(13107&y)<<2))>>4|(3855&y)<<4,m[g]=((65280&y)>>8|(255&y)<<8)>>1}var v=function(e,t,s){for(var i=e.length,n=0,o=new r(t);n<i;++n)e[n]&&++o[e[n]-1];var a,h=new r(t);for(n=1;n<t;++n)h[n]=h[n-1]+o[n-1]<<1;if(s){a=new r(1<<t);var l=15-t;for(n=0;n<i;++n)if(e[n])for(var c=n<<4|e[n],d=t-e[n],u=h[e[n]-1]++<<d,p=u|(1<<d)-1;u<=p;++u)a[m[u]>>l]=c}else for(a=new r(i),n=0;n<i;++n)e[n]&&(a[n]=m[h[e[n]-1]++]>>15-e[n]);return a},w=new s(288);for(g=0;g<144;++g)w[g]=8;for(g=144;g<256;++g)w[g]=9;for(g=256;g<280;++g)w[g]=7;for(g=280;g<288;++g)w[g]=8;var x=new s(32);for(g=0;g<32;++g)x[g]=5;var b=v(w,9,0),E=v(w,9,1),S=v(x,5,0),k=v(x,5,1),_=function(e){for(var t=e[0],s=1;s<e.length;++s)e[s]>t&&(t=e[s]);return t},C=function(e,t,s){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(7&t)&s},A=function(e,t){var s=t/8|0;return(e[s]|e[s+1]<<8|e[s+2]<<16)>>(7&t)},I=function(e){return(e+7)/8|0},T=function(e,t,r){return(null==t||t<0)&&(t=0),(null==r||r>e.length)&&(r=e.length),new s(e.subarray(t,r))},P=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],L=function(e,t,s){var r=new Error(t||P[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,L),!s)throw r;return r},M=function(e,t,r,i){var h=e.length,l=i?i.length:0;if(!h||t.f&&!t.l)return r||new s(0);var d=!r,u=d||2!=t.i,f=t.i;d&&(r=new s(3*h));var m=function(e){var t=r.length;if(e>t){var i=new s(Math.max(2*t,e));i.set(r),r=i}},g=t.f||0,y=t.p||0,w=t.b||0,x=t.l,b=t.d,S=t.m,P=t.n,M=8*h;do{if(!x){g=C(e,y,1);var R=C(e,y+1,3);if(y+=3,!R){var N=e[(G=I(y)+4)-4]|e[G-3]<<8,O=G+N;if(O>h){f&&L(0);break}u&&m(w+N),r.set(e.subarray(G,O),w),t.b=w+=N,t.p=y=8*O,t.f=g;continue}if(1==R)x=E,b=k,S=9,P=5;else if(2==R){var U=C(e,y,31)+257,B=C(e,y+10,15)+4,D=U+C(e,y+5,31)+1;y+=14;for(var j=new s(D),q=new s(19),H=0;H<B;++H)q[a[H]]=C(e,y+3*H,7);y+=3*B;var V=_(q),z=(1<<V)-1,F=v(q,V,1);for(H=0;H<D;){var G,$=F[C(e,y,z)];if(y+=15&$,(G=$>>4)<16)j[H++]=G;else{var K=0,W=0;for(16==G?(W=3+C(e,y,3),y+=2,K=j[H-1]):17==G?(W=3+C(e,y,7),y+=3):18==G&&(W=11+C(e,y,127),y+=7);W--;)j[H++]=K}}var Y=j.subarray(0,U),J=j.subarray(U);S=_(Y),P=_(J),x=v(Y,S,1),b=v(J,P,1)}else L(1);if(y>M){f&&L(0);break}}u&&m(w+131072);for(var X=(1<<S)-1,Z=(1<<P)-1,Q=y;;Q=y){var ee=(K=x[A(e,y)&X])>>4;if((y+=15&K)>M){f&&L(0);break}if(K||L(2),ee<256)r[w++]=ee;else{if(256==ee){Q=y,x=null;break}var te=ee-254;if(ee>264){var se=n[H=ee-257];te=C(e,y,(1<<se)-1)+c[H],y+=se}var re=b[A(e,y)&Z],ie=re>>4;if(re||L(3),y+=15&re,J=p[ie],ie>3&&(se=o[ie],J+=A(e,y)&(1<<se)-1,y+=se),y>M){f&&L(0);break}u&&m(w+131072);var ne=w+te;if(w<J){var oe=l-J,ae=Math.min(J,ne);for(oe+w<0&&L(3);w<ae;++w)r[w]=i[oe+w]}for(;w<ne;++w)r[w]=r[w-J]}}t.l=x,t.p=Q,t.b=w,t.f=g,x&&(g=1,t.m=S,t.d=b,t.n=P)}while(!g);return w!=r.length&&d?T(r,0,w):r.subarray(0,w)},R=function(e,t,s){s<<=7&t;var r=t/8|0;e[r]|=s,e[r+1]|=s>>8},N=function(e,t,s){s<<=7&t;var r=t/8|0;e[r]|=s,e[r+1]|=s>>8,e[r+2]|=s>>16},O=function(e,t){for(var i=[],n=0;n<e.length;++n)e[n]&&i.push({s:n,f:e[n]});var o=i.length,a=i.slice();if(!o)return{t:V,l:0};if(1==o){var h=new s(i[0].s+1);return h[i[0].s]=1,{t:h,l:1}}i.sort(function(e,t){return e.f-t.f}),i.push({s:-1,f:25001});var l=i[0],c=i[1],d=0,u=1,p=2;for(i[0]={s:-1,f:l.f+c.f,l,r:c};u!=o-1;)l=i[i[d].f<i[p].f?d++:p++],c=i[d!=u&&i[d].f<i[p].f?d++:p++],i[u++]={s:-1,f:l.f+c.f,l,r:c};var f=a[0].s;for(n=1;n<o;++n)a[n].s>f&&(f=a[n].s);var m=new r(f+1),g=U(i[u-1],m,0);if(g>t){n=0;var y=0,v=g-t,w=1<<v;for(a.sort(function(e,t){return m[t.s]-m[e.s]||e.f-t.f});n<o;++n){var x=a[n].s;if(!(m[x]>t))break;y+=w-(1<<g-m[x]),m[x]=t}for(y>>=v;y>0;){var b=a[n].s;m[b]<t?y-=1<<t-m[b]++-1:++n}for(;n>=0&&y;--n){var E=a[n].s;m[E]==t&&(--m[E],++y)}g=t}return{t:new s(m),l:g}},U=function(e,t,s){return-1==e.s?Math.max(U(e.l,t,s+1),U(e.r,t,s+1)):t[e.s]=s},B=function(e){for(var t=e.length;t&&!e[--t];);for(var s=new r(++t),i=0,n=e[0],o=1,a=function(e){s[i++]=e},h=1;h<=t;++h)if(e[h]==n&&h!=t)++o;else{if(!n&&o>2){for(;o>138;o-=138)a(32754);o>2&&(a(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(a(n),--o;o>6;o-=6)a(8304);o>2&&(a(o-3<<5|8208),o=0)}for(;o--;)a(n);o=1,n=e[h]}return{c:s.subarray(0,i),n:t}},D=function(e,t){for(var s=0,r=0;r<t.length;++r)s+=e[r]*t[r];return s},j=function(e,t,s){var r=s.length,i=I(t+2);e[i]=255&r,e[i+1]=r>>8,e[i+2]=255^e[i],e[i+3]=255^e[i+1];for(var n=0;n<r;++n)e[i+n+4]=s[n];return 8*(i+4+r)},q=function(e,t,s,i,h,l,c,d,u,p,f){R(t,f++,s),++h[256];for(var m=O(h,15),g=m.t,y=m.l,E=O(l,15),k=E.t,_=E.l,C=B(g),A=C.c,I=C.n,T=B(k),P=T.c,L=T.n,M=new r(19),U=0;U<A.length;++U)++M[31&A[U]];for(U=0;U<P.length;++U)++M[31&P[U]];for(var q=O(M,7),H=q.t,V=q.l,z=19;z>4&&!H[a[z-1]];--z);var F,G,$,K,W=p+5<<3,Y=D(h,w)+D(l,x)+c,J=D(h,g)+D(l,k)+c+14+3*z+D(M,H)+2*M[16]+3*M[17]+7*M[18];if(u>=0&&W<=Y&&W<=J)return j(t,f,e.subarray(u,u+p));if(R(t,f,1+(J<Y)),f+=2,J<Y){F=v(g,y,0),G=g,$=v(k,_,0),K=k;var X=v(H,V,0);for(R(t,f,I-257),R(t,f+5,L-1),R(t,f+10,z-4),f+=14,U=0;U<z;++U)R(t,f+3*U,H[a[U]]);f+=3*z;for(var Z=[A,P],Q=0;Q<2;++Q){var ee=Z[Q];for(U=0;U<ee.length;++U){var te=31&ee[U];R(t,f,X[te]),f+=H[te],te>15&&(R(t,f,ee[U]>>5&127),f+=ee[U]>>12)}}}else F=b,G=w,$=S,K=x;for(U=0;U<d;++U){var se=i[U];if(se>255){N(t,f,F[257+(te=se>>18&31)]),f+=G[te+257],te>7&&(R(t,f,se>>23&31),f+=n[te]);var re=31&se;N(t,f,$[re]),f+=K[re],re>3&&(N(t,f,se>>5&8191),f+=o[re])}else N(t,f,F[se]),f+=G[se]}return N(t,f,F[256]),f+G[256]},H=new i([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),V=new s(0),z=function(e,t,a,h,l,c){var u=c.z||e.length,p=new s(h+u+5*(1+Math.ceil(u/7e3))+l),m=p.subarray(h,p.length-l),g=c.l,y=7&(c.r||0);if(t){y&&(m[0]=c.r>>3);for(var v=H[t-1],w=v>>13,x=8191&v,b=(1<<a)-1,E=c.p||new r(32768),S=c.h||new r(b+1),k=Math.ceil(a/3),_=2*k,C=function(t){return(e[t]^e[t+1]<<k^e[t+2]<<_)&b},A=new i(25e3),P=new r(288),L=new r(32),M=0,R=0,N=c.i||0,O=0,U=c.w||0,B=0;N+2<u;++N){var D=C(N),V=32767&N,z=S[D];if(E[V]=z,S[D]=V,U<=N){var F=u-N;if((M>7e3||O>24576)&&(F>423||!g)){y=q(e,m,0,A,P,L,R,O,B,N-B,y),O=M=R=0,B=N;for(var G=0;G<286;++G)P[G]=0;for(G=0;G<30;++G)L[G]=0}var $=2,K=0,W=x,Y=V-z&32767;if(F>2&&D==C(N-Y))for(var J=Math.min(w,F)-1,X=Math.min(32767,N),Z=Math.min(258,F);Y<=X&&--W&&V!=z;){if(e[N+$]==e[N+$-Y]){for(var Q=0;Q<Z&&e[N+Q]==e[N+Q-Y];++Q);if(Q>$){if($=Q,K=Y,Q>J)break;var ee=Math.min(Y,Q-2),te=0;for(G=0;G<ee;++G){var se=N-Y+G&32767,re=se-E[se]&32767;re>te&&(te=re,z=se)}}}Y+=(V=z)-(z=E[V])&32767}if(K){A[O++]=268435456|d[$]<<18|f[K];var ie=31&d[$],ne=31&f[K];R+=n[ie]+o[ne],++P[257+ie],++L[ne],U=N+$,++M}else A[O++]=e[N],++P[e[N]]}}for(N=Math.max(N,U);N<u;++N)A[O++]=e[N],++P[e[N]];y=q(e,m,g,A,P,L,R,O,B,N-B,y),g||(c.r=7&y|m[y/8|0]<<3,y-=7,c.h=S,c.p=E,c.i=N,c.w=U)}else{for(N=c.w||0;N<u+g;N+=65535){var oe=N+65535;oe>=u&&(m[y/8|0]=g,oe=u),y=j(m,y+1,e.subarray(N,oe))}c.i=u}return T(p,0,h+I(y)+l)},F=function(){for(var e=new Int32Array(256),t=0;t<256;++t){for(var s=t,r=9;--r;)s=(1&s&&-306674912)^s>>>1;e[t]=s}return e}(),G=function(){var e=-1;return{p:function(t){for(var s=e,r=0;r<t.length;++r)s=F[255&s^t[r]]^s>>>8;e=s},d:function(){return~e}}},$=function(e,t,r,i,n){if(!n&&(n={l:1},t.dictionary)){var o=t.dictionary.subarray(-32768),a=new s(o.length+e.length);a.set(o),a.set(e,o.length),e=a,n.w=o.length}return z(e,null==t.level?6:t.level,null==t.mem?n.l?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):20:12+t.mem,r,i,n)},K=function(e,t){var s={};for(var r in e)s[r]=e[r];for(var r in t)s[r]=t[r];return s},W=function(e,t){return e[t]|e[t+1]<<8},Y=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},J=function(e,t){return Y(e,t)+4294967296*Y(e,t+4)},X=function(e,t,s){for(;s;++t)e[t]=s,s>>>=8};function Z(e,t){return $(e,t||{},0,0)}function Q(e,t){return M(e,{i:2},t&&t.out,t&&t.dictionary)}var ee=function(e,t,r,i){for(var n in e){var o=e[n],a=t+n,h=i;Array.isArray(o)&&(h=K(i,o[1]),o=o[0]),ArrayBuffer.isView(o)?r[a]=[o,h]:(r[a+="/"]=[new s(0),h],ee(o,a,r,i))}},te="undefined"!=typeof TextEncoder&&new TextEncoder,se="undefined"!=typeof TextDecoder&&new TextDecoder;try{se.decode(V,{stream:!0})}catch(e){}var re=function(e){for(var t="",s=0;;){var r=e[s++],i=(r>127)+(r>223)+(r>239);if(s+i>e.length)return{s:t,r:T(e,s-1)};i?3==i?(r=((15&r)<<18|(63&e[s++])<<12|(63&e[s++])<<6|63&e[s++])-65536,t+=String.fromCharCode(55296|r>>10,56320|1023&r)):t+=1&i?String.fromCharCode((31&r)<<6|63&e[s++]):String.fromCharCode((15&r)<<12|(63&e[s++])<<6|63&e[s++]):t+=String.fromCharCode(r)}};function ie(e,t){if(t){for(var r=new s(e.length),i=0;i<e.length;++i)r[i]=e.charCodeAt(i);return r}if(te)return te.encode(e);var n=e.length,o=new s(e.length+(e.length>>1)),a=0,h=function(e){o[a++]=e};for(i=0;i<n;++i){if(a+5>o.length){var l=new s(a+8+(n-i<<1));l.set(o),o=l}var c=e.charCodeAt(i);c<128||t?h(c):c<2048?(h(192|c>>6),h(128|63&c)):c>55295&&c<57344?(h(240|(c=65536+(1047552&c)|1023&e.charCodeAt(++i))>>18),h(128|c>>12&63),h(128|c>>6&63),h(128|63&c)):(h(224|c>>12),h(128|c>>6&63),h(128|63&c))}return T(o,0,a)}function ne(e,t){if(t){for(var s="",r=0;r<e.length;r+=16384)s+=String.fromCharCode.apply(null,e.subarray(r,r+16384));return s}if(se)return se.decode(e);var i=re(e),n=i.s;return(s=i.r).length&&L(8),n}var oe=function(e,t){return t+30+W(e,t+26)+W(e,t+28)},ae=function(e,t,s){var r=W(e,t+28),i=W(e,t+30),n=ne(e.subarray(t+46,t+46+r),!(2048&W(e,t+8))),o=t+46+r,a=he(e,o,i,s,Y(e,t+20),Y(e,t+24),Y(e,t+42)),h=a[0],l=a[1],c=a[2];return[W(e,t+10),h,l,n,o+i+W(e,t+32),c]},he=function(e,t,s,r,i,n,o){var a=4294967295==i,h=4294967295==n,l=4294967295==o,c=t+s;if(r&&a+h+l){for(;t+4<c;t+=4+W(e,t+2))if(1==W(e,t))return[a?J(e,t+4+8*h):i,h?J(e,t+4):n,l?J(e,t+4+8*(h+a)):o,1];r<2&&L(13)}return[i,n,o,0]},le=function(e){var t=0;if(e)for(var s in e){var r=e[s].length;r>65535&&L(9),t+=r+4}return t},ce=function(e,t,s,r,i,n,o,a){var h=r.length,l=s.extra,c=a&&a.length,d=le(l);X(e,t,null!=o?33639248:67324752),t+=4,null!=o&&(e[t++]=20,e[t++]=s.os),e[t]=20,t+=2,e[t++]=s.flag<<1|(n<0&&8),e[t++]=i&&8,e[t++]=255&s.compression,e[t++]=s.compression>>8;var u=new Date(null==s.mtime?Date.now():s.mtime),p=u.getFullYear()-1980;if((p<0||p>119)&&L(10),X(e,t,p<<25|u.getMonth()+1<<21|u.getDate()<<16|u.getHours()<<11|u.getMinutes()<<5|u.getSeconds()>>1),t+=4,-1!=n&&(X(e,t,s.crc),X(e,t+4,n<0?-n-2:n),X(e,t+8,s.size)),X(e,t+12,h),X(e,t+14,d),t+=16,null!=o&&(X(e,t,c),X(e,t+6,s.attrs),X(e,t+10,o),t+=14),e.set(r,t),t+=h,d)for(var f in l){var m=l[f],g=m.length;X(e,t,+f),X(e,t+2,g),e.set(m,t+4),t+=4+g}return c&&(e.set(a,t),t+=c),t},de=function(e,t,s,r,i){X(e,t,101010256),X(e,t+8,s),X(e,t+10,s),X(e,t+12,r),X(e,t+16,i)};"function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout&&setTimeout}};const t={};let s=function s(r){const i=t[r];if(void 0!==i)return i.exports;const n=t[r]={exports:{}};return e[r].call(n.exports,n,n.exports,s),n.exports}(44);return s=s.default,s})());