This repository has been archived by the owner on Jun 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgameservice-sdk.js
2 lines (2 loc) · 86 KB
/
gameservice-sdk.js
1
2
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("gameservice-sdk",[],t):"object"==typeof exports?exports["gameservice-sdk"]=t():e["gameservice-sdk"]=t()}(self,(function(){return(()=>{var e={9669:(e,t,i)=>{e.exports=i(1609)},5448:(e,t,i)=>{"use strict";var n=i(4867),s=i(6026),o=i(4372),r=i(1246),a=i(4097),h=i(4109),c=i(7985),u=i(5061);e.exports=function(e){return new Promise((function(t,i){var d=e.data,l=e.headers;n.isFormData(d)&&delete l["Content-Type"];var m=new XMLHttpRequest;if(e.auth){var p=e.auth.username||"",f=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";l.Authorization="Basic "+btoa(p+":"+f)}var v=a(e.baseURL,e.url);if(m.open(e.method.toUpperCase(),r(v,e.params,e.paramsSerializer),!0),m.timeout=e.timeout,m.onreadystatechange=function(){if(m&&4===m.readyState&&(0!==m.status||m.responseURL&&0===m.responseURL.indexOf("file:"))){var n="getAllResponseHeaders"in m?h(m.getAllResponseHeaders()):null,o={data:e.responseType&&"text"!==e.responseType?m.response:m.responseText,status:m.status,statusText:m.statusText,headers:n,config:e,request:m};s(t,i,o),m=null}},m.onabort=function(){m&&(i(u("Request aborted",e,"ECONNABORTED",m)),m=null)},m.onerror=function(){i(u("Network Error",e,null,m)),m=null},m.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),i(u(t,e,"ECONNABORTED",m)),m=null},n.isStandardBrowserEnv()){var T=(e.withCredentials||c(v))&&e.xsrfCookieName?o.read(e.xsrfCookieName):void 0;T&&(l[e.xsrfHeaderName]=T)}if("setRequestHeader"in m&&n.forEach(l,(function(e,t){void 0===d&&"content-type"===t.toLowerCase()?delete l[t]:m.setRequestHeader(t,e)})),n.isUndefined(e.withCredentials)||(m.withCredentials=!!e.withCredentials),e.responseType)try{m.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&m.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&m.upload&&m.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function(e){m&&(m.abort(),i(e),m=null)})),d||(d=null),m.send(d)}))}},1609:(e,t,i)=>{"use strict";var n=i(4867),s=i(1849),o=i(321),r=i(7185);function a(e){var t=new o(e),i=s(o.prototype.request,t);return n.extend(i,o.prototype,t),n.extend(i,t),i}var h=a(i(5655));h.Axios=o,h.create=function(e){return a(r(h.defaults,e))},h.Cancel=i(5263),h.CancelToken=i(4972),h.isCancel=i(6502),h.all=function(e){return Promise.all(e)},h.spread=i(8713),h.isAxiosError=i(6268),e.exports=h,e.exports.default=h},5263:e=>{"use strict";function t(e){this.message=e}t.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},t.prototype.__CANCEL__=!0,e.exports=t},4972:(e,t,i)=>{"use strict";var n=i(5263);function s(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var i=this;e((function(e){i.reason||(i.reason=new n(e),t(i.reason))}))}s.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},s.source=function(){var e;return{token:new s((function(t){e=t})),cancel:e}},e.exports=s},6502:e=>{"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},321:(e,t,i)=>{"use strict";var n=i(4867),s=i(1246),o=i(782),r=i(3572),a=i(7185);function h(e){this.defaults=e,this.interceptors={request:new o,response:new o}}h.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=a(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=[r,void 0],i=Promise.resolve(e);for(this.interceptors.request.forEach((function(e){t.unshift(e.fulfilled,e.rejected)})),this.interceptors.response.forEach((function(e){t.push(e.fulfilled,e.rejected)}));t.length;)i=i.then(t.shift(),t.shift());return i},h.prototype.getUri=function(e){return e=a(this.defaults,e),s(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},n.forEach(["delete","get","head","options"],(function(e){h.prototype[e]=function(t,i){return this.request(a(i||{},{method:e,url:t,data:(i||{}).data}))}})),n.forEach(["post","put","patch"],(function(e){h.prototype[e]=function(t,i,n){return this.request(a(n||{},{method:e,url:t,data:i}))}})),e.exports=h},782:(e,t,i)=>{"use strict";var n=i(4867);function s(){this.handlers=[]}s.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},s.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},s.prototype.forEach=function(e){n.forEach(this.handlers,(function(t){null!==t&&e(t)}))},e.exports=s},4097:(e,t,i)=>{"use strict";var n=i(1793),s=i(7303);e.exports=function(e,t){return e&&!n(t)?s(e,t):t}},5061:(e,t,i)=>{"use strict";var n=i(481);e.exports=function(e,t,i,s,o){var r=new Error(e);return n(r,t,i,s,o)}},3572:(e,t,i)=>{"use strict";var n=i(4867),s=i(8527),o=i(6502),r=i(5655);function a(e){e.cancelToken&&e.cancelToken.throwIfRequested()}e.exports=function(e){return a(e),e.headers=e.headers||{},e.data=s(e.data,e.headers,e.transformRequest),e.headers=n.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),n.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||r.adapter)(e).then((function(t){return a(e),t.data=s(t.data,t.headers,e.transformResponse),t}),(function(t){return o(t)||(a(e),t&&t.response&&(t.response.data=s(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))}},481:e=>{"use strict";e.exports=function(e,t,i,n,s){return e.config=t,i&&(e.code=i),e.request=n,e.response=s,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}},7185:(e,t,i)=>{"use strict";var n=i(4867);e.exports=function(e,t){t=t||{};var i={},s=["url","method","data"],o=["headers","auth","proxy","params"],r=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],a=["validateStatus"];function h(e,t){return n.isPlainObject(e)&&n.isPlainObject(t)?n.merge(e,t):n.isPlainObject(t)?n.merge({},t):n.isArray(t)?t.slice():t}function c(s){n.isUndefined(t[s])?n.isUndefined(e[s])||(i[s]=h(void 0,e[s])):i[s]=h(e[s],t[s])}n.forEach(s,(function(e){n.isUndefined(t[e])||(i[e]=h(void 0,t[e]))})),n.forEach(o,c),n.forEach(r,(function(s){n.isUndefined(t[s])?n.isUndefined(e[s])||(i[s]=h(void 0,e[s])):i[s]=h(void 0,t[s])})),n.forEach(a,(function(n){n in t?i[n]=h(e[n],t[n]):n in e&&(i[n]=h(void 0,e[n]))}));var u=s.concat(o).concat(r).concat(a),d=Object.keys(e).concat(Object.keys(t)).filter((function(e){return-1===u.indexOf(e)}));return n.forEach(d,c),i}},6026:(e,t,i)=>{"use strict";var n=i(5061);e.exports=function(e,t,i){var s=i.config.validateStatus;i.status&&s&&!s(i.status)?t(n("Request failed with status code "+i.status,i.config,null,i.request,i)):e(i)}},8527:(e,t,i)=>{"use strict";var n=i(4867);e.exports=function(e,t,i){return n.forEach(i,(function(i){e=i(e,t)})),e}},5655:(e,t,i)=>{"use strict";var n=i(4867),s=i(6016),o={"Content-Type":"application/x-www-form-urlencoded"};function r(e,t){!n.isUndefined(e)&&n.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var a,h={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(a=i(5448)),a),transformRequest:[function(e,t){return s(t,"Accept"),s(t,"Content-Type"),n.isFormData(e)||n.isArrayBuffer(e)||n.isBuffer(e)||n.isStream(e)||n.isFile(e)||n.isBlob(e)?e:n.isArrayBufferView(e)?e.buffer:n.isURLSearchParams(e)?(r(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):n.isObject(e)?(r(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};n.forEach(["delete","get","head"],(function(e){h.headers[e]={}})),n.forEach(["post","put","patch"],(function(e){h.headers[e]=n.merge(o)})),e.exports=h},1849:e=>{"use strict";e.exports=function(e,t){return function(){for(var i=new Array(arguments.length),n=0;n<i.length;n++)i[n]=arguments[n];return e.apply(t,i)}}},1246:(e,t,i)=>{"use strict";var n=i(4867);function s(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}e.exports=function(e,t,i){if(!t)return e;var o;if(i)o=i(t);else if(n.isURLSearchParams(t))o=t.toString();else{var r=[];n.forEach(t,(function(e,t){null!=e&&(n.isArray(e)?t+="[]":e=[e],n.forEach(e,(function(e){n.isDate(e)?e=e.toISOString():n.isObject(e)&&(e=JSON.stringify(e)),r.push(s(t)+"="+s(e))})))})),o=r.join("&")}if(o){var a=e.indexOf("#");-1!==a&&(e=e.slice(0,a)),e+=(-1===e.indexOf("?")?"?":"&")+o}return e}},7303:e=>{"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},4372:(e,t,i)=>{"use strict";var n=i(4867);e.exports=n.isStandardBrowserEnv()?{write:function(e,t,i,s,o,r){var a=[];a.push(e+"="+encodeURIComponent(t)),n.isNumber(i)&&a.push("expires="+new Date(i).toGMTString()),n.isString(s)&&a.push("path="+s),n.isString(o)&&a.push("domain="+o),!0===r&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},1793:e=>{"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},6268:e=>{"use strict";e.exports=function(e){return"object"==typeof e&&!0===e.isAxiosError}},7985:(e,t,i)=>{"use strict";var n=i(4867);e.exports=n.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),i=document.createElement("a");function s(e){var n=e;return t&&(i.setAttribute("href",n),n=i.href),i.setAttribute("href",n),{href:i.href,protocol:i.protocol?i.protocol.replace(/:$/,""):"",host:i.host,search:i.search?i.search.replace(/^\?/,""):"",hash:i.hash?i.hash.replace(/^#/,""):"",hostname:i.hostname,port:i.port,pathname:"/"===i.pathname.charAt(0)?i.pathname:"/"+i.pathname}}return e=s(window.location.href),function(t){var i=n.isString(t)?s(t):t;return i.protocol===e.protocol&&i.host===e.host}}():function(){return!0}},6016:(e,t,i)=>{"use strict";var n=i(4867);e.exports=function(e,t){n.forEach(e,(function(i,n){n!==t&&n.toUpperCase()===t.toUpperCase()&&(e[t]=i,delete e[n])}))}},4109:(e,t,i)=>{"use strict";var n=i(4867),s=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,i,o,r={};return e?(n.forEach(e.split("\n"),(function(e){if(o=e.indexOf(":"),t=n.trim(e.substr(0,o)).toLowerCase(),i=n.trim(e.substr(o+1)),t){if(r[t]&&s.indexOf(t)>=0)return;r[t]="set-cookie"===t?(r[t]?r[t]:[]).concat([i]):r[t]?r[t]+", "+i:i}})),r):r}},8713:e=>{"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},4867:(e,t,i)=>{"use strict";var n=i(1849),s=Object.prototype.toString;function o(e){return"[object Array]"===s.call(e)}function r(e){return void 0===e}function a(e){return null!==e&&"object"==typeof e}function h(e){if("[object Object]"!==s.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function c(e){return"[object Function]"===s.call(e)}function u(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),o(e))for(var i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.call(null,e[s],s,e)}e.exports={isArray:o,isArrayBuffer:function(e){return"[object ArrayBuffer]"===s.call(e)},isBuffer:function(e){return null!==e&&!r(e)&&null!==e.constructor&&!r(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:a,isPlainObject:h,isUndefined:r,isDate:function(e){return"[object Date]"===s.call(e)},isFile:function(e){return"[object File]"===s.call(e)},isBlob:function(e){return"[object Blob]"===s.call(e)},isFunction:c,isStream:function(e){return a(e)&&c(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&"undefined"!=typeof window&&"undefined"!=typeof document},forEach:u,merge:function e(){var t={};function i(i,n){h(t[n])&&h(i)?t[n]=e(t[n],i):h(i)?t[n]=e({},i):o(i)?t[n]=i.slice():t[n]=i}for(var n=0,s=arguments.length;n<s;n++)u(arguments[n],i);return t},extend:function(e,t,i){return u(t,(function(t,s){e[s]=i&&"function"==typeof t?n(t,i):t})),e},trim:function(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e}}},2454:function(e,t,i){"use strict";var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(s,o){function r(e){try{h(n.next(e))}catch(e){o(e)}}function a(e){try{h(n.throw(e))}catch(e){o(e)}}function h(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}h((n=n.apply(e,t||[])).next())}))},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Achievements=void 0;const o=i(7595),r=i(1563),a=s(i(9669));t.Achievements=class{constructor(e){this.superThis=e}GetAchievements(){return n(this,void 0,void 0,(function*(){try{let{data:e}=yield a.default.get(`${o.Url.Api.Endpoint}${o.Url.Api.GetAchievements}`,{headers:{"x-access-token":this.superThis.Authentication.gameToken}});return r.Log("GetAchievements",e),e.achievement}catch(e){throw e.response?e.response.data.msg:e}}))}Unlock(e){return n(this,void 0,void 0,(function*(){try{let{data:t}=yield a.default.post(`${o.Url.Api.Endpoint}${o.Url.Api.GetAchievementsv2}/${e}`,null,{headers:{"x-access-token":this.superThis.Authentication.gameToken}});return r.Log("Unlock",t),t.new}catch(e){throw e.response?e.response.data.msg:e}}))}}},8732:function(e,t,i){"use strict";var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(s,o){function r(e){try{h(n.next(e))}catch(e){o(e)}}function a(e){try{h(n.throw(e))}catch(e){o(e)}}function h(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}h((n=n.apply(e,t||[])).next())}))},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Assets=void 0;const o=i(7595),r=i(1563),a=s(i(9669));t.Assets=class{constructor(e){this.superThis=e}GetAssetInfo(e){return n(this,void 0,void 0,(function*(){try{let{data:t}=yield a.default.get(`${o.Url.Api.Endpoint}${o.Url.Api.DownloadAssets}/${this.superThis.ClientID}/datapack/?tag=${e}`,{headers:{"x-access-token":this.superThis.Authentication.gameToken}});return r.Log("GetAssetInfo",t),t.data}catch(e){throw e.response?e.response.data.msg:e}}))}}},9182:function(e,t,i){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[i]}})}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return s(t,e),t},r=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(s,o){function r(e){try{h(n.next(e))}catch(e){o(e)}}function a(e){try{h(n.throw(e))}catch(e){o(e)}}function h(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}h((n=n.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Authentication=void 0;const h=i(7595),c=i(1563),u=o(i(8827)),d=i(5877),l=a(i(9669));t.Authentication=class{constructor(e){this.superThis=e,this.userToken="",this.gameToken="",this.gameID=""}Login(e,t){return r(this,void 0,void 0,(function*(){try{let{data:i}=yield l.default.post(`${h.Url.Api.Endpoint}${h.Url.Api.Login}`,{email:e,password:t,device_id:d.v4()});return this.userToken=i.token,yield this.Start(),i.token}catch(e){if(e&&e.response){if(e.response.data)throw e.response.data;throw e.response}throw e}}))}LoginWithToken(e){return r(this,void 0,void 0,(function*(){this.userToken=e,yield this.Start()}))}SignUp(e,t,i){return r(this,void 0,void 0,(function*(){try{let{data:n}=yield l.default.post(`${h.Url.Api.Endpoint}${h.Url.Api.Login}`,{mode:"register",name:e,client_id:this.superThis.ClientID,email:t,password:i,device_id:d.v4()});return c.Log("SignUp",n),this.userToken=n.token,yield this.Start(),n.token}catch(e){throw e&&e.response?e.response.data.msg:e}}))}CheckSmsStatus(){return r(this,void 0,void 0,(function*(){return!0}))}SendLoginCodeSms(e){return r(this,void 0,void 0,(function*(){try{let{data:t}=yield l.default.post(`${h.Url.Api.Endpoint}${h.Url.Api.SMSAuth}`,{game:this.superThis.ClientID,secret:this.superThis.ClientSecret,phone_number:e});return c.Log("SendLoginCodeSms",t),!0}catch(e){throw e&&e.response?e.response.data.msg:e}}))}LoginOrSignUpWithSms(e,t,i){return r(this,void 0,void 0,(function*(){try{let{data:n}=yield l.default.post(`${h.Url.Api.Endpoint}${h.Url.Api.SMSAuthCallback}`,{name:e,code:i,phone_number:t,device_id:d.v4()});return c.Log("SendLoginCodeSms",n),n.token}catch(e){throw e&&e.response?e.response.data.msg:e}}))}LoginAsGuest(){return r(this,void 0,void 0,(function*(){try{let{data:e}=yield l.default.post(`${h.Url.Api.Endpoint}${h.Url.Api.Login}`,{device_id:d.v4()});return c.Log("LoginAsGuest",e),this.userToken=e.token,yield this.Start(),e.token}catch(e){throw e&&e.response?e.response.data.msg:e}}))}Start(){return r(this,void 0,void 0,(function*(){try{let{data:e}=yield l.default.post(`${h.Url.Api.Endpoint}${h.Url.Api.Start}`,{game:this.superThis.ClientID,system_info:u.get(),secret:this.superThis.ClientSecret,token:this.userToken,connectionType:"wss"});return this.gameToken=e.token,this.gameID=e.game._id,yield this.superThis.GSLive.Command.Initilize(e.command),e.token}catch(e){throw e&&e.response?e.response.data.msg:e}}))}}},1351:function(e,t,i){"use strict";var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(s,o){function r(e){try{h(n.next(e))}catch(e){o(e)}}function a(e){try{h(n.throw(e))}catch(e){o(e)}}function h(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}h((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.Chats=void 0;const s=i(7595),o=i(6351),r=i(3264);t.Chats=class{constructor(e){this.superThis=e,this.OnSubscribeChannel=e=>{},this.OnChatReceived=()=>{},this.ChannelsSubscribed=()=>{},this.ChannelsRecentMessages=()=>{},this.ChannelMembers=()=>{},this.PendingMessages=()=>{},this.OnUnSubscribeChannel=()=>{}}SubscribeChannel(e){return n(this,void 0,void 0,(function*(){let t=new o.Packet(this.superThis);t.SetHead(s.Actions.Command.ActionSubscribe),t.SetToken(this.superThis.GSLive.Command.commandToken),t.SetMsg(e),t.Send()}))}SendChannelMessage(e,t){return n(this,void 0,void 0,(function*(){let i=new r.Message(this.superThis);i.SetTo(e),i.SetText(t);let n=new o.Packet(this.superThis);n.SetHead(s.Actions.Command.ActionChat),n.SetToken(this.superThis.GSLive.Command.commandToken),n.SetData(i.ToString()),n.Send()}))}SendPrivateMessage(e,t){return n(this,void 0,void 0,(function*(){let i=new r.Message(this.superThis);i.SetTo(e),i.SetText(t);let n=new o.Packet(this.superThis);n.SetHead(s.Actions.Command.ActionPrivateChat),n.SetToken(this.superThis.GSLive.Command.commandToken),n.SetData(i.ToString()),n.Send()}))}GetChannelsSubscribed(){return n(this,void 0,void 0,(function*(){let e=new o.Packet(this.superThis);e.SetHead(s.Actions.Command.ActionGetSubscribedChannels),e.SetToken(this.superThis.GSLive.Command.commandToken),e.Send()}))}GetChannelRecentMessages(e){return n(this,void 0,void 0,(function*(){let t=new o.Data(this.superThis);t.SetID(e);let i=new o.Packet(this.superThis);i.SetHead(s.Actions.Command.ActionGetLastGroupMessages),i.SetToken(this.superThis.GSLive.Command.commandToken),i.SetData(t.ToString()),i.Send()}))}GetChannelMembers(e,t=0,i=25){return n(this,void 0,void 0,(function*(){let n=new o.Data(this.superThis);n.SetID(e),n.SetMin(t),n.SetMax(i);let r=new o.Packet(this.superThis);r.SetHead(s.Actions.Command.ActionGetMembersOfChannel),r.SetToken(this.superThis.GSLive.Command.commandToken),r.SetData(n.ToString()),r.Send()}))}GetPendingMessages(){return n(this,void 0,void 0,(function*(){let e=new o.Packet(this.superThis);e.SetHead(s.Actions.Command.ActionGetPendingMessages),e.SetToken(this.superThis.GSLive.Command.commandToken),e.Send()}))}UnSubscribeChannel(e){return n(this,void 0,void 0,(function*(){let t=new o.Packet(this.superThis);t.SetHead(s.Actions.Command.ActionUnSubscribe),t.SetToken(this.superThis.GSLive.Command.commandToken),t.SetMsg(e),t.Send()}))}}},3264:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Message=void 0,t.Message=class{constructor(e){this.superThis=e}GetIsPrivate(){return this.IsPrivate}SetIsPrivate(e){this.IsPrivate=e}GetTo(){return this.To}SetTo(e){this.To=e}GetFrom(){return this.From}SetFrom(e){this.From=e}GetText(){return this.Text}SetText(e){this.Text=e}GetTime(){return this.Time}SetTime(e){this.Time=e}GetChannel(){return this.Channel}SetChannel(e){this.Channel=e}Cast(){return{0:this.IsPrivate,1:this.To,2:this.From,3:this.Text,4:this.Time,5:this.Channel}}Parse(e){let t=JSON.parse(e);this.SetIsPrivate(t[0]),this.SetTo(t[1]),this.SetFrom(t[2]),this.SetText(t[3]),this.SetTime(t[4]),this.SetChannel(t[5])}ToString(){return JSON.stringify(this.Cast())}}},6587:function(e,t,i){"use strict";var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(s,o){function r(e){try{h(n.next(e))}catch(e){o(e)}}function a(e){try{h(n.throw(e))}catch(e){o(e)}}function h(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}h((n=n.apply(e,t||[])).next())}))},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Command=void 0;const o=i(7595),r=s(i(7026)),a=i(6351),h=i(3264),c=i(1563),u=i(7663);t.Command=class{constructor(e){this.superThis=e,this.commandToken="",this.isInAutoMatchQueue=!1,this.OnConnect=e=>{let t=new a.Payload(this.superThis);t.SetGameID(this.superThis.Authentication.gameID),t.SetToken(this.superThis.Authentication.userToken);let i=new a.Packet(this.superThis);i.SetHead(o.Actions.Command.ActionAuth),i.SetData(t.ToString()),i.Send(!1)},this.OnReceive=e=>n(this,void 0,void 0,(function*(){var t;let i=new a.Packet(this.superThis);switch(i.Parse(e.data,""!=this.superThis.GSLive.Cipher&&""!=this.commandToken),i.GetHead()){case o.Actions.Command.ActionAuth:this.commandToken=i.GetToken(),this.superThis.onReady();break;case o.Actions.Command.ActionChat:let e=new h.Message(this.superThis);e.Parse(i.GetData()),this.superThis.GSLive.Chats.OnChatReceived(e.GetChannel(),e.GetFrom(),e.GetText(),!1);break;case o.Actions.Command.ActionPrivateChat:let n=new h.Message(this.superThis);n.Parse(i.GetData()),this.superThis.GSLive.Chats.OnChatReceived(n.GetChannel(),n.GetFrom(),n.GetText(),!0);break;case o.Actions.Command.ActionSubscribe:this.superThis.GSLive.Chats.OnSubscribeChannel(i.GetMsg());break;case o.Actions.Command.ActionUnSubscribe:this.superThis.GSLive.Chats.OnUnSubscribeChannel(i.GetMsg());break;case o.Actions.Command.ActionGetLastGroupMessages:let s=JSON.parse(i.GetData());this.superThis.GSLive.Chats.ChannelsRecentMessages(s);break;case o.Actions.Command.ActionGetMembersOfChannel:let r=JSON.parse(i.GetData());this.superThis.GSLive.Chats.ChannelMembers(r);break;case o.Actions.Command.ActionGetSubscribedChannels:let c=JSON.parse(i.GetData());this.superThis.GSLive.Chats.ChannelsSubscribed(c);break;case o.Actions.Command.ActionGetPendingMessages:let u=JSON.parse(i.GetData());this.superThis.GSLive.Chats.PendingMessages(u);break;case o.Actions.Command.ActionAutoMatch:let d;null!=i.GetData()&&(d=JSON.parse(i.GetData())),i.GetMsg()&&(d=i.GetMsg()),this.superThis.GSLive.TurnBased.OnAutoMatchUpdated(d),this.superThis.GSLive.RealTime.OnAutoMatchUpdated(d),this.isInAutoMatchQueue=!0;break;case o.Actions.Command.LeftWaitingQ:this.superThis.GSLive.TurnBased.OnAutoMatchCanceled(i.GetMsg()||""),this.superThis.GSLive.RealTime.OnAutoMatchCanceled(i.GetMsg()||""),this.isInAutoMatchQueue=!1;break;case o.Actions.Command.ActionGetRooms:break;case o.Actions.Command.ActionJoinRoom:let l=new a.StartGame;l.parse(i.GetData()),1==l.Room.syncMode?yield this.superThis.GSLive.TurnbasedController.Initilize(l.Room._id,l.Area.Endpoint,l.Area.Port):yield this.superThis.GSLive.RealTimeController.Initilize(l.Room._id,null===(t=l.Area)||void 0===t?void 0:t.Hash,l.Area.Endpoint,l.Area.Port),this.isInAutoMatchQueue=!1;break;case o.Actions.Error:console.error(`[Command] [Error] [Msg: ${i.GetMsg()}]`)}})),this.onDisconnect=e=>{e.wasClean?c.Log("[Command]",`[close] Connection closed cleanly, code = ${e.code} reason = ${e.reason}`):c.Log("[Command]","[close] Connection died"),this.commandToken=""}}Initilize(e){if(null==e.ip||null==e.port)return console.error("No valid command returned from HttpServices",{relay:e});"undefined"==typeof window?(c.Log("[Command]",`[Node] [Connecting] [${e.ip}:${e.port}]`),u.GSLive.CommandConnection=new r.default(`ws://${e.ip}:${e.port}`)):(c.Log("[Command]",`[Browser] [Connecting] [${e.port}:${e.port}]`),u.GSLive.CommandConnection=new WebSocket(`ws://${e.ip}:${e.port}`)),this.superThis.GSLive.Cipher=e.cipher,this.superThis.GSLive.isEncriptionActive="deactive"!=e.encription,u.GSLive.CommandConnection.onopen=this.OnConnect,u.GSLive.CommandConnection.onmessage=this.OnReceive,u.GSLive.CommandConnection.onclose=this.onDisconnect,u.GSLive.CommandConnection.onerror=e=>{throw e}}}},6351:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Area=t.StartGame=t.Data=t.Payload=t.Packet=t.Rc4=void 0;const n=i(7663);function s(e,t){for(var i,n=[],s=0,o="",r=0;r<256;r++)n[r]=r;for(r=0;r<256;r++)s=(s+n[r]+e.charCodeAt(r%e.length))%256,i=n[r],n[r]=n[s],n[s]=i;r=0,s=0;for(var a=0;a<t.length;a++)s=(s+n[r=(r+1)%256])%256,i=n[r],n[r]=n[s],n[s]=i,o+=String.fromCharCode(t.charCodeAt(a)^n[(n[r]+n[s])%256]);return o}t.Rc4=s,t.Packet=class{constructor(e){this.superThis=e,this.Send=(e=!0)=>{let t=this.ToString(e);if(void 0===n.GSLive.CommandConnection)throw"User not connected to Command Server";n.GSLive.CommandConnection.send(t)}}Parse(e,t=!0){let i=JSON.parse(e),n=i[2],o=i[3];this.superThis.GSLive.isEncriptionActive&&t&&(i[2]&&(n=Buffer.from(s(this.superThis.GSLive.Cipher,Buffer.from(i[2],"base64").toString("latin1")),"latin1").toString("utf-8")),i[3]&&(o=Buffer.from(s(this.superThis.GSLive.Cipher,Buffer.from(i[3],"base64").toString("latin1")),"latin1").toString("utf-8"))),this.SetToken(i[0]),this.SetHead(i[1]),this.SetData(n),this.SetMsg(o)}GetToken(){return this.Token}SetToken(e){this.Token=e}GetHead(){return this.Head}SetHead(e){this.Head=e}GetData(){return this.Data}SetData(e){this.Data=e}GetMsg(){return this.Msg}SetMsg(e){this.Msg=e}Export(){return{0:this.Token,1:this.Head,2:this.Data,3:this.Msg}}Cast(e=!0){if(this.superThis.GSLive.isEncriptionActive&&e){if(this.Data){let e=s(this.superThis.GSLive.Cipher,Buffer.from(this.Data).toString("utf-8")),t=Buffer.from(e,"latin1").toString("base64");this.Data=t}if(this.Msg){let e=s(this.superThis.GSLive.Cipher,Buffer.from(this.Msg).toString("utf-8")),t=Buffer.from(e,"latin1").toString("base64");this.Msg=t}}return{0:this.Token,1:this.Head,2:this.Data,3:this.Msg}}ToString(e=!0){return JSON.stringify(this.Cast(e))}},t.Payload=class{constructor(e){this.superThis=e}GetGameID(){return this.GameID}SetGameID(e){this.GameID=e}GetToken(){return this.Token}SetToken(e){this.Token=e}Cast(){return{0:this.GameID,1:this.Token}}ToString(){return JSON.stringify(this.Cast())}},t.Data=class{constructor(e){this.superThis=e}GetID(){return this.ID}SetID(e){this.ID=e}GetUser(){return this.User}SetUser(e){this.User=e}GetInvite(){return this.Invite}SetInvite(e){this.Invite=e}GetName(){return this.Name}SetName(e){this.Name=e}GetHead(){return this.Head}SetHead(e){this.Head=e}GetMin(){return this.Min}SetMin(e){this.Min=e}GetMax(){return this.Max}SetMax(e){this.Max=e}GetSyncMode(){return this.SyncMode}SetSyncMode(e){this.SyncMode=e}GetRole(){return this.Role}SetRole(e){this.Role=e}GetPrivate(){return this.Private}SetPrivate(e){this.Private=e}GetPersist(){return this.Persist}SetPersist(e){this.Persist=e}GetExtra(){return this.Extra}SetExtra(e){this.Extra=e}GetPassword(){return this.Password}SetPassword(e){this.Password=e}Parse(e){this.ID=e[0],this.User=e[1],this.Invite=e[2],this.Name=e[3],this.Head=e[4],this.Min=e[5],this.Max=e[6],this.SyncMode=e[7],this.Role=e[8],this.Private=e[9],this.Persist=e[10],this.Extra=e[11],this.Password=e[12]}Export(){return{ID:this.ID,User:this.User,Invite:this.Invite,Name:this.Name,Head:this.Head,Min:this.Min,Max:this.Max,SyncMode:this.SyncMode,Role:this.Role,Private:this.Private,Persist:this.Persist,Extra:this.Extra,Password:this.Password}}Cast(){return{0:this.ID,1:this.User,2:this.Invite,3:this.Name,4:this.Head,5:this.Min,6:this.Max,7:this.SyncMode,8:this.Role,9:this.Private,10:this.Persist,11:this.Extra,12:this.Password}}ToString(){return JSON.stringify(this.Cast())}},t.StartGame=class{parse(e){let t=JSON.parse(e),i=new o;i.parse(JSON.stringify(t[2])),this.Room=t[0],this.MemerID=t[1],this.Area=i}cast(){return{0:this.Room,1:this.MemerID,2:this.Area}}toString(){return JSON.stringify(this.cast())}};class o{constructor(){this.Endpoint="",this.Port=0}parse(e){let t=JSON.parse(e);this.Endpoint=t[0],this.Protocol=t[1],this.Port=t[2],this.Token=t[3],this.PublicKey=t[4],this.Hash=t[5]}cast(){return{0:this.Endpoint,1:this.Protocol,2:this.Port,3:this.Token,4:this.PublicKey,5:this.Hash}}toString(){return JSON.stringify(this.cast())}}t.Area=o},3904:function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.RealTime=void 0;const s=i(7595),o=i(6137),r=i(6137),a=n(i(7026)),h=i(1563),c=i(4841),u=i(49);class d{constructor(e){this.superThis=e,this.realtimeToken=BigInt(0),this.RoomID="",this.ConnectHash="",this.OnConnect=e=>{h.Log("[RealTime]","[onConnect]");let t=new r.AuthPayload;t.RoomID=this.RoomID,t.Token=this.superThis.Authentication.gameToken,t.Hash=this.ConnectHash;let i=new r.Packet;i.Action=s.Actions.RealTime.ActionAuth,i.Payload=t.ToBuffer(),i.Send()},this.OnReceive=e=>{var t,i;let n=new r.Packet;switch(n.Deserialize(Buffer.from(e.data.toString(),"base64")),n.Action){case s.Actions.RealTime.ActionAuth:this.realtimeToken=n.Token;break;case s.Actions.RealTime.ActionPublicMessage:let e=new o.Data;e.Deserialize(n.Payload),this.superThis.GSLive.RealTime.NewMessageReceived({MessageInfo:{MessageType:c.MessageType[n.Action],SendType:c.GProtocolSendType[n.Type],ClientReceiveTime:n.ClientSendTime},Message:e.Export()});break;case s.Actions.RealTime.ActionPrivateMessage:let a=new o.Data;a.Deserialize(n.Payload),this.superThis.GSLive.RealTime.NewMessageReceived({MessageInfo:{MessageType:c.MessageType[n.Action],SendType:c.GProtocolSendType[n.Type],ClientReceiveTime:n.ClientSendTime},Message:a.Export()});break;case s.Actions.RealTime.ActionJoin:let l=new o.JoinPayload;l.Parse(JSON.parse(r.BufferToString(n.Payload))),this.superThis.GSLive.RealTime.OnJoinedRoom(l.Export());break;case s.Actions.RealTime.ActionMembersDetail:let m=JSON.parse(r.BufferToString(n.Payload));this.superThis.GSLive.RealTime.RoomMembersDetailReceived(m);break;case s.Actions.RealTime.ActionLeave:let p=JSON.parse(r.BufferToString(n.Payload));this.superThis.GSLive.RealTime.OnLeaveRoom(p),p.user.isMe&&(null===(t=d.Connection)||void 0===t||t.close(),this.realtimeToken=BigInt(0),this.ConnectHash="",this.RoomID="",d.Connection=void 0);break;case s.Actions.RealTime.ActionEventMessage:let f=new o.Data;f.Deserialize(n.Payload);let v=new c.EventPayload;v.Deserialize(f.Payload),this.superThis.GSLive.RealTime.OnPropertyEvent({By:f.SenderID,Name:v.Name,Value:r.BufferToString(v.Value),Action:f.GetExtra().Action,Type:f.GetExtra().Type});break;case s.Actions.RealTime.ActionRoomInfo:let T=JSON.parse(r.BufferToString(n.Payload)),S=new u.Room;S.Parse(T),this.superThis.GSLive.RealTime.CurrentRoomInfoReceived(S.Export());break;case s.Actions.Error:console.error(`[Error] [Msg: ${null===(i=n.Payload)||void 0===i?void 0:i.toString()}]`);break;default:h.Log("[RealTime]",`[OnReceive]: ${n.ToString()}`)}},this.onDisconnect=e=>{e.wasClean?h.Log("[RealTime]",`[close] Connection closed cleanly, code=${e.code} reason=${e.reason}`):h.Log("[RealTime]","[close] Connection died"),this.realtimeToken=BigInt(0),this.ConnectHash=""}}Initilize(e,t,i,n){h.Log("[RealTime]",`[Connecting] [${e}] [ws://${i}:${n}]`),this.RoomID=e,this.ConnectHash=t,d.Connection=new a.default(`ws://${i}:${n}`),d.Connection.binaryType="arraybuffer",d.Connection.onopen=this.OnConnect,d.Connection.onmessage=this.OnReceive,d.Connection.onclose=this.onDisconnect,d.Connection.onerror=function(e){throw e}}}t.RealTime=d,d.Connection=void 0},6137:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JoinPayload=t.AuthPayload=t.BufferToString=t.StringToBuffer=t.Operations=t.Types=t.Data=t.Packet=void 0;const n=i(3904),s=i(49);function o(e){let t=unescape(encodeURIComponent(e)).split(""),i=[];for(var n=0;n<t.length;n++)i.push(t[n].charCodeAt(0));return new Uint8Array(i)}function r(e){var t=String.fromCharCode.apply(null,[].slice.call(e));return decodeURIComponent(escape(t))}var a,h;t.Packet=class{constructor(){this._Token=BigInt(0),this._Type=0,this.Send=()=>{let e=this.Serialize();n.RealTime.Connection.readyState&&n.RealTime.Connection.send(e,{binary:!0,compress:!1})}}get Action(){return this._Action}set Action(e){e>255&&(e=255),this._Action=e}get Token(){return this._Token}set Token(e){this._Token=e}get Type(){return this._Type}set Type(e){e>255&&(e=255),this._Type=e}Cast(){return{1:this.Action,2:r(this.Payload),3:Number(this.Token),4:this.Type,5:this.ClientSendTime}}ToString(){return JSON.stringify(this.Cast())}Parse(e){this.Action=e[1],this.Payload=e[2],this.Token=e[3],this.Type=e[4],this.ClientSendTime=e[5]}Serialize(){var e;let t=0,i=0;this.Payload&&(t=1),this.ClientSendTime&&(i=1);let n=[this.Action,i,t];if(1===t){let t=Buffer.alloc(2);t.writeUInt16LE(null===(e=this.Payload)||void 0===e?void 0:e.length),n=[...n,...t.valueOf()]}n.push(this.Type);let s=Buffer.alloc(8);if(s.writeBigUInt64LE(this.Token),n=[...n,...s.valueOf()],1===t&&(n=[...n,...this.Payload]),1===i){let e=Buffer.alloc(8);e.writeBigInt64LE(BigInt(this.ClientSendTime)),n=[...n,...e.valueOf()]}return new Uint8Array(n)}Deserialize(e){let t=Buffer.from(e),i=0,n=0,s=0,o=0;this.Action=t.readUInt8(i++),n=t.readUInt8(i++),s=t.readUInt8(i++),s>0&&(o=t.readUInt16LE(i),i+=2),this.Type=t.readUInt8(i++),this.Token=t.readBigUInt64LE(i),i+=8,s>0&&(this.Payload=t.slice(i,i+o),i+=o),n>0&&(this.ClientSendTime=Number(t.readBigInt64LE(i)))}},t.Data=class{constructor(){this._Extra=new Uint8Array}get SenderID(){return this._SenderID}set SenderID(e){this._SenderID=e}get ReceiverID(){return this._ReceiverID}set ReceiverID(e){this._ReceiverID=e}get Payload(){return this._Payload}set Payload(e){this._Payload=e}GetExtra(){let e=Buffer.from(this._Extra);return{Type:e.readUInt8(),Action:e.readUInt8(1)}}SetExtra(e,t){this._Extra=new Uint8Array([e,t])}Cast(){return{1:this.SenderID,2:this.ReceiverID,3:r(this.Payload),4:this._Extra}}Parse(e){this.SenderID=e[1],this.ReceiverID=e[2],this.Payload=e[3],this._Extra=e[4]}Export(){return{SenderID:this.SenderID,ReceiverID:this.ReceiverID,Payload:r(this.Payload),Extra:this.GetExtra()}}Serialize(){var e,t;let i=0,n=0,s=0,r=0;this.SenderID&&(i=1),this.ReceiverID&&(n=1),this.Payload.length>0&&(s=1),this._Extra&&(r=1);let a=[i,n,s,r],h=o(this.ReceiverID),c=o(this.SenderID);if(i>0&&a.push(c.length),n>0&&a.push(h.length),s>0){let t=Buffer.alloc(2);t.writeUInt16LE(null===(e=this.Payload)||void 0===e?void 0:e.length),a=[...a,...t.valueOf()]}if(r>0){let e=Buffer.alloc(2);e.writeUInt16LE(null===(t=this._Extra)||void 0===t?void 0:t.length),a=[...a,...e.valueOf()]}return i>0&&(a=[...a,...c]),n>0&&(a=[...a,...h]),s>0&&(a=[...a,...this.Payload]),r>0&&(a=[...a,...this._Extra]),new Uint8Array(a)}Deserialize(e){let t=Buffer.from(e),i=0,n=0,s=0,o=0,a=0,h=t.readUInt8(i++),c=t.readUInt8(i++),u=t.readUInt8(i++),d=t.readUInt8(i++);h>0&&(n=t.readUInt8(i++)),c>0&&(s=t.readUInt8(i++)),u>0&&(o=t.readUInt16LE(i),i+=2),d>0&&(a=t.readUInt16LE(i),i+=2),h>0&&(this.SenderID=r(t.slice(i,i+n)),i+=n),c>0&&(this.ReceiverID=r(t.slice(i,i+s)),i+=s),u>0&&(this.Payload=t.slice(i,i+o),i+=o),d>0&&(this._Extra=t.slice(i,i+a),i+=a)}},(h=t.Types||(t.Types={}))[h.Object=1]="Object",h[h.Function=2]="Function",h[h.Property=3]="Property",(a=t.Operations||(t.Operations={}))[a.SetMemberProperty=2]="SetMemberProperty",a[a.DelMemberProperty=3]="DelMemberProperty",a[a.SetRoomProperty=0]="SetRoomProperty",a[a.DelRoomProperty=1]="DelRoomProperty",a[a.BufferedFunction=2]="BufferedFunction",a[a.InstanceObject=0]="InstanceObject",a[a.DestroyObject=1]="DestroyObject",t.StringToBuffer=o,t.BufferToString=r,t.AuthPayload=class{Cast(){return{1:this.RoomID,2:this.Token,3:this.Hash}}Parse(e){this.RoomID=e[1],this.Token=e[2],this.Hash=e[3]}ToString(){return JSON.stringify(this.Cast())}ToBuffer(){return o(this.ToString())}},t.JoinPayload=class{Cast(){return{1:this.JoinType,2:this.Room,3:this.UserJoined,4:this.JoinMemberOrder}}Parse(e){this.JoinType=e[1];let t=new s.Room;t.Parse(e[2]),this.Room=t.Export(),this.UserJoined=e[3],this.JoinMemberOrder=e[4]}ToString(){return JSON.stringify(this.Cast())}ToBuffer(){return o(this.ToString())}Export(){return{JoinType:this.JoinType,Room:this.Room,UserJoined:this.UserJoined,JoinMemberOrder:this.JoinMemberOrder}}}},2780:function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.TurnBased=void 0;const s=i(7595),o=i(6351),r=i(49),a=n(i(7026)),h=i(1563);class c{constructor(e){this.superThis=e,this.turnbasedToken="",this.RoomID="",this.OnConnect=e=>{let t=new o.Payload(this.superThis);t.SetGameID(this.RoomID),t.SetToken(this.superThis.Authentication.gameToken);let i=new r.Packet(this.superThis);i.SetHead(s.Actions.TurnBased.ActionAuth),i.SetData(t.ToString()),i.Send(!1)},this.OnReceive=e=>{var t;let i=new r.Packet(this.superThis);switch(i.Parse(e.data,""!=this.superThis.GSLive.Cipher),i.GetHead()){case s.Actions.TurnBased.ActionAuth:this.turnbasedToken=i.GetToken();break;case s.Actions.TurnBased.ActionJoin:let e=JSON.parse(i.GetData()),n=new r.JoinDetail;n.Parse(e),this.superThis.GSLive.TurnBased.OnJoinedRoom(n.Export());break;case s.Actions.TurnBased.ActionTakeTurn:let o=JSON.parse(i.GetData());this.superThis.GSLive.TurnBased.OnTakeTurn(o[1],o[0]);break;case s.Actions.TurnBased.ActionChooseNext:let a=JSON.parse(i.GetData());this.superThis.GSLive.TurnBased.OnChoosedNext(a);break;case s.Actions.TurnBased.ActionLeave:let h=JSON.parse(i.GetData());this.superThis.GSLive.TurnBased.OnLeaveRoom(h),h.user.isMe&&(null===(t=c.Connection)||void 0===t||t.close(),this.turnbasedToken="",this.RoomID="",c.Connection=void 0);break;case s.Actions.TurnBased.ActionVote:let u=JSON.parse(i.GetData()),d=new r.VoteDetail;d.Parse(u),this.superThis.GSLive.TurnBased.OnVoteReceived(d.Member,d.Outcome);break;case s.Actions.TurnBased.ActionAcceptVote:let l=JSON.parse(i.GetData()),m=new r.GameResult;m.Parse(l),this.superThis.GSLive.TurnBased.OnComplete(m);break;case s.Actions.TurnBased.ActionGetUsers:let p=JSON.parse(i.GetData());this.superThis.GSLive.TurnBased.OnRoomMembersDetailReceived(p);break;case s.Actions.TurnBased.ActionCurrentTurnDetail:let f=JSON.parse(i.GetData());this.superThis.GSLive.TurnBased.OnCurrentTurnMember(f);break;case s.Actions.TurnBased.ModifyValue:let v=JSON.parse(i.GetData()),T=new r.PropertyChange;T.Parse(v),this.superThis.GSLive.TurnBased.OnPropertyUpdated(T);break;case s.Actions.TurnBased.GetRoomInfo:let S=JSON.parse(i.GetData()),g=new r.Room;g.Parse(S),this.superThis.GSLive.TurnBased.OnCurrentRoomInfoReceived(g.Export());break;case s.Actions.Error:console.error(`[Error] [Msg: ${i.GetMsg()}]`)}},this.onDisconnect=e=>{e.wasClean?h.Log("[TurnBased]",`[close] Connection closed cleanly, code=${e.code} reason=${e.reason}`):h.Log("[TurnBased]","[close] Connection died"),this.turnbasedToken=""}}Initilize(e,t,i){if(this.RoomID=e,null==t||null==i)throw`No valid area returned from Command, ${e}, ${t}, ${i}`;"undefined"==typeof window?(h.Log("[TurnBased]",`[Node] [Connecting] [ws://${t}:${i}]`),c.Connection=new a.default(`ws://${t}:${i}`,{maxPayload:2048})):(h.Log("[TurnBased]",`[Browser] [Connecting] [ws://${t}:${i}]`),c.Connection=new WebSocket(`ws://${t}:${i}`)),c.Connection.onopen=this.OnConnect,c.Connection.onmessage=this.OnReceive,c.Connection.onclose=this.onDisconnect,c.Connection.onerror=e=>{throw e}}}t.TurnBased=c,c.Connection=void 0},49:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GameResult=t.VoteDetail=t.JoinDetail=t.PropertyChange=t.Room=t.Packet=void 0;const n=i(2780),s=i(1175),o=i(6351);t.Packet=class{constructor(e){this.superThis=e,this.Send=(e=!0)=>{let t=this.ToString(e);n.TurnBased.Connection.send(t)}}Parse(e,t=!0){let i=JSON.parse(e),n=i[2],s=i[3];this.superThis.GSLive.isEncriptionActive&&t&&(i[2]&&(n=Buffer.from(o.Rc4(this.superThis.GSLive.Cipher,Buffer.from(i[2],"base64").toString("latin1")),"latin1").toString("utf-8")),i[3]&&(s=Buffer.from(o.Rc4(this.superThis.GSLive.Cipher,Buffer.from(i[3],"base64").toString("latin1")),"latin1").toString("utf-8"))),this.SetToken(i[0]),this.SetHead(i[1]),this.SetData(n),this.SetMsg(s)}GetToken(){return this.Token}SetToken(e){this.Token=e}GetHead(){return this.Head}SetHead(e){this.Head=e}GetData(){return this.Data}SetData(e){this.Data=e}GetMsg(){return this.Msg}SetMsg(e){this.Msg=e}Cast(e=!0){if(this.superThis.GSLive.isEncriptionActive&&e){if(this.Data){let e=o.Rc4(this.superThis.GSLive.Cipher,Buffer.from(this.Data).toString("utf-8")),t=Buffer.from(e,"latin1").toString("base64");this.Data=t}if(this.Msg){let e=o.Rc4(this.superThis.GSLive.Cipher,Buffer.from(this.Msg).toString("utf-8")),t=Buffer.from(e,"latin1").toString("base64");this.Msg=t}}return{0:this.Token,1:this.Head,2:this.Data,3:this.Msg}}ToString(e=!0){return JSON.stringify(this.Cast(e))}};class r{constructor(){this._Name="",this._Private=!1,this._Persist=!1}Parse(e){this.ID=e[1],this.Name=e[2],this.Logo=e[3],this.Creator=e[4],this.Min=e[5],this.Max=e[6],this.Role=e[7],this.Private=e[8],this.Status=e[9],this.NumOfMembers=e[10],this.Variables=e[11],this.Persist=e[12],this.CreatedAt=e[13]}get ID(){return this._ID}set ID(e){this._ID=e}get Name(){return this._Name}set Name(e){this._Name=e}get Logo(){return this._Logo}set Logo(e){this._Logo=e}get Creator(){return this._Creator}set Creator(e){this._Creator=e}get Min(){return this._Min}set Min(e){this._Min=e}get Max(){return this._Max}set Max(e){this._Max=e}get Role(){return this._Role}set Role(e){this._Role=e}get Private(){return this._Private}set Private(e){this._Private=e}get Status(){return this._Status}set Status(e){this._Status=e}get NumOfMembers(){return this._NumOfMembers}set NumOfMembers(e){this._NumOfMembers=e}get Variables(){return this._Variables}set Variables(e){this._Variables=e}get Persist(){return this._Persist}set Persist(e){this._Persist=e}get CreatedAt(){return this._CreatedAt}set CreatedAt(e){this._CreatedAt=e}Export(){return{ID:this.ID,Name:this.Name,Logo:this.Logo,Creator:this.Creator,Min:this.Min,Max:this.Max,Role:this.Role,Private:this.Private,Status:this.Status,NumOfMembers:this.NumOfMembers,Variables:this.Variables,Persist:this.Persist,CreatedAt:this.CreatedAt}}Cast(){return{1:this.ID,2:this.Name,3:this.Logo,4:this.Creator,5:this.Min,6:this.Max,7:this.Role,8:this.Private,9:this.Status,10:this.NumOfMembers,11:this.Variables,12:this.Persist,13:this.CreatedAt}}ToString(){return JSON.stringify(this.Cast())}}t.Room=r,t.PropertyChange=class{Parse(e){1==e[1]?this.Type=s.PropertyType.Room:this.Type=s.PropertyType.Member,3==e[2]||1==e[2]?this.Action="SetOtUpdate":this.Action="Delete",this.Sender=e[3],this.Name=e[4],this.Value=e[5]}Export(){return{Type:this.Type,Action:this.Action,Sender:this.Sender,Name:this.Name,Value:this.Value}}},t.JoinDetail=class{Parse(e){let t=new r;t.Parse(e[2]),this.JoinType=e[1],this.UserJoined=e[3],this.Room=t,this.JoinOrder=e[4]}Export(){var e;return{JoinType:this.JoinType,UserJoined:this.UserJoined,Room:null===(e=this.Room)||void 0===e?void 0:e.Export(),JoinOrder:this.JoinOrder}}},t.VoteDetail=class{Parse(e){this.Member=e[0];let t={};for(let i in e[1]){let n=new s.Outcome;n.Parse(e[1][i]),t[i]=n}this.Outcome=t}},t.GameResult=class{Parse(e){this.AcceptCount=e.Accept;let t={};for(let i in e.Outcomes){let n=new s.Outcome;n.Parse(e.Outcomes[i]),t[i]=n}this.Outcome=t}}},6745:function(e,t,i){"use strict";var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(s,o){function r(e){try{h(n.next(e))}catch(e){o(e)}}function a(e){try{h(n.throw(e))}catch(e){o(e)}}function h(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}h((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.RealTime=void 0;const s=i(7595),o=i(4841),r=i(6351),a=i(6137);t.RealTime=class{constructor(e){this.superThis=e,this.OnReconnected=()=>{},this.OnJoinedRoom=()=>{},this.OnAutoMatchUpdated=()=>{},this.OnAutoMatchCanceled=()=>{},this.OnAvailableRoomsReceived=()=>{},this.OnFindMemberReceived=()=>{},this.OnInvitationSent=()=>{},this.CurrentRoomInfoReceived=()=>{},this.RoomMembersDetailReceived=()=>{},this.NewMessageReceived=()=>{},this.OnLeaveRoom=()=>{},this.OnPropertyEvent=()=>{}}CreateRoom(e){return n(this,void 0,void 0,(function*(){if(""==this.superThis.GSLive.Command.commandToken)throw"User not connected to Command Server";if(this.superThis.GSLive.RealTimeController.RoomID)throw"User is already in game room, please left from it first.";let t=new r.Data(this.superThis);t.SetMax(e.maxPlayer),t.SetMin(e.minPlayer),t.SetName(e.roomName),t.SetPassword(e.roomPassword),t.SetRole(e.role),t.SetPersist(e.isPersist),t.SetPrivate(e.isPrivate),t.SetExtra(e.extra),t.SetSyncMode(2);let i=new r.Packet(this.superThis);i.SetHead(s.Actions.Command.ActionCreateRoom),i.SetToken(this.superThis.GSLive.Command.commandToken),i.SetData(t.ToString()),i.Send()}))}AutoMatch(e){return n(this,void 0,void 0,(function*(){if(""==this.superThis.GSLive.Command.commandToken)throw"User not connected to Command Server";if(this.superThis.GSLive.Command.isInAutoMatchQueue)throw"User is in automatch queue already";if(this.superThis.GSLive.RealTimeController.RoomID)throw"User is already in game room, please left from it first.";let t=new r.Data(this.superThis);t.SetMax(e.maxPlayer),t.SetMin(e.minPlayer),t.SetRole(e.role),t.SetPersist(e.isPersist),t.SetExtra(e.extra),t.SetSyncMode(2);let i=new r.Packet(this.superThis);i.SetHead(s.Actions.Command.ActionAutoMatch),i.SetToken(this.superThis.GSLive.Command.commandToken),i.SetData(t.ToString()),i.Send()}))}CancelAutoMatch(){return n(this,void 0,void 0,(function*(){if(""==this.superThis.GSLive.Command.commandToken)throw"User not connected to Command Server";if(!this.superThis.GSLive.Command.isInAutoMatchQueue)throw"User is not in automatch queue";let e=new r.Packet(this.superThis);e.SetHead(s.Actions.Command.LeftWaitingQ),e.SetToken(this.superThis.GSLive.Command.commandToken),e.Send()}))}GetAvailableRooms(e,t){return n(this,void 0,void 0,(function*(){if(""==this.superThis.GSLive.Command.commandToken)throw"User not connected to Command Server";let i=new r.Data(this.superThis);i.SetMax(t),i.SetRole(e);let n=new r.Packet(this.superThis);n.SetHead(s.Actions.Command.ActionGetRooms),n.SetToken(this.superThis.GSLive.Command.commandToken),n.SetData(i.ToString()),n.Send()}))}JoinRoom(e,t,i){return n(this,void 0,void 0,(function*(){if(""==this.superThis.GSLive.Command.commandToken)throw"User not connected to Command Server";if(this.superThis.GSLive.RealTimeController.RoomID)throw"User is already in game room, please left from it first.";let n=new r.Data(this.superThis);n.SetID(e),n.SetExtra(t),n.SetPassword(i);let o=new r.Packet(this.superThis);o.SetHead(s.Actions.Command.ActionJoinRoom),o.SetToken(this.superThis.GSLive.Command.commandToken),o.SetData(n.ToString()),o.Send()}))}FindMember(e,t){return n(this,void 0,void 0,(function*(){if(""==this.superThis.GSLive.Command.commandToken)throw"User not connected to Command Server";let i=new r.Data(this.superThis);i.SetUser(e),i.SetMax(t);let n=new r.Packet(this.superThis);n.SetHead(s.Actions.Command.ActionFindUser),n.SetToken(this.superThis.GSLive.Command.commandToken),n.SetData(i.ToString()),n.Send()}))}InviteUser(e,t){return n(this,void 0,void 0,(function*(){if(""==this.superThis.GSLive.Command.commandToken)throw"User not connected to Command Server";let i=new r.Data(this.superThis);i.SetID(e),i.SetUser(t);let n=new r.Packet(this.superThis);n.SetHead(s.Actions.Command.ActionInviteUser),n.SetToken(this.superThis.GSLive.Command.commandToken),n.SetData(i.ToString()),n.Send()}))}GetInviteInbox(){return n(this,void 0,void 0,(function*(){if(""==this.superThis.GSLive.Command.commandToken)throw"User not connected to Command Server";let e=new r.Data(this.superThis);e.SetSyncMode(2);let t=new r.Packet(this.superThis);t.SetHead(s.Actions.Command.ActionGetInviteList),t.SetToken(this.superThis.GSLive.Command.commandToken),t.SetData(e.ToString()),t.Send()}))}AcceptInvite(e,t){return n(this,void 0,void 0,(function*(){if(""==this.superThis.GSLive.Command.commandToken)throw"User not connected to Command Server";if(this.superThis.GSLive.RealTimeController.RoomID)throw"User is already in game room, please left from it first.";let i=new r.Data(this.superThis);i.SetInvite(e),i.SetExtra(t);let n=new r.Packet(this.superThis);n.SetHead(s.Actions.Command.ActionAcceptInvite),n.SetToken(this.superThis.GSLive.Command.commandToken),n.SetData(i.ToString()),n.Send()}))}GetCurrentRoomInfo(){return n(this,void 0,void 0,(function*(){if(this.superThis.GSLive.RealTimeController.RoomID.length<1)throw"User is not in any game room";let e=new a.Packet;e.Action=s.Actions.RealTime.ActionRoomInfo,e.Token=this.superThis.GSLive.RealTimeController.realtimeToken,e.Send()}))}GetRoomMembersDetail(){return n(this,void 0,void 0,(function*(){if(this.superThis.GSLive.RealTimeController.RoomID.length<1)throw"User is not in any game room";let e=new a.Packet;e.Action=s.Actions.RealTime.ActionMembersDetail,e.Token=this.superThis.GSLive.RealTimeController.realtimeToken,e.Send()}))}SendPublicMessage(e,t){return n(this,void 0,void 0,(function*(){if(this.superThis.GSLive.RealTimeController.RoomID.length<1)throw"User is not in any game room";let i=new a.Packet;i.Action=s.Actions.RealTime.ActionPublicMessage,i.Token=this.superThis.GSLive.RealTimeController.realtimeToken,i.Type=t,i.Payload=a.StringToBuffer(e),i.Send()}))}SendPrivateMessage(e,t){return n(this,void 0,void 0,(function*(){if(this.superThis.GSLive.RealTimeController.RoomID.length<1)throw"User is not in any game room";let i=new a.Data;i.ReceiverID=e,i.Payload=a.StringToBuffer(t);let n=new a.Packet;n.Action=s.Actions.RealTime.ActionPrivateMessage,n.Token=this.superThis.GSLive.RealTimeController.realtimeToken,n.Payload=i.Serialize(),n.Send()}))}SetOrUpdateMemberProperty(e,t){return n(this,void 0,void 0,(function*(){if(this.superThis.GSLive.RealTimeController.RoomID.length<1)throw"User is not in any game room";let i=new o.EventPayload;i.Name=e,i.Value=a.StringToBuffer(t),(new a.Data).Payload=i.Serialize();let n=new a.Data;n.SetExtra(a.Types.Property,a.Operations.SetMemberProperty),n.Payload=i.Serialize();let r=new a.Packet;r.Action=s.Actions.RealTime.ActionEventMessage,r.Token=this.superThis.GSLive.RealTimeController.realtimeToken,r.Payload=n.Serialize(),r.Send()}))}RemoveMemberProperty(e){return n(this,void 0,void 0,(function*(){if(this.superThis.GSLive.RealTimeController.RoomID.length<1)throw"User is not in any game room";let t=new o.EventPayload;t.Name=e,(new a.Data).Payload=t.Serialize();let i=new a.Data;i.SetExtra(a.Types.Property,a.Operations.DelMemberProperty),i.Payload=t.Serialize();let n=new a.Packet;n.Action=s.Actions.RealTime.ActionEventMessage,n.Token=this.superThis.GSLive.RealTimeController.realtimeToken,n.Payload=i.Serialize(),n.Send()}))}SetOrUpdateRoomProperty(e,t){return n(this,void 0,void 0,(function*(){if(this.superThis.GSLive.RealTimeController.RoomID.length<1)throw"User is not in any game room";let i=new o.EventPayload;i.Name=e,i.Value=a.StringToBuffer(t),(new a.Data).Payload=i.Serialize();let n=new a.Data;n.SetExtra(a.Types.Property,a.Operations.SetRoomProperty),n.Payload=i.Serialize();let r=new a.Packet;r.Action=s.Actions.RealTime.ActionEventMessage,r.Token=this.superThis.GSLive.RealTimeController.realtimeToken,r.Payload=n.Serialize(),r.Send()}))}RemoveRoomProperty(e){return n(this,void 0,void 0,(function*(){if(this.superThis.GSLive.RealTimeController.RoomID.length<1)throw"User is not in any game room";let t=new o.EventPayload;t.Name=e,(new a.Data).Payload=t.Serialize();let i=new a.Data;i.SetExtra(a.Types.Property,a.Operations.DelRoomProperty),i.Payload=t.Serialize();let n=new a.Packet;n.Action=s.Actions.RealTime.ActionEventMessage,n.Token=this.superThis.GSLive.RealTimeController.realtimeToken,n.Payload=i.Serialize(),n.Send()}))}GetRoomProperties(){return n(this,void 0,void 0,(function*(){if(this.superThis.GSLive.RealTimeController.RoomID.length<1)throw"User is not in any game room";let e=new a.Packet;e.Action=s.Actions.RealTime.ActionGetRoomSnapshot,e.Token=this.superThis.GSLive.RealTimeController.realtimeToken,e.Send()}))}LeaveRoom(){return n(this,void 0,void 0,(function*(){if(this.superThis.GSLive.RealTimeController.RoomID.length<1)throw"User is not in any game room";let e=new a.Packet;e.Action=s.Actions.RealTime.ActionLeave,e.Token=this.superThis.GSLive.RealTimeController.realtimeToken,e.Send()}))}}},4841:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EventPayload=t.MessageType=t.GProtocolSendType=t.AutoMatchOptions=t.CreateRoomOptions=t.PropertyType=void 0;const n=i(6137);var s,o,r;(s=t.PropertyType||(t.PropertyType={})).Room="room",s.Member="member",t.CreateRoomOptions=class{constructor(){this.roomName="default",this.role="default",this.minPlayer=2,this.maxPlayer=2,this.isPrivate=!1,this.isPersist=!1,this.role="default",this.minPlayer=2,this.maxPlayer=2,this.isPersist=!1,this.extra=void 0,this.isPrivate=!1,this.roomPassword=void 0,this.roomName="default"}},t.AutoMatchOptions=class{constructor(){this.role="default",this.minPlayer=2,this.maxPlayer=2,this.isPersist=!1,this.role="default",this.minPlayer=2,this.maxPlayer=2,this.isPersist=!1,this.extra=null}},(r=t.GProtocolSendType||(t.GProtocolSendType={}))[r.UnReliable=0]="UnReliable",r[r.Reliable=1]="Reliable",(o=t.MessageType||(t.MessageType={}))[o.Private=4]="Private",o[o.Public=3]="Public",t.EventPayload=class{constructor(){this.Name="",this.Value=new Uint8Array}Serialize(){var e;let t=Buffer.alloc(2);t.writeUInt16LE(n.StringToBuffer(this.Name).length);let i=Buffer.alloc(2);i.writeUInt16LE(null===(e=this.Value)||void 0===e?void 0:e.length);let s=[2,12,...t.valueOf(),...n.StringToBuffer(this.Name),13,...i.valueOf(),...this.Value];return new Uint8Array(s)}Deserialize(e){let t=Buffer.from(e),i=1;i++;let s=t.readUInt16LE(i);i+=2;let o=t.slice(i,i+s);i+=s,this.Name=n.BufferToString(o),i++;let r=t.readUInt16LE(i);i+=2;let a=t.slice(i,i+r);i+=r,this.Value=a}Export(){return{Name:this.Name,Value:n.BufferToString(this.Value)}}}},9875:function(e,t,i){"use strict";var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(s,o){function r(e){try{h(n.next(e))}catch(e){o(e)}}function a(e){try{h(n.throw(e))}catch(e){o(e)}}function h(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}h((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.TurnBased=void 0;const s=i(7595),o=i(1175),r=i(49),a=i(6351);t.TurnBased=class{constructor(e){this.superThis=e,this.OnReconnected=()=>{},this.OnJoinedRoom=()=>{},this.OnAutoMatchUpdated=()=>{},this.OnAutoMatchCanceled=()=>{},this.OnAvailableRoomsReceived=()=>{},this.OnFindMemberReceived=()=>{},this.NewInviteReceived=()=>{},this.OnInvitationSent=()=>{},this.OnInviteInboxReceived=()=>{},this.OnCurrentRoomInfoReceived=()=>{},this.OnRoomMembersDetailReceived=()=>{},this.OnChoosedNext=()=>{},this.OnTakeTurn=()=>{},this.OnCurrentTurnMember=()=>{},this.OnVoteReceived=()=>{},this.OnComplete=()=>{},this.OnPropertyUpdated=()=>{},this.OnLeaveRoom=()=>{}}CreateRoom(e){return n(this,void 0,void 0,(function*(){if(""==this.superThis.GSLive.Command.commandToken)throw"User not connected to Command Server";if(this.superThis.GSLive.TurnbasedController.RoomID)throw"User is already in game room, please left from it first.";let t=new a.Data(this.superThis);t.SetMax(e.maxPlayer),t.SetMin(e.minPlayer),t.SetName(e.roomName),t.SetPassword(e.roomPassword),t.SetRole(e.role),t.SetPersist(e.isPersist),t.SetPrivate(e.isPrivate),t.SetExtra(e.extra),t.SetSyncMode(1);let i=new a.Packet(this.superThis);i.SetHead(s.Actions.Command.ActionCreateRoom),i.SetToken(this.superThis.GSLive.Command.commandToken),i.SetData(t.ToString()),i.Send()}))}AutoMatch(e){return n(this,void 0,void 0,(function*(){if(""==this.superThis.GSLive.Command.commandToken)throw"User not connected to Command Server";if(this.superThis.GSLive.Command.isInAutoMatchQueue)throw"User is in automatch queue already";if(this.superThis.GSLive.TurnbasedController.RoomID)throw"User is already in game room, please left from it first.";let t=new a.Data(this.superThis);t.SetMax(e.maxPlayer),t.SetMin(e.minPlayer),t.SetRole(e.role),t.SetPersist(e.isPersist),t.SetExtra(e.extra),t.SetSyncMode(1);let i=new a.Packet(this.superThis);i.SetHead(s.Actions.Command.ActionAutoMatch),i.SetToken(this.superThis.GSLive.Command.commandToken),i.SetData(t.ToString()),i.Send()}))}CancelAutoMatch(){return n(this,void 0,void 0,(function*(){if(""==this.superThis.GSLive.Command.commandToken)throw"User not connected to Command Server";if(!this.superThis.GSLive.Command.isInAutoMatchQueue)throw"User is not in automatch queue";let e=new a.Packet(this.superThis);e.SetHead(s.Actions.Command.LeftWaitingQ),e.SetToken(this.superThis.GSLive.Command.commandToken),e.Send()}))}GetAvailableRooms(e,t){return n(this,void 0,void 0,(function*(){if(""==this.superThis.GSLive.Command.commandToken)throw"User not connected to Command Server";let i=new a.Data(this.superThis);i.SetMax(t),i.SetRole(e);let n=new a.Packet(this.superThis);n.SetHead(s.Actions.Command.ActionGetRooms),n.SetToken(this.superThis.GSLive.Command.commandToken),n.SetData(i.ToString()),n.Send()}))}JoinRoom(e,t,i){return n(this,void 0,void 0,(function*(){if(""==this.superThis.GSLive.Command.commandToken)throw"User not connected to Command Server";if(this.superThis.GSLive.TurnbasedController.RoomID)throw"User is already in game room, please left from it first.";let n=new a.Data(this.superThis);n.SetID(e),n.SetExtra(t),n.SetPassword(i);let o=new a.Packet(this.superThis);o.SetHead(s.Actions.Command.ActionJoinRoom),o.SetToken(this.superThis.GSLive.Command.commandToken),o.SetData(n.ToString()),o.Send()}))}FindMember(e,t){return n(this,void 0,void 0,(function*(){if(""==this.superThis.GSLive.Command.commandToken)throw"User not connected to Command Server";let i=new a.Data(this.superThis);i.SetUser(e),i.SetMax(t);let n=new a.Packet(this.superThis);n.SetHead(s.Actions.Command.ActionFindUser),n.SetToken(this.superThis.GSLive.Command.commandToken),n.SetData(i.ToString()),n.Send()}))}InviteUser(e,t){return n(this,void 0,void 0,(function*(){if(""==this.superThis.GSLive.Command.commandToken)throw"User not connected to Command Server";let i=new a.Data(this.superThis);i.SetID(e),i.SetUser(t);let n=new a.Packet(this.superThis);n.SetHead(s.Actions.Command.ActionInviteUser),n.SetToken(this.superThis.GSLive.Command.commandToken),n.SetData(i.ToString()),n.Send()}))}GetInviteInbox(){return n(this,void 0,void 0,(function*(){if(""==this.superThis.GSLive.Command.commandToken)throw"User not connected to Command Server";let e=new a.Data(this.superThis);e.SetSyncMode(1);let t=new a.Packet(this.superThis);t.SetHead(s.Actions.Command.ActionGetInviteList),t.SetToken(this.superThis.GSLive.Command.commandToken),t.SetData(e.ToString()),t.Send()}))}AcceptInvite(e,t){return n(this,void 0,void 0,(function*(){if(""==this.superThis.GSLive.Command.commandToken)throw"User not connected to Command Server";if(this.superThis.GSLive.TurnbasedController.RoomID)throw"User is already in game room, please left from it first.";let i=new a.Data(this.superThis);i.SetInvite(e),i.SetExtra(t);let n=new a.Packet(this.superThis);n.SetHead(s.Actions.Command.ActionAcceptInvite),n.SetToken(this.superThis.GSLive.Command.commandToken),n.SetData(i.ToString()),n.Send()}))}GetCurrentRoomInfo(){return n(this,void 0,void 0,(function*(){if(this.superThis.GSLive.TurnbasedController.RoomID.length<1)throw"User is not in any game room";let e=new r.Packet(this.superThis);e.SetHead(s.Actions.TurnBased.GetRoomInfo),e.SetToken(this.superThis.GSLive.TurnbasedController.turnbasedToken),e.Send()}))}GetRoomMembersDetail(){return n(this,void 0,void 0,(function*(){if(this.superThis.GSLive.TurnbasedController.RoomID.length<1)throw"User is not in any game room";let e=new r.Packet(this.superThis);e.SetHead(s.Actions.TurnBased.ActionGetUsers),e.SetToken(this.superThis.GSLive.TurnbasedController.turnbasedToken),e.Send()}))}ChooseNext(e){return n(this,void 0,void 0,(function*(){if(this.superThis.GSLive.TurnbasedController.RoomID.length<1)throw"User is not in any game room";let t=new o.Data(this.superThis);e&&(t.Next=e);let i=new r.Packet(this.superThis);i.SetHead(s.Actions.TurnBased.ActionChooseNext),i.SetToken(this.superThis.GSLive.TurnbasedController.turnbasedToken),i.SetData(t.ToString()),i.Send()}))}TakeTurn(e,t){return n(this,void 0,void 0,(function*(){if(this.superThis.GSLive.TurnbasedController.RoomID.length<1)throw"User is not in any game room";let i=new o.Data(this.superThis);t&&(i.Next=t),i.Data=e;let n=new r.Packet(this.superThis);n.SetHead(s.Actions.TurnBased.ActionTakeTurn),n.SetToken(this.superThis.GSLive.TurnbasedController.turnbasedToken),n.SetData(i.ToString()),n.Send()}))}GetCurrentTurnMember(){return n(this,void 0,void 0,(function*(){if(this.superThis.GSLive.TurnbasedController.RoomID.length<1)throw"User is not in any game room";let e=new r.Packet(this.superThis);e.SetHead(s.Actions.TurnBased.ActionCurrentTurnDetail),e.SetToken(this.superThis.GSLive.TurnbasedController.turnbasedToken),e.Send()}))}Vote(e){return n(this,void 0,void 0,(function*(){if(this.superThis.GSLive.TurnbasedController.RoomID.length<1)throw"User is not in any game room";let t=new o.Data(this.superThis),i={};Object.keys(e).map((t=>{i[t]={0:e[t].Rank,1:`${e[t].Value}`}})),t.Outcomes=i;let n=new r.Packet(this.superThis);n.SetHead(s.Actions.TurnBased.ActionVote),n.SetToken(this.superThis.GSLive.TurnbasedController.turnbasedToken),n.SetData(t.ToString()),n.Send()}))}AcceptVote(e){return n(this,void 0,void 0,(function*(){if(this.superThis.GSLive.TurnbasedController.RoomID.length<1)throw"User is not in any game room";let t=new o.Data(this.superThis);t.ID=e;let i=new r.Packet(this.superThis);i.SetHead(s.Actions.TurnBased.ActionAcceptVote),i.SetToken(this.superThis.GSLive.TurnbasedController.turnbasedToken),i.SetData(t.ToString()),i.Send()}))}SetOrUpdateProperty(e,t){return n(this,void 0,void 0,(function*(){if(this.superThis.GSLive.TurnbasedController.RoomID.length<1)throw"User is not in any game room";let i=new o.Data(this.superThis);if(i.Head=1,e===o.PropertyType.Room&&(i.Head=3),!t.name||t.name.length<5||t.name.length>32)throw new Error("name of value should be between 5-32");if(!t.value||t.value.length>1024)throw new Error("value of value should less than 1024");i.ID=t.name,i.Data=t.value;let n=new r.Packet(this.superThis);n.SetHead(s.Actions.TurnBased.ModifyValue),n.SetToken(this.superThis.GSLive.TurnbasedController.turnbasedToken),n.SetData(i.ToString()),n.Send()}))}RemoveProperty(e,t){return n(this,void 0,void 0,(function*(){if(this.superThis.GSLive.TurnbasedController.RoomID.length<1)throw"User is not in any game room";let i=new o.Data(this.superThis);if(i.Head=2,e===o.PropertyType.Room&&(i.Head=4),!t||t.length<5||t.length>32)throw new Error("name of value should be between 5-32");i.ID=t;let n=new r.Packet(this.superThis);n.SetHead(s.Actions.TurnBased.ModifyValue),n.SetToken(this.superThis.GSLive.TurnbasedController.turnbasedToken),n.SetData(i.ToString()),n.Send()}))}LeaveRoom(e){return n(this,void 0,void 0,(function*(){if(this.superThis.GSLive.TurnbasedController.RoomID.length<1)throw"User is not in any game room";let t=new o.Data(this.superThis);t.Next=e;let i=new r.Packet(this.superThis);i.SetHead(s.Actions.TurnBased.ActionLeave),i.SetToken(this.superThis.GSLive.TurnbasedController.turnbasedToken),i.SetData(t.ToString()),i.Send()}))}}},1175:(e,t)=>{"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.Outcome=t.AutoMatchOptions=t.CreateRoomOptions=t.PropertyType=t.Data=void 0,t.Data=class{constructor(e){this.superThis=e}Cast(){return{0:this.Head,1:this.ID,2:this.Data,3:this.Next,4:this.Outcomes,5:this.Private}}ToString(){return JSON.stringify(this.Cast())}},(i=t.PropertyType||(t.PropertyType={})).Room="room",i.Member="member",t.CreateRoomOptions=class{constructor(){this.roomName="default",this.role="default",this.minPlayer=2,this.maxPlayer=2,this.isPrivate=!1,this.isPersist=!1,this.role="default",this.minPlayer=2,this.maxPlayer=2,this.isPersist=!1,this.extra=void 0,this.isPrivate=!1,this.roomPassword=void 0,this.roomName="default"}},t.AutoMatchOptions=class{constructor(){this.role="default",this.minPlayer=2,this.maxPlayer=2,this.isPersist=!1,this.role="default",this.minPlayer=2,this.maxPlayer=2,this.isPersist=!1,this.extra=null}},t.Outcome=class{get Value(){return this._Value}set Value(e){this._Value=e}get Rank(){return this._Rank}set Rank(e){this._Rank=e}Parse(e){this.Rank=e[0],this.Value=e[1]}}},7663:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GSLive=void 0;const n=i(1351),s=i(9875),o=i(6745),r=i(6587),a=i(2780),h=i(3904);class c{constructor(e){this.superThis=e,this.Cipher="",this.isEncriptionActive=!1,this.Command=new r.Command(e),this.TurnbasedController=new a.TurnBased(e),this.RealTimeController=new h.RealTime(e),this.TurnBased=new s.TurnBased(e),this.RealTime=new o.RealTime(e),this.Chats=new n.Chats(e)}IsCommandAvailable(){return!0}IsTurnBasedAvailable(){return!0}IsRealTimeAvailable(){return!0}GetPing(){return 0}}t.GSLive=c,c.CommandConnection=void 0},1764:function(e,t,i){"use strict";var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(s,o){function r(e){try{h(n.next(e))}catch(e){o(e)}}function a(e){try{h(n.throw(e))}catch(e){o(e)}}function h(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}h((n=n.apply(e,t||[])).next())}))},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Leaderboards=void 0;const o=s(i(9669)),r=i(7595),a=i(1563);t.Leaderboards=class{constructor(e){this.superThis=e}GetLeaderBoards(){return n(this,void 0,void 0,(function*(){try{let{data:e}=yield o.default.get(`${r.Url.Api.Endpoint}${r.Url.Api.Leaderboard}`,{headers:{"x-access-token":this.superThis.Authentication.gameToken}});return a.Log("GetLeaderBoards",e),e.leaderboard}catch(e){throw console.error(e),e.response?e.response.data.msg:e}}))}SubmitScore(e,t){return n(this,void 0,void 0,(function*(){try{let{data:i}=yield o.default.post(`${r.Url.Api.Endpoint}${r.Url.Api.LeaderboardV2}${e}`,{value:t},{headers:{"x-access-token":this.superThis.Authentication.gameToken}});return a.Log("SubmitScore",i),i.leaderboard}catch(e){throw e.response?e.response.data.msg:e}}))}GetLeaderBoardDetails(e,t=0,i=25){return n(this,void 0,void 0,(function*(){try{let{data:n}=yield o.default.get(`${r.Url.Api.Endpoint}${r.Url.Api.LeaderboardV2}${e}?skip=${t}&limit=${i}`,{headers:{"x-access-token":this.superThis.Authentication.gameToken}});return a.Log("GetLeaderBoardDetails",n),{scores:n.scores,leaderboard:n.leaderboard}}catch(e){throw e.response?e.response.data.msg:e}}))}GetCurrentPlayerScore(e){return n(this,void 0,void 0,(function*(){try{let{data:t}=yield o.default.get(`${r.Url.Api.Endpoint}${r.Url.Api.LeaderboardV2}${e}/me`,{headers:{"x-access-token":this.superThis.Authentication.gameToken}});return a.Log("GetCurrentPlayerScore",t),t}catch(e){throw e.response?e.response.data.msg:e}}))}}},965:function(e,t,i){"use strict";var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(s,o){function r(e){try{h(n.next(e))}catch(e){o(e)}}function a(e){try{h(n.throw(e))}catch(e){o(e)}}function h(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}h((n=n.apply(e,t||[])).next())}))},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Player=void 0;const o=i(7595),r=i(7339),a=i(1563),h=s(i(9669)),c=i(5877);t.Player=class{constructor(e){this.superThis=e}GetCurrentPlayer(){return n(this,void 0,void 0,(function*(){try{let{data:e}=yield h.default.get(`${o.Url.Api.Endpoint}${o.Url.Api.GetCurrentPlayer}`,{headers:{"x-access-token":this.superThis.Authentication.gameToken}});return a.Log("GetCurrentPlayer",e),e.data}catch(e){throw e&&e.response?e.response.data.msg:e}}))}GetMemberData(e){return n(this,void 0,void 0,(function*(){try{let{data:t}=yield h.default.get(`${o.Url.Api.Endpoint}${o.Url.Api.GetCurrentPlayer}/${e}`,{headers:{"x-access-token":this.superThis.Authentication.gameToken}});return a.Log("GetCurrentPlayer",t),t}catch(e){throw e&&e.response?e.response.data.msg:e}}))}GetLastLoginMemberInfo(){return n(this,void 0,void 0,(function*(){try{let{data:e}=yield h.default.post(`${o.Url.Api.Endpoint}${o.Url.Api.LastLoginInfo}`,{game:this.superThis.ClientID,secret:this.superThis.ClientSecret,device_id:c.v4()},{headers:{"x-access-token":this.superThis.Authentication.gameToken}});a.Log("GetLastLoginMemberInfo",e);let t=new r.MemberInfo;return t.Parse(e),t}catch(e){throw e&&e.response?e.response.data.msg:e}}))}EditCurrentPlayerProfile(e){return n(this,void 0,void 0,(function*(){try{let{data:t}=yield h.default.put(`${o.Url.Api.Endpoint}${o.Url.Api.GetCurrentPlayer}`,e.Export(),{headers:{"x-access-token":this.superThis.Authentication.gameToken}}),i=new r.MemberInfo;return i.Parse(t),i}catch(e){throw e&&e.response?e.response.data.msg:e}}))}ChangePassword(e,t){return n(this,void 0,void 0,(function*(){try{let{data:i}=yield h.default.post(`${o.Url.Api.Endpoint}${o.Url.Api.GetCurrentUser}/changepassword`,{old_password:e,new_password:t},{headers:{"x-access-token":this.superThis.Authentication.gameToken}});return a.Log("ChangePassword",i),i.data}catch(e){throw e&&e.response?e.response.data.msg:e}}))}GetActiveDevices(){return n(this,void 0,void 0,(function*(){try{let{data:e}=yield h.default.get(`${o.Url.Api.Endpoint}${o.Url.Api.Devices}`,{headers:{"x-access-token":this.superThis.Authentication.gameToken}});return a.Log("GetActiveDevices",e),e}catch(e){throw console.error(e),e&&e.response?e.response.data.msg:e}}))}RevokeActiveDevice(e){return n(this,void 0,void 0,(function*(){try{let{data:t}=yield h.default.post(`${o.Url.Api.Endpoint}${o.Url.Api.Devices}/${e}`,{headers:{"x-access-token":this.superThis.Authentication.gameToken}});return a.Log("RevokeActiveDevice",t),!0}catch(e){throw e&&e.response?e.response.data.msg:e}}))}}},7339:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Profile=t.MemberInfo=void 0,t.MemberInfo=class{constructor(){this.Parse=e=>{this.Id=e._id,this.Logo=e.logo,this.Name=e.name,this.Label=e.label,this.Tags=e.tags,this.Extra=e.extra,this.GlobalProperty=e.global_property,this.Email=e.email,this.PhoneNumber=e.phonenumber}}},t.Profile=class{Export(){return{name:this.Name,label:this.Label,tags:this.Tags,extra:this.Extra,global_property:this.GlobalProperty,options:this.Options,email:this.Email,mobile:this.Mobile}}}},3927:function(e,t,i){"use strict";var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(s,o){function r(e){try{h(n.next(e))}catch(e){o(e)}}function a(e){try{h(n.throw(e))}catch(e){o(e)}}function h(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}h((n=n.apply(e,t||[])).next())}))},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Save=void 0;const o=s(i(9669)),r=i(7595),a=i(1563);t.Save=class{constructor(e){this.superThis=e}Set(e,t){return n(this,void 0,void 0,(function*(){try{"object"==typeof t&&(t=JSON.stringify(t));let{data:i}=yield o.default.post(`${r.Url.Api.Endpoint}${r.Url.Api.SaveGame}`,{data:t,name:e},{headers:{"x-access-token":this.superThis.Authentication.gameToken}});return a.Log("SetSave",i),i.new}catch(e){throw e.response?e.response.data.msg:e}}))}Get(e=""){return n(this,void 0,void 0,(function*(){try{let{data:t}=yield o.default.get(`${r.Url.Api.Endpoint}${r.Url.Api.SaveGame}${e}`,{headers:{"x-access-token":this.superThis.Authentication.gameToken}});return a.Log("GetSave",t),t}catch(e){throw e.response?e.response.data.msg:e}}))}Remove(e){return n(this,void 0,void 0,(function*(){try{let{data:t}=yield o.default.delete(`${r.Url.Api.Endpoint}${r.Url.Api.SaveGame}${e}`,{headers:{"x-access-token":this.superThis.Authentication.gameToken}});return a.Log("RemoveSave",t),!0}catch(e){throw e.response?e.response.data.msg:e}}))}}},8529:function(e,t,i){"use strict";var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(s,o){function r(e){try{h(n.next(e))}catch(e){o(e)}}function a(e){try{h(n.throw(e))}catch(e){o(e)}}function h(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}h((n=n.apply(e,t||[])).next())}))},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Friends=void 0;const o=i(7595),r=i(1563),a=s(i(9669));t.Friends=class{constructor(e){this.superThis=e}FindMembers(e,t=0,i=25){return n(this,void 0,void 0,(function*(){try{let n=`${o.Url.Api.Endpoint}${o.Url.Api.Friends}?q=${e}&skip=${t}&limit=${i}`,{data:s}=yield a.default.get(n,{headers:{"x-access-token":this.superThis.Authentication.gameToken}});return r.Log("FindMembers",s),[s.count,s.list]}catch(e){throw e&&e.response?e.response.data.msg:e}}))}GetMyFriends(e=0,t=25){return n(this,void 0,void 0,(function*(){try{let i=`${o.Url.Api.Endpoint}${o.Url.Api.Friends}/me?skip=${e}&limit=${t}`,{data:n}=yield a.default.get(i,{headers:{"x-access-token":this.superThis.Authentication.gameToken}});return r.Log("GetMyFriends",n),[n.count,n.list]}catch(e){throw e&&e.response?e.response.data.msg:e}}))}GetFriendRequests(e=0,t=25){return n(this,void 0,void 0,(function*(){try{let i=`${o.Url.Api.Endpoint}${o.Url.Api.Friends}/me/pending?skip=${e}&limit=${t}`,{data:n}=yield a.default.get(i,{headers:{"x-access-token":this.superThis.Authentication.gameToken}});return r.Log("GetFriendRequests",n),[n.count,n.list]}catch(e){throw e&&e.response?e.response.data.msg:e}}))}SendFriendRequest(e){return n(this,void 0,void 0,(function*(){try{let t=`${o.Url.Api.Endpoint}${o.Url.Api.Friends}/${e}`,{data:i}=yield a.default.post(t,void 0,{headers:{"x-access-token":this.superThis.Authentication.gameToken}});return r.Log("SendFriendRequest",i),i.status}catch(e){throw e&&e.response?e.response.data.msg:e}}))}AcceptFriendRequest(e){return n(this,void 0,void 0,(function*(){try{let t=`${o.Url.Api.Endpoint}${o.Url.Api.Friends}/${e}`,{data:i}=yield a.default.put(t,void 0,{headers:{"x-access-token":this.superThis.Authentication.gameToken}});return r.Log("AcceptFriendRequest",i),i.status}catch(e){throw e&&e.response?e.response.data.msg:e}}))}DeleteFriend(e){return n(this,void 0,void 0,(function*(){try{let t=`${o.Url.Api.Endpoint}${o.Url.Api.Friends}/${e}`,{data:i}=yield a.default.put(t,void 0,{headers:{"x-access-token":this.superThis.Authentication.gameToken}});return r.Log("AcceptFriendRequest",i),i.status}catch(e){throw e&&e.response?e.response.data.msg:e}}))}}},7137:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Social=void 0;const n=i(8529);t.Social=class{constructor(e){this.superThis=e,this.Friends=new n.Friends(e)}}},869:function(e,t,i){"use strict";var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(s,o){function r(e){try{h(n.next(e))}catch(e){o(e)}}function a(e){try{h(n.throw(e))}catch(e){o(e)}}function h(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}h((n=n.apply(e,t||[])).next())}))},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Table=void 0;const o=s(i(9669)),r=i(7595);t.Table=class{constructor(e){this.superThis=e}GetTableItems(e,t={skip:0,limit:25,find:void 0,rowsOwner:void 0,sort:void 0}){return n(this,void 0,void 0,(function*(){try{let i=`${r.Url.Api.Endpoint}${r.Url.Api.Table}${e}?skip=${t.skip}&limit=${t.limit}`;t.rowsOwner&&""!=t.rowsOwner&&(i+=`&owner=${t.rowsOwner}`),t.sort&&t.sort[0]&&t.sort[1]&&""!=t.sort[0]&&(i+=`&sort=${t.sort[0]}&sortby=${t.sort[1]}`),t.find&&t.find[0]&&t.find[1]&&""!=t.find[0]&&(i+=`&conditionProperty=${t.find[0]}&conditionValue=${t.find[1]}`);let{data:n}=yield o.default.get(i,{headers:{"x-access-token":this.superThis.Authentication.gameToken}});return n}catch(e){throw e.response?e.response.data.msg:e}}))}Aggrigation(e){}GetTableItem(e,t){return n(this,void 0,void 0,(function*(){try{let i=`${r.Url.Api.Endpoint}${r.Url.Api.Table}${e}/${t}`,{data:n}=yield o.default.get(i,{headers:{"x-access-token":this.superThis.Authentication.gameToken}});return n.data}catch(e){throw e.response?e.response.data.msg:e}}))}AddItemToTable(e,t){return n(this,void 0,void 0,(function*(){try{let i=`${r.Url.Api.Endpoint}${r.Url.Api.Table}${e}`,{data:n}=yield o.default.post(i,t,{headers:{"x-access-token":this.superThis.Authentication.gameToken}});return n.data}catch(e){throw e.response?e.response.data.msg:e}}))}UpdateTableItem(e,t,i){return n(this,void 0,void 0,(function*(){try{let n=`${r.Url.Api.Endpoint}${r.Url.Api.Table}${e}/${t}`,{data:s}=yield o.default.put(n,i,{headers:{"x-access-token":this.superThis.Authentication.gameToken}});return s.data}catch(e){throw e.response?e.response.data.msg:e}}))}DeleteTableItem(e,t){return n(this,void 0,void 0,(function*(){try{let i=`${r.Url.Api.Endpoint}${r.Url.Api.Table}${e}/${t}`,{data:n}=yield o.default.delete(i,{headers:{"x-access-token":this.superThis.Authentication.gameToken}});return n.status}catch(e){throw e.response?e.response.data.msg:e}}))}DeleteAllTableItems(e){return n(this,void 0,void 0,(function*(){try{let t=`${r.Url.Api.Endpoint}${r.Url.Api.Table}${e}`,{data:i}=yield o.default.delete(t,{headers:{"x-access-token":this.superThis.Authentication.gameToken}});return i.status}catch(e){throw e.response?e.response.data.msg:e}}))}}},6707:function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.GameService=void 0;const s=i(9182),o=n(i(6555)),r=i(8732),a=i(1764),h=i(2454),c=i(965),u=i(3927),d=i(869),l=i(7663),m=i(7137);t.GameService=class{constructor(e,t,i=!0){if(this.ClientID="",this.ClientSecret="",this.Verbose=!1,this.onReady=()=>{},"string"!=typeof e||"string"!=typeof t)throw new Error(o.default.Internal.InvalidInput);this.ClientID=e,this.ClientSecret=t,this.Verbose=i,this.Authentication=new s.Authentication(this),this.Assets=new r.Assets(this),this.Achievements=new h.Achievements(this),this.Leaderboards=new a.Leaderboards(this),this.Player=new c.Player(this),this.Save=new u.Save(this),this.Table=new d.Table(this),this.GSLive=new l.GSLive(this),this.Social=new m.Social(this)}IsAuthenticated(){return""!=this.Authentication.gameToken}IsCommandAvailabe(){var e;return(null===(e=l.GSLive.CommandConnection)||void 0===e?void 0:e.readyState)===WebSocket.OPEN&&""!=this.GSLive.Command.commandToken}}},7595:(e,t)=>{"use strict";var i,n,s;Object.defineProperty(t,"__esModule",{value:!0}),t.Actions=t.Url=void 0,function(e){e.Endpoint="https://api.gamesservice.ir",e.Login="/auth/app/login",e.Start="/auth/start",e.SMSAuth="/auth/phone",e.SMSAuthCallback="/Auth/phone/callback",e.GetCurrentPlayer="/v1/member/",e.GetCurrentUser="/v1/User",e.LastLoginInfo="/auth/app/login/info",e.Devices="/v1/devices",e.GetAchievements="/v1/achievement",e.GetAchievementsv2="/v2/achievement",e.DownloadAssets="/game/",e.SaveGame="/v1/savegame/",e.Leaderboard="/v1/leaderboard/",e.LeaderboardV2="/v2/leaderboard/",e.Table="/v1/bucket/",e.Friends="/v1/friends"}(i||(i={})),function(e){e.Endpoint="https://dbaas.gamesservice.ir"}(n||(n={})),function(e){e.Endpoint="ws://localhost:3004"}(s||(s={}));let o={Api:i,DBaaS:n,Command:s};var r,a,h;t.Url=o,function(e){e[e.ActionAuth=0]="ActionAuth",e[e.ActionAutoMatch=1]="ActionAutoMatch",e[e.ActionCreateRoom=2]="ActionCreateRoom",e[e.ActionGetRooms=3]="ActionGetRooms",e[e.ActionJoinRoom=4]="ActionJoinRoom",e[e.ActionPing=5]="ActionPing",e[e.ActionInviteUser=6]="ActionInviteUser",e[e.ActionKickUser=7]="ActionKickUser",e[e.ActionGetInviteList=8]="ActionGetInviteList",e[e.ActionAcceptInvite=9]="ActionAcceptInvite",e[e.ActionFindUser=10]="ActionFindUser",e[e.ActionNotification=11]="ActionNotification",e[e.ActionInviteNotif=15]="ActionInviteNotif",e[e.ActionMirror=99]="ActionMirror",e[e.LeftWaitingQ=16]="LeftWaitingQ",e[e.ActionSubscribe=12]="ActionSubscribe",e[e.ActionPrivateChat=18]="ActionPrivateChat",e[e.ActionChat=13]="ActionChat",e[e.ActionUnSubscribe=14]="ActionUnSubscribe",e[e.ActionGetSubscribedChannels=17]="ActionGetSubscribedChannels",e[e.ActionGetMembersOfChannel=19]="ActionGetMembersOfChannel",e[e.ActionGetLastGroupMessages=20]="ActionGetLastGroupMessages",e[e.ActionGetPendingMessages=21]="ActionGetPendingMessages"}(r||(r={})),function(e){e[e.ActionAuth=1]="ActionAuth",e[e.ActionPing=2]="ActionPing",e[e.ActionCreate=10]="ActionCreate",e[e.ActionJoin=11]="ActionJoin",e[e.ActionTakeTurn=4]="ActionTakeTurn",e[e.ActionChooseNext=5]="ActionChooseNext",e[e.ActionLeave=6]="ActionLeave",e[e.ActionVote=7]="ActionVote",e[e.ActionAcceptVote=8]="ActionAcceptVote",e[e.ActionGetUsers=9]="ActionGetUsers",e[e.ActionCurrentTurnDetail=12]="ActionCurrentTurnDetail",e[e.ModifyValue=13]="ModifyValue",e[e.ModifyRoomValue=16]="ModifyRoomValue",e[e.GetRoomInfo=14]="GetRoomInfo",e[e.GetMemberSnapShot=15]="GetMemberSnapShot"}(a||(a={})),function(e){e[e.ActionAuth=1]="ActionAuth",e[e.ActionData=2]="ActionData",e[e.ActionPublicMessage=3]="ActionPublicMessage",e[e.ActionPrivateMessage=4]="ActionPrivateMessage",e[e.ActionJoin=5]="ActionJoin",e[e.ActionMembersDetail=6]="ActionMembersDetail",e[e.ActionLeave=7]="ActionLeave",e[e.ActionDestroy=8]="ActionDestroy",e[e.ActionStatus=9]="ActionStatus",e[e.ActionMirror=10]="ActionMirror",e[e.ActionEventMessage=11]="ActionEventMessage",e[e.ActionGetRoomSnapshot=12]="ActionGetRoomSnapshot",e[e.ActionObserver=13]="ActionObserver",e[e.ActionRoomInfo=14]="ActionRoomInfo"}(h||(h={}));let c={Command:r,TurnBased:a,RealTime:h,Error:100};t.Actions=c},6555:(e,t)=>{"use strict";var i,n;Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.InvalidInput="Check input parameters of function"}(i||(i={})),function(e){e.INVALID_ID="Request input's are not valid"}(n||(n={})),t.default={Internal:i,Command:n}},1563:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Log=void 0,t.Log=function(e,t){console.log(e,t)}},8827:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.get=void 0;const n=i(5877);t.get=function(){let e={DeviceID:n.v4()};return JSON.stringify(e)}},5877:(e,t,i)=>{var n=i(3570),s=i(1171),o=s;o.v1=n,o.v4=s,e.exports=o},5327:e=>{for(var t=[],i=0;i<256;++i)t[i]=(i+256).toString(16).substr(1);e.exports=function(e,i){var n=i||0,s=t;return[s[e[n++]],s[e[n++]],s[e[n++]],s[e[n++]],"-",s[e[n++]],s[e[n++]],"-",s[e[n++]],s[e[n++]],"-",s[e[n++]],s[e[n++]],"-",s[e[n++]],s[e[n++]],s[e[n++]],s[e[n++]],s[e[n++]],s[e[n++]]].join("")}},5217:e=>{var t="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(t){var i=new Uint8Array(16);e.exports=function(){return t(i),i}}else{var n=new Array(16);e.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),n[t]=e>>>((3&t)<<3)&255;return n}}},3570:(e,t,i)=>{var n,s,o=i(5217),r=i(5327),a=0,h=0;e.exports=function(e,t,i){var c=t&&i||0,u=t||[],d=(e=e||{}).node||n,l=void 0!==e.clockseq?e.clockseq:s;if(null==d||null==l){var m=o();null==d&&(d=n=[1|m[0],m[1],m[2],m[3],m[4],m[5]]),null==l&&(l=s=16383&(m[6]<<8|m[7]))}var p=void 0!==e.msecs?e.msecs:(new Date).getTime(),f=void 0!==e.nsecs?e.nsecs:h+1,v=p-a+(f-h)/1e4;if(v<0&&void 0===e.clockseq&&(l=l+1&16383),(v<0||p>a)&&void 0===e.nsecs&&(f=0),f>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");a=p,h=f,s=l;var T=(1e4*(268435455&(p+=122192928e5))+f)%4294967296;u[c++]=T>>>24&255,u[c++]=T>>>16&255,u[c++]=T>>>8&255,u[c++]=255&T;var S=p/4294967296*1e4&268435455;u[c++]=S>>>8&255,u[c++]=255&S,u[c++]=S>>>24&15|16,u[c++]=S>>>16&255,u[c++]=l>>>8|128,u[c++]=255&l;for(var g=0;g<6;++g)u[c+g]=d[g];return t||r(u)}},1171:(e,t,i)=>{var n=i(5217),s=i(5327);e.exports=function(e,t,i){var o=t&&i||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var r=(e=e||{}).random||(e.rng||n)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t)for(var a=0;a<16;++a)t[o+a]=r[a];return t||s(r)}},7026:e=>{"use strict";e.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}}},t={};function i(n){var s=t[n];if(void 0!==s)return s.exports;var o=t[n]={exports:{}};return e[n].call(o.exports,o,o.exports,i),o.exports}var n={};return(()=>{"use strict";var e=n;Object.defineProperty(e,"__esModule",{value:!0});const t=i(6707);e.default=t.GameService})(),n})()}));
//# sourceMappingURL=gameservice-sdk.js.map