UNPKG

40.9 kBJavaScriptView Raw
1function e(e,t,n,i){Object.defineProperty(e,t,{get:n,set:i,enumerable:!0,configurable:!0})}var t,n,i,r,o=globalThis,s={},a={},c=o.parcelRequire83ac;null==c&&((c=function(e){if(e in s)return s[e].exports;if(e in a){var t=a[e];delete a[e];var n={id:e,exports:{}};return s[e]=n,t.call(n.exports,n,n.exports),n.exports}var i=Error("Cannot find module '"+e+"'");throw i.code="MODULE_NOT_FOUND",i}).register=function(e,t){a[e]=t},o.parcelRequire83ac=c);var h=c.register;function l(e){return"".concat(e<0?"-":"","0x").concat(Math.abs(e).toString(16).padStart(2,"0"))}h("5L6jO",function(e,t){}),h("hBa25",function(t,n){e(t.exports,"StreamConnection",()=>o);var i=c("aGTqB"),r=c("brJ7I");class o extends r.DataConnection{constructor(e,t,n){super(e,t,{...n,reliable:!0}),this._CHUNK_SIZE=32768,this._splitStream=new TransformStream({transform:(e,t)=>{for(let n=0;n<e.length;n+=this._CHUNK_SIZE)t.enqueue(e.subarray(n,n+this._CHUNK_SIZE))}}),this._rawSendStream=new WritableStream({write:async(e,t)=>{let n=new Promise(e=>this.dataChannel.addEventListener("bufferedamountlow",e,{once:!0}));await (this.dataChannel.bufferedAmount<=r.DataConnection.MAX_BUFFERED_AMOUNT-e.byteLength||n);try{this.dataChannel.send(e)}catch(e){(0,i.default).error(`DC#:${this.connectionId} Error when sending:`,e),t.error(e),this.close()}}}),this.writer=this._splitStream.writable.getWriter(),this._rawReadStream=new ReadableStream({start:e=>{this.once("open",()=>{this.dataChannel.addEventListener("message",t=>{e.enqueue(t.data)})})}}),this._splitStream.readable.pipeTo(this._rawSendStream)}_initializeDataChannel(e){super._initializeDataChannel(e),this.dataChannel.binaryType="arraybuffer",this.dataChannel.bufferedAmountLowThreshold=r.DataConnection.MAX_BUFFERED_AMOUNT/2}}}),h("aGTqB",function(t,n){e(t.exports,"default",()=>o),(i=r||(r={}))[i.Disabled=0]="Disabled",i[i.Errors=1]="Errors",i[i.Warnings=2]="Warnings",i[i.All=3]="All";var i,r,o=new class{get logLevel(){return this._logLevel}set logLevel(e){this._logLevel=e}log(...e){this._logLevel>=3&&this._print(3,...e)}warn(...e){this._logLevel>=2&&this._print(2,...e)}error(...e){this._logLevel>=1&&this._print(1,...e)}setLogFunction(e){this._print=e}_print(e,...t){let n=["PeerJS: ",...t];for(let e in n)n[e]instanceof Error&&(n[e]="("+n[e].name+") "+n[e].message);e>=3?console.log(...n):e>=2?console.warn("WARNING",...n):e>=1&&console.error("ERROR",...n)}constructor(){this._logLevel=0}}}),h("brJ7I",function(t,n){e(t.exports,"DataConnection",()=>h);var i=c("aGTqB"),r=c("eEr5Q"),o=c("3pPW3"),s=c("kRc3N"),a=c("9Ek5E");class h extends s.BaseConnection{static #e=this.ID_PREFIX="dc_";static #t=this.MAX_BUFFERED_AMOUNT=8388608;get type(){return o.ConnectionType.Data}constructor(e,t,n){super(e,t,n),this.connectionId=this.options.connectionId||h.ID_PREFIX+(0,a.randomToken)(),this.label=this.options.label||this.connectionId,this.reliable=!!this.options.reliable,this._negotiator=new r.Negotiator(this),this._negotiator.startConnection(this.options._payload||{originator:!0,reliable:this.reliable})}_initializeDataChannel(e){this.dataChannel=e,this.dataChannel.onopen=()=>{(0,i.default).log(`DC#${this.connectionId} dc connection success`),this._open=!0,this.emit("open")},this.dataChannel.onmessage=e=>{(0,i.default).log(`DC#${this.connectionId} dc onmessage:`,e.data)},this.dataChannel.onclose=()=>{(0,i.default).log(`DC#${this.connectionId} dc closed for:`,this.peer),this.close()}}close(e){if(e?.flush){this.send({__peerData:{type:"close"}});return}this._negotiator&&(this._negotiator.cleanup(),this._negotiator=null),this.provider&&(this.provider._removeConnection(this),this.provider=null),this.dataChannel&&(this.dataChannel.onopen=null,this.dataChannel.onmessage=null,this.dataChannel.onclose=null,this.dataChannel=null),this.open&&(this._open=!1,super.emit("close"))}send(e,t=!1){if(!this.open){this.emitError(o.DataConnectionErrorType.NotOpenYet,"Connection is not open. You should listen for the `open` event before sending messages.");return}return this._send(e,t)}async handleMessage(e){let t=e.payload;switch(e.type){case o.ServerMessageType.Answer:await this._negotiator.handleSDP(e.type,t.sdp);break;case o.ServerMessageType.Candidate:await this._negotiator.handleCandidate(t.candidate);break;default:(0,i.default).warn("Unrecognized message type:",e.type,"from peer:",this.peer)}}}}),h("eEr5Q",function(t,n){e(t.exports,"Negotiator",()=>o);var i=c("aGTqB"),r=c("3pPW3");class o{constructor(e){this.connection=e}startConnection(e){let t=this._startPeerConnection();if(this.connection.peerConnection=t,this.connection.type===r.ConnectionType.Media&&e._stream&&this._addTracksToConnection(e._stream,t),e.originator){let n=this.connection,i={ordered:!!e.reliable},r=t.createDataChannel(n.label,i);n._initializeDataChannel(r),this._makeOffer()}else this.handleSDP("OFFER",e.sdp)}_startPeerConnection(){(0,i.default).log("Creating RTCPeerConnection.");let e=new RTCPeerConnection(this.connection.provider.options.config);return this._setupListeners(e),e}_setupListeners(e){let t=this.connection.peer,n=this.connection.connectionId,o=this.connection.type,s=this.connection.provider;(0,i.default).log("Listening for ICE candidates."),e.onicecandidate=e=>{e.candidate&&e.candidate.candidate&&((0,i.default).log(`Received ICE candidates for ${t}:`,e.candidate),s.socket.send({type:r.ServerMessageType.Candidate,payload:{candidate:e.candidate,type:o,connectionId:n},dst:t}))},e.oniceconnectionstatechange=()=>{switch(e.iceConnectionState){case"failed":(0,i.default).log("iceConnectionState is failed, closing connections to "+t),this.connection.emitError(r.BaseConnectionErrorType.NegotiationFailed,"Negotiation of connection to "+t+" failed."),this.connection.close();break;case"closed":(0,i.default).log("iceConnectionState is closed, closing connections to "+t),this.connection.emitError(r.BaseConnectionErrorType.ConnectionClosed,"Connection to "+t+" closed."),this.connection.close();break;case"disconnected":(0,i.default).log("iceConnectionState changed to disconnected on the connection with "+t);break;case"completed":e.onicecandidate=()=>{}}this.connection.emit("iceStateChanged",e.iceConnectionState)},(0,i.default).log("Listening for data channel"),e.ondatachannel=e=>{(0,i.default).log("Received data channel");let r=e.channel;s.getConnection(t,n)._initializeDataChannel(r)},(0,i.default).log("Listening for remote stream"),e.ontrack=e=>{(0,i.default).log("Received remote stream");let o=e.streams[0],a=s.getConnection(t,n);a.type===r.ConnectionType.Media&&this._addStreamToMediaConnection(o,a)}}cleanup(){(0,i.default).log("Cleaning up PeerConnection to "+this.connection.peer);let e=this.connection.peerConnection;if(!e)return;this.connection.peerConnection=null,e.onicecandidate=e.oniceconnectionstatechange=e.ondatachannel=e.ontrack=()=>{};let t="closed"!==e.signalingState,n=!1,r=this.connection.dataChannel;r&&(n=!!r.readyState&&"closed"!==r.readyState),(t||n)&&e.close()}async _makeOffer(){let e=this.connection.peerConnection,t=this.connection.provider;try{let n=await e.createOffer(this.connection.options.constraints);(0,i.default).log("Created offer."),this.connection.options.sdpTransform&&"function"==typeof this.connection.options.sdpTransform&&(n.sdp=this.connection.options.sdpTransform(n.sdp)||n.sdp);try{await e.setLocalDescription(n),(0,i.default).log("Set localDescription:",n,`for:${this.connection.peer}`);let o={sdp:n,type:this.connection.type,connectionId:this.connection.connectionId,metadata:this.connection.metadata};if(this.connection.type===r.ConnectionType.Data){let e=this.connection;o={...o,label:e.label,reliable:e.reliable,serialization:e.serialization}}t.socket.send({type:r.ServerMessageType.Offer,payload:o,dst:this.connection.peer})}catch(e){"OperationError: Failed to set local offer sdp: Called in wrong state: kHaveRemoteOffer"!=e&&(t.emitError(r.PeerErrorType.WebRTC,e),(0,i.default).log("Failed to setLocalDescription, ",e))}}catch(e){t.emitError(r.PeerErrorType.WebRTC,e),(0,i.default).log("Failed to createOffer, ",e)}}async _makeAnswer(){let e=this.connection.peerConnection,t=this.connection.provider;try{let n=await e.createAnswer();(0,i.default).log("Created answer."),this.connection.options.sdpTransform&&"function"==typeof this.connection.options.sdpTransform&&(n.sdp=this.connection.options.sdpTransform(n.sdp)||n.sdp);try{await e.setLocalDescription(n),(0,i.default).log("Set localDescription:",n,`for:${this.connection.peer}`),t.socket.send({type:r.ServerMessageType.Answer,payload:{sdp:n,type:this.connection.type,connectionId:this.connection.connectionId},dst:this.connection.peer})}catch(e){t.emitError(r.PeerErrorType.WebRTC,e),(0,i.default).log("Failed to setLocalDescription, ",e)}}catch(e){t.emitError(r.PeerErrorType.WebRTC,e),(0,i.default).log("Failed to create answer, ",e)}}async handleSDP(e,t){t=new RTCSessionDescription(t);let n=this.connection.peerConnection,o=this.connection.provider;(0,i.default).log("Setting remote description",t);try{await n.setRemoteDescription(t),(0,i.default).log(`Set remoteDescription:${e} for:${this.connection.peer}`),"OFFER"===e&&await this._makeAnswer()}catch(e){o.emitError(r.PeerErrorType.WebRTC,e),(0,i.default).log("Failed to setRemoteDescription, ",e)}}async handleCandidate(e){(0,i.default).log("handleCandidate:",e);try{await this.connection.peerConnection.addIceCandidate(e),(0,i.default).log(`Added ICE candidate for:${this.connection.peer}`)}catch(e){this.connection.provider.emitError(r.PeerErrorType.WebRTC,e),(0,i.default).log("Failed to handleCandidate, ",e)}}_addTracksToConnection(e,t){if((0,i.default).log(`add tracks from stream ${e.id} to peer connection`),!t.addTrack)return(0,i.default).error("Your browser does't support RTCPeerConnection#addTrack. Ignored.");e.getTracks().forEach(n=>{t.addTrack(n,e)})}_addStreamToMediaConnection(e,t){(0,i.default).log(`add stream ${e.id} to media connection ${t.connectionId}`),t.addStream(e)}}}),h("3pPW3",function(t,n){var i,r,o,s,a,c,h,l,u,f,d,p,y,v;e(t.exports,"ConnectionType",()=>i),e(t.exports,"PeerErrorType",()=>r),e(t.exports,"BaseConnectionErrorType",()=>o),e(t.exports,"DataConnectionErrorType",()=>s),e(t.exports,"ServerMessageType",()=>h),(l=i||(i={})).Data="data",l.Media="media",(u=r||(r={})).BrowserIncompatible="browser-incompatible",u.Disconnected="disconnected",u.InvalidID="invalid-id",u.InvalidKey="invalid-key",u.Network="network",u.PeerUnavailable="peer-unavailable",u.SslUnavailable="ssl-unavailable",u.ServerError="server-error",u.SocketError="socket-error",u.SocketClosed="socket-closed",u.UnavailableID="unavailable-id",u.WebRTC="webrtc",(f=o||(o={})).NegotiationFailed="negotiation-failed",f.ConnectionClosed="connection-closed",(d=s||(s={})).NotOpenYet="not-open-yet",d.MessageToBig="message-too-big",(p=a||(a={})).Binary="binary",p.BinaryUTF8="binary-utf8",p.JSON="json",p.None="raw",(y=c||(c={})).Message="message",y.Disconnected="disconnected",y.Error="error",y.Close="close",(v=h||(h={})).Heartbeat="HEARTBEAT",v.Candidate="CANDIDATE",v.Offer="OFFER",v.Answer="ANSWER",v.Open="OPEN",v.Error="ERROR",v.IdTaken="ID-TAKEN",v.InvalidKey="INVALID-KEY",v.Leave="LEAVE",v.Expire="EXPIRE"}),h("kRc3N",function(t,n){e(t.exports,"BaseConnection",()=>r);var i=c("8edWV");class r extends i.EventEmitterWithError{get open(){return this._open}constructor(e,t,n){super(),this.peer=e,this.provider=t,this.options=n,this._open=!1,this.metadata=n.metadata}}}),h("8edWV",function(t,n){e(t.exports,"EventEmitterWithError",()=>o);var i=c("2b5HH"),r=c("aGTqB");class o extends i.EventEmitter{emitError(e,t){(0,r.default).error("Error:",t),this.emit("error",new s(`${e}`,t))}}class s extends Error{constructor(e,t){"string"==typeof t?super(t):(super(),Object.assign(this,t)),this.type=e}}}),h("2b5HH",function(e,t){var n=Object.prototype.hasOwnProperty,i="~";function r(){}function o(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function s(e,t,n,r,s){if("function"!=typeof n)throw TypeError("The listener must be a function");var a=new o(n,r||e,s),c=i?i+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],a]:e._events[c].push(a):(e._events[c]=a,e._eventsCount++),e}function a(e,t){0==--e._eventsCount?e._events=new r:delete e._events[t]}function c(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(i=!1)),c.prototype.eventNames=function(){var e,t,r=[];if(0===this._eventsCount)return r;for(t in e=this._events)n.call(e,t)&&r.push(i?t.slice(1):t);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(e)):r},c.prototype.listeners=function(e){var t=i?i+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var r=0,o=n.length,s=Array(o);r<o;r++)s[r]=n[r].fn;return s},c.prototype.listenerCount=function(e){var t=i?i+e:e,n=this._events[t];return n?n.fn?1:n.length:0},c.prototype.emit=function(e,t,n,r,o,s){var a=i?i+e:e;if(!this._events[a])return!1;var c,h,l=this._events[a],u=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),u){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,n),!0;case 4:return l.fn.call(l.context,t,n,r),!0;case 5:return l.fn.call(l.context,t,n,r,o),!0;case 6:return l.fn.call(l.context,t,n,r,o,s),!0}for(h=1,c=Array(u-1);h<u;h++)c[h-1]=arguments[h];l.fn.apply(l.context,c)}else{var f,d=l.length;for(h=0;h<d;h++)switch(l[h].once&&this.removeListener(e,l[h].fn,void 0,!0),u){case 1:l[h].fn.call(l[h].context);break;case 2:l[h].fn.call(l[h].context,t);break;case 3:l[h].fn.call(l[h].context,t,n);break;case 4:l[h].fn.call(l[h].context,t,n,r);break;default:if(!c)for(f=1,c=Array(u-1);f<u;f++)c[f-1]=arguments[f];l[h].fn.apply(l[h].context,c)}}return!0},c.prototype.on=function(e,t,n){return s(this,e,t,n,!1)},c.prototype.once=function(e,t,n){return s(this,e,t,n,!0)},c.prototype.removeListener=function(e,t,n,r){var o=i?i+e:e;if(!this._events[o])return this;if(!t)return a(this,o),this;var s=this._events[o];if(s.fn)s.fn!==t||r&&!s.once||n&&s.context!==n||a(this,o);else{for(var c=0,h=[],l=s.length;c<l;c++)(s[c].fn!==t||r&&!s[c].once||n&&s[c].context!==n)&&h.push(s[c]);h.length?this._events[o]=1===h.length?h[0]:h:a(this,o)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=i?i+e:e,this._events[t]&&a(this,t)):(this._events=new r,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=i,c.EventEmitter=c,e.exports=c}),h("9Ek5E",function(t,n){e(t.exports,"randomToken",()=>i);let i=()=>Math.random().toString(36).slice(2)});var u=function(e,t){this.type=e,this.data=t},f=(t=function(e,n){return(t=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,n)},function(e,n){if("function"!=typeof n&&null!==n)throw TypeError("Class extends value "+String(n)+" is not a constructor or null");function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}),d=function(e){function t(n){var i=e.call(this,n)||this;return Object.setPrototypeOf(i,Object.create(t.prototype)),Object.defineProperty(i,"name",{configurable:!0,enumerable:!1,value:t.name}),i}return f(t,e),t}(Error);function p(e,t,n){e.setUint32(t,Math.floor(n/4294967296)),e.setUint32(t+4,n)}function y(e,t){return 4294967296*e.getInt32(t)+e.getUint32(t+4)}var v={type:-1,encode:function(e){var t,n,i,r;return e instanceof Date?function(e){var t=e.sec,n=e.nsec;if(t>=0&&n>=0&&t<=17179869183){if(0===n&&t<=4294967295){var i=new Uint8Array(4),r=new DataView(i.buffer);return r.setUint32(0,t),i}var o=t/4294967296,i=new Uint8Array(8),r=new DataView(i.buffer);return r.setUint32(0,n<<2|3&o),r.setUint32(4,4294967295&t),i}var i=new Uint8Array(12),r=new DataView(i.buffer);return r.setUint32(0,n),p(r,4,t),i}((n=Math.floor((t=e.getTime())/1e3),r=Math.floor((i=(t-1e3*n)*1e6)/1e9),{sec:n+r,nsec:i-1e9*r})):null},decode:function(e){var t=function(e){var t=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(e.byteLength){case 4:var n=t.getUint32(0),i=0;return{sec:n,nsec:0};case 8:var r=t.getUint32(0),n=(3&r)*4294967296+t.getUint32(4),i=r>>>2;return{sec:n,nsec:i};case 12:var n=y(t,4),i=t.getUint32(0);return{sec:n,nsec:i};default:throw new d("Unrecognized data size for timestamp (expected 4, 8, or 12): ".concat(e.length))}}(e);return new Date(1e3*t.sec+t.nsec/1e6)}},w=function(){function e(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(v)}return e.prototype.register=function(e){var t=e.type,n=e.encode,i=e.decode;if(t>=0)this.encoders[t]=n,this.decoders[t]=i;else{var r=1+t;this.builtInEncoders[r]=n,this.builtInDecoders[r]=i}},e.prototype.tryToEncode=function(e,t){for(var n=0;n<this.builtInEncoders.length;n++){var i=this.builtInEncoders[n];if(null!=i){var r=i(e,t);if(null!=r){var o=-1-n;return new u(o,r)}}}for(var n=0;n<this.encoders.length;n++){var i=this.encoders[n];if(null!=i){var r=i(e,t);if(null!=r){var o=n;return new u(o,r)}}}return e instanceof u?e:null},e.prototype.decode=function(e,t,n){var i=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return i?i(e,t,n):new u(t,e)},e.defaultCodec=new e,e}(),g=c("5L6jO"),b=(void 0===g||(null===(n=null==g?void 0:g.env)||void 0===n?void 0:n.TEXT_ENCODING)!=="never")&&"undefined"!=typeof TextEncoder&&"undefined"!=typeof TextDecoder;function m(e){for(var t=e.length,n=0,i=0;i<t;){var r=e.charCodeAt(i++);if((4294967168&r)==0){n++;continue}if((4294965248&r)==0)n+=2;else{if(r>=55296&&r<=56319&&i<t){var o=e.charCodeAt(i);(64512&o)==56320&&(++i,r=((1023&r)<<10)+(1023&o)+65536)}(4294901760&r)==0?n+=3:n+=4}}return n}var U=b?new TextEncoder:void 0,E=b?void 0!==g&&(null===(i=null==g?void 0:g.env)||void 0===i?void 0:i.TEXT_ENCODING)!=="force"?200:0:4294967295,C=(null==U?void 0:U.encodeInto)?function(e,t,n){U.encodeInto(e,t.subarray(n))}:function(e,t,n){t.set(U.encode(e),n)};function x(e,t,n){for(var i=t,r=i+n,o=[],s="";i<r;){var a=e[i++];if((128&a)==0)o.push(a);else if((224&a)==192){var c=63&e[i++];o.push((31&a)<<6|c)}else if((240&a)==224){var c=63&e[i++],h=63&e[i++];o.push((31&a)<<12|c<<6|h)}else if((248&a)==240){var c=63&e[i++],h=63&e[i++],l=(7&a)<<18|c<<12|h<<6|63&e[i++];l>65535&&(l-=65536,o.push(l>>>10&1023|55296),l=56320|1023&l),o.push(l)}else o.push(a);o.length>=4096&&(s+=String.fromCharCode.apply(String,o),o.length=0)}return o.length>0&&(s+=String.fromCharCode.apply(String,o)),s}var S=b?new TextDecoder:null,_=b?void 0!==g&&(null===(r=null==g?void 0:g.env)||void 0===r?void 0:r.TEXT_DECODER)!=="force"?200:0:4294967295;function T(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e instanceof ArrayBuffer?new Uint8Array(e):Uint8Array.from(e)}var I=function(){function e(e,t){void 0===e&&(e=16),void 0===t&&(t=16),this.maxKeyLength=e,this.maxLengthPerKey=t,this.hit=0,this.miss=0,this.caches=[];for(var n=0;n<this.maxKeyLength;n++)this.caches.push([])}return e.prototype.canBeCached=function(e){return e>0&&e<=this.maxKeyLength},e.prototype.find=function(e,t,n){var i=this.caches[n-1];e:for(var r=0;r<i.length;r++){for(var o=i[r],s=o.bytes,a=0;a<n;a++)if(s[a]!==e[t+a])continue e;return o.str}return null},e.prototype.store=function(e,t){var n=this.caches[e.length-1],i={bytes:e,str:t};n.length>=this.maxLengthPerKey?n[Math.random()*n.length|0]=i:n.push(i)},e.prototype.decode=function(e,t,n){var i=this.find(e,t,n);if(null!=i)return this.hit++,i;this.miss++;var r=x(e,t,n),o=Uint8Array.prototype.slice.call(e,t,t+n);return this.store(o,r),r},e}(),B=function(e,t){var n,i,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw TypeError("Generator is already executing.");for(;s;)try{if(n=1,i&&(r=2&o[0]?i.return:o[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;switch(i=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,i=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=(r=s.trys).length>0&&r[r.length-1])&&(6===o[0]||2===o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){s.label=o[1];break}if(6===o[0]&&s.label<r[1]){s.label=r[1],r=o;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(o);break}r[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],i=0}finally{n=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},k=function(e){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(n){t[n]=e[n]&&function(t){return new Promise(function(i,r){!function(e,t,n,i){Promise.resolve(i).then(function(t){e({value:t,done:n})},t)}(i,r,(t=e[n](t)).done,t.value)})}}},D=function(e){return this instanceof D?(this.v=e,this):new D(e)},A=function(e,t,n){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var i,r=n.apply(e,t||[]),o=[];return i={},s("next"),s("throw"),s("return"),i[Symbol.asyncIterator]=function(){return this},i;function s(e){r[e]&&(i[e]=function(t){return new Promise(function(n,i){o.push([e,t,n,i])>1||a(e,t)})})}function a(e,t){try{var n;(n=r[e](t)).value instanceof D?Promise.resolve(n.value.v).then(c,h):l(o[0][2],n)}catch(e){l(o[0][3],e)}}function c(e){a("next",e)}function h(e){a("throw",e)}function l(e,t){e(t),o.shift(),o.length&&a(o[0][0],o[0][1])}},L=function(e){var t=typeof e;return"string"===t||"number"===t},O=new DataView(new ArrayBuffer(0)),P=new Uint8Array(O.buffer),R=function(){try{O.getInt8(0)}catch(e){return e.constructor}throw Error("never reached")}(),M=new R("Insufficient data"),F=new I,z=function(){function e(e,t,n,i,r,o,s,a){void 0===e&&(e=w.defaultCodec),void 0===t&&(t=void 0),void 0===n&&(n=4294967295),void 0===i&&(i=4294967295),void 0===r&&(r=4294967295),void 0===o&&(o=4294967295),void 0===s&&(s=4294967295),void 0===a&&(a=F),this.extensionCodec=e,this.context=t,this.maxStrLength=n,this.maxBinLength=i,this.maxArrayLength=r,this.maxMapLength=o,this.maxExtLength=s,this.keyDecoder=a,this.totalPos=0,this.pos=0,this.view=O,this.bytes=P,this.headByte=-1,this.stack=[]}return e.prototype.reinitializeState=function(){this.totalPos=0,this.headByte=-1,this.stack.length=0},e.prototype.setBuffer=function(e){this.bytes=T(e),this.view=function(e){if(e instanceof ArrayBuffer)return new DataView(e);var t=T(e);return new DataView(t.buffer,t.byteOffset,t.byteLength)}(this.bytes),this.pos=0},e.prototype.appendBuffer=function(e){if(-1!==this.headByte||this.hasRemaining(1)){var t=this.bytes.subarray(this.pos),n=T(e),i=new Uint8Array(t.length+n.length);i.set(t),i.set(n,t.length),this.setBuffer(i)}else this.setBuffer(e)},e.prototype.hasRemaining=function(e){return this.view.byteLength-this.pos>=e},e.prototype.createExtraByteError=function(e){var t=this.view,n=this.pos;return RangeError("Extra ".concat(t.byteLength-n," of ").concat(t.byteLength," byte(s) found at buffer[").concat(e,"]"))},e.prototype.decode=function(e){this.reinitializeState(),this.setBuffer(e);var t=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return t},e.prototype.decodeMulti=function(e){return B(this,function(t){switch(t.label){case 0:this.reinitializeState(),this.setBuffer(e),t.label=1;case 1:if(!this.hasRemaining(1))return[3,3];return[4,this.doDecodeSync()];case 2:return t.sent(),[3,1];case 3:return[2]}})},e.prototype.decodeAsync=function(e){var t,n,i,r,o,s,a,c;return o=this,s=void 0,a=void 0,c=function(){var o,s,a,c,h,u,f;return B(this,function(d){switch(d.label){case 0:o=!1,d.label=1;case 1:d.trys.push([1,6,7,12]),t=k(e),d.label=2;case 2:return[4,t.next()];case 3:if((n=d.sent()).done)return[3,5];if(a=n.value,o)throw this.createExtraByteError(this.totalPos);this.appendBuffer(a);try{s=this.doDecodeSync(),o=!0}catch(e){if(!(e instanceof R))throw e}this.totalPos+=this.pos,d.label=4;case 4:return[3,2];case 5:return[3,12];case 6:return i={error:d.sent()},[3,12];case 7:if(d.trys.push([7,,10,11]),!(n&&!n.done&&(r=t.return)))return[3,9];return[4,r.call(t)];case 8:d.sent(),d.label=9;case 9:return[3,11];case 10:if(i)throw i.error;return[7];case 11:return[7];case 12:if(o){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return[2,s]}throw c=this,h=c.headByte,u=c.pos,f=c.totalPos,RangeError("Insufficient data in parsing ".concat(l(h)," at ").concat(f," (").concat(u," in the current buffer)"))}})},new(a||(a=Promise))(function(e,t){function n(e){try{r(c.next(e))}catch(e){t(e)}}function i(e){try{r(c.throw(e))}catch(e){t(e)}}function r(t){var r;t.done?e(t.value):((r=t.value)instanceof a?r:new a(function(e){e(r)})).then(n,i)}r((c=c.apply(o,s||[])).next())})},e.prototype.decodeArrayStream=function(e){return this.decodeMultiAsync(e,!0)},e.prototype.decodeStream=function(e){return this.decodeMultiAsync(e,!1)},e.prototype.decodeMultiAsync=function(e,t){return A(this,arguments,function(){var n,i,r,o,s,a,c,h;return B(this,function(l){switch(l.label){case 0:n=t,i=-1,l.label=1;case 1:l.trys.push([1,13,14,19]),r=k(e),l.label=2;case 2:return[4,D(r.next())];case 3:if((o=l.sent()).done)return[3,12];if(s=o.value,t&&0===i)throw this.createExtraByteError(this.totalPos);this.appendBuffer(s),n&&(i=this.readArraySize(),n=!1,this.complete()),l.label=4;case 4:l.trys.push([4,9,,10]),l.label=5;case 5:return[4,D(this.doDecodeSync())];case 6:return[4,l.sent()];case 7:if(l.sent(),0==--i)return[3,8];return[3,5];case 8:return[3,10];case 9:if(!((a=l.sent())instanceof R))throw a;return[3,10];case 10:this.totalPos+=this.pos,l.label=11;case 11:return[3,2];case 12:return[3,19];case 13:return c={error:l.sent()},[3,19];case 14:if(l.trys.push([14,,17,18]),!(o&&!o.done&&(h=r.return)))return[3,16];return[4,D(h.call(r))];case 15:l.sent(),l.label=16;case 16:return[3,18];case 17:if(c)throw c.error;return[7];case 18:return[7];case 19:return[2]}})})},e.prototype.doDecodeSync=function(){t:for(;;){var e=this.readHeadByte(),t=void 0;if(e>=224)t=e-256;else if(e<192){if(e<128)t=e;else if(e<144){var n=e-128;if(0!==n){this.pushMapState(n),this.complete();continue}t={}}else if(e<160){var n=e-144;if(0!==n){this.pushArrayState(n),this.complete();continue}t=[]}else{var i=e-160;t=this.decodeUtf8String(i,0)}}else if(192===e)t=null;else if(194===e)t=!1;else if(195===e)t=!0;else if(202===e)t=this.readF32();else if(203===e)t=this.readF64();else if(204===e)t=this.readU8();else if(205===e)t=this.readU16();else if(206===e)t=this.readU32();else if(207===e)t=this.readU64();else if(208===e)t=this.readI8();else if(209===e)t=this.readI16();else if(210===e)t=this.readI32();else if(211===e)t=this.readI64();else if(217===e){var i=this.lookU8();t=this.decodeUtf8String(i,1)}else if(218===e){var i=this.lookU16();t=this.decodeUtf8String(i,2)}else if(219===e){var i=this.lookU32();t=this.decodeUtf8String(i,4)}else if(220===e){var n=this.readU16();if(0!==n){this.pushArrayState(n),this.complete();continue}t=[]}else if(221===e){var n=this.readU32();if(0!==n){this.pushArrayState(n),this.complete();continue}t=[]}else if(222===e){var n=this.readU16();if(0!==n){this.pushMapState(n),this.complete();continue}t={}}else if(223===e){var n=this.readU32();if(0!==n){this.pushMapState(n),this.complete();continue}t={}}else if(196===e){var n=this.lookU8();t=this.decodeBinary(n,1)}else if(197===e){var n=this.lookU16();t=this.decodeBinary(n,2)}else if(198===e){var n=this.lookU32();t=this.decodeBinary(n,4)}else if(212===e)t=this.decodeExtension(1,0);else if(213===e)t=this.decodeExtension(2,0);else if(214===e)t=this.decodeExtension(4,0);else if(215===e)t=this.decodeExtension(8,0);else if(216===e)t=this.decodeExtension(16,0);else if(199===e){var n=this.lookU8();t=this.decodeExtension(n,1)}else if(200===e){var n=this.lookU16();t=this.decodeExtension(n,2)}else if(201===e){var n=this.lookU32();t=this.decodeExtension(n,4)}else throw new d("Unrecognized type byte: ".concat(l(e)));this.complete();for(var r=this.stack;r.length>0;){var o=r[r.length-1];if(0===o.type){if(o.array[o.position]=t,o.position++,o.position===o.size)r.pop(),t=o.array;else continue t}else if(1===o.type){if(!L(t))throw new d("The type of key must be string or number but "+typeof t);if("__proto__"===t)throw new d("The key __proto__ is not allowed");o.key=t,o.type=2;continue t}else if(o.map[o.key]=t,o.readCount++,o.readCount===o.size)r.pop(),t=o.map;else{o.key=null,o.type=1;continue t}}return t}},e.prototype.readHeadByte=function(){return -1===this.headByte&&(this.headByte=this.readU8()),this.headByte},e.prototype.complete=function(){this.headByte=-1},e.prototype.readArraySize=function(){var e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:if(e<160)return e-144;throw new d("Unrecognized array type byte: ".concat(l(e)))}},e.prototype.pushMapState=function(e){if(e>this.maxMapLength)throw new d("Max length exceeded: map length (".concat(e,") > maxMapLengthLength (").concat(this.maxMapLength,")"));this.stack.push({type:1,size:e,key:null,readCount:0,map:{}})},e.prototype.pushArrayState=function(e){if(e>this.maxArrayLength)throw new d("Max length exceeded: array length (".concat(e,") > maxArrayLength (").concat(this.maxArrayLength,")"));this.stack.push({type:0,size:e,array:Array(e),position:0})},e.prototype.decodeUtf8String=function(e,t){if(e>this.maxStrLength)throw new d("Max length exceeded: UTF-8 byte length (".concat(e,") > maxStrLength (").concat(this.maxStrLength,")"));if(this.bytes.byteLength<this.pos+t+e)throw M;var n,i,r,o=this.pos+t;return this.stateIsMapKey()&&(null===(i=this.keyDecoder)||void 0===i?void 0:i.canBeCached(e))?r=this.keyDecoder.decode(this.bytes,o,e):e>_?(n=this.bytes.subarray(o,o+e),r=S.decode(n)):r=x(this.bytes,o,e),this.pos+=t+e,r},e.prototype.stateIsMapKey=function(){return this.stack.length>0&&1===this.stack[this.stack.length-1].type},e.prototype.decodeBinary=function(e,t){if(e>this.maxBinLength)throw new d("Max length exceeded: bin length (".concat(e,") > maxBinLength (").concat(this.maxBinLength,")"));if(!this.hasRemaining(e+t))throw M;var n=this.pos+t,i=this.bytes.subarray(n,n+e);return this.pos+=t+e,i},e.prototype.decodeExtension=function(e,t){if(e>this.maxExtLength)throw new d("Max length exceeded: ext length (".concat(e,") > maxExtLength (").concat(this.maxExtLength,")"));var n=this.view.getInt8(this.pos+t),i=this.decodeBinary(e,t+1);return this.extensionCodec.decode(i,n,this.context)},e.prototype.lookU8=function(){return this.view.getUint8(this.pos)},e.prototype.lookU16=function(){return this.view.getUint16(this.pos)},e.prototype.lookU32=function(){return this.view.getUint32(this.pos)},e.prototype.readU8=function(){var e=this.view.getUint8(this.pos);return this.pos++,e},e.prototype.readI8=function(){var e=this.view.getInt8(this.pos);return this.pos++,e},e.prototype.readU16=function(){var e=this.view.getUint16(this.pos);return this.pos+=2,e},e.prototype.readI16=function(){var e=this.view.getInt16(this.pos);return this.pos+=2,e},e.prototype.readU32=function(){var e=this.view.getUint32(this.pos);return this.pos+=4,e},e.prototype.readI32=function(){var e=this.view.getInt32(this.pos);return this.pos+=4,e},e.prototype.readU64=function(){var e,t,n=(e=this.view,t=this.pos,4294967296*e.getUint32(t)+e.getUint32(t+4));return this.pos+=8,n},e.prototype.readI64=function(){var e=y(this.view,this.pos);return this.pos+=8,e},e.prototype.readF32=function(){var e=this.view.getFloat32(this.pos);return this.pos+=4,e},e.prototype.readF64=function(){var e=this.view.getFloat64(this.pos);return this.pos+=8,e},e}(),N=function(e,t){var n,i,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw TypeError("Generator is already executing.");for(;s;)try{if(n=1,i&&(r=2&o[0]?i.return:o[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;switch(i=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,i=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=(r=s.trys).length>0&&r[r.length-1])&&(6===o[0]||2===o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){s.label=o[1];break}if(6===o[0]&&s.label<r[1]){s.label=r[1],r=o;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(o);break}r[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],i=0}finally{n=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},W=function(e){return this instanceof W?(this.v=e,this):new W(e)},j=function(e,t,n){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var i,r=n.apply(e,t||[]),o=[];return i={},s("next"),s("throw"),s("return"),i[Symbol.asyncIterator]=function(){return this},i;function s(e){r[e]&&(i[e]=function(t){return new Promise(function(n,i){o.push([e,t,n,i])>1||a(e,t)})})}function a(e,t){try{var n;(n=r[e](t)).value instanceof W?Promise.resolve(n.value.v).then(c,h):l(o[0][2],n)}catch(e){l(o[0][3],e)}}function c(e){a("next",e)}function h(e){a("throw",e)}function l(e,t){e(t),o.shift(),o.length&&a(o[0][0],o[0][1])}},$={},H=function(){function e(e,t,n,i,r,o,s,a){void 0===e&&(e=w.defaultCodec),void 0===t&&(t=void 0),void 0===n&&(n=100),void 0===i&&(i=2048),void 0===r&&(r=!1),void 0===o&&(o=!1),void 0===s&&(s=!1),void 0===a&&(a=!1),this.extensionCodec=e,this.context=t,this.maxDepth=n,this.initialBufferSize=i,this.sortKeys=r,this.forceFloat32=o,this.ignoreUndefined=s,this.forceIntegerToFloat=a,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}return e.prototype.reinitializeState=function(){this.pos=0},e.prototype.encodeSharedRef=function(e){return this.reinitializeState(),this.doEncode(e,1),this.bytes.subarray(0,this.pos)},e.prototype.encode=function(e){return this.reinitializeState(),this.doEncode(e,1),this.bytes.slice(0,this.pos)},e.prototype.doEncode=function(e,t){if(t>this.maxDepth)throw Error("Too deep objects in depth ".concat(t));null==e?this.encodeNil():"boolean"==typeof e?this.encodeBoolean(e):"number"==typeof e?this.encodeNumber(e):"string"==typeof e?this.encodeString(e):this.encodeObject(e,t)},e.prototype.ensureBufferSizeToWrite=function(e){var t=this.pos+e;this.view.byteLength<t&&this.resizeBuffer(2*t)},e.prototype.resizeBuffer=function(e){var t=new ArrayBuffer(e),n=new Uint8Array(t),i=new DataView(t);n.set(this.bytes),this.view=i,this.bytes=n},e.prototype.encodeNil=function(){this.writeU8(192)},e.prototype.encodeBoolean=function(e){!1===e?this.writeU8(194):this.writeU8(195)},e.prototype.encodeNumber=function(e){Number.isSafeInteger(e)&&!this.forceIntegerToFloat?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):(this.writeU8(211),this.writeI64(e)):this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))},e.prototype.writeStringHeader=function(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else if(e<4294967296)this.writeU8(219),this.writeU32(e);else throw Error("Too long string: ".concat(e," bytes in UTF-8"))},e.prototype.encodeString=function(e){if(e.length>E){var t=m(e);this.ensureBufferSizeToWrite(5+t),this.writeStringHeader(t),C(e,this.bytes,this.pos),this.pos+=t}else{var t=m(e);this.ensureBufferSizeToWrite(5+t),this.writeStringHeader(t),function(e,t,n){for(var i=e.length,r=n,o=0;o<i;){var s=e.charCodeAt(o++);if((4294967168&s)==0){t[r++]=s;continue}if((4294965248&s)==0)t[r++]=s>>6&31|192;else{if(s>=55296&&s<=56319&&o<i){var a=e.charCodeAt(o);(64512&a)==56320&&(++o,s=((1023&s)<<10)+(1023&a)+65536)}(4294901760&s)==0?t[r++]=s>>12&15|224:(t[r++]=s>>18&7|240,t[r++]=s>>12&63|128),t[r++]=s>>6&63|128}t[r++]=63&s|128}}(e,this.bytes,this.pos),this.pos+=t}},e.prototype.encodeObject=function(e,t){var n=this.extensionCodec.tryToEncode(e,this.context);if(null!=n)this.encodeExtension(n);else if(Array.isArray(e))this.encodeArray(e,t);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else if("object"==typeof e)this.encodeMap(e,t);else throw Error("Unrecognized object: ".concat(Object.prototype.toString.apply(e)))},e.prototype.encodeBinary=function(e){var t=e.byteLength;if(t<256)this.writeU8(196),this.writeU8(t);else if(t<65536)this.writeU8(197),this.writeU16(t);else if(t<4294967296)this.writeU8(198),this.writeU32(t);else throw Error("Too large binary: ".concat(t));var n=T(e);this.writeU8a(n)},e.prototype.encodeArray=function(e,t){var n=e.length;if(n<16)this.writeU8(144+n);else if(n<65536)this.writeU8(220),this.writeU16(n);else if(n<4294967296)this.writeU8(221),this.writeU32(n);else throw Error("Too large array: ".concat(n));for(var i=0;i<e.length;i++){var r=e[i];this.doEncode(r,t+1)}},e.prototype.countWithoutUndefined=function(e,t){for(var n=0,i=0;i<t.length;i++)void 0!==e[t[i]]&&n++;return n},e.prototype.encodeMap=function(e,t){var n=Object.keys(e);this.sortKeys&&n.sort();var i=this.ignoreUndefined?this.countWithoutUndefined(e,n):n.length;if(i<16)this.writeU8(128+i);else if(i<65536)this.writeU8(222),this.writeU16(i);else if(i<4294967296)this.writeU8(223),this.writeU32(i);else throw Error("Too large map object: ".concat(i));for(var r=0;r<n.length;r++){var o=n[r],s=e[o];this.ignoreUndefined&&void 0===s||(this.encodeString(o),this.doEncode(s,t+1))}},e.prototype.encodeExtension=function(e){var t=e.data.length;if(1===t)this.writeU8(212);else if(2===t)this.writeU8(213);else if(4===t)this.writeU8(214);else if(8===t)this.writeU8(215);else if(16===t)this.writeU8(216);else if(t<256)this.writeU8(199),this.writeU8(t);else if(t<65536)this.writeU8(200),this.writeU16(t);else if(t<4294967296)this.writeU8(201),this.writeU32(t);else throw Error("Too large extension object: ".concat(t));this.writeI8(e.type),this.writeU8a(e.data)},e.prototype.writeU8=function(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++},e.prototype.writeU8a=function(e){var t=e.length;this.ensureBufferSizeToWrite(t),this.bytes.set(e,this.pos),this.pos+=t},e.prototype.writeI8=function(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++},e.prototype.writeU16=function(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2},e.prototype.writeI16=function(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2},e.prototype.writeU32=function(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4},e.prototype.writeI32=function(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4},e.prototype.writeF32=function(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4},e.prototype.writeF64=function(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8},e.prototype.writeU64=function(e){var t,n;this.ensureBufferSizeToWrite(8),t=this.view,n=this.pos,t.setUint32(n,e/4294967296),t.setUint32(n+4,e),this.pos+=8},e.prototype.writeI64=function(e){this.ensureBufferSizeToWrite(8),p(this.view,this.pos,e),this.pos+=8},e}(),K=c("hBa25");class V extends K.StreamConnection{constructor(e,t,n){super(e,t,n),this.serialization="MsgPack",this._encoder=new H,(async()=>{var e,t,n;for await(let i of(e=this._rawReadStream,void 0===t&&(t=$),n=null!=e[Symbol.asyncIterator]?e:function(e){return j(this,arguments,function(){var t,n,i,r;return N(this,function(o){switch(o.label){case 0:t=e.getReader(),o.label=1;case 1:o.trys.push([1,,9,10]),o.label=2;case 2:return[4,W(t.read())];case 3:if(i=(n=o.sent()).done,r=n.value,!i)return[3,5];return[4,W(void 0)];case 4:return[2,o.sent()];case 5:return function(e){if(null==e)throw Error("Assertion Failure: value must not be null nor undefined")}(r),[4,W(r)];case 6:return[4,o.sent()];case 7:return o.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})})}(e),new z(t.extensionCodec,t.context,t.maxStrLength,t.maxBinLength,t.maxArrayLength,t.maxMapLength,t.maxExtLength).decodeStream(n))){if(i.__peerData?.type==="close"){this.close();return}this.emit("data",i)}})()}_send(e){return this.writer.write(this._encoder.encode(e))}}export{V as MsgPack};
2//# sourceMappingURL=serializer.msgpack.mjs.map