@helia/car 3.2.1 → 4.0.0
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 +4 -3
- package/dist/index.min.js +1 -1
- package/dist/src/index.d.ts +8 -11
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +10 -10
- package/dist/src/index.js.map +1 -1
- package/dist/typedoc-urls.json +2 -0
- package/package.json +9 -8
- package/src/index.ts +14 -15
package/README.md
CHANGED
|
@@ -46,13 +46,13 @@ import { CarWriter } from '@ipld/car'
|
|
|
46
46
|
import { Readable } from 'node:stream'
|
|
47
47
|
import nodeFs from 'node:fs'
|
|
48
48
|
|
|
49
|
-
const helia = createHelia({
|
|
49
|
+
const helia = await createHelia({
|
|
50
50
|
// ... helia config
|
|
51
51
|
})
|
|
52
52
|
const fs = unixfs(helia)
|
|
53
53
|
|
|
54
54
|
// add some UnixFS data
|
|
55
|
-
const cid = await fs.addBytes(
|
|
55
|
+
const cid = await fs.addBytes(Uint8Array.from([0, 1, 2, 3, 4]))
|
|
56
56
|
|
|
57
57
|
// export it as a Car
|
|
58
58
|
const c = car(helia)
|
|
@@ -75,7 +75,7 @@ import { CarReader } from '@ipld/car'
|
|
|
75
75
|
import { Readable } from 'node:stream'
|
|
76
76
|
import nodeFs from 'node:fs'
|
|
77
77
|
|
|
78
|
-
const helia = createHelia({
|
|
78
|
+
const helia = await createHelia({
|
|
79
79
|
// ... helia config
|
|
80
80
|
})
|
|
81
81
|
|
|
@@ -83,6 +83,7 @@ const helia = createHelia({
|
|
|
83
83
|
const inStream = nodeFs.createReadStream('example.car')
|
|
84
84
|
const reader = await CarReader.fromIterable(inStream)
|
|
85
85
|
|
|
86
|
+
const c = car(helia)
|
|
86
87
|
await c.import(reader)
|
|
87
88
|
```
|
|
88
89
|
|
package/dist/index.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.HeliaCar = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
-
"use strict";var HeliaCar=(()=>{var bn=Object.create;var Ce=Object.defineProperty;var vn=Object.getOwnPropertyDescriptor;var En=Object.getOwnPropertyNames;var _n=Object.getPrototypeOf,kn=Object.prototype.hasOwnProperty;var ce=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Tn=(e,t)=>{for(var r in t)Ce(e,r,{get:t[r],enumerable:!0})},Nt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of En(t))!kn.call(e,o)&&o!==r&&Ce(e,o,{get:()=>t[o],enumerable:!(n=vn(t,o))||n.enumerable});return e};var Se=(e,t,r)=>(r=e!=null?bn(_n(e)):{},Nt(t||!e||!e.__esModule?Ce(r,"default",{value:e,enumerable:!0}):r,e)),An=e=>Nt(Ce({},"__esModule",{value:!0}),e);var jr=ce((Ws,Zr)=>{Zr.exports=yt;var Qr=128,Mo=127,$o=~Mo,Lo=Math.pow(2,31);function yt(e,t,r){if(Number.MAX_SAFE_INTEGER&&e>Number.MAX_SAFE_INTEGER)throw yt.bytes=0,new RangeError("Could not encode varint");t=t||[],r=r||0;for(var n=r;e>=Lo;)t[r++]=e&255|Qr,e/=128;for(;e&$o;)t[r++]=e&255|Qr,e>>>=7;return t[r]=e|0,yt.bytes=r-n+1,t}});var rn=ce((Ks,tn)=>{tn.exports=mt;var Vo=128,en=127;function mt(e,n){var r=0,n=n||0,o=0,i=n,a,u=e.length;do{if(i>=u||o>49)throw mt.bytes=0,new RangeError("Could not decode varint");a=e[i++],r+=o<28?(a&en)<<o:(a&en)*Math.pow(2,o),o+=7}while(a>=Vo);return mt.bytes=i-n,r}});var on=ce((Ys,nn)=>{var Po=Math.pow(2,7),Fo=Math.pow(2,14),Ho=Math.pow(2,21),qo=Math.pow(2,28),Go=Math.pow(2,35),Wo=Math.pow(2,42),Ko=Math.pow(2,49),Yo=Math.pow(2,56),Xo=Math.pow(2,63);nn.exports=function(e){return e<Po?1:e<Fo?2:e<Ho?3:e<qo?4:e<Go?5:e<Wo?6:e<Ko?7:e<Yo?8:e<Xo?9:10}});var qe=ce((Xs,sn)=>{sn.exports={encode:jr(),decode:rn(),encodingLength:on()}});var wn=ce((Za,At)=>{"use strict";var ui=Object.prototype.hasOwnProperty,E="~";function _e(){}Object.create&&(_e.prototype=Object.create(null),new _e().__proto__||(E=!1));function fi(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function mn(e,t,r,n,o){if(typeof r!="function")throw new TypeError("The listener must be a function");var i=new fi(r,n||e,o),a=E?E+t:t;return e._events[a]?e._events[a].fn?e._events[a]=[e._events[a],i]:e._events[a].push(i):(e._events[a]=i,e._eventsCount++),e}function Ke(e,t){--e._eventsCount===0?e._events=new _e:delete e._events[t]}function b(){this._events=new _e,this._eventsCount=0}b.prototype.eventNames=function(){var t=[],r,n;if(this._eventsCount===0)return t;for(n in r=this._events)ui.call(r,n)&&t.push(E?n.slice(1):n);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(r)):t};b.prototype.listeners=function(t){var r=E?E+t:t,n=this._events[r];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,i=n.length,a=new Array(i);o<i;o++)a[o]=n[o].fn;return a};b.prototype.listenerCount=function(t){var r=E?E+t:t,n=this._events[r];return n?n.fn?1:n.length:0};b.prototype.emit=function(t,r,n,o,i,a){var u=E?E+t:t;if(!this._events[u])return!1;var c=this._events[u],p=arguments.length,l,m;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),p){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,r),!0;case 3:return c.fn.call(c.context,r,n),!0;case 4:return c.fn.call(c.context,r,n,o),!0;case 5:return c.fn.call(c.context,r,n,o,i),!0;case 6:return c.fn.call(c.context,r,n,o,i,a),!0}for(m=1,l=new Array(p-1);m<p;m++)l[m-1]=arguments[m];c.fn.apply(c.context,l)}else{var v=c.length,Y;for(m=0;m<v;m++)switch(c[m].once&&this.removeListener(t,c[m].fn,void 0,!0),p){case 1:c[m].fn.call(c[m].context);break;case 2:c[m].fn.call(c[m].context,r);break;case 3:c[m].fn.call(c[m].context,r,n);break;case 4:c[m].fn.call(c[m].context,r,n,o);break;default:if(!l)for(Y=1,l=new Array(p-1);Y<p;Y++)l[Y-1]=arguments[Y];c[m].fn.apply(c[m].context,l)}}return!0};b.prototype.on=function(t,r,n){return mn(this,t,r,n,!1)};b.prototype.once=function(t,r,n){return mn(this,t,r,n,!0)};b.prototype.removeListener=function(t,r,n,o){var i=E?E+t:t;if(!this._events[i])return this;if(!r)return Ke(this,i),this;var a=this._events[i];if(a.fn)a.fn===r&&(!o||a.once)&&(!n||a.context===n)&&Ke(this,i);else{for(var u=0,c=[],p=a.length;u<p;u++)(a[u].fn!==r||o&&!a[u].once||n&&a[u].context!==n)&&c.push(a[u]);c.length?this._events[i]=c.length===1?c[0]:c:Ke(this,i)}return this};b.prototype.removeAllListeners=function(t){var r;return t?(r=E?E+t:t,this._events[r]&&Ke(this,r)):(this._events=new _e,this._eventsCount=0),this};b.prototype.off=b.prototype.removeListener;b.prototype.addListener=b.prototype.on;b.prefixed=E;b.EventEmitter=b;typeof At<"u"&&(At.exports=b)});var hi={};Tn(hi,{car:()=>li});var In=["string","number","bigint","symbol"],Cn=["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 Ot(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(In.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(Sn(e))return"Buffer";let r=Un(e);return r||"Object"}function Sn(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function Un(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(Cn.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 d=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",Bn=new TextDecoder,Nn=new TextEncoder;function Ue(e){return Q&&globalThis.Buffer.isBuffer(e)}function Ye(e){return e instanceof Uint8Array?Ue(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var Mt=Q?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):Rt(e,t,r):(e,t,r)=>r-t>64?Bn.decode(e.subarray(t,r)):Rt(e,t,r),$t=Q?e=>e.length>64?globalThis.Buffer.from(e):Dt(e):e=>e.length>64?Nn.encode(e):Dt(e),L=e=>Uint8Array.from(e),Z=Q?(e,t,r)=>Ue(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),Lt=Q?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),Ye(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},Vt=Q?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function Pt(e,t){if(Ue(e)&&Ue(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 Dt(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 Rt(e,t,r){let n=[];for(;t<r;){let o=e[t],i=null,a=o>239?4:o>223?3:o>191?2:1;if(t+a<=r){let u,c,p,l;switch(a){case 1:o<128&&(i=o);break;case 2:u=e[t+1],(u&192)===128&&(l=(o&31)<<6|u&63,l>127&&(i=l));break;case 3:u=e[t+1],c=e[t+2],(u&192)===128&&(c&192)===128&&(l=(o&15)<<12|(u&63)<<6|c&63,l>2047&&(l<55296||l>57343)&&(i=l));break;case 4:u=e[t+1],c=e[t+2],p=e[t+3],(u&192)===128&&(c&192)===128&&(p&192)===128&&(l=(o&15)<<18|(u&63)<<12|(c&63)<<6|p&63,l>65535&&l<1114112&&(i=l))}}i===null?(i=65533,a=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),t+=a}return On(n)}var zt=4096;function On(e){let t=e.length;if(t<=zt)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=zt));return r}var Dn=256,ue=class{constructor(t=Dn){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=Vt(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=Z(n,0,this.cursor)}else r=Lt(this.chunks,this.cursor);return t&&this.reset(),r}};var h="CBOR decode error:",Xe="CBOR encode error:",fe=[];fe[23]=1;fe[24]=2;fe[25]=3;fe[26]=5;fe[27]=9;function F(e,t,r){if(e.length-t<r)throw new Error(`${h} not enough data for type`)}var g=[24,256,65536,4294967296,BigInt("18446744073709551616")];function k(e,t,r){F(e,t,1);let n=e[t];if(r.strict===!0&&n<g[0])throw new Error(`${h} integer encoded in more bytes than necessary (strict decode)`);return n}function T(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(`${h} integer encoded in more bytes than necessary (strict decode)`);return n}function A(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(`${h} integer encoded in more bytes than necessary (strict decode)`);return n}function I(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<g[3])throw new Error(`${h} 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(`${h} integers outside of the safe integer range are not supported`)}function Ft(e,t,r,n){return new d(s.uint,k(e,t+1,n),2)}function Ht(e,t,r,n){return new d(s.uint,T(e,t+1,n),3)}function qt(e,t,r,n){return new d(s.uint,A(e,t+1,n),5)}function Gt(e,t,r,n){return new d(s.uint,I(e,t+1,n),9)}function S(e,t){return x(e,0,t.value)}function x(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],i=Number(n&BigInt(4294967295)),a=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]=a&255,a=a>>8,o[3]=a&255,a=a>>8,o[2]=a&255,a=a>>8,o[1]=a&255,e.push(o)}else throw new Error(`${h} encountered BigInt larger than allowable range`)}}S.encodedSize=function(t){return x.encodedSize(t.value)};x.encodedSize=function(t){return t<g[0]?1:t<g[1]?2:t<g[2]?3:t<g[3]?5:9};S.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function Wt(e,t,r,n){return new d(s.negint,-1-k(e,t+1,n),2)}function Kt(e,t,r,n){return new d(s.negint,-1-T(e,t+1,n),3)}function Yt(e,t,r,n){return new d(s.negint,-1-A(e,t+1,n),5)}var Je=BigInt(-1),Xt=BigInt(1);function Jt(e,t,r,n){let o=I(e,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new d(s.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${h} integers outside of the safe integer range are not supported`);return new d(s.negint,Je-BigInt(o),9)}function Be(e,t){let r=t.value,n=typeof r=="bigint"?r*Je-Xt:r*-1-1;x(e,t.type.majorEncoded,n)}Be.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*Je-Xt:r*-1-1;return n<g[0]?1:n<g[1]?2:n<g[2]?3:n<g[3]?5:9};Be.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function de(e,t,r,n){F(e,t,r+n);let o=Z(e,t+r,t+r+n);return new d(s.bytes,o,r+n)}function Qt(e,t,r,n){return de(e,t,1,r)}function Zt(e,t,r,n){return de(e,t,2,k(e,t+1,n))}function jt(e,t,r,n){return de(e,t,3,T(e,t+1,n))}function er(e,t,r,n){return de(e,t,5,A(e,t+1,n))}function tr(e,t,r,n){let o=I(e,t+1,n);if(typeof o=="bigint")throw new Error(`${h} 64-bit integer bytes lengths not supported`);return de(e,t,9,o)}function Ne(e){return e.encodedBytes===void 0&&(e.encodedBytes=e.type===s.string?$t(e.value):e.value),e.encodedBytes}function j(e,t){let r=Ne(t);x(e,t.type.majorEncoded,r.length),e.push(r)}j.encodedSize=function(t){let r=Ne(t);return x.encodedSize(r.length)+r.length};j.compareTokens=function(t,r){return zn(Ne(t),Ne(r))};function zn(e,t){return e.length<t.length?-1:e.length>t.length?1:Pt(e,t)}function le(e,t,r,n,o){let i=r+n;F(e,t,i);let a=new d(s.string,Mt(e,t+r,t+i),i);return o.retainStringBytes===!0&&(a.byteValue=Z(e,t+r,t+i)),a}function rr(e,t,r,n){return le(e,t,1,r,n)}function nr(e,t,r,n){return le(e,t,2,k(e,t+1,n),n)}function or(e,t,r,n){return le(e,t,3,T(e,t+1,n),n)}function ir(e,t,r,n){return le(e,t,5,A(e,t+1,n),n)}function sr(e,t,r,n){let o=I(e,t+1,n);if(typeof o=="bigint")throw new Error(`${h} 64-bit integer string lengths not supported`);return le(e,t,9,o,n)}var ar=j;function ee(e,t,r,n){return new d(s.array,n,r)}function cr(e,t,r,n){return ee(e,t,1,r)}function ur(e,t,r,n){return ee(e,t,2,k(e,t+1,n))}function fr(e,t,r,n){return ee(e,t,3,T(e,t+1,n))}function dr(e,t,r,n){return ee(e,t,5,A(e,t+1,n))}function lr(e,t,r,n){let o=I(e,t+1,n);if(typeof o=="bigint")throw new Error(`${h} 64-bit integer array lengths not supported`);return ee(e,t,9,o)}function hr(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${h} indefinite length items not allowed`);return ee(e,t,1,1/0)}function Oe(e,t){x(e,s.array.majorEncoded,t.value)}Oe.compareTokens=S.compareTokens;Oe.encodedSize=function(t){return x.encodedSize(t.value)};function te(e,t,r,n){return new d(s.map,n,r)}function pr(e,t,r,n){return te(e,t,1,r)}function yr(e,t,r,n){return te(e,t,2,k(e,t+1,n))}function mr(e,t,r,n){return te(e,t,3,T(e,t+1,n))}function wr(e,t,r,n){return te(e,t,5,A(e,t+1,n))}function gr(e,t,r,n){let o=I(e,t+1,n);if(typeof o=="bigint")throw new Error(`${h} 64-bit integer map lengths not supported`);return te(e,t,9,o)}function xr(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${h} indefinite length items not allowed`);return te(e,t,1,1/0)}function De(e,t){x(e,s.map.majorEncoded,t.value)}De.compareTokens=S.compareTokens;De.encodedSize=function(t){return x.encodedSize(t.value)};function br(e,t,r,n){return new d(s.tag,r,1)}function vr(e,t,r,n){return new d(s.tag,k(e,t+1,n),2)}function Er(e,t,r,n){return new d(s.tag,T(e,t+1,n),3)}function _r(e,t,r,n){return new d(s.tag,A(e,t+1,n),5)}function kr(e,t,r,n){return new d(s.tag,I(e,t+1,n),9)}function Re(e,t){x(e,s.tag.majorEncoded,t.value)}Re.compareTokens=S.compareTokens;Re.encodedSize=function(t){return x.encodedSize(t.value)};var Fn=20,Hn=21,qn=22,Gn=23;function Tr(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${h} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new d(s.null,null,1):new d(s.undefined,void 0,1)}function Ar(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${h} indefinite length items not allowed`);return new d(s.break,void 0,1)}function Qe(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${h} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${h} Infinity values are not supported`)}return new d(s.float,e,t)}function Ir(e,t,r,n){return Qe(Ze(e,t+1),3,n)}function Cr(e,t,r,n){return Qe(je(e,t+1),5,n)}function Sr(e,t,r,n){return Qe(Or(e,t+1),9,n)}function ze(e,t,r){let n=t.value;if(n===!1)e.push([s.float.majorEncoded|Fn]);else if(n===!0)e.push([s.float.majorEncoded|Hn]);else if(n===null)e.push([s.float.majorEncoded|qn]);else if(n===void 0)e.push([s.float.majorEncoded|Gn]);else{let o,i=!1;(!r||r.float64!==!0)&&(Br(n),o=Ze(D,1),n===o||Number.isNaN(n)?(D[0]=249,e.push(D.slice(0,3)),i=!0):(Nr(n),o=je(D,1),n===o&&(D[0]=250,e.push(D.slice(0,5)),i=!0))),i||(Wn(n),o=Or(D,1),D[0]=251,e.push(D.slice(0,9)))}}ze.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){Br(n);let o=Ze(D,1);if(n===o||Number.isNaN(n))return 3;if(Nr(n),o=je(D,1),n===o)return 5}return 9};var Ur=new ArrayBuffer(9),U=new DataView(Ur,1),D=new Uint8Array(Ur,0);function Br(e){if(e===1/0)U.setUint16(0,31744,!1);else if(e===-1/0)U.setUint16(0,64512,!1);else if(Number.isNaN(e))U.setUint16(0,32256,!1);else{U.setFloat32(0,e);let t=U.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)U.setUint16(0,31744,!1);else if(r===0)U.setUint16(0,(e&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?U.setUint16(0,0):o<-14?U.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):U.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function Ze(e,t){if(e.length-t<2)throw new Error(`${h} 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 Nr(e){U.setFloat32(0,e,!1)}function je(e,t){if(e.length-t<4)throw new Error(`${h} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function Wn(e){U.setFloat64(0,e,!1)}function Or(e,t){if(e.length-t<8)throw new Error(`${h} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}ze.compareTokens=S.compareTokens;function y(e,t,r){throw new Error(`${h} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function Me(e){return()=>{throw new Error(`${h} ${e}`)}}var f=[];for(let e=0;e<=23;e++)f[e]=y;f[24]=Ft;f[25]=Ht;f[26]=qt;f[27]=Gt;f[28]=y;f[29]=y;f[30]=y;f[31]=y;for(let e=32;e<=55;e++)f[e]=y;f[56]=Wt;f[57]=Kt;f[58]=Yt;f[59]=Jt;f[60]=y;f[61]=y;f[62]=y;f[63]=y;for(let e=64;e<=87;e++)f[e]=Qt;f[88]=Zt;f[89]=jt;f[90]=er;f[91]=tr;f[92]=y;f[93]=y;f[94]=y;f[95]=Me("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)f[e]=rr;f[120]=nr;f[121]=or;f[122]=ir;f[123]=sr;f[124]=y;f[125]=y;f[126]=y;f[127]=Me("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)f[e]=cr;f[152]=ur;f[153]=fr;f[154]=dr;f[155]=lr;f[156]=y;f[157]=y;f[158]=y;f[159]=hr;for(let e=160;e<=183;e++)f[e]=pr;f[184]=yr;f[185]=mr;f[186]=wr;f[187]=gr;f[188]=y;f[189]=y;f[190]=y;f[191]=xr;for(let e=192;e<=215;e++)f[e]=br;f[216]=vr;f[217]=Er;f[218]=_r;f[219]=kr;f[220]=y;f[221]=y;f[222]=y;f[223]=y;for(let e=224;e<=243;e++)f[e]=Me("simple values are not supported");f[244]=y;f[245]=y;f[246]=y;f[247]=Tr;f[248]=Me("simple values are not supported");f[249]=Ir;f[250]=Cr;f[251]=Sr;f[252]=y;f[253]=y;f[254]=y;f[255]=Ar;var R=[];for(let e=0;e<24;e++)R[e]=new d(s.uint,e,1);for(let e=-1;e>=-24;e--)R[31-e]=new d(s.negint,e,1);R[64]=new d(s.bytes,new Uint8Array(0),1);R[96]=new d(s.string,"",1);R[128]=new d(s.array,0,1);R[160]=new d(s.map,0,1);R[244]=new d(s.false,!1,1);R[245]=new d(s.true,!0,1);R[246]=new d(s.null,null,1);function et(e){switch(e.type){case s.false:return L([244]);case s.true:return L([245]);case s.null:return L([246]);case s.bytes:return e.value.length?void 0:L([64]);case s.string:return e.value===""?L([96]):void 0;case s.array:return e.value===0?L([128]):void 0;case s.map:return e.value===0?L([160]):void 0;case s.uint:return e.value<24?L([Number(e.value)]):void 0;case s.negint:if(e.value>=-24)return L([31-Number(e.value)])}}var Yn={float64:!1,mapSorter:Jn,quickEncodeToken:et};function rt(){let e=[];return e[s.uint.major]=S,e[s.negint.major]=Be,e[s.bytes.major]=j,e[s.string.major]=ar,e[s.array.major]=Oe,e[s.map.major]=De,e[s.tag.major]=Re,e[s.float.major]=ze,e}var Dr=rt(),tt=new ue,$e=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(`${Xe} object contains circular references`);return new e(r,t)}},G={null:new d(s.null,null),undefined:new d(s.undefined,void 0),true:new d(s.true,!0),false:new d(s.false,!1),emptyArray:new d(s.array,0),emptyMap:new d(s.map,0)},W={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new d(s.float,e):e>=0?new d(s.uint,e):new d(s.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new d(s.uint,e):new d(s.negint,e)},Uint8Array(e,t,r,n){return new d(s.bytes,e)},string(e,t,r,n){return new d(s.string,e)},boolean(e,t,r,n){return e?G.true:G.false},null(e,t,r,n){return G.null},undefined(e,t,r,n){return G.undefined},ArrayBuffer(e,t,r,n){return new d(s.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new d(s.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[G.emptyArray,new d(s.break)]:G.emptyArray;n=$e.createCheck(n,e);let o=[],i=0;for(let a of e)o[i++]=he(a,r,n);return r.addBreakTokens?[new d(s.array,e.length),o,new d(s.break)]:[new d(s.array,e.length),o]},Object(e,t,r,n){let o=t!=="Object",i=o?e.keys():Object.keys(e),a=o?e.size:i.length;if(!a)return r.addBreakTokens===!0?[G.emptyMap,new d(s.break)]:G.emptyMap;n=$e.createCheck(n,e);let u=[],c=0;for(let p of i)u[c++]=[he(p,r,n),he(o?e.get(p):e[p],r,n)];return Xn(u,r),r.addBreakTokens?[new d(s.map,a),u,new d(s.break)]:[new d(s.map,a),u]}};W.Map=W.Object;W.Buffer=W.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))W[`${e}Array`]=W.DataView;function he(e,t={},r){let n=Ot(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||W[n];if(typeof o=="function"){let a=o(e,n,t,r);if(a!=null)return a}let i=W[n];if(!i)throw new Error(`${Xe} unsupported type: ${n}`);return i(e,n,t,r)}function Xn(e,t){t.mapSorter&&e.sort(t.mapSorter)}function Jn(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=Dr[o].compareTokens(r,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function Rr(e,t,r,n){if(Array.isArray(t))for(let o of t)Rr(e,o,r,n);else r[t.type.major](e,t,n)}function Qn(e,t,r){let n=he(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 a=i.encodedSize(n,r),u=new ue(a);if(i(u,n,r),u.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return Ye(u.chunks[0])}}return tt.reset(),Rr(tt,n,t,r),tt.toBytes(!0)}function nt(e,t){return t=Object.assign({},Yn,t),Qn(e,Dr,t)}var Zn={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Le=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=R[t];if(r===void 0){let n=f[t];if(!n)throw new Error(`${h} 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}},pe=Symbol.for("DONE"),Ve=Symbol.for("BREAK");function jn(e,t,r){let n=[];for(let o=0;o<e.value;o++){let i=re(t,r);if(i===Ve){if(e.value===1/0)break;throw new Error(`${h} got unexpected break to lengthed array`)}if(i===pe)throw new Error(`${h} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=i}return n}function eo(e,t,r){let n=r.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let a=0;a<e.value;a++){let u=re(t,r);if(u===Ve){if(e.value===1/0)break;throw new Error(`${h} got unexpected break to lengthed map`)}if(u===pe)throw new Error(`${h} found map but not enough entries (got ${a} [no key], expected ${e.value})`);if(n!==!0&&typeof u!="string")throw new Error(`${h} non-string keys not supported (got ${typeof u})`);if(r.rejectDuplicateMapKeys===!0&&(n&&i.has(u)||!n&&u in o))throw new Error(`${h} found repeat map key "${u}"`);let c=re(t,r);if(c===pe)throw new Error(`${h} found map but not enough entries (got ${a} [no value], expected ${e.value})`);n?i.set(u,c):o[u]=c}return n?i:o}function re(e,t){if(e.done())return pe;let r=e.next();if(r.type===s.break)return Ve;if(r.type.terminal)return r.value;if(r.type===s.array)return jn(r,e,t);if(r.type===s.map)return eo(r,e,t);if(r.type===s.tag){if(t.tags&&typeof t.tags[r.value]=="function"){let n=re(e,t);return t.tags[r.value](n)}throw new Error(`${h} tag not supported (${r.value})`)}throw new Error("unsupported")}function zr(e,t){if(!(e instanceof Uint8Array))throw new Error(`${h} data to decode must be a Uint8Array`);t=Object.assign({},Zn,t);let r=t.tokenizer||new Le(e,t),n=re(r,t);if(n===pe)throw new Error(`${h} did not find any content to decode`);if(n===Ve)throw new Error(`${h} got unexpected break`);return[n,e.subarray(r.pos())]}function ot(e,t){let[r,n]=zr(e,t);if(n.length>0)throw new Error(`${h} too many terminals, data makes no sense`);return r}var ls=new Uint8Array(0);function Mr(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 ne(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 ro(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),a=i.charCodeAt(0);if(r[a]!==255)throw new TypeError(i+" is ambiguous");r[a]=o}var u=e.length,c=e.charAt(0),p=Math.log(u)/Math.log(256),l=Math.log(256)/Math.log(u);function m(w){if(w instanceof Uint8Array||(ArrayBuffer.isView(w)?w=new Uint8Array(w.buffer,w.byteOffset,w.byteLength):Array.isArray(w)&&(w=Uint8Array.from(w))),!(w instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(w.length===0)return"";for(var _=0,X=0,N=0,z=w.length;N!==z&&w[N]===0;)N++,_++;for(var M=(z-N)*l+1>>>0,C=new Uint8Array(M);N!==z;){for(var $=w[N],q=0,O=M-1;($!==0||q<X)&&O!==-1;O--,q++)$+=256*C[O]>>>0,C[O]=$%u>>>0,$=$/u>>>0;if($!==0)throw new Error("Non-zero carry");X=q,N++}for(var P=M-X;P!==M&&C[P]===0;)P++;for(var Ie=c.repeat(_);P<M;++P)Ie+=e.charAt(C[P]);return Ie}function v(w){if(typeof w!="string")throw new TypeError("Expected String");if(w.length===0)return new Uint8Array;var _=0;if(w[_]!==" "){for(var X=0,N=0;w[_]===c;)X++,_++;for(var z=(w.length-_)*p+1>>>0,M=new Uint8Array(z);w[_];){var C=r[w.charCodeAt(_)];if(C===255)return;for(var $=0,q=z-1;(C!==0||$<N)&&q!==-1;q--,$++)C+=u*M[q]>>>0,M[q]=C%256>>>0,C=C/256>>>0;if(C!==0)throw new Error("Non-zero carry");N=$,_++}if(w[_]!==" "){for(var O=z-N;O!==z&&M[O]===0;)O++;for(var P=new Uint8Array(X+(z-O)),Ie=X;O!==z;)P[Ie++]=M[O++];return P}}}function Y(w){var _=v(w);if(_)return _;throw new Error(`Non-${t} character`)}return{encode:m,decodeUnsafe:v,decode:Y}}var no=ro,oo=no,$r=oo;var it=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")}},st=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){if(this.name=t,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),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 Lr(this,t)}},at=class{decoders;constructor(t){this.decoders=t}or(t){return Lr(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 Lr(e,t){return new at({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var ct=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 it(t,r,n),this.decoder=new st(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Vr({name:e,prefix:t,encode:r,decode:n}){return new ct(e,t,r,n)}function oe({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=$r(r,e);return Vr({prefix:t,name:e,encode:n,decode:i=>ne(o(i))})}function io(e,t,r,n){let o={};for(let l=0;l<t.length;++l)o[t[l]]=l;let i=e.length;for(;e[i-1]==="=";)--i;let a=new Uint8Array(i*r/8|0),u=0,c=0,p=0;for(let l=0;l<i;++l){let m=o[e[l]];if(m===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|m,u+=r,u>=8&&(u-=8,a[p++]=255&c>>u)}if(u>=r||255&c<<8-u)throw new SyntaxError("Unexpected end of data");return a}function so(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,i="",a=0,u=0;for(let c=0;c<e.length;++c)for(u=u<<8|e[c],a+=8;a>r;)a-=r,i+=t[o&u>>a];if(a!==0&&(i+=t[o&u<<r-a]),n)for(;i.length*r&7;)i+="=";return i}function V({name:e,prefix:t,bitsPerChar:r,alphabet:n}){return Vr({prefix:t,name:e,encode(o){return so(o,n,r)},decode(o){return io(o,n,r,e)}})}var ye=V({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),xs=V({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),bs=V({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),vs=V({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Es=V({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),_s=V({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ks=V({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ts=V({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),As=V({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Pe=oe({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ss=oe({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var H=oe({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ns=oe({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ao=Hr,Pr=128,co=127,uo=~co,fo=Math.pow(2,31);function Hr(e,t,r){t=t||[],r=r||0;for(var n=r;e>=fo;)t[r++]=e&255|Pr,e/=128;for(;e&uo;)t[r++]=e&255|Pr,e>>>=7;return t[r]=e|0,Hr.bytes=r-n+1,t}var lo=ut,ho=128,Fr=127;function ut(e,n){var r=0,n=n||0,o=0,i=n,a,u=e.length;do{if(i>=u)throw ut.bytes=0,new RangeError("Could not decode varint");a=e[i++],r+=o<28?(a&Fr)<<o:(a&Fr)*Math.pow(2,o),o+=7}while(a>=ho);return ut.bytes=i-n,r}var po=Math.pow(2,7),yo=Math.pow(2,14),mo=Math.pow(2,21),wo=Math.pow(2,28),go=Math.pow(2,35),xo=Math.pow(2,42),bo=Math.pow(2,49),vo=Math.pow(2,56),Eo=Math.pow(2,63),_o=function(e){return e<po?1:e<yo?2:e<mo?3:e<wo?4:e<go?5:e<xo?6:e<bo?7:e<vo?8:e<Eo?9:10},ko={encode:ao,decode:lo,encodingLength:_o},To=ko,me=To;function we(e,t=0){return[me.decode(e,t),me.decode.bytes]}function ie(e,t,r=0){return me.encode(e,t,r),t}function se(e){return me.encodingLength(e)}function Gr(e,t){let r=t.byteLength,n=se(e),o=n+se(r),i=new Uint8Array(o+r);return ie(e,i,0),ie(r,i,n),i.set(t,o),new ae(e,r,t,i)}function Fe(e){let t=ne(e),[r,n]=we(t),[o,i]=we(t.subarray(n)),a=t.subarray(n+i);if(a.byteLength!==o)throw new Error("Incorrect length");return new ae(r,o,a,t)}function Wr(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Mr(e.bytes,r.bytes)}}var ae=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function Kr(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return Io(r,dt(e),t??H.encoder);default:return Co(r,dt(e),t??ye.encoder)}}var Yr=new WeakMap;function dt(e){let t=Yr.get(e);if(t==null){let r=new Map;return Yr.set(e,r),r}return t}var B=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!==ge)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==So)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=Gr(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&&Wr(t.multihash,n.multihash)}toString(t){return Kr(this,t)}toJSON(){return{"/":Kr(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:a}=r;return new e(n,o,i,a??Xr(n,o,i.bytes))}else if(r[Uo]===!0){let{version:n,multihash:o,code:i}=r,a=Fe(o);return e.create(n,i,a)}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!==ge)throw new Error(`Version 0 CID must use dag-pb (code: ${ge}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=Xr(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,ge,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=ne(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),a=new ae(r.multihashCode,r.digestSize,i,o);return[r.version===0?e.createV0(a):e.createV1(r.codec,a),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[m,v]=we(t.subarray(r));return r+=v,m},o=n(),i=ge;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let a=r,u=n(),c=n(),p=r+c,l=p-a;return{version:o,codec:i,multihashCode:u,digestSize:c,multihashSize:l,size:p}}static parse(t,r){let[n,o]=Ao(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 dt(i).set(n,t),i}};function Ao(e,t){switch(e[0]){case"Q":{let r=t??H;return[H.prefix,r.decode(`${H.prefix}${e}`)]}case H.prefix:{let r=t??H;return[H.prefix,r.decode(e)]}case ye.prefix:{let r=t??ye;return[ye.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 Io(e,t,r){let{prefix:n}=r;if(n!==H.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 Co(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 ge=112,So=18;function Xr(e,t,r){let n=se(e),o=n+se(t),i=new Uint8Array(o+r.byteLength);return ie(e,i,0),ie(t,i,n),i.set(r,o),i}var Uo=Symbol.for("@ipld/js-cid/CID");var Jr=42;function Bo(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=B.asCID(e);if(!t)return null;let r=new Uint8Array(t.bytes.byteLength+1);return r.set(t.bytes,1),[new d(s.tag,Jr),new d(s.bytes,r)]}function Oo(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function Do(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}var lt={float64:!0,typeEncoders:{Object:No,undefined:Oo,number:Do}},qs={...lt,typeEncoders:{...lt.typeEncoders}};function Ro(e){if(e[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return B.decode(e.subarray(1))}var He={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:[]};He.tags[Jr]=Ro;var Gs={...He,tags:He.tags.slice()};var ht=e=>nt(e,lt),pt=e=>ot(Bo(e),He);var wt=Se(qe(),1);var gt=40;function xt(e,t){if(!e.length)throw new Error("Unexpected end of data");let r=wt.default.decode(e);return t.seek(wt.default.decode.bytes),r}function bt(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),r=0;return{version:2,characteristics:[t.getBigUint64(r,!0),t.getBigUint64(r+=8,!0)],dataOffset:Number(t.getBigUint64(r+=8,!0)),dataSize:Number(t.getBigUint64(r+=8,!0)),indexOffset:Number(t.getBigUint64(r+=8,!0))}}var K={Null:e=>e===null?e:void 0,Int:e=>Number.isInteger(e)?e:void 0,Float:e=>typeof e=="number"&&Number.isFinite(e)?e:void 0,String:e=>typeof e=="string"?e:void 0,Bool:e=>typeof e=="boolean"?e:void 0,Bytes:e=>e instanceof Uint8Array?e:void 0,Link:e=>e!==null&&typeof e=="object"&&e.asCID===e?e:void 0,List:e=>Array.isArray(e)?e:void 0,Map:e=>e!==null&&typeof e=="object"&&e.asCID!==e&&!Array.isArray(e)&&!(e instanceof Uint8Array)?e:void 0},xe={"CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)":K.Link,"CarV1HeaderOrV2Pragma > roots (anon)":e=>{if(K.List(e)!==void 0){for(let t=0;t<e.length;t++){let r=e[t];if(r=xe["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](r),r===void 0)return;if(r!==e[t]){let n=e.slice(0,t);for(let o=t;o<e.length;o++){let i=e[o];if(i=xe["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](i),i===void 0)return;n.push(i)}return n}}return e}},Int:K.Int,CarV1HeaderOrV2Pragma:e=>{if(K.Map(e)===void 0)return;let t=Object.entries(e),r=e,n=1;for(let o=0;o<t.length;o++){let[i,a]=t[o];switch(i){case"roots":{let u=xe["CarV1HeaderOrV2Pragma > roots (anon)"](e[i]);if(u===void 0)return;if(u!==a||r!==e){if(r===e){r={};for(let c=0;c<o;c++)r[t[c][0]]=t[c][1]}r.roots=u}}break;case"version":{n--;let u=xe.Int(e[i]);if(u===void 0)return;if(u!==a||r!==e){if(r===e){r={};for(let c=0;c<o;c++)r[t[c][0]]=t[c][1]}r.version=u}}break;default:return}}if(!(n>0))return r}},be={"CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)":K.Link,"CarV1HeaderOrV2Pragma > roots (anon)":e=>{if(K.List(e)!==void 0){for(let t=0;t<e.length;t++){let r=e[t];if(r=be["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](r),r===void 0)return;if(r!==e[t]){let n=e.slice(0,t);for(let o=t;o<e.length;o++){let i=e[o];if(i=be["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](i),i===void 0)return;n.push(i)}return n}}return e}},Int:K.Int,CarV1HeaderOrV2Pragma:e=>{if(K.Map(e)===void 0)return;let t=Object.entries(e),r=e,n=1;for(let o=0;o<t.length;o++){let[i,a]=t[o];switch(i){case"roots":{let u=be["CarV1HeaderOrV2Pragma > roots (anon)"](a);if(u===void 0)return;if(u!==a||r!==e){if(r===e){r={};for(let c=0;c<o;c++)r[t[c][0]]=t[c][1]}r.roots=u}}break;case"version":{n--;let u=be.Int(a);if(u===void 0)return;if(u!==a||r!==e){if(r===e){r={};for(let c=0;c<o;c++)r[t[c][0]]=t[c][1]}r.version=u}}break;default:return}}if(!(n>0))return r}},vt={toTyped:xe.CarV1HeaderOrV2Pragma,toRepresentation:be.CarV1HeaderOrV2Pragma};var sa=rt();var jo=Se(qe(),1);var da=[new d(s.map,2),new d(s.string,"version"),new d(s.uint,1),new d(s.string,"roots")],la=new d(s.tag,42);async function Et(e,t){let r=xt(await e.upTo(8),e);if(r===0)throw new Error("Invalid CAR header (zero length)");let n=await e.exactly(r,!0),o=pt(n);if(vt.toTyped(o)===void 0)throw new Error("Invalid CAR header format");if(o.version!==1&&o.version!==2||t!==void 0&&o.version!==t)throw new Error(`Invalid CAR version: ${o.version}${t!==void 0?` (expected ${t})`:""}`);if(o.version===1){if(!Array.isArray(o.roots))throw new Error("Invalid CAR header format");return o}if(o.roots!==void 0)throw new Error("Invalid CAR header format");let i=bt(await e.exactly(gt,!0));e.seek(i.dataOffset-e.pos);let a=await Et(e,1);return Object.assign(a,i)}function ve(e){let t=0;return{async upTo(r){return e.subarray(t,t+Math.min(r,e.length-t))},async exactly(r,n=!1){if(r>e.length-t)throw new Error("Unexpected end of data");let o=e.subarray(t,t+r);return n&&(t+=r),o},seek(r){t+=r},get pos(){return t}}}var _t=Se(qe(),1),un=1;function kt(e){let t=ht({version:un,roots:e}),r=_t.default.encode(t.length),n=new Uint8Array(r.length+t.length);return n.set(r,0),n.set(t,r.length),n}function fn(e){return{async setRoots(t){let r=kt(t);await e.write(r)},async writeBlock(t){let{cid:r,bytes:n}=t;await e.write(new Uint8Array(_t.default.encode(r.bytes.length+n.length))),await e.write(r.bytes),n.length&&await e.write(n)},async close(){await e.end()},version(){return un}}}function Ge(){}function dn(){let e=[],t=null,r=Ge,n=!1,o=null,i=Ge,a=()=>(t||(t=new Promise(p=>{r=()=>{t=null,r=Ge,p()}})),t),u={write(p){e.push(p);let l=a();return i(),l},async end(){n=!0;let p=a();i(),await p}},c={async next(){let p=e.shift();return p?(e.length===0&&r(),{done:!1,value:p}):n?(r(),{done:!0,value:void 0}):(o||(o=new Promise(l=>{i=()=>(o=null,i=Ge,l(c.next()))})),o)}};return{writer:u,iterator:c}}var Ee=class e{constructor(t,r){this._encoder=r,this._mutex=r.setRoots(t),this._ended=!1}async put(t){if(!(t.bytes instanceof Uint8Array)||!t.cid)throw new TypeError("Can only write {cid, bytes} objects");if(this._ended)throw new Error("Already closed");let r=B.asCID(t.cid);if(!r)throw new TypeError("Can only write {cid, bytes} objects");return this._mutex=this._mutex.then(()=>this._encoder.writeBlock({cid:r,bytes:t.bytes})),this._mutex}async close(){if(this._ended)throw new Error("Already closed");return await this._mutex,this._ended=!0,this._encoder.close()}version(){return this._encoder.version()}static create(t){t=ni(t);let{encoder:r,iterator:n}=ln(),o=new e(t,r),i=new We(n);return{writer:o,out:i}}static createAppender(){let{encoder:t,iterator:r}=ln();t.setRoots=()=>Promise.resolve();let n=new e([],t),o=new We(r);return{writer:n,out:o}}static async updateRootsInBytes(t,r){let n=ve(t);await Et(n);let o=kt(r);if(Number(n.pos)!==o.length)throw new Error(`updateRoots() can only overwrite a header of the same length (old header is ${n.pos} bytes, new header is ${o.length} bytes)`);return t.set(o,0),t}},We=class{constructor(t){this._iterator=t}[Symbol.asyncIterator](){if(this._iterating)throw new Error("Multiple iterator not supported");return this._iterating=!0,this._iterator}};function ln(){let e=dn(),{writer:t,iterator:r}=e;return{encoder:fn(t),iterator:r}}function ni(e){if(e===void 0)return[];if(!Array.isArray(e)){let r=B.asCID(e);if(!r)throw new TypeError("roots must be a single CID or an array of CIDs");return[r]}let t=[];for(let r of e){let n=B.asCID(r);if(!n)throw new TypeError("roots must be a single CID or an array of CIDs");t.push(n)}return t}function oi(e){return e[Symbol.asyncIterator]!=null}function ii(e){if(oi(e))return(async()=>{for await(let t of e);})();for(let t of e);}var hn=ii;function si(e){let[t,r]=e[Symbol.asyncIterator]!=null?[e[Symbol.asyncIterator](),Symbol.asyncIterator]:[e[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>t.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:t.next(),[r](){return this}}}var pn=si;function ai(e){return e[Symbol.asyncIterator]!=null}function ci(e,t){let r=0;if(ai(e))return async function*(){for await(let c of e)yield t(c,r++)}();let n=pn(e),{value:o,done:i}=n.next();if(i===!0)return function*(){}();let a=t(o,r++);if(typeof a.then=="function")return async function*(){yield await a;for await(let c of n)yield t(c,r++)}();let u=t;return function*(){yield a;for(let c of n)yield u(c,r++)}()}var yn=ci;function Tt(){let e={};return e.promise=new Promise((t,r)=>{e.resolve=t,e.reject=r}),e}var It=Se(wn(),1);var ke=class extends Error{constructor(t){super(t),this.name="TimeoutError"}},Ct=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t}},gn=e=>globalThis.DOMException===void 0?new Ct(e):new DOMException(e),xn=e=>{let t=e.reason===void 0?gn("This operation was aborted."):e.reason;return t instanceof Error?t:gn(t)};function St(e,t){let{milliseconds:r,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout}}=t,a,c=new Promise((p,l)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(t.signal){let{signal:v}=t;v.aborted&&l(xn(v)),v.addEventListener("abort",()=>{l(xn(v))})}if(r===Number.POSITIVE_INFINITY){e.then(p,l);return}let m=new ke;a=i.setTimeout.call(void 0,()=>{if(n){try{p(n())}catch(v){l(v)}return}typeof e.cancel=="function"&&e.cancel(),o===!1?p():o instanceof Error?l(o):(m.message=o??`Promise timed out after ${r} milliseconds`,l(m))},r),(async()=>{try{p(await e)}catch(v){l(v)}})()}).finally(()=>{c.clear()});return c.clear=()=>{i.clearTimeout.call(void 0,a),a=void 0},c}function Ut(e,t,r){let n=0,o=e.length;for(;o>0;){let i=Math.trunc(o/2),a=n+i;r(e[a],t)<=0?(n=++a,o-=i+1):o=i}return n}var Te=class{#e=[];enqueue(t,r){r={priority:0,...r};let n={priority:r.priority,run:t};if(this.size&&this.#e[this.size-1].priority>=r.priority){this.#e.push(n);return}let o=Ut(this.#e,n,(i,a)=>a.priority-i.priority);this.#e.splice(o,0,n)}dequeue(){return this.#e.shift()?.run}filter(t){return this.#e.filter(r=>r.priority===t.priority).map(r=>r.run)}get size(){return this.#e.length}};var Ae=class extends It.default{#e;#s;#i=0;#h;#a;#p=0;#r;#c;#t;#y;#n=0;#u;#o;#m;timeout;constructor(t){if(super(),t={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:Te,...t},!(typeof t.intervalCap=="number"&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${t.intervalCap?.toString()??""}\` (${typeof t.intervalCap})`);if(t.interval===void 0||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${t.interval?.toString()??""}\` (${typeof t.interval})`);this.#e=t.carryoverConcurrencyCount,this.#s=t.intervalCap===Number.POSITIVE_INFINITY||t.interval===0,this.#h=t.intervalCap,this.#a=t.interval,this.#t=new t.queueClass,this.#y=t.queueClass,this.concurrency=t.concurrency,this.timeout=t.timeout,this.#m=t.throwOnTimeout===!0,this.#o=t.autoStart===!1}get#x(){return this.#s||this.#i<this.#h}get#b(){return this.#n<this.#u}#v(){this.#n--,this.#f(),this.emit("next")}#E(){this.#g(),this.#w(),this.#c=void 0}get#_(){let t=Date.now();if(this.#r===void 0){let r=this.#p-t;if(r<0)this.#i=this.#e?this.#n:0;else return this.#c===void 0&&(this.#c=setTimeout(()=>{this.#E()},r)),!0}return!1}#f(){if(this.#t.size===0)return this.#r&&clearInterval(this.#r),this.#r=void 0,this.emit("empty"),this.#n===0&&this.emit("idle"),!1;if(!this.#o){let t=!this.#_;if(this.#x&&this.#b){let r=this.#t.dequeue();return r?(this.emit("active"),r(),t&&this.#w(),!0):!1}}return!1}#w(){this.#s||this.#r!==void 0||(this.#r=setInterval(()=>{this.#g()},this.#a),this.#p=Date.now()+this.#a)}#g(){this.#i===0&&this.#n===0&&this.#r&&(clearInterval(this.#r),this.#r=void 0),this.#i=this.#e?this.#n:0,this.#d()}#d(){for(;this.#f(););}get concurrency(){return this.#u}set concurrency(t){if(!(typeof t=="number"&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);this.#u=t,this.#d()}async#k(t){return new Promise((r,n)=>{t.addEventListener("abort",()=>{n(t.reason)},{once:!0})})}async add(t,r={}){return r={timeout:this.timeout,throwOnTimeout:this.#m,...r},new Promise((n,o)=>{this.#t.enqueue(async()=>{this.#n++,this.#i++;try{r.signal?.throwIfAborted();let i=t({signal:r.signal});r.timeout&&(i=St(Promise.resolve(i),{milliseconds:r.timeout})),r.signal&&(i=Promise.race([i,this.#k(r.signal)]));let a=await i;n(a),this.emit("completed",a)}catch(i){if(i instanceof ke&&!r.throwOnTimeout){n();return}o(i),this.emit("error",i)}finally{this.#v()}},r),this.emit("add"),this.#f()})}async addAll(t,r){return Promise.all(t.map(async n=>this.add(n,r)))}start(){return this.#o?(this.#o=!1,this.#d(),this):this}pause(){this.#o=!0}clear(){this.#t=new this.#y}async onEmpty(){this.#t.size!==0&&await this.#l("empty")}async onSizeLessThan(t){this.#t.size<t||await this.#l("next",()=>this.#t.size<t)}async onIdle(){this.#n===0&&this.#t.size===0||await this.#l("idle")}async#l(t,r){return new Promise(n=>{let o=()=>{r&&!r()||(this.off(t,o),n())};this.on(t,o)})}get size(){return this.#t.size}sizeBy(t){return this.#t.filter(t).length}get pending(){return this.#n}get isPaused(){return this.#o}};var di=1,Bt=class{components;constructor(t,r){this.components=t}async import(t,r){await hn(this.components.blockstore.putMany(yn(t.blocks(),({cid:n,bytes:o})=>({cid:n,block:o})),r))}async export(t,r,n){let o=Tt(),i=Array.isArray(t)?t:[t],a=new Ae({concurrency:di});a.on("idle",()=>{o.resolve()}),a.on("error",u=>{a.clear(),o.reject(u)});for(let u of i)a.add(async()=>{await this.#e(u,a,async(c,p)=>{n?.blockFilter?.has(c.multihash.bytes)!==!0&&(n?.blockFilter?.add(c.multihash.bytes),await r.put({cid:c,bytes:p}))},n)}).catch(()=>{});try{await o.promise}finally{await r.close()}}async*stream(t,r){let{writer:n,out:o}=Ee.create(t);this.export(t,n,r).catch(()=>{});for await(let i of o)yield i}async#e(t,r,n,o){let i=this.components.dagWalkers[t.code];if(i==null)throw new Error(`No dag walker found for cid codec ${t.code}`);let a=await this.components.blockstore.get(t,o);await n(t,a);for await(let u of i.walk(a))r.add(async()=>{await this.#e(u,r,n,o)})}};function li(e,t={}){return new Bt(e,t)}return An(hi);})();
|
|
2
|
+
"use strict";var HeliaCar=(()=>{var Tn=Object.create;var Se=Object.defineProperty;var In=Object.getOwnPropertyDescriptor;var Cn=Object.getOwnPropertyNames;var Sn=Object.getPrototypeOf,Un=Object.prototype.hasOwnProperty;var ce=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Bn=(e,t)=>{for(var r in t)Se(e,r,{get:t[r],enumerable:!0})},$t=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Cn(t))!Un.call(e,o)&&o!==r&&Se(e,o,{get:()=>t[o],enumerable:!(n=In(t,o))||n.enumerable});return e};var Ue=(e,t,r)=>(r=e!=null?Tn(Sn(e)):{},$t(t||!e||!e.__esModule?Se(r,"default",{value:e,enumerable:!0}):r,e)),Nn=e=>$t(Se({},"__esModule",{value:!0}),e);var on=ce((ta,nn)=>{nn.exports=gt;var rn=128,qo=127,Ho=~qo,Go=Math.pow(2,31);function gt(e,t,r){if(Number.MAX_SAFE_INTEGER&&e>Number.MAX_SAFE_INTEGER)throw gt.bytes=0,new RangeError("Could not encode varint");t=t||[],r=r||0;for(var n=r;e>=Go;)t[r++]=e&255|rn,e/=128;for(;e&Ho;)t[r++]=e&255|rn,e>>>=7;return t[r]=e|0,gt.bytes=r-n+1,t}});var cn=ce((ra,an)=>{an.exports=xt;var Wo=128,sn=127;function xt(e,n){var r=0,n=n||0,o=0,i=n,a,u=e.length;do{if(i>=u||o>49)throw xt.bytes=0,new RangeError("Could not decode varint");a=e[i++],r+=o<28?(a&sn)<<o:(a&sn)*Math.pow(2,o),o+=7}while(a>=Wo);return xt.bytes=i-n,r}});var fn=ce((na,un)=>{var jo=Math.pow(2,7),Ko=Math.pow(2,14),Yo=Math.pow(2,21),Jo=Math.pow(2,28),Xo=Math.pow(2,35),Qo=Math.pow(2,42),Zo=Math.pow(2,49),ei=Math.pow(2,56),ti=Math.pow(2,63);un.exports=function(e){return e<jo?1:e<Ko?2:e<Yo?3:e<Jo?4:e<Xo?5:e<Qo?6:e<Zo?7:e<ei?8:e<ti?9:10}});var Ge=ce((oa,dn)=>{dn.exports={encode:on(),decode:cn(),encodingLength:fn()}});var _n=ce((wc,Nt)=>{"use strict";var xi=Object.prototype.hasOwnProperty,_="~";function ke(){}Object.create&&(ke.prototype=Object.create(null),new ke().__proto__||(_=!1));function bi(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function En(e,t,r,n,o){if(typeof r!="function")throw new TypeError("The listener must be a function");var i=new bi(r,n||e,o),a=_?_+t:t;return e._events[a]?e._events[a].fn?e._events[a]=[e._events[a],i]:e._events[a].push(i):(e._events[a]=i,e._eventsCount++),e}function Ye(e,t){--e._eventsCount===0?e._events=new ke:delete e._events[t]}function v(){this._events=new ke,this._eventsCount=0}v.prototype.eventNames=function(){var t=[],r,n;if(this._eventsCount===0)return t;for(n in r=this._events)xi.call(r,n)&&t.push(_?n.slice(1):n);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(r)):t};v.prototype.listeners=function(t){var r=_?_+t:t,n=this._events[r];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,i=n.length,a=new Array(i);o<i;o++)a[o]=n[o].fn;return a};v.prototype.listenerCount=function(t){var r=_?_+t:t,n=this._events[r];return n?n.fn?1:n.length:0};v.prototype.emit=function(t,r,n,o,i,a){var u=_?_+t:t;if(!this._events[u])return!1;var c=this._events[u],p=arguments.length,l,m;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),p){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,r),!0;case 3:return c.fn.call(c.context,r,n),!0;case 4:return c.fn.call(c.context,r,n,o),!0;case 5:return c.fn.call(c.context,r,n,o,i),!0;case 6:return c.fn.call(c.context,r,n,o,i,a),!0}for(m=1,l=new Array(p-1);m<p;m++)l[m-1]=arguments[m];c.fn.apply(c.context,l)}else{var E=c.length,K;for(m=0;m<E;m++)switch(c[m].once&&this.removeListener(t,c[m].fn,void 0,!0),p){case 1:c[m].fn.call(c[m].context);break;case 2:c[m].fn.call(c[m].context,r);break;case 3:c[m].fn.call(c[m].context,r,n);break;case 4:c[m].fn.call(c[m].context,r,n,o);break;default:if(!l)for(K=1,l=new Array(p-1);K<p;K++)l[K-1]=arguments[K];c[m].fn.apply(c[m].context,l)}}return!0};v.prototype.on=function(t,r,n){return En(this,t,r,n,!1)};v.prototype.once=function(t,r,n){return En(this,t,r,n,!0)};v.prototype.removeListener=function(t,r,n,o){var i=_?_+t:t;if(!this._events[i])return this;if(!r)return Ye(this,i),this;var a=this._events[i];if(a.fn)a.fn===r&&(!o||a.once)&&(!n||a.context===n)&&Ye(this,i);else{for(var u=0,c=[],p=a.length;u<p;u++)(a[u].fn!==r||o&&!a[u].once||n&&a[u].context!==n)&&c.push(a[u]);c.length?this._events[i]=c.length===1?c[0]:c:Ye(this,i)}return this};v.prototype.removeAllListeners=function(t){var r;return t?(r=_?_+t:t,this._events[r]&&Ye(this,r)):(this._events=new ke,this._eventsCount=0),this};v.prototype.off=v.prototype.removeListener;v.prototype.addListener=v.prototype.on;v.prefixed=_;v.EventEmitter=v;typeof Nt<"u"&&(Nt.exports=v)});var _i={};Bn(_i,{car:()=>Ei});var On=["string","number","bigint","symbol"],Dn=["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(On.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(Mn(e))return"Buffer";let r=Rn(e);return r||"Object"}function Mn(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function Rn(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(Dn.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 d=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 X=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",zn=new TextDecoder,$n=new TextEncoder;function Be(e){return X&&globalThis.Buffer.isBuffer(e)}function Je(e){return e instanceof Uint8Array?Be(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var qt=X?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):Pt(e,t,r):(e,t,r)=>r-t>64?zn.decode(e.subarray(t,r)):Pt(e,t,r),Ht=X?e=>e.length>64?globalThis.Buffer.from(e):Vt(e):e=>e.length>64?$n.encode(e):Vt(e),L=e=>Uint8Array.from(e),Q=X?(e,t,r)=>Be(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),Gt=X?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),Je(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=X?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function jt(e,t){if(Be(e)&&Be(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):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128)}return t}function Pt(e,t,r){let n=[];for(;t<r;){let o=e[t],i=null,a=o>239?4:o>223?3:o>191?2:1;if(t+a<=r){let u,c,p,l;switch(a){case 1:o<128&&(i=o);break;case 2:u=e[t+1],(u&192)===128&&(l=(o&31)<<6|u&63,l>127&&(i=l));break;case 3:u=e[t+1],c=e[t+2],(u&192)===128&&(c&192)===128&&(l=(o&15)<<12|(u&63)<<6|c&63,l>2047&&(l<55296||l>57343)&&(i=l));break;case 4:u=e[t+1],c=e[t+2],p=e[t+3],(u&192)===128&&(c&192)===128&&(p&192)===128&&(l=(o&15)<<18|(u&63)<<12|(c&63)<<6|p&63,l>65535&&l<1114112&&(i=l))}}i===null?(i=65533,a=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),t+=a}return Ln(n)}var Ft=4096;function Ln(e){let t=e.length;if(t<=Ft)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=Ft));return r}var Vn=256,ue=class{constructor(t=Vn){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=Q(n,0,this.cursor)}else r=Gt(this.chunks,this.cursor);return t&&this.reset(),r}};var h="CBOR decode error:",Xe="CBOR encode error:",fe=[];fe[23]=1;fe[24]=2;fe[25]=3;fe[26]=5;fe[27]=9;function F(e,t,r){if(e.length-t<r)throw new Error(`${h} not enough data for type`)}var x=[24,256,65536,4294967296,BigInt("18446744073709551616")];function A(e,t,r){F(e,t,1);let n=e[t];if(r.strict===!0&&n<x[0])throw new Error(`${h} integer encoded in more bytes than necessary (strict decode)`);return n}function T(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(`${h} integer encoded in more bytes than necessary (strict decode)`);return n}function I(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(`${h} integer encoded in more bytes than necessary (strict decode)`);return n}function C(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(`${h} 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(`${h} integers outside of the safe integer range are not supported`)}function Kt(e,t,r,n){return new d(s.uint,A(e,t+1,n),2)}function Yt(e,t,r,n){return new d(s.uint,T(e,t+1,n),3)}function Jt(e,t,r,n){return new d(s.uint,I(e,t+1,n),5)}function Xt(e,t,r,n){return new d(s.uint,C(e,t+1,n),9)}function U(e,t){return b(e,0,t.value)}function b(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)),a=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]=a&255,a=a>>8,o[3]=a&255,a=a>>8,o[2]=a&255,a=a>>8,o[1]=a&255,e.push(o)}else throw new Error(`${h} encountered BigInt larger than allowable range`)}}U.encodedSize=function(t){return b.encodedSize(t.value)};b.encodedSize=function(t){return t<x[0]?1:t<x[1]?2:t<x[2]?3:t<x[3]?5:9};U.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function Qt(e,t,r,n){return new d(s.negint,-1-A(e,t+1,n),2)}function Zt(e,t,r,n){return new d(s.negint,-1-T(e,t+1,n),3)}function er(e,t,r,n){return new d(s.negint,-1-I(e,t+1,n),5)}var Qe=BigInt(-1),tr=BigInt(1);function rr(e,t,r,n){let o=C(e,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new d(s.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${h} integers outside of the safe integer range are not supported`);return new d(s.negint,Qe-BigInt(o),9)}function Ne(e,t){let r=t.value,n=typeof r=="bigint"?r*Qe-tr:r*-1-1;b(e,t.type.majorEncoded,n)}Ne.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*Qe-tr:r*-1-1;return n<x[0]?1:n<x[1]?2:n<x[2]?3:n<x[3]?5:9};Ne.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function de(e,t,r,n){F(e,t,r+n);let o=Q(e,t+r,t+r+n);return new d(s.bytes,o,r+n)}function nr(e,t,r,n){return de(e,t,1,r)}function or(e,t,r,n){return de(e,t,2,A(e,t+1,n))}function ir(e,t,r,n){return de(e,t,3,T(e,t+1,n))}function sr(e,t,r,n){return de(e,t,5,I(e,t+1,n))}function ar(e,t,r,n){let o=C(e,t+1,n);if(typeof o=="bigint")throw new Error(`${h} 64-bit integer bytes lengths not supported`);return de(e,t,9,o)}function Oe(e){return e.encodedBytes===void 0&&(e.encodedBytes=e.type===s.string?Ht(e.value):e.value),e.encodedBytes}function Z(e,t){let r=Oe(t);b(e,t.type.majorEncoded,r.length),e.push(r)}Z.encodedSize=function(t){let r=Oe(t);return b.encodedSize(r.length)+r.length};Z.compareTokens=function(t,r){return Fn(Oe(t),Oe(r))};function Fn(e,t){return e.length<t.length?-1:e.length>t.length?1:jt(e,t)}function le(e,t,r,n,o){let i=r+n;F(e,t,i);let a=new d(s.string,qt(e,t+r,t+i),i);return o.retainStringBytes===!0&&(a.byteValue=Q(e,t+r,t+i)),a}function cr(e,t,r,n){return le(e,t,1,r,n)}function ur(e,t,r,n){return le(e,t,2,A(e,t+1,n),n)}function fr(e,t,r,n){return le(e,t,3,T(e,t+1,n),n)}function dr(e,t,r,n){return le(e,t,5,I(e,t+1,n),n)}function lr(e,t,r,n){let o=C(e,t+1,n);if(typeof o=="bigint")throw new Error(`${h} 64-bit integer string lengths not supported`);return le(e,t,9,o,n)}var hr=Z;function ee(e,t,r,n){return new d(s.array,n,r)}function pr(e,t,r,n){return ee(e,t,1,r)}function yr(e,t,r,n){return ee(e,t,2,A(e,t+1,n))}function mr(e,t,r,n){return ee(e,t,3,T(e,t+1,n))}function wr(e,t,r,n){return ee(e,t,5,I(e,t+1,n))}function gr(e,t,r,n){let o=C(e,t+1,n);if(typeof o=="bigint")throw new Error(`${h} 64-bit integer array lengths not supported`);return ee(e,t,9,o)}function xr(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${h} indefinite length items not allowed`);return ee(e,t,1,1/0)}function De(e,t){b(e,s.array.majorEncoded,t.value)}De.compareTokens=U.compareTokens;De.encodedSize=function(t){return b.encodedSize(t.value)};function te(e,t,r,n){return new d(s.map,n,r)}function br(e,t,r,n){return te(e,t,1,r)}function vr(e,t,r,n){return te(e,t,2,A(e,t+1,n))}function Er(e,t,r,n){return te(e,t,3,T(e,t+1,n))}function _r(e,t,r,n){return te(e,t,5,I(e,t+1,n))}function kr(e,t,r,n){let o=C(e,t+1,n);if(typeof o=="bigint")throw new Error(`${h} 64-bit integer map lengths not supported`);return te(e,t,9,o)}function Ar(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${h} indefinite length items not allowed`);return te(e,t,1,1/0)}function Me(e,t){b(e,s.map.majorEncoded,t.value)}Me.compareTokens=U.compareTokens;Me.encodedSize=function(t){return b.encodedSize(t.value)};function Tr(e,t,r,n){return new d(s.tag,r,1)}function Ir(e,t,r,n){return new d(s.tag,A(e,t+1,n),2)}function Cr(e,t,r,n){return new d(s.tag,T(e,t+1,n),3)}function Sr(e,t,r,n){return new d(s.tag,I(e,t+1,n),5)}function Ur(e,t,r,n){return new d(s.tag,C(e,t+1,n),9)}function Re(e,t){b(e,s.tag.majorEncoded,t.value)}Re.compareTokens=U.compareTokens;Re.encodedSize=function(t){return b.encodedSize(t.value)};var Kn=20,Yn=21,Jn=22,Xn=23;function Br(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${h} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new d(s.null,null,1):new d(s.undefined,void 0,1)}function Nr(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${h} indefinite length items not allowed`);return new d(s.break,void 0,1)}function Ze(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${h} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${h} Infinity values are not supported`)}return new d(s.float,e,t)}function Or(e,t,r,n){return Ze(et(e,t+1),3,n)}function Dr(e,t,r,n){return Ze(tt(e,t+1),5,n)}function Mr(e,t,r,n){return Ze(Lr(e,t+1),9,n)}function ze(e,t,r){let n=t.value;if(n===!1)e.push([s.float.majorEncoded|Kn]);else if(n===!0)e.push([s.float.majorEncoded|Yn]);else if(n===null)e.push([s.float.majorEncoded|Jn]);else if(n===void 0)e.push([s.float.majorEncoded|Xn]);else{let o,i=!1;(!r||r.float64!==!0)&&(zr(n),o=et(D,1),n===o||Number.isNaN(n)?(D[0]=249,e.push(D.slice(0,3)),i=!0):($r(n),o=tt(D,1),n===o&&(D[0]=250,e.push(D.slice(0,5)),i=!0))),i||(Qn(n),o=Lr(D,1),D[0]=251,e.push(D.slice(0,9)))}}ze.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){zr(n);let o=et(D,1);if(n===o||Number.isNaN(n))return 3;if($r(n),o=tt(D,1),n===o)return 5}return 9};var Rr=new ArrayBuffer(9),B=new DataView(Rr,1),D=new Uint8Array(Rr,0);function zr(e){if(e===1/0)B.setUint16(0,31744,!1);else if(e===-1/0)B.setUint16(0,64512,!1);else if(Number.isNaN(e))B.setUint16(0,32256,!1);else{B.setFloat32(0,e);let t=B.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)B.setUint16(0,31744,!1);else if(r===0)B.setUint16(0,(e&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?B.setUint16(0,0):o<-14?B.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):B.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function et(e,t){if(e.length-t<2)throw new Error(`${h} 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 $r(e){B.setFloat32(0,e,!1)}function tt(e,t){if(e.length-t<4)throw new Error(`${h} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function Qn(e){B.setFloat64(0,e,!1)}function Lr(e,t){if(e.length-t<8)throw new Error(`${h} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}ze.compareTokens=U.compareTokens;function y(e,t,r){throw new Error(`${h} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function $e(e){return()=>{throw new Error(`${h} ${e}`)}}var f=[];for(let e=0;e<=23;e++)f[e]=y;f[24]=Kt;f[25]=Yt;f[26]=Jt;f[27]=Xt;f[28]=y;f[29]=y;f[30]=y;f[31]=y;for(let e=32;e<=55;e++)f[e]=y;f[56]=Qt;f[57]=Zt;f[58]=er;f[59]=rr;f[60]=y;f[61]=y;f[62]=y;f[63]=y;for(let e=64;e<=87;e++)f[e]=nr;f[88]=or;f[89]=ir;f[90]=sr;f[91]=ar;f[92]=y;f[93]=y;f[94]=y;f[95]=$e("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)f[e]=cr;f[120]=ur;f[121]=fr;f[122]=dr;f[123]=lr;f[124]=y;f[125]=y;f[126]=y;f[127]=$e("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)f[e]=pr;f[152]=yr;f[153]=mr;f[154]=wr;f[155]=gr;f[156]=y;f[157]=y;f[158]=y;f[159]=xr;for(let e=160;e<=183;e++)f[e]=br;f[184]=vr;f[185]=Er;f[186]=_r;f[187]=kr;f[188]=y;f[189]=y;f[190]=y;f[191]=Ar;for(let e=192;e<=215;e++)f[e]=Tr;f[216]=Ir;f[217]=Cr;f[218]=Sr;f[219]=Ur;f[220]=y;f[221]=y;f[222]=y;f[223]=y;for(let e=224;e<=243;e++)f[e]=$e("simple values are not supported");f[244]=y;f[245]=y;f[246]=y;f[247]=Br;f[248]=$e("simple values are not supported");f[249]=Or;f[250]=Dr;f[251]=Mr;f[252]=y;f[253]=y;f[254]=y;f[255]=Nr;var M=[];for(let e=0;e<24;e++)M[e]=new d(s.uint,e,1);for(let e=-1;e>=-24;e--)M[31-e]=new d(s.negint,e,1);M[64]=new d(s.bytes,new Uint8Array(0),1);M[96]=new d(s.string,"",1);M[128]=new d(s.array,0,1);M[160]=new d(s.map,0,1);M[244]=new d(s.false,!1,1);M[245]=new d(s.true,!0,1);M[246]=new d(s.null,null,1);function rt(e){switch(e.type){case s.false:return L([244]);case s.true:return L([245]);case s.null:return L([246]);case s.bytes:return e.value.length?void 0:L([64]);case s.string:return e.value===""?L([96]):void 0;case s.array:return e.value===0?L([128]):void 0;case s.map:return e.value===0?L([160]):void 0;case s.uint:return e.value<24?L([Number(e.value)]):void 0;case s.negint:if(e.value>=-24)return L([31-Number(e.value)])}}var eo={float64:!1,mapSorter:ro,quickEncodeToken:rt};function ot(){let e=[];return e[s.uint.major]=U,e[s.negint.major]=Ne,e[s.bytes.major]=Z,e[s.string.major]=hr,e[s.array.major]=De,e[s.map.major]=Me,e[s.tag.major]=Re,e[s.float.major]=ze,e}var Vr=ot(),nt=new ue,Le=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(`${Xe} object contains circular references`);return new e(r,t)}},G={null:new d(s.null,null),undefined:new d(s.undefined,void 0),true:new d(s.true,!0),false:new d(s.false,!1),emptyArray:new d(s.array,0),emptyMap:new d(s.map,0)},W={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new d(s.float,e):e>=0?new d(s.uint,e):new d(s.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new d(s.uint,e):new d(s.negint,e)},Uint8Array(e,t,r,n){return new d(s.bytes,e)},string(e,t,r,n){return new d(s.string,e)},boolean(e,t,r,n){return e?G.true:G.false},null(e,t,r,n){return G.null},undefined(e,t,r,n){return G.undefined},ArrayBuffer(e,t,r,n){return new d(s.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new d(s.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[G.emptyArray,new d(s.break)]:G.emptyArray;n=Le.createCheck(n,e);let o=[],i=0;for(let a of e)o[i++]=he(a,r,n);return r.addBreakTokens?[new d(s.array,e.length),o,new d(s.break)]:[new d(s.array,e.length),o]},Object(e,t,r,n){let o=t!=="Object",i=o?e.keys():Object.keys(e),a=o?e.size:i.length;if(!a)return r.addBreakTokens===!0?[G.emptyMap,new d(s.break)]:G.emptyMap;n=Le.createCheck(n,e);let u=[],c=0;for(let p of i)u[c++]=[he(p,r,n),he(o?e.get(p):e[p],r,n)];return to(u,r),r.addBreakTokens?[new d(s.map,a),u,new d(s.break)]:[new d(s.map,a),u]}};W.Map=W.Object;W.Buffer=W.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))W[`${e}Array`]=W.DataView;function he(e,t={},r){let n=Lt(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||W[n];if(typeof o=="function"){let a=o(e,n,t,r);if(a!=null)return a}let i=W[n];if(!i)throw new Error(`${Xe} unsupported type: ${n}`);return i(e,n,t,r)}function to(e,t){t.mapSorter&&e.sort(t.mapSorter)}function ro(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=Vr[o].compareTokens(r,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function Pr(e,t,r,n){if(Array.isArray(t))for(let o of t)Pr(e,o,r,n);else r[t.type.major](e,t,n)}function no(e,t,r){let n=he(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 a=i.encodedSize(n,r),u=new ue(a);if(i(u,n,r),u.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return Je(u.chunks[0])}}return nt.reset(),Pr(nt,n,t,r),nt.toBytes(!0)}function it(e,t){return t=Object.assign({},eo,t),no(e,Vr,t)}var oo={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Ve=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=M[t];if(r===void 0){let n=f[t];if(!n)throw new Error(`${h} 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}},pe=Symbol.for("DONE"),Pe=Symbol.for("BREAK");function io(e,t,r){let n=[];for(let o=0;o<e.value;o++){let i=re(t,r);if(i===Pe){if(e.value===1/0)break;throw new Error(`${h} got unexpected break to lengthed array`)}if(i===pe)throw new Error(`${h} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=i}return n}function so(e,t,r){let n=r.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let a=0;a<e.value;a++){let u=re(t,r);if(u===Pe){if(e.value===1/0)break;throw new Error(`${h} got unexpected break to lengthed map`)}if(u===pe)throw new Error(`${h} found map but not enough entries (got ${a} [no key], expected ${e.value})`);if(n!==!0&&typeof u!="string")throw new Error(`${h} non-string keys not supported (got ${typeof u})`);if(r.rejectDuplicateMapKeys===!0&&(n&&i.has(u)||!n&&u in o))throw new Error(`${h} found repeat map key "${u}"`);let c=re(t,r);if(c===pe)throw new Error(`${h} found map but not enough entries (got ${a} [no value], expected ${e.value})`);n?i.set(u,c):o[u]=c}return n?i:o}function re(e,t){if(e.done())return pe;let r=e.next();if(r.type===s.break)return Pe;if(r.type.terminal)return r.value;if(r.type===s.array)return io(r,e,t);if(r.type===s.map)return so(r,e,t);if(r.type===s.tag){if(t.tags&&typeof t.tags[r.value]=="function"){let n=re(e,t);return t.tags[r.value](n)}throw new Error(`${h} tag not supported (${r.value})`)}throw new Error("unsupported")}function Fr(e,t){if(!(e instanceof Uint8Array))throw new Error(`${h} data to decode must be a Uint8Array`);t=Object.assign({},oo,t);let r=t.tokenizer||new Ve(e,t),n=re(r,t);if(n===pe)throw new Error(`${h} did not find any content to decode`);if(n===Pe)throw new Error(`${h} got unexpected break`);return[n,e.subarray(r.pos())]}function st(e,t){let[r,n]=Fr(e,t);if(n.length>0)throw new Error(`${h} too many terminals, data makes no sense`);return r}var Es=new Uint8Array(0);function qr(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 ne(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 co(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),a=i.charCodeAt(0);if(r[a]!==255)throw new TypeError(i+" is ambiguous");r[a]=o}var u=e.length,c=e.charAt(0),p=Math.log(u)/Math.log(256),l=Math.log(256)/Math.log(u);function m(w){if(w instanceof Uint8Array||(ArrayBuffer.isView(w)?w=new Uint8Array(w.buffer,w.byteOffset,w.byteLength):Array.isArray(w)&&(w=Uint8Array.from(w))),!(w instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(w.length===0)return"";for(var k=0,Y=0,N=0,R=w.length;N!==R&&w[N]===0;)N++,k++;for(var z=(R-N)*l+1>>>0,S=new Uint8Array(z);N!==R;){for(var $=w[N],H=0,O=z-1;($!==0||H<Y)&&O!==-1;O--,H++)$+=256*S[O]>>>0,S[O]=$%u>>>0,$=$/u>>>0;if($!==0)throw new Error("Non-zero carry");Y=H,N++}for(var P=z-Y;P!==z&&S[P]===0;)P++;for(var Ce=c.repeat(k);P<z;++P)Ce+=e.charAt(S[P]);return Ce}function E(w){if(typeof w!="string")throw new TypeError("Expected String");if(w.length===0)return new Uint8Array;var k=0;if(w[k]!==" "){for(var Y=0,N=0;w[k]===c;)Y++,k++;for(var R=(w.length-k)*p+1>>>0,z=new Uint8Array(R);w[k];){var S=r[w.charCodeAt(k)];if(S===255)return;for(var $=0,H=R-1;(S!==0||$<N)&&H!==-1;H--,$++)S+=u*z[H]>>>0,z[H]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");N=$,k++}if(w[k]!==" "){for(var O=R-N;O!==R&&z[O]===0;)O++;for(var P=new Uint8Array(Y+(R-O)),Ce=Y;O!==R;)P[Ce++]=z[O++];return P}}}function K(w){var k=E(w);if(k)return k;throw new Error(`Non-${t} character`)}return{encode:m,decodeUnsafe:E,decode:K}}var uo=co,fo=uo,Gr=fo;var at=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")}},ct=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 Wr(this,t)}},ut=class{decoders;constructor(t){this.decoders=t}or(t){return Wr(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 Wr(e,t){return new ut({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var ft=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 at(t,r,n),this.decoder=new ct(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function jr({name:e,prefix:t,encode:r,decode:n}){return new ft(e,t,r,n)}function oe({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=Gr(r,e);return jr({prefix:t,name:e,encode:n,decode:i=>ne(o(i))})}function lo(e,t,r,n){let o={};for(let l=0;l<t.length;++l)o[t[l]]=l;let i=e.length;for(;e[i-1]==="=";)--i;let a=new Uint8Array(i*r/8|0),u=0,c=0,p=0;for(let l=0;l<i;++l){let m=o[e[l]];if(m===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|m,u+=r,u>=8&&(u-=8,a[p++]=255&c>>u)}if(u>=r||255&c<<8-u)throw new SyntaxError("Unexpected end of data");return a}function ho(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,i="",a=0,u=0;for(let c=0;c<e.length;++c)for(u=u<<8|e[c],a+=8;a>r;)a-=r,i+=t[o&u>>a];if(a!==0&&(i+=t[o&u<<r-a]),n)for(;i.length*r&7;)i+="=";return i}function V({name:e,prefix:t,bitsPerChar:r,alphabet:n}){return jr({prefix:t,name:e,encode(o){return ho(o,n,r)},decode(o){return lo(o,n,r,e)}})}var ye=V({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Cs=V({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ss=V({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Us=V({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Bs=V({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ns=V({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Os=V({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ds=V({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ms=V({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Fe=oe({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),$s=oe({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var q=oe({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ps=oe({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var po=Jr,Kr=128,yo=127,mo=~yo,wo=Math.pow(2,31);function Jr(e,t,r){t=t||[],r=r||0;for(var n=r;e>=wo;)t[r++]=e&255|Kr,e/=128;for(;e&mo;)t[r++]=e&255|Kr,e>>>=7;return t[r]=e|0,Jr.bytes=r-n+1,t}var go=dt,xo=128,Yr=127;function dt(e,n){var r=0,n=n||0,o=0,i=n,a,u=e.length;do{if(i>=u)throw dt.bytes=0,new RangeError("Could not decode varint");a=e[i++],r+=o<28?(a&Yr)<<o:(a&Yr)*Math.pow(2,o),o+=7}while(a>=xo);return dt.bytes=i-n,r}var bo=Math.pow(2,7),vo=Math.pow(2,14),Eo=Math.pow(2,21),_o=Math.pow(2,28),ko=Math.pow(2,35),Ao=Math.pow(2,42),To=Math.pow(2,49),Io=Math.pow(2,56),Co=Math.pow(2,63),So=function(e){return e<bo?1:e<vo?2:e<Eo?3:e<_o?4:e<ko?5:e<Ao?6:e<To?7:e<Io?8:e<Co?9:10},Uo={encode:po,decode:go,encodingLength:So},Bo=Uo,me=Bo;function we(e,t=0){return[me.decode(e,t),me.decode.bytes]}function ie(e,t,r=0){return me.encode(e,t,r),t}function se(e){return me.encodingLength(e)}function ht(e,t){let r=t.byteLength,n=se(e),o=n+se(r),i=new Uint8Array(o+r);return ie(e,i,0),ie(r,i,n),i.set(t,o),new ae(e,r,t,i)}function qe(e){let t=ne(e),[r,n]=we(t),[o,i]=we(t.subarray(n)),a=t.subarray(n+i);if(a.byteLength!==o)throw new Error("Incorrect length");return new ae(r,o,a,t)}function Xr(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&qr(e.bytes,r.bytes)}}var ae=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function Qr(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return Oo(r,pt(e),t??q.encoder);default:return Do(r,pt(e),t??ye.encoder)}}var Zr=new WeakMap;function pt(e){let t=Zr.get(e);if(t==null){let r=new Map;return Zr.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!==xe)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Mo)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=ht(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&&Xr(t.multihash,n.multihash)}toString(t){return Qr(this,t)}toJSON(){return{"/":Qr(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:a}=r;return new e(n,o,i,a??en(n,o,i.bytes))}else if(r[Ro]===!0){let{version:n,multihash:o,code:i}=r,a=qe(o);return e.create(n,i,a)}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!==xe)throw new Error(`Version 0 CID must use dag-pb (code: ${xe}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=en(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,xe,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=ne(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),a=new ae(r.multihashCode,r.digestSize,i,o);return[r.version===0?e.createV0(a):e.createV1(r.codec,a),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[m,E]=we(t.subarray(r));return r+=E,m},o=n(),i=xe;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let a=r,u=n(),c=n(),p=r+c,l=p-a;return{version:o,codec:i,multihashCode:u,digestSize:c,multihashSize:l,size:p}}static parse(t,r){let[n,o]=No(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 pt(i).set(n,t),i}};function No(e,t){switch(e[0]){case"Q":{let r=t??q;return[q.prefix,r.decode(`${q.prefix}${e}`)]}case q.prefix:{let r=t??q;return[q.prefix,r.decode(e)]}case ye.prefix:{let r=t??ye;return[ye.prefix,r.decode(e)]}case Fe.prefix:{let r=t??Fe;return[Fe.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 Oo(e,t,r){let{prefix:n}=r;if(n!==q.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 Do(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 xe=112,Mo=18;function en(e,t,r){let n=se(e),o=n+se(t),i=new Uint8Array(o+r.byteLength);return ie(e,i,0),ie(t,i,n),i.set(r,o),i}var Ro=Symbol.for("@ipld/js-cid/CID");var tn=42;function zo(e){return e instanceof ArrayBuffer?new Uint8Array(e,0,e.byteLength):e}function $o(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 d(s.tag,tn),new d(s.bytes,r)]}function Lo(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function Vo(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}var yt={float64:!0,typeEncoders:{Object:$o,undefined:Lo,number:Vo}},Zs={...yt,typeEncoders:{...yt.typeEncoders}};function Po(e){if(e[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return g.decode(e.subarray(1))}var He={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:[]};He.tags[tn]=Po;var ea={...He,tags:He.tags.slice()};var mt=e=>it(e,yt),wt=e=>st(zo(e),He);var bt=Ue(Ge(),1);var vt=40;function Et(e,t){if(!e.length)throw new Error("Unexpected end of data");let r=bt.default.decode(e);return t.seek(bt.default.decode.bytes),r}function _t(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),r=0;return{version:2,characteristics:[t.getBigUint64(r,!0),t.getBigUint64(r+=8,!0)],dataOffset:Number(t.getBigUint64(r+=8,!0)),dataSize:Number(t.getBigUint64(r+=8,!0)),indexOffset:Number(t.getBigUint64(r+=8,!0))}}var j={Null:e=>e===null?e:void 0,Int:e=>Number.isInteger(e)?e:void 0,Float:e=>typeof e=="number"&&Number.isFinite(e)?e:void 0,String:e=>typeof e=="string"?e:void 0,Bool:e=>typeof e=="boolean"?e:void 0,Bytes:e=>e instanceof Uint8Array?e:void 0,Link:e=>e!==null&&typeof e=="object"&&e.asCID===e?e:void 0,List:e=>Array.isArray(e)?e:void 0,Map:e=>e!==null&&typeof e=="object"&&e.asCID!==e&&!Array.isArray(e)&&!(e instanceof Uint8Array)?e:void 0},be={"CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)":j.Link,"CarV1HeaderOrV2Pragma > roots (anon)":e=>{if(j.List(e)!==void 0){for(let t=0;t<e.length;t++){let r=e[t];if(r=be["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](r),r===void 0)return;if(r!==e[t]){let n=e.slice(0,t);for(let o=t;o<e.length;o++){let i=e[o];if(i=be["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](i),i===void 0)return;n.push(i)}return n}}return e}},Int:j.Int,CarV1HeaderOrV2Pragma:e=>{if(j.Map(e)===void 0)return;let t=Object.entries(e),r=e,n=1;for(let o=0;o<t.length;o++){let[i,a]=t[o];switch(i){case"roots":{let u=be["CarV1HeaderOrV2Pragma > roots (anon)"](e[i]);if(u===void 0)return;if(u!==a||r!==e){if(r===e){r={};for(let c=0;c<o;c++)r[t[c][0]]=t[c][1]}r.roots=u}}break;case"version":{n--;let u=be.Int(e[i]);if(u===void 0)return;if(u!==a||r!==e){if(r===e){r={};for(let c=0;c<o;c++)r[t[c][0]]=t[c][1]}r.version=u}}break;default:return}}if(!(n>0))return r}},ve={"CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)":j.Link,"CarV1HeaderOrV2Pragma > roots (anon)":e=>{if(j.List(e)!==void 0){for(let t=0;t<e.length;t++){let r=e[t];if(r=ve["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](r),r===void 0)return;if(r!==e[t]){let n=e.slice(0,t);for(let o=t;o<e.length;o++){let i=e[o];if(i=ve["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](i),i===void 0)return;n.push(i)}return n}}return e}},Int:j.Int,CarV1HeaderOrV2Pragma:e=>{if(j.Map(e)===void 0)return;let t=Object.entries(e),r=e,n=1;for(let o=0;o<t.length;o++){let[i,a]=t[o];switch(i){case"roots":{let u=ve["CarV1HeaderOrV2Pragma > roots (anon)"](a);if(u===void 0)return;if(u!==a||r!==e){if(r===e){r={};for(let c=0;c<o;c++)r[t[c][0]]=t[c][1]}r.roots=u}}break;case"version":{n--;let u=ve.Int(a);if(u===void 0)return;if(u!==a||r!==e){if(r===e){r={};for(let c=0;c<o;c++)r[t[c][0]]=t[c][1]}r.version=u}}break;default:return}}if(!(n>0))return r}},kt={toTyped:be.CarV1HeaderOrV2Pragma,toRepresentation:ve.CarV1HeaderOrV2Pragma};var ya=ot();var ii=Ue(Ge(),1);var ba=[new d(s.map,2),new d(s.string,"version"),new d(s.uint,1),new d(s.string,"roots")],va=new d(s.tag,42);async function At(e,t){let r=Et(await e.upTo(8),e);if(r===0)throw new Error("Invalid CAR header (zero length)");let n=await e.exactly(r,!0),o=wt(n);if(kt.toTyped(o)===void 0)throw new Error("Invalid CAR header format");if(o.version!==1&&o.version!==2||t!==void 0&&o.version!==t)throw new Error(`Invalid CAR version: ${o.version}${t!==void 0?` (expected ${t})`:""}`);if(o.version===1){if(!Array.isArray(o.roots))throw new Error("Invalid CAR header format");return o}if(o.roots!==void 0)throw new Error("Invalid CAR header format");let i=_t(await e.exactly(vt,!0));e.seek(i.dataOffset-e.pos);let a=await At(e,1);return Object.assign(a,i)}function Ee(e){let t=0;return{async upTo(r){return e.subarray(t,t+Math.min(r,e.length-t))},async exactly(r,n=!1){if(r>e.length-t)throw new Error("Unexpected end of data");let o=e.subarray(t,t+r);return n&&(t+=r),o},seek(r){t+=r},get pos(){return t}}}var Tt=Ue(Ge(),1),pn=1;function It(e){let t=mt({version:pn,roots:e}),r=Tt.default.encode(t.length),n=new Uint8Array(r.length+t.length);return n.set(r,0),n.set(t,r.length),n}function yn(e){return{async setRoots(t){let r=It(t);await e.write(r)},async writeBlock(t){let{cid:r,bytes:n}=t;await e.write(new Uint8Array(Tt.default.encode(r.bytes.length+n.length))),await e.write(r.bytes),n.length&&await e.write(n)},async close(){await e.end()},version(){return pn}}}function We(){}function mn(){let e=[],t=null,r=We,n=!1,o=null,i=We,a=()=>(t||(t=new Promise(p=>{r=()=>{t=null,r=We,p()}})),t),u={write(p){e.push(p);let l=a();return i(),l},async end(){n=!0;let p=a();i(),await p}},c={async next(){let p=e.shift();return p?(e.length===0&&r(),{done:!1,value:p}):n?(r(),{done:!0,value:void 0}):(o||(o=new Promise(l=>{i=()=>(o=null,i=We,l(c.next()))})),o)}};return{writer:u,iterator:c}}var _e=class e{constructor(t,r){this._encoder=r,this._mutex=r.setRoots(t),this._ended=!1}async put(t){if(!(t.bytes instanceof Uint8Array)||!t.cid)throw new TypeError("Can only write {cid, bytes} objects");if(this._ended)throw new Error("Already closed");let r=g.asCID(t.cid);if(!r)throw new TypeError("Can only write {cid, bytes} objects");return this._mutex=this._mutex.then(()=>this._encoder.writeBlock({cid:r,bytes:t.bytes})),this._mutex}async close(){if(this._ended)throw new Error("Already closed");return await this._mutex,this._ended=!0,this._encoder.close()}version(){return this._encoder.version()}static create(t){t=ui(t);let{encoder:r,iterator:n}=wn(),o=new e(t,r),i=new je(n);return{writer:o,out:i}}static createAppender(){let{encoder:t,iterator:r}=wn();t.setRoots=()=>Promise.resolve();let n=new e([],t),o=new je(r);return{writer:n,out:o}}static async updateRootsInBytes(t,r){let n=Ee(t);await At(n);let o=It(r);if(Number(n.pos)!==o.length)throw new Error(`updateRoots() can only overwrite a header of the same length (old header is ${n.pos} bytes, new header is ${o.length} bytes)`);return t.set(o,0),t}},je=class{constructor(t){this._iterator=t}[Symbol.asyncIterator](){if(this._iterating)throw new Error("Multiple iterator not supported");return this._iterating=!0,this._iterator}};function wn(){let e=mn(),{writer:t,iterator:r}=e;return{encoder:yn(t),iterator:r}}function ui(e){if(e===void 0)return[];if(!Array.isArray(e)){let r=g.asCID(e);if(!r)throw new TypeError("roots must be a single CID or an array of CIDs");return[r]}let t=[];for(let r of e){let n=g.asCID(r);if(!n)throw new TypeError("roots must be a single CID or an array of CIDs");t.push(n)}return t}function fi(e){return e[Symbol.asyncIterator]!=null}function di(e){if(fi(e))return(async()=>{for await(let t of e);})();for(let t of e);}var gn=di;function li(e){let[t,r]=e[Symbol.asyncIterator]!=null?[e[Symbol.asyncIterator](),Symbol.asyncIterator]:[e[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>t.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:t.next(),[r](){return this}}}var xn=li;function hi(e){return e[Symbol.asyncIterator]!=null}function pi(e,t){let r=0;if(hi(e))return async function*(){for await(let c of e)yield t(c,r++)}();let n=xn(e),{value:o,done:i}=n.next();if(i===!0)return function*(){}();let a=t(o,r++);if(typeof a.then=="function")return async function*(){yield await a;for await(let c of n)yield t(c,r++)}();let u=t;return function*(){yield a;for(let c of n)yield u(c,r++)}()}var bn=pi;function Ke({enumerable:e=!0,configurable:t=!1}={}){return{enumerable:e,configurable:t,writable:!1}}function*mi(e,t){if(t!=null&&typeof t=="object")if(Array.isArray(t))for(let[r,n]of t.entries()){let o=[...e,r],i=g.asCID(n);i!=null?yield[o.join("/"),i]:typeof n=="object"&&(yield*Ct(n,o))}else{let r=g.asCID(t);r!=null?yield[e.join("/"),r]:yield*Ct(t,e)}}function*Ct(e,t){if(e==null||e instanceof Uint8Array)return;let r=g.asCID(e);r!=null&&(yield[t.join("/"),r]);for(let[n,o]of Object.entries(e)){let i=[...t,n];yield*mi(i,o)}}function*wi(e,t){if(Array.isArray(t))for(let[r,n]of t.entries()){let o=[...e,r];yield o.join("/"),typeof n=="object"&&g.asCID(n)==null&&(yield*St(n,o))}else yield*St(t,e)}function*St(e,t){if(!(e==null||typeof e!="object"))for(let[r,n]of Object.entries(e)){let o=[...t,r];yield o.join("/"),n!=null&&!(n instanceof Uint8Array)&&typeof n=="object"&&g.asCID(n)==null&&(yield*wi(o,n))}}function gi(e,t){let r=e;for(let[n,o]of t.entries()){if(r=r[o],r==null)throw new Error(`Object has no property at ${t.slice(0,n+1).map(a=>`[${JSON.stringify(a)}]`).join("")}`);let i=g.asCID(r);if(i!=null)return{value:i,remaining:t.slice(n+1).join("/")}}return{value:r}}var Ut=class{cid;bytes;value;asBlock;constructor({cid:t,bytes:r,value:n}){if(t==null||r==null||typeof n>"u")throw new Error("Missing required argument");this.cid=t,this.bytes=r,this.value=n,this.asBlock=this,Object.defineProperties(this,{cid:Ke(),bytes:Ke(),value:Ke(),asBlock:Ke()})}links(){return Ct(this.value,[])}tree(){return St(this.value,[])}get(t="/"){return gi(this.value,t.split("/").filter(Boolean))}};function vn({bytes:e,cid:t,value:r,codec:n}){let o=r!==void 0?r:n?.decode(e);if(o===void 0)throw new Error('Missing required argument, must either provide "value" or "codec"');return new Ut({cid:t,bytes:e,value:o})}function Bt(){let e={};return e.promise=new Promise((t,r)=>{e.resolve=t,e.reject=r}),e}var Ot=Ue(_n(),1);var Ae=class extends Error{constructor(t){super(t),this.name="TimeoutError"}},Dt=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t}},kn=e=>globalThis.DOMException===void 0?new Dt(e):new DOMException(e),An=e=>{let t=e.reason===void 0?kn("This operation was aborted."):e.reason;return t instanceof Error?t:kn(t)};function Mt(e,t){let{milliseconds:r,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout}}=t,a,c=new Promise((p,l)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(t.signal){let{signal:E}=t;E.aborted&&l(An(E)),E.addEventListener("abort",()=>{l(An(E))})}if(r===Number.POSITIVE_INFINITY){e.then(p,l);return}let m=new Ae;a=i.setTimeout.call(void 0,()=>{if(n){try{p(n())}catch(E){l(E)}return}typeof e.cancel=="function"&&e.cancel(),o===!1?p():o instanceof Error?l(o):(m.message=o??`Promise timed out after ${r} milliseconds`,l(m))},r),(async()=>{try{p(await e)}catch(E){l(E)}})()}).finally(()=>{c.clear()});return c.clear=()=>{i.clearTimeout.call(void 0,a),a=void 0},c}function Rt(e,t,r){let n=0,o=e.length;for(;o>0;){let i=Math.trunc(o/2),a=n+i;r(e[a],t)<=0?(n=++a,o-=i+1):o=i}return n}var Te=class{#e=[];enqueue(t,r){r={priority:0,...r};let n={priority:r.priority,run:t};if(this.size&&this.#e[this.size-1].priority>=r.priority){this.#e.push(n);return}let o=Rt(this.#e,n,(i,a)=>a.priority-i.priority);this.#e.splice(o,0,n)}dequeue(){return this.#e.shift()?.run}filter(t){return this.#e.filter(r=>r.priority===t.priority).map(r=>r.run)}get size(){return this.#e.length}};var Ie=class extends Ot.default{#e;#s;#i=0;#h;#a;#p=0;#r;#c;#t;#y;#n=0;#u;#o;#m;timeout;constructor(t){if(super(),t={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:Te,...t},!(typeof t.intervalCap=="number"&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${t.intervalCap?.toString()??""}\` (${typeof t.intervalCap})`);if(t.interval===void 0||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${t.interval?.toString()??""}\` (${typeof t.interval})`);this.#e=t.carryoverConcurrencyCount,this.#s=t.intervalCap===Number.POSITIVE_INFINITY||t.interval===0,this.#h=t.intervalCap,this.#a=t.interval,this.#t=new t.queueClass,this.#y=t.queueClass,this.concurrency=t.concurrency,this.timeout=t.timeout,this.#m=t.throwOnTimeout===!0,this.#o=t.autoStart===!1}get#x(){return this.#s||this.#i<this.#h}get#b(){return this.#n<this.#u}#v(){this.#n--,this.#f(),this.emit("next")}#E(){this.#g(),this.#w(),this.#c=void 0}get#_(){let t=Date.now();if(this.#r===void 0){let r=this.#p-t;if(r<0)this.#i=this.#e?this.#n:0;else return this.#c===void 0&&(this.#c=setTimeout(()=>{this.#E()},r)),!0}return!1}#f(){if(this.#t.size===0)return this.#r&&clearInterval(this.#r),this.#r=void 0,this.emit("empty"),this.#n===0&&this.emit("idle"),!1;if(!this.#o){let t=!this.#_;if(this.#x&&this.#b){let r=this.#t.dequeue();return r?(this.emit("active"),r(),t&&this.#w(),!0):!1}}return!1}#w(){this.#s||this.#r!==void 0||(this.#r=setInterval(()=>{this.#g()},this.#a),this.#p=Date.now()+this.#a)}#g(){this.#i===0&&this.#n===0&&this.#r&&(clearInterval(this.#r),this.#r=void 0),this.#i=this.#e?this.#n:0,this.#d()}#d(){for(;this.#f(););}get concurrency(){return this.#u}set concurrency(t){if(!(typeof t=="number"&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);this.#u=t,this.#d()}async#k(t){return new Promise((r,n)=>{t.addEventListener("abort",()=>{n(t.reason)},{once:!0})})}async add(t,r={}){return r={timeout:this.timeout,throwOnTimeout:this.#m,...r},new Promise((n,o)=>{this.#t.enqueue(async()=>{this.#n++,this.#i++;try{r.signal?.throwIfAborted();let i=t({signal:r.signal});r.timeout&&(i=Mt(Promise.resolve(i),{milliseconds:r.timeout})),r.signal&&(i=Promise.race([i,this.#k(r.signal)]));let a=await i;n(a),this.emit("completed",a)}catch(i){if(i instanceof Ae&&!r.throwOnTimeout){n();return}o(i),this.emit("error",i)}finally{this.#v()}},r),this.emit("add"),this.#f()})}async addAll(t,r){return Promise.all(t.map(async n=>this.add(n,r)))}start(){return this.#o?(this.#o=!1,this.#d(),this):this}pause(){this.#o=!0}clear(){this.#t=new this.#y}async onEmpty(){this.#t.size!==0&&await this.#l("empty")}async onSizeLessThan(t){this.#t.size<t||await this.#l("next",()=>this.#t.size<t)}async onIdle(){this.#n===0&&this.#t.size===0||await this.#l("idle")}async#l(t,r){return new Promise(n=>{let o=()=>{r&&!r()||(this.off(t,o),n())};this.on(t,o)})}get size(){return this.#t.size}sizeBy(t){return this.#t.filter(t).length}get pending(){return this.#n}get isPaused(){return this.#o}};var vi=1,zt=class{components;constructor(t,r){this.components=t}async import(t,r){await gn(this.components.blockstore.putMany(bn(t.blocks(),({cid:n,bytes:o})=>({cid:n,block:o})),r))}async export(t,r,n){let o=Bt(),i=Array.isArray(t)?t:[t],a=new Ie({concurrency:vi});a.on("idle",()=>{o.resolve()}),a.on("error",u=>{a.clear(),o.reject(u)});for(let u of i)a.add(async()=>{await this.#e(u,a,async(c,p)=>{n?.blockFilter?.has(c.multihash.bytes)!==!0&&(n?.blockFilter?.add(c.multihash.bytes),await r.put({cid:c,bytes:p}))},n)}).catch(()=>{});try{await o.promise}finally{await r.close()}}async*stream(t,r){let{writer:n,out:o}=_e.create(t);this.export(t,n,r).catch(()=>{});for await(let i of o)yield i}async#e(t,r,n,o){let i=await this.components.getCodec(t.code),a=await this.components.blockstore.get(t,o);await n(t,a);let u=vn({bytes:a,cid:t,codec:i});for await(let[,c]of u.links())r.add(async()=>{await this.#e(c,r,n,o)})}};function Ei(e,t={}){return new zt(e,t)}return Nn(_i);})();
|
|
3
3
|
return HeliaCar}));
|
package/dist/src/index.d.ts
CHANGED
|
@@ -17,13 +17,13 @@
|
|
|
17
17
|
* import { Readable } from 'node:stream'
|
|
18
18
|
* import nodeFs from 'node:fs'
|
|
19
19
|
*
|
|
20
|
-
* const helia = createHelia({
|
|
20
|
+
* const helia = await createHelia({
|
|
21
21
|
* // ... helia config
|
|
22
22
|
* })
|
|
23
23
|
* const fs = unixfs(helia)
|
|
24
24
|
*
|
|
25
25
|
* // add some UnixFS data
|
|
26
|
-
* const cid = await fs.addBytes(
|
|
26
|
+
* const cid = await fs.addBytes(Uint8Array.from([0, 1, 2, 3, 4]))
|
|
27
27
|
*
|
|
28
28
|
* // export it as a Car
|
|
29
29
|
* const c = car(helia)
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
* import { Readable } from 'node:stream'
|
|
47
47
|
* import nodeFs from 'node:fs'
|
|
48
48
|
*
|
|
49
|
-
* const helia = createHelia({
|
|
49
|
+
* const helia = await createHelia({
|
|
50
50
|
* // ... helia config
|
|
51
51
|
* })
|
|
52
52
|
*
|
|
@@ -54,11 +54,12 @@
|
|
|
54
54
|
* const inStream = nodeFs.createReadStream('example.car')
|
|
55
55
|
* const reader = await CarReader.fromIterable(inStream)
|
|
56
56
|
*
|
|
57
|
+
* const c = car(helia)
|
|
57
58
|
* await c.import(reader)
|
|
58
59
|
* ```
|
|
59
60
|
*/
|
|
60
61
|
import { CarWriter } from '@ipld/car';
|
|
61
|
-
import type {
|
|
62
|
+
import type { CodecLoader } from '@helia/interface';
|
|
62
63
|
import type { GetBlockProgressEvents, PutManyBlocksProgressEvents } from '@helia/interface/blocks';
|
|
63
64
|
import type { CarReader } from '@ipld/car';
|
|
64
65
|
import type { AbortOptions } from '@libp2p/interface';
|
|
@@ -68,9 +69,9 @@ import type { CID } from 'multiformats/cid';
|
|
|
68
69
|
import type { ProgressOptions } from 'progress-events';
|
|
69
70
|
export interface CarComponents {
|
|
70
71
|
blockstore: Blockstore;
|
|
71
|
-
|
|
72
|
+
getCodec: CodecLoader;
|
|
72
73
|
}
|
|
73
|
-
interface ExportCarOptions extends AbortOptions, ProgressOptions<GetBlockProgressEvents> {
|
|
74
|
+
export interface ExportCarOptions extends AbortOptions, ProgressOptions<GetBlockProgressEvents> {
|
|
74
75
|
/**
|
|
75
76
|
* If a filter is passed it will be used to deduplicate blocks exported in the car file
|
|
76
77
|
*/
|
|
@@ -154,9 +155,5 @@ export interface Car {
|
|
|
154
155
|
/**
|
|
155
156
|
* Create a {@link Car} instance for use with {@link https://github.com/ipfs/helia Helia}
|
|
156
157
|
*/
|
|
157
|
-
export declare function car(helia:
|
|
158
|
-
blockstore: Blockstore;
|
|
159
|
-
dagWalkers: Record<number, DAGWalker>;
|
|
160
|
-
}, init?: any): Car;
|
|
161
|
-
export {};
|
|
158
|
+
export declare function car(helia: CarComponents, init?: any): Car;
|
|
162
159
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAMrC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,KAAK,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAA;AAClG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEtD,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,UAAU,CAAA;IACtB,QAAQ,EAAE,WAAW,CAAA;CACtB;AAED,MAAM,WAAW,gBAAiB,SAAQ,YAAY,EAAE,eAAe,CAAC,sBAAsB,CAAC;IAC7F;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,GAAG;IAClB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,eAAe,CAAC,2BAA2B,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE/H;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,MAAM,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE,KAAK,GAAG,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE9G;;;;;;;;;;;;;;;;;;;OAmBG;IACH,MAAM,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG,EAAE,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,eAAe,CAAC,sBAAsB,CAAC,GAAG,cAAc,CAAC,UAAU,CAAC,CAAA;CACxH;AA2FD;;GAEG;AACH,wBAAgB,GAAG,CAAE,KAAK,EAAE,aAAa,EAAE,IAAI,GAAE,GAAQ,GAAG,GAAG,CAE9D"}
|
package/dist/src/index.js
CHANGED
|
@@ -17,13 +17,13 @@
|
|
|
17
17
|
* import { Readable } from 'node:stream'
|
|
18
18
|
* import nodeFs from 'node:fs'
|
|
19
19
|
*
|
|
20
|
-
* const helia = createHelia({
|
|
20
|
+
* const helia = await createHelia({
|
|
21
21
|
* // ... helia config
|
|
22
22
|
* })
|
|
23
23
|
* const fs = unixfs(helia)
|
|
24
24
|
*
|
|
25
25
|
* // add some UnixFS data
|
|
26
|
-
* const cid = await fs.addBytes(
|
|
26
|
+
* const cid = await fs.addBytes(Uint8Array.from([0, 1, 2, 3, 4]))
|
|
27
27
|
*
|
|
28
28
|
* // export it as a Car
|
|
29
29
|
* const c = car(helia)
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
* import { Readable } from 'node:stream'
|
|
47
47
|
* import nodeFs from 'node:fs'
|
|
48
48
|
*
|
|
49
|
-
* const helia = createHelia({
|
|
49
|
+
* const helia = await createHelia({
|
|
50
50
|
* // ... helia config
|
|
51
51
|
* })
|
|
52
52
|
*
|
|
@@ -54,12 +54,14 @@
|
|
|
54
54
|
* const inStream = nodeFs.createReadStream('example.car')
|
|
55
55
|
* const reader = await CarReader.fromIterable(inStream)
|
|
56
56
|
*
|
|
57
|
+
* const c = car(helia)
|
|
57
58
|
* await c.import(reader)
|
|
58
59
|
* ```
|
|
59
60
|
*/
|
|
60
61
|
import { CarWriter } from '@ipld/car';
|
|
61
62
|
import drain from 'it-drain';
|
|
62
63
|
import map from 'it-map';
|
|
64
|
+
import { createUnsafe } from 'multiformats/block';
|
|
63
65
|
import defer from 'p-defer';
|
|
64
66
|
import PQueue from 'p-queue';
|
|
65
67
|
const DAG_WALK_QUEUE_CONCURRENCY = 1;
|
|
@@ -121,14 +123,12 @@ class DefaultCar {
|
|
|
121
123
|
* and update the pin count for them
|
|
122
124
|
*/
|
|
123
125
|
async #walkDag(cid, queue, withBlock, options) {
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
const block = await this.components.blockstore.get(cid, options);
|
|
129
|
-
await withBlock(cid, block);
|
|
126
|
+
const codec = await this.components.getCodec(cid.code);
|
|
127
|
+
const bytes = await this.components.blockstore.get(cid, options);
|
|
128
|
+
await withBlock(cid, bytes);
|
|
129
|
+
const block = createUnsafe({ bytes, cid, codec });
|
|
130
130
|
// walk dag, ensure all blocks are present
|
|
131
|
-
for await (const cid of
|
|
131
|
+
for await (const [, cid] of block.links()) {
|
|
132
132
|
void queue.add(async () => {
|
|
133
133
|
await this.#walkDag(cid, queue, withBlock, options);
|
|
134
134
|
});
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,KAAK,MAAM,UAAU,CAAA;AAC5B,OAAO,GAAG,MAAM,QAAQ,CAAA;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,KAAK,MAAM,SAAS,CAAA;AAC3B,OAAO,MAAM,MAAM,SAAS,CAAA;AAoG5B,MAAM,0BAA0B,GAAG,CAAC,CAAA;AAEpC,MAAM,UAAU;IACG,UAAU,CAAe;IAE1C,YAAa,UAAyB,EAAE,IAAS;QAC/C,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;IAED,KAAK,CAAC,MAAM,CAAE,MAAiC,EAAE,OAAqE;QACpH,MAAM,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,OAAO,CAC5C,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,EACjE,OAAO,CACR,CAAC,CAAA;IACJ,CAAC;IAED,KAAK,CAAC,MAAM,CAAE,IAAiB,EAAE,MAAwC,EAAE,OAA0B;QACnG,MAAM,QAAQ,GAAG,KAAK,EAAqB,CAAA;QAC3C,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;QAEjD,sFAAsF;QACtF,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC;YACvB,WAAW,EAAE,0BAA0B;SACxC,CAAC,CAAA;QACF,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;YACpB,QAAQ,CAAC,OAAO,EAAE,CAAA;QACpB,CAAC,CAAC,CAAA;QACF,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YACxB,KAAK,CAAC,KAAK,EAAE,CAAA;YACb,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QACtB,CAAC,CAAC,CAAA;QAEF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,KAAK,KAAK,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE;gBACxB,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE;oBACpD,0EAA0E;oBAC1E,IAAI,OAAO,EAAE,WAAW,EAAE,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC;wBAC5D,OAAM;oBACR,CAAC;oBAED,OAAO,EAAE,WAAW,EAAE,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;oBAC9C,MAAM,MAAM,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAA;gBAClC,CAAC,EAAE,OAAO,CAAC,CAAA;YACb,CAAC,CAAC;iBACC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;QACpB,CAAC;QAED,6BAA6B;QAC7B,IAAI,CAAC;YACH,MAAM,QAAQ,CAAC,OAAO,CAAA;QACxB,CAAC;gBAAS,CAAC;YACT,MAAM,MAAM,CAAC,KAAK,EAAE,CAAA;QACtB,CAAC;IACH,CAAC;IAED,KAAK,CAAC,CAAE,MAAM,CAAE,IAAiB,EAAE,OAA0B;QAC3D,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QAE9C,0EAA0E;QAC1E,YAAY;QACZ,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC;aAC/B,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;QAElB,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;YAC5B,MAAM,GAAG,CAAA;QACX,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,QAAQ,CAAE,GAAQ,EAAE,KAAa,EAAE,SAAyD,EAAE,OAAgE;QAClK,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QACtD,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;QAEhE,MAAM,SAAS,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QAE3B,MAAM,KAAK,GAAG,YAAY,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAA;QAEjD,0CAA0C;QAC1C,IAAI,KAAK,EAAE,MAAM,CAAC,EAAC,GAAG,CAAC,IAAI,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC;YACzC,KAAK,KAAK,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE;gBACxB,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;YACrD,CAAC,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,GAAG,CAAE,KAAoB,EAAE,OAAY,EAAE;IACvD,OAAO,IAAI,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;AACpC,CAAC"}
|
package/dist/typedoc-urls.json
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
".:Car": "https://ipfs.github.io/helia/interfaces/_helia_car.Car.html",
|
|
4
4
|
"CarComponents": "https://ipfs.github.io/helia/interfaces/_helia_car.CarComponents.html",
|
|
5
5
|
".:CarComponents": "https://ipfs.github.io/helia/interfaces/_helia_car.CarComponents.html",
|
|
6
|
+
"ExportCarOptions": "https://ipfs.github.io/helia/interfaces/_helia_car.ExportCarOptions.html",
|
|
7
|
+
".:ExportCarOptions": "https://ipfs.github.io/helia/interfaces/_helia_car.ExportCarOptions.html",
|
|
6
8
|
"car": "https://ipfs.github.io/helia/functions/_helia_car.car-1.html",
|
|
7
9
|
".:car": "https://ipfs.github.io/helia/functions/_helia_car.car-1.html"
|
|
8
10
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helia/car",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Import/export car files from Helia",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/ipfs/helia/tree/main/packages/car#readme",
|
|
@@ -128,6 +128,7 @@
|
|
|
128
128
|
"clean": "aegir clean",
|
|
129
129
|
"lint": "aegir lint",
|
|
130
130
|
"dep-check": "aegir dep-check",
|
|
131
|
+
"doc-check": "aegir doc-check",
|
|
131
132
|
"build": "aegir build",
|
|
132
133
|
"test": "aegir test",
|
|
133
134
|
"test:chrome": "aegir test -t browser --cov",
|
|
@@ -139,10 +140,10 @@
|
|
|
139
140
|
"release": "aegir release"
|
|
140
141
|
},
|
|
141
142
|
"dependencies": {
|
|
142
|
-
"@helia/interface": "^
|
|
143
|
+
"@helia/interface": "^5.0.0",
|
|
143
144
|
"@ipld/car": "^5.3.0",
|
|
144
|
-
"@libp2p/interface": "^
|
|
145
|
-
"@libp2p/utils": "^
|
|
145
|
+
"@libp2p/interface": "^2.0.0",
|
|
146
|
+
"@libp2p/utils": "^6.0.0",
|
|
146
147
|
"interface-blockstore": "^5.2.10",
|
|
147
148
|
"it-drain": "^3.0.5",
|
|
148
149
|
"it-map": "^3.0.5",
|
|
@@ -152,12 +153,12 @@
|
|
|
152
153
|
"progress-events": "^1.0.0"
|
|
153
154
|
},
|
|
154
155
|
"devDependencies": {
|
|
155
|
-
"@helia/mfs": "^
|
|
156
|
-
"@helia/unixfs": "^
|
|
156
|
+
"@helia/mfs": "^4.0.0",
|
|
157
|
+
"@helia/unixfs": "^4.0.0",
|
|
157
158
|
"@ipld/dag-pb": "^4.1.0",
|
|
158
159
|
"aegir": "^44.0.1",
|
|
159
|
-
"blockstore-core": "^
|
|
160
|
-
"datastore-core": "^
|
|
160
|
+
"blockstore-core": "^5.0.0",
|
|
161
|
+
"datastore-core": "^10.0.0",
|
|
161
162
|
"ipfs-unixfs-importer": "^15.2.4",
|
|
162
163
|
"it-to-buffer": "^4.0.5"
|
|
163
164
|
},
|
package/src/index.ts
CHANGED
|
@@ -17,13 +17,13 @@
|
|
|
17
17
|
* import { Readable } from 'node:stream'
|
|
18
18
|
* import nodeFs from 'node:fs'
|
|
19
19
|
*
|
|
20
|
-
* const helia = createHelia({
|
|
20
|
+
* const helia = await createHelia({
|
|
21
21
|
* // ... helia config
|
|
22
22
|
* })
|
|
23
23
|
* const fs = unixfs(helia)
|
|
24
24
|
*
|
|
25
25
|
* // add some UnixFS data
|
|
26
|
-
* const cid = await fs.addBytes(
|
|
26
|
+
* const cid = await fs.addBytes(Uint8Array.from([0, 1, 2, 3, 4]))
|
|
27
27
|
*
|
|
28
28
|
* // export it as a Car
|
|
29
29
|
* const c = car(helia)
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
* import { Readable } from 'node:stream'
|
|
47
47
|
* import nodeFs from 'node:fs'
|
|
48
48
|
*
|
|
49
|
-
* const helia = createHelia({
|
|
49
|
+
* const helia = await createHelia({
|
|
50
50
|
* // ... helia config
|
|
51
51
|
* })
|
|
52
52
|
*
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
* const inStream = nodeFs.createReadStream('example.car')
|
|
55
55
|
* const reader = await CarReader.fromIterable(inStream)
|
|
56
56
|
*
|
|
57
|
+
* const c = car(helia)
|
|
57
58
|
* await c.import(reader)
|
|
58
59
|
* ```
|
|
59
60
|
*/
|
|
@@ -61,9 +62,10 @@
|
|
|
61
62
|
import { CarWriter } from '@ipld/car'
|
|
62
63
|
import drain from 'it-drain'
|
|
63
64
|
import map from 'it-map'
|
|
65
|
+
import { createUnsafe } from 'multiformats/block'
|
|
64
66
|
import defer from 'p-defer'
|
|
65
67
|
import PQueue from 'p-queue'
|
|
66
|
-
import type {
|
|
68
|
+
import type { CodecLoader } from '@helia/interface'
|
|
67
69
|
import type { GetBlockProgressEvents, PutManyBlocksProgressEvents } from '@helia/interface/blocks'
|
|
68
70
|
import type { CarReader } from '@ipld/car'
|
|
69
71
|
import type { AbortOptions } from '@libp2p/interface'
|
|
@@ -74,10 +76,10 @@ import type { ProgressOptions } from 'progress-events'
|
|
|
74
76
|
|
|
75
77
|
export interface CarComponents {
|
|
76
78
|
blockstore: Blockstore
|
|
77
|
-
|
|
79
|
+
getCodec: CodecLoader
|
|
78
80
|
}
|
|
79
81
|
|
|
80
|
-
interface ExportCarOptions extends AbortOptions, ProgressOptions<GetBlockProgressEvents> {
|
|
82
|
+
export interface ExportCarOptions extends AbortOptions, ProgressOptions<GetBlockProgressEvents> {
|
|
81
83
|
/**
|
|
82
84
|
* If a filter is passed it will be used to deduplicate blocks exported in the car file
|
|
83
85
|
*/
|
|
@@ -235,18 +237,15 @@ class DefaultCar implements Car {
|
|
|
235
237
|
* and update the pin count for them
|
|
236
238
|
*/
|
|
237
239
|
async #walkDag (cid: CID, queue: PQueue, withBlock: (cid: CID, block: Uint8Array) => Promise<void>, options?: AbortOptions & ProgressOptions<GetBlockProgressEvents>): Promise<void> {
|
|
238
|
-
const
|
|
239
|
-
|
|
240
|
-
if (dagWalker == null) {
|
|
241
|
-
throw new Error(`No dag walker found for cid codec ${cid.code}`)
|
|
242
|
-
}
|
|
240
|
+
const codec = await this.components.getCodec(cid.code)
|
|
241
|
+
const bytes = await this.components.blockstore.get(cid, options)
|
|
243
242
|
|
|
244
|
-
|
|
243
|
+
await withBlock(cid, bytes)
|
|
245
244
|
|
|
246
|
-
|
|
245
|
+
const block = createUnsafe({ bytes, cid, codec })
|
|
247
246
|
|
|
248
247
|
// walk dag, ensure all blocks are present
|
|
249
|
-
for await (const cid of
|
|
248
|
+
for await (const [,cid] of block.links()) {
|
|
250
249
|
void queue.add(async () => {
|
|
251
250
|
await this.#walkDag(cid, queue, withBlock, options)
|
|
252
251
|
})
|
|
@@ -257,6 +256,6 @@ class DefaultCar implements Car {
|
|
|
257
256
|
/**
|
|
258
257
|
* Create a {@link Car} instance for use with {@link https://github.com/ipfs/helia Helia}
|
|
259
258
|
*/
|
|
260
|
-
export function car (helia:
|
|
259
|
+
export function car (helia: CarComponents, init: any = {}): Car {
|
|
261
260
|
return new DefaultCar(helia, init)
|
|
262
261
|
}
|