@helia/dag-cbor 5.1.1-eb1908b3 → 5.1.1-f6cc7640

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.min.js CHANGED
@@ -1,4 +1,4 @@
1
1
  (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.HeliaDagCbor = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- "use strict";var HeliaDagCbor=(()=>{var ze=Object.defineProperty;var Lr=Object.getOwnPropertyDescriptor;var zr=Object.getOwnPropertyNames;var Fr=Object.prototype.hasOwnProperty;var Rr=(e,t)=>{for(var r in t)ze(e,r,{get:t[r],enumerable:!0})},jr=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of zr(t))!Fr.call(e,o)&&o!==r&&ze(e,o,{get:()=>t[o],enumerable:!(n=Lr(t,o))||n.enumerable});return e};var Vr=e=>jr(ze({},"__esModule",{value:!0}),e);var ho={};Rr(ho,{dagCbor:()=>po});var yo=new Uint8Array(0);function ut(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function K(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}function Pr(e,t){if(e.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<e.length;o++){var s=e.charAt(o),c=s.charCodeAt(0);if(r[c]!==255)throw new TypeError(s+" is ambiguous");r[c]=o}var d=e.length,p=e.charAt(0),y=Math.log(d)/Math.log(256),B=Math.log(256)/Math.log(d);function J(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";for(var x=0,q=0,I=0,C=h.length;I!==C&&h[I]===0;)I++,x++;for(var N=(C-I)*B+1>>>0,v=new Uint8Array(N);I!==C;){for(var D=h[I],R=0,k=N-1;(D!==0||R<q)&&k!==-1;k--,R++)D+=256*v[k]>>>0,v[k]=D%d>>>0,D=D/d>>>0;if(D!==0)throw new Error("Non-zero carry");q=R,I++}for(var L=N-q;L!==N&&v[L]===0;)L++;for(var we=p.repeat(x);L<N;++L)we+=e.charAt(v[L]);return we}function xe(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var x=0;if(h[x]!==" "){for(var q=0,I=0;h[x]===p;)q++,x++;for(var C=(h.length-x)*y+1>>>0,N=new Uint8Array(C);h[x];){var v=r[h.charCodeAt(x)];if(v===255)return;for(var D=0,R=C-1;(v!==0||D<I)&&R!==-1;R--,D++)v+=d*N[R]>>>0,N[R]=v%256>>>0,v=v/256>>>0;if(v!==0)throw new Error("Non-zero carry");I=D,x++}if(h[x]!==" "){for(var k=C-I;k!==C&&N[k]===0;)k++;for(var L=new Uint8Array(q+(C-k)),we=q;k!==C;)L[we++]=N[k++];return L}}}function Or(h){var x=xe(h);if(x)return x;throw new Error(`Non-${t} character`)}return{encode:J,decodeUnsafe:xe,decode:Or}}var qr=Pr,Gr=qr,ft=Gr;var Fe=class{name;prefix;baseEncode;constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Re=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){this.name=t,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return dt(this,t)}},je=class{decoders;constructor(t){this.decoders=t}or(t){return dt(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function dt(e,t){return new je({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var Ve=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Fe(t,r,n),this.decoder=new Re(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function lt({name:e,prefix:t,encode:r,decode:n}){return new Ve(e,t,r,n)}function X({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=ft(r,e);return lt({prefix:t,name:e,encode:n,decode:s=>K(o(s))})}function Hr(e,t,r,n){let o=e.length;for(;e[o-1]==="=";)--o;let s=new Uint8Array(o*r/8|0),c=0,d=0,p=0;for(let y=0;y<o;++y){let B=t[e[y]];if(B===void 0)throw new SyntaxError(`Non-${n} character`);d=d<<r|B,c+=r,c>=8&&(c-=8,s[p++]=255&d>>c)}if(c>=r||(255&d<<8-c)!==0)throw new SyntaxError("Unexpected end of data");return s}function Jr(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,s="",c=0,d=0;for(let p=0;p<e.length;++p)for(d=d<<8|e[p],c+=8;c>r;)c-=r,s+=t[o&d>>c];if(c!==0&&(s+=t[o&d<<r-c]),n)for(;(s.length*r&7)!==0;)s+="=";return s}function Kr(e){let t={};for(let r=0;r<e.length;++r)t[e[r]]=r;return t}function $({name:e,prefix:t,bitsPerChar:r,alphabet:n}){let o=Kr(n);return lt({prefix:t,name:e,encode(s){return Jr(s,n,r)},decode(s){return Hr(s,o,r,e)}})}var ie=$({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),vo=$({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ao=$({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),To=$({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Io=$({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ko=$({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),So=$({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),_o=$({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Bo=$({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var be=X({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Do=X({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var z=X({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Oo=X({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Xr=mt,pt=128,Wr=127,Qr=~Wr,Yr=Math.pow(2,31);function mt(e,t,r){t=t||[],r=r||0;for(var n=r;e>=Yr;)t[r++]=e&255|pt,e/=128;for(;e&Qr;)t[r++]=e&255|pt,e>>>=7;return t[r]=e|0,mt.bytes=r-n+1,t}var Zr=Pe,en=128,ht=127;function Pe(e,n){var r=0,n=n||0,o=0,s=n,c,d=e.length;do{if(s>=d)throw Pe.bytes=0,new RangeError("Could not decode varint");c=e[s++],r+=o<28?(c&ht)<<o:(c&ht)*Math.pow(2,o),o+=7}while(c>=en);return Pe.bytes=s-n,r}var tn=Math.pow(2,7),rn=Math.pow(2,14),nn=Math.pow(2,21),on=Math.pow(2,28),sn=Math.pow(2,35),cn=Math.pow(2,42),an=Math.pow(2,49),un=Math.pow(2,56),fn=Math.pow(2,63),dn=function(e){return e<tn?1:e<rn?2:e<nn?3:e<on?4:e<sn?5:e<cn?6:e<an?7:e<un?8:e<fn?9:10},ln={encode:Xr,decode:Zr,encodingLength:dn},pn=ln,se=pn;function ce(e,t=0){return[se.decode(e,t),se.decode.bytes]}function W(e,t,r=0){return se.encode(e,t,r),t}function Q(e){return se.encodingLength(e)}function Ee(e,t){let r=t.byteLength,n=Q(e),o=n+Q(r),s=new Uint8Array(o+r);return W(e,s,0),W(r,s,n),s.set(t,o),new Y(e,r,t,s)}function gt(e){let t=K(e),[r,n]=ce(t),[o,s]=ce(t.subarray(n)),c=t.subarray(n+s);if(c.byteLength!==o)throw new Error("Incorrect length");return new Y(r,o,c,t)}function xt(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&ut(e.bytes,r.bytes)}}var Y=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function bt(e,t){let{bytes:r,version:n}=e;return n===0?mn(r,qe(e),t??z.encoder):yn(r,qe(e),t??ie.encoder)}var Et=new WeakMap;function qe(e){let t=Et.get(e);if(t==null){let r=new Map;return Et.set(e,r),r}return t}var G=class e{code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,this.version=t,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:t,multihash:r}=this;if(t!==ae)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==gn)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.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:t,digest:r}=this.multihash,n=Ee(t,r);return e.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(t){return e.equals(this,t)}static equals(t,r){let n=r;return n!=null&&t.code===n.code&&t.version===n.version&&xt(t.multihash,n.multihash)}toString(t){return bt(this,t)}toJSON(){return{"/":bt(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let r=t;if(r instanceof e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:c}=r;return new e(n,o,s,c??Ut(n,o,s.bytes))}else if(r[xn]===!0){let{version:n,multihash:o,code:s}=r,c=gt(o);return e.create(n,s,c)}else return null}static create(t,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(t){case 0:{if(r!==ae)throw new Error(`Version 0 CID must use dag-pb (code: ${ae}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=Ut(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,ae,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=K(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),c=new Y(r.multihashCode,r.digestSize,s,o);return[r.version===0?e.createV0(c):e.createV1(r.codec,c),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[J,xe]=ce(t.subarray(r));return r+=xe,J},o=n(),s=ae;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let c=r,d=n(),p=n(),y=r+p,B=y-c;return{version:o,codec:s,multihashCode:d,digestSize:p,multihashSize:B,size:y}}static parse(t,r){let[n,o]=hn(t,r),s=e.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return qe(s).set(n,t),s}};function hn(e,t){switch(e[0]){case"Q":{let r=t??z;return[z.prefix,r.decode(`${z.prefix}${e}`)]}case z.prefix:{let r=t??z;return[z.prefix,r.decode(e)]}case ie.prefix:{let r=t??ie;return[ie.prefix,r.decode(e)]}case be.prefix:{let r=t??be;return[be.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function mn(e,t,r){let{prefix:n}=r;if(n!==z.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let s=r.encode(e).slice(1);return t.set(n,s),s}else return o}function yn(e,t,r){let{prefix:n}=r,o=t.get(n);if(o==null){let s=r.encode(e);return t.set(n,s),s}else return o}var ae=112,gn=18;function Ut(e,t,r){let n=Q(e),o=n+Q(t),s=new Uint8Array(o+r.byteLength);return W(e,s,0),W(t,s,n),s.set(r,o),s}var xn=Symbol.for("@ipld/js-cid/CID");var Ue=class extends Error{static name="InvalidCodecError";constructor(t="Invalid codec"){super(t),this.name="InvalidCodecError"}};var wn=["Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array","Tagged"];function Ge(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(t==="string"||t==="number"||t==="bigint"||t==="symbol")return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(e instanceof Uint8Array)return"Uint8Array";if(e.constructor===Object)return"Object";let r=bn(e);return r||"Object"}function bn(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(wn.includes(t))return t}var i=class{constructor(t,r,n){this.major=t,this.majorEncoded=t<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(t){return this.major<t.major?-1:this.major>t.major?1:0}static equals(t,r){return t===r||t.major===r.major&&t.name===r.name}};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 u=class{constructor(t,r,n){this.type=t,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var ue=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",En=new TextEncoder;function ve(e){return ue&&globalThis.Buffer.isBuffer(e)}function fe(e){return e instanceof Uint8Array?ve(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var Un=24,vn=200,Ae=ue?e=>e.length>=Un?globalThis.Buffer.from(e):vt(e):e=>e.length>=vn?En.encode(e):vt(e),M=e=>Uint8Array.from(e),At=ue?(e,t,r)=>ve(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),Tt=ue?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),fe(globalThis.Buffer.concat(e,t))):(e,t)=>{let r=new Uint8Array(t),n=0;for(let o of e)n+o.length>r.length&&(o=o.subarray(0,r.length-n)),r.set(o,n),n+=o.length;return r},It=ue?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function Te(e,t){if(ve(e)&&ve(t))return e.compare(t);for(let r=0;r<e.length;r++)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return 0}function vt(e){let t=[],r=0;for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&n+1<e.length&&(e.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(e.charCodeAt(++n)&1023),t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(o>=55296&&o<=57343&&(o=65533),t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128)}return t}var An=256,de=class{constructor(t=An){this.chunkSize=t,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(t){let r=this.chunks[this.chunks.length-1];if(this.cursor+t.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(t,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)}t.length<64&&t.length<this.chunkSize?(r=It(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(t,0)):(this.chunks.push(t),this.maxCursor+=t.length)}this.cursor+=t.length}toBytes(t=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];t&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=At(n,0,this.cursor)}else r=Tt(this.chunks,this.cursor);return t&&this.reset(),r}},Ie=class{constructor(t){this.dest=t,this.cursor=0,this.chunks=[t]}reset(){this.cursor=0}push(t){if(this.cursor+t.length>this.dest.length)throw new Error("write out of bounds, destination buffer is too small");this.dest.set(t,this.cursor),this.cursor+=t.length}toBytes(t=!1){let r=this.dest.subarray(0,this.cursor);return t&&this.reset(),r}};var f="CBOR decode error:",ke="CBOR encode error:",le=[];le[23]=1;le[24]=2;le[25]=3;le[26]=5;le[27]=9;function F(e,t,r){if(e.length-t<r)throw new Error(`${f} not enough data for type`)}var g=[24,256,65536,4294967296,BigInt("18446744073709551616")];function w(e,t,r){F(e,t,1);let n=e[t];if(r.strict===!0&&n<g[0])throw new Error(`${f} integer encoded in more bytes than necessary (strict decode)`);return n}function b(e,t,r){F(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<g[1])throw new Error(`${f} integer encoded in more bytes than necessary (strict decode)`);return n}function E(e,t,r){F(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<g[2])throw new Error(`${f} integer encoded in more bytes than necessary (strict decode)`);return n}function U(e,t,r){F(e,t,8);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],o=e[t+4]*16777216+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],s=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&s<g[3])throw new Error(`${f} 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(`${f} integers outside of the safe integer range are not supported`)}function kt(e,t,r,n){return new u(i.uint,w(e,t+1,n),2)}function St(e,t,r,n){return new u(i.uint,b(e,t+1,n),3)}function _t(e,t,r,n){return new u(i.uint,E(e,t+1,n),5)}function Bt(e,t,r,n){return new u(i.uint,U(e,t+1,n),9)}function A(e,t){return m(e,0,t.value)}function m(e,t,r){if(r<g[0]){let n=Number(r);e.push([t|n])}else if(r<g[1]){let n=Number(r);e.push([t|24,n])}else if(r<g[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<g[3]){let n=Number(r);e.push([t|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<g[4]){let o=[t|27,0,0,0,0,0,0,0],s=Number(n&BigInt(4294967295)),c=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]=c&255,c=c>>8,o[3]=c&255,c=c>>8,o[2]=c&255,c=c>>8,o[1]=c&255,e.push(o)}else throw new Error(`${f} encountered BigInt larger than allowable range`)}}A.encodedSize=function(t){return m.encodedSize(t.value)};m.encodedSize=function(t){return t<g[0]?1:t<g[1]?2:t<g[2]?3:t<g[3]?5:9};A.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function Ct(e,t,r,n){return new u(i.negint,-1-w(e,t+1,n),2)}function Nt(e,t,r,n){return new u(i.negint,-1-b(e,t+1,n),3)}function Dt(e,t,r,n){return new u(i.negint,-1-E(e,t+1,n),5)}var He=BigInt(-1),$t=BigInt(1);function Mt(e,t,r,n){let o=U(e,t+1,n);if(typeof o!="bigint"){let s=-1-o;if(s>=Number.MIN_SAFE_INTEGER)return new u(i.negint,s,9)}if(n.allowBigInt!==!0)throw new Error(`${f} integers outside of the safe integer range are not supported`);return new u(i.negint,He-BigInt(o),9)}function Se(e,t){let r=t.value,n=typeof r=="bigint"?r*He-$t:r*-1-1;m(e,t.type.majorEncoded,n)}Se.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*He-$t:r*-1-1;return n<g[0]?1:n<g[1]?2:n<g[2]?3:n<g[3]?5:9};Se.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function pe(e,t,r,n){F(e,t,r+n);let o=e.slice(t+r,t+r+n);return new u(i.bytes,o,r+n)}function Ot(e,t,r,n){return pe(e,t,1,r)}function Lt(e,t,r,n){return pe(e,t,2,w(e,t+1,n))}function zt(e,t,r,n){return pe(e,t,3,b(e,t+1,n))}function Ft(e,t,r,n){return pe(e,t,5,E(e,t+1,n))}function Rt(e,t,r,n){let o=U(e,t+1,n);if(typeof o=="bigint")throw new Error(`${f} 64-bit integer bytes lengths not supported`);return pe(e,t,9,o)}function _e(e){return e.encodedBytes===void 0&&(e.encodedBytes=i.equals(e.type,i.string)?Ae(e.value):e.value),e.encodedBytes}function Z(e,t){let r=_e(t);m(e,t.type.majorEncoded,r.length),e.push(r)}Z.encodedSize=function(t){let r=_e(t);return m.encodedSize(r.length)+r.length};Z.compareTokens=function(t,r){return In(_e(t),_e(r))};function In(e,t){return e.length<t.length?-1:e.length>t.length?1:Te(e,t)}var jt=new TextDecoder,Sn=32;function _n(e,t,r){if(r-t<Sn){let o="";for(let s=t;s<r;s++){let c=e[s];if(c&128)return jt.decode(e.subarray(t,r));o+=String.fromCharCode(c)}return o}return jt.decode(e.subarray(t,r))}function he(e,t,r,n,o){let s=r+n;F(e,t,s);let c=new u(i.string,_n(e,t+r,t+s),s);return o.retainStringBytes===!0&&(c.byteValue=e.slice(t+r,t+s)),c}function Vt(e,t,r,n){return he(e,t,1,r,n)}function Pt(e,t,r,n){return he(e,t,2,w(e,t+1,n),n)}function qt(e,t,r,n){return he(e,t,3,b(e,t+1,n),n)}function Gt(e,t,r,n){return he(e,t,5,E(e,t+1,n),n)}function Ht(e,t,r,n){let o=U(e,t+1,n);if(typeof o=="bigint")throw new Error(`${f} 64-bit integer string lengths not supported`);return he(e,t,9,o,n)}var Jt=Z;function ee(e,t,r,n){return new u(i.array,n,r)}function Kt(e,t,r,n){return ee(e,t,1,r)}function Xt(e,t,r,n){return ee(e,t,2,w(e,t+1,n))}function Wt(e,t,r,n){return ee(e,t,3,b(e,t+1,n))}function Qt(e,t,r,n){return ee(e,t,5,E(e,t+1,n))}function Yt(e,t,r,n){let o=U(e,t+1,n);if(typeof o=="bigint")throw new Error(`${f} 64-bit integer array lengths not supported`);return ee(e,t,9,o)}function Zt(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${f} indefinite length items not allowed`);return ee(e,t,1,1/0)}function Be(e,t){m(e,i.array.majorEncoded,t.value)}Be.compareTokens=A.compareTokens;Be.encodedSize=function(t){return m.encodedSize(t.value)};function te(e,t,r,n){return new u(i.map,n,r)}function er(e,t,r,n){return te(e,t,1,r)}function tr(e,t,r,n){return te(e,t,2,w(e,t+1,n))}function rr(e,t,r,n){return te(e,t,3,b(e,t+1,n))}function nr(e,t,r,n){return te(e,t,5,E(e,t+1,n))}function or(e,t,r,n){let o=U(e,t+1,n);if(typeof o=="bigint")throw new Error(`${f} 64-bit integer map lengths not supported`);return te(e,t,9,o)}function ir(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${f} indefinite length items not allowed`);return te(e,t,1,1/0)}function Ce(e,t){m(e,i.map.majorEncoded,t.value)}Ce.compareTokens=A.compareTokens;Ce.encodedSize=function(t){return m.encodedSize(t.value)};function sr(e,t,r,n){return new u(i.tag,r,1)}function cr(e,t,r,n){return new u(i.tag,w(e,t+1,n),2)}function ar(e,t,r,n){return new u(i.tag,b(e,t+1,n),3)}function ur(e,t,r,n){return new u(i.tag,E(e,t+1,n),5)}function fr(e,t,r,n){return new u(i.tag,U(e,t+1,n),9)}function Ne(e,t){m(e,i.tag.majorEncoded,t.value)}Ne.compareTokens=A.compareTokens;Ne.encodedSize=function(t){return m.encodedSize(t.value)};var Je=20,Ke=21,Xe=22,We=23;function dr(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${f} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new u(i.null,null,1):new u(i.undefined,void 0,1)}function lr(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${f} indefinite length items not allowed`);return new u(i.break,void 0,1)}function Qe(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${f} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${f} Infinity values are not supported`)}return new u(i.float,e,t)}function pr(e,t,r,n){return Qe(Ye(e,t+1),3,n)}function hr(e,t,r,n){return Qe(Ze(e,t+1),5,n)}function mr(e,t,r,n){return Qe(wr(e,t+1),9,n)}function me(e,t,r){let n=t.value;if(n===!1)e.push([i.float.majorEncoded|Je]);else if(n===!0)e.push([i.float.majorEncoded|Ke]);else if(n===null)e.push([i.float.majorEncoded|Xe]);else if(n===void 0)e.push([i.float.majorEncoded|We]);else{let o,s=!1;(!r||r.float64!==!0)&&(gr(n),o=Ye(S,1),n===o||Number.isNaN(n)?(S[0]=249,e.push(S.slice(0,3)),s=!0):(xr(n),o=Ze(S,1),n===o&&(S[0]=250,e.push(S.slice(0,5)),s=!0))),s||($n(n),o=wr(S,1),S[0]=251,e.push(S.slice(0,9)))}}me.encodedSize=function(t,r){let n=t.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){gr(n);let o=Ye(S,1);if(n===o||Number.isNaN(n))return 3;if(xr(n),o=Ze(S,1),n===o)return 5}return 9};var yr=new ArrayBuffer(9),T=new DataView(yr,1),S=new Uint8Array(yr,0);function gr(e){if(e===1/0)T.setUint16(0,31744,!1);else if(e===-1/0)T.setUint16(0,64512,!1);else if(Number.isNaN(e))T.setUint16(0,32256,!1);else{T.setFloat32(0,e);let t=T.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)T.setUint16(0,31744,!1);else if(r===0)T.setUint16(0,(t&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?T.setUint16(0,0):o<-14?T.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):T.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function Ye(e,t){if(e.length-t<2)throw new Error(`${f} not enough data for float16`);let r=(e[t]<<8)+e[t+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 xr(e){T.setFloat32(0,e,!1)}function Ze(e,t){if(e.length-t<4)throw new Error(`${f} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function $n(e){T.setFloat64(0,e,!1)}function wr(e,t){if(e.length-t<8)throw new Error(`${f} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}me.compareTokens=A.compareTokens;function l(e,t,r){throw new Error(`${f} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function De(e){return()=>{throw new Error(`${f} ${e}`)}}var a=[];for(let e=0;e<=23;e++)a[e]=l;a[24]=kt;a[25]=St;a[26]=_t;a[27]=Bt;a[28]=l;a[29]=l;a[30]=l;a[31]=l;for(let e=32;e<=55;e++)a[e]=l;a[56]=Ct;a[57]=Nt;a[58]=Dt;a[59]=Mt;a[60]=l;a[61]=l;a[62]=l;a[63]=l;for(let e=64;e<=87;e++)a[e]=Ot;a[88]=Lt;a[89]=zt;a[90]=Ft;a[91]=Rt;a[92]=l;a[93]=l;a[94]=l;a[95]=De("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)a[e]=Vt;a[120]=Pt;a[121]=qt;a[122]=Gt;a[123]=Ht;a[124]=l;a[125]=l;a[126]=l;a[127]=De("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)a[e]=Kt;a[152]=Xt;a[153]=Wt;a[154]=Qt;a[155]=Yt;a[156]=l;a[157]=l;a[158]=l;a[159]=Zt;for(let e=160;e<=183;e++)a[e]=er;a[184]=tr;a[185]=rr;a[186]=nr;a[187]=or;a[188]=l;a[189]=l;a[190]=l;a[191]=ir;for(let e=192;e<=215;e++)a[e]=sr;a[216]=cr;a[217]=ar;a[218]=ur;a[219]=fr;a[220]=l;a[221]=l;a[222]=l;a[223]=l;for(let e=224;e<=243;e++)a[e]=De("simple values are not supported");a[244]=l;a[245]=l;a[246]=l;a[247]=dr;a[248]=De("simple values are not supported");a[249]=pr;a[250]=hr;a[251]=mr;a[252]=l;a[253]=l;a[254]=l;a[255]=lr;var _=[];for(let e=0;e<24;e++)_[e]=new u(i.uint,e,1);for(let e=-1;e>=-24;e--)_[31-e]=new u(i.negint,e,1);_[64]=new u(i.bytes,new Uint8Array(0),1);_[96]=new u(i.string,"",1);_[128]=new u(i.array,0,1);_[160]=new u(i.map,0,1);_[244]=new u(i.false,!1,1);_[245]=new u(i.true,!0,1);_[246]=new u(i.null,null,1);function et(e){switch(e.type){case i.false:return M([244]);case i.true:return M([245]);case i.null:return M([246]);case i.bytes:return e.value.length?void 0:M([64]);case i.string:return e.value===""?M([96]):void 0;case i.array:return e.value===0?M([128]):void 0;case i.map:return e.value===0?M([160]):void 0;case i.uint:return e.value<24?M([Number(e.value)]):void 0;case i.negint:if(e.value>=-24)return M([31-Number(e.value)])}}var On={float64:!1,mapSorter:Fn,quickEncodeToken:et},Ar=Object.freeze({float64:!0,mapSorter:Rn,quickEncodeToken:et});function Ln(){let e=[];return e[i.uint.major]=A,e[i.negint.major]=Se,e[i.bytes.major]=Z,e[i.string.major]=Jt,e[i.array.major]=Be,e[i.map.major]=Ce,e[i.tag.major]=Ne,e[i.float.major]=me,e}var ne=Ln(),$e=new de,ge=class e{constructor(t,r){this.obj=t,this.parent=r}includes(t){let r=this;do if(r.obj===t)return!0;while(r=r.parent);return!1}static createCheck(t,r){if(t&&t.includes(r))throw new Error(`${ke} object contains circular references`);return new e(r,t)}},j={null:new u(i.null,null),undefined:new u(i.undefined,void 0),true:new u(i.true,!0),false:new u(i.false,!1),emptyArray:new u(i.array,0),emptyMap:new u(i.map,0)},O={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new u(i.float,e):e>=0?new u(i.uint,e):new u(i.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new u(i.uint,e):new u(i.negint,e)},Uint8Array(e,t,r,n){return new u(i.bytes,e)},string(e,t,r,n){return new u(i.string,e)},boolean(e,t,r,n){return e?j.true:j.false},null(e,t,r,n){return j.null},undefined(e,t,r,n){return j.undefined},ArrayBuffer(e,t,r,n){return new u(i.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new u(i.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[j.emptyArray,new u(i.break)]:j.emptyArray;n=ge.createCheck(n,e);let o=[],s=0;for(let c of e)o[s++]=re(c,r,n);return r.addBreakTokens?[new u(i.array,e.length),o,new u(i.break)]:[new u(i.array,e.length),o]},Object(e,t,r,n){let o=t!=="Object",s=o?e.keys():Object.keys(e),c=o?e.size:s.length,d;if(c){d=new Array(c),n=ge.createCheck(n,e);let p=!o&&r.ignoreUndefinedProperties,y=0;for(let B of s){let J=o?e.get(B):e[B];p&&J===void 0||(d[y++]=[re(B,r,n),re(J,r,n)])}y<c&&(d.length=y)}return d?.length?(zn(d,r),r.addBreakTokens?[new u(i.map,d.length),d,new u(i.break)]:[new u(i.map,d.length),d]):r.addBreakTokens===!0?[j.emptyMap,new u(i.break)]:j.emptyMap},Tagged(e,t,r,n){return[new u(i.tag,e.tag),re(e.value,r,n)]}};O.Map=O.Object;O.Buffer=O.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))O[`${e}Array`]=O.DataView;function re(e,t={},r){let n=Ge(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||O[n];if(typeof o=="function"){let c=o(e,n,t,r);if(c!=null)return c}let s=O[n];if(!s)throw new Error(`${ke} unsupported type: ${n}`);return s(e,n,t,r)}function zn(e,t){t.mapSorter&&e.sort(t.mapSorter)}function Fn(e,t){let r=Array.isArray(e[0])?e[0][0]:e[0],n=Array.isArray(t[0])?t[0][0]:t[0];if(r.type!==n.type)return r.type.compare(n.type);let o=r.type.major,s=ne[o].compareTokens(r,n);return s===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),s}function Rn(e,t){if(e[0]instanceof u&&t[0]instanceof u){let r=e[0],n=t[0];return r._keyBytes||(r._keyBytes=br(r.value)),n._keyBytes||(n._keyBytes=br(n.value)),Te(r._keyBytes,n._keyBytes)}throw new Error("rfc8949MapSorter: complex key types are not supported yet")}function br(e){return Ir(e,ne,Ar)}function ye(e,t,r,n){if(Array.isArray(t))for(let o of t)ye(e,o,r,n);else r[t.type.major](e,t,n)}var Er=i.uint.majorEncoded,Ur=i.negint.majorEncoded,jn=i.bytes.majorEncoded,Vn=i.string.majorEncoded,vr=i.array.majorEncoded,Pn=i.float.majorEncoded|Je,qn=i.float.majorEncoded|Ke,Gn=i.float.majorEncoded|Xe,Hn=i.float.majorEncoded|We,Jn=BigInt(-1),Kn=BigInt(1);function Xn(e){return e.addBreakTokens!==!0}function Tr(e,t,r,n){let o=Ge(t),s=r.typeEncoders&&r.typeEncoders[o];if(s){let c=s(t,o,r,n);if(c!=null){ye(e,c,ne,r);return}}switch(o){case"null":e.push([Gn]);return;case"undefined":e.push([Hn]);return;case"boolean":e.push([t?qn:Pn]);return;case"number":!Number.isInteger(t)||!Number.isSafeInteger(t)?me(e,new u(i.float,t),r):t>=0?m(e,Er,t):m(e,Ur,t*-1-1);return;case"bigint":t>=BigInt(0)?m(e,Er,t):m(e,Ur,t*Jn-Kn);return;case"string":{let c=Ae(t);m(e,Vn,c.length),e.push(c);return}case"Uint8Array":m(e,jn,t.length),e.push(t);return;case"Array":if(!t.length){e.push([vr]);return}n=ge.createCheck(n,t),m(e,vr,t.length);for(let c of t)Tr(e,c,r,n);return;case"Object":case"Map":{let c=O.Object(t,o,r,n);ye(e,c,ne,r)}return;default:{let c=O[o];if(!c)throw new Error(`${ke} unsupported type: ${o}`);let d=c(t,o,r,n);ye(e,d,ne,r)}}}function Ir(e,t,r,n){let o=n instanceof Uint8Array,s=o?new Ie(n):$e,c=re(e,r);if(!Array.isArray(c)&&r.quickEncodeToken){let d=r.quickEncodeToken(c);if(d)return o?(s.push(d),s.toBytes()):d;let p=t[c.type.major];if(p.encodedSize){let y=p.encodedSize(c,r);if(o||(s=new de(y)),p(s,c,r),s.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${c} was wrong`);return o?s.toBytes():fe(s.chunks[0])}}return s.reset(),ye(s,c,t,r),s.toBytes(!0)}function tt(e,t){return t=Object.assign({},On,t),Xn(t)?($e.reset(),Tr($e,e,t,void 0),$e.toBytes(!0)):Ir(e,ne,t)}var Wn={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Me=class{constructor(t,r={}){this._pos=0,this.data=t,this.options=r}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let t=this.data[this._pos],r=_[t];if(r===void 0){let n=a[t];if(!n)throw new Error(`${f} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let o=t&31;r=n(this.data,this._pos,o,this.options)}return this._pos+=r.encodedLength,r}},V=Symbol.for("DONE"),oe=Symbol.for("BREAK");function Qn(e,t,r){let n=[];for(let o=0;o<e.value;o++){let s=P(t,r);if(s===oe){if(e.value===1/0)break;throw new Error(`${f} got unexpected break to lengthed array`)}if(s===V)throw new Error(`${f} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=s}return n}function Yn(e,t,r){let n=r.useMaps===!0,o=r.rejectDuplicateMapKeys===!0,s=n?void 0:{},c=n?new Map:void 0;for(let d=0;d<e.value;d++){let p=P(t,r);if(p===oe){if(e.value===1/0)break;throw new Error(`${f} got unexpected break to lengthed map`)}if(p===V)throw new Error(`${f} found map but not enough entries (got ${d} [no key], expected ${e.value})`);if(!n&&typeof p!="string")throw new Error(`${f} non-string keys not supported (got ${typeof p})`);if(o&&(n&&c.has(p)||!n&&Object.hasOwn(s,p)))throw new Error(`${f} found repeat map key "${p}"`);let y=P(t,r);if(y===V)throw new Error(`${f} found map but not enough entries (got ${d} [no value], expected ${e.value})`);n?c.set(p,y):s[p]=y}return n?c:s}function*Zn(e,t,r){for(let n=0;n<e.value;n++){let o=P(t,r);if(o===oe){if(e.value===1/0)break;throw new Error(`${f} got unexpected break to lengthed map`)}if(o===V)throw new Error(`${f} found map but not enough entries (got ${n} [no key], expected ${e.value})`);let s=P(t,r);if(s===V)throw new Error(`${f} found map but not enough entries (got ${n} [no value], expected ${e.value})`);yield[o,s]}}function eo(e,t){let r=!1,n=function(){if(r)throw new Error(`${f} tag decode() may only be called once`);r=!0;let o=P(e,t);if(o===V)throw new Error(`${f} tag content missing`);if(o===oe)throw new Error(`${f} got unexpected break in tag content`);return o};return n.entries=function(){if(r)throw new Error(`${f} tag decode() may only be called once`);r=!0;let o=e.next();if(!i.equals(o.type,i.map))throw new Error(`${f} entries() requires map content, got ${o.type.name}`);let s=[];for(let c of Zn(o,e,t))s.push(c);return s},Object.defineProperty(n,"_called",{get(){return r},enumerable:!1}),n}function P(e,t){if(e.done())return V;let r=e.next();if(i.equals(r.type,i.break))return oe;if(r.type.terminal)return r.value;if(i.equals(r.type,i.array))return Qn(r,e,t);if(i.equals(r.type,i.map))return Yn(r,e,t);if(i.equals(r.type,i.tag)){if(t.tags&&typeof t.tags[r.value]=="function"){let n=eo(e,t),o=t.tags[r.value](n);if(!n._called)throw new Error(`${f} tag decoder must call decode() or entries()`);return o}throw new Error(`${f} tag not supported (${r.value})`)}throw new Error("unsupported")}function kr(e,t){if(!(e instanceof Uint8Array))throw new Error(`${f} data to decode must be a Uint8Array`);t=Object.assign({},Wn,t);let r=fe(e),n=t.tokenizer||new Me(r,t),o=P(n,t);if(o===V)throw new Error(`${f} did not find any content to decode`);if(o===oe)throw new Error(`${f} got unexpected break`);return[o,e.subarray(n.pos())]}function rt(e,t){let[r,n]=kr(e,t);if(n.length>0)throw new Error(`${f} too many terminals, data makes no sense`);return r}var Oe=class e{constructor(t,r){if(typeof t!="number"||!Number.isInteger(t)||t<0)throw new TypeError("Tagged: tag must be a non-negative integer");this.tag=t,this.value=r}static decoder(t){return r=>new e(t,r())}static preserve(...t){let r={};for(let n of t)r[n]=e.decoder(n);return r}};Object.defineProperty(Oe.prototype,Symbol.toStringTag,{value:"Tagged"});var Sr=42;function ro(e){return e instanceof ArrayBuffer?new Uint8Array(e,0,e.byteLength):e}function no(e){if(e.asCID!==e&&e["/"]!==e.bytes)return null;let t=G.asCID(e);if(!t)return null;let r=new Uint8Array(t.bytes.byteLength+1);return r.set(t.bytes,1),[new u(i.tag,Sr),new u(i.bytes,r)]}function oo(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function io(e){if(Number.isNaN(e))throw new Error("`NaN` is not supported by the IPLD Data Model and cannot be encoded");if(e===1/0||e===-1/0)throw new Error("`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded");return null}function so(e){for(let t of e.keys())if(typeof t!="string"||t.length===0)throw new Error("Non-string Map keys are not supported by the IPLD Data Model and cannot be encoded");return null}var nt={float64:!0,typeEncoders:{Map:so,Object:no,undefined:oo,number:io}},Xi={...nt,typeEncoders:{...nt.typeEncoders}};function co(e){let t=e();if(t[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return G.decode(t.subarray(1))}var ot={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:{[Sr]:co}},Wi={...ot,tags:{...ot.tags}};var it=113,_r=e=>tt(e,nt),Br=e=>rt(ro(e),ot);function Cr(e=0){return new Uint8Array(e)}function st(e,t){t==null&&(t=e.reduce((o,s)=>o+s.length,0));let r=Cr(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}function uo(e){return e[Symbol.asyncIterator]!=null}function fo(e){if(uo(e))return(async()=>{let n=new Uint8Array(0);for await(let o of e)n=st([n,o],n.length+o.length);return n})();let t=[],r=0;for(let n of e)t.push(n),r+=n.byteLength;return st(t,r)}var Nr=fo;var lo=20;function at({name:e,code:t,encode:r,minDigestLength:n,maxDigestLength:o}){return new ct(e,t,r,n,o)}var ct=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,r,n,o,s){this.name=t,this.code=r,this.encode=n,this.minDigestLength=o??lo,this.maxDigestLength=s}digest(t,r){if(r?.truncate!=null){if(r.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&r.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(t instanceof Uint8Array){let n=this.encode(t);return n instanceof Uint8Array?Dr(n,this.code,r?.truncate):n.then(o=>Dr(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function Dr(e,t,r){if(r!=null&&r!==e.byteLength){if(r>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,r)}return Ee(t,e)}function $r(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var Mr=at({name:"sha2-256",code:18,encode:$r("SHA-256")}),cs=at({name:"sha2-512",code:19,encode:$r("SHA-512")});var Le=class{components;constructor(t){this.components=t}async add(t,r={}){let n=_r(t),o=await(r.hasher??Mr).digest(n),s=G.createV1(it,o);return await this.components.blockstore.put(s,n,r),s}async get(t,r={}){if(t.code!==it)throw new Ue("The passed CID had an incorrect codec, it may correspond to a non-DAG-CBOR block");let n=await Nr(this.components.blockstore.get(t,r));return Br(n)}};function po(e){return new Le(e)}return Vr(ho);})();
2
+ "use strict";var HeliaDagCbor=(()=>{var Fe=Object.defineProperty;var Fr=Object.getOwnPropertyDescriptor;var Rr=Object.getOwnPropertyNames;var jr=Object.prototype.hasOwnProperty;var Vr=(e,t)=>{for(var r in t)Fe(e,r,{get:t[r],enumerable:!0})},Pr=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Rr(t))!jr.call(e,o)&&o!==r&&Fe(e,o,{get:()=>t[o],enumerable:!(n=Fr(t,o))||n.enumerable});return e};var qr=e=>Pr(Fe({},"__esModule",{value:!0}),e);var xo={};Vr(xo,{dagCbor:()=>go});var bo=new Uint8Array(0);function ft(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function W(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return G(e);if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return G(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));throw new Error("Unknown type, must be binary type")}function Gr(e){return e?.buffer instanceof ArrayBuffer}function G(e){return Gr(e)?e:e.slice()}function Hr(e,t){if(e.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<e.length;o++){var s=e.charAt(o),c=s.charCodeAt(0);if(r[c]!==255)throw new TypeError(s+" is ambiguous");r[c]=o}var d=e.length,p=e.charAt(0),y=Math.log(d)/Math.log(256),_=Math.log(256)/Math.log(d);function K(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";for(var x=0,q=0,I=0,C=h.length;I!==C&&h[I]===0;)I++,x++;for(var N=(C-I)*_+1>>>0,U=new Uint8Array(N);I!==C;){for(var D=h[I],R=0,k=N-1;(D!==0||R<q)&&k!==-1;k--,R++)D+=256*U[k]>>>0,U[k]=D%d>>>0,D=D/d>>>0;if(D!==0)throw new Error("Non-zero carry");q=R,I++}for(var L=N-q;L!==N&&U[L]===0;)L++;for(var be=p.repeat(x);L<N;++L)be+=e.charAt(U[L]);return be}function we(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var x=0;if(h[x]!==" "){for(var q=0,I=0;h[x]===p;)q++,x++;for(var C=(h.length-x)*y+1>>>0,N=new Uint8Array(C);h[x];){var U=r[h.charCodeAt(x)];if(U===255)return;for(var D=0,R=C-1;(U!==0||D<I)&&R!==-1;R--,D++)U+=d*N[R]>>>0,N[R]=U%256>>>0,U=U/256>>>0;if(U!==0)throw new Error("Non-zero carry");I=D,x++}if(h[x]!==" "){for(var k=C-I;k!==C&&N[k]===0;)k++;for(var L=new Uint8Array(q+(C-k)),be=q;k!==C;)L[be++]=N[k++];return L}}}function zr(h){var x=we(h);if(x)return x;throw new Error(`Non-${t} character`)}return{encode:K,decodeUnsafe:we,decode:zr}}var Jr=Hr,Kr=Jr,dt=Kr;var Re=class{name;prefix;baseEncode;constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},je=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){this.name=t,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return lt(this,t)}},Ve=class{decoders;constructor(t){this.decoders=t}or(t){return lt(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function lt(e,t){return new Ve({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var Pe=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Re(t,r,n),this.decoder=new je(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function pt({name:e,prefix:t,encode:r,decode:n}){return new Pe(e,t,r,n)}function X({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=dt(r,e);return pt({prefix:t,name:e,encode:n,decode:s=>W(o(s))})}function Wr(e,t,r,n){let o=e.length;for(;e[o-1]==="=";)--o;let s=new Uint8Array(o*r/8|0),c=0,d=0,p=0;for(let y=0;y<o;++y){let _=t[e[y]];if(_===void 0)throw new SyntaxError(`Non-${n} character`);d=d<<r|_,c+=r,c>=8&&(c-=8,s[p++]=255&d>>c)}if(c>=r||(255&d<<8-c)!==0)throw new SyntaxError("Unexpected end of data");return s}function Xr(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,s="",c=0,d=0;for(let p=0;p<e.length;++p)for(d=d<<8|e[p],c+=8;c>r;)c-=r,s+=t[o&d>>c];if(c!==0&&(s+=t[o&d<<r-c]),n)for(;(s.length*r&7)!==0;)s+="=";return s}function Qr(e){let t={};for(let r=0;r<e.length;++r)t[e[r]]=r;return t}function $({name:e,prefix:t,bitsPerChar:r,alphabet:n}){let o=Qr(n);return pt({prefix:t,name:e,encode(s){return Xr(s,n,r)},decode(s){return Wr(s,o,r,e)}})}var se=$({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),ko=$({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Bo=$({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),So=$({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),_o=$({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Co=$({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),No=$({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Do=$({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),$o=$({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ee=X({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Lo=X({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var z=X({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ro=X({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Yr=yt,ht=128,Zr=127,en=~Zr,tn=Math.pow(2,31);function yt(e,t,r){t=t||[],r=r||0;for(var n=r;e>=tn;)t[r++]=e&255|ht,e/=128;for(;e&en;)t[r++]=e&255|ht,e>>>=7;return t[r]=e|0,yt.bytes=r-n+1,t}var rn=qe,nn=128,mt=127;function qe(e,n){var r=0,n=n||0,o=0,s=n,c,d=e.length;do{if(s>=d)throw qe.bytes=0,new RangeError("Could not decode varint");c=e[s++],r+=o<28?(c&mt)<<o:(c&mt)*Math.pow(2,o),o+=7}while(c>=nn);return qe.bytes=s-n,r}var on=Math.pow(2,7),sn=Math.pow(2,14),cn=Math.pow(2,21),an=Math.pow(2,28),un=Math.pow(2,35),fn=Math.pow(2,42),dn=Math.pow(2,49),ln=Math.pow(2,56),pn=Math.pow(2,63),hn=function(e){return e<on?1:e<sn?2:e<cn?3:e<an?4:e<un?5:e<fn?6:e<dn?7:e<ln?8:e<pn?9:10},mn={encode:Yr,decode:rn,encodingLength:hn},yn=mn,ce=yn;function ae(e,t=0){return[ce.decode(e,t),ce.decode.bytes]}function Q(e,t,r=0){return ce.encode(e,t,r),t}function Y(e){return ce.encodingLength(e)}function Ae(e,t){let r=t.byteLength,n=Y(e),o=n+Y(r),s=new Uint8Array(o+r);return Q(e,s,0),Q(r,s,n),s.set(t,o),new Z(e,r,t,s)}function xt(e){let t=W(e),[r,n]=ae(t),[o,s]=ae(t.subarray(n)),c=t.subarray(n+s);if(c.byteLength!==o)throw new Error("Incorrect length");return new Z(r,o,c,t)}function wt(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&ft(e.bytes,r.bytes)}}var Z=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=G(n),this.bytes=G(o)}};function Et(e,t){let{bytes:r,version:n}=e;return n===0?xn(r,Ge(e),t??z.encoder):wn(r,Ge(e),t??se.encoder)}var At=new WeakMap;function Ge(e){let t=At.get(e);if(t==null){let r=new Map;return At.set(e,r),r}return t}var H=class e{code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,this.version=t,this.multihash=n,this.bytes=G(o),this["/"]=this.bytes}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:t,multihash:r}=this;if(t!==ue)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==bn)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.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:t,digest:r}=this.multihash,n=Ae(t,r);return e.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(t){return e.equals(this,t)}static equals(t,r){let n=r;return n!=null&&t.code===n.code&&t.version===n.version&&wt(t.multihash,n.multihash)}toString(t){return Et(this,t)}toJSON(){return{"/":Et(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let r=t;if(r instanceof e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:c}=r;return new e(n,o,s,c??Ut(n,o,s.bytes))}else if(r[En]===!0){let{version:n,multihash:o,code:s}=r,c=xt(o);return e.create(n,s,c)}else return null}static create(t,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(t){case 0:{if(r!==ue)throw new Error(`Version 0 CID must use dag-pb (code: ${ue}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=Ut(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,ue,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=W(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),c=new Z(r.multihashCode,r.digestSize,s,o);return[r.version===0?e.createV0(c):e.createV1(r.codec,c),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[K,we]=ae(t.subarray(r));return r+=we,K},o=n(),s=ue;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let c=r,d=n(),p=n(),y=r+p,_=y-c;return{version:o,codec:s,multihashCode:d,digestSize:p,multihashSize:_,size:y}}static parse(t,r){let[n,o]=gn(t,r),s=e.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Ge(s).set(n,t),s}};function gn(e,t){switch(e[0]){case"Q":{let r=t??z;return[z.prefix,r.decode(`${z.prefix}${e}`)]}case z.prefix:{let r=t??z;return[z.prefix,r.decode(e)]}case se.prefix:{let r=t??se;return[se.prefix,r.decode(e)]}case Ee.prefix:{let r=t??Ee;return[Ee.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function xn(e,t,r){let{prefix:n}=r;if(n!==z.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let s=r.encode(e).slice(1);return t.set(n,s),s}else return o}function wn(e,t,r){let{prefix:n}=r,o=t.get(n);if(o==null){let s=r.encode(e);return t.set(n,s),s}else return o}var ue=112,bn=18;function Ut(e,t,r){let n=Y(e),o=n+Y(t),s=new Uint8Array(o+r.byteLength);return Q(e,s,0),Q(t,s,n),s.set(r,o),s}var En=Symbol.for("@ipld/js-cid/CID");var Ue=class extends Error{static name="InvalidCodecError";constructor(t="Invalid codec"){super(t),this.name="InvalidCodecError"}};var An=["Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array","Tagged"];function He(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(t==="string"||t==="number"||t==="bigint"||t==="symbol")return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(e instanceof Uint8Array)return"Uint8Array";if(e.constructor===Object)return"Object";let r=Un(e);return r||"Object"}function Un(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(An.includes(t))return t}var i=class{constructor(t,r,n){this.major=t,this.majorEncoded=t<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(t){return this.major<t.major?-1:this.major>t.major?1:0}static equals(t,r){return t===r||t.major===r.major&&t.name===r.name}};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 u=class{constructor(t,r,n){this.type=t,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var fe=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",vn=new TextEncoder;function ve(e){return fe&&globalThis.Buffer.isBuffer(e)}function de(e){return e instanceof Uint8Array?ve(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var Tn=24,In=200,Te=fe?e=>e.length>=Tn?globalThis.Buffer.from(e):vt(e):e=>e.length>=In?vn.encode(e):vt(e),M=e=>Uint8Array.from(e),Tt=fe?(e,t,r)=>ve(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),It=fe?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),de(globalThis.Buffer.concat(e,t))):(e,t)=>{let r=new Uint8Array(t),n=0;for(let o of e)n+o.length>r.length&&(o=o.subarray(0,r.length-n)),r.set(o,n),n+=o.length;return r},kt=fe?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function Ie(e,t){if(ve(e)&&ve(t))return e.compare(t);for(let r=0;r<e.length;r++)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return 0}function vt(e){let t=[],r=0;for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&n+1<e.length&&(e.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(e.charCodeAt(++n)&1023),t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(o>=55296&&o<=57343&&(o=65533),t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128)}return t}var kn=256,le=class{constructor(t=kn){this.chunkSize=t,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(t){let r=this.chunks[this.chunks.length-1];if(this.cursor+t.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(t,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)}t.length<64&&t.length<this.chunkSize?(r=kt(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(t,0)):(this.chunks.push(t),this.maxCursor+=t.length)}this.cursor+=t.length}toBytes(t=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];t&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=Tt(n,0,this.cursor)}else r=It(this.chunks,this.cursor);return t&&this.reset(),r}},ke=class{constructor(t){this.dest=t,this.cursor=0,this.chunks=[t]}reset(){this.cursor=0}push(t){if(this.cursor+t.length>this.dest.length)throw new Error("write out of bounds, destination buffer is too small");this.dest.set(t,this.cursor),this.cursor+=t.length}toBytes(t=!1){let r=this.dest.subarray(0,this.cursor);return t&&this.reset(),r}};var f="CBOR decode error:",Be="CBOR encode error:",pe=[];pe[23]=1;pe[24]=2;pe[25]=3;pe[26]=5;pe[27]=9;function F(e,t,r){if(e.length-t<r)throw new Error(`${f} not enough data for type`)}var g=[24,256,65536,4294967296,BigInt("18446744073709551616")];function w(e,t,r){F(e,t,1);let n=e[t];if(r.strict===!0&&n<g[0])throw new Error(`${f} integer encoded in more bytes than necessary (strict decode)`);return n}function b(e,t,r){F(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<g[1])throw new Error(`${f} integer encoded in more bytes than necessary (strict decode)`);return n}function E(e,t,r){F(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<g[2])throw new Error(`${f} integer encoded in more bytes than necessary (strict decode)`);return n}function A(e,t,r){F(e,t,8);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],o=e[t+4]*16777216+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],s=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&s<g[3])throw new Error(`${f} 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(`${f} integers outside of the safe integer range are not supported`)}function Bt(e,t,r,n){return new u(i.uint,w(e,t+1,n),2)}function St(e,t,r,n){return new u(i.uint,b(e,t+1,n),3)}function _t(e,t,r,n){return new u(i.uint,E(e,t+1,n),5)}function Ct(e,t,r,n){return new u(i.uint,A(e,t+1,n),9)}function v(e,t){return m(e,0,t.value)}function m(e,t,r){if(r<g[0]){let n=Number(r);e.push([t|n])}else if(r<g[1]){let n=Number(r);e.push([t|24,n])}else if(r<g[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<g[3]){let n=Number(r);e.push([t|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<g[4]){let o=[t|27,0,0,0,0,0,0,0],s=Number(n&BigInt(4294967295)),c=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]=c&255,c=c>>8,o[3]=c&255,c=c>>8,o[2]=c&255,c=c>>8,o[1]=c&255,e.push(o)}else throw new Error(`${f} encountered BigInt larger than allowable range`)}}v.encodedSize=function(t){return m.encodedSize(t.value)};m.encodedSize=function(t){return t<g[0]?1:t<g[1]?2:t<g[2]?3:t<g[3]?5:9};v.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function Nt(e,t,r,n){return new u(i.negint,-1-w(e,t+1,n),2)}function Dt(e,t,r,n){return new u(i.negint,-1-b(e,t+1,n),3)}function $t(e,t,r,n){return new u(i.negint,-1-E(e,t+1,n),5)}var Je=BigInt(-1),Mt=BigInt(1);function Ot(e,t,r,n){let o=A(e,t+1,n);if(typeof o!="bigint"){let s=-1-o;if(s>=Number.MIN_SAFE_INTEGER)return new u(i.negint,s,9)}if(n.allowBigInt!==!0)throw new Error(`${f} integers outside of the safe integer range are not supported`);return new u(i.negint,Je-BigInt(o),9)}function Se(e,t){let r=t.value,n=typeof r=="bigint"?r*Je-Mt:r*-1-1;m(e,t.type.majorEncoded,n)}Se.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*Je-Mt:r*-1-1;return n<g[0]?1:n<g[1]?2:n<g[2]?3:n<g[3]?5:9};Se.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function he(e,t,r,n){F(e,t,r+n);let o=e.slice(t+r,t+r+n);return new u(i.bytes,o,r+n)}function Lt(e,t,r,n){return he(e,t,1,r)}function zt(e,t,r,n){return he(e,t,2,w(e,t+1,n))}function Ft(e,t,r,n){return he(e,t,3,b(e,t+1,n))}function Rt(e,t,r,n){return he(e,t,5,E(e,t+1,n))}function jt(e,t,r,n){let o=A(e,t+1,n);if(typeof o=="bigint")throw new Error(`${f} 64-bit integer bytes lengths not supported`);return he(e,t,9,o)}function _e(e){return e.encodedBytes===void 0&&(e.encodedBytes=i.equals(e.type,i.string)?Te(e.value):e.value),e.encodedBytes}function ee(e,t){let r=_e(t);m(e,t.type.majorEncoded,r.length),e.push(r)}ee.encodedSize=function(t){let r=_e(t);return m.encodedSize(r.length)+r.length};ee.compareTokens=function(t,r){return Sn(_e(t),_e(r))};function Sn(e,t){return e.length<t.length?-1:e.length>t.length?1:Ie(e,t)}var Vt=new TextDecoder,Cn=32;function Nn(e,t,r){if(r-t<Cn){let o="";for(let s=t;s<r;s++){let c=e[s];if(c&128)return Vt.decode(e.subarray(t,r));o+=String.fromCharCode(c)}return o}return Vt.decode(e.subarray(t,r))}function me(e,t,r,n,o){let s=r+n;F(e,t,s);let c=new u(i.string,Nn(e,t+r,t+s),s);return o.retainStringBytes===!0&&(c.byteValue=e.slice(t+r,t+s)),c}function Pt(e,t,r,n){return me(e,t,1,r,n)}function qt(e,t,r,n){return me(e,t,2,w(e,t+1,n),n)}function Gt(e,t,r,n){return me(e,t,3,b(e,t+1,n),n)}function Ht(e,t,r,n){return me(e,t,5,E(e,t+1,n),n)}function Jt(e,t,r,n){let o=A(e,t+1,n);if(typeof o=="bigint")throw new Error(`${f} 64-bit integer string lengths not supported`);return me(e,t,9,o,n)}var Kt=ee;function te(e,t,r,n){return new u(i.array,n,r)}function Wt(e,t,r,n){return te(e,t,1,r)}function Xt(e,t,r,n){return te(e,t,2,w(e,t+1,n))}function Qt(e,t,r,n){return te(e,t,3,b(e,t+1,n))}function Yt(e,t,r,n){return te(e,t,5,E(e,t+1,n))}function Zt(e,t,r,n){let o=A(e,t+1,n);if(typeof o=="bigint")throw new Error(`${f} 64-bit integer array lengths not supported`);return te(e,t,9,o)}function er(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${f} indefinite length items not allowed`);return te(e,t,1,1/0)}function Ce(e,t){m(e,i.array.majorEncoded,t.value)}Ce.compareTokens=v.compareTokens;Ce.encodedSize=function(t){return m.encodedSize(t.value)};function re(e,t,r,n){return new u(i.map,n,r)}function tr(e,t,r,n){return re(e,t,1,r)}function rr(e,t,r,n){return re(e,t,2,w(e,t+1,n))}function nr(e,t,r,n){return re(e,t,3,b(e,t+1,n))}function or(e,t,r,n){return re(e,t,5,E(e,t+1,n))}function ir(e,t,r,n){let o=A(e,t+1,n);if(typeof o=="bigint")throw new Error(`${f} 64-bit integer map lengths not supported`);return re(e,t,9,o)}function sr(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${f} indefinite length items not allowed`);return re(e,t,1,1/0)}function Ne(e,t){m(e,i.map.majorEncoded,t.value)}Ne.compareTokens=v.compareTokens;Ne.encodedSize=function(t){return m.encodedSize(t.value)};function cr(e,t,r,n){return new u(i.tag,r,1)}function ar(e,t,r,n){return new u(i.tag,w(e,t+1,n),2)}function ur(e,t,r,n){return new u(i.tag,b(e,t+1,n),3)}function fr(e,t,r,n){return new u(i.tag,E(e,t+1,n),5)}function dr(e,t,r,n){return new u(i.tag,A(e,t+1,n),9)}function De(e,t){m(e,i.tag.majorEncoded,t.value)}De.compareTokens=v.compareTokens;De.encodedSize=function(t){return m.encodedSize(t.value)};var Ke=20,We=21,Xe=22,Qe=23;function lr(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${f} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new u(i.null,null,1):new u(i.undefined,void 0,1)}function pr(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${f} indefinite length items not allowed`);return new u(i.break,void 0,1)}function Ye(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${f} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${f} Infinity values are not supported`)}return new u(i.float,e,t)}function hr(e,t,r,n){return Ye(Ze(e,t+1),3,n)}function mr(e,t,r,n){return Ye(et(e,t+1),5,n)}function yr(e,t,r,n){return Ye(br(e,t+1),9,n)}function ye(e,t,r){let n=t.value;if(n===!1)e.push([i.float.majorEncoded|Ke]);else if(n===!0)e.push([i.float.majorEncoded|We]);else if(n===null)e.push([i.float.majorEncoded|Xe]);else if(n===void 0)e.push([i.float.majorEncoded|Qe]);else{let o,s=!1;(!r||r.float64!==!0)&&(xr(n),o=Ze(B,1),n===o||Number.isNaN(n)?(B[0]=249,e.push(B.slice(0,3)),s=!0):(wr(n),o=et(B,1),n===o&&(B[0]=250,e.push(B.slice(0,5)),s=!0))),s||(Ln(n),o=br(B,1),B[0]=251,e.push(B.slice(0,9)))}}ye.encodedSize=function(t,r){let n=t.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){xr(n);let o=Ze(B,1);if(n===o||Number.isNaN(n))return 3;if(wr(n),o=et(B,1),n===o)return 5}return 9};var gr=new ArrayBuffer(9),T=new DataView(gr,1),B=new Uint8Array(gr,0);function xr(e){if(e===1/0)T.setUint16(0,31744,!1);else if(e===-1/0)T.setUint16(0,64512,!1);else if(Number.isNaN(e))T.setUint16(0,32256,!1);else{T.setFloat32(0,e);let t=T.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)T.setUint16(0,31744,!1);else if(r===0)T.setUint16(0,(t&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?T.setUint16(0,0):o<-14?T.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):T.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function Ze(e,t){if(e.length-t<2)throw new Error(`${f} not enough data for float16`);let r=(e[t]<<8)+e[t+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 wr(e){T.setFloat32(0,e,!1)}function et(e,t){if(e.length-t<4)throw new Error(`${f} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function Ln(e){T.setFloat64(0,e,!1)}function br(e,t){if(e.length-t<8)throw new Error(`${f} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}ye.compareTokens=v.compareTokens;function l(e,t,r){throw new Error(`${f} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function $e(e){return()=>{throw new Error(`${f} ${e}`)}}var a=[];for(let e=0;e<=23;e++)a[e]=l;a[24]=Bt;a[25]=St;a[26]=_t;a[27]=Ct;a[28]=l;a[29]=l;a[30]=l;a[31]=l;for(let e=32;e<=55;e++)a[e]=l;a[56]=Nt;a[57]=Dt;a[58]=$t;a[59]=Ot;a[60]=l;a[61]=l;a[62]=l;a[63]=l;for(let e=64;e<=87;e++)a[e]=Lt;a[88]=zt;a[89]=Ft;a[90]=Rt;a[91]=jt;a[92]=l;a[93]=l;a[94]=l;a[95]=$e("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)a[e]=Pt;a[120]=qt;a[121]=Gt;a[122]=Ht;a[123]=Jt;a[124]=l;a[125]=l;a[126]=l;a[127]=$e("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)a[e]=Wt;a[152]=Xt;a[153]=Qt;a[154]=Yt;a[155]=Zt;a[156]=l;a[157]=l;a[158]=l;a[159]=er;for(let e=160;e<=183;e++)a[e]=tr;a[184]=rr;a[185]=nr;a[186]=or;a[187]=ir;a[188]=l;a[189]=l;a[190]=l;a[191]=sr;for(let e=192;e<=215;e++)a[e]=cr;a[216]=ar;a[217]=ur;a[218]=fr;a[219]=dr;a[220]=l;a[221]=l;a[222]=l;a[223]=l;for(let e=224;e<=243;e++)a[e]=$e("simple values are not supported");a[244]=l;a[245]=l;a[246]=l;a[247]=lr;a[248]=$e("simple values are not supported");a[249]=hr;a[250]=mr;a[251]=yr;a[252]=l;a[253]=l;a[254]=l;a[255]=pr;var S=[];for(let e=0;e<24;e++)S[e]=new u(i.uint,e,1);for(let e=-1;e>=-24;e--)S[31-e]=new u(i.negint,e,1);S[64]=new u(i.bytes,new Uint8Array(0),1);S[96]=new u(i.string,"",1);S[128]=new u(i.array,0,1);S[160]=new u(i.map,0,1);S[244]=new u(i.false,!1,1);S[245]=new u(i.true,!0,1);S[246]=new u(i.null,null,1);function tt(e){switch(e.type){case i.false:return M([244]);case i.true:return M([245]);case i.null:return M([246]);case i.bytes:return e.value.length?void 0:M([64]);case i.string:return e.value===""?M([96]):void 0;case i.array:return e.value===0?M([128]):void 0;case i.map:return e.value===0?M([160]):void 0;case i.uint:return e.value<24?M([Number(e.value)]):void 0;case i.negint:if(e.value>=-24)return M([31-Number(e.value)])}}var Fn={float64:!1,mapSorter:Vn,quickEncodeToken:tt},Tr=Object.freeze({float64:!0,mapSorter:Pn,quickEncodeToken:tt});function Rn(){let e=[];return e[i.uint.major]=v,e[i.negint.major]=Se,e[i.bytes.major]=ee,e[i.string.major]=Kt,e[i.array.major]=Ce,e[i.map.major]=Ne,e[i.tag.major]=De,e[i.float.major]=ye,e}var oe=Rn(),Me=new le,xe=class e{constructor(t,r){this.obj=t,this.parent=r}includes(t){let r=this;do if(r.obj===t)return!0;while(r=r.parent);return!1}static createCheck(t,r){if(t&&t.includes(r))throw new Error(`${Be} object contains circular references`);return new e(r,t)}},j={null:new u(i.null,null),undefined:new u(i.undefined,void 0),true:new u(i.true,!0),false:new u(i.false,!1),emptyArray:new u(i.array,0),emptyMap:new u(i.map,0)},O={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new u(i.float,e):e>=0?new u(i.uint,e):new u(i.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new u(i.uint,e):new u(i.negint,e)},Uint8Array(e,t,r,n){return new u(i.bytes,e)},string(e,t,r,n){return new u(i.string,e)},boolean(e,t,r,n){return e?j.true:j.false},null(e,t,r,n){return j.null},undefined(e,t,r,n){return j.undefined},ArrayBuffer(e,t,r,n){return new u(i.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new u(i.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[j.emptyArray,new u(i.break)]:j.emptyArray;n=xe.createCheck(n,e);let o=[],s=0;for(let c of e)o[s++]=ne(c,r,n);return r.addBreakTokens?[new u(i.array,e.length),o,new u(i.break)]:[new u(i.array,e.length),o]},Object(e,t,r,n){let o=t!=="Object",s=o?e.keys():Object.keys(e),c=o?e.size:s.length,d;if(c){d=new Array(c),n=xe.createCheck(n,e);let p=!o&&r.ignoreUndefinedProperties,y=0;for(let _ of s){let K=o?e.get(_):e[_];p&&K===void 0||(d[y++]=[ne(_,r,n),ne(K,r,n)])}y<c&&(d.length=y)}return d?.length?(jn(d,r),r.addBreakTokens?[new u(i.map,d.length),d,new u(i.break)]:[new u(i.map,d.length),d]):r.addBreakTokens===!0?[j.emptyMap,new u(i.break)]:j.emptyMap},Tagged(e,t,r,n){return[new u(i.tag,e.tag),ne(e.value,r,n)]}};O.Map=O.Object;O.Buffer=O.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))O[`${e}Array`]=O.DataView;function ne(e,t={},r){let n=He(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||O[n];if(typeof o=="function"){let c=o(e,n,t,r);if(c!=null)return c}let s=O[n];if(!s)throw new Error(`${Be} unsupported type: ${n}`);return s(e,n,t,r)}function jn(e,t){t.mapSorter&&e.sort(t.mapSorter)}function Vn(e,t){let r=Array.isArray(e[0])?e[0][0]:e[0],n=Array.isArray(t[0])?t[0][0]:t[0];if(r.type!==n.type)return r.type.compare(n.type);let o=r.type.major,s=oe[o].compareTokens(r,n);return s===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),s}function Pn(e,t){if(e[0]instanceof u&&t[0]instanceof u){let r=e[0],n=t[0];return r._keyBytes||(r._keyBytes=Er(r.value)),n._keyBytes||(n._keyBytes=Er(n.value)),Ie(r._keyBytes,n._keyBytes)}throw new Error("rfc8949MapSorter: complex key types are not supported yet")}function Er(e){return kr(e,oe,Tr)}function ge(e,t,r,n){if(Array.isArray(t))for(let o of t)ge(e,o,r,n);else r[t.type.major](e,t,n)}var Ar=i.uint.majorEncoded,Ur=i.negint.majorEncoded,qn=i.bytes.majorEncoded,Gn=i.string.majorEncoded,vr=i.array.majorEncoded,Hn=i.float.majorEncoded|Ke,Jn=i.float.majorEncoded|We,Kn=i.float.majorEncoded|Xe,Wn=i.float.majorEncoded|Qe,Xn=BigInt(-1),Qn=BigInt(1);function Yn(e){return e.addBreakTokens!==!0}function Ir(e,t,r,n){let o=He(t),s=r.typeEncoders&&r.typeEncoders[o];if(s){let c=s(t,o,r,n);if(c!=null){ge(e,c,oe,r);return}}switch(o){case"null":e.push([Kn]);return;case"undefined":e.push([Wn]);return;case"boolean":e.push([t?Jn:Hn]);return;case"number":!Number.isInteger(t)||!Number.isSafeInteger(t)?ye(e,new u(i.float,t),r):t>=0?m(e,Ar,t):m(e,Ur,t*-1-1);return;case"bigint":t>=BigInt(0)?m(e,Ar,t):m(e,Ur,t*Xn-Qn);return;case"string":{let c=Te(t);m(e,Gn,c.length),e.push(c);return}case"Uint8Array":m(e,qn,t.length),e.push(t);return;case"Array":if(!t.length){e.push([vr]);return}n=xe.createCheck(n,t),m(e,vr,t.length);for(let c of t)Ir(e,c,r,n);return;case"Object":case"Map":{let c=O.Object(t,o,r,n);ge(e,c,oe,r)}return;default:{let c=O[o];if(!c)throw new Error(`${Be} unsupported type: ${o}`);let d=c(t,o,r,n);ge(e,d,oe,r)}}}function kr(e,t,r,n){let o=n instanceof Uint8Array,s=o?new ke(n):Me,c=ne(e,r);if(!Array.isArray(c)&&r.quickEncodeToken){let d=r.quickEncodeToken(c);if(d)return o?(s.push(d),s.toBytes()):d;let p=t[c.type.major];if(p.encodedSize){let y=p.encodedSize(c,r);if(o||(s=new le(y)),p(s,c,r),s.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${c} was wrong`);return o?s.toBytes():de(s.chunks[0])}}return s.reset(),ge(s,c,t,r),s.toBytes(!0)}function rt(e,t){return t=Object.assign({},Fn,t),Yn(t)?(Me.reset(),Ir(Me,e,t,void 0),Me.toBytes(!0)):kr(e,oe,t)}var Zn={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Oe=class{constructor(t,r={}){this._pos=0,this.data=t,this.options=r}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let t=this.data[this._pos],r=S[t];if(r===void 0){let n=a[t];if(!n)throw new Error(`${f} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let o=t&31;r=n(this.data,this._pos,o,this.options)}return this._pos+=r.encodedLength,r}},V=Symbol.for("DONE"),ie=Symbol.for("BREAK");function eo(e,t,r){let n=[];for(let o=0;o<e.value;o++){let s=P(t,r);if(s===ie){if(e.value===1/0)break;throw new Error(`${f} got unexpected break to lengthed array`)}if(s===V)throw new Error(`${f} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=s}return n}function to(e,t,r){let n=r.useMaps===!0,o=r.rejectDuplicateMapKeys===!0,s=n?void 0:{},c=n?new Map:void 0;for(let d=0;d<e.value;d++){let p=P(t,r);if(p===ie){if(e.value===1/0)break;throw new Error(`${f} got unexpected break to lengthed map`)}if(p===V)throw new Error(`${f} found map but not enough entries (got ${d} [no key], expected ${e.value})`);if(!n&&typeof p!="string")throw new Error(`${f} non-string keys not supported (got ${typeof p})`);if(o&&(n&&c.has(p)||!n&&Object.hasOwn(s,p)))throw new Error(`${f} found repeat map key "${p}"`);let y=P(t,r);if(y===V)throw new Error(`${f} found map but not enough entries (got ${d} [no value], expected ${e.value})`);n?c.set(p,y):s[p]=y}return n?c:s}function*ro(e,t,r){for(let n=0;n<e.value;n++){let o=P(t,r);if(o===ie){if(e.value===1/0)break;throw new Error(`${f} got unexpected break to lengthed map`)}if(o===V)throw new Error(`${f} found map but not enough entries (got ${n} [no key], expected ${e.value})`);let s=P(t,r);if(s===V)throw new Error(`${f} found map but not enough entries (got ${n} [no value], expected ${e.value})`);yield[o,s]}}function no(e,t){let r=!1,n=function(){if(r)throw new Error(`${f} tag decode() may only be called once`);r=!0;let o=P(e,t);if(o===V)throw new Error(`${f} tag content missing`);if(o===ie)throw new Error(`${f} got unexpected break in tag content`);return o};return n.entries=function(){if(r)throw new Error(`${f} tag decode() may only be called once`);r=!0;let o=e.next();if(!i.equals(o.type,i.map))throw new Error(`${f} entries() requires map content, got ${o.type.name}`);let s=[];for(let c of ro(o,e,t))s.push(c);return s},Object.defineProperty(n,"_called",{get(){return r},enumerable:!1}),n}function P(e,t){if(e.done())return V;let r=e.next();if(i.equals(r.type,i.break))return ie;if(r.type.terminal)return r.value;if(i.equals(r.type,i.array))return eo(r,e,t);if(i.equals(r.type,i.map))return to(r,e,t);if(i.equals(r.type,i.tag)){if(t.tags&&typeof t.tags[r.value]=="function"){let n=no(e,t),o=t.tags[r.value](n);if(!n._called)throw new Error(`${f} tag decoder must call decode() or entries()`);return o}throw new Error(`${f} tag not supported (${r.value})`)}throw new Error("unsupported")}function Br(e,t){if(!(e instanceof Uint8Array))throw new Error(`${f} data to decode must be a Uint8Array`);t=Object.assign({},Zn,t);let r=de(e),n=t.tokenizer||new Oe(r,t),o=P(n,t);if(o===V)throw new Error(`${f} did not find any content to decode`);if(o===ie)throw new Error(`${f} got unexpected break`);return[o,e.subarray(n.pos())]}function nt(e,t){let[r,n]=Br(e,t);if(n.length>0)throw new Error(`${f} too many terminals, data makes no sense`);return r}var Le=class e{constructor(t,r){if(typeof t!="number"||!Number.isInteger(t)||t<0)throw new TypeError("Tagged: tag must be a non-negative integer");this.tag=t,this.value=r}static decoder(t){return r=>new e(t,r())}static preserve(...t){let r={};for(let n of t)r[n]=e.decoder(n);return r}};Object.defineProperty(Le.prototype,Symbol.toStringTag,{value:"Tagged"});var Sr=42;function io(e){return e instanceof ArrayBuffer?new Uint8Array(e,0,e.byteLength):e}function so(e){if(e.asCID!==e&&e["/"]!==e.bytes)return null;let t=H.asCID(e);if(!t)return null;let r=new Uint8Array(t.bytes.byteLength+1);return r.set(t.bytes,1),[new u(i.tag,Sr),new u(i.bytes,r)]}function co(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function ao(e){if(Number.isNaN(e))throw new Error("`NaN` is not supported by the IPLD Data Model and cannot be encoded");if(e===1/0||e===-1/0)throw new Error("`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded");return null}function uo(e){for(let t of e.keys())if(typeof t!="string"||t.length===0)throw new Error("Non-string Map keys are not supported by the IPLD Data Model and cannot be encoded");return null}var ot={float64:!0,typeEncoders:{Map:uo,Object:so,undefined:co,number:ao}},Zi={...ot,typeEncoders:{...ot.typeEncoders}};function fo(e){let t=e();if(t[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return H.decode(t.subarray(1))}var it={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:{[Sr]:fo}},es={...it,tags:{...it.tags}};var st=113,_r=e=>rt(e,ot),Cr=e=>nt(io(e),it);function Nr(e=0){return new Uint8Array(e)}function po(e){return e?.buffer instanceof ArrayBuffer}function Dr(e){if(po(e))return e;let t=e.slice();return new Uint8Array(t.buffer,0,t.byteLength)}function ct(e,t){t==null&&(t=e.reduce((o,s)=>o+s.length,0));let r=Nr(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return Dr(r)}function ho(e){return e[Symbol.asyncIterator]!=null}function mo(e){if(ho(e))return(async()=>{let n=new Uint8Array(0);for await(let o of e)n=ct([n,o],n.length+o.length);return n})();let t=[],r=0;for(let n of e)t.push(n),r+=n.byteLength;return ct(t,r)}var $r=mo;var yo=20;function ut({name:e,code:t,encode:r,minDigestLength:n,maxDigestLength:o}){return new at(e,t,r,n,o)}var at=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,r,n,o,s){this.name=t,this.code=r,this.encode=n,this.minDigestLength=o??yo,this.maxDigestLength=s}digest(t,r){if(r?.truncate!=null){if(r.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&r.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(t instanceof Uint8Array){let n=this.encode(t);return n instanceof Uint8Array?Mr(n,this.code,r?.truncate):n.then(o=>Mr(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function Mr(e,t,r){if(r!=null&&r!==e.byteLength){if(r>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,r)}return Ae(t,e)}function Or(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var Lr=ut({name:"sha2-256",code:18,encode:Or("SHA-256")}),fs=ut({name:"sha2-512",code:19,encode:Or("SHA-512")});var ze=class{components;constructor(t){this.components=t}async add(t,r={}){let n=_r(t),o=await(r.hasher??Lr).digest(n),s=H.createV1(st,o);return await this.components.blockstore.put(s,n,r),s}async get(t,r={}){if(t.code!==st)throw new Ue("The passed CID had an incorrect codec, it may correspond to a non-DAG-CBOR block");let n=await $r(this.components.blockstore.get(t,r));return Cr(n)}};function go(e){return new ze(e)}return qr(xo);})();
3
3
  return HeliaDagCbor}));
4
4
  //# sourceMappingURL=index.min.js.map