rune-sdk
Version:
Build a multiplayer game played by millions! Your game runs inside the Rune app with 10 million installs across [iOS](https://apps.apple.com/app/rune-games-and-voice-chat/id1450358364) and [Android](https://play.google.com/store/apps/details?id=ai.rune.ti
10 lines (8 loc) • 45.4 kB
JavaScript
/*
Copyright (c) 2024 Rune AI Inc.
All rights reserved.
This code is proprietary to Rune AI Inc.
The code may be used solely for accessing the Service provided by Rune AI Inc. following the Rune AI Inc. Terms of Service ("Terms") accessible at rune.ai/eula. You may not use this code for any use or purpose other than as expressly permitted by the Terms.
Restrictions set forth in the Terms include, but is not limited to, that you may not copy, adapt, modify, prepare derivative works based upon, distribute, license, sell, transfer, publicly display, publicly perform, transmit, stream, broadcast, attempt to discover any source code, reverse engineer, decompile, dissemble, or otherwise exploit the code as a whole or any portion of the code.
*/
!function(){"use strict";function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function t(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=a(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){u=!0,o=e},f:function(){try{s||null==r.return||r.return()}finally{if(u)throw o}}}}function r(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function n(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,o,a,s=[],u=!0,l=!1;try{if(o=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=o.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){l=!0,i=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw i}}return s}}(e,t)||a(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t){return function(t){if(Array.isArray(t))return e(t)}(t)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||a(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function a(t,r){if(t){if("string"==typeof t)return e(t,r);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,r):void 0}}var s=function e(t){var r=t,n={}.toString.call(t).slice(8,-1);if("Set"==n)return new Set(i(t).map((function(t){return e(t)})));if("Map"==n)return new Map(i(t).map((function(t){return[e(t[0]),e(t[1])]})));if("Date"==n)return new Date(t.getTime());if("RegExp"==n)return RegExp(t.source,function(e){if("string"==typeof e.source.flags)return e.source.flags;var t=[];return e.global&&t.push("g"),e.ignoreCase&&t.push("i"),e.multiline&&t.push("m"),e.sticky&&t.push("y"),e.unicode&&t.push("u"),t.join("")}(t));if("Array"==n||"Object"==n)for(var o in r=Array.isArray(t)?[]:{},t)r[o]=e(t[o]);return r};var u="".concat("RUNE","_INVALID_ACTION");var l=["acos","acosh","asin","asinh","atan","atan2","atanh","cbrt","cos","cosh","exp","expm1","hypot","log","log10","log1p","log2","pow","sin","sinh","sqrt","tan"];var c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",f=c.length;var p=function(){return p=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},p.apply(this,arguments)};function d(e,t,r){if(r||2===arguments.length)for(var n,i=0,o=t.length;i<o;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}var h,v,y,g=4294967295;function w(e,t,r){var n=Math.floor(r/4294967296),i=r;e.setUint32(t,n),e.setUint32(t+4,i)}var m=("undefined"==typeof process||"never"!==(null===(h=null===process||void 0===process?void 0:process.env)||void 0===h?void 0:h.TEXT_ENCODING))&&"undefined"!=typeof TextEncoder&&"undefined"!=typeof TextDecoder;function b(e){for(var t=e.length,r=0,n=0;n<t;){var i=e.charCodeAt(n++);if(0!=(4294967168&i))if(0==(4294965248&i))r+=2;else{if(i>=55296&&i<=56319&&n<t){var o=e.charCodeAt(n);56320==(64512&o)&&(++n,i=((1023&i)<<10)+(1023&o)+65536)}r+=0==(4294901760&i)?3:4}else r++}return r}var S=m?new TextEncoder:void 0,E=m?"undefined"!=typeof process&&"force"!==(null===(v=null===process||void 0===process?void 0:process.env)||void 0===v?void 0:v.TEXT_ENCODING)?200:0:g;var P=(null==S?void 0:S.encodeInto)?function(e,t,r){S.encodeInto(e,t.subarray(r))}:function(e,t,r){t.set(S.encode(e),r)};m&&new TextDecoder,m&&"undefined"!=typeof process&&(null===(y=null===process||void 0===process?void 0:process.env)||void 0===y||y.TEXT_DECODER);var A,O=function(e,t){this.type=e,this.data=t},T=(A=function(e,t){return A=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},A(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}A(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),M=function(e){function t(r){var n=e.call(this,r)||this,i=Object.create(t.prototype);return Object.setPrototypeOf(n,i),Object.defineProperty(n,"name",{configurable:!0,enumerable:!1,value:t.name}),n}return T(t,e),t}(Error);var _={type:-1,encode:function(e){var t,r,n,i;return e instanceof Date?function(e){var t,r=e.sec,n=e.nsec;if(r>=0&&n>=0&&r<=17179869183){if(0===n&&r<=4294967295){var i=new Uint8Array(4);return(t=new DataView(i.buffer)).setUint32(0,r),i}var o=r/4294967296,a=4294967295&r;return i=new Uint8Array(8),(t=new DataView(i.buffer)).setUint32(0,n<<2|3&o),t.setUint32(4,a),i}return i=new Uint8Array(12),(t=new DataView(i.buffer)).setUint32(0,n),w(t,4,r),i}((t=e.getTime(),r=Math.floor(t/1e3),n=1e6*(t-1e3*r),i=Math.floor(n/1e9),{sec:r+i,nsec:n-1e9*i})):null},decode:function(e){var t=function(e){var t=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(e.byteLength){case 4:return{sec:n=t.getUint32(0),nsec:0};case 8:var r=t.getUint32(0);return{sec:n=4294967296*(3&r)+t.getUint32(4),nsec:r>>>2};case 12:var n=function(e,t){return 4294967296*e.getInt32(t)+e.getUint32(t+4)}(t,4);return{sec:n,nsec:t.getUint32(0)};default:throw new M("Unrecognized data size for timestamp (expected 4, 8, or 12): ".concat(e.length))}}(e);return new Date(1e3*t.sec+t.nsec/1e6)}},I=function(){function e(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(_)}return e.prototype.register=function(e){var t=e.type,r=e.encode,n=e.decode;if(t>=0)this.encoders[t]=r,this.decoders[t]=n;else{var i=1+t;this.builtInEncoders[i]=r,this.builtInDecoders[i]=n}},e.prototype.tryToEncode=function(e,t){for(var r=0;r<this.builtInEncoders.length;r++){if(null!=(n=this.builtInEncoders[r]))if(null!=(i=n(e,t)))return new O(-1-r,i)}for(r=0;r<this.encoders.length;r++){var n,i;if(null!=(n=this.encoders[r]))if(null!=(i=n(e,t)))return new O(r,i)}return e instanceof O?e:null},e.prototype.decode=function(e,t,r){var n=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return n?n(e,t,r):new O(t,e)},e.defaultCodec=new e,e}();var U=function(){function e(e,t,r,n,i,o,a,s){void 0===e&&(e=I.defaultCodec),void 0===t&&(t=void 0),void 0===r&&(r=100),void 0===n&&(n=2048),void 0===i&&(i=!1),void 0===o&&(o=!1),void 0===a&&(a=!1),void 0===s&&(s=!1),this.extensionCodec=e,this.context=t,this.maxDepth=r,this.initialBufferSize=n,this.sortKeys=i,this.forceFloat32=o,this.ignoreUndefined=a,this.forceIntegerToFloat=s,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}return e.prototype.reinitializeState=function(){this.pos=0},e.prototype.encodeSharedRef=function(e){return this.reinitializeState(),this.doEncode(e,1),this.bytes.subarray(0,this.pos)},e.prototype.encode=function(e){return this.reinitializeState(),this.doEncode(e,1),this.bytes.slice(0,this.pos)},e.prototype.doEncode=function(e,t){if(t>this.maxDepth)throw new Error("Too deep objects in depth ".concat(t));null===e?this.encodeNil():void 0===e?this.encodeUndefined():"boolean"==typeof e?this.encodeBoolean(e):"number"==typeof e?this.encodeNumber(e):"string"==typeof e?this.encodeString(e):this.encodeObject(e,t)},e.prototype.ensureBufferSizeToWrite=function(e){var t=this.pos+e;this.view.byteLength<t&&this.resizeBuffer(2*t)},e.prototype.resizeBuffer=function(e){var t=new ArrayBuffer(e),r=new Uint8Array(t),n=new DataView(t);r.set(this.bytes),this.view=n,this.bytes=r},e.prototype.encodeNil=function(){this.writeU8(192)},e.prototype.encodeUndefined=function(){this.writeU8(193)},e.prototype.encodeBoolean=function(e){!1===e?this.writeU8(194):this.writeU8(195)},e.prototype.encodeNumber=function(e){Number.isSafeInteger(e)&&!this.forceIntegerToFloat?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):(this.writeU8(211),this.writeI64(e)):this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))},e.prototype.writeStringHeader=function(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else{if(!(e<4294967296))throw new Error("Too long string: ".concat(e," bytes in UTF-8"));this.writeU8(219),this.writeU32(e)}},e.prototype.encodeString=function(e){if(e.length>E){var t=b(e);this.ensureBufferSizeToWrite(5+t),this.writeStringHeader(t),P(e,this.bytes,this.pos),this.pos+=t}else{t=b(e);this.ensureBufferSizeToWrite(5+t),this.writeStringHeader(t),function(e,t,r){for(var n=e.length,i=r,o=0;o<n;){var a=e.charCodeAt(o++);if(0!=(4294967168&a)){if(0==(4294965248&a))t[i++]=a>>6&31|192;else{if(a>=55296&&a<=56319&&o<n){var s=e.charCodeAt(o);56320==(64512&s)&&(++o,a=((1023&a)<<10)+(1023&s)+65536)}0==(4294901760&a)?(t[i++]=a>>12&15|224,t[i++]=a>>6&63|128):(t[i++]=a>>18&7|240,t[i++]=a>>12&63|128,t[i++]=a>>6&63|128)}t[i++]=63&a|128}else t[i++]=a}}(e,this.bytes,this.pos),this.pos+=t}},e.prototype.encodeObject=function(e,t){var r=this.extensionCodec.tryToEncode(e,this.context);if(null!=r)this.encodeExtension(r);else if(Array.isArray(e))this.encodeArray(e,t);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else{if("object"!==o(e))throw new Error("Unrecognized object: ".concat(Object.prototype.toString.apply(e)));this.encodeMap(e,t)}},e.prototype.encodeBinary=function(e){var t=e.byteLength;if(t<256)this.writeU8(196),this.writeU8(t);else if(t<65536)this.writeU8(197),this.writeU16(t);else{if(!(t<4294967296))throw new Error("Too large binary: ".concat(t));this.writeU8(198),this.writeU32(t)}var r,n=(r=e)instanceof Uint8Array?r:ArrayBuffer.isView(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r instanceof ArrayBuffer?new Uint8Array(r):Uint8Array.from(r);this.writeU8a(n)},e.prototype.encodeArray=function(e,t){var r=e.length;if(r<16)this.writeU8(144+r);else if(r<65536)this.writeU8(220),this.writeU16(r);else{if(!(r<4294967296))throw new Error("Too large array: ".concat(r));this.writeU8(221),this.writeU32(r)}for(var n=0,i=e;n<i.length;n++){var o=i[n];this.doEncode(o,t+1)}},e.prototype.countWithoutUndefined=function(e,t){for(var r=0,n=0,i=t;n<i.length;n++){void 0!==e[i[n]]&&r++}return r},e.prototype.encodeMap=function(e,t){var r=Object.keys(e);this.sortKeys&&r.sort();var n=this.ignoreUndefined?this.countWithoutUndefined(e,r):r.length;if(n<16)this.writeU8(128+n);else if(n<65536)this.writeU8(222),this.writeU16(n);else{if(!(n<4294967296))throw new Error("Too large map object: ".concat(n));this.writeU8(223),this.writeU32(n)}for(var i=0,o=r;i<o.length;i++){var a=o[i],s=e[a];this.ignoreUndefined&&void 0===s||(this.encodeString(a),this.doEncode(s,t+1))}},e.prototype.encodeExtension=function(e){var t=e.data.length;if(1===t)this.writeU8(212);else if(2===t)this.writeU8(213);else if(4===t)this.writeU8(214);else if(8===t)this.writeU8(215);else if(16===t)this.writeU8(216);else if(t<256)this.writeU8(199),this.writeU8(t);else if(t<65536)this.writeU8(200),this.writeU16(t);else{if(!(t<4294967296))throw new Error("Too large extension object: ".concat(t));this.writeU8(201),this.writeU32(t)}this.writeI8(e.type),this.writeU8a(e.data)},e.prototype.writeU8=function(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++},e.prototype.writeU8a=function(e){var t=e.length;this.ensureBufferSizeToWrite(t),this.bytes.set(e,this.pos),this.pos+=t},e.prototype.writeI8=function(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++},e.prototype.writeU16=function(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2},e.prototype.writeI16=function(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2},e.prototype.writeU32=function(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4},e.prototype.writeI32=function(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4},e.prototype.writeF32=function(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4},e.prototype.writeF64=function(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8},e.prototype.writeU64=function(e){this.ensureBufferSizeToWrite(8),function(e,t,r){var n=r/4294967296,i=r;e.setUint32(t,n),e.setUint32(t+4,i)}(this.view,this.pos,e),this.pos+=8},e.prototype.writeI64=function(e){this.ensureBufferSizeToWrite(8),w(this.view,this.pos,e),this.pos+=8},e}(),R={};function D(e,t){var r;return void 0===t&&(t={}),function(e,t){return void 0===t&&(t=R),new U(t.extensionCodec,t.context,t.maxDepth,t.initialBufferSize,t.sortKeys,t.forceFloat32,t.ignoreUndefined,t.forceIntegerToFloat).encodeSharedRef(e)}(e,{maxDepth:25,sortKeys:null!==(r=t.sortKeys)&&void 0!==r&&r})}function j(e){for(var t=D(e,{sortKeys:!0}),r=0,n=0;n<t.length;n++)r+=t[n];return r}function x(e,t){var r=new Error("[GAMES_SDK][".concat(e,"]"));return t&&(r.extraLoggingData=t),r}var k={};Object.defineProperty(k,"__esModule",{value:!0});var C,z=k.default=function e(t){if("object"!==o(t)||null===t)return t;if(Array.isArray(t))return t.map((function(t){return"object"!==o(t)||null===t?t:e(t)}));var r={};for(var n in t){var i=t[n];r[n]="object"!==o(i)||null===i?i:e(i)}return r},N="remove",L="replace",B="add",F=Symbol.for("__MUTATIVE_PROXY_DRAFT__"),W=Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"),q=Symbol.iterator,G={mutable:"mutable",immutable:"immutable"},V={};function K(e){var t;return null!==(t=e.copy)&&void 0!==t?t:e.original}function H(e){return!!Y(e)}function Y(e){return"object"!==o(e)?null:null==e?void 0:e[F]}function J(e){var t,r=Y(e);return r?null!==(t=r.copy)&&void 0!==t?t:r.original:e}function X(e,t){return!(!e||"object"!==o(e))&&(Object.getPrototypeOf(e)===Object.prototype||Array.isArray(e)||e instanceof Map||e instanceof Set||!!(null==t?void 0:t.mark)&&((r=t.mark(e,G))===G.immutable||"function"==typeof r));var r}function Q(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(Object.hasOwnProperty.call(e,"key")){var r=Y($(e.parent.copy,e.key));if(null!==r&&(null==r?void 0:r.original)!==e.original)return null;t.push(3===e.parent.type?Array.from(e.parent.setMap.keys()).indexOf(e.key):e.key)}return e.parent?Q(e.parent,t):t.reverse()}function Z(e){return Array.isArray(e)?1:e instanceof Map?2:e instanceof Set?3:0}function $(e,t){return 2===Z(e)?e.get(t):e[t]}function ee(e,t,r){2===Z(e)?e.set(t,r):e[t]=r}function te(e,t){var r=Y(e);return(r?K(r):e)[t]}function re(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function ne(e){if(e)for(;e.finalities.revoke.length>0;){e.finalities.revoke.pop()()}}function ie(e,t){return t?e:[""].concat(e).map((function(e){var t="".concat(e);return-1===t.indexOf("/")&&-1===t.indexOf("~")?t:t.replace(/~/g,"~0").replace(/\//g,"~1")})).join("/")}var oe=Object.prototype.propertyIsEnumerable;function ae(e,t){var r;if(Array.isArray(e))return Array.prototype.concat.call(e);if(e instanceof Set)return new Set(e.values());if(e instanceof Map)return new Map(e);if((null==t?void 0:t.mark)&&void 0!==(r=t.mark(e,G))&&r!==G.mutable){if(r===G.immutable)return function(e){var t=Object.create(Object.getPrototypeOf(e));return Reflect.ownKeys(e).forEach((function(r){var n=Reflect.getOwnPropertyDescriptor(e,r);n.enumerable&&n.configurable&&n.writable?t[r]=e[r]:(n.writable||(n.writable=!0,n.configurable=!0),(n.get||n.set)&&(n={configurable:!0,writable:!0,enumerable:n.enumerable,value:e[r]}),Reflect.defineProperty(t,r,n))})),t}(e);if("function"==typeof r){if(t.enablePatches||t.enableAutoFreeze)throw new Error("You can't use mark and patches or auto freeze together.");return r()}throw new Error("Unsupported mark result: ".concat(r))}if("object"===o(e)&&Object.getPrototypeOf(e)===Object.prototype){var n={};return Object.keys(e).forEach((function(t){n[t]=e[t]})),Object.getOwnPropertySymbols(e).forEach((function(t){oe.call(e,t)&&(n[t]=e[t])})),n}throw new Error("Please check mark() to ensure that it is a stable marker draftable function.")}function se(e){e.copy||(e.copy=ae(e.original,e.options))}function ue(e){if(!X(e))return J(e);if(Array.isArray(e))return e.map(ue);if(e instanceof Map)return new Map(Array.from(e.entries()).map((function(e){var t=n(e,2);return[t[0],ue(t[1])]})));if(e instanceof Set)return new Set(Array.from(e).map(ue));var t=Object.create(Object.getPrototypeOf(e));for(var r in e)t[r]=ue(e[r]);return t}function le(e){return H(e)?ue(e):e}function ce(e){var t;e.assignedMap=null!==(t=e.assignedMap)&&void 0!==t?t:new Map,e.operated||(e.operated=!0,e.parent&&ce(e.parent))}function fe(){throw new Error("Cannot modify frozen object")}function pe(e,r,i,a,s){i=null!=i?i:new WeakMap,a=null!=a?a:[],s=null!=s?s:[];var u=i.has(e)?i.get(e):e;if(a.length>0){var l=a.indexOf(u);if(u&&"object"===o(u)&&-1!==l){if(a[0]===u)throw new Error("Forbids circular reference");throw new Error("Forbids circular reference: ~/".concat(s.slice(0,l).map((function(e,t){if("symbol"===o(e))return"[".concat(e.toString(),"]");var r=a[t];return"object"===o(e)&&(r instanceof Map||r instanceof Set)?Array.from(r.keys()).indexOf(e):e})).join("/")))}a.push(u),s.push(r)}else a.push(u);if(Object.isFrozen(e)||H(e))return a.pop(),void s.pop();switch(Z(e)){case 2:var c,f=t(e);try{for(f.s();!(c=f.n()).done;){var p=n(c.value,2),d=p[0],h=p[1];pe(d,d,i,a,s),pe(h,d,i,a,s)}}catch(e){f.e(e)}finally{f.f()}e.set=e.clear=e.delete=fe;break;case 3:var v,y=t(e);try{for(y.s();!(v=y.n()).done;){var g=v.value;pe(g,g,i,a,s)}}catch(e){y.e(e)}finally{y.f()}e.add=e.clear=e.delete=fe;break;case 1:Object.freeze(e);var w,m=0,b=t(e);try{for(b.s();!(w=b.n()).done;){pe(w.value,m,i,a,s),m+=1}}catch(e){b.e(e)}finally{b.f()}break;default:Object.freeze(e),Object.keys(e).forEach((function(t){pe(e[t],t,i,a,s)}))}a.pop(),s.pop()}function de(e,t){return e instanceof Map?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function he(e,t){if(t in e)for(var r=Reflect.getPrototypeOf(e);r;){var n=Reflect.getOwnPropertyDescriptor(r,t);if(n)return n;r=Reflect.getPrototypeOf(r)}}function ve(e,r){var n=Z(e);if(0===n)Reflect.ownKeys(e).forEach((function(t){r(t,e[t],e)}));else if(1===n){var i,o=0,a=t(e);try{for(a.s();!(i=a.n()).done;){var s=i.value;r(o,s,e),o+=1}}catch(e){a.e(e)}finally{a.f()}}else e.forEach((function(t,n){return r(n,t,e)}))}function ye(e,t,r){if(!H(e)&&X(e,r)&&!t.has(e)&&!Object.isFrozen(e)){var n=e instanceof Set,i=n?new Map:void 0;if(t.add(e),ve(e,(function(o,a){var s;if(H(a)){var u=Y(a);se(u);var l=(null===(s=u.assignedMap)||void 0===s?void 0:s.size)||u.operated?u.copy:u.original;ee(n?i:e,o,l)}else ye(a,t,r)})),i){var o=e,a=Array.from(o);o.clear(),a.forEach((function(e){o.add(i.has(e)?i.get(e):e)}))}}}function ge(e,t){var r=3===e.type?e.setMap:e.copy;e.finalities.revoke.length>1&&e.assignedMap.get(t)&&r&&ye($(r,t),e.finalities.handledSet,e.options)}function we(e){3===e.type&&e.copy&&(e.copy.clear(),e.setMap.forEach((function(t){e.copy.add(J(t))})))}function me(e,t,r,n){if(e.operated&&e.assignedMap&&e.assignedMap.size>0&&!e.finalized){if(r&&n){var i=Q(e);i&&t(e,i,r,n)}e.finalized=!0}}function be(e,t,r,n){var i=Y(r);i&&(i.callbacks||(i.callbacks=[]),i.callbacks.push((function(o,a){var s,u=3===e.type?e.setMap:e.copy;if(re($(u,t),r)){var l=i.original;i.copy&&(l=i.copy),we(e),me(e,n,o,a),e.options.enableAutoFreeze&&(e.options.updatedValues=null!==(s=e.options.updatedValues)&&void 0!==s?s:new WeakMap,e.options.updatedValues.set(l,i.original)),ee(u,t,l)}})),e.options.enableAutoFreeze&&i.finalities!==e.finalities&&(e.options.enableAutoFreeze=!1)),X(r,e.options)&&e.finalities.draft.push((function(){re($(3===e.type?e.setMap:e.copy,t),r)&&ge(e,t)}))}function Se(e,t,r,n){var i=e.options.enablePatches.pathAsArray,o=void 0===i||i;switch(e.type){case 0:case 2:return function(e,t,r,n,i){var o=e.original,a=e.copy;e.assignedMap.forEach((function(e,s){var u=$(o,s),l=le($(a,s)),c=e?de(o,s)?L:B:N;if(!re(u,l)||c!==L){var f=ie(t.concat(s),i);r.push(c===N?{op:c,path:f}:{op:c,path:f,value:l}),n.push(c===B?{op:N,path:f}:c===N?{op:B,path:f,value:u}:{op:L,path:f,value:u})}}))}(e,t,r,n,o);case 1:return function(e,t,r,n,i){var o=e.original,a=e.assignedMap,s=e.options,u=e.copy;if(u.length<o.length){var l=[u,o];o=l[0],u=l[1];var c=[n,r];r=c[0],n=c[1]}for(var f=0;f<o.length;f+=1)if(a.get(f.toString())&&u[f]!==o[f]){var p=ie(t.concat([f]),i);r.push({op:L,path:p,value:le(u[f])}),n.push({op:L,path:p,value:le(o[f])})}for(var d=o.length;d<u.length;d+=1){var h=ie(t.concat([d]),i);r.push({op:B,path:h,value:le(u[d])})}if(o.length<u.length){var v=s.enablePatches.arrayLengthAssignment;if(void 0===v||v){var y=ie(t.concat(["length"]),i);n.push({op:L,path:y,value:o.length})}else for(var g=u.length;o.length<g;g-=1){var w=ie(t.concat([g-1]),i);n.push({op:N,path:w})}}}(e,t,r,n,o);case 3:return function(e,t,r,n,i){var o=e.original,a=e.copy,s=0;o.forEach((function(e){if(!a.has(e)){var o=ie(t.concat([s]),i);r.push({op:N,path:o,value:e}),n.unshift({op:B,path:o,value:e})}s+=1})),s=0,a.forEach((function(e){if(!o.has(e)){var a=ie(t.concat([s]),i);r.push({op:B,path:a,value:e}),n.unshift({op:N,path:a,value:e})}s+=1}))}(e,t,r,n,o)}}var Ee=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if("object"===o(e)&&null!==e&&(!X(e,t)||r))throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.")},Pe=r({get size(){return K(Y(this)).size},has:function(e){return K(Y(this)).has(e)},set:function(e,t){var r=Y(this),n=K(r);return n.has(e)&&re(n.get(e),t)||(se(r),ce(r),r.assignedMap.set(e,!0),r.copy.set(e,t),be(r,e,t,Se)),this},delete:function(e){if(!this.has(e))return!1;var t=Y(this);return se(t),ce(t),t.original.has(e)?t.assignedMap.set(e,!1):t.assignedMap.delete(e),t.copy.delete(e),!0},clear:function(){var e=Y(this);if(this.size){se(e),ce(e),e.assignedMap=new Map;var r,i=t(e.original);try{for(i.s();!(r=i.n()).done;){var o=n(r.value,1)[0];e.assignedMap.set(o,!1)}}catch(e){i.e(e)}finally{i.f()}e.copy.clear()}},forEach:function(e,t){var r=this;K(Y(this)).forEach((function(n,i){e.call(t,r.get(i),i,r)}))},get:function(e){var t,r,n=Y(this),i=K(n).get(e),o=(null===(r=(t=n.options).mark)||void 0===r?void 0:r.call(t,i,G))===G.mutable;if(n.options.strict&&Ee(i,n.options,o),o)return i;if(n.finalized||!X(i,n.options))return i;if(i!==n.original.get(e))return i;var a=V.createDraft({original:i,parentDraft:n,key:e,finalities:n.finalities,options:n.options});return se(n),n.copy.set(e,a),a},keys:function(){return K(Y(this)).keys()},values:function(){var e,t=this,n=this.keys();return r(e={},q,(function(){return t.values()})),r(e,"next",(function(){var e=n.next();return e.done?e:{done:!1,value:t.get(e.value)}})),e},entries:function(){var e,t=this,n=this.keys();return r(e={},q,(function(){return t.entries()})),r(e,"next",(function(){var e=n.next();if(e.done)return e;var r=t.get(e.value);return{done:!1,value:[e.value,r]}})),e}},q,(function(){return this.entries()})),Ae=Reflect.ownKeys(Pe),Oe=function(e,t,r){var n=r.isValuesIterator;return function(){var r,i,o=t.next();if(o.done)return o;var a=o.value,s=e.setMap.get(a),u=Y(s),l=(null===(i=(r=e.options).mark)||void 0===i?void 0:i.call(r,s,G))===G.mutable;if(e.options.strict&&Ee(a,e.options,l),l||u||!X(a,e.options)||e.finalized||!e.original.has(a))u&&(s=u.proxy);else{var c=V.createDraft({original:a,parentDraft:e,key:a,finalities:e.finalities,options:e.options});e.setMap.set(a,c),s=c}return{done:!1,value:n?s:[s,s]}}},Te=(C={get size(){return Y(this).setMap.size},has:function(e){var t=Y(this);if(t.setMap.has(e))return!0;se(t);var r=Y(e);return!(!r||!t.setMap.has(r.original))},add:function(e){var t=Y(this);return this.has(e)||(se(t),ce(t),t.assignedMap.set(e,!0),t.setMap.set(e,e),be(t,e,e,Se)),this},delete:function(e){if(!this.has(e))return!1;var t=Y(this);se(t),ce(t);var r=Y(e);return r&&t.setMap.has(r.original)?(t.assignedMap.set(r.original,!1),t.setMap.delete(r.original)):(!r&&t.setMap.has(e)?t.assignedMap.set(e,!1):t.assignedMap.delete(e),t.setMap.delete(e))},clear:function(){if(this.size){var e=Y(this);se(e),ce(e);var r,n=t(e.original);try{for(n.s();!(r=n.n()).done;){var i=r.value;e.assignedMap.set(i,!1)}}catch(e){n.e(e)}finally{n.f()}e.setMap.clear()}},values:function(){var e,t=this,n=Y(this);se(n);var i=n.setMap.keys();return r(e={},Symbol.iterator,(function(){return t.values()})),r(e,"next",Oe(n,i,{isValuesIterator:!0})),e},entries:function(){var e,t=this,n=Y(this);se(n);var i=n.setMap.keys();return r(e={},Symbol.iterator,(function(){return t.entries()})),r(e,"next",Oe(n,i,{isValuesIterator:!1})),e},keys:function(){return this.values()}},r(C,q,(function(){return this.values()})),r(C,"forEach",(function(e,t){for(var r=this.values(),n=r.next();!n.done;)e.call(t,n.value,n.value,this),n=r.next()})),C),Me=Reflect.ownKeys(Te),_e=new WeakSet,Ie={get:function(e,t,r){var n,i,o,a=null===(n=e.copy)||void 0===n?void 0:n[t];if(a&&_e.has(a))return a;if(t===F)return e;if(e.options.mark){var s="size"===t&&(e.original instanceof Map||e.original instanceof Set)?Reflect.get(e.original,t):Reflect.get(e.original,t,r);if((o=e.options.mark(s,G))===G.mutable)return e.options.strict&&Ee(s,e.options,!0),s}var u=K(e);if(u instanceof Map&&Ae.includes(t)){if("size"===t)return Object.getOwnPropertyDescriptor(Pe,"size").get.call(e.proxy);var l=Pe[t];if(l)return l.bind(e.proxy)}if(u instanceof Set&&Me.includes(t)){if("size"===t)return Object.getOwnPropertyDescriptor(Te,"size").get.call(e.proxy);var c=Te[t];if(c)return c.bind(e.proxy)}if(!de(u,t)){var f=he(u,t);return f?"value"in f?f.value:null===(i=f.get)||void 0===i?void 0:i.call(e.proxy):void 0}var p=u[t];if(e.options.strict&&Ee(p,e.options),e.finalized||!X(p,e.options))return p;if(p===te(e.original,t)){if(se(e),e.copy[t]=Ue({original:e.original[t],parentDraft:e,key:1===e.type?Number(t):t,finalities:e.finalities,options:e.options}),"function"==typeof o){var d=Y(e.copy[t]);return se(d),ce(d),d.copy}return e.copy[t]}return p},set:function(e,t,r){var n,i;if(3===e.type||2===e.type)throw new Error("Map/Set draft does not support any property assignment.");if(1===e.type&&"length"!==t&&(!(Number.isInteger(i=Number(t))&&i>=0)||0!==t&&0!==i&&String(i)!==String(t)))throw new Error("Only supports setting array indices and the 'length' property.");var o=he(K(e),t);if(null==o?void 0:o.set)return o.set.call(e.proxy,r),!0;var a=te(K(e),t),s=Y(a);return s&&re(s.original,r)?(e.copy[t]=r,e.assignedMap=null!==(n=e.assignedMap)&&void 0!==n?n:new Map,e.assignedMap.set(t,!1),!0):(re(r,a)&&(void 0!==r||de(e.original,t))||(se(e),ce(e),de(e.original,t)&&re(r,e.original[t])?e.assignedMap.delete(t):e.assignedMap.set(t,!0),e.copy[t]=r,be(e,t,r,Se)),!0)},has:function(e,t){return t in K(e)},ownKeys:function(e){return Reflect.ownKeys(K(e))},getOwnPropertyDescriptor:function(e,t){var r=K(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n?{writable:!0,configurable:1!==e.type||"length"!==t,enumerable:n.enumerable,value:r[t]}:n},getPrototypeOf:function(e){return Reflect.getPrototypeOf(e.original)},setPrototypeOf:function(){throw new Error("Cannot call 'setPrototypeOf()' on drafts")},defineProperty:function(){throw new Error("Cannot call 'defineProperty()' on drafts")},deleteProperty:function(e,t){var r;return 1===e.type?Ie.set.call(this,e,t,void 0,e.proxy):(void 0!==te(e.original,t)||t in e.original?(se(e),ce(e),e.assignedMap.set(t,!1)):(e.assignedMap=null!==(r=e.assignedMap)&&void 0!==r?r:new Map,e.assignedMap.delete(t)),e.copy&&delete e.copy[t],!0)}};function Ue(e){var t=e.original,r=e.parentDraft,n=e.key,i=e.finalities,o=e.options,a=Z(t),s={type:a,finalized:!1,parent:r,original:t,copy:null,proxy:null,finalities:i,options:o,setMap:3===a?new Map(t.entries()):void 0};(n||"key"in e)&&(s.key=n);var u=Proxy.revocable(1===a?Object.assign([],s):s,Ie),l=u.proxy,c=u.revoke;if(i.revoke.push(c),_e.add(l),s.proxy=l,r){var f=r;f.finalities.draft.push((function(e,t){var r,i,o=Y(l),a=3===f.type?f.setMap:f.copy,s=$(a,n),u=Y(s);if(u){var c=u.original;u.operated&&(c=J(s)),we(u),me(u,Se,e,t),f.options.enableAutoFreeze&&(f.options.updatedValues=null!==(r=f.options.updatedValues)&&void 0!==r?r:new WeakMap,f.options.updatedValues.set(c,u.original)),ee(a,n,c)}null===(i=o.callbacks)||void 0===i||i.forEach((function(r){r(e,t)}))}))}else{var p=Y(l);p.finalities.draft.push((function(e,t){we(p),me(p,Se,e,t)}))}return l}function Re(e,t,r,n,i){var o,a=Y(e),s=null!==(o=null==a?void 0:a.original)&&void 0!==o?o:e,u=!!t.length;if(null==a?void 0:a.operated)for(;a.finalities.draft.length>0;){a.finalities.draft.pop()(r,n)}var l=u?t[0]:a?a.operated?a.copy:a.original:e;return a&&ne(a),i&&pe(l,l,null==a?void 0:a.options.updatedValues),[l,r&&u?[{op:L,path:[],value:t[0]}]:r,n&&u?[{op:L,path:[],value:s}]:n]}function De(e){var t=e.rootDraft,r=e.value,n=e.useRawReturn,i=void 0!==n&&n,a=e.isRoot,s=void 0===a||a;ve(r,(function(r,n,i){var a=Y(n);if(a&&t&&a.finalities===t.finalities){e.isContainDraft=!0;var s=a.original;if(i instanceof Set){var u=Array.from(i);i.clear(),u.forEach((function(e){return i.add(r===e?s:e)}))}else ee(i,r,s)}else"object"===o(n)&&null!==n&&(e.value=n,e.isRoot=!1,De(e))})),s&&(e.isContainDraft||console.warn("The return value does not contain any draft, please use 'rawReturn()' to wrap the return value to improve performance."),i&&console.warn("The return value contains drafts, please don't use 'rawReturn()' to wrap the return value."))}function je(e){var t=Y(e);if(!X(e,null==t?void 0:t.options))return e;var r,n=Z(e);if(t&&!t.operated)return t.original;t&&(t.finalized=!0);try{r=2===n?new Map(e):3===n?Array.from(t.setMap.values()):ae(e,null==t?void 0:t.options)}finally{t&&(t.finalized=!1)}return ve(r,(function(e,n){t&&re($(t.original,e),n)||ee(r,e,je(n))})),3===n?new Set(r):r}function xe(e){if(!H(e))throw new Error("current() is only used for Draft, parameter: ".concat(e));return je(e)}V.createDraft=Ue;var ke=function(e){if(void 0!==e&&"[object Object]"!==Object.prototype.toString.call(e))throw new Error("Invalid options: ".concat(String(e),", 'options' should be an object."));return function r(i,a,s){var u,l,c;if("function"==typeof i&&"function"!=typeof a)return function(e){for(var t=this,n=arguments.length,o=new Array(n>1?n-1:0),s=1;s<n;s++)o[s-1]=arguments[s];return r(e,(function(e){return i.call.apply(i,[t,e].concat(o))}),a)};var f=i,p=a,d=s;if("function"!=typeof a&&(d=a),void 0!==d&&"[object Object]"!==Object.prototype.toString.call(d))throw new Error("Invalid options: ".concat(d,", 'options' should be an object."));d=Object.assign(Object.assign({},e),d);var h=H(f)?xe(f):f,v=Array.isArray(d.mark)?function(e,r){var n,i=t(d.mark);try{for(i.s();!(n=i.n()).done;){var o=n.value;if("function"!=typeof o)throw new Error("Invalid mark: ".concat(o,", 'mark' should be a function."));var a=o(e,r);if(a)return a}}catch(e){i.e(e)}finally{i.f()}}:d.mark,y=null!==(u=d.enablePatches)&&void 0!==u&&u,g=null!==(l=d.strict)&&void 0!==l&&l,w={enableAutoFreeze:null!==(c=d.enableAutoFreeze)&&void 0!==c&&c,mark:v,strict:g,enablePatches:y};if(!X(h,w)&&"object"===o(h)&&null!==h)throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");var m,b=function(e,t){var r,i,o,a={draft:[],revoke:[],handledSet:new WeakSet};t.enablePatches&&(i=[],o=[]);var s=(null===(r=t.mark)||void 0===r?void 0:r.call(t,e,G))!==G.mutable&&X(e,t)?Ue({original:e,parentDraft:null,finalities:a,options:t}):e;return[s,function(){var e=n(Re(s,arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],i,o,t.enableAutoFreeze),3),r=e[0],a=e[1],u=e[2];return t.enablePatches?[r,a,u]:r}]}(h,w),S=n(b,2),E=S[0],P=S[1];if("function"!=typeof a){if(!X(h,w))throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");return[E,P]}try{m=p(E)}catch(e){throw ne(Y(E)),e}var A=function(e){var t=Y(E);if(!H(e)){if(void 0!==e&&!re(e,E)&&(null==t?void 0:t.operated))throw new Error("Either the value is returned as a new non-draft value, or only the draft is modified without returning any value.");var r=null==e?void 0:e[W];if(r){var n=r[0];return w.strict&&"object"===o(e)&&null!==e&&De({rootDraft:t,value:e,useRawReturn:!0}),P([n])}if(void 0!==e)return"object"===o(e)&&null!==e&&De({rootDraft:t,value:e}),P([e])}if(e===E||void 0===e)return P([]);var i=Y(e);if(w===i.options){if(i.operated)throw new Error("Cannot return a modified child draft.");return P([xe(e)])}return P([e])};return m instanceof Promise?m.then(A,(function(e){throw ne(Y(E)),e})):A(m)}}();function Ce(e,t,r){if(!r){var n=z(e);return t(n),n}return ke(e,t,{mark:function(){return"immutable"}})}Object.prototype.constructor.toString();var ze=new Map;function Ne(e){var t=ze.get(e);if(!t)throw new Error("[GAMES_SDK][ROOM_GAME_STATE_MISSING]");return t}function Le(e,t){ze.set(e,t)}function Be(e){ze.delete(e)}function Fe(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}function We(e,t){if(!e.persisted)throw x("PERSISTED_KEY_MISSING");if(!Fe(e.persisted))throw x("PERSISTED_NOT_AN_OBJECT");t.forEach((function(t){if(!e.persisted[t])throw x("PERSISTED_PLAYER_MISSING",{playerId:t});if(!Fe(e.persisted[t]))throw x("PERSISTED_PLAYER_NOT_AN_OBJECT",{playerId:t});var r,n,i,o=(r=e.persisted[t],n=100,{size:i=(JSON.stringify(r)||"").length,underLimit:i<1024*n});if(!o.underLimit)throw x("PERSISTED_PLAYER_OVER_LIMIT",{playerId:t,limit:100,size:o.size})})),Object.keys(e.persisted).forEach((function(e){if(!t.includes(e))throw x("PERSISTED_EXTRA_KEY_DETECTED",{key:e})}))}function qe(e){for(var t=Ke(this,e),r=0;r<this.length;r++)this[r]=t[r];return this}var Ge=function(e,t){if(void 0===e&&void 0===t)return 0;if(void 0===e)return 1;if(void 0===t)return-1;var r=Ve(e),n=Ve(t);return r<n?-1:r>n?1:0},Ve=function(e){if(null===e)return"null";if("boolean"==typeof e||"number"==typeof e)return e.toString();if("string"==typeof e)return e;if("symbol"==typeof e)throw new TypeError;return e.toString()};function Ke(e,t){if(void 0===t&&(t=Ge),e.length<=1)return e;var r=Math.floor(e.length/2),n=e.slice(0,r),i=e.slice(r);return function(e,t,r){var n=[];for(;e.length&&t.length;)r(e[0],t[0])<=0?n.push(e.shift()):n.push(t.shift());return n.concat(e,t)}(Ke(n,t),Ke(i,t),t)}function He(e,t){var r,n=globalThis.Math.random;globalThis.Math.random=(r=e,function(){var e=r+=1831565813;return e=Math.imul(e^e>>>15,1|e),(((e^=e+Math.imul(e^e>>>7,61|e))^e>>>14)>>>0)/4294967296});var i=globalThis.Array.prototype.sort;globalThis.Array.prototype.sort=qe;try{return t()}finally{globalThis.Math.random=n,globalThis.Array.prototype.sort=i}}function Ye(e,t,r){return e.state.gameOverContext=null,e.state.aiPromptRequest=null,e.context=t,He(t.randomSeed,r)}function Je(e,t,r,n,i,o,a,s,u){return Ye(e,n,(function(){try{var n=Ne(r),l=Ce(n,i,e.gameConfig.reactive);if("runtime"!==t){if(!u&&l.persisted)throw x("PERSISTED_STATE_USED_WITHOUT_FLAG");n.persisted!==l.persisted&&We(l,o)}return Le(r,l),{data:{gameContext:{gameOver:e.state.gameOverContext},stateHash:a?j(l):void 0},aiPromptRequest:e.state.aiPromptRequest}}catch(e){if(s&&(function(e){return"object"==typeof e&&null!==e&&"name"in e}(c=e)&&("RUNE_INVALID_ACTION"===c.name||"DUSK_INVALID_ACTION"===c.name)))return{data:!1,aiPromptRequest:null};if("[GAMES_SDK][ROOM_GAME_STATE_MISSING]"===e.message)return{error:e.message};throw Be(r),e}var c}))}function Xe(e,t){var r,n,i,o={state:{gameOverContext:null,aiPromptRequest:null},context:{msPerTick:0,logicTick:0,randomSeed:0,serverStartedAt:0},initParams:e,gameConfig:{minPlayers:e.minPlayers,maxPlayers:e.maxPlayers,eventCallbacks:{playerJoined:!!(null===(r=e.events)||void 0===r?void 0:r.playerJoined),playerLeft:!!(null===(n=e.events)||void 0===n?void 0:n.playerLeft)},update:!!e.update,updatesPerSecond:e.updatesPerSecond||1,landscape:null!==(i=e.landscape)&&void 0!==i&&i,persistPlayerData:e.persistPlayerData||!1,reactive:void 0===e.reactive||e.reactive},getConfig:function(){return o.gameConfig},runSetup:function(r){var n=r.roomId,i=r.logicContext,a=r.playerIds,s=r.calculateStateHash,u=r.persistedPlayers;return Ye(o,i,(function(){var r,i,l,c,f=(null===(r=o.gameConfig)||void 0===r?void 0:r.persistPlayerData)&&null!==u;f?(l={persisted:u},a.forEach((function(e){l.persisted[e]||(l.persisted[e]={})}))):l={};var p=Ce(l,(function(t){var r;c=null!==(r=e.setup(a,f?{game:t}:void 0))&&void 0!==r?r:{}}),o.gameConfig.reactive);if("runtime"!==t){if(c.persisted)throw x("SETUP_PERSISTED_KEY_NOT_ALLOWED");(null===(i=o.gameConfig)||void 0===i?void 0:i.persistPlayerData)&&p.persisted!==l.persisted&&We(p,a)}var d=Ce(c||{},(function(e){var t;(null===(t=o.gameConfig)||void 0===t?void 0:t.persistPlayerData)&&(e.persisted=p.persisted)}),o.gameConfig.reactive);if(Le(n,d),o.state.gameOverContext)throw x("SETUP_GAME_OVER_NOT_ALLOWED");return{data:{gameState:d,stateHash:s?j(d):void 0},aiPromptRequest:o.state.aiPromptRequest}}))},runAction:function(e,r){var n,i=r.roomId,a=r.logicContext,s=r.params,u=r.actionContext,l=r.calculateStateHash;return Je(o,t,i,a,(function(t){o.initParams.actions[e](s,p(p({},u),{game:t}))}),u.allPlayerIds,l,!0,(null===(n=o.gameConfig)||void 0===n?void 0:n.persistPlayerData)||!1)},runUpdate:function(r){var n,i=r.roomId,a=r.logicContext,s=r.updateContext;return Je(o,t,i,a,(function(t){var r;null===(r=e.update)||void 0===r||r.call(e,p(p({},s),{game:t}))}),s.allPlayerIds,!1,!1,(null===(n=o.gameConfig)||void 0===n?void 0:n.persistPlayerData)||!1)},runPlayerJoinedEvent:function(r){var n,i,a=r.roomId,s=r.logicContext,u=r.playerId,l=r.persistedPlayerState,c=r.eventContext,f=r.calculateStateHash,d=Ne(a);(null===(n=o.gameConfig)||void 0===n?void 0:n.persistPlayerData)&&null!==l&&Le(a,Ce(d,(function(e){e.persisted[u]=l}),o.gameConfig.reactive));return Je(o,t,a,s,(function(t){var r,n;null===(n=null===(r=e.events)||void 0===r?void 0:r.playerJoined)||void 0===n||n.call(r,u,p(p({},c),{game:t}))}),c.allPlayerIds,f,!1,(null===(i=o.gameConfig)||void 0===i?void 0:i.persistPlayerData)||!1)},runPlayerLeftEvent:function(r){var n,i,a,s,u,l=r.roomId,c=r.logicContext,f=r.playerId,h=r.eventContext,v=r.calculateStateHash,y=Je(o,t,l,c,(function(t){var r,n;null===(n=null===(r=e.events)||void 0===r?void 0:r.playerLeft)||void 0===n||n.call(r,f,p(p({},h),{game:t}))}),d(d([],function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)a.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return a}(h.allPlayerIds),!1),[f],!1),!1,!1,(null===(i=o.gameConfig)||void 0===i?void 0:i.persistPlayerData)||!1);if(null===(a=o.gameConfig)||void 0===a?void 0:a.persistPlayerData){var g=Ne(l);u=g.persisted[f],Le(l,Ce(g,(function(e){delete e.persisted[f]}),o.gameConfig.reactive))}var w=void 0;return v&&(w=j(Ne(l))),"data"in y?{data:p(p({},y.data),{stateHash:w,persistedPlayers:(null===(s=o.gameConfig)||void 0===s?void 0:s.persistPlayerData)&&u?(n={},n[f]=u,n):null}),aiPromptRequest:o.state.aiPromptRequest}:p(p({},y),{aiPromptRequest:o.state.aiPromptRequest})},runAIPromptResponseEvent:function(r){var n,i=r.roomId,a=r.logicContext,s=r.aiPromptResponse,u=r.eventContext,l=r.calculateStateHash,c=Je(o,t,i,a,(function(t){var r,n;null===(n=null===(r=e.ai)||void 0===r?void 0:r.promptResponse)||void 0===n||n.call(r,s,p(p({},u),{game:t}))}),u.allPlayerIds,l,!1,(null===(n=o.gameConfig)||void 0===n?void 0:n.persistPlayerData)||!1);return"data"in c?{data:c.data,aiPromptRequest:o.state.aiPromptRequest}:p(p({},c),{aiPromptRequest:o.state.aiPromptRequest})},getGameState:function(e,t){try{var r=Ne(e);return{data:{gameState:Ne(e),stateHash:t?j(r):void 0},aiPromptRequest:null}}catch(e){if("[GAMES_SDK][ROOM_GAME_STATE_MISSING]"===e.message)return{error:e.message};throw e}},getPersistedData:function(e,t){var r;if(!(null===(r=o.gameConfig)||void 0===r?void 0:r.persistPlayerData))throw x("PERSISTED_STATE_NOT_ENABLED");var n=o.getGameState(e,!1);if("error"in n)return n;var i=n.data.gameState.persisted;if(!t)return{data:{persistedPlayers:i},aiPromptRequest:null};var a={};return t.forEach((function(e){a[e]=i[e]})),{data:{persistedPlayers:a},aiPromptRequest:null}},cleanup:function(e){Be(e)},rehydrate:function(e,t){Le(e,t)},getActionNames:function(){return e.actions?Object.keys(e.actions):[]}};return o}var Qe=function(e){globalThis.Math.__SDK_PRECISION_SET__||(l.forEach((function(e){var t,r;globalThis.Math[e]=(t=globalThis.Math,r=globalThis.Math[e],function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return t.fround(r.apply(t,e))})})),globalThis.Math.__SDK_PRECISION_SET__=!0);var t=void 0,r={initLogic:function(r){if(!r)throw new Error("initParams are required");"runtime"!==e&&function(e){if(e.minPlayers<1)throw new Error("minPlayers cannot be lower than 1");if(e.maxPlayers>6)throw new Error("maxPlayers cannot be greater than ".concat(6));if(e.maxPlayers<e.minPlayers)throw new Error("minPlayers cannot be greater than maxPlayers");if(void 0!==e.updatesPerSecond&&("number"!=typeof e.updatesPerSecond||e.updatesPerSecond<1||e.updatesPerSecond>30||!Number.isInteger(e.updatesPerSecond)))throw new Error("updatesPerSecond must be either not defined or a number between 1 & ".concat(30))}(r),t=Xe(r,e)},invalidAction:function(){return(e=new Error("".concat("Rune",".invalidAction() was called"))).name=u,e;var e},gameOver:function(e){if(!t)throw new Error("INIT_LOGIC_NOT_CALLED");t.state.gameOverContext={reason:"gameEnded",options:s(e),players:{}}},gameTime:function(){var e,r,n,i;if(!t)throw new Error("INIT_LOGIC_NOT_CALLED");return n=null!==(e=t.context.logicTick)&&void 0!==e?e:0,i=null!==(r=t.context.msPerTick)&&void 0!==r?r:0,n*i},worldTime:function(){if(!t)throw new Error("INIT_LOGIC_NOT_CALLED");return t.context.serverStartedAt+1e3*Math.floor(r.gameTime()/1e3)},gameTimeInSeconds:function(){return e=r.gameTime(),Math.floor(e/1e3);var e},ai:{promptRequest:function(e){var r;if(!(null===(r=null==t?void 0:t.initParams.ai)||void 0===r?void 0:r.promptResponse))throw x("AI_PROMPT_RESPONSE_NOT_DEFINED");if(!e||"object"!=typeof e||!("messages"in e)||"object"!=typeof e.messages||0===e.messages.length)throw x("AI_PROMPT_REQUEST_PARAM_WRONG_FORMAT",{promptRequestParam:e});e.messages.forEach((function(t){if(!t.content||!t.role)throw x("AI_PROMPT_REQUEST_PARAM_WRONG_FORMAT",{promptRequestParam:e});Array.isArray(t.content)&&t.content.forEach((function(t){if(t.type&&!["text","image_data"].includes(t.type))throw x("AI_PROMPT_REQUEST_PARAM_WRONG_FORMAT",{promptRequestParam:e});if("image_data"===t.type&&!t.image_url.startsWith("data:image"))throw x("AI_PROMPT_REQUEST_PARAM_WRONG_FORMAT",{promptRequestParam:e})}))}));var n=function(e){for(var t="",r=0;r<e;)t+=c.charAt(Math.floor(Math.random()*f)),r+=1;return t}(6);return t.state.aiPromptRequest={requestId:n,data:e},{requestId:n}}}};return{publicSdk:r,getLogicRunnerBindings:function(){return t}}}("runtime"),Ze=Qe.publicSdk,$e=Qe.getLogicRunnerBindings;globalThis.Rune=Ze,globalThis.Dusk=Ze,globalThis.RUNE_FUNCTION_PREFIX_getLogicRunnerBindings=$e}();