diff --git a/code/adapters/local.ts b/code/adapters/local.ts index dd080f0..cba27ef 100644 --- a/code/adapters/local.ts +++ b/code/adapters/local.ts @@ -31,6 +31,7 @@ namespace THNK { async prepare(runtimeScene: gdjs.RuntimeScene): Promise { bc.addEventListener("message", this.boundOnBCMessage); bc.postMessage({ message: "connect", from: ownID } as MessageTypes); + window.addEventListener("beforeunload", () => this.close()); } close() { @@ -58,6 +59,7 @@ namespace THNK { async prepare(): Promise { bc.addEventListener("message", this.boundOnBCMessage); + window.addEventListener("beforeunload", () => this.close()); } close() { diff --git a/extensions/THNK.json b/extensions/THNK.json index 1adfd51..855b134 100644 --- a/extensions/THNK.json +++ b/extensions/THNK.json @@ -2,14 +2,24 @@ "author": "", "category": "Network", "extensionNamespace": "", - "fullName": "THNK framework - Preview", + "fullName": "THNK framework - Core", "helpPath": "https://thnk.cloud/docs/getting-started/", "iconUrl": "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAyMy4wLjMsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iSWNvbnMiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4Ig0KCSB2aWV3Qm94PSIwIDAgMzIgMzIiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDMyIDMyOyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+DQo8c3R5bGUgdHlwZT0idGV4dC9jc3MiPg0KCS5zdDB7ZmlsbDpub25lO3N0cm9rZTojMDAwMDAwO3N0cm9rZS13aWR0aDoyO3N0cm9rZS1saW5lY2FwOnJvdW5kO3N0cm9rZS1saW5lam9pbjpyb3VuZDtzdHJva2UtbWl0ZXJsaW1pdDoxMDt9DQo8L3N0eWxlPg0KPGc+DQoJPHBhdGggZD0iTTI2LDE5Yy0xLjIsMC0yLjMsMC4zLTMuMywxaC00LjRjLTEtMC43LTIuMS0xLTMuMy0xYy0zLjMsMC02LDIuNy02LDZzMi43LDYsNiw2YzEuMiwwLDIuMy0wLjMsMy4zLTFoNC40DQoJCWMxLDAuNywyLjEsMSwzLjMsMWMzLjMsMCw2LTIuNyw2LTZTMjkuMywxOSwyNiwxOXogTTE3LDI2aC0xdjFjMCwwLjYtMC40LDEtMSwxcy0xLTAuNC0xLTF2LTFoLTFjLTAuNiwwLTEtMC40LTEtMXMwLjQtMSwxLTFoMXYtMQ0KCQljMC0wLjYsMC40LTEsMS0xczEsMC40LDEsMXYxaDFjMC42LDAsMSwwLjQsMSwxUzE3LjYsMjYsMTcsMjZ6IE0yNS45LDI2LjRjLTAuMSwwLjEtMC4xLDAuMi0wLjIsMC4zYy0wLjEsMC4xLTAuMiwwLjItMC4zLDAuMg0KCQlTMjUuMSwyNywyNSwyN2MtMC4xLDAtMC4zLDAtMC40LTAuMWMtMC4xLDAtMC4yLTAuMS0wLjMtMC4yYy0wLjEtMC4xLTAuMi0wLjItMC4yLTAuM0MyNCwyNi4zLDI0LDI2LjEsMjQsMjZzMC0wLjMsMC4xLTAuNA0KCQljMC4xLTAuMSwwLjEtMC4yLDAuMi0wLjNjMC4xLTAuMSwwLjItMC4yLDAuMy0wLjJjMC40LTAuMiwwLjgtMC4xLDEuMSwwLjJjMC4xLDAuMSwwLjIsMC4yLDAuMiwwLjNjMCwwLjEsMC4xLDAuMywwLjEsMC40DQoJCVMyNiwyNi4zLDI1LjksMjYuNHogTTI3LjksMjQuNGMtMC4xLDAuMS0wLjEsMC4yLTAuMiwwLjNjLTAuMSwwLjEtMC4yLDAuMi0wLjMsMC4yUzI3LjEsMjUsMjcsMjVjLTAuMSwwLTAuMywwLTAuNC0wLjENCgkJYy0wLjEsMC0wLjItMC4xLTAuMy0wLjJDMjYuMSwyNC41LDI2LDI0LjMsMjYsMjRjMC0wLjMsMC4xLTAuNSwwLjMtMC43YzAsMCwwLjEtMC4xLDAuMS0wLjFjMC4xLDAsMC4xLTAuMSwwLjItMC4xDQoJCWMwLjEsMCwwLjEsMCwwLjItMC4xYzAuMSwwLDAuMywwLDAuNCwwYzAuMSwwLDAuMSwwLDAuMiwwLjFjMC4xLDAsMC4xLDAsMC4yLDAuMWMwLDAsMC4xLDAuMSwwLjEsMC4xYzAuMiwwLjIsMC4zLDAuNSwwLjMsMC43DQoJCUMyOCwyNC4xLDI4LDI0LjMsMjcuOSwyNC40eiIvPg0KCTxwYXRoIGQ9Ik0xMy41LDE3LjJjMC4xLTAuNSwwLjEtMSwwLTEuNWMtMC4yLTEuMi0xLjEtMi4xLTIuMi0yLjVjLTAuNi0wLjItMS4zLTAuNC0yLjEtMC41Yy0yLjQtMC41LTUuMS0xLjEtNi4xLTMuMg0KCQlDMi43LDguNywyLjUsOCwyLjMsNy4zQzAuOSw5LjUsMCwxMi4yLDAsMTVjMCw1LjIsMi45LDkuOCw3LjEsMTIuMmMwLTAuMiwwLjEtMC4zLDAuMS0wLjVDNy4xLDI2LjEsNywyNS42LDcsMjUNCgkJQzcsMjEuMSw5LjgsMTcuOSwxMy41LDE3LjJ6Ii8+DQoJPHBhdGggZD0iTTkuNiwxMC43YzAuOCwwLjIsMS42LDAuNCwyLjMsMC42YzEuOCwwLjYsMy4yLDIuMSwzLjUsNGMwLjEsMC42LDAuMSwxLjIsMCwxLjhjMS4yLDAuMSwyLjMsMC40LDMuMywxaDIuOQ0KCQljMS0wLjcsMS44LTEuNiwyLjQtMi42YzEuNC0yLjEsMS43LTYsMS44LTcuN0MyMy41LDMuNywxOS4xLDEsMTQsMUMxMC4xLDEsNi42LDIuNiw0LDUuMmMwLDAuNSwwLjIsMS45LDAuOSwzLjMNCgkJQzUuNSw5LjgsNy43LDEwLjIsOS42LDEwLjd6Ii8+DQoJPHBhdGggZD0iTTI1LjUsMTdjMC4yLDAsMC4zLDAsMC41LDBjMC42LDAsMS4yLDAuMSwxLjgsMC4yYzAuMS0wLjcsMC4yLTEuNSwwLjItMi4yYzAtMS4yLTAuMi0yLjMtMC40LTMuNA0KCQljLTAuMywxLjctMC44LDMuNi0xLjcsNC45QzI1LjcsMTYuNywyNS42LDE2LjksMjUuNSwxN3oiLz4NCjwvZz4NCjwvc3ZnPg0K", "name": "THNK", "previewIconUrl": "https://resources.gdevelop-app.com/assets/Icons/Glyphster Pack/Master/SVG/Videogames/Videogames_online_gaming_games_joystick_connect_globe.svg", - "shortDescription": "A framework too build authoritative multiplayer games. This is a preview version of the THNK Framework.", - "version": "1.0.0-minimal-prototype", - "description": "# The THNK Framework\n\nNote: This preview build is a Minimally Viable Prototype ( not a Mostly Viable prototype :P ), and is therefore highly unstable.\nThe API, protocol, concepts, everything, will probably be changed at some point, and may be full of bugs. Use at your own risk!\n\nThe THNK Framework is a framework for building authoritative multiplayer games in GDevelop.", + "shortDescription": "A framework to build authoritative multiplayer games.", + "version": "1.0.0", + "description": [ + "# The THNK Framework", + "", + "A framework for building authoritative games with GDevelop. In a single click, you can turn your THNK game multiplayer!", + "", + "Games made with THNK multiplayer will, through a mix of imposed rules and a rich set of optimisations & performant features, run fast as state-of-the-art multiplayer games.", + "", + "This - the core THNK extension - allows you to build any game with the authoritative server-client pattern. They will not be multiplayer: by default, all THNK games are single player and will run fine without being connected to anyone else. When/if you want to add multiplayer, THNK servers can be started and connected to in 1 action via the different THNK adapter extensions.", + "", + "Learn more at https://thnk.cloud/ ;)" + ], "tags": [ "multiplayer", "arthuro", @@ -34,7 +44,12 @@ "events": [ { "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": "}// Load THNK library (https://github.com/arthuro555/THNK)\nwindow.THNK=(()=>{var ti=Object.defineProperty;var Qa=Object.getOwnPropertyDescriptor;var Ja=Object.getOwnPropertyNames;var tn=Object.prototype.hasOwnProperty;var en=(t,e)=>{for(var i in e)ti(t,i,{get:e[i],enumerable:!0})},sn=(t,e,i,a)=>{if(e&&typeof e==\"object\"||typeof e==\"function\")for(let s of Ja(e))!tn.call(t,s)&&s!==i&&ti(t,s,{get:()=>e[s],enumerable:!(a=Qa(e,s))||a.enumerable});return t};var an=t=>sn(ti({},\"__esModule\",{value:!0}),t);var Xl={};en(Xl,{ClientAdapter:()=>Yl,ServerAdapter:()=>Gl,client:()=>ua,players:()=>ia,server:()=>Ls,settings:()=>sa});var nn=Object.defineProperty,Ke=(t,e)=>{for(var i in e)nn(t,i,{get:e[i],enumerable:!0})},Ls={};Ke(Ls,{events:()=>Gn,startServer:()=>Yn});var Ct=new Int32Array(2),Zi=new Float32Array(Ct.buffer),Li=new Float64Array(Ct.buffer),Te=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1,wi;(function(t){t[t.UTF8_BYTES=1]=\"UTF8_BYTES\",t[t.UTF16_STRING=2]=\"UTF16_STRING\"})(wi||(wi={}));var jt=class{constructor(t){this.bytes_=t,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(t){return new jt(new Uint8Array(t))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(t){this.position_=t}capacity(){return this.bytes_.length}readInt8(t){return this.readUint8(t)<<24>>24}readUint8(t){return this.bytes_[t]}readInt16(t){return this.readUint16(t)<<16>>16}readUint16(t){return this.bytes_[t]|this.bytes_[t+1]<<8}readInt32(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24}readUint32(t){return this.readInt32(t)>>>0}readInt64(t){return BigInt.asIntN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<>8}writeUint16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeInt32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeUint32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeInt64(t,e){this.writeInt32(t,Number(BigInt.asIntN(32,e))),this.writeInt32(t+4,Number(BigInt.asIntN(32,e>>BigInt(32))))}writeUint64(t,e){this.writeUint32(t,Number(BigInt.asUintN(32,e))),this.writeUint32(t+4,Number(BigInt.asUintN(32,e>>BigInt(32))))}writeFloat32(t,e){Zi[0]=e,this.writeInt32(t,Ct[0])}writeFloat64(t,e){Li[0]=e,this.writeInt32(t,Ct[Te?0:1]),this.writeInt32(t+4,Ct[Te?1:0])}getBufferIdentifier(){if(this.bytes_.lengththis.minalign&&(this.minalign=t);let i=~(this.bb.capacity()-this.space+e)+1&t-1;for(;this.space=0&&this.vtable[e]==0;e--);let i=e+1;for(;e>=0;e--)this.addInt16(this.vtable[e]!=0?t-this.vtable[e]:0);let a=2;this.addInt16(t-this.object_start);let s=(i+a)*2;this.addInt16(s);let n=0,r=this.space;t:for(e=0;e=0;n--)this.writeInt8(s.charCodeAt(n))}this.prep(this.minalign,4+a),this.addOffset(t),a&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,e){this.finish(t,e,!0)}requiredField(t,e){let i=this.bb.capacity()-t,a=i-this.bb.readInt32(i);if(this.bb.readInt16(a+e)==0)throw new Error(\"FlatBuffers: field \"+e+\" must be set\")}startVector(t,e,i){this.notNested(),this.vector_num_elems=e,this.prep(4,t*e),this.prep(i,t*e)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(t){if(!t)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(t))return this.string_maps.get(t);let e=this.createString(t);return this.string_maps.set(t,e),e}createString(t){if(t==null)return 0;let e;t instanceof Uint8Array?e=t:e=this.text_encoder.encode(t),this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length);for(let i=0,a=this.space,s=this.bb.bytes();i=0;i--)t.addInt8(e[i]);return t.endVector()}static startContentVector(t,e){t.startVector(1,e,1)}static endClientInputMessage(t){let e=t.endObject();return t.requiredField(e,4),t.requiredField(e,6),e}static createClientInputMessage(t,e,i){return mt.startClientInputMessage(t),mt.addName(t,e),mt.addContent(t,i),mt.endClientInputMessage(t)}},Tt=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsConnectionRequestMessage(t,e){return(e||new Tt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsConnectionRequestMessage(t,e){return t.setPosition(t.position()+4),(e||new Tt).__init(t.readInt32(t.position())+t.position(),t)}token(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}static startConnectionRequestMessage(t){t.startObject(1)}static addToken(t,e){t.addFieldOffset(0,e,0)}static endConnectionRequestMessage(t){return t.endObject()}static createConnectionRequestMessage(t,e){return Tt.startConnectionRequestMessage(t),Tt.addToken(t,e),Tt.endConnectionRequestMessage(t)}},vt=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsClientMessage(t,e){return(e||new vt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsClientMessage(t,e){return t.setPosition(t.position()+4),(e||new vt).__init(t.readInt32(t.position())+t.position(),t)}contentType(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readUint8(this.bb_pos+t):0}content(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__union(t,this.bb_pos+e):null}static startClientMessage(t){t.startObject(2)}static addContentType(t,e){t.addFieldInt8(0,e,0)}static addContent(t,e){t.addFieldOffset(1,e,0)}static endClientMessage(t){let e=t.endObject();return t.requiredField(e,6),e}static createClientMessage(t,e,i){return vt.startClientMessage(t),vt.addContentType(t,e),vt.addContent(t,i),vt.endClientMessage(t)}},B=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsVariable(t,e){return(e||new B).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsVariable(t,e){return t.setPosition(t.position()+4),(e||new B).__init(t.readInt32(t.position())+t.position(),t)}type(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readUint8(this.bb_pos+t):0}text(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}number(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readFloat32(this.bb_pos+t):0}boolean(){let t=this.bb.__offset(this.bb_pos,10);return t?!!this.bb.readInt8(this.bb_pos+t):!1}operations(t,e){let i=this.bb.__offset(this.bb_pos,12);return i?(e||new W).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+t*4),this.bb):null}operationsLength(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startVariable(t){t.startObject(5)}static addType(t,e){t.addFieldInt8(0,e,0)}static addText(t,e){t.addFieldOffset(1,e,0)}static addNumber(t,e){t.addFieldFloat32(2,e,0)}static addBoolean(t,e){t.addFieldInt8(3,+e,0)}static addOperations(t,e){t.addFieldOffset(4,e,0)}static createOperationsVector(t,e){t.startVector(4,e.length,4);for(let i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startOperationsVector(t,e){t.startVector(4,e,4)}static endVariable(t){return t.endObject()}static createVariable(t,e,i,a,s,n){return B.startVariable(t),B.addType(t,e),B.addText(t,i),B.addNumber(t,a),B.addBoolean(t,s),B.addOperations(t,n),B.endVariable(t)}},W=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsCollectionOperation(t,e){return(e||new W).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsCollectionOperation(t,e){return t.setPosition(t.position()+4),(e||new W).__init(t.readInt32(t.position())+t.position(),t)}operation(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readUint8(this.bb_pos+t):0}name(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}index(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readUint16(this.bb_pos+t):0}val(t){let e=this.bb.__offset(this.bb_pos,10);return e?(t||new B).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startCollectionOperation(t){t.startObject(4)}static addOperation(t,e){t.addFieldInt8(0,e,0)}static addName(t,e){t.addFieldOffset(1,e,0)}static addIndex(t,e){t.addFieldInt16(2,e,0)}static addVal(t,e){t.addFieldOffset(3,e,0)}static endCollectionOperation(t){return t.endObject()}},Ui=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}r(){return this.bb.readUint16(this.bb_pos)}g(){return this.bb.readUint16(this.bb_pos+2)}b(){return this.bb.readUint16(this.bb_pos+4)}static sizeOf(){return 6}static createRGB(t,e,i,a){return t.prep(2,6),t.writeInt16(a),t.writeInt16(i),t.writeInt16(e),t.offset()}},j=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsObjState(t,e){return(e||new j).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsObjState(t,e){return t.setPosition(t.position()+4),(e||new j).__init(t.readInt32(t.position())+t.position(),t)}x(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readFloat32(this.bb_pos+t):null}y(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readFloat32(this.bb_pos+t):null}height(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readFloat32(this.bb_pos+t):null}width(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readFloat32(this.bb_pos+t):null}angle(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.readFloat32(this.bb_pos+t):null}scale(){let t=this.bb.__offset(this.bb_pos,14);return t?this.bb.readFloat32(this.bb_pos+t):null}tint(t){let e=this.bb.__offset(this.bb_pos,16);return e?(t||new Ui).__init(this.bb_pos+e,this.bb):null}setXTo0(){let t=this.bb.__offset(this.bb_pos,18);return t?!!this.bb.readInt8(this.bb_pos+t):!1}setYTo0(){let t=this.bb.__offset(this.bb_pos,20);return t?!!this.bb.readInt8(this.bb_pos+t):!1}setHeightTo0(){let t=this.bb.__offset(this.bb_pos,22);return t?!!this.bb.readInt8(this.bb_pos+t):!1}setWidthTo0(){let t=this.bb.__offset(this.bb_pos,24);return t?!!this.bb.readInt8(this.bb_pos+t):!1}setAngleTo0(){let t=this.bb.__offset(this.bb_pos,26);return t?!!this.bb.readInt8(this.bb_pos+t):!1}setScaleTo0(){let t=this.bb.__offset(this.bb_pos,28);return t?!!this.bb.readInt8(this.bb_pos+t):!1}zOrder(){let t=this.bb.__offset(this.bb_pos,30);return t?this.bb.readUint16(this.bb_pos+t):null}bigZOrder(){let t=this.bb.__offset(this.bb_pos,32);return t?this.bb.readUint32(this.bb_pos+t):null}visible(){let t=this.bb.__offset(this.bb_pos,34);return t?this.bb.readUint8(this.bb_pos+t):null}flippedX(){let t=this.bb.__offset(this.bb_pos,36);return t?this.bb.readUint8(this.bb_pos+t):null}flippedY(){let t=this.bb.__offset(this.bb_pos,38);return t?this.bb.readUint8(this.bb_pos+t):null}opacity(){let t=this.bb.__offset(this.bb_pos,40);return t?this.bb.readUint8(this.bb_pos+t):null}setOpacityTo0(){let t=this.bb.__offset(this.bb_pos,42);return t?!!this.bb.readInt8(this.bb_pos+t):!1}animation(){let t=this.bb.__offset(this.bb_pos,44);return t?this.bb.readUint8(this.bb_pos+t):null}text(t){let e=this.bb.__offset(this.bb_pos,46);return e?this.bb.__string(this.bb_pos+e,t):null}static startObjState(t){t.startObject(22)}static addX(t,e){t.addFieldFloat32(0,e,0)}static addY(t,e){t.addFieldFloat32(1,e,0)}static addHeight(t,e){t.addFieldFloat32(2,e,0)}static addWidth(t,e){t.addFieldFloat32(3,e,0)}static addAngle(t,e){t.addFieldFloat32(4,e,0)}static addScale(t,e){t.addFieldFloat32(5,e,0)}static addTint(t,e){t.addFieldStruct(6,e,0)}static addSetXTo0(t,e){t.addFieldInt8(7,+e,0)}static addSetYTo0(t,e){t.addFieldInt8(8,+e,0)}static addSetHeightTo0(t,e){t.addFieldInt8(9,+e,0)}static addSetWidthTo0(t,e){t.addFieldInt8(10,+e,0)}static addSetAngleTo0(t,e){t.addFieldInt8(11,+e,0)}static addSetScaleTo0(t,e){t.addFieldInt8(12,+e,0)}static addZOrder(t,e){t.addFieldInt16(13,e,0)}static addBigZOrder(t,e){t.addFieldInt32(14,e,0)}static addVisible(t,e){t.addFieldInt8(15,e,0)}static addFlippedX(t,e){t.addFieldInt8(16,e,0)}static addFlippedY(t,e){t.addFieldInt8(17,e,0)}static addOpacity(t,e){t.addFieldInt8(18,e,0)}static addSetOpacityTo0(t,e){t.addFieldInt8(19,+e,0)}static addAnimation(t,e){t.addFieldInt8(20,e,0)}static addText(t,e){t.addFieldOffset(21,e,0)}static endObjState(t){return t.endObject()}},G=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsGameObject(t,e){return(e||new G).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsGameObject(t,e){return t.setPosition(t.position()+4),(e||new G).__init(t.readInt32(t.position())+t.position(),t)}id(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readUint16(this.bb_pos+t):0}name(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}objState(t){let e=this.bb.__offset(this.bb_pos,8);return e?(t||new j).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}publicStateDiff(t){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readUint8(this.bb.__vector(this.bb_pos+e)+t):0}publicStateDiffLength(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}publicStateDiffArray(){let t=this.bb.__offset(this.bb_pos,10);return t?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}privateStateDiff(t){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.readUint8(this.bb.__vector(this.bb_pos+e)+t):0}privateStateDiffLength(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}privateStateDiffArray(){let t=this.bb.__offset(this.bb_pos,12);return t?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}packedPublicState(t){let e=this.bb.__offset(this.bb_pos,14);return e?this.bb.readUint8(this.bb.__vector(this.bb_pos+e)+t):0}packedPublicStateLength(){let t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}packedPublicStateArray(){let t=this.bb.__offset(this.bb_pos,14);return t?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}packedPrivateState(t){let e=this.bb.__offset(this.bb_pos,16);return e?this.bb.readUint8(this.bb.__vector(this.bb_pos+e)+t):0}packedPrivateStateLength(){let t=this.bb.__offset(this.bb_pos,16);return t?this.bb.__vector_len(this.bb_pos+t):0}packedPrivateStateArray(){let t=this.bb.__offset(this.bb_pos,16);return t?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}static startGameObject(t){t.startObject(7)}static addId(t,e){t.addFieldInt16(0,e,0)}static addName(t,e){t.addFieldOffset(1,e,0)}static addObjState(t,e){t.addFieldOffset(2,e,0)}static addPublicStateDiff(t,e){t.addFieldOffset(3,e,0)}static createPublicStateDiffVector(t,e){t.startVector(1,e.length,1);for(let i=e.length-1;i>=0;i--)t.addInt8(e[i]);return t.endVector()}static startPublicStateDiffVector(t,e){t.startVector(1,e,1)}static addPrivateStateDiff(t,e){t.addFieldOffset(4,e,0)}static createPrivateStateDiffVector(t,e){t.startVector(1,e.length,1);for(let i=e.length-1;i>=0;i--)t.addInt8(e[i]);return t.endVector()}static startPrivateStateDiffVector(t,e){t.startVector(1,e,1)}static addPackedPublicState(t,e){t.addFieldOffset(5,e,0)}static createPackedPublicStateVector(t,e){t.startVector(1,e.length,1);for(let i=e.length-1;i>=0;i--)t.addInt8(e[i]);return t.endVector()}static startPackedPublicStateVector(t,e){t.startVector(1,e,1)}static addPackedPrivateState(t,e){t.addFieldOffset(6,e,0)}static createPackedPrivateStateVector(t,e){t.startVector(1,e.length,1);for(let i=e.length-1;i>=0;i--)t.addInt8(e[i]);return t.endVector()}static startPackedPrivateStateVector(t,e){t.startVector(1,e,1)}static endGameObject(t){return t.endObject()}},Q=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsGameStateSnapshot(t,e){return(e||new Q).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsGameStateSnapshot(t,e){return t.setPosition(t.position()+4),(e||new Q).__init(t.readInt32(t.position())+t.position(),t)}objects(t,e){let i=this.bb.__offset(this.bb_pos,4);return i?(e||new G).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+t*4),this.bb):null}objectsLength(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}publicStatePacked(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb.__vector(this.bb_pos+e)+t):0}publicStatePackedLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}publicStatePackedArray(){let t=this.bb.__offset(this.bb_pos,6);return t?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}privateStatePacked(t){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readUint8(this.bb.__vector(this.bb_pos+e)+t):0}privateStatePackedLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}privateStatePackedArray(){let t=this.bb.__offset(this.bb_pos,8);return t?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}static startGameStateSnapshot(t){t.startObject(3)}static addObjects(t,e){t.addFieldOffset(0,e,0)}static createObjectsVector(t,e){t.startVector(4,e.length,4);for(let i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startObjectsVector(t,e){t.startVector(4,e,4)}static addPublicStatePacked(t,e){t.addFieldOffset(1,e,0)}static createPublicStatePackedVector(t,e){t.startVector(1,e.length,1);for(let i=e.length-1;i>=0;i--)t.addInt8(e[i]);return t.endVector()}static startPublicStatePackedVector(t,e){t.startVector(1,e,1)}static addPrivateStatePacked(t,e){t.addFieldOffset(2,e,0)}static createPrivateStatePackedVector(t,e){t.startVector(1,e.length,1);for(let i=e.length-1;i>=0;i--)t.addInt8(e[i]);return t.endVector()}static startPrivateStatePackedVector(t,e){t.startVector(1,e,1)}static endGameStateSnapshot(t){return t.endObject()}static createGameStateSnapshot(t,e,i,a){return Q.startGameStateSnapshot(t),Q.addObjects(t,e),Q.addPublicStatePacked(t,i),Q.addPrivateStatePacked(t,a),Q.endGameStateSnapshot(t)}},Zt=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsConnectionStartMessage(t,e){return(e||new Zt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsConnectionStartMessage(t,e){return t.setPosition(t.position()+4),(e||new Zt).__init(t.readInt32(t.position())+t.position(),t)}sceneName(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}sceneSnapshot(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new Q).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startConnectionStartMessage(t){t.startObject(2)}static addSceneName(t,e){t.addFieldOffset(0,e,0)}static addSceneSnapshot(t,e){t.addFieldOffset(1,e,0)}static endConnectionStartMessage(t){let e=t.endObject();return t.requiredField(e,4),t.requiredField(e,6),e}},Ut=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsCreatedObject(t,e){return(e||new Ut).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsCreatedObject(t,e){return t.setPosition(t.position()+4),(e||new Ut).__init(t.readInt32(t.position())+t.position(),t)}id(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readUint16(this.bb_pos+t):0}name(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}static startCreatedObject(t){t.startObject(2)}static addId(t,e){t.addFieldInt16(0,e,0)}static addName(t,e){t.addFieldOffset(1,e,0)}static endCreatedObject(t){let e=t.endObject();return t.requiredField(e,6),e}static createCreatedObject(t,e,i){return Ut.startCreatedObject(t),Ut.addId(t,e),Ut.addName(t,i),Ut.endCreatedObject(t)}},Y=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsScene(t,e){return(e||new Y).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsScene(t,e){return t.setPosition(t.position()+4),(e||new Y).__init(t.readInt32(t.position())+t.position(),t)}publicStateDiff(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readUint8(this.bb.__vector(this.bb_pos+e)+t):0}publicStateDiffLength(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}publicStateDiffArray(){let t=this.bb.__offset(this.bb_pos,4);return t?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}privateStateDiff(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb.__vector(this.bb_pos+e)+t):0}privateStateDiffLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}privateStateDiffArray(){let t=this.bb.__offset(this.bb_pos,6);return t?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}objects(t,e){let i=this.bb.__offset(this.bb_pos,8);return i?(e||new G).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+t*4),this.bb):null}objectsLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}createdObjects(t,e){let i=this.bb.__offset(this.bb_pos,10);return i?(e||new Ut).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+t*4),this.bb):null}createdObjectsLength(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}deletedObjects(t){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.readUint16(this.bb.__vector(this.bb_pos+e)+t*2):0}deletedObjectsLength(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}deletedObjectsArray(){let t=this.bb.__offset(this.bb_pos,12);return t?new Uint16Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}static startScene(t){t.startObject(5)}static addPublicStateDiff(t,e){t.addFieldOffset(0,e,0)}static createPublicStateDiffVector(t,e){t.startVector(1,e.length,1);for(let i=e.length-1;i>=0;i--)t.addInt8(e[i]);return t.endVector()}static startPublicStateDiffVector(t,e){t.startVector(1,e,1)}static addPrivateStateDiff(t,e){t.addFieldOffset(1,e,0)}static createPrivateStateDiffVector(t,e){t.startVector(1,e.length,1);for(let i=e.length-1;i>=0;i--)t.addInt8(e[i]);return t.endVector()}static startPrivateStateDiffVector(t,e){t.startVector(1,e,1)}static addObjects(t,e){t.addFieldOffset(2,e,0)}static createObjectsVector(t,e){t.startVector(4,e.length,4);for(let i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startObjectsVector(t,e){t.startVector(4,e,4)}static addCreatedObjects(t,e){t.addFieldOffset(3,e,0)}static createCreatedObjectsVector(t,e){t.startVector(4,e.length,4);for(let i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startCreatedObjectsVector(t,e){t.startVector(4,e,4)}static addDeletedObjects(t,e){t.addFieldOffset(4,e,0)}static createDeletedObjectsVector(t,e){t.startVector(2,e.length,2);for(let i=e.length-1;i>=0;i--)t.addInt16(e[i]);return t.endVector()}static startDeletedObjectsVector(t,e){t.startVector(2,e,2)}static endScene(t){return t.endObject()}static createScene(t,e,i,a,s,n){return Y.startScene(t),Y.addPublicStateDiff(t,e),Y.addPrivateStateDiff(t,i),Y.addObjects(t,a),Y.addCreatedObjects(t,s),Y.addDeletedObjects(t,n),Y.endScene(t)}},Ot=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsGameStateUpdateMessage(t,e){return(e||new Ot).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsGameStateUpdateMessage(t,e){return t.setPosition(t.position()+4),(e||new Ot).__init(t.readInt32(t.position())+t.position(),t)}scene(t){let e=this.bb.__offset(this.bb_pos,4);return e?(t||new Y).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startGameStateUpdateMessage(t){t.startObject(1)}static addScene(t,e){t.addFieldOffset(0,e,0)}static endGameStateUpdateMessage(t){return t.endObject()}static createGameStateUpdateMessage(t,e){return Ot.startGameStateUpdateMessage(t),Ot.addScene(t,e),Ot.endGameStateUpdateMessage(t)}},ht=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsResumePreviousSceneMessage(t,e){return(e||new ht).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsResumePreviousSceneMessage(t,e){return t.setPosition(t.position()+4),(e||new ht).__init(t.readInt32(t.position())+t.position(),t)}snapshot(t){let e=this.bb.__offset(this.bb_pos,4);return e?(t||new Q).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}name(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}static startResumePreviousSceneMessage(t){t.startObject(2)}static addSnapshot(t,e){t.addFieldOffset(0,e,0)}static addName(t,e){t.addFieldOffset(1,e,0)}static endResumePreviousSceneMessage(t){return t.endObject()}static createResumePreviousSceneMessage(t,e,i){return ht.startResumePreviousSceneMessage(t),ht.addSnapshot(t,e),ht.addName(t,i),ht.endResumePreviousSceneMessage(t)}},dt=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsSceneSwitchMessage(t,e){return(e||new dt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSceneSwitchMessage(t,e){return t.setPosition(t.position()+4),(e||new dt).__init(t.readInt32(t.position())+t.position(),t)}sceneName(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}isPause(){let t=this.bb.__offset(this.bb_pos,6);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startSceneSwitchMessage(t){t.startObject(2)}static addSceneName(t,e){t.addFieldOffset(0,e,0)}static addIsPause(t,e){t.addFieldInt8(1,+e,0)}static endSceneSwitchMessage(t){let e=t.endObject();return t.requiredField(e,4),e}static createSceneSwitchMessage(t,e,i){return dt.startSceneSwitchMessage(t),dt.addSceneName(t,e),dt.addIsPause(t,i),dt.endSceneSwitchMessage(t)}},ct=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsServerMessage(t,e){return(e||new ct).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsServerMessage(t,e){return t.setPosition(t.position()+4),(e||new ct).__init(t.readInt32(t.position())+t.position(),t)}contentType(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readUint8(this.bb_pos+t):0}content(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__union(t,this.bb_pos+e):null}static startServerMessage(t){t.startObject(2)}static addContentType(t,e){t.addFieldInt8(0,e,0)}static addContent(t,e){t.addFieldOffset(1,e,0)}static endServerMessage(t){let e=t.endObject();return t.requiredField(e,6),e}static createServerMessage(t,e,i){return ct.startServerMessage(t),ct.addContentType(t,e),ct.addContent(t,i),ct.endServerMessage(t)}},yi;try{yi=new TextDecoder}catch{}var v,At,d=0,nt={},M,Ft,lt=0,pt=0,J,It,ot=[],z,Hi={useRecords:!1,mapsAsObjects:!0},Hs=class{},Ys=new Hs;Ys.name=\"MessagePack 0xC1\";var ee=!1,Gs=2;try{new Function(\"\")}catch{Gs=1/0}var He=class{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.sequential&&t.trusted!==!1&&(t.trusted=!0,!t.structures&&t.useRecords!=!1&&(t.structures=[],t.maxSharedStructures||(t.maxSharedStructures=0))),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0)),Object.assign(this,t)}unpack(t,e){if(v)return $s(()=>(vi(),this?this.unpack(t,e):He.prototype.unpack.call(Hi,t,e)));At=e>-1?e:t.length,d=0,pt=0,Ft=null,J=null,v=t;try{z=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(i){throw v=null,t instanceof Uint8Array?i:new Error(\"Source must be a Uint8Array or Buffer but was a \"+(t&&typeof t==\"object\"?t.constructor.name:typeof t))}if(this instanceof He){if(nt=this,this.structures)return M=this.structures,Ve();(!M||M.length>0)&&(M=[])}else nt=Hi,(!M||M.length>0)&&(M=[]);return Ve()}unpackMultiple(t,e){let i,a=0;try{ee=!0;let s=t.length,n=this?this.unpack(t,s):Qs.unpack(t,s);if(e){for(e(n);d=32&&(s.highByte=i-32>>5))}t.sharedLength=t.length;for(let i in e||[])if(i>=0){let a=t[i],s=e[i];s&&(a&&((t.restoreStructures||(t.restoreStructures=[]))[i]=a),t[i]=s)}return this.structures=t}decode(t,e){return this.unpack(t,e)}};function Ve(){try{if(!nt.trusted&&!ee){let e=M.sharedLength||0;eAt)throw new Error(\"Unexpected end of MessagePack data\");if(!ee)throw new Error(\"Data read, but end of buffer not reached \"+JSON.stringify(t).slice(0,100))}return t}catch(t){throw M.restoreStructures&&Yi(),vi(),(t instanceof RangeError||t.message.startsWith(\"Unexpected end of buffer\")||d>At)&&(t.incomplete=!0),t}}function Yi(){for(let t in M.restoreStructures)M[t]=M.restoreStructures[t];M.restoreStructures=null}function X(){let t=v[d++];if(t<160)if(t<128){if(t<64)return t;{let e=M[t&63]||nt.getStructures&&Xs()[t&63];return e?(e.read||(e.read=Ti(e,t&63)),e.read()):t}}else if(t<144)if(t-=128,nt.mapsAsObjects){let e={};for(let i=0;i=d)return Ft.slice(d-lt,(d+=e)-lt);if(pt==0&&At<140){let i=e<16?Vi(e):Ws(e);if(i!=null)return i}return mi(e)}else{let e;switch(t){case 192:return null;case 193:return J?(e=X(),e>0?J[1].slice(J.position1,J.position1+=e):J[0].slice(J.position0,J.position0-=e)):Ys;case 194:return!1;case 195:return!0;case 196:if(e=v[d++],e===void 0)throw new Error(\"Unexpected end of buffer\");return ei(e);case 197:return e=z.getUint16(d),d+=2,ei(e);case 198:return e=z.getUint32(d),d+=4,ei(e);case 199:return Nt(v[d++]);case 200:return e=z.getUint16(d),d+=2,Nt(e);case 201:return e=z.getUint32(d),d+=4,Nt(e);case 202:if(e=z.getFloat32(d),nt.useFloat32>2){let i=Fi[(v[d]&127)<<1|v[d+1]>>7];return d+=4,(i*e+(e>0?.5:-.5)>>0)/i}return d+=4,e;case 203:return e=z.getFloat64(d),d+=8,e;case 204:return v[d++];case 205:return e=z.getUint16(d),d+=2,e;case 206:return e=z.getUint32(d),d+=4,e;case 207:return nt.int64AsNumber?(e=z.getUint32(d)*4294967296,e+=z.getUint32(d+4)):e=z.getBigUint64(d),d+=8,e;case 208:return z.getInt8(d++);case 209:return e=z.getInt16(d),d+=2,e;case 210:return e=z.getInt32(d),d+=4,e;case 211:return nt.int64AsNumber?(e=z.getInt32(d)*4294967296,e+=z.getUint32(d+4)):e=z.getBigInt64(d),d+=8,e;case 212:if(e=v[d++],e==114)return $i(v[d++]&63);{let i=ot[e];if(i)return i.read?(d++,i.read(X())):i.noBuffer?(d++,i()):i(v.subarray(d,++d));throw new Error(\"Unknown extension \"+e)}case 213:return e=v[d],e==114?(d++,$i(v[d++]&63,v[d++])):Nt(2);case 214:return Nt(4);case 215:return Nt(8);case 216:return Nt(16);case 217:return e=v[d++],pt>=d?Ft.slice(d-lt,(d+=e)-lt):on(e);case 218:return e=z.getUint16(d),d+=2,pt>=d?Ft.slice(d-lt,(d+=e)-lt):ln(e);case 219:return e=z.getUint32(d),d+=4,pt>=d?Ft.slice(d-lt,(d+=e)-lt):hn(e);case 220:return e=z.getUint16(d),d+=2,Xi(e);case 221:return e=z.getUint32(d),d+=4,Xi(e);case 222:return e=z.getUint16(d),d+=2,Wi(e);case 223:return e=z.getUint32(d),d+=4,Wi(e);default:if(t>=224)return t-256;if(t===void 0){let i=new Error(\"Unexpected end of MessagePack data\");throw i.incomplete=!0,i}throw new Error(\"Unknown MessagePack token \"+t)}}}var rn=/^[a-zA-Z_$][a-zA-Z\\d_$]*$/;function Ti(t,e){function i(){if(i.count++>Gs){let s=t.read=new Function(\"r\",\"return function(){return {\"+t.map(n=>n===\"__proto__\"?\"__proto_:r()\":rn.test(n)?n+\":r()\":\"[\"+JSON.stringify(n)+\"]:r()\").join(\",\")+\"}}\")(X);return t.highByte===0&&(t.read=Gi(e,t.read)),s()}let a={};for(let s=0,n=t.length;sfunction(){let i=v[d++];if(i===0)return e();let a=t<32?-(t+(i<<5)):t+(i<<5),s=M[a]||Xs()[a];if(!s)throw new Error(\"Record id is not defined for \"+a);return s.read||(s.read=Ti(s,t)),s.read()};function Xs(){let t=$s(()=>(v=null,nt.getStructures()));return M=nt._mergeStructures(t,M)}var mi=Ie,on=Ie,ln=Ie,hn=Ie;function Ie(t){let e;if(t<16&&(e=Vi(t)))return e;if(t>64&&yi)return yi.decode(v.subarray(d,d+=t));let i=d+t,a=[];for(e=\"\";d65535&&(b-=65536,a.push(b>>>10&1023|55296),b=56320|b&1023),a.push(b)}else a.push(s);a.length>=4096&&(e+=q.apply(String,a),a.length=0)}return a.length>0&&(e+=q.apply(String,a)),e}function Xi(t){let e=new Array(t);for(let i=0;i0){d=e;return}i[a]=s}return q.apply(String,i)}function Vi(t){if(t<4)if(t<2){if(t===0)return\"\";{let e=v[d++];if((e&128)>1){d-=1;return}return q(e)}}else{let e=v[d++],i=v[d++];if((e&128)>0||(i&128)>0){d-=2;return}if(t<3)return q(e,i);let a=v[d++];if((a&128)>0){d-=3;return}return q(e,i,a)}else{let e=v[d++],i=v[d++],a=v[d++],s=v[d++];if((e&128)>0||(i&128)>0||(a&128)>0||(s&128)>0){d-=4;return}if(t<6){if(t===4)return q(e,i,a,s);{let n=v[d++];if((n&128)>0){d-=5;return}return q(e,i,a,s,n)}}else if(t<8){let n=v[d++],r=v[d++];if((n&128)>0||(r&128)>0){d-=6;return}if(t<7)return q(e,i,a,s,n,r);let o=v[d++];if((o&128)>0){d-=7;return}return q(e,i,a,s,n,r,o)}else{let n=v[d++],r=v[d++],o=v[d++],b=v[d++];if((n&128)>0||(r&128)>0||(o&128)>0||(b&128)>0){d-=8;return}if(t<10){if(t===8)return q(e,i,a,s,n,r,o,b);{let l=v[d++];if((l&128)>0){d-=9;return}return q(e,i,a,s,n,r,o,b,l)}}else if(t<12){let l=v[d++],h=v[d++];if((l&128)>0||(h&128)>0){d-=10;return}if(t<11)return q(e,i,a,s,n,r,o,b,l,h);let O=v[d++];if((O&128)>0){d-=11;return}return q(e,i,a,s,n,r,o,b,l,h,O)}else{let l=v[d++],h=v[d++],O=v[d++],w=v[d++];if((l&128)>0||(h&128)>0||(O&128)>0||(w&128)>0){d-=12;return}if(t<14){if(t===12)return q(e,i,a,s,n,r,o,b,l,h,O,w);{let _=v[d++];if((_&128)>0){d-=13;return}return q(e,i,a,s,n,r,o,b,l,h,O,w,_)}}else{let _=v[d++],V=v[d++];if((_&128)>0||(V&128)>0){d-=14;return}if(t<15)return q(e,i,a,s,n,r,o,b,l,h,O,w,_,V);let U=v[d++];if((U&128)>0){d-=15;return}return q(e,i,a,s,n,r,o,b,l,h,O,w,_,V,U)}}}}}function Ki(){let t=v[d++],e;if(t<192)e=t-160;else switch(t){case 217:e=v[d++];break;case 218:e=z.getUint16(d),d+=2;break;case 219:e=z.getUint32(d),d+=4;break;default:throw new Error(\"Expected string\")}return Ie(e)}function ei(t){return nt.copyBuffers?Uint8Array.prototype.slice.call(v,d,d+=t):v.subarray(d,d+=t)}function Nt(t){let e=v[d++];if(ot[e])return ot[e](v.subarray(d,d+=t));throw new Error(\"Unknown extension type \"+e)}var qi=new Array(4096);function Ks(){let t=v[d++];if(t>=160&&t<192){if(t=t-160,pt>=d)return Ft.slice(d-lt,(d+=t)-lt);if(!(pt==0&&At<180))return mi(t)}else return d--,X();let e=(t<<5^(t>1?z.getUint16(d):t>0?v[d]:0))&4095,i=qi[e],a=d,s=d+t-3,n,r=0;if(i&&i.bytes==t){for(;a{var i=X();let a=t;e!==void 0&&(t=t<32?-((e<<5)+t):(e<<5)+t,i.highByte=e);let s=M[t];return s&&s.isShared&&((M.restoreStructures||(M.restoreStructures=[]))[t]=s),M[t]=i,i.read=Ti(i,a),i.read()};ot[0]=()=>{};ot[0].noBuffer=!0;ot[101]=()=>{let t=X();return(globalThis[t[0]]||Error)(t[1])};ot[105]=t=>{let e=z.getUint32(d-4);It||(It=new Map);let i=v[d],a;i>=144&&i<160||i==220||i==221?a=[]:a={};let s={target:a};It.set(e,s);let n=X();return s.used?Object.assign(a,n):(s.target=n,n)};ot[112]=t=>{let e=z.getUint32(d-4),i=It.get(e);return i.used=!0,i.target};ot[115]=()=>new Set(X());var qs=[\"Int8\",\"Uint8\",\"Uint8Clamped\",\"Int16\",\"Uint16\",\"Int32\",\"Uint32\",\"Float32\",\"Float64\",\"BigInt64\",\"BigUint64\"].map(t=>t+\"Array\");ot[116]=t=>{let e=t[0],i=qs[e];if(!i)throw new Error(\"Could not find typed array for code \"+e);return new globalThis[i](Uint8Array.prototype.slice.call(t,1).buffer)};ot[120]=()=>{let t=X();return new RegExp(t[0],t[1])};var dn=[];ot[98]=t=>{let e=(t[0]<<24)+(t[1]<<16)+(t[2]<<8)+t[3],i=d;return d+=e-t.length,J=dn,J=[Ki(),Ki()],J.position0=0,J.position1=0,J.postBundlePosition=d,d=i,X()};ot[255]=t=>t.length==4?new Date((t[0]*16777216+(t[1]<<16)+(t[2]<<8)+t[3])*1e3):t.length==8?new Date(((t[0]<<22)+(t[1]<<14)+(t[2]<<6)+(t[3]>>2))/1e6+((t[3]&3)*4294967296+t[4]*16777216+(t[5]<<16)+(t[6]<<8)+t[7])*1e3):t.length==12?new Date(((t[0]<<24)+(t[1]<<16)+(t[2]<<8)+t[3])/1e6+((t[4]&128?-281474976710656:0)+t[6]*1099511627776+t[7]*4294967296+t[8]*16777216+(t[9]<<16)+(t[10]<<8)+t[11])*1e3):new Date(\"invalid\");function $s(t){let e=At,i=d,a=lt,s=pt,n=Ft,r=It,o=J,b=new Uint8Array(v.slice(0,At)),l=M,h=M.slice(0,M.length),O=nt,w=ee,_=t();return At=e,d=i,lt=a,pt=s,Ft=n,It=r,J=o,v=b,ee=w,M=l,M.splice(0,M.length,...h),nt=O,z=new DataView(v.buffer,v.byteOffset,v.byteLength),_}function vi(){v=null,It=null,M=null}var Fi=new Array(147);for(let t=0;t<256;t++)Fi[t]=+(\"1e\"+Math.floor(45.15-t*.30103));var Qs=new He({useRecords:!1}),cn=Qs.unpack,Be;try{Be=new TextEncoder}catch{}var Si,Js,qe=typeof Buffer<\"u\",Fe=qe?function(t){return Buffer.allocUnsafeSlow(t)}:Uint8Array,ta=qe?Buffer:Uint8Array,Qi=qe?4294967296:2144337920,f,oe,H,c=0,it,K=null,bn=61440,un=/[\\u0080-\\uFFFF]/,qt=Symbol(\"record-id\"),fn=class extends He{constructor(t){super(t),this.offset=0;let e,i,a,s,n=0,r=ta.prototype.utf8Write?function(u,S){return f.utf8Write(u,S,4294967295)}:Be&&Be.encodeInto?function(u,S){return Be.encodeInto(u,f.subarray(S)).written}:!1,o=this;t||(t={});let b=t&&t.sequential,l=t.structures||t.saveStructures,h=t.maxSharedStructures;if(h==null&&(h=l?32:0),h>8160)throw new Error(\"Maximum maxSharedStructure is 8160\");t.structuredClone&&t.moreTypes==null&&(t.moreTypes=!0);let O=t.maxOwnStructures;O==null&&(O=l?32:64),!this.structures&&t.useRecords!=!1&&(this.structures=[]);let w=h>32||O+h>64,_=h+64,V=h+O+64;if(V>8256)throw new Error(\"Maximum maxSharedStructure + maxOwnStructure is 8192\");let U=[],x=0,I=0;this.pack=this.encode=function(u,S){if(f||(f=new Fe(8192),H=new DataView(f.buffer,0,8192),c=0),it=f.length-10,it-c<2048?(f=new Fe(f.length),H=new DataView(f.buffer,0,f.length),it=f.length-10,c=0):c=c+7&2147483640,e=c,s=o.structuredClone?new Map:null,o.bundleStrings&&typeof u!=\"string\"?(K=[],K.size=1/0):K=null,a=o.structures,a){a.uninitialized&&(a=o._mergeStructures(o.getStructures()));let p=a.sharedLength||0;if(p>h)throw new Error(\"Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to \"+a.sharedLength);if(!a.transitions){a.transitions=Object.create(null);for(let g=0;git&&A(c),o.offset=c;let p=pn(f.subarray(e,c),s.idsToInsert);return s=null,p}return S&yn?(f.start=e,f.end=c,f):f.subarray(e,c)}finally{if(a){I<10&&I++;let p=a.sharedLength||h;if(a.length>p&&(a.length=p),x>1e4)a.transitions=null,I=0,x=0,U.length>0&&(U=[]);else if(U.length>0&&!b){for(let g=0,y=U.length;g{c>it&&(f=A(c));var S=typeof u,p;if(S===\"string\"){let g=u.length;if(K&&g>=4&&g<4096){if((K.size+=g)>bn){let C,L=(K[0]?K[0].length*3+K[1].length:0)+10;c+L>it&&(f=A(c+L)),K.position?(f[c]=200,c+=3,f[c++]=98,C=c-e,c+=4,es(e,k),H.setUint16(C+e-3,c-e-C)):(f[c++]=214,f[c++]=98,C=c-e,c+=4),K=[\"\",\"\"],K.size=0,K.position=C}let T=un.test(u);K[T?0:1]+=u,f[c++]=193,k(T?-g:g);return}let y;g<32?y=1:g<256?y=2:g<65536?y=3:y=5;let R=g*3;if(c+R>it&&(f=A(c+R)),g<64||!r){let T,C,L,E=c+y;for(T=0;T>6|192,f[E++]=C&63|128):(C&64512)===55296&&((L=u.charCodeAt(T+1))&64512)===56320?(C=65536+((C&1023)<<10)+(L&1023),T++,f[E++]=C>>18|240,f[E++]=C>>12&63|128,f[E++]=C>>6&63|128,f[E++]=C&63|128):(f[E++]=C>>12|224,f[E++]=C>>6&63|128,f[E++]=C&63|128);p=E-c-y}else p=r(u,c+y);p<32?f[c++]=160|p:p<256?(y<2&&f.copyWithin(c+2,c+1,c+1+p),f[c++]=217,f[c++]=p):p<65536?(y<3&&f.copyWithin(c+3,c+2,c+2+p),f[c++]=218,f[c++]=p>>8,f[c++]=p&255):(y<5&&f.copyWithin(c+5,c+3,c+3+p),f[c++]=219,H.setUint32(c,p),c+=4),c+=p}else if(S===\"number\")if(u>>>0===u)u<64||u<128&&this.useRecords===!1?f[c++]=u:u<256?(f[c++]=204,f[c++]=u):u<65536?(f[c++]=205,f[c++]=u>>8,f[c++]=u&255):(f[c++]=206,H.setUint32(c,u),c+=4);else if(u>>0===u)u>=-32?f[c++]=256+u:u>=-128?(f[c++]=208,f[c++]=u+256):u>=-32768?(f[c++]=209,H.setInt16(c,u),c+=2):(f[c++]=210,H.setInt32(c,u),c+=4);else{let g;if((g=this.useFloat32)>0&&u<4294967296&&u>=-2147483648){f[c++]=202,H.setFloat32(c,u);let y;if(g<4||(y=u*Fi[(f[c]&127)<<1|f[c+1]>>7])>>0===y){c+=4;return}else c--}f[c++]=203,H.setFloat64(c,u),c+=8}else if(S===\"object\")if(!u)f[c++]=192;else{if(s){let y=s.get(u);if(y){if(!y.id){let R=s.idsToInsert||(s.idsToInsert=[]);y.id=R.push(y)}f[c++]=214,f[c++]=112,H.setUint32(c,y.id),c+=4;return}else s.set(u,{offset:c-e})}let g=u.constructor;if(g===Object)m(u,!0);else if(g===Array){p=u.length,p<16?f[c++]=144|p:p<65536?(f[c++]=220,f[c++]=p>>8,f[c++]=p&255):(f[c++]=221,H.setUint32(c,p),c+=4);for(let y=0;y>8,f[c++]=p&255):(f[c++]=223,H.setUint32(c,p),c+=4);for(let[y,R]of u)k(y),k(R)}else{for(let y=0,R=Si.length;y(f=L,L=null,c+=re,c>it&&A(c),{target:f,targetView:H,position:c-re}),k)}finally{L&&(f=L,H=E,c=at,it=f.length-10)}Et&&(Et.length+c>it&&A(Et.length+c),c=_n(Et,f,c,C.type));return}}m(u,!u.hasOwnProperty)}}else if(S===\"boolean\")f[c++]=u?195:194;else if(S===\"bigint\"){if(u=-(BigInt(1)<0)f[c++]=207,H.setBigUint64(c,u);else if(this.largeBigIntToFloat)f[c++]=203,H.setFloat64(c,Number(u));else throw new RangeError(u+\" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64\");c+=8}else if(S===\"undefined\")this.encodeUndefinedAsNil?f[c++]=192:(f[c++]=212,f[c++]=0,f[c++]=0);else if(S===\"function\")k(this.writeFunction&&this.writeFunction());else throw new Error(\"Unknown type: \"+S)},m=this.useRecords===!1?this.variableMapSize?u=>{let S=Object.keys(u),p=S.length;p<16?f[c++]=128|p:p<65536?(f[c++]=222,f[c++]=p>>8,f[c++]=p&255):(f[c++]=223,H.setUint32(c,p),c+=4);let g;for(let y=0;y{f[c++]=222;let p=c-e;c+=2;let g=0;for(let y in u)(S||u.hasOwnProperty(y))&&(k(y),k(u[y]),g++);f[p+++e]=g>>8,f[p+e]=g&255}:t.progressiveRecords&&!w?(u,S)=>{let p,g=a.transitions||(a.transitions=Object.create(null)),y=c++-e,R;for(let T in u)if(S||u.hasOwnProperty(T)){if(p=g[T],p)g=p;else{let C=Object.keys(u),L=g;g=a.transitions;let E=0;for(let at=0,Et=C.length;at{let p,g=a.transitions||(a.transitions=Object.create(null)),y=0;for(let T in u)(S||u.hasOwnProperty(T))&&(p=g[T],p||(p=g[T]=Object.create(null),y++),g=p);let R=g[qt];R?R>=96&&w?(f[c++]=((R-=96)&31)+96,f[c++]=R>>5):f[c++]=R:Z(g,g.__keys__||Object.keys(u),y);for(let T in u)(S||u.hasOwnProperty(T))&&k(u[T])},A=u=>{let S;if(u>16777216){if(u-e>Qi)throw new Error(\"Packed buffer would be larger than maximum buffer size\");S=Math.min(Qi,Math.round(Math.max((u-e)*(u>67108864?1.25:2),4194304)/4096)*4096)}else S=(Math.max(u-e<<2,f.length-1)>>12)+1<<12;let p=new Fe(S);return H=new DataView(p.buffer,0,S),u=Math.min(u,f.length),f.copy?f.copy(p,0,e,u):p.set(f.slice(e,u)),c-=e,e=0,it=p.length-10,f=p},Z=(u,S,p)=>{let g=a.nextId;g||(g=64),g<_&&this.shouldShareStructure&&!this.shouldShareStructure(S)?(g=a.nextOwnId,g=V&&(g=_),a.nextId=g+1);let y=S.highByte=g>=96&&w?g-96>>5:-1;u[qt]=g,u.__keys__=S,a[g-64]=S,g<_?(S.isShared=!0,a.sharedLength=g-63,i=!0,y>=0?(f[c++]=(g&31)+96,f[c++]=y):f[c++]=g):(y>=0?(f[c++]=213,f[c++]=114,f[c++]=(g&31)+96,f[c++]=y):(f[c++]=212,f[c++]=114,f[c++]=g),p&&(x+=I*p),U.length>=O&&(U.shift()[qt]=0),U.push(u),k(S))},F=(u,S,p,g)=>{let y=f,R=c,T=it,C=e;f=oe,c=0,e=0,f||(oe=f=new Fe(8192)),it=f.length-10,Z(u,S,g),oe=f;let L=c;if(f=y,c=R,it=T,e=C,L>1){let E=c+L-1;E>it&&A(E);let at=p+e;f.copyWithin(at+L,at+1,c),f.set(oe.slice(0,L),at),c=E}else f[p+e]=oe[0]}}useBuffer(t){f=t,H=new DataView(f.buffer,f.byteOffset,f.byteLength),c=0}clearSharedData(){this.structures&&(this.structures=[])}};Js=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Hs];Si=[{pack(t,e,i){let a=t.getTime()/1e3;if((this.useTimestamp32||t.getMilliseconds()===0)&&a>=0&&a<4294967296){let{target:s,targetView:n,position:r}=e(6);s[r++]=214,s[r++]=255,n.setUint32(r,a)}else if(a>0&&a<4294967296){let{target:s,targetView:n,position:r}=e(10);s[r++]=215,s[r++]=255,n.setUint32(r,t.getMilliseconds()*4e6+(a/1e3/4294967296>>0)),n.setUint32(r+4,a)}else if(isNaN(a)){if(this.onInvalidDate)return e(0),i(this.onInvalidDate());let{target:s,targetView:n,position:r}=e(3);s[r++]=212,s[r++]=255,s[r++]=255}else{let{target:s,targetView:n,position:r}=e(15);s[r++]=199,s[r++]=12,s[r++]=255,n.setUint32(r,t.getMilliseconds()*1e6),n.setBigInt64(r+4,BigInt(Math.floor(a)))}}},{pack(t,e,i){let a=Array.from(t),{target:s,position:n}=e(this.moreTypes?3:0);this.moreTypes&&(s[n++]=212,s[n++]=115,s[n++]=0),i(a)}},{pack(t,e,i){let{target:a,position:s}=e(this.moreTypes?3:0);this.moreTypes&&(a[s++]=212,a[s++]=101,a[s++]=0),i([t.name,t.message])}},{pack(t,e,i){let{target:a,position:s}=e(this.moreTypes?3:0);this.moreTypes&&(a[s++]=212,a[s++]=120,a[s++]=0),i([t.source,t.flags])}},{pack(t,e){this.moreTypes?Ji(t,16,e):ts(qe?Buffer.from(t):new Uint8Array(t),e)}},{pack(t,e){let i=t.constructor;i!==ta&&this.moreTypes?Ji(t,qs.indexOf(i.name),e):ts(t,e)}},{pack(t,e){let{target:i,position:a}=e(1);i[a]=193}}];function Ji(t,e,i,a){let s=t.byteLength;if(s+1<256){var{target:n,position:r}=i(4+s);n[r++]=199,n[r++]=s+1}else if(s+1<65536){var{target:n,position:r}=i(5+s);n[r++]=200,n[r++]=s+1>>8,n[r++]=s+1&255}else{var{target:n,position:r,targetView:o}=i(7+s);n[r++]=201,o.setUint32(r,s+1),r+=4}n[r++]=116,n[r++]=e,n.set(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),r)}function ts(t,e){let i=t.byteLength;var a,s;if(i<256){var{target:a,position:s}=e(i+2);a[s++]=196,a[s++]=i}else if(i<65536){var{target:a,position:s}=e(i+3);a[s++]=197,a[s++]=i>>8,a[s++]=i&255}else{var{target:a,position:s,targetView:n}=e(i+5);a[s++]=198,n.setUint32(s,i),s+=4}a.set(t,s)}function _n(t,e,i,a){let s=t.length;switch(s){case 1:e[i++]=212;break;case 2:e[i++]=213;break;case 4:e[i++]=214;break;case 8:e[i++]=215;break;case 16:e[i++]=216;break;default:s<256?(e[i++]=199,e[i++]=s):s<65536?(e[i++]=200,e[i++]=s>>8,e[i++]=s&255):(e[i++]=201,e[i++]=s>>24,e[i++]=s>>16&255,e[i++]=s>>8&255,e[i++]=s&255)}return e[i++]=a,e.set(t,i),i+=s,i}function pn(t,e){let i,a=e.length*6,s=t.length-a;for(e.sort((n,r)=>n.offset>r.offset?1:-1);i=e.pop();){let n=i.offset,r=i.id;t.copyWithin(n+a,n,s),a-=6;let o=n+a;t[o++]=214,t[o++]=105,t[o++]=r>>24,t[o++]=r>>16&255,t[o++]=r>>8&255,t[o++]=r&255,s=n}return t}function es(t,e){if(K.length>0){H.setUint32(K.position+t,c-K.position-t);let i=K;K=null,e(i[0]),e(i[1])}}var gn=new fn({useRecords:!1}),wn=gn.pack,yn=512,mn=1024,_e=t=>wn(t.toJSObject()),pe=(t,e)=>t.fromJSObject(cn(e)),ea=(t,e,i)=>{if(!e.thnkServer)return-1;let{stateVariables:a,objectsRegistery:s}=e.thnkServer,{publicStateVariable:n,privateStateVariable:r}=a,o=n.getChildrenCount()!==0?Q.createPublicStatePackedVector(t,_e(n)):null,b=r.getChild(i),l=b.getChildrenCount()!==0?Q.createPrivateStatePackedVector(t,_e(b)):null,h=s.createObjectsSnapshot(t,i),O=h.length?Q.createObjectsVector(t,h):null;return Q.startGameStateSnapshot(t),o&&Q.addPublicStatePacked(t,o),l&&Q.addPrivateStatePacked(t,l),O&&Q.addObjects(t,O),Q.endGameStateSnapshot(t)},vn=(t,e,i)=>{let a=new Bt(512),s=a.createString(i.getName()),n=ea(a,i,t);Zt.startConnectionStartMessage(a),Zt.addSceneName(a,s),Zt.addSceneSnapshot(a,n),e.sendServerMessageTo(t,a,ct.createServerMessage(a,1,Zt.endConnectionStartMessage(a)))},Sn=(t,e,i)=>{let a=new Bt(256),s=i.serialize(a,t);if(!s)return;Ot.startGameStateUpdateMessage(a),Ot.addScene(a,s);let n=Ot.endGameStateUpdateMessage(a);e.sendServerMessageTo(t,a,ct.createServerMessage(a,2,n))},kn=(t,e,i)=>{let a=new Bt(512),s=a.createString(e);dt.startSceneSwitchMessage(a),dt.addSceneName(a,s),dt.addIsPause(a,i),t.sendServerMessageToAll(a,ct.createServerMessage(a,3,dt.endSceneSwitchMessage(a)))},ii=(t,e,i)=>{for(let a of t){let s=new Bt(512),n=i?s.createString(i.getName()):null,r=i?ea(s,i,a):null;ht.startResumePreviousSceneMessage(s),r&&n&&(ht.addSnapshot(s,r),ht.addName(s,n));let o=ct.createServerMessage(s,4,ht.endResumePreviousSceneMessage(s));e.sendServerMessageTo(a,s,o)}},ia={};Ke(ia,{getCurrentPlayerID:()=>On,markObjectAsOwned:()=>An,pickOwnedObjects:()=>In,switchPlayerContext:()=>Ye});var ge=\"\",ki=new Map,On=()=>ge,Ye=t=>{ge=t},An=t=>{let e=ki.get(ge);e||ki.set(ge,e=new gdjs.LongLivedObjectsList),e.addObject(t.getName(),t)},In=t=>{let e=ki.get(ge);if(!e){for(let i of Object.values(t.items))i.length=0;return!1}for(let[i,a]of Object.entries(t.items))gdjs.copyArray(e.getObjects(i),a);return!0},is=new Map,Di=t=>{let e=is.get(t);return e||is.set(t,e=[]),e},jn=(t,e,i)=>{Di(e).push({initiatorUserID:t,serializedExtraData:i})},xn=(t,e,i)=>{Di(e).push({initiatorUserID:t,extraData:i})},Cn=(t,e)=>{let i=Di(t);if(i.length){let a=i.shift();return Ye(a.initiatorUserID),a.serializedExtraData?pe(e,a.serializedExtraData):a.extraData&&gdjs.Variable.copy(a.extraData,e),!0}return!1},Un=t=>{var e;return!!((e=t.thnkServer)!=null&&e.playerManager.popConnection())},Tn=t=>{var e;return!!((e=t.thnkServer)!=null&&e.playerManager.popDisconnection())},sa={};Ke(sa,{getTickRate:()=>Ri,isDedicated:()=>ra,setDedicated:()=>Vn,setTickRate:()=>Fn});var aa=!1,na=120,Vn=()=>{aa=!0},Fn=t=>{na=Math.max(1,t)},Ri=()=>na,ra=()=>aa,st=class extends gdjs.Variable{constructor(){super(...arguments),this.dirty=!0,this.operations=[]}static setupSyncedVariable(t,e){let i=new st;return t.has(e)&&gdjs.Variable.copy(t.get(e),i),t.add(e,i),i}static setupStateVariables(t){let e=st.setupSyncedVariable(t,\"State\"),i=st.setupSyncedVariable(t,\"PlayerState\"),a=st.setupSyncedVariable(t,\"TeamState\");return{publicStateVariable:e,privateStateVariable:i,teamStateVariable:a}}reinitialize(t){if(this._type=\"number\",this._value=0,this._str=\"0\",this._bool=!1,this._children={},this._childrenArray=[],this._undefinedInContainer=!1,t!==void 0){if(this._type=t.type||\"number\",this._type===\"number\")this._value=parseFloat(t.value||\"0\"),this._value!==this._value&&(this._value=0);else if(this._type===\"string\")this._str=\"\"+t.value||\"0\";else if(this._type===\"boolean\")this._bool=!!t.value;else if(this._type===\"structure\"){if(t.children!==void 0)for(var e=0,i=t.children.length;e{let[i,a,s]=e.split(\";\").map(n=>parseInt(n,10));return Ui.createRGB(t,i,a,s)},Rn=(t,e,i)=>{let a=e.getString?t.createSharedString(e.getString()):null;j.startObjState(t),j.addX(t,e.getX()),j.addY(t,e.getY()),j.addHeight(t,e.getHeight()),j.addWidth(t,e.getWidth()),j.addAngle(t,e.getAngle()),e.getX()===0&&j.addSetXTo0(t,!0),e.getY()===0&&j.addSetYTo0(t,!0),e.getHeight()===0&&j.addSetHeightTo0(t,!0),e.getWidth()===0&&j.addSetWidthTo0(t,!0),e.getAngle()===0&&j.addSetAngleTo0(t,!0),e.getZOrder()<=65535?j.addZOrder(t,e.getZOrder()+1):j.addBigZOrder(t,e.getZOrder()+1),j.addVisible(t,e.isHidden()?1:2),e.isFlippedX&&j.addFlippedX(t,e.isFlippedX()?1:2),e.isFlippedY&&j.addFlippedY(t,e.isFlippedY()?1:2),e.getOpacity&&(e.getOpacity()!==0?j.addOpacity(t,e.getOpacity()):j.addSetOpacityTo0(t,!0)),e.getAnimation&&j.addAnimation(t,e.getAnimation()+1),e.getColor&&j.addTint(t,oa(t,e.getColor())),a&&j.addText(t,a);let s=j.endObjState(t),{stateVariables:n}=e,{publicStateVariable:r,privateStateVariable:o}=n,b=r.getChildrenCount()!==0?G.createPackedPublicStateVector(t,_e(r)):null,l=o.getChild(i),h=l.getChildrenCount()!==0?G.createPackedPrivateStateVector(t,_e(l)):null,O=t.createSharedString(e.getName());return G.startGameObject(t),G.addId(t,e.thnkID),G.addName(t,O),G.addObjState(t,s),b&&G.addPackedPublicState(t,b),h&&G.addPackedPrivateState(t,h),G.endGameObject(t)},Pn=new gdjs.Logger(\"THNK - Objects replication\"),zn=class{constructor(){this.recycledIDs=[],this.currentNewID=1,this.generateNewID=()=>{let t=this.recycledIDs.pop()??this.currentNewID++;return t>65535?(Pn.error(\"Maximum amount of simultaneously replicated objects reached! Weird stuff is going to happen...\"),t%65535):t},this.registeredObjects=new Map,this.createdObjects=new Map,this.deletedObjects=new Set}forEach(t){for(let e of this.registeredObjects.values())t(e)}registerObject(t){t.thnkID=this.generateNewID(),this.registeredObjects.set(t.thnkID,t),this.createdObjects.set(t.thnkID,t.getName()),t.stateVariables=st.setupStateVariables(t.getVariables())}unregisterObject(t){this.recycledIDs.push(t.thnkID),this.registeredObjects.delete(t.thnkID),this.deletedObjects.add(t.thnkID),this.createdObjects.delete(t.thnkID)}createObjectsSnapshot(t,e){let i=[];for(let a of this.registeredObjects.values())i.push(Rn(t,a,e));return i}getCreatedObjects(){let t=[...this.createdObjects.entries()];return this.createdObjects.clear(),t}getDeletedObjects(){let t=Uint16Array.from(this.deletedObjects.values());return this.deletedObjects.clear(),t}},Mn=class{constructor(){this.currentDiff=0,this.diffsCount=Math.min(30,Ri()*4),this.diffs=new Array(this.diffsCount)}createSnapshot(t){let e=la.createDiff(t);return e&&(this.diffs[++this.currentDiff%this.diffsCount]=e),e}getSnapshot(t){return this.currentDiff-t>this.diffsCount?null:this.diffs[t%this.diffsCount]}},la=class{constructor(){}static createDiff(t){let e=ha.createDiff(t);if(!e)return null;let i=new la;return i.sceneDiff=e,i}serialize(t,e){var i;return(i=this.sceneDiff)==null?void 0:i.serialize(t,e)}},ha=class{constructor(){this.privateStateVariablesDiffs=new Map,this.teamStateVariablesDiffs=new Map,this.objectsDiff=new Map,this.deletedObjects=new Set,this.createdObjects=new Map}static createDiff(t){let{thnkServer:e}=t;if(!e)throw new Error(\"Impossible to take a diff snapshot when not running a THNK server!\");let{stateVariables:i,objectsRegistery:a}=e,{publicStateVariable:s,privateStateVariable:n,teamStateVariable:r}=i,o=new ha;s.isDirty()&&(o.publicStateVariableDiff=s.serializeToBinary());{let b=n.getAllChildren();for(let l in b)b[l].isDirty()&&o.privateStateVariablesDiffs.set(l,b[l].serializeToBinary())}{let b=r.getAllChildren();for(let l in b)b[l].isDirty()&&o.teamStateVariablesDiffs.set(l,b[l].serializeToBinary())}a.forEach(b=>{let l=da.createDiff(b);l&&o.objectsDiff.set(b.thnkID,l)});for(let[b,l]of a.getCreatedObjects())o.createdObjects.set(b,l);for(let b of a.getDeletedObjects())o.deletedObjects.add(b);return o}serialize(t,e){let i=this.publicStateVariableDiff?Y.createPublicStateDiffVector(t,this.publicStateVariableDiff):null,a=this.privateStateVariablesDiffs.get(e),s=a?Y.createPrivateStateDiffVector(t,a):null,n=[];for(let l of this.objectsDiff.values())l.needsToBeSerialized(e)&&n.push(l.serialize(t,e));let r=n.length?Y.createObjectsVector(t,n):null,o=null;if(this.createdObjects.size){let l=new Uint16Array(this.createdObjects.size),h=0;for(let[O,w]of this.createdObjects){let _=t.createSharedString(w);l[h++]=Ut.createCreatedObject(t,O,_)}o=Y.createCreatedObjectsVector(t,l)}let b=this.deletedObjects.size?Y.createDeletedObjectsVector(t,[...this.deletedObjects]):null;return Y.startScene(t),i&&Y.addPublicStateDiff(t,i),s&&Y.addPrivateStateDiff(t,s),r&&Y.addObjects(t,r),o&&Y.addCreatedObjects(t,o),b&&Y.addDeletedObjects(t,b),Y.endScene(t)}},da=class{constructor(t,e){this.privateStateVariablesDiffs=new Map,this.teamStateVariablesDiffs=new Map,this.propertyChanged=!1,this.id=t,this.aabb=e}static createDiff(t){let e=new da(t.thnkID,t.getVisibilityAABB()||t.getAABB());t.getX()!==t.prevX&&(t.prevX=t.getX(),e.propertyChanged=!0,e.x=t.getX()),t.getY()!==t.prevY&&(t.prevY=t.getY(),e.propertyChanged=!0,e.y=t.getY()),t.getHeight()!==t.prevHeight&&(t.prevHeight=t.getHeight(),e.propertyChanged=!0,e.height=t.getHeight()),t.getWidth()!==t.prevWidth&&(t.prevWidth=t.getWidth(),e.propertyChanged=!0,e.width=t.getWidth()),t.getAngle()!==t.prevAngle&&(t.prevAngle=t.getAngle(),e.propertyChanged=!0,e.angle=t.getAngle()),t.getZOrder()!==t.prevZOrder&&(t.prevZOrder=t.getZOrder(),e.propertyChanged=!0,e.zOrder=t.getZOrder()),t.isHidden()!==t.prevVisibility&&(t.prevVisibility=t.isHidden(),e.propertyChanged=!0,e.hidden=t.isHidden()),t.isFlippedX&&t.isFlippedX()!==t.prevFlippedX&&(t.prevFlippedX=t.isFlippedX(),e.propertyChanged=!0,e.flippedX=t.isFlippedX()),t.isFlippedY&&t.isFlippedY()!==t.prevFlippedY&&(t.prevFlippedY=t.isFlippedY(),e.propertyChanged=!0,e.flippedY=t.isFlippedY()),t.getOpacity&&t.getOpacity()!==t.prevOpacity&&(t.prevOpacity=t.getOpacity(),e.propertyChanged=!0,e.opacity=t.getOpacity()),t.getString&&t.getString()!==t.prevText&&(t.prevText=t.getString(),e.propertyChanged=!0,e.string=t.getString()),t.getColor&&t.getColor()!==t.prevColor&&(t.prevColor=t.getColor(),e.propertyChanged=!0,e.color=t.getColor()),t.getAnimation&&t.getAnimation()!==t.prevAnimation&&(t.prevAnimation=t.getAnimation(),e.propertyChanged=!0,e.animation=t.getAnimation());let{publicStateVariable:i,privateStateVariable:a,teamStateVariable:s}=t.stateVariables;i.isDirty()&&(e.publicStateVariableDiff=i.serializeToBinary());{let n=a.getAllChildren();for(let r in n)n[r].isDirty()&&e.privateStateVariablesDiffs.set(r,n[r].serializeToBinary())}{let n=s.getAllChildren();for(let r in n)n[r].isDirty()&&e.teamStateVariablesDiffs.set(r,n[r].serializeToBinary())}return e.propertyChanged||e.publicStateVariableDiff||e.privateStateVariablesDiffs.size||e.teamStateVariablesDiffs.size?e:null}needsToBeSerialized(t){return this.propertyChanged||this.publicStateVariableDiff||this.privateStateVariablesDiffs.has(t)}serialize(t,e){let i=this.string!==void 0?t.createSharedString(this.string):null;this.propertyChanged&&(j.startObjState(t),this.x!==void 0&&(this.x===0?j.addSetXTo0(t,!0):j.addX(t,this.x)),this.y!==void 0&&(this.y===0?j.addSetYTo0(t,!0):j.addY(t,this.y)),this.height!==void 0&&(this.height===0?j.addSetHeightTo0(t,!0):j.addHeight(t,this.height)),this.width!==void 0&&(this.width===0?j.addSetWidthTo0(t,!0):j.addWidth(t,this.width)),this.angle!==void 0&&(this.angle===0?j.addSetAngleTo0(t,!0):j.addAngle(t,this.angle)),this.zOrder!==void 0&&(this.zOrder<=65535?j.addZOrder(t,this.zOrder+1):j.addBigZOrder(t,this.zOrder+1)),this.hidden!==void 0&&j.addVisible(t,this.hidden?1:2),this.flippedX!==void 0&&j.addFlippedX(t,this.flippedX?1:2),this.flippedY!==void 0&&j.addFlippedY(t,this.flippedY?1:2),this.opacity!==void 0&&(this.opacity===0?j.addSetOpacityTo0(t,!0):j.addOpacity(t,this.opacity)),this.animation!==void 0&&j.addAnimation(t,this.animation+1),i&&j.addText(t,i),this.color!==void 0&&j.addTint(t,oa(t,this.color)));let a=this.propertyChanged?j.endObjState(t):null,s=this.publicStateVariableDiff?G.createPublicStateDiffVector(t,this.publicStateVariableDiff):null,n=this.privateStateVariablesDiffs.get(e),r=n?G.createPrivateStateDiffVector(t,n):null;return G.startGameObject(t),G.addId(t,this.id),a&&G.addObjState(t,a),s&&G.addPublicStateDiff(t,s),r&&G.addPrivateStateDiff(t,r),G.endGameObject(t)}},Bn=class{constructor(t,e){this.objectsRegistery=new zn,this.playerManager=new Dn,this.runServerCode=!0,this.snapshotsManager=new Mn,this.adapter=t,this.stateVariables=e}},ca=(t,e)=>{t.thnkServer=new Bn(e,st.setupStateVariables(t.getVariables())),ra()||t.thnkServer.playerManager._onConnect(e.getServerID())},Oi=new gdjs.Logger(\"THNK - Server\"),si=0,En=t=>{if(!t.thnkServer)return;let{adapter:e}=t.thnkServer;for(let[a,s]of e.getUsersPendingMessages()){for(let n of s)switch(n.contentType()){case 1:if(t.thnkServer.playerManager.alreadyHas(a))continue;vn(a,e,t),t.thnkServer.playerManager._onConnect(a);continue;case 2:let r=n.content(new mt),o=r.name();if(!o)continue;let b=r.contentArray();jn(a,o,b);continue;default:Oi.error(`Received message with unknown type '${n.contentType()}'`);continue}s.length=0}for(let a of e.getDisconnectedUsers())t.thnkServer.playerManager._onDisconnect(a);e.getDisconnectedUsers().length=0;let i=t.getTimeManager();si+=i.getElapsedTime()/i.getTimeScale(),si>1e3/Ri()&&(si=0,t.thnkServer.runServerCode=!0);{let a=t.thnkServer.adapter.getServerID(),s=r=>{let o=r.getChild(a).getAllChildren();for(let b in o)r.addChild(b,o[b])},{privateStateVariable:n}=t.thnkServer.stateVariables;s(n),t.thnkServer.objectsRegistery.forEach(r=>s(r.getVariables().get(\"PlayerState\")))}},Nn=t=>{if(!t.thnkServer||!t.thnkServer.runServerCode)return;t.thnkServer.runServerCode=!1;let{snapshotsManager:e}=t.thnkServer,i=e.createSnapshot(t);if(i)for(let a of t.thnkServer.playerManager.connectedPlayers.values())Sn(a,t.thnkServer.adapter,i)},Jt=null,ba=(t,e)=>{if(t.thnkServer){let{adapter:i}=t.thnkServer;Jt={adapter:i,isPause:e},e&&(t.thnkServer.previouslyConnectedUsers=new Set(i.getConnectedUsers()))}},Zn=t=>{if(Jt){let{adapter:e,isPause:i}=Jt;ca(t,e);for(let a of e.getConnectedUsers())t.thnkServer.playerManager._onConnect(a);kn(e,t.getName(),i),Jt=null}},Ln=t=>{if(Jt)if(t.thnkServer){let{adapter:e,previouslyConnectedUsers:i}=t.thnkServer;if(i){let a=[],s=[];for(let n of e.getConnectedUsers())i.has(n)?s.push(n):a.push(n);ii(a,e,t),ii(s,e)}else Oi.warn(\"List of previously connected players not found! A full snapshot will be sent to all players. This is likely a bug, please open an issue on the THNK GitHub page!\"),ii([...e.getConnectedUsers()],e,t)}else Oi.warn(\"Resumed a scene that is not a server, shutting the server down. This is likely a bug, please open an issue on the THNK GitHub page!\"),Jt.adapter.close()};gdjs.registerRuntimeScenePreEventsCallback(En);gdjs.registerRuntimeScenePostEventsCallback(Nn);gdjs.registerRuntimeSceneUnloadedCallback(t=>ba(t,!1));gdjs.registerRuntimeScenePausedCallback(t=>ba(t,!0));gdjs.registerRuntimeSceneLoadedCallback(Zn);gdjs.registerRuntimeSceneResumedCallback(Ln);var Hn=new gdjs.Logger(\"THNK - Server\"),Yn=async(t,e,i)=>{try{await t.prepare(e)}catch(s){Hn.error(\"Adapter crashed while starting server! Error: \",s);return}let a=i?e.getGame().getSceneStack().replace(i,!0):e;ca(a,t)},Gn={popMessage:Cn,addRawMessageToTheQueue:xn,popConnection:Un,popDisconnection:Tn},ua={};Ke(ua,{getConnectionState:()=>Qn,messages:()=>sr,startClient:()=>ir});var ie=(t,e)=>{switch(e.type()){case 1:return t.setString(e.text()),t;case 2:return t.setNumber(e.number()),t;case 3:return t.setBoolean(e.boolean()),t}if(e.type()===4){t.castTo(\"structure\");for(let i=e.operationsLength(),a=0,s=e.operations(0);a{let i=t.objState();if(i){let o=i.x();o!==null&&e.setX(o);let b=i.y();b!==null&&e.setY(b);let l=i.height();l!==null&&e.setHeight(l);let h=i.width();h!==null&&e.setWidth(h);let O=i.angle();O!==null&&e.setAngle(O),i.setXTo0()&&e.setX(0),i.setYTo0()&&e.setY(0),i.setHeightTo0()&&e.setHeight(0),i.setWidthTo0()&&e.setWidth(0),i.setAngleTo0()&&e.setAngle(0);{let x=i.visible();x!==null&&e.hide(x===1);let I=i.flippedX();I!==null&&e.flipX&&e.flipX(I===1);let k=i.flippedY();k!==null&&e.flipY&&e.flipY(k===1)}let w=i.zOrder()??i.bigZOrder();w!==null&&e.setZOrder(w-1);let _=i.opacity();e.setOpacity&&(_!==null&&e.setOpacity(_),i.setOpacityTo0()&&e.setOpacity(0));let V=i.animation();V!==null&&e.setAnimation&&e.setAnimation(V-1);let U=i.text();if(U!==null&&e.setString&&e.setString(U),e.setColor){let x=i.tint(Xn);x&&e.setColor(`${x.r()};${x.g()};${x.b()}`)}}let a=e.getVariables().get(\"State\"),s=t.publicStateDiffArray();if(s)ie(a,B.getRootAsVariable(new jt(s)));else{let o=t.packedPublicStateArray();o&&pe(a,o)}let n=e.getVariables().get(\"PlayerState\"),r=t.privateStateDiffArray();if(r)ie(n,B.getRootAsVariable(new jt(r)));else{let o=t.packedPrivateStateArray();o&&pe(n,o)}},_a=(t,e)=>{if(!e.thnkClient)return;let{objectsRegistery:i}=e.thnkClient,a=t.publicStatePackedArray();a&&pe(e.getVariables().get(\"State\"),a);let s=t.privateStatePackedArray();if(s&&pe(e.getVariables().get(\"PlayerState\"),s),i.clear(),t.objectsLength()!==0)for(let n=t.objectsLength(),r=0,o=t.objects(0);r{if(!e.thnkClient)return;let{objectsRegistery:i}=e.thnkClient,a=t.publicStateDiffArray();a&&ie(e.getVariables().get(\"State\"),B.getRootAsVariable(new jt(a)));let s=t.privateStateDiffArray();s&&ie(e.getVariables().get(\"PlayerState\"),B.getRootAsVariable(new jt(s)));let n=t.deletedObjectsArray();if(n)for(let r of n)i.deleteObject(r);if(t.createdObjectsLength()!==0)for(let r=t.createdObjectsLength(),o=0,b=t.createdObjects(0);o{if(!t.thnkClient)return;let{adapter:e}=t.thnkClient;for(let i of e.getPendingMessages())switch(i.contentType()){case 1:ss.warn(\"A second ConnectionStartMessage was received from the server. This is likely a bug, please open an issue on the THNK GitHub!\");continue;case 2:let a=i.content(new Ot).scene();a&&Wn(a,t);continue;case 3:let s=i.content(new dt),n=s.sceneName();if(!n){console.error(\"Server requested scene switch, but no scene name was sent! This is likely a bug, please open an issue on the THNK GitHub!\");continue}let r=s.isPause()?t.getGame().getSceneStack().push(n):t.getGame().getSceneStack().replace(n,!0);r.thnkClient=t.thnkClient,t=r;continue;case 4:let o=i.content(new ht),b=o.name(),l=null;try{l=b?t.getGame().getSceneStack().replace(b,!0):t.getGame().getSceneStack().pop()}catch{console.info(\"Error spotted!\")}if(!l)continue;let h=o.snapshot();h&&_a(h,l),l.thnkClient=t.thnkClient,t=l;continue;default:ss.error(`Received message with unknown type '${i.contentType()}'`)}e.markPendingMessagesAsRead()};gdjs.registerRuntimeScenePreEventsCallback(Kn);var qn=(t,e)=>{let i=new Bt(32),a=e?i.createString(e):null;Tt.startConnectionRequestMessage(i),a&&Tt.addToken(i,a);let s=Tt.endConnectionRequestMessage(i);t.sendClientMessage(i,vt.createClientMessage(i,1,s))},$n=(t,e,i)=>{let a=new Bt(256),s=a.createString(e),n=mt.createContentVector(a,_e(i)),r=mt.createClientInputMessage(a,s,n);t.sendClientMessage(a,vt.createClientMessage(a,2,r))},pa=\"disconnected\",ce=t=>pa=t,Qn=()=>pa,Jn=class{constructor(t){this.objectsRegistery=new Map,this.runtimeScene=t}registerObject(t,e){e.thnkID=t,this.objectsRegistery.set(t,e)}getObject(t){return this.objectsRegistery.get(t)}deleteObject(t){let e=this.objectsRegistery.get(t);!e||(e.deleteFromScene(this.runtimeScene),this.objectsRegistery.delete(t))}clear(){this.objectsRegistery.forEach(t=>t.deleteFromScene(this.runtimeScene)),this.objectsRegistery.clear()}},tr=class{constructor(t,e){this.adapter=t,this.objectsRegistery=new Jn(e)}},er=new gdjs.Logger(\"THNK - Client\"),as=t=>{ce(\"failed\"),er.error(\"Connection failed: \"+t)},ir=async(t,e)=>{ce(\"connecting\");let i=t.getGame().getSceneStack();try{await e.prepare(t)}catch{as(\"Adapter crashed while starting server!\");return}ce(\"loading\"),qn(e);let a=setInterval(()=>{let s=e.getPendingMessages().shift();if(!!s&&s.contentType()===1){clearInterval(a);let n=s.content(new Zt),r=n.sceneName(),o=n.sceneSnapshot();if(!r||!o){as(\"Server Connection Start Message was invalid, couldn't finish setting up the connection.\");return}let b=i.replace(r,!0);b.thnkClient=new tr(e,b),_a(o,b),ce(\"connected\")}},200)},sr={sendClientMessage:$n};function se(t){let e=t.length;for(;--e>=0;)t[e]=0}var ar=0,ga=1,nr=2,rr=3,or=258,Pi=29,je=256,we=je+1+Pi,te=30,zi=19,wa=2*we+1,Lt=15,ai=16,lr=7,Mi=256,ya=16,ma=17,va=18,Ai=new Uint8Array([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]),Ee=new Uint8Array([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]),hr=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Sa=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),dr=512,St=new Array((we+2)*2);se(St);var be=new Array(te*2);se(be);var ye=new Array(dr);se(ye);var me=new Array(or-rr+1);se(me);var Bi=new Array(Pi);se(Bi);var Ge=new Array(te);se(Ge);function ni(t,e,i,a,s){this.static_tree=t,this.extra_bits=e,this.extra_base=i,this.elems=a,this.max_length=s,this.has_stree=t&&t.length}var ka,Oa,Aa;function ri(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}var Ia=t=>t<256?ye[t]:ye[256+(t>>>7)],ve=(t,e)=>{t.pending_buf[t.pending++]=e&255,t.pending_buf[t.pending++]=e>>>8&255},rt=(t,e,i)=>{t.bi_valid>ai-i?(t.bi_buf|=e<>ai-t.bi_valid,t.bi_valid+=i-ai):(t.bi_buf|=e<{rt(t,i[e*2],i[e*2+1])},ja=(t,e)=>{let i=0;do i|=t&1,t>>>=1,i<<=1;while(--e>0);return i>>>1},cr=t=>{t.bi_valid===16?(ve(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=t.bi_buf&255,t.bi_buf>>=8,t.bi_valid-=8)},br=(t,e)=>{let i=e.dyn_tree,a=e.max_code,s=e.stat_desc.static_tree,n=e.stat_desc.has_stree,r=e.stat_desc.extra_bits,o=e.stat_desc.extra_base,b=e.stat_desc.max_length,l,h,O,w,_,V,U=0;for(w=0;w<=Lt;w++)t.bl_count[w]=0;for(i[t.heap[t.heap_max]*2+1]=0,l=t.heap_max+1;lb&&(w=b,U++),i[h*2+1]=w,!(h>a)&&(t.bl_count[w]++,_=0,h>=o&&(_=r[h-o]),V=i[h*2],t.opt_len+=V*(w+_),n&&(t.static_len+=V*(s[h*2+1]+_)));if(U!==0){do{for(w=b-1;t.bl_count[w]===0;)w--;t.bl_count[w]--,t.bl_count[w+1]+=2,t.bl_count[b]--,U-=2}while(U>0);for(w=b;w!==0;w--)for(h=t.bl_count[w];h!==0;)O=t.heap[--l],!(O>a)&&(i[O*2+1]!==w&&(t.opt_len+=(w-i[O*2+1])*i[O*2],i[O*2+1]=w),h--)}},xa=(t,e,i)=>{let a=new Array(Lt+1),s=0,n,r;for(n=1;n<=Lt;n++)a[n]=s=s+i[n-1]<<1;for(r=0;r<=e;r++){let o=t[r*2+1];o!==0&&(t[r*2]=ja(a[o]++,o))}},ur=()=>{let t,e,i,a,s,n=new Array(Lt+1);for(i=0,a=0;a>=7;a{let e;for(e=0;e{t.bi_valid>8?ve(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},fr=(t,e,i,a)=>{Ua(t),a&&(ve(t,i),ve(t,~i)),t.pending_buf.set(t.window.subarray(e,e+i),t.pending),t.pending+=i},ns=(t,e,i,a)=>{let s=e*2,n=i*2;return t[s]{let a=t.heap[i],s=i<<1;for(;s<=t.heap_len&&(s{let a,s,n=0,r,o;if(t.last_lit!==0)do a=t.pending_buf[t.d_buf+n*2]<<8|t.pending_buf[t.d_buf+n*2+1],s=t.pending_buf[t.l_buf+n],n++,a===0?gt(t,s,e):(r=me[s],gt(t,r+je+1,e),o=Ai[r],o!==0&&(s-=Bi[r],rt(t,s,o)),a--,r=Ia(a),gt(t,r,i),o=Ee[r],o!==0&&(a-=Ge[r],rt(t,a,o)));while(n{let i=e.dyn_tree,a=e.stat_desc.static_tree,s=e.stat_desc.has_stree,n=e.stat_desc.elems,r,o,b=-1,l;for(t.heap_len=0,t.heap_max=wa,r=0;r>1;r>=1;r--)oi(t,i,r);l=n;do r=t.heap[1],t.heap[1]=t.heap[t.heap_len--],oi(t,i,1),o=t.heap[1],t.heap[--t.heap_max]=r,t.heap[--t.heap_max]=o,i[l*2]=i[r*2]+i[o*2],t.depth[l]=(t.depth[r]>=t.depth[o]?t.depth[r]:t.depth[o])+1,i[r*2+1]=i[o*2+1]=l,t.heap[1]=l++,oi(t,i,1);while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],br(t,e),xa(i,b,t.bl_count)},os=(t,e,i)=>{let a,s=-1,n,r=e[0*2+1],o=0,b=7,l=4;for(r===0&&(b=138,l=3),e[(i+1)*2+1]=65535,a=0;a<=i;a++)n=r,r=e[(a+1)*2+1],!(++o{let a,s=-1,n,r=e[0*2+1],o=0,b=7,l=4;for(r===0&&(b=138,l=3),a=0;a<=i;a++)if(n=r,r=e[(a+1)*2+1],!(++o{let e;for(os(t,t.dyn_ltree,t.l_desc.max_code),os(t,t.dyn_dtree,t.d_desc.max_code),Ii(t,t.bl_desc),e=zi-1;e>=3&&t.bl_tree[Sa[e]*2+1]===0;e--);return t.opt_len+=3*(e+1)+5+5+4,e},pr=(t,e,i,a)=>{let s;for(rt(t,e-257,5),rt(t,i-1,5),rt(t,a-4,4),s=0;s{let e=4093624447,i;for(i=0;i<=31;i++,e>>>=1)if(e&1&&t.dyn_ltree[i*2]!==0)return 0;if(t.dyn_ltree[9*2]!==0||t.dyn_ltree[10*2]!==0||t.dyn_ltree[13*2]!==0)return 1;for(i=32;i{hs||(ur(),hs=!0),t.l_desc=new ri(t.dyn_ltree,ka),t.d_desc=new ri(t.dyn_dtree,Oa),t.bl_desc=new ri(t.bl_tree,Aa),t.bi_buf=0,t.bi_valid=0,Ca(t)},Ta=(t,e,i,a)=>{rt(t,(ar<<1)+(a?1:0),3),fr(t,e,i,!0)},yr=t=>{rt(t,ga<<1,3),gt(t,Mi,St),cr(t)},mr=(t,e,i,a)=>{let s,n,r=0;t.level>0?(t.strm.data_type===2&&(t.strm.data_type=gr(t)),Ii(t,t.l_desc),Ii(t,t.d_desc),r=_r(t),s=t.opt_len+3+7>>>3,n=t.static_len+3+7>>>3,n<=s&&(s=n)):s=n=i+5,i+4<=s&&e!==-1?Ta(t,e,i,a):t.strategy===4||n===s?(rt(t,(ga<<1)+(a?1:0),3),rs(t,St,be)):(rt(t,(nr<<1)+(a?1:0),3),pr(t,t.l_desc.max_code+1,t.d_desc.max_code+1,r+1),rs(t,t.dyn_ltree,t.dyn_dtree)),Ca(t),a&&Ua(t)},vr=(t,e,i)=>(t.pending_buf[t.d_buf+t.last_lit*2]=e>>>8&255,t.pending_buf[t.d_buf+t.last_lit*2+1]=e&255,t.pending_buf[t.l_buf+t.last_lit]=i&255,t.last_lit++,e===0?t.dyn_ltree[i*2]++:(t.matches++,e--,t.dyn_ltree[(me[i]+je+1)*2]++,t.dyn_dtree[Ia(e)*2]++),t.last_lit===t.lit_bufsize-1),Sr=wr,kr=Ta,Or=mr,Ar=vr,Ir=yr,jr={_tr_init:Sr,_tr_stored_block:kr,_tr_flush_block:Or,_tr_tally:Ar,_tr_align:Ir},xr=(t,e,i,a)=>{let s=t&65535|0,n=t>>>16&65535|0,r=0;for(;i!==0;){r=i>2e3?2e3:i,i-=r;do s=s+e[a++]|0,n=n+s|0;while(--r);s%=65521,n%=65521}return s|n<<16|0},Se=xr,Cr=()=>{let t,e=[];for(var i=0;i<256;i++){t=i;for(var a=0;a<8;a++)t=t&1?3988292384^t>>>1:t>>>1;e[i]=t}return e},Ur=new Uint32Array(Cr()),Tr=(t,e,i,a)=>{let s=Ur,n=a+i;t^=-1;for(let r=a;r>>8^s[(t^e[r])&255];return t^-1},$=Tr,Yt={2:\"need dictionary\",1:\"stream end\",0:\"\",\"-1\":\"file error\",\"-2\":\"stream error\",\"-3\":\"data error\",\"-4\":\"insufficient memory\",\"-5\":\"buffer error\",\"-6\":\"incompatible version\"},ae={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},{_tr_init:Vr,_tr_stored_block:Fr,_tr_flush_block:Dr,_tr_tally:Pt,_tr_align:Rr}=jr,{Z_NO_FLUSH:Kt,Z_PARTIAL_FLUSH:Pr,Z_FULL_FLUSH:zr,Z_FINISH:zt,Z_BLOCK:ds,Z_OK:wt,Z_STREAM_END:cs,Z_STREAM_ERROR:bt,Z_DATA_ERROR:Mr,Z_BUF_ERROR:li,Z_DEFAULT_COMPRESSION:Br,Z_FILTERED:Er,Z_HUFFMAN_ONLY:De,Z_RLE:Nr,Z_FIXED:Zr,Z_DEFAULT_STRATEGY:Lr,Z_UNKNOWN:Hr,Z_DEFLATED:$e}=ae,Yr=9,Gr=15,Xr=8,Wr=29,Kr=256,ji=Kr+1+Wr,qr=30,$r=19,Qr=2*ji+1,Jr=15,D=3,Dt=258,ut=Dt+D+1,to=32,Qe=42,xi=69,Ne=73,Ze=91,Le=103,Ht=113,he=666,tt=1,xe=2,Gt=3,ne=4,eo=3,Rt=(t,e)=>(t.msg=Yt[e],e),bs=t=>(t<<1)-(t>4?9:0),Vt=t=>{let e=t.length;for(;--e>=0;)t[e]=0},io=(t,e,i)=>(e<{let e=t.state,i=e.pending;i>t.avail_out&&(i=t.avail_out),i!==0&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+i),t.next_out),t.next_out+=i,e.pending_out+=i,t.total_out+=i,t.avail_out-=i,e.pending-=i,e.pending===0&&(e.pending_out=0))},et=(t,e)=>{Dr(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,xt(t.strm)},P=(t,e)=>{t.pending_buf[t.pending++]=e},le=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=e&255},so=(t,e,i,a)=>{let s=t.avail_in;return s>a&&(s=a),s===0?0:(t.avail_in-=s,e.set(t.input.subarray(t.next_in,t.next_in+s),i),t.state.wrap===1?t.adler=Se(t.adler,e,s,i):t.state.wrap===2&&(t.adler=$(t.adler,e,s,i)),t.next_in+=s,t.total_in+=s,s)},Va=(t,e)=>{let i=t.max_chain_length,a=t.strstart,s,n,r=t.prev_length,o=t.nice_match,b=t.strstart>t.w_size-ut?t.strstart-(t.w_size-ut):0,l=t.window,h=t.w_mask,O=t.prev,w=t.strstart+Dt,_=l[a+r-1],V=l[a+r];t.prev_length>=t.good_match&&(i>>=2),o>t.lookahead&&(o=t.lookahead);do if(s=e,!(l[s+r]!==V||l[s+r-1]!==_||l[s]!==l[a]||l[++s]!==l[a+1])){a+=2,s++;do;while(l[++a]===l[++s]&&l[++a]===l[++s]&&l[++a]===l[++s]&&l[++a]===l[++s]&&l[++a]===l[++s]&&l[++a]===l[++s]&&l[++a]===l[++s]&&l[++a]===l[++s]&&ar){if(t.match_start=e,r=n,n>=o)break;_=l[a+r-1],V=l[a+r]}}while((e=O[e&h])>b&&--i!==0);return r<=t.lookahead?r:t.lookahead},Xt=t=>{let e=t.w_size,i,a,s,n,r;do{if(n=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-ut)){t.window.set(t.window.subarray(e,e+e),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,a=t.hash_size,i=a;do s=t.head[--i],t.head[i]=s>=e?s-e:0;while(--a);a=e,i=a;do s=t.prev[--i],t.prev[i]=s>=e?s-e:0;while(--a);n+=e}if(t.strm.avail_in===0)break;if(a=so(t.strm,t.window,t.strstart+t.lookahead,n),t.lookahead+=a,t.lookahead+t.insert>=D)for(r=t.strstart-t.insert,t.ins_h=t.window[r],t.ins_h=Mt(t,t.ins_h,t.window[r+1]);t.insert&&(t.ins_h=Mt(t,t.ins_h,t.window[r+D-1]),t.prev[r&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=r,r++,t.insert--,!(t.lookahead+t.insert{let i=65535;for(i>t.pending_buf_size-5&&(i=t.pending_buf_size-5);;){if(t.lookahead<=1){if(Xt(t),t.lookahead===0&&e===Kt)return tt;if(t.lookahead===0)break}t.strstart+=t.lookahead,t.lookahead=0;let a=t.block_start+i;if((t.strstart===0||t.strstart>=a)&&(t.lookahead=t.strstart-a,t.strstart=a,et(t,!1),t.strm.avail_out===0)||t.strstart-t.block_start>=t.w_size-ut&&(et(t,!1),t.strm.avail_out===0))return tt}return t.insert=0,e===zt?(et(t,!0),t.strm.avail_out===0?Gt:ne):(t.strstart>t.block_start&&(et(t,!1),t.strm.avail_out),tt)},hi=(t,e)=>{let i,a;for(;;){if(t.lookahead=D&&(t.ins_h=Mt(t,t.ins_h,t.window[t.strstart+D-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),i!==0&&t.strstart-i<=t.w_size-ut&&(t.match_length=Va(t,i)),t.match_length>=D)if(a=Pt(t,t.strstart-t.match_start,t.match_length-D),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=D){t.match_length--;do t.strstart++,t.ins_h=Mt(t,t.ins_h,t.window[t.strstart+D-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart;while(--t.match_length!==0);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=Mt(t,t.ins_h,t.window[t.strstart+1]);else a=Pt(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(a&&(et(t,!1),t.strm.avail_out===0))return tt}return t.insert=t.strstart{let i,a,s;for(;;){if(t.lookahead=D&&(t.ins_h=Mt(t,t.ins_h,t.window[t.strstart+D-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=D-1,i!==0&&t.prev_length4096)&&(t.match_length=D-1)),t.prev_length>=D&&t.match_length<=t.prev_length){s=t.strstart+t.lookahead-D,a=Pt(t,t.strstart-1-t.prev_match,t.prev_length-D),t.lookahead-=t.prev_length-1,t.prev_length-=2;do++t.strstart<=s&&(t.ins_h=Mt(t,t.ins_h,t.window[t.strstart+D-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart);while(--t.prev_length!==0);if(t.match_available=0,t.match_length=D-1,t.strstart++,a&&(et(t,!1),t.strm.avail_out===0))return tt}else if(t.match_available){if(a=Pt(t,0,t.window[t.strstart-1]),a&&et(t,!1),t.strstart++,t.lookahead--,t.strm.avail_out===0)return tt}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(a=Pt(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart{let i,a,s,n,r=t.window;for(;;){if(t.lookahead<=Dt){if(Xt(t),t.lookahead<=Dt&&e===Kt)return tt;if(t.lookahead===0)break}if(t.match_length=0,t.lookahead>=D&&t.strstart>0&&(s=t.strstart-1,a=r[s],a===r[++s]&&a===r[++s]&&a===r[++s])){n=t.strstart+Dt;do;while(a===r[++s]&&a===r[++s]&&a===r[++s]&&a===r[++s]&&a===r[++s]&&a===r[++s]&&a===r[++s]&&a===r[++s]&&st.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=D?(i=Pt(t,1,t.match_length-D),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(i=Pt(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),i&&(et(t,!1),t.strm.avail_out===0))return tt}return t.insert=0,e===zt?(et(t,!0),t.strm.avail_out===0?Gt:ne):t.last_lit&&(et(t,!1),t.strm.avail_out===0)?tt:xe},ro=(t,e)=>{let i;for(;;){if(t.lookahead===0&&(Xt(t),t.lookahead===0)){if(e===Kt)return tt;break}if(t.match_length=0,i=Pt(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,i&&(et(t,!1),t.strm.avail_out===0))return tt}return t.insert=0,e===zt?(et(t,!0),t.strm.avail_out===0?Gt:ne):t.last_lit&&(et(t,!1),t.strm.avail_out===0)?tt:xe};function _t(t,e,i,a,s){this.good_length=t,this.max_lazy=e,this.nice_length=i,this.max_chain=a,this.func=s}var de=[new _t(0,0,0,0,ao),new _t(4,4,8,4,hi),new _t(4,5,16,8,hi),new _t(4,6,32,32,hi),new _t(4,4,16,16,$t),new _t(8,16,32,32,$t),new _t(8,16,128,128,$t),new _t(8,32,128,256,$t),new _t(32,128,258,1024,$t),new _t(32,258,258,4096,$t)],oo=t=>{t.window_size=2*t.w_size,Vt(t.head),t.max_lazy_match=de[t.level].max_lazy,t.good_match=de[t.level].good_length,t.nice_match=de[t.level].nice_length,t.max_chain_length=de[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=D-1,t.match_available=0,t.ins_h=0};function lo(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=$e,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(Qr*2),this.dyn_dtree=new Uint16Array((2*qr+1)*2),this.bl_tree=new Uint16Array((2*$r+1)*2),Vt(this.dyn_ltree),Vt(this.dyn_dtree),Vt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(Jr+1),this.heap=new Uint16Array(2*ji+1),Vt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*ji+1),Vt(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}var Fa=t=>{if(!t||!t.state)return Rt(t,bt);t.total_in=t.total_out=0,t.data_type=Hr;let e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?Qe:Ht,t.adler=e.wrap===2?0:1,e.last_flush=Kt,Vr(e),wt},Da=t=>{let e=Fa(t);return e===wt&&oo(t.state),e},ho=(t,e)=>!t||!t.state||t.state.wrap!==2?bt:(t.state.gzhead=e,wt),Ra=(t,e,i,a,s,n)=>{if(!t)return bt;let r=1;if(e===Br&&(e=6),a<0?(r=0,a=-a):a>15&&(r=2,a-=16),s<1||s>Yr||i!==$e||a<8||a>15||e<0||e>9||n<0||n>Zr)return Rt(t,bt);a===8&&(a=9);let o=new lo;return t.state=o,o.strm=t,o.wrap=r,o.gzhead=null,o.w_bits=a,o.w_size=1<Ra(t,e,$e,Gr,Xr,Lr),bo=(t,e)=>{let i,a;if(!t||!t.state||e>ds||e<0)return t?Rt(t,bt):bt;let s=t.state;if(!t.output||!t.input&&t.avail_in!==0||s.status===he&&e!==zt)return Rt(t,t.avail_out===0?li:bt);s.strm=t;let n=s.last_flush;if(s.last_flush=e,s.status===Qe)if(s.wrap===2)t.adler=0,P(s,31),P(s,139),P(s,8),s.gzhead?(P(s,(s.gzhead.text?1:0)+(s.gzhead.hcrc?2:0)+(s.gzhead.extra?4:0)+(s.gzhead.name?8:0)+(s.gzhead.comment?16:0)),P(s,s.gzhead.time&255),P(s,s.gzhead.time>>8&255),P(s,s.gzhead.time>>16&255),P(s,s.gzhead.time>>24&255),P(s,s.level===9?2:s.strategy>=De||s.level<2?4:0),P(s,s.gzhead.os&255),s.gzhead.extra&&s.gzhead.extra.length&&(P(s,s.gzhead.extra.length&255),P(s,s.gzhead.extra.length>>8&255)),s.gzhead.hcrc&&(t.adler=$(t.adler,s.pending_buf,s.pending,0)),s.gzindex=0,s.status=xi):(P(s,0),P(s,0),P(s,0),P(s,0),P(s,0),P(s,s.level===9?2:s.strategy>=De||s.level<2?4:0),P(s,eo),s.status=Ht);else{let r=$e+(s.w_bits-8<<4)<<8,o=-1;s.strategy>=De||s.level<2?o=0:s.level<6?o=1:s.level===6?o=2:o=3,r|=o<<6,s.strstart!==0&&(r|=to),r+=31-r%31,s.status=Ht,le(s,r),s.strstart!==0&&(le(s,t.adler>>>16),le(s,t.adler&65535)),t.adler=1}if(s.status===xi)if(s.gzhead.extra){for(i=s.pending;s.gzindex<(s.gzhead.extra.length&65535)&&!(s.pending===s.pending_buf_size&&(s.gzhead.hcrc&&s.pending>i&&(t.adler=$(t.adler,s.pending_buf,s.pending-i,i)),xt(t),i=s.pending,s.pending===s.pending_buf_size));)P(s,s.gzhead.extra[s.gzindex]&255),s.gzindex++;s.gzhead.hcrc&&s.pending>i&&(t.adler=$(t.adler,s.pending_buf,s.pending-i,i)),s.gzindex===s.gzhead.extra.length&&(s.gzindex=0,s.status=Ne)}else s.status=Ne;if(s.status===Ne)if(s.gzhead.name){i=s.pending;do{if(s.pending===s.pending_buf_size&&(s.gzhead.hcrc&&s.pending>i&&(t.adler=$(t.adler,s.pending_buf,s.pending-i,i)),xt(t),i=s.pending,s.pending===s.pending_buf_size)){a=1;break}s.gzindexi&&(t.adler=$(t.adler,s.pending_buf,s.pending-i,i)),a===0&&(s.gzindex=0,s.status=Ze)}else s.status=Ze;if(s.status===Ze)if(s.gzhead.comment){i=s.pending;do{if(s.pending===s.pending_buf_size&&(s.gzhead.hcrc&&s.pending>i&&(t.adler=$(t.adler,s.pending_buf,s.pending-i,i)),xt(t),i=s.pending,s.pending===s.pending_buf_size)){a=1;break}s.gzindexi&&(t.adler=$(t.adler,s.pending_buf,s.pending-i,i)),a===0&&(s.status=Le)}else s.status=Le;if(s.status===Le&&(s.gzhead.hcrc?(s.pending+2>s.pending_buf_size&&xt(t),s.pending+2<=s.pending_buf_size&&(P(s,t.adler&255),P(s,t.adler>>8&255),t.adler=0,s.status=Ht)):s.status=Ht),s.pending!==0){if(xt(t),t.avail_out===0)return s.last_flush=-1,wt}else if(t.avail_in===0&&bs(e)<=bs(n)&&e!==zt)return Rt(t,li);if(s.status===he&&t.avail_in!==0)return Rt(t,li);if(t.avail_in!==0||s.lookahead!==0||e!==Kt&&s.status!==he){let r=s.strategy===De?ro(s,e):s.strategy===Nr?no(s,e):de[s.level].func(s,e);if((r===Gt||r===ne)&&(s.status=he),r===tt||r===Gt)return t.avail_out===0&&(s.last_flush=-1),wt;if(r===xe&&(e===Pr?Rr(s):e!==ds&&(Fr(s,0,0,!1),e===zr&&(Vt(s.head),s.lookahead===0&&(s.strstart=0,s.block_start=0,s.insert=0))),xt(t),t.avail_out===0))return s.last_flush=-1,wt}return e!==zt?wt:s.wrap<=0?cs:(s.wrap===2?(P(s,t.adler&255),P(s,t.adler>>8&255),P(s,t.adler>>16&255),P(s,t.adler>>24&255),P(s,t.total_in&255),P(s,t.total_in>>8&255),P(s,t.total_in>>16&255),P(s,t.total_in>>24&255)):(le(s,t.adler>>>16),le(s,t.adler&65535)),xt(t),s.wrap>0&&(s.wrap=-s.wrap),s.pending!==0?wt:cs)},uo=t=>{if(!t||!t.state)return bt;let e=t.state.status;return e!==Qe&&e!==xi&&e!==Ne&&e!==Ze&&e!==Le&&e!==Ht&&e!==he?Rt(t,bt):(t.state=null,e===Ht?Rt(t,Mr):wt)},fo=(t,e)=>{let i=e.length;if(!t||!t.state)return bt;let a=t.state,s=a.wrap;if(s===2||s===1&&a.status!==Qe||a.lookahead)return bt;if(s===1&&(t.adler=Se(t.adler,e,i,0)),a.wrap=0,i>=a.w_size){s===0&&(Vt(a.head),a.strstart=0,a.block_start=0,a.insert=0);let b=new Uint8Array(a.w_size);b.set(e.subarray(i-a.w_size,i),0),e=b,i=a.w_size}let n=t.avail_in,r=t.next_in,o=t.input;for(t.avail_in=i,t.next_in=0,t.input=e,Xt(a);a.lookahead>=D;){let b=a.strstart,l=a.lookahead-(D-1);do a.ins_h=Mt(a,a.ins_h,a.window[b+D-1]),a.prev[b&a.w_mask]=a.head[a.ins_h],a.head[a.ins_h]=b,b++;while(--l);a.strstart=b,a.lookahead=D-1,Xt(a)}return a.strstart+=a.lookahead,a.block_start=a.strstart,a.insert=a.lookahead,a.lookahead=0,a.match_length=a.prev_length=D-1,a.match_available=0,t.next_in=r,t.input=o,t.avail_in=n,a.wrap=s,wt},_o=co,po=Ra,go=Da,wo=Fa,yo=ho,mo=bo,vo=uo,So=fo,ko=\"pako deflate (from Nodeca project)\",ue={deflateInit:_o,deflateInit2:po,deflateReset:go,deflateResetKeep:wo,deflateSetHeader:yo,deflate:mo,deflateEnd:vo,deflateSetDictionary:So,deflateInfo:ko},Oo=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),Ao=function(t){let e=Array.prototype.slice.call(arguments,1);for(;e.length;){let i=e.shift();if(i){if(typeof i!=\"object\")throw new TypeError(i+\"must be non-object\");for(let a in i)Oo(i,a)&&(t[a]=i[a])}}return t},Io=t=>{let e=0;for(let a=0,s=t.length;a=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;ke[254]=ke[254]=1;var jo=t=>{if(typeof TextEncoder==\"function\"&&TextEncoder.prototype.encode)return new TextEncoder().encode(t);let e,i,a,s,n,r=t.length,o=0;for(s=0;s>>6,e[n++]=128|i&63):i<65536?(e[n++]=224|i>>>12,e[n++]=128|i>>>6&63,e[n++]=128|i&63):(e[n++]=240|i>>>18,e[n++]=128|i>>>12&63,e[n++]=128|i>>>6&63,e[n++]=128|i&63);return e},xo=(t,e)=>{if(e<65534&&t.subarray&&Pa)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let i=\"\";for(let a=0;a{let i=e||t.length;if(typeof TextDecoder==\"function\"&&TextDecoder.prototype.decode)return new TextDecoder().decode(t.subarray(0,e));let a,s,n=new Array(i*2);for(s=0,a=0;a4){n[s++]=65533,a+=o-1;continue}for(r&=o===2?31:o===3?15:7;o>1&&a1){n[s++]=65533;continue}r<65536?n[s++]=r:(r-=65536,n[s++]=55296|r>>10&1023,n[s++]=56320|r&1023)}return xo(n,s)},Uo=(t,e)=>{e=e||t.length,e>t.length&&(e=t.length);let i=e-1;for(;i>=0&&(t[i]&192)===128;)i--;return i<0||i===0?e:i+ke[t[i]]>e?i:e},Oe={string2buf:jo,buf2string:Co,utf8border:Uo};function To(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg=\"\",this.state=null,this.data_type=2,this.adler=0}var za=To,Ma=Object.prototype.toString,{Z_NO_FLUSH:Vo,Z_SYNC_FLUSH:Fo,Z_FULL_FLUSH:Do,Z_FINISH:Ro,Z_OK:Xe,Z_STREAM_END:Po,Z_DEFAULT_COMPRESSION:zo,Z_DEFAULT_STRATEGY:Mo,Z_DEFLATED:Bo}=ae;function Ce(t){this.options=Je.assign({level:zo,method:Bo,chunkSize:16384,windowBits:15,memLevel:8,strategy:Mo},t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg=\"\",this.ended=!1,this.chunks=[],this.strm=new za,this.strm.avail_out=0;let i=ue.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(i!==Xe)throw new Error(Yt[i]);if(e.header&&ue.deflateSetHeader(this.strm,e.header),e.dictionary){let a;if(typeof e.dictionary==\"string\"?a=Oe.string2buf(e.dictionary):Ma.call(e.dictionary)===\"[object ArrayBuffer]\"?a=new Uint8Array(e.dictionary):a=e.dictionary,i=ue.deflateSetDictionary(this.strm,a),i!==Xe)throw new Error(Yt[i]);this._dict_set=!0}}Ce.prototype.push=function(t,e){let i=this.strm,a=this.options.chunkSize,s,n;if(this.ended)return!1;for(e===~~e?n=e:n=e===!0?Ro:Vo,typeof t==\"string\"?i.input=Oe.string2buf(t):Ma.call(t)===\"[object ArrayBuffer]\"?i.input=new Uint8Array(t):i.input=t,i.next_in=0,i.avail_in=i.input.length;;){if(i.avail_out===0&&(i.output=new Uint8Array(a),i.next_out=0,i.avail_out=a),(n===Fo||n===Do)&&i.avail_out<=6){this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;continue}if(s=ue.deflate(i,n),s===Po)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),s=ue.deflateEnd(this.strm),this.onEnd(s),this.ended=!0,s===Xe;if(i.avail_out===0){this.onData(i.output);continue}if(n>0&&i.next_out>0){this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;continue}if(i.avail_in===0)break}return!0};Ce.prototype.onData=function(t){this.chunks.push(t)};Ce.prototype.onEnd=function(t){t===Xe&&(this.result=Je.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};function Ei(t,e){let i=new Ce(e);if(i.push(t,!0),i.err)throw i.msg||Yt[i.err];return i.result}function Eo(t,e){return e=e||{},e.raw=!0,Ei(t,e)}function No(t,e){return e=e||{},e.gzip=!0,Ei(t,e)}var Zo=Ce,Lo=Ei,Ho=Eo,Yo=No,Go=ae,Xo={Deflate:Zo,deflate:Lo,deflateRaw:Ho,gzip:Yo,constants:Go},Re=30,Wo=12,Ko=function(t,e){let i,a,s,n,r,o,b,l,h,O,w,_,V,U,x,I,k,m,A,Z,F,u,S,p,g=t.state;i=t.next_in,S=t.input,a=i+(t.avail_in-5),s=t.next_out,p=t.output,n=s-(e-t.avail_out),r=s+(t.avail_out-257),o=g.dmax,b=g.wsize,l=g.whave,h=g.wnext,O=g.window,w=g.hold,_=g.bits,V=g.lencode,U=g.distcode,x=(1<>>24,w>>>=m,_-=m,m=k>>>16&255,m===0)p[s++]=k&65535;else if(m&16){A=k&65535,m&=15,m&&(_>>=m,_-=m),_<15&&(w+=S[i++]<<_,_+=8,w+=S[i++]<<_,_+=8),k=U[w&I];i:for(;;){if(m=k>>>24,w>>>=m,_-=m,m=k>>>16&255,m&16){if(Z=k&65535,m&=15,_o){t.msg=\"invalid distance too far back\",g.mode=Re;break t}if(w>>>=m,_-=m,m=s-n,Z>m){if(m=Z-m,m>l&&g.sane){t.msg=\"invalid distance too far back\",g.mode=Re;break t}if(F=0,u=O,h===0){if(F+=b-m,m2;)p[s++]=u[F++],p[s++]=u[F++],p[s++]=u[F++],A-=3;A&&(p[s++]=u[F++],A>1&&(p[s++]=u[F++]))}else{F=s-Z;do p[s++]=p[F++],p[s++]=p[F++],p[s++]=p[F++],A-=3;while(A>2);A&&(p[s++]=p[F++],A>1&&(p[s++]=p[F++]))}}else if((m&64)===0){k=U[(k&65535)+(w&(1<>3,i-=A,_-=A<<3,w&=(1<<_)-1,t.next_in=i,t.next_out=s,t.avail_in=i{let b=o.bits,l=0,h=0,O=0,w=0,_=0,V=0,U=0,x=0,I=0,k=0,m,A,Z,F,u,S=null,p=0,g,y=new Uint16Array(Qt+1),R=new Uint16Array(Qt+1),T=null,C=0,L,E,at;for(l=0;l<=Qt;l++)y[l]=0;for(h=0;h=1&&y[w]===0;w--);if(_>w&&(_=w),w===0)return s[n++]=1<<24|64<<16|0,s[n++]=1<<24|64<<16|0,o.bits=1,0;for(O=1;O0&&(t===_s||w!==1))return-1;for(R[1]=0,l=1;lus||t===ps&&I>fs)return 1;for(;;){L=l-U,r[h]g?(E=T[C+r[h]],at=S[p+r[h]]):(E=32+64,at=0),m=1<>U)+A]=L<<24|E<<16|at|0;while(A!==0);for(m=1<>=1;if(m!==0?(k&=m-1,k+=m):k=0,h++,--y[l]===0){if(l===w)break;l=e[i+r[h]]}if(l>_&&(k&F)!==Z){for(U===0&&(U=_),u+=O,V=l-U,x=1<us||t===ps&&I>fs)return 1;Z=k&F,s[Z]=_<<24|V<<16|u-n|0}}return k!==0&&(s[u+k]=l-U<<24|64<<16|0),o.bits=_,0},fe=tl,el=0,Ba=1,Ea=2,{Z_FINISH:gs,Z_BLOCK:il,Z_TREES:Pe,Z_OK:Wt,Z_STREAM_END:sl,Z_NEED_DICT:al,Z_STREAM_ERROR:ft,Z_DATA_ERROR:Na,Z_MEM_ERROR:Za,Z_BUF_ERROR:nl,Z_DEFLATED:ws}=ae,La=1,ys=2,ms=3,vs=4,Ss=5,ks=6,Os=7,As=8,Is=9,js=10,We=11,yt=12,ci=13,xs=14,bi=15,Cs=16,Us=17,Ts=18,Vs=19,ze=20,Me=21,Fs=22,Ds=23,Rs=24,Ps=25,zs=26,ui=27,Ms=28,Bs=29,N=30,Ha=31,rl=32,ol=852,ll=592,hl=15,dl=hl,Es=t=>(t>>>24&255)+(t>>>8&65280)+((t&65280)<<8)+((t&255)<<24);function cl(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}var Ya=t=>{if(!t||!t.state)return ft;let e=t.state;return t.total_in=t.total_out=e.total=0,t.msg=\"\",e.wrap&&(t.adler=e.wrap&1),e.mode=La,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(ol),e.distcode=e.distdyn=new Int32Array(ll),e.sane=1,e.back=-1,Wt},Ga=t=>{if(!t||!t.state)return ft;let e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,Ya(t)},Xa=(t,e)=>{let i;if(!t||!t.state)return ft;let a=t.state;return e<0?(i=0,e=-e):(i=(e>>4)+1,e<48&&(e&=15)),e&&(e<8||e>15)?ft:(a.window!==null&&a.wbits!==e&&(a.window=null),a.wrap=i,a.wbits=e,Ga(t))},Wa=(t,e)=>{if(!t)return ft;let i=new cl;t.state=i,i.window=null;let a=Xa(t,e);return a!==Wt&&(t.state=null),a},bl=t=>Wa(t,dl),Ns=!0,fi,_i,ul=t=>{if(Ns){fi=new Int32Array(512),_i=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(fe(Ba,t.lens,0,288,fi,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;fe(Ea,t.lens,0,32,_i,0,t.work,{bits:5}),Ns=!1}t.lencode=fi,t.lenbits=9,t.distcode=_i,t.distbits=5},Ka=(t,e,i,a)=>{let s,n=t.state;return n.window===null&&(n.wsize=1<=n.wsize?(n.window.set(e.subarray(i-n.wsize,i),0),n.wnext=0,n.whave=n.wsize):(s=n.wsize-n.wnext,s>a&&(s=a),n.window.set(e.subarray(i-a,i-a+s),n.wnext),a-=s,a?(n.window.set(e.subarray(i-a,i),0),n.wnext=a,n.whave=n.wsize):(n.wnext+=s,n.wnext===n.wsize&&(n.wnext=0),n.whave{let i,a,s,n,r,o,b,l,h,O,w,_,V,U,x=0,I,k,m,A,Z,F,u,S,p=new Uint8Array(4),g,y,R=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!t||!t.state||!t.output||!t.input&&t.avail_in!==0)return ft;i=t.state,i.mode===yt&&(i.mode=ci),r=t.next_out,s=t.output,b=t.avail_out,n=t.next_in,a=t.input,o=t.avail_in,l=i.hold,h=i.bits,O=o,w=b,S=Wt;t:for(;;)switch(i.mode){case La:if(i.wrap===0){i.mode=ci;break}for(;h<16;){if(o===0)break t;o--,l+=a[n++]<>>8&255,i.check=$(i.check,p,2,0),l=0,h=0,i.mode=ys;break}if(i.flags=0,i.head&&(i.head.done=!1),!(i.wrap&1)||(((l&255)<<8)+(l>>8))%31){t.msg=\"incorrect header check\",i.mode=N;break}if((l&15)!==ws){t.msg=\"unknown compression method\",i.mode=N;break}if(l>>>=4,h-=4,u=(l&15)+8,i.wbits===0)i.wbits=u;else if(u>i.wbits){t.msg=\"invalid window size\",i.mode=N;break}i.dmax=1<>8&1),i.flags&512&&(p[0]=l&255,p[1]=l>>>8&255,i.check=$(i.check,p,2,0)),l=0,h=0,i.mode=ms;case ms:for(;h<32;){if(o===0)break t;o--,l+=a[n++]<>>8&255,p[2]=l>>>16&255,p[3]=l>>>24&255,i.check=$(i.check,p,4,0)),l=0,h=0,i.mode=vs;case vs:for(;h<16;){if(o===0)break t;o--,l+=a[n++]<>8),i.flags&512&&(p[0]=l&255,p[1]=l>>>8&255,i.check=$(i.check,p,2,0)),l=0,h=0,i.mode=Ss;case Ss:if(i.flags&1024){for(;h<16;){if(o===0)break t;o--,l+=a[n++]<>>8&255,i.check=$(i.check,p,2,0)),l=0,h=0}else i.head&&(i.head.extra=null);i.mode=ks;case ks:if(i.flags&1024&&(_=i.length,_>o&&(_=o),_&&(i.head&&(u=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Uint8Array(i.head.extra_len)),i.head.extra.set(a.subarray(n,n+_),u)),i.flags&512&&(i.check=$(i.check,a,_,n)),o-=_,n+=_,i.length-=_),i.length))break t;i.length=0,i.mode=Os;case Os:if(i.flags&2048){if(o===0)break t;_=0;do u=a[n+_++],i.head&&u&&i.length<65536&&(i.head.name+=String.fromCharCode(u));while(u&&_>9&1,i.head.done=!0),t.adler=i.check=0,i.mode=yt;break;case js:for(;h<32;){if(o===0)break t;o--,l+=a[n++]<>>=h&7,h-=h&7,i.mode=ui;break}for(;h<3;){if(o===0)break t;o--,l+=a[n++]<>>=1,h-=1,l&3){case 0:i.mode=xs;break;case 1:if(ul(i),i.mode=ze,e===Pe){l>>>=2,h-=2;break t}break;case 2:i.mode=Us;break;case 3:t.msg=\"invalid block type\",i.mode=N}l>>>=2,h-=2;break;case xs:for(l>>>=h&7,h-=h&7;h<32;){if(o===0)break t;o--,l+=a[n++]<>>16^65535)){t.msg=\"invalid stored block lengths\",i.mode=N;break}if(i.length=l&65535,l=0,h=0,i.mode=bi,e===Pe)break t;case bi:i.mode=Cs;case Cs:if(_=i.length,_){if(_>o&&(_=o),_>b&&(_=b),_===0)break t;s.set(a.subarray(n,n+_),r),o-=_,n+=_,b-=_,r+=_,i.length-=_;break}i.mode=yt;break;case Us:for(;h<14;){if(o===0)break t;o--,l+=a[n++]<>>=5,h-=5,i.ndist=(l&31)+1,l>>>=5,h-=5,i.ncode=(l&15)+4,l>>>=4,h-=4,i.nlen>286||i.ndist>30){t.msg=\"too many length or distance symbols\",i.mode=N;break}i.have=0,i.mode=Ts;case Ts:for(;i.have>>=3,h-=3}for(;i.have<19;)i.lens[R[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,g={bits:i.lenbits},S=fe(el,i.lens,0,19,i.lencode,0,i.work,g),i.lenbits=g.bits,S){t.msg=\"invalid code lengths set\",i.mode=N;break}i.have=0,i.mode=Vs;case Vs:for(;i.have>>24,k=x>>>16&255,m=x&65535,!(I<=h);){if(o===0)break t;o--,l+=a[n++]<>>=I,h-=I,i.lens[i.have++]=m;else{if(m===16){for(y=I+2;h>>=I,h-=I,i.have===0){t.msg=\"invalid bit length repeat\",i.mode=N;break}u=i.lens[i.have-1],_=3+(l&3),l>>>=2,h-=2}else if(m===17){for(y=I+3;h>>=I,h-=I,u=0,_=3+(l&7),l>>>=3,h-=3}else{for(y=I+7;h>>=I,h-=I,u=0,_=11+(l&127),l>>>=7,h-=7}if(i.have+_>i.nlen+i.ndist){t.msg=\"invalid bit length repeat\",i.mode=N;break}for(;_--;)i.lens[i.have++]=u}}if(i.mode===N)break;if(i.lens[256]===0){t.msg=\"invalid code -- missing end-of-block\",i.mode=N;break}if(i.lenbits=9,g={bits:i.lenbits},S=fe(Ba,i.lens,0,i.nlen,i.lencode,0,i.work,g),i.lenbits=g.bits,S){t.msg=\"invalid literal/lengths set\",i.mode=N;break}if(i.distbits=6,i.distcode=i.distdyn,g={bits:i.distbits},S=fe(Ea,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,g),i.distbits=g.bits,S){t.msg=\"invalid distances set\",i.mode=N;break}if(i.mode=ze,e===Pe)break t;case ze:i.mode=Me;case Me:if(o>=6&&b>=258){t.next_out=r,t.avail_out=b,t.next_in=n,t.avail_in=o,i.hold=l,i.bits=h,Ko(t,w),r=t.next_out,s=t.output,b=t.avail_out,n=t.next_in,a=t.input,o=t.avail_in,l=i.hold,h=i.bits,i.mode===yt&&(i.back=-1);break}for(i.back=0;x=i.lencode[l&(1<>>24,k=x>>>16&255,m=x&65535,!(I<=h);){if(o===0)break t;o--,l+=a[n++]<>A)],I=x>>>24,k=x>>>16&255,m=x&65535,!(A+I<=h);){if(o===0)break t;o--,l+=a[n++]<>>=A,h-=A,i.back+=A}if(l>>>=I,h-=I,i.back+=I,i.length=m,k===0){i.mode=zs;break}if(k&32){i.back=-1,i.mode=yt;break}if(k&64){t.msg=\"invalid literal/length code\",i.mode=N;break}i.extra=k&15,i.mode=Fs;case Fs:if(i.extra){for(y=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=Ds;case Ds:for(;x=i.distcode[l&(1<>>24,k=x>>>16&255,m=x&65535,!(I<=h);){if(o===0)break t;o--,l+=a[n++]<>A)],I=x>>>24,k=x>>>16&255,m=x&65535,!(A+I<=h);){if(o===0)break t;o--,l+=a[n++]<>>=A,h-=A,i.back+=A}if(l>>>=I,h-=I,i.back+=I,k&64){t.msg=\"invalid distance code\",i.mode=N;break}i.offset=m,i.extra=k&15,i.mode=Rs;case Rs:if(i.extra){for(y=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){t.msg=\"invalid distance too far back\",i.mode=N;break}i.mode=Ps;case Ps:if(b===0)break t;if(_=w-b,i.offset>_){if(_=i.offset-_,_>i.whave&&i.sane){t.msg=\"invalid distance too far back\",i.mode=N;break}_>i.wnext?(_-=i.wnext,V=i.wsize-_):V=i.wnext-_,_>i.length&&(_=i.length),U=i.window}else U=s,V=r-i.offset,_=i.length;_>b&&(_=b),b-=_,i.length-=_;do s[r++]=U[V++];while(--_);i.length===0&&(i.mode=Me);break;case zs:if(b===0)break t;s[r++]=i.length,b--,i.mode=Me;break;case ui:if(i.wrap){for(;h<32;){if(o===0)break t;o--,l|=a[n++]<{if(!t||!t.state)return ft;let e=t.state;return e.window&&(e.window=null),t.state=null,Wt},pl=(t,e)=>{if(!t||!t.state)return ft;let i=t.state;return(i.wrap&2)===0?ft:(i.head=e,e.done=!1,Wt)},gl=(t,e)=>{let i=e.length,a,s,n;return!t||!t.state||(a=t.state,a.wrap!==0&&a.mode!==We)?ft:a.mode===We&&(s=1,s=Se(s,e,i,0),s!==a.check)?Na:(n=Ka(t,e,i,i),n?(a.mode=Ha,Za):(a.havedict=1,Wt))},wl=Ga,yl=Xa,ml=Ya,vl=bl,Sl=Wa,kl=fl,Ol=_l,Al=pl,Il=gl,jl=\"pako inflate (from Nodeca project)\",kt={inflateReset:wl,inflateReset2:yl,inflateResetKeep:ml,inflateInit:vl,inflateInit2:Sl,inflate:kl,inflateEnd:Ol,inflateGetHeader:Al,inflateSetDictionary:Il,inflateInfo:jl};function xl(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name=\"\",this.comment=\"\",this.hcrc=0,this.done=!1}var Cl=xl,qa=Object.prototype.toString,{Z_NO_FLUSH:Ul,Z_FINISH:Tl,Z_OK:Ae,Z_STREAM_END:pi,Z_NEED_DICT:gi,Z_STREAM_ERROR:Vl,Z_DATA_ERROR:Zs,Z_MEM_ERROR:Fl}=ae;function Ue(t){this.options=Je.assign({chunkSize:1024*64,windowBits:15,to:\"\"},t||{});let e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,e.windowBits===0&&(e.windowBits=-15)),e.windowBits>=0&&e.windowBits<16&&!(t&&t.windowBits)&&(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(e.windowBits&15)===0&&(e.windowBits|=15),this.err=0,this.msg=\"\",this.ended=!1,this.chunks=[],this.strm=new za,this.strm.avail_out=0;let i=kt.inflateInit2(this.strm,e.windowBits);if(i!==Ae)throw new Error(Yt[i]);if(this.header=new Cl,kt.inflateGetHeader(this.strm,this.header),e.dictionary&&(typeof e.dictionary==\"string\"?e.dictionary=Oe.string2buf(e.dictionary):qa.call(e.dictionary)===\"[object ArrayBuffer]\"&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(i=kt.inflateSetDictionary(this.strm,e.dictionary),i!==Ae)))throw new Error(Yt[i])}Ue.prototype.push=function(t,e){let i=this.strm,a=this.options.chunkSize,s=this.options.dictionary,n,r,o;if(this.ended)return!1;for(e===~~e?r=e:r=e===!0?Tl:Ul,qa.call(t)===\"[object ArrayBuffer]\"?i.input=new Uint8Array(t):i.input=t,i.next_in=0,i.avail_in=i.input.length;;){for(i.avail_out===0&&(i.output=new Uint8Array(a),i.next_out=0,i.avail_out=a),n=kt.inflate(i,r),n===gi&&s&&(n=kt.inflateSetDictionary(i,s),n===Ae?n=kt.inflate(i,r):n===Zs&&(n=gi));i.avail_in>0&&n===pi&&i.state.wrap>0&&t[i.next_in]!==0;)kt.inflateReset(i),n=kt.inflate(i,r);switch(n){case Vl:case Zs:case gi:case Fl:return this.onEnd(n),this.ended=!0,!1}if(o=i.avail_out,i.next_out&&(i.avail_out===0||n===pi))if(this.options.to===\"string\"){let b=Oe.utf8border(i.output,i.next_out),l=i.next_out-b,h=Oe.buf2string(i.output,b);i.next_out=l,i.avail_out=a-l,l&&i.output.set(i.output.subarray(b,b+l),0),this.onData(h)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(!(n===Ae&&o===0)){if(n===pi)return n=kt.inflateEnd(this.strm),this.onEnd(n),this.ended=!0,!0;if(i.avail_in===0)break}}return!0};Ue.prototype.onData=function(t){this.chunks.push(t)};Ue.prototype.onEnd=function(t){t===Ae&&(this.options.to===\"string\"?this.result=this.chunks.join(\"\"):this.result=Je.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};function Ni(t,e){let i=new Ue(e);if(i.push(t),i.err)throw i.msg||Yt[i.err];return i.result}function Dl(t,e){return e=e||{},e.raw=!0,Ni(t,e)}var Rl=Ue,Pl=Ni,zl=Dl,Ml=Ni,Bl=ae,El={Inflate:Rl,inflate:Pl,inflateRaw:zl,ungzip:Ml,constants:Bl},{Deflate:Kl,deflate:ql,deflateRaw:Nl,gzip:$l}=Xo,{Inflate:Ql,inflate:Jl,inflateRaw:Zl,ungzip:th}=El,Ll=Nl,Hl=Zl,$a=t=>Hl(t),Ci=t=>Ll(t,{level:9}),Yl=class{constructor(){this.pendingMessages=[]}sendClientMessage(t,e){t.finish(e),this.doSendMessage(Ci(t.asUint8Array()))}getPendingMessages(){return this.pendingMessages}markPendingMessagesAsRead(){this.pendingMessages.length=0}onMessage(t){this.pendingMessages.push(ct.getRootAsServerMessage(new jt($a(t))))}onDisconnection(){ce(\"disconnected\")}},Gl=class{constructor(){this.usersPendingMessages=new Map,this.disconnectedUsers=[]}sendServerMessageTo(t,e,i){e.finish(i),this.doSendMessageTo(t,Ci(e.asUint8Array()))}sendServerMessageToAll(t,e){t.finish(e);let i=Ci(t.asUint8Array());for(let a of this.usersPendingMessages.keys())this.doSendMessageTo(a,i)}getUsersPendingMessages(){return this.usersPendingMessages.entries()}getConnectedUsers(){return this.usersPendingMessages.keys()}getDisconnectedUsers(){return this.disconnectedUsers}onMessage(t,e){this.usersPendingMessages.get(t).push(vt.getRootAsClientMessage(new jt($a(e))))}onConnection(t){this.usersPendingMessages.set(t,[])}onDisconnection(t){this.usersPendingMessages.delete(t),this.disconnectedUsers.push(t)}};gdjs.BBTextRuntimeObject&&(gdjs.BBTextRuntimeObject.prototype.getString=gdjs.BBTextRuntimeObject.prototype.getBBText,gdjs.BBTextRuntimeObject.prototype.setString=gdjs.BBTextRuntimeObject.prototype.setBBText),gdjs.BitmapTextRuntimeObject&&(gdjs.BitmapTextRuntimeObject.prototype.getString=gdjs.BitmapTextRuntimeObject.prototype.getText,gdjs.BitmapTextRuntimeObject.prototype.setString=gdjs.BitmapTextRuntimeObject.prototype.setText,gdjs.BitmapTextRuntimeObject.prototype.getColor=gdjs.BitmapTextRuntimeObject.prototype.getTint,gdjs.BitmapTextRuntimeObject.prototype.setColor=gdjs.BitmapTextRuntimeObject.prototype.setTint);return an(Xl);})();\n/*! pako 2.0.4 https://github.com/nodeca/pako @license (MIT AND Zlib) */\n{", + "inlineCode": [ + "}// Load THNK library (https://github.com/arthuro555/THNK)", + "window.THNK=(()=>{var ti=Object.defineProperty;var Qa=Object.getOwnPropertyDescriptor;var Ja=Object.getOwnPropertyNames;var tn=Object.prototype.hasOwnProperty;var en=(t,e)=>{for(var i in e)ti(t,i,{get:e[i],enumerable:!0})},sn=(t,e,i,a)=>{if(e&&typeof e==\"object\"||typeof e==\"function\")for(let s of Ja(e))!tn.call(t,s)&&s!==i&&ti(t,s,{get:()=>e[s],enumerable:!(a=Qa(e,s))||a.enumerable});return t};var an=t=>sn(ti({},\"__esModule\",{value:!0}),t);var Xl={};en(Xl,{ClientAdapter:()=>Yl,ServerAdapter:()=>Gl,client:()=>ua,players:()=>ia,server:()=>Ls,settings:()=>sa});var nn=Object.defineProperty,Ke=(t,e)=>{for(var i in e)nn(t,i,{get:e[i],enumerable:!0})},Ls={};Ke(Ls,{events:()=>Gn,startServer:()=>Yn});var Ct=new Int32Array(2),Zi=new Float32Array(Ct.buffer),Li=new Float64Array(Ct.buffer),Te=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1,wi;(function(t){t[t.UTF8_BYTES=1]=\"UTF8_BYTES\",t[t.UTF16_STRING=2]=\"UTF16_STRING\"})(wi||(wi={}));var jt=class{constructor(t){this.bytes_=t,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(t){return new jt(new Uint8Array(t))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(t){this.position_=t}capacity(){return this.bytes_.length}readInt8(t){return this.readUint8(t)<<24>>24}readUint8(t){return this.bytes_[t]}readInt16(t){return this.readUint16(t)<<16>>16}readUint16(t){return this.bytes_[t]|this.bytes_[t+1]<<8}readInt32(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24}readUint32(t){return this.readInt32(t)>>>0}readInt64(t){return BigInt.asIntN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<>8}writeUint16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeInt32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeUint32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeInt64(t,e){this.writeInt32(t,Number(BigInt.asIntN(32,e))),this.writeInt32(t+4,Number(BigInt.asIntN(32,e>>BigInt(32))))}writeUint64(t,e){this.writeUint32(t,Number(BigInt.asUintN(32,e))),this.writeUint32(t+4,Number(BigInt.asUintN(32,e>>BigInt(32))))}writeFloat32(t,e){Zi[0]=e,this.writeInt32(t,Ct[0])}writeFloat64(t,e){Li[0]=e,this.writeInt32(t,Ct[Te?0:1]),this.writeInt32(t+4,Ct[Te?1:0])}getBufferIdentifier(){if(this.bytes_.lengththis.minalign&&(this.minalign=t);let i=~(this.bb.capacity()-this.space+e)+1&t-1;for(;this.space=0&&this.vtable[e]==0;e--);let i=e+1;for(;e>=0;e--)this.addInt16(this.vtable[e]!=0?t-this.vtable[e]:0);let a=2;this.addInt16(t-this.object_start);let s=(i+a)*2;this.addInt16(s);let n=0,r=this.space;t:for(e=0;e=0;n--)this.writeInt8(s.charCodeAt(n))}this.prep(this.minalign,4+a),this.addOffset(t),a&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,e){this.finish(t,e,!0)}requiredField(t,e){let i=this.bb.capacity()-t,a=i-this.bb.readInt32(i);if(this.bb.readInt16(a+e)==0)throw new Error(\"FlatBuffers: field \"+e+\" must be set\")}startVector(t,e,i){this.notNested(),this.vector_num_elems=e,this.prep(4,t*e),this.prep(i,t*e)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(t){if(!t)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(t))return this.string_maps.get(t);let e=this.createString(t);return this.string_maps.set(t,e),e}createString(t){if(t==null)return 0;let e;t instanceof Uint8Array?e=t:e=this.text_encoder.encode(t),this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length);for(let i=0,a=this.space,s=this.bb.bytes();i=0;i--)t.addInt8(e[i]);return t.endVector()}static startContentVector(t,e){t.startVector(1,e,1)}static endClientInputMessage(t){let e=t.endObject();return t.requiredField(e,4),t.requiredField(e,6),e}static createClientInputMessage(t,e,i){return mt.startClientInputMessage(t),mt.addName(t,e),mt.addContent(t,i),mt.endClientInputMessage(t)}},Tt=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsConnectionRequestMessage(t,e){return(e||new Tt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsConnectionRequestMessage(t,e){return t.setPosition(t.position()+4),(e||new Tt).__init(t.readInt32(t.position())+t.position(),t)}token(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}static startConnectionRequestMessage(t){t.startObject(1)}static addToken(t,e){t.addFieldOffset(0,e,0)}static endConnectionRequestMessage(t){return t.endObject()}static createConnectionRequestMessage(t,e){return Tt.startConnectionRequestMessage(t),Tt.addToken(t,e),Tt.endConnectionRequestMessage(t)}},vt=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsClientMessage(t,e){return(e||new vt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsClientMessage(t,e){return t.setPosition(t.position()+4),(e||new vt).__init(t.readInt32(t.position())+t.position(),t)}contentType(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readUint8(this.bb_pos+t):0}content(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__union(t,this.bb_pos+e):null}static startClientMessage(t){t.startObject(2)}static addContentType(t,e){t.addFieldInt8(0,e,0)}static addContent(t,e){t.addFieldOffset(1,e,0)}static endClientMessage(t){let e=t.endObject();return t.requiredField(e,6),e}static createClientMessage(t,e,i){return vt.startClientMessage(t),vt.addContentType(t,e),vt.addContent(t,i),vt.endClientMessage(t)}},B=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsVariable(t,e){return(e||new B).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsVariable(t,e){return t.setPosition(t.position()+4),(e||new B).__init(t.readInt32(t.position())+t.position(),t)}type(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readUint8(this.bb_pos+t):0}text(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}number(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readFloat32(this.bb_pos+t):0}boolean(){let t=this.bb.__offset(this.bb_pos,10);return t?!!this.bb.readInt8(this.bb_pos+t):!1}operations(t,e){let i=this.bb.__offset(this.bb_pos,12);return i?(e||new W).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+t*4),this.bb):null}operationsLength(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startVariable(t){t.startObject(5)}static addType(t,e){t.addFieldInt8(0,e,0)}static addText(t,e){t.addFieldOffset(1,e,0)}static addNumber(t,e){t.addFieldFloat32(2,e,0)}static addBoolean(t,e){t.addFieldInt8(3,+e,0)}static addOperations(t,e){t.addFieldOffset(4,e,0)}static createOperationsVector(t,e){t.startVector(4,e.length,4);for(let i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startOperationsVector(t,e){t.startVector(4,e,4)}static endVariable(t){return t.endObject()}static createVariable(t,e,i,a,s,n){return B.startVariable(t),B.addType(t,e),B.addText(t,i),B.addNumber(t,a),B.addBoolean(t,s),B.addOperations(t,n),B.endVariable(t)}},W=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsCollectionOperation(t,e){return(e||new W).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsCollectionOperation(t,e){return t.setPosition(t.position()+4),(e||new W).__init(t.readInt32(t.position())+t.position(),t)}operation(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readUint8(this.bb_pos+t):0}name(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}index(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readUint16(this.bb_pos+t):0}val(t){let e=this.bb.__offset(this.bb_pos,10);return e?(t||new B).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startCollectionOperation(t){t.startObject(4)}static addOperation(t,e){t.addFieldInt8(0,e,0)}static addName(t,e){t.addFieldOffset(1,e,0)}static addIndex(t,e){t.addFieldInt16(2,e,0)}static addVal(t,e){t.addFieldOffset(3,e,0)}static endCollectionOperation(t){return t.endObject()}},Ui=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}r(){return this.bb.readUint16(this.bb_pos)}g(){return this.bb.readUint16(this.bb_pos+2)}b(){return this.bb.readUint16(this.bb_pos+4)}static sizeOf(){return 6}static createRGB(t,e,i,a){return t.prep(2,6),t.writeInt16(a),t.writeInt16(i),t.writeInt16(e),t.offset()}},j=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsObjState(t,e){return(e||new j).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsObjState(t,e){return t.setPosition(t.position()+4),(e||new j).__init(t.readInt32(t.position())+t.position(),t)}x(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readFloat32(this.bb_pos+t):null}y(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readFloat32(this.bb_pos+t):null}height(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readFloat32(this.bb_pos+t):null}width(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readFloat32(this.bb_pos+t):null}angle(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.readFloat32(this.bb_pos+t):null}scale(){let t=this.bb.__offset(this.bb_pos,14);return t?this.bb.readFloat32(this.bb_pos+t):null}tint(t){let e=this.bb.__offset(this.bb_pos,16);return e?(t||new Ui).__init(this.bb_pos+e,this.bb):null}setXTo0(){let t=this.bb.__offset(this.bb_pos,18);return t?!!this.bb.readInt8(this.bb_pos+t):!1}setYTo0(){let t=this.bb.__offset(this.bb_pos,20);return t?!!this.bb.readInt8(this.bb_pos+t):!1}setHeightTo0(){let t=this.bb.__offset(this.bb_pos,22);return t?!!this.bb.readInt8(this.bb_pos+t):!1}setWidthTo0(){let t=this.bb.__offset(this.bb_pos,24);return t?!!this.bb.readInt8(this.bb_pos+t):!1}setAngleTo0(){let t=this.bb.__offset(this.bb_pos,26);return t?!!this.bb.readInt8(this.bb_pos+t):!1}setScaleTo0(){let t=this.bb.__offset(this.bb_pos,28);return t?!!this.bb.readInt8(this.bb_pos+t):!1}zOrder(){let t=this.bb.__offset(this.bb_pos,30);return t?this.bb.readUint16(this.bb_pos+t):null}bigZOrder(){let t=this.bb.__offset(this.bb_pos,32);return t?this.bb.readUint32(this.bb_pos+t):null}visible(){let t=this.bb.__offset(this.bb_pos,34);return t?this.bb.readUint8(this.bb_pos+t):null}flippedX(){let t=this.bb.__offset(this.bb_pos,36);return t?this.bb.readUint8(this.bb_pos+t):null}flippedY(){let t=this.bb.__offset(this.bb_pos,38);return t?this.bb.readUint8(this.bb_pos+t):null}opacity(){let t=this.bb.__offset(this.bb_pos,40);return t?this.bb.readUint8(this.bb_pos+t):null}setOpacityTo0(){let t=this.bb.__offset(this.bb_pos,42);return t?!!this.bb.readInt8(this.bb_pos+t):!1}animation(){let t=this.bb.__offset(this.bb_pos,44);return t?this.bb.readUint8(this.bb_pos+t):null}text(t){let e=this.bb.__offset(this.bb_pos,46);return e?this.bb.__string(this.bb_pos+e,t):null}static startObjState(t){t.startObject(22)}static addX(t,e){t.addFieldFloat32(0,e,0)}static addY(t,e){t.addFieldFloat32(1,e,0)}static addHeight(t,e){t.addFieldFloat32(2,e,0)}static addWidth(t,e){t.addFieldFloat32(3,e,0)}static addAngle(t,e){t.addFieldFloat32(4,e,0)}static addScale(t,e){t.addFieldFloat32(5,e,0)}static addTint(t,e){t.addFieldStruct(6,e,0)}static addSetXTo0(t,e){t.addFieldInt8(7,+e,0)}static addSetYTo0(t,e){t.addFieldInt8(8,+e,0)}static addSetHeightTo0(t,e){t.addFieldInt8(9,+e,0)}static addSetWidthTo0(t,e){t.addFieldInt8(10,+e,0)}static addSetAngleTo0(t,e){t.addFieldInt8(11,+e,0)}static addSetScaleTo0(t,e){t.addFieldInt8(12,+e,0)}static addZOrder(t,e){t.addFieldInt16(13,e,0)}static addBigZOrder(t,e){t.addFieldInt32(14,e,0)}static addVisible(t,e){t.addFieldInt8(15,e,0)}static addFlippedX(t,e){t.addFieldInt8(16,e,0)}static addFlippedY(t,e){t.addFieldInt8(17,e,0)}static addOpacity(t,e){t.addFieldInt8(18,e,0)}static addSetOpacityTo0(t,e){t.addFieldInt8(19,+e,0)}static addAnimation(t,e){t.addFieldInt8(20,e,0)}static addText(t,e){t.addFieldOffset(21,e,0)}static endObjState(t){return t.endObject()}},G=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsGameObject(t,e){return(e||new G).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsGameObject(t,e){return t.setPosition(t.position()+4),(e||new G).__init(t.readInt32(t.position())+t.position(),t)}id(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readUint16(this.bb_pos+t):0}name(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}objState(t){let e=this.bb.__offset(this.bb_pos,8);return e?(t||new j).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}publicStateDiff(t){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readUint8(this.bb.__vector(this.bb_pos+e)+t):0}publicStateDiffLength(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}publicStateDiffArray(){let t=this.bb.__offset(this.bb_pos,10);return t?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}privateStateDiff(t){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.readUint8(this.bb.__vector(this.bb_pos+e)+t):0}privateStateDiffLength(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}privateStateDiffArray(){let t=this.bb.__offset(this.bb_pos,12);return t?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}packedPublicState(t){let e=this.bb.__offset(this.bb_pos,14);return e?this.bb.readUint8(this.bb.__vector(this.bb_pos+e)+t):0}packedPublicStateLength(){let t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}packedPublicStateArray(){let t=this.bb.__offset(this.bb_pos,14);return t?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}packedPrivateState(t){let e=this.bb.__offset(this.bb_pos,16);return e?this.bb.readUint8(this.bb.__vector(this.bb_pos+e)+t):0}packedPrivateStateLength(){let t=this.bb.__offset(this.bb_pos,16);return t?this.bb.__vector_len(this.bb_pos+t):0}packedPrivateStateArray(){let t=this.bb.__offset(this.bb_pos,16);return t?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}static startGameObject(t){t.startObject(7)}static addId(t,e){t.addFieldInt16(0,e,0)}static addName(t,e){t.addFieldOffset(1,e,0)}static addObjState(t,e){t.addFieldOffset(2,e,0)}static addPublicStateDiff(t,e){t.addFieldOffset(3,e,0)}static createPublicStateDiffVector(t,e){t.startVector(1,e.length,1);for(let i=e.length-1;i>=0;i--)t.addInt8(e[i]);return t.endVector()}static startPublicStateDiffVector(t,e){t.startVector(1,e,1)}static addPrivateStateDiff(t,e){t.addFieldOffset(4,e,0)}static createPrivateStateDiffVector(t,e){t.startVector(1,e.length,1);for(let i=e.length-1;i>=0;i--)t.addInt8(e[i]);return t.endVector()}static startPrivateStateDiffVector(t,e){t.startVector(1,e,1)}static addPackedPublicState(t,e){t.addFieldOffset(5,e,0)}static createPackedPublicStateVector(t,e){t.startVector(1,e.length,1);for(let i=e.length-1;i>=0;i--)t.addInt8(e[i]);return t.endVector()}static startPackedPublicStateVector(t,e){t.startVector(1,e,1)}static addPackedPrivateState(t,e){t.addFieldOffset(6,e,0)}static createPackedPrivateStateVector(t,e){t.startVector(1,e.length,1);for(let i=e.length-1;i>=0;i--)t.addInt8(e[i]);return t.endVector()}static startPackedPrivateStateVector(t,e){t.startVector(1,e,1)}static endGameObject(t){return t.endObject()}},Q=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsGameStateSnapshot(t,e){return(e||new Q).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsGameStateSnapshot(t,e){return t.setPosition(t.position()+4),(e||new Q).__init(t.readInt32(t.position())+t.position(),t)}objects(t,e){let i=this.bb.__offset(this.bb_pos,4);return i?(e||new G).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+t*4),this.bb):null}objectsLength(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}publicStatePacked(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb.__vector(this.bb_pos+e)+t):0}publicStatePackedLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}publicStatePackedArray(){let t=this.bb.__offset(this.bb_pos,6);return t?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}privateStatePacked(t){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readUint8(this.bb.__vector(this.bb_pos+e)+t):0}privateStatePackedLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}privateStatePackedArray(){let t=this.bb.__offset(this.bb_pos,8);return t?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}static startGameStateSnapshot(t){t.startObject(3)}static addObjects(t,e){t.addFieldOffset(0,e,0)}static createObjectsVector(t,e){t.startVector(4,e.length,4);for(let i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startObjectsVector(t,e){t.startVector(4,e,4)}static addPublicStatePacked(t,e){t.addFieldOffset(1,e,0)}static createPublicStatePackedVector(t,e){t.startVector(1,e.length,1);for(let i=e.length-1;i>=0;i--)t.addInt8(e[i]);return t.endVector()}static startPublicStatePackedVector(t,e){t.startVector(1,e,1)}static addPrivateStatePacked(t,e){t.addFieldOffset(2,e,0)}static createPrivateStatePackedVector(t,e){t.startVector(1,e.length,1);for(let i=e.length-1;i>=0;i--)t.addInt8(e[i]);return t.endVector()}static startPrivateStatePackedVector(t,e){t.startVector(1,e,1)}static endGameStateSnapshot(t){return t.endObject()}static createGameStateSnapshot(t,e,i,a){return Q.startGameStateSnapshot(t),Q.addObjects(t,e),Q.addPublicStatePacked(t,i),Q.addPrivateStatePacked(t,a),Q.endGameStateSnapshot(t)}},Zt=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsConnectionStartMessage(t,e){return(e||new Zt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsConnectionStartMessage(t,e){return t.setPosition(t.position()+4),(e||new Zt).__init(t.readInt32(t.position())+t.position(),t)}sceneName(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}sceneSnapshot(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new Q).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startConnectionStartMessage(t){t.startObject(2)}static addSceneName(t,e){t.addFieldOffset(0,e,0)}static addSceneSnapshot(t,e){t.addFieldOffset(1,e,0)}static endConnectionStartMessage(t){let e=t.endObject();return t.requiredField(e,4),t.requiredField(e,6),e}},Ut=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsCreatedObject(t,e){return(e||new Ut).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsCreatedObject(t,e){return t.setPosition(t.position()+4),(e||new Ut).__init(t.readInt32(t.position())+t.position(),t)}id(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readUint16(this.bb_pos+t):0}name(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}static startCreatedObject(t){t.startObject(2)}static addId(t,e){t.addFieldInt16(0,e,0)}static addName(t,e){t.addFieldOffset(1,e,0)}static endCreatedObject(t){let e=t.endObject();return t.requiredField(e,6),e}static createCreatedObject(t,e,i){return Ut.startCreatedObject(t),Ut.addId(t,e),Ut.addName(t,i),Ut.endCreatedObject(t)}},Y=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsScene(t,e){return(e||new Y).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsScene(t,e){return t.setPosition(t.position()+4),(e||new Y).__init(t.readInt32(t.position())+t.position(),t)}publicStateDiff(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readUint8(this.bb.__vector(this.bb_pos+e)+t):0}publicStateDiffLength(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}publicStateDiffArray(){let t=this.bb.__offset(this.bb_pos,4);return t?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}privateStateDiff(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb.__vector(this.bb_pos+e)+t):0}privateStateDiffLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}privateStateDiffArray(){let t=this.bb.__offset(this.bb_pos,6);return t?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}objects(t,e){let i=this.bb.__offset(this.bb_pos,8);return i?(e||new G).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+t*4),this.bb):null}objectsLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}createdObjects(t,e){let i=this.bb.__offset(this.bb_pos,10);return i?(e||new Ut).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+t*4),this.bb):null}createdObjectsLength(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}deletedObjects(t){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.readUint16(this.bb.__vector(this.bb_pos+e)+t*2):0}deletedObjectsLength(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}deletedObjectsArray(){let t=this.bb.__offset(this.bb_pos,12);return t?new Uint16Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}static startScene(t){t.startObject(5)}static addPublicStateDiff(t,e){t.addFieldOffset(0,e,0)}static createPublicStateDiffVector(t,e){t.startVector(1,e.length,1);for(let i=e.length-1;i>=0;i--)t.addInt8(e[i]);return t.endVector()}static startPublicStateDiffVector(t,e){t.startVector(1,e,1)}static addPrivateStateDiff(t,e){t.addFieldOffset(1,e,0)}static createPrivateStateDiffVector(t,e){t.startVector(1,e.length,1);for(let i=e.length-1;i>=0;i--)t.addInt8(e[i]);return t.endVector()}static startPrivateStateDiffVector(t,e){t.startVector(1,e,1)}static addObjects(t,e){t.addFieldOffset(2,e,0)}static createObjectsVector(t,e){t.startVector(4,e.length,4);for(let i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startObjectsVector(t,e){t.startVector(4,e,4)}static addCreatedObjects(t,e){t.addFieldOffset(3,e,0)}static createCreatedObjectsVector(t,e){t.startVector(4,e.length,4);for(let i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startCreatedObjectsVector(t,e){t.startVector(4,e,4)}static addDeletedObjects(t,e){t.addFieldOffset(4,e,0)}static createDeletedObjectsVector(t,e){t.startVector(2,e.length,2);for(let i=e.length-1;i>=0;i--)t.addInt16(e[i]);return t.endVector()}static startDeletedObjectsVector(t,e){t.startVector(2,e,2)}static endScene(t){return t.endObject()}static createScene(t,e,i,a,s,n){return Y.startScene(t),Y.addPublicStateDiff(t,e),Y.addPrivateStateDiff(t,i),Y.addObjects(t,a),Y.addCreatedObjects(t,s),Y.addDeletedObjects(t,n),Y.endScene(t)}},Ot=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsGameStateUpdateMessage(t,e){return(e||new Ot).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsGameStateUpdateMessage(t,e){return t.setPosition(t.position()+4),(e||new Ot).__init(t.readInt32(t.position())+t.position(),t)}scene(t){let e=this.bb.__offset(this.bb_pos,4);return e?(t||new Y).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startGameStateUpdateMessage(t){t.startObject(1)}static addScene(t,e){t.addFieldOffset(0,e,0)}static endGameStateUpdateMessage(t){return t.endObject()}static createGameStateUpdateMessage(t,e){return Ot.startGameStateUpdateMessage(t),Ot.addScene(t,e),Ot.endGameStateUpdateMessage(t)}},ht=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsResumePreviousSceneMessage(t,e){return(e||new ht).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsResumePreviousSceneMessage(t,e){return t.setPosition(t.position()+4),(e||new ht).__init(t.readInt32(t.position())+t.position(),t)}snapshot(t){let e=this.bb.__offset(this.bb_pos,4);return e?(t||new Q).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}name(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}static startResumePreviousSceneMessage(t){t.startObject(2)}static addSnapshot(t,e){t.addFieldOffset(0,e,0)}static addName(t,e){t.addFieldOffset(1,e,0)}static endResumePreviousSceneMessage(t){return t.endObject()}static createResumePreviousSceneMessage(t,e,i){return ht.startResumePreviousSceneMessage(t),ht.addSnapshot(t,e),ht.addName(t,i),ht.endResumePreviousSceneMessage(t)}},dt=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsSceneSwitchMessage(t,e){return(e||new dt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSceneSwitchMessage(t,e){return t.setPosition(t.position()+4),(e||new dt).__init(t.readInt32(t.position())+t.position(),t)}sceneName(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}isPause(){let t=this.bb.__offset(this.bb_pos,6);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startSceneSwitchMessage(t){t.startObject(2)}static addSceneName(t,e){t.addFieldOffset(0,e,0)}static addIsPause(t,e){t.addFieldInt8(1,+e,0)}static endSceneSwitchMessage(t){let e=t.endObject();return t.requiredField(e,4),e}static createSceneSwitchMessage(t,e,i){return dt.startSceneSwitchMessage(t),dt.addSceneName(t,e),dt.addIsPause(t,i),dt.endSceneSwitchMessage(t)}},ct=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsServerMessage(t,e){return(e||new ct).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsServerMessage(t,e){return t.setPosition(t.position()+4),(e||new ct).__init(t.readInt32(t.position())+t.position(),t)}contentType(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readUint8(this.bb_pos+t):0}content(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__union(t,this.bb_pos+e):null}static startServerMessage(t){t.startObject(2)}static addContentType(t,e){t.addFieldInt8(0,e,0)}static addContent(t,e){t.addFieldOffset(1,e,0)}static endServerMessage(t){let e=t.endObject();return t.requiredField(e,6),e}static createServerMessage(t,e,i){return ct.startServerMessage(t),ct.addContentType(t,e),ct.addContent(t,i),ct.endServerMessage(t)}},yi;try{yi=new TextDecoder}catch{}var v,At,d=0,nt={},M,Ft,lt=0,pt=0,J,It,ot=[],z,Hi={useRecords:!1,mapsAsObjects:!0},Hs=class{},Ys=new Hs;Ys.name=\"MessagePack 0xC1\";var ee=!1,Gs=2;try{new Function(\"\")}catch{Gs=1/0}var He=class{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.sequential&&t.trusted!==!1&&(t.trusted=!0,!t.structures&&t.useRecords!=!1&&(t.structures=[],t.maxSharedStructures||(t.maxSharedStructures=0))),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0)),Object.assign(this,t)}unpack(t,e){if(v)return $s(()=>(vi(),this?this.unpack(t,e):He.prototype.unpack.call(Hi,t,e)));At=e>-1?e:t.length,d=0,pt=0,Ft=null,J=null,v=t;try{z=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(i){throw v=null,t instanceof Uint8Array?i:new Error(\"Source must be a Uint8Array or Buffer but was a \"+(t&&typeof t==\"object\"?t.constructor.name:typeof t))}if(this instanceof He){if(nt=this,this.structures)return M=this.structures,Ve();(!M||M.length>0)&&(M=[])}else nt=Hi,(!M||M.length>0)&&(M=[]);return Ve()}unpackMultiple(t,e){let i,a=0;try{ee=!0;let s=t.length,n=this?this.unpack(t,s):Qs.unpack(t,s);if(e){for(e(n);d=32&&(s.highByte=i-32>>5))}t.sharedLength=t.length;for(let i in e||[])if(i>=0){let a=t[i],s=e[i];s&&(a&&((t.restoreStructures||(t.restoreStructures=[]))[i]=a),t[i]=s)}return this.structures=t}decode(t,e){return this.unpack(t,e)}};function Ve(){try{if(!nt.trusted&&!ee){let e=M.sharedLength||0;eAt)throw new Error(\"Unexpected end of MessagePack data\");if(!ee)throw new Error(\"Data read, but end of buffer not reached \"+JSON.stringify(t).slice(0,100))}return t}catch(t){throw M.restoreStructures&&Yi(),vi(),(t instanceof RangeError||t.message.startsWith(\"Unexpected end of buffer\")||d>At)&&(t.incomplete=!0),t}}function Yi(){for(let t in M.restoreStructures)M[t]=M.restoreStructures[t];M.restoreStructures=null}function X(){let t=v[d++];if(t<160)if(t<128){if(t<64)return t;{let e=M[t&63]||nt.getStructures&&Xs()[t&63];return e?(e.read||(e.read=Ti(e,t&63)),e.read()):t}}else if(t<144)if(t-=128,nt.mapsAsObjects){let e={};for(let i=0;i=d)return Ft.slice(d-lt,(d+=e)-lt);if(pt==0&&At<140){let i=e<16?Vi(e):Ws(e);if(i!=null)return i}return mi(e)}else{let e;switch(t){case 192:return null;case 193:return J?(e=X(),e>0?J[1].slice(J.position1,J.position1+=e):J[0].slice(J.position0,J.position0-=e)):Ys;case 194:return!1;case 195:return!0;case 196:if(e=v[d++],e===void 0)throw new Error(\"Unexpected end of buffer\");return ei(e);case 197:return e=z.getUint16(d),d+=2,ei(e);case 198:return e=z.getUint32(d),d+=4,ei(e);case 199:return Nt(v[d++]);case 200:return e=z.getUint16(d),d+=2,Nt(e);case 201:return e=z.getUint32(d),d+=4,Nt(e);case 202:if(e=z.getFloat32(d),nt.useFloat32>2){let i=Fi[(v[d]&127)<<1|v[d+1]>>7];return d+=4,(i*e+(e>0?.5:-.5)>>0)/i}return d+=4,e;case 203:return e=z.getFloat64(d),d+=8,e;case 204:return v[d++];case 205:return e=z.getUint16(d),d+=2,e;case 206:return e=z.getUint32(d),d+=4,e;case 207:return nt.int64AsNumber?(e=z.getUint32(d)*4294967296,e+=z.getUint32(d+4)):e=z.getBigUint64(d),d+=8,e;case 208:return z.getInt8(d++);case 209:return e=z.getInt16(d),d+=2,e;case 210:return e=z.getInt32(d),d+=4,e;case 211:return nt.int64AsNumber?(e=z.getInt32(d)*4294967296,e+=z.getUint32(d+4)):e=z.getBigInt64(d),d+=8,e;case 212:if(e=v[d++],e==114)return $i(v[d++]&63);{let i=ot[e];if(i)return i.read?(d++,i.read(X())):i.noBuffer?(d++,i()):i(v.subarray(d,++d));throw new Error(\"Unknown extension \"+e)}case 213:return e=v[d],e==114?(d++,$i(v[d++]&63,v[d++])):Nt(2);case 214:return Nt(4);case 215:return Nt(8);case 216:return Nt(16);case 217:return e=v[d++],pt>=d?Ft.slice(d-lt,(d+=e)-lt):on(e);case 218:return e=z.getUint16(d),d+=2,pt>=d?Ft.slice(d-lt,(d+=e)-lt):ln(e);case 219:return e=z.getUint32(d),d+=4,pt>=d?Ft.slice(d-lt,(d+=e)-lt):hn(e);case 220:return e=z.getUint16(d),d+=2,Xi(e);case 221:return e=z.getUint32(d),d+=4,Xi(e);case 222:return e=z.getUint16(d),d+=2,Wi(e);case 223:return e=z.getUint32(d),d+=4,Wi(e);default:if(t>=224)return t-256;if(t===void 0){let i=new Error(\"Unexpected end of MessagePack data\");throw i.incomplete=!0,i}throw new Error(\"Unknown MessagePack token \"+t)}}}var rn=/^[a-zA-Z_$][a-zA-Z\\d_$]*$/;function Ti(t,e){function i(){if(i.count++>Gs){let s=t.read=new Function(\"r\",\"return function(){return {\"+t.map(n=>n===\"__proto__\"?\"__proto_:r()\":rn.test(n)?n+\":r()\":\"[\"+JSON.stringify(n)+\"]:r()\").join(\",\")+\"}}\")(X);return t.highByte===0&&(t.read=Gi(e,t.read)),s()}let a={};for(let s=0,n=t.length;sfunction(){let i=v[d++];if(i===0)return e();let a=t<32?-(t+(i<<5)):t+(i<<5),s=M[a]||Xs()[a];if(!s)throw new Error(\"Record id is not defined for \"+a);return s.read||(s.read=Ti(s,t)),s.read()};function Xs(){let t=$s(()=>(v=null,nt.getStructures()));return M=nt._mergeStructures(t,M)}var mi=Ie,on=Ie,ln=Ie,hn=Ie;function Ie(t){let e;if(t<16&&(e=Vi(t)))return e;if(t>64&&yi)return yi.decode(v.subarray(d,d+=t));let i=d+t,a=[];for(e=\"\";d65535&&(b-=65536,a.push(b>>>10&1023|55296),b=56320|b&1023),a.push(b)}else a.push(s);a.length>=4096&&(e+=q.apply(String,a),a.length=0)}return a.length>0&&(e+=q.apply(String,a)),e}function Xi(t){let e=new Array(t);for(let i=0;i0){d=e;return}i[a]=s}return q.apply(String,i)}function Vi(t){if(t<4)if(t<2){if(t===0)return\"\";{let e=v[d++];if((e&128)>1){d-=1;return}return q(e)}}else{let e=v[d++],i=v[d++];if((e&128)>0||(i&128)>0){d-=2;return}if(t<3)return q(e,i);let a=v[d++];if((a&128)>0){d-=3;return}return q(e,i,a)}else{let e=v[d++],i=v[d++],a=v[d++],s=v[d++];if((e&128)>0||(i&128)>0||(a&128)>0||(s&128)>0){d-=4;return}if(t<6){if(t===4)return q(e,i,a,s);{let n=v[d++];if((n&128)>0){d-=5;return}return q(e,i,a,s,n)}}else if(t<8){let n=v[d++],r=v[d++];if((n&128)>0||(r&128)>0){d-=6;return}if(t<7)return q(e,i,a,s,n,r);let o=v[d++];if((o&128)>0){d-=7;return}return q(e,i,a,s,n,r,o)}else{let n=v[d++],r=v[d++],o=v[d++],b=v[d++];if((n&128)>0||(r&128)>0||(o&128)>0||(b&128)>0){d-=8;return}if(t<10){if(t===8)return q(e,i,a,s,n,r,o,b);{let l=v[d++];if((l&128)>0){d-=9;return}return q(e,i,a,s,n,r,o,b,l)}}else if(t<12){let l=v[d++],h=v[d++];if((l&128)>0||(h&128)>0){d-=10;return}if(t<11)return q(e,i,a,s,n,r,o,b,l,h);let O=v[d++];if((O&128)>0){d-=11;return}return q(e,i,a,s,n,r,o,b,l,h,O)}else{let l=v[d++],h=v[d++],O=v[d++],w=v[d++];if((l&128)>0||(h&128)>0||(O&128)>0||(w&128)>0){d-=12;return}if(t<14){if(t===12)return q(e,i,a,s,n,r,o,b,l,h,O,w);{let _=v[d++];if((_&128)>0){d-=13;return}return q(e,i,a,s,n,r,o,b,l,h,O,w,_)}}else{let _=v[d++],V=v[d++];if((_&128)>0||(V&128)>0){d-=14;return}if(t<15)return q(e,i,a,s,n,r,o,b,l,h,O,w,_,V);let U=v[d++];if((U&128)>0){d-=15;return}return q(e,i,a,s,n,r,o,b,l,h,O,w,_,V,U)}}}}}function Ki(){let t=v[d++],e;if(t<192)e=t-160;else switch(t){case 217:e=v[d++];break;case 218:e=z.getUint16(d),d+=2;break;case 219:e=z.getUint32(d),d+=4;break;default:throw new Error(\"Expected string\")}return Ie(e)}function ei(t){return nt.copyBuffers?Uint8Array.prototype.slice.call(v,d,d+=t):v.subarray(d,d+=t)}function Nt(t){let e=v[d++];if(ot[e])return ot[e](v.subarray(d,d+=t));throw new Error(\"Unknown extension type \"+e)}var qi=new Array(4096);function Ks(){let t=v[d++];if(t>=160&&t<192){if(t=t-160,pt>=d)return Ft.slice(d-lt,(d+=t)-lt);if(!(pt==0&&At<180))return mi(t)}else return d--,X();let e=(t<<5^(t>1?z.getUint16(d):t>0?v[d]:0))&4095,i=qi[e],a=d,s=d+t-3,n,r=0;if(i&&i.bytes==t){for(;a{var i=X();let a=t;e!==void 0&&(t=t<32?-((e<<5)+t):(e<<5)+t,i.highByte=e);let s=M[t];return s&&s.isShared&&((M.restoreStructures||(M.restoreStructures=[]))[t]=s),M[t]=i,i.read=Ti(i,a),i.read()};ot[0]=()=>{};ot[0].noBuffer=!0;ot[101]=()=>{let t=X();return(globalThis[t[0]]||Error)(t[1])};ot[105]=t=>{let e=z.getUint32(d-4);It||(It=new Map);let i=v[d],a;i>=144&&i<160||i==220||i==221?a=[]:a={};let s={target:a};It.set(e,s);let n=X();return s.used?Object.assign(a,n):(s.target=n,n)};ot[112]=t=>{let e=z.getUint32(d-4),i=It.get(e);return i.used=!0,i.target};ot[115]=()=>new Set(X());var qs=[\"Int8\",\"Uint8\",\"Uint8Clamped\",\"Int16\",\"Uint16\",\"Int32\",\"Uint32\",\"Float32\",\"Float64\",\"BigInt64\",\"BigUint64\"].map(t=>t+\"Array\");ot[116]=t=>{let e=t[0],i=qs[e];if(!i)throw new Error(\"Could not find typed array for code \"+e);return new globalThis[i](Uint8Array.prototype.slice.call(t,1).buffer)};ot[120]=()=>{let t=X();return new RegExp(t[0],t[1])};var dn=[];ot[98]=t=>{let e=(t[0]<<24)+(t[1]<<16)+(t[2]<<8)+t[3],i=d;return d+=e-t.length,J=dn,J=[Ki(),Ki()],J.position0=0,J.position1=0,J.postBundlePosition=d,d=i,X()};ot[255]=t=>t.length==4?new Date((t[0]*16777216+(t[1]<<16)+(t[2]<<8)+t[3])*1e3):t.length==8?new Date(((t[0]<<22)+(t[1]<<14)+(t[2]<<6)+(t[3]>>2))/1e6+((t[3]&3)*4294967296+t[4]*16777216+(t[5]<<16)+(t[6]<<8)+t[7])*1e3):t.length==12?new Date(((t[0]<<24)+(t[1]<<16)+(t[2]<<8)+t[3])/1e6+((t[4]&128?-281474976710656:0)+t[6]*1099511627776+t[7]*4294967296+t[8]*16777216+(t[9]<<16)+(t[10]<<8)+t[11])*1e3):new Date(\"invalid\");function $s(t){let e=At,i=d,a=lt,s=pt,n=Ft,r=It,o=J,b=new Uint8Array(v.slice(0,At)),l=M,h=M.slice(0,M.length),O=nt,w=ee,_=t();return At=e,d=i,lt=a,pt=s,Ft=n,It=r,J=o,v=b,ee=w,M=l,M.splice(0,M.length,...h),nt=O,z=new DataView(v.buffer,v.byteOffset,v.byteLength),_}function vi(){v=null,It=null,M=null}var Fi=new Array(147);for(let t=0;t<256;t++)Fi[t]=+(\"1e\"+Math.floor(45.15-t*.30103));var Qs=new He({useRecords:!1}),cn=Qs.unpack,Be;try{Be=new TextEncoder}catch{}var Si,Js,qe=typeof Buffer<\"u\",Fe=qe?function(t){return Buffer.allocUnsafeSlow(t)}:Uint8Array,ta=qe?Buffer:Uint8Array,Qi=qe?4294967296:2144337920,f,oe,H,c=0,it,K=null,bn=61440,un=/[\\u0080-\\uFFFF]/,qt=Symbol(\"record-id\"),fn=class extends He{constructor(t){super(t),this.offset=0;let e,i,a,s,n=0,r=ta.prototype.utf8Write?function(u,S){return f.utf8Write(u,S,4294967295)}:Be&&Be.encodeInto?function(u,S){return Be.encodeInto(u,f.subarray(S)).written}:!1,o=this;t||(t={});let b=t&&t.sequential,l=t.structures||t.saveStructures,h=t.maxSharedStructures;if(h==null&&(h=l?32:0),h>8160)throw new Error(\"Maximum maxSharedStructure is 8160\");t.structuredClone&&t.moreTypes==null&&(t.moreTypes=!0);let O=t.maxOwnStructures;O==null&&(O=l?32:64),!this.structures&&t.useRecords!=!1&&(this.structures=[]);let w=h>32||O+h>64,_=h+64,V=h+O+64;if(V>8256)throw new Error(\"Maximum maxSharedStructure + maxOwnStructure is 8192\");let U=[],x=0,I=0;this.pack=this.encode=function(u,S){if(f||(f=new Fe(8192),H=new DataView(f.buffer,0,8192),c=0),it=f.length-10,it-c<2048?(f=new Fe(f.length),H=new DataView(f.buffer,0,f.length),it=f.length-10,c=0):c=c+7&2147483640,e=c,s=o.structuredClone?new Map:null,o.bundleStrings&&typeof u!=\"string\"?(K=[],K.size=1/0):K=null,a=o.structures,a){a.uninitialized&&(a=o._mergeStructures(o.getStructures()));let p=a.sharedLength||0;if(p>h)throw new Error(\"Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to \"+a.sharedLength);if(!a.transitions){a.transitions=Object.create(null);for(let g=0;git&&A(c),o.offset=c;let p=pn(f.subarray(e,c),s.idsToInsert);return s=null,p}return S&yn?(f.start=e,f.end=c,f):f.subarray(e,c)}finally{if(a){I<10&&I++;let p=a.sharedLength||h;if(a.length>p&&(a.length=p),x>1e4)a.transitions=null,I=0,x=0,U.length>0&&(U=[]);else if(U.length>0&&!b){for(let g=0,y=U.length;g{c>it&&(f=A(c));var S=typeof u,p;if(S===\"string\"){let g=u.length;if(K&&g>=4&&g<4096){if((K.size+=g)>bn){let C,L=(K[0]?K[0].length*3+K[1].length:0)+10;c+L>it&&(f=A(c+L)),K.position?(f[c]=200,c+=3,f[c++]=98,C=c-e,c+=4,es(e,k),H.setUint16(C+e-3,c-e-C)):(f[c++]=214,f[c++]=98,C=c-e,c+=4),K=[\"\",\"\"],K.size=0,K.position=C}let T=un.test(u);K[T?0:1]+=u,f[c++]=193,k(T?-g:g);return}let y;g<32?y=1:g<256?y=2:g<65536?y=3:y=5;let R=g*3;if(c+R>it&&(f=A(c+R)),g<64||!r){let T,C,L,E=c+y;for(T=0;T>6|192,f[E++]=C&63|128):(C&64512)===55296&&((L=u.charCodeAt(T+1))&64512)===56320?(C=65536+((C&1023)<<10)+(L&1023),T++,f[E++]=C>>18|240,f[E++]=C>>12&63|128,f[E++]=C>>6&63|128,f[E++]=C&63|128):(f[E++]=C>>12|224,f[E++]=C>>6&63|128,f[E++]=C&63|128);p=E-c-y}else p=r(u,c+y);p<32?f[c++]=160|p:p<256?(y<2&&f.copyWithin(c+2,c+1,c+1+p),f[c++]=217,f[c++]=p):p<65536?(y<3&&f.copyWithin(c+3,c+2,c+2+p),f[c++]=218,f[c++]=p>>8,f[c++]=p&255):(y<5&&f.copyWithin(c+5,c+3,c+3+p),f[c++]=219,H.setUint32(c,p),c+=4),c+=p}else if(S===\"number\")if(u>>>0===u)u<64||u<128&&this.useRecords===!1?f[c++]=u:u<256?(f[c++]=204,f[c++]=u):u<65536?(f[c++]=205,f[c++]=u>>8,f[c++]=u&255):(f[c++]=206,H.setUint32(c,u),c+=4);else if(u>>0===u)u>=-32?f[c++]=256+u:u>=-128?(f[c++]=208,f[c++]=u+256):u>=-32768?(f[c++]=209,H.setInt16(c,u),c+=2):(f[c++]=210,H.setInt32(c,u),c+=4);else{let g;if((g=this.useFloat32)>0&&u<4294967296&&u>=-2147483648){f[c++]=202,H.setFloat32(c,u);let y;if(g<4||(y=u*Fi[(f[c]&127)<<1|f[c+1]>>7])>>0===y){c+=4;return}else c--}f[c++]=203,H.setFloat64(c,u),c+=8}else if(S===\"object\")if(!u)f[c++]=192;else{if(s){let y=s.get(u);if(y){if(!y.id){let R=s.idsToInsert||(s.idsToInsert=[]);y.id=R.push(y)}f[c++]=214,f[c++]=112,H.setUint32(c,y.id),c+=4;return}else s.set(u,{offset:c-e})}let g=u.constructor;if(g===Object)m(u,!0);else if(g===Array){p=u.length,p<16?f[c++]=144|p:p<65536?(f[c++]=220,f[c++]=p>>8,f[c++]=p&255):(f[c++]=221,H.setUint32(c,p),c+=4);for(let y=0;y>8,f[c++]=p&255):(f[c++]=223,H.setUint32(c,p),c+=4);for(let[y,R]of u)k(y),k(R)}else{for(let y=0,R=Si.length;y(f=L,L=null,c+=re,c>it&&A(c),{target:f,targetView:H,position:c-re}),k)}finally{L&&(f=L,H=E,c=at,it=f.length-10)}Et&&(Et.length+c>it&&A(Et.length+c),c=_n(Et,f,c,C.type));return}}m(u,!u.hasOwnProperty)}}else if(S===\"boolean\")f[c++]=u?195:194;else if(S===\"bigint\"){if(u=-(BigInt(1)<0)f[c++]=207,H.setBigUint64(c,u);else if(this.largeBigIntToFloat)f[c++]=203,H.setFloat64(c,Number(u));else throw new RangeError(u+\" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64\");c+=8}else if(S===\"undefined\")this.encodeUndefinedAsNil?f[c++]=192:(f[c++]=212,f[c++]=0,f[c++]=0);else if(S===\"function\")k(this.writeFunction&&this.writeFunction());else throw new Error(\"Unknown type: \"+S)},m=this.useRecords===!1?this.variableMapSize?u=>{let S=Object.keys(u),p=S.length;p<16?f[c++]=128|p:p<65536?(f[c++]=222,f[c++]=p>>8,f[c++]=p&255):(f[c++]=223,H.setUint32(c,p),c+=4);let g;for(let y=0;y{f[c++]=222;let p=c-e;c+=2;let g=0;for(let y in u)(S||u.hasOwnProperty(y))&&(k(y),k(u[y]),g++);f[p+++e]=g>>8,f[p+e]=g&255}:t.progressiveRecords&&!w?(u,S)=>{let p,g=a.transitions||(a.transitions=Object.create(null)),y=c++-e,R;for(let T in u)if(S||u.hasOwnProperty(T)){if(p=g[T],p)g=p;else{let C=Object.keys(u),L=g;g=a.transitions;let E=0;for(let at=0,Et=C.length;at{let p,g=a.transitions||(a.transitions=Object.create(null)),y=0;for(let T in u)(S||u.hasOwnProperty(T))&&(p=g[T],p||(p=g[T]=Object.create(null),y++),g=p);let R=g[qt];R?R>=96&&w?(f[c++]=((R-=96)&31)+96,f[c++]=R>>5):f[c++]=R:Z(g,g.__keys__||Object.keys(u),y);for(let T in u)(S||u.hasOwnProperty(T))&&k(u[T])},A=u=>{let S;if(u>16777216){if(u-e>Qi)throw new Error(\"Packed buffer would be larger than maximum buffer size\");S=Math.min(Qi,Math.round(Math.max((u-e)*(u>67108864?1.25:2),4194304)/4096)*4096)}else S=(Math.max(u-e<<2,f.length-1)>>12)+1<<12;let p=new Fe(S);return H=new DataView(p.buffer,0,S),u=Math.min(u,f.length),f.copy?f.copy(p,0,e,u):p.set(f.slice(e,u)),c-=e,e=0,it=p.length-10,f=p},Z=(u,S,p)=>{let g=a.nextId;g||(g=64),g<_&&this.shouldShareStructure&&!this.shouldShareStructure(S)?(g=a.nextOwnId,g=V&&(g=_),a.nextId=g+1);let y=S.highByte=g>=96&&w?g-96>>5:-1;u[qt]=g,u.__keys__=S,a[g-64]=S,g<_?(S.isShared=!0,a.sharedLength=g-63,i=!0,y>=0?(f[c++]=(g&31)+96,f[c++]=y):f[c++]=g):(y>=0?(f[c++]=213,f[c++]=114,f[c++]=(g&31)+96,f[c++]=y):(f[c++]=212,f[c++]=114,f[c++]=g),p&&(x+=I*p),U.length>=O&&(U.shift()[qt]=0),U.push(u),k(S))},F=(u,S,p,g)=>{let y=f,R=c,T=it,C=e;f=oe,c=0,e=0,f||(oe=f=new Fe(8192)),it=f.length-10,Z(u,S,g),oe=f;let L=c;if(f=y,c=R,it=T,e=C,L>1){let E=c+L-1;E>it&&A(E);let at=p+e;f.copyWithin(at+L,at+1,c),f.set(oe.slice(0,L),at),c=E}else f[p+e]=oe[0]}}useBuffer(t){f=t,H=new DataView(f.buffer,f.byteOffset,f.byteLength),c=0}clearSharedData(){this.structures&&(this.structures=[])}};Js=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Hs];Si=[{pack(t,e,i){let a=t.getTime()/1e3;if((this.useTimestamp32||t.getMilliseconds()===0)&&a>=0&&a<4294967296){let{target:s,targetView:n,position:r}=e(6);s[r++]=214,s[r++]=255,n.setUint32(r,a)}else if(a>0&&a<4294967296){let{target:s,targetView:n,position:r}=e(10);s[r++]=215,s[r++]=255,n.setUint32(r,t.getMilliseconds()*4e6+(a/1e3/4294967296>>0)),n.setUint32(r+4,a)}else if(isNaN(a)){if(this.onInvalidDate)return e(0),i(this.onInvalidDate());let{target:s,targetView:n,position:r}=e(3);s[r++]=212,s[r++]=255,s[r++]=255}else{let{target:s,targetView:n,position:r}=e(15);s[r++]=199,s[r++]=12,s[r++]=255,n.setUint32(r,t.getMilliseconds()*1e6),n.setBigInt64(r+4,BigInt(Math.floor(a)))}}},{pack(t,e,i){let a=Array.from(t),{target:s,position:n}=e(this.moreTypes?3:0);this.moreTypes&&(s[n++]=212,s[n++]=115,s[n++]=0),i(a)}},{pack(t,e,i){let{target:a,position:s}=e(this.moreTypes?3:0);this.moreTypes&&(a[s++]=212,a[s++]=101,a[s++]=0),i([t.name,t.message])}},{pack(t,e,i){let{target:a,position:s}=e(this.moreTypes?3:0);this.moreTypes&&(a[s++]=212,a[s++]=120,a[s++]=0),i([t.source,t.flags])}},{pack(t,e){this.moreTypes?Ji(t,16,e):ts(qe?Buffer.from(t):new Uint8Array(t),e)}},{pack(t,e){let i=t.constructor;i!==ta&&this.moreTypes?Ji(t,qs.indexOf(i.name),e):ts(t,e)}},{pack(t,e){let{target:i,position:a}=e(1);i[a]=193}}];function Ji(t,e,i,a){let s=t.byteLength;if(s+1<256){var{target:n,position:r}=i(4+s);n[r++]=199,n[r++]=s+1}else if(s+1<65536){var{target:n,position:r}=i(5+s);n[r++]=200,n[r++]=s+1>>8,n[r++]=s+1&255}else{var{target:n,position:r,targetView:o}=i(7+s);n[r++]=201,o.setUint32(r,s+1),r+=4}n[r++]=116,n[r++]=e,n.set(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),r)}function ts(t,e){let i=t.byteLength;var a,s;if(i<256){var{target:a,position:s}=e(i+2);a[s++]=196,a[s++]=i}else if(i<65536){var{target:a,position:s}=e(i+3);a[s++]=197,a[s++]=i>>8,a[s++]=i&255}else{var{target:a,position:s,targetView:n}=e(i+5);a[s++]=198,n.setUint32(s,i),s+=4}a.set(t,s)}function _n(t,e,i,a){let s=t.length;switch(s){case 1:e[i++]=212;break;case 2:e[i++]=213;break;case 4:e[i++]=214;break;case 8:e[i++]=215;break;case 16:e[i++]=216;break;default:s<256?(e[i++]=199,e[i++]=s):s<65536?(e[i++]=200,e[i++]=s>>8,e[i++]=s&255):(e[i++]=201,e[i++]=s>>24,e[i++]=s>>16&255,e[i++]=s>>8&255,e[i++]=s&255)}return e[i++]=a,e.set(t,i),i+=s,i}function pn(t,e){let i,a=e.length*6,s=t.length-a;for(e.sort((n,r)=>n.offset>r.offset?1:-1);i=e.pop();){let n=i.offset,r=i.id;t.copyWithin(n+a,n,s),a-=6;let o=n+a;t[o++]=214,t[o++]=105,t[o++]=r>>24,t[o++]=r>>16&255,t[o++]=r>>8&255,t[o++]=r&255,s=n}return t}function es(t,e){if(K.length>0){H.setUint32(K.position+t,c-K.position-t);let i=K;K=null,e(i[0]),e(i[1])}}var gn=new fn({useRecords:!1}),wn=gn.pack,yn=512,mn=1024,_e=t=>wn(t.toJSObject()),pe=(t,e)=>t.fromJSObject(cn(e)),ea=(t,e,i)=>{if(!e.thnkServer)return-1;let{stateVariables:a,objectsRegistery:s}=e.thnkServer,{publicStateVariable:n,privateStateVariable:r}=a,o=n.getChildrenCount()!==0?Q.createPublicStatePackedVector(t,_e(n)):null,b=r.getChild(i),l=b.getChildrenCount()!==0?Q.createPrivateStatePackedVector(t,_e(b)):null,h=s.createObjectsSnapshot(t,i),O=h.length?Q.createObjectsVector(t,h):null;return Q.startGameStateSnapshot(t),o&&Q.addPublicStatePacked(t,o),l&&Q.addPrivateStatePacked(t,l),O&&Q.addObjects(t,O),Q.endGameStateSnapshot(t)},vn=(t,e,i)=>{let a=new Bt(512),s=a.createString(i.getName()),n=ea(a,i,t);Zt.startConnectionStartMessage(a),Zt.addSceneName(a,s),Zt.addSceneSnapshot(a,n),e.sendServerMessageTo(t,a,ct.createServerMessage(a,1,Zt.endConnectionStartMessage(a)))},Sn=(t,e,i)=>{let a=new Bt(256),s=i.serialize(a,t);if(!s)return;Ot.startGameStateUpdateMessage(a),Ot.addScene(a,s);let n=Ot.endGameStateUpdateMessage(a);e.sendServerMessageTo(t,a,ct.createServerMessage(a,2,n))},kn=(t,e,i)=>{let a=new Bt(512),s=a.createString(e);dt.startSceneSwitchMessage(a),dt.addSceneName(a,s),dt.addIsPause(a,i),t.sendServerMessageToAll(a,ct.createServerMessage(a,3,dt.endSceneSwitchMessage(a)))},ii=(t,e,i)=>{for(let a of t){let s=new Bt(512),n=i?s.createString(i.getName()):null,r=i?ea(s,i,a):null;ht.startResumePreviousSceneMessage(s),r&&n&&(ht.addSnapshot(s,r),ht.addName(s,n));let o=ct.createServerMessage(s,4,ht.endResumePreviousSceneMessage(s));e.sendServerMessageTo(a,s,o)}},ia={};Ke(ia,{getCurrentPlayerID:()=>On,markObjectAsOwned:()=>An,pickOwnedObjects:()=>In,switchPlayerContext:()=>Ye});var ge=\"\",ki=new Map,On=()=>ge,Ye=t=>{ge=t},An=t=>{let e=ki.get(ge);e||ki.set(ge,e=new gdjs.LongLivedObjectsList),e.addObject(t.getName(),t)},In=t=>{let e=ki.get(ge);if(!e){for(let i of Object.values(t.items))i.length=0;return!1}for(let[i,a]of Object.entries(t.items))gdjs.copyArray(e.getObjects(i),a);return!0},is=new Map,Di=t=>{let e=is.get(t);return e||is.set(t,e=[]),e},jn=(t,e,i)=>{Di(e).push({initiatorUserID:t,serializedExtraData:i})},xn=(t,e,i)=>{Di(e).push({initiatorUserID:t,extraData:i})},Cn=(t,e)=>{let i=Di(t);if(i.length){let a=i.shift();return Ye(a.initiatorUserID),a.serializedExtraData?pe(e,a.serializedExtraData):a.extraData&&gdjs.Variable.copy(a.extraData,e),!0}return!1},Un=t=>{var e;return!!((e=t.thnkServer)!=null&&e.playerManager.popConnection())},Tn=t=>{var e;return!!((e=t.thnkServer)!=null&&e.playerManager.popDisconnection())},sa={};Ke(sa,{getTickRate:()=>Ri,isDedicated:()=>ra,setDedicated:()=>Vn,setTickRate:()=>Fn});var aa=!1,na=120,Vn=()=>{aa=!0},Fn=t=>{na=Math.max(1,t)},Ri=()=>na,ra=()=>aa,st=class extends gdjs.Variable{constructor(){super(...arguments),this.dirty=!0,this.operations=[]}static setupSyncedVariable(t,e){let i=new st;return t.has(e)&&gdjs.Variable.copy(t.get(e),i),t.add(e,i),i}static setupStateVariables(t){let e=st.setupSyncedVariable(t,\"State\"),i=st.setupSyncedVariable(t,\"PlayerState\"),a=st.setupSyncedVariable(t,\"TeamState\");return{publicStateVariable:e,privateStateVariable:i,teamStateVariable:a}}reinitialize(t){if(this._type=\"number\",this._value=0,this._str=\"0\",this._bool=!1,this._children={},this._childrenArray=[],this._undefinedInContainer=!1,t!==void 0){if(this._type=t.type||\"number\",this._type===\"number\")this._value=parseFloat(t.value||\"0\"),this._value!==this._value&&(this._value=0);else if(this._type===\"string\")this._str=\"\"+t.value||\"0\";else if(this._type===\"boolean\")this._bool=!!t.value;else if(this._type===\"structure\"){if(t.children!==void 0)for(var e=0,i=t.children.length;e{let[i,a,s]=e.split(\";\").map(n=>parseInt(n,10));return Ui.createRGB(t,i,a,s)},Rn=(t,e,i)=>{let a=e.getString?t.createSharedString(e.getString()):null;j.startObjState(t),j.addX(t,e.getX()),j.addY(t,e.getY()),j.addHeight(t,e.getHeight()),j.addWidth(t,e.getWidth()),j.addAngle(t,e.getAngle()),e.getX()===0&&j.addSetXTo0(t,!0),e.getY()===0&&j.addSetYTo0(t,!0),e.getHeight()===0&&j.addSetHeightTo0(t,!0),e.getWidth()===0&&j.addSetWidthTo0(t,!0),e.getAngle()===0&&j.addSetAngleTo0(t,!0),e.getZOrder()<=65535?j.addZOrder(t,e.getZOrder()+1):j.addBigZOrder(t,e.getZOrder()+1),j.addVisible(t,e.isHidden()?1:2),e.isFlippedX&&j.addFlippedX(t,e.isFlippedX()?1:2),e.isFlippedY&&j.addFlippedY(t,e.isFlippedY()?1:2),e.getOpacity&&(e.getOpacity()!==0?j.addOpacity(t,e.getOpacity()):j.addSetOpacityTo0(t,!0)),e.getAnimation&&j.addAnimation(t,e.getAnimation()+1),e.getColor&&j.addTint(t,oa(t,e.getColor())),a&&j.addText(t,a);let s=j.endObjState(t),{stateVariables:n}=e,{publicStateVariable:r,privateStateVariable:o}=n,b=r.getChildrenCount()!==0?G.createPackedPublicStateVector(t,_e(r)):null,l=o.getChild(i),h=l.getChildrenCount()!==0?G.createPackedPrivateStateVector(t,_e(l)):null,O=t.createSharedString(e.getName());return G.startGameObject(t),G.addId(t,e.thnkID),G.addName(t,O),G.addObjState(t,s),b&&G.addPackedPublicState(t,b),h&&G.addPackedPrivateState(t,h),G.endGameObject(t)},Pn=new gdjs.Logger(\"THNK - Objects replication\"),zn=class{constructor(){this.recycledIDs=[],this.currentNewID=1,this.generateNewID=()=>{let t=this.recycledIDs.pop()??this.currentNewID++;return t>65535?(Pn.error(\"Maximum amount of simultaneously replicated objects reached! Weird stuff is going to happen...\"),t%65535):t},this.registeredObjects=new Map,this.createdObjects=new Map,this.deletedObjects=new Set}forEach(t){for(let e of this.registeredObjects.values())t(e)}registerObject(t){t.thnkID=this.generateNewID(),this.registeredObjects.set(t.thnkID,t),this.createdObjects.set(t.thnkID,t.getName()),t.stateVariables=st.setupStateVariables(t.getVariables())}unregisterObject(t){this.recycledIDs.push(t.thnkID),this.registeredObjects.delete(t.thnkID),this.deletedObjects.add(t.thnkID),this.createdObjects.delete(t.thnkID)}createObjectsSnapshot(t,e){let i=[];for(let a of this.registeredObjects.values())i.push(Rn(t,a,e));return i}getCreatedObjects(){let t=[...this.createdObjects.entries()];return this.createdObjects.clear(),t}getDeletedObjects(){let t=Uint16Array.from(this.deletedObjects.values());return this.deletedObjects.clear(),t}},Mn=class{constructor(){this.currentDiff=0,this.diffsCount=Math.min(30,Ri()*4),this.diffs=new Array(this.diffsCount)}createSnapshot(t){let e=la.createDiff(t);return e&&(this.diffs[++this.currentDiff%this.diffsCount]=e),e}getSnapshot(t){return this.currentDiff-t>this.diffsCount?null:this.diffs[t%this.diffsCount]}},la=class{constructor(){}static createDiff(t){let e=ha.createDiff(t);if(!e)return null;let i=new la;return i.sceneDiff=e,i}serialize(t,e){var i;return(i=this.sceneDiff)==null?void 0:i.serialize(t,e)}},ha=class{constructor(){this.privateStateVariablesDiffs=new Map,this.teamStateVariablesDiffs=new Map,this.objectsDiff=new Map,this.deletedObjects=new Set,this.createdObjects=new Map}static createDiff(t){let{thnkServer:e}=t;if(!e)throw new Error(\"Impossible to take a diff snapshot when not running a THNK server!\");let{stateVariables:i,objectsRegistery:a}=e,{publicStateVariable:s,privateStateVariable:n,teamStateVariable:r}=i,o=new ha;s.isDirty()&&(o.publicStateVariableDiff=s.serializeToBinary());{let b=n.getAllChildren();for(let l in b)b[l].isDirty()&&o.privateStateVariablesDiffs.set(l,b[l].serializeToBinary())}{let b=r.getAllChildren();for(let l in b)b[l].isDirty()&&o.teamStateVariablesDiffs.set(l,b[l].serializeToBinary())}a.forEach(b=>{let l=da.createDiff(b);l&&o.objectsDiff.set(b.thnkID,l)});for(let[b,l]of a.getCreatedObjects())o.createdObjects.set(b,l);for(let b of a.getDeletedObjects())o.deletedObjects.add(b);return o}serialize(t,e){let i=this.publicStateVariableDiff?Y.createPublicStateDiffVector(t,this.publicStateVariableDiff):null,a=this.privateStateVariablesDiffs.get(e),s=a?Y.createPrivateStateDiffVector(t,a):null,n=[];for(let l of this.objectsDiff.values())l.needsToBeSerialized(e)&&n.push(l.serialize(t,e));let r=n.length?Y.createObjectsVector(t,n):null,o=null;if(this.createdObjects.size){let l=new Uint16Array(this.createdObjects.size),h=0;for(let[O,w]of this.createdObjects){let _=t.createSharedString(w);l[h++]=Ut.createCreatedObject(t,O,_)}o=Y.createCreatedObjectsVector(t,l)}let b=this.deletedObjects.size?Y.createDeletedObjectsVector(t,[...this.deletedObjects]):null;return Y.startScene(t),i&&Y.addPublicStateDiff(t,i),s&&Y.addPrivateStateDiff(t,s),r&&Y.addObjects(t,r),o&&Y.addCreatedObjects(t,o),b&&Y.addDeletedObjects(t,b),Y.endScene(t)}},da=class{constructor(t,e){this.privateStateVariablesDiffs=new Map,this.teamStateVariablesDiffs=new Map,this.propertyChanged=!1,this.id=t,this.aabb=e}static createDiff(t){let e=new da(t.thnkID,t.getVisibilityAABB()||t.getAABB());t.getX()!==t.prevX&&(t.prevX=t.getX(),e.propertyChanged=!0,e.x=t.getX()),t.getY()!==t.prevY&&(t.prevY=t.getY(),e.propertyChanged=!0,e.y=t.getY()),t.getHeight()!==t.prevHeight&&(t.prevHeight=t.getHeight(),e.propertyChanged=!0,e.height=t.getHeight()),t.getWidth()!==t.prevWidth&&(t.prevWidth=t.getWidth(),e.propertyChanged=!0,e.width=t.getWidth()),t.getAngle()!==t.prevAngle&&(t.prevAngle=t.getAngle(),e.propertyChanged=!0,e.angle=t.getAngle()),t.getZOrder()!==t.prevZOrder&&(t.prevZOrder=t.getZOrder(),e.propertyChanged=!0,e.zOrder=t.getZOrder()),t.isHidden()!==t.prevVisibility&&(t.prevVisibility=t.isHidden(),e.propertyChanged=!0,e.hidden=t.isHidden()),t.isFlippedX&&t.isFlippedX()!==t.prevFlippedX&&(t.prevFlippedX=t.isFlippedX(),e.propertyChanged=!0,e.flippedX=t.isFlippedX()),t.isFlippedY&&t.isFlippedY()!==t.prevFlippedY&&(t.prevFlippedY=t.isFlippedY(),e.propertyChanged=!0,e.flippedY=t.isFlippedY()),t.getOpacity&&t.getOpacity()!==t.prevOpacity&&(t.prevOpacity=t.getOpacity(),e.propertyChanged=!0,e.opacity=t.getOpacity()),t.getString&&t.getString()!==t.prevText&&(t.prevText=t.getString(),e.propertyChanged=!0,e.string=t.getString()),t.getColor&&t.getColor()!==t.prevColor&&(t.prevColor=t.getColor(),e.propertyChanged=!0,e.color=t.getColor()),t.getAnimation&&t.getAnimation()!==t.prevAnimation&&(t.prevAnimation=t.getAnimation(),e.propertyChanged=!0,e.animation=t.getAnimation());let{publicStateVariable:i,privateStateVariable:a,teamStateVariable:s}=t.stateVariables;i.isDirty()&&(e.publicStateVariableDiff=i.serializeToBinary());{let n=a.getAllChildren();for(let r in n)n[r].isDirty()&&e.privateStateVariablesDiffs.set(r,n[r].serializeToBinary())}{let n=s.getAllChildren();for(let r in n)n[r].isDirty()&&e.teamStateVariablesDiffs.set(r,n[r].serializeToBinary())}return e.propertyChanged||e.publicStateVariableDiff||e.privateStateVariablesDiffs.size||e.teamStateVariablesDiffs.size?e:null}needsToBeSerialized(t){return this.propertyChanged||this.publicStateVariableDiff||this.privateStateVariablesDiffs.has(t)}serialize(t,e){let i=this.string!==void 0?t.createSharedString(this.string):null;this.propertyChanged&&(j.startObjState(t),this.x!==void 0&&(this.x===0?j.addSetXTo0(t,!0):j.addX(t,this.x)),this.y!==void 0&&(this.y===0?j.addSetYTo0(t,!0):j.addY(t,this.y)),this.height!==void 0&&(this.height===0?j.addSetHeightTo0(t,!0):j.addHeight(t,this.height)),this.width!==void 0&&(this.width===0?j.addSetWidthTo0(t,!0):j.addWidth(t,this.width)),this.angle!==void 0&&(this.angle===0?j.addSetAngleTo0(t,!0):j.addAngle(t,this.angle)),this.zOrder!==void 0&&(this.zOrder<=65535?j.addZOrder(t,this.zOrder+1):j.addBigZOrder(t,this.zOrder+1)),this.hidden!==void 0&&j.addVisible(t,this.hidden?1:2),this.flippedX!==void 0&&j.addFlippedX(t,this.flippedX?1:2),this.flippedY!==void 0&&j.addFlippedY(t,this.flippedY?1:2),this.opacity!==void 0&&(this.opacity===0?j.addSetOpacityTo0(t,!0):j.addOpacity(t,this.opacity)),this.animation!==void 0&&j.addAnimation(t,this.animation+1),i&&j.addText(t,i),this.color!==void 0&&j.addTint(t,oa(t,this.color)));let a=this.propertyChanged?j.endObjState(t):null,s=this.publicStateVariableDiff?G.createPublicStateDiffVector(t,this.publicStateVariableDiff):null,n=this.privateStateVariablesDiffs.get(e),r=n?G.createPrivateStateDiffVector(t,n):null;return G.startGameObject(t),G.addId(t,this.id),a&&G.addObjState(t,a),s&&G.addPublicStateDiff(t,s),r&&G.addPrivateStateDiff(t,r),G.endGameObject(t)}},Bn=class{constructor(t,e){this.objectsRegistery=new zn,this.playerManager=new Dn,this.runServerCode=!0,this.snapshotsManager=new Mn,this.adapter=t,this.stateVariables=e}},ca=(t,e)=>{t.thnkServer=new Bn(e,st.setupStateVariables(t.getVariables())),ra()||t.thnkServer.playerManager._onConnect(e.getServerID())},Oi=new gdjs.Logger(\"THNK - Server\"),si=0,En=t=>{if(!t.thnkServer)return;let{adapter:e}=t.thnkServer;for(let[a,s]of e.getUsersPendingMessages()){for(let n of s)switch(n.contentType()){case 1:if(t.thnkServer.playerManager.alreadyHas(a))continue;vn(a,e,t),t.thnkServer.playerManager._onConnect(a);continue;case 2:let r=n.content(new mt),o=r.name();if(!o)continue;let b=r.contentArray();jn(a,o,b);continue;default:Oi.error(`Received message with unknown type '${n.contentType()}'`);continue}s.length=0}for(let a of e.getDisconnectedUsers())t.thnkServer.playerManager._onDisconnect(a);e.getDisconnectedUsers().length=0;let i=t.getTimeManager();si+=i.getElapsedTime()/i.getTimeScale(),si>1e3/Ri()&&(si=0,t.thnkServer.runServerCode=!0);{let a=t.thnkServer.adapter.getServerID(),s=r=>{let o=r.getChild(a).getAllChildren();for(let b in o)r.addChild(b,o[b])},{privateStateVariable:n}=t.thnkServer.stateVariables;s(n),t.thnkServer.objectsRegistery.forEach(r=>s(r.getVariables().get(\"PlayerState\")))}},Nn=t=>{if(!t.thnkServer||!t.thnkServer.runServerCode)return;t.thnkServer.runServerCode=!1;let{snapshotsManager:e}=t.thnkServer,i=e.createSnapshot(t);if(i)for(let a of t.thnkServer.playerManager.connectedPlayers.values())Sn(a,t.thnkServer.adapter,i)},Jt=null,ba=(t,e)=>{if(t.thnkServer){let{adapter:i}=t.thnkServer;Jt={adapter:i,isPause:e},e&&(t.thnkServer.previouslyConnectedUsers=new Set(i.getConnectedUsers()))}},Zn=t=>{if(Jt){let{adapter:e,isPause:i}=Jt;ca(t,e);for(let a of e.getConnectedUsers())t.thnkServer.playerManager._onConnect(a);kn(e,t.getName(),i),Jt=null}},Ln=t=>{if(Jt)if(t.thnkServer){let{adapter:e,previouslyConnectedUsers:i}=t.thnkServer;if(i){let a=[],s=[];for(let n of e.getConnectedUsers())i.has(n)?s.push(n):a.push(n);ii(a,e,t),ii(s,e)}else Oi.warn(\"List of previously connected players not found! A full snapshot will be sent to all players. This is likely a bug, please open an issue on the THNK GitHub page!\"),ii([...e.getConnectedUsers()],e,t)}else Oi.warn(\"Resumed a scene that is not a server, shutting the server down. This is likely a bug, please open an issue on the THNK GitHub page!\"),Jt.adapter.close()};gdjs.registerRuntimeScenePreEventsCallback(En);gdjs.registerRuntimeScenePostEventsCallback(Nn);gdjs.registerRuntimeSceneUnloadedCallback(t=>ba(t,!1));gdjs.registerRuntimeScenePausedCallback(t=>ba(t,!0));gdjs.registerRuntimeSceneLoadedCallback(Zn);gdjs.registerRuntimeSceneResumedCallback(Ln);var Hn=new gdjs.Logger(\"THNK - Server\"),Yn=async(t,e,i)=>{try{await t.prepare(e)}catch(s){Hn.error(\"Adapter crashed while starting server! Error: \",s);return}let a=i?e.getGame().getSceneStack().replace(i,!0):e;ca(a,t)},Gn={popMessage:Cn,addRawMessageToTheQueue:xn,popConnection:Un,popDisconnection:Tn},ua={};Ke(ua,{getConnectionState:()=>Qn,messages:()=>sr,startClient:()=>ir});var ie=(t,e)=>{switch(e.type()){case 1:return t.setString(e.text()),t;case 2:return t.setNumber(e.number()),t;case 3:return t.setBoolean(e.boolean()),t}if(e.type()===4){t.castTo(\"structure\");for(let i=e.operationsLength(),a=0,s=e.operations(0);a{let i=t.objState();if(i){let o=i.x();o!==null&&e.setX(o);let b=i.y();b!==null&&e.setY(b);let l=i.height();l!==null&&e.setHeight(l);let h=i.width();h!==null&&e.setWidth(h);let O=i.angle();O!==null&&e.setAngle(O),i.setXTo0()&&e.setX(0),i.setYTo0()&&e.setY(0),i.setHeightTo0()&&e.setHeight(0),i.setWidthTo0()&&e.setWidth(0),i.setAngleTo0()&&e.setAngle(0);{let x=i.visible();x!==null&&e.hide(x===1);let I=i.flippedX();I!==null&&e.flipX&&e.flipX(I===1);let k=i.flippedY();k!==null&&e.flipY&&e.flipY(k===1)}let w=i.zOrder()??i.bigZOrder();w!==null&&e.setZOrder(w-1);let _=i.opacity();e.setOpacity&&(_!==null&&e.setOpacity(_),i.setOpacityTo0()&&e.setOpacity(0));let V=i.animation();V!==null&&e.setAnimation&&e.setAnimation(V-1);let U=i.text();if(U!==null&&e.setString&&e.setString(U),e.setColor){let x=i.tint(Xn);x&&e.setColor(`${x.r()};${x.g()};${x.b()}`)}}let a=e.getVariables().get(\"State\"),s=t.publicStateDiffArray();if(s)ie(a,B.getRootAsVariable(new jt(s)));else{let o=t.packedPublicStateArray();o&&pe(a,o)}let n=e.getVariables().get(\"PlayerState\"),r=t.privateStateDiffArray();if(r)ie(n,B.getRootAsVariable(new jt(r)));else{let o=t.packedPrivateStateArray();o&&pe(n,o)}},_a=(t,e)=>{if(!e.thnkClient)return;let{objectsRegistery:i}=e.thnkClient,a=t.publicStatePackedArray();a&&pe(e.getVariables().get(\"State\"),a);let s=t.privateStatePackedArray();if(s&&pe(e.getVariables().get(\"PlayerState\"),s),i.clear(),t.objectsLength()!==0)for(let n=t.objectsLength(),r=0,o=t.objects(0);r{if(!e.thnkClient)return;let{objectsRegistery:i}=e.thnkClient,a=t.publicStateDiffArray();a&&ie(e.getVariables().get(\"State\"),B.getRootAsVariable(new jt(a)));let s=t.privateStateDiffArray();s&&ie(e.getVariables().get(\"PlayerState\"),B.getRootAsVariable(new jt(s)));let n=t.deletedObjectsArray();if(n)for(let r of n)i.deleteObject(r);if(t.createdObjectsLength()!==0)for(let r=t.createdObjectsLength(),o=0,b=t.createdObjects(0);o{if(!t.thnkClient)return;let{adapter:e}=t.thnkClient;for(let i of e.getPendingMessages())switch(i.contentType()){case 1:ss.warn(\"A second ConnectionStartMessage was received from the server. This is likely a bug, please open an issue on the THNK GitHub!\");continue;case 2:let a=i.content(new Ot).scene();a&&Wn(a,t);continue;case 3:let s=i.content(new dt),n=s.sceneName();if(!n){console.error(\"Server requested scene switch, but no scene name was sent! This is likely a bug, please open an issue on the THNK GitHub!\");continue}let r=s.isPause()?t.getGame().getSceneStack().push(n):t.getGame().getSceneStack().replace(n,!0);r.thnkClient=t.thnkClient,t=r;continue;case 4:let o=i.content(new ht),b=o.name(),l=null;try{l=b?t.getGame().getSceneStack().replace(b,!0):t.getGame().getSceneStack().pop()}catch{console.info(\"Error spotted!\")}if(!l)continue;let h=o.snapshot();h&&_a(h,l),l.thnkClient=t.thnkClient,t=l;continue;default:ss.error(`Received message with unknown type '${i.contentType()}'`)}e.markPendingMessagesAsRead()};gdjs.registerRuntimeScenePreEventsCallback(Kn);var qn=(t,e)=>{let i=new Bt(32),a=e?i.createString(e):null;Tt.startConnectionRequestMessage(i),a&&Tt.addToken(i,a);let s=Tt.endConnectionRequestMessage(i);t.sendClientMessage(i,vt.createClientMessage(i,1,s))},$n=(t,e,i)=>{let a=new Bt(256),s=a.createString(e),n=mt.createContentVector(a,_e(i)),r=mt.createClientInputMessage(a,s,n);t.sendClientMessage(a,vt.createClientMessage(a,2,r))},pa=\"disconnected\",ce=t=>pa=t,Qn=()=>pa,Jn=class{constructor(t){this.objectsRegistery=new Map,this.runtimeScene=t}registerObject(t,e){e.thnkID=t,this.objectsRegistery.set(t,e)}getObject(t){return this.objectsRegistery.get(t)}deleteObject(t){let e=this.objectsRegistery.get(t);!e||(e.deleteFromScene(this.runtimeScene),this.objectsRegistery.delete(t))}clear(){this.objectsRegistery.forEach(t=>t.deleteFromScene(this.runtimeScene)),this.objectsRegistery.clear()}},tr=class{constructor(t,e){this.adapter=t,this.objectsRegistery=new Jn(e)}},er=new gdjs.Logger(\"THNK - Client\"),as=t=>{ce(\"failed\"),er.error(\"Connection failed: \"+t)},ir=async(t,e)=>{ce(\"connecting\");let i=t.getGame().getSceneStack();try{await e.prepare(t)}catch{as(\"Adapter crashed while starting server!\");return}ce(\"loading\"),qn(e);let a=setInterval(()=>{let s=e.getPendingMessages().shift();if(!!s&&s.contentType()===1){clearInterval(a);let n=s.content(new Zt),r=n.sceneName(),o=n.sceneSnapshot();if(!r||!o){as(\"Server Connection Start Message was invalid, couldn't finish setting up the connection.\");return}let b=i.replace(r,!0);b.thnkClient=new tr(e,b),_a(o,b),ce(\"connected\")}},200)},sr={sendClientMessage:$n};function se(t){let e=t.length;for(;--e>=0;)t[e]=0}var ar=0,ga=1,nr=2,rr=3,or=258,Pi=29,je=256,we=je+1+Pi,te=30,zi=19,wa=2*we+1,Lt=15,ai=16,lr=7,Mi=256,ya=16,ma=17,va=18,Ai=new Uint8Array([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]),Ee=new Uint8Array([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]),hr=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Sa=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),dr=512,St=new Array((we+2)*2);se(St);var be=new Array(te*2);se(be);var ye=new Array(dr);se(ye);var me=new Array(or-rr+1);se(me);var Bi=new Array(Pi);se(Bi);var Ge=new Array(te);se(Ge);function ni(t,e,i,a,s){this.static_tree=t,this.extra_bits=e,this.extra_base=i,this.elems=a,this.max_length=s,this.has_stree=t&&t.length}var ka,Oa,Aa;function ri(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}var Ia=t=>t<256?ye[t]:ye[256+(t>>>7)],ve=(t,e)=>{t.pending_buf[t.pending++]=e&255,t.pending_buf[t.pending++]=e>>>8&255},rt=(t,e,i)=>{t.bi_valid>ai-i?(t.bi_buf|=e<>ai-t.bi_valid,t.bi_valid+=i-ai):(t.bi_buf|=e<{rt(t,i[e*2],i[e*2+1])},ja=(t,e)=>{let i=0;do i|=t&1,t>>>=1,i<<=1;while(--e>0);return i>>>1},cr=t=>{t.bi_valid===16?(ve(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=t.bi_buf&255,t.bi_buf>>=8,t.bi_valid-=8)},br=(t,e)=>{let i=e.dyn_tree,a=e.max_code,s=e.stat_desc.static_tree,n=e.stat_desc.has_stree,r=e.stat_desc.extra_bits,o=e.stat_desc.extra_base,b=e.stat_desc.max_length,l,h,O,w,_,V,U=0;for(w=0;w<=Lt;w++)t.bl_count[w]=0;for(i[t.heap[t.heap_max]*2+1]=0,l=t.heap_max+1;lb&&(w=b,U++),i[h*2+1]=w,!(h>a)&&(t.bl_count[w]++,_=0,h>=o&&(_=r[h-o]),V=i[h*2],t.opt_len+=V*(w+_),n&&(t.static_len+=V*(s[h*2+1]+_)));if(U!==0){do{for(w=b-1;t.bl_count[w]===0;)w--;t.bl_count[w]--,t.bl_count[w+1]+=2,t.bl_count[b]--,U-=2}while(U>0);for(w=b;w!==0;w--)for(h=t.bl_count[w];h!==0;)O=t.heap[--l],!(O>a)&&(i[O*2+1]!==w&&(t.opt_len+=(w-i[O*2+1])*i[O*2],i[O*2+1]=w),h--)}},xa=(t,e,i)=>{let a=new Array(Lt+1),s=0,n,r;for(n=1;n<=Lt;n++)a[n]=s=s+i[n-1]<<1;for(r=0;r<=e;r++){let o=t[r*2+1];o!==0&&(t[r*2]=ja(a[o]++,o))}},ur=()=>{let t,e,i,a,s,n=new Array(Lt+1);for(i=0,a=0;a>=7;a{let e;for(e=0;e{t.bi_valid>8?ve(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},fr=(t,e,i,a)=>{Ua(t),a&&(ve(t,i),ve(t,~i)),t.pending_buf.set(t.window.subarray(e,e+i),t.pending),t.pending+=i},ns=(t,e,i,a)=>{let s=e*2,n=i*2;return t[s]{let a=t.heap[i],s=i<<1;for(;s<=t.heap_len&&(s{let a,s,n=0,r,o;if(t.last_lit!==0)do a=t.pending_buf[t.d_buf+n*2]<<8|t.pending_buf[t.d_buf+n*2+1],s=t.pending_buf[t.l_buf+n],n++,a===0?gt(t,s,e):(r=me[s],gt(t,r+je+1,e),o=Ai[r],o!==0&&(s-=Bi[r],rt(t,s,o)),a--,r=Ia(a),gt(t,r,i),o=Ee[r],o!==0&&(a-=Ge[r],rt(t,a,o)));while(n{let i=e.dyn_tree,a=e.stat_desc.static_tree,s=e.stat_desc.has_stree,n=e.stat_desc.elems,r,o,b=-1,l;for(t.heap_len=0,t.heap_max=wa,r=0;r>1;r>=1;r--)oi(t,i,r);l=n;do r=t.heap[1],t.heap[1]=t.heap[t.heap_len--],oi(t,i,1),o=t.heap[1],t.heap[--t.heap_max]=r,t.heap[--t.heap_max]=o,i[l*2]=i[r*2]+i[o*2],t.depth[l]=(t.depth[r]>=t.depth[o]?t.depth[r]:t.depth[o])+1,i[r*2+1]=i[o*2+1]=l,t.heap[1]=l++,oi(t,i,1);while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],br(t,e),xa(i,b,t.bl_count)},os=(t,e,i)=>{let a,s=-1,n,r=e[0*2+1],o=0,b=7,l=4;for(r===0&&(b=138,l=3),e[(i+1)*2+1]=65535,a=0;a<=i;a++)n=r,r=e[(a+1)*2+1],!(++o{let a,s=-1,n,r=e[0*2+1],o=0,b=7,l=4;for(r===0&&(b=138,l=3),a=0;a<=i;a++)if(n=r,r=e[(a+1)*2+1],!(++o{let e;for(os(t,t.dyn_ltree,t.l_desc.max_code),os(t,t.dyn_dtree,t.d_desc.max_code),Ii(t,t.bl_desc),e=zi-1;e>=3&&t.bl_tree[Sa[e]*2+1]===0;e--);return t.opt_len+=3*(e+1)+5+5+4,e},pr=(t,e,i,a)=>{let s;for(rt(t,e-257,5),rt(t,i-1,5),rt(t,a-4,4),s=0;s{let e=4093624447,i;for(i=0;i<=31;i++,e>>>=1)if(e&1&&t.dyn_ltree[i*2]!==0)return 0;if(t.dyn_ltree[9*2]!==0||t.dyn_ltree[10*2]!==0||t.dyn_ltree[13*2]!==0)return 1;for(i=32;i{hs||(ur(),hs=!0),t.l_desc=new ri(t.dyn_ltree,ka),t.d_desc=new ri(t.dyn_dtree,Oa),t.bl_desc=new ri(t.bl_tree,Aa),t.bi_buf=0,t.bi_valid=0,Ca(t)},Ta=(t,e,i,a)=>{rt(t,(ar<<1)+(a?1:0),3),fr(t,e,i,!0)},yr=t=>{rt(t,ga<<1,3),gt(t,Mi,St),cr(t)},mr=(t,e,i,a)=>{let s,n,r=0;t.level>0?(t.strm.data_type===2&&(t.strm.data_type=gr(t)),Ii(t,t.l_desc),Ii(t,t.d_desc),r=_r(t),s=t.opt_len+3+7>>>3,n=t.static_len+3+7>>>3,n<=s&&(s=n)):s=n=i+5,i+4<=s&&e!==-1?Ta(t,e,i,a):t.strategy===4||n===s?(rt(t,(ga<<1)+(a?1:0),3),rs(t,St,be)):(rt(t,(nr<<1)+(a?1:0),3),pr(t,t.l_desc.max_code+1,t.d_desc.max_code+1,r+1),rs(t,t.dyn_ltree,t.dyn_dtree)),Ca(t),a&&Ua(t)},vr=(t,e,i)=>(t.pending_buf[t.d_buf+t.last_lit*2]=e>>>8&255,t.pending_buf[t.d_buf+t.last_lit*2+1]=e&255,t.pending_buf[t.l_buf+t.last_lit]=i&255,t.last_lit++,e===0?t.dyn_ltree[i*2]++:(t.matches++,e--,t.dyn_ltree[(me[i]+je+1)*2]++,t.dyn_dtree[Ia(e)*2]++),t.last_lit===t.lit_bufsize-1),Sr=wr,kr=Ta,Or=mr,Ar=vr,Ir=yr,jr={_tr_init:Sr,_tr_stored_block:kr,_tr_flush_block:Or,_tr_tally:Ar,_tr_align:Ir},xr=(t,e,i,a)=>{let s=t&65535|0,n=t>>>16&65535|0,r=0;for(;i!==0;){r=i>2e3?2e3:i,i-=r;do s=s+e[a++]|0,n=n+s|0;while(--r);s%=65521,n%=65521}return s|n<<16|0},Se=xr,Cr=()=>{let t,e=[];for(var i=0;i<256;i++){t=i;for(var a=0;a<8;a++)t=t&1?3988292384^t>>>1:t>>>1;e[i]=t}return e},Ur=new Uint32Array(Cr()),Tr=(t,e,i,a)=>{let s=Ur,n=a+i;t^=-1;for(let r=a;r>>8^s[(t^e[r])&255];return t^-1},$=Tr,Yt={2:\"need dictionary\",1:\"stream end\",0:\"\",\"-1\":\"file error\",\"-2\":\"stream error\",\"-3\":\"data error\",\"-4\":\"insufficient memory\",\"-5\":\"buffer error\",\"-6\":\"incompatible version\"},ae={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},{_tr_init:Vr,_tr_stored_block:Fr,_tr_flush_block:Dr,_tr_tally:Pt,_tr_align:Rr}=jr,{Z_NO_FLUSH:Kt,Z_PARTIAL_FLUSH:Pr,Z_FULL_FLUSH:zr,Z_FINISH:zt,Z_BLOCK:ds,Z_OK:wt,Z_STREAM_END:cs,Z_STREAM_ERROR:bt,Z_DATA_ERROR:Mr,Z_BUF_ERROR:li,Z_DEFAULT_COMPRESSION:Br,Z_FILTERED:Er,Z_HUFFMAN_ONLY:De,Z_RLE:Nr,Z_FIXED:Zr,Z_DEFAULT_STRATEGY:Lr,Z_UNKNOWN:Hr,Z_DEFLATED:$e}=ae,Yr=9,Gr=15,Xr=8,Wr=29,Kr=256,ji=Kr+1+Wr,qr=30,$r=19,Qr=2*ji+1,Jr=15,D=3,Dt=258,ut=Dt+D+1,to=32,Qe=42,xi=69,Ne=73,Ze=91,Le=103,Ht=113,he=666,tt=1,xe=2,Gt=3,ne=4,eo=3,Rt=(t,e)=>(t.msg=Yt[e],e),bs=t=>(t<<1)-(t>4?9:0),Vt=t=>{let e=t.length;for(;--e>=0;)t[e]=0},io=(t,e,i)=>(e<{let e=t.state,i=e.pending;i>t.avail_out&&(i=t.avail_out),i!==0&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+i),t.next_out),t.next_out+=i,e.pending_out+=i,t.total_out+=i,t.avail_out-=i,e.pending-=i,e.pending===0&&(e.pending_out=0))},et=(t,e)=>{Dr(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,xt(t.strm)},P=(t,e)=>{t.pending_buf[t.pending++]=e},le=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=e&255},so=(t,e,i,a)=>{let s=t.avail_in;return s>a&&(s=a),s===0?0:(t.avail_in-=s,e.set(t.input.subarray(t.next_in,t.next_in+s),i),t.state.wrap===1?t.adler=Se(t.adler,e,s,i):t.state.wrap===2&&(t.adler=$(t.adler,e,s,i)),t.next_in+=s,t.total_in+=s,s)},Va=(t,e)=>{let i=t.max_chain_length,a=t.strstart,s,n,r=t.prev_length,o=t.nice_match,b=t.strstart>t.w_size-ut?t.strstart-(t.w_size-ut):0,l=t.window,h=t.w_mask,O=t.prev,w=t.strstart+Dt,_=l[a+r-1],V=l[a+r];t.prev_length>=t.good_match&&(i>>=2),o>t.lookahead&&(o=t.lookahead);do if(s=e,!(l[s+r]!==V||l[s+r-1]!==_||l[s]!==l[a]||l[++s]!==l[a+1])){a+=2,s++;do;while(l[++a]===l[++s]&&l[++a]===l[++s]&&l[++a]===l[++s]&&l[++a]===l[++s]&&l[++a]===l[++s]&&l[++a]===l[++s]&&l[++a]===l[++s]&&l[++a]===l[++s]&&ar){if(t.match_start=e,r=n,n>=o)break;_=l[a+r-1],V=l[a+r]}}while((e=O[e&h])>b&&--i!==0);return r<=t.lookahead?r:t.lookahead},Xt=t=>{let e=t.w_size,i,a,s,n,r;do{if(n=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-ut)){t.window.set(t.window.subarray(e,e+e),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,a=t.hash_size,i=a;do s=t.head[--i],t.head[i]=s>=e?s-e:0;while(--a);a=e,i=a;do s=t.prev[--i],t.prev[i]=s>=e?s-e:0;while(--a);n+=e}if(t.strm.avail_in===0)break;if(a=so(t.strm,t.window,t.strstart+t.lookahead,n),t.lookahead+=a,t.lookahead+t.insert>=D)for(r=t.strstart-t.insert,t.ins_h=t.window[r],t.ins_h=Mt(t,t.ins_h,t.window[r+1]);t.insert&&(t.ins_h=Mt(t,t.ins_h,t.window[r+D-1]),t.prev[r&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=r,r++,t.insert--,!(t.lookahead+t.insert{let i=65535;for(i>t.pending_buf_size-5&&(i=t.pending_buf_size-5);;){if(t.lookahead<=1){if(Xt(t),t.lookahead===0&&e===Kt)return tt;if(t.lookahead===0)break}t.strstart+=t.lookahead,t.lookahead=0;let a=t.block_start+i;if((t.strstart===0||t.strstart>=a)&&(t.lookahead=t.strstart-a,t.strstart=a,et(t,!1),t.strm.avail_out===0)||t.strstart-t.block_start>=t.w_size-ut&&(et(t,!1),t.strm.avail_out===0))return tt}return t.insert=0,e===zt?(et(t,!0),t.strm.avail_out===0?Gt:ne):(t.strstart>t.block_start&&(et(t,!1),t.strm.avail_out),tt)},hi=(t,e)=>{let i,a;for(;;){if(t.lookahead=D&&(t.ins_h=Mt(t,t.ins_h,t.window[t.strstart+D-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),i!==0&&t.strstart-i<=t.w_size-ut&&(t.match_length=Va(t,i)),t.match_length>=D)if(a=Pt(t,t.strstart-t.match_start,t.match_length-D),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=D){t.match_length--;do t.strstart++,t.ins_h=Mt(t,t.ins_h,t.window[t.strstart+D-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart;while(--t.match_length!==0);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=Mt(t,t.ins_h,t.window[t.strstart+1]);else a=Pt(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(a&&(et(t,!1),t.strm.avail_out===0))return tt}return t.insert=t.strstart{let i,a,s;for(;;){if(t.lookahead=D&&(t.ins_h=Mt(t,t.ins_h,t.window[t.strstart+D-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=D-1,i!==0&&t.prev_length4096)&&(t.match_length=D-1)),t.prev_length>=D&&t.match_length<=t.prev_length){s=t.strstart+t.lookahead-D,a=Pt(t,t.strstart-1-t.prev_match,t.prev_length-D),t.lookahead-=t.prev_length-1,t.prev_length-=2;do++t.strstart<=s&&(t.ins_h=Mt(t,t.ins_h,t.window[t.strstart+D-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart);while(--t.prev_length!==0);if(t.match_available=0,t.match_length=D-1,t.strstart++,a&&(et(t,!1),t.strm.avail_out===0))return tt}else if(t.match_available){if(a=Pt(t,0,t.window[t.strstart-1]),a&&et(t,!1),t.strstart++,t.lookahead--,t.strm.avail_out===0)return tt}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(a=Pt(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart{let i,a,s,n,r=t.window;for(;;){if(t.lookahead<=Dt){if(Xt(t),t.lookahead<=Dt&&e===Kt)return tt;if(t.lookahead===0)break}if(t.match_length=0,t.lookahead>=D&&t.strstart>0&&(s=t.strstart-1,a=r[s],a===r[++s]&&a===r[++s]&&a===r[++s])){n=t.strstart+Dt;do;while(a===r[++s]&&a===r[++s]&&a===r[++s]&&a===r[++s]&&a===r[++s]&&a===r[++s]&&a===r[++s]&&a===r[++s]&&st.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=D?(i=Pt(t,1,t.match_length-D),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(i=Pt(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),i&&(et(t,!1),t.strm.avail_out===0))return tt}return t.insert=0,e===zt?(et(t,!0),t.strm.avail_out===0?Gt:ne):t.last_lit&&(et(t,!1),t.strm.avail_out===0)?tt:xe},ro=(t,e)=>{let i;for(;;){if(t.lookahead===0&&(Xt(t),t.lookahead===0)){if(e===Kt)return tt;break}if(t.match_length=0,i=Pt(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,i&&(et(t,!1),t.strm.avail_out===0))return tt}return t.insert=0,e===zt?(et(t,!0),t.strm.avail_out===0?Gt:ne):t.last_lit&&(et(t,!1),t.strm.avail_out===0)?tt:xe};function _t(t,e,i,a,s){this.good_length=t,this.max_lazy=e,this.nice_length=i,this.max_chain=a,this.func=s}var de=[new _t(0,0,0,0,ao),new _t(4,4,8,4,hi),new _t(4,5,16,8,hi),new _t(4,6,32,32,hi),new _t(4,4,16,16,$t),new _t(8,16,32,32,$t),new _t(8,16,128,128,$t),new _t(8,32,128,256,$t),new _t(32,128,258,1024,$t),new _t(32,258,258,4096,$t)],oo=t=>{t.window_size=2*t.w_size,Vt(t.head),t.max_lazy_match=de[t.level].max_lazy,t.good_match=de[t.level].good_length,t.nice_match=de[t.level].nice_length,t.max_chain_length=de[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=D-1,t.match_available=0,t.ins_h=0};function lo(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=$e,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(Qr*2),this.dyn_dtree=new Uint16Array((2*qr+1)*2),this.bl_tree=new Uint16Array((2*$r+1)*2),Vt(this.dyn_ltree),Vt(this.dyn_dtree),Vt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(Jr+1),this.heap=new Uint16Array(2*ji+1),Vt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*ji+1),Vt(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}var Fa=t=>{if(!t||!t.state)return Rt(t,bt);t.total_in=t.total_out=0,t.data_type=Hr;let e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?Qe:Ht,t.adler=e.wrap===2?0:1,e.last_flush=Kt,Vr(e),wt},Da=t=>{let e=Fa(t);return e===wt&&oo(t.state),e},ho=(t,e)=>!t||!t.state||t.state.wrap!==2?bt:(t.state.gzhead=e,wt),Ra=(t,e,i,a,s,n)=>{if(!t)return bt;let r=1;if(e===Br&&(e=6),a<0?(r=0,a=-a):a>15&&(r=2,a-=16),s<1||s>Yr||i!==$e||a<8||a>15||e<0||e>9||n<0||n>Zr)return Rt(t,bt);a===8&&(a=9);let o=new lo;return t.state=o,o.strm=t,o.wrap=r,o.gzhead=null,o.w_bits=a,o.w_size=1<Ra(t,e,$e,Gr,Xr,Lr),bo=(t,e)=>{let i,a;if(!t||!t.state||e>ds||e<0)return t?Rt(t,bt):bt;let s=t.state;if(!t.output||!t.input&&t.avail_in!==0||s.status===he&&e!==zt)return Rt(t,t.avail_out===0?li:bt);s.strm=t;let n=s.last_flush;if(s.last_flush=e,s.status===Qe)if(s.wrap===2)t.adler=0,P(s,31),P(s,139),P(s,8),s.gzhead?(P(s,(s.gzhead.text?1:0)+(s.gzhead.hcrc?2:0)+(s.gzhead.extra?4:0)+(s.gzhead.name?8:0)+(s.gzhead.comment?16:0)),P(s,s.gzhead.time&255),P(s,s.gzhead.time>>8&255),P(s,s.gzhead.time>>16&255),P(s,s.gzhead.time>>24&255),P(s,s.level===9?2:s.strategy>=De||s.level<2?4:0),P(s,s.gzhead.os&255),s.gzhead.extra&&s.gzhead.extra.length&&(P(s,s.gzhead.extra.length&255),P(s,s.gzhead.extra.length>>8&255)),s.gzhead.hcrc&&(t.adler=$(t.adler,s.pending_buf,s.pending,0)),s.gzindex=0,s.status=xi):(P(s,0),P(s,0),P(s,0),P(s,0),P(s,0),P(s,s.level===9?2:s.strategy>=De||s.level<2?4:0),P(s,eo),s.status=Ht);else{let r=$e+(s.w_bits-8<<4)<<8,o=-1;s.strategy>=De||s.level<2?o=0:s.level<6?o=1:s.level===6?o=2:o=3,r|=o<<6,s.strstart!==0&&(r|=to),r+=31-r%31,s.status=Ht,le(s,r),s.strstart!==0&&(le(s,t.adler>>>16),le(s,t.adler&65535)),t.adler=1}if(s.status===xi)if(s.gzhead.extra){for(i=s.pending;s.gzindex<(s.gzhead.extra.length&65535)&&!(s.pending===s.pending_buf_size&&(s.gzhead.hcrc&&s.pending>i&&(t.adler=$(t.adler,s.pending_buf,s.pending-i,i)),xt(t),i=s.pending,s.pending===s.pending_buf_size));)P(s,s.gzhead.extra[s.gzindex]&255),s.gzindex++;s.gzhead.hcrc&&s.pending>i&&(t.adler=$(t.adler,s.pending_buf,s.pending-i,i)),s.gzindex===s.gzhead.extra.length&&(s.gzindex=0,s.status=Ne)}else s.status=Ne;if(s.status===Ne)if(s.gzhead.name){i=s.pending;do{if(s.pending===s.pending_buf_size&&(s.gzhead.hcrc&&s.pending>i&&(t.adler=$(t.adler,s.pending_buf,s.pending-i,i)),xt(t),i=s.pending,s.pending===s.pending_buf_size)){a=1;break}s.gzindexi&&(t.adler=$(t.adler,s.pending_buf,s.pending-i,i)),a===0&&(s.gzindex=0,s.status=Ze)}else s.status=Ze;if(s.status===Ze)if(s.gzhead.comment){i=s.pending;do{if(s.pending===s.pending_buf_size&&(s.gzhead.hcrc&&s.pending>i&&(t.adler=$(t.adler,s.pending_buf,s.pending-i,i)),xt(t),i=s.pending,s.pending===s.pending_buf_size)){a=1;break}s.gzindexi&&(t.adler=$(t.adler,s.pending_buf,s.pending-i,i)),a===0&&(s.status=Le)}else s.status=Le;if(s.status===Le&&(s.gzhead.hcrc?(s.pending+2>s.pending_buf_size&&xt(t),s.pending+2<=s.pending_buf_size&&(P(s,t.adler&255),P(s,t.adler>>8&255),t.adler=0,s.status=Ht)):s.status=Ht),s.pending!==0){if(xt(t),t.avail_out===0)return s.last_flush=-1,wt}else if(t.avail_in===0&&bs(e)<=bs(n)&&e!==zt)return Rt(t,li);if(s.status===he&&t.avail_in!==0)return Rt(t,li);if(t.avail_in!==0||s.lookahead!==0||e!==Kt&&s.status!==he){let r=s.strategy===De?ro(s,e):s.strategy===Nr?no(s,e):de[s.level].func(s,e);if((r===Gt||r===ne)&&(s.status=he),r===tt||r===Gt)return t.avail_out===0&&(s.last_flush=-1),wt;if(r===xe&&(e===Pr?Rr(s):e!==ds&&(Fr(s,0,0,!1),e===zr&&(Vt(s.head),s.lookahead===0&&(s.strstart=0,s.block_start=0,s.insert=0))),xt(t),t.avail_out===0))return s.last_flush=-1,wt}return e!==zt?wt:s.wrap<=0?cs:(s.wrap===2?(P(s,t.adler&255),P(s,t.adler>>8&255),P(s,t.adler>>16&255),P(s,t.adler>>24&255),P(s,t.total_in&255),P(s,t.total_in>>8&255),P(s,t.total_in>>16&255),P(s,t.total_in>>24&255)):(le(s,t.adler>>>16),le(s,t.adler&65535)),xt(t),s.wrap>0&&(s.wrap=-s.wrap),s.pending!==0?wt:cs)},uo=t=>{if(!t||!t.state)return bt;let e=t.state.status;return e!==Qe&&e!==xi&&e!==Ne&&e!==Ze&&e!==Le&&e!==Ht&&e!==he?Rt(t,bt):(t.state=null,e===Ht?Rt(t,Mr):wt)},fo=(t,e)=>{let i=e.length;if(!t||!t.state)return bt;let a=t.state,s=a.wrap;if(s===2||s===1&&a.status!==Qe||a.lookahead)return bt;if(s===1&&(t.adler=Se(t.adler,e,i,0)),a.wrap=0,i>=a.w_size){s===0&&(Vt(a.head),a.strstart=0,a.block_start=0,a.insert=0);let b=new Uint8Array(a.w_size);b.set(e.subarray(i-a.w_size,i),0),e=b,i=a.w_size}let n=t.avail_in,r=t.next_in,o=t.input;for(t.avail_in=i,t.next_in=0,t.input=e,Xt(a);a.lookahead>=D;){let b=a.strstart,l=a.lookahead-(D-1);do a.ins_h=Mt(a,a.ins_h,a.window[b+D-1]),a.prev[b&a.w_mask]=a.head[a.ins_h],a.head[a.ins_h]=b,b++;while(--l);a.strstart=b,a.lookahead=D-1,Xt(a)}return a.strstart+=a.lookahead,a.block_start=a.strstart,a.insert=a.lookahead,a.lookahead=0,a.match_length=a.prev_length=D-1,a.match_available=0,t.next_in=r,t.input=o,t.avail_in=n,a.wrap=s,wt},_o=co,po=Ra,go=Da,wo=Fa,yo=ho,mo=bo,vo=uo,So=fo,ko=\"pako deflate (from Nodeca project)\",ue={deflateInit:_o,deflateInit2:po,deflateReset:go,deflateResetKeep:wo,deflateSetHeader:yo,deflate:mo,deflateEnd:vo,deflateSetDictionary:So,deflateInfo:ko},Oo=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),Ao=function(t){let e=Array.prototype.slice.call(arguments,1);for(;e.length;){let i=e.shift();if(i){if(typeof i!=\"object\")throw new TypeError(i+\"must be non-object\");for(let a in i)Oo(i,a)&&(t[a]=i[a])}}return t},Io=t=>{let e=0;for(let a=0,s=t.length;a=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;ke[254]=ke[254]=1;var jo=t=>{if(typeof TextEncoder==\"function\"&&TextEncoder.prototype.encode)return new TextEncoder().encode(t);let e,i,a,s,n,r=t.length,o=0;for(s=0;s>>6,e[n++]=128|i&63):i<65536?(e[n++]=224|i>>>12,e[n++]=128|i>>>6&63,e[n++]=128|i&63):(e[n++]=240|i>>>18,e[n++]=128|i>>>12&63,e[n++]=128|i>>>6&63,e[n++]=128|i&63);return e},xo=(t,e)=>{if(e<65534&&t.subarray&&Pa)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let i=\"\";for(let a=0;a{let i=e||t.length;if(typeof TextDecoder==\"function\"&&TextDecoder.prototype.decode)return new TextDecoder().decode(t.subarray(0,e));let a,s,n=new Array(i*2);for(s=0,a=0;a4){n[s++]=65533,a+=o-1;continue}for(r&=o===2?31:o===3?15:7;o>1&&a1){n[s++]=65533;continue}r<65536?n[s++]=r:(r-=65536,n[s++]=55296|r>>10&1023,n[s++]=56320|r&1023)}return xo(n,s)},Uo=(t,e)=>{e=e||t.length,e>t.length&&(e=t.length);let i=e-1;for(;i>=0&&(t[i]&192)===128;)i--;return i<0||i===0?e:i+ke[t[i]]>e?i:e},Oe={string2buf:jo,buf2string:Co,utf8border:Uo};function To(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg=\"\",this.state=null,this.data_type=2,this.adler=0}var za=To,Ma=Object.prototype.toString,{Z_NO_FLUSH:Vo,Z_SYNC_FLUSH:Fo,Z_FULL_FLUSH:Do,Z_FINISH:Ro,Z_OK:Xe,Z_STREAM_END:Po,Z_DEFAULT_COMPRESSION:zo,Z_DEFAULT_STRATEGY:Mo,Z_DEFLATED:Bo}=ae;function Ce(t){this.options=Je.assign({level:zo,method:Bo,chunkSize:16384,windowBits:15,memLevel:8,strategy:Mo},t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg=\"\",this.ended=!1,this.chunks=[],this.strm=new za,this.strm.avail_out=0;let i=ue.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(i!==Xe)throw new Error(Yt[i]);if(e.header&&ue.deflateSetHeader(this.strm,e.header),e.dictionary){let a;if(typeof e.dictionary==\"string\"?a=Oe.string2buf(e.dictionary):Ma.call(e.dictionary)===\"[object ArrayBuffer]\"?a=new Uint8Array(e.dictionary):a=e.dictionary,i=ue.deflateSetDictionary(this.strm,a),i!==Xe)throw new Error(Yt[i]);this._dict_set=!0}}Ce.prototype.push=function(t,e){let i=this.strm,a=this.options.chunkSize,s,n;if(this.ended)return!1;for(e===~~e?n=e:n=e===!0?Ro:Vo,typeof t==\"string\"?i.input=Oe.string2buf(t):Ma.call(t)===\"[object ArrayBuffer]\"?i.input=new Uint8Array(t):i.input=t,i.next_in=0,i.avail_in=i.input.length;;){if(i.avail_out===0&&(i.output=new Uint8Array(a),i.next_out=0,i.avail_out=a),(n===Fo||n===Do)&&i.avail_out<=6){this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;continue}if(s=ue.deflate(i,n),s===Po)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),s=ue.deflateEnd(this.strm),this.onEnd(s),this.ended=!0,s===Xe;if(i.avail_out===0){this.onData(i.output);continue}if(n>0&&i.next_out>0){this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;continue}if(i.avail_in===0)break}return!0};Ce.prototype.onData=function(t){this.chunks.push(t)};Ce.prototype.onEnd=function(t){t===Xe&&(this.result=Je.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};function Ei(t,e){let i=new Ce(e);if(i.push(t,!0),i.err)throw i.msg||Yt[i.err];return i.result}function Eo(t,e){return e=e||{},e.raw=!0,Ei(t,e)}function No(t,e){return e=e||{},e.gzip=!0,Ei(t,e)}var Zo=Ce,Lo=Ei,Ho=Eo,Yo=No,Go=ae,Xo={Deflate:Zo,deflate:Lo,deflateRaw:Ho,gzip:Yo,constants:Go},Re=30,Wo=12,Ko=function(t,e){let i,a,s,n,r,o,b,l,h,O,w,_,V,U,x,I,k,m,A,Z,F,u,S,p,g=t.state;i=t.next_in,S=t.input,a=i+(t.avail_in-5),s=t.next_out,p=t.output,n=s-(e-t.avail_out),r=s+(t.avail_out-257),o=g.dmax,b=g.wsize,l=g.whave,h=g.wnext,O=g.window,w=g.hold,_=g.bits,V=g.lencode,U=g.distcode,x=(1<>>24,w>>>=m,_-=m,m=k>>>16&255,m===0)p[s++]=k&65535;else if(m&16){A=k&65535,m&=15,m&&(_>>=m,_-=m),_<15&&(w+=S[i++]<<_,_+=8,w+=S[i++]<<_,_+=8),k=U[w&I];i:for(;;){if(m=k>>>24,w>>>=m,_-=m,m=k>>>16&255,m&16){if(Z=k&65535,m&=15,_o){t.msg=\"invalid distance too far back\",g.mode=Re;break t}if(w>>>=m,_-=m,m=s-n,Z>m){if(m=Z-m,m>l&&g.sane){t.msg=\"invalid distance too far back\",g.mode=Re;break t}if(F=0,u=O,h===0){if(F+=b-m,m2;)p[s++]=u[F++],p[s++]=u[F++],p[s++]=u[F++],A-=3;A&&(p[s++]=u[F++],A>1&&(p[s++]=u[F++]))}else{F=s-Z;do p[s++]=p[F++],p[s++]=p[F++],p[s++]=p[F++],A-=3;while(A>2);A&&(p[s++]=p[F++],A>1&&(p[s++]=p[F++]))}}else if((m&64)===0){k=U[(k&65535)+(w&(1<>3,i-=A,_-=A<<3,w&=(1<<_)-1,t.next_in=i,t.next_out=s,t.avail_in=i{let b=o.bits,l=0,h=0,O=0,w=0,_=0,V=0,U=0,x=0,I=0,k=0,m,A,Z,F,u,S=null,p=0,g,y=new Uint16Array(Qt+1),R=new Uint16Array(Qt+1),T=null,C=0,L,E,at;for(l=0;l<=Qt;l++)y[l]=0;for(h=0;h=1&&y[w]===0;w--);if(_>w&&(_=w),w===0)return s[n++]=1<<24|64<<16|0,s[n++]=1<<24|64<<16|0,o.bits=1,0;for(O=1;O0&&(t===_s||w!==1))return-1;for(R[1]=0,l=1;lus||t===ps&&I>fs)return 1;for(;;){L=l-U,r[h]g?(E=T[C+r[h]],at=S[p+r[h]]):(E=32+64,at=0),m=1<>U)+A]=L<<24|E<<16|at|0;while(A!==0);for(m=1<>=1;if(m!==0?(k&=m-1,k+=m):k=0,h++,--y[l]===0){if(l===w)break;l=e[i+r[h]]}if(l>_&&(k&F)!==Z){for(U===0&&(U=_),u+=O,V=l-U,x=1<us||t===ps&&I>fs)return 1;Z=k&F,s[Z]=_<<24|V<<16|u-n|0}}return k!==0&&(s[u+k]=l-U<<24|64<<16|0),o.bits=_,0},fe=tl,el=0,Ba=1,Ea=2,{Z_FINISH:gs,Z_BLOCK:il,Z_TREES:Pe,Z_OK:Wt,Z_STREAM_END:sl,Z_NEED_DICT:al,Z_STREAM_ERROR:ft,Z_DATA_ERROR:Na,Z_MEM_ERROR:Za,Z_BUF_ERROR:nl,Z_DEFLATED:ws}=ae,La=1,ys=2,ms=3,vs=4,Ss=5,ks=6,Os=7,As=8,Is=9,js=10,We=11,yt=12,ci=13,xs=14,bi=15,Cs=16,Us=17,Ts=18,Vs=19,ze=20,Me=21,Fs=22,Ds=23,Rs=24,Ps=25,zs=26,ui=27,Ms=28,Bs=29,N=30,Ha=31,rl=32,ol=852,ll=592,hl=15,dl=hl,Es=t=>(t>>>24&255)+(t>>>8&65280)+((t&65280)<<8)+((t&255)<<24);function cl(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}var Ya=t=>{if(!t||!t.state)return ft;let e=t.state;return t.total_in=t.total_out=e.total=0,t.msg=\"\",e.wrap&&(t.adler=e.wrap&1),e.mode=La,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(ol),e.distcode=e.distdyn=new Int32Array(ll),e.sane=1,e.back=-1,Wt},Ga=t=>{if(!t||!t.state)return ft;let e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,Ya(t)},Xa=(t,e)=>{let i;if(!t||!t.state)return ft;let a=t.state;return e<0?(i=0,e=-e):(i=(e>>4)+1,e<48&&(e&=15)),e&&(e<8||e>15)?ft:(a.window!==null&&a.wbits!==e&&(a.window=null),a.wrap=i,a.wbits=e,Ga(t))},Wa=(t,e)=>{if(!t)return ft;let i=new cl;t.state=i,i.window=null;let a=Xa(t,e);return a!==Wt&&(t.state=null),a},bl=t=>Wa(t,dl),Ns=!0,fi,_i,ul=t=>{if(Ns){fi=new Int32Array(512),_i=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(fe(Ba,t.lens,0,288,fi,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;fe(Ea,t.lens,0,32,_i,0,t.work,{bits:5}),Ns=!1}t.lencode=fi,t.lenbits=9,t.distcode=_i,t.distbits=5},Ka=(t,e,i,a)=>{let s,n=t.state;return n.window===null&&(n.wsize=1<=n.wsize?(n.window.set(e.subarray(i-n.wsize,i),0),n.wnext=0,n.whave=n.wsize):(s=n.wsize-n.wnext,s>a&&(s=a),n.window.set(e.subarray(i-a,i-a+s),n.wnext),a-=s,a?(n.window.set(e.subarray(i-a,i),0),n.wnext=a,n.whave=n.wsize):(n.wnext+=s,n.wnext===n.wsize&&(n.wnext=0),n.whave{let i,a,s,n,r,o,b,l,h,O,w,_,V,U,x=0,I,k,m,A,Z,F,u,S,p=new Uint8Array(4),g,y,R=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!t||!t.state||!t.output||!t.input&&t.avail_in!==0)return ft;i=t.state,i.mode===yt&&(i.mode=ci),r=t.next_out,s=t.output,b=t.avail_out,n=t.next_in,a=t.input,o=t.avail_in,l=i.hold,h=i.bits,O=o,w=b,S=Wt;t:for(;;)switch(i.mode){case La:if(i.wrap===0){i.mode=ci;break}for(;h<16;){if(o===0)break t;o--,l+=a[n++]<>>8&255,i.check=$(i.check,p,2,0),l=0,h=0,i.mode=ys;break}if(i.flags=0,i.head&&(i.head.done=!1),!(i.wrap&1)||(((l&255)<<8)+(l>>8))%31){t.msg=\"incorrect header check\",i.mode=N;break}if((l&15)!==ws){t.msg=\"unknown compression method\",i.mode=N;break}if(l>>>=4,h-=4,u=(l&15)+8,i.wbits===0)i.wbits=u;else if(u>i.wbits){t.msg=\"invalid window size\",i.mode=N;break}i.dmax=1<>8&1),i.flags&512&&(p[0]=l&255,p[1]=l>>>8&255,i.check=$(i.check,p,2,0)),l=0,h=0,i.mode=ms;case ms:for(;h<32;){if(o===0)break t;o--,l+=a[n++]<>>8&255,p[2]=l>>>16&255,p[3]=l>>>24&255,i.check=$(i.check,p,4,0)),l=0,h=0,i.mode=vs;case vs:for(;h<16;){if(o===0)break t;o--,l+=a[n++]<>8),i.flags&512&&(p[0]=l&255,p[1]=l>>>8&255,i.check=$(i.check,p,2,0)),l=0,h=0,i.mode=Ss;case Ss:if(i.flags&1024){for(;h<16;){if(o===0)break t;o--,l+=a[n++]<>>8&255,i.check=$(i.check,p,2,0)),l=0,h=0}else i.head&&(i.head.extra=null);i.mode=ks;case ks:if(i.flags&1024&&(_=i.length,_>o&&(_=o),_&&(i.head&&(u=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Uint8Array(i.head.extra_len)),i.head.extra.set(a.subarray(n,n+_),u)),i.flags&512&&(i.check=$(i.check,a,_,n)),o-=_,n+=_,i.length-=_),i.length))break t;i.length=0,i.mode=Os;case Os:if(i.flags&2048){if(o===0)break t;_=0;do u=a[n+_++],i.head&&u&&i.length<65536&&(i.head.name+=String.fromCharCode(u));while(u&&_>9&1,i.head.done=!0),t.adler=i.check=0,i.mode=yt;break;case js:for(;h<32;){if(o===0)break t;o--,l+=a[n++]<>>=h&7,h-=h&7,i.mode=ui;break}for(;h<3;){if(o===0)break t;o--,l+=a[n++]<>>=1,h-=1,l&3){case 0:i.mode=xs;break;case 1:if(ul(i),i.mode=ze,e===Pe){l>>>=2,h-=2;break t}break;case 2:i.mode=Us;break;case 3:t.msg=\"invalid block type\",i.mode=N}l>>>=2,h-=2;break;case xs:for(l>>>=h&7,h-=h&7;h<32;){if(o===0)break t;o--,l+=a[n++]<>>16^65535)){t.msg=\"invalid stored block lengths\",i.mode=N;break}if(i.length=l&65535,l=0,h=0,i.mode=bi,e===Pe)break t;case bi:i.mode=Cs;case Cs:if(_=i.length,_){if(_>o&&(_=o),_>b&&(_=b),_===0)break t;s.set(a.subarray(n,n+_),r),o-=_,n+=_,b-=_,r+=_,i.length-=_;break}i.mode=yt;break;case Us:for(;h<14;){if(o===0)break t;o--,l+=a[n++]<>>=5,h-=5,i.ndist=(l&31)+1,l>>>=5,h-=5,i.ncode=(l&15)+4,l>>>=4,h-=4,i.nlen>286||i.ndist>30){t.msg=\"too many length or distance symbols\",i.mode=N;break}i.have=0,i.mode=Ts;case Ts:for(;i.have>>=3,h-=3}for(;i.have<19;)i.lens[R[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,g={bits:i.lenbits},S=fe(el,i.lens,0,19,i.lencode,0,i.work,g),i.lenbits=g.bits,S){t.msg=\"invalid code lengths set\",i.mode=N;break}i.have=0,i.mode=Vs;case Vs:for(;i.have>>24,k=x>>>16&255,m=x&65535,!(I<=h);){if(o===0)break t;o--,l+=a[n++]<>>=I,h-=I,i.lens[i.have++]=m;else{if(m===16){for(y=I+2;h>>=I,h-=I,i.have===0){t.msg=\"invalid bit length repeat\",i.mode=N;break}u=i.lens[i.have-1],_=3+(l&3),l>>>=2,h-=2}else if(m===17){for(y=I+3;h>>=I,h-=I,u=0,_=3+(l&7),l>>>=3,h-=3}else{for(y=I+7;h>>=I,h-=I,u=0,_=11+(l&127),l>>>=7,h-=7}if(i.have+_>i.nlen+i.ndist){t.msg=\"invalid bit length repeat\",i.mode=N;break}for(;_--;)i.lens[i.have++]=u}}if(i.mode===N)break;if(i.lens[256]===0){t.msg=\"invalid code -- missing end-of-block\",i.mode=N;break}if(i.lenbits=9,g={bits:i.lenbits},S=fe(Ba,i.lens,0,i.nlen,i.lencode,0,i.work,g),i.lenbits=g.bits,S){t.msg=\"invalid literal/lengths set\",i.mode=N;break}if(i.distbits=6,i.distcode=i.distdyn,g={bits:i.distbits},S=fe(Ea,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,g),i.distbits=g.bits,S){t.msg=\"invalid distances set\",i.mode=N;break}if(i.mode=ze,e===Pe)break t;case ze:i.mode=Me;case Me:if(o>=6&&b>=258){t.next_out=r,t.avail_out=b,t.next_in=n,t.avail_in=o,i.hold=l,i.bits=h,Ko(t,w),r=t.next_out,s=t.output,b=t.avail_out,n=t.next_in,a=t.input,o=t.avail_in,l=i.hold,h=i.bits,i.mode===yt&&(i.back=-1);break}for(i.back=0;x=i.lencode[l&(1<>>24,k=x>>>16&255,m=x&65535,!(I<=h);){if(o===0)break t;o--,l+=a[n++]<>A)],I=x>>>24,k=x>>>16&255,m=x&65535,!(A+I<=h);){if(o===0)break t;o--,l+=a[n++]<>>=A,h-=A,i.back+=A}if(l>>>=I,h-=I,i.back+=I,i.length=m,k===0){i.mode=zs;break}if(k&32){i.back=-1,i.mode=yt;break}if(k&64){t.msg=\"invalid literal/length code\",i.mode=N;break}i.extra=k&15,i.mode=Fs;case Fs:if(i.extra){for(y=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=Ds;case Ds:for(;x=i.distcode[l&(1<>>24,k=x>>>16&255,m=x&65535,!(I<=h);){if(o===0)break t;o--,l+=a[n++]<>A)],I=x>>>24,k=x>>>16&255,m=x&65535,!(A+I<=h);){if(o===0)break t;o--,l+=a[n++]<>>=A,h-=A,i.back+=A}if(l>>>=I,h-=I,i.back+=I,k&64){t.msg=\"invalid distance code\",i.mode=N;break}i.offset=m,i.extra=k&15,i.mode=Rs;case Rs:if(i.extra){for(y=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){t.msg=\"invalid distance too far back\",i.mode=N;break}i.mode=Ps;case Ps:if(b===0)break t;if(_=w-b,i.offset>_){if(_=i.offset-_,_>i.whave&&i.sane){t.msg=\"invalid distance too far back\",i.mode=N;break}_>i.wnext?(_-=i.wnext,V=i.wsize-_):V=i.wnext-_,_>i.length&&(_=i.length),U=i.window}else U=s,V=r-i.offset,_=i.length;_>b&&(_=b),b-=_,i.length-=_;do s[r++]=U[V++];while(--_);i.length===0&&(i.mode=Me);break;case zs:if(b===0)break t;s[r++]=i.length,b--,i.mode=Me;break;case ui:if(i.wrap){for(;h<32;){if(o===0)break t;o--,l|=a[n++]<{if(!t||!t.state)return ft;let e=t.state;return e.window&&(e.window=null),t.state=null,Wt},pl=(t,e)=>{if(!t||!t.state)return ft;let i=t.state;return(i.wrap&2)===0?ft:(i.head=e,e.done=!1,Wt)},gl=(t,e)=>{let i=e.length,a,s,n;return!t||!t.state||(a=t.state,a.wrap!==0&&a.mode!==We)?ft:a.mode===We&&(s=1,s=Se(s,e,i,0),s!==a.check)?Na:(n=Ka(t,e,i,i),n?(a.mode=Ha,Za):(a.havedict=1,Wt))},wl=Ga,yl=Xa,ml=Ya,vl=bl,Sl=Wa,kl=fl,Ol=_l,Al=pl,Il=gl,jl=\"pako inflate (from Nodeca project)\",kt={inflateReset:wl,inflateReset2:yl,inflateResetKeep:ml,inflateInit:vl,inflateInit2:Sl,inflate:kl,inflateEnd:Ol,inflateGetHeader:Al,inflateSetDictionary:Il,inflateInfo:jl};function xl(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name=\"\",this.comment=\"\",this.hcrc=0,this.done=!1}var Cl=xl,qa=Object.prototype.toString,{Z_NO_FLUSH:Ul,Z_FINISH:Tl,Z_OK:Ae,Z_STREAM_END:pi,Z_NEED_DICT:gi,Z_STREAM_ERROR:Vl,Z_DATA_ERROR:Zs,Z_MEM_ERROR:Fl}=ae;function Ue(t){this.options=Je.assign({chunkSize:1024*64,windowBits:15,to:\"\"},t||{});let e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,e.windowBits===0&&(e.windowBits=-15)),e.windowBits>=0&&e.windowBits<16&&!(t&&t.windowBits)&&(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(e.windowBits&15)===0&&(e.windowBits|=15),this.err=0,this.msg=\"\",this.ended=!1,this.chunks=[],this.strm=new za,this.strm.avail_out=0;let i=kt.inflateInit2(this.strm,e.windowBits);if(i!==Ae)throw new Error(Yt[i]);if(this.header=new Cl,kt.inflateGetHeader(this.strm,this.header),e.dictionary&&(typeof e.dictionary==\"string\"?e.dictionary=Oe.string2buf(e.dictionary):qa.call(e.dictionary)===\"[object ArrayBuffer]\"&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(i=kt.inflateSetDictionary(this.strm,e.dictionary),i!==Ae)))throw new Error(Yt[i])}Ue.prototype.push=function(t,e){let i=this.strm,a=this.options.chunkSize,s=this.options.dictionary,n,r,o;if(this.ended)return!1;for(e===~~e?r=e:r=e===!0?Tl:Ul,qa.call(t)===\"[object ArrayBuffer]\"?i.input=new Uint8Array(t):i.input=t,i.next_in=0,i.avail_in=i.input.length;;){for(i.avail_out===0&&(i.output=new Uint8Array(a),i.next_out=0,i.avail_out=a),n=kt.inflate(i,r),n===gi&&s&&(n=kt.inflateSetDictionary(i,s),n===Ae?n=kt.inflate(i,r):n===Zs&&(n=gi));i.avail_in>0&&n===pi&&i.state.wrap>0&&t[i.next_in]!==0;)kt.inflateReset(i),n=kt.inflate(i,r);switch(n){case Vl:case Zs:case gi:case Fl:return this.onEnd(n),this.ended=!0,!1}if(o=i.avail_out,i.next_out&&(i.avail_out===0||n===pi))if(this.options.to===\"string\"){let b=Oe.utf8border(i.output,i.next_out),l=i.next_out-b,h=Oe.buf2string(i.output,b);i.next_out=l,i.avail_out=a-l,l&&i.output.set(i.output.subarray(b,b+l),0),this.onData(h)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(!(n===Ae&&o===0)){if(n===pi)return n=kt.inflateEnd(this.strm),this.onEnd(n),this.ended=!0,!0;if(i.avail_in===0)break}}return!0};Ue.prototype.onData=function(t){this.chunks.push(t)};Ue.prototype.onEnd=function(t){t===Ae&&(this.options.to===\"string\"?this.result=this.chunks.join(\"\"):this.result=Je.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};function Ni(t,e){let i=new Ue(e);if(i.push(t),i.err)throw i.msg||Yt[i.err];return i.result}function Dl(t,e){return e=e||{},e.raw=!0,Ni(t,e)}var Rl=Ue,Pl=Ni,zl=Dl,Ml=Ni,Bl=ae,El={Inflate:Rl,inflate:Pl,inflateRaw:zl,ungzip:Ml,constants:Bl},{Deflate:Kl,deflate:ql,deflateRaw:Nl,gzip:$l}=Xo,{Inflate:Ql,inflate:Jl,inflateRaw:Zl,ungzip:th}=El,Ll=Nl,Hl=Zl,$a=t=>Hl(t),Ci=t=>Ll(t,{level:9}),Yl=class{constructor(){this.pendingMessages=[]}sendClientMessage(t,e){t.finish(e),this.doSendMessage(Ci(t.asUint8Array()))}getPendingMessages(){return this.pendingMessages}markPendingMessagesAsRead(){this.pendingMessages.length=0}onMessage(t){this.pendingMessages.push(ct.getRootAsServerMessage(new jt($a(t))))}onDisconnection(){ce(\"disconnected\")}},Gl=class{constructor(){this.usersPendingMessages=new Map,this.disconnectedUsers=[]}sendServerMessageTo(t,e,i){e.finish(i),this.doSendMessageTo(t,Ci(e.asUint8Array()))}sendServerMessageToAll(t,e){t.finish(e);let i=Ci(t.asUint8Array());for(let a of this.usersPendingMessages.keys())this.doSendMessageTo(a,i)}getUsersPendingMessages(){return this.usersPendingMessages.entries()}getConnectedUsers(){return this.usersPendingMessages.keys()}getDisconnectedUsers(){return this.disconnectedUsers}onMessage(t,e){this.usersPendingMessages.get(t).push(vt.getRootAsClientMessage(new jt($a(e))))}onConnection(t){this.usersPendingMessages.set(t,[])}onDisconnection(t){this.usersPendingMessages.delete(t),this.disconnectedUsers.push(t)}};gdjs.BBTextRuntimeObject&&(gdjs.BBTextRuntimeObject.prototype.getString=gdjs.BBTextRuntimeObject.prototype.getBBText,gdjs.BBTextRuntimeObject.prototype.setString=gdjs.BBTextRuntimeObject.prototype.setBBText),gdjs.BitmapTextRuntimeObject&&(gdjs.BitmapTextRuntimeObject.prototype.getString=gdjs.BitmapTextRuntimeObject.prototype.getText,gdjs.BitmapTextRuntimeObject.prototype.setString=gdjs.BitmapTextRuntimeObject.prototype.setText,gdjs.BitmapTextRuntimeObject.prototype.getColor=gdjs.BitmapTextRuntimeObject.prototype.getTint,gdjs.BitmapTextRuntimeObject.prototype.setColor=gdjs.BitmapTextRuntimeObject.prototype.setTint);return an(Xl);})();", + "/*! pako 2.0.4 https://github.com/nodeca/pako @license (MIT AND Zlib) */", + "{" + ], "parameterObjects": "", "useStrict": true, "eventsSheetExpanded": false @@ -364,7 +379,10 @@ "events": [ { "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": "eventsFunctionContext.returnValue = !!runtimeScene.thnkServer;\n", + "inlineCode": [ + "eventsFunctionContext.returnValue = !!runtimeScene.thnkServer;", + "" + ], "parameterObjects": "", "useStrict": true, "eventsSheetExpanded": false @@ -382,7 +400,11 @@ "events": [ { "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": "// If we are neither client nor server, we are playing singleplayer.\neventsFunctionContext.returnValue = !runtimeScene.thnkServer && !runtimeScene.thnkClient;\n", + "inlineCode": [ + "// If we are neither client nor server, we are playing singleplayer.", + "eventsFunctionContext.returnValue = !runtimeScene.thnkServer && !runtimeScene.thnkClient;", + "" + ], "parameterObjects": "", "useStrict": true, "eventsSheetExpanded": false @@ -401,7 +423,10 @@ "events": [ { "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": "eventsFunctionContext.returnValue = !THNK.settings.DEDICATED;\n", + "inlineCode": [ + "eventsFunctionContext.returnValue = !THNK.settings.DEDICATED;", + "" + ], "parameterObjects": "", "useStrict": true, "eventsSheetExpanded": false @@ -420,7 +445,10 @@ "events": [ { "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": "eventsFunctionContext.returnValue = THNK.client.getConnectionState() === \"connecting\";\n", + "inlineCode": [ + "eventsFunctionContext.returnValue = THNK.client.getConnectionState() === \"connecting\";", + "" + ], "parameterObjects": "", "useStrict": true, "eventsSheetExpanded": false @@ -484,34 +512,6 @@ "parameters": [], "objectGroups": [] }, - { - "description": "Gets the local client's own Player ID, which is the identity that a server associates with a client.", - "fullName": "Get the local client's own Player ID", - "functionType": "StringExpression", - "group": "Client", - "name": "PlayerID", - "sentence": "", - "events": [ - { - "type": "BuiltinCommonInstructions::Comment", - "color": { - "b": 109, - "g": 230, - "r": 255, - "textB": 0, - "textG": 0, - "textR": 0 - }, - "comment": "UNIMPLEMENTED", - "comment2": "" - } - ], - "expressionType": { - "type": "string" - }, - "parameters": [], - "objectGroups": [] - }, { "description": "Sends a message to the server.", "fullName": "Send a message to the server", @@ -522,7 +522,22 @@ "events": [ { "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": "if (runtimeScene.thnkClient) {\n THNK.client.messages.sendClientMessage(\n runtimeScene.thnkClient.adapter,\n eventsFunctionContext.getArgument(\"message\"),\n eventsFunctionContext.getArgument(\"extra_data\")\n );\n} else THNK.server.events.addRawMessageToTheQueue(\n runtimeScene.thnkServer\n ? runtimeScene.thnkServer.adapter.getServerID()\n : THNK.players.getCurrentPlayerID(),\n eventsFunctionContext.getArgument(\"message\"),\n eventsFunctionContext.getArgument(\"extra_data\")\n);\n", + "inlineCode": [ + "if (runtimeScene.thnkClient) {", + " THNK.client.messages.sendClientMessage(", + " runtimeScene.thnkClient.adapter,", + " eventsFunctionContext.getArgument(\"message\"),", + " eventsFunctionContext.getArgument(\"extra_data\")", + " );", + "} else THNK.server.events.addRawMessageToTheQueue(", + " runtimeScene.thnkServer", + " ? runtimeScene.thnkServer.adapter.getServerID()", + " : THNK.players.getCurrentPlayerID(),", + " eventsFunctionContext.getArgument(\"message\"),", + " eventsFunctionContext.getArgument(\"extra_data\")", + ");", + "" + ], "parameterObjects": "", "useStrict": true, "eventsSheetExpanded": false @@ -562,7 +577,14 @@ "events": [ { "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": "eventsFunctionContext.returnValue = runtimeScene.thnkServer \n // The server is active, only run server code if it is time to.\n ? runtimeScene.thnkServer.runServerCode \n // The server is innactive. Only run the server code if client mode is innactive too, as that'd mean singleplayer.\n : !runtimeScene.thnkClient;\n", + "inlineCode": [ + "eventsFunctionContext.returnValue = runtimeScene.thnkServer ", + " // The server is active, only run server code if it is time to.", + " ? runtimeScene.thnkServer.runServerCode ", + " // The server is innactive. Only run the server code if client mode is innactive too, as that'd mean singleplayer.", + " : !runtimeScene.thnkClient;", + "" + ], "parameterObjects": "", "useStrict": true, "eventsSheetExpanded": false @@ -586,7 +608,10 @@ }, { "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": "THNK.settings.setTickRate(eventsFunctionContext.getArgument(\"TargetTPS\"));\n", + "inlineCode": [ + "THNK.settings.setTickRate(eventsFunctionContext.getArgument(\"TargetTPS\"));", + "" + ], "parameterObjects": "", "useStrict": true, "eventsSheetExpanded": false @@ -611,7 +636,11 @@ "events": [ { "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": "eventsFunctionContext.returnValue =\n THNK.players.switchPlayerContext(eventsFunctionContext.getArgument(\"PlayerID\"));\n", + "inlineCode": [ + "eventsFunctionContext.returnValue =", + " THNK.players.switchPlayerContext(eventsFunctionContext.getArgument(\"PlayerID\"));", + "" + ], "parameterObjects": "", "useStrict": true, "eventsSheetExpanded": false @@ -636,7 +665,10 @@ "events": [ { "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": "eventsFunctionContext.returnValue = THNK.players.getCurrentPlayerID();\n", + "inlineCode": [ + "eventsFunctionContext.returnValue = THNK.players.getCurrentPlayerID();", + "" + ], "parameterObjects": "", "useStrict": true, "eventsSheetExpanded": false @@ -658,7 +690,10 @@ "events": [ { "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": "for (const obj of objects) THNK.players.markObjectAsOwned(obj);\n", + "inlineCode": [ + "for (const obj of objects) THNK.players.markObjectAsOwned(obj);", + "" + ], "parameterObjects": "Object", "useStrict": true, "eventsSheetExpanded": false @@ -683,7 +718,11 @@ "events": [ { "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": "THNK.players.pickOwnedObjects(eventsFunctionContext.getObjectsLists(\"Object\"));\neventsFunctionContext.returnValue = true;\n", + "inlineCode": [ + "THNK.players.pickOwnedObjects(eventsFunctionContext.getObjectsLists(\"Object\"));", + "eventsFunctionContext.returnValue = true;", + "" + ], "parameterObjects": "", "useStrict": true, "eventsSheetExpanded": false @@ -708,7 +747,13 @@ "events": [ { "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": "if (!runtimeScene.thnkClient) eventsFunctionContext.returnValue = THNK.server.events.popMessage(\n eventsFunctionContext.getArgument(\"message\"),\n eventsFunctionContext.getArgument(\"extra_data\")\n);\n", + "inlineCode": [ + "if (!runtimeScene.thnkClient) eventsFunctionContext.returnValue = THNK.server.events.popMessage(", + " eventsFunctionContext.getArgument(\"message\"),", + " eventsFunctionContext.getArgument(\"extra_data\")", + ");", + "" + ], "parameterObjects": "", "useStrict": true, "eventsSheetExpanded": false @@ -783,7 +828,10 @@ }, { "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": "if (runtimeScene.thnkServer) eventsFunctionContext.returnValue = THNK.server.events.popConnection(runtimeScene);\n", + "inlineCode": [ + "if (runtimeScene.thnkServer) eventsFunctionContext.returnValue = THNK.server.events.popConnection(runtimeScene);", + "" + ], "parameterObjects": "", "useStrict": true, "eventsSheetExpanded": false @@ -802,7 +850,10 @@ "events": [ { "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": "if (runtimeScene.thnkServer) eventsFunctionContext.returnValue = THNK.server.events.popDisconnection(runtimeScene);\n", + "inlineCode": [ + "if (runtimeScene.thnkServer) eventsFunctionContext.returnValue = THNK.server.events.popDisconnection(runtimeScene);", + "" + ], "parameterObjects": "", "useStrict": true, "eventsSheetExpanded": false @@ -854,7 +905,23 @@ "events": [ { "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": "if (runtimeScene.thnkServer)\n runtimeScene.thnkServer.objectsRegistery.registerObject(objects[0]);\n\nif (runtimeScene.thnkClient && typeof objects[0].thnkID !== \"number\") {\n // Object was not created by the server but the game is in client mode, delete it.\n objects[0].deleteFromScene(runtimeScene);\n\n // Workaround a GDevelop bug that creates a ghost object when deleting an object at the beginning of the scene\n if (runtimeScene.getTimeManager().isFirstFrame()) {\n runtimeScene.getAsyncTasksManager().addTask(new gdjs.ResolveTask(), () => {\n objects[0].onDestroyFromScene(runtimeScene);\n });\n }\n}\n", + "inlineCode": [ + "if (runtimeScene.thnkServer)", + " runtimeScene.thnkServer.objectsRegistery.registerObject(objects[0]);", + "", + "if (runtimeScene.thnkClient && typeof objects[0].thnkID !== \"number\") {", + " // Object was not created by the server but the game is in client mode, delete it.", + " objects[0].deleteFromScene(runtimeScene);", + "", + " // Workaround a GDevelop bug that creates a ghost object when deleting an object at the beginning of the scene", + " if (runtimeScene.getTimeManager().isFirstFrame()) {", + " runtimeScene.getAsyncTasksManager().addTask(new gdjs.ResolveTask(), () => {", + " objects[0].onDestroyFromScene(runtimeScene);", + " });", + " }", + "}", + "" + ], "parameterObjects": "Object", "useStrict": true, "eventsSheetExpanded": false @@ -885,7 +952,11 @@ "events": [ { "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": "if (runtimeScene.thnkServer)\n runtimeScene.thnkServer.objectsRegistery.unregisterObject(objects[0]);\n", + "inlineCode": [ + "if (runtimeScene.thnkServer)", + " runtimeScene.thnkServer.objectsRegistery.unregisterObject(objects[0]);", + "" + ], "parameterObjects": "Object", "useStrict": true, "eventsSheetExpanded": false diff --git a/extensions/THNK_GeckosClient.json b/extensions/THNK_GeckosClient.json index 2c245e3..d07873d 100644 --- a/extensions/THNK_GeckosClient.json +++ b/extensions/THNK_GeckosClient.json @@ -1,21 +1,22 @@ { "author": "", "category": "Network", - "description": "A THNK client adapter for networking via [geckos.io](https://geckos.io), a client-server netwroking solution that uses fast UDP and encrypted connections.", "extensionNamespace": "", - "fullName": "THNK Geckos.io Client adapter", - "helpPath": "", + "fullName": "THNK Framework - Geckos client adapter", + "helpPath": "https://thnk.cloud/", "iconUrl": "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0ibWRpLWxhbi1jb25uZWN0IiB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCI+PHBhdGggZD0iTTQsMUMyLjg5LDEgMiwxLjg5IDIsM1Y3QzIsOC4xMSAyLjg5LDkgNCw5SDFWMTFIMTNWOUgxMEMxMS4xMSw5IDEyLDguMTEgMTIsN1YzQzEyLDEuODkgMTEuMTEsMSAxMCwxSDRNNCwzSDEwVjdINFYzTTMsMTNWMThMMywyMEgxMFYxOEg1VjEzSDNNMTQsMTNDMTIuODksMTMgMTIsMTMuODkgMTIsMTVWMTlDMTIsMjAuMTEgMTIuODksMjEgMTQsMjFIMTFWMjNIMjNWMjFIMjBDMjEuMTEsMjEgMjIsMjAuMTEgMjIsMTlWMTVDMjIsMTMuODkgMjEuMTEsMTMgMjAsMTNIMTRNMTQsMTVIMjBWMTlIMTRWMTVaIiAvPjwvc3ZnPg==", "name": "THNK_GeckosClient", "previewIconUrl": "https://resources.gdevelop-app.com/assets/Icons/lan-connect.svg", - "shortDescription": "A THNK client adapter for networking via geckos.io", + "shortDescription": "A THNK client adapter for networking via geckos.io (IP & Port).", "version": "1.0.0", + "description": "A THNK client adapter for networking via [geckos.io](https://geckos.io), a client-server netwroking solution that uses fast UDP and encrypted connections.", "tags": [ "THNK", "adapter", "client", - "gecko", - "io" + "geckos", + "io", + "geckos.io" ], "authorIds": [ "ZgrsWuRTAkXgeuPV9bo0zuEcA2w1" @@ -30,17 +31,683 @@ ], "eventsFunctions": [ { - "description": "", "fullName": "", "functionType": "Action", - "group": "", "name": "onFirstSceneLoaded", - "private": false, "sentence": "", "events": [ { "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": "// Load THNK Geckos Client Adapter (https://github.com/arthuro555/THNK)\n\"use strict\";\n(() => {\n var __create = Object.create;\n var __defProp = Object.defineProperty;\n var __getOwnPropDesc = Object.getOwnPropertyDescriptor;\n var __getOwnPropNames = Object.getOwnPropertyNames;\n var __getProtoOf = Object.getPrototypeOf;\n var __hasOwnProp = Object.prototype.hasOwnProperty;\n var __commonJS = (cb, mod) => function __require() {\n return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;\n };\n var __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n };\n var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n ));\n\n // node_modules/@yandeu/events/cjs/version.js\n var require_version = __commonJS({\n \"node_modules/@yandeu/events/cjs/version.js\"(exports) {\n \"use strict\";\n Object.defineProperty(exports, \"__esModule\", { value: true });\n exports.VERSION = void 0;\n exports.VERSION = \"0.0.5\";\n }\n });\n\n // node_modules/@yandeu/events/cjs/index.js\n var require_cjs = __commonJS({\n \"node_modules/@yandeu/events/cjs/index.js\"(exports) {\n \"use strict\";\n var __spreadArray = exports && exports.__spreadArray || function(to, from) {\n for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)\n to[j] = from[i];\n return to;\n };\n Object.defineProperty(exports, \"__esModule\", { value: true });\n exports.Events = void 0;\n var version_1 = require_version();\n var EE = function() {\n function EE2(fn, context, once) {\n if (once === void 0) {\n once = false;\n }\n this.fn = fn;\n this.context = context;\n this.once = once;\n }\n return EE2;\n }();\n var addListener = function(emitter, event, fn, context, once) {\n if (typeof fn !== \"function\") {\n throw new TypeError(\"The listener must be a function\");\n }\n var listener = new EE(fn, context || emitter, once);\n if (!emitter._events.has(event))\n emitter._events.set(event, listener), emitter._eventsCount++;\n else if (!emitter._events.get(event).fn)\n emitter._events.get(event).push(listener);\n else\n emitter._events.set(event, [emitter._events.get(event), listener]);\n return emitter;\n };\n var clearEvent = function(emitter, event) {\n if (--emitter._eventsCount === 0)\n emitter._events = /* @__PURE__ */ new Map();\n else\n emitter._events.delete(event);\n };\n var Events2 = function() {\n function Events3() {\n this._events = /* @__PURE__ */ new Map();\n this._eventsCount = 0;\n }\n Object.defineProperty(Events3, \"VERSION\", {\n get: function() {\n return version_1.VERSION;\n },\n enumerable: false,\n configurable: true\n });\n Events3.prototype.eventNames = function() {\n return Array.from(this._events.keys());\n };\n Events3.prototype.listeners = function(event) {\n var handlers = this._events.get(event);\n if (!handlers)\n return [];\n if (handlers.fn)\n return [handlers.fn];\n for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {\n ee[i] = handlers[i].fn;\n }\n return ee;\n };\n Events3.prototype.listenerCount = function(event) {\n var listeners = this._events.get(event);\n if (!listeners)\n return 0;\n if (listeners.fn)\n return 1;\n return listeners.length;\n };\n Events3.prototype.emit = function(event) {\n var _a, _b;\n var args = [];\n for (var _i = 1; _i < arguments.length; _i++) {\n args[_i - 1] = arguments[_i];\n }\n if (!this._events.has(event))\n return false;\n var listeners = this._events.get(event);\n var i;\n if (listeners.fn) {\n if (listeners.once)\n this.removeListener(event, listeners.fn, void 0, true);\n return (_a = listeners.fn).call.apply(_a, __spreadArray([listeners.context], args)), true;\n } else {\n var length_1 = listeners.length;\n for (i = 0; i < length_1; i++) {\n if (listeners[i].once)\n this.removeListener(event, listeners[i].fn, void 0, true);\n (_b = listeners[i].fn).call.apply(_b, __spreadArray([listeners[i].context], args));\n }\n }\n return true;\n };\n Events3.prototype.on = function(event, fn, context) {\n return addListener(this, event, fn, context, false);\n };\n Events3.prototype.once = function(event, fn, context) {\n return addListener(this, event, fn, context, true);\n };\n Events3.prototype.removeListener = function(event, fn, context, once) {\n if (!this._events.has(event))\n return this;\n if (!fn) {\n clearEvent(this, event);\n return this;\n }\n var listeners = this._events.get(event);\n if (listeners.fn) {\n if (listeners.fn === fn && (!once || listeners.once) && (!context || listeners.context === context)) {\n clearEvent(this, event);\n }\n } else {\n for (var i = 0, events = [], length = listeners.length; i < length; i++) {\n if (listeners[i].fn !== fn || once && !listeners[i].once || context && listeners[i].context !== context) {\n events.push(listeners[i]);\n }\n }\n if (events.length)\n this._events.set(event, events.length === 1 ? events[0] : events);\n else\n clearEvent(this, event);\n }\n return this;\n };\n Events3.prototype.removeAllListeners = function(event) {\n if (event) {\n if (this._events.delete(event))\n clearEvent(this, event);\n } else {\n this._events = /* @__PURE__ */ new Map();\n this._eventsCount = 0;\n }\n return this;\n };\n Object.defineProperty(Events3.prototype, \"off\", {\n get: function() {\n return this.removeListener;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Events3.prototype, \"addListener\", {\n get: function() {\n return this.on;\n },\n enumerable: false,\n configurable: true\n });\n return Events3;\n }();\n exports.Events = Events2;\n }\n });\n\n // node_modules/@geckos.io/common/lib/bridge.js\n var import_events = __toESM(require_cjs(), 1);\n var Bridge = class {\n constructor() {\n this.eventEmitter = new import_events.Events();\n }\n emit(eventName, data, connection = {}) {\n this.eventEmitter.emit(eventName, data, connection);\n }\n on(eventName, cb) {\n return this.eventEmitter.on(eventName, (data, options) => {\n cb(data, options);\n });\n }\n removeAllListeners() {\n this.eventEmitter.removeAllListeners();\n }\n };\n var bridge = new Bridge();\n\n // node_modules/@geckos.io/common/lib/constants.js\n var EVENTS = {\n CONNECT: \"connect\",\n CONNECTION: \"connection\",\n DATA_CHANNEL_IS_OPEN: \"dataChannelIsOpen\",\n DISCONNECT: \"disconnect\",\n DISCONNECTED: \"disconnected\",\n DROP: \"dropped\",\n ERROR: \"error\",\n RAW_MESSAGE: \"rawMessage\",\n RECEIVED_FROM_DATA_CHANNEL: \"receiveFromDataChannel\",\n SEND_OVER_DATA_CHANNEL: \"sendOverDataChannel\"\n };\n var ERRORS = {\n BROWSER_NOT_SUPPORTED: \"BROWSER_NOT_SUPPORTED\",\n COULD_NOT_PARSE_MESSAGE: \"COULD_NOT_PARSE_MESSAGE\",\n DROPPED_FROM_BUFFERING: \"DROPPED_FROM_BUFFERING\",\n MAX_MESSAGE_SIZE_EXCEEDED: \"MAX_MESSAGE_SIZE_EXCEEDED\"\n };\n\n // node_modules/@geckos.io/common/lib/types.js\n var ArrayBufferView = Object.getPrototypeOf(Object.getPrototypeOf(new Uint8Array())).constructor;\n\n // node_modules/@geckos.io/common/lib/helpers.js\n var tick = typeof Promise == \"function\" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout;\n var isStringMessage = (data) => {\n return typeof data === \"string\";\n };\n var isBufferMessage = (data) => {\n return data instanceof ArrayBuffer || data instanceof ArrayBufferView;\n };\n var isJSONMessage = (data) => {\n try {\n if (typeof data !== \"string\")\n return false;\n if (!isNaN(parseInt(data)))\n return false;\n JSON.parse(data);\n return true;\n } catch (error) {\n return false;\n }\n };\n\n // node_modules/@geckos.io/common/lib/parseMessage.js\n var ParseMessage = (ev) => {\n let { data } = ev;\n if (!data)\n data = ev;\n const isBuffer = isBufferMessage(data);\n const isJson = isJSONMessage(data);\n const isString = isStringMessage(data);\n if (isJson) {\n const object = JSON.parse(data);\n const key = Object.keys(object)[0];\n const value = object[key];\n return { key, data: value };\n }\n if (isBuffer) {\n return { key: EVENTS.RAW_MESSAGE, data };\n }\n if (isString) {\n return { key: EVENTS.RAW_MESSAGE, data };\n }\n return { key: \"error\", data: new Error(ERRORS.COULD_NOT_PARSE_MESSAGE) };\n };\n var parseMessage_default = ParseMessage;\n\n // node_modules/@geckos.io/common/lib/sendMessage.js\n var SendMessage = (dataChannel, maxMessageSize, eventName, data = null) => {\n var _a;\n const send = (data2, isBuffer) => {\n var _a2;\n const bytes = (_a2 = data2.byteLength) !== null && _a2 !== void 0 ? _a2 : data2.length * 2;\n if (typeof maxMessageSize === \"number\" && bytes > maxMessageSize) {\n throw new Error(`maxMessageSize of ${maxMessageSize} exceeded`);\n } else {\n Promise.resolve().then(() => {\n if (dataChannel.send)\n dataChannel.send(data2);\n else {\n if (!isBuffer)\n dataChannel.sendMessage(data2);\n else\n dataChannel.sendMessageBinary(Buffer.from(data2));\n }\n }).catch((error) => {\n console.log(\"error\", error);\n });\n }\n };\n if (!dataChannel)\n return;\n if (dataChannel.readyState === \"open\" || ((_a = dataChannel.isOpen) === null || _a === void 0 ? void 0 : _a.call(dataChannel))) {\n try {\n if (eventName === EVENTS.RAW_MESSAGE && data !== null && (isStringMessage(data) || isBufferMessage(data))) {\n send(data, isBufferMessage(data));\n } else {\n send(JSON.stringify({ [eventName]: data }), false);\n }\n } catch (error) {\n console.error(\"Error in sendMessage.ts: \", error.message);\n return error;\n }\n }\n };\n var sendMessage_default = SendMessage;\n\n // node_modules/@geckos.io/client/lib/wrtc/connectionsManager.js\n var ConnectionsManagerClient = class {\n constructor(url, authorization, label, rtcConfiguration) {\n this.url = url;\n this.authorization = authorization;\n this.label = label;\n this.rtcConfiguration = rtcConfiguration;\n this.bridge = new Bridge();\n this.onDataChannel = (ev) => {\n const { channel } = ev;\n if (channel.label !== this.label)\n return;\n this.dataChannel = channel;\n this.dataChannel.binaryType = \"arraybuffer\";\n this.dataChannel.onmessage = (ev2) => {\n const { key, data } = parseMessage_default(ev2);\n this.bridge.emit(key, data);\n };\n };\n }\n emit(eventName, data = null) {\n sendMessage_default(this.dataChannel, this.maxMessageSize, eventName, data);\n }\n async fetchAdditionalCandidates(host, id) {\n var _a;\n if (((_a = this.dataChannel) === null || _a === void 0 ? void 0 : _a.readyState) === \"closed\")\n return;\n const res = await fetch(`${host}/connections/${id}/additional-candidates`, {\n method: \"GET\",\n headers: {\n \"Content-Type\": \"application/json\"\n }\n });\n if (res.ok) {\n const candidates = await res.json();\n candidates.forEach((c) => {\n this.localPeerConnection.addIceCandidate(c);\n });\n }\n }\n async connect() {\n const host = `${this.url}/.wrtc/v2`;\n let headers = { \"Content-Type\": \"application/json\" };\n if (this.authorization)\n headers = { ...headers, [\"Authorization\"]: this.authorization };\n let userData = {};\n try {\n const res = await fetch(`${host}/connections`, {\n method: \"POST\",\n headers\n });\n if (res.status >= 300) {\n throw {\n name: \"Error\",\n message: `Connection failed with status code ${res.status}.`,\n status: res.status,\n statusText: res.statusText\n };\n }\n const json = await res.json();\n userData = json.userData;\n this.remotePeerConnection = json;\n } catch (error) {\n console.error(error.message);\n return { error };\n }\n const { id, localDescription } = this.remotePeerConnection;\n const configuration = {\n sdpSemantics: \"unified-plan\",\n ...this.rtcConfiguration\n };\n const RTCPc = RTCPeerConnection || webkitRTCPeerConnection;\n this.localPeerConnection = new RTCPc(configuration);\n const showBackOffIntervals = (attempts = 10, initial = 50, factor = 1.8, jitter = 20) => Array(attempts).fill(0).map((_, index) => parseInt((initial * factor ** index).toString()) + parseInt((Math.random() * jitter).toString()));\n showBackOffIntervals().forEach((ms) => {\n setTimeout(() => {\n this.fetchAdditionalCandidates(host, id).catch(() => {\n });\n }, ms);\n });\n try {\n await this.localPeerConnection.setRemoteDescription(localDescription);\n this.localPeerConnection.addEventListener(\"datachannel\", this.onDataChannel, { once: true });\n const originalAnswer = await this.localPeerConnection.createAnswer();\n const updatedAnswer = new RTCSessionDescription({\n type: \"answer\",\n sdp: originalAnswer.sdp\n });\n await this.localPeerConnection.setLocalDescription(updatedAnswer);\n try {\n await fetch(`${host}/connections/${id}/remote-description`, {\n method: \"POST\",\n body: JSON.stringify(this.localPeerConnection.localDescription),\n headers: {\n \"Content-Type\": \"application/json\"\n }\n });\n } catch (error) {\n console.error(error.message);\n return { error };\n }\n const waitForDataChannel = () => {\n return new Promise((resolve) => {\n this.localPeerConnection.addEventListener(\"datachannel\", () => {\n resolve();\n }, { once: true });\n });\n };\n if (!this.dataChannel)\n await waitForDataChannel();\n return {\n userData,\n localPeerConnection: this.localPeerConnection,\n dataChannel: this.dataChannel,\n id\n };\n } catch (error) {\n console.error(error.message);\n this.localPeerConnection.close();\n return { error };\n }\n }\n };\n\n // node_modules/@geckos.io/client/lib/wrtc/peerConnection.js\n var PeerConnection = class {\n async connect(connectionsManager) {\n const webRTCPcSupported = RTCPeerConnection || webkitRTCPeerConnection;\n if (webRTCPcSupported) {\n const { localPeerConnection, dataChannel, id, userData, error } = await connectionsManager.connect();\n if (error)\n return { error };\n if (!localPeerConnection || !dataChannel || !id || !userData)\n return { error: new Error('Something went wrong in \"await connectionsManager.connect()\"') };\n this.localPeerConnection = localPeerConnection;\n this.dataChannel = dataChannel;\n this.id = id;\n return { userData };\n } else {\n const error = new Error(ERRORS.BROWSER_NOT_SUPPORTED);\n console.error(error.message);\n return { error };\n }\n }\n };\n\n // node_modules/@geckos.io/common/lib/makeRandomId.js\n var makeRandomId = (length = 24) => {\n const possible = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\";\n let id = \"\";\n for (let i = 0; i < length; i++) {\n id += possible.charAt(Math.floor(Math.random() * possible.length));\n }\n return id;\n };\n var makeRandomId_default = makeRandomId;\n\n // node_modules/@geckos.io/common/lib/runInterval.js\n var runInterval = (interval = 200, runs = 1, cb) => {\n let counter = 0;\n if (typeof cb !== \"function\") {\n console.error(\"You have to define your callback function!\");\n return;\n }\n const i = setInterval(() => {\n cb();\n counter++;\n if (counter === runs - 1) {\n clearInterval(i);\n }\n }, interval);\n cb();\n };\n var runInterval_default = runInterval;\n\n // node_modules/@geckos.io/common/lib/reliableMessage.js\n var makeReliable = (options, cb) => {\n const { interval = 150, runs = 10 } = options;\n const id = makeRandomId_default(24);\n runInterval_default(interval, runs, () => {\n cb(id);\n });\n };\n\n // node_modules/@geckos.io/client/lib/geckos/channel.js\n var ClientChannel = class {\n constructor(url, authorization, port, label, rtcConfiguration) {\n this.userData = {};\n this.receivedReliableMessages = [];\n this.url = port ? `${url}:${port}` : url;\n this.connectionsManager = new ConnectionsManagerClient(this.url, authorization, label, rtcConfiguration);\n this.bridge = this.connectionsManager.bridge;\n this.bridge.on(EVENTS.DISCONNECTED, () => this.bridge.removeAllListeners());\n }\n onconnectionstatechange() {\n const lpc = this.peerConnection.localPeerConnection;\n lpc.onconnectionstatechange = () => {\n if (lpc.connectionState === \"disconnected\" || lpc.connectionState === \"closed\")\n this.bridge.emit(EVENTS.DISCONNECTED);\n };\n }\n get id() {\n return this.peerConnection.id;\n }\n close() {\n this.peerConnection.localPeerConnection.close();\n this.bridge.emit(EVENTS.DISCONNECTED);\n try {\n const host = `${this.url}/.wrtc/v2`;\n fetch(`${host}/connections/${this.id}/close`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\"\n }\n });\n } catch (error) {\n console.error(error.message);\n }\n }\n emit(eventName, data = null, options) {\n if (options && options.reliable) {\n makeReliable(options, (id) => this.connectionsManager.emit(eventName, {\n MESSAGE: data,\n RELIABLE: 1,\n ID: id\n }));\n } else {\n this.connectionsManager.emit(eventName, data);\n }\n }\n get raw() {\n return {\n emit: (rawMessage) => this.emit(EVENTS.RAW_MESSAGE, rawMessage)\n };\n }\n onRaw(callback) {\n this.bridge.on(EVENTS.RAW_MESSAGE, (rawMessage) => {\n const cb = (rawMessage2) => callback(rawMessage2);\n cb(rawMessage);\n });\n }\n async onConnect(callback) {\n var _a;\n this.peerConnection = new PeerConnection();\n const response = await this.peerConnection.connect(this.connectionsManager);\n if (response.error)\n callback(response.error);\n else {\n if (response.userData)\n this.userData = response.userData;\n this.maxMessageSize = this.connectionsManager.maxMessageSize = (_a = this.peerConnection.localPeerConnection.sctp) === null || _a === void 0 ? void 0 : _a.maxMessageSize;\n this.onconnectionstatechange();\n callback();\n }\n }\n onDisconnect(callback) {\n this.bridge.on(EVENTS.DISCONNECTED, callback);\n }\n on(eventName, callback) {\n this.bridge.on(eventName, (data) => {\n const isReliableMessage = data && data.RELIABLE === 1 && data.ID !== \"undefined\";\n const expireTime = 15e3;\n const deleteExpiredReliableMessages = () => {\n const currentTime = new Date().getTime();\n this.receivedReliableMessages.forEach((msg, index, object) => {\n if (msg.expire <= currentTime) {\n object.splice(index, 1);\n }\n });\n };\n if (isReliableMessage) {\n deleteExpiredReliableMessages();\n if (this.receivedReliableMessages.filter((obj) => obj.id === data.ID).length === 0) {\n this.receivedReliableMessages.push({\n id: data.ID,\n timestamp: new Date(),\n expire: new Date().getTime() + expireTime\n });\n callback(data.MESSAGE);\n } else {\n }\n } else {\n callback(data);\n }\n });\n }\n };\n var geckosClient = (options = {}) => {\n const { authorization = void 0, iceServers = [], iceTransportPolicy = \"all\", label = \"geckos.io\", port = 9208, url = `${location.protocol}//${location.hostname}` } = options;\n return new ClientChannel(url, authorization, port, label, { iceServers, iceTransportPolicy });\n };\n var channel_default = geckosClient;\n\n // code/adapters/geckos-client.ts\n var logger = new gdjs.Logger(\"THNK - Geckos.io Adapter\");\n THNK.GeckosClientAdapter = class GeckosClientAdapter extends THNK.ClientAdapter {\n constructor(ip, port) {\n super();\n this.connection = null;\n this.ip = `http://${ip}`;\n this.port = port;\n }\n async prepare() {\n this.connection = channel_default({ url: this.ip, port: this.port, label: \"THNK\" });\n await new Promise(\n (resolve, reject) => this.connection.onConnect((error) => {\n if (error)\n return reject(error.message);\n this.connection.onRaw(\n (message) => this.onMessage(message)\n );\n this.connection.onDisconnect(() => this.onDisconnection());\n resolve();\n })\n );\n }\n close() {\n if (this.connection)\n this.connection.close();\n }\n doSendMessage(message) {\n if (!this.connection) {\n return logger.error(\n \"Tried to send a message on an unestablished connection!\"\n );\n }\n this.connection.raw.emit(\n message.buffer.slice(message.buffer.byteLength - message.byteLength)\n );\n }\n };\n})();\n/**\n * @package npmjs.com/package/@yandeu/events (events.min.js)\n *\n * @author Arnout Kazemier (https://github.com/3rd-Eden)\n * @copyright Copyright (c) 2014 Arnout Kazemier\n * @license {@link https://github.com/primus/eventemitter3/blob/master/LICENSE|MIT}\n *\n * @author Yannick Deubel (https://github.com/yandeu)\n * @copyright Copyright (c) 2021 Yannick Deubel; Project Url: https://github.com/yandeu/events\n * @license {@link https://github.com/yandeu/events/blob/master/LICENSE|MIT}\n */\n", + "inlineCode": [ + "// Load THNK Geckos Client Adapter (https://github.com/arthuro555/THNK)", + "\"use strict\";", + "(() => {", + " var __create = Object.create;", + " var __defProp = Object.defineProperty;", + " var __getOwnPropDesc = Object.getOwnPropertyDescriptor;", + " var __getOwnPropNames = Object.getOwnPropertyNames;", + " var __getProtoOf = Object.getPrototypeOf;", + " var __hasOwnProp = Object.prototype.hasOwnProperty;", + " var __commonJS = (cb, mod) => function __require() {", + " return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;", + " };", + " var __copyProps = (to, from, except, desc) => {", + " if (from && typeof from === \"object\" || typeof from === \"function\") {", + " for (let key of __getOwnPropNames(from))", + " if (!__hasOwnProp.call(to, key) && key !== except)", + " __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });", + " }", + " return to;", + " };", + " var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(", + " isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,", + " mod", + " ));", + "", + " // node_modules/@yandeu/events/cjs/version.js", + " var require_version = __commonJS({", + " \"node_modules/@yandeu/events/cjs/version.js\"(exports) {", + " \"use strict\";", + " Object.defineProperty(exports, \"__esModule\", { value: true });", + " exports.VERSION = void 0;", + " exports.VERSION = \"0.0.5\";", + " }", + " });", + "", + " // node_modules/@yandeu/events/cjs/index.js", + " var require_cjs = __commonJS({", + " \"node_modules/@yandeu/events/cjs/index.js\"(exports) {", + " \"use strict\";", + " var __spreadArray = exports && exports.__spreadArray || function(to, from) {", + " for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)", + " to[j] = from[i];", + " return to;", + " };", + " Object.defineProperty(exports, \"__esModule\", { value: true });", + " exports.Events = void 0;", + " var version_1 = require_version();", + " var EE = function() {", + " function EE2(fn, context, once) {", + " if (once === void 0) {", + " once = false;", + " }", + " this.fn = fn;", + " this.context = context;", + " this.once = once;", + " }", + " return EE2;", + " }();", + " var addListener = function(emitter, event, fn, context, once) {", + " if (typeof fn !== \"function\") {", + " throw new TypeError(\"The listener must be a function\");", + " }", + " var listener = new EE(fn, context || emitter, once);", + " if (!emitter._events.has(event))", + " emitter._events.set(event, listener), emitter._eventsCount++;", + " else if (!emitter._events.get(event).fn)", + " emitter._events.get(event).push(listener);", + " else", + " emitter._events.set(event, [emitter._events.get(event), listener]);", + " return emitter;", + " };", + " var clearEvent = function(emitter, event) {", + " if (--emitter._eventsCount === 0)", + " emitter._events = /* @__PURE__ */ new Map();", + " else", + " emitter._events.delete(event);", + " };", + " var Events2 = function() {", + " function Events3() {", + " this._events = /* @__PURE__ */ new Map();", + " this._eventsCount = 0;", + " }", + " Object.defineProperty(Events3, \"VERSION\", {", + " get: function() {", + " return version_1.VERSION;", + " },", + " enumerable: false,", + " configurable: true", + " });", + " Events3.prototype.eventNames = function() {", + " return Array.from(this._events.keys());", + " };", + " Events3.prototype.listeners = function(event) {", + " var handlers = this._events.get(event);", + " if (!handlers)", + " return [];", + " if (handlers.fn)", + " return [handlers.fn];", + " for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {", + " ee[i] = handlers[i].fn;", + " }", + " return ee;", + " };", + " Events3.prototype.listenerCount = function(event) {", + " var listeners = this._events.get(event);", + " if (!listeners)", + " return 0;", + " if (listeners.fn)", + " return 1;", + " return listeners.length;", + " };", + " Events3.prototype.emit = function(event) {", + " var _a, _b;", + " var args = [];", + " for (var _i = 1; _i < arguments.length; _i++) {", + " args[_i - 1] = arguments[_i];", + " }", + " if (!this._events.has(event))", + " return false;", + " var listeners = this._events.get(event);", + " var i;", + " if (listeners.fn) {", + " if (listeners.once)", + " this.removeListener(event, listeners.fn, void 0, true);", + " return (_a = listeners.fn).call.apply(_a, __spreadArray([listeners.context], args)), true;", + " } else {", + " var length_1 = listeners.length;", + " for (i = 0; i < length_1; i++) {", + " if (listeners[i].once)", + " this.removeListener(event, listeners[i].fn, void 0, true);", + " (_b = listeners[i].fn).call.apply(_b, __spreadArray([listeners[i].context], args));", + " }", + " }", + " return true;", + " };", + " Events3.prototype.on = function(event, fn, context) {", + " return addListener(this, event, fn, context, false);", + " };", + " Events3.prototype.once = function(event, fn, context) {", + " return addListener(this, event, fn, context, true);", + " };", + " Events3.prototype.removeListener = function(event, fn, context, once) {", + " if (!this._events.has(event))", + " return this;", + " if (!fn) {", + " clearEvent(this, event);", + " return this;", + " }", + " var listeners = this._events.get(event);", + " if (listeners.fn) {", + " if (listeners.fn === fn && (!once || listeners.once) && (!context || listeners.context === context)) {", + " clearEvent(this, event);", + " }", + " } else {", + " for (var i = 0, events = [], length = listeners.length; i < length; i++) {", + " if (listeners[i].fn !== fn || once && !listeners[i].once || context && listeners[i].context !== context) {", + " events.push(listeners[i]);", + " }", + " }", + " if (events.length)", + " this._events.set(event, events.length === 1 ? events[0] : events);", + " else", + " clearEvent(this, event);", + " }", + " return this;", + " };", + " Events3.prototype.removeAllListeners = function(event) {", + " if (event) {", + " if (this._events.delete(event))", + " clearEvent(this, event);", + " } else {", + " this._events = /* @__PURE__ */ new Map();", + " this._eventsCount = 0;", + " }", + " return this;", + " };", + " Object.defineProperty(Events3.prototype, \"off\", {", + " get: function() {", + " return this.removeListener;", + " },", + " enumerable: false,", + " configurable: true", + " });", + " Object.defineProperty(Events3.prototype, \"addListener\", {", + " get: function() {", + " return this.on;", + " },", + " enumerable: false,", + " configurable: true", + " });", + " return Events3;", + " }();", + " exports.Events = Events2;", + " }", + " });", + "", + " // node_modules/@geckos.io/common/lib/bridge.js", + " var import_events = __toESM(require_cjs(), 1);", + " var Bridge = class {", + " constructor() {", + " this.eventEmitter = new import_events.Events();", + " }", + " emit(eventName, data, connection = {}) {", + " this.eventEmitter.emit(eventName, data, connection);", + " }", + " on(eventName, cb) {", + " return this.eventEmitter.on(eventName, (data, options) => {", + " cb(data, options);", + " });", + " }", + " removeAllListeners() {", + " this.eventEmitter.removeAllListeners();", + " }", + " };", + " var bridge = new Bridge();", + "", + " // node_modules/@geckos.io/common/lib/constants.js", + " var EVENTS = {", + " CONNECT: \"connect\",", + " CONNECTION: \"connection\",", + " DATA_CHANNEL_IS_OPEN: \"dataChannelIsOpen\",", + " DISCONNECT: \"disconnect\",", + " DISCONNECTED: \"disconnected\",", + " DROP: \"dropped\",", + " ERROR: \"error\",", + " RAW_MESSAGE: \"rawMessage\",", + " RECEIVED_FROM_DATA_CHANNEL: \"receiveFromDataChannel\",", + " SEND_OVER_DATA_CHANNEL: \"sendOverDataChannel\"", + " };", + " var ERRORS = {", + " BROWSER_NOT_SUPPORTED: \"BROWSER_NOT_SUPPORTED\",", + " COULD_NOT_PARSE_MESSAGE: \"COULD_NOT_PARSE_MESSAGE\",", + " DROPPED_FROM_BUFFERING: \"DROPPED_FROM_BUFFERING\",", + " MAX_MESSAGE_SIZE_EXCEEDED: \"MAX_MESSAGE_SIZE_EXCEEDED\"", + " };", + "", + " // node_modules/@geckos.io/common/lib/types.js", + " var ArrayBufferView = Object.getPrototypeOf(Object.getPrototypeOf(new Uint8Array())).constructor;", + "", + " // node_modules/@geckos.io/common/lib/helpers.js", + " var tick = typeof Promise == \"function\" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout;", + " var isStringMessage = (data) => {", + " return typeof data === \"string\";", + " };", + " var isBufferMessage = (data) => {", + " return data instanceof ArrayBuffer || data instanceof ArrayBufferView;", + " };", + " var isJSONMessage = (data) => {", + " try {", + " if (typeof data !== \"string\")", + " return false;", + " if (!isNaN(parseInt(data)))", + " return false;", + " JSON.parse(data);", + " return true;", + " } catch (error) {", + " return false;", + " }", + " };", + "", + " // node_modules/@geckos.io/common/lib/parseMessage.js", + " var ParseMessage = (ev) => {", + " let { data } = ev;", + " if (!data)", + " data = ev;", + " const isBuffer = isBufferMessage(data);", + " const isJson = isJSONMessage(data);", + " const isString = isStringMessage(data);", + " if (isJson) {", + " const object = JSON.parse(data);", + " const key = Object.keys(object)[0];", + " const value = object[key];", + " return { key, data: value };", + " }", + " if (isBuffer) {", + " return { key: EVENTS.RAW_MESSAGE, data };", + " }", + " if (isString) {", + " return { key: EVENTS.RAW_MESSAGE, data };", + " }", + " return { key: \"error\", data: new Error(ERRORS.COULD_NOT_PARSE_MESSAGE) };", + " };", + " var parseMessage_default = ParseMessage;", + "", + " // node_modules/@geckos.io/common/lib/sendMessage.js", + " var SendMessage = (dataChannel, maxMessageSize, eventName, data = null) => {", + " var _a;", + " const send = (data2, isBuffer) => {", + " var _a2;", + " const bytes = (_a2 = data2.byteLength) !== null && _a2 !== void 0 ? _a2 : data2.length * 2;", + " if (typeof maxMessageSize === \"number\" && bytes > maxMessageSize) {", + " throw new Error(`maxMessageSize of ${maxMessageSize} exceeded`);", + " } else {", + " Promise.resolve().then(() => {", + " if (dataChannel.send)", + " dataChannel.send(data2);", + " else {", + " if (!isBuffer)", + " dataChannel.sendMessage(data2);", + " else", + " dataChannel.sendMessageBinary(Buffer.from(data2));", + " }", + " }).catch((error) => {", + " console.log(\"error\", error);", + " });", + " }", + " };", + " if (!dataChannel)", + " return;", + " if (dataChannel.readyState === \"open\" || ((_a = dataChannel.isOpen) === null || _a === void 0 ? void 0 : _a.call(dataChannel))) {", + " try {", + " if (eventName === EVENTS.RAW_MESSAGE && data !== null && (isStringMessage(data) || isBufferMessage(data))) {", + " send(data, isBufferMessage(data));", + " } else {", + " send(JSON.stringify({ [eventName]: data }), false);", + " }", + " } catch (error) {", + " console.error(\"Error in sendMessage.ts: \", error.message);", + " return error;", + " }", + " }", + " };", + " var sendMessage_default = SendMessage;", + "", + " // node_modules/@geckos.io/client/lib/wrtc/connectionsManager.js", + " var ConnectionsManagerClient = class {", + " constructor(url, authorization, label, rtcConfiguration) {", + " this.url = url;", + " this.authorization = authorization;", + " this.label = label;", + " this.rtcConfiguration = rtcConfiguration;", + " this.bridge = new Bridge();", + " this.onDataChannel = (ev) => {", + " const { channel } = ev;", + " if (channel.label !== this.label)", + " return;", + " this.dataChannel = channel;", + " this.dataChannel.binaryType = \"arraybuffer\";", + " this.dataChannel.onmessage = (ev2) => {", + " const { key, data } = parseMessage_default(ev2);", + " this.bridge.emit(key, data);", + " };", + " };", + " }", + " emit(eventName, data = null) {", + " sendMessage_default(this.dataChannel, this.maxMessageSize, eventName, data);", + " }", + " async fetchAdditionalCandidates(host, id) {", + " var _a;", + " if (((_a = this.dataChannel) === null || _a === void 0 ? void 0 : _a.readyState) === \"closed\")", + " return;", + " const res = await fetch(`${host}/connections/${id}/additional-candidates`, {", + " method: \"GET\",", + " headers: {", + " \"Content-Type\": \"application/json\"", + " }", + " });", + " if (res.ok) {", + " const candidates = await res.json();", + " candidates.forEach((c) => {", + " this.localPeerConnection.addIceCandidate(c);", + " });", + " }", + " }", + " async connect() {", + " const host = `${this.url}/.wrtc/v2`;", + " let headers = { \"Content-Type\": \"application/json\" };", + " if (this.authorization)", + " headers = { ...headers, [\"Authorization\"]: this.authorization };", + " let userData = {};", + " try {", + " const res = await fetch(`${host}/connections`, {", + " method: \"POST\",", + " headers", + " });", + " if (res.status >= 300) {", + " throw {", + " name: \"Error\",", + " message: `Connection failed with status code ${res.status}.`,", + " status: res.status,", + " statusText: res.statusText", + " };", + " }", + " const json = await res.json();", + " userData = json.userData;", + " this.remotePeerConnection = json;", + " } catch (error) {", + " console.error(error.message);", + " return { error };", + " }", + " const { id, localDescription } = this.remotePeerConnection;", + " const configuration = {", + " sdpSemantics: \"unified-plan\",", + " ...this.rtcConfiguration", + " };", + " const RTCPc = RTCPeerConnection || webkitRTCPeerConnection;", + " this.localPeerConnection = new RTCPc(configuration);", + " const showBackOffIntervals = (attempts = 10, initial = 50, factor = 1.8, jitter = 20) => Array(attempts).fill(0).map((_, index) => parseInt((initial * factor ** index).toString()) + parseInt((Math.random() * jitter).toString()));", + " showBackOffIntervals().forEach((ms) => {", + " setTimeout(() => {", + " this.fetchAdditionalCandidates(host, id).catch(() => {", + " });", + " }, ms);", + " });", + " try {", + " await this.localPeerConnection.setRemoteDescription(localDescription);", + " this.localPeerConnection.addEventListener(\"datachannel\", this.onDataChannel, { once: true });", + " const originalAnswer = await this.localPeerConnection.createAnswer();", + " const updatedAnswer = new RTCSessionDescription({", + " type: \"answer\",", + " sdp: originalAnswer.sdp", + " });", + " await this.localPeerConnection.setLocalDescription(updatedAnswer);", + " try {", + " await fetch(`${host}/connections/${id}/remote-description`, {", + " method: \"POST\",", + " body: JSON.stringify(this.localPeerConnection.localDescription),", + " headers: {", + " \"Content-Type\": \"application/json\"", + " }", + " });", + " } catch (error) {", + " console.error(error.message);", + " return { error };", + " }", + " const waitForDataChannel = () => {", + " return new Promise((resolve) => {", + " this.localPeerConnection.addEventListener(\"datachannel\", () => {", + " resolve();", + " }, { once: true });", + " });", + " };", + " if (!this.dataChannel)", + " await waitForDataChannel();", + " return {", + " userData,", + " localPeerConnection: this.localPeerConnection,", + " dataChannel: this.dataChannel,", + " id", + " };", + " } catch (error) {", + " console.error(error.message);", + " this.localPeerConnection.close();", + " return { error };", + " }", + " }", + " };", + "", + " // node_modules/@geckos.io/client/lib/wrtc/peerConnection.js", + " var PeerConnection = class {", + " async connect(connectionsManager) {", + " const webRTCPcSupported = RTCPeerConnection || webkitRTCPeerConnection;", + " if (webRTCPcSupported) {", + " const { localPeerConnection, dataChannel, id, userData, error } = await connectionsManager.connect();", + " if (error)", + " return { error };", + " if (!localPeerConnection || !dataChannel || !id || !userData)", + " return { error: new Error('Something went wrong in \"await connectionsManager.connect()\"') };", + " this.localPeerConnection = localPeerConnection;", + " this.dataChannel = dataChannel;", + " this.id = id;", + " return { userData };", + " } else {", + " const error = new Error(ERRORS.BROWSER_NOT_SUPPORTED);", + " console.error(error.message);", + " return { error };", + " }", + " }", + " };", + "", + " // node_modules/@geckos.io/common/lib/makeRandomId.js", + " var makeRandomId = (length = 24) => {", + " const possible = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\";", + " let id = \"\";", + " for (let i = 0; i < length; i++) {", + " id += possible.charAt(Math.floor(Math.random() * possible.length));", + " }", + " return id;", + " };", + " var makeRandomId_default = makeRandomId;", + "", + " // node_modules/@geckos.io/common/lib/runInterval.js", + " var runInterval = (interval = 200, runs = 1, cb) => {", + " let counter = 0;", + " if (typeof cb !== \"function\") {", + " console.error(\"You have to define your callback function!\");", + " return;", + " }", + " const i = setInterval(() => {", + " cb();", + " counter++;", + " if (counter === runs - 1) {", + " clearInterval(i);", + " }", + " }, interval);", + " cb();", + " };", + " var runInterval_default = runInterval;", + "", + " // node_modules/@geckos.io/common/lib/reliableMessage.js", + " var makeReliable = (options, cb) => {", + " const { interval = 150, runs = 10 } = options;", + " const id = makeRandomId_default(24);", + " runInterval_default(interval, runs, () => {", + " cb(id);", + " });", + " };", + "", + " // node_modules/@geckos.io/client/lib/geckos/channel.js", + " var ClientChannel = class {", + " constructor(url, authorization, port, label, rtcConfiguration) {", + " this.userData = {};", + " this.receivedReliableMessages = [];", + " this.url = port ? `${url}:${port}` : url;", + " this.connectionsManager = new ConnectionsManagerClient(this.url, authorization, label, rtcConfiguration);", + " this.bridge = this.connectionsManager.bridge;", + " this.bridge.on(EVENTS.DISCONNECTED, () => this.bridge.removeAllListeners());", + " }", + " onconnectionstatechange() {", + " const lpc = this.peerConnection.localPeerConnection;", + " lpc.onconnectionstatechange = () => {", + " if (lpc.connectionState === \"disconnected\" || lpc.connectionState === \"closed\")", + " this.bridge.emit(EVENTS.DISCONNECTED);", + " };", + " }", + " get id() {", + " return this.peerConnection.id;", + " }", + " close() {", + " this.peerConnection.localPeerConnection.close();", + " this.bridge.emit(EVENTS.DISCONNECTED);", + " try {", + " const host = `${this.url}/.wrtc/v2`;", + " fetch(`${host}/connections/${this.id}/close`, {", + " method: \"POST\",", + " headers: {", + " \"Content-Type\": \"application/json\"", + " }", + " });", + " } catch (error) {", + " console.error(error.message);", + " }", + " }", + " emit(eventName, data = null, options) {", + " if (options && options.reliable) {", + " makeReliable(options, (id) => this.connectionsManager.emit(eventName, {", + " MESSAGE: data,", + " RELIABLE: 1,", + " ID: id", + " }));", + " } else {", + " this.connectionsManager.emit(eventName, data);", + " }", + " }", + " get raw() {", + " return {", + " emit: (rawMessage) => this.emit(EVENTS.RAW_MESSAGE, rawMessage)", + " };", + " }", + " onRaw(callback) {", + " this.bridge.on(EVENTS.RAW_MESSAGE, (rawMessage) => {", + " const cb = (rawMessage2) => callback(rawMessage2);", + " cb(rawMessage);", + " });", + " }", + " async onConnect(callback) {", + " var _a;", + " this.peerConnection = new PeerConnection();", + " const response = await this.peerConnection.connect(this.connectionsManager);", + " if (response.error)", + " callback(response.error);", + " else {", + " if (response.userData)", + " this.userData = response.userData;", + " this.maxMessageSize = this.connectionsManager.maxMessageSize = (_a = this.peerConnection.localPeerConnection.sctp) === null || _a === void 0 ? void 0 : _a.maxMessageSize;", + " this.onconnectionstatechange();", + " callback();", + " }", + " }", + " onDisconnect(callback) {", + " this.bridge.on(EVENTS.DISCONNECTED, callback);", + " }", + " on(eventName, callback) {", + " this.bridge.on(eventName, (data) => {", + " const isReliableMessage = data && data.RELIABLE === 1 && data.ID !== \"undefined\";", + " const expireTime = 15e3;", + " const deleteExpiredReliableMessages = () => {", + " const currentTime = new Date().getTime();", + " this.receivedReliableMessages.forEach((msg, index, object) => {", + " if (msg.expire <= currentTime) {", + " object.splice(index, 1);", + " }", + " });", + " };", + " if (isReliableMessage) {", + " deleteExpiredReliableMessages();", + " if (this.receivedReliableMessages.filter((obj) => obj.id === data.ID).length === 0) {", + " this.receivedReliableMessages.push({", + " id: data.ID,", + " timestamp: new Date(),", + " expire: new Date().getTime() + expireTime", + " });", + " callback(data.MESSAGE);", + " } else {", + " }", + " } else {", + " callback(data);", + " }", + " });", + " }", + " };", + " var geckosClient = (options = {}) => {", + " const { authorization = void 0, iceServers = [], iceTransportPolicy = \"all\", label = \"geckos.io\", port = 9208, url = `${location.protocol}//${location.hostname}` } = options;", + " return new ClientChannel(url, authorization, port, label, { iceServers, iceTransportPolicy });", + " };", + " var channel_default = geckosClient;", + "", + " // code/adapters/geckos-client.ts", + " var logger = new gdjs.Logger(\"THNK - Geckos.io Adapter\");", + " THNK.GeckosClientAdapter = class GeckosClientAdapter extends THNK.ClientAdapter {", + " constructor(ip, port) {", + " super();", + " this.connection = null;", + " this.ip = `http://${ip}`;", + " this.port = port;", + " }", + " async prepare() {", + " this.connection = channel_default({ url: this.ip, port: this.port, label: \"THNK\" });", + " await new Promise(", + " (resolve, reject) => this.connection.onConnect((error) => {", + " if (error)", + " return reject(error.message);", + " this.connection.onRaw(", + " (message) => this.onMessage(message)", + " );", + " this.connection.onDisconnect(() => this.onDisconnection());", + " resolve();", + " })", + " );", + " }", + " close() {", + " if (this.connection)", + " this.connection.close();", + " }", + " doSendMessage(message) {", + " if (!this.connection) {", + " return logger.error(", + " \"Tried to send a message on an unestablished connection!\"", + " );", + " }", + " this.connection.raw.emit(", + " message.buffer.slice(message.buffer.byteLength - message.byteLength)", + " );", + " }", + " };", + "})();", + "/**", + " * @package npmjs.com/package/@yandeu/events (events.min.js)", + " *", + " * @author Arnout Kazemier (https://github.com/3rd-Eden)", + " * @copyright Copyright (c) 2014 Arnout Kazemier", + " * @license {@link https://github.com/primus/eventemitter3/blob/master/LICENSE|MIT}", + " *", + " * @author Yannick Deubel (https://github.com/yandeu)", + " * @copyright Copyright (c) 2021 Yannick Deubel; Project Url: https://github.com/yandeu/events", + " * @license {@link https://github.com/yandeu/events/blob/master/LICENSE|MIT}", + " */", + "" + ], "parameterObjects": "", "useStrict": true, "eventsSheetExpanded": false @@ -53,14 +720,21 @@ "description": "Connects to a geckos.io THNK server.", "fullName": "Connect to server", "functionType": "Action", - "group": "", "name": "ConnectToServer", - "private": false, "sentence": "Connect to server at _PARAM1_:_PARAM2_", "events": [ { "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": "THNK.client.startClient(\n runtimeScene,\n new THNK.GeckosClientAdapter(\n eventsFunctionContext.getArgument(\"Host\"),\n eventsFunctionContext.getArgument(\"Port\")\n )\n);\n", + "inlineCode": [ + "THNK.client.startClient(", + " runtimeScene,", + " new THNK.GeckosClientAdapter(", + " eventsFunctionContext.getArgument(\"Host\"),", + " eventsFunctionContext.getArgument(\"Port\")", + " )", + ");", + "" + ], "parameterObjects": "", "useStrict": true, "eventsSheetExpanded": false @@ -68,23 +742,13 @@ ], "parameters": [ { - "codeOnly": false, - "defaultValue": "", "description": "Hostname (URL or IP address)", - "longDescription": "", "name": "Host", - "optional": false, - "supplementaryInformation": "", "type": "string" }, { - "codeOnly": false, - "defaultValue": "", "description": "The port the server is hosted on", - "longDescription": "", "name": "Port", - "optional": false, - "supplementaryInformation": "", "type": "expression" } ], diff --git a/extensions/THNK_GeckosServer.json b/extensions/THNK_GeckosServer.json index ff95bdb..1ad0bf1 100644 --- a/extensions/THNK_GeckosServer.json +++ b/extensions/THNK_GeckosServer.json @@ -1,16 +1,28 @@ { "author": "", "category": "Network", - "description": "A THNK adapter to provide a server via [geckos.io](https://geckos.io).", "extensionNamespace": "", - "fullName": "THNK Server (Geckos.io)", - "helpPath": "", + "fullName": "THNK Framework - Geckos server adapter", + "helpPath": "https://thnk.cloud/", "iconUrl": "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0ibWRpLXNlcnZlci1uZXR3b3JrIiB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCI+PHBhdGggZD0iTTEzLDE5SDE0QTEsMSAwIDAsMSAxNSwyMEgyMlYyMkgxNUExLDEgMCAwLDEgMTQsMjNIMTBBMSwxIDAgMCwxIDksMjJIMlYyMEg5QTEsMSAwIDAsMSAxMCwxOUgxMVYxN0g0QTEsMSAwIDAsMSAzLDE2VjEyQTEsMSAwIDAsMSA0LDExSDIwQTEsMSAwIDAsMSAyMSwxMlYxNkExLDEgMCAwLDEgMjAsMTdIMTNWMTlNNCwzSDIwQTEsMSAwIDAsMSAyMSw0VjhBMSwxIDAgMCwxIDIwLDlINEExLDEgMCAwLDEgMyw4VjRBMSwxIDAgMCwxIDQsM005LDdIMTBWNUg5VjdNOSwxNUgxMFYxM0g5VjE1TTUsNVY3SDdWNUg1TTUsMTNWMTVIN1YxM0g1WiIgLz48L3N2Zz4=", "name": "THNK_GeckosServer", "previewIconUrl": "https://resources.gdevelop-app.com/assets/Icons/server-network.svg", - "shortDescription": "A THNK adapter to provide a server via geckos.io", + "shortDescription": "A THNK adapter to provide a server via geckos.io (IP & Port).", "version": "1.0.0", - "tags": [], + "description": [ + "A THNK adapter to provide a server via [geckos.io](https://geckos.io). Geckos servers are bound to the local machine's networking: you connect to one using your machine's IP address and a port number (preferably 4 digits long).", + "", + "NOTE: The geckos servers will only work on previews and PC builds. Preview support is currently windows-only." + ], + "tags": [ + "THNK", + "adapter", + "geckos", + "IP", + "port", + "address", + "geckos.io" + ], "authorIds": [ "ZgrsWuRTAkXgeuPV9bo0zuEcA2w1" ], @@ -24,17 +36,26 @@ ], "eventsFunctions": [ { - "description": "", "fullName": "", "functionType": "Action", - "group": "", "name": "onFirstSceneLoaded", - "private": false, "sentence": "", "events": [ { "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": "// Load THNK Geckos Server Adapter (https://github.com/arthuro555/THNK)\n\"use strict\";var ht=Object.create;var Te=Object.defineProperty;var ut=Object.getOwnPropertyDescriptor;var ft=Object.getOwnPropertyNames;var lt=Object.getPrototypeOf,dt=Object.prototype.hasOwnProperty;var U=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var pt=(r,e,t,i)=>{if(e&&typeof e==\"object\"||typeof e==\"function\")for(let s of ft(e))!dt.call(r,s)&&s!==t&&Te(r,s,{get:()=>e[s],enumerable:!(i=ut(e,s))||i.enumerable});return r};var xe=(r,e,t)=>(t=r!=null?ht(lt(r)):{},pt(e||!r||!r.__esModule?Te(t,\"default\",{value:r,enumerable:!0}):t,r));var Ae=U((Kt,Be)=>{var b=require(\"fs\"),Et=require(\"util\"),K=require(\"path\"),_e=require(\"events\"),Ue=require(\"zlib\"),ze=require(\"stream\"),o={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSIGFIRST:80,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,MAXFILECOMMENT:65535,ENDL64HDR:20,ENDL64SIG:117853008,ENDL64SIGFIRST:80,ENDL64OFS:8,END64HDR:56,END64SIG:101075792,END64SIGFIRST:80,END64SUB:24,END64TOT:32,END64SIZ:40,END64OFF:48,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,FLG_ENC:0,FLG_COMP1:1,FLG_COMP2:2,FLG_DESC:4,FLG_ENH:8,FLG_STR:16,FLG_LNG:1024,FLG_MSK:4096,FLG_ENTRY_ENC:1,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535},k=function(r){let e,t,i,s,c,p,d=this,E=r.storeEntries!==!1?{}:null,a=r.file,l=r.nameEncoding?new TextDecoder(r.nameEncoding):null;C();function C(){r.fd?(e=r.fd,F()):b.open(a,\"r\",(n,h)=>{if(n)return d.emit(\"error\",n);e=h,F()})}function F(){b.fstat(e,(n,h)=>{if(n)return d.emit(\"error\",n);t=h.size,i=r.chunkSize||Math.round(t/1e3),i=Math.max(Math.min(i,Math.min(128*1024,t)),Math.min(1024,t)),D()})}function y(n,h){if(n||!h)return d.emit(\"error\",n||new Error(\"Archive read error\"));let f=s.lastPos,u=f-s.win.position,g=s.win.buffer,m=s.minPos;for(;--f>=m&&--u>=0;)if(g.length-u>=4&&g[u]===s.firstByte&&g.readUInt32LE(u)===s.sig){s.lastBufferPosition=u,s.lastBytesRead=h,s.complete();return}if(f===m)return d.emit(\"error\",new Error(\"Bad archive\"));if(s.lastPos=f+1,s.chunkSize*=2,f<=m)return d.emit(\"error\",new Error(\"Bad archive\"));let _=Math.min(s.chunkSize,f-m);s.win.expandLeft(_,y)}function D(){let n=Math.min(o.ENDHDR+o.MAXFILECOMMENT,t);s={win:new ce(e),totalReadLength:n,minPos:t-n,lastPos:t,chunkSize:Math.min(1024,i),firstByte:o.ENDSIGFIRST,sig:o.ENDSIG,complete:R},s.win.read(t-s.chunkSize,s.chunkSize,y)}function R(){let n=s.win.buffer,h=s.lastBufferPosition;try{c=new pe,c.read(n.slice(h,h+o.ENDHDR)),c.headerOffset=s.win.position+h,c.commentLength?d.comment=n.slice(h+o.ENDHDR,h+o.ENDHDR+c.commentLength).toString():d.comment=null,d.entriesCount=c.volumeEntries,d.centralDirectory=c,c.volumeEntries===o.EF_ZIP64_OR_16&&c.totalEntries===o.EF_ZIP64_OR_16||c.size===o.EF_ZIP64_OR_32||c.offset===o.EF_ZIP64_OR_32?N():(s={},P())}catch(f){d.emit(\"error\",f)}}function N(){let n=o.ENDL64HDR;s.lastBufferPosition>n?(s.lastBufferPosition-=n,M()):(s={win:s.win,totalReadLength:n,minPos:s.win.position-n,lastPos:s.win.position,chunkSize:s.chunkSize,firstByte:o.ENDL64SIGFIRST,sig:o.ENDL64SIG,complete:M},s.win.read(s.lastPos-s.chunkSize,s.chunkSize,y))}function M(){let n=s.win.buffer,h=new Ee;h.read(n.slice(s.lastBufferPosition,s.lastBufferPosition+o.ENDL64HDR));let f=t-h.headerOffset;s={win:s.win,totalReadLength:f,minPos:h.headerOffset,lastPos:s.lastPos,chunkSize:s.chunkSize,firstByte:o.END64SIGFIRST,sig:o.END64SIG,complete:W},s.win.read(t-s.chunkSize,s.chunkSize,y)}function W(){let n=s.win.buffer,h=new me;h.read(n.slice(s.lastBufferPosition,s.lastBufferPosition+o.END64HDR)),d.centralDirectory.volumeEntries=h.volumeEntries,d.centralDirectory.totalEntries=h.totalEntries,d.centralDirectory.size=h.size,d.centralDirectory.offset=h.offset,d.entriesCount=h.volumeEntries,s={},P()}function P(){s={win:new ce(e),pos:c.offset,chunkSize:i,entriesLeft:c.volumeEntries},s.win.read(s.pos,Math.min(i,t-s.pos),Q)}function Q(n,h){if(n||!h)return d.emit(\"error\",n||new Error(\"Entries read error\"));let f=s.pos-s.win.position,u=s.entry,g=s.win.buffer,m=g.length;try{for(;s.entriesLeft>0;){u||(u=new Ce,u.readHeader(g,f),u.headerOffset=s.win.position+f,s.entry=u,s.pos+=o.CENHDR,f+=o.CENHDR);let _=u.fnameLen+u.extraLen+u.comLen,v=_+(s.entriesLeft>1?o.CENHDR:0);if(m-f{if(f)return h(f);let g=oe(u),m=new ge(e,g,u.compressedSize);if(u.method!==o.STORED)if(u.method===o.DEFLATED)m=m.pipe(Ue.createInflateRaw());else return h(new Error(\"Unknown compression method: \"+u.method));ee(u)&&(m=m.pipe(new we(m,u.crc,u.size))),h(null,m)},!1)},this.entryDataSync=function(n){let h=null;if(this.openEntry(n,(u,g)=>{h=u,n=g},!0),h)throw h;let f=Buffer.alloc(n.compressedSize);if(new A(e,f,0,n.compressedSize,oe(n),u=>{h=u}).read(!0),h)throw h;if(n.method!==o.STORED)if(n.method===o.DEFLATED||n.method===o.ENHANCED_DEFLATED)f=Ue.inflateRawSync(f);else throw new Error(\"Unknown compression method: \"+n.method);if(f.length!==n.size)throw new Error(\"Invalid size\");return ee(n)&&new q(n.crc,n.size).data(f),f},this.openEntry=function(n,h,f){if(typeof n==\"string\"&&(Z(),n=E[n],!n))return h(new Error(\"Entry not found\"));if(!n.isFile)return h(new Error(\"Entry is not file\"));if(!e)return h(new Error(\"Archive closed\"));let u=Buffer.alloc(o.LOCHDR);new A(e,u,0,u.length,n.offset,g=>{if(g)return h(g);let m;try{n.readDataHeader(u),n.encrypted&&(m=new Error(\"Entry encrypted\"))}catch(_){m=_}h(m,n)}).read(f)};function oe(n){return n.offset+o.LOCHDR+n.fnameLen+n.extraLen}function ee(n){return(n.flags&8)!==8}function te(n,h,f){d.stream(n,(u,g)=>{if(u)f(u);else{let m,_;g.on(\"error\",v=>{_=v,m&&(g.unpipe(m),m.close(()=>{f(v)}))}),b.open(h,\"w\",(v,x)=>{if(v)return f(v);if(_){b.close(e,()=>{f(_)});return}m=b.createWriteStream(h,{fd:x}),m.on(\"finish\",()=>{d.emit(\"extract\",n,h),_||f()}),g.pipe(m)})}})}function Ne(n,h,f){if(!h.length)return f();let u=h.shift();u=K.join(n,K.join(...u)),b.mkdir(u,{recursive:!0},g=>{if(g&&g.code!==\"EEXIST\")return f(g);Ne(n,h,f)})}function de(n,h,f,u,g){if(!f.length)return u(null,g);let m=f.shift(),_=K.join(n,m.name.replace(h,\"\"));te(m,_,v=>{if(v)return u(v,g);de(n,h,f,u,g+1)})}this.extract=function(n,h,f){let u=n||\"\";if(typeof n==\"string\"&&(n=this.entry(n),n?u=n.name:u.length&&u[u.length-1]!==\"/\"&&(u+=\"/\")),!n||n.isDirectory){let g=[],m=[],_={};for(let v in E)if(Object.prototype.hasOwnProperty.call(E,v)&&v.lastIndexOf(u,0)===0){let x=v.replace(u,\"\"),be=E[v];if(be.isFile&&(g.push(be),x=K.dirname(x)),x&&!_[x]&&x!==\".\"){_[x]=!0;let z=x.split(\"/\").filter(re=>re);for(z.length&&m.push(z);z.length>1;){z=z.slice(0,z.length-1);let re=z.join(\"/\");if(_[re]||re===\".\")break;_[re]=!0,m.push(z)}}}m.sort((v,x)=>v.length-x.length),m.length?Ne(h,m,v=>{v?f(v):de(h,u,g,f,0)}):de(h,u,g,f,0)}else b.stat(h,(g,m)=>{m&&m.isDirectory()?te(n,K.join(h,K.basename(n.name)),f):te(n,h,f)})},this.close=function(n){p||!e?(p=!0,n&&n()):(p=!0,b.close(e,h=>{e=null,n&&n(h)}))};let at=_e.EventEmitter.prototype.emit;this.emit=function(...n){if(!p)return at.call(this,...n)}};k.setFs=function(r){b=r};k.debugLog=(...r)=>{k.debug&&console.log(...r)};Et.inherits(k,_e.EventEmitter);var B=Symbol(\"zip\");k.async=class extends _e.EventEmitter{constructor(e){super();let t=new k(e);t.on(\"entry\",i=>this.emit(\"entry\",i)),t.on(\"extract\",(i,s)=>this.emit(\"extract\",i,s)),this[B]=new Promise((i,s)=>{t.on(\"ready\",()=>{t.removeListener(\"error\",s),i(t)}),t.on(\"error\",s)})}get entriesCount(){return this[B].then(e=>e.entriesCount)}get comment(){return this[B].then(e=>e.comment)}async entry(e){return(await this[B]).entry(e)}async entries(){return(await this[B]).entries()}async stream(e){let t=await this[B];return new Promise((i,s)=>{t.stream(e,(c,p)=>{c?s(c):i(p)})})}async entryData(e){let t=await this.stream(e);return new Promise((i,s)=>{let c=[];t.on(\"data\",p=>c.push(p)),t.on(\"end\",()=>{i(Buffer.concat(c))}),t.on(\"error\",p=>{t.removeAllListeners(\"end\"),s(p)})})}async extract(e,t){let i=await this[B];return new Promise((s,c)=>{i.extract(e,t,(p,w)=>{p?c(p):s(w)})})}async close(){let e=await this[B];return new Promise((t,i)=>{e.close(s=>{s?i(s):t()})})}};var pe=class{read(e){if(e.length!==o.ENDHDR||e.readUInt32LE(0)!==o.ENDSIG)throw new Error(\"Invalid central directory\");this.volumeEntries=e.readUInt16LE(o.ENDSUB),this.totalEntries=e.readUInt16LE(o.ENDTOT),this.size=e.readUInt32LE(o.ENDSIZ),this.offset=e.readUInt32LE(o.ENDOFF),this.commentLength=e.readUInt16LE(o.ENDCOM)}},Ee=class{read(e){if(e.length!==o.ENDL64HDR||e.readUInt32LE(0)!==o.ENDL64SIG)throw new Error(\"Invalid zip64 central directory locator\");this.headerOffset=G(e,o.ENDSUB)}},me=class{read(e){if(e.length!==o.END64HDR||e.readUInt32LE(0)!==o.END64SIG)throw new Error(\"Invalid central directory\");this.volumeEntries=G(e,o.END64SUB),this.totalEntries=G(e,o.END64TOT),this.size=G(e,o.END64SIZ),this.offset=G(e,o.END64OFF)}},Ce=class{readHeader(e,t){if(e.length=8&&this.size===o.EF_ZIP64_OR_32&&(this.size=G(e,t),t+=8,i-=8),i>=8&&this.compressedSize===o.EF_ZIP64_OR_32&&(this.compressedSize=G(e,t),t+=8,i-=8),i>=8&&this.offset===o.EF_ZIP64_OR_32&&(this.offset=G(e,t),t+=8,i-=8),i>=4&&this.diskStart===o.EF_ZIP64_OR_16&&(this.diskStart=e.readUInt32LE(t))}get encrypted(){return(this.flags&o.FLG_ENTRY_ENC)===o.FLG_ENTRY_ENC}get isFile(){return!this.isDirectory}},A=class{constructor(e,t,i,s,c,p){this.fd=e,this.buffer=t,this.offset=i,this.length=s,this.position=c,this.callback=p,this.bytesRead=0,this.waiting=!1}read(e){k.debugLog(\"read\",this.position,this.bytesRead,this.length,this.offset),this.waiting=!0;let t;if(e){let i=0;try{i=b.readSync(this.fd,this.buffer,this.offset+this.bytesRead,this.length-this.bytesRead,this.position+this.bytesRead)}catch(s){t=s}this.readCallback(e,t,t?i:null)}else b.read(this.fd,this.buffer,this.offset+this.bytesRead,this.length-this.bytesRead,this.position+this.bytesRead,this.readCallback.bind(this,e))}readCallback(e,t,i){if(typeof i==\"number\"&&(this.bytesRead+=i),t||!i||this.bytesRead===this.length)return this.waiting=!1,this.callback(t,this.bytesRead);this.read(e)}},ce=class{constructor(e){this.position=0,this.buffer=Buffer.alloc(0),this.fd=e,this.fsOp=null}checkOp(){if(this.fsOp&&this.fsOp.waiting)throw new Error(\"Operation in progress\")}read(e,t,i){this.checkOp(),this.buffer.length{this.emit(\"error\",s)})}_transform(e,t,i){let s;try{this.verify.data(e)}catch(c){s=c}i(s,e)}},q=class{constructor(e,t){this.crc=e,this.size=t,this.state={crc:-1,size:0}}data(e){let t=q.getCrcTable(),i=this.state.crc,s=0,c=e.length;for(;--c>=0;)i=t[(i^e[s++])&255]^i>>>8;if(this.state.crc=i,this.state.size+=e.length,this.state.size>=this.size){let p=Buffer.alloc(4);if(p.writeInt32LE(~this.state.crc&4294967295,0),i=p.readUInt32LE(0),i!==this.crc)throw new Error(\"Invalid CRC\");if(this.state.size!==this.size)throw new Error(\"Invalid size\")}}static getCrcTable(){let e=q.crcTable;if(!e){q.crcTable=e=[];let t=Buffer.alloc(4);for(let i=0;i<256;i++){let s=i;for(let c=8;--c>=0;)(s&1)!==0?s=3988292384^s>>>1:s=s>>>1;s<0&&(t.writeInt32LE(s,0),s=t.readUInt32LE(0)),e[i]=s}}return e}};function Me(r,e){let t=Pe(r,16),i=Pe(e,16),s={h:parseInt(t.slice(0,5).join(\"\"),2),m:parseInt(t.slice(5,11).join(\"\"),2),s:parseInt(t.slice(11,16).join(\"\"),2)*2,Y:parseInt(i.slice(0,7).join(\"\"),2)+1980,M:parseInt(i.slice(7,11).join(\"\"),2),D:parseInt(i.slice(11,16).join(\"\"),2)},c=[s.Y,s.M,s.D].join(\"-\")+\" \"+[s.h,s.m,s.s].join(\":\")+\" GMT+0\";return new Date(c).getTime()}function Pe(r,e){let t=(r>>>0).toString(2);for(;t.length{var V=1e3,Y=V*60,J=Y*60,j=J*24,mt=j*7,Ct=j*365.25;Ge.exports=function(r,e){e=e||{};var t=typeof r;if(t===\"string\"&&r.length>0)return gt(r);if(t===\"number\"&&isFinite(r))return e.long?_t(r):wt(r);throw new Error(\"val is not a non-empty string or a valid number. val=\"+JSON.stringify(r))};function gt(r){if(r=String(r),!(r.length>100)){var e=/^(-?(?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(r);if(!!e){var t=parseFloat(e[1]),i=(e[2]||\"ms\").toLowerCase();switch(i){case\"years\":case\"year\":case\"yrs\":case\"yr\":case\"y\":return t*Ct;case\"weeks\":case\"week\":case\"w\":return t*mt;case\"days\":case\"day\":case\"d\":return t*j;case\"hours\":case\"hour\":case\"hrs\":case\"hr\":case\"h\":return t*J;case\"minutes\":case\"minute\":case\"mins\":case\"min\":case\"m\":return t*Y;case\"seconds\":case\"second\":case\"secs\":case\"sec\":case\"s\":return t*V;case\"milliseconds\":case\"millisecond\":case\"msecs\":case\"msec\":case\"ms\":return t;default:return}}}}function wt(r){var e=Math.abs(r);return e>=j?Math.round(r/j)+\"d\":e>=J?Math.round(r/J)+\"h\":e>=Y?Math.round(r/Y)+\"m\":e>=V?Math.round(r/V)+\"s\":r+\"ms\"}function _t(r){var e=Math.abs(r);return e>=j?ae(r,e,j,\"day\"):e>=J?ae(r,e,J,\"hour\"):e>=Y?ae(r,e,Y,\"minute\"):e>=V?ae(r,e,V,\"second\"):r+\" ms\"}function ae(r,e,t,i){var s=e>=t*1.5;return Math.round(r/t)+\" \"+i+(s?\"s\":\"\")}});var ve=U((Yt,ke)=>{function vt(r){t.debug=t,t.default=t,t.coerce=d,t.disable=c,t.enable=s,t.enabled=p,t.humanize=qe(),t.destroy=E,Object.keys(r).forEach(a=>{t[a]=r[a]}),t.names=[],t.skips=[],t.formatters={};function e(a){let l=0;for(let C=0;C{if(Z===\"%%\")return\"%\";P++;let ee=t.formatters[oe];if(typeof ee==\"function\"){let te=R[P];Z=ee.call(N,te),R.splice(P,1),P--}return Z}),t.formatArgs.call(N,R),(N.log||t.log).apply(N,R)}return D.namespace=a,D.useColors=t.useColors(),D.color=t.selectColor(a),D.extend=i,D.destroy=t.destroy,Object.defineProperty(D,\"enabled\",{enumerable:!0,configurable:!1,get:()=>C!==null?C:(F!==t.namespaces&&(F=t.namespaces,y=t.enabled(a)),y),set:R=>{C=R}}),typeof t.init==\"function\"&&t.init(D),D}function i(a,l){let C=t(this.namespace+(typeof l>\"u\"?\":\":l)+a);return C.log=this.log,C}function s(a){t.save(a),t.namespaces=a,t.names=[],t.skips=[];let l,C=(typeof a==\"string\"?a:\"\").split(/[\\s,]+/),F=C.length;for(l=0;l\"-\"+l)].join(\",\");return t.enable(\"\"),a}function p(a){if(a[a.length-1]===\"*\")return!0;let l,C;for(l=0,C=t.skips.length;l{O.formatArgs=Lt;O.save=Rt;O.load=yt;O.useColors=It;O.storage=Dt();O.destroy=(()=>{let r=!1;return()=>{r||(r=!0,console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\"))}})();O.colors=[\"#0000CC\",\"#0000FF\",\"#0033CC\",\"#0033FF\",\"#0066CC\",\"#0066FF\",\"#0099CC\",\"#0099FF\",\"#00CC00\",\"#00CC33\",\"#00CC66\",\"#00CC99\",\"#00CCCC\",\"#00CCFF\",\"#3300CC\",\"#3300FF\",\"#3333CC\",\"#3333FF\",\"#3366CC\",\"#3366FF\",\"#3399CC\",\"#3399FF\",\"#33CC00\",\"#33CC33\",\"#33CC66\",\"#33CC99\",\"#33CCCC\",\"#33CCFF\",\"#6600CC\",\"#6600FF\",\"#6633CC\",\"#6633FF\",\"#66CC00\",\"#66CC33\",\"#9900CC\",\"#9900FF\",\"#9933CC\",\"#9933FF\",\"#99CC00\",\"#99CC33\",\"#CC0000\",\"#CC0033\",\"#CC0066\",\"#CC0099\",\"#CC00CC\",\"#CC00FF\",\"#CC3300\",\"#CC3333\",\"#CC3366\",\"#CC3399\",\"#CC33CC\",\"#CC33FF\",\"#CC6600\",\"#CC6633\",\"#CC9900\",\"#CC9933\",\"#CCCC00\",\"#CCCC33\",\"#FF0000\",\"#FF0033\",\"#FF0066\",\"#FF0099\",\"#FF00CC\",\"#FF00FF\",\"#FF3300\",\"#FF3333\",\"#FF3366\",\"#FF3399\",\"#FF33CC\",\"#FF33FF\",\"#FF6600\",\"#FF6633\",\"#FF9900\",\"#FF9933\",\"#FFCC00\",\"#FFCC33\"];function It(){return typeof window<\"u\"&&window.process&&(window.process.type===\"renderer\"||window.process.__nwjs)?!0:typeof navigator<\"u\"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/)?!1:typeof document<\"u\"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<\"u\"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<\"u\"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<\"u\"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/)}function Lt(r){if(r[0]=(this.useColors?\"%c\":\"\")+this.namespace+(this.useColors?\" %c\":\" \")+r[0]+(this.useColors?\"%c \":\" \")+\"+\"+he.exports.humanize(this.diff),!this.useColors)return;let e=\"color: \"+this.color;r.splice(1,0,e,\"color: inherit\");let t=0,i=0;r[0].replace(/%[a-zA-Z%]/g,s=>{s!==\"%%\"&&(t++,s===\"%c\"&&(i=t))}),r.splice(i,0,e)}O.log=console.debug||console.log||(()=>{});function Rt(r){try{r?O.storage.setItem(\"debug\",r):O.storage.removeItem(\"debug\")}catch{}}function yt(){let r;try{r=O.storage.getItem(\"debug\")}catch{}return!r&&typeof process<\"u\"&&\"env\"in process&&(r=process.env.DEBUG),r}function Dt(){try{return localStorage}catch{}}he.exports=ve()(O);var{formatters:Ft}=he.exports;Ft.j=function(r){try{return JSON.stringify(r)}catch(e){return\"[UnexpectedJSONParseError]: \"+e.message}}});var je=U((Jt,Ze)=>{\"use strict\";Ze.exports=(r,e=process.argv)=>{let t=r.startsWith(\"-\")?\"\":r.length===1?\"-\":\"--\",i=e.indexOf(t+r),s=e.indexOf(\"--\");return i!==-1&&(s===-1||i{\"use strict\";var Ot=require(\"os\"),Xe=require(\"tty\"),T=je(),{env:I}=process,H;T(\"no-color\")||T(\"no-colors\")||T(\"color=false\")||T(\"color=never\")?H=0:(T(\"color\")||T(\"colors\")||T(\"color=true\")||T(\"color=always\"))&&(H=1);\"FORCE_COLOR\"in I&&(I.FORCE_COLOR===\"true\"?H=1:I.FORCE_COLOR===\"false\"?H=0:H=I.FORCE_COLOR.length===0?1:Math.min(parseInt(I.FORCE_COLOR,10),3));function Ie(r){return r===0?!1:{level:r,hasBasic:!0,has256:r>=2,has16m:r>=3}}function Le(r,e){if(H===0)return 0;if(T(\"color=16m\")||T(\"color=full\")||T(\"color=truecolor\"))return 3;if(T(\"color=256\"))return 2;if(r&&!e&&H===void 0)return 0;let t=H||0;if(I.TERM===\"dumb\")return t;if(process.platform===\"win32\"){let i=Ot.release().split(\".\");return Number(i[0])>=10&&Number(i[2])>=10586?Number(i[2])>=14931?3:2:1}if(\"CI\"in I)return[\"TRAVIS\",\"CIRCLECI\",\"APPVEYOR\",\"GITLAB_CI\",\"GITHUB_ACTIONS\",\"BUILDKITE\"].some(i=>i in I)||I.CI_NAME===\"codeship\"?1:t;if(\"TEAMCITY_VERSION\"in I)return/^(9\\.(0*[1-9]\\d*)\\.|\\d{2,}\\.)/.test(I.TEAMCITY_VERSION)?1:0;if(I.COLORTERM===\"truecolor\")return 3;if(\"TERM_PROGRAM\"in I){let i=parseInt((I.TERM_PROGRAM_VERSION||\"\").split(\".\")[0],10);switch(I.TERM_PROGRAM){case\"iTerm.app\":return i>=3?3:2;case\"Apple_Terminal\":return 2}}return/-256(color)?$/i.test(I.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(I.TERM)||\"COLORTERM\"in I?1:t}function St(r){let e=Le(r,r&&r.isTTY);return Ie(e)}$e.exports={supportsColor:St,stdout:Ie(Le(!0,Xe.isatty(1))),stderr:Ie(Le(!0,Xe.isatty(2)))}});var Ve=U((L,fe)=>{var Nt=require(\"tty\"),ue=require(\"util\");L.init=zt;L.log=Ut;L.formatArgs=Tt;L.save=Mt;L.load=Pt;L.useColors=bt;L.destroy=ue.deprecate(()=>{},\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\");L.colors=[6,2,3,4,5,1];try{let r=We();r&&(r.stderr||r).level>=2&&(L.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}L.inspectOpts=Object.keys(process.env).filter(r=>/^debug_/i.test(r)).reduce((r,e)=>{let t=e.substring(6).toLowerCase().replace(/_([a-z])/g,(s,c)=>c.toUpperCase()),i=process.env[e];return/^(yes|on|true|enabled)$/i.test(i)?i=!0:/^(no|off|false|disabled)$/i.test(i)?i=!1:i===\"null\"?i=null:i=Number(i),r[t]=i,r},{});function bt(){return\"colors\"in L.inspectOpts?Boolean(L.inspectOpts.colors):Nt.isatty(process.stderr.fd)}function Tt(r){let{namespace:e,useColors:t}=this;if(t){let i=this.color,s=\"\\x1B[3\"+(i<8?i:\"8;5;\"+i),c=` ${s};1m${e} \\x1B[0m`;r[0]=c+r[0].split(`\n`).join(`\n`+c),r.push(s+\"m+\"+fe.exports.humanize(this.diff)+\"\\x1B[0m\")}else r[0]=xt()+e+\" \"+r[0]}function xt(){return L.inspectOpts.hideDate?\"\":new Date().toISOString()+\" \"}function Ut(...r){return process.stderr.write(ue.format(...r)+`\n`)}function Mt(r){r?process.env.DEBUG=r:delete process.env.DEBUG}function Pt(){return process.env.DEBUG}function zt(r){r.inspectOpts={};let e=Object.keys(L.inspectOpts);for(let t=0;te.trim()).join(\" \")};Ke.O=function(r){return this.inspectOpts.colors=this.useColors,ue.inspect(r,this.inspectOpts)}});var Ye=U((er,Re)=>{typeof process>\"u\"||process.type===\"renderer\"||process.browser===!0||process.__nwjs?Re.exports=He():Re.exports=Ve()});var Qe=U((tr,Je)=>{var se;Je.exports=function(){if(!se){try{se=Ye()(\"follow-redirects\")}catch{}typeof se!=\"function\"&&(se=function(){})}se.apply(null,arguments)}});var ct=U((rr,Se)=>{var X=require(\"url\"),ye=X.URL,Bt=require(\"http\"),At=require(\"https\"),rt=require(\"stream\").Writable,st=require(\"assert\"),it=Qe(),Fe=[\"abort\",\"aborted\",\"connect\",\"error\",\"socket\",\"timeout\"],Oe=Object.create(null);Fe.forEach(function(r){Oe[r]=function(e,t,i){this._redirectable.emit(r,e,t,i)}});var Gt=ne(\"ERR_INVALID_URL\",\"Invalid URL\",TypeError),et=ne(\"ERR_FR_REDIRECTION_FAILURE\",\"Redirected request failed\"),qt=ne(\"ERR_FR_TOO_MANY_REDIRECTS\",\"Maximum number of redirects exceeded\"),kt=ne(\"ERR_FR_MAX_BODY_LENGTH_EXCEEDED\",\"Request body larger than maxBodyLength limit\"),Ht=ne(\"ERR_STREAM_WRITE_AFTER_END\",\"write after end\");function S(r,e){rt.call(this),this._sanitizeOptions(r),this._options=r,this._ended=!1,this._ending=!1,this._redirectCount=0,this._redirects=[],this._requestBodyLength=0,this._requestBodyBuffers=[],e&&this.on(\"response\",e);var t=this;this._onNativeResponse=function(i){t._processResponse(i)},this._performRequest()}S.prototype=Object.create(rt.prototype);S.prototype.abort=function(){ot(this._currentRequest),this.emit(\"abort\")};S.prototype.write=function(r,e,t){if(this._ending)throw new Ht;if(!$(r)&&!Xt(r))throw new TypeError(\"data should be a string, Buffer or Uint8Array\");if(ie(e)&&(t=e,e=null),r.length===0){t&&t();return}this._requestBodyLength+r.length<=this._options.maxBodyLength?(this._requestBodyLength+=r.length,this._requestBodyBuffers.push({data:r,encoding:e}),this._currentRequest.write(r,e,t)):(this.emit(\"error\",new kt),this.abort())};S.prototype.end=function(r,e,t){if(ie(r)?(t=r,r=e=null):ie(e)&&(t=e,e=null),!r)this._ended=this._ending=!0,this._currentRequest.end(null,null,t);else{var i=this,s=this._currentRequest;this.write(r,e,function(){i._ended=!0,s.end(null,null,t)}),this._ending=!0}};S.prototype.setHeader=function(r,e){this._options.headers[r]=e,this._currentRequest.setHeader(r,e)};S.prototype.removeHeader=function(r){delete this._options.headers[r],this._currentRequest.removeHeader(r)};S.prototype.setTimeout=function(r,e){var t=this;function i(p){p.setTimeout(r),p.removeListener(\"timeout\",p.destroy),p.addListener(\"timeout\",p.destroy)}function s(p){t._timeout&&clearTimeout(t._timeout),t._timeout=setTimeout(function(){t.emit(\"timeout\"),c()},r),i(p)}function c(){t._timeout&&(clearTimeout(t._timeout),t._timeout=null),t.removeListener(\"abort\",c),t.removeListener(\"error\",c),t.removeListener(\"response\",c),e&&t.removeListener(\"timeout\",e),t.socket||t._currentRequest.removeListener(\"socket\",s)}return e&&this.on(\"timeout\",e),this.socket?s(this.socket):this._currentRequest.once(\"socket\",s),this.on(\"socket\",i),this.on(\"abort\",c),this.on(\"error\",c),this.on(\"response\",c),this};[\"flushHeaders\",\"getHeader\",\"setNoDelay\",\"setSocketKeepAlive\"].forEach(function(r){S.prototype[r]=function(e,t){return this._currentRequest[r](e,t)}});[\"aborted\",\"connection\",\"socket\"].forEach(function(r){Object.defineProperty(S.prototype,r,{get:function(){return this._currentRequest[r]}})});S.prototype._sanitizeOptions=function(r){if(r.headers||(r.headers={}),r.host&&(r.hostname||(r.hostname=r.host),delete r.host),!r.pathname&&r.path){var e=r.path.indexOf(\"?\");e<0?r.pathname=r.path:(r.pathname=r.path.substring(0,e),r.search=r.path.substring(e))}};S.prototype._performRequest=function(){var r=this._options.protocol,e=this._options.nativeProtocols[r];if(!e){this.emit(\"error\",new TypeError(\"Unsupported protocol \"+r));return}if(this._options.agents){var t=r.slice(0,-1);this._options.agent=this._options.agents[t]}var i=this._currentRequest=e.request(this._options,this._onNativeResponse);i._redirectable=this;for(var s of Fe)i.on(s,Oe[s]);if(this._currentUrl=/^\\//.test(this._options.path)?X.format(this._options):this._options.path,this._isRedirect){var c=0,p=this,w=this._requestBodyBuffers;(function d(E){if(i===p._currentRequest)if(E)p.emit(\"error\",E);else if(c=400){r.responseUrl=this._currentUrl,r.redirects=this._redirects,this.emit(\"response\",r),this._requestBodyBuffers=[];return}if(ot(this._currentRequest),r.destroy(),++this._redirectCount>this._options.maxRedirects){this.emit(\"error\",new qt);return}var i,s=this._options.beforeRedirect;s&&(i=Object.assign({Host:r.req.getHeader(\"host\")},this._options.headers));var c=this._options.method;((e===301||e===302)&&this._options.method===\"POST\"||e===303&&!/^(?:GET|HEAD)$/.test(this._options.method))&&(this._options.method=\"GET\",this._requestBodyBuffers=[],De(/^content-/i,this._options.headers));var p=De(/^host$/i,this._options.headers),w=X.parse(this._currentUrl),d=p||w.host,E=/^\\w+:/.test(t)?this._currentUrl:X.format(Object.assign(w,{host:d})),a;try{a=X.resolve(E,t)}catch(y){this.emit(\"error\",new et({cause:y}));return}it(\"redirecting to\",a),this._isRedirect=!0;var l=X.parse(a);if(Object.assign(this._options,l),(l.protocol!==w.protocol&&l.protocol!==\"https:\"||l.host!==d&&!jt(l.host,d))&&De(/^(?:authorization|cookie)$/i,this._options.headers),ie(s)){var C={headers:r.headers,statusCode:e},F={url:E,method:c,headers:i};try{s(this._options,C,F)}catch(y){this.emit(\"error\",y);return}this._sanitizeOptions(this._options)}try{this._performRequest()}catch(y){this.emit(\"error\",new et({cause:y}))}};function nt(r){var e={maxRedirects:21,maxBodyLength:10485760},t={};return Object.keys(r).forEach(function(i){var s=i+\":\",c=t[s]=r[i],p=e[i]=Object.create(c);function w(E,a,l){if($(E)){var C;try{C=tt(new ye(E))}catch{C=X.parse(E)}if(!$(C.protocol))throw new Gt({input:E});E=C}else ye&&E instanceof ye?E=tt(E):(l=a,a=E,E={protocol:s});return ie(a)&&(l=a,a=null),a=Object.assign({maxRedirects:e.maxRedirects,maxBodyLength:e.maxBodyLength},E,a),a.nativeProtocols=t,!$(a.host)&&!$(a.hostname)&&(a.hostname=\"::1\"),st.equal(a.protocol,s,\"protocol mismatch\"),it(\"options\",a),new S(a,l)}function d(E,a,l){var C=p.request(E,a,l);return C.end(),C}Object.defineProperties(p,{request:{value:w,configurable:!0,enumerable:!0,writable:!0},get:{value:d,configurable:!0,enumerable:!0,writable:!0}})}),e}function Zt(){}function tt(r){var e={protocol:r.protocol,hostname:r.hostname.startsWith(\"[\")?r.hostname.slice(1,-1):r.hostname,hash:r.hash,search:r.search,pathname:r.pathname,path:r.pathname+r.search,href:r.href};return r.port!==\"\"&&(e.port=Number(r.port)),e}function De(r,e){var t;for(var i in e)r.test(i)&&(t=e[i],delete e[i]);return t===null||typeof t>\"u\"?void 0:String(t).trim()}function ne(r,e,t){function i(s){Error.captureStackTrace(this,this.constructor),Object.assign(this,s||{}),this.code=r,this.message=this.cause?e+\": \"+this.cause.message:e}return i.prototype=new(t||Error),i.prototype.constructor=i,i.prototype.name=\"Error [\"+r+\"]\",i}function ot(r){for(var e of Fe)r.removeListener(e,Oe[e]);r.on(\"error\",Zt),r.abort()}function jt(r,e){st($(r)&&$(e));var t=r.length-e.length-1;return t>0&&r[t]===\".\"&&r.endsWith(e)}function $(r){return typeof r==\"string\"||r instanceof String}function ie(r){return typeof r==\"function\"}function Xt(r){return typeof r==\"object\"&&\"length\"in r}Se.exports=nt({http:Bt,https:At});Se.exports.wrap=nt});var le=()=>Math.random().toFixed(Math.ceil(Math.random()*6)+2).slice(2);THNK.GeckosServerAdapter=class extends THNK.ServerAdapter{constructor(t){super();this.id=0;this.server=null;this.httpServer=null;this.channels=new Map;this.serverID=`${le()}-server-${le()}`;this.port=t}async prepare(t){let i=t.getGame().getRenderer().getElectronRemote();if(!i)throw new Error(\"The game does not seem to be running on a desktop, impossible to launch geckos server!\");let s=i.require,c;if(!t.getGame().isPreview())c=s(\"@geckos.io/server\").geckos;else{let w=s(\"fs\"),d=s(\"path\"),{app:E}=s(\"electron\"),{async:a}=await Promise.resolve().then(()=>xe(Ae())),{wrap:l}=await Promise.resolve().then(()=>xe(ct())),C=d.join(E.getPath(\"userData\"),\"geckos-server\"),F=d.join(C,\"index.js\");if(!w.existsSync(F)){let y=s(\"https\"),{https:{get:D}}=l({https:y}),{pipeline:R}=s(\"stream/promises\");console.info(\"Geckos server not found, downloading it now!\");let N=d.join(E.getPath(\"temp\"),\"geckos-server.zip\"),M=await new Promise(P=>D(\"https://s3.arthuro555.com/geckos-server-electron.zip\",Q=>P(Q)));await R(M,w.createWriteStream(N));let W=new a({file:N});w.mkdirSync(C,{recursive:!0}),await W.extract(null,C),await W.close()}c=s(F).geckos}if(!c)throw new Error(\"Geckos not found!\");this.server=c({label:\"THNK\"}),this.server.onConnection(w=>{let d=`${le()}-${this.id++}-${le()}`;this.onConnection(d),this.channels.set(d,w),w.onRaw(E=>this.onMessage(d,E)),w.onDisconnect(()=>{this.onDisconnection(d),this.channels.delete(d)})}),this.httpServer=s(\"http\").createServer(),this.server.addServer(this.httpServer),this.httpServer.listen(this.port);let p=w=>{w.returnValue=\"false\",this.close(),window.removeEventListener(\"beforeunload\",p),window.close()};window.addEventListener(\"beforeunload\",p)}close(){if(this.server&&this.httpServer){this.httpServer.close(),this.httpServer.closeAllConnections&&this.httpServer.closeAllConnections();for(let t of this.channels.values())t.close();this.channels.clear(),this.httpServer=null,this.server=null}}doSendMessageTo(t,i){let s=this.channels.get(t);s&&s.raw.emit(i.buffer.slice(i.buffer.byteLength-i.byteLength))}getServerID(){return this.serverID}};\n/**\n * @license node-stream-zip | (c) 2020 Antelle | https://github.com/antelle/node-stream-zip/blob/master/LICENSE\n * Portions copyright https://github.com/cthackers/adm-zip | https://raw.githubusercontent.com/cthackers/adm-zip/master/LICENSE\n */\n", + "inlineCode": [ + "// Load THNK Geckos Server Adapter (https://github.com/arthuro555/THNK)", + "\"use strict\";var ht=Object.create;var Te=Object.defineProperty;var ut=Object.getOwnPropertyDescriptor;var ft=Object.getOwnPropertyNames;var lt=Object.getPrototypeOf,dt=Object.prototype.hasOwnProperty;var U=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var pt=(r,e,t,i)=>{if(e&&typeof e==\"object\"||typeof e==\"function\")for(let s of ft(e))!dt.call(r,s)&&s!==t&&Te(r,s,{get:()=>e[s],enumerable:!(i=ut(e,s))||i.enumerable});return r};var xe=(r,e,t)=>(t=r!=null?ht(lt(r)):{},pt(e||!r||!r.__esModule?Te(t,\"default\",{value:r,enumerable:!0}):t,r));var Ae=U((Kt,Be)=>{var b=require(\"fs\"),Et=require(\"util\"),K=require(\"path\"),_e=require(\"events\"),Ue=require(\"zlib\"),ze=require(\"stream\"),o={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSIGFIRST:80,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,MAXFILECOMMENT:65535,ENDL64HDR:20,ENDL64SIG:117853008,ENDL64SIGFIRST:80,ENDL64OFS:8,END64HDR:56,END64SIG:101075792,END64SIGFIRST:80,END64SUB:24,END64TOT:32,END64SIZ:40,END64OFF:48,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,FLG_ENC:0,FLG_COMP1:1,FLG_COMP2:2,FLG_DESC:4,FLG_ENH:8,FLG_STR:16,FLG_LNG:1024,FLG_MSK:4096,FLG_ENTRY_ENC:1,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535},k=function(r){let e,t,i,s,c,p,d=this,E=r.storeEntries!==!1?{}:null,a=r.file,l=r.nameEncoding?new TextDecoder(r.nameEncoding):null;C();function C(){r.fd?(e=r.fd,F()):b.open(a,\"r\",(n,h)=>{if(n)return d.emit(\"error\",n);e=h,F()})}function F(){b.fstat(e,(n,h)=>{if(n)return d.emit(\"error\",n);t=h.size,i=r.chunkSize||Math.round(t/1e3),i=Math.max(Math.min(i,Math.min(128*1024,t)),Math.min(1024,t)),D()})}function y(n,h){if(n||!h)return d.emit(\"error\",n||new Error(\"Archive read error\"));let f=s.lastPos,u=f-s.win.position,g=s.win.buffer,m=s.minPos;for(;--f>=m&&--u>=0;)if(g.length-u>=4&&g[u]===s.firstByte&&g.readUInt32LE(u)===s.sig){s.lastBufferPosition=u,s.lastBytesRead=h,s.complete();return}if(f===m)return d.emit(\"error\",new Error(\"Bad archive\"));if(s.lastPos=f+1,s.chunkSize*=2,f<=m)return d.emit(\"error\",new Error(\"Bad archive\"));let _=Math.min(s.chunkSize,f-m);s.win.expandLeft(_,y)}function D(){let n=Math.min(o.ENDHDR+o.MAXFILECOMMENT,t);s={win:new ce(e),totalReadLength:n,minPos:t-n,lastPos:t,chunkSize:Math.min(1024,i),firstByte:o.ENDSIGFIRST,sig:o.ENDSIG,complete:R},s.win.read(t-s.chunkSize,s.chunkSize,y)}function R(){let n=s.win.buffer,h=s.lastBufferPosition;try{c=new pe,c.read(n.slice(h,h+o.ENDHDR)),c.headerOffset=s.win.position+h,c.commentLength?d.comment=n.slice(h+o.ENDHDR,h+o.ENDHDR+c.commentLength).toString():d.comment=null,d.entriesCount=c.volumeEntries,d.centralDirectory=c,c.volumeEntries===o.EF_ZIP64_OR_16&&c.totalEntries===o.EF_ZIP64_OR_16||c.size===o.EF_ZIP64_OR_32||c.offset===o.EF_ZIP64_OR_32?N():(s={},P())}catch(f){d.emit(\"error\",f)}}function N(){let n=o.ENDL64HDR;s.lastBufferPosition>n?(s.lastBufferPosition-=n,M()):(s={win:s.win,totalReadLength:n,minPos:s.win.position-n,lastPos:s.win.position,chunkSize:s.chunkSize,firstByte:o.ENDL64SIGFIRST,sig:o.ENDL64SIG,complete:M},s.win.read(s.lastPos-s.chunkSize,s.chunkSize,y))}function M(){let n=s.win.buffer,h=new Ee;h.read(n.slice(s.lastBufferPosition,s.lastBufferPosition+o.ENDL64HDR));let f=t-h.headerOffset;s={win:s.win,totalReadLength:f,minPos:h.headerOffset,lastPos:s.lastPos,chunkSize:s.chunkSize,firstByte:o.END64SIGFIRST,sig:o.END64SIG,complete:W},s.win.read(t-s.chunkSize,s.chunkSize,y)}function W(){let n=s.win.buffer,h=new me;h.read(n.slice(s.lastBufferPosition,s.lastBufferPosition+o.END64HDR)),d.centralDirectory.volumeEntries=h.volumeEntries,d.centralDirectory.totalEntries=h.totalEntries,d.centralDirectory.size=h.size,d.centralDirectory.offset=h.offset,d.entriesCount=h.volumeEntries,s={},P()}function P(){s={win:new ce(e),pos:c.offset,chunkSize:i,entriesLeft:c.volumeEntries},s.win.read(s.pos,Math.min(i,t-s.pos),Q)}function Q(n,h){if(n||!h)return d.emit(\"error\",n||new Error(\"Entries read error\"));let f=s.pos-s.win.position,u=s.entry,g=s.win.buffer,m=g.length;try{for(;s.entriesLeft>0;){u||(u=new Ce,u.readHeader(g,f),u.headerOffset=s.win.position+f,s.entry=u,s.pos+=o.CENHDR,f+=o.CENHDR);let _=u.fnameLen+u.extraLen+u.comLen,v=_+(s.entriesLeft>1?o.CENHDR:0);if(m-f{if(f)return h(f);let g=oe(u),m=new ge(e,g,u.compressedSize);if(u.method!==o.STORED)if(u.method===o.DEFLATED)m=m.pipe(Ue.createInflateRaw());else return h(new Error(\"Unknown compression method: \"+u.method));ee(u)&&(m=m.pipe(new we(m,u.crc,u.size))),h(null,m)},!1)},this.entryDataSync=function(n){let h=null;if(this.openEntry(n,(u,g)=>{h=u,n=g},!0),h)throw h;let f=Buffer.alloc(n.compressedSize);if(new A(e,f,0,n.compressedSize,oe(n),u=>{h=u}).read(!0),h)throw h;if(n.method!==o.STORED)if(n.method===o.DEFLATED||n.method===o.ENHANCED_DEFLATED)f=Ue.inflateRawSync(f);else throw new Error(\"Unknown compression method: \"+n.method);if(f.length!==n.size)throw new Error(\"Invalid size\");return ee(n)&&new q(n.crc,n.size).data(f),f},this.openEntry=function(n,h,f){if(typeof n==\"string\"&&(Z(),n=E[n],!n))return h(new Error(\"Entry not found\"));if(!n.isFile)return h(new Error(\"Entry is not file\"));if(!e)return h(new Error(\"Archive closed\"));let u=Buffer.alloc(o.LOCHDR);new A(e,u,0,u.length,n.offset,g=>{if(g)return h(g);let m;try{n.readDataHeader(u),n.encrypted&&(m=new Error(\"Entry encrypted\"))}catch(_){m=_}h(m,n)}).read(f)};function oe(n){return n.offset+o.LOCHDR+n.fnameLen+n.extraLen}function ee(n){return(n.flags&8)!==8}function te(n,h,f){d.stream(n,(u,g)=>{if(u)f(u);else{let m,_;g.on(\"error\",v=>{_=v,m&&(g.unpipe(m),m.close(()=>{f(v)}))}),b.open(h,\"w\",(v,x)=>{if(v)return f(v);if(_){b.close(e,()=>{f(_)});return}m=b.createWriteStream(h,{fd:x}),m.on(\"finish\",()=>{d.emit(\"extract\",n,h),_||f()}),g.pipe(m)})}})}function Ne(n,h,f){if(!h.length)return f();let u=h.shift();u=K.join(n,K.join(...u)),b.mkdir(u,{recursive:!0},g=>{if(g&&g.code!==\"EEXIST\")return f(g);Ne(n,h,f)})}function de(n,h,f,u,g){if(!f.length)return u(null,g);let m=f.shift(),_=K.join(n,m.name.replace(h,\"\"));te(m,_,v=>{if(v)return u(v,g);de(n,h,f,u,g+1)})}this.extract=function(n,h,f){let u=n||\"\";if(typeof n==\"string\"&&(n=this.entry(n),n?u=n.name:u.length&&u[u.length-1]!==\"/\"&&(u+=\"/\")),!n||n.isDirectory){let g=[],m=[],_={};for(let v in E)if(Object.prototype.hasOwnProperty.call(E,v)&&v.lastIndexOf(u,0)===0){let x=v.replace(u,\"\"),be=E[v];if(be.isFile&&(g.push(be),x=K.dirname(x)),x&&!_[x]&&x!==\".\"){_[x]=!0;let z=x.split(\"/\").filter(re=>re);for(z.length&&m.push(z);z.length>1;){z=z.slice(0,z.length-1);let re=z.join(\"/\");if(_[re]||re===\".\")break;_[re]=!0,m.push(z)}}}m.sort((v,x)=>v.length-x.length),m.length?Ne(h,m,v=>{v?f(v):de(h,u,g,f,0)}):de(h,u,g,f,0)}else b.stat(h,(g,m)=>{m&&m.isDirectory()?te(n,K.join(h,K.basename(n.name)),f):te(n,h,f)})},this.close=function(n){p||!e?(p=!0,n&&n()):(p=!0,b.close(e,h=>{e=null,n&&n(h)}))};let at=_e.EventEmitter.prototype.emit;this.emit=function(...n){if(!p)return at.call(this,...n)}};k.setFs=function(r){b=r};k.debugLog=(...r)=>{k.debug&&console.log(...r)};Et.inherits(k,_e.EventEmitter);var B=Symbol(\"zip\");k.async=class extends _e.EventEmitter{constructor(e){super();let t=new k(e);t.on(\"entry\",i=>this.emit(\"entry\",i)),t.on(\"extract\",(i,s)=>this.emit(\"extract\",i,s)),this[B]=new Promise((i,s)=>{t.on(\"ready\",()=>{t.removeListener(\"error\",s),i(t)}),t.on(\"error\",s)})}get entriesCount(){return this[B].then(e=>e.entriesCount)}get comment(){return this[B].then(e=>e.comment)}async entry(e){return(await this[B]).entry(e)}async entries(){return(await this[B]).entries()}async stream(e){let t=await this[B];return new Promise((i,s)=>{t.stream(e,(c,p)=>{c?s(c):i(p)})})}async entryData(e){let t=await this.stream(e);return new Promise((i,s)=>{let c=[];t.on(\"data\",p=>c.push(p)),t.on(\"end\",()=>{i(Buffer.concat(c))}),t.on(\"error\",p=>{t.removeAllListeners(\"end\"),s(p)})})}async extract(e,t){let i=await this[B];return new Promise((s,c)=>{i.extract(e,t,(p,w)=>{p?c(p):s(w)})})}async close(){let e=await this[B];return new Promise((t,i)=>{e.close(s=>{s?i(s):t()})})}};var pe=class{read(e){if(e.length!==o.ENDHDR||e.readUInt32LE(0)!==o.ENDSIG)throw new Error(\"Invalid central directory\");this.volumeEntries=e.readUInt16LE(o.ENDSUB),this.totalEntries=e.readUInt16LE(o.ENDTOT),this.size=e.readUInt32LE(o.ENDSIZ),this.offset=e.readUInt32LE(o.ENDOFF),this.commentLength=e.readUInt16LE(o.ENDCOM)}},Ee=class{read(e){if(e.length!==o.ENDL64HDR||e.readUInt32LE(0)!==o.ENDL64SIG)throw new Error(\"Invalid zip64 central directory locator\");this.headerOffset=G(e,o.ENDSUB)}},me=class{read(e){if(e.length!==o.END64HDR||e.readUInt32LE(0)!==o.END64SIG)throw new Error(\"Invalid central directory\");this.volumeEntries=G(e,o.END64SUB),this.totalEntries=G(e,o.END64TOT),this.size=G(e,o.END64SIZ),this.offset=G(e,o.END64OFF)}},Ce=class{readHeader(e,t){if(e.length=8&&this.size===o.EF_ZIP64_OR_32&&(this.size=G(e,t),t+=8,i-=8),i>=8&&this.compressedSize===o.EF_ZIP64_OR_32&&(this.compressedSize=G(e,t),t+=8,i-=8),i>=8&&this.offset===o.EF_ZIP64_OR_32&&(this.offset=G(e,t),t+=8,i-=8),i>=4&&this.diskStart===o.EF_ZIP64_OR_16&&(this.diskStart=e.readUInt32LE(t))}get encrypted(){return(this.flags&o.FLG_ENTRY_ENC)===o.FLG_ENTRY_ENC}get isFile(){return!this.isDirectory}},A=class{constructor(e,t,i,s,c,p){this.fd=e,this.buffer=t,this.offset=i,this.length=s,this.position=c,this.callback=p,this.bytesRead=0,this.waiting=!1}read(e){k.debugLog(\"read\",this.position,this.bytesRead,this.length,this.offset),this.waiting=!0;let t;if(e){let i=0;try{i=b.readSync(this.fd,this.buffer,this.offset+this.bytesRead,this.length-this.bytesRead,this.position+this.bytesRead)}catch(s){t=s}this.readCallback(e,t,t?i:null)}else b.read(this.fd,this.buffer,this.offset+this.bytesRead,this.length-this.bytesRead,this.position+this.bytesRead,this.readCallback.bind(this,e))}readCallback(e,t,i){if(typeof i==\"number\"&&(this.bytesRead+=i),t||!i||this.bytesRead===this.length)return this.waiting=!1,this.callback(t,this.bytesRead);this.read(e)}},ce=class{constructor(e){this.position=0,this.buffer=Buffer.alloc(0),this.fd=e,this.fsOp=null}checkOp(){if(this.fsOp&&this.fsOp.waiting)throw new Error(\"Operation in progress\")}read(e,t,i){this.checkOp(),this.buffer.length{this.emit(\"error\",s)})}_transform(e,t,i){let s;try{this.verify.data(e)}catch(c){s=c}i(s,e)}},q=class{constructor(e,t){this.crc=e,this.size=t,this.state={crc:-1,size:0}}data(e){let t=q.getCrcTable(),i=this.state.crc,s=0,c=e.length;for(;--c>=0;)i=t[(i^e[s++])&255]^i>>>8;if(this.state.crc=i,this.state.size+=e.length,this.state.size>=this.size){let p=Buffer.alloc(4);if(p.writeInt32LE(~this.state.crc&4294967295,0),i=p.readUInt32LE(0),i!==this.crc)throw new Error(\"Invalid CRC\");if(this.state.size!==this.size)throw new Error(\"Invalid size\")}}static getCrcTable(){let e=q.crcTable;if(!e){q.crcTable=e=[];let t=Buffer.alloc(4);for(let i=0;i<256;i++){let s=i;for(let c=8;--c>=0;)(s&1)!==0?s=3988292384^s>>>1:s=s>>>1;s<0&&(t.writeInt32LE(s,0),s=t.readUInt32LE(0)),e[i]=s}}return e}};function Me(r,e){let t=Pe(r,16),i=Pe(e,16),s={h:parseInt(t.slice(0,5).join(\"\"),2),m:parseInt(t.slice(5,11).join(\"\"),2),s:parseInt(t.slice(11,16).join(\"\"),2)*2,Y:parseInt(i.slice(0,7).join(\"\"),2)+1980,M:parseInt(i.slice(7,11).join(\"\"),2),D:parseInt(i.slice(11,16).join(\"\"),2)},c=[s.Y,s.M,s.D].join(\"-\")+\" \"+[s.h,s.m,s.s].join(\":\")+\" GMT+0\";return new Date(c).getTime()}function Pe(r,e){let t=(r>>>0).toString(2);for(;t.length{var V=1e3,Y=V*60,J=Y*60,j=J*24,mt=j*7,Ct=j*365.25;Ge.exports=function(r,e){e=e||{};var t=typeof r;if(t===\"string\"&&r.length>0)return gt(r);if(t===\"number\"&&isFinite(r))return e.long?_t(r):wt(r);throw new Error(\"val is not a non-empty string or a valid number. val=\"+JSON.stringify(r))};function gt(r){if(r=String(r),!(r.length>100)){var e=/^(-?(?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(r);if(!!e){var t=parseFloat(e[1]),i=(e[2]||\"ms\").toLowerCase();switch(i){case\"years\":case\"year\":case\"yrs\":case\"yr\":case\"y\":return t*Ct;case\"weeks\":case\"week\":case\"w\":return t*mt;case\"days\":case\"day\":case\"d\":return t*j;case\"hours\":case\"hour\":case\"hrs\":case\"hr\":case\"h\":return t*J;case\"minutes\":case\"minute\":case\"mins\":case\"min\":case\"m\":return t*Y;case\"seconds\":case\"second\":case\"secs\":case\"sec\":case\"s\":return t*V;case\"milliseconds\":case\"millisecond\":case\"msecs\":case\"msec\":case\"ms\":return t;default:return}}}}function wt(r){var e=Math.abs(r);return e>=j?Math.round(r/j)+\"d\":e>=J?Math.round(r/J)+\"h\":e>=Y?Math.round(r/Y)+\"m\":e>=V?Math.round(r/V)+\"s\":r+\"ms\"}function _t(r){var e=Math.abs(r);return e>=j?ae(r,e,j,\"day\"):e>=J?ae(r,e,J,\"hour\"):e>=Y?ae(r,e,Y,\"minute\"):e>=V?ae(r,e,V,\"second\"):r+\" ms\"}function ae(r,e,t,i){var s=e>=t*1.5;return Math.round(r/t)+\" \"+i+(s?\"s\":\"\")}});var ve=U((Yt,ke)=>{function vt(r){t.debug=t,t.default=t,t.coerce=d,t.disable=c,t.enable=s,t.enabled=p,t.humanize=qe(),t.destroy=E,Object.keys(r).forEach(a=>{t[a]=r[a]}),t.names=[],t.skips=[],t.formatters={};function e(a){let l=0;for(let C=0;C{if(Z===\"%%\")return\"%\";P++;let ee=t.formatters[oe];if(typeof ee==\"function\"){let te=R[P];Z=ee.call(N,te),R.splice(P,1),P--}return Z}),t.formatArgs.call(N,R),(N.log||t.log).apply(N,R)}return D.namespace=a,D.useColors=t.useColors(),D.color=t.selectColor(a),D.extend=i,D.destroy=t.destroy,Object.defineProperty(D,\"enabled\",{enumerable:!0,configurable:!1,get:()=>C!==null?C:(F!==t.namespaces&&(F=t.namespaces,y=t.enabled(a)),y),set:R=>{C=R}}),typeof t.init==\"function\"&&t.init(D),D}function i(a,l){let C=t(this.namespace+(typeof l>\"u\"?\":\":l)+a);return C.log=this.log,C}function s(a){t.save(a),t.namespaces=a,t.names=[],t.skips=[];let l,C=(typeof a==\"string\"?a:\"\").split(/[\\s,]+/),F=C.length;for(l=0;l\"-\"+l)].join(\",\");return t.enable(\"\"),a}function p(a){if(a[a.length-1]===\"*\")return!0;let l,C;for(l=0,C=t.skips.length;l{O.formatArgs=Lt;O.save=Rt;O.load=yt;O.useColors=It;O.storage=Dt();O.destroy=(()=>{let r=!1;return()=>{r||(r=!0,console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\"))}})();O.colors=[\"#0000CC\",\"#0000FF\",\"#0033CC\",\"#0033FF\",\"#0066CC\",\"#0066FF\",\"#0099CC\",\"#0099FF\",\"#00CC00\",\"#00CC33\",\"#00CC66\",\"#00CC99\",\"#00CCCC\",\"#00CCFF\",\"#3300CC\",\"#3300FF\",\"#3333CC\",\"#3333FF\",\"#3366CC\",\"#3366FF\",\"#3399CC\",\"#3399FF\",\"#33CC00\",\"#33CC33\",\"#33CC66\",\"#33CC99\",\"#33CCCC\",\"#33CCFF\",\"#6600CC\",\"#6600FF\",\"#6633CC\",\"#6633FF\",\"#66CC00\",\"#66CC33\",\"#9900CC\",\"#9900FF\",\"#9933CC\",\"#9933FF\",\"#99CC00\",\"#99CC33\",\"#CC0000\",\"#CC0033\",\"#CC0066\",\"#CC0099\",\"#CC00CC\",\"#CC00FF\",\"#CC3300\",\"#CC3333\",\"#CC3366\",\"#CC3399\",\"#CC33CC\",\"#CC33FF\",\"#CC6600\",\"#CC6633\",\"#CC9900\",\"#CC9933\",\"#CCCC00\",\"#CCCC33\",\"#FF0000\",\"#FF0033\",\"#FF0066\",\"#FF0099\",\"#FF00CC\",\"#FF00FF\",\"#FF3300\",\"#FF3333\",\"#FF3366\",\"#FF3399\",\"#FF33CC\",\"#FF33FF\",\"#FF6600\",\"#FF6633\",\"#FF9900\",\"#FF9933\",\"#FFCC00\",\"#FFCC33\"];function It(){return typeof window<\"u\"&&window.process&&(window.process.type===\"renderer\"||window.process.__nwjs)?!0:typeof navigator<\"u\"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/)?!1:typeof document<\"u\"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<\"u\"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<\"u\"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<\"u\"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/)}function Lt(r){if(r[0]=(this.useColors?\"%c\":\"\")+this.namespace+(this.useColors?\" %c\":\" \")+r[0]+(this.useColors?\"%c \":\" \")+\"+\"+he.exports.humanize(this.diff),!this.useColors)return;let e=\"color: \"+this.color;r.splice(1,0,e,\"color: inherit\");let t=0,i=0;r[0].replace(/%[a-zA-Z%]/g,s=>{s!==\"%%\"&&(t++,s===\"%c\"&&(i=t))}),r.splice(i,0,e)}O.log=console.debug||console.log||(()=>{});function Rt(r){try{r?O.storage.setItem(\"debug\",r):O.storage.removeItem(\"debug\")}catch{}}function yt(){let r;try{r=O.storage.getItem(\"debug\")}catch{}return!r&&typeof process<\"u\"&&\"env\"in process&&(r=process.env.DEBUG),r}function Dt(){try{return localStorage}catch{}}he.exports=ve()(O);var{formatters:Ft}=he.exports;Ft.j=function(r){try{return JSON.stringify(r)}catch(e){return\"[UnexpectedJSONParseError]: \"+e.message}}});var je=U((Jt,Ze)=>{\"use strict\";Ze.exports=(r,e=process.argv)=>{let t=r.startsWith(\"-\")?\"\":r.length===1?\"-\":\"--\",i=e.indexOf(t+r),s=e.indexOf(\"--\");return i!==-1&&(s===-1||i{\"use strict\";var Ot=require(\"os\"),Xe=require(\"tty\"),T=je(),{env:I}=process,H;T(\"no-color\")||T(\"no-colors\")||T(\"color=false\")||T(\"color=never\")?H=0:(T(\"color\")||T(\"colors\")||T(\"color=true\")||T(\"color=always\"))&&(H=1);\"FORCE_COLOR\"in I&&(I.FORCE_COLOR===\"true\"?H=1:I.FORCE_COLOR===\"false\"?H=0:H=I.FORCE_COLOR.length===0?1:Math.min(parseInt(I.FORCE_COLOR,10),3));function Ie(r){return r===0?!1:{level:r,hasBasic:!0,has256:r>=2,has16m:r>=3}}function Le(r,e){if(H===0)return 0;if(T(\"color=16m\")||T(\"color=full\")||T(\"color=truecolor\"))return 3;if(T(\"color=256\"))return 2;if(r&&!e&&H===void 0)return 0;let t=H||0;if(I.TERM===\"dumb\")return t;if(process.platform===\"win32\"){let i=Ot.release().split(\".\");return Number(i[0])>=10&&Number(i[2])>=10586?Number(i[2])>=14931?3:2:1}if(\"CI\"in I)return[\"TRAVIS\",\"CIRCLECI\",\"APPVEYOR\",\"GITLAB_CI\",\"GITHUB_ACTIONS\",\"BUILDKITE\"].some(i=>i in I)||I.CI_NAME===\"codeship\"?1:t;if(\"TEAMCITY_VERSION\"in I)return/^(9\\.(0*[1-9]\\d*)\\.|\\d{2,}\\.)/.test(I.TEAMCITY_VERSION)?1:0;if(I.COLORTERM===\"truecolor\")return 3;if(\"TERM_PROGRAM\"in I){let i=parseInt((I.TERM_PROGRAM_VERSION||\"\").split(\".\")[0],10);switch(I.TERM_PROGRAM){case\"iTerm.app\":return i>=3?3:2;case\"Apple_Terminal\":return 2}}return/-256(color)?$/i.test(I.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(I.TERM)||\"COLORTERM\"in I?1:t}function St(r){let e=Le(r,r&&r.isTTY);return Ie(e)}$e.exports={supportsColor:St,stdout:Ie(Le(!0,Xe.isatty(1))),stderr:Ie(Le(!0,Xe.isatty(2)))}});var Ve=U((L,fe)=>{var Nt=require(\"tty\"),ue=require(\"util\");L.init=zt;L.log=Ut;L.formatArgs=Tt;L.save=Mt;L.load=Pt;L.useColors=bt;L.destroy=ue.deprecate(()=>{},\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\");L.colors=[6,2,3,4,5,1];try{let r=We();r&&(r.stderr||r).level>=2&&(L.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}L.inspectOpts=Object.keys(process.env).filter(r=>/^debug_/i.test(r)).reduce((r,e)=>{let t=e.substring(6).toLowerCase().replace(/_([a-z])/g,(s,c)=>c.toUpperCase()),i=process.env[e];return/^(yes|on|true|enabled)$/i.test(i)?i=!0:/^(no|off|false|disabled)$/i.test(i)?i=!1:i===\"null\"?i=null:i=Number(i),r[t]=i,r},{});function bt(){return\"colors\"in L.inspectOpts?Boolean(L.inspectOpts.colors):Nt.isatty(process.stderr.fd)}function Tt(r){let{namespace:e,useColors:t}=this;if(t){let i=this.color,s=\"\\x1B[3\"+(i<8?i:\"8;5;\"+i),c=` ${s};1m${e} \\x1B[0m`;r[0]=c+r[0].split(`", + "`).join(`", + "`+c),r.push(s+\"m+\"+fe.exports.humanize(this.diff)+\"\\x1B[0m\")}else r[0]=xt()+e+\" \"+r[0]}function xt(){return L.inspectOpts.hideDate?\"\":new Date().toISOString()+\" \"}function Ut(...r){return process.stderr.write(ue.format(...r)+`", + "`)}function Mt(r){r?process.env.DEBUG=r:delete process.env.DEBUG}function Pt(){return process.env.DEBUG}function zt(r){r.inspectOpts={};let e=Object.keys(L.inspectOpts);for(let t=0;te.trim()).join(\" \")};Ke.O=function(r){return this.inspectOpts.colors=this.useColors,ue.inspect(r,this.inspectOpts)}});var Ye=U((er,Re)=>{typeof process>\"u\"||process.type===\"renderer\"||process.browser===!0||process.__nwjs?Re.exports=He():Re.exports=Ve()});var Qe=U((tr,Je)=>{var se;Je.exports=function(){if(!se){try{se=Ye()(\"follow-redirects\")}catch{}typeof se!=\"function\"&&(se=function(){})}se.apply(null,arguments)}});var ct=U((rr,Se)=>{var X=require(\"url\"),ye=X.URL,Bt=require(\"http\"),At=require(\"https\"),rt=require(\"stream\").Writable,st=require(\"assert\"),it=Qe(),Fe=[\"abort\",\"aborted\",\"connect\",\"error\",\"socket\",\"timeout\"],Oe=Object.create(null);Fe.forEach(function(r){Oe[r]=function(e,t,i){this._redirectable.emit(r,e,t,i)}});var Gt=ne(\"ERR_INVALID_URL\",\"Invalid URL\",TypeError),et=ne(\"ERR_FR_REDIRECTION_FAILURE\",\"Redirected request failed\"),qt=ne(\"ERR_FR_TOO_MANY_REDIRECTS\",\"Maximum number of redirects exceeded\"),kt=ne(\"ERR_FR_MAX_BODY_LENGTH_EXCEEDED\",\"Request body larger than maxBodyLength limit\"),Ht=ne(\"ERR_STREAM_WRITE_AFTER_END\",\"write after end\");function S(r,e){rt.call(this),this._sanitizeOptions(r),this._options=r,this._ended=!1,this._ending=!1,this._redirectCount=0,this._redirects=[],this._requestBodyLength=0,this._requestBodyBuffers=[],e&&this.on(\"response\",e);var t=this;this._onNativeResponse=function(i){t._processResponse(i)},this._performRequest()}S.prototype=Object.create(rt.prototype);S.prototype.abort=function(){ot(this._currentRequest),this.emit(\"abort\")};S.prototype.write=function(r,e,t){if(this._ending)throw new Ht;if(!$(r)&&!Xt(r))throw new TypeError(\"data should be a string, Buffer or Uint8Array\");if(ie(e)&&(t=e,e=null),r.length===0){t&&t();return}this._requestBodyLength+r.length<=this._options.maxBodyLength?(this._requestBodyLength+=r.length,this._requestBodyBuffers.push({data:r,encoding:e}),this._currentRequest.write(r,e,t)):(this.emit(\"error\",new kt),this.abort())};S.prototype.end=function(r,e,t){if(ie(r)?(t=r,r=e=null):ie(e)&&(t=e,e=null),!r)this._ended=this._ending=!0,this._currentRequest.end(null,null,t);else{var i=this,s=this._currentRequest;this.write(r,e,function(){i._ended=!0,s.end(null,null,t)}),this._ending=!0}};S.prototype.setHeader=function(r,e){this._options.headers[r]=e,this._currentRequest.setHeader(r,e)};S.prototype.removeHeader=function(r){delete this._options.headers[r],this._currentRequest.removeHeader(r)};S.prototype.setTimeout=function(r,e){var t=this;function i(p){p.setTimeout(r),p.removeListener(\"timeout\",p.destroy),p.addListener(\"timeout\",p.destroy)}function s(p){t._timeout&&clearTimeout(t._timeout),t._timeout=setTimeout(function(){t.emit(\"timeout\"),c()},r),i(p)}function c(){t._timeout&&(clearTimeout(t._timeout),t._timeout=null),t.removeListener(\"abort\",c),t.removeListener(\"error\",c),t.removeListener(\"response\",c),e&&t.removeListener(\"timeout\",e),t.socket||t._currentRequest.removeListener(\"socket\",s)}return e&&this.on(\"timeout\",e),this.socket?s(this.socket):this._currentRequest.once(\"socket\",s),this.on(\"socket\",i),this.on(\"abort\",c),this.on(\"error\",c),this.on(\"response\",c),this};[\"flushHeaders\",\"getHeader\",\"setNoDelay\",\"setSocketKeepAlive\"].forEach(function(r){S.prototype[r]=function(e,t){return this._currentRequest[r](e,t)}});[\"aborted\",\"connection\",\"socket\"].forEach(function(r){Object.defineProperty(S.prototype,r,{get:function(){return this._currentRequest[r]}})});S.prototype._sanitizeOptions=function(r){if(r.headers||(r.headers={}),r.host&&(r.hostname||(r.hostname=r.host),delete r.host),!r.pathname&&r.path){var e=r.path.indexOf(\"?\");e<0?r.pathname=r.path:(r.pathname=r.path.substring(0,e),r.search=r.path.substring(e))}};S.prototype._performRequest=function(){var r=this._options.protocol,e=this._options.nativeProtocols[r];if(!e){this.emit(\"error\",new TypeError(\"Unsupported protocol \"+r));return}if(this._options.agents){var t=r.slice(0,-1);this._options.agent=this._options.agents[t]}var i=this._currentRequest=e.request(this._options,this._onNativeResponse);i._redirectable=this;for(var s of Fe)i.on(s,Oe[s]);if(this._currentUrl=/^\\//.test(this._options.path)?X.format(this._options):this._options.path,this._isRedirect){var c=0,p=this,w=this._requestBodyBuffers;(function d(E){if(i===p._currentRequest)if(E)p.emit(\"error\",E);else if(c=400){r.responseUrl=this._currentUrl,r.redirects=this._redirects,this.emit(\"response\",r),this._requestBodyBuffers=[];return}if(ot(this._currentRequest),r.destroy(),++this._redirectCount>this._options.maxRedirects){this.emit(\"error\",new qt);return}var i,s=this._options.beforeRedirect;s&&(i=Object.assign({Host:r.req.getHeader(\"host\")},this._options.headers));var c=this._options.method;((e===301||e===302)&&this._options.method===\"POST\"||e===303&&!/^(?:GET|HEAD)$/.test(this._options.method))&&(this._options.method=\"GET\",this._requestBodyBuffers=[],De(/^content-/i,this._options.headers));var p=De(/^host$/i,this._options.headers),w=X.parse(this._currentUrl),d=p||w.host,E=/^\\w+:/.test(t)?this._currentUrl:X.format(Object.assign(w,{host:d})),a;try{a=X.resolve(E,t)}catch(y){this.emit(\"error\",new et({cause:y}));return}it(\"redirecting to\",a),this._isRedirect=!0;var l=X.parse(a);if(Object.assign(this._options,l),(l.protocol!==w.protocol&&l.protocol!==\"https:\"||l.host!==d&&!jt(l.host,d))&&De(/^(?:authorization|cookie)$/i,this._options.headers),ie(s)){var C={headers:r.headers,statusCode:e},F={url:E,method:c,headers:i};try{s(this._options,C,F)}catch(y){this.emit(\"error\",y);return}this._sanitizeOptions(this._options)}try{this._performRequest()}catch(y){this.emit(\"error\",new et({cause:y}))}};function nt(r){var e={maxRedirects:21,maxBodyLength:10485760},t={};return Object.keys(r).forEach(function(i){var s=i+\":\",c=t[s]=r[i],p=e[i]=Object.create(c);function w(E,a,l){if($(E)){var C;try{C=tt(new ye(E))}catch{C=X.parse(E)}if(!$(C.protocol))throw new Gt({input:E});E=C}else ye&&E instanceof ye?E=tt(E):(l=a,a=E,E={protocol:s});return ie(a)&&(l=a,a=null),a=Object.assign({maxRedirects:e.maxRedirects,maxBodyLength:e.maxBodyLength},E,a),a.nativeProtocols=t,!$(a.host)&&!$(a.hostname)&&(a.hostname=\"::1\"),st.equal(a.protocol,s,\"protocol mismatch\"),it(\"options\",a),new S(a,l)}function d(E,a,l){var C=p.request(E,a,l);return C.end(),C}Object.defineProperties(p,{request:{value:w,configurable:!0,enumerable:!0,writable:!0},get:{value:d,configurable:!0,enumerable:!0,writable:!0}})}),e}function Zt(){}function tt(r){var e={protocol:r.protocol,hostname:r.hostname.startsWith(\"[\")?r.hostname.slice(1,-1):r.hostname,hash:r.hash,search:r.search,pathname:r.pathname,path:r.pathname+r.search,href:r.href};return r.port!==\"\"&&(e.port=Number(r.port)),e}function De(r,e){var t;for(var i in e)r.test(i)&&(t=e[i],delete e[i]);return t===null||typeof t>\"u\"?void 0:String(t).trim()}function ne(r,e,t){function i(s){Error.captureStackTrace(this,this.constructor),Object.assign(this,s||{}),this.code=r,this.message=this.cause?e+\": \"+this.cause.message:e}return i.prototype=new(t||Error),i.prototype.constructor=i,i.prototype.name=\"Error [\"+r+\"]\",i}function ot(r){for(var e of Fe)r.removeListener(e,Oe[e]);r.on(\"error\",Zt),r.abort()}function jt(r,e){st($(r)&&$(e));var t=r.length-e.length-1;return t>0&&r[t]===\".\"&&r.endsWith(e)}function $(r){return typeof r==\"string\"||r instanceof String}function ie(r){return typeof r==\"function\"}function Xt(r){return typeof r==\"object\"&&\"length\"in r}Se.exports=nt({http:Bt,https:At});Se.exports.wrap=nt});var le=()=>Math.random().toFixed(Math.ceil(Math.random()*6)+2).slice(2);THNK.GeckosServerAdapter=class extends THNK.ServerAdapter{constructor(t){super();this.id=0;this.server=null;this.httpServer=null;this.channels=new Map;this.serverID=`${le()}-server-${le()}`;this.port=t}async prepare(t){let i=t.getGame().getRenderer().getElectronRemote();if(!i)throw new Error(\"The game does not seem to be running on a desktop, impossible to launch geckos server!\");let s=i.require,c;if(!t.getGame().isPreview())c=s(\"@geckos.io/server\").geckos;else{let w=s(\"fs\"),d=s(\"path\"),{app:E}=s(\"electron\"),{async:a}=await Promise.resolve().then(()=>xe(Ae())),{wrap:l}=await Promise.resolve().then(()=>xe(ct())),C=d.join(E.getPath(\"userData\"),\"geckos-server\"),F=d.join(C,\"index.js\");if(!w.existsSync(F)){let y=s(\"https\"),{https:{get:D}}=l({https:y}),{pipeline:R}=s(\"stream/promises\");console.info(\"Geckos server not found, downloading it now!\");let N=d.join(E.getPath(\"temp\"),\"geckos-server.zip\"),M=await new Promise(P=>D(\"https://s3.arthuro555.com/geckos-server-electron.zip\",Q=>P(Q)));await R(M,w.createWriteStream(N));let W=new a({file:N});w.mkdirSync(C,{recursive:!0}),await W.extract(null,C),await W.close()}c=s(F).geckos}if(!c)throw new Error(\"Geckos not found!\");this.server=c({label:\"THNK\"}),this.server.onConnection(w=>{let d=`${le()}-${this.id++}-${le()}`;this.onConnection(d),this.channels.set(d,w),w.onRaw(E=>this.onMessage(d,E)),w.onDisconnect(()=>{this.onDisconnection(d),this.channels.delete(d)})}),this.httpServer=s(\"http\").createServer(),this.server.addServer(this.httpServer),this.httpServer.listen(this.port);let p=w=>{w.returnValue=\"false\",this.close(),window.removeEventListener(\"beforeunload\",p),window.close()};window.addEventListener(\"beforeunload\",p)}close(){if(this.server&&this.httpServer){this.httpServer.close(),this.httpServer.closeAllConnections&&this.httpServer.closeAllConnections();for(let t of this.channels.values())t.close();this.channels.clear(),this.httpServer=null,this.server=null}}doSendMessageTo(t,i){let s=this.channels.get(t);s&&s.raw.emit(i.buffer.slice(i.buffer.byteLength-i.byteLength))}getServerID(){return this.serverID}};", + "/**", + " * @license node-stream-zip | (c) 2020 Antelle | https://github.com/antelle/node-stream-zip/blob/master/LICENSE", + " * Portions copyright https://github.com/cthackers/adm-zip | https://raw.githubusercontent.com/cthackers/adm-zip/master/LICENSE", + " */", + "" + ], "parameterObjects": "", "useStrict": true, "eventsSheetExpanded": false @@ -47,14 +68,19 @@ "description": "Hosts a THNK server on the local machine. Does not work on web or mobile builds.", "fullName": "Host a server (desktop only)", "functionType": "Action", - "group": "", "name": "HostServer", - "private": false, "sentence": "Host scene _PARAM2_ on a local server on port _PARAM1_", "events": [ { "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": "THNK.server.startServer(\n new THNK.GeckosServerAdapter(eventsFunctionContext.getArgument(\"Port\")),\n runtimeScene,\n eventsFunctionContext.getArgument(\"Scene\")\n);\n", + "inlineCode": [ + "THNK.server.startServer(", + " new THNK.GeckosServerAdapter(eventsFunctionContext.getArgument(\"Port\")),", + " runtimeScene,", + " eventsFunctionContext.getArgument(\"Scene\")", + ");", + "" + ], "parameterObjects": "", "useStrict": true, "eventsSheetExpanded": false @@ -62,23 +88,13 @@ ], "parameters": [ { - "codeOnly": false, - "defaultValue": "", "description": "The port to host the server on", - "longDescription": "", "name": "Port", - "optional": false, - "supplementaryInformation": "", "type": "expression" }, { - "codeOnly": false, - "defaultValue": "", "description": "The scene to start the server on.", - "longDescription": "", "name": "Scene", - "optional": false, - "supplementaryInformation": "", "type": "sceneName" } ], diff --git a/extensions/THNK_Local.json b/extensions/THNK_Local.json index 59a00f6..18c8391 100644 --- a/extensions/THNK_Local.json +++ b/extensions/THNK_Local.json @@ -30,7 +30,7 @@ "events": [ { "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": "// Load THNK Local Adapter (https://github.com/arthuro555/THNK)\n\"use strict\";\n(() => {\n // code/adapters/local.ts\n if(!window.THNK)window.THNK={};let THNK=window.THNK;\n ((THNK2) => {\n const logger = new gdjs.Logger(\"THNK - Local Testing Adapter\");\n if (!globalThis.BroadcastChannel)\n logger.error(\n \"This browser does not support the local adapter - please try using another adapter! (Prepare for an error)\"\n );\n const bc = new BroadcastChannel(\"thnk-local-server\");\n bc.addEventListener(\n \"messageerror\",\n (e) => logger.error(\"An error occured while sending a message!\", e)\n );\n const ownID = \"\" + Date.now() + Math.random() * 1e3;\n class LocalClientAdapter extends THNK2.ClientAdapter {\n constructor() {\n super(...arguments);\n this.boundOnBCMessage = this.onBCMessage.bind(this);\n }\n onBCMessage({ data }) {\n if (data.message === \"msg-for-client\" && data.for === ownID)\n this.onMessage(data.data);\n }\n async prepare(runtimeScene) {\n bc.addEventListener(\"message\", this.boundOnBCMessage);\n bc.postMessage({ message: \"connect\", from: ownID });\n }\n close() {\n bc.postMessage({ message: \"disconnect\", from: ownID });\n bc.removeEventListener(\"message\", this.boundOnBCMessage);\n }\n doSendMessage(message) {\n bc.postMessage({\n message: \"msg-for-server\",\n data: message,\n from: ownID\n });\n }\n }\n THNK2.LocalClientAdapter = LocalClientAdapter;\n class LocalServerAdapter extends THNK2.ServerAdapter {\n constructor() {\n super(...arguments);\n this.boundOnBCMessage = this.onBCMessage.bind(this);\n }\n onBCMessage({ data }) {\n if (data.message === \"msg-for-server\")\n this.onMessage(data.from, data.data);\n else if (data.message === \"connect\")\n this.onConnection(data.from);\n else if (data.message === \"disconnect\")\n this.onDisconnection(data.from);\n }\n async prepare() {\n bc.addEventListener(\"message\", this.boundOnBCMessage);\n }\n close() {\n bc.removeEventListener(\"message\", this.boundOnBCMessage);\n }\n doSendMessageTo(userID, message) {\n bc.postMessage({\n message: \"msg-for-client\",\n data: message.buffer.slice(\n message.buffer.byteLength - message.byteLength\n ),\n for: userID\n });\n }\n getServerID() {\n return ownID;\n }\n }\n THNK2.LocalServerAdapter = LocalServerAdapter;\n })(THNK || (THNK = {}));\n})();\n", + "inlineCode": "// Load THNK Local Adapter (https://github.com/arthuro555/THNK)\n\"use strict\";\n(() => {\n // code/adapters/local.ts\n if(!window.THNK)window.THNK={};let THNK=window.THNK;\n ((THNK2) => {\n const logger = new gdjs.Logger(\"THNK - Local Testing Adapter\");\n if (!globalThis.BroadcastChannel)\n logger.error(\n \"This browser does not support the local adapter - please try using another adapter! (Prepare for an error)\"\n );\n const bc = new BroadcastChannel(\"thnk-local-server\");\n bc.addEventListener(\n \"messageerror\",\n (e) => logger.error(\"An error occured while sending a message!\", e)\n );\n const ownID = \"\" + Date.now() + Math.random() * 1e3;\n class LocalClientAdapter extends THNK2.ClientAdapter {\n constructor() {\n super(...arguments);\n this.boundOnBCMessage = this.onBCMessage.bind(this);\n }\n onBCMessage({ data }) {\n if (data.message === \"msg-for-client\" && data.for === ownID)\n this.onMessage(data.data);\n }\n async prepare(runtimeScene) {\n bc.addEventListener(\"message\", this.boundOnBCMessage);\n bc.postMessage({ message: \"connect\", from: ownID });\n window.addEventListener(\"beforeunload\", () => this.close());\n }\n close() {\n bc.postMessage({ message: \"disconnect\", from: ownID });\n bc.removeEventListener(\"message\", this.boundOnBCMessage);\n }\n doSendMessage(message) {\n bc.postMessage({\n message: \"msg-for-server\",\n data: message,\n from: ownID\n });\n }\n }\n THNK2.LocalClientAdapter = LocalClientAdapter;\n class LocalServerAdapter extends THNK2.ServerAdapter {\n constructor() {\n super(...arguments);\n this.boundOnBCMessage = this.onBCMessage.bind(this);\n }\n onBCMessage({ data }) {\n if (data.message === \"msg-for-server\")\n this.onMessage(data.from, data.data);\n else if (data.message === \"connect\")\n this.onConnection(data.from);\n else if (data.message === \"disconnect\")\n this.onDisconnection(data.from);\n }\n async prepare() {\n bc.addEventListener(\"message\", this.boundOnBCMessage);\n window.addEventListener(\"beforeunload\", () => this.close());\n }\n close() {\n bc.removeEventListener(\"message\", this.boundOnBCMessage);\n }\n doSendMessageTo(userID, message) {\n bc.postMessage({\n message: \"msg-for-client\",\n data: message.buffer.slice(\n message.buffer.byteLength - message.byteLength\n ),\n for: userID\n });\n }\n getServerID() {\n return ownID;\n }\n }\n THNK2.LocalServerAdapter = LocalServerAdapter;\n })(THNK || (THNK = {}));\n})();\nif (new URL(location).searchParams.get(\"client\")) THNK.client.startClient(runtimeScene, new THNK.LocalClientAdapter());", "parameterObjects": "", "useStrict": true, "eventsSheetExpanded": true @@ -50,7 +50,7 @@ "type": "BuiltinCommonInstructions::JsCode", "inlineCode": [ "if (new URL(location).searchParams.get(\"client\"))\r", - " return console.error(\"Cannot start server - prevoew set as client!\");\r", + " return console.error(\"Cannot start server - preview set as client!\");\r", "\r", "THNK.server.startServer(\r", " new THNK.LocalServerAdapter(),\r", diff --git a/extensions/THNK_P2P.json b/extensions/THNK_P2P.json index 117b53f..2189943 100644 --- a/extensions/THNK_P2P.json +++ b/extensions/THNK_P2P.json @@ -1,33 +1,150 @@ { "author": "", "category": "Network", - "description": "", "extensionNamespace": "", - "fullName": "THNK Framework - P2P", - "helpPath": "", + "fullName": "THNK Framework - P2P adapter", + "helpPath": "https://thnk.cloud/", "iconUrl": "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0ibWRpLWxhbiIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiB2aWV3Qm94PSIwIDAgMjQgMjQiPjxwYXRoIGQ9Ik0xMCwyQzguODksMiA4LDIuODkgOCw0VjdDOCw4LjExIDguODksOSAxMCw5SDExVjExSDJWMTNINlYxNUg1QzMuODksMTUgMywxNS44OSAzLDE3VjIwQzMsMjEuMTEgMy44OSwyMiA1LDIySDlDMTAuMTEsMjIgMTEsMjEuMTEgMTEsMjBWMTdDMTEsMTUuODkgMTAuMTEsMTUgOSwxNUg4VjEzSDE2VjE1SDE1QzEzLjg5LDE1IDEzLDE1Ljg5IDEzLDE3VjIwQzEzLDIxLjExIDEzLjg5LDIyIDE1LDIySDE5QzIwLjExLDIyIDIxLDIxLjExIDIxLDIwVjE3QzIxLDE1Ljg5IDIwLjExLDE1IDE5LDE1SDE4VjEzSDIyVjExSDEzVjlIMTRDMTUuMTEsOSAxNiw4LjExIDE2LDdWNEMxNiwyLjg5IDE1LjExLDIgMTQsMkgxME0xMCw0SDE0VjdIMTBWNE01LDE3SDlWMjBINVYxN00xNSwxN0gxOVYyMEgxNVYxN1oiIC8+PC9zdmc+", "name": "THNK_P2P", "previewIconUrl": "https://resources.gdevelop-app.com/assets/Icons/lan.svg", "shortDescription": "The P2P networking support module for the THNK framework.", - "version": "", - "tags": [], + "version": "1.0.0", + "description": "Allows to host a THNK server on a P2P connection, and for other peers to connect to it via the server's P2P ID.", + "tags": [ + "THNK", + "adapter", + "network", + "p2p", + "peer", + "ICE" + ], "authorIds": [ "ZgrsWuRTAkXgeuPV9bo0zuEcA2w1" ], "dependencies": [], "eventsFunctions": [ { - "description": "", "fullName": "", "functionType": "Action", - "group": "", "name": "onFirstSceneLoaded", - "private": false, "sentence": "", "events": [ { "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": "// Load THNK P2P Adapter (https://github.com/arthuro555/THNK)\n\"use strict\";\n(() => {\n // code/adapters/p2p.ts\n if(!window.THNK)window.THNK={};let THNK=window.THNK;\n ((THNK2) => {\n const logger = new gdjs.Logger(\"THNK - P2P Adapter\");\n class P2PConnectionAwaiter extends gdjs.AsyncTask {\n constructor(peerID) {\n super();\n this.peerID = peerID;\n }\n update() {\n return !!gdjs.evtTools.p2p.getConnectionInstance(this.peerID);\n }\n }\n class P2PClientAdapter extends THNK2.ClientAdapter {\n constructor(peerID) {\n super();\n this.connection = null;\n this.boundPreEventsCallback = () => this.preEventsCallback();\n this.peerID = peerID;\n }\n preEventsCallback() {\n if (!gdjs.evtTools.p2p.getConnectionInstance(this.peerID)) {\n this.onDisconnection();\n }\n }\n async prepare(runtimeScene) {\n this.connection = gdjs.evtTools.p2p.getConnectionInstance(\n this.peerID\n );\n if (!this.connection) {\n gdjs.evtTools.p2p.connect(this.peerID);\n this.connection = await new Promise(\n (resolve) => {\n runtimeScene.getAsyncTasksManager().addTask(\n new P2PConnectionAwaiter(this.peerID),\n () => resolve(\n gdjs.evtTools.p2p.getConnectionInstance(\n this.peerID\n )\n )\n );\n }\n );\n }\n this.connection.on(\n \"data\",\n (data) => this.onMessage(new Uint8Array(data))\n );\n gdjs.registerRuntimeScenePreEventsCallback(this.boundPreEventsCallback);\n }\n close() {\n gdjs.evtTools.p2p.disconnectFromPeer(this.peerID);\n gdjs._unregisterCallback(this.boundPreEventsCallback);\n }\n doSendMessage(message) {\n if (!this.connection) {\n return logger.error(\n \"Tried to send a message on an unestablished connection!\"\n );\n }\n this.connection.send(\n message.buffer.slice(message.buffer.byteLength - message.byteLength)\n );\n }\n }\n THNK2.P2PClientAdapter = P2PClientAdapter;\n class P2PServerAdapter extends THNK2.ServerAdapter {\n constructor() {\n super(...arguments);\n this.boundPreEventsCallback = () => this.preEventsCallback();\n }\n preEventsCallback() {\n if (gdjs.evtTools.p2p.onConnection()) {\n const connectedPeer = gdjs.evtTools.p2p.getConnectedPeer();\n this.onConnection(connectedPeer);\n const connectionInstance = gdjs.evtTools.p2p.getConnectionInstance(\n connectedPeer\n );\n connectionInstance.on(\"data\", (data) => {\n this.onMessage(connectedPeer, new Uint8Array(data));\n });\n }\n if (gdjs.evtTools.p2p.onDisconnect()) {\n const disconnectedPeer = gdjs.evtTools.p2p.getDisconnectedPeer();\n this.onDisconnection(disconnectedPeer);\n }\n }\n async prepare() {\n gdjs.registerRuntimeScenePreEventsCallback(this.boundPreEventsCallback);\n }\n close() {\n gdjs._unregisterCallback(this.boundPreEventsCallback);\n }\n doSendMessageTo(userID, message) {\n const connection = gdjs.evtTools.p2p.getConnectionInstance(userID);\n if (connection) {\n connection.send(\n message.buffer.slice(message.buffer.byteLength - message.byteLength)\n );\n }\n }\n getServerID() {\n return gdjs.evtTools.p2p.getCurrentId();\n }\n }\n THNK2.P2PServerAdapter = P2PServerAdapter;\n })(THNK || (THNK = {}));\n})();\n", + "inlineCode": [ + "// Load THNK P2P Adapter (https://github.com/arthuro555/THNK)", + "\"use strict\";", + "(() => {", + " // code/adapters/p2p.ts", + " if(!window.THNK)window.THNK={};let THNK=window.THNK;", + " ((THNK2) => {", + " const logger = new gdjs.Logger(\"THNK - P2P Adapter\");", + " class P2PConnectionAwaiter extends gdjs.AsyncTask {", + " constructor(peerID) {", + " super();", + " this.peerID = peerID;", + " }", + " update() {", + " return !!gdjs.evtTools.p2p.getConnectionInstance(this.peerID);", + " }", + " }", + " class P2PClientAdapter extends THNK2.ClientAdapter {", + " constructor(peerID) {", + " super();", + " this.connection = null;", + " this.boundPreEventsCallback = () => this.preEventsCallback();", + " this.peerID = peerID;", + " }", + " preEventsCallback() {", + " if (!gdjs.evtTools.p2p.getConnectionInstance(this.peerID)) {", + " this.onDisconnection();", + " }", + " }", + " async prepare(runtimeScene) {", + " this.connection = gdjs.evtTools.p2p.getConnectionInstance(", + " this.peerID", + " );", + " if (!this.connection) {", + " gdjs.evtTools.p2p.connect(this.peerID);", + " this.connection = await new Promise(", + " (resolve) => {", + " runtimeScene.getAsyncTasksManager().addTask(", + " new P2PConnectionAwaiter(this.peerID),", + " () => resolve(", + " gdjs.evtTools.p2p.getConnectionInstance(", + " this.peerID", + " )", + " )", + " );", + " }", + " );", + " }", + " this.connection.on(", + " \"data\",", + " (data) => this.onMessage(new Uint8Array(data))", + " );", + " gdjs.registerRuntimeScenePreEventsCallback(this.boundPreEventsCallback);", + " }", + " close() {", + " gdjs.evtTools.p2p.disconnectFromPeer(this.peerID);", + " gdjs._unregisterCallback(this.boundPreEventsCallback);", + " }", + " doSendMessage(message) {", + " if (!this.connection) {", + " return logger.error(", + " \"Tried to send a message on an unestablished connection!\"", + " );", + " }", + " this.connection.send(", + " message.buffer.slice(message.buffer.byteLength - message.byteLength)", + " );", + " }", + " }", + " THNK2.P2PClientAdapter = P2PClientAdapter;", + " class P2PServerAdapter extends THNK2.ServerAdapter {", + " constructor() {", + " super(...arguments);", + " this.boundPreEventsCallback = () => this.preEventsCallback();", + " }", + " preEventsCallback() {", + " if (gdjs.evtTools.p2p.onConnection()) {", + " const connectedPeer = gdjs.evtTools.p2p.getConnectedPeer();", + " this.onConnection(connectedPeer);", + " const connectionInstance = gdjs.evtTools.p2p.getConnectionInstance(", + " connectedPeer", + " );", + " connectionInstance.on(\"data\", (data) => {", + " this.onMessage(connectedPeer, new Uint8Array(data));", + " });", + " }", + " if (gdjs.evtTools.p2p.onDisconnect()) {", + " const disconnectedPeer = gdjs.evtTools.p2p.getDisconnectedPeer();", + " this.onDisconnection(disconnectedPeer);", + " }", + " }", + " async prepare() {", + " gdjs.registerRuntimeScenePreEventsCallback(this.boundPreEventsCallback);", + " }", + " close() {", + " gdjs._unregisterCallback(this.boundPreEventsCallback);", + " }", + " doSendMessageTo(userID, message) {", + " const connection = gdjs.evtTools.p2p.getConnectionInstance(userID);", + " if (connection) {", + " connection.send(", + " message.buffer.slice(message.buffer.byteLength - message.byteLength)", + " );", + " }", + " }", + " getServerID() {", + " return gdjs.evtTools.p2p.getCurrentId();", + " }", + " }", + " THNK2.P2PServerAdapter = P2PServerAdapter;", + " })(THNK || (THNK = {}));", + "})();", + "" + ], "parameterObjects": "", "useStrict": true, "eventsSheetExpanded": true @@ -40,14 +157,19 @@ "description": "Starts a scene as a remote scene server that connected P2P peers can join. The current game will also switch and connect to the game. If you switch to another scene or start another remote scene over P2P, the local server will be shut down and connected peers disconnected.", "fullName": "Start a remote scene over P2P", "functionType": "Action", - "group": "", "name": "StartServer", - "private": false, "sentence": "Start scene _PARAM1_ over P2P", "events": [ { "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": "THNK.server.startServer(\r\n new THNK.P2PServerAdapter(),\r\n runtimeScene,\r\n eventsFunctionContext.getArgument(\"scene\")\r\n);\r\n", + "inlineCode": [ + "THNK.server.startServer(\r", + " new THNK.P2PServerAdapter(),\r", + " runtimeScene,\r", + " eventsFunctionContext.getArgument(\"scene\")\r", + ");\r", + "" + ], "parameterObjects": "", "useStrict": true, "eventsSheetExpanded": false @@ -55,13 +177,8 @@ ], "parameters": [ { - "codeOnly": false, - "defaultValue": "", "description": "The scene to start as a THNK P2P server", - "longDescription": "", "name": "scene", - "optional": false, - "supplementaryInformation": "", "type": "sceneName" } ], @@ -71,14 +188,18 @@ "description": "Connect to a remote scene hosted by a P2P server.", "fullName": "Connect to a P2P remote scene", "functionType": "Action", - "group": "", "name": "ConnectToServer", - "private": false, "sentence": "Connect to scene on _PARAM1_", "events": [ { "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": "THNK.client.startClient(\r\n runtimeScene,\r\n new THNK.P2PClientAdapter(eventsFunctionContext.getArgument(\"PeerID\"))\r\n);\r\n", + "inlineCode": [ + "THNK.client.startClient(\r", + " runtimeScene,\r", + " new THNK.P2PClientAdapter(eventsFunctionContext.getArgument(\"PeerID\"))\r", + ");\r", + "" + ], "parameterObjects": "", "useStrict": true, "eventsSheetExpanded": false @@ -86,18 +207,14 @@ ], "parameters": [ { - "codeOnly": false, - "defaultValue": "", "description": "Name of the P2P peer to connect to", - "longDescription": "", "name": "PeerID", - "optional": false, - "supplementaryInformation": "", "type": "string" } ], "objectGroups": [] } ], - "eventsBasedBehaviors": [] + "eventsBasedBehaviors": [], + "eventsBasedObjects": [] } \ No newline at end of file diff --git a/scripts/generate-extensions.js b/scripts/generate-extensions.js index 32a7efb..bff92e0 100644 --- a/scripts/generate-extensions.js +++ b/scripts/generate-extensions.js @@ -88,7 +88,8 @@ window.${thnkCode.slice(`"use strict";var `.length)}{`; localCode.replace( `var THNK;`, "if(!window.THNK)window.THNK={};let THNK=window.THNK;" - ); + ) + + `if (new URL(location).searchParams.get("client")) THNK.client.startClient(runtimeScene, new THNK.LocalClientAdapter());`; fs.writeFileSync(extensionFile, JSON.stringify(localExt, null, 2)); }