Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ipld/dag-json

Package Overview
Dependencies
Maintainers
9
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ipld/dag-json - npm Package Compare versions

Comparing version 9.1.1 to 10.0.0

2

dist/index.min.js
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.IpldDagJson = factory()}(typeof self !== 'undefined' ? self : this, function () {
"use strict";var IpldDagJson=(()=>{var Te=Object.defineProperty;var yr=Object.getOwnPropertyDescriptor;var gr=Object.getOwnPropertyNames;var wr=Object.prototype.hasOwnProperty;var xr=(t,e)=>{for(var r in e)Te(t,r,{get:e[r],enumerable:!0})},br=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of gr(e))!wr.call(t,o)&&o!==r&&Te(t,o,{get:()=>e[o],enumerable:!(n=yr(e,o))||n.enumerable});return t};var kr=t=>br(Te({},"__esModule",{value:!0}),t);var Dn={};xr(Dn,{code:()=>Cn,decode:()=>lr,encode:()=>pr,format:()=>Nn,name:()=>In,parse:()=>zn,stringify:()=>Nn});var Er=et,Ze=128,vr=127,Sr=~vr,Ur=Math.pow(2,31);function et(t,e,r){e=e||[],r=r||0;for(var n=r;t>=Ur;)e[r++]=t&255|Ze,t/=128;for(;t&Sr;)e[r++]=t&255|Ze,t>>>=7;return e[r]=t|0,et.bytes=r-n+1,e}var Ar=Be,Tr=128,Ye=127;function Be(t,n){var r=0,n=n||0,o=0,s=n,a,f=t.length;do{if(s>=f)throw Be.bytes=0,new RangeError("Could not decode varint");a=t[s++],r+=o<28?(a&Ye)<<o:(a&Ye)*Math.pow(2,o),o+=7}while(a>=Tr);return Be.bytes=s-n,r}var Br=Math.pow(2,7),$r=Math.pow(2,14),_r=Math.pow(2,21),Ir=Math.pow(2,28),Cr=Math.pow(2,35),Nr=Math.pow(2,42),Mr=Math.pow(2,49),zr=Math.pow(2,56),Or=Math.pow(2,63),Dr=function(t){return t<Br?1:t<$r?2:t<_r?3:t<Ir?4:t<Cr?5:t<Nr?6:t<Mr?7:t<zr?8:t<Or?9:10},Fr={encode:Er,decode:Ar,encodingLength:Dr},Vr=Fr,ne=Vr;var oe=(t,e=0)=>[ne.decode(t,e),ne.decode.bytes],G=(t,e,r=0)=>(ne.encode(t,e,r),e),J=t=>ne.encodingLength(t);var Pn=new Uint8Array(0);var tt=(t,e)=>{if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0},K=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")};var _e=(t,e)=>{let r=e.byteLength,n=J(t),o=n+J(r),s=new Uint8Array(o+r);return G(t,s,0),G(r,s,n),s.set(e,o),new X(t,r,e,s)},rt=t=>{let e=K(t),[r,n]=oe(e),[o,s]=oe(e.subarray(n)),a=e.subarray(n+s);if(a.byteLength!==o)throw new Error("Incorrect length");return new X(r,o,a,e)},nt=(t,e)=>{if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&tt(t.bytes,r.bytes)}},X=class{constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};function Pr(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<t.length;o++){var s=t.charAt(o),a=s.charCodeAt(0);if(r[a]!==255)throw new TypeError(s+" is ambiguous");r[a]=o}var f=t.length,h=t.charAt(0),g=Math.log(f)/Math.log(256),l=Math.log(256)/Math.log(f);function w(m){if(m instanceof Uint8Array||(ArrayBuffer.isView(m)?m=new Uint8Array(m.buffer,m.byteOffset,m.byteLength):Array.isArray(m)&&(m=Uint8Array.from(m))),!(m instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(m.length===0)return"";for(var E=0,q=0,_=0,M=m.length;_!==M&&m[_]===0;)_++,E++;for(var z=(M-_)*l+1>>>0,T=new Uint8Array(z);_!==M;){for(var O=m[_],P=0,I=z-1;(O!==0||P<q)&&I!==-1;I--,P++)O+=256*T[I]>>>0,T[I]=O%f>>>0,O=O/f>>>0;if(O!==0)throw new Error("Non-zero carry");q=P,_++}for(var D=z-q;D!==z&&T[D]===0;)D++;for(var me=h.repeat(E);D<z;++D)me+=t.charAt(T[D]);return me}function le(m){if(typeof m!="string")throw new TypeError("Expected String");if(m.length===0)return new Uint8Array;var E=0;if(m[E]!==" "){for(var q=0,_=0;m[E]===h;)q++,E++;for(var M=(m.length-E)*g+1>>>0,z=new Uint8Array(M);m[E];){var T=r[m.charCodeAt(E)];if(T===255)return;for(var O=0,P=M-1;(T!==0||O<_)&&P!==-1;P--,O++)T+=f*z[P]>>>0,z[P]=T%256>>>0,T=T/256>>>0;if(T!==0)throw new Error("Non-zero carry");_=O,E++}if(m[E]!==" "){for(var I=M-_;I!==M&&z[I]===0;)I++;for(var D=new Uint8Array(q+(M-I)),me=q;I!==M;)D[me++]=z[I++];return D}}}function mr(m){var E=le(m);if(E)return E;throw new Error(`Non-${e} character`)}return{encode:w,decodeUnsafe:le,decode:mr}}var Rr=Pr,Lr=Rr,ot=Lr;var Ce=class{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Ne=class{constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return it(this,e)}},Me=class{constructor(e){this.decoders=e}or(e){return it(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},it=(t,e)=>new Me({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),ze=class{constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Ce(e,r,n),this.decoder=new Ne(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},st=({name:t,prefix:e,encode:r,decode:n})=>new ze(t,e,r,n),Oe=({prefix:t,name:e,alphabet:r})=>{let{encode:n,decode:o}=ot(r,e);return st({prefix:t,name:e,encode:n,decode:s=>K(o(s))})},qr=(t,e,r,n)=>{let o={};for(let l=0;l<e.length;++l)o[e[l]]=l;let s=t.length;for(;t[s-1]==="=";)--s;let a=new Uint8Array(s*r/8|0),f=0,h=0,g=0;for(let l=0;l<s;++l){let w=o[t[l]];if(w===void 0)throw new SyntaxError(`Non-${n} character`);h=h<<r|w,f+=r,f>=8&&(f-=8,a[g++]=255&h>>f)}if(f>=r||255&h<<8-f)throw new SyntaxError("Unexpected end of data");return a},Wr=(t,e,r)=>{let n=e[e.length-1]==="=",o=(1<<r)-1,s="",a=0,f=0;for(let h=0;h<t.length;++h)for(f=f<<8|t[h],a+=8;a>r;)a-=r,s+=e[o&f>>a];if(a&&(s+=e[o&f<<r-a]),n)for(;s.length*r&7;)s+="=";return s},k=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>st({prefix:e,name:t,encode(o){return Wr(o,n,r)},decode(o){return qr(o,n,r,t)}});var F=Oe({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Kn=Oe({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ie=k({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Qn=k({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Zn=k({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Yn=k({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),eo=k({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),to=k({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ro=k({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),no=k({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),oo=k({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var at=(t,e)=>{let{bytes:r,version:n}=t;switch(n){case 0:return Jr(r,De(t),e||F.encoder);default:return Kr(r,De(t),e||ie.encoder)}};var ct=new WeakMap,De=t=>{let e=ct.get(t);if(e==null){let r=new Map;return ct.set(t,r),r}return e},y=class{constructor(e,r,n,o){this.code=r,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:r}=this;if(e!==se)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Xr)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return y.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:r}=this.multihash,n=_e(e,r);return y.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return y.equals(this,e)}static equals(e,r){let n=r;return n&&e.code===n.code&&e.version===n.version&&nt(e.multihash,n.multihash)}toString(e){return at(this,e)}toJSON(){return{"/":at(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof y)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:a}=r;return new y(n,o,s,a||ut(n,o,s.bytes))}else if(r[Hr]===!0){let{version:n,multihash:o,code:s}=r,a=rt(o);return y.create(n,s,a)}else return null}static create(e,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(r!==se)throw new Error(`Version 0 CID must use dag-pb (code: ${se}) block encoding`);return new y(e,r,n,n.bytes)}case 1:{let o=ut(e,r,n.bytes);return new y(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return y.create(0,se,e)}static createV1(e,r){return y.create(1,e,r)}static decode(e){let[r,n]=y.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=y.inspectBytes(e),n=r.size-r.multihashSize,o=K(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),a=new X(r.multihashCode,r.digestSize,s,o);return[r.version===0?y.createV0(a):y.createV1(r.codec,a),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[w,le]=oe(e.subarray(r));return r+=le,w},o=n(),s=se;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let a=r,f=n(),h=n(),g=r+h,l=g-a;return{version:o,codec:s,multihashCode:f,digestSize:h,multihashSize:l,size:g}}static parse(e,r){let[n,o]=Gr(e,r),s=y.decode(o);return De(s).set(n,e),s}},Gr=(t,e)=>{switch(t[0]){case"Q":{let r=e||F;return[F.prefix,r.decode(`${F.prefix}${t}`)]}case F.prefix:{let r=e||F;return[F.prefix,r.decode(t)]}case ie.prefix:{let r=e||ie;return[ie.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}},Jr=(t,e,r)=>{let{prefix:n}=r;if(n!==F.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let s=r.encode(t).slice(1);return e.set(n,s),s}else return o},Kr=(t,e,r)=>{let{prefix:n}=r,o=e.get(n);if(o==null){let s=r.encode(t);return e.set(n,s),s}else return o},se=112,Xr=18,ut=(t,e,r)=>{let n=J(t),o=n+J(e),s=new Uint8Array(o+r.byteLength);return G(t,s,0),G(e,s,n),s.set(r,o),s},Hr=Symbol.for("@ipld/js-cid/CID");var Fe=k({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),yo=k({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),go=k({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),wo=k({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Zr=["string","number","bigint","symbol"],Yr=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function ft(t){if(t===null)return"null";if(t===void 0)return"undefined";if(t===!0||t===!1)return"boolean";let e=typeof t;if(Zr.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(t))return"Array";if(en(t))return"Buffer";let r=tn(t);return r||"Object"}function en(t){return t&&t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer.call(null,t)}function tn(t){let e=Object.prototype.toString.call(t).slice(8,-1);if(Yr.includes(e))return e}var i=class{constructor(e,r,n){this.major=e,this.majorEncoded=e<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:this.major>e.major?1:0}};i.uint=new i(0,"uint",!0);i.negint=new i(1,"negint",!0);i.bytes=new i(2,"bytes",!0);i.string=new i(3,"string",!0);i.array=new i(4,"array",!1);i.map=new i(5,"map",!1);i.tag=new i(6,"tag",!1);i.float=new i(7,"float",!0);i.false=new i(7,"false",!0);i.true=new i(7,"true",!0);i.null=new i(7,"null",!0);i.undefined=new i(7,"undefined",!0);i.break=new i(7,"break",!0);var c=class{constructor(e,r,n){this.type=e,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var H=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",rn=new TextDecoder,nn=new TextEncoder;function ye(t){return H&&globalThis.Buffer.isBuffer(t)}function ae(t){return t instanceof Uint8Array?ye(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t:Uint8Array.from(t)}var lt=H?(t,e,r)=>r-e>64?globalThis.Buffer.from(t.subarray(e,r)).toString("utf8"):ht(t,e,r):(t,e,r)=>r-e>64?rn.decode(t.subarray(e,r)):ht(t,e,r),ge=H?t=>t.length>64?globalThis.Buffer.from(t):dt(t):t=>t.length>64?nn.encode(t):dt(t);var Q=H?(t,e,r)=>ye(t)?new Uint8Array(t.subarray(e,r)):t.slice(e,r):(t,e,r)=>t.slice(e,r),mt=H?(t,e)=>(t=t.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),ae(globalThis.Buffer.concat(t,e))):(t,e)=>{let r=new Uint8Array(e),n=0;for(let o of t)n+o.length>r.length&&(o=o.subarray(0,r.length-n)),r.set(o,n),n+=o.length;return r},yt=H?t=>globalThis.Buffer.allocUnsafe(t):t=>new Uint8Array(t);function gt(t,e){if(ye(t)&&ye(e))return t.compare(e);for(let r=0;r<t.length;r++)if(t[r]!==e[r])return t[r]<e[r]?-1:1;return 0}function dt(t,e=1/0){let r,n=t.length,o=null,s=[];for(let a=0;a<n;++a){if(r=t.charCodeAt(a),r>55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&s.push(239,191,189);continue}else if(a+1===n){(e-=3)>-1&&s.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&s.push(239,191,189),o=r;continue}r=(o-55296<<10|r-56320)+65536}else o&&(e-=3)>-1&&s.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;s.push(r)}else if(r<2048){if((e-=2)<0)break;s.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;s.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return s}function ht(t,e,r){let n=[];for(;e<r;){let o=t[e],s=null,a=o>239?4:o>223?3:o>191?2:1;if(e+a<=r){let f,h,g,l;switch(a){case 1:o<128&&(s=o);break;case 2:f=t[e+1],(f&192)===128&&(l=(o&31)<<6|f&63,l>127&&(s=l));break;case 3:f=t[e+1],h=t[e+2],(f&192)===128&&(h&192)===128&&(l=(o&15)<<12|(f&63)<<6|h&63,l>2047&&(l<55296||l>57343)&&(s=l));break;case 4:f=t[e+1],h=t[e+2],g=t[e+3],(f&192)===128&&(h&192)===128&&(g&192)===128&&(l=(o&15)<<18|(f&63)<<12|(h&63)<<6|g&63,l>65535&&l<1114112&&(s=l))}}s===null?(s=65533,a=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),e+=a}return Ve(n)}var pt=4096;function Ve(t){let e=t.length;if(e<=pt)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=pt));return r}var on=256,ce=class{constructor(e=on){this.chunkSize=e,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(e){let r=this.chunks[this.chunks.length-1];if(this.cursor+e.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(e,o)}else{if(r){let o=r.length-(this.maxCursor-this.cursor)-1;o<r.length&&(this.chunks[this.chunks.length-1]=r.subarray(0,o),this.maxCursor=this.cursor-1)}e.length<64&&e.length<this.chunkSize?(r=yt(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(e,0)):(this.chunks.push(e),this.maxCursor+=e.length)}this.cursor+=e.length}toBytes(e=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];e&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=Q(n,0,this.cursor)}else r=mt(this.chunks,this.cursor);return e&&this.reset(),r}};var d="CBOR decode error:",V="CBOR encode error:",ue=[];ue[23]=1;ue[24]=2;ue[25]=3;ue[26]=5;ue[27]=9;function j(t,e,r){if(t.length-e<r)throw new Error(`${d} not enough data for type`)}var x=[24,256,65536,4294967296,BigInt("18446744073709551616")];function v(t,e,r){j(t,e,1);let n=t[e];if(r.strict===!0&&n<x[0])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);return n}function S(t,e,r){j(t,e,2);let n=t[e]<<8|t[e+1];if(r.strict===!0&&n<x[1])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);return n}function U(t,e,r){j(t,e,4);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3];if(r.strict===!0&&n<x[2])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);return n}function A(t,e,r){j(t,e,8);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3],o=t[e+4]*16777216+(t[e+5]<<16)+(t[e+6]<<8)+t[e+7],s=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&s<x[3])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);if(s<=Number.MAX_SAFE_INTEGER)return Number(s);if(r.allowBigInt===!0)return s;throw new Error(`${d} integers outside of the safe integer range are not supported`)}function wt(t,e,r,n){return new c(i.uint,v(t,e+1,n),2)}function xt(t,e,r,n){return new c(i.uint,S(t,e+1,n),3)}function bt(t,e,r,n){return new c(i.uint,U(t,e+1,n),5)}function kt(t,e,r,n){return new c(i.uint,A(t,e+1,n),9)}function B(t,e){return b(t,0,e.value)}function b(t,e,r){if(r<x[0]){let n=Number(r);t.push([e|n])}else if(r<x[1]){let n=Number(r);t.push([e|24,n])}else if(r<x[2]){let n=Number(r);t.push([e|25,n>>>8,n&255])}else if(r<x[3]){let n=Number(r);t.push([e|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<x[4]){let o=[e|27,0,0,0,0,0,0,0],s=Number(n&BigInt(4294967295)),a=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=s&255,s=s>>8,o[7]=s&255,s=s>>8,o[6]=s&255,s=s>>8,o[5]=s&255,o[4]=a&255,a=a>>8,o[3]=a&255,a=a>>8,o[2]=a&255,a=a>>8,o[1]=a&255,t.push(o)}else throw new Error(`${d} encountered BigInt larger than allowable range`)}}B.encodedSize=function(e){return b.encodedSize(e.value)};b.encodedSize=function(e){return e<x[0]?1:e<x[1]?2:e<x[2]?3:e<x[3]?5:9};B.compareTokens=function(e,r){return e.value<r.value?-1:e.value>r.value?1:0};function Et(t,e,r,n){return new c(i.negint,-1-v(t,e+1,n),2)}function vt(t,e,r,n){return new c(i.negint,-1-S(t,e+1,n),3)}function St(t,e,r,n){return new c(i.negint,-1-U(t,e+1,n),5)}var je=BigInt(-1),Ut=BigInt(1);function At(t,e,r,n){let o=A(t,e+1,n);if(typeof o!="bigint"){let s=-1-o;if(s>=Number.MIN_SAFE_INTEGER)return new c(i.negint,s,9)}if(n.allowBigInt!==!0)throw new Error(`${d} integers outside of the safe integer range are not supported`);return new c(i.negint,je-BigInt(o),9)}function we(t,e){let r=e.value,n=typeof r=="bigint"?r*je-Ut:r*-1-1;b(t,e.type.majorEncoded,n)}we.encodedSize=function(e){let r=e.value,n=typeof r=="bigint"?r*je-Ut:r*-1-1;return n<x[0]?1:n<x[1]?2:n<x[2]?3:n<x[3]?5:9};we.compareTokens=function(e,r){return e.value<r.value?1:e.value>r.value?-1:0};function fe(t,e,r,n){j(t,e,r+n);let o=Q(t,e+r,e+r+n);return new c(i.bytes,o,r+n)}function Tt(t,e,r,n){return fe(t,e,1,r)}function Bt(t,e,r,n){return fe(t,e,2,v(t,e+1,n))}function $t(t,e,r,n){return fe(t,e,3,S(t,e+1,n))}function _t(t,e,r,n){return fe(t,e,5,U(t,e+1,n))}function It(t,e,r,n){let o=A(t,e+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer bytes lengths not supported`);return fe(t,e,9,o)}function xe(t){return t.encodedBytes===void 0&&(t.encodedBytes=t.type===i.string?ge(t.value):t.value),t.encodedBytes}function Z(t,e){let r=xe(e);b(t,e.type.majorEncoded,r.length),t.push(r)}Z.encodedSize=function(e){let r=xe(e);return b.encodedSize(r.length)+r.length};Z.compareTokens=function(e,r){return an(xe(e),xe(r))};function an(t,e){return t.length<e.length?-1:t.length>e.length?1:gt(t,e)}function de(t,e,r,n,o){let s=r+n;j(t,e,s);let a=new c(i.string,lt(t,e+r,e+s),s);return o.retainStringBytes===!0&&(a.byteValue=Q(t,e+r,e+s)),a}function Ct(t,e,r,n){return de(t,e,1,r,n)}function Nt(t,e,r,n){return de(t,e,2,v(t,e+1,n),n)}function Mt(t,e,r,n){return de(t,e,3,S(t,e+1,n),n)}function zt(t,e,r,n){return de(t,e,5,U(t,e+1,n),n)}function Ot(t,e,r,n){let o=A(t,e+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer string lengths not supported`);return de(t,e,9,o,n)}var Dt=Z;function Y(t,e,r,n){return new c(i.array,n,r)}function Ft(t,e,r,n){return Y(t,e,1,r)}function Vt(t,e,r,n){return Y(t,e,2,v(t,e+1,n))}function jt(t,e,r,n){return Y(t,e,3,S(t,e+1,n))}function Pt(t,e,r,n){return Y(t,e,5,U(t,e+1,n))}function Rt(t,e,r,n){let o=A(t,e+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer array lengths not supported`);return Y(t,e,9,o)}function Lt(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${d} indefinite length items not allowed`);return Y(t,e,1,1/0)}function be(t,e){b(t,i.array.majorEncoded,e.value)}be.compareTokens=B.compareTokens;be.encodedSize=function(e){return b.encodedSize(e.value)};function ee(t,e,r,n){return new c(i.map,n,r)}function qt(t,e,r,n){return ee(t,e,1,r)}function Wt(t,e,r,n){return ee(t,e,2,v(t,e+1,n))}function Gt(t,e,r,n){return ee(t,e,3,S(t,e+1,n))}function Jt(t,e,r,n){return ee(t,e,5,U(t,e+1,n))}function Kt(t,e,r,n){let o=A(t,e+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer map lengths not supported`);return ee(t,e,9,o)}function Xt(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${d} indefinite length items not allowed`);return ee(t,e,1,1/0)}function ke(t,e){b(t,i.map.majorEncoded,e.value)}ke.compareTokens=B.compareTokens;ke.encodedSize=function(e){return b.encodedSize(e.value)};function Ht(t,e,r,n){return new c(i.tag,r,1)}function Qt(t,e,r,n){return new c(i.tag,v(t,e+1,n),2)}function Zt(t,e,r,n){return new c(i.tag,S(t,e+1,n),3)}function Yt(t,e,r,n){return new c(i.tag,U(t,e+1,n),5)}function er(t,e,r,n){return new c(i.tag,A(t,e+1,n),9)}function Ee(t,e){b(t,i.tag.majorEncoded,e.value)}Ee.compareTokens=B.compareTokens;Ee.encodedSize=function(e){return b.encodedSize(e.value)};var pn=20,ln=21,mn=22,yn=23;function tr(t,e,r,n){if(n.allowUndefined===!1)throw new Error(`${d} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new c(i.null,null,1):new c(i.undefined,void 0,1)}function rr(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${d} indefinite length items not allowed`);return new c(i.break,void 0,1)}function Pe(t,e,r){if(r){if(r.allowNaN===!1&&Number.isNaN(t))throw new Error(`${d} NaN values are not supported`);if(r.allowInfinity===!1&&(t===1/0||t===-1/0))throw new Error(`${d} Infinity values are not supported`)}return new c(i.float,t,e)}function nr(t,e,r,n){return Pe(Re(t,e+1),3,n)}function or(t,e,r,n){return Pe(Le(t,e+1),5,n)}function ir(t,e,r,n){return Pe(ur(t,e+1),9,n)}function ve(t,e,r){let n=e.value;if(n===!1)t.push([i.float.majorEncoded|pn]);else if(n===!0)t.push([i.float.majorEncoded|ln]);else if(n===null)t.push([i.float.majorEncoded|mn]);else if(n===void 0)t.push([i.float.majorEncoded|yn]);else{let o,s=!1;(!r||r.float64!==!0)&&(ar(n),o=Re(C,1),n===o||Number.isNaN(n)?(C[0]=249,t.push(C.slice(0,3)),s=!0):(cr(n),o=Le(C,1),n===o&&(C[0]=250,t.push(C.slice(0,5)),s=!0))),s||(gn(n),o=ur(C,1),C[0]=251,t.push(C.slice(0,9)))}}ve.encodedSize=function(e,r){let n=e.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){ar(n);let o=Re(C,1);if(n===o||Number.isNaN(n))return 3;if(cr(n),o=Le(C,1),n===o)return 5}return 9};var sr=new ArrayBuffer(9),$=new DataView(sr,1),C=new Uint8Array(sr,0);function ar(t){if(t===1/0)$.setUint16(0,31744,!1);else if(t===-1/0)$.setUint16(0,64512,!1);else if(Number.isNaN(t))$.setUint16(0,32256,!1);else{$.setFloat32(0,t);let e=$.getUint32(0),r=(e&2139095040)>>23,n=e&8388607;if(r===255)$.setUint16(0,31744,!1);else if(r===0)$.setUint16(0,(t&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?$.setUint16(0,0):o<-14?$.setUint16(0,(e&2147483648)>>16|1<<24+o,!1):$.setUint16(0,(e&2147483648)>>16|o+15<<10|n>>13,!1)}}}function Re(t,e){if(t.length-e<2)throw new Error(`${d} not enough data for float16`);let r=(t[e]<<8)+t[e+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,o=r&1023,s;return n===0?s=o*2**-24:n!==31?s=(o+1024)*2**(n-25):s=o===0?1/0:NaN,r&32768?-s:s}function cr(t){$.setFloat32(0,t,!1)}function Le(t,e){if(t.length-e<4)throw new Error(`${d} not enough data for float32`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,4).getFloat32(0,!1)}function gn(t){$.setFloat64(0,t,!1)}function ur(t,e){if(t.length-e<8)throw new Error(`${d} not enough data for float64`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,8).getFloat64(0,!1)}ve.compareTokens=B.compareTokens;function p(t,e,r){throw new Error(`${d} encountered invalid minor (${r}) for major ${t[e]>>>5}`)}function Se(t){return()=>{throw new Error(`${d} ${t}`)}}var u=[];for(let t=0;t<=23;t++)u[t]=p;u[24]=wt;u[25]=xt;u[26]=bt;u[27]=kt;u[28]=p;u[29]=p;u[30]=p;u[31]=p;for(let t=32;t<=55;t++)u[t]=p;u[56]=Et;u[57]=vt;u[58]=St;u[59]=At;u[60]=p;u[61]=p;u[62]=p;u[63]=p;for(let t=64;t<=87;t++)u[t]=Tt;u[88]=Bt;u[89]=$t;u[90]=_t;u[91]=It;u[92]=p;u[93]=p;u[94]=p;u[95]=Se("indefinite length bytes/strings are not supported");for(let t=96;t<=119;t++)u[t]=Ct;u[120]=Nt;u[121]=Mt;u[122]=zt;u[123]=Ot;u[124]=p;u[125]=p;u[126]=p;u[127]=Se("indefinite length bytes/strings are not supported");for(let t=128;t<=151;t++)u[t]=Ft;u[152]=Vt;u[153]=jt;u[154]=Pt;u[155]=Rt;u[156]=p;u[157]=p;u[158]=p;u[159]=Lt;for(let t=160;t<=183;t++)u[t]=qt;u[184]=Wt;u[185]=Gt;u[186]=Jt;u[187]=Kt;u[188]=p;u[189]=p;u[190]=p;u[191]=Xt;for(let t=192;t<=215;t++)u[t]=Ht;u[216]=Qt;u[217]=Zt;u[218]=Yt;u[219]=er;u[220]=p;u[221]=p;u[222]=p;u[223]=p;for(let t=224;t<=243;t++)u[t]=Se("simple values are not supported");u[244]=p;u[245]=p;u[246]=p;u[247]=tr;u[248]=Se("simple values are not supported");u[249]=nr;u[250]=or;u[251]=ir;u[252]=p;u[253]=p;u[254]=p;u[255]=rr;var N=[];for(let t=0;t<24;t++)N[t]=new c(i.uint,t,1);for(let t=-1;t>=-24;t--)N[31-t]=new c(i.negint,t,1);N[64]=new c(i.bytes,new Uint8Array(0),1);N[96]=new c(i.string,"",1);N[128]=new c(i.array,0,1);N[160]=new c(i.map,0,1);N[244]=new c(i.false,!1,1);N[245]=new c(i.true,!0,1);N[246]=new c(i.null,null,1);function xn(){let t=[];return t[i.uint.major]=B,t[i.negint.major]=we,t[i.bytes.major]=Z,t[i.string.major]=Dt,t[i.array.major]=be,t[i.map.major]=ke,t[i.tag.major]=Ee,t[i.float.major]=ve,t}var di=xn(),qe=new ce,te=class{constructor(e,r){this.obj=e,this.parent=r}includes(e){let r=this;do if(r.obj===e)return!0;while(r=r.parent);return!1}static createCheck(e,r){if(e&&e.includes(r))throw new Error(`${V} object contains circular references`);return new te(r,e)}},R={null:new c(i.null,null),undefined:new c(i.undefined,void 0),true:new c(i.true,!0),false:new c(i.false,!1),emptyArray:new c(i.array,0),emptyMap:new c(i.map,0)},L={number(t,e,r,n){return!Number.isInteger(t)||!Number.isSafeInteger(t)?new c(i.float,t):t>=0?new c(i.uint,t):new c(i.negint,t)},bigint(t,e,r,n){return t>=BigInt(0)?new c(i.uint,t):new c(i.negint,t)},Uint8Array(t,e,r,n){return new c(i.bytes,t)},string(t,e,r,n){return new c(i.string,t)},boolean(t,e,r,n){return t?R.true:R.false},null(t,e,r,n){return R.null},undefined(t,e,r,n){return R.undefined},ArrayBuffer(t,e,r,n){return new c(i.bytes,new Uint8Array(t))},DataView(t,e,r,n){return new c(i.bytes,new Uint8Array(t.buffer,t.byteOffset,t.byteLength))},Array(t,e,r,n){if(!t.length)return r.addBreakTokens===!0?[R.emptyArray,new c(i.break)]:R.emptyArray;n=te.createCheck(n,t);let o=[],s=0;for(let a of t)o[s++]=Ue(a,r,n);return r.addBreakTokens?[new c(i.array,t.length),o,new c(i.break)]:[new c(i.array,t.length),o]},Object(t,e,r,n){let o=e!=="Object",s=o?t.keys():Object.keys(t),a=o?t.size:s.length;if(!a)return r.addBreakTokens===!0?[R.emptyMap,new c(i.break)]:R.emptyMap;n=te.createCheck(n,t);let f=[],h=0;for(let g of s)f[h++]=[Ue(g,r,n),Ue(o?t.get(g):t[g],r,n)];return bn(f,r),r.addBreakTokens?[new c(i.map,a),f,new c(i.break)]:[new c(i.map,a),f]}};L.Map=L.Object;L.Buffer=L.Uint8Array;for(let t of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))L[`${t}Array`]=L.DataView;function Ue(t,e={},r){let n=ft(t),o=e&&e.typeEncoders&&e.typeEncoders[n]||L[n];if(typeof o=="function"){let a=o(t,n,e,r);if(a!=null)return a}let s=L[n];if(!s)throw new Error(`${V} unsupported type: ${n}`);return s(t,n,e,r)}function bn(t,e){e.mapSorter&&t.sort(e.mapSorter)}function fr(t,e,r,n){if(Array.isArray(e))for(let o of e)fr(t,o,r,n);else r[e.type.major](t,e,n)}function dr(t,e,r){let n=Ue(t,r);if(!Array.isArray(n)&&r.quickEncodeToken){let o=r.quickEncodeToken(n);if(o)return o;let s=e[n.type.major];if(s.encodedSize){let a=s.encodedSize(n,r),f=new ce(a);if(s(f,n,r),f.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return ae(f.chunks[0])}}return qe.reset(),fr(qe,n,e,r),qe.toBytes(!0)}var kn={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},We=class{constructor(e,r={}){this.pos=0,this.data=e,this.options=r}done(){return this.pos>=this.data.length}next(){let e=this.data[this.pos],r=N[e];if(r===void 0){let n=u[e];if(!n)throw new Error(`${d} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);let o=e&31;r=n(this.data,this.pos,o,this.options)}return this.pos+=r.encodedLength,r}},he=Symbol.for("DONE"),Ae=Symbol.for("BREAK");function En(t,e,r){let n=[];for(let o=0;o<t.value;o++){let s=pe(e,r);if(s===Ae){if(t.value===1/0)break;throw new Error(`${d} got unexpected break to lengthed array`)}if(s===he)throw new Error(`${d} found array but not enough entries (got ${o}, expected ${t.value})`);n[o]=s}return n}function vn(t,e,r){let n=r.useMaps===!0,o=n?void 0:{},s=n?new Map:void 0;for(let a=0;a<t.value;a++){let f=pe(e,r);if(f===Ae){if(t.value===1/0)break;throw new Error(`${d} got unexpected break to lengthed map`)}if(f===he)throw new Error(`${d} found map but not enough entries (got ${a} [no key], expected ${t.value})`);if(n!==!0&&typeof f!="string")throw new Error(`${d} non-string keys not supported (got ${typeof f})`);let h=pe(e,r);if(h===he)throw new Error(`${d} found map but not enough entries (got ${a} [no value], expected ${t.value})`);n?s.set(f,h):o[f]=h}return n?s:o}function pe(t,e){if(t.done())return he;let r=t.next();if(r.type===i.break)return Ae;if(r.type.terminal)return r.value;if(r.type===i.array)return En(r,t,e);if(r.type===i.map)return vn(r,t,e);if(r.type===i.tag){if(e.tags&&typeof e.tags[r.value]=="function"){let n=pe(t,e);return e.tags[r.value](n)}throw new Error(`${d} tag not supported (${r.value})`)}throw new Error("unsupported")}function Ge(t,e){if(!(t instanceof Uint8Array))throw new Error(`${d} data to decode must be a Uint8Array`);e=Object.assign({},kn,e);let r=e.tokenizer||new We(t,e),n=pe(r,e);if(n===he)throw new Error(`${d} did not find any content to decode`);if(n===Ae)throw new Error(`${d} got unexpected break`);if(!r.done())throw new Error(`${d} too many terminals, data makes no sense`);return n}var Je=class extends Array{constructor(){super(),this.inRecursive=[]}prefix(e){let r=this.inRecursive[this.inRecursive.length-1];r&&(r.type===i.array&&(r.elements++,r.elements!==1&&e.push([44])),r.type===i.map&&(r.elements++,r.elements!==1&&(r.elements%2===1?e.push([44]):e.push([58]))))}[i.uint.major](e,r){this.prefix(e);let n=String(r.value),o=[];for(let s=0;s<n.length;s++)o[s]=n.charCodeAt(s);e.push(o)}[i.negint.major](e,r){this[i.uint.major](e,r)}[i.bytes.major](e,r){throw new Error(`${V} unsupported type: Uint8Array`)}[i.string.major](e,r){this.prefix(e);let n=ge(JSON.stringify(r.value));e.push(n.length>32?ae(n):n)}[i.array.major](e,r){this.prefix(e),this.inRecursive.push({type:i.array,elements:0}),e.push([91])}[i.map.major](e,r){this.prefix(e),this.inRecursive.push({type:i.map,elements:0}),e.push([123])}[i.tag.major](e,r){}[i.float.major](e,r){if(r.type.name==="break"){let a=this.inRecursive.pop();if(a){if(a.type===i.array)e.push([93]);else if(a.type===i.map)e.push([125]);else throw new Error("Unexpected recursive type; this should not happen!");return}throw new Error("Unexpected break; this should not happen!")}if(r.value===void 0)throw new Error(`${V} unsupported type: undefined`);if(this.prefix(e),r.type.name==="true"){e.push([116,114,117,101]);return}else if(r.type.name==="false"){e.push([102,97,108,115,101]);return}else if(r.type.name==="null"){e.push([110,117,108,108]);return}let n=String(r.value),o=[],s=!1;for(let a=0;a<n.length;a++)o[a]=n.charCodeAt(a),!s&&(o[a]===46||o[a]===101||o[a]===69)&&(s=!0);s||(o.push(46),o.push(48)),e.push(o)}};function Sn(t,e){if(Array.isArray(t[0])||Array.isArray(e[0]))throw new Error(`${V} complex map keys are not supported`);let r=t[0],n=e[0];if(r.type!==i.string||n.type!==i.string)throw new Error(`${V} non-string map keys are not supported`);if(r<n)return-1;if(r>n)return 1;throw new Error(`${V} unexpected duplicate map keys, this is not supported`)}var Un={addBreakTokens:!0,mapSorter:Sn};function Ke(t,e){return e=Object.assign({},Un,e),dr(t,new Je,e)}var re=class{constructor(e,r={}){this.pos=0,this.data=e,this.options=r,this.modeStack=["value"],this.lastToken=""}done(){return this.pos>=this.data.length}ch(){return this.data[this.pos]}currentMode(){return this.modeStack[this.modeStack.length-1]}skipWhitespace(){let e=this.ch();for(;e===32||e===9||e===13||e===10;)e=this.data[++this.pos]}expect(e){if(this.data.length-this.pos<e.length)throw new Error(`${d} unexpected end of input at position ${this.pos}`);for(let r=0;r<e.length;r++)if(this.data[this.pos++]!==e[r])throw new Error(`${d} unexpected token at position ${this.pos}, expected to find '${String.fromCharCode(...e)}'`)}parseNumber(){let e=this.pos,r=!1,n=!1,o=f=>{for(;!this.done();){let h=this.ch();if(f.includes(h))this.pos++;else break}};if(this.ch()===45&&(r=!0,this.pos++),this.ch()===48)if(this.pos++,this.ch()===46)this.pos++,n=!0;else return new c(i.uint,0,this.pos-e);if(o([48,49,50,51,52,53,54,55,56,57]),r&&this.pos===e+1)throw new Error(`${d} unexpected token at position ${this.pos}`);if(!this.done()&&this.ch()===46){if(n)throw new Error(`${d} unexpected token at position ${this.pos}`);n=!0,this.pos++,o([48,49,50,51,52,53,54,55,56,57])}!this.done()&&(this.ch()===101||this.ch()===69)&&(n=!0,this.pos++,!this.done()&&(this.ch()===43||this.ch()===45)&&this.pos++,o([48,49,50,51,52,53,54,55,56,57]));let s=String.fromCharCode.apply(null,this.data.subarray(e,this.pos)),a=parseFloat(s);return n?new c(i.float,a,this.pos-e):this.options.allowBigInt!==!0||Number.isSafeInteger(a)?new c(a>=0?i.uint:i.negint,a,this.pos-e):new c(a>=0?i.uint:i.negint,BigInt(s),this.pos-e)}parseString(){if(this.ch()!==34)throw new Error(`${d} unexpected character at position ${this.pos}; this shouldn't happen`);this.pos++;for(let s=this.pos,a=0;s<this.data.length&&a<65536;s++,a++){let f=this.data[s];if(f===92||f<32||f>=128)break;if(f===34){let h=String.fromCharCode.apply(null,this.data.subarray(this.pos,s));return this.pos=s+1,new c(i.string,h,a)}}let e=this.pos,r=[],n=()=>{if(this.pos+4>=this.data.length)throw new Error(`${d} unexpected end of unicode escape sequence at position ${this.pos}`);let s=0;for(let a=0;a<4;a++){let f=this.ch();if(f>=48&&f<=57)f-=48;else if(f>=97&&f<=102)f=f-97+10;else if(f>=65&&f<=70)f=f-65+10;else throw new Error(`${d} unexpected unicode escape character at position ${this.pos}`);s=s*16+f,this.pos++}return s},o=()=>{let s=this.ch(),a=null,f=s>239?4:s>223?3:s>191?2:1;if(this.pos+f>this.data.length)throw new Error(`${d} unexpected unicode sequence at position ${this.pos}`);let h,g,l,w;switch(f){case 1:s<128&&(a=s);break;case 2:h=this.data[this.pos+1],(h&192)===128&&(w=(s&31)<<6|h&63,w>127&&(a=w));break;case 3:h=this.data[this.pos+1],g=this.data[this.pos+2],(h&192)===128&&(g&192)===128&&(w=(s&15)<<12|(h&63)<<6|g&63,w>2047&&(w<55296||w>57343)&&(a=w));break;case 4:h=this.data[this.pos+1],g=this.data[this.pos+2],l=this.data[this.pos+3],(h&192)===128&&(g&192)===128&&(l&192)===128&&(w=(s&15)<<18|(h&63)<<12|(g&63)<<6|l&63,w>65535&&w<1114112&&(a=w))}a===null?(a=65533,f=1):a>65535&&(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023),r.push(a),this.pos+=f};for(;!this.done();){let s=this.ch(),a;switch(s){case 92:if(this.pos++,this.done())throw new Error(`${d} unexpected string termination at position ${this.pos}`);switch(a=this.ch(),this.pos++,a){case 34:case 39:case 92:case 47:r.push(a);break;case 98:r.push(8);break;case 116:r.push(9);break;case 110:r.push(10);break;case 102:r.push(12);break;case 114:r.push(13);break;case 117:r.push(n());break;default:throw new Error(`${d} unexpected string escape character at position ${this.pos}`)}break;case 34:return this.pos++,new c(i.string,Ve(r),this.pos-e);default:if(s<32)throw new Error(`${d} invalid control character at position ${this.pos}`);s<128?(r.push(s),this.pos++):o()}}throw new Error(`${d} unexpected end of string at position ${this.pos}`)}parseValue(){switch(this.ch()){case 123:return this.modeStack.push("obj-start"),this.pos++,new c(i.map,1/0,1);case 91:return this.modeStack.push("array-start"),this.pos++,new c(i.array,1/0,1);case 34:return this.parseString();case 110:return this.expect([110,117,108,108]),new c(i.null,null,4);case 102:return this.expect([102,97,108,115,101]),new c(i.false,!1,5);case 116:return this.expect([116,114,117,101]),new c(i.true,!0,4);case 45:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.parseNumber();default:throw new Error(`${d} unexpected character at position ${this.pos}`)}}next(){switch(this.skipWhitespace(),this.currentMode()){case"value":return this.modeStack.pop(),this.parseValue();case"array-value":{if(this.modeStack.pop(),this.ch()===93)return this.pos++,this.skipWhitespace(),new c(i.break,void 0,1);if(this.ch()!==44)throw new Error(`${d} unexpected character at position ${this.pos}, was expecting array delimiter but found '${String.fromCharCode(this.ch())}'`);return this.pos++,this.modeStack.push("array-value"),this.skipWhitespace(),this.parseValue()}case"array-start":return this.modeStack.pop(),this.ch()===93?(this.pos++,this.skipWhitespace(),new c(i.break,void 0,1)):(this.modeStack.push("array-value"),this.skipWhitespace(),this.parseValue());case"obj-key":if(this.ch()===125)return this.modeStack.pop(),this.pos++,this.skipWhitespace(),new c(i.break,void 0,1);if(this.ch()!==44)throw new Error(`${d} unexpected character at position ${this.pos}, was expecting object delimiter but found '${String.fromCharCode(this.ch())}'`);this.pos++,this.skipWhitespace();case"obj-start":{if(this.modeStack.pop(),this.ch()===125)return this.pos++,this.skipWhitespace(),new c(i.break,void 0,1);let e=this.parseString();if(this.skipWhitespace(),this.ch()!==58)throw new Error(`${d} unexpected character at position ${this.pos}, was expecting key/value delimiter ':' but found '${String.fromCharCode(this.ch())}'`);return this.pos++,this.modeStack.push("obj-value"),e}case"obj-value":return this.modeStack.pop(),this.modeStack.push("obj-key"),this.skipWhitespace(),this.parseValue();default:throw new Error(`${d} unexpected parse state at position ${this.pos}; this shouldn't happen`)}}};function Xe(t,e){return e=Object.assign({tokenizer:new re(t,e)},e),Ge(t,e)}function Tn(t){if(t.asCID!==t&&t["/"]!==t.bytes)return null;let e=y.asCID(t);if(!e)return null;let r=e.toString();return[new c(i.map,1/0,1),new c(i.string,"/",1),new c(i.string,r,r.length),new c(i.break,void 0,1)]}function hr(t){let e=Fe.encode(t).slice(1);return[new c(i.map,1/0,1),new c(i.string,"/",1),new c(i.map,1/0,1),new c(i.string,"bytes",5),new c(i.string,e,e.length),new c(i.break,void 0,1),new c(i.break,void 0,1)]}function Bn(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function $n(t){if(Number.isNaN(t))throw new Error("`NaN` is not supported by the IPLD Data Model and cannot be encoded");if(t===1/0||t===-1/0)throw new Error("`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded");return null}var _n={typeEncoders:{Object:Tn,Uint8Array:hr,Buffer:hr,undefined:Bn,number:$n}},He=class extends re{constructor(e,r){super(e,r),this.tokenBuffer=[]}done(){return this.tokenBuffer.length===0&&super.done()}_next(){return this.tokenBuffer.length>0?this.tokenBuffer.pop():super.next()}next(){let e=this._next();if(e.type===i.map){let r=this._next();if(r.type===i.string&&r.value==="/"){let n=this._next();if(n.type===i.string){if(this._next().type!==i.break)throw new Error("Invalid encoded CID form");return this.tokenBuffer.push(n),new c(i.tag,42,0)}if(n.type===i.map){let o=this._next();if(o.type===i.string&&o.value==="bytes"){let s=this._next();if(s.type===i.string){for(let f=0;f<2;f++)if(this._next().type!==i.break)throw new Error("Invalid encoded Bytes form");let a=Fe.decode(`m${s.value}`);return new c(i.bytes,a,s.value.length)}this.tokenBuffer.push(s)}this.tokenBuffer.push(o)}this.tokenBuffer.push(n)}this.tokenBuffer.push(r)}return e}},Qe={allowIndefinite:!1,allowUndefined:!1,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,tags:[]};Qe.tags[42]=y.parse;var In="dag-json",Cn=297,pr=t=>Ke(t,_n),lr=t=>{let e=Object.assign(Qe,{tokenizer:new He(t,Qe)});return Xe(t,e)},Nn=t=>Mn.decode(pr(t));var Mn=new TextDecoder,zn=t=>lr(On.encode(t)),On=new TextEncoder;return kr(Dn);})();
"use strict";var IpldDagJson=(()=>{var Te=Object.defineProperty;var yr=Object.getOwnPropertyDescriptor;var gr=Object.getOwnPropertyNames;var wr=Object.prototype.hasOwnProperty;var xr=(t,e)=>{for(var r in e)Te(t,r,{get:e[r],enumerable:!0})},br=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of gr(e))!wr.call(t,o)&&o!==r&&Te(t,o,{get:()=>e[o],enumerable:!(n=yr(e,o))||n.enumerable});return t};var kr=t=>br(Te({},"__esModule",{value:!0}),t);var Dn={};xr(Dn,{code:()=>Cn,decode:()=>lr,encode:()=>pr,format:()=>Nn,name:()=>In,parse:()=>zn,stringify:()=>Nn});var Er=et,Ze=128,vr=127,Sr=~vr,Ur=Math.pow(2,31);function et(t,e,r){e=e||[],r=r||0;for(var n=r;t>=Ur;)e[r++]=t&255|Ze,t/=128;for(;t&Sr;)e[r++]=t&255|Ze,t>>>=7;return e[r]=t|0,et.bytes=r-n+1,e}var Ar=Be,Tr=128,Ye=127;function Be(t,n){var r=0,n=n||0,o=0,s=n,a,u=t.length;do{if(s>=u)throw Be.bytes=0,new RangeError("Could not decode varint");a=t[s++],r+=o<28?(a&Ye)<<o:(a&Ye)*Math.pow(2,o),o+=7}while(a>=Tr);return Be.bytes=s-n,r}var Br=Math.pow(2,7),$r=Math.pow(2,14),_r=Math.pow(2,21),Ir=Math.pow(2,28),Cr=Math.pow(2,35),Nr=Math.pow(2,42),Mr=Math.pow(2,49),zr=Math.pow(2,56),Or=Math.pow(2,63),Dr=function(t){return t<Br?1:t<$r?2:t<_r?3:t<Ir?4:t<Cr?5:t<Nr?6:t<Mr?7:t<zr?8:t<Or?9:10},Fr={encode:Er,decode:Ar,encodingLength:Dr},Vr=Fr,ne=Vr;var oe=(t,e=0)=>[ne.decode(t,e),ne.decode.bytes],G=(t,e,r=0)=>(ne.encode(t,e,r),e),J=t=>ne.encodingLength(t);var Pn=new Uint8Array(0);var tt=(t,e)=>{if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0},K=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")};var _e=(t,e)=>{let r=e.byteLength,n=J(t),o=n+J(r),s=new Uint8Array(o+r);return G(t,s,0),G(r,s,n),s.set(e,o),new X(t,r,e,s)},rt=t=>{let e=K(t),[r,n]=oe(e),[o,s]=oe(e.subarray(n)),a=e.subarray(n+s);if(a.byteLength!==o)throw new Error("Incorrect length");return new X(r,o,a,e)},nt=(t,e)=>{if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&tt(t.bytes,r.bytes)}},X=class{constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};function Pr(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<t.length;o++){var s=t.charAt(o),a=s.charCodeAt(0);if(r[a]!==255)throw new TypeError(s+" is ambiguous");r[a]=o}var u=t.length,h=t.charAt(0),g=Math.log(u)/Math.log(256),l=Math.log(256)/Math.log(u);function w(m){if(m instanceof Uint8Array||(ArrayBuffer.isView(m)?m=new Uint8Array(m.buffer,m.byteOffset,m.byteLength):Array.isArray(m)&&(m=Uint8Array.from(m))),!(m instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(m.length===0)return"";for(var E=0,q=0,_=0,M=m.length;_!==M&&m[_]===0;)_++,E++;for(var z=(M-_)*l+1>>>0,T=new Uint8Array(z);_!==M;){for(var O=m[_],P=0,I=z-1;(O!==0||P<q)&&I!==-1;I--,P++)O+=256*T[I]>>>0,T[I]=O%u>>>0,O=O/u>>>0;if(O!==0)throw new Error("Non-zero carry");q=P,_++}for(var D=z-q;D!==z&&T[D]===0;)D++;for(var me=h.repeat(E);D<z;++D)me+=t.charAt(T[D]);return me}function le(m){if(typeof m!="string")throw new TypeError("Expected String");if(m.length===0)return new Uint8Array;var E=0;if(m[E]!==" "){for(var q=0,_=0;m[E]===h;)q++,E++;for(var M=(m.length-E)*g+1>>>0,z=new Uint8Array(M);m[E];){var T=r[m.charCodeAt(E)];if(T===255)return;for(var O=0,P=M-1;(T!==0||O<_)&&P!==-1;P--,O++)T+=u*z[P]>>>0,z[P]=T%256>>>0,T=T/256>>>0;if(T!==0)throw new Error("Non-zero carry");_=O,E++}if(m[E]!==" "){for(var I=M-_;I!==M&&z[I]===0;)I++;for(var D=new Uint8Array(q+(M-I)),me=q;I!==M;)D[me++]=z[I++];return D}}}function mr(m){var E=le(m);if(E)return E;throw new Error(`Non-${e} character`)}return{encode:w,decodeUnsafe:le,decode:mr}}var Rr=Pr,Lr=Rr,ot=Lr;var Ce=class{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Ne=class{constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return it(this,e)}},Me=class{constructor(e){this.decoders=e}or(e){return it(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},it=(t,e)=>new Me({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),ze=class{constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Ce(e,r,n),this.decoder=new Ne(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},st=({name:t,prefix:e,encode:r,decode:n})=>new ze(t,e,r,n),Oe=({prefix:t,name:e,alphabet:r})=>{let{encode:n,decode:o}=ot(r,e);return st({prefix:t,name:e,encode:n,decode:s=>K(o(s))})},qr=(t,e,r,n)=>{let o={};for(let l=0;l<e.length;++l)o[e[l]]=l;let s=t.length;for(;t[s-1]==="=";)--s;let a=new Uint8Array(s*r/8|0),u=0,h=0,g=0;for(let l=0;l<s;++l){let w=o[t[l]];if(w===void 0)throw new SyntaxError(`Non-${n} character`);h=h<<r|w,u+=r,u>=8&&(u-=8,a[g++]=255&h>>u)}if(u>=r||255&h<<8-u)throw new SyntaxError("Unexpected end of data");return a},Wr=(t,e,r)=>{let n=e[e.length-1]==="=",o=(1<<r)-1,s="",a=0,u=0;for(let h=0;h<t.length;++h)for(u=u<<8|t[h],a+=8;a>r;)a-=r,s+=e[o&u>>a];if(a&&(s+=e[o&u<<r-a]),n)for(;s.length*r&7;)s+="=";return s},k=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>st({prefix:e,name:t,encode(o){return Wr(o,n,r)},decode(o){return qr(o,n,r,t)}});var F=Oe({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Kn=Oe({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ie=k({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Qn=k({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Zn=k({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Yn=k({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),eo=k({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),to=k({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ro=k({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),no=k({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),oo=k({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var at=(t,e)=>{let{bytes:r,version:n}=t;switch(n){case 0:return Jr(r,De(t),e||F.encoder);default:return Kr(r,De(t),e||ie.encoder)}};var ct=new WeakMap,De=t=>{let e=ct.get(t);if(e==null){let r=new Map;return ct.set(t,r),r}return e},y=class{constructor(e,r,n,o){this.code=r,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:r}=this;if(e!==se)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Xr)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return y.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:r}=this.multihash,n=_e(e,r);return y.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return y.equals(this,e)}static equals(e,r){let n=r;return n&&e.code===n.code&&e.version===n.version&&nt(e.multihash,n.multihash)}toString(e){return at(this,e)}toJSON(){return{"/":at(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof y)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:a}=r;return new y(n,o,s,a||ut(n,o,s.bytes))}else if(r[Hr]===!0){let{version:n,multihash:o,code:s}=r,a=rt(o);return y.create(n,s,a)}else return null}static create(e,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(r!==se)throw new Error(`Version 0 CID must use dag-pb (code: ${se}) block encoding`);return new y(e,r,n,n.bytes)}case 1:{let o=ut(e,r,n.bytes);return new y(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return y.create(0,se,e)}static createV1(e,r){return y.create(1,e,r)}static decode(e){let[r,n]=y.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=y.inspectBytes(e),n=r.size-r.multihashSize,o=K(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),a=new X(r.multihashCode,r.digestSize,s,o);return[r.version===0?y.createV0(a):y.createV1(r.codec,a),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[w,le]=oe(e.subarray(r));return r+=le,w},o=n(),s=se;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let a=r,u=n(),h=n(),g=r+h,l=g-a;return{version:o,codec:s,multihashCode:u,digestSize:h,multihashSize:l,size:g}}static parse(e,r){let[n,o]=Gr(e,r),s=y.decode(o);return De(s).set(n,e),s}},Gr=(t,e)=>{switch(t[0]){case"Q":{let r=e||F;return[F.prefix,r.decode(`${F.prefix}${t}`)]}case F.prefix:{let r=e||F;return[F.prefix,r.decode(t)]}case ie.prefix:{let r=e||ie;return[ie.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}},Jr=(t,e,r)=>{let{prefix:n}=r;if(n!==F.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let s=r.encode(t).slice(1);return e.set(n,s),s}else return o},Kr=(t,e,r)=>{let{prefix:n}=r,o=e.get(n);if(o==null){let s=r.encode(t);return e.set(n,s),s}else return o},se=112,Xr=18,ut=(t,e,r)=>{let n=J(t),o=n+J(e),s=new Uint8Array(o+r.byteLength);return G(t,s,0),G(e,s,n),s.set(r,o),s},Hr=Symbol.for("@ipld/js-cid/CID");var Fe=k({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),yo=k({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),go=k({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),wo=k({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Zr=["string","number","bigint","symbol"],Yr=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function ft(t){if(t===null)return"null";if(t===void 0)return"undefined";if(t===!0||t===!1)return"boolean";let e=typeof t;if(Zr.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(t))return"Array";if(en(t))return"Buffer";let r=tn(t);return r||"Object"}function en(t){return t&&t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer.call(null,t)}function tn(t){let e=Object.prototype.toString.call(t).slice(8,-1);if(Yr.includes(e))return e}var i=class{constructor(e,r,n){this.major=e,this.majorEncoded=e<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:this.major>e.major?1:0}};i.uint=new i(0,"uint",!0);i.negint=new i(1,"negint",!0);i.bytes=new i(2,"bytes",!0);i.string=new i(3,"string",!0);i.array=new i(4,"array",!1);i.map=new i(5,"map",!1);i.tag=new i(6,"tag",!1);i.float=new i(7,"float",!0);i.false=new i(7,"false",!0);i.true=new i(7,"true",!0);i.null=new i(7,"null",!0);i.undefined=new i(7,"undefined",!0);i.break=new i(7,"break",!0);var c=class{constructor(e,r,n){this.type=e,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var H=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",rn=new TextDecoder,nn=new TextEncoder;function ye(t){return H&&globalThis.Buffer.isBuffer(t)}function ae(t){return t instanceof Uint8Array?ye(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t:Uint8Array.from(t)}var lt=H?(t,e,r)=>r-e>64?globalThis.Buffer.from(t.subarray(e,r)).toString("utf8"):ht(t,e,r):(t,e,r)=>r-e>64?rn.decode(t.subarray(e,r)):ht(t,e,r),ge=H?t=>t.length>64?globalThis.Buffer.from(t):dt(t):t=>t.length>64?nn.encode(t):dt(t);var Q=H?(t,e,r)=>ye(t)?new Uint8Array(t.subarray(e,r)):t.slice(e,r):(t,e,r)=>t.slice(e,r),mt=H?(t,e)=>(t=t.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),ae(globalThis.Buffer.concat(t,e))):(t,e)=>{let r=new Uint8Array(e),n=0;for(let o of t)n+o.length>r.length&&(o=o.subarray(0,r.length-n)),r.set(o,n),n+=o.length;return r},yt=H?t=>globalThis.Buffer.allocUnsafe(t):t=>new Uint8Array(t);function gt(t,e){if(ye(t)&&ye(e))return t.compare(e);for(let r=0;r<t.length;r++)if(t[r]!==e[r])return t[r]<e[r]?-1:1;return 0}function dt(t,e=1/0){let r,n=t.length,o=null,s=[];for(let a=0;a<n;++a){if(r=t.charCodeAt(a),r>55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&s.push(239,191,189);continue}else if(a+1===n){(e-=3)>-1&&s.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&s.push(239,191,189),o=r;continue}r=(o-55296<<10|r-56320)+65536}else o&&(e-=3)>-1&&s.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;s.push(r)}else if(r<2048){if((e-=2)<0)break;s.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;s.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return s}function ht(t,e,r){let n=[];for(;e<r;){let o=t[e],s=null,a=o>239?4:o>223?3:o>191?2:1;if(e+a<=r){let u,h,g,l;switch(a){case 1:o<128&&(s=o);break;case 2:u=t[e+1],(u&192)===128&&(l=(o&31)<<6|u&63,l>127&&(s=l));break;case 3:u=t[e+1],h=t[e+2],(u&192)===128&&(h&192)===128&&(l=(o&15)<<12|(u&63)<<6|h&63,l>2047&&(l<55296||l>57343)&&(s=l));break;case 4:u=t[e+1],h=t[e+2],g=t[e+3],(u&192)===128&&(h&192)===128&&(g&192)===128&&(l=(o&15)<<18|(u&63)<<12|(h&63)<<6|g&63,l>65535&&l<1114112&&(s=l))}}s===null?(s=65533,a=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),e+=a}return Ve(n)}var pt=4096;function Ve(t){let e=t.length;if(e<=pt)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=pt));return r}var on=256,ce=class{constructor(e=on){this.chunkSize=e,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(e){let r=this.chunks[this.chunks.length-1];if(this.cursor+e.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(e,o)}else{if(r){let o=r.length-(this.maxCursor-this.cursor)-1;o<r.length&&(this.chunks[this.chunks.length-1]=r.subarray(0,o),this.maxCursor=this.cursor-1)}e.length<64&&e.length<this.chunkSize?(r=yt(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(e,0)):(this.chunks.push(e),this.maxCursor+=e.length)}this.cursor+=e.length}toBytes(e=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];e&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=Q(n,0,this.cursor)}else r=mt(this.chunks,this.cursor);return e&&this.reset(),r}};var d="CBOR decode error:",V="CBOR encode error:",ue=[];ue[23]=1;ue[24]=2;ue[25]=3;ue[26]=5;ue[27]=9;function j(t,e,r){if(t.length-e<r)throw new Error(`${d} not enough data for type`)}var x=[24,256,65536,4294967296,BigInt("18446744073709551616")];function v(t,e,r){j(t,e,1);let n=t[e];if(r.strict===!0&&n<x[0])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);return n}function S(t,e,r){j(t,e,2);let n=t[e]<<8|t[e+1];if(r.strict===!0&&n<x[1])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);return n}function U(t,e,r){j(t,e,4);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3];if(r.strict===!0&&n<x[2])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);return n}function A(t,e,r){j(t,e,8);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3],o=t[e+4]*16777216+(t[e+5]<<16)+(t[e+6]<<8)+t[e+7],s=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&s<x[3])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);if(s<=Number.MAX_SAFE_INTEGER)return Number(s);if(r.allowBigInt===!0)return s;throw new Error(`${d} integers outside of the safe integer range are not supported`)}function wt(t,e,r,n){return new c(i.uint,v(t,e+1,n),2)}function xt(t,e,r,n){return new c(i.uint,S(t,e+1,n),3)}function bt(t,e,r,n){return new c(i.uint,U(t,e+1,n),5)}function kt(t,e,r,n){return new c(i.uint,A(t,e+1,n),9)}function B(t,e){return b(t,0,e.value)}function b(t,e,r){if(r<x[0]){let n=Number(r);t.push([e|n])}else if(r<x[1]){let n=Number(r);t.push([e|24,n])}else if(r<x[2]){let n=Number(r);t.push([e|25,n>>>8,n&255])}else if(r<x[3]){let n=Number(r);t.push([e|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<x[4]){let o=[e|27,0,0,0,0,0,0,0],s=Number(n&BigInt(4294967295)),a=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=s&255,s=s>>8,o[7]=s&255,s=s>>8,o[6]=s&255,s=s>>8,o[5]=s&255,o[4]=a&255,a=a>>8,o[3]=a&255,a=a>>8,o[2]=a&255,a=a>>8,o[1]=a&255,t.push(o)}else throw new Error(`${d} encountered BigInt larger than allowable range`)}}B.encodedSize=function(e){return b.encodedSize(e.value)};b.encodedSize=function(e){return e<x[0]?1:e<x[1]?2:e<x[2]?3:e<x[3]?5:9};B.compareTokens=function(e,r){return e.value<r.value?-1:e.value>r.value?1:0};function Et(t,e,r,n){return new c(i.negint,-1-v(t,e+1,n),2)}function vt(t,e,r,n){return new c(i.negint,-1-S(t,e+1,n),3)}function St(t,e,r,n){return new c(i.negint,-1-U(t,e+1,n),5)}var je=BigInt(-1),Ut=BigInt(1);function At(t,e,r,n){let o=A(t,e+1,n);if(typeof o!="bigint"){let s=-1-o;if(s>=Number.MIN_SAFE_INTEGER)return new c(i.negint,s,9)}if(n.allowBigInt!==!0)throw new Error(`${d} integers outside of the safe integer range are not supported`);return new c(i.negint,je-BigInt(o),9)}function we(t,e){let r=e.value,n=typeof r=="bigint"?r*je-Ut:r*-1-1;b(t,e.type.majorEncoded,n)}we.encodedSize=function(e){let r=e.value,n=typeof r=="bigint"?r*je-Ut:r*-1-1;return n<x[0]?1:n<x[1]?2:n<x[2]?3:n<x[3]?5:9};we.compareTokens=function(e,r){return e.value<r.value?1:e.value>r.value?-1:0};function fe(t,e,r,n){j(t,e,r+n);let o=Q(t,e+r,e+r+n);return new c(i.bytes,o,r+n)}function Tt(t,e,r,n){return fe(t,e,1,r)}function Bt(t,e,r,n){return fe(t,e,2,v(t,e+1,n))}function $t(t,e,r,n){return fe(t,e,3,S(t,e+1,n))}function _t(t,e,r,n){return fe(t,e,5,U(t,e+1,n))}function It(t,e,r,n){let o=A(t,e+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer bytes lengths not supported`);return fe(t,e,9,o)}function xe(t){return t.encodedBytes===void 0&&(t.encodedBytes=t.type===i.string?ge(t.value):t.value),t.encodedBytes}function Z(t,e){let r=xe(e);b(t,e.type.majorEncoded,r.length),t.push(r)}Z.encodedSize=function(e){let r=xe(e);return b.encodedSize(r.length)+r.length};Z.compareTokens=function(e,r){return an(xe(e),xe(r))};function an(t,e){return t.length<e.length?-1:t.length>e.length?1:gt(t,e)}function de(t,e,r,n,o){let s=r+n;j(t,e,s);let a=new c(i.string,lt(t,e+r,e+s),s);return o.retainStringBytes===!0&&(a.byteValue=Q(t,e+r,e+s)),a}function Ct(t,e,r,n){return de(t,e,1,r,n)}function Nt(t,e,r,n){return de(t,e,2,v(t,e+1,n),n)}function Mt(t,e,r,n){return de(t,e,3,S(t,e+1,n),n)}function zt(t,e,r,n){return de(t,e,5,U(t,e+1,n),n)}function Ot(t,e,r,n){let o=A(t,e+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer string lengths not supported`);return de(t,e,9,o,n)}var Dt=Z;function Y(t,e,r,n){return new c(i.array,n,r)}function Ft(t,e,r,n){return Y(t,e,1,r)}function Vt(t,e,r,n){return Y(t,e,2,v(t,e+1,n))}function jt(t,e,r,n){return Y(t,e,3,S(t,e+1,n))}function Pt(t,e,r,n){return Y(t,e,5,U(t,e+1,n))}function Rt(t,e,r,n){let o=A(t,e+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer array lengths not supported`);return Y(t,e,9,o)}function Lt(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${d} indefinite length items not allowed`);return Y(t,e,1,1/0)}function be(t,e){b(t,i.array.majorEncoded,e.value)}be.compareTokens=B.compareTokens;be.encodedSize=function(e){return b.encodedSize(e.value)};function ee(t,e,r,n){return new c(i.map,n,r)}function qt(t,e,r,n){return ee(t,e,1,r)}function Wt(t,e,r,n){return ee(t,e,2,v(t,e+1,n))}function Gt(t,e,r,n){return ee(t,e,3,S(t,e+1,n))}function Jt(t,e,r,n){return ee(t,e,5,U(t,e+1,n))}function Kt(t,e,r,n){let o=A(t,e+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer map lengths not supported`);return ee(t,e,9,o)}function Xt(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${d} indefinite length items not allowed`);return ee(t,e,1,1/0)}function ke(t,e){b(t,i.map.majorEncoded,e.value)}ke.compareTokens=B.compareTokens;ke.encodedSize=function(e){return b.encodedSize(e.value)};function Ht(t,e,r,n){return new c(i.tag,r,1)}function Qt(t,e,r,n){return new c(i.tag,v(t,e+1,n),2)}function Zt(t,e,r,n){return new c(i.tag,S(t,e+1,n),3)}function Yt(t,e,r,n){return new c(i.tag,U(t,e+1,n),5)}function er(t,e,r,n){return new c(i.tag,A(t,e+1,n),9)}function Ee(t,e){b(t,i.tag.majorEncoded,e.value)}Ee.compareTokens=B.compareTokens;Ee.encodedSize=function(e){return b.encodedSize(e.value)};var pn=20,ln=21,mn=22,yn=23;function tr(t,e,r,n){if(n.allowUndefined===!1)throw new Error(`${d} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new c(i.null,null,1):new c(i.undefined,void 0,1)}function rr(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${d} indefinite length items not allowed`);return new c(i.break,void 0,1)}function Pe(t,e,r){if(r){if(r.allowNaN===!1&&Number.isNaN(t))throw new Error(`${d} NaN values are not supported`);if(r.allowInfinity===!1&&(t===1/0||t===-1/0))throw new Error(`${d} Infinity values are not supported`)}return new c(i.float,t,e)}function nr(t,e,r,n){return Pe(Re(t,e+1),3,n)}function or(t,e,r,n){return Pe(Le(t,e+1),5,n)}function ir(t,e,r,n){return Pe(ur(t,e+1),9,n)}function ve(t,e,r){let n=e.value;if(n===!1)t.push([i.float.majorEncoded|pn]);else if(n===!0)t.push([i.float.majorEncoded|ln]);else if(n===null)t.push([i.float.majorEncoded|mn]);else if(n===void 0)t.push([i.float.majorEncoded|yn]);else{let o,s=!1;(!r||r.float64!==!0)&&(ar(n),o=Re(C,1),n===o||Number.isNaN(n)?(C[0]=249,t.push(C.slice(0,3)),s=!0):(cr(n),o=Le(C,1),n===o&&(C[0]=250,t.push(C.slice(0,5)),s=!0))),s||(gn(n),o=ur(C,1),C[0]=251,t.push(C.slice(0,9)))}}ve.encodedSize=function(e,r){let n=e.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){ar(n);let o=Re(C,1);if(n===o||Number.isNaN(n))return 3;if(cr(n),o=Le(C,1),n===o)return 5}return 9};var sr=new ArrayBuffer(9),$=new DataView(sr,1),C=new Uint8Array(sr,0);function ar(t){if(t===1/0)$.setUint16(0,31744,!1);else if(t===-1/0)$.setUint16(0,64512,!1);else if(Number.isNaN(t))$.setUint16(0,32256,!1);else{$.setFloat32(0,t);let e=$.getUint32(0),r=(e&2139095040)>>23,n=e&8388607;if(r===255)$.setUint16(0,31744,!1);else if(r===0)$.setUint16(0,(t&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?$.setUint16(0,0):o<-14?$.setUint16(0,(e&2147483648)>>16|1<<24+o,!1):$.setUint16(0,(e&2147483648)>>16|o+15<<10|n>>13,!1)}}}function Re(t,e){if(t.length-e<2)throw new Error(`${d} not enough data for float16`);let r=(t[e]<<8)+t[e+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,o=r&1023,s;return n===0?s=o*2**-24:n!==31?s=(o+1024)*2**(n-25):s=o===0?1/0:NaN,r&32768?-s:s}function cr(t){$.setFloat32(0,t,!1)}function Le(t,e){if(t.length-e<4)throw new Error(`${d} not enough data for float32`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,4).getFloat32(0,!1)}function gn(t){$.setFloat64(0,t,!1)}function ur(t,e){if(t.length-e<8)throw new Error(`${d} not enough data for float64`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,8).getFloat64(0,!1)}ve.compareTokens=B.compareTokens;function p(t,e,r){throw new Error(`${d} encountered invalid minor (${r}) for major ${t[e]>>>5}`)}function Se(t){return()=>{throw new Error(`${d} ${t}`)}}var f=[];for(let t=0;t<=23;t++)f[t]=p;f[24]=wt;f[25]=xt;f[26]=bt;f[27]=kt;f[28]=p;f[29]=p;f[30]=p;f[31]=p;for(let t=32;t<=55;t++)f[t]=p;f[56]=Et;f[57]=vt;f[58]=St;f[59]=At;f[60]=p;f[61]=p;f[62]=p;f[63]=p;for(let t=64;t<=87;t++)f[t]=Tt;f[88]=Bt;f[89]=$t;f[90]=_t;f[91]=It;f[92]=p;f[93]=p;f[94]=p;f[95]=Se("indefinite length bytes/strings are not supported");for(let t=96;t<=119;t++)f[t]=Ct;f[120]=Nt;f[121]=Mt;f[122]=zt;f[123]=Ot;f[124]=p;f[125]=p;f[126]=p;f[127]=Se("indefinite length bytes/strings are not supported");for(let t=128;t<=151;t++)f[t]=Ft;f[152]=Vt;f[153]=jt;f[154]=Pt;f[155]=Rt;f[156]=p;f[157]=p;f[158]=p;f[159]=Lt;for(let t=160;t<=183;t++)f[t]=qt;f[184]=Wt;f[185]=Gt;f[186]=Jt;f[187]=Kt;f[188]=p;f[189]=p;f[190]=p;f[191]=Xt;for(let t=192;t<=215;t++)f[t]=Ht;f[216]=Qt;f[217]=Zt;f[218]=Yt;f[219]=er;f[220]=p;f[221]=p;f[222]=p;f[223]=p;for(let t=224;t<=243;t++)f[t]=Se("simple values are not supported");f[244]=p;f[245]=p;f[246]=p;f[247]=tr;f[248]=Se("simple values are not supported");f[249]=nr;f[250]=or;f[251]=ir;f[252]=p;f[253]=p;f[254]=p;f[255]=rr;var N=[];for(let t=0;t<24;t++)N[t]=new c(i.uint,t,1);for(let t=-1;t>=-24;t--)N[31-t]=new c(i.negint,t,1);N[64]=new c(i.bytes,new Uint8Array(0),1);N[96]=new c(i.string,"",1);N[128]=new c(i.array,0,1);N[160]=new c(i.map,0,1);N[244]=new c(i.false,!1,1);N[245]=new c(i.true,!0,1);N[246]=new c(i.null,null,1);function xn(){let t=[];return t[i.uint.major]=B,t[i.negint.major]=we,t[i.bytes.major]=Z,t[i.string.major]=Dt,t[i.array.major]=be,t[i.map.major]=ke,t[i.tag.major]=Ee,t[i.float.major]=ve,t}var di=xn(),qe=new ce,te=class{constructor(e,r){this.obj=e,this.parent=r}includes(e){let r=this;do if(r.obj===e)return!0;while(r=r.parent);return!1}static createCheck(e,r){if(e&&e.includes(r))throw new Error(`${V} object contains circular references`);return new te(r,e)}},R={null:new c(i.null,null),undefined:new c(i.undefined,void 0),true:new c(i.true,!0),false:new c(i.false,!1),emptyArray:new c(i.array,0),emptyMap:new c(i.map,0)},L={number(t,e,r,n){return!Number.isInteger(t)||!Number.isSafeInteger(t)?new c(i.float,t):t>=0?new c(i.uint,t):new c(i.negint,t)},bigint(t,e,r,n){return t>=BigInt(0)?new c(i.uint,t):new c(i.negint,t)},Uint8Array(t,e,r,n){return new c(i.bytes,t)},string(t,e,r,n){return new c(i.string,t)},boolean(t,e,r,n){return t?R.true:R.false},null(t,e,r,n){return R.null},undefined(t,e,r,n){return R.undefined},ArrayBuffer(t,e,r,n){return new c(i.bytes,new Uint8Array(t))},DataView(t,e,r,n){return new c(i.bytes,new Uint8Array(t.buffer,t.byteOffset,t.byteLength))},Array(t,e,r,n){if(!t.length)return r.addBreakTokens===!0?[R.emptyArray,new c(i.break)]:R.emptyArray;n=te.createCheck(n,t);let o=[],s=0;for(let a of t)o[s++]=Ue(a,r,n);return r.addBreakTokens?[new c(i.array,t.length),o,new c(i.break)]:[new c(i.array,t.length),o]},Object(t,e,r,n){let o=e!=="Object",s=o?t.keys():Object.keys(t),a=o?t.size:s.length;if(!a)return r.addBreakTokens===!0?[R.emptyMap,new c(i.break)]:R.emptyMap;n=te.createCheck(n,t);let u=[],h=0;for(let g of s)u[h++]=[Ue(g,r,n),Ue(o?t.get(g):t[g],r,n)];return bn(u,r),r.addBreakTokens?[new c(i.map,a),u,new c(i.break)]:[new c(i.map,a),u]}};L.Map=L.Object;L.Buffer=L.Uint8Array;for(let t of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))L[`${t}Array`]=L.DataView;function Ue(t,e={},r){let n=ft(t),o=e&&e.typeEncoders&&e.typeEncoders[n]||L[n];if(typeof o=="function"){let a=o(t,n,e,r);if(a!=null)return a}let s=L[n];if(!s)throw new Error(`${V} unsupported type: ${n}`);return s(t,n,e,r)}function bn(t,e){e.mapSorter&&t.sort(e.mapSorter)}function fr(t,e,r,n){if(Array.isArray(e))for(let o of e)fr(t,o,r,n);else r[e.type.major](t,e,n)}function dr(t,e,r){let n=Ue(t,r);if(!Array.isArray(n)&&r.quickEncodeToken){let o=r.quickEncodeToken(n);if(o)return o;let s=e[n.type.major];if(s.encodedSize){let a=s.encodedSize(n,r),u=new ce(a);if(s(u,n,r),u.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return ae(u.chunks[0])}}return qe.reset(),fr(qe,n,e,r),qe.toBytes(!0)}var kn={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},We=class{constructor(e,r={}){this.pos=0,this.data=e,this.options=r}done(){return this.pos>=this.data.length}next(){let e=this.data[this.pos],r=N[e];if(r===void 0){let n=f[e];if(!n)throw new Error(`${d} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);let o=e&31;r=n(this.data,this.pos,o,this.options)}return this.pos+=r.encodedLength,r}},he=Symbol.for("DONE"),Ae=Symbol.for("BREAK");function En(t,e,r){let n=[];for(let o=0;o<t.value;o++){let s=pe(e,r);if(s===Ae){if(t.value===1/0)break;throw new Error(`${d} got unexpected break to lengthed array`)}if(s===he)throw new Error(`${d} found array but not enough entries (got ${o}, expected ${t.value})`);n[o]=s}return n}function vn(t,e,r){let n=r.useMaps===!0,o=n?void 0:{},s=n?new Map:void 0;for(let a=0;a<t.value;a++){let u=pe(e,r);if(u===Ae){if(t.value===1/0)break;throw new Error(`${d} got unexpected break to lengthed map`)}if(u===he)throw new Error(`${d} found map but not enough entries (got ${a} [no key], expected ${t.value})`);if(n!==!0&&typeof u!="string")throw new Error(`${d} non-string keys not supported (got ${typeof u})`);if(r.rejectDuplicateMapKeys===!0&&(n&&s.has(u)||!n&&u in o))throw new Error(`${d} found repeat map key "${u}"`);let h=pe(e,r);if(h===he)throw new Error(`${d} found map but not enough entries (got ${a} [no value], expected ${t.value})`);n?s.set(u,h):o[u]=h}return n?s:o}function pe(t,e){if(t.done())return he;let r=t.next();if(r.type===i.break)return Ae;if(r.type.terminal)return r.value;if(r.type===i.array)return En(r,t,e);if(r.type===i.map)return vn(r,t,e);if(r.type===i.tag){if(e.tags&&typeof e.tags[r.value]=="function"){let n=pe(t,e);return e.tags[r.value](n)}throw new Error(`${d} tag not supported (${r.value})`)}throw new Error("unsupported")}function Ge(t,e){if(!(t instanceof Uint8Array))throw new Error(`${d} data to decode must be a Uint8Array`);e=Object.assign({},kn,e);let r=e.tokenizer||new We(t,e),n=pe(r,e);if(n===he)throw new Error(`${d} did not find any content to decode`);if(n===Ae)throw new Error(`${d} got unexpected break`);if(!r.done())throw new Error(`${d} too many terminals, data makes no sense`);return n}var Je=class extends Array{constructor(){super(),this.inRecursive=[]}prefix(e){let r=this.inRecursive[this.inRecursive.length-1];r&&(r.type===i.array&&(r.elements++,r.elements!==1&&e.push([44])),r.type===i.map&&(r.elements++,r.elements!==1&&(r.elements%2===1?e.push([44]):e.push([58]))))}[i.uint.major](e,r){this.prefix(e);let n=String(r.value),o=[];for(let s=0;s<n.length;s++)o[s]=n.charCodeAt(s);e.push(o)}[i.negint.major](e,r){this[i.uint.major](e,r)}[i.bytes.major](e,r){throw new Error(`${V} unsupported type: Uint8Array`)}[i.string.major](e,r){this.prefix(e);let n=ge(JSON.stringify(r.value));e.push(n.length>32?ae(n):n)}[i.array.major](e,r){this.prefix(e),this.inRecursive.push({type:i.array,elements:0}),e.push([91])}[i.map.major](e,r){this.prefix(e),this.inRecursive.push({type:i.map,elements:0}),e.push([123])}[i.tag.major](e,r){}[i.float.major](e,r){if(r.type.name==="break"){let a=this.inRecursive.pop();if(a){if(a.type===i.array)e.push([93]);else if(a.type===i.map)e.push([125]);else throw new Error("Unexpected recursive type; this should not happen!");return}throw new Error("Unexpected break; this should not happen!")}if(r.value===void 0)throw new Error(`${V} unsupported type: undefined`);if(this.prefix(e),r.type.name==="true"){e.push([116,114,117,101]);return}else if(r.type.name==="false"){e.push([102,97,108,115,101]);return}else if(r.type.name==="null"){e.push([110,117,108,108]);return}let n=String(r.value),o=[],s=!1;for(let a=0;a<n.length;a++)o[a]=n.charCodeAt(a),!s&&(o[a]===46||o[a]===101||o[a]===69)&&(s=!0);s||(o.push(46),o.push(48)),e.push(o)}};function Sn(t,e){if(Array.isArray(t[0])||Array.isArray(e[0]))throw new Error(`${V} complex map keys are not supported`);let r=t[0],n=e[0];if(r.type!==i.string||n.type!==i.string)throw new Error(`${V} non-string map keys are not supported`);if(r<n)return-1;if(r>n)return 1;throw new Error(`${V} unexpected duplicate map keys, this is not supported`)}var Un={addBreakTokens:!0,mapSorter:Sn};function Ke(t,e){return e=Object.assign({},Un,e),dr(t,new Je,e)}var re=class{constructor(e,r={}){this.pos=0,this.data=e,this.options=r,this.modeStack=["value"],this.lastToken=""}done(){return this.pos>=this.data.length}ch(){return this.data[this.pos]}currentMode(){return this.modeStack[this.modeStack.length-1]}skipWhitespace(){let e=this.ch();for(;e===32||e===9||e===13||e===10;)e=this.data[++this.pos]}expect(e){if(this.data.length-this.pos<e.length)throw new Error(`${d} unexpected end of input at position ${this.pos}`);for(let r=0;r<e.length;r++)if(this.data[this.pos++]!==e[r])throw new Error(`${d} unexpected token at position ${this.pos}, expected to find '${String.fromCharCode(...e)}'`)}parseNumber(){let e=this.pos,r=!1,n=!1,o=u=>{for(;!this.done();){let h=this.ch();if(u.includes(h))this.pos++;else break}};if(this.ch()===45&&(r=!0,this.pos++),this.ch()===48)if(this.pos++,this.ch()===46)this.pos++,n=!0;else return new c(i.uint,0,this.pos-e);if(o([48,49,50,51,52,53,54,55,56,57]),r&&this.pos===e+1)throw new Error(`${d} unexpected token at position ${this.pos}`);if(!this.done()&&this.ch()===46){if(n)throw new Error(`${d} unexpected token at position ${this.pos}`);n=!0,this.pos++,o([48,49,50,51,52,53,54,55,56,57])}!this.done()&&(this.ch()===101||this.ch()===69)&&(n=!0,this.pos++,!this.done()&&(this.ch()===43||this.ch()===45)&&this.pos++,o([48,49,50,51,52,53,54,55,56,57]));let s=String.fromCharCode.apply(null,this.data.subarray(e,this.pos)),a=parseFloat(s);return n?new c(i.float,a,this.pos-e):this.options.allowBigInt!==!0||Number.isSafeInteger(a)?new c(a>=0?i.uint:i.negint,a,this.pos-e):new c(a>=0?i.uint:i.negint,BigInt(s),this.pos-e)}parseString(){if(this.ch()!==34)throw new Error(`${d} unexpected character at position ${this.pos}; this shouldn't happen`);this.pos++;for(let s=this.pos,a=0;s<this.data.length&&a<65536;s++,a++){let u=this.data[s];if(u===92||u<32||u>=128)break;if(u===34){let h=String.fromCharCode.apply(null,this.data.subarray(this.pos,s));return this.pos=s+1,new c(i.string,h,a)}}let e=this.pos,r=[],n=()=>{if(this.pos+4>=this.data.length)throw new Error(`${d} unexpected end of unicode escape sequence at position ${this.pos}`);let s=0;for(let a=0;a<4;a++){let u=this.ch();if(u>=48&&u<=57)u-=48;else if(u>=97&&u<=102)u=u-97+10;else if(u>=65&&u<=70)u=u-65+10;else throw new Error(`${d} unexpected unicode escape character at position ${this.pos}`);s=s*16+u,this.pos++}return s},o=()=>{let s=this.ch(),a=null,u=s>239?4:s>223?3:s>191?2:1;if(this.pos+u>this.data.length)throw new Error(`${d} unexpected unicode sequence at position ${this.pos}`);let h,g,l,w;switch(u){case 1:s<128&&(a=s);break;case 2:h=this.data[this.pos+1],(h&192)===128&&(w=(s&31)<<6|h&63,w>127&&(a=w));break;case 3:h=this.data[this.pos+1],g=this.data[this.pos+2],(h&192)===128&&(g&192)===128&&(w=(s&15)<<12|(h&63)<<6|g&63,w>2047&&(w<55296||w>57343)&&(a=w));break;case 4:h=this.data[this.pos+1],g=this.data[this.pos+2],l=this.data[this.pos+3],(h&192)===128&&(g&192)===128&&(l&192)===128&&(w=(s&15)<<18|(h&63)<<12|(g&63)<<6|l&63,w>65535&&w<1114112&&(a=w))}a===null?(a=65533,u=1):a>65535&&(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023),r.push(a),this.pos+=u};for(;!this.done();){let s=this.ch(),a;switch(s){case 92:if(this.pos++,this.done())throw new Error(`${d} unexpected string termination at position ${this.pos}`);switch(a=this.ch(),this.pos++,a){case 34:case 39:case 92:case 47:r.push(a);break;case 98:r.push(8);break;case 116:r.push(9);break;case 110:r.push(10);break;case 102:r.push(12);break;case 114:r.push(13);break;case 117:r.push(n());break;default:throw new Error(`${d} unexpected string escape character at position ${this.pos}`)}break;case 34:return this.pos++,new c(i.string,Ve(r),this.pos-e);default:if(s<32)throw new Error(`${d} invalid control character at position ${this.pos}`);s<128?(r.push(s),this.pos++):o()}}throw new Error(`${d} unexpected end of string at position ${this.pos}`)}parseValue(){switch(this.ch()){case 123:return this.modeStack.push("obj-start"),this.pos++,new c(i.map,1/0,1);case 91:return this.modeStack.push("array-start"),this.pos++,new c(i.array,1/0,1);case 34:return this.parseString();case 110:return this.expect([110,117,108,108]),new c(i.null,null,4);case 102:return this.expect([102,97,108,115,101]),new c(i.false,!1,5);case 116:return this.expect([116,114,117,101]),new c(i.true,!0,4);case 45:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.parseNumber();default:throw new Error(`${d} unexpected character at position ${this.pos}`)}}next(){switch(this.skipWhitespace(),this.currentMode()){case"value":return this.modeStack.pop(),this.parseValue();case"array-value":{if(this.modeStack.pop(),this.ch()===93)return this.pos++,this.skipWhitespace(),new c(i.break,void 0,1);if(this.ch()!==44)throw new Error(`${d} unexpected character at position ${this.pos}, was expecting array delimiter but found '${String.fromCharCode(this.ch())}'`);return this.pos++,this.modeStack.push("array-value"),this.skipWhitespace(),this.parseValue()}case"array-start":return this.modeStack.pop(),this.ch()===93?(this.pos++,this.skipWhitespace(),new c(i.break,void 0,1)):(this.modeStack.push("array-value"),this.skipWhitespace(),this.parseValue());case"obj-key":if(this.ch()===125)return this.modeStack.pop(),this.pos++,this.skipWhitespace(),new c(i.break,void 0,1);if(this.ch()!==44)throw new Error(`${d} unexpected character at position ${this.pos}, was expecting object delimiter but found '${String.fromCharCode(this.ch())}'`);this.pos++,this.skipWhitespace();case"obj-start":{if(this.modeStack.pop(),this.ch()===125)return this.pos++,this.skipWhitespace(),new c(i.break,void 0,1);let e=this.parseString();if(this.skipWhitespace(),this.ch()!==58)throw new Error(`${d} unexpected character at position ${this.pos}, was expecting key/value delimiter ':' but found '${String.fromCharCode(this.ch())}'`);return this.pos++,this.modeStack.push("obj-value"),e}case"obj-value":return this.modeStack.pop(),this.modeStack.push("obj-key"),this.skipWhitespace(),this.parseValue();default:throw new Error(`${d} unexpected parse state at position ${this.pos}; this shouldn't happen`)}}};function Xe(t,e){return e=Object.assign({tokenizer:new re(t,e)},e),Ge(t,e)}function Tn(t){if(t.asCID!==t&&t["/"]!==t.bytes)return null;let e=y.asCID(t);if(!e)return null;let r=e.toString();return[new c(i.map,1/0,1),new c(i.string,"/",1),new c(i.string,r,r.length),new c(i.break,void 0,1)]}function hr(t){let e=Fe.encode(t).slice(1);return[new c(i.map,1/0,1),new c(i.string,"/",1),new c(i.map,1/0,1),new c(i.string,"bytes",5),new c(i.string,e,e.length),new c(i.break,void 0,1),new c(i.break,void 0,1)]}function Bn(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function $n(t){if(Number.isNaN(t))throw new Error("`NaN` is not supported by the IPLD Data Model and cannot be encoded");if(t===1/0||t===-1/0)throw new Error("`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded");return null}var _n={typeEncoders:{Object:Tn,Uint8Array:hr,Buffer:hr,undefined:Bn,number:$n}},He=class extends re{constructor(e,r){super(e,r),this.tokenBuffer=[]}done(){return this.tokenBuffer.length===0&&super.done()}_next(){return this.tokenBuffer.length>0?this.tokenBuffer.pop():super.next()}next(){let e=this._next();if(e.type===i.map){let r=this._next();if(r.type===i.string&&r.value==="/"){let n=this._next();if(n.type===i.string){if(this._next().type!==i.break)throw new Error("Invalid encoded CID form");return this.tokenBuffer.push(n),new c(i.tag,42,0)}if(n.type===i.map){let o=this._next();if(o.type===i.string&&o.value==="bytes"){let s=this._next();if(s.type===i.string){for(let u=0;u<2;u++)if(this._next().type!==i.break)throw new Error("Invalid encoded Bytes form");let a=Fe.decode(`m${s.value}`);return new c(i.bytes,a,s.value.length)}this.tokenBuffer.push(s)}this.tokenBuffer.push(o)}this.tokenBuffer.push(n)}this.tokenBuffer.push(r)}return e}},Qe={allowIndefinite:!1,allowUndefined:!1,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:[]};Qe.tags[42]=y.parse;var In="dag-json",Cn=297,pr=t=>Ke(t,_n),lr=t=>{let e=Object.assign(Qe,{tokenizer:new He(t,Qe)});return Xe(t,e)},Nn=t=>Mn.decode(pr(t));var Mn=new TextDecoder,zn=t=>lr(On.encode(t)),On=new TextEncoder;return kr(Dn);})();
return IpldDagJson}));
{
"name": "@ipld/dag-json",
"version": "9.1.1",
"version": "10.0.0",
"description": "JS implementation of DAG-JSON",

@@ -164,3 +164,3 @@ "author": "Rod <rod@vagg.org> (http://r.va.gg/)",

"dependencies": {
"cborg": "^1.5.4",
"cborg": "^1.10.0",
"multiformats": "^11.0.0"

@@ -167,0 +167,0 @@ },

@@ -195,2 +195,3 @@ /* eslint max-depth: ["error", 7] */

useMaps: false,
rejectDuplicateMapKeys: true,
/** @type {import('cborg').TagDecoder[]} */

@@ -197,0 +198,0 @@ tags: []

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc