UNPKG

ldpos-client

Version:
1 lines 485 kB
function e(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(r){if("default"!==r&&!(r in e)){var a=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,a.get?a:{enumerable:!0,get:function(){return t[r]}})}}))})),Object.freeze(e)}var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function r(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function a(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var a=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,a.get?a:{enumerable:!0,get:function(){return e[t]}})})),r}var o={};var i=class{async next(e){let t=this.createConsumer(e),r=await t.next();return t.return(),r}async once(e){let t=await this.next(e);if(t.done){if(null!=e){let e=new Error("Stream consumer operation timed out early because stream ended");throw e.name="TimeoutError",e}await new Promise((()=>{}))}return t.value}createConsumer(){throw new TypeError("Method must be overriden by subclass")}[Symbol.asyncIterator](){return this.createConsumer()}};let n=class{constructor(e,t,r,a){this.id=t,this._backpressure=0,this.currentNode=r,this.timeout=a,this.isAlive=!0,this.stream=e,this.stream.setConsumer(this.id,this)}getStats(){let e={id:this.id,backpressure:this._backpressure};return null!=this.timeout&&(e.timeout=this.timeout),e}_resetBackpressure(){this._backpressure=0}applyBackpressure(e){this._backpressure++}releaseBackpressure(e){this._backpressure--}getBackpressure(){return this._backpressure}clearActiveTimeout(){clearTimeout(this._timeoutId),delete this._timeoutId}write(e){void 0!==this._timeoutId&&this.clearActiveTimeout(e),this.applyBackpressure(e),this._resolve&&(this._resolve(),delete this._resolve)}kill(e){this._killPacket={value:e,done:!0},void 0!==this._timeoutId&&this.clearActiveTimeout(this._killPacket),this._destroy(),this._resolve&&(this._resolve(),delete this._resolve)}_destroy(){this.isAlive=!1,this._resetBackpressure(),this.stream.removeConsumer(this.id)}async _waitForNextItem(e){return new Promise(((t,r)=>{let a;if(this._resolve=t,void 0!==e){let t=new Error("Stream consumer iteration timed out");(async()=>{let o=function(e){let t,r=new Promise((r=>{t=setTimeout(r,e)}));return{timeoutId:t,promise:r}}(e);a=o.timeoutId,await o.promise,t.name="TimeoutError",delete this._resolve,r(t)})()}this._timeoutId=a}))}async next(){for(this.stream.setConsumer(this.id,this);;){if(!this.currentNode.next)try{await this._waitForNextItem(this.timeout)}catch(e){throw this._destroy(),e}if(this._killPacket){this._destroy();let e=this._killPacket;return delete this._killPacket,e}if(this.currentNode=this.currentNode.next,this.releaseBackpressure(this.currentNode.data),!this.currentNode.consumerId||this.currentNode.consumerId===this.id)return this.currentNode.data.done&&this._destroy(),this.currentNode.data}}return(){return delete this.currentNode,this._destroy(),{}}[Symbol.asyncIterator](){return this}};const s=i,u=n;var l=class extends s{constructor(e){super(),e=e||{},this._nextConsumerId=1,this.generateConsumerId=e.generateConsumerId,this.generateConsumerId||(this.generateConsumerId=()=>this._nextConsumerId++),this.removeConsumerCallback=e.removeConsumerCallback,this._consumers=new Map,this.tailNode={next:null,data:{value:void 0,done:!1}}}_write(e,t,r){let a={data:{value:e,done:t},next:null};r&&(a.consumerId=r),this.tailNode.next=a,this.tailNode=a;for(let e of this._consumers.values())e.write(a.data)}write(e){this._write(e,!1)}close(e){this._write(e,!0)}writeToConsumer(e,t){this._write(t,!1,e)}closeConsumer(e,t){this._write(t,!0,e)}kill(e){for(let t of this._consumers.keys())this.killConsumer(t,e)}killConsumer(e,t){let r=this._consumers.get(e);r&&r.kill(t)}getBackpressure(){let e=0;for(let t of this._consumers.values()){let r=t.getBackpressure();r>e&&(e=r)}return e}getConsumerBackpressure(e){let t=this._consumers.get(e);return t?t.getBackpressure():0}hasConsumer(e){return this._consumers.has(e)}setConsumer(e,t){this._consumers.set(e,t),t.currentNode||(t.currentNode=this.tailNode)}removeConsumer(e){let t=this._consumers.delete(e);return this.removeConsumerCallback&&this.removeConsumerCallback(e),t}getConsumerStats(e){let t=this._consumers.get(e);if(t)return t.getStats()}getConsumerStatsList(){let e=[];for(let t of this._consumers.values())e.push(t.getStats());return e}createConsumer(e){return new u(this,this.generateConsumerId(),this.tailNode,e)}getConsumerList(){return[...this._consumers.values()]}getConsumerCount(){return this._consumers.size}};const c=class{async next(e){let t=this.createConsumer(e),r=await t.next();return t.return(),r}async once(e){let t=await this.next(e);if(t.done){if(null!=e){let e=new Error("Stream consumer operation timed out early because stream ended");throw e.name="TimeoutError",e}await new Promise((()=>{}))}return t.value}createConsumer(){throw new TypeError("Method must be overriden by subclass")}[Symbol.asyncIterator](){return this.createConsumer()}};var h=class extends c{constructor(e,t){super(),this._streamDemux=e,this.name=t}createConsumer(e){return this._streamDemux.createConsumer(this.name,e)}};const d=l,p=h;var f=class{constructor(){this.streams={},this._nextConsumerId=1,this.generateConsumerId=()=>this._nextConsumerId++}write(e,t){this.streams[e]&&this.streams[e].write(t)}close(e,t){this.streams[e]&&this.streams[e].close(t)}closeAll(e){for(let t of Object.values(this.streams))t.close(e)}writeToConsumer(e,t){for(let r of Object.values(this.streams))if(r.hasConsumer(e))return r.writeToConsumer(e,t)}closeConsumer(e,t){for(let r of Object.values(this.streams))if(r.hasConsumer(e))return r.closeConsumer(e,t)}getConsumerStats(e){for(let[t,r]of Object.entries(this.streams))if(r.hasConsumer(e))return{...r.getConsumerStats(e),stream:t}}getConsumerStatsList(e){return this.streams[e]?this.streams[e].getConsumerStatsList().map((t=>({...t,stream:e}))):[]}getConsumerStatsListAll(){let e=[];for(let t of Object.keys(this.streams)){let r=this.getConsumerStatsList(t);for(let t of r)e.push(t)}return e}kill(e,t){this.streams[e]&&this.streams[e].kill(t)}killAll(e){for(let t of Object.values(this.streams))t.kill(e)}killConsumer(e,t){for(let r of Object.values(this.streams))if(r.hasConsumer(e))return r.killConsumer(e,t)}getBackpressure(e){return this.streams[e]?this.streams[e].getBackpressure():0}getBackpressureAll(){return Object.values(this.streams).reduce(((e,t)=>Math.max(e,t.getBackpressure())),0)}getConsumerBackpressure(e){for(let t of Object.values(this.streams))if(t.hasConsumer(e))return t.getConsumerBackpressure(e);return 0}hasConsumer(e,t){return!!this.streams[e]&&this.streams[e].hasConsumer(t)}hasConsumerAll(e){return Object.values(this.streams).some((t=>t.hasConsumer(e)))}getConsumerCount(e){return this.streams[e]?this.streams[e].getConsumerCount():0}getConsumerCountAll(){return Object.values(this.streams).reduce(((e,t)=>e+t.getConsumerCount()),0)}createConsumer(e,t){return this.streams[e]||(this.streams[e]=new d({generateConsumerId:this.generateConsumerId,removeConsumerCallback:()=>{this.getConsumerCount(e)||delete this.streams[e]}})),this.streams[e].createConsumer(t)}stream(e){return new p(this,e)}unstream(e){delete this.streams[e]}};const m=f;function g(e){this._listenerDemux=new m}g.prototype.emit=function(e,t){this._listenerDemux.write(e,t)},g.prototype.listener=function(e){return this._listenerDemux.stream(e)},g.prototype.closeListener=function(e){this._listenerDemux.close(e)},g.prototype.closeAllListeners=function(){this._listenerDemux.closeAll()},g.prototype.removeListener=function(e){this._listenerDemux.unstream(e)},g.prototype.getListenerConsumerStats=function(e){return this._listenerDemux.getConsumerStats(e)},g.prototype.getListenerConsumerStatsList=function(e){return this._listenerDemux.getConsumerStatsList(e)},g.prototype.getAllListenersConsumerStatsList=function(){return this._listenerDemux.getConsumerStatsListAll()},g.prototype.getListenerConsumerCount=function(e){return this._listenerDemux.getConsumerCount(e)},g.prototype.getAllListenersConsumerCount=function(){return this._listenerDemux.getConsumerCountAll()},g.prototype.killListener=function(e){this._listenerDemux.kill(e)},g.prototype.killAllListeners=function(){this._listenerDemux.killAll()},g.prototype.killListenerConsumer=function(e){this._listenerDemux.killConsumer(e)},g.prototype.getListenerBackpressure=function(e){return this._listenerDemux.getBackpressure(e)},g.prototype.getAllListenersBackpressure=function(){return this._listenerDemux.getBackpressureAll()},g.prototype.getListenerConsumerBackpressure=function(e){return this._listenerDemux.getConsumerBackpressure(e)},g.prototype.hasListenerConsumer=function(e,t){return this._listenerDemux.hasConsumer(e,t)},g.prototype.hasAnyListenerConsumer=function(e){return this._listenerDemux.hasConsumerAll(e)};var b=g;const v=class{async next(e){let t=this.createConsumer(e),r=await t.next();return t.return(),r}async once(e){let t=await this.next(e);return t.done&&await new Promise((()=>{})),t.value}createConsumer(){throw new TypeError("Method must be overriden by subclass")}[Symbol.asyncIterator](){return this.createConsumer()}};let y=class e extends v{constructor(t,r,a,o){super(),this.PENDING=e.PENDING,this.SUBSCRIBED=e.SUBSCRIBED,this.UNSUBSCRIBED=e.UNSUBSCRIBED,this.name=t,this.client=r,this._eventDemux=a,this._dataStream=o.stream(this.name)}createConsumer(e){return this._dataStream.createConsumer(e)}listener(e){return this._eventDemux.stream(`${this.name}/${e}`)}close(){this.client.closeChannel(this.name)}kill(){this.client.killChannel(this.name)}killOutputConsumer(e){this.hasOutputConsumer(e)&&this.client.killChannelOutputConsumer(e)}killListenerConsumer(e){this.hasAnyListenerConsumer(e)&&this.client.killChannelListenerConsumer(e)}getOutputConsumerStats(e){if(this.hasOutputConsumer(e))return this.client.getChannelOutputConsumerStats(e)}getListenerConsumerStats(e){if(this.hasAnyListenerConsumer(e))return this.client.getChannelListenerConsumerStats(e)}getBackpressure(){return this.client.getChannelBackpressure(this.name)}getListenerConsumerBackpressure(e){return this.hasAnyListenerConsumer(e)?this.client.getChannelListenerConsumerBackpressure(e):0}getOutputConsumerBackpressure(e){return this.hasOutputConsumer(e)?this.client.getChannelOutputConsumerBackpressure(e):0}closeOutput(){this.client.channelCloseOutput(this.name)}closeListener(e){this.client.channelCloseListener(this.name,e)}closeAllListeners(){this.client.channelCloseAllListeners(this.name)}killOutput(){this.client.channelKillOutput(this.name)}killListener(e){this.client.channelKillListener(this.name,e)}killAllListeners(){this.client.channelKillAllListeners(this.name)}getOutputConsumerStatsList(){return this.client.channelGetOutputConsumerStatsList(this.name)}getListenerConsumerStatsList(e){return this.client.channelGetListenerConsumerStatsList(this.name,e)}getAllListenersConsumerStatsList(){return this.client.channelGetAllListenersConsumerStatsList(this.name)}getOutputBackpressure(){return this.client.channelGetOutputBackpressure(this.name)}getListenerBackpressure(e){return this.client.channelGetListenerBackpressure(this.name,e)}getAllListenersBackpressure(){return this.client.channelGetAllListenersBackpressure(this.name)}hasOutputConsumer(e){return this.client.channelHasOutputConsumer(this.name,e)}hasListenerConsumer(e,t){return this.client.channelHasListenerConsumer(this.name,e,t)}hasAnyListenerConsumer(e){return this.client.channelHasAnyListenerConsumer(this.name,e)}get state(){return this.client.getChannelState(this.name)}set state(e){throw new Error("Cannot directly set channel state")}get options(){return this.client.getChannelOptions(this.name)}set options(e){throw new Error("Cannot directly set channel options")}subscribe(e){this.client.subscribe(this.name,e)}unsubscribe(){this.client.unsubscribe(this.name)}isSubscribed(e){return this.client.isSubscribed(this.name,e)}transmitPublish(e){return this.client.transmitPublish(this.name,e)}invokePublish(e){return this.client.invokePublish(this.name,e)}};y.PENDING="pending",y.SUBSCRIBED="subscribed",y.UNSUBSCRIBED="unsubscribed";var k=y;function w(){this._internalStorage={},this.isLocalStorageEnabled=this._checkLocalStorageEnabled()}w.prototype._checkLocalStorageEnabled=function(){let e;try{localStorage.setItem("__scLocalStorageTest",1),localStorage.removeItem("__scLocalStorageTest")}catch(t){e=t}return!e},w.prototype.saveToken=function(e,t,r){return this.isLocalStorageEnabled?localStorage.setItem(e,t):this._internalStorage[e]=t,Promise.resolve(t)},w.prototype.removeToken=function(e){let t=this.loadToken(e);return this.isLocalStorageEnabled?localStorage.removeItem(e):delete this._internalStorage[e],t},w.prototype.loadToken=function(e){let t;return t=this.isLocalStorageEnabled?localStorage.getItem(e):this._internalStorage[e]||null,Promise.resolve(t)};var _=w,S="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},E=[],x=[],z="undefined"!=typeof Uint8Array?Uint8Array:Array,T=!1;function A(){T=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)E[t]=e[t],x[e.charCodeAt(t)]=t;x["-".charCodeAt(0)]=62,x["_".charCodeAt(0)]=63}function C(e,t,r){for(var a,o,i=[],n=t;n<r;n+=3)a=(e[n]<<16)+(e[n+1]<<8)+e[n+2],i.push(E[(o=a)>>18&63]+E[o>>12&63]+E[o>>6&63]+E[63&o]);return i.join("")}function j(e){var t;T||A();for(var r=e.length,a=r%3,o="",i=[],n=16383,s=0,u=r-a;s<u;s+=n)i.push(C(e,s,s+n>u?u:s+n));return 1===a?(t=e[r-1],o+=E[t>>2],o+=E[t<<4&63],o+="=="):2===a&&(t=(e[r-2]<<8)+e[r-1],o+=E[t>>10],o+=E[t>>4&63],o+=E[t<<2&63],o+="="),i.push(o),i.join("")}function B(e,t,r,a,o){var i,n,s=8*o-a-1,u=(1<<s)-1,l=u>>1,c=-7,h=r?o-1:0,d=r?-1:1,p=e[t+h];for(h+=d,i=p&(1<<-c)-1,p>>=-c,c+=s;c>0;i=256*i+e[t+h],h+=d,c-=8);for(n=i&(1<<-c)-1,i>>=-c,c+=a;c>0;n=256*n+e[t+h],h+=d,c-=8);if(0===i)i=1-l;else{if(i===u)return n?NaN:1/0*(p?-1:1);n+=Math.pow(2,a),i-=l}return(p?-1:1)*n*Math.pow(2,i-a)}function I(e,t,r,a,o,i){var n,s,u,l=8*i-o-1,c=(1<<l)-1,h=c>>1,d=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=a?0:i-1,f=a?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,n=c):(n=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-n))<1&&(n--,u*=2),(t+=n+h>=1?d/u:d*Math.pow(2,1-h))*u>=2&&(n++,u/=2),n+h>=c?(s=0,n=c):n+h>=1?(s=(t*u-1)*Math.pow(2,o),n+=h):(s=t*Math.pow(2,h-1)*Math.pow(2,o),n=0));o>=8;e[r+p]=255&s,p+=f,s/=256,o-=8);for(n=n<<o|s,l+=o;l>0;e[r+p]=255&n,p+=f,n/=256,l-=8);e[r+p-f]|=128*m}var R={}.toString,P=Array.isArray||function(e){return"[object Array]"==R.call(e)};D.TYPED_ARRAY_SUPPORT=void 0===S.TYPED_ARRAY_SUPPORT||S.TYPED_ARRAY_SUPPORT;var O=M();function M(){return D.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function L(e,t){if(M()<t)throw new RangeError("Invalid typed array length");return D.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=D.prototype:(null===e&&(e=new D(t)),e.length=t),e}function D(e,t,r){if(!(D.TYPED_ARRAY_SUPPORT||this instanceof D))return new D(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 q(this,e)}return N(this,e,t,r)}function N(e,t,r,a){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,a){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(a||0))throw new RangeError("'length' is out of bounds");t=void 0===r&&void 0===a?new Uint8Array(t):void 0===a?new Uint8Array(t,r):new Uint8Array(t,r,a);D.TYPED_ARRAY_SUPPORT?(e=t).__proto__=D.prototype:e=K(e,t);return e}(e,t,r,a):"string"==typeof t?function(e,t,r){"string"==typeof r&&""!==r||(r="utf8");if(!D.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var a=0|W(t,r);e=L(e,a);var o=e.write(t,r);o!==a&&(e=e.slice(0,o));return e}(e,t,r):function(e,t){if(H(t)){var r=0|F(t.length);return 0===(e=L(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||(a=t.length)!=a?L(e,0):K(e,t);if("Buffer"===t.type&&P(t.data))return K(e,t.data)}var a;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function U(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 q(e,t){if(U(t),e=L(e,t<0?0:0|F(t)),!D.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function K(e,t){var r=t.length<0?0:0|F(t.length);e=L(e,r);for(var a=0;a<r;a+=1)e[a]=255&t[a];return e}function F(e){if(e>=M())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+M().toString(16)+" bytes");return 0|e}function H(e){return!(null==e||!e._isBuffer)}function W(e,t){if(H(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 a=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return ve(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return ye(e).length;default:if(a)return ve(e).length;t=(""+t).toLowerCase(),a=!0}}function G(e,t,r){var a=!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 se(this,t,r);case"utf8":case"utf-8":return ae(this,t,r);case"ascii":return ie(this,t,r);case"latin1":case"binary":return ne(this,t,r);case"base64":return re(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(this,t,r);default:if(a)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),a=!0}}function $(e,t,r){var a=e[t];e[t]=e[r],e[r]=a}function Y(e,t,r,a,o){if(0===e.length)return-1;if("string"==typeof r?(a=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=D.from(t,a)),H(t))return 0===t.length?-1:V(e,t,r,a,o);if("number"==typeof t)return t&=255,D.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):V(e,[t],r,a,o);throw new TypeError("val must be string, number or Buffer")}function V(e,t,r,a,o){var i,n=1,s=e.length,u=t.length;if(void 0!==a&&("ucs2"===(a=String(a).toLowerCase())||"ucs-2"===a||"utf16le"===a||"utf-16le"===a)){if(e.length<2||t.length<2)return-1;n=2,s/=2,u/=2,r/=2}function l(e,t){return 1===n?e[t]:e.readUInt16BE(t*n)}if(o){var c=-1;for(i=r;i<s;i++)if(l(e,i)===l(t,-1===c?0:i-c)){if(-1===c&&(c=i),i-c+1===u)return c*n}else-1!==c&&(i-=i-c),c=-1}else for(r+u>s&&(r=s-u),i=r;i>=0;i--){for(var h=!0,d=0;d<u;d++)if(l(e,i+d)!==l(t,d)){h=!1;break}if(h)return i}return-1}function J(e,t,r,a){r=Number(r)||0;var o=e.length-r;a?(a=Number(a))>o&&(a=o):a=o;var i=t.length;if(i%2!=0)throw new TypeError("Invalid hex string");a>i/2&&(a=i/2);for(var n=0;n<a;++n){var s=parseInt(t.substr(2*n,2),16);if(isNaN(s))return n;e[r+n]=s}return n}function X(e,t,r,a){return ke(ve(t,e.length-r),e,r,a)}function Z(e,t,r,a){return ke(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,a)}function Q(e,t,r,a){return Z(e,t,r,a)}function ee(e,t,r,a){return ke(ye(t),e,r,a)}function te(e,t,r,a){return ke(function(e,t){for(var r,a,o,i=[],n=0;n<e.length&&!((t-=2)<0);++n)a=(r=e.charCodeAt(n))>>8,o=r%256,i.push(o),i.push(a);return i}(t,e.length-r),e,r,a)}function re(e,t,r){return 0===t&&r===e.length?j(e):j(e.slice(t,r))}function ae(e,t,r){r=Math.min(e.length,r);for(var a=[],o=t;o<r;){var i,n,s,u,l=e[o],c=null,h=l>239?4:l>223?3:l>191?2:1;if(o+h<=r)switch(h){case 1:l<128&&(c=l);break;case 2:128==(192&(i=e[o+1]))&&(u=(31&l)<<6|63&i)>127&&(c=u);break;case 3:i=e[o+1],n=e[o+2],128==(192&i)&&128==(192&n)&&(u=(15&l)<<12|(63&i)<<6|63&n)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:i=e[o+1],n=e[o+2],s=e[o+3],128==(192&i)&&128==(192&n)&&128==(192&s)&&(u=(15&l)<<18|(63&i)<<12|(63&n)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,h=1):c>65535&&(c-=65536,a.push(c>>>10&1023|55296),c=56320|1023&c),a.push(c),o+=h}return function(e){var t=e.length;if(t<=oe)return String.fromCharCode.apply(String,e);var r="",a=0;for(;a<t;)r+=String.fromCharCode.apply(String,e.slice(a,a+=oe));return r}(a)}D.poolSize=8192,D._augment=function(e){return e.__proto__=D.prototype,e},D.from=function(e,t,r){return N(null,e,t,r)},D.TYPED_ARRAY_SUPPORT&&(D.prototype.__proto__=Uint8Array.prototype,D.__proto__=Uint8Array),D.alloc=function(e,t,r){return function(e,t,r,a){return U(t),t<=0?L(e,t):void 0!==r?"string"==typeof a?L(e,t).fill(r,a):L(e,t).fill(r):L(e,t)}(null,e,t,r)},D.allocUnsafe=function(e){return q(null,e)},D.allocUnsafeSlow=function(e){return q(null,e)},D.isBuffer=we,D.compare=function(e,t){if(!H(e)||!H(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,a=t.length,o=0,i=Math.min(r,a);o<i;++o)if(e[o]!==t[o]){r=e[o],a=t[o];break}return r<a?-1:a<r?1:0},D.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}},D.concat=function(e,t){if(!P(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return D.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var a=D.allocUnsafe(t),o=0;for(r=0;r<e.length;++r){var i=e[r];if(!H(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(a,o),o+=i.length}return a},D.byteLength=W,D.prototype._isBuffer=!0,D.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)$(this,t,t+1);return this},D.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)$(this,t,t+3),$(this,t+1,t+2);return this},D.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)$(this,t,t+7),$(this,t+1,t+6),$(this,t+2,t+5),$(this,t+3,t+4);return this},D.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?ae(this,0,e):G.apply(this,arguments)},D.prototype.equals=function(e){if(!H(e))throw new TypeError("Argument must be a Buffer");return this===e||0===D.compare(this,e)},D.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},D.prototype.compare=function(e,t,r,a,o){if(!H(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===a&&(a=0),void 0===o&&(o=this.length),t<0||r>e.length||a<0||o>this.length)throw new RangeError("out of range index");if(a>=o&&t>=r)return 0;if(a>=o)return-1;if(t>=r)return 1;if(this===e)return 0;for(var i=(o>>>=0)-(a>>>=0),n=(r>>>=0)-(t>>>=0),s=Math.min(i,n),u=this.slice(a,o),l=e.slice(t,r),c=0;c<s;++c)if(u[c]!==l[c]){i=u[c],n=l[c];break}return i<n?-1:n<i?1:0},D.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},D.prototype.indexOf=function(e,t,r){return Y(this,e,t,r,!0)},D.prototype.lastIndexOf=function(e,t,r){return Y(this,e,t,r,!1)},D.prototype.write=function(e,t,r,a){if(void 0===t)a="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)a=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===a&&(a="utf8")):(a=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");a||(a="utf8");for(var i=!1;;)switch(a){case"hex":return J(this,e,t,r);case"utf8":case"utf-8":return X(this,e,t,r);case"ascii":return Z(this,e,t,r);case"latin1":case"binary":return Q(this,e,t,r);case"base64":return ee(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return te(this,e,t,r);default:if(i)throw new TypeError("Unknown encoding: "+a);a=(""+a).toLowerCase(),i=!0}},D.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var oe=4096;function ie(e,t,r){var a="";r=Math.min(e.length,r);for(var o=t;o<r;++o)a+=String.fromCharCode(127&e[o]);return a}function ne(e,t,r){var a="";r=Math.min(e.length,r);for(var o=t;o<r;++o)a+=String.fromCharCode(e[o]);return a}function se(e,t,r){var a=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>a)&&(r=a);for(var o="",i=t;i<r;++i)o+=be(e[i]);return o}function ue(e,t,r){for(var a=e.slice(t,r),o="",i=0;i<a.length;i+=2)o+=String.fromCharCode(a[i]+256*a[i+1]);return o}function le(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 ce(e,t,r,a,o,i){if(!H(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+a>e.length)throw new RangeError("Index out of range")}function he(e,t,r,a){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*(a?o:1-o))>>>8*(a?o:1-o)}function de(e,t,r,a){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*(a?o:3-o)&255}function pe(e,t,r,a,o,i){if(r+a>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function fe(e,t,r,a,o){return o||pe(e,0,r,4),I(e,t,r,a,23,4),r+4}function me(e,t,r,a,o){return o||pe(e,0,r,8),I(e,t,r,a,52,8),r+8}D.prototype.slice=function(e,t){var r,a=this.length;if((e=~~e)<0?(e+=a)<0&&(e=0):e>a&&(e=a),(t=void 0===t?a:~~t)<0?(t+=a)<0&&(t=0):t>a&&(t=a),t<e&&(t=e),D.TYPED_ARRAY_SUPPORT)(r=this.subarray(e,t)).__proto__=D.prototype;else{var o=t-e;r=new D(o,void 0);for(var i=0;i<o;++i)r[i]=this[i+e]}return r},D.prototype.readUIntLE=function(e,t,r){e|=0,t|=0,r||le(e,t,this.length);for(var a=this[e],o=1,i=0;++i<t&&(o*=256);)a+=this[e+i]*o;return a},D.prototype.readUIntBE=function(e,t,r){e|=0,t|=0,r||le(e,t,this.length);for(var a=this[e+--t],o=1;t>0&&(o*=256);)a+=this[e+--t]*o;return a},D.prototype.readUInt8=function(e,t){return t||le(e,1,this.length),this[e]},D.prototype.readUInt16LE=function(e,t){return t||le(e,2,this.length),this[e]|this[e+1]<<8},D.prototype.readUInt16BE=function(e,t){return t||le(e,2,this.length),this[e]<<8|this[e+1]},D.prototype.readUInt32LE=function(e,t){return t||le(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},D.prototype.readUInt32BE=function(e,t){return t||le(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},D.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||le(e,t,this.length);for(var a=this[e],o=1,i=0;++i<t&&(o*=256);)a+=this[e+i]*o;return a>=(o*=128)&&(a-=Math.pow(2,8*t)),a},D.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||le(e,t,this.length);for(var a=t,o=1,i=this[e+--a];a>0&&(o*=256);)i+=this[e+--a]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*t)),i},D.prototype.readInt8=function(e,t){return t||le(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},D.prototype.readInt16LE=function(e,t){t||le(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},D.prototype.readInt16BE=function(e,t){t||le(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},D.prototype.readInt32LE=function(e,t){return t||le(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},D.prototype.readInt32BE=function(e,t){return t||le(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},D.prototype.readFloatLE=function(e,t){return t||le(e,4,this.length),B(this,e,!0,23,4)},D.prototype.readFloatBE=function(e,t){return t||le(e,4,this.length),B(this,e,!1,23,4)},D.prototype.readDoubleLE=function(e,t){return t||le(e,8,this.length),B(this,e,!0,52,8)},D.prototype.readDoubleBE=function(e,t){return t||le(e,8,this.length),B(this,e,!1,52,8)},D.prototype.writeUIntLE=function(e,t,r,a){(e=+e,t|=0,r|=0,a)||ce(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},D.prototype.writeUIntBE=function(e,t,r,a){(e=+e,t|=0,r|=0,a)||ce(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},D.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,255,0),D.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},D.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),D.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):he(this,e,t,!0),t+2},D.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),D.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):he(this,e,t,!1),t+2},D.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),D.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):de(this,e,t,!0),t+4},D.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),D.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):de(this,e,t,!1),t+4},D.prototype.writeIntLE=function(e,t,r,a){if(e=+e,t|=0,!a){var o=Math.pow(2,8*r-1);ce(this,e,t,r,o-1,-o)}var i=0,n=1,s=0;for(this[t]=255&e;++i<r&&(n*=256);)e<0&&0===s&&0!==this[t+i-1]&&(s=1),this[t+i]=(e/n>>0)-s&255;return t+r},D.prototype.writeIntBE=function(e,t,r,a){if(e=+e,t|=0,!a){var o=Math.pow(2,8*r-1);ce(this,e,t,r,o-1,-o)}var i=r-1,n=1,s=0;for(this[t+i]=255&e;--i>=0&&(n*=256);)e<0&&0===s&&0!==this[t+i+1]&&(s=1),this[t+i]=(e/n>>0)-s&255;return t+r},D.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,127,-128),D.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},D.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),D.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):he(this,e,t,!0),t+2},D.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),D.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):he(this,e,t,!1),t+2},D.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),D.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):de(this,e,t,!0),t+4},D.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),D.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):de(this,e,t,!1),t+4},D.prototype.writeFloatLE=function(e,t,r){return fe(this,e,t,!0,r)},D.prototype.writeFloatBE=function(e,t,r){return fe(this,e,t,!1,r)},D.prototype.writeDoubleLE=function(e,t,r){return me(this,e,t,!0,r)},D.prototype.writeDoubleBE=function(e,t,r){return me(this,e,t,!1,r)},D.prototype.copy=function(e,t,r,a){if(r||(r=0),a||0===a||(a=this.length),t>=e.length&&(t=e.length),t||(t=0),a>0&&a<r&&(a=r),a===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(a<0)throw new RangeError("sourceEnd out of bounds");a>this.length&&(a=this.length),e.length-t<a-r&&(a=e.length-t+r);var o,i=a-r;if(this===e&&r<t&&t<a)for(o=i-1;o>=0;--o)e[o+t]=this[o+r];else if(i<1e3||!D.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},D.prototype.fill=function(e,t,r,a){if("string"==typeof e){if("string"==typeof t?(a=t,t=0,r=this.length):"string"==typeof r&&(a=r,r=this.length),1===e.length){var o=e.charCodeAt(0);o<256&&(e=o)}if(void 0!==a&&"string"!=typeof a)throw new TypeError("encoding must be a string");if("string"==typeof a&&!D.isEncoding(a))throw new TypeError("Unknown encoding: "+a)}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 n=H(e)?e:ve(new D(e,a).toString()),s=n.length;for(i=0;i<r-t;++i)this[i+t]=n[i%s]}return this};var ge=/[^+\/0-9A-Za-z-_]/g;function be(e){return e<16?"0"+e.toString(16):e.toString(16)}function ve(e,t){var r;t=t||1/0;for(var a=e.length,o=null,i=[],n=0;n<a;++n){if((r=e.charCodeAt(n))>55295&&r<57344){if(!o){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(n+1===a){(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 ye(e){return function(e){var t,r,a,o,i,n;T||A();var s=e.length;if(s%4>0)throw new Error("Invalid string. Length must be a multiple of 4");i="="===e[s-2]?2:"="===e[s-1]?1:0,n=new z(3*s/4-i),a=i>0?s-4:s;var u=0;for(t=0,r=0;t<a;t+=4,r+=3)o=x[e.charCodeAt(t)]<<18|x[e.charCodeAt(t+1)]<<12|x[e.charCodeAt(t+2)]<<6|x[e.charCodeAt(t+3)],n[u++]=o>>16&255,n[u++]=o>>8&255,n[u++]=255&o;return 2===i?(o=x[e.charCodeAt(t)]<<2|x[e.charCodeAt(t+1)]>>4,n[u++]=255&o):1===i&&(o=x[e.charCodeAt(t)]<<10|x[e.charCodeAt(t+1)]<<4|x[e.charCodeAt(t+2)]>>2,n[u++]=o>>8&255,n[u++]=255&o),n}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(ge,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function ke(e,t,r,a){for(var o=0;o<a&&!(o+r>=t.length||o>=e.length);++o)t[o+r]=e[o];return o}function we(e){return null!=e&&(!!e._isBuffer||_e(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&_e(e.slice(0,0))}(e))}function _e(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}var Se=Object.freeze({__proto__:null,Buffer:D,INSPECT_MAX_BYTES:50,SlowBuffer:function(e){return+e!=e&&(e=0),D.alloc(+e)},isBuffer:we,kMaxLength:O}),Ee={};const xe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ze=/^[ \n\r\t]*[{\[]/;let Te=function(e){let t=new Uint8Array(e),r=t.length,a="";for(let e=0;e<r;e+=3)a+=xe[t[e]>>2],a+=xe[(3&t[e])<<4|t[e+1]>>4],a+=xe[(15&t[e+1])<<2|t[e+2]>>6],a+=xe[63&t[e+2]];return r%3==2?a=a.substring(0,a.length-1)+"=":r%3==1&&(a=a.substring(0,a.length-2)+"=="),a},Ae=function(e,t){if("undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer)return{base64:!0,data:Te(t)};if(void 0!==D){if(t instanceof D)return{base64:!0,data:t.toString("base64")};if(t&&"Buffer"===t.type&&Array.isArray(t.data)){let e;return e=D.from?D.from(t.data):new D(t.data),{base64:!0,data:e.toString("base64")}}}return t};Ee.decode=function(e){if(null==e)return null;if("#1"===e||"#2"===e)return e;let t=e.toString();if(!ze.test(t))return t;try{return JSON.parse(t)}catch(e){}return t},Ee.encode=function(e){return"#1"===e||"#2"===e?e:JSON.stringify(e,Ae)};var Ce={exports:{}};const je=function(e){var t=[],r=[];return function e(a,o){var i,n,s;if(!("object"!=typeof a||null===a||a instanceof Boolean||a instanceof Date||a instanceof Number||a instanceof RegExp||a instanceof String)){for(i=0;i<t.length;i+=1)if(t[i]===a)return{$ref:r[i]};if(t.push(a),r.push(o),"[object Array]"===Object.prototype.toString.apply(a))for(s=[],i=0;i<a.length;i+=1)s[i]=e(a[i],o+"["+i+"]");else for(n in s={},a)Object.prototype.hasOwnProperty.call(a,n)&&(s[n]=e(a[n],o+"["+JSON.stringify(n)+"]"));return s}return a}(e,"$")},Be=function(){return!this}();function Ie(e,t){this.name="AuthTokenExpiredError",this.message=e,this.expiry=t,Error.captureStackTrace&&!Be?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function Re(e){this.name="AuthTokenInvalidError",this.message=e,Error.captureStackTrace&&!Be?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function Pe(e,t){this.name="AuthTokenNotBeforeError",this.message=e,this.date=t,Error.captureStackTrace&&!Be?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function Oe(e){this.name="AuthTokenError",this.message=e,Error.captureStackTrace&&!Be?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function Me(e){this.name="AuthError",this.message=e,Error.captureStackTrace&&!Be?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function Le(e,t){this.name="SilentMiddlewareBlockedError",this.message=e,this.type=t,Error.captureStackTrace&&!Be?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function De(e){this.name="InvalidActionError",this.message=e,Error.captureStackTrace&&!Be?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function Ne(e){this.name="InvalidArgumentsError",this.message=e,Error.captureStackTrace&&!Be?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function Ue(e){this.name="InvalidOptionsError",this.message=e,Error.captureStackTrace&&!Be?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function qe(e){this.name="InvalidMessageError",this.message=e,Error.captureStackTrace&&!Be?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function Ke(e,t){this.name="SocketProtocolError",this.message=e,this.code=t,Error.captureStackTrace&&!Be?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function Fe(e){this.name="ServerProtocolError",this.message=e,Error.captureStackTrace&&!Be?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function He(e){this.name="HTTPServerError",this.message=e,Error.captureStackTrace&&!Be?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function We(e){this.name="ResourceLimitError",this.message=e,Error.captureStackTrace&&!Be?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function Ge(e){this.name="TimeoutError",this.message=e,Error.captureStackTrace&&!Be?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function $e(e,t,r,a){this.name="BadConnectionError",this.message=e,this.type=t,this.code=r||1001,this.reason=a||Ze[this.code]||"",Error.captureStackTrace&&!Be?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function Ye(e){this.name="BrokerError",this.message=e,Error.captureStackTrace&&!Be?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function Ve(e,t){this.name="ProcessExitError",this.message=e,this.code=t,Error.captureStackTrace&&!Be?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}function Je(e){this.name="UnknownError",this.message=e,Error.captureStackTrace&&!Be?Error.captureStackTrace(this,arguments.callee):this.stack=(new Error).stack}Ie.prototype=Object.create(Error.prototype),Re.prototype=Object.create(Error.prototype),Pe.prototype=Object.create(Error.prototype),Oe.prototype=Object.create(Error.prototype),Me.prototype=Object.create(Error.prototype),Le.prototype=Object.create(Error.prototype),De.prototype=Object.create(Error.prototype),Ne.prototype=Object.create(Error.prototype),Ue.prototype=Object.create(Error.prototype),qe.prototype=Object.create(Error.prototype),Ke.prototype=Object.create(Error.prototype),Fe.prototype=Object.create(Error.prototype),He.prototype=Object.create(Error.prototype),We.prototype=Object.create(Error.prototype),Ge.prototype=Object.create(Error.prototype),$e.prototype=Object.create(Error.prototype),Ye.prototype=Object.create(Error.prototype),Ve.prototype=Object.create(Error.prototype),Je.prototype=Object.create(Error.prototype),Ce.exports={AuthTokenExpiredError:Ie,AuthTokenInvalidError:Re,AuthTokenNotBeforeError:Pe,AuthTokenError:Oe,AuthError:Me,SilentMiddlewareBlockedError:Le,InvalidActionError:De,InvalidArgumentsError:Ne,InvalidOptionsError:Ue,InvalidMessageError:qe,SocketProtocolError:Ke,ServerProtocolError:Fe,HTTPServerError:He,ResourceLimitError:We,TimeoutError:Ge,BadConnectionError:$e,BrokerError:Ye,ProcessExitError:Ve,UnknownError:Je};const Xe={1001:"Socket was disconnected",1002:"A WebSocket protocol error was encountered",1003:"Server terminated socket because it received invalid data",1005:"Socket closed without status code",1006:"Socket hung up",1007:"Message format was incorrect",1008:"Encountered a policy violation",1009:"Message was too big to process",1010:"Client ended the connection because the server did not comply with extension requirements",1011:"Server encountered an unexpected fatal condition",4e3:"Server ping timed out",4001:"Client pong timed out",4002:"Server failed to sign auth token",4003:"Failed to complete handshake",4004:"Client failed to save auth token",4005:"Did not receive #handshake from client before timeout",4006:"Failed to bind socket to message broker",4007:"Client connection establishment timed out",4008:"Server rejected handshake from client",4009:"Server received a message before the client handshake"},Ze={1e3:"Socket closed normally",1001:Xe[1001]};Ce.exports.socketProtocolErrorStatuses=Xe,Ce.exports.socketProtocolIgnoreStatuses=Ze,Ce.exports.dehydrateError=function(e){let t;if(e&&"object"==typeof e){t={message:e.message};for(let r of Object.keys(e))t[r]=e[r]}else t="function"==typeof e?"[function "+("string"==typeof e.name?e.name:"anonymous")+"]":e;return je(t)},Ce.exports.hydrateError=function(e){let t=null;if(null!=e)if("object"==typeof e){t=new Error("string"==typeof e.message?e.message:"Invalid error message format"),"string"==typeof e.name&&(t.name=e.name);for(let r of Object.keys(e))void 0===t[r]&&(t[r]=e[r])}else t=e;return t},Ce.exports.decycle=je;var Qe=Ce.exports;const et=Qe,tt=et.InvalidActionError;var rt,at;const ot=function(e,t,r,a){this.socket=e,this.id=t,this.procedure=r,this.data=a,this.sent=!1,this._respond=(e,t)=>{if(this.sent)throw new tt(`Response to request ${this.id} has already been sent`);this.sent=!0,this.socket.sendObject(e,t)},this.end=(e,t)=>{let r={rid:this.id};void 0!==e&&(r.data=e),this._respond(r,t)},this.error=(e,t)=>{let r={rid:this.id,error:et.dehydrateError(e)};this._respond(r,t)}};let it;if("undefined"!=typeof WebSocket)it=function(e,t){return new WebSocket(e)};else{let e=function(){if(at)return rt;let e;at=1,e="undefined"!=typeof WorkerGlobalScope?self:"undefined"!=typeof window&&window||function(){return this}();const t=e.WebSocket||e.MozWebSocket;function r(e,r,a){let o;return o=r?new t(e,r):new t(e),o}return t&&(r.prototype=t.prototype),rt=t?r:null}();it=function(t,r){return new e(t,[],r)}}const nt=Qe,st=nt.TimeoutError,ut=nt.BadConnectionError;function lt(e,t,r,a,o){this.state=this.CLOSED,this.auth=e,this.codec=t,this.options=r,this.wsOptions=a,this.protocolVersion=r.protocolVersion,this.connectTimeout=r.connectTimeout,this.pingTimeout=r.pingTimeout,this.pingTimeoutDisabled=!!r.pingTimeoutDisabled,this.callIdGenerator=r.callIdGenerator,this.authTokenName=r.authTokenName,this.isBufferingBatch=!1,this._pingTimeoutTicker=null,this._callbackMap={},this._batchBuffer=[],this.lastPingTimestamp=Date.now(),o||(o={}),this._onOpenHandler=o.onOpen||function(){},this._onOpenAbortHandler=o.onOpenAbort||function(){},this._onCloseHandler=o.onClose||function(){},this._onEventHandler=o.onEvent||function(){},this._onErrorHandler=o.onError||function(){},this._onInboundInvokeHandler=o.onInboundInvoke||function(){},this._onInboundTransmitHandler=o.onInboundTransmit||function(){},this.state=this.CONNECTING;let i=this.uri(),n=it(i,a);n.binaryType=this.options.binaryType,this.socket=n,n.onopen=()=>{this._onOpen()},n.onclose=async e=>{let t;t=null==e.code?1005:e.code,this._destroy(t,e.reason)},n.onmessage=(e,t)=>{this._onMessage(e.data)},n.onerror=e=>{this.state===this.CONNECTING&&this._destroy(1006)},this._connectTimeoutRef=setTimeout((()=>{this._destroy(4007),this.socket.close(4007)}),this.connectTimeout),1===this.protocolVersion?this._handlePing=e=>"#1"===e&&(this._resetPingTimeout(),this.socket.readyState===this.socket.OPEN&&this.send("#2"),!0):this._handlePing=e=>""===e&&(this._resetPingTimeout(),this.socket.readyState===this.socket.OPEN&&this.send(""),!0)}lt.CONNECTING=lt.prototype.CONNECTING="connecting",lt.OPEN=lt.prototype.OPEN="open",lt.CLOSED=lt.prototype.CLOSED="closed",lt.computeURI=function(e){let t,r=e.query||{};t=null==e.protocolScheme?e.secure?"wss":"ws":e.protocolScheme,e.timestampRequests&&(r[e.timestampParam]=(new Date).getTime());let a,o,i=new URLSearchParams;for(let[e,t]of Object.entries(r))if(Array.isArray(t))for(let r of t)i.append(e,r);else i.set(e,t);if(r=i.toString(),r.length&&(r="?"+r),null==e.socketPath){if(e.host)a=e.host;else{let r="";e.port&&("wss"===t&&443!==e.port||"ws"===t&&80!==e.port)&&(r=":"+e.port),a=e.hostname+r}o=e.path}else a=e.socketPath,o=`:${e.path}`;return t+"://"+a+o+r},lt.prototype.uri=function(){return lt.computeURI(this.options)},lt.prototype._onOpen=async function(){let e;clearTimeout(this._connectTimeoutRef),this._resetPingTimeout();try{e=await this._handshake()}catch(e){return null==e.statusCode&&(e.statusCode=4003),this._onError(e),this._destroy(e.statusCode,e.toString()),void this.socket.close(e.statusCode)}this.state=this.OPEN,e&&(this.pingTimeout=e.pingTimeout),this._resetPingTimeout(),this._onOpenHandler(e)},lt.prototype._handshake=async function(){let e=await this.auth.loadToken(this.authTokenName),t=await this.invoke("#handshake",{authToken:e},{force:!0});return t&&(t.authToken=e,t.authError&&(t.authError=nt.hydrateError(t.authError))),t},lt.prototype._abortAllPendingEventsDueToBadConnection=function(e,t,r){Object.keys(this._callbackMap||{}).forEach((a=>{let o=this._callbackMap[a];delete this._callbackMap[a],clearTimeout(o.timeout),delete o.timeout;let i=`Event ${o.event} was aborted due to a bad connection`,n=new ut(i,e,t,r),s=o.callback;s&&(delete o.callback,s.call(o,n,o))}))},lt.prototype._destroy=function(e,t){!t&&nt.socketProtocolErrorStatuses[e]&&(t=nt.socketProtocolErrorStatuses[e]),delete this.socket.onopen,delete this.socket.onclose,delete this.socket.onmessage,delete this.socket.onerror,clearTimeout(this._connectTimeoutRef),clearTimeout(this._pingTimeoutTicker),this.state===this.OPEN?(this.state=this.CLOSED,this._abortAllPendingEventsDueToBadConnection("disconnect",e,t),this._onCloseHandler({code:e,reason:t})):this.state===this.CONNECTING?(this.state=this.CLOSED,this._abortAllPendingEventsDueToBadConnection("connectAbort",e,t),this._onOpenAbortHandler({code:e,reason:t})):this.state===this.CLOSED&&this._abortAllPendingEventsDueToBadConnection("connectAbort",e,t)},lt.prototype._processInboundPacket=function(e,t){if(e&&"string"==typeof e.event)if("number"==typeof e.cid){let t=new ot(this,e.cid,e.event,e.data);this._onInboundInvokeHandler(t)}else this._onInboundTransmitHandler({...e});else if(e&&"number"==typeof e.rid){let t=this._callbackMap[e.rid];if(t&&(clearTimeout(t.timeout),delete t.timeout,delete this._callbackMap[e.rid],t.callback)){let r=nt.hydrateError(e.error);t.callback(r,e.data)}}else this._onEventHandler({event:"raw",data:{message:t}})},lt.prototype._onMessage=function(e){if(this._onEventHandler({event:"message",data:{message:e}}),this._handlePing(e))return;let t=this.decode(e);if(Array.isArray(t)){let r=t.length;for(let a=0;a<r;a++)this._processInboundPacket(t[a],e)}else this._processInboundPacket(t,e)},lt.prototype._onError=function(e){this._onErrorHandler({error:e})},lt.prototype.isStale=function(){return Date.now()-this.lastPingTimestamp>=this.pingTimeout},lt.prototype._resetPingTimeout=function(){this.pingTimeoutDisabled||(this.lastPingTimestamp=Date.now(),clearTimeout(this._pingTimeoutTicker),this._pingTimeoutTicker=setTimeout((()=>{this._destroy(4e3),this.socket.close(4e3)}),this.pingTimeout))},lt.prototype.clearAllListeners=function(){this._onOpenHandler=function(){},this._onOpenAbortHandler=function(){},this._onCloseHandler=function(){},this._onEventHandler=function(){},this._onErrorHandler=function(){},this._onInboundInvokeHandler=function(){},this._onInboundTransmitHandler=function(){}},lt.prototype.startBatch=function(){this.isBufferingBatch=!0,this._batchBuffer=[]},lt.prototype.flushBatch=function(){if(this.isBufferingBatch=!1,!this._batchBuffer.length)return;let e=this.serializeObject(this._batchBuffer);this._batchBuffer=[],this.send(e)},lt.prototype.cancelBatch=function(){this.isBufferingBatch=!1,this._batchBuffer=[]},lt.prototype.getBytesReceived=function(){return this.socket.bytesReceived},lt.prototype.close=function(e,t){this.state!==this.OPEN&&this.state!==this.CONNECTING||(e=e||1e3,this._destroy(e,t),this.socket.close(e,t))},lt.prototype.transmitObject=function(e){let t={event:e.event,data:e.data};return e.callback&&(t.cid=e.cid=this.callIdGenerator(),this._callbackMap[e.cid]=e),this.sendObject(t),e.cid||null},lt.prototype._handleEventAckTimeout=function(e){e.cid&&delete this._callbackMap[e.cid],delete e.timeout;let t=e.callback;if(t){delete e.callback;let r=new st(`Event response for ${e.event} event timed out`);t.call(e,r,e)}},lt.prototype.transmit=function(e,t,r){let