@helia/dag-cbor 4.1.0-9993b476 → 4.1.0-e502d45f
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/README.md +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +4 -4
- package/dist/src/dag-cbor.d.ts +9 -0
- package/dist/src/dag-cbor.d.ts.map +1 -0
- package/dist/src/dag-cbor.js +26 -0
- package/dist/src/dag-cbor.js.map +1 -0
- package/dist/src/index.d.ts +1 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -21
- package/dist/src/index.js.map +1 -1
- package/package.json +2 -2
- package/src/dag-cbor.ts +34 -0
- package/src/index.ts +4 -31
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ repo and examine the changes made.
|
|
|
30
30
|
|
|
31
31
|
-->
|
|
32
32
|
|
|
33
|
-
`@helia/dag-cbor` makes working with DAG-CBOR
|
|
33
|
+
`@helia/dag-cbor` makes working with DAG-CBOR <https://ipld.io/docs/codecs/known/dag-cbor/> simple & straightforward.
|
|
34
34
|
|
|
35
35
|
See the DAGCBOR interface for all available operations.
|
|
36
36
|
|
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 Ie=Object.defineProperty;var Tr=Object.getOwnPropertyDescriptor;var kr=Object.getOwnPropertyNames;var Sr=Object.prototype.hasOwnProperty;var Br=(e,t)=>{for(var r in t)Ie(e,r,{get:t[r],enumerable:!0})},Ir=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of kr(t))!Sr.call(e,o)&&o!==r&&Ie(e,o,{get:()=>t[o],enumerable:!(n=Tr(t,o))||n.enumerable});return e};var Cr=e=>Ir(Ie({},"__esModule",{value:!0}),e);var Hn={};Br(Hn,{dagCbor:()=>Kn});var _r=["string","number","bigint","symbol"],Nr=["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 Qe(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(_r.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(Dr(e))return"Buffer";let r=$r(e);return r||"Object"}function Dr(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function $r(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(Nr.includes(t))return t}var s=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}};s.uint=new s(0,"uint",!0);s.negint=new s(1,"negint",!0);s.bytes=new s(2,"bytes",!0);s.string=new s(3,"string",!0);s.array=new s(4,"array",!1);s.map=new s(5,"map",!1);s.tag=new s(6,"tag",!1);s.float=new s(7,"float",!0);s.false=new s(7,"false",!0);s.true=new s(7,"true",!0);s.null=new s(7,"null",!0);s.undefined=new s(7,"undefined",!0);s.break=new s(7,"break",!0);var a=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 G=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Mr=new TextDecoder,zr=new TextEncoder;function pe(e){return G&&globalThis.Buffer.isBuffer(e)}function Ce(e){return e instanceof Uint8Array?pe(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var et=G?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):Ze(e,t,r):(e,t,r)=>r-t>64?Mr.decode(e.subarray(t,r)):Ze(e,t,r),tt=G?e=>e.length>64?globalThis.Buffer.from(e):We(e):e=>e.length>64?zr.encode(e):We(e),$=e=>Uint8Array.from(e),J=G?(e,t,r)=>pe(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),rt=G?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),Ce(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},nt=G?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function ot(e,t){if(pe(e)&&pe(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 We(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):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128)}return t}function Ze(e,t,r){let n=[];for(;t<r;){let o=e[t],i=null,u=o>239?4:o>223?3:o>191?2:1;if(t+u<=r){let f,h,g,m;switch(u){case 1:o<128&&(i=o);break;case 2:f=e[t+1],(f&192)===128&&(m=(o&31)<<6|f&63,m>127&&(i=m));break;case 3:f=e[t+1],h=e[t+2],(f&192)===128&&(h&192)===128&&(m=(o&15)<<12|(f&63)<<6|h&63,m>2047&&(m<55296||m>57343)&&(i=m));break;case 4:f=e[t+1],h=e[t+2],g=e[t+3],(f&192)===128&&(h&192)===128&&(g&192)===128&&(m=(o&15)<<18|(f&63)<<12|(h&63)<<6|g&63,m>65535&&m<1114112&&(i=m))}}i===null?(i=65533,u=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),t+=u}return Or(n)}var Ye=4096;function Or(e){let t=e.length;if(t<=Ye)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=Ye));return r}var Fr=256,re=class{constructor(t=Fr){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=nt(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=J(n,0,this.cursor)}else r=rt(this.chunks,this.cursor);return t&&this.reset(),r}};var d="CBOR decode error:",_e="CBOR encode error:",ne=[];ne[23]=1;ne[24]=2;ne[25]=3;ne[26]=5;ne[27]=9;function O(e,t,r){if(e.length-t<r)throw new Error(`${d} not enough data for type`)}var x=[24,256,65536,4294967296,BigInt("18446744073709551616")];function b(e,t,r){O(e,t,1);let n=e[t];if(r.strict===!0&&n<x[0])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);return n}function E(e,t,r){O(e,t,2);let n=e[t]<<8|e[t+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(e,t,r){O(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+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(e,t,r){O(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],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&i<x[3])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(r.allowBigInt===!0)return i;throw new Error(`${d} integers outside of the safe integer range are not supported`)}function it(e,t,r,n){return new a(s.uint,b(e,t+1,n),2)}function st(e,t,r,n){return new a(s.uint,E(e,t+1,n),3)}function ct(e,t,r,n){return new a(s.uint,U(e,t+1,n),5)}function at(e,t,r,n){return new a(s.uint,A(e,t+1,n),9)}function T(e,t){return y(e,0,t.value)}function y(e,t,r){if(r<x[0]){let n=Number(r);e.push([t|n])}else if(r<x[1]){let n=Number(r);e.push([t|24,n])}else if(r<x[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<x[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<x[4]){let o=[t|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),u=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=u&255,u=u>>8,o[3]=u&255,u=u>>8,o[2]=u&255,u=u>>8,o[1]=u&255,e.push(o)}else throw new Error(`${d} encountered BigInt larger than allowable range`)}}T.encodedSize=function(t){return y.encodedSize(t.value)};y.encodedSize=function(t){return t<x[0]?1:t<x[1]?2:t<x[2]?3:t<x[3]?5:9};T.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function ut(e,t,r,n){return new a(s.negint,-1-b(e,t+1,n),2)}function ft(e,t,r,n){return new a(s.negint,-1-E(e,t+1,n),3)}function dt(e,t,r,n){return new a(s.negint,-1-U(e,t+1,n),5)}var Ne=BigInt(-1),lt=BigInt(1);function pt(e,t,r,n){let o=A(e,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new a(s.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${d} integers outside of the safe integer range are not supported`);return new a(s.negint,Ne-BigInt(o),9)}function he(e,t){let r=t.value,n=typeof r=="bigint"?r*Ne-lt:r*-1-1;y(e,t.type.majorEncoded,n)}he.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*Ne-lt:r*-1-1;return n<x[0]?1:n<x[1]?2:n<x[2]?3:n<x[3]?5:9};he.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function oe(e,t,r,n){O(e,t,r+n);let o=J(e,t+r,t+r+n);return new a(s.bytes,o,r+n)}function ht(e,t,r,n){return oe(e,t,1,r)}function mt(e,t,r,n){return oe(e,t,2,b(e,t+1,n))}function xt(e,t,r,n){return oe(e,t,3,E(e,t+1,n))}function yt(e,t,r,n){return oe(e,t,5,U(e,t+1,n))}function gt(e,t,r,n){let o=A(e,t+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer bytes lengths not supported`);return oe(e,t,9,o)}function me(e){return e.encodedBytes===void 0&&(e.encodedBytes=e.type===s.string?tt(e.value):e.value),e.encodedBytes}function K(e,t){let r=me(t);y(e,t.type.majorEncoded,r.length),e.push(r)}K.encodedSize=function(t){let r=me(t);return y.encodedSize(r.length)+r.length};K.compareTokens=function(t,r){return Vr(me(t),me(r))};function Vr(e,t){return e.length<t.length?-1:e.length>t.length?1:ot(e,t)}function ie(e,t,r,n,o){let i=r+n;O(e,t,i);let u=new a(s.string,et(e,t+r,t+i),i);return o.retainStringBytes===!0&&(u.byteValue=J(e,t+r,t+i)),u}function wt(e,t,r,n){return ie(e,t,1,r,n)}function bt(e,t,r,n){return ie(e,t,2,b(e,t+1,n),n)}function Et(e,t,r,n){return ie(e,t,3,E(e,t+1,n),n)}function Ut(e,t,r,n){return ie(e,t,5,U(e,t+1,n),n)}function At(e,t,r,n){let o=A(e,t+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer string lengths not supported`);return ie(e,t,9,o,n)}var vt=K;function H(e,t,r,n){return new a(s.array,n,r)}function Tt(e,t,r,n){return H(e,t,1,r)}function kt(e,t,r,n){return H(e,t,2,b(e,t+1,n))}function St(e,t,r,n){return H(e,t,3,E(e,t+1,n))}function Bt(e,t,r,n){return H(e,t,5,U(e,t+1,n))}function It(e,t,r,n){let o=A(e,t+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer array lengths not supported`);return H(e,t,9,o)}function Ct(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${d} indefinite length items not allowed`);return H(e,t,1,1/0)}function xe(e,t){y(e,s.array.majorEncoded,t.value)}xe.compareTokens=T.compareTokens;xe.encodedSize=function(t){return y.encodedSize(t.value)};function X(e,t,r,n){return new a(s.map,n,r)}function _t(e,t,r,n){return X(e,t,1,r)}function Nt(e,t,r,n){return X(e,t,2,b(e,t+1,n))}function Dt(e,t,r,n){return X(e,t,3,E(e,t+1,n))}function $t(e,t,r,n){return X(e,t,5,U(e,t+1,n))}function Mt(e,t,r,n){let o=A(e,t+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer map lengths not supported`);return X(e,t,9,o)}function zt(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${d} indefinite length items not allowed`);return X(e,t,1,1/0)}function ye(e,t){y(e,s.map.majorEncoded,t.value)}ye.compareTokens=T.compareTokens;ye.encodedSize=function(t){return y.encodedSize(t.value)};function Ot(e,t,r,n){return new a(s.tag,r,1)}function Ft(e,t,r,n){return new a(s.tag,b(e,t+1,n),2)}function Lt(e,t,r,n){return new a(s.tag,E(e,t+1,n),3)}function Vt(e,t,r,n){return new a(s.tag,U(e,t+1,n),5)}function Rt(e,t,r,n){return new a(s.tag,A(e,t+1,n),9)}function ge(e,t){y(e,s.tag.majorEncoded,t.value)}ge.compareTokens=T.compareTokens;ge.encodedSize=function(t){return y.encodedSize(t.value)};var Jr=20,Kr=21,Hr=22,Xr=23;function Pt(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${d} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new a(s.null,null,1):new a(s.undefined,void 0,1)}function jt(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${d} indefinite length items not allowed`);return new a(s.break,void 0,1)}function De(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${d} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${d} Infinity values are not supported`)}return new a(s.float,e,t)}function qt(e,t,r,n){return De($e(e,t+1),3,n)}function Gt(e,t,r,n){return De(Me(e,t+1),5,n)}function Jt(e,t,r,n){return De(Qt(e,t+1),9,n)}function we(e,t,r){let n=t.value;if(n===!1)e.push([s.float.majorEncoded|Jr]);else if(n===!0)e.push([s.float.majorEncoded|Kr]);else if(n===null)e.push([s.float.majorEncoded|Hr]);else if(n===void 0)e.push([s.float.majorEncoded|Xr]);else{let o,i=!1;(!r||r.float64!==!0)&&(Ht(n),o=$e(I,1),n===o||Number.isNaN(n)?(I[0]=249,e.push(I.slice(0,3)),i=!0):(Xt(n),o=Me(I,1),n===o&&(I[0]=250,e.push(I.slice(0,5)),i=!0))),i||(Qr(n),o=Qt(I,1),I[0]=251,e.push(I.slice(0,9)))}}we.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){Ht(n);let o=$e(I,1);if(n===o||Number.isNaN(n))return 3;if(Xt(n),o=Me(I,1),n===o)return 5}return 9};var Kt=new ArrayBuffer(9),k=new DataView(Kt,1),I=new Uint8Array(Kt,0);function Ht(e){if(e===1/0)k.setUint16(0,31744,!1);else if(e===-1/0)k.setUint16(0,64512,!1);else if(Number.isNaN(e))k.setUint16(0,32256,!1);else{k.setFloat32(0,e);let t=k.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)k.setUint16(0,31744,!1);else if(r===0)k.setUint16(0,(e&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?k.setUint16(0,0):o<-14?k.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):k.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function $e(e,t){if(e.length-t<2)throw new Error(`${d} 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,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,r&32768?-i:i}function Xt(e){k.setFloat32(0,e,!1)}function Me(e,t){if(e.length-t<4)throw new Error(`${d} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function Qr(e){k.setFloat64(0,e,!1)}function Qt(e,t){if(e.length-t<8)throw new Error(`${d} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}we.compareTokens=T.compareTokens;function l(e,t,r){throw new Error(`${d} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function be(e){return()=>{throw new Error(`${d} ${e}`)}}var c=[];for(let e=0;e<=23;e++)c[e]=l;c[24]=it;c[25]=st;c[26]=ct;c[27]=at;c[28]=l;c[29]=l;c[30]=l;c[31]=l;for(let e=32;e<=55;e++)c[e]=l;c[56]=ut;c[57]=ft;c[58]=dt;c[59]=pt;c[60]=l;c[61]=l;c[62]=l;c[63]=l;for(let e=64;e<=87;e++)c[e]=ht;c[88]=mt;c[89]=xt;c[90]=yt;c[91]=gt;c[92]=l;c[93]=l;c[94]=l;c[95]=be("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)c[e]=wt;c[120]=bt;c[121]=Et;c[122]=Ut;c[123]=At;c[124]=l;c[125]=l;c[126]=l;c[127]=be("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)c[e]=Tt;c[152]=kt;c[153]=St;c[154]=Bt;c[155]=It;c[156]=l;c[157]=l;c[158]=l;c[159]=Ct;for(let e=160;e<=183;e++)c[e]=_t;c[184]=Nt;c[185]=Dt;c[186]=$t;c[187]=Mt;c[188]=l;c[189]=l;c[190]=l;c[191]=zt;for(let e=192;e<=215;e++)c[e]=Ot;c[216]=Ft;c[217]=Lt;c[218]=Vt;c[219]=Rt;c[220]=l;c[221]=l;c[222]=l;c[223]=l;for(let e=224;e<=243;e++)c[e]=be("simple values are not supported");c[244]=l;c[245]=l;c[246]=l;c[247]=Pt;c[248]=be("simple values are not supported");c[249]=qt;c[250]=Gt;c[251]=Jt;c[252]=l;c[253]=l;c[254]=l;c[255]=jt;var C=[];for(let e=0;e<24;e++)C[e]=new a(s.uint,e,1);for(let e=-1;e>=-24;e--)C[31-e]=new a(s.negint,e,1);C[64]=new a(s.bytes,new Uint8Array(0),1);C[96]=new a(s.string,"",1);C[128]=new a(s.array,0,1);C[160]=new a(s.map,0,1);C[244]=new a(s.false,!1,1);C[245]=new a(s.true,!0,1);C[246]=new a(s.null,null,1);function Wt(e){switch(e.type){case s.false:return $([244]);case s.true:return $([245]);case s.null:return $([246]);case s.bytes:return e.value.length?void 0:$([64]);case s.string:return e.value===""?$([96]):void 0;case s.array:return e.value===0?$([128]):void 0;case s.map:return e.value===0?$([160]):void 0;case s.uint:return e.value<24?$([Number(e.value)]):void 0;case s.negint:if(e.value>=-24)return $([31-Number(e.value)])}}var Zr={float64:!1,mapSorter:tn,quickEncodeToken:Wt};function Yr(){let e=[];return e[s.uint.major]=T,e[s.negint.major]=he,e[s.bytes.major]=K,e[s.string.major]=vt,e[s.array.major]=xe,e[s.map.major]=ye,e[s.tag.major]=ge,e[s.float.major]=we,e}var Zt=Yr(),ze=new re,Ue=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(`${_e} object contains circular references`);return new e(r,t)}},V={null:new a(s.null,null),undefined:new a(s.undefined,void 0),true:new a(s.true,!0),false:new a(s.false,!1),emptyArray:new a(s.array,0),emptyMap:new a(s.map,0)},R={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new a(s.float,e):e>=0?new a(s.uint,e):new a(s.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new a(s.uint,e):new a(s.negint,e)},Uint8Array(e,t,r,n){return new a(s.bytes,e)},string(e,t,r,n){return new a(s.string,e)},boolean(e,t,r,n){return e?V.true:V.false},null(e,t,r,n){return V.null},undefined(e,t,r,n){return V.undefined},ArrayBuffer(e,t,r,n){return new a(s.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new a(s.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[V.emptyArray,new a(s.break)]:V.emptyArray;n=Ue.createCheck(n,e);let o=[],i=0;for(let u of e)o[i++]=Ee(u,r,n);return r.addBreakTokens?[new a(s.array,e.length),o,new a(s.break)]:[new a(s.array,e.length),o]},Object(e,t,r,n){let o=t!=="Object",i=o?e.keys():Object.keys(e),u=o?e.size:i.length;if(!u)return r.addBreakTokens===!0?[V.emptyMap,new a(s.break)]:V.emptyMap;n=Ue.createCheck(n,e);let f=[],h=0;for(let g of i)f[h++]=[Ee(g,r,n),Ee(o?e.get(g):e[g],r,n)];return en(f,r),r.addBreakTokens?[new a(s.map,u),f,new a(s.break)]:[new a(s.map,u),f]}};R.Map=R.Object;R.Buffer=R.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))R[`${e}Array`]=R.DataView;function Ee(e,t={},r){let n=Qe(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||R[n];if(typeof o=="function"){let u=o(e,n,t,r);if(u!=null)return u}let i=R[n];if(!i)throw new Error(`${_e} unsupported type: ${n}`);return i(e,n,t,r)}function en(e,t){t.mapSorter&&e.sort(t.mapSorter)}function tn(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,i=Zt[o].compareTokens(r,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function Yt(e,t,r,n){if(Array.isArray(t))for(let o of t)Yt(e,o,r,n);else r[t.type.major](e,t,n)}function rn(e,t,r){let n=Ee(e,r);if(!Array.isArray(n)&&r.quickEncodeToken){let o=r.quickEncodeToken(n);if(o)return o;let i=t[n.type.major];if(i.encodedSize){let u=i.encodedSize(n,r),f=new re(u);if(i(f,n,r),f.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return Ce(f.chunks[0])}}return ze.reset(),Yt(ze,n,t,r),ze.toBytes(!0)}function Oe(e,t){return t=Object.assign({},Zr,t),rn(e,Zt,t)}var nn={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Ae=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=C[t];if(r===void 0){let n=c[t];if(!n)throw new Error(`${d} 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}},se=Symbol.for("DONE"),ve=Symbol.for("BREAK");function on(e,t,r){let n=[];for(let o=0;o<e.value;o++){let i=Q(t,r);if(i===ve){if(e.value===1/0)break;throw new Error(`${d} got unexpected break to lengthed array`)}if(i===se)throw new Error(`${d} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=i}return n}function sn(e,t,r){let n=r.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let u=0;u<e.value;u++){let f=Q(t,r);if(f===ve){if(e.value===1/0)break;throw new Error(`${d} got unexpected break to lengthed map`)}if(f===se)throw new Error(`${d} found map but not enough entries (got ${u} [no key], expected ${e.value})`);if(n!==!0&&typeof f!="string")throw new Error(`${d} non-string keys not supported (got ${typeof f})`);if(r.rejectDuplicateMapKeys===!0&&(n&&i.has(f)||!n&&f in o))throw new Error(`${d} found repeat map key "${f}"`);let h=Q(t,r);if(h===se)throw new Error(`${d} found map but not enough entries (got ${u} [no value], expected ${e.value})`);n?i.set(f,h):o[f]=h}return n?i:o}function Q(e,t){if(e.done())return se;let r=e.next();if(r.type===s.break)return ve;if(r.type.terminal)return r.value;if(r.type===s.array)return on(r,e,t);if(r.type===s.map)return sn(r,e,t);if(r.type===s.tag){if(t.tags&&typeof t.tags[r.value]=="function"){let n=Q(e,t);return t.tags[r.value](n)}throw new Error(`${d} tag not supported (${r.value})`)}throw new Error("unsupported")}function er(e,t){if(!(e instanceof Uint8Array))throw new Error(`${d} data to decode must be a Uint8Array`);t=Object.assign({},nn,t);let r=t.tokenizer||new Ae(e,t),n=Q(r,t);if(n===se)throw new Error(`${d} did not find any content to decode`);if(n===ve)throw new Error(`${d} got unexpected break`);return[n,e.subarray(r.pos())]}function Fe(e,t){let[r,n]=er(e,t);if(n.length>0)throw new Error(`${d} too many terminals, data makes no sense`);return r}var Ho=new Uint8Array(0);function tr(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 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 an(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 i=e.charAt(o),u=i.charCodeAt(0);if(r[u]!==255)throw new TypeError(i+" is ambiguous");r[u]=o}var f=e.length,h=e.charAt(0),g=Math.log(f)/Math.log(256),m=Math.log(256)/Math.log(f);function Be(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var w=0,P=0,S=0,_=p.length;S!==_&&p[S]===0;)S++,w++;for(var N=(_-S)*m+1>>>0,v=new Uint8Array(N);S!==_;){for(var D=p[S],L=0,B=N-1;(D!==0||L<P)&&B!==-1;B--,L++)D+=256*v[B]>>>0,v[B]=D%f>>>0,D=D/f>>>0;if(D!==0)throw new Error("Non-zero carry");P=L,S++}for(var z=N-P;z!==N&&v[z]===0;)z++;for(var le=h.repeat(w);z<N;++z)le+=e.charAt(v[z]);return le}function de(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var w=0;if(p[w]!==" "){for(var P=0,S=0;p[w]===h;)P++,w++;for(var _=(p.length-w)*g+1>>>0,N=new Uint8Array(_);p[w];){var v=r[p.charCodeAt(w)];if(v===255)return;for(var D=0,L=_-1;(v!==0||D<S)&&L!==-1;L--,D++)v+=f*N[L]>>>0,N[L]=v%256>>>0,v=v/256>>>0;if(v!==0)throw new Error("Non-zero carry");S=D,w++}if(p[w]!==" "){for(var B=_-S;B!==_&&N[B]===0;)B++;for(var z=new Uint8Array(P+(_-B)),le=P;B!==_;)z[le++]=N[B++];return z}}}function vr(p){var w=de(p);if(w)return w;throw new Error(`Non-${t} character`)}return{encode:Be,decodeUnsafe:de,decode:vr}}var un=an,fn=un,rr=fn;var Le=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")}},Ve=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 nr(this,t)}},Re=class{decoders;constructor(t){this.decoders=t}or(t){return nr(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 nr(e,t){return new Re({...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 Le(t,r,n),this.decoder=new Ve(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function or({name:e,prefix:t,encode:r,decode:n}){return new Pe(e,t,r,n)}function Z({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=rr(r,e);return or({prefix:t,name:e,encode:n,decode:i=>W(o(i))})}function dn(e,t,r,n){let o=e.length;for(;e[o-1]==="=";)--o;let i=new Uint8Array(o*r/8|0),u=0,f=0,h=0;for(let g=0;g<o;++g){let m=t[e[g]];if(m===void 0)throw new SyntaxError(`Non-${n} character`);f=f<<r|m,u+=r,u>=8&&(u-=8,i[h++]=255&f>>u)}if(u>=r||(255&f<<8-u)!==0)throw new SyntaxError("Unexpected end of data");return i}function ln(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,i="",u=0,f=0;for(let h=0;h<e.length;++h)for(f=f<<8|e[h],u+=8;u>r;)u-=r,i+=t[o&f>>u];if(u!==0&&(i+=t[o&f<<r-u]),n)for(;(i.length*r&7)!==0;)i+="=";return i}function pn(e){let t={};for(let r=0;r<e.length;++r)t[e[r]]=r;return t}function M({name:e,prefix:t,bitsPerChar:r,alphabet:n}){let o=pn(n);return or({prefix:t,name:e,encode(i){return ln(i,n,r)},decode(i){return dn(i,o,r,e)}})}var ce=M({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),ti=M({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),ri=M({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ni=M({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),oi=M({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ii=M({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),si=M({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),ci=M({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ai=M({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Te=Z({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),di=Z({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var F=Z({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),hi=Z({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var hn=cr,ir=128,mn=127,xn=~mn,yn=Math.pow(2,31);function cr(e,t,r){t=t||[],r=r||0;for(var n=r;e>=yn;)t[r++]=e&255|ir,e/=128;for(;e&xn;)t[r++]=e&255|ir,e>>>=7;return t[r]=e|0,cr.bytes=r-n+1,t}var gn=je,wn=128,sr=127;function je(e,n){var r=0,n=n||0,o=0,i=n,u,f=e.length;do{if(i>=f)throw je.bytes=0,new RangeError("Could not decode varint");u=e[i++],r+=o<28?(u&sr)<<o:(u&sr)*Math.pow(2,o),o+=7}while(u>=wn);return je.bytes=i-n,r}var bn=Math.pow(2,7),En=Math.pow(2,14),Un=Math.pow(2,21),An=Math.pow(2,28),vn=Math.pow(2,35),Tn=Math.pow(2,42),kn=Math.pow(2,49),Sn=Math.pow(2,56),Bn=Math.pow(2,63),In=function(e){return e<bn?1:e<En?2:e<Un?3:e<An?4:e<vn?5:e<Tn?6:e<kn?7:e<Sn?8:e<Bn?9:10},Cn={encode:hn,decode:gn,encodingLength:In},_n=Cn,ae=_n;function ue(e,t=0){return[ae.decode(e,t),ae.decode.bytes]}function Y(e,t,r=0){return ae.encode(e,t,r),t}function ee(e){return ae.encodingLength(e)}function ke(e,t){let r=t.byteLength,n=ee(e),o=n+ee(r),i=new Uint8Array(o+r);return Y(e,i,0),Y(r,i,n),i.set(t,o),new te(e,r,t,i)}function ur(e){let t=W(e),[r,n]=ue(t),[o,i]=ue(t.subarray(n)),u=t.subarray(n+i);if(u.byteLength!==o)throw new Error("Incorrect length");return new te(r,o,u,t)}function fr(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&tr(e.bytes,r.bytes)}}var te=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function lr(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return Dn(r,qe(e),t??F.encoder);default:return $n(r,qe(e),t??ce.encoder)}}var pr=new WeakMap;function qe(e){let t=pr.get(e);if(t==null){let r=new Map;return pr.set(e,r),r}return t}var q=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!==fe)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Mn)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=ke(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&&fr(t.multihash,n.multihash)}toString(t){return lr(this,t)}toJSON(){return{"/":lr(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:i,bytes:u}=r;return new e(n,o,i,u??hr(n,o,i.bytes))}else if(r[zn]===!0){let{version:n,multihash:o,code:i}=r,u=ur(o);return e.create(n,i,u)}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!==fe)throw new Error(`Version 0 CID must use dag-pb (code: ${fe}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=hr(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,fe,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 i=o.subarray(r.multihashSize-r.digestSize),u=new te(r.multihashCode,r.digestSize,i,o);return[r.version===0?e.createV0(u):e.createV1(r.codec,u),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[Be,de]=ue(t.subarray(r));return r+=de,Be},o=n(),i=fe;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let u=r,f=n(),h=n(),g=r+h,m=g-u;return{version:o,codec:i,multihashCode:f,digestSize:h,multihashSize:m,size:g}}static parse(t,r){let[n,o]=Nn(t,r),i=e.decode(o);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return qe(i).set(n,t),i}};function Nn(e,t){switch(e[0]){case"Q":{let r=t??F;return[F.prefix,r.decode(`${F.prefix}${e}`)]}case F.prefix:{let r=t??F;return[F.prefix,r.decode(e)]}case ce.prefix:{let r=t??ce;return[ce.prefix,r.decode(e)]}case Te.prefix:{let r=t??Te;return[Te.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 Dn(e,t,r){let{prefix:n}=r;if(n!==F.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let i=r.encode(e).slice(1);return t.set(n,i),i}else return o}function $n(e,t,r){let{prefix:n}=r,o=t.get(n);if(o==null){let i=r.encode(e);return t.set(n,i),i}else return o}var fe=112,Mn=18;function hr(e,t,r){let n=ee(e),o=n+ee(t),i=new Uint8Array(o+r.byteLength);return Y(e,i,0),Y(t,i,n),i.set(r,o),i}var zn=Symbol.for("@ipld/js-cid/CID");var mr=42;function On(e){return e instanceof ArrayBuffer?new Uint8Array(e,0,e.byteLength):e}function Fn(e){if(e.asCID!==e&&e["/"]!==e.bytes)return null;let t=q.asCID(e);if(!t)return null;let r=new Uint8Array(t.bytes.byteLength+1);return r.set(t.bytes,1),[new a(s.tag,mr),new a(s.bytes,r)]}function Ln(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function Vn(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 Rn(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 Ge={float64:!0,typeEncoders:{Map:Rn,Object:Fn,undefined:Ln,number:Vn}},ki={...Ge,typeEncoders:{...Ge.typeEncoders}};function Pn(e){if(e[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return q.decode(e.subarray(1))}var Se={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:[]};Se.tags[mr]=Pn;var Si={...Se,tags:Se.tags.slice()};var xr=113,yr=e=>Oe(e,Ge),gr=e=>Fe(On(e),Se);function wr(e=0){return new Uint8Array(e)}function Je(e,t){t==null&&(t=e.reduce((o,i)=>o+i.length,0));let r=wr(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}function qn(e){return e[Symbol.asyncIterator]!=null}function Gn(e){if(qn(e))return(async()=>{let n=new Uint8Array(0);for await(let o of e)n=Je([n,o],n.length+o.length);return n})();let t=[],r=0;for(let n of e)t.push(n),r+=n.byteLength;return Je(t,r)}var br=Gn;var Jn=20;function He({name:e,code:t,encode:r,minDigestLength:n,maxDigestLength:o}){return new Ke(e,t,r,n,o)}var Ke=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,r,n,o,i){this.name=t,this.code=r,this.encode=n,this.minDigestLength=o??Jn,this.maxDigestLength=i}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?Er(n,this.code,r?.truncate):n.then(o=>Er(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function Er(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 ke(t,e)}function Ur(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var Ar=He({name:"sha2-256",code:18,encode:Ur("SHA-256")}),Fi=He({name:"sha2-512",code:19,encode:Ur("SHA-512")});var Xe=class{components;constructor(t){this.components=t}async add(t,r={}){let n=yr(t),o=await(r.hasher??Ar).digest(n),i=q.createV1(xr,o);return await this.components.blockstore.put(i,n,r),i}async get(t,r={}){let n=await br(this.components.blockstore.get(t,r));return gr(n)}};function Kn(e){return new Xe(e)}return Cr(Hn);})();
|
|
2
|
+
"use strict";var HeliaDagCbor=(()=>{var _e=Object.defineProperty;var Tr=Object.getOwnPropertyDescriptor;var Sr=Object.getOwnPropertyNames;var Br=Object.prototype.hasOwnProperty;var Ir=(e,t)=>{for(var r in t)_e(e,r,{get:t[r],enumerable:!0})},Cr=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Sr(t))!Br.call(e,o)&&o!==r&&_e(e,o,{get:()=>t[o],enumerable:!(n=Tr(t,o))||n.enumerable});return e};var _r=e=>Cr(_e({},"__esModule",{value:!0}),e);var Xn={};Ir(Xn,{dagCbor:()=>Kn});var Wn=new Uint8Array(0);function Ze(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 G(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 Nr(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 i=e.charAt(o),u=i.charCodeAt(0);if(r[u]!==255)throw new TypeError(i+" is ambiguous");r[u]=o}var f=e.length,h=e.charAt(0),g=Math.log(f)/Math.log(256),m=Math.log(256)/Math.log(f);function Ce(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var w=0,P=0,S=0,_=p.length;S!==_&&p[S]===0;)S++,w++;for(var N=(_-S)*m+1>>>0,v=new Uint8Array(N);S!==_;){for(var D=p[S],L=0,B=N-1;(D!==0||L<P)&&B!==-1;B--,L++)D+=256*v[B]>>>0,v[B]=D%f>>>0,D=D/f>>>0;if(D!==0)throw new Error("Non-zero carry");P=L,S++}for(var z=N-P;z!==N&&v[z]===0;)z++;for(var le=h.repeat(w);z<N;++z)le+=e.charAt(v[z]);return le}function de(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var w=0;if(p[w]!==" "){for(var P=0,S=0;p[w]===h;)P++,w++;for(var _=(p.length-w)*g+1>>>0,N=new Uint8Array(_);p[w];){var v=r[p.charCodeAt(w)];if(v===255)return;for(var D=0,L=_-1;(v!==0||D<S)&&L!==-1;L--,D++)v+=f*N[L]>>>0,N[L]=v%256>>>0,v=v/256>>>0;if(v!==0)throw new Error("Non-zero carry");S=D,w++}if(p[w]!==" "){for(var B=_-S;B!==_&&N[B]===0;)B++;for(var z=new Uint8Array(P+(_-B)),le=P;B!==_;)z[le++]=N[B++];return z}}}function kr(p){var w=de(p);if(w)return w;throw new Error(`Non-${t} character`)}return{encode:Ce,decodeUnsafe:de,decode:kr}}var Dr=Nr,$r=Dr,Ye=$r;var Ne=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")}},De=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 et(this,t)}},$e=class{decoders;constructor(t){this.decoders=t}or(t){return et(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 et(e,t){return new $e({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var Me=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 Ne(t,r,n),this.decoder=new De(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function tt({name:e,prefix:t,encode:r,decode:n}){return new Me(e,t,r,n)}function H({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=Ye(r,e);return tt({prefix:t,name:e,encode:n,decode:i=>G(o(i))})}function Mr(e,t,r,n){let o=e.length;for(;e[o-1]==="=";)--o;let i=new Uint8Array(o*r/8|0),u=0,f=0,h=0;for(let g=0;g<o;++g){let m=t[e[g]];if(m===void 0)throw new SyntaxError(`Non-${n} character`);f=f<<r|m,u+=r,u>=8&&(u-=8,i[h++]=255&f>>u)}if(u>=r||(255&f<<8-u)!==0)throw new SyntaxError("Unexpected end of data");return i}function zr(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,i="",u=0,f=0;for(let h=0;h<e.length;++h)for(f=f<<8|e[h],u+=8;u>r;)u-=r,i+=t[o&f>>u];if(u!==0&&(i+=t[o&f<<r-u]),n)for(;(i.length*r&7)!==0;)i+="=";return i}function Or(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=Or(n);return tt({prefix:t,name:e,encode(i){return zr(i,n,r)},decode(i){return Mr(i,o,r,e)}})}var re=$({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),oo=$({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),io=$({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),so=$({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),co=$({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ao=$({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),uo=$({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),fo=$({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),lo=$({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var pe=H({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),mo=H({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var O=H({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),go=H({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Fr=ot,rt=128,Lr=127,Vr=~Lr,Rr=Math.pow(2,31);function ot(e,t,r){t=t||[],r=r||0;for(var n=r;e>=Rr;)t[r++]=e&255|rt,e/=128;for(;e&Vr;)t[r++]=e&255|rt,e>>>=7;return t[r]=e|0,ot.bytes=r-n+1,t}var Pr=ze,jr=128,nt=127;function ze(e,n){var r=0,n=n||0,o=0,i=n,u,f=e.length;do{if(i>=f)throw ze.bytes=0,new RangeError("Could not decode varint");u=e[i++],r+=o<28?(u&nt)<<o:(u&nt)*Math.pow(2,o),o+=7}while(u>=jr);return ze.bytes=i-n,r}var qr=Math.pow(2,7),Gr=Math.pow(2,14),Hr=Math.pow(2,21),Jr=Math.pow(2,28),Kr=Math.pow(2,35),Xr=Math.pow(2,42),Qr=Math.pow(2,49),Wr=Math.pow(2,56),Zr=Math.pow(2,63),Yr=function(e){return e<qr?1:e<Gr?2:e<Hr?3:e<Jr?4:e<Kr?5:e<Xr?6:e<Qr?7:e<Wr?8:e<Zr?9:10},en={encode:Fr,decode:Pr,encodingLength:Yr},tn=en,ne=tn;function oe(e,t=0){return[ne.decode(e,t),ne.decode.bytes]}function J(e,t,r=0){return ne.encode(e,t,r),t}function K(e){return ne.encodingLength(e)}function he(e,t){let r=t.byteLength,n=K(e),o=n+K(r),i=new Uint8Array(o+r);return J(e,i,0),J(r,i,n),i.set(t,o),new X(e,r,t,i)}function st(e){let t=G(e),[r,n]=oe(t),[o,i]=oe(t.subarray(n)),u=t.subarray(n+i);if(u.byteLength!==o)throw new Error("Incorrect length");return new X(r,o,u,t)}function ct(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Ze(e.bytes,r.bytes)}}var X=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function ut(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return nn(r,Oe(e),t??O.encoder);default:return on(r,Oe(e),t??re.encoder)}}var ft=new WeakMap;function Oe(e){let t=ft.get(e);if(t==null){let r=new Map;return ft.set(e,r),r}return t}var j=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!==ie)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==sn)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=he(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&&ct(t.multihash,n.multihash)}toString(t){return ut(this,t)}toJSON(){return{"/":ut(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:i,bytes:u}=r;return new e(n,o,i,u??dt(n,o,i.bytes))}else if(r[cn]===!0){let{version:n,multihash:o,code:i}=r,u=st(o);return e.create(n,i,u)}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!==ie)throw new Error(`Version 0 CID must use dag-pb (code: ${ie}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=dt(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,ie,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=G(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),u=new X(r.multihashCode,r.digestSize,i,o);return[r.version===0?e.createV0(u):e.createV1(r.codec,u),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[Ce,de]=oe(t.subarray(r));return r+=de,Ce},o=n(),i=ie;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let u=r,f=n(),h=n(),g=r+h,m=g-u;return{version:o,codec:i,multihashCode:f,digestSize:h,multihashSize:m,size:g}}static parse(t,r){let[n,o]=rn(t,r),i=e.decode(o);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Oe(i).set(n,t),i}};function rn(e,t){switch(e[0]){case"Q":{let r=t??O;return[O.prefix,r.decode(`${O.prefix}${e}`)]}case O.prefix:{let r=t??O;return[O.prefix,r.decode(e)]}case re.prefix:{let r=t??re;return[re.prefix,r.decode(e)]}case pe.prefix:{let r=t??pe;return[pe.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 nn(e,t,r){let{prefix:n}=r;if(n!==O.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let i=r.encode(e).slice(1);return t.set(n,i),i}else return o}function on(e,t,r){let{prefix:n}=r,o=t.get(n);if(o==null){let i=r.encode(e);return t.set(n,i),i}else return o}var ie=112,sn=18;function dt(e,t,r){let n=K(e),o=n+K(t),i=new Uint8Array(o+r.byteLength);return J(e,i,0),J(t,i,n),i.set(r,o),i}var cn=Symbol.for("@ipld/js-cid/CID");var me=class extends Error{static name="InvalidCodecError";constructor(t="Invalid codec"){super(t),this.name="InvalidCodecError"}};var an=["string","number","bigint","symbol"],un=["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 lt(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(an.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(fn(e))return"Buffer";let r=dn(e);return r||"Object"}function fn(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function dn(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(un.includes(t))return t}var s=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}};s.uint=new s(0,"uint",!0);s.negint=new s(1,"negint",!0);s.bytes=new s(2,"bytes",!0);s.string=new s(3,"string",!0);s.array=new s(4,"array",!1);s.map=new s(5,"map",!1);s.tag=new s(6,"tag",!1);s.float=new s(7,"float",!0);s.false=new s(7,"false",!0);s.true=new s(7,"true",!0);s.null=new s(7,"null",!0);s.undefined=new s(7,"undefined",!0);s.break=new s(7,"break",!0);var a=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 Q=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",ln=new TextDecoder,pn=new TextEncoder;function xe(e){return Q&&globalThis.Buffer.isBuffer(e)}function Fe(e){return e instanceof Uint8Array?xe(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var xt=Q?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):ht(e,t,r):(e,t,r)=>r-t>64?ln.decode(e.subarray(t,r)):ht(e,t,r),yt=Q?e=>e.length>64?globalThis.Buffer.from(e):pt(e):e=>e.length>64?pn.encode(e):pt(e),M=e=>Uint8Array.from(e),W=Q?(e,t,r)=>xe(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),gt=Q?(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},wt=Q?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function bt(e,t){if(xe(e)&&xe(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 pt(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):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128)}return t}function ht(e,t,r){let n=[];for(;t<r;){let o=e[t],i=null,u=o>239?4:o>223?3:o>191?2:1;if(t+u<=r){let f,h,g,m;switch(u){case 1:o<128&&(i=o);break;case 2:f=e[t+1],(f&192)===128&&(m=(o&31)<<6|f&63,m>127&&(i=m));break;case 3:f=e[t+1],h=e[t+2],(f&192)===128&&(h&192)===128&&(m=(o&15)<<12|(f&63)<<6|h&63,m>2047&&(m<55296||m>57343)&&(i=m));break;case 4:f=e[t+1],h=e[t+2],g=e[t+3],(f&192)===128&&(h&192)===128&&(g&192)===128&&(m=(o&15)<<18|(f&63)<<12|(h&63)<<6|g&63,m>65535&&m<1114112&&(i=m))}}i===null?(i=65533,u=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),t+=u}return hn(n)}var mt=4096;function hn(e){let t=e.length;if(t<=mt)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=mt));return r}var mn=256,se=class{constructor(t=mn){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=wt(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=W(n,0,this.cursor)}else r=gt(this.chunks,this.cursor);return t&&this.reset(),r}};var d="CBOR decode error:",Le="CBOR encode error:",ce=[];ce[23]=1;ce[24]=2;ce[25]=3;ce[26]=5;ce[27]=9;function F(e,t,r){if(e.length-t<r)throw new Error(`${d} not enough data for type`)}var x=[24,256,65536,4294967296,BigInt("18446744073709551616")];function b(e,t,r){F(e,t,1);let n=e[t];if(r.strict===!0&&n<x[0])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);return n}function E(e,t,r){F(e,t,2);let n=e[t]<<8|e[t+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(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<x[2])throw new Error(`${d} 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],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&i<x[3])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(r.allowBigInt===!0)return i;throw new Error(`${d} integers outside of the safe integer range are not supported`)}function Et(e,t,r,n){return new a(s.uint,b(e,t+1,n),2)}function Ut(e,t,r,n){return new a(s.uint,E(e,t+1,n),3)}function At(e,t,r,n){return new a(s.uint,U(e,t+1,n),5)}function vt(e,t,r,n){return new a(s.uint,A(e,t+1,n),9)}function k(e,t){return y(e,0,t.value)}function y(e,t,r){if(r<x[0]){let n=Number(r);e.push([t|n])}else if(r<x[1]){let n=Number(r);e.push([t|24,n])}else if(r<x[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<x[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<x[4]){let o=[t|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),u=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=u&255,u=u>>8,o[3]=u&255,u=u>>8,o[2]=u&255,u=u>>8,o[1]=u&255,e.push(o)}else throw new Error(`${d} encountered BigInt larger than allowable range`)}}k.encodedSize=function(t){return y.encodedSize(t.value)};y.encodedSize=function(t){return t<x[0]?1:t<x[1]?2:t<x[2]?3:t<x[3]?5:9};k.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function kt(e,t,r,n){return new a(s.negint,-1-b(e,t+1,n),2)}function Tt(e,t,r,n){return new a(s.negint,-1-E(e,t+1,n),3)}function St(e,t,r,n){return new a(s.negint,-1-U(e,t+1,n),5)}var Ve=BigInt(-1),Bt=BigInt(1);function It(e,t,r,n){let o=A(e,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new a(s.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${d} integers outside of the safe integer range are not supported`);return new a(s.negint,Ve-BigInt(o),9)}function ye(e,t){let r=t.value,n=typeof r=="bigint"?r*Ve-Bt:r*-1-1;y(e,t.type.majorEncoded,n)}ye.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*Ve-Bt:r*-1-1;return n<x[0]?1:n<x[1]?2:n<x[2]?3:n<x[3]?5:9};ye.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function ae(e,t,r,n){F(e,t,r+n);let o=W(e,t+r,t+r+n);return new a(s.bytes,o,r+n)}function Ct(e,t,r,n){return ae(e,t,1,r)}function _t(e,t,r,n){return ae(e,t,2,b(e,t+1,n))}function Nt(e,t,r,n){return ae(e,t,3,E(e,t+1,n))}function Dt(e,t,r,n){return ae(e,t,5,U(e,t+1,n))}function $t(e,t,r,n){let o=A(e,t+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer bytes lengths not supported`);return ae(e,t,9,o)}function ge(e){return e.encodedBytes===void 0&&(e.encodedBytes=e.type===s.string?yt(e.value):e.value),e.encodedBytes}function Z(e,t){let r=ge(t);y(e,t.type.majorEncoded,r.length),e.push(r)}Z.encodedSize=function(t){let r=ge(t);return y.encodedSize(r.length)+r.length};Z.compareTokens=function(t,r){return yn(ge(t),ge(r))};function yn(e,t){return e.length<t.length?-1:e.length>t.length?1:bt(e,t)}function ue(e,t,r,n,o){let i=r+n;F(e,t,i);let u=new a(s.string,xt(e,t+r,t+i),i);return o.retainStringBytes===!0&&(u.byteValue=W(e,t+r,t+i)),u}function Mt(e,t,r,n){return ue(e,t,1,r,n)}function zt(e,t,r,n){return ue(e,t,2,b(e,t+1,n),n)}function Ot(e,t,r,n){return ue(e,t,3,E(e,t+1,n),n)}function Ft(e,t,r,n){return ue(e,t,5,U(e,t+1,n),n)}function Lt(e,t,r,n){let o=A(e,t+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer string lengths not supported`);return ue(e,t,9,o,n)}var Vt=Z;function Y(e,t,r,n){return new a(s.array,n,r)}function Rt(e,t,r,n){return Y(e,t,1,r)}function Pt(e,t,r,n){return Y(e,t,2,b(e,t+1,n))}function jt(e,t,r,n){return Y(e,t,3,E(e,t+1,n))}function qt(e,t,r,n){return Y(e,t,5,U(e,t+1,n))}function Gt(e,t,r,n){let o=A(e,t+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer array lengths not supported`);return Y(e,t,9,o)}function Ht(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${d} indefinite length items not allowed`);return Y(e,t,1,1/0)}function we(e,t){y(e,s.array.majorEncoded,t.value)}we.compareTokens=k.compareTokens;we.encodedSize=function(t){return y.encodedSize(t.value)};function ee(e,t,r,n){return new a(s.map,n,r)}function Jt(e,t,r,n){return ee(e,t,1,r)}function Kt(e,t,r,n){return ee(e,t,2,b(e,t+1,n))}function Xt(e,t,r,n){return ee(e,t,3,E(e,t+1,n))}function Qt(e,t,r,n){return ee(e,t,5,U(e,t+1,n))}function Wt(e,t,r,n){let o=A(e,t+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer map lengths not supported`);return ee(e,t,9,o)}function Zt(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${d} indefinite length items not allowed`);return ee(e,t,1,1/0)}function be(e,t){y(e,s.map.majorEncoded,t.value)}be.compareTokens=k.compareTokens;be.encodedSize=function(t){return y.encodedSize(t.value)};function Yt(e,t,r,n){return new a(s.tag,r,1)}function er(e,t,r,n){return new a(s.tag,b(e,t+1,n),2)}function tr(e,t,r,n){return new a(s.tag,E(e,t+1,n),3)}function rr(e,t,r,n){return new a(s.tag,U(e,t+1,n),5)}function nr(e,t,r,n){return new a(s.tag,A(e,t+1,n),9)}function Ee(e,t){y(e,s.tag.majorEncoded,t.value)}Ee.compareTokens=k.compareTokens;Ee.encodedSize=function(t){return y.encodedSize(t.value)};var An=20,vn=21,kn=22,Tn=23;function or(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${d} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new a(s.null,null,1):new a(s.undefined,void 0,1)}function ir(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${d} indefinite length items not allowed`);return new a(s.break,void 0,1)}function Re(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${d} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${d} Infinity values are not supported`)}return new a(s.float,e,t)}function sr(e,t,r,n){return Re(Pe(e,t+1),3,n)}function cr(e,t,r,n){return Re(je(e,t+1),5,n)}function ar(e,t,r,n){return Re(lr(e,t+1),9,n)}function Ue(e,t,r){let n=t.value;if(n===!1)e.push([s.float.majorEncoded|An]);else if(n===!0)e.push([s.float.majorEncoded|vn]);else if(n===null)e.push([s.float.majorEncoded|kn]);else if(n===void 0)e.push([s.float.majorEncoded|Tn]);else{let o,i=!1;(!r||r.float64!==!0)&&(fr(n),o=Pe(I,1),n===o||Number.isNaN(n)?(I[0]=249,e.push(I.slice(0,3)),i=!0):(dr(n),o=je(I,1),n===o&&(I[0]=250,e.push(I.slice(0,5)),i=!0))),i||(Sn(n),o=lr(I,1),I[0]=251,e.push(I.slice(0,9)))}}Ue.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){fr(n);let o=Pe(I,1);if(n===o||Number.isNaN(n))return 3;if(dr(n),o=je(I,1),n===o)return 5}return 9};var ur=new ArrayBuffer(9),T=new DataView(ur,1),I=new Uint8Array(ur,0);function fr(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,(e&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 Pe(e,t){if(e.length-t<2)throw new Error(`${d} 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,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,r&32768?-i:i}function dr(e){T.setFloat32(0,e,!1)}function je(e,t){if(e.length-t<4)throw new Error(`${d} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function Sn(e){T.setFloat64(0,e,!1)}function lr(e,t){if(e.length-t<8)throw new Error(`${d} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}Ue.compareTokens=k.compareTokens;function l(e,t,r){throw new Error(`${d} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function Ae(e){return()=>{throw new Error(`${d} ${e}`)}}var c=[];for(let e=0;e<=23;e++)c[e]=l;c[24]=Et;c[25]=Ut;c[26]=At;c[27]=vt;c[28]=l;c[29]=l;c[30]=l;c[31]=l;for(let e=32;e<=55;e++)c[e]=l;c[56]=kt;c[57]=Tt;c[58]=St;c[59]=It;c[60]=l;c[61]=l;c[62]=l;c[63]=l;for(let e=64;e<=87;e++)c[e]=Ct;c[88]=_t;c[89]=Nt;c[90]=Dt;c[91]=$t;c[92]=l;c[93]=l;c[94]=l;c[95]=Ae("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)c[e]=Mt;c[120]=zt;c[121]=Ot;c[122]=Ft;c[123]=Lt;c[124]=l;c[125]=l;c[126]=l;c[127]=Ae("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)c[e]=Rt;c[152]=Pt;c[153]=jt;c[154]=qt;c[155]=Gt;c[156]=l;c[157]=l;c[158]=l;c[159]=Ht;for(let e=160;e<=183;e++)c[e]=Jt;c[184]=Kt;c[185]=Xt;c[186]=Qt;c[187]=Wt;c[188]=l;c[189]=l;c[190]=l;c[191]=Zt;for(let e=192;e<=215;e++)c[e]=Yt;c[216]=er;c[217]=tr;c[218]=rr;c[219]=nr;c[220]=l;c[221]=l;c[222]=l;c[223]=l;for(let e=224;e<=243;e++)c[e]=Ae("simple values are not supported");c[244]=l;c[245]=l;c[246]=l;c[247]=or;c[248]=Ae("simple values are not supported");c[249]=sr;c[250]=cr;c[251]=ar;c[252]=l;c[253]=l;c[254]=l;c[255]=ir;var C=[];for(let e=0;e<24;e++)C[e]=new a(s.uint,e,1);for(let e=-1;e>=-24;e--)C[31-e]=new a(s.negint,e,1);C[64]=new a(s.bytes,new Uint8Array(0),1);C[96]=new a(s.string,"",1);C[128]=new a(s.array,0,1);C[160]=new a(s.map,0,1);C[244]=new a(s.false,!1,1);C[245]=new a(s.true,!0,1);C[246]=new a(s.null,null,1);function pr(e){switch(e.type){case s.false:return M([244]);case s.true:return M([245]);case s.null:return M([246]);case s.bytes:return e.value.length?void 0:M([64]);case s.string:return e.value===""?M([96]):void 0;case s.array:return e.value===0?M([128]):void 0;case s.map:return e.value===0?M([160]):void 0;case s.uint:return e.value<24?M([Number(e.value)]):void 0;case s.negint:if(e.value>=-24)return M([31-Number(e.value)])}}var In={float64:!1,mapSorter:Nn,quickEncodeToken:pr};function Cn(){let e=[];return e[s.uint.major]=k,e[s.negint.major]=ye,e[s.bytes.major]=Z,e[s.string.major]=Vt,e[s.array.major]=we,e[s.map.major]=be,e[s.tag.major]=Ee,e[s.float.major]=Ue,e}var hr=Cn(),qe=new se,ke=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(`${Le} object contains circular references`);return new e(r,t)}},V={null:new a(s.null,null),undefined:new a(s.undefined,void 0),true:new a(s.true,!0),false:new a(s.false,!1),emptyArray:new a(s.array,0),emptyMap:new a(s.map,0)},R={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new a(s.float,e):e>=0?new a(s.uint,e):new a(s.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new a(s.uint,e):new a(s.negint,e)},Uint8Array(e,t,r,n){return new a(s.bytes,e)},string(e,t,r,n){return new a(s.string,e)},boolean(e,t,r,n){return e?V.true:V.false},null(e,t,r,n){return V.null},undefined(e,t,r,n){return V.undefined},ArrayBuffer(e,t,r,n){return new a(s.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new a(s.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[V.emptyArray,new a(s.break)]:V.emptyArray;n=ke.createCheck(n,e);let o=[],i=0;for(let u of e)o[i++]=ve(u,r,n);return r.addBreakTokens?[new a(s.array,e.length),o,new a(s.break)]:[new a(s.array,e.length),o]},Object(e,t,r,n){let o=t!=="Object",i=o?e.keys():Object.keys(e),u=o?e.size:i.length;if(!u)return r.addBreakTokens===!0?[V.emptyMap,new a(s.break)]:V.emptyMap;n=ke.createCheck(n,e);let f=[],h=0;for(let g of i)f[h++]=[ve(g,r,n),ve(o?e.get(g):e[g],r,n)];return _n(f,r),r.addBreakTokens?[new a(s.map,u),f,new a(s.break)]:[new a(s.map,u),f]}};R.Map=R.Object;R.Buffer=R.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))R[`${e}Array`]=R.DataView;function ve(e,t={},r){let n=lt(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||R[n];if(typeof o=="function"){let u=o(e,n,t,r);if(u!=null)return u}let i=R[n];if(!i)throw new Error(`${Le} unsupported type: ${n}`);return i(e,n,t,r)}function _n(e,t){t.mapSorter&&e.sort(t.mapSorter)}function Nn(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,i=hr[o].compareTokens(r,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function mr(e,t,r,n){if(Array.isArray(t))for(let o of t)mr(e,o,r,n);else r[t.type.major](e,t,n)}function Dn(e,t,r){let n=ve(e,r);if(!Array.isArray(n)&&r.quickEncodeToken){let o=r.quickEncodeToken(n);if(o)return o;let i=t[n.type.major];if(i.encodedSize){let u=i.encodedSize(n,r),f=new se(u);if(i(f,n,r),f.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return Fe(f.chunks[0])}}return qe.reset(),mr(qe,n,t,r),qe.toBytes(!0)}function Ge(e,t){return t=Object.assign({},In,t),Dn(e,hr,t)}var $n={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Te=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=C[t];if(r===void 0){let n=c[t];if(!n)throw new Error(`${d} 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}},fe=Symbol.for("DONE"),Se=Symbol.for("BREAK");function Mn(e,t,r){let n=[];for(let o=0;o<e.value;o++){let i=te(t,r);if(i===Se){if(e.value===1/0)break;throw new Error(`${d} got unexpected break to lengthed array`)}if(i===fe)throw new Error(`${d} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=i}return n}function zn(e,t,r){let n=r.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let u=0;u<e.value;u++){let f=te(t,r);if(f===Se){if(e.value===1/0)break;throw new Error(`${d} got unexpected break to lengthed map`)}if(f===fe)throw new Error(`${d} found map but not enough entries (got ${u} [no key], expected ${e.value})`);if(n!==!0&&typeof f!="string")throw new Error(`${d} non-string keys not supported (got ${typeof f})`);if(r.rejectDuplicateMapKeys===!0&&(n&&i.has(f)||!n&&f in o))throw new Error(`${d} found repeat map key "${f}"`);let h=te(t,r);if(h===fe)throw new Error(`${d} found map but not enough entries (got ${u} [no value], expected ${e.value})`);n?i.set(f,h):o[f]=h}return n?i:o}function te(e,t){if(e.done())return fe;let r=e.next();if(r.type===s.break)return Se;if(r.type.terminal)return r.value;if(r.type===s.array)return Mn(r,e,t);if(r.type===s.map)return zn(r,e,t);if(r.type===s.tag){if(t.tags&&typeof t.tags[r.value]=="function"){let n=te(e,t);return t.tags[r.value](n)}throw new Error(`${d} tag not supported (${r.value})`)}throw new Error("unsupported")}function xr(e,t){if(!(e instanceof Uint8Array))throw new Error(`${d} data to decode must be a Uint8Array`);t=Object.assign({},$n,t);let r=t.tokenizer||new Te(e,t),n=te(r,t);if(n===fe)throw new Error(`${d} did not find any content to decode`);if(n===Se)throw new Error(`${d} got unexpected break`);return[n,e.subarray(r.pos())]}function He(e,t){let[r,n]=xr(e,t);if(n.length>0)throw new Error(`${d} too many terminals, data makes no sense`);return r}var yr=42;function Fn(e){return e instanceof ArrayBuffer?new Uint8Array(e,0,e.byteLength):e}function Ln(e){if(e.asCID!==e&&e["/"]!==e.bytes)return null;let t=j.asCID(e);if(!t)return null;let r=new Uint8Array(t.bytes.byteLength+1);return r.set(t.bytes,1),[new a(s.tag,yr),new a(s.bytes,r)]}function Vn(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function Rn(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 Pn(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 Je={float64:!0,typeEncoders:{Map:Pn,Object:Ln,undefined:Vn,number:Rn}},Bi={...Je,typeEncoders:{...Je.typeEncoders}};function jn(e){if(e[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return j.decode(e.subarray(1))}var Be={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:[]};Be.tags[yr]=jn;var Ii={...Be,tags:Be.tags.slice()};var Ke=113,gr=e=>Ge(e,Je),wr=e=>He(Fn(e),Be);function br(e=0){return new Uint8Array(e)}function Xe(e,t){t==null&&(t=e.reduce((o,i)=>o+i.length,0));let r=br(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}function Gn(e){return e[Symbol.asyncIterator]!=null}function Hn(e){if(Gn(e))return(async()=>{let n=new Uint8Array(0);for await(let o of e)n=Xe([n,o],n.length+o.length);return n})();let t=[],r=0;for(let n of e)t.push(n),r+=n.byteLength;return Xe(t,r)}var Er=Hn;var Jn=20;function We({name:e,code:t,encode:r,minDigestLength:n,maxDigestLength:o}){return new Qe(e,t,r,n,o)}var Qe=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,r,n,o,i){this.name=t,this.code=r,this.encode=n,this.minDigestLength=o??Jn,this.maxDigestLength=i}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?Ur(n,this.code,r?.truncate):n.then(o=>Ur(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function Ur(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 he(t,e)}function Ar(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var vr=We({name:"sha2-256",code:18,encode:Ar("SHA-256")}),Vi=We({name:"sha2-512",code:19,encode:Ar("SHA-512")});var Ie=class{components;constructor(t){this.components=t}async add(t,r={}){let n=gr(t),o=await(r.hasher??vr).digest(n),i=j.createV1(Ke,o);return await this.components.blockstore.put(i,n,r),i}async get(t,r={}){if(t.code!==Ke)throw new me("The passed CID had an incorrect codec, it may correspond to a non-DAG-CBOR block");let n=await Er(this.components.blockstore.get(t,r));return wr(n)}};function Kn(e){return new Ie(e)}return _r(Xn);})();
|
|
3
3
|
return HeliaDagCbor}));
|
|
4
4
|
//# sourceMappingURL=index.min.js.map
|