@cg-devcenter/rtc-fpnn-webjs-sdk 1.0.0-cg.3 → 1.0.0-cg.4
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 +23 -3
- package/dist/rtm.d.ts +42 -8
- package/dist/rtm.min.js +6 -6
- package/dist/rtm.shared-worker.js +4 -4
- package/dist/rtm.vite.d.ts +1 -0
- package/dist/rtm.vite.mjs +13 -2
- package/docs/CAPABILITIES.md +11 -5
- package/docs/PROTOCOL_MIGRATION.md +146 -0
- package/docs/USAGE.md +106 -6
- package/package.json +3 -2
package/dist/rtm.min.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
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 i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.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 i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));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=10)}([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 i=r(1),o=i.msgpack,s=i.Int64BE,a=i.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},f={image:40,audio:41,video:42,file:50},c={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 o}},{key:"FILE_TYPE",get:function(){return f}},{key:"CHAT_TYPE",get:function(){return c}},{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 i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};var s=o.fpnn?o.fpnn:"undefined"==typeof window?{FPClient:function e(){throw i(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){i(this,t);var n=r instanceof Error?r:new Error(String(r||"FPNN error")),o=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 o.code=e,o.name="FPError",o.stack=n.stack||o.stack,o.error=n,o}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}}}}:r(14),a=o.msgpack||r(15),u=o.md5||r(16),f=o.Int64BE&&o.Uint64BE?{Int64BE:o.Int64BE,Uint64BE:o.Uint64BE}:r(19);e.exports={fpnn:s,msgpack:a,md5:u,Int64BE:f.Int64BE,Uint64BE:f.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 i=r(0),o=r(6),s=r(7),a=r(9),u=r(1),f=u.fpnn,c=u.md5;function l(e){var t="ws://";return this._ssl&&(t="wss://"),t+e+"/service/websocket"}function h(e){var t=f.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===i.ERROR_CODE.RTM_EC_API_FREQUENCY_LIMITED||e===i.ERROR_CODE.RTM_EC_UNKNOWN_ERROR}function d(e,t){return!e&&!h(t)}function p(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 f.FPClient({endpoint:l.call(this,this._endpoint),autoReconnect:!1,connectionTimeout:this._connectionTimeout,platformImpl:this._platformImpl});var n=this._baseClient,i=this,o=!1,a=!1,u=!1,c=!1;function h(t,r){u||(u=!0,e&&e(t,r))}"tlv-v1"===this._protocol&&(this._canReconnect=this._autoReconnect),n.on("close",(function(){n===i._baseClient&&(a||c||(c=!0,h(!1,f.FPConfig.ERROR_CODE.FPNN_EC_CORE_INVALID_CONNECTION),"tlv-v1"===i._protocol&&y.call(i)))})),n.on("error",(function(e){n===i._baseClient&&(a||m.call(i,e),o||h(!1,f.FPConfig.ERROR_CODE.FPNN_EC_CORE_INVALID_CONNECTION))})),n.on("connect",(function(){n===i._baseClient&&(o||(o=!0,i._requireClose=!1,g.call(i,(function(e,t){if(e)a=!0;else if("tlv-v1"===i._protocol&&d(e,t))i._canReconnect=!1;else if("tlv-v1"===i._protocol&&!c&&n===i._baseClient)return h(e,t),void n.close();h(e,t)}),t)))})),n.processor=this._processor,n.connect()}function g(e,t){var r=this._baseClient;if(r){var n={pid:this._pid,uid:this._uid,token:this._token,version:this._clientVersion||"WebSocket_"+i.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 o={flag:1,method:"auth",payload:i.MsgPack.encode(n,this._msgOptions)},s=this;C.call(this,r,o,(function(t,n){if(r===s._baseClient){var o=n&&("tlv-v1"===s._protocol?n.accepted:n.ok);if(o)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&&y.call(s)})),r.on("error",(function(e){r===s._baseClient&&m.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&&(m.call(s,new f.FPError(f.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,f.FPConfig.ERROR_CODE.FPNN_EC_OK));var a=!1;if(n&&!o){var u="tlv-v1"===s._protocol?i.ERROR_CODE.RTM_EC_INVALID_AUTH_TOEKN:f.FPConfig.ERROR_CODE.FPNN_EC_OK;e&&e(!1,u),"tlv-v1"===s._protocol&&m.call(s,new f.FPError(u,new Error("Gate rejected auth.login (accepted=false)")))}t&&(e&&e(!1,t.code),m.call(s,t),a="tlv-v1"===s._protocol?h(t.code):!!s._reconnectTimeout),a||(s._reconnectTimeout&&(clearTimeout(s._reconnectTimeout),s._reconnectTimeout=0),s._reconnectCount=0,s._reconnectInterval=0)}}),t)}else e&&e(!1,f.FPConfig.ERROR_CODE.FPNN_EC_CORE_INVALID_CONNECTION)}function y(){return this._reconnectTimeout&&(clearTimeout(this._reconnectTimeout),this._reconnectTimeout=0),this._checkLastPingTimerID&&(clearInterval(this._checkLastPingTimerID),this._checkLastPingTimerID=0),this._requireClose?(this.emit("SessionClosed",f.FPConfig.ERROR_CODE.FPNN_EC_OK),this._reconnectCount=0,this._reconnectInterval=0,void(this._canReconnect=!1)):this._autoReconnect?(m.call(this,new f.FPError(f.FPConfig.ERROR_CODE.FPNN_EC_CORE_UNKNOWN_ERROR,new Error("connection closed, requireClose: "+this._requireClose))),void _.call(this)):(this.emit("SessionClosed",f.FPConfig.ERROR_CODE.FPNN_EC_CORE_UNKNOWN_ERROR),this._reconnectCount=0,this._reconnectInterval=0,void(this._canReconnect=!1))}function _(){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==f.FPConfig.ERROR_CODE.FPNN_EC_OK?e?(r.emit("ReloginCompleted",!0,!1,f.FPConfig.ERROR_CODE.FPNN_EC_OK,t),m.call(r,new f.FPError(f.FPConfig.ERROR_CODE.FPNN_EC_OK,new Error("relogin successfully, reconnectCount: "+t))),r._reconnectCount=0,r._reconnectInterval=0):(r.emit("ReloginCompleted",!1,!1,i.ERROR_CODE.RTM_EC_INVALID_AUTH_TOEKN,t),r.emit("SessionClosed",i.ERROR_CODE.RTM_EC_INVALID_AUTH_TOEKN),m.call(r,new f.FPError(i.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&&d(e,n)?(r.emit("ReloginCompleted",!1,!1,n,t),r.emit("SessionClosed",n),m.call(r,new f.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&&_.call(r),m.call(r,new f.FPError(i.ERROR_CODE.RTM_EC_UNKNOWN_ERROR,new Error("relogin fail, errorCode: "+n+", reconnectCount: "+t))))}),n)}),e)}}function m(e){this.emit("ErrorRecorder",e)}function v(e){return this._md5?this._md5(e).toUpperCase():c(e).toUpperCase()}function b(e,r,n,o,s){var a=this;n&&"0"!=n.toString()||(n=k.call(this)),w.call(a,e,(function(u,c){if(u)o&&o({mid:n,error:u},null);else{var l=c.token,h=c.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 c=v.call(a,u).toLowerCase(),p=v.call(a,c+":"+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 _=new f.FPClient({endpoint:y,autoReconnect:!1,connectionTimeout:s,platformImpl:a._platformImpl});_.on("close",(function(){})),_.on("error",(function(e){var t=i.ERROR_CODE.RTM_EC_UNKNOWN_ERROR;void 0!==e.code&&(t=e.code),m.call(a,new f.FPError(t,e))})),_.on("connect",(function(){var t={token:l,sign:p,ext:d,file:u,endpoint:h};for(var r in e)t[r]=e[r];E.call(a,_,t,n,o,s)})),_.connect()}else o&&o({mid:n,error:new f.FPError(i.ERROR_CODE.RTM_EC_UNKNOWN_ERROR,new Error("no file content!"))},null)},g.readAsArrayBuffer(r)}else o&&o({mid:n,error:new f.FPError(i.ERROR_CODE.RTM_EC_UNKNOWN_ERROR,new Error(JSON.stringify(c)))},null)}}))}function w(e,t,r){var n={};for(var o in e)"mtype"!=o&&(n[o]=e[o]);var s={flag:1,method:"filetoken",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,s,t,r)}function E(e,t,r,n,o){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:i.MsgPack.encode(s,this._msgOptions)};C.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 i.Int64(""+r.mtime)),n&&n(null,{mid:s.mid,payload:r}))}),o)}function k(){++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 i.Int64(Date.now().toString()+e)}function R(e){return"tlv-v1"===this._protocol?null==e?0:e:e&&"0"!=e.toString()?e:k.call(this)}function P(e,t){if(!t)return new f.FPError(i.ERROR_CODE.RTM_EC_UNKNOWN_ERROR,Error("data is null"));if(t instanceof Error){var r=i.ERROR_CODE.RTM_EC_UNKNOWN_ERROR;return void 0!==t.code&&(r=t.code),new f.FPError(r,t)}if(e){if(t.hasOwnProperty("code")&&t.hasOwnProperty("ex"))return new f.FPError(t.code,new Error(t.ex));if(t.hasOwnProperty("status")&&t.hasOwnProperty("reason")){var n=new f.FPError(t.status,new Error(t.reason));return n.status=t.status,n.reason=t.reason,n}}return null}function C(e,t,r,n){var o=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=P.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=o?i.MsgPack.decode(e.payload,s._binaryOptions):i.MsgPack.decode(e.payload,s._msgOptions),2==e.mtype&&(n=0!=e.ss),(t=P.call(s,n,a))?void(r&&r(t,null)):void(r&&r(null,a))}(t=P.call(s,n,e))?r&&r(t,null):r&&r(null,e)}}),n):r&&r(new f.FPError(f.FPConfig.ERROR_CODE.FPNN_EC_CORE_INVALID_CONNECTION,Error("invalid connection")),null)}function O(e){if("string"==typeof e)return e;try{return new TextDecoder("utf-8",{fatal:!0}).decode(e)}catch(e){return}}var T=function(){function e(t){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),f.FPEvent.assign(this),this._protocol=t.protocol||"fpnn","fpnn"!==this._protocol&&"tlv-v1"!==this._protocol)throw new Error('options.protocol must be "fpnn" or "tlv-v1"');if(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=i.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){if(this._tlvEndpoint=t.tlvEndpoint||t.tlv_endpoint,!this._tlvEndpoint&&"string"==typeof t.endpoint&&/^wss?:\/\//i.test(t.endpoint)&&(this._tlvEndpoint=t.endpoint),!this._tlvEndpoint&&"string"==typeof t.ssl_endpoint&&/^wss?:\/\//i.test(t.ssl_endpoint)&&(this._tlvEndpoint=t.ssl_endpoint),"string"!=typeof this._tlvEndpoint||!/^wss?:\/\//i.test(this._tlvEndpoint))throw new Error("tlv-v1 requires options.tlvEndpoint as the deployment-provided ws:// or wss:// URL")}else{if(null!=this._endpoint){var r=this._endpoint.split(":");2==r.length&&"13325"==r[1]&&(this._endpoint=r[0]+":13321")}null!=t.ssl_endpoint&&(this._endpoint=t.ssl_endpoint,this._ssl=!0)}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:i.MsgPack.createCodec({int64:!0})},this._binaryOptions={codec:i.MsgPack.createCodec({int64:!0,useraw:!0})};var n=this;this._processor=new o(this);var s=function(){n._requireClose=!0,n._canReconnect=!1,"tlv-v1"!==n._protocol&&n._baseClient&&n._baseClient.close()};this._processor.on(i.SERVER_PUSH.kickOut,s),this._processor.on(i.TLV_SERVER_PUSH.kickOut,s),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),p.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:i.MsgPack.encode({},this._msgOptions)},n=this;this._requireClose=!0,C.call(this,this._baseClient,r,(function(e,r){"tlv-v1"===n._protocol?e&&(m.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:i.MsgPack.encode({},this._msgOptions)};C.call(this,this._baseClient,r,(function(e,r){e?t&&t(e,null):(r&&void 0!==r.mts&&(r.mts=new i.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,o,s,a){var u={to:e,mid:o=R.call(this,o),mtype:t,msg:r,attrs:n},f={flag:1,method:"sendmsg",payload:"tlv-v1"===this._protocol?u:i.MsgPack.encode(u,this._msgOptions)},c="tlv-v1"===this._protocol;C.call(this,this._baseClient,f,(function(e,t){e?a&&a(c?{message_ref:u.mid,error:e}:{mid:u.mid,error:e},null):(c||void 0===t.mtime||(t.mtime=new i.Int64(t.mtime)),a&&a(null,c?{message_ref:t.message_ref,payload:t}:{mid:u.mid,payload:t}))}),s)}},{key:"sendMessages",value:function(e,t,r,n,o,s,a){var u={tos:e,mid:o=R.call(this,o),mtype:t,msg:r,attrs:n},f={flag:1,method:"sendmsgs",payload:"tlv-v1"===this._protocol?u:i.MsgPack.encode(u,this._msgOptions)},c="tlv-v1"===this._protocol;C.call(this,this._baseClient,f,(function(e,t){e?a&&a(c?{message_ref:u.mid,error:e}:{mid:u.mid,error:e},null):(c||void 0===t.mtime||(t.mtime=new i.Int64(t.mtime)),a&&a(null,c?{message_ref:t.message_ref,payload:t}:{mid:u.mid,payload:t}))}),s)}},{key:"sendGroupMessage",value:function(e,t,r,n,o,s,a){var u={gid:e,mid:o=R.call(this,o),mtype:t,msg:r,attrs:n},f={flag:1,method:"sendgroupmsg",payload:"tlv-v1"===this._protocol?u:i.MsgPack.encode(u,this._msgOptions)},c="tlv-v1"===this._protocol;C.call(this,this._baseClient,f,(function(e,t){e?a&&a(c?{message_ref:u.mid,error:e}:{mid:u.mid,error:e},null):(c||void 0===t.mtime||(t.mtime=new i.Int64(t.mtime)),a&&a(null,c?{message_ref:t.message_ref,payload:t}:{mid:u.mid,payload:t}))}),s)}},{key:"sendRoomMessage",value:function(e,t,r,n,o,s,a){var u={rid:e,mid:o=R.call(this,o),mtype:t,msg:r,attrs:n},f={flag:1,method:"sendroommsg",payload:"tlv-v1"===this._protocol?u:i.MsgPack.encode(u,this._msgOptions)},c="tlv-v1"===this._protocol;C.call(this,this._baseClient,f,(function(e,t){e?a&&a(c?{message_ref:u.mid,error:e}:{mid:u.mid,error:e},null):(c||void 0===t.mtime||(t.mtime=new i.Int64(t.mtime)),a&&a(null,c?{message_ref:t.message_ref,payload:t}:{mid:u.mid,payload:t}))}),s)}},{key:"getUnreadMessage",value:function(e,t,r,n){"boolean"!=typeof t&&("function"==typeof r&&void 0===n&&(n=r,r=t),t=void 0);var o={clear:void 0!==e&&e};void 0!==t&&(o.gettime=t);var s={flag:1,method:"getunread",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,(function(e,t){if(e)n&&n(e,null);else{var r=t.p2p;if(r){var o=[];r.forEach((function(e,t){o[t]=new i.Int64(""+e)})),t.p2p=o}var s=t.group;if(s){var a=[];s.forEach((function(e,t){a[t]=new i.Int64(""+e)})),t.group=a}n&&n(null,t)}}),r)}},{key:"getP2PUnreadMessageNum",value:function(e,t,r,n,o){var s={uids:e};void 0!==t&&(s.mtime=t),void 0!==r&&(s.mtypes=r);var a={flag:1,method:"getp2punread",payload:i.MsgPack.encode(s,this._msgOptions)},u="tlv-v1"===this._protocol;C.call(this,this._baseClient,a,(function(e,t){if(e)o&&o(e,null);else if(u)o&&o(null,t);else{var r={p2p:{},ltime:{}},n=t.p2p;if(n)for(var s in n)r.p2p[new i.Int64(""+s)]=n[s];var a=t.ltime;if(a)for(var s in a)r.ltime[new i.Int64(""+s)]=new i.Int64(""+a[s]);o&&o(null,r)}}),n)}},{key:"getGroupUnreadMessageNum",value:function(e,t,r,n,o){var s={gids:e};void 0!==t&&(s.mtime=t),void 0!==r&&(s.mtypes=r);var a={flag:1,method:"getgroupunread",payload:i.MsgPack.encode(s,this._msgOptions)},u="tlv-v1"===this._protocol;C.call(this,this._baseClient,a,(function(e,t){if(e)o&&o(e,null);else if(u)o&&o(null,t);else{var r={group:{},ltime:{}},n=t.group;if(n)for(var s in n)r.group[new i.Int64(""+s)]=n[s];var a=t.ltime;if(a)for(var s in a)r.ltime[new i.Int64(""+s)]=new i.Int64(""+a[s]);o&&o(null,r)}}),n)}},{key:"cleanUnreadMessage",value:function(e,t){var r={flag:1,method:"cleanunread",payload:i.MsgPack.encode({},this._msgOptions)};C.call(this,this._baseClient,r,t,e)}},{key:"setSessionRead",value:function(e,t,r,n,o){var s={category:e,xid:t,read_seq:r},a={flag:1,method:"setsessionread",payload:i.MsgPack.encode(s,this._msgOptions)};C.call(this,this._baseClient,a,o,n)}},{key:"getSession",value:function(e,t){var r={flag:1,method:"getsession",payload:i.MsgPack.encode({},this._msgOptions)};C.call(this,this._baseClient,r,(function(e,r){if(e)t&&t(e,null);else{var n=r.p2p;if(n){var o=[];n.forEach((function(e,t){o[t]=new i.Int64(""+e)})),r.p2p=o}var s=r.group;if(s){var a=[];s.forEach((function(e,t){a[t]=new i.Int64(""+e)})),r.group=a}t&&t(null,r)}}),e)}},{key:"getGroupMessage",value:function(e,t,r,n,o,s,a,u,f){var c={gid:e,desc:t,num:r};void 0!==n&&(c.begin=n),void 0!==o&&(c.end=o),void 0!==s&&(c.lastid=s),void 0!==a&&(c.mtypes=a);var l={flag:1,method:"getgroupmsg",payload:i.MsgPack.encode(c,this._msgOptions)};C.call(this,this._baseClient,l,(function(e,t){if(e)f&&f(e,null);else{var r=t.msgs;r&&r.forEach((function(e,t){var n=e[5],o=O(e[5]),s=O(e[6]);r[t]={id:new i.Int64(""+e[0]),from:new i.Int64(""+e[1]),mtype:Number(e[2]),mid:new i.Int64(""+e[3]),deleted:e[4],msg:o,binary:n,attrs:s,mtime:new i.Int64(""+e[7])}})),f&&f(null,t)}}),u,!0)}},{key:"getRoomMessage",value:function(e,t,r,n,o,s,a,u,f){var c={rid:e,desc:t,num:r};void 0!==n&&(c.begin=n),void 0!==o&&(c.end=o),void 0!==s&&(c.lastid=s),void 0!==a&&(c.mtypes=a);var l={flag:1,method:"getroommsg",payload:i.MsgPack.encode(c,this._msgOptions)};C.call(this,this._baseClient,l,(function(e,t){if(e)f&&f(e,null);else{var r=t.msgs;r&&r.forEach((function(e,t){var n=e[5],o=O(e[5]),s=O(e[6]);r[t]={id:new i.Int64(""+e[0]),from:new i.Int64(""+e[1]),mtype:Number(e[2]),mid:new i.Int64(""+e[3]),deleted:e[4],msg:o,binary:n,attrs:s,mtime:new i.Int64(""+e[7])}})),f&&f(null,t)}}),u,!0)}},{key:"getBroadcastMessage",value:function(e,t,r,n,o,s,a,u){var f={desc:e,num:t};void 0!==r&&(f.begin=r),void 0!==n&&(f.end=n),void 0!==o&&(f.lastid=o),void 0!==s&&(f.mtypes=s);var c={flag:1,method:"getbroadcastmsg",payload:i.MsgPack.encode(f,this._msgOptions)};C.call(this,this._baseClient,c,(function(e,t){if(e)u&&u(e,null);else{var r=t.msgs;r&&r.forEach((function(e,t){var n=e[5],o=O(e[5]),s=O(e[6]);r[t]={id:new i.Int64(""+e[0]),from:new i.Int64(""+e[1]),mtype:Number(e[2]),mid:new i.Int64(""+e[3]),deleted:e[4],msg:o,binary:n,attrs:s,mtime:new i.Int64(""+e[7])}})),u&&u(null,t)}}),a,!0)}},{key:"getP2PMessage",value:function(e,t,r,n,o,s,a,u,f){var c={ouid:e,desc:t,num:r};void 0!==n&&(c.begin=n),void 0!==o&&(c.end=o),void 0!==s&&(c.lastid=s),void 0!==a&&(c.mtypes=a);var l={flag:1,method:"getp2pmsg",payload:i.MsgPack.encode(c,this._msgOptions)};C.call(this,this._baseClient,l,(function(e,t){if(e)f&&f(e,null);else{var r=t.msgs;r&&r.forEach((function(e,t){var n=e[5],o=O(e[5]),s=O(e[6]);r[t]={id:new i.Int64(""+e[0]),direction:Number(e[1]),mtype:Number(e[2]),mid:new i.Int64(""+e[3]),deleted:e[4],msg:o,binary:n,attrs:s,mtime:new i.Int64(""+e[7])}})),f&&f(null,t)}}),u,!0)}},{key:"getP2PMessageByMessageId",value:function(e,t,r,n,i,o,s,a,u){var f={ouid:e,mid:t,desc:r,num:n};void 0!==i&&(f.begin=i),void 0!==o&&(f.end=o),void 0!==s&&(f.mtypes=s),this._getMessageByAnchor("getp2pmsgbymessageid",f,!0,a,u)}},{key:"getGroupMessageByMessageId",value:function(e,t,r,n,i,o,s,a,u){var f={gid:e,mid:t,desc:r,num:n};void 0!==i&&(f.begin=i),void 0!==o&&(f.end=o),void 0!==s&&(f.mtypes=s),this._getMessageByAnchor("getgroupmsgbymessageid",f,!1,a,u)}},{key:"getRoomMessageByMessageId",value:function(e,t,r,n,i,o,s,a,u){var f={rid:e,mid:t,desc:r,num:n};void 0!==i&&(f.begin=i),void 0!==o&&(f.end=o),void 0!==s&&(f.mtypes=s),this._getMessageByAnchor("getroommsgbymessageid",f,!1,a,u)}},{key:"getBroadcastMessageByMessageId",value:function(e,t,r,n,i,o,s,a){var u={mid:e,desc:t,num:r};void 0!==n&&(u.begin=n),void 0!==i&&(u.end=i),void 0!==o&&(u.mtypes=o),this._getMessageByAnchor("getbroadcastmsgbymessageid",u,!1,s,a)}},{key:"_getMessageByAnchor",value:function(e,t,r,n,o){var s={flag:1,method:e,payload:i.MsgPack.encode(t,this._msgOptions)};C.call(this,this._baseClient,s,(function(e,t){e?o&&o(e,null):o&&o(null,function(e,t){var r=e&&e.msgs;return r?(r.forEach((function(e,n){var o={id:new i.Int64(""+e[0]),mtype:Number(e[2]),mid:new i.Int64(""+e[3]),deleted:e[4],msg:O(e[5]),binary:e[5],attrs:O(e[6]),mtime:new i.Int64(""+e[7])};t?o.direction=Number(e[1]):o.from=new i.Int64(""+e[1]),r[n]=o})),e):e}(t,r))}),n,!0)}},{key:"getP2PMessageCount",value:function(e,t,r,n,i,o){this._getMessageCount("getp2pmsgcount",{ouid:e,begin:t,end:r,mtypes:n},i,o)}},{key:"getGroupMessageCount",value:function(e,t,r,n,i,o){this._getMessageCount("getgroupmsgcount",{gid:e,begin:t,end:r,mtypes:n},i,o)}},{key:"getRoomMessageCount",value:function(e,t,r,n,i,o){this._getMessageCount("getroommsgcount",{rid:e,begin:t,end:r,mtypes:n},i,o)}},{key:"getBroadcastMessageCount",value:function(e,t,r,n,i){this._getMessageCount("getbroadcastmsgcount",{begin:e,end:t,mtypes:r},n,i)}},{key:"_getMessageCount",value:function(e,t,r,n){var o={};Object.keys(t).forEach((function(e){void 0!==t[e]&&(o[e]=t[e])}));var s={flag:1,method:e,payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"fileToken",value:function(e,t,r,n,i,o,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!==i&&(a.gid=i),w.call(this,a,s,o)}},{key:"addAttrs",value:function(e,t,r){var n={attrs:e},o={flag:1,method:"addattrs",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"getAttrs",value:function(e,t){var r={flag:1,method:"getattrs",payload:i.MsgPack.encode({},this._msgOptions)};C.call(this,this._baseClient,r,t,e)}},{key:"addDebugLog",value:function(e,t,r,n){var o={msg:e,attrs:t},s={flag:1,method:"adddebuglog",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"addDevice",value:function(e,t,r,n){var o={apptype:e,devicetoken:t},s={flag:1,method:"adddevice",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"removeDevice",value:function(e,t,r){var n={devicetoken:e},o={flag:1,method:"removedevice",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"setTranslationLanguage",value:function(e,t,r){var n={lang:e},o={flag:1,method:"setlang",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"translate",value:function(e,t,r,n,o,s,a){var u={text:e,dst:r};void 0!==t&&(u.src=t),void 0!==n&&(u.type=n),void 0!==o&&(u.profanity=o);var f={flag:1,method:"translate",payload:i.MsgPack.encode(u,this._msgOptions)};C.call(this,this._baseClient,f,a,s)}},{key:"profanity",value:function(e,t,r,n){var o={text:e};void 0!==t&&(o.classify=t);var s={flag:1,method:"profanity",payload:i.MsgPack.encode(o,this._msgOptions)};C.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):"number"!=typeof t||void 0!==r&&"function"!=typeof r||(n="function"==typeof r?r:n,r=t,t=void 0);var o={text:e};void 0!==t&&(o.strategyId=t);var s={flag:1,method:"tcheck",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"imageCheck",value:function(e,t,r,n,o){var s={image:e,type:t};void 0!==r&&(s.strategyId=r);var a={flag:1,method:"icheck",payload:i.MsgPack.encode(s,this._msgOptions)};C.call(this,this._baseClient,a,o,n)}},{key:"audioCheck",value:function(e,t,r,n,o,s,a,u){var f={audio:e,type:t,lang:r};void 0!==n&&(f.codec=n),void 0!==o&&(f.srate=o),void 0!==s&&(f.strategyId=s);var c={flag:1,method:"acheck",payload:i.MsgPack.encode(f,this._msgOptions)};C.call(this,this._baseClient,c,u,a)}},{key:"videoCheck",value:function(e,t,r,n,o,s){var a={video:e,type:t,videoName:r};void 0!==n&&(a.strategyId=n);var u={flag:1,method:"vcheck",payload:i.MsgPack.encode(a,this._msgOptions)};C.call(this,this._baseClient,u,s,o)}},{key:"speech2Text",value:function(e,t,r,n,o,s,a){var u={audio:e,type:t,lang:r};void 0!==n&&(u.codec=n),void 0!==o&&(u.srate=o);var f={flag:1,method:"speech2text",payload:i.MsgPack.encode(u,this._msgOptions)};C.call(this,this._baseClient,f,a,s)}},{key:"getGroupsOpenInfo",value:function(e,t,r){var n={gids:e},o={flag:1,method:"getgroupsopeninfo",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"getRoomsOpenInfo",value:function(e,t,r){var n={rids:e},o={flag:1,method:"getroomsopeninfo",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"getRoomMembers",value:function(e,t,r){var n={rid:e},o={flag:1,method:"getroommembers",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"getRoomCount",value:function(e,t,r){var n={rids:e},o={flag:1,method:"getroomcount",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"addDevicePushOption",value:function(e,t,r,n,o){var s={type:e,xid:t};void 0!==r&&(s.mtypes=r);var a={flag:1,method:"addoption",payload:i.MsgPack.encode(s,this._msgOptions)};C.call(this,this._baseClient,a,o,n)}},{key:"removeDevicePushOption",value:function(e,t,r,n,o){var s={type:e,xid:t};void 0!==r&&(s.mtypes=r);var a={flag:1,method:"removeoption",payload:i.MsgPack.encode(s,this._msgOptions)};C.call(this,this._baseClient,a,o,n)}},{key:"getDevicePushOption",value:function(e,t){var r={flag:1,method:"getoption",payload:i.MsgPack.encode({},this._msgOptions)};C.call(this,this._baseClient,r,t,e)}},{key:"addFriends",value:function(e,t,r){var n={friends:e},o={flag:1,method:"addfriends",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"deleteFriends",value:function(e,t,r){var n={friends:e},o={flag:1,method:"delfriends",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"getFriends",value:function(e,t){var r={flag:1,method:"getfriends",payload:i.MsgPack.encode({},this._msgOptions)};C.call(this,this._baseClient,r,(function(e,r){if(e)t&&t(e,null);else{var n=r.uids;if(n){var o=[];return n.forEach((function(e,t){o[t]=new i.Int64(e)})),void(t&&t(null,o))}t&&t(null,r)}}),e)}},{key:"addGroupMembers",value:function(e,t,r,n){var o={gid:e,uids:t},s={flag:1,method:"addgroupmembers",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"deleteGroupMembers",value:function(e,t,r,n){var o={gid:e,uids:t},s={flag:1,method:"delgroupmembers",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"getGroupMembers",value:function(e,t,r,n){var o={gid:e};void 0!==t&&(o.online=t);var s={flag:1,method:"getgroupmembers",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,(function(e,t){if(e)n&&n(e,null);else{var r=t.uids;if(r){var o=[];r.forEach((function(e,t){o[t]=new i.Int64(e)})),t.uids=o}var s=t.onlines;if(s){var a=[];s.forEach((function(e,t){a[t]=new i.Int64(e)})),t.onlines=a}n&&n(null,t)}}),r)}},{key:"getGroupCount",value:function(e,t,r,n){var o={gid:e};void 0!==t&&(o.online=t);var s={flag:1,method:"getgroupcount",payload:i.MsgPack.encode(o,this._msgOptions)};C.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:i.MsgPack.encode({},this._msgOptions)},n="tlv-v1"===this._protocol?"group_refs":"gids";C.call(this,this._baseClient,r,(function(e,r){if(e)t&&t(e,null);else{var o=r[n];if(o){var s=[];return o.forEach((function(e,t){s[t]=new i.Int64(e)})),void(t&&t(null,s))}t&&t(null,r)}}),e)}},{key:"enterRoom",value:function(e,t,r){var n={rid:e},o={flag:1,method:"enterroom",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"enterRooms",value:function(e,t,r){var n={rids:e},o={flag:1,method:"enterrooms",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"leaveRoom",value:function(e,t,r){var n={rid:e},o={flag:1,method:"leaveroom",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"getUserRooms",value:function(e,t){var r={flag:1,method:"getuserrooms",payload:i.MsgPack.encode({},this._msgOptions)},n="tlv-v1"===this._protocol?"room_refs":"rooms";C.call(this,this._baseClient,r,(function(e,r){if(e)t&&t(e,null);else{var o=r[n];if(o){var s=[];return o.forEach((function(e,t){s[t]=new i.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 o={flag:1,method:"getuserroomsandlastmsg",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"getOnlineUsers",value:function(e,t,r){var n={uids:e},o={flag:1,method:"getonlineusers",payload:i.MsgPack.encode(n,this._msgOptions)},s="tlv-v1"===this._protocol?"online_users":"uids";C.call(this,this._baseClient,o,(function(e,t){if(e)r&&r(e,null);else{var n=t[s];if(n){var o=[];return n.forEach((function(e,t){o[t]=new i.Int64(e)})),void(r&&r(null,o))}r&&r(null,t)}}),t)}},{key:"deleteMessage",value:function(e,t,r,n,o,s){var a={from:e,mid:t,xid:r,type:n},u={flag:1,method:"delmsg",payload:i.MsgPack.encode(a,this._msgOptions)};C.call(this,this._baseClient,u,s,o)}},{key:"getMessage",value:function(e,t,r,n,o,s){var a={from:e,mid:t,xid:r,type:n},u={flag:1,method:"getmsg",payload:i.MsgPack.encode(a,this._msgOptions)};C.call(this,this._baseClient,u,(function(e,t){e?s&&s(e,null):(void 0!==t.id&&(t.id=new i.Int64(""+t.id)),void 0!==t.mtime&&(t.mtime=new i.Int64(""+t.mtime)),s&&s(null,t))}),o,!0)}},{key:"sendChat",value:function(e,t,r,n,o,s){this.sendMessage.call(this,e,i.CHAT_TYPE.text,t,r,n,o,s)}},{key:"sendAudio",value:function(e,t,r,n,o,s){this.sendMessage.call(this,e,i.CHAT_TYPE.audio,t,r,n,o,s)}},{key:"sendCmd",value:function(e,t,r,n,o,s){this.sendMessage.call(this,e,i.CHAT_TYPE.cmd,t,r,n,o,s)}},{key:"sendGroupChat",value:function(e,t,r,n,o,s){this.sendGroupMessage.call(this,e,i.CHAT_TYPE.text,t,r,n,o,s)}},{key:"sendGroupAudio",value:function(e,t,r,n,o,s){this.sendGroupMessage.call(this,e,i.CHAT_TYPE.audio,t,r,n,o,s)}},{key:"sendGroupCmd",value:function(e,t,r,n,o,s){this.sendGroupMessage.call(this,e,i.CHAT_TYPE.cmd,t,r,n,o,s)}},{key:"sendRoomChat",value:function(e,t,r,n,o,s){this.sendRoomMessage.call(this,e,i.CHAT_TYPE.text,t,r,n,o,s)}},{key:"sendRoomAudio",value:function(e,t,r,n,o,s){this.sendRoomMessage.call(this,e,i.CHAT_TYPE.audio,t,r,n,o,s)}},{key:"sendRoomCmd",value:function(e,t,r,n,o,s){this.sendRoomMessage.call(this,e,i.CHAT_TYPE.cmd,t,r,n,o,s)}},{key:"getGroupChat",value:function(e,t,r,n,o,s,a,u){this.getGroupMessage.call(this,e,t,r,n,o,s,[i.CHAT_TYPE.text,i.CHAT_TYPE.audio,i.CHAT_TYPE.cmd],a,u)}},{key:"getRoomChat",value:function(e,t,r,n,o,s,a,u){this.getRoomMessage.call(this,e,t,r,n,o,s,[i.CHAT_TYPE.text,i.CHAT_TYPE.audio,i.CHAT_TYPE.cmd],a,u)}},{key:"getP2PChat",value:function(e,t,r,n,o,s,a,u){this.getP2PMessage.call(this,e,t,r,n,o,s,[i.CHAT_TYPE.text,i.CHAT_TYPE.audio,i.CHAT_TYPE.cmd],a,u)}},{key:"getBroadcastChat",value:function(e,t,r,n,o,s,a){this.getBroadcastMessage.call(this,e,t,r,n,o,[i.CHAT_TYPE.text,i.CHAT_TYPE.audio,i.CHAT_TYPE.cmd],s,a)}},{key:"deleteChat",value:function(e,t,r,n,i,o){this.deleteMessage(e,t,r,n,i,o)}},{key:"getChat",value:function(e,t,r,n,i,o){this.getMessage(e,t,r,n,i,o)}},{key:"setUserInfo",value:function(e,t,r,n){var o={};void 0!==e&&(o.oinfo=e),void 0!==t&&(o.pinfo=t);var s={flag:1,method:"setuserinfo",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"getUserInfo",value:function(e,t){var r={flag:1,method:"getuserinfo",payload:i.MsgPack.encode({},this._msgOptions)};C.call(this,this._baseClient,r,t,e)}},{key:"getUserOpenInfo",value:function(e,t,r){var n={uids:e},o={flag:1,method:"getuseropeninfo",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"setGroupInfo",value:function(e,t,r,n,o){var s={gid:e};void 0!==t&&(s.oinfo=t),void 0!==r&&(s.pinfo=r);var a={flag:1,method:"setgroupinfo",payload:i.MsgPack.encode(s,this._msgOptions)};C.call(this,this._baseClient,a,o,n)}},{key:"getGroupInfo",value:function(e,t,r){var n={gid:e},o={flag:1,method:"getgroupinfo",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"getGroupOpenInfo",value:function(e,t,r){var n={gid:e},o={flag:1,method:"getgroupopeninfo",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"setRoomInfo",value:function(e,t,r,n,o){var s={rid:e};void 0!==t&&(s.oinfo=t),void 0!==r&&(s.pinfo=r);var a={flag:1,method:"setroominfo",payload:i.MsgPack.encode(s,this._msgOptions)};C.call(this,this._baseClient,a,o,n)}},{key:"setRoomProfile",value:function(e,t,r,n,o,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!==o&&(u.icon=o);var f={flag:1,method:"setroominfo",payload:i.MsgPack.encode(u,this._msgOptions)};C.call(this,this._baseClient,f,a,s)}},{key:"getRoomInfo",value:function(e,t,r){var n={rid:e},o={flag:1,method:"getroominfo",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"getRoomOpenInfo",value:function(e,t,r){var n={rid:e},o={flag:1,method:"getroomopeninfo",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"dataSet",value:function(e,t,r,n){var o={key:e,val:t},s={flag:1,method:"dataset",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"dataGet",value:function(e,t,r){var n={key:e},o={flag:1,method:"dataget",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"dataDelete",value:function(e,t,r){var n={key:e},o={flag:1,method:"datadel",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"addBlacks",value:function(e,t,r){var n={blacks:e},o={flag:1,method:"addblacks",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"deleteBlacks",value:function(e,t,r){var n={blacks:e},o={flag:1,method:"delblacks",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"getBlacks",value:function(e,t){var r={flag:1,method:"getblacks",payload:i.MsgPack.encode({},this._msgOptions)},n="tlv-v1"===this._protocol?"blocked_users":"uids";C.call(this,this._baseClient,r,(function(e,r){if(e)t&&t(e,null);else{var o=r[n];if(o){var s=[];return o.forEach((function(e,t){s[t]=new i.Int64(""+e)})),void(t&&t(null,s))}t&&t(null,r)}}),e)}},{key:"sendFile",value:function(e,t,r,n,i,o){var s={to:t,mtype:e,cmd:"sendfile"};b.call(this,s,r,n,o,i)}},{key:"sendGroupFile",value:function(e,t,r,n,i,o){var s={gid:t,mtype:e,cmd:"sendgroupfile"};b.call(this,s,r,n,o,i)}},{key:"sendRoomFile",value:function(e,t,r,n,i,o){var s={rid:t,mtype:e,cmd:"sendroomfile"};b.call(this,s,r,n,o,i)}},{key:"getP2PConversationList",value:function(e,t,r,n){var o={};void 0!==e&&(o.mtime=e),void 0!==t&&(o.mtypes=t);var s={flag:1,method:"getp2pconversationlist",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"getP2PUnreadConversationList",value:function(e,t,r,n){var o={};void 0!==e&&(o.mtime=e),void 0!==t&&(o.mtypes=t);var s={flag:1,method:"getp2punreadconversationlist",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"getGroupConversationList",value:function(e,t,r,n){var o={};void 0!==e&&(o.mtime=e),void 0!==t&&(o.mtypes=t);var s={flag:1,method:"getgroupconversationlist",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"getGroupUnreadConversationList",value:function(e,t,r,n){var o={};void 0!==e&&(o.mtime=e),void 0!==t&&(o.mtypes=t);var s={flag:1,method:"getgroupunreadconversationlist",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"getUnreadConversationList",value:function(e,t,r,n,o){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:i.MsgPack.encode(s,this._msgOptions)};C.call(this,this._baseClient,a,o,n)}},{key:"removeSession",value:function(e,t,r,n){var o="boolean"==typeof t;o||("function"==typeof r&&void 0===n&&(n=r,r=t),t=!1);var s={to:e};("tlv-v1"===this._protocol||o)&&(s.oneway=t);var a={flag:1,method:"removesession",payload:i.MsgPack.encode(s,this._msgOptions)};C.call(this,this._baseClient,a,n,r)}},{key:"processor",get:function(){return this._processor}}]),e}();e.exports=T}).call(this,r(5).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},i=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 s=function(e){function t(e){o(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){o(this,e),this.high=t>>>0,this.low=r>>>0,this.signed=!!n}return i(e,[{key:"isNegative",value:function(){return this.signed&&0!=(2147483648&this.high)}},{key:"toString",value:function(){if(!this.isNegative())return f(this.high,this.low);var e=u(this.high,this.low);return"-"+f(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 f(e,t){var r=[e>>>0];c(r,65536),c(r,65536),function(e,t){var r=t,n=0;for(;r>0;){n===e.length&&e.push(0);var i=e[n]+r;e[n]=i%1e7,r=Math.floor(i/1e7),n+=1}}(r,t>>>0);for(var n=String(r[r.length-1]),i=r.length-2;i>=0;i-=1)n+=String(r[i]).padStart(7,"0");return n}function c(e,t){for(var r=0,n=0;n<e.length;n+=1){var i=e[n]*t+r;e[n]=i%1e7,r=Math.floor(i/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 i=t[n],o=void 0;if(i<=127)o=i;else if(i>=194&&i<=223){o=(31&i)<<6|63&_(t,n+1),n+=1}else if(i>=224&&i<=239){var a=_(t,n+1),u=_(t,n+2);if(224===i&&a<160||237===i&&a>159)throw new s("invalid UTF-8 string");o=(15&i)<<12|(63&a)<<6|63&u,n+=2}else{if(!(i>=240&&i<=244))throw new s("invalid UTF-8 string");var f=_(t,n+1),c=_(t,n+2),l=_(t,n+3);if(240===i&&f<144||244===i&&f>143)throw new s("invalid UTF-8 string");o=(7&i)<<18|(63&f)<<12|(63&c)<<6|63&l,n+=3}if(o<=65535)r+=String.fromCharCode(o);else{var h=o-65536;r+=String.fromCharCode(55296|h>>10,56320|1023&h)}}return r}function _(e,t){if(t>=e.length||128!=(192&e[t]))throw new s("invalid UTF-8 string");return e[t]}var m=function(){function e(){o(this,e),this.chunks=[],this.length=0}return i(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 i=void 0===e?"undefined":n(e);if("boolean"!==i)if("string"!==i)if("number"!==i)if("bigint"!==i){if("object"!==i)throw new s("unsupported MessagePack value type: "+i);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 o=d(e);if(o)!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)}(o,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 i=10*r+(e.charCodeAt(n)-48);r=i%4294967296;var o=10*t+Math.floor(i/4294967296);if(o>=4294967296)throw new s("integer exceeds uint64");t=o}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 i=u(n.high,n.low);return t.byte(211),void t.uint64(i.high,i.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){o(this,e),this.bytes=p(t),this.offset=0,this.allowIntegerMapKeyAtPath=r&&Array.isArray(r.allowIntegerMapKeyAtPath)?r.allowIntegerMapKeyAtPath.slice():null}return i(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),i=0;i<e;i+=1)n[i]=this.value(t+1,r.concat(String(i)));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,i={},o=0;o<e;o+=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(i,u))throw new s("duplicate MessagePack map key: "+u);Object.defineProperty(i,u,{configurable:!0,enumerable:!0,value:this.value(t+1,r.concat(u)),writable:!0})}return i}},{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 m;return v(e,t,0),t.finish()},getByteView:d,isPlainMap:h,toUint8Array:p,utf8Decode:y,utf8Encode:g}},function(e,t,r){"use strict";(function(e){
|
|
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 i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.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 i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));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=13)}([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 i=r(1),o=i.msgpack,s=i.Int64BE,a=i.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 o}},{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 i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};var s=function(){if(o.fpnn)return o.fpnn;var e="undefined"!=typeof self&&"function"==typeof self.importScripts&&"function"==typeof self.WebSocket;return"undefined"!=typeof window||e?r(17):{FPClient:function e(){throw i(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){i(this,t);var n=r instanceof Error?r:new Error(String(r||"FPNN error")),o=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 o.code=e,o.name="FPError",o.stack=n.stack||o.stack,o.error=n,o}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=o.msgpack||r(18),u=o.md5||r(19),c=o.Int64BE&&o.Uint64BE?{Int64BE:o.Int64BE,Uint64BE:o.Uint64BE}:r(22);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 i=r(0),o=r(7),s=r(8),a=r(5),u=r(1),c=u.fpnn,f=u.md5;function l(e){var t="ws://";return this._ssl&&(t="wss://"),t+e+"/service/websocket"}function h(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===i.ERROR_CODE.RTM_EC_API_FREQUENCY_LIMITED||e===i.ERROR_CODE.RTM_EC_UNKNOWN_ERROR}function d(e,t){return!e&&!h(t)}function p(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:l.call(this,this._endpoint),autoReconnect:!1,connectionTimeout:this._connectionTimeout,platformImpl:this._platformImpl});var n=this._baseClient,i=this,o=!1,a=!1,u=!1,f=!1;function h(t,r){u||(u=!0,e&&e(t,r))}"tlv-v1"===this._protocol&&(this._canReconnect=this._autoReconnect),n.on("close",(function(){n===i._baseClient&&(a||f||(f=!0,h(!1,c.FPConfig.ERROR_CODE.FPNN_EC_CORE_INVALID_CONNECTION),"tlv-v1"===i._protocol&&y.call(i)))})),n.on("error",(function(e){n===i._baseClient&&(a||m.call(i,e),o||h(!1,c.FPConfig.ERROR_CODE.FPNN_EC_CORE_INVALID_CONNECTION))})),n.on("connect",(function(){n===i._baseClient&&(o||(o=!0,i._requireClose=!1,g.call(i,(function(e,t){if(e)a=!0;else if("tlv-v1"===i._protocol&&d(e,t))i._canReconnect=!1;else if("tlv-v1"===i._protocol&&!f&&n===i._baseClient)return h(e,t),void n.close();h(e,t)}),t)))})),n.processor=this._processor,n.connect()}function g(e,t){var r=this._baseClient;if(r){var n={pid:this._pid,uid:this._uid,token:this._token,version:this._clientVersion||"WebSocket_"+i.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 o={flag:1,method:"auth",payload:i.MsgPack.encode(n,this._msgOptions)},s=this;C.call(this,r,o,(function(t,n){if(r===s._baseClient){var o=n&&("tlv-v1"===s._protocol?n.accepted:n.ok);if(o)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&&y.call(s)})),r.on("error",(function(e){r===s._baseClient&&m.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&&(m.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&&!o){var u="tlv-v1"===s._protocol?i.ERROR_CODE.RTM_EC_INVALID_AUTH_TOEKN:c.FPConfig.ERROR_CODE.FPNN_EC_OK;e&&e(!1,u),"tlv-v1"===s._protocol&&m.call(s,new c.FPError(u,new Error("Gate rejected auth.login (accepted=false)")))}t&&(e&&e(!1,t.code),m.call(s,t),a="tlv-v1"===s._protocol?h(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 y(){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?(m.call(this,new c.FPError(c.FPConfig.ERROR_CODE.FPNN_EC_CORE_UNKNOWN_ERROR,new Error("connection closed, requireClose: "+this._requireClose))),void _.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 _(){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),m.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,i.ERROR_CODE.RTM_EC_INVALID_AUTH_TOEKN,t),r.emit("SessionClosed",i.ERROR_CODE.RTM_EC_INVALID_AUTH_TOEKN),m.call(r,new c.FPError(i.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&&d(e,n)?(r.emit("ReloginCompleted",!1,!1,n,t),r.emit("SessionClosed",n),m.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&&_.call(r),m.call(r,new c.FPError(i.ERROR_CODE.RTM_EC_UNKNOWN_ERROR,new Error("relogin fail, errorCode: "+n+", reconnectCount: "+t))))}),n)}),e)}}function m(e){this.emit("ErrorRecorder",e)}function v(e){return this._md5?this._md5(e).toUpperCase():f(e).toUpperCase()}function b(e,r,n,o,s){var a=this;n&&"0"!=n.toString()||(n=k.call(this)),w.call(a,e,(function(u,f){if(u)o&&o({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=v.call(a,u).toLowerCase(),p=v.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 _=new c.FPClient({endpoint:y,autoReconnect:!1,connectionTimeout:s,platformImpl:a._platformImpl});_.on("close",(function(){})),_.on("error",(function(e){var t=i.ERROR_CODE.RTM_EC_UNKNOWN_ERROR;void 0!==e.code&&(t=e.code),m.call(a,new c.FPError(t,e))})),_.on("connect",(function(){var t={token:l,sign:p,ext:d,file:u,endpoint:h};for(var r in e)t[r]=e[r];E.call(a,_,t,n,o,s)})),_.connect()}else o&&o({mid:n,error:new c.FPError(i.ERROR_CODE.RTM_EC_UNKNOWN_ERROR,new Error("no file content!"))},null)},g.readAsArrayBuffer(r)}else o&&o({mid:n,error:new c.FPError(i.ERROR_CODE.RTM_EC_UNKNOWN_ERROR,new Error(JSON.stringify(f)))},null)}}))}function w(e,t,r){var n={};for(var o in e)"mtype"!=o&&(n[o]=e[o]);var s={flag:1,method:"filetoken",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,s,t,r)}function E(e,t,r,n,o){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:i.MsgPack.encode(s,this._msgOptions)};C.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 i.Int64(""+r.mtime)),n&&n(null,{mid:s.mid,payload:r}))}),o)}function k(){++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 i.Int64(Date.now().toString()+e)}function R(e){return"tlv-v1"===this._protocol?null==e?0:e:e&&"0"!=e.toString()?e:k.call(this)}function P(e,t){if(!t)return new c.FPError(i.ERROR_CODE.RTM_EC_UNKNOWN_ERROR,Error("data is null"));if(t instanceof Error){var r=i.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 C(e,t,r,n){var o=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=P.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=o?i.MsgPack.decode(e.payload,s._binaryOptions):i.MsgPack.decode(e.payload,s._msgOptions),2==e.mtype&&(n=0!=e.ss),(t=P.call(s,n,a))?void(r&&r(t,null)):void(r&&r(null,a))}(t=P.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 O(e){if("string"==typeof e)return e;try{return new TextDecoder("utf-8",{fatal:!0}).decode(e)}catch(e){return}}var T=function(){function e(t){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),c.FPEvent.assign(this),this._protocol=t.protocol||"fpnn","fpnn"!==this._protocol&&"tlv-v1"!==this._protocol)throw new Error('options.protocol must be "fpnn" or "tlv-v1"');if(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=i.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){if(this._tlvEndpoint=t.tlvEndpoint||t.tlv_endpoint,!this._tlvEndpoint&&"string"==typeof t.endpoint&&/^wss?:\/\//i.test(t.endpoint)&&(this._tlvEndpoint=t.endpoint),!this._tlvEndpoint&&"string"==typeof t.ssl_endpoint&&/^wss?:\/\//i.test(t.ssl_endpoint)&&(this._tlvEndpoint=t.ssl_endpoint),"string"!=typeof this._tlvEndpoint||!/^wss?:\/\//i.test(this._tlvEndpoint))throw new Error("tlv-v1 requires options.tlvEndpoint as the deployment-provided ws:// or wss:// URL")}else{if(null!=this._endpoint){var r=this._endpoint.split(":");2==r.length&&"13325"==r[1]&&(this._endpoint=r[0]+":13321")}null!=t.ssl_endpoint&&(this._endpoint=t.ssl_endpoint,this._ssl=!0)}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:i.MsgPack.createCodec({int64:!0})},this._binaryOptions={codec:i.MsgPack.createCodec({int64:!0,useraw:!0})};var n=this;this._processor=new o(this);var s=function(){n._requireClose=!0,n._canReconnect=!1,"tlv-v1"!==n._protocol&&n._baseClient&&n._baseClient.close()};this._processor.on(i.SERVER_PUSH.kickOut,s),this._processor.on(i.TLV_SERVER_PUSH.kickOut,s),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),p.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:i.MsgPack.encode({},this._msgOptions)},n=this;this._requireClose=!0,C.call(this,this._baseClient,r,(function(e,r){"tlv-v1"===n._protocol?e&&(m.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:i.MsgPack.encode({},this._msgOptions)};C.call(this,this._baseClient,r,(function(e,r){e?t&&t(e,null):(r&&void 0!==r.mts&&(r.mts=new i.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,o,s,a){var u={to:e,mid:o=R.call(this,o),mtype:t,msg:r,attrs:n},c={flag:1,method:"sendmsg",payload:"tlv-v1"===this._protocol?u:i.MsgPack.encode(u,this._msgOptions)},f="tlv-v1"===this._protocol;C.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 i.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,o,s,a){var u={tos:e,mid:o=R.call(this,o),mtype:t,msg:r,attrs:n},c={flag:1,method:"sendmsgs",payload:"tlv-v1"===this._protocol?u:i.MsgPack.encode(u,this._msgOptions)},f="tlv-v1"===this._protocol;C.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 i.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,o,s,a){var u={gid:e,mid:o=R.call(this,o),mtype:t,msg:r,attrs:n},c={flag:1,method:"sendgroupmsg",payload:"tlv-v1"===this._protocol?u:i.MsgPack.encode(u,this._msgOptions)},f="tlv-v1"===this._protocol;C.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 i.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,o,s,a){var u={rid:e,mid:o=R.call(this,o),mtype:t,msg:r,attrs:n},c={flag:1,method:"sendroommsg",payload:"tlv-v1"===this._protocol?u:i.MsgPack.encode(u,this._msgOptions)},f="tlv-v1"===this._protocol;C.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 i.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){"boolean"!=typeof t&&("function"==typeof r&&void 0===n&&(n=r,r=t),t=void 0);var o={clear:void 0!==e&&e};void 0!==t&&(o.gettime=t);var s={flag:1,method:"getunread",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,(function(e,t){if(e)n&&n(e,null);else{var r=t.p2p;if(r){var o=[];r.forEach((function(e,t){o[t]=new i.Int64(""+e)})),t.p2p=o}var s=t.group;if(s){var a=[];s.forEach((function(e,t){a[t]=new i.Int64(""+e)})),t.group=a}n&&n(null,t)}}),r)}},{key:"getP2PUnreadMessageNum",value:function(e,t,r,n,o){var s={uids:e};void 0!==t&&(s.mtime=t),void 0!==r&&(s.mtypes=r);var a={flag:1,method:"getp2punread",payload:i.MsgPack.encode(s,this._msgOptions)},u="tlv-v1"===this._protocol;C.call(this,this._baseClient,a,(function(e,t){if(e)o&&o(e,null);else if(u)o&&o(null,t);else{var r={p2p:{},ltime:{}},n=t.p2p;if(n)for(var s in n)r.p2p[new i.Int64(""+s)]=n[s];var a=t.ltime;if(a)for(var s in a)r.ltime[new i.Int64(""+s)]=new i.Int64(""+a[s]);o&&o(null,r)}}),n)}},{key:"getGroupUnreadMessageNum",value:function(e,t,r,n,o){var s={gids:e};void 0!==t&&(s.mtime=t),void 0!==r&&(s.mtypes=r);var a={flag:1,method:"getgroupunread",payload:i.MsgPack.encode(s,this._msgOptions)},u="tlv-v1"===this._protocol;C.call(this,this._baseClient,a,(function(e,t){if(e)o&&o(e,null);else if(u)o&&o(null,t);else{var r={group:{},ltime:{}},n=t.group;if(n)for(var s in n)r.group[new i.Int64(""+s)]=n[s];var a=t.ltime;if(a)for(var s in a)r.ltime[new i.Int64(""+s)]=new i.Int64(""+a[s]);o&&o(null,r)}}),n)}},{key:"cleanUnreadMessage",value:function(e,t){var r={flag:1,method:"cleanunread",payload:i.MsgPack.encode({},this._msgOptions)};C.call(this,this._baseClient,r,t,e)}},{key:"setSessionRead",value:function(e,t,r,n,o){var s={category:e,xid:t,read_seq:r},a={flag:1,method:"setsessionread",payload:i.MsgPack.encode(s,this._msgOptions)};C.call(this,this._baseClient,a,o,n)}},{key:"getSession",value:function(e,t){var r={flag:1,method:"getsession",payload:i.MsgPack.encode({},this._msgOptions)};C.call(this,this._baseClient,r,(function(e,r){if(e)t&&t(e,null);else{var n=r.p2p;if(n){var o=[];n.forEach((function(e,t){o[t]=new i.Int64(""+e)})),r.p2p=o}var s=r.group;if(s){var a=[];s.forEach((function(e,t){a[t]=new i.Int64(""+e)})),r.group=a}t&&t(null,r)}}),e)}},{key:"getGroupMessage",value:function(e,t,r,n,o,s,a,u,c){var f={gid:e,desc:t,num:r};void 0!==n&&(f.begin=n),void 0!==o&&(f.end=o),void 0!==s&&(f.lastid=s),void 0!==a&&(f.mtypes=a);var l={flag:1,method:"getgroupmsg",payload:i.MsgPack.encode(f,this._msgOptions)};C.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],o=O(e[5]),s=O(e[6]);r[t]={id:new i.Int64(""+e[0]),from:new i.Int64(""+e[1]),mtype:Number(e[2]),mid:new i.Int64(""+e[3]),deleted:e[4],msg:o,binary:n,attrs:s,mtime:new i.Int64(""+e[7])}})),c&&c(null,t)}}),u,!0)}},{key:"getRoomMessage",value:function(e,t,r,n,o,s,a,u,c){var f={rid:e,desc:t,num:r};void 0!==n&&(f.begin=n),void 0!==o&&(f.end=o),void 0!==s&&(f.lastid=s),void 0!==a&&(f.mtypes=a);var l={flag:1,method:"getroommsg",payload:i.MsgPack.encode(f,this._msgOptions)};C.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],o=O(e[5]),s=O(e[6]);r[t]={id:new i.Int64(""+e[0]),from:new i.Int64(""+e[1]),mtype:Number(e[2]),mid:new i.Int64(""+e[3]),deleted:e[4],msg:o,binary:n,attrs:s,mtime:new i.Int64(""+e[7])}})),c&&c(null,t)}}),u,!0)}},{key:"getBroadcastMessage",value:function(e,t,r,n,o,s,a,u){var c={desc:e,num:t};void 0!==r&&(c.begin=r),void 0!==n&&(c.end=n),void 0!==o&&(c.lastid=o),void 0!==s&&(c.mtypes=s);var f={flag:1,method:"getbroadcastmsg",payload:i.MsgPack.encode(c,this._msgOptions)};C.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],o=O(e[5]),s=O(e[6]);r[t]={id:new i.Int64(""+e[0]),from:new i.Int64(""+e[1]),mtype:Number(e[2]),mid:new i.Int64(""+e[3]),deleted:e[4],msg:o,binary:n,attrs:s,mtime:new i.Int64(""+e[7])}})),u&&u(null,t)}}),a,!0)}},{key:"getP2PMessage",value:function(e,t,r,n,o,s,a,u,c){var f={ouid:e,desc:t,num:r};void 0!==n&&(f.begin=n),void 0!==o&&(f.end=o),void 0!==s&&(f.lastid=s),void 0!==a&&(f.mtypes=a);var l={flag:1,method:"getp2pmsg",payload:i.MsgPack.encode(f,this._msgOptions)};C.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],o=O(e[5]),s=O(e[6]);r[t]={id:new i.Int64(""+e[0]),direction:Number(e[1]),mtype:Number(e[2]),mid:new i.Int64(""+e[3]),deleted:e[4],msg:o,binary:n,attrs:s,mtime:new i.Int64(""+e[7])}})),c&&c(null,t)}}),u,!0)}},{key:"getP2PMessageByMessageId",value:function(e,t,r,n,i,o,s,a,u){var c={ouid:e,mid:t,desc:r,num:n};void 0!==i&&(c.begin=i),void 0!==o&&(c.end=o),void 0!==s&&(c.mtypes=s),this._getMessageByAnchor("getp2pmsgbymessageid",c,!0,a,u)}},{key:"getGroupMessageByMessageId",value:function(e,t,r,n,i,o,s,a,u){var c={gid:e,mid:t,desc:r,num:n};void 0!==i&&(c.begin=i),void 0!==o&&(c.end=o),void 0!==s&&(c.mtypes=s),this._getMessageByAnchor("getgroupmsgbymessageid",c,!1,a,u)}},{key:"getRoomMessageByMessageId",value:function(e,t,r,n,i,o,s,a,u){var c={rid:e,mid:t,desc:r,num:n};void 0!==i&&(c.begin=i),void 0!==o&&(c.end=o),void 0!==s&&(c.mtypes=s),this._getMessageByAnchor("getroommsgbymessageid",c,!1,a,u)}},{key:"getBroadcastMessageByMessageId",value:function(e,t,r,n,i,o,s,a){var u={mid:e,desc:t,num:r};void 0!==n&&(u.begin=n),void 0!==i&&(u.end=i),void 0!==o&&(u.mtypes=o),this._getMessageByAnchor("getbroadcastmsgbymessageid",u,!1,s,a)}},{key:"_getMessageByAnchor",value:function(e,t,r,n,o){var s={flag:1,method:e,payload:i.MsgPack.encode(t,this._msgOptions)};C.call(this,this._baseClient,s,(function(e,t){e?o&&o(e,null):o&&o(null,function(e,t){var r=e&&e.msgs;return r?(r.forEach((function(e,n){var o={id:new i.Int64(""+e[0]),mtype:Number(e[2]),mid:new i.Int64(""+e[3]),deleted:e[4],msg:O(e[5]),binary:e[5],attrs:O(e[6]),mtime:new i.Int64(""+e[7])};t?o.direction=Number(e[1]):o.from=new i.Int64(""+e[1]),r[n]=o})),e):e}(t,r))}),n,!0)}},{key:"getP2PMessageCount",value:function(e,t,r,n,i,o){this._getMessageCount("getp2pmsgcount",{ouid:e,begin:t,end:r,mtypes:n},i,o)}},{key:"getGroupMessageCount",value:function(e,t,r,n,i,o){this._getMessageCount("getgroupmsgcount",{gid:e,begin:t,end:r,mtypes:n},i,o)}},{key:"getRoomMessageCount",value:function(e,t,r,n,i,o){this._getMessageCount("getroommsgcount",{rid:e,begin:t,end:r,mtypes:n},i,o)}},{key:"getBroadcastMessageCount",value:function(e,t,r,n,i){this._getMessageCount("getbroadcastmsgcount",{begin:e,end:t,mtypes:r},n,i)}},{key:"_getMessageCount",value:function(e,t,r,n){var o={};Object.keys(t).forEach((function(e){void 0!==t[e]&&(o[e]=t[e])}));var s={flag:1,method:e,payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"fileToken",value:function(e,t,r,n,i,o,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!==i&&(a.gid=i),w.call(this,a,s,o)}},{key:"addAttrs",value:function(e,t,r){var n={attrs:e},o={flag:1,method:"addattrs",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"getAttrs",value:function(e,t){var r={flag:1,method:"getattrs",payload:i.MsgPack.encode({},this._msgOptions)};C.call(this,this._baseClient,r,t,e)}},{key:"addDebugLog",value:function(e,t,r,n){var o={msg:e,attrs:t},s={flag:1,method:"adddebuglog",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"addDevice",value:function(e,t,r,n){var o={apptype:e,devicetoken:t},s={flag:1,method:"adddevice",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"removeDevice",value:function(e,t,r){var n={devicetoken:e},o={flag:1,method:"removedevice",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"setTranslationLanguage",value:function(e,t,r){var n={lang:e},o={flag:1,method:"setlang",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"translate",value:function(e,t,r,n,o,s,a){var u={text:e,dst:r};void 0!==t&&(u.src=t),void 0!==n&&(u.type=n),void 0!==o&&(u.profanity=o);var c={flag:1,method:"translate",payload:i.MsgPack.encode(u,this._msgOptions)};C.call(this,this._baseClient,c,a,s)}},{key:"profanity",value:function(e,t,r,n){var o={text:e};void 0!==t&&(o.classify=t);var s={flag:1,method:"profanity",payload:i.MsgPack.encode(o,this._msgOptions)};C.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):"number"!=typeof t||void 0!==r&&"function"!=typeof r||(n="function"==typeof r?r:n,r=t,t=void 0);var o={text:e};void 0!==t&&(o.strategyId=t);var s={flag:1,method:"tcheck",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"imageCheck",value:function(e,t,r,n,o){var s={image:e,type:t};void 0!==r&&(s.strategyId=r);var a={flag:1,method:"icheck",payload:i.MsgPack.encode(s,this._msgOptions)};C.call(this,this._baseClient,a,o,n)}},{key:"audioCheck",value:function(e,t,r,n,o,s,a,u){var c={audio:e,type:t,lang:r};void 0!==n&&(c.codec=n),void 0!==o&&(c.srate=o),void 0!==s&&(c.strategyId=s);var f={flag:1,method:"acheck",payload:i.MsgPack.encode(c,this._msgOptions)};C.call(this,this._baseClient,f,u,a)}},{key:"videoCheck",value:function(e,t,r,n,o,s){var a={video:e,type:t,videoName:r};void 0!==n&&(a.strategyId=n);var u={flag:1,method:"vcheck",payload:i.MsgPack.encode(a,this._msgOptions)};C.call(this,this._baseClient,u,s,o)}},{key:"speech2Text",value:function(e,t,r,n,o,s,a){var u={audio:e,type:t,lang:r};void 0!==n&&(u.codec=n),void 0!==o&&(u.srate=o);var c={flag:1,method:"speech2text",payload:i.MsgPack.encode(u,this._msgOptions)};C.call(this,this._baseClient,c,a,s)}},{key:"getGroupsOpenInfo",value:function(e,t,r){var n={gids:e},o={flag:1,method:"getgroupsopeninfo",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"getRoomsOpenInfo",value:function(e,t,r){var n={rids:e},o={flag:1,method:"getroomsopeninfo",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"getRoomMembers",value:function(e,t,r){var n={rid:e},o={flag:1,method:"getroommembers",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"getRoomCount",value:function(e,t,r){var n={rids:e},o={flag:1,method:"getroomcount",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"addDevicePushOption",value:function(e,t,r,n,o){var s={type:e,xid:t};void 0!==r&&(s.mtypes=r);var a={flag:1,method:"addoption",payload:i.MsgPack.encode(s,this._msgOptions)};C.call(this,this._baseClient,a,o,n)}},{key:"removeDevicePushOption",value:function(e,t,r,n,o){var s={type:e,xid:t};void 0!==r&&(s.mtypes=r);var a={flag:1,method:"removeoption",payload:i.MsgPack.encode(s,this._msgOptions)};C.call(this,this._baseClient,a,o,n)}},{key:"getDevicePushOption",value:function(e,t){var r={flag:1,method:"getoption",payload:i.MsgPack.encode({},this._msgOptions)};C.call(this,this._baseClient,r,t,e)}},{key:"addFriends",value:function(e,t,r){var n={friends:e},o={flag:1,method:"addfriends",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"deleteFriends",value:function(e,t,r){var n={friends:e},o={flag:1,method:"delfriends",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"getFriends",value:function(e,t){var r={flag:1,method:"getfriends",payload:i.MsgPack.encode({},this._msgOptions)};C.call(this,this._baseClient,r,(function(e,r){if(e)t&&t(e,null);else{var n=r.uids;if(n){var o=[];return n.forEach((function(e,t){o[t]=new i.Int64(e)})),void(t&&t(null,o))}t&&t(null,r)}}),e)}},{key:"addGroupMembers",value:function(e,t,r,n){var o={gid:e,uids:t},s={flag:1,method:"addgroupmembers",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"deleteGroupMembers",value:function(e,t,r,n){var o={gid:e,uids:t},s={flag:1,method:"delgroupmembers",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"getGroupMembers",value:function(e,t,r,n){var o={gid:e};void 0!==t&&(o.online=t);var s={flag:1,method:"getgroupmembers",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,(function(e,t){if(e)n&&n(e,null);else{var r=t.uids;if(r){var o=[];r.forEach((function(e,t){o[t]=new i.Int64(e)})),t.uids=o}var s=t.onlines;if(s){var a=[];s.forEach((function(e,t){a[t]=new i.Int64(e)})),t.onlines=a}n&&n(null,t)}}),r)}},{key:"getGroupCount",value:function(e,t,r,n){var o={gid:e};void 0!==t&&(o.online=t);var s={flag:1,method:"getgroupcount",payload:i.MsgPack.encode(o,this._msgOptions)};C.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:i.MsgPack.encode({},this._msgOptions)},n="tlv-v1"===this._protocol?"group_refs":"gids";C.call(this,this._baseClient,r,(function(e,r){if(e)t&&t(e,null);else{var o=r[n];if(o){var s=[];return o.forEach((function(e,t){s[t]=new i.Int64(e)})),void(t&&t(null,s))}t&&t(null,r)}}),e)}},{key:"enterRoom",value:function(e,t,r){var n={rid:e},o={flag:1,method:"enterroom",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"enterRooms",value:function(e,t,r){var n={rids:e},o={flag:1,method:"enterrooms",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"leaveRoom",value:function(e,t,r){var n={rid:e},o={flag:1,method:"leaveroom",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"getUserRooms",value:function(e,t){var r={flag:1,method:"getuserrooms",payload:i.MsgPack.encode({},this._msgOptions)},n="tlv-v1"===this._protocol?"room_refs":"rooms";C.call(this,this._baseClient,r,(function(e,r){if(e)t&&t(e,null);else{var o=r[n];if(o){var s=[];return o.forEach((function(e,t){s[t]=new i.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 o={flag:1,method:"getuserroomsandlastmsg",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"getOnlineUsers",value:function(e,t,r){var n={uids:e},o={flag:1,method:"getonlineusers",payload:i.MsgPack.encode(n,this._msgOptions)},s="tlv-v1"===this._protocol?"online_users":"uids";C.call(this,this._baseClient,o,(function(e,t){if(e)r&&r(e,null);else{var n=t[s];if(n){var o=[];return n.forEach((function(e,t){o[t]=new i.Int64(e)})),void(r&&r(null,o))}r&&r(null,t)}}),t)}},{key:"deleteMessage",value:function(e,t,r,n,o,s){var a={from:e,mid:t,xid:r,type:n},u={flag:1,method:"delmsg",payload:i.MsgPack.encode(a,this._msgOptions)};C.call(this,this._baseClient,u,s,o)}},{key:"getMessage",value:function(e,t,r,n,o,s){var a={from:e,mid:t,xid:r,type:n},u={flag:1,method:"getmsg",payload:i.MsgPack.encode(a,this._msgOptions)};C.call(this,this._baseClient,u,(function(e,t){e?s&&s(e,null):(void 0!==t.id&&(t.id=new i.Int64(""+t.id)),void 0!==t.mtime&&(t.mtime=new i.Int64(""+t.mtime)),s&&s(null,t))}),o,!0)}},{key:"sendChat",value:function(e,t,r,n,o,s){this.sendMessage.call(this,e,i.CHAT_TYPE.text,t,r,n,o,s)}},{key:"sendAudio",value:function(e,t,r,n,o,s){this.sendMessage.call(this,e,i.CHAT_TYPE.audio,t,r,n,o,s)}},{key:"sendCmd",value:function(e,t,r,n,o,s){this.sendMessage.call(this,e,i.CHAT_TYPE.cmd,t,r,n,o,s)}},{key:"sendGroupChat",value:function(e,t,r,n,o,s){this.sendGroupMessage.call(this,e,i.CHAT_TYPE.text,t,r,n,o,s)}},{key:"sendGroupAudio",value:function(e,t,r,n,o,s){this.sendGroupMessage.call(this,e,i.CHAT_TYPE.audio,t,r,n,o,s)}},{key:"sendGroupCmd",value:function(e,t,r,n,o,s){this.sendGroupMessage.call(this,e,i.CHAT_TYPE.cmd,t,r,n,o,s)}},{key:"sendRoomChat",value:function(e,t,r,n,o,s){this.sendRoomMessage.call(this,e,i.CHAT_TYPE.text,t,r,n,o,s)}},{key:"sendRoomAudio",value:function(e,t,r,n,o,s){this.sendRoomMessage.call(this,e,i.CHAT_TYPE.audio,t,r,n,o,s)}},{key:"sendRoomCmd",value:function(e,t,r,n,o,s){this.sendRoomMessage.call(this,e,i.CHAT_TYPE.cmd,t,r,n,o,s)}},{key:"getGroupChat",value:function(e,t,r,n,o,s,a,u){this.getGroupMessage.call(this,e,t,r,n,o,s,[i.CHAT_TYPE.text,i.CHAT_TYPE.audio,i.CHAT_TYPE.cmd],a,u)}},{key:"getRoomChat",value:function(e,t,r,n,o,s,a,u){this.getRoomMessage.call(this,e,t,r,n,o,s,[i.CHAT_TYPE.text,i.CHAT_TYPE.audio,i.CHAT_TYPE.cmd],a,u)}},{key:"getP2PChat",value:function(e,t,r,n,o,s,a,u){this.getP2PMessage.call(this,e,t,r,n,o,s,[i.CHAT_TYPE.text,i.CHAT_TYPE.audio,i.CHAT_TYPE.cmd],a,u)}},{key:"getBroadcastChat",value:function(e,t,r,n,o,s,a){this.getBroadcastMessage.call(this,e,t,r,n,o,[i.CHAT_TYPE.text,i.CHAT_TYPE.audio,i.CHAT_TYPE.cmd],s,a)}},{key:"deleteChat",value:function(e,t,r,n,i,o){this.deleteMessage(e,t,r,n,i,o)}},{key:"getChat",value:function(e,t,r,n,i,o){this.getMessage(e,t,r,n,i,o)}},{key:"setUserInfo",value:function(e,t,r,n){var o={};void 0!==e&&(o.oinfo=e),void 0!==t&&(o.pinfo=t);var s={flag:1,method:"setuserinfo",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"getUserInfo",value:function(e,t){var r={flag:1,method:"getuserinfo",payload:i.MsgPack.encode({},this._msgOptions)};C.call(this,this._baseClient,r,t,e)}},{key:"getUserOpenInfo",value:function(e,t,r){var n={uids:e},o={flag:1,method:"getuseropeninfo",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"setGroupInfo",value:function(e,t,r,n,o){var s={gid:e};void 0!==t&&(s.oinfo=t),void 0!==r&&(s.pinfo=r);var a={flag:1,method:"setgroupinfo",payload:i.MsgPack.encode(s,this._msgOptions)};C.call(this,this._baseClient,a,o,n)}},{key:"getGroupInfo",value:function(e,t,r){var n={gid:e},o={flag:1,method:"getgroupinfo",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"getGroupOpenInfo",value:function(e,t,r){var n={gid:e},o={flag:1,method:"getgroupopeninfo",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"setRoomInfo",value:function(e,t,r,n,o){var s={rid:e};void 0!==t&&(s.oinfo=t),void 0!==r&&(s.pinfo=r);var a={flag:1,method:"setroominfo",payload:i.MsgPack.encode(s,this._msgOptions)};C.call(this,this._baseClient,a,o,n)}},{key:"setRoomProfile",value:function(e,t,r,n,o,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!==o&&(u.icon=o);var c={flag:1,method:"setroominfo",payload:i.MsgPack.encode(u,this._msgOptions)};C.call(this,this._baseClient,c,a,s)}},{key:"getRoomInfo",value:function(e,t,r){var n={rid:e},o={flag:1,method:"getroominfo",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"getRoomOpenInfo",value:function(e,t,r){var n={rid:e},o={flag:1,method:"getroomopeninfo",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"dataSet",value:function(e,t,r,n){var o={key:e,val:t},s={flag:1,method:"dataset",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"dataGet",value:function(e,t,r){var n={key:e},o={flag:1,method:"dataget",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"dataDelete",value:function(e,t,r){var n={key:e},o={flag:1,method:"datadel",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"addBlacks",value:function(e,t,r){var n={blacks:e},o={flag:1,method:"addblacks",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"deleteBlacks",value:function(e,t,r){var n={blacks:e},o={flag:1,method:"delblacks",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"getBlacks",value:function(e,t){var r={flag:1,method:"getblacks",payload:i.MsgPack.encode({},this._msgOptions)},n="tlv-v1"===this._protocol?"blocked_users":"uids";C.call(this,this._baseClient,r,(function(e,r){if(e)t&&t(e,null);else{var o=r[n];if(o){var s=[];return o.forEach((function(e,t){s[t]=new i.Int64(""+e)})),void(t&&t(null,s))}t&&t(null,r)}}),e)}},{key:"sendFile",value:function(e,t,r,n,i,o){var s={to:t,mtype:e,cmd:"sendfile"};b.call(this,s,r,n,o,i)}},{key:"sendGroupFile",value:function(e,t,r,n,i,o){var s={gid:t,mtype:e,cmd:"sendgroupfile"};b.call(this,s,r,n,o,i)}},{key:"sendRoomFile",value:function(e,t,r,n,i,o){var s={rid:t,mtype:e,cmd:"sendroomfile"};b.call(this,s,r,n,o,i)}},{key:"getP2PConversationList",value:function(e,t,r,n){var o={};void 0!==e&&(o.mtime=e),void 0!==t&&(o.mtypes=t);var s={flag:1,method:"getp2pconversationlist",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"getP2PUnreadConversationList",value:function(e,t,r,n){var o={};void 0!==e&&(o.mtime=e),void 0!==t&&(o.mtypes=t);var s={flag:1,method:"getp2punreadconversationlist",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"getGroupConversationList",value:function(e,t,r,n){var o={};void 0!==e&&(o.mtime=e),void 0!==t&&(o.mtypes=t);var s={flag:1,method:"getgroupconversationlist",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"getGroupUnreadConversationList",value:function(e,t,r,n){var o={};void 0!==e&&(o.mtime=e),void 0!==t&&(o.mtypes=t);var s={flag:1,method:"getgroupunreadconversationlist",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"getUnreadConversationList",value:function(e,t,r,n,o){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:i.MsgPack.encode(s,this._msgOptions)};C.call(this,this._baseClient,a,o,n)}},{key:"removeSession",value:function(e,t,r,n){var o="boolean"==typeof t;o||("function"==typeof r&&void 0===n&&(n=r,r=t),t=!1);var s={to:e};("tlv-v1"===this._protocol||o)&&(s.oneway=t);var a={flag:1,method:"removesession",payload:i.MsgPack.encode(s,this._msgOptions)};C.call(this,this._baseClient,a,n,r)}},{key:"processor",get:function(){return this._processor}}]),e}();e.exports=T}).call(this,r(6).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},i=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 s=function(e){function t(e){o(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){o(this,e),this.high=t>>>0,this.low=r>>>0,this.signed=!!n}return i(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 i=e[n]+r;e[n]=i%1e7,r=Math.floor(i/1e7),n+=1}}(r,t>>>0);for(var n=String(r[r.length-1]),i=r.length-2;i>=0;i-=1)n+=String(r[i]).padStart(7,"0");return n}function f(e,t){for(var r=0,n=0;n<e.length;n+=1){var i=e[n]*t+r;e[n]=i%1e7,r=Math.floor(i/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 i=t[n],o=void 0;if(i<=127)o=i;else if(i>=194&&i<=223){o=(31&i)<<6|63&_(t,n+1),n+=1}else if(i>=224&&i<=239){var a=_(t,n+1),u=_(t,n+2);if(224===i&&a<160||237===i&&a>159)throw new s("invalid UTF-8 string");o=(15&i)<<12|(63&a)<<6|63&u,n+=2}else{if(!(i>=240&&i<=244))throw new s("invalid UTF-8 string");var c=_(t,n+1),f=_(t,n+2),l=_(t,n+3);if(240===i&&c<144||244===i&&c>143)throw new s("invalid UTF-8 string");o=(7&i)<<18|(63&c)<<12|(63&f)<<6|63&l,n+=3}if(o<=65535)r+=String.fromCharCode(o);else{var h=o-65536;r+=String.fromCharCode(55296|h>>10,56320|1023&h)}}return r}function _(e,t){if(t>=e.length||128!=(192&e[t]))throw new s("invalid UTF-8 string");return e[t]}var m=function(){function e(){o(this,e),this.chunks=[],this.length=0}return i(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 i=void 0===e?"undefined":n(e);if("boolean"!==i)if("string"!==i)if("number"!==i)if("bigint"!==i){if("object"!==i)throw new s("unsupported MessagePack value type: "+i);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 o=d(e);if(o)!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)}(o,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 i=10*r+(e.charCodeAt(n)-48);r=i%4294967296;var o=10*t+Math.floor(i/4294967296);if(o>=4294967296)throw new s("integer exceeds uint64");t=o}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 i=u(n.high,n.low);return t.byte(211),void t.uint64(i.high,i.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){o(this,e),this.bytes=p(t),this.offset=0,this.allowIntegerMapKeyAtPath=r&&Array.isArray(r.allowIntegerMapKeyAtPath)?r.allowIntegerMapKeyAtPath.slice():null}return i(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),i=0;i<e;i+=1)n[i]=this.value(t+1,r.concat(String(i)));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,i={},o=0;o<e;o+=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(i,u))throw new s("duplicate MessagePack map key: "+u);Object.defineProperty(i,u,{configurable:!0,enumerable:!0,value:this.value(t+1,r.concat(u)),writable:!0})}return i}},{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 m;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,off:!0,on:!0,removeEvent:!0,startAutoReconnect:!0};function i(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(o){if(!n[o]&&"_"!==o.charAt(0)){var s=t[o];if("function"==typeof s){var a="login"===o?2:s.length-1;a<0||Object.defineProperty(r,o,{configurable:!1,enumerable:!0,writable:!1,value:function(){var t=Array.prototype.slice.call(arguments);if("login"===o){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),i(e,o,t,s)}))}if(t.length>a)return Promise.reject(new TypeError("Do not pass a callback to promises."+o+"()"));for(;t.length<a;)t.push(void 0);return new Promise((function(r,n){t.push((function(e,t){e?n(e):r(t)})),i(e,o,t,n)}))}})}}})),Object.freeze(r)}},function(e,t,r){"use strict";(function(e){
|
|
2
2
|
/*!
|
|
3
3
|
* The buffer module from node.js, for the browser.
|
|
4
4
|
*
|
|
5
5
|
* @author Feross Aboukhadijeh <http://feross.org>
|
|
6
6
|
* @license MIT
|
|
7
7
|
*/
|
|
8
|
-
var n=r(11),i=r(12),o=r(13);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 f(this,e,t,r)}function f(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),i=(e=a(e,n)).write(t,r);i!==n&&(e=e.slice(0,i));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&&o(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 c(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(c(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 _(e,t,r,n,i){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=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=u.from(t,n)),u.isBuffer(t))return 0===t.length?-1:m(e,t,r,n,i);if("number"==typeof t)return t&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):m(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function m(e,t,r,n,i){var o,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 f(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var c=-1;for(o=r;o<a;o++)if(f(e,o)===f(t,-1===c?0:o-c)){if(-1===c&&(c=o),o-c+1===u)return c*s}else-1!==c&&(o-=o-c),c=-1}else for(r+u>a&&(r=a-u),o=r;o>=0;o--){for(var l=!0,h=0;h<u;h++)if(f(e,o+h)!==f(t,h)){l=!1;break}if(l)return o}return-1}function v(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/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 Y(j(t,e.length-r),e,r,n)}function w(e,t,r,n){return Y(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 Y(q(t),e,r,n)}function R(e,t,r,n){return Y(function(e,t){for(var r,n,i,o=[],s=0;s<e.length&&!((t-=2)<0);++s)r=e.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(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=[],i=t;i<r;){var o,s,a,u,f=e[i],c=null,l=f>239?4:f>223?3:f>191?2:1;if(i+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&f)<<6|63&o)>127&&(c=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&f)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&f)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),i+=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 f(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 c(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,i=0,o=Math.min(r,n);i<o;++i)if(e[i]!==t[i]){r=e[i],n=t[i];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(!o(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),i=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,i),i+=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,i){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===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),f=this.slice(n,i),c=e.slice(t,r),l=0;l<a;++l)if(f[l]!==c[l]){o=f[l],s=c[l];break}return o<s?-1:s<o?1:0},u.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},u.prototype.indexOf=function(e,t,r){return _(this,e,t,r,!0)},u.prototype.lastIndexOf=function(e,t,r){return _(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 i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!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(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!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 i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}function T(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]);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 i="",o=t;o<r;++o)i+=L(e[o]);return i}function S(e,t,r){for(var n=e.slice(t,r),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}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,i,o){if(!u.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)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 i=0,o=Math.min(e.length-r,2);i<o;++i)e[r+i]=(t&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function B(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i<o;++i)e[r+i]=t>>>8*(n?i:3-i)&255}function N(e,t,r,n,i,o){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,o){return o||N(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function F(e,t,r,n,o){return o||N(e,0,r,8),i.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 i=t-e;r=new u(i,void 0);for(var o=0;o<i;++o)r[o]=this[o+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],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;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],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;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],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n>=(i*=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,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},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),i.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return t||M(e,4,this.length),i.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return t||M(e,8,this.length),i.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return t||M(e,8,this.length),i.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 i=1,o=0;for(this[t]=255&e;++o<r&&(i*=256);)this[t+o]=e/i&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 i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&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 i=Math.pow(2,8*r-1);I(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o<r&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},u.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);I(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(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 F(this,e,t,!0,r)},u.prototype.writeDoubleBE=function(e,t,r){return F(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 i,o=n-r;if(this===e&&r<t&&t<n)for(i=o-1;i>=0;--i)e[i+t]=this[i+r];else if(o<1e3||!u.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)e[i+t]=this[i+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+o),t);return o},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 i=e.charCodeAt(0);i<256&&(e=i)}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 o;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o<r;++o)this[o]=e;else{var s=u.isBuffer(e)?e:j(new u(e,n).toString()),a=s.length;for(o=0;o<r-t;++o)this[o+t]=s[o%a]}return this};var D=/[^+\/0-9A-Za-z-_]/g;function L(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,i=null,o=[],s=0;s<n;++s){if((r=e.charCodeAt(s))>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.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;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function q(e){return n.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(D,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Y(e,t,r,n){for(var i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}}).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 i=r(1).fpnn,o=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),i.FPEvent.assign(this),this._map={},this._client=t,this.uid=0,this._expireTimerID=0,this._msgOptions={codec:o.MsgPack.createCodec({int64:!0})},this._binaryOptions={codec:o.MsgPack.createCodec({int64:!0,useraw:!0})},this._binaryMessageMethodList=[o.SERVER_PUSH.recvMessage,o.SERVER_PUSH.recvGroupMessage,o.SERVER_PUSH.recvRoomMessage,o.SERVER_PUSH.recvBroadcastMessage,o.SERVER_PUSH.recvFile,o.SERVER_PUSH.recvGroupFile,o.SERVER_PUSH.recvRoomFile,o.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=o.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,i=!0;o.SERVER_PUSH.kickOut==e.method&&(i=!1),o.SERVER_PUSH.kickOutRoom==e.method&&(i=!1),i&&t&&(0==e.flag&&t(JSON.stringify({}),!1),1==e.flag&&t(o.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=o.MsgPack.decode(e.payload,this._binaryOptions)).mtype==o.CHAT_TYPE.text)s=o.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=o.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(o.SERVER_PUSH.kickOut,e)}},{key:"kickoutroom",value:function(e){e.rid&&(e.rid=new o.Int64(e.rid)),this.emit(o.SERVER_PUSH.kickOutRoom,e)}},{key:"pushmsg",value:function(e){e.from&&(e.from=new o.Int64(e.from)),e.mid&&(e.mid=new o.Int64(e.mid),!a.call(this,1,e.mid,e.from))||(e.mtime&&(e.mtime=new o.Int64(e.mtime)),e.mtype>=40&&e.mtype<=50?this.emit(o.SERVER_PUSH.recvFile,e):e.mtype!=o.CHAT_TYPE.text?e.mtype!=o.CHAT_TYPE.audio?e.mtype!=o.CHAT_TYPE.cmd?(delete e.ftype,this.emit(o.SERVER_PUSH.recvMessage,e)):this.emit(o.SERVER_PUSH.recvCmd,e):this.emit(o.SERVER_PUSH.recvFile,e):this.emit(o.SERVER_PUSH.recvChat,e))}},{key:"pushgroupmsg",value:function(e){e.from&&(e.from=new o.Int64(e.from)),e.mid&&(e.mid=new o.Int64(e.mid),!a.call(this,2,e.mid,e.from,e.gid))||(e.gid&&(e.gid=new o.Int64(e.gid)),e.mtime&&(e.mtime=new o.Int64(e.mtime)),e.mtype>=40&&e.mtype<=50?this.emit(o.SERVER_PUSH.recvGroupFile,e):e.mtype!=o.CHAT_TYPE.text?e.mtype!=o.CHAT_TYPE.audio?e.mtype!=o.CHAT_TYPE.cmd?(delete e.ftype,this.emit(o.SERVER_PUSH.recvGroupMessage,e)):this.emit(o.SERVER_PUSH.recvGroupCmd,e):this.emit(o.SERVER_PUSH.recvGroupFile,e):this.emit(o.SERVER_PUSH.recvGroupChat,e))}},{key:"pushroommsg",value:function(e){e.from&&(e.from=new o.Int64(e.from)),e.mid&&(e.mid=new o.Int64(e.mid),!a.call(this,3,e.mid,e.from,e.rid))||(e.rid&&(e.rid=new o.Int64(e.rid)),e.mtime&&(e.mtime=new o.Int64(e.mtime)),e.mtype>=40&&e.mtype<=50?this.emit(o.SERVER_PUSH.recvRoomFile,e):e.mtype!=o.CHAT_TYPE.text?e.mtype!=o.CHAT_TYPE.audio?e.mtype!=o.CHAT_TYPE.cmd?(delete e.ftype,this.emit(o.SERVER_PUSH.recvRoomMessage,e)):this.emit(o.SERVER_PUSH.recvRoomCmd,e):this.emit(o.SERVER_PUSH.recvRoomFile,e):this.emit(o.SERVER_PUSH.recvRoomChat,e))}},{key:"pushbroadcastmsg",value:function(e){e.from&&(e.from=new o.Int64(e.from)),e.mid&&(e.mid=new o.Int64(e.mid),!a.call(this,4,e.mid,e.from))||(e.mtime&&(e.mtime=new o.Int64(e.mtime)),e.mtype>=40&&e.mtype<=50?this.emit(o.SERVER_PUSH.recvBroadcastFile,e):e.mtype!=o.CHAT_TYPE.text?e.mtype!=o.CHAT_TYPE.audio?e.mtype!=o.CHAT_TYPE.cmd?(delete e.ftype,this.emit(o.SERVER_PUSH.recvBroadcastMessage,e)):this.emit(o.SERVER_PUSH.recvBroadcastCmd,e):this.emit(o.SERVER_PUSH.recvBroadcastFile,e):this.emit(o.SERVER_PUSH.recvBroadcastChat,e))}},{key:"ping",value:function(e){this._client._lastPingTime=parseInt(Date.now()/1e3),this.emit(o.SERVER_PUSH.recvPing,e)}}]),e}());function a(e,t,r,n){var i=[];i.push(e),i.push(t),i.push(r),null!=n&&i.push(n);var s=i.join("_");if(this._map.hasOwnProperty(s)){if(this._map[s]>Date.now())return!1;delete this._map[s]}return this._map[s]=o.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()||f.call(e,t)}),o.MID_TTL+1e3)}function f(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},i=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(8),s=r(20),a=r(4),u=r(0),f=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||c,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 i(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),i=s.toWireRequest(e&&e.method,n.payload,this._requestMetadata,{omitLegacyNil:n.legacyEncoded});this._request(i.uri,i.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 i=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"))}(i)})).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=o.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 i=this._allocateSequence(),o="number"==typeof r&&r>0?r:this._requestTimeout,s={handlers:n,timer:setTimeout(this._onRequestTimeout.bind(this,i),o),uri:e};this._pending.set(i,s);try{this._sendFrame(i,"1",e,t)}catch(e){this._pending.delete(i),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<o.MAX_SEQUENCE;e+=1){var t=this._nextSequence;if(this._nextSequence=t===o.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 i=o.encodeFrame(e,t,r,n),s=i.buffer.slice(i.byteOffset,i.byteOffset+i.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 c(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=f},function(e,t,r){"use strict";var n=r(4),i=new Uint8Array([2,0,109,116,1,0]),o=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 o("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:o,VERSION:1,decodeFrame:function(e){var t=n.toUint8Array(e);if(0===t.length||t.length>67239936)throw new o("TLV frame length is outside the allowed limit");if(t.length<27)throw new o("TLV frame is too short");if(204!==t[0]||1!==t[1]||4!==t[2]||0!==t[3])throw new o("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 o("TLV v1 metadata length must be exactly 7");for(var a=0;a<i.length;a+=1)if(t[10+a]!==i[a])throw new o("TLV v1 metadata must contain only key mt");var f=t[16];if(48!==f&&49!==f&&50!==f)throw new o("TLV v1 metadata mt is invalid");var c=String.fromCharCode(f);if(u(t,17)!==t.length-21)throw new o("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 o("invalid URI length in message queue");var d=n.utf8Decode(t.subarray(l,l+h));if(0!==t[l+=h])throw new o("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 o("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 o)throw e;throw new o("invalid MsgPack payload: "+e.message)}return{mt:c,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 o('metadata mt must be "0", "1", or "2"')}(t);var f=function(e){if("string"!=typeof e||0===e.length)throw new o("URI must be a non-empty UTF-8 string");var t=n.utf8Encode(e);if(0===t.length||t.length>255)throw new o("URI UTF-8 length must be in 1..255");return t}(r),c=n.encodeMap(void 0===u?{}:u);if(0===c.length||c.length>67108864)throw new o("MsgPack payload length is outside the TLV v1 limit");var l=1+f.length+1+4+c.length,h=21+l;if(h>67239936)throw new o("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(i,10),d[16]=t.charCodeAt(0),a(d,17,l);var p=21;return d[p]=f.length,p+=1,d.set(f,p),d[p+=f.length]=0,a(d,p+=1,c.length),p+=4,d.set(c,p),d}}},function(e,t,r){"use strict";var n={close:!0,constructor:!0,destroy:!0,emit:!0,off:!0,on:!0,removeEvent:!0,startAutoReconnect:!0};function i(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(o){if(!n[o]&&"_"!==o.charAt(0)){var s=t[o];if("function"==typeof s){var a="login"===o?2:s.length-1;a<0||Object.defineProperty(r,o,{configurable:!1,enumerable:!0,writable:!1,value:function(){var t=Array.prototype.slice.call(arguments);if("login"===o){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),i(e,o,t,s)}))}if(t.length>a)return Promise.reject(new TypeError("Do not pass a callback to promises."+o+"()"));for(;t.length<a;)t.push(void 0);return new Promise((function(r,n){t.push((function(e,t){e?n(e):r(t)})),i(e,o,t,n)}))}})}}})),Object.freeze(r)}},function(e,t,r){"use strict";var n=r(2),i=r(21),o=i.createWorkerName,s=r(0),a=r(6),u=r(8),f=r(7);e.exports={RTMClient:n,RTMSharedWorkerClient:i,createSharedWorkerName:o,RTMConfig:s,RTMProcessor:a,TLVCodec:u,TLVWebSocketClient:f}},function(e,t,r){"use strict";t.byteLength=function(e){var t=f(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){var t,r,n=f(e),s=n[0],a=n[1],u=new o(function(e,t,r){return 3*(t+r)/4-r}(0,s,a)),c=0,l=a>0?s-4:s;for(r=0;r<l;r+=4)t=i[e.charCodeAt(r)]<<18|i[e.charCodeAt(r+1)]<<12|i[e.charCodeAt(r+2)]<<6|i[e.charCodeAt(r+3)],u[c++]=t>>16&255,u[c++]=t>>8&255,u[c++]=255&t;2===a&&(t=i[e.charCodeAt(r)]<<2|i[e.charCodeAt(r+1)]>>4,u[c++]=255&t);1===a&&(t=i[e.charCodeAt(r)]<<10|i[e.charCodeAt(r+1)]<<4|i[e.charCodeAt(r+2)]>>2,u[c++]=t>>8&255,u[c++]=255&t);return u},t.fromByteArray=function(e){for(var t,r=e.length,i=r%3,o=[],s=0,a=r-i;s<a;s+=16383)o.push(c(e,s,s+16383>a?a:s+16383));1===i?(t=e[r-1],o.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],o.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a<u;++a)n[a]=s[a],i[s.charCodeAt(a)]=a;function f(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 c(e,t,r){for(var i,o,s=[],a=t;a<r;a+=3)i=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),s.push(n[(o=i)>>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(e,t){
|
|
8
|
+
var n=r(14),i=r(15),o=r(16);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),i=(e=a(e,n)).write(t,r);i!==n&&(e=e.slice(0,i));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&&o(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 _(e,t,r,n,i){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=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=u.from(t,n)),u.isBuffer(t))return 0===t.length?-1:m(e,t,r,n,i);if("number"==typeof t)return t&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):m(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function m(e,t,r,n,i){var o,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(i){var f=-1;for(o=r;o<a;o++)if(c(e,o)===c(t,-1===f?0:o-f)){if(-1===f&&(f=o),o-f+1===u)return f*s}else-1!==f&&(o-=o-f),f=-1}else for(r+u>a&&(r=a-u),o=r;o>=0;o--){for(var l=!0,h=0;h<u;h++)if(c(e,o+h)!==c(t,h)){l=!1;break}if(l)return o}return-1}function v(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/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 Y(j(t,e.length-r),e,r,n)}function w(e,t,r,n){return Y(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 Y(q(t),e,r,n)}function R(e,t,r,n){return Y(function(e,t){for(var r,n,i,o=[],s=0;s<e.length&&!((t-=2)<0);++s)r=e.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(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=[],i=t;i<r;){var o,s,a,u,c=e[i],f=null,l=c>239?4:c>223?3:c>191?2:1;if(i+l<=r)switch(l){case 1:c<128&&(f=c);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&c)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&c)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&o)<<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),i+=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,i=0,o=Math.min(r,n);i<o;++i)if(e[i]!==t[i]){r=e[i],n=t[i];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(!o(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),i=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,i),i+=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,i){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===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),c=this.slice(n,i),f=e.slice(t,r),l=0;l<a;++l)if(c[l]!==f[l]){o=c[l],s=f[l];break}return o<s?-1:s<o?1:0},u.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},u.prototype.indexOf=function(e,t,r){return _(this,e,t,r,!0)},u.prototype.lastIndexOf=function(e,t,r){return _(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 i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!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(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!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 i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}function T(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]);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 i="",o=t;o<r;++o)i+=L(e[o]);return i}function S(e,t,r){for(var n=e.slice(t,r),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}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,i,o){if(!u.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)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 i=0,o=Math.min(e.length-r,2);i<o;++i)e[r+i]=(t&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function N(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i<o;++i)e[r+i]=t>>>8*(n?i:3-i)&255}function B(e,t,r,n,i,o){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,o){return o||B(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function D(e,t,r,n,o){return o||B(e,0,r,8),i.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 i=t-e;r=new u(i,void 0);for(var o=0;o<i;++o)r[o]=this[o+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],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;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],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;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],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n>=(i*=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,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},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),i.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return t||M(e,4,this.length),i.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return t||M(e,8,this.length),i.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return t||M(e,8,this.length),i.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 i=1,o=0;for(this[t]=255&e;++o<r&&(i*=256);)this[t+o]=e/i&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 i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&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):N(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):N(this,e,t,!1),t+4},u.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);I(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o<r&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},u.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);I(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(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):N(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):N(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 i,o=n-r;if(this===e&&r<t&&t<n)for(i=o-1;i>=0;--i)e[i+t]=this[i+r];else if(o<1e3||!u.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)e[i+t]=this[i+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+o),t);return o},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 i=e.charCodeAt(0);i<256&&(e=i)}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 o;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o<r;++o)this[o]=e;else{var s=u.isBuffer(e)?e:j(new u(e,n).toString()),a=s.length;for(o=0;o<r-t;++o)this[o+t]=s[o%a]}return this};var F=/[^+\/0-9A-Za-z-_]/g;function L(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,i=null,o=[],s=0;s<n;++s){if((r=e.charCodeAt(s))>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.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;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function q(e){return n.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(F,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Y(e,t,r,n){for(var i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}}).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 i=r(1).fpnn,o=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),i.FPEvent.assign(this),this._map={},this._client=t,this.uid=0,this._expireTimerID=0,this._msgOptions={codec:o.MsgPack.createCodec({int64:!0})},this._binaryOptions={codec:o.MsgPack.createCodec({int64:!0,useraw:!0})},this._binaryMessageMethodList=[o.SERVER_PUSH.recvMessage,o.SERVER_PUSH.recvGroupMessage,o.SERVER_PUSH.recvRoomMessage,o.SERVER_PUSH.recvBroadcastMessage,o.SERVER_PUSH.recvFile,o.SERVER_PUSH.recvGroupFile,o.SERVER_PUSH.recvRoomFile,o.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=o.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,i=!0;o.SERVER_PUSH.kickOut==e.method&&(i=!1),o.SERVER_PUSH.kickOutRoom==e.method&&(i=!1),i&&t&&(0==e.flag&&t(JSON.stringify({}),!1),1==e.flag&&t(o.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=o.MsgPack.decode(e.payload,this._binaryOptions)).mtype==o.CHAT_TYPE.text)s=o.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=o.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(o.SERVER_PUSH.kickOut,e)}},{key:"kickoutroom",value:function(e){e.rid&&(e.rid=new o.Int64(e.rid)),this.emit(o.SERVER_PUSH.kickOutRoom,e)}},{key:"pushmsg",value:function(e){e.from&&(e.from=new o.Int64(e.from)),e.mid&&(e.mid=new o.Int64(e.mid),!a.call(this,1,e.mid,e.from))||(e.mtime&&(e.mtime=new o.Int64(e.mtime)),e.mtype>=40&&e.mtype<=50?this.emit(o.SERVER_PUSH.recvFile,e):e.mtype!=o.CHAT_TYPE.text?e.mtype!=o.CHAT_TYPE.audio?e.mtype!=o.CHAT_TYPE.cmd?(delete e.ftype,this.emit(o.SERVER_PUSH.recvMessage,e)):this.emit(o.SERVER_PUSH.recvCmd,e):this.emit(o.SERVER_PUSH.recvFile,e):this.emit(o.SERVER_PUSH.recvChat,e))}},{key:"pushgroupmsg",value:function(e){e.from&&(e.from=new o.Int64(e.from)),e.mid&&(e.mid=new o.Int64(e.mid),!a.call(this,2,e.mid,e.from,e.gid))||(e.gid&&(e.gid=new o.Int64(e.gid)),e.mtime&&(e.mtime=new o.Int64(e.mtime)),e.mtype>=40&&e.mtype<=50?this.emit(o.SERVER_PUSH.recvGroupFile,e):e.mtype!=o.CHAT_TYPE.text?e.mtype!=o.CHAT_TYPE.audio?e.mtype!=o.CHAT_TYPE.cmd?(delete e.ftype,this.emit(o.SERVER_PUSH.recvGroupMessage,e)):this.emit(o.SERVER_PUSH.recvGroupCmd,e):this.emit(o.SERVER_PUSH.recvGroupFile,e):this.emit(o.SERVER_PUSH.recvGroupChat,e))}},{key:"pushroommsg",value:function(e){e.from&&(e.from=new o.Int64(e.from)),e.mid&&(e.mid=new o.Int64(e.mid),!a.call(this,3,e.mid,e.from,e.rid))||(e.rid&&(e.rid=new o.Int64(e.rid)),e.mtime&&(e.mtime=new o.Int64(e.mtime)),e.mtype>=40&&e.mtype<=50?this.emit(o.SERVER_PUSH.recvRoomFile,e):e.mtype!=o.CHAT_TYPE.text?e.mtype!=o.CHAT_TYPE.audio?e.mtype!=o.CHAT_TYPE.cmd?(delete e.ftype,this.emit(o.SERVER_PUSH.recvRoomMessage,e)):this.emit(o.SERVER_PUSH.recvRoomCmd,e):this.emit(o.SERVER_PUSH.recvRoomFile,e):this.emit(o.SERVER_PUSH.recvRoomChat,e))}},{key:"pushbroadcastmsg",value:function(e){e.from&&(e.from=new o.Int64(e.from)),e.mid&&(e.mid=new o.Int64(e.mid),!a.call(this,4,e.mid,e.from))||(e.mtime&&(e.mtime=new o.Int64(e.mtime)),e.mtype>=40&&e.mtype<=50?this.emit(o.SERVER_PUSH.recvBroadcastFile,e):e.mtype!=o.CHAT_TYPE.text?e.mtype!=o.CHAT_TYPE.audio?e.mtype!=o.CHAT_TYPE.cmd?(delete e.ftype,this.emit(o.SERVER_PUSH.recvBroadcastMessage,e)):this.emit(o.SERVER_PUSH.recvBroadcastCmd,e):this.emit(o.SERVER_PUSH.recvBroadcastFile,e):this.emit(o.SERVER_PUSH.recvBroadcastChat,e))}},{key:"ping",value:function(e){this._client._lastPingTime=parseInt(Date.now()/1e3),this.emit(o.SERVER_PUSH.recvPing,e)}}]),e}());function a(e,t,r,n){var i=[];i.push(e),i.push(t),i.push(r),null!=n&&i.push(n);var s=i.join("_");if(this._map.hasOwnProperty(s)){if(this._map[s]>Date.now())return!1;delete this._map[s]}return this._map[s]=o.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)}),o.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},i=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(9),s=r(23),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 i(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),i=s.toWireRequest(e&&e.method,n.payload,this._requestMetadata,{omitLegacyNil:n.legacyEncoded});this._request(i.uri,i.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 i=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"))}(i)})).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=o.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 i=this._allocateSequence(),o="number"==typeof r&&r>0?r:this._requestTimeout,s={handlers:n,timer:setTimeout(this._onRequestTimeout.bind(this,i),o),uri:e};this._pending.set(i,s);try{this._sendFrame(i,"1",e,t)}catch(e){this._pending.delete(i),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<o.MAX_SEQUENCE;e+=1){var t=this._nextSequence;if(this._nextSequence=t===o.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 i=o.encodeFrame(e,t,r,n),s=i.buffer.slice(i.byteOffset,i.byteOffset+i.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),i=new Uint8Array([2,0,109,116,1,0]),o=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 o("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:o,VERSION:1,decodeFrame:function(e){var t=n.toUint8Array(e);if(0===t.length||t.length>67239936)throw new o("TLV frame length is outside the allowed limit");if(t.length<27)throw new o("TLV frame is too short");if(204!==t[0]||1!==t[1]||4!==t[2]||0!==t[3])throw new o("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 o("TLV v1 metadata length must be exactly 7");for(var a=0;a<i.length;a+=1)if(t[10+a]!==i[a])throw new o("TLV v1 metadata must contain only key mt");var c=t[16];if(48!==c&&49!==c&&50!==c)throw new o("TLV v1 metadata mt is invalid");var f=String.fromCharCode(c);if(u(t,17)!==t.length-21)throw new o("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 o("invalid URI length in message queue");var d=n.utf8Decode(t.subarray(l,l+h));if(0!==t[l+=h])throw new o("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 o("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 o)throw e;throw new o("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 o('metadata mt must be "0", "1", or "2"')}(t);var c=function(e){if("string"!=typeof e||0===e.length)throw new o("URI must be a non-empty UTF-8 string");var t=n.utf8Encode(e);if(0===t.length||t.length>255)throw new o("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 o("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 o("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(i,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},i=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,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(11),d=h.normalizeClientOptions,p=h.sharedEndpoint,g=r(12),y="__rtmSharedWorkerType__",_=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}(),m={sendFile:!0,sendGroupFile:!0,sendRoomFile:!0},v=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 i=function(e){if(null!=e&&""!==e){if("string"!=typeof e)throw new Error("RTMSharedWorkerClient workerUrl must be a string");return e}if(!_)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",_)}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),o=d(n.clientOptions);if("function"==typeof o.requestMetadata||"function"==typeof o.requestMetadataProvider||"function"==typeof o.webSocketFactory)throw new Error("SharedWorker client options must be structured-cloneable; requestMetadata and webSocketFactory functions are not supported");var a,c=g(n.conversation),f=n.workerName||(void 0!==n.uid&&null!==n.uid?b({pid:o.pid,uid:n.uid,protocol:o.protocol,endpoint:p(o),namespace:n.workerNamespace}):"fpnn"===o.protocol?"rtm-shared-worker:fpnn":"rtm-shared-worker"),l=void 0===n.idleShutdownTimeout?5e3:n.idleShutdownTimeout;if(!("number"==typeof(a=l)&&isFinite(a)&&a>=0))throw new Error("RTMSharedWorkerClient idleShutdownTimeout must be a non-negative number");if(this._listeners={},this._processorListeners={},this._callbackSeq=0,this._callbacks=new Map,this._destroyed=!1,this._destroying=!1,this._failedError=null,this._conversation=c,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(i,f),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:o,conversation:c,idleShutdownTimeout:l})){var h=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}),h)}else this._settleReady(new Error("Failed to initialize the RTM SharedWorker client")),this.destroy();var y=this;this.processor={on:function(e,t){return y._addListener(y._processorListeners,e,t),this},off:function(e,t){return y._removeListener(y._processorListeners,e,t),this},removeEvent:function(e,t){return 0===arguments.length?y._processorListeners={}:y._removeListener(y._processorListeners,e,t),this}}}return i(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:"removeEvent",value:function(e,t){return 0===arguments.length?this._listeners={}:this._removeListener(this._listeners,e,t),this}},{key:"whenReady",value:function(){return this._readyPromise.then(E)}},{key:"getSharedSession",value:function(){return E(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(i,o){var s=++n._callbackSeq,a=function(e){e instanceof Error?o(e):i(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),o(new Error("Failed to request shared RTM login")))}))}))}},{key:"setConversation",value:function(e,t){var r=g(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}this._conversation=r;var i=void 0;if("function"==typeof t){i=++this._callbackSeq;var o=function(e){t(e)};o.fail=t,this._callbacks.set(i,o)}return this._post({type:"setConversation",conversation:r,requestId:i})||void 0===i||(this._callbacks.delete(i),t(new Error("Failed to send conversation route to SharedWorker"))),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={},this._processorListeners={},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("conversation-set"!==t.type)if("event"!==t.type)if("login-result"!==t.type)if("error"!==t.type){if("ready"===t.type){var r=w(t.session);return this._session=r,this._settleReady(null,r),void this._emit(this._listeners,"SharedWorkerReady",[r])}"session-state"===t.type&&(this._session=w(t.session),this._emit(this._listeners,"SharedSessionState",[E(this._session)]))}else{var n=O(t.error,a),i=null;if(void 0!==t.requestId){var o=this._callbacks.get(t.requestId);o&&(this._callbacks.delete(t.requestId),o(n))}else this._failedError=n,i=this._failPendingCallbacks(n);try{this._settleReady(n),this._emit(this._listeners,"SharedWorkerError",[n])}finally{!0===t.fatal&&this.destroy()}if(i)throw i.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);this._emit("processor"===t.channel?this._processorListeners:this._listeners,t.name,u)}else{var c=this._callbacks.get(t.requestId);c&&(this._callbacks.delete(t.requestId),c(null))}else{var f=this._callbacks.get(t.callbackId);f&&(this._callbacks.delete(t.callbackId),f.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,i){if("function"==typeof n.fail||n.rejectOnDestroy){t._callbacks.delete(i);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,i){i<=e||(r._callbacks.delete(i),"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(E(t)))}}]),e}();function b(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 i=void 0===e.protocol?"tlv-v1":e.protocol;if("tlv-v1"!==i&&"fpnn"!==i)throw new Error('createSharedWorkerName protocol must be "tlv-v1" or "fpnn"');var o=[String(void 0===e.namespace||null===e.namespace?"":e.namespace),t,r,String(void 0===e.endpoint||null===e.endpoint?"":e.endpoint)];return"fpnn"===i&&o.unshift(i),"rtm-shared:"+o.map((function(e){var t=encodeURIComponent(e);return t.length+":"+t})).join("|")}function w(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 E(e){return{status:e.status,uid:e.uid}}function k(e,t){if("function"==typeof t){var r=new Error("File sending is not supported by RTMSharedWorkerClient");r.code=a.ERROR_CODE.RTM_EC_UNKNOWN_ERROR,t({mid:e,error:r},null)}}function R(e,t,r,i){if("function"==typeof e){var s=++r._callbackSeq,u=function(){return e.apply(null,arguments)};return u.fail=function(t){"login"===i?e(!1,t.status||a.ERROR_CODE.RTM_EC_UNKNOWN_ERROR):e(t,null)},t.set(s,u),o({},"__rtmSharedWorkerCallback__",s)}if(e&&"object"===(void 0===e?"undefined":n(e))){var c,h;if(f.isInt64BE(e))return o(c={},y,"int64"),o(c,"value",e.toString()),c;if(l.isUint64BE(e))return o(h={},y,"uint64"),o(h,"value",e.toString()),h;if(Array.isArray(e))return e.map((function(e){return R(e,t,r,i)}));if(T(e)){var d={};return Object.keys(e).forEach((function(n){d[n]=R(e[n],t,r,i)})),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[y])return t.Int64(e.value);if("uint64"===e[y])return t.Uint64(e.value);if("error"===e[y]){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}v.createWorkerName=b,Object.getOwnPropertyNames(s.prototype).forEach((function(e){"constructor"===e||"destroy"===e||"_"===e.charAt(0)||m[e]||Object.defineProperty(v.prototype,e,{configurable:!0,enumerable:!1,writable:!0,value:function(){return this._invoke(e,Array.prototype.slice.call(arguments))}})})),v.prototype.sendFile=function(e,t,r,n,i,o){k(n,o)},v.prototype.sendGroupFile=function(e,t,r,n,i,o){k(n,o)},v.prototype.sendRoomFile=function(e,t,r,n,i,o){k(n,o)},e.exports=v},function(e,t,r){"use strict";var n=r(0);var i={"tlv-v1":{},fpnn:{}};function o(e,t,r,n){t.forEach((function(t){i[e][t]={type:r,field:n}}))}var s=n.TLV_SERVER_PUSH;o("tlv-v1",[s.recvMessage],"direct","sender"),o("tlv-v1",[s.recvGroupMessage],"group","group_ref"),o("tlv-v1",[s.recvRoomMessage,s.kickOutRoom],"room","room_ref");var a=n.SERVER_PUSH;o("fpnn",[a.recvMessage,a.recvChat,a.recvAudio,a.recvCmd,a.recvFile],"direct","from"),o("fpnn",[a.recvGroupMessage,a.recvGroupChat,a.recvGroupAudio,a.recvGroupCmd,a.recvGroupFile],"group","gid"),o("fpnn",[a.recvRoomMessage,a.recvRoomChat,a.recvRoomAudio,a.recvRoomCmd,a.recvRoomFile,a.kickOutRoom],"room","rid"),e.exports={normalizeClientOptions:function(e){var t=Object.assign({},e||{});if(void 0===t.protocol&&(t.protocol="tlv-v1"),"tlv-v1"!==t.protocol&&"fpnn"!==t.protocol)throw new Error('SharedWorker protocol must be "tlv-v1" or "fpnn"');if("fpnn"===t.protocol){var r=void 0!==t.ssl_endpoint?t.ssl_endpoint:t.endpoint;if("string"!=typeof r||!r.trim()||/[\s/?#]/.test(r))throw new Error("SharedWorker FPNN requires endpoint or ssl_endpoint as host[:port], without a URL scheme or path")}return t},sharedEndpoint:function(e){if("tlv-v1"===e.protocol)return e.tlvEndpoint||e.tlv_endpoint||e.endpoint||e.ssl_endpoint;if(void 0!==e.ssl_endpoint)return"wss://"+e.ssl_endpoint+"/service/websocket";var t=e.endpoint.split(":");return"ws://"+(2===t.length&&"13325"===t[1]?t[0]+":13321":e.endpoint)+"/service/websocket"},conversationRoute:function(e,t,r){var n=i[e],o=n&&Object.prototype.hasOwnProperty.call(n,t)?n[t]:null;return o?{type:o.type,id:r&&r[o.field]}:null}}},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},i=r(1),o=i.Int64BE,s=i.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&&(o.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(2),i=r(10),o=r(24),s=i.createWorkerName,a=r(0),u=r(7),c=r(9),f=r(8);e.exports={RTMClient:n,createClient:o,RTMSharedWorkerClient:i,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 o(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=i[e.charCodeAt(r)]<<18|i[e.charCodeAt(r+1)]<<12|i[e.charCodeAt(r+2)]<<6|i[e.charCodeAt(r+3)],u[f++]=t>>16&255,u[f++]=t>>8&255,u[f++]=255&t;2===a&&(t=i[e.charCodeAt(r)]<<2|i[e.charCodeAt(r+1)]>>4,u[f++]=255&t);1===a&&(t=i[e.charCodeAt(r)]<<10|i[e.charCodeAt(r+1)]<<4|i[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,i=r%3,o=[],s=0,a=r-i;s<a;s+=16383)o.push(f(e,s,s+16383>a?a:s+16383));1===i?(t=e[r-1],o.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],o.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a<u;++a)n[a]=s[a],i[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 i,o,s=[],a=t;a<r;a+=3)i=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),s.push(n[(o=i)>>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(e,t){
|
|
9
9
|
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
10
|
-
t.read=function(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<<a)-1,f=u>>1,c=-7,l=r?i-1:0,h=r?-1:1,d=e[t+l];for(l+=h,o=d&(1<<-c)-1,d>>=-c,c+=a;c>0;o=256*o+e[t+l],l+=h,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=n;c>0;s=256*s+e[t+l],l+=h,c-=8);if(0===o)o=1-f;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=f}return(d?-1:1)*s*Math.pow(2,o-n)},t.write=function(e,t,r,n,i,o){var s,a,u,f=8*o-i-1,c=(1<<f)-1,l=c>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-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=c):(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>=c?(a=0,s=c):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<<i|a,f+=i;f>0;e[r+d]=255&s,d+=p,s/=256,f-=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){window,e.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.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 i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));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}}(),i=r(10).Buffer,o={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=i.from([0,1]),a=i.from([64,128]),u=i.from([0,1,2]),f=i.from("FPNN"),c=i.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 i}},{key:"ERROR_CODE",get:function(){return o}},{key:"FP_FLAG",get:function(){return a}},{key:"FP_MESSAGE_TYPE",get:function(){return u}},{key:"TCP_MAGIC",get:function(){return f}},{key:"HTTP_MAGIC",get:function(){return c}},{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}}(),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,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 i=[],o=1;o<arguments.length;o++)i[o-1]=arguments[o];n.apply(e,i)}}},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=i},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 i=r(1),o=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),i.assign(this),this._endpoint=t.endpoint||null,this._timeout=t.connectionTimeout||1e4,this._platform=t.platformImpl||new o,this._connectTimeout=0,this._queue=[];var r=this;i.assign(this._platform),this._platform.on("open",(function(){f.call(r)})),this._platform.on("message",(function(e){u.call(r,e)})),this._platform.on("close",(function(){c.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 c.call(e);l.call(e,t),c.call(e)}}),this._timeout),this._platform.open(this._endpoint)}}},{key:"destroy",value:function(){this.removeEvent(),this.close(),this._platform.removeEvent(),c.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 f(){this._connectTimeout&&(clearTimeout(this._connectTimeout),this._connectTimeout=0),a.call(this),this.emit("connect")}function c(){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}}(),i=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=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}}(),i=r(0),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,[{key:"buildPkgData",value:function(e){var t={};return t.magic=e.magic||i.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=i.BUFFER.byteLength(t.payload)),t.method&&(t.ss=i.BUFFER.byteLength(t.method)),t.wpos=0,t}},{key:"cbKey",value:function(e){return e.magic+"_"+e.seq}},{key:"isHTTP",value:function(e){return i.HTTP_MAGIC.equals(e.magic)}},{key:"isTCP",value:function(e){return i.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=i.BUFFER.from(e.method);if(e.wpos+=r.copy(t,e.wpos,0),this.isJson(e)){var n=i.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=i.BUFFER.from(e.method);if(e.wpos+=r.copy(t,e.wpos,0),this.isJson(e)){var n=i.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=i.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=i.BUFFER.allocUnsafe(4);return r+=e.copy(n,0,r,r+4),t.magic=n,n=i.BUFFER.allocUnsafe(1),r+=e.copy(n,0,r,r+1),t.version=i.FPNN_VERSION.indexOf(n),r+=e.copy(n,0,r,r+1),t.flag=i.FP_FLAG.indexOf(n),r+=e.copy(n,0,r,r+1),t.mtype=i.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=i.BUFFER.allocUnsafe(t.ss);t.wpos+=e.copy(r,0,t.wpos,t.wpos+t.ss),t.method=r.toString();var n=i.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=i.BUFFER.allocUnsafe(t.ss);t.wpos+=e.copy(r,0,t.wpos,t.wpos+t.ss),t.method=r.toString();var n=i.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=i.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=i.BUFFER.allocUnsafe(t);return this.isHTTP(e)&&(e.wpos+=i.HTTP_MAGIC.copy(r,e.wpos,0)),this.isTCP(e)&&(e.wpos+=i.TCP_MAGIC.copy(r,e.wpos,0)),e.wpos+=i.FPNN_VERSION.copy(r,e.wpos,e.version,e.version+1),this.isJson(e)&&(e.wpos+=i.FP_FLAG.copy(r,e.wpos,e.flag,e.flag+1)),this.isMsgPack(e)&&(e.wpos+=i.FP_FLAG.copy(r,e.wpos,e.flag,e.flag+1)),e.wpos+=i.FP_MESSAGE_TYPE.copy(r,e.wpos,e.mtype,e.mtype+1),r}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}}(),i=r(0),o=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=i.SEND_TIMEOUT),this._exMap[e]=r+Date.now()}},{key:"removeCb",value:function(e){if(e)c.call(this,e);else for(var t in this._cbMap)u.call(this,t,new o(i.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 o(i.ERROR_CODE.FPNN_EC_CORE_TIMEOUT,Error("Timeout")))}),i.CHECK_CBS_INTERVAL)}function u(e,t){var r=this;setTimeout((function(){f.call(r,e,t)}),0)}function f(e,t){if(this._cbMap.hasOwnProperty(e)){var r=this._cbMap[e];l.call(this,e),r&&r(t)}}function c(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}}(),i=r(1),o=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),i.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=o},function(e,t,r){"use strict";var n=r(9),i=r(0),o=r(1),s=r(3),a=r(5),u=r(6),f=r(7),c=r(2),l=r(4),h=r(13);e.exports={FPClient:n,FPConfig:i,FPEvent:o,FPSocket:s,FPPackage:a,FPCallback:u,FPProcessor:f,FPError:c,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}}(),i=r(0),o=r(1),s=r(3),a=r(5),u=r(6),f=r(7),c=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),o.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 c(i.ERROR_CODE.FPNN_EC_CORE_UNKNOWN_ERROR,e))})),this._pkg=new a,this._cbs=new u,this._psr=new f,this._seq=0,this._wpos=0,this._peekData=null,this._readID=0,this._reconnectID=0,this._buffer=i.BUFFER.allocUnsafe(i.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||i.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 o=this._pkg.enCode(n);this._conn.write(o)}else t&&t(new c(i.ERROR_CODE.FPNN_EC_CORE_CONNECTION_CLOSED,new Error("Connection Closed")))}},{key:"sendNotify",value:function(e){var t={};t.magic=e.magic||i.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=i.BUFFER.allocUnsafe(i.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=i.BUFFER.from(e);var t=this._wpos+e.length;if(t>this._buffer.length&&_.call(this,t,2*i.READ_BUFFER_LEN),this._wpos+=e.copy(this._buffer,this._wpos,0),!this._readID){var r=this;this._readID=setInterval((function(){m.call(r)}),0)}}function _(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=Math.max(e,t),o=i.BUFFER.allocUnsafe(n);this._wpos=this._buffer.copy(o,0,r,this._wpos),this._buffer=o}function m(){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(_.call(this,2*e,i.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 c(i.ERROR_CODE.FPNN_EC_PROTO_INVALID_PACKAGE,new Error("Invalid Protocol Package")))}function v(e,t,r,n){var i={flag:e,mtype:2,seq:t,ss:(n=n||!1)?1:0,payload:r};this.sendQuest(i)}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=i.BUFFER.allocUnsafe(t.pkgLen))}return t}function w(e){return!(!i.TCP_MAGIC.equals(e.magic)&&!i.HTTP_MAGIC.equals(e.magic)||e.version<0||e.version>=i.FPNN_VERSION.length||e.flag<0||e.flag>=i.FP_FLAG.length||e.mtype<0||e.mtype>=i.FP_MESSAGE_TYPE.length)}e.exports=l},function(e,t,r){"use strict";
|
|
10
|
+
t.read=function(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<<a)-1,c=u>>1,f=-7,l=r?i-1:0,h=r?-1:1,d=e[t+l];for(l+=h,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=h,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=h,f-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=c}return(d?-1:1)*s*Math.pow(2,o-n)},t.write=function(e,t,r,n,i,o){var s,a,u,c=8*o-i-1,f=(1<<c)-1,l=f>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-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,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<<i|a,c+=i;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 i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.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 i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));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}}(),i=r(10).Buffer,o={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=i.from([0,1]),a=i.from([64,128]),u=i.from([0,1,2]),c=i.from("FPNN"),f=i.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 i}},{key:"ERROR_CODE",get:function(){return o}},{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}}(),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,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 i=[],o=1;o<arguments.length;o++)i[o-1]=arguments[o];n.apply(e,i)}}},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=i},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 i=r(1),o=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),i.assign(this),this._endpoint=t.endpoint||null,this._timeout=t.connectionTimeout||1e4,this._platform=t.platformImpl||new o,this._connectTimeout=0,this._queue=[];var r=this;i.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}}(),i=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=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}}(),i=r(0),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,[{key:"buildPkgData",value:function(e){var t={};return t.magic=e.magic||i.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=i.BUFFER.byteLength(t.payload)),t.method&&(t.ss=i.BUFFER.byteLength(t.method)),t.wpos=0,t}},{key:"cbKey",value:function(e){return e.magic+"_"+e.seq}},{key:"isHTTP",value:function(e){return i.HTTP_MAGIC.equals(e.magic)}},{key:"isTCP",value:function(e){return i.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=i.BUFFER.from(e.method);if(e.wpos+=r.copy(t,e.wpos,0),this.isJson(e)){var n=i.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=i.BUFFER.from(e.method);if(e.wpos+=r.copy(t,e.wpos,0),this.isJson(e)){var n=i.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=i.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=i.BUFFER.allocUnsafe(4);return r+=e.copy(n,0,r,r+4),t.magic=n,n=i.BUFFER.allocUnsafe(1),r+=e.copy(n,0,r,r+1),t.version=i.FPNN_VERSION.indexOf(n),r+=e.copy(n,0,r,r+1),t.flag=i.FP_FLAG.indexOf(n),r+=e.copy(n,0,r,r+1),t.mtype=i.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=i.BUFFER.allocUnsafe(t.ss);t.wpos+=e.copy(r,0,t.wpos,t.wpos+t.ss),t.method=r.toString();var n=i.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=i.BUFFER.allocUnsafe(t.ss);t.wpos+=e.copy(r,0,t.wpos,t.wpos+t.ss),t.method=r.toString();var n=i.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=i.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=i.BUFFER.allocUnsafe(t);return this.isHTTP(e)&&(e.wpos+=i.HTTP_MAGIC.copy(r,e.wpos,0)),this.isTCP(e)&&(e.wpos+=i.TCP_MAGIC.copy(r,e.wpos,0)),e.wpos+=i.FPNN_VERSION.copy(r,e.wpos,e.version,e.version+1),this.isJson(e)&&(e.wpos+=i.FP_FLAG.copy(r,e.wpos,e.flag,e.flag+1)),this.isMsgPack(e)&&(e.wpos+=i.FP_FLAG.copy(r,e.wpos,e.flag,e.flag+1)),e.wpos+=i.FP_MESSAGE_TYPE.copy(r,e.wpos,e.mtype,e.mtype+1),r}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}}(),i=r(0),o=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=i.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 o(i.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 o(i.ERROR_CODE.FPNN_EC_CORE_TIMEOUT,Error("Timeout")))}),i.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}}(),i=r(1),o=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),i.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=o},function(e,t,r){"use strict";var n=r(9),i=r(0),o=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:i,FPEvent:o,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}}(),i=r(0),o=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),o.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(i.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=i.BUFFER.allocUnsafe(i.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||i.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 o=this._pkg.enCode(n);this._conn.write(o)}else t&&t(new f(i.ERROR_CODE.FPNN_EC_CORE_CONNECTION_CLOSED,new Error("Connection Closed")))}},{key:"sendNotify",value:function(e){var t={};t.magic=e.magic||i.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=i.BUFFER.allocUnsafe(i.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=i.BUFFER.from(e);var t=this._wpos+e.length;if(t>this._buffer.length&&_.call(this,t,2*i.READ_BUFFER_LEN),this._wpos+=e.copy(this._buffer,this._wpos,0),!this._readID){var r=this;this._readID=setInterval((function(){m.call(r)}),0)}}function _(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=Math.max(e,t),o=i.BUFFER.allocUnsafe(n);this._wpos=this._buffer.copy(o,0,r,this._wpos),this._buffer=o}function m(){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(_.call(this,2*e,i.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(i.ERROR_CODE.FPNN_EC_PROTO_INVALID_PACKAGE,new Error("Invalid Protocol Package")))}function v(e,t,r,n){var i={flag:e,mtype:2,seq:t,ss:(n=n||!1)?1:0,payload:r};this.sendQuest(i)}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=i.BUFFER.allocUnsafe(t.pkgLen))}return t}function w(e){return!(!i.TCP_MAGIC.equals(e.magic)&&!i.HTTP_MAGIC.equals(e.magic)||e.version<0||e.version>=i.FPNN_VERSION.length||e.flag<0||e.flag>=i.FP_FLAG.length||e.mtype<0||e.mtype>=i.FP_MESSAGE_TYPE.length)}e.exports=l},function(e,t,r){"use strict";
|
|
11
11
|
/*!
|
|
12
12
|
* The buffer module from node.js, for the browser.
|
|
13
13
|
*
|
|
14
14
|
* @author Feross Aboukhadijeh <https://feross.org>
|
|
15
15
|
* @license MIT
|
|
16
|
-
*/var n=r(11),i=r(12);function o(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 f(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=o(r),i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}(e,t);if(ArrayBuffer.isView(e))return c(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(L(e,ArrayBuffer)||e&&L(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 i=function(e){if(s.isBuffer(e)){var t=0|l(e.length),r=o(t);return 0===r.length||e.copy(r,0,0,t),r}return void 0!==e.length?"number"!=typeof e.length||j(e.length)?o(0):c(e):"Buffer"===e.type&&Array.isArray(e.data)?c(e.data):void 0}(e);if(i)return i;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 f(e){return u(e),o(e<0?0:0|l(e))}function c(e){for(var t=e.length<0?0:0|l(e.length),r=o(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)||L(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 i=!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 F(e).length;default:if(i)return n?-1:x(e).length;t=(""+t).toLowerCase(),i=!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,i){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=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)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,i);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):y(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function y(e,t,r,n,i){var o,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 f(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var c=-1;for(o=r;o<a;o++)if(f(e,o)===f(t,-1===c?0:o-c)){if(-1===c&&(c=o),o-c+1===u)return c*s}else-1!==c&&(o-=o-c),c=-1}else for(r+u>a&&(r=a-u),o=r;o>=0;o--){for(var l=!0,h=0;h<u;h++)if(f(e,o+h)!==f(t,h)){l=!1;break}if(l)return o}return-1}function _(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var o=t.length;n>o/2&&(n=o/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 m(e,t,r,n){return D(x(t,e.length-r),e,r,n)}function v(e,t,r,n){return D(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 D(F(t),e,r,n)}function E(e,t,r,n){return D(function(e,t){for(var r,n,i,o=[],s=0;s<e.length&&!((t-=2)<0);++s)n=(r=e.charCodeAt(s))>>8,i=r%256,o.push(i),o.push(n);return o}(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=[],i=t;i<r;){var o,s,a,u,f=e[i],c=null,l=f>239?4:f>223?3:f>191?2:1;if(i+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&f)<<6|63&o)>127&&(c=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&f)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&f)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),i+=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 i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}function C(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]);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 i="",o=t;o<r;++o)i+=N(e[o]);return i}function T(e,t,r){for(var n=e.slice(t,r),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}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,i,o){if(!s.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)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,i,o){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,o){return t=+t,r>>>=0,o||M(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function U(e,t,r,n,o){return t=+t,r>>>=0,o||M(e,0,r,8),i.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?o(e):void 0!==t?"string"==typeof r?o(e).fill(t,r):o(e).fill(t):o(e)}(e,t,r)},s.allocUnsafe=function(e){return f(e)},s.allocUnsafeSlow=function(e){return f(e)},s.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==s.prototype},s.compare=function(e,t){if(L(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),L(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,i=0,o=Math.min(r,n);i<o;++i)if(e[i]!==t[i]){r=e[i],n=t[i];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),i=0;for(r=0;r<e.length;++r){var o=e[r];if(L(o,Uint8Array)&&(o=s.from(o)),!s.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,i),i+=o.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,i){if(L(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===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(t>>>=0),u=Math.min(o,a),f=this.slice(n,i),c=e.slice(t,r),l=0;l<u;++l)if(f[l]!==c[l]){o=f[l],a=c[l];break}return o<a?-1:a<o?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 i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return _(this,e,t,r);case"utf8":case"utf-8":return m(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(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!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],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;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],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;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],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n>=(i*=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,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},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),i.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return e>>>=0,t||A(e,4,this.length),i.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return e>>>=0,t||A(e,8,this.length),i.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return e>>>=0,t||A(e,8,this.length),i.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 i=1,o=0;for(this[t]=255&e;++o<r&&(i*=256);)this[t+o]=e/i&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 i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&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 i=Math.pow(2,8*r-1);S(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o<r&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},s.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);S(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(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 i=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 o=i-1;o>=0;--o)e[o+t]=this[o+r];else Uint8Array.prototype.set.call(e,this.subarray(r,n),t);return i},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 i=e.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(e=i)}}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 o;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o<r;++o)this[o]=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(o=0;o<r-t;++o)this[o+t]=a[o%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,i=null,o=[],s=0;s<n;++s){if((r=e.charCodeAt(s))>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.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;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function F(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 D(e,t,r,n){for(var i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function L(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=f(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){var t,r,n=f(e),s=n[0],a=n[1],u=new o(function(e,t,r){return 3*(t+r)/4-r}(0,s,a)),c=0,l=a>0?s-4:s;for(r=0;r<l;r+=4)t=i[e.charCodeAt(r)]<<18|i[e.charCodeAt(r+1)]<<12|i[e.charCodeAt(r+2)]<<6|i[e.charCodeAt(r+3)],u[c++]=t>>16&255,u[c++]=t>>8&255,u[c++]=255&t;return 2===a&&(t=i[e.charCodeAt(r)]<<2|i[e.charCodeAt(r+1)]>>4,u[c++]=255&t),1===a&&(t=i[e.charCodeAt(r)]<<10|i[e.charCodeAt(r+1)]<<4|i[e.charCodeAt(r+2)]>>2,u[c++]=t>>8&255,u[c++]=255&t),u},t.fromByteArray=function(e){for(var t,r=e.length,i=r%3,o=[],s=0,a=r-i;s<a;s+=16383)o.push(c(e,s,s+16383>a?a:s+16383));return 1===i?(t=e[r-1],o.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],o.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"=")),o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a<u;++a)n[a]=s[a],i[s.charCodeAt(a)]=a;function f(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 c(e,t,r){for(var i,o,s=[],a=t;a<r;a+=3)i=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),s.push(n[(o=i)>>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(e,t){
|
|
16
|
+
*/var n=r(11),i=r(12);function o(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=o(r),i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),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(L(e,ArrayBuffer)||e&&L(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 i=function(e){if(s.isBuffer(e)){var t=0|l(e.length),r=o(t);return 0===r.length||e.copy(r,0,0,t),r}return void 0!==e.length?"number"!=typeof e.length||j(e.length)?o(0):f(e):"Buffer"===e.type&&Array.isArray(e.data)?f(e.data):void 0}(e);if(i)return i;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),o(e<0?0:0|l(e))}function f(e){for(var t=e.length<0?0:0|l(e.length),r=o(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)||L(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 i=!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(i)return n?-1:x(e).length;t=(""+t).toLowerCase(),i=!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,i){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=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)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,i);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):y(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function y(e,t,r,n,i){var o,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(i){var f=-1;for(o=r;o<a;o++)if(c(e,o)===c(t,-1===f?0:o-f)){if(-1===f&&(f=o),o-f+1===u)return f*s}else-1!==f&&(o-=o-f),f=-1}else for(r+u>a&&(r=a-u),o=r;o>=0;o--){for(var l=!0,h=0;h<u;h++)if(c(e,o+h)!==c(t,h)){l=!1;break}if(l)return o}return-1}function _(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var o=t.length;n>o/2&&(n=o/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 m(e,t,r,n){return F(x(t,e.length-r),e,r,n)}function v(e,t,r,n){return F(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 F(D(t),e,r,n)}function E(e,t,r,n){return F(function(e,t){for(var r,n,i,o=[],s=0;s<e.length&&!((t-=2)<0);++s)n=(r=e.charCodeAt(s))>>8,i=r%256,o.push(i),o.push(n);return o}(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=[],i=t;i<r;){var o,s,a,u,c=e[i],f=null,l=c>239?4:c>223?3:c>191?2:1;if(i+l<=r)switch(l){case 1:c<128&&(f=c);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&c)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&c)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&o)<<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),i+=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 i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}function C(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]);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 i="",o=t;o<r;++o)i+=B(e[o]);return i}function T(e,t,r){for(var n=e.slice(t,r),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}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,i,o){if(!s.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)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,i,o){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,o){return t=+t,r>>>=0,o||M(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function U(e,t,r,n,o){return t=+t,r>>>=0,o||M(e,0,r,8),i.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?o(e):void 0!==t?"string"==typeof r?o(e).fill(t,r):o(e).fill(t):o(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(L(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),L(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,i=0,o=Math.min(r,n);i<o;++i)if(e[i]!==t[i]){r=e[i],n=t[i];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),i=0;for(r=0;r<e.length;++r){var o=e[r];if(L(o,Uint8Array)&&(o=s.from(o)),!s.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,i),i+=o.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,i){if(L(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===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(t>>>=0),u=Math.min(o,a),c=this.slice(n,i),f=e.slice(t,r),l=0;l<u;++l)if(c[l]!==f[l]){o=c[l],a=f[l];break}return o<a?-1:a<o?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 i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return _(this,e,t,r);case"utf8":case"utf-8":return m(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(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!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],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;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],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;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],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n>=(i*=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,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},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),i.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return e>>>=0,t||A(e,4,this.length),i.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return e>>>=0,t||A(e,8,this.length),i.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return e>>>=0,t||A(e,8,this.length),i.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 i=1,o=0;for(this[t]=255&e;++o<r&&(i*=256);)this[t+o]=e/i&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 i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&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 i=Math.pow(2,8*r-1);S(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o<r&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},s.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);S(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(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 i=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 o=i-1;o>=0;--o)e[o+t]=this[o+r];else Uint8Array.prototype.set.call(e,this.subarray(r,n),t);return i},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 i=e.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(e=i)}}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 o;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o<r;++o)this[o]=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(o=0;o<r-t;++o)this[o+t]=a[o%u]}return this};var N=/[^+/0-9A-Za-z-_]/g;function B(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,i=null,o=[],s=0;s<n;++s){if((r=e.charCodeAt(s))>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.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;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function D(e){return n.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(N,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function F(e,t,r,n){for(var i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function L(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 o(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=i[e.charCodeAt(r)]<<18|i[e.charCodeAt(r+1)]<<12|i[e.charCodeAt(r+2)]<<6|i[e.charCodeAt(r+3)],u[f++]=t>>16&255,u[f++]=t>>8&255,u[f++]=255&t;return 2===a&&(t=i[e.charCodeAt(r)]<<2|i[e.charCodeAt(r+1)]>>4,u[f++]=255&t),1===a&&(t=i[e.charCodeAt(r)]<<10|i[e.charCodeAt(r+1)]<<4|i[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,i=r%3,o=[],s=0,a=r-i;s<a;s+=16383)o.push(f(e,s,s+16383>a?a:s+16383));return 1===i?(t=e[r-1],o.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],o.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"=")),o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a<u;++a)n[a]=s[a],i[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 i,o,s=[],a=t;a<r;a+=3)i=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),s.push(n[(o=i)>>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(e,t){
|
|
17
17
|
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
18
|
-
t.read=function(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<<a)-1,f=u>>1,c=-7,l=r?i-1:0,h=r?-1:1,d=e[t+l];for(l+=h,o=d&(1<<-c)-1,d>>=-c,c+=a;c>0;o=256*o+e[t+l],l+=h,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=n;c>0;s=256*s+e[t+l],l+=h,c-=8);if(0===o)o=1-f;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=f}return(d?-1:1)*s*Math.pow(2,o-n)},t.write=function(e,t,r,n,i,o){var s,a,u,f=8*o-i-1,c=(1<<f)-1,l=c>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-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=c):(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>=c?(a=0,s=c):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<<i|a,f+=i;f>0;e[r+d]=255&s,d+=p,s/=256,f-=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}}(),i=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=i}])},function(e,t,r){(function(t){e.exports=function e(t,r,n){function i(s,a){if(!r[s]){if(!t[s]){if(o)return o(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var f=r[s]={exports:{}};t[s][0].call(f.exports,(function(e){var r=t[s][1][e];return i(r||e)}),f,f.exports,e,t,r,n)}return r[s].exports}for(var o=!1,s=0;s<n.length;s++)i(n[s]);return i}({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 i;r||(r=0),n||0===n||(n=this.length),t||(t=0);var o=n-r;if(e===this&&r<t&&t<n)for(i=o-1;i>=0;i--)e[i+t]=this[i+r];else for(i=0;i<o;i++)e[i+t]=this[i+r];return o},r.toString=function(e,t,r){var n=this,i=0|t;r||(r=n.length);for(var o="",s=0;i<r;)(s=n[i++])<128?o+=String.fromCharCode(s):(192==(224&s)?s=(31&s)<<6|63&n[i++]:224==(240&s)?s=(15&s)<<12|(63&n[i++])<<6|63&n[i++]:240==(248&s)&&(s=(7&s)<<18|(63&n[i++])<<12|(63&n[i++])<<6|63&n[i++]),s>=65536?(s-=65536,o+=String.fromCharCode(55296+(s>>>10),56320+(1023&s))):o+=String.fromCharCode(s));return o},r.write=function(e,t){for(var r=this,n=t||(t|=0),i=e.length,o=0,s=0;s<i;)(o=e.charCodeAt(s++))<128?r[n++]=o:o<2048?(r[n++]=192|o>>>6,r[n++]=128|63&o):o<55296||o>57343?(r[n++]=224|o>>>12,r[n++]=128|o>>>6&63,r[n++]=128|63&o):(o=65536+(o-55296<<10|e.charCodeAt(s++)-56320),r[n++]=240|o>>>18,r[n++]=128|o>>>12&63,r[n++]=128|o>>>6&63,r[n++]=128|63&o);return n-t}},{}],4:[function(e,t,r){function n(e){return new Array(e)}var i=e("./bufferish");(r=t.exports=n(0)).alloc=n,r.concat=i.concat,r.from=function(e){if(!i.isBuffer(e)&&i.isView(e))e=i.Uint8Array.from(e);else if(i.isArrayBuffer(e))e=new Uint8Array(e);else{if("string"==typeof e)return i.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 o(e)}var i=e("./bufferish"),o=i.global;(r=t.exports=i.hasBuffer?n(0):[]).alloc=i.hasBuffer&&o.alloc||n,r.concat=i.concat,r.from=function(e){if(!i.isBuffer(e)&&i.isView(e))e=i.Uint8Array.from(e);else if(i.isArrayBuffer(e))e=new Uint8Array(e);else{if("string"==typeof e)return i.from.call(r,e);if("number"==typeof e)throw new TypeError('"value" argument must not be a number')}return o.from&&1!==o.from.length?o.from(e):new o(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(f||a||u||!s.isView(this)||!s.isView(e))return o.copy.call(this,e,t,r,n);var c=r||null!=n?i.call(this,r,n):this;return e.set(c,t),c.length}function i(e,t){var r=this.slice||!f&&this.subarray;if(r)return r.call(this,e,t);var i=s.alloc.call(this,t-e);return n.call(this,i,0,e,t),i}var o=e("./buffer-lite");r.copy=n,r.slice=i,r.toString=function(e,t,r){var n=!u&&s.isBuffer(this)?this.toString:o.toString;return n.apply(this,arguments)},r.write=function(e){return function(){var t=this[e]||o[e];return t.apply(this,arguments)}}("write");var s=e("./bufferish"),a=s.global,u=s.hasBuffer&&"TYPED_ARRAY_SUPPORT"in a,f=u&&!a.TYPED_ARRAY_SUPPORT},{"./buffer-lite":3,"./bufferish":8}],7:[function(e,t,r){function n(e){return new Uint8Array(e)}var i=e("./bufferish");(r=t.exports=i.hasArrayBuffer?n(0):[]).alloc=n,r.concat=i.concat,r.from=function(e){if(i.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 i.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 o(this).alloc(e)}function i(e){var t=3*e.length,r=n.call(this,t),i=_.write.call(r,e);return t!==i&&(r=_.slice.call(r,0,i)),r}function o(e){return h(e)?g:d(e)?y:l(e)?p:f?g:c?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"),f=r.hasBuffer=u&&!!u.isBuffer,c=r.hasArrayBuffer="undefined"!=typeof ArrayBuffer,l=r.isArray=e("isarray");r.isArrayBuffer=c?function(e){return e instanceof ArrayBuffer||m(e)}:s;var h=r.isBuffer=f?u.isBuffer:s,d=r.isView=c?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 i=this!==r&&this||e[0],o=n.call(i,t),s=0;return Array.prototype.forEach.call(e,(function(e){s+=_.copy.call(e,o,s)})),o},r.from=function(e){return"string"==typeof e?i.call(this,e):o(this).from(e)};var p=r.Array=e("./bufferish-array"),g=r.Buffer=e("./bufferish-buffer"),y=r.Uint8Array=e("./bufferish-uint8array"),_=r.prototype=e("./bufferish-proto"),m=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 i(e,t){return e&&t?function(){return e.apply(this,arguments),t.apply(this,arguments)}:e||t}function o(e){return new n(e)}var s=e("isarray");r.createCodec=o,r.install=function(e){for(var t in e)n.prototype[t]=i(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=o({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 i=e("./read-core").preset;e("./flex-buffer").FlexDecoder.mixin(n.prototype),n.prototype.codec=i,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 o.call(this,e):new n(e)}r.Decoder=n;var i=e("event-lite"),o=e("./decode-buffer").DecodeBuffer;n.prototype=new o,i.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 i=e("./write-core").preset;e("./flex-buffer").FlexEncoder.mixin(n.prototype),n.prototype.codec=i,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 o.call(this,e):new n(e)}r.Encoder=n;var i=e("event-lite"),o=e("./encode-buffer").EncodeBuffer;n.prototype=new o,i.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 i(e){return e.valueOf()}function o(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,[o,n]),e.addExtPacker(11,Boolean,[i,n]),e.addExtPacker(12,String,[i,n]),e.addExtPacker(13,Date,[Number,n]),e.addExtPacker(15,Number,[i,n]),"undefined"!=typeof Uint8Array&&(e.addExtPacker(17,Int8Array,c),e.addExtPacker(18,Uint8Array,c),e.addExtPacker(19,Int16Array,c),e.addExtPacker(20,Uint16Array,c),e.addExtPacker(21,Int32Array,c),e.addExtPacker(22,Uint32Array,c),e.addExtPacker(23,Float32Array,c),"undefined"!=typeof Float64Array&&e.addExtPacker(24,Float64Array,c),"undefined"!=typeof Uint8ClampedArray&&e.addExtPacker(25,Uint8ClampedArray,c),e.addExtPacker(26,ArrayBuffer,c),e.addExtPacker(29,DataView,c)),u.hasBuffer&&e.addExtPacker(27,f,u.from)};var a,u=e("./bufferish"),f=u.global,c=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 i(e){return RegExp.apply(null,e)}function o(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,o(Error)]),e.addExtUnpacker(1,[n,o(EvalError)]),e.addExtUnpacker(2,[n,o(RangeError)]),e.addExtUnpacker(3,[n,o(ReferenceError)]),e.addExtUnpacker(4,[n,o(SyntaxError)]),e.addExtUnpacker(5,[n,o(TypeError)]),e.addExtUnpacker(6,[n,o(URIError)]),e.addExtUnpacker(10,[n,i]),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)])),f.hasBuffer&&e.addExtUnpacker(27,s(c))};var u,f=e("./bufferish"),c=f.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 i(){if(!(this instanceof i))return new i}function o(){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 f(){return(this.buffers||(this.buffers=[])).shift()}function c(e){return function(t){for(var r in e)t[r]=e[r];return t}}r.FlexDecoder=n,r.FlexEncoder=i;var l=e("./bufferish"),h=2048,d=65536,p="BUFFER_SHORTAGE";n.mixin=c({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:f,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),i.mixin=c({bufferish:l,write:o,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,i=n+t;if(i<r)return this.offset=i,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}),i.mixin(i.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&&o.setExtUnpackers(this),this}var i=e("./ext-buffer").ExtBuffer,o=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 i(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={},i=new Array(t),o=new Array(t),s=e.codec.decode;for(r=0;r<t;r++)i[r]=s(e),o[r]=s(e);for(r=0;r<t;r++)n[i[r]]=o[r];return n}function i(e,t){var r,n=new Map,i=new Array(t),o=new Array(t),s=e.codec.decode;for(r=0;r<t;r++)i[r]=s(e),o[r]=s(e);for(r=0;r<t;r++)n.set(i[r],o[r]);return n}function o(e,t){for(var r=new Array(t),n=e.codec.decode,i=0;i<t;i++)r[i]=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,i=T.slice.call(e.buffer,r,n);return O.from(i)}function u(e,t){var r=e.reserve(t),n=r+t,i=T.slice.call(e.buffer,r,n);return O.Uint8Array.from(i).buffer}function f(e,t){var r=e.reserve(t+1),n=e.buffer[r++],i=r+t,o=e.codec.getExtUnpacker(n);if(!o)throw new Error("Invalid ext type: "+(n?"0x"+n.toString(16):n));return o(T.slice.call(e.buffer,r,i))}function c(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 _(e){return new P(this,e).toNumber()}function m(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?i:n,array:o,str:s,bin:t?u:a,ext:f,uint8:c,uint16:h,uint32:p,uint64:y(8,r?v:_),int8:l,int16:d,int32:g,int64:y(8,r?b:m),float32:y(4,w),float64:y(8,E)}},r.readUint8=c;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]=i(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]=i(null),r[193]=null,r[194]=i(!1),r[195]=i(!0),r[196]=o(e.uint8,e.bin),r[197]=o(e.uint16,e.bin),r[198]=o(e.uint32,e.bin),r[199]=o(e.uint8,e.ext),r[200]=o(e.uint16,e.ext),r[201]=o(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]=o(e.uint8,e.str),r[218]=o(e.uint16,e.str),r[219]=o(e.uint32,e.str),r[220]=o(e.uint16,e.array),r[221]=o(e.uint32,e.array),r[222]=o(e.uint16,e.map),r[223]=o(e.uint32,e.map),t=224;t<=255;t++)r[t]=i(t-256);return r}function i(e){return function(){return e}}function o(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&&o.setExtPackers(this),this}var i=e("./ext-buffer").ExtBuffer,o=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 i(t,e)}r=a.filter(r);var o=t.name;o&&"Object"!==o?(this.extPackers||(this.extPackers={}))[o]=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 i=this.extEncoderList||(this.extEncoderList=[]),o=i.length,s=0;s<o;s++){var a=i[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]=i(196),e[197]=o(197),e[198]=s(198),e[199]=i(199),e[200]=o(200),e[201]=s(201),e[202]=a(202,4,b.writeFloatBE||c,!0),e[203]=a(203,8,b.writeDoubleBE||l,!0),e[204]=i(204),e[205]=o(205),e[206]=s(206),e[207]=a(207,8,u),e[208]=i(208),e[209]=o(209),e[210]=s(210),e[211]=a(211,8,f),e[217]=i(217),e[218]=o(218),e[219]=s(219),e[220]=o(220),e[221]=s(221),e[222]=o(222),e[223]=s(223),e}function i(e){return function(t,r){var n=t.reserve(2),i=t.buffer;i[n++]=e,i[n]=r}}function o(e){return function(t,r){var n=t.reserve(3),i=t.buffer;i[n++]=e,i[n++]=r>>>8,i[n]=r}}function s(e){return function(t,r){var n=t.reserve(5),i=t.buffer;i[n++]=e,i[n++]=r>>>24,i[n++]=r>>>16,i[n++]=r>>>8,i[n]=r}}function a(e,t,r,n){return function(i,o){var s=i.reserve(t+1);i.buffer[s++]=e,r.call(i.buffer,o,s,n)}}function u(e,t){new p(this,t,e)}function f(e,t){new g(this,t,e)}function c(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,_=e("./bufferish"),m=_.global,v=_.hasBuffer&&"TYPED_ARRAY_SUPPORT"in m&&!m.TYPED_ARRAY_SUPPORT,b=_.hasBuffer&&m.prototype||{};r.getWriteToken=function(e){return e&&e.uint8array?function(){var e=n();return e[202]=a(202,4,c),e[203]=a(203,8,l),e}():v||_.hasBuffer&&e&&e.safe?function(){var e=y.slice();return e[196]=a(196,1,m.prototype.writeUInt8),e[197]=a(197,2,m.prototype.writeUInt16BE),e[198]=a(198,4,m.prototype.writeUInt32BE),e[199]=a(199,1,m.prototype.writeUInt8),e[200]=a(200,2,m.prototype.writeUInt16BE),e[201]=a(201,4,m.prototype.writeUInt32BE),e[202]=a(202,4,m.prototype.writeFloatBE),e[203]=a(203,8,m.prototype.writeDoubleBE),e[204]=a(204,1,m.prototype.writeUInt8),e[205]=a(205,2,m.prototype.writeUInt16BE),e[206]=a(206,4,m.prototype.writeUInt32BE),e[207]=a(207,8,u),e[208]=a(208,1,m.prototype.writeInt8),e[209]=a(209,2,m.prototype.writeInt16BE),e[210]=a(210,4,m.prototype.writeInt32BE),e[211]=a(211,8,f),e[217]=a(217,1,m.prototype.writeUInt8),e[218]=a(218,2,m.prototype.writeUInt16BE),e[219]=a(219,4,m.prototype.writeUInt32BE),e[220]=a(220,2,m.prototype.writeUInt16BE),e[221]=a(221,4,m.prototype.writeUInt32BE),e[222]=a(222,2,m.prototype.writeUInt16BE),e[223]=a(223,4,m.prototype.writeUInt32BE),e}():n()}},{"./bufferish":8,"./write-uint8":28,ieee754:32,"int64-buffer":33}],27:[function(e,t,r){var n=e("isarray"),i=e("int64-buffer"),o=i.Uint64BE,s=i.Int64BE,a=e("./bufferish"),u=e("./bufferish-proto"),f=e("./write-token"),c=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,i=0;i<r;i++)n(e,t[i])}(e,t);if(o.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 i=e.codec.getExtPacker(t);return i&&(t=i(t)),t instanceof l?function(e,t){var r=t.buffer,n=r.length,i=p[n]||(n<255?199:n<=65535?200:201);y[i](e,n),c[t.type](e),e.send(r)}(e,t):void w(e,t)}function r(e,t){y[192](e,t)}function i(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 i=e.codec.encode;r.forEach((function(r){i(e,r),i(e,t[r])}))}var y=f.getWriteToken(e),_=e&&e.useraw,m=h&&e&&e.binarraybuffer,v=m?a.isArrayBuffer:a.isBuffer,b=m?function(e,t){i(e,new Uint8Array(t))}:i,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,i){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:_?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,i=5+3*n;t.offset=t.reserve(i);var o=t.buffer,s=e(n),a=t.offset+s;n=u.write.call(o,r,a);var f=e(n);if(s!==f){var c=a+f-s,l=a+n;u.copy.call(o,o,c,a,l)}y[1===f?160+n:f<=3?215+f:219](t,n),t.offset+=n}}(_?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 i=r.uint8=new Array(256),o=0;o<=255;o++)i[o]=n(o)},{}],29:[function(e,r,n){(function(t){"use strict";function r(){return o.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function i(e,t){if(r()<t)throw new RangeError("Invalid typed array length");return o.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=o.prototype:(null===e&&(e=new o(t)),e.length=t),e}function o(e,t,r){if(!(o.TYPED_ARRAY_SUPPORT||this instanceof o))return new o(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),o.TYPED_ARRAY_SUPPORT?(e=t).__proto__=o.prototype:e=f(e,t),e}(e,t,r,n):"string"==typeof t?function(e,t,r){if("string"==typeof r&&""!==r||(r="utf8"),!o.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|l(t,r),s=(e=i(e,n)).write(t,r);return s!==n&&(e=e.slice(0,s)),e}(e,t,r):function(e,t){if(o.isBuffer(t)){var r=0|c(t.length);return 0===(e=i(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)?i(e,0):f(e,t);if("Buffer"===t.type&&q(t.data))return f(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=i(e,t<0?0:0|c(t)),!o.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function f(e,t){var r=t.length<0?0:0|c(t.length);e=i(e,r);for(var n=0;n<r;n+=1)e[n]=255&t[n];return e}function c(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(o.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 F(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,i){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=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=o.from(t,n)),o.isBuffer(t))return 0===t.length?-1:g(e,t,r,n,i);if("number"==typeof t)return t&=255,o.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):g(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function g(e,t,r,n,i){function o(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}var s,a=1,u=e.length,f=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,f/=2,r/=2}if(i){var c=-1;for(s=r;s<u;s++)if(o(e,s)===o(t,-1===c?0:s-c)){if(-1===c&&(c=s),s-c+1===f)return c*a}else-1!==c&&(s-=s-c),c=-1}else for(r+f>u&&(r=u-f),s=r;s>=0;s--){for(var l=!0,h=0;h<f;h++)if(o(e,s+h)!==o(t,h)){l=!1;break}if(l)return s}return-1}function y(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/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 _(e,t,r,n){return D(x(t,e.length-r),e,r,n)}function m(e,t,r,n){return D(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 m(e,t,r,n)}function b(e,t,r,n){return D(F(t),e,r,n)}function w(e,t,r,n){return D(function(e,t){for(var r,n,i,o=[],s=0;s<e.length&&!((t-=2)<0);++s)r=e.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function E(e,t,r){return 0===t&&r===e.length?L.fromByteArray(e):L.fromByteArray(e.slice(t,r))}function k(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i<r;){var o,s,a,u,f=e[i],c=null,l=f>239?4:f>223?3:f>191?2:1;if(i+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&f)<<6|63&o)>127&&(c=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&f)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&f)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),i+=l}return function(e){var t=e.length;if(t<=Y)return String.fromCharCode.apply(String,e);for(var r="",n=0;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=Y));return r}(n)}function R(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}function P(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]);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 i="",o=t;o<r;++o)i+=N(e[o]);return i}function O(e,t,r){for(var n=e.slice(t,r),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}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,i,s){if(!o.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||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 i=0,o=Math.min(e.length-r,2);i<o;++i)e[r+i]=(t&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function M(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i<o;++i)e[r+i]=t>>>8*(n?i:3-i)&255}function I(e,t,r,n,i,o){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,i){return i||I(e,0,r,4),j.write(e,t,r,n,23,4),r+4}function B(e,t,r,n,i){return i||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,i=null,o=[],s=0;s<n;++s){if((r=e.charCodeAt(s))>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.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;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function F(e){return L.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(V,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function D(e,t,r,n){for(var i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}var L=e("base64-js"),j=e("ieee754"),q=e("isarray");n.Buffer=o,n.SlowBuffer=function(e){return+e!=e&&(e=0),o.alloc(+e)},n.INSPECT_MAX_BYTES=50,o.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(),o.poolSize=8192,o._augment=function(e){return e.__proto__=o.prototype,e},o.from=function(e,t,r){return s(null,e,t,r)},o.TYPED_ARRAY_SUPPORT&&(o.prototype.__proto__=Uint8Array.prototype,o.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&o[Symbol.species]===o&&Object.defineProperty(o,Symbol.species,{value:null,configurable:!0})),o.alloc=function(e,t,r){return function(e,t,r,n){return a(t),t<=0?i(e,t):void 0!==r?"string"==typeof n?i(e,t).fill(r,n):i(e,t).fill(r):i(e,t)}(null,e,t,r)},o.allocUnsafe=function(e){return u(null,e)},o.allocUnsafeSlow=function(e){return u(null,e)},o.isBuffer=function(e){return!(null==e||!e._isBuffer)},o.compare=function(e,t){if(!o.isBuffer(e)||!o.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,i=0,s=Math.min(r,n);i<s;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0},o.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}},o.concat=function(e,t){if(!q(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return o.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=o.allocUnsafe(t),i=0;for(r=0;r<e.length;++r){var s=e[r];if(!o.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(n,i),i+=s.length}return n},o.byteLength=l,o.prototype._isBuffer=!0,o.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},o.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},o.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},o.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?k(this,0,e):h.apply(this,arguments)},o.prototype.equals=function(e){if(!o.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===o.compare(this,e)},o.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+">"},o.prototype.compare=function(e,t,r,n,i){if(!o.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===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var s=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(t>>>=0),u=Math.min(s,a),f=this.slice(n,i),c=e.slice(t,r),l=0;l<u;++l)if(f[l]!==c[l]){s=f[l],a=c[l];break}return s<a?-1:a<s?1:0},o.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},o.prototype.indexOf=function(e,t,r){return p(this,e,t,r,!0)},o.prototype.lastIndexOf=function(e,t,r){return p(this,e,t,r,!1)},o.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 i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return y(this,e,t,r);case"utf8":case"utf-8":return _(this,e,t,r);case"ascii":return m(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(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Y=4096;o.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),o.TYPED_ARRAY_SUPPORT)(r=this.subarray(e,t)).__proto__=o.prototype;else{var i=t-e;r=new o(i,void 0);for(var s=0;s<i;++s)r[s]=this[s+e]}return r},o.prototype.readUIntLE=function(e,t,r){e|=0,t|=0,r||T(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n},o.prototype.readUIntBE=function(e,t,r){e|=0,t|=0,r||T(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},o.prototype.readUInt8=function(e,t){return t||T(e,1,this.length),this[e]},o.prototype.readUInt16LE=function(e,t){return t||T(e,2,this.length),this[e]|this[e+1]<<8},o.prototype.readUInt16BE=function(e,t){return t||T(e,2,this.length),this[e]<<8|this[e+1]},o.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]},o.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])},o.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||T(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*t)),n},o.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||T(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},o.prototype.readInt8=function(e,t){return t||T(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},o.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},o.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},o.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},o.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]},o.prototype.readFloatLE=function(e,t){return t||T(e,4,this.length),j.read(this,e,!0,23,4)},o.prototype.readFloatBE=function(e,t){return t||T(e,4,this.length),j.read(this,e,!1,23,4)},o.prototype.readDoubleLE=function(e,t){return t||T(e,8,this.length),j.read(this,e,!0,52,8)},o.prototype.readDoubleBE=function(e,t){return t||T(e,8,this.length),j.read(this,e,!1,52,8)},o.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 i=1,o=0;for(this[t]=255&e;++o<r&&(i*=256);)this[t+o]=e/i&255;return t+r},o.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 i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},o.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||A(this,e,t,1,255,0),o.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},o.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||A(this,e,t,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):S(this,e,t,!0),t+2},o.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||A(this,e,t,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):S(this,e,t,!1),t+2},o.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||A(this,e,t,4,4294967295,0),o.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},o.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||A(this,e,t,4,4294967295,0),o.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},o.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);A(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o<r&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},o.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);A(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},o.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||A(this,e,t,1,127,-128),o.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},o.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||A(this,e,t,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):S(this,e,t,!0),t+2},o.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||A(this,e,t,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):S(this,e,t,!1),t+2},o.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||A(this,e,t,4,2147483647,-2147483648),o.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},o.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),o.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},o.prototype.writeFloatLE=function(e,t,r){return U(this,e,t,!0,r)},o.prototype.writeFloatBE=function(e,t,r){return U(this,e,t,!1,r)},o.prototype.writeDoubleLE=function(e,t,r){return B(this,e,t,!0,r)},o.prototype.writeDoubleBE=function(e,t,r){return B(this,e,t,!1,r)},o.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 i,s=n-r;if(this===e&&r<t&&t<n)for(i=s-1;i>=0;--i)e[i+t]=this[i+r];else if(s<1e3||!o.TYPED_ARRAY_SUPPORT)for(i=0;i<s;++i)e[i+t]=this[i+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+s),t);return s},o.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 i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!o.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=o.isBuffer(e)?e:x(new o(e,n).toString()),u=a.length;for(s=0;s<r-t;++s)this[s+t]=a[s%u]}return this};var V=/[^+\/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 i(e){return s[e>>18&63]+s[e>>12&63]+s[e>>6&63]+s[63&e]}function o(e,t,r){for(var n,o=[],s=t;s<r;s+=3)n=(e[s]<<16)+(e[s+1]<<8)+e[s+2],o.push(i(n));return o.join("")}r.byteLength=function(e){return 3*e.length/4-n(e)},r.toByteArray=function(e){var t,r,i,o,s,f,c=e.length;s=n(e),f=new u(3*c/4-s),i=s>0?c-4:c;var l=0;for(t=0,r=0;t<i;t+=4,r+=3)o=a[e.charCodeAt(t)]<<18|a[e.charCodeAt(t+1)]<<12|a[e.charCodeAt(t+2)]<<6|a[e.charCodeAt(t+3)],f[l++]=o>>16&255,f[l++]=o>>8&255,f[l++]=255&o;return 2===s?(o=a[e.charCodeAt(t)]<<2|a[e.charCodeAt(t+1)]>>4,f[l++]=255&o):1===s&&(o=a[e.charCodeAt(t)]<<10|a[e.charCodeAt(t+1)]<<4|a[e.charCodeAt(t+2)]>>2,f[l++]=o>>8&255,f[l++]=255&o),f},r.fromByteArray=function(e){for(var t,r=e.length,n=r%3,i="",a=[],u=16383,f=0,c=r-n;f<c;f+=u)a.push(o(e,f,f+u>c?c:f+u));return 1===n?(t=e[r-1],i+=s[t>>2],i+=s[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=s[t>>10],i+=s[t>>4&63],i+=s[t<<2&63],i+="="),a.push(i),a.join("")};for(var s=[],a=[],u="undefined"!=typeof Uint8Array?Uint8Array:Array,f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=0,l=f.length;c<l;++c)s[c]=f[c],a[f.charCodeAt(c)]=c;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=i(a,e,!0)){if(!(s=s.filter(r)).length)return n.call(a,e);a[o][e]=s}}else if((s=a[o])&&(delete s[e],!Object.keys(s).length))return n.call(a)}else delete a[o];return a}function i(e,t,r){if(!r||e[o]){var n=e[o]||(e[o]={});return n[t]||(n[t]=[])}}void 0!==t&&(t.exports=e);var o="listeners",s={on:function(e,t){return i(this,e).push(t),this},once:function(e,t){function r(){n.call(o,e,r),t.apply(this,arguments)}var o=this;return r.originalListener=t,i(o,e).push(r),o},off:n,emit:function(e,t){function r(e){e.call(s)}function n(e){e.call(s,t)}function o(e){e.apply(s,f)}var s=this,a=i(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 f=Array.prototype.slice.call(arguments,1);a.forEach(o)}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,i){var o,s,a=8*i-n-1,u=(1<<a)-1,f=u>>1,c=-7,l=r?i-1:0,h=r?-1:1,d=e[t+l];for(l+=h,o=d&(1<<-c)-1,d>>=-c,c+=a;c>0;o=256*o+e[t+l],l+=h,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=n;c>0;s=256*s+e[t+l],l+=h,c-=8);if(0===o)o=1-f;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=f}return(d?-1:1)*s*Math.pow(2,o-n)},r.write=function(e,t,r,n,i,o){var s,a,u,f=8*o-i-1,c=(1<<f)-1,l=c>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-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=c):(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>=c?(a=0,s=c):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<<i|a,f+=i;f>0;e[r+d]=255&s,d+=p,s/=256,f-=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,i){y&&_&&(t instanceof _&&(t=new y(t)),n instanceof _&&(n=new y(n))),t||r||n||d?(s(t,r)||(i=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 i=0,o=r.length,s=0,a=0;"-"===r[0]&&i++;for(var u=i;i<o;){var f=parseInt(r[i++],n);if(!(f>=0))break;a=a*n+f,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,i||10):s(n,i)?a(t,r,n,i):"number"==typeof i?(R(t,r+C,n),R(t,r+O,i)):n>0?I(t,r,n):n<0?U(t,r,n):a(t,r,m,0))):e.buffer=u(m,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?f:l,U=r?c: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),i=P(t,r+O),o="",s=!v&&2147483648&n;for(s&&(n=~n,i=b-i),e=e||10;;){var a=n%e*b+i;if(n=Math.floor(n/e),i=Math.floor(a/e),o=(a%e).toString(e)+o,!n&&!i)break}return s&&(o="-"+o),o},B.toJSON=k,B.toArray=n,g&&(B.toBuffer=i),y&&(B.toArrayBuffer=o),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 i(t){var r=this.buffer,n=this.offset;if(d=g,!1!==t&&0===n&&8===r.length&&e.isBuffer(r))return r;var i=new g(8);return a(i,0,r,n),i}function o(e){var t=this.buffer,r=this.offset,n=t.buffer;if(d=y,!1!==e&&0===r&&n instanceof _&&8===n.byteLength)return n;var i=new y(8);return a(i,0,t,r),i.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 i=0;i<8;i++)e[t++]=255&r[n++]}function u(e,t){return Array.prototype.slice.call(e,t,t+8)}function f(e,t,r){for(var n=t+8;n>t;)e[--n]=255&r,r/=256}function c(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,_=p!==typeof ArrayBuffer&&ArrayBuffer,m=[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__;
|
|
18
|
+
t.read=function(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<<a)-1,c=u>>1,f=-7,l=r?i-1:0,h=r?-1:1,d=e[t+l];for(l+=h,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=h,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=h,f-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=c}return(d?-1:1)*s*Math.pow(2,o-n)},t.write=function(e,t,r,n,i,o){var s,a,u,c=8*o-i-1,f=(1<<c)-1,l=f>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-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,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<<i|a,c+=i;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}}(),i=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=i}])},function(e,t,r){(function(t){e.exports=function e(t,r,n){function i(s,a){if(!r[s]){if(!t[s]){if(o)return o(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 i(r||e)}),c,c.exports,e,t,r,n)}return r[s].exports}for(var o=!1,s=0;s<n.length;s++)i(n[s]);return i}({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 i;r||(r=0),n||0===n||(n=this.length),t||(t=0);var o=n-r;if(e===this&&r<t&&t<n)for(i=o-1;i>=0;i--)e[i+t]=this[i+r];else for(i=0;i<o;i++)e[i+t]=this[i+r];return o},r.toString=function(e,t,r){var n=this,i=0|t;r||(r=n.length);for(var o="",s=0;i<r;)(s=n[i++])<128?o+=String.fromCharCode(s):(192==(224&s)?s=(31&s)<<6|63&n[i++]:224==(240&s)?s=(15&s)<<12|(63&n[i++])<<6|63&n[i++]:240==(248&s)&&(s=(7&s)<<18|(63&n[i++])<<12|(63&n[i++])<<6|63&n[i++]),s>=65536?(s-=65536,o+=String.fromCharCode(55296+(s>>>10),56320+(1023&s))):o+=String.fromCharCode(s));return o},r.write=function(e,t){for(var r=this,n=t||(t|=0),i=e.length,o=0,s=0;s<i;)(o=e.charCodeAt(s++))<128?r[n++]=o:o<2048?(r[n++]=192|o>>>6,r[n++]=128|63&o):o<55296||o>57343?(r[n++]=224|o>>>12,r[n++]=128|o>>>6&63,r[n++]=128|63&o):(o=65536+(o-55296<<10|e.charCodeAt(s++)-56320),r[n++]=240|o>>>18,r[n++]=128|o>>>12&63,r[n++]=128|o>>>6&63,r[n++]=128|63&o);return n-t}},{}],4:[function(e,t,r){function n(e){return new Array(e)}var i=e("./bufferish");(r=t.exports=n(0)).alloc=n,r.concat=i.concat,r.from=function(e){if(!i.isBuffer(e)&&i.isView(e))e=i.Uint8Array.from(e);else if(i.isArrayBuffer(e))e=new Uint8Array(e);else{if("string"==typeof e)return i.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 o(e)}var i=e("./bufferish"),o=i.global;(r=t.exports=i.hasBuffer?n(0):[]).alloc=i.hasBuffer&&o.alloc||n,r.concat=i.concat,r.from=function(e){if(!i.isBuffer(e)&&i.isView(e))e=i.Uint8Array.from(e);else if(i.isArrayBuffer(e))e=new Uint8Array(e);else{if("string"==typeof e)return i.from.call(r,e);if("number"==typeof e)throw new TypeError('"value" argument must not be a number')}return o.from&&1!==o.from.length?o.from(e):new o(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 o.copy.call(this,e,t,r,n);var f=r||null!=n?i.call(this,r,n):this;return e.set(f,t),f.length}function i(e,t){var r=this.slice||!c&&this.subarray;if(r)return r.call(this,e,t);var i=s.alloc.call(this,t-e);return n.call(this,i,0,e,t),i}var o=e("./buffer-lite");r.copy=n,r.slice=i,r.toString=function(e,t,r){var n=!u&&s.isBuffer(this)?this.toString:o.toString;return n.apply(this,arguments)},r.write=function(e){return function(){var t=this[e]||o[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 i=e("./bufferish");(r=t.exports=i.hasArrayBuffer?n(0):[]).alloc=n,r.concat=i.concat,r.from=function(e){if(i.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 i.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 o(this).alloc(e)}function i(e){var t=3*e.length,r=n.call(this,t),i=_.write.call(r,e);return t!==i&&(r=_.slice.call(r,0,i)),r}function o(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||m(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 i=this!==r&&this||e[0],o=n.call(i,t),s=0;return Array.prototype.forEach.call(e,(function(e){s+=_.copy.call(e,o,s)})),o},r.from=function(e){return"string"==typeof e?i.call(this,e):o(this).from(e)};var p=r.Array=e("./bufferish-array"),g=r.Buffer=e("./bufferish-buffer"),y=r.Uint8Array=e("./bufferish-uint8array"),_=r.prototype=e("./bufferish-proto"),m=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 i(e,t){return e&&t?function(){return e.apply(this,arguments),t.apply(this,arguments)}:e||t}function o(e){return new n(e)}var s=e("isarray");r.createCodec=o,r.install=function(e){for(var t in e)n.prototype[t]=i(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=o({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 i=e("./read-core").preset;e("./flex-buffer").FlexDecoder.mixin(n.prototype),n.prototype.codec=i,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 o.call(this,e):new n(e)}r.Decoder=n;var i=e("event-lite"),o=e("./decode-buffer").DecodeBuffer;n.prototype=new o,i.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 i=e("./write-core").preset;e("./flex-buffer").FlexEncoder.mixin(n.prototype),n.prototype.codec=i,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 o.call(this,e):new n(e)}r.Encoder=n;var i=e("event-lite"),o=e("./encode-buffer").EncodeBuffer;n.prototype=new o,i.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 i(e){return e.valueOf()}function o(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,[o,n]),e.addExtPacker(11,Boolean,[i,n]),e.addExtPacker(12,String,[i,n]),e.addExtPacker(13,Date,[Number,n]),e.addExtPacker(15,Number,[i,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 i(e){return RegExp.apply(null,e)}function o(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,o(Error)]),e.addExtUnpacker(1,[n,o(EvalError)]),e.addExtUnpacker(2,[n,o(RangeError)]),e.addExtUnpacker(3,[n,o(ReferenceError)]),e.addExtUnpacker(4,[n,o(SyntaxError)]),e.addExtUnpacker(5,[n,o(TypeError)]),e.addExtUnpacker(6,[n,o(URIError)]),e.addExtUnpacker(10,[n,i]),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 i(){if(!(this instanceof i))return new i}function o(){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=i;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),i.mixin=f({bufferish:l,write:o,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,i=n+t;if(i<r)return this.offset=i,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}),i.mixin(i.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&&o.setExtUnpackers(this),this}var i=e("./ext-buffer").ExtBuffer,o=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 i(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={},i=new Array(t),o=new Array(t),s=e.codec.decode;for(r=0;r<t;r++)i[r]=s(e),o[r]=s(e);for(r=0;r<t;r++)n[i[r]]=o[r];return n}function i(e,t){var r,n=new Map,i=new Array(t),o=new Array(t),s=e.codec.decode;for(r=0;r<t;r++)i[r]=s(e),o[r]=s(e);for(r=0;r<t;r++)n.set(i[r],o[r]);return n}function o(e,t){for(var r=new Array(t),n=e.codec.decode,i=0;i<t;i++)r[i]=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,i=T.slice.call(e.buffer,r,n);return O.from(i)}function u(e,t){var r=e.reserve(t),n=r+t,i=T.slice.call(e.buffer,r,n);return O.Uint8Array.from(i).buffer}function c(e,t){var r=e.reserve(t+1),n=e.buffer[r++],i=r+t,o=e.codec.getExtUnpacker(n);if(!o)throw new Error("Invalid ext type: "+(n?"0x"+n.toString(16):n));return o(T.slice.call(e.buffer,r,i))}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 _(e){return new P(this,e).toNumber()}function m(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?i:n,array:o,str:s,bin:t?u:a,ext:c,uint8:f,uint16:h,uint32:p,uint64:y(8,r?v:_),int8:l,int16:d,int32:g,int64:y(8,r?b:m),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]=i(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]=i(null),r[193]=null,r[194]=i(!1),r[195]=i(!0),r[196]=o(e.uint8,e.bin),r[197]=o(e.uint16,e.bin),r[198]=o(e.uint32,e.bin),r[199]=o(e.uint8,e.ext),r[200]=o(e.uint16,e.ext),r[201]=o(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]=o(e.uint8,e.str),r[218]=o(e.uint16,e.str),r[219]=o(e.uint32,e.str),r[220]=o(e.uint16,e.array),r[221]=o(e.uint32,e.array),r[222]=o(e.uint16,e.map),r[223]=o(e.uint32,e.map),t=224;t<=255;t++)r[t]=i(t-256);return r}function i(e){return function(){return e}}function o(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&&o.setExtPackers(this),this}var i=e("./ext-buffer").ExtBuffer,o=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 i(t,e)}r=a.filter(r);var o=t.name;o&&"Object"!==o?(this.extPackers||(this.extPackers={}))[o]=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 i=this.extEncoderList||(this.extEncoderList=[]),o=i.length,s=0;s<o;s++){var a=i[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]=i(196),e[197]=o(197),e[198]=s(198),e[199]=i(199),e[200]=o(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]=i(204),e[205]=o(205),e[206]=s(206),e[207]=a(207,8,u),e[208]=i(208),e[209]=o(209),e[210]=s(210),e[211]=a(211,8,c),e[217]=i(217),e[218]=o(218),e[219]=s(219),e[220]=o(220),e[221]=s(221),e[222]=o(222),e[223]=s(223),e}function i(e){return function(t,r){var n=t.reserve(2),i=t.buffer;i[n++]=e,i[n]=r}}function o(e){return function(t,r){var n=t.reserve(3),i=t.buffer;i[n++]=e,i[n++]=r>>>8,i[n]=r}}function s(e){return function(t,r){var n=t.reserve(5),i=t.buffer;i[n++]=e,i[n++]=r>>>24,i[n++]=r>>>16,i[n++]=r>>>8,i[n]=r}}function a(e,t,r,n){return function(i,o){var s=i.reserve(t+1);i.buffer[s++]=e,r.call(i.buffer,o,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,_=e("./bufferish"),m=_.global,v=_.hasBuffer&&"TYPED_ARRAY_SUPPORT"in m&&!m.TYPED_ARRAY_SUPPORT,b=_.hasBuffer&&m.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||_.hasBuffer&&e&&e.safe?function(){var e=y.slice();return e[196]=a(196,1,m.prototype.writeUInt8),e[197]=a(197,2,m.prototype.writeUInt16BE),e[198]=a(198,4,m.prototype.writeUInt32BE),e[199]=a(199,1,m.prototype.writeUInt8),e[200]=a(200,2,m.prototype.writeUInt16BE),e[201]=a(201,4,m.prototype.writeUInt32BE),e[202]=a(202,4,m.prototype.writeFloatBE),e[203]=a(203,8,m.prototype.writeDoubleBE),e[204]=a(204,1,m.prototype.writeUInt8),e[205]=a(205,2,m.prototype.writeUInt16BE),e[206]=a(206,4,m.prototype.writeUInt32BE),e[207]=a(207,8,u),e[208]=a(208,1,m.prototype.writeInt8),e[209]=a(209,2,m.prototype.writeInt16BE),e[210]=a(210,4,m.prototype.writeInt32BE),e[211]=a(211,8,c),e[217]=a(217,1,m.prototype.writeUInt8),e[218]=a(218,2,m.prototype.writeUInt16BE),e[219]=a(219,4,m.prototype.writeUInt32BE),e[220]=a(220,2,m.prototype.writeUInt16BE),e[221]=a(221,4,m.prototype.writeUInt32BE),e[222]=a(222,2,m.prototype.writeUInt16BE),e[223]=a(223,4,m.prototype.writeUInt32BE),e}():n()}},{"./bufferish":8,"./write-uint8":28,ieee754:32,"int64-buffer":33}],27:[function(e,t,r){var n=e("isarray"),i=e("int64-buffer"),o=i.Uint64BE,s=i.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,i=0;i<r;i++)n(e,t[i])}(e,t);if(o.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 i=e.codec.getExtPacker(t);return i&&(t=i(t)),t instanceof l?function(e,t){var r=t.buffer,n=r.length,i=p[n]||(n<255?199:n<=65535?200:201);y[i](e,n),f[t.type](e),e.send(r)}(e,t):void w(e,t)}function r(e,t){y[192](e,t)}function i(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 i=e.codec.encode;r.forEach((function(r){i(e,r),i(e,t[r])}))}var y=c.getWriteToken(e),_=e&&e.useraw,m=h&&e&&e.binarraybuffer,v=m?a.isArrayBuffer:a.isBuffer,b=m?function(e,t){i(e,new Uint8Array(t))}:i,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,i){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:_?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,i=5+3*n;t.offset=t.reserve(i);var o=t.buffer,s=e(n),a=t.offset+s;n=u.write.call(o,r,a);var c=e(n);if(s!==c){var f=a+c-s,l=a+n;u.copy.call(o,o,f,a,l)}y[1===c?160+n:c<=3?215+c:219](t,n),t.offset+=n}}(_?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 i=r.uint8=new Array(256),o=0;o<=255;o++)i[o]=n(o)},{}],29:[function(e,r,n){(function(t){"use strict";function r(){return o.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function i(e,t){if(r()<t)throw new RangeError("Invalid typed array length");return o.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=o.prototype:(null===e&&(e=new o(t)),e.length=t),e}function o(e,t,r){if(!(o.TYPED_ARRAY_SUPPORT||this instanceof o))return new o(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),o.TYPED_ARRAY_SUPPORT?(e=t).__proto__=o.prototype:e=c(e,t),e}(e,t,r,n):"string"==typeof t?function(e,t,r){if("string"==typeof r&&""!==r||(r="utf8"),!o.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|l(t,r),s=(e=i(e,n)).write(t,r);return s!==n&&(e=e.slice(0,s)),e}(e,t,r):function(e,t){if(o.isBuffer(t)){var r=0|f(t.length);return 0===(e=i(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)?i(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=i(e,t<0?0:0|f(t)),!o.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=i(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(o.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,i){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=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=o.from(t,n)),o.isBuffer(t))return 0===t.length?-1:g(e,t,r,n,i);if("number"==typeof t)return t&=255,o.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):g(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function g(e,t,r,n,i){function o(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(i){var f=-1;for(s=r;s<u;s++)if(o(e,s)===o(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(o(e,s+h)!==o(t,h)){l=!1;break}if(l)return s}return-1}function y(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/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 _(e,t,r,n){return F(x(t,e.length-r),e,r,n)}function m(e,t,r,n){return F(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 m(e,t,r,n)}function b(e,t,r,n){return F(D(t),e,r,n)}function w(e,t,r,n){return F(function(e,t){for(var r,n,i,o=[],s=0;s<e.length&&!((t-=2)<0);++s)r=e.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function E(e,t,r){return 0===t&&r===e.length?L.fromByteArray(e):L.fromByteArray(e.slice(t,r))}function k(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i<r;){var o,s,a,u,c=e[i],f=null,l=c>239?4:c>223?3:c>191?2:1;if(i+l<=r)switch(l){case 1:c<128&&(f=c);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&c)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&c)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&o)<<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),i+=l}return function(e){var t=e.length;if(t<=Y)return String.fromCharCode.apply(String,e);for(var r="",n=0;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=Y));return r}(n)}function R(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}function P(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]);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 i="",o=t;o<r;++o)i+=B(e[o]);return i}function O(e,t,r){for(var n=e.slice(t,r),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}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,i,s){if(!o.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||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 i=0,o=Math.min(e.length-r,2);i<o;++i)e[r+i]=(t&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function M(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i<o;++i)e[r+i]=t>>>8*(n?i:3-i)&255}function I(e,t,r,n,i,o){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,i){return i||I(e,0,r,4),j.write(e,t,r,n,23,4),r+4}function N(e,t,r,n,i){return i||I(e,0,r,8),j.write(e,t,r,n,52,8),r+8}function B(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,i=null,o=[],s=0;s<n;++s){if((r=e.charCodeAt(s))>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.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;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function D(e){return L.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(V,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function F(e,t,r,n){for(var i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}var L=e("base64-js"),j=e("ieee754"),q=e("isarray");n.Buffer=o,n.SlowBuffer=function(e){return+e!=e&&(e=0),o.alloc(+e)},n.INSPECT_MAX_BYTES=50,o.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(),o.poolSize=8192,o._augment=function(e){return e.__proto__=o.prototype,e},o.from=function(e,t,r){return s(null,e,t,r)},o.TYPED_ARRAY_SUPPORT&&(o.prototype.__proto__=Uint8Array.prototype,o.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&o[Symbol.species]===o&&Object.defineProperty(o,Symbol.species,{value:null,configurable:!0})),o.alloc=function(e,t,r){return function(e,t,r,n){return a(t),t<=0?i(e,t):void 0!==r?"string"==typeof n?i(e,t).fill(r,n):i(e,t).fill(r):i(e,t)}(null,e,t,r)},o.allocUnsafe=function(e){return u(null,e)},o.allocUnsafeSlow=function(e){return u(null,e)},o.isBuffer=function(e){return!(null==e||!e._isBuffer)},o.compare=function(e,t){if(!o.isBuffer(e)||!o.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,i=0,s=Math.min(r,n);i<s;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0},o.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}},o.concat=function(e,t){if(!q(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return o.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=o.allocUnsafe(t),i=0;for(r=0;r<e.length;++r){var s=e[r];if(!o.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(n,i),i+=s.length}return n},o.byteLength=l,o.prototype._isBuffer=!0,o.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},o.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},o.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},o.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?k(this,0,e):h.apply(this,arguments)},o.prototype.equals=function(e){if(!o.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===o.compare(this,e)},o.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+">"},o.prototype.compare=function(e,t,r,n,i){if(!o.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===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var s=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(t>>>=0),u=Math.min(s,a),c=this.slice(n,i),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},o.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},o.prototype.indexOf=function(e,t,r){return p(this,e,t,r,!0)},o.prototype.lastIndexOf=function(e,t,r){return p(this,e,t,r,!1)},o.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 i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return y(this,e,t,r);case"utf8":case"utf-8":return _(this,e,t,r);case"ascii":return m(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(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Y=4096;o.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),o.TYPED_ARRAY_SUPPORT)(r=this.subarray(e,t)).__proto__=o.prototype;else{var i=t-e;r=new o(i,void 0);for(var s=0;s<i;++s)r[s]=this[s+e]}return r},o.prototype.readUIntLE=function(e,t,r){e|=0,t|=0,r||T(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n},o.prototype.readUIntBE=function(e,t,r){e|=0,t|=0,r||T(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},o.prototype.readUInt8=function(e,t){return t||T(e,1,this.length),this[e]},o.prototype.readUInt16LE=function(e,t){return t||T(e,2,this.length),this[e]|this[e+1]<<8},o.prototype.readUInt16BE=function(e,t){return t||T(e,2,this.length),this[e]<<8|this[e+1]},o.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]},o.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])},o.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||T(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*t)),n},o.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||T(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},o.prototype.readInt8=function(e,t){return t||T(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},o.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},o.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},o.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},o.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]},o.prototype.readFloatLE=function(e,t){return t||T(e,4,this.length),j.read(this,e,!0,23,4)},o.prototype.readFloatBE=function(e,t){return t||T(e,4,this.length),j.read(this,e,!1,23,4)},o.prototype.readDoubleLE=function(e,t){return t||T(e,8,this.length),j.read(this,e,!0,52,8)},o.prototype.readDoubleBE=function(e,t){return t||T(e,8,this.length),j.read(this,e,!1,52,8)},o.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 i=1,o=0;for(this[t]=255&e;++o<r&&(i*=256);)this[t+o]=e/i&255;return t+r},o.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 i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},o.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||A(this,e,t,1,255,0),o.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},o.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||A(this,e,t,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):S(this,e,t,!0),t+2},o.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||A(this,e,t,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):S(this,e,t,!1),t+2},o.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||A(this,e,t,4,4294967295,0),o.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},o.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||A(this,e,t,4,4294967295,0),o.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},o.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);A(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o<r&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},o.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);A(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},o.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||A(this,e,t,1,127,-128),o.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},o.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||A(this,e,t,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):S(this,e,t,!0),t+2},o.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||A(this,e,t,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):S(this,e,t,!1),t+2},o.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||A(this,e,t,4,2147483647,-2147483648),o.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},o.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),o.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},o.prototype.writeFloatLE=function(e,t,r){return U(this,e,t,!0,r)},o.prototype.writeFloatBE=function(e,t,r){return U(this,e,t,!1,r)},o.prototype.writeDoubleLE=function(e,t,r){return N(this,e,t,!0,r)},o.prototype.writeDoubleBE=function(e,t,r){return N(this,e,t,!1,r)},o.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 i,s=n-r;if(this===e&&r<t&&t<n)for(i=s-1;i>=0;--i)e[i+t]=this[i+r];else if(s<1e3||!o.TYPED_ARRAY_SUPPORT)for(i=0;i<s;++i)e[i+t]=this[i+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+s),t);return s},o.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 i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!o.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=o.isBuffer(e)?e:x(new o(e,n).toString()),u=a.length;for(s=0;s<r-t;++s)this[s+t]=a[s%u]}return this};var V=/[^+\/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 i(e){return s[e>>18&63]+s[e>>12&63]+s[e>>6&63]+s[63&e]}function o(e,t,r){for(var n,o=[],s=t;s<r;s+=3)n=(e[s]<<16)+(e[s+1]<<8)+e[s+2],o.push(i(n));return o.join("")}r.byteLength=function(e){return 3*e.length/4-n(e)},r.toByteArray=function(e){var t,r,i,o,s,c,f=e.length;s=n(e),c=new u(3*f/4-s),i=s>0?f-4:f;var l=0;for(t=0,r=0;t<i;t+=4,r+=3)o=a[e.charCodeAt(t)]<<18|a[e.charCodeAt(t+1)]<<12|a[e.charCodeAt(t+2)]<<6|a[e.charCodeAt(t+3)],c[l++]=o>>16&255,c[l++]=o>>8&255,c[l++]=255&o;return 2===s?(o=a[e.charCodeAt(t)]<<2|a[e.charCodeAt(t+1)]>>4,c[l++]=255&o):1===s&&(o=a[e.charCodeAt(t)]<<10|a[e.charCodeAt(t+1)]<<4|a[e.charCodeAt(t+2)]>>2,c[l++]=o>>8&255,c[l++]=255&o),c},r.fromByteArray=function(e){for(var t,r=e.length,n=r%3,i="",a=[],u=16383,c=0,f=r-n;c<f;c+=u)a.push(o(e,c,c+u>f?f:c+u));return 1===n?(t=e[r-1],i+=s[t>>2],i+=s[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=s[t>>10],i+=s[t>>4&63],i+=s[t<<2&63],i+="="),a.push(i),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=i(a,e,!0)){if(!(s=s.filter(r)).length)return n.call(a,e);a[o][e]=s}}else if((s=a[o])&&(delete s[e],!Object.keys(s).length))return n.call(a)}else delete a[o];return a}function i(e,t,r){if(!r||e[o]){var n=e[o]||(e[o]={});return n[t]||(n[t]=[])}}void 0!==t&&(t.exports=e);var o="listeners",s={on:function(e,t){return i(this,e).push(t),this},once:function(e,t){function r(){n.call(o,e,r),t.apply(this,arguments)}var o=this;return r.originalListener=t,i(o,e).push(r),o},off:n,emit:function(e,t){function r(e){e.call(s)}function n(e){e.call(s,t)}function o(e){e.apply(s,c)}var s=this,a=i(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(o)}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,i){var o,s,a=8*i-n-1,u=(1<<a)-1,c=u>>1,f=-7,l=r?i-1:0,h=r?-1:1,d=e[t+l];for(l+=h,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=h,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=h,f-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=c}return(d?-1:1)*s*Math.pow(2,o-n)},r.write=function(e,t,r,n,i,o){var s,a,u,c=8*o-i-1,f=(1<<c)-1,l=f>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-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,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<<i|a,c+=i;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,i){y&&_&&(t instanceof _&&(t=new y(t)),n instanceof _&&(n=new y(n))),t||r||n||d?(s(t,r)||(i=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 i=0,o=r.length,s=0,a=0;"-"===r[0]&&i++;for(var u=i;i<o;){var c=parseInt(r[i++],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,i||10):s(n,i)?a(t,r,n,i):"number"==typeof i?(R(t,r+C,n),R(t,r+O,i)):n>0?I(t,r,n):n<0?U(t,r,n):a(t,r,m,0))):e.buffer=u(m,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,N=E.prototype,B="is"+e,x="_"+B;return N.buffer=void 0,N.offset=0,N[x]=!0,N.toNumber=k,N.toString=function(e){var t=this.buffer,r=this.offset,n=P(t,r+C),i=P(t,r+O),o="",s=!v&&2147483648&n;for(s&&(n=~n,i=b-i),e=e||10;;){var a=n%e*b+i;if(n=Math.floor(n/e),i=Math.floor(a/e),o=(a%e).toString(e)+o,!n&&!i)break}return s&&(o="-"+o),o},N.toJSON=k,N.toArray=n,g&&(N.toBuffer=i),y&&(N.toArrayBuffer=o),E[B]=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 i(t){var r=this.buffer,n=this.offset;if(d=g,!1!==t&&0===n&&8===r.length&&e.isBuffer(r))return r;var i=new g(8);return a(i,0,r,n),i}function o(e){var t=this.buffer,r=this.offset,n=t.buffer;if(d=y,!1!==e&&0===r&&n instanceof _&&8===n.byteLength)return n;var i=new y(8);return a(i,0,t,r),i.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 i=0;i<8;i++)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,_=p!==typeof ArrayBuffer&&ArrayBuffer,m=[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
19
|
/**
|
|
20
20
|
* [js-md5]{@link https://github.com/emn178/js-md5}
|
|
21
21
|
*
|
|
@@ -24,4 +24,4 @@ t.read=function(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<<a)-1,f=u>>1,c=-7,l=r?i-1:0,h=
|
|
|
24
24
|
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
|
25
25
|
* @copyright Chen, Yi-Cyuan 2014-2017
|
|
26
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__(18),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 i,o,s=0,u=e.length,f=this.blocks,c=this.buffer8;s<u;){if(this.hashed&&(this.hashed=!1,f[0]=f[16],f[16]=f[1]=f[2]=f[3]=f[4]=f[5]=f[6]=f[7]=f[8]=f[9]=f[10]=f[11]=f[12]=f[13]=f[14]=f[15]=0),t)if(a)for(o=this.start;s<u&&o<64;++s)c[o++]=e[s];else for(o=this.start;s<u&&o<64;++s)f[o>>2]|=e[s]<<y[3&o++];else if(a)for(o=this.start;s<u&&o<64;++s)(i=e.charCodeAt(s))<128?c[o++]=i:i<2048?(c[o++]=192|i>>6,c[o++]=128|63&i):i<55296||i>=57344?(c[o++]=224|i>>12,c[o++]=128|i>>6&63,c[o++]=128|63&i):(i=65536+((1023&i)<<10|1023&e.charCodeAt(++s)),c[o++]=240|i>>18,c[o++]=128|i>>12&63,c[o++]=128|i>>6&63,c[o++]=128|63&i);else for(o=this.start;s<u&&o<64;++s)(i=e.charCodeAt(s))<128?f[o>>2]|=i<<y[3&o++]:i<2048?(f[o>>2]|=(192|i>>6)<<y[3&o++],f[o>>2]|=(128|63&i)<<y[3&o++]):i<55296||i>=57344?(f[o>>2]|=(224|i>>12)<<y[3&o++],f[o>>2]|=(128|i>>6&63)<<y[3&o++],f[o>>2]|=(128|63&i)<<y[3&o++]):(i=65536+((1023&i)<<10|1023&e.charCodeAt(++s)),f[o>>2]|=(240|i>>18)<<y[3&o++],f[o>>2]|=(128|i>>12&63)<<y[3&o++],f[o>>2]|=(128|i>>6&63)<<y[3&o++],f[o>>2]|=(128|63&i)<<y[3&o++]);this.lastByteIndex=o,this.bytes+=o-this.start,o>=64?(this.start=o-64,this.hash(),this.hashed=!0):this.start=o}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,i,o,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+=((o=(n=((n+=((i=t^r)^(e=((e+=(i^n)+s[5]-378558)<<4|e>>>28)+t<<0))+s[8]-2022574463)<<11|n>>>21)+e<<0)^e)^(r=((r+=(o^t)+s[11]+1839030562)<<16|r>>>16)+n<<0))+s[14]-35309556)<<23|t>>>9)+r<<0,t=((t+=((o=(n=((n+=((i=t^r)^(e=((e+=(i^n)+s[1]-1530992060)<<4|e>>>28)+t<<0))+s[4]+1272893353)<<11|n>>>21)+e<<0)^e)^(r=((r+=(o^t)+s[7]-155497632)<<16|r>>>16)+n<<0))+s[10]-1094730640)<<23|t>>>9)+r<<0,t=((t+=((o=(n=((n+=((i=t^r)^(e=((e+=(i^n)+s[13]+681279174)<<4|e>>>28)+t<<0))+s[0]-358537222)<<11|n>>>21)+e<<0)^e)^(r=((r+=(o^t)+s[3]-722521979)<<16|r>>>16)+n<<0))+s[6]+76029189)<<23|t>>>9)+r<<0,t=((t+=((o=(n=((n+=((i=t^r)^(e=((e+=(i^n)+s[9]-640364487)<<4|e>>>28)+t<<0))+s[12]-421815835)<<11|n>>>21)+e<<0)^e)^(r=((r+=(o^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,i=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[i>>4&15]+n[15&i]+n[i>>12&15]+n[i>>8&15]+n[i>>20&15]+n[i>>16&15]+n[i>>28&15]+n[i>>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="",i=this.array(),o=0;o<15;)e=i[o++],t=i[o++],r=i[o++],n+=p[e>>>2]+p[63&(e<<4|t>>>4)]+p[63&(t<<2|r>>>6)]+p[63&r];return e=i[o],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__(17),__webpack_require__(3))},function(e,t){var r,n,i=e.exports={};function o(){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===o||!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:o}catch(e){r=o}try{n="function"==typeof clearTimeout?clearTimeout:s}catch(e){n=s}}();var u,f=[],c=!1,l=-1;function h(){c&&u&&(c=!1,u.length?f=u.concat(f):l=-1,f.length&&d())}function d(){if(!c){var e=a(h);c=!0;for(var t=f.length;t;){for(u=f,f=[];++l<t;)u&&u[l].run();l=-1,t=f.length}u=null,c=!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(){}i.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];f.push(new p(e,t)),1!==f.length||c||a(d)},p.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=g,i.addListener=g,i.once=g,i.off=g,i.removeListener=g,i.removeAllListeners=g,i.emit=g,i.prependListener=g,i.prependOnceListener=g,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.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 m(e,t,r,n){return this instanceof m?function(e,t,r,n,i){if(h&&d&&(t instanceof d&&(t=new h(t)),n instanceof d&&(n=new h(n))),t||r||n||f){if(!s(t,r))i=r,n=t,r=0,t=new(f||Array)(8);e.buffer=t,e.offset=r|=0,c!==typeof n&&("string"==typeof n?function(e,t,r,n){var i=0,o=r.length,s=0,a=0;"-"===r[0]&&i++;for(var u=i;i<o;){var f=parseInt(r[i++],n);if(!(f>=0))break;a=a*n+f,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,i||10):s(n,i)?a(t,r,n,i):"number"==typeof i?(b(t,r+E,n),b(t,r+k,i)):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 m(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]*_+(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=m.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),i=w(t,r+k),o="",s=!g&&2147483648&n;for(s&&(n=~n,i=y-i),e=e||10;;){var a=n%e*y+i;if(n=Math.floor(n/e),i=Math.floor(a/e),o=(a%e).toString(e)+o,!n&&!i)break}return s&&(o="-"+o),o},S.toJSON=v,S.toArray=n,l&&(S.toBuffer=i),h&&(S.toArrayBuffer=o),m[M]=function(e){return!(!e||!e[I])},t[e]=m,m}function n(e){var t=this.buffer,r=this.offset;return f=null,!1!==e&&0===r&&8===t.length&&g(t)?t:u(t,r)}function i(t){var r=this.buffer,n=this.offset;if(f=l,!1!==t&&0===n&&8===r.length&&e.isBuffer(r))return r;var i=new l(8);return a(i,0,r,n),i}function o(e){var t=this.buffer,r=this.offset,n=t.buffer;if(f=h,!1!==e&&0===r&&n instanceof d&&8===n.byteLength)return n;var i=new h(8);return a(i,0,t,r),i.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 i=0;i<8;i++)e[t++]=255&r[n++]}function u(e,t){return Array.prototype.slice.call(e,t,t+8)}var f,c="undefined",l=c!==typeof e&&e,h=c!==typeof Uint8Array&&Uint8Array,d=c!==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,_=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(5).Buffer)},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 i=r(4),o=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 i=n||{};return{defaults:i.defaults||{},pass:i.pass||[],request:t||{},required:i.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},f={end_ms:0,start_ms:0},c={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"},c),d,{defaults:a,required:["peer","reverse","limit","start_ms","end_ms","cursor"]}),getgroupmsg:s("history.group",Object.assign({gid:"group_ref"},c),d,{defaults:a,required:["group_ref","reverse","limit","start_ms","end_ms","cursor"]}),getroommsg:s("history.room",Object.assign({rid:"room_ref"},c),d,{defaults:a,required:["room_ref","reverse","limit","start_ms","end_ms","cursor"]}),getbroadcastmsg:s("history.broadcast",c,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:f,required:["peer","start_ms","end_ms"]}),getgroupmsgcount:s("history.group_count",Object.assign({gid:"group_ref"},h),{count:"total"},{defaults:f,required:["group_ref","start_ms","end_ms"]}),getroommsgcount:s("history.room_count",Object.assign({rid:"room_ref"},h),{count:"total"},{defaults:f,required:["room_ref","start_ms","end_ms"]}),getbroadcastmsgcount:s("history.broadcast_count",h,{count:"total"},{defaults:f,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},_={"event.kicked":!0,"event.room_removed":!0},m="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:m},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),F=P(!1),D=v("string_or_bin",!1),L=v("tuple8",!1);function j(e,t){return O(e,x,t)}function q(e,t){return O(e,M,t)}function Y(e,t){return O(e,I,t)}function V(e){return T(e,"string",F)}function H(e){return T(e,"positive_decimal_int64",F)}function W(e){return T(e,"positive_decimal_int64",U)}function G(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)},X={anchor:E(!0),end_ms:k(!0),kinds:q(!1),limit:R(!0),reverse:C(!0),start_ms:k(!0)},Z={end_ms:k(!0),kinds:q(!1),start_ms:k(!0)},$={"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:V(!1),user:E(!0)}),"connection.close":A(),"system.time":A(),"connection.set_props":A({props:V(!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)},X)),"history.group_anchor":A(Object.assign({group_ref:E(!0)},X)),"history.room_anchor":A(Object.assign({room_ref:E(!0)},X)),"history.broadcast_anchor":A(X),"history.direct_count":A(Object.assign({peer:E(!0)},Z)),"history.group_count":A(Object.assign({group_ref:E(!0)},Z)),"history.room_count":A(Object.assign({room_ref:E(!0)},Z)),"history.broadcast_count":A(Z),"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,L),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:V(!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:H(!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:H(!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:W(!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:H(!0)}),"room.last_messages":S({last_by_room:function(e){return T(e,"positive_decimal_int64",L)}(!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,F,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:W(!0),times:G(!0)}),"unread.group":S({counts:W(!0),times:G(!0)}),"session.remove":S(),"conversation.direct":S({badges:Y(!0),last_items:O(!0,L),peers:j(!0)}),"conversation.direct_unread":S({badges:Y(!0),last_items:O(!0,L),peers:j(!0)}),"conversation.group":S({badges:Y(!0),group_refs:j(!0),last_items:O(!0,L)}),"conversation.group_unread":S({badges:Y(!0),group_refs:j(!0),last_items:O(!0,L)}),"conversation.unread":S({group_badges:Y(!0),group_last:O(!0,L),group_refs:j(!0),peer_badges:Y(!0),peer_last:O(!0,L),peers:j(!0)}),"control.ping":S({ts:b(!1)})},ie={from_locale:P(!0),original:P(!0),to_locale:P(!0),translated:P(!0)},oe={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)},oe),"event.group":Object.assign({group_ref:E(!0)},oe),"event.room":Object.assign({room_ref:E(!0)},oe),"event.broadcast":oe,"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 fe(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 i.Int64Value||e&&"object"===(void 0===e?"undefined":n(e))&&"number"==typeof e.offset&&e.buffer&&"function"==typeof e.toString?ue(e.toString()):null}function ce(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 i="-"===r.charAt(0),o="-"===n.charAt(0);if(i!==o)return i?-1:1;var s=i?r.slice(1):r,a=o?n.slice(1):n,u=void 0;return u=s.length!==a.length?s.length<a.length?-1:1:s<a?-1:1,i?-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 i=e.charCodeAt(r+1);if(i<56320||i>57343)throw new o(200034,"string contains an unpaired surrogate");t+=4,r+=1}else{if(n>=56320&&n<=57343)throw new o(200034,"string contains an unpaired surrogate");t+=n<=127?1:n<=2047?2:3}}return t}function he(e,t){throw new o(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=i.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 i.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||ce(n,m)>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||i.getByteView(e))return;pe("Chat payload",e,ie)}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],D,t+"[5]"),de(e[6],F,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 o={};e.forEach((function(e){o[fe(e)]=!0})),Object.keys(o).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=fe(e);(null===n||ce(n,"-9223372036854775808")<0||ce(n,m)>0)&&he(r,"must be a signed int64 integer"),void 0!==t.min&&ce(n,t.min)<0&&he(r,"is below the allowed range"),void 0!==t.max&&ce(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&&!(ce(n,"1")>=0&&ce(n,"39")<=0||ce(n,"51")>=0&&ce(n,"127")<=0)&&he(r,"must be in kind ranges [1,39] or [51,127]")}(e,t,r)}function pe(e,t,r){i.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 i=r[n];Object.prototype.hasOwnProperty.call(t,n)?de(t[n],i,e+"."+n):i.required&&he(e+"."+n,"is required")}))}function ge(e,t,r){for(var n=t[r[0]].length,i=1;i<r.length;i+=1)t[r[i]].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:$,RESPONSE_SCHEMAS:ne,RESERVED_WIRES:g,ROUTES:p,TLVContractError:o,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(_,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 o(200020,e+" is reserved and unavailable on the TLV Client port");throw new o(20004,"unknown or unsupported TLV Client wire: "+e)}if(!i.isPlainMap(t))throw new o(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 o(200034,s.uri+" does not accept field "+e);r=e}if(Object.prototype.hasOwnProperty.call(a,r))throw new o(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=$[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(!i.isPlainMap(n))throw new o(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 o(200034,r+" has conflicting "+t+" values");e[t]=n[t]}}))}(a,r,s.uri),function(e,t){var r=$[e.uri];if(!r)throw new o(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"),i=Object.prototype.hasOwnProperty.call(t,"auth_ver");if(n!==i)throw new o(200034,"auth.login requires auth_sec and auth_ver together");if(i&&"2"!==fe(t.auth_ver))throw new o(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 o(200034,"unsupported Push URI: "+e);pe(e+" Push",t,r)},validateResponse:function(e,t){var r=ne[e];if(!r)throw new o(200034,"unsupported Answer URI: "+e);r.allowEmpty&&i.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="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},i=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,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(9),f=r(1),c=f.Int64BE,l=f.Uint64BE,h="__rtmSharedWorkerType__",d=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}(),p={sendFile:!0,sendGroupFile:!0,sendRoomFile:!0},g=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 i=function(e){if(null!=e&&""!==e){if("string"!=typeof e)throw new Error("RTMSharedWorkerClient workerUrl must be a string");return e}if(!d)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",d)}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),o=Object.assign({},n.clientOptions||{});if(void 0!==o.protocol&&"tlv-v1"!==o.protocol)throw new Error('RTMSharedWorkerClient only supports protocol: "tlv-v1"');if(o.protocol="tlv-v1","function"==typeof o.requestMetadata||"function"==typeof o.requestMetadataProvider||"function"==typeof o.webSocketFactory)throw new Error("SharedWorker client options must be structured-cloneable; requestMetadata and webSocketFactory functions are not supported");var a,f=b(n.conversation),c=n.workerName||(void 0!==n.uid&&null!==n.uid?y({pid:o.pid,uid:n.uid,endpoint:o.tlvEndpoint||o.endpoint,namespace:n.workerNamespace}):"rtm-shared-worker"),l=void 0===n.idleShutdownTimeout?5e3:n.idleShutdownTimeout;if(!("number"==typeof(a=l)&&isFinite(a)&&a>=0))throw new Error("RTMSharedWorkerClient idleShutdownTimeout must be a non-negative number");if(this._listeners={},this._processorListeners={},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(i,c),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:o,conversation:f,idleShutdownTimeout:l})){var h=function(e){return"number"==typeof e&&isFinite(e)&&e>0}(n.readyTimeout)?n.readyTimeout:1e4;this._readyTimer=setTimeout((function(){var e=k("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}),h)}else this._settleReady(new Error("Failed to initialize the RTM SharedWorker client")),this.destroy();var p=this;this.processor={on:function(e,t){return p._addListener(p._processorListeners,e,t),this},off:function(e,t){return p._removeListener(p._processorListeners,e,t),this},removeEvent:function(e,t){return 0===arguments.length?p._processorListeners={}:p._removeListener(p._processorListeners,e,t),this}}}return i(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:"removeEvent",value:function(e,t){return 0===arguments.length?this._listeners={}:this._removeListener(this._listeners,e,t),this}},{key:"whenReady",value:function(){return this._readyPromise.then(m)}},{key:"getSharedSession",value:function(){return m(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(i,o){var s=++n._callbackSeq,a=function(e){e instanceof Error?o(e):i(e)};a.rejectOnDestroy=!0,n._callbacks.set(s,a);var u=w(e,n._callbacks,n);n._post({type:"login-if-needed",uid:u,credential:t,timeout:r,requestId:s})||(n._callbacks.delete(s),o(new Error("Failed to request shared RTM login")))}))}))}},{key:"setConversation",value:function(e,t){var r=b(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}this._conversation=r;var i=void 0;if("function"==typeof t){i=++this._callbackSeq;var o=function(e){t(e)};o.fail=t,this._callbacks.set(i,o)}return this._post({type:"setConversation",conversation:r,requestId:i})||void 0===i||(this._callbacks.delete(i),t(new Error("Failed to send conversation route to SharedWorker"))),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={},this._processorListeners={},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("conversation-set"!==t.type)if("event"!==t.type)if("login-result"!==t.type)if("error"!==t.type){if("ready"===t.type){var r=_(t.session);return this._session=r,this._settleReady(null,r),void this._emit(this._listeners,"SharedWorkerReady",[r])}"session-state"===t.type&&(this._session=_(t.session),this._emit(this._listeners,"SharedSessionState",[m(this._session)]))}else{var n=R(t.error,a),i=null;if(void 0!==t.requestId){var o=this._callbacks.get(t.requestId);o&&(this._callbacks.delete(t.requestId),o(n))}else this._failedError=n,i=this._failPendingCallbacks(n);try{this._settleReady(n),this._emit(this._listeners,"SharedWorkerError",[n])}finally{!0===t.fatal&&this.destroy()}if(i)throw i.error}else{var s=this._callbacks.get(t.requestId);s&&(this._callbacks.delete(t.requestId),s(t.error?R(t.error,a):t.result))}else{var u=R(t.args,a);this._emit("processor"===t.channel?this._processorListeners:this._listeners,t.name,u)}else{var f=this._callbacks.get(t.requestId);f&&(this._callbacks.delete(t.requestId),f(null))}else{var c=this._callbacks.get(t.callbackId);c&&(this._callbacks.delete(t.callbackId),c.apply(null,R(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,i){if("function"==typeof n.fail||n.rejectOnDestroy){t._callbacks.delete(i);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=k("RTMSharedWorkerClient has been destroyed","RTM_SHARED_CLIENT_DESTROYED");return E(e,t,r),void this._emit(this._listeners,"SharedWorkerError",[r])}if(this._failedError)E(e,t,this._failedError);else{var n=this._callbackSeq;this._post({type:"invoke",method:e,args:w(t,this._callbacks,this,e)})||this._failCallbacksSince(n,this._failedError||k("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,i){i<=e||(r._callbacks.delete(i),"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(m(t)))}}]),e}();function y(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");return"rtm-shared:"+[String(void 0===e.namespace||null===e.namespace?"":e.namespace),t,r,String(void 0===e.endpoint||null===e.endpoint?"":e.endpoint)].map((function(e){var t=encodeURIComponent(e);return t.length+":"+t})).join("|")}function _(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 m(e){return{status:e.status,uid:e.uid}}function v(e,t){if("function"==typeof t){var r=new Error("File sending is not supported by RTMSharedWorkerClient");r.code=a.ERROR_CODE.RTM_EC_UNKNOWN_ERROR,t({mid:e,error:r},null)}}function b(e){if(null==e)return null;if(!P(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&&(c.isInt64BE(t)||l.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 w(e,t,r,i){if("function"==typeof e){var s=++r._callbackSeq,u=function(){return e.apply(null,arguments)};return u.fail=function(t){"login"===i?e(!1,t.status||a.ERROR_CODE.RTM_EC_UNKNOWN_ERROR):e(t,null)},t.set(s,u),o({},"__rtmSharedWorkerCallback__",s)}if(e&&"object"===(void 0===e?"undefined":n(e))){var f,d;if(c.isInt64BE(e))return o(f={},h,"int64"),o(f,"value",e.toString()),f;if(l.isUint64BE(e))return o(d={},h,"uint64"),o(d,"value",e.toString()),d;if(Array.isArray(e))return e.map((function(e){return w(e,t,r,i)}));if(P(e)){var p={};return Object.keys(e).forEach((function(n){p[n]=w(e[n],t,r,i)})),p}}return e}function E(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 k(e,t){var r=new Error(e);return r.code=t,r}function R(e,t){if(Array.isArray(e))return e.map((function(e){return R(e,t)}));if(!P(e))return e;if("int64"===e[h])return t.Int64(e.value);if("uint64"===e[h])return t.Uint64(e.value);if("error"===e[h]){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]=R(e[r],t)})),n}function P(e){if(null===e||"object"!==(void 0===e?"undefined":n(e)))return!1;var t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}g.createWorkerName=y,Object.getOwnPropertyNames(s.prototype).forEach((function(e){"constructor"===e||"destroy"===e||"_"===e.charAt(0)||p[e]||Object.defineProperty(g.prototype,e,{configurable:!0,enumerable:!1,writable:!0,value:function(){return this._invoke(e,Array.prototype.slice.call(arguments))}})})),g.prototype.sendFile=function(e,t,r,n,i,o){v(n,o)},g.prototype.sendGroupFile=function(e,t,r,n,i,o){v(n,o)},g.prototype.sendRoomFile=function(e,t,r,n,i,o){v(n,o)},e.exports=g}])}));
|
|
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__(21),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 i,o,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(o=this.start;s<u&&o<64;++s)f[o++]=e[s];else for(o=this.start;s<u&&o<64;++s)c[o>>2]|=e[s]<<y[3&o++];else if(a)for(o=this.start;s<u&&o<64;++s)(i=e.charCodeAt(s))<128?f[o++]=i:i<2048?(f[o++]=192|i>>6,f[o++]=128|63&i):i<55296||i>=57344?(f[o++]=224|i>>12,f[o++]=128|i>>6&63,f[o++]=128|63&i):(i=65536+((1023&i)<<10|1023&e.charCodeAt(++s)),f[o++]=240|i>>18,f[o++]=128|i>>12&63,f[o++]=128|i>>6&63,f[o++]=128|63&i);else for(o=this.start;s<u&&o<64;++s)(i=e.charCodeAt(s))<128?c[o>>2]|=i<<y[3&o++]:i<2048?(c[o>>2]|=(192|i>>6)<<y[3&o++],c[o>>2]|=(128|63&i)<<y[3&o++]):i<55296||i>=57344?(c[o>>2]|=(224|i>>12)<<y[3&o++],c[o>>2]|=(128|i>>6&63)<<y[3&o++],c[o>>2]|=(128|63&i)<<y[3&o++]):(i=65536+((1023&i)<<10|1023&e.charCodeAt(++s)),c[o>>2]|=(240|i>>18)<<y[3&o++],c[o>>2]|=(128|i>>12&63)<<y[3&o++],c[o>>2]|=(128|i>>6&63)<<y[3&o++],c[o>>2]|=(128|63&i)<<y[3&o++]);this.lastByteIndex=o,this.bytes+=o-this.start,o>=64?(this.start=o-64,this.hash(),this.hashed=!0):this.start=o}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,i,o,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+=((o=(n=((n+=((i=t^r)^(e=((e+=(i^n)+s[5]-378558)<<4|e>>>28)+t<<0))+s[8]-2022574463)<<11|n>>>21)+e<<0)^e)^(r=((r+=(o^t)+s[11]+1839030562)<<16|r>>>16)+n<<0))+s[14]-35309556)<<23|t>>>9)+r<<0,t=((t+=((o=(n=((n+=((i=t^r)^(e=((e+=(i^n)+s[1]-1530992060)<<4|e>>>28)+t<<0))+s[4]+1272893353)<<11|n>>>21)+e<<0)^e)^(r=((r+=(o^t)+s[7]-155497632)<<16|r>>>16)+n<<0))+s[10]-1094730640)<<23|t>>>9)+r<<0,t=((t+=((o=(n=((n+=((i=t^r)^(e=((e+=(i^n)+s[13]+681279174)<<4|e>>>28)+t<<0))+s[0]-358537222)<<11|n>>>21)+e<<0)^e)^(r=((r+=(o^t)+s[3]-722521979)<<16|r>>>16)+n<<0))+s[6]+76029189)<<23|t>>>9)+r<<0,t=((t+=((o=(n=((n+=((i=t^r)^(e=((e+=(i^n)+s[9]-640364487)<<4|e>>>28)+t<<0))+s[12]-421815835)<<11|n>>>21)+e<<0)^e)^(r=((r+=(o^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,i=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[i>>4&15]+n[15&i]+n[i>>12&15]+n[i>>8&15]+n[i>>20&15]+n[i>>16&15]+n[i>>28&15]+n[i>>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="",i=this.array(),o=0;o<15;)e=i[o++],t=i[o++],r=i[o++],n+=p[e>>>2]+p[63&(e<<4|t>>>4)]+p[63&(t<<2|r>>>6)]+p[63&r];return e=i[o],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__(20),__webpack_require__(3))},function(e,t){var r,n,i=e.exports={};function o(){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===o||!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:o}catch(e){r=o}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(){}i.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)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=g,i.addListener=g,i.once=g,i.off=g,i.removeListener=g,i.removeAllListeners=g,i.emit=g,i.prependListener=g,i.prependOnceListener=g,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.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 m(e,t,r,n){return this instanceof m?function(e,t,r,n,i){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))i=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 i=0,o=r.length,s=0,a=0;"-"===r[0]&&i++;for(var u=i;i<o;){var c=parseInt(r[i++],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,i||10):s(n,i)?a(t,r,n,i):"number"==typeof i?(b(t,r+E,n),b(t,r+k,i)):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 m(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]*_+(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=m.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),i=w(t,r+k),o="",s=!g&&2147483648&n;for(s&&(n=~n,i=y-i),e=e||10;;){var a=n%e*y+i;if(n=Math.floor(n/e),i=Math.floor(a/e),o=(a%e).toString(e)+o,!n&&!i)break}return s&&(o="-"+o),o},S.toJSON=v,S.toArray=n,l&&(S.toBuffer=i),h&&(S.toArrayBuffer=o),m[M]=function(e){return!(!e||!e[I])},t[e]=m,m}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 i(t){var r=this.buffer,n=this.offset;if(c=l,!1!==t&&0===n&&8===r.length&&e.isBuffer(r))return r;var i=new l(8);return a(i,0,r,n),i}function o(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 i=new h(8);return a(i,0,t,r),i.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 i=0;i<8;i++)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,_=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(6).Buffer)},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 i=r(4),o=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 i=n||{};return{defaults:i.defaults||{},pass:i.pass||[],request:t||{},required:i.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},_={"event.kicked":!0,"event.room_removed":!0},m="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:m},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),N=b(!1),B=k(!1),x=E(!1),D=P(!1),F=v("string_or_bin",!1),L=v("tuple8",!1);function j(e,t){return O(e,x,t)}function q(e,t){return O(e,M,t)}function Y(e,t){return O(e,I,t)}function V(e){return T(e,"string",D)}function H(e){return T(e,"positive_decimal_int64",D)}function W(e){return T(e,"positive_decimal_int64",U)}function G(e){return T(e,"positive_decimal_int64",B)}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)},X={anchor:E(!0),end_ms:k(!0),kinds:q(!1),limit:R(!0),reverse:C(!0),start_ms:k(!0)},$={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:V(!1),user:E(!0)}),"connection.close":A(),"system.time":A(),"connection.set_props":A({props:V(!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)},X)),"history.group_anchor":A(Object.assign({group_ref:E(!0)},X)),"history.room_anchor":A(Object.assign({room_ref:E(!0)},X)),"history.broadcast_anchor":A(X),"history.direct_count":A(Object.assign({peer:E(!0)},$)),"history.group_count":A(Object.assign({group_ref:E(!0)},$)),"history.room_count":A(Object.assign({room_ref:E(!0)},$)),"history.broadcast_count":A($),"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,L),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:V(!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:H(!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:H(!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:W(!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:H(!0)}),"room.last_messages":S({last_by_room:function(e){return T(e,"positive_decimal_int64",L)}(!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:W(!0),times:G(!0)}),"unread.group":S({counts:W(!0),times:G(!0)}),"session.remove":S(),"conversation.direct":S({badges:Y(!0),last_items:O(!0,L),peers:j(!0)}),"conversation.direct_unread":S({badges:Y(!0),last_items:O(!0,L),peers:j(!0)}),"conversation.group":S({badges:Y(!0),group_refs:j(!0),last_items:O(!0,L)}),"conversation.group_unread":S({badges:Y(!0),group_refs:j(!0),last_items:O(!0,L)}),"conversation.unread":S({group_badges:Y(!0),group_last:O(!0,L),group_refs:j(!0),peer_badges:Y(!0),peer_last:O(!0,L),peers:j(!0)}),"control.ping":S({ts:b(!1)})},ie={from_locale:P(!0),original:P(!0),to_locale:P(!0),translated:P(!0)},oe={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)},oe),"event.group":Object.assign({group_ref:E(!0)},oe),"event.room":Object.assign({room_ref:E(!0)},oe),"event.broadcast":oe,"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 i.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 i="-"===r.charAt(0),o="-"===n.charAt(0);if(i!==o)return i?-1:1;var s=i?r.slice(1):r,a=o?n.slice(1):n,u=void 0;return u=s.length!==a.length?s.length<a.length?-1:1:s<a?-1:1,i?-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 i=e.charCodeAt(r+1);if(i<56320||i>57343)throw new o(200034,"string contains an unpaired surrogate");t+=4,r+=1}else{if(n>=56320&&n<=57343)throw new o(200034,"string contains an unpaired surrogate");t+=n<=127?1:n<=2047?2:3}}return t}function he(e,t){throw new o(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=i.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 i.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,m)>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||i.getByteView(e))return;pe("Chat payload",e,ie)}else!function(e,t){Array.isArray(e)&&8===e.length||he(t,"must be an 8-item message tuple"),de(e[0],N,t+"[0]"),de(e[1],N,t+"[1]"),de(e[2],M,t+"[2]"),de(e[3],N,t+"[3]"),de(e[4],v("boolean",!1),t+"[4]"),de(e[5],F,t+"[5]"),de(e[6],D,t+"[6]"),de(e[7],N,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 o={};e.forEach((function(e){o[ce(e)]=!0})),Object.keys(o).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,m)>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){i.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 i=r[n];Object.prototype.hasOwnProperty.call(t,n)?de(t[n],i,e+"."+n):i.required&&he(e+"."+n,"is required")}))}function ge(e,t,r){for(var n=t[r[0]].length,i=1;i<r.length;i+=1)t[r[i]].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:o,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(_,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 o(200020,e+" is reserved and unavailable on the TLV Client port");throw new o(20004,"unknown or unsupported TLV Client wire: "+e)}if(!i.isPlainMap(t))throw new o(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 o(200034,s.uri+" does not accept field "+e);r=e}if(Object.prototype.hasOwnProperty.call(a,r))throw new o(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(!i.isPlainMap(n))throw new o(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 o(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 o(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"),i=Object.prototype.hasOwnProperty.call(t,"auth_ver");if(n!==i)throw new o(200034,"auth.login requires auth_sec and auth_ver together");if(i&&"2"!==ce(t.auth_ver))throw new o(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 o(200034,"unsupported Push URI: "+e);pe(e+" Push",t,r)},validateResponse:function(e,t){var r=ne[e];if(!r)throw new o(200034,"unsupported Answer URI: "+e);r.allowEmpty&&i.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=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 o=r(2),s=r(10),a=r(0),u=r(5),c=r(11).normalizeClientOptions,f=r(12),l=["sharing","uid","conversation","workerName","workerUrl","workerNamespace","readyTimeout","idleShutdownTimeout"],h=function(){function e(t){if(i(this,e),"undefined"==typeof SharedWorker)throw g("Browser SharedWorker support is required; use sharing: false for an independent connection","RTM_SHARED_WORKER_UNSUPPORTED");var r,n;this._config=Object.assign({},t),this._options=c(p(t)),this._config.conversation=f(t.conversation),this._delegate=null,this._uid=null,this._destroyed=!1,this._events=new d,this.processor=new d,this.promises=(r=this,(n=Object.assign({},u(r,o.prototype))).login=function(e,t,n){return arguments.length>3?Promise.reject(new TypeError("promises.login(uid, credential, timeout?)")):r.loginIfNeeded(e,t,n).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(n)),void 0!==t.uid&&null!==t.uid&&this._attach(t.uid)}return n(e,[{key:"_attach",value:function(e){if(this._assertActive(),"number"==typeof e&&(!isFinite(e)||Math.floor(e)!==e||Math.abs(e)>9007199254740991))throw g("Use a decimal string for a UID outside the safe integer range","RTM_SHARED_UID_INVALID");var t=null==e?"":String(e).trim().replace(/^0+(?=\d)/,"");if(!/^\d+$/.test(t)||/^0+$/.test(t))throw g("Provide a positive UID in login() or createClient({ uid }) before attaching","RTM_SHARED_UID_REQUIRED");if(t.length>20||20===t.length&&t>"18446744073709551615")throw g("UID exceeds the uint64 range","RTM_SHARED_UID_INVALID");if(null!==this._uid&&this._uid!==t)throw g("This client is bound to UID "+this._uid+"; create another client for UID "+t,"RTM_SHARED_UID_MISMATCH");if(!this._delegate){var r=this._config,n=new s({workerName:r.workerName||s.createWorkerName({pid:this._options.pid,protocol:this._options.protocol,uid:t,namespace:r.workerNamespace}),workerUrl:r.workerUrl,conversation:r.conversation,readyTimeout:r.readyTimeout,idleShutdownTimeout:r.idleShutdownTimeout,clientOptions:this._options});this._uid=t,this._delegate=n,this._events.bind(n),this.processor.bind(n.processor)}return this._delegate}},{key:"_assertActive",value:function(){if(this._destroyed)throw g("RTM client has been destroyed","RTM_CLIENT_DESTROYED")}},{key:"login",value:function(e,t,r,n){var i=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{i._events.emit("SharedWorkerError",e)}}))}},{key:"loginIfNeeded",value:function(e,t,r){try{var n=this._attach(e),i=this._uid.length>19||19===this._uid.length&&this._uid>"9223372036854775807"?a.Uint64(this._uid):a.Int64(this._uid);return n.loginIfNeeded(i,t,r)}catch(e){return Promise.reject(e)}}},{key:"whenReady",value:function(e){try{return this._attach(void 0===e?this._uid:e).whenReady()}catch(e){return Promise.reject(e)}}},{key:"getSharedSession",value:function(){return this._delegate?this._delegate.getSharedSession():{status:"idle",uid:null}}},{key:"setConversation",value:function(e,t){return this._assertActive(),e=f(e),this._delegate?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:"close",value:function(){this._assertActive(),this._delegate&&this._delegate.close()}},{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){try{if(this._assertActive(),!this._delegate)throw g("Call login() before "+e+"()","RTM_SHARED_UID_REQUIRED")}catch(e){var r=t.slice().reverse().find((function(e){return"function"==typeof e}));if(r)return void r(e,null);throw e}return this._delegate[e].apply(this._delegate,t)}}]),e}(),d=function(){function e(){i(this,e),this._listeners=Object.create(null),this._target=null}return n(e,[{key:"bind",value:function(e){var t=this;this._target=e,Object.keys(this._listeners).forEach((function(r){t._listeners[r].forEach((function(t){return e.on(r,t)}))}))}},{key:"on",value:function(e,t){if("function"!=typeof t)return this;var r=this._listeners[e]||(this._listeners[e]=[]);return-1===r.indexOf(t)&&(r.push(t),this._target&&this._target.on(e,t)),this}},{key:"off",value:function(e,t){var r=this,n=this._listeners[e]||[];return n.slice().forEach((function(i){void 0!==t&&i!==t||(r._target&&r._target.removeEvent(e,i),n.splice(n.indexOf(i),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:"clear",value:function(){this._target=null,this._listeners=Object.create(null)}}]),e}();function p(e){var t=Object.assign({},e);return l.forEach((function(e){delete t[e]})),t}function g(e,t){var r=new Error(e);return r.code=t,r}Object.getOwnPropertyNames(o.prototype).forEach((function(e){"constructor"===e||"_"===e.charAt(0)||Object.prototype.hasOwnProperty.call(h.prototype,e)||"function"==typeof Object.getOwnPropertyDescriptor(o.prototype,e).value&&(h.prototype[e]=function(){return this._invoke(e,Array.prototype.slice.call(arguments))})})),e.exports=function(e){var t=e||{};if(void 0!==t.sharing&&"boolean"!=typeof t.sharing)throw new TypeError("sharing must be a boolean");if(!1===t.sharing){var r=p(t);return void 0===r.protocol&&(r.protocol="tlv-v1"),new o(r)}return new h(t)}}])}));
|