@eyhn/msgpack-stream
Version:
MessagePack for ECMA-262/JavaScript/TypeScript
2 lines • 41.2 kB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.MessagePack=t():e.MessagePack=t()}(this,(()=>(()=>{"use strict";var e={d:(t,i)=>{for(var r in i)e.o(i,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:i[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{DataViewIndexOutOfBoundsError:()=>H,DecodeError:()=>v,Decoder:()=>G,EXT_TIMESTAMP:()=>B,Encoder:()=>D,ExtData:()=>b,ExtensionCodec:()=>A,decode:()=>oe,decodeArrayStream:()=>ye,decodeAsync:()=>le,decodeMulti:()=>he,decodeMultiStream:()=>we,decodeStream:()=>ae,decodeTimestampExtension:()=>E,decodeTimestampToTimeSpec:()=>L,encode:()=>k,encodeDateToTimeSpec:()=>S,encodeStream:()=>$,encodeTimeSpecToTimestamp:()=>x,encodeTimestampExtension:()=>I});const i=4294967295;function r(e,t,i){const r=i/4294967296,n=i;e.setUint32(t,r),e.setUint32(t+4,n)}function n(e,t,i){const r=Math.floor(i/4294967296),n=i;e.setUint32(t,r),e.setUint32(t+4,n)}function s(e,t){return 4294967296*e.getInt32(t)+e.getUint32(t+4)}function o(e,t){return 4294967296*e.getUint32(t)+e.getUint32(t+4)}var h,a,f;const d=("undefined"==typeof process||"never"!==(null===(h=null===process||void 0===process?void 0:process.env)||void 0===h?void 0:h.TEXT_ENCODING))&&"undefined"!=typeof TextEncoder&&"undefined"!=typeof TextDecoder;function c(e){const t=e.length;let i=0,r=0;for(;r<t;){let n=e.charCodeAt(r++);if(0!=(4294967168&n))if(0==(4294965248&n))i+=2;else{if(n>=55296&&n<=56319&&r<t){const t=e.charCodeAt(r);56320==(64512&t)&&(++r,n=((1023&n)<<10)+(1023&t)+65536)}i+=0==(4294901760&n)?3:4}else i++}return i}function u(e,t,i){const r=e.length;let n=i,s=0;for(;s<r;){let i=e.charCodeAt(s++);if(0!=(4294967168&i)){if(0==(4294965248&i))t[n++]=i>>6&31|192;else{if(i>=55296&&i<=56319&&s<r){const t=e.charCodeAt(s);56320==(64512&t)&&(++s,i=((1023&i)<<10)+(1023&t)+65536)}0==(4294901760&i)?(t[n++]=i>>12&15|224,t[n++]=i>>6&63|128):(t[n++]=i>>18&7|240,t[n++]=i>>12&63|128,t[n++]=i>>6&63|128)}t[n++]=63&i|128}else t[n++]=i}}const l=d?new TextEncoder:void 0,y=d?"undefined"!=typeof process&&"force"!==(null===(a=null===process||void 0===process?void 0:process.env)||void 0===a?void 0:a.TEXT_ENCODING)?200:0:i,w=(null==l?void 0:l.encodeInto)?function(e,t,i){l.encodeInto(e,t.subarray(i))}:function(e,t,i){t.set(l.encode(e),i)};function g(e,t,i){let r=t;const n=r+i,s=[];let o="";for(;r<n;){const t=e[r++];if(0==(128&t))s.push(t);else if(192==(224&t)){const i=63&e[r++];s.push((31&t)<<6|i)}else if(224==(240&t)){const i=63&e[r++],n=63&e[r++];s.push((31&t)<<12|i<<6|n)}else if(240==(248&t)){let i=(7&t)<<18|(63&e[r++])<<12|(63&e[r++])<<6|63&e[r++];i>65535&&(i-=65536,s.push(i>>>10&1023|55296),i=56320|1023&i),s.push(i)}else s.push(t);s.length>=4096&&(o+=String.fromCharCode(...s),s.length=0)}return s.length>0&&(o+=String.fromCharCode(...s)),o}const p=d?new TextDecoder:null,U=d?"undefined"!=typeof process&&"force"!==(null===(f=null===process||void 0===process?void 0:process.env)||void 0===f?void 0:f.TEXT_DECODER)?200:0:i;function m(e,t,i){const r=e.subarray(t,t+i);return p.decode(r)}class b{constructor(e,t){this.type=e,this.data=t}}class v extends Error{constructor(e){super(e);const t=Object.create(v.prototype);Object.setPrototypeOf(this,t),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:v.name})}}const B=-1;function x({sec:e,nsec:t}){if(e>=0&&t>=0&&e<=17179869183){if(0===t&&e<=4294967295){const t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e),t}{const i=e/4294967296,r=4294967295&e,n=new Uint8Array(8),s=new DataView(n.buffer);return s.setUint32(0,t<<2|3&i),s.setUint32(4,r),n}}{const i=new Uint8Array(12),r=new DataView(i.buffer);return r.setUint32(0,t),n(r,4,e),i}}function S(e){const t=e.getTime(),i=Math.floor(t/1e3),r=1e6*(t-1e3*i),n=Math.floor(r/1e9);return{sec:i+n,nsec:r-1e9*n}}function I(e){return e instanceof Date?x(S(e)):null}function L(e){const t=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(e.byteLength){case 4:return{sec:t.getUint32(0),nsec:0};case 8:{const e=t.getUint32(0);return{sec:4294967296*(3&e)+t.getUint32(4),nsec:e>>>2}}case 12:return{sec:s(t,4),nsec:t.getUint32(0)};default:throw new v(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${e.length}`)}}function E(e){const t=L(e);return new Date(1e3*t.sec+t.nsec/1e6)}const F={type:B,encode:I,decode:E};class A{constructor(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(F)}register({type:e,encode:t,decode:i}){if(e>=0)this.encoders[e]=t,this.decoders[e]=i;else{const r=1+e;this.builtInEncoders[r]=t,this.builtInDecoders[r]=i}}tryToEncode(e,t){for(let i=0;i<this.builtInEncoders.length;i++){const r=this.builtInEncoders[i];if(null!=r){const n=r(e,t);if(null!=n)return new b(-1-i,n)}}for(let i=0;i<this.encoders.length;i++){const r=this.encoders[i];if(null!=r){const n=r(e,t);if(null!=n)return new b(i,n)}}return e instanceof b?e:null}decode(e,t,i){const r=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return r?r(e,t,i):new b(t,e)}}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)}A.defaultCodec=new A;class D{constructor(e=A.defaultCodec,t,i=100,r=2048,n=!1,s=!1,o=!1,h=!1){this.extensionCodec=e,this.context=t,this.maxDepth=i,this.initialBufferSize=r,this.sortKeys=n,this.forceFloat32=s,this.ignoreUndefined=o,this.forceIntegerToFloat=h,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}reinitializeState(){this.pos=0}encodeSharedRef(e){return this.reinitializeState(),this.doEncode(e,1),this.bytes.subarray(0,this.pos)}encode(e){return this.reinitializeState(),this.doEncode(e,1),this.bytes.slice(0,this.pos)}doEncode(e,t){if(t>this.maxDepth)throw new Error(`Too deep objects in depth ${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)}ensureBufferSizeToWrite(e){const t=this.pos+e;this.view.byteLength<t&&this.resizeBuffer(2*t)}resizeBuffer(e){const t=new ArrayBuffer(e),i=new Uint8Array(t),r=new DataView(t);i.set(this.bytes),this.view=r,this.bytes=i}encodeNil(){this.writeU8(192)}encodeBoolean(e){!1===e?this.writeU8(194):this.writeU8(195)}encodeNumber(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))}writeStringHeader(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))throw new Error(`Too long string: ${e} bytes in UTF-8`);this.writeU8(219),this.writeU32(e)}}encodeString(e){if(e.length>y){const t=c(e);this.ensureBufferSizeToWrite(5+t),this.writeStringHeader(t),w(e,this.bytes,this.pos),this.pos+=t}else{const t=c(e);this.ensureBufferSizeToWrite(5+t),this.writeStringHeader(t),u(e,this.bytes,this.pos),this.pos+=t}}encodeObject(e,t){const i=this.extensionCodec.tryToEncode(e,this.context);if(null!=i)this.encodeExtension(i);else if(Array.isArray(e))this.encodeArray(e,t);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else{if("object"!=typeof e)throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`);this.encodeMap(e,t)}}encodeBinary(e){const 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))throw new Error(`Too large binary: ${t}`);this.writeU8(198),this.writeU32(t)}const i=T(e);this.writeU8a(i)}encodeArray(e,t){const i=e.length;if(i<16)this.writeU8(144+i);else if(i<65536)this.writeU8(220),this.writeU16(i);else{if(!(i<4294967296))throw new Error(`Too large array: ${i}`);this.writeU8(221),this.writeU32(i)}for(const i of e)this.doEncode(i,t+1)}countWithoutUndefined(e,t){let i=0;for(const r of t)void 0!==e[r]&&i++;return i}encodeMap(e,t){const i=Object.keys(e);this.sortKeys&&i.sort();const r=this.ignoreUndefined?this.countWithoutUndefined(e,i):i.length;if(r<16)this.writeU8(128+r);else if(r<65536)this.writeU8(222),this.writeU16(r);else{if(!(r<4294967296))throw new Error(`Too large map object: ${r}`);this.writeU8(223),this.writeU32(r)}for(const r of i){const i=e[r];this.ignoreUndefined&&void 0===i||(this.encodeString(r),this.doEncode(i,t+1))}}encodeExtension(e){const 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))throw new Error(`Too large extension object: ${t}`);this.writeU8(201),this.writeU32(t)}this.writeI8(e.type),this.writeU8a(e.data)}writeU8(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++}writeU8a(e){const t=e.length;this.ensureBufferSizeToWrite(t),this.bytes.set(e,this.pos),this.pos+=t}writeI8(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++}writeU16(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2}writeI16(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2}writeU32(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4}writeI32(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4}writeF32(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4}writeF64(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8}writeU64(e){this.ensureBufferSizeToWrite(8),r(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),n(this.view,this.pos,e),this.pos+=8}}class M{constructor(e=A.defaultCodec,t,i=100,r=2048,n=!1,s=!1,o=!1,h=!1){this.extensionCodec=e,this.context=t,this.maxDepth=i,this.bufferSize=r,this.sortKeys=n,this.forceFloat32=s,this.ignoreUndefined=o,this.forceIntegerToFloat=h,this.view=new DataView(new ArrayBuffer(2048)),this.bytes=new Uint8Array(this.view.buffer)}*encode(e){const t=new Uint8Array(this.bufferSize);let i=0;for(let r of this.doEncode(e,1))if(r.length>=t.length)i>=0&&(yield t.slice(0,i)),i=0,yield r.slice();else for(;r.length>0;){const e=Math.min(t.length-i,r.length),n=r.subarray(0,e);t.set(n,i),i+=n.length,i===t.length&&(yield t.slice(),i=0),r=r.subarray(e,r.length)}i>=0&&(yield t.subarray(0,i))}doEncode(e,t){if(t>this.maxDepth)throw new Error(`Too deep objects in depth ${t}`);return 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)}ensureBufferSizeToWrite(e){this.view.byteLength<e&&this.resizeBuffer(2*e)}resizeBuffer(e){const t=new ArrayBuffer(e),i=new Uint8Array(t),r=new DataView(t);this.view=r,this.bytes=i}encodeNil(){return this.writeU8(192)}encodeBoolean(e){return!1===e?this.writeU8(194):this.writeU8(195)}encodeNumber(e){return Number.isSafeInteger(e)&&!this.forceIntegerToFloat?e>=0?e<128?this.writeU8(e):e<256?this.writeU8U8(204,e):e<65536?this.writeU8U16(205,e):e<4294967296?this.writeU8U32(206,e):this.writeU8U64(207,e):e>=-32?this.writeU8(224|e+32):e>=-128?this.writeU8I8(208,e):e>=-32768?this.writeU8I16(209,e):e>=-2147483648?this.writeU8I32(210,e):this.writeU8I64(211,e):this.forceFloat32?this.writeU8F32(202,e):this.writeU8F64(203,e)}buildStringHeader(e){if(e<32)return[160+e];if(e<256)return[217,e];if(e<65536){const t=new DataView(new ArrayBuffer(3));return t.setUint8(0,218),t.setUint16(1,e),new Uint8Array(t.buffer)}if(e<4294967296){const t=new DataView(new ArrayBuffer(5));return t.setUint8(0,219),t.setUint32(1,e),new Uint8Array(t.buffer)}throw new Error(`Too long string: ${e} bytes in UTF-8`)}encodeString(e){if(e.length>y){const t=c(e);this.ensureBufferSizeToWrite(5+t);const i=this.buildStringHeader(t);return this.bytes.set(i,0),w(e,this.bytes,i.length),this.writeBuffer(t+i.length)}{const t=c(e);this.ensureBufferSizeToWrite(5+t);const i=this.buildStringHeader(t);return this.bytes.set(i,0),u(e,this.bytes,i.length),this.writeBuffer(t+i.length)}}encodeObject(e,t){const i=this.extensionCodec.tryToEncode(e,this.context);if(null!=i)return this.encodeExtension(i);if(Array.isArray(e))return this.encodeArray(e,t);if(ArrayBuffer.isView(e))return this.encodeBinary(e);if("object"==typeof e)return this.encodeMap(e,t);throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`)}*encodeBinary(e){const t=e.byteLength;if(t<256)yield*this.writeU8U8(196,t);else if(t<65536)yield*this.writeU8U16(197,t);else{if(!(t<4294967296))throw new Error(`Too large binary: ${t}`);yield*this.writeU8U32(198,t)}const i=T(e);yield*this.writeU8a(i)}*encodeArray(e,t){const i=e.length;if(i<16)yield*this.writeU8(144+i);else if(i<65536)yield*this.writeU8U16(220,i);else{if(!(i<4294967296))throw new Error(`Too large array: ${i}`);yield*this.writeU8U32(221,i)}for(const i of e)yield*this.doEncode(i,t+1)}countWithoutUndefined(e,t){let i=0;for(const r of t)void 0!==e[r]&&i++;return i}*encodeMap(e,t){const i=Object.keys(e);this.sortKeys&&i.sort();const r=this.ignoreUndefined?this.countWithoutUndefined(e,i):i.length;if(r<16)yield*this.writeU8(128+r);else if(r<65536)yield*this.writeU8U16(222,r);else{if(!(r<4294967296))throw new Error(`Too large map object: ${r}`);yield*this.writeU8U32(223,r)}for(const r of i){const i=e[r];this.ignoreUndefined&&void 0===i||(yield*this.encodeString(r),yield*this.doEncode(i,t+1))}}*encodeExtension(e){const t=e.data.length;if(1===t)yield*this.writeU8(212);else if(2===t)yield*this.writeU8(213);else if(4===t)yield*this.writeU8(214);else if(8===t)yield*this.writeU8(215);else if(16===t)yield*this.writeU8(216);else if(t<256)yield*this.writeU8U8(199,t);else if(t<65536)yield*this.writeU8U16(200,t);else{if(!(t<4294967296))throw new Error(`Too large extension object: ${t}`);yield*this.writeU8U32(201,t)}yield*this.writeI8(e.type),yield*this.writeU8a(e.data)}writeU8(e){return this.view.setUint8(0,e),this.writeBuffer(1)}writeU8a(e){const t=e.length;return this.ensureBufferSizeToWrite(t),this.bytes.set(e,0),this.writeBuffer(t)}writeI8(e){return this.view.setInt8(0,e),this.writeBuffer(1)}writeU16(e){return this.view.setUint16(0,e),this.writeBuffer(2)}writeI16(e){return this.view.setInt16(0,e),this.writeBuffer(2)}writeU32(e){return this.view.setUint32(0,e),this.writeBuffer(4)}writeI32(e){return this.view.setInt32(0,e),this.writeBuffer(4)}writeF32(e){return this.view.setFloat32(0,e),this.writeBuffer(4)}writeF64(e){return this.view.setFloat64(0,e),this.writeBuffer(8)}writeU64(e){return r(this.view,0,e),this.writeBuffer(8)}writeI64(e){return n(this.view,0,e),this.writeBuffer(8)}writeU8U8(e,t){return this.view.setUint8(0,e),this.view.setUint8(1,t),this.writeBuffer(2)}writeU8U16(e,t){return this.view.setUint8(0,e),this.view.setUint16(1,t),this.writeBuffer(3)}writeU8U32(e,t){return this.view.setUint8(0,e),this.view.setUint32(1,t),this.writeBuffer(5)}writeU8U64(e,t){return this.view.setUint8(0,e),r(this.view,1,t),this.writeBuffer(9)}writeU8I8(e,t){return this.view.setUint8(0,e),this.view.setInt8(1,t),this.writeBuffer(2)}writeU8I16(e,t){return this.view.setUint8(0,e),this.view.setInt16(1,t),this.writeBuffer(3)}writeU8I32(e,t){return this.view.setUint8(0,e),this.view.setInt32(1,t),this.writeBuffer(5)}writeU8I64(e,t){return this.view.setUint8(0,e),n(this.view,1,t),this.writeBuffer(9)}writeU8F32(e,t){return this.view.setUint8(0,e),this.view.setFloat32(1,t),this.writeBuffer(5)}writeU8F64(e,t){return this.view.setUint8(0,e),this.view.setFloat64(1,t),this.writeBuffer(9)}*writeBuffer(e){yield this.bytes.subarray(0,e)}}const z={};function k(e,t=z){return new D(t.extensionCodec,t.context,t.maxDepth,t.initialBufferSize,t.sortKeys,t.forceFloat32,t.ignoreUndefined,t.forceIntegerToFloat).encodeSharedRef(e)}function $(e,t=z){return new M(t.extensionCodec,t.context,t.maxDepth,t.streamBufferSize,t.sortKeys,t.forceFloat32,t.ignoreUndefined,t.forceIntegerToFloat).encode(e)}function O(e){return`${e<0?"-":""}0x${Math.abs(e).toString(16).padStart(2,"0")}`}class C{constructor(e=16,t=16){this.maxKeyLength=e,this.maxLengthPerKey=t,this.hit=0,this.miss=0,this.caches=[];for(let e=0;e<this.maxKeyLength;e++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,t,i){const r=this.caches[i-1];e:for(const n of r){const r=n.bytes;for(let n=0;n<i;n++)if(r[n]!==e[t+n])continue e;return n.str}return null}store(e,t){const i=this.caches[e.length-1],r={bytes:e,str:t};i.length>=this.maxLengthPerKey?i[Math.random()*i.length|0]=r:i.push(r)}decode(e,t,i){const r=this.find(e,t,i);if(null!=r)return this.hit++,r;this.miss++;const n=g(e,t,i),s=Uint8Array.prototype.slice.call(e,t,t+i);return this.store(s,n),n}}var V=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,i=e[Symbol.asyncIterator];return i?i.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(i){t[i]=e[i]&&function(t){return new Promise((function(r,n){!function(e,t,i,r){Promise.resolve(r).then((function(t){e({value:t,done:i})}),t)}(r,n,(t=e[i](t)).done,t.value)}))}}},P=function(e){return this instanceof P?(this.v=e,this):new P(e)};const _="array",j="map_key",W=e=>{const t=typeof e;return"string"===t||"number"===t},K=new DataView(new ArrayBuffer(0)),N=new Uint8Array(K.buffer),H=(()=>{try{K.getInt8(0)}catch(e){return e.constructor}throw new Error("never reached")})(),R=new H("Insufficient data"),X=new C;class G{constructor(e=A.defaultCodec,t,i=4294967295,r=4294967295,n=4294967295,s=4294967295,o=4294967295,h=X){this.extensionCodec=e,this.context=t,this.maxStrLength=i,this.maxBinLength=r,this.maxArrayLength=n,this.maxMapLength=s,this.maxExtLength=o,this.keyDecoder=h,this.totalPos=0,this.pos=0,this.view=K,this.bytes=N,this.headByte=-1,this.stack=[]}reinitializeState(){this.totalPos=0,this.headByte=-1,this.stack.length=0}setBuffer(e){this.bytes=T(e),this.view=function(e){if(e instanceof ArrayBuffer)return new DataView(e);const t=T(e);return new DataView(t.buffer,t.byteOffset,t.byteLength)}(this.bytes),this.pos=0}appendBuffer(e){if(-1!==this.headByte||this.hasRemaining(1)){const t=this.bytes.subarray(this.pos),i=T(e),r=new Uint8Array(t.length+i.length);r.set(t),r.set(i,t.length),this.setBuffer(r)}else this.setBuffer(e)}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){const{view:t,pos:i}=this;return new RangeError(`Extra ${t.byteLength-i} of ${t.byteLength} byte(s) found at buffer[${e}]`)}decode(e){this.reinitializeState(),this.setBuffer(e);const t=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return t}*decodeMulti(e){for(this.reinitializeState(),this.setBuffer(e);this.hasRemaining(1);)yield this.doDecodeSync()}decodeAsync(e){var t,i,r,n,s,o,h,a;return s=this,o=void 0,a=function*(){let s,o=!1;try{for(t=V(e);!(i=yield t.next()).done;){const e=i.value;if(o)throw this.createExtraByteError(this.totalPos);this.appendBuffer(e);try{s=this.doDecodeSync(),o=!0}catch(e){if(!(e instanceof H))throw e}this.totalPos+=this.pos}}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=t.return)&&(yield n.call(t))}finally{if(r)throw r.error}}if(o){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return s}const{headByte:h,pos:a,totalPos:f}=this;throw new RangeError(`Insufficient data in parsing ${O(h)} at ${f} (${a} in the current buffer)`)},new((h=void 0)||(h=Promise))((function(e,t){function i(e){try{n(a.next(e))}catch(e){t(e)}}function r(e){try{n(a.throw(e))}catch(e){t(e)}}function n(t){var n;t.done?e(t.value):(n=t.value,n instanceof h?n:new h((function(e){e(n)}))).then(i,r)}n((a=a.apply(s,o||[])).next())}))}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}decodeMultiAsync(e,t){return function(e,t,i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,n=i.apply(e,t||[]),s=[];return r={},o("next"),o("throw"),o("return"),r[Symbol.asyncIterator]=function(){return this},r;function o(e){n[e]&&(r[e]=function(t){return new Promise((function(i,r){s.push([e,t,i,r])>1||h(e,t)}))})}function h(e,t){try{(i=n[e](t)).value instanceof P?Promise.resolve(i.value.v).then(a,f):d(s[0][2],i)}catch(e){d(s[0][3],e)}var i}function a(e){h("next",e)}function f(e){h("throw",e)}function d(e,t){e(t),s.shift(),s.length&&h(s[0][0],s[0][1])}}(this,arguments,(function*(){var i,r;let n=t,s=-1;try{for(var o,h=V(e);!(o=yield P(h.next())).done;){const e=o.value;if(t&&0===s)throw this.createExtraByteError(this.totalPos);this.appendBuffer(e),n&&(s=this.readArraySize(),n=!1,this.complete());try{for(;yield yield P(this.doDecodeSync()),0!=--s;);}catch(e){if(!(e instanceof H))throw e}this.totalPos+=this.pos}}catch(e){i={error:e}}finally{try{o&&!o.done&&(r=h.return)&&(yield P(r.call(h)))}finally{if(i)throw i.error}}}))}doDecodeSync(){e:for(;;){const e=this.readHeadByte();let t;if(e>=224)t=e-256;else if(e<192)if(e<128)t=e;else if(e<144){const i=e-128;if(0!==i){this.pushMapState(i),this.complete();continue e}t={}}else if(e<160){const i=e-144;if(0!==i){this.pushArrayState(i),this.complete();continue e}t=[]}else{const 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){const e=this.lookU8();t=this.decodeUtf8String(e,1)}else if(218===e){const e=this.lookU16();t=this.decodeUtf8String(e,2)}else if(219===e){const e=this.lookU32();t=this.decodeUtf8String(e,4)}else if(220===e){const e=this.readU16();if(0!==e){this.pushArrayState(e),this.complete();continue e}t=[]}else if(221===e){const e=this.readU32();if(0!==e){this.pushArrayState(e),this.complete();continue e}t=[]}else if(222===e){const e=this.readU16();if(0!==e){this.pushMapState(e),this.complete();continue e}t={}}else if(223===e){const e=this.readU32();if(0!==e){this.pushMapState(e),this.complete();continue e}t={}}else if(196===e){const e=this.lookU8();t=this.decodeBinary(e,1)}else if(197===e){const e=this.lookU16();t=this.decodeBinary(e,2)}else if(198===e){const e=this.lookU32();t=this.decodeBinary(e,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){const e=this.lookU8();t=this.decodeExtension(e,1)}else if(200===e){const e=this.lookU16();t=this.decodeExtension(e,2)}else{if(201!==e)throw new v(`Unrecognized type byte: ${O(e)}`);{const e=this.lookU32();t=this.decodeExtension(e,4)}}this.complete();const i=this.stack;for(;i.length>0;){const e=i[i.length-1];if(e.type===_){if(e.array[e.position]=t,e.position++,e.position!==e.size)continue e;i.pop(),t=e.array}else{if(e.type===j){if(!W(t))throw new v("The type of key must be string or number but "+typeof t);if("__proto__"===t)throw new v("The key __proto__ is not allowed");e.key=t,e.type="map_value";continue e}if(e.map[e.key]=t,e.readCount++,e.readCount!==e.size){e.key=null,e.type=j;continue e}i.pop(),t=e.map}}return t}}readHeadByte(){return-1===this.headByte&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=-1}readArraySize(){const e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:if(e<160)return e-144;throw new v(`Unrecognized array type byte: ${O(e)}`)}}pushMapState(e){if(e>this.maxMapLength)throw new v(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.push({type:j,size:e,key:null,readCount:0,map:{}})}pushArrayState(e){if(e>this.maxArrayLength)throw new v(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.push({type:_,size:e,array:new Array(e),position:0})}decodeUtf8String(e,t){var i;if(e>this.maxStrLength)throw new v(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+t+e)throw R;const r=this.pos+t;let n;return n=this.stateIsMapKey()&&(null===(i=this.keyDecoder)||void 0===i?void 0:i.canBeCached(e))?this.keyDecoder.decode(this.bytes,r,e):e>U?m(this.bytes,r,e):g(this.bytes,r,e),this.pos+=t+e,n}stateIsMapKey(){return this.stack.length>0&&this.stack[this.stack.length-1].type===j}decodeBinary(e,t){if(e>this.maxBinLength)throw new v(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+t))throw R;const i=this.pos+t,r=this.bytes.subarray(i,i+e);return this.pos+=t+e,r}decodeExtension(e,t){if(e>this.maxExtLength)throw new v(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);const i=this.view.getInt8(this.pos+t),r=this.decodeBinary(e,t+1);return this.extensionCodec.decode(r,i,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){const e=this.view.getUint8(this.pos);return this.pos++,e}readI8(){const e=this.view.getInt8(this.pos);return this.pos++,e}readU16(){const e=this.view.getUint16(this.pos);return this.pos+=2,e}readI16(){const e=this.view.getInt16(this.pos);return this.pos+=2,e}readU32(){const e=this.view.getUint32(this.pos);return this.pos+=4,e}readI32(){const e=this.view.getInt32(this.pos);return this.pos+=4,e}readU64(){const e=o(this.view,this.pos);return this.pos+=8,e}readI64(){const e=s(this.view,this.pos);return this.pos+=8,e}readF32(){const e=this.view.getFloat32(this.pos);return this.pos+=4,e}readF64(){const e=this.view.getFloat64(this.pos);return this.pos+=8,e}}var q=function(e,t,i,r){return new(i||(i=Promise))((function(n,s){function o(e){try{a(r.next(e))}catch(e){s(e)}}function h(e){try{a(r.throw(e))}catch(e){s(e)}}function a(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,h)}a((r=r.apply(e,t||[])).next())}))},J=function(e){return this instanceof J?(this.v=e,this):new J(e)};const Q="array",Y="map_key",Z=e=>{const t=typeof e;return"string"===t||"number"===t},ee=new DataView(new ArrayBuffer(0)),te=(()=>{try{ee.getInt8(0)}catch(e){return e.constructor}throw new Error("never reached")})(),ie=new C,re=new te("Insufficient data");class ne{constructor(e,t=A.defaultCodec,i,r=4294967295,n=4294967295,s=4294967295,o=4294967295,h=4294967295,a=ie,f=2048){this.readIterable=e,this.extensionCodec=t,this.context=i,this.maxStrLength=r,this.maxBinLength=n,this.maxArrayLength=s,this.maxMapLength=o,this.maxExtLength=h,this.keyDecoder=a,this.bufferSize=f,this.headByte=-1,this.stack=[],this.buffer=null,this.readStream=e[Symbol.asyncIterator]()}reinitializeState(){this.headByte=-1,this.stack.length=0}createExtraByteError(){return new RangeError("Extra bytes found")}decode(){return this.reinitializeState(),this.doDecodeSync()}decodeMulti(){return function(e,t,i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,n=i.apply(e,t||[]),s=[];return r={},o("next"),o("throw"),o("return"),r[Symbol.asyncIterator]=function(){return this},r;function o(e){n[e]&&(r[e]=function(t){return new Promise((function(i,r){s.push([e,t,i,r])>1||h(e,t)}))})}function h(e,t){try{(i=n[e](t)).value instanceof J?Promise.resolve(i.value.v).then(a,f):d(s[0][2],i)}catch(e){d(s[0][3],e)}var i}function a(e){h("next",e)}function f(e){h("throw",e)}function d(e,t){e(t),s.shift(),s.length&&h(s[0][0],s[0][1])}}(this,arguments,(function*(){for(this.reinitializeState();;)yield yield J(yield J(this.doDecodeSync()))}))}doDecodeSync(){var e,t,i,r,n,s,o,h,a,f,d,c,u,l,y,w,g,p,U,m,b,B,x,S,I,L,E,F;return q(this,void 0,void 0,(function*(){e:for(;;){const A=null!==(e=this.readHeadByteFromBuffer())&&void 0!==e?e:yield this.readHeadByte();let T;if(A>=224)T=A-256;else if(A<192)if(A<128)T=A;else if(A<144){const e=A-128;if(0!==e){this.pushMapState(e),this.complete();continue e}T={}}else if(A<160){const e=A-144;if(0!==e){this.pushArrayState(e),this.complete();continue e}T=[]}else{const e=A-160;T=null!==(t=this.decodeUtf8StringFromBuffer(e))&&void 0!==t?t:yield this.decodeUtf8String(e)}else if(192===A)T=null;else if(194===A)T=!1;else if(195===A)T=!0;else if(202===A)T=null!==(i=this.readF32FromBuffer())&&void 0!==i?i:yield this.readF32();else if(203===A)T=null!==(r=this.readF64FromBuffer())&&void 0!==r?r:yield this.readF64();else if(204===A)T=null!==(n=this.readU8FromBuffer())&&void 0!==n?n:yield this.readU8();else if(205===A)T=null!==(s=this.readU16FromBuffer())&&void 0!==s?s:yield this.readU16();else if(206===A)T=null!==(o=this.readU32FromBuffer())&&void 0!==o?o:yield this.readU32();else if(207===A)T=null!==(h=this.readU64FromBuffer())&&void 0!==h?h:yield this.readU64();else if(208===A)T=null!==(a=this.readI8FromBuffer())&&void 0!==a?a:yield this.readI8();else if(209===A)T=null!==(f=this.readI16FromBuffer())&&void 0!==f?f:yield this.readI16();else if(210===A)T=null!==(d=this.readI32FromBuffer())&&void 0!==d?d:yield this.readI32();else if(211===A)T=null!==(c=this.readI64FromBuffer())&&void 0!==c?c:yield this.readI64();else if(217===A){const e=null!==(u=this.readU8FromBuffer())&&void 0!==u?u:yield this.readU8();T=null!==(l=this.decodeUtf8StringFromBuffer(e))&&void 0!==l?l:yield this.decodeUtf8String(e)}else if(218===A){const e=null!==(y=this.readU16FromBuffer())&&void 0!==y?y:yield this.readU16();T=null!==(w=this.decodeUtf8StringFromBuffer(e))&&void 0!==w?w:yield this.decodeUtf8String(e)}else if(219===A){const e=null!==(g=this.readU32FromBuffer())&&void 0!==g?g:yield this.readU32();T=null!==(p=this.decodeUtf8StringFromBuffer(e))&&void 0!==p?p:yield this.decodeUtf8String(e)}else if(220===A){const e=null!==(U=this.readU16FromBuffer())&&void 0!==U?U:yield this.readU16();if(0!==e){this.pushArrayState(e),this.complete();continue e}T=[]}else if(221===A){const e=null!==(m=this.readU32FromBuffer())&&void 0!==m?m:yield this.readU32();if(0!==e){this.pushArrayState(e),this.complete();continue e}T=[]}else if(222===A){const e=null!==(b=this.readU16FromBuffer())&&void 0!==b?b:yield this.readU16();if(0!==e){this.pushMapState(e),this.complete();continue e}T={}}else if(223===A){const e=null!==(B=this.readU32FromBuffer())&&void 0!==B?B:yield this.readU32();if(0!==e){this.pushMapState(e),this.complete();continue e}T={}}else if(196===A){const e=null!==(x=this.readU8FromBuffer())&&void 0!==x?x:yield this.readU8();T=yield this.decodeBinary(e)}else if(197===A){const e=null!==(S=this.readU16FromBuffer())&&void 0!==S?S:yield this.readU16();T=yield this.decodeBinary(e)}else if(198===A){const e=null!==(I=this.readU32FromBuffer())&&void 0!==I?I:yield this.readU32();T=yield this.decodeBinary(e)}else if(212===A)T=yield this.decodeExtension(1);else if(213===A)T=yield this.decodeExtension(2);else if(214===A)T=yield this.decodeExtension(4);else if(215===A)T=yield this.decodeExtension(8);else if(216===A)T=yield this.decodeExtension(16);else if(199===A){const e=null!==(L=this.readU8FromBuffer())&&void 0!==L?L:yield this.readU8();T=yield this.decodeExtension(e)}else if(200===A){const e=null!==(E=this.readU16FromBuffer())&&void 0!==E?E:yield this.readU16();T=yield this.decodeExtension(e)}else{if(201!==A)throw new v(`Unrecognized type byte: ${O(A)}`);{const e=null!==(F=this.readU32FromBuffer())&&void 0!==F?F:yield this.readU32();T=yield this.decodeExtension(e)}}this.complete();const D=this.stack;for(;D.length>0;){const e=D[D.length-1];if(e.type===Q){if(e.array[e.position]=T,e.position++,e.position!==e.size)continue e;D.pop(),T=e.array}else{if(e.type===Y){if(!Z(T))throw new v("The type of key must be string or number but "+typeof T);if("__proto__"===T)throw new v("The key __proto__ is not allowed");e.key=T,e.type="map_value";continue e}if(e.map[e.key]=T,e.readCount++,e.readCount!==e.size){e.key=null,e.type=Y;continue e}D.pop(),T=e.map}}return T}}))}readHeadByteFromBuffer(){const e=this.readU8FromBuffer();return null===e?null:(-1===this.headByte&&(this.headByte=e),this.headByte)}readHeadByte(){return q(this,void 0,void 0,(function*(){return-1===this.headByte&&(this.headByte=yield this.readU8()),this.headByte}))}complete(){this.headByte=-1}pushMapState(e){if(e>this.maxMapLength)throw new v(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.push({type:Y,size:e,key:null,readCount:0,map:{}})}pushArrayState(e){if(e>this.maxArrayLength)throw new v(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.push({type:Q,size:e,array:new Array(e),position:0})}decodeUtf8StringFromBuffer(e){var t;if(e>this.maxStrLength)throw new v(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);const i=this.readBytesFromBuffer(e);if(null===i)return null;let r;return r=this.stateIsMapKey()&&(null===(t=this.keyDecoder)||void 0===t?void 0:t.canBeCached(e))?this.keyDecoder.decode(i,0,e):e>U?m(i,0,e):g(i,0,e),r}decodeUtf8String(e){var t;return q(this,void 0,void 0,(function*(){if(e>this.maxStrLength)throw new v(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);const i=yield this.readBytes(e);let r;return r=this.stateIsMapKey()&&(null===(t=this.keyDecoder)||void 0===t?void 0:t.canBeCached(e))?this.keyDecoder.decode(i,0,e):e>U?m(i,0,e):g(i,0,e),r}))}stateIsMapKey(){return this.stack.length>0&&this.stack[this.stack.length-1].type===Y}decodeBinary(e){return q(this,void 0,void 0,(function*(){if(e>this.maxBinLength)throw new v(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);return yield this.readBytes(e)}))}decodeExtension(e){return q(this,void 0,void 0,(function*(){if(e>this.maxExtLength)throw new v(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);const t=yield this.readI8(),i=yield this.decodeBinary(e);return this.extensionCodec.decode(i,t,this.context)}))}readU8(){return q(this,void 0,void 0,(function*(){const e=yield this.readBytes(1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}))}readI8(){return q(this,void 0,void 0,(function*(){const e=yield this.readBytes(1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}))}readU16(){return q(this,void 0,void 0,(function*(){const e=yield this.readBytes(2);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint16(0)}))}readI16(){return q(this,void 0,void 0,(function*(){const e=yield this.readBytes(2);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt16(0)}))}readU32(){return q(this,void 0,void 0,(function*(){const e=yield this.readBytes(4);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(0)}))}readI32(){return q(this,void 0,void 0,(function*(){const e=yield this.readBytes(4);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt32(0)}))}readU64(){return q(this,void 0,void 0,(function*(){const e=yield this.readBytes(8);return o(new DataView(e.buffer,e.byteOffset,e.byteLength),0)}))}readI64(){return q(this,void 0,void 0,(function*(){const e=yield this.readBytes(8);return s(new DataView(e.buffer,e.byteOffset,e.byteLength),0)}))}readF32(){return q(this,void 0,void 0,(function*(){const e=yield this.readBytes(4);return new DataView(e.buffer,e.byteOffset,e.byteLength).getFloat32(0)}))}readF64(){return q(this,void 0,void 0,(function*(){const e=yield this.readBytes(8);return new DataView(e.buffer,e.byteOffset,e.byteLength).getFloat64(0)}))}readU8FromBuffer(){const e=this.readBytesFromBuffer(1);return e?new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0):null}readI8FromBuffer(){const e=this.readBytesFromBuffer(1);return e?new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0):null}readU16FromBuffer(){const e=this.readBytesFromBuffer(2);return e?new DataView(e.buffer,e.byteOffset,e.byteLength).getUint16(0):null}readI16FromBuffer(){const e=this.readBytesFromBuffer(2);return e?new DataView(e.buffer,e.byteOffset,e.byteLength).getInt16(0):null}readU32FromBuffer(){const e=this.readBytesFromBuffer(4);return e?new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(0):null}readI32FromBuffer(){const e=this.readBytesFromBuffer(4);return e?new DataView(e.buffer,e.byteOffset,e.byteLength).getInt32(0):null}readU64FromBuffer(){const e=this.readBytesFromBuffer(8);return e?o(new DataView(e.buffer,e.byteOffset,e.byteLength),0):null}readI64FromBuffer(){const e=this.readBytesFromBuffer(8);return e?s(new DataView(e.buffer,e.byteOffset,e.byteLength),0):null}readF32FromBuffer(){const e=this.readBytesFromBuffer(4);return e?new DataView(e.buffer,e.byteOffset,e.byteLength).getFloat32(0):null}readF64FromBuffer(){const e=this.readBytesFromBuffer(8);return e?new DataView(e.buffer,e.byteOffset,e.byteLength).getFloat64(0):null}readBytesFromBuffer(e){if(this.buffer&&this.buffer.length>=e){const t=this.buffer.subarray(0,e);return this.buffer=this.buffer.subarray(e),t}return null}readBytes(e){var t,i;return q(this,void 0,void 0,(function*(){if(this.buffer&&e<=this.buffer.length){const t=this.buffer.subarray(0,e);return this.buffer=this.buffer.subarray(e),t}{const r=null!==(i=null===(t=this.buffer)||void 0===t?void 0:t.length)&&void 0!==i?i:0,n=e-r,s=new Uint8Array(e);if(this.buffer&&s.set(this.buffer,0),n<this.bufferSize){const e=yield this.readToBuffer(this.bufferSize);if(e.length<n)throw re;s.set(e.subarray(0,n),r),this.buffer=this.buffer.subarray(n)}else{const e=yield this.readToBuffer(n);if(e.length<n)throw re;s.set(e.subarray(0,n),r),this.buffer=this.buffer.subarray(n)}return s}}))}readToBuffer(e){return q(this,void 0,void 0,(function*(){const t=[];let i=0;for(;i<e;){const e=yield this.readStream.next(this.bufferSize);if(e.done)break;t.push(e.value),i+=e.value.length}if(1==t.length)return this.buffer=t[0],t[0];this.buffer=new Uint8Array(i);let r=0;for(const e of t)this.buffer.set(e,r),r+=e.length;return this.buffer}))}}const se={};function oe(e,t=se){return new G(t.extensionCodec,t.context,t.maxStrLength,t.maxBinLength,t.maxArrayLength,t.maxMapLength,t.maxExtLength).decode(e)}function he(e,t=se){return new G(t.extensionCodec,t.context,t.maxStrLength,t.maxBinLength,t.maxArrayLength,t.maxMapLength,t.maxExtLength).decodeMulti(e)}function ae(e,t=se){return new ne(e,t.extensionCodec,t.context,t.maxStrLength,t.maxBinLength,t.maxArrayLength,t.maxMapLength,t.maxExtLength).decode()}var fe=function(e){return this instanceof fe?(this.v=e,this):new fe(e)},de=function(e,t,i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,n=i.apply(e,t||[]),s=[];return r={},o("next"),o("throw"),o("return"),r[Symbol.asyncIterator]=function(){return this},r;function o(e){n[e]&&(r[e]=function(t){return new Promise((function(i,r){s.push([e,t,i,r])>1||h(e,t)}))})}function h(e,t){try{(i=n[e](t)).value instanceof fe?Promise.resolve(i.value.v).then(a,f):d(s[0][2],i)}catch(e){d(s[0][3],e)}var i}function a(e){h("next",e)}function f(e){h("throw",e)}function d(e,t){e(t),s.shift(),s.length&&h(s[0][0],s[0][1])}};function ce(e){if(null==e)throw new Error("Assertion Failure: value must not be null nor undefined")}function ue(e){return null!=e[Symbol.asyncIterator]?e:function(e){return de(this,arguments,(function*(){const t=e.getReader();try{for(;;){const{done:e,value:i}=yield fe(t.read());if(e)return yield fe(void 0);ce(i),yield yield fe(i)}}finally{t.releaseLock()}}))}(e)}function le(e,t=se){return i=this,r=void 0,s=function*(){const i=ue(e);return new G(t.extensionCodec,t.context,t.maxStrLength,t.maxBinLength,t.maxArrayLength,t.maxMapLength,t.maxExtLength).decodeAsync(i)},new((n=void 0)||(n=Promise))((function(e,t){function o(e){try{a(s.next(e))}catch(e){t(e)}}function h(e){try{a(s.throw(e))}catch(e){t(e)}}function a(t){var i;t.done?e(t.value):(i=t.value,i instanceof n?i:new n((function(e){e(i)}))).then(o,h)}a((s=s.apply(i,r||[])).next())}));var i,r,n,s}function ye(e,t=se){const i=ue(e);return new G(t.extensionCodec,t.context,t.maxStrLength,t.maxBinLength,t.maxArrayLength,t.maxMapLength,t.maxExtLength).decodeArrayStream(i)}function we(e,t=se){const i=ue(e);return new G(t.extensionCodec,t.context,t.maxStrLength,t.maxBinLength,t.maxArrayLength,t.maxMapLength,t.maxExtLength).decodeStream(i)}return t})()));
//# sourceMappingURL=msgpack.min.js.map