homegames-client 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/homegames-client.js +1 -1
- package/package.json +3 -3
- package/src/game-loader.js +9 -0
- package/src/game-view.js +7 -1
- package/src/index.js +1 -1
- package/src/input.js +29 -6
- package/src/local-game-chrome.js +1 -1
- package/src/local-game-loader.js +1 -0
- package/src/portable-project.js +3 -0
package/dist/homegames-client.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see homegames-client.js.LICENSE.txt */
|
|
2
|
-
!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,78,5,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,199,7,137,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,55,9,266,3,10,1,2,0,49,6,4,4,14,10,5350,0,7,14,11465,27,2343,9,87,9,39,4,60,6,26,9,535,9,470,0,2,54,8,3,82,0,12,1,19628,1,4178,9,519,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,233,0,3,0,8,1,6,0,475,6,110,6,6,9,4759,9,787719,239],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,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,7,25,39,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,5,57,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,31,9,2,0,3,0,2,37,2,0,26,0,2,0,45,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,200,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,24,43,261,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,33,24,3,24,45,74,6,0,67,12,65,1,2,0,15,4,10,7381,42,31,98,114,8702,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,208,30,2,2,2,1,2,6,3,4,10,1,225,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4381,3,5773,3,7472,16,621,2467,541,1507,4938,6,8489],r="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽ-ೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-Ა-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ--ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",n={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"},i="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:i,"5module":i+" export import",6:i+" 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 g={beforeExpr:!0},m={startsExpr:!0},y={};function x(e,t){return void 0===t&&(t={}),t.keyword=e,y[e]=new p(e,t)}var v={num:new p("num",m),regexp:new p("regexp",m),string:new p("string",m),name:new p("name",m),privateId:new p("privateId",m),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(",",g),semi:new p(";",g),colon:new p(":",g),dot:new p("."),question:new p("?",g),questionDot:new p("?."),arrow:new p("=>",g),template:new p("template"),invalidTemplate:new p("invalidTemplate"),ellipsis:new p("...",g),backQuote:new p("`",m),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:x("break"),_case:x("case",g),_catch:x("catch"),_continue:x("continue"),_debugger:x("debugger"),_default:x("default",g),_do:x("do",{isLoop:!0,beforeExpr:!0}),_else:x("else",g),_finally:x("finally"),_for:x("for",{isLoop:!0}),_function:x("function",m),_if:x("if"),_return:x("return",g),_switch:x("switch"),_throw:x("throw",g),_try:x("try"),_var:x("var"),_const:x("const"),_while:x("while",{isLoop:!0}),_with:x("with"),_new:x("new",{beforeExpr:!0,startsExpr:!0}),_this:x("this",m),_super:x("super",m),_class:x("class",m),_extends:x("extends",g),_export:x("export"),_import:x("import",m),_null:x("null",m),_true:x("true",m),_false:x("false",m),_in:x("in",{beforeExpr:!0,binop:7}),_instanceof:x("instanceof",{beforeExpr:!0,binop:7}),_typeof:x("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:x("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:x("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},w=/\r\n?|\n|\u2028|\u2029/,b=new RegExp(w.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 n=e.charCodeAt(r);if(E(n))return r<s-1&&13===n&&10===e.charCodeAt(r+1)?r+2:r+1}return-1}var _=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,C=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,A=Object.prototype,k=A.hasOwnProperty,I=A.toString,T=Object.hasOwn||function(e,t){return k.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 O=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,N=function(e,t){this.line=e,this.column=t};N.prototype.offset=function(e){return new N(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 n=S(e,r,t);if(n<0)return new N(s,t-r);++s,r=n}}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,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},q=!1;function H(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?(!q&&"object"==typeof console&&console.warn&&(q=!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,n,i,o,a){var h={type:s?"Block":"Line",value:r,start:n,end:i};e.locations&&(h.loc=new U(this,o,a)),e.ranges&&(h.range=[n,i]),t.push(h)}}(t,t.onComment)),"commonjs"===t.sourceType&&t.allowAwaitOutsideFunction)throw new Error("Cannot use allowAwaitOutsideFunction with sourceType: commonjs");return t}var j=256,$=259;function G(e,t){return 2|(e?4:0)|(t?8:0)}var V=function(e,t,s){this.options=e=H(e),this.sourceFile=e.sourceFile,this.keywords=M(o[e.ecmaVersion>=6?6:"module"===e.sourceType?"5module":5]);var r="";!0!==e.allowReserved&&(r=n[e.ecmaVersion>=6?6:5===e.ecmaVersion?5:3],"module"===e.sourceType&&(r+=" await")),this.reservedWords=M(r);var i=(r?r+" ":"")+n.strict;this.reservedWordsStrict=M(i),this.reservedWordsStrictBind=M(i+" "+n.strictBind),this.input=String(t),this.containsEsc=!1,s?(this.pos=s,this.lineStart=this.input.lastIndexOf("\n",s-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(w).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=v.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=[]},F={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowReturn:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},allowUsing:{configurable:!0},inClassStaticBlock:{configurable:!0}};V.prototype.parse=function(){var e=this,t=this.options.program||this.startNode();return this.nextToken(),this.catchStackOverflow(function(){return e.parseTopLevel(t)})},F.inFunction.get=function(){return(2&this.currentVarScope().flags)>0},F.inGenerator.get=function(){return(8&this.currentVarScope().flags)>0},F.inAsync.get=function(){return(4&this.currentVarScope().flags)>0},F.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},F.allowReturn.get=function(){return!!this.inFunction||!!(this.options.allowReturnOutsideFunction&&1&this.currentVarScope().flags)},F.allowSuper.get=function(){return(64&this.currentThisScope().flags)>0||this.options.allowSuperOutsideMethod},F.allowDirectSuper.get=function(){return(128&this.currentThisScope().flags)>0},F.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())},F.allowNewDotTarget.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(768&t||2&t&&!(16&t))return!0}return!1},F.allowUsing.get=function(){var e=this.currentScope().flags;return!(1024&e||!this.inModule&&1&e)},F.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&j)>0},V.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},V.parse=function(e,t){return new this(t,e).parse()},V.parseExpressionAt=function(e,t,s){var r=new this(s,e,t);return r.nextToken(),r.parseExpression()},V.tokenizer=function(e,t){return new this(t,e)},Object.defineProperties(V.prototype,F);var z=V.prototype,Y=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;z.strictDirective=function(e){if(this.options.ecmaVersion<5)return!1;for(;;){C.lastIndex=e,e+=C.exec(this.input)[0].length;var t=Y.exec(this.input.slice(e));if(!t)return!1;if("use strict"===(t[1]||t[2])){C.lastIndex=e+t[0].length;var s=C.exec(this.input),r=s.index+s[0].length,n=this.input.charAt(r);return";"===n||"}"===n||w.test(s[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(n)||"!"===n&&"="===this.input.charAt(r+1))}e+=t[0].length,C.lastIndex=e,e+=C.exec(this.input)[0].length,";"===this.input[e]&&e++}},z.eat=function(e){return this.type===e&&(this.next(),!0)},z.isContextual=function(e){return this.type===v.name&&this.value===e&&!this.containsEsc},z.eatContextual=function(e){return!!this.isContextual(e)&&(this.next(),!0)},z.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")}},z.expectContextual=function(e){this.eatContextual(e)||this.unexpected()},z.canInsertSemicolon=function(){return this.type===v.eof||this.type===v.braceR||w.test(this.input.slice(this.lastTokEnd,this.start))},z.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},z.semicolon=function(){this.eat(v.semi)||this.insertSemicolon()||this.unexpected()},z.afterTrailingComma=function(e,t){if(this.type===e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),t||this.next(),!0},z.expect=function(e){this.eat(e)||this.unexpected()},z.unexpected=function(e){this.raise(null!=e?e:this.start,"Unexpected token")};var K=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};z.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")}},z.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")},z.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")},z.isSimpleAssignTarget=function(e){return"ParenthesizedExpression"===e.type?this.isSimpleAssignTarget(e.expression):"Identifier"===e.type||"MemberExpression"===e.type};var W=V.prototype;W.parseTopLevel=function(e){var t=Object.create(null);for(e.body||(e.body=[]);this.type!==v.eof;){var s=this.parseStatement(null,!0,t);e.body.push(s)}if(this.inModule)for(var r=0,n=Object.keys(this.undefinedExports);r<n.length;r+=1){var i=n[r];this.raiseRecoverable(this.undefinedExports[i].start,"Export '"+i+"' 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 J={kind:"loop"},X={kind:"switch"};W.isLet=function(e){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;C.lastIndex=this.pos;var t=C.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 n=s;do{s+=r<=65535?1:2}while(u(r=this.fullCharCodeAt(s)));if(92===r)return!0;var i=this.input.slice(n,s);if(!a.test(i))return!0}return!1},W.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;C.lastIndex=this.pos;var e,t=C.exec(this.input),s=this.pos+t[0].length;return!(w.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))},W.isUsingKeyword=function(e,t){if(this.options.ecmaVersion<17||!this.isContextual(e?"await":"using"))return!1;C.lastIndex=this.pos;var s=C.exec(this.input),r=this.pos+s[0].length;if(w.test(this.input.slice(this.pos,r)))return!1;if(e){var n,i=r+5;if("using"!==this.input.slice(r,i)||i===this.input.length||u(n=this.fullCharCodeAt(i))||92===n)return!1;C.lastIndex=i;var o=C.exec(this.input);if(r=i+o[0].length,o&&w.test(this.input.slice(i,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&&(C.lastIndex=r,r+=C.exec(this.input)[0].length,61!==this.input.charCodeAt(r)||61===(h=this.input.charCodeAt(r+1))||62===h))},W.isAwaitUsing=function(e){return this.isUsingKeyword(!0,e)},W.isUsing=function(e){return this.isUsingKeyword(!1,e)},W.parseStatement=function(e,t,s){var r,n=this.type,i=this.startNode();switch(this.isLet(e)&&(n=v._var,r="let"),n){case v._break:case v._continue:return this.parseBreakContinueStatement(i,n.keyword);case v._debugger:return this.parseDebuggerStatement(i);case v._do:return this.parseDoStatement(i);case v._for:return this.parseForStatement(i);case v._function:return e&&(this.strict||"if"!==e&&"label"!==e)&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(i,!1,!e);case v._class:return e&&this.unexpected(),this.parseClass(i,!0);case v._if:return this.parseIfStatement(i);case v._return:return this.parseReturnStatement(i);case v._switch:return this.parseSwitchStatement(i);case v._throw:return this.parseThrowStatement(i);case v._try:return this.parseTryStatement(i);case v._const:case v._var:return r=r||this.value,e&&"var"!==r&&this.unexpected(),this.parseVarStatement(i,r);case v._while:return this.parseWhileStatement(i);case v._with:return this.parseWithStatement(i);case v.braceL:return this.parseBlock(!0,i);case v.semi:return this.parseEmptyStatement(i);case v._export:case v._import:if(this.options.ecmaVersion>10&&n===v._import){C.lastIndex=this.pos;var o=C.exec(this.input),a=this.pos+o[0].length,h=this.input.charCodeAt(a);if(40===h||46===h)return this.parseExpressionStatement(i,this.parseExpression())}return this.options.allowImportExportEverywhere||(t||this.raise(this.start,"'import' and 'export' may only appear at the top level"),this.inModule||this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")),n===v._import?this.parseImport(i):this.parseExport(i,s);default:if(this.isAsyncFunction())return e&&this.unexpected(),this.next(),this.parseFunctionStatement(i,!0,!e);var l=this.isAwaitUsing(!1)?"await using":this.isUsing(!1)?"using":null;if(l)return this.allowUsing||this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script` or in the bare case statement"),e&&this.raise(this.start,"Using declaration is not allowed in single-statement positions"),"await using"===l&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.next(),this.parseVar(i,!1,l),this.semicolon(),this.finishNode(i,"VariableDeclaration");var c=this.value,d=this.parseExpression();return n===v.name&&"Identifier"===d.type&&this.eat(v.colon)?this.parseLabeledStatement(i,c,d,e):this.parseExpressionStatement(i,d)}},W.parseBreakContinueStatement=function(e,t){var s="break"===t;this.next(),this.eat(v.semi)||this.insertSemicolon()?e.label=null:this.type!==v.name?this.unexpected():(e.label=this.parseIdent(),this.semicolon());for(var r=0;r<this.labels.length;++r){var n=this.labels[r];if(null==e.label||n.name===e.label.name){if(null!=n.kind&&(s||"loop"===n.kind))break;if(e.label&&s)break}}return r===this.labels.length&&this.raise(e.start,"Unsyntactic "+t),this.finishNode(e,s?"BreakStatement":"ContinueStatement")},W.parseDebuggerStatement=function(e){return this.next(),this.semicolon(),this.finishNode(e,"DebuggerStatement")},W.parseDoStatement=function(e){return this.next(),this.labels.push(J),e.body=this.parseStatement("do"),this.labels.pop(),this.expect(v._while),e.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(v.semi):this.semicolon(),this.finishNode(e,"DoWhileStatement")},W.parseForStatement=function(e){this.next();var t=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(J),this.enterScope(0),this.expect(v.parenL),this.type===v.semi)return t>-1&&this.unexpected(t),this.parseFor(e,null);var s=this.isLet();if(this.type===v._var||this.type===v._const||s){var r=this.startNode(),n=s?"let":this.value;return this.next(),this.parseVar(r,!0,n),this.finishNode(r,"VariableDeclaration"),this.parseForAfterInit(e,r,t)}var i=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 K,d=this.start,u=t>-1?this.parseExprSubscripts(c,"await"):this.parseExpression(!0,c);return this.type===v._in||(o=this.options.ecmaVersion>=6&&this.isContextual("of"))?(t>-1?(this.type===v._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()),i&&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))},W.parseForAfterInit=function(e,t,s){return(this.type===v._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&1===t.declarations.length?(this.type===v._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))},W.parseFunctionStatement=function(e,t,s){return this.next(),this.parseFunction(e,Z|(s?0:ee),!1,t)},W.parseIfStatement=function(e){return this.next(),e.test=this.parseParenExpression(),e.consequent=this.parseStatement("if"),e.alternate=this.eat(v._else)?this.parseStatement("if"):null,this.finishNode(e,"IfStatement")},W.parseReturnStatement=function(e){return this.allowReturn||this.raise(this.start,"'return' outside of function"),this.next(),this.eat(v.semi)||this.insertSemicolon()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,"ReturnStatement")},W.parseSwitchStatement=function(e){var t;this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(v.braceL),this.labels.push(X),this.enterScope(1024);for(var s=!1;this.type!==v.braceR;)if(this.type===v._case||this.type===v._default){var r=this.type===v._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(v.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")},W.parseThrowStatement=function(e){return this.next(),w.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=[];W.parseCatchClauseParam=function(){var e=this.parseBindingAtom(),t="Identifier"===e.type;return this.enterScope(t?32:0),this.checkLValPattern(e,t?4:2),this.expect(v.parenR),e},W.parseTryStatement=function(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.type===v._catch){var t=this.startNode();this.next(),this.eat(v.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(v._finally)?this.parseBlock():null,e.handler||e.finalizer||this.raise(e.start,"Missing catch or finally clause"),this.finishNode(e,"TryStatement")},W.parseVarStatement=function(e,t,s){return this.next(),this.parseVar(e,!1,t,s),this.semicolon(),this.finishNode(e,"VariableDeclaration")},W.parseWhileStatement=function(e){return this.next(),e.test=this.parseParenExpression(),this.labels.push(J),e.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(e,"WhileStatement")},W.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")},W.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,"EmptyStatement")},W.parseLabeledStatement=function(e,t,s,r){for(var n=0,i=this.labels;n<i.length;n+=1)i[n].name===t&&this.raise(s.start,"Label '"+t+"' is already declared");for(var o=this.type.isLoop?"loop":this.type===v._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")},W.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,"ExpressionStatement")},W.parseBlock=function(e,t,s){for(void 0===e&&(e=!0),void 0===t&&(t=this.startNode()),t.body=[],this.expect(v.braceL),e&&this.enterScope(0);this.type!==v.braceR;){var r=this.parseStatement(null);t.body.push(r)}return s&&(this.strict=!1),this.next(),e&&this.exitScope(),this.finishNode(t,"BlockStatement")},W.parseFor=function(e,t){return e.init=t,this.expect(v.semi),e.test=this.type===v.semi?null:this.parseExpression(),this.expect(v.semi),e.update=this.type===v.parenR?null:this.parseExpression(),this.expect(v.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,"ForStatement")},W.parseForIn=function(e,t){var s=this.type===v._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(v.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,s?"ForInStatement":"ForOfStatement")},W.parseVar=function(e,t,s,r){for(e.declarations=[],e.kind=s;;){var n=this.startNode();if(this.parseVarId(n,s),this.eat(v.eq)?n.init=this.parseMaybeAssign(t):r||"const"!==s||this.type===v._in||this.options.ecmaVersion>=6&&this.isContextual("of")?r||"using"!==s&&"await using"!==s||!(this.options.ecmaVersion>=17)||this.type===v._in||this.isContextual("of")?r||"Identifier"===n.id.type||t&&(this.type===v._in||this.isContextual("of"))?n.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(n,"VariableDeclarator")),!this.eat(v.comma))break}return e},W.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 Z=1,ee=2;function te(e,t){var s=t.key.name,r=e[s],n="true";return"MethodDefinition"!==t.type||"get"!==t.kind&&"set"!==t.kind||(n=(t.static?"s":"i")+t.kind),"iget"===r&&"iset"===n||"iset"===r&&"iget"===n||"sget"===r&&"sset"===n||"sset"===r&&"sget"===n?(e[s]="true",!1):!!r||(e[s]=n,!1)}function se(e,t){var s=e.computed,r=e.key;return!s&&("Identifier"===r.type&&r.name===t||"Literal"===r.type&&r.value===t)}W.parseFunction=function(e,t,s,r,n){this.initFunction(e),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!r)&&(this.type===v.star&&t&ee&&this.unexpected(),e.generator=this.eat(v.star)),this.options.ecmaVersion>=8&&(e.async=!!r),t&Z&&(e.id=4&t&&this.type!==v.name?null:this.parseIdent(),!e.id||t&ee||this.checkLValSimple(e.id,this.strict||e.generator||e.async?this.treatFunctionsAsVar?1:2:3));var i=this.yieldPos,o=this.awaitPos,a=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(G(e.async,e.generator)),t&Z||(e.id=this.type===v.name?this.parseIdent():null),this.parseFunctionParams(e),this.parseFunctionBody(e,s,!1,n),this.yieldPos=i,this.awaitPos=o,this.awaitIdentPos=a,this.finishNode(e,t&Z?"FunctionDeclaration":"FunctionExpression")},W.parseFunctionParams=function(e){this.expect(v.parenL),e.params=this.parseBindingList(v.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},W.parseClass=function(e,t){this.next();var s=this.strict;this.strict=!0,this.parseClassId(e,t),this.parseClassSuper(e);var r=this.enterClassBody(),n=this.startNode(),i=!1;for(n.body=[],this.expect(v.braceL);this.type!==v.braceR;){var o=this.parseClassElement(null!==e.superClass);o&&(n.body.push(o),"MethodDefinition"===o.type&&"constructor"===o.kind?(i&&this.raiseRecoverable(o.start,"Duplicate constructor in the same class"),i=!0):o.key&&"PrivateIdentifier"===o.key.type&&te(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(n,"ClassBody"),this.exitClassBody(),this.finishNode(e,t?"ClassDeclaration":"ClassExpression")},W.parseClassElement=function(e){if(this.eat(v.semi))return null;var t=this.options.ecmaVersion,s=this.startNode(),r="",n=!1,i=!1,o="method",a=!1;if(this.eatContextual("static")){if(t>=13&&this.eat(v.braceL))return this.parseClassStaticBlock(s),s;this.isClassElementNameStart()||this.type===v.star?a=!0:r="static"}if(s.static=a,!r&&t>=8&&this.eatContextual("async")&&(!this.isClassElementNameStart()&&this.type!==v.star||this.canInsertSemicolon()?r="async":i=!0),!r&&(t>=9||!i)&&this.eat(v.star)&&(n=!0),!r&&!i&&!n){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===v.parenL||"method"!==o||n||i){var l=!s.static&&se(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,n,i,c)}else this.parseClassField(s);return s},W.isClassElementNameStart=function(){return this.type===v.name||this.type===v.privateId||this.type===v.num||this.type===v.string||this.type===v.bracketL||this.type.keyword},W.parseClassElementName=function(e){this.type===v.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)},W.parseClassMethod=function(e,t,s,r){var n=e.key;"constructor"===e.kind?(t&&this.raise(n.start,"Constructor can't be a generator"),s&&this.raise(n.start,"Constructor can't be an async method")):e.static&&se(e,"prototype")&&this.raise(n.start,"Classes may not have a static property named prototype");var i=e.value=this.parseMethod(t,s,r);return"get"===e.kind&&0!==i.params.length&&this.raiseRecoverable(i.start,"getter should have no params"),"set"===e.kind&&1!==i.params.length&&this.raiseRecoverable(i.start,"setter should have exactly one param"),"set"===e.kind&&"RestElement"===i.params[0].type&&this.raiseRecoverable(i.params[0].start,"Setter cannot use rest params"),this.finishNode(e,"MethodDefinition")},W.parseClassField=function(e){return se(e,"constructor")?this.raise(e.key.start,"Classes can't have a field named 'constructor'"):e.static&&se(e,"prototype")&&this.raise(e.key.start,"Classes can't have a static field named 'prototype'"),this.eat(v.eq)?(this.enterScope(576),e.value=this.parseMaybeAssign(),this.exitScope()):e.value=null,this.semicolon(),this.finishNode(e,"PropertyDefinition")},W.parseClassStaticBlock=function(e){e.body=[];var t=this.labels;for(this.labels=[],this.enterScope(320);this.type!==v.braceR;){var s=this.parseStatement(null);e.body.push(s)}return this.next(),this.exitScope(),this.labels=t,this.finishNode(e,"StaticBlock")},W.parseClassId=function(e,t){this.type===v.name?(e.id=this.parseIdent(),t&&this.checkLValSimple(e.id,2,!1)):(!0===t&&this.unexpected(),e.id=null)},W.parseClassSuper=function(e){e.superClass=this.eat(v._extends)?this.parseExprSubscripts(null,!1):null},W.enterClassBody=function(){var e={declared:Object.create(null),used:[]};return this.privateNameStack.push(e),e.declared},W.exitClassBody=function(){var e=this.privateNameStack.pop(),t=e.declared,s=e.used;if(this.options.checkPrivateFields)for(var r=this.privateNameStack.length,n=0===r?null:this.privateNameStack[r-1],i=0;i<s.length;++i){var o=s[i];T(t,o.name)||(n?n.used.push(o):this.raiseRecoverable(o.start,"Private field '#"+o.name+"' must be declared in an enclosing class"))}},W.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!==v.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ExportAllDeclaration")},W.parseExport=function(e,t){if(this.next(),this.eat(v.star))return this.parseExportAllDeclaration(e,t);if(this.eat(v._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!==v.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 n=r[s];this.checkUnreserved(n.local),this.checkLocalExport(n.local),"Literal"===n.local.type&&this.raise(n.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")},W.parseExportDeclaration=function(e){return this.parseStatement(null)},W.parseExportDefaultDeclaration=function(){var e;if(this.type===v._function||(e=this.isAsyncFunction())){var t=this.startNode();return this.next(),e&&this.next(),this.parseFunction(t,4|Z,!1,e)}if(this.type===v._class){var s=this.startNode();return this.parseClass(s,"nullableID")}var r=this.parseMaybeAssign();return this.semicolon(),r},W.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)},W.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,n=t.properties;r<n.length;r+=1){var i=n[r];this.checkPatternExport(e,i)}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)},W.checkVariableExport=function(e,t){if(e)for(var s=0,r=t;s<r.length;s+=1){var n=r[s];this.checkPatternExport(e,n.id)}},W.shouldParseExportStatement=function(){return"var"===this.type.keyword||"const"===this.type.keyword||"class"===this.type.keyword||"function"===this.type.keyword||this.isLet()||this.isAsyncFunction()},W.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")},W.parseExportSpecifiers=function(e){var t=[],s=!0;for(this.expect(v.braceL);!this.eat(v.braceR);){if(s)s=!1;else if(this.expect(v.comma),this.afterTrailingComma(v.braceR))break;t.push(this.parseExportSpecifier(e))}return t},W.parseImport=function(e){return this.next(),this.type===v.string?(e.specifiers=Q,e.source=this.parseExprAtom()):(e.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),e.source=this.type===v.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ImportDeclaration")},W.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")},W.parseImportDefaultSpecifier=function(){var e=this.startNode();return e.local=this.parseIdent(),this.checkLValSimple(e.local,2),this.finishNode(e,"ImportDefaultSpecifier")},W.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")},W.parseImportSpecifiers=function(){var e=[],t=!0;if(this.type===v.name&&(e.push(this.parseImportDefaultSpecifier()),!this.eat(v.comma)))return e;if(this.type===v.star)return e.push(this.parseImportNamespaceSpecifier()),e;for(this.expect(v.braceL);!this.eat(v.braceR);){if(t)t=!1;else if(this.expect(v.comma),this.afterTrailingComma(v.braceR))break;e.push(this.parseImportSpecifier())}return e},W.parseWithClause=function(){var e=[];if(!this.eat(v._with))return e;this.expect(v.braceL);for(var t={},s=!0;!this.eat(v.braceR);){if(s)s=!1;else if(this.expect(v.comma),this.afterTrailingComma(v.braceR))break;var r=this.parseImportAttribute(),n="Identifier"===r.key.type?r.key.name:r.key.value;T(t,n)&&this.raiseRecoverable(r.key.start,"Duplicate attribute key '"+n+"'"),t[n]=!0,e.push(r)}return e},W.parseImportAttribute=function(){var e=this.startNode();return e.key=this.type===v.string?this.parseExprAtom():this.parseIdent("never"!==this.options.allowReserved),this.expect(v.colon),this.type!==v.string&&this.unexpected(),e.value=this.parseExprAtom(),this.finishNode(e,"ImportAttribute")},W.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===v.string){var e=this.parseLiteral(this.value);return O.test(e.value)&&this.raise(e.start,"An export name cannot include a lone surrogate."),e}return this.parseIdent(!0)},W.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)},W.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 re=V.prototype;re.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,n=e.properties;r<n.length;r+=1){var i=n[r];this.toAssignable(i,t),"RestElement"!==i.type||"ArrayPattern"!==i.argument.type&&"ObjectPattern"!==i.argument.type||this.raise(i.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},re.toAssignableList=function(e,t){for(var s=e.length,r=0;r<s;r++){var n=e[r];n&&this.toAssignable(n,t)}if(s){var i=e[s-1];6===this.options.ecmaVersion&&t&&i&&"RestElement"===i.type&&"Identifier"!==i.argument.type&&this.unexpected(i.argument.start)}return e},re.parseSpread=function(e){var t=this.startNode();return this.next(),t.argument=this.parseMaybeAssign(!1,e),this.finishNode(t,"SpreadElement")},re.parseRestBinding=function(){var e=this.startNode();return this.next(),6===this.options.ecmaVersion&&this.type!==v.name&&this.unexpected(),e.argument=this.parseBindingAtom(),this.finishNode(e,"RestElement")},re.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case v.bracketL:var e=this.startNode();return this.next(),e.elements=this.parseBindingList(v.bracketR,!0,!0),this.finishNode(e,"ArrayPattern");case v.braceL:return this.parseObj(!0)}return this.parseIdent()},re.parseBindingList=function(e,t,s,r){for(var n=[],i=!0;!this.eat(e);)if(i?i=!1:this.expect(v.comma),t&&this.type===v.comma)n.push(null);else{if(s&&this.afterTrailingComma(e))break;if(this.type===v.ellipsis){var o=this.parseRestBinding();this.parseBindingListItem(o),n.push(o),this.type===v.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.expect(e);break}n.push(this.parseAssignableListItem(r))}return n},re.parseAssignableListItem=function(e){var t=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(t),t},re.parseBindingListItem=function(e){return e},re.parseMaybeDefault=function(e,t,s){if(s=s||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(v.eq))return s;var r=this.startNodeAt(e,t);return r.left=s,r.right=this.parseMaybeAssign(),this.finishNode(r,"AssignmentPattern")},re.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")}},re.checkLValPattern=function(e,t,s){switch(void 0===t&&(t=0),e.type){case"ObjectPattern":for(var r=0,n=e.properties;r<n.length;r+=1){var i=n[r];this.checkLValInnerPattern(i,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)}},re.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,n){this.token=e,this.isExpr=!!t,this.preserveSpace=!!s,this.override=r,this.generator=!!n},ie={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)},oe=V.prototype;oe.initialContext=function(){return[ie.b_stat]},oe.curContext=function(){return this.context[this.context.length-1]},oe.braceIsBlock=function(e){var t=this.curContext();return t===ie.f_expr||t===ie.f_stat||(e!==v.colon||t!==ie.b_stat&&t!==ie.b_expr?e===v._return||e===v.name&&this.exprAllowed?w.test(this.input.slice(this.lastTokEnd,this.start)):e===v._else||e===v.semi||e===v.eof||e===v.parenR||e===v.arrow||(e===v.braceL?t===ie.b_stat:e!==v._var&&e!==v._const&&e!==v.name&&!this.exprAllowed):!t.isExpr)},oe.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},oe.updateContext=function(e){var t,s=this.type;s.keyword&&e===v.dot?this.exprAllowed=!1:(t=s.updateContext)?t.call(this,e):this.exprAllowed=s.beforeExpr},oe.overrideContext=function(e){this.curContext()!==e&&(this.context[this.context.length-1]=e)},v.parenR.updateContext=v.braceR.updateContext=function(){if(1!==this.context.length){var e=this.context.pop();e===ie.b_stat&&"function"===this.curContext().token&&(e=this.context.pop()),this.exprAllowed=!e.isExpr}else this.exprAllowed=!0},v.braceL.updateContext=function(e){this.context.push(this.braceIsBlock(e)?ie.b_stat:ie.b_expr),this.exprAllowed=!0},v.dollarBraceL.updateContext=function(){this.context.push(ie.b_tmpl),this.exprAllowed=!0},v.parenL.updateContext=function(e){var t=e===v._if||e===v._for||e===v._with||e===v._while;this.context.push(t?ie.p_stat:ie.p_expr),this.exprAllowed=!0},v.incDec.updateContext=function(){},v._function.updateContext=v._class.updateContext=function(e){!e.beforeExpr||e===v._else||e===v.semi&&this.curContext()!==ie.p_stat||e===v._return&&w.test(this.input.slice(this.lastTokEnd,this.start))||(e===v.colon||e===v.braceL)&&this.curContext()===ie.b_stat?this.context.push(ie.f_stat):this.context.push(ie.f_expr),this.exprAllowed=!1},v.colon.updateContext=function(){"function"===this.curContext().token&&this.context.pop(),this.exprAllowed=!0},v.backQuote.updateContext=function(){this.curContext()===ie.q_tmpl?this.context.pop():this.context.push(ie.q_tmpl),this.exprAllowed=!1},v.star.updateContext=function(e){if(e===v._function){var t=this.context.length-1;this.context[t]===ie.f_expr?this.context[t]=ie.f_expr_gen:this.context[t]=ie.f_gen}this.exprAllowed=!0},v.name.updateContext=function(e){var t=!1;this.options.ecmaVersion>=6&&e!==v.dot&&("of"===this.value&&!this.exprAllowed||"yield"===this.value&&this.inGeneratorContext())&&(t=!0),this.exprAllowed=t};var ae=V.prototype;function he(e){return"Identifier"===e.type||"ParenthesizedExpression"===e.type&&he(e.expression)}function le(e){return"MemberExpression"===e.type&&"PrivateIdentifier"===e.property.type||"ChainExpression"===e.type&&le(e.expression)||"ParenthesizedExpression"===e.type&&le(e.expression)}ae.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,n=e.key;switch(n.type){case"Identifier":r=n.name;break;case"Literal":r=String(n.value);break;default:return}var i=e.kind;if(this.options.ecmaVersion>=6)"__proto__"===r&&"init"===i&&(t.proto&&(s?s.doubleProto<0&&(s.doubleProto=n.start):this.raiseRecoverable(n.start,"Redefinition of __proto__ property")),t.proto=!0);else{var o=t[r="$"+r];o?("init"===i?this.strict&&o.init||o.get||o.set:o.init||o[i])&&this.raiseRecoverable(n.start,"Redefinition of property"):o=t[r]={init:!1,get:!1,set:!1},o[i]=!0}}},ae.parseExpression=function(e,t){var s=this;return this.catchStackOverflow(function(){var r=s.start,n=s.startLoc,i=s.parseMaybeAssign(e,t);if(s.type===v.comma){var o=s.startNodeAt(r,n);for(o.expressions=[i];s.eat(v.comma);)o.expressions.push(s.parseMaybeAssign(e,t));return s.finishNode(o,"SequenceExpression")}return i})},ae.parseMaybeAssign=function(e,t,s){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(e);this.exprAllowed=!1}var r=!1,n=-1,i=-1,o=-1;t?(n=t.parenthesizedAssign,i=t.trailingComma,o=t.doubleProto,t.parenthesizedAssign=t.trailingComma=-1):(t=new K,r=!0);var a=this.start,h=this.startLoc;this.type!==v.parenL&&this.type!==v.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===v.eq&&(l=this.toAssignable(l,!1,t)),r||(t.parenthesizedAssign=t.trailingComma=t.doubleProto=-1),t.shorthandAssign>=l.start&&(t.shorthandAssign=-1),this.type===v.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),n>-1&&(t.parenthesizedAssign=n),i>-1&&(t.trailingComma=i),l},ae.parseMaybeConditional=function(e,t){var s=this.start,r=this.startLoc,n=this.parseExprOps(e,t);if(this.checkExpressionErrors(t))return n;if(("ArrowFunctionExpression"!==n.type||n.start!==s)&&this.eat(v.question)){var i=this.startNodeAt(s,r);return i.test=n,i.consequent=this.parseMaybeAssign(),this.expect(v.colon),i.alternate=this.parseMaybeAssign(e),this.finishNode(i,"ConditionalExpression")}return n},ae.parseExprOps=function(e,t){var s=this.start,r=this.startLoc,n=this.parseMaybeUnary(t,!1,!1,e);return this.checkExpressionErrors(t)||n.start===s&&"ArrowFunctionExpression"===n.type?n:this.parseExprOp(n,s,r,-1,e)},ae.parseExprOp=function(e,t,s,r,n){var i=this.type.binop;if(null!=i&&(!n||this.type!==v._in)&&i>r){var o=this.type===v.logicalOR||this.type===v.logicalAND,a=this.type===v.coalesce;a&&(i=v.logicalAND.binop);var h=this.value;this.next();var l=this.start,c=this.startLoc,d=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,n),l,c,i,n),u=this.buildBinary(t,s,e,d,h,o||a);return(o&&this.type===v.coalesce||a&&(this.type===v.logicalOR||this.type===v.logicalAND))&&this.raiseRecoverable(this.start,"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"),this.parseExprOp(u,t,s,r,n)}return e},ae.buildBinary=function(e,t,s,r,n,i){"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=n,o.right=r,this.finishNode(o,i?"LogicalExpression":"BinaryExpression")},ae.parseMaybeUnary=function(e,t,s,r){var n,i=this.start,o=this.startLoc;if(this.isContextual("await")&&this.canAwait)n=this.parseAwait(r),t=!0;else if(this.type.prefix){var a=this.startNode(),h=this.type===v.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&&he(a.argument)?this.raiseRecoverable(a.start,"Deleting local variable in strict mode"):"delete"===a.operator&&le(a.argument)?this.raiseRecoverable(a.start,"Private fields can not be deleted"):t=!0,n=this.finishNode(a,h?"UpdateExpression":"UnaryExpression")}else if(t||this.type!==v.privateId){if(n=this.parseExprSubscripts(e,r),this.checkExpressionErrors(e))return n;for(;this.type.postfix&&!this.canInsertSemicolon();){var l=this.startNodeAt(i,o);l.operator=this.value,l.prefix=!1,l.argument=n,this.checkLValSimple(n),this.next(),n=this.finishNode(l,"UpdateExpression")}}else(r||0===this.privateNameStack.length)&&this.options.checkPrivateFields&&this.unexpected(),n=this.parsePrivateIdent(),this.type!==v._in&&this.unexpected();return s||!this.eat(v.starstar)?n:t?void this.unexpected(this.lastTokStart):this.buildBinary(i,o,n,this.parseMaybeUnary(null,!1,!1,r),"**",!1)},ae.parseExprSubscripts=function(e,t){var s=this.start,r=this.startLoc,n=this.parseExprAtom(e,t);if("ArrowFunctionExpression"===n.type&&")"!==this.input.slice(this.lastTokStart,this.lastTokEnd))return n;var i=this.parseSubscripts(n,s,r,!1,t);return e&&"MemberExpression"===i.type&&(e.parenthesizedAssign>=i.start&&(e.parenthesizedAssign=-1),e.parenthesizedBind>=i.start&&(e.parenthesizedBind=-1),e.trailingComma>=i.start&&(e.trailingComma=-1)),i},ae.parseSubscripts=function(e,t,s,r,n){for(var i=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,i,o,n);if(a.optional&&(o=!0),a===e||"ArrowFunctionExpression"===a.type){if(o){var h=this.startNodeAt(t,s);h.expression=a,a=this.finishNode(h,"ChainExpression")}return a}e=a}},ae.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(v.arrow)},ae.parseSubscriptAsyncArrow=function(e,t,s,r){return this.parseArrowExpression(this.startNodeAt(e,t),s,!0,r)},ae.parseSubscript=function(e,t,s,r,n,i,o){var a=this.options.ecmaVersion>=11,h=a&&this.eat(v.questionDot);r&&h&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var l=this.eat(v.bracketL);if(l||h&&this.type!==v.parenL&&this.type!==v.backQuote||this.eat(v.dot)){var c=this.startNodeAt(t,s);c.object=e,l?(c.property=this.parseExpression(),this.expect(v.bracketR)):this.type===v.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(v.parenL)){var d=new K,u=this.yieldPos,p=this.awaitPos,f=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var g=this.parseExprList(v.parenR,this.options.ecmaVersion>=8,!1,d);if(n&&!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,g,o);this.checkExpressionErrors(d,!0),this.yieldPos=u||this.yieldPos,this.awaitPos=p||this.awaitPos,this.awaitIdentPos=f||this.awaitIdentPos;var m=this.startNodeAt(t,s);m.callee=e,m.arguments=g,a&&(m.optional=h),e=this.finishNode(m,"CallExpression")}else if(this.type===v.backQuote){(h||i)&&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},ae.parseExprAtom=function(e,t,s){this.type===v.slash&&this.readRegexp();var r,n=this.potentialArrowAt===this.start;switch(this.type){case v._super:return this.allowSuper||this.raise(this.start,"'super' keyword outside a method"),r=this.startNode(),this.next(),this.type!==v.parenL||this.allowDirectSuper||this.raise(r.start,"super() call outside constructor of a subclass"),this.type!==v.dot&&this.type!==v.bracketL&&this.type!==v.parenL&&this.unexpected(),this.finishNode(r,"Super");case v._this:return r=this.startNode(),this.next(),this.finishNode(r,"ThisExpression");case v.name:var i=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(v._function))return this.overrideContext(ie.f_expr),this.parseFunction(this.startNodeAt(i,o),0,!1,!0,t);if(n&&!this.canInsertSemicolon()){if(this.eat(v.arrow))return this.parseArrowExpression(this.startNodeAt(i,o),[h],!1,t);if(this.options.ecmaVersion>=8&&"async"===h.name&&this.type===v.name&&!a&&(!this.potentialArrowInForAwait||"of"!==this.value||this.containsEsc))return h=this.parseIdent(!1),!this.canInsertSemicolon()&&this.eat(v.arrow)||this.unexpected(),this.parseArrowExpression(this.startNodeAt(i,o),[h],!0,t)}return h;case v.regexp:var l=this.value;return(r=this.parseLiteral(l.value)).regex={pattern:l.pattern,flags:l.flags},r;case v.num:case v.string:return this.parseLiteral(this.value);case v._null:case v._true:case v._false:return(r=this.startNode()).value=this.type===v._null?null:this.type===v._true,r.raw=this.type.keyword,this.next(),this.finishNode(r,"Literal");case v.parenL:var c=this.start,d=this.parseParenAndDistinguishExpression(n,t);return e&&(e.parenthesizedAssign<0&&!this.isSimpleAssignTarget(d)&&(e.parenthesizedAssign=c),e.parenthesizedBind<0&&(e.parenthesizedBind=c)),d;case v.bracketL:return r=this.startNode(),this.next(),r.elements=this.parseExprList(v.bracketR,!0,!0,e),this.finishNode(r,"ArrayExpression");case v.braceL:return this.overrideContext(ie.b_expr),this.parseObj(!1,e);case v._function:return r=this.startNode(),this.next(),this.parseFunction(r,0);case v._class:return this.parseClass(this.startNode(),!1);case v._new:return this.parseNew();case v.backQuote:return this.parseTemplate();case v._import:return this.options.ecmaVersion>=11?this.parseExprImport(s):this.unexpected();default:return this.parseExprAtomDefault()}},ae.parseExprAtomDefault=function(){this.unexpected()},ae.parseExprImport=function(e){var t=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import"),this.next(),this.type===v.parenL&&!e)return this.parseDynamicImport(t);if(this.type===v.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()},ae.parseDynamicImport=function(e){if(this.next(),e.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(v.parenR)?e.options=null:(this.expect(v.comma),this.afterTrailingComma(v.parenR)?e.options=null:(e.options=this.parseMaybeAssign(),this.eat(v.parenR)||(this.expect(v.comma),this.afterTrailingComma(v.parenR)||this.unexpected())));else if(!this.eat(v.parenR)){var t=this.start;this.eat(v.comma)&&this.eat(v.parenR)?this.raiseRecoverable(t,"Trailing comma is not allowed in import()"):this.unexpected(t)}return this.finishNode(e,"ImportExpression")},ae.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")},ae.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")},ae.parseParenExpression=function(){this.expect(v.parenL);var e=this.parseExpression();return this.expect(v.parenR),e},ae.shouldParseArrow=function(e){return!this.canInsertSemicolon()},ae.parseParenAndDistinguishExpression=function(e,t){var s,r=this.start,n=this.startLoc,i=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 K,p=this.yieldPos,f=this.awaitPos;for(this.yieldPos=0,this.awaitPos=0;this.type!==v.parenR;){if(c?c=!1:this.expect(v.comma),i&&this.afterTrailingComma(v.parenR,!0)){d=!0;break}if(this.type===v.ellipsis){o=this.start,l.push(this.parseParenItem(this.parseRestBinding())),this.type===v.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}l.push(this.parseMaybeAssign(!1,u,this.parseParenItem))}var g=this.lastTokEnd,m=this.lastTokEndLoc;if(this.expect(v.parenR),e&&this.shouldParseArrow(l)&&this.eat(v.arrow))return this.checkPatternErrors(u,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=p,this.awaitPos=f,this.parseParenArrowList(r,n,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",g,m)):s=l[0]}else s=this.parseParenExpression();if(this.options.preserveParens){var y=this.startNodeAt(r,n);return y.expression=s,this.finishNode(y,"ParenthesizedExpression")}return s},ae.parseParenItem=function(e){return e},ae.parseParenArrowList=function(e,t,s,r){return this.parseArrowExpression(this.startNodeAt(e,t),s,!1,r)};var ce=[];ae.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===v.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,n=this.startLoc;return e.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),r,n,!0,!1),"Super"===e.callee.type&&this.raiseRecoverable(r,"Invalid use of 'super'"),this.eat(v.parenL)?e.arguments=this.parseExprList(v.parenR,this.options.ecmaVersion>=8,!1):e.arguments=ce,this.finishNode(e,"NewExpression")},ae.parseTemplateElement=function(e){var t=e.isTagged,s=this.startNode();return this.type===v.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===v.backQuote,this.finishNode(s,"TemplateElement")},ae.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===v.eof&&this.raise(this.pos,"Unterminated template literal"),this.expect(v.dollarBraceL),s.expressions.push(this.parseExpression()),this.expect(v.braceR),s.quasis.push(r=this.parseTemplateElement({isTagged:t}));return this.next(),this.finishNode(s,"TemplateLiteral")},ae.isAsyncProp=function(e){return!e.computed&&"Identifier"===e.key.type&&"async"===e.key.name&&(this.type===v.name||this.type===v.num||this.type===v.string||this.type===v.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===v.star)&&!w.test(this.input.slice(this.lastTokEnd,this.start))},ae.parseObj=function(e,t){var s=this.startNode(),r=!0,n={};for(s.properties=[],this.next();!this.eat(v.braceR);){if(r)r=!1;else if(this.expect(v.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(v.braceR))break;var i=this.parseProperty(e,t);e||this.checkPropClash(i,n,t),s.properties.push(i)}return this.finishNode(s,e?"ObjectPattern":"ObjectExpression")},ae.parseProperty=function(e,t){var s,r,n,i,o=this.startNode();if(this.options.ecmaVersion>=9&&this.eat(v.ellipsis))return e?(o.argument=this.parseIdent(!1),this.type===v.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===v.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)&&(n=this.start,i=this.startLoc),e||(s=this.eat(v.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(v.star),this.parsePropertyName(o)):r=!1,this.parsePropertyValue(o,e,s,r,n,i,t,a),this.finishNode(o,"Property")},ae.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")},ae.parsePropertyValue=function(e,t,s,r,n,i,o,a){(s||r)&&this.type===v.colon&&this.unexpected(),this.eat(v.colon)?(e.value=t?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,o),e.kind="init"):this.options.ecmaVersion>=6&&this.type===v.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===v.comma||this.type===v.braceR||this.type===v.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=n),t?e.value=this.parseMaybeDefault(n,i,this.copyNode(e.key)):this.type===v.eq&&o?(o.shorthandAssign<0&&(o.shorthandAssign=this.start),e.value=this.parseMaybeDefault(n,i,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))},ae.parsePropertyName=function(e){if(this.options.ecmaVersion>=6){if(this.eat(v.bracketL))return e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(v.bracketR),e.key;e.computed=!1}return e.key=this.type===v.num||this.type===v.string?this.parseExprAtom():this.parseIdent("never"!==this.options.allowReserved)},ae.initFunction=function(e){e.id=null,this.options.ecmaVersion>=6&&(e.generator=e.expression=!1),this.options.ecmaVersion>=8&&(e.async=!1)},ae.parseMethod=function(e,t,s){var r=this.startNode(),n=this.yieldPos,i=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|G(t,r.generator)|(s?128:0)),this.expect(v.parenL),r.params=this.parseBindingList(v.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(r,!1,!0,!1),this.yieldPos=n,this.awaitPos=i,this.awaitIdentPos=o,this.finishNode(r,"FunctionExpression")},ae.parseArrowExpression=function(e,t,s,r){var n=this.yieldPos,i=this.awaitPos,o=this.awaitIdentPos;return this.enterScope(16|G(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=n,this.awaitPos=i,this.awaitIdentPos=o,this.finishNode(e,"ArrowFunctionExpression")},ae.parseFunctionBody=function(e,t,s,r){var n=t&&this.type!==v.braceL,i=this.strict,o=!1;if(n)e.body=this.parseMaybeAssign(r),e.expression=!0,this.checkParams(e,!1);else{var a=this.options.ecmaVersion>=7&&!this.isSimpleParamList(e.params);i&&!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,!i&&!o&&!t&&!s&&this.isSimpleParamList(e.params)),this.strict&&e.id&&this.checkLValSimple(e.id,5),e.body=this.parseBlock(!1,void 0,o&&!i),e.expression=!1,this.adaptDirectivePrologue(e.body.body),this.labels=h}this.exitScope()},ae.isSimpleParamList=function(e){for(var t=0,s=e;t<s.length;t+=1)if("Identifier"!==s[t].type)return!1;return!0},ae.checkParams=function(e,t){for(var s=Object.create(null),r=0,n=e.params;r<n.length;r+=1){var i=n[r];this.checkLValInnerPattern(i,1,t?null:s)}},ae.parseExprList=function(e,t,s,r){for(var n=[],i=!0;!this.eat(e);){if(i)i=!1;else if(this.expect(v.comma),t&&this.afterTrailingComma(e))break;var o=void 0;s&&this.type===v.comma?o=null:this.type===v.ellipsis?(o=this.parseSpread(r),r&&this.type===v.comma&&r.trailingComma<0&&(r.trailingComma=this.start)):o=this.parseMaybeAssign(!1,r),n.push(o)}return n},ae.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&$||"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"))},ae.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},ae.parseIdentNode=function(){var e=this.startNode();return this.type===v.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=v.name):this.unexpected(),e},ae.parsePrivateIdent=function(){var e=this.startNode();return this.type===v.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},ae.parseYield=function(e){this.yieldPos||(this.yieldPos=this.start);var t=this.startNode();return this.next(),this.type===v.semi||this.canInsertSemicolon()||this.type!==v.star&&!this.type.startsExpr?(t.delegate=!1,t.argument=null):(t.delegate=this.eat(v.star),t.argument=this.parseMaybeAssign(e)),this.finishNode(t,"YieldExpression")},ae.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 de=V.prototype;de.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},de.raiseRecoverable=de.raise,de.curPosition=function(){if(this.options.locations)return new N(this.curLine,this.pos-this.lineStart)};var ue=V.prototype,pe=function(e){this.flags=e,this.var=[],this.lexical=[],this.functions=[]};ue.enterScope=function(e){this.scopeStack.push(new pe(e))},ue.exitScope=function(){this.scopeStack.pop()},ue.treatFunctionsAsVarInScope=function(e){return 2&e.flags||!this.inModule&&1&e.flags},ue.declareName=function(e,t,s){var r=!1;if(2===t){var n=this.currentScope();r=n.lexical.indexOf(e)>-1||n.functions.indexOf(e)>-1||n.var.indexOf(e)>-1,n.lexical.push(e),this.inModule&&1&n.flags&&delete this.undefinedExports[e]}else if(4===t)this.currentScope().lexical.push(e);else if(3===t){var i=this.currentScope();r=this.treatFunctionsAsVar?i.lexical.indexOf(e)>-1:i.lexical.indexOf(e)>-1||i.var.indexOf(e)>-1,i.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&$)break}r&&this.raiseRecoverable(s,"Identifier '"+e+"' has already been declared")},ue.checkLocalExport=function(e){-1===this.scopeStack[0].lexical.indexOf(e.name)&&-1===this.scopeStack[0].var.indexOf(e.name)&&(this.undefinedExports[e.name]=e)},ue.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]},ue.currentVarScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(771&t.flags)return t}},ue.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 fe=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=V.prototype;function me(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 fe(this,this.start,this.startLoc)},ge.startNodeAt=function(e,t){return new fe(this,e,t)},ge.finishNode=function(e,t){return me.call(this,e,t,this.lastTokEnd,this.lastTokEndLoc)},ge.finishNodeAt=function(e,t,s,r){return me.call(this,e,t,s,r)},ge.copyNode=function(e){var t=new fe(this,e.start,this.startLoc);for(var s in e)t[s]=e[s];return t};var ye="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",xe=ye+" Extended_Pictographic",ve=xe+" EBase EComp EMod EPres ExtPict",we={9:ye,10:xe,11:xe,12:ve,13:ve,14:ve},be={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"},Ee="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",Se="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=Se+" 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",ke=Ae+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",Ie={9:Se,10:_e,11:Ce,12:Ae,13:ke,14:ke+" 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"},Te={};function Pe(e){var t=Te[e]={binary:M(we[e]+" "+Ee),binaryOfStrings:M(be[e]),nonBinary:{General_Category:M(Ee),Script:M(Ie[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 Le=0,Me=[9,10,11,12,13,14];Le<Me.length;Le+=1)Pe(Me[Le]);var Re=V.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 Ne=function(e){this.parser=e,this.validFlags="gim"+(e.options.ecmaVersion>=6?"uy":"")+(e.options.ecmaVersion>=9?"s":"")+(e.options.ecmaVersion>=13?"d":"")+(e.options.ecmaVersion>=15?"v":""),this.unicodeProperties=Te[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 Ue(e){return 105===e||109===e||115===e}function Be(e){return 36===e||e>=40&&e<=43||46===e||63===e||e>=91&&e<=94||e>=123&&e<=125}function De(e){return e>=65&&e<=90||e>=97&&e<=122}Ne.prototype.reset=function(e,t,s){var r=-1!==s.indexOf("v"),n=-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=n&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=n&&this.parser.options.ecmaVersion>=9)},Ne.prototype.raise=function(e){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+e)},Ne.prototype.at=function(e,t){void 0===t&&(t=!1);var s=this.source,r=s.length;if(e>=r)return-1;var n=s.charCodeAt(e);if(!t&&!this.switchU||n<=55295||n>=57344||e+1>=r)return n;var i=s.charCodeAt(e+1);return i>=56320&&i<=57343?(n<<10)+i-56613888:n},Ne.prototype.nextIndex=function(e,t){void 0===t&&(t=!1);var s=this.source,r=s.length;if(e>=r)return r;var n,i=s.charCodeAt(e);return!t&&!this.switchU||i<=55295||i>=57344||e+1>=r||(n=s.charCodeAt(e+1))<56320||n>57343?e+1:e+2},Ne.prototype.current=function(e){return void 0===e&&(e=!1),this.at(this.pos,e)},Ne.prototype.lookahead=function(e){return void 0===e&&(e=!1),this.at(this.nextIndex(this.pos,e),e)},Ne.prototype.advance=function(e){void 0===e&&(e=!1),this.pos=this.nextIndex(this.pos,e)},Ne.prototype.eat=function(e,t){return void 0===t&&(t=!1),this.current(t)===e&&(this.advance(t),!0)},Ne.prototype.eatChars=function(e,t){void 0===t&&(t=!1);for(var s=this.pos,r=0,n=e;r<n.length;r+=1){var i=n[r],o=this.at(s,t);if(-1===o||o!==i)return!1;s=this.nextIndex(s,t)}return this.pos=s,!0},Re.validateRegExpFlags=function(e){for(var t=e.validFlags,s=e.flags,r=!1,n=!1,i=0;i<s.length;i++){var o=s.charAt(i);-1===t.indexOf(o)&&this.raise(e.start,"Invalid regular expression flag"),s.indexOf(o,i+1)>-1&&this.raise(e.start,"Duplicate regular expression flag"),"u"===o&&(r=!0),"v"===o&&(n=!0)}this.options.ecmaVersion>=15&&r&&n&&this.raise(e.start,"Invalid regular expression flag")},Re.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))},Re.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")}},Re.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")},Re.regexp_alternative=function(e){for(;e.pos<e.source.length&&this.regexp_eatTerm(e););},Re.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)},Re.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},Re.regexp_eatQuantifier=function(e,t){return void 0===t&&(t=!1),!!this.regexp_eatQuantifierPrefix(e,t)&&(e.eat(63),!0)},Re.regexp_eatQuantifierPrefix=function(e,t){return e.eat(42)||e.eat(43)||e.eat(63)||this.regexp_eatBracedQuantifier(e,t)},Re.regexp_eatBracedQuantifier=function(e,t){var s=e.pos;if(e.eat(123)){var r=0,n=-1;if(this.regexp_eatDecimalDigits(e)&&(r=e.lastIntValue,e.eat(44)&&this.regexp_eatDecimalDigits(e)&&(n=e.lastIntValue),e.eat(125)))return-1!==n&&n<r&&!t&&e.raise("numbers out of order in {} quantifier"),!0;e.switchU&&!t&&e.raise("Incomplete quantifier"),e.pos=s}return!1},Re.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)},Re.regexp_eatReverseSolidusAtomEscape=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatAtomEscape(e))return!0;e.pos=t}return!1},Re.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 n=0;n<s.length;n++){var i=s.charAt(n);s.indexOf(i,n+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},Re.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},Re.regexp_eatModifiers=function(e){for(var t="",s=0;-1!==(s=e.current())&&Ue(s);)t+=R(s),e.advance();return t},Re.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)},Re.regexp_eatInvalidBracedQuantifier=function(e){return this.regexp_eatBracedQuantifier(e,!0)&&e.raise("Nothing to repeat"),!1},Re.regexp_eatSyntaxCharacter=function(e){var t=e.current();return!!Be(t)&&(e.lastIntValue=t,e.advance(),!0)},Re.regexp_eatPatternCharacters=function(e){for(var t=e.pos,s=0;-1!==(s=e.current())&&!Be(s);)e.advance();return e.pos!==t},Re.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))},Re.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,n=s;r<n.length;r+=1)n[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}},Re.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},Re.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},Re.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)},Re.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)},Re.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)},Re.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},Re.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},Re.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)},Re.regexp_eatCControlLetter=function(e){var t=e.pos;if(e.eat(99)){if(this.regexp_eatControlLetter(e))return!0;e.pos=t}return!1},Re.regexp_eatZero=function(e){return 48===e.current()&&!je(e.lookahead())&&(e.lastIntValue=0,e.advance(),!0)},Re.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)},Re.regexp_eatControlLetter=function(e){var t=e.current();return!!De(t)&&(e.lastIntValue=t%32,e.advance(),!0)},Re.regexp_eatRegExpUnicodeEscapeSequence=function(e,t){void 0===t&&(t=!1);var s,r=e.pos,n=t||e.switchU;if(e.eat(117)){if(this.regexp_eatFixedHexDigits(e,4)){var i=e.lastIntValue;if(n&&i>=55296&&i<=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*(i-55296)+(a-56320)+65536,!0}e.pos=o,e.lastIntValue=i}return!0}if(n&&e.eat(123)&&this.regexp_eatHexDigits(e)&&e.eat(125)&&((s=e.lastIntValue)>=0&&s<=1114111))return!0;n&&e.raise("Invalid unicode escape"),e.pos=r}return!1},Re.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))},Re.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 De(e)||95===e}function He(e){return qe(e)||je(e)}function je(e){return e>=48&&e<=57}function $e(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function Ge(e){return e>=65&&e<=70?e-65+10:e>=97&&e<=102?e-97+10:e-48}function Ve(e){return e>=48&&e<=55}Re.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},Re.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 n=e.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(e,n)}return 0},Re.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")},Re.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")},Re.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue="";qe(t=e.current());)e.lastStringValue+=R(t),e.advance();return""!==e.lastStringValue},Re.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue="";He(t=e.current());)e.lastStringValue+=R(t),e.advance();return""!==e.lastStringValue},Re.regexp_eatLoneUnicodePropertyNameOrValue=function(e){return this.regexp_eatUnicodePropertyValue(e)},Re.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},Re.regexp_classContents=function(e){return 93===e.current()?1:e.switchV?this.regexp_classSetExpression(e):(this.regexp_nonEmptyClassRanges(e),1)},Re.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")}}},Re.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||Ve(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)},Re.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)},Re.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)}},Re.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},Re.regexp_eatClassSetOperand=function(e){return this.regexp_eatClassSetCharacter(e)?1:this.regexp_eatClassStringDisjunction(e)||this.regexp_eatNestedClass(e)},Re.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 n=this.regexp_eatCharacterClassEscape(e);if(n)return n;e.pos=t}return null},Re.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},Re.regexp_classStringDisjunctionContents=function(e){for(var t=this.regexp_classString(e);e.eat(124);)2===this.regexp_classString(e)&&(t=2);return t},Re.regexp_classString=function(e){for(var t=0;this.regexp_eatClassSetCharacter(e);)t++;return 1===t?1:2},Re.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))},Re.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)},Re.regexp_eatClassControlLetter=function(e){var t=e.current();return!(!je(t)&&95!==t||(e.lastIntValue=t%32,e.advance(),0))},Re.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},Re.regexp_eatDecimalDigits=function(e){var t=e.pos,s=0;for(e.lastIntValue=0;je(s=e.current());)e.lastIntValue=10*e.lastIntValue+(s-48),e.advance();return e.pos!==t},Re.regexp_eatHexDigits=function(e){var t=e.pos,s=0;for(e.lastIntValue=0;$e(s=e.current());)e.lastIntValue=16*e.lastIntValue+Ge(s),e.advance();return e.pos!==t},Re.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},Re.regexp_eatOctalDigit=function(e){var t=e.current();return Ve(t)?(e.lastIntValue=t-48,e.advance(),!0):(e.lastIntValue=0,!1)},Re.regexp_eatFixedHexDigits=function(e,t){var s=e.pos;e.lastIntValue=0;for(var r=0;r<t;++r){var n=e.current();if(!$e(n))return e.pos=s,!1;e.lastIntValue=16*e.lastIntValue+Ge(n),e.advance()}return!0};var Fe=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])},ze=V.prototype;function Ye(e){return"function"!=typeof BigInt?null:BigInt(e.replace(/_/g,""))}ze.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 Fe(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()},ze.getToken=function(){return this.next(),new Fe(this)},"undefined"!=typeof Symbol&&(ze[Symbol.iterator]=function(){var e=this;return{next:function(){var t=e.getToken();return{done:t.type===v.eof,value:t}}}}),ze.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(v.eof):e.override?e.override(this):void this.readToken(this.fullCharCodeAtPos())},ze.readToken=function(e){return d(e,this.options.ecmaVersion>=6)||92===e?this.readWord():this.getTokenFromCode(e)},ze.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},ze.fullCharCodeAtPos=function(){return this.fullCharCodeAt(this.pos)},ze.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,n=t;(r=S(this.input,n,this.pos))>-1;)++this.curLine,n=this.lineStart=r;this.options.onComment&&this.options.onComment(!0,this.input.slice(t+2,s),t,this.pos,e,this.curPosition())},ze.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())},ze.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&&_.test(String.fromCharCode(e))))break e;++this.pos}}},ze.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)},ze.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(v.ellipsis)):(++this.pos,this.finishToken(v.dot))},ze.readToken_slash=function(){var e=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):61===e?this.finishOp(v.assign,2):this.finishOp(v.slash,1)},ze.readToken_mult_modulo_exp=function(e){var t=this.input.charCodeAt(this.pos+1),s=1,r=42===e?v.star:v.modulo;return this.options.ecmaVersion>=7&&42===e&&42===t&&(++s,r=v.starstar,t=this.input.charCodeAt(this.pos+2)),61===t?this.finishOp(v.assign,s+1):this.finishOp(r,s)},ze.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(v.assign,3):this.finishOp(124===e?v.logicalOR:v.logicalAND,2):61===t?this.finishOp(v.assign,2):this.finishOp(124===e?v.bitwiseOR:v.bitwiseAND,1)},ze.readToken_caret=function(){return 61===this.input.charCodeAt(this.pos+1)?this.finishOp(v.assign,2):this.finishOp(v.bitwiseXOR,1)},ze.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&&!w.test(this.input.slice(this.lastTokEnd,this.pos))?this.finishOp(v.incDec,2):(this.skipLineComment(3),this.skipSpace(),this.nextToken()):61===t?this.finishOp(v.assign,2):this.finishOp(v.plusMin,1)},ze.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(v.assign,s+1):this.finishOp(v.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(v.relational,s)):(this.skipLineComment(4),this.skipSpace(),this.nextToken())},ze.readToken_eq_excl=function(e){var t=this.input.charCodeAt(this.pos+1);return 61===t?this.finishOp(v.equality,61===this.input.charCodeAt(this.pos+2)?3:2):61===e&&62===t&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(v.arrow)):this.finishOp(61===e?v.eq:v.prefix,1)},ze.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(v.questionDot,2)}if(63===t)return e>=12&&61===this.input.charCodeAt(this.pos+2)?this.finishOp(v.assign,3):this.finishOp(v.coalesce,2)}return this.finishOp(v.question,1)},ze.readToken_numberSign=function(){var e=35;if(this.options.ecmaVersion>=13&&(++this.pos,d(e=this.fullCharCodeAtPos(),!0)||92===e))return this.finishToken(v.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+R(e)+"'")},ze.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(v.parenL);case 41:return++this.pos,this.finishToken(v.parenR);case 59:return++this.pos,this.finishToken(v.semi);case 44:return++this.pos,this.finishToken(v.comma);case 91:return++this.pos,this.finishToken(v.bracketL);case 93:return++this.pos,this.finishToken(v.bracketR);case 123:return++this.pos,this.finishToken(v.braceL);case 125:return++this.pos,this.finishToken(v.braceR);case 58:return++this.pos,this.finishToken(v.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(v.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(v.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+R(e)+"'")},ze.finishOp=function(e,t){var s=this.input.slice(this.pos,this.pos+t);return this.pos+=t,this.finishToken(e,s)},ze.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(w.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 n=this.input.slice(s,this.pos);++this.pos;var i=this.pos,o=this.readWord1();this.containsEsc&&this.unexpected(i);var a=this.regexpState||(this.regexpState=new Ne(this));a.reset(s,n,o),this.validateRegExpFlags(a),this.validateRegExpPattern(a);var h=null;try{h=new RegExp(n,o)}catch(e){}return this.finishToken(v.regexp,{pattern:n,flags:o,value:h})},ze.readInt=function(e,t,s){for(var r=this.options.ecmaVersion>=12&&void 0===t,n=s&&48===this.input.charCodeAt(this.pos),i=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)n&&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===i||null!=t&&this.pos-i!==t?null:o},ze.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=Ye(this.input.slice(t,this.pos)),++this.pos):d(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(v.num,s)},ze.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 n=Ye(this.input.slice(t,this.pos));return++this.pos,d(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(v.num,n)}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 i,o=(i=this.input.slice(t,this.pos),s?parseInt(i,8):parseFloat(i.replace(/_/g,"")));return this.finishToken(v.num,o)},ze.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},ze.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(v.string,t)};var Ke={};ze.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e!==Ke)throw e;this.readInvalidTemplateToken()}this.inTemplateElement=!1},ze.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw Ke;this.raise(e,t)},ze.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!==v.template&&this.type!==v.invalidTemplate?(e+=this.input.slice(t,this.pos),this.finishToken(v.template,e)):36===s?(this.pos+=2,this.finishToken(v.dollarBraceL)):(++this.pos,this.finishToken(v.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}},ze.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(v.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")},ze.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],n=parseInt(r,8);return n>255&&(r=r.slice(0,-1),n=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(n)}return E(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(t)}},ze.readHexChar=function(e){var t=this.pos,s=this.readInt(16,e);return null===s&&this.invalidStringToken(t,"Bad character escape sequence"),s},ze.readWord1=function(){this.containsEsc=!1;for(var e="",t=!0,s=this.pos,r=this.options.ecmaVersion>=6;this.pos<this.input.length;){var n=this.fullCharCodeAtPos();if(u(n,r))this.pos+=n<=65535?1:2;else{if(92!==n)break;this.containsEsc=!0,e+=this.input.slice(s,this.pos);var i=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(i,"Invalid Unicode escape"),e+=R(o),s=this.pos}t=!1}return e+this.input.slice(s,this.pos)},ze.readWord=function(){var e=this.readWord1(),t=v.name;return this.keywords.test(e)&&(t=y[e]),this.finishToken(t,e)};var We="8.17.0";V.acorn={Parser:V,version:We,defaultOptions:D,Position:N,SourceLocation:U,getLineInfo:B,Node:fe,TokenType:p,tokTypes:v,keywordTypes:y,TokContext:ne,tokContexts:ie,isIdentifierChar:u,isIdentifierStart:d,Token:Fe,isNewLine:E,lineBreak:w,lineBreakG:b,nonASCIIwhitespace:_},e.Node=fe,e.Parser=V,e.Position=N,e.SourceLocation=U,e.TokContext=ne,e.Token=Fe,e.TokenType=p,e.defaultOptions=D,e.getLineInfo=B,e.isIdentifierChar=u,e.isIdentifierStart=d,e.isNewLine=E,e.keywordTypes=y,e.lineBreak=w,e.lineBreakG=b,e.nonASCIIwhitespace=_,e.parse=function(e,t){return V.parse(e,t)},e.parseExpressionAt=function(e,t,s){return V.parseExpressionAt(e,t,s)},e.tokContexts=ie,e.tokTypes=v,e.tokenizer=function(e,t){return V.tokenizer(e,t)},e.version=We}(t)},7526(e,t){"use strict";t.toByteArray=function(e){var t,s,i=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=i[0],a=i[1],h=new n(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,n=r%3,i=[],o=16383,a=0,l=r-n;a<l;a+=o)i.push(h(e,a,a+o>l?l:a+o));return 1===n?(t=e[r-1],i.push(s[t>>2]+s[t<<4&63]+"==")):2===n&&(t=(e[r-2]<<8)+e[r-1],i.push(s[t>>10]+s[t>>4&63]+s[t<<2&63]+"=")),i.join("")};for(var s=[],r=[],n="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0;o<64;++o)s[o]=i[o],r[i.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,n=[],i=t;i<s;i+=3)r=(e[i]<<16&16711680)+(e[i+1]<<8&65280)+(255&e[i+2]),n.push(a(r));return n.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},8287(e,t,s){"use strict";const r=s(7526),n=s(251),i="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|g(e,t);let r=a(s);const n=r.write(e,t);return n!==s&&(r=r.slice(0,n)),r}(e,t);if(ArrayBuffer.isView(e))return function(e){if(W(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(W(e,ArrayBuffer)||e&&W(e.buffer,ArrayBuffer))return p(e,t,s);if("undefined"!=typeof SharedArrayBuffer&&(W(e,SharedArrayBuffer)||e&&W(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 n=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(n)return n;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 g(e,t){if(h.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||W(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 n=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return s;case"utf8":case"utf-8":return z(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*s;case"hex":return s>>>1;case"base64":return Y(e).length;default:if(n)return r?-1:z(e).length;t=(""+t).toLowerCase(),n=!0}}function m(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 A(this,t,s);case"ascii":return I(this,t,s);case"latin1":case"binary":return T(this,t,s);case"base64":return C(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 x(e,t,s,r,n){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=n?0:e.length-1),s<0&&(s=e.length+s),s>=e.length){if(n)return-1;s=e.length-1}else if(s<0){if(!n)return-1;s=0}if("string"==typeof t&&(t=h.from(t,r)),h.isBuffer(t))return 0===t.length?-1:v(e,t,s,r,n);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(e,t,s):Uint8Array.prototype.lastIndexOf.call(e,t,s):v(e,[t],s,r,n);throw new TypeError("val must be string, number or Buffer")}function v(e,t,s,r,n){let i,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(n){let r=-1;for(i=s;i<a;i++)if(l(e,i)===l(t,-1===r?0:i-r)){if(-1===r&&(r=i),i-r+1===h)return r*o}else-1!==r&&(i-=i-r),r=-1}else for(s+h>a&&(s=a-h),i=s;i>=0;i--){let s=!0;for(let r=0;r<h;r++)if(l(e,i+r)!==l(t,r)){s=!1;break}if(s)return i}return-1}function w(e,t,s,r){s=Number(s)||0;const n=e.length-s;r?(r=Number(r))>n&&(r=n):r=n;const i=t.length;let o;for(r>i/2&&(r=i/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 K(z(t,e.length-s),e,s,r)}function E(e,t,s,r){return K(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 K(Y(t),e,s,r)}function _(e,t,s,r){return K(function(e,t){let s,r,n;const i=[];for(let o=0;o<e.length&&!((t-=2)<0);++o)s=e.charCodeAt(o),r=s>>8,n=s%256,i.push(n),i.push(r);return i}(t,e.length-s),e,s,r)}function C(e,t,s){return 0===t&&s===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,s))}function A(e,t,s){s=Math.min(e.length,s);const r=[];let n=t;for(;n<s;){const t=e[n];let i=null,o=t>239?4:t>223?3:t>191?2:1;if(n+o<=s){let s,r,a,h;switch(o){case 1:t<128&&(i=t);break;case 2:s=e[n+1],128==(192&s)&&(h=(31&t)<<6|63&s,h>127&&(i=h));break;case 3:s=e[n+1],r=e[n+2],128==(192&s)&&128==(192&r)&&(h=(15&t)<<12|(63&s)<<6|63&r,h>2047&&(h<55296||h>57343)&&(i=h));break;case 4:s=e[n+1],r=e[n+2],a=e[n+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&&(i=h))}}null===i?(i=65533,o=1):i>65535&&(i-=65536,r.push(i>>>10&1023|55296),i=56320|1023&i),r.push(i),n+=o}return function(e){const t=e.length;if(t<=k)return String.fromCharCode.apply(String,e);let s="",r=0;for(;r<t;)s+=String.fromCharCode.apply(String,e.slice(r,r+=k));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(W(e,Uint8Array)&&(e=h.from(e,e.offset,e.byteLength)),W(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 n=0,i=Math.min(s,r);n<i;++n)if(e[n]!==t[n]){s=e[n],r=t[n];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 n=0;for(s=0;s<e.length;++s){let t=e[s];if(W(t,Uint8Array))n+t.length>r.length?(h.isBuffer(t)||(t=h.from(t)),t.copy(r,n)):Uint8Array.prototype.set.call(r,t,n);else{if(!h.isBuffer(t))throw new TypeError('"list" argument must be an Array of Buffers');t.copy(r,n)}n+=t.length}return r},h.byteLength=g,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?A(this,0,e):m.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+">"},i&&(h.prototype[i]=h.prototype.inspect),h.prototype.compare=function(e,t,s,r,n){if(W(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===n&&(n=this.length),t<0||s>e.length||r<0||n>this.length)throw new RangeError("out of range index");if(r>=n&&t>=s)return 0;if(r>=n)return-1;if(t>=s)return 1;if(this===e)return 0;let i=(n>>>=0)-(r>>>=0),o=(s>>>=0)-(t>>>=0);const a=Math.min(i,o),l=this.slice(r,n),c=e.slice(t,s);for(let e=0;e<a;++e)if(l[e]!==c[e]){i=l[e],o=c[e];break}return i<o?-1:o<i?1:0},h.prototype.includes=function(e,t,s){return-1!==this.indexOf(e,t,s)},h.prototype.indexOf=function(e,t,s){return x(this,e,t,s,!0)},h.prototype.lastIndexOf=function(e,t,s){return x(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 n=this.length-t;if((void 0===s||s>n)&&(s=n),e.length>0&&(s<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");let i=!1;for(;;)switch(r){case"hex":return w(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 _(this,e,t,s);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const k=4096;function I(e,t,s){let r="";s=Math.min(e.length,s);for(let n=t;n<s;++n)r+=String.fromCharCode(127&e[n]);return r}function T(e,t,s){let r="";s=Math.min(e.length,s);for(let n=t;n<s;++n)r+=String.fromCharCode(e[n]);return r}function P(e,t,s){const r=e.length;(!t||t<0)&&(t=0),(!s||s<0||s>r)&&(s=r);let n="";for(let r=t;r<s;++r)n+=X[e[r]];return n}function L(e,t,s){const r=e.slice(t,s);let n="";for(let e=0;e<r.length-1;e+=2)n+=String.fromCharCode(r[e]+256*r[e+1]);return n}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,n,i){if(!h.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>n||t<i)throw new RangeError('"value" argument is out of bounds');if(s+r>e.length)throw new RangeError("Index out of range")}function O(e,t,s,r,n){$(t,r,n,e,s,7);let i=Number(t&BigInt(4294967295));e[s++]=i,i>>=8,e[s++]=i,i>>=8,e[s++]=i,i>>=8,e[s++]=i;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 N(e,t,s,r,n){$(t,r,n,e,s,7);let i=Number(t&BigInt(4294967295));e[s+7]=i,i>>=8,e[s+6]=i,i>>=8,e[s+5]=i,i>>=8,e[s+4]=i;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,n,i){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,i){return t=+t,s>>>=0,i||U(e,0,s,4),n.write(e,t,s,r,23,4),s+4}function D(e,t,s,r,i){return t=+t,s>>>=0,i||U(e,0,s,8),n.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],n=1,i=0;for(;++i<t&&(n*=256);)r+=this[e+i]*n;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],n=1;for(;t>0&&(n*=256);)r+=this[e+--t]*n;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=Q(function(e){G(e>>>=0,"offset");const t=this[e],s=this[e+7];void 0!==t&&void 0!==s||V(e,this.length-8);const r=t+256*this[++e]+65536*this[++e]+this[++e]*2**24,n=this[++e]+256*this[++e]+65536*this[++e]+s*2**24;return BigInt(r)+(BigInt(n)<<BigInt(32))}),h.prototype.readBigUInt64BE=Q(function(e){G(e>>>=0,"offset");const t=this[e],s=this[e+7];void 0!==t&&void 0!==s||V(e,this.length-8);const r=t*2**24+65536*this[++e]+256*this[++e]+this[++e],n=this[++e]*2**24+65536*this[++e]+256*this[++e]+s;return(BigInt(r)<<BigInt(32))+BigInt(n)}),h.prototype.readIntLE=function(e,t,s){e>>>=0,t>>>=0,s||M(e,t,this.length);let r=this[e],n=1,i=0;for(;++i<t&&(n*=256);)r+=this[e+i]*n;return n*=128,r>=n&&(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,n=1,i=this[e+--r];for(;r>0&&(n*=256);)i+=this[e+--r]*n;return n*=128,i>=n&&(i-=Math.pow(2,8*t)),i},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=Q(function(e){G(e>>>=0,"offset");const t=this[e],s=this[e+7];void 0!==t&&void 0!==s||V(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=Q(function(e){G(e>>>=0,"offset");const t=this[e],s=this[e+7];void 0!==t&&void 0!==s||V(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),n.read(this,e,!0,23,4)},h.prototype.readFloatBE=function(e,t){return e>>>=0,t||M(e,4,this.length),n.read(this,e,!1,23,4)},h.prototype.readDoubleLE=function(e,t){return e>>>=0,t||M(e,8,this.length),n.read(this,e,!0,52,8)},h.prototype.readDoubleBE=function(e,t){return e>>>=0,t||M(e,8,this.length),n.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 n=1,i=0;for(this[t]=255&e;++i<s&&(n*=256);)this[t+i]=e/n&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 n=s-1,i=1;for(this[t+n]=255&e;--n>=0&&(i*=256);)this[t+n]=e/i&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=Q(function(e,t=0){return O(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),h.prototype.writeBigUInt64BE=Q(function(e,t=0){return N(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 n=0,i=1,o=0;for(this[t]=255&e;++n<s&&(i*=256);)e<0&&0===o&&0!==this[t+n-1]&&(o=1),this[t+n]=(e/i|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 n=s-1,i=1,o=0;for(this[t+n]=255&e;--n>=0&&(i*=256);)e<0&&0===o&&0!==this[t+n+1]&&(o=1),this[t+n]=(e/i|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=Q(function(e,t=0){return O(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),h.prototype.writeBigInt64BE=Q(function(e,t=0){return N(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 n=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),n},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 n;if(t>>>=0,s=void 0===s?this.length:s>>>0,e||(e=0),"number"==typeof e)for(n=t;n<s;++n)this[n]=e;else{const i=h.isBuffer(e)?e:h.from(e,r),o=i.length;if(0===o)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(n=0;n<s-t;++n)this[n+t]=i[n%o]}return this};const q={};function H(e,t,s){q[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 j(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 $(e,t,s,r,n,i){if(e>s||e<t){const r="bigint"==typeof t?"n":"";let n;throw n=i>3?0===t||t===BigInt(0)?`>= 0${r} and < 2${r} ** ${8*(i+1)}${r}`:`>= -(2${r} ** ${8*(i+1)-1}${r}) and < 2 ** ${8*(i+1)-1}${r}`:`>= ${t}${r} and <= ${s}${r}`,new q.ERR_OUT_OF_RANGE("value",n,e)}!function(e,t,s){G(t,"offset"),void 0!==e[t]&&void 0!==e[t+s]||V(t,e.length-(s+1))}(r,n,i)}function G(e,t){if("number"!=typeof e)throw new q.ERR_INVALID_ARG_TYPE(t,"number",e)}function V(e,t,s){if(Math.floor(e)!==e)throw G(e,s),new q.ERR_OUT_OF_RANGE(s||"offset","an integer",e);if(t<0)throw new q.ERR_BUFFER_OUT_OF_BOUNDS;throw new q.ERR_OUT_OF_RANGE(s||"offset",`>= ${s?1:0} and <= ${t}`,e)}H("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),H("ERR_INVALID_ARG_TYPE",function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),H("ERR_OUT_OF_RANGE",function(e,t,s){let r=`The value of "${e}" is out of range.`,n=s;return Number.isInteger(s)&&Math.abs(s)>2**32?n=j(String(s)):"bigint"==typeof s&&(n=String(s),(s>BigInt(2)**BigInt(32)||s<-(BigInt(2)**BigInt(32)))&&(n=j(n)),n+="n"),r+=` It must be ${t}. Received ${n}`,r},RangeError);const F=/[^+/0-9A-Za-z-_]/g;function z(e,t){let s;t=t||1/0;const r=e.length;let n=null;const i=[];for(let o=0;o<r;++o){if(s=e.charCodeAt(o),s>55295&&s<57344){if(!n){if(s>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(o+1===r){(t-=3)>-1&&i.push(239,191,189);continue}n=s;continue}if(s<56320){(t-=3)>-1&&i.push(239,191,189),n=s;continue}s=65536+(n-55296<<10|s-56320)}else n&&(t-=3)>-1&&i.push(239,191,189);if(n=null,s<128){if((t-=1)<0)break;i.push(s)}else if(s<2048){if((t-=2)<0)break;i.push(s>>6|192,63&s|128)}else if(s<65536){if((t-=3)<0)break;i.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;i.push(s>>18|240,s>>12&63|128,s>>6&63|128,63&s|128)}}return i}function Y(e){return r.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(F,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function K(e,t,s,r){let n;for(n=0;n<r&&!(n+s>=t.length||n>=e.length);++n)t[n+s]=e[n];return n}function W(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 n=0;n<16;++n)t[r+n]=e[s]+e[n]}return t}();function Q(e){return"undefined"==typeof BigInt?Z:e}function Z(){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"}){if("string"!=typeof t||!t||"string"!=typeof s||!s)throw new Error("Export storage requires a host-selected game identity");const n=[t,s,r];let i;const o=()=>i||=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 a(e){const t=Object.keys(e),s=new Set;let r=0;if(t.length>128)throw new Error("Too many exports");for(const n of t){if(!/^[A-Za-z0-9_][A-Za-z0-9_. -]{0,119}$/.test(n)||/[ .]$/.test(n)||/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(n)||["__proto__","constructor","prototype"].includes(n)||s.has(n.toLowerCase()))throw new Error("Invalid export name");s.add(n.toLowerCase());const t=e[n];if(!(t instanceof Uint8Array)||t.length>16777216||(r+=t.length)>67108864)throw new Error("Export size limit exceeded")}}return{async getExports(){const e=await o();return new Promise((t,s)=>{const r=e.transaction("exports","readonly"),i=r.objectStore("exports").get(n);r.oncomplete=()=>{try{const e=i.result||{};a(e),t(e)}catch(e){s(e)}},r.onabort=()=>s(r.error||new Error("Unable to read exports"))})},async putExport(e,t){a({[e]:t}),t=t.slice();const s=await o();return new Promise((r,i)=>{const o=s.transaction("exports","readwrite"),h=o.objectStore("exports"),l=h.get(n);let c;l.onsuccess=()=>{try{const s={...l.result,[e]:t};a(s),h.put(s,n)}catch(e){c=e,o.abort()}},o.oncomplete=()=>r(),o.onabort=()=>i(c||o.error||new Error("Unable to save export"))})}}}}},97(e){"use strict";e.exports={createExportsViewer:function(e,{list:t,read:s}){const r=e.document,n=(e,t,s)=>{const n=r.createElement(e);return t&&(n.textContent=t),s?.append(n),n},i=n("dialog");i.className="hg-exports",i.setAttribute("aria-label","Game exports"),n("style",null,i).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=n("div",null,i);o.className="hg-exports-head",n("h2","Game exports",o);const a=n("button","Refresh",o),h=n("button","Close",o),l=n("p","Loading exports…",i);l.setAttribute("role","status");const c=n("div",null,i);c.className="hg-exports-body";const d=n("div",null,c);d.className="hg-exports-files",d.setAttribute("aria-label","Export files");const u=n("div",null,c);u.className="hg-exports-preview";let p,f,g=!1,m=!1;const y=new Promise(e=>{f=e});function x(){u.querySelectorAll("video,audio").forEach(e=>{e.pause(),e.removeAttribute("src"),e.load()}),u.replaceChildren(),p&&e.URL.revokeObjectURL(p),p=null}function v(){g||(g=!0,x(),i.close(),i.remove(),f())}const w=e=>e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`;function b(e){m=e,a.disabled=e,d.querySelectorAll("button").forEach(t=>{t.disabled=e})}async function E(t,i){if(!g&&!m){b(!0),x(),l.textContent=`Loading ${t.name}…`,d.querySelectorAll("button").forEach(e=>e.setAttribute("aria-pressed",String(e===i)));try{const i=await s(t.name);if(g)return;if(i.name!==t.name||!(i.bytes instanceof Uint8Array)||i.bytes.length>16777216)throw new Error("Invalid export file");const{name:o,bytes:a}=i,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(n("h3",o,u),l.textContent=`${w(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=n(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=()=>{!g&&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));n("pre",t||"(Empty file)",u),a.length>65536&&n("p","Preview shows the first 64 KB. Save file includes all bytes.",u)}else n("p","No preview for this format. Save it to open in another app.",u);const c=n("button","Save file",u);c.className="hg-exports-save",c.onclick=()=>{const t=e.URL.createObjectURL(new e.Blob([a],{type:h})),s=n("a",null,r.body);s.href=t,s.download=o,s.click(),s.remove(),e.setTimeout(()=>e.URL.revokeObjectURL(t),3e4)}}catch(e){g||(l.textContent=e.message)}finally{g||b(!1)}}}async function S(){if(!g&&!m){b(!0),x(),d.replaceChildren(),l.textContent="Loading exports…";try{const e=await t();if(g)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=n("button",`${t.name} · ${w(t.size)}`,d);e.setAttribute("aria-pressed","false"),e.onclick=()=>E(t,e)}}catch(e){g||(l.textContent=e.message)}finally{g||b(!1)}}}return a.onclick=S,h.onclick=v,i.oncancel=e=>{e.preventDefault(),v()},r.body.append(i),i.showModal(),h.focus(),S(),{result:y,close:v}}}},5766(e,t,s){var r=s(8287).hp;const n=8388608,i=s(6862),{describeMedia:o}=s(3947);e.exports=class{constructor(e,t={}){this.game=e,this.gameInput=new i(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}handleInput(e,t){if(!t||"object"!=typeof t||"string"!=typeof t.type)return;const s=Number(e);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("string"!=typeof t.key||t.key.length>20)return;this.gameInput.keyDown(s,t.key)}else if("keyup"===t.type){if("string"!=typeof t.key||t.key.length>20)return;this.gameInput.keyUp(s,t.key)}else if("mouseup"===t.type)this.game.handleMouseUp&&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(!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.gameInput.gamepad(s,t);else{const e=this.findNode(t.nodeId);if(e&&e.node&&e.node.input)if("file"===e.node.input.type){const i=((e,t=!1)=>{if("string"==typeof e){let s;if(!t&&"function"==typeof atob){if(s=atob(e),0===s.length||s.length>n)return null;const t=new Uint8Array(s.length);for(let e=0;e<s.length;e++)t[e]=s.charCodeAt(e);return t}const i=r.from(e,"base64");return 0===i.length||i.length>n?null:i}if(e&&"object"==typeof e){const s=Object.values(e);return 0===s.length||s.length>n?null:t?r.from(s):Uint8Array.from(s)}return null})(t.input,this.fileBuffers);i&&e.node.input.oninput(s,i,((e,t)=>({...o(e,t),contentType:"string"==typeof t.contentType&&t.contentType.length<=100?t.contentType:null}))(i,t))}else e.node.input.oninput(s,t.input)}else if("onhover"===t.type){const e=this.findNode(t.nodeId);e&&e.node&&e.node.onHover&&e.node.onHover(s)}else if("offhover"===t.type){const e=this.findNode(t.nodeId);e&&e.node&&e.node.offHover&&e.node.offHover(s)}}catch(e){console.error(`[GameDispatcher] Error handling input type="${t.type}":`,e)}}_handleClick(e,t){if(!t||"number"!=typeof t.x||"number"!=typeof 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 n=this._findClick(t.x,t.y,e),i=n?this.findPointerNode(n.id):null;if(r&&(this._activePresses[e]={node:i&&i.node||null,x:t.x,y:t.y}),i&&i.node&&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"!=typeof t.x||"number"!=typeof t.y)return;if(t.x<0||t.y<0||t.x>=100||t.y>=100)return;const s=this._activePresses[e];s&&(s.x=t.x,s.y=t.y);const{x:r,y:n}=this.toGameCoords(t.x,t.y);try{this.game.handleMouseMove&&this.game.handleMouseMove(e,{x:r,y:n})}catch(e){console.error("[GameDispatcher] game.handleMouseMove threw:",e)}if(s&&s.node&&"function"==typeof s.node.onDrag)try{s.node.onDrag(e,r,n)}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"==typeof t.x&&"number"==typeof t.y?t:{x:s.x,y:s.y};try{const{x:t,y:n}=this.toGameCoords(r.x,r.y);s.node.offClick(e,t,n)}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];t&&t.node&&(this.findPointerNode(t.node.id)||this.endPress(e,null))}_findClick(e,t,s){let r=null;for(const n of this.getLayers(e,t,s))!1!==n.interactive&&(r=this._findClickHelper(e,t,s,n.root.node,null,n.scale||{x:1,y:1},0)||r);return r}_findClickHelper(e,t,s,r,n,i,o){if(o>100)return n;if(r.playerIds&&r.playerIds.length>0&&!r.playerIds.find(e=>e==s))return n;if(r.coordinates2d&&r.coordinates2d.length>0){const s=[];for(let e=0;e<r.coordinates2d.length;e++){const t=100-100*i.x,n=100-100*i.y,o=r.coordinates2d[e][0]*((100-t)/100)+t/2,a=r.coordinates2d[e][1]*((100-n)/100)+n/2;s.push([o,a])}if(s.length>0){let i=!1,o=s[0][0],a=s[0][0],h=s[0][1],l=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),h=Math.min(s[e][1],h),l=Math.max(s[e][1],l);if(!(e<o||e>a||t<h||t>l)){let r=0,n=s.length-1;for(;r<s.length;n=r++)s[r][1]>t!=s[n][1]>t&&e<(s[n][0]-s[r][0])*(t-s[r][1])/(s[n][1]-s[r][1])+s[r][0]&&(i=!i)}i&&(n=r)}}if(r.children){const a=Object.keys(r.children);for(let h=0;h<a.length;h++){const l=r.children[a[h]];l&&l.node&&(n=this._findClickHelper(e,t,s,l.node,n,i,o+1))}}return n}}},6862(e,t,s){const{Buttons:r,mapInputs:n}=s(1011),i=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(i.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 i=this._player(e),h=this._keys(i),l=i.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(n(r,this.bindings)).filter(([,e])=>e.pressed).map(([e])=>e));!1===t.connected?i.pads.delete(s):i.pads.set(s,{state:r,keys:u});const p=this._keys(i);for(const t of h)p.has(t)||this.game.handleKeyUp?.(e,t);for(const t of u){const r=[...i.pads].find(([,e])=>e.keys.has(t))?.[0];i.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)})}}}},2947(e,t,s){"use strict";const{createProject:r}=s(5110),{DIRECTORY:n,createUserExports:i}=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():i({...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 i=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(i))h[n+"/"+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=(e,s)=>{const r=t(e?e+"/"+s:s);return[r,r+".js",r+"/index.js"]},r={image:1,audio:2,font:3,video:4},n=e=>{const t=e.map(({key:e,type:t,data:s})=>{const n=new Uint8Array(44+s.length);n[0]=1,n[1]=r[t]||r.image;const i=(s.length+32).toString(36),o=10-i.length;for(let e=0;e<o;e++)n[2+e]=48;for(let e=0;e<i.length;e++)n[2+o+e]=i.charCodeAt(e);const a=Math.min(32,e.length);for(let t=0;t<a;t++)n[12+t]=e.charCodeAt(t);return n.set(s,44),n}),s=t.reduce((e,t)=>e+t.length,0),n=new Uint8Array(s);let i=0;for(const e of t)n.set(e,i),i+=e.length;return n},i=new WeakMap;e.exports={normalizePath:t,resolutionCandidates:s,resolveInFiles:(e,t,r)=>{for(const n of s(t,r))if(Object.prototype.hasOwnProperty.call(e,n))return n;return null},packAssetBundle:n,splitAssetBundle:(e,t=10485760)=>{const s=[];let r=0,n=0;for(;n<e.length;){const i=String.fromCharCode(...e.subarray(n+2,n+12)),o=parseInt(i,36)+12;if(1!==e[n]||!/^[0-9a-z]{10}$/.test(i)||o<44||n+o>e.length)throw new Error("Invalid asset bundle");if(o>t)throw new Error("An asset exceeds the RTC packet limit");n+o-r>t&&(s.push(e.subarray(r,n)),r=n),n+=o}return n>r&&s.push(e.subarray(r,n)),s},loadAssetBundle:async(e,t,s=Object.create(null))=>{i.has(s)||i.set(s,new Map);const r=i.get(s),o=await Promise.all(e.map(async e=>{if(!Object.prototype.hasOwnProperty.call(s,e.key)){const i={};r.set(e.key,i);const o=await t(e),a=n([{key:e.key,type:e.type,data:o}]);return r.get(e.key)===i&&(s[e.key]=a),a}return s[e.key]})),a=new Uint8Array(o.reduce((e,t)=>e+t.length,0));let h=0;for(const e of o)a.set(e,h),h+=e.length;return a},ASSET_TYPE_BYTES:r}},6620(e,t,s){var r=s(8287).hp;const{MAX_UPLOAD_BYTES:n,describeMedia:i}=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,n={id:r,playerId:Number(e),audio:!!t.audio,video:!!t.video,transmitting:!1!==t.transmitting,pushToTalk:!!t.pushToTalk};return new Promise((e,t)=>{const i={info:n,resolve:e,reject:t};i.timer=setTimeout(()=>this.stop(r,"Microphone/camera permission timed out"),6e4),this.streams.set(r,i),s.send({type:"media",action:"request",stream:n})})}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 i=Math.min(30,Math.max(1,Number(t.durationSeconds)||30)),o=Math.min(n,Math.max(131072,Math.floor(Number(t.maxBytes)||n))),a={id:"recording-"+ ++this.sequence,kind:r,durationSeconds:i,maxBytes:o,prompt:String(t.prompt||"").slice(0,120)};return new Promise((t,r)=>{const n={info:a,resolve:t,reject:r};n.timer=setTimeout(()=>this.cancelRecording(e,"Recording timed out. Please try again."),18e4),this.recordings.set(e,n),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 n=r.from(t.data,"base64"),o=i(n,{contentType:t.contentType,fileName:t.fileName});if(!n.length||n.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:n,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,n="string"==typeof t.contentType?t.contentType.toLowerCase().split(";")[0].slice(0,100):"";let i=null,o=null;const a=(e,t)=>{i=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"===n||/\.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"===n||/\.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)||n.startsWith("audio/")||/\.(m4a|m4b)$/i.test(r||"");a(e?"audio":"video",e?"audio/mp4":"video/mp4")}}return{kind:i,contentType:o,fileName:r}};e.exports={MAX_UPLOAD_BYTES:t,describeMedia:r,createFileUploadHandler:({Asset:e,registerAsset:s,isPlayerActive:n})=>{let i=0;const o=new Map;return async(a,h,l={},c={})=>{if(!n(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-"+ ++i;p&&o.set(p,f);const g=new e({id:f,type:u.kind,contentType:u.contentType,fileName:u.fileName},d.slice());return g.key=f,await s(f,g),g}}}},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 n;try{n=e(t.localStorage.getItem(r))}catch(e){n=s()}const i=s=>{n=e(s);try{t.localStorage.setItem(r,n)}catch(e){}return n};return i(n),{get:()=>n,set:i}}}}e.exports={createPlayerIdentity:t,...t()}},8106(e){"use strict";e.exports={createPlayerToolbar:function(e,t={}){const s=e.document,r=new Map,n=(e,t,r)=>{const n=s.createElement(e);return n.className=t,r&&(n.textContent=r),n},i=n("header","hg-player-bar");i.setAttribute("aria-label","Game controls");const o=n("style","");o.textContent="\n.hg-player-bar,.hg-player-menu{box-sizing:border-box;color:#f6f6ee;background:#202321;font:14px/1.4 system-ui,sans-serif}\n.hg-player-bar *,.hg-player-menu *{box-sizing:border-box}\n.hg-player-bar{display:flex;flex:none;align-items:center;gap:6px;width:100%;height:calc(58px + env(safe-area-inset-top));padding:calc(6px + env(safe-area-inset-top)) max(10px,env(safe-area-inset-right)) 6px max(10px,env(safe-area-inset-left));border-bottom:1px solid #363b36}\n.hg-player-heading{flex:1;min-width:0}.hg-player-title{margin:0;font-size:14px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}\n.hg-player-status{margin:0;color:#b7bfb5;font-size:11px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}\n.hg-player-bar button,.hg-player-bar a,.hg-player-menu button{font:inherit;color:inherit;border:1px solid #4a5049;border-radius:8px;background:transparent;cursor:pointer;text-decoration:none}\n.hg-player-bar button,.hg-player-bar a{display:inline-flex;align-items:center;justify-content:center;flex:none;min-width:40px;height:44px;padding:0 10px;white-space:nowrap}\n.hg-player-bar .hg-player-icon{font-size:21px;padding:0;width:40px}\n.hg-player-bar .hg-player-share{background:#fff78e;color:#22261e;border-color:#fff78e;font-weight:600}\n.hg-player-bar button:hover,.hg-player-bar a:hover,.hg-player-menu button:hover{background:#394036}\n.hg-player-bar .hg-player-share:hover{background:#fffbb5}\n.hg-player-bar :focus-visible,.hg-player-menu :focus-visible{outline:2px solid #fff78e;outline-offset:2px}\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-bar.hg-player-simple .hg-player-status{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}\n.hg-player-menu{position:fixed;inset:max(68px,env(safe-area-inset-top)) 12px auto auto;margin:0;width:min(320px,calc(100vw - 24px));max-height:calc(100dvh - 90px);overflow:auto;padding:16px;border:1px solid #4a5049;border-radius:12px;box-shadow:0 16px 50px #0008}\n.hg-player-menu::backdrop{background:#080c0a99}.hg-player-menu h2{margin:0 0 12px;font-size:16px}\n.hg-player-menu-actions{display:flex;flex-direction:column;gap:6px}.hg-player-menu button{width:100%;min-height:44px;padding:10px 12px;text-align:left}\n.hg-player-menu .hg-player-menu-status{font-size:12px;color:#b7bfb5;overflow-wrap:anywhere;margin:12px 0}\n.hg-player-menu .hg-player-menu-close{text-align:center;margin-top:10px}\n.hg-player-name{margin:0 0 16px;padding-bottom:16px;border-bottom:1px solid #4a5049}\n.hg-player-name label{display:block;margin-bottom:6px}.hg-player-name input{width:100%;min-height:44px;padding:10px;font:inherit;color:inherit;background:#141815;border:1px solid #4a5049;border-radius:8px}\n.hg-player-name button{margin-top:8px}.hg-player-name p{font-size:12px;color:#b7bfb5;margin:8px 0 0;overflow-wrap:anywhere}\n",i.append(o);const a=n("string"==typeof t.home?"a":"button","hg-player-icon","⌂");a.setAttribute("aria-label","Home"),a.title="Home",a.hidden=!t.home,"string"==typeof t.home?a.href=t.home:(a.type="button",a.onclick=t.home);const h=n("div","hg-player-heading"),l=n("h1","hg-player-title"),c=n("p","hg-player-status");c.setAttribute("role","status"),c.setAttribute("aria-atomic","true"),h.append(l,c);const d=n("button","hg-player-icon","⇩");d.type="button",d.title="View exports",d.setAttribute("aria-label","View exports"),d.hidden=!0;const u=n("button","hg-player-share","Share");u.type="button",u.hidden=!0;const p=n("button","hg-player-icon","⋯");p.type="button",p.title="More",p.setAttribute("aria-label","More"),p.setAttribute("aria-haspopup","dialog");const f=n("button","","Download");f.type="button",f.hidden=!0,t.simple&&(i.classList.add("hg-player-simple"),p.hidden=!0),i.append(a,h,d,u,f,p);const g=n("dialog","hg-player-menu");g.setAttribute("aria-label","Game options");const m=n("h2","","Game options"),y=n("div","hg-player-menu-actions"),x=n("p","hg-player-menu-status"),v=n("form","hg-player-name");v.hidden=!0;const w=n("label","","Your name"),b=n("input","");b.type="text",b.maxLength=32,b.required=!0,b.autocomplete="nickname",b.setAttribute("aria-label","Your name"),w.append(b);const E=n("button","","Save name");E.type="submit";const S=n("p","");S.setAttribute("role","status"),v.append(w,E,S);let _,C="";v.onsubmit=async e=>{if(e.preventDefault(),_&&!E.disabled){E.disabled=!0;try{C=await _(b.value),b.value=C,S.textContent="Name updated for this session."}catch(e){S.textContent=e.message||String(e)}finally{E.disabled=!1}}};const A=n("button","hg-player-menu-close","Done");A.type="button",A.onclick=()=>g.close(),g.append(m,v,y,x,A),s.body.append(g);let k=!1;const I=()=>{k&&(k=!1,t.onClose?.())};p.onclick=()=>{g.open||(b.value=C,S.textContent="",k=!0,t.onOpen?.(),g.showModal())},g.addEventListener("close",I),g.addEventListener("click",e=>{if(e.target===g){const t=g.getBoundingClientRect();(e.clientX<t.left||e.clientX>t.right||e.clientY<t.top||e.clientY>t.bottom)&&g.close()}});let T=!1;const P={bar:i,menu:g,statusElement:c,setTitle(e){l.textContent=l.title=e||"Homegames"},setStatus(e){c.textContent=c.title=x.textContent=e||""},setPlayerName(e,t){C=e,_=t,v.hidden=!t,g.open||(b.value=e),t&&(p.hidden=!1)},setAction(e,s){if(!s){const t=r.get(e);return void(t&&(t.hidden=!0,t!==u&&t!==d&&t!==f&&t.remove(),r.delete(e)))}let i=r.get(e);i||(i="share"===e?u:"exports"===e?d:t.simple&&"download-html"===e?f:n("button","",s.label),i.type="button",r.set(e,i),i!==u&&i!==d&&i!==f&&y.append(i)),s.id&&(i.id=s.id),i!==d&&(i.textContent=i===f?"Download":s.label),i.hidden=!!s.hidden||t.simple&&i===d,i.disabled=!!s.disabled,i.onclick=()=>{g.open&&(g.close(),I());try{Promise.resolve(s.run()).catch(e=>P.setStatus(e.message||String(e)))}catch(e){P.setStatus(e.message||String(e))}},t.onActionReady?.(e)},runAction(e){const t=r.get(e);return!(!t||t.disabled||(t.click(),0))},openMenu(){p.click()},dispose(){T||(T=!0,g.open&&g.close(),g.remove(),i.remove())}};i.homegamesToolbar=P,P.setTitle(t.title),P.setStatus(t.status);for(const[e,s]of Object.entries(t.actions||{}))P.setAction(e,s);return P}}},5564(e){"use strict";e.exports={attachClientHost:function(e,t,s,r,n,i,o,a={}){const h=e.document;let l,c,d,u=0,p=!1,f=a.toolbar,g=!1;const m=new Map;function y(e,t){return!l||p?Promise.reject(new Error("The player is not ready")):new Promise((s,r)=>{const n=++u,i=setTimeout(()=>{m.delete(n),r(new Error("Game download timed out"))},6e4);m.set(n,{resolve:s,reject:r,timer:i,format:e}),l.postMessage({type:"download-game",id:n,format:e,name:t})})}const x=e=>{a.onPlayerStatus?a.onPlayerStatus(e):f?.setStatus(e)};function v(e,t){l&&!p&&l.postMessage({type:"player-control",action:e,value:t})}async function w(t){try{x("Preparing game download…");const s=await y(t),r=e.URL.createObjectURL(new Blob([s],{type:"html"===t?"text/html":"application/zip"})),n=h.createElement("a");n.href=r,n.download="my-game."+t,n.click(),setTimeout(()=>e.URL.revokeObjectURL(r),3e4),x("Game copy downloaded")}catch(e){x(e.message)}}function b(h){if(p||l||h.source!==t.contentWindow||"null"!==h.origin||"homegames-client-connect-v1"!==h.data?.type)return;const u=new e.MessageChannel;l=u.port1,l.onmessage=t=>{const o=t.data;if(!p&&"player-state"===o?.type){if("string"==typeof o.title&&f?.setTitle(o.title.slice(0,200)),"string"==typeof o.status&&x(o.status.slice(0,300)),o.ready){f?.setPlayerName(a.profile?.get()||"",o.playerNames&&a.profile?e=>{if(p)throw new Error("This player has closed. Reopen the game to change your name.");const t=a.profile.set(e);return v("player-name",t),t}:null);for(const[e,t]of[["share","Share"],["copy-share","Share a copy"],["manual-connect","Manual connection"],["exports","View exports"]])f?.setAction(e,"exports"===e||o.sharing?{label:t,run:()=>v(e)}:null);f?.setAction("download-html",{label:"Download game HTML",id:a.htmlId,run:()=>w("html")}),f?.setAction("download-zip",{label:"Download game ZIP",id:a.zipId,run:()=>w("zip")})}return}if(!p&&"close-exports"===o?.type)return void d?.close();if(!p&&"view-exports"===o?.type&&Number.isSafeInteger(o.id))return d||!n?void l.postMessage({type:"export-result",id:o.id,error:"Export viewer is unavailable or already open"}):(d=n(e,{list:()=>y("export-list"),read:e=>y("export-file",e)}),void d.result.finally(()=>{d=null,p||l.postMessage({type:"export-result",id:o.id})}));if(!p&&["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=>{p||l.postMessage({type:"export-result",id:o.id,value:e})},e=>{p||l.postMessage({type:"export-result",id:o.id,error:e.message})});if(!p&&"cancel-audio"===o?.type)return void(c?.requestId===o.id&&c.close());if(!p&&["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:i;return t?(c=t(e,o.recording||{}),c.requestId=o.id,void c.result.then(e=>{c=null,p||l.postMessage({type:"audio-result",id:o.id,value:e})},e=>{c=null,p||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=m.get(o?.id);!p&&"game-download"===o?.type&&h&&(m.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()},"*",[u.port2]),!f&&o&&(f=o(e,{title:a.title,home:a.home,status:"Starting game…",onOpen:()=>v("pause-input"),onClose:()=>v("resume-input")}),g=!0,t.before(f.bar)),t.parentElement.style.display="flex",t.parentElement.style.flexDirection="column",t.style.flex="1",t.style.minHeight="0",t.style.height="0"}return e.addEventListener("message",b),{request:y,command:v,download:w,close(){p=!0,e.removeEventListener("message",b),l?.close(),g&&f?.dispose(),c?.close(),d?.close();for(const e of m.values())clearTimeout(e.timer),e.reject(new Error("Player closed"));m.clear()}}},connectClientSource:function(e,t,s={},r={}){let n,i,o,a,h=!1,l=0;const c=new Map,d=new Promise(e=>{i=e}),u=setTimeout(i,15e3),p=l=>{!h&&l.source===e.parent&&"homegames-client-port-v1"===l.data?.type&&l.ports[0]&&(e.removeEventListener("message",p),n=l.ports[0],a=l.data.playerName,clearTimeout(u),i(),o&&n.postMessage({type:"player-state",...o}),n.onmessage=async e=>{const i=e.data;if(h||"player-control"!==i?.type||!Object.hasOwn(r,i.action)){if("audio-result"===i?.type||"export-result"===i?.type){const e=c.get(i.id);if(!e)return;return c.delete(i.id),clearTimeout(e.timer),void(i.error?e.reject(new Error(i.error)):e.resolve(i.value))}if(!h&&"download-game"===i?.type&&Number.isSafeInteger(i.id)&&["html","zip","export-list","export-file"].includes(i.format))try{const e="export-list"===i.format?{value:await s.list()}:"export-file"===i.format?{value:await s.read(i.name)}:{bytes:await t(i.format)};h||n.postMessage({type:"game-download",id:i.id,...e})}catch(e){h||n.postMessage({type:"game-download",id:i.id,error:e.message})}}else try{"player-name"===i.action&&(a=i.value),await r[i.action](i.value)}catch(e){n.postMessage({type:"player-state",status:e.message})}})};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 i=++l,o={resolve:s,reject:r,recordingId:t.recording?.id,type:e};o.timer="view-exports"===e?null:setTimeout(()=>{c.delete(i),"record-audio"!==e&&"record-video"!==e||n?.postMessage({type:"cancel-audio",id:i}),r(new Error("Client request timed out"))},9e4),c.set(i,o),d.then(()=>{if(c.has(i))return h||!n?(clearTimeout(o.timer),c.delete(i),void r(new Error("Client adapter is unavailable"))):void n.postMessage({type:e,id:i,...t})})});return{setState(e){o={...o,...e},h||n?.postMessage({type:"player-state",...o})},getPlayerName:async()=>(await d,a),recordAudio:e=>f("record-audio",{recording:e}),recordVideo:e=>f("record-video",{recording:e}),viewExports:()=>f("view-exports"),closeExports(){n?.postMessage({type:"close-exports"})},cancelRecording(e){for(const[t,s]of c)["record-audio","record-video"].includes(s.type)&&s.recordingId===e&&(n?.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),i(),e.removeEventListener("message",p);for(const[e,t]of c)t.recordingId&&n?.postMessage({type:"cancel-audio",id:e}),clearTimeout(t.timer),t.reject(new Error("Player closed"));c.clear(),n?.close()}}},recordAudio:function(e,t){const s=e.document;let r,n,i,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 g=new Promise((e,t)=>{r=(r,h)=>{a||(a=!0,clearTimeout(o),"recording"===i?.state&&i.stop(),n?.getTracks().forEach(e=>e.stop()),s.removeEventListener("visibilitychange",m),c.close(),c.remove(),r?t(r):e(h))}});f.onclick=()=>r(new Error("Recording cancelled"));const m=()=>{s.hidden&&r(new Error("Recording cancelled because the page was hidden"))};return s.addEventListener("visibilitychange",m),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());n=s,i=new e.MediaRecorder(n);const c=[];let d=0;i.ondataavailable=e=>{e.data.size&&(d+=e.data.size,d>5242880?r(new Error("Recording is too large")):c.push(e.data))},i.onstop=async()=>{if(a)return;let s;try{s=new(e.AudioContext||e.webkitAudioContext);const n=await s.decodeAudioData(await new Blob(c).arrayBuffer()),i=22050,o=Math.min(Math.floor(n.duration*i),h*i),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,i,!0),d.setUint32(28,2*i,!0),d.setUint16(32,2,!0),d.setUint16(34,16,!0),u(36,"data"),d.setUint32(40,2*o,!0);const p=n.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*n.sampleRate/i))]))),!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())}},i.onerror=()=>r(new Error("Recording failed")),i.start(250),u.textContent="Recording…",o=setTimeout(()=>{i.stop(),n.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:g,close:()=>r(new Error("Recording cancelled"))}}}},5758(e,t,s){"use strict";const{exportArchive:r,LIMITS:n}=s(5110),{attachSaveHost:i}=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),p=e=>JSON.stringify(e).replace(/</g,"\\u003c"),f=e=>String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),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`},m=3*n.archiveBytes+8388608;function y(e){let t="";for(let s=0;s<e.length;s+=8192)t+=String.fromCharCode(...e.subarray(s,s+8192));return btoa(t)}async function x(e,{clientBundleSource:t,installationId:s,sharing:n={}}={}){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 i=new URL(n.signalingUrl||"wss://api.homegames.io/rtc");if(!["ws:","wss:","http:","https:"].includes(i.protocol)||i.username||i.password)throw new Error("Invalid signaling URL");i.protocol="https:"===i.protocol?"wss:":"http:"===i.protocol?"ws:":i.protocol;const o=new URL(n.joinUrl||"https://homegames.io/play.html");if(!["http:","https:"].includes(o.protocol))throw new Error("Invalid invitation URL");const a=new URL(n.receiveUrl||"/game-app.html",o);if(!["http:","https:"].includes(a.protocol))throw new Error("Invalid copy receiver URL");const h={archive:y(await r(e)),installationId:s,sharing:!1!==n&&{signalingUrl:i.href,joinUrl:o.href,receiveUrl:a.href}},l=`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'":i.origin+i.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="${f(l)}"><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=${p(h)};\nlet client,clientSource,copyShare,pairing;\nconst state=status=>clientSource?.setState({status});\nconst fail=error=>{document.getElementById('error').hidden=false;document.getElementById('error').textContent=error.message||String(error);state('Unable to play: '+(error.message||String(error)));};\ntry {\nconst project=await HomegamesClient.PortableProject.importArchive(Uint8Array.from(atob(payload.archive),ch=>ch.charCodeAt(0)));\nconst saveError=error=>{state('Progress not saved: '+error.message);};\nconst saveStore=await HomegamesClient.PortableProject.connectSaveStore(window,{gameKey:'project:'+payload.installationId,versionId:'save-schema:'+project.manifest.saveSchemaVersion,onError:saveError,stop:()=>client?.stop()});\nconst shareCopy=async()=>{const copy=await client.requestGameCopy();copyShare?.close();copyShare=HomegamesClient.GameCopies.showCopyShare(copy.project,{signalingUrl:payload.sharing.signalingUrl,receiveUrl:payload.sharing.receiveUrl,onOpen:()=>client.setInputEnabled(false),onClose:()=>client.setInputEnabled(true)});};\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}));\n},{list:()=>client.listExports(),read:name=>client.readExport(name)}, {\nshare:()=>client.showShare(),exports:()=>client.viewExports(),'copy-share':shareCopy,'manual-connect':()=>pairing?.show(),\n'pause-input':()=>client.setInputEnabled(false),'resume-input':()=>client.setInputEnabled(true),'player-name':name=>client.setPlayerName(name)\n});\nconst ready=status=>clientSource.setState({title:project.metadata.name||'Homegame',status,ready:true,sharing:!!payload.sharing,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'),onSessionStatus:state,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,platform:clientSource,playerName:await clientSource.getPlayerName?.(),onReady:()=>ready('Connected manually to host'),onClose:()=>state('Host disconnected'),onError:fail});client.start();}}):null;\nwindow.addEventListener('pagehide',()=>{copyShare?.close();pairing?.dispose();client.stop();clientSource.close();});client.startLocalGame({});\n}catch(error){fail(error);}\n})();\n<\/script></body></html>`}function v(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 *; camera 'none'; microphone 'none'; geolocation 'none'"),s.referrerPolicy="no-referrer",s.srcdoc=t,s}e.exports={runtimeDocument:x,createFrame:v,buildIsolatedHtml:async function(e,t){const s=await x(e,t),n=p({formatVersion:1,document:s,archive:y(await r(e)),name:g(e.metadata.name),title:e.metadata.name||"Homegame",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>${f(e.metadata.name||"Homegame")}</title>\n<style>html,body{margin:0;height:100%;background:#101820;color:#f7fafc;font:14px system-ui}body{display:flex;flex-direction:column}iframe{flex:1;width:100%;border:0;min-height: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">${n}<\/script>\n<script>const payload=JSON.parse(document.getElementById('homegames-project').textContent);\nconst originalHtml='<!doctype html>\\n'+document.documentElement.outerHTML;\nlet frame,saveHost,clientHost;\nconst toolbar=(${d.toString()})(window,{title:payload.title,status:'Starting game…',onOpen:()=>clientHost?.command('pause-input'),onClose:()=>clientHost?.command('resume-input')});document.body.prepend(toolbar.bar);\nconst showSaveStatus=message=>toolbar.setStatus(message);\nasync function mount(){clientHost?.close();if(saveHost)await saveHost.close();frame?.remove();frame=(${v.toString()})(document,payload.document);saveHost=(${i.toString()})(window,frame,{...payload.saves,onStatus:value=>showSaveStatus(value.message)});clientHost=(${o.toString()})(window,frame,(${a.toString()}),(${c.toString()})(window,payload.saves),(${h.toString()}),(${l.toString()}),(${d.toString()}),{toolbar,htmlId:'portable-html-copy',zipId:'portable-copy',profile:(${u.toString()})().profile(window)});document.body.appendChild(frame);}\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(Uint8Array.from(atob(payload.archive),c=>c.charCodeAt(0)),'application/zip',payload.name)});\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();\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);}};\n<\/script></body></html>`},filename:g,readHtmlArchive:function(e){if("string"!=typeof e||e.length>m)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(n.archiveBytes/3)||/[^A-Za-z0-9+/=]/.test(r.archive))throw new Error("Invalid game HTML archive");const i=Uint8Array.from(atob(r.archive),e=>e.charCodeAt(0));if(i.length>n.archiveBytes)throw new Error("Game archive is too large");return i},htmlBytesLimit:m}},4811(e,t,s){"use strict";const{describeMedia:r}=s(3947);function n(e,t){const s=r(e,{fileName:t});if(s.kind)return s;const n=String.fromCharCode(...e.subarray(0,4)),i={wOFF:"font/woff",wOF2:"font/woff2",OTTO:"font/otf","\0\0\0":"font/ttf"};if(e.length>=12&&i[n])return{kind:"font",contentType:i[n]};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:n,validateAsset:function(e,t){if(!e||!["image","audio","video","font"].includes(e.type)||!(t instanceof Uint8Array)||!t.length||t.length>10485716||n(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:n}=s(595),i=s(8630),{describeAsset:o}=s(4811),{packAssetBundle:a}=s(3735),h="homegame.json",l=".homegame/inventory.json",c=Object.freeze({files:512,fileBytes:16777216,totalBytes:67108864,archiveBytes:68157440,sourceBytes:1048576}),d=new TextEncoder,u=new TextDecoder("utf-8",{fatal:!0}),p=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),f=e=>{throw new Error(e)},g=e=>"string"==typeof e?d.encode(e):e instanceof Uint8Array?new Uint8Array(e):f("Project files must contain text or Uint8Array bytes"),m=e=>u.decode(e),y=e=>JSON.stringify(x(e));function x(e){if(Array.isArray(e))return e.map(x);if(e&&"object"==typeof e){const t=Object.create(null);for(const s of Object.keys(e).sort())t[s]=x(e[s]);return t}return e}function v(e){("string"!=typeof e||!e.length||e.length>240)&&f("Invalid project path");const t=e.startsWith("./")?e.slice(2):e;/^[A-Za-z0-9_. /-]+$/.test(t)||f(`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))&&f(`Unsafe project path: ${e}`);return t}function w(e){const t=new Set;for(const s of e){v(s)!==s&&f(`Non-canonical project path: ${s}`);const e=s.toLowerCase();t.has(e)&&f(`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("/"))&&f(`File/directory collision: ${e}`)}}function b(e,t){try{return JSON.parse(m(e))}catch(e){f(`Invalid JSON or UTF-8 in ${t}`)}}async function E(e,t){if(t.sha256)return t.sha256(e);globalThis.crypto?.subtle||f("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 S(e,t){if(e&&"string"==typeof e.type){t(e);for(const s of Object.values(e))Array.isArray(s)?s.forEach(e=>S(e,t)):s&&"string"==typeof s.type&&S(s,t)}}function _(e,t,s=new Map,r=new Set){e||f(`${t} must be declared as a literal`),(r.has(e)||r.size>64)&&f(`Circular or excessive constant expression in ${t}`),r=new Set(r).add(e);const n=e=>_(e,t,s,r),i=(e,r=new Set)=>{if((!e||r.has(e)||r.size>64)&&f(`Unresolved constant in ${t}`),r.add(e),"Identifier"===e.type&&s.has(e.name))return i(s.get(e.name),r);if("MemberExpression"===e.type){const t=i(e.object,r),s=e.computed?n(e.property):e.property.name;if("ObjectExpression"===t.type)return i(t.properties.find(e=>"Property"===e.type&&!e.computed&&(e.key.name??e.key.value)===s)?.value,r)}return e},o=i(e);if(o!==e)return n(o);if("Literal"===e.type&&!(e.value instanceof RegExp))return e.value;if("UnaryExpression"===e.type&&["-","+","!"].includes(e.operator)){const t=n(e.argument);return"!"===e.operator?!t:"-"===e.operator?-t:+t}if("ArrayExpression"===e.type)return e.elements.map(n);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)&&f(`${t} must use literal properties`);const e=r.key.name??r.key.value;p(s,e)&&f(`Duplicate ${t} property: ${e}`),s[e]=n(r.value)}return s}f(`${t} must be declared as a literal`)}function C(e,t,s){"string"==typeof s&&/^\.\.?\//.test(s)||f(`Unsupported module in ${t}: ${s}`);const r=t.split("/").slice(0,-1);for(const e of s.split("/"))"."!==e&&(".."===e?(r.length||f(`Module escapes project root in ${t}: ${s}`),r.pop()):r.push(e));const n=v(r.join("/"));n.startsWith("user-exports/")&&f("User exports are bytes, not executable modules");const i=[n,`${n}.js`,`${n}.json`,`${n}/index.js`].find(t=>p(e,t));return i&&/\.(js|json)$/.test(i)||f(`Missing JavaScript module or JSON data in ${t}: ${s}`),i}function A(e,t){return e.endsWith(".js")?"text/javascript":e.endsWith(".json")?"application/json":o(t,e).contentType||"application/octet-stream"}async function k(e,t={}){const r=Object.keys(e);r.length>c.files&&f("Project contains too many files"),w(r);const n=Object.create(null);let a=0;for(const t of r){(".homegame"===t.toLowerCase()||t.toLowerCase().startsWith(".homegame/"))&&f("The .homegame directory is reserved for generated inventory");const s=e[t],r="string"==typeof s?d.encode(s).length:s?.byteLength;(!Number.isSafeInteger(r)||r>c.fileBytes||(a+=r)>c.totalBytes)&&f(`Project size limit exceeded at ${t}`),n[t]=g(s)}p(n,h)||f("Missing homegame.json");const l=Object.fromEntries(Object.entries(n).filter(([e])=>e.startsWith("user-exports/")).map(([e,t])=>[e.slice(13),t]));s(5828).validateFiles(l);const u=b(n[h],h);1!==u?.formatVersion&&f(`Unsupported project format: ${u?.formatVersion}`),"string"==typeof u.gameId&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(u.gameId)||f("homegame.json needs a UUID gameId"),(!Number.isSafeInteger(u.saveSchemaVersion)||u.saveSchemaVersion<1)&&f("Invalid saveSchemaVersion");const x=u.runtime?.squishVersion;Array.isArray(t.supportedRuntimes)&&t.supportedRuntimes.includes(x)||f(`Unsupported runtime: squish-${x}. Supported: ${(t.supportedRuntimes||[]).join(", ")}`),v(u.entry)===u.entry&&!u.entry.startsWith("user-exports/")&&u.entry.endsWith(".js")&&p(n,u.entry)||f(`Missing or invalid entry: ${u.entry}`);const{metadata:k,assets:I}=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>c.sourceBytes&&f(`JavaScript file exceeds 1 MiB: ${t}`);try{s[t]=i.parse(m(r),{ecmaVersion:"latest",sourceType:"script"})}catch(e){f(`Cannot parse ${t}: ${e.message}`)}}const r=[];S(s[t.entry],e=>{"MethodDefinition"===e.type&&e.static&&!e.computed&&"metadata"===(e.key.name??e.key.value)&&r.push(e)});const n=r[0]?.value.body.body;1===r.length&&1===n.length&&"ReturnStatement"===n[0].type&&"ObjectExpression"===n[0].argument?.type||f("Portable games need one static metadata() returning a literal object");const a=Object.create(null),h=[],l=new Set,d=new Map;for(const e of s[t.entry].body)if("VariableDeclaration"===e.type&&"const"===e.kind)for(const t of e.declarations)"Identifier"===t.id.type&&d.set(t.id.name,t.init);for(const t of n[0].argument.properties){("Property"!==t.type||t.computed||t.method||"init"!==t.kind)&&f("Portable metadata must use literal properties");const s=t.key.name??t.key.value;if(p(a,s)&&f(`Duplicate metadata property: ${s}`),"assets"===s){"ObjectExpression"!==t.value.type&&f("metadata.assets must be a literal object"),a.assets=Object.create(null);for(const s of t.value.properties){("Property"!==s.type||s.computed||s.method||"init"!==s.kind)&&f("Asset declarations must use literal keys");const t=s.key.name??s.key.value;/^[A-Za-z0-9_-]{1,32}$/.test(t)&&!["__proto__","constructor","prototype"].includes(t)||f(`Invalid asset key: ${t}`),p(a.assets,t)&&f(`Duplicate asset key: ${t}`);const r=s.value;"NewExpression"===r.type&&"Asset"===r.callee.name&&1===r.arguments.length||f(`Asset ${t} must use new Asset({ path, type })`);const n=_(r.arguments[0],`Asset ${t}`);void 0!==n.id&&f(`Asset ${t} still uses a hosted asset ID; convert it to a project path`);const i=v(n.path);p(e,i)||f(`Missing asset "${t}": ${i}`);const c=o(e[i],i);["image","audio","video","font"].includes(n.type)&&c.kind===n.type||f(`Unsupported or invalid ${n.type} asset "${t}": ${i}`),a.assets[t]=n,h.push({key:t,path:i,type:n.type}),l.add(r)}}else a[s]=_(t.value,`metadata.${s}`,d)}a.squishVersion!==t.runtime.squishVersion&&f("metadata.squishVersion must match homegame.json"),!a.services||Array.isArray(a.services)&&!a.services.some(e=>"multiplayer"!==e)||f("This portable runtime supports only the multiplayer service");for(const[r,n]of Object.entries(s))S(n,s=>{if("NewExpression"!==s.type||"Asset"!==s.callee.name||l.has(s)||2===s.arguments.length||f(`Declare portable assets in the entry metadata.assets or supply bytes: ${r}`),"CallExpression"===s.type&&"require"===s.callee.name){const n=_(s.arguments[0],`require() in ${r}`);if(n===`squish-${t.runtime.squishVersion}`)return;"string"==typeof n&&n.startsWith("squish-")&&f(`Runtime mismatch in ${r}: ${n}`);const i=C(e,r,n);i.endsWith(".json")&&b(e[i],i)}});return{metadata:a,assets:h}}(n,u);I.some(e=>44+n[e.path].length>10485760)&&f("An asset exceeds the current 10 MiB RTC packet limit");const T=[];for(const e of r.sort())T.push({path:e,byteLength:n[e].length,mediaType:A(e,n[e]),sha256:await E(n[e],t)});const P=await E(d.encode(y({manifest:u,files:T})),t),L=Object.freeze({listFiles:()=>[...r],readFile:e=>{const t=v(e);return p(n,t)||f(`Missing project file: ${t}`),n[t].slice()},stat:e=>{const t=v(e),s=T.find(e=>e.path===t);return s||f(`Missing project file: ${t}`),{...s}}});return{manifest:u,metadata:k,assets:I,revision:P,inventory:T,reader:L}}e.exports={checkSyntax:function(e){try{return i.parse(e,{ecmaVersion:"latest",sourceType:"script"}),null}catch(e){return{message:e.message,line:e.loc?.line||1}}},MANIFEST:h,INVENTORY:l,LIMITS:c,normalizePath:v,resolveModule:C,canonical:y,createProject:k,exportArchive:async function(e){const t=Object.create(null);for(const s of e.reader.listFiles())t[s]=e.reader.readFile(s);return t[l]=d.encode(y({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){(!(e instanceof Uint8Array)||e.length>c.archiveBytes||e.length<22)&&f("Invalid or oversized project archive");const t=new DataView(e.buffer,e.byteOffset,e.byteLength);let s=e.length-22;for(;s>=Math.max(0,e.length-65557)&&101010256!==t.getUint32(s,!0);)s--;s<Math.max(0,e.length-65557)&&f("Damaged ZIP: missing directory"),(s+22+t.getUint16(s+20,!0)!==e.length||t.getUint16(s+4,!0)||t.getUint16(s+6,!0)||t.getUint16(s+8,!0)!==t.getUint16(s+10,!0))&&f("Unsupported multi-volume or damaged ZIP");const r=t.getUint16(s+10,!0),n=t.getUint32(s+12,!0),i=t.getUint32(s+16,!0);(r>c.files+1||i+n!==s)&&f("Unsupported ZIP directory or too many files");let o=i,a=0;const h=[],l=[];for(let n=0;n<r;n++){(o+46>s||33639248!==t.getUint32(o,!0))&&f("Damaged ZIP directory");const r=t.getUint16(o+8,!0),n=t.getUint16(o+10,!0),d=t.getUint32(o+24,!0),u=t.getUint32(o+20,!0),p=t.getUint16(o+28,!0),g=t.getUint16(o+30,!0),y=t.getUint16(o+32,!0),x=t.getUint32(o+42,!0),v=t.getUint32(o+38,!0)>>>16;(1&r||![0,8].includes(n)||t.getUint16(o+34,!0)||40960==(61440&v))&&f("Encrypted files, links and this ZIP compression are unsupported"),(d>c.fileBytes||(a+=d)>c.totalBytes+c.fileBytes)&&f("Expanded ZIP exceeds project size limits"),(o+46+p+g+y>s||x+30>i)&&f("Damaged ZIP entry");const w=m(e.subarray(o+46,o+46+p));h.push(w),67324752===t.getUint32(x,!0)&&t.getUint16(x+6,!0)===r&&t.getUint16(x+8,!0)===n||f("ZIP headers disagree");const b=t.getUint16(x+26,!0),E=x+30+b+t.getUint16(x+28,!0);(E+u>i||m(e.subarray(x+30,x+30+b))!==w)&&f("Damaged ZIP file bounds or name"),l.push({name:w,size:d,offset:x,end:E+u}),o+=46+p+g+y}return o!==s&&f("Damaged ZIP directory length"),w(h),l.sort((e,t)=>e.offset-t.offset),l.some((e,t)=>t&&e.offset<l[t-1].end)&&f("Overlapping ZIP entries"),l}(e),r=n(e)}catch(e){f(`Cannot import project: ${e.message}`)}for(const e of s)r[e.name]?.length!==e.size&&f(`Damaged ZIP file: ${e.name}`);p(r,l)||f("Missing project inventory");const i=b(r[l],l);delete r[l];const o=await k(r,t);return 1===i?.formatVersion&&i.revision===o.revision&&y(i.files)===y(o.inventory)||f("Project integrity check failed: missing, changed or undeclared files"),o},assetBundle:function(e){return a(e.assets.map(t=>({key:t.key,type:t.type,data:e.reader.readFile(t.path)})))}}},7435(e,t,s){"use strict";const{normalizePath:r,resolveModule:n,assetBundle:i}=s(5110),o=new TextDecoder("utf-8",{fatal:!0});function a(e,t,{trusted:i=!1}={}){if(!i)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(688).Asset{constructor(t,n){if(void 0!==n){if(!(n instanceof ArrayBuffer||ArrayBuffer.isView(n)||Array.isArray(n)))throw new Error("Generated assets need byte data");if((n.byteLength??n.length)>10485716)throw new Error("Generated asset exceeds the RTC packet limit");const e=n instanceof ArrayBuffer?new Uint8Array(n):ArrayBuffer.isView(n)?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):Uint8Array.from(n);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 i=r(t.path);if(!e.assets.some(e=>e.path===i&&e.type===t.type))throw new Error(`Undeclared project asset: ${i}`);const o=e.reader.readFile(i);super({...t,path:i},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(n(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(2947).bindGameProject(f,()=>e,{supportedRuntimes:Object.keys(t)},{files:s(5828).projectExports(e)})}e.exports={loadTrustedGame:a,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",gameClass:a(e,t,{trusted:s}),assetBundle:e.assets.length?i(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:n,versionId:i,compatibility:o=[],onStatus:a=()=>{}}=s;if(!/^[a-zA-Z0-9-]{16,80}$/.test(r)||"string"!=typeof n||!/^save-schema:\d+$/.test(i))throw new Error("Invalid save identity");const h="project:"+r,l=[i,...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,g,m,y=!1,x=0,v=!1,w=null,b=0,E=Promise.resolve();const S=(e,t)=>{try{a({state:e,message:t})}catch(e){}},_=e=>S("error","Progress not saved: "+e.message+" Download a save backup before closing."),C=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 A(){return c||(c=new Promise((t,s)=>{let r=!1;const n=e.indexedDB.open("homegames-portable-saves",1);n.onupgradeneeded=()=>n.result.createObjectStore("saves",{keyPath:["installationId","versionId"]}),n.onerror=()=>s(n.error),n.onblocked=()=>{r=!0,s(new Error("Close other game tabs and reload to update save storage."))},n.onsuccess=()=>{r?n.result.close():(n.result.onversionchange=()=>n.result.close(),t(n.result))}})),c}function k(e){b++;const t=E.then(e);return E=t.catch(()=>{}).finally(()=>{b--}),t}async function I(){try{const e=await A(),t=await new Promise((t,s)=>{const n=e.transaction("saves","readonly"),i=[];l.forEach((e,t)=>{const s=n.objectStore("saves").get([r,e]);s.onsuccess=()=>{i[t]=s.result}}),n.oncomplete=()=>t(i),n.onabort=()=>s(n.error||new Error("Could not read game save"))});x=t[0]?.generation||0;const s=t.find(Boolean);if(s){if(s.envelope.gameId!==n||!l.includes(s.envelope.versionId))throw new Error("Saved game identity does not match this game");w={...s.envelope,data:C(s.envelope.data)}}return v=!0,S("ready",w?"Game progress restored from this browser":"Game saves stay in this browser"),w}catch(e){return v=!0,m=e,_(e),null}}async function T(e,t=i){if(!v)throw new Error("Load this game before saving");if(w=((e,t=i)=>({gameKey:h,gameId:n,versionId:t,savedAt:Date.now(),data:C(e)}))(e,t),m)throw m;const s=await A(),o=w;await new Promise((e,t)=>{const n=s.transaction("saves","readwrite"),a=n.objectStore("saves");let h;const l=a.get([r,i]);l.onsuccess=()=>{try{if((l.result?.generation||0)!==x)throw new Error("Another tab saved newer progress. Reload to use it, or download this session’s save.");a.put({installationId:r,versionId:i,generation:x+1,envelope:o})}catch(e){h=e,n.abort()}},n.oncomplete=()=>{x++,e()},n.onabort=()=>t(h||n.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 n;try{"put"===r&&(n=C(t.data))}catch(e){return P({id:s,error:e.message}),void _(e)}k(async()=>{if(y)throw new Error("Game session closed");return"get"===r?v?w:I():T(n)}).then(e=>P({id:s,value:e}),e=>{_(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(g),d?.close(),e.removeEventListener("message",L),e.removeEventListener("beforeunload",M),c?.then(e=>e.close(),()=>{})}function O(){return u||(u=(async()=>{d&&!y&&await new Promise(e=>{f=e,g=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 O(),R()})(),p),dispose:R,async exportSave(){if(await E,!w)throw new Error("This game has not saved any progress yet");return JSON.stringify({...w,data:C(w.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!==n||!l.includes(t.versionId))throw new Error("This save is for a different game or an incompatible save version");const s=C(t.data);await O(),await k(async()=>{v||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"})),n=e.document.createElement("a");n.href=r,n.download=t,n.click(),setTimeout(()=>e.URL.revokeObjectURL(r),3e4)})}}},connectSaveStore:function(e,{gameKey:t,versionId:s,onError:r=()=>{},stop:n=()=>{}}){return new Promise((i,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,n)=>{const i=++h,o=setTimeout(()=>{c.delete(i);const e=new Error("Game save timed out");r(e),n(e)},1e4);c.set(i,{resolve:s,reject:n,timeout:o});try{a.postMessage(void 0===t?{id:i,op:e}:{id:i,op:e,data:t})}catch(e){clearTimeout(o),c.delete(i),n(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){n(),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)},i({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:n}=s(5110),{validateName:i,LIMITS:o}=s(5828),a=65536,h=new TextEncoder,l=new TextDecoder("utf-8",{fatal:!0});function c(e){const t=h.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||(n=t.id,!(Number.isInteger(n)&&n>0&&n<=4294967295)))return;var n;const h=this.transfers.get(e),l=e=>s(c({action:"error",id:t.id,message:e}));if("cancel"===t.action)return void(h?.id===t.id&&this.leave(e));if("request"===t.action){if(h||this.transfers.size>=4)return void l("A file transfer is already in progress. Try again shortly.");const n={id:t.id,offset:0,send:s};this.transfers.set(e,n),this.touch(e,n);try{let a,h;const l=t.kind||"project";if("export-list"===l){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)!==n)return;return this.leave(e),void s(c({action:"exports",id:n.id,files:t}))}if("export"===l){if(i(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:l,name:t.name}}else{if("project"!==l)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)!==n)return;n.bytes=a,s(c({action:"offer",id:n.id,bytes:a.length,...h}))}catch(t){this.transfers.get(e)===n&&(this.leave(e),l(String(t.message).slice(0,200)))}return}if("ack"!==t.action||!h||h.id!==t.id)return;if(!h.bytes||t.offset!==h.offset)return this.leave(e),void l("Invalid game-copy acknowledgement");if(this.touch(e,h),h.offset===h.bytes.length)return this.leave(e),void s(c({action:"complete",id:h.id}));const d=Math.min(h.offset+a,h.bytes.length),u=new Uint8Array(9+d-h.offset);u[0]=15;const p=new DataView(u.buffer);p.setUint32(1,h.id),p.setUint32(5,h.offset),u.set(h.bytes.subarray(h.offset,d),9),h.offset=d,s(u)}touch(e,t){clearTimeout(t.timer),t.timer=setTimeout(()=>{this.transfers.get(e)===t&&(this.leave(e),t.send(c({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{i(t)}catch(e){return Promise.reject(e)}return new Promise((s,r)=>{const n=this.sequence=this.sequence%4294967295+1;this.pending={id:n,resolve:s,reject:r,offset:0,kind:e,name:t},this.touch();try{this.send({type:"project-transfer",action:"request",id:n,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(l.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 n=e.files.map(e=>{if(i(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(n)}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:n.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(a,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,CHUNK_BYTES:a}},9956(e,t,s){const{Squisher:r}=s(688);e.exports={createSessionRuntime:(e,t,n={})=>{if("function"!=typeof e?.squish||"function"!=typeof e?.unsquish)throw new Error("Session needs an explicit Squish codec");const i=new r({...n,game:t,encodeNode:e.squish,decodeNode:e.unsquish});let o=!1;return{squisher:i,listExports:()=>o?Promise.reject(new Error("Session closed")):n.userExportsStore?.list()||Promise.resolve([]),readExport:e=>o?Promise.reject(new Error("Session closed")):n.userExportsStore?.read(e)||Promise.reject(new Error("Export not found")),exportProject:()=>o?Promise.reject(new Error("Session closed")):s(2947).exportGameProject(t,n.userExportsStore),stop(){o||(o=!0,i.close(),n.userExportsStore?.close())}}},playerFrame:(e,t)=>Uint8Array.from(e.getPlayerFrame(t).flat()),collectGameAssets:({game:e,customBottomLayer:t,customTopLayer:s})=>Object.assign({},e.constructor.metadata?.()?.assets,t?.assets,s?.assets,e.getAssets?.())}},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 n(e){const t=Object.keys(e),n=new Set;let i=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(n.has(t))throw new Error("Export names must differ ignoring capitalization");n.add(t);const a=e[o];if(!(a instanceof Uint8Array)||a.length>s.fileBytes||(i+=a.length)>s.totalBytes)throw new Error("User export size limit exceeded")}}const i=e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e,new Uint8Array(t)]));e.exports={DIRECTORY:t,LIMITS:s,validateName:r,validateFiles:n,createUserExports:function(e={},t=async()=>{}){n(e);let o=i(e),a=Promise.resolve(),h=!1,l=0;const c=new Map;return{userExports:Object.freeze(i(o)),createExport:function(e,i){try{if(h)throw new Error("Game session closed");if(r(e),!(i instanceof Uint8Array))throw new Error("Export data must be Uint8Array bytes");if(i.length>s.fileBytes||l>=128)throw new Error("User export limit exceeded");i=new Uint8Array(i)}catch(e){return Promise.reject(e)}l++;const d=a.then(async()=>{const s={...o,[e]:i};n(s),await t(e,new Uint8Array(i)),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 i(o)},close:()=>(h=!0,a)}},projectExports:function(e){const s=Object.create(null);for(const n of e.reader.listFiles())if(n.startsWith(t+"/")){const t=n.slice(13);r(t),s[t]=e.reader.readFile(n)}return n(s),s}}},5900(e){"use strict";e.exports={recordVideo:function(e,t){const{document:s,navigator:r,MediaRecorder:n,performance:i,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)),i=s.createElement("dialog");i.setAttribute("aria-label","Record video"),i.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",i.append(o,h,l,c,d,u),this.container.appendChild(i);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:i,preview:l,status:c,start:d,cancel:u,chunks:[],size:0};u.onclick=()=>this.fail("Recording cancelled. You can try again."),i.oncancel=e=>{e.preventDefault(),u.onclick()},d.onclick=async()=>{d.disabled=!0;try{if(void 0===n)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")}},i.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=>n.isTypeSupported(e)),s=e.recorder=new n(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=i.now()+1e3*e.duration,o=()=>{e.status.textContent=`RECORDING · ${Math.max(0,Math.ceil((r-i.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",n=new o(t.chunks,{type:r});if(!n.size||n.size>t.maxBytes)throw new Error("Recording was empty or too large. Please try again.");const i=new Uint8Array(await n.arrayBuffer());if(this.active!==t)return;let a="";for(let e=0;e<i.length;e+=8192)a+=String.fromCharCode(...i.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:n}=s(9902),i=s(6636),o=s(6260),a=s(9387),h=(e,t,s)=>Number.isFinite(e)?Math.max(t,Math.min(s,e)):0,l=(e,t)=>"string"==typeof e.name&&e.name.length>0&&t.includes(e.name);function c(e,t=[]){if(!e)return null;const s=String(e.id||"");return t.find(e=>l(e,s))||("standard"===e.mapping?o:null)||Object.values(i).find(e=>l(e,s))||null}function d(e,t=c(e),s={}){if(!e||!1===e.connected||!t)return null;const n={},i={};for(const s of new Set([...Object.values(r),...Object.keys(t.buttons||{})])){const r=e.buttons?.[t.buttons?.[s]],i=h("number"==typeof r?r:r?.value,0,1);n[s]={value:i,pressed:"boolean"==typeof r?.pressed?r.pressed:i>=.5}}for(const r of new Set([...Object.keys(o.sticks),...Object.keys(t.sticks||{})])){const n=h(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)");i[r]={value:Math.abs(n)<=o?0:Math.sign(n)*(Math.abs(n)-o)/(1-o)}}return{buttons:n,sticks:i}}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=c(e,this.options.mappings||[]),s=d(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,Sticks:n,mapGamepad:d,getGamepadMapping:c,mapInputs:a}},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 n=e?.sticks?.[t];if(n)return{value:n.value,pressed:Math.abs(n.value)>=s};const i=/^(STICK_[12])_(LEFT|RIGHT|UP|DOWN)$/.exec(t);if(i){const[,t,r]=i,n=t+("LEFT"===r||"RIGHT"===r?"_X":"_Y"),o="LEFT"===r||"UP"===r?-1:1,a=Math.max(0,(e?.sticks?.[n]?.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),n=s(1085),i=s(1193),o=s(7635),a=s(6593),h=s(9075),l=s(4255);e.exports={DUALSHOCK_4:r,STADIA:n,XBOX_ONE:i,LUNA:o,DUALSHOCK_5:a,SWITCH_PRO:h,NES_30:l}},251(e,t){t.read=function(e,t,s,r,n){var i,o,a=8*n-r-1,h=(1<<a)-1,l=h>>1,c=-7,d=s?n-1:0,u=s?-1:1,p=e[t+d];for(d+=u,i=p&(1<<-c)-1,p>>=-c,c+=a;c>0;i=256*i+e[t+d],d+=u,c-=8);for(o=i&(1<<-c)-1,i>>=-c,c+=r;c>0;o=256*o+e[t+d],d+=u,c-=8);if(0===i)i=1-l;else{if(i===h)return o?NaN:1/0*(p?-1:1);o+=Math.pow(2,r),i-=l}return(p?-1:1)*o*Math.pow(2,i-r)},t.write=function(e,t,s,r,n,i){var o,a,h,l=8*i-n-1,c=(1<<l)-1,d=c>>1,u=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:i-1,f=r?1:-1,g=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,n),o+=d):(a=t*Math.pow(2,d-1)*Math.pow(2,n),o=0));n>=8;e[s+p]=255&a,p+=f,a/=256,n-=8);for(o=o<<n|a,l+=n;l>0;e[s+p]=255&o,p+=f,o/=256,l-=8);e[s+p-f]|=128*g}},3008(e,t){var s,r,n=function(){var e=function(e,t){var s=e,r=o[t],n=null,i=0,h=null,m=[],y={},v=function(e,t){n=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}(i=4*s+17),w(0,0),w(i-7,0),w(0,i-7),E(),b(),_(e,t),s>=7&&S(e),null==h&&(h=A(s,r,m)),C(h,t)},w=function(e,t){for(var s=-1;s<=7;s+=1)if(!(e+s<=-1||i<=e+s))for(var r=-1;r<=7;r+=1)t+r<=-1||i<=t+r||(n[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<i-8;e+=1)null==n[e][6]&&(n[e][6]=e%2==0);for(var t=8;t<i-8;t+=1)null==n[6][t]&&(n[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 i=e[t],o=e[r];if(null==n[i][o])for(var h=-2;h<=2;h+=1)for(var l=-2;l<=2;l+=1)n[i+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);n[Math.floor(r/3)][r%3+i-8-3]=o}for(r=0;r<18;r+=1)o=!e&&1==(t>>r&1),n[r%3+i-8-3][Math.floor(r/3)]=o},_=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?n[h][8]=l:h<8?n[h+1][8]=l:n[i-15+h][8]=l}for(h=0;h<15;h+=1)l=!e&&1==(o>>h&1),h<8?n[8][i-h-1]=l:h<9?n[8][15-h-1+1]=l:n[8][15-h-1]=l;n[i-8][8]=!e},C=function(e,t){for(var s=-1,r=i-1,o=7,h=0,l=a.getMaskFunction(t),c=i-1;c>0;c-=2)for(6==c&&(c-=1);;){for(var d=0;d<2;d+=1)if(null==n[r][c-d]){var u=!1;h<e.length&&(u=1==(e[h]>>>o&1)),l(r,c-d)&&(u=!u),n[r][c-d]=u,-1==(o-=1)&&(h+=1,o=7)}if((r+=s)<0||i<=r){r-=s,s=-s;break}}},A=function(e,t,s){for(var r=c.getRSBlocks(e,t),n=d(),i=0;i<s.length;i+=1){var o=s[i];n.put(o.getMode(),4),n.put(o.getLength(),a.getLengthInBits(o.getMode(),e)),o.write(n)}var h=0;for(i=0;i<r.length;i+=1)h+=r[i].dataCount;if(n.getLengthInBits()>8*h)throw"code length overflow. ("+n.getLengthInBits()+">"+8*h+")";for(n.getLengthInBits()+4<=8*h&&n.put(0,4);n.getLengthInBits()%8!=0;)n.putBit(!1);for(;!(n.getLengthInBits()>=8*h||(n.put(236,8),n.getLengthInBits()>=8*h));)n.put(17,8);return function(e,t){for(var s=0,r=0,n=0,i=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),n=Math.max(n,d),i[h]=new Array(c);for(var u=0;u<i[h].length;u+=1)i[h][u]=255&e.getBuffer()[u+s];s+=c;var p=a.getErrorCorrectPolynomial(d),f=l(i[h],p.getLength()-1).mod(p);for(o[h]=new Array(p.getLength()-1),u=0;u<o[h].length;u+=1){var g=u+f.getLength()-o[h].length;o[h][u]=g>=0?f.getAt(g):0}}var m=0;for(u=0;u<t.length;u+=1)m+=t[u].totalCount;var y=new Array(m),x=0;for(u=0;u<r;u+=1)for(h=0;h<t.length;h+=1)u<i[h].length&&(y[x]=i[h][u],x+=1);for(u=0;u<n;u+=1)for(h=0;h<t.length;h+=1)u<o[h].length&&(y[x]=o[h][u],x+=1);return y}(n,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=g(e);break;default:throw"mode:"+t}m.push(s),h=null},y.isDark=function(e,t){if(e<0||i<=e||t<0||i<=t)throw e+","+t;return n[e][t]},y.getModuleCount=function(){return i},y.make=function(){if(s<1){for(var e=1;e<40;e++){for(var t=c.getRSBlocks(e,r),n=d(),i=0;i<m.length;i++){var o=m[i];n.put(o.getMode(),4),n.put(o.getLength(),a.getLengthInBits(o.getMode(),e)),o.write(n)}var h=0;for(i=0;i<t.length;i++)h+=t[i].dataCount;if(n.getLengthInBits()<=8*h)break}s=e}v(!1,function(){for(var e=0,t=0,s=0;s<8;s+=1){v(!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 n=0;n<y.getModuleCount();n+=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,n)?"#000000":"#ffffff",s+=";",s+='"/>';s+="</tr>"}return(s+="</tbody>")+"</table>"},y.createSvgTag=function(e,t,s,r){var n={};"object"==typeof arguments[0]&&(e=(n=arguments[0]).cellSize,t=n.margin,s=n.alt,r=n.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 i,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+=n.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="'+k([r.id,s.id].join(" ").trim())+'"':"",c+=">",c+=r.text?'<title id="'+k(r.id)+'">'+k(r.text)+"</title>":"",c+=s.text?'<description id="'+k(s.id)+'">'+k(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,i=0;i<y.getModuleCount();i+=1)y.isDark(o,i)&&(c+="M"+(i*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,n=s-t;return x(s,s,function(t,s){if(r<=t&&t<n&&r<=s&&s<n){var i=Math.floor((t-r)/e),o=Math.floor((s-r)/e);return y.isDark(o,i)?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,n="";return n+="<img",n+=' src="',n+=y.createDataURL(e,t),n+='"',n+=' width="',n+=r,n+='"',n+=' height="',n+=r,n+='"',s&&(n+=' alt="',n+=k(s),n+='"'),n+"/>"};var k=function(e){for(var t="",s=0;s<e.length;s+=1){var r=e.charAt(s);switch(r){case"<":t+="<";break;case">":t+=">";break;case"&":t+="&";break;case'"':t+=""";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,n,i,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),n=Math.floor((t+1-a)/1),s=0;s<o;s+=1)i="█",a<=s&&s<h&&a<=t&&t<h&&y.isDark(r,Math.floor((s-a)/1))&&(i=" "),a<=s&&s<h&&a<=t+1&&t+1<h&&y.isDark(n,Math.floor((s-a)/1))?i+=" ":i+="█",d+=e<1&&t+1>=h?c[i]:l[i];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,n,i,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(n=Math.floor((s-a)/e),u="",r=0;r<o;r+=1)i=1,a<=r&&r<h&&a<=s&&s<h&&y.isDark(n,Math.floor((r-a)/e))&&(i=0),u+=i?l:c;for(n=0;n<e;n+=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 n=0;n<s;n++)e.fillStyle=y.isDark(r,n)?"black":"white",e.fillRect(n*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},n=0,i={};;){var o=s.read();if(-1==o)break;var a=r(),h=r()<<8|r();i[String.fromCharCode(o<<8|a)]=h,n+=1}if(n!=t)throw n+" != "+t;return i}(),r="?".charCodeAt(0);return function(e){for(var t=[],n=0;n<e.length;n+=1){var i=e.charCodeAt(n);if(i<128)t.push(i);else{var o=s[e.charAt(n)];"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,n,i,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,i=function(e){for(var t=0;0!=e;)t+=1,e>>>=1;return t},(n={}).getBCHTypeInfo=function(e){for(var t=e<<10;i(t)-i(s)>=0;)t^=s<<i(t)-i(s);return 21522^(e<<10|t)},n.getBCHTypeNumber=function(e){for(var t=e<<12;i(t)-i(r)>=0;)t^=r<<i(t)-i(r);return e<<12|t},n.getPatternPosition=function(e){return t[e-1]},n.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}},n.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},n.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}}},n.getLostPoint=function(e){for(var t=e.getModuleCount(),s=0,r=0;r<t;r+=1)for(var n=0;n<t;n+=1){for(var i=0,o=e.isDark(r,n),a=-1;a<=1;a+=1)if(!(r+a<0||t<=r+a))for(var h=-1;h<=1;h+=1)n+h<0||t<=n+h||0==a&&0==h||o==e.isDark(r+a,n+h)&&(i+=1);i>5&&(s+=3+i-5)}for(r=0;r<t-1;r+=1)for(n=0;n<t-1;n+=1){var l=0;e.isDark(r,n)&&(l+=1),e.isDark(r+1,n)&&(l+=1),e.isDark(r,n+1)&&(l+=1),e.isDark(r+1,n+1)&&(l+=1),0!=l&&4!=l||(s+=3)}for(r=0;r<t;r+=1)for(n=0;n<t-6;n+=1)e.isDark(r,n)&&!e.isDark(r,n+1)&&e.isDark(r,n+2)&&e.isDark(r,n+3)&&e.isDark(r,n+4)&&!e.isDark(r,n+5)&&e.isDark(r,n+6)&&(s+=40);for(n=0;n<t;n+=1)for(r=0;r<t-6;r+=1)e.isDark(r,n)&&!e.isDark(r+1,n)&&e.isDark(r+2,n)&&e.isDark(r+3,n)&&e.isDark(r+4,n)&&!e.isDark(r+5,n)&&e.isDark(r+6,n)&&(s+=40);var c=0;for(n=0;n<t;n+=1)for(r=0;r<t;r+=1)e.isDark(r,n)&&(c+=1);return s+Math.abs(100*c/t/t-50)/5*10},n),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),n=0;n<e.length-s;n+=1)r[n]=e[n+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 n=0;n<e.getLength();n+=1)t[s+n]^=h.gexp(h.glog(r.getAt(s))+h.glog(e.getAt(n)));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()),n=0;n<r.getLength();n+=1)s[n]=r.getAt(n);for(n=0;n<e.getLength();n+=1)s[n]^=h.gexp(h.glog(e.getAt(n))+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 n=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===n)throw"bad rs block @ typeNumber:"+s+"/errorCorrectionLevel:"+r;for(var i=n.length/3,a=[],h=0;h<i;h+=1)for(var l=n[3*h+0],c=n[3*h+1],d=n[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,n=0;n+2<s.length;)e.put(r(s.substring(n,n+3)),10),n+=3;n<s.length&&(s.length-n==1?e.put(r(s.substring(n,n+1)),4):s.length-n==2&&e.put(r(s.substring(n,n+2)),7))}},r=function(e){for(var t=0,s=0;s<e.length;s+=1)t=10*t+n(e.charAt(s));return t},n=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,n=0;n+1<s.length;)e.put(45*r(s.charAt(n))+r(s.charAt(n+1)),11),n+=2;n<s.length&&e.put(r(s.charAt(n)),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)}}},g=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),n={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 n=(255&t[s])<<8|255&t[s+1];if(33088<=n&&n<=40956)n-=33088;else{if(!(57408<=n&&n<=60351))throw"illegal char at "+(s+1)+"/"+n;n-=49472}n=192*(n>>>8&255)+(255&n),e.put(n,13),s+=2}if(s<t.length)throw"illegal char at "+(s+1)}};return n},m=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 n=0;n<r;n+=1)t.writeByte(e[n+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,n=0,i={read:function(){for(;n<8;){if(s>=t.length){if(0==n)return-1;throw"unexpected end of file./"+n}var e=t.charAt(s);if(s+=1,"="==e)return n=0,-1;e.match(/^\s$/)||(r=r<<6|o(e.charCodeAt(0)),n+=6)}var i=r>>>n-8&255;return n-=8,i}},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 i},x=function(e,t,s){for(var r=function(e,t){var s=e,r=t,n=new Array(e*t),i={setPixel:function(e,t,r){n[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 n=0;t.length-n>255;)e.writeByte(255),e.writeBytes(t,n,255),n+=255;e.writeByte(t.length-n),e.writeBytes(t,n,t.length-n),e.writeByte(0),e.writeString(";")}},o=function(e){for(var t=1<<e,s=1+(1<<e),r=e+1,i=a(),o=0;o<t;o+=1)i.add(String.fromCharCode(o));i.add(String.fromCharCode(t)),i.add(String.fromCharCode(s));var h,l,c,d=m(),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(n[p]);for(p+=1;p<n.length;){var g=String.fromCharCode(n[p]);p+=1,i.contains(f+g)?f+=g:(u.write(i.indexOf(f),r),i.size()<4095&&(i.size()==1<<r&&(r+=1),i.add(f+g)),f=g)}return u.write(i.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 i}(e,t),n=0;n<t;n+=1)for(var i=0;i<e;i+=1)r.setPixel(i,n,s(i,n));var o=m();r.write(o);for(var a=function(){var e=0,t=0,s=0,r="",n={},i=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 n.writeByte=function(r){for(e=e<<8|255&r,t+=8,s+=1;t>=6;)i(e>>>t-6),t-=6},n.flush=function(){if(t>0&&(i(e<<6-t),e=0,t=0),s%3!=0)for(var n=3-s%3,o=0;o<n;o+=1)r+="="},n.toString=function(){return r},n}(),h=o.toByteArray(),l=0;l<h.length;l+=1)a.writeByte(h[l]);return a.flush(),"data:image/gif;base64,"+a};return e}();n.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 n})?s.apply(t,[]):s)||(e.exports=r)},5656(e,t,s){const r=s(9482),n=(e,t,s,n,i,o,a,h,l,c,d,u,p,f)=>new r(e,t,s,n,i,o,a,h,l,c,d,u,p,f);e.exports={gameNode:n,BaseNode:class{constructor({color:e,onClick:t,coordinates2d:s,border:r,fill:i,textInfo:o,assetInfo:a,playerIds:h,effects:l,input:c,subtype:d,node:u,id:p,onHover:f,offHover:g}){this.node=u||n(e,t,s,r,i,o,a,h,l,c,d,p,f,g),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")}}}},961(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,n=Math.floor(Math.random()*r.length);return t[r[n]]}}},9579(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)}}}},847(e,t,s){const r=s(3431),n=s(7910),{gameNode:i,BaseNode:o}=s(5656),a={[r.CIRCLE]:n.SHAPE_2D_CIRCLE,[r.POLYGON]:n.SHAPE_2D_POLYGON,[r.LINE]:n.SHAPE_2D_LINE},h={[n.SHAPE_2D_CIRCLE]:r.CIRCLE,[n.SHAPE_2D_POLYGON]:r.POLYGON,[n.SHAPE_2D_LINE]:r.LINE};class l extends o{constructor({color:e,onClick:t,shapeType:s,coordinates2d:r,border:n,fill:i,playerIds:o,effects:h,input:l,node:c,id:d,onHover:u,offHover:p}){if(!(r&&s||c))throw new Error("Shape requires coordinates2d and shapeType");super({color:e,onClick:t,coordinates2d:r,border:n,fill:i,playerIds:o,effects:h,input:l,node:c,subtype:a[s],id:d,onHover:u,offHover:p})}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:i}){if(!e&&!r)throw new Error("Text node requires textInfo");super({textInfo:e,playerIds:t,input:s,node:r,subtype:n.TEXT,id:i})}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:i,node:o,id:a,onHover:h,offHover:l}){if(!e&&!o)throw new Error("Asset node requires assetInfo");super({assetInfo:e,onClick:t,coordinates2d:s,playerIds:r,effects:i,node:o,subtype:n.ASSET,id:a,onHover:h,offHover:l})}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={Asset:d,Shape:l,Text:c};e.exports={gameNode:i,GameNode:u}},9482(e){e.exports=class{constructor(e,t,s,r,n,i,o,a=[],h=null,l=null,c=null,d=null,u,p){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=n,this.text=i,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}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}}},3431(e){e.exports={CIRCLE:1,POLYGON:2,LINE:3}},7706(e,t,s){const{GameNode:r}=s(847),n=s(3431),i=s(3250),o=s(961),a=s(9579);e.exports=class extends a{constructor(e){var t;super(),this.planeSize=e,this.plane=(t=this.planeSize,new r.Shape({shapeType:n.POLYGON,coordinates2d:i.rectangle(0,0,t,t)})),this.fakeRoot=new r.Shape({shapeType:n.POLYGON,coordinates2d:i.rectangle(0,0,0,0),fill:o.COLORS.BLACK}),this.layers=[{root:this.fakeRoot}]}updatePlaneSize(e){this.planeSize=e,this.plane.node.coordinates2d=i.rectangle(0,0,e,e)}getLayers(){return this.layers}getPlane(){return this.plane}getPlaneSize(){return this.planeSize}getViewRoot(){return this.fakeRoot}}},5725(e,t,s){const{GameNode:r}=s(847);e.exports={CONSTRUCTOR_TO_TYPE:{Asset:1,Shape:2,Text:3},TYPE_TO_CONSTRUCTOR:{1:r.Asset,2:r.Shape,3:r.Text}}},6036(e){e.exports={getPath:(e,t,s,r,n=100,i=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>n||l<0||l>i){let e=h,t=l;h<0?e=0:h>n&&(e=n),l<0?t=0:l>i&&(t=i),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}}},7588(e,t,s){const r=s(9482),{CONSTRUCTOR_TO_TYPE:n,TYPE_TO_CONSTRUCTOR:i}=s(5725),o=s(4747),{squishId:a}=s(5407),{squishColor:h}=s(9967),{squishPlayerIds:l}=s(8885),{squishPos:c}=s(9866),{squishFill:d}=s(3927),{squishSize:u}=s(1523),{squishHandleClick:p}=s(9022),{squishBorder:f}=s(5972),{squishSubType:g}=s(9958),{squishInput:m}=s(7688),{squishCoordinates2d:y}=s(3697),{squishEffect:x}=s(8875),{squishText:v}=s(5353),{squishAsset:w}=s(8048),b={id:a,color:h,playerIds:l,pos:c,coordinates2d:y,fill:d,size:u,text:v,asset:w,effects:x,handleClick:p,border:f,subType:g,input:m},E={};for(const e in b)E[Number(b[e].type)]=e;e.exports={squish:(e,t=null)=>{let s=[];const r=e.node,i=(()=>{const e=Object.keys(b).filter(e=>b[e].dependsOn&&b[e].dependsOn.length>0);return[Object.keys(b).filter(e=>!b[e].dependsOn||0===b[e].dependsOn.length),e].flat()})();for(const e in i){const n=i[e];if(n in r){const e=r[n];if(null!=e){const i=b[n].squish(e,t,r),o=i.length+3,a=Math.min(255,o),h=Math.min(255,Math.max(0,o-255));s.push([b[n].type,h,a,...i])}}}let a=n[e.constructor.name];a||(a=n[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],n=e[t+1]+e[t+2],i=e.slice(t+3,t+n);if(!E[r]){console.warn("Unknown sub frame type "+r);break}{const e=E[r],t=(0,b[e].unsquish)(i,Object.assign({},s));s[e]=t}t+=n}const n=i[e[4]];return n?new n({node:s}):{node:s}}}},8048(e,t,s){const{getFractional:r}=s(3222),n={type:48,squish:(e,t)=>{const s=Object.keys(e)[0],n=new Array(18+s.length),i=e[s],o=t?t.x*i.pos.x+Math.round(100*(1-t.x))/2:i.pos.x,a=t?t.y*i.pos.y+Math.round(100*(1-t.y))/2:i.pos.y,h=t?t.x*i.size.x:i.size.x,l=t?t.y*i.size.y:i.size.y,c=i.startTime||0,d=i.cropLeft||0,u=i.cropTop||0,p=i.cropRight||0,f=i.cropBottom||0;n[0]=Math.floor(o),n[1]=r(o),n[2]=Math.floor(a),n[3]=r(a),n[4]=Math.floor(h),n[5]=r(h),n[6]=Math.floor(l),n[7]=r(l),n[8]=Math.floor(c),n[9]=r(c),n[10]=Math.floor(d),n[11]=r(d),n[12]=Math.floor(u),n[13]=r(u),n[14]=Math.floor(p),n[15]=r(p),n[16]=Math.floor(f),n[17]=r(f);for(let e=0;e<s.length;e++)n[18+e]=s.codePointAt(e);return n},unsquish:e=>{const t=e[0]+e[1]/100,s=e[2]+e[3]/100,r=e[4]+e[5]/100,n=e[6]+e[7]/100,i=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:n},startTime:i,cropLeft:o,cropTop:a,cropRight:h,cropBottom:l}}}};e.exports={ASSET_SUBTYPE:48,squishAsset:n}},5972(e){e.exports={BORDER_SUBTYPE:54,squishBorder:{type:54,squish:e=>[e],unsquish:e=>e[0]}}},9967(e){e.exports={COLOR_SUBTYPE:42,squishColor:{type:42,squish:e=>[e[0],e[1],e[2],e[3]],unsquish:e=>[e[0],e[1],e[2],e[3]]}}},3697(e,t,s){const{getFractional:r}=s(3222),n=s(7910),i=e=>e<0?0:e>255?255:e,o=(e,t)=>e*t+Math.round(100*(1-e))/2,a={type:52,squish:(e,t,s)=>{const a=e.flat(),h=new Array(2*a.length);if(s.subType==n.SHAPE_2D_CIRCLE)if(t){const e=i(o(t.x,a[0]));h[0]=e,h[1]=r(e);const s=i(o(t.y,a[1]));let n;h[2]=s,h[3]=r(s),n=t.x===t.y?t.x*a[2]:Math.sqrt(Math.pow(100*t.x,2)+Math.pow(100*t.y,2))*(a[2]/100),h[4]=Math.floor(n),h[5]=r(n)}else{const e=i(a[0]);h[0]=Math.floor(e),h[1]=r(e);const t=i(a[1]);h[2]=Math.floor(t),h[3]=r(t);const s=a[2];h[4]=Math.round(s),h[5]=r(s)}else for(const e in a)if(t){const s=e%2==0?t.x:t.y,n=s*a[e],o=Math.round(100*(1-s)),l=i(n+o/2);h[2*e]=l,h[2*e+1]=r(l)}else{const t=i(a[e]);h[2*e]=Math.floor(t),h[2*e+1]=Math.round(100*(t-Math.floor(t)))}return h},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===n.SHAPE_2D_POLYGON||t===n.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={COORDINATES_2D_SUBTYPE:52,squishCoordinates2d:a}},8875(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 n={[t]:{color:s}};return r&&(n[t].blur=r),n}};e.exports={EFFECTS_SUBTYPE:49,squishEffect:t}},3927(e){e.exports={FILL_SUBTYPE:53,squishFill:{type:53,squish:e=>[e[0],e[1],e[2],e[3]],unsquish:e=>[e[0],e[1],e[2],e[3]]}}},9022(e){e.exports={ONCLICK_SUBTYPE:50,squishHandleClick:{type:50,squish:e=>e?[1]:[0],unsquish:e=>1===e[0]}}},5407(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={ID_SUBTYPE:43,squishId:t}},7688(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={INPUT_SUBTYPE:51,squishInput:t}},8885(e){e.exports={PLAYER_ID_SUBTYPE:44,squishPlayerIds:{type:44,squish:e=>e,unsquish:e=>e}}},9866(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={POS_SUBTYPE:45,squishPos:s}},1523(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={SIZE_SUBTYPE:46,squishSize:s}},9958(e){e.exports={SUBTYPE_TYPE:55,squishSubType:{type:55,squish:e=>[e],unsquish:e=>e[0]}}},5353(e,t,s){const{hypLength:r}=s(3222),n=s(961),{squishColor:i}=s(9967),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||n.BLACK,p=i.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 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+p.length+2+3*[...a].length;l[r+g]=Number(s[0]),l[r+g+1]=Number(s[1]),l[r+g+2]=Number(s[2]),g+=3}let m=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 n=6+p.length+2+3*[...a].length+3*[...h].length;l[n+m]=Number(r[0]),l[n+m+1]=Number(r[1]),l[n+m+2]=Number(r[2]),m+=3}return l},unsquish:e=>{const t=e[0]+e[1]/100,s=e[2]+e[3]/100,r=e[4]+e[5]/100,n=e.slice(6,10),i=e[10],o=e[11],a=e.slice(12,12+i),h=e.slice(12+i,12+i+o),l=e.slice(12+i+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 n=t+s+r;c.push(n)}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 n=t+s+r;u.push(n)}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 n=t+s+r;f.push(n)}return{x:t,y:s,text:String.fromCodePoint.apply(null,f),size:r,color:n,align:d,font:p}}};e.exports={TEXT_SUBTYPE:47,squishText:o}},4747(e,t,s){const{GameNode:r}=s(847),n=s(7910);e.exports={[[n.ASSET]]:r.Asset,[[n.TEXT]]:r.Text,[[n.SHAPE_2D_POLYGON]]:r.Shape,[[n.SHAPE_2D_CIRCLE]]:r.Shape,[[n.SHAPE_2D_LINE]]:r.Shape}},7910(e){e.exports={ASSET:1,TEXT:2,SHAPE_2D_POLYGON:3,SHAPE_2D_CIRCLE:4,SHAPE_2D_LINE:5}},4123(e,t,s){const{getRandomTerrain:r,getRandomStartPoint:n}=s(229),i=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,n(a,h,t),a,h,t);const d=((e,t,s,r)=>{const n=[];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(n.findIndex(e=>e.x===a.x&&e.y===a.y)>-1||a.x===t.x&&a.y===t.y||s.filled){n.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}}i(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:n}=((e,t)=>{const s=e.x,r=e.y,n=t.x,i=t.y;return{width:Math.floor(s/n),height:Math.floor(r/i)}})(e,t);let i=((e,t)=>{const s=[],r={filled:!1,north:!0,south:!0,east:!0,west:!0};for(let n=0;n<e;n++){s[n]=[];for(let i=0;i<t;i++){const o={...r};0===n?o.west=!1:n===e-1&&(o.east=!1),0===i?o.north=!1:i===t-1&&(o.south=!1),s[n].push(o)}}return s})(r,n);const a={x:Math.floor(Math.random()*r),y:Math.floor(Math.random()*n)};return i=o(i,a,s,r,n),i}}},229(e){const t=(e,{x:t,y:s},r,n,i)=>{t<0||t>=r||s<0||s>=n||t===i.x&&s===i.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},n,i,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},n,i,o),0===a?(t(e,{x:s+1,y:r},n,i,o),t(e,{x:s,y:r+1},n,i,o),t(e,{x:s+1,y:r+1},n,i,o)):1===a?(t(e,{x:s-1,y:r},n,i,o),t(e,{x:s,y:r+1},n,i,o),t(e,{x:s-1,y:r+1},n,i,o)):2===a?(t(e,{x:s,y:r-1},n,i,o),t(e,{x:s+1,y:r},n,i,o),t(e,{x:s+1,y:r-1},n,i,o)):(t(e,{x:s,y:r-1},n,i,o),t(e,{x:s-1,y:r},n,i,o),t(e,{x:s-1,y:r-1},n,i,o))},(e,{x:s,y:r},n,i,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},n,i,o),0===a?(t(e,{x:s,y:r+1},n,i,o),t(e,{x:s,y:r+2},n,i,o),t(e,{x:s,y:r+3},n,i,o)):1===a?(t(e,{x:s+1,y:r},n,i,o),t(e,{x:s+2,y:r},n,i,o),t(e,{x:s+3,y:r},n,i,o)):2===a?(t(e,{x:s-1,y:r},n,i,o),t(e,{x:s-2,y:r},n,i,o),t(e,{x:s-3,y:r},n,i,o)):(t(e,{x:s,y:r-1},n,i,o),t(e,{x:s,y:r-2},n,i,o),t(e,{x:s,y:r-3},n,i,o))},(e,{x:s,y:r},n,i,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},n,i,o),0===a?(t(e,{x:s,y:r+1},n,i,o),t(e,{x:s,y:r+2},n,i,o),t(e,{x:s+1,y:r+2},n,i,o)):1===a?(t(e,{x:s+1,y:r},n,i,o),t(e,{x:s+2,y:r},n,i,o),t(e,{x:s+2,y:r-1},n,i,o)):2===a?(t(e,{x:s-1,y:r},n,i,o),t(e,{x:s-2,y:r},n,i,o),t(e,{x:s-2,y:r+1},n,i,o)):(t(e,{x:s,y:r-1},n,i,o),t(e,{x:s,y:r-2},n,i,o),t(e,{x:s-1,y:r-2},n,i,o))},(e,{x:s,y:r},n,i,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},n,i,o),0===a?(t(e,{x:s,y:r+1},n,i,o),t(e,{x:s-1,y:r+1},n,i,o),t(e,{x:s-1,y:r+2},n,i,o)):1===a?(t(e,{x:s+1,y:r},n,i,o),t(e,{x:s+1,y:r+1},n,i,o),t(e,{x:s+2,y:r+1},n,i,o)):2===a?(t(e,{x:s-1,y:r},n,i,o),t(e,{x:s-1,y:r+1},n,i,o),t(e,{x:s-2,y:r+1},n,i,o)):(t(e,{x:s,y:r-1},n,i,o),t(e,{x:s-1,y:r-1},n,i,o),t(e,{x:s-1,y:r-2},n,i,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}}},836(e){const t=(e,s,r,n=[])=>{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]],i=s.node.coordinates2d,o=r[0][0],a=r[1][0],h=i[0][0],l=i[1][0],c=r[0][1],d=r[2][1],u=i[0][1],p=i[2][1];l<o||a<h||c>p||u>d||n.push(e)}for(const i in e.node.children)t(e.node.children[i],s,r,n);return n};e.exports={checkCollisions:(e,s,r=null)=>t(e,s,r)}},3222(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)))}},3250(e){e.exports={triangle:(e,t,s,r,n,i)=>[[e,t],[s,r],[n,i],[e,t]],rectangle:(e,t,s,r)=>[[e,t],[e+s,t],[e+s,t+r],[e,t+r],[e,t]]}},6560(e,t,s){const{GameNode:r}=s(847),n=s(3431),i=s(3250),o=s(836),a=s(961);e.exports={getView:(e,t,s,h={},l={})=>{const c=o.checkCollisions(e,{node:{coordinates2d:i.rectangle(t.x,t.y,t.w,t.h)}},t=>t.node.id!==e.node.id),d=new r.Shape({shapeType:n.POLYGON,coordinates2d:i.rectangle(0,0,0,0),fill:a.COLORS.BLACK}),u=[];return c.length>0&&c.forEach(e=>{const r=[],n=[],i=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 i){const o=i[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),g=(l.y||1)*(c-t.y);p&&(h.x&&(f+=h.x),h.y&&(g+=h.y)),n.push([f,g])}{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],i=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=i,a.size.y=o;const h=n[0],l=n[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}}},4789(e,t,s){const r=s(4419),n=(e,t,s,n,i,o,a,h,l,c,d,u,p,f)=>new r(e,t,s,n,i,o,a,h,l,c,d,u,p,f);e.exports={gameNode:n,BaseNode:class{constructor({color:e,onClick:t,coordinates2d:s,border:r,fill:i,textInfo:o,assetInfo:a,playerIds:h,effects:l,input:c,subtype:d,node:u,id:p,onHover:f,offHover:g}){this.node=u||n(e,t,s,r,i,o,a,h,l,c,d,p,f,g),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")}}}},3872(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,n=Math.floor(Math.random()*r.length);return t[r[n]]}}},2706(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)}}}},9930(e,t,s){const r=s(9990),n=s(675),{gameNode:i,BaseNode:o}=s(4789),a={[r.CIRCLE]:n.SHAPE_2D_CIRCLE,[r.POLYGON]:n.SHAPE_2D_POLYGON,[r.LINE]:n.SHAPE_2D_LINE},h={[n.SHAPE_2D_CIRCLE]:r.CIRCLE,[n.SHAPE_2D_POLYGON]:r.POLYGON,[n.SHAPE_2D_LINE]:r.LINE};class l extends o{constructor({color:e,onClick:t,shapeType:s,coordinates2d:r,border:n,fill:i,playerIds:o,effects:h,input:l,node:c,id:d,onHover:u,offHover:p}){if(!(r&&s||c))throw new Error("Shape requires coordinates2d and shapeType");super({color:e,onClick:t,coordinates2d:r,border:n,fill:i,playerIds:o,effects:h,input:l,node:c,subtype:a[s],id:d,onHover:u,offHover:p})}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:i}){if(!e&&!r)throw new Error("Text node requires textInfo");super({textInfo:e,playerIds:t,input:s,node:r,subtype:n.TEXT,id:i})}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:i,node:o,id:a,onHover:h,offHover:l}){if(!e&&!o)throw new Error("Asset node requires assetInfo");super({assetInfo:e,onClick:t,coordinates2d:s,playerIds:r,effects:i,node:o,subtype:n.ASSET,id:a,onHover:h,offHover:l})}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={Asset:d,Shape:l,Text:c};e.exports={gameNode:i,GameNode:u}},4419(e){e.exports=class{constructor(e,t,s,r,n,i,o,a=[],h=null,l=null,c=null,d=null,u,p){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=n,this.text=i,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}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}}},9990(e){e.exports={CIRCLE:1,POLYGON:2,LINE:3}},711(e,t,s){const{GameNode:r}=s(9930),n=s(9990),i=s(3485),o=s(3872),a=s(2706);e.exports=class extends a{constructor(e){var t;super(),this.planeSize=e,this.plane=(t=this.planeSize,new r.Shape({shapeType:n.POLYGON,coordinates2d:i.rectangle(0,0,t,t)})),this.fakeRoot=new r.Shape({shapeType:n.POLYGON,coordinates2d:i.rectangle(0,0,0,0),fill:o.COLORS.BLACK}),this.layers=[{root:this.fakeRoot}]}updatePlaneSize(e){this.planeSize=e,this.plane.node.coordinates2d=i.rectangle(0,0,e,e)}getLayers(){return this.layers}getPlane(){return this.plane}getPlaneSize(){return this.planeSize}getViewRoot(){return this.fakeRoot}}},1416(e,t,s){const{GameNode:r}=s(9930);e.exports={CONSTRUCTOR_TO_TYPE:{Asset:1,Shape:2,Text:3},TYPE_TO_CONSTRUCTOR:{1:r.Asset,2:r.Shape,3:r.Text}}},9807(e){e.exports={getPath:(e,t,s,r,n=100,i=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>n||l<0||l>i){let e=h,t=l;h<0?e=0:h>n&&(e=n),l<0?t=0:l>i&&(t=i),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}}},3317(e,t,s){const r=s(4419),{CONSTRUCTOR_TO_TYPE:n,TYPE_TO_CONSTRUCTOR:i}=s(1416),o=s(8018),{squishId:a}=s(6342),{squishColor:h}=s(7844),{squishPlayerIds:l}=s(754),{squishPos:c}=s(6589),{squishFill:d}=s(4562),{squishSize:u}=s(9378),{squishHandleClick:p}=s(4817),{squishBorder:f}=s(9537),{squishSubType:g}=s(3557),{squishInput:m}=s(9627),{squishCoordinates2d:y}=s(2882),{squishEffect:x}=s(7266),{squishText:v}=s(8364),{squishAsset:w}=s(2887),b={id:a,color:h,playerIds:l,pos:c,coordinates2d:y,fill:d,size:u,text:v,asset:w,effects:x,handleClick:p,border:f,subType:g,input:m},E={};for(const e in b)E[Number(b[e].type)]=e;e.exports={squish:(e,t=null)=>{let s=[];const r=e.node,i=(()=>{const e=Object.keys(b).filter(e=>b[e].dependsOn&&b[e].dependsOn.length>0);return[Object.keys(b).filter(e=>!b[e].dependsOn||0===b[e].dependsOn.length),e].flat()})();for(const e in i){const n=i[e];if(n in r){const e=r[n];if(null!=e){const i=b[n].squish(e,t,r),o=i.length+3,a=Math.min(255,o),h=Math.min(255,Math.max(0,o-255));s.push([b[n].type,h,a,...i])}}}let a=n[e.constructor.name];a||(a=n[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],n=e[t+1]+e[t+2],i=e.slice(t+3,t+n);if(!E[r]){console.warn("Unknown sub frame type "+r);break}{const e=E[r],t=(0,b[e].unsquish)(i,Object.assign({},s));s[e]=t}t+=n}const n=i[e[4]];return n?new n({node:s}):{node:s}}}},2887(e,t,s){const{getFractional:r}=s(5491),n={type:48,squish:(e,t)=>{const s=Object.keys(e)[0],n=new Array(18+s.length),i=e[s],o=t?t.x*i.pos.x+Math.round(100*(1-t.x))/2:i.pos.x,a=t?t.y*i.pos.y+Math.round(100*(1-t.y))/2:i.pos.y,h=t?t.x*i.size.x:i.size.x,l=t?t.y*i.size.y:i.size.y,c=i.startTime||0,d=i.cropLeft||0,u=i.cropTop||0,p=i.cropRight||0,f=i.cropBottom||0;n[0]=Math.floor(o),n[1]=r(o),n[2]=Math.floor(a),n[3]=r(a),n[4]=Math.floor(h),n[5]=r(h),n[6]=Math.floor(l),n[7]=r(l),n[8]=Math.floor(c),n[9]=r(c),n[10]=Math.floor(d),n[11]=r(d),n[12]=Math.floor(u),n[13]=r(u),n[14]=Math.floor(p),n[15]=r(p),n[16]=Math.floor(f),n[17]=r(f);for(let e=0;e<s.length;e++)n[18+e]=s.codePointAt(e);return n},unsquish:e=>{const t=e[0]+e[1]/100,s=e[2]+e[3]/100,r=e[4]+e[5]/100,n=e[6]+e[7]/100,i=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:n},startTime:i,cropLeft:o,cropTop:a,cropRight:h,cropBottom:l}}}};e.exports={ASSET_SUBTYPE:48,squishAsset:n}},9537(e){e.exports={BORDER_SUBTYPE:54,squishBorder:{type:54,squish:e=>[e],unsquish:e=>e[0]}}},7844(e){e.exports={COLOR_SUBTYPE:42,squishColor:{type:42,squish:e=>[e[0],e[1],e[2],e[3]],unsquish:e=>[e[0],e[1],e[2],e[3]]}}},2882(e,t,s){const{getFractional:r}=s(5491),n=s(675),i=e=>e<0?0:e>255?255:e,o=(e,t)=>e*t+Math.round(100*(1-e))/2,a={type:52,squish:(e,t,s)=>{const a=e.flat(),h=new Array(2*a.length);if(s.subType==n.SHAPE_2D_CIRCLE)if(t){const e=i(o(t.x,a[0]));h[0]=Math.floor(e),h[1]=r(e);const s=i(o(t.y,a[1]));let n;h[2]=Math.floor(s),h[3]=r(s),n=t.x===t.y?t.x*a[2]:Math.sqrt(Math.pow(100*t.x,2)+Math.pow(100*t.y,2))*(a[2]/100),h[4]=Math.floor(n),h[5]=r(n)}else{const e=i(a[0]);h[0]=Math.floor(e),h[1]=r(e);const t=i(a[1]);h[2]=Math.floor(t),h[3]=r(t);const s=a[2];h[4]=Math.round(s),h[5]=r(s)}else for(const e in a)if(t){const s=e%2==0?t.x:t.y,n=s*a[e],o=Math.round(100*(1-s)),l=i(n+o/2);h[2*e]=Math.floor(l),h[2*e+1]=r(l)}else{const t=i(a[e]);h[2*e]=Math.floor(t),h[2*e+1]=Math.round(100*(t-Math.floor(t)))}return h},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===n.SHAPE_2D_POLYGON||t===n.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={COORDINATES_2D_SUBTYPE:52,squishCoordinates2d:a}},7266(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 n={[t]:{color:s}};return r&&(n[t].blur=r),n}};e.exports={EFFECTS_SUBTYPE:49,squishEffect:t}},4562(e){e.exports={FILL_SUBTYPE:53,squishFill:{type:53,squish:e=>[e[0],e[1],e[2],e[3]],unsquish:e=>[e[0],e[1],e[2],e[3]]}}},4817(e){e.exports={ONCLICK_SUBTYPE:50,squishHandleClick:{type:50,squish:e=>e?[1]:[0],unsquish:e=>1===e[0]}}},6342(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={ID_SUBTYPE:43,squishId:t}},9627(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={INPUT_SUBTYPE:51,squishInput:t}},754(e){e.exports={PLAYER_ID_SUBTYPE:44,squishPlayerIds:{type:44,squish:e=>e,unsquish:e=>e}}},6589(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={POS_SUBTYPE:45,squishPos:s}},9378(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={SIZE_SUBTYPE:46,squishSize:s}},3557(e){e.exports={SUBTYPE_TYPE:55,squishSubType:{type:55,squish:e=>[e],unsquish:e=>e[0]}}},8364(e,t,s){const{hypLength:r}=s(5491),n=s(3872),{squishColor:i}=s(7844),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||n.BLACK,p=i.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 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+p.length+2+3*[...a].length;l[r+g]=Number(s[0]),l[r+g+1]=Number(s[1]),l[r+g+2]=Number(s[2]),g+=3}let m=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 n=6+p.length+2+3*[...a].length+3*[...h].length;l[n+m]=Number(r[0]),l[n+m+1]=Number(r[1]),l[n+m+2]=Number(r[2]),m+=3}return l},unsquish:e=>{const t=e[0]+e[1]/100,s=e[2]+e[3]/100,r=e[4]+e[5]/100,n=e.slice(6,10),i=e[10],o=e[11],a=e.slice(12,12+i),h=e.slice(12+i,12+i+o),l=e.slice(12+i+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 n=t+s+r;c.push(n)}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 n=t+s+r;u.push(n)}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 n=t+s+r;f.push(n)}return{x:t,y:s,text:String.fromCodePoint.apply(null,f),size:r,color:n,align:d,font:p}}};e.exports={TEXT_SUBTYPE:47,squishText:o}},8018(e,t,s){const{GameNode:r}=s(9930),n=s(675);e.exports={[[n.ASSET]]:r.Asset,[[n.TEXT]]:r.Text,[[n.SHAPE_2D_POLYGON]]:r.Shape,[[n.SHAPE_2D_CIRCLE]]:r.Shape,[[n.SHAPE_2D_LINE]]:r.Shape}},675(e){e.exports={ASSET:1,TEXT:2,SHAPE_2D_POLYGON:3,SHAPE_2D_CIRCLE:4,SHAPE_2D_LINE:5}},7004(e,t,s){const{getRandomTerrain:r,getRandomStartPoint:n}=s(5988),i=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,n(a,h,t),a,h,t);const d=((e,t,s,r)=>{const n=[];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(n.findIndex(e=>e.x===a.x&&e.y===a.y)>-1||a.x===t.x&&a.y===t.y||s.filled){n.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}}i(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:n}=((e,t)=>{const s=e.x,r=e.y,n=t.x,i=t.y;return{width:Math.floor(s/n),height:Math.floor(r/i)}})(e,t);let i=((e,t)=>{const s=[],r={filled:!1,north:!0,south:!0,east:!0,west:!0};for(let n=0;n<e;n++){s[n]=[];for(let i=0;i<t;i++){const o={...r};0===n?o.west=!1:n===e-1&&(o.east=!1),0===i?o.north=!1:i===t-1&&(o.south=!1),s[n].push(o)}}return s})(r,n);const a={x:Math.floor(Math.random()*r),y:Math.floor(Math.random()*n)};return i=o(i,a,s,r,n),i}}},5988(e){const t=(e,{x:t,y:s},r,n,i)=>{t<0||t>=r||s<0||s>=n||t===i.x&&s===i.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},n,i,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},n,i,o),0===a?(t(e,{x:s+1,y:r},n,i,o),t(e,{x:s,y:r+1},n,i,o),t(e,{x:s+1,y:r+1},n,i,o)):1===a?(t(e,{x:s-1,y:r},n,i,o),t(e,{x:s,y:r+1},n,i,o),t(e,{x:s-1,y:r+1},n,i,o)):2===a?(t(e,{x:s,y:r-1},n,i,o),t(e,{x:s+1,y:r},n,i,o),t(e,{x:s+1,y:r-1},n,i,o)):(t(e,{x:s,y:r-1},n,i,o),t(e,{x:s-1,y:r},n,i,o),t(e,{x:s-1,y:r-1},n,i,o))},(e,{x:s,y:r},n,i,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},n,i,o),0===a?(t(e,{x:s,y:r+1},n,i,o),t(e,{x:s,y:r+2},n,i,o),t(e,{x:s,y:r+3},n,i,o)):1===a?(t(e,{x:s+1,y:r},n,i,o),t(e,{x:s+2,y:r},n,i,o),t(e,{x:s+3,y:r},n,i,o)):2===a?(t(e,{x:s-1,y:r},n,i,o),t(e,{x:s-2,y:r},n,i,o),t(e,{x:s-3,y:r},n,i,o)):(t(e,{x:s,y:r-1},n,i,o),t(e,{x:s,y:r-2},n,i,o),t(e,{x:s,y:r-3},n,i,o))},(e,{x:s,y:r},n,i,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},n,i,o),0===a?(t(e,{x:s,y:r+1},n,i,o),t(e,{x:s,y:r+2},n,i,o),t(e,{x:s+1,y:r+2},n,i,o)):1===a?(t(e,{x:s+1,y:r},n,i,o),t(e,{x:s+2,y:r},n,i,o),t(e,{x:s+2,y:r-1},n,i,o)):2===a?(t(e,{x:s-1,y:r},n,i,o),t(e,{x:s-2,y:r},n,i,o),t(e,{x:s-2,y:r+1},n,i,o)):(t(e,{x:s,y:r-1},n,i,o),t(e,{x:s,y:r-2},n,i,o),t(e,{x:s-1,y:r-2},n,i,o))},(e,{x:s,y:r},n,i,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},n,i,o),0===a?(t(e,{x:s,y:r+1},n,i,o),t(e,{x:s-1,y:r+1},n,i,o),t(e,{x:s-1,y:r+2},n,i,o)):1===a?(t(e,{x:s+1,y:r},n,i,o),t(e,{x:s+1,y:r+1},n,i,o),t(e,{x:s+2,y:r+1},n,i,o)):2===a?(t(e,{x:s-1,y:r},n,i,o),t(e,{x:s-1,y:r+1},n,i,o),t(e,{x:s-2,y:r+1},n,i,o)):(t(e,{x:s,y:r-1},n,i,o),t(e,{x:s-1,y:r-1},n,i,o),t(e,{x:s-1,y:r-2},n,i,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}}},799(e){const t=(e,s,r,n=[])=>{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]],i=s.node.coordinates2d,o=r[0][0],a=r[1][0],h=i[0][0],l=i[1][0],c=r[0][1],d=r[2][1],u=i[0][1],p=i[2][1];l<o||a<h||c>p||u>d||n.push(e)}for(const i in e.node.children)t(e.node.children[i],s,r,n);return n};e.exports={checkCollisions:(e,s,r=null)=>t(e,s,r)}},5491(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)))}},3485(e){e.exports={triangle:(e,t,s,r,n,i)=>[[e,t],[s,r],[n,i],[e,t]],rectangle:(e,t,s,r)=>[[e,t],[e+s,t],[e+s,t+r],[e,t+r],[e,t]]}},177(e,t,s){const{GameNode:r}=s(9930),n=s(9990),i=s(3485),o=s(799),a=s(3872);e.exports={getView:(e,t,s,h={},l={})=>{const c=o.checkCollisions(e,{node:{coordinates2d:i.rectangle(t.x,t.y,t.w,t.h)}},t=>t.node.id!==e.node.id),d=new r.Shape({shapeType:n.POLYGON,coordinates2d:i.rectangle(0,0,0,0),fill:a.COLORS.BLACK}),u=[];return c.length>0&&c.forEach(e=>{const r=[],n=[],i=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 i){const o=i[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),g=(l.y||1)*(c-t.y);p&&(h.x&&(f+=h.x),h.y&&(g+=h.y)),n.push([f,g])}{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],i=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=i,a.size.y=o;const h=n[0],l=n[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}}},1563(e,t,s){const r=s(7457),n=(e,t,s,n,i,o,a,h,l,c,d,u,p,f,g,m)=>new r(e,t,s,n,i,o,a,h,l,c,d,u,p,f,g,m);e.exports={gameNode:n,BaseNode:class{constructor({color:e,onClick:t,coordinates2d:s,border:r,fill:i,textInfo:o,assetInfo:a,playerIds:h,effects:l,input:c,subtype:d,node:u,id:p,onHover:f,offHover:g,onDrag:m,offClick:y}){this.node=u||n(e,t,s,r,i,o,a,h,l,c,d,p,f,g,m,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")}}}},3002(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,n=Math.floor(Math.random()*r.length);return t[r[n]]}}},2212(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)}}}},6308(e,t,s){const r=s(2316),n=s(6541),{gameNode:i,BaseNode:o}=s(1563),a={[r.CIRCLE]:n.SHAPE_2D_CIRCLE,[r.POLYGON]:n.SHAPE_2D_POLYGON,[r.LINE]:n.SHAPE_2D_LINE},h={[n.SHAPE_2D_CIRCLE]:r.CIRCLE,[n.SHAPE_2D_POLYGON]:r.POLYGON,[n.SHAPE_2D_LINE]:r.LINE};class l extends o{constructor({color:e,onClick:t,shapeType:s,coordinates2d:r,border:n,fill:i,playerIds:o,effects:h,input:l,node:c,id:d,onHover:u,offHover:p,onDrag:f,offClick:g}){if(!(r&&s||c))throw new Error("Shape requires coordinates2d and shapeType");super({color:e,onClick:t,coordinates2d:r,border:n,fill:i,playerIds:o,effects:h,input:l,node:c,subtype:a[s],id:d,onHover:u,offHover:p,onDrag:f,offClick:g})}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:i,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:n.TEXT,id:i,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:i,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:i,node:o,subtype:n.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={Asset:d,Shape:l,Text:c};e.exports={gameNode:i,GameNode:u}},7457(e){e.exports=class{constructor(e,t,s,r,n,i,o,a=[],h=null,l=null,c=null,d=null,u,p,f,g){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=n,this.text=i,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=g}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}}},2316(e){e.exports={CIRCLE:1,POLYGON:2,LINE:3}},6525(e,t,s){const{GameNode:r}=s(6308),n=s(2316),i=s(7043),o=s(3002),a=s(2212);e.exports=class extends a{constructor(e){var t;super(),this.planeSize=e,this.plane=(t=this.planeSize,new r.Shape({shapeType:n.POLYGON,coordinates2d:i.rectangle(0,0,t,t)})),this.fakeRoot=new r.Shape({shapeType:n.POLYGON,coordinates2d:i.rectangle(0,0,0,0),fill:o.COLORS.BLACK}),this.layers=[{root:this.fakeRoot}]}updatePlaneSize(e){this.planeSize=e,this.plane.node.coordinates2d=i.rectangle(0,0,e,e)}getLayers(){return this.layers}getPlane(){return this.plane}getPlaneSize(){return this.planeSize}getViewRoot(){return this.fakeRoot}}},2330(e,t,s){const{GameNode:r}=s(6308);e.exports={CONSTRUCTOR_TO_TYPE:{Asset:1,Shape:2,Text:3},TYPE_TO_CONSTRUCTOR:{1:r.Asset,2:r.Shape,3:r.Text}}},6021(e){e.exports={getPath:(e,t,s,r,n=100,i=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>n||l<0||l>i){let e=h,t=l;h<0?e=0:h>n&&(e=n),l<0?t=0:l>i&&(t=i),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}}},4003(e,t,s){const r=s(7457),{CONSTRUCTOR_TO_TYPE:n,TYPE_TO_CONSTRUCTOR:i}=s(2330),o=s(260),{squishId:a}=s(3280),{squishColor:h}=s(3114),{squishPlayerIds:l}=s(7536),{squishPos:c}=s(4267),{squishFill:d}=s(1968),{squishSize:u}=s(9124),{squishHandleClick:p}=s(3855),{squishOnHover:f}=s(2052),{squishBorder:g}=s(2459),{squishSubType:m}=s(923),{squishInput:y}=s(8517),{squishCoordinates2d:x}=s(2684),{squishEffect:v}=s(5808),{squishText:w}=s(3718),{squishAsset:b}=s(949),E={id:a,color:h,playerIds:l,pos:c,coordinates2d:x,fill:d,size:u,text:w,asset:b,effects:v,handleClick:p,onHover:f,border:g,subType:m,input:y},S={};for(const e in E)S[Number(E[e].type)]=e;e.exports={squish:(e,t=null)=>{let s=[];const r=e.node,i=(()=>{const e=Object.keys(E).filter(e=>E[e].dependsOn&&E[e].dependsOn.length>0);return[Object.keys(E).filter(e=>!E[e].dependsOn||0===E[e].dependsOn.length),e].flat()})();for(const e in i){const n=i[e];if(n in r){const e=r[n];if(null!=e){const i=E[n].squish(e,t,r),o=i.length+3,a=Math.min(255,o),h=Math.min(255,Math.max(0,o-255));s.push([E[n].type,h,a,...i])}}}let a=n[e.constructor.name];a||(a=n[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],n=e[t+1]+e[t+2],i=e.slice(t+3,t+n);if(!S[r]){console.warn("Unknown sub frame type "+r);break}{const e=S[r],t=(0,E[e].unsquish)(i,Object.assign({},s));s[e]=t}t+=n}const n=i[e[4]];return n?new n({node:s}):{node:s}}}},949(e,t,s){const{getFractional:r}=s(5841),n={type:48,squish:(e,t)=>{const s=Object.keys(e)[0],n=new Array(18+s.length),i=e[s],o=t?t.x*i.pos.x+Math.round(100*(1-t.x))/2:i.pos.x,a=t?t.y*i.pos.y+Math.round(100*(1-t.y))/2:i.pos.y,h=t?t.x*i.size.x:i.size.x,l=t?t.y*i.size.y:i.size.y,c=i.startTime||0,d=i.cropLeft||0,u=i.cropTop||0,p=i.cropRight||0,f=i.cropBottom||0;n[0]=Math.floor(o),n[1]=r(o),n[2]=Math.floor(a),n[3]=r(a),n[4]=Math.floor(h),n[5]=r(h),n[6]=Math.floor(l),n[7]=r(l),n[8]=Math.floor(c),n[9]=r(c),n[10]=Math.floor(d),n[11]=r(d),n[12]=Math.floor(u),n[13]=r(u),n[14]=Math.floor(p),n[15]=r(p),n[16]=Math.floor(f),n[17]=r(f);for(let e=0;e<s.length;e++)n[18+e]=s.codePointAt(e);return n},unsquish:e=>{const t=e[0]+e[1]/100,s=e[2]+e[3]/100,r=e[4]+e[5]/100,n=e[6]+e[7]/100,i=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:n},startTime:i,cropLeft:o,cropTop:a,cropRight:h,cropBottom:l}}}};e.exports={ASSET_SUBTYPE:48,squishAsset:n}},2459(e){e.exports={BORDER_SUBTYPE:54,squishBorder:{type:54,squish:e=>[e],unsquish:e=>e[0]}}},3114(e){e.exports={COLOR_SUBTYPE:42,squishColor:{type:42,squish:e=>[e[0],e[1],e[2],e[3]],unsquish:e=>[e[0],e[1],e[2],e[3]]}}},2684(e,t,s){const{getFractional:r}=s(5841),n=s(6541),i=e=>e<0?0:e>255?255:e,o=(e,t)=>e*t+Math.round(100*(1-e))/2,a={type:52,squish:(e,t,s)=>{const a=e.flat(),h=new Array(2*a.length);if(s.subType==n.SHAPE_2D_CIRCLE)if(t){const e=i(o(t.x,a[0]));h[0]=Math.floor(e),h[1]=r(e);const s=i(o(t.y,a[1]));let n;h[2]=Math.floor(s),h[3]=r(s),n=t.x===t.y?t.x*a[2]:Math.sqrt(Math.pow(100*t.x,2)+Math.pow(100*t.y,2))*(a[2]/100),h[4]=Math.floor(n),h[5]=r(n)}else{const e=i(a[0]);h[0]=Math.floor(e),h[1]=r(e);const t=i(a[1]);h[2]=Math.floor(t),h[3]=r(t);const s=a[2];h[4]=Math.round(s),h[5]=r(s)}else for(const e in a)if(t){const s=e%2==0?t.x:t.y,n=s*a[e],o=Math.round(100*(1-s)),l=i(n+o/2);h[2*e]=Math.floor(l),h[2*e+1]=r(l)}else{const t=i(a[e]);h[2*e]=Math.floor(t),h[2*e+1]=Math.round(100*(t-Math.floor(t)))}return h},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===n.SHAPE_2D_POLYGON||t===n.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={COORDINATES_2D_SUBTYPE:52,squishCoordinates2d:a}},5808(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 n={[t]:{color:s}};return r&&(n[t].blur=r),n}};e.exports={EFFECTS_SUBTYPE:49,squishEffect:t}},1968(e){e.exports={FILL_SUBTYPE:53,squishFill:{type:53,squish:e=>[e[0],e[1],e[2],e[3]],unsquish:e=>[e[0],e[1],e[2],e[3]]}}},3855(e){e.exports={ONCLICK_SUBTYPE:50,squishHandleClick:{type:50,squish:e=>e?[1]:[0],unsquish:e=>1===e[0]}}},3280(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={ID_SUBTYPE:43,squishId:t}},8517(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={INPUT_SUBTYPE:51,squishInput:t}},2052(e){e.exports={ONHOVER_SUBTYPE:56,squishOnHover:{type:56,squish:e=>e?[1]:[0],unsquish:e=>1===e[0]}}},7536(e){e.exports={PLAYER_ID_SUBTYPE:44,squishPlayerIds:{type:44,squish:e=>e,unsquish:e=>e}}},4267(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={POS_SUBTYPE:45,squishPos:s}},9124(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={SIZE_SUBTYPE:46,squishSize:s}},923(e){e.exports={SUBTYPE_TYPE:55,squishSubType:{type:55,squish:e=>[e],unsquish:e=>e[0]}}},3718(e,t,s){const{hypLength:r}=s(5841),n=s(3002),{squishColor:i}=s(3114),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||n.BLACK,p=i.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 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+p.length+2+3*[...a].length;l[r+g]=Number(s[0]),l[r+g+1]=Number(s[1]),l[r+g+2]=Number(s[2]),g+=3}let m=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 n=6+p.length+2+3*[...a].length+3*[...h].length;l[n+m]=Number(r[0]),l[n+m+1]=Number(r[1]),l[n+m+2]=Number(r[2]),m+=3}return l},unsquish:e=>{const t=e[0]+e[1]/100,s=e[2]+e[3]/100,r=e[4]+e[5]/100,n=e.slice(6,10),i=e[10],o=e[11],a=e.slice(12,12+i),h=e.slice(12+i,12+i+o),l=e.slice(12+i+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 n=t+s+r;c.push(n)}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 n=t+s+r;u.push(n)}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 n=t+s+r;f.push(n)}return{x:t,y:s,text:String.fromCodePoint.apply(null,f),size:r,color:n,align:d,font:p}}};e.exports={TEXT_SUBTYPE:47,squishText:o}},260(e,t,s){const{GameNode:r}=s(6308),n=s(6541);e.exports={[[n.ASSET]]:r.Asset,[[n.TEXT]]:r.Text,[[n.SHAPE_2D_POLYGON]]:r.Shape,[[n.SHAPE_2D_CIRCLE]]:r.Shape,[[n.SHAPE_2D_LINE]]:r.Shape}},6541(e){e.exports={ASSET:1,TEXT:2,SHAPE_2D_POLYGON:3,SHAPE_2D_CIRCLE:4,SHAPE_2D_LINE:5}},10(e,t,s){const{getRandomTerrain:r,getRandomStartPoint:n}=s(182),i=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,n(a,h,t),a,h,t);const d=((e,t,s,r)=>{const n=[];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(n.findIndex(e=>e.x===a.x&&e.y===a.y)>-1||a.x===t.x&&a.y===t.y||s.filled){n.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}}i(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:n}=((e,t)=>{const s=e.x,r=e.y,n=t.x,i=t.y;return{width:Math.floor(s/n),height:Math.floor(r/i)}})(e,t);let i=((e,t)=>{const s=[],r={filled:!1,north:!0,south:!0,east:!0,west:!0};for(let n=0;n<e;n++){s[n]=[];for(let i=0;i<t;i++){const o={...r};0===n?o.west=!1:n===e-1&&(o.east=!1),0===i?o.north=!1:i===t-1&&(o.south=!1),s[n].push(o)}}return s})(r,n);const a={x:Math.floor(Math.random()*r),y:Math.floor(Math.random()*n)};return i=o(i,a,s,r,n),i}}},182(e){const t=(e,{x:t,y:s},r,n,i)=>{t<0||t>=r||s<0||s>=n||t===i.x&&s===i.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},n,i,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},n,i,o),0===a?(t(e,{x:s+1,y:r},n,i,o),t(e,{x:s,y:r+1},n,i,o),t(e,{x:s+1,y:r+1},n,i,o)):1===a?(t(e,{x:s-1,y:r},n,i,o),t(e,{x:s,y:r+1},n,i,o),t(e,{x:s-1,y:r+1},n,i,o)):2===a?(t(e,{x:s,y:r-1},n,i,o),t(e,{x:s+1,y:r},n,i,o),t(e,{x:s+1,y:r-1},n,i,o)):(t(e,{x:s,y:r-1},n,i,o),t(e,{x:s-1,y:r},n,i,o),t(e,{x:s-1,y:r-1},n,i,o))},(e,{x:s,y:r},n,i,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},n,i,o),0===a?(t(e,{x:s,y:r+1},n,i,o),t(e,{x:s,y:r+2},n,i,o),t(e,{x:s,y:r+3},n,i,o)):1===a?(t(e,{x:s+1,y:r},n,i,o),t(e,{x:s+2,y:r},n,i,o),t(e,{x:s+3,y:r},n,i,o)):2===a?(t(e,{x:s-1,y:r},n,i,o),t(e,{x:s-2,y:r},n,i,o),t(e,{x:s-3,y:r},n,i,o)):(t(e,{x:s,y:r-1},n,i,o),t(e,{x:s,y:r-2},n,i,o),t(e,{x:s,y:r-3},n,i,o))},(e,{x:s,y:r},n,i,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},n,i,o),0===a?(t(e,{x:s,y:r+1},n,i,o),t(e,{x:s,y:r+2},n,i,o),t(e,{x:s+1,y:r+2},n,i,o)):1===a?(t(e,{x:s+1,y:r},n,i,o),t(e,{x:s+2,y:r},n,i,o),t(e,{x:s+2,y:r-1},n,i,o)):2===a?(t(e,{x:s-1,y:r},n,i,o),t(e,{x:s-2,y:r},n,i,o),t(e,{x:s-2,y:r+1},n,i,o)):(t(e,{x:s,y:r-1},n,i,o),t(e,{x:s,y:r-2},n,i,o),t(e,{x:s-1,y:r-2},n,i,o))},(e,{x:s,y:r},n,i,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},n,i,o),0===a?(t(e,{x:s,y:r+1},n,i,o),t(e,{x:s-1,y:r+1},n,i,o),t(e,{x:s-1,y:r+2},n,i,o)):1===a?(t(e,{x:s+1,y:r},n,i,o),t(e,{x:s+1,y:r+1},n,i,o),t(e,{x:s+2,y:r+1},n,i,o)):2===a?(t(e,{x:s-1,y:r},n,i,o),t(e,{x:s-1,y:r+1},n,i,o),t(e,{x:s-2,y:r+1},n,i,o)):(t(e,{x:s,y:r-1},n,i,o),t(e,{x:s-1,y:r-1},n,i,o),t(e,{x:s-1,y:r-2},n,i,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}}},6897(e){const t=(e,s,r,n=[])=>{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]],i=s.node.coordinates2d,o=r[0][0],a=r[1][0],h=i[0][0],l=i[1][0],c=r[0][1],d=r[2][1],u=i[0][1],p=i[2][1];l<o||a<h||c>p||u>d||n.push(e)}for(const i in e.node.children)t(e.node.children[i],s,r,n);return n};e.exports={checkCollisions:(e,s,r=null)=>t(e,s,r)}},5841(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)))}},7043(e){e.exports={triangle:(e,t,s,r,n,i)=>[[e,t],[s,r],[n,i],[e,t]],rectangle:(e,t,s,r)=>[[e,t],[e+s,t],[e+s,t+r],[e,t+r],[e,t]]}},6967(e,t,s){const{GameNode:r}=s(6308),n=s(2316),i=s(7043),o=s(6897),a=s(3002);e.exports={getView:(e,t,s,h={},l={})=>{const c=o.checkCollisions(e,{node:{coordinates2d:i.rectangle(t.x,t.y,t.w,t.h)}},t=>t.node.id!==e.node.id),d=new r.Shape({shapeType:n.POLYGON,coordinates2d:i.rectangle(0,0,0,0),fill:a.COLORS.BLACK}),u=[];return c.length>0&&c.forEach(e=>{const r=[],n=[],i=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 i){const o=i[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),g=(l.y||1)*(c-t.y);p&&(h.x&&(f+=h.x),h.y&&(g+=h.y)),n.push([f,g])}{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],i=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=i,a.size.y=o;const h=n[0],l=n[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}}},688(e,t,s){const{squish:r,unsquish:n}=s(7208),{gameNode:i,GameNode:o}=s(1267),a=(s(7478),s(9173)),h=s(7903),l=s(8406),c=s(7643),d=s(6734),u=s(436),{terrainGenerator:p}=s(967),f=s(3802),g=s(8231),m=s(8257),y=s(5864),x=s(280);e.exports={squish:r,unsquish:n,gameNode:i,subtypes:f,Game:h,ViewableGame:l,GameNode:o,Colors:a,Shapes:c,Squisher:g,ShapeUtils:d,ViewUtils:u,TerrainGenerator:p,GeometryUtils:y,Asset:m,Physics:x}},8257(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"))}}},6364(e,t,s){const r=s(7478),n=(e,t,s,n,i,o,a,h,l,c,d,u,p,f,g,m)=>new r(e,t,s,n,i,o,a,h,l,c,d,u,p,f,g,m);e.exports={gameNode:n,BaseNode:class{constructor({color:e,onClick:t,coordinates2d:s,border:r,fill:i,textInfo:o,assetInfo:a,playerIds:h,effects:l,input:c,subtype:d,node:u,id:p,onHover:f,offHover:g,onDrag:m,offClick:y}){this.node=u||n(e,t,s,r,i,o,a,h,l,c,d,p,f,g,m,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")}}}},9173(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,n=Math.floor(Math.random()*r.length);return t[r[n]]}}},7903(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)}}}},1267(e,t,s){const r=s(7643),n=s(3802),{gameNode:i,BaseNode:o}=s(6364),a={[r.CIRCLE]:n.SHAPE_2D_CIRCLE,[r.POLYGON]:n.SHAPE_2D_POLYGON,[r.LINE]:n.SHAPE_2D_LINE},h={[n.SHAPE_2D_CIRCLE]:r.CIRCLE,[n.SHAPE_2D_POLYGON]:r.POLYGON,[n.SHAPE_2D_LINE]:r.LINE};class l extends o{constructor({color:e,onClick:t,shapeType:s,coordinates2d:r,border:n,fill:i,playerIds:o,effects:h,input:l,node:c,id:d,onHover:u,offHover:p,onDrag:f,offClick:g}){if(!(r&&s||c))throw new Error("Shape requires coordinates2d and shapeType");super({color:e,onClick:t,coordinates2d:r,border:n,fill:i,playerIds:o,effects:h,input:l,node:c,subtype:a[s],id:d,onHover:u,offHover:p,onDrag:f,offClick:g})}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:i,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:n.TEXT,id:i,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:i,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:i,node:o,subtype:n.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:i,...o}){if(!i&&!/^[A-Za-z0-9-]{1,64}$/.test(e||""))throw new Error("Stream requires a valid streamId");super({...o,node:i,subtype:n.STREAM}),i||(this.node.stream={id:e,pos:t,size:s,audio:!!r})}},Asset:d,Shape:l,Text:c};e.exports={gameNode:i,GameNode:u}},7478(e){e.exports=class{constructor(e,t,s,r,n,i,o,a=[],h=null,l=null,c=null,d=null,u,p,f,g){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=n,this.text=i,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=g}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}}},7643(e){e.exports={CIRCLE:1,POLYGON:2,LINE:3}},8231(e,t,s){const{squish:r,unsquish:n}=s(7208);e.exports=class{constructor({game:e,scale:t,customBottomLayer:s,customTopLayer:i,onAssetUpdate:o,encodeNode:a=r,decodeNode:h=n,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=i,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,n)=>{if(!e?.node)return;this.observedNodes.has(e)||(e.addListener(this),this.observedNodes.add(e)),s.add(e);const i=e.node.playerIds,o=i?.length?[...n,i.map(Number)]:n;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 n=this.playerSettings[t]&&this.playerSettings[t].SOUND;return!(!n||!1!==n.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(8410).loadAssetBundle,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]}}},8406(e,t,s){const{GameNode:r}=s(1267),n=s(7643),i=s(6734),o=s(9173),a=s(7903);e.exports=class extends a{constructor(e){var t;super(),this.planeSize=e,this.plane=(t=this.planeSize,new r.Shape({shapeType:n.POLYGON,coordinates2d:i.rectangle(0,0,t,t)})),this.fakeRoot=new r.Shape({shapeType:n.POLYGON,coordinates2d:i.rectangle(0,0,0,0),fill:o.COLORS.BLACK}),this.layers=[{root:this.fakeRoot}]}updatePlaneSize(e){this.planeSize=e,this.plane.node.coordinates2d=i.rectangle(0,0,e,e)}getLayers(){return this.layers}getPlane(){return this.plane}getPlaneSize(){return this.planeSize}getViewRoot(){return this.fakeRoot}}},8410(e){const t={image:1,audio:2,font:3,video:4};e.exports={loadAssetBundle:async function(e,s=Object.create(null)){const r=[];for(const[n,i]of Object.entries(e)){if(!t[i.info?.type]||!/^[\x20-\x7e]{1,32}$/.test(n))throw new Error("Invalid asset declaration: "+n);if(!Object.hasOwn(s,n)){const e=i.data;if(!(e instanceof Uint8Array))throw new Error("The host must supply local asset bytes: "+n);const r=new Uint8Array(44+e.length);r[0]=1,r[1]=t[i.info.type],r.set((new TextEncoder).encode((e.length+32).toString(36).padStart(10,"0")),2),r.set((new TextEncoder).encode(n),12),r.set(e,44),s[n]=r}r.push(s[n])}const n=new Uint8Array(r.reduce((e,t)=>e+t.length,0));let i=0;for(const e of r)n.set(e,i),i+=e.length;return n}}},2177(e,t,s){const{GameNode:r}=s(1267);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}}},280(e){e.exports={getPath:(e,t,s,r,n=100,i=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>n||l<0||l>i){let e=h,t=l;h<0?e=0:h>n&&(e=n),l<0?t=0:l>i&&(t=i),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}}},7208(e,t,s){const r=s(7478),{CONSTRUCTOR_TO_TYPE:n,TYPE_TO_CONSTRUCTOR:i}=s(2177),o=s(5647),{squishId:a}=s(2603),{squishColor:h}=s(3187),{squishPlayerIds:l}=s(3641),{squishPos:c}=s(3070),{squishFill:d}=s(3971),{squishSize:u}=s(2575),{squishHandleClick:p}=s(7666),{squishOnHover:f}=s(4017),{squishBorder:g}=s(7456),{squishSubType:m}=s(986),{squishInput:y}=s(6844),{squishCoordinates2d:x}=s(7829),{squishEffect:v}=s(3399),{squishText:w}=s(5317),{squishAsset:b}=s(2108),{squishStream:E}=s(3122),S={stream:E,id:a,color:h,playerIds:l,pos:c,coordinates2d:x,fill:d,size:u,text:w,asset:b,effects:v,handleClick:p,onHover:f,border:g,subType:m,input:y},_={};for(const e in S)_[Number(S[e].type)]=e;e.exports={squish:(e,t=null)=>{let s=[];const r=e.node,i=(()=>{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 i){const n=i[e];if(n in r){const e=r[n];if(null!=e){const i=S[n].squish(e,t,r),o=i.length+3,a=Math.min(255,o),h=Math.min(255,Math.max(0,o-255));s.push([S[n].type,h,a,...i])}}}let a=n[e.constructor.name];a||(a=n[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],n=e[t+1]+e[t+2],i=e.slice(t+3,t+n);if(!_[r]){console.warn("Unknown sub frame type "+r);break}{const e=_[r],t=(0,S[e].unsquish)(i,Object.assign({},s));s[e]=t}t+=n}const n=i[e[4]];return n?new n({node:s}):{node:s}}}},2108(e,t,s){const{getFractional:r}=s(6474),n={type:48,squish:(e,t)=>{const s=Object.keys(e)[0],n=new Array(18+s.length),i=e[s],o=t?t.x*i.pos.x+Math.round(100*(1-t.x))/2:i.pos.x,a=t?t.y*i.pos.y+Math.round(100*(1-t.y))/2:i.pos.y,h=t?t.x*i.size.x:i.size.x,l=t?t.y*i.size.y:i.size.y,c=i.startTime||0,d=i.cropLeft||0,u=i.cropTop||0,p=i.cropRight||0,f=i.cropBottom||0;n[0]=Math.floor(o),n[1]=r(o),n[2]=Math.floor(a),n[3]=r(a),n[4]=Math.floor(h),n[5]=r(h),n[6]=Math.floor(l),n[7]=r(l),n[8]=Math.floor(c),n[9]=r(c),n[10]=Math.floor(d),n[11]=r(d),n[12]=Math.floor(u),n[13]=r(u),n[14]=Math.floor(p),n[15]=r(p),n[16]=Math.floor(f),n[17]=r(f);for(let e=0;e<s.length;e++)n[18+e]=s.codePointAt(e);return n},unsquish:e=>{const t=e[0]+e[1]/100,s=e[2]+e[3]/100,r=e[4]+e[5]/100,n=e[6]+e[7]/100,i=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:n},startTime:i,cropLeft:o,cropTop:a,cropRight:h,cropBottom:l}}}};e.exports={ASSET_SUBTYPE:48,squishAsset:n}},7456(e){e.exports={BORDER_SUBTYPE:54,squishBorder:{type:54,squish:e=>[e],unsquish:e=>e[0]}}},3187(e){e.exports={COLOR_SUBTYPE:42,squishColor:{type:42,squish:e=>[e[0],e[1],e[2],e[3]],unsquish:e=>[e[0],e[1],e[2],e[3]]}}},7829(e,t,s){const{getFractional:r}=s(6474),n=s(3802),i=e=>e<0?0:e>255?255:e,o=(e,t)=>e*t+Math.round(100*(1-e))/2,a={type:52,squish:(e,t,s)=>{const a=e.flat(),h=new Array(2*a.length);if(s.subType==n.SHAPE_2D_CIRCLE)if(t){const e=i(o(t.x,a[0]));h[0]=Math.floor(e),h[1]=r(e);const s=i(o(t.y,a[1]));let n;h[2]=Math.floor(s),h[3]=r(s),n=t.x===t.y?t.x*a[2]:Math.sqrt(Math.pow(100*t.x,2)+Math.pow(100*t.y,2))*(a[2]/100),h[4]=Math.floor(n),h[5]=r(n)}else{const e=i(a[0]);h[0]=Math.floor(e),h[1]=r(e);const t=i(a[1]);h[2]=Math.floor(t),h[3]=r(t);const s=a[2];h[4]=Math.round(s),h[5]=r(s)}else for(const e in a)if(t){const s=e%2==0?t.x:t.y,n=s*a[e],o=Math.round(100*(1-s)),l=i(n+o/2);h[2*e]=Math.floor(l),h[2*e+1]=r(l)}else{const t=i(a[e]);h[2*e]=Math.floor(t),h[2*e+1]=Math.round(100*(t-Math.floor(t)))}return h},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===n.SHAPE_2D_POLYGON||t===n.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={COORDINATES_2D_SUBTYPE:52,squishCoordinates2d:a}},3399(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 n={[t]:{color:s}};return r&&(n[t].blur=r),n}};e.exports={EFFECTS_SUBTYPE:49,squishEffect:t}},3971(e){e.exports={FILL_SUBTYPE:53,squishFill:{type:53,squish:e=>[e[0],e[1],e[2],e[3]],unsquish:e=>[e[0],e[1],e[2],e[3]]}}},7666(e){e.exports={ONCLICK_SUBTYPE:50,squishHandleClick:{type:50,squish:e=>e?[1]:[0],unsquish:e=>1===e[0]}}},2603(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={ID_SUBTYPE:43,squishId:t}},6844(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={INPUT_SUBTYPE:51,squishInput:t}},4017(e){e.exports={ONHOVER_SUBTYPE:56,squishOnHover:{type:56,squish:e=>e?[1]:[0],unsquish:e=>1===e[0]}}},3641(e){e.exports={PLAYER_ID_SUBTYPE:44,squishPlayerIds:{type:44,squish:e=>e,unsquish:e=>e}}},3070(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={POS_SUBTYPE:45,squishPos:s}},2575(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={SIZE_SUBTYPE:46,squishSize:s}},3122(e,t,s){const{squishAsset:r}=s(2108),n={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:n}},986(e){e.exports={SUBTYPE_TYPE:55,squishSubType:{type:55,squish:e=>[e],unsquish:e=>e[0]}}},5317(e,t,s){const{hypLength:r}=s(6474),n=s(9173),{squishColor:i}=s(3187),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||n.BLACK,p=i.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 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+p.length+2+3*[...a].length;l[r+g]=Number(s[0]),l[r+g+1]=Number(s[1]),l[r+g+2]=Number(s[2]),g+=3}let m=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 n=6+p.length+2+3*[...a].length+3*[...h].length;l[n+m]=Number(r[0]),l[n+m+1]=Number(r[1]),l[n+m+2]=Number(r[2]),m+=3}return l},unsquish:e=>{const t=e[0]+e[1]/100,s=e[2]+e[3]/100,r=e[4]+e[5]/100,n=e.slice(6,10),i=e[10],o=e[11],a=e.slice(12,12+i),h=e.slice(12+i,12+i+o),l=e.slice(12+i+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 n=t+s+r;c.push(n)}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 n=t+s+r;u.push(n)}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 n=t+s+r;f.push(n)}return{x:t,y:s,text:String.fromCodePoint.apply(null,f),size:r,color:n,align:d,font:p}}};e.exports={TEXT_SUBTYPE:47,squishText:o}},5647(e,t,s){const{GameNode:r}=s(1267),n=s(3802);e.exports={[[n.STREAM]]:r.Stream,[[n.ASSET]]:r.Asset,[[n.TEXT]]:r.Text,[[n.SHAPE_2D_POLYGON]]:r.Shape,[[n.SHAPE_2D_CIRCLE]]:r.Shape,[[n.SHAPE_2D_LINE]]:r.Shape}},3802(e){e.exports={STREAM:6,ASSET:1,TEXT:2,SHAPE_2D_POLYGON:3,SHAPE_2D_CIRCLE:4,SHAPE_2D_LINE:5}},967(e,t,s){const{getRandomTerrain:r,getRandomStartPoint:n}=s(9337),i=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,n(a,h,t),a,h,t);const d=((e,t,s,r)=>{const n=[];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(n.findIndex(e=>e.x===a.x&&e.y===a.y)>-1||a.x===t.x&&a.y===t.y||s.filled){n.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}}i(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:n}=((e,t)=>{const s=e.x,r=e.y,n=t.x,i=t.y;return{width:Math.floor(s/n),height:Math.floor(r/i)}})(e,t);let i=((e,t)=>{const s=[],r={filled:!1,north:!0,south:!0,east:!0,west:!0};for(let n=0;n<e;n++){s[n]=[];for(let i=0;i<t;i++){const o={...r};0===n?o.west=!1:n===e-1&&(o.east=!1),0===i?o.north=!1:i===t-1&&(o.south=!1),s[n].push(o)}}return s})(r,n);const a={x:Math.floor(Math.random()*r),y:Math.floor(Math.random()*n)};return i=o(i,a,s,r,n),i}}},9337(e){const t=(e,{x:t,y:s},r,n,i)=>{t<0||t>=r||s<0||s>=n||t===i.x&&s===i.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},n,i,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},n,i,o),0===a?(t(e,{x:s+1,y:r},n,i,o),t(e,{x:s,y:r+1},n,i,o),t(e,{x:s+1,y:r+1},n,i,o)):1===a?(t(e,{x:s-1,y:r},n,i,o),t(e,{x:s,y:r+1},n,i,o),t(e,{x:s-1,y:r+1},n,i,o)):2===a?(t(e,{x:s,y:r-1},n,i,o),t(e,{x:s+1,y:r},n,i,o),t(e,{x:s+1,y:r-1},n,i,o)):(t(e,{x:s,y:r-1},n,i,o),t(e,{x:s-1,y:r},n,i,o),t(e,{x:s-1,y:r-1},n,i,o))},(e,{x:s,y:r},n,i,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},n,i,o),0===a?(t(e,{x:s,y:r+1},n,i,o),t(e,{x:s,y:r+2},n,i,o),t(e,{x:s,y:r+3},n,i,o)):1===a?(t(e,{x:s+1,y:r},n,i,o),t(e,{x:s+2,y:r},n,i,o),t(e,{x:s+3,y:r},n,i,o)):2===a?(t(e,{x:s-1,y:r},n,i,o),t(e,{x:s-2,y:r},n,i,o),t(e,{x:s-3,y:r},n,i,o)):(t(e,{x:s,y:r-1},n,i,o),t(e,{x:s,y:r-2},n,i,o),t(e,{x:s,y:r-3},n,i,o))},(e,{x:s,y:r},n,i,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},n,i,o),0===a?(t(e,{x:s,y:r+1},n,i,o),t(e,{x:s,y:r+2},n,i,o),t(e,{x:s+1,y:r+2},n,i,o)):1===a?(t(e,{x:s+1,y:r},n,i,o),t(e,{x:s+2,y:r},n,i,o),t(e,{x:s+2,y:r-1},n,i,o)):2===a?(t(e,{x:s-1,y:r},n,i,o),t(e,{x:s-2,y:r},n,i,o),t(e,{x:s-2,y:r+1},n,i,o)):(t(e,{x:s,y:r-1},n,i,o),t(e,{x:s,y:r-2},n,i,o),t(e,{x:s-1,y:r-2},n,i,o))},(e,{x:s,y:r},n,i,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},n,i,o),0===a?(t(e,{x:s,y:r+1},n,i,o),t(e,{x:s-1,y:r+1},n,i,o),t(e,{x:s-1,y:r+2},n,i,o)):1===a?(t(e,{x:s+1,y:r},n,i,o),t(e,{x:s+1,y:r+1},n,i,o),t(e,{x:s+2,y:r+1},n,i,o)):2===a?(t(e,{x:s-1,y:r},n,i,o),t(e,{x:s-1,y:r+1},n,i,o),t(e,{x:s-2,y:r+1},n,i,o)):(t(e,{x:s,y:r-1},n,i,o),t(e,{x:s-1,y:r-1},n,i,o),t(e,{x:s-1,y:r-2},n,i,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}}},5864(e){const t=(e,s,r,n=[])=>{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]],i=s.node.coordinates2d,o=r[0][0],a=r[1][0],h=i[0][0],l=i[1][0],c=r[0][1],d=r[2][1],u=i[0][1],p=i[2][1];l<o||a<h||c>p||u>d||n.push(e)}for(const i in e.node.children)t(e.node.children[i],s,r,n);return n};e.exports={checkCollisions:(e,s,r=null)=>t(e,s,r)}},6474(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)))}},6734(e){e.exports={triangle:(e,t,s,r,n,i)=>[[e,t],[s,r],[n,i],[e,t]],rectangle:(e,t,s,r)=>[[e,t],[e+s,t],[e+s,t+r],[e,t+r],[e,t]]}},436(e,t,s){const{GameNode:r}=s(1267),n=s(7643),i=s(6734),o=s(5864),a=s(9173);e.exports={getView:(e,t,s,h={},l={})=>{const c=o.checkCollisions(e,{node:{coordinates2d:i.rectangle(t.x,t.y,t.w,t.h)}},t=>t.node.id!==e.node.id),d=new r.Shape({shapeType:n.POLYGON,coordinates2d:i.rectangle(0,0,0,0),fill:a.COLORS.BLACK}),u=[];return c.length>0&&c.forEach(e=>{const r=[],n=[],i=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 i){const o=i[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),g=(l.y||1)*(c-t.y);p&&(h.x&&(f+=h.x),h.y&&(g+=h.y)),n.push([f,g])}{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],i=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=i,a.size.y=o;const h=n[0],l=n[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),n=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)),n=parseInt(r,36);if(!Number.isFinite(n)||n<=0)break;const i=e.slice(t+12,t+12+32),o=String.fromCharCode.apply(null,i.filter(e=>e)),a=e.slice(t+12+32,t+12+n),h=1===s?"image":2===s?"audio":3===s?"font":4===s?"video":null;h&&this.storeRawAsset(o,h,a),t+=12+n}}storeRawAsset(e,t,s){const i=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(i).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=n(e.subarray(0,1024)).replace(/^\xEF\xBB\xBF/,"");return/^\s*(?:<\?xml\b[^?]*\?>\s*)?<svg\b/i.test(t)?"image/svg+xml":"image/jpeg"})(i);this.assets[e]={type:"image",data:`data:${t};base64,`+btoa(n(i))},delete this.imageCache[e],this._notifyReady()}else if("audio"===t)if(this.audioCtx)try{this.audioCtx.decodeAudioData(i.buffer.slice(i.byteOffset,i.byteOffset+i.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:i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength),decoded:!1};else if("video"===t){const t=r(i);this.assets[e]={type:"video",data:new Blob([i],{type:t.contentType||"video/mp4"}),url:null},this._notifyReady()}else if("font"===t)try{new FontFace(e,i).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={}}}},3625(e,t,s){const r=s(7588),{Squisher:n,Asset:i}=s(688);e.exports={...r,Asset:i,Squisher:class extends n{constructor(e){super({...e,encodeNode:r.squish,decodeNode:r.unsquish})}},Game:s(9579),ViewableGame:s(7706),Colors:s(961),Shapes:s(3431),subtypes:s(7910),ShapeUtils:s(3250),ViewUtils:s(6560),GeometryUtils:s(836),Physics:s(6036),...s(847),TerrainGenerator:s(4123).terrainGenerator}},842(e,t,s){const r=s(3317),{Squisher:n,Asset:i}=s(688);e.exports={...r,Asset:i,Squisher:class extends n{constructor(e){super({...e,encodeNode:r.squish,decodeNode:r.unsquish})}},Game:s(2706),ViewableGame:s(711),Colors:s(3872),Shapes:s(9990),subtypes:s(675),ShapeUtils:s(3485),ViewUtils:s(177),GeometryUtils:s(799),Physics:s(9807),...s(9930),TerrainGenerator:s(7004).terrainGenerator}},6428(e,t,s){const r=s(4003),{Squisher:n,Asset:i}=s(688);e.exports={...r,Asset:i,Squisher:class extends n{constructor(e){super({...e,encodeNode:r.squish,decodeNode:r.unsquish})}},Game:s(2212),ViewableGame:s(6525),Colors:s(3002),Shapes:s(2316),subtypes:s(6541),ShapeUtils:s(7043),ViewUtils:s(6967),GeometryUtils:s(6897),Physics:s(6021),...s(6308),TerrainGenerator:s(10).terrainGenerator}},9630(e,t,s){const{squishMap:r,DEFAULT_VERSION:n}=s(9732),{normalizePath:i,resolveInFiles:o}=s(3735);e.exports={loadGameClass:({files:e,entryPoint:t})=>{if(!e||!t)throw new Error("loadGameClass requires { files, entryPoint }");const s={};for(const t of Object.keys(e))s[i(t)]=e[t];const n={},a=e=>{if(n[e])return n[e].exports;const t=e.includes("/")?e.slice(0,e.lastIndexOf("/")):"",i=n=>{const i=/^squish-(\d+)$/.exec(n);if(i){const e=r[i[1]];if(e)return e;throw new Error("Unsupported Squish runtime: "+n)}if(n.startsWith("./")||n.startsWith("../")){const r=o(s,t,n);if(r)return a(r);throw new Error("Cannot resolve require('"+n+"') from "+e+" — not in the game source map")}throw new Error("Game tried to require('"+n+"') — local games may only require their squish version and their own files")},h={exports:{}};n[e]=h;const l=s[e],c=new Function("module","exports","require","__filename","__dirname",l);try{c(h,h.exports,i,e,t)}catch(t){throw delete n[e],t}return h.exports},h=i(t);if(!Object.prototype.hasOwnProperty.call(s,h))throw new Error('Entry point "'+t+'" not found in game source map');return a(h)}}},1768(e,t,s){const r=s(6899),n=s(549),i=s(7868);e.exports={GameView:class{constructor({container:e,assetManager:t,send:s,gamepad:o,onAssetReady:a}){this.container=e,e.innerHTML="",Object.assign(e.style,{position:"relative",overflow:"hidden",background:"#000"}),this.canvas=document.createElement("canvas"),Object.assign(this.canvas.style,{display:"block",margin:"0 auto",cursor:"default"}),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 n(this.canvas,this.assetManager),this.inputHandler=new i(this.canvas,s,()=>this.renderer.thingIndices,this.assetManager,o),this.inputHandler.attach()}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,n=this._cursorRaster;if(n?.data===e.data&&n.image===t&&n.width===s&&n.height===r)return n.url;const i=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),i.url=e.toDataURL("image/png")}catch(e){}return i.url}resize(e){const t=this.container.clientWidth||window.innerWidth,s=this.container.clientHeight||window.innerHeight,r=t*e.y/e.x<=s,n=r?t:Math.floor(s*e.x/e.y),i=r?Math.floor(t*e.y/e.x):s;this.canvas.width=2*n,this.canvas.height=2*i,this.canvas.style.width=n+"px",this.canvas.style.height=i+"px",this.inputHandler.clientWidth=n,this.inputHandler.clientHeight=i}destroy(){this.destroyed||(this.destroyed=!0,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:n}=s(1011),i=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),n=Math.max(0,e-this.nextPoll);this.nextPoll=e+r-n%r;const i=new Map(s.map(e=>[e.index,e]));for(const[e,t]of this.previous)i.has(e)&&i.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=i}_release(e){this.send(JSON.stringify({type:"input",gamepad:!0,gamepadIndex:e.index,connected:!1,deltaTime:0,input:n({buttons:[],axes:[]},i)}))}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,n=!1;const i=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){n=!1;const a=new URLSearchParams(new URL(o).hash.slice(1)),h=r=i({gameKey:e.gameKey,versionId:e.versionId,roomId:a.get("room"),invite:a.get("invite")});h.then(e=>{n||r!==h?i({...e,remove:!0}).catch(()=>{}):s=e}).catch(t)},onHeartbeat(e){s&&i({...s,playerCount:e}).catch(e=>{s=null,t(e)})},onEnd(){n=!0,r=null,s&&i({...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},n=(e,t,s)=>e.convertToBlob?e.convertToBlob({type:t,quality:s}):new Promise((r,n)=>{e.toBlob(e=>{e?r(e):n(new Error("Canvas encoding failed"))},t,s)}),i=(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 n=Math.max(16,Math.round(e.width*t)),i=Math.max(16,Math.round(e.height*t)),o=r(n,i),a=o.getContext("2d");return s&&(a.fillStyle="#ffffff",a.fillRect(0,0,n,i)),a.drawImage(e.source,0,0,n,i),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),n=new Image;n.onload=()=>{URL.revokeObjectURL(r),t({source:n,width:n.naturalWidth,height:n.naturalHeight,close:()=>{}})},n.onerror=()=>{URL.revokeObjectURL(r),s(new Error("Not decodable as an image"))},n.src=r})})(e);try{const e=-1!==t.indexOf(c),h=e?c:await(async()=>{if(null!==s)return s;const e=await n(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 n(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:i(l,h),resized:!0}}finally{d.close()}}}},44(e,t,s){const{ProjectTransferClient:r,CONTROL:n,CHUNK:i}=s(4394),o=s(1525),a=s(4849),{loadLocalGame:h,loadHomeGame:l}=s(7348),{GameView:c,FrameLoop:d,getClientInfo:u}=s(1768),{squishMap:p,DEFAULT_VERSION:f}=s(9732),g=s(814),m=s(3598),{RtcHost:y,createRtcTransport:x,readInvitation:v}=s(4454),{createSaveStore:w}=s(7699),{CURSOR_OPCODE:b,decodeCursor:E}=s(5199);class S{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=e.onClose||(()=>{}),this.onError=e.onError||(()=>{}),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||w(),this.platform=e.platform,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?{getLink:()=>this._getRtcHost().share(),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,{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,onSaveData:this.onSaveData,onError:this.onError,onReady:e=>{this.onReady(e),this._shareOptions?.autoStart&&this._getRtcHost().share().catch(e=>this._localChrome?.setStatus?.(`Not available to join: ${e.message}. Use Share to retry.`))}}),onError:this.onError})}start(){this._sessions.start()}stop(){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 y(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=>S.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")}setInputEnabled(e){const t=this._localSession?.inputHandler||this.inputHandler;e?t?.attach():t?.detach()}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=S.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(){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()}}),this._resizeHandler=()=>{this._initCanvas(),this._sendClientInfo()},window.addEventListener("resize",this._resizeHandler);const s=this._mediaClient=new m({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._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._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 n:case i: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 b:try{this.view?.setCursor(E(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=p[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.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),n=new URL(this.wsUrl);n.port=r,this._reconnect(n.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)};S.LocalSession=g,S.loadLocalGame=h,S.packAssetBundle=_,S.fitImageToSize=C,S.downloadSave=A,S.createRtcTransport=x,S.readInvitation=v,S.RtcHost=y,S.createShareDialog=s(172),S.GameCopies=s(2157),S.createSessionFrame=a,S.createPlayerToolbar=s(8106).createPlayerToolbar,S.householdRoom=s(9225),S.PortableProject=s(7237),S.ManualRtc=s(9742),S.createManualPairing=s(5880),e.exports&&(e.exports={default:S,HomegamesClient:S,LocalSession:g,loadLocalGame:h,packAssetBundle:_,fitImageToSize:C,downloadSave:A}),"undefined"!=typeof window&&(window.HomegamesClient=S,window.LocalSession=g)},7868(e,t,s){const r=s(5562),{fitImageToSize:n}=s(9311),{MAX_UPLOAD_BYTES:i}=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,n,i={}){this.canvas=e,this.send=t,this.getThingIndices=s,this.assetManager=n,this.mouseDown=!1,this.mousePos=null,this._pressClickSent=!1,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===i?null:new r(t,i),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._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.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=>{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._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(),this._touchActive=!0,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.assetManager.unlockAudio()):this._touchActive=!1},e.touchmove=e=>{e.preventDefault(),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.assetManager.liveMedia?.release("pointer"),!this._touchActive)return;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},e.touchcancel=()=>{this.assetManager.liveMedia?.release("pointer"),this.mouseDown&&this._lastClientPos&&this._sendMouseUp(this._lastClientPos[0],this._lastClientPos[1]),this.mouseDown=!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),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._pressClickSent=!0,this._handleClick(s,!0)),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),this.mouseDown=!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"]')}_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){const s=this.canvas.getBoundingClientRect(),r=(e-s.left)/s.width*100,n=(t-s.top)/s.height*100,i=Math.min(99.99,Math.max(0,r)),o=Math.min(99.99,Math.max(0,n));this.send(JSON.stringify({type:"mouseup",data:{x:i,y:o}}))}_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,n=(t-s.top)/s.height*100,i=Math.min(99.99,Math.max(0,r)),o=Math.min(99.99,Math.max(0,n));this.send(JSON.stringify({type:"mousemove",data:{x:i,y:o}}))}_onHover(e){this.send(JSON.stringify({type:"onhover",nodeId:e}))}_offHover(e){this.send(JSON.stringify({type:"offhover",nodeId:e}))}_sendPendingClick(e){this.mouseDown&&!this._pressClickSent&&!this.spectating&&this._focused&&(this._pressClickSent=!0,this._handleClick(e,!0))}_promptTextInput(e){if(this._textDialog)return;const t=document.createElement("dialog"),s=document.createElement("div"),r=document.createElement("label"),n=document.createElement("input"),i=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",n.type="text",n.maxLength=4096,n.style.cssText="display:block;width:min(300px,65vw);padding:10px;margin:12px 0;font:inherit",r.append(n),i.textContent="Done",i.type="button",o.textContent="Cancel",o.type="button";for(const e of[i,o])e.style.cssText="padding:8px 16px;margin-right:8px;font:inherit";const a=()=>{t.close(),t.remove(),this._textDialog=null};i.onclick=t=>{t.preventDefault();const s=n.value;a(),this.send(JSON.stringify({type:"input",input:s,nodeId:e}))},n.onkeydown=e=>{"Enter"===e.key&&i.onclick(e)},o.onclick=a,t.oncancel=e=>{e.preventDefault(),a()},s.append(r,i,o),t.append(s),document.body.append(t),this._textDialog=t,t.showModal(),n.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(),n=(e-r.left)/r.width*100,i=(s-r.top)/r.height*100;if(n>=0&&n<=100&&i>=0&&i<=100){const e={x:n,y:i};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/*",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>i)try{a=await n(r,i)}catch(e){const t=(r.size/1048576).toFixed(1);return void alert(`That file is ${t}MB — uploads are limited to ${i/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){const t=this.canvas.getBoundingClientRect();return e*t.width/100+t.left}_translateY(e){const t=this.canvas.getBoundingClientRect();return e*t.height/100+t.top}_canClick(e,t){let s=!1,r=!1,n=null,i=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:n,nodeId:i};const a=this.getThingIndices();for(const o in a){const h=a[o];let l=h[3];if(!l||!l.length)continue;if(!l[0].length){const e=new Array(l.length/2);for(let t=0;t<l.length;t+=2)e[t/2]=[l[t],l[t+1]];l=e}let c=!1,d=this._translateX(l[0][0]),u=d,p=this._translateY(l[0][1]),f=p;for(let e=1;e<l.length;e++){const t=this._translateX(l[e][0]),s=this._translateY(l[e][1]);t<d&&(d=t),t>u&&(u=t),s<p&&(p=s),s>f&&(f=s)}if(!(e<d||e>u||t<p||t>f)){let s=0,r=l.length-1;for(;s<l.length;r=s++){const n=this._translateY(l[s][1]),i=this._translateY(l[r][1]),o=this._translateX(l[s][0]),a=this._translateX(l[r][0]);n>t!=i>t&&e<(a-o)*(t-n)/(i-n)+o&&(c=!c)}}c&&(s=h[0],n=h[1],i=h[2],r=!!h[4])}return{isClickable:s,isHoverable:r,action:n,nodeId:i}}}},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:n}=s(8106),i=(e,t,i,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=n(window,{title:t,home:i,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),o&&(p=s(172)({container:c,...o}),d.setAction("share",{label:"Share",run:()=>p.show()}),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=>d.setStatus(e),dispose(){f||(f=!0,p?.dispose(),d.dispose(),c.remove(),l())}}};i.addExportsButton=(e,t)=>{const s=e.homegamesToolbar;return s?.setAction("exports",{label:"View exports",run:t}),()=>s?.setAction("exports",null)},e.exports=i},7348(e){const t=async({manifestUrl:e,gameKey:t,versionId:s,baseUrl:r}={},{signal:n}={})=>{const i=await fetch(e,{signal:n});if(!i.ok)throw new Error("Manifest fetch failed: "+i.status);const o=await i.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:n});if(!s.ok)throw new Error("Asset bundle fetch failed: "+s.status);a=new Uint8ClampedArray(await s.arrayBuffer())}return{name:o.name,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 n=s?`?versionId=${encodeURIComponent(s)}`:"";return t({gameKey:e,versionId:s,manifestUrl:`/games/${encodeURIComponent(e)}/local-manifest${n}`},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),n=s(9503),{playerFrame:i}=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:g}=s(1768),{squishMap:m,DEFAULT_VERSION:y}=s(9732),x=s(7538),{loadGameClass:v}=s(9630),{createSaveStore:w,createDebouncedWriter:b,serializeSaveData:E,isCompatibleSave:S,DEFAULT_VERSION_ID:_}=s(7699),{generateName:C,initialName:A,normalizeName:k}=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=A(e.playerName),this.assetBundle=e.assetBundle||null,this.assetPackets=this.assetBundle?a(this.assetBundle):[],this.onReady=e.onReady||(()=>{}),this.onError=e.onError||(()=>{}),this.gameKey=e.gameKey||null,this.versionId=e.versionId||_,this.onSaveData=e.onSaveData||null,this.saveStore=e.saveStore||w(),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=v({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"));const t="function"==typeof this.gameClass.metadata?this.gameClass.metadata():{};this.maxPlayers=Math.min(255,t.maxPlayers||64),this.pointerLockEnabled=!0===t.pointerLock;const r=t.squishVersion||y;let n=m[r];if(!n)return void this.onError(new Error("Unsupported Squish runtime: squish-"+r));this.unsquish=n.unsquish,this.squishVersion=r,this.aspectRatio=t.aspectRatio||{x:16,y:9};const i=this.gameKey||this.gameClass.name||"local-game",o="local:"+i,a=Array.isArray(t.saveCompatibility)?t.saveCompatibility:[],h=this._bootGeneration;this.exportStorage=this.platform?.getExports?this.platform:s(739).createExportStorage(window,{installationId:i,gameId:i,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:n,saveGame:e=>{let t;try{t=JSON.parse(E(e))}catch(e){return Promise.reject(e)}return c({gameKey:i,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:i}){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:i,services:{}}),this.runtime=n(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,n]=s(e);this.disablePick(),t&&t(r,n)},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,n=this.inputHandler?.gamepads;n&&null===n.index&&n.setIndex(0);const i=new Set(this.players.map(e=>e.view?.inputHandler.gamepads?.index));if(void 0===t)for(t=0;i.has(t);)t++;return this._joinPlayer(s,r,C(),!1!==this.gamepadOptions&&{...this.gamepadOptions,index:t}),this._captureFrame(),r}_joinPlayer(e,t,s,r){const n=new x(this.game,t),i=new p({container:e,assetManager:this.assetManager,gamepad:r,send:e=>{t===this.playerId&&this._noteInput(e),n.handleMessage(e)},onAssetReady:()=>this._invalidateFrames()});if(this.players.push({playerId:t,info:{name:s},settings:{SOUND:!0},view:i,dispatcher:n,cursor:null,currentBuf:null,frameDirty:!0}),t===this.playerId){const s=new u({container:e,platform:this.platform,assets:i.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)})}i.inputHandler.squishVersion=this.squishVersion,i.inputHandler.setPointerLockEnabled(this.pointerLockEnabled),i.resize(this.aspectRatio);try{this.game.handleNewPlayer?.({playerId:t,settings:{SOUND:!0},info:{name:s},clientInfo:g(),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 n=1;for(;this.players.some(e=>e.playerId===n);)n++;const i=Array.from(this.squishVersion,e=>e.charCodeAt(0));e(Uint8Array.from([2,n,this.aspectRatio.x,this.aspectRatio.y,0,0,i.length,...i,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 x(this.game,n),h={playerId:n,info:{name:A(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:n,settings:{SOUND:!0},info:{...h.info},clientInfo:s,requestedGame:null}),this._captureFrame()}catch(e){throw this.removePlayer(n),e}return{playerId:n,handleMessage:t=>{if(!h.dispatcher)return;let s;try{s=JSON.parse(t)}catch(e){return}if("player-info"===s?.type)try{this.setPlayerName(n,s.name)}catch(e){}else"project-transfer"===s?.type?this.handleProjectMessage(n,s,e):h.dispatcher.handleInput(s)},leave:()=>this.removePlayer(n)}}setPlayerName(e,t){const s=k(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=i(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:n,DEFAULT_ICE:i}=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 g=document.createElement("section"),m=document.createElement("section"),y=document.createElement("h3");y.textContent="Host a player",g.append(y);const x=document.createElement("h3");x.textContent="Join a host",m.append(x);let v=null,w=null,b=!1,E=!1;const S=[],_=e=>{b||(u.textContent=e)},C=(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){_(e.message)}finally{E=!1,S.forEach(e=>e.disabled=!1)}}},S.push(r),e.append(r),r},A=(e,t,s=!1)=>{const r=document.createElement("label");r.textContent=t;const n=document.createElement("textarea");return n.setAttribute("aria-label",t),n.readOnly=s,n.maxLength=131072,n.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(n),e.append(r),n},k=A(g,"Offer to send",!0),I=A(g,"Answer from friend");C(g,"Create offer",async()=>{const e=t();if(!e?.game)throw new Error("Start a local game to host a player");v||(v=new r(e,{onStatus:_})),v.iceServers=f.checked?i:[],k.value="",I.value="",_("Collecting network addresses…"),k.value=await v.createOffer(),_("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),_("Handshake copied")}catch(t){e.focus(),e.select(),_("Copy the selected handshake text")}};C(g,"Copy offer",()=>T(k)),C(g,"Connect with answer",async()=>{if(!v)throw new Error("Create an offer first");await v.acceptAnswer(I.value),_("Connecting directly…")}),C(g,"Cancel offer",()=>{v?.cancelOffer(),k.value="",I.value="",_("Pending offer cancelled")});const P=A(m,"Offer from host"),L=A(m,"Answer to send",!0);C(m,"Create answer",async()=>{const e=n(P.value,{iceServers:f.checked?i:[],onStatus:_});v?.stop(),v=null,w?.close(),w=e,L.value="",_("Collecting network addresses…");try{s(e.transport),L.value=await e.answer(),_("Send the entire answer back to the host, then choose Done.")}catch(t){throw e.close(),t}}),C(m,"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,g,m,d,u,M),e.append(h),h.onclose=a,{show(){b||h.open||(h.showModal(),o())},dispose(){b||(b=!0,v?.stop(),w?.close(),h.remove())}}}},3598(e,t,s){const r=s(7511);e.exports=class{constructor({container:e,assets:t,send:s,platform:n,publish:i=()=>{},unpublish:o=()=>{}}){Object.assign(this,{container:e,assets:t,send:s,publish:i,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:n,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 n=document.createElement("button");n.textContent="Cancel";for(const e of[r,n])e.style.cssText="padding:12px;margin:16px 8px 0 0;font:inherit";t.append(s,r,n),this.container.appendChild(t),this.pending.set(e.id,t);const i=t=>{this.remove(e.id),this.send({type:"media",action:"result",id:e.id,error:t})};t.oncancel=e=>{e.preventDefault(),i("Microphone/camera permission cancelled")},n.onclick=()=>i("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)&&i(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)}}}},7237(e,t,s){const r=s(5110),{prepareTrustedLocalGame:n}=s(7435),{squishMap:i}=s(9732),o={supportedRuntimes:Object.keys(i)},a=s(5758),h=s(5061),l=s(5564);e.exports={create:e=>r.createProject(e,o),importArchive:e=>r.importArchive(e,o),exportArchive:r.exportArchive,normalizePath:r.normalizePath,limits:r.LIMITS,buildIsolatedHtml:a.buildIsolatedHtml,runtimeDocument:a.runtimeDocument,createFrame:a.createFrame,attachSaveHost:h.attachSaveHost,attachPlayerHost:(e,t,r)=>{const n=h.attachSaveHost(e,t,r),i=s(739).createExportStorage(e,r),o=l.attachClientHost(e,t,l.recordAudio,i,s(97).createExportsViewer,s(5900).recordVideo,s(8106).createPlayerToolbar,{...r,profile:s(4367).profile(e)});return{...n,get stopped(){return n.stopped},command:o.command,downloadGame:o.download,close:async()=>{o.close(),await n.close()}}},connectClientSource:l.connectClientSource,connectSaveStore:h.connectSaveStore,filename:a.filename,readHtmlArchive:a.readHtmlArchive,htmlBytesLimit:a.htmlBytesLimit,checkSyntax:r.checkSyntax,prepareTrustedLocalGame:(e,t)=>n(e,i,t)}},7511(e,t,s){const{recordAudio:r}=s(5564),{recordVideo:n}=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:n)(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:n,ctx:i,assetManager:o}=this,a=new Set(Object.keys(this.playingSounds)),h=new Set,l=new Set;this.mediaDirty=!1,i.clearRect(0,0,n.width,n.height),this.thingIndices=[];let c=0;for(;e&&c<e.length;){e[c];const d=e[c+1]+e[c+2]+e[c+3];let u;try{u=t(e.slice(c,c+d)).node}catch(e){c+=d;continue}if(!u.coordinates2d&&u.input&&u.text){const e=Math.floor(n.width),t=u.text.size/100*e;i.font=t+"px sans-serif";const s=i.measureText(u.text.text);let r=u.text.x*n.width/100;u.text.align&&"center"===u.text.align&&(r-=s.width/2),r=r/n.width*100;const o=s.actualBoundingBoxDescent-s.actualBoundingBoxAscent,a=s.width/n.width*100,h=o/n.height*100;this.thingIndices.push([!!u.handleClick,u.input&&u.input.type,u.id,[r,u.text.y,r+a,u.text.y,r+a,u.text.y+h,r,u.text.y+h,r,u.text.y],!!u.onHover])}else if(null!==u.coordinates2d&&void 0!==u.coordinates2d){if(this.thingIndices.push([!!u.handleClick,u.input&&u.input.type,u.id,u.coordinates2d,!!u.onHover]),u.effects&&u.effects.shadow){const e=u.effects.shadow.color;i.shadowColor="rgba("+e[0]+","+e[1]+","+e[2]+","+e[3]+")",u.effects.shadow.blur&&(i.shadowBlur=u.effects.shadow.blur)}u.color&&(i.globalAlpha=u.color[3]/255),null!==u.fill&&void 0!==u.fill&&(i.fillStyle="rgba("+u.fill[0]+","+u.fill[1]+","+u.fill[2]+","+u.fill[3]+")"),void 0!==u.border&&null!==u.border&&(i.lineWidth=u.border/255*.1*n.width,i.strokeStyle="rgba("+u.color[0]+","+u.color[1]+","+u.color[2]+","+u.color[3]+")"),i.beginPath();const e=u.coordinates2d[0];i.moveTo(e[0]*n.width/100,e[1]*n.height/100);for(let e=1;e<u.coordinates2d.length;e++){const t=u.coordinates2d[e];i.lineTo(t[0]*n.width/100,t[1]*n.height/100)}void 0!==u.fill&&null!==u.fill&&i.fill(),void 0!==u.border&&null!==u.border&&i.stroke(),i.shadowColor=null,i.shadowBlur=0,i.lineWidth=0,i.strokeStyle=null}if(u.text){i.globalAlpha=u.text.color[3]/255,i.fillStyle="rgba("+u.text.color[0]+","+u.text.color[1]+","+u.text.color[2]+","+u.text.color[3]+")";const e=Math.floor(n.width),t=u.text.size/100*e,s=u.text.font&&"default"!==u.text.font?u.text.font:"sans-serif";i.font=t+"px "+s,u.text.align&&(i.textAlign=u.text.align),i.textBaseline="top",i.fillText(u.text.text,u.text.x*n.width/100,u.text.y*n.height/100)}if(u.asset||u.stream){const e=u.stream,t=e?e.id:Object.keys(u.asset)[0],c=e?o.liveMedia?.streams.get(e.id):o.assets[t];if(c&&"audio"===c.type){const e=`${u.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,u.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||u.asset[t];let h;if("video"===c.type||e){const d=`${u.id}:${t}`;l.add(d);let p=this.videos.get(d);p&&p.asset!==c&&(p.destroy(),p=null);const f={...s,muteAudio:!!s.muteAudio||!(!e||e.audio&&!c.local&&c.transmitting)};if(p||(p=new r(o,c,a.startTime||0,()=>{this.mediaDirty=!0},f),this.videos.set(d,p)),p.update(f.muteAudio,!!s.freezeMedia),h=(!e||c.video)&&!p.error&&p.element.readyState>=2?p.element:null,!h&&(!e||c.video)){const e=a.pos.x/100*n.width,t=a.pos.y/100*n.height;i.fillStyle="#202226",i.fillRect(e,t,a.size.x/100*n.width,a.size.y/100*n.height),i.fillStyle="#fff",i.font=`${Math.max(12,.015*n.width)}px sans-serif`,i.textAlign="center",i.textBaseline="middle",i.fillText(p.error?"Video format not supported":"Loading video…",e+a.size.x/200*n.width,t+a.size.y/200*n.height)}}else h=o.getImage(t);if(h){if(h.width=a.size.x/100*n.width,h.height=a.size.y/100*n.height,u.effects&&u.effects.shadow){const e=u.effects.shadow.color;i.shadowColor="rgba("+e[0]+","+e[1]+","+e[2]+","+e[3]+")",u.effects.shadow.blur&&(i.shadowBlur=u.effects.shadow.blur)}const e=a.pos.x/100*n.width,t=a.pos.y/100*n.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 n=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);n=Math.max(0,Math.min(n,(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)-n),d=Math.min(d,(h.videoHeight||h.naturalHeight)-a),c>=1&&d>=1&&i.drawImage(h,n,a,c,d,e,t,h.width,h.height)}else i.drawImage(h,e,t,h.width,h.height)}}}c+=d,i.shadowColor=null,i.shadowBlur=0,i.lineWidth=0,i.strokeStyle=null,i.globalAlpha=1}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,n=r?(new TextEncoder).encode(e):e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength);if(!n.length||n.length>t)return this.fail(new Error("Game packet is too large"));const i=!r&&3===n[0];if(i){if(this.lastFrame&&n.length===this.lastFrame.length&&n.every((e,t)=>e===this.lastFrame[t]))return void this.stats.duplicateFrames++;this.lastFrame=n,this.queue=this.queue.filter(e=>!e.frame||null!==e.offset||(this.queuedBytes-=e.bytes.length,this.stats.replacedFrames++,!1))}if(this.queuedBytes+n.length>s)return this.fail(new Error("Guest connection is too slow"));this.queue.push({bytes:n,text:r,frame:i,offset:null}),this.queuedBytes+=n.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,n=r?null:e instanceof ArrayBuffer?new Uint8Array(e):e,i=3===n?.[0];i&&(this.queue=this.queue.filter(e=>!e.frame||(this.bytes-=e.size,this.replacedFrames++,!1)));const o=r?2*e.length:n.byteLength;this.bytes+o>s?this.fail(new Error("Game message queue is full")):(this.queue.push({data:e,transfer:t,frame:i,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),n=65536,i=async e=>Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",e)),e=>e.toString(16).padStart(2,"0")).join(""),o=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 a(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=a(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=o(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+n,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:n}){Object.assign(this,{send:e,onOffer:t,onProgress:s,importArchive:r,onComplete:n}),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=o(e);if("offer"===this.state)return this.metadata=a(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;if(await i(s)!==r.sha256)throw new Error("The game copy was damaged during transfer. Try again.");const n=await this.importArchive(s);if(n.revision!==r.revision||n.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:n}),"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(n,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,offer:a,CHUNK:n}},2157(e,t,s){"use strict";const r=s(1240),{Peer:n,signalUrl:i}=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:n="all",onStatus:i=()=>{}}={}){Object.assign(this,{project:e,signalingUrl:t,receiveUrl:s,worker:r,iceTransportPolicy:n,onStatus:i}),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(i(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:i(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 i=()=>{clearTimeout(r),r=setTimeout(()=>a.close(new Error("Copy transfer timed out. Open the invitation to try again.")),12e4)},a=new n({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)}%`)),i(),s.open()},onMessage:e=>{try{i(),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,g,m,y=!1,x=!1,v=!1;const w=()=>{v||(v=!0,clearTimeout(m),p?.close(),f?.close(),u.close())},b=()=>{y||(y=!0,g?.close(),w())},E=e=>{y||(b(),x||l(e||new Error("The sender disconnected before the copy was saved. Open the invitation to try again.")))},S=e=>{v||y||("validating"===g?.state||x?w():E(e))},_=()=>{clearTimeout(m),m=setTimeout(()=>E(new Error("Copy transfer timed out. Open the invitation to try again.")),12e4)};return g=new o.Receiver(e=>{v||p.channel.send(e)},{onOffer:t,onProgress:s,importArchive:a.importArchive,onComplete:async e=>{clearTimeout(m),await h(e),x=!0,setTimeout(b,100)}}),f=u.signal(i(e.signalingUrl),{type:"join",roomId:e.roomId,invite:e.invite},e=>{"joined"===e.type?p=new n({network:u,iceServers:e.iceServers,iceTransportPolicy:d,sendSignal:e=>f.send({type:"signal",...e}),onOpen:_,onMessage:e=>{_(),g.receive(e).catch(E)},onEnd:S}):"signal"===e.type&&p?.signal(e)},S),{accept:()=>{if(y||!g)throw new Error("Reconnect to the sender to receive this game");_(),g.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=i(s.get("signal")),n=new URL(r);if(n.username||n.password||n.hash||n.search)throw new Error("Invalid invitation service");return{roomId:s.get("room"),invite:s.get("invite"),signalingUrl:r}},showCopyShare:function(e,t={}){let r,n=!1;const i=new h(e,{...t,onStatus:e=>r?.setStatus(e)}),o=()=>{n||(n=!0,i.close(),r.dispose(),t.onClose?.())};return r=s(172)({container:document.body,getLink:()=>i.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),n=[{urls:"stun:stun.l.google.com:19302"}],i=131072;function o(e,t){if("string"!=typeof e||e.length>i)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>i)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(i),e.pc.removeEventListener("icegatheringstatechange",n),e.cancelGather=null,r?s(r):t()},n=()=>{"complete"===e.pc.iceGatheringState&&r()},i=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",n),n()})}class l{constructor({id:e=crypto.randomUUID(),iceServers:t=n,onOpen:s=()=>{},onMessage:i=()=>{},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:i,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=n,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:n=>{try{if("string"!=typeof n||n.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(n);else{const t=JSON.parse(n);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=n,onStatus:s=()=>{}}={}){const r=o(e,"offer");let i=null,c=!1,d=!1;const u=new l({id:r.id,iceServers:t,onOpen:()=>{c=!0,i?.onOpen(),s("Connected to host")},onMessage:e=>{"string"!=typeof e&&i?.onMessage(e)},onEnd:e=>{d=!0,e&&i?.onError(e),i?.onClose(),s(e?.message||"Host disconnected")}});let p;return{transport:e=>(i=e,c&&queueMicrotask(()=>i.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:n}},1240(e,t,s){const r=s(8221),n=s(844),i=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([`(${i.toString()})(${r.workerSource()},${n.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,i){if(this.onSignalMessage=s,this.onSignalEnd=r,this.onHeartbeat=i,!this.worker)return this.inlineSignal=n(e,t,s,r,i);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,n={callbacks:t,mode:"main-thread",protocol:null,mailbox:null};if(this.channels.set(s,n),this.worker)try{this.worker.postMessage({type:"bind",id:s,channel:e},[e]),n.mode="worker"}catch(e){}if("worker"===n.mode)n.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{n.protocol=new r(e,t);let s=!1;const i=()=>{s||n.protocol.closed||this.closed||(s=!0,n.protocol.flush(),t.onOpen())};e.onopen=i,"open"===e.readyState&&queueMicrotask(i)}return{send:(e,{transfer:t=!1}={})=>{!this.closed&&this.channels.has(s)&&(n.mailbox?n.mailbox.send(e,t):n.protocol.send(e))},close:()=>{this.channels.delete(s)&&(n.mailbox?.close(),n.protocol?.close(),"worker"!==n.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),n=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 i{constructor({iceServers:e,sendSignal:t,onOpen:s,onMessage:r,onEnd:n,onTrack:i=()=>{},network:o,host:a=!1,iceTransportPolicy:h="all"}){this.pc=new RTCPeerConnection({iceServers:e,iceTransportPolicy:h}),Object.assign(this,{sendSignal:t,onEnd:n}),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),i(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:n=!0,iceTransportPolicy:i="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:n,iceTransportPolicy:i,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 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(n(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:n(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(),n=0;const o=new i({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(),n=0),++n>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,g=!1,m=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 i=new URL(r.url),a=o(i.hash);["http:","https:"].includes(i.protocol)&&!i.username&&!i.password&&a?.roomId===e&&a.invite&&n(a.signalingUrl)===n(s)&&(m=i.href)}catch(e){}else c.onMessage(t)},x=e=>{f||(f=!0,p?.close(),u?.close(),d.close(),e&&!g&&c.onError(e),c.onClose())};try{u=d.signal(n(s),{type:"join",roomId:e,invite:t},e=>{"joined"===e.type?p=new i({network:d,iceServers:e.iceServers,iceTransportPolicy:l,onTrack:e=>c.onTrack?.(e),sendSignal:e=>u.send({type:"signal",...e}),onOpen:()=>{g=!0,c.onOpen()},onMessage:y,onEnd:x}):"signal"===e.type&&p?.signal(e)},x)}catch(e){queueMicrotask(()=>x(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(!g)throw new Error("Connect to the host before sharing this game");if(m)return m;const r=new URL(a,window.location.href),i=new URLSearchParams({room:e,signal:n(s)});return t&&i.set("invite",t),r.hash=i.toString(),r.href},close:()=>{f=!0,p?.close(),u?.close(),d.close()}}},readInvitation:o,Peer:i,signalUrl:n}},844(e){e.exports=function(e,t,s,r,n=()=>{}){const i=new WebSocket(e);let o=!1,a=null,h=null;const l=e=>{o||(o=!0,clearTimeout(c),clearInterval(a),i.onopen=i.onmessage=i.onerror=i.onclose=null,i.close(),r(e))},c=setTimeout(()=>l(new Error("Signaling connection timed out")),15e3),d=e=>{o||1!==i.readyState||i.send(JSON.stringify(e))};return i.onopen=()=>d(t),i.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)}},i.onerror=()=>l(new Error("Cannot reach the invitation service")),i.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),n(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 n=(e,t={},s=[])=>postMessage({type:e,...t},s),i=(e,t)=>n("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=>n("signal-message",{data:e}),e=>n("signal-end",{message:e?.message}),e=>n("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=>n("data",{id:h,data:e},"string"==typeof e?[]:[e.buffer||e]),e=>i(h,e)),l=new e(t,{onMessage:e=>a.send(e,!0),onError:e=>i(h,e),onClose:()=>{a.close(),s.delete(h),n("channel-close",{id:h})}});s.set(h,{protocol:l,mailbox:a});const c=()=>{r||l.closed||(r=!0,l.flush(),n("channel-open",{id:h}))};t.onopen=c,"open"===t.readyState&&c()}else if("send"===a)s.get(h)?.protocol.send(l),n("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&&n("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(n=>{try{const i=e?e.getItem(t+r):s[r];if(!i)return void n(null);const o=JSON.parse(i);n(o&&"object"==typeof o?o:null)}catch(e){n(null)}}),putSave:(r,n)=>new Promise((i,o)=>{let a;try{a=JSON.stringify(n)}catch(e){return void o(e)}if(e)try{return e.setItem(t+r,a),void i()}catch(e){}s[r]=a,i()}),deleteSave:r=>new Promise(n=>{try{e&&e.removeItem(t+r)}catch(e){}delete s[r],n()})}},createDebouncedWriter:({intervalMs:e,write:t})=>{let s=0,r=null;const n=()=>{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((i,o)=>{if(r)return r.value=t,r.resolvers.push(i),void r.rejecters.push(o);r={value:t,resolvers:[i],rejecters:[o]};const a=Math.max(0,e-(Date.now()-s));setTimeout(n,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)),MAX_SAVE_DATA_BYTES:s,DEFAULT_VERSION_ID:"local-game-version",STORAGE_PREFIX:t}},1525(e){e.exports=class{constructor({remote:e,loadLocal:t,mountLocal:s,createLocal:r,onError:n}){Object.assign(this,{remote:e,loadLocal:t,mountLocal:s,createLocal:r,onError:n}),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%; display:flex; flex-direction:column; background:#101211; 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:n,onClose:i,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 g=document.createElement("p");g.setAttribute("role","status"),g.className="hg-share-status";const m=document.createElement("input");m.readOnly=!0,m.setAttribute("aria-label","Invitation link"),m.className="hg-share-link";const y=document.createElement("div");y.className="hg-share-actions";const x=(e,t)=>{const s=document.createElement("button");return s.type="button",s.textContent=e,s.onclick=t,y.appendChild(s),s},v=x("Copy link",async()=>{try{await navigator.clipboard.writeText(m.value),g.textContent="Link copied"}catch(e){m.focus(),m.select(),g.textContent="Copy the selected invitation link"}});v.className="hg-share-copy";const w=x(h,()=>c.close());[u,p,f,g,m,y].forEach(e=>c.appendChild(e)),e.appendChild(c);let b=0,E=!1;return c.onclose=()=>{b++,i?.()},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||(g.textContent=e)},async show(){if(E||c.open)return;const e=++b;f.innerHTML="",f.hidden=!0,m.value="",m.hidden=!0,v.disabled=!0,g.textContent="Creating invitation…",c.showModal(),n?.(),w.focus();try{const s=await t();if(e!==b)return;const n=r(0,"M");n.addData(s),n.make(),f.innerHTML=n.createSvgTag({cellSize:4,margin:16,scalable:!0}),f.firstChild.style.cssText="display:block;width:100%;height:100%;background:white",f.hidden=!1,m.value=s,m.hidden=!1,v.disabled=!1,g.textContent=a}catch(t){e===b&&(g.textContent=t.message)}},dispose(){E||(E=!0,b++,c.open&&c.close(),c.remove(),d())}}}},9732(e,t,s){const r={142:s(3625),143:s(842),145:s(6428),146:s(688)};e.exports={squishMap:r,DEFAULT_VERSION:"142"}},5537(e){e.exports=class{constructor(e,t,s,r,n={}){Object.assign(this,{assetManager:e,asset:t,invalidate:r,closed:!1,frozen:!1,forceMute:!1});const i=this.element=document.createElement("video");i.playsInline=!0,i.preload="auto",i.muted=!0,i.onloadedmetadata=()=>{s>0&&Number.isFinite(i.duration)&&(i.currentTime=Math.min(s,i.duration))},i.onloadeddata=i.onseeked=i.onended=()=>{this.closed||r()},i.onerror=()=>{this.closed||(this.error=!0,r())},"stream"===t.type?i.srcObject=t.data:(t.url||(t.url=URL.createObjectURL(t.data)),i.src=t.url),e.mediaPlayers.add(this),this.update(!!n.muteAudio,!!n.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";var s=Uint8Array,r=Uint16Array,n=Int32Array,i=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),i=0;i<31;++i)s[i]=t+=1<<e[i-1];var o=new n(s[30]);for(i=1;i<30;++i)for(var a=s[i];a<s[i+1];++a)o[a]=a-s[i]<<5|i;return{b:s,r:o}},l=h(i,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,g=new r(32768),m=0;m<32768;++m){var y=(43690&m)>>1|(21845&m)<<1;y=(61680&(y=(52428&y)>>2|(13107&y)<<2))>>4|(3855&y)<<4,g[m]=((65280&y)>>8|(255&y)<<8)>>1}var x=function(e,t,s){for(var n=e.length,i=0,o=new r(t);i<n;++i)e[i]&&++o[e[i]-1];var a,h=new r(t);for(i=1;i<t;++i)h[i]=h[i-1]+o[i-1]<<1;if(s){a=new r(1<<t);var l=15-t;for(i=0;i<n;++i)if(e[i])for(var c=i<<4|e[i],d=t-e[i],u=h[e[i]-1]++<<d,p=u|(1<<d)-1;u<=p;++u)a[g[u]>>l]=c}else for(a=new r(n),i=0;i<n;++i)e[i]&&(a[i]=g[h[e[i]-1]++]>>15-e[i]);return a},v=new s(288);for(m=0;m<144;++m)v[m]=8;for(m=144;m<256;++m)v[m]=9;for(m=256;m<280;++m)v[m]=7;for(m=280;m<288;++m)v[m]=8;var w=new s(32);for(m=0;m<32;++m)w[m]=5;var b=x(v,9,0),E=x(v,9,1),S=x(w,5,0),_=x(w,5,1),C=function(e){for(var t=e[0],s=1;s<e.length;++s)e[s]>t&&(t=e[s]);return t},A=function(e,t,s){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(7&t)&s},k=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,n){var h=e.length,l=n?n.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 g=function(e){var t=r.length;if(e>t){var n=new s(Math.max(2*t,e));n.set(r),r=n}},m=t.f||0,y=t.p||0,v=t.b||0,w=t.l,b=t.d,S=t.m,P=t.n,M=8*h;do{if(!w){m=A(e,y,1);var R=A(e,y+1,3);if(y+=3,!R){var O=e[(F=I(y)+4)-4]|e[F-3]<<8,N=F+O;if(N>h){f&&L(0);break}u&&g(v+O),r.set(e.subarray(F,N),v),t.b=v+=O,t.p=y=8*N,t.f=m;continue}if(1==R)w=E,b=_,S=9,P=5;else if(2==R){var U=A(e,y,31)+257,B=A(e,y+10,15)+4,D=U+A(e,y+5,31)+1;y+=14;for(var q=new s(D),H=new s(19),j=0;j<B;++j)H[a[j]]=A(e,y+3*j,7);y+=3*B;var $=C(H),G=(1<<$)-1,V=x(H,$,1);for(j=0;j<D;){var F,z=V[A(e,y,G)];if(y+=15&z,(F=z>>4)<16)q[j++]=F;else{var Y=0,K=0;for(16==F?(K=3+A(e,y,3),y+=2,Y=q[j-1]):17==F?(K=3+A(e,y,7),y+=3):18==F&&(K=11+A(e,y,127),y+=7);K--;)q[j++]=Y}}var W=q.subarray(0,U),J=q.subarray(U);S=C(W),P=C(J),w=x(W,S,1),b=x(J,P,1)}else L(1);if(y>M){f&&L(0);break}}u&&g(v+131072);for(var X=(1<<S)-1,Q=(1<<P)-1,Z=y;;Z=y){var ee=(Y=w[k(e,y)&X])>>4;if((y+=15&Y)>M){f&&L(0);break}if(Y||L(2),ee<256)r[v++]=ee;else{if(256==ee){Z=y,w=null;break}var te=ee-254;if(ee>264){var se=i[j=ee-257];te=A(e,y,(1<<se)-1)+c[j],y+=se}var re=b[k(e,y)&Q],ne=re>>4;if(re||L(3),y+=15&re,J=p[ne],ne>3&&(se=o[ne],J+=k(e,y)&(1<<se)-1,y+=se),y>M){f&&L(0);break}u&&g(v+131072);var ie=v+te;if(v<J){var oe=l-J,ae=Math.min(J,ie);for(oe+v<0&&L(3);v<ae;++v)r[v]=n[oe+v]}for(;v<ie;++v)r[v]=r[v-J]}}t.l=w,t.p=Z,t.b=v,t.f=m,w&&(m=1,t.m=S,t.d=b,t.n=P)}while(!m);return v!=r.length&&d?T(r,0,v):r.subarray(0,v)},R=function(e,t,s){s<<=7&t;var r=t/8|0;e[r]|=s,e[r+1]|=s>>8},O=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},N=function(e,t){for(var n=[],i=0;i<e.length;++i)e[i]&&n.push({s:i,f:e[i]});var o=n.length,a=n.slice();if(!o)return{t:$,l:0};if(1==o){var h=new s(n[0].s+1);return h[n[0].s]=1,{t:h,l:1}}n.sort(function(e,t){return e.f-t.f}),n.push({s:-1,f:25001});var l=n[0],c=n[1],d=0,u=1,p=2;for(n[0]={s:-1,f:l.f+c.f,l,r:c};u!=o-1;)l=n[n[d].f<n[p].f?d++:p++],c=n[d!=u&&n[d].f<n[p].f?d++:p++],n[u++]={s:-1,f:l.f+c.f,l,r:c};var f=a[0].s;for(i=1;i<o;++i)a[i].s>f&&(f=a[i].s);var g=new r(f+1),m=U(n[u-1],g,0);if(m>t){i=0;var y=0,x=m-t,v=1<<x;for(a.sort(function(e,t){return g[t.s]-g[e.s]||e.f-t.f});i<o;++i){var w=a[i].s;if(!(g[w]>t))break;y+=v-(1<<m-g[w]),g[w]=t}for(y>>=x;y>0;){var b=a[i].s;g[b]<t?y-=1<<t-g[b]++-1:++i}for(;i>=0&&y;--i){var E=a[i].s;g[E]==t&&(--g[E],++y)}m=t}return{t:new s(g),l:m}},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),n=0,i=e[0],o=1,a=function(e){s[n++]=e},h=1;h<=t;++h)if(e[h]==i&&h!=t)++o;else{if(!i&&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(i),--o;o>6;o-=6)a(8304);o>2&&(a(o-3<<5|8208),o=0)}for(;o--;)a(i);o=1,i=e[h]}return{c:s.subarray(0,n),n:t}},D=function(e,t){for(var s=0,r=0;r<t.length;++r)s+=e[r]*t[r];return s},q=function(e,t,s){var r=s.length,n=I(t+2);e[n]=255&r,e[n+1]=r>>8,e[n+2]=255^e[n],e[n+3]=255^e[n+1];for(var i=0;i<r;++i)e[n+i+4]=s[i];return 8*(n+4+r)},H=function(e,t,s,n,h,l,c,d,u,p,f){R(t,f++,s),++h[256];for(var g=N(h,15),m=g.t,y=g.l,E=N(l,15),_=E.t,C=E.l,A=B(m),k=A.c,I=A.n,T=B(_),P=T.c,L=T.n,M=new r(19),U=0;U<k.length;++U)++M[31&k[U]];for(U=0;U<P.length;++U)++M[31&P[U]];for(var H=N(M,7),j=H.t,$=H.l,G=19;G>4&&!j[a[G-1]];--G);var V,F,z,Y,K=p+5<<3,W=D(h,v)+D(l,w)+c,J=D(h,m)+D(l,_)+c+14+3*G+D(M,j)+2*M[16]+3*M[17]+7*M[18];if(u>=0&&K<=W&&K<=J)return q(t,f,e.subarray(u,u+p));if(R(t,f,1+(J<W)),f+=2,J<W){V=x(m,y,0),F=m,z=x(_,C,0),Y=_;var X=x(j,$,0);for(R(t,f,I-257),R(t,f+5,L-1),R(t,f+10,G-4),f+=14,U=0;U<G;++U)R(t,f+3*U,j[a[U]]);f+=3*G;for(var Q=[k,P],Z=0;Z<2;++Z){var ee=Q[Z];for(U=0;U<ee.length;++U){var te=31&ee[U];R(t,f,X[te]),f+=j[te],te>15&&(R(t,f,ee[U]>>5&127),f+=ee[U]>>12)}}}else V=b,F=v,z=S,Y=w;for(U=0;U<d;++U){var se=n[U];if(se>255){O(t,f,V[257+(te=se>>18&31)]),f+=F[te+257],te>7&&(R(t,f,se>>23&31),f+=i[te]);var re=31&se;O(t,f,z[re]),f+=Y[re],re>3&&(O(t,f,se>>5&8191),f+=o[re])}else O(t,f,V[se]),f+=F[se]}return O(t,f,V[256]),f+F[256]},j=new n([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),$=new s(0),G=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),g=p.subarray(h,p.length-l),m=c.l,y=7&(c.r||0);if(t){y&&(g[0]=c.r>>3);for(var x=j[t-1],v=x>>13,w=8191&x,b=(1<<a)-1,E=c.p||new r(32768),S=c.h||new r(b+1),_=Math.ceil(a/3),C=2*_,A=function(t){return(e[t]^e[t+1]<<_^e[t+2]<<C)&b},k=new n(25e3),P=new r(288),L=new r(32),M=0,R=0,O=c.i||0,N=0,U=c.w||0,B=0;O+2<u;++O){var D=A(O),$=32767&O,G=S[D];if(E[$]=G,S[D]=$,U<=O){var V=u-O;if((M>7e3||N>24576)&&(V>423||!m)){y=H(e,g,0,k,P,L,R,N,B,O-B,y),N=M=R=0,B=O;for(var F=0;F<286;++F)P[F]=0;for(F=0;F<30;++F)L[F]=0}var z=2,Y=0,K=w,W=$-G&32767;if(V>2&&D==A(O-W))for(var J=Math.min(v,V)-1,X=Math.min(32767,O),Q=Math.min(258,V);W<=X&&--K&&$!=G;){if(e[O+z]==e[O+z-W]){for(var Z=0;Z<Q&&e[O+Z]==e[O+Z-W];++Z);if(Z>z){if(z=Z,Y=W,Z>J)break;var ee=Math.min(W,Z-2),te=0;for(F=0;F<ee;++F){var se=O-W+F&32767,re=se-E[se]&32767;re>te&&(te=re,G=se)}}}W+=($=G)-(G=E[$])&32767}if(Y){k[N++]=268435456|d[z]<<18|f[Y];var ne=31&d[z],ie=31&f[Y];R+=i[ne]+o[ie],++P[257+ne],++L[ie],U=O+z,++M}else k[N++]=e[O],++P[e[O]]}}for(O=Math.max(O,U);O<u;++O)k[N++]=e[O],++P[e[O]];y=H(e,g,m,k,P,L,R,N,B,O-B,y),m||(c.r=7&y|g[y/8|0]<<3,y-=7,c.h=S,c.p=E,c.i=O,c.w=U)}else{for(O=c.w||0;O<u+m;O+=65535){var oe=O+65535;oe>=u&&(g[y/8|0]=m,oe=u),y=q(g,y+1,e.subarray(O,oe))}c.i=u}return T(p,0,h+I(y)+l)},V=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}(),F=function(){var e=-1;return{p:function(t){for(var s=e,r=0;r<t.length;++r)s=V[255&s^t[r]]^s>>>8;e=s},d:function(){return~e}}},z=function(e,t,r,n,i){if(!i&&(i={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,i.w=o.length}return G(e,null==t.level?6:t.level,null==t.mem?i.l?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):20:12+t.mem,r,n,i)},Y=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},K=function(e,t){return e[t]|e[t+1]<<8},W=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},J=function(e,t){return W(e,t)+4294967296*W(e,t+4)},X=function(e,t,s){for(;s;++t)e[t]=s,s>>>=8};function Q(e,t){return z(e,t||{},0,0)}function Z(e,t){return M(e,{i:2},t&&t.out,t&&t.dictionary)}var ee=function(e,t,r,n){for(var i in e){var o=e[i],a=t+i,h=n;Array.isArray(o)&&(h=Y(n,o[1]),o=o[0]),o instanceof s?r[a]=[o,h]:(r[a+="/"]=[new s(0),h],ee(o,a,r,n))}},te="undefined"!=typeof TextEncoder&&new TextEncoder,se="undefined"!=typeof TextDecoder&&new TextDecoder;try{se.decode($,{stream:!0})}catch(e){}var re=function(e){for(var t="",s=0;;){var r=e[s++],n=(r>127)+(r>223)+(r>239);if(s+n>e.length)return{s:t,r:T(e,s-1)};n?3==n?(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&n?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 ne(e,t){if(t){for(var r=new s(e.length),n=0;n<e.length;++n)r[n]=e.charCodeAt(n);return r}if(te)return te.encode(e);var i=e.length,o=new s(e.length+(e.length>>1)),a=0,h=function(e){o[a++]=e};for(n=0;n<i;++n){if(a+5>o.length){var l=new s(a+8+(i-n<<1));l.set(o),o=l}var c=e.charCodeAt(n);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(++n))>>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 ie(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 n=re(e),i=n.s;return(s=n.r).length&&L(8),i}var oe=function(e,t){return t+30+K(e,t+26)+K(e,t+28)},ae=function(e,t,s){var r=K(e,t+28),n=ie(e.subarray(t+46,t+46+r),!(2048&K(e,t+8))),i=t+46+r,o=W(e,t+20),a=s&&4294967295==o?he(e,i):[o,W(e,t+24),W(e,t+42)],h=a[0],l=a[1],c=a[2];return[K(e,t+10),h,l,n,i+K(e,t+30)+K(e,t+32),c]},he=function(e,t){for(;1!=K(e,t);t+=4+K(e,t+2));return[J(e,t+12),J(e,t+4),J(e,t+20)]},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,n,i,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|(i<0&&8),e[t++]=n&&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!=i&&(X(e,t,s.crc),X(e,t+4,i<0?-i-2:i),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 g=l[f],m=g.length;X(e,t,+f),X(e,t+2,m),e.set(g,t+4),t+=4+m}return c&&(e.set(a,t),t+=c),t},de=function(e,t,s,r,n){X(e,t,101010256),X(e,t+8,s),X(e,t+10,s),X(e,t+12,r),X(e,t+16,n)};t.zipSync=function(e,t){t||(t={});var r={},n=[];ee(e,"",r,t);var i=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=(_=ne(a)).length,p=c.comment,f=p&&ne(p),g=f&&f.length,m=le(c.extra);u>65535&&L(11);var y=d?Q(l,c):l,x=y.length,v=F();v.p(l),n.push(Y(c,{size:l.length,crc:v.d(),c:y,f:_,m:f,u:u!=a.length||f&&p.length!=g,o:i,compression:d})),i+=30+u+m+x,o+=76+2*(u+m)+(g||0)+x}for(var w=new s(o+22),b=i,E=o-i,S=0;S<n.length;++S){var _=n[S];ce(w,_.o,_,_.f,_.u,_.c.length);var C=30+_.f.length+le(_.extra);w.set(_.c,_.o+C),ce(w,i,_,_.f,_.u,_.c.length,_.o,_.m),i+=16+C+(_.m?_.m.length:0)}return de(w,i,n.length,E,b),w};"function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout&&setTimeout;t.unzipSync=function(e,t){for(var r={},n=e.length-22;101010256!=W(e,n);--n)(!n||e.length-n>65558)&&L(13);var i=K(e,n+8);if(!i)return{};var o=W(e,n+16),a=4294967295==o||65535==i;if(a){var h=W(e,n-12);(a=101075792==W(e,h))&&(i=W(e,h+32),o=W(e,h+48))}for(var l=t&&t.filter,c=0;c<i;++c){var d=ae(e,o,a),u=d[0],p=d[1],f=d[2],g=d[3],m=d[4],y=d[5],x=oe(e,y);o=m,l&&!l({name:g,size:p,originalSize:f,compression:u})||(u?8==u?r[g]=Z(e.subarray(x,x+p),{out:new s(f)}):L(14,"unknown compression type "+u):r[g]=T(e,x,x+p))}return r}}};const t={};let s=function s(r){const n=t[r];if(void 0!==n)return n.exports;const i=t[r]={exports:{}};return e[r].call(i.exports,i,i.exports,s),i.exports}(44);return s=s.default,s})());
|
|
2
|
+
!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,78,5,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,199,7,137,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,55,9,266,3,10,1,2,0,49,6,4,4,14,10,5350,0,7,14,11465,27,2343,9,87,9,39,4,60,6,26,9,535,9,470,0,2,54,8,3,82,0,12,1,19628,1,4178,9,519,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,233,0,3,0,8,1,6,0,475,6,110,6,6,9,4759,9,787719,239],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,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,7,25,39,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,5,57,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,31,9,2,0,3,0,2,37,2,0,26,0,2,0,45,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,200,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,24,43,261,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,33,24,3,24,45,74,6,0,67,12,65,1,2,0,15,4,10,7381,42,31,98,114,8702,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,208,30,2,2,2,1,2,6,3,4,10,1,225,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4381,3,5773,3,7472,16,621,2467,541,1507,4938,6,8489],r="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽ-ೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-Ა-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ--ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",n={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"},i="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:i,"5module":i+" export import",6:i+" 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 g={beforeExpr:!0},m={startsExpr:!0},y={};function x(e,t){return void 0===t&&(t={}),t.keyword=e,y[e]=new p(e,t)}var v={num:new p("num",m),regexp:new p("regexp",m),string:new p("string",m),name:new p("name",m),privateId:new p("privateId",m),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(",",g),semi:new p(";",g),colon:new p(":",g),dot:new p("."),question:new p("?",g),questionDot:new p("?."),arrow:new p("=>",g),template:new p("template"),invalidTemplate:new p("invalidTemplate"),ellipsis:new p("...",g),backQuote:new p("`",m),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:x("break"),_case:x("case",g),_catch:x("catch"),_continue:x("continue"),_debugger:x("debugger"),_default:x("default",g),_do:x("do",{isLoop:!0,beforeExpr:!0}),_else:x("else",g),_finally:x("finally"),_for:x("for",{isLoop:!0}),_function:x("function",m),_if:x("if"),_return:x("return",g),_switch:x("switch"),_throw:x("throw",g),_try:x("try"),_var:x("var"),_const:x("const"),_while:x("while",{isLoop:!0}),_with:x("with"),_new:x("new",{beforeExpr:!0,startsExpr:!0}),_this:x("this",m),_super:x("super",m),_class:x("class",m),_extends:x("extends",g),_export:x("export"),_import:x("import",m),_null:x("null",m),_true:x("true",m),_false:x("false",m),_in:x("in",{beforeExpr:!0,binop:7}),_instanceof:x("instanceof",{beforeExpr:!0,binop:7}),_typeof:x("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:x("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:x("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},w=/\r\n?|\n|\u2028|\u2029/,b=new RegExp(w.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 n=e.charCodeAt(r);if(E(n))return r<s-1&&13===n&&10===e.charCodeAt(r+1)?r+2:r+1}return-1}var _=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,C=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,A=Object.prototype,k=A.hasOwnProperty,I=A.toString,T=Object.hasOwn||function(e,t){return k.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 O=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,N=function(e,t){this.line=e,this.column=t};N.prototype.offset=function(e){return new N(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 n=S(e,r,t);if(n<0)return new N(s,t-r);++s,r=n}}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,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},H=!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?(!H&&"object"==typeof console&&console.warn&&(H=!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,n,i,o,a){var h={type:s?"Block":"Line",value:r,start:n,end:i};e.locations&&(h.loc=new U(this,o,a)),e.ranges&&(h.range=[n,i]),t.push(h)}}(t,t.onComment)),"commonjs"===t.sourceType&&t.allowAwaitOutsideFunction)throw new Error("Cannot use allowAwaitOutsideFunction with sourceType: commonjs");return t}var j=256,G=259;function $(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=n[e.ecmaVersion>=6?6:5===e.ecmaVersion?5:3],"module"===e.sourceType&&(r+=" await")),this.reservedWords=M(r);var i=(r?r+" ":"")+n.strict;this.reservedWordsStrict=M(i),this.reservedWordsStrictBind=M(i+" "+n.strictBind),this.input=String(t),this.containsEsc=!1,s?(this.pos=s,this.lineStart=this.input.lastIndexOf("\n",s-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(w).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=v.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=[]},V={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)})},V.inFunction.get=function(){return(2&this.currentVarScope().flags)>0},V.inGenerator.get=function(){return(8&this.currentVarScope().flags)>0},V.inAsync.get=function(){return(4&this.currentVarScope().flags)>0},V.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},V.allowReturn.get=function(){return!!this.inFunction||!!(this.options.allowReturnOutsideFunction&&1&this.currentVarScope().flags)},V.allowSuper.get=function(){return(64&this.currentThisScope().flags)>0||this.options.allowSuperOutsideMethod},V.allowDirectSuper.get=function(){return(128&this.currentThisScope().flags)>0},V.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())},V.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},V.allowUsing.get=function(){var e=this.currentScope().flags;return!(1024&e||!this.inModule&&1&e)},V.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&j)>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,V);var z=F.prototype,Y=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;z.strictDirective=function(e){if(this.options.ecmaVersion<5)return!1;for(;;){C.lastIndex=e,e+=C.exec(this.input)[0].length;var t=Y.exec(this.input.slice(e));if(!t)return!1;if("use strict"===(t[1]||t[2])){C.lastIndex=e+t[0].length;var s=C.exec(this.input),r=s.index+s[0].length,n=this.input.charAt(r);return";"===n||"}"===n||w.test(s[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(n)||"!"===n&&"="===this.input.charAt(r+1))}e+=t[0].length,C.lastIndex=e,e+=C.exec(this.input)[0].length,";"===this.input[e]&&e++}},z.eat=function(e){return this.type===e&&(this.next(),!0)},z.isContextual=function(e){return this.type===v.name&&this.value===e&&!this.containsEsc},z.eatContextual=function(e){return!!this.isContextual(e)&&(this.next(),!0)},z.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")}},z.expectContextual=function(e){this.eatContextual(e)||this.unexpected()},z.canInsertSemicolon=function(){return this.type===v.eof||this.type===v.braceR||w.test(this.input.slice(this.lastTokEnd,this.start))},z.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},z.semicolon=function(){this.eat(v.semi)||this.insertSemicolon()||this.unexpected()},z.afterTrailingComma=function(e,t){if(this.type===e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),t||this.next(),!0},z.expect=function(e){this.eat(e)||this.unexpected()},z.unexpected=function(e){this.raise(null!=e?e:this.start,"Unexpected token")};var K=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};z.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")}},z.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")},z.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")},z.isSimpleAssignTarget=function(e){return"ParenthesizedExpression"===e.type?this.isSimpleAssignTarget(e.expression):"Identifier"===e.type||"MemberExpression"===e.type};var W=F.prototype;W.parseTopLevel=function(e){var t=Object.create(null);for(e.body||(e.body=[]);this.type!==v.eof;){var s=this.parseStatement(null,!0,t);e.body.push(s)}if(this.inModule)for(var r=0,n=Object.keys(this.undefinedExports);r<n.length;r+=1){var i=n[r];this.raiseRecoverable(this.undefinedExports[i].start,"Export '"+i+"' 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 J={kind:"loop"},X={kind:"switch"};W.isLet=function(e){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;C.lastIndex=this.pos;var t=C.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 n=s;do{s+=r<=65535?1:2}while(u(r=this.fullCharCodeAt(s)));if(92===r)return!0;var i=this.input.slice(n,s);if(!a.test(i))return!0}return!1},W.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;C.lastIndex=this.pos;var e,t=C.exec(this.input),s=this.pos+t[0].length;return!(w.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))},W.isUsingKeyword=function(e,t){if(this.options.ecmaVersion<17||!this.isContextual(e?"await":"using"))return!1;C.lastIndex=this.pos;var s=C.exec(this.input),r=this.pos+s[0].length;if(w.test(this.input.slice(this.pos,r)))return!1;if(e){var n,i=r+5;if("using"!==this.input.slice(r,i)||i===this.input.length||u(n=this.fullCharCodeAt(i))||92===n)return!1;C.lastIndex=i;var o=C.exec(this.input);if(r=i+o[0].length,o&&w.test(this.input.slice(i,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&&(C.lastIndex=r,r+=C.exec(this.input)[0].length,61!==this.input.charCodeAt(r)||61===(h=this.input.charCodeAt(r+1))||62===h))},W.isAwaitUsing=function(e){return this.isUsingKeyword(!0,e)},W.isUsing=function(e){return this.isUsingKeyword(!1,e)},W.parseStatement=function(e,t,s){var r,n=this.type,i=this.startNode();switch(this.isLet(e)&&(n=v._var,r="let"),n){case v._break:case v._continue:return this.parseBreakContinueStatement(i,n.keyword);case v._debugger:return this.parseDebuggerStatement(i);case v._do:return this.parseDoStatement(i);case v._for:return this.parseForStatement(i);case v._function:return e&&(this.strict||"if"!==e&&"label"!==e)&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(i,!1,!e);case v._class:return e&&this.unexpected(),this.parseClass(i,!0);case v._if:return this.parseIfStatement(i);case v._return:return this.parseReturnStatement(i);case v._switch:return this.parseSwitchStatement(i);case v._throw:return this.parseThrowStatement(i);case v._try:return this.parseTryStatement(i);case v._const:case v._var:return r=r||this.value,e&&"var"!==r&&this.unexpected(),this.parseVarStatement(i,r);case v._while:return this.parseWhileStatement(i);case v._with:return this.parseWithStatement(i);case v.braceL:return this.parseBlock(!0,i);case v.semi:return this.parseEmptyStatement(i);case v._export:case v._import:if(this.options.ecmaVersion>10&&n===v._import){C.lastIndex=this.pos;var o=C.exec(this.input),a=this.pos+o[0].length,h=this.input.charCodeAt(a);if(40===h||46===h)return this.parseExpressionStatement(i,this.parseExpression())}return this.options.allowImportExportEverywhere||(t||this.raise(this.start,"'import' and 'export' may only appear at the top level"),this.inModule||this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")),n===v._import?this.parseImport(i):this.parseExport(i,s);default:if(this.isAsyncFunction())return e&&this.unexpected(),this.next(),this.parseFunctionStatement(i,!0,!e);var l=this.isAwaitUsing(!1)?"await using":this.isUsing(!1)?"using":null;if(l)return this.allowUsing||this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script` or in the bare case statement"),e&&this.raise(this.start,"Using declaration is not allowed in single-statement positions"),"await using"===l&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.next(),this.parseVar(i,!1,l),this.semicolon(),this.finishNode(i,"VariableDeclaration");var c=this.value,d=this.parseExpression();return n===v.name&&"Identifier"===d.type&&this.eat(v.colon)?this.parseLabeledStatement(i,c,d,e):this.parseExpressionStatement(i,d)}},W.parseBreakContinueStatement=function(e,t){var s="break"===t;this.next(),this.eat(v.semi)||this.insertSemicolon()?e.label=null:this.type!==v.name?this.unexpected():(e.label=this.parseIdent(),this.semicolon());for(var r=0;r<this.labels.length;++r){var n=this.labels[r];if(null==e.label||n.name===e.label.name){if(null!=n.kind&&(s||"loop"===n.kind))break;if(e.label&&s)break}}return r===this.labels.length&&this.raise(e.start,"Unsyntactic "+t),this.finishNode(e,s?"BreakStatement":"ContinueStatement")},W.parseDebuggerStatement=function(e){return this.next(),this.semicolon(),this.finishNode(e,"DebuggerStatement")},W.parseDoStatement=function(e){return this.next(),this.labels.push(J),e.body=this.parseStatement("do"),this.labels.pop(),this.expect(v._while),e.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(v.semi):this.semicolon(),this.finishNode(e,"DoWhileStatement")},W.parseForStatement=function(e){this.next();var t=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(J),this.enterScope(0),this.expect(v.parenL),this.type===v.semi)return t>-1&&this.unexpected(t),this.parseFor(e,null);var s=this.isLet();if(this.type===v._var||this.type===v._const||s){var r=this.startNode(),n=s?"let":this.value;return this.next(),this.parseVar(r,!0,n),this.finishNode(r,"VariableDeclaration"),this.parseForAfterInit(e,r,t)}var i=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 K,d=this.start,u=t>-1?this.parseExprSubscripts(c,"await"):this.parseExpression(!0,c);return this.type===v._in||(o=this.options.ecmaVersion>=6&&this.isContextual("of"))?(t>-1?(this.type===v._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()),i&&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))},W.parseForAfterInit=function(e,t,s){return(this.type===v._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&1===t.declarations.length?(this.type===v._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))},W.parseFunctionStatement=function(e,t,s){return this.next(),this.parseFunction(e,Z|(s?0:ee),!1,t)},W.parseIfStatement=function(e){return this.next(),e.test=this.parseParenExpression(),e.consequent=this.parseStatement("if"),e.alternate=this.eat(v._else)?this.parseStatement("if"):null,this.finishNode(e,"IfStatement")},W.parseReturnStatement=function(e){return this.allowReturn||this.raise(this.start,"'return' outside of function"),this.next(),this.eat(v.semi)||this.insertSemicolon()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,"ReturnStatement")},W.parseSwitchStatement=function(e){var t;this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(v.braceL),this.labels.push(X),this.enterScope(1024);for(var s=!1;this.type!==v.braceR;)if(this.type===v._case||this.type===v._default){var r=this.type===v._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(v.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")},W.parseThrowStatement=function(e){return this.next(),w.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=[];W.parseCatchClauseParam=function(){var e=this.parseBindingAtom(),t="Identifier"===e.type;return this.enterScope(t?32:0),this.checkLValPattern(e,t?4:2),this.expect(v.parenR),e},W.parseTryStatement=function(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.type===v._catch){var t=this.startNode();this.next(),this.eat(v.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(v._finally)?this.parseBlock():null,e.handler||e.finalizer||this.raise(e.start,"Missing catch or finally clause"),this.finishNode(e,"TryStatement")},W.parseVarStatement=function(e,t,s){return this.next(),this.parseVar(e,!1,t,s),this.semicolon(),this.finishNode(e,"VariableDeclaration")},W.parseWhileStatement=function(e){return this.next(),e.test=this.parseParenExpression(),this.labels.push(J),e.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(e,"WhileStatement")},W.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")},W.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,"EmptyStatement")},W.parseLabeledStatement=function(e,t,s,r){for(var n=0,i=this.labels;n<i.length;n+=1)i[n].name===t&&this.raise(s.start,"Label '"+t+"' is already declared");for(var o=this.type.isLoop?"loop":this.type===v._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")},W.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,"ExpressionStatement")},W.parseBlock=function(e,t,s){for(void 0===e&&(e=!0),void 0===t&&(t=this.startNode()),t.body=[],this.expect(v.braceL),e&&this.enterScope(0);this.type!==v.braceR;){var r=this.parseStatement(null);t.body.push(r)}return s&&(this.strict=!1),this.next(),e&&this.exitScope(),this.finishNode(t,"BlockStatement")},W.parseFor=function(e,t){return e.init=t,this.expect(v.semi),e.test=this.type===v.semi?null:this.parseExpression(),this.expect(v.semi),e.update=this.type===v.parenR?null:this.parseExpression(),this.expect(v.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,"ForStatement")},W.parseForIn=function(e,t){var s=this.type===v._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(v.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,s?"ForInStatement":"ForOfStatement")},W.parseVar=function(e,t,s,r){for(e.declarations=[],e.kind=s;;){var n=this.startNode();if(this.parseVarId(n,s),this.eat(v.eq)?n.init=this.parseMaybeAssign(t):r||"const"!==s||this.type===v._in||this.options.ecmaVersion>=6&&this.isContextual("of")?r||"using"!==s&&"await using"!==s||!(this.options.ecmaVersion>=17)||this.type===v._in||this.isContextual("of")?r||"Identifier"===n.id.type||t&&(this.type===v._in||this.isContextual("of"))?n.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(n,"VariableDeclarator")),!this.eat(v.comma))break}return e},W.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 Z=1,ee=2;function te(e,t){var s=t.key.name,r=e[s],n="true";return"MethodDefinition"!==t.type||"get"!==t.kind&&"set"!==t.kind||(n=(t.static?"s":"i")+t.kind),"iget"===r&&"iset"===n||"iset"===r&&"iget"===n||"sget"===r&&"sset"===n||"sset"===r&&"sget"===n?(e[s]="true",!1):!!r||(e[s]=n,!1)}function se(e,t){var s=e.computed,r=e.key;return!s&&("Identifier"===r.type&&r.name===t||"Literal"===r.type&&r.value===t)}W.parseFunction=function(e,t,s,r,n){this.initFunction(e),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!r)&&(this.type===v.star&&t&ee&&this.unexpected(),e.generator=this.eat(v.star)),this.options.ecmaVersion>=8&&(e.async=!!r),t&Z&&(e.id=4&t&&this.type!==v.name?null:this.parseIdent(),!e.id||t&ee||this.checkLValSimple(e.id,this.strict||e.generator||e.async?this.treatFunctionsAsVar?1:2:3));var i=this.yieldPos,o=this.awaitPos,a=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope($(e.async,e.generator)),t&Z||(e.id=this.type===v.name?this.parseIdent():null),this.parseFunctionParams(e),this.parseFunctionBody(e,s,!1,n),this.yieldPos=i,this.awaitPos=o,this.awaitIdentPos=a,this.finishNode(e,t&Z?"FunctionDeclaration":"FunctionExpression")},W.parseFunctionParams=function(e){this.expect(v.parenL),e.params=this.parseBindingList(v.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},W.parseClass=function(e,t){this.next();var s=this.strict;this.strict=!0,this.parseClassId(e,t),this.parseClassSuper(e);var r=this.enterClassBody(),n=this.startNode(),i=!1;for(n.body=[],this.expect(v.braceL);this.type!==v.braceR;){var o=this.parseClassElement(null!==e.superClass);o&&(n.body.push(o),"MethodDefinition"===o.type&&"constructor"===o.kind?(i&&this.raiseRecoverable(o.start,"Duplicate constructor in the same class"),i=!0):o.key&&"PrivateIdentifier"===o.key.type&&te(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(n,"ClassBody"),this.exitClassBody(),this.finishNode(e,t?"ClassDeclaration":"ClassExpression")},W.parseClassElement=function(e){if(this.eat(v.semi))return null;var t=this.options.ecmaVersion,s=this.startNode(),r="",n=!1,i=!1,o="method",a=!1;if(this.eatContextual("static")){if(t>=13&&this.eat(v.braceL))return this.parseClassStaticBlock(s),s;this.isClassElementNameStart()||this.type===v.star?a=!0:r="static"}if(s.static=a,!r&&t>=8&&this.eatContextual("async")&&(!this.isClassElementNameStart()&&this.type!==v.star||this.canInsertSemicolon()?r="async":i=!0),!r&&(t>=9||!i)&&this.eat(v.star)&&(n=!0),!r&&!i&&!n){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===v.parenL||"method"!==o||n||i){var l=!s.static&&se(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,n,i,c)}else this.parseClassField(s);return s},W.isClassElementNameStart=function(){return this.type===v.name||this.type===v.privateId||this.type===v.num||this.type===v.string||this.type===v.bracketL||this.type.keyword},W.parseClassElementName=function(e){this.type===v.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)},W.parseClassMethod=function(e,t,s,r){var n=e.key;"constructor"===e.kind?(t&&this.raise(n.start,"Constructor can't be a generator"),s&&this.raise(n.start,"Constructor can't be an async method")):e.static&&se(e,"prototype")&&this.raise(n.start,"Classes may not have a static property named prototype");var i=e.value=this.parseMethod(t,s,r);return"get"===e.kind&&0!==i.params.length&&this.raiseRecoverable(i.start,"getter should have no params"),"set"===e.kind&&1!==i.params.length&&this.raiseRecoverable(i.start,"setter should have exactly one param"),"set"===e.kind&&"RestElement"===i.params[0].type&&this.raiseRecoverable(i.params[0].start,"Setter cannot use rest params"),this.finishNode(e,"MethodDefinition")},W.parseClassField=function(e){return se(e,"constructor")?this.raise(e.key.start,"Classes can't have a field named 'constructor'"):e.static&&se(e,"prototype")&&this.raise(e.key.start,"Classes can't have a static field named 'prototype'"),this.eat(v.eq)?(this.enterScope(576),e.value=this.parseMaybeAssign(),this.exitScope()):e.value=null,this.semicolon(),this.finishNode(e,"PropertyDefinition")},W.parseClassStaticBlock=function(e){e.body=[];var t=this.labels;for(this.labels=[],this.enterScope(320);this.type!==v.braceR;){var s=this.parseStatement(null);e.body.push(s)}return this.next(),this.exitScope(),this.labels=t,this.finishNode(e,"StaticBlock")},W.parseClassId=function(e,t){this.type===v.name?(e.id=this.parseIdent(),t&&this.checkLValSimple(e.id,2,!1)):(!0===t&&this.unexpected(),e.id=null)},W.parseClassSuper=function(e){e.superClass=this.eat(v._extends)?this.parseExprSubscripts(null,!1):null},W.enterClassBody=function(){var e={declared:Object.create(null),used:[]};return this.privateNameStack.push(e),e.declared},W.exitClassBody=function(){var e=this.privateNameStack.pop(),t=e.declared,s=e.used;if(this.options.checkPrivateFields)for(var r=this.privateNameStack.length,n=0===r?null:this.privateNameStack[r-1],i=0;i<s.length;++i){var o=s[i];T(t,o.name)||(n?n.used.push(o):this.raiseRecoverable(o.start,"Private field '#"+o.name+"' must be declared in an enclosing class"))}},W.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!==v.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ExportAllDeclaration")},W.parseExport=function(e,t){if(this.next(),this.eat(v.star))return this.parseExportAllDeclaration(e,t);if(this.eat(v._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!==v.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 n=r[s];this.checkUnreserved(n.local),this.checkLocalExport(n.local),"Literal"===n.local.type&&this.raise(n.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")},W.parseExportDeclaration=function(e){return this.parseStatement(null)},W.parseExportDefaultDeclaration=function(){var e;if(this.type===v._function||(e=this.isAsyncFunction())){var t=this.startNode();return this.next(),e&&this.next(),this.parseFunction(t,4|Z,!1,e)}if(this.type===v._class){var s=this.startNode();return this.parseClass(s,"nullableID")}var r=this.parseMaybeAssign();return this.semicolon(),r},W.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)},W.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,n=t.properties;r<n.length;r+=1){var i=n[r];this.checkPatternExport(e,i)}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)},W.checkVariableExport=function(e,t){if(e)for(var s=0,r=t;s<r.length;s+=1){var n=r[s];this.checkPatternExport(e,n.id)}},W.shouldParseExportStatement=function(){return"var"===this.type.keyword||"const"===this.type.keyword||"class"===this.type.keyword||"function"===this.type.keyword||this.isLet()||this.isAsyncFunction()},W.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")},W.parseExportSpecifiers=function(e){var t=[],s=!0;for(this.expect(v.braceL);!this.eat(v.braceR);){if(s)s=!1;else if(this.expect(v.comma),this.afterTrailingComma(v.braceR))break;t.push(this.parseExportSpecifier(e))}return t},W.parseImport=function(e){return this.next(),this.type===v.string?(e.specifiers=Q,e.source=this.parseExprAtom()):(e.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),e.source=this.type===v.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ImportDeclaration")},W.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")},W.parseImportDefaultSpecifier=function(){var e=this.startNode();return e.local=this.parseIdent(),this.checkLValSimple(e.local,2),this.finishNode(e,"ImportDefaultSpecifier")},W.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")},W.parseImportSpecifiers=function(){var e=[],t=!0;if(this.type===v.name&&(e.push(this.parseImportDefaultSpecifier()),!this.eat(v.comma)))return e;if(this.type===v.star)return e.push(this.parseImportNamespaceSpecifier()),e;for(this.expect(v.braceL);!this.eat(v.braceR);){if(t)t=!1;else if(this.expect(v.comma),this.afterTrailingComma(v.braceR))break;e.push(this.parseImportSpecifier())}return e},W.parseWithClause=function(){var e=[];if(!this.eat(v._with))return e;this.expect(v.braceL);for(var t={},s=!0;!this.eat(v.braceR);){if(s)s=!1;else if(this.expect(v.comma),this.afterTrailingComma(v.braceR))break;var r=this.parseImportAttribute(),n="Identifier"===r.key.type?r.key.name:r.key.value;T(t,n)&&this.raiseRecoverable(r.key.start,"Duplicate attribute key '"+n+"'"),t[n]=!0,e.push(r)}return e},W.parseImportAttribute=function(){var e=this.startNode();return e.key=this.type===v.string?this.parseExprAtom():this.parseIdent("never"!==this.options.allowReserved),this.expect(v.colon),this.type!==v.string&&this.unexpected(),e.value=this.parseExprAtom(),this.finishNode(e,"ImportAttribute")},W.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===v.string){var e=this.parseLiteral(this.value);return O.test(e.value)&&this.raise(e.start,"An export name cannot include a lone surrogate."),e}return this.parseIdent(!0)},W.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)},W.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 re=F.prototype;re.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,n=e.properties;r<n.length;r+=1){var i=n[r];this.toAssignable(i,t),"RestElement"!==i.type||"ArrayPattern"!==i.argument.type&&"ObjectPattern"!==i.argument.type||this.raise(i.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},re.toAssignableList=function(e,t){for(var s=e.length,r=0;r<s;r++){var n=e[r];n&&this.toAssignable(n,t)}if(s){var i=e[s-1];6===this.options.ecmaVersion&&t&&i&&"RestElement"===i.type&&"Identifier"!==i.argument.type&&this.unexpected(i.argument.start)}return e},re.parseSpread=function(e){var t=this.startNode();return this.next(),t.argument=this.parseMaybeAssign(!1,e),this.finishNode(t,"SpreadElement")},re.parseRestBinding=function(){var e=this.startNode();return this.next(),6===this.options.ecmaVersion&&this.type!==v.name&&this.unexpected(),e.argument=this.parseBindingAtom(),this.finishNode(e,"RestElement")},re.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case v.bracketL:var e=this.startNode();return this.next(),e.elements=this.parseBindingList(v.bracketR,!0,!0),this.finishNode(e,"ArrayPattern");case v.braceL:return this.parseObj(!0)}return this.parseIdent()},re.parseBindingList=function(e,t,s,r){for(var n=[],i=!0;!this.eat(e);)if(i?i=!1:this.expect(v.comma),t&&this.type===v.comma)n.push(null);else{if(s&&this.afterTrailingComma(e))break;if(this.type===v.ellipsis){var o=this.parseRestBinding();this.parseBindingListItem(o),n.push(o),this.type===v.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.expect(e);break}n.push(this.parseAssignableListItem(r))}return n},re.parseAssignableListItem=function(e){var t=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(t),t},re.parseBindingListItem=function(e){return e},re.parseMaybeDefault=function(e,t,s){if(s=s||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(v.eq))return s;var r=this.startNodeAt(e,t);return r.left=s,r.right=this.parseMaybeAssign(),this.finishNode(r,"AssignmentPattern")},re.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")}},re.checkLValPattern=function(e,t,s){switch(void 0===t&&(t=0),e.type){case"ObjectPattern":for(var r=0,n=e.properties;r<n.length;r+=1){var i=n[r];this.checkLValInnerPattern(i,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)}},re.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,n){this.token=e,this.isExpr=!!t,this.preserveSpace=!!s,this.override=r,this.generator=!!n},ie={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)},oe=F.prototype;oe.initialContext=function(){return[ie.b_stat]},oe.curContext=function(){return this.context[this.context.length-1]},oe.braceIsBlock=function(e){var t=this.curContext();return t===ie.f_expr||t===ie.f_stat||(e!==v.colon||t!==ie.b_stat&&t!==ie.b_expr?e===v._return||e===v.name&&this.exprAllowed?w.test(this.input.slice(this.lastTokEnd,this.start)):e===v._else||e===v.semi||e===v.eof||e===v.parenR||e===v.arrow||(e===v.braceL?t===ie.b_stat:e!==v._var&&e!==v._const&&e!==v.name&&!this.exprAllowed):!t.isExpr)},oe.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},oe.updateContext=function(e){var t,s=this.type;s.keyword&&e===v.dot?this.exprAllowed=!1:(t=s.updateContext)?t.call(this,e):this.exprAllowed=s.beforeExpr},oe.overrideContext=function(e){this.curContext()!==e&&(this.context[this.context.length-1]=e)},v.parenR.updateContext=v.braceR.updateContext=function(){if(1!==this.context.length){var e=this.context.pop();e===ie.b_stat&&"function"===this.curContext().token&&(e=this.context.pop()),this.exprAllowed=!e.isExpr}else this.exprAllowed=!0},v.braceL.updateContext=function(e){this.context.push(this.braceIsBlock(e)?ie.b_stat:ie.b_expr),this.exprAllowed=!0},v.dollarBraceL.updateContext=function(){this.context.push(ie.b_tmpl),this.exprAllowed=!0},v.parenL.updateContext=function(e){var t=e===v._if||e===v._for||e===v._with||e===v._while;this.context.push(t?ie.p_stat:ie.p_expr),this.exprAllowed=!0},v.incDec.updateContext=function(){},v._function.updateContext=v._class.updateContext=function(e){!e.beforeExpr||e===v._else||e===v.semi&&this.curContext()!==ie.p_stat||e===v._return&&w.test(this.input.slice(this.lastTokEnd,this.start))||(e===v.colon||e===v.braceL)&&this.curContext()===ie.b_stat?this.context.push(ie.f_stat):this.context.push(ie.f_expr),this.exprAllowed=!1},v.colon.updateContext=function(){"function"===this.curContext().token&&this.context.pop(),this.exprAllowed=!0},v.backQuote.updateContext=function(){this.curContext()===ie.q_tmpl?this.context.pop():this.context.push(ie.q_tmpl),this.exprAllowed=!1},v.star.updateContext=function(e){if(e===v._function){var t=this.context.length-1;this.context[t]===ie.f_expr?this.context[t]=ie.f_expr_gen:this.context[t]=ie.f_gen}this.exprAllowed=!0},v.name.updateContext=function(e){var t=!1;this.options.ecmaVersion>=6&&e!==v.dot&&("of"===this.value&&!this.exprAllowed||"yield"===this.value&&this.inGeneratorContext())&&(t=!0),this.exprAllowed=t};var ae=F.prototype;function he(e){return"Identifier"===e.type||"ParenthesizedExpression"===e.type&&he(e.expression)}function le(e){return"MemberExpression"===e.type&&"PrivateIdentifier"===e.property.type||"ChainExpression"===e.type&&le(e.expression)||"ParenthesizedExpression"===e.type&&le(e.expression)}ae.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,n=e.key;switch(n.type){case"Identifier":r=n.name;break;case"Literal":r=String(n.value);break;default:return}var i=e.kind;if(this.options.ecmaVersion>=6)"__proto__"===r&&"init"===i&&(t.proto&&(s?s.doubleProto<0&&(s.doubleProto=n.start):this.raiseRecoverable(n.start,"Redefinition of __proto__ property")),t.proto=!0);else{var o=t[r="$"+r];o?("init"===i?this.strict&&o.init||o.get||o.set:o.init||o[i])&&this.raiseRecoverable(n.start,"Redefinition of property"):o=t[r]={init:!1,get:!1,set:!1},o[i]=!0}}},ae.parseExpression=function(e,t){var s=this;return this.catchStackOverflow(function(){var r=s.start,n=s.startLoc,i=s.parseMaybeAssign(e,t);if(s.type===v.comma){var o=s.startNodeAt(r,n);for(o.expressions=[i];s.eat(v.comma);)o.expressions.push(s.parseMaybeAssign(e,t));return s.finishNode(o,"SequenceExpression")}return i})},ae.parseMaybeAssign=function(e,t,s){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(e);this.exprAllowed=!1}var r=!1,n=-1,i=-1,o=-1;t?(n=t.parenthesizedAssign,i=t.trailingComma,o=t.doubleProto,t.parenthesizedAssign=t.trailingComma=-1):(t=new K,r=!0);var a=this.start,h=this.startLoc;this.type!==v.parenL&&this.type!==v.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===v.eq&&(l=this.toAssignable(l,!1,t)),r||(t.parenthesizedAssign=t.trailingComma=t.doubleProto=-1),t.shorthandAssign>=l.start&&(t.shorthandAssign=-1),this.type===v.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),n>-1&&(t.parenthesizedAssign=n),i>-1&&(t.trailingComma=i),l},ae.parseMaybeConditional=function(e,t){var s=this.start,r=this.startLoc,n=this.parseExprOps(e,t);if(this.checkExpressionErrors(t))return n;if(("ArrowFunctionExpression"!==n.type||n.start!==s)&&this.eat(v.question)){var i=this.startNodeAt(s,r);return i.test=n,i.consequent=this.parseMaybeAssign(),this.expect(v.colon),i.alternate=this.parseMaybeAssign(e),this.finishNode(i,"ConditionalExpression")}return n},ae.parseExprOps=function(e,t){var s=this.start,r=this.startLoc,n=this.parseMaybeUnary(t,!1,!1,e);return this.checkExpressionErrors(t)||n.start===s&&"ArrowFunctionExpression"===n.type?n:this.parseExprOp(n,s,r,-1,e)},ae.parseExprOp=function(e,t,s,r,n){var i=this.type.binop;if(null!=i&&(!n||this.type!==v._in)&&i>r){var o=this.type===v.logicalOR||this.type===v.logicalAND,a=this.type===v.coalesce;a&&(i=v.logicalAND.binop);var h=this.value;this.next();var l=this.start,c=this.startLoc,d=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,n),l,c,i,n),u=this.buildBinary(t,s,e,d,h,o||a);return(o&&this.type===v.coalesce||a&&(this.type===v.logicalOR||this.type===v.logicalAND))&&this.raiseRecoverable(this.start,"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"),this.parseExprOp(u,t,s,r,n)}return e},ae.buildBinary=function(e,t,s,r,n,i){"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=n,o.right=r,this.finishNode(o,i?"LogicalExpression":"BinaryExpression")},ae.parseMaybeUnary=function(e,t,s,r){var n,i=this.start,o=this.startLoc;if(this.isContextual("await")&&this.canAwait)n=this.parseAwait(r),t=!0;else if(this.type.prefix){var a=this.startNode(),h=this.type===v.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&&he(a.argument)?this.raiseRecoverable(a.start,"Deleting local variable in strict mode"):"delete"===a.operator&&le(a.argument)?this.raiseRecoverable(a.start,"Private fields can not be deleted"):t=!0,n=this.finishNode(a,h?"UpdateExpression":"UnaryExpression")}else if(t||this.type!==v.privateId){if(n=this.parseExprSubscripts(e,r),this.checkExpressionErrors(e))return n;for(;this.type.postfix&&!this.canInsertSemicolon();){var l=this.startNodeAt(i,o);l.operator=this.value,l.prefix=!1,l.argument=n,this.checkLValSimple(n),this.next(),n=this.finishNode(l,"UpdateExpression")}}else(r||0===this.privateNameStack.length)&&this.options.checkPrivateFields&&this.unexpected(),n=this.parsePrivateIdent(),this.type!==v._in&&this.unexpected();return s||!this.eat(v.starstar)?n:t?void this.unexpected(this.lastTokStart):this.buildBinary(i,o,n,this.parseMaybeUnary(null,!1,!1,r),"**",!1)},ae.parseExprSubscripts=function(e,t){var s=this.start,r=this.startLoc,n=this.parseExprAtom(e,t);if("ArrowFunctionExpression"===n.type&&")"!==this.input.slice(this.lastTokStart,this.lastTokEnd))return n;var i=this.parseSubscripts(n,s,r,!1,t);return e&&"MemberExpression"===i.type&&(e.parenthesizedAssign>=i.start&&(e.parenthesizedAssign=-1),e.parenthesizedBind>=i.start&&(e.parenthesizedBind=-1),e.trailingComma>=i.start&&(e.trailingComma=-1)),i},ae.parseSubscripts=function(e,t,s,r,n){for(var i=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,i,o,n);if(a.optional&&(o=!0),a===e||"ArrowFunctionExpression"===a.type){if(o){var h=this.startNodeAt(t,s);h.expression=a,a=this.finishNode(h,"ChainExpression")}return a}e=a}},ae.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(v.arrow)},ae.parseSubscriptAsyncArrow=function(e,t,s,r){return this.parseArrowExpression(this.startNodeAt(e,t),s,!0,r)},ae.parseSubscript=function(e,t,s,r,n,i,o){var a=this.options.ecmaVersion>=11,h=a&&this.eat(v.questionDot);r&&h&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var l=this.eat(v.bracketL);if(l||h&&this.type!==v.parenL&&this.type!==v.backQuote||this.eat(v.dot)){var c=this.startNodeAt(t,s);c.object=e,l?(c.property=this.parseExpression(),this.expect(v.bracketR)):this.type===v.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(v.parenL)){var d=new K,u=this.yieldPos,p=this.awaitPos,f=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var g=this.parseExprList(v.parenR,this.options.ecmaVersion>=8,!1,d);if(n&&!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,g,o);this.checkExpressionErrors(d,!0),this.yieldPos=u||this.yieldPos,this.awaitPos=p||this.awaitPos,this.awaitIdentPos=f||this.awaitIdentPos;var m=this.startNodeAt(t,s);m.callee=e,m.arguments=g,a&&(m.optional=h),e=this.finishNode(m,"CallExpression")}else if(this.type===v.backQuote){(h||i)&&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},ae.parseExprAtom=function(e,t,s){this.type===v.slash&&this.readRegexp();var r,n=this.potentialArrowAt===this.start;switch(this.type){case v._super:return this.allowSuper||this.raise(this.start,"'super' keyword outside a method"),r=this.startNode(),this.next(),this.type!==v.parenL||this.allowDirectSuper||this.raise(r.start,"super() call outside constructor of a subclass"),this.type!==v.dot&&this.type!==v.bracketL&&this.type!==v.parenL&&this.unexpected(),this.finishNode(r,"Super");case v._this:return r=this.startNode(),this.next(),this.finishNode(r,"ThisExpression");case v.name:var i=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(v._function))return this.overrideContext(ie.f_expr),this.parseFunction(this.startNodeAt(i,o),0,!1,!0,t);if(n&&!this.canInsertSemicolon()){if(this.eat(v.arrow))return this.parseArrowExpression(this.startNodeAt(i,o),[h],!1,t);if(this.options.ecmaVersion>=8&&"async"===h.name&&this.type===v.name&&!a&&(!this.potentialArrowInForAwait||"of"!==this.value||this.containsEsc))return h=this.parseIdent(!1),!this.canInsertSemicolon()&&this.eat(v.arrow)||this.unexpected(),this.parseArrowExpression(this.startNodeAt(i,o),[h],!0,t)}return h;case v.regexp:var l=this.value;return(r=this.parseLiteral(l.value)).regex={pattern:l.pattern,flags:l.flags},r;case v.num:case v.string:return this.parseLiteral(this.value);case v._null:case v._true:case v._false:return(r=this.startNode()).value=this.type===v._null?null:this.type===v._true,r.raw=this.type.keyword,this.next(),this.finishNode(r,"Literal");case v.parenL:var c=this.start,d=this.parseParenAndDistinguishExpression(n,t);return e&&(e.parenthesizedAssign<0&&!this.isSimpleAssignTarget(d)&&(e.parenthesizedAssign=c),e.parenthesizedBind<0&&(e.parenthesizedBind=c)),d;case v.bracketL:return r=this.startNode(),this.next(),r.elements=this.parseExprList(v.bracketR,!0,!0,e),this.finishNode(r,"ArrayExpression");case v.braceL:return this.overrideContext(ie.b_expr),this.parseObj(!1,e);case v._function:return r=this.startNode(),this.next(),this.parseFunction(r,0);case v._class:return this.parseClass(this.startNode(),!1);case v._new:return this.parseNew();case v.backQuote:return this.parseTemplate();case v._import:return this.options.ecmaVersion>=11?this.parseExprImport(s):this.unexpected();default:return this.parseExprAtomDefault()}},ae.parseExprAtomDefault=function(){this.unexpected()},ae.parseExprImport=function(e){var t=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import"),this.next(),this.type===v.parenL&&!e)return this.parseDynamicImport(t);if(this.type===v.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()},ae.parseDynamicImport=function(e){if(this.next(),e.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(v.parenR)?e.options=null:(this.expect(v.comma),this.afterTrailingComma(v.parenR)?e.options=null:(e.options=this.parseMaybeAssign(),this.eat(v.parenR)||(this.expect(v.comma),this.afterTrailingComma(v.parenR)||this.unexpected())));else if(!this.eat(v.parenR)){var t=this.start;this.eat(v.comma)&&this.eat(v.parenR)?this.raiseRecoverable(t,"Trailing comma is not allowed in import()"):this.unexpected(t)}return this.finishNode(e,"ImportExpression")},ae.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")},ae.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")},ae.parseParenExpression=function(){this.expect(v.parenL);var e=this.parseExpression();return this.expect(v.parenR),e},ae.shouldParseArrow=function(e){return!this.canInsertSemicolon()},ae.parseParenAndDistinguishExpression=function(e,t){var s,r=this.start,n=this.startLoc,i=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 K,p=this.yieldPos,f=this.awaitPos;for(this.yieldPos=0,this.awaitPos=0;this.type!==v.parenR;){if(c?c=!1:this.expect(v.comma),i&&this.afterTrailingComma(v.parenR,!0)){d=!0;break}if(this.type===v.ellipsis){o=this.start,l.push(this.parseParenItem(this.parseRestBinding())),this.type===v.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}l.push(this.parseMaybeAssign(!1,u,this.parseParenItem))}var g=this.lastTokEnd,m=this.lastTokEndLoc;if(this.expect(v.parenR),e&&this.shouldParseArrow(l)&&this.eat(v.arrow))return this.checkPatternErrors(u,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=p,this.awaitPos=f,this.parseParenArrowList(r,n,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",g,m)):s=l[0]}else s=this.parseParenExpression();if(this.options.preserveParens){var y=this.startNodeAt(r,n);return y.expression=s,this.finishNode(y,"ParenthesizedExpression")}return s},ae.parseParenItem=function(e){return e},ae.parseParenArrowList=function(e,t,s,r){return this.parseArrowExpression(this.startNodeAt(e,t),s,!1,r)};var ce=[];ae.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===v.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,n=this.startLoc;return e.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),r,n,!0,!1),"Super"===e.callee.type&&this.raiseRecoverable(r,"Invalid use of 'super'"),this.eat(v.parenL)?e.arguments=this.parseExprList(v.parenR,this.options.ecmaVersion>=8,!1):e.arguments=ce,this.finishNode(e,"NewExpression")},ae.parseTemplateElement=function(e){var t=e.isTagged,s=this.startNode();return this.type===v.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===v.backQuote,this.finishNode(s,"TemplateElement")},ae.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===v.eof&&this.raise(this.pos,"Unterminated template literal"),this.expect(v.dollarBraceL),s.expressions.push(this.parseExpression()),this.expect(v.braceR),s.quasis.push(r=this.parseTemplateElement({isTagged:t}));return this.next(),this.finishNode(s,"TemplateLiteral")},ae.isAsyncProp=function(e){return!e.computed&&"Identifier"===e.key.type&&"async"===e.key.name&&(this.type===v.name||this.type===v.num||this.type===v.string||this.type===v.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===v.star)&&!w.test(this.input.slice(this.lastTokEnd,this.start))},ae.parseObj=function(e,t){var s=this.startNode(),r=!0,n={};for(s.properties=[],this.next();!this.eat(v.braceR);){if(r)r=!1;else if(this.expect(v.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(v.braceR))break;var i=this.parseProperty(e,t);e||this.checkPropClash(i,n,t),s.properties.push(i)}return this.finishNode(s,e?"ObjectPattern":"ObjectExpression")},ae.parseProperty=function(e,t){var s,r,n,i,o=this.startNode();if(this.options.ecmaVersion>=9&&this.eat(v.ellipsis))return e?(o.argument=this.parseIdent(!1),this.type===v.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===v.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)&&(n=this.start,i=this.startLoc),e||(s=this.eat(v.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(v.star),this.parsePropertyName(o)):r=!1,this.parsePropertyValue(o,e,s,r,n,i,t,a),this.finishNode(o,"Property")},ae.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")},ae.parsePropertyValue=function(e,t,s,r,n,i,o,a){(s||r)&&this.type===v.colon&&this.unexpected(),this.eat(v.colon)?(e.value=t?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,o),e.kind="init"):this.options.ecmaVersion>=6&&this.type===v.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===v.comma||this.type===v.braceR||this.type===v.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=n),t?e.value=this.parseMaybeDefault(n,i,this.copyNode(e.key)):this.type===v.eq&&o?(o.shorthandAssign<0&&(o.shorthandAssign=this.start),e.value=this.parseMaybeDefault(n,i,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))},ae.parsePropertyName=function(e){if(this.options.ecmaVersion>=6){if(this.eat(v.bracketL))return e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(v.bracketR),e.key;e.computed=!1}return e.key=this.type===v.num||this.type===v.string?this.parseExprAtom():this.parseIdent("never"!==this.options.allowReserved)},ae.initFunction=function(e){e.id=null,this.options.ecmaVersion>=6&&(e.generator=e.expression=!1),this.options.ecmaVersion>=8&&(e.async=!1)},ae.parseMethod=function(e,t,s){var r=this.startNode(),n=this.yieldPos,i=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|$(t,r.generator)|(s?128:0)),this.expect(v.parenL),r.params=this.parseBindingList(v.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(r,!1,!0,!1),this.yieldPos=n,this.awaitPos=i,this.awaitIdentPos=o,this.finishNode(r,"FunctionExpression")},ae.parseArrowExpression=function(e,t,s,r){var n=this.yieldPos,i=this.awaitPos,o=this.awaitIdentPos;return this.enterScope(16|$(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=n,this.awaitPos=i,this.awaitIdentPos=o,this.finishNode(e,"ArrowFunctionExpression")},ae.parseFunctionBody=function(e,t,s,r){var n=t&&this.type!==v.braceL,i=this.strict,o=!1;if(n)e.body=this.parseMaybeAssign(r),e.expression=!0,this.checkParams(e,!1);else{var a=this.options.ecmaVersion>=7&&!this.isSimpleParamList(e.params);i&&!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,!i&&!o&&!t&&!s&&this.isSimpleParamList(e.params)),this.strict&&e.id&&this.checkLValSimple(e.id,5),e.body=this.parseBlock(!1,void 0,o&&!i),e.expression=!1,this.adaptDirectivePrologue(e.body.body),this.labels=h}this.exitScope()},ae.isSimpleParamList=function(e){for(var t=0,s=e;t<s.length;t+=1)if("Identifier"!==s[t].type)return!1;return!0},ae.checkParams=function(e,t){for(var s=Object.create(null),r=0,n=e.params;r<n.length;r+=1){var i=n[r];this.checkLValInnerPattern(i,1,t?null:s)}},ae.parseExprList=function(e,t,s,r){for(var n=[],i=!0;!this.eat(e);){if(i)i=!1;else if(this.expect(v.comma),t&&this.afterTrailingComma(e))break;var o=void 0;s&&this.type===v.comma?o=null:this.type===v.ellipsis?(o=this.parseSpread(r),r&&this.type===v.comma&&r.trailingComma<0&&(r.trailingComma=this.start)):o=this.parseMaybeAssign(!1,r),n.push(o)}return n},ae.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&G||"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"))},ae.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},ae.parseIdentNode=function(){var e=this.startNode();return this.type===v.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=v.name):this.unexpected(),e},ae.parsePrivateIdent=function(){var e=this.startNode();return this.type===v.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},ae.parseYield=function(e){this.yieldPos||(this.yieldPos=this.start);var t=this.startNode();return this.next(),this.type===v.semi||this.canInsertSemicolon()||this.type!==v.star&&!this.type.startsExpr?(t.delegate=!1,t.argument=null):(t.delegate=this.eat(v.star),t.argument=this.parseMaybeAssign(e)),this.finishNode(t,"YieldExpression")},ae.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 de=F.prototype;de.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},de.raiseRecoverable=de.raise,de.curPosition=function(){if(this.options.locations)return new N(this.curLine,this.pos-this.lineStart)};var ue=F.prototype,pe=function(e){this.flags=e,this.var=[],this.lexical=[],this.functions=[]};ue.enterScope=function(e){this.scopeStack.push(new pe(e))},ue.exitScope=function(){this.scopeStack.pop()},ue.treatFunctionsAsVarInScope=function(e){return 2&e.flags||!this.inModule&&1&e.flags},ue.declareName=function(e,t,s){var r=!1;if(2===t){var n=this.currentScope();r=n.lexical.indexOf(e)>-1||n.functions.indexOf(e)>-1||n.var.indexOf(e)>-1,n.lexical.push(e),this.inModule&&1&n.flags&&delete this.undefinedExports[e]}else if(4===t)this.currentScope().lexical.push(e);else if(3===t){var i=this.currentScope();r=this.treatFunctionsAsVar?i.lexical.indexOf(e)>-1:i.lexical.indexOf(e)>-1||i.var.indexOf(e)>-1,i.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&G)break}r&&this.raiseRecoverable(s,"Identifier '"+e+"' has already been declared")},ue.checkLocalExport=function(e){-1===this.scopeStack[0].lexical.indexOf(e.name)&&-1===this.scopeStack[0].var.indexOf(e.name)&&(this.undefinedExports[e.name]=e)},ue.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]},ue.currentVarScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(771&t.flags)return t}},ue.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 fe=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 me(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 fe(this,this.start,this.startLoc)},ge.startNodeAt=function(e,t){return new fe(this,e,t)},ge.finishNode=function(e,t){return me.call(this,e,t,this.lastTokEnd,this.lastTokEndLoc)},ge.finishNodeAt=function(e,t,s,r){return me.call(this,e,t,s,r)},ge.copyNode=function(e){var t=new fe(this,e.start,this.startLoc);for(var s in e)t[s]=e[s];return t};var ye="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",xe=ye+" Extended_Pictographic",ve=xe+" EBase EComp EMod EPres ExtPict",we={9:ye,10:xe,11:xe,12:ve,13:ve,14:ve},be={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"},Ee="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",Se="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=Se+" 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",ke=Ae+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",Ie={9:Se,10:_e,11:Ce,12:Ae,13:ke,14:ke+" 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"},Te={};function Pe(e){var t=Te[e]={binary:M(we[e]+" "+Ee),binaryOfStrings:M(be[e]),nonBinary:{General_Category:M(Ee),Script:M(Ie[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 Le=0,Me=[9,10,11,12,13,14];Le<Me.length;Le+=1)Pe(Me[Le]);var Re=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 Ne=function(e){this.parser=e,this.validFlags="gim"+(e.options.ecmaVersion>=6?"uy":"")+(e.options.ecmaVersion>=9?"s":"")+(e.options.ecmaVersion>=13?"d":"")+(e.options.ecmaVersion>=15?"v":""),this.unicodeProperties=Te[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 Ue(e){return 105===e||109===e||115===e}function Be(e){return 36===e||e>=40&&e<=43||46===e||63===e||e>=91&&e<=94||e>=123&&e<=125}function De(e){return e>=65&&e<=90||e>=97&&e<=122}Ne.prototype.reset=function(e,t,s){var r=-1!==s.indexOf("v"),n=-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=n&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=n&&this.parser.options.ecmaVersion>=9)},Ne.prototype.raise=function(e){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+e)},Ne.prototype.at=function(e,t){void 0===t&&(t=!1);var s=this.source,r=s.length;if(e>=r)return-1;var n=s.charCodeAt(e);if(!t&&!this.switchU||n<=55295||n>=57344||e+1>=r)return n;var i=s.charCodeAt(e+1);return i>=56320&&i<=57343?(n<<10)+i-56613888:n},Ne.prototype.nextIndex=function(e,t){void 0===t&&(t=!1);var s=this.source,r=s.length;if(e>=r)return r;var n,i=s.charCodeAt(e);return!t&&!this.switchU||i<=55295||i>=57344||e+1>=r||(n=s.charCodeAt(e+1))<56320||n>57343?e+1:e+2},Ne.prototype.current=function(e){return void 0===e&&(e=!1),this.at(this.pos,e)},Ne.prototype.lookahead=function(e){return void 0===e&&(e=!1),this.at(this.nextIndex(this.pos,e),e)},Ne.prototype.advance=function(e){void 0===e&&(e=!1),this.pos=this.nextIndex(this.pos,e)},Ne.prototype.eat=function(e,t){return void 0===t&&(t=!1),this.current(t)===e&&(this.advance(t),!0)},Ne.prototype.eatChars=function(e,t){void 0===t&&(t=!1);for(var s=this.pos,r=0,n=e;r<n.length;r+=1){var i=n[r],o=this.at(s,t);if(-1===o||o!==i)return!1;s=this.nextIndex(s,t)}return this.pos=s,!0},Re.validateRegExpFlags=function(e){for(var t=e.validFlags,s=e.flags,r=!1,n=!1,i=0;i<s.length;i++){var o=s.charAt(i);-1===t.indexOf(o)&&this.raise(e.start,"Invalid regular expression flag"),s.indexOf(o,i+1)>-1&&this.raise(e.start,"Duplicate regular expression flag"),"u"===o&&(r=!0),"v"===o&&(n=!0)}this.options.ecmaVersion>=15&&r&&n&&this.raise(e.start,"Invalid regular expression flag")},Re.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))},Re.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")}},Re.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")},Re.regexp_alternative=function(e){for(;e.pos<e.source.length&&this.regexp_eatTerm(e););},Re.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)},Re.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},Re.regexp_eatQuantifier=function(e,t){return void 0===t&&(t=!1),!!this.regexp_eatQuantifierPrefix(e,t)&&(e.eat(63),!0)},Re.regexp_eatQuantifierPrefix=function(e,t){return e.eat(42)||e.eat(43)||e.eat(63)||this.regexp_eatBracedQuantifier(e,t)},Re.regexp_eatBracedQuantifier=function(e,t){var s=e.pos;if(e.eat(123)){var r=0,n=-1;if(this.regexp_eatDecimalDigits(e)&&(r=e.lastIntValue,e.eat(44)&&this.regexp_eatDecimalDigits(e)&&(n=e.lastIntValue),e.eat(125)))return-1!==n&&n<r&&!t&&e.raise("numbers out of order in {} quantifier"),!0;e.switchU&&!t&&e.raise("Incomplete quantifier"),e.pos=s}return!1},Re.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)},Re.regexp_eatReverseSolidusAtomEscape=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatAtomEscape(e))return!0;e.pos=t}return!1},Re.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 n=0;n<s.length;n++){var i=s.charAt(n);s.indexOf(i,n+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},Re.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},Re.regexp_eatModifiers=function(e){for(var t="",s=0;-1!==(s=e.current())&&Ue(s);)t+=R(s),e.advance();return t},Re.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)},Re.regexp_eatInvalidBracedQuantifier=function(e){return this.regexp_eatBracedQuantifier(e,!0)&&e.raise("Nothing to repeat"),!1},Re.regexp_eatSyntaxCharacter=function(e){var t=e.current();return!!Be(t)&&(e.lastIntValue=t,e.advance(),!0)},Re.regexp_eatPatternCharacters=function(e){for(var t=e.pos,s=0;-1!==(s=e.current())&&!Be(s);)e.advance();return e.pos!==t},Re.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))},Re.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,n=s;r<n.length;r+=1)n[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}},Re.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},Re.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},Re.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)},Re.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)},Re.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)},Re.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},Re.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},Re.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)},Re.regexp_eatCControlLetter=function(e){var t=e.pos;if(e.eat(99)){if(this.regexp_eatControlLetter(e))return!0;e.pos=t}return!1},Re.regexp_eatZero=function(e){return 48===e.current()&&!je(e.lookahead())&&(e.lastIntValue=0,e.advance(),!0)},Re.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)},Re.regexp_eatControlLetter=function(e){var t=e.current();return!!De(t)&&(e.lastIntValue=t%32,e.advance(),!0)},Re.regexp_eatRegExpUnicodeEscapeSequence=function(e,t){void 0===t&&(t=!1);var s,r=e.pos,n=t||e.switchU;if(e.eat(117)){if(this.regexp_eatFixedHexDigits(e,4)){var i=e.lastIntValue;if(n&&i>=55296&&i<=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*(i-55296)+(a-56320)+65536,!0}e.pos=o,e.lastIntValue=i}return!0}if(n&&e.eat(123)&&this.regexp_eatHexDigits(e)&&e.eat(125)&&((s=e.lastIntValue)>=0&&s<=1114111))return!0;n&&e.raise("Invalid unicode escape"),e.pos=r}return!1},Re.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))},Re.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 He(e){return De(e)||95===e}function qe(e){return He(e)||je(e)}function je(e){return e>=48&&e<=57}function Ge(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function $e(e){return e>=65&&e<=70?e-65+10:e>=97&&e<=102?e-97+10:e-48}function Fe(e){return e>=48&&e<=55}Re.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},Re.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 n=e.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(e,n)}return 0},Re.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")},Re.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")},Re.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue="";He(t=e.current());)e.lastStringValue+=R(t),e.advance();return""!==e.lastStringValue},Re.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue="";qe(t=e.current());)e.lastStringValue+=R(t),e.advance();return""!==e.lastStringValue},Re.regexp_eatLoneUnicodePropertyNameOrValue=function(e){return this.regexp_eatUnicodePropertyValue(e)},Re.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},Re.regexp_classContents=function(e){return 93===e.current()?1:e.switchV?this.regexp_classSetExpression(e):(this.regexp_nonEmptyClassRanges(e),1)},Re.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")}}},Re.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||Fe(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)},Re.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)},Re.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)}},Re.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},Re.regexp_eatClassSetOperand=function(e){return this.regexp_eatClassSetCharacter(e)?1:this.regexp_eatClassStringDisjunction(e)||this.regexp_eatNestedClass(e)},Re.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 n=this.regexp_eatCharacterClassEscape(e);if(n)return n;e.pos=t}return null},Re.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},Re.regexp_classStringDisjunctionContents=function(e){for(var t=this.regexp_classString(e);e.eat(124);)2===this.regexp_classString(e)&&(t=2);return t},Re.regexp_classString=function(e){for(var t=0;this.regexp_eatClassSetCharacter(e);)t++;return 1===t?1:2},Re.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))},Re.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)},Re.regexp_eatClassControlLetter=function(e){var t=e.current();return!(!je(t)&&95!==t||(e.lastIntValue=t%32,e.advance(),0))},Re.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},Re.regexp_eatDecimalDigits=function(e){var t=e.pos,s=0;for(e.lastIntValue=0;je(s=e.current());)e.lastIntValue=10*e.lastIntValue+(s-48),e.advance();return e.pos!==t},Re.regexp_eatHexDigits=function(e){var t=e.pos,s=0;for(e.lastIntValue=0;Ge(s=e.current());)e.lastIntValue=16*e.lastIntValue+$e(s),e.advance();return e.pos!==t},Re.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},Re.regexp_eatOctalDigit=function(e){var t=e.current();return Fe(t)?(e.lastIntValue=t-48,e.advance(),!0):(e.lastIntValue=0,!1)},Re.regexp_eatFixedHexDigits=function(e,t){var s=e.pos;e.lastIntValue=0;for(var r=0;r<t;++r){var n=e.current();if(!Ge(n))return e.pos=s,!1;e.lastIntValue=16*e.lastIntValue+$e(n),e.advance()}return!0};var Ve=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])},ze=F.prototype;function Ye(e){return"function"!=typeof BigInt?null:BigInt(e.replace(/_/g,""))}ze.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 Ve(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()},ze.getToken=function(){return this.next(),new Ve(this)},"undefined"!=typeof Symbol&&(ze[Symbol.iterator]=function(){var e=this;return{next:function(){var t=e.getToken();return{done:t.type===v.eof,value:t}}}}),ze.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(v.eof):e.override?e.override(this):void this.readToken(this.fullCharCodeAtPos())},ze.readToken=function(e){return d(e,this.options.ecmaVersion>=6)||92===e?this.readWord():this.getTokenFromCode(e)},ze.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},ze.fullCharCodeAtPos=function(){return this.fullCharCodeAt(this.pos)},ze.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,n=t;(r=S(this.input,n,this.pos))>-1;)++this.curLine,n=this.lineStart=r;this.options.onComment&&this.options.onComment(!0,this.input.slice(t+2,s),t,this.pos,e,this.curPosition())},ze.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())},ze.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&&_.test(String.fromCharCode(e))))break e;++this.pos}}},ze.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)},ze.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(v.ellipsis)):(++this.pos,this.finishToken(v.dot))},ze.readToken_slash=function(){var e=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):61===e?this.finishOp(v.assign,2):this.finishOp(v.slash,1)},ze.readToken_mult_modulo_exp=function(e){var t=this.input.charCodeAt(this.pos+1),s=1,r=42===e?v.star:v.modulo;return this.options.ecmaVersion>=7&&42===e&&42===t&&(++s,r=v.starstar,t=this.input.charCodeAt(this.pos+2)),61===t?this.finishOp(v.assign,s+1):this.finishOp(r,s)},ze.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(v.assign,3):this.finishOp(124===e?v.logicalOR:v.logicalAND,2):61===t?this.finishOp(v.assign,2):this.finishOp(124===e?v.bitwiseOR:v.bitwiseAND,1)},ze.readToken_caret=function(){return 61===this.input.charCodeAt(this.pos+1)?this.finishOp(v.assign,2):this.finishOp(v.bitwiseXOR,1)},ze.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&&!w.test(this.input.slice(this.lastTokEnd,this.pos))?this.finishOp(v.incDec,2):(this.skipLineComment(3),this.skipSpace(),this.nextToken()):61===t?this.finishOp(v.assign,2):this.finishOp(v.plusMin,1)},ze.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(v.assign,s+1):this.finishOp(v.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(v.relational,s)):(this.skipLineComment(4),this.skipSpace(),this.nextToken())},ze.readToken_eq_excl=function(e){var t=this.input.charCodeAt(this.pos+1);return 61===t?this.finishOp(v.equality,61===this.input.charCodeAt(this.pos+2)?3:2):61===e&&62===t&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(v.arrow)):this.finishOp(61===e?v.eq:v.prefix,1)},ze.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(v.questionDot,2)}if(63===t)return e>=12&&61===this.input.charCodeAt(this.pos+2)?this.finishOp(v.assign,3):this.finishOp(v.coalesce,2)}return this.finishOp(v.question,1)},ze.readToken_numberSign=function(){var e=35;if(this.options.ecmaVersion>=13&&(++this.pos,d(e=this.fullCharCodeAtPos(),!0)||92===e))return this.finishToken(v.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+R(e)+"'")},ze.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(v.parenL);case 41:return++this.pos,this.finishToken(v.parenR);case 59:return++this.pos,this.finishToken(v.semi);case 44:return++this.pos,this.finishToken(v.comma);case 91:return++this.pos,this.finishToken(v.bracketL);case 93:return++this.pos,this.finishToken(v.bracketR);case 123:return++this.pos,this.finishToken(v.braceL);case 125:return++this.pos,this.finishToken(v.braceR);case 58:return++this.pos,this.finishToken(v.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(v.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(v.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+R(e)+"'")},ze.finishOp=function(e,t){var s=this.input.slice(this.pos,this.pos+t);return this.pos+=t,this.finishToken(e,s)},ze.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(w.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 n=this.input.slice(s,this.pos);++this.pos;var i=this.pos,o=this.readWord1();this.containsEsc&&this.unexpected(i);var a=this.regexpState||(this.regexpState=new Ne(this));a.reset(s,n,o),this.validateRegExpFlags(a),this.validateRegExpPattern(a);var h=null;try{h=new RegExp(n,o)}catch(e){}return this.finishToken(v.regexp,{pattern:n,flags:o,value:h})},ze.readInt=function(e,t,s){for(var r=this.options.ecmaVersion>=12&&void 0===t,n=s&&48===this.input.charCodeAt(this.pos),i=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)n&&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===i||null!=t&&this.pos-i!==t?null:o},ze.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=Ye(this.input.slice(t,this.pos)),++this.pos):d(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(v.num,s)},ze.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 n=Ye(this.input.slice(t,this.pos));return++this.pos,d(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(v.num,n)}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 i,o=(i=this.input.slice(t,this.pos),s?parseInt(i,8):parseFloat(i.replace(/_/g,"")));return this.finishToken(v.num,o)},ze.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},ze.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(v.string,t)};var Ke={};ze.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e!==Ke)throw e;this.readInvalidTemplateToken()}this.inTemplateElement=!1},ze.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw Ke;this.raise(e,t)},ze.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!==v.template&&this.type!==v.invalidTemplate?(e+=this.input.slice(t,this.pos),this.finishToken(v.template,e)):36===s?(this.pos+=2,this.finishToken(v.dollarBraceL)):(++this.pos,this.finishToken(v.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}},ze.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(v.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")},ze.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],n=parseInt(r,8);return n>255&&(r=r.slice(0,-1),n=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(n)}return E(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(t)}},ze.readHexChar=function(e){var t=this.pos,s=this.readInt(16,e);return null===s&&this.invalidStringToken(t,"Bad character escape sequence"),s},ze.readWord1=function(){this.containsEsc=!1;for(var e="",t=!0,s=this.pos,r=this.options.ecmaVersion>=6;this.pos<this.input.length;){var n=this.fullCharCodeAtPos();if(u(n,r))this.pos+=n<=65535?1:2;else{if(92!==n)break;this.containsEsc=!0,e+=this.input.slice(s,this.pos);var i=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(i,"Invalid Unicode escape"),e+=R(o),s=this.pos}t=!1}return e+this.input.slice(s,this.pos)},ze.readWord=function(){var e=this.readWord1(),t=v.name;return this.keywords.test(e)&&(t=y[e]),this.finishToken(t,e)};var We="8.17.0";F.acorn={Parser:F,version:We,defaultOptions:D,Position:N,SourceLocation:U,getLineInfo:B,Node:fe,TokenType:p,tokTypes:v,keywordTypes:y,TokContext:ne,tokContexts:ie,isIdentifierChar:u,isIdentifierStart:d,Token:Ve,isNewLine:E,lineBreak:w,lineBreakG:b,nonASCIIwhitespace:_},e.Node=fe,e.Parser=F,e.Position=N,e.SourceLocation=U,e.TokContext=ne,e.Token=Ve,e.TokenType=p,e.defaultOptions=D,e.getLineInfo=B,e.isIdentifierChar=u,e.isIdentifierStart=d,e.isNewLine=E,e.keywordTypes=y,e.lineBreak=w,e.lineBreakG=b,e.nonASCIIwhitespace=_,e.parse=function(e,t){return F.parse(e,t)},e.parseExpressionAt=function(e,t,s){return F.parseExpressionAt(e,t,s)},e.tokContexts=ie,e.tokTypes=v,e.tokenizer=function(e,t){return F.tokenizer(e,t)},e.version=We}(t)},7526(e,t){"use strict";t.toByteArray=function(e){var t,s,i=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=i[0],a=i[1],h=new n(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,n=r%3,i=[],o=16383,a=0,l=r-n;a<l;a+=o)i.push(h(e,a,a+o>l?l:a+o));return 1===n?(t=e[r-1],i.push(s[t>>2]+s[t<<4&63]+"==")):2===n&&(t=(e[r-2]<<8)+e[r-1],i.push(s[t>>10]+s[t>>4&63]+s[t<<2&63]+"=")),i.join("")};for(var s=[],r=[],n="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0;o<64;++o)s[o]=i[o],r[i.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,n=[],i=t;i<s;i+=3)r=(e[i]<<16&16711680)+(e[i+1]<<8&65280)+(255&e[i+2]),n.push(a(r));return n.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},8287(e,t,s){"use strict";const r=s(7526),n=s(251),i="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|g(e,t);let r=a(s);const n=r.write(e,t);return n!==s&&(r=r.slice(0,n)),r}(e,t);if(ArrayBuffer.isView(e))return function(e){if(W(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(W(e,ArrayBuffer)||e&&W(e.buffer,ArrayBuffer))return p(e,t,s);if("undefined"!=typeof SharedArrayBuffer&&(W(e,SharedArrayBuffer)||e&&W(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 n=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(n)return n;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 g(e,t){if(h.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||W(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 n=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return s;case"utf8":case"utf-8":return z(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*s;case"hex":return s>>>1;case"base64":return Y(e).length;default:if(n)return r?-1:z(e).length;t=(""+t).toLowerCase(),n=!0}}function m(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 A(this,t,s);case"ascii":return I(this,t,s);case"latin1":case"binary":return T(this,t,s);case"base64":return C(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 x(e,t,s,r,n){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=n?0:e.length-1),s<0&&(s=e.length+s),s>=e.length){if(n)return-1;s=e.length-1}else if(s<0){if(!n)return-1;s=0}if("string"==typeof t&&(t=h.from(t,r)),h.isBuffer(t))return 0===t.length?-1:v(e,t,s,r,n);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(e,t,s):Uint8Array.prototype.lastIndexOf.call(e,t,s):v(e,[t],s,r,n);throw new TypeError("val must be string, number or Buffer")}function v(e,t,s,r,n){let i,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(n){let r=-1;for(i=s;i<a;i++)if(l(e,i)===l(t,-1===r?0:i-r)){if(-1===r&&(r=i),i-r+1===h)return r*o}else-1!==r&&(i-=i-r),r=-1}else for(s+h>a&&(s=a-h),i=s;i>=0;i--){let s=!0;for(let r=0;r<h;r++)if(l(e,i+r)!==l(t,r)){s=!1;break}if(s)return i}return-1}function w(e,t,s,r){s=Number(s)||0;const n=e.length-s;r?(r=Number(r))>n&&(r=n):r=n;const i=t.length;let o;for(r>i/2&&(r=i/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 K(z(t,e.length-s),e,s,r)}function E(e,t,s,r){return K(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 K(Y(t),e,s,r)}function _(e,t,s,r){return K(function(e,t){let s,r,n;const i=[];for(let o=0;o<e.length&&!((t-=2)<0);++o)s=e.charCodeAt(o),r=s>>8,n=s%256,i.push(n),i.push(r);return i}(t,e.length-s),e,s,r)}function C(e,t,s){return 0===t&&s===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,s))}function A(e,t,s){s=Math.min(e.length,s);const r=[];let n=t;for(;n<s;){const t=e[n];let i=null,o=t>239?4:t>223?3:t>191?2:1;if(n+o<=s){let s,r,a,h;switch(o){case 1:t<128&&(i=t);break;case 2:s=e[n+1],128==(192&s)&&(h=(31&t)<<6|63&s,h>127&&(i=h));break;case 3:s=e[n+1],r=e[n+2],128==(192&s)&&128==(192&r)&&(h=(15&t)<<12|(63&s)<<6|63&r,h>2047&&(h<55296||h>57343)&&(i=h));break;case 4:s=e[n+1],r=e[n+2],a=e[n+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&&(i=h))}}null===i?(i=65533,o=1):i>65535&&(i-=65536,r.push(i>>>10&1023|55296),i=56320|1023&i),r.push(i),n+=o}return function(e){const t=e.length;if(t<=k)return String.fromCharCode.apply(String,e);let s="",r=0;for(;r<t;)s+=String.fromCharCode.apply(String,e.slice(r,r+=k));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(W(e,Uint8Array)&&(e=h.from(e,e.offset,e.byteLength)),W(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 n=0,i=Math.min(s,r);n<i;++n)if(e[n]!==t[n]){s=e[n],r=t[n];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 n=0;for(s=0;s<e.length;++s){let t=e[s];if(W(t,Uint8Array))n+t.length>r.length?(h.isBuffer(t)||(t=h.from(t)),t.copy(r,n)):Uint8Array.prototype.set.call(r,t,n);else{if(!h.isBuffer(t))throw new TypeError('"list" argument must be an Array of Buffers');t.copy(r,n)}n+=t.length}return r},h.byteLength=g,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?A(this,0,e):m.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+">"},i&&(h.prototype[i]=h.prototype.inspect),h.prototype.compare=function(e,t,s,r,n){if(W(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===n&&(n=this.length),t<0||s>e.length||r<0||n>this.length)throw new RangeError("out of range index");if(r>=n&&t>=s)return 0;if(r>=n)return-1;if(t>=s)return 1;if(this===e)return 0;let i=(n>>>=0)-(r>>>=0),o=(s>>>=0)-(t>>>=0);const a=Math.min(i,o),l=this.slice(r,n),c=e.slice(t,s);for(let e=0;e<a;++e)if(l[e]!==c[e]){i=l[e],o=c[e];break}return i<o?-1:o<i?1:0},h.prototype.includes=function(e,t,s){return-1!==this.indexOf(e,t,s)},h.prototype.indexOf=function(e,t,s){return x(this,e,t,s,!0)},h.prototype.lastIndexOf=function(e,t,s){return x(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 n=this.length-t;if((void 0===s||s>n)&&(s=n),e.length>0&&(s<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");let i=!1;for(;;)switch(r){case"hex":return w(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 _(this,e,t,s);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const k=4096;function I(e,t,s){let r="";s=Math.min(e.length,s);for(let n=t;n<s;++n)r+=String.fromCharCode(127&e[n]);return r}function T(e,t,s){let r="";s=Math.min(e.length,s);for(let n=t;n<s;++n)r+=String.fromCharCode(e[n]);return r}function P(e,t,s){const r=e.length;(!t||t<0)&&(t=0),(!s||s<0||s>r)&&(s=r);let n="";for(let r=t;r<s;++r)n+=X[e[r]];return n}function L(e,t,s){const r=e.slice(t,s);let n="";for(let e=0;e<r.length-1;e+=2)n+=String.fromCharCode(r[e]+256*r[e+1]);return n}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,n,i){if(!h.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>n||t<i)throw new RangeError('"value" argument is out of bounds');if(s+r>e.length)throw new RangeError("Index out of range")}function O(e,t,s,r,n){G(t,r,n,e,s,7);let i=Number(t&BigInt(4294967295));e[s++]=i,i>>=8,e[s++]=i,i>>=8,e[s++]=i,i>>=8,e[s++]=i;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 N(e,t,s,r,n){G(t,r,n,e,s,7);let i=Number(t&BigInt(4294967295));e[s+7]=i,i>>=8,e[s+6]=i,i>>=8,e[s+5]=i,i>>=8,e[s+4]=i;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,n,i){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,i){return t=+t,s>>>=0,i||U(e,0,s,4),n.write(e,t,s,r,23,4),s+4}function D(e,t,s,r,i){return t=+t,s>>>=0,i||U(e,0,s,8),n.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],n=1,i=0;for(;++i<t&&(n*=256);)r+=this[e+i]*n;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],n=1;for(;t>0&&(n*=256);)r+=this[e+--t]*n;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=Q(function(e){$(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,n=this[++e]+256*this[++e]+65536*this[++e]+s*2**24;return BigInt(r)+(BigInt(n)<<BigInt(32))}),h.prototype.readBigUInt64BE=Q(function(e){$(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],n=this[++e]*2**24+65536*this[++e]+256*this[++e]+s;return(BigInt(r)<<BigInt(32))+BigInt(n)}),h.prototype.readIntLE=function(e,t,s){e>>>=0,t>>>=0,s||M(e,t,this.length);let r=this[e],n=1,i=0;for(;++i<t&&(n*=256);)r+=this[e+i]*n;return n*=128,r>=n&&(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,n=1,i=this[e+--r];for(;r>0&&(n*=256);)i+=this[e+--r]*n;return n*=128,i>=n&&(i-=Math.pow(2,8*t)),i},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=Q(function(e){$(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=Q(function(e){$(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),n.read(this,e,!0,23,4)},h.prototype.readFloatBE=function(e,t){return e>>>=0,t||M(e,4,this.length),n.read(this,e,!1,23,4)},h.prototype.readDoubleLE=function(e,t){return e>>>=0,t||M(e,8,this.length),n.read(this,e,!0,52,8)},h.prototype.readDoubleBE=function(e,t){return e>>>=0,t||M(e,8,this.length),n.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 n=1,i=0;for(this[t]=255&e;++i<s&&(n*=256);)this[t+i]=e/n&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 n=s-1,i=1;for(this[t+n]=255&e;--n>=0&&(i*=256);)this[t+n]=e/i&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=Q(function(e,t=0){return O(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),h.prototype.writeBigUInt64BE=Q(function(e,t=0){return N(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 n=0,i=1,o=0;for(this[t]=255&e;++n<s&&(i*=256);)e<0&&0===o&&0!==this[t+n-1]&&(o=1),this[t+n]=(e/i|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 n=s-1,i=1,o=0;for(this[t+n]=255&e;--n>=0&&(i*=256);)e<0&&0===o&&0!==this[t+n+1]&&(o=1),this[t+n]=(e/i|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=Q(function(e,t=0){return O(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),h.prototype.writeBigInt64BE=Q(function(e,t=0){return N(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 n=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),n},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 n;if(t>>>=0,s=void 0===s?this.length:s>>>0,e||(e=0),"number"==typeof e)for(n=t;n<s;++n)this[n]=e;else{const i=h.isBuffer(e)?e:h.from(e,r),o=i.length;if(0===o)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(n=0;n<s-t;++n)this[n+t]=i[n%o]}return this};const H={};function q(e,t,s){H[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 j(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 G(e,t,s,r,n,i){if(e>s||e<t){const r="bigint"==typeof t?"n":"";let n;throw n=i>3?0===t||t===BigInt(0)?`>= 0${r} and < 2${r} ** ${8*(i+1)}${r}`:`>= -(2${r} ** ${8*(i+1)-1}${r}) and < 2 ** ${8*(i+1)-1}${r}`:`>= ${t}${r} and <= ${s}${r}`,new H.ERR_OUT_OF_RANGE("value",n,e)}!function(e,t,s){$(t,"offset"),void 0!==e[t]&&void 0!==e[t+s]||F(t,e.length-(s+1))}(r,n,i)}function $(e,t){if("number"!=typeof e)throw new H.ERR_INVALID_ARG_TYPE(t,"number",e)}function F(e,t,s){if(Math.floor(e)!==e)throw $(e,s),new H.ERR_OUT_OF_RANGE(s||"offset","an integer",e);if(t<0)throw new H.ERR_BUFFER_OUT_OF_BOUNDS;throw new H.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.`,n=s;return Number.isInteger(s)&&Math.abs(s)>2**32?n=j(String(s)):"bigint"==typeof s&&(n=String(s),(s>BigInt(2)**BigInt(32)||s<-(BigInt(2)**BigInt(32)))&&(n=j(n)),n+="n"),r+=` It must be ${t}. Received ${n}`,r},RangeError);const V=/[^+/0-9A-Za-z-_]/g;function z(e,t){let s;t=t||1/0;const r=e.length;let n=null;const i=[];for(let o=0;o<r;++o){if(s=e.charCodeAt(o),s>55295&&s<57344){if(!n){if(s>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(o+1===r){(t-=3)>-1&&i.push(239,191,189);continue}n=s;continue}if(s<56320){(t-=3)>-1&&i.push(239,191,189),n=s;continue}s=65536+(n-55296<<10|s-56320)}else n&&(t-=3)>-1&&i.push(239,191,189);if(n=null,s<128){if((t-=1)<0)break;i.push(s)}else if(s<2048){if((t-=2)<0)break;i.push(s>>6|192,63&s|128)}else if(s<65536){if((t-=3)<0)break;i.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;i.push(s>>18|240,s>>12&63|128,s>>6&63|128,63&s|128)}}return i}function Y(e){return r.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(V,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function K(e,t,s,r){let n;for(n=0;n<r&&!(n+s>=t.length||n>=e.length);++n)t[n+s]=e[n];return n}function W(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 n=0;n<16;++n)t[r+n]=e[s]+e[n]}return t}();function Q(e){return"undefined"==typeof BigInt?Z:e}function Z(){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:n,transaction:i}){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=()=>n?Promise.resolve(n):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 n of t){if(!/^[A-Za-z0-9_][A-Za-z0-9_. -]{0,119}$/.test(n)||/[ .]$/.test(n)||/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(n)||["__proto__","constructor","prototype"].includes(n)||s.has(n.toLowerCase()))throw new Error("Invalid export name");s.add(n.toLowerCase());const t=e[n];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"),n=r.objectStore("exports").get(o);r.oncomplete=()=>{try{const e=n.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,n)=>{const a=i?i(["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=()=>n(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,n=(e,t,s)=>{const n=r.createElement(e);return t&&(n.textContent=t),s?.append(n),n},i=n("dialog");i.className="hg-exports",i.setAttribute("aria-label","Game exports"),n("style",null,i).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=n("div",null,i);o.className="hg-exports-head",n("h2","Game exports",o);const a=n("button","Refresh",o),h=n("button","Close",o),l=n("p","Loading exports…",i);l.setAttribute("role","status");const c=n("div",null,i);c.className="hg-exports-body";const d=n("div",null,c);d.className="hg-exports-files",d.setAttribute("aria-label","Export files");const u=n("div",null,c);u.className="hg-exports-preview";let p,f,g=!1,m=!1;const y=new Promise(e=>{f=e});function x(){u.querySelectorAll("video,audio").forEach(e=>{e.pause(),e.removeAttribute("src"),e.load()}),u.replaceChildren(),p&&e.URL.revokeObjectURL(p),p=null}function v(){g||(g=!0,x(),i.close(),i.remove(),f())}const w=e=>e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`;function b(e){m=e,a.disabled=e,d.querySelectorAll("button").forEach(t=>{t.disabled=e})}async function E(t,i){if(!g&&!m){b(!0),x(),l.textContent=`Loading ${t.name}…`,d.querySelectorAll("button").forEach(e=>e.setAttribute("aria-pressed",String(e===i)));try{const i=await s(t.name);if(g)return;if(i.name!==t.name||!(i.bytes instanceof Uint8Array)||i.bytes.length>16777216)throw new Error("Invalid export file");const{name:o,bytes:a}=i,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(n("h3",o,u),l.textContent=`${w(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=n(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=()=>{!g&&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));n("pre",t||"(Empty file)",u),a.length>65536&&n("p","Preview shows the first 64 KB. Save file includes all bytes.",u)}else n("p","No preview for this format. Save it to open in another app.",u);const c=n("button","Save file",u);c.className="hg-exports-save",c.onclick=()=>{const t=e.URL.createObjectURL(new e.Blob([a],{type:h})),s=n("a",null,r.body);s.href=t,s.download=o,s.click(),s.remove(),e.setTimeout(()=>e.URL.revokeObjectURL(t),3e4)}}catch(e){g||(l.textContent=e.message)}finally{g||b(!1)}}}async function S(){if(!g&&!m){b(!0),x(),d.replaceChildren(),l.textContent="Loading exports…";try{const e=await t();if(g)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=n("button",`${t.name} · ${w(t.size)}`,d);e.setAttribute("aria-pressed","false"),e.onclick=()=>E(t,e)}}catch(e){g||(l.textContent=e.message)}finally{g||b(!1)}}}return a.onclick=S,h.onclick=v,i.oncancel=e=>{e.preventDefault(),v()},r.body.append(i),i.showModal(),h.focus(),S(),{result:y,close:v}}}},5766(e,t,s){var r=s(8287).hp;const n=8388608,i=s(6862),{describeMedia:o}=s(3947);e.exports=class{constructor(e,t={}){this.game=e,this.gameInput=new i(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}handleInput(e,t){if(!t||"object"!=typeof t||"string"!=typeof t.type)return;const s=Number(e);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("string"!=typeof t.key||t.key.length>20)return;this.gameInput.keyDown(s,t.key)}else if("keyup"===t.type){if("string"!=typeof t.key||t.key.length>20)return;this.gameInput.keyUp(s,t.key)}else if("mouseup"===t.type)this.game.handleMouseUp&&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(!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.gameInput.gamepad(s,t);else{const e=this.findNode(t.nodeId);if(e&&e.node&&e.node.input)if("file"===e.node.input.type){const i=((e,t=!1)=>{if("string"==typeof e){let s;if(!t&&"function"==typeof atob){if(s=atob(e),0===s.length||s.length>n)return null;const t=new Uint8Array(s.length);for(let e=0;e<s.length;e++)t[e]=s.charCodeAt(e);return t}const i=r.from(e,"base64");return 0===i.length||i.length>n?null:i}if(e&&"object"==typeof e){const s=Object.values(e);return 0===s.length||s.length>n?null:t?r.from(s):Uint8Array.from(s)}return null})(t.input,this.fileBuffers);i&&e.node.input.oninput(s,i,((e,t)=>({...o(e,t),contentType:"string"==typeof t.contentType&&t.contentType.length<=100?t.contentType:null}))(i,t))}else e.node.input.oninput(s,t.input)}else if("onhover"===t.type){const e=this.findNode(t.nodeId);e&&e.node&&e.node.onHover&&e.node.onHover(s)}else if("offhover"===t.type){const e=this.findNode(t.nodeId);e&&e.node&&e.node.offHover&&e.node.offHover(s)}}catch(e){console.error(`[GameDispatcher] Error handling input type="${t.type}":`,e)}}_handleClick(e,t){if(!t||"number"!=typeof t.x||"number"!=typeof 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 n=this._findClick(t.x,t.y,e),i=n?this.findPointerNode(n.id):null;if(r&&(this._activePresses[e]={node:i&&i.node||null,x:t.x,y:t.y}),i&&i.node&&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"!=typeof t.x||"number"!=typeof t.y)return;if(t.x<0||t.y<0||t.x>=100||t.y>=100)return;const s=this._activePresses[e];s&&(s.x=t.x,s.y=t.y);const{x:r,y:n}=this.toGameCoords(t.x,t.y);try{this.game.handleMouseMove&&this.game.handleMouseMove(e,{x:r,y:n})}catch(e){console.error("[GameDispatcher] game.handleMouseMove threw:",e)}if(s&&s.node&&"function"==typeof s.node.onDrag)try{s.node.onDrag(e,r,n)}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"==typeof t.x&&"number"==typeof t.y?t:{x:s.x,y:s.y};try{const{x:t,y:n}=this.toGameCoords(r.x,r.y);s.node.offClick(e,t,n)}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];t&&t.node&&(this.findPointerNode(t.node.id)||this.endPress(e,null))}_findClick(e,t,s){let r=null;for(const n of this.getLayers(e,t,s))!1!==n.interactive&&(r=this._findClickHelper(e,t,s,n.root.node,null,n.scale||{x:1,y:1},0)||r);return r}_findClickHelper(e,t,s,r,n,i,o){if(o>100)return n;if(r.playerIds&&r.playerIds.length>0&&!r.playerIds.find(e=>e==s))return n;if(r.coordinates2d&&r.coordinates2d.length>0){const s=[];for(let e=0;e<r.coordinates2d.length;e++){const t=100-100*i.x,n=100-100*i.y,o=r.coordinates2d[e][0]*((100-t)/100)+t/2,a=r.coordinates2d[e][1]*((100-n)/100)+n/2;s.push([o,a])}if(s.length>0){let i=!1,o=s[0][0],a=s[0][0],h=s[0][1],l=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),h=Math.min(s[e][1],h),l=Math.max(s[e][1],l);if(!(e<o||e>a||t<h||t>l)){let r=0,n=s.length-1;for(;r<s.length;n=r++)s[r][1]>t!=s[n][1]>t&&e<(s[n][0]-s[r][0])*(t-s[r][1])/(s[n][1]-s[r][1])+s[r][0]&&(i=!i)}i&&(n=r)}}if(r.children){const a=Object.keys(r.children);for(let h=0;h<a.length;h++){const l=r.children[a[h]];l&&l.node&&(n=this._findClickHelper(e,t,s,l.node,n,i,o+1))}}return n}}},6862(e,t,s){const{Buttons:r,mapInputs:n}=s(5951),i=s(8800),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(i.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 i=this._player(e),h=this._keys(i),l=i.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(n(r,this.bindings)).filter(([,e])=>e.pressed).map(([e])=>e));!1===t.connected?i.pads.delete(s):i.pads.set(s,{state:r,keys:u});const p=this._keys(i);for(const t of h)p.has(t)||this.game.handleKeyUp?.(e,t);for(const t of u){const r=[...i.pads].find(([,e])=>e.keys.has(t))?.[0];i.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)})}}}},2947(e,t,s){"use strict";const{createProject:r}=s(5110),{DIRECTORY:n,createUserExports:i}=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():i({...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 i=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(i))h[n+"/"+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=(e,s)=>{const r=t(e?e+"/"+s:s);return[r,r+".js",r+"/index.js"]},r={image:1,audio:2,font:3,video:4},n=e=>{const t=e.map(({key:e,type:t,data:s})=>{const n=new Uint8Array(44+s.length);n[0]=1,n[1]=r[t]||r.image;const i=(s.length+32).toString(36),o=10-i.length;for(let e=0;e<o;e++)n[2+e]=48;for(let e=0;e<i.length;e++)n[2+o+e]=i.charCodeAt(e);const a=Math.min(32,e.length);for(let t=0;t<a;t++)n[12+t]=e.charCodeAt(t);return n.set(s,44),n}),s=t.reduce((e,t)=>e+t.length,0),n=new Uint8Array(s);let i=0;for(const e of t)n.set(e,i),i+=e.length;return n},i=new WeakMap;e.exports={normalizePath:t,resolutionCandidates:s,resolveInFiles:(e,t,r)=>{for(const n of s(t,r))if(Object.prototype.hasOwnProperty.call(e,n))return n;return null},packAssetBundle:n,splitAssetBundle:(e,t=10485760)=>{const s=[];let r=0,n=0;for(;n<e.length;){const i=String.fromCharCode(...e.subarray(n+2,n+12)),o=parseInt(i,36)+12;if(1!==e[n]||!/^[0-9a-z]{10}$/.test(i)||o<44||n+o>e.length)throw new Error("Invalid asset bundle");if(o>t)throw new Error("An asset exceeds the RTC packet limit");n+o-r>t&&(s.push(e.subarray(r,n)),r=n),n+=o}return n>r&&s.push(e.subarray(r,n)),s},loadAssetBundle:async(e,t,s=Object.create(null))=>{i.has(s)||i.set(s,new Map);const r=i.get(s),o=await Promise.all(e.map(async e=>{if(!Object.prototype.hasOwnProperty.call(s,e.key)){const i={};r.set(e.key,i);const o=await t(e),a=n([{key:e.key,type:e.type,data:o}]);return r.get(e.key)===i&&(s[e.key]=a),a}return s[e.key]})),a=new Uint8Array(o.reduce((e,t)=>e+t.length,0));let h=0;for(const e of o)a.set(e,h),h+=e.length;return a},ASSET_TYPE_BYTES:r}},6620(e,t,s){var r=s(8287).hp;const{MAX_UPLOAD_BYTES:n,describeMedia:i}=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,n={id:r,playerId:Number(e),audio:!!t.audio,video:!!t.video,transmitting:!1!==t.transmitting,pushToTalk:!!t.pushToTalk};return new Promise((e,t)=>{const i={info:n,resolve:e,reject:t};i.timer=setTimeout(()=>this.stop(r,"Microphone/camera permission timed out"),6e4),this.streams.set(r,i),s.send({type:"media",action:"request",stream:n})})}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 i=Math.min(30,Math.max(1,Number(t.durationSeconds)||30)),o=Math.min(n,Math.max(131072,Math.floor(Number(t.maxBytes)||n))),a={id:"recording-"+ ++this.sequence,kind:r,durationSeconds:i,maxBytes:o,prompt:String(t.prompt||"").slice(0,120)};return new Promise((t,r)=>{const n={info:a,resolve:t,reject:r};n.timer=setTimeout(()=>this.cancelRecording(e,"Recording timed out. Please try again."),18e4),this.recordings.set(e,n),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 n=r.from(t.data,"base64"),o=i(n,{contentType:t.contentType,fileName:t.fileName});if(!n.length||n.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:n,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,n="string"==typeof t.contentType?t.contentType.toLowerCase().split(";")[0].slice(0,100):"";let i=null,o=null;const a=(e,t)=>{i=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"===n||/\.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"===n||/\.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)||n.startsWith("audio/")||/\.(m4a|m4b)$/i.test(r||"");a(e?"audio":"video",e?"audio/mp4":"video/mp4")}}return{kind:i,contentType:o,fileName:r}};e.exports={MAX_UPLOAD_BYTES:t,describeMedia:r,createFileUploadHandler:({Asset:e,registerAsset:s,isPlayerActive:n})=>{let i=0;const o=new Map;return async(a,h,l={},c={})=>{if(!n(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-"+ ++i;p&&o.set(p,f);const g=new e({id:f,type:u.kind,contentType:u.contentType,fileName:u.fileName},d.slice());return g.key=f,await s(f,g),g}}}},2982(e,t,s){const r=s(8800);e.exports={...r,name:"DUALSHOCK 4 Wireless Controller"}},3701(e,t,s){const r=s(8800);e.exports={...r,name:"DualSense Wireless Controller Extended Gamepad"}},439(e,t,s){const r=s(8800);e.exports={...r,name:"Luna Gamepad Extended Gamepad"}},8864(e,t,s){const r=s(8800);e.exports={...r,name:"8Bitdo NES30 Arcade(x)"}},6057(e,t,s){const r=s(8800);e.exports={...r,name:"Stadia Controller Extended Gamepad"}},8800(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}}},5055(e,t,s){const r=s(8800);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}}},7597(e,t,s){const r=s(8800);e.exports={...r,name:"Xbox Wireless Controller"}},5951(e,t,s){const{Buttons:r,Sticks:n}=s(9010),i=s(1696),o=s(8800),a=s(159),h=(e,t,s)=>Number.isFinite(e)?Math.max(t,Math.min(s,e)):0,l=(e,t)=>"string"==typeof e.name&&e.name.length>0&&t.includes(e.name);function c(e,t=[]){if(!e)return null;const s=String(e.id||"");return t.find(e=>l(e,s))||("standard"===e.mapping?o:null)||Object.values(i).find(e=>l(e,s))||null}function d(e,t=c(e),s={}){if(!e||!1===e.connected||!t)return null;const n={},i={};for(const s of new Set([...Object.values(r),...Object.keys(t.buttons||{})])){const r=e.buttons?.[t.buttons?.[s]],i=h("number"==typeof r?r:r?.value,0,1);n[s]={value:i,pressed:"boolean"==typeof r?.pressed?r.pressed:i>=.5}}for(const r of new Set([...Object.keys(o.sticks),...Object.keys(t.sticks||{})])){const n=h(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)");i[r]={value:Math.abs(n)<=o?0:Math.sign(n)*(Math.abs(n)-o)/(1-o)}}return{buttons:n,sticks:i}}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=c(e,this.options.mappings||[]),s=d(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,Sticks:n,mapGamepad:d,getGamepadMapping:c,mapInputs:a}},9010(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"}}},159(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 n=e?.sticks?.[t];if(n)return{value:n.value,pressed:Math.abs(n.value)>=s};const i=/^(STICK_[12])_(LEFT|RIGHT|UP|DOWN)$/.exec(t);if(i){const[,t,r]=i,n=t+("LEFT"===r||"RIGHT"===r?"_X":"_Y"),o="LEFT"===r||"UP"===r?-1:1,a=Math.max(0,(e?.sticks?.[n]?.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)}]}))}},1696(e,t,s){const r=s(2982),n=s(6057),i=s(7597),o=s(439),a=s(3701),h=s(5055),l=s(8864);e.exports={DUALSHOCK_4:r,STADIA:n,XBOX_ONE:i,LUNA:o,DUALSHOCK_5:a,SWITCH_PRO:h,NES_30:l}},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 n;try{n=e(t.localStorage.getItem(r))}catch(e){n=s()}const i=s=>{n=e(s);try{t.localStorage.setItem(r,n)}catch(e){}return n};return i(n),{get:()=>n,set:i}}}}e.exports={createPlayerIdentity:t,...t()}},8106(e){"use strict";e.exports={createPlayerToolbar:function(e,t={}){const s=e.document,r=new Map,n=new Set,i=(e,t,r)=>{const n=s.createElement(e);return n.className=t,r&&(n.textContent=r),n},o=i("header","hg-player-bar");o.setAttribute("aria-label","Game controls");const a=i("style","");a.textContent="\n.hg-player-bar,.hg-player-menu{box-sizing:border-box;color:#f6f6ee;background:#202321;font:14px/1.4 system-ui,sans-serif}\n.hg-player-bar *,.hg-player-menu *{box-sizing:border-box}\n.hg-player-bar{display:flex;flex:none;align-items:center;gap:6px;width:100%;height:calc(58px + env(safe-area-inset-top));padding:calc(6px + env(safe-area-inset-top)) max(10px,env(safe-area-inset-right)) 6px max(10px,env(safe-area-inset-left));border-bottom:1px solid #363b36}\n.hg-player-heading{flex:1;min-width:0}.hg-player-title{margin:0;font-size:14px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}\n.hg-player-identity{display:flex;align-items:baseline;gap:10px;min-width:0}.hg-player-author{font-size:12px;font-weight:400;color:#b7bfb5;margin-left:6px}\n.hg-player-status{margin:0;color:#b7bfb5;font-size:11px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}\n.hg-player-bar button,.hg-player-bar a,.hg-player-menu button{font:inherit;color:inherit;border:1px solid #4a5049;border-radius:8px;background:transparent;cursor:pointer;text-decoration:none}\n.hg-player-bar button,.hg-player-bar a{display:inline-flex;align-items:center;justify-content:center;flex:none;min-width:40px;height:44px;padding:0 10px;white-space:nowrap}\n.hg-player-bar .hg-player-icon{font-size:21px;padding:0;width:40px}\n.hg-player-home img{display:block;width:32px;height:32px;object-fit:contain}\n.hg-player-bar .hg-player-brand{height:auto;min-height:24px;min-width:0;padding:0;border:0;border-radius:3px;color:#94d2e5;font-size:12px;text-decoration:underline;text-underline-offset:3px}\n.hg-player-bar .hg-player-brand:hover{background:transparent;color:#b9e5f1}\n.hg-player-bar .hg-player-share{background:#fff78e;color:#22261e;border-color:#fff78e;font-weight:600}\n.hg-player-bar button:hover,.hg-player-bar a:hover,.hg-player-menu button:hover{background:#394036}\n.hg-player-bar .hg-player-share:hover{background:#fffbb5}\n.hg-player-bar .hg-player-install{background:#a8edc9;color:#17271e;border-color:#a8edc9;font-weight:600}.hg-player-bar .hg-player-install:hover{background:#c4f5dc}\n.hg-player-bar :focus-visible,.hg-player-menu :focus-visible{outline:2px solid #fff78e;outline-offset:2px}\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-edit-short{display:none}\n@media(max-width:600px){.hg-player-edit-long{display:none}.hg-player-edit-short{display:inline}.hg-player-bar{gap:4px;flex-wrap:wrap;height:auto}.hg-player-home{order:-2}.hg-player-heading{order:-1;flex-basis:calc(100% - 48px)}.hg-player-share{margin-left:auto}.hg-player-bar button:not(.hg-player-icon){padding:0 8px}}\n.hg-player-menu{position:fixed;inset:max(68px,env(safe-area-inset-top)) 12px auto auto;margin:0;width:min(320px,calc(100vw - 24px));max-height:calc(100dvh - 90px);overflow:auto;padding:16px;border:1px solid #4a5049;border-radius:12px;box-shadow:0 16px 50px #0008}\n.hg-player-menu::backdrop{background:#080c0a99}.hg-player-menu h2{margin:0 0 12px;font-size:16px}\n.hg-player-menu-actions{display:flex;flex-direction:column;gap:6px}.hg-player-menu button{width:100%;min-height:44px;padding:10px 12px;text-align:left}\n.hg-player-menu .hg-player-menu-status{font-size:12px;color:#b7bfb5;overflow-wrap:anywhere;margin:12px 0}\n.hg-player-menu .hg-player-menu-close{text-align:center;margin-top:10px}\n.hg-player-name{margin:0 0 16px;padding-bottom:16px;border-bottom:1px solid #4a5049}\n.hg-player-name label{display:block;margin-bottom:6px}.hg-player-name input{width:100%;min-height:44px;padding:10px;font:inherit;color:inherit;background:#141815;border:1px solid #4a5049;border-radius:8px}\n.hg-player-name button{margin-top:8px}.hg-player-name p{font-size:12px;color:#b7bfb5;margin:8px 0 0;overflow-wrap:anywhere}\n",o.append(a);const h=i("string"==typeof t.home?"a":"button","hg-player-icon hg-player-home");h.setAttribute("aria-label","Home"),h.title="Home",h.hidden=!t.home;const l=i("img","");l.alt="",l.width=l.height=32,l.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=",h.append(l),"string"==typeof t.home?h.href=t.home:(h.type="button",h.onclick=t.home);const c=i("div","hg-player-heading"),d=i("div","hg-player-identity"),u=i("h1","hg-player-title"),p=i("span",""),f=i("span","hg-player-author"),g=i("p","hg-player-status");u.append(p,f);const m=i("a","hg-player-brand","homegames.io");m.href="https://homegames.io/",m.target="_blank",m.rel="noopener noreferrer",m.title="Open homegames.io in a new tab",d.append(u,m),g.setAttribute("role","status"),g.setAttribute("aria-atomic","true"),c.append(d,g);const y=i("button","hg-player-share","Share");y.type="button",y.hidden=!0;const x=i("button","hg-player-icon","⋯");x.type="button",x.title="More",x.setAttribute("aria-label","More"),x.setAttribute("aria-haspopup","dialog");const v=i("button","","Download file");v.type="button",v.hidden=!0;const w=i("button","hg-player-install","Download app");w.type="button",w.hidden=!0;const b=i("button","hg-player-edit");b.type="button",b.hidden=!0,b.title="Open your own editable copy in Studio",b.setAttribute("aria-label","Edit this game"),b.append(i("span","hg-player-edit-long","Edit this game"),i("span","hg-player-edit-short","Edit"));const E=new Set([y,w,v,b]);o.append(h,c,y,w,v,b,x);const S=i("dialog","hg-player-menu");S.setAttribute("aria-label","Game options");const _=i("h2","","Game options"),C=i("div","hg-player-menu-actions"),A=()=>{r.has("install")&&!w.hidden?(C.prepend(v),v.textContent="Download game file (HTML)"):(o.insertBefore(v,b),v.textContent="Download file")},k=i("p","hg-player-menu-status"),I=i("form","hg-player-name");I.hidden=!0;const T=i("label","","Your name"),P=i("input","");P.type="text",P.maxLength=32,P.required=!0,P.autocomplete="nickname",P.setAttribute("aria-label","Your name"),T.append(P);const L=i("button","","Save name");L.type="submit";const M=i("p","");M.setAttribute("role","status"),I.append(T,L,M);let R,O="";I.onsubmit=async e=>{if(e.preventDefault(),R&&!L.disabled){L.disabled=!0;try{O=await R(P.value),P.value=O,M.textContent="Name updated for this session."}catch(e){M.textContent=e.message||String(e)}finally{L.disabled=!1}}};const N=i("button","hg-player-menu-close","Done");N.type="button",N.onclick=()=>S.close(),S.append(_,I,C,k,N),s.body.append(S);let U=!1;const B=()=>{U&&(U=!1,t.onClose?.())};x.onclick=()=>{S.open||(P.value=O,M.textContent="",U=!0,t.onOpen?.(),S.showModal())},S.addEventListener("close",B),S.addEventListener("click",e=>{if(e.target===S){const t=S.getBoundingClientRect();(e.clientX<t.left||e.clientX>t.right||e.clientY<t.top||e.clientY>t.bottom)&&S.close()}});let D=!1;const H={bar:o,menu:S,statusElement:g,setTitle(e){p.textContent=p.title=e||"Homegames"},setAuthor(e){f.textContent="string"==typeof e&&e.trim()?" by "+e.trim().slice(0,200):"",f.title=f.textContent.trim(),f.hidden=!f.textContent},setStatus(e){g.textContent=g.title=k.textContent=e||""},setPlayerName(e,t){O=e,R=t,I.hidden=!t,S.open||(P.value=e),t&&(x.hidden=!1)},setAction(e,s){if(!s){const t=r.get(e);return t&&(t.hidden=!0,E.has(t)||t.remove(),r.delete(e)),void("install"===e&&A())}let o=r.get(e);o||(o="share"===e?y:"edit-game"===e?b:"install"===e?w:"download-html"===e?v:i("button","",s.label),o.type="button",r.set(e,o),E.has(o)||C.append(o)),s.id&&(o.id=s.id),o!==b&&(o.textContent=s.label),o.hidden=!!s.hidden,o.disabled=!!s.disabled||n.has(e),"install"!==e&&"download-html"!==e||A(),o.onclick=()=>{if(!n.has(e)){S.open&&(S.close(),B()),n.add(e),o.disabled=!0;try{Promise.resolve(s.run()).catch(e=>H.setStatus(e.message||String(e))).finally(()=>{n.delete(e),o.disabled=!!s.disabled})}catch(t){n.delete(e),o.disabled=!!s.disabled,H.setStatus(t.message||String(t))}}},t.onActionReady?.(e)},runAction(e){const t=r.get(e);return!(!t||t.disabled||(t.click(),0))},openMenu(){x.click()},dispose(){D||(D=!0,S.open&&S.close(),S.remove(),o.remove())}};o.homegamesToolbar=H,H.setTitle(t.title),H.setAuthor(t.author),H.setStatus(t.status);for(const[e,s]of Object.entries(t.actions||{}))H.setAction(e,s);return H}}},5564(e){"use strict";e.exports={attachClientHost:function(e,t,s,r,n,i,o,a={}){const h=e.document;let l,c,d,u=0,p=!1,f=a.toolbar,g=!1,m=a.title;const y=new Map;function x(e,t){return!l||p?Promise.reject(new Error("The player is not ready")):new Promise((s,r)=>{const n=++u,i=setTimeout(()=>{y.delete(n),r(new Error("Game download timed out"))},6e4);y.set(n,{resolve:s,reject:r,timer:i,format:e}),l.postMessage({type:"download-game",id:n,format:e,name:t})})}const v=e=>{a.onPlayerStatus?a.onPlayerStatus(e):f?.setStatus(e)};function w(e,t){l&&!p&&l.postMessage({type:"player-control",action:e,value:t})}async function b(t){try{const s="function"==typeof a.downloadName?a.downloadName():a.downloadName;let r=String(s||m||"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"),v("Preparing game download…");const n=await x(t),i=e.URL.createObjectURL(new Blob([n],{type:"html"===t?"text/html":"application/zip"})),o=h.createElement("a");o.href=i,o.download=r+"."+t,o.click(),setTimeout(()=>e.URL.revokeObjectURL(i),3e4),v("Game copy downloaded")}catch(e){v(e.message)}}function E(h){if(p||l||h.source!==t.contentWindow||"null"!==h.origin||"homegames-client-connect-v1"!==h.data?.type)return;const u=new e.MessageChannel;l=u.port1,l.onmessage=t=>{const o=t.data;if(!p&&"player-state"===o?.type){if("string"==typeof o.title&&(m=o.title.slice(0,200),f?.setTitle(m)),"string"==typeof o.author&&f?.setAuthor?.(o.author.slice(0,200)),"string"==typeof o.status&&v(o.status.slice(0,300)),o.ready){f?.setPlayerName(a.profile?.get()||"",o.playerNames&&a.profile?e=>{if(p)throw new Error("This player has closed. Reopen the game to change your name.");const t=a.profile.set(e);return w("player-name",t),t}:null);for(const[e,t]of[["share","Share"],["copy-share","Share a copy"],["manual-connect","Manual connection"],["exports","View exports"]])f?.setAction(e,"exports"===e||o.sharing?{label:t,run:()=>w(e)}:null);f?.setAction("download-html",{label:"Download game HTML",id:a.htmlId,run:()=>b("html")}),f?.setAction("download-zip",{label:"Download game ZIP",id:a.zipId,run:()=>b("zip")}),a.editGame&&f?.setAction("edit-game",{label:"Edit this game",id:"edit-game",run:()=>a.editGame(()=>x("zip"))})}return}if(!p&&"close-exports"===o?.type)return void d?.close();if(!p&&"view-exports"===o?.type&&Number.isSafeInteger(o.id))return d||!n?void l.postMessage({type:"export-result",id:o.id,error:"Export viewer is unavailable or already open"}):(d=n(e,{list:()=>x("export-list"),read:e=>x("export-file",e)}),void d.result.finally(()=>{d=null,p||l.postMessage({type:"export-result",id:o.id})}));if(!p&&["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=>{p||l.postMessage({type:"export-result",id:o.id,value:e})},e=>{p||l.postMessage({type:"export-result",id:o.id,error:e.message})});if(!p&&"cancel-audio"===o?.type)return void(c?.requestId===o.id&&c.close());if(!p&&["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:i;return t?(c=t(e,o.recording||{}),c.requestId=o.id,void c.result.then(e=>{c=null,p||l.postMessage({type:"audio-result",id:o.id,value:e})},e=>{c=null,p||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=y.get(o?.id);!p&&"game-download"===o?.type&&h&&(y.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()},"*",[u.port2]),!f&&o&&(f=o(e,{title:a.title,author:a.author,home:a.home,status:"Starting game…",onOpen:()=>w("pause-input"),onClose:()=>w("resume-input")}),g=!0,t.before(f.bar)),t.parentElement.style.display="flex",t.parentElement.style.flexDirection="column",t.style.flex="1",t.style.minHeight="0",t.style.height="0"}return e.addEventListener("message",E),{request:x,command:w,download:b,close(){p=!0,e.removeEventListener("message",E),l?.close(),g&&f?.dispose(),c?.close(),d?.close();for(const e of y.values())clearTimeout(e.timer),e.reject(new Error("Player closed"));y.clear()}}},connectClientSource:function(e,t,s={},r={}){let n,i,o,a,h=!1,l=0;const c=new Map,d=new Promise(e=>{i=e}),u=setTimeout(i,15e3),p=l=>{!h&&l.source===e.parent&&"homegames-client-port-v1"===l.data?.type&&l.ports[0]&&(e.removeEventListener("message",p),n=l.ports[0],a=l.data.playerName,clearTimeout(u),i(),o&&n.postMessage({type:"player-state",...o}),n.onmessage=async e=>{const i=e.data;if(h||"player-control"!==i?.type||!Object.hasOwn(r,i.action)){if("audio-result"===i?.type||"export-result"===i?.type){const e=c.get(i.id);if(!e)return;return c.delete(i.id),clearTimeout(e.timer),void(i.error?e.reject(new Error(i.error)):e.resolve(i.value))}if(!h&&"download-game"===i?.type&&Number.isSafeInteger(i.id)&&["html","zip","export-list","export-file"].includes(i.format))try{const e="export-list"===i.format?{value:await s.list()}:"export-file"===i.format?{value:await s.read(i.name)}:{bytes:await t(i.format)};h||n.postMessage({type:"game-download",id:i.id,...e})}catch(e){h||n.postMessage({type:"game-download",id:i.id,error:e.message})}}else try{"player-name"===i.action&&(a=i.value),await r[i.action](i.value)}catch(e){n.postMessage({type:"player-state",status:e.message})}})};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 i=++l,o={resolve:s,reject:r,recordingId:t.recording?.id,type:e};o.timer="view-exports"===e?null:setTimeout(()=>{c.delete(i),"record-audio"!==e&&"record-video"!==e||n?.postMessage({type:"cancel-audio",id:i}),r(new Error("Client request timed out"))},9e4),c.set(i,o),d.then(()=>{if(c.has(i))return h||!n?(clearTimeout(o.timer),c.delete(i),void r(new Error("Client adapter is unavailable"))):void n.postMessage({type:e,id:i,...t})})});return{setState(e){o={...o,...e},h||n?.postMessage({type:"player-state",...o})},getPlayerName:async()=>(await d,a),recordAudio:e=>f("record-audio",{recording:e}),recordVideo:e=>f("record-video",{recording:e}),viewExports:()=>f("view-exports"),closeExports(){n?.postMessage({type:"close-exports"})},cancelRecording(e){for(const[t,s]of c)["record-audio","record-video"].includes(s.type)&&s.recordingId===e&&(n?.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),i(),e.removeEventListener("message",p);for(const[e,t]of c)t.recordingId&&n?.postMessage({type:"cancel-audio",id:e}),clearTimeout(t.timer),t.reject(new Error("Player closed"));c.clear(),n?.close()}}},recordAudio:function(e,t){const s=e.document;let r,n,i,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 g=new Promise((e,t)=>{r=(r,h)=>{a||(a=!0,clearTimeout(o),"recording"===i?.state&&i.stop(),n?.getTracks().forEach(e=>e.stop()),s.removeEventListener("visibilitychange",m),c.close(),c.remove(),r?t(r):e(h))}});f.onclick=()=>r(new Error("Recording cancelled"));const m=()=>{s.hidden&&r(new Error("Recording cancelled because the page was hidden"))};return s.addEventListener("visibilitychange",m),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());n=s,i=new e.MediaRecorder(n);const c=[];let d=0;i.ondataavailable=e=>{e.data.size&&(d+=e.data.size,d>5242880?r(new Error("Recording is too large")):c.push(e.data))},i.onstop=async()=>{if(a)return;let s;try{s=new(e.AudioContext||e.webkitAudioContext);const n=await s.decodeAudioData(await new Blob(c).arrayBuffer()),i=22050,o=Math.min(Math.floor(n.duration*i),h*i),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,i,!0),d.setUint32(28,2*i,!0),d.setUint16(32,2,!0),d.setUint16(34,16,!0),u(36,"data"),d.setUint32(40,2*o,!0);const p=n.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*n.sampleRate/i))]))),!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())}},i.onerror=()=>r(new Error("Recording failed")),i.start(250),u.textContent="Recording…",o=setTimeout(()=>{i.stop(),n.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:g,close:()=>r(new Error("Recording cancelled"))}}}},5758(e,t,s){"use strict";const{exportArchive:r,LIMITS:n}=s(5110),{attachSaveHost:i}=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"),g=e=>String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),m=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*n.archiveBytes+8388608;function x(e){let t="";for(let s=0;s<e.length;s+=8192)t+=String.fromCharCode(...e.subarray(s,s+8192));return btoa(t)}async function v(e,{clientBundleSource:t,installationId:s,sharing:n={},studioUrl:i,studioDebug:o=!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 a=new URL(n.signalingUrl||"wss://api.homegames.io/rtc");if(!["ws:","wss:","http:","https:"].includes(a.protocol)||a.username||a.password)throw new Error("Invalid signaling URL");a.protocol="https:"===a.protocol?"wss:":"http:"===a.protocol?"ws:":a.protocol;const h=new URL(n.joinUrl||"https://homegames.io/play.html");if(!["http:","https:"].includes(h.protocol))throw new Error("Invalid invitation URL");const l=new URL(i||"/studio.html",h);if(!["http:","https:"].includes(l.protocol)||l.username||l.password)throw new Error("Invalid Studio URL");const c=new URL(n.receiveUrl||"/game-app.html",h);if(!["http:","https:"].includes(c.protocol))throw new Error("Invalid copy receiver URL");const d={archive:x(await r(e)),installationId:s,studioUrl:l.href,studioDebug:!0===o,sharing:!1!==n&&{signalingUrl:a.href,joinUrl:h.href,receiveUrl:c.href}},u=`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'":a.origin+a.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="${g(u)}"><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(d)};\nlet client,clientSource,copyShare,pairing,debug;\nconst state=status=>clientSource?.setState({status});\nconst fail=error=>{document.getElementById('error').hidden=false;document.getElementById('error').textContent=error.message||String(error);state('Unable to play: '+(error.message||String(error)));};\ntry {\nconst project=await HomegamesClient.PortableProject.importArchive(Uint8Array.from(atob(payload.archive),ch=>ch.charCodeAt(0)));\nconst saveError=error=>{state('Progress not saved: '+error.message);};\nconst saveStore=await HomegamesClient.PortableProject.connectSaveStore(window,{gameKey:'project:'+payload.installationId,versionId:'save-schema:'+project.manifest.saveSchemaVersion,onError:saveError,stop:()=>client?.stop()});\nconst shareCopy=async()=>{const copy=await client.requestGameCopy();copyShare?.close();copyShare=HomegamesClient.GameCopies.showCopyShare(copy.project,{signalingUrl:payload.sharing.signalingUrl,receiveUrl:payload.sharing.receiveUrl,onOpen:()=>client.setInputEnabled(false),onClose:()=>client.setInputEnabled(true)});};\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(),'copy-share':shareCopy,'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,ready:true,sharing:!!payload.sharing,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,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,platform:clientSource,playerName:await clientSource.getPlayerName?.(),onReady:()=>{ready('Connected manually to host');debug?.ready();},onClose:()=>state('Host disconnected'),onError:fail});client.start();}}):null;\nif(payload.studioDebug)debug=HomegamesClient.PortableProject.connectStudioDebugSource(window,()=>client._localSession);\nwindow.addEventListener('pagehide',()=>{debug?.close();copyShare?.close();pairing?.dispose();client.stop();clientSource.close();});client.startLocalGame({});\n}catch(error){fail(error);}\n})();\n<\/script></body></html>`}function w(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:v,createFrame:w,buildIsolatedHtml:async function(e,t){const s=await v(e,t),n=new URL(t.studioUrl||"/studio.html",t.sharing?.joinUrl||"https://homegames.io/play.html").href,y=f({formatVersion:1,document:s,archive:x(await r(e)),name:m(e.metadata.name),title:e.metadata.name||"Homegame",author:e.metadata.author||e.metadata.createdBy||"",studioUrl:n,homeUrl:new URL("/catalog.html",n).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>${g(e.metadata.name||"Homegame")}</title>\n<style>html,body{margin:0;height:100%;background:#101820;color:#f7fafc;font:14px system-ui}body{display:flex;flex-direction:column}iframe{flex:1;width:100%;border:0;min-height: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 originalHtml='<!doctype html>\\n'+document.documentElement.outerHTML;\nlet frame,saveHost,clientHost;\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=>toolbar.setStatus(message);\nconst editGame=getArchive=>{showSaveStatus('Opening Studio…');return (${p.toString()})(window,getArchive,payload.studioUrl).then(()=>showSaveStatus('Editable copy saved in Studio'));};\nasync function mount(){clientHost?.close();if(saveHost)await saveHost.close();frame?.remove();frame=(${w.toString()})(document,payload.document);saveHost=(${i.toString()})(window,frame,{...payload.saves,onStatus:value=>showSaveStatus(value.message)});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);}\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(Uint8Array.from(atob(payload.archive),c=>c.charCodeAt(0)),'application/zip',payload.name)});\ntoolbar.setAction('edit-game',{label:'Edit this game',id:'edit-game',run:()=>editGame(()=>Uint8Array.from(atob(payload.archive),c=>c.charCodeAt(0)))});\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();\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);}};\n<\/script></body></html>`},filename:m,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(n.archiveBytes/3)||/[^A-Za-z0-9+/=]/.test(r.archive))throw new Error("Invalid game HTML archive");const i=Uint8Array.from(atob(r.archive),e=>e.charCodeAt(0));if(i.length>n.archiveBytes)throw new Error("Game archive is too large");return i},htmlBytesLimit:y}},4811(e,t,s){"use strict";const{describeMedia:r}=s(3947);function n(e,t){const s=r(e,{fileName:t});if(s.kind)return s;const n=String.fromCharCode(...e.subarray(0,4)),i={wOFF:"font/woff",wOF2:"font/woff2",OTTO:"font/otf","\0\0\0":"font/ttf"};if(e.length>=12&&i[n])return{kind:"font",contentType:i[n]};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:n,validateAsset:function(e,t){if(!e||!["image","audio","video","font"].includes(e.type)||!(t instanceof Uint8Array)||!t.length||t.length>10485716||n(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:n}=s(595),i=s(8630),{describeAsset:o}=s(4811),{packAssetBundle:a}=s(3735),h="homegame.json",l=".homegame/inventory.json",c=Object.freeze({files:512,fileBytes:16777216,totalBytes:67108864,archiveBytes:68157440,sourceBytes:1048576}),d=new TextEncoder,u=new TextDecoder("utf-8",{fatal:!0}),p=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),f=e=>{throw new Error(e)},g=e=>"string"==typeof e?d.encode(e):e instanceof Uint8Array?new Uint8Array(e):f("Project files must contain text or Uint8Array bytes"),m=e=>u.decode(e),y=e=>JSON.stringify(x(e));function x(e){if(Array.isArray(e))return e.map(x);if(e&&"object"==typeof e){const t=Object.create(null);for(const s of Object.keys(e).sort())t[s]=x(e[s]);return t}return e}function v(e){("string"!=typeof e||!e.length||e.length>240)&&f("Invalid project path");const t=e.startsWith("./")?e.slice(2):e;/^[A-Za-z0-9_. /-]+$/.test(t)||f(`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))&&f(`Unsafe project path: ${e}`);return t}function w(e){const t=new Set;for(const s of e){v(s)!==s&&f(`Non-canonical project path: ${s}`);const e=s.toLowerCase();t.has(e)&&f(`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("/"))&&f(`File/directory collision: ${e}`)}}function b(e,t){try{return JSON.parse(m(e))}catch(e){f(`Invalid JSON or UTF-8 in ${t}`)}}async function E(e,t){if(t.sha256)return t.sha256(e);globalThis.crypto?.subtle||f("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 S(e,t){if(e&&"string"==typeof e.type){t(e);for(const s of Object.values(e))Array.isArray(s)?s.forEach(e=>S(e,t)):s&&"string"==typeof s.type&&S(s,t)}}function _(e,t,s=new Map,r=new Set){e||f(`${t} must be declared as a literal`),(r.has(e)||r.size>64)&&f(`Circular or excessive constant expression in ${t}`),r=new Set(r).add(e);const n=e=>_(e,t,s,r),i=(e,r=new Set)=>{if((!e||r.has(e)||r.size>64)&&f(`Unresolved constant in ${t}`),r.add(e),"Identifier"===e.type&&s.has(e.name))return i(s.get(e.name),r);if("MemberExpression"===e.type){const t=i(e.object,r),s=e.computed?n(e.property):e.property.name;if("ObjectExpression"===t.type)return i(t.properties.find(e=>"Property"===e.type&&!e.computed&&(e.key.name??e.key.value)===s)?.value,r)}return e},o=i(e);if(o!==e)return n(o);if("Literal"===e.type&&!(e.value instanceof RegExp))return e.value;if("UnaryExpression"===e.type&&["-","+","!"].includes(e.operator)){const t=n(e.argument);return"!"===e.operator?!t:"-"===e.operator?-t:+t}if("ArrayExpression"===e.type)return e.elements.map(n);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)&&f(`${t} must use literal properties`);const e=r.key.name??r.key.value;p(s,e)&&f(`Duplicate ${t} property: ${e}`),s[e]=n(r.value)}return s}f(`${t} must be declared as a literal`)}function C(e,t,s){"string"==typeof s&&/^\.\.?\//.test(s)||f(`Unsupported module in ${t}: ${s}`);const r=t.split("/").slice(0,-1);for(const e of s.split("/"))"."!==e&&(".."===e?(r.length||f(`Module escapes project root in ${t}: ${s}`),r.pop()):r.push(e));const n=v(r.join("/"));n.startsWith("user-exports/")&&f("User exports are bytes, not executable modules");const i=[n,`${n}.js`,`${n}.json`,`${n}/index.js`].find(t=>p(e,t));return i&&/\.(js|json)$/.test(i)||f(`Missing JavaScript module or JSON data in ${t}: ${s}`),i}function A(e,t){return e.endsWith(".js")?"text/javascript":e.endsWith(".json")?"application/json":o(t,e).contentType||"application/octet-stream"}async function k(e,t={}){const r=Object.keys(e);r.length>c.files&&f("Project contains too many files"),w(r);const n=Object.create(null);let a=0;for(const t of r){(".homegame"===t.toLowerCase()||t.toLowerCase().startsWith(".homegame/"))&&f("The .homegame directory is reserved for generated inventory");const s=e[t],r="string"==typeof s?d.encode(s).length:s?.byteLength;(!Number.isSafeInteger(r)||r>c.fileBytes||(a+=r)>c.totalBytes)&&f(`Project size limit exceeded at ${t}`),n[t]=g(s)}p(n,h)||f("Missing homegame.json");const l=Object.fromEntries(Object.entries(n).filter(([e])=>e.startsWith("user-exports/")).map(([e,t])=>[e.slice(13),t]));s(5828).validateFiles(l);const u=b(n[h],h);1!==u?.formatVersion&&f(`Unsupported project format: ${u?.formatVersion}`),"string"==typeof u.gameId&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(u.gameId)||f("homegame.json needs a UUID gameId"),(!Number.isSafeInteger(u.saveSchemaVersion)||u.saveSchemaVersion<1)&&f("Invalid saveSchemaVersion");const x=u.runtime?.squishVersion;Array.isArray(t.supportedRuntimes)&&t.supportedRuntimes.includes(x)||f(`Unsupported runtime: squish-${x}. Supported: ${(t.supportedRuntimes||[]).join(", ")}`),v(u.entry)===u.entry&&!u.entry.startsWith("user-exports/")&&u.entry.endsWith(".js")&&p(n,u.entry)||f(`Missing or invalid entry: ${u.entry}`);const{metadata:k,assets:I}=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>c.sourceBytes&&f(`JavaScript file exceeds 1 MiB: ${t}`);try{s[t]=i.parse(m(r),{ecmaVersion:"latest",sourceType:"script"})}catch(e){f(`Cannot parse ${t}: ${e.message}`)}}const r=[];S(s[t.entry],e=>{"MethodDefinition"===e.type&&e.static&&!e.computed&&"metadata"===(e.key.name??e.key.value)&&r.push(e)});const n=r[0]?.value.body.body;1===r.length&&1===n.length&&"ReturnStatement"===n[0].type&&"ObjectExpression"===n[0].argument?.type||f("Portable games need one static metadata() returning a literal object");const a=Object.create(null),h=[],l=new Set,d=new Map;for(const e of s[t.entry].body)if("VariableDeclaration"===e.type&&"const"===e.kind)for(const t of e.declarations)"Identifier"===t.id.type&&d.set(t.id.name,t.init);for(const t of n[0].argument.properties){("Property"!==t.type||t.computed||t.method||"init"!==t.kind)&&f("Portable metadata must use literal properties");const s=t.key.name??t.key.value;if(p(a,s)&&f(`Duplicate metadata property: ${s}`),"assets"===s){"ObjectExpression"!==t.value.type&&f("metadata.assets must be a literal object"),a.assets=Object.create(null);for(const s of t.value.properties){("Property"!==s.type||s.computed||s.method||"init"!==s.kind)&&f("Asset declarations must use literal keys");const t=s.key.name??s.key.value;/^[A-Za-z0-9_-]{1,32}$/.test(t)&&!["__proto__","constructor","prototype"].includes(t)||f(`Invalid asset key: ${t}`),p(a.assets,t)&&f(`Duplicate asset key: ${t}`);const r=s.value;"NewExpression"===r.type&&"Asset"===r.callee.name&&1===r.arguments.length||f(`Asset ${t} must use new Asset({ path, type })`);const n=_(r.arguments[0],`Asset ${t}`);void 0!==n.id&&f(`Asset ${t} still uses a hosted asset ID; convert it to a project path`);const i=v(n.path);p(e,i)||f(`Missing asset "${t}": ${i}`);const c=o(e[i],i);["image","audio","video","font"].includes(n.type)&&c.kind===n.type||f(`Unsupported or invalid ${n.type} asset "${t}": ${i}`),a.assets[t]=n,h.push({key:t,path:i,type:n.type}),l.add(r)}}else a[s]=_(t.value,`metadata.${s}`,d)}a.squishVersion!==t.runtime.squishVersion&&f("metadata.squishVersion must match homegame.json"),!a.services||Array.isArray(a.services)&&!a.services.some(e=>"multiplayer"!==e)||f("This portable runtime supports only the multiplayer service");for(const[r,n]of Object.entries(s))S(n,s=>{if("NewExpression"!==s.type||"Asset"!==s.callee.name||l.has(s)||2===s.arguments.length||f(`Declare portable assets in the entry metadata.assets or supply bytes: ${r}`),"CallExpression"===s.type&&"require"===s.callee.name){const n=_(s.arguments[0],`require() in ${r}`);if(n===`squish-${t.runtime.squishVersion}`)return;"string"==typeof n&&n.startsWith("squish-")&&f(`Runtime mismatch in ${r}: ${n}`);const i=C(e,r,n);i.endsWith(".json")&&b(e[i],i)}});return{metadata:a,assets:h}}(n,u);I.some(e=>44+n[e.path].length>10485760)&&f("An asset exceeds the current 10 MiB RTC packet limit");const T=[];for(const e of r.sort())T.push({path:e,byteLength:n[e].length,mediaType:A(e,n[e]),sha256:await E(n[e],t)});const P=await E(d.encode(y({manifest:u,files:T})),t),L=Object.freeze({listFiles:()=>[...r],readFile:e=>{const t=v(e);return p(n,t)||f(`Missing project file: ${t}`),n[t].slice()},stat:e=>{const t=v(e),s=T.find(e=>e.path===t);return s||f(`Missing project file: ${t}`),{...s}}});return{manifest:u,metadata:k,assets:I,revision:P,inventory:T,reader:L}}e.exports={checkSyntax:function(e){try{return i.parse(e,{ecmaVersion:"latest",sourceType:"script"}),null}catch(e){return{message:e.message,line:e.loc?.line||1}}},thumbnailPath:function(e){try{const t=v(b(g(e[h]),h).entry),s=g(e[t]);if(s.length>c.sourceBytes)return null;const r=i.parse(m(s),{ecmaVersion:"latest",sourceType:"script"}),n=[],o=new Map;S(r,e=>{"MethodDefinition"===e.type&&e.static&&!e.computed&&"metadata"===(e.key.name??e.key.value)&&n.push(e)});const a=n[0]?.value.body.body;if(1!==n.length||1!==a.length||"ReturnStatement"!==a[0].type||"ObjectExpression"!==a[0].argument?.type)return null;for(const e of r.body)if("VariableDeclaration"===e.type&&"const"===e.kind)for(const t of e.declarations)"Identifier"===t.id.type&&o.set(t.id.name,t.init);const l=a[0].argument.properties.find(e=>"Property"===e.type&&!e.computed&&!e.method&&"init"===e.kind&&"thumbnail"===(e.key.name??e.key.value));if(!l)return null;const d=v(_(l.value,"thumbnail",o));return p(e,d)?d:null}catch(e){return null}},MANIFEST:h,INVENTORY:l,LIMITS:c,normalizePath:v,resolveModule:C,canonical:y,createProject:k,exportArchive:async function(e){const t=Object.create(null);for(const s of e.reader.listFiles())t[s]=e.reader.readFile(s);return t[l]=d.encode(y({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){(!(e instanceof Uint8Array)||e.length>c.archiveBytes||e.length<22)&&f("Invalid or oversized project archive");const t=new DataView(e.buffer,e.byteOffset,e.byteLength);let s=e.length-22;for(;s>=Math.max(0,e.length-65557)&&101010256!==t.getUint32(s,!0);)s--;s<Math.max(0,e.length-65557)&&f("Damaged ZIP: missing directory"),(s+22+t.getUint16(s+20,!0)!==e.length||t.getUint16(s+4,!0)||t.getUint16(s+6,!0)||t.getUint16(s+8,!0)!==t.getUint16(s+10,!0))&&f("Unsupported multi-volume or damaged ZIP");const r=t.getUint16(s+10,!0),n=t.getUint32(s+12,!0),i=t.getUint32(s+16,!0);(r>c.files+1||i+n!==s)&&f("Unsupported ZIP directory or too many files");let o=i,a=0;const h=[],l=[];for(let n=0;n<r;n++){(o+46>s||33639248!==t.getUint32(o,!0))&&f("Damaged ZIP directory");const r=t.getUint16(o+8,!0),n=t.getUint16(o+10,!0),d=t.getUint32(o+24,!0),u=t.getUint32(o+20,!0),p=t.getUint16(o+28,!0),g=t.getUint16(o+30,!0),y=t.getUint16(o+32,!0),x=t.getUint32(o+42,!0),v=t.getUint32(o+38,!0)>>>16;(1&r||![0,8].includes(n)||t.getUint16(o+34,!0)||40960==(61440&v))&&f("Encrypted files, links and this ZIP compression are unsupported"),(d>c.fileBytes||(a+=d)>c.totalBytes+c.fileBytes)&&f("Expanded ZIP exceeds project size limits"),(o+46+p+g+y>s||x+30>i)&&f("Damaged ZIP entry");const w=m(e.subarray(o+46,o+46+p));h.push(w),67324752===t.getUint32(x,!0)&&t.getUint16(x+6,!0)===r&&t.getUint16(x+8,!0)===n||f("ZIP headers disagree");const b=t.getUint16(x+26,!0),E=x+30+b+t.getUint16(x+28,!0);(E+u>i||m(e.subarray(x+30,x+30+b))!==w)&&f("Damaged ZIP file bounds or name"),l.push({name:w,size:d,offset:x,end:E+u}),o+=46+p+g+y}return o!==s&&f("Damaged ZIP directory length"),w(h),l.sort((e,t)=>e.offset-t.offset),l.some((e,t)=>t&&e.offset<l[t-1].end)&&f("Overlapping ZIP entries"),l}(e),r=n(e)}catch(e){f(`Cannot import project: ${e.message}`)}for(const e of s)r[e.name]?.length!==e.size&&f(`Damaged ZIP file: ${e.name}`);p(r,l)||f("Missing project inventory");const i=b(r[l],l);delete r[l];const o=await k(r,t);return 1===i?.formatVersion&&i.revision===o.revision&&y(i.files)===y(o.inventory)||f("Project integrity check failed: missing, changed or undeclared files"),o},assetBundle:function(e){return a(e.assets.map(t=>({key:t.key,type:t.type,data:e.reader.readFile(t.path)})))}}},7435(e,t,s){"use strict";const{normalizePath:r,resolveModule:n,assetBundle:i}=s(5110),o=new TextDecoder("utf-8",{fatal:!0});function a(e,t,{trusted:i=!1}={}){if(!i)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(688).Asset{constructor(t,n){if(void 0!==n){if(!(n instanceof ArrayBuffer||ArrayBuffer.isView(n)||Array.isArray(n)))throw new Error("Generated assets need byte data");if((n.byteLength??n.length)>10485716)throw new Error("Generated asset exceeds the RTC packet limit");const e=n instanceof ArrayBuffer?new Uint8Array(n):ArrayBuffer.isView(n)?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):Uint8Array.from(n);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 i=r(t.path);if(!e.assets.some(e=>e.path===i&&e.type===t.type))throw new Error(`Undeclared project asset: ${i}`);const o=e.reader.readFile(i);super({...t,path:i},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(n(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(2947).bindGameProject(f,()=>e,{supportedRuntimes:Object.keys(t)},{files:s(5828).projectExports(e)})}e.exports={loadTrustedGame:a,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?i(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:n,versionId:i,compatibility:o=[],onStatus:a=()=>{}}=s;if(!/^[a-zA-Z0-9-]{16,80}$/.test(r)||"string"!=typeof n||!/^save-schema:\d+$/.test(i))throw new Error("Invalid save identity");const h="project:"+r,l=[i,...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,g,m,y=!1,x=0,v=!1,w=null,b=0,E=Promise.resolve();const S=(e,t)=>{try{a({state:e,message:t})}catch(e){}},_=e=>S("error","Progress not saved: "+e.message+" Download a save backup before closing."),C=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 A(){return s.database?Promise.resolve(s.database):(c||(c=new Promise((t,s)=>{let r=!1;const n=e.indexedDB.open("homegames-portable-saves",1);n.onupgradeneeded=()=>n.result.createObjectStore("saves",{keyPath:["installationId","versionId"]}),n.onerror=()=>s(n.error),n.onblocked=()=>{r=!0,s(new Error("Close other game tabs and reload to update save storage."))},n.onsuccess=()=>{r?n.result.close():(n.result.onversionchange=()=>n.result.close(),t(n.result))}})),c)}function k(e){b++;const t=E.then(e);return E=t.catch(()=>{}).finally(()=>{b--}),t}async function I(){try{const e=await A(),t=await new Promise((t,s)=>{const n=e.transaction("saves","readonly"),i=[];l.forEach((e,t)=>{const s=n.objectStore("saves").get([r,e]);s.onsuccess=()=>{i[t]=s.result}}),n.oncomplete=()=>t(i),n.onabort=()=>s(n.error||new Error("Could not read game save"))});x=t[0]?.generation||0;const s=t.find(Boolean);if(s){if(s.envelope.gameId!==n||!l.includes(s.envelope.versionId))throw new Error("Saved game identity does not match this game");w={...s.envelope,data:C(s.envelope.data)}}return v=!0,S("ready",w?"Game progress restored from this browser":"Game saves stay in this browser"),w}catch(e){return v=!0,m=e,_(e),null}}async function T(e,t=i){if(!v)throw new Error("Load this game before saving");if(w=((e,t=i)=>({gameKey:h,gameId:n,versionId:t,savedAt:Date.now(),data:C(e)}))(e,t),m)throw m;const o=await A(),a=w;await new Promise((e,t)=>{const n=s.transaction?s.transaction(["saves"]):o.transaction("saves","readwrite"),h=n.objectStore("saves");let l;const c=h.get([r,i]);c.onsuccess=()=>{try{if((c.result?.generation||0)!==x)throw new Error("Another tab saved newer progress. Reload to use it, or download this session’s save.");h.put({installationId:r,versionId:i,generation:x+1,envelope:a})}catch(e){l=e,n.abort()}},n.oncomplete=()=>{x++,e()},n.onabort=()=>t(l||n.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 n;try{"put"===r&&(n=C(t.data))}catch(e){return P({id:s,error:e.message}),void _(e)}k(async()=>{if(y)throw new Error("Game session closed");return"get"===r?v?w:I():T(n)}).then(e=>P({id:s,value:e}),e=>{_(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(g),d?.close(),e.removeEventListener("message",L),e.removeEventListener("beforeunload",M),c?.then(e=>e.close(),()=>{})}function O(){return u||(u=(async()=>{d&&!y&&await new Promise(e=>{f=e,g=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 O(),R()})(),p),dispose:R,async exportSave(){if(await E,!w)throw new Error("This game has not saved any progress yet");return JSON.stringify({...w,data:C(w.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!==n||!l.includes(t.versionId))throw new Error("This save is for a different game or an incompatible save version");const s=C(t.data);await O(),await k(async()=>{v||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"})),n=e.document.createElement("a");n.href=r,n.download=t,n.click(),setTimeout(()=>e.URL.revokeObjectURL(r),3e4)})}}},connectSaveStore:function(e,{gameKey:t,versionId:s,onError:r=()=>{},stop:n=()=>{}}){return new Promise((i,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,n)=>{const i=++h,o=setTimeout(()=>{c.delete(i);const e=new Error("Game save timed out");r(e),n(e)},1e4);c.set(i,{resolve:s,reject:n,timeout:o});try{a.postMessage(void 0===t?{id:i,op:e}:{id:i,op:e,data:t})}catch(e){clearTimeout(o),c.delete(i),n(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){n(),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)},i({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:n}=s(5110),{validateName:i,LIMITS:o}=s(5828),a=65536,h=new TextEncoder,l=new TextDecoder("utf-8",{fatal:!0});function c(e){const t=h.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||(n=t.id,!(Number.isInteger(n)&&n>0&&n<=4294967295)))return;var n;const h=this.transfers.get(e),l=e=>s(c({action:"error",id:t.id,message:e}));if("cancel"===t.action)return void(h?.id===t.id&&this.leave(e));if("request"===t.action){if(h||this.transfers.size>=4)return void l("A file transfer is already in progress. Try again shortly.");const n={id:t.id,offset:0,send:s};this.transfers.set(e,n),this.touch(e,n);try{let a,h;const l=t.kind||"project";if("export-list"===l){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)!==n)return;return this.leave(e),void s(c({action:"exports",id:n.id,files:t}))}if("export"===l){if(i(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:l,name:t.name}}else{if("project"!==l)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)!==n)return;n.bytes=a,s(c({action:"offer",id:n.id,bytes:a.length,...h}))}catch(t){this.transfers.get(e)===n&&(this.leave(e),l(String(t.message).slice(0,200)))}return}if("ack"!==t.action||!h||h.id!==t.id)return;if(!h.bytes||t.offset!==h.offset)return this.leave(e),void l("Invalid game-copy acknowledgement");if(this.touch(e,h),h.offset===h.bytes.length)return this.leave(e),void s(c({action:"complete",id:h.id}));const d=Math.min(h.offset+a,h.bytes.length),u=new Uint8Array(9+d-h.offset);u[0]=15;const p=new DataView(u.buffer);p.setUint32(1,h.id),p.setUint32(5,h.offset),u.set(h.bytes.subarray(h.offset,d),9),h.offset=d,s(u)}touch(e,t){clearTimeout(t.timer),t.timer=setTimeout(()=>{this.transfers.get(e)===t&&(this.leave(e),t.send(c({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{i(t)}catch(e){return Promise.reject(e)}return new Promise((s,r)=>{const n=this.sequence=this.sequence%4294967295+1;this.pending={id:n,resolve:s,reject:r,offset:0,kind:e,name:t},this.touch();try{this.send({type:"project-transfer",action:"request",id:n,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(l.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 n=e.files.map(e=>{if(i(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(n)}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:n.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(a,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,CHUNK_BYTES:a}},9956(e,t,s){const{Squisher:r}=s(688);e.exports={createSessionRuntime:(e,t,n={})=>{if("function"!=typeof e?.squish||"function"!=typeof e?.unsquish)throw new Error("Session needs an explicit Squish codec");const i=new r({...n,game:t,encodeNode:e.squish,decodeNode:e.unsquish});let o=!1;return{squisher:i,listExports:()=>o?Promise.reject(new Error("Session closed")):n.userExportsStore?.list()||Promise.resolve([]),readExport:e=>o?Promise.reject(new Error("Session closed")):n.userExportsStore?.read(e)||Promise.reject(new Error("Export not found")),exportProject:()=>o?Promise.reject(new Error("Session closed")):s(2947).exportGameProject(t,n.userExportsStore),stop(){o||(o=!0,i.close(),n.userExportsStore?.close())}}},playerFrame:(e,t)=>Uint8Array.from(e.getPlayerFrame(t).flat()),collectGameAssets:({game:e,customBottomLayer:t,customTopLayer:s})=>Object.assign({},e.constructor.metadata?.()?.assets,t?.assets,s?.assets,e.getAssets?.())}},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 n(e,i){if(!e||"object"!=typeof e||i>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=n(s,i+1);e&&o.children.push(e)}return o}return Array.isArray(e)?e.slice(0,128).map(e=>n(e,0)).filter(Boolean):[]}e.exports={inspectorTree:t,attachStudioDebugHost:function(e,s,{onReady:r=()=>{},onError:n=()=>{},onLog:i=()=>{}}={}){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 n=++d,i=setTimeout(()=>{p.delete(n),r(new Error("Preview debugger timed out"))},5e3);p.set(n,{resolve:s,reject:r,timer:i}),o.postMessage({id:n,action:e,value:t})})}const g=(e,t)=>{f(e,t).catch(e=>{c||n(e)})};function m(n){if(c||o||n.source!==s.contentWindow||"null"!==n.origin||"homegames-studio-debug-v1"!==n.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))i(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",m),{embedded:!0,get playerId(){return u},enableInspector(e,t){a=e,h=t,g("inspect",!0)},disableInspector(){a=h=l=null,g("inspect",!1)},showFrame:e=>g("frame",e),resumeLive:()=>g("live"),setHighlight:e=>g("highlight",e),enablePick(e){l=e,g("pick",!0)},disablePick(){l=null,g("pick",!1)},addPlayer:()=>f("add-player"),removePlayer:e=>g("remove-player",e),freeze:()=>g("freeze"),stop(){if(!c){c=!0,e.removeEventListener("message",m),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,n=new Map;let i,o,a,h=!1,l=!1,c=0,d=0,u=null;const p=e=>{!h&&i&&i.postMessage(e)},f=()=>e.dispatchEvent(new e.Event("resize"));function g(e){null!==u&&e?.removePlayer(u),u=null,o?.remove(),o=null,a?.remove(),a=null,f()}const m=(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){n.clear(),d=0,s?e.enableInspector(e=>{if(!e.buf?.byteLength||e.buf.byteLength>8388608)return;const s=++c;for(n.set(s,e.buf.slice()),d+=e.buf.byteLength;n.size>600||d>67108864;){const e=n.keys().next().value;d-=n.get(e).byteLength,n.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=n.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 g(e),new Error("Could not add a player");return a=m(t,"Player "+e.playerId),m(o,"Player "+u),f(),u},"remove-player":e=>g(e),freeze(e){g(e),e.freeze()}};function x(t){h||i||t.source!==e.parent||"homegames-studio-debug-port-v1"!==t.data?.type||!t.ports[0]||(e.removeEventListener("message",x),i=t.ports[0],i.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",x),e.parent.postMessage({type:"homegames-studio-debug-v1"},"*");const v={},w={};let b=0,E=0;for(const t of["log","warn","error"])v[t]=e.console[t],w[t]=(...s)=>{v[t].apply(e.console,s);const r=Date.now();if(r-b>1e3&&(E=0,b=r),++E>25)return;const n=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:n})},e.console[t]=w[t];return{ready(){l=!!s(),p({event:"ready",available:l,playerId:s()?.playerId})},close(){if(!h){h=!0,e.removeEventListener("message",x),s()?.disableInspector(),g(s()),n.clear(),i?.close();for(const t of Object.keys(v))e.console[t]===w[t]&&(e.console[t]=v[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 n=e.crypto.randomUUID(),i=r.origin;return r.hash=new URLSearchParams({edit:n,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(g),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===i&&e.data?.token===n)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:n,bytes:e},i),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),g=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"),n=s.get("from"),i=e.opener,o="file://"===n;if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(r||"")||!i)return Promise.reject(new Error("Reopen Edit this game from the player, or import its HTML or ZIP."));try{if(!("null"===n||o||["http:","https:"].includes(new URL(n).protocol)&&new URL(n).origin===n))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{i.postMessage({...e,token:r},"null"===n||o?"*":n)}catch(e){}},d=(t,r)=>{l||(l=!0,clearTimeout(g),clearInterval(m),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!==i||(o?!["null","file://"].includes(e.origin):e.origin!==n)||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(m),clearTimeout(g),Promise.resolve().then(()=>t(s)).then(e=>d(null,e),d)},f=()=>c({type:"homegames-studio-ready"}),g=setTimeout(()=>d(new Error("The game did not arrive. Keep its tab open and try Edit this game again.")),9e4),m=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 n(e){const t=Object.keys(e),n=new Set;let i=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(n.has(t))throw new Error("Export names must differ ignoring capitalization");n.add(t);const a=e[o];if(!(a instanceof Uint8Array)||a.length>s.fileBytes||(i+=a.length)>s.totalBytes)throw new Error("User export size limit exceeded")}}const i=e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e,new Uint8Array(t)]));e.exports={DIRECTORY:t,LIMITS:s,validateName:r,validateFiles:n,createUserExports:function(e={},t=async()=>{}){n(e);let o=i(e),a=Promise.resolve(),h=!1,l=0;const c=new Map;return{userExports:Object.freeze(i(o)),createExport:function(e,i){try{if(h)throw new Error("Game session closed");if(r(e),!(i instanceof Uint8Array))throw new Error("Export data must be Uint8Array bytes");if(i.length>s.fileBytes||l>=128)throw new Error("User export limit exceeded");i=new Uint8Array(i)}catch(e){return Promise.reject(e)}l++;const d=a.then(async()=>{const s={...o,[e]:i};n(s),await t(e,new Uint8Array(i)),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 i(o)},close:()=>(h=!0,a)}},projectExports:function(e){const s=Object.create(null);for(const n of e.reader.listFiles())if(n.startsWith(t+"/")){const t=n.slice(13);r(t),s[t]=e.reader.readFile(n)}return n(s),s}}},5900(e){"use strict";e.exports={recordVideo:function(e,t){const{document:s,navigator:r,MediaRecorder:n,performance:i,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)),i=s.createElement("dialog");i.setAttribute("aria-label","Record video"),i.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",i.append(o,h,l,c,d,u),this.container.appendChild(i);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:i,preview:l,status:c,start:d,cancel:u,chunks:[],size:0};u.onclick=()=>this.fail("Recording cancelled. You can try again."),i.oncancel=e=>{e.preventDefault(),u.onclick()},d.onclick=async()=>{d.disabled=!0;try{if(void 0===n)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")}},i.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=>n.isTypeSupported(e)),s=e.recorder=new n(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=i.now()+1e3*e.duration,o=()=>{e.status.textContent=`RECORDING · ${Math.max(0,Math.ceil((r-i.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",n=new o(t.chunks,{type:r});if(!n.size||n.size>t.maxBytes)throw new Error("Recording was empty or too large. Please try again.");const i=new Uint8Array(await n.arrayBuffer());if(this.active!==t)return;let a="";for(let e=0;e<i.length;e+=8192)a+=String.fromCharCode(...i.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:n}=s(9902),i=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||""),n=s.userAgent??("undefined"==typeof navigator?"":navigator.userAgent||""),h=""===e.mapping&&/\bAndroid\b/i.test(n)&&/\b(?:Chrome|Chromium)\//.test(n)&&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(i).find(e=>c(e,r))||null}function u(e,t=d(e),s={}){if(!e||!1===e.connected||!t)return null;const n={},i={};for(const s of new Set([...Object.values(r),...Object.keys(t.buttons||{})])){const r=e.buttons?.[t.buttons?.[s]],i=l("number"==typeof r?r:r?.value,0,1);n[s]={value:i,pressed:"boolean"==typeof r?.pressed?r.pressed:i>=.5}}for(const r of new Set([...Object.keys(o.sticks),...Object.keys(t.sticks||{})])){const n=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)");i[r]={value:Math.abs(n)<=o?0:Math.sign(n)*(Math.abs(n)-o)/(1-o)}}return{buttons:n,sticks:i}}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,Sticks:n,mapGamepad:u,getGamepadMapping:d,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 n=e?.sticks?.[t];if(n)return{value:n.value,pressed:Math.abs(n.value)>=s};const i=/^(STICK_[12])_(LEFT|RIGHT|UP|DOWN)$/.exec(t);if(i){const[,t,r]=i,n=t+("LEFT"===r||"RIGHT"===r?"_X":"_Y"),o="LEFT"===r||"UP"===r?-1:1,a=Math.max(0,(e?.sticks?.[n]?.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),n=s(1085),i=s(1193),o=s(7635),a=s(6593),h=s(9075),l=s(4255);e.exports={DUALSHOCK_4:r,STADIA:n,XBOX_ONE:i,LUNA:o,DUALSHOCK_5:a,SWITCH_PRO:h,NES_30:l}},251(e,t){t.read=function(e,t,s,r,n){var i,o,a=8*n-r-1,h=(1<<a)-1,l=h>>1,c=-7,d=s?n-1:0,u=s?-1:1,p=e[t+d];for(d+=u,i=p&(1<<-c)-1,p>>=-c,c+=a;c>0;i=256*i+e[t+d],d+=u,c-=8);for(o=i&(1<<-c)-1,i>>=-c,c+=r;c>0;o=256*o+e[t+d],d+=u,c-=8);if(0===i)i=1-l;else{if(i===h)return o?NaN:1/0*(p?-1:1);o+=Math.pow(2,r),i-=l}return(p?-1:1)*o*Math.pow(2,i-r)},t.write=function(e,t,s,r,n,i){var o,a,h,l=8*i-n-1,c=(1<<l)-1,d=c>>1,u=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:i-1,f=r?1:-1,g=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,n),o+=d):(a=t*Math.pow(2,d-1)*Math.pow(2,n),o=0));n>=8;e[s+p]=255&a,p+=f,a/=256,n-=8);for(o=o<<n|a,l+=n;l>0;e[s+p]=255&o,p+=f,o/=256,l-=8);e[s+p-f]|=128*g}},3008(e,t){var s,r,n=function(){var e=function(e,t){var s=e,r=o[t],n=null,i=0,h=null,m=[],y={},v=function(e,t){n=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}(i=4*s+17),w(0,0),w(i-7,0),w(0,i-7),E(),b(),_(e,t),s>=7&&S(e),null==h&&(h=A(s,r,m)),C(h,t)},w=function(e,t){for(var s=-1;s<=7;s+=1)if(!(e+s<=-1||i<=e+s))for(var r=-1;r<=7;r+=1)t+r<=-1||i<=t+r||(n[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<i-8;e+=1)null==n[e][6]&&(n[e][6]=e%2==0);for(var t=8;t<i-8;t+=1)null==n[6][t]&&(n[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 i=e[t],o=e[r];if(null==n[i][o])for(var h=-2;h<=2;h+=1)for(var l=-2;l<=2;l+=1)n[i+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);n[Math.floor(r/3)][r%3+i-8-3]=o}for(r=0;r<18;r+=1)o=!e&&1==(t>>r&1),n[r%3+i-8-3][Math.floor(r/3)]=o},_=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?n[h][8]=l:h<8?n[h+1][8]=l:n[i-15+h][8]=l}for(h=0;h<15;h+=1)l=!e&&1==(o>>h&1),h<8?n[8][i-h-1]=l:h<9?n[8][15-h-1+1]=l:n[8][15-h-1]=l;n[i-8][8]=!e},C=function(e,t){for(var s=-1,r=i-1,o=7,h=0,l=a.getMaskFunction(t),c=i-1;c>0;c-=2)for(6==c&&(c-=1);;){for(var d=0;d<2;d+=1)if(null==n[r][c-d]){var u=!1;h<e.length&&(u=1==(e[h]>>>o&1)),l(r,c-d)&&(u=!u),n[r][c-d]=u,-1==(o-=1)&&(h+=1,o=7)}if((r+=s)<0||i<=r){r-=s,s=-s;break}}},A=function(e,t,s){for(var r=c.getRSBlocks(e,t),n=d(),i=0;i<s.length;i+=1){var o=s[i];n.put(o.getMode(),4),n.put(o.getLength(),a.getLengthInBits(o.getMode(),e)),o.write(n)}var h=0;for(i=0;i<r.length;i+=1)h+=r[i].dataCount;if(n.getLengthInBits()>8*h)throw"code length overflow. ("+n.getLengthInBits()+">"+8*h+")";for(n.getLengthInBits()+4<=8*h&&n.put(0,4);n.getLengthInBits()%8!=0;)n.putBit(!1);for(;!(n.getLengthInBits()>=8*h||(n.put(236,8),n.getLengthInBits()>=8*h));)n.put(17,8);return function(e,t){for(var s=0,r=0,n=0,i=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),n=Math.max(n,d),i[h]=new Array(c);for(var u=0;u<i[h].length;u+=1)i[h][u]=255&e.getBuffer()[u+s];s+=c;var p=a.getErrorCorrectPolynomial(d),f=l(i[h],p.getLength()-1).mod(p);for(o[h]=new Array(p.getLength()-1),u=0;u<o[h].length;u+=1){var g=u+f.getLength()-o[h].length;o[h][u]=g>=0?f.getAt(g):0}}var m=0;for(u=0;u<t.length;u+=1)m+=t[u].totalCount;var y=new Array(m),x=0;for(u=0;u<r;u+=1)for(h=0;h<t.length;h+=1)u<i[h].length&&(y[x]=i[h][u],x+=1);for(u=0;u<n;u+=1)for(h=0;h<t.length;h+=1)u<o[h].length&&(y[x]=o[h][u],x+=1);return y}(n,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=g(e);break;default:throw"mode:"+t}m.push(s),h=null},y.isDark=function(e,t){if(e<0||i<=e||t<0||i<=t)throw e+","+t;return n[e][t]},y.getModuleCount=function(){return i},y.make=function(){if(s<1){for(var e=1;e<40;e++){for(var t=c.getRSBlocks(e,r),n=d(),i=0;i<m.length;i++){var o=m[i];n.put(o.getMode(),4),n.put(o.getLength(),a.getLengthInBits(o.getMode(),e)),o.write(n)}var h=0;for(i=0;i<t.length;i++)h+=t[i].dataCount;if(n.getLengthInBits()<=8*h)break}s=e}v(!1,function(){for(var e=0,t=0,s=0;s<8;s+=1){v(!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 n=0;n<y.getModuleCount();n+=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,n)?"#000000":"#ffffff",s+=";",s+='"/>';s+="</tr>"}return(s+="</tbody>")+"</table>"},y.createSvgTag=function(e,t,s,r){var n={};"object"==typeof arguments[0]&&(e=(n=arguments[0]).cellSize,t=n.margin,s=n.alt,r=n.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 i,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+=n.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="'+k([r.id,s.id].join(" ").trim())+'"':"",c+=">",c+=r.text?'<title id="'+k(r.id)+'">'+k(r.text)+"</title>":"",c+=s.text?'<description id="'+k(s.id)+'">'+k(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,i=0;i<y.getModuleCount();i+=1)y.isDark(o,i)&&(c+="M"+(i*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,n=s-t;return x(s,s,function(t,s){if(r<=t&&t<n&&r<=s&&s<n){var i=Math.floor((t-r)/e),o=Math.floor((s-r)/e);return y.isDark(o,i)?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,n="";return n+="<img",n+=' src="',n+=y.createDataURL(e,t),n+='"',n+=' width="',n+=r,n+='"',n+=' height="',n+=r,n+='"',s&&(n+=' alt="',n+=k(s),n+='"'),n+"/>"};var k=function(e){for(var t="",s=0;s<e.length;s+=1){var r=e.charAt(s);switch(r){case"<":t+="<";break;case">":t+=">";break;case"&":t+="&";break;case'"':t+=""";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,n,i,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),n=Math.floor((t+1-a)/1),s=0;s<o;s+=1)i="█",a<=s&&s<h&&a<=t&&t<h&&y.isDark(r,Math.floor((s-a)/1))&&(i=" "),a<=s&&s<h&&a<=t+1&&t+1<h&&y.isDark(n,Math.floor((s-a)/1))?i+=" ":i+="█",d+=e<1&&t+1>=h?c[i]:l[i];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,n,i,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(n=Math.floor((s-a)/e),u="",r=0;r<o;r+=1)i=1,a<=r&&r<h&&a<=s&&s<h&&y.isDark(n,Math.floor((r-a)/e))&&(i=0),u+=i?l:c;for(n=0;n<e;n+=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 n=0;n<s;n++)e.fillStyle=y.isDark(r,n)?"black":"white",e.fillRect(n*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},n=0,i={};;){var o=s.read();if(-1==o)break;var a=r(),h=r()<<8|r();i[String.fromCharCode(o<<8|a)]=h,n+=1}if(n!=t)throw n+" != "+t;return i}(),r="?".charCodeAt(0);return function(e){for(var t=[],n=0;n<e.length;n+=1){var i=e.charCodeAt(n);if(i<128)t.push(i);else{var o=s[e.charAt(n)];"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,n,i,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,i=function(e){for(var t=0;0!=e;)t+=1,e>>>=1;return t},(n={}).getBCHTypeInfo=function(e){for(var t=e<<10;i(t)-i(s)>=0;)t^=s<<i(t)-i(s);return 21522^(e<<10|t)},n.getBCHTypeNumber=function(e){for(var t=e<<12;i(t)-i(r)>=0;)t^=r<<i(t)-i(r);return e<<12|t},n.getPatternPosition=function(e){return t[e-1]},n.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}},n.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},n.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}}},n.getLostPoint=function(e){for(var t=e.getModuleCount(),s=0,r=0;r<t;r+=1)for(var n=0;n<t;n+=1){for(var i=0,o=e.isDark(r,n),a=-1;a<=1;a+=1)if(!(r+a<0||t<=r+a))for(var h=-1;h<=1;h+=1)n+h<0||t<=n+h||0==a&&0==h||o==e.isDark(r+a,n+h)&&(i+=1);i>5&&(s+=3+i-5)}for(r=0;r<t-1;r+=1)for(n=0;n<t-1;n+=1){var l=0;e.isDark(r,n)&&(l+=1),e.isDark(r+1,n)&&(l+=1),e.isDark(r,n+1)&&(l+=1),e.isDark(r+1,n+1)&&(l+=1),0!=l&&4!=l||(s+=3)}for(r=0;r<t;r+=1)for(n=0;n<t-6;n+=1)e.isDark(r,n)&&!e.isDark(r,n+1)&&e.isDark(r,n+2)&&e.isDark(r,n+3)&&e.isDark(r,n+4)&&!e.isDark(r,n+5)&&e.isDark(r,n+6)&&(s+=40);for(n=0;n<t;n+=1)for(r=0;r<t-6;r+=1)e.isDark(r,n)&&!e.isDark(r+1,n)&&e.isDark(r+2,n)&&e.isDark(r+3,n)&&e.isDark(r+4,n)&&!e.isDark(r+5,n)&&e.isDark(r+6,n)&&(s+=40);var c=0;for(n=0;n<t;n+=1)for(r=0;r<t;r+=1)e.isDark(r,n)&&(c+=1);return s+Math.abs(100*c/t/t-50)/5*10},n),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),n=0;n<e.length-s;n+=1)r[n]=e[n+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 n=0;n<e.getLength();n+=1)t[s+n]^=h.gexp(h.glog(r.getAt(s))+h.glog(e.getAt(n)));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()),n=0;n<r.getLength();n+=1)s[n]=r.getAt(n);for(n=0;n<e.getLength();n+=1)s[n]^=h.gexp(h.glog(e.getAt(n))+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 n=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===n)throw"bad rs block @ typeNumber:"+s+"/errorCorrectionLevel:"+r;for(var i=n.length/3,a=[],h=0;h<i;h+=1)for(var l=n[3*h+0],c=n[3*h+1],d=n[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,n=0;n+2<s.length;)e.put(r(s.substring(n,n+3)),10),n+=3;n<s.length&&(s.length-n==1?e.put(r(s.substring(n,n+1)),4):s.length-n==2&&e.put(r(s.substring(n,n+2)),7))}},r=function(e){for(var t=0,s=0;s<e.length;s+=1)t=10*t+n(e.charAt(s));return t},n=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,n=0;n+1<s.length;)e.put(45*r(s.charAt(n))+r(s.charAt(n+1)),11),n+=2;n<s.length&&e.put(r(s.charAt(n)),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)}}},g=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),n={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 n=(255&t[s])<<8|255&t[s+1];if(33088<=n&&n<=40956)n-=33088;else{if(!(57408<=n&&n<=60351))throw"illegal char at "+(s+1)+"/"+n;n-=49472}n=192*(n>>>8&255)+(255&n),e.put(n,13),s+=2}if(s<t.length)throw"illegal char at "+(s+1)}};return n},m=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 n=0;n<r;n+=1)t.writeByte(e[n+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,n=0,i={read:function(){for(;n<8;){if(s>=t.length){if(0==n)return-1;throw"unexpected end of file./"+n}var e=t.charAt(s);if(s+=1,"="==e)return n=0,-1;e.match(/^\s$/)||(r=r<<6|o(e.charCodeAt(0)),n+=6)}var i=r>>>n-8&255;return n-=8,i}},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 i},x=function(e,t,s){for(var r=function(e,t){var s=e,r=t,n=new Array(e*t),i={setPixel:function(e,t,r){n[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 n=0;t.length-n>255;)e.writeByte(255),e.writeBytes(t,n,255),n+=255;e.writeByte(t.length-n),e.writeBytes(t,n,t.length-n),e.writeByte(0),e.writeString(";")}},o=function(e){for(var t=1<<e,s=1+(1<<e),r=e+1,i=a(),o=0;o<t;o+=1)i.add(String.fromCharCode(o));i.add(String.fromCharCode(t)),i.add(String.fromCharCode(s));var h,l,c,d=m(),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(n[p]);for(p+=1;p<n.length;){var g=String.fromCharCode(n[p]);p+=1,i.contains(f+g)?f+=g:(u.write(i.indexOf(f),r),i.size()<4095&&(i.size()==1<<r&&(r+=1),i.add(f+g)),f=g)}return u.write(i.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 i}(e,t),n=0;n<t;n+=1)for(var i=0;i<e;i+=1)r.setPixel(i,n,s(i,n));var o=m();r.write(o);for(var a=function(){var e=0,t=0,s=0,r="",n={},i=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 n.writeByte=function(r){for(e=e<<8|255&r,t+=8,s+=1;t>=6;)i(e>>>t-6),t-=6},n.flush=function(){if(t>0&&(i(e<<6-t),e=0,t=0),s%3!=0)for(var n=3-s%3,o=0;o<n;o+=1)r+="="},n.toString=function(){return r},n}(),h=o.toByteArray(),l=0;l<h.length;l+=1)a.writeByte(h[l]);return a.flush(),"data:image/gif;base64,"+a};return e}();n.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 n})?s.apply(t,[]):s)||(e.exports=r)},5656(e,t,s){const r=s(9482),n=(e,t,s,n,i,o,a,h,l,c,d,u,p,f)=>new r(e,t,s,n,i,o,a,h,l,c,d,u,p,f);e.exports={gameNode:n,BaseNode:class{constructor({color:e,onClick:t,coordinates2d:s,border:r,fill:i,textInfo:o,assetInfo:a,playerIds:h,effects:l,input:c,subtype:d,node:u,id:p,onHover:f,offHover:g}){this.node=u||n(e,t,s,r,i,o,a,h,l,c,d,p,f,g),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")}}}},961(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,n=Math.floor(Math.random()*r.length);return t[r[n]]}}},9579(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)}}}},847(e,t,s){const r=s(3431),n=s(7910),{gameNode:i,BaseNode:o}=s(5656),a={[r.CIRCLE]:n.SHAPE_2D_CIRCLE,[r.POLYGON]:n.SHAPE_2D_POLYGON,[r.LINE]:n.SHAPE_2D_LINE},h={[n.SHAPE_2D_CIRCLE]:r.CIRCLE,[n.SHAPE_2D_POLYGON]:r.POLYGON,[n.SHAPE_2D_LINE]:r.LINE};class l extends o{constructor({color:e,onClick:t,shapeType:s,coordinates2d:r,border:n,fill:i,playerIds:o,effects:h,input:l,node:c,id:d,onHover:u,offHover:p}){if(!(r&&s||c))throw new Error("Shape requires coordinates2d and shapeType");super({color:e,onClick:t,coordinates2d:r,border:n,fill:i,playerIds:o,effects:h,input:l,node:c,subtype:a[s],id:d,onHover:u,offHover:p})}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:i}){if(!e&&!r)throw new Error("Text node requires textInfo");super({textInfo:e,playerIds:t,input:s,node:r,subtype:n.TEXT,id:i})}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:i,node:o,id:a,onHover:h,offHover:l}){if(!e&&!o)throw new Error("Asset node requires assetInfo");super({assetInfo:e,onClick:t,coordinates2d:s,playerIds:r,effects:i,node:o,subtype:n.ASSET,id:a,onHover:h,offHover:l})}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={Asset:d,Shape:l,Text:c};e.exports={gameNode:i,GameNode:u}},9482(e){e.exports=class{constructor(e,t,s,r,n,i,o,a=[],h=null,l=null,c=null,d=null,u,p){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=n,this.text=i,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}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}}},3431(e){e.exports={CIRCLE:1,POLYGON:2,LINE:3}},7706(e,t,s){const{GameNode:r}=s(847),n=s(3431),i=s(3250),o=s(961),a=s(9579);e.exports=class extends a{constructor(e){var t;super(),this.planeSize=e,this.plane=(t=this.planeSize,new r.Shape({shapeType:n.POLYGON,coordinates2d:i.rectangle(0,0,t,t)})),this.fakeRoot=new r.Shape({shapeType:n.POLYGON,coordinates2d:i.rectangle(0,0,0,0),fill:o.COLORS.BLACK}),this.layers=[{root:this.fakeRoot}]}updatePlaneSize(e){this.planeSize=e,this.plane.node.coordinates2d=i.rectangle(0,0,e,e)}getLayers(){return this.layers}getPlane(){return this.plane}getPlaneSize(){return this.planeSize}getViewRoot(){return this.fakeRoot}}},5725(e,t,s){const{GameNode:r}=s(847);e.exports={CONSTRUCTOR_TO_TYPE:{Asset:1,Shape:2,Text:3},TYPE_TO_CONSTRUCTOR:{1:r.Asset,2:r.Shape,3:r.Text}}},6036(e){e.exports={getPath:(e,t,s,r,n=100,i=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>n||l<0||l>i){let e=h,t=l;h<0?e=0:h>n&&(e=n),l<0?t=0:l>i&&(t=i),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}}},7588(e,t,s){const r=s(9482),{CONSTRUCTOR_TO_TYPE:n,TYPE_TO_CONSTRUCTOR:i}=s(5725),o=s(4747),{squishId:a}=s(5407),{squishColor:h}=s(9967),{squishPlayerIds:l}=s(8885),{squishPos:c}=s(9866),{squishFill:d}=s(3927),{squishSize:u}=s(1523),{squishHandleClick:p}=s(9022),{squishBorder:f}=s(5972),{squishSubType:g}=s(9958),{squishInput:m}=s(7688),{squishCoordinates2d:y}=s(3697),{squishEffect:x}=s(8875),{squishText:v}=s(5353),{squishAsset:w}=s(8048),b={id:a,color:h,playerIds:l,pos:c,coordinates2d:y,fill:d,size:u,text:v,asset:w,effects:x,handleClick:p,border:f,subType:g,input:m},E={};for(const e in b)E[Number(b[e].type)]=e;e.exports={squish:(e,t=null)=>{let s=[];const r=e.node,i=(()=>{const e=Object.keys(b).filter(e=>b[e].dependsOn&&b[e].dependsOn.length>0);return[Object.keys(b).filter(e=>!b[e].dependsOn||0===b[e].dependsOn.length),e].flat()})();for(const e in i){const n=i[e];if(n in r){const e=r[n];if(null!=e){const i=b[n].squish(e,t,r),o=i.length+3,a=Math.min(255,o),h=Math.min(255,Math.max(0,o-255));s.push([b[n].type,h,a,...i])}}}let a=n[e.constructor.name];a||(a=n[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],n=e[t+1]+e[t+2],i=e.slice(t+3,t+n);if(!E[r]){console.warn("Unknown sub frame type "+r);break}{const e=E[r],t=(0,b[e].unsquish)(i,Object.assign({},s));s[e]=t}t+=n}const n=i[e[4]];return n?new n({node:s}):{node:s}}}},8048(e,t,s){const{getFractional:r}=s(3222),n={type:48,squish:(e,t)=>{const s=Object.keys(e)[0],n=new Array(18+s.length),i=e[s],o=t?t.x*i.pos.x+Math.round(100*(1-t.x))/2:i.pos.x,a=t?t.y*i.pos.y+Math.round(100*(1-t.y))/2:i.pos.y,h=t?t.x*i.size.x:i.size.x,l=t?t.y*i.size.y:i.size.y,c=i.startTime||0,d=i.cropLeft||0,u=i.cropTop||0,p=i.cropRight||0,f=i.cropBottom||0;n[0]=Math.floor(o),n[1]=r(o),n[2]=Math.floor(a),n[3]=r(a),n[4]=Math.floor(h),n[5]=r(h),n[6]=Math.floor(l),n[7]=r(l),n[8]=Math.floor(c),n[9]=r(c),n[10]=Math.floor(d),n[11]=r(d),n[12]=Math.floor(u),n[13]=r(u),n[14]=Math.floor(p),n[15]=r(p),n[16]=Math.floor(f),n[17]=r(f);for(let e=0;e<s.length;e++)n[18+e]=s.codePointAt(e);return n},unsquish:e=>{const t=e[0]+e[1]/100,s=e[2]+e[3]/100,r=e[4]+e[5]/100,n=e[6]+e[7]/100,i=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:n},startTime:i,cropLeft:o,cropTop:a,cropRight:h,cropBottom:l}}}};e.exports={ASSET_SUBTYPE:48,squishAsset:n}},5972(e){e.exports={BORDER_SUBTYPE:54,squishBorder:{type:54,squish:e=>[e],unsquish:e=>e[0]}}},9967(e){e.exports={COLOR_SUBTYPE:42,squishColor:{type:42,squish:e=>[e[0],e[1],e[2],e[3]],unsquish:e=>[e[0],e[1],e[2],e[3]]}}},3697(e,t,s){const{getFractional:r}=s(3222),n=s(7910),i=e=>e<0?0:e>255?255:e,o=(e,t)=>e*t+Math.round(100*(1-e))/2,a={type:52,squish:(e,t,s)=>{const a=e.flat(),h=new Array(2*a.length);if(s.subType==n.SHAPE_2D_CIRCLE)if(t){const e=i(o(t.x,a[0]));h[0]=e,h[1]=r(e);const s=i(o(t.y,a[1]));let n;h[2]=s,h[3]=r(s),n=t.x===t.y?t.x*a[2]:Math.sqrt(Math.pow(100*t.x,2)+Math.pow(100*t.y,2))*(a[2]/100),h[4]=Math.floor(n),h[5]=r(n)}else{const e=i(a[0]);h[0]=Math.floor(e),h[1]=r(e);const t=i(a[1]);h[2]=Math.floor(t),h[3]=r(t);const s=a[2];h[4]=Math.round(s),h[5]=r(s)}else for(const e in a)if(t){const s=e%2==0?t.x:t.y,n=s*a[e],o=Math.round(100*(1-s)),l=i(n+o/2);h[2*e]=l,h[2*e+1]=r(l)}else{const t=i(a[e]);h[2*e]=Math.floor(t),h[2*e+1]=Math.round(100*(t-Math.floor(t)))}return h},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===n.SHAPE_2D_POLYGON||t===n.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={COORDINATES_2D_SUBTYPE:52,squishCoordinates2d:a}},8875(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 n={[t]:{color:s}};return r&&(n[t].blur=r),n}};e.exports={EFFECTS_SUBTYPE:49,squishEffect:t}},3927(e){e.exports={FILL_SUBTYPE:53,squishFill:{type:53,squish:e=>[e[0],e[1],e[2],e[3]],unsquish:e=>[e[0],e[1],e[2],e[3]]}}},9022(e){e.exports={ONCLICK_SUBTYPE:50,squishHandleClick:{type:50,squish:e=>e?[1]:[0],unsquish:e=>1===e[0]}}},5407(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={ID_SUBTYPE:43,squishId:t}},7688(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={INPUT_SUBTYPE:51,squishInput:t}},8885(e){e.exports={PLAYER_ID_SUBTYPE:44,squishPlayerIds:{type:44,squish:e=>e,unsquish:e=>e}}},9866(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={POS_SUBTYPE:45,squishPos:s}},1523(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={SIZE_SUBTYPE:46,squishSize:s}},9958(e){e.exports={SUBTYPE_TYPE:55,squishSubType:{type:55,squish:e=>[e],unsquish:e=>e[0]}}},5353(e,t,s){const{hypLength:r}=s(3222),n=s(961),{squishColor:i}=s(9967),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||n.BLACK,p=i.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 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+p.length+2+3*[...a].length;l[r+g]=Number(s[0]),l[r+g+1]=Number(s[1]),l[r+g+2]=Number(s[2]),g+=3}let m=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 n=6+p.length+2+3*[...a].length+3*[...h].length;l[n+m]=Number(r[0]),l[n+m+1]=Number(r[1]),l[n+m+2]=Number(r[2]),m+=3}return l},unsquish:e=>{const t=e[0]+e[1]/100,s=e[2]+e[3]/100,r=e[4]+e[5]/100,n=e.slice(6,10),i=e[10],o=e[11],a=e.slice(12,12+i),h=e.slice(12+i,12+i+o),l=e.slice(12+i+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 n=t+s+r;c.push(n)}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 n=t+s+r;u.push(n)}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 n=t+s+r;f.push(n)}return{x:t,y:s,text:String.fromCodePoint.apply(null,f),size:r,color:n,align:d,font:p}}};e.exports={TEXT_SUBTYPE:47,squishText:o}},4747(e,t,s){const{GameNode:r}=s(847),n=s(7910);e.exports={[[n.ASSET]]:r.Asset,[[n.TEXT]]:r.Text,[[n.SHAPE_2D_POLYGON]]:r.Shape,[[n.SHAPE_2D_CIRCLE]]:r.Shape,[[n.SHAPE_2D_LINE]]:r.Shape}},7910(e){e.exports={ASSET:1,TEXT:2,SHAPE_2D_POLYGON:3,SHAPE_2D_CIRCLE:4,SHAPE_2D_LINE:5}},4123(e,t,s){const{getRandomTerrain:r,getRandomStartPoint:n}=s(229),i=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,n(a,h,t),a,h,t);const d=((e,t,s,r)=>{const n=[];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(n.findIndex(e=>e.x===a.x&&e.y===a.y)>-1||a.x===t.x&&a.y===t.y||s.filled){n.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}}i(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:n}=((e,t)=>{const s=e.x,r=e.y,n=t.x,i=t.y;return{width:Math.floor(s/n),height:Math.floor(r/i)}})(e,t);let i=((e,t)=>{const s=[],r={filled:!1,north:!0,south:!0,east:!0,west:!0};for(let n=0;n<e;n++){s[n]=[];for(let i=0;i<t;i++){const o={...r};0===n?o.west=!1:n===e-1&&(o.east=!1),0===i?o.north=!1:i===t-1&&(o.south=!1),s[n].push(o)}}return s})(r,n);const a={x:Math.floor(Math.random()*r),y:Math.floor(Math.random()*n)};return i=o(i,a,s,r,n),i}}},229(e){const t=(e,{x:t,y:s},r,n,i)=>{t<0||t>=r||s<0||s>=n||t===i.x&&s===i.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},n,i,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},n,i,o),0===a?(t(e,{x:s+1,y:r},n,i,o),t(e,{x:s,y:r+1},n,i,o),t(e,{x:s+1,y:r+1},n,i,o)):1===a?(t(e,{x:s-1,y:r},n,i,o),t(e,{x:s,y:r+1},n,i,o),t(e,{x:s-1,y:r+1},n,i,o)):2===a?(t(e,{x:s,y:r-1},n,i,o),t(e,{x:s+1,y:r},n,i,o),t(e,{x:s+1,y:r-1},n,i,o)):(t(e,{x:s,y:r-1},n,i,o),t(e,{x:s-1,y:r},n,i,o),t(e,{x:s-1,y:r-1},n,i,o))},(e,{x:s,y:r},n,i,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},n,i,o),0===a?(t(e,{x:s,y:r+1},n,i,o),t(e,{x:s,y:r+2},n,i,o),t(e,{x:s,y:r+3},n,i,o)):1===a?(t(e,{x:s+1,y:r},n,i,o),t(e,{x:s+2,y:r},n,i,o),t(e,{x:s+3,y:r},n,i,o)):2===a?(t(e,{x:s-1,y:r},n,i,o),t(e,{x:s-2,y:r},n,i,o),t(e,{x:s-3,y:r},n,i,o)):(t(e,{x:s,y:r-1},n,i,o),t(e,{x:s,y:r-2},n,i,o),t(e,{x:s,y:r-3},n,i,o))},(e,{x:s,y:r},n,i,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},n,i,o),0===a?(t(e,{x:s,y:r+1},n,i,o),t(e,{x:s,y:r+2},n,i,o),t(e,{x:s+1,y:r+2},n,i,o)):1===a?(t(e,{x:s+1,y:r},n,i,o),t(e,{x:s+2,y:r},n,i,o),t(e,{x:s+2,y:r-1},n,i,o)):2===a?(t(e,{x:s-1,y:r},n,i,o),t(e,{x:s-2,y:r},n,i,o),t(e,{x:s-2,y:r+1},n,i,o)):(t(e,{x:s,y:r-1},n,i,o),t(e,{x:s,y:r-2},n,i,o),t(e,{x:s-1,y:r-2},n,i,o))},(e,{x:s,y:r},n,i,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},n,i,o),0===a?(t(e,{x:s,y:r+1},n,i,o),t(e,{x:s-1,y:r+1},n,i,o),t(e,{x:s-1,y:r+2},n,i,o)):1===a?(t(e,{x:s+1,y:r},n,i,o),t(e,{x:s+1,y:r+1},n,i,o),t(e,{x:s+2,y:r+1},n,i,o)):2===a?(t(e,{x:s-1,y:r},n,i,o),t(e,{x:s-1,y:r+1},n,i,o),t(e,{x:s-2,y:r+1},n,i,o)):(t(e,{x:s,y:r-1},n,i,o),t(e,{x:s-1,y:r-1},n,i,o),t(e,{x:s-1,y:r-2},n,i,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}}},836(e){const t=(e,s,r,n=[])=>{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]],i=s.node.coordinates2d,o=r[0][0],a=r[1][0],h=i[0][0],l=i[1][0],c=r[0][1],d=r[2][1],u=i[0][1],p=i[2][1];l<o||a<h||c>p||u>d||n.push(e)}for(const i in e.node.children)t(e.node.children[i],s,r,n);return n};e.exports={checkCollisions:(e,s,r=null)=>t(e,s,r)}},3222(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)))}},3250(e){e.exports={triangle:(e,t,s,r,n,i)=>[[e,t],[s,r],[n,i],[e,t]],rectangle:(e,t,s,r)=>[[e,t],[e+s,t],[e+s,t+r],[e,t+r],[e,t]]}},6560(e,t,s){const{GameNode:r}=s(847),n=s(3431),i=s(3250),o=s(836),a=s(961);e.exports={getView:(e,t,s,h={},l={})=>{const c=o.checkCollisions(e,{node:{coordinates2d:i.rectangle(t.x,t.y,t.w,t.h)}},t=>t.node.id!==e.node.id),d=new r.Shape({shapeType:n.POLYGON,coordinates2d:i.rectangle(0,0,0,0),fill:a.COLORS.BLACK}),u=[];return c.length>0&&c.forEach(e=>{const r=[],n=[],i=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 i){const o=i[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),g=(l.y||1)*(c-t.y);p&&(h.x&&(f+=h.x),h.y&&(g+=h.y)),n.push([f,g])}{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],i=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=i,a.size.y=o;const h=n[0],l=n[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}}},4789(e,t,s){const r=s(4419),n=(e,t,s,n,i,o,a,h,l,c,d,u,p,f)=>new r(e,t,s,n,i,o,a,h,l,c,d,u,p,f);e.exports={gameNode:n,BaseNode:class{constructor({color:e,onClick:t,coordinates2d:s,border:r,fill:i,textInfo:o,assetInfo:a,playerIds:h,effects:l,input:c,subtype:d,node:u,id:p,onHover:f,offHover:g}){this.node=u||n(e,t,s,r,i,o,a,h,l,c,d,p,f,g),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")}}}},3872(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,n=Math.floor(Math.random()*r.length);return t[r[n]]}}},2706(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)}}}},9930(e,t,s){const r=s(9990),n=s(675),{gameNode:i,BaseNode:o}=s(4789),a={[r.CIRCLE]:n.SHAPE_2D_CIRCLE,[r.POLYGON]:n.SHAPE_2D_POLYGON,[r.LINE]:n.SHAPE_2D_LINE},h={[n.SHAPE_2D_CIRCLE]:r.CIRCLE,[n.SHAPE_2D_POLYGON]:r.POLYGON,[n.SHAPE_2D_LINE]:r.LINE};class l extends o{constructor({color:e,onClick:t,shapeType:s,coordinates2d:r,border:n,fill:i,playerIds:o,effects:h,input:l,node:c,id:d,onHover:u,offHover:p}){if(!(r&&s||c))throw new Error("Shape requires coordinates2d and shapeType");super({color:e,onClick:t,coordinates2d:r,border:n,fill:i,playerIds:o,effects:h,input:l,node:c,subtype:a[s],id:d,onHover:u,offHover:p})}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:i}){if(!e&&!r)throw new Error("Text node requires textInfo");super({textInfo:e,playerIds:t,input:s,node:r,subtype:n.TEXT,id:i})}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:i,node:o,id:a,onHover:h,offHover:l}){if(!e&&!o)throw new Error("Asset node requires assetInfo");super({assetInfo:e,onClick:t,coordinates2d:s,playerIds:r,effects:i,node:o,subtype:n.ASSET,id:a,onHover:h,offHover:l})}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={Asset:d,Shape:l,Text:c};e.exports={gameNode:i,GameNode:u}},4419(e){e.exports=class{constructor(e,t,s,r,n,i,o,a=[],h=null,l=null,c=null,d=null,u,p){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=n,this.text=i,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}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}}},9990(e){e.exports={CIRCLE:1,POLYGON:2,LINE:3}},711(e,t,s){const{GameNode:r}=s(9930),n=s(9990),i=s(3485),o=s(3872),a=s(2706);e.exports=class extends a{constructor(e){var t;super(),this.planeSize=e,this.plane=(t=this.planeSize,new r.Shape({shapeType:n.POLYGON,coordinates2d:i.rectangle(0,0,t,t)})),this.fakeRoot=new r.Shape({shapeType:n.POLYGON,coordinates2d:i.rectangle(0,0,0,0),fill:o.COLORS.BLACK}),this.layers=[{root:this.fakeRoot}]}updatePlaneSize(e){this.planeSize=e,this.plane.node.coordinates2d=i.rectangle(0,0,e,e)}getLayers(){return this.layers}getPlane(){return this.plane}getPlaneSize(){return this.planeSize}getViewRoot(){return this.fakeRoot}}},1416(e,t,s){const{GameNode:r}=s(9930);e.exports={CONSTRUCTOR_TO_TYPE:{Asset:1,Shape:2,Text:3},TYPE_TO_CONSTRUCTOR:{1:r.Asset,2:r.Shape,3:r.Text}}},9807(e){e.exports={getPath:(e,t,s,r,n=100,i=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>n||l<0||l>i){let e=h,t=l;h<0?e=0:h>n&&(e=n),l<0?t=0:l>i&&(t=i),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}}},3317(e,t,s){const r=s(4419),{CONSTRUCTOR_TO_TYPE:n,TYPE_TO_CONSTRUCTOR:i}=s(1416),o=s(8018),{squishId:a}=s(6342),{squishColor:h}=s(7844),{squishPlayerIds:l}=s(754),{squishPos:c}=s(6589),{squishFill:d}=s(4562),{squishSize:u}=s(9378),{squishHandleClick:p}=s(4817),{squishBorder:f}=s(9537),{squishSubType:g}=s(3557),{squishInput:m}=s(9627),{squishCoordinates2d:y}=s(2882),{squishEffect:x}=s(7266),{squishText:v}=s(8364),{squishAsset:w}=s(2887),b={id:a,color:h,playerIds:l,pos:c,coordinates2d:y,fill:d,size:u,text:v,asset:w,effects:x,handleClick:p,border:f,subType:g,input:m},E={};for(const e in b)E[Number(b[e].type)]=e;e.exports={squish:(e,t=null)=>{let s=[];const r=e.node,i=(()=>{const e=Object.keys(b).filter(e=>b[e].dependsOn&&b[e].dependsOn.length>0);return[Object.keys(b).filter(e=>!b[e].dependsOn||0===b[e].dependsOn.length),e].flat()})();for(const e in i){const n=i[e];if(n in r){const e=r[n];if(null!=e){const i=b[n].squish(e,t,r),o=i.length+3,a=Math.min(255,o),h=Math.min(255,Math.max(0,o-255));s.push([b[n].type,h,a,...i])}}}let a=n[e.constructor.name];a||(a=n[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],n=e[t+1]+e[t+2],i=e.slice(t+3,t+n);if(!E[r]){console.warn("Unknown sub frame type "+r);break}{const e=E[r],t=(0,b[e].unsquish)(i,Object.assign({},s));s[e]=t}t+=n}const n=i[e[4]];return n?new n({node:s}):{node:s}}}},2887(e,t,s){const{getFractional:r}=s(5491),n={type:48,squish:(e,t)=>{const s=Object.keys(e)[0],n=new Array(18+s.length),i=e[s],o=t?t.x*i.pos.x+Math.round(100*(1-t.x))/2:i.pos.x,a=t?t.y*i.pos.y+Math.round(100*(1-t.y))/2:i.pos.y,h=t?t.x*i.size.x:i.size.x,l=t?t.y*i.size.y:i.size.y,c=i.startTime||0,d=i.cropLeft||0,u=i.cropTop||0,p=i.cropRight||0,f=i.cropBottom||0;n[0]=Math.floor(o),n[1]=r(o),n[2]=Math.floor(a),n[3]=r(a),n[4]=Math.floor(h),n[5]=r(h),n[6]=Math.floor(l),n[7]=r(l),n[8]=Math.floor(c),n[9]=r(c),n[10]=Math.floor(d),n[11]=r(d),n[12]=Math.floor(u),n[13]=r(u),n[14]=Math.floor(p),n[15]=r(p),n[16]=Math.floor(f),n[17]=r(f);for(let e=0;e<s.length;e++)n[18+e]=s.codePointAt(e);return n},unsquish:e=>{const t=e[0]+e[1]/100,s=e[2]+e[3]/100,r=e[4]+e[5]/100,n=e[6]+e[7]/100,i=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:n},startTime:i,cropLeft:o,cropTop:a,cropRight:h,cropBottom:l}}}};e.exports={ASSET_SUBTYPE:48,squishAsset:n}},9537(e){e.exports={BORDER_SUBTYPE:54,squishBorder:{type:54,squish:e=>[e],unsquish:e=>e[0]}}},7844(e){e.exports={COLOR_SUBTYPE:42,squishColor:{type:42,squish:e=>[e[0],e[1],e[2],e[3]],unsquish:e=>[e[0],e[1],e[2],e[3]]}}},2882(e,t,s){const{getFractional:r}=s(5491),n=s(675),i=e=>e<0?0:e>255?255:e,o=(e,t)=>e*t+Math.round(100*(1-e))/2,a={type:52,squish:(e,t,s)=>{const a=e.flat(),h=new Array(2*a.length);if(s.subType==n.SHAPE_2D_CIRCLE)if(t){const e=i(o(t.x,a[0]));h[0]=Math.floor(e),h[1]=r(e);const s=i(o(t.y,a[1]));let n;h[2]=Math.floor(s),h[3]=r(s),n=t.x===t.y?t.x*a[2]:Math.sqrt(Math.pow(100*t.x,2)+Math.pow(100*t.y,2))*(a[2]/100),h[4]=Math.floor(n),h[5]=r(n)}else{const e=i(a[0]);h[0]=Math.floor(e),h[1]=r(e);const t=i(a[1]);h[2]=Math.floor(t),h[3]=r(t);const s=a[2];h[4]=Math.round(s),h[5]=r(s)}else for(const e in a)if(t){const s=e%2==0?t.x:t.y,n=s*a[e],o=Math.round(100*(1-s)),l=i(n+o/2);h[2*e]=Math.floor(l),h[2*e+1]=r(l)}else{const t=i(a[e]);h[2*e]=Math.floor(t),h[2*e+1]=Math.round(100*(t-Math.floor(t)))}return h},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===n.SHAPE_2D_POLYGON||t===n.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={COORDINATES_2D_SUBTYPE:52,squishCoordinates2d:a}},7266(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 n={[t]:{color:s}};return r&&(n[t].blur=r),n}};e.exports={EFFECTS_SUBTYPE:49,squishEffect:t}},4562(e){e.exports={FILL_SUBTYPE:53,squishFill:{type:53,squish:e=>[e[0],e[1],e[2],e[3]],unsquish:e=>[e[0],e[1],e[2],e[3]]}}},4817(e){e.exports={ONCLICK_SUBTYPE:50,squishHandleClick:{type:50,squish:e=>e?[1]:[0],unsquish:e=>1===e[0]}}},6342(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={ID_SUBTYPE:43,squishId:t}},9627(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={INPUT_SUBTYPE:51,squishInput:t}},754(e){e.exports={PLAYER_ID_SUBTYPE:44,squishPlayerIds:{type:44,squish:e=>e,unsquish:e=>e}}},6589(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={POS_SUBTYPE:45,squishPos:s}},9378(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={SIZE_SUBTYPE:46,squishSize:s}},3557(e){e.exports={SUBTYPE_TYPE:55,squishSubType:{type:55,squish:e=>[e],unsquish:e=>e[0]}}},8364(e,t,s){const{hypLength:r}=s(5491),n=s(3872),{squishColor:i}=s(7844),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||n.BLACK,p=i.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 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+p.length+2+3*[...a].length;l[r+g]=Number(s[0]),l[r+g+1]=Number(s[1]),l[r+g+2]=Number(s[2]),g+=3}let m=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 n=6+p.length+2+3*[...a].length+3*[...h].length;l[n+m]=Number(r[0]),l[n+m+1]=Number(r[1]),l[n+m+2]=Number(r[2]),m+=3}return l},unsquish:e=>{const t=e[0]+e[1]/100,s=e[2]+e[3]/100,r=e[4]+e[5]/100,n=e.slice(6,10),i=e[10],o=e[11],a=e.slice(12,12+i),h=e.slice(12+i,12+i+o),l=e.slice(12+i+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 n=t+s+r;c.push(n)}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 n=t+s+r;u.push(n)}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 n=t+s+r;f.push(n)}return{x:t,y:s,text:String.fromCodePoint.apply(null,f),size:r,color:n,align:d,font:p}}};e.exports={TEXT_SUBTYPE:47,squishText:o}},8018(e,t,s){const{GameNode:r}=s(9930),n=s(675);e.exports={[[n.ASSET]]:r.Asset,[[n.TEXT]]:r.Text,[[n.SHAPE_2D_POLYGON]]:r.Shape,[[n.SHAPE_2D_CIRCLE]]:r.Shape,[[n.SHAPE_2D_LINE]]:r.Shape}},675(e){e.exports={ASSET:1,TEXT:2,SHAPE_2D_POLYGON:3,SHAPE_2D_CIRCLE:4,SHAPE_2D_LINE:5}},7004(e,t,s){const{getRandomTerrain:r,getRandomStartPoint:n}=s(5988),i=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,n(a,h,t),a,h,t);const d=((e,t,s,r)=>{const n=[];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(n.findIndex(e=>e.x===a.x&&e.y===a.y)>-1||a.x===t.x&&a.y===t.y||s.filled){n.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}}i(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:n}=((e,t)=>{const s=e.x,r=e.y,n=t.x,i=t.y;return{width:Math.floor(s/n),height:Math.floor(r/i)}})(e,t);let i=((e,t)=>{const s=[],r={filled:!1,north:!0,south:!0,east:!0,west:!0};for(let n=0;n<e;n++){s[n]=[];for(let i=0;i<t;i++){const o={...r};0===n?o.west=!1:n===e-1&&(o.east=!1),0===i?o.north=!1:i===t-1&&(o.south=!1),s[n].push(o)}}return s})(r,n);const a={x:Math.floor(Math.random()*r),y:Math.floor(Math.random()*n)};return i=o(i,a,s,r,n),i}}},5988(e){const t=(e,{x:t,y:s},r,n,i)=>{t<0||t>=r||s<0||s>=n||t===i.x&&s===i.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},n,i,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},n,i,o),0===a?(t(e,{x:s+1,y:r},n,i,o),t(e,{x:s,y:r+1},n,i,o),t(e,{x:s+1,y:r+1},n,i,o)):1===a?(t(e,{x:s-1,y:r},n,i,o),t(e,{x:s,y:r+1},n,i,o),t(e,{x:s-1,y:r+1},n,i,o)):2===a?(t(e,{x:s,y:r-1},n,i,o),t(e,{x:s+1,y:r},n,i,o),t(e,{x:s+1,y:r-1},n,i,o)):(t(e,{x:s,y:r-1},n,i,o),t(e,{x:s-1,y:r},n,i,o),t(e,{x:s-1,y:r-1},n,i,o))},(e,{x:s,y:r},n,i,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},n,i,o),0===a?(t(e,{x:s,y:r+1},n,i,o),t(e,{x:s,y:r+2},n,i,o),t(e,{x:s,y:r+3},n,i,o)):1===a?(t(e,{x:s+1,y:r},n,i,o),t(e,{x:s+2,y:r},n,i,o),t(e,{x:s+3,y:r},n,i,o)):2===a?(t(e,{x:s-1,y:r},n,i,o),t(e,{x:s-2,y:r},n,i,o),t(e,{x:s-3,y:r},n,i,o)):(t(e,{x:s,y:r-1},n,i,o),t(e,{x:s,y:r-2},n,i,o),t(e,{x:s,y:r-3},n,i,o))},(e,{x:s,y:r},n,i,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},n,i,o),0===a?(t(e,{x:s,y:r+1},n,i,o),t(e,{x:s,y:r+2},n,i,o),t(e,{x:s+1,y:r+2},n,i,o)):1===a?(t(e,{x:s+1,y:r},n,i,o),t(e,{x:s+2,y:r},n,i,o),t(e,{x:s+2,y:r-1},n,i,o)):2===a?(t(e,{x:s-1,y:r},n,i,o),t(e,{x:s-2,y:r},n,i,o),t(e,{x:s-2,y:r+1},n,i,o)):(t(e,{x:s,y:r-1},n,i,o),t(e,{x:s,y:r-2},n,i,o),t(e,{x:s-1,y:r-2},n,i,o))},(e,{x:s,y:r},n,i,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},n,i,o),0===a?(t(e,{x:s,y:r+1},n,i,o),t(e,{x:s-1,y:r+1},n,i,o),t(e,{x:s-1,y:r+2},n,i,o)):1===a?(t(e,{x:s+1,y:r},n,i,o),t(e,{x:s+1,y:r+1},n,i,o),t(e,{x:s+2,y:r+1},n,i,o)):2===a?(t(e,{x:s-1,y:r},n,i,o),t(e,{x:s-1,y:r+1},n,i,o),t(e,{x:s-2,y:r+1},n,i,o)):(t(e,{x:s,y:r-1},n,i,o),t(e,{x:s-1,y:r-1},n,i,o),t(e,{x:s-1,y:r-2},n,i,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}}},799(e){const t=(e,s,r,n=[])=>{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]],i=s.node.coordinates2d,o=r[0][0],a=r[1][0],h=i[0][0],l=i[1][0],c=r[0][1],d=r[2][1],u=i[0][1],p=i[2][1];l<o||a<h||c>p||u>d||n.push(e)}for(const i in e.node.children)t(e.node.children[i],s,r,n);return n};e.exports={checkCollisions:(e,s,r=null)=>t(e,s,r)}},5491(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)))}},3485(e){e.exports={triangle:(e,t,s,r,n,i)=>[[e,t],[s,r],[n,i],[e,t]],rectangle:(e,t,s,r)=>[[e,t],[e+s,t],[e+s,t+r],[e,t+r],[e,t]]}},177(e,t,s){const{GameNode:r}=s(9930),n=s(9990),i=s(3485),o=s(799),a=s(3872);e.exports={getView:(e,t,s,h={},l={})=>{const c=o.checkCollisions(e,{node:{coordinates2d:i.rectangle(t.x,t.y,t.w,t.h)}},t=>t.node.id!==e.node.id),d=new r.Shape({shapeType:n.POLYGON,coordinates2d:i.rectangle(0,0,0,0),fill:a.COLORS.BLACK}),u=[];return c.length>0&&c.forEach(e=>{const r=[],n=[],i=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 i){const o=i[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),g=(l.y||1)*(c-t.y);p&&(h.x&&(f+=h.x),h.y&&(g+=h.y)),n.push([f,g])}{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],i=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=i,a.size.y=o;const h=n[0],l=n[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}}},1563(e,t,s){const r=s(7457),n=(e,t,s,n,i,o,a,h,l,c,d,u,p,f,g,m)=>new r(e,t,s,n,i,o,a,h,l,c,d,u,p,f,g,m);e.exports={gameNode:n,BaseNode:class{constructor({color:e,onClick:t,coordinates2d:s,border:r,fill:i,textInfo:o,assetInfo:a,playerIds:h,effects:l,input:c,subtype:d,node:u,id:p,onHover:f,offHover:g,onDrag:m,offClick:y}){this.node=u||n(e,t,s,r,i,o,a,h,l,c,d,p,f,g,m,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")}}}},3002(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,n=Math.floor(Math.random()*r.length);return t[r[n]]}}},2212(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)}}}},6308(e,t,s){const r=s(2316),n=s(6541),{gameNode:i,BaseNode:o}=s(1563),a={[r.CIRCLE]:n.SHAPE_2D_CIRCLE,[r.POLYGON]:n.SHAPE_2D_POLYGON,[r.LINE]:n.SHAPE_2D_LINE},h={[n.SHAPE_2D_CIRCLE]:r.CIRCLE,[n.SHAPE_2D_POLYGON]:r.POLYGON,[n.SHAPE_2D_LINE]:r.LINE};class l extends o{constructor({color:e,onClick:t,shapeType:s,coordinates2d:r,border:n,fill:i,playerIds:o,effects:h,input:l,node:c,id:d,onHover:u,offHover:p,onDrag:f,offClick:g}){if(!(r&&s||c))throw new Error("Shape requires coordinates2d and shapeType");super({color:e,onClick:t,coordinates2d:r,border:n,fill:i,playerIds:o,effects:h,input:l,node:c,subtype:a[s],id:d,onHover:u,offHover:p,onDrag:f,offClick:g})}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:i,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:n.TEXT,id:i,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:i,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:i,node:o,subtype:n.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={Asset:d,Shape:l,Text:c};e.exports={gameNode:i,GameNode:u}},7457(e){e.exports=class{constructor(e,t,s,r,n,i,o,a=[],h=null,l=null,c=null,d=null,u,p,f,g){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=n,this.text=i,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=g}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}}},2316(e){e.exports={CIRCLE:1,POLYGON:2,LINE:3}},6525(e,t,s){const{GameNode:r}=s(6308),n=s(2316),i=s(7043),o=s(3002),a=s(2212);e.exports=class extends a{constructor(e){var t;super(),this.planeSize=e,this.plane=(t=this.planeSize,new r.Shape({shapeType:n.POLYGON,coordinates2d:i.rectangle(0,0,t,t)})),this.fakeRoot=new r.Shape({shapeType:n.POLYGON,coordinates2d:i.rectangle(0,0,0,0),fill:o.COLORS.BLACK}),this.layers=[{root:this.fakeRoot}]}updatePlaneSize(e){this.planeSize=e,this.plane.node.coordinates2d=i.rectangle(0,0,e,e)}getLayers(){return this.layers}getPlane(){return this.plane}getPlaneSize(){return this.planeSize}getViewRoot(){return this.fakeRoot}}},2330(e,t,s){const{GameNode:r}=s(6308);e.exports={CONSTRUCTOR_TO_TYPE:{Asset:1,Shape:2,Text:3},TYPE_TO_CONSTRUCTOR:{1:r.Asset,2:r.Shape,3:r.Text}}},6021(e){e.exports={getPath:(e,t,s,r,n=100,i=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>n||l<0||l>i){let e=h,t=l;h<0?e=0:h>n&&(e=n),l<0?t=0:l>i&&(t=i),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}}},4003(e,t,s){const r=s(7457),{CONSTRUCTOR_TO_TYPE:n,TYPE_TO_CONSTRUCTOR:i}=s(2330),o=s(260),{squishId:a}=s(3280),{squishColor:h}=s(3114),{squishPlayerIds:l}=s(7536),{squishPos:c}=s(4267),{squishFill:d}=s(1968),{squishSize:u}=s(9124),{squishHandleClick:p}=s(3855),{squishOnHover:f}=s(2052),{squishBorder:g}=s(2459),{squishSubType:m}=s(923),{squishInput:y}=s(8517),{squishCoordinates2d:x}=s(2684),{squishEffect:v}=s(5808),{squishText:w}=s(3718),{squishAsset:b}=s(949),E={id:a,color:h,playerIds:l,pos:c,coordinates2d:x,fill:d,size:u,text:w,asset:b,effects:v,handleClick:p,onHover:f,border:g,subType:m,input:y},S={};for(const e in E)S[Number(E[e].type)]=e;e.exports={squish:(e,t=null)=>{let s=[];const r=e.node,i=(()=>{const e=Object.keys(E).filter(e=>E[e].dependsOn&&E[e].dependsOn.length>0);return[Object.keys(E).filter(e=>!E[e].dependsOn||0===E[e].dependsOn.length),e].flat()})();for(const e in i){const n=i[e];if(n in r){const e=r[n];if(null!=e){const i=E[n].squish(e,t,r),o=i.length+3,a=Math.min(255,o),h=Math.min(255,Math.max(0,o-255));s.push([E[n].type,h,a,...i])}}}let a=n[e.constructor.name];a||(a=n[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],n=e[t+1]+e[t+2],i=e.slice(t+3,t+n);if(!S[r]){console.warn("Unknown sub frame type "+r);break}{const e=S[r],t=(0,E[e].unsquish)(i,Object.assign({},s));s[e]=t}t+=n}const n=i[e[4]];return n?new n({node:s}):{node:s}}}},949(e,t,s){const{getFractional:r}=s(5841),n={type:48,squish:(e,t)=>{const s=Object.keys(e)[0],n=new Array(18+s.length),i=e[s],o=t?t.x*i.pos.x+Math.round(100*(1-t.x))/2:i.pos.x,a=t?t.y*i.pos.y+Math.round(100*(1-t.y))/2:i.pos.y,h=t?t.x*i.size.x:i.size.x,l=t?t.y*i.size.y:i.size.y,c=i.startTime||0,d=i.cropLeft||0,u=i.cropTop||0,p=i.cropRight||0,f=i.cropBottom||0;n[0]=Math.floor(o),n[1]=r(o),n[2]=Math.floor(a),n[3]=r(a),n[4]=Math.floor(h),n[5]=r(h),n[6]=Math.floor(l),n[7]=r(l),n[8]=Math.floor(c),n[9]=r(c),n[10]=Math.floor(d),n[11]=r(d),n[12]=Math.floor(u),n[13]=r(u),n[14]=Math.floor(p),n[15]=r(p),n[16]=Math.floor(f),n[17]=r(f);for(let e=0;e<s.length;e++)n[18+e]=s.codePointAt(e);return n},unsquish:e=>{const t=e[0]+e[1]/100,s=e[2]+e[3]/100,r=e[4]+e[5]/100,n=e[6]+e[7]/100,i=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:n},startTime:i,cropLeft:o,cropTop:a,cropRight:h,cropBottom:l}}}};e.exports={ASSET_SUBTYPE:48,squishAsset:n}},2459(e){e.exports={BORDER_SUBTYPE:54,squishBorder:{type:54,squish:e=>[e],unsquish:e=>e[0]}}},3114(e){e.exports={COLOR_SUBTYPE:42,squishColor:{type:42,squish:e=>[e[0],e[1],e[2],e[3]],unsquish:e=>[e[0],e[1],e[2],e[3]]}}},2684(e,t,s){const{getFractional:r}=s(5841),n=s(6541),i=e=>e<0?0:e>255?255:e,o=(e,t)=>e*t+Math.round(100*(1-e))/2,a={type:52,squish:(e,t,s)=>{const a=e.flat(),h=new Array(2*a.length);if(s.subType==n.SHAPE_2D_CIRCLE)if(t){const e=i(o(t.x,a[0]));h[0]=Math.floor(e),h[1]=r(e);const s=i(o(t.y,a[1]));let n;h[2]=Math.floor(s),h[3]=r(s),n=t.x===t.y?t.x*a[2]:Math.sqrt(Math.pow(100*t.x,2)+Math.pow(100*t.y,2))*(a[2]/100),h[4]=Math.floor(n),h[5]=r(n)}else{const e=i(a[0]);h[0]=Math.floor(e),h[1]=r(e);const t=i(a[1]);h[2]=Math.floor(t),h[3]=r(t);const s=a[2];h[4]=Math.round(s),h[5]=r(s)}else for(const e in a)if(t){const s=e%2==0?t.x:t.y,n=s*a[e],o=Math.round(100*(1-s)),l=i(n+o/2);h[2*e]=Math.floor(l),h[2*e+1]=r(l)}else{const t=i(a[e]);h[2*e]=Math.floor(t),h[2*e+1]=Math.round(100*(t-Math.floor(t)))}return h},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===n.SHAPE_2D_POLYGON||t===n.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={COORDINATES_2D_SUBTYPE:52,squishCoordinates2d:a}},5808(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 n={[t]:{color:s}};return r&&(n[t].blur=r),n}};e.exports={EFFECTS_SUBTYPE:49,squishEffect:t}},1968(e){e.exports={FILL_SUBTYPE:53,squishFill:{type:53,squish:e=>[e[0],e[1],e[2],e[3]],unsquish:e=>[e[0],e[1],e[2],e[3]]}}},3855(e){e.exports={ONCLICK_SUBTYPE:50,squishHandleClick:{type:50,squish:e=>e?[1]:[0],unsquish:e=>1===e[0]}}},3280(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={ID_SUBTYPE:43,squishId:t}},8517(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={INPUT_SUBTYPE:51,squishInput:t}},2052(e){e.exports={ONHOVER_SUBTYPE:56,squishOnHover:{type:56,squish:e=>e?[1]:[0],unsquish:e=>1===e[0]}}},7536(e){e.exports={PLAYER_ID_SUBTYPE:44,squishPlayerIds:{type:44,squish:e=>e,unsquish:e=>e}}},4267(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={POS_SUBTYPE:45,squishPos:s}},9124(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={SIZE_SUBTYPE:46,squishSize:s}},923(e){e.exports={SUBTYPE_TYPE:55,squishSubType:{type:55,squish:e=>[e],unsquish:e=>e[0]}}},3718(e,t,s){const{hypLength:r}=s(5841),n=s(3002),{squishColor:i}=s(3114),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||n.BLACK,p=i.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 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+p.length+2+3*[...a].length;l[r+g]=Number(s[0]),l[r+g+1]=Number(s[1]),l[r+g+2]=Number(s[2]),g+=3}let m=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 n=6+p.length+2+3*[...a].length+3*[...h].length;l[n+m]=Number(r[0]),l[n+m+1]=Number(r[1]),l[n+m+2]=Number(r[2]),m+=3}return l},unsquish:e=>{const t=e[0]+e[1]/100,s=e[2]+e[3]/100,r=e[4]+e[5]/100,n=e.slice(6,10),i=e[10],o=e[11],a=e.slice(12,12+i),h=e.slice(12+i,12+i+o),l=e.slice(12+i+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 n=t+s+r;c.push(n)}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 n=t+s+r;u.push(n)}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 n=t+s+r;f.push(n)}return{x:t,y:s,text:String.fromCodePoint.apply(null,f),size:r,color:n,align:d,font:p}}};e.exports={TEXT_SUBTYPE:47,squishText:o}},260(e,t,s){const{GameNode:r}=s(6308),n=s(6541);e.exports={[[n.ASSET]]:r.Asset,[[n.TEXT]]:r.Text,[[n.SHAPE_2D_POLYGON]]:r.Shape,[[n.SHAPE_2D_CIRCLE]]:r.Shape,[[n.SHAPE_2D_LINE]]:r.Shape}},6541(e){e.exports={ASSET:1,TEXT:2,SHAPE_2D_POLYGON:3,SHAPE_2D_CIRCLE:4,SHAPE_2D_LINE:5}},10(e,t,s){const{getRandomTerrain:r,getRandomStartPoint:n}=s(182),i=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,n(a,h,t),a,h,t);const d=((e,t,s,r)=>{const n=[];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(n.findIndex(e=>e.x===a.x&&e.y===a.y)>-1||a.x===t.x&&a.y===t.y||s.filled){n.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}}i(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:n}=((e,t)=>{const s=e.x,r=e.y,n=t.x,i=t.y;return{width:Math.floor(s/n),height:Math.floor(r/i)}})(e,t);let i=((e,t)=>{const s=[],r={filled:!1,north:!0,south:!0,east:!0,west:!0};for(let n=0;n<e;n++){s[n]=[];for(let i=0;i<t;i++){const o={...r};0===n?o.west=!1:n===e-1&&(o.east=!1),0===i?o.north=!1:i===t-1&&(o.south=!1),s[n].push(o)}}return s})(r,n);const a={x:Math.floor(Math.random()*r),y:Math.floor(Math.random()*n)};return i=o(i,a,s,r,n),i}}},182(e){const t=(e,{x:t,y:s},r,n,i)=>{t<0||t>=r||s<0||s>=n||t===i.x&&s===i.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},n,i,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},n,i,o),0===a?(t(e,{x:s+1,y:r},n,i,o),t(e,{x:s,y:r+1},n,i,o),t(e,{x:s+1,y:r+1},n,i,o)):1===a?(t(e,{x:s-1,y:r},n,i,o),t(e,{x:s,y:r+1},n,i,o),t(e,{x:s-1,y:r+1},n,i,o)):2===a?(t(e,{x:s,y:r-1},n,i,o),t(e,{x:s+1,y:r},n,i,o),t(e,{x:s+1,y:r-1},n,i,o)):(t(e,{x:s,y:r-1},n,i,o),t(e,{x:s-1,y:r},n,i,o),t(e,{x:s-1,y:r-1},n,i,o))},(e,{x:s,y:r},n,i,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},n,i,o),0===a?(t(e,{x:s,y:r+1},n,i,o),t(e,{x:s,y:r+2},n,i,o),t(e,{x:s,y:r+3},n,i,o)):1===a?(t(e,{x:s+1,y:r},n,i,o),t(e,{x:s+2,y:r},n,i,o),t(e,{x:s+3,y:r},n,i,o)):2===a?(t(e,{x:s-1,y:r},n,i,o),t(e,{x:s-2,y:r},n,i,o),t(e,{x:s-3,y:r},n,i,o)):(t(e,{x:s,y:r-1},n,i,o),t(e,{x:s,y:r-2},n,i,o),t(e,{x:s,y:r-3},n,i,o))},(e,{x:s,y:r},n,i,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},n,i,o),0===a?(t(e,{x:s,y:r+1},n,i,o),t(e,{x:s,y:r+2},n,i,o),t(e,{x:s+1,y:r+2},n,i,o)):1===a?(t(e,{x:s+1,y:r},n,i,o),t(e,{x:s+2,y:r},n,i,o),t(e,{x:s+2,y:r-1},n,i,o)):2===a?(t(e,{x:s-1,y:r},n,i,o),t(e,{x:s-2,y:r},n,i,o),t(e,{x:s-2,y:r+1},n,i,o)):(t(e,{x:s,y:r-1},n,i,o),t(e,{x:s,y:r-2},n,i,o),t(e,{x:s-1,y:r-2},n,i,o))},(e,{x:s,y:r},n,i,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},n,i,o),0===a?(t(e,{x:s,y:r+1},n,i,o),t(e,{x:s-1,y:r+1},n,i,o),t(e,{x:s-1,y:r+2},n,i,o)):1===a?(t(e,{x:s+1,y:r},n,i,o),t(e,{x:s+1,y:r+1},n,i,o),t(e,{x:s+2,y:r+1},n,i,o)):2===a?(t(e,{x:s-1,y:r},n,i,o),t(e,{x:s-1,y:r+1},n,i,o),t(e,{x:s-2,y:r+1},n,i,o)):(t(e,{x:s,y:r-1},n,i,o),t(e,{x:s-1,y:r-1},n,i,o),t(e,{x:s-1,y:r-2},n,i,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}}},6897(e){const t=(e,s,r,n=[])=>{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]],i=s.node.coordinates2d,o=r[0][0],a=r[1][0],h=i[0][0],l=i[1][0],c=r[0][1],d=r[2][1],u=i[0][1],p=i[2][1];l<o||a<h||c>p||u>d||n.push(e)}for(const i in e.node.children)t(e.node.children[i],s,r,n);return n};e.exports={checkCollisions:(e,s,r=null)=>t(e,s,r)}},5841(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)))}},7043(e){e.exports={triangle:(e,t,s,r,n,i)=>[[e,t],[s,r],[n,i],[e,t]],rectangle:(e,t,s,r)=>[[e,t],[e+s,t],[e+s,t+r],[e,t+r],[e,t]]}},6967(e,t,s){const{GameNode:r}=s(6308),n=s(2316),i=s(7043),o=s(6897),a=s(3002);e.exports={getView:(e,t,s,h={},l={})=>{const c=o.checkCollisions(e,{node:{coordinates2d:i.rectangle(t.x,t.y,t.w,t.h)}},t=>t.node.id!==e.node.id),d=new r.Shape({shapeType:n.POLYGON,coordinates2d:i.rectangle(0,0,0,0),fill:a.COLORS.BLACK}),u=[];return c.length>0&&c.forEach(e=>{const r=[],n=[],i=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 i){const o=i[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),g=(l.y||1)*(c-t.y);p&&(h.x&&(f+=h.x),h.y&&(g+=h.y)),n.push([f,g])}{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],i=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=i,a.size.y=o;const h=n[0],l=n[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}}},688(e,t,s){const{squish:r,unsquish:n}=s(7208),{gameNode:i,GameNode:o}=s(1267),a=(s(7478),s(9173)),h=s(7903),l=s(8406),c=s(7643),d=s(6734),u=s(436),{terrainGenerator:p}=s(967),f=s(3802),g=s(8231),m=s(8257),y=s(5864),x=s(280);e.exports={squish:r,unsquish:n,gameNode:i,subtypes:f,Game:h,ViewableGame:l,GameNode:o,Colors:a,Shapes:c,Squisher:g,ShapeUtils:d,ViewUtils:u,TerrainGenerator:p,GeometryUtils:y,Asset:m,Physics:x}},8257(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"))}}},6364(e,t,s){const r=s(7478),n=(e,t,s,n,i,o,a,h,l,c,d,u,p,f,g,m)=>new r(e,t,s,n,i,o,a,h,l,c,d,u,p,f,g,m);e.exports={gameNode:n,BaseNode:class{constructor({color:e,onClick:t,coordinates2d:s,border:r,fill:i,textInfo:o,assetInfo:a,playerIds:h,effects:l,input:c,subtype:d,node:u,id:p,onHover:f,offHover:g,onDrag:m,offClick:y}){this.node=u||n(e,t,s,r,i,o,a,h,l,c,d,p,f,g,m,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")}}}},9173(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,n=Math.floor(Math.random()*r.length);return t[r[n]]}}},7903(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)}}}},1267(e,t,s){const r=s(7643),n=s(3802),{gameNode:i,BaseNode:o}=s(6364),a={[r.CIRCLE]:n.SHAPE_2D_CIRCLE,[r.POLYGON]:n.SHAPE_2D_POLYGON,[r.LINE]:n.SHAPE_2D_LINE},h={[n.SHAPE_2D_CIRCLE]:r.CIRCLE,[n.SHAPE_2D_POLYGON]:r.POLYGON,[n.SHAPE_2D_LINE]:r.LINE};class l extends o{constructor({color:e,onClick:t,shapeType:s,coordinates2d:r,border:n,fill:i,playerIds:o,effects:h,input:l,node:c,id:d,onHover:u,offHover:p,onDrag:f,offClick:g}){if(!(r&&s||c))throw new Error("Shape requires coordinates2d and shapeType");super({color:e,onClick:t,coordinates2d:r,border:n,fill:i,playerIds:o,effects:h,input:l,node:c,subtype:a[s],id:d,onHover:u,offHover:p,onDrag:f,offClick:g})}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:i,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:n.TEXT,id:i,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:i,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:i,node:o,subtype:n.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:i,...o}){if(!i&&!/^[A-Za-z0-9-]{1,64}$/.test(e||""))throw new Error("Stream requires a valid streamId");super({...o,node:i,subtype:n.STREAM}),i||(this.node.stream={id:e,pos:t,size:s,audio:!!r})}},Asset:d,Shape:l,Text:c};e.exports={gameNode:i,GameNode:u}},7478(e){e.exports=class{constructor(e,t,s,r,n,i,o,a=[],h=null,l=null,c=null,d=null,u,p,f,g){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=n,this.text=i,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=g}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}}},7643(e){e.exports={CIRCLE:1,POLYGON:2,LINE:3}},8231(e,t,s){const{squish:r,unsquish:n}=s(7208);e.exports=class{constructor({game:e,scale:t,customBottomLayer:s,customTopLayer:i,onAssetUpdate:o,encodeNode:a=r,decodeNode:h=n,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=i,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,n)=>{if(!e?.node)return;this.observedNodes.has(e)||(e.addListener(this),this.observedNodes.add(e)),s.add(e);const i=e.node.playerIds,o=i?.length?[...n,i.map(Number)]:n;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 n=this.playerSettings[t]&&this.playerSettings[t].SOUND;return!(!n||!1!==n.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(8410).loadAssetBundle,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]}}},8406(e,t,s){const{GameNode:r}=s(1267),n=s(7643),i=s(6734),o=s(9173),a=s(7903);e.exports=class extends a{constructor(e){var t;super(),this.planeSize=e,this.plane=(t=this.planeSize,new r.Shape({shapeType:n.POLYGON,coordinates2d:i.rectangle(0,0,t,t)})),this.fakeRoot=new r.Shape({shapeType:n.POLYGON,coordinates2d:i.rectangle(0,0,0,0),fill:o.COLORS.BLACK}),this.layers=[{root:this.fakeRoot}]}updatePlaneSize(e){this.planeSize=e,this.plane.node.coordinates2d=i.rectangle(0,0,e,e)}getLayers(){return this.layers}getPlane(){return this.plane}getPlaneSize(){return this.planeSize}getViewRoot(){return this.fakeRoot}}},8410(e){const t={image:1,audio:2,font:3,video:4};e.exports={loadAssetBundle:async function(e,s=Object.create(null)){const r=[];for(const[n,i]of Object.entries(e)){if(!t[i.info?.type]||!/^[\x20-\x7e]{1,32}$/.test(n))throw new Error("Invalid asset declaration: "+n);if(!Object.hasOwn(s,n)){const e=i.data;if(!(e instanceof Uint8Array))throw new Error("The host must supply local asset bytes: "+n);const r=new Uint8Array(44+e.length);r[0]=1,r[1]=t[i.info.type],r.set((new TextEncoder).encode((e.length+32).toString(36).padStart(10,"0")),2),r.set((new TextEncoder).encode(n),12),r.set(e,44),s[n]=r}r.push(s[n])}const n=new Uint8Array(r.reduce((e,t)=>e+t.length,0));let i=0;for(const e of r)n.set(e,i),i+=e.length;return n}}},2177(e,t,s){const{GameNode:r}=s(1267);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}}},280(e){e.exports={getPath:(e,t,s,r,n=100,i=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>n||l<0||l>i){let e=h,t=l;h<0?e=0:h>n&&(e=n),l<0?t=0:l>i&&(t=i),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}}},7208(e,t,s){const r=s(7478),{CONSTRUCTOR_TO_TYPE:n,TYPE_TO_CONSTRUCTOR:i}=s(2177),o=s(5647),{squishId:a}=s(2603),{squishColor:h}=s(3187),{squishPlayerIds:l}=s(3641),{squishPos:c}=s(3070),{squishFill:d}=s(3971),{squishSize:u}=s(2575),{squishHandleClick:p}=s(7666),{squishOnHover:f}=s(4017),{squishBorder:g}=s(7456),{squishSubType:m}=s(986),{squishInput:y}=s(6844),{squishCoordinates2d:x}=s(7829),{squishEffect:v}=s(3399),{squishText:w}=s(5317),{squishAsset:b}=s(2108),{squishStream:E}=s(3122),S={stream:E,id:a,color:h,playerIds:l,pos:c,coordinates2d:x,fill:d,size:u,text:w,asset:b,effects:v,handleClick:p,onHover:f,border:g,subType:m,input:y},_={};for(const e in S)_[Number(S[e].type)]=e;e.exports={squish:(e,t=null)=>{let s=[];const r=e.node,i=(()=>{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 i){const n=i[e];if(n in r){const e=r[n];if(null!=e){const i=S[n].squish(e,t,r),o=i.length+3,a=Math.min(255,o),h=Math.min(255,Math.max(0,o-255));s.push([S[n].type,h,a,...i])}}}let a=n[e.constructor.name];a||(a=n[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],n=e[t+1]+e[t+2],i=e.slice(t+3,t+n);if(!_[r]){console.warn("Unknown sub frame type "+r);break}{const e=_[r],t=(0,S[e].unsquish)(i,Object.assign({},s));s[e]=t}t+=n}const n=i[e[4]];return n?new n({node:s}):{node:s}}}},2108(e,t,s){const{getFractional:r}=s(6474),n={type:48,squish:(e,t)=>{const s=Object.keys(e)[0],n=new Array(18+s.length),i=e[s],o=t?t.x*i.pos.x+Math.round(100*(1-t.x))/2:i.pos.x,a=t?t.y*i.pos.y+Math.round(100*(1-t.y))/2:i.pos.y,h=t?t.x*i.size.x:i.size.x,l=t?t.y*i.size.y:i.size.y,c=i.startTime||0,d=i.cropLeft||0,u=i.cropTop||0,p=i.cropRight||0,f=i.cropBottom||0;n[0]=Math.floor(o),n[1]=r(o),n[2]=Math.floor(a),n[3]=r(a),n[4]=Math.floor(h),n[5]=r(h),n[6]=Math.floor(l),n[7]=r(l),n[8]=Math.floor(c),n[9]=r(c),n[10]=Math.floor(d),n[11]=r(d),n[12]=Math.floor(u),n[13]=r(u),n[14]=Math.floor(p),n[15]=r(p),n[16]=Math.floor(f),n[17]=r(f);for(let e=0;e<s.length;e++)n[18+e]=s.codePointAt(e);return n},unsquish:e=>{const t=e[0]+e[1]/100,s=e[2]+e[3]/100,r=e[4]+e[5]/100,n=e[6]+e[7]/100,i=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:n},startTime:i,cropLeft:o,cropTop:a,cropRight:h,cropBottom:l}}}};e.exports={ASSET_SUBTYPE:48,squishAsset:n}},7456(e){e.exports={BORDER_SUBTYPE:54,squishBorder:{type:54,squish:e=>[e],unsquish:e=>e[0]}}},3187(e){e.exports={COLOR_SUBTYPE:42,squishColor:{type:42,squish:e=>[e[0],e[1],e[2],e[3]],unsquish:e=>[e[0],e[1],e[2],e[3]]}}},7829(e,t,s){const{getFractional:r}=s(6474),n=s(3802),i=e=>e<0?0:e>255?255:e,o=(e,t)=>e*t+Math.round(100*(1-e))/2,a={type:52,squish:(e,t,s)=>{const a=e.flat(),h=new Array(2*a.length);if(s.subType==n.SHAPE_2D_CIRCLE)if(t){const e=i(o(t.x,a[0]));h[0]=Math.floor(e),h[1]=r(e);const s=i(o(t.y,a[1]));let n;h[2]=Math.floor(s),h[3]=r(s),n=t.x===t.y?t.x*a[2]:Math.sqrt(Math.pow(100*t.x,2)+Math.pow(100*t.y,2))*(a[2]/100),h[4]=Math.floor(n),h[5]=r(n)}else{const e=i(a[0]);h[0]=Math.floor(e),h[1]=r(e);const t=i(a[1]);h[2]=Math.floor(t),h[3]=r(t);const s=a[2];h[4]=Math.round(s),h[5]=r(s)}else for(const e in a)if(t){const s=e%2==0?t.x:t.y,n=s*a[e],o=Math.round(100*(1-s)),l=i(n+o/2);h[2*e]=Math.floor(l),h[2*e+1]=r(l)}else{const t=i(a[e]);h[2*e]=Math.floor(t),h[2*e+1]=Math.round(100*(t-Math.floor(t)))}return h},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===n.SHAPE_2D_POLYGON||t===n.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={COORDINATES_2D_SUBTYPE:52,squishCoordinates2d:a}},3399(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 n={[t]:{color:s}};return r&&(n[t].blur=r),n}};e.exports={EFFECTS_SUBTYPE:49,squishEffect:t}},3971(e){e.exports={FILL_SUBTYPE:53,squishFill:{type:53,squish:e=>[e[0],e[1],e[2],e[3]],unsquish:e=>[e[0],e[1],e[2],e[3]]}}},7666(e){e.exports={ONCLICK_SUBTYPE:50,squishHandleClick:{type:50,squish:e=>e?[1]:[0],unsquish:e=>1===e[0]}}},2603(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={ID_SUBTYPE:43,squishId:t}},6844(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={INPUT_SUBTYPE:51,squishInput:t}},4017(e){e.exports={ONHOVER_SUBTYPE:56,squishOnHover:{type:56,squish:e=>e?[1]:[0],unsquish:e=>1===e[0]}}},3641(e){e.exports={PLAYER_ID_SUBTYPE:44,squishPlayerIds:{type:44,squish:e=>e,unsquish:e=>e}}},3070(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={POS_SUBTYPE:45,squishPos:s}},2575(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={SIZE_SUBTYPE:46,squishSize:s}},3122(e,t,s){const{squishAsset:r}=s(2108),n={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:n}},986(e){e.exports={SUBTYPE_TYPE:55,squishSubType:{type:55,squish:e=>[e],unsquish:e=>e[0]}}},5317(e,t,s){const{hypLength:r}=s(6474),n=s(9173),{squishColor:i}=s(3187),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||n.BLACK,p=i.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 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+p.length+2+3*[...a].length;l[r+g]=Number(s[0]),l[r+g+1]=Number(s[1]),l[r+g+2]=Number(s[2]),g+=3}let m=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 n=6+p.length+2+3*[...a].length+3*[...h].length;l[n+m]=Number(r[0]),l[n+m+1]=Number(r[1]),l[n+m+2]=Number(r[2]),m+=3}return l},unsquish:e=>{const t=e[0]+e[1]/100,s=e[2]+e[3]/100,r=e[4]+e[5]/100,n=e.slice(6,10),i=e[10],o=e[11],a=e.slice(12,12+i),h=e.slice(12+i,12+i+o),l=e.slice(12+i+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 n=t+s+r;c.push(n)}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 n=t+s+r;u.push(n)}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 n=t+s+r;f.push(n)}return{x:t,y:s,text:String.fromCodePoint.apply(null,f),size:r,color:n,align:d,font:p}}};e.exports={TEXT_SUBTYPE:47,squishText:o}},5647(e,t,s){const{GameNode:r}=s(1267),n=s(3802);e.exports={[[n.STREAM]]:r.Stream,[[n.ASSET]]:r.Asset,[[n.TEXT]]:r.Text,[[n.SHAPE_2D_POLYGON]]:r.Shape,[[n.SHAPE_2D_CIRCLE]]:r.Shape,[[n.SHAPE_2D_LINE]]:r.Shape}},3802(e){e.exports={STREAM:6,ASSET:1,TEXT:2,SHAPE_2D_POLYGON:3,SHAPE_2D_CIRCLE:4,SHAPE_2D_LINE:5}},967(e,t,s){const{getRandomTerrain:r,getRandomStartPoint:n}=s(9337),i=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,n(a,h,t),a,h,t);const d=((e,t,s,r)=>{const n=[];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(n.findIndex(e=>e.x===a.x&&e.y===a.y)>-1||a.x===t.x&&a.y===t.y||s.filled){n.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}}i(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:n}=((e,t)=>{const s=e.x,r=e.y,n=t.x,i=t.y;return{width:Math.floor(s/n),height:Math.floor(r/i)}})(e,t);let i=((e,t)=>{const s=[],r={filled:!1,north:!0,south:!0,east:!0,west:!0};for(let n=0;n<e;n++){s[n]=[];for(let i=0;i<t;i++){const o={...r};0===n?o.west=!1:n===e-1&&(o.east=!1),0===i?o.north=!1:i===t-1&&(o.south=!1),s[n].push(o)}}return s})(r,n);const a={x:Math.floor(Math.random()*r),y:Math.floor(Math.random()*n)};return i=o(i,a,s,r,n),i}}},9337(e){const t=(e,{x:t,y:s},r,n,i)=>{t<0||t>=r||s<0||s>=n||t===i.x&&s===i.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},n,i,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},n,i,o),0===a?(t(e,{x:s+1,y:r},n,i,o),t(e,{x:s,y:r+1},n,i,o),t(e,{x:s+1,y:r+1},n,i,o)):1===a?(t(e,{x:s-1,y:r},n,i,o),t(e,{x:s,y:r+1},n,i,o),t(e,{x:s-1,y:r+1},n,i,o)):2===a?(t(e,{x:s,y:r-1},n,i,o),t(e,{x:s+1,y:r},n,i,o),t(e,{x:s+1,y:r-1},n,i,o)):(t(e,{x:s,y:r-1},n,i,o),t(e,{x:s-1,y:r},n,i,o),t(e,{x:s-1,y:r-1},n,i,o))},(e,{x:s,y:r},n,i,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},n,i,o),0===a?(t(e,{x:s,y:r+1},n,i,o),t(e,{x:s,y:r+2},n,i,o),t(e,{x:s,y:r+3},n,i,o)):1===a?(t(e,{x:s+1,y:r},n,i,o),t(e,{x:s+2,y:r},n,i,o),t(e,{x:s+3,y:r},n,i,o)):2===a?(t(e,{x:s-1,y:r},n,i,o),t(e,{x:s-2,y:r},n,i,o),t(e,{x:s-3,y:r},n,i,o)):(t(e,{x:s,y:r-1},n,i,o),t(e,{x:s,y:r-2},n,i,o),t(e,{x:s,y:r-3},n,i,o))},(e,{x:s,y:r},n,i,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},n,i,o),0===a?(t(e,{x:s,y:r+1},n,i,o),t(e,{x:s,y:r+2},n,i,o),t(e,{x:s+1,y:r+2},n,i,o)):1===a?(t(e,{x:s+1,y:r},n,i,o),t(e,{x:s+2,y:r},n,i,o),t(e,{x:s+2,y:r-1},n,i,o)):2===a?(t(e,{x:s-1,y:r},n,i,o),t(e,{x:s-2,y:r},n,i,o),t(e,{x:s-2,y:r+1},n,i,o)):(t(e,{x:s,y:r-1},n,i,o),t(e,{x:s,y:r-2},n,i,o),t(e,{x:s-1,y:r-2},n,i,o))},(e,{x:s,y:r},n,i,o)=>{const a=Math.floor(4*Math.random());t(e,{x:s,y:r},n,i,o),0===a?(t(e,{x:s,y:r+1},n,i,o),t(e,{x:s-1,y:r+1},n,i,o),t(e,{x:s-1,y:r+2},n,i,o)):1===a?(t(e,{x:s+1,y:r},n,i,o),t(e,{x:s+1,y:r+1},n,i,o),t(e,{x:s+2,y:r+1},n,i,o)):2===a?(t(e,{x:s-1,y:r},n,i,o),t(e,{x:s-1,y:r+1},n,i,o),t(e,{x:s-2,y:r+1},n,i,o)):(t(e,{x:s,y:r-1},n,i,o),t(e,{x:s-1,y:r-1},n,i,o),t(e,{x:s-1,y:r-2},n,i,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}}},5864(e){const t=(e,s,r,n=[])=>{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]],i=s.node.coordinates2d,o=r[0][0],a=r[1][0],h=i[0][0],l=i[1][0],c=r[0][1],d=r[2][1],u=i[0][1],p=i[2][1];l<o||a<h||c>p||u>d||n.push(e)}for(const i in e.node.children)t(e.node.children[i],s,r,n);return n};e.exports={checkCollisions:(e,s,r=null)=>t(e,s,r)}},6474(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)))}},6734(e){e.exports={triangle:(e,t,s,r,n,i)=>[[e,t],[s,r],[n,i],[e,t]],rectangle:(e,t,s,r)=>[[e,t],[e+s,t],[e+s,t+r],[e,t+r],[e,t]]}},436(e,t,s){const{GameNode:r}=s(1267),n=s(7643),i=s(6734),o=s(5864),a=s(9173);e.exports={getView:(e,t,s,h={},l={})=>{const c=o.checkCollisions(e,{node:{coordinates2d:i.rectangle(t.x,t.y,t.w,t.h)}},t=>t.node.id!==e.node.id),d=new r.Shape({shapeType:n.POLYGON,coordinates2d:i.rectangle(0,0,0,0),fill:a.COLORS.BLACK}),u=[];return c.length>0&&c.forEach(e=>{const r=[],n=[],i=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 i){const o=i[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),g=(l.y||1)*(c-t.y);p&&(h.x&&(f+=h.x),h.y&&(g+=h.y)),n.push([f,g])}{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],i=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=i,a.size.y=o;const h=n[0],l=n[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),n=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)),n=parseInt(r,36);if(!Number.isFinite(n)||n<=0)break;const i=e.slice(t+12,t+12+32),o=String.fromCharCode.apply(null,i.filter(e=>e)),a=e.slice(t+12+32,t+12+n),h=1===s?"image":2===s?"audio":3===s?"font":4===s?"video":null;h&&this.storeRawAsset(o,h,a),t+=12+n}}storeRawAsset(e,t,s){const i=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(i).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=n(e.subarray(0,1024)).replace(/^\xEF\xBB\xBF/,"");return/^\s*(?:<\?xml\b[^?]*\?>\s*)?<svg\b/i.test(t)?"image/svg+xml":"image/jpeg"})(i);this.assets[e]={type:"image",data:`data:${t};base64,`+btoa(n(i))},delete this.imageCache[e],this._notifyReady()}else if("audio"===t)if(this.audioCtx)try{this.audioCtx.decodeAudioData(i.buffer.slice(i.byteOffset,i.byteOffset+i.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:i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength),decoded:!1};else if("video"===t){const t=r(i);this.assets[e]={type:"video",data:new Blob([i],{type:t.contentType||"video/mp4"}),url:null},this._notifyReady()}else if("font"===t)try{new FontFace(e,i).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={}}}},3625(e,t,s){const r=s(7588),{Squisher:n,Asset:i}=s(688);e.exports={...r,Asset:i,Squisher:class extends n{constructor(e){super({...e,encodeNode:r.squish,decodeNode:r.unsquish})}},Game:s(9579),ViewableGame:s(7706),Colors:s(961),Shapes:s(3431),subtypes:s(7910),ShapeUtils:s(3250),ViewUtils:s(6560),GeometryUtils:s(836),Physics:s(6036),...s(847),TerrainGenerator:s(4123).terrainGenerator}},842(e,t,s){const r=s(3317),{Squisher:n,Asset:i}=s(688);e.exports={...r,Asset:i,Squisher:class extends n{constructor(e){super({...e,encodeNode:r.squish,decodeNode:r.unsquish})}},Game:s(2706),ViewableGame:s(711),Colors:s(3872),Shapes:s(9990),subtypes:s(675),ShapeUtils:s(3485),ViewUtils:s(177),GeometryUtils:s(799),Physics:s(9807),...s(9930),TerrainGenerator:s(7004).terrainGenerator}},6428(e,t,s){const r=s(4003),{Squisher:n,Asset:i}=s(688);e.exports={...r,Asset:i,Squisher:class extends n{constructor(e){super({...e,encodeNode:r.squish,decodeNode:r.unsquish})}},Game:s(2212),ViewableGame:s(6525),Colors:s(3002),Shapes:s(2316),subtypes:s(6541),ShapeUtils:s(7043),ViewUtils:s(6967),GeometryUtils:s(6897),Physics:s(6021),...s(6308),TerrainGenerator:s(10).terrainGenerator}},9630(e,t,s){const{squishMap:r,DEFAULT_VERSION:n}=s(9732),{normalizePath:i,resolveInFiles:o}=s(3735);e.exports={loadGameClass:({files:e,entryPoint:t})=>{if(!e||!t)throw new Error("loadGameClass requires { files, entryPoint }");const s={};for(const t of Object.keys(e))s[i(t)]=e[t];const n={},a=e=>{if(n[e])return n[e].exports;const t=e.includes("/")?e.slice(0,e.lastIndexOf("/")):"",i=n=>{const i=/^squish-(\d+)$/.exec(n);if(i){const e=r[i[1]];if(e)return e;throw new Error("Unsupported Squish runtime: "+n)}if(n.startsWith("./")||n.startsWith("../")){const r=o(s,t,n);if(r)return a(r);throw new Error("Cannot resolve require('"+n+"') from "+e+" — not in the game source map")}throw new Error("Game tried to require('"+n+"') — local games may only require their squish version and their own files")},h={exports:{}};n[e]=h;const l=s[e];if(e.endsWith(".json"))try{return h.exports=JSON.parse(l),h.exports}catch(t){throw delete n[e],new Error("Invalid JSON module "+e+": "+t.message)}const c=new Function("module","exports","require","__filename","__dirname",l);try{c(h,h.exports,i,e,t)}catch(t){throw delete n[e],t}return h.exports},h=i(t);if(!Object.prototype.hasOwnProperty.call(s,h))throw new Error('Entry point "'+t+'" not found in game source map');return a(h)}}},1768(e,t,s){const r=s(6899),n=s(549),i=s(7868);e.exports={GameView:class{constructor({container:e,assetManager:t,send:s,gamepad:o,onAssetReady:a}){this.container=e,e.innerHTML="",Object.assign(e.style,{position:"relative",overflow:"hidden",background:"#000"}),this.canvas=document.createElement("canvas"),Object.assign(this.canvas.style,{display:"block",margin:"0 auto",cursor:"default",webkitTapHighlightColor:"transparent",webkitTouchCallout:"none",webkitUserSelect:"none",userSelect:"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 n(this.canvas,this.assetManager),this.inputHandler=new i(this.canvas,s,()=>this.renderer.thingIndices,this.assetManager,o),this.inputHandler.attach()}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,n=this._cursorRaster;if(n?.data===e.data&&n.image===t&&n.width===s&&n.height===r)return n.url;const i=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),i.url=e.toDataURL("image/png")}catch(e){}return i.url}resize(e){const t=this.container.clientWidth||window.innerWidth,s=this.container.clientHeight||window.innerHeight,r=t*e.y/e.x<=s,n=r?t:Math.floor(s*e.x/e.y),i=r?Math.floor(t*e.y/e.x):s;this.canvas.width=2*n,this.canvas.height=2*i,this.canvas.style.width=n+"px",this.canvas.style.height=i+"px",this.inputHandler.clientWidth=n,this.inputHandler.clientHeight=i}destroy(){this.destroyed||(this.destroyed=!0,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:n}=s(1011),i=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),n=Math.max(0,e-this.nextPoll);this.nextPoll=e+r-n%r;const i=new Map(s.map(e=>[e.index,e]));for(const[e,t]of this.previous)i.has(e)&&i.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=i}_release(e){this.send(JSON.stringify({type:"input",gamepad:!0,gamepadIndex:e.index,connected:!1,deltaTime:0,input:n({buttons:[],axes:[]},i)}))}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,n=!1;const i=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){n=!1;const a=new URLSearchParams(new URL(o).hash.slice(1)),h=r=i({gameKey:e.gameKey,versionId:e.versionId,roomId:a.get("room"),invite:a.get("invite")});h.then(e=>{n||r!==h?i({...e,remove:!0}).catch(()=>{}):s=e}).catch(t)},onHeartbeat(e){s&&i({...s,playerCount:e}).catch(e=>{s=null,t(e)})},onEnd(){n=!0,r=null,s&&i({...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},n=(e,t,s)=>e.convertToBlob?e.convertToBlob({type:t,quality:s}):new Promise((r,n)=>{e.toBlob(e=>{e?r(e):n(new Error("Canvas encoding failed"))},t,s)}),i=(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 n=Math.max(16,Math.round(e.width*t)),i=Math.max(16,Math.round(e.height*t)),o=r(n,i),a=o.getContext("2d");return s&&(a.fillStyle="#ffffff",a.fillRect(0,0,n,i)),a.drawImage(e.source,0,0,n,i),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),n=new Image;n.onload=()=>{URL.revokeObjectURL(r),t({source:n,width:n.naturalWidth,height:n.naturalHeight,close:()=>{}})},n.onerror=()=>{URL.revokeObjectURL(r),s(new Error("Not decodable as an image"))},n.src=r})})(e);try{const e=-1!==t.indexOf(c),h=e?c:await(async()=>{if(null!==s)return s;const e=await n(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 n(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:i(l,h),resized:!0}}finally{d.close()}}}},44(e,t,s){const{ProjectTransferClient:r,CONTROL:n,CHUNK:i}=s(4394),o=s(1525),a=s(4849),{loadLocalGame:h,loadHomeGame:l}=s(7348),{GameView:c,FrameLoop:d,getClientInfo:u}=s(1768),{squishMap:p,DEFAULT_VERSION:f}=s(9732),g=s(814),m=s(3598),{RtcHost:y,createRtcTransport:x,readInvitation:v}=s(4454),{createSaveStore:w}=s(7699),{CURSOR_OPCODE:b,decodeCursor:E}=s(5199);class S{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=e.onClose||(()=>{}),this.onError=e.onError||(()=>{}),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||w(),this.platform=e.platform,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?{getLink:()=>this._getRtcHost().share(),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,onSaveData:this.onSaveData,onError:this.onError,onReady:e=>{this.onReady(e),this._shareOptions?.autoStart&&this._getRtcHost().share().catch(e=>this._localChrome?.setStatus?.(`Not available to join: ${e.message}. Use Share to retry.`))}}),onError:this.onError})}start(){this._sessions.start()}stop(){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 y(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=>S.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")}setInputEnabled(e){const t=this._localSession?.inputHandler||this.inputHandler;e?t?.attach():t?.detach()}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=S.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(){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()}}),this._resizeHandler=()=>{this._initCanvas(),this._sendClientInfo()},window.addEventListener("resize",this._resizeHandler);const s=this._mediaClient=new m({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._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._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 n:case i: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 b:try{this.view?.setCursor(E(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=p[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.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),n=new URL(this.wsUrl);n.port=r,this._reconnect(n.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)};S.LocalSession=g,S.loadLocalGame=h,S.packAssetBundle=_,S.fitImageToSize=C,S.downloadSave=A,S.createRtcTransport=x,S.readInvitation=v,S.RtcHost=y,S.createShareDialog=s(172),S.GameCopies=s(2157),S.createSessionFrame=a,S.createPlayerToolbar=s(8106).createPlayerToolbar,S.householdRoom=s(9225),S.PortableProject=s(7237),S.ManualRtc=s(9742),S.createManualPairing=s(5880),e.exports&&(e.exports={default:S,HomegamesClient:S,LocalSession:g,loadLocalGame:h,packAssetBundle:_,fitImageToSize:C,downloadSave:A}),"undefined"!=typeof window&&(window.HomegamesClient=S,window.LocalSession=g)},7868(e,t,s){const r=s(5562),{fitImageToSize:n}=s(9311),{MAX_UPLOAD_BYTES:i}=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,n,i={}){this.canvas=e,this.send=t,this.getThingIndices=s,this.assetManager=n,this.mouseDown=!1,this.mousePos=null,this._pressClickSent=!1,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===i?null:new r(t,i),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._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=>{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._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(),this._focused=!0,this._touchActive=!0,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=>{e.preventDefault(),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.assetManager.liveMedia?.release("pointer"),!this._touchActive)return;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},e.touchcancel=()=>{this.assetManager.liveMedia?.release("pointer"),this.mouseDown&&this._lastClientPos&&this._sendMouseUp(this._lastClientPos[0],this._lastClientPos[1],!0),this.mouseDown=!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),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._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"]')}_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(),n=(e-r.left)/r.width*100,i=(t-r.top)/r.height*100,o=Math.min(99.99,Math.max(0,n)),a=Math.min(99.99,Math.max(0,i)),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,n=(t-s.top)/s.height*100,i=Math.min(99.99,Math.max(0,r)),o=Math.min(99.99,Math.max(0,n));this.send(JSON.stringify({type:"mousemove",data:{x:i,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"),n=document.createElement("input"),i=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",n.type="text",n.maxLength=4096,n.style.cssText="display:block;width:min(300px,65vw);padding:10px;margin:12px 0;font:inherit",r.append(n),i.textContent="Done",i.type="button",o.textContent="Cancel",o.type="button";for(const e of[i,o])e.style.cssText="padding:8px 16px;margin-right:8px;font:inherit";const a=()=>{t.close(),t.remove(),this._textDialog=null};i.onclick=t=>{t.preventDefault();const s=n.value;a(),this.send(JSON.stringify({type:"input",input:s,nodeId:e}))},n.onkeydown=e=>{"Enter"===e.key&&i.onclick(e)},o.onclick=a,t.oncancel=e=>{e.preventDefault(),a()},s.append(r,i,o),t.append(s),document.body.append(t),this._textDialog=t,t.showModal(),n.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(),n=(e-r.left)/r.width*100,i=(s-r.top)/r.height*100;if(n>=0&&n<=100&&i>=0&&i<=100){const e={x:n,y:i};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/*",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>i)try{a=await n(r,i)}catch(e){const t=(r.size/1048576).toFixed(1);return void alert(`That file is ${t}MB — uploads are limited to ${i/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){const t=this.canvas.getBoundingClientRect();return e*t.width/100+t.left}_translateY(e){const t=this.canvas.getBoundingClientRect();return e*t.height/100+t.top}_canClick(e,t){let s=!1,r=!1,n=null,i=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:n,nodeId:i};const a=this.getThingIndices();for(const o in a){const h=a[o];let l=h[3];if(!l||!l.length)continue;if(!l[0].length){const e=new Array(l.length/2);for(let t=0;t<l.length;t+=2)e[t/2]=[l[t],l[t+1]];l=e}let c=!1,d=this._translateX(l[0][0]),u=d,p=this._translateY(l[0][1]),f=p;for(let e=1;e<l.length;e++){const t=this._translateX(l[e][0]),s=this._translateY(l[e][1]);t<d&&(d=t),t>u&&(u=t),s<p&&(p=s),s>f&&(f=s)}if(!(e<d||e>u||t<p||t>f)){let s=0,r=l.length-1;for(;s<l.length;r=s++){const n=this._translateY(l[s][1]),i=this._translateY(l[r][1]),o=this._translateX(l[s][0]),a=this._translateX(l[r][0]);n>t!=i>t&&e<(a-o)*(t-n)/(i-n)+o&&(c=!c)}}c&&(s=h[0],n=h[1],i=h[2],r=!!h[4])}return{isClickable:s,isHoverable:r,action:n,nodeId:i}}}},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:n}=s(8106),i=(e,t,i,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=n(window,{title:t,author:a.author,home:i,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),o&&(p=s(172)({container:c,...o}),d.setAction("share",{label:"Share",run:()=>p.show()}),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=>d.setStatus(e),dispose(){f||(f=!0,p?.dispose(),d.dispose(),c.remove(),l())}}};i.addExportsButton=(e,t)=>{const s=e.homegamesToolbar;return s?.setAction("exports",{label:"View exports",run:t}),()=>s?.setAction("exports",null)},e.exports=i},7348(e){const t=async({manifestUrl:e,gameKey:t,versionId:s,baseUrl:r}={},{signal:n}={})=>{const i=await fetch(e,{signal:n});if(!i.ok)throw new Error("Manifest fetch failed: "+i.status);const o=await i.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:n});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 n=s?`?versionId=${encodeURIComponent(s)}`:"";return t({gameKey:e,versionId:s,manifestUrl:`/games/${encodeURIComponent(e)}/local-manifest${n}`},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),n=s(9503),{playerFrame:i}=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:g}=s(1768),{squishMap:m,DEFAULT_VERSION:y}=s(9732),x=s(7538),{loadGameClass:v}=s(9630),{createSaveStore:w,createDebouncedWriter:b,serializeSaveData:E,isCompatibleSave:S,DEFAULT_VERSION_ID:_}=s(7699),{generateName:C,initialName:A,normalizeName:k}=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=A(e.playerName),this.assetBundle=e.assetBundle||null,this.assetPackets=this.assetBundle?a(this.assetBundle):[],this.onReady=e.onReady||(()=>{}),this.onError=e.onError||(()=>{}),this.gameKey=e.gameKey||null,this.versionId=e.versionId||_,this.onSaveData=e.onSaveData||null,this.saveStore=e.saveStore||w(),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=v({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"));const t="function"==typeof this.gameClass.metadata?this.gameClass.metadata():{};this.maxPlayers=Math.min(255,t.maxPlayers||64),this.pointerLockEnabled=!0===t.pointerLock;const r=t.squishVersion||y;let n=m[r];if(!n)return void this.onError(new Error("Unsupported Squish runtime: squish-"+r));this.unsquish=n.unsquish,this.squishVersion=r,this.aspectRatio=t.aspectRatio||{x:16,y:9};const i=this.gameKey||this.gameClass.name||"local-game",o="local:"+i,a=Array.isArray(t.saveCompatibility)?t.saveCompatibility:[],h=this._bootGeneration;this.exportStorage=this.platform?.getExports?this.platform:s(739).createExportStorage(window,{installationId:i,gameId:i,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:n,saveGame:e=>{let t;try{t=JSON.parse(E(e))}catch(e){return Promise.reject(e)}return c({gameKey:i,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:i}){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:i,services:{}}),this.runtime=n(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,n]=s(e);this.disablePick(),t&&t(r,n)},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,n=this.inputHandler?.gamepads;n&&null===n.index&&n.setIndex(0);const i=new Set(this.players.map(e=>e.view?.inputHandler.gamepads?.index));if(void 0===t)for(t=0;i.has(t);)t++;return this._joinPlayer(s,r,C(),!1!==this.gamepadOptions&&{...this.gamepadOptions,index:t}),this._captureFrame(),r}_joinPlayer(e,t,s,r){const n=new x(this.game,t),i=new p({container:e,assetManager:this.assetManager,gamepad:r,send:e=>{t===this.playerId&&this._noteInput(e),n.handleMessage(e)},onAssetReady:()=>this._invalidateFrames()});if(this.players.push({playerId:t,info:{name:s},settings:{SOUND:!0},view:i,dispatcher:n,cursor:null,currentBuf:null,frameDirty:!0}),t===this.playerId){const s=new u({container:e,platform:this.platform,assets:i.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)})}i.inputHandler.squishVersion=this.squishVersion,i.inputHandler.setPointerLockEnabled(this.pointerLockEnabled),i.resize(this.aspectRatio);try{this.game.handleNewPlayer?.({playerId:t,settings:{SOUND:!0},info:{name:s},clientInfo:g(),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 n=1;for(;this.players.some(e=>e.playerId===n);)n++;const i=Array.from(this.squishVersion,e=>e.charCodeAt(0));e(Uint8Array.from([2,n,this.aspectRatio.x,this.aspectRatio.y,0,0,i.length,...i,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 x(this.game,n),h={playerId:n,info:{name:A(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:n,settings:{SOUND:!0},info:{...h.info},clientInfo:s,requestedGame:null}),this._captureFrame()}catch(e){throw this.removePlayer(n),e}return{playerId:n,handleMessage:t=>{if(!h.dispatcher)return;let s;try{s=JSON.parse(t)}catch(e){return}if("player-info"===s?.type)try{this.setPlayerName(n,s.name)}catch(e){}else"project-transfer"===s?.type?this.handleProjectMessage(n,s,e):h.dispatcher.handleInput(s)},leave:()=>this.removePlayer(n)}}setPlayerName(e,t){const s=k(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=i(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:n,DEFAULT_ICE:i}=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 g=document.createElement("section"),m=document.createElement("section"),y=document.createElement("h3");y.textContent="Host a player",g.append(y);const x=document.createElement("h3");x.textContent="Join a host",m.append(x);let v=null,w=null,b=!1,E=!1;const S=[],_=e=>{b||(u.textContent=e)},C=(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){_(e.message)}finally{E=!1,S.forEach(e=>e.disabled=!1)}}},S.push(r),e.append(r),r},A=(e,t,s=!1)=>{const r=document.createElement("label");r.textContent=t;const n=document.createElement("textarea");return n.setAttribute("aria-label",t),n.readOnly=s,n.maxLength=131072,n.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(n),e.append(r),n},k=A(g,"Offer to send",!0),I=A(g,"Answer from friend");C(g,"Create offer",async()=>{const e=t();if(!e?.game)throw new Error("Start a local game to host a player");v||(v=new r(e,{onStatus:_})),v.iceServers=f.checked?i:[],k.value="",I.value="",_("Collecting network addresses…"),k.value=await v.createOffer(),_("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),_("Handshake copied")}catch(t){e.focus(),e.select(),_("Copy the selected handshake text")}};C(g,"Copy offer",()=>T(k)),C(g,"Connect with answer",async()=>{if(!v)throw new Error("Create an offer first");await v.acceptAnswer(I.value),_("Connecting directly…")}),C(g,"Cancel offer",()=>{v?.cancelOffer(),k.value="",I.value="",_("Pending offer cancelled")});const P=A(m,"Offer from host"),L=A(m,"Answer to send",!0);C(m,"Create answer",async()=>{const e=n(P.value,{iceServers:f.checked?i:[],onStatus:_});v?.stop(),v=null,w?.close(),w=e,L.value="",_("Collecting network addresses…");try{s(e.transport),L.value=await e.answer(),_("Send the entire answer back to the host, then choose Done.")}catch(t){throw e.close(),t}}),C(m,"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,g,m,d,u,M),e.append(h),h.onclose=a,{show(){b||h.open||(h.showModal(),o())},dispose(){b||(b=!0,v?.stop(),w?.close(),h.remove())}}}},3598(e,t,s){const r=s(7511);e.exports=class{constructor({container:e,assets:t,send:s,platform:n,publish:i=()=>{},unpublish:o=()=>{}}){Object.assign(this,{container:e,assets:t,send:s,publish:i,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:n,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 n=document.createElement("button");n.textContent="Cancel";for(const e of[r,n])e.style.cssText="padding:12px;margin:16px 8px 0 0;font:inherit";t.append(s,r,n),this.container.appendChild(t),this.pending.set(e.id,t);const i=t=>{this.remove(e.id),this.send({type:"media",action:"result",id:e.id,error:t})};t.oncancel=e=>{e.preventDefault(),i("Microphone/camera permission cancelled")},n.onclick=()=>i("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)&&i(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)}}}},7237(e,t,s){const r=s(5110),{prepareTrustedLocalGame:n}=s(7435),{squishMap:i}=s(9732),o={supportedRuntimes:Object.keys(i)},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,normalizePath:r.normalizePath,limits:r.LIMITS,buildIsolatedHtml:a.buildIsolatedHtml,runtimeDocument:a.runtimeDocument,createFrame:a.createFrame,attachSaveHost:h.attachSaveHost,attachPlayerHost:(e,t,r)=>{const n=h.attachSaveHost(e,t,r),i=s(739).createExportStorage(e,r),o=l.attachClientHost(e,t,l.recordAudio,i,s(97).createExportsViewer,s(5900).recordVideo,s(8106).createPlayerToolbar,{...r,profile:s(4367).profile(e)});return{...n,get stopped(){return n.stopped},command:o.command,downloadGame:o.download,close:async()=>{o.close(),await n.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)=>n(e,i,t)}},7511(e,t,s){const{recordAudio:r}=s(5564),{recordVideo:n}=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:n)(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:n,ctx:i,assetManager:o}=this,a=new Set(Object.keys(this.playingSounds)),h=new Set,l=new Set;this.mediaDirty=!1,i.clearRect(0,0,n.width,n.height),this.thingIndices=[];let c=0;for(;e&&c<e.length;){e[c];const d=e[c+1]+e[c+2]+e[c+3];let u;try{u=t(e.slice(c,c+d)).node}catch(e){c+=d;continue}if(!u.coordinates2d&&u.input&&u.text){const e=Math.floor(n.width),t=u.text.size/100*e;i.font=t+"px sans-serif";const s=i.measureText(u.text.text);let r=u.text.x*n.width/100;u.text.align&&"center"===u.text.align&&(r-=s.width/2),r=r/n.width*100;const o=s.actualBoundingBoxDescent-s.actualBoundingBoxAscent,a=s.width/n.width*100,h=o/n.height*100;this.thingIndices.push([!!u.handleClick,u.input&&u.input.type,u.id,[r,u.text.y,r+a,u.text.y,r+a,u.text.y+h,r,u.text.y+h,r,u.text.y],!!u.onHover])}else if(null!==u.coordinates2d&&void 0!==u.coordinates2d){if(this.thingIndices.push([!!u.handleClick,u.input&&u.input.type,u.id,u.coordinates2d,!!u.onHover]),u.effects&&u.effects.shadow){const e=u.effects.shadow.color;i.shadowColor="rgba("+e[0]+","+e[1]+","+e[2]+","+e[3]+")",u.effects.shadow.blur&&(i.shadowBlur=u.effects.shadow.blur)}u.color&&(i.globalAlpha=u.color[3]/255),null!==u.fill&&void 0!==u.fill&&(i.fillStyle="rgba("+u.fill[0]+","+u.fill[1]+","+u.fill[2]+","+u.fill[3]+")"),void 0!==u.border&&null!==u.border&&(i.lineWidth=u.border/255*.1*n.width,i.strokeStyle="rgba("+u.color[0]+","+u.color[1]+","+u.color[2]+","+u.color[3]+")"),i.beginPath();const e=u.coordinates2d[0];i.moveTo(e[0]*n.width/100,e[1]*n.height/100);for(let e=1;e<u.coordinates2d.length;e++){const t=u.coordinates2d[e];i.lineTo(t[0]*n.width/100,t[1]*n.height/100)}void 0!==u.fill&&null!==u.fill&&i.fill(),void 0!==u.border&&null!==u.border&&i.stroke(),i.shadowColor=null,i.shadowBlur=0,i.lineWidth=0,i.strokeStyle=null}if(u.text){i.globalAlpha=u.text.color[3]/255,i.fillStyle="rgba("+u.text.color[0]+","+u.text.color[1]+","+u.text.color[2]+","+u.text.color[3]+")";const e=Math.floor(n.width),t=u.text.size/100*e,s=u.text.font&&"default"!==u.text.font?u.text.font:"sans-serif";i.font=t+"px "+s,u.text.align&&(i.textAlign=u.text.align),i.textBaseline="top",i.fillText(u.text.text,u.text.x*n.width/100,u.text.y*n.height/100)}if(u.asset||u.stream){const e=u.stream,t=e?e.id:Object.keys(u.asset)[0],c=e?o.liveMedia?.streams.get(e.id):o.assets[t];if(c&&"audio"===c.type){const e=`${u.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,u.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||u.asset[t];let h;if("video"===c.type||e){const d=`${u.id}:${t}`;l.add(d);let p=this.videos.get(d);p&&p.asset!==c&&(p.destroy(),p=null);const f={...s,muteAudio:!!s.muteAudio||!(!e||e.audio&&!c.local&&c.transmitting)};if(p||(p=new r(o,c,a.startTime||0,()=>{this.mediaDirty=!0},f),this.videos.set(d,p)),p.update(f.muteAudio,!!s.freezeMedia),h=(!e||c.video)&&!p.error&&p.element.readyState>=2?p.element:null,!h&&(!e||c.video)){const e=a.pos.x/100*n.width,t=a.pos.y/100*n.height;i.fillStyle="#202226",i.fillRect(e,t,a.size.x/100*n.width,a.size.y/100*n.height),i.fillStyle="#fff",i.font=`${Math.max(12,.015*n.width)}px sans-serif`,i.textAlign="center",i.textBaseline="middle",i.fillText(p.error?"Video format not supported":"Loading video…",e+a.size.x/200*n.width,t+a.size.y/200*n.height)}}else h=o.getImage(t);if(h){if(h.width=a.size.x/100*n.width,h.height=a.size.y/100*n.height,u.effects&&u.effects.shadow){const e=u.effects.shadow.color;i.shadowColor="rgba("+e[0]+","+e[1]+","+e[2]+","+e[3]+")",u.effects.shadow.blur&&(i.shadowBlur=u.effects.shadow.blur)}const e=a.pos.x/100*n.width,t=a.pos.y/100*n.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 n=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);n=Math.max(0,Math.min(n,(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)-n),d=Math.min(d,(h.videoHeight||h.naturalHeight)-a),c>=1&&d>=1&&i.drawImage(h,n,a,c,d,e,t,h.width,h.height)}else i.drawImage(h,e,t,h.width,h.height)}}}c+=d,i.shadowColor=null,i.shadowBlur=0,i.lineWidth=0,i.strokeStyle=null,i.globalAlpha=1}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,n=r?(new TextEncoder).encode(e):e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength);if(!n.length||n.length>t)return this.fail(new Error("Game packet is too large"));const i=!r&&3===n[0];if(i){if(this.lastFrame&&n.length===this.lastFrame.length&&n.every((e,t)=>e===this.lastFrame[t]))return void this.stats.duplicateFrames++;this.lastFrame=n,this.queue=this.queue.filter(e=>!e.frame||null!==e.offset||(this.queuedBytes-=e.bytes.length,this.stats.replacedFrames++,!1))}if(this.queuedBytes+n.length>s)return this.fail(new Error("Guest connection is too slow"));this.queue.push({bytes:n,text:r,frame:i,offset:null}),this.queuedBytes+=n.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,n=r?null:e instanceof ArrayBuffer?new Uint8Array(e):e,i=3===n?.[0];i&&(this.queue=this.queue.filter(e=>!e.frame||(this.bytes-=e.size,this.replacedFrames++,!1)));const o=r?2*e.length:n.byteLength;this.bytes+o>s?this.fail(new Error("Game message queue is full")):(this.queue.push({data:e,transfer:t,frame:i,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),n=65536,i=async e=>Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",e)),e=>e.toString(16).padStart(2,"0")).join(""),o=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 a(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=a(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=o(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+n,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:n}){Object.assign(this,{send:e,onOffer:t,onProgress:s,importArchive:r,onComplete:n}),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=o(e);if("offer"===this.state)return this.metadata=a(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;if(await i(s)!==r.sha256)throw new Error("The game copy was damaged during transfer. Try again.");const n=await this.importArchive(s);if(n.revision!==r.revision||n.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:n}),"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(n,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,offer:a,CHUNK:n}},2157(e,t,s){"use strict";const r=s(1240),{Peer:n,signalUrl:i}=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:n="all",onStatus:i=()=>{}}={}){Object.assign(this,{project:e,signalingUrl:t,receiveUrl:s,worker:r,iceTransportPolicy:n,onStatus:i}),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(i(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:i(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 i=()=>{clearTimeout(r),r=setTimeout(()=>a.close(new Error("Copy transfer timed out. Open the invitation to try again.")),12e4)},a=new n({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)}%`)),i(),s.open()},onMessage:e=>{try{i(),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,g,m,y=!1,x=!1,v=!1;const w=()=>{v||(v=!0,clearTimeout(m),p?.close(),f?.close(),u.close())},b=()=>{y||(y=!0,g?.close(),w())},E=e=>{y||(b(),x||l(e||new Error("The sender disconnected before the copy was saved. Open the invitation to try again.")))},S=e=>{v||y||("validating"===g?.state||x?w():E(e))},_=()=>{clearTimeout(m),m=setTimeout(()=>E(new Error("Copy transfer timed out. Open the invitation to try again.")),12e4)};return g=new o.Receiver(e=>{v||p.channel.send(e)},{onOffer:t,onProgress:s,importArchive:a.importArchive,onComplete:async e=>{clearTimeout(m),await h(e),x=!0,setTimeout(b,100)}}),f=u.signal(i(e.signalingUrl),{type:"join",roomId:e.roomId,invite:e.invite},e=>{"joined"===e.type?p=new n({network:u,iceServers:e.iceServers,iceTransportPolicy:d,sendSignal:e=>f.send({type:"signal",...e}),onOpen:_,onMessage:e=>{_(),g.receive(e).catch(E)},onEnd:S}):"signal"===e.type&&p?.signal(e)},S),{accept:()=>{if(y||!g)throw new Error("Reconnect to the sender to receive this game");_(),g.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=i(s.get("signal")),n=new URL(r);if(n.username||n.password||n.hash||n.search)throw new Error("Invalid invitation service");return{roomId:s.get("room"),invite:s.get("invite"),signalingUrl:r}},showCopyShare:function(e,t={}){let r,n=!1;const i=new h(e,{...t,onStatus:e=>r?.setStatus(e)}),o=()=>{n||(n=!0,i.close(),r.dispose(),t.onClose?.())};return r=s(172)({container:document.body,getLink:()=>i.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),n=[{urls:"stun:stun.l.google.com:19302"}],i=131072;function o(e,t){if("string"!=typeof e||e.length>i)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>i)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(i),e.pc.removeEventListener("icegatheringstatechange",n),e.cancelGather=null,r?s(r):t()},n=()=>{"complete"===e.pc.iceGatheringState&&r()},i=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",n),n()})}class l{constructor({id:e=crypto.randomUUID(),iceServers:t=n,onOpen:s=()=>{},onMessage:i=()=>{},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:i,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=n,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:n=>{try{if("string"!=typeof n||n.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(n);else{const t=JSON.parse(n);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=n,onStatus:s=()=>{}}={}){const r=o(e,"offer");let i=null,c=!1,d=!1;const u=new l({id:r.id,iceServers:t,onOpen:()=>{c=!0,i?.onOpen(),s("Connected to host")},onMessage:e=>{"string"!=typeof e&&i?.onMessage(e)},onEnd:e=>{d=!0,e&&i?.onError(e),i?.onClose(),s(e?.message||"Host disconnected")}});let p;return{transport:e=>(i=e,c&&queueMicrotask(()=>i.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:n}},1240(e,t,s){const r=s(8221),n=s(844),i=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([`(${i.toString()})(${r.workerSource()},${n.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,i){if(this.onSignalMessage=s,this.onSignalEnd=r,this.onHeartbeat=i,!this.worker)return this.inlineSignal=n(e,t,s,r,i);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,n={callbacks:t,mode:"main-thread",protocol:null,mailbox:null};if(this.channels.set(s,n),this.worker)try{this.worker.postMessage({type:"bind",id:s,channel:e},[e]),n.mode="worker"}catch(e){}if("worker"===n.mode)n.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{n.protocol=new r(e,t);let s=!1;const i=()=>{s||n.protocol.closed||this.closed||(s=!0,n.protocol.flush(),t.onOpen())};e.onopen=i,"open"===e.readyState&&queueMicrotask(i)}return{send:(e,{transfer:t=!1}={})=>{!this.closed&&this.channels.has(s)&&(n.mailbox?n.mailbox.send(e,t):n.protocol.send(e))},close:()=>{this.channels.delete(s)&&(n.mailbox?.close(),n.protocol?.close(),"worker"!==n.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),n=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 i{constructor({iceServers:e,sendSignal:t,onOpen:s,onMessage:r,onEnd:n,onTrack:i=()=>{},network:o,host:a=!1,iceTransportPolicy:h="all"}){this.pc=new RTCPeerConnection({iceServers:e,iceTransportPolicy:h}),Object.assign(this,{sendSignal:t,onEnd:n}),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),i(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:n=!0,iceTransportPolicy:i="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:n,iceTransportPolicy:i,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 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(n(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:n(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(),n=0;const o=new i({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(),n=0),++n>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,g=!1,m=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 i=new URL(r.url),a=o(i.hash);["http:","https:"].includes(i.protocol)&&!i.username&&!i.password&&a?.roomId===e&&a.invite&&n(a.signalingUrl)===n(s)&&(m=i.href)}catch(e){}else c.onMessage(t)},x=e=>{f||(f=!0,p?.close(),u?.close(),d.close(),e&&!g&&c.onError(e),c.onClose())};try{u=d.signal(n(s),{type:"join",roomId:e,invite:t},e=>{"joined"===e.type?p=new i({network:d,iceServers:e.iceServers,iceTransportPolicy:l,onTrack:e=>c.onTrack?.(e),sendSignal:e=>u.send({type:"signal",...e}),onOpen:()=>{g=!0,c.onOpen()},onMessage:y,onEnd:x}):"signal"===e.type&&p?.signal(e)},x)}catch(e){queueMicrotask(()=>x(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(!g)throw new Error("Connect to the host before sharing this game");if(m)return m;const r=new URL(a,window.location.href),i=new URLSearchParams({room:e,signal:n(s)});return t&&i.set("invite",t),r.hash=i.toString(),r.href},close:()=>{f=!0,p?.close(),u?.close(),d.close()}}},readInvitation:o,Peer:i,signalUrl:n}},844(e){e.exports=function(e,t,s,r,n=()=>{}){const i=new WebSocket(e);let o=!1,a=null,h=null;const l=e=>{o||(o=!0,clearTimeout(c),clearInterval(a),i.onopen=i.onmessage=i.onerror=i.onclose=null,i.close(),r(e))},c=setTimeout(()=>l(new Error("Signaling connection timed out")),15e3),d=e=>{o||1!==i.readyState||i.send(JSON.stringify(e))};return i.onopen=()=>d(t),i.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)}},i.onerror=()=>l(new Error("Cannot reach the invitation service")),i.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),n(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 n=(e,t={},s=[])=>postMessage({type:e,...t},s),i=(e,t)=>n("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=>n("signal-message",{data:e}),e=>n("signal-end",{message:e?.message}),e=>n("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=>n("data",{id:h,data:e},"string"==typeof e?[]:[e.buffer||e]),e=>i(h,e)),l=new e(t,{onMessage:e=>a.send(e,!0),onError:e=>i(h,e),onClose:()=>{a.close(),s.delete(h),n("channel-close",{id:h})}});s.set(h,{protocol:l,mailbox:a});const c=()=>{r||l.closed||(r=!0,l.flush(),n("channel-open",{id:h}))};t.onopen=c,"open"===t.readyState&&c()}else if("send"===a)s.get(h)?.protocol.send(l),n("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&&n("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(n=>{try{const i=e?e.getItem(t+r):s[r];if(!i)return void n(null);const o=JSON.parse(i);n(o&&"object"==typeof o?o:null)}catch(e){n(null)}}),putSave:(r,n)=>new Promise((i,o)=>{let a;try{a=JSON.stringify(n)}catch(e){return void o(e)}if(e)try{return e.setItem(t+r,a),void i()}catch(e){}s[r]=a,i()}),deleteSave:r=>new Promise(n=>{try{e&&e.removeItem(t+r)}catch(e){}delete s[r],n()})}},createDebouncedWriter:({intervalMs:e,write:t})=>{let s=0,r=null;const n=()=>{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((i,o)=>{if(r)return r.value=t,r.resolvers.push(i),void r.rejecters.push(o);r={value:t,resolvers:[i],rejecters:[o]};const a=Math.max(0,e-(Date.now()-s));setTimeout(n,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)),MAX_SAVE_DATA_BYTES:s,DEFAULT_VERSION_ID:"local-game-version",STORAGE_PREFIX:t}},1525(e){e.exports=class{constructor({remote:e,loadLocal:t,mountLocal:s,createLocal:r,onError:n}){Object.assign(this,{remote:e,loadLocal:t,mountLocal:s,createLocal:r,onError:n}),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%; display:flex; flex-direction:column; background:#101211; 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:n,onClose:i,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 g=document.createElement("p");g.setAttribute("role","status"),g.className="hg-share-status";const m=document.createElement("input");m.readOnly=!0,m.setAttribute("aria-label","Invitation link"),m.className="hg-share-link";const y=document.createElement("div");y.className="hg-share-actions";const x=(e,t)=>{const s=document.createElement("button");return s.type="button",s.textContent=e,s.onclick=t,y.appendChild(s),s},v=x("Copy link",async()=>{try{await navigator.clipboard.writeText(m.value),g.textContent="Link copied"}catch(e){m.focus(),m.select(),g.textContent="Copy the selected invitation link"}});v.className="hg-share-copy";const w=x(h,()=>c.close());[u,p,f,g,m,y].forEach(e=>c.appendChild(e)),e.appendChild(c);let b=0,E=!1;return c.onclose=()=>{b++,i?.()},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||(g.textContent=e)},async show(){if(E||c.open)return;const e=++b;f.innerHTML="",f.hidden=!0,m.value="",m.hidden=!0,v.disabled=!0,g.textContent="Creating invitation…",c.showModal(),n?.(),w.focus();try{const s=await t();if(e!==b)return;const n=r(0,"M");n.addData(s),n.make(),f.innerHTML=n.createSvgTag({cellSize:4,margin:16,scalable:!0}),f.firstChild.style.cssText="display:block;width:100%;height:100%;background:white",f.hidden=!1,m.value=s,m.hidden=!1,v.disabled=!1,g.textContent=a}catch(t){e===b&&(g.textContent=t.message)}},dispose(){E||(E=!0,b++,c.open&&c.close(),c.remove(),d())}}}},9732(e,t,s){const r={142:s(3625),143:s(842),145:s(6428),146:s(688)};e.exports={squishMap:r,DEFAULT_VERSION:"142"}},5537(e){e.exports=class{constructor(e,t,s,r,n={}){Object.assign(this,{assetManager:e,asset:t,invalidate:r,closed:!1,frozen:!1,forceMute:!1});const i=this.element=document.createElement("video");i.playsInline=!0,i.preload="auto",i.muted=!0,i.onloadedmetadata=()=>{s>0&&Number.isFinite(i.duration)&&(i.currentTime=Math.min(s,i.duration))},i.onloadeddata=i.onseeked=i.onended=()=>{this.closed||r()},i.onerror=()=>{this.closed||(this.error=!0,r())},"stream"===t.type?i.srcObject=t.data:(t.url||(t.url=URL.createObjectURL(t.data)),i.src=t.url),e.mediaPlayers.add(this),this.update(!!n.muteAudio,!!n.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";var s=Uint8Array,r=Uint16Array,n=Int32Array,i=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),i=0;i<31;++i)s[i]=t+=1<<e[i-1];var o=new n(s[30]);for(i=1;i<30;++i)for(var a=s[i];a<s[i+1];++a)o[a]=a-s[i]<<5|i;return{b:s,r:o}},l=h(i,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,g=new r(32768),m=0;m<32768;++m){var y=(43690&m)>>1|(21845&m)<<1;y=(61680&(y=(52428&y)>>2|(13107&y)<<2))>>4|(3855&y)<<4,g[m]=((65280&y)>>8|(255&y)<<8)>>1}var x=function(e,t,s){for(var n=e.length,i=0,o=new r(t);i<n;++i)e[i]&&++o[e[i]-1];var a,h=new r(t);for(i=1;i<t;++i)h[i]=h[i-1]+o[i-1]<<1;if(s){a=new r(1<<t);var l=15-t;for(i=0;i<n;++i)if(e[i])for(var c=i<<4|e[i],d=t-e[i],u=h[e[i]-1]++<<d,p=u|(1<<d)-1;u<=p;++u)a[g[u]>>l]=c}else for(a=new r(n),i=0;i<n;++i)e[i]&&(a[i]=g[h[e[i]-1]++]>>15-e[i]);return a},v=new s(288);for(m=0;m<144;++m)v[m]=8;for(m=144;m<256;++m)v[m]=9;for(m=256;m<280;++m)v[m]=7;for(m=280;m<288;++m)v[m]=8;var w=new s(32);for(m=0;m<32;++m)w[m]=5;var b=x(v,9,0),E=x(v,9,1),S=x(w,5,0),_=x(w,5,1),C=function(e){for(var t=e[0],s=1;s<e.length;++s)e[s]>t&&(t=e[s]);return t},A=function(e,t,s){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(7&t)&s},k=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,n){var h=e.length,l=n?n.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 g=function(e){var t=r.length;if(e>t){var n=new s(Math.max(2*t,e));n.set(r),r=n}},m=t.f||0,y=t.p||0,v=t.b||0,w=t.l,b=t.d,S=t.m,P=t.n,M=8*h;do{if(!w){m=A(e,y,1);var R=A(e,y+1,3);if(y+=3,!R){var O=e[(V=I(y)+4)-4]|e[V-3]<<8,N=V+O;if(N>h){f&&L(0);break}u&&g(v+O),r.set(e.subarray(V,N),v),t.b=v+=O,t.p=y=8*N,t.f=m;continue}if(1==R)w=E,b=_,S=9,P=5;else if(2==R){var U=A(e,y,31)+257,B=A(e,y+10,15)+4,D=U+A(e,y+5,31)+1;y+=14;for(var H=new s(D),q=new s(19),j=0;j<B;++j)q[a[j]]=A(e,y+3*j,7);y+=3*B;var G=C(q),$=(1<<G)-1,F=x(q,G,1);for(j=0;j<D;){var V,z=F[A(e,y,$)];if(y+=15&z,(V=z>>4)<16)H[j++]=V;else{var Y=0,K=0;for(16==V?(K=3+A(e,y,3),y+=2,Y=H[j-1]):17==V?(K=3+A(e,y,7),y+=3):18==V&&(K=11+A(e,y,127),y+=7);K--;)H[j++]=Y}}var W=H.subarray(0,U),J=H.subarray(U);S=C(W),P=C(J),w=x(W,S,1),b=x(J,P,1)}else L(1);if(y>M){f&&L(0);break}}u&&g(v+131072);for(var X=(1<<S)-1,Q=(1<<P)-1,Z=y;;Z=y){var ee=(Y=w[k(e,y)&X])>>4;if((y+=15&Y)>M){f&&L(0);break}if(Y||L(2),ee<256)r[v++]=ee;else{if(256==ee){Z=y,w=null;break}var te=ee-254;if(ee>264){var se=i[j=ee-257];te=A(e,y,(1<<se)-1)+c[j],y+=se}var re=b[k(e,y)&Q],ne=re>>4;if(re||L(3),y+=15&re,J=p[ne],ne>3&&(se=o[ne],J+=k(e,y)&(1<<se)-1,y+=se),y>M){f&&L(0);break}u&&g(v+131072);var ie=v+te;if(v<J){var oe=l-J,ae=Math.min(J,ie);for(oe+v<0&&L(3);v<ae;++v)r[v]=n[oe+v]}for(;v<ie;++v)r[v]=r[v-J]}}t.l=w,t.p=Z,t.b=v,t.f=m,w&&(m=1,t.m=S,t.d=b,t.n=P)}while(!m);return v!=r.length&&d?T(r,0,v):r.subarray(0,v)},R=function(e,t,s){s<<=7&t;var r=t/8|0;e[r]|=s,e[r+1]|=s>>8},O=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},N=function(e,t){for(var n=[],i=0;i<e.length;++i)e[i]&&n.push({s:i,f:e[i]});var o=n.length,a=n.slice();if(!o)return{t:G,l:0};if(1==o){var h=new s(n[0].s+1);return h[n[0].s]=1,{t:h,l:1}}n.sort(function(e,t){return e.f-t.f}),n.push({s:-1,f:25001});var l=n[0],c=n[1],d=0,u=1,p=2;for(n[0]={s:-1,f:l.f+c.f,l,r:c};u!=o-1;)l=n[n[d].f<n[p].f?d++:p++],c=n[d!=u&&n[d].f<n[p].f?d++:p++],n[u++]={s:-1,f:l.f+c.f,l,r:c};var f=a[0].s;for(i=1;i<o;++i)a[i].s>f&&(f=a[i].s);var g=new r(f+1),m=U(n[u-1],g,0);if(m>t){i=0;var y=0,x=m-t,v=1<<x;for(a.sort(function(e,t){return g[t.s]-g[e.s]||e.f-t.f});i<o;++i){var w=a[i].s;if(!(g[w]>t))break;y+=v-(1<<m-g[w]),g[w]=t}for(y>>=x;y>0;){var b=a[i].s;g[b]<t?y-=1<<t-g[b]++-1:++i}for(;i>=0&&y;--i){var E=a[i].s;g[E]==t&&(--g[E],++y)}m=t}return{t:new s(g),l:m}},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),n=0,i=e[0],o=1,a=function(e){s[n++]=e},h=1;h<=t;++h)if(e[h]==i&&h!=t)++o;else{if(!i&&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(i),--o;o>6;o-=6)a(8304);o>2&&(a(o-3<<5|8208),o=0)}for(;o--;)a(i);o=1,i=e[h]}return{c:s.subarray(0,n),n:t}},D=function(e,t){for(var s=0,r=0;r<t.length;++r)s+=e[r]*t[r];return s},H=function(e,t,s){var r=s.length,n=I(t+2);e[n]=255&r,e[n+1]=r>>8,e[n+2]=255^e[n],e[n+3]=255^e[n+1];for(var i=0;i<r;++i)e[n+i+4]=s[i];return 8*(n+4+r)},q=function(e,t,s,n,h,l,c,d,u,p,f){R(t,f++,s),++h[256];for(var g=N(h,15),m=g.t,y=g.l,E=N(l,15),_=E.t,C=E.l,A=B(m),k=A.c,I=A.n,T=B(_),P=T.c,L=T.n,M=new r(19),U=0;U<k.length;++U)++M[31&k[U]];for(U=0;U<P.length;++U)++M[31&P[U]];for(var q=N(M,7),j=q.t,G=q.l,$=19;$>4&&!j[a[$-1]];--$);var F,V,z,Y,K=p+5<<3,W=D(h,v)+D(l,w)+c,J=D(h,m)+D(l,_)+c+14+3*$+D(M,j)+2*M[16]+3*M[17]+7*M[18];if(u>=0&&K<=W&&K<=J)return H(t,f,e.subarray(u,u+p));if(R(t,f,1+(J<W)),f+=2,J<W){F=x(m,y,0),V=m,z=x(_,C,0),Y=_;var X=x(j,G,0);for(R(t,f,I-257),R(t,f+5,L-1),R(t,f+10,$-4),f+=14,U=0;U<$;++U)R(t,f+3*U,j[a[U]]);f+=3*$;for(var Q=[k,P],Z=0;Z<2;++Z){var ee=Q[Z];for(U=0;U<ee.length;++U){var te=31&ee[U];R(t,f,X[te]),f+=j[te],te>15&&(R(t,f,ee[U]>>5&127),f+=ee[U]>>12)}}}else F=b,V=v,z=S,Y=w;for(U=0;U<d;++U){var se=n[U];if(se>255){O(t,f,F[257+(te=se>>18&31)]),f+=V[te+257],te>7&&(R(t,f,se>>23&31),f+=i[te]);var re=31&se;O(t,f,z[re]),f+=Y[re],re>3&&(O(t,f,se>>5&8191),f+=o[re])}else O(t,f,F[se]),f+=V[se]}return O(t,f,F[256]),f+V[256]},j=new n([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),G=new s(0),$=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),g=p.subarray(h,p.length-l),m=c.l,y=7&(c.r||0);if(t){y&&(g[0]=c.r>>3);for(var x=j[t-1],v=x>>13,w=8191&x,b=(1<<a)-1,E=c.p||new r(32768),S=c.h||new r(b+1),_=Math.ceil(a/3),C=2*_,A=function(t){return(e[t]^e[t+1]<<_^e[t+2]<<C)&b},k=new n(25e3),P=new r(288),L=new r(32),M=0,R=0,O=c.i||0,N=0,U=c.w||0,B=0;O+2<u;++O){var D=A(O),G=32767&O,$=S[D];if(E[G]=$,S[D]=G,U<=O){var F=u-O;if((M>7e3||N>24576)&&(F>423||!m)){y=q(e,g,0,k,P,L,R,N,B,O-B,y),N=M=R=0,B=O;for(var V=0;V<286;++V)P[V]=0;for(V=0;V<30;++V)L[V]=0}var z=2,Y=0,K=w,W=G-$&32767;if(F>2&&D==A(O-W))for(var J=Math.min(v,F)-1,X=Math.min(32767,O),Q=Math.min(258,F);W<=X&&--K&&G!=$;){if(e[O+z]==e[O+z-W]){for(var Z=0;Z<Q&&e[O+Z]==e[O+Z-W];++Z);if(Z>z){if(z=Z,Y=W,Z>J)break;var ee=Math.min(W,Z-2),te=0;for(V=0;V<ee;++V){var se=O-W+V&32767,re=se-E[se]&32767;re>te&&(te=re,$=se)}}}W+=(G=$)-($=E[G])&32767}if(Y){k[N++]=268435456|d[z]<<18|f[Y];var ne=31&d[z],ie=31&f[Y];R+=i[ne]+o[ie],++P[257+ne],++L[ie],U=O+z,++M}else k[N++]=e[O],++P[e[O]]}}for(O=Math.max(O,U);O<u;++O)k[N++]=e[O],++P[e[O]];y=q(e,g,m,k,P,L,R,N,B,O-B,y),m||(c.r=7&y|g[y/8|0]<<3,y-=7,c.h=S,c.p=E,c.i=O,c.w=U)}else{for(O=c.w||0;O<u+m;O+=65535){var oe=O+65535;oe>=u&&(g[y/8|0]=m,oe=u),y=H(g,y+1,e.subarray(O,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}(),V=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}}},z=function(e,t,r,n,i){if(!i&&(i={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,i.w=o.length}return $(e,null==t.level?6:t.level,null==t.mem?i.l?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):20:12+t.mem,r,n,i)},Y=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},K=function(e,t){return e[t]|e[t+1]<<8},W=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},J=function(e,t){return W(e,t)+4294967296*W(e,t+4)},X=function(e,t,s){for(;s;++t)e[t]=s,s>>>=8};function Q(e,t){return z(e,t||{},0,0)}function Z(e,t){return M(e,{i:2},t&&t.out,t&&t.dictionary)}var ee=function(e,t,r,n){for(var i in e){var o=e[i],a=t+i,h=n;Array.isArray(o)&&(h=Y(n,o[1]),o=o[0]),o instanceof s?r[a]=[o,h]:(r[a+="/"]=[new s(0),h],ee(o,a,r,n))}},te="undefined"!=typeof TextEncoder&&new TextEncoder,se="undefined"!=typeof TextDecoder&&new TextDecoder;try{se.decode(G,{stream:!0})}catch(e){}var re=function(e){for(var t="",s=0;;){var r=e[s++],n=(r>127)+(r>223)+(r>239);if(s+n>e.length)return{s:t,r:T(e,s-1)};n?3==n?(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&n?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 ne(e,t){if(t){for(var r=new s(e.length),n=0;n<e.length;++n)r[n]=e.charCodeAt(n);return r}if(te)return te.encode(e);var i=e.length,o=new s(e.length+(e.length>>1)),a=0,h=function(e){o[a++]=e};for(n=0;n<i;++n){if(a+5>o.length){var l=new s(a+8+(i-n<<1));l.set(o),o=l}var c=e.charCodeAt(n);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(++n))>>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 ie(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 n=re(e),i=n.s;return(s=n.r).length&&L(8),i}var oe=function(e,t){return t+30+K(e,t+26)+K(e,t+28)},ae=function(e,t,s){var r=K(e,t+28),n=ie(e.subarray(t+46,t+46+r),!(2048&K(e,t+8))),i=t+46+r,o=W(e,t+20),a=s&&4294967295==o?he(e,i):[o,W(e,t+24),W(e,t+42)],h=a[0],l=a[1],c=a[2];return[K(e,t+10),h,l,n,i+K(e,t+30)+K(e,t+32),c]},he=function(e,t){for(;1!=K(e,t);t+=4+K(e,t+2));return[J(e,t+12),J(e,t+4),J(e,t+20)]},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,n,i,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|(i<0&&8),e[t++]=n&&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!=i&&(X(e,t,s.crc),X(e,t+4,i<0?-i-2:i),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 g=l[f],m=g.length;X(e,t,+f),X(e,t+2,m),e.set(g,t+4),t+=4+m}return c&&(e.set(a,t),t+=c),t},de=function(e,t,s,r,n){X(e,t,101010256),X(e,t+8,s),X(e,t+10,s),X(e,t+12,r),X(e,t+16,n)};t.zipSync=function(e,t){t||(t={});var r={},n=[];ee(e,"",r,t);var i=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=(_=ne(a)).length,p=c.comment,f=p&&ne(p),g=f&&f.length,m=le(c.extra);u>65535&&L(11);var y=d?Q(l,c):l,x=y.length,v=V();v.p(l),n.push(Y(c,{size:l.length,crc:v.d(),c:y,f:_,m:f,u:u!=a.length||f&&p.length!=g,o:i,compression:d})),i+=30+u+m+x,o+=76+2*(u+m)+(g||0)+x}for(var w=new s(o+22),b=i,E=o-i,S=0;S<n.length;++S){var _=n[S];ce(w,_.o,_,_.f,_.u,_.c.length);var C=30+_.f.length+le(_.extra);w.set(_.c,_.o+C),ce(w,i,_,_.f,_.u,_.c.length,_.o,_.m),i+=16+C+(_.m?_.m.length:0)}return de(w,i,n.length,E,b),w};"function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout&&setTimeout;t.unzipSync=function(e,t){for(var r={},n=e.length-22;101010256!=W(e,n);--n)(!n||e.length-n>65558)&&L(13);var i=K(e,n+8);if(!i)return{};var o=W(e,n+16),a=4294967295==o||65535==i;if(a){var h=W(e,n-12);(a=101075792==W(e,h))&&(i=W(e,h+32),o=W(e,h+48))}for(var l=t&&t.filter,c=0;c<i;++c){var d=ae(e,o,a),u=d[0],p=d[1],f=d[2],g=d[3],m=d[4],y=d[5],x=oe(e,y);o=m,l&&!l({name:g,size:p,originalSize:f,compression:u})||(u?8==u?r[g]=Z(e.subarray(x,x+p),{out:new s(f)}):L(14,"unknown compression type "+u):r[g]=T(e,x,x+p))}return r}}};const t={};let s=function s(r){const n=t[r];if(void 0!==n)return n.exports;const i=t[r]={exports:{}};return e[r].call(i.exports,i,i.exports,s),i.exports}(44);return s=s.default,s})());
|