@cg-devcenter/rtc-fpnn-webjs-sdk 1.0.0-cg.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +113 -0
- package/dist/rtm.d.cts +3 -0
- package/dist/rtm.d.mts +59 -0
- package/dist/rtm.d.ts +639 -0
- package/dist/rtm.min.js +27 -0
- package/dist/rtm.mjs +18 -0
- package/dist/rtm.shared-worker.js +27 -0
- package/dist/rtm.vite-plugin.d.mts +8 -0
- package/dist/rtm.vite-plugin.mjs +23 -0
- package/dist/rtm.vite.d.ts +59 -0
- package/dist/rtm.vite.mjs +33 -0
- package/dist/rtm.webpack4-adapter.cjs +29 -0
- package/dist/rtm.webpack4-plugin.cjs +50 -0
- package/dist/rtm.webpack4-plugin.d.cts +5 -0
- package/docs/CAPABILITIES.md +129 -0
- package/docs/Chat.md +278 -0
- package/docs/Data.md +33 -0
- package/docs/EventProcess.md +126 -0
- package/docs/Files.md +52 -0
- package/docs/Friends.md +50 -0
- package/docs/Groups.md +64 -0
- package/docs/LEGACY_RTM_TLV_COMPATIBILITY.md +188 -0
- package/docs/Messages.md +183 -0
- package/docs/PROTOCOL_MIGRATION.md +148 -0
- package/docs/RTM_MIGRATION.md +206 -0
- package/docs/Rooms.md +67 -0
- package/docs/System.md +49 -0
- package/docs/TLV.md +62 -0
- package/docs/TLV_CONTRACT.md +180 -0
- package/docs/USAGE.md +624 -0
- package/docs/Users.md +48 -0
- package/docs/ValueAdded.md +82 -0
- package/package.json +93 -0
package/dist/rtm.min.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.rtm=t():e.rtm=t()}("undefined"!=typeof globalThis?globalThis:this,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=18)}([function(e,t,r){"use strict";var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();var o=r(1),i=o.msgpack,s=o.Int64BE,a=o.Uint64BE,u={RTM_EC_UNKNOWN_METHOD:20004,RTM_EC_INVALID_PROJECT_ID_OR_USER_ID:200001,RTM_EC_INVALID_PROJECT_ID_OR_SIGN:200002,RTM_EC_INVALID_FILE_OR_SIGN_OR_TOKEN:200003,RTM_EC_ATTRS_WITHOUT_SIGN_OR_EXT:200004,RTM_EC_API_FREQUENCY_LIMITED:200010,RTM_EC_MESSAGE_FREQUENCY_LIMITED:200011,RTM_EC_FORBIDDEN_METHOD:200020,RTM_EC_PERMISSION_DENIED:200021,RTM_EC_UNAUTHORIZED:200022,RTM_EC_DUPLCATED_AUTH:200023,RTM_EC_AUTH_DENIED:200024,RTM_EC_ADMIN_LOGIN:200025,RTM_EC_ADMIN_ONLY:200026,RTM_EC_INVALID_AUTH_TOEKN:200027,RTM_EC_LARGE_MESSAGE_OR_ATTRS:200030,RTM_EC_LARGE_FILE_OR_ATTRS:200031,RTM_EC_TOO_MANY_ITEMS_IN_PARAMETERS:200032,RTM_EC_EMPTY_PARAMETER:200033,RTM_EC_INVALID_PARAMETER:200034,RTM_EC_NOT_IN_ROOM:200040,RTM_EC_NOT_GROUP_MEMBER:200041,RTM_EC_MAX_GROUP_MEMBER_COUNT:200042,RTM_EC_NOT_FRIEND:200043,RTM_EC_BANNED_IN_GROUP:200044,RTM_EC_BANNED_IN_ROOM:200045,RTM_EC_EMPTY_GROUP:200046,RTM_EC_ENTER_TOO_MANY_ROOMS:200047,RTM_EC_UNSUPPORTED_LANGUAGE:200050,RTM_EC_EMPTY_TRANSLATION:200051,RTM_EC_SEND_TO_SELF:200052,RTM_EC_DUPLCATED_MID:200053,RTM_EC_SENSITIVE_WORDS:200054,RTM_EC_UNKNOWN_ERROR:200999},c={image:40,audio:41,video:42,file:50},f={text:30,audio:31,cmd:32},l={kickOut:"kickout",kickOutRoom:"kickoutroom",recvMessage:"pushmsg",recvGroupMessage:"pushgroupmsg",recvRoomMessage:"pushroommsg",recvBroadcastMessage:"pushbroadcastmsg",recvFile:"pushfile",recvGroupFile:"pushgroupfile",recvRoomFile:"pushroomfile",recvBroadcastFile:"pushbroadcastfile",recvPing:"ping",recvChat:"pushchat",recvAudio:"pushaudio",recvCmd:"pushcmd",recvGroupChat:"pushgroupchat",recvGroupAudio:"pushgroupaudio",recvGroupCmd:"pushgroupcmd",recvRoomChat:"pushroomchat",recvRoomAudio:"pushroomaudio",recvRoomCmd:"pushroomcmd",recvBroadcastChat:"pushbroadcastchat",recvBroadcastAudio:"pushbroadcastaudio",recvBroadcastCmd:"pushbroadcastcmd"},h={kickOut:"event.kicked",kickOutRoom:"event.room_removed",recvBroadcastMessage:"event.broadcast",recvGroupMessage:"event.group",recvMessage:"event.direct",recvRoomMessage:"event.room"},d=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return n(e,null,[{key:"ERROR_CODE",get:function(){return u}},{key:"MsgPack",get:function(){return i}},{key:"FILE_TYPE",get:function(){return c}},{key:"CHAT_TYPE",get:function(){return f}},{key:"SERVER_PUSH",get:function(){return l}},{key:"TLV_SERVER_PUSH",get:function(){return h}},{key:"MID_TTL",get:function(){return 5e3}},{key:"API_VERSION",get:function(){return"2.7.3"}},{key:"SDK_VERSION",get:function(){return"2.7.6"}},{key:"MAX_PING_SECONDS",get:function(){return 60}}]),e}();d.Int64=function(e){return new s(""+e)},d.Uint64=function(e){return new a(""+e)},e.exports=d},function(e,t,r){"use strict";var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};var s=function(){if(i.fpnn)return i.fpnn;var e="undefined"!=typeof self&&"function"==typeof self.importScripts&&"function"==typeof self.WebSocket;return"undefined"!=typeof window||e?r(22):{FPClient:function e(){throw o(this,e),new Error('protocol: "fpnn" requires the browser FPNN runtime; use protocol: "tlv-v1" with WebSocket or webSocketFactory')},FPConfig:{ERROR_CODE:{FPNN_EC_OK:0,FPNN_EC_CORE_UNKNOWN_ERROR:20001,FPNN_EC_CORE_CONNECTION_CLOSED:20002,FPNN_EC_CORE_INVALID_CONNECTION:20012}},FPError:function(e){function t(e,r){o(this,t);var n=r instanceof Error?r:new Error(String(r||"FPNN error")),i=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,n.message));return i.code=e,i.name="FPError",i.stack=n.stack||i.stack,i.error=n,i}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,Error),n(t,[{key:"toString",value:function(){return"code: "+this.code+" ex: "+this.message}}]),t}(),FPEvent:{assign:function(e){if(!e||Object.prototype.hasOwnProperty.call(e,"events"))throw new Error(e+" is null or hasOwnProperty [ events ]");if(Object.prototype.hasOwnProperty.call(e,"on")||Object.prototype.hasOwnProperty.call(e,"emit")||Object.prototype.hasOwnProperty.call(e,"removeEvent"))throw new Error(e+" hasOwnProperty [ on | emit | removeEvent | listenerCount]");e.events={},e.on=function(t,r){Object.prototype.hasOwnProperty.call(e.events,t)||(e.events[t]=[]),-1===e.events[t].indexOf(r)&&e.events[t].push(r)},e.emit=function(t){var r=Array.prototype.slice.call(arguments,1);(e.events[t]||[]).slice().forEach((function(t){t&&t.apply(e,r)}))},e.removeEvent=function(t,r){if(0===arguments.length)e.events={};else if(1===arguments.length)Object.prototype.hasOwnProperty.call(e.events,t)&&delete e.events[t];else if(e.events[t]){var n=e.events[t].indexOf(r);-1!==n&&e.events[t].splice(n,1)}},e.listenerCount=function(t){return Object.prototype.hasOwnProperty.call(e.events,t)?e.events[t].length:0}}}}}(),a=i.msgpack||r(23),u=i.md5||r(24),c=i.Int64BE&&i.Uint64BE?{Int64BE:i.Int64BE,Uint64BE:i.Uint64BE}:r(27);e.exports={fpnn:s,msgpack:a,md5:u,Int64BE:c.Int64BE,Uint64BE:c.Uint64BE}},function(e,t,r){"use strict";(function(t){var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();var o=r(0),i=r(8),s=r(9),a=r(5),u=r(1),c=u.fpnn,f=u.md5,l=r(6).normalizeFpnnEndpoint,h=r(12).normalizeClientOptions;function d(e){var t="ws://";return this._ssl&&(t="wss://"),t+e+"/service/websocket"}function p(e){var t=c.FPConfig.ERROR_CODE;return e===t.FPNN_EC_CORE_INVALID_CONNECTION||e===t.FPNN_EC_CORE_CONNECTION_CLOSED||e===t.FPNN_EC_CORE_UNKNOWN_ERROR||e===o.ERROR_CODE.RTM_EC_API_FREQUENCY_LIMITED||e===o.ERROR_CODE.RTM_EC_UNKNOWN_ERROR}function g(e,t){return!e&&!p(t)}function y(e,t){if(this._reconnectTimeout&&(clearTimeout(this._reconnectTimeout),this._reconnectTimeout=0),this._checkLastPingTimerID&&(clearInterval(this._checkLastPingTimerID),this._checkLastPingTimerID=0),null!=this._baseClient){var r=this._baseClient;this._baseClient=null,r.destroy()}"tlv-v1"===this._protocol?this._baseClient=new s({endpoint:this._tlvEndpoint,heartbeatIdleMs:this._tlvHeartbeatIdleMs,heartbeatTimeoutMs:this._tlvHeartbeatTimeoutMs,connectionTimeout:this._connectionTimeout,legacyMsgOptions:this._msgOptions,pushDedupTtlMs:this._pushDedupTtlMs,requestMetadata:this._requestMetadata,requestTimeout:this._requestTimeout,webSocketFactory:this._webSocketFactory}):this._baseClient=new c.FPClient({endpoint:d.call(this,this._endpoint),autoReconnect:!1,connectionTimeout:this._connectionTimeout,platformImpl:this._platformImpl});var n=this._baseClient,o=this,i=!1,a=!1,u=!1,f=!1;function l(t,r){u||(u=!0,e&&e(t,r))}"tlv-v1"===this._protocol&&(this._canReconnect=this._autoReconnect),n.on("close",(function(){n===o._baseClient&&(a||f||(f=!0,l(!1,c.FPConfig.ERROR_CODE.FPNN_EC_CORE_INVALID_CONNECTION),"tlv-v1"===o._protocol&&_.call(o)))})),n.on("error",(function(e){n===o._baseClient&&(a||b.call(o,e),i||l(!1,c.FPConfig.ERROR_CODE.FPNN_EC_CORE_INVALID_CONNECTION))})),n.on("connect",(function(){n===o._baseClient&&(i||(i=!0,o._requireClose=!1,m.call(o,(function(e,t){if(e)a=!0;else if("tlv-v1"===o._protocol&&g(e,t))o._canReconnect=!1;else if("tlv-v1"===o._protocol&&!f&&n===o._baseClient)return l(e,t),void n.close();l(e,t)}),t)))})),n.processor=this._processor,n.connect()}function m(e,t){var r=this._baseClient;if(r){var n={pid:this._pid,uid:this._uid,token:this._token,version:this._clientVersion||"WebSocket_"+o.SDK_VERSION};this._attrs&&(n.attrs=this._attrs),"tlv-v1"===this._protocol&&(void 0!==this._authSec&&(n.ts=this._authSec),void 0!==this._authVer&&(n.authv=this._authVer),void 0!==this._locale&&(n.lang=this._locale));var i={flag:1,method:"auth",payload:o.MsgPack.encode(n,this._msgOptions)},s=this;A.call(this,r,i,(function(t,n){if(r===s._baseClient){var i=n&&("tlv-v1"===s._protocol?n.accepted:n.ok);if(i)return s._reconnectTimeout&&(clearTimeout(s._reconnectTimeout),s._reconnectTimeout=0),s._reconnectCount=0,s._reconnectInterval=0,s._canReconnect=!0,r.on("close",(function(){r===s._baseClient&&_.call(s)})),r.on("error",(function(e){r===s._baseClient&&b.call(s,e)})),"tlv-v1"===s._protocol?r.markAuthenticated():(s._lastPingTime=parseInt(Date.now()/1e3),s._checkLastPingTimerID=setInterval((function(){parseInt(Date.now()/1e3)-s._lastPingTime>=s._maxPingIntervalSeconds&&(b.call(s,new c.FPError(c.FPConfig.ERROR_CODE.FPNN_EC_CORE_CONNECTION_CLOSED,Error("Close connection for no ping, start reconnect"))),s.startAutoReconnect())}),1e3*s._maxPingIntervalSeconds/2)),void(e&&e(!0,c.FPConfig.ERROR_CODE.FPNN_EC_OK));var a=!1;if(n&&!i){var u="tlv-v1"===s._protocol?o.ERROR_CODE.RTM_EC_INVALID_AUTH_TOEKN:c.FPConfig.ERROR_CODE.FPNN_EC_OK;e&&e(!1,u),"tlv-v1"===s._protocol&&b.call(s,new c.FPError(u,new Error("Gate rejected auth.login (accepted=false)")))}t&&(e&&e(!1,t.code),b.call(s,t),a="tlv-v1"===s._protocol?p(t.code):!!s._reconnectTimeout),a||(s._reconnectTimeout&&(clearTimeout(s._reconnectTimeout),s._reconnectTimeout=0),s._reconnectCount=0,s._reconnectInterval=0)}}),t)}else e&&e(!1,c.FPConfig.ERROR_CODE.FPNN_EC_CORE_INVALID_CONNECTION)}function _(){return this._reconnectTimeout&&(clearTimeout(this._reconnectTimeout),this._reconnectTimeout=0),this._checkLastPingTimerID&&(clearInterval(this._checkLastPingTimerID),this._checkLastPingTimerID=0),this._requireClose?(this.emit("SessionClosed",c.FPConfig.ERROR_CODE.FPNN_EC_OK),this._reconnectCount=0,this._reconnectInterval=0,void(this._canReconnect=!1)):this._autoReconnect?(b.call(this,new c.FPError(c.FPConfig.ERROR_CODE.FPNN_EC_CORE_UNKNOWN_ERROR,new Error("connection closed, requireClose: "+this._requireClose))),void v.call(this)):(this.emit("SessionClosed",c.FPConfig.ERROR_CODE.FPNN_EC_CORE_UNKNOWN_ERROR),this._reconnectCount=0,this._reconnectInterval=0,void(this._canReconnect=!1))}function v(){if(!this._requireClose&&this._canReconnect&&!this._reconnectTimeout){var e=0;this._reconnectCount>=this._regressiveStrategy.startConnectFailedCount&&((e=this._reconnectInterval+1e3*this._regressiveStrategy.maxIntervalSeconds/this._regressiveStrategy.linearRegressiveCount)>1e3*this._regressiveStrategy.maxIntervalSeconds&&(e=1e3*this._regressiveStrategy.maxIntervalSeconds),this._reconnectInterval=e),this._reconnectCount+=1;var t=this._reconnectCount,r=this;this._reconnectTimeout=setTimeout((function(){r._reconnectTimeout=0;var n="tlv-v1"===r._protocol?void 0:e;r.login(r._uid,r._token,(function(e,n){n==c.FPConfig.ERROR_CODE.FPNN_EC_OK?e?(r.emit("ReloginCompleted",!0,!1,c.FPConfig.ERROR_CODE.FPNN_EC_OK,t),b.call(r,new c.FPError(c.FPConfig.ERROR_CODE.FPNN_EC_OK,new Error("relogin successfully, reconnectCount: "+t))),r._reconnectCount=0,r._reconnectInterval=0):(r.emit("ReloginCompleted",!1,!1,o.ERROR_CODE.RTM_EC_INVALID_AUTH_TOEKN,t),r.emit("SessionClosed",o.ERROR_CODE.RTM_EC_INVALID_AUTH_TOEKN),b.call(r,new c.FPError(o.ERROR_CODE.RTM_EC_UNKNOWN_ERROR,new Error("relogin fail, token error, reconnectCount: "+t))),r._reconnectCount=0,r._reconnectInterval=0,r._canReconnect=!1):"tlv-v1"===r._protocol&&g(e,n)?(r.emit("ReloginCompleted",!1,!1,n,t),r.emit("SessionClosed",n),b.call(r,new c.FPError(n,new Error("relogin terminal auth failure, errorCode: "+n+", reconnectCount: "+t))),r._reconnectCount=0,r._reconnectInterval=0,r._canReconnect=!1):(r.emit("ReloginCompleted",!1,!0,n,t),"tlv-v1"!==r._protocol&&v.call(r),b.call(r,new c.FPError(o.ERROR_CODE.RTM_EC_UNKNOWN_ERROR,new Error("relogin fail, errorCode: "+n+", reconnectCount: "+t))))}),n)}),e)}}function b(e){this.emit("ErrorRecorder",e)}function w(e){return this._md5?this._md5(e).toUpperCase():f(e).toUpperCase()}function E(e,r,n,i,s){var a=this;n&&"0"!=n.toString()||(n=P.call(this)),k.call(a,e,(function(u,f){if(u)i&&i({mid:n,error:u},null);else{var l=f.token,h=f.endpoint,d=null;if(null!=r&&void 0!==r.name){var p=r.name.lastIndexOf(".");-1!=p&&(d=r.name.slice(p+1))}if(l&&h){var g=new FileReader;g.onload=function(r){var u=t.from(r.target.result);if(console.log("content:"),console.log(u.length),u){var f=w.call(a,u).toLowerCase(),p=w.call(a,f+":"+l).toLowerCase(),g=a._endpoint.split(":"),y="ws://fileproxy-"+g[0]+":13461/service/websocket";a._ssl&&(y="wss://fileproxy-"+g[0]+":13462/service/websocket");var m=new c.FPClient({endpoint:y,autoReconnect:!1,connectionTimeout:s,platformImpl:a._platformImpl});m.on("close",(function(){})),m.on("error",(function(e){var t=o.ERROR_CODE.RTM_EC_UNKNOWN_ERROR;void 0!==e.code&&(t=e.code),b.call(a,new c.FPError(t,e))})),m.on("connect",(function(){var t={token:l,sign:p,ext:d,file:u,endpoint:h};for(var r in e)t[r]=e[r];R.call(a,m,t,n,i,s)})),m.connect()}else i&&i({mid:n,error:new c.FPError(o.ERROR_CODE.RTM_EC_UNKNOWN_ERROR,new Error("no file content!"))},null)},g.readAsArrayBuffer(r)}else i&&i({mid:n,error:new c.FPError(o.ERROR_CODE.RTM_EC_UNKNOWN_ERROR,new Error(JSON.stringify(f)))},null)}}))}function k(e,t,r){var n={};for(var i in e)"mtype"!=i&&(n[i]=e[i]);var s={flag:1,method:"filetoken",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,s,t,r)}function R(e,t,r,n,i){var s={pid:this._pid,from:this._uid,mid:r,endpoint:t.endpoint};for(var a in t)"sign"!=a?"ext"!=a&&"cmd"!=a&&(s[a]=t[a]):s.attrs=JSON.stringify({rtm:{sign:t.sign,ext:t.ext}});var u={flag:1,method:t.cmd,payload:o.MsgPack.encode(s,this._msgOptions)};A.call(this,e,u,(function(t,r){e.destroy(),t?n&&n({mid:s.mid,error:t},null):(void 0!==r.mtime&&(r.mtime=new o.Int64(""+r.mtime)),n&&n(null,{mid:s.mid,payload:r}))}),i)}function P(){++this._midSeq>=999&&(this._midSeq=0);var e=this._midSeq.toString();return this._midSeq<100&&(e="0"+e),this._midSeq<10&&(e="0"+e),new o.Int64(Date.now().toString()+e)}function C(e){return"tlv-v1"===this._protocol?null==e?0:e:e&&"0"!=e.toString()?e:P.call(this)}function O(e,t,r){var n="boolean"==typeof e;return n?"function"==typeof t&&void 0===r&&(r=t,t=void 0):"function"==typeof t&&void 0===r?(r=t,t=e):void 0===t&&("function"==typeof e&&void 0===r?r=e:void 0!==e&&(t=e)),{value:n?e:void 0,provided:n,timeout:t,callback:r}}function T(e,t){if(!t)return new c.FPError(o.ERROR_CODE.RTM_EC_UNKNOWN_ERROR,Error("data is null"));if(t instanceof Error){var r=o.ERROR_CODE.RTM_EC_UNKNOWN_ERROR;return void 0!==t.code&&(r=t.code),new c.FPError(r,t)}if(e){if(t.hasOwnProperty("code")&&t.hasOwnProperty("ex"))return new c.FPError(t.code,new Error(t.ex));if(t.hasOwnProperty("status")&&t.hasOwnProperty("reason")){var n=new c.FPError(t.status,new Error(t.reason));return n.status=t.status,n.reason=t.reason,n}}return null}function A(e,t,r,n){var i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],s=this;e?e.sendQuest(t,(function(e){if(r){var t=null,n=!1;if(e&&Object.prototype.hasOwnProperty.call(e,"_tlvPayload"))return 2==e.mtype&&(n=0!=e.ss),(t=T.call(s,n,e._tlvPayload))?void(r&&r(t,null)):void(r&&r(null,e._tlvPayload));if(e&&e.payload){var a=null;return a=i?o.MsgPack.decode(e.payload,s._binaryOptions):o.MsgPack.decode(e.payload,s._msgOptions),2==e.mtype&&(n=0!=e.ss),(t=T.call(s,n,a))?void(r&&r(t,null)):void(r&&r(null,a))}(t=T.call(s,n,e))?r&&r(t,null):r&&r(null,e)}}),n):r&&r(new c.FPError(c.FPConfig.ERROR_CODE.FPNN_EC_CORE_INVALID_CONNECTION,Error("invalid connection")),null)}function S(e){if("string"==typeof e)return e;try{return new TextDecoder("utf-8",{fatal:!0}).decode(e)}catch(e){return}}var M=function(){function e(t){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),t=h(t),c.FPEvent.assign(this),this._protocol=t.protocol,this._endpoint=t.endpoint,this._pid=t.pid,this._attrs=t.attrs,this._autoReconnect=void 0===t.autoReconnect||t.autoReconnect,this._connectionTimeout=t.connectionTimeout||3e4,this._maxPingIntervalSeconds=o.MAX_PING_SECONDS,this._platformImpl=void 0,this._requestMetadata=t.requestMetadata||t.requestMetadataProvider,this._requestTimeout=t.requestTimeout||2e4,this._tlvHeartbeatIdleMs=t.tlvHeartbeatIdleMs||3e4,this._tlvHeartbeatTimeoutMs=t.tlvHeartbeatTimeoutMs||1e4,this._pushDedupTtlMs=t.pushDedupTtlMs||3e4,this._webSocketFactory=t.webSocketFactory,this._authSec=t.authSec,this._authVer=t.authVer,this._locale=t.locale,this._clientVersion=t.clientVersion,void 0!==t.maxPingIntervalSeconds&&(this._maxPingIntervalSeconds=t.maxPingIntervalSeconds),this._lastPingTime=0,this._checkLastPingTimerID=0,this._regressiveStrategy={startConnectFailedCount:3,maxIntervalSeconds:8,linearRegressiveCount:4},void 0!==t.regressiveStrategy&&void 0!==t.regressiveStrategy.startConnectFailedCount&&void 0!==t.regressiveStrategy.maxIntervalSeconds&&void 0!==t.regressiveStrategy.linearRegressiveCount&&(this._regressiveStrategy.startConnectFailedCount=t.regressiveStrategy.startConnectFailedCount,this._regressiveStrategy.maxIntervalSeconds=t.regressiveStrategy.maxIntervalSeconds,this._regressiveStrategy.linearRegressiveCount=t.regressiveStrategy.linearRegressiveCount),this._canReconnect=!1,this._reconnectCount=0,this._reconnectInterval=0,this._ssl=!1,"tlv-v1"===this._protocol)this._tlvEndpoint=t.tlvEndpoint;else{var r=void 0!==t.ssl_endpoint,n=r?t.ssl_endpoint:t.endpoint;this._endpoint=r?n:l(n),this._ssl=r}void 0!==t.platformImpl&&(this._platformImpl=t.platformImpl),this._md5=t.md5||null,this._midSeq=0,this._saltSeq=0,this._baseClient=null,this._reconnectTimeout=0,this._requireClose=!1,this._msgOptions={codec:o.MsgPack.createCodec({int64:!0})},this._binaryOptions={codec:o.MsgPack.createCodec({int64:!0,useraw:!0})};var s=this;this._processor=new i(this);var u=function(){s._requireClose=!0,s._canReconnect=!1,"tlv-v1"!==s._protocol&&s._baseClient&&s._baseClient.close()};this._processor.on(o.SERVER_PUSH.kickOut,u),this._processor.on(o.TLV_SERVER_PUSH.kickOut,u),this.promises=a(this,e.prototype)}return n(e,[{key:"login",value:function(e,t,r,n){this._uid=e,this._token=t,this._processor&&(this._processor.uid=this._uid),y.call(this,r,n)}},{key:"bye",value:function(e,t){"function"==typeof e&&(t=e,e=void 0);var r={flag:1,method:"bye",payload:o.MsgPack.encode({},this._msgOptions)},n=this;this._requireClose=!0,A.call(this,this._baseClient,r,(function(e,r){"tlv-v1"===n._protocol?e&&(b.call(n,e),n._baseClient&&n._baseClient.close()):n._baseClient&&n._baseClient.close(),t&&t(e||null,r)}),e)}},{key:"getServerTime",value:function(e,t){var r={flag:1,method:"getservertime",payload:o.MsgPack.encode({},this._msgOptions)};A.call(this,this._baseClient,r,(function(e,r){e?t&&t(e,null):(r&&void 0!==r.mts&&(r.mts=new o.Int64(""+r.mts)),t&&t(null,r))}),e)}},{key:"close",value:function(){this._requireClose=!0,this._baseClient&&this._baseClient.close()}},{key:"startAutoReconnect",value:function(){this._requireClose=!1,this._baseClient&&this._baseClient.close()}},{key:"destroy",value:function(){this.close(),this._midSeq=0,this._saltSeq=0,this._processor&&(this._processor.destroy(),this._processor=null),this._baseClient&&(this._baseClient.destroy(),this._baseClient=null),this._reconnectTimeout&&(clearTimeout(this._reconnectTimeout),this._reconnectTimeout=0),this._checkLastPingTimerID&&(clearInterval(this._checkLastPingTimerID),this._checkLastPingTimerID=0),this.removeEvent()}},{key:"sendMessage",value:function(e,t,r,n,i,s,a){var u={to:e,mid:i=C.call(this,i),mtype:t,msg:r,attrs:n},c={flag:1,method:"sendmsg",payload:"tlv-v1"===this._protocol?u:o.MsgPack.encode(u,this._msgOptions)},f="tlv-v1"===this._protocol;A.call(this,this._baseClient,c,(function(e,t){e?a&&a(f?{message_ref:u.mid,error:e}:{mid:u.mid,error:e},null):(f||void 0===t.mtime||(t.mtime=new o.Int64(t.mtime)),a&&a(null,f?{message_ref:t.message_ref,payload:t}:{mid:u.mid,payload:t}))}),s)}},{key:"sendMessages",value:function(e,t,r,n,i,s,a){var u={tos:e,mid:i=C.call(this,i),mtype:t,msg:r,attrs:n},c={flag:1,method:"sendmsgs",payload:"tlv-v1"===this._protocol?u:o.MsgPack.encode(u,this._msgOptions)},f="tlv-v1"===this._protocol;A.call(this,this._baseClient,c,(function(e,t){e?a&&a(f?{message_ref:u.mid,error:e}:{mid:u.mid,error:e},null):(f||void 0===t.mtime||(t.mtime=new o.Int64(t.mtime)),a&&a(null,f?{message_ref:t.message_ref,payload:t}:{mid:u.mid,payload:t}))}),s)}},{key:"sendGroupMessage",value:function(e,t,r,n,i,s,a){var u={gid:e,mid:i=C.call(this,i),mtype:t,msg:r,attrs:n},c={flag:1,method:"sendgroupmsg",payload:"tlv-v1"===this._protocol?u:o.MsgPack.encode(u,this._msgOptions)},f="tlv-v1"===this._protocol;A.call(this,this._baseClient,c,(function(e,t){e?a&&a(f?{message_ref:u.mid,error:e}:{mid:u.mid,error:e},null):(f||void 0===t.mtime||(t.mtime=new o.Int64(t.mtime)),a&&a(null,f?{message_ref:t.message_ref,payload:t}:{mid:u.mid,payload:t}))}),s)}},{key:"sendRoomMessage",value:function(e,t,r,n,i,s,a){var u={rid:e,mid:i=C.call(this,i),mtype:t,msg:r,attrs:n},c={flag:1,method:"sendroommsg",payload:"tlv-v1"===this._protocol?u:o.MsgPack.encode(u,this._msgOptions)},f="tlv-v1"===this._protocol;A.call(this,this._baseClient,c,(function(e,t){e?a&&a(f?{message_ref:u.mid,error:e}:{mid:u.mid,error:e},null):(f||void 0===t.mtime||(t.mtime=new o.Int64(t.mtime)),a&&a(null,f?{message_ref:t.message_ref,payload:t}:{mid:u.mid,payload:t}))}),s)}},{key:"getUnreadMessage",value:function(e,t,r,n){var i=O(t,r,n);t=i.value,r=i.timeout,n=i.callback;var s={clear:void 0!==e&&e};void 0!==t&&(s.gettime=t);var a={flag:1,method:"getunread",payload:o.MsgPack.encode(s,this._msgOptions)};A.call(this,this._baseClient,a,(function(e,t){if(e)n&&n(e,null);else{var r=t.p2p;if(r){var i=[];r.forEach((function(e,t){i[t]=new o.Int64(""+e)})),t.p2p=i}var s=t.group;if(s){var a=[];s.forEach((function(e,t){a[t]=new o.Int64(""+e)})),t.group=a}n&&n(null,t)}}),r)}},{key:"getP2PUnreadMessageNum",value:function(e,t,r,n,i){var s={uids:e};void 0!==t&&(s.mtime=t),void 0!==r&&(s.mtypes=r);var a={flag:1,method:"getp2punread",payload:o.MsgPack.encode(s,this._msgOptions)},u="tlv-v1"===this._protocol;A.call(this,this._baseClient,a,(function(e,t){if(e)i&&i(e,null);else if(u)i&&i(null,t);else{var r={p2p:{},ltime:{}},n=t.p2p;if(n)for(var s in n)r.p2p[new o.Int64(""+s)]=n[s];var a=t.ltime;if(a)for(var s in a)r.ltime[new o.Int64(""+s)]=new o.Int64(""+a[s]);i&&i(null,r)}}),n)}},{key:"getGroupUnreadMessageNum",value:function(e,t,r,n,i){var s={gids:e};void 0!==t&&(s.mtime=t),void 0!==r&&(s.mtypes=r);var a={flag:1,method:"getgroupunread",payload:o.MsgPack.encode(s,this._msgOptions)},u="tlv-v1"===this._protocol;A.call(this,this._baseClient,a,(function(e,t){if(e)i&&i(e,null);else if(u)i&&i(null,t);else{var r={group:{},ltime:{}},n=t.group;if(n)for(var s in n)r.group[new o.Int64(""+s)]=n[s];var a=t.ltime;if(a)for(var s in a)r.ltime[new o.Int64(""+s)]=new o.Int64(""+a[s]);i&&i(null,r)}}),n)}},{key:"cleanUnreadMessage",value:function(e,t){var r={flag:1,method:"cleanunread",payload:o.MsgPack.encode({},this._msgOptions)};A.call(this,this._baseClient,r,t,e)}},{key:"setSessionRead",value:function(e,t,r,n,i){var s={category:e,xid:t,read_seq:r},a={flag:1,method:"setsessionread",payload:o.MsgPack.encode(s,this._msgOptions)};A.call(this,this._baseClient,a,i,n)}},{key:"getSession",value:function(e,t){var r={flag:1,method:"getsession",payload:o.MsgPack.encode({},this._msgOptions)};A.call(this,this._baseClient,r,(function(e,r){if(e)t&&t(e,null);else{var n=r.p2p;if(n){var i=[];n.forEach((function(e,t){i[t]=new o.Int64(""+e)})),r.p2p=i}var s=r.group;if(s){var a=[];s.forEach((function(e,t){a[t]=new o.Int64(""+e)})),r.group=a}t&&t(null,r)}}),e)}},{key:"getGroupMessage",value:function(e,t,r,n,i,s,a,u,c){var f={gid:e,desc:t,num:r};void 0!==n&&(f.begin=n),void 0!==i&&(f.end=i),void 0!==s&&(f.lastid=s),void 0!==a&&(f.mtypes=a);var l={flag:1,method:"getgroupmsg",payload:o.MsgPack.encode(f,this._msgOptions)};A.call(this,this._baseClient,l,(function(e,t){if(e)c&&c(e,null);else{var r=t.msgs;r&&r.forEach((function(e,t){var n=e[5],i=S(e[5]),s=S(e[6]);r[t]={id:new o.Int64(""+e[0]),from:new o.Int64(""+e[1]),mtype:Number(e[2]),mid:new o.Int64(""+e[3]),deleted:e[4],msg:i,binary:n,attrs:s,mtime:new o.Int64(""+e[7])}})),c&&c(null,t)}}),u,!0)}},{key:"getRoomMessage",value:function(e,t,r,n,i,s,a,u,c){var f={rid:e,desc:t,num:r};void 0!==n&&(f.begin=n),void 0!==i&&(f.end=i),void 0!==s&&(f.lastid=s),void 0!==a&&(f.mtypes=a);var l={flag:1,method:"getroommsg",payload:o.MsgPack.encode(f,this._msgOptions)};A.call(this,this._baseClient,l,(function(e,t){if(e)c&&c(e,null);else{var r=t.msgs;r&&r.forEach((function(e,t){var n=e[5],i=S(e[5]),s=S(e[6]);r[t]={id:new o.Int64(""+e[0]),from:new o.Int64(""+e[1]),mtype:Number(e[2]),mid:new o.Int64(""+e[3]),deleted:e[4],msg:i,binary:n,attrs:s,mtime:new o.Int64(""+e[7])}})),c&&c(null,t)}}),u,!0)}},{key:"getBroadcastMessage",value:function(e,t,r,n,i,s,a,u){var c={desc:e,num:t};void 0!==r&&(c.begin=r),void 0!==n&&(c.end=n),void 0!==i&&(c.lastid=i),void 0!==s&&(c.mtypes=s);var f={flag:1,method:"getbroadcastmsg",payload:o.MsgPack.encode(c,this._msgOptions)};A.call(this,this._baseClient,f,(function(e,t){if(e)u&&u(e,null);else{var r=t.msgs;r&&r.forEach((function(e,t){var n=e[5],i=S(e[5]),s=S(e[6]);r[t]={id:new o.Int64(""+e[0]),from:new o.Int64(""+e[1]),mtype:Number(e[2]),mid:new o.Int64(""+e[3]),deleted:e[4],msg:i,binary:n,attrs:s,mtime:new o.Int64(""+e[7])}})),u&&u(null,t)}}),a,!0)}},{key:"getP2PMessage",value:function(e,t,r,n,i,s,a,u,c){var f={ouid:e,desc:t,num:r};void 0!==n&&(f.begin=n),void 0!==i&&(f.end=i),void 0!==s&&(f.lastid=s),void 0!==a&&(f.mtypes=a);var l={flag:1,method:"getp2pmsg",payload:o.MsgPack.encode(f,this._msgOptions)};A.call(this,this._baseClient,l,(function(e,t){if(e)c&&c(e,null);else{var r=t.msgs;r&&r.forEach((function(e,t){var n=e[5],i=S(e[5]),s=S(e[6]);r[t]={id:new o.Int64(""+e[0]),direction:Number(e[1]),mtype:Number(e[2]),mid:new o.Int64(""+e[3]),deleted:e[4],msg:i,binary:n,attrs:s,mtime:new o.Int64(""+e[7])}})),c&&c(null,t)}}),u,!0)}},{key:"getP2PMessageByMessageId",value:function(e,t,r,n,o,i,s,a,u){var c={ouid:e,mid:t,desc:r,num:n};void 0!==o&&(c.begin=o),void 0!==i&&(c.end=i),void 0!==s&&(c.mtypes=s),this._getMessageByAnchor("getp2pmsgbymessageid",c,!0,a,u)}},{key:"getGroupMessageByMessageId",value:function(e,t,r,n,o,i,s,a,u){var c={gid:e,mid:t,desc:r,num:n};void 0!==o&&(c.begin=o),void 0!==i&&(c.end=i),void 0!==s&&(c.mtypes=s),this._getMessageByAnchor("getgroupmsgbymessageid",c,!1,a,u)}},{key:"getRoomMessageByMessageId",value:function(e,t,r,n,o,i,s,a,u){var c={rid:e,mid:t,desc:r,num:n};void 0!==o&&(c.begin=o),void 0!==i&&(c.end=i),void 0!==s&&(c.mtypes=s),this._getMessageByAnchor("getroommsgbymessageid",c,!1,a,u)}},{key:"getBroadcastMessageByMessageId",value:function(e,t,r,n,o,i,s,a){var u={mid:e,desc:t,num:r};void 0!==n&&(u.begin=n),void 0!==o&&(u.end=o),void 0!==i&&(u.mtypes=i),this._getMessageByAnchor("getbroadcastmsgbymessageid",u,!1,s,a)}},{key:"_getMessageByAnchor",value:function(e,t,r,n,i){var s={flag:1,method:e,payload:o.MsgPack.encode(t,this._msgOptions)};A.call(this,this._baseClient,s,(function(e,t){e?i&&i(e,null):i&&i(null,function(e,t){var r=e&&e.msgs;return r?(r.forEach((function(e,n){var i={id:new o.Int64(""+e[0]),mtype:Number(e[2]),mid:new o.Int64(""+e[3]),deleted:e[4],msg:S(e[5]),binary:e[5],attrs:S(e[6]),mtime:new o.Int64(""+e[7])};t?i.direction=Number(e[1]):i.from=new o.Int64(""+e[1]),r[n]=i})),e):e}(t,r))}),n,!0)}},{key:"getP2PMessageCount",value:function(e,t,r,n,o,i){this._getMessageCount("getp2pmsgcount",{ouid:e,begin:t,end:r,mtypes:n},o,i)}},{key:"getGroupMessageCount",value:function(e,t,r,n,o,i){this._getMessageCount("getgroupmsgcount",{gid:e,begin:t,end:r,mtypes:n},o,i)}},{key:"getRoomMessageCount",value:function(e,t,r,n,o,i){this._getMessageCount("getroommsgcount",{rid:e,begin:t,end:r,mtypes:n},o,i)}},{key:"getBroadcastMessageCount",value:function(e,t,r,n,o){this._getMessageCount("getbroadcastmsgcount",{begin:e,end:t,mtypes:r},n,o)}},{key:"_getMessageCount",value:function(e,t,r,n){var i={};Object.keys(t).forEach((function(e){void 0!==t[e]&&(i[e]=t[e])}));var s={flag:1,method:e,payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,n,r)}},{key:"fileToken",value:function(e,t,r,n,o,i,s){var a={cmd:e};void 0!==t&&(a.tos=t),void 0!==r&&(a.to=r),void 0!==n&&(a.rid=n),void 0!==o&&(a.gid=o),k.call(this,a,s,i)}},{key:"addAttrs",value:function(e,t,r){var n={attrs:e},i={flag:1,method:"addattrs",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"getAttrs",value:function(e,t){var r={flag:1,method:"getattrs",payload:o.MsgPack.encode({},this._msgOptions)};A.call(this,this._baseClient,r,t,e)}},{key:"addDebugLog",value:function(e,t,r,n){var i={msg:e,attrs:t},s={flag:1,method:"adddebuglog",payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,n,r)}},{key:"addDevice",value:function(e,t,r,n){var i={apptype:e,devicetoken:t},s={flag:1,method:"adddevice",payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,n,r)}},{key:"removeDevice",value:function(e,t,r){var n={devicetoken:e},i={flag:1,method:"removedevice",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"setTranslationLanguage",value:function(e,t,r){var n={lang:e},i={flag:1,method:"setlang",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"translate",value:function(e,t,r,n,i,s,a){var u={text:e,dst:r};void 0!==t&&(u.src=t),void 0!==n&&(u.type=n),void 0!==i&&(u.profanity=i);var c={flag:1,method:"translate",payload:o.MsgPack.encode(u,this._msgOptions)};A.call(this,this._baseClient,c,a,s)}},{key:"profanity",value:function(e,t,r,n){var i={text:e};void 0!==t&&(i.classify=t);var s={flag:1,method:"profanity",payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,n,r)}},{key:"textCheck",value:function(e,t,r,n){"function"==typeof t?(n=t,t=void 0,r=void 0):arguments.length<4&&"number"==typeof t&&(void 0===r||"function"==typeof r)&&(n="function"==typeof r?r:n,r=t,t=void 0);var i={text:e};void 0!==t&&(i.strategyId=t);var s={flag:1,method:"tcheck",payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,n,r)}},{key:"imageCheck",value:function(e,t,r,n,i){var s={image:e,type:t};void 0!==r&&(s.strategyId=r);var a={flag:1,method:"icheck",payload:o.MsgPack.encode(s,this._msgOptions)};A.call(this,this._baseClient,a,i,n)}},{key:"audioCheck",value:function(e,t,r,n,i,s,a,u){var c={audio:e,type:t,lang:r};void 0!==n&&(c.codec=n),void 0!==i&&(c.srate=i),void 0!==s&&(c.strategyId=s);var f={flag:1,method:"acheck",payload:o.MsgPack.encode(c,this._msgOptions)};A.call(this,this._baseClient,f,u,a)}},{key:"videoCheck",value:function(e,t,r,n,i,s){var a={video:e,type:t,videoName:r};void 0!==n&&(a.strategyId=n);var u={flag:1,method:"vcheck",payload:o.MsgPack.encode(a,this._msgOptions)};A.call(this,this._baseClient,u,s,i)}},{key:"speech2Text",value:function(e,t,r,n,i,s,a){var u={audio:e,type:t,lang:r};void 0!==n&&(u.codec=n),void 0!==i&&(u.srate=i);var c={flag:1,method:"speech2text",payload:o.MsgPack.encode(u,this._msgOptions)};A.call(this,this._baseClient,c,a,s)}},{key:"getGroupsOpenInfo",value:function(e,t,r){var n={gids:e},i={flag:1,method:"getgroupsopeninfo",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"getRoomsOpenInfo",value:function(e,t,r){var n={rids:e},i={flag:1,method:"getroomsopeninfo",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"getRoomMembers",value:function(e,t,r){var n={rid:e},i={flag:1,method:"getroommembers",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"getRoomCount",value:function(e,t,r){var n={rids:e},i={flag:1,method:"getroomcount",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"addDevicePushOption",value:function(e,t,r,n,i){var s={type:e,xid:t};void 0!==r&&(s.mtypes=r);var a={flag:1,method:"addoption",payload:o.MsgPack.encode(s,this._msgOptions)};A.call(this,this._baseClient,a,i,n)}},{key:"removeDevicePushOption",value:function(e,t,r,n,i){var s={type:e,xid:t};void 0!==r&&(s.mtypes=r);var a={flag:1,method:"removeoption",payload:o.MsgPack.encode(s,this._msgOptions)};A.call(this,this._baseClient,a,i,n)}},{key:"getDevicePushOption",value:function(e,t){var r={flag:1,method:"getoption",payload:o.MsgPack.encode({},this._msgOptions)};A.call(this,this._baseClient,r,t,e)}},{key:"addFriends",value:function(e,t,r){var n={friends:e},i={flag:1,method:"addfriends",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"deleteFriends",value:function(e,t,r){var n={friends:e},i={flag:1,method:"delfriends",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"getFriends",value:function(e,t){var r={flag:1,method:"getfriends",payload:o.MsgPack.encode({},this._msgOptions)};A.call(this,this._baseClient,r,(function(e,r){if(e)t&&t(e,null);else{var n=r.uids;if(n){var i=[];return n.forEach((function(e,t){i[t]=new o.Int64(e)})),void(t&&t(null,i))}t&&t(null,r)}}),e)}},{key:"addGroupMembers",value:function(e,t,r,n){var i={gid:e,uids:t},s={flag:1,method:"addgroupmembers",payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,n,r)}},{key:"deleteGroupMembers",value:function(e,t,r,n){var i={gid:e,uids:t},s={flag:1,method:"delgroupmembers",payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,n,r)}},{key:"getGroupMembers",value:function(e,t,r,n){var i={gid:e};void 0!==t&&(i.online=t);var s={flag:1,method:"getgroupmembers",payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,(function(e,t){if(e)n&&n(e,null);else{var r=t.uids;if(r){var i=[];r.forEach((function(e,t){i[t]=new o.Int64(e)})),t.uids=i}var s=t.onlines;if(s){var a=[];s.forEach((function(e,t){a[t]=new o.Int64(e)})),t.onlines=a}n&&n(null,t)}}),r)}},{key:"getGroupCount",value:function(e,t,r,n){var i={gid:e};void 0!==t&&(i.online=t);var s={flag:1,method:"getgroupcount",payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,(function(e,t){e?n&&n(e,null):n&&n(null,t)}),r)}},{key:"getUserGroups",value:function(e,t){var r={flag:1,method:"getusergroups",payload:o.MsgPack.encode({},this._msgOptions)},n="tlv-v1"===this._protocol?"group_refs":"gids";A.call(this,this._baseClient,r,(function(e,r){if(e)t&&t(e,null);else{var i=r[n];if(i){var s=[];return i.forEach((function(e,t){s[t]=new o.Int64(e)})),void(t&&t(null,s))}t&&t(null,r)}}),e)}},{key:"enterRoom",value:function(e,t,r){var n={rid:e},i={flag:1,method:"enterroom",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"enterRooms",value:function(e,t,r){var n={rids:e},i={flag:1,method:"enterrooms",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"leaveRoom",value:function(e,t,r){var n={rid:e},i={flag:1,method:"leaveroom",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"getUserRooms",value:function(e,t){var r={flag:1,method:"getuserrooms",payload:o.MsgPack.encode({},this._msgOptions)},n="tlv-v1"===this._protocol?"room_refs":"rooms";A.call(this,this._baseClient,r,(function(e,r){if(e)t&&t(e,null);else{var i=r[n];if(i){var s=[];return i.forEach((function(e,t){s[t]=new o.Int64(e)})),void(t&&t(null,s))}t&&t(null,r)}}),e)}},{key:"getUserRoomsAndLastMessage",value:function(e,t,r){var n={};void 0!==e&&(n.mtypes=e);var i={flag:1,method:"getuserroomsandlastmsg",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"getOnlineUsers",value:function(e,t,r){var n={uids:e},i={flag:1,method:"getonlineusers",payload:o.MsgPack.encode(n,this._msgOptions)},s="tlv-v1"===this._protocol?"online_users":"uids";A.call(this,this._baseClient,i,(function(e,t){if(e)r&&r(e,null);else{var n=t[s];if(n){var i=[];return n.forEach((function(e,t){i[t]=new o.Int64(e)})),void(r&&r(null,i))}r&&r(null,t)}}),t)}},{key:"deleteMessage",value:function(e,t,r,n,i,s){var a={from:e,mid:t,xid:r,type:n},u={flag:1,method:"delmsg",payload:o.MsgPack.encode(a,this._msgOptions)};A.call(this,this._baseClient,u,s,i)}},{key:"getMessage",value:function(e,t,r,n,i,s){var a={from:e,mid:t,xid:r,type:n},u={flag:1,method:"getmsg",payload:o.MsgPack.encode(a,this._msgOptions)};A.call(this,this._baseClient,u,(function(e,t){e?s&&s(e,null):(void 0!==t.id&&(t.id=new o.Int64(""+t.id)),void 0!==t.mtime&&(t.mtime=new o.Int64(""+t.mtime)),s&&s(null,t))}),i,!0)}},{key:"sendChat",value:function(e,t,r,n,i,s){this.sendMessage.call(this,e,o.CHAT_TYPE.text,t,r,n,i,s)}},{key:"sendAudio",value:function(e,t,r,n,i,s){this.sendMessage.call(this,e,o.CHAT_TYPE.audio,t,r,n,i,s)}},{key:"sendCmd",value:function(e,t,r,n,i,s){this.sendMessage.call(this,e,o.CHAT_TYPE.cmd,t,r,n,i,s)}},{key:"sendGroupChat",value:function(e,t,r,n,i,s){this.sendGroupMessage.call(this,e,o.CHAT_TYPE.text,t,r,n,i,s)}},{key:"sendGroupAudio",value:function(e,t,r,n,i,s){this.sendGroupMessage.call(this,e,o.CHAT_TYPE.audio,t,r,n,i,s)}},{key:"sendGroupCmd",value:function(e,t,r,n,i,s){this.sendGroupMessage.call(this,e,o.CHAT_TYPE.cmd,t,r,n,i,s)}},{key:"sendRoomChat",value:function(e,t,r,n,i,s){this.sendRoomMessage.call(this,e,o.CHAT_TYPE.text,t,r,n,i,s)}},{key:"sendRoomAudio",value:function(e,t,r,n,i,s){this.sendRoomMessage.call(this,e,o.CHAT_TYPE.audio,t,r,n,i,s)}},{key:"sendRoomCmd",value:function(e,t,r,n,i,s){this.sendRoomMessage.call(this,e,o.CHAT_TYPE.cmd,t,r,n,i,s)}},{key:"getGroupChat",value:function(e,t,r,n,i,s,a,u){this.getGroupMessage.call(this,e,t,r,n,i,s,[o.CHAT_TYPE.text,o.CHAT_TYPE.audio,o.CHAT_TYPE.cmd],a,u)}},{key:"getRoomChat",value:function(e,t,r,n,i,s,a,u){this.getRoomMessage.call(this,e,t,r,n,i,s,[o.CHAT_TYPE.text,o.CHAT_TYPE.audio,o.CHAT_TYPE.cmd],a,u)}},{key:"getP2PChat",value:function(e,t,r,n,i,s,a,u){this.getP2PMessage.call(this,e,t,r,n,i,s,[o.CHAT_TYPE.text,o.CHAT_TYPE.audio,o.CHAT_TYPE.cmd],a,u)}},{key:"getBroadcastChat",value:function(e,t,r,n,i,s,a){this.getBroadcastMessage.call(this,e,t,r,n,i,[o.CHAT_TYPE.text,o.CHAT_TYPE.audio,o.CHAT_TYPE.cmd],s,a)}},{key:"deleteChat",value:function(e,t,r,n,o,i){this.deleteMessage(e,t,r,n,o,i)}},{key:"getChat",value:function(e,t,r,n,o,i){this.getMessage(e,t,r,n,o,i)}},{key:"setUserInfo",value:function(e,t,r,n){var i={};void 0!==e&&(i.oinfo=e),void 0!==t&&(i.pinfo=t);var s={flag:1,method:"setuserinfo",payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,n,r)}},{key:"getUserInfo",value:function(e,t){var r={flag:1,method:"getuserinfo",payload:o.MsgPack.encode({},this._msgOptions)};A.call(this,this._baseClient,r,t,e)}},{key:"getUserOpenInfo",value:function(e,t,r){var n={uids:e},i={flag:1,method:"getuseropeninfo",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"setGroupInfo",value:function(e,t,r,n,i){var s={gid:e};void 0!==t&&(s.oinfo=t),void 0!==r&&(s.pinfo=r);var a={flag:1,method:"setgroupinfo",payload:o.MsgPack.encode(s,this._msgOptions)};A.call(this,this._baseClient,a,i,n)}},{key:"getGroupInfo",value:function(e,t,r){var n={gid:e},i={flag:1,method:"getgroupinfo",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"getGroupOpenInfo",value:function(e,t,r){var n={gid:e},i={flag:1,method:"getgroupopeninfo",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"setRoomInfo",value:function(e,t,r,n,i){var s={rid:e};void 0!==t&&(s.oinfo=t),void 0!==r&&(s.pinfo=r);var a={flag:1,method:"setroominfo",payload:o.MsgPack.encode(s,this._msgOptions)};A.call(this,this._baseClient,a,i,n)}},{key:"setRoomProfile",value:function(e,t,r,n,i,s,a){var u={rid:e};void 0!==t&&(u.oinfo=t),void 0!==r&&(u.pinfo=r),void 0!==n&&(u.name=n),void 0!==i&&(u.icon=i);var c={flag:1,method:"setroominfo",payload:o.MsgPack.encode(u,this._msgOptions)};A.call(this,this._baseClient,c,a,s)}},{key:"getRoomInfo",value:function(e,t,r){var n={rid:e},i={flag:1,method:"getroominfo",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"getRoomOpenInfo",value:function(e,t,r){var n={rid:e},i={flag:1,method:"getroomopeninfo",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"dataSet",value:function(e,t,r,n){var i={key:e,val:t},s={flag:1,method:"dataset",payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,n,r)}},{key:"dataGet",value:function(e,t,r){var n={key:e},i={flag:1,method:"dataget",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"dataDelete",value:function(e,t,r){var n={key:e},i={flag:1,method:"datadel",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"addBlacks",value:function(e,t,r){var n={blacks:e},i={flag:1,method:"addblacks",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"deleteBlacks",value:function(e,t,r){var n={blacks:e},i={flag:1,method:"delblacks",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"getBlacks",value:function(e,t){var r={flag:1,method:"getblacks",payload:o.MsgPack.encode({},this._msgOptions)},n="tlv-v1"===this._protocol?"blocked_users":"uids";A.call(this,this._baseClient,r,(function(e,r){if(e)t&&t(e,null);else{var i=r[n];if(i){var s=[];return i.forEach((function(e,t){s[t]=new o.Int64(""+e)})),void(t&&t(null,s))}t&&t(null,r)}}),e)}},{key:"sendFile",value:function(e,t,r,n,o,i){var s={to:t,mtype:e,cmd:"sendfile"};E.call(this,s,r,n,i,o)}},{key:"sendGroupFile",value:function(e,t,r,n,o,i){var s={gid:t,mtype:e,cmd:"sendgroupfile"};E.call(this,s,r,n,i,o)}},{key:"sendRoomFile",value:function(e,t,r,n,o,i){var s={rid:t,mtype:e,cmd:"sendroomfile"};E.call(this,s,r,n,i,o)}},{key:"getP2PConversationList",value:function(e,t,r,n){var i={};void 0!==e&&(i.mtime=e),void 0!==t&&(i.mtypes=t);var s={flag:1,method:"getp2pconversationlist",payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,n,r)}},{key:"getP2PUnreadConversationList",value:function(e,t,r,n){var i={};void 0!==e&&(i.mtime=e),void 0!==t&&(i.mtypes=t);var s={flag:1,method:"getp2punreadconversationlist",payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,n,r)}},{key:"getGroupConversationList",value:function(e,t,r,n){var i={};void 0!==e&&(i.mtime=e),void 0!==t&&(i.mtypes=t);var s={flag:1,method:"getgroupconversationlist",payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,n,r)}},{key:"getGroupUnreadConversationList",value:function(e,t,r,n){var i={};void 0!==e&&(i.mtime=e),void 0!==t&&(i.mtypes=t);var s={flag:1,method:"getgroupunreadconversationlist",payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,n,r)}},{key:"getUnreadConversationList",value:function(e,t,r,n,i){var s={};void 0!==e&&(s.clear=e),void 0!==t&&(s.mtime=t),void 0!==r&&(s.mtypes=r);var a={flag:1,method:"getunreadconversationlist",payload:o.MsgPack.encode(s,this._msgOptions)};A.call(this,this._baseClient,a,i,n)}},{key:"removeSession",value:function(e,t,r,n){var i=O(t,r,n),s=i.provided;t=!!s&&i.value,r=i.timeout,n=i.callback;var a={to:e};("tlv-v1"===this._protocol||s)&&(a.oneway=t);var u={flag:1,method:"removesession",payload:o.MsgPack.encode(a,this._msgOptions)};A.call(this,this._baseClient,u,n,r)}},{key:"processor",get:function(){return this._processor}}]),e}();e.exports=M}).call(this,r(7).Buffer)},function(e,t){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,r){"use strict";var n="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=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var s=function(e){function t(e){i(this,t);var r=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return r.name="TLVMsgPackError",r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,Error),t}(),a=function(){function e(t,r,n){i(this,e),this.high=t>>>0,this.low=r>>>0,this.signed=!!n}return o(e,[{key:"isNegative",value:function(){return this.signed&&0!=(2147483648&this.high)}},{key:"toString",value:function(){if(!this.isNegative())return c(this.high,this.low);var e=u(this.high,this.low);return"-"+c(e.high,e.low)}},{key:"valueOf",value:function(){return Number(this.toString())}}]),e}();function u(e,t){var r=1+~t>>>0,n=~e>>>0;return 0===r&&(n=n+1>>>0),{high:n,low:r}}function c(e,t){var r=[e>>>0];f(r,65536),f(r,65536),function(e,t){var r=t,n=0;for(;r>0;){n===e.length&&e.push(0);var o=e[n]+r;e[n]=o%1e7,r=Math.floor(o/1e7),n+=1}}(r,t>>>0);for(var n=String(r[r.length-1]),o=r.length-2;o>=0;o-=1)n+=String(r[o]).padStart(7,"0");return n}function f(e,t){for(var r=0,n=0;n<e.length;n+=1){var o=e[n]*t+r;e[n]=o%1e7,r=Math.floor(o/1e7)}for(;r>0;)e.push(r%1e7),r=Math.floor(r/1e7)}function l(e){return Number.isSafeInteger?Number.isSafeInteger(e):"number"==typeof e&&isFinite(e)&&Math.floor(e)===e&&Math.abs(e)<=9007199254740991}function h(e){if(!e||"object"!==(void 0===e?"undefined":n(e))||Array.isArray(e))return!1;var t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function d(e){if(e instanceof Uint8Array)return e;if("undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer)return new Uint8Array(e);if("undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView&&ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);if("undefined"!=typeof ArrayBuffer&&e&&"[object ArrayBuffer]"===Object.prototype.toString.call(e))try{return new Uint8Array(ArrayBuffer.prototype.slice.call(e,0))}catch(e){}return null}function p(e){var t=d(e);if(!t)throw new s("expected binary data");return t}function g(e){if("string"!=typeof e)throw new s("expected UTF-8 string");if(function(e){for(var t=0;t<e.length;t+=1){var r=e.charCodeAt(t);if(r>=55296&&r<=56319){var n=e.charCodeAt(t+1);if(n<56320||n>57343)throw new s("string contains an unpaired surrogate");t+=1}else if(r>=56320&&r<=57343)throw new s("string contains an unpaired surrogate")}}(e),"undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var t=[],r=0;r<e.length;r+=1){var n=e.charCodeAt(r);if(n>=55296&&n<=56319)n=65536+(n-55296<<10)+(e.charCodeAt(r+1)-56320),r+=1;n<=127?t.push(n):n<=2047?t.push(192|n>>6,128|63&n):n<=65535?t.push(224|n>>12,128|n>>6&63,128|63&n):t.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|63&n)}return new Uint8Array(t)}function y(e){var t=p(e);if("undefined"!=typeof TextDecoder)try{return new TextDecoder("utf-8",{fatal:!0}).decode(t)}catch(e){throw new s("invalid UTF-8 string")}for(var r="",n=0;n<t.length;n+=1){var o=t[n],i=void 0;if(o<=127)i=o;else if(o>=194&&o<=223){i=(31&o)<<6|63&m(t,n+1),n+=1}else if(o>=224&&o<=239){var a=m(t,n+1),u=m(t,n+2);if(224===o&&a<160||237===o&&a>159)throw new s("invalid UTF-8 string");i=(15&o)<<12|(63&a)<<6|63&u,n+=2}else{if(!(o>=240&&o<=244))throw new s("invalid UTF-8 string");var c=m(t,n+1),f=m(t,n+2),l=m(t,n+3);if(240===o&&c<144||244===o&&c>143)throw new s("invalid UTF-8 string");i=(7&o)<<18|(63&c)<<12|(63&f)<<6|63&l,n+=3}if(i<=65535)r+=String.fromCharCode(i);else{var h=i-65536;r+=String.fromCharCode(55296|h>>10,56320|1023&h)}}return r}function m(e,t){if(t>=e.length||128!=(192&e[t]))throw new s("invalid UTF-8 string");return e[t]}var _=function(){function e(){i(this,e),this.chunks=[],this.length=0}return o(e,[{key:"byte",value:function(e){this.chunks.push(new Uint8Array([255&e])),this.length+=1}},{key:"bytes",value:function(e){var t=p(e);this.chunks.push(t),this.length+=t.length}},{key:"uint16",value:function(e){this.byte(e>>>8),this.byte(e)}},{key:"uint32",value:function(e){var t=e>>>0;this.byte(t>>>24),this.byte(t>>>16),this.byte(t>>>8),this.byte(t)}},{key:"uint64",value:function(e,t){this.uint32(e),this.uint32(t)}},{key:"finish",value:function(){var e=new Uint8Array(this.length),t=0;return this.chunks.forEach((function(r){e.set(r,t),t+=r.length})),e}}]),e}();function v(e,t,r){if(r>128)throw new s("MessagePack nesting is too deep");if(null==e)throw new s("nil and undefined are not allowed in TLV payloads");var o=void 0===e?"undefined":n(e);if("boolean"!==o)if("string"!==o)if("number"!==o)if("bigint"!==o){if("object"!==o)throw new s("unsupported MessagePack value type: "+o);if(e instanceof a)!function(e,t){if(e.isNegative())return t.byte(211),void t.uint64(e.high,e.low);if(k(e),0===e.high)return void w(e.low,t);t.byte(207),t.uint64(e.high,e.low)}(e,t);else{var i=d(e);if(i)!function(e,t){e.length<=255?(t.byte(196),t.byte(e.length)):e.length<=65535?(t.byte(197),t.uint16(e.length)):(t.byte(198),t.uint32(e.length));t.bytes(e)}(i,t);else if(function(e){if(!e||"object"!==(void 0===e?"undefined":n(e))||e instanceof a)return!1;if("number"!=typeof e.offset||"function"!=typeof e.toString||!e.buffer)return!1;var t=e.buffer,r="number"==typeof t.length?t.length:t.byteLength;return"number"==typeof r&&e.offset>=0&&e.offset+8<=r}(e))!function(e,t){var r=function(e){var t=e.buffer,r=e.offset,n=function(e){return 255&t[r+e]};return{high:16777216*n(0)+65536*n(1)+256*n(2)+n(3)>>>0,low:16777216*n(4)+65536*n(5)+256*n(6)+n(7)>>>0,signed:"-"===String(e).charAt(0)}}(e);if(r.signed)return t.byte(211),void t.uint64(r.high,r.low);if(k(r),0===r.high)return void w(r.low,t);t.byte(207),t.uint64(r.high,r.low)}(e,t);else if(Array.isArray(e))!function(e,t,r){e.length<=15?t.byte(144|e.length):e.length<=65535?(t.byte(220),t.uint16(e.length)):(t.byte(221),t.uint32(e.length));e.forEach((function(e){v(e,t,r)}))}(e,t,r+1);else{if(!h(e))throw new s("unsupported MessagePack object");!function(e,t,r){var n=Object.keys(e);n.length<=15?t.byte(128|n.length):n.length<=65535?(t.byte(222),t.uint16(n.length)):(t.byte(223),t.uint32(n.length));n.forEach((function(n){b(n,t),v(e[n],t,r)}))}(e,t,r+1)}}}else!function(e,t){var r="-"===e.charAt(0),n=function(e){if(!/^[0-9]+$/.test(e))throw new s("invalid integer text");for(var t=0,r=0,n=0;n<e.length;n+=1){var o=10*r+(e.charCodeAt(n)-48);r=o%4294967296;var i=10*t+Math.floor(o/4294967296);if(i>=4294967296)throw new s("integer exceeds uint64");t=i}return{high:t>>>0,low:r>>>0}}(r?e.slice(1):e);if(r){if(n.high>2147483648||2147483648===n.high&&0!==n.low)throw new s("integer is below int64 minimum");var o=u(n.high,n.low);return t.byte(211),void t.uint64(o.high,o.low)}if(k(n),0===n.high)return void w(n.low,t);t.byte(207),t.uint64(n.high,n.low)}(e.toString(),t);else!function(e,t){if(!isFinite(e))throw new s("non-finite numbers are not allowed");if(!l(e))throw new s("floating-point and unsafe integer numbers are not allowed");w(e,t)}(e,t);else b(e,t);else t.byte(e?195:194)}function b(e,t){var r=g(e);r.length<=31?t.byte(160|r.length):r.length<=255?(t.byte(217),t.byte(r.length)):r.length<=65535?(t.byte(218),t.uint16(r.length)):(t.byte(219),t.uint32(r.length)),t.bytes(r)}function w(e,t){if(e>=0)if(e<=127)t.byte(e);else if(e<=255)t.byte(204),t.byte(e);else if(e<=65535)t.byte(205),t.uint16(e);else if(e<=4294967295)t.byte(206),t.uint32(e);else{var r=E(e);t.byte(207),t.uint64(r.high,r.low)}else if(e>=-32)t.byte(256+e);else if(e>=-128)t.byte(208),t.byte(e);else if(e>=-32768)t.byte(209),t.uint16(e);else if(e>=-2147483648)t.byte(210),t.uint32(e);else{var n=function(e){if(e>=0)return E(e);var t=E(-e);return u(t.high,t.low)}(e);t.byte(211),t.uint64(n.high,n.low)}}function E(e){var t=Math.floor(e/4294967296);return{high:t>>>0,low:e-4294967296*t>>>0}}function k(e){if(e.high>=2147483648)throw new s("unsigned integer exceeds the supported int64 range")}var R=function(){function e(t,r){i(this,e),this.bytes=p(t),this.offset=0,this.allowIntegerMapKeyAtPath=r&&Array.isArray(r.allowIntegerMapKeyAtPath)?r.allowIntegerMapKeyAtPath.slice():null}return o(e,[{key:"ensure",value:function(e){if(e<0||this.offset+e>this.bytes.length)throw new s("truncated MessagePack value")}},{key:"byte",value:function(){this.ensure(1);var e=this.bytes[this.offset];return this.offset+=1,e}},{key:"uint16",value:function(){this.ensure(2);var e=256*this.bytes[this.offset]+this.bytes[this.offset+1];return this.offset+=2,e}},{key:"uint32",value:function(){this.ensure(4);var e=16777216*this.bytes[this.offset]+65536*this.bytes[this.offset+1]+256*this.bytes[this.offset+2]+this.bytes[this.offset+3];return this.offset+=4,e>>>0}},{key:"uint64",value:function(e){var t=this.uint32(),r=this.uint32();if(e&&0!=(2147483648&t)){var n=u(t,r);return n.high<2097152?-(4294967296*n.high+n.low):new a(t,r,!0)}if(t>=2147483648)throw new s("unsigned integer exceeds the supported int64 range");return t<2097152?4294967296*t+r:new a(t,r,!!e)}},{key:"int8",value:function(){var e=this.byte();return 128&e?e-256:e}},{key:"int16",value:function(){var e=this.uint16();return 32768&e?e-65536:e}},{key:"int32",value:function(){var e=this.uint32();return e>2147483647?e-4294967296:e}},{key:"float32",value:function(){this.ensure(4);var e=new DataView(this.bytes.buffer,this.bytes.byteOffset+this.offset,4).getFloat32(0,!1);if(this.offset+=4,!isFinite(e))throw new s("non-finite float is not allowed");return e}},{key:"float64",value:function(){this.ensure(8);var e=new DataView(this.bytes.buffer,this.bytes.byteOffset+this.offset,8).getFloat64(0,!1);if(this.offset+=8,!isFinite(e))throw new s("non-finite float is not allowed");return e}},{key:"binary",value:function(e){this.ensure(e);var t=new Uint8Array(e);return t.set(this.bytes.subarray(this.offset,this.offset+e)),this.offset+=e,t}},{key:"string",value:function(e){this.ensure(e);var t=y(this.bytes.subarray(this.offset,this.offset+e));return this.offset+=e,t}},{key:"array",value:function(e,t,r){if(e>this.bytes.length-this.offset)throw new s("truncated MessagePack array");for(var n=new Array(e),o=0;o<e;o+=1)n[o]=this.value(t+1,r.concat(String(o)));return n}},{key:"map",value:function(e,t,r){if(e>Math.floor((this.bytes.length-this.offset)/2))throw new s("truncated MessagePack map");for(var n,o={},i=0;i<e;i+=1){var u=this.value(t+1,r);if("string"!=typeof u){if(!(this._allowsIntegerMapKey(r)&&(n=u,l(n)||n instanceof a)))throw new s("MessagePack map key must be a string");u=String(u)}if(Object.prototype.hasOwnProperty.call(o,u))throw new s("duplicate MessagePack map key: "+u);Object.defineProperty(o,u,{configurable:!0,enumerable:!0,value:this.value(t+1,r.concat(u)),writable:!0})}return o}},{key:"_allowsIntegerMapKey",value:function(e){if(!this.allowIntegerMapKeyAtPath||e.length!==this.allowIntegerMapKeyAtPath.length)return!1;for(var t=0;t<e.length;t+=1)if(e[t]!==this.allowIntegerMapKeyAtPath[t])return!1;return!0}},{key:"value",value:function(e,t){if(e>128)throw new s("MessagePack nesting is too deep");var r=this.byte();if(r<=127)return r;if(r>=224)return r-256;if(r>=160&&r<=191)return this.string(31&r);if(r>=144&&r<=159)return this.array(15&r,e,t);if(r>=128&&r<=143)return this.map(15&r,e,t);switch(r){case 192:throw new s("nil is not allowed in TLV payloads");case 194:return!1;case 195:return!0;case 196:return this.binary(this.byte());case 197:return this.binary(this.uint16());case 198:return this.binary(this.uint32());case 202:return this.float32();case 203:return this.float64();case 204:return this.byte();case 205:return this.uint16();case 206:return this.uint32();case 207:return this.uint64(!1);case 208:return this.int8();case 209:return this.int16();case 210:return this.int32();case 211:return this.uint64(!0);case 217:return this.string(this.byte());case 218:return this.string(this.uint16());case 219:return this.string(this.uint32());case 220:return this.array(this.uint16(),e,t);case 221:return this.array(this.uint32(),e,t);case 222:return this.map(this.uint16(),e,t);case 223:return this.map(this.uint32(),e,t);default:throw new s("MessagePack extension and reserved values are not allowed")}}}]),e}();e.exports={Int64Value:a,MsgPackError:s,decodeMap:function(e,t){var r=new R(e,t),n=r.value(0,[]);if(!h(n))throw new s("TLV payload must be a map");if(r.offset!==r.bytes.length)throw new s("MessagePack payload has trailing bytes or values");return n},encodeMap:function(e){if(!h(e))throw new s("TLV payload must be a map");var t=new _;return v(e,t,0),t.finish()},getByteView:d,isPlainMap:h,toUint8Array:p,utf8Decode:y,utf8Encode:g}},function(e,t,r){"use strict";var n={close:!0,constructor:!0,destroy:!0,emit:!0,listenerCount:!0,off:!0,on:!0,removeEvent:!0,startAutoReconnect:!0};function o(e,t,r,n){try{e[t].apply(e,r)}catch(e){n(e)}}e.exports=function(e,t){var r={};return Object.getOwnPropertyNames(t).forEach((function(i){if(!n[i]&&"_"!==i.charAt(0)){var s=t[i];if("function"==typeof s){var a="login"===i?2:s.length-1;a<0||Object.defineProperty(r,i,{configurable:!1,enumerable:!0,writable:!1,value:function(){var t=Array.prototype.slice.call(arguments);if("login"===i){if(t.length>3)return Promise.reject(new TypeError("promises.login(uid, credential, timeout?)"));var r=t.length>2?t[2]:void 0;return t.length=2,new Promise((function(n,s){t.push((function(e,t){if(e instanceof Error)s(e);else if(e)n({accepted:!0,errorCode:t||0});else{var r=new Error("RTM login rejected ("+String(t)+")");r.code=t,r.status=t,s(r)}}),r),o(e,i,t,s)}))}if(t.length>a)return Promise.reject(new TypeError("Do not pass a callback to promises."+i+"()"));for(var n="textCheck"===i&&2===t.length&&"number"==typeof t[1]?2:a;t.length<n;)t.push(void 0);return new Promise((function(r,n){t.push((function(e,t){e?n(e):r(t)})),o(e,i,t,n)}))}})}}})),Object.freeze(r)}},function(e,t,r){"use strict";function n(e){var t=e.split(".");return 4===t.length&&t.every((function(e){return/^\d{1,3}$/.test(e)&&Number(e)<=255}))}function o(e){return/^[0-9a-f]{1,4}$/i.test(e)}e.exports={isValidFpnnEndpoint:function(e){if("string"!=typeof e||0===e.length||e!==e.trim()||/[\s\\/?#@%]/.test(e))return!1;var t=void 0,r=void 0;if("["===e.charAt(0)){var i=e.indexOf("]");if(i<0)return!1;t=e.slice(0,i+1);var s=e.slice(i+1);if(s){if(!/^:\d+$/.test(s))return!1;r=s.slice(1)}if(!/^\[[0-9a-f:.]+\]$/i.test(t))return!1}else{var a=e.indexOf(":");if(a>=0){if(e.indexOf(":",a+1)>=0)return!1;if(t=e.slice(0,a),r=e.slice(a+1),!/^\d+$/.test(r))return!1}else t=e}if(!t||void 0!==r&&(Number(r)<1||Number(r)>65535))return!1;if("function"!=typeof URL)return function(e){if("["===e.charAt(0))return function(e){if(!e||e.indexOf(":")<0||e.indexOf(":::")>=0)return!1;if(e.indexOf(".")>=0){var t=e.lastIndexOf(":");if(t<0||!n(e.slice(t+1)))return!1;e=e.slice(0,t)+":0:0"}var r=e.indexOf("::");if(r>=0){if(e.indexOf("::",r+2)>=0)return!1;var i=e.slice(0,r).split(":").filter(Boolean),s=e.slice(r+2).split(":").filter(Boolean);return i.length+s.length<8&&i.concat(s).every(o)}var a=e.split(":");return 8===a.length&&a.every(o)}(e.slice(1,-1));var t=e.replace(/\.$/,"");return!(!t||t.length>253)&&(/^[0-9.]+$/.test(t)?n(t):t.split(".").every((function(e){return e.length>0&&e.length<=63&&/^[a-z0-9\u0080-\uFFFF](?:[a-z0-9\u0080-\uFFFF-]*[a-z0-9\u0080-\uFFFF])?$/i.test(e)})))}(t);try{var u=new URL("ws://"+e);if("ws:"!==u.protocol||u.username||u.password||"/"!==u.pathname||u.search||u.hash||!u.hostname)return!1;if("["===t.charAt(0))return"["===u.hostname.charAt(0);var c=u.hostname.replace(/\.$/,"");return!(!c||c.length>253)&&c.split(".").every((function(e){return e.length>0&&e.length<=63&&/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test(e)}))}catch(e){return!1}},normalizeFpnnEndpoint:function(e){if("string"!=typeof e)return e;var t=/^(\[[^\]]+\]|[^:]+):13325$/.exec(e);return t?t[1]+":13321":e}}},function(e,t,r){"use strict";(function(e){
|
|
2
|
+
/*!
|
|
3
|
+
* The buffer module from node.js, for the browser.
|
|
4
|
+
*
|
|
5
|
+
* @author Feross Aboukhadijeh <http://feross.org>
|
|
6
|
+
* @license MIT
|
|
7
|
+
*/
|
|
8
|
+
var n=r(19),o=r(20),i=r(21);function s(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,t){if(s()<t)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=u.prototype:(null===e&&(e=new u(t)),e.length=t),e}function u(e,t,r){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(e,t,r);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return l(this,e)}return c(this,e,t,r)}function c(e,t,r,n){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,r,n){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");t=void 0===r&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,r):new Uint8Array(t,r,n);u.TYPED_ARRAY_SUPPORT?(e=t).__proto__=u.prototype:e=h(e,t);return e}(e,t,r,n):"string"==typeof t?function(e,t,r){"string"==typeof r&&""!==r||(r="utf8");if(!u.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|p(t,r),o=(e=a(e,n)).write(t,r);o!==n&&(e=e.slice(0,o));return e}(e,t,r):function(e,t){if(u.isBuffer(t)){var r=0|d(t.length);return 0===(e=a(e,r)).length||t.copy(e,0,0,r),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(n=t.length)!=n?a(e,0):h(e,t);if("Buffer"===t.type&&i(t.data))return h(e,t.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function f(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function l(e,t){if(f(t),e=a(e,t<0?0:0|d(t)),!u.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function h(e,t){var r=t.length<0?0:0|d(t.length);e=a(e,r);for(var n=0;n<r;n+=1)e[n]=255&t[n];return e}function d(e){if(e>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|e}function p(e,t){if(u.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return j(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return q(e).length;default:if(n)return j(e).length;t=(""+t).toLowerCase(),n=!0}}function g(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return A(this,t,r);case"utf8":case"utf-8":return C(this,t,r);case"ascii":return O(this,t,r);case"latin1":case"binary":return T(this,t,r);case"base64":return P(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function y(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function m(e,t,r,n,o){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=o?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(o)return-1;r=e.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof t&&(t=u.from(t,n)),u.isBuffer(t))return 0===t.length?-1:_(e,t,r,n,o);if("number"==typeof t)return t&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):_(e,[t],r,n,o);throw new TypeError("val must be string, number or Buffer")}function _(e,t,r,n,o){var i,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function c(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(o){var f=-1;for(i=r;i<a;i++)if(c(e,i)===c(t,-1===f?0:i-f)){if(-1===f&&(f=i),i-f+1===u)return f*s}else-1!==f&&(i-=i-f),f=-1}else for(r+u>a&&(r=a-u),i=r;i>=0;i--){for(var l=!0,h=0;h<u;h++)if(c(e,i+h)!==c(t,h)){l=!1;break}if(l)return i}return-1}function v(e,t,r,n){r=Number(r)||0;var o=e.length-r;n?(n=Number(n))>o&&(n=o):n=o;var i=t.length;if(i%2!=0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var s=0;s<n;++s){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))return s;e[r+s]=a}return s}function b(e,t,r,n){return V(j(t,e.length-r),e,r,n)}function w(e,t,r,n){return V(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function E(e,t,r,n){return w(e,t,r,n)}function k(e,t,r,n){return V(q(t),e,r,n)}function R(e,t,r,n){return V(function(e,t){for(var r,n,o,i=[],s=0;s<e.length&&!((t-=2)<0);++s)r=e.charCodeAt(s),n=r>>8,o=r%256,i.push(o),i.push(n);return i}(t,e.length-r),e,r,n)}function P(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function C(e,t,r){r=Math.min(e.length,r);for(var n=[],o=t;o<r;){var i,s,a,u,c=e[o],f=null,l=c>239?4:c>223?3:c>191?2:1;if(o+l<=r)switch(l){case 1:c<128&&(f=c);break;case 2:128==(192&(i=e[o+1]))&&(u=(31&c)<<6|63&i)>127&&(f=u);break;case 3:i=e[o+1],s=e[o+2],128==(192&i)&&128==(192&s)&&(u=(15&c)<<12|(63&i)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:i=e[o+1],s=e[o+2],a=e[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),o+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=4096));return r}(n)}t.Buffer=u,t.SlowBuffer=function(e){+e!=e&&(e=0);return u.alloc(+e)},t.INSPECT_MAX_BYTES=50,u.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),t.kMaxLength=s(),u.poolSize=8192,u._augment=function(e){return e.__proto__=u.prototype,e},u.from=function(e,t,r){return c(null,e,t,r)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0})),u.alloc=function(e,t,r){return function(e,t,r,n){return f(t),t<=0?a(e,t):void 0!==r?"string"==typeof n?a(e,t).fill(r,n):a(e,t).fill(r):a(e,t)}(null,e,t,r)},u.allocUnsafe=function(e){return l(null,e)},u.allocUnsafeSlow=function(e){return l(null,e)},u.isBuffer=function(e){return!(null==e||!e._isBuffer)},u.compare=function(e,t){if(!u.isBuffer(e)||!u.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,o=0,i=Math.min(r,n);o<i;++o)if(e[o]!==t[o]){r=e[o],n=t[o];break}return r<n?-1:n<r?1:0},u.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(e,t){if(!i(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return u.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=u.allocUnsafe(t),o=0;for(r=0;r<e.length;++r){var s=e[r];if(!u.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(n,o),o+=s.length}return n},u.byteLength=p,u.prototype._isBuffer=!0,u.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)y(this,t,t+1);return this},u.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)y(this,t,t+3),y(this,t+1,t+2);return this},u.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)y(this,t,t+7),y(this,t+1,t+6),y(this,t+2,t+5),y(this,t+3,t+4);return this},u.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?C(this,0,e):g.apply(this,arguments)},u.prototype.equals=function(e){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===u.compare(this,e)},u.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),"<Buffer "+e+">"},u.prototype.compare=function(e,t,r,n,o){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),t<0||r>e.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&t>=r)return 0;if(n>=o)return-1;if(t>=r)return 1;if(this===e)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(i,s),c=this.slice(n,o),f=e.slice(t,r),l=0;l<a;++l)if(c[l]!==f[l]){i=c[l],s=f[l];break}return i<s?-1:s<i?1:0},u.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},u.prototype.indexOf=function(e,t,r){return m(this,e,t,r,!0)},u.prototype.lastIndexOf=function(e,t,r){return m(this,e,t,r,!1)},u.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-t;if((void 0===r||r>o)&&(r=o),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return v(this,e,t,r);case"utf8":case"utf-8":return b(this,e,t,r);case"ascii":return w(this,e,t,r);case"latin1":case"binary":return E(this,e,t,r);case"base64":return k(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,t,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function O(e,t,r){var n="";r=Math.min(e.length,r);for(var o=t;o<r;++o)n+=String.fromCharCode(127&e[o]);return n}function T(e,t,r){var n="";r=Math.min(e.length,r);for(var o=t;o<r;++o)n+=String.fromCharCode(e[o]);return n}function A(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var o="",i=t;i<r;++i)o+=F(e[i]);return o}function S(e,t,r){for(var n=e.slice(t,r),o="",i=0;i<n.length;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function M(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function I(e,t,r,n,o,i){if(!u.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<i)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function U(e,t,r,n){t<0&&(t=65535+t+1);for(var o=0,i=Math.min(e.length-r,2);o<i;++o)e[r+o]=(t&255<<8*(n?o:1-o))>>>8*(n?o:1-o)}function B(e,t,r,n){t<0&&(t=4294967295+t+1);for(var o=0,i=Math.min(e.length-r,4);o<i;++o)e[r+o]=t>>>8*(n?o:3-o)&255}function N(e,t,r,n,o,i){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function x(e,t,r,n,i){return i||N(e,0,r,4),o.write(e,t,r,n,23,4),r+4}function D(e,t,r,n,i){return i||N(e,0,r,8),o.write(e,t,r,n,52,8),r+8}u.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t<e&&(t=e),u.TYPED_ARRAY_SUPPORT)(r=this.subarray(e,t)).__proto__=u.prototype;else{var o=t-e;r=new u(o,void 0);for(var i=0;i<o;++i)r[i]=this[i+e]}return r},u.prototype.readUIntLE=function(e,t,r){e|=0,t|=0,r||M(e,t,this.length);for(var n=this[e],o=1,i=0;++i<t&&(o*=256);)n+=this[e+i]*o;return n},u.prototype.readUIntBE=function(e,t,r){e|=0,t|=0,r||M(e,t,this.length);for(var n=this[e+--t],o=1;t>0&&(o*=256);)n+=this[e+--t]*o;return n},u.prototype.readUInt8=function(e,t){return t||M(e,1,this.length),this[e]},u.prototype.readUInt16LE=function(e,t){return t||M(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUInt16BE=function(e,t){return t||M(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUInt32LE=function(e,t){return t||M(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},u.prototype.readUInt32BE=function(e,t){return t||M(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||M(e,t,this.length);for(var n=this[e],o=1,i=0;++i<t&&(o*=256);)n+=this[e+i]*o;return n>=(o*=128)&&(n-=Math.pow(2,8*t)),n},u.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||M(e,t,this.length);for(var n=t,o=1,i=this[e+--n];n>0&&(o*=256);)i+=this[e+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*t)),i},u.prototype.readInt8=function(e,t){return t||M(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},u.prototype.readInt16LE=function(e,t){t||M(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(e,t){t||M(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(e,t){return t||M(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return t||M(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readFloatLE=function(e,t){return t||M(e,4,this.length),o.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return t||M(e,4,this.length),o.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return t||M(e,8,this.length),o.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return t||M(e,8,this.length),o.read(this,e,!1,52,8)},u.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||I(this,e,t,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[t]=255&e;++i<r&&(o*=256);)this[t+i]=e/o&255;return t+r},u.prototype.writeUIntBE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||I(this,e,t,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[t+o]=255&e;--o>=0&&(i*=256);)this[t+o]=e/i&255;return t+r},u.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,1,255,0),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},u.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):U(this,e,t,!0),t+2},u.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):U(this,e,t,!1),t+2},u.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):B(this,e,t,!0),t+4},u.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):B(this,e,t,!1),t+4},u.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var o=Math.pow(2,8*r-1);I(this,e,t,r,o-1,-o)}var i=0,s=1,a=0;for(this[t]=255&e;++i<r&&(s*=256);)e<0&&0===a&&0!==this[t+i-1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+r},u.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var o=Math.pow(2,8*r-1);I(this,e,t,r,o-1,-o)}var i=r-1,s=1,a=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===a&&0!==this[t+i+1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+r},u.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,1,127,-128),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},u.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):U(this,e,t,!0),t+2},u.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):U(this,e,t,!1),t+2},u.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):B(this,e,t,!0),t+4},u.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):B(this,e,t,!1),t+4},u.prototype.writeFloatLE=function(e,t,r){return x(this,e,t,!0,r)},u.prototype.writeFloatBE=function(e,t,r){return x(this,e,t,!1,r)},u.prototype.writeDoubleLE=function(e,t,r){return D(this,e,t,!0,r)},u.prototype.writeDoubleBE=function(e,t,r){return D(this,e,t,!1,r)},u.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var o,i=n-r;if(this===e&&r<t&&t<n)for(o=i-1;o>=0;--o)e[o+t]=this[o+r];else if(i<1e3||!u.TYPED_ARRAY_SUPPORT)for(o=0;o<i;++o)e[o+t]=this[o+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+i),t);return i},u.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===e.length){var o=e.charCodeAt(0);o<256&&(e=o)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!u.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var i;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(i=t;i<r;++i)this[i]=e;else{var s=u.isBuffer(e)?e:j(new u(e,n).toString()),a=s.length;for(i=0;i<r-t;++i)this[i+t]=s[i%a]}return this};var L=/[^+\/0-9A-Za-z-_]/g;function F(e){return e<16?"0"+e.toString(16):e.toString(16)}function j(e,t){var r;t=t||1/0;for(var n=e.length,o=null,i=[],s=0;s<n;++s){if((r=e.charCodeAt(s))>55295&&r<57344){if(!o){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function q(e){return n.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(L,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function V(e,t,r,n){for(var o=0;o<n&&!(o+r>=t.length||o>=e.length);++o)t[o+r]=e[o];return o}}).call(this,r(3))},function(e,t,r){"use strict";var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();var o=r(1).fpnn,i=r(0),s=(r(2),function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),o.FPEvent.assign(this),this._map={},this._client=t,this.uid=0,this._expireTimerID=0,this._msgOptions={codec:i.MsgPack.createCodec({int64:!0})},this._binaryOptions={codec:i.MsgPack.createCodec({int64:!0,useraw:!0})},this._binaryMessageMethodList=[i.SERVER_PUSH.recvMessage,i.SERVER_PUSH.recvGroupMessage,i.SERVER_PUSH.recvRoomMessage,i.SERVER_PUSH.recvBroadcastMessage,i.SERVER_PUSH.recvFile,i.SERVER_PUSH.recvGroupFile,i.SERVER_PUSH.recvRoomFile,i.SERVER_PUSH.recvBroadcastFile],u.call(this)}return n(e,[{key:"service",value:function(e,t){if(e&&Object.prototype.hasOwnProperty.call(e,"_tlvPayload")&&(r=e.method,n=i.TLV_SERVER_PUSH,r===n.recvMessage||r===n.recvGroupMessage||r===n.recvRoomMessage||r===n.recvBroadcastMessage||r===n.kickOut||r===n.kickOutRoom))this._serviceTLVPush(e);else{var r,n,o=!0;i.SERVER_PUSH.kickOut==e.method&&(o=!1),i.SERVER_PUSH.kickOutRoom==e.method&&(o=!1),o&&t&&(0==e.flag&&t(JSON.stringify({}),!1),1==e.flag&&t(i.MsgPack.encode({},this._msgOptions),!1));var s=null;if(e&&Object.prototype.hasOwnProperty.call(e,"_tlvPayload")&&(s=e._tlvPayload,e._tlvBinaryPayload&&(s.binary=s.msg)),s||0!=e.flag||(s=JSON.parse(e.payload)),!s&&1==e.flag)if(-1!==this._binaryMessageMethodList.indexOf(e.method))if((s=i.MsgPack.decode(e.payload,this._binaryOptions)).mtype==i.CHAT_TYPE.text)s=i.MsgPack.decode(e.payload,this._msgOptions);else{s.binary=s.msg;try{s.msg=new TextDecoder("utf-8",{fatal:!0}).decode(s.msg)}catch(e){s.msg=void 0}try{s.attrs=new TextDecoder("utf-8",{fatal:!0}).decode(s.attrs)}catch(e){}}else s=i.MsgPack.decode(e.payload,this._msgOptions);if(s){if(void 0!==s.attrs)try{var a=JSON.parse(s.attrs);if(a&&void 0!==a.excludedUids&&Array.isArray(a.excludedUids)&&a.excludedUids.includes(this.uid.toString()))return}catch(e){}"function"==typeof this[e.method]&&this[e.method].call(this,s)}}}},{key:"_serviceTLVPush",value:function(e){var t=e._tlvPayload;if(t&&void 0!==t.extra)try{var r=JSON.parse(t.extra);if(r&&void 0!==r.excludedUids&&Array.isArray(r.excludedUids)&&r.excludedUids.includes(this.uid.toString()))return}catch(e){}this.emit(e.method,t)}},{key:"destroy",value:function(){this._map={},this._expireTimerID&&(clearInterval(this._expireTimerID),this._expireTimerID=0)}},{key:"kickout",value:function(e){this.emit(i.SERVER_PUSH.kickOut,e)}},{key:"kickoutroom",value:function(e){e.rid&&(e.rid=new i.Int64(e.rid)),this.emit(i.SERVER_PUSH.kickOutRoom,e)}},{key:"pushmsg",value:function(e){e.from&&(e.from=new i.Int64(e.from)),e.mid&&(e.mid=new i.Int64(e.mid),!a.call(this,1,e.mid,e.from))||(e.mtime&&(e.mtime=new i.Int64(e.mtime)),e.mtype>=40&&e.mtype<=50?this.emit(i.SERVER_PUSH.recvFile,e):e.mtype!=i.CHAT_TYPE.text?e.mtype!=i.CHAT_TYPE.audio?e.mtype!=i.CHAT_TYPE.cmd?(delete e.ftype,this.emit(i.SERVER_PUSH.recvMessage,e)):this.emit(i.SERVER_PUSH.recvCmd,e):this.emit(i.SERVER_PUSH.recvFile,e):this.emit(i.SERVER_PUSH.recvChat,e))}},{key:"pushgroupmsg",value:function(e){e.from&&(e.from=new i.Int64(e.from)),e.mid&&(e.mid=new i.Int64(e.mid),!a.call(this,2,e.mid,e.from,e.gid))||(e.gid&&(e.gid=new i.Int64(e.gid)),e.mtime&&(e.mtime=new i.Int64(e.mtime)),e.mtype>=40&&e.mtype<=50?this.emit(i.SERVER_PUSH.recvGroupFile,e):e.mtype!=i.CHAT_TYPE.text?e.mtype!=i.CHAT_TYPE.audio?e.mtype!=i.CHAT_TYPE.cmd?(delete e.ftype,this.emit(i.SERVER_PUSH.recvGroupMessage,e)):this.emit(i.SERVER_PUSH.recvGroupCmd,e):this.emit(i.SERVER_PUSH.recvGroupFile,e):this.emit(i.SERVER_PUSH.recvGroupChat,e))}},{key:"pushroommsg",value:function(e){e.from&&(e.from=new i.Int64(e.from)),e.mid&&(e.mid=new i.Int64(e.mid),!a.call(this,3,e.mid,e.from,e.rid))||(e.rid&&(e.rid=new i.Int64(e.rid)),e.mtime&&(e.mtime=new i.Int64(e.mtime)),e.mtype>=40&&e.mtype<=50?this.emit(i.SERVER_PUSH.recvRoomFile,e):e.mtype!=i.CHAT_TYPE.text?e.mtype!=i.CHAT_TYPE.audio?e.mtype!=i.CHAT_TYPE.cmd?(delete e.ftype,this.emit(i.SERVER_PUSH.recvRoomMessage,e)):this.emit(i.SERVER_PUSH.recvRoomCmd,e):this.emit(i.SERVER_PUSH.recvRoomFile,e):this.emit(i.SERVER_PUSH.recvRoomChat,e))}},{key:"pushbroadcastmsg",value:function(e){e.from&&(e.from=new i.Int64(e.from)),e.mid&&(e.mid=new i.Int64(e.mid),!a.call(this,4,e.mid,e.from))||(e.mtime&&(e.mtime=new i.Int64(e.mtime)),e.mtype>=40&&e.mtype<=50?this.emit(i.SERVER_PUSH.recvBroadcastFile,e):e.mtype!=i.CHAT_TYPE.text?e.mtype!=i.CHAT_TYPE.audio?e.mtype!=i.CHAT_TYPE.cmd?(delete e.ftype,this.emit(i.SERVER_PUSH.recvBroadcastMessage,e)):this.emit(i.SERVER_PUSH.recvBroadcastCmd,e):this.emit(i.SERVER_PUSH.recvBroadcastFile,e):this.emit(i.SERVER_PUSH.recvBroadcastChat,e))}},{key:"ping",value:function(e){this._client._lastPingTime=parseInt(Date.now()/1e3),this.emit(i.SERVER_PUSH.recvPing,e)}}]),e}());function a(e,t,r,n){var o=[];o.push(e),o.push(t),o.push(r),null!=n&&o.push(n);var s=o.join("_");if(this._map.hasOwnProperty(s)){if(this._map[s]>Date.now())return!1;delete this._map[s]}return this._map[s]=i.MID_TTL+Date.now(),!0}function u(){var e=this;this._expireTimerID=setInterval((function(){for(var t in e._map)e._map[t]>Date.now()||c.call(e,t)}),i.MID_TTL+1e3)}function c(e){var t=this;setTimeout((function(){delete t._map[e]}),0)}e.exports=s},function(e,t,r){"use strict";var n="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=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();var i=r(10),s=r(11),a=r(4),u=r(0),c=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);var r=t||{};if("string"!=typeof r.endpoint||!/^wss?:\/\//i.test(r.endpoint))throw new Error("tlv-v1 requires an explicit ws:// or wss:// endpoint URL");this._endpoint=r.endpoint,this._webSocketFactory=r.webSocketFactory||f,this._legacyMsgPack=r.legacyMsgPack||u.MsgPack,this._legacyMsgOptions=r.legacyMsgOptions,this._requestMetadata=r.requestMetadata,this._connectionTimeout=r.connectionTimeout||3e4,this._requestTimeout=r.requestTimeout||2e4,this._heartbeatIdleMs=r.heartbeatIdleMs||3e4,this._heartbeatTimeoutMs=r.heartbeatTimeoutMs||1e4,this._dedupTtlMs=Math.max(r.pushDedupTtlMs||3e4,2e4),this._listeners={},this._pending=new Map,this._receivedMessages=new Map,this._nextSequence=1,this._socket=null,this._connectionGeneration=0,this._state="idle",this._authenticated=!1,this._connectionTimer=0,this._heartbeatTimer=0,this._heartbeatPending=!1,this._lastActivity=0,this._incomingQueue=Promise.resolve(),this._protocolClosing=!1,this._destroyed=!1,this.processor=null}return o(e,[{key:"on",value:function(e,t){return"function"!=typeof t||(this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push(t)),this}},{key:"off",value:function(e,t){var r=this._listeners[e];return r?(this._listeners[e]=r.filter((function(e){return e!==t})),this):this}},{key:"emit",value:function(e){var t=this._listeners[e]||[],r=Array.prototype.slice.call(arguments,1),n=this;t.slice().forEach((function(e){e.apply(n,r)}))}},{key:"connect",value:function(){if(!this._destroyed&&"connecting"!==this._state&&"open"!==this._state&&"closing"!==this._state){var e=this._connectionGeneration+1;this._connectionGeneration=e,this._nextSequence=1,this._receivedMessages.clear(),this._incomingQueue=Promise.resolve(),this._state="connecting",this._protocolClosing=!1;var t=void 0;try{t=this._webSocketFactory(this._endpoint)}catch(e){return this._state="closed",this.emit("error",h("cannot create WebSocket: "+e.message)),void this.emit("close")}if(!t||"function"!=typeof t.send||"function"!=typeof t.close)return this._state="closed",this.emit("error",h("webSocketFactory returned an invalid socket")),void this.emit("close");this._socket=t;try{t.binaryType="arraybuffer"}catch(e){}t.onopen=this._onOpen.bind(this,t,e),t.onmessage=this._onMessage.bind(this,t,e),t.onerror=this._onError.bind(this,t,e),t.onclose=this._onClose.bind(this,t,e),this._connectionTimer=setTimeout(this._onConnectionTimeout.bind(this,t,e),this._connectionTimeout)}}},{key:"close",value:function(){this._clearConnectionTimeout(),this._stopHeartbeat(),this._authenticated=!1,"open"!==this._state&&"connecting"!==this._state||(this._state="closing");var e=this._socket;if(e)try{e.close()}catch(e){this._finalizeClose()}else this._finalizeClose()}},{key:"destroy",value:function(){if(!this._destroyed){this._destroyed=!0,this._clearConnectionTimeout(),this._stopHeartbeat(),this._authenticated=!1;var e=this._socket;if(e)try{e.close()}catch(e){}this._finalizeClose(),this._listeners={},this._receivedMessages.clear()}}},{key:"markAuthenticated",value:function(){this._destroyed||"open"!==this._state||(this._authenticated=!0,this._lastActivity=Date.now(),this._startHeartbeat())}},{key:"sendQuest",value:function(e,t,r){try{var n=this._decodeLegacyPayload(e&&e.payload),o=s.toWireRequest(e&&e.method,n.payload,this._requestMetadata,{omitLegacyNil:n.legacyEncoded});this._request(o.uri,o.payload,r,{onError:function(e){t&&t(d(e))},onSuccess:function(e){t&&t({_tlvPayload:p(e),mtype:2,ss:0})}})}catch(e){t&&t(d(e))}}},{key:"_decodeLegacyPayload",value:function(e){if(null==e)return{legacyEncoded:!1,payload:{}};if(a.isPlainMap(e))return{legacyEncoded:!1,payload:e};try{var t=this._legacyMsgPack.decode(e,this._legacyMsgOptions);if(!a.isPlainMap(t))throw new Error("legacy request payload is not a map");return{legacyEncoded:!0,payload:t}}catch(e){throw new s.TLVContractError(200034,"cannot decode local request payload: "+e.message)}}},{key:"_onOpen",value:function(e,t){e!==this._socket||t!==this._connectionGeneration||"connecting"!==this._state||this._destroyed||(this._clearConnectionTimeout(),this._state="open",this._lastActivity=Date.now(),this.emit("connect"))}},{key:"_onMessage",value:function(e,t,r){if(e===this._socket&&t===this._connectionGeneration&&"open"===this._state&&!this._destroyed){var o=r&&("object"===(void 0===r?"undefined":n(r))||"function"==typeof r)&&"data"in r?r.data:r;this._incomingQueue=this._incomingQueue.then((function(){return function(e){if("string"==typeof e)return Promise.reject(new Error("WebSocket text messages are forbidden by TLV v1"));var t=a.getByteView(e);if(t)return Promise.resolve(t);if(e&&"function"==typeof e.arrayBuffer){var r=void 0;try{r=e.arrayBuffer()}catch(e){return Promise.reject(e)}return Promise.resolve(r).then((function(e){var t=a.getByteView(e);if(!t)throw new Error("WebSocket Blob did not resolve to binary data");return t}))}return Promise.reject(new Error("WebSocket message is not binary data"))}(o)})).then(this._handleIncomingBytes.bind(this,e,t)).catch(this._handleIncomingFailure.bind(this,e,t))}}},{key:"_onError",value:function(e,t,r){if(e===this._socket&&t===this._connectionGeneration&&!this._destroyed){var n=r&&r.message?r.message:"WebSocket transport error";this.emit("error",h(n))}}},{key:"_onClose",value:function(e,t){e===this._socket&&t===this._connectionGeneration&&this._finalizeClose()}},{key:"_onConnectionTimeout",value:function(e,t){if(this._connectionTimer=0,e===this._socket&&t===this._connectionGeneration&&"connecting"===this._state&&!this._destroyed){var r=h("WebSocket connection timed out after "+this._connectionTimeout+" ms");try{this.emit("error",r)}finally{if(e===this._socket&&t===this._connectionGeneration&&!this._destroyed&&"closed"!==this._state){this._state="closing";try{e.close()}catch(e){}e===this._socket&&t===this._connectionGeneration&&"closed"!==this._state&&this._finalizeClose()}}}}},{key:"_clearConnectionTimeout",value:function(){this._connectionTimer&&(clearTimeout(this._connectionTimer),this._connectionTimer=0)}},{key:"_handleIncomingBytes",value:function(e,t,r){if(e===this._socket&&t===this._connectionGeneration&&"open"===this._state&&!this._destroyed){this._lastActivity=Date.now();var n=i.decodeFrame(r);"2"!==n.mt?"1"!==n.mt?this._handleOneWayPush(n):this._handleReliablePush(n):this._handleAnswer(n)}}},{key:"_handleIncomingFailure",value:function(e,t,r){e!==this._socket||t!==this._connectionGeneration||this._destroyed||this._protocolFailure(r)}},{key:"_handleAnswer",value:function(e){if("control.ack"===e.uri)throw new Error("Gate must not send control.ack to a Client");var t=this._pending.get(e.sequence);if(t){if("control.error"===e.uri)return s.validateControlError(e.payload),void this._completePending(e.sequence,!1,{reason:e.payload.reason,status:Number(e.payload.status)});if(e.uri!==t.uri)throw new Error("Answer URI does not match pending request URI");s.validateResponse(e.uri,e.payload),this._completePending(e.sequence,!0,e.payload)}}},{key:"_handleReliablePush",value:function(e){if(!s.isReliablePush(e.uri))throw new Error('Gate sent an unsupported mt="1" Quest URI: '+e.uri);s.validatePush(e.uri,e.payload);var t=String(e.payload.message_ref),r=this._isDuplicateMessage(t);if(this._sendFrame(e.sequence,"2","control.ack",{}),!r){var n={method:e.uri,payload:p(e.payload)};this._rememberMessage(t),this._dispatchPush(n)}}},{key:"_handleOneWayPush",value:function(e){if(!s.isOneWayPush(e.uri))throw new Error('Gate sent an unsupported mt="0" URI: '+e.uri);s.validatePush(e.uri,e.payload);var t={method:e.uri,payload:p(e.payload)};"event.kicked"===e.uri&&(this._authenticated=!1,this._stopHeartbeat()),this._dispatchPush(t)}},{key:"_dispatchPush",value:function(e){if(this.processor&&"function"==typeof this.processor.service){var t=a.getByteView(e.payload.payload);this.processor.service({_tlvBinaryPayload:!!t,_tlvPayload:e.payload,flag:1,method:e.method})}}},{key:"_request",value:function(e,t,r,n){if(!this._destroyed&&"open"===this._state&&this._socket)if(this._authenticated||"auth.login"===e||"control.ping"===e)if(this._authenticated&&"auth.login"===e)n.onError({status:200023,reason:"auth.login cannot be sent twice on one connection"});else{var o=this._allocateSequence(),i="number"==typeof r&&r>0?r:this._requestTimeout,s={handlers:n,timer:setTimeout(this._onRequestTimeout.bind(this,o),i),uri:e};this._pending.set(o,s);try{this._sendFrame(o,"1",e,t)}catch(e){this._pending.delete(o),clearTimeout(s.timer),n.onError(l(e))}}else n.onError({status:200022,reason:"authentication is required before "+e});else n.onError(h("invalid WebSocket connection"))}},{key:"_onRequestTimeout",value:function(e){var t=this._pending.get(e);t&&(this._pending.delete(e),t.handlers.onError({status:200999,reason:"request timeout"}))}},{key:"_completePending",value:function(e,t,r){var n=this._pending.get(e);n&&(this._pending.delete(e),clearTimeout(n.timer),t?n.handlers.onSuccess(r):n.handlers.onError(r))}},{key:"_allocateSequence",value:function(){for(var e=0;e<i.MAX_SEQUENCE;e+=1){var t=this._nextSequence;if(this._nextSequence=t===i.MAX_SEQUENCE?1:t+1,!this._pending.has(t))return t}throw new Error("all TLV request sequences are pending")}},{key:"_sendFrame",value:function(e,t,r,n){if(this._destroyed||"open"!==this._state||!this._socket)throw h("invalid WebSocket connection");var o=i.encodeFrame(e,t,r,n),s=o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength);this._socket.send(s),this._lastActivity=Date.now()}},{key:"_startHeartbeat",value:function(){this._stopHeartbeat(),this._heartbeatTimer=setInterval(this._heartbeatTick.bind(this),1e3)}},{key:"_stopHeartbeat",value:function(){this._heartbeatTimer&&(clearInterval(this._heartbeatTimer),this._heartbeatTimer=0),this._heartbeatPending=!1}},{key:"_heartbeatTick",value:function(){this._authenticated&&!this._heartbeatPending&&"open"===this._state&&(Date.now()-this._lastActivity<this._heartbeatIdleMs||(this._heartbeatPending=!0,this._request("control.ping",{},this._heartbeatTimeoutMs,{onError:this._onHeartbeatError.bind(this),onSuccess:this._onHeartbeatAnswer.bind(this)})))}},{key:"_onHeartbeatAnswer",value:function(e){this._heartbeatPending=!1,a.isPlainMap(e)||this._protocolFailure(new Error("control.ping Answer body must be a map"))}},{key:"_onHeartbeatError",value:function(e){this._heartbeatPending=!1,this._protocolFailure(new Error("control.ping failed: "+l(e).reason))}},{key:"_isDuplicateMessage",value:function(e){this._expireReceivedMessages();var t=this._receivedMessages.get(e);return void 0!==t&&t>Date.now()}},{key:"_rememberMessage",value:function(e){this._receivedMessages.set(e,Date.now()+this._dedupTtlMs)}},{key:"_expireReceivedMessages",value:function(){var e=Date.now();this._receivedMessages.forEach((function(t,r){t<=e&&this._receivedMessages.delete(r)}),this)}},{key:"_protocolFailure",value:function(e){if(!this._protocolClosing&&"closed"!==this._state){this._protocolClosing=!0;var t=l(e);this.emit("error",h("TLV protocol error: "+t.reason));var r=this._socket;if(r){this._state="closing";try{r.close(1002,"TLV protocol error")}catch(e){this._finalizeClose()}}else this._finalizeClose()}}},{key:"_finalizeClose",value:function(){if("closed"!==this._state){this._state="closed",this._clearConnectionTimeout(),this._socket=null,this._authenticated=!1,this._stopHeartbeat();var e=Array.from(this._pending.values());this._pending.clear(),e.forEach((function(e){clearTimeout(e.timer),e.handlers.onError(h("WebSocket connection closed"))})),this.emit("close")}}}]),e}();function f(e){var t="undefined"!=typeof WebSocket?WebSocket:"undefined"!=typeof globalThis?globalThis.WebSocket:void 0;if("function"!=typeof t)throw new Error("WebSocket is unavailable; provide options.webSocketFactory");return new t(e)}function l(e){return e&&"number"==typeof e.status?{reason:"string"==typeof e.reason?e.reason:e.message||String(e.status),status:e.status}:{reason:e&&e.message?e.message:String(e||"unknown error"),status:200999}}function h(e){return{reason:e,status:200999}}function d(e){var t=l(e);return{_tlvPayload:{reason:t.reason,status:t.status},mtype:2,ss:1}}function p(e){if(e instanceof a.Int64Value)return new u.Int64(e.toString());if(Array.isArray(e))return e.map(p);if(a.isPlainMap(e)){var t={};return Object.keys(e).forEach((function(r){t[r]=p(e[r])})),t}return e}e.exports=c},function(e,t,r){"use strict";var n=r(4),o=new Uint8Array([2,0,109,116,1,0]),i=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return r.name="TLVCodecError",r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,Error),t}();function s(e){if("number"!=typeof e||!isFinite(e)||Math.floor(e)!==e||e<1||e>2147483647)throw new i("sequence must be an integer in 1..2147483647")}function a(e,t,r){var n=r>>>0;e[t]=255&n,e[t+1]=n>>>8&255,e[t+2]=n>>>16&255,e[t+3]=n>>>24&255}function u(e,t){return e[t]+256*e[t+1]+65536*e[t+2]+16777216*e[t+3]>>>0}e.exports={FLAGS:4,MAGIC:204,MAX_FRAME_LENGTH:67239936,MAX_PAYLOAD_LENGTH:67108864,MAX_SEQUENCE:2147483647,METADATA_LENGTH:7,TLVCodecError:i,VERSION:1,decodeFrame:function(e){var t=n.toUint8Array(e);if(0===t.length||t.length>67239936)throw new i("TLV frame length is outside the allowed limit");if(t.length<27)throw new i("TLV frame is too short");if(204!==t[0]||1!==t[1]||4!==t[2]||0!==t[3])throw new i("invalid TLV v1 header");var r=u(t,4);if(s(r),7!==function(e,t){return e[t]+256*e[t+1]}(t,8))throw new i("TLV v1 metadata length must be exactly 7");for(var a=0;a<o.length;a+=1)if(t[10+a]!==o[a])throw new i("TLV v1 metadata must contain only key mt");var c=t[16];if(48!==c&&49!==c&&50!==c)throw new i("TLV v1 metadata mt is invalid");var f=String.fromCharCode(c);if(u(t,17)!==t.length-21)throw new i("message queue length does not match the frame boundary");var l=21,h=t[l];if(l+=1,0===h||l+h+1+4>t.length)throw new i("invalid URI length in message queue");var d=n.utf8Decode(t.subarray(l,l+h));if(0!==t[l+=h])throw new i("TLV v1 passThrough must be empty");var p=u(t,l+=1);if(l+=4,0===p||p>67108864||l+p!==t.length)throw new i("invalid MsgPack payload length or trailing bytes");var g=t.subarray(l,l+p),y=void 0;try{y=n.decodeMap(g,{allowIntegerMapKeyAtPath:"room.last_messages"===d?["last_by_room"]:null})}catch(e){if(e instanceof i)throw e;throw new i("invalid MsgPack payload: "+e.message)}return{mt:f,payload:y,payloadBytes:new Uint8Array(g),sequence:r,uri:d}},encodeFrame:function(e,t,r,u){s(e),function(e){if("0"!==e&&"1"!==e&&"2"!==e)throw new i('metadata mt must be "0", "1", or "2"')}(t);var c=function(e){if("string"!=typeof e||0===e.length)throw new i("URI must be a non-empty UTF-8 string");var t=n.utf8Encode(e);if(0===t.length||t.length>255)throw new i("URI UTF-8 length must be in 1..255");return t}(r),f=n.encodeMap(void 0===u?{}:u);if(0===f.length||f.length>67108864)throw new i("MsgPack payload length is outside the TLV v1 limit");var l=1+c.length+1+4+f.length,h=21+l;if(h>67239936)throw new i("TLV frame exceeds the maximum frame length");var d=new Uint8Array(h);d[0]=204,d[1]=1,d[2]=4,d[3]=0,a(d,4,e),function(e,t,r){e[t]=255&r,e[t+1]=r>>>8&255}(d,8,7),d.set(o,10),d[16]=t.charCodeAt(0),a(d,17,l);var p=21;return d[p]=c.length,p+=1,d.set(c,p),d[p+=c.length]=0,a(d,p+=1,f.length),p+=4,d.set(f,p),d}}},function(e,t,r){"use strict";var n="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};var o=r(4),i=function(e){function t(e,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,r));return n.name="TLVContractError",n.status=e,n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,Error),t}();function s(e,t,r,n){var o=n||{};return{defaults:o.defaults||{},pass:o.pass||[],request:t||{},required:o.required||[],response:r||{},uri:e}}var a={cursor:0,end_ms:0,limit:20,reverse:!1,start_ms:0},u={end_ms:0,limit:20,reverse:!1,start_ms:0},c={end_ms:0,start_ms:0},f={begin:"start_ms",desc:"reverse",end:"end_ms",lastid:"cursor",mtypes:"kinds",num:"limit"},l={begin:"start_ms",desc:"reverse",end:"end_ms",mid:"anchor",mtypes:"kinds",num:"limit"},h={begin:"start_ms",end:"end_ms",mtypes:"kinds"},d={begin:"first_ms",end:"last_ms",lastid:"next",msgs:"items",num:"size"},p={auth:s("auth.login",{attrs:"props",authv:"auth_ver",lang:"locale",pid:"project",token:"credential",ts:"auth_sec",uid:"user",version:"client_ver"},{ok:"accepted"},{required:["project","user","credential","client_ver"]}),bye:s("connection.close"),getservertime:s("system.time",null,{mts:"server_ms"}),addattrs:s("connection.set_props",{attrs:"props"},null,{required:["props"]}),getattrs:s("connection.get_props",null,{attrs:"props"}),adddebuglog:s("system.debug",{attrs:"context",msg:"entry"},null,{required:["entry","context"]}),getonlineusers:s("presence.online",{uids:"users"},{uids:"online_users"},{required:["users"]}),setuserinfo:s("user.set_profile",{oinfo:"public_data",pinfo:"private_data"}),getuserinfo:s("user.get_profile",null,{oinfo:"public_data",pinfo:"private_data"}),getuseropeninfo:s("user.get_public",{uids:"users"},{info:"profiles"},{required:["users"]}),setlang:s("user.set_locale",{lang:"locale"},{ok:"updated"},{required:["locale"]}),dataget:s("storage.get",{key:"slot"},{val:"value"},{required:["slot"]}),dataset:s("storage.set",{key:"slot",val:"value"},null,{required:["slot","value"]}),datadel:s("storage.delete",{key:"slot"},null,{required:["slot"]}),addblacks:s("blacklist.add",{blacks:"blocked_users"},null,{required:["blocked_users"]}),delblacks:s("blacklist.remove",{blacks:"blocked_users"},null,{required:["blocked_users"]}),getblacks:s("blacklist.list",null,{uids:"blocked_users"}),addgroupmembers:s("group.add",{gid:"group_ref",uids:"members"},null,{required:["group_ref","members"]}),delgroupmembers:s("group.remove",{gid:"group_ref",uids:"members"},null,{required:["group_ref","members"]}),getgroupmembers:s("group.members",{gid:"group_ref",online:"with_online"},{onlines:"active_members",uids:"members"},{required:["group_ref"]}),getgroupcount:s("group.count",{gid:"group_ref",online:"with_online"},{cn:"total",online:"active_total"},{required:["group_ref"]}),getusergroups:s("group.joined",null,{gids:"group_refs"}),setgroupinfo:s("group.set_profile",{gid:"group_ref",oinfo:"public_data",pinfo:"private_data"},null,{required:["group_ref"]}),getgroupinfo:s("group.get_profile",{gid:"group_ref"},{oinfo:"public_data",pinfo:"private_data"},{required:["group_ref"]}),getgroupopeninfo:s("group.get_public",{gid:"group_ref"},{oinfo:"public_data"},{required:["group_ref"]}),getgroupsopeninfo:s("group.get_public_batch",{gids:"group_refs"},{info:"profiles"},{required:["group_refs"]}),enterroom:s("room.join",{rid:"room_ref"},null,{required:["room_ref"]}),leaveroom:s("room.leave",{rid:"room_ref"},null,{required:["room_ref"]}),enterrooms:s("room.join_batch",{rids:"room_refs"},null,{required:["room_refs"]}),getuserrooms:s("room.joined",null,{rooms:"room_refs"}),getroommembers:s("room.members",{rid:"room_ref"},{uids:"members"},{required:["room_ref"]}),getroomcount:s("room.counts",{rids:"room_refs"},{cn:"totals"},{required:["room_refs"]}),setroominfo:s("room.set_profile",{icon:"avatar",name:"label",oinfo:"public_data",pinfo:"private_data",rid:"room_ref"},null,{required:["room_ref"]}),getroominfo:s("room.get_profile",{rid:"room_ref"},{oinfo:"public_data",pinfo:"private_data"},{required:["room_ref"]}),getroomopeninfo:s("room.get_public",{rid:"room_ref"},{oinfo:"public_data"},{required:["room_ref"]}),getroomsopeninfo:s("room.get_public_batch",{rids:"room_refs"},{info:"profiles"},{required:["room_refs"]}),getuserroomsandlastmsg:s("room.last_messages",{mtypes:"kinds"},{rooms:"last_by_room"}),sendmsg:s("message.send",{attrs:"extra",mid:"message_ref",msg:"payload",mtype:"kind",to:"recipient"},{mid:"message_ref",mtime:"time_ms"},{pass:["checkParams","strategyid"],required:["recipient","message_ref","kind","payload","extra"]}),sendmsgs:s("message.send_batch",{attrs:"extra",mid:"message_ref",msg:"payload",mtype:"kind",tos:"recipients"},{mid:"message_ref",mtime:"time_ms"},{required:["recipients","message_ref","kind","payload","extra"]}),sendgroupmsg:s("message.send_group",{attrs:"extra",gid:"group_ref",mid:"message_ref",msg:"payload",mtype:"kind"},{mid:"message_ref",mtime:"time_ms"},{pass:["checkParams","strategyid"],required:["group_ref","message_ref","kind","payload","extra"]}),sendroommsg:s("message.send_room",{attrs:"extra",mid:"message_ref",msg:"payload",mtype:"kind",rid:"room_ref"},{mid:"message_ref",mtime:"time_ms"},{pass:["checkParams","strategyid"],required:["room_ref","message_ref","kind","payload","extra"]}),tcheck:s("moderation.check",{region:"zone",text:"payload"},{language:"detected_locale",result:"decision",text:"filtered",wlist:"matches"},{pass:["checkParams","strategyId"],required:["payload"]}),translate:s("translation.run",{dst:"to_locale",profanity:"filter_mode",src:"from_locale",text:"input",type:"format"},{dtext:"output",dst:"to_locale",source:"detected_locale",sourceText:"original",src:"from_locale",stext:"input",target:"resolved_locale",targetText:"translated"},{defaults:{filter_mode:"off",format:"chat"},required:["input","to_locale","format","filter_mode"]}),getp2pmsg:s("history.direct",Object.assign({ouid:"peer"},f),d,{defaults:a,required:["peer","reverse","limit","start_ms","end_ms","cursor"]}),getgroupmsg:s("history.group",Object.assign({gid:"group_ref"},f),d,{defaults:a,required:["group_ref","reverse","limit","start_ms","end_ms","cursor"]}),getroommsg:s("history.room",Object.assign({rid:"room_ref"},f),d,{defaults:a,required:["room_ref","reverse","limit","start_ms","end_ms","cursor"]}),getbroadcastmsg:s("history.broadcast",f,d,{defaults:a,required:["reverse","limit","start_ms","end_ms","cursor"]}),getp2pmsgbymessageid:s("history.direct_anchor",Object.assign({ouid:"peer"},l),d,{defaults:u,required:["peer","anchor","reverse","limit","start_ms","end_ms"]}),getgroupmsgbymessageid:s("history.group_anchor",Object.assign({gid:"group_ref"},l),d,{defaults:u,required:["group_ref","anchor","reverse","limit","start_ms","end_ms"]}),getroommsgbymessageid:s("history.room_anchor",Object.assign({rid:"room_ref"},l),d,{defaults:u,required:["room_ref","anchor","reverse","limit","start_ms","end_ms"]}),getbroadcastmsgbymessageid:s("history.broadcast_anchor",l,d,{defaults:u,required:["anchor","reverse","limit","start_ms","end_ms"]}),getp2pmsgcount:s("history.direct_count",Object.assign({ouid:"peer"},h),{count:"total"},{defaults:c,required:["peer","start_ms","end_ms"]}),getgroupmsgcount:s("history.group_count",Object.assign({gid:"group_ref"},h),{count:"total"},{defaults:c,required:["group_ref","start_ms","end_ms"]}),getroommsgcount:s("history.room_count",Object.assign({rid:"room_ref"},h),{count:"total"},{defaults:c,required:["room_ref","start_ms","end_ms"]}),getbroadcastmsgcount:s("history.broadcast_count",h,{count:"total"},{defaults:c,required:["start_ms","end_ms"]}),getmsg:s("message.get",{from:"sender",mid:"message_ref",type:"channel",xid:"target_ref"},{attrs:"extra",from:"sender",id:"sequence",mid:"message_ref",msg:"payload",mtime:"time_ms",mtype:"kind"},{required:["sender","message_ref","target_ref","channel"]}),delmsg:s("message.revoke",{from:"sender",mid:"message_ref",type:"channel",xid:"target_ref"},null,{required:["sender","message_ref","target_ref","channel"]}),getunread:s("unread.summary",{clear:"mark_read",gettime:"with_logout"},{group:"group_refs",logouttime:"logout_sec",p2p:"peers"},{defaults:{mark_read:!1},required:["mark_read"]}),getsession:s("session.list",null,{group:"group_refs",p2p:"peers"}),cleanunread:s("unread.clear"),setsessionread:s("session.read",{category:"channel",read_seq:"through",xid:"target_ref"},null,{required:["channel","target_ref","through"]}),getp2punread:s("unread.direct",{mtime:"since_ms",mtypes:"kinds",uids:"peers"},{ltime:"times",p2p:"counts"},{required:["peers"]}),getgroupunread:s("unread.group",{gids:"group_refs",mtime:"since_ms",mtypes:"kinds"},{group:"counts",ltime:"times"},{required:["group_refs"]}),removesession:s("session.remove",{oneway:"local_only",to:"peer"},null,{defaults:{local_only:!1},required:["peer","local_only"]}),getp2pconversationlist:s("conversation.direct",{mtime:"since_ms",mtypes:"kinds"},{conversations:"peers",msgs:"last_items",unreads:"badges"}),getp2punreadconversationlist:s("conversation.direct_unread",{mtime:"since_ms",mtypes:"kinds"},{conversations:"peers",msgs:"last_items",unreads:"badges"}),getgroupconversationlist:s("conversation.group",{mtime:"since_ms",mtypes:"kinds"},{conversations:"group_refs",msgs:"last_items",unreads:"badges"}),getgroupunreadconversationlist:s("conversation.group_unread",{mtime:"since_ms",mtypes:"kinds"},{conversations:"group_refs",msgs:"last_items",unreads:"badges"}),getunreadconversationlist:s("conversation.unread",{clear:"mark_read",mtime:"since_ms",mtypes:"kinds"},{groupConversations:"group_refs",groupMsgs:"group_last",groupUnreads:"group_badges",p2pConversations:"peers",p2pMsgs:"peer_last",p2pUnreads:"peer_badges"},{defaults:{mark_read:!1},required:["mark_read"]})},g=new Set(["acheck","adddevice","addfriends","addoption","addprojectban","adminCommand","broadcastfile","closeRTCRoom","delfriends","filetoken","getfriends","getoption","getRTCRoomList","getRTCRoomMemberCount","getRTCRoomMembers","icheck","inviteUserIntoRTCRoom","isfriend","isfriends","isprojectban","kickoutFromRTCRoom","profanity","pullIntoRTCRoom","removedevice","removeoption","removeprojectban","sendfile","sendfiles","sendgroupfile","sendroomfile","setRTCRoomMicStatus","speech2text","speechtranslation","uploadfile","vcheck"]),y={"event.broadcast":!0,"event.direct":!0,"event.group":!0,"event.room":!0},m={"event.kicked":!0,"event.room_removed":!0},_="9223372036854775807";function v(e,t,r){return Object.assign({required:!!t,type:e},r||{})}function b(e,t){return v("integer",e,Object.assign({min:"-9223372036854775808",max:_},t||{}))}function w(e,t){return v("integer",e,Object.assign({min:"-2147483648",max:"2147483647"},t||{}))}function E(e,t){return b(e,Object.assign({min:"1"},t||{}))}function k(e,t){return b(e,Object.assign({min:"0"},t||{}))}function R(e,t){return w(e,Object.assign({min:"0"},t||{}))}function P(e,t){return v("string",e,t)}function C(e){return v("boolean",e)}function O(e,t,r){return v("array",e,Object.assign({element:t},r||{}))}function T(e,t,r,n){return v("map",e,Object.assign({key:t,value:r},n||{}))}function A(e){return Object.assign({sent_ms:b(!1),trace:P(!1)},e||{})}function S(e,t){return{allowEmpty:!(!t||!t.allowEmpty),fields:e||{}}}var M=b(!1),I=w(!1),U=R(!1),B=b(!1),N=k(!1),x=E(!1),D=P(!1),L=v("string_or_bin",!1),F=v("tuple8",!1);function j(e,t){return O(e,x,t)}function q(e,t){return O(e,M,t)}function V(e,t){return O(e,I,t)}function Y(e){return T(e,"string",D)}function G(e){return T(e,"positive_decimal_int64",D)}function H(e){return T(e,"positive_decimal_int64",U)}function W(e){return T(e,"positive_decimal_int64",N)}function z(e){return b(e,{max:"255",min:"0"})}var K,J={extra:P(!0,{maxBytes:65535}),kind:(K=!0,b(K,{messageKind:!0})),message_ref:k(!0),payload:v("string_or_bin",!0,{maxBytes:65535})},Q={cursor:b(!0),end_ms:k(!0),kinds:q(!1),limit:R(!0),reverse:C(!0),start_ms:k(!0)},$={anchor:E(!0),end_ms:k(!0),kinds:q(!1),limit:R(!0),reverse:C(!0),start_ms:k(!0)},X={end_ms:k(!0),kinds:q(!1),start_ms:k(!0)},Z={"auth.login":A({auth_sec:k(!1),auth_ver:w(!1,{enum:["2"]}),client_ver:P(!0,{nonEmpty:!0}),credential:P(!0,{nonEmpty:!0}),locale:P(!1),project:b(!0,{max:"4294967295",min:"1"}),props:Y(!1),user:E(!0)}),"connection.close":A(),"system.time":A(),"connection.set_props":A({props:Y(!0)}),"connection.get_props":A(),"system.debug":A({context:P(!0),entry:P(!0,{nonEmpty:!0})}),"presence.online":A({users:j(!0,{minItems:1})}),"user.set_profile":A({private_data:P(!1),public_data:P(!1)}),"user.get_profile":A(),"user.get_public":A({users:j(!0,{minItems:1})}),"user.set_locale":A({locale:P(!0)}),"storage.get":A({slot:P(!0)}),"storage.set":A({slot:P(!0),value:P(!0)}),"storage.delete":A({slot:P(!0)}),"blacklist.add":A({blocked_users:j(!0,{minItems:1,uniqueInt64Max:100})}),"blacklist.remove":A({blocked_users:j(!0,{minItems:1,uniqueInt64Max:100})}),"blacklist.list":A(),"group.add":A({group_ref:E(!0),members:j(!0,{minItems:1})}),"group.remove":A({group_ref:E(!0),members:j(!0,{minItems:1})}),"group.members":A({group_ref:E(!0),with_online:C(!1)}),"group.count":A({group_ref:E(!0),with_online:C(!1)}),"group.joined":A(),"group.set_profile":A({group_ref:E(!0),private_data:P(!1),public_data:P(!1)}),"group.get_profile":A({group_ref:E(!0)}),"group.get_public":A({group_ref:E(!0)}),"group.get_public_batch":A({group_refs:j(!0,{minItems:1})}),"room.join":A({room_ref:E(!0)}),"room.leave":A({room_ref:E(!0)}),"room.join_batch":A({room_refs:j(!0,{maxItems:100,minItems:1})}),"room.joined":A(),"room.members":A({room_ref:E(!0)}),"room.counts":A({room_refs:j(!0,{minItems:1})}),"room.set_profile":A({avatar:P(!1),label:P(!1),private_data:P(!1),public_data:P(!1),room_ref:E(!0)}),"room.get_profile":A({room_ref:E(!0)}),"room.get_public":A({room_ref:E(!0)}),"room.get_public_batch":A({room_refs:j(!0,{minItems:1})}),"room.last_messages":A({kinds:q(!1)}),"message.send":A(Object.assign({recipient:E(!0)},J,{checkParams:P(!1),strategyid:P(!1)})),"message.send_batch":A(Object.assign({recipients:j(!0,{maxItems:100,minItems:1})},J)),"message.send_group":A(Object.assign({group_ref:E(!0)},J,{checkParams:P(!1),strategyid:P(!1)})),"message.send_room":A(Object.assign({room_ref:E(!0)},J,{checkParams:P(!1),strategyid:P(!1)})),"moderation.check":A({checkParams:P(!1),payload:P(!0,{nonEmpty:!0}),strategyId:P(!1),zone:P(!1)}),"translation.run":A({filter_mode:P(!0,{enum:["off","stop","censor"]}),format:P(!0,{nonEmpty:!0}),from_locale:P(!1),input:P(!0,{nonEmpty:!0}),to_locale:P(!0)}),"history.direct":A(Object.assign({peer:E(!0)},Q)),"history.group":A(Object.assign({group_ref:E(!0)},Q)),"history.room":A(Object.assign({room_ref:E(!0)},Q)),"history.broadcast":A(Q),"history.direct_anchor":A(Object.assign({peer:E(!0)},$)),"history.group_anchor":A(Object.assign({group_ref:E(!0)},$)),"history.room_anchor":A(Object.assign({room_ref:E(!0)},$)),"history.broadcast_anchor":A($),"history.direct_count":A(Object.assign({peer:E(!0)},X)),"history.group_count":A(Object.assign({group_ref:E(!0)},X)),"history.room_count":A(Object.assign({room_ref:E(!0)},X)),"history.broadcast_count":A(X),"message.get":A({channel:w(!0,{enum:["1","2","3","4"]}),message_ref:b(!0),sender:E(!0),target_ref:k(!0)}),"message.revoke":A({channel:w(!0,{enum:["1","2","3","4"]}),message_ref:b(!0),sender:E(!0),target_ref:k(!0)}),"unread.summary":A({mark_read:C(!0),with_logout:C(!1)}),"session.list":A(),"unread.clear":A(),"session.read":A({channel:w(!0,{enum:["1","2","3","4","5"]}),target_ref:k(!0),through:E(!0)}),"unread.direct":A({kinds:q(!1),peers:j(!0,{minItems:1}),since_ms:k(!1)}),"unread.group":A({group_refs:j(!0,{minItems:1}),kinds:q(!1),since_ms:k(!1)}),"session.remove":A({local_only:C(!0),peer:E(!0)}),"conversation.direct":A({kinds:q(!1),since_ms:k(!1)}),"conversation.direct_unread":A({kinds:q(!1),since_ms:k(!1)}),"conversation.group":A({kinds:q(!1),since_ms:k(!1)}),"conversation.group_unread":A({kinds:q(!1),since_ms:k(!1)}),"conversation.unread":A({kinds:q(!1),mark_read:C(!0),since_ms:k(!1)})},ee={first_ms:k(!0),items:O(!0,F),last_ms:k(!0),next:b(!0),size:R(!0)},te={message_ref:b(!0),time_ms:b(!0)},re={extra:P(!0),kind:z(!0),message_ref:b(!0),payload:v("string_or_bin",!0),sender:E(!0),sequence:b(!0),time_ms:b(!0)},ne={"auth.login":S({accepted:C(!0),telemetry_on:C(!1)}),"connection.close":S(),"system.time":S({server_ms:b(!0)}),"connection.set_props":S(),"connection.get_props":S({props:Y(!0)}),"system.debug":S(),"presence.online":S({online_users:j(!0)}),"user.set_profile":S(),"user.get_profile":S({private_data:P(!0),public_data:P(!0)}),"user.get_public":S({profiles:G(!0)}),"user.set_locale":S({updated:C(!0)}),"storage.get":S({value:P(!0)}),"storage.set":S(),"storage.delete":S(),"blacklist.add":S(),"blacklist.remove":S(),"blacklist.list":S({blocked_users:j(!0)}),"group.add":S(),"group.remove":S(),"group.members":S({active_members:j(!1),members:j(!0)}),"group.count":S({active_total:R(!1),total:R(!0)}),"group.joined":S({group_refs:j(!0)}),"group.set_profile":S(),"group.get_profile":S({private_data:P(!0),public_data:P(!0)}),"group.get_public":S({public_data:P(!0)}),"group.get_public_batch":S({profiles:G(!0)}),"room.join":S(),"room.leave":S(),"room.join_batch":S(),"room.joined":S({room_refs:j(!0)}),"room.members":S({members:j(!0)}),"room.counts":S({totals:H(!0)}),"room.set_profile":S(),"room.get_profile":S({private_data:P(!0),public_data:P(!0)}),"room.get_public":S({public_data:P(!0)}),"room.get_public_batch":S({profiles:G(!0)}),"room.last_messages":S({last_by_room:function(e){return T(e,"positive_decimal_int64",F)}(!0)}),"message.send":S(te),"message.send_batch":S(te),"message.send_group":S(te),"message.send_room":S(te),"moderation.check":S({decision:w(!0),detected_locale:P(!0),filtered:P(!0),matches:function(e,t){return O(e,D,t)}(!1)}),"translation.run":S({detected_locale:P(!0),from_locale:P(!0),input:P(!0),original:P(!0),output:P(!0),resolved_locale:P(!0),to_locale:P(!0),translated:P(!0)}),"history.direct":S(ee),"history.group":S(ee),"history.room":S(ee),"history.broadcast":S(ee),"history.direct_anchor":S(ee),"history.group_anchor":S(ee),"history.room_anchor":S(ee),"history.broadcast_anchor":S(ee),"history.direct_count":S({total:R(!0)}),"history.group_count":S({total:R(!0)}),"history.room_count":S({total:R(!0)}),"history.broadcast_count":S({total:R(!0)}),"message.get":S(re,{allowEmpty:!0}),"message.revoke":S(),"unread.summary":S({group_refs:j(!0),logout_sec:k(!1),peers:j(!0)}),"session.list":S({group_refs:j(!0),peers:j(!0)}),"unread.clear":S(),"session.read":S(),"unread.direct":S({counts:H(!0),times:W(!0)}),"unread.group":S({counts:H(!0),times:W(!0)}),"session.remove":S(),"conversation.direct":S({badges:V(!0),last_items:O(!0,F),peers:j(!0)}),"conversation.direct_unread":S({badges:V(!0),last_items:O(!0,F),peers:j(!0)}),"conversation.group":S({badges:V(!0),group_refs:j(!0),last_items:O(!0,F)}),"conversation.group_unread":S({badges:V(!0),group_refs:j(!0),last_items:O(!0,F)}),"conversation.unread":S({group_badges:V(!0),group_last:O(!0,F),group_refs:j(!0),peer_badges:V(!0),peer_last:O(!0,F),peers:j(!0)}),"control.ping":S({ts:b(!1)})},oe={from_locale:P(!0),original:P(!0),to_locale:P(!0),translated:P(!0)},ie={extra:P(!0,{maxBytes:65535}),kind:z(!0),message_ref:b(!0),payload:v("push_payload",!0),sender:E(!0),time_ms:b(!0)},se={"event.direct":Object.assign({recipient:E(!0)},ie),"event.group":Object.assign({group_ref:E(!0)},ie),"event.room":Object.assign({room_ref:E(!0)},ie),"event.broadcast":ie,"event.kicked":{},"event.room_removed":{room_ref:E(!0)}};function ae(e){return p[e]||null}function ue(e){var t=String(e);if(!/^-?[0-9]+$/.test(t))return null;var r="-"===t.charAt(0),n=(r?t.slice(1):t).replace(/^0+/,"")||"0";return r&&"0"!==n?"-"+n:n}function ce(e){return"number"==typeof e?function(e){if(Number.isSafeInteger)return Number.isSafeInteger(e);return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e&&Math.abs(e)<=9007199254740991}(e)?ue(e):null:"bigint"==typeof e||e instanceof o.Int64Value||e&&"object"===(void 0===e?"undefined":n(e))&&"number"==typeof e.offset&&e.buffer&&"function"==typeof e.toString?ue(e.toString()):null}function fe(e,t){var r=ue(e),n=ue(t);if(null===r||null===n)throw new Error("integer comparison requires decimal integers");if(r===n)return 0;var o="-"===r.charAt(0),i="-"===n.charAt(0);if(o!==i)return o?-1:1;var s=o?r.slice(1):r,a=i?n.slice(1):n,u=void 0;return u=s.length!==a.length?s.length<a.length?-1:1:s<a?-1:1,o?-u:u}function le(e){for(var t=0,r=0;r<e.length;r+=1){var n=e.charCodeAt(r);if(n>=55296&&n<=56319){var o=e.charCodeAt(r+1);if(o<56320||o>57343)throw new i(200034,"string contains an unpaired surrogate");t+=4,r+=1}else{if(n>=56320&&n<=57343)throw new i(200034,"string contains an unpaired surrogate");t+=n<=127?1:n<=2047?2:3}}return t}function he(e,t){throw new i(200034,e+" "+t)}function de(e,t,r){if(null==e&&he(r,"must not be nil"),"integer"!==t.type)if("boolean"!==t.type){if("string"===t.type)return"string"!=typeof e&&he(r,"must be a UTF-8 string"),t.nonEmpty&&0===e.length&&he(r,"must not be empty"),t.enum&&-1===t.enum.indexOf(e)&&he(r,"is not an allowed value"),void(void 0!==t.maxBytes&&le(e)>t.maxBytes&&he(r,"exceeds "+t.maxBytes+" UTF-8 bytes"));if("string_or_bin"===t.type){if("string"==typeof e)return void(void 0!==t.maxBytes&&le(e)>t.maxBytes&&he(r,"exceeds "+t.maxBytes+" UTF-8 bytes"));var n=o.getByteView(e);return n||he(r,"must be a string or MsgPack bin value"),void(void 0!==t.maxBytes&&n.byteLength>t.maxBytes&&he(r,"exceeds "+t.maxBytes+" bytes"))}if("array"!==t.type){if("map"===t.type)return o.isPlainMap(e)||he(r,"must be a map"),void Object.keys(e).forEach((function(n){!function(e,t,r){if("string"!==t)if("positive_decimal_int64"!==t)he(r,"uses an unsupported map-key contract");else{var n=ue(e);(null===n||"-"===n.charAt(0)||"0"===n||fe(n,_)>0)&&he(r,"must be a positive decimal int64 map key")}}(n,t.key,r+"."+n),de(e[n],t.value,r+"."+n)}));if("tuple8"!==t.type)if("push_payload"!==t.type)he(r,"uses an unsupported value contract");else{if("string"==typeof e||o.getByteView(e))return;pe("Chat payload",e,oe)}else!function(e,t){Array.isArray(e)&&8===e.length||he(t,"must be an 8-item message tuple"),de(e[0],B,t+"[0]"),de(e[1],B,t+"[1]"),de(e[2],M,t+"[2]"),de(e[3],B,t+"[3]"),de(e[4],v("boolean",!1),t+"[4]"),de(e[5],L,t+"[5]"),de(e[6],D,t+"[6]"),de(e[7],B,t+"[7]")}(e,r)}else if(Array.isArray(e)||he(r,"must be an array"),void 0!==t.minItems&&e.length<t.minItems&&he(r,"must not be empty"),void 0!==t.maxItems&&e.length>t.maxItems&&he(r,"contains too many items"),e.forEach((function(e,n){de(e,t.element,r+"["+n+"]")})),void 0!==t.uniqueInt64Max){var i={};e.forEach((function(e){i[ce(e)]=!0})),Object.keys(i).length>t.uniqueInt64Max&&he(r,"contains too many distinct int64 items")}}else"boolean"!=typeof e&&he(r,"must be boolean");else!function(e,t,r){var n=ce(e);(null===n||fe(n,"-9223372036854775808")<0||fe(n,_)>0)&&he(r,"must be a signed int64 integer"),void 0!==t.min&&fe(n,t.min)<0&&he(r,"is below the allowed range"),void 0!==t.max&&fe(n,t.max)>0&&he(r,"is above the allowed range"),t.enum&&-1===t.enum.indexOf(n)&&he(r,"is not an allowed value"),t.messageKind&&!(fe(n,"1")>=0&&fe(n,"39")<=0||fe(n,"51")>=0&&fe(n,"127")<=0)&&he(r,"must be in kind ranges [1,39] or [51,127]")}(e,t,r)}function pe(e,t,r){o.isPlainMap(t)||he(e,"body must be a map"),Object.keys(t).forEach((function(t){Object.prototype.hasOwnProperty.call(r,t)||he(e+"."+t,"is not defined by this contract")})),Object.keys(r).forEach((function(n){var o=r[n];Object.prototype.hasOwnProperty.call(t,n)?de(t[n],o,e+"."+n):o.required&&he(e+"."+n,"is required")}))}function ge(e,t,r){for(var n=t[r[0]].length,o=1;o<r.length;o+=1)t[r[o]].length!==n&&he(e+" Answer",r.join(", ")+" must have matching lengths")}function ye(e){return g.has(e)||"string"==typeof e&&0===e.indexOf("imclient_")}e.exports={RELIABLE_PUSHES:y,REQUEST_SCHEMAS:Z,RESPONSE_SCHEMAS:ne,RESERVED_WIRES:g,ROUTES:p,TLVContractError:i,getRoute:ae,getRouteByUri:function(e){for(var t=Object.keys(p),r=0;r<t.length;r+=1){var n=p[t[r]];if(n.uri===e)return{method:t[r],route:n}}return null},isOneWayPush:function(e){return Object.prototype.hasOwnProperty.call(m,e)},isReliablePush:function(e){return Object.prototype.hasOwnProperty.call(y,e)},isReservedWire:ye,toWireRequest:function(e,t,r,n){var s=ae(e);if(!s){if(ye(e))throw new i(200020,e+" is reserved and unavailable on the TLV Client port");throw new i(20004,"unknown or unsupported TLV Client wire: "+e)}if(!o.isPlainMap(t))throw new i(200034,e+" request body must be a map");var a={};return Object.keys(t).forEach((function(e){var r=void 0;if("trace_id"!==e&&"send_ts"!==e){if("trace"===e||"sent_ms"===e)r=e;else if(Object.prototype.hasOwnProperty.call(s.request,e))r=s.request[e];else{if(-1===s.pass.indexOf(e))throw new i(200034,s.uri+" does not accept field "+e);r=e}if(Object.prototype.hasOwnProperty.call(a,r))throw new i(200034,s.uri+" received duplicate field mapping for "+r);n&&n.omitLegacyNil&&(void 0===t[e]||null===t[e])&&function(e,t){if("trace"===t||"sent_ms"===t)return!0;if(Object.prototype.hasOwnProperty.call(e.defaults,t))return!0;var r=Z[e.uri];return!(!r||!r[t]||r[t].required)}(s,r)||(a[r]=t[e])}})),Object.keys(s.defaults).forEach((function(e){Object.prototype.hasOwnProperty.call(a,e)||(a[e]=s.defaults[e])})),function(e,t,r){if(!t)return;var n="function"==typeof t?t():t;if(!n)return;if(!o.isPlainMap(n))throw new i(200034,r+" request metadata must be a map");["trace","sent_ms"].forEach((function(t){if(void 0!==n[t]){if(Object.prototype.hasOwnProperty.call(e,t)&&e[t]!==n[t])throw new i(200034,r+" has conflicting "+t+" values");e[t]=n[t]}}))}(a,r,s.uri),function(e,t){var r=Z[e.uri];if(!r)throw new i(200034,"missing request schema for "+e.uri);if(pe(e.uri+" request",t,r),"auth.login"===e.uri){var n=Object.prototype.hasOwnProperty.call(t,"auth_sec"),o=Object.prototype.hasOwnProperty.call(t,"auth_ver");if(n!==o)throw new i(200034,"auth.login requires auth_sec and auth_ver together");if(o&&"2"!==ce(t.auth_ver))throw new i(200034,"auth.login auth_ver must be 2")}}(s,a),{payload:a,uri:s.uri}},validateControlError:function(e){pe("control.error Answer",e,{reason:P(!0),status:w(!0)})},validatePush:function(e,t){var r=se[e];if(!r)throw new i(200034,"unsupported Push URI: "+e);pe(e+" Push",t,r)},validateResponse:function(e,t){var r=ne[e];if(!r)throw new i(200034,"unsupported Answer URI: "+e);r.allowEmpty&&o.isPlainMap(t)&&0===Object.keys(t).length||(pe(e+" Answer",t,r.fields),function(e,t){var r=void 0;if("conversation.direct"===e||"conversation.direct_unread"===e)r=["peers","badges","last_items"];else if("conversation.group"===e||"conversation.group_unread"===e)r=["group_refs","badges","last_items"];else if("conversation.unread"===e)return ge(e,t,["group_refs","group_badges","group_last"]),void ge(e,t,["peers","peer_badges","peer_last"]);r&&ge(e,t,r)}(e,t))}}},function(e,t,r){"use strict";var n=r(6),o=n.isValidFpnnEndpoint,i=n.normalizeFpnnEndpoint;e.exports={normalizeClientOptions:function(e){var t=Object.assign({},e||{});if(void 0===t.protocol&&(t.protocol="fpnn"),"fpnn"!==t.protocol&&"tlv-v1"!==t.protocol)throw new Error('options.protocol must be "fpnn" or "tlv-v1"');if("fpnn"===t.protocol){var r=void 0!==t.ssl_endpoint,n=r?t.ssl_endpoint:i(t.endpoint);if(!o(n))throw new Error("FPNN requires options.endpoint or options.ssl_endpoint as host[:port], without a URL scheme or path");r||(t.endpoint=n)}else{var s=t.tlvEndpoint||t.tlv_endpoint;if(!s&&"string"==typeof t.endpoint&&/^wss?:\/\//i.test(t.endpoint)&&(s=t.endpoint),!s&&"string"==typeof t.ssl_endpoint&&/^wss?:\/\//i.test(t.ssl_endpoint)&&(s=t.ssl_endpoint),"string"!=typeof s||!/^wss?:\/\//i.test(s))throw new Error("tlv-v1 requires options.tlvEndpoint as the deployment-provided ws:// or wss:// URL");t.tlvEndpoint=s}return t}}},function(e,t,r){"use strict";var n="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=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var s=r(2),a=r(0),u=r(5),c=r(1),f=c.Int64BE,l=c.Uint64BE,h=r(14),d=h.normalizeClientOptions,p=h.sharedEndpoint,g=r(15).getSharedWorkerConfigFallbackReason,y=r(16),m=r(17),_="__rtmSharedWorkerType__",v=function(){if("undefined"==typeof document)return null;if(document.currentScript&&document.currentScript.src)return document.currentScript.src;if("function"==typeof document.getElementsByTagName)for(var e=document.getElementsByTagName("script"),t=0;t<e.length;t++){var r=e[t];if(r&&r.src&&/\/rtm(?:\.min)?\.js(?:[?#]|$)/i.test(r.src))return r.src}return null}(),b=function(){function e(t){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);var n=t||{};if("undefined"==typeof SharedWorker)throw new Error("RTMSharedWorkerClient requires browser SharedWorker support");var o=function(e){if(null!=e&&""!==e){if("string"!=typeof e)throw new Error("RTMSharedWorkerClient workerUrl must be a string");return e}if(!v)throw new Error("RTMSharedWorkerClient could not infer workerUrl; serve rtm.shared-worker.js next to the SDK script or provide workerUrl");var t=void 0;try{t=new URL("rtm.shared-worker.js",v)}catch(e){throw new Error("RTMSharedWorkerClient could not resolve rtm.shared-worker.js beside the SDK script; provide workerUrl")}if("undefined"!=typeof window&&window.location&&t.origin!==window.location.origin)throw new Error("RTMSharedWorkerClient default worker URL is cross-origin; serve rtm.shared-worker.js from this page origin or provide a same-origin workerUrl");return t.href}(n.workerUrl),i=d(n.clientOptions);this._protocol=i.protocol;var a=g(i);if(a)throw new Error("RTMSharedWorkerClient cannot use "+a.replace(/^options/,"clientOptions")+"; use createClient() to run this configuration on the current page");var c,f=y(n.conversation),l=n.workerName||(void 0!==n.uid&&null!==n.uid?w({pid:i.pid,uid:n.uid,protocol:i.protocol,endpoint:p(i),namespace:n.workerNamespace}):"fpnn"===i.protocol?"rtm-shared-worker:fpnn":"rtm-shared-worker"),h=void 0===n.idleShutdownTimeout?5e3:n.idleShutdownTimeout;if(!("number"==typeof(c=h)&&isFinite(c)&&c>=0))throw new Error("RTMSharedWorkerClient idleShutdownTimeout must be a non-negative number");if(this._listeners=Object.create(null),this._processorListeners=Object.create(null),this._callbackSeq=0,this._callbacks=new Map,this._destroyed=!1,this._destroying=!1,this._failedError=null,this._conversation=f,this.promises=u(this,s.prototype),this._pageWindow="undefined"!=typeof window&&window.addEventListener?window:null,this._pageHideListener=function(e){e&&e.persisted||r.destroy()},this._session={status:"idle",uid:null},this._readySettled=!1,this._readyPromise=new Promise((function(e,t){r._resolveReady=e,r._rejectReady=t})),this._readyPromise.catch((function(){})),this._worker=new SharedWorker(o,l),this._worker.onerror=this._onWorkerError.bind(this),this._port=this._worker.port,this._pageWindow&&this._pageWindow.addEventListener("pagehide",this._pageHideListener),this._port.onmessage=this._onMessage.bind(this),this._port.onmessageerror=this._onMessageError.bind(this),"function"==typeof this._port.start&&this._port.start(),this._post({type:"init",options:i,idleShutdownTimeout:h})){var m=function(e){return"number"==typeof e&&isFinite(e)&&e>0}(n.readyTimeout)?n.readyTimeout:1e4;this._readyTimer=setTimeout((function(){var e=C("Timed out waiting for the RTM SharedWorker to initialize","RTM_SHARED_WORKER_READY_TIMEOUT");r._failedError=e;var t=r._failPendingCallbacks(e);r._settleReady(e);try{r._emit(r._listeners,"SharedWorkerError",[e])}finally{r.destroy()}if(t)throw t.error}),m)}else this._settleReady(new Error("Failed to initialize the RTM SharedWorker client")),this.destroy();var _=this;this.processor={on:function(e,t){return _._addListener(_._processorListeners,e,t),this},off:function(e,t){return _._removeListener(_._processorListeners,e,t),this},removeEvent:function(e,t){return 0===arguments.length?_._processorListeners=Object.create(null):_._removeListener(_._processorListeners,e,t),this},emit:function(e){_._emit(_._processorListeners,e,Array.prototype.slice.call(arguments,1))},listenerCount:function(e){return(_._processorListeners[e]||[]).length}}}return o(e,[{key:"on",value:function(e,t){return this._addListener(this._listeners,e,t),this}},{key:"off",value:function(e,t){return this._removeListener(this._listeners,e,t),this}},{key:"emit",value:function(e){this._emit(this._listeners,e,Array.prototype.slice.call(arguments,1))}},{key:"listenerCount",value:function(e){return(this._listeners[e]||[]).length}},{key:"removeEvent",value:function(e,t){return 0===arguments.length?this._listeners=Object.create(null):this._removeListener(this._listeners,e,t),this}},{key:"whenReady",value:function(){return this._readyPromise.then(k)}},{key:"getSharedSession",value:function(){return k(this._session)}},{key:"loginIfNeeded",value:function(e,t,r){var n=this;return this.whenReady().then((function(){if(n._destroyed||n._destroying)throw new Error("RTMSharedWorkerClient has been destroyed");return new Promise((function(o,i){var s=++n._callbackSeq,a=function(e){e instanceof Error?i(e):o(e)};a.rejectOnDestroy=!0,n._callbacks.set(s,a);var u=R(e,n._callbacks,n);n._post({type:"login-if-needed",uid:u,credential:t,timeout:r,requestId:s})||(n._callbacks.delete(s),i(new Error("Failed to request shared RTM login")))}))}))}},{key:"setConversation",value:function(e,t){var r=y(e);if(this._destroyed||this._destroying){var n=new Error("RTMSharedWorkerClient has been destroyed");return"function"==typeof t&&t(n),this._emit(this._listeners,"SharedWorkerError",[n]),this}return this._conversation=r,"function"==typeof t&&t(null),this}},{key:"destroy",value:function(){if(!this._destroyed&&!this._destroying){this._destroying=!0;var e=null,t=null;try{this._settleReady(new Error("RTMSharedWorkerClient was destroyed before it became ready"));var r=new Error("RTMSharedWorkerClient was destroyed before the shared login completed");e=this._failPendingCallbacks(r)}finally{try{this._post({type:"detach"},!0)}catch(e){t=e}if(this._destroyed=!0,this._destroying=!1,this._callbacks.clear(),this._listeners=Object.create(null),this._processorListeners=Object.create(null),this._pageWindow&&this._pageHideListener)try{this._pageWindow.removeEventListener("pagehide",this._pageHideListener)}catch(e){t=t||e}this._pageWindow=null,this._pageHideListener=null,this._worker.onerror=null,this._port.onmessage=null,this._port.onmessageerror=null;try{this._port.close()}catch(e){t=t||e}}if(t)throw t;if(e)throw e.error}}},{key:"_addListener",value:function(e,t,r){"function"==typeof r&&(e[t]||(e[t]=[]),-1===e[t].indexOf(r)&&e[t].push(r))}},{key:"_removeListener",value:function(e,t,r){e[t]&&(void 0!==r?(e[t]=e[t].filter((function(e){return e!==r})),0===e[t].length&&delete e[t]):delete e[t])}},{key:"_emit",value:function(e,t,r){(e[t]||[]).slice().forEach((function(e){e.apply(null,r)}))}},{key:"_onMessage",value:function(e){var t=e&&e.data;if(t&&!this._destroyed)if("callback"!==t.type)if("event"!==t.type)if("login-result"!==t.type)if("error"!==t.type){if("ready"===t.type){var r=E(t.session);return this._session=r,this._settleReady(null,r),void this._emit(this._listeners,"SharedWorkerReady",[r])}"session-state"===t.type&&(this._session=E(t.session),this._emit(this._listeners,"SharedSessionState",[k(this._session)]))}else{var n=O(t.error,a),o=null;if(void 0!==t.requestId){var i=this._callbacks.get(t.requestId);i&&(this._callbacks.delete(t.requestId),i(n))}else this._failedError=n,o=this._failPendingCallbacks(n);try{this._settleReady(n),this._emit(this._listeners,"SharedWorkerError",[n])}finally{!0===t.fatal&&this.destroy()}if(o)throw o.error}else{var s=this._callbacks.get(t.requestId);s&&(this._callbacks.delete(t.requestId),s(t.error?O(t.error,a):t.result))}else{var u=O(t.args,a);if("processor"===t.channel&&!m(this._conversation,this._protocol,t.name,u[0]))return;this._emit("processor"===t.channel?this._processorListeners:this._listeners,t.name,u)}else{var c=this._callbacks.get(t.callbackId);c&&(this._callbacks.delete(t.callbackId),c.apply(null,O(t.args,a)))}}},{key:"_onMessageError",value:function(e){var t=new Error("Failed to read a SharedWorker message");t.code="RTM_SHARED_WORKER_MESSAGE_ERROR",t.event=e,this._failedError=t;var r=this._failPendingCallbacks(t);this._settleReady(t);try{this._emit(this._listeners,"SharedWorkerError",[t])}finally{this.destroy()}if(r)throw r.error}},{key:"_onWorkerError",value:function(e){var t=new Error(e&&e.message?"RTM SharedWorker failed to load: "+e.message:"RTM SharedWorker failed to load");t.code="RTM_SHARED_WORKER_LOAD_ERROR",e&&e.filename&&(t.filename=e.filename),e&&e.lineno&&(t.lineno=e.lineno),this._failedError=t;var r=this._failPendingCallbacks(t);this._settleReady(t);try{this._emit(this._listeners,"SharedWorkerError",[t])}finally{this.destroy()}if(r)throw r.error}},{key:"_failPendingCallbacks",value:function(e){var t=this,r=null;return this._callbacks.forEach((function(n,o){if("function"==typeof n.fail||n.rejectOnDestroy){t._callbacks.delete(o);try{"function"==typeof n.fail?n.fail(e):n(e)}catch(e){r||(r={error:e})}}})),r}},{key:"_invoke",value:function(e,t){if(this._destroyed||this._destroying){var r=C("RTMSharedWorkerClient has been destroyed","RTM_SHARED_CLIENT_DESTROYED");return P(e,t,r),void this._emit(this._listeners,"SharedWorkerError",[r])}if(this._failedError)P(e,t,this._failedError);else{var n=this._callbackSeq;this._post({type:"invoke",method:e,args:R(t,this._callbacks,this,e)})||this._failCallbacksSince(n,this._failedError||C("Failed to send request to RTM SharedWorker","RTM_SHARED_WORKER_POST_MESSAGE_ERROR"))}}},{key:"_failCallbacksSince",value:function(e,t){var r=this;this._callbacks.forEach((function(n,o){o<=e||(r._callbacks.delete(o),"function"==typeof n.fail&&n.fail(t))}))}},{key:"_post",value:function(e,t){var r=t&&e&&"detach"===e.type;if((this._destroyed||this._destroying)&&!r)return!1;if(this._failedError&&!r)return!1;try{return this._port.postMessage(e),!0}catch(e){return this._emit(this._listeners,"SharedWorkerError",[e]),!1}}},{key:"_settleReady",value:function(e,t){this._readySettled||(this._readySettled=!0,void 0!==this._readyTimer&&(clearTimeout(this._readyTimer),this._readyTimer=void 0),e?this._rejectReady(e):this._resolveReady(k(t)))}}]),e}();function w(e){if(!e||"object"!==(void 0===e?"undefined":n(e)))throw new Error("createSharedWorkerName requires { pid, uid }");var t=void 0===e.pid||null===e.pid?"":String(e.pid).trim(),r=void 0===e.uid||null===e.uid?"":String(e.uid).trim();if(!t||!r)throw new Error("createSharedWorkerName requires non-empty pid and uid");var o=void 0===e.protocol?"fpnn":e.protocol;if("tlv-v1"!==o&&"fpnn"!==o)throw new Error('createSharedWorkerName protocol must be "tlv-v1" or "fpnn"');var i=[String(void 0===e.namespace||null===e.namespace?"":e.namespace),t,r,String(void 0===e.endpoint||null===e.endpoint?"":e.endpoint)];return"fpnn"===o&&i.unshift(o),"rtm-shared:"+i.map((function(e){var t=encodeURIComponent(e);return t.length+":"+t})).join("|")}function E(e){if(!e||"object"!==(void 0===e?"undefined":n(e)))return{status:"idle",uid:null};var t=["idle","connecting","authenticated"].indexOf(e.status)>=0?e.status:"idle";return{status:t,uid:"idle"===t||void 0===e.uid||null===e.uid?null:String(e.uid)}}function k(e){return{status:e.status,uid:e.uid}}function R(e,t,r,o){if("function"==typeof e){var s=++r._callbackSeq,u=function(){return e.apply(null,arguments)};return u.fail=function(t){"login"===o?e(!1,t.status||a.ERROR_CODE.RTM_EC_UNKNOWN_ERROR):e(t,null)},t.set(s,u),i({},"__rtmSharedWorkerCallback__",s)}if(e&&"object"===(void 0===e?"undefined":n(e))){var c,h;if(f.isInt64BE(e))return i(c={},_,"int64"),i(c,"value",e.toString()),c;if(l.isUint64BE(e))return i(h={},_,"uint64"),i(h,"value",e.toString()),h;if(Array.isArray(e))return e.map((function(e){return R(e,t,r,o)}));if(T(e)){var d={};return Object.keys(e).forEach((function(n){d[n]=R(e[n],t,r,o)})),d}}return e}function P(e,t,r){(t||[]).forEach((function(t){"function"==typeof t&&("login"===e?t(!1,r.status||a.ERROR_CODE.RTM_EC_UNKNOWN_ERROR):t(r,null))}))}function C(e,t){var r=new Error(e);return r.code=t,r}function O(e,t){if(Array.isArray(e))return e.map((function(e){return O(e,t)}));if(!T(e))return e;if("int64"===e[_])return t.Int64(e.value);if("uint64"===e[_])return t.Uint64(e.value);if("error"===e[_]){var r=new Error(e.message||"SharedWorker error");return r.name=e.name||"Error",void 0!==e.code&&(r.code=e.code),void 0!==e.status&&(r.status=e.status),void 0!==e.reason&&(r.reason=e.reason),e.stack&&(r.stack=e.stack),r}var n={};return Object.keys(e).forEach((function(r){n[r]=O(e[r],t)})),n}function T(e){if(null===e||"object"!==(void 0===e?"undefined":n(e)))return!1;var t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}b.createWorkerName=w,Object.getOwnPropertyNames(s.prototype).forEach((function(e){"constructor"===e||"destroy"===e||"_"===e.charAt(0)||Object.prototype.hasOwnProperty.call(b.prototype,e)||"function"==typeof Object.getOwnPropertyDescriptor(s.prototype,e).value&&Object.defineProperty(b.prototype,e,{configurable:!0,enumerable:!1,writable:!0,value:function(){return this._invoke(e,Array.prototype.slice.call(arguments))}})})),e.exports=b},function(e,t,r){"use strict";var n=r(12).normalizeClientOptions,o=r(6).normalizeFpnnEndpoint;e.exports={normalizeClientOptions:n,sharedEndpoint:function(e){return"tlv-v1"===e.protocol?e.tlvEndpoint||e.tlv_endpoint||e.endpoint||e.ssl_endpoint:void 0!==e.ssl_endpoint?"wss://"+e.ssl_endpoint+"/service/websocket":"ws://"+o(e.endpoint)+"/service/websocket"}}},function(e,t,r){"use strict";var n="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};e.exports={getSharedWorkerConfigFallbackReason:function(e){var t=new Set;return function e(r,o){if("function"==typeof r)return o+" is a function; SharedWorker cannot preserve page-side function behavior";if("symbol"===(void 0===r?"undefined":n(r)))return o+" is a symbol and cannot be transferred to SharedWorker";if("bigint"==typeof r)return o+" is a bigint that cannot be compared safely between shared pages";if("number"==typeof r&&!isFinite(r))return o+" is not a finite number and cannot be compared safely between shared pages";if(null==r||"object"!==(void 0===r?"undefined":n(r)))return null;if(t.has(r))return o+" contains a circular reference that cannot be compared safely between shared pages";var i=void 0,s=void 0;try{i=Array.isArray(r),s=Object.getPrototypeOf(r)}catch(e){return o+" cannot be inspected for SharedWorker transfer"}if(i?s!==Array.prototype:s!==Object.prototype&&null!==s)return o+" uses a custom object prototype; SharedWorker cannot preserve its behavior";var a=void 0;try{a=Object.getOwnPropertySymbols(r)}catch(e){return o+" cannot be inspected for SharedWorker transfer"}if(a.length)return o+" contains symbol-keyed data that cannot be transferred reliably";t.add(r);var u=void 0;try{u=Object.keys(r)}catch(e){return t.delete(r),o+" cannot be inspected for SharedWorker transfer"}for(var c=0;c<u.length;c+=1){var f=u[c],l=void 0;try{l=Object.getOwnPropertyDescriptor(r,f)}catch(e){return t.delete(r),o+"."+f+" cannot be inspected for SharedWorker transfer"}if(!l||l.get||l.set)return t.delete(r),o+"."+f+" uses an accessor that cannot be preserved in SharedWorker";var h=i?o+"["+f+"]":o+"."+f,d=void 0;try{d=r[f]}catch(e){return t.delete(r),h+" cannot be inspected for SharedWorker transfer"}var p=e(d,h);if(p)return t.delete(r),p}return t.delete(r),null}(e,"options")}}},function(e,t,r){"use strict";var n="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=r(1),i=o.Int64BE,s=o.Uint64BE;e.exports=function(e){if(null==e)return null;if(!function(e){if(null===e||"object"!==(void 0===e?"undefined":n(e)))return!1;var t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(e)||-1===["direct","group","room"].indexOf(e.type))throw new Error('conversation.type must be "direct", "group", or "room"');var t=e.id,r=void 0;if("string"==typeof t)r=t;else if("number"==typeof t&&function(e){if(Number.isSafeInteger)return Number.isSafeInteger(e);return isFinite(e)&&Math.floor(e)===e&&Math.abs(e)<=9007199254740991}(t))r=String(t);else{if(!("bigint"==typeof t||t&&(i.isInt64BE(t)||s.isUint64BE(t))))throw new Error("conversation.id must be a positive int64 string, safe integer, or RTMConfig.Int64");r=t.toString()}if(!/^\d+$/.test(r)||/^0+$/.test(r))throw new Error("conversation.id must be a positive int64");if((r=r.replace(/^0+(?=\d)/,"")).length>19||19===r.length&&r>"9223372036854775807")throw new Error("conversation.id exceeds the positive int64 range");return{type:e.type,id:r}}},function(e,t,r){"use strict";var n=r(0),o={"tlv-v1":{},fpnn:{}};function i(e,t,r,n){t.forEach((function(t){o[e][t]={type:r,field:n}}))}var s=n.TLV_SERVER_PUSH;i("tlv-v1",[s.recvMessage],"direct","sender"),i("tlv-v1",[s.recvGroupMessage],"group","group_ref"),i("tlv-v1",[s.recvRoomMessage,s.kickOutRoom],"room","room_ref");var a=n.SERVER_PUSH;i("fpnn",[a.recvMessage,a.recvChat,a.recvAudio,a.recvCmd,a.recvFile],"direct","from"),i("fpnn",[a.recvGroupMessage,a.recvGroupChat,a.recvGroupAudio,a.recvGroupCmd,a.recvGroupFile],"group","gid"),i("fpnn",[a.recvRoomMessage,a.recvRoomChat,a.recvRoomAudio,a.recvRoomCmd,a.recvRoomFile,a.kickOutRoom],"room","rid"),e.exports=function(e,t,r,n){if(!e)return!0;var i=o[t],s=i&&Object.prototype.hasOwnProperty.call(i,r)?i[r]:null;if(!s)return!0;var a=n&&n[s.field];return e.type===s.type&&String(a)===e.id}},function(e,t,r){"use strict";var n=r(2),o=r(13),i=r(28),s=o.createWorkerName,a=r(0),u=r(8),c=r(10),f=r(9);e.exports={RTMClient:n,createClient:i,RTMSharedWorkerClient:o,createSharedWorkerName:s,RTMConfig:a,RTMProcessor:u,TLVCodec:c,TLVWebSocketClient:f}},function(e,t,r){"use strict";t.byteLength=function(e){var t=c(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){var t,r,n=c(e),s=n[0],a=n[1],u=new i(function(e,t,r){return 3*(t+r)/4-r}(0,s,a)),f=0,l=a>0?s-4:s;for(r=0;r<l;r+=4)t=o[e.charCodeAt(r)]<<18|o[e.charCodeAt(r+1)]<<12|o[e.charCodeAt(r+2)]<<6|o[e.charCodeAt(r+3)],u[f++]=t>>16&255,u[f++]=t>>8&255,u[f++]=255&t;2===a&&(t=o[e.charCodeAt(r)]<<2|o[e.charCodeAt(r+1)]>>4,u[f++]=255&t);1===a&&(t=o[e.charCodeAt(r)]<<10|o[e.charCodeAt(r+1)]<<4|o[e.charCodeAt(r+2)]>>2,u[f++]=t>>8&255,u[f++]=255&t);return u},t.fromByteArray=function(e){for(var t,r=e.length,o=r%3,i=[],s=0,a=r-o;s<a;s+=16383)i.push(f(e,s,s+16383>a?a:s+16383));1===o?(t=e[r-1],i.push(n[t>>2]+n[t<<4&63]+"==")):2===o&&(t=(e[r-2]<<8)+e[r-1],i.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a<u;++a)n[a]=s[a],o[s.charCodeAt(a)]=a;function c(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function f(e,t,r){for(var o,i,s=[],a=t;a<r;a+=3)o=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),s.push(n[(i=o)>>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return s.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},function(e,t){
|
|
9
|
+
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
10
|
+
t.read=function(e,t,r,n,o){var i,s,a=8*o-n-1,u=(1<<a)-1,c=u>>1,f=-7,l=r?o-1:0,h=r?-1:1,d=e[t+l];for(l+=h,i=d&(1<<-f)-1,d>>=-f,f+=a;f>0;i=256*i+e[t+l],l+=h,f-=8);for(s=i&(1<<-f)-1,i>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=h,f-=8);if(0===i)i=1-c;else{if(i===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),i-=c}return(d?-1:1)*s*Math.pow(2,i-n)},t.write=function(e,t,r,n,o,i){var s,a,u,c=8*i-o-1,f=(1<<c)-1,l=f>>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:i-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,o),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,o),s=0));o>=8;e[r+d]=255&a,d+=p,a/=256,o-=8);for(s=s<<o|a,c+=o;c>0;e[r+d]=255&s,d+=p,s/=256,c-=8);e[r+d-p]|=128*g}},function(e,t){var r={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},function(e,t,r){"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self&&self,e.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=8)}([function(e,t,r){"use strict";var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),o=r(10).Buffer,i={FPNN_EC_OK:0,FPNN_EC_PROTO_UNKNOWN_ERROR:10001,FPNN_EC_PROTO_NOT_SUPPORTED:10002,FPNN_EC_PROTO_INVALID_PACKAGE:10003,FPNN_EC_PROTO_JSON_CONVERT:10004,FPNN_EC_PROTO_STRING_KEY:10005,FPNN_EC_PROTO_MAP_VALUE:10006,FPNN_EC_PROTO_METHOD_TYPE:10007,FPNN_EC_PROTO_PROTO_TYPE:10008,FPNN_EC_PROTO_KEY_NOT_FOUND:10009,FPNN_EC_PROTO_TYPE_CONVERT:10010,FPNN_EC_CORE_UNKNOWN_ERROR:20001,FPNN_EC_CORE_CONNECTION_CLOSED:20002,FPNN_EC_CORE_TIMEOUT:20003,FPNN_EC_CORE_UNKNOWN_METHOD:20004,FPNN_EC_CORE_ENCODING:20005,FPNN_EC_CORE_DECODING:20006,FPNN_EC_CORE_SEND_ERROR:20007,FPNN_EC_CORE_RECV_ERROR:20008,FPNN_EC_CORE_INVALID_PACKAGE:20009,FPNN_EC_CORE_HTTP_ERROR:20010,FPNN_EC_CORE_WORK_QUEUE_FULL:20011,FPNN_EC_CORE_INVALID_CONNECTION:20012,FPNN_EC_CORE_FORBIDDEN:20013,FPNN_EC_CORE_SERVER_STOPPING:20014},s=o.from([0,1]),a=o.from([64,128]),u=o.from([0,1,2]),c=o.from("FPNN"),f=o.from("POST"),l=["secp256k1","secp224r1"],h=["aes-128-cfb","aes-256-cfb"],d=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return n(e,null,[{key:"SDK_VERSION",get:function(){return"2.0.0"}},{key:"BUFFER",get:function(){return o}},{key:"ERROR_CODE",get:function(){return i}},{key:"FP_FLAG",get:function(){return a}},{key:"FP_MESSAGE_TYPE",get:function(){return u}},{key:"TCP_MAGIC",get:function(){return c}},{key:"HTTP_MAGIC",get:function(){return f}},{key:"FPNN_VERSION",get:function(){return s}},{key:"READ_BUFFER_LEN",get:function(){return 1024}},{key:"CHECK_CBS_INTERVAL",get:function(){return 1e3}},{key:"SEND_TIMEOUT",get:function(){return 2e4}},{key:"CRYPTO_CURVES",get:function(){return l}},{key:"CRYPTO_ALGORITHM",get:function(){return h}}]),e}();e.exports=d},function(e,t,r){"use strict";var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),o=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return n(e,null,[{key:"assign",value:function(e){if(!e||e.hasOwnProperty("events"))throw new Error(e+" is null or hasOwnProperty [ events ]");if(e.hasOwnProperty("on")||e.hasOwnProperty("emit")||e.hasOwnProperty("removeEvent"))throw new Error(e+" hasOwnProperty [ on | emit | removeEvent | listenerCount]");e.events={},e.on=function(t,r){e.events.hasOwnProperty(t)||(e.events[t]=[]),-1==e.events[t].indexOf(r)&&e.events[t].push(r)},e.emit=function(){if(0!=arguments.length)for(var t=e.events[arguments[0]]||[],r=0;r<t.length;r++){var n=t[r];if(n){for(var o=[],i=1;i<arguments.length;i++)o[i-1]=arguments[i];n.apply(e,o)}}},e.removeEvent=function(){if(0!=arguments.length)if(1!=arguments.length){var t=arguments[0],r=e.events[t].indexOf(arguments[1]);r>-1&&e.events[t].splice(r,1)}else{var n=arguments[0];e.events.hasOwnProperty(n)&&delete e.events[n]}else e.events={}},e.listenerCount=function(t){return e.events.hasOwnProperty(t)?(e.events[t]||[]).length:0}}}]),e}();e.exports=o},function(e,t,r){"use strict";function n(e,t){this.code=e,this.name="FPError",this.message=t.message||"",this.stack=t.stack,this.error=t}n.prototype=Object.create(Error.prototype),n.prototype.toString=function(){return"code: "+this.code+" ex: "+this.message},e.exports=n},function(e,t,r){"use strict";var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();r(0);var o=r(1),i=r(4),s=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),o.assign(this),this._endpoint=t.endpoint||null,this._timeout=t.connectionTimeout||1e4,this._platform=t.platformImpl||new i,this._connectTimeout=0,this._queue=[];var r=this;o.assign(this._platform),this._platform.on("open",(function(){c.call(r)})),this._platform.on("message",(function(e){u.call(r,e)})),this._platform.on("close",(function(){f.call(r)})),this._platform.on("error",(function(e){l.call(r,e)}))}return n(e,[{key:"write",value:function(e){if(e)if("[object String]"===Object.prototype.toString.call(e))this._queue.push(e);else{var t=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);this._queue.push(t)}a.call(this)}},{key:"close",value:function(e){e&&this.emit("error",e),this._platform.close()}},{key:"open",value:function(){if(this.isConnecting||this.isOpen||!this._endpoint)this.emit("error",new Error("has connected or worng endpoint!"));else{var e=this;this._connectTimeout&&(clearTimeout(this._connectTimeout),this._connectTimeout=0),this._connectTimeout=setTimeout((function(){var t=new Error("connect timeout!");if(e.isOpen)e.close(t);else{if(e.isConnecting)return e.close(t),void f.call(e);l.call(e,t),f.call(e)}}),this._timeout),this._platform.open(this._endpoint)}}},{key:"destroy",value:function(){this.removeEvent(),this.close(),this._platform.removeEvent(),f.call(this)}},{key:"endpoint",get:function(){return this._endpoint}},{key:"isOpen",get:function(){return this._platform.isOpen}},{key:"isConnecting",get:function(){return this._platform.isConnecting}}]),e}();function a(){if(this.isOpen)for(;this._queue.length;)this._platform.send(this._queue.shift())}function u(e){this.emit("data",e)}function c(){this._connectTimeout&&(clearTimeout(this._connectTimeout),this._connectTimeout=0),a.call(this),this.emit("connect")}function f(){this._connectTimeout&&(clearTimeout(this._connectTimeout),this._connectTimeout=0),this._queue=[],this.emit("close")}function l(e){this.emit("error",e)}e.exports=s},function(e,t,r){"use strict";var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),o=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._socket=null}return n(e,[{key:"open",value:function(e){var t=this;try{this._socket=new WebSocket(e)}catch(e){return void this.emit("error",e)}this._socket.binaryType="arraybuffer",this._socket.onopen=function(e){t.emit("open")},this._socket.onmessage=function(e){t.emit("message",e.data)},this._socket.onclose=function(e){t.emit("close")},this._socket.onerror=function(e){t.emit("error",e)}}},{key:"send",value:function(e){try{this._socket.send(e)}catch(e){return void this.emit("error",e)}}},{key:"close",value:function(){this._socket&&this._socket.close()}},{key:"isOpen",get:function(){return!!this._socket&&this._socket.readyState==WebSocket.OPEN}},{key:"isConnecting",get:function(){return!!this._socket&&this._socket.readyState==WebSocket.CONNECTING}}]),e}();e.exports=o},function(e,t,r){"use strict";var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),o=r(0),i=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return n(e,[{key:"buildPkgData",value:function(e){var t={};return t.magic=e.magic||o.TCP_MAGIC,t.version=e.version||0,t.flag=e.flag||0,t.mtype=e.mtype||0,t.ss=e.ss||0,t.method=e.method||null,t.seq=e.seq||0,t.payload=e.payload||null,t.payload&&(t.psize=o.BUFFER.byteLength(t.payload)),t.method&&(t.ss=o.BUFFER.byteLength(t.method)),t.wpos=0,t}},{key:"cbKey",value:function(e){return e.magic+"_"+e.seq}},{key:"isHTTP",value:function(e){return o.HTTP_MAGIC.equals(e.magic)}},{key:"isTCP",value:function(e){return o.TCP_MAGIC.equals(e.magic)}},{key:"isMsgPack",value:function(e){return 1==e.flag}},{key:"isJson",value:function(e){return 0==e.flag}},{key:"isOneWay",value:function(e){return 0==e.mtype}},{key:"isTwoWay",value:function(e){return 1==e.mtype}},{key:"isQuest",value:function(e){return this.isTwoWay(e)||this.isOneWay(e)}},{key:"isAnswer",value:function(e){return 2==e.mtype}},{key:"isSupportPack",value:function(e){return this.isMsgPack(e)!=this.isJson(e)}},{key:"enCode",value:function(e){return this.isOneWay(e)?this.enCodeOneway(e):this.isTwoWay(e)?this.enCodeTwoway(e):this.isAnswer(e)?this.enCodeAnswer(e):null}},{key:"enCodeOneway",value:function(e){var t=s.call(this,e,12+e.ss+e.psize);e.wpos=t.writeUInt8(e.ss,e.wpos),e.wpos=t.writeUInt32LE(e.psize,e.wpos);var r=o.BUFFER.from(e.method);if(e.wpos+=r.copy(t,e.wpos,0),this.isJson(e)){var n=o.BUFFER.from(e.payload);e.wpos+=n.copy(t,e.wpos,0)}return this.isMsgPack(e)&&(this.wpos+=this.payload.copy(t,this.wpos,0)),t}},{key:"enCodeTwoway",value:function(e){var t=s.call(this,e,16+e.ss+e.psize);e.wpos=t.writeUInt8(e.ss,e.wpos),e.wpos=t.writeUInt32LE(e.psize,e.wpos),e.wpos=t.writeUInt32LE(e.seq,e.wpos);var r=o.BUFFER.from(e.method);if(e.wpos+=r.copy(t,e.wpos,0),this.isJson(e)){var n=o.BUFFER.from(e.payload);e.wpos+=n.copy(t,e.wpos,0)}return this.isMsgPack(e)&&(e.wpos+=e.payload.copy(t,e.wpos,0)),t}},{key:"enCodeAnswer",value:function(e){var t=s.call(this,e,16+e.psize);if(e.wpos=t.writeUInt8(e.ss,e.wpos),e.wpos=t.writeUInt32LE(e.psize,e.wpos),e.wpos=t.writeUInt32LE(e.seq,e.wpos),this.isJson(e)){var r=o.BUFFER.from(e.payload);e.wpos+=r.copy(t,e.wpos,0)}return this.isMsgPack(e)&&(e.wpos+=e.payload.copy(t,e.wpos,0)),t}},{key:"peekHead",value:function(e){var t={},r=0,n=o.BUFFER.allocUnsafe(4);return r+=e.copy(n,0,r,r+4),t.magic=n,n=o.BUFFER.allocUnsafe(1),r+=e.copy(n,0,r,r+1),t.version=o.FPNN_VERSION.indexOf(n),r+=e.copy(n,0,r,r+1),t.flag=o.FP_FLAG.indexOf(n),r+=e.copy(n,0,r,r+1),t.mtype=o.FP_MESSAGE_TYPE.indexOf(n),r+=e.copy(n,0,r,r+1),t.ss=n.readUInt8(0),t.psize=e.readUInt32LE(r),t.wpos=r+4,t}},{key:"deCode",value:function(e){var t=this.peekHead(e);return this.isOneWay(t)&&this.deCodeOneWay(e,t),this.isTwoWay(t)&&this.deCodeTwoWay(e,t),this.isAnswer(t)&&this.deCodeAnswer(e,t),t}},{key:"deCodeOneWay",value:function(e,t){if(e.length==12+t.ss+t.psize){var r=o.BUFFER.allocUnsafe(t.ss);t.wpos+=e.copy(r,0,t.wpos,t.wpos+t.ss),t.method=r.toString();var n=o.BUFFER.allocUnsafe(t.psize);t.wpos+=e.copy(n,0,t.wpos),this.isJson(t)&&(t.payload=n.toString()),this.isMsgPack(t)&&(t.payload=n)}else t=null}},{key:"deCodeTwoWay",value:function(e,t){if(e.length==16+t.ss+t.psize){t.seq=e.readUInt32LE(t.wpos),t.wpos+=4;var r=o.BUFFER.allocUnsafe(t.ss);t.wpos+=e.copy(r,0,t.wpos,t.wpos+t.ss),t.method=r.toString();var n=o.BUFFER.allocUnsafe(t.psize);t.wpos+=e.copy(n,0,t.wpos),this.isJson(t)&&(t.payload=n.toString()),this.isMsgPack(t)&&(t.payload=n)}else t=null}},{key:"deCodeAnswer",value:function(e,t){if(e.length==16+t.psize){t.seq=e.readUInt32LE(t.wpos),t.wpos+=4;var r=o.BUFFER.allocUnsafe(t.psize);t.wpos+=e.copy(r,0,t.wpos),this.isJson(t)&&(t.payload=r.toString()),this.isMsgPack(t)&&(t.payload=r)}else t=null}}]),e}();function s(e,t){var r=o.BUFFER.allocUnsafe(t);return this.isHTTP(e)&&(e.wpos+=o.HTTP_MAGIC.copy(r,e.wpos,0)),this.isTCP(e)&&(e.wpos+=o.TCP_MAGIC.copy(r,e.wpos,0)),e.wpos+=o.FPNN_VERSION.copy(r,e.wpos,e.version,e.version+1),this.isJson(e)&&(e.wpos+=o.FP_FLAG.copy(r,e.wpos,e.flag,e.flag+1)),this.isMsgPack(e)&&(e.wpos+=o.FP_FLAG.copy(r,e.wpos,e.flag,e.flag+1)),e.wpos+=o.FP_MESSAGE_TYPE.copy(r,e.wpos,e.mtype,e.mtype+1),r}e.exports=i},function(e,t,r){"use strict";var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),o=r(0),i=r(2),s=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._cbMap={},this._exMap={},a.call(this)}return n(e,[{key:"addCb",value:function(e,t,r){this._cbMap.hasOwnProperty(e)||(this._cbMap[e]=t),r||(r=o.SEND_TIMEOUT),this._exMap[e]=r+Date.now()}},{key:"removeCb",value:function(e){if(e)f.call(this,e);else for(var t in this._cbMap)u.call(this,t,new i(o.ERROR_CODE.FPNN_EC_CORE_CONNECTION_CLOSED,new Error("Connection Closed")))}},{key:"execCb",value:function(e,t){u.call(this,e,t)}}]),e}();function a(){var e=this;setInterval((function(){for(var t in e._exMap)e._exMap[t]>Date.now()||u.call(e,t,new i(o.ERROR_CODE.FPNN_EC_CORE_TIMEOUT,Error("Timeout")))}),o.CHECK_CBS_INTERVAL)}function u(e,t){var r=this;setTimeout((function(){c.call(r,e,t)}),0)}function c(e,t){if(this._cbMap.hasOwnProperty(e)){var r=this._cbMap[e];l.call(this,e),r&&r(t)}}function f(e){var t=this;setTimeout((function(){l.call(t,e)}),0)}function l(e){this._cbMap.hasOwnProperty(e)&&delete this._cbMap[e],this._exMap.hasOwnProperty(e)&&delete this._exMap[e]}e.exports=s},function(e,t,r){"use strict";var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),o=r(1),i=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),o.assign(this)}return n(e,[{key:"service",value:function(e,t){this.emit(e.method,e.payload,t)}},{key:"destroy",value:function(){}}]),e}();e.exports=i},function(e,t,r){"use strict";var n=r(9),o=r(0),i=r(1),s=r(3),a=r(5),u=r(6),c=r(7),f=r(2),l=r(4),h=r(13);e.exports={FPClient:n,FPConfig:o,FPEvent:i,FPSocket:s,FPPackage:a,FPCallback:u,FPProcessor:c,FPError:f,BrowserImpl:l,WechatImpl:h}},function(e,t,r){"use strict";var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),o=r(0),i=r(1),s=r(3),a=r(5),u=r(6),c=r(7),f=r(2),l=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),i.assign(this),this._autoReconnect=t.autoReconnect||!1,this._conn=new s(t);var r=this;this._conn.on("connect",(function(){d.call(r)})),this._conn.on("close",(function(){p.call(r)})),this._conn.on("data",(function(e){y.call(r,e)})),this._conn.on("error",(function(e){h.call(r,new f(o.ERROR_CODE.FPNN_EC_CORE_UNKNOWN_ERROR,e))})),this._pkg=new a,this._cbs=new u,this._psr=new c,this._seq=0,this._wpos=0,this._peekData=null,this._readID=0,this._reconnectID=0,this._buffer=o.BUFFER.allocUnsafe(o.READ_BUFFER_LEN)}return n(e,[{key:"connect",value:function(){this.hasConnect||this._conn.open()}},{key:"sendQuest",value:function(e,t,r){if(this._conn.isOpen){var n={};n.magic=e.magic||o.TCP_MAGIC,n.version=e.version||1,n.flag=e.flag||0,n.mtype=e.hasOwnProperty("mtype")?e.mtype:1,n.method=e.method,n.seq=e.hasOwnProperty("seq")?e.seq:++this._seq,n.payload=e.payload,n=this._pkg.buildPkgData(n),t&&this._cbs.addCb(this._pkg.cbKey(n),t,r);var i=this._pkg.enCode(n);this._conn.write(i)}else t&&t(new f(o.ERROR_CODE.FPNN_EC_CORE_CONNECTION_CLOSED,new Error("Connection Closed")))}},{key:"sendNotify",value:function(e){var t={};t.magic=e.magic||o.TCP_MAGIC,t.version=e.version||1,t.flag=e.flag||0,t.mtype=e.mtype||0,t.method=e.method,t.payload=e.payload,t=this._pkg.buildPkgData(t);var r=this._pkg.enCode(t);this._conn.write(r)}},{key:"close",value:function(e){e&&h.call(this,e),this._conn.close()}},{key:"destroy",value:function(){this._autoReconnect=!1,this.removeEvent(),this._psr.destroy(),this._conn.destroy(),p.call(this)}},{key:"processor",get:function(){return this._psr},set:function(e){return this._psr=e}},{key:"isOpen",get:function(){return this._conn.isOpen}},{key:"hasConnect",get:function(){return this._conn.isOpen||this._conn.isConnecting}}]),e}();function h(e){this.emit("error",e)}function d(){this._reconnectID&&(clearTimeout(this._reconnectID),this._reconnectID=0),this.emit("connect")}function p(){this._readID&&(clearInterval(this._readID),this._readID=0),this._reconnectID&&(clearTimeout(this._reconnectID),this._reconnectID=0),this._seq=0,this._wpos=0,this._peekData=null,this._cbs.removeCb(),this._buffer=o.BUFFER.allocUnsafe(o.READ_BUFFER_LEN),this.emit("close"),this._autoReconnect&&g.call(this)}function g(){if(!this._reconnectID){var e=this;this._reconnectID=setTimeout((function(){e.connect()}),100)}}function y(e){e=o.BUFFER.from(e);var t=this._wpos+e.length;if(t>this._buffer.length&&m.call(this,t,2*o.READ_BUFFER_LEN),this._wpos+=e.copy(this._buffer,this._wpos,0),!this._readID){var r=this;this._readID=setInterval((function(){_.call(r)}),0)}}function m(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=Math.max(e,t),i=o.BUFFER.allocUnsafe(n);this._wpos=this._buffer.copy(i,0,r,this._wpos),this._buffer=i}function _(){if(!(this._wpos<12))if(this._peekData||(this._peekData=b.call(this,this._buffer),this._peekData)){var e=this._wpos-this._peekData.pkgLen;if(!(e<0)){this._buffer.copy(this._peekData.buffer,0,0,this._peekData.pkgLen);var t=this._pkg.deCode(this._peekData.buffer);if(m.call(this,2*e,o.READ_BUFFER_LEN,this._peekData.pkgLen),delete this._peekData,this._peekData=null,this._pkg.isAnswer(t)){var r=this._pkg.cbKey(t);this._cbs.execCb(r,t)}if(this._pkg.isQuest(t)){var n=this;this._psr.service(t,(function(e,r){v.call(n,t.flag,t.seq,e,r)}))}}}else this.conn.close(new f(o.ERROR_CODE.FPNN_EC_PROTO_INVALID_PACKAGE,new Error("Invalid Protocol Package")))}function v(e,t,r,n){var o={flag:e,mtype:2,seq:t,ss:(n=n||!1)?1:0,payload:r};this.sendQuest(o)}function b(e){var t=null;if(e.length>=12){if(t=this._pkg.peekHead(e),!w.call(this,t))return null;this._pkg.isOneWay(t)&&(t.pkgLen=12+t.ss+t.psize),this._pkg.isTwoWay(t)&&(t.pkgLen=16+t.ss+t.psize),this._pkg.isAnswer(t)&&(t.pkgLen=16+t.psize),t.pkgLen>0&&(t.buffer=o.BUFFER.allocUnsafe(t.pkgLen))}return t}function w(e){return!(!o.TCP_MAGIC.equals(e.magic)&&!o.HTTP_MAGIC.equals(e.magic)||e.version<0||e.version>=o.FPNN_VERSION.length||e.flag<0||e.flag>=o.FP_FLAG.length||e.mtype<0||e.mtype>=o.FP_MESSAGE_TYPE.length)}e.exports=l},function(e,t,r){"use strict";
|
|
11
|
+
/*!
|
|
12
|
+
* The buffer module from node.js, for the browser.
|
|
13
|
+
*
|
|
14
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
|
15
|
+
* @license MIT
|
|
16
|
+
*/var n=r(11),o=r(12);function i(e){if(e>2147483647)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return t.__proto__=s.prototype,t}function s(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return c(e)}return a(e,t,r)}function a(e,t,r){if("string"==typeof e)return function(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!s.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=0|h(e,t),n=i(r),o=n.write(e,t);return o!==r&&(n=n.slice(0,o)),n}(e,t);if(ArrayBuffer.isView(e))return f(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(F(e,ArrayBuffer)||e&&F(e.buffer,ArrayBuffer))return function(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');var n;return(n=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r)).__proto__=s.prototype,n}(e,t,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var n=e.valueOf&&e.valueOf();if(null!=n&&n!==e)return s.from(n,t,r);var o=function(e){if(s.isBuffer(e)){var t=0|l(e.length),r=i(t);return 0===r.length||e.copy(r,0,0,t),r}return void 0!==e.length?"number"!=typeof e.length||j(e.length)?i(0):f(e):"Buffer"===e.type&&Array.isArray(e.data)?f(e.data):void 0}(e);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return s.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function u(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function c(e){return u(e),i(e<0?0:0|l(e))}function f(e){for(var t=e.length<0?0:0|l(e.length),r=i(t),n=0;n<t;n+=1)r[n]=255&e[n];return r}function l(e){if(e>=2147483647)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+2147483647..toString(16)+" bytes");return 0|e}function h(e,t){if(s.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||F(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var o=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return x(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return D(e).length;default:if(o)return n?-1:x(e).length;t=(""+t).toLowerCase(),o=!0}}function d(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return O(this,t,r);case"utf8":case"utf-8":return R(this,t,r);case"ascii":return P(this,t,r);case"latin1":case"binary":return C(this,t,r);case"base64":return k(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function p(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function g(e,t,r,n,o){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),j(r=+r)&&(r=o?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(o)return-1;r=e.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof t&&(t=s.from(t,n)),s.isBuffer(t))return 0===t.length?-1:y(e,t,r,n,o);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):y(e,[t],r,n,o);throw new TypeError("val must be string, number or Buffer")}function y(e,t,r,n,o){var i,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function c(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(o){var f=-1;for(i=r;i<a;i++)if(c(e,i)===c(t,-1===f?0:i-f)){if(-1===f&&(f=i),i-f+1===u)return f*s}else-1!==f&&(i-=i-f),f=-1}else for(r+u>a&&(r=a-u),i=r;i>=0;i--){for(var l=!0,h=0;h<u;h++)if(c(e,i+h)!==c(t,h)){l=!1;break}if(l)return i}return-1}function m(e,t,r,n){r=Number(r)||0;var o=e.length-r;n?(n=Number(n))>o&&(n=o):n=o;var i=t.length;n>i/2&&(n=i/2);for(var s=0;s<n;++s){var a=parseInt(t.substr(2*s,2),16);if(j(a))return s;e[r+s]=a}return s}function _(e,t,r,n){return L(x(t,e.length-r),e,r,n)}function v(e,t,r,n){return L(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function b(e,t,r,n){return v(e,t,r,n)}function w(e,t,r,n){return L(D(t),e,r,n)}function E(e,t,r,n){return L(function(e,t){for(var r,n,o,i=[],s=0;s<e.length&&!((t-=2)<0);++s)n=(r=e.charCodeAt(s))>>8,o=r%256,i.push(o),i.push(n);return i}(t,e.length-r),e,r,n)}function k(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function R(e,t,r){r=Math.min(e.length,r);for(var n=[],o=t;o<r;){var i,s,a,u,c=e[o],f=null,l=c>239?4:c>223?3:c>191?2:1;if(o+l<=r)switch(l){case 1:c<128&&(f=c);break;case 2:128==(192&(i=e[o+1]))&&(u=(31&c)<<6|63&i)>127&&(f=u);break;case 3:i=e[o+1],s=e[o+2],128==(192&i)&&128==(192&s)&&(u=(15&c)<<12|(63&i)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:i=e[o+1],s=e[o+2],a=e[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),o+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);for(var r="",n=0;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=4096));return r}(n)}function P(e,t,r){var n="";r=Math.min(e.length,r);for(var o=t;o<r;++o)n+=String.fromCharCode(127&e[o]);return n}function C(e,t,r){var n="";r=Math.min(e.length,r);for(var o=t;o<r;++o)n+=String.fromCharCode(e[o]);return n}function O(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var o="",i=t;i<r;++i)o+=N(e[i]);return o}function T(e,t,r){for(var n=e.slice(t,r),o="",i=0;i<n.length;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function A(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function S(e,t,r,n,o,i){if(!s.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<i)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function M(e,t,r,n,o,i){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function I(e,t,r,n,i){return t=+t,r>>>=0,i||M(e,0,r,4),o.write(e,t,r,n,23,4),r+4}function U(e,t,r,n,i){return t=+t,r>>>=0,i||M(e,0,r,8),o.write(e,t,r,n,52,8),r+8}t.Buffer=s,t.SlowBuffer=function(e){return+e!=e&&(e=0),s.alloc(+e)},t.INSPECT_MAX_BYTES=50,t.kMaxLength=2147483647,s.TYPED_ARRAY_SUPPORT=function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()}catch(e){return!1}}(),s.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}}),"undefined"!=typeof Symbol&&null!=Symbol.species&&s[Symbol.species]===s&&Object.defineProperty(s,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),s.poolSize=8192,s.from=function(e,t,r){return a(e,t,r)},s.prototype.__proto__=Uint8Array.prototype,s.__proto__=Uint8Array,s.alloc=function(e,t,r){return function(e,t,r){return u(e),e<=0?i(e):void 0!==t?"string"==typeof r?i(e).fill(t,r):i(e).fill(t):i(e)}(e,t,r)},s.allocUnsafe=function(e){return c(e)},s.allocUnsafeSlow=function(e){return c(e)},s.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==s.prototype},s.compare=function(e,t){if(F(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),F(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(e)||!s.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var r=e.length,n=t.length,o=0,i=Math.min(r,n);o<i;++o)if(e[o]!==t[o]){r=e[o],n=t[o];break}return r<n?-1:n<r?1:0},s.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},s.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return s.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=s.allocUnsafe(t),o=0;for(r=0;r<e.length;++r){var i=e[r];if(F(i,Uint8Array)&&(i=s.from(i)),!s.isBuffer(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(n,o),o+=i.length}return n},s.byteLength=h,s.prototype._isBuffer=!0,s.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)p(this,t,t+1);return this},s.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)p(this,t,t+3),p(this,t+1,t+2);return this},s.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)p(this,t,t+7),p(this,t+1,t+6),p(this,t+2,t+5),p(this,t+3,t+4);return this},s.prototype.toString=function(){var e=this.length;return 0===e?"":0===arguments.length?R(this,0,e):d.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(e){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===s.compare(this,e)},s.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},s.prototype.compare=function(e,t,r,n,o){if(F(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),!s.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),t<0||r>e.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&t>=r)return 0;if(n>=o)return-1;if(t>=r)return 1;if(this===e)return 0;for(var i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(t>>>=0),u=Math.min(i,a),c=this.slice(n,o),f=e.slice(t,r),l=0;l<u;++l)if(c[l]!==f[l]){i=c[l],a=f[l];break}return i<a?-1:a<i?1:0},s.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},s.prototype.indexOf=function(e,t,r){return g(this,e,t,r,!0)},s.prototype.lastIndexOf=function(e,t,r){return g(this,e,t,r,!1)},s.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-t;if((void 0===r||r>o)&&(r=o),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return m(this,e,t,r);case"utf8":case"utf-8":return _(this,e,t,r);case"ascii":return v(this,e,t,r);case"latin1":case"binary":return b(this,e,t,r);case"base64":return w(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,e,t,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},s.prototype.slice=function(e,t){var r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e);var n=this.subarray(e,t);return n.__proto__=s.prototype,n},s.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||A(e,t,this.length);for(var n=this[e],o=1,i=0;++i<t&&(o*=256);)n+=this[e+i]*o;return n},s.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||A(e,t,this.length);for(var n=this[e+--t],o=1;t>0&&(o*=256);)n+=this[e+--t]*o;return n},s.prototype.readUInt8=function(e,t){return e>>>=0,t||A(e,1,this.length),this[e]},s.prototype.readUInt16LE=function(e,t){return e>>>=0,t||A(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUInt16BE=function(e,t){return e>>>=0,t||A(e,2,this.length),this[e]<<8|this[e+1]},s.prototype.readUInt32LE=function(e,t){return e>>>=0,t||A(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},s.prototype.readUInt32BE=function(e,t){return e>>>=0,t||A(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},s.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||A(e,t,this.length);for(var n=this[e],o=1,i=0;++i<t&&(o*=256);)n+=this[e+i]*o;return n>=(o*=128)&&(n-=Math.pow(2,8*t)),n},s.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||A(e,t,this.length);for(var n=t,o=1,i=this[e+--n];n>0&&(o*=256);)i+=this[e+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*t)),i},s.prototype.readInt8=function(e,t){return e>>>=0,t||A(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},s.prototype.readInt16LE=function(e,t){e>>>=0,t||A(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(e,t){e>>>=0,t||A(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(e,t){return e>>>=0,t||A(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},s.prototype.readInt32BE=function(e,t){return e>>>=0,t||A(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},s.prototype.readFloatLE=function(e,t){return e>>>=0,t||A(e,4,this.length),o.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return e>>>=0,t||A(e,4,this.length),o.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return e>>>=0,t||A(e,8,this.length),o.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return e>>>=0,t||A(e,8,this.length),o.read(this,e,!1,52,8)},s.prototype.writeUIntLE=function(e,t,r,n){e=+e,t>>>=0,r>>>=0,n||S(this,e,t,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[t]=255&e;++i<r&&(o*=256);)this[t+i]=e/o&255;return t+r},s.prototype.writeUIntBE=function(e,t,r,n){e=+e,t>>>=0,r>>>=0,n||S(this,e,t,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[t+o]=255&e;--o>=0&&(i*=256);)this[t+o]=e/i&255;return t+r},s.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||S(this,e,t,1,255,0),this[t]=255&e,t+1},s.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||S(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||S(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||S(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},s.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||S(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},s.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var o=Math.pow(2,8*r-1);S(this,e,t,r,o-1,-o)}var i=0,s=1,a=0;for(this[t]=255&e;++i<r&&(s*=256);)e<0&&0===a&&0!==this[t+i-1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+r},s.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var o=Math.pow(2,8*r-1);S(this,e,t,r,o-1,-o)}var i=r-1,s=1,a=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===a&&0!==this[t+i+1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+r},s.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||S(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},s.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||S(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||S(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||S(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},s.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||S(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},s.prototype.writeFloatLE=function(e,t,r){return I(this,e,t,!0,r)},s.prototype.writeFloatBE=function(e,t,r){return I(this,e,t,!1,r)},s.prototype.writeDoubleLE=function(e,t,r){return U(this,e,t,!0,r)},s.prototype.writeDoubleBE=function(e,t,r){return U(this,e,t,!1,r)},s.prototype.copy=function(e,t,r,n){if(!s.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var o=n-r;if(this===e&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(t,r,n);else if(this===e&&r<t&&t<n)for(var i=o-1;i>=0;--i)e[i+t]=this[i+r];else Uint8Array.prototype.set.call(e,this.subarray(r,n),t);return o},s.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===e.length){var o=e.charCodeAt(0);("utf8"===n&&o<128||"latin1"===n)&&(e=o)}}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var i;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(i=t;i<r;++i)this[i]=e;else{var a=s.isBuffer(e)?e:s.from(e,n),u=a.length;if(0===u)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(i=0;i<r-t;++i)this[i+t]=a[i%u]}return this};var B=/[^+/0-9A-Za-z-_]/g;function N(e){return e<16?"0"+e.toString(16):e.toString(16)}function x(e,t){var r;t=t||1/0;for(var n=e.length,o=null,i=[],s=0;s<n;++s){if((r=e.charCodeAt(s))>55295&&r<57344){if(!o){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function D(e){return n.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(B,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function L(e,t,r,n){for(var o=0;o<n&&!(o+r>=t.length||o>=e.length);++o)t[o+r]=e[o];return o}function F(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function j(e){return e!=e}},function(e,t,r){"use strict";t.byteLength=function(e){var t=c(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){var t,r,n=c(e),s=n[0],a=n[1],u=new i(function(e,t,r){return 3*(t+r)/4-r}(0,s,a)),f=0,l=a>0?s-4:s;for(r=0;r<l;r+=4)t=o[e.charCodeAt(r)]<<18|o[e.charCodeAt(r+1)]<<12|o[e.charCodeAt(r+2)]<<6|o[e.charCodeAt(r+3)],u[f++]=t>>16&255,u[f++]=t>>8&255,u[f++]=255&t;return 2===a&&(t=o[e.charCodeAt(r)]<<2|o[e.charCodeAt(r+1)]>>4,u[f++]=255&t),1===a&&(t=o[e.charCodeAt(r)]<<10|o[e.charCodeAt(r+1)]<<4|o[e.charCodeAt(r+2)]>>2,u[f++]=t>>8&255,u[f++]=255&t),u},t.fromByteArray=function(e){for(var t,r=e.length,o=r%3,i=[],s=0,a=r-o;s<a;s+=16383)i.push(f(e,s,s+16383>a?a:s+16383));return 1===o?(t=e[r-1],i.push(n[t>>2]+n[t<<4&63]+"==")):2===o&&(t=(e[r-2]<<8)+e[r-1],i.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"=")),i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a<u;++a)n[a]=s[a],o[s.charCodeAt(a)]=a;function c(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function f(e,t,r){for(var o,i,s=[],a=t;a<r;a+=3)o=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),s.push(n[(i=o)>>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return s.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},function(e,t){
|
|
17
|
+
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
18
|
+
t.read=function(e,t,r,n,o){var i,s,a=8*o-n-1,u=(1<<a)-1,c=u>>1,f=-7,l=r?o-1:0,h=r?-1:1,d=e[t+l];for(l+=h,i=d&(1<<-f)-1,d>>=-f,f+=a;f>0;i=256*i+e[t+l],l+=h,f-=8);for(s=i&(1<<-f)-1,i>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=h,f-=8);if(0===i)i=1-c;else{if(i===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),i-=c}return(d?-1:1)*s*Math.pow(2,i-n)},t.write=function(e,t,r,n,o,i){var s,a,u,c=8*i-o-1,f=(1<<c)-1,l=f>>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:i-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,o),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,o),s=0));o>=8;e[r+d]=255&a,d+=p,a/=256,o-=8);for(s=s<<o|a,c+=o;c>0;e[r+d]=255&s,d+=p,s/=256,c-=8);e[r+d-p]|=128*g}},function(e,t,r){"use strict";var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),o=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._socket=null}return n(e,[{key:"open",value:function(e){var t=this;wx&&wx.connectSocket?(this._socket=wx.connectSocket({url:e,protocols:"arraybuffer"}),this._socket.onOpen((function(e){t.emit("open")})),this._socket.onMessage((function(e){t.emit("message",e.data)})),this._socket.onClose((function(){t.emit("close")})),this._socket.onError((function(e){t.emit("error",e)}))):this.emit("error",new Error("Not support `wx` or `wx.connectSocket` undefined"))}},{key:"send",value:function(e){this._socket&&this._socket.send({data:e})}},{key:"close",value:function(){this._socket&&this._socket.close({})}},{key:"isOpen",get:function(){return!!this._socket&&1==this._socket.readyState}},{key:"isConnecting",get:function(){return!!this._socket&&0==this._socket.readyState}}]),e}();e.exports=o}])},function(e,t,r){(function(t){e.exports=function e(t,r,n){function o(s,a){if(!r[s]){if(!t[s]){if(i)return i(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var c=r[s]={exports:{}};t[s][0].call(c.exports,(function(e){var r=t[s][1][e];return o(r||e)}),c,c.exports,e,t,r,n)}return r[s].exports}for(var i=!1,s=0;s<n.length;s++)o(n[s]);return o}({1:[function(e,t,r){r.encode=e("./encode").encode,r.decode=e("./decode").decode,r.Encoder=e("./encoder").Encoder,r.Decoder=e("./decoder").Decoder,r.createCodec=e("./ext").createCodec,r.codec=e("./codec").codec},{"./codec":10,"./decode":12,"./decoder":13,"./encode":15,"./encoder":16,"./ext":20}],2:[function(e,t,r){(function(e){function r(e){return e&&e.isBuffer&&e}t.exports=r(void 0!==e&&e)||r(this.Buffer)||r("undefined"!=typeof window&&window.Buffer)||this.Buffer}).call(this,e("buffer").Buffer)},{buffer:29}],3:[function(e,t,r){r.copy=function(e,t,r,n){var o;r||(r=0),n||0===n||(n=this.length),t||(t=0);var i=n-r;if(e===this&&r<t&&t<n)for(o=i-1;o>=0;o--)e[o+t]=this[o+r];else for(o=0;o<i;o++)e[o+t]=this[o+r];return i},r.toString=function(e,t,r){var n=this,o=0|t;r||(r=n.length);for(var i="",s=0;o<r;)(s=n[o++])<128?i+=String.fromCharCode(s):(192==(224&s)?s=(31&s)<<6|63&n[o++]:224==(240&s)?s=(15&s)<<12|(63&n[o++])<<6|63&n[o++]:240==(248&s)&&(s=(7&s)<<18|(63&n[o++])<<12|(63&n[o++])<<6|63&n[o++]),s>=65536?(s-=65536,i+=String.fromCharCode(55296+(s>>>10),56320+(1023&s))):i+=String.fromCharCode(s));return i},r.write=function(e,t){for(var r=this,n=t||(t|=0),o=e.length,i=0,s=0;s<o;)(i=e.charCodeAt(s++))<128?r[n++]=i:i<2048?(r[n++]=192|i>>>6,r[n++]=128|63&i):i<55296||i>57343?(r[n++]=224|i>>>12,r[n++]=128|i>>>6&63,r[n++]=128|63&i):(i=65536+(i-55296<<10|e.charCodeAt(s++)-56320),r[n++]=240|i>>>18,r[n++]=128|i>>>12&63,r[n++]=128|i>>>6&63,r[n++]=128|63&i);return n-t}},{}],4:[function(e,t,r){function n(e){return new Array(e)}var o=e("./bufferish");(r=t.exports=n(0)).alloc=n,r.concat=o.concat,r.from=function(e){if(!o.isBuffer(e)&&o.isView(e))e=o.Uint8Array.from(e);else if(o.isArrayBuffer(e))e=new Uint8Array(e);else{if("string"==typeof e)return o.from.call(r,e);if("number"==typeof e)throw new TypeError('"value" argument must not be a number')}return Array.prototype.slice.call(e)}},{"./bufferish":8}],5:[function(e,t,r){function n(e){return new i(e)}var o=e("./bufferish"),i=o.global;(r=t.exports=o.hasBuffer?n(0):[]).alloc=o.hasBuffer&&i.alloc||n,r.concat=o.concat,r.from=function(e){if(!o.isBuffer(e)&&o.isView(e))e=o.Uint8Array.from(e);else if(o.isArrayBuffer(e))e=new Uint8Array(e);else{if("string"==typeof e)return o.from.call(r,e);if("number"==typeof e)throw new TypeError('"value" argument must not be a number')}return i.from&&1!==i.from.length?i.from(e):new i(e)}},{"./bufferish":8}],6:[function(e,t,r){function n(e,t,r,n){var a=s.isBuffer(this),u=s.isBuffer(e);if(a&&u)return this.copy(e,t,r,n);if(c||a||u||!s.isView(this)||!s.isView(e))return i.copy.call(this,e,t,r,n);var f=r||null!=n?o.call(this,r,n):this;return e.set(f,t),f.length}function o(e,t){var r=this.slice||!c&&this.subarray;if(r)return r.call(this,e,t);var o=s.alloc.call(this,t-e);return n.call(this,o,0,e,t),o}var i=e("./buffer-lite");r.copy=n,r.slice=o,r.toString=function(e,t,r){var n=!u&&s.isBuffer(this)?this.toString:i.toString;return n.apply(this,arguments)},r.write=function(e){return function(){var t=this[e]||i[e];return t.apply(this,arguments)}}("write");var s=e("./bufferish"),a=s.global,u=s.hasBuffer&&"TYPED_ARRAY_SUPPORT"in a,c=u&&!a.TYPED_ARRAY_SUPPORT},{"./buffer-lite":3,"./bufferish":8}],7:[function(e,t,r){function n(e){return new Uint8Array(e)}var o=e("./bufferish");(r=t.exports=o.hasArrayBuffer?n(0):[]).alloc=n,r.concat=o.concat,r.from=function(e){if(o.isView(e)){var t=e.byteOffset,n=e.byteLength;(e=e.buffer).byteLength!==n&&(e.slice?e=e.slice(t,t+n):(e=new Uint8Array(e)).byteLength!==n&&(e=Array.prototype.slice.call(e,t,t+n)))}else{if("string"==typeof e)return o.from.call(r,e);if("number"==typeof e)throw new TypeError('"value" argument must not be a number')}return new Uint8Array(e)}},{"./bufferish":8}],8:[function(e,t,r){function n(e){return i(this).alloc(e)}function o(e){var t=3*e.length,r=n.call(this,t),o=m.write.call(r,e);return t!==o&&(r=m.slice.call(r,0,o)),r}function i(e){return h(e)?g:d(e)?y:l(e)?p:c?g:f?y:p}function s(){return!1}function a(e,t){return e="[object "+e+"]",function(r){return null!=r&&{}.toString.call(t?r[t]:r)===e}}var u=r.global=e("./buffer-global"),c=r.hasBuffer=u&&!!u.isBuffer,f=r.hasArrayBuffer="undefined"!=typeof ArrayBuffer,l=r.isArray=e("isarray");r.isArrayBuffer=f?function(e){return e instanceof ArrayBuffer||_(e)}:s;var h=r.isBuffer=c?u.isBuffer:s,d=r.isView=f?ArrayBuffer.isView||a("ArrayBuffer","buffer"):s;r.alloc=n,r.concat=function(e,t){t||(t=0,Array.prototype.forEach.call(e,(function(e){t+=e.length})));var o=this!==r&&this||e[0],i=n.call(o,t),s=0;return Array.prototype.forEach.call(e,(function(e){s+=m.copy.call(e,i,s)})),i},r.from=function(e){return"string"==typeof e?o.call(this,e):i(this).from(e)};var p=r.Array=e("./bufferish-array"),g=r.Buffer=e("./bufferish-buffer"),y=r.Uint8Array=e("./bufferish-uint8array"),m=r.prototype=e("./bufferish-proto"),_=a("ArrayBuffer")},{"./buffer-global":2,"./bufferish-array":4,"./bufferish-buffer":5,"./bufferish-proto":6,"./bufferish-uint8array":7,isarray:34}],9:[function(e,t,r){function n(e){return this instanceof n?(this.options=e,void this.init()):new n(e)}function o(e,t){return e&&t?function(){return e.apply(this,arguments),t.apply(this,arguments)}:e||t}function i(e){return new n(e)}var s=e("isarray");r.createCodec=i,r.install=function(e){for(var t in e)n.prototype[t]=o(n.prototype[t],e[t])},r.filter=function(e){return s(e)?function(e){function t(e,t){return t(e)}return e=e.slice(),function(r){return e.reduce(t,r)}}(e):e};var a=e("./bufferish");n.prototype.init=function(){var e=this.options;return e&&e.uint8array&&(this.bufferish=a.Uint8Array),this},r.preset=i({preset:!0})},{"./bufferish":8,isarray:34}],10:[function(e,t,r){e("./read-core"),e("./write-core"),r.codec={preset:e("./codec-base").preset}},{"./codec-base":9,"./read-core":22,"./write-core":25}],11:[function(e,t,r){function n(e){if(!(this instanceof n))return new n(e);if(e&&(this.options=e,e.codec)){var t=this.codec=e.codec;t.bufferish&&(this.bufferish=t.bufferish)}}r.DecodeBuffer=n;var o=e("./read-core").preset;e("./flex-buffer").FlexDecoder.mixin(n.prototype),n.prototype.codec=o,n.prototype.fetch=function(){return this.codec.decode(this)}},{"./flex-buffer":21,"./read-core":22}],12:[function(e,t,r){r.decode=function(e,t){var r=new n(t);return r.write(e),r.read()};var n=e("./decode-buffer").DecodeBuffer},{"./decode-buffer":11}],13:[function(e,t,r){function n(e){return this instanceof n?void i.call(this,e):new n(e)}r.Decoder=n;var o=e("event-lite"),i=e("./decode-buffer").DecodeBuffer;n.prototype=new i,o.mixin(n.prototype),n.prototype.decode=function(e){arguments.length&&this.write(e),this.flush()},n.prototype.push=function(e){this.emit("data",e)},n.prototype.end=function(e){this.decode(e),this.emit("end")}},{"./decode-buffer":11,"event-lite":31}],14:[function(e,t,r){function n(e){if(!(this instanceof n))return new n(e);if(e&&(this.options=e,e.codec)){var t=this.codec=e.codec;t.bufferish&&(this.bufferish=t.bufferish)}}r.EncodeBuffer=n;var o=e("./write-core").preset;e("./flex-buffer").FlexEncoder.mixin(n.prototype),n.prototype.codec=o,n.prototype.write=function(e){this.codec.encode(this,e)}},{"./flex-buffer":21,"./write-core":25}],15:[function(e,t,r){r.encode=function(e,t){var r=new n(t);return r.write(e),r.read()};var n=e("./encode-buffer").EncodeBuffer},{"./encode-buffer":14}],16:[function(e,t,r){function n(e){return this instanceof n?void i.call(this,e):new n(e)}r.Encoder=n;var o=e("event-lite"),i=e("./encode-buffer").EncodeBuffer;n.prototype=new i,o.mixin(n.prototype),n.prototype.encode=function(e){this.write(e),this.emit("data",this.read())},n.prototype.end=function(e){arguments.length&&this.encode(e),this.flush(),this.emit("end")}},{"./encode-buffer":14,"event-lite":31}],17:[function(e,t,r){r.ExtBuffer=function e(t,r){return this instanceof e?(this.buffer=n.from(t),void(this.type=r)):new e(t,r)};var n=e("./bufferish")},{"./bufferish":8}],18:[function(e,t,r){function n(t){return a||(a=e("./encode").encode),a(t)}function o(e){return e.valueOf()}function i(e){(e=RegExp.prototype.toString.call(e).split("/")).shift();var t=[e.pop()];return t.unshift(e.join("/")),t}function s(e){var t={};for(var r in l)t[r]=e[r];return t}r.setExtPackers=function(e){e.addExtPacker(14,Error,[s,n]),e.addExtPacker(1,EvalError,[s,n]),e.addExtPacker(2,RangeError,[s,n]),e.addExtPacker(3,ReferenceError,[s,n]),e.addExtPacker(4,SyntaxError,[s,n]),e.addExtPacker(5,TypeError,[s,n]),e.addExtPacker(6,URIError,[s,n]),e.addExtPacker(10,RegExp,[i,n]),e.addExtPacker(11,Boolean,[o,n]),e.addExtPacker(12,String,[o,n]),e.addExtPacker(13,Date,[Number,n]),e.addExtPacker(15,Number,[o,n]),"undefined"!=typeof Uint8Array&&(e.addExtPacker(17,Int8Array,f),e.addExtPacker(18,Uint8Array,f),e.addExtPacker(19,Int16Array,f),e.addExtPacker(20,Uint16Array,f),e.addExtPacker(21,Int32Array,f),e.addExtPacker(22,Uint32Array,f),e.addExtPacker(23,Float32Array,f),"undefined"!=typeof Float64Array&&e.addExtPacker(24,Float64Array,f),"undefined"!=typeof Uint8ClampedArray&&e.addExtPacker(25,Uint8ClampedArray,f),e.addExtPacker(26,ArrayBuffer,f),e.addExtPacker(29,DataView,f)),u.hasBuffer&&e.addExtPacker(27,c,u.from)};var a,u=e("./bufferish"),c=u.global,f=u.Uint8Array.from,l={name:1,message:1,stack:1,columnNumber:1,fileName:1,lineNumber:1}},{"./bufferish":8,"./encode":15}],19:[function(e,t,r){function n(t){return u||(u=e("./decode").decode),u(t)}function o(e){return RegExp.apply(null,e)}function i(e){return function(t){var r=new e;for(var n in l)r[n]=t[n];return r}}function s(e){return function(t){return new e(t)}}function a(e){return new Uint8Array(e).buffer}r.setExtUnpackers=function(e){e.addExtUnpacker(14,[n,i(Error)]),e.addExtUnpacker(1,[n,i(EvalError)]),e.addExtUnpacker(2,[n,i(RangeError)]),e.addExtUnpacker(3,[n,i(ReferenceError)]),e.addExtUnpacker(4,[n,i(SyntaxError)]),e.addExtUnpacker(5,[n,i(TypeError)]),e.addExtUnpacker(6,[n,i(URIError)]),e.addExtUnpacker(10,[n,o]),e.addExtUnpacker(11,[n,s(Boolean)]),e.addExtUnpacker(12,[n,s(String)]),e.addExtUnpacker(13,[n,s(Date)]),e.addExtUnpacker(15,[n,s(Number)]),"undefined"!=typeof Uint8Array&&(e.addExtUnpacker(17,s(Int8Array)),e.addExtUnpacker(18,s(Uint8Array)),e.addExtUnpacker(19,[a,s(Int16Array)]),e.addExtUnpacker(20,[a,s(Uint16Array)]),e.addExtUnpacker(21,[a,s(Int32Array)]),e.addExtUnpacker(22,[a,s(Uint32Array)]),e.addExtUnpacker(23,[a,s(Float32Array)]),"undefined"!=typeof Float64Array&&e.addExtUnpacker(24,[a,s(Float64Array)]),"undefined"!=typeof Uint8ClampedArray&&e.addExtUnpacker(25,s(Uint8ClampedArray)),e.addExtUnpacker(26,a),e.addExtUnpacker(29,[a,s(DataView)])),c.hasBuffer&&e.addExtUnpacker(27,s(f))};var u,c=e("./bufferish"),f=c.global,l={name:1,message:1,stack:1,columnNumber:1,fileName:1,lineNumber:1}},{"./bufferish":8,"./decode":12}],20:[function(e,t,r){e("./read-core"),e("./write-core"),r.createCodec=e("./codec-base").createCodec},{"./codec-base":9,"./read-core":22,"./write-core":25}],21:[function(e,t,r){function n(){if(!(this instanceof n))return new n}function o(){if(!(this instanceof o))return new o}function i(){throw new Error("method not implemented: write()")}function s(){throw new Error("method not implemented: fetch()")}function a(){return this.buffers&&this.buffers.length?(this.flush(),this.pull()):this.fetch()}function u(e){(this.buffers||(this.buffers=[])).push(e)}function c(){return(this.buffers||(this.buffers=[])).shift()}function f(e){return function(t){for(var r in e)t[r]=e[r];return t}}r.FlexDecoder=n,r.FlexEncoder=o;var l=e("./bufferish"),h=2048,d=65536,p="BUFFER_SHORTAGE";n.mixin=f({bufferish:l,write:function(e){var t=this.offset?l.prototype.slice.call(this.buffer,this.offset):this.buffer;this.buffer=t?e?this.bufferish.concat([t,e]):t:e,this.offset=0},fetch:s,flush:function(){for(;this.offset<this.buffer.length;){var e,t=this.offset;try{e=this.fetch()}catch(e){if(e&&e.message!=p)throw e;this.offset=t;break}this.push(e)}},push:u,pull:c,read:a,reserve:function(e){var t=this.offset,r=t+e;if(r>this.buffer.length)throw new Error(p);return this.offset=r,t},offset:0}),n.mixin(n.prototype),o.mixin=f({bufferish:l,write:i,fetch:function(){var e=this.start;if(e<this.offset){var t=this.start=this.offset;return l.prototype.slice.call(this.buffer,e,t)}},flush:function(){for(;this.start<this.offset;){var e=this.fetch();e&&this.push(e)}},push:u,pull:function(){var e=this.buffers||(this.buffers=[]),t=e.length>1?this.bufferish.concat(e):e[0];return e.length=0,t},read:a,reserve:function(e){var t=0|e;if(this.buffer){var r=this.buffer.length,n=0|this.offset,o=n+t;if(o<r)return this.offset=o,n;this.flush(),e=Math.max(e,Math.min(2*r,this.maxBufferSize))}return e=Math.max(e,this.minBufferSize),this.buffer=this.bufferish.alloc(e),this.start=0,this.offset=t,0},send:function(e){var t=e.length;if(t>this.minBufferSize)this.flush(),this.push(e);else{var r=this.reserve(t);l.prototype.copy.call(e,this.buffer,r)}},maxBufferSize:d,minBufferSize:h,offset:0,start:0}),o.mixin(o.prototype)},{"./bufferish":8}],22:[function(e,t,r){function n(){var e=this.options;return this.decode=function(e){var t=a.getReadToken(e);return function(e){var r=s(e),n=t[r];if(!n)throw new Error("Invalid type: "+(r?"0x"+r.toString(16):r));return n(e)}}(e),e&&e.preset&&i.setExtUnpackers(this),this}var o=e("./ext-buffer").ExtBuffer,i=e("./ext-unpacker"),s=e("./read-format").readUint8,a=e("./read-token"),u=e("./codec-base");u.install({addExtUnpacker:function(e,t){(this.extUnpackers||(this.extUnpackers=[]))[e]=u.filter(t)},getExtUnpacker:function(e){return(this.extUnpackers||(this.extUnpackers=[]))[e]||function(t){return new o(t,e)}},init:n}),r.preset=n.call(u.preset)},{"./codec-base":9,"./ext-buffer":17,"./ext-unpacker":19,"./read-format":23,"./read-token":24}],23:[function(e,t,r){function n(e,t){var r,n={},o=new Array(t),i=new Array(t),s=e.codec.decode;for(r=0;r<t;r++)o[r]=s(e),i[r]=s(e);for(r=0;r<t;r++)n[o[r]]=i[r];return n}function o(e,t){var r,n=new Map,o=new Array(t),i=new Array(t),s=e.codec.decode;for(r=0;r<t;r++)o[r]=s(e),i[r]=s(e);for(r=0;r<t;r++)n.set(o[r],i[r]);return n}function i(e,t){for(var r=new Array(t),n=e.codec.decode,o=0;o<t;o++)r[o]=n(e);return r}function s(e,t){var r=e.reserve(t),n=r+t;return T.toString.call(e.buffer,"utf-8",r,n)}function a(e,t){var r=e.reserve(t),n=r+t,o=T.slice.call(e.buffer,r,n);return O.from(o)}function u(e,t){var r=e.reserve(t),n=r+t,o=T.slice.call(e.buffer,r,n);return O.Uint8Array.from(o).buffer}function c(e,t){var r=e.reserve(t+1),n=e.buffer[r++],o=r+t,i=e.codec.getExtUnpacker(n);if(!i)throw new Error("Invalid ext type: "+(n?"0x"+n.toString(16):n));return i(T.slice.call(e.buffer,r,o))}function f(e){var t=e.reserve(1);return e.buffer[t]}function l(e){var t=e.reserve(1),r=e.buffer[t];return 128&r?r-256:r}function h(e){var t=e.reserve(2),r=e.buffer;return r[t++]<<8|r[t]}function d(e){var t=e.reserve(2),r=e.buffer,n=r[t++]<<8|r[t];return 32768&n?n-65536:n}function p(e){var t=e.reserve(4),r=e.buffer;return 16777216*r[t++]+(r[t++]<<16)+(r[t++]<<8)+r[t]}function g(e){var t=e.reserve(4),r=e.buffer;return r[t++]<<24|r[t++]<<16|r[t++]<<8|r[t]}function y(e,t){return function(r){var n=r.reserve(e);return t.call(r.buffer,n,S)}}function m(e){return new P(this,e).toNumber()}function _(e){return new C(this,e).toNumber()}function v(e){return new P(this,e)}function b(e){return new C(this,e)}function w(e){return k.read(this,e,!1,23,4)}function E(e){return k.read(this,e,!1,52,8)}var k=e("ieee754"),R=e("int64-buffer"),P=R.Uint64BE,C=R.Int64BE;r.getReadFormat=function(e){var t=O.hasArrayBuffer&&e&&e.binarraybuffer,r=e&&e.int64;return{map:A&&e&&e.usemap?o:n,array:i,str:s,bin:t?u:a,ext:c,uint8:f,uint16:h,uint32:p,uint64:y(8,r?v:m),int8:l,int16:d,int32:g,int64:y(8,r?b:_),float32:y(4,w),float64:y(8,E)}},r.readUint8=f;var O=e("./bufferish"),T=e("./bufferish-proto"),A="undefined"!=typeof Map,S=!0},{"./bufferish":8,"./bufferish-proto":6,ieee754:32,"int64-buffer":33}],24:[function(e,t,r){function n(e){var t,r=new Array(256);for(t=0;t<=127;t++)r[t]=o(t);for(t=128;t<=143;t++)r[t]=s(t-128,e.map);for(t=144;t<=159;t++)r[t]=s(t-144,e.array);for(t=160;t<=191;t++)r[t]=s(t-160,e.str);for(r[192]=o(null),r[193]=null,r[194]=o(!1),r[195]=o(!0),r[196]=i(e.uint8,e.bin),r[197]=i(e.uint16,e.bin),r[198]=i(e.uint32,e.bin),r[199]=i(e.uint8,e.ext),r[200]=i(e.uint16,e.ext),r[201]=i(e.uint32,e.ext),r[202]=e.float32,r[203]=e.float64,r[204]=e.uint8,r[205]=e.uint16,r[206]=e.uint32,r[207]=e.uint64,r[208]=e.int8,r[209]=e.int16,r[210]=e.int32,r[211]=e.int64,r[212]=s(1,e.ext),r[213]=s(2,e.ext),r[214]=s(4,e.ext),r[215]=s(8,e.ext),r[216]=s(16,e.ext),r[217]=i(e.uint8,e.str),r[218]=i(e.uint16,e.str),r[219]=i(e.uint32,e.str),r[220]=i(e.uint16,e.array),r[221]=i(e.uint32,e.array),r[222]=i(e.uint16,e.map),r[223]=i(e.uint32,e.map),t=224;t<=255;t++)r[t]=o(t-256);return r}function o(e){return function(){return e}}function i(e,t){return function(r){var n=e(r);return t(r,n)}}function s(e,t){return function(r){return t(r,e)}}var a=e("./read-format");r.getReadToken=function(e){var t=a.getReadFormat(e);return e&&e.useraw?function(e){var t,r=n(e).slice();for(r[217]=r[196],r[218]=r[197],r[219]=r[198],t=160;t<=191;t++)r[t]=s(t-160,e.bin);return r}(t):n(t)}},{"./read-format":23}],25:[function(e,t,r){function n(){var e=this.options;return this.encode=function(e){var t=s.getWriteType(e);return function(e,r){var n=t[typeof r];if(!n)throw new Error('Unsupported type "'+typeof r+'": '+r);n(e,r)}}(e),e&&e.preset&&i.setExtPackers(this),this}var o=e("./ext-buffer").ExtBuffer,i=e("./ext-packer"),s=e("./write-type"),a=e("./codec-base");a.install({addExtPacker:function(e,t,r){function n(t){return r&&(t=r(t)),new o(t,e)}r=a.filter(r);var i=t.name;i&&"Object"!==i?(this.extPackers||(this.extPackers={}))[i]=n:(this.extEncoderList||(this.extEncoderList=[])).unshift([t,n])},getExtPacker:function(e){var t=this.extPackers||(this.extPackers={}),r=e.constructor,n=r&&r.name&&t[r.name];if(n)return n;for(var o=this.extEncoderList||(this.extEncoderList=[]),i=o.length,s=0;s<i;s++){var a=o[s];if(r===a[0])return a[1]}},init:n}),r.preset=n.call(a.preset)},{"./codec-base":9,"./ext-buffer":17,"./ext-packer":18,"./write-type":27}],26:[function(e,t,r){function n(){var e=y.slice();return e[196]=o(196),e[197]=i(197),e[198]=s(198),e[199]=o(199),e[200]=i(200),e[201]=s(201),e[202]=a(202,4,b.writeFloatBE||f,!0),e[203]=a(203,8,b.writeDoubleBE||l,!0),e[204]=o(204),e[205]=i(205),e[206]=s(206),e[207]=a(207,8,u),e[208]=o(208),e[209]=i(209),e[210]=s(210),e[211]=a(211,8,c),e[217]=o(217),e[218]=i(218),e[219]=s(219),e[220]=i(220),e[221]=s(221),e[222]=i(222),e[223]=s(223),e}function o(e){return function(t,r){var n=t.reserve(2),o=t.buffer;o[n++]=e,o[n]=r}}function i(e){return function(t,r){var n=t.reserve(3),o=t.buffer;o[n++]=e,o[n++]=r>>>8,o[n]=r}}function s(e){return function(t,r){var n=t.reserve(5),o=t.buffer;o[n++]=e,o[n++]=r>>>24,o[n++]=r>>>16,o[n++]=r>>>8,o[n]=r}}function a(e,t,r,n){return function(o,i){var s=o.reserve(t+1);o.buffer[s++]=e,r.call(o.buffer,i,s,n)}}function u(e,t){new p(this,t,e)}function c(e,t){new g(this,t,e)}function f(e,t){h.write(this,e,t,!1,23,4)}function l(e,t){h.write(this,e,t,!1,52,8)}var h=e("ieee754"),d=e("int64-buffer"),p=d.Uint64BE,g=d.Int64BE,y=e("./write-uint8").uint8,m=e("./bufferish"),_=m.global,v=m.hasBuffer&&"TYPED_ARRAY_SUPPORT"in _&&!_.TYPED_ARRAY_SUPPORT,b=m.hasBuffer&&_.prototype||{};r.getWriteToken=function(e){return e&&e.uint8array?function(){var e=n();return e[202]=a(202,4,f),e[203]=a(203,8,l),e}():v||m.hasBuffer&&e&&e.safe?function(){var e=y.slice();return e[196]=a(196,1,_.prototype.writeUInt8),e[197]=a(197,2,_.prototype.writeUInt16BE),e[198]=a(198,4,_.prototype.writeUInt32BE),e[199]=a(199,1,_.prototype.writeUInt8),e[200]=a(200,2,_.prototype.writeUInt16BE),e[201]=a(201,4,_.prototype.writeUInt32BE),e[202]=a(202,4,_.prototype.writeFloatBE),e[203]=a(203,8,_.prototype.writeDoubleBE),e[204]=a(204,1,_.prototype.writeUInt8),e[205]=a(205,2,_.prototype.writeUInt16BE),e[206]=a(206,4,_.prototype.writeUInt32BE),e[207]=a(207,8,u),e[208]=a(208,1,_.prototype.writeInt8),e[209]=a(209,2,_.prototype.writeInt16BE),e[210]=a(210,4,_.prototype.writeInt32BE),e[211]=a(211,8,c),e[217]=a(217,1,_.prototype.writeUInt8),e[218]=a(218,2,_.prototype.writeUInt16BE),e[219]=a(219,4,_.prototype.writeUInt32BE),e[220]=a(220,2,_.prototype.writeUInt16BE),e[221]=a(221,4,_.prototype.writeUInt32BE),e[222]=a(222,2,_.prototype.writeUInt16BE),e[223]=a(223,4,_.prototype.writeUInt32BE),e}():n()}},{"./bufferish":8,"./write-uint8":28,ieee754:32,"int64-buffer":33}],27:[function(e,t,r){var n=e("isarray"),o=e("int64-buffer"),i=o.Uint64BE,s=o.Int64BE,a=e("./bufferish"),u=e("./bufferish-proto"),c=e("./write-token"),f=e("./write-uint8").uint8,l=e("./ext-buffer").ExtBuffer,h="undefined"!=typeof Uint8Array,d="undefined"!=typeof Map,p=[];p[1]=212,p[2]=213,p[4]=214,p[8]=215,p[16]=216,r.getWriteType=function(e){function t(e,t){if(null===t)return r(e,t);if(v(t))return b(e,t);if(n(t))return function(e,t){var r=t.length;y[r<16?144+r:r<=65535?220:221](e,r);for(var n=e.codec.encode,o=0;o<r;o++)n(e,t[o])}(e,t);if(i.isUint64BE(t))return function(e,t){y[207](e,t.toArray())}(e,t);if(s.isInt64BE(t))return function(e,t){y[211](e,t.toArray())}(e,t);var o=e.codec.getExtPacker(t);return o&&(t=o(t)),t instanceof l?function(e,t){var r=t.buffer,n=r.length,o=p[n]||(n<255?199:n<=65535?200:201);y[o](e,n),f[t.type](e),e.send(r)}(e,t):void w(e,t)}function r(e,t){y[192](e,t)}function o(e,t){var r=t.length;y[r<255?196:r<=65535?197:198](e,r),e.send(t)}function g(e,t){var r=Object.keys(t),n=r.length;y[n<16?128+n:n<=65535?222:223](e,n);var o=e.codec.encode;r.forEach((function(r){o(e,r),o(e,t[r])}))}var y=c.getWriteToken(e),m=e&&e.useraw,_=h&&e&&e.binarraybuffer,v=_?a.isArrayBuffer:a.isBuffer,b=_?function(e,t){o(e,new Uint8Array(t))}:o,w=d&&e&&e.usemap?function(e,t){if(!(t instanceof Map))return g(e,t);var r=t.size;y[r<16?128+r:r<=65535?222:223](e,r);var n=e.codec.encode;t.forEach((function(t,r,o){n(e,r),n(e,t)}))}:g;return{boolean:function(e,t){y[t?195:194](e,t)},function:r,number:function(e,t){var r=0|t;return t!==r?void y[203](e,t):void y[-32<=r&&r<=127?255&r:0<=r?r<=255?204:r<=65535?205:206:-128<=r?208:-32768<=r?209:210](e,r)},object:m?function(e,r){return v(r)?function(e,t){var r=t.length;y[r<32?160+r:r<=65535?218:219](e,r),e.send(t)}(e,r):void t(e,r)}:t,string:function(e){return function(t,r){var n=r.length,o=5+3*n;t.offset=t.reserve(o);var i=t.buffer,s=e(n),a=t.offset+s;n=u.write.call(i,r,a);var c=e(n);if(s!==c){var f=a+c-s,l=a+n;u.copy.call(i,i,f,a,l)}y[1===c?160+n:c<=3?215+c:219](t,n),t.offset+=n}}(m?function(e){return e<32?1:e<=65535?3:5}:function(e){return e<32?1:e<=255?2:e<=65535?3:5}),symbol:r,undefined:r}}},{"./bufferish":8,"./bufferish-proto":6,"./ext-buffer":17,"./write-token":26,"./write-uint8":28,"int64-buffer":33,isarray:34}],28:[function(e,t,r){function n(e){return function(t){var r=t.reserve(1);t.buffer[r]=e}}for(var o=r.uint8=new Array(256),i=0;i<=255;i++)o[i]=n(i)},{}],29:[function(e,r,n){(function(t){"use strict";function r(){return i.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function o(e,t){if(r()<t)throw new RangeError("Invalid typed array length");return i.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=i.prototype:(null===e&&(e=new i(t)),e.length=t),e}function i(e,t,r){if(!(i.TYPED_ARRAY_SUPPORT||this instanceof i))return new i(e,t,r);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return u(this,e)}return s(this,e,t,r)}function s(e,t,r,n){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,r,n){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");return t=void 0===r&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,r):new Uint8Array(t,r,n),i.TYPED_ARRAY_SUPPORT?(e=t).__proto__=i.prototype:e=c(e,t),e}(e,t,r,n):"string"==typeof t?function(e,t,r){if("string"==typeof r&&""!==r||(r="utf8"),!i.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|l(t,r),s=(e=o(e,n)).write(t,r);return s!==n&&(e=e.slice(0,s)),e}(e,t,r):function(e,t){if(i.isBuffer(t)){var r=0|f(t.length);return 0===(e=o(e,r)).length||t.copy(e,0,0,r),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||function(e){return e!=e}(t.length)?o(e,0):c(e,t);if("Buffer"===t.type&&q(t.data))return c(e,t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function a(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function u(e,t){if(a(t),e=o(e,t<0?0:0|f(t)),!i.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function c(e,t){var r=t.length<0?0:0|f(t.length);e=o(e,r);for(var n=0;n<r;n+=1)e[n]=255&t[n];return e}function f(e){if(e>=r())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r().toString(16)+" bytes");return 0|e}function l(e,t){if(i.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return x(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return D(e).length;default:if(n)return x(e).length;t=(""+t).toLowerCase(),n=!0}}function h(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return C(this,t,r);case"utf8":case"utf-8":return k(this,t,r);case"ascii":return R(this,t,r);case"latin1":case"binary":return P(this,t,r);case"base64":return E(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function d(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function p(e,t,r,n,o){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=o?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(o)return-1;r=e.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof t&&(t=i.from(t,n)),i.isBuffer(t))return 0===t.length?-1:g(e,t,r,n,o);if("number"==typeof t)return t&=255,i.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):g(e,[t],r,n,o);throw new TypeError("val must be string, number or Buffer")}function g(e,t,r,n,o){function i(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}var s,a=1,u=e.length,c=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;a=2,u/=2,c/=2,r/=2}if(o){var f=-1;for(s=r;s<u;s++)if(i(e,s)===i(t,-1===f?0:s-f)){if(-1===f&&(f=s),s-f+1===c)return f*a}else-1!==f&&(s-=s-f),f=-1}else for(r+c>u&&(r=u-c),s=r;s>=0;s--){for(var l=!0,h=0;h<c;h++)if(i(e,s+h)!==i(t,h)){l=!1;break}if(l)return s}return-1}function y(e,t,r,n){r=Number(r)||0;var o=e.length-r;n?(n=Number(n))>o&&(n=o):n=o;var i=t.length;if(i%2!=0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var s=0;s<n;++s){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))return s;e[r+s]=a}return s}function m(e,t,r,n){return L(x(t,e.length-r),e,r,n)}function _(e,t,r,n){return L(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function v(e,t,r,n){return _(e,t,r,n)}function b(e,t,r,n){return L(D(t),e,r,n)}function w(e,t,r,n){return L(function(e,t){for(var r,n,o,i=[],s=0;s<e.length&&!((t-=2)<0);++s)r=e.charCodeAt(s),n=r>>8,o=r%256,i.push(o),i.push(n);return i}(t,e.length-r),e,r,n)}function E(e,t,r){return 0===t&&r===e.length?F.fromByteArray(e):F.fromByteArray(e.slice(t,r))}function k(e,t,r){r=Math.min(e.length,r);for(var n=[],o=t;o<r;){var i,s,a,u,c=e[o],f=null,l=c>239?4:c>223?3:c>191?2:1;if(o+l<=r)switch(l){case 1:c<128&&(f=c);break;case 2:128==(192&(i=e[o+1]))&&(u=(31&c)<<6|63&i)>127&&(f=u);break;case 3:i=e[o+1],s=e[o+2],128==(192&i)&&128==(192&s)&&(u=(15&c)<<12|(63&i)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:i=e[o+1],s=e[o+2],a=e[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),o+=l}return function(e){var t=e.length;if(t<=V)return String.fromCharCode.apply(String,e);for(var r="",n=0;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=V));return r}(n)}function R(e,t,r){var n="";r=Math.min(e.length,r);for(var o=t;o<r;++o)n+=String.fromCharCode(127&e[o]);return n}function P(e,t,r){var n="";r=Math.min(e.length,r);for(var o=t;o<r;++o)n+=String.fromCharCode(e[o]);return n}function C(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var o="",i=t;i<r;++i)o+=N(e[i]);return o}function O(e,t,r){for(var n=e.slice(t,r),o="",i=0;i<n.length;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function T(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function A(e,t,r,n,o,s){if(!i.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<s)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function S(e,t,r,n){t<0&&(t=65535+t+1);for(var o=0,i=Math.min(e.length-r,2);o<i;++o)e[r+o]=(t&255<<8*(n?o:1-o))>>>8*(n?o:1-o)}function M(e,t,r,n){t<0&&(t=4294967295+t+1);for(var o=0,i=Math.min(e.length-r,4);o<i;++o)e[r+o]=t>>>8*(n?o:3-o)&255}function I(e,t,r,n,o,i){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function U(e,t,r,n,o){return o||I(e,0,r,4),j.write(e,t,r,n,23,4),r+4}function B(e,t,r,n,o){return o||I(e,0,r,8),j.write(e,t,r,n,52,8),r+8}function N(e){return e<16?"0"+e.toString(16):e.toString(16)}function x(e,t){t=t||1/0;for(var r,n=e.length,o=null,i=[],s=0;s<n;++s){if((r=e.charCodeAt(s))>55295&&r<57344){if(!o){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function D(e){return F.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Y,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function L(e,t,r,n){for(var o=0;o<n&&!(o+r>=t.length||o>=e.length);++o)t[o+r]=e[o];return o}var F=e("base64-js"),j=e("ieee754"),q=e("isarray");n.Buffer=i,n.SlowBuffer=function(e){return+e!=e&&(e=0),i.alloc(+e)},n.INSPECT_MAX_BYTES=50,i.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),n.kMaxLength=r(),i.poolSize=8192,i._augment=function(e){return e.__proto__=i.prototype,e},i.from=function(e,t,r){return s(null,e,t,r)},i.TYPED_ARRAY_SUPPORT&&(i.prototype.__proto__=Uint8Array.prototype,i.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&i[Symbol.species]===i&&Object.defineProperty(i,Symbol.species,{value:null,configurable:!0})),i.alloc=function(e,t,r){return function(e,t,r,n){return a(t),t<=0?o(e,t):void 0!==r?"string"==typeof n?o(e,t).fill(r,n):o(e,t).fill(r):o(e,t)}(null,e,t,r)},i.allocUnsafe=function(e){return u(null,e)},i.allocUnsafeSlow=function(e){return u(null,e)},i.isBuffer=function(e){return!(null==e||!e._isBuffer)},i.compare=function(e,t){if(!i.isBuffer(e)||!i.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,o=0,s=Math.min(r,n);o<s;++o)if(e[o]!==t[o]){r=e[o],n=t[o];break}return r<n?-1:n<r?1:0},i.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},i.concat=function(e,t){if(!q(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return i.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=i.allocUnsafe(t),o=0;for(r=0;r<e.length;++r){var s=e[r];if(!i.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(n,o),o+=s.length}return n},i.byteLength=l,i.prototype._isBuffer=!0,i.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)d(this,t,t+1);return this},i.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)d(this,t,t+3),d(this,t+1,t+2);return this},i.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)d(this,t,t+7),d(this,t+1,t+6),d(this,t+2,t+5),d(this,t+3,t+4);return this},i.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?k(this,0,e):h.apply(this,arguments)},i.prototype.equals=function(e){if(!i.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===i.compare(this,e)},i.prototype.inspect=function(){var e="",t=n.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),"<Buffer "+e+">"},i.prototype.compare=function(e,t,r,n,o){if(!i.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),t<0||r>e.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&t>=r)return 0;if(n>=o)return-1;if(t>=r)return 1;if(this===e)return 0;for(var s=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(t>>>=0),u=Math.min(s,a),c=this.slice(n,o),f=e.slice(t,r),l=0;l<u;++l)if(c[l]!==f[l]){s=c[l],a=f[l];break}return s<a?-1:a<s?1:0},i.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},i.prototype.indexOf=function(e,t,r){return p(this,e,t,r,!0)},i.prototype.lastIndexOf=function(e,t,r){return p(this,e,t,r,!1)},i.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-t;if((void 0===r||r>o)&&(r=o),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return y(this,e,t,r);case"utf8":case"utf-8":return m(this,e,t,r);case"ascii":return _(this,e,t,r);case"latin1":case"binary":return v(this,e,t,r);case"base64":return b(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return w(this,e,t,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},i.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var V=4096;i.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t<e&&(t=e),i.TYPED_ARRAY_SUPPORT)(r=this.subarray(e,t)).__proto__=i.prototype;else{var o=t-e;r=new i(o,void 0);for(var s=0;s<o;++s)r[s]=this[s+e]}return r},i.prototype.readUIntLE=function(e,t,r){e|=0,t|=0,r||T(e,t,this.length);for(var n=this[e],o=1,i=0;++i<t&&(o*=256);)n+=this[e+i]*o;return n},i.prototype.readUIntBE=function(e,t,r){e|=0,t|=0,r||T(e,t,this.length);for(var n=this[e+--t],o=1;t>0&&(o*=256);)n+=this[e+--t]*o;return n},i.prototype.readUInt8=function(e,t){return t||T(e,1,this.length),this[e]},i.prototype.readUInt16LE=function(e,t){return t||T(e,2,this.length),this[e]|this[e+1]<<8},i.prototype.readUInt16BE=function(e,t){return t||T(e,2,this.length),this[e]<<8|this[e+1]},i.prototype.readUInt32LE=function(e,t){return t||T(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},i.prototype.readUInt32BE=function(e,t){return t||T(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},i.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||T(e,t,this.length);for(var n=this[e],o=1,i=0;++i<t&&(o*=256);)n+=this[e+i]*o;return n>=(o*=128)&&(n-=Math.pow(2,8*t)),n},i.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||T(e,t,this.length);for(var n=t,o=1,i=this[e+--n];n>0&&(o*=256);)i+=this[e+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*t)),i},i.prototype.readInt8=function(e,t){return t||T(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},i.prototype.readInt16LE=function(e,t){t||T(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},i.prototype.readInt16BE=function(e,t){t||T(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},i.prototype.readInt32LE=function(e,t){return t||T(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},i.prototype.readInt32BE=function(e,t){return t||T(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},i.prototype.readFloatLE=function(e,t){return t||T(e,4,this.length),j.read(this,e,!0,23,4)},i.prototype.readFloatBE=function(e,t){return t||T(e,4,this.length),j.read(this,e,!1,23,4)},i.prototype.readDoubleLE=function(e,t){return t||T(e,8,this.length),j.read(this,e,!0,52,8)},i.prototype.readDoubleBE=function(e,t){return t||T(e,8,this.length),j.read(this,e,!1,52,8)},i.prototype.writeUIntLE=function(e,t,r,n){e=+e,t|=0,r|=0,n||A(this,e,t,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[t]=255&e;++i<r&&(o*=256);)this[t+i]=e/o&255;return t+r},i.prototype.writeUIntBE=function(e,t,r,n){e=+e,t|=0,r|=0,n||A(this,e,t,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[t+o]=255&e;--o>=0&&(i*=256);)this[t+o]=e/i&255;return t+r},i.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||A(this,e,t,1,255,0),i.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},i.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||A(this,e,t,2,65535,0),i.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):S(this,e,t,!0),t+2},i.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||A(this,e,t,2,65535,0),i.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):S(this,e,t,!1),t+2},i.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||A(this,e,t,4,4294967295,0),i.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):M(this,e,t,!0),t+4},i.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||A(this,e,t,4,4294967295,0),i.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):M(this,e,t,!1),t+4},i.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var o=Math.pow(2,8*r-1);A(this,e,t,r,o-1,-o)}var i=0,s=1,a=0;for(this[t]=255&e;++i<r&&(s*=256);)e<0&&0===a&&0!==this[t+i-1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+r},i.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var o=Math.pow(2,8*r-1);A(this,e,t,r,o-1,-o)}var i=r-1,s=1,a=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===a&&0!==this[t+i+1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+r},i.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||A(this,e,t,1,127,-128),i.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},i.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||A(this,e,t,2,32767,-32768),i.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):S(this,e,t,!0),t+2},i.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||A(this,e,t,2,32767,-32768),i.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):S(this,e,t,!1),t+2},i.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||A(this,e,t,4,2147483647,-2147483648),i.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):M(this,e,t,!0),t+4},i.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||A(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),i.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):M(this,e,t,!1),t+4},i.prototype.writeFloatLE=function(e,t,r){return U(this,e,t,!0,r)},i.prototype.writeFloatBE=function(e,t,r){return U(this,e,t,!1,r)},i.prototype.writeDoubleLE=function(e,t,r){return B(this,e,t,!0,r)},i.prototype.writeDoubleBE=function(e,t,r){return B(this,e,t,!1,r)},i.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var o,s=n-r;if(this===e&&r<t&&t<n)for(o=s-1;o>=0;--o)e[o+t]=this[o+r];else if(s<1e3||!i.TYPED_ARRAY_SUPPORT)for(o=0;o<s;++o)e[o+t]=this[o+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+s),t);return s},i.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===e.length){var o=e.charCodeAt(0);o<256&&(e=o)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!i.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var s;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(s=t;s<r;++s)this[s]=e;else{var a=i.isBuffer(e)?e:x(new i(e,n).toString()),u=a.length;for(s=0;s<r-t;++s)this[s+t]=a[s%u]}return this};var Y=/[^+\/0-9A-Za-z-_]/g}).call(this,void 0!==t?t:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"base64-js":30,ieee754:32,isarray:34}],30:[function(e,t,r){"use strict";function n(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===e[t-2]?2:"="===e[t-1]?1:0}function o(e){return s[e>>18&63]+s[e>>12&63]+s[e>>6&63]+s[63&e]}function i(e,t,r){for(var n,i=[],s=t;s<r;s+=3)n=(e[s]<<16)+(e[s+1]<<8)+e[s+2],i.push(o(n));return i.join("")}r.byteLength=function(e){return 3*e.length/4-n(e)},r.toByteArray=function(e){var t,r,o,i,s,c,f=e.length;s=n(e),c=new u(3*f/4-s),o=s>0?f-4:f;var l=0;for(t=0,r=0;t<o;t+=4,r+=3)i=a[e.charCodeAt(t)]<<18|a[e.charCodeAt(t+1)]<<12|a[e.charCodeAt(t+2)]<<6|a[e.charCodeAt(t+3)],c[l++]=i>>16&255,c[l++]=i>>8&255,c[l++]=255&i;return 2===s?(i=a[e.charCodeAt(t)]<<2|a[e.charCodeAt(t+1)]>>4,c[l++]=255&i):1===s&&(i=a[e.charCodeAt(t)]<<10|a[e.charCodeAt(t+1)]<<4|a[e.charCodeAt(t+2)]>>2,c[l++]=i>>8&255,c[l++]=255&i),c},r.fromByteArray=function(e){for(var t,r=e.length,n=r%3,o="",a=[],u=16383,c=0,f=r-n;c<f;c+=u)a.push(i(e,c,c+u>f?f:c+u));return 1===n?(t=e[r-1],o+=s[t>>2],o+=s[t<<4&63],o+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],o+=s[t>>10],o+=s[t>>4&63],o+=s[t<<2&63],o+="="),a.push(o),a.join("")};for(var s=[],a=[],u="undefined"!=typeof Uint8Array?Uint8Array:Array,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",f=0,l=c.length;f<l;++f)s[f]=c[f],a[c.charCodeAt(f)]=f;a["-".charCodeAt(0)]=62,a["_".charCodeAt(0)]=63},{}],31:[function(e,t,r){!function(e){function r(e){for(var t in s)e[t]=s[t];return e}function n(e,t){function r(e){return e!==t&&e.originalListener!==t}var s,a=this;if(arguments.length){if(t){if(s=o(a,e,!0)){if(!(s=s.filter(r)).length)return n.call(a,e);a[i][e]=s}}else if((s=a[i])&&(delete s[e],!Object.keys(s).length))return n.call(a)}else delete a[i];return a}function o(e,t,r){if(!r||e[i]){var n=e[i]||(e[i]={});return n[t]||(n[t]=[])}}void 0!==t&&(t.exports=e);var i="listeners",s={on:function(e,t){return o(this,e).push(t),this},once:function(e,t){function r(){n.call(i,e,r),t.apply(this,arguments)}var i=this;return r.originalListener=t,o(i,e).push(r),i},off:n,emit:function(e,t){function r(e){e.call(s)}function n(e){e.call(s,t)}function i(e){e.apply(s,c)}var s=this,a=o(s,e,!0);if(!a)return!1;var u=arguments.length;if(1===u)a.forEach(r);else if(2===u)a.forEach(n);else{var c=Array.prototype.slice.call(arguments,1);a.forEach(i)}return!!a.length}};r(e.prototype),e.mixin=r}((function e(){if(!(this instanceof e))return new e}))},{}],32:[function(e,t,r){r.read=function(e,t,r,n,o){var i,s,a=8*o-n-1,u=(1<<a)-1,c=u>>1,f=-7,l=r?o-1:0,h=r?-1:1,d=e[t+l];for(l+=h,i=d&(1<<-f)-1,d>>=-f,f+=a;f>0;i=256*i+e[t+l],l+=h,f-=8);for(s=i&(1<<-f)-1,i>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=h,f-=8);if(0===i)i=1-c;else{if(i===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),i-=c}return(d?-1:1)*s*Math.pow(2,i-n)},r.write=function(e,t,r,n,o,i){var s,a,u,c=8*i-o-1,f=(1<<c)-1,l=f>>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:i-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,o),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,o),s=0));o>=8;e[r+d]=255&a,d+=p,a/=256,o-=8);for(s=s<<o|a,c+=o;c>0;e[r+d]=255&s,d+=p,s/=256,c-=8);e[r+d-p]|=128*g}},{}],33:[function(e,t,r){(function(e){!function(t){function r(e,r,v){function E(e,t,r,n){return this instanceof E?function(e,t,r,n,o){y&&m&&(t instanceof m&&(t=new y(t)),n instanceof m&&(n=new y(n))),t||r||n||d?(s(t,r)||(o=r,n=t,r=0,t=new(d||Array)(8)),e.buffer=t,e.offset=r|=0,p!==typeof n&&("string"==typeof n?function(e,t,r,n){var o=0,i=r.length,s=0,a=0;"-"===r[0]&&o++;for(var u=o;o<i;){var c=parseInt(r[o++],n);if(!(c>=0))break;a=a*n+c,s=s*n+Math.floor(a/b),a%=b}u&&(s=~s,a?a=b-a:s++),R(e,t+C,s),R(e,t+O,a)}(t,r,n,o||10):s(n,o)?a(t,r,n,o):"number"==typeof o?(R(t,r+C,n),R(t,r+O,o)):n>0?I(t,r,n):n<0?U(t,r,n):a(t,r,_,0))):e.buffer=u(_,0)}(this,e,t,r,n):new E(e,t,r,n)}function k(){var e=this.buffer,t=this.offset,r=P(e,t+C),n=P(e,t+O);return v||(r|=0),r?r*b+n:n}function R(e,t,r){e[t+M]=255&r,r>>=8,e[t+S]=255&r,r>>=8,e[t+A]=255&r,r>>=8,e[t+T]=255&r}function P(e,t){return e[t+T]*w+(e[t+A]<<16)+(e[t+S]<<8)+e[t+M]}var C=r?0:4,O=r?4:0,T=r?0:3,A=r?1:2,S=r?2:1,M=r?3:0,I=r?c:l,U=r?f:h,B=E.prototype,N="is"+e,x="_"+N;return B.buffer=void 0,B.offset=0,B[x]=!0,B.toNumber=k,B.toString=function(e){var t=this.buffer,r=this.offset,n=P(t,r+C),o=P(t,r+O),i="",s=!v&&2147483648&n;for(s&&(n=~n,o=b-o),e=e||10;;){var a=n%e*b+o;if(n=Math.floor(n/e),o=Math.floor(a/e),i=(a%e).toString(e)+i,!n&&!o)break}return s&&(i="-"+i),i},B.toJSON=k,B.toArray=n,g&&(B.toBuffer=o),y&&(B.toArrayBuffer=i),E[N]=function(e){return!(!e||!e[x])},t[e]=E,E}function n(e){var t=this.buffer,r=this.offset;return d=null,!1!==e&&0===r&&8===t.length&&v(t)?t:u(t,r)}function o(t){var r=this.buffer,n=this.offset;if(d=g,!1!==t&&0===n&&8===r.length&&e.isBuffer(r))return r;var o=new g(8);return a(o,0,r,n),o}function i(e){var t=this.buffer,r=this.offset,n=t.buffer;if(d=y,!1!==e&&0===r&&n instanceof m&&8===n.byteLength)return n;var o=new y(8);return a(o,0,t,r),o.buffer}function s(e,t){var r=e&&e.length;return t|=0,r&&t+8<=r&&"string"!=typeof e[t]}function a(e,t,r,n){t|=0,n|=0;for(var o=0;o<8;o++)e[t++]=255&r[n++]}function u(e,t){return Array.prototype.slice.call(e,t,t+8)}function c(e,t,r){for(var n=t+8;n>t;)e[--n]=255&r,r/=256}function f(e,t,r){var n=t+8;for(r++;n>t;)e[--n]=255&-r^255,r/=256}function l(e,t,r){for(var n=t+8;t<n;)e[t++]=255&r,r/=256}function h(e,t,r){var n=t+8;for(r++;t<n;)e[t++]=255&-r^255,r/=256}var d,p="undefined",g=p!==typeof e&&e,y=p!==typeof Uint8Array&&Uint8Array,m=p!==typeof ArrayBuffer&&ArrayBuffer,_=[0,0,0,0,0,0,0,0],v=Array.isArray||function(e){return!!e&&"[object Array]"==Object.prototype.toString.call(e)},b=4294967296,w=16777216;r("Uint64BE",!0,!0),r("Int64BE",!0,!1),r("Uint64LE",!1,!0),r("Int64LE",!1,!1)}("object"==typeof r&&"string"!=typeof r.nodeName?r:this||{})}).call(this,e("buffer").Buffer)},{buffer:29}],34:[function(e,t,r){var n={}.toString;t.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},{}]},{},[1])(1)}).call(this,r(3))},function(module,exports,__webpack_require__){(function(process,global){var __WEBPACK_AMD_DEFINE_RESULT__;
|
|
19
|
+
/**
|
|
20
|
+
* [js-md5]{@link https://github.com/emn178/js-md5}
|
|
21
|
+
*
|
|
22
|
+
* @namespace md5
|
|
23
|
+
* @version 0.7.3
|
|
24
|
+
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
|
25
|
+
* @copyright Chen, Yi-Cyuan 2014-2017
|
|
26
|
+
* @license MIT
|
|
27
|
+
*/!function(){"use strict";function t(e){if(e)d[0]=d[16]=d[1]=d[2]=d[3]=d[4]=d[5]=d[6]=d[7]=d[8]=d[9]=d[10]=d[11]=d[12]=d[13]=d[14]=d[15]=0,this.blocks=d,this.buffer8=l;else if(a){var t=new ArrayBuffer(68);this.buffer8=new Uint8Array(t),this.blocks=new Uint32Array(t)}else this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.h0=this.h1=this.h2=this.h3=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0}var r="input is invalid type",e="object"==typeof window,i=e?window:{};i.JS_MD5_NO_WINDOW&&(e=!1);var s=!e&&"object"==typeof self,h=!i.JS_MD5_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node;h?i=global:s&&(i=self);var f=!i.JS_MD5_NO_COMMON_JS&&"object"==typeof module&&module.exports,o=__webpack_require__(26),a=!i.JS_MD5_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,n="0123456789abcdef".split(""),u=[128,32768,8388608,-2147483648],y=[0,8,16,24],c=["hex","array","digest","buffer","arrayBuffer","base64"],p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),d=[],l;if(a){var A=new ArrayBuffer(68);l=new Uint8Array(A),d=new Uint32Array(A)}!i.JS_MD5_NO_NODE_JS&&Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),!a||!i.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(e){return"object"==typeof e&&e.buffer&&e.buffer.constructor===ArrayBuffer});var b=function(e){return function(r){return new t(!0).update(r)[e]()}},v=function(){var e=b("hex");h&&(e=w(e)),e.create=function(){return new t},e.update=function(t){return e.create().update(t)};for(var r=0;r<c.length;++r){var n=c[r];e[n]=b(n)}return e},w=function(t){var e=eval("require('crypto')"),i=eval("require('buffer').Buffer"),s=function(n){if("string"==typeof n)return e.createHash("md5").update(n,"utf8").digest("hex");if(null==n)throw r;return n.constructor===ArrayBuffer&&(n=new Uint8Array(n)),Array.isArray(n)||ArrayBuffer.isView(n)||n.constructor===i?e.createHash("md5").update(new i(n)).digest("hex"):t(n)};return s};t.prototype.update=function(e){if(!this.finalized){var t,n=typeof e;if("string"!==n){if("object"!==n)throw r;if(null===e)throw r;if(a&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||a&&ArrayBuffer.isView(e)))throw r;t=!0}for(var o,i,s=0,u=e.length,c=this.blocks,f=this.buffer8;s<u;){if(this.hashed&&(this.hashed=!1,c[0]=c[16],c[16]=c[1]=c[2]=c[3]=c[4]=c[5]=c[6]=c[7]=c[8]=c[9]=c[10]=c[11]=c[12]=c[13]=c[14]=c[15]=0),t)if(a)for(i=this.start;s<u&&i<64;++s)f[i++]=e[s];else for(i=this.start;s<u&&i<64;++s)c[i>>2]|=e[s]<<y[3&i++];else if(a)for(i=this.start;s<u&&i<64;++s)(o=e.charCodeAt(s))<128?f[i++]=o:o<2048?(f[i++]=192|o>>6,f[i++]=128|63&o):o<55296||o>=57344?(f[i++]=224|o>>12,f[i++]=128|o>>6&63,f[i++]=128|63&o):(o=65536+((1023&o)<<10|1023&e.charCodeAt(++s)),f[i++]=240|o>>18,f[i++]=128|o>>12&63,f[i++]=128|o>>6&63,f[i++]=128|63&o);else for(i=this.start;s<u&&i<64;++s)(o=e.charCodeAt(s))<128?c[i>>2]|=o<<y[3&i++]:o<2048?(c[i>>2]|=(192|o>>6)<<y[3&i++],c[i>>2]|=(128|63&o)<<y[3&i++]):o<55296||o>=57344?(c[i>>2]|=(224|o>>12)<<y[3&i++],c[i>>2]|=(128|o>>6&63)<<y[3&i++],c[i>>2]|=(128|63&o)<<y[3&i++]):(o=65536+((1023&o)<<10|1023&e.charCodeAt(++s)),c[i>>2]|=(240|o>>18)<<y[3&i++],c[i>>2]|=(128|o>>12&63)<<y[3&i++],c[i>>2]|=(128|o>>6&63)<<y[3&i++],c[i>>2]|=(128|63&o)<<y[3&i++]);this.lastByteIndex=i,this.bytes+=i-this.start,i>=64?(this.start=i-64,this.hash(),this.hashed=!0):this.start=i}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}},t.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex;e[t>>2]|=u[3&t],t>=56&&(this.hashed||this.hash(),e[0]=e[16],e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=this.bytes<<3,e[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},t.prototype.hash=function(){var e,t,r,n,o,i,s=this.blocks;this.first?t=((t=((e=((e=s[0]-680876937)<<7|e>>>25)-271733879<<0)^(r=((r=(-271733879^(n=((n=(-1732584194^2004318071&e)+s[1]-117830708)<<12|n>>>20)+e<<0)&(-271733879^e))+s[2]-1126478375)<<17|r>>>15)+n<<0)&(n^e))+s[3]-1316259209)<<22|t>>>10)+r<<0:(e=this.h0,t=this.h1,r=this.h2,t=((t+=((e=((e+=((n=this.h3)^t&(r^n))+s[0]-680876936)<<7|e>>>25)+t<<0)^(r=((r+=(t^(n=((n+=(r^e&(t^r))+s[1]-389564586)<<12|n>>>20)+e<<0)&(e^t))+s[2]+606105819)<<17|r>>>15)+n<<0)&(n^e))+s[3]-1044525330)<<22|t>>>10)+r<<0),t=((t+=((e=((e+=(n^t&(r^n))+s[4]-176418897)<<7|e>>>25)+t<<0)^(r=((r+=(t^(n=((n+=(r^e&(t^r))+s[5]+1200080426)<<12|n>>>20)+e<<0)&(e^t))+s[6]-1473231341)<<17|r>>>15)+n<<0)&(n^e))+s[7]-45705983)<<22|t>>>10)+r<<0,t=((t+=((e=((e+=(n^t&(r^n))+s[8]+1770035416)<<7|e>>>25)+t<<0)^(r=((r+=(t^(n=((n+=(r^e&(t^r))+s[9]-1958414417)<<12|n>>>20)+e<<0)&(e^t))+s[10]-42063)<<17|r>>>15)+n<<0)&(n^e))+s[11]-1990404162)<<22|t>>>10)+r<<0,t=((t+=((e=((e+=(n^t&(r^n))+s[12]+1804603682)<<7|e>>>25)+t<<0)^(r=((r+=(t^(n=((n+=(r^e&(t^r))+s[13]-40341101)<<12|n>>>20)+e<<0)&(e^t))+s[14]-1502002290)<<17|r>>>15)+n<<0)&(n^e))+s[15]+1236535329)<<22|t>>>10)+r<<0,t=((t+=((n=((n+=(t^r&((e=((e+=(r^n&(t^r))+s[1]-165796510)<<5|e>>>27)+t<<0)^t))+s[6]-1069501632)<<9|n>>>23)+e<<0)^e&((r=((r+=(e^t&(n^e))+s[11]+643717713)<<14|r>>>18)+n<<0)^n))+s[0]-373897302)<<20|t>>>12)+r<<0,t=((t+=((n=((n+=(t^r&((e=((e+=(r^n&(t^r))+s[5]-701558691)<<5|e>>>27)+t<<0)^t))+s[10]+38016083)<<9|n>>>23)+e<<0)^e&((r=((r+=(e^t&(n^e))+s[15]-660478335)<<14|r>>>18)+n<<0)^n))+s[4]-405537848)<<20|t>>>12)+r<<0,t=((t+=((n=((n+=(t^r&((e=((e+=(r^n&(t^r))+s[9]+568446438)<<5|e>>>27)+t<<0)^t))+s[14]-1019803690)<<9|n>>>23)+e<<0)^e&((r=((r+=(e^t&(n^e))+s[3]-187363961)<<14|r>>>18)+n<<0)^n))+s[8]+1163531501)<<20|t>>>12)+r<<0,t=((t+=((n=((n+=(t^r&((e=((e+=(r^n&(t^r))+s[13]-1444681467)<<5|e>>>27)+t<<0)^t))+s[2]-51403784)<<9|n>>>23)+e<<0)^e&((r=((r+=(e^t&(n^e))+s[7]+1735328473)<<14|r>>>18)+n<<0)^n))+s[12]-1926607734)<<20|t>>>12)+r<<0,t=((t+=((i=(n=((n+=((o=t^r)^(e=((e+=(o^n)+s[5]-378558)<<4|e>>>28)+t<<0))+s[8]-2022574463)<<11|n>>>21)+e<<0)^e)^(r=((r+=(i^t)+s[11]+1839030562)<<16|r>>>16)+n<<0))+s[14]-35309556)<<23|t>>>9)+r<<0,t=((t+=((i=(n=((n+=((o=t^r)^(e=((e+=(o^n)+s[1]-1530992060)<<4|e>>>28)+t<<0))+s[4]+1272893353)<<11|n>>>21)+e<<0)^e)^(r=((r+=(i^t)+s[7]-155497632)<<16|r>>>16)+n<<0))+s[10]-1094730640)<<23|t>>>9)+r<<0,t=((t+=((i=(n=((n+=((o=t^r)^(e=((e+=(o^n)+s[13]+681279174)<<4|e>>>28)+t<<0))+s[0]-358537222)<<11|n>>>21)+e<<0)^e)^(r=((r+=(i^t)+s[3]-722521979)<<16|r>>>16)+n<<0))+s[6]+76029189)<<23|t>>>9)+r<<0,t=((t+=((i=(n=((n+=((o=t^r)^(e=((e+=(o^n)+s[9]-640364487)<<4|e>>>28)+t<<0))+s[12]-421815835)<<11|n>>>21)+e<<0)^e)^(r=((r+=(i^t)+s[15]+530742520)<<16|r>>>16)+n<<0))+s[2]-995338651)<<23|t>>>9)+r<<0,t=((t+=((n=((n+=(t^((e=((e+=(r^(t|~n))+s[0]-198630844)<<6|e>>>26)+t<<0)|~r))+s[7]+1126891415)<<10|n>>>22)+e<<0)^((r=((r+=(e^(n|~t))+s[14]-1416354905)<<15|r>>>17)+n<<0)|~e))+s[5]-57434055)<<21|t>>>11)+r<<0,t=((t+=((n=((n+=(t^((e=((e+=(r^(t|~n))+s[12]+1700485571)<<6|e>>>26)+t<<0)|~r))+s[3]-1894986606)<<10|n>>>22)+e<<0)^((r=((r+=(e^(n|~t))+s[10]-1051523)<<15|r>>>17)+n<<0)|~e))+s[1]-2054922799)<<21|t>>>11)+r<<0,t=((t+=((n=((n+=(t^((e=((e+=(r^(t|~n))+s[8]+1873313359)<<6|e>>>26)+t<<0)|~r))+s[15]-30611744)<<10|n>>>22)+e<<0)^((r=((r+=(e^(n|~t))+s[6]-1560198380)<<15|r>>>17)+n<<0)|~e))+s[13]+1309151649)<<21|t>>>11)+r<<0,t=((t+=((n=((n+=(t^((e=((e+=(r^(t|~n))+s[4]-145523070)<<6|e>>>26)+t<<0)|~r))+s[11]-1120210379)<<10|n>>>22)+e<<0)^((r=((r+=(e^(n|~t))+s[2]+718787259)<<15|r>>>17)+n<<0)|~e))+s[9]-343485551)<<21|t>>>11)+r<<0,this.first?(this.h0=e+1732584193<<0,this.h1=t-271733879<<0,this.h2=r-1732584194<<0,this.h3=n+271733878<<0,this.first=!1):(this.h0=this.h0+e<<0,this.h1=this.h1+t<<0,this.h2=this.h2+r<<0,this.h3=this.h3+n<<0)},t.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,o=this.h3;return n[e>>4&15]+n[15&e]+n[e>>12&15]+n[e>>8&15]+n[e>>20&15]+n[e>>16&15]+n[e>>28&15]+n[e>>24&15]+n[t>>4&15]+n[15&t]+n[t>>12&15]+n[t>>8&15]+n[t>>20&15]+n[t>>16&15]+n[t>>28&15]+n[t>>24&15]+n[r>>4&15]+n[15&r]+n[r>>12&15]+n[r>>8&15]+n[r>>20&15]+n[r>>16&15]+n[r>>28&15]+n[r>>24&15]+n[o>>4&15]+n[15&o]+n[o>>12&15]+n[o>>8&15]+n[o>>20&15]+n[o>>16&15]+n[o>>28&15]+n[o>>24&15]},t.prototype.toString=t.prototype.hex,t.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,n=this.h3;return[255&e,e>>8&255,e>>16&255,e>>24&255,255&t,t>>8&255,t>>16&255,t>>24&255,255&r,r>>8&255,r>>16&255,r>>24&255,255&n,n>>8&255,n>>16&255,n>>24&255]},t.prototype.array=t.prototype.digest,t.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(16),t=new Uint32Array(e);return t[0]=this.h0,t[1]=this.h1,t[2]=this.h2,t[3]=this.h3,e},t.prototype.buffer=t.prototype.arrayBuffer,t.prototype.base64=function(){for(var e,t,r,n="",o=this.array(),i=0;i<15;)e=o[i++],t=o[i++],r=o[i++],n+=p[e>>>2]+p[63&(e<<4|t>>>4)]+p[63&(t<<2|r>>>6)]+p[63&r];return e=o[i],n+(p[e>>>2]+p[e<<4&63]+"==")};var _=v();f?module.exports=_:(i.md5=_,o&&(__WEBPACK_AMD_DEFINE_RESULT__=function(){return _}.call(exports,__webpack_require__,exports,module),void 0===__WEBPACK_AMD_DEFINE_RESULT__||(module.exports=__WEBPACK_AMD_DEFINE_RESULT__)))}()}).call(this,__webpack_require__(25),__webpack_require__(3))},function(e,t){var r,n,o=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(e){if(r===setTimeout)return setTimeout(e,0);if((r===i||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:i}catch(e){r=i}try{n="function"==typeof clearTimeout?clearTimeout:s}catch(e){n=s}}();var u,c=[],f=!1,l=-1;function h(){f&&u&&(f=!1,u.length?c=u.concat(c):l=-1,c.length&&d())}function d(){if(!f){var e=a(h);f=!0;for(var t=c.length;t;){for(u=c,c=[];++l<t;)u&&u[l].run();l=-1,t=c.length}u=null,f=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===s||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function p(e,t){this.fun=e,this.array=t}function g(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];c.push(new p(e,t)),1!==c.length||f||a(d)},p.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=g,o.addListener=g,o.once=g,o.off=g,o.removeListener=g,o.removeAllListeners=g,o.emit=g,o.prependListener=g,o.prependOnceListener=g,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,t){(function(t){e.exports=t}).call(this,{})},function(e,t,r){(function(e){!function(t){function r(e,r,g){function _(e,t,r,n){return this instanceof _?function(e,t,r,n,o){if(h&&d&&(t instanceof d&&(t=new h(t)),n instanceof d&&(n=new h(n))),t||r||n||c){if(!s(t,r))o=r,n=t,r=0,t=new(c||Array)(8);e.buffer=t,e.offset=r|=0,f!==typeof n&&("string"==typeof n?function(e,t,r,n){var o=0,i=r.length,s=0,a=0;"-"===r[0]&&o++;for(var u=o;o<i;){var c=parseInt(r[o++],n);if(!(c>=0))break;a=a*n+c,s=s*n+Math.floor(a/y),a%=y}u&&(s=~s,a?a=y-a:s++),b(e,t+E,s),b(e,t+k,a)}(t,r,n,o||10):s(n,o)?a(t,r,n,o):"number"==typeof o?(b(t,r+E,n),b(t,r+k,o)):n>0?T(t,r,n):n<0?A(t,r,n):a(t,r,p,0))}else e.buffer=u(p,0)}(this,e,t,r,n):new _(e,t,r,n)}function v(){var e=this.buffer,t=this.offset,r=w(e,t+E),n=w(e,t+k);return g||(r|=0),r?r*y+n:n}function b(e,t,r){e[t+O]=255&r,r>>=8,e[t+C]=255&r,r>>=8,e[t+P]=255&r,r>>=8,e[t+R]=255&r}function w(e,t){return e[t+R]*m+(e[t+P]<<16)+(e[t+C]<<8)+e[t+O]}var E=r?0:4,k=r?4:0,R=r?0:3,P=r?1:2,C=r?2:1,O=r?3:0,T=r?function(e,t,r){for(var n=t+8;n>t;)e[--n]=255&r,r/=256}:function(e,t,r){for(var n=t+8;t<n;)e[t++]=255&r,r/=256},A=r?function(e,t,r){var n=t+8;for(r++;n>t;)e[--n]=255&-r^255,r/=256}:function(e,t,r){var n=t+8;for(r++;t<n;)e[t++]=255&-r^255,r/=256},S=_.prototype,M="is"+e,I="_"+M;return S.buffer=void 0,S.offset=0,S[I]=!0,S.toNumber=v,S.toString=function(e){var t=this.buffer,r=this.offset,n=w(t,r+E),o=w(t,r+k),i="",s=!g&&2147483648&n;for(s&&(n=~n,o=y-o),e=e||10;;){var a=n%e*y+o;if(n=Math.floor(n/e),o=Math.floor(a/e),i=(a%e).toString(e)+i,!n&&!o)break}return s&&(i="-"+i),i},S.toJSON=v,S.toArray=n,l&&(S.toBuffer=o),h&&(S.toArrayBuffer=i),_[M]=function(e){return!(!e||!e[I])},t[e]=_,_}function n(e){var t=this.buffer,r=this.offset;return c=null,!1!==e&&0===r&&8===t.length&&g(t)?t:u(t,r)}function o(t){var r=this.buffer,n=this.offset;if(c=l,!1!==t&&0===n&&8===r.length&&e.isBuffer(r))return r;var o=new l(8);return a(o,0,r,n),o}function i(e){var t=this.buffer,r=this.offset,n=t.buffer;if(c=h,!1!==e&&0===r&&n instanceof d&&8===n.byteLength)return n;var o=new h(8);return a(o,0,t,r),o.buffer}function s(e,t){var r=e&&e.length;return t|=0,r&&t+8<=r&&"string"!=typeof e[t]}function a(e,t,r,n){t|=0,n|=0;for(var o=0;o<8;o++)e[t++]=255&r[n++]}function u(e,t){return Array.prototype.slice.call(e,t,t+8)}var c,f="undefined",l=f!==typeof e&&e,h=f!==typeof Uint8Array&&Uint8Array,d=f!==typeof ArrayBuffer&&ArrayBuffer,p=[0,0,0,0,0,0,0,0],g=Array.isArray||function(e){return!!e&&"[object Array]"==Object.prototype.toString.call(e)},y=4294967296,m=16777216;r("Uint64BE",!0,!0),r("Int64BE",!0,!1),r("Uint64LE",!1,!0),r("Int64LE",!1,!1)}("string"!=typeof t.nodeName?t:this||{})}).call(this,r(7).Buffer)},function(e,t,r){"use strict";var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=r(2),s=r(13),a=r(0),u=r(5),c=r(14),f=c.normalizeClientOptions,l=c.sharedEndpoint,h=r(15).getSharedWorkerConfigFallbackReason,d=r(16),p=r(17),g=r(29),y=["sharing","uid","conversation","workerName","workerUrl","workerNamespace","readyTimeout","idleShutdownTimeout","compatibility"],m=function(){function e(t,r){var n,s,a=this;o(this,e),this._connectionInfo=Object.freeze(Object.assign({},r)),this._usesSharedWorker="shared"===this._connectionInfo.mode,this._config=Object.assign({},t),this._compatibility=g.validateCompatibility(t.compatibility),this._legacyTlv=g.isEnabled(this._compatibility,t.protocol),this._options=f(v(t)),this._config.conversation=d(t.conversation),this._delegate=null,this._delegateType=null,this._uid=null,this._session={status:"idle",uid:null},this._directLoginPromise=null,this._destroyed=!1,this._events=new _,this.processor=new _(this._legacyTlv?g.createPushAdapter((function(e){return a.processor.emit("CompatibilityError",e)})):null),this.promises=(n=this,(s=Object.assign({},u(n,i.prototype))).login=function(e,t,r){return arguments.length>3?Promise.reject(new TypeError("promises.login(uid, credential, timeout?)")):n.loginIfNeeded(e,t,r).then((function(e){if(e.accepted)return{accepted:!0,errorCode:e.errorCode||0};var t=new Error("RTM login rejected ("+String(e.errorCode)+")");throw t.code=e.errorCode,t.status=e.errorCode,t}))},Object.freeze(s)),void 0!==t.uid&&null!==t.uid&&this._attach(t.uid)}return n(e,[{key:"_attach",value:function(e){var t=this;if(this._assertActive(),"number"==typeof e&&(!isFinite(e)||Math.floor(e)!==e||Math.abs(e)>9007199254740991))throw b("Use a decimal string for a UID outside the safe integer range","RTM_SHARED_UID_INVALID");var r=null==e?"":String(e).trim().replace(/^0+(?=\d)/,"");if(!/^\d+$/.test(r)||/^0+$/.test(r))throw b("Provide a positive UID in login() or createClient({ uid }) before attaching","RTM_SHARED_UID_REQUIRED");if(r.length>20||20===r.length&&r>"18446744073709551615")throw b("UID exceeds the uint64 range","RTM_SHARED_UID_INVALID");if(null!==this._uid&&this._uid!==r)throw b("This client is bound to UID "+this._uid+"; create another client for UID "+r,"RTM_SHARED_UID_MISMATCH");if(!this._delegate){var n=this._config,o=this._usesSharedWorker?new s({workerName:n.workerName||s.createWorkerName({pid:this._options.pid,protocol:this._options.protocol,uid:r,endpoint:l(this._options),namespace:n.workerNamespace}),workerUrl:n.workerUrl,conversation:n.conversation,readyTimeout:n.readyTimeout,idleShutdownTimeout:n.idleShutdownTimeout,clientOptions:this._options}):new i(this._options);this._uid=r,this._delegate=o,this._delegateType=this._usesSharedWorker?"shared":"direct","direct"===this._delegateType&&o.on("SessionClosed",(function(){t._session={status:"idle",uid:null}})),this._events.bind(o);var a="direct"===this._delegateType?function(e,r){return p(t._config.conversation,t._options.protocol,e,r[0])}:null;this.processor.bind(o.processor,a)}return this._delegate}},{key:"_assertActive",value:function(){if(this._destroyed)throw b("RTM client has been destroyed","RTM_CLIENT_DESTROYED")}},{key:"login",value:function(e,t,r,n){var o=this;this.loginIfNeeded(e,t,n).then((function(e){"function"==typeof r&&r(e.accepted,e.errorCode)}),(function(e){var t="number"==typeof e.status?e.status:"number"==typeof e.code?e.code:a.ERROR_CODE.RTM_EC_UNKNOWN_ERROR;try{"function"==typeof r&&r(!1,t)}finally{o._usesSharedWorker&&o._events.emit("SharedWorkerError",e)}}))}},{key:"loginIfNeeded",value:function(e,t,r){try{var n=this._attach(e),o=this._uid.length>19||19===this._uid.length&&this._uid>"9223372036854775807"?a.Uint64(this._uid):a.Int64(this._uid);return this._usesSharedWorker?n.loginIfNeeded(o,t,r):this._loginDirect(n,o,t,r)}catch(e){return Promise.reject(e)}}},{key:"_loginDirect",value:function(e,t,r,n){var o=this;if("authenticated"===this._session.status)return Promise.resolve({accepted:!0,errorCode:0,reused:!0,uid:this._uid});if("connecting"===this._session.status&&this._directLoginPromise)return this._directLoginPromise;if("string"!=typeof r||0===r.length)return Promise.reject(b("This RTM UID is not logged in yet; provide its server-issued credential first.","RTM_SHARED_CREDENTIAL_REQUIRED"));this._session={status:"connecting",uid:this._uid};var i=new Promise((function(i,s){var a=!1;try{e.login(t,r,(function(e,t){a||(a=!0,o._session=e?{status:"authenticated",uid:o._uid}:{status:"idle",uid:null},i({accepted:Boolean(e),errorCode:t||0,reused:!1,uid:e?o._uid:null}))}),n)}catch(e){o._session={status:"idle",uid:null},s(e)}}));return this._directLoginPromise=i.then((function(e){return o._directLoginPromise=null,e}),(function(e){throw o._directLoginPromise=null,e})),this._directLoginPromise}},{key:"whenReady",value:function(e){try{var t=this._attach(void 0===e?this._uid:e);return this._usesSharedWorker?t.whenReady():Promise.resolve({status:this._session.status,uid:this._session.uid})}catch(e){return Promise.reject(e)}}},{key:"getSharedSession",value:function(){return"shared"===this._delegateType?this._delegate.getSharedSession():{status:this._session.status,uid:this._session.uid}}},{key:"getConnectionInfo",value:function(){return{mode:this._connectionInfo.mode,fallbackReason:this._connectionInfo.fallbackReason}}},{key:"setConversation",value:function(e,t){return this._assertActive(),e=d(e),"shared"===this._delegateType?this._delegate.setConversation(e,t):(this._config.conversation=e,"function"==typeof t&&t(null)),this}},{key:"on",value:function(e,t){return this._events.on(e,t),this}},{key:"off",value:function(e,t){return this._events.off(e,t),this}},{key:"removeEvent",value:function(){return this._events.removeEvent.apply(this._events,arguments),this}},{key:"emit",value:function(){this._events.emit.apply(this._events,arguments)}},{key:"listenerCount",value:function(e){return this._events.listenerCount(e)}},{key:"close",value:function(){this._assertActive(),this._delegate&&this._delegate.close()}},{key:"startAutoReconnect",value:function(){this._assertActive(),this._delegate&&this._delegate.startAutoReconnect()}},{key:"destroy",value:function(){if(!this._destroyed){this._destroyed=!0;try{this._delegate&&this._delegate.destroy()}finally{this._events.clear(),this.processor.clear()}}}},{key:"_invoke",value:function(e,t){var r=this;try{if(this._assertActive(),!this._delegate)throw b("Call login() before "+e+"()","RTM_SHARED_UID_REQUIRED")}catch(e){var n=t.slice().reverse().find((function(e){return"function"==typeof e}));if(n)return void n(e,null);throw e}return this._legacyTlv?g.invoke(e,t,this._delegate,this._options.protocol,-1,(function(e){return r.processor.emit("CompatibilityError",e)})):this._delegate[e].apply(this._delegate,t)}}]),e}(),_=function(){function e(t){o(this,e),this._listeners=Object.create(null),this._bindings=Object.create(null),this._target=null,this._filter=null,this._eventAdapter=t||null}return n(e,[{key:"bind",value:function(e,t){var r=this;this._target=e,this._filter="function"==typeof t?t:null,Object.keys(this._listeners).forEach((function(e){r._listeners[e].forEach((function(t){return r._bind(e,t)}))}))}},{key:"_bind",value:function(e,t){var r=this,n=this._eventAdapter&&this._eventAdapter.bind(e,t);if(n&&n.local){(this._bindings[e]||(this._bindings[e]=[])).push({callback:t,local:!0})}else{var o=n?n.type:e,i=n?n.callback:t,s=this._filter?function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];r._filter(o,t)&&i.apply(null,t)}:i;(this._bindings[e]||(this._bindings[e]=[])).push({callback:t,sourceType:o,wrapped:s}),this._target.on(o,s)}}},{key:"_unbind",value:function(e,t){var r=this,n=this._bindings[e]||[];n.slice().forEach((function(e){void 0!==t&&t!==e.callback||(e.local||("function"!=typeof r._target.listenerCount||r._target.listenerCount(e.sourceType)>0)&&r._target.removeEvent(e.sourceType,e.wrapped),n.splice(n.indexOf(e),1))})),n.length||delete this._bindings[e]}},{key:"on",value:function(e,t){if("function"!=typeof t)return this;this._eventAdapter&&"function"==typeof this._eventAdapter.validate&&this._eventAdapter.validate(e);var r=this._listeners[e]||(this._listeners[e]=[]);return-1===r.indexOf(t)&&(r.push(t),this._target&&this._bind(e,t)),this}},{key:"off",value:function(e,t){var r=this,n=this._listeners[e]||[];return n.slice().forEach((function(o){void 0!==t&&o!==t||(r._target&&r._unbind(e,o),n.splice(n.indexOf(o),1))})),n.length||delete this._listeners[e],this}},{key:"removeEvent",value:function(e,t){var r=this;return arguments.length?this.off(e,t):(Object.keys(this._listeners).forEach((function(e){return r.off(e)})),this)}},{key:"emit",value:function(e){var t=Array.prototype.slice.call(arguments,1);(this._listeners[e]||[]).slice().forEach((function(e){return e.apply(null,t)}))}},{key:"listenerCount",value:function(e){return(this._listeners[e]||[]).length}},{key:"clear",value:function(){var e=this;this._target&&Object.keys(this._bindings).forEach((function(t){return e._unbind(t)})),this._target=null,this._filter=null,this._listeners=Object.create(null),this._bindings=Object.create(null)}}]),e}();function v(e){var t=Object.assign({},e);return y.forEach((function(e){delete t[e]})),t}function b(e,t){var r=new Error(e);return r.code=t,r}Object.getOwnPropertyNames(i.prototype).forEach((function(e){"constructor"===e||"_"===e.charAt(0)||Object.prototype.hasOwnProperty.call(m.prototype,e)||"function"==typeof Object.getOwnPropertyDescriptor(i.prototype,e).value&&(m.prototype[e]=function(){return this._invoke(e,Array.prototype.slice.call(arguments))})})),e.exports=function(e){var t=Object.assign({},e||{});if(t.compatibility=g.validateCompatibility(t.compatibility),void 0===t.protocol&&(t.protocol="fpnn"),void 0!==t.sharing&&"boolean"!=typeof t.sharing)throw new TypeError("sharing must be a boolean");var r=f(v(t)),n="shared",o=null;return!1===t.sharing?n="direct":"function"!=typeof SharedWorker?(n="direct",o="SharedWorker is unavailable in this runtime"):(o=h(r))&&(n="direct"),new m(t,{mode:n,fallbackReason:o})}},function(e,t,r){"use strict";var n="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};var o=r(0),i=r(11),s={login:"auth",bye:"bye",getServerTime:"getservertime",addAttrs:"addattrs",getAttrs:"getattrs",addDebugLog:"adddebuglog",getOnlineUsers:"getonlineusers",setUserInfo:"setuserinfo",getUserInfo:"getuserinfo",getUserOpenInfo:"getuseropeninfo",setTranslationLanguage:"setlang",dataSet:"dataset",dataGet:"dataget",dataDelete:"datadel",addBlacks:"addblacks",deleteBlacks:"delblacks",getBlacks:"getblacks",addGroupMembers:"addgroupmembers",deleteGroupMembers:"delgroupmembers",getGroupMembers:"getgroupmembers",getGroupCount:"getgroupcount",getUserGroups:"getusergroups",enterRoom:"enterroom",enterRooms:"enterrooms",leaveRoom:"leaveroom",getUserRooms:"getuserrooms",getRoomMembers:"getroommembers",getRoomCount:"getroomcount",setGroupInfo:"setgroupinfo",getGroupInfo:"getgroupinfo",getGroupOpenInfo:"getgroupopeninfo",getGroupsOpenInfo:"getgroupsopeninfo",setRoomInfo:"setroominfo",setRoomProfile:"setroominfo",getRoomInfo:"getroominfo",getRoomOpenInfo:"getroomopeninfo",getRoomsOpenInfo:"getroomsopeninfo",getUserRoomsAndLastMessage:"getuserroomsandlastmsg",sendMessage:"sendmsg",sendMessages:"sendmsgs",sendGroupMessage:"sendgroupmsg",sendRoomMessage:"sendroommsg",sendChat:"sendmsg",sendAudio:"sendmsg",sendCmd:"sendmsg",sendGroupChat:"sendgroupmsg",sendGroupAudio:"sendgroupmsg",sendGroupCmd:"sendgroupmsg",sendRoomChat:"sendroommsg",sendRoomAudio:"sendroommsg",sendRoomCmd:"sendroommsg",getUnreadMessage:"getunread",getP2PUnreadMessageNum:"getp2punread",getGroupUnreadMessageNum:"getgroupunread",cleanUnreadMessage:"cleanunread",setSessionRead:"setsessionread",getSession:"getsession",getGroupMessage:"getgroupmsg",getRoomMessage:"getroommsg",getBroadcastMessage:"getbroadcastmsg",getP2PMessage:"getp2pmsg",getGroupChat:"getgroupmsg",getRoomChat:"getroommsg",getBroadcastChat:"getbroadcastmsg",getP2PChat:"getp2pmsg",getP2PMessageByMessageId:"getp2pmsgbymessageid",getGroupMessageByMessageId:"getgroupmsgbymessageid",getRoomMessageByMessageId:"getroommsgbymessageid",getBroadcastMessageByMessageId:"getbroadcastmsgbymessageid",getP2PMessageCount:"getp2pmsgcount",getGroupMessageCount:"getgroupmsgcount",getRoomMessageCount:"getroommsgcount",getBroadcastMessageCount:"getbroadcastmsgcount",getMessage:"getmsg",getChat:"getmsg",deleteMessage:"delmsg",deleteChat:"delmsg",translate:"translate",textCheck:"tcheck",getP2PConversationList:"getp2pconversationlist",getP2PUnreadConversationList:"getp2punreadconversationlist",getGroupConversationList:"getgroupconversationlist",getGroupUnreadConversationList:"getgroupunreadconversationlist",getUnreadConversationList:"getunreadconversationlist",removeSession:"removesession"},a={sendMessage:4,sendMessages:4,sendGroupMessage:4,sendRoomMessage:4,sendChat:3,sendAudio:3,sendCmd:3,sendGroupChat:3,sendGroupAudio:3,sendGroupCmd:3,sendRoomChat:3,sendRoomAudio:3,sendRoomCmd:3,sendFile:3,sendGroupFile:3,sendRoomFile:3},u=new Set(Object.keys(a)),c={sendMessage:{values:[0,4]},sendMessages:{values:[4],arrays:[0]},sendGroupMessage:{values:[0,4]},sendRoomMessage:{values:[0,4]},getP2PUnreadMessageNum:{arrays:[0],values:[1]},getGroupUnreadMessageNum:{arrays:[0],values:[1]},setSessionRead:{values:[1,2]},getGroupMessage:{values:[0,3,4,5]},getRoomMessage:{values:[0,3,4,5]},getBroadcastMessage:{values:[2,3,4]},getP2PMessage:{values:[0,3,4,5]},getP2PMessageByMessageId:{values:[0,1,4,5]},getGroupMessageByMessageId:{values:[0,1,4,5]},getRoomMessageByMessageId:{values:[0,1,4,5]},getBroadcastMessageByMessageId:{values:[0,3,4]},getP2PMessageCount:{values:[0,1,2]},getGroupMessageCount:{values:[0,1,2]},getRoomMessageCount:{values:[0,1,2]},getBroadcastMessageCount:{values:[0,1]},getGroupsOpenInfo:{arrays:[0]},getRoomsOpenInfo:{arrays:[0]},getRoomMembers:{values:[0]},getRoomCount:{arrays:[0]},getGroupMembers:{values:[0]},getGroupCount:{values:[0]},addGroupMembers:{values:[0],arrays:[1]},deleteGroupMembers:{values:[0],arrays:[1]},enterRoom:{values:[0]},enterRooms:{arrays:[0]},leaveRoom:{values:[0]},getOnlineUsers:{arrays:[0]},getUserOpenInfo:{arrays:[0]},deleteMessage:{values:[0,1,2]},getMessage:{values:[0,1,2]},deleteChat:{values:[0,1,2]},getChat:{values:[0,1,2]},setGroupInfo:{values:[0]},getGroupInfo:{values:[0]},getGroupOpenInfo:{values:[0]},setRoomInfo:{values:[0]},setRoomProfile:{values:[0]},getRoomInfo:{values:[0]},getRoomOpenInfo:{values:[0]},addBlacks:{arrays:[0]},deleteBlacks:{arrays:[0]},sendChat:{values:[0,3]},sendAudio:{values:[0,3]},sendCmd:{values:[0,3]},sendGroupChat:{values:[0,3]},sendGroupAudio:{values:[0,3]},sendGroupCmd:{values:[0,3]},sendRoomChat:{values:[0,3]},sendRoomAudio:{values:[0,3]},sendRoomCmd:{values:[0,3]},getGroupChat:{values:[0,3,4,5]},getRoomChat:{values:[0,3,4,5]},getP2PChat:{values:[0,3,4,5]},getBroadcastChat:{values:[2,3,4]},getP2PConversationList:{values:[0]},getP2PUnreadConversationList:{values:[0]},getGroupConversationList:{values:[0]},getGroupUnreadConversationList:{values:[0]},getUnreadConversationList:{values:[1]},removeSession:{values:[0]}},f=new Set(["getGroupMessage","getRoomMessage","getBroadcastMessage","getP2PMessage","getGroupChat","getRoomChat","getBroadcastChat","getP2PChat","getP2PMessageByMessageId","getGroupMessageByMessageId","getRoomMessageByMessageId","getBroadcastMessageByMessageId"]),l={getP2PMessage:"direct",getP2PChat:"direct",getP2PMessageByMessageId:"direct",getGroupMessage:"group",getGroupChat:"group",getGroupMessageByMessageId:"group",getRoomMessage:"room",getRoomChat:"room",getRoomMessageByMessageId:"room",getBroadcastMessage:"broadcast",getBroadcastChat:"broadcast",getBroadcastMessageByMessageId:"broadcast"},h={"event.direct":{category:"direct",id:"recipient",events:{message:o.SERVER_PUSH.recvMessage,file:o.SERVER_PUSH.recvFile,chat:o.SERVER_PUSH.recvChat,cmd:o.SERVER_PUSH.recvCmd}},"event.group":{category:"group",id:"group_ref",events:{message:o.SERVER_PUSH.recvGroupMessage,file:o.SERVER_PUSH.recvGroupFile,chat:o.SERVER_PUSH.recvGroupChat,cmd:o.SERVER_PUSH.recvGroupCmd}},"event.room":{category:"room",id:"room_ref",events:{message:o.SERVER_PUSH.recvRoomMessage,file:o.SERVER_PUSH.recvRoomFile,chat:o.SERVER_PUSH.recvRoomChat,cmd:o.SERVER_PUSH.recvRoomCmd}},"event.broadcast":{category:"broadcast",id:null,events:{message:o.SERVER_PUSH.recvBroadcastMessage,file:o.SERVER_PUSH.recvBroadcastFile,chat:o.SERVER_PUSH.recvBroadcastChat,cmd:o.SERVER_PUSH.recvBroadcastCmd}},"event.kicked":{category:"kicked",id:null,events:{message:o.SERVER_PUSH.kickOut}},"event.room_removed":{category:"room_removed",id:"room_ref",events:{message:o.SERVER_PUSH.kickOutRoom}}},d=new Set(Object.keys(h)),p=new Set([o.SERVER_PUSH.recvAudio,o.SERVER_PUSH.recvGroupAudio,o.SERVER_PUSH.recvRoomAudio,o.SERVER_PUSH.recvBroadcastAudio]),g=function(e){function t(e,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.name="RTMCompatibilityError",n.code=r&&r.code||"RTM_COMPATIBILITY_MAPPING_FAILED",n.method=r&&r.method,n.protocol=r&&r.protocol,n.compatibility="legacy-rtm",r&&void 0!==r.cause&&(n.cause=r.cause),n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,Error),t}();function y(e){if("string"!=typeof e||!/^-?\d+$/.test(e))return e;var t="-"===e.charAt(0),r=(t?e.slice(1):e).replace(/^0+/,"")||"0",n=t?"9223372036854775808":"9223372036854775807";return r.length>n.length||r.length===n.length&&r>n?e:o.Int64(e)}function m(e,t,r){if(w(r,e),!t)throw e;t(e,null)}function _(e,t,r,n){if(null==t)return t;if(u.has(e))return function(e,t,r){var n=v(r[a[e]],e);if(t&&Object.prototype.hasOwnProperty.call(t,"error"))return{mid:n,error:t.error};if(!I(t))throw new g("Cannot map "+e+" result to the legacy RTM response shape.",{method:e,protocol:"tlv-v1"});var o=I(t.payload)?Object.assign({},t.payload):Object.assign({},t),i=void 0!==t.message_ref?t.message_ref:o.message_ref,s=o.time_ms;delete o.message_ref,delete o.time_ms,void 0!==s&&(o.mtime=s);return{mid:n||i,payload:o}}(e,t,r);var o=s[e],c=o&&i.ROUTES[o],h=c&&c.response&&I(t)?function(e,t,r,n){var o=Object.assign({},t);return Object.keys(r).forEach((function(t){var i=r[t];if(t!==i&&Object.prototype.hasOwnProperty.call(o,i)){if(Object.prototype.hasOwnProperty.call(o,t))throw new g("Cannot map "+e+' response: both "'+t+'" and "'+i+'" are present.',{method:e,protocol:n});o[t]=o[i],delete o[i]}})),o}(e,t,c.response,n):t;if(!I(h))return h;if(h=Object.assign({},h),f.has(e)&&Array.isArray(h.msgs)){var d=l[e];h.msgs=h.msgs.map((function(t){return k(t,d,e,n)}))}if("getMessage"!==e&&"getChat"!==e||(h=function(e,t,r){var n=Object.assign({},e);void 0!==n.id&&(n.id=A(n.id,"id",t,r));void 0!==n.mid&&(n.mid=A(n.mid,"mid",t,r));void 0!==n.mtime&&(n.mtime=A(n.mtime,"mtime",t,r));void 0!==n.from&&(n.from=A(n.from,"from",t,r));void 0!==n.msg&&(n.msg=C(n.msg));return n}(h,e,n)),"getUserRoomsAndLastMessage"===e&&I(h.rooms)){var p={};Object.keys(h.rooms).forEach((function(t){p[t]=k(h.rooms[t],"room",e,n)})),h.rooms=p}if("getP2PConversationList"===e||"getP2PUnreadConversationList"===e||"getGroupConversationList"===e||"getGroupUnreadConversationList"===e){var y=e.startsWith("getGroup")?"group":"direct";Array.isArray(h.msgs)&&(h.msgs=h.msgs.map((function(t){return k(t,y,e,n)})))}return"getUnreadConversationList"===e&&(Array.isArray(h.p2pMsgs)&&(h.p2pMsgs=h.p2pMsgs.map((function(t){return k(t,"direct",e,n)}))),Array.isArray(h.groupMsgs)&&(h.groupMsgs=h.groupMsgs.map((function(t){return k(t,"group",e,n)})))),h}function v(e,t){return null==e||""===String(e)||/^[+-]?0+$/.test(String(e))?b(t):e}function b(e){var t="undefined"!=typeof globalThis?globalThis.crypto:null;if(!t||"function"!=typeof t.getRandomValues)throw new g("crypto.getRandomValues() is required to generate legacy RTM message IDs.",{method:e,protocol:"tlv-v1",code:"RTM_COMPATIBILITY_UNSUPPORTED"});var r=new Uint32Array(2);return t.getRandomValues(r),r[0]=2147483647&r[0],0===r[0]&&0===r[1]&&(r[1]=1),o.Int64(function(e,t){var r=[e>>>16,65535&e,t>>>16,65535&t],n="";for(;r.some(Boolean);){for(var o=0,i=0;i<r.length;i+=1){var s=65536*o+r[i];r[i]=Math.floor(s/10),o=s%10}n=String(o)+n}return n||"0"}(r[0],r[1]))}function w(e,t){if("function"==typeof e)try{e(t)}catch(e){}}function E(e){if(e===o.SERVER_PUSH.kickOut)return"event.kicked";if(e===o.SERVER_PUSH.kickOutRoom)return"event.room_removed";for(var t=Object.keys(h),r=function(r){var n=t[r],o=h[n];if(o&&o.events&&Object.keys(o.events).some((function(t){return o.events[t]===e})))return{v:n}},i=0;i<t.length;i+=1){var s=r(i);if("object"===(void 0===s?"undefined":n(s)))return s.v}return null}function k(e,t,r,n){if(!Array.isArray(e)){if(!I(e))throw new g("Cannot map "+r+" history row: expected a tuple or message object.",{method:r,protocol:n});return Object.assign({},e)}if(8!==e.length)throw new g("Cannot map "+r+" history row: expected an 8-field tuple.",{method:r,protocol:n});var o,i={id:A(e[0],"history.id",r,n),mtype:Number(S(e[2],"history.kind",r,n)),mid:A(e[3],"history.message_ref",r,n),deleted:e[4],msg:R(e[5],Number(S(e[2],"history.kind",r,n))),binary:(o=e[5],C(o)),attrs:R(e[6],0),mtime:A(e[7],"history.time_ms",r,n)};return"direct"===t?i.direction=Number(S(e[1],"history.direction",r,n)):i.from=A(e[1],"history.sender",r,n),i}function R(e,t){if("string"==typeof e)return e;var r=O(e);if(r)try{if("function"!=typeof TextDecoder)return;return new TextDecoder("utf-8",{fatal:!0}).decode(r)}catch(e){return}}function P(e){if("string"==typeof e||null==e)return e;var t=R(e);return void 0===t?C(e):t}function C(e,t){var r=O(e);if(r)return T(r);if(e instanceof ArrayBuffer)return e.slice(0);if(!e||"object"!==(void 0===e?"undefined":n(e)))return e;if(e.buffer&&"number"==typeof e.offset&&"function"==typeof e.toString)return e;var o=t||new Map;if(o.has(e))return o.get(e);if(Array.isArray(e)){var i=[];return o.set(e,i),e.forEach((function(e){return i.push(C(e,o))})),i}var s=Object.create(null===Object.getPrototypeOf(e)?null:Object.prototype);return o.set(e,s),Object.keys(e).forEach((function(t){s[t]=C(e[t],o)})),s}function O(e){return e instanceof ArrayBuffer?new Uint8Array(e):ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):null}function T(e){return new Uint8Array(e)}function A(e,t,r,n){var i=S(e,t,r,n);return o.Int64(i)}function S(e,t,r,n){if(e&&"function"==typeof e.toString){var o=e.toString();if(/^-?\d+$/.test(o))return o}if("number"==typeof e&&Number.isSafeInteger(e))return String(e);throw new g("Cannot map "+r+": "+t+" is not an exact integer.",{method:r,protocol:n||"tlv-v1"})}function M(e,t,r){if(e instanceof g)return e;var n=new g("Failed to adapt legacy RTM "+t+" contract: "+(e&&e.message?e.message:String(e)),{method:t,protocol:r,cause:e,code:"RTM_COMPATIBILITY_MAPPING_FAILED"});return e&&e.stack&&(n.stack=e.stack+"\nCaused by: "+n.stack),n}function I(e){if(!e||"object"!==(void 0===e?"undefined":n(e))||Array.isArray(e))return!1;var t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}e.exports={METHOD_ROUTES:s,RTMCompatibilityError:g,SEND_MID_INDEX:a,adaptResult:_,createPushAdapter:function(e){return{validate:function(t){if(d.has(t)){var r=new g('legacy Push names only; use compatibility "native" to observe raw TLV Push names.',{method:"processor.on",protocol:"tlv-v1",code:"RTM_COMPATIBILITY_UNSUPPORTED"});throw w(e,r),r}if(t===o.SERVER_PUSH.recvPing){var n=new g("TLV has no server ping Push; the SDK heartbeat is internal.",{method:"processor.on",protocol:"tlv-v1",code:"RTM_COMPATIBILITY_UNSUPPORTED"});throw w(e,n),n}if(p.has(t)){var i=new g("Legacy RTM does not emit a dedicated audio event; subscribe to pushfile.",{method:"processor.on",protocol:"tlv-v1",code:"RTM_COMPATIBILITY_UNSUPPORTED"});throw w(e,i),i}if("CompatibilityError"!==t&&!E(t)){var s=new g('Unsupported legacy RTM Processor event "'+String(t)+'".',{method:"processor.on",protocol:"tlv-v1",code:"RTM_COMPATIBILITY_UNSUPPORTED"});throw w(e,s),s}},bind:function(t,r){if("CompatibilityError"===t)return{local:!0};var n=E(t);return n?{type:n,callback:function(i){var s=void 0;try{s=function(e,t,r){var n=h[e];if(!n)return null;var i=I(t)?t:{};if("event.kicked"===e||"event.room_removed"===e){var s={};return n.id&&void 0!==i[n.id]&&(s.rid=i[n.id]),r===o.SERVER_PUSH.kickOutRoom&&void 0===s.rid?null:s}var a=Number(S(i.kind,"kind",r)),u="message";a===o.CHAT_TYPE.text?u="chat":a===o.CHAT_TYPE.cmd?u="cmd":(a===o.CHAT_TYPE.audio||a>=40&&a<=50)&&(u="file");if(n.events[u]!==r)return null;var c=C(i.payload),f=O(i.payload),l=a!==o.CHAT_TYPE.text,d={from:A(i.sender,"sender",r),mtype:a,mid:A(i.message_ref,"message_ref",r),msg:l?P(i.payload):c,attrs:P(i.extra),mtime:A(i.time_ms,"time_ms",r)};l&&f?d.binary=T(f):l&&void 0!==i.binary&&(d.binary=C(i.binary));n.id&&void 0!==i[n.id]&&(d["group"===n.category?"gid":"room"===n.category?"rid":"to"]=i[n.id]);return d}(n,i,t)}catch(r){return void w(e,M(r,"processor."+t,"tlv-v1"))}s&&r(s)}}:null}}},generateMessageId:b,isEnabled:function(e,t){return"legacy-rtm"===e&&"tlv-v1"===t},invoke:function(e,t,r,o,i,f){var l=t.slice(),h=function(e,t){if(t>=0&&"function"==typeof e[t])return t;for(var r=e.length-1;r>=0;r-=1)if("function"==typeof e[r])return r;return-1}(l,i),d=h>=0?l[h]:null,p=a[e],b=void 0,E=!1,k=void 0;function R(){try{return d.apply(null,arguments)}catch(e){throw k=e,e}}if(!s[e])return m(new g('No TLV v1 equivalent for legacy RTM method "'+e+'".',{method:e,protocol:o,code:"RTM_COMPATIBILITY_UNSUPPORTED"}),d,f);!function(e,t){var r=c[e];if(!r)return;(r.values||[]).forEach((function(e){e<t.length&&(t[e]=y(t[e]))})),(r.arrays||[]).forEach((function(e){e<t.length&&Array.isArray(t[e])&&(t[e]=t[e].map((function(e){return y(e)})))}))}(e,l);try{void 0!==p&&(b=v(l[p],e),l[p]=b)}catch(t){return m(M(t,e,o),d,f)}d&&(l[h]=function(t,r){if(!E)if(E=!0,t)R(function(e,t,r){if(!u.has(e)||!t||"object"!==(void 0===t?"undefined":n(t))||!Object.prototype.hasOwnProperty.call(t,"error"))return t;var o=Object.assign({},t);return delete o.message_ref,o.mid=void 0!==r?r:t.mid,o}(e,t,b),null);else{var i=void 0;try{i=_(e,r,l,o)}catch(t){var s=M(t,e,o);return w(f,s),void R(s,null)}R(null,i)}});try{return r[e].apply(r,l)}catch(e){if(k===e)throw e;if(d){if(E)return;return E=!0,e instanceof g?m(e,d,f):void d(e,null)}throw e instanceof g&&"function"==typeof f&&f(e),e}},toLegacyHistoryMessage:k,validateCompatibility:function(e){if(void 0===e)return"native";if("native"===e||"legacy-rtm"===e)return e;throw new TypeError('compatibility must be "native" or "legacy-rtm"')}}}])}));
|