@cg-devcenter/rtc-fpnn-webjs-sdk 1.0.0-cg.12 → 1.0.0-cg.13

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/dist/rtm.min.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * @author Feross Aboukhadijeh <http://feross.org>
6
6
  * @license MIT
7
7
  */
8
- var n=r(20),o=r(21),i=r(22);function s(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,t){if(s()<t)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=u.prototype:(null===e&&(e=new u(t)),e.length=t),e}function u(e,t,r){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(e,t,r);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return l(this,e)}return c(this,e,t,r)}function c(e,t,r,n){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,r,n){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");t=void 0===r&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,r):new Uint8Array(t,r,n);u.TYPED_ARRAY_SUPPORT?(e=t).__proto__=u.prototype:e=h(e,t);return e}(e,t,r,n):"string"==typeof t?function(e,t,r){"string"==typeof r&&""!==r||(r="utf8");if(!u.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|p(t,r),o=(e=a(e,n)).write(t,r);o!==n&&(e=e.slice(0,o));return e}(e,t,r):function(e,t){if(u.isBuffer(t)){var r=0|d(t.length);return 0===(e=a(e,r)).length||t.copy(e,0,0,r),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(n=t.length)!=n?a(e,0):h(e,t);if("Buffer"===t.type&&i(t.data))return h(e,t.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function f(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function l(e,t){if(f(t),e=a(e,t<0?0:0|d(t)),!u.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function h(e,t){var r=t.length<0?0:0|d(t.length);e=a(e,r);for(var n=0;n<r;n+=1)e[n]=255&t[n];return e}function d(e){if(e>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|e}function p(e,t){if(u.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return j(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return q(e).length;default:if(n)return j(e).length;t=(""+t).toLowerCase(),n=!0}}function g(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return A(this,t,r);case"utf8":case"utf-8":return C(this,t,r);case"ascii":return O(this,t,r);case"latin1":case"binary":return T(this,t,r);case"base64":return P(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function y(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function m(e,t,r,n,o){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=o?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(o)return-1;r=e.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof t&&(t=u.from(t,n)),u.isBuffer(t))return 0===t.length?-1:_(e,t,r,n,o);if("number"==typeof t)return t&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):_(e,[t],r,n,o);throw new TypeError("val must be string, number or Buffer")}function _(e,t,r,n,o){var i,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function c(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(o){var f=-1;for(i=r;i<a;i++)if(c(e,i)===c(t,-1===f?0:i-f)){if(-1===f&&(f=i),i-f+1===u)return f*s}else-1!==f&&(i-=i-f),f=-1}else for(r+u>a&&(r=a-u),i=r;i>=0;i--){for(var l=!0,h=0;h<u;h++)if(c(e,i+h)!==c(t,h)){l=!1;break}if(l)return i}return-1}function v(e,t,r,n){r=Number(r)||0;var o=e.length-r;n?(n=Number(n))>o&&(n=o):n=o;var i=t.length;if(i%2!=0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var s=0;s<n;++s){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))return s;e[r+s]=a}return s}function b(e,t,r,n){return V(j(t,e.length-r),e,r,n)}function w(e,t,r,n){return V(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function E(e,t,r,n){return w(e,t,r,n)}function k(e,t,r,n){return V(q(t),e,r,n)}function R(e,t,r,n){return V(function(e,t){for(var r,n,o,i=[],s=0;s<e.length&&!((t-=2)<0);++s)r=e.charCodeAt(s),n=r>>8,o=r%256,i.push(o),i.push(n);return i}(t,e.length-r),e,r,n)}function P(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function C(e,t,r){r=Math.min(e.length,r);for(var n=[],o=t;o<r;){var i,s,a,u,c=e[o],f=null,l=c>239?4:c>223?3:c>191?2:1;if(o+l<=r)switch(l){case 1:c<128&&(f=c);break;case 2:128==(192&(i=e[o+1]))&&(u=(31&c)<<6|63&i)>127&&(f=u);break;case 3:i=e[o+1],s=e[o+2],128==(192&i)&&128==(192&s)&&(u=(15&c)<<12|(63&i)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:i=e[o+1],s=e[o+2],a=e[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),o+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=4096));return r}(n)}t.Buffer=u,t.SlowBuffer=function(e){+e!=e&&(e=0);return u.alloc(+e)},t.INSPECT_MAX_BYTES=50,u.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),t.kMaxLength=s(),u.poolSize=8192,u._augment=function(e){return e.__proto__=u.prototype,e},u.from=function(e,t,r){return c(null,e,t,r)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0})),u.alloc=function(e,t,r){return function(e,t,r,n){return f(t),t<=0?a(e,t):void 0!==r?"string"==typeof n?a(e,t).fill(r,n):a(e,t).fill(r):a(e,t)}(null,e,t,r)},u.allocUnsafe=function(e){return l(null,e)},u.allocUnsafeSlow=function(e){return l(null,e)},u.isBuffer=function(e){return!(null==e||!e._isBuffer)},u.compare=function(e,t){if(!u.isBuffer(e)||!u.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,o=0,i=Math.min(r,n);o<i;++o)if(e[o]!==t[o]){r=e[o],n=t[o];break}return r<n?-1:n<r?1:0},u.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(e,t){if(!i(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return u.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=u.allocUnsafe(t),o=0;for(r=0;r<e.length;++r){var s=e[r];if(!u.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(n,o),o+=s.length}return n},u.byteLength=p,u.prototype._isBuffer=!0,u.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)y(this,t,t+1);return this},u.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)y(this,t,t+3),y(this,t+1,t+2);return this},u.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)y(this,t,t+7),y(this,t+1,t+6),y(this,t+2,t+5),y(this,t+3,t+4);return this},u.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?C(this,0,e):g.apply(this,arguments)},u.prototype.equals=function(e){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===u.compare(this,e)},u.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),"<Buffer "+e+">"},u.prototype.compare=function(e,t,r,n,o){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),t<0||r>e.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&t>=r)return 0;if(n>=o)return-1;if(t>=r)return 1;if(this===e)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(i,s),c=this.slice(n,o),f=e.slice(t,r),l=0;l<a;++l)if(c[l]!==f[l]){i=c[l],s=f[l];break}return i<s?-1:s<i?1:0},u.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},u.prototype.indexOf=function(e,t,r){return m(this,e,t,r,!0)},u.prototype.lastIndexOf=function(e,t,r){return m(this,e,t,r,!1)},u.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-t;if((void 0===r||r>o)&&(r=o),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return v(this,e,t,r);case"utf8":case"utf-8":return b(this,e,t,r);case"ascii":return w(this,e,t,r);case"latin1":case"binary":return E(this,e,t,r);case"base64":return k(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,t,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function O(e,t,r){var n="";r=Math.min(e.length,r);for(var o=t;o<r;++o)n+=String.fromCharCode(127&e[o]);return n}function T(e,t,r){var n="";r=Math.min(e.length,r);for(var o=t;o<r;++o)n+=String.fromCharCode(e[o]);return n}function A(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var o="",i=t;i<r;++i)o+=F(e[i]);return o}function S(e,t,r){for(var n=e.slice(t,r),o="",i=0;i<n.length;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function M(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function I(e,t,r,n,o,i){if(!u.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<i)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function U(e,t,r,n){t<0&&(t=65535+t+1);for(var o=0,i=Math.min(e.length-r,2);o<i;++o)e[r+o]=(t&255<<8*(n?o:1-o))>>>8*(n?o:1-o)}function B(e,t,r,n){t<0&&(t=4294967295+t+1);for(var o=0,i=Math.min(e.length-r,4);o<i;++o)e[r+o]=t>>>8*(n?o:3-o)&255}function N(e,t,r,n,o,i){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function x(e,t,r,n,i){return i||N(e,0,r,4),o.write(e,t,r,n,23,4),r+4}function D(e,t,r,n,i){return i||N(e,0,r,8),o.write(e,t,r,n,52,8),r+8}u.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t<e&&(t=e),u.TYPED_ARRAY_SUPPORT)(r=this.subarray(e,t)).__proto__=u.prototype;else{var o=t-e;r=new u(o,void 0);for(var i=0;i<o;++i)r[i]=this[i+e]}return r},u.prototype.readUIntLE=function(e,t,r){e|=0,t|=0,r||M(e,t,this.length);for(var n=this[e],o=1,i=0;++i<t&&(o*=256);)n+=this[e+i]*o;return n},u.prototype.readUIntBE=function(e,t,r){e|=0,t|=0,r||M(e,t,this.length);for(var n=this[e+--t],o=1;t>0&&(o*=256);)n+=this[e+--t]*o;return n},u.prototype.readUInt8=function(e,t){return t||M(e,1,this.length),this[e]},u.prototype.readUInt16LE=function(e,t){return t||M(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUInt16BE=function(e,t){return t||M(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUInt32LE=function(e,t){return t||M(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},u.prototype.readUInt32BE=function(e,t){return t||M(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||M(e,t,this.length);for(var n=this[e],o=1,i=0;++i<t&&(o*=256);)n+=this[e+i]*o;return n>=(o*=128)&&(n-=Math.pow(2,8*t)),n},u.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||M(e,t,this.length);for(var n=t,o=1,i=this[e+--n];n>0&&(o*=256);)i+=this[e+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*t)),i},u.prototype.readInt8=function(e,t){return t||M(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},u.prototype.readInt16LE=function(e,t){t||M(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(e,t){t||M(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(e,t){return t||M(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return t||M(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readFloatLE=function(e,t){return t||M(e,4,this.length),o.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return t||M(e,4,this.length),o.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return t||M(e,8,this.length),o.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return t||M(e,8,this.length),o.read(this,e,!1,52,8)},u.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||I(this,e,t,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[t]=255&e;++i<r&&(o*=256);)this[t+i]=e/o&255;return t+r},u.prototype.writeUIntBE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||I(this,e,t,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[t+o]=255&e;--o>=0&&(i*=256);)this[t+o]=e/i&255;return t+r},u.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,1,255,0),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},u.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):U(this,e,t,!0),t+2},u.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):U(this,e,t,!1),t+2},u.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):B(this,e,t,!0),t+4},u.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):B(this,e,t,!1),t+4},u.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var o=Math.pow(2,8*r-1);I(this,e,t,r,o-1,-o)}var i=0,s=1,a=0;for(this[t]=255&e;++i<r&&(s*=256);)e<0&&0===a&&0!==this[t+i-1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+r},u.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var o=Math.pow(2,8*r-1);I(this,e,t,r,o-1,-o)}var i=r-1,s=1,a=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===a&&0!==this[t+i+1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+r},u.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,1,127,-128),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},u.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):U(this,e,t,!0),t+2},u.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):U(this,e,t,!1),t+2},u.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):B(this,e,t,!0),t+4},u.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):B(this,e,t,!1),t+4},u.prototype.writeFloatLE=function(e,t,r){return x(this,e,t,!0,r)},u.prototype.writeFloatBE=function(e,t,r){return x(this,e,t,!1,r)},u.prototype.writeDoubleLE=function(e,t,r){return D(this,e,t,!0,r)},u.prototype.writeDoubleBE=function(e,t,r){return D(this,e,t,!1,r)},u.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var o,i=n-r;if(this===e&&r<t&&t<n)for(o=i-1;o>=0;--o)e[o+t]=this[o+r];else if(i<1e3||!u.TYPED_ARRAY_SUPPORT)for(o=0;o<i;++o)e[o+t]=this[o+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+i),t);return i},u.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===e.length){var o=e.charCodeAt(0);o<256&&(e=o)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!u.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var i;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(i=t;i<r;++i)this[i]=e;else{var s=u.isBuffer(e)?e:j(new u(e,n).toString()),a=s.length;for(i=0;i<r-t;++i)this[i+t]=s[i%a]}return this};var L=/[^+\/0-9A-Za-z-_]/g;function F(e){return e<16?"0"+e.toString(16):e.toString(16)}function j(e,t){var r;t=t||1/0;for(var n=e.length,o=null,i=[],s=0;s<n;++s){if((r=e.charCodeAt(s))>55295&&r<57344){if(!o){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function q(e){return n.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(L,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function V(e,t,r,n){for(var o=0;o<n&&!(o+r>=t.length||o>=e.length);++o)t[o+r]=e[o];return o}}).call(this,r(3))},function(e,t,r){"use strict";var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();var o=r(1).fpnn,i=r(0),s=(r(2),function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),o.FPEvent.assign(this),this._map={},this._client=t,this.uid=0,this._expireTimerID=0,this._msgOptions={codec:i.MsgPack.createCodec({int64:!0})},this._binaryOptions={codec:i.MsgPack.createCodec({int64:!0,useraw:!0})},this._binaryMessageMethodList=[i.SERVER_PUSH.recvMessage,i.SERVER_PUSH.recvGroupMessage,i.SERVER_PUSH.recvRoomMessage,i.SERVER_PUSH.recvBroadcastMessage,i.SERVER_PUSH.recvFile,i.SERVER_PUSH.recvGroupFile,i.SERVER_PUSH.recvRoomFile,i.SERVER_PUSH.recvBroadcastFile],u.call(this)}return n(e,[{key:"service",value:function(e,t){if(e&&Object.prototype.hasOwnProperty.call(e,"_tlvPayload")&&(r=e.method,n=i.TLV_SERVER_PUSH,r===n.recvMessage||r===n.recvGroupMessage||r===n.recvRoomMessage||r===n.recvBroadcastMessage||r===n.kickOut||r===n.kickOutRoom))this._serviceTLVPush(e);else{var r,n,o=!0;i.SERVER_PUSH.kickOut==e.method&&(o=!1),i.SERVER_PUSH.kickOutRoom==e.method&&(o=!1),o&&t&&(0==e.flag&&t(JSON.stringify({}),!1),1==e.flag&&t(i.MsgPack.encode({},this._msgOptions),!1));var s=null;if(e&&Object.prototype.hasOwnProperty.call(e,"_tlvPayload")&&(s=e._tlvPayload,e._tlvBinaryPayload&&(s.binary=s.msg)),s||0!=e.flag||(s=JSON.parse(e.payload)),!s&&1==e.flag)if(-1!==this._binaryMessageMethodList.indexOf(e.method))if((s=i.MsgPack.decode(e.payload,this._binaryOptions)).mtype==i.CHAT_TYPE.text)s=i.MsgPack.decode(e.payload,this._msgOptions);else{s.binary=s.msg;try{s.msg=new TextDecoder("utf-8",{fatal:!0}).decode(s.msg)}catch(e){s.msg=void 0}try{s.attrs=new TextDecoder("utf-8",{fatal:!0}).decode(s.attrs)}catch(e){}}else s=i.MsgPack.decode(e.payload,this._msgOptions);if(s){if(void 0!==s.attrs)try{var a=JSON.parse(s.attrs);if(a&&void 0!==a.excludedUids&&Array.isArray(a.excludedUids)&&a.excludedUids.includes(this.uid.toString()))return}catch(e){}"function"==typeof this[e.method]&&this[e.method].call(this,s)}}}},{key:"_serviceTLVPush",value:function(e){var t=e._tlvPayload;if(t&&void 0!==t.extra)try{var r=JSON.parse(t.extra);if(r&&void 0!==r.excludedUids&&Array.isArray(r.excludedUids)&&r.excludedUids.includes(this.uid.toString()))return}catch(e){}this.emit(e.method,t)}},{key:"destroy",value:function(){this._map={},this._expireTimerID&&(clearInterval(this._expireTimerID),this._expireTimerID=0)}},{key:"kickout",value:function(e){this.emit(i.SERVER_PUSH.kickOut,e)}},{key:"kickoutroom",value:function(e){e.rid&&(e.rid=new i.Int64(e.rid)),this.emit(i.SERVER_PUSH.kickOutRoom,e)}},{key:"pushmsg",value:function(e){e.from&&(e.from=new i.Int64(e.from)),e.mid&&(e.mid=new i.Int64(e.mid),!a.call(this,1,e.mid,e.from))||(e.mtime&&(e.mtime=new i.Int64(e.mtime)),e.mtype>=40&&e.mtype<=50?this.emit(i.SERVER_PUSH.recvFile,e):e.mtype!=i.CHAT_TYPE.text?e.mtype!=i.CHAT_TYPE.audio?e.mtype!=i.CHAT_TYPE.cmd?(delete e.ftype,this.emit(i.SERVER_PUSH.recvMessage,e)):this.emit(i.SERVER_PUSH.recvCmd,e):this.emit(i.SERVER_PUSH.recvFile,e):this.emit(i.SERVER_PUSH.recvChat,e))}},{key:"pushgroupmsg",value:function(e){e.from&&(e.from=new i.Int64(e.from)),e.mid&&(e.mid=new i.Int64(e.mid),!a.call(this,2,e.mid,e.from,e.gid))||(e.gid&&(e.gid=new i.Int64(e.gid)),e.mtime&&(e.mtime=new i.Int64(e.mtime)),e.mtype>=40&&e.mtype<=50?this.emit(i.SERVER_PUSH.recvGroupFile,e):e.mtype!=i.CHAT_TYPE.text?e.mtype!=i.CHAT_TYPE.audio?e.mtype!=i.CHAT_TYPE.cmd?(delete e.ftype,this.emit(i.SERVER_PUSH.recvGroupMessage,e)):this.emit(i.SERVER_PUSH.recvGroupCmd,e):this.emit(i.SERVER_PUSH.recvGroupFile,e):this.emit(i.SERVER_PUSH.recvGroupChat,e))}},{key:"pushroommsg",value:function(e){e.from&&(e.from=new i.Int64(e.from)),e.mid&&(e.mid=new i.Int64(e.mid),!a.call(this,3,e.mid,e.from,e.rid))||(e.rid&&(e.rid=new i.Int64(e.rid)),e.mtime&&(e.mtime=new i.Int64(e.mtime)),e.mtype>=40&&e.mtype<=50?this.emit(i.SERVER_PUSH.recvRoomFile,e):e.mtype!=i.CHAT_TYPE.text?e.mtype!=i.CHAT_TYPE.audio?e.mtype!=i.CHAT_TYPE.cmd?(delete e.ftype,this.emit(i.SERVER_PUSH.recvRoomMessage,e)):this.emit(i.SERVER_PUSH.recvRoomCmd,e):this.emit(i.SERVER_PUSH.recvRoomFile,e):this.emit(i.SERVER_PUSH.recvRoomChat,e))}},{key:"pushbroadcastmsg",value:function(e){e.from&&(e.from=new i.Int64(e.from)),e.mid&&(e.mid=new i.Int64(e.mid),!a.call(this,4,e.mid,e.from))||(e.mtime&&(e.mtime=new i.Int64(e.mtime)),e.mtype>=40&&e.mtype<=50?this.emit(i.SERVER_PUSH.recvBroadcastFile,e):e.mtype!=i.CHAT_TYPE.text?e.mtype!=i.CHAT_TYPE.audio?e.mtype!=i.CHAT_TYPE.cmd?(delete e.ftype,this.emit(i.SERVER_PUSH.recvBroadcastMessage,e)):this.emit(i.SERVER_PUSH.recvBroadcastCmd,e):this.emit(i.SERVER_PUSH.recvBroadcastFile,e):this.emit(i.SERVER_PUSH.recvBroadcastChat,e))}},{key:"ping",value:function(e){this._client._lastPingTime=parseInt(Date.now()/1e3),this.emit(i.SERVER_PUSH.recvPing,e)}}]),e}());function a(e,t,r,n){var o=[];o.push(e),o.push(t),o.push(r),null!=n&&o.push(n);var s=o.join("_");if(this._map.hasOwnProperty(s)){if(this._map[s]>Date.now())return!1;delete this._map[s]}return this._map[s]=i.MID_TTL+Date.now(),!0}function u(){var e=this;this._expireTimerID=setInterval((function(){for(var t in e._map)e._map[t]>Date.now()||c.call(e,t)}),i.MID_TTL+1e3)}function c(e){var t=this;setTimeout((function(){delete t._map[e]}),0)}e.exports=s},function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();var i=r(11),s=r(12),a=r(4),u=r(0),c=r(5).normalizeTlvEndpoint,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||{};this._endpoint=c(r.endpoint),this._webSocketFactory=r.webSocketFactory||l,this._legacyMsgPack=r.legacyMsgPack||u.MsgPack,this._legacyMsgOptions=r.legacyMsgOptions,this._requestMetadata=r.requestMetadata,this._connectionTimeout=r.connectionTimeout||3e4,this._requestTimeout=r.requestTimeout||2e4,this._heartbeatIdleMs=r.heartbeatIdleMs||3e4,this._heartbeatTimeoutMs=r.heartbeatTimeoutMs||1e4,this._dedupTtlMs=Math.max(r.pushDedupTtlMs||3e4,2e4),this._listeners={},this._pending=new Map,this._receivedMessages=new Map,this._nextSequence=1,this._socket=null,this._connectionGeneration=0,this._state="idle",this._authenticated=!1,this._connectionTimer=0,this._heartbeatTimer=0,this._heartbeatPending=!1,this._lastActivity=0,this._incomingQueue=Promise.resolve(),this._protocolClosing=!1,this._destroyed=!1,this.processor=null}return o(e,[{key:"on",value:function(e,t){return"function"!=typeof t||(this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push(t)),this}},{key:"off",value:function(e,t){var r=this._listeners[e];return r?(this._listeners[e]=r.filter((function(e){return e!==t})),this):this}},{key:"emit",value:function(e){var t=this._listeners[e]||[],r=Array.prototype.slice.call(arguments,1),n=this;t.slice().forEach((function(e){e.apply(n,r)}))}},{key:"connect",value:function(){if(!this._destroyed&&"connecting"!==this._state&&"open"!==this._state&&"closing"!==this._state){var e=this._connectionGeneration+1;this._connectionGeneration=e,this._nextSequence=1,this._receivedMessages.clear(),this._incomingQueue=Promise.resolve(),this._state="connecting",this._protocolClosing=!1;var t=void 0;try{t=this._webSocketFactory(this._endpoint)}catch(e){return this._state="closed",this.emit("error",d("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",d("webSocketFactory returned an invalid socket")),void this.emit("close");this._socket=t;try{t.binaryType="arraybuffer"}catch(e){}t.onopen=this._onOpen.bind(this,t,e),t.onmessage=this._onMessage.bind(this,t,e),t.onerror=this._onError.bind(this,t,e),t.onclose=this._onClose.bind(this,t,e),this._connectionTimer=setTimeout(this._onConnectionTimeout.bind(this,t,e),this._connectionTimeout)}}},{key:"close",value:function(){this._clearConnectionTimeout(),this._stopHeartbeat(),this._authenticated=!1,"open"!==this._state&&"connecting"!==this._state||(this._state="closing");var e=this._socket;if(e)try{e.close()}catch(e){this._finalizeClose()}else this._finalizeClose()}},{key:"destroy",value:function(){if(!this._destroyed){this._destroyed=!0,this._clearConnectionTimeout(),this._stopHeartbeat(),this._authenticated=!1;var e=this._socket;if(e)try{e.close()}catch(e){}this._finalizeClose(),this._listeners={},this._receivedMessages.clear()}}},{key:"markAuthenticated",value:function(){this._destroyed||"open"!==this._state||(this._authenticated=!0,this._lastActivity=Date.now(),this._startHeartbeat())}},{key:"sendQuest",value:function(e,t,r){try{var n=this._decodeLegacyPayload(e&&e.payload),o=s.toWireRequest(e&&e.method,n.payload,this._requestMetadata,{omitLegacyNil:n.legacyEncoded});this._request(o.uri,o.payload,r,{onError:function(e){t&&t(p(e))},onSuccess:function(e){t&&t({_tlvPayload:g(e),mtype:2,ss:0})}})}catch(e){t&&t(p(e))}}},{key:"_decodeLegacyPayload",value:function(e){if(null==e)return{legacyEncoded:!1,payload:{}};if(a.isPlainMap(e))return{legacyEncoded:!1,payload:e};try{var t=this._legacyMsgPack.decode(e,this._legacyMsgOptions);if(!a.isPlainMap(t))throw new Error("legacy request payload is not a map");return{legacyEncoded:!0,payload:t}}catch(e){throw new s.TLVContractError(200034,"cannot decode local request payload: "+e.message)}}},{key:"_onOpen",value:function(e,t){e!==this._socket||t!==this._connectionGeneration||"connecting"!==this._state||this._destroyed||(this._clearConnectionTimeout(),this._state="open",this._lastActivity=Date.now(),this.emit("connect"))}},{key:"_onMessage",value:function(e,t,r){if(e===this._socket&&t===this._connectionGeneration&&"open"===this._state&&!this._destroyed){var o=r&&("object"===(void 0===r?"undefined":n(r))||"function"==typeof r)&&"data"in r?r.data:r;this._incomingQueue=this._incomingQueue.then((function(){return function(e){if("string"==typeof e)return Promise.reject(new Error("WebSocket text messages are forbidden by TLV v1"));var t=a.getByteView(e);if(t)return Promise.resolve(t);if(e&&"function"==typeof e.arrayBuffer){var r=void 0;try{r=e.arrayBuffer()}catch(e){return Promise.reject(e)}return Promise.resolve(r).then((function(e){var t=a.getByteView(e);if(!t)throw new Error("WebSocket Blob did not resolve to binary data");return t}))}return Promise.reject(new Error("WebSocket message is not binary data"))}(o)})).then(this._handleIncomingBytes.bind(this,e,t)).catch(this._handleIncomingFailure.bind(this,e,t))}}},{key:"_onError",value:function(e,t,r){if(e===this._socket&&t===this._connectionGeneration&&!this._destroyed){var n=r&&r.message?r.message:"WebSocket transport error";this.emit("error",d(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=d("WebSocket connection timed out after "+this._connectionTimeout+" ms");try{this.emit("error",r)}finally{if(e===this._socket&&t===this._connectionGeneration&&!this._destroyed&&"closed"!==this._state){this._state="closing";try{e.close()}catch(e){}e===this._socket&&t===this._connectionGeneration&&"closed"!==this._state&&this._finalizeClose()}}}}},{key:"_clearConnectionTimeout",value:function(){this._connectionTimer&&(clearTimeout(this._connectionTimer),this._connectionTimer=0)}},{key:"_handleIncomingBytes",value:function(e,t,r){if(e===this._socket&&t===this._connectionGeneration&&"open"===this._state&&!this._destroyed){this._lastActivity=Date.now();var n=i.decodeFrame(r);"2"!==n.mt?"1"!==n.mt?this._handleOneWayPush(n):this._handleReliablePush(n):this._handleAnswer(n)}}},{key:"_handleIncomingFailure",value:function(e,t,r){e!==this._socket||t!==this._connectionGeneration||this._destroyed||this._protocolFailure(r)}},{key:"_handleAnswer",value:function(e){if("control.ack"===e.uri)throw new Error("Gate must not send control.ack to a Client");var t=this._pending.get(e.sequence);if(t){if("control.error"===e.uri)return s.validateControlError(e.payload),void this._completePending(e.sequence,!1,{reason:e.payload.reason,status:Number(e.payload.status)});if(e.uri!==t.uri)throw new Error("Answer URI does not match pending request URI");s.validateResponse(e.uri,e.payload),this._completePending(e.sequence,!0,e.payload)}}},{key:"_handleReliablePush",value:function(e){if(!s.isReliablePush(e.uri))throw new Error('Gate sent an unsupported mt="1" Quest URI: '+e.uri);s.validatePush(e.uri,e.payload);var t=String(e.payload.message_ref),r=this._isDuplicateMessage(t);if(this._sendFrame(e.sequence,"2","control.ack",{}),!r){var n={method:e.uri,payload:g(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:g(e.payload)};"event.kicked"===e.uri&&(this._authenticated=!1,this._stopHeartbeat()),this._dispatchPush(t)}},{key:"_dispatchPush",value:function(e){if(this.processor&&"function"==typeof this.processor.service){var t=a.getByteView(e.payload.payload);this.processor.service({_tlvBinaryPayload:!!t,_tlvPayload:e.payload,flag:1,method:e.method})}}},{key:"_request",value:function(e,t,r,n){if(!this._destroyed&&"open"===this._state&&this._socket)if(this._authenticated||"auth.login"===e||"control.ping"===e)if(this._authenticated&&"auth.login"===e)n.onError({status:200023,reason:"auth.login cannot be sent twice on one connection"});else{var o=this._allocateSequence(),i="number"==typeof r&&r>0?r:this._requestTimeout,s={handlers:n,timer:setTimeout(this._onRequestTimeout.bind(this,o),i),uri:e};this._pending.set(o,s);try{this._sendFrame(o,"1",e,t)}catch(e){this._pending.delete(o),clearTimeout(s.timer),n.onError(h(e))}}else n.onError({status:200022,reason:"authentication is required before "+e});else n.onError(d("invalid WebSocket connection"))}},{key:"_onRequestTimeout",value:function(e){var t=this._pending.get(e);t&&(this._pending.delete(e),t.handlers.onError({status:200999,reason:"request timeout"}))}},{key:"_completePending",value:function(e,t,r){var n=this._pending.get(e);n&&(this._pending.delete(e),clearTimeout(n.timer),t?n.handlers.onSuccess(r):n.handlers.onError(r))}},{key:"_allocateSequence",value:function(){for(var e=0;e<i.MAX_SEQUENCE;e+=1){var t=this._nextSequence;if(this._nextSequence=t===i.MAX_SEQUENCE?1:t+1,!this._pending.has(t))return t}throw new Error("all TLV request sequences are pending")}},{key:"_sendFrame",value:function(e,t,r,n){if(this._destroyed||"open"!==this._state||!this._socket)throw d("invalid WebSocket connection");var o=i.encodeFrame(e,t,r,n),s=o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength);this._socket.send(s),this._lastActivity=Date.now()}},{key:"_startHeartbeat",value:function(){this._stopHeartbeat(),this._heartbeatTimer=setInterval(this._heartbeatTick.bind(this),1e3)}},{key:"_stopHeartbeat",value:function(){this._heartbeatTimer&&(clearInterval(this._heartbeatTimer),this._heartbeatTimer=0),this._heartbeatPending=!1}},{key:"_heartbeatTick",value:function(){this._authenticated&&!this._heartbeatPending&&"open"===this._state&&(Date.now()-this._lastActivity<this._heartbeatIdleMs||(this._heartbeatPending=!0,this._request("control.ping",{},this._heartbeatTimeoutMs,{onError:this._onHeartbeatError.bind(this),onSuccess:this._onHeartbeatAnswer.bind(this)})))}},{key:"_onHeartbeatAnswer",value:function(e){this._heartbeatPending=!1,a.isPlainMap(e)||this._protocolFailure(new Error("control.ping Answer body must be a map"))}},{key:"_onHeartbeatError",value:function(e){this._heartbeatPending=!1,this._protocolFailure(new Error("control.ping failed: "+h(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=h(e);this.emit("error",d("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(d("WebSocket connection closed"))})),this.emit("close")}}}]),e}();function l(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 h(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 d(e){return{reason:e,status:200999}}function p(e){var t=h(e);return{_tlvPayload:{reason:t.reason,status:t.status},mtype:2,ss:1}}function g(e){if(e instanceof a.Int64Value)return new u.Int64(e.toString());if(Array.isArray(e))return e.map(g);if(a.isPlainMap(e)){var t={};return Object.keys(e).forEach((function(r){t[r]=g(e[r])})),t}return e}e.exports=f},function(e,t,r){"use strict";var n=r(4),o=new Uint8Array([2,0,109,116,1,0]),i=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return r.name="TLVCodecError",r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,Error),t}();function s(e){if("number"!=typeof e||!isFinite(e)||Math.floor(e)!==e||e<1||e>2147483647)throw new i("sequence must be an integer in 1..2147483647")}function a(e,t,r){var n=r>>>0;e[t]=255&n,e[t+1]=n>>>8&255,e[t+2]=n>>>16&255,e[t+3]=n>>>24&255}function u(e,t){return e[t]+256*e[t+1]+65536*e[t+2]+16777216*e[t+3]>>>0}e.exports={FLAGS:4,MAGIC:204,MAX_FRAME_LENGTH:67239936,MAX_PAYLOAD_LENGTH:67108864,MAX_SEQUENCE:2147483647,METADATA_LENGTH:7,TLVCodecError:i,VERSION:1,decodeFrame:function(e){var t=n.toUint8Array(e);if(0===t.length||t.length>67239936)throw new i("TLV frame length is outside the allowed limit");if(t.length<27)throw new i("TLV frame is too short");if(204!==t[0]||1!==t[1]||4!==t[2]||0!==t[3])throw new i("invalid TLV v1 header");var r=u(t,4);if(s(r),7!==function(e,t){return e[t]+256*e[t+1]}(t,8))throw new i("TLV v1 metadata length must be exactly 7");for(var a=0;a<o.length;a+=1)if(t[10+a]!==o[a])throw new i("TLV v1 metadata must contain only key mt");var c=t[16];if(48!==c&&49!==c&&50!==c)throw new i("TLV v1 metadata mt is invalid");var f=String.fromCharCode(c);if(u(t,17)!==t.length-21)throw new i("message queue length does not match the frame boundary");var l=21,h=t[l];if(l+=1,0===h||l+h+1+4>t.length)throw new i("invalid URI length in message queue");var d=n.utf8Decode(t.subarray(l,l+h));if(0!==t[l+=h])throw new i("TLV v1 passThrough must be empty");var p=u(t,l+=1);if(l+=4,0===p||p>67108864||l+p!==t.length)throw new i("invalid MsgPack payload length or trailing bytes");var g=t.subarray(l,l+p),y=void 0;try{y=n.decodeMap(g,{allowIntegerMapKeyAtPath:"room.last_messages"===d?["last_by_room"]:null})}catch(e){if(e instanceof i)throw e;throw new i("invalid MsgPack payload: "+e.message)}return{mt:f,payload:y,payloadBytes:new Uint8Array(g),sequence:r,uri:d}},encodeFrame:function(e,t,r,u){s(e),function(e){if("0"!==e&&"1"!==e&&"2"!==e)throw new i('metadata mt must be "0", "1", or "2"')}(t);var c=function(e){if("string"!=typeof e||0===e.length)throw new i("URI must be a non-empty UTF-8 string");var t=n.utf8Encode(e);if(0===t.length||t.length>255)throw new i("URI UTF-8 length must be in 1..255");return t}(r),f=n.encodeMap(void 0===u?{}:u);if(0===f.length||f.length>67108864)throw new i("MsgPack payload length is outside the TLV v1 limit");var l=1+c.length+1+4+f.length,h=21+l;if(h>67239936)throw new i("TLV frame exceeds the maximum frame length");var d=new Uint8Array(h);d[0]=204,d[1]=1,d[2]=4,d[3]=0,a(d,4,e),function(e,t,r){e[t]=255&r,e[t+1]=r>>>8&255}(d,8,7),d.set(o,10),d[16]=t.charCodeAt(0),a(d,17,l);var p=21;return d[p]=c.length,p+=1,d.set(c,p),d[p+=c.length]=0,a(d,p+=1,f.length),p+=4,d.set(f,p),d}}},function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};var o=r(4),i=function(e){function t(e,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,r));return n.name="TLVContractError",n.status=e,n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,Error),t}();function s(e,t,r,n){var o=n||{};return{defaults:o.defaults||{},pass:o.pass||[],request:t||{},required:o.required||[],response:r||{},uri:e}}var a={cursor:0,end_ms:0,limit:20,reverse:!1,start_ms:0},u={end_ms:0,limit:20,reverse:!1,start_ms:0},c={end_ms:0,start_ms:0},f={begin:"start_ms",desc:"reverse",end:"end_ms",lastid:"cursor",mtypes:"kinds",num:"limit"},l={begin:"start_ms",desc:"reverse",end:"end_ms",mid:"anchor",mtypes:"kinds",num:"limit"},h={begin:"start_ms",end:"end_ms",mtypes:"kinds"},d={begin:"first_ms",end:"last_ms",lastid:"next",msgs:"items",num:"size"},p={auth:s("auth.login",{attrs:"props",authv:"auth_ver",lang:"locale",pid:"project",token:"credential",ts:"auth_sec",uid:"user",version:"client_ver"},{ok:"accepted"},{required:["project","user","credential","client_ver"]}),bye:s("connection.close"),getservertime:s("system.time",null,{mts:"server_ms"}),addattrs:s("connection.set_props",{attrs:"props"},null,{required:["props"]}),getattrs:s("connection.get_props",null,{attrs:"props"}),adddebuglog:s("system.debug",{attrs:"context",msg:"entry"},null,{required:["entry","context"]}),getonlineusers:s("presence.online",{uids:"users"},{uids:"online_users"},{required:["users"]}),setuserinfo:s("user.set_profile",{oinfo:"public_data",pinfo:"private_data"}),getuserinfo:s("user.get_profile",null,{oinfo:"public_data",pinfo:"private_data"}),getuseropeninfo:s("user.get_public",{uids:"users"},{info:"profiles"},{required:["users"]}),setlang:s("user.set_locale",{lang:"locale"},{ok:"updated"},{required:["locale"]}),dataget:s("storage.get",{key:"slot"},{val:"value"},{required:["slot"]}),dataset:s("storage.set",{key:"slot",val:"value"},null,{required:["slot","value"]}),datadel:s("storage.delete",{key:"slot"},null,{required:["slot"]}),addblacks:s("blacklist.add",{blacks:"blocked_users"},null,{required:["blocked_users"]}),delblacks:s("blacklist.remove",{blacks:"blocked_users"},null,{required:["blocked_users"]}),getblacks:s("blacklist.list",null,{uids:"blocked_users"}),addgroupmembers:s("group.add",{gid:"group_ref",uids:"members"},null,{required:["group_ref","members"]}),delgroupmembers:s("group.remove",{gid:"group_ref",uids:"members"},null,{required:["group_ref","members"]}),getgroupmembers:s("group.members",{gid:"group_ref",online:"with_online"},{onlines:"active_members",uids:"members"},{required:["group_ref"]}),getgroupcount:s("group.count",{gid:"group_ref",online:"with_online"},{cn:"total",online:"active_total"},{required:["group_ref"]}),getusergroups:s("group.joined",null,{gids:"group_refs"}),setgroupinfo:s("group.set_profile",{gid:"group_ref",oinfo:"public_data",pinfo:"private_data"},null,{required:["group_ref"]}),getgroupinfo:s("group.get_profile",{gid:"group_ref"},{oinfo:"public_data",pinfo:"private_data"},{required:["group_ref"]}),getgroupopeninfo:s("group.get_public",{gid:"group_ref"},{oinfo:"public_data"},{required:["group_ref"]}),getgroupsopeninfo:s("group.get_public_batch",{gids:"group_refs"},{info:"profiles"},{required:["group_refs"]}),enterroom:s("room.join",{rid:"room_ref"},null,{required:["room_ref"]}),leaveroom:s("room.leave",{rid:"room_ref"},null,{required:["room_ref"]}),enterrooms:s("room.join_batch",{rids:"room_refs"},null,{required:["room_refs"]}),getuserrooms:s("room.joined",null,{rooms:"room_refs"}),getroommembers:s("room.members",{rid:"room_ref"},{uids:"members"},{required:["room_ref"]}),getroomcount:s("room.counts",{rids:"room_refs"},{cn:"totals"},{required:["room_refs"]}),setroominfo:s("room.set_profile",{icon:"avatar",name:"label",oinfo:"public_data",pinfo:"private_data",rid:"room_ref"},null,{required:["room_ref"]}),getroominfo:s("room.get_profile",{rid:"room_ref"},{oinfo:"public_data",pinfo:"private_data"},{required:["room_ref"]}),getroomopeninfo:s("room.get_public",{rid:"room_ref"},{oinfo:"public_data"},{required:["room_ref"]}),getroomsopeninfo:s("room.get_public_batch",{rids:"room_refs"},{info:"profiles"},{required:["room_refs"]}),getuserroomsandlastmsg:s("room.last_messages",{mtypes:"kinds"},{rooms:"last_by_room"}),sendmsg:s("message.send",{attrs:"extra",mid:"message_ref",msg:"payload",mtype:"kind",to:"recipient"},{mid:"message_ref",mtime:"time_ms"},{pass:["checkParams","strategyid"],required:["recipient","message_ref","kind","payload","extra"]}),sendmsgs:s("message.send_batch",{attrs:"extra",mid:"message_ref",msg:"payload",mtype:"kind",tos:"recipients"},{mid:"message_ref",mtime:"time_ms"},{required:["recipients","message_ref","kind","payload","extra"]}),sendgroupmsg:s("message.send_group",{attrs:"extra",gid:"group_ref",mid:"message_ref",msg:"payload",mtype:"kind"},{mid:"message_ref",mtime:"time_ms"},{pass:["checkParams","strategyid"],required:["group_ref","message_ref","kind","payload","extra"]}),sendroommsg:s("message.send_room",{attrs:"extra",mid:"message_ref",msg:"payload",mtype:"kind",rid:"room_ref"},{mid:"message_ref",mtime:"time_ms"},{pass:["checkParams","strategyid"],required:["room_ref","message_ref","kind","payload","extra"]}),tcheck:s("moderation.check",{region:"zone",text:"payload"},{language:"detected_locale",result:"decision",text:"filtered",wlist:"matches"},{pass:["checkParams","strategyId"],required:["payload"]}),translate:s("translation.run",{dst:"to_locale",profanity:"filter_mode",src:"from_locale",text:"input",type:"format"},{dtext:"output",dst:"to_locale",source:"detected_locale",sourceText:"original",src:"from_locale",stext:"input",target:"resolved_locale",targetText:"translated"},{defaults:{filter_mode:"off",format:"chat"},required:["input","to_locale","format","filter_mode"]}),getp2pmsg:s("history.direct",Object.assign({ouid:"peer"},f),d,{defaults:a,required:["peer","reverse","limit","start_ms","end_ms","cursor"]}),getgroupmsg:s("history.group",Object.assign({gid:"group_ref"},f),d,{defaults:a,required:["group_ref","reverse","limit","start_ms","end_ms","cursor"]}),getroommsg:s("history.room",Object.assign({rid:"room_ref"},f),d,{defaults:a,required:["room_ref","reverse","limit","start_ms","end_ms","cursor"]}),getbroadcastmsg:s("history.broadcast",f,d,{defaults:a,required:["reverse","limit","start_ms","end_ms","cursor"]}),getp2pmsgbymessageid:s("history.direct_anchor",Object.assign({ouid:"peer"},l),d,{defaults:u,required:["peer","anchor","reverse","limit","start_ms","end_ms"]}),getgroupmsgbymessageid:s("history.group_anchor",Object.assign({gid:"group_ref"},l),d,{defaults:u,required:["group_ref","anchor","reverse","limit","start_ms","end_ms"]}),getroommsgbymessageid:s("history.room_anchor",Object.assign({rid:"room_ref"},l),d,{defaults:u,required:["room_ref","anchor","reverse","limit","start_ms","end_ms"]}),getbroadcastmsgbymessageid:s("history.broadcast_anchor",l,d,{defaults:u,required:["anchor","reverse","limit","start_ms","end_ms"]}),getp2pmsgcount:s("history.direct_count",Object.assign({ouid:"peer"},h),{count:"total"},{defaults:c,required:["peer","start_ms","end_ms"]}),getgroupmsgcount:s("history.group_count",Object.assign({gid:"group_ref"},h),{count:"total"},{defaults:c,required:["group_ref","start_ms","end_ms"]}),getroommsgcount:s("history.room_count",Object.assign({rid:"room_ref"},h),{count:"total"},{defaults:c,required:["room_ref","start_ms","end_ms"]}),getbroadcastmsgcount:s("history.broadcast_count",h,{count:"total"},{defaults:c,required:["start_ms","end_ms"]}),getmsg:s("message.get",{from:"sender",mid:"message_ref",type:"channel",xid:"target_ref"},{attrs:"extra",from:"sender",id:"sequence",mid:"message_ref",msg:"payload",mtime:"time_ms",mtype:"kind"},{required:["sender","message_ref","target_ref","channel"]}),delmsg:s("message.revoke",{from:"sender",mid:"message_ref",type:"channel",xid:"target_ref"},null,{required:["sender","message_ref","target_ref","channel"]}),getunread:s("unread.summary",{clear:"mark_read",gettime:"with_logout"},{group:"group_refs",logouttime:"logout_sec",p2p:"peers"},{defaults:{mark_read:!1},required:["mark_read"]}),getsession:s("session.list",null,{group:"group_refs",p2p:"peers"}),cleanunread:s("unread.clear"),setsessionread:s("session.read",{category:"channel",read_seq:"through",xid:"target_ref"},null,{required:["channel","target_ref","through"]}),getp2punread:s("unread.direct",{mtime:"since_ms",mtypes:"kinds",uids:"peers"},{ltime:"times",p2p:"counts"},{required:["peers"]}),getgroupunread:s("unread.group",{gids:"group_refs",mtime:"since_ms",mtypes:"kinds"},{group:"counts",ltime:"times"},{required:["group_refs"]}),removesession:s("session.remove",{oneway:"local_only",to:"peer"},null,{defaults:{local_only:!1},required:["peer","local_only"]}),getp2pconversationlist:s("conversation.direct",{mtime:"since_ms",mtypes:"kinds"},{conversations:"peers",msgs:"last_items",unreads:"badges"}),getp2punreadconversationlist:s("conversation.direct_unread",{mtime:"since_ms",mtypes:"kinds"},{conversations:"peers",msgs:"last_items",unreads:"badges"}),getgroupconversationlist:s("conversation.group",{mtime:"since_ms",mtypes:"kinds"},{conversations:"group_refs",msgs:"last_items",unreads:"badges"}),getgroupunreadconversationlist:s("conversation.group_unread",{mtime:"since_ms",mtypes:"kinds"},{conversations:"group_refs",msgs:"last_items",unreads:"badges"}),getunreadconversationlist:s("conversation.unread",{clear:"mark_read",mtime:"since_ms",mtypes:"kinds"},{groupConversations:"group_refs",groupMsgs:"group_last",groupUnreads:"group_badges",p2pConversations:"peers",p2pMsgs:"peer_last",p2pUnreads:"peer_badges"},{defaults:{mark_read:!1},required:["mark_read"]})},g=new Set(["acheck","adddevice","addfriends","addoption","addprojectban","adminCommand","broadcastfile","closeRTCRoom","delfriends","filetoken","getfriends","getoption","getRTCRoomList","getRTCRoomMemberCount","getRTCRoomMembers","icheck","inviteUserIntoRTCRoom","isfriend","isfriends","isprojectban","kickoutFromRTCRoom","profanity","pullIntoRTCRoom","removedevice","removeoption","removeprojectban","sendfile","sendfiles","sendgroupfile","sendroomfile","setRTCRoomMicStatus","speech2text","speechtranslation","uploadfile","vcheck"]),y={"event.broadcast":!0,"event.direct":!0,"event.group":!0,"event.room":!0},m={"event.kicked":!0,"event.room_removed":!0},_="9223372036854775807";function v(e,t,r){return Object.assign({required:!!t,type:e},r||{})}function b(e,t){return v("integer",e,Object.assign({min:"-9223372036854775808",max:_},t||{}))}function w(e,t){return v("integer",e,Object.assign({min:"-2147483648",max:"2147483647"},t||{}))}function E(e,t){return b(e,Object.assign({min:"1"},t||{}))}function k(e,t){return b(e,Object.assign({min:"0"},t||{}))}function R(e,t){return w(e,Object.assign({min:"0"},t||{}))}function P(e,t){return v("string",e,t)}function C(e){return v("boolean",e)}function O(e,t,r){return v("array",e,Object.assign({element:t},r||{}))}function T(e,t,r,n){return v("map",e,Object.assign({key:t,value:r},n||{}))}function A(e){return Object.assign({sent_ms:b(!1),trace:P(!1)},e||{})}function S(e,t){return{allowEmpty:!(!t||!t.allowEmpty),fields:e||{}}}var M=b(!1),I=w(!1),U=R(!1),B=b(!1),N=k(!1),x=E(!1),D=P(!1),L=v("string_or_bin",!1),F=v("tuple8",!1);function j(e,t){return O(e,x,t)}function q(e,t){return O(e,M,t)}function V(e,t){return O(e,I,t)}function Y(e){return T(e,"string",D)}function G(e){return T(e,"positive_decimal_int64",D)}function H(e){return T(e,"positive_decimal_int64",U)}function W(e){return T(e,"positive_decimal_int64",N)}function z(e){return b(e,{max:"255",min:"0"})}var K,J={extra:P(!0,{maxBytes:65535}),kind:(K=!0,b(K,{messageKind:!0})),message_ref:k(!0),payload:v("string_or_bin",!0,{maxBytes:65535})},$={cursor:b(!0),end_ms:k(!0),kinds:q(!1),limit:R(!0),reverse:C(!0),start_ms:k(!0)},Q={anchor:E(!0),end_ms:k(!0),kinds:q(!1),limit:R(!0),reverse:C(!0),start_ms:k(!0)},X={end_ms:k(!0),kinds:q(!1),start_ms:k(!0)},Z={"auth.login":A({auth_sec:k(!1),auth_ver:w(!1,{enum:["2"]}),client_ver:P(!0,{nonEmpty:!0}),credential:P(!0,{nonEmpty:!0}),locale:P(!1),project:b(!0,{max:"4294967295",min:"1"}),props:Y(!1),user:E(!0)}),"connection.close":A(),"system.time":A(),"connection.set_props":A({props:Y(!0)}),"connection.get_props":A(),"system.debug":A({context:P(!0),entry:P(!0,{nonEmpty:!0})}),"presence.online":A({users:j(!0,{minItems:1})}),"user.set_profile":A({private_data:P(!1),public_data:P(!1)}),"user.get_profile":A(),"user.get_public":A({users:j(!0,{minItems:1})}),"user.set_locale":A({locale:P(!0)}),"storage.get":A({slot:P(!0)}),"storage.set":A({slot:P(!0),value:P(!0)}),"storage.delete":A({slot:P(!0)}),"blacklist.add":A({blocked_users:j(!0,{minItems:1,uniqueInt64Max:100})}),"blacklist.remove":A({blocked_users:j(!0,{minItems:1,uniqueInt64Max:100})}),"blacklist.list":A(),"group.add":A({group_ref:E(!0),members:j(!0,{minItems:1})}),"group.remove":A({group_ref:E(!0),members:j(!0,{minItems:1})}),"group.members":A({group_ref:E(!0),with_online:C(!1)}),"group.count":A({group_ref:E(!0),with_online:C(!1)}),"group.joined":A(),"group.set_profile":A({group_ref:E(!0),private_data:P(!1),public_data:P(!1)}),"group.get_profile":A({group_ref:E(!0)}),"group.get_public":A({group_ref:E(!0)}),"group.get_public_batch":A({group_refs:j(!0,{minItems:1})}),"room.join":A({room_ref:E(!0)}),"room.leave":A({room_ref:E(!0)}),"room.join_batch":A({room_refs:j(!0,{maxItems:100,minItems:1})}),"room.joined":A(),"room.members":A({room_ref:E(!0)}),"room.counts":A({room_refs:j(!0,{minItems:1})}),"room.set_profile":A({avatar:P(!1),label:P(!1),private_data:P(!1),public_data:P(!1),room_ref:E(!0)}),"room.get_profile":A({room_ref:E(!0)}),"room.get_public":A({room_ref:E(!0)}),"room.get_public_batch":A({room_refs:j(!0,{minItems:1})}),"room.last_messages":A({kinds:q(!1)}),"message.send":A(Object.assign({recipient:E(!0)},J,{checkParams:P(!1),strategyid:P(!1)})),"message.send_batch":A(Object.assign({recipients:j(!0,{maxItems:100,minItems:1})},J)),"message.send_group":A(Object.assign({group_ref:E(!0)},J,{checkParams:P(!1),strategyid:P(!1)})),"message.send_room":A(Object.assign({room_ref:E(!0)},J,{checkParams:P(!1),strategyid:P(!1)})),"moderation.check":A({checkParams:P(!1),payload:P(!0,{nonEmpty:!0}),strategyId:P(!1),zone:P(!1)}),"translation.run":A({filter_mode:P(!0,{enum:["off","stop","censor"]}),format:P(!0,{nonEmpty:!0}),from_locale:P(!1),input:P(!0,{nonEmpty:!0}),to_locale:P(!0)}),"history.direct":A(Object.assign({peer:E(!0)},$)),"history.group":A(Object.assign({group_ref:E(!0)},$)),"history.room":A(Object.assign({room_ref:E(!0)},$)),"history.broadcast":A($),"history.direct_anchor":A(Object.assign({peer:E(!0)},Q)),"history.group_anchor":A(Object.assign({group_ref:E(!0)},Q)),"history.room_anchor":A(Object.assign({room_ref:E(!0)},Q)),"history.broadcast_anchor":A(Q),"history.direct_count":A(Object.assign({peer:E(!0)},X)),"history.group_count":A(Object.assign({group_ref:E(!0)},X)),"history.room_count":A(Object.assign({room_ref:E(!0)},X)),"history.broadcast_count":A(X),"message.get":A({channel:w(!0,{enum:["1","2","3","4"]}),message_ref:b(!0),sender:E(!0),target_ref:k(!0)}),"message.revoke":A({channel:w(!0,{enum:["1","2","3","4"]}),message_ref:b(!0),sender:E(!0),target_ref:k(!0)}),"unread.summary":A({mark_read:C(!0),with_logout:C(!1)}),"session.list":A(),"unread.clear":A(),"session.read":A({channel:w(!0,{enum:["1","2","3","4","5"]}),target_ref:k(!0),through:E(!0)}),"unread.direct":A({kinds:q(!1),peers:j(!0,{minItems:1}),since_ms:k(!1)}),"unread.group":A({group_refs:j(!0,{minItems:1}),kinds:q(!1),since_ms:k(!1)}),"session.remove":A({local_only:C(!0),peer:E(!0)}),"conversation.direct":A({kinds:q(!1),since_ms:k(!1)}),"conversation.direct_unread":A({kinds:q(!1),since_ms:k(!1)}),"conversation.group":A({kinds:q(!1),since_ms:k(!1)}),"conversation.group_unread":A({kinds:q(!1),since_ms:k(!1)}),"conversation.unread":A({kinds:q(!1),mark_read:C(!0),since_ms:k(!1)})},ee={first_ms:k(!0),items:O(!0,F),last_ms:k(!0),next:b(!0),size:R(!0)},te={message_ref:b(!0),time_ms:b(!0)},re={extra:P(!0),kind:z(!0),message_ref:b(!0),payload:v("string_or_bin",!0),sender:E(!0),sequence:b(!0),time_ms:b(!0)},ne={"auth.login":S({accepted:C(!0),telemetry_on:C(!1)}),"connection.close":S(),"system.time":S({server_ms:b(!0)}),"connection.set_props":S(),"connection.get_props":S({props:Y(!0)}),"system.debug":S(),"presence.online":S({online_users:j(!0)}),"user.set_profile":S(),"user.get_profile":S({private_data:P(!0),public_data:P(!0)}),"user.get_public":S({profiles:G(!0)}),"user.set_locale":S({updated:C(!0)}),"storage.get":S({value:P(!0)}),"storage.set":S(),"storage.delete":S(),"blacklist.add":S(),"blacklist.remove":S(),"blacklist.list":S({blocked_users:j(!0)}),"group.add":S(),"group.remove":S(),"group.members":S({active_members:j(!1),members:j(!0)}),"group.count":S({active_total:R(!1),total:R(!0)}),"group.joined":S({group_refs:j(!0)}),"group.set_profile":S(),"group.get_profile":S({private_data:P(!0),public_data:P(!0)}),"group.get_public":S({public_data:P(!0)}),"group.get_public_batch":S({profiles:G(!0)}),"room.join":S(),"room.leave":S(),"room.join_batch":S(),"room.joined":S({room_refs:j(!0)}),"room.members":S({members:j(!0)}),"room.counts":S({totals:H(!0)}),"room.set_profile":S(),"room.get_profile":S({private_data:P(!0),public_data:P(!0)}),"room.get_public":S({public_data:P(!0)}),"room.get_public_batch":S({profiles:G(!0)}),"room.last_messages":S({last_by_room:function(e){return T(e,"positive_decimal_int64",F)}(!0)}),"message.send":S(te),"message.send_batch":S(te),"message.send_group":S(te),"message.send_room":S(te),"moderation.check":S({decision:w(!0),detected_locale:P(!0),filtered:P(!0),matches:function(e,t){return O(e,D,t)}(!1)}),"translation.run":S({detected_locale:P(!0),from_locale:P(!0),input:P(!0),original:P(!0),output:P(!0),resolved_locale:P(!0),to_locale:P(!0),translated:P(!0)}),"history.direct":S(ee),"history.group":S(ee),"history.room":S(ee),"history.broadcast":S(ee),"history.direct_anchor":S(ee),"history.group_anchor":S(ee),"history.room_anchor":S(ee),"history.broadcast_anchor":S(ee),"history.direct_count":S({total:R(!0)}),"history.group_count":S({total:R(!0)}),"history.room_count":S({total:R(!0)}),"history.broadcast_count":S({total:R(!0)}),"message.get":S(re,{allowEmpty:!0}),"message.revoke":S(),"unread.summary":S({group_refs:j(!0),logout_sec:k(!1),peers:j(!0)}),"session.list":S({group_refs:j(!0),peers:j(!0)}),"unread.clear":S(),"session.read":S(),"unread.direct":S({counts:H(!0),times:W(!0)}),"unread.group":S({counts:H(!0),times:W(!0)}),"session.remove":S(),"conversation.direct":S({badges:V(!0),last_items:O(!0,F),peers:j(!0)}),"conversation.direct_unread":S({badges:V(!0),last_items:O(!0,F),peers:j(!0)}),"conversation.group":S({badges:V(!0),group_refs:j(!0),last_items:O(!0,F)}),"conversation.group_unread":S({badges:V(!0),group_refs:j(!0),last_items:O(!0,F)}),"conversation.unread":S({group_badges:V(!0),group_last:O(!0,F),group_refs:j(!0),peer_badges:V(!0),peer_last:O(!0,F),peers:j(!0)}),"control.ping":S({ts:b(!1)})},oe={from_locale:P(!0),original:P(!0),to_locale:P(!0),translated:P(!0)},ie={extra:P(!0,{maxBytes:65535}),kind:z(!0),message_ref:b(!0),payload:v("push_payload",!0),sender:E(!0),time_ms:b(!0)},se={"event.direct":Object.assign({recipient:E(!0)},ie),"event.group":Object.assign({group_ref:E(!0)},ie),"event.room":Object.assign({room_ref:E(!0)},ie),"event.broadcast":ie,"event.kicked":{},"event.room_removed":{room_ref:E(!0)}};function ae(e){return p[e]||null}function ue(e){var t=String(e);if(!/^-?[0-9]+$/.test(t))return null;var r="-"===t.charAt(0),n=(r?t.slice(1):t).replace(/^0+/,"")||"0";return r&&"0"!==n?"-"+n:n}function ce(e){return"number"==typeof e?function(e){if(Number.isSafeInteger)return Number.isSafeInteger(e);return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e&&Math.abs(e)<=9007199254740991}(e)?ue(e):null:"bigint"==typeof e||e instanceof o.Int64Value||e&&"object"===(void 0===e?"undefined":n(e))&&"number"==typeof e.offset&&e.buffer&&"function"==typeof e.toString?ue(e.toString()):null}function fe(e,t){var r=ue(e),n=ue(t);if(null===r||null===n)throw new Error("integer comparison requires decimal integers");if(r===n)return 0;var o="-"===r.charAt(0),i="-"===n.charAt(0);if(o!==i)return o?-1:1;var s=o?r.slice(1):r,a=i?n.slice(1):n,u=void 0;return u=s.length!==a.length?s.length<a.length?-1:1:s<a?-1:1,o?-u:u}function le(e){for(var t=0,r=0;r<e.length;r+=1){var n=e.charCodeAt(r);if(n>=55296&&n<=56319){var o=e.charCodeAt(r+1);if(o<56320||o>57343)throw new i(200034,"string contains an unpaired surrogate");t+=4,r+=1}else{if(n>=56320&&n<=57343)throw new i(200034,"string contains an unpaired surrogate");t+=n<=127?1:n<=2047?2:3}}return t}function he(e,t){throw new i(200034,e+" "+t)}function de(e,t,r){if(null==e&&he(r,"must not be nil"),"integer"!==t.type)if("boolean"!==t.type){if("string"===t.type)return"string"!=typeof e&&he(r,"must be a UTF-8 string"),t.nonEmpty&&0===e.length&&he(r,"must not be empty"),t.enum&&-1===t.enum.indexOf(e)&&he(r,"is not an allowed value"),void(void 0!==t.maxBytes&&le(e)>t.maxBytes&&he(r,"exceeds "+t.maxBytes+" UTF-8 bytes"));if("string_or_bin"===t.type){if("string"==typeof e)return void(void 0!==t.maxBytes&&le(e)>t.maxBytes&&he(r,"exceeds "+t.maxBytes+" UTF-8 bytes"));var n=o.getByteView(e);return n||he(r,"must be a string or MsgPack bin value"),void(void 0!==t.maxBytes&&n.byteLength>t.maxBytes&&he(r,"exceeds "+t.maxBytes+" bytes"))}if("array"!==t.type){if("map"===t.type)return o.isPlainMap(e)||he(r,"must be a map"),void Object.keys(e).forEach((function(n){!function(e,t,r){if("string"!==t)if("positive_decimal_int64"!==t)he(r,"uses an unsupported map-key contract");else{var n=ue(e);(null===n||"-"===n.charAt(0)||"0"===n||fe(n,_)>0)&&he(r,"must be a positive decimal int64 map key")}}(n,t.key,r+"."+n),de(e[n],t.value,r+"."+n)}));if("tuple8"!==t.type)if("push_payload"!==t.type)he(r,"uses an unsupported value contract");else{if("string"==typeof e||o.getByteView(e))return;pe("Chat payload",e,oe)}else!function(e,t){Array.isArray(e)&&8===e.length||he(t,"must be an 8-item message tuple"),de(e[0],B,t+"[0]"),de(e[1],B,t+"[1]"),de(e[2],M,t+"[2]"),de(e[3],B,t+"[3]"),de(e[4],v("boolean",!1),t+"[4]"),de(e[5],L,t+"[5]"),de(e[6],D,t+"[6]"),de(e[7],B,t+"[7]")}(e,r)}else if(Array.isArray(e)||he(r,"must be an array"),void 0!==t.minItems&&e.length<t.minItems&&he(r,"must not be empty"),void 0!==t.maxItems&&e.length>t.maxItems&&he(r,"contains too many items"),e.forEach((function(e,n){de(e,t.element,r+"["+n+"]")})),void 0!==t.uniqueInt64Max){var i={};e.forEach((function(e){i[ce(e)]=!0})),Object.keys(i).length>t.uniqueInt64Max&&he(r,"contains too many distinct int64 items")}}else"boolean"!=typeof e&&he(r,"must be boolean");else!function(e,t,r){var n=ce(e);(null===n||fe(n,"-9223372036854775808")<0||fe(n,_)>0)&&he(r,"must be a signed int64 integer"),void 0!==t.min&&fe(n,t.min)<0&&he(r,"is below the allowed range"),void 0!==t.max&&fe(n,t.max)>0&&he(r,"is above the allowed range"),t.enum&&-1===t.enum.indexOf(n)&&he(r,"is not an allowed value"),t.messageKind&&!(fe(n,"1")>=0&&fe(n,"39")<=0||fe(n,"51")>=0&&fe(n,"127")<=0)&&he(r,"must be in kind ranges [1,39] or [51,127]")}(e,t,r)}function pe(e,t,r){o.isPlainMap(t)||he(e,"body must be a map"),Object.keys(t).forEach((function(t){Object.prototype.hasOwnProperty.call(r,t)||he(e+"."+t,"is not defined by this contract")})),Object.keys(r).forEach((function(n){var o=r[n];Object.prototype.hasOwnProperty.call(t,n)?de(t[n],o,e+"."+n):o.required&&he(e+"."+n,"is required")}))}function ge(e,t,r){for(var n=t[r[0]].length,o=1;o<r.length;o+=1)t[r[o]].length!==n&&he(e+" Answer",r.join(", ")+" must have matching lengths")}function ye(e){return g.has(e)||"string"==typeof e&&0===e.indexOf("imclient_")}e.exports={RELIABLE_PUSHES:y,REQUEST_SCHEMAS:Z,RESPONSE_SCHEMAS:ne,RESERVED_WIRES:g,ROUTES:p,TLVContractError:i,getRoute:ae,getRouteByUri:function(e){for(var t=Object.keys(p),r=0;r<t.length;r+=1){var n=p[t[r]];if(n.uri===e)return{method:t[r],route:n}}return null},isOneWayPush:function(e){return Object.prototype.hasOwnProperty.call(m,e)},isReliablePush:function(e){return Object.prototype.hasOwnProperty.call(y,e)},isReservedWire:ye,toWireRequest:function(e,t,r,n){var s=ae(e);if(!s){if(ye(e))throw new i(200020,e+" is reserved and unavailable on the TLV Client port");throw new i(20004,"unknown or unsupported TLV Client wire: "+e)}if(!o.isPlainMap(t))throw new i(200034,e+" request body must be a map");var a={};return Object.keys(t).forEach((function(e){var r=void 0;if("trace_id"!==e&&"send_ts"!==e){if("trace"===e||"sent_ms"===e)r=e;else if(Object.prototype.hasOwnProperty.call(s.request,e))r=s.request[e];else{if(-1===s.pass.indexOf(e))throw new i(200034,s.uri+" does not accept field "+e);r=e}if(Object.prototype.hasOwnProperty.call(a,r))throw new i(200034,s.uri+" received duplicate field mapping for "+r);n&&n.omitLegacyNil&&(void 0===t[e]||null===t[e])&&function(e,t){if("trace"===t||"sent_ms"===t)return!0;if(Object.prototype.hasOwnProperty.call(e.defaults,t))return!0;var r=Z[e.uri];return!(!r||!r[t]||r[t].required)}(s,r)||(a[r]=t[e])}})),Object.keys(s.defaults).forEach((function(e){Object.prototype.hasOwnProperty.call(a,e)||(a[e]=s.defaults[e])})),function(e,t,r){if(!t)return;var n="function"==typeof t?t():t;if(!n)return;if(!o.isPlainMap(n))throw new i(200034,r+" request metadata must be a map");["trace","sent_ms"].forEach((function(t){if(void 0!==n[t]){if(Object.prototype.hasOwnProperty.call(e,t)&&e[t]!==n[t])throw new i(200034,r+" has conflicting "+t+" values");e[t]=n[t]}}))}(a,r,s.uri),function(e,t){var r=Z[e.uri];if(!r)throw new i(200034,"missing request schema for "+e.uri);if(pe(e.uri+" request",t,r),"auth.login"===e.uri){var n=Object.prototype.hasOwnProperty.call(t,"auth_sec"),o=Object.prototype.hasOwnProperty.call(t,"auth_ver");if(n!==o)throw new i(200034,"auth.login requires auth_sec and auth_ver together");if(o&&"2"!==ce(t.auth_ver))throw new i(200034,"auth.login auth_ver must be 2")}}(s,a),{payload:a,uri:s.uri}},validateControlError:function(e){pe("control.error Answer",e,{reason:P(!0),status:w(!0)})},validatePush:function(e,t){var r=se[e];if(!r)throw new i(200034,"unsupported Push URI: "+e);pe(e+" Push",t,r)},validateResponse:function(e,t){var r=ne[e];if(!r)throw new i(200034,"unsupported Answer URI: "+e);r.allowEmpty&&o.isPlainMap(t)&&0===Object.keys(t).length||(pe(e+" Answer",t,r.fields),function(e,t){var r=void 0;if("conversation.direct"===e||"conversation.direct_unread"===e)r=["peers","badges","last_items"];else if("conversation.group"===e||"conversation.group_unread"===e)r=["group_refs","badges","last_items"];else if("conversation.unread"===e)return ge(e,t,["group_refs","group_badges","group_last"]),void ge(e,t,["peers","peer_badges","peer_last"]);r&&ge(e,t,r)}(e,t))}}},function(e,t,r){"use strict";var n=r(7),o=n.isValidFpnnEndpoint,i=n.normalizeFpnnEndpoint,s=r(5).normalizeTlvEndpoint;e.exports={normalizeClientOptions:function(e){var t=Object.assign({},e||{});if(void 0===t.protocol&&(t.protocol="fpnn"),"fpnn"!==t.protocol&&"tlv-v1"!==t.protocol)throw new Error('options.protocol must be "fpnn" or "tlv-v1"');if("fpnn"===t.protocol){var r=void 0!==t.ssl_endpoint,n=r?t.ssl_endpoint:i(t.endpoint);if(!o(n))throw new Error("FPNN requires options.endpoint or options.ssl_endpoint as host[:port], without a URL scheme or path");r||(t.endpoint=n)}else{var a=t.tlvEndpoint||t.tlv_endpoint;if(!a&&"string"==typeof t.endpoint&&/^wss?:\/\//i.test(t.endpoint)&&(a=t.endpoint),!a&&"string"==typeof t.ssl_endpoint&&/^wss?:\/\//i.test(t.ssl_endpoint)&&(a=t.ssl_endpoint),"string"!=typeof a||!/^wss?:\/\//i.test(a))throw new Error("tlv-v1 requires options.tlvEndpoint as the deployment-provided ws:// or wss:// URL");t.tlvEndpoint=s(a),delete t.tlv_endpoint,delete t.endpoint,delete t.ssl_endpoint}return t}}},function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var s=r(2),a=r(0),u=r(6),c=r(1),f=c.Int64BE,l=c.Uint64BE,h=r(15),d=h.normalizeClientOptions,p=h.sharedEndpoint,g=r(16).getSharedWorkerConfigFallbackReason,y=r(17),m=r(18),_=r(5).normalizeTlvEndpoint,v="__rtmSharedWorkerType__",b=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}(),w=function(){function e(t){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);var n=t||{};if("undefined"==typeof SharedWorker)throw new Error("RTMSharedWorkerClient requires browser SharedWorker support");var o=function(e){if(null!=e&&""!==e){if("string"!=typeof e)throw new Error("RTMSharedWorkerClient workerUrl must be a string");return e}if(!b)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",b)}catch(e){throw new Error("RTMSharedWorkerClient could not resolve rtm.shared-worker.js beside the SDK script; provide workerUrl")}if("undefined"!=typeof window&&window.location&&t.origin!==window.location.origin)throw new Error("RTMSharedWorkerClient default worker URL is cross-origin; serve rtm.shared-worker.js from this page origin or provide a same-origin workerUrl");return t.href}(n.workerUrl),i=d(n.clientOptions);this._protocol=i.protocol;var a=g(i);if(a)throw new Error("RTMSharedWorkerClient cannot use "+a.replace(/^options/,"clientOptions")+"; use createClient() to run this configuration on the current page");var c,f=y(n.conversation),l=n.workerName||(void 0!==n.uid&&null!==n.uid?E({pid:i.pid,uid:n.uid,protocol:i.protocol,endpoint:p(i),namespace:n.workerNamespace}):"fpnn"===i.protocol?"rtm-shared-worker:fpnn":"rtm-shared-worker"),h=void 0===n.idleShutdownTimeout?5e3:n.idleShutdownTimeout;if(!("number"==typeof(c=h)&&isFinite(c)&&c>=0))throw new Error("RTMSharedWorkerClient idleShutdownTimeout must be a non-negative number");if(this._listeners=Object.create(null),this._processorListeners=Object.create(null),this._callbackSeq=0,this._callbacks=new Map,this._destroyed=!1,this._destroying=!1,this._failedError=null,this._conversation=f,this.promises=u(this,s.prototype),this._pageWindow="undefined"!=typeof window&&window.addEventListener?window:null,this._pageHideListener=function(e){e&&e.persisted||r.destroy()},this._session={status:"idle",uid:null},this._readySettled=!1,this._readyPromise=new Promise((function(e,t){r._resolveReady=e,r._rejectReady=t})),this._readyPromise.catch((function(){})),this._worker=new SharedWorker(o,l),this._worker.onerror=this._onWorkerError.bind(this),this._port=this._worker.port,this._pageWindow&&this._pageWindow.addEventListener("pagehide",this._pageHideListener),this._port.onmessage=this._onMessage.bind(this),this._port.onmessageerror=this._onMessageError.bind(this),"function"==typeof this._port.start&&this._port.start(),this._post({type:"init",options:i,idleShutdownTimeout:h})){var m=function(e){return"number"==typeof e&&isFinite(e)&&e>0}(n.readyTimeout)?n.readyTimeout:1e4;this._readyTimer=setTimeout((function(){var e=O("Timed out waiting for the RTM SharedWorker to initialize","RTM_SHARED_WORKER_READY_TIMEOUT");r._failedError=e;var t=r._failPendingCallbacks(e);r._settleReady(e);try{r._emit(r._listeners,"SharedWorkerError",[e])}finally{r.destroy()}if(t)throw t.error}),m)}else this._settleReady(new Error("Failed to initialize the RTM SharedWorker client")),this.destroy();var _=this;this.processor={on:function(e,t){return _._addListener(_._processorListeners,e,t),this},off:function(e,t){return _._removeListener(_._processorListeners,e,t),this},removeEvent:function(e,t){return 0===arguments.length?_._processorListeners=Object.create(null):_._removeListener(_._processorListeners,e,t),this},emit:function(e){_._emit(_._processorListeners,e,Array.prototype.slice.call(arguments,1))},listenerCount:function(e){return(_._processorListeners[e]||[]).length}}}return o(e,[{key:"on",value:function(e,t){return this._addListener(this._listeners,e,t),this}},{key:"off",value:function(e,t){return this._removeListener(this._listeners,e,t),this}},{key:"emit",value:function(e){this._emit(this._listeners,e,Array.prototype.slice.call(arguments,1))}},{key:"listenerCount",value:function(e){return(this._listeners[e]||[]).length}},{key:"removeEvent",value:function(e,t){return 0===arguments.length?this._listeners=Object.create(null):this._removeListener(this._listeners,e,t),this}},{key:"whenReady",value:function(){return this._readyPromise.then(R)}},{key:"getSharedSession",value:function(){return R(this._session)}},{key:"loginIfNeeded",value:function(e,t,r){var n=this;return this.whenReady().then((function(){if(n._destroyed||n._destroying)throw new Error("RTMSharedWorkerClient has been destroyed");return new Promise((function(o,i){var s=++n._callbackSeq,a=function(e){e instanceof Error?i(e):o(e)};a.rejectOnDestroy=!0,n._callbacks.set(s,a);var u=P(e,n._callbacks,n);n._post({type:"login-if-needed",uid:u,credential:t,timeout:r,requestId:s})||(n._callbacks.delete(s),i(new Error("Failed to request shared RTM login")))}))}))}},{key:"setConversation",value:function(e,t){var r=y(e);if(this._destroyed||this._destroying){var n=new Error("RTMSharedWorkerClient has been destroyed");return"function"==typeof t&&t(n),this._emit(this._listeners,"SharedWorkerError",[n]),this}return this._conversation=r,"function"==typeof t&&t(null),this}},{key:"destroy",value:function(){if(!this._destroyed&&!this._destroying){this._destroying=!0;var e=null,t=null;try{this._settleReady(new Error("RTMSharedWorkerClient was destroyed before it became ready"));var r=new Error("RTMSharedWorkerClient was destroyed before the shared login completed");e=this._failPendingCallbacks(r)}finally{try{this._post({type:"detach"},!0)}catch(e){t=e}if(this._destroyed=!0,this._destroying=!1,this._callbacks.clear(),this._listeners=Object.create(null),this._processorListeners=Object.create(null),this._pageWindow&&this._pageHideListener)try{this._pageWindow.removeEventListener("pagehide",this._pageHideListener)}catch(e){t=t||e}this._pageWindow=null,this._pageHideListener=null,this._worker.onerror=null,this._port.onmessage=null,this._port.onmessageerror=null;try{this._port.close()}catch(e){t=t||e}}if(t)throw t;if(e)throw e.error}}},{key:"_addListener",value:function(e,t,r){"function"==typeof r&&(e[t]||(e[t]=[]),-1===e[t].indexOf(r)&&e[t].push(r))}},{key:"_removeListener",value:function(e,t,r){e[t]&&(void 0!==r?(e[t]=e[t].filter((function(e){return e!==r})),0===e[t].length&&delete e[t]):delete e[t])}},{key:"_emit",value:function(e,t,r){(e[t]||[]).slice().forEach((function(e){e.apply(null,r)}))}},{key:"_onMessage",value:function(e){var t=e&&e.data;if(t&&!this._destroyed)if("callback"!==t.type)if("event"!==t.type)if("login-result"!==t.type)if("error"!==t.type){if("ready"===t.type){var r=k(t.session);return this._session=r,this._settleReady(null,r),void this._emit(this._listeners,"SharedWorkerReady",[r])}"session-state"===t.type&&(this._session=k(t.session),this._emit(this._listeners,"SharedSessionState",[R(this._session)]))}else{var n=T(t.error,a),o=null;if(void 0!==t.requestId){var i=this._callbacks.get(t.requestId);i&&(this._callbacks.delete(t.requestId),i(n))}else this._failedError=n,o=this._failPendingCallbacks(n);try{this._settleReady(n),this._emit(this._listeners,"SharedWorkerError",[n])}finally{!0===t.fatal&&this.destroy()}if(o)throw o.error}else{var s=this._callbacks.get(t.requestId);s&&(this._callbacks.delete(t.requestId),s(t.error?T(t.error,a):t.result))}else{var u=T(t.args,a);if("processor"===t.channel&&!m(this._conversation,this._protocol,t.name,u[0]))return;this._emit("processor"===t.channel?this._processorListeners:this._listeners,t.name,u)}else{var c=this._callbacks.get(t.callbackId);c&&(this._callbacks.delete(t.callbackId),c.apply(null,T(t.args,a)))}}},{key:"_onMessageError",value:function(e){var t=new Error("Failed to read a SharedWorker message");t.code="RTM_SHARED_WORKER_MESSAGE_ERROR",t.event=e,this._failedError=t;var r=this._failPendingCallbacks(t);this._settleReady(t);try{this._emit(this._listeners,"SharedWorkerError",[t])}finally{this.destroy()}if(r)throw r.error}},{key:"_onWorkerError",value:function(e){var t=new Error(e&&e.message?"RTM SharedWorker failed to load: "+e.message:"RTM SharedWorker failed to load");t.code="RTM_SHARED_WORKER_LOAD_ERROR",e&&e.filename&&(t.filename=e.filename),e&&e.lineno&&(t.lineno=e.lineno),this._failedError=t;var r=this._failPendingCallbacks(t);this._settleReady(t);try{this._emit(this._listeners,"SharedWorkerError",[t])}finally{this.destroy()}if(r)throw r.error}},{key:"_failPendingCallbacks",value:function(e){var t=this,r=null;return this._callbacks.forEach((function(n,o){if("function"==typeof n.fail||n.rejectOnDestroy){t._callbacks.delete(o);try{"function"==typeof n.fail?n.fail(e):n(e)}catch(e){r||(r={error:e})}}})),r}},{key:"_invoke",value:function(e,t){if(this._destroyed||this._destroying){var r=O("RTMSharedWorkerClient has been destroyed","RTM_SHARED_CLIENT_DESTROYED");return C(e,t,r),void this._emit(this._listeners,"SharedWorkerError",[r])}if(this._failedError)C(e,t,this._failedError);else{var n=this._callbackSeq;this._post({type:"invoke",method:e,args:P(t,this._callbacks,this,e)})||this._failCallbacksSince(n,this._failedError||O("Failed to send request to RTM SharedWorker","RTM_SHARED_WORKER_POST_MESSAGE_ERROR"))}}},{key:"_failCallbacksSince",value:function(e,t){var r=this;this._callbacks.forEach((function(n,o){o<=e||(r._callbacks.delete(o),"function"==typeof n.fail&&n.fail(t))}))}},{key:"_post",value:function(e,t){var r=t&&e&&"detach"===e.type;if((this._destroyed||this._destroying)&&!r)return!1;if(this._failedError&&!r)return!1;try{return this._port.postMessage(e),!0}catch(e){return this._emit(this._listeners,"SharedWorkerError",[e]),!1}}},{key:"_settleReady",value:function(e,t){this._readySettled||(this._readySettled=!0,void 0!==this._readyTimer&&(clearTimeout(this._readyTimer),this._readyTimer=void 0),e?this._rejectReady(e):this._resolveReady(R(t)))}}]),e}();function E(e){if(!e||"object"!==(void 0===e?"undefined":n(e)))throw new Error("createSharedWorkerName requires { pid, uid }");var t=void 0===e.pid||null===e.pid?"":String(e.pid).trim(),r=void 0===e.uid||null===e.uid?"":String(e.uid).trim();if(!t||!r)throw new Error("createSharedWorkerName requires non-empty pid and uid");var o=void 0===e.protocol?"fpnn":e.protocol;if("tlv-v1"!==o&&"fpnn"!==o)throw new Error('createSharedWorkerName protocol must be "tlv-v1" or "fpnn"');var i=String(void 0===e.endpoint||null===e.endpoint?"":e.endpoint);"tlv-v1"===o&&/^wss?:\/\//i.test(i)&&(i=_(i));var s=[String(void 0===e.namespace||null===e.namespace?"":e.namespace),t,r,i];return"fpnn"===o&&s.unshift(o),"rtm-shared:"+s.map((function(e){var t=encodeURIComponent(e);return t.length+":"+t})).join("|")}function k(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 R(e){return{status:e.status,uid:e.uid}}function P(e,t,r,o){if("function"==typeof e){var s=++r._callbackSeq,u=function(){return e.apply(null,arguments)};return u.fail=function(t){"login"===o?e(!1,t.status||a.ERROR_CODE.RTM_EC_UNKNOWN_ERROR):e(t,null)},t.set(s,u),i({},"__rtmSharedWorkerCallback__",s)}if(e&&"object"===(void 0===e?"undefined":n(e))){var c,h;if(f.isInt64BE(e))return i(c={},v,"int64"),i(c,"value",e.toString()),c;if(l.isUint64BE(e))return i(h={},v,"uint64"),i(h,"value",e.toString()),h;if(Array.isArray(e))return e.map((function(e){return P(e,t,r,o)}));if(A(e)){var d={};return Object.keys(e).forEach((function(n){d[n]=P(e[n],t,r,o)})),d}}return e}function C(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 O(e,t){var r=new Error(e);return r.code=t,r}function T(e,t){if(Array.isArray(e))return e.map((function(e){return T(e,t)}));if(!A(e))return e;if("int64"===e[v])return t.Int64(e.value);if("uint64"===e[v])return t.Uint64(e.value);if("error"===e[v]){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]=T(e[r],t)})),n}function A(e){if(null===e||"object"!==(void 0===e?"undefined":n(e)))return!1;var t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}w.createWorkerName=E,Object.getOwnPropertyNames(s.prototype).forEach((function(e){"constructor"===e||"destroy"===e||"_"===e.charAt(0)||Object.prototype.hasOwnProperty.call(w.prototype,e)||"function"==typeof Object.getOwnPropertyDescriptor(s.prototype,e).value&&Object.defineProperty(w.prototype,e,{configurable:!0,enumerable:!1,writable:!0,value:function(){return this._invoke(e,Array.prototype.slice.call(arguments))}})})),e.exports=w},function(e,t,r){"use strict";var n=r(13).normalizeClientOptions,o=r(7).normalizeFpnnEndpoint;e.exports={normalizeClientOptions:n,sharedEndpoint:function(e){return"tlv-v1"===e.protocol?e.tlvEndpoint||e.tlv_endpoint||e.endpoint||e.ssl_endpoint:void 0!==e.ssl_endpoint?"wss://"+e.ssl_endpoint+"/service/websocket":"ws://"+o(e.endpoint)+"/service/websocket"}}},function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};e.exports={getSharedWorkerConfigFallbackReason:function(e){var t=new Set;return function e(r,o){if("function"==typeof r)return o+" is a function; SharedWorker cannot preserve page-side function behavior";if("symbol"===(void 0===r?"undefined":n(r)))return o+" is a symbol and cannot be transferred to SharedWorker";if("bigint"==typeof r)return o+" is a bigint that cannot be compared safely between shared pages";if("number"==typeof r&&!isFinite(r))return o+" is not a finite number and cannot be compared safely between shared pages";if(null==r||"object"!==(void 0===r?"undefined":n(r)))return null;if(t.has(r))return o+" contains a circular reference that cannot be compared safely between shared pages";var i=void 0,s=void 0;try{i=Array.isArray(r),s=Object.getPrototypeOf(r)}catch(e){return o+" cannot be inspected for SharedWorker transfer"}if(i?s!==Array.prototype:s!==Object.prototype&&null!==s)return o+" uses a custom object prototype; SharedWorker cannot preserve its behavior";var a=void 0;try{a=Object.getOwnPropertySymbols(r)}catch(e){return o+" cannot be inspected for SharedWorker transfer"}if(a.length)return o+" contains symbol-keyed data that cannot be transferred reliably";t.add(r);var u=void 0;try{u=Object.keys(r)}catch(e){return t.delete(r),o+" cannot be inspected for SharedWorker transfer"}for(var c=0;c<u.length;c+=1){var f=u[c],l=void 0;try{l=Object.getOwnPropertyDescriptor(r,f)}catch(e){return t.delete(r),o+"."+f+" cannot be inspected for SharedWorker transfer"}if(!l||l.get||l.set)return t.delete(r),o+"."+f+" uses an accessor that cannot be preserved in SharedWorker";var h=i?o+"["+f+"]":o+"."+f,d=void 0;try{d=r[f]}catch(e){return t.delete(r),h+" cannot be inspected for SharedWorker transfer"}var p=e(d,h);if(p)return t.delete(r),p}return t.delete(r),null}(e,"options")}}},function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=r(1),i=o.Int64BE,s=o.Uint64BE;e.exports=function(e){if(null==e)return null;if(!function(e){if(null===e||"object"!==(void 0===e?"undefined":n(e)))return!1;var t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(e)||-1===["direct","group","room"].indexOf(e.type))throw new Error('conversation.type must be "direct", "group", or "room"');var t=e.id,r=void 0;if("string"==typeof t)r=t;else if("number"==typeof t&&function(e){if(Number.isSafeInteger)return Number.isSafeInteger(e);return isFinite(e)&&Math.floor(e)===e&&Math.abs(e)<=9007199254740991}(t))r=String(t);else{if(!("bigint"==typeof t||t&&(i.isInt64BE(t)||s.isUint64BE(t))))throw new Error("conversation.id must be a positive int64 string, safe integer, or RTMConfig.Int64");r=t.toString()}if(!/^\d+$/.test(r)||/^0+$/.test(r))throw new Error("conversation.id must be a positive int64");if((r=r.replace(/^0+(?=\d)/,"")).length>19||19===r.length&&r>"9223372036854775807")throw new Error("conversation.id exceeds the positive int64 range");return{type:e.type,id:r}}},function(e,t,r){"use strict";var n=r(0),o={"tlv-v1":{},fpnn:{}};function i(e,t,r,n){t.forEach((function(t){o[e][t]={type:r,field:n}}))}var s=n.TLV_SERVER_PUSH;i("tlv-v1",[s.recvMessage],"direct","sender"),i("tlv-v1",[s.recvGroupMessage],"group","group_ref"),i("tlv-v1",[s.recvRoomMessage,s.kickOutRoom],"room","room_ref");var a=n.SERVER_PUSH;i("fpnn",[a.recvMessage,a.recvChat,a.recvAudio,a.recvCmd,a.recvFile],"direct","from"),i("fpnn",[a.recvGroupMessage,a.recvGroupChat,a.recvGroupAudio,a.recvGroupCmd,a.recvGroupFile],"group","gid"),i("fpnn",[a.recvRoomMessage,a.recvRoomChat,a.recvRoomAudio,a.recvRoomCmd,a.recvRoomFile,a.kickOutRoom],"room","rid"),e.exports=function(e,t,r,n){if(!e)return!0;var i=o[t],s=i&&Object.prototype.hasOwnProperty.call(i,r)?i[r]:null;if(!s)return!0;var a=n&&n[s.field];return e.type===s.type&&String(a)===e.id}},function(e,t,r){"use strict";var n=r(2),o=r(14),i=r(29),s=o.createWorkerName,a=r(0),u=r(9),c=r(11),f=r(10);e.exports={RTMClient:n,createClient:i,RTMSharedWorkerClient:o,createSharedWorkerName:s,RTMConfig:a,RTMProcessor:u,TLVCodec:c,TLVWebSocketClient:f}},function(e,t,r){"use strict";t.byteLength=function(e){var t=c(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){var t,r,n=c(e),s=n[0],a=n[1],u=new i(function(e,t,r){return 3*(t+r)/4-r}(0,s,a)),f=0,l=a>0?s-4:s;for(r=0;r<l;r+=4)t=o[e.charCodeAt(r)]<<18|o[e.charCodeAt(r+1)]<<12|o[e.charCodeAt(r+2)]<<6|o[e.charCodeAt(r+3)],u[f++]=t>>16&255,u[f++]=t>>8&255,u[f++]=255&t;2===a&&(t=o[e.charCodeAt(r)]<<2|o[e.charCodeAt(r+1)]>>4,u[f++]=255&t);1===a&&(t=o[e.charCodeAt(r)]<<10|o[e.charCodeAt(r+1)]<<4|o[e.charCodeAt(r+2)]>>2,u[f++]=t>>8&255,u[f++]=255&t);return u},t.fromByteArray=function(e){for(var t,r=e.length,o=r%3,i=[],s=0,a=r-o;s<a;s+=16383)i.push(f(e,s,s+16383>a?a:s+16383));1===o?(t=e[r-1],i.push(n[t>>2]+n[t<<4&63]+"==")):2===o&&(t=(e[r-2]<<8)+e[r-1],i.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a<u;++a)n[a]=s[a],o[s.charCodeAt(a)]=a;function c(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function f(e,t,r){for(var o,i,s=[],a=t;a<r;a+=3)o=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),s.push(n[(i=o)>>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return s.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},function(e,t){
8
+ var n=r(20),o=r(21),i=r(22);function s(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,t){if(s()<t)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=u.prototype:(null===e&&(e=new u(t)),e.length=t),e}function u(e,t,r){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(e,t,r);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return l(this,e)}return c(this,e,t,r)}function c(e,t,r,n){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,r,n){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");t=void 0===r&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,r):new Uint8Array(t,r,n);u.TYPED_ARRAY_SUPPORT?(e=t).__proto__=u.prototype:e=h(e,t);return e}(e,t,r,n):"string"==typeof t?function(e,t,r){"string"==typeof r&&""!==r||(r="utf8");if(!u.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|p(t,r),o=(e=a(e,n)).write(t,r);o!==n&&(e=e.slice(0,o));return e}(e,t,r):function(e,t){if(u.isBuffer(t)){var r=0|d(t.length);return 0===(e=a(e,r)).length||t.copy(e,0,0,r),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(n=t.length)!=n?a(e,0):h(e,t);if("Buffer"===t.type&&i(t.data))return h(e,t.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function f(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function l(e,t){if(f(t),e=a(e,t<0?0:0|d(t)),!u.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function h(e,t){var r=t.length<0?0:0|d(t.length);e=a(e,r);for(var n=0;n<r;n+=1)e[n]=255&t[n];return e}function d(e){if(e>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|e}function p(e,t){if(u.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return j(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return q(e).length;default:if(n)return j(e).length;t=(""+t).toLowerCase(),n=!0}}function g(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return A(this,t,r);case"utf8":case"utf-8":return C(this,t,r);case"ascii":return O(this,t,r);case"latin1":case"binary":return T(this,t,r);case"base64":return P(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function y(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function m(e,t,r,n,o){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=o?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(o)return-1;r=e.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof t&&(t=u.from(t,n)),u.isBuffer(t))return 0===t.length?-1:_(e,t,r,n,o);if("number"==typeof t)return t&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):_(e,[t],r,n,o);throw new TypeError("val must be string, number or Buffer")}function _(e,t,r,n,o){var i,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function c(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(o){var f=-1;for(i=r;i<a;i++)if(c(e,i)===c(t,-1===f?0:i-f)){if(-1===f&&(f=i),i-f+1===u)return f*s}else-1!==f&&(i-=i-f),f=-1}else for(r+u>a&&(r=a-u),i=r;i>=0;i--){for(var l=!0,h=0;h<u;h++)if(c(e,i+h)!==c(t,h)){l=!1;break}if(l)return i}return-1}function v(e,t,r,n){r=Number(r)||0;var o=e.length-r;n?(n=Number(n))>o&&(n=o):n=o;var i=t.length;if(i%2!=0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var s=0;s<n;++s){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))return s;e[r+s]=a}return s}function b(e,t,r,n){return V(j(t,e.length-r),e,r,n)}function w(e,t,r,n){return V(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function E(e,t,r,n){return w(e,t,r,n)}function k(e,t,r,n){return V(q(t),e,r,n)}function R(e,t,r,n){return V(function(e,t){for(var r,n,o,i=[],s=0;s<e.length&&!((t-=2)<0);++s)r=e.charCodeAt(s),n=r>>8,o=r%256,i.push(o),i.push(n);return i}(t,e.length-r),e,r,n)}function P(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function C(e,t,r){r=Math.min(e.length,r);for(var n=[],o=t;o<r;){var i,s,a,u,c=e[o],f=null,l=c>239?4:c>223?3:c>191?2:1;if(o+l<=r)switch(l){case 1:c<128&&(f=c);break;case 2:128==(192&(i=e[o+1]))&&(u=(31&c)<<6|63&i)>127&&(f=u);break;case 3:i=e[o+1],s=e[o+2],128==(192&i)&&128==(192&s)&&(u=(15&c)<<12|(63&i)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:i=e[o+1],s=e[o+2],a=e[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),o+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=4096));return r}(n)}t.Buffer=u,t.SlowBuffer=function(e){+e!=e&&(e=0);return u.alloc(+e)},t.INSPECT_MAX_BYTES=50,u.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),t.kMaxLength=s(),u.poolSize=8192,u._augment=function(e){return e.__proto__=u.prototype,e},u.from=function(e,t,r){return c(null,e,t,r)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0})),u.alloc=function(e,t,r){return function(e,t,r,n){return f(t),t<=0?a(e,t):void 0!==r?"string"==typeof n?a(e,t).fill(r,n):a(e,t).fill(r):a(e,t)}(null,e,t,r)},u.allocUnsafe=function(e){return l(null,e)},u.allocUnsafeSlow=function(e){return l(null,e)},u.isBuffer=function(e){return!(null==e||!e._isBuffer)},u.compare=function(e,t){if(!u.isBuffer(e)||!u.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,o=0,i=Math.min(r,n);o<i;++o)if(e[o]!==t[o]){r=e[o],n=t[o];break}return r<n?-1:n<r?1:0},u.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(e,t){if(!i(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return u.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=u.allocUnsafe(t),o=0;for(r=0;r<e.length;++r){var s=e[r];if(!u.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(n,o),o+=s.length}return n},u.byteLength=p,u.prototype._isBuffer=!0,u.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)y(this,t,t+1);return this},u.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)y(this,t,t+3),y(this,t+1,t+2);return this},u.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)y(this,t,t+7),y(this,t+1,t+6),y(this,t+2,t+5),y(this,t+3,t+4);return this},u.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?C(this,0,e):g.apply(this,arguments)},u.prototype.equals=function(e){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===u.compare(this,e)},u.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),"<Buffer "+e+">"},u.prototype.compare=function(e,t,r,n,o){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),t<0||r>e.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&t>=r)return 0;if(n>=o)return-1;if(t>=r)return 1;if(this===e)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(i,s),c=this.slice(n,o),f=e.slice(t,r),l=0;l<a;++l)if(c[l]!==f[l]){i=c[l],s=f[l];break}return i<s?-1:s<i?1:0},u.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},u.prototype.indexOf=function(e,t,r){return m(this,e,t,r,!0)},u.prototype.lastIndexOf=function(e,t,r){return m(this,e,t,r,!1)},u.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-t;if((void 0===r||r>o)&&(r=o),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return v(this,e,t,r);case"utf8":case"utf-8":return b(this,e,t,r);case"ascii":return w(this,e,t,r);case"latin1":case"binary":return E(this,e,t,r);case"base64":return k(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,t,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function O(e,t,r){var n="";r=Math.min(e.length,r);for(var o=t;o<r;++o)n+=String.fromCharCode(127&e[o]);return n}function T(e,t,r){var n="";r=Math.min(e.length,r);for(var o=t;o<r;++o)n+=String.fromCharCode(e[o]);return n}function A(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var o="",i=t;i<r;++i)o+=F(e[i]);return o}function S(e,t,r){for(var n=e.slice(t,r),o="",i=0;i<n.length;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function M(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function I(e,t,r,n,o,i){if(!u.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<i)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function U(e,t,r,n){t<0&&(t=65535+t+1);for(var o=0,i=Math.min(e.length-r,2);o<i;++o)e[r+o]=(t&255<<8*(n?o:1-o))>>>8*(n?o:1-o)}function B(e,t,r,n){t<0&&(t=4294967295+t+1);for(var o=0,i=Math.min(e.length-r,4);o<i;++o)e[r+o]=t>>>8*(n?o:3-o)&255}function N(e,t,r,n,o,i){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function x(e,t,r,n,i){return i||N(e,0,r,4),o.write(e,t,r,n,23,4),r+4}function D(e,t,r,n,i){return i||N(e,0,r,8),o.write(e,t,r,n,52,8),r+8}u.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t<e&&(t=e),u.TYPED_ARRAY_SUPPORT)(r=this.subarray(e,t)).__proto__=u.prototype;else{var o=t-e;r=new u(o,void 0);for(var i=0;i<o;++i)r[i]=this[i+e]}return r},u.prototype.readUIntLE=function(e,t,r){e|=0,t|=0,r||M(e,t,this.length);for(var n=this[e],o=1,i=0;++i<t&&(o*=256);)n+=this[e+i]*o;return n},u.prototype.readUIntBE=function(e,t,r){e|=0,t|=0,r||M(e,t,this.length);for(var n=this[e+--t],o=1;t>0&&(o*=256);)n+=this[e+--t]*o;return n},u.prototype.readUInt8=function(e,t){return t||M(e,1,this.length),this[e]},u.prototype.readUInt16LE=function(e,t){return t||M(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUInt16BE=function(e,t){return t||M(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUInt32LE=function(e,t){return t||M(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},u.prototype.readUInt32BE=function(e,t){return t||M(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||M(e,t,this.length);for(var n=this[e],o=1,i=0;++i<t&&(o*=256);)n+=this[e+i]*o;return n>=(o*=128)&&(n-=Math.pow(2,8*t)),n},u.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||M(e,t,this.length);for(var n=t,o=1,i=this[e+--n];n>0&&(o*=256);)i+=this[e+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*t)),i},u.prototype.readInt8=function(e,t){return t||M(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},u.prototype.readInt16LE=function(e,t){t||M(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(e,t){t||M(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(e,t){return t||M(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return t||M(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readFloatLE=function(e,t){return t||M(e,4,this.length),o.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return t||M(e,4,this.length),o.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return t||M(e,8,this.length),o.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return t||M(e,8,this.length),o.read(this,e,!1,52,8)},u.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||I(this,e,t,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[t]=255&e;++i<r&&(o*=256);)this[t+i]=e/o&255;return t+r},u.prototype.writeUIntBE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||I(this,e,t,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[t+o]=255&e;--o>=0&&(i*=256);)this[t+o]=e/i&255;return t+r},u.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,1,255,0),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},u.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):U(this,e,t,!0),t+2},u.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):U(this,e,t,!1),t+2},u.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):B(this,e,t,!0),t+4},u.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):B(this,e,t,!1),t+4},u.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var o=Math.pow(2,8*r-1);I(this,e,t,r,o-1,-o)}var i=0,s=1,a=0;for(this[t]=255&e;++i<r&&(s*=256);)e<0&&0===a&&0!==this[t+i-1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+r},u.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var o=Math.pow(2,8*r-1);I(this,e,t,r,o-1,-o)}var i=r-1,s=1,a=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===a&&0!==this[t+i+1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+r},u.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,1,127,-128),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},u.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):U(this,e,t,!0),t+2},u.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):U(this,e,t,!1),t+2},u.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):B(this,e,t,!0),t+4},u.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):B(this,e,t,!1),t+4},u.prototype.writeFloatLE=function(e,t,r){return x(this,e,t,!0,r)},u.prototype.writeFloatBE=function(e,t,r){return x(this,e,t,!1,r)},u.prototype.writeDoubleLE=function(e,t,r){return D(this,e,t,!0,r)},u.prototype.writeDoubleBE=function(e,t,r){return D(this,e,t,!1,r)},u.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var o,i=n-r;if(this===e&&r<t&&t<n)for(o=i-1;o>=0;--o)e[o+t]=this[o+r];else if(i<1e3||!u.TYPED_ARRAY_SUPPORT)for(o=0;o<i;++o)e[o+t]=this[o+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+i),t);return i},u.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===e.length){var o=e.charCodeAt(0);o<256&&(e=o)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!u.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var i;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(i=t;i<r;++i)this[i]=e;else{var s=u.isBuffer(e)?e:j(new u(e,n).toString()),a=s.length;for(i=0;i<r-t;++i)this[i+t]=s[i%a]}return this};var L=/[^+\/0-9A-Za-z-_]/g;function F(e){return e<16?"0"+e.toString(16):e.toString(16)}function j(e,t){var r;t=t||1/0;for(var n=e.length,o=null,i=[],s=0;s<n;++s){if((r=e.charCodeAt(s))>55295&&r<57344){if(!o){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function q(e){return n.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(L,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function V(e,t,r,n){for(var o=0;o<n&&!(o+r>=t.length||o>=e.length);++o)t[o+r]=e[o];return o}}).call(this,r(3))},function(e,t,r){"use strict";var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();var o=r(1).fpnn,i=r(0),s=(r(2),function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),o.FPEvent.assign(this),this._map={},this._client=t,this.uid=0,this._expireTimerID=0,this._msgOptions={codec:i.MsgPack.createCodec({int64:!0})},this._binaryOptions={codec:i.MsgPack.createCodec({int64:!0,useraw:!0})},this._binaryMessageMethodList=[i.SERVER_PUSH.recvMessage,i.SERVER_PUSH.recvGroupMessage,i.SERVER_PUSH.recvRoomMessage,i.SERVER_PUSH.recvBroadcastMessage,i.SERVER_PUSH.recvFile,i.SERVER_PUSH.recvGroupFile,i.SERVER_PUSH.recvRoomFile,i.SERVER_PUSH.recvBroadcastFile],u.call(this)}return n(e,[{key:"service",value:function(e,t){if(e&&Object.prototype.hasOwnProperty.call(e,"_tlvPayload")&&(r=e.method,n=i.TLV_SERVER_PUSH,r===n.recvMessage||r===n.recvGroupMessage||r===n.recvRoomMessage||r===n.recvBroadcastMessage||r===n.kickOut||r===n.kickOutRoom))this._serviceTLVPush(e);else{var r,n,o=!0;i.SERVER_PUSH.kickOut==e.method&&(o=!1),i.SERVER_PUSH.kickOutRoom==e.method&&(o=!1),o&&t&&(0==e.flag&&t(JSON.stringify({}),!1),1==e.flag&&t(i.MsgPack.encode({},this._msgOptions),!1));var s=null;if(e&&Object.prototype.hasOwnProperty.call(e,"_tlvPayload")&&(s=e._tlvPayload,e._tlvBinaryPayload&&(s.binary=s.msg)),s||0!=e.flag||(s=JSON.parse(e.payload)),!s&&1==e.flag)if(-1!==this._binaryMessageMethodList.indexOf(e.method))if((s=i.MsgPack.decode(e.payload,this._binaryOptions)).mtype==i.CHAT_TYPE.text)s=i.MsgPack.decode(e.payload,this._msgOptions);else{s.binary=s.msg;try{s.msg=new TextDecoder("utf-8",{fatal:!0}).decode(s.msg)}catch(e){s.msg=void 0}try{s.attrs=new TextDecoder("utf-8",{fatal:!0}).decode(s.attrs)}catch(e){}}else s=i.MsgPack.decode(e.payload,this._msgOptions);if(s){if(void 0!==s.attrs)try{var a=JSON.parse(s.attrs);if(a&&void 0!==a.excludedUids&&Array.isArray(a.excludedUids)&&a.excludedUids.includes(this.uid.toString()))return}catch(e){}"function"==typeof this[e.method]&&this[e.method].call(this,s)}}}},{key:"_serviceTLVPush",value:function(e){var t=e._tlvPayload;if(t&&void 0!==t.extra)try{var r=JSON.parse(t.extra);if(r&&void 0!==r.excludedUids&&Array.isArray(r.excludedUids)&&r.excludedUids.includes(this.uid.toString()))return}catch(e){}this.emit(e.method,t)}},{key:"destroy",value:function(){this._map={},this._expireTimerID&&(clearInterval(this._expireTimerID),this._expireTimerID=0)}},{key:"kickout",value:function(e){this.emit(i.SERVER_PUSH.kickOut,e)}},{key:"kickoutroom",value:function(e){e.rid&&(e.rid=new i.Int64(e.rid)),this.emit(i.SERVER_PUSH.kickOutRoom,e)}},{key:"pushmsg",value:function(e){e.from&&(e.from=new i.Int64(e.from)),e.mid&&(e.mid=new i.Int64(e.mid),!a.call(this,1,e.mid,e.from))||(e.mtime&&(e.mtime=new i.Int64(e.mtime)),e.mtype>=40&&e.mtype<=50?this.emit(i.SERVER_PUSH.recvFile,e):e.mtype!=i.CHAT_TYPE.text?e.mtype!=i.CHAT_TYPE.audio?e.mtype!=i.CHAT_TYPE.cmd?(delete e.ftype,this.emit(i.SERVER_PUSH.recvMessage,e)):this.emit(i.SERVER_PUSH.recvCmd,e):this.emit(i.SERVER_PUSH.recvFile,e):this.emit(i.SERVER_PUSH.recvChat,e))}},{key:"pushgroupmsg",value:function(e){e.from&&(e.from=new i.Int64(e.from)),e.mid&&(e.mid=new i.Int64(e.mid),!a.call(this,2,e.mid,e.from,e.gid))||(e.gid&&(e.gid=new i.Int64(e.gid)),e.mtime&&(e.mtime=new i.Int64(e.mtime)),e.mtype>=40&&e.mtype<=50?this.emit(i.SERVER_PUSH.recvGroupFile,e):e.mtype!=i.CHAT_TYPE.text?e.mtype!=i.CHAT_TYPE.audio?e.mtype!=i.CHAT_TYPE.cmd?(delete e.ftype,this.emit(i.SERVER_PUSH.recvGroupMessage,e)):this.emit(i.SERVER_PUSH.recvGroupCmd,e):this.emit(i.SERVER_PUSH.recvGroupFile,e):this.emit(i.SERVER_PUSH.recvGroupChat,e))}},{key:"pushroommsg",value:function(e){e.from&&(e.from=new i.Int64(e.from)),e.mid&&(e.mid=new i.Int64(e.mid),!a.call(this,3,e.mid,e.from,e.rid))||(e.rid&&(e.rid=new i.Int64(e.rid)),e.mtime&&(e.mtime=new i.Int64(e.mtime)),e.mtype>=40&&e.mtype<=50?this.emit(i.SERVER_PUSH.recvRoomFile,e):e.mtype!=i.CHAT_TYPE.text?e.mtype!=i.CHAT_TYPE.audio?e.mtype!=i.CHAT_TYPE.cmd?(delete e.ftype,this.emit(i.SERVER_PUSH.recvRoomMessage,e)):this.emit(i.SERVER_PUSH.recvRoomCmd,e):this.emit(i.SERVER_PUSH.recvRoomFile,e):this.emit(i.SERVER_PUSH.recvRoomChat,e))}},{key:"pushbroadcastmsg",value:function(e){e.from&&(e.from=new i.Int64(e.from)),e.mid&&(e.mid=new i.Int64(e.mid),!a.call(this,4,e.mid,e.from))||(e.mtime&&(e.mtime=new i.Int64(e.mtime)),e.mtype>=40&&e.mtype<=50?this.emit(i.SERVER_PUSH.recvBroadcastFile,e):e.mtype!=i.CHAT_TYPE.text?e.mtype!=i.CHAT_TYPE.audio?e.mtype!=i.CHAT_TYPE.cmd?(delete e.ftype,this.emit(i.SERVER_PUSH.recvBroadcastMessage,e)):this.emit(i.SERVER_PUSH.recvBroadcastCmd,e):this.emit(i.SERVER_PUSH.recvBroadcastFile,e):this.emit(i.SERVER_PUSH.recvBroadcastChat,e))}},{key:"ping",value:function(e){this._client._lastPingTime=parseInt(Date.now()/1e3),this.emit(i.SERVER_PUSH.recvPing,e)}}]),e}());function a(e,t,r,n){var o=[];o.push(e),o.push(t),o.push(r),null!=n&&o.push(n);var s=o.join("_");if(this._map.hasOwnProperty(s)){if(this._map[s]>Date.now())return!1;delete this._map[s]}return this._map[s]=i.MID_TTL+Date.now(),!0}function u(){var e=this;this._expireTimerID=setInterval((function(){for(var t in e._map)e._map[t]>Date.now()||c.call(e,t)}),i.MID_TTL+1e3)}function c(e){var t=this;setTimeout((function(){delete t._map[e]}),0)}e.exports=s},function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();var i=r(11),s=r(12),a=r(4),u=r(0),c=r(5).normalizeTlvEndpoint,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||{};this._endpoint=c(r.endpoint),this._webSocketFactory=r.webSocketFactory||l,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._protocolCloseTimer=0,this._heartbeatTimer=0,this._heartbeatPending=!1,this._lastActivity=0,this._incomingQueue=Promise.resolve(),this._protocolClosing=!1,this._destroyed=!1,this.processor=null}return o(e,[{key:"on",value:function(e,t){return"function"!=typeof t||(this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push(t)),this}},{key:"off",value:function(e,t){var r=this._listeners[e];return r?(this._listeners[e]=r.filter((function(e){return e!==t})),this):this}},{key:"emit",value:function(e){var t=this._listeners[e]||[],r=Array.prototype.slice.call(arguments,1),n=this;t.slice().forEach((function(e){e.apply(n,r)}))}},{key:"connect",value:function(){if(!this._destroyed&&"connecting"!==this._state&&"open"!==this._state&&"closing"!==this._state){var e=this._connectionGeneration+1;this._connectionGeneration=e,this._nextSequence=1,this._receivedMessages.clear(),this._incomingQueue=Promise.resolve(),this._state="connecting",this._protocolClosing=!1;var t=void 0;try{t=this._webSocketFactory(this._endpoint)}catch(e){return this._state="closed",this.emit("error",d("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",d("webSocketFactory returned an invalid socket")),void this.emit("close");this._socket=t;try{t.binaryType="arraybuffer"}catch(e){}t.onopen=this._onOpen.bind(this,t,e),t.onmessage=this._onMessage.bind(this,t,e),t.onerror=this._onError.bind(this,t,e),t.onclose=this._onClose.bind(this,t,e),this._connectionTimer=setTimeout(this._onConnectionTimeout.bind(this,t,e),this._connectionTimeout)}}},{key:"close",value:function(){this._clearConnectionTimeout(),this._stopHeartbeat(),this._authenticated=!1,"open"!==this._state&&"connecting"!==this._state||(this._state="closing");var e=this._socket;if(e)try{e.close()}catch(e){this._finalizeClose()}else this._finalizeClose()}},{key:"destroy",value:function(){if(!this._destroyed){this._destroyed=!0,this._clearConnectionTimeout(),this._stopHeartbeat(),this._authenticated=!1;var e=this._socket;if(e)try{e.close()}catch(e){}this._finalizeClose(),this._listeners={},this._receivedMessages.clear()}}},{key:"markAuthenticated",value:function(){this._destroyed||"open"!==this._state||(this._authenticated=!0,this._lastActivity=Date.now(),this._startHeartbeat())}},{key:"sendQuest",value:function(e,t,r){try{var n=this._decodeLegacyPayload(e&&e.payload),o=s.toWireRequest(e&&e.method,n.payload,this._requestMetadata,{omitLegacyNil:n.legacyEncoded});this._request(o.uri,o.payload,r,{onError:function(e){t&&t(p(e))},onSuccess:function(e){t&&t({_tlvPayload:g(e),mtype:2,ss:0})}})}catch(e){t&&t(p(e))}}},{key:"_decodeLegacyPayload",value:function(e){if(null==e)return{legacyEncoded:!1,payload:{}};if(a.isPlainMap(e))return{legacyEncoded:!1,payload:e};try{var t=this._legacyMsgPack.decode(e,this._legacyMsgOptions);if(!a.isPlainMap(t))throw new Error("legacy request payload is not a map");return{legacyEncoded:!0,payload:t}}catch(e){throw new s.TLVContractError(200034,"cannot decode local request payload: "+e.message)}}},{key:"_onOpen",value:function(e,t){e!==this._socket||t!==this._connectionGeneration||"connecting"!==this._state||this._destroyed||(this._clearConnectionTimeout(),this._state="open",this._lastActivity=Date.now(),this.emit("connect"))}},{key:"_onMessage",value:function(e,t,r){if(e===this._socket&&t===this._connectionGeneration&&"open"===this._state&&!this._destroyed){var o=r&&("object"===(void 0===r?"undefined":n(r))||"function"==typeof r)&&"data"in r?r.data:r;this._incomingQueue=this._incomingQueue.then((function(){return function(e){if("string"==typeof e)return Promise.reject(new Error("WebSocket text messages are forbidden by TLV v1"));var t=a.getByteView(e);if(t)return Promise.resolve(t);if(e&&"function"==typeof e.arrayBuffer){var r=void 0;try{r=e.arrayBuffer()}catch(e){return Promise.reject(e)}return Promise.resolve(r).then((function(e){var t=a.getByteView(e);if(!t)throw new Error("WebSocket Blob did not resolve to binary data");return t}))}return Promise.reject(new Error("WebSocket message is not binary data"))}(o)})).then(this._handleIncomingBytes.bind(this,e,t)).catch(this._handleIncomingFailure.bind(this,e,t))}}},{key:"_onError",value:function(e,t,r){if(e===this._socket&&t===this._connectionGeneration&&!this._destroyed){var n=r&&r.message?r.message:"WebSocket transport error";this.emit("error",d(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=d("WebSocket connection timed out after "+this._connectionTimeout+" ms");try{this.emit("error",r)}finally{if(e===this._socket&&t===this._connectionGeneration&&!this._destroyed&&"closed"!==this._state){this._state="closing";try{e.close()}catch(e){}e===this._socket&&t===this._connectionGeneration&&"closed"!==this._state&&this._finalizeClose()}}}}},{key:"_clearConnectionTimeout",value:function(){this._connectionTimer&&(clearTimeout(this._connectionTimer),this._connectionTimer=0)}},{key:"_handleIncomingBytes",value:function(e,t,r){if(e===this._socket&&t===this._connectionGeneration&&"open"===this._state&&!this._destroyed){this._lastActivity=Date.now();var n=i.decodeFrame(r);"2"!==n.mt?"1"!==n.mt?this._handleOneWayPush(n):this._handleReliablePush(n):this._handleAnswer(n)}}},{key:"_handleIncomingFailure",value:function(e,t,r){e!==this._socket||t!==this._connectionGeneration||this._destroyed||this._protocolFailure(r)}},{key:"_handleAnswer",value:function(e){if("control.ack"===e.uri)throw new Error("Gate must not send control.ack to a Client");var t=this._pending.get(e.sequence);if(t){if("control.error"===e.uri)return s.validateControlError(e.payload),void this._completePending(e.sequence,!1,{reason:e.payload.reason,status:Number(e.payload.status)});if(e.uri!==t.uri)throw new Error("Answer URI does not match pending request URI");s.validateResponse(e.uri,e.payload),this._completePending(e.sequence,!0,e.payload)}}},{key:"_handleReliablePush",value:function(e){if(!s.isReliablePush(e.uri))throw new Error('Gate sent an unsupported mt="1" Quest URI: '+e.uri);s.validatePush(e.uri,e.payload);var t=String(e.payload.message_ref),r=this._isDuplicateMessage(t);if(this._sendFrame(e.sequence,"2","control.ack",{}),!r){var n={method:e.uri,payload:g(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:g(e.payload)};"event.kicked"===e.uri&&(this._authenticated=!1,this._stopHeartbeat()),this._dispatchPush(t)}},{key:"_dispatchPush",value:function(e){if(this.processor&&"function"==typeof this.processor.service){var t=a.getByteView(e.payload.payload);this.processor.service({_tlvBinaryPayload:!!t,_tlvPayload:e.payload,flag:1,method:e.method})}}},{key:"_request",value:function(e,t,r,n){if(!this._destroyed&&"open"===this._state&&this._socket)if(this._authenticated||"auth.login"===e||"control.ping"===e)if(this._authenticated&&"auth.login"===e)n.onError({status:200023,reason:"auth.login cannot be sent twice on one connection"});else{var o=this._allocateSequence(),i="number"==typeof r&&r>0?r:this._requestTimeout,s={handlers:n,timer:setTimeout(this._onRequestTimeout.bind(this,o),i),uri:e};this._pending.set(o,s);try{this._sendFrame(o,"1",e,t)}catch(e){this._pending.delete(o),clearTimeout(s.timer),n.onError(h(e))}}else n.onError({status:200022,reason:"authentication is required before "+e});else n.onError(d("invalid WebSocket connection"))}},{key:"_onRequestTimeout",value:function(e){var t=this._pending.get(e);t&&(this._pending.delete(e),t.handlers.onError({status:200999,reason:"request timeout"}))}},{key:"_completePending",value:function(e,t,r){var n=this._pending.get(e);n&&(this._pending.delete(e),clearTimeout(n.timer),t?n.handlers.onSuccess(r):n.handlers.onError(r))}},{key:"_allocateSequence",value:function(){for(var e=0;e<i.MAX_SEQUENCE;e+=1){var t=this._nextSequence;if(this._nextSequence=t===i.MAX_SEQUENCE?1:t+1,!this._pending.has(t))return t}throw new Error("all TLV request sequences are pending")}},{key:"_sendFrame",value:function(e,t,r,n){if(this._destroyed||"open"!==this._state||!this._socket)throw d("invalid WebSocket connection");var o=i.encodeFrame(e,t,r,n),s=o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength);this._socket.send(s),this._lastActivity=Date.now()}},{key:"_startHeartbeat",value:function(){this._stopHeartbeat(),this._heartbeatTimer=setInterval(this._heartbeatTick.bind(this),1e3)}},{key:"_stopHeartbeat",value:function(){this._heartbeatTimer&&(clearInterval(this._heartbeatTimer),this._heartbeatTimer=0),this._heartbeatPending=!1}},{key:"_heartbeatTick",value:function(){this._authenticated&&!this._heartbeatPending&&"open"===this._state&&(Date.now()-this._lastActivity<this._heartbeatIdleMs||(this._heartbeatPending=!0,this._request("control.ping",{},this._heartbeatTimeoutMs,{onError:this._onHeartbeatError.bind(this),onSuccess:this._onHeartbeatAnswer.bind(this)})))}},{key:"_onHeartbeatAnswer",value:function(e){this._heartbeatPending=!1,a.isPlainMap(e)||this._protocolFailure(new Error("control.ping Answer body must be a map"))}},{key:"_onHeartbeatError",value:function(e){this._heartbeatPending=!1,this._protocolFailure(new Error("control.ping failed: "+h(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=this._socket,r=this._connectionGeneration,n=h(e);this._state="closing";try{this.emit("error",d("TLV protocol error: "+n.reason))}finally{if("closing"===this._state&&t===this._socket&&r===this._connectionGeneration)if(t){var o=this._onClose.bind(this,t,r);this._protocolCloseTimer=setTimeout(o,2e3);try{t.close()}catch(e){o()}}else this._finalizeClose()}}}},{key:"_finalizeClose",value:function(){if("closed"!==this._state){this._state="closed",this._clearConnectionTimeout(),this._protocolCloseTimer&&(clearTimeout(this._protocolCloseTimer),this._protocolCloseTimer=0),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(d("WebSocket connection closed"))})),this.emit("close")}}}]),e}();function l(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 h(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 d(e){return{reason:e,status:200999}}function p(e){var t=h(e);return{_tlvPayload:{reason:t.reason,status:t.status},mtype:2,ss:1}}function g(e){if(e instanceof a.Int64Value)return new u.Int64(e.toString());if(Array.isArray(e))return e.map(g);if(a.isPlainMap(e)){var t={};return Object.keys(e).forEach((function(r){t[r]=g(e[r])})),t}return e}e.exports=f},function(e,t,r){"use strict";var n=r(4),o=new Uint8Array([2,0,109,116,1,0]),i=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return r.name="TLVCodecError",r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,Error),t}();function s(e){if("number"!=typeof e||!isFinite(e)||Math.floor(e)!==e||e<1||e>2147483647)throw new i("sequence must be an integer in 1..2147483647")}function a(e,t,r){var n=r>>>0;e[t]=255&n,e[t+1]=n>>>8&255,e[t+2]=n>>>16&255,e[t+3]=n>>>24&255}function u(e,t){return e[t]+256*e[t+1]+65536*e[t+2]+16777216*e[t+3]>>>0}e.exports={FLAGS:4,MAGIC:204,MAX_FRAME_LENGTH:67239936,MAX_PAYLOAD_LENGTH:67108864,MAX_SEQUENCE:2147483647,METADATA_LENGTH:7,TLVCodecError:i,VERSION:1,decodeFrame:function(e){var t=n.toUint8Array(e);if(0===t.length||t.length>67239936)throw new i("TLV frame length is outside the allowed limit");if(t.length<27)throw new i("TLV frame is too short");if(204!==t[0]||1!==t[1]||4!==t[2]||0!==t[3])throw new i("invalid TLV v1 header");var r=u(t,4);if(s(r),7!==function(e,t){return e[t]+256*e[t+1]}(t,8))throw new i("TLV v1 metadata length must be exactly 7");for(var a=0;a<o.length;a+=1)if(t[10+a]!==o[a])throw new i("TLV v1 metadata must contain only key mt");var c=t[16];if(48!==c&&49!==c&&50!==c)throw new i("TLV v1 metadata mt is invalid");var f=String.fromCharCode(c);if(u(t,17)!==t.length-21)throw new i("message queue length does not match the frame boundary");var l=21,h=t[l];if(l+=1,0===h||l+h+1+4>t.length)throw new i("invalid URI length in message queue");var d=n.utf8Decode(t.subarray(l,l+h));if(0!==t[l+=h])throw new i("TLV v1 passThrough must be empty");var p=u(t,l+=1);if(l+=4,0===p||p>67108864||l+p!==t.length)throw new i("invalid MsgPack payload length or trailing bytes");var g=t.subarray(l,l+p),y=void 0;try{y=n.decodeMap(g,{allowIntegerMapKeyAtPath:"room.last_messages"===d?["last_by_room"]:null})}catch(e){if(e instanceof i)throw e;throw new i("invalid MsgPack payload: "+e.message)}return{mt:f,payload:y,payloadBytes:new Uint8Array(g),sequence:r,uri:d}},encodeFrame:function(e,t,r,u){s(e),function(e){if("0"!==e&&"1"!==e&&"2"!==e)throw new i('metadata mt must be "0", "1", or "2"')}(t);var c=function(e){if("string"!=typeof e||0===e.length)throw new i("URI must be a non-empty UTF-8 string");var t=n.utf8Encode(e);if(0===t.length||t.length>255)throw new i("URI UTF-8 length must be in 1..255");return t}(r),f=n.encodeMap(void 0===u?{}:u);if(0===f.length||f.length>67108864)throw new i("MsgPack payload length is outside the TLV v1 limit");var l=1+c.length+1+4+f.length,h=21+l;if(h>67239936)throw new i("TLV frame exceeds the maximum frame length");var d=new Uint8Array(h);d[0]=204,d[1]=1,d[2]=4,d[3]=0,a(d,4,e),function(e,t,r){e[t]=255&r,e[t+1]=r>>>8&255}(d,8,7),d.set(o,10),d[16]=t.charCodeAt(0),a(d,17,l);var p=21;return d[p]=c.length,p+=1,d.set(c,p),d[p+=c.length]=0,a(d,p+=1,f.length),p+=4,d.set(f,p),d}}},function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};var o=r(4),i=function(e){function t(e,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,r));return n.name="TLVContractError",n.status=e,n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,Error),t}();function s(e,t,r,n){var o=n||{};return{defaults:o.defaults||{},pass:o.pass||[],request:t||{},required:o.required||[],response:r||{},uri:e}}var a={cursor:0,end_ms:0,limit:20,reverse:!1,start_ms:0},u={end_ms:0,limit:20,reverse:!1,start_ms:0},c={end_ms:0,start_ms:0},f={begin:"start_ms",desc:"reverse",end:"end_ms",lastid:"cursor",mtypes:"kinds",num:"limit"},l={begin:"start_ms",desc:"reverse",end:"end_ms",mid:"anchor",mtypes:"kinds",num:"limit"},h={begin:"start_ms",end:"end_ms",mtypes:"kinds"},d={begin:"first_ms",end:"last_ms",lastid:"next",msgs:"items",num:"size"},p={auth:s("auth.login",{attrs:"props",authv:"auth_ver",lang:"locale",pid:"project",token:"credential",ts:"auth_sec",uid:"user",version:"client_ver"},{ok:"accepted"},{required:["project","user","credential","client_ver"]}),bye:s("connection.close"),getservertime:s("system.time",null,{mts:"server_ms"}),addattrs:s("connection.set_props",{attrs:"props"},null,{required:["props"]}),getattrs:s("connection.get_props",null,{attrs:"props"}),adddebuglog:s("system.debug",{attrs:"context",msg:"entry"},null,{required:["entry","context"]}),getonlineusers:s("presence.online",{uids:"users"},{uids:"online_users"},{required:["users"]}),setuserinfo:s("user.set_profile",{oinfo:"public_data",pinfo:"private_data"}),getuserinfo:s("user.get_profile",null,{oinfo:"public_data",pinfo:"private_data"}),getuseropeninfo:s("user.get_public",{uids:"users"},{info:"profiles"},{required:["users"]}),setlang:s("user.set_locale",{lang:"locale"},{ok:"updated"},{required:["locale"]}),dataget:s("storage.get",{key:"slot"},{val:"value"},{required:["slot"]}),dataset:s("storage.set",{key:"slot",val:"value"},null,{required:["slot","value"]}),datadel:s("storage.delete",{key:"slot"},null,{required:["slot"]}),addblacks:s("blacklist.add",{blacks:"blocked_users"},null,{required:["blocked_users"]}),delblacks:s("blacklist.remove",{blacks:"blocked_users"},null,{required:["blocked_users"]}),getblacks:s("blacklist.list",null,{uids:"blocked_users"}),addgroupmembers:s("group.add",{gid:"group_ref",uids:"members"},null,{required:["group_ref","members"]}),delgroupmembers:s("group.remove",{gid:"group_ref",uids:"members"},null,{required:["group_ref","members"]}),getgroupmembers:s("group.members",{gid:"group_ref",online:"with_online"},{onlines:"active_members",uids:"members"},{required:["group_ref"]}),getgroupcount:s("group.count",{gid:"group_ref",online:"with_online"},{cn:"total",online:"active_total"},{required:["group_ref"]}),getusergroups:s("group.joined",null,{gids:"group_refs"}),setgroupinfo:s("group.set_profile",{gid:"group_ref",oinfo:"public_data",pinfo:"private_data"},null,{required:["group_ref"]}),getgroupinfo:s("group.get_profile",{gid:"group_ref"},{oinfo:"public_data",pinfo:"private_data"},{required:["group_ref"]}),getgroupopeninfo:s("group.get_public",{gid:"group_ref"},{oinfo:"public_data"},{required:["group_ref"]}),getgroupsopeninfo:s("group.get_public_batch",{gids:"group_refs"},{info:"profiles"},{required:["group_refs"]}),enterroom:s("room.join",{rid:"room_ref"},null,{required:["room_ref"]}),leaveroom:s("room.leave",{rid:"room_ref"},null,{required:["room_ref"]}),enterrooms:s("room.join_batch",{rids:"room_refs"},null,{required:["room_refs"]}),getuserrooms:s("room.joined",null,{rooms:"room_refs"}),getroommembers:s("room.members",{rid:"room_ref"},{uids:"members"},{required:["room_ref"]}),getroomcount:s("room.counts",{rids:"room_refs"},{cn:"totals"},{required:["room_refs"]}),setroominfo:s("room.set_profile",{icon:"avatar",name:"label",oinfo:"public_data",pinfo:"private_data",rid:"room_ref"},null,{required:["room_ref"]}),getroominfo:s("room.get_profile",{rid:"room_ref"},{oinfo:"public_data",pinfo:"private_data"},{required:["room_ref"]}),getroomopeninfo:s("room.get_public",{rid:"room_ref"},{oinfo:"public_data"},{required:["room_ref"]}),getroomsopeninfo:s("room.get_public_batch",{rids:"room_refs"},{info:"profiles"},{required:["room_refs"]}),getuserroomsandlastmsg:s("room.last_messages",{mtypes:"kinds"},{rooms:"last_by_room"}),sendmsg:s("message.send",{attrs:"extra",mid:"message_ref",msg:"payload",mtype:"kind",to:"recipient"},{mid:"message_ref",mtime:"time_ms"},{pass:["checkParams","strategyid"],required:["recipient","message_ref","kind","payload","extra"]}),sendmsgs:s("message.send_batch",{attrs:"extra",mid:"message_ref",msg:"payload",mtype:"kind",tos:"recipients"},{mid:"message_ref",mtime:"time_ms"},{required:["recipients","message_ref","kind","payload","extra"]}),sendgroupmsg:s("message.send_group",{attrs:"extra",gid:"group_ref",mid:"message_ref",msg:"payload",mtype:"kind"},{mid:"message_ref",mtime:"time_ms"},{pass:["checkParams","strategyid"],required:["group_ref","message_ref","kind","payload","extra"]}),sendroommsg:s("message.send_room",{attrs:"extra",mid:"message_ref",msg:"payload",mtype:"kind",rid:"room_ref"},{mid:"message_ref",mtime:"time_ms"},{pass:["checkParams","strategyid"],required:["room_ref","message_ref","kind","payload","extra"]}),tcheck:s("moderation.check",{region:"zone",text:"payload"},{language:"detected_locale",result:"decision",text:"filtered",wlist:"matches"},{pass:["checkParams","strategyId"],required:["payload"]}),translate:s("translation.run",{dst:"to_locale",profanity:"filter_mode",src:"from_locale",text:"input",type:"format"},{dtext:"output",dst:"to_locale",source:"detected_locale",sourceText:"original",src:"from_locale",stext:"input",target:"resolved_locale",targetText:"translated"},{defaults:{filter_mode:"off",format:"chat"},required:["input","to_locale","format","filter_mode"]}),getp2pmsg:s("history.direct",Object.assign({ouid:"peer"},f),d,{defaults:a,required:["peer","reverse","limit","start_ms","end_ms","cursor"]}),getgroupmsg:s("history.group",Object.assign({gid:"group_ref"},f),d,{defaults:a,required:["group_ref","reverse","limit","start_ms","end_ms","cursor"]}),getroommsg:s("history.room",Object.assign({rid:"room_ref"},f),d,{defaults:a,required:["room_ref","reverse","limit","start_ms","end_ms","cursor"]}),getbroadcastmsg:s("history.broadcast",f,d,{defaults:a,required:["reverse","limit","start_ms","end_ms","cursor"]}),getp2pmsgbymessageid:s("history.direct_anchor",Object.assign({ouid:"peer"},l),d,{defaults:u,required:["peer","anchor","reverse","limit","start_ms","end_ms"]}),getgroupmsgbymessageid:s("history.group_anchor",Object.assign({gid:"group_ref"},l),d,{defaults:u,required:["group_ref","anchor","reverse","limit","start_ms","end_ms"]}),getroommsgbymessageid:s("history.room_anchor",Object.assign({rid:"room_ref"},l),d,{defaults:u,required:["room_ref","anchor","reverse","limit","start_ms","end_ms"]}),getbroadcastmsgbymessageid:s("history.broadcast_anchor",l,d,{defaults:u,required:["anchor","reverse","limit","start_ms","end_ms"]}),getp2pmsgcount:s("history.direct_count",Object.assign({ouid:"peer"},h),{count:"total"},{defaults:c,required:["peer","start_ms","end_ms"]}),getgroupmsgcount:s("history.group_count",Object.assign({gid:"group_ref"},h),{count:"total"},{defaults:c,required:["group_ref","start_ms","end_ms"]}),getroommsgcount:s("history.room_count",Object.assign({rid:"room_ref"},h),{count:"total"},{defaults:c,required:["room_ref","start_ms","end_ms"]}),getbroadcastmsgcount:s("history.broadcast_count",h,{count:"total"},{defaults:c,required:["start_ms","end_ms"]}),getmsg:s("message.get",{from:"sender",mid:"message_ref",type:"channel",xid:"target_ref"},{attrs:"extra",from:"sender",id:"sequence",mid:"message_ref",msg:"payload",mtime:"time_ms",mtype:"kind"},{required:["sender","message_ref","target_ref","channel"]}),delmsg:s("message.revoke",{from:"sender",mid:"message_ref",type:"channel",xid:"target_ref"},null,{required:["sender","message_ref","target_ref","channel"]}),getunread:s("unread.summary",{clear:"mark_read",gettime:"with_logout"},{group:"group_refs",logouttime:"logout_sec",p2p:"peers"},{defaults:{mark_read:!1},required:["mark_read"]}),getsession:s("session.list",null,{group:"group_refs",p2p:"peers"}),cleanunread:s("unread.clear"),setsessionread:s("session.read",{category:"channel",read_seq:"through",xid:"target_ref"},null,{required:["channel","target_ref","through"]}),getp2punread:s("unread.direct",{mtime:"since_ms",mtypes:"kinds",uids:"peers"},{ltime:"times",p2p:"counts"},{required:["peers"]}),getgroupunread:s("unread.group",{gids:"group_refs",mtime:"since_ms",mtypes:"kinds"},{group:"counts",ltime:"times"},{required:["group_refs"]}),removesession:s("session.remove",{oneway:"local_only",to:"peer"},null,{defaults:{local_only:!1},required:["peer","local_only"]}),getp2pconversationlist:s("conversation.direct",{mtime:"since_ms",mtypes:"kinds"},{conversations:"peers",msgs:"last_items",unreads:"badges"}),getp2punreadconversationlist:s("conversation.direct_unread",{mtime:"since_ms",mtypes:"kinds"},{conversations:"peers",msgs:"last_items",unreads:"badges"}),getgroupconversationlist:s("conversation.group",{mtime:"since_ms",mtypes:"kinds"},{conversations:"group_refs",msgs:"last_items",unreads:"badges"}),getgroupunreadconversationlist:s("conversation.group_unread",{mtime:"since_ms",mtypes:"kinds"},{conversations:"group_refs",msgs:"last_items",unreads:"badges"}),getunreadconversationlist:s("conversation.unread",{clear:"mark_read",mtime:"since_ms",mtypes:"kinds"},{groupConversations:"group_refs",groupMsgs:"group_last",groupUnreads:"group_badges",p2pConversations:"peers",p2pMsgs:"peer_last",p2pUnreads:"peer_badges"},{defaults:{mark_read:!1},required:["mark_read"]})},g=new Set(["acheck","adddevice","addfriends","addoption","addprojectban","adminCommand","broadcastfile","closeRTCRoom","delfriends","filetoken","getfriends","getoption","getRTCRoomList","getRTCRoomMemberCount","getRTCRoomMembers","icheck","inviteUserIntoRTCRoom","isfriend","isfriends","isprojectban","kickoutFromRTCRoom","profanity","pullIntoRTCRoom","removedevice","removeoption","removeprojectban","sendfile","sendfiles","sendgroupfile","sendroomfile","setRTCRoomMicStatus","speech2text","speechtranslation","uploadfile","vcheck"]),y={"event.broadcast":!0,"event.direct":!0,"event.group":!0,"event.room":!0},m={"event.kicked":!0,"event.room_removed":!0},_="9223372036854775807";function v(e,t,r){return Object.assign({required:!!t,type:e},r||{})}function b(e,t){return v("integer",e,Object.assign({min:"-9223372036854775808",max:_},t||{}))}function w(e,t){return v("integer",e,Object.assign({min:"-2147483648",max:"2147483647"},t||{}))}function E(e,t){return b(e,Object.assign({min:"1"},t||{}))}function k(e,t){return b(e,Object.assign({min:"0"},t||{}))}function R(e,t){return w(e,Object.assign({min:"0"},t||{}))}function P(e,t){return v("string",e,t)}function C(e){return v("boolean",e)}function O(e,t,r){return v("array",e,Object.assign({element:t},r||{}))}function T(e,t,r,n){return v("map",e,Object.assign({key:t,value:r},n||{}))}function A(e){return Object.assign({sent_ms:b(!1),trace:P(!1)},e||{})}function S(e,t){return{allowEmpty:!(!t||!t.allowEmpty),fields:e||{}}}var M=b(!1),I=w(!1),U=R(!1),B=b(!1),N=k(!1),x=E(!1),D=P(!1),L=v("string_or_bin",!1),F=v("tuple8",!1);function j(e,t){return O(e,x,t)}function q(e,t){return O(e,M,t)}function V(e,t){return O(e,I,t)}function Y(e){return T(e,"string",D)}function G(e){return T(e,"positive_decimal_int64",D)}function H(e){return T(e,"positive_decimal_int64",U)}function W(e){return T(e,"positive_decimal_int64",N)}function z(e){return b(e,{max:"255",min:"0"})}var K,J={extra:P(!0,{maxBytes:65535}),kind:(K=!0,b(K,{messageKind:!0})),message_ref:k(!0),payload:v("string_or_bin",!0,{maxBytes:65535})},$={cursor:b(!0),end_ms:k(!0),kinds:q(!1),limit:R(!0),reverse:C(!0),start_ms:k(!0)},Q={anchor:E(!0),end_ms:k(!0),kinds:q(!1),limit:R(!0),reverse:C(!0),start_ms:k(!0)},X={end_ms:k(!0),kinds:q(!1),start_ms:k(!0)},Z={"auth.login":A({auth_sec:k(!1),auth_ver:w(!1,{enum:["2"]}),client_ver:P(!0,{nonEmpty:!0}),credential:P(!0,{nonEmpty:!0}),locale:P(!1),project:b(!0,{max:"4294967295",min:"1"}),props:Y(!1),user:E(!0)}),"connection.close":A(),"system.time":A(),"connection.set_props":A({props:Y(!0)}),"connection.get_props":A(),"system.debug":A({context:P(!0),entry:P(!0,{nonEmpty:!0})}),"presence.online":A({users:j(!0,{minItems:1})}),"user.set_profile":A({private_data:P(!1),public_data:P(!1)}),"user.get_profile":A(),"user.get_public":A({users:j(!0,{minItems:1})}),"user.set_locale":A({locale:P(!0)}),"storage.get":A({slot:P(!0)}),"storage.set":A({slot:P(!0),value:P(!0)}),"storage.delete":A({slot:P(!0)}),"blacklist.add":A({blocked_users:j(!0,{minItems:1,uniqueInt64Max:100})}),"blacklist.remove":A({blocked_users:j(!0,{minItems:1,uniqueInt64Max:100})}),"blacklist.list":A(),"group.add":A({group_ref:E(!0),members:j(!0,{minItems:1})}),"group.remove":A({group_ref:E(!0),members:j(!0,{minItems:1})}),"group.members":A({group_ref:E(!0),with_online:C(!1)}),"group.count":A({group_ref:E(!0),with_online:C(!1)}),"group.joined":A(),"group.set_profile":A({group_ref:E(!0),private_data:P(!1),public_data:P(!1)}),"group.get_profile":A({group_ref:E(!0)}),"group.get_public":A({group_ref:E(!0)}),"group.get_public_batch":A({group_refs:j(!0,{minItems:1})}),"room.join":A({room_ref:E(!0)}),"room.leave":A({room_ref:E(!0)}),"room.join_batch":A({room_refs:j(!0,{maxItems:100,minItems:1})}),"room.joined":A(),"room.members":A({room_ref:E(!0)}),"room.counts":A({room_refs:j(!0,{minItems:1})}),"room.set_profile":A({avatar:P(!1),label:P(!1),private_data:P(!1),public_data:P(!1),room_ref:E(!0)}),"room.get_profile":A({room_ref:E(!0)}),"room.get_public":A({room_ref:E(!0)}),"room.get_public_batch":A({room_refs:j(!0,{minItems:1})}),"room.last_messages":A({kinds:q(!1)}),"message.send":A(Object.assign({recipient:E(!0)},J,{checkParams:P(!1),strategyid:P(!1)})),"message.send_batch":A(Object.assign({recipients:j(!0,{maxItems:100,minItems:1})},J)),"message.send_group":A(Object.assign({group_ref:E(!0)},J,{checkParams:P(!1),strategyid:P(!1)})),"message.send_room":A(Object.assign({room_ref:E(!0)},J,{checkParams:P(!1),strategyid:P(!1)})),"moderation.check":A({checkParams:P(!1),payload:P(!0,{nonEmpty:!0}),strategyId:P(!1),zone:P(!1)}),"translation.run":A({filter_mode:P(!0,{enum:["off","stop","censor"]}),format:P(!0,{nonEmpty:!0}),from_locale:P(!1),input:P(!0,{nonEmpty:!0}),to_locale:P(!0)}),"history.direct":A(Object.assign({peer:E(!0)},$)),"history.group":A(Object.assign({group_ref:E(!0)},$)),"history.room":A(Object.assign({room_ref:E(!0)},$)),"history.broadcast":A($),"history.direct_anchor":A(Object.assign({peer:E(!0)},Q)),"history.group_anchor":A(Object.assign({group_ref:E(!0)},Q)),"history.room_anchor":A(Object.assign({room_ref:E(!0)},Q)),"history.broadcast_anchor":A(Q),"history.direct_count":A(Object.assign({peer:E(!0)},X)),"history.group_count":A(Object.assign({group_ref:E(!0)},X)),"history.room_count":A(Object.assign({room_ref:E(!0)},X)),"history.broadcast_count":A(X),"message.get":A({channel:w(!0,{enum:["1","2","3","4"]}),message_ref:b(!0),sender:E(!0),target_ref:k(!0)}),"message.revoke":A({channel:w(!0,{enum:["1","2","3","4"]}),message_ref:b(!0),sender:E(!0),target_ref:k(!0)}),"unread.summary":A({mark_read:C(!0),with_logout:C(!1)}),"session.list":A(),"unread.clear":A(),"session.read":A({channel:w(!0,{enum:["1","2","3","4","5"]}),target_ref:k(!0),through:E(!0)}),"unread.direct":A({kinds:q(!1),peers:j(!0,{minItems:1}),since_ms:k(!1)}),"unread.group":A({group_refs:j(!0,{minItems:1}),kinds:q(!1),since_ms:k(!1)}),"session.remove":A({local_only:C(!0),peer:E(!0)}),"conversation.direct":A({kinds:q(!1),since_ms:k(!1)}),"conversation.direct_unread":A({kinds:q(!1),since_ms:k(!1)}),"conversation.group":A({kinds:q(!1),since_ms:k(!1)}),"conversation.group_unread":A({kinds:q(!1),since_ms:k(!1)}),"conversation.unread":A({kinds:q(!1),mark_read:C(!0),since_ms:k(!1)})},ee={first_ms:k(!0),items:O(!0,F),last_ms:k(!0),next:b(!0),size:R(!0)},te={message_ref:b(!0),time_ms:b(!0)},re={extra:P(!0),kind:z(!0),message_ref:b(!0),payload:v("string_or_bin",!0),sender:E(!0),sequence:b(!0),time_ms:b(!0)},ne={"auth.login":S({accepted:C(!0),telemetry_on:C(!1)}),"connection.close":S(),"system.time":S({server_ms:b(!0)}),"connection.set_props":S(),"connection.get_props":S({props:Y(!0)}),"system.debug":S(),"presence.online":S({online_users:j(!0)}),"user.set_profile":S(),"user.get_profile":S({private_data:P(!0),public_data:P(!0)}),"user.get_public":S({profiles:G(!0)}),"user.set_locale":S({updated:C(!0)}),"storage.get":S({value:P(!0)}),"storage.set":S(),"storage.delete":S(),"blacklist.add":S(),"blacklist.remove":S(),"blacklist.list":S({blocked_users:j(!0)}),"group.add":S(),"group.remove":S(),"group.members":S({active_members:j(!1),members:j(!0)}),"group.count":S({active_total:R(!1),total:R(!0)}),"group.joined":S({group_refs:j(!0)}),"group.set_profile":S(),"group.get_profile":S({private_data:P(!0),public_data:P(!0)}),"group.get_public":S({public_data:P(!0)}),"group.get_public_batch":S({profiles:G(!0)}),"room.join":S(),"room.leave":S(),"room.join_batch":S(),"room.joined":S({room_refs:j(!0)}),"room.members":S({members:j(!0)}),"room.counts":S({totals:H(!0)}),"room.set_profile":S(),"room.get_profile":S({private_data:P(!0),public_data:P(!0)}),"room.get_public":S({public_data:P(!0)}),"room.get_public_batch":S({profiles:G(!0)}),"room.last_messages":S({last_by_room:function(e){return T(e,"positive_decimal_int64",F)}(!0)}),"message.send":S(te),"message.send_batch":S(te),"message.send_group":S(te),"message.send_room":S(te),"moderation.check":S({decision:w(!0),detected_locale:P(!0),filtered:P(!0),matches:function(e,t){return O(e,D,t)}(!1)}),"translation.run":S({detected_locale:P(!0),from_locale:P(!0),input:P(!0),original:P(!0),output:P(!0),resolved_locale:P(!0),to_locale:P(!0),translated:P(!0)}),"history.direct":S(ee),"history.group":S(ee),"history.room":S(ee),"history.broadcast":S(ee),"history.direct_anchor":S(ee),"history.group_anchor":S(ee),"history.room_anchor":S(ee),"history.broadcast_anchor":S(ee),"history.direct_count":S({total:R(!0)}),"history.group_count":S({total:R(!0)}),"history.room_count":S({total:R(!0)}),"history.broadcast_count":S({total:R(!0)}),"message.get":S(re,{allowEmpty:!0}),"message.revoke":S(),"unread.summary":S({group_refs:j(!0),logout_sec:k(!1),peers:j(!0)}),"session.list":S({group_refs:j(!0),peers:j(!0)}),"unread.clear":S(),"session.read":S(),"unread.direct":S({counts:H(!0),times:W(!0)}),"unread.group":S({counts:H(!0),times:W(!0)}),"session.remove":S(),"conversation.direct":S({badges:V(!0),last_items:O(!0,F),peers:j(!0)}),"conversation.direct_unread":S({badges:V(!0),last_items:O(!0,F),peers:j(!0)}),"conversation.group":S({badges:V(!0),group_refs:j(!0),last_items:O(!0,F)}),"conversation.group_unread":S({badges:V(!0),group_refs:j(!0),last_items:O(!0,F)}),"conversation.unread":S({group_badges:V(!0),group_last:O(!0,F),group_refs:j(!0),peer_badges:V(!0),peer_last:O(!0,F),peers:j(!0)}),"control.ping":S({ts:b(!1)})},oe={from_locale:P(!0),original:P(!0),to_locale:P(!0),translated:P(!0)},ie={extra:P(!0,{maxBytes:65535}),kind:z(!0),message_ref:b(!0),payload:v("push_payload",!0),sender:E(!0),time_ms:b(!0)},se={"event.direct":Object.assign({recipient:E(!0)},ie),"event.group":Object.assign({group_ref:E(!0)},ie),"event.room":Object.assign({room_ref:E(!0)},ie),"event.broadcast":ie,"event.kicked":{},"event.room_removed":{room_ref:E(!0)}};function ae(e){return p[e]||null}function ue(e){var t=String(e);if(!/^-?[0-9]+$/.test(t))return null;var r="-"===t.charAt(0),n=(r?t.slice(1):t).replace(/^0+/,"")||"0";return r&&"0"!==n?"-"+n:n}function ce(e){return"number"==typeof e?function(e){if(Number.isSafeInteger)return Number.isSafeInteger(e);return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e&&Math.abs(e)<=9007199254740991}(e)?ue(e):null:"bigint"==typeof e||e instanceof o.Int64Value||e&&"object"===(void 0===e?"undefined":n(e))&&"number"==typeof e.offset&&e.buffer&&"function"==typeof e.toString?ue(e.toString()):null}function fe(e,t){var r=ue(e),n=ue(t);if(null===r||null===n)throw new Error("integer comparison requires decimal integers");if(r===n)return 0;var o="-"===r.charAt(0),i="-"===n.charAt(0);if(o!==i)return o?-1:1;var s=o?r.slice(1):r,a=i?n.slice(1):n,u=void 0;return u=s.length!==a.length?s.length<a.length?-1:1:s<a?-1:1,o?-u:u}function le(e){for(var t=0,r=0;r<e.length;r+=1){var n=e.charCodeAt(r);if(n>=55296&&n<=56319){var o=e.charCodeAt(r+1);if(o<56320||o>57343)throw new i(200034,"string contains an unpaired surrogate");t+=4,r+=1}else{if(n>=56320&&n<=57343)throw new i(200034,"string contains an unpaired surrogate");t+=n<=127?1:n<=2047?2:3}}return t}function he(e,t){throw new i(200034,e+" "+t)}function de(e,t,r){if(null==e&&he(r,"must not be nil"),"integer"!==t.type)if("boolean"!==t.type){if("string"===t.type)return"string"!=typeof e&&he(r,"must be a UTF-8 string"),t.nonEmpty&&0===e.length&&he(r,"must not be empty"),t.enum&&-1===t.enum.indexOf(e)&&he(r,"is not an allowed value"),void(void 0!==t.maxBytes&&le(e)>t.maxBytes&&he(r,"exceeds "+t.maxBytes+" UTF-8 bytes"));if("string_or_bin"===t.type){if("string"==typeof e)return void(void 0!==t.maxBytes&&le(e)>t.maxBytes&&he(r,"exceeds "+t.maxBytes+" UTF-8 bytes"));var n=o.getByteView(e);return n||he(r,"must be a string or MsgPack bin value"),void(void 0!==t.maxBytes&&n.byteLength>t.maxBytes&&he(r,"exceeds "+t.maxBytes+" bytes"))}if("array"!==t.type){if("map"===t.type)return o.isPlainMap(e)||he(r,"must be a map"),void Object.keys(e).forEach((function(n){!function(e,t,r){if("string"!==t)if("positive_decimal_int64"!==t)he(r,"uses an unsupported map-key contract");else{var n=ue(e);(null===n||"-"===n.charAt(0)||"0"===n||fe(n,_)>0)&&he(r,"must be a positive decimal int64 map key")}}(n,t.key,r+"."+n),de(e[n],t.value,r+"."+n)}));if("tuple8"!==t.type)if("push_payload"!==t.type)he(r,"uses an unsupported value contract");else{if("string"==typeof e||o.getByteView(e))return;pe("Chat payload",e,oe)}else!function(e,t){Array.isArray(e)&&8===e.length||he(t,"must be an 8-item message tuple"),de(e[0],B,t+"[0]"),de(e[1],B,t+"[1]"),de(e[2],M,t+"[2]"),de(e[3],B,t+"[3]"),de(e[4],v("boolean",!1),t+"[4]"),de(e[5],L,t+"[5]"),de(e[6],D,t+"[6]"),de(e[7],B,t+"[7]")}(e,r)}else if(Array.isArray(e)||he(r,"must be an array"),void 0!==t.minItems&&e.length<t.minItems&&he(r,"must not be empty"),void 0!==t.maxItems&&e.length>t.maxItems&&he(r,"contains too many items"),e.forEach((function(e,n){de(e,t.element,r+"["+n+"]")})),void 0!==t.uniqueInt64Max){var i={};e.forEach((function(e){i[ce(e)]=!0})),Object.keys(i).length>t.uniqueInt64Max&&he(r,"contains too many distinct int64 items")}}else"boolean"!=typeof e&&he(r,"must be boolean");else!function(e,t,r){var n=ce(e);(null===n||fe(n,"-9223372036854775808")<0||fe(n,_)>0)&&he(r,"must be a signed int64 integer"),void 0!==t.min&&fe(n,t.min)<0&&he(r,"is below the allowed range"),void 0!==t.max&&fe(n,t.max)>0&&he(r,"is above the allowed range"),t.enum&&-1===t.enum.indexOf(n)&&he(r,"is not an allowed value"),t.messageKind&&!(fe(n,"1")>=0&&fe(n,"39")<=0||fe(n,"51")>=0&&fe(n,"127")<=0)&&he(r,"must be in kind ranges [1,39] or [51,127]")}(e,t,r)}function pe(e,t,r){o.isPlainMap(t)||he(e,"body must be a map"),Object.keys(t).forEach((function(t){Object.prototype.hasOwnProperty.call(r,t)||he(e+"."+t,"is not defined by this contract")})),Object.keys(r).forEach((function(n){var o=r[n];Object.prototype.hasOwnProperty.call(t,n)?de(t[n],o,e+"."+n):o.required&&he(e+"."+n,"is required")}))}function ge(e,t,r){for(var n=t[r[0]].length,o=1;o<r.length;o+=1)t[r[o]].length!==n&&he(e+" Answer",r.join(", ")+" must have matching lengths")}function ye(e){return g.has(e)||"string"==typeof e&&0===e.indexOf("imclient_")}e.exports={RELIABLE_PUSHES:y,REQUEST_SCHEMAS:Z,RESPONSE_SCHEMAS:ne,RESERVED_WIRES:g,ROUTES:p,TLVContractError:i,getRoute:ae,getRouteByUri:function(e){for(var t=Object.keys(p),r=0;r<t.length;r+=1){var n=p[t[r]];if(n.uri===e)return{method:t[r],route:n}}return null},isOneWayPush:function(e){return Object.prototype.hasOwnProperty.call(m,e)},isReliablePush:function(e){return Object.prototype.hasOwnProperty.call(y,e)},isReservedWire:ye,toWireRequest:function(e,t,r,n){var s=ae(e);if(!s){if(ye(e))throw new i(200020,e+" is reserved and unavailable on the TLV Client port");throw new i(20004,"unknown or unsupported TLV Client wire: "+e)}if(!o.isPlainMap(t))throw new i(200034,e+" request body must be a map");var a={};return Object.keys(t).forEach((function(e){var r=void 0;if("trace_id"!==e&&"send_ts"!==e){if("trace"===e||"sent_ms"===e)r=e;else if(Object.prototype.hasOwnProperty.call(s.request,e))r=s.request[e];else{if(-1===s.pass.indexOf(e))throw new i(200034,s.uri+" does not accept field "+e);r=e}if(Object.prototype.hasOwnProperty.call(a,r))throw new i(200034,s.uri+" received duplicate field mapping for "+r);n&&n.omitLegacyNil&&(void 0===t[e]||null===t[e])&&function(e,t){if("trace"===t||"sent_ms"===t)return!0;if(Object.prototype.hasOwnProperty.call(e.defaults,t))return!0;var r=Z[e.uri];return!(!r||!r[t]||r[t].required)}(s,r)||(a[r]=t[e])}})),Object.keys(s.defaults).forEach((function(e){Object.prototype.hasOwnProperty.call(a,e)||(a[e]=s.defaults[e])})),function(e,t,r){if(!t)return;var n="function"==typeof t?t():t;if(!n)return;if(!o.isPlainMap(n))throw new i(200034,r+" request metadata must be a map");["trace","sent_ms"].forEach((function(t){if(void 0!==n[t]){if(Object.prototype.hasOwnProperty.call(e,t)&&e[t]!==n[t])throw new i(200034,r+" has conflicting "+t+" values");e[t]=n[t]}}))}(a,r,s.uri),function(e,t){var r=Z[e.uri];if(!r)throw new i(200034,"missing request schema for "+e.uri);if(pe(e.uri+" request",t,r),"auth.login"===e.uri){var n=Object.prototype.hasOwnProperty.call(t,"auth_sec"),o=Object.prototype.hasOwnProperty.call(t,"auth_ver");if(n!==o)throw new i(200034,"auth.login requires auth_sec and auth_ver together");if(o&&"2"!==ce(t.auth_ver))throw new i(200034,"auth.login auth_ver must be 2")}}(s,a),{payload:a,uri:s.uri}},validateControlError:function(e){pe("control.error Answer",e,{reason:P(!0),status:w(!0)})},validatePush:function(e,t){var r=se[e];if(!r)throw new i(200034,"unsupported Push URI: "+e);pe(e+" Push",t,r)},validateResponse:function(e,t){var r=ne[e];if(!r)throw new i(200034,"unsupported Answer URI: "+e);r.allowEmpty&&o.isPlainMap(t)&&0===Object.keys(t).length||(pe(e+" Answer",t,r.fields),function(e,t){var r=void 0;if("conversation.direct"===e||"conversation.direct_unread"===e)r=["peers","badges","last_items"];else if("conversation.group"===e||"conversation.group_unread"===e)r=["group_refs","badges","last_items"];else if("conversation.unread"===e)return ge(e,t,["group_refs","group_badges","group_last"]),void ge(e,t,["peers","peer_badges","peer_last"]);r&&ge(e,t,r)}(e,t))}}},function(e,t,r){"use strict";var n=r(7),o=n.isValidFpnnEndpoint,i=n.normalizeFpnnEndpoint,s=r(5).normalizeTlvEndpoint;e.exports={normalizeClientOptions:function(e){var t=Object.assign({},e||{});if(void 0===t.protocol&&(t.protocol="fpnn"),"fpnn"!==t.protocol&&"tlv-v1"!==t.protocol)throw new Error('options.protocol must be "fpnn" or "tlv-v1"');if("fpnn"===t.protocol){var r=void 0!==t.ssl_endpoint,n=r?t.ssl_endpoint:i(t.endpoint);if(!o(n))throw new Error("FPNN requires options.endpoint or options.ssl_endpoint as host[:port], without a URL scheme or path");r||(t.endpoint=n)}else{var a=t.tlvEndpoint||t.tlv_endpoint;if(!a&&"string"==typeof t.endpoint&&/^wss?:\/\//i.test(t.endpoint)&&(a=t.endpoint),!a&&"string"==typeof t.ssl_endpoint&&/^wss?:\/\//i.test(t.ssl_endpoint)&&(a=t.ssl_endpoint),"string"!=typeof a||!/^wss?:\/\//i.test(a))throw new Error("tlv-v1 requires options.tlvEndpoint as the deployment-provided ws:// or wss:// URL");t.tlvEndpoint=s(a),delete t.tlv_endpoint,delete t.endpoint,delete t.ssl_endpoint}return t}}},function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var s=r(2),a=r(0),u=r(6),c=r(1),f=c.Int64BE,l=c.Uint64BE,h=r(15),d=h.normalizeClientOptions,p=h.sharedEndpoint,g=r(16).getSharedWorkerConfigFallbackReason,y=r(17),m=r(18),_=r(5).normalizeTlvEndpoint,v="__rtmSharedWorkerType__",b=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}(),w=function(){function e(t){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);var n=t||{};if("undefined"==typeof SharedWorker)throw new Error("RTMSharedWorkerClient requires browser SharedWorker support");var o=function(e){if(null!=e&&""!==e){if("string"!=typeof e)throw new Error("RTMSharedWorkerClient workerUrl must be a string");return e}if(!b)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",b)}catch(e){throw new Error("RTMSharedWorkerClient could not resolve rtm.shared-worker.js beside the SDK script; provide workerUrl")}if("undefined"!=typeof window&&window.location&&t.origin!==window.location.origin)throw new Error("RTMSharedWorkerClient default worker URL is cross-origin; serve rtm.shared-worker.js from this page origin or provide a same-origin workerUrl");return t.href}(n.workerUrl),i=d(n.clientOptions);this._protocol=i.protocol;var a=g(i);if(a)throw new Error("RTMSharedWorkerClient cannot use "+a.replace(/^options/,"clientOptions")+"; use createClient() to run this configuration on the current page");var c,f=y(n.conversation),l=n.workerName||(void 0!==n.uid&&null!==n.uid?E({pid:i.pid,uid:n.uid,protocol:i.protocol,endpoint:p(i),namespace:n.workerNamespace}):"fpnn"===i.protocol?"rtm-shared-worker:fpnn":"rtm-shared-worker"),h=void 0===n.idleShutdownTimeout?5e3:n.idleShutdownTimeout;if(!("number"==typeof(c=h)&&isFinite(c)&&c>=0))throw new Error("RTMSharedWorkerClient idleShutdownTimeout must be a non-negative number");if(this._listeners=Object.create(null),this._processorListeners=Object.create(null),this._callbackSeq=0,this._callbacks=new Map,this._destroyed=!1,this._destroying=!1,this._failedError=null,this._conversation=f,this.promises=u(this,s.prototype),this._pageWindow="undefined"!=typeof window&&window.addEventListener?window:null,this._pageHideListener=function(e){e&&e.persisted||r.destroy()},this._session={status:"idle",uid:null},this._readySettled=!1,this._readyPromise=new Promise((function(e,t){r._resolveReady=e,r._rejectReady=t})),this._readyPromise.catch((function(){})),this._worker=new SharedWorker(o,l),this._worker.onerror=this._onWorkerError.bind(this),this._port=this._worker.port,this._pageWindow&&this._pageWindow.addEventListener("pagehide",this._pageHideListener),this._port.onmessage=this._onMessage.bind(this),this._port.onmessageerror=this._onMessageError.bind(this),"function"==typeof this._port.start&&this._port.start(),this._post({type:"init",options:i,idleShutdownTimeout:h})){var m=function(e){return"number"==typeof e&&isFinite(e)&&e>0}(n.readyTimeout)?n.readyTimeout:1e4;this._readyTimer=setTimeout((function(){var e=O("Timed out waiting for the RTM SharedWorker to initialize","RTM_SHARED_WORKER_READY_TIMEOUT");r._failedError=e;var t=r._failPendingCallbacks(e);r._settleReady(e);try{r._emit(r._listeners,"SharedWorkerError",[e])}finally{r.destroy()}if(t)throw t.error}),m)}else this._settleReady(new Error("Failed to initialize the RTM SharedWorker client")),this.destroy();var _=this;this.processor={on:function(e,t){return _._addListener(_._processorListeners,e,t),this},off:function(e,t){return _._removeListener(_._processorListeners,e,t),this},removeEvent:function(e,t){return 0===arguments.length?_._processorListeners=Object.create(null):_._removeListener(_._processorListeners,e,t),this},emit:function(e){_._emit(_._processorListeners,e,Array.prototype.slice.call(arguments,1))},listenerCount:function(e){return(_._processorListeners[e]||[]).length}}}return o(e,[{key:"on",value:function(e,t){return this._addListener(this._listeners,e,t),this}},{key:"off",value:function(e,t){return this._removeListener(this._listeners,e,t),this}},{key:"emit",value:function(e){this._emit(this._listeners,e,Array.prototype.slice.call(arguments,1))}},{key:"listenerCount",value:function(e){return(this._listeners[e]||[]).length}},{key:"removeEvent",value:function(e,t){return 0===arguments.length?this._listeners=Object.create(null):this._removeListener(this._listeners,e,t),this}},{key:"whenReady",value:function(){return this._readyPromise.then(R)}},{key:"getSharedSession",value:function(){return R(this._session)}},{key:"loginIfNeeded",value:function(e,t,r){var n=this;return this.whenReady().then((function(){if(n._destroyed||n._destroying)throw new Error("RTMSharedWorkerClient has been destroyed");return new Promise((function(o,i){var s=++n._callbackSeq,a=function(e){e instanceof Error?i(e):o(e)};a.rejectOnDestroy=!0,n._callbacks.set(s,a);var u=P(e,n._callbacks,n);n._post({type:"login-if-needed",uid:u,credential:t,timeout:r,requestId:s})||(n._callbacks.delete(s),i(new Error("Failed to request shared RTM login")))}))}))}},{key:"setConversation",value:function(e,t){var r=y(e);if(this._destroyed||this._destroying){var n=new Error("RTMSharedWorkerClient has been destroyed");return"function"==typeof t&&t(n),this._emit(this._listeners,"SharedWorkerError",[n]),this}return this._conversation=r,"function"==typeof t&&t(null),this}},{key:"destroy",value:function(){if(!this._destroyed&&!this._destroying){this._destroying=!0;var e=null,t=null;try{this._settleReady(new Error("RTMSharedWorkerClient was destroyed before it became ready"));var r=new Error("RTMSharedWorkerClient was destroyed before the shared login completed");e=this._failPendingCallbacks(r)}finally{try{this._post({type:"detach"},!0)}catch(e){t=e}if(this._destroyed=!0,this._destroying=!1,this._callbacks.clear(),this._listeners=Object.create(null),this._processorListeners=Object.create(null),this._pageWindow&&this._pageHideListener)try{this._pageWindow.removeEventListener("pagehide",this._pageHideListener)}catch(e){t=t||e}this._pageWindow=null,this._pageHideListener=null,this._worker.onerror=null,this._port.onmessage=null,this._port.onmessageerror=null;try{this._port.close()}catch(e){t=t||e}}if(t)throw t;if(e)throw e.error}}},{key:"_addListener",value:function(e,t,r){"function"==typeof r&&(e[t]||(e[t]=[]),-1===e[t].indexOf(r)&&e[t].push(r))}},{key:"_removeListener",value:function(e,t,r){e[t]&&(void 0!==r?(e[t]=e[t].filter((function(e){return e!==r})),0===e[t].length&&delete e[t]):delete e[t])}},{key:"_emit",value:function(e,t,r){(e[t]||[]).slice().forEach((function(e){e.apply(null,r)}))}},{key:"_onMessage",value:function(e){var t=e&&e.data;if(t&&!this._destroyed)if("callback"!==t.type)if("event"!==t.type)if("login-result"!==t.type)if("error"!==t.type){if("ready"===t.type){var r=k(t.session);return this._session=r,this._settleReady(null,r),void this._emit(this._listeners,"SharedWorkerReady",[r])}"session-state"===t.type&&(this._session=k(t.session),this._emit(this._listeners,"SharedSessionState",[R(this._session)]))}else{var n=T(t.error,a),o=null;if(void 0!==t.requestId){var i=this._callbacks.get(t.requestId);i&&(this._callbacks.delete(t.requestId),i(n))}else this._failedError=n,o=this._failPendingCallbacks(n);try{this._settleReady(n),this._emit(this._listeners,"SharedWorkerError",[n])}finally{!0===t.fatal&&this.destroy()}if(o)throw o.error}else{var s=this._callbacks.get(t.requestId);s&&(this._callbacks.delete(t.requestId),s(t.error?T(t.error,a):t.result))}else{var u=T(t.args,a);if("processor"===t.channel&&!m(this._conversation,this._protocol,t.name,u[0]))return;this._emit("processor"===t.channel?this._processorListeners:this._listeners,t.name,u)}else{var c=this._callbacks.get(t.callbackId);c&&(this._callbacks.delete(t.callbackId),c.apply(null,T(t.args,a)))}}},{key:"_onMessageError",value:function(e){var t=new Error("Failed to read a SharedWorker message");t.code="RTM_SHARED_WORKER_MESSAGE_ERROR",t.event=e,this._failedError=t;var r=this._failPendingCallbacks(t);this._settleReady(t);try{this._emit(this._listeners,"SharedWorkerError",[t])}finally{this.destroy()}if(r)throw r.error}},{key:"_onWorkerError",value:function(e){var t=new Error(e&&e.message?"RTM SharedWorker failed to load: "+e.message:"RTM SharedWorker failed to load");t.code="RTM_SHARED_WORKER_LOAD_ERROR",e&&e.filename&&(t.filename=e.filename),e&&e.lineno&&(t.lineno=e.lineno),this._failedError=t;var r=this._failPendingCallbacks(t);this._settleReady(t);try{this._emit(this._listeners,"SharedWorkerError",[t])}finally{this.destroy()}if(r)throw r.error}},{key:"_failPendingCallbacks",value:function(e){var t=this,r=null;return this._callbacks.forEach((function(n,o){if("function"==typeof n.fail||n.rejectOnDestroy){t._callbacks.delete(o);try{"function"==typeof n.fail?n.fail(e):n(e)}catch(e){r||(r={error:e})}}})),r}},{key:"_invoke",value:function(e,t){if(this._destroyed||this._destroying){var r=O("RTMSharedWorkerClient has been destroyed","RTM_SHARED_CLIENT_DESTROYED");return C(e,t,r),void this._emit(this._listeners,"SharedWorkerError",[r])}if(this._failedError)C(e,t,this._failedError);else{var n=this._callbackSeq;this._post({type:"invoke",method:e,args:P(t,this._callbacks,this,e)})||this._failCallbacksSince(n,this._failedError||O("Failed to send request to RTM SharedWorker","RTM_SHARED_WORKER_POST_MESSAGE_ERROR"))}}},{key:"_failCallbacksSince",value:function(e,t){var r=this;this._callbacks.forEach((function(n,o){o<=e||(r._callbacks.delete(o),"function"==typeof n.fail&&n.fail(t))}))}},{key:"_post",value:function(e,t){var r=t&&e&&"detach"===e.type;if((this._destroyed||this._destroying)&&!r)return!1;if(this._failedError&&!r)return!1;try{return this._port.postMessage(e),!0}catch(e){return this._emit(this._listeners,"SharedWorkerError",[e]),!1}}},{key:"_settleReady",value:function(e,t){this._readySettled||(this._readySettled=!0,void 0!==this._readyTimer&&(clearTimeout(this._readyTimer),this._readyTimer=void 0),e?this._rejectReady(e):this._resolveReady(R(t)))}}]),e}();function E(e){if(!e||"object"!==(void 0===e?"undefined":n(e)))throw new Error("createSharedWorkerName requires { pid, uid }");var t=void 0===e.pid||null===e.pid?"":String(e.pid).trim(),r=void 0===e.uid||null===e.uid?"":String(e.uid).trim();if(!t||!r)throw new Error("createSharedWorkerName requires non-empty pid and uid");var o=void 0===e.protocol?"fpnn":e.protocol;if("tlv-v1"!==o&&"fpnn"!==o)throw new Error('createSharedWorkerName protocol must be "tlv-v1" or "fpnn"');var i=String(void 0===e.endpoint||null===e.endpoint?"":e.endpoint);"tlv-v1"===o&&/^wss?:\/\//i.test(i)&&(i=_(i));var s=[String(void 0===e.namespace||null===e.namespace?"":e.namespace),t,r,i];return"fpnn"===o&&s.unshift(o),"rtm-shared:"+s.map((function(e){var t=encodeURIComponent(e);return t.length+":"+t})).join("|")}function k(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 R(e){return{status:e.status,uid:e.uid}}function P(e,t,r,o){if("function"==typeof e){var s=++r._callbackSeq,u=function(){return e.apply(null,arguments)};return u.fail=function(t){"login"===o?e(!1,t.status||a.ERROR_CODE.RTM_EC_UNKNOWN_ERROR):e(t,null)},t.set(s,u),i({},"__rtmSharedWorkerCallback__",s)}if(e&&"object"===(void 0===e?"undefined":n(e))){var c,h;if(f.isInt64BE(e))return i(c={},v,"int64"),i(c,"value",e.toString()),c;if(l.isUint64BE(e))return i(h={},v,"uint64"),i(h,"value",e.toString()),h;if(Array.isArray(e))return e.map((function(e){return P(e,t,r,o)}));if(A(e)){var d={};return Object.keys(e).forEach((function(n){d[n]=P(e[n],t,r,o)})),d}}return e}function C(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 O(e,t){var r=new Error(e);return r.code=t,r}function T(e,t){if(Array.isArray(e))return e.map((function(e){return T(e,t)}));if(!A(e))return e;if("int64"===e[v])return t.Int64(e.value);if("uint64"===e[v])return t.Uint64(e.value);if("error"===e[v]){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]=T(e[r],t)})),n}function A(e){if(null===e||"object"!==(void 0===e?"undefined":n(e)))return!1;var t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}w.createWorkerName=E,Object.getOwnPropertyNames(s.prototype).forEach((function(e){"constructor"===e||"destroy"===e||"_"===e.charAt(0)||Object.prototype.hasOwnProperty.call(w.prototype,e)||"function"==typeof Object.getOwnPropertyDescriptor(s.prototype,e).value&&Object.defineProperty(w.prototype,e,{configurable:!0,enumerable:!1,writable:!0,value:function(){return this._invoke(e,Array.prototype.slice.call(arguments))}})})),e.exports=w},function(e,t,r){"use strict";var n=r(13).normalizeClientOptions,o=r(7).normalizeFpnnEndpoint;e.exports={normalizeClientOptions:n,sharedEndpoint:function(e){return"tlv-v1"===e.protocol?e.tlvEndpoint||e.tlv_endpoint||e.endpoint||e.ssl_endpoint:void 0!==e.ssl_endpoint?"wss://"+e.ssl_endpoint+"/service/websocket":"ws://"+o(e.endpoint)+"/service/websocket"}}},function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};e.exports={getSharedWorkerConfigFallbackReason:function(e){var t=new Set;return function e(r,o){if("function"==typeof r)return o+" is a function; SharedWorker cannot preserve page-side function behavior";if("symbol"===(void 0===r?"undefined":n(r)))return o+" is a symbol and cannot be transferred to SharedWorker";if("bigint"==typeof r)return o+" is a bigint that cannot be compared safely between shared pages";if("number"==typeof r&&!isFinite(r))return o+" is not a finite number and cannot be compared safely between shared pages";if(null==r||"object"!==(void 0===r?"undefined":n(r)))return null;if(t.has(r))return o+" contains a circular reference that cannot be compared safely between shared pages";var i=void 0,s=void 0;try{i=Array.isArray(r),s=Object.getPrototypeOf(r)}catch(e){return o+" cannot be inspected for SharedWorker transfer"}if(i?s!==Array.prototype:s!==Object.prototype&&null!==s)return o+" uses a custom object prototype; SharedWorker cannot preserve its behavior";var a=void 0;try{a=Object.getOwnPropertySymbols(r)}catch(e){return o+" cannot be inspected for SharedWorker transfer"}if(a.length)return o+" contains symbol-keyed data that cannot be transferred reliably";t.add(r);var u=void 0;try{u=Object.keys(r)}catch(e){return t.delete(r),o+" cannot be inspected for SharedWorker transfer"}for(var c=0;c<u.length;c+=1){var f=u[c],l=void 0;try{l=Object.getOwnPropertyDescriptor(r,f)}catch(e){return t.delete(r),o+"."+f+" cannot be inspected for SharedWorker transfer"}if(!l||l.get||l.set)return t.delete(r),o+"."+f+" uses an accessor that cannot be preserved in SharedWorker";var h=i?o+"["+f+"]":o+"."+f,d=void 0;try{d=r[f]}catch(e){return t.delete(r),h+" cannot be inspected for SharedWorker transfer"}var p=e(d,h);if(p)return t.delete(r),p}return t.delete(r),null}(e,"options")}}},function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=r(1),i=o.Int64BE,s=o.Uint64BE;e.exports=function(e){if(null==e)return null;if(!function(e){if(null===e||"object"!==(void 0===e?"undefined":n(e)))return!1;var t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(e)||-1===["direct","group","room"].indexOf(e.type))throw new Error('conversation.type must be "direct", "group", or "room"');var t=e.id,r=void 0;if("string"==typeof t)r=t;else if("number"==typeof t&&function(e){if(Number.isSafeInteger)return Number.isSafeInteger(e);return isFinite(e)&&Math.floor(e)===e&&Math.abs(e)<=9007199254740991}(t))r=String(t);else{if(!("bigint"==typeof t||t&&(i.isInt64BE(t)||s.isUint64BE(t))))throw new Error("conversation.id must be a positive int64 string, safe integer, or RTMConfig.Int64");r=t.toString()}if(!/^\d+$/.test(r)||/^0+$/.test(r))throw new Error("conversation.id must be a positive int64");if((r=r.replace(/^0+(?=\d)/,"")).length>19||19===r.length&&r>"9223372036854775807")throw new Error("conversation.id exceeds the positive int64 range");return{type:e.type,id:r}}},function(e,t,r){"use strict";var n=r(0),o={"tlv-v1":{},fpnn:{}};function i(e,t,r,n){t.forEach((function(t){o[e][t]={type:r,field:n}}))}var s=n.TLV_SERVER_PUSH;i("tlv-v1",[s.recvMessage],"direct","sender"),i("tlv-v1",[s.recvGroupMessage],"group","group_ref"),i("tlv-v1",[s.recvRoomMessage,s.kickOutRoom],"room","room_ref");var a=n.SERVER_PUSH;i("fpnn",[a.recvMessage,a.recvChat,a.recvAudio,a.recvCmd,a.recvFile],"direct","from"),i("fpnn",[a.recvGroupMessage,a.recvGroupChat,a.recvGroupAudio,a.recvGroupCmd,a.recvGroupFile],"group","gid"),i("fpnn",[a.recvRoomMessage,a.recvRoomChat,a.recvRoomAudio,a.recvRoomCmd,a.recvRoomFile,a.kickOutRoom],"room","rid"),e.exports=function(e,t,r,n){if(!e)return!0;var i=o[t],s=i&&Object.prototype.hasOwnProperty.call(i,r)?i[r]:null;if(!s)return!0;var a=n&&n[s.field];return e.type===s.type&&String(a)===e.id}},function(e,t,r){"use strict";var n=r(2),o=r(14),i=r(29),s=o.createWorkerName,a=r(0),u=r(9),c=r(11),f=r(10);e.exports={RTMClient:n,createClient:i,RTMSharedWorkerClient:o,createSharedWorkerName:s,RTMConfig:a,RTMProcessor:u,TLVCodec:c,TLVWebSocketClient:f}},function(e,t,r){"use strict";t.byteLength=function(e){var t=c(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){var t,r,n=c(e),s=n[0],a=n[1],u=new i(function(e,t,r){return 3*(t+r)/4-r}(0,s,a)),f=0,l=a>0?s-4:s;for(r=0;r<l;r+=4)t=o[e.charCodeAt(r)]<<18|o[e.charCodeAt(r+1)]<<12|o[e.charCodeAt(r+2)]<<6|o[e.charCodeAt(r+3)],u[f++]=t>>16&255,u[f++]=t>>8&255,u[f++]=255&t;2===a&&(t=o[e.charCodeAt(r)]<<2|o[e.charCodeAt(r+1)]>>4,u[f++]=255&t);1===a&&(t=o[e.charCodeAt(r)]<<10|o[e.charCodeAt(r+1)]<<4|o[e.charCodeAt(r+2)]>>2,u[f++]=t>>8&255,u[f++]=255&t);return u},t.fromByteArray=function(e){for(var t,r=e.length,o=r%3,i=[],s=0,a=r-o;s<a;s+=16383)i.push(f(e,s,s+16383>a?a:s+16383));1===o?(t=e[r-1],i.push(n[t>>2]+n[t<<4&63]+"==")):2===o&&(t=(e[r-2]<<8)+e[r-1],i.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a<u;++a)n[a]=s[a],o[s.charCodeAt(a)]=a;function c(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function f(e,t,r){for(var o,i,s=[],a=t;a<r;a+=3)o=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),s.push(n[(i=o)>>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return s.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},function(e,t){
9
9
  /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
10
10
  t.read=function(e,t,r,n,o){var i,s,a=8*o-n-1,u=(1<<a)-1,c=u>>1,f=-7,l=r?o-1:0,h=r?-1:1,d=e[t+l];for(l+=h,i=d&(1<<-f)-1,d>>=-f,f+=a;f>0;i=256*i+e[t+l],l+=h,f-=8);for(s=i&(1<<-f)-1,i>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=h,f-=8);if(0===i)i=1-c;else{if(i===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),i-=c}return(d?-1:1)*s*Math.pow(2,i-n)},t.write=function(e,t,r,n,o,i){var s,a,u,c=8*i-o-1,f=(1<<c)-1,l=f>>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:i-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,o),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,o),s=0));o>=8;e[r+d]=255&a,d+=p,a/=256,o-=8);for(s=s<<o|a,c+=o;c>0;e[r+d]=255&s,d+=p,s/=256,c-=8);e[r+d-p]|=128*g}},function(e,t){var r={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},function(e,t,r){"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self&&self,e.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=8)}([function(e,t,r){"use strict";var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),o=r(10).Buffer,i={FPNN_EC_OK:0,FPNN_EC_PROTO_UNKNOWN_ERROR:10001,FPNN_EC_PROTO_NOT_SUPPORTED:10002,FPNN_EC_PROTO_INVALID_PACKAGE:10003,FPNN_EC_PROTO_JSON_CONVERT:10004,FPNN_EC_PROTO_STRING_KEY:10005,FPNN_EC_PROTO_MAP_VALUE:10006,FPNN_EC_PROTO_METHOD_TYPE:10007,FPNN_EC_PROTO_PROTO_TYPE:10008,FPNN_EC_PROTO_KEY_NOT_FOUND:10009,FPNN_EC_PROTO_TYPE_CONVERT:10010,FPNN_EC_CORE_UNKNOWN_ERROR:20001,FPNN_EC_CORE_CONNECTION_CLOSED:20002,FPNN_EC_CORE_TIMEOUT:20003,FPNN_EC_CORE_UNKNOWN_METHOD:20004,FPNN_EC_CORE_ENCODING:20005,FPNN_EC_CORE_DECODING:20006,FPNN_EC_CORE_SEND_ERROR:20007,FPNN_EC_CORE_RECV_ERROR:20008,FPNN_EC_CORE_INVALID_PACKAGE:20009,FPNN_EC_CORE_HTTP_ERROR:20010,FPNN_EC_CORE_WORK_QUEUE_FULL:20011,FPNN_EC_CORE_INVALID_CONNECTION:20012,FPNN_EC_CORE_FORBIDDEN:20013,FPNN_EC_CORE_SERVER_STOPPING:20014},s=o.from([0,1]),a=o.from([64,128]),u=o.from([0,1,2]),c=o.from("FPNN"),f=o.from("POST"),l=["secp256k1","secp224r1"],h=["aes-128-cfb","aes-256-cfb"],d=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return n(e,null,[{key:"SDK_VERSION",get:function(){return"2.0.0"}},{key:"BUFFER",get:function(){return o}},{key:"ERROR_CODE",get:function(){return i}},{key:"FP_FLAG",get:function(){return a}},{key:"FP_MESSAGE_TYPE",get:function(){return u}},{key:"TCP_MAGIC",get:function(){return c}},{key:"HTTP_MAGIC",get:function(){return f}},{key:"FPNN_VERSION",get:function(){return s}},{key:"READ_BUFFER_LEN",get:function(){return 1024}},{key:"CHECK_CBS_INTERVAL",get:function(){return 1e3}},{key:"SEND_TIMEOUT",get:function(){return 2e4}},{key:"CRYPTO_CURVES",get:function(){return l}},{key:"CRYPTO_ALGORITHM",get:function(){return h}}]),e}();e.exports=d},function(e,t,r){"use strict";var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),o=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return n(e,null,[{key:"assign",value:function(e){if(!e||e.hasOwnProperty("events"))throw new Error(e+" is null or hasOwnProperty [ events ]");if(e.hasOwnProperty("on")||e.hasOwnProperty("emit")||e.hasOwnProperty("removeEvent"))throw new Error(e+" hasOwnProperty [ on | emit | removeEvent | listenerCount]");e.events={},e.on=function(t,r){e.events.hasOwnProperty(t)||(e.events[t]=[]),-1==e.events[t].indexOf(r)&&e.events[t].push(r)},e.emit=function(){if(0!=arguments.length)for(var t=e.events[arguments[0]]||[],r=0;r<t.length;r++){var n=t[r];if(n){for(var o=[],i=1;i<arguments.length;i++)o[i-1]=arguments[i];n.apply(e,o)}}},e.removeEvent=function(){if(0!=arguments.length)if(1!=arguments.length){var t=arguments[0],r=e.events[t].indexOf(arguments[1]);r>-1&&e.events[t].splice(r,1)}else{var n=arguments[0];e.events.hasOwnProperty(n)&&delete e.events[n]}else e.events={}},e.listenerCount=function(t){return e.events.hasOwnProperty(t)?(e.events[t]||[]).length:0}}}]),e}();e.exports=o},function(e,t,r){"use strict";function n(e,t){this.code=e,this.name="FPError",this.message=t.message||"",this.stack=t.stack,this.error=t}n.prototype=Object.create(Error.prototype),n.prototype.toString=function(){return"code: "+this.code+" ex: "+this.message},e.exports=n},function(e,t,r){"use strict";var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();r(0);var o=r(1),i=r(4),s=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),o.assign(this),this._endpoint=t.endpoint||null,this._timeout=t.connectionTimeout||1e4,this._platform=t.platformImpl||new i,this._connectTimeout=0,this._queue=[];var r=this;o.assign(this._platform),this._platform.on("open",(function(){c.call(r)})),this._platform.on("message",(function(e){u.call(r,e)})),this._platform.on("close",(function(){f.call(r)})),this._platform.on("error",(function(e){l.call(r,e)}))}return n(e,[{key:"write",value:function(e){if(e)if("[object String]"===Object.prototype.toString.call(e))this._queue.push(e);else{var t=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);this._queue.push(t)}a.call(this)}},{key:"close",value:function(e){e&&this.emit("error",e),this._platform.close()}},{key:"open",value:function(){if(this.isConnecting||this.isOpen||!this._endpoint)this.emit("error",new Error("has connected or worng endpoint!"));else{var e=this;this._connectTimeout&&(clearTimeout(this._connectTimeout),this._connectTimeout=0),this._connectTimeout=setTimeout((function(){var t=new Error("connect timeout!");if(e.isOpen)e.close(t);else{if(e.isConnecting)return e.close(t),void f.call(e);l.call(e,t),f.call(e)}}),this._timeout),this._platform.open(this._endpoint)}}},{key:"destroy",value:function(){this.removeEvent(),this.close(),this._platform.removeEvent(),f.call(this)}},{key:"endpoint",get:function(){return this._endpoint}},{key:"isOpen",get:function(){return this._platform.isOpen}},{key:"isConnecting",get:function(){return this._platform.isConnecting}}]),e}();function a(){if(this.isOpen)for(;this._queue.length;)this._platform.send(this._queue.shift())}function u(e){this.emit("data",e)}function c(){this._connectTimeout&&(clearTimeout(this._connectTimeout),this._connectTimeout=0),a.call(this),this.emit("connect")}function f(){this._connectTimeout&&(clearTimeout(this._connectTimeout),this._connectTimeout=0),this._queue=[],this.emit("close")}function l(e){this.emit("error",e)}e.exports=s},function(e,t,r){"use strict";var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),o=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._socket=null}return n(e,[{key:"open",value:function(e){var t=this;try{this._socket=new WebSocket(e)}catch(e){return void this.emit("error",e)}this._socket.binaryType="arraybuffer",this._socket.onopen=function(e){t.emit("open")},this._socket.onmessage=function(e){t.emit("message",e.data)},this._socket.onclose=function(e){t.emit("close")},this._socket.onerror=function(e){t.emit("error",e)}}},{key:"send",value:function(e){try{this._socket.send(e)}catch(e){return void this.emit("error",e)}}},{key:"close",value:function(){this._socket&&this._socket.close()}},{key:"isOpen",get:function(){return!!this._socket&&this._socket.readyState==WebSocket.OPEN}},{key:"isConnecting",get:function(){return!!this._socket&&this._socket.readyState==WebSocket.CONNECTING}}]),e}();e.exports=o},function(e,t,r){"use strict";var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),o=r(0),i=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return n(e,[{key:"buildPkgData",value:function(e){var t={};return t.magic=e.magic||o.TCP_MAGIC,t.version=e.version||0,t.flag=e.flag||0,t.mtype=e.mtype||0,t.ss=e.ss||0,t.method=e.method||null,t.seq=e.seq||0,t.payload=e.payload||null,t.payload&&(t.psize=o.BUFFER.byteLength(t.payload)),t.method&&(t.ss=o.BUFFER.byteLength(t.method)),t.wpos=0,t}},{key:"cbKey",value:function(e){return e.magic+"_"+e.seq}},{key:"isHTTP",value:function(e){return o.HTTP_MAGIC.equals(e.magic)}},{key:"isTCP",value:function(e){return o.TCP_MAGIC.equals(e.magic)}},{key:"isMsgPack",value:function(e){return 1==e.flag}},{key:"isJson",value:function(e){return 0==e.flag}},{key:"isOneWay",value:function(e){return 0==e.mtype}},{key:"isTwoWay",value:function(e){return 1==e.mtype}},{key:"isQuest",value:function(e){return this.isTwoWay(e)||this.isOneWay(e)}},{key:"isAnswer",value:function(e){return 2==e.mtype}},{key:"isSupportPack",value:function(e){return this.isMsgPack(e)!=this.isJson(e)}},{key:"enCode",value:function(e){return this.isOneWay(e)?this.enCodeOneway(e):this.isTwoWay(e)?this.enCodeTwoway(e):this.isAnswer(e)?this.enCodeAnswer(e):null}},{key:"enCodeOneway",value:function(e){var t=s.call(this,e,12+e.ss+e.psize);e.wpos=t.writeUInt8(e.ss,e.wpos),e.wpos=t.writeUInt32LE(e.psize,e.wpos);var r=o.BUFFER.from(e.method);if(e.wpos+=r.copy(t,e.wpos,0),this.isJson(e)){var n=o.BUFFER.from(e.payload);e.wpos+=n.copy(t,e.wpos,0)}return this.isMsgPack(e)&&(this.wpos+=this.payload.copy(t,this.wpos,0)),t}},{key:"enCodeTwoway",value:function(e){var t=s.call(this,e,16+e.ss+e.psize);e.wpos=t.writeUInt8(e.ss,e.wpos),e.wpos=t.writeUInt32LE(e.psize,e.wpos),e.wpos=t.writeUInt32LE(e.seq,e.wpos);var r=o.BUFFER.from(e.method);if(e.wpos+=r.copy(t,e.wpos,0),this.isJson(e)){var n=o.BUFFER.from(e.payload);e.wpos+=n.copy(t,e.wpos,0)}return this.isMsgPack(e)&&(e.wpos+=e.payload.copy(t,e.wpos,0)),t}},{key:"enCodeAnswer",value:function(e){var t=s.call(this,e,16+e.psize);if(e.wpos=t.writeUInt8(e.ss,e.wpos),e.wpos=t.writeUInt32LE(e.psize,e.wpos),e.wpos=t.writeUInt32LE(e.seq,e.wpos),this.isJson(e)){var r=o.BUFFER.from(e.payload);e.wpos+=r.copy(t,e.wpos,0)}return this.isMsgPack(e)&&(e.wpos+=e.payload.copy(t,e.wpos,0)),t}},{key:"peekHead",value:function(e){var t={},r=0,n=o.BUFFER.allocUnsafe(4);return r+=e.copy(n,0,r,r+4),t.magic=n,n=o.BUFFER.allocUnsafe(1),r+=e.copy(n,0,r,r+1),t.version=o.FPNN_VERSION.indexOf(n),r+=e.copy(n,0,r,r+1),t.flag=o.FP_FLAG.indexOf(n),r+=e.copy(n,0,r,r+1),t.mtype=o.FP_MESSAGE_TYPE.indexOf(n),r+=e.copy(n,0,r,r+1),t.ss=n.readUInt8(0),t.psize=e.readUInt32LE(r),t.wpos=r+4,t}},{key:"deCode",value:function(e){var t=this.peekHead(e);return this.isOneWay(t)&&this.deCodeOneWay(e,t),this.isTwoWay(t)&&this.deCodeTwoWay(e,t),this.isAnswer(t)&&this.deCodeAnswer(e,t),t}},{key:"deCodeOneWay",value:function(e,t){if(e.length==12+t.ss+t.psize){var r=o.BUFFER.allocUnsafe(t.ss);t.wpos+=e.copy(r,0,t.wpos,t.wpos+t.ss),t.method=r.toString();var n=o.BUFFER.allocUnsafe(t.psize);t.wpos+=e.copy(n,0,t.wpos),this.isJson(t)&&(t.payload=n.toString()),this.isMsgPack(t)&&(t.payload=n)}else t=null}},{key:"deCodeTwoWay",value:function(e,t){if(e.length==16+t.ss+t.psize){t.seq=e.readUInt32LE(t.wpos),t.wpos+=4;var r=o.BUFFER.allocUnsafe(t.ss);t.wpos+=e.copy(r,0,t.wpos,t.wpos+t.ss),t.method=r.toString();var n=o.BUFFER.allocUnsafe(t.psize);t.wpos+=e.copy(n,0,t.wpos),this.isJson(t)&&(t.payload=n.toString()),this.isMsgPack(t)&&(t.payload=n)}else t=null}},{key:"deCodeAnswer",value:function(e,t){if(e.length==16+t.psize){t.seq=e.readUInt32LE(t.wpos),t.wpos+=4;var r=o.BUFFER.allocUnsafe(t.psize);t.wpos+=e.copy(r,0,t.wpos),this.isJson(t)&&(t.payload=r.toString()),this.isMsgPack(t)&&(t.payload=r)}else t=null}}]),e}();function s(e,t){var r=o.BUFFER.allocUnsafe(t);return this.isHTTP(e)&&(e.wpos+=o.HTTP_MAGIC.copy(r,e.wpos,0)),this.isTCP(e)&&(e.wpos+=o.TCP_MAGIC.copy(r,e.wpos,0)),e.wpos+=o.FPNN_VERSION.copy(r,e.wpos,e.version,e.version+1),this.isJson(e)&&(e.wpos+=o.FP_FLAG.copy(r,e.wpos,e.flag,e.flag+1)),this.isMsgPack(e)&&(e.wpos+=o.FP_FLAG.copy(r,e.wpos,e.flag,e.flag+1)),e.wpos+=o.FP_MESSAGE_TYPE.copy(r,e.wpos,e.mtype,e.mtype+1),r}e.exports=i},function(e,t,r){"use strict";var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),o=r(0),i=r(2),s=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._cbMap={},this._exMap={},a.call(this)}return n(e,[{key:"addCb",value:function(e,t,r){this._cbMap.hasOwnProperty(e)||(this._cbMap[e]=t),r||(r=o.SEND_TIMEOUT),this._exMap[e]=r+Date.now()}},{key:"removeCb",value:function(e){if(e)f.call(this,e);else for(var t in this._cbMap)u.call(this,t,new i(o.ERROR_CODE.FPNN_EC_CORE_CONNECTION_CLOSED,new Error("Connection Closed")))}},{key:"execCb",value:function(e,t){u.call(this,e,t)}}]),e}();function a(){var e=this;setInterval((function(){for(var t in e._exMap)e._exMap[t]>Date.now()||u.call(e,t,new i(o.ERROR_CODE.FPNN_EC_CORE_TIMEOUT,Error("Timeout")))}),o.CHECK_CBS_INTERVAL)}function u(e,t){var r=this;setTimeout((function(){c.call(r,e,t)}),0)}function c(e,t){if(this._cbMap.hasOwnProperty(e)){var r=this._cbMap[e];l.call(this,e),r&&r(t)}}function f(e){var t=this;setTimeout((function(){l.call(t,e)}),0)}function l(e){this._cbMap.hasOwnProperty(e)&&delete this._cbMap[e],this._exMap.hasOwnProperty(e)&&delete this._exMap[e]}e.exports=s},function(e,t,r){"use strict";var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),o=r(1),i=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),o.assign(this)}return n(e,[{key:"service",value:function(e,t){this.emit(e.method,e.payload,t)}},{key:"destroy",value:function(){}}]),e}();e.exports=i},function(e,t,r){"use strict";var n=r(9),o=r(0),i=r(1),s=r(3),a=r(5),u=r(6),c=r(7),f=r(2),l=r(4),h=r(13);e.exports={FPClient:n,FPConfig:o,FPEvent:i,FPSocket:s,FPPackage:a,FPCallback:u,FPProcessor:c,FPError:f,BrowserImpl:l,WechatImpl:h}},function(e,t,r){"use strict";var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),o=r(0),i=r(1),s=r(3),a=r(5),u=r(6),c=r(7),f=r(2),l=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),i.assign(this),this._autoReconnect=t.autoReconnect||!1,this._conn=new s(t);var r=this;this._conn.on("connect",(function(){d.call(r)})),this._conn.on("close",(function(){p.call(r)})),this._conn.on("data",(function(e){y.call(r,e)})),this._conn.on("error",(function(e){h.call(r,new f(o.ERROR_CODE.FPNN_EC_CORE_UNKNOWN_ERROR,e))})),this._pkg=new a,this._cbs=new u,this._psr=new c,this._seq=0,this._wpos=0,this._peekData=null,this._readID=0,this._reconnectID=0,this._buffer=o.BUFFER.allocUnsafe(o.READ_BUFFER_LEN)}return n(e,[{key:"connect",value:function(){this.hasConnect||this._conn.open()}},{key:"sendQuest",value:function(e,t,r){if(this._conn.isOpen){var n={};n.magic=e.magic||o.TCP_MAGIC,n.version=e.version||1,n.flag=e.flag||0,n.mtype=e.hasOwnProperty("mtype")?e.mtype:1,n.method=e.method,n.seq=e.hasOwnProperty("seq")?e.seq:++this._seq,n.payload=e.payload,n=this._pkg.buildPkgData(n),t&&this._cbs.addCb(this._pkg.cbKey(n),t,r);var i=this._pkg.enCode(n);this._conn.write(i)}else t&&t(new f(o.ERROR_CODE.FPNN_EC_CORE_CONNECTION_CLOSED,new Error("Connection Closed")))}},{key:"sendNotify",value:function(e){var t={};t.magic=e.magic||o.TCP_MAGIC,t.version=e.version||1,t.flag=e.flag||0,t.mtype=e.mtype||0,t.method=e.method,t.payload=e.payload,t=this._pkg.buildPkgData(t);var r=this._pkg.enCode(t);this._conn.write(r)}},{key:"close",value:function(e){e&&h.call(this,e),this._conn.close()}},{key:"destroy",value:function(){this._autoReconnect=!1,this.removeEvent(),this._psr.destroy(),this._conn.destroy(),p.call(this)}},{key:"processor",get:function(){return this._psr},set:function(e){return this._psr=e}},{key:"isOpen",get:function(){return this._conn.isOpen}},{key:"hasConnect",get:function(){return this._conn.isOpen||this._conn.isConnecting}}]),e}();function h(e){this.emit("error",e)}function d(){this._reconnectID&&(clearTimeout(this._reconnectID),this._reconnectID=0),this.emit("connect")}function p(){this._readID&&(clearInterval(this._readID),this._readID=0),this._reconnectID&&(clearTimeout(this._reconnectID),this._reconnectID=0),this._seq=0,this._wpos=0,this._peekData=null,this._cbs.removeCb(),this._buffer=o.BUFFER.allocUnsafe(o.READ_BUFFER_LEN),this.emit("close"),this._autoReconnect&&g.call(this)}function g(){if(!this._reconnectID){var e=this;this._reconnectID=setTimeout((function(){e.connect()}),100)}}function y(e){e=o.BUFFER.from(e);var t=this._wpos+e.length;if(t>this._buffer.length&&m.call(this,t,2*o.READ_BUFFER_LEN),this._wpos+=e.copy(this._buffer,this._wpos,0),!this._readID){var r=this;this._readID=setInterval((function(){_.call(r)}),0)}}function m(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=Math.max(e,t),i=o.BUFFER.allocUnsafe(n);this._wpos=this._buffer.copy(i,0,r,this._wpos),this._buffer=i}function _(){if(!(this._wpos<12))if(this._peekData||(this._peekData=b.call(this,this._buffer),this._peekData)){var e=this._wpos-this._peekData.pkgLen;if(!(e<0)){this._buffer.copy(this._peekData.buffer,0,0,this._peekData.pkgLen);var t=this._pkg.deCode(this._peekData.buffer);if(m.call(this,2*e,o.READ_BUFFER_LEN,this._peekData.pkgLen),delete this._peekData,this._peekData=null,this._pkg.isAnswer(t)){var r=this._pkg.cbKey(t);this._cbs.execCb(r,t)}if(this._pkg.isQuest(t)){var n=this;this._psr.service(t,(function(e,r){v.call(n,t.flag,t.seq,e,r)}))}}}else this.conn.close(new f(o.ERROR_CODE.FPNN_EC_PROTO_INVALID_PACKAGE,new Error("Invalid Protocol Package")))}function v(e,t,r,n){var o={flag:e,mtype:2,seq:t,ss:(n=n||!1)?1:0,payload:r};this.sendQuest(o)}function b(e){var t=null;if(e.length>=12){if(t=this._pkg.peekHead(e),!w.call(this,t))return null;this._pkg.isOneWay(t)&&(t.pkgLen=12+t.ss+t.psize),this._pkg.isTwoWay(t)&&(t.pkgLen=16+t.ss+t.psize),this._pkg.isAnswer(t)&&(t.pkgLen=16+t.psize),t.pkgLen>0&&(t.buffer=o.BUFFER.allocUnsafe(t.pkgLen))}return t}function w(e){return!(!o.TCP_MAGIC.equals(e.magic)&&!o.HTTP_MAGIC.equals(e.magic)||e.version<0||e.version>=o.FPNN_VERSION.length||e.flag<0||e.flag>=o.FP_FLAG.length||e.mtype<0||e.mtype>=o.FP_MESSAGE_TYPE.length)}e.exports=l},function(e,t,r){"use strict";
11
11
  /*!
@@ -24,4 +24,4 @@ t.read=function(e,t,r,n,o){var i,s,a=8*o-n-1,u=(1<<a)-1,c=u>>1,f=-7,l=r?o-1:0,h=
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__(27),a=!i.JS_MD5_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,n="0123456789abcdef".split(""),u=[128,32768,8388608,-2147483648],y=[0,8,16,24],c=["hex","array","digest","buffer","arrayBuffer","base64"],p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),d=[],l;if(a){var A=new ArrayBuffer(68);l=new Uint8Array(A),d=new Uint32Array(A)}!i.JS_MD5_NO_NODE_JS&&Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),!a||!i.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(e){return"object"==typeof e&&e.buffer&&e.buffer.constructor===ArrayBuffer});var b=function(e){return function(r){return new t(!0).update(r)[e]()}},v=function(){var e=b("hex");h&&(e=w(e)),e.create=function(){return new t},e.update=function(t){return e.create().update(t)};for(var r=0;r<c.length;++r){var n=c[r];e[n]=b(n)}return e},w=function(t){var e=eval("require('crypto')"),i=eval("require('buffer').Buffer"),s=function(n){if("string"==typeof n)return e.createHash("md5").update(n,"utf8").digest("hex");if(null==n)throw r;return n.constructor===ArrayBuffer&&(n=new Uint8Array(n)),Array.isArray(n)||ArrayBuffer.isView(n)||n.constructor===i?e.createHash("md5").update(new i(n)).digest("hex"):t(n)};return s};t.prototype.update=function(e){if(!this.finalized){var t,n=typeof e;if("string"!==n){if("object"!==n)throw r;if(null===e)throw r;if(a&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||a&&ArrayBuffer.isView(e)))throw r;t=!0}for(var o,i,s=0,u=e.length,c=this.blocks,f=this.buffer8;s<u;){if(this.hashed&&(this.hashed=!1,c[0]=c[16],c[16]=c[1]=c[2]=c[3]=c[4]=c[5]=c[6]=c[7]=c[8]=c[9]=c[10]=c[11]=c[12]=c[13]=c[14]=c[15]=0),t)if(a)for(i=this.start;s<u&&i<64;++s)f[i++]=e[s];else for(i=this.start;s<u&&i<64;++s)c[i>>2]|=e[s]<<y[3&i++];else if(a)for(i=this.start;s<u&&i<64;++s)(o=e.charCodeAt(s))<128?f[i++]=o:o<2048?(f[i++]=192|o>>6,f[i++]=128|63&o):o<55296||o>=57344?(f[i++]=224|o>>12,f[i++]=128|o>>6&63,f[i++]=128|63&o):(o=65536+((1023&o)<<10|1023&e.charCodeAt(++s)),f[i++]=240|o>>18,f[i++]=128|o>>12&63,f[i++]=128|o>>6&63,f[i++]=128|63&o);else for(i=this.start;s<u&&i<64;++s)(o=e.charCodeAt(s))<128?c[i>>2]|=o<<y[3&i++]:o<2048?(c[i>>2]|=(192|o>>6)<<y[3&i++],c[i>>2]|=(128|63&o)<<y[3&i++]):o<55296||o>=57344?(c[i>>2]|=(224|o>>12)<<y[3&i++],c[i>>2]|=(128|o>>6&63)<<y[3&i++],c[i>>2]|=(128|63&o)<<y[3&i++]):(o=65536+((1023&o)<<10|1023&e.charCodeAt(++s)),c[i>>2]|=(240|o>>18)<<y[3&i++],c[i>>2]|=(128|o>>12&63)<<y[3&i++],c[i>>2]|=(128|o>>6&63)<<y[3&i++],c[i>>2]|=(128|63&o)<<y[3&i++]);this.lastByteIndex=i,this.bytes+=i-this.start,i>=64?(this.start=i-64,this.hash(),this.hashed=!0):this.start=i}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}},t.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex;e[t>>2]|=u[3&t],t>=56&&(this.hashed||this.hash(),e[0]=e[16],e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=this.bytes<<3,e[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},t.prototype.hash=function(){var e,t,r,n,o,i,s=this.blocks;this.first?t=((t=((e=((e=s[0]-680876937)<<7|e>>>25)-271733879<<0)^(r=((r=(-271733879^(n=((n=(-1732584194^2004318071&e)+s[1]-117830708)<<12|n>>>20)+e<<0)&(-271733879^e))+s[2]-1126478375)<<17|r>>>15)+n<<0)&(n^e))+s[3]-1316259209)<<22|t>>>10)+r<<0:(e=this.h0,t=this.h1,r=this.h2,t=((t+=((e=((e+=((n=this.h3)^t&(r^n))+s[0]-680876936)<<7|e>>>25)+t<<0)^(r=((r+=(t^(n=((n+=(r^e&(t^r))+s[1]-389564586)<<12|n>>>20)+e<<0)&(e^t))+s[2]+606105819)<<17|r>>>15)+n<<0)&(n^e))+s[3]-1044525330)<<22|t>>>10)+r<<0),t=((t+=((e=((e+=(n^t&(r^n))+s[4]-176418897)<<7|e>>>25)+t<<0)^(r=((r+=(t^(n=((n+=(r^e&(t^r))+s[5]+1200080426)<<12|n>>>20)+e<<0)&(e^t))+s[6]-1473231341)<<17|r>>>15)+n<<0)&(n^e))+s[7]-45705983)<<22|t>>>10)+r<<0,t=((t+=((e=((e+=(n^t&(r^n))+s[8]+1770035416)<<7|e>>>25)+t<<0)^(r=((r+=(t^(n=((n+=(r^e&(t^r))+s[9]-1958414417)<<12|n>>>20)+e<<0)&(e^t))+s[10]-42063)<<17|r>>>15)+n<<0)&(n^e))+s[11]-1990404162)<<22|t>>>10)+r<<0,t=((t+=((e=((e+=(n^t&(r^n))+s[12]+1804603682)<<7|e>>>25)+t<<0)^(r=((r+=(t^(n=((n+=(r^e&(t^r))+s[13]-40341101)<<12|n>>>20)+e<<0)&(e^t))+s[14]-1502002290)<<17|r>>>15)+n<<0)&(n^e))+s[15]+1236535329)<<22|t>>>10)+r<<0,t=((t+=((n=((n+=(t^r&((e=((e+=(r^n&(t^r))+s[1]-165796510)<<5|e>>>27)+t<<0)^t))+s[6]-1069501632)<<9|n>>>23)+e<<0)^e&((r=((r+=(e^t&(n^e))+s[11]+643717713)<<14|r>>>18)+n<<0)^n))+s[0]-373897302)<<20|t>>>12)+r<<0,t=((t+=((n=((n+=(t^r&((e=((e+=(r^n&(t^r))+s[5]-701558691)<<5|e>>>27)+t<<0)^t))+s[10]+38016083)<<9|n>>>23)+e<<0)^e&((r=((r+=(e^t&(n^e))+s[15]-660478335)<<14|r>>>18)+n<<0)^n))+s[4]-405537848)<<20|t>>>12)+r<<0,t=((t+=((n=((n+=(t^r&((e=((e+=(r^n&(t^r))+s[9]+568446438)<<5|e>>>27)+t<<0)^t))+s[14]-1019803690)<<9|n>>>23)+e<<0)^e&((r=((r+=(e^t&(n^e))+s[3]-187363961)<<14|r>>>18)+n<<0)^n))+s[8]+1163531501)<<20|t>>>12)+r<<0,t=((t+=((n=((n+=(t^r&((e=((e+=(r^n&(t^r))+s[13]-1444681467)<<5|e>>>27)+t<<0)^t))+s[2]-51403784)<<9|n>>>23)+e<<0)^e&((r=((r+=(e^t&(n^e))+s[7]+1735328473)<<14|r>>>18)+n<<0)^n))+s[12]-1926607734)<<20|t>>>12)+r<<0,t=((t+=((i=(n=((n+=((o=t^r)^(e=((e+=(o^n)+s[5]-378558)<<4|e>>>28)+t<<0))+s[8]-2022574463)<<11|n>>>21)+e<<0)^e)^(r=((r+=(i^t)+s[11]+1839030562)<<16|r>>>16)+n<<0))+s[14]-35309556)<<23|t>>>9)+r<<0,t=((t+=((i=(n=((n+=((o=t^r)^(e=((e+=(o^n)+s[1]-1530992060)<<4|e>>>28)+t<<0))+s[4]+1272893353)<<11|n>>>21)+e<<0)^e)^(r=((r+=(i^t)+s[7]-155497632)<<16|r>>>16)+n<<0))+s[10]-1094730640)<<23|t>>>9)+r<<0,t=((t+=((i=(n=((n+=((o=t^r)^(e=((e+=(o^n)+s[13]+681279174)<<4|e>>>28)+t<<0))+s[0]-358537222)<<11|n>>>21)+e<<0)^e)^(r=((r+=(i^t)+s[3]-722521979)<<16|r>>>16)+n<<0))+s[6]+76029189)<<23|t>>>9)+r<<0,t=((t+=((i=(n=((n+=((o=t^r)^(e=((e+=(o^n)+s[9]-640364487)<<4|e>>>28)+t<<0))+s[12]-421815835)<<11|n>>>21)+e<<0)^e)^(r=((r+=(i^t)+s[15]+530742520)<<16|r>>>16)+n<<0))+s[2]-995338651)<<23|t>>>9)+r<<0,t=((t+=((n=((n+=(t^((e=((e+=(r^(t|~n))+s[0]-198630844)<<6|e>>>26)+t<<0)|~r))+s[7]+1126891415)<<10|n>>>22)+e<<0)^((r=((r+=(e^(n|~t))+s[14]-1416354905)<<15|r>>>17)+n<<0)|~e))+s[5]-57434055)<<21|t>>>11)+r<<0,t=((t+=((n=((n+=(t^((e=((e+=(r^(t|~n))+s[12]+1700485571)<<6|e>>>26)+t<<0)|~r))+s[3]-1894986606)<<10|n>>>22)+e<<0)^((r=((r+=(e^(n|~t))+s[10]-1051523)<<15|r>>>17)+n<<0)|~e))+s[1]-2054922799)<<21|t>>>11)+r<<0,t=((t+=((n=((n+=(t^((e=((e+=(r^(t|~n))+s[8]+1873313359)<<6|e>>>26)+t<<0)|~r))+s[15]-30611744)<<10|n>>>22)+e<<0)^((r=((r+=(e^(n|~t))+s[6]-1560198380)<<15|r>>>17)+n<<0)|~e))+s[13]+1309151649)<<21|t>>>11)+r<<0,t=((t+=((n=((n+=(t^((e=((e+=(r^(t|~n))+s[4]-145523070)<<6|e>>>26)+t<<0)|~r))+s[11]-1120210379)<<10|n>>>22)+e<<0)^((r=((r+=(e^(n|~t))+s[2]+718787259)<<15|r>>>17)+n<<0)|~e))+s[9]-343485551)<<21|t>>>11)+r<<0,this.first?(this.h0=e+1732584193<<0,this.h1=t-271733879<<0,this.h2=r-1732584194<<0,this.h3=n+271733878<<0,this.first=!1):(this.h0=this.h0+e<<0,this.h1=this.h1+t<<0,this.h2=this.h2+r<<0,this.h3=this.h3+n<<0)},t.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,o=this.h3;return n[e>>4&15]+n[15&e]+n[e>>12&15]+n[e>>8&15]+n[e>>20&15]+n[e>>16&15]+n[e>>28&15]+n[e>>24&15]+n[t>>4&15]+n[15&t]+n[t>>12&15]+n[t>>8&15]+n[t>>20&15]+n[t>>16&15]+n[t>>28&15]+n[t>>24&15]+n[r>>4&15]+n[15&r]+n[r>>12&15]+n[r>>8&15]+n[r>>20&15]+n[r>>16&15]+n[r>>28&15]+n[r>>24&15]+n[o>>4&15]+n[15&o]+n[o>>12&15]+n[o>>8&15]+n[o>>20&15]+n[o>>16&15]+n[o>>28&15]+n[o>>24&15]},t.prototype.toString=t.prototype.hex,t.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,n=this.h3;return[255&e,e>>8&255,e>>16&255,e>>24&255,255&t,t>>8&255,t>>16&255,t>>24&255,255&r,r>>8&255,r>>16&255,r>>24&255,255&n,n>>8&255,n>>16&255,n>>24&255]},t.prototype.array=t.prototype.digest,t.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(16),t=new Uint32Array(e);return t[0]=this.h0,t[1]=this.h1,t[2]=this.h2,t[3]=this.h3,e},t.prototype.buffer=t.prototype.arrayBuffer,t.prototype.base64=function(){for(var e,t,r,n="",o=this.array(),i=0;i<15;)e=o[i++],t=o[i++],r=o[i++],n+=p[e>>>2]+p[63&(e<<4|t>>>4)]+p[63&(t<<2|r>>>6)]+p[63&r];return e=o[i],n+(p[e>>>2]+p[e<<4&63]+"==")};var _=v();f?module.exports=_:(i.md5=_,o&&(__WEBPACK_AMD_DEFINE_RESULT__=function(){return _}.call(exports,__webpack_require__,exports,module),void 0===__WEBPACK_AMD_DEFINE_RESULT__||(module.exports=__WEBPACK_AMD_DEFINE_RESULT__)))}()}).call(this,__webpack_require__(26),__webpack_require__(3))},function(e,t){var r,n,o=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(e){if(r===setTimeout)return setTimeout(e,0);if((r===i||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:i}catch(e){r=i}try{n="function"==typeof clearTimeout?clearTimeout:s}catch(e){n=s}}();var u,c=[],f=!1,l=-1;function h(){f&&u&&(f=!1,u.length?c=u.concat(c):l=-1,c.length&&d())}function d(){if(!f){var e=a(h);f=!0;for(var t=c.length;t;){for(u=c,c=[];++l<t;)u&&u[l].run();l=-1,t=c.length}u=null,f=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===s||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function p(e,t){this.fun=e,this.array=t}function g(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];c.push(new p(e,t)),1!==c.length||f||a(d)},p.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=g,o.addListener=g,o.once=g,o.off=g,o.removeListener=g,o.removeAllListeners=g,o.emit=g,o.prependListener=g,o.prependOnceListener=g,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,t){(function(t){e.exports=t}).call(this,{})},function(e,t,r){(function(e){!function(t){function r(e,r,g){function _(e,t,r,n){return this instanceof _?function(e,t,r,n,o){if(h&&d&&(t instanceof d&&(t=new h(t)),n instanceof d&&(n=new h(n))),t||r||n||c){if(!s(t,r))o=r,n=t,r=0,t=new(c||Array)(8);e.buffer=t,e.offset=r|=0,f!==typeof n&&("string"==typeof n?function(e,t,r,n){var o=0,i=r.length,s=0,a=0;"-"===r[0]&&o++;for(var u=o;o<i;){var c=parseInt(r[o++],n);if(!(c>=0))break;a=a*n+c,s=s*n+Math.floor(a/y),a%=y}u&&(s=~s,a?a=y-a:s++),b(e,t+E,s),b(e,t+k,a)}(t,r,n,o||10):s(n,o)?a(t,r,n,o):"number"==typeof o?(b(t,r+E,n),b(t,r+k,o)):n>0?T(t,r,n):n<0?A(t,r,n):a(t,r,p,0))}else e.buffer=u(p,0)}(this,e,t,r,n):new _(e,t,r,n)}function v(){var e=this.buffer,t=this.offset,r=w(e,t+E),n=w(e,t+k);return g||(r|=0),r?r*y+n:n}function b(e,t,r){e[t+O]=255&r,r>>=8,e[t+C]=255&r,r>>=8,e[t+P]=255&r,r>>=8,e[t+R]=255&r}function w(e,t){return e[t+R]*m+(e[t+P]<<16)+(e[t+C]<<8)+e[t+O]}var E=r?0:4,k=r?4:0,R=r?0:3,P=r?1:2,C=r?2:1,O=r?3:0,T=r?function(e,t,r){for(var n=t+8;n>t;)e[--n]=255&r,r/=256}:function(e,t,r){for(var n=t+8;t<n;)e[t++]=255&r,r/=256},A=r?function(e,t,r){var n=t+8;for(r++;n>t;)e[--n]=255&-r^255,r/=256}:function(e,t,r){var n=t+8;for(r++;t<n;)e[t++]=255&-r^255,r/=256},S=_.prototype,M="is"+e,I="_"+M;return S.buffer=void 0,S.offset=0,S[I]=!0,S.toNumber=v,S.toString=function(e){var t=this.buffer,r=this.offset,n=w(t,r+E),o=w(t,r+k),i="",s=!g&&2147483648&n;for(s&&(n=~n,o=y-o),e=e||10;;){var a=n%e*y+o;if(n=Math.floor(n/e),o=Math.floor(a/e),i=(a%e).toString(e)+i,!n&&!o)break}return s&&(i="-"+i),i},S.toJSON=v,S.toArray=n,l&&(S.toBuffer=o),h&&(S.toArrayBuffer=i),_[M]=function(e){return!(!e||!e[I])},t[e]=_,_}function n(e){var t=this.buffer,r=this.offset;return c=null,!1!==e&&0===r&&8===t.length&&g(t)?t:u(t,r)}function o(t){var r=this.buffer,n=this.offset;if(c=l,!1!==t&&0===n&&8===r.length&&e.isBuffer(r))return r;var o=new l(8);return a(o,0,r,n),o}function i(e){var t=this.buffer,r=this.offset,n=t.buffer;if(c=h,!1!==e&&0===r&&n instanceof d&&8===n.byteLength)return n;var o=new h(8);return a(o,0,t,r),o.buffer}function s(e,t){var r=e&&e.length;return t|=0,r&&t+8<=r&&"string"!=typeof e[t]}function a(e,t,r,n){t|=0,n|=0;for(var o=0;o<8;o++)e[t++]=255&r[n++]}function u(e,t){return Array.prototype.slice.call(e,t,t+8)}var c,f="undefined",l=f!==typeof e&&e,h=f!==typeof Uint8Array&&Uint8Array,d=f!==typeof ArrayBuffer&&ArrayBuffer,p=[0,0,0,0,0,0,0,0],g=Array.isArray||function(e){return!!e&&"[object Array]"==Object.prototype.toString.call(e)},y=4294967296,m=16777216;r("Uint64BE",!0,!0),r("Int64BE",!0,!1),r("Uint64LE",!1,!0),r("Int64LE",!1,!1)}("string"!=typeof t.nodeName?t:this||{})}).call(this,r(8).Buffer)},function(e,t,r){"use strict";var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=r(2),s=r(14),a=r(0),u=r(6),c=r(15),f=c.normalizeClientOptions,l=c.sharedEndpoint,h=r(16).getSharedWorkerConfigFallbackReason,d=r(17),p=r(18),g=r(30),y=["sharing","uid","conversation","workerName","workerUrl","workerNamespace","readyTimeout","idleShutdownTimeout","compatibility"],m=function(){function e(t,r){var n,s,a=this;o(this,e),this._connectionInfo=Object.freeze(Object.assign({},r)),this._usesSharedWorker="shared"===this._connectionInfo.mode,this._config=Object.assign({},t),this._compatibility=g.validateCompatibility(t.compatibility),this._legacyTlv=g.isEnabled(this._compatibility,t.protocol),this._options=f(v(t)),this._config.conversation=d(t.conversation),this._delegate=null,this._delegateType=null,this._uid=null,this._session={status:"idle",uid:null},this._directLoginPromise=null,this._destroyed=!1,this._events=new _,this.processor=new _(this._legacyTlv?g.createPushAdapter((function(e){return a.processor.emit("CompatibilityError",e)})):null),this.promises=(n=this,(s=Object.assign({},u(n,i.prototype))).login=function(e,t,r){return arguments.length>3?Promise.reject(new TypeError("promises.login(uid, credential, timeout?)")):n.loginIfNeeded(e,t,r).then((function(e){if(e.accepted)return{accepted:!0,errorCode:e.errorCode||0};var t=new Error("RTM login rejected ("+String(e.errorCode)+")");throw t.code=e.errorCode,t.status=e.errorCode,t}))},Object.freeze(s)),void 0!==t.uid&&null!==t.uid&&this._attach(t.uid)}return n(e,[{key:"_attach",value:function(e){var t=this;if(this._assertActive(),"number"==typeof e&&(!isFinite(e)||Math.floor(e)!==e||Math.abs(e)>9007199254740991))throw b("Use a decimal string for a UID outside the safe integer range","RTM_SHARED_UID_INVALID");var r=null==e?"":String(e).trim().replace(/^0+(?=\d)/,"");if(!/^\d+$/.test(r)||/^0+$/.test(r))throw b("Provide a positive UID in login() or createClient({ uid }) before attaching","RTM_SHARED_UID_REQUIRED");if(r.length>20||20===r.length&&r>"18446744073709551615")throw b("UID exceeds the uint64 range","RTM_SHARED_UID_INVALID");if(null!==this._uid&&this._uid!==r)throw b("This client is bound to UID "+this._uid+"; create another client for UID "+r,"RTM_SHARED_UID_MISMATCH");if(!this._delegate){var n=this._config,o=this._usesSharedWorker?new s({workerName:n.workerName||s.createWorkerName({pid:this._options.pid,protocol:this._options.protocol,uid:r,endpoint:l(this._options),namespace:n.workerNamespace}),workerUrl:n.workerUrl,conversation:n.conversation,readyTimeout:n.readyTimeout,idleShutdownTimeout:n.idleShutdownTimeout,clientOptions:this._options}):new i(this._options);this._uid=r,this._delegate=o,this._delegateType=this._usesSharedWorker?"shared":"direct","direct"===this._delegateType&&o.on("SessionClosed",(function(){t._session={status:"idle",uid:null}})),this._events.bind(o);var a="direct"===this._delegateType?function(e,r){return p(t._config.conversation,t._options.protocol,e,r[0])}:null;this.processor.bind(o.processor,a)}return this._delegate}},{key:"_assertActive",value:function(){if(this._destroyed)throw b("RTM client has been destroyed","RTM_CLIENT_DESTROYED")}},{key:"login",value:function(e,t,r,n){var o=this;this.loginIfNeeded(e,t,n).then((function(e){"function"==typeof r&&r(e.accepted,e.errorCode)}),(function(e){var t="number"==typeof e.status?e.status:"number"==typeof e.code?e.code:a.ERROR_CODE.RTM_EC_UNKNOWN_ERROR;try{"function"==typeof r&&r(!1,t)}finally{o._usesSharedWorker&&o._events.emit("SharedWorkerError",e)}}))}},{key:"loginIfNeeded",value:function(e,t,r){try{var n=this._attach(e),o=this._uid.length>19||19===this._uid.length&&this._uid>"9223372036854775807"?a.Uint64(this._uid):a.Int64(this._uid);return this._usesSharedWorker?n.loginIfNeeded(o,t,r):this._loginDirect(n,o,t,r)}catch(e){return Promise.reject(e)}}},{key:"_loginDirect",value:function(e,t,r,n){var o=this;if("authenticated"===this._session.status)return Promise.resolve({accepted:!0,errorCode:0,reused:!0,uid:this._uid});if("connecting"===this._session.status&&this._directLoginPromise)return this._directLoginPromise;if("string"!=typeof r||0===r.length)return Promise.reject(b("This RTM UID is not logged in yet; provide its server-issued credential first.","RTM_SHARED_CREDENTIAL_REQUIRED"));this._session={status:"connecting",uid:this._uid};var i=new Promise((function(i,s){var a=!1;try{e.login(t,r,(function(e,t){a||(a=!0,o._session=e?{status:"authenticated",uid:o._uid}:{status:"idle",uid:null},i({accepted:Boolean(e),errorCode:t||0,reused:!1,uid:e?o._uid:null}))}),n)}catch(e){o._session={status:"idle",uid:null},s(e)}}));return this._directLoginPromise=i.then((function(e){return o._directLoginPromise=null,e}),(function(e){throw o._directLoginPromise=null,e})),this._directLoginPromise}},{key:"whenReady",value:function(e){try{var t=this._attach(void 0===e?this._uid:e);return this._usesSharedWorker?t.whenReady():Promise.resolve({status:this._session.status,uid:this._session.uid})}catch(e){return Promise.reject(e)}}},{key:"getSharedSession",value:function(){return"shared"===this._delegateType?this._delegate.getSharedSession():{status:this._session.status,uid:this._session.uid}}},{key:"getConnectionInfo",value:function(){return{mode:this._connectionInfo.mode,fallbackReason:this._connectionInfo.fallbackReason}}},{key:"setConversation",value:function(e,t){return this._assertActive(),e=d(e),"shared"===this._delegateType?this._delegate.setConversation(e,t):(this._config.conversation=e,"function"==typeof t&&t(null)),this}},{key:"on",value:function(e,t){return this._events.on(e,t),this}},{key:"off",value:function(e,t){return this._events.off(e,t),this}},{key:"removeEvent",value:function(){return this._events.removeEvent.apply(this._events,arguments),this}},{key:"emit",value:function(){this._events.emit.apply(this._events,arguments)}},{key:"listenerCount",value:function(e){return this._events.listenerCount(e)}},{key:"close",value:function(){this._assertActive(),this._delegate&&this._delegate.close()}},{key:"startAutoReconnect",value:function(){this._assertActive(),this._delegate&&this._delegate.startAutoReconnect()}},{key:"destroy",value:function(){if(!this._destroyed){this._destroyed=!0;try{this._delegate&&this._delegate.destroy()}finally{this._events.clear(),this.processor.clear()}}}},{key:"_invoke",value:function(e,t){var r=this;try{if(this._assertActive(),!this._delegate)throw b("Call login() before "+e+"()","RTM_SHARED_UID_REQUIRED")}catch(e){var n=t.slice().reverse().find((function(e){return"function"==typeof e}));if(n)return void n(e,null);throw e}return this._legacyTlv?g.invoke(e,t,this._delegate,this._options.protocol,-1,(function(e){return r.processor.emit("CompatibilityError",e)})):this._delegate[e].apply(this._delegate,t)}}]),e}(),_=function(){function e(t){o(this,e),this._listeners=Object.create(null),this._bindings=Object.create(null),this._target=null,this._filter=null,this._eventAdapter=t||null}return n(e,[{key:"bind",value:function(e,t){var r=this;this._target=e,this._filter="function"==typeof t?t:null,Object.keys(this._listeners).forEach((function(e){r._listeners[e].forEach((function(t){return r._bind(e,t)}))}))}},{key:"_bind",value:function(e,t){var r=this,n=this._eventAdapter&&this._eventAdapter.bind(e,t);if(n&&n.local){(this._bindings[e]||(this._bindings[e]=[])).push({callback:t,local:!0})}else{var o=n?n.type:e,i=n?n.callback:t,s=this._filter?function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];r._filter(o,t)&&i.apply(null,t)}:i;(this._bindings[e]||(this._bindings[e]=[])).push({callback:t,sourceType:o,wrapped:s}),this._target.on(o,s)}}},{key:"_unbind",value:function(e,t){var r=this,n=this._bindings[e]||[];n.slice().forEach((function(e){void 0!==t&&t!==e.callback||(e.local||("function"!=typeof r._target.listenerCount||r._target.listenerCount(e.sourceType)>0)&&r._target.removeEvent(e.sourceType,e.wrapped),n.splice(n.indexOf(e),1))})),n.length||delete this._bindings[e]}},{key:"on",value:function(e,t){if("function"!=typeof t)return this;this._eventAdapter&&"function"==typeof this._eventAdapter.validate&&this._eventAdapter.validate(e);var r=this._listeners[e]||(this._listeners[e]=[]);return-1===r.indexOf(t)&&(r.push(t),this._target&&this._bind(e,t)),this}},{key:"off",value:function(e,t){var r=this,n=this._listeners[e]||[];return n.slice().forEach((function(o){void 0!==t&&o!==t||(r._target&&r._unbind(e,o),n.splice(n.indexOf(o),1))})),n.length||delete this._listeners[e],this}},{key:"removeEvent",value:function(e,t){var r=this;return arguments.length?this.off(e,t):(Object.keys(this._listeners).forEach((function(e){return r.off(e)})),this)}},{key:"emit",value:function(e){var t=Array.prototype.slice.call(arguments,1);(this._listeners[e]||[]).slice().forEach((function(e){return e.apply(null,t)}))}},{key:"listenerCount",value:function(e){return(this._listeners[e]||[]).length}},{key:"clear",value:function(){var e=this;this._target&&Object.keys(this._bindings).forEach((function(t){return e._unbind(t)})),this._target=null,this._filter=null,this._listeners=Object.create(null),this._bindings=Object.create(null)}}]),e}();function v(e){var t=Object.assign({},e);return y.forEach((function(e){delete t[e]})),t}function b(e,t){var r=new Error(e);return r.code=t,r}Object.getOwnPropertyNames(i.prototype).forEach((function(e){"constructor"===e||"_"===e.charAt(0)||Object.prototype.hasOwnProperty.call(m.prototype,e)||"function"==typeof Object.getOwnPropertyDescriptor(i.prototype,e).value&&(m.prototype[e]=function(){return this._invoke(e,Array.prototype.slice.call(arguments))})})),e.exports=function(e){var t=Object.assign({},e||{});if(t.compatibility=g.validateCompatibility(t.compatibility),void 0===t.protocol&&(t.protocol="fpnn"),void 0!==t.sharing&&"boolean"!=typeof t.sharing)throw new TypeError("sharing must be a boolean");var r=f(v(t)),n="shared",o=null;return!1===t.sharing?n="direct":"function"!=typeof SharedWorker?(n="direct",o="SharedWorker is unavailable in this runtime"):(o=h(r))&&(n="direct"),new m(t,{mode:n,fallbackReason:o})}},function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};var o=r(0),i=r(12),s={login:"auth",bye:"bye",getServerTime:"getservertime",addAttrs:"addattrs",getAttrs:"getattrs",addDebugLog:"adddebuglog",getOnlineUsers:"getonlineusers",setUserInfo:"setuserinfo",getUserInfo:"getuserinfo",getUserOpenInfo:"getuseropeninfo",setTranslationLanguage:"setlang",dataSet:"dataset",dataGet:"dataget",dataDelete:"datadel",addBlacks:"addblacks",deleteBlacks:"delblacks",getBlacks:"getblacks",addGroupMembers:"addgroupmembers",deleteGroupMembers:"delgroupmembers",getGroupMembers:"getgroupmembers",getGroupCount:"getgroupcount",getUserGroups:"getusergroups",enterRoom:"enterroom",enterRooms:"enterrooms",leaveRoom:"leaveroom",getUserRooms:"getuserrooms",getRoomMembers:"getroommembers",getRoomCount:"getroomcount",setGroupInfo:"setgroupinfo",getGroupInfo:"getgroupinfo",getGroupOpenInfo:"getgroupopeninfo",getGroupsOpenInfo:"getgroupsopeninfo",setRoomInfo:"setroominfo",setRoomProfile:"setroominfo",getRoomInfo:"getroominfo",getRoomOpenInfo:"getroomopeninfo",getRoomsOpenInfo:"getroomsopeninfo",getUserRoomsAndLastMessage:"getuserroomsandlastmsg",sendMessage:"sendmsg",sendMessages:"sendmsgs",sendGroupMessage:"sendgroupmsg",sendRoomMessage:"sendroommsg",sendChat:"sendmsg",sendAudio:"sendmsg",sendCmd:"sendmsg",sendGroupChat:"sendgroupmsg",sendGroupAudio:"sendgroupmsg",sendGroupCmd:"sendgroupmsg",sendRoomChat:"sendroommsg",sendRoomAudio:"sendroommsg",sendRoomCmd:"sendroommsg",getUnreadMessage:"getunread",getP2PUnreadMessageNum:"getp2punread",getGroupUnreadMessageNum:"getgroupunread",cleanUnreadMessage:"cleanunread",setSessionRead:"setsessionread",getSession:"getsession",getGroupMessage:"getgroupmsg",getRoomMessage:"getroommsg",getBroadcastMessage:"getbroadcastmsg",getP2PMessage:"getp2pmsg",getGroupChat:"getgroupmsg",getRoomChat:"getroommsg",getBroadcastChat:"getbroadcastmsg",getP2PChat:"getp2pmsg",getP2PMessageByMessageId:"getp2pmsgbymessageid",getGroupMessageByMessageId:"getgroupmsgbymessageid",getRoomMessageByMessageId:"getroommsgbymessageid",getBroadcastMessageByMessageId:"getbroadcastmsgbymessageid",getP2PMessageCount:"getp2pmsgcount",getGroupMessageCount:"getgroupmsgcount",getRoomMessageCount:"getroommsgcount",getBroadcastMessageCount:"getbroadcastmsgcount",getMessage:"getmsg",getChat:"getmsg",deleteMessage:"delmsg",deleteChat:"delmsg",translate:"translate",textCheck:"tcheck",getP2PConversationList:"getp2pconversationlist",getP2PUnreadConversationList:"getp2punreadconversationlist",getGroupConversationList:"getgroupconversationlist",getGroupUnreadConversationList:"getgroupunreadconversationlist",getUnreadConversationList:"getunreadconversationlist",removeSession:"removesession"},a={sendMessage:4,sendMessages:4,sendGroupMessage:4,sendRoomMessage:4,sendChat:3,sendAudio:3,sendCmd:3,sendGroupChat:3,sendGroupAudio:3,sendGroupCmd:3,sendRoomChat:3,sendRoomAudio:3,sendRoomCmd:3,sendFile:3,sendGroupFile:3,sendRoomFile:3},u=new Set(Object.keys(a)),c={sendMessage:{values:[0,4]},sendMessages:{values:[4],arrays:[0]},sendGroupMessage:{values:[0,4]},sendRoomMessage:{values:[0,4]},getP2PUnreadMessageNum:{arrays:[0],values:[1]},getGroupUnreadMessageNum:{arrays:[0],values:[1]},setSessionRead:{values:[1,2]},getGroupMessage:{values:[0,3,4,5]},getRoomMessage:{values:[0,3,4,5]},getBroadcastMessage:{values:[2,3,4]},getP2PMessage:{values:[0,3,4,5]},getP2PMessageByMessageId:{values:[0,1,4,5]},getGroupMessageByMessageId:{values:[0,1,4,5]},getRoomMessageByMessageId:{values:[0,1,4,5]},getBroadcastMessageByMessageId:{values:[0,3,4]},getP2PMessageCount:{values:[0,1,2]},getGroupMessageCount:{values:[0,1,2]},getRoomMessageCount:{values:[0,1,2]},getBroadcastMessageCount:{values:[0,1]},getGroupsOpenInfo:{arrays:[0]},getRoomsOpenInfo:{arrays:[0]},getRoomMembers:{values:[0]},getRoomCount:{arrays:[0]},getGroupMembers:{values:[0]},getGroupCount:{values:[0]},addGroupMembers:{values:[0],arrays:[1]},deleteGroupMembers:{values:[0],arrays:[1]},enterRoom:{values:[0]},enterRooms:{arrays:[0]},leaveRoom:{values:[0]},getOnlineUsers:{arrays:[0]},getUserOpenInfo:{arrays:[0]},deleteMessage:{values:[0,1,2]},getMessage:{values:[0,1,2]},deleteChat:{values:[0,1,2]},getChat:{values:[0,1,2]},setGroupInfo:{values:[0]},getGroupInfo:{values:[0]},getGroupOpenInfo:{values:[0]},setRoomInfo:{values:[0]},setRoomProfile:{values:[0]},getRoomInfo:{values:[0]},getRoomOpenInfo:{values:[0]},addBlacks:{arrays:[0]},deleteBlacks:{arrays:[0]},sendChat:{values:[0,3]},sendAudio:{values:[0,3]},sendCmd:{values:[0,3]},sendGroupChat:{values:[0,3]},sendGroupAudio:{values:[0,3]},sendGroupCmd:{values:[0,3]},sendRoomChat:{values:[0,3]},sendRoomAudio:{values:[0,3]},sendRoomCmd:{values:[0,3]},getGroupChat:{values:[0,3,4,5]},getRoomChat:{values:[0,3,4,5]},getP2PChat:{values:[0,3,4,5]},getBroadcastChat:{values:[2,3,4]},getP2PConversationList:{values:[0]},getP2PUnreadConversationList:{values:[0]},getGroupConversationList:{values:[0]},getGroupUnreadConversationList:{values:[0]},getUnreadConversationList:{values:[1]},removeSession:{values:[0]}},f=new Set(["getGroupMessage","getRoomMessage","getBroadcastMessage","getP2PMessage","getGroupChat","getRoomChat","getBroadcastChat","getP2PChat","getP2PMessageByMessageId","getGroupMessageByMessageId","getRoomMessageByMessageId","getBroadcastMessageByMessageId"]),l={getP2PMessage:"direct",getP2PChat:"direct",getP2PMessageByMessageId:"direct",getGroupMessage:"group",getGroupChat:"group",getGroupMessageByMessageId:"group",getRoomMessage:"room",getRoomChat:"room",getRoomMessageByMessageId:"room",getBroadcastMessage:"broadcast",getBroadcastChat:"broadcast",getBroadcastMessageByMessageId:"broadcast"},h={"event.direct":{category:"direct",id:"recipient",events:{message:o.SERVER_PUSH.recvMessage,file:o.SERVER_PUSH.recvFile,chat:o.SERVER_PUSH.recvChat,cmd:o.SERVER_PUSH.recvCmd}},"event.group":{category:"group",id:"group_ref",events:{message:o.SERVER_PUSH.recvGroupMessage,file:o.SERVER_PUSH.recvGroupFile,chat:o.SERVER_PUSH.recvGroupChat,cmd:o.SERVER_PUSH.recvGroupCmd}},"event.room":{category:"room",id:"room_ref",events:{message:o.SERVER_PUSH.recvRoomMessage,file:o.SERVER_PUSH.recvRoomFile,chat:o.SERVER_PUSH.recvRoomChat,cmd:o.SERVER_PUSH.recvRoomCmd}},"event.broadcast":{category:"broadcast",id:null,events:{message:o.SERVER_PUSH.recvBroadcastMessage,file:o.SERVER_PUSH.recvBroadcastFile,chat:o.SERVER_PUSH.recvBroadcastChat,cmd:o.SERVER_PUSH.recvBroadcastCmd}},"event.kicked":{category:"kicked",id:null,events:{message:o.SERVER_PUSH.kickOut}},"event.room_removed":{category:"room_removed",id:"room_ref",events:{message:o.SERVER_PUSH.kickOutRoom}}},d=new Set(Object.keys(h)),p=new Set([o.SERVER_PUSH.recvAudio,o.SERVER_PUSH.recvGroupAudio,o.SERVER_PUSH.recvRoomAudio,o.SERVER_PUSH.recvBroadcastAudio]),g=function(e){function t(e,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.name="RTMCompatibilityError",n.code=r&&r.code||"RTM_COMPATIBILITY_MAPPING_FAILED",n.method=r&&r.method,n.protocol=r&&r.protocol,n.compatibility="legacy-rtm",r&&void 0!==r.cause&&(n.cause=r.cause),n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,Error),t}();function y(e){if("string"!=typeof e||!/^-?\d+$/.test(e))return e;var t="-"===e.charAt(0),r=(t?e.slice(1):e).replace(/^0+/,"")||"0",n=t?"9223372036854775808":"9223372036854775807";return r.length>n.length||r.length===n.length&&r>n?e:o.Int64(e)}function m(e,t,r){if(w(r,e),!t)throw e;t(e,null)}function _(e,t,r,n){if(null==t)return t;if(u.has(e))return function(e,t,r){var n=v(r[a[e]],e);if(t&&Object.prototype.hasOwnProperty.call(t,"error"))return{mid:n,error:t.error};if(!I(t))throw new g("Cannot map "+e+" result to the legacy RTM response shape.",{method:e,protocol:"tlv-v1"});var o=I(t.payload)?Object.assign({},t.payload):Object.assign({},t),i=void 0!==t.message_ref?t.message_ref:o.message_ref,s=o.time_ms;delete o.message_ref,delete o.time_ms,void 0!==s&&(o.mtime=s);return{mid:n||i,payload:o}}(e,t,r);var o=s[e],c=o&&i.ROUTES[o],h=c&&c.response&&I(t)?function(e,t,r,n){var o=Object.assign({},t);return Object.keys(r).forEach((function(t){var i=r[t];if(t!==i&&Object.prototype.hasOwnProperty.call(o,i)){if(Object.prototype.hasOwnProperty.call(o,t))throw new g("Cannot map "+e+' response: both "'+t+'" and "'+i+'" are present.',{method:e,protocol:n});o[t]=o[i],delete o[i]}})),o}(e,t,c.response,n):t;if(!I(h))return h;if(h=Object.assign({},h),f.has(e)&&Array.isArray(h.msgs)){var d=l[e];h.msgs=h.msgs.map((function(t){return k(t,d,e,n)}))}if("getMessage"!==e&&"getChat"!==e||(h=function(e,t,r){var n=Object.assign({},e);void 0!==n.id&&(n.id=A(n.id,"id",t,r));void 0!==n.mid&&(n.mid=A(n.mid,"mid",t,r));void 0!==n.mtime&&(n.mtime=A(n.mtime,"mtime",t,r));void 0!==n.from&&(n.from=A(n.from,"from",t,r));void 0!==n.msg&&(n.msg=C(n.msg));return n}(h,e,n)),"getUserRoomsAndLastMessage"===e&&I(h.rooms)){var p={};Object.keys(h.rooms).forEach((function(t){p[t]=k(h.rooms[t],"room",e,n)})),h.rooms=p}if("getP2PConversationList"===e||"getP2PUnreadConversationList"===e||"getGroupConversationList"===e||"getGroupUnreadConversationList"===e){var y=e.startsWith("getGroup")?"group":"direct";Array.isArray(h.msgs)&&(h.msgs=h.msgs.map((function(t){return k(t,y,e,n)})))}return"getUnreadConversationList"===e&&(Array.isArray(h.p2pMsgs)&&(h.p2pMsgs=h.p2pMsgs.map((function(t){return k(t,"direct",e,n)}))),Array.isArray(h.groupMsgs)&&(h.groupMsgs=h.groupMsgs.map((function(t){return k(t,"group",e,n)})))),h}function v(e,t){return null==e||""===String(e)||/^[+-]?0+$/.test(String(e))?b(t):e}function b(e){var t="undefined"!=typeof globalThis?globalThis.crypto:null;if(!t||"function"!=typeof t.getRandomValues)throw new g("crypto.getRandomValues() is required to generate legacy RTM message IDs.",{method:e,protocol:"tlv-v1",code:"RTM_COMPATIBILITY_UNSUPPORTED"});var r=new Uint32Array(2);return t.getRandomValues(r),r[0]=2147483647&r[0],0===r[0]&&0===r[1]&&(r[1]=1),o.Int64(function(e,t){var r=[e>>>16,65535&e,t>>>16,65535&t],n="";for(;r.some(Boolean);){for(var o=0,i=0;i<r.length;i+=1){var s=65536*o+r[i];r[i]=Math.floor(s/10),o=s%10}n=String(o)+n}return n||"0"}(r[0],r[1]))}function w(e,t){if("function"==typeof e)try{e(t)}catch(e){}}function E(e){if(e===o.SERVER_PUSH.kickOut)return"event.kicked";if(e===o.SERVER_PUSH.kickOutRoom)return"event.room_removed";for(var t=Object.keys(h),r=function(r){var n=t[r],o=h[n];if(o&&o.events&&Object.keys(o.events).some((function(t){return o.events[t]===e})))return{v:n}},i=0;i<t.length;i+=1){var s=r(i);if("object"===(void 0===s?"undefined":n(s)))return s.v}return null}function k(e,t,r,n){if(!Array.isArray(e)){if(!I(e))throw new g("Cannot map "+r+" history row: expected a tuple or message object.",{method:r,protocol:n});return Object.assign({},e)}if(8!==e.length)throw new g("Cannot map "+r+" history row: expected an 8-field tuple.",{method:r,protocol:n});var o,i={id:A(e[0],"history.id",r,n),mtype:Number(S(e[2],"history.kind",r,n)),mid:A(e[3],"history.message_ref",r,n),deleted:e[4],msg:R(e[5],Number(S(e[2],"history.kind",r,n))),binary:(o=e[5],C(o)),attrs:R(e[6],0),mtime:A(e[7],"history.time_ms",r,n)};return"direct"===t?i.direction=Number(S(e[1],"history.direction",r,n)):i.from=A(e[1],"history.sender",r,n),i}function R(e,t){if("string"==typeof e)return e;var r=O(e);if(r)try{if("function"!=typeof TextDecoder)return;return new TextDecoder("utf-8",{fatal:!0}).decode(r)}catch(e){return}}function P(e){if("string"==typeof e||null==e)return e;var t=R(e);return void 0===t?C(e):t}function C(e,t){var r=O(e);if(r)return T(r);if(e instanceof ArrayBuffer)return e.slice(0);if(!e||"object"!==(void 0===e?"undefined":n(e)))return e;if(e.buffer&&"number"==typeof e.offset&&"function"==typeof e.toString)return e;var o=t||new Map;if(o.has(e))return o.get(e);if(Array.isArray(e)){var i=[];return o.set(e,i),e.forEach((function(e){return i.push(C(e,o))})),i}var s=Object.create(null===Object.getPrototypeOf(e)?null:Object.prototype);return o.set(e,s),Object.keys(e).forEach((function(t){s[t]=C(e[t],o)})),s}function O(e){return e instanceof ArrayBuffer?new Uint8Array(e):ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):null}function T(e){return new Uint8Array(e)}function A(e,t,r,n){var i=S(e,t,r,n);return o.Int64(i)}function S(e,t,r,n){if(e&&"function"==typeof e.toString){var o=e.toString();if(/^-?\d+$/.test(o))return o}if("number"==typeof e&&Number.isSafeInteger(e))return String(e);throw new g("Cannot map "+r+": "+t+" is not an exact integer.",{method:r,protocol:n||"tlv-v1"})}function M(e,t,r){if(e instanceof g)return e;var n=new g("Failed to adapt legacy RTM "+t+" contract: "+(e&&e.message?e.message:String(e)),{method:t,protocol:r,cause:e,code:"RTM_COMPATIBILITY_MAPPING_FAILED"});return e&&e.stack&&(n.stack=e.stack+"\nCaused by: "+n.stack),n}function I(e){if(!e||"object"!==(void 0===e?"undefined":n(e))||Array.isArray(e))return!1;var t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}e.exports={METHOD_ROUTES:s,RTMCompatibilityError:g,SEND_MID_INDEX:a,adaptResult:_,createPushAdapter:function(e){return{validate:function(t){if(d.has(t)){var r=new g('legacy Push names only; use compatibility "native" to observe raw TLV Push names.',{method:"processor.on",protocol:"tlv-v1",code:"RTM_COMPATIBILITY_UNSUPPORTED"});throw w(e,r),r}if(t===o.SERVER_PUSH.recvPing){var n=new g("TLV has no server ping Push; the SDK heartbeat is internal.",{method:"processor.on",protocol:"tlv-v1",code:"RTM_COMPATIBILITY_UNSUPPORTED"});throw w(e,n),n}if(p.has(t)){var i=new g("Legacy RTM does not emit a dedicated audio event; subscribe to pushfile.",{method:"processor.on",protocol:"tlv-v1",code:"RTM_COMPATIBILITY_UNSUPPORTED"});throw w(e,i),i}if("CompatibilityError"!==t&&!E(t)){var s=new g('Unsupported legacy RTM Processor event "'+String(t)+'".',{method:"processor.on",protocol:"tlv-v1",code:"RTM_COMPATIBILITY_UNSUPPORTED"});throw w(e,s),s}},bind:function(t,r){if("CompatibilityError"===t)return{local:!0};var n=E(t);return n?{type:n,callback:function(i){var s=void 0;try{s=function(e,t,r){var n=h[e];if(!n)return null;var i=I(t)?t:{};if("event.kicked"===e||"event.room_removed"===e){var s={};return n.id&&void 0!==i[n.id]&&(s.rid=i[n.id]),r===o.SERVER_PUSH.kickOutRoom&&void 0===s.rid?null:s}var a=Number(S(i.kind,"kind",r)),u="message";a===o.CHAT_TYPE.text?u="chat":a===o.CHAT_TYPE.cmd?u="cmd":(a===o.CHAT_TYPE.audio||a>=40&&a<=50)&&(u="file");if(n.events[u]!==r)return null;var c=C(i.payload),f=O(i.payload),l=a!==o.CHAT_TYPE.text,d={from:A(i.sender,"sender",r),mtype:a,mid:A(i.message_ref,"message_ref",r),msg:l?P(i.payload):c,attrs:P(i.extra),mtime:A(i.time_ms,"time_ms",r)};l&&f?d.binary=T(f):l&&void 0!==i.binary&&(d.binary=C(i.binary));n.id&&void 0!==i[n.id]&&(d["group"===n.category?"gid":"room"===n.category?"rid":"to"]=i[n.id]);return d}(n,i,t)}catch(r){return void w(e,M(r,"processor."+t,"tlv-v1"))}s&&r(s)}}:null}}},generateMessageId:b,isEnabled:function(e,t){return"legacy-rtm"===e&&"tlv-v1"===t},invoke:function(e,t,r,o,i,f){var l=t.slice(),h=function(e,t){if(t>=0&&"function"==typeof e[t])return t;for(var r=e.length-1;r>=0;r-=1)if("function"==typeof e[r])return r;return-1}(l,i),d=h>=0?l[h]:null,p=a[e],b=void 0,E=!1,k=void 0;function R(){try{return d.apply(null,arguments)}catch(e){throw k=e,e}}if(!s[e])return m(new g('No TLV v1 equivalent for legacy RTM method "'+e+'".',{method:e,protocol:o,code:"RTM_COMPATIBILITY_UNSUPPORTED"}),d,f);!function(e,t){var r=c[e];if(!r)return;(r.values||[]).forEach((function(e){e<t.length&&(t[e]=y(t[e]))})),(r.arrays||[]).forEach((function(e){e<t.length&&Array.isArray(t[e])&&(t[e]=t[e].map((function(e){return y(e)})))}))}(e,l);try{void 0!==p&&(b=v(l[p],e),l[p]=b)}catch(t){return m(M(t,e,o),d,f)}d&&(l[h]=function(t,r){if(!E)if(E=!0,t)R(function(e,t,r){if(!u.has(e)||!t||"object"!==(void 0===t?"undefined":n(t))||!Object.prototype.hasOwnProperty.call(t,"error"))return t;var o=Object.assign({},t);return delete o.message_ref,o.mid=void 0!==r?r:t.mid,o}(e,t,b),null);else{var i=void 0;try{i=_(e,r,l,o)}catch(t){var s=M(t,e,o);return w(f,s),void R(s,null)}R(null,i)}});try{return r[e].apply(r,l)}catch(e){if(k===e)throw e;if(d){if(E)return;return E=!0,e instanceof g?m(e,d,f):void d(e,null)}throw e instanceof g&&"function"==typeof f&&f(e),e}},toLegacyHistoryMessage:k,validateCompatibility:function(e){if(void 0===e)return"native";if("native"===e||"legacy-rtm"===e)return e;throw new TypeError('compatibility must be "native" or "legacy-rtm"')}}}])}));
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__(27),a=!i.JS_MD5_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,n="0123456789abcdef".split(""),u=[128,32768,8388608,-2147483648],y=[0,8,16,24],c=["hex","array","digest","buffer","arrayBuffer","base64"],p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),d=[],l;if(a){var A=new ArrayBuffer(68);l=new Uint8Array(A),d=new Uint32Array(A)}!i.JS_MD5_NO_NODE_JS&&Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),!a||!i.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(e){return"object"==typeof e&&e.buffer&&e.buffer.constructor===ArrayBuffer});var b=function(e){return function(r){return new t(!0).update(r)[e]()}},v=function(){var e=b("hex");h&&(e=w(e)),e.create=function(){return new t},e.update=function(t){return e.create().update(t)};for(var r=0;r<c.length;++r){var n=c[r];e[n]=b(n)}return e},w=function(t){var e=eval("require('crypto')"),i=eval("require('buffer').Buffer"),s=function(n){if("string"==typeof n)return e.createHash("md5").update(n,"utf8").digest("hex");if(null==n)throw r;return n.constructor===ArrayBuffer&&(n=new Uint8Array(n)),Array.isArray(n)||ArrayBuffer.isView(n)||n.constructor===i?e.createHash("md5").update(new i(n)).digest("hex"):t(n)};return s};t.prototype.update=function(e){if(!this.finalized){var t,n=typeof e;if("string"!==n){if("object"!==n)throw r;if(null===e)throw r;if(a&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||a&&ArrayBuffer.isView(e)))throw r;t=!0}for(var o,i,s=0,u=e.length,c=this.blocks,f=this.buffer8;s<u;){if(this.hashed&&(this.hashed=!1,c[0]=c[16],c[16]=c[1]=c[2]=c[3]=c[4]=c[5]=c[6]=c[7]=c[8]=c[9]=c[10]=c[11]=c[12]=c[13]=c[14]=c[15]=0),t)if(a)for(i=this.start;s<u&&i<64;++s)f[i++]=e[s];else for(i=this.start;s<u&&i<64;++s)c[i>>2]|=e[s]<<y[3&i++];else if(a)for(i=this.start;s<u&&i<64;++s)(o=e.charCodeAt(s))<128?f[i++]=o:o<2048?(f[i++]=192|o>>6,f[i++]=128|63&o):o<55296||o>=57344?(f[i++]=224|o>>12,f[i++]=128|o>>6&63,f[i++]=128|63&o):(o=65536+((1023&o)<<10|1023&e.charCodeAt(++s)),f[i++]=240|o>>18,f[i++]=128|o>>12&63,f[i++]=128|o>>6&63,f[i++]=128|63&o);else for(i=this.start;s<u&&i<64;++s)(o=e.charCodeAt(s))<128?c[i>>2]|=o<<y[3&i++]:o<2048?(c[i>>2]|=(192|o>>6)<<y[3&i++],c[i>>2]|=(128|63&o)<<y[3&i++]):o<55296||o>=57344?(c[i>>2]|=(224|o>>12)<<y[3&i++],c[i>>2]|=(128|o>>6&63)<<y[3&i++],c[i>>2]|=(128|63&o)<<y[3&i++]):(o=65536+((1023&o)<<10|1023&e.charCodeAt(++s)),c[i>>2]|=(240|o>>18)<<y[3&i++],c[i>>2]|=(128|o>>12&63)<<y[3&i++],c[i>>2]|=(128|o>>6&63)<<y[3&i++],c[i>>2]|=(128|63&o)<<y[3&i++]);this.lastByteIndex=i,this.bytes+=i-this.start,i>=64?(this.start=i-64,this.hash(),this.hashed=!0):this.start=i}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}},t.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex;e[t>>2]|=u[3&t],t>=56&&(this.hashed||this.hash(),e[0]=e[16],e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=this.bytes<<3,e[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},t.prototype.hash=function(){var e,t,r,n,o,i,s=this.blocks;this.first?t=((t=((e=((e=s[0]-680876937)<<7|e>>>25)-271733879<<0)^(r=((r=(-271733879^(n=((n=(-1732584194^2004318071&e)+s[1]-117830708)<<12|n>>>20)+e<<0)&(-271733879^e))+s[2]-1126478375)<<17|r>>>15)+n<<0)&(n^e))+s[3]-1316259209)<<22|t>>>10)+r<<0:(e=this.h0,t=this.h1,r=this.h2,t=((t+=((e=((e+=((n=this.h3)^t&(r^n))+s[0]-680876936)<<7|e>>>25)+t<<0)^(r=((r+=(t^(n=((n+=(r^e&(t^r))+s[1]-389564586)<<12|n>>>20)+e<<0)&(e^t))+s[2]+606105819)<<17|r>>>15)+n<<0)&(n^e))+s[3]-1044525330)<<22|t>>>10)+r<<0),t=((t+=((e=((e+=(n^t&(r^n))+s[4]-176418897)<<7|e>>>25)+t<<0)^(r=((r+=(t^(n=((n+=(r^e&(t^r))+s[5]+1200080426)<<12|n>>>20)+e<<0)&(e^t))+s[6]-1473231341)<<17|r>>>15)+n<<0)&(n^e))+s[7]-45705983)<<22|t>>>10)+r<<0,t=((t+=((e=((e+=(n^t&(r^n))+s[8]+1770035416)<<7|e>>>25)+t<<0)^(r=((r+=(t^(n=((n+=(r^e&(t^r))+s[9]-1958414417)<<12|n>>>20)+e<<0)&(e^t))+s[10]-42063)<<17|r>>>15)+n<<0)&(n^e))+s[11]-1990404162)<<22|t>>>10)+r<<0,t=((t+=((e=((e+=(n^t&(r^n))+s[12]+1804603682)<<7|e>>>25)+t<<0)^(r=((r+=(t^(n=((n+=(r^e&(t^r))+s[13]-40341101)<<12|n>>>20)+e<<0)&(e^t))+s[14]-1502002290)<<17|r>>>15)+n<<0)&(n^e))+s[15]+1236535329)<<22|t>>>10)+r<<0,t=((t+=((n=((n+=(t^r&((e=((e+=(r^n&(t^r))+s[1]-165796510)<<5|e>>>27)+t<<0)^t))+s[6]-1069501632)<<9|n>>>23)+e<<0)^e&((r=((r+=(e^t&(n^e))+s[11]+643717713)<<14|r>>>18)+n<<0)^n))+s[0]-373897302)<<20|t>>>12)+r<<0,t=((t+=((n=((n+=(t^r&((e=((e+=(r^n&(t^r))+s[5]-701558691)<<5|e>>>27)+t<<0)^t))+s[10]+38016083)<<9|n>>>23)+e<<0)^e&((r=((r+=(e^t&(n^e))+s[15]-660478335)<<14|r>>>18)+n<<0)^n))+s[4]-405537848)<<20|t>>>12)+r<<0,t=((t+=((n=((n+=(t^r&((e=((e+=(r^n&(t^r))+s[9]+568446438)<<5|e>>>27)+t<<0)^t))+s[14]-1019803690)<<9|n>>>23)+e<<0)^e&((r=((r+=(e^t&(n^e))+s[3]-187363961)<<14|r>>>18)+n<<0)^n))+s[8]+1163531501)<<20|t>>>12)+r<<0,t=((t+=((n=((n+=(t^r&((e=((e+=(r^n&(t^r))+s[13]-1444681467)<<5|e>>>27)+t<<0)^t))+s[2]-51403784)<<9|n>>>23)+e<<0)^e&((r=((r+=(e^t&(n^e))+s[7]+1735328473)<<14|r>>>18)+n<<0)^n))+s[12]-1926607734)<<20|t>>>12)+r<<0,t=((t+=((i=(n=((n+=((o=t^r)^(e=((e+=(o^n)+s[5]-378558)<<4|e>>>28)+t<<0))+s[8]-2022574463)<<11|n>>>21)+e<<0)^e)^(r=((r+=(i^t)+s[11]+1839030562)<<16|r>>>16)+n<<0))+s[14]-35309556)<<23|t>>>9)+r<<0,t=((t+=((i=(n=((n+=((o=t^r)^(e=((e+=(o^n)+s[1]-1530992060)<<4|e>>>28)+t<<0))+s[4]+1272893353)<<11|n>>>21)+e<<0)^e)^(r=((r+=(i^t)+s[7]-155497632)<<16|r>>>16)+n<<0))+s[10]-1094730640)<<23|t>>>9)+r<<0,t=((t+=((i=(n=((n+=((o=t^r)^(e=((e+=(o^n)+s[13]+681279174)<<4|e>>>28)+t<<0))+s[0]-358537222)<<11|n>>>21)+e<<0)^e)^(r=((r+=(i^t)+s[3]-722521979)<<16|r>>>16)+n<<0))+s[6]+76029189)<<23|t>>>9)+r<<0,t=((t+=((i=(n=((n+=((o=t^r)^(e=((e+=(o^n)+s[9]-640364487)<<4|e>>>28)+t<<0))+s[12]-421815835)<<11|n>>>21)+e<<0)^e)^(r=((r+=(i^t)+s[15]+530742520)<<16|r>>>16)+n<<0))+s[2]-995338651)<<23|t>>>9)+r<<0,t=((t+=((n=((n+=(t^((e=((e+=(r^(t|~n))+s[0]-198630844)<<6|e>>>26)+t<<0)|~r))+s[7]+1126891415)<<10|n>>>22)+e<<0)^((r=((r+=(e^(n|~t))+s[14]-1416354905)<<15|r>>>17)+n<<0)|~e))+s[5]-57434055)<<21|t>>>11)+r<<0,t=((t+=((n=((n+=(t^((e=((e+=(r^(t|~n))+s[12]+1700485571)<<6|e>>>26)+t<<0)|~r))+s[3]-1894986606)<<10|n>>>22)+e<<0)^((r=((r+=(e^(n|~t))+s[10]-1051523)<<15|r>>>17)+n<<0)|~e))+s[1]-2054922799)<<21|t>>>11)+r<<0,t=((t+=((n=((n+=(t^((e=((e+=(r^(t|~n))+s[8]+1873313359)<<6|e>>>26)+t<<0)|~r))+s[15]-30611744)<<10|n>>>22)+e<<0)^((r=((r+=(e^(n|~t))+s[6]-1560198380)<<15|r>>>17)+n<<0)|~e))+s[13]+1309151649)<<21|t>>>11)+r<<0,t=((t+=((n=((n+=(t^((e=((e+=(r^(t|~n))+s[4]-145523070)<<6|e>>>26)+t<<0)|~r))+s[11]-1120210379)<<10|n>>>22)+e<<0)^((r=((r+=(e^(n|~t))+s[2]+718787259)<<15|r>>>17)+n<<0)|~e))+s[9]-343485551)<<21|t>>>11)+r<<0,this.first?(this.h0=e+1732584193<<0,this.h1=t-271733879<<0,this.h2=r-1732584194<<0,this.h3=n+271733878<<0,this.first=!1):(this.h0=this.h0+e<<0,this.h1=this.h1+t<<0,this.h2=this.h2+r<<0,this.h3=this.h3+n<<0)},t.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,o=this.h3;return n[e>>4&15]+n[15&e]+n[e>>12&15]+n[e>>8&15]+n[e>>20&15]+n[e>>16&15]+n[e>>28&15]+n[e>>24&15]+n[t>>4&15]+n[15&t]+n[t>>12&15]+n[t>>8&15]+n[t>>20&15]+n[t>>16&15]+n[t>>28&15]+n[t>>24&15]+n[r>>4&15]+n[15&r]+n[r>>12&15]+n[r>>8&15]+n[r>>20&15]+n[r>>16&15]+n[r>>28&15]+n[r>>24&15]+n[o>>4&15]+n[15&o]+n[o>>12&15]+n[o>>8&15]+n[o>>20&15]+n[o>>16&15]+n[o>>28&15]+n[o>>24&15]},t.prototype.toString=t.prototype.hex,t.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,n=this.h3;return[255&e,e>>8&255,e>>16&255,e>>24&255,255&t,t>>8&255,t>>16&255,t>>24&255,255&r,r>>8&255,r>>16&255,r>>24&255,255&n,n>>8&255,n>>16&255,n>>24&255]},t.prototype.array=t.prototype.digest,t.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(16),t=new Uint32Array(e);return t[0]=this.h0,t[1]=this.h1,t[2]=this.h2,t[3]=this.h3,e},t.prototype.buffer=t.prototype.arrayBuffer,t.prototype.base64=function(){for(var e,t,r,n="",o=this.array(),i=0;i<15;)e=o[i++],t=o[i++],r=o[i++],n+=p[e>>>2]+p[63&(e<<4|t>>>4)]+p[63&(t<<2|r>>>6)]+p[63&r];return e=o[i],n+(p[e>>>2]+p[e<<4&63]+"==")};var _=v();f?module.exports=_:(i.md5=_,o&&(__WEBPACK_AMD_DEFINE_RESULT__=function(){return _}.call(exports,__webpack_require__,exports,module),void 0===__WEBPACK_AMD_DEFINE_RESULT__||(module.exports=__WEBPACK_AMD_DEFINE_RESULT__)))}()}).call(this,__webpack_require__(26),__webpack_require__(3))},function(e,t){var r,n,o=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(e){if(r===setTimeout)return setTimeout(e,0);if((r===i||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:i}catch(e){r=i}try{n="function"==typeof clearTimeout?clearTimeout:s}catch(e){n=s}}();var u,c=[],f=!1,l=-1;function h(){f&&u&&(f=!1,u.length?c=u.concat(c):l=-1,c.length&&d())}function d(){if(!f){var e=a(h);f=!0;for(var t=c.length;t;){for(u=c,c=[];++l<t;)u&&u[l].run();l=-1,t=c.length}u=null,f=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===s||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function p(e,t){this.fun=e,this.array=t}function g(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];c.push(new p(e,t)),1!==c.length||f||a(d)},p.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=g,o.addListener=g,o.once=g,o.off=g,o.removeListener=g,o.removeAllListeners=g,o.emit=g,o.prependListener=g,o.prependOnceListener=g,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,t){(function(t){e.exports=t}).call(this,{})},function(e,t,r){(function(e){!function(t){function r(e,r,g){function _(e,t,r,n){return this instanceof _?function(e,t,r,n,o){if(h&&d&&(t instanceof d&&(t=new h(t)),n instanceof d&&(n=new h(n))),t||r||n||c){if(!s(t,r))o=r,n=t,r=0,t=new(c||Array)(8);e.buffer=t,e.offset=r|=0,f!==typeof n&&("string"==typeof n?function(e,t,r,n){var o=0,i=r.length,s=0,a=0;"-"===r[0]&&o++;for(var u=o;o<i;){var c=parseInt(r[o++],n);if(!(c>=0))break;a=a*n+c,s=s*n+Math.floor(a/y),a%=y}u&&(s=~s,a?a=y-a:s++),b(e,t+E,s),b(e,t+k,a)}(t,r,n,o||10):s(n,o)?a(t,r,n,o):"number"==typeof o?(b(t,r+E,n),b(t,r+k,o)):n>0?T(t,r,n):n<0?A(t,r,n):a(t,r,p,0))}else e.buffer=u(p,0)}(this,e,t,r,n):new _(e,t,r,n)}function v(){var e=this.buffer,t=this.offset,r=w(e,t+E),n=w(e,t+k);return g||(r|=0),r?r*y+n:n}function b(e,t,r){e[t+O]=255&r,r>>=8,e[t+C]=255&r,r>>=8,e[t+P]=255&r,r>>=8,e[t+R]=255&r}function w(e,t){return e[t+R]*m+(e[t+P]<<16)+(e[t+C]<<8)+e[t+O]}var E=r?0:4,k=r?4:0,R=r?0:3,P=r?1:2,C=r?2:1,O=r?3:0,T=r?function(e,t,r){for(var n=t+8;n>t;)e[--n]=255&r,r/=256}:function(e,t,r){for(var n=t+8;t<n;)e[t++]=255&r,r/=256},A=r?function(e,t,r){var n=t+8;for(r++;n>t;)e[--n]=255&-r^255,r/=256}:function(e,t,r){var n=t+8;for(r++;t<n;)e[t++]=255&-r^255,r/=256},S=_.prototype,M="is"+e,I="_"+M;return S.buffer=void 0,S.offset=0,S[I]=!0,S.toNumber=v,S.toString=function(e){var t=this.buffer,r=this.offset,n=w(t,r+E),o=w(t,r+k),i="",s=!g&&2147483648&n;for(s&&(n=~n,o=y-o),e=e||10;;){var a=n%e*y+o;if(n=Math.floor(n/e),o=Math.floor(a/e),i=(a%e).toString(e)+i,!n&&!o)break}return s&&(i="-"+i),i},S.toJSON=v,S.toArray=n,l&&(S.toBuffer=o),h&&(S.toArrayBuffer=i),_[M]=function(e){return!(!e||!e[I])},t[e]=_,_}function n(e){var t=this.buffer,r=this.offset;return c=null,!1!==e&&0===r&&8===t.length&&g(t)?t:u(t,r)}function o(t){var r=this.buffer,n=this.offset;if(c=l,!1!==t&&0===n&&8===r.length&&e.isBuffer(r))return r;var o=new l(8);return a(o,0,r,n),o}function i(e){var t=this.buffer,r=this.offset,n=t.buffer;if(c=h,!1!==e&&0===r&&n instanceof d&&8===n.byteLength)return n;var o=new h(8);return a(o,0,t,r),o.buffer}function s(e,t){var r=e&&e.length;return t|=0,r&&t+8<=r&&"string"!=typeof e[t]}function a(e,t,r,n){t|=0,n|=0;for(var o=0;o<8;o++)e[t++]=255&r[n++]}function u(e,t){return Array.prototype.slice.call(e,t,t+8)}var c,f="undefined",l=f!==typeof e&&e,h=f!==typeof Uint8Array&&Uint8Array,d=f!==typeof ArrayBuffer&&ArrayBuffer,p=[0,0,0,0,0,0,0,0],g=Array.isArray||function(e){return!!e&&"[object Array]"==Object.prototype.toString.call(e)},y=4294967296,m=16777216;r("Uint64BE",!0,!0),r("Int64BE",!0,!1),r("Uint64LE",!1,!0),r("Int64LE",!1,!1)}("string"!=typeof t.nodeName?t:this||{})}).call(this,r(8).Buffer)},function(e,t,r){"use strict";var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=r(2),s=r(14),a=r(0),u=r(6),c=r(15),f=c.normalizeClientOptions,l=c.sharedEndpoint,h=r(16).getSharedWorkerConfigFallbackReason,d=r(17),p=r(18),g=r(30),y=["sharing","uid","conversation","workerName","workerUrl","workerNamespace","readyTimeout","idleShutdownTimeout","compatibility"],m=function(){function e(t,r){var n,s,a=this;o(this,e),this._connectionInfo=Object.freeze(Object.assign({},r)),this._usesSharedWorker="shared"===this._connectionInfo.mode,this._config=Object.assign({},t),this._compatibility=g.validateCompatibility(t.compatibility),this._legacyTlv=g.isEnabled(this._compatibility,t.protocol),this._options=f(v(t)),this._config.conversation=d(t.conversation),this._delegate=null,this._delegateType=null,this._uid=null,this._session={status:"idle",uid:null},this._directLoginPromise=null,this._destroyed=!1,this._events=new _,this.processor=new _(this._legacyTlv?g.createPushAdapter((function(e){return a.processor.emit("CompatibilityError",e)})):null),this.promises=(n=this,(s=Object.assign({},u(n,i.prototype))).login=function(e,t,r){return arguments.length>3?Promise.reject(new TypeError("promises.login(uid, credential, timeout?)")):n.loginIfNeeded(e,t,r).then((function(e){if(e.accepted)return{accepted:!0,errorCode:e.errorCode||0};var t=new Error("RTM login rejected ("+String(e.errorCode)+")");throw t.code=e.errorCode,t.status=e.errorCode,t}))},Object.freeze(s)),void 0!==t.uid&&null!==t.uid&&this._attach(t.uid)}return n(e,[{key:"_attach",value:function(e){var t=this;if(this._assertActive(),"number"==typeof e&&(!isFinite(e)||Math.floor(e)!==e||Math.abs(e)>9007199254740991))throw b("Use a decimal string for a UID outside the safe integer range","RTM_SHARED_UID_INVALID");var r=null==e?"":String(e).trim().replace(/^0+(?=\d)/,"");if(!/^\d+$/.test(r)||/^0+$/.test(r))throw b("Provide a positive UID in login() or createClient({ uid }) before attaching","RTM_SHARED_UID_REQUIRED");if(r.length>20||20===r.length&&r>"18446744073709551615")throw b("UID exceeds the uint64 range","RTM_SHARED_UID_INVALID");if(null!==this._uid&&this._uid!==r)throw b("This client is bound to UID "+this._uid+"; create another client for UID "+r,"RTM_SHARED_UID_MISMATCH");if(!this._delegate){var n=this._config,o=this._usesSharedWorker?new s({workerName:n.workerName||s.createWorkerName({pid:this._options.pid,protocol:this._options.protocol,uid:r,endpoint:l(this._options),namespace:n.workerNamespace}),workerUrl:n.workerUrl,conversation:n.conversation,readyTimeout:n.readyTimeout,idleShutdownTimeout:n.idleShutdownTimeout,clientOptions:this._options}):new i(this._options);this._uid=r,this._delegate=o,this._delegateType=this._usesSharedWorker?"shared":"direct","direct"===this._delegateType&&o.on("SessionClosed",(function(){t._session={status:"idle",uid:null}})),this._events.bind(o);var a="direct"===this._delegateType?function(e,r){return p(t._config.conversation,t._options.protocol,e,r[0])}:null;this.processor.bind(o.processor,a)}return this._delegate}},{key:"_assertActive",value:function(){if(this._destroyed)throw b("RTM client has been destroyed","RTM_CLIENT_DESTROYED")}},{key:"login",value:function(e,t,r,n){var o=this;this.loginIfNeeded(e,t,n).then((function(e){"function"==typeof r&&r(e.accepted,e.errorCode)}),(function(e){var t="number"==typeof e.status?e.status:"number"==typeof e.code?e.code:a.ERROR_CODE.RTM_EC_UNKNOWN_ERROR;try{"function"==typeof r&&r(!1,t)}finally{o._usesSharedWorker&&o._events.emit("SharedWorkerError",e)}}))}},{key:"loginIfNeeded",value:function(e,t,r){try{var n=this._attach(e),o=this._uid.length>19||19===this._uid.length&&this._uid>"9223372036854775807"?a.Uint64(this._uid):a.Int64(this._uid);return this._usesSharedWorker?n.loginIfNeeded(o,t,r):this._loginDirect(n,o,t,r)}catch(e){return Promise.reject(e)}}},{key:"_loginDirect",value:function(e,t,r,n){var o=this;if("authenticated"===this._session.status)return Promise.resolve({accepted:!0,errorCode:0,reused:!0,uid:this._uid});if("connecting"===this._session.status&&this._directLoginPromise)return this._directLoginPromise;if("string"!=typeof r||0===r.length)return Promise.reject(b("This RTM UID is not logged in yet; provide its server-issued credential first.","RTM_SHARED_CREDENTIAL_REQUIRED"));this._session={status:"connecting",uid:this._uid};var i=new Promise((function(i,s){var a=!1;try{e.login(t,r,(function(e,t){a||(a=!0,o._session=e?{status:"authenticated",uid:o._uid}:{status:"idle",uid:null},i({accepted:Boolean(e),errorCode:t||0,reused:!1,uid:e?o._uid:null}))}),n)}catch(e){o._session={status:"idle",uid:null},s(e)}}));return this._directLoginPromise=i.then((function(e){return o._directLoginPromise=null,e}),(function(e){throw o._directLoginPromise=null,e})),this._directLoginPromise}},{key:"whenReady",value:function(e){try{var t=this._attach(void 0===e?this._uid:e);return this._usesSharedWorker?t.whenReady():Promise.resolve({status:this._session.status,uid:this._session.uid})}catch(e){return Promise.reject(e)}}},{key:"getSharedSession",value:function(){return"shared"===this._delegateType?this._delegate.getSharedSession():{status:this._session.status,uid:this._session.uid}}},{key:"getConnectionInfo",value:function(){return{mode:this._connectionInfo.mode,fallbackReason:this._connectionInfo.fallbackReason}}},{key:"setConversation",value:function(e,t){return this._assertActive(),e=d(e),"shared"===this._delegateType?this._delegate.setConversation(e,t):(this._config.conversation=e,"function"==typeof t&&t(null)),this}},{key:"on",value:function(e,t){return this._events.on(e,t),this}},{key:"off",value:function(e,t){return this._events.off(e,t),this}},{key:"removeEvent",value:function(){return this._events.removeEvent.apply(this._events,arguments),this}},{key:"emit",value:function(){this._events.emit.apply(this._events,arguments)}},{key:"listenerCount",value:function(e){return this._events.listenerCount(e)}},{key:"close",value:function(){this._assertActive(),this._delegate&&this._delegate.close()}},{key:"startAutoReconnect",value:function(){this._assertActive(),this._delegate&&this._delegate.startAutoReconnect()}},{key:"destroy",value:function(){if(!this._destroyed){this._destroyed=!0;try{this._legacyTlv&&"direct"===this._delegateType&&this._events.off("SessionClosed"),this._delegate&&this._delegate.destroy()}finally{this._events.clear(),this.processor.clear()}}}},{key:"_invoke",value:function(e,t){var r=this;try{if(this._assertActive(),!this._delegate)throw b("Call login() before "+e+"()","RTM_SHARED_UID_REQUIRED")}catch(e){var n=t.slice().reverse().find((function(e){return"function"==typeof e}));if(n)return void n(e,null);throw e}return this._legacyTlv?g.invoke(e,t,this._delegate,this._options.protocol,-1,(function(e){return r.processor.emit("CompatibilityError",e)})):this._delegate[e].apply(this._delegate,t)}}]),e}(),_=function(){function e(t){o(this,e),this._listeners=Object.create(null),this._bindings=Object.create(null),this._target=null,this._filter=null,this._eventAdapter=t||null}return n(e,[{key:"bind",value:function(e,t){var r=this;this._target=e,this._filter="function"==typeof t?t:null,Object.keys(this._listeners).forEach((function(e){r._listeners[e].forEach((function(t){return r._bind(e,t)}))}))}},{key:"_bind",value:function(e,t){var r=this,n=this._eventAdapter&&this._eventAdapter.bind(e,t);if(n&&n.local){(this._bindings[e]||(this._bindings[e]=[])).push({callback:t,local:!0})}else{var o=n?n.type:e,i=n?n.callback:t,s=this._filter?function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];r._filter(o,t)&&i.apply(null,t)}:i;(this._bindings[e]||(this._bindings[e]=[])).push({callback:t,sourceType:o,wrapped:s}),this._target.on(o,s)}}},{key:"_unbind",value:function(e,t){var r=this,n=this._bindings[e]||[];n.slice().forEach((function(e){void 0!==t&&t!==e.callback||(e.local||("function"!=typeof r._target.listenerCount||r._target.listenerCount(e.sourceType)>0)&&r._target.removeEvent(e.sourceType,e.wrapped),n.splice(n.indexOf(e),1))})),n.length||delete this._bindings[e]}},{key:"on",value:function(e,t){if("function"!=typeof t)return this;this._eventAdapter&&"function"==typeof this._eventAdapter.validate&&this._eventAdapter.validate(e);var r=this._listeners[e]||(this._listeners[e]=[]);return-1===r.indexOf(t)&&(r.push(t),this._target&&this._bind(e,t)),this}},{key:"off",value:function(e,t){var r=this,n=this._listeners[e]||[];return n.slice().forEach((function(o){void 0!==t&&o!==t||(r._target&&r._unbind(e,o),n.splice(n.indexOf(o),1))})),n.length||delete this._listeners[e],this}},{key:"removeEvent",value:function(e,t){var r=this;return arguments.length?this.off(e,t):(Object.keys(this._listeners).forEach((function(e){return r.off(e)})),this)}},{key:"emit",value:function(e){var t=Array.prototype.slice.call(arguments,1);(this._listeners[e]||[]).slice().forEach((function(e){return e.apply(null,t)}))}},{key:"listenerCount",value:function(e){return(this._listeners[e]||[]).length}},{key:"clear",value:function(){var e=this;this._target&&Object.keys(this._bindings).forEach((function(t){return e._unbind(t)})),this._target=null,this._filter=null,this._listeners=Object.create(null),this._bindings=Object.create(null)}}]),e}();function v(e){var t=Object.assign({},e);return y.forEach((function(e){delete t[e]})),t}function b(e,t){var r=new Error(e);return r.code=t,r}Object.getOwnPropertyNames(i.prototype).forEach((function(e){"constructor"===e||"_"===e.charAt(0)||Object.prototype.hasOwnProperty.call(m.prototype,e)||"function"==typeof Object.getOwnPropertyDescriptor(i.prototype,e).value&&(m.prototype[e]=function(){return this._invoke(e,Array.prototype.slice.call(arguments))})})),e.exports=function(e){var t=Object.assign({},e||{});if(t.compatibility=g.validateCompatibility(t.compatibility),void 0===t.protocol&&(t.protocol="fpnn"),void 0!==t.sharing&&"boolean"!=typeof t.sharing)throw new TypeError("sharing must be a boolean");var r=f(v(t)),n="shared",o=null;return!1===t.sharing?n="direct":"function"!=typeof SharedWorker?(n="direct",o="SharedWorker is unavailable in this runtime"):(o=h(r))&&(n="direct"),new m(t,{mode:n,fallbackReason:o})}},function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};var o=r(0),i=r(12),s={login:"auth",bye:"bye",getServerTime:"getservertime",addAttrs:"addattrs",getAttrs:"getattrs",addDebugLog:"adddebuglog",getOnlineUsers:"getonlineusers",setUserInfo:"setuserinfo",getUserInfo:"getuserinfo",getUserOpenInfo:"getuseropeninfo",setTranslationLanguage:"setlang",dataSet:"dataset",dataGet:"dataget",dataDelete:"datadel",addBlacks:"addblacks",deleteBlacks:"delblacks",getBlacks:"getblacks",addGroupMembers:"addgroupmembers",deleteGroupMembers:"delgroupmembers",getGroupMembers:"getgroupmembers",getGroupCount:"getgroupcount",getUserGroups:"getusergroups",enterRoom:"enterroom",enterRooms:"enterrooms",leaveRoom:"leaveroom",getUserRooms:"getuserrooms",getRoomMembers:"getroommembers",getRoomCount:"getroomcount",setGroupInfo:"setgroupinfo",getGroupInfo:"getgroupinfo",getGroupOpenInfo:"getgroupopeninfo",getGroupsOpenInfo:"getgroupsopeninfo",setRoomInfo:"setroominfo",setRoomProfile:"setroominfo",getRoomInfo:"getroominfo",getRoomOpenInfo:"getroomopeninfo",getRoomsOpenInfo:"getroomsopeninfo",getUserRoomsAndLastMessage:"getuserroomsandlastmsg",sendMessage:"sendmsg",sendMessages:"sendmsgs",sendGroupMessage:"sendgroupmsg",sendRoomMessage:"sendroommsg",sendChat:"sendmsg",sendAudio:"sendmsg",sendCmd:"sendmsg",sendGroupChat:"sendgroupmsg",sendGroupAudio:"sendgroupmsg",sendGroupCmd:"sendgroupmsg",sendRoomChat:"sendroommsg",sendRoomAudio:"sendroommsg",sendRoomCmd:"sendroommsg",getUnreadMessage:"getunread",getP2PUnreadMessageNum:"getp2punread",getGroupUnreadMessageNum:"getgroupunread",cleanUnreadMessage:"cleanunread",setSessionRead:"setsessionread",getSession:"getsession",getGroupMessage:"getgroupmsg",getRoomMessage:"getroommsg",getBroadcastMessage:"getbroadcastmsg",getP2PMessage:"getp2pmsg",getGroupChat:"getgroupmsg",getRoomChat:"getroommsg",getBroadcastChat:"getbroadcastmsg",getP2PChat:"getp2pmsg",getP2PMessageByMessageId:"getp2pmsgbymessageid",getGroupMessageByMessageId:"getgroupmsgbymessageid",getRoomMessageByMessageId:"getroommsgbymessageid",getBroadcastMessageByMessageId:"getbroadcastmsgbymessageid",getP2PMessageCount:"getp2pmsgcount",getGroupMessageCount:"getgroupmsgcount",getRoomMessageCount:"getroommsgcount",getBroadcastMessageCount:"getbroadcastmsgcount",getMessage:"getmsg",getChat:"getmsg",deleteMessage:"delmsg",deleteChat:"delmsg",translate:"translate",textCheck:"tcheck",getP2PConversationList:"getp2pconversationlist",getP2PUnreadConversationList:"getp2punreadconversationlist",getGroupConversationList:"getgroupconversationlist",getGroupUnreadConversationList:"getgroupunreadconversationlist",getUnreadConversationList:"getunreadconversationlist",removeSession:"removesession"},a={sendMessage:4,sendMessages:4,sendGroupMessage:4,sendRoomMessage:4,sendChat:3,sendAudio:3,sendCmd:3,sendGroupChat:3,sendGroupAudio:3,sendGroupCmd:3,sendRoomChat:3,sendRoomAudio:3,sendRoomCmd:3,sendFile:3,sendGroupFile:3,sendRoomFile:3},u=new Set(Object.keys(a)),c={sendMessage:{values:[0,4]},sendMessages:{values:[4],arrays:[0]},sendGroupMessage:{values:[0,4]},sendRoomMessage:{values:[0,4]},getP2PUnreadMessageNum:{arrays:[0],values:[1]},getGroupUnreadMessageNum:{arrays:[0],values:[1]},setSessionRead:{values:[1,2]},getGroupMessage:{values:[0,3,4,5]},getRoomMessage:{values:[0,3,4,5]},getBroadcastMessage:{values:[2,3,4]},getP2PMessage:{values:[0,3,4,5]},getP2PMessageByMessageId:{values:[0,1,4,5]},getGroupMessageByMessageId:{values:[0,1,4,5]},getRoomMessageByMessageId:{values:[0,1,4,5]},getBroadcastMessageByMessageId:{values:[0,3,4]},getP2PMessageCount:{values:[0,1,2]},getGroupMessageCount:{values:[0,1,2]},getRoomMessageCount:{values:[0,1,2]},getBroadcastMessageCount:{values:[0,1]},getGroupsOpenInfo:{arrays:[0]},getRoomsOpenInfo:{arrays:[0]},getRoomMembers:{values:[0]},getRoomCount:{arrays:[0]},getGroupMembers:{values:[0]},getGroupCount:{values:[0]},addGroupMembers:{values:[0],arrays:[1]},deleteGroupMembers:{values:[0],arrays:[1]},enterRoom:{values:[0]},enterRooms:{arrays:[0]},leaveRoom:{values:[0]},getOnlineUsers:{arrays:[0]},getUserOpenInfo:{arrays:[0]},deleteMessage:{values:[0,1,2]},getMessage:{values:[0,1,2]},deleteChat:{values:[0,1,2]},getChat:{values:[0,1,2]},setGroupInfo:{values:[0]},getGroupInfo:{values:[0]},getGroupOpenInfo:{values:[0]},setRoomInfo:{values:[0]},setRoomProfile:{values:[0]},getRoomInfo:{values:[0]},getRoomOpenInfo:{values:[0]},addBlacks:{arrays:[0]},deleteBlacks:{arrays:[0]},sendChat:{values:[0,3]},sendAudio:{values:[0,3]},sendCmd:{values:[0,3]},sendGroupChat:{values:[0,3]},sendGroupAudio:{values:[0,3]},sendGroupCmd:{values:[0,3]},sendRoomChat:{values:[0,3]},sendRoomAudio:{values:[0,3]},sendRoomCmd:{values:[0,3]},getGroupChat:{values:[0,3,4,5]},getRoomChat:{values:[0,3,4,5]},getP2PChat:{values:[0,3,4,5]},getBroadcastChat:{values:[2,3,4]},getP2PConversationList:{values:[0]},getP2PUnreadConversationList:{values:[0]},getGroupConversationList:{values:[0]},getGroupUnreadConversationList:{values:[0]},getUnreadConversationList:{values:[1]},removeSession:{values:[0]}},f=new Set(["getGroupMessage","getRoomMessage","getBroadcastMessage","getP2PMessage","getGroupChat","getRoomChat","getBroadcastChat","getP2PChat","getP2PMessageByMessageId","getGroupMessageByMessageId","getRoomMessageByMessageId","getBroadcastMessageByMessageId"]),l={getP2PMessage:"direct",getP2PChat:"direct",getP2PMessageByMessageId:"direct",getGroupMessage:"group",getGroupChat:"group",getGroupMessageByMessageId:"group",getRoomMessage:"room",getRoomChat:"room",getRoomMessageByMessageId:"room",getBroadcastMessage:"broadcast",getBroadcastChat:"broadcast",getBroadcastMessageByMessageId:"broadcast"},h={"event.direct":{category:"direct",id:"recipient",events:{message:o.SERVER_PUSH.recvMessage,file:o.SERVER_PUSH.recvFile,chat:o.SERVER_PUSH.recvChat,cmd:o.SERVER_PUSH.recvCmd}},"event.group":{category:"group",id:"group_ref",events:{message:o.SERVER_PUSH.recvGroupMessage,file:o.SERVER_PUSH.recvGroupFile,chat:o.SERVER_PUSH.recvGroupChat,cmd:o.SERVER_PUSH.recvGroupCmd}},"event.room":{category:"room",id:"room_ref",events:{message:o.SERVER_PUSH.recvRoomMessage,file:o.SERVER_PUSH.recvRoomFile,chat:o.SERVER_PUSH.recvRoomChat,cmd:o.SERVER_PUSH.recvRoomCmd}},"event.broadcast":{category:"broadcast",id:null,events:{message:o.SERVER_PUSH.recvBroadcastMessage,file:o.SERVER_PUSH.recvBroadcastFile,chat:o.SERVER_PUSH.recvBroadcastChat,cmd:o.SERVER_PUSH.recvBroadcastCmd}},"event.kicked":{category:"kicked",id:null,events:{message:o.SERVER_PUSH.kickOut}},"event.room_removed":{category:"room_removed",id:"room_ref",events:{message:o.SERVER_PUSH.kickOutRoom}}},d=new Set(Object.keys(h)),p=new Set([o.SERVER_PUSH.recvAudio,o.SERVER_PUSH.recvGroupAudio,o.SERVER_PUSH.recvRoomAudio,o.SERVER_PUSH.recvBroadcastAudio]),g=function(e){function t(e,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.name="RTMCompatibilityError",n.code=r&&r.code||"RTM_COMPATIBILITY_MAPPING_FAILED",n.method=r&&r.method,n.protocol=r&&r.protocol,n.compatibility="legacy-rtm",r&&void 0!==r.cause&&(n.cause=r.cause),n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,Error),t}();function y(e){if("string"!=typeof e||!/^-?\d+$/.test(e))return e;var t="-"===e.charAt(0),r=(t?e.slice(1):e).replace(/^0+/,"")||"0",n=t?"9223372036854775808":"9223372036854775807";return r.length>n.length||r.length===n.length&&r>n?e:o.Int64(e)}function m(e,t,r){if(w(r,e),!t)throw e;t(e,null)}function _(e,t,r,n){if(null==t)return t;if(u.has(e))return function(e,t,r){var n=v(r[a[e]],e);if(t&&Object.prototype.hasOwnProperty.call(t,"error"))return{mid:n,error:t.error};if(!I(t))throw new g("Cannot map "+e+" result to the legacy RTM response shape.",{method:e,protocol:"tlv-v1"});var o=I(t.payload)?Object.assign({},t.payload):Object.assign({},t),i=void 0!==t.message_ref?t.message_ref:o.message_ref,s=o.time_ms;delete o.message_ref,delete o.time_ms,void 0!==s&&(o.mtime=s);return{mid:n||i,payload:o}}(e,t,r);var o=s[e],c=o&&i.ROUTES[o],h=c&&c.response&&I(t)?function(e,t,r,n){var o=Object.assign({},t);return Object.keys(r).forEach((function(t){var i=r[t];if(t!==i&&Object.prototype.hasOwnProperty.call(o,i)){if(Object.prototype.hasOwnProperty.call(o,t))throw new g("Cannot map "+e+' response: both "'+t+'" and "'+i+'" are present.',{method:e,protocol:n});o[t]=o[i],delete o[i]}})),o}(e,t,c.response,n):t;if(!I(h))return h;if(h=Object.assign({},h),f.has(e)&&Array.isArray(h.msgs)){var d=l[e];h.msgs=h.msgs.map((function(t){return k(t,d,e,n)}))}if("getMessage"!==e&&"getChat"!==e||(h=function(e,t,r){var n=Object.assign({},e);void 0!==n.id&&(n.id=A(n.id,"id",t,r));void 0!==n.mid&&(n.mid=A(n.mid,"mid",t,r));void 0!==n.mtime&&(n.mtime=A(n.mtime,"mtime",t,r));void 0!==n.from&&(n.from=A(n.from,"from",t,r));void 0!==n.msg&&(n.msg=C(n.msg));return n}(h,e,n)),"getUserRoomsAndLastMessage"===e&&I(h.rooms)){var p={};Object.keys(h.rooms).forEach((function(t){p[t]=k(h.rooms[t],"room",e,n)})),h.rooms=p}if("getP2PConversationList"===e||"getP2PUnreadConversationList"===e||"getGroupConversationList"===e||"getGroupUnreadConversationList"===e){var y=e.startsWith("getGroup")?"group":"direct";Array.isArray(h.msgs)&&(h.msgs=h.msgs.map((function(t){return k(t,y,e,n)})))}return"getUnreadConversationList"===e&&(Array.isArray(h.p2pMsgs)&&(h.p2pMsgs=h.p2pMsgs.map((function(t){return k(t,"direct",e,n)}))),Array.isArray(h.groupMsgs)&&(h.groupMsgs=h.groupMsgs.map((function(t){return k(t,"group",e,n)})))),h}function v(e,t){return null==e||""===String(e)||/^[+-]?0+$/.test(String(e))?b(t):e}function b(e){var t="undefined"!=typeof globalThis?globalThis.crypto:null;if(!t||"function"!=typeof t.getRandomValues)throw new g("crypto.getRandomValues() is required to generate legacy RTM message IDs.",{method:e,protocol:"tlv-v1",code:"RTM_COMPATIBILITY_UNSUPPORTED"});var r=new Uint32Array(2);return t.getRandomValues(r),r[0]=2147483647&r[0],0===r[0]&&0===r[1]&&(r[1]=1),o.Int64(function(e,t){var r=[e>>>16,65535&e,t>>>16,65535&t],n="";for(;r.some(Boolean);){for(var o=0,i=0;i<r.length;i+=1){var s=65536*o+r[i];r[i]=Math.floor(s/10),o=s%10}n=String(o)+n}return n||"0"}(r[0],r[1]))}function w(e,t){if("function"==typeof e)try{e(t)}catch(e){}}function E(e){if(e===o.SERVER_PUSH.kickOut)return"event.kicked";if(e===o.SERVER_PUSH.kickOutRoom)return"event.room_removed";for(var t=Object.keys(h),r=function(r){var n=t[r],o=h[n];if(o&&o.events&&Object.keys(o.events).some((function(t){return o.events[t]===e})))return{v:n}},i=0;i<t.length;i+=1){var s=r(i);if("object"===(void 0===s?"undefined":n(s)))return s.v}return null}function k(e,t,r,n){if(!Array.isArray(e)){if(!I(e))throw new g("Cannot map "+r+" history row: expected a tuple or message object.",{method:r,protocol:n});return Object.assign({},e)}if(8!==e.length)throw new g("Cannot map "+r+" history row: expected an 8-field tuple.",{method:r,protocol:n});var o,i={id:A(e[0],"history.id",r,n),mtype:Number(S(e[2],"history.kind",r,n)),mid:A(e[3],"history.message_ref",r,n),deleted:e[4],msg:R(e[5],Number(S(e[2],"history.kind",r,n))),binary:(o=e[5],C(o)),attrs:R(e[6],0),mtime:A(e[7],"history.time_ms",r,n)};return"direct"===t?i.direction=Number(S(e[1],"history.direction",r,n)):i.from=A(e[1],"history.sender",r,n),i}function R(e,t){if("string"==typeof e)return e;var r=O(e);if(r)try{if("function"!=typeof TextDecoder)return;return new TextDecoder("utf-8",{fatal:!0}).decode(r)}catch(e){return}}function P(e){if("string"==typeof e||null==e)return e;var t=R(e);return void 0===t?C(e):t}function C(e,t){var r=O(e);if(r)return T(r);if(e instanceof ArrayBuffer)return e.slice(0);if(!e||"object"!==(void 0===e?"undefined":n(e)))return e;if(e.buffer&&"number"==typeof e.offset&&"function"==typeof e.toString)return e;var o=t||new Map;if(o.has(e))return o.get(e);if(Array.isArray(e)){var i=[];return o.set(e,i),e.forEach((function(e){return i.push(C(e,o))})),i}var s=Object.create(null===Object.getPrototypeOf(e)?null:Object.prototype);return o.set(e,s),Object.keys(e).forEach((function(t){s[t]=C(e[t],o)})),s}function O(e){return e instanceof ArrayBuffer?new Uint8Array(e):ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):null}function T(e){return new Uint8Array(e)}function A(e,t,r,n){var i=S(e,t,r,n);return o.Int64(i)}function S(e,t,r,n){if(e&&"function"==typeof e.toString){var o=e.toString();if(/^-?\d+$/.test(o))return o}if("number"==typeof e&&Number.isSafeInteger(e))return String(e);throw new g("Cannot map "+r+": "+t+" is not an exact integer.",{method:r,protocol:n||"tlv-v1"})}function M(e,t,r){if(e instanceof g)return e;var n=new g("Failed to adapt legacy RTM "+t+" contract: "+(e&&e.message?e.message:String(e)),{method:t,protocol:r,cause:e,code:"RTM_COMPATIBILITY_MAPPING_FAILED"});return e&&e.stack&&(n.stack=e.stack+"\nCaused by: "+n.stack),n}function I(e){if(!e||"object"!==(void 0===e?"undefined":n(e))||Array.isArray(e))return!1;var t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}e.exports={METHOD_ROUTES:s,RTMCompatibilityError:g,SEND_MID_INDEX:a,adaptResult:_,createPushAdapter:function(e){return{validate:function(t){if(d.has(t)){var r=new g('legacy Push names only; use compatibility "native" to observe raw TLV Push names.',{method:"processor.on",protocol:"tlv-v1",code:"RTM_COMPATIBILITY_UNSUPPORTED"});throw w(e,r),r}if(t===o.SERVER_PUSH.recvPing){var n=new g("TLV has no server ping Push; the SDK heartbeat is internal.",{method:"processor.on",protocol:"tlv-v1",code:"RTM_COMPATIBILITY_UNSUPPORTED"});throw w(e,n),n}if(p.has(t)){var i=new g("Legacy RTM does not emit a dedicated audio event; subscribe to pushfile.",{method:"processor.on",protocol:"tlv-v1",code:"RTM_COMPATIBILITY_UNSUPPORTED"});throw w(e,i),i}if("CompatibilityError"!==t&&!E(t)){var s=new g('Unsupported legacy RTM Processor event "'+String(t)+'".',{method:"processor.on",protocol:"tlv-v1",code:"RTM_COMPATIBILITY_UNSUPPORTED"});throw w(e,s),s}},bind:function(t,r){if("CompatibilityError"===t)return{local:!0};var n=E(t);return n?{type:n,callback:function(i){var s=void 0;try{s=function(e,t,r){var n=h[e];if(!n)return null;var i=I(t)?t:{};if("event.kicked"===e||"event.room_removed"===e){var s={};return n.id&&void 0!==i[n.id]&&(s.rid=i[n.id]),r===o.SERVER_PUSH.kickOutRoom&&void 0===s.rid?null:s}var a=Number(S(i.kind,"kind",r)),u="message";a===o.CHAT_TYPE.text?u="chat":a===o.CHAT_TYPE.cmd?u="cmd":(a===o.CHAT_TYPE.audio||a>=40&&a<=50)&&(u="file");if(n.events[u]!==r)return null;var c=C(i.payload),f=O(i.payload),l=a!==o.CHAT_TYPE.text,d={from:A(i.sender,"sender",r),mtype:a,mid:A(i.message_ref,"message_ref",r),msg:l?P(i.payload):c,attrs:P(i.extra),mtime:A(i.time_ms,"time_ms",r)};l&&f?d.binary=T(f):l&&void 0!==i.binary&&(d.binary=C(i.binary));n.id&&void 0!==i[n.id]&&(d["group"===n.category?"gid":"room"===n.category?"rid":"to"]=i[n.id]);return d}(n,i,t)}catch(r){return void w(e,M(r,"processor."+t,"tlv-v1"))}s&&r(s)}}:null}}},generateMessageId:b,isEnabled:function(e,t){return"legacy-rtm"===e&&"tlv-v1"===t},invoke:function(e,t,r,o,i,f){var l=t.slice(),h=function(e,t){if(t>=0&&"function"==typeof e[t])return t;for(var r=e.length-1;r>=0;r-=1)if("function"==typeof e[r])return r;return-1}(l,i),d=h>=0?l[h]:null,p=a[e],b=void 0,E=!1,k=void 0;function R(){try{return d.apply(null,arguments)}catch(e){throw k=e,e}}if(!s[e])return m(new g('No TLV v1 equivalent for legacy RTM method "'+e+'".',{method:e,protocol:o,code:"RTM_COMPATIBILITY_UNSUPPORTED"}),d,f);!function(e,t){var r=c[e];if(!r)return;(r.values||[]).forEach((function(e){e<t.length&&(t[e]=y(t[e]))})),(r.arrays||[]).forEach((function(e){e<t.length&&Array.isArray(t[e])&&(t[e]=t[e].map((function(e){return y(e)})))}))}(e,l);try{void 0!==p&&(b=v(l[p],e),l[p]=b)}catch(t){return m(M(t,e,o),d,f)}d&&(l[h]=function(t,r){if(!E)if(E=!0,t)R(function(e,t,r){if(!u.has(e)||!t||"object"!==(void 0===t?"undefined":n(t))||!Object.prototype.hasOwnProperty.call(t,"error"))return t;var o=Object.assign({},t);return delete o.message_ref,o.mid=void 0!==r?r:t.mid,o}(e,t,b),null);else{var i=void 0;try{i=_(e,r,l,o)}catch(t){var s=M(t,e,o);return w(f,s),void R(s,null)}R(null,i)}});try{return r[e].apply(r,l)}catch(e){if(k===e)throw e;if(d){if(E)return;return E=!0,e instanceof g?m(e,d,f):void d(e,null)}throw e instanceof g&&"function"==typeof f&&f(e),e}},toLegacyHistoryMessage:k,validateCompatibility:function(e){if(void 0===e)return"native";if("native"===e||"legacy-rtm"===e)return e;throw new TypeError('compatibility must be "native" or "legacy-rtm"')}}}])}));