@helia/car 1.0.3 → 2.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 +62 -12
- package/dist/index.min.js +1 -1
- package/dist/src/index.d.ts +5 -5
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/utils/dag-walkers.d.ts +1 -1
- package/dist/src/utils/dag-walkers.d.ts.map +1 -1
- package/dist/src/utils/dag-walkers.js.map +1 -1
- package/dist/typedoc-urls.json +6 -1
- package/package.json +15 -14
- package/src/index.ts +5 -5
- package/src/utils/dag-walkers.ts +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
</a>
|
|
5
5
|
</p>
|
|
6
6
|
|
|
7
|
-
# @helia/car
|
|
7
|
+
# @helia/car
|
|
8
8
|
|
|
9
9
|
[](https://ipfs.tech)
|
|
10
10
|
[](https://discuss.ipfs.tech)
|
|
@@ -13,21 +13,71 @@
|
|
|
13
13
|
|
|
14
14
|
> Import/export car files from Helia
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
# About
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
- [Browser `<script>` tag](#browser-script-tag)
|
|
20
|
-
- [API Docs](#api-docs)
|
|
21
|
-
- [License](#license)
|
|
22
|
-
- [Contribute](#contribute)
|
|
18
|
+
`@helia/car` provides `import` and `export` methods to read/write Car files to Helia's blockstore.
|
|
23
19
|
|
|
24
|
-
|
|
20
|
+
See the Car interface for all available operations.
|
|
21
|
+
|
|
22
|
+
By default it supports `dag-pb`, `dag-cbor`, `dag-json` and `raw` CIDs, more esoteric DAG walkers can be passed as an init option.
|
|
23
|
+
|
|
24
|
+
## Example - Exporting a DAG as a CAR file
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { createHelia } from 'helia'
|
|
28
|
+
import { unixfs } from '@helia/unixfs'
|
|
29
|
+
import { car } from '@helia/car'
|
|
30
|
+
import { CarWriter } from '@ipld/car'
|
|
31
|
+
import { Readable } from 'node:stream'
|
|
32
|
+
import nodeFs from 'node:fs'
|
|
33
|
+
|
|
34
|
+
const helia = createHelia({
|
|
35
|
+
// ... helia config
|
|
36
|
+
})
|
|
37
|
+
const fs = unixfs(helia)
|
|
38
|
+
|
|
39
|
+
// add some UnixFS data
|
|
40
|
+
const cid = await fs.addBytes(fileData1)
|
|
41
|
+
|
|
42
|
+
// export it as a Car
|
|
43
|
+
const c = car(helia)
|
|
44
|
+
const { writer, out } = await CarWriter.create(cid)
|
|
45
|
+
|
|
46
|
+
// `out` needs to be directed somewhere, see the @ipld/car docs for more information
|
|
47
|
+
Readable.from(out).pipe(nodeFs.createWriteStream('example.car'))
|
|
48
|
+
|
|
49
|
+
// write the DAG behind `cid` into the writer
|
|
50
|
+
await c.export(cid, writer)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Example - Importing all blocks from a CAR file
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
import { createHelia } from 'helia'
|
|
57
|
+
import { unixfs } from '@helia/unixfs'
|
|
58
|
+
import { car } from '@helia/car'
|
|
59
|
+
import { CarReader } from '@ipld/car'
|
|
60
|
+
import { Readable } from 'node:stream'
|
|
61
|
+
import nodeFs from 'node:fs'
|
|
62
|
+
|
|
63
|
+
const helia = createHelia({
|
|
64
|
+
// ... helia config
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
// import the car
|
|
68
|
+
const inStream = nodeFs.createReadStream('example.car')
|
|
69
|
+
const reader = await CarReader.fromIterable(inStream)
|
|
70
|
+
|
|
71
|
+
await c.import(reader)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
# Install
|
|
25
75
|
|
|
26
76
|
```console
|
|
27
77
|
$ npm i @helia/car
|
|
28
78
|
```
|
|
29
79
|
|
|
30
|
-
|
|
80
|
+
## Browser `<script>` tag
|
|
31
81
|
|
|
32
82
|
Loading this module through a script tag will make it's exports available as `HeliaCar` in the global namespace.
|
|
33
83
|
|
|
@@ -35,18 +85,18 @@ Loading this module through a script tag will make it's exports available as `He
|
|
|
35
85
|
<script src="https://unpkg.com/@helia/car/dist/index.min.js"></script>
|
|
36
86
|
```
|
|
37
87
|
|
|
38
|
-
|
|
88
|
+
# API Docs
|
|
39
89
|
|
|
40
90
|
- <https://ipfs.github.io/helia-car/modules/_helia_car.html>
|
|
41
91
|
|
|
42
|
-
|
|
92
|
+
# License
|
|
43
93
|
|
|
44
94
|
Licensed under either of
|
|
45
95
|
|
|
46
96
|
- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
|
|
47
97
|
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
|
|
48
98
|
|
|
49
|
-
|
|
99
|
+
# Contribute
|
|
50
100
|
|
|
51
101
|
Contributions welcome! Please check out [the issues](https://github.com/ipfs/helia-car/issues).
|
|
52
102
|
|
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 ze=Object.defineProperty;var xn=Object.getOwnPropertyDescriptor;var vn=Object.getOwnPropertyNames;var kn=Object.getPrototypeOf,En=Object.prototype.hasOwnProperty;var _n=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Tn=(t,e)=>{for(var r in e)ze(t,r,{get:e[r],enumerable:!0})},Nt=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of vn(e))!En.call(t,o)&&o!==r&&ze(t,o,{get:()=>e[o],enumerable:!(n=xn(e,o))||n.enumerable});return t};var An=(t,e,r)=>(r=t!=null?bn(kn(t)):{},Nt(e||!t||!t.__esModule?ze(r,"default",{value:t,enumerable:!0}):r,t)),In=t=>Nt(ze({},"__esModule",{value:!0}),t);var zt=_n((Yo,at)=>{"use strict";var Cn=Object.prototype.hasOwnProperty,_="~";function we(){}Object.create&&(we.prototype=Object.create(null),new we().__proto__||(_=!1));function $n(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function Dt(t,e,r,n,o){if(typeof r!="function")throw new TypeError("The listener must be a function");var i=new $n(r,n||t,o),s=_?_+e:e;return t._events[s]?t._events[s].fn?t._events[s]=[t._events[s],i]:t._events[s].push(i):(t._events[s]=i,t._eventsCount++),t}function Le(t,e){--t._eventsCount===0?t._events=new we:delete t._events[e]}function E(){this._events=new we,this._eventsCount=0}E.prototype.eventNames=function(){var e=[],r,n;if(this._eventsCount===0)return e;for(n in r=this._events)Cn.call(r,n)&&e.push(_?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(r)):e};E.prototype.listeners=function(e){var r=_?_+e:e,n=this._events[r];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,i=n.length,s=new Array(i);o<i;o++)s[o]=n[o].fn;return s};E.prototype.listenerCount=function(e){var r=_?_+e:e,n=this._events[r];return n?n.fn?1:n.length:0};E.prototype.emit=function(e,r,n,o,i,s){var c=_?_+e:e;if(!this._events[c])return!1;var u=this._events[c],p=arguments.length,w,m;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),p){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,r),!0;case 3:return u.fn.call(u.context,r,n),!0;case 4:return u.fn.call(u.context,r,n,o),!0;case 5:return u.fn.call(u.context,r,n,o,i),!0;case 6:return u.fn.call(u.context,r,n,o,i,s),!0}for(m=1,w=new Array(p-1);m<p;m++)w[m-1]=arguments[m];u.fn.apply(u.context,w)}else{var ie=u.length,ee;for(m=0;m<ie;m++)switch(u[m].once&&this.removeListener(e,u[m].fn,void 0,!0),p){case 1:u[m].fn.call(u[m].context);break;case 2:u[m].fn.call(u[m].context,r);break;case 3:u[m].fn.call(u[m].context,r,n);break;case 4:u[m].fn.call(u[m].context,r,n,o);break;default:if(!w)for(ee=1,w=new Array(p-1);ee<p;ee++)w[ee-1]=arguments[ee];u[m].fn.apply(u[m].context,w)}}return!0};E.prototype.on=function(e,r,n){return Dt(this,e,r,n,!1)};E.prototype.once=function(e,r,n){return Dt(this,e,r,n,!0)};E.prototype.removeListener=function(e,r,n,o){var i=_?_+e:e;if(!this._events[i])return this;if(!r)return Le(this,i),this;var s=this._events[i];if(s.fn)s.fn===r&&(!o||s.once)&&(!n||s.context===n)&&Le(this,i);else{for(var c=0,u=[],p=s.length;c<p;c++)(s[c].fn!==r||o&&!s[c].once||n&&s[c].context!==n)&&u.push(s[c]);u.length?this._events[i]=u.length===1?u[0]:u:Le(this,i)}return this};E.prototype.removeAllListeners=function(e){var r;return e?(r=_?_+e:e,this._events[r]&&Le(this,r)):(this._events=new we,this._eventsCount=0),this};E.prototype.off=E.prototype.removeListener;E.prototype.addListener=E.prototype.on;E.prefixed=_;E.EventEmitter=E;typeof at<"u"&&(at.exports=E)});var Ro={};Tn(Ro,{car:()=>Qo});function Sn(t){return t[Symbol.asyncIterator]!=null}function Bn(t){if(Sn(t))return(async()=>{for await(let e of t);})();for(let e of t);}var Pt=Bn;function Un(t){let[e,r]=t[Symbol.asyncIterator]!=null?[t[Symbol.asyncIterator](),Symbol.asyncIterator]:[t[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>e.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:e.next(),[r](){return this}}}var Ct=Un;function Nn(t){return t[Symbol.asyncIterator]!=null}function Pn(t,e){if(Nn(t))return async function*(){for await(let c of t)yield e(c)}();let r=Ct(t),{value:n,done:o}=r.next();if(o===!0)return function*(){}();let i=e(n);if(typeof i.then=="function")return async function*(){yield await i;for await(let c of r)yield e(c)}();let s=e;return function*(){yield i;for(let c of r)yield s(c)}()}var $t=Pn;function st(){let t={};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t}var Rt=An(zt(),1);var ye=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},ct=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},Lt=t=>globalThis.DOMException===void 0?new ct(t):new DOMException(t),Mt=t=>{let e=t.reason===void 0?Lt("This operation was aborted."):t.reason;return e instanceof Error?e:Lt(e)};function ut(t,e,r,n){let o,i=new Promise((s,c)=>{if(typeof e!="number"||Math.sign(e)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${e}\``);if(e===Number.POSITIVE_INFINITY){s(t);return}if(n={customTimers:{setTimeout,clearTimeout},...n},n.signal){let{signal:u}=n;u.aborted&&c(Mt(u)),u.addEventListener("abort",()=>{c(Mt(u))})}o=n.customTimers.setTimeout.call(void 0,()=>{if(typeof r=="function"){try{s(r())}catch(w){c(w)}return}let u=typeof r=="string"?r:`Promise timed out after ${e} milliseconds`,p=r instanceof Error?r:new ye(u);typeof t.cancel=="function"&&t.cancel(),c(p)},e),(async()=>{try{s(await t)}catch(u){c(u)}finally{n.customTimers.clearTimeout.call(void 0,o)}})()});return i.clear=()=>{clearTimeout(o),o=void 0},i}function ft(t,e,r){let n=0,o=t.length;for(;o>0;){let i=Math.trunc(o/2),s=n+i;r(t[s],e)<=0?(n=++s,o-=i+1):o=i}return n}var re=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},R,ge=class{constructor(){R.set(this,[])}enqueue(e,r){r={priority:0,...r};let n={priority:r.priority,run:e};if(this.size&&re(this,R,"f")[this.size-1].priority>=r.priority){re(this,R,"f").push(n);return}let o=ft(re(this,R,"f"),n,(i,s)=>s.priority-i.priority);re(this,R,"f").splice(o,0,n)}dequeue(){let e=re(this,R,"f").shift();return e?.run}filter(e){return re(this,R,"f").filter(r=>r.priority===e.priority).map(r=>r.run)}get size(){return re(this,R,"f").length}};R=new WeakMap;var b=function(t,e,r,n,o){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?o.call(t,r):o?o.value=r:e.set(t,r),r},l=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},x,xe,ve,J,We,ke,Me,M,be,I,Oe,S,Ee,K,Fe,Ot,Ft,Wt,jt,Vt,je,ht,dt,Qe,Qt,Ve,Re=class extends Error{},_e=class extends Rt.default{constructor(e){var r,n,o,i;if(super(),x.add(this),xe.set(this,void 0),ve.set(this,void 0),J.set(this,0),We.set(this,void 0),ke.set(this,void 0),Me.set(this,0),M.set(this,void 0),be.set(this,void 0),I.set(this,void 0),Oe.set(this,void 0),S.set(this,0),Ee.set(this,void 0),K.set(this,void 0),Fe.set(this,void 0),Object.defineProperty(this,"timeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:ge,...e},!(typeof e.intervalCap=="number"&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(n=(r=e.intervalCap)===null||r===void 0?void 0:r.toString())!==null&&n!==void 0?n:""}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${(i=(o=e.interval)===null||o===void 0?void 0:o.toString())!==null&&i!==void 0?i:""}\` (${typeof e.interval})`);b(this,xe,e.carryoverConcurrencyCount,"f"),b(this,ve,e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,"f"),b(this,We,e.intervalCap,"f"),b(this,ke,e.interval,"f"),b(this,I,new e.queueClass,"f"),b(this,Oe,e.queueClass,"f"),this.concurrency=e.concurrency,this.timeout=e.timeout,b(this,Fe,e.throwOnTimeout===!0,"f"),b(this,K,e.autoStart===!1,"f")}get concurrency(){return l(this,Ee,"f")}set concurrency(e){if(!(typeof e=="number"&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);b(this,Ee,e,"f"),l(this,x,"m",Qe).call(this)}async add(e,r={}){return r={timeout:this.timeout,throwOnTimeout:l(this,Fe,"f"),...r},new Promise((n,o)=>{l(this,I,"f").enqueue(async()=>{var i,s,c;b(this,S,(s=l(this,S,"f"),s++,s),"f"),b(this,J,(c=l(this,J,"f"),c++,c),"f");try{if(!((i=r.signal)===null||i===void 0)&&i.aborted)throw new Re("The task was aborted.");let u=e({signal:r.signal});r.timeout&&(u=ut(Promise.resolve(u),r.timeout)),r.signal&&(u=Promise.race([u,l(this,x,"m",Qt).call(this,r.signal)]));let p=await u;n(p),this.emit("completed",p)}catch(u){if(u instanceof ye&&!r.throwOnTimeout){n();return}o(u),this.emit("error",u)}finally{l(this,x,"m",Wt).call(this)}},r),this.emit("add"),l(this,x,"m",je).call(this)})}async addAll(e,r){return Promise.all(e.map(async n=>this.add(n,r)))}start(){return l(this,K,"f")?(b(this,K,!1,"f"),l(this,x,"m",Qe).call(this),this):this}pause(){b(this,K,!0,"f")}clear(){b(this,I,new(l(this,Oe,"f")),"f")}async onEmpty(){l(this,I,"f").size!==0&&await l(this,x,"m",Ve).call(this,"empty")}async onSizeLessThan(e){l(this,I,"f").size<e||await l(this,x,"m",Ve).call(this,"next",()=>l(this,I,"f").size<e)}async onIdle(){l(this,S,"f")===0&&l(this,I,"f").size===0||await l(this,x,"m",Ve).call(this,"idle")}get size(){return l(this,I,"f").size}sizeBy(e){return l(this,I,"f").filter(e).length}get pending(){return l(this,S,"f")}get isPaused(){return l(this,K,"f")}};xe=new WeakMap,ve=new WeakMap,J=new WeakMap,We=new WeakMap,ke=new WeakMap,Me=new WeakMap,M=new WeakMap,be=new WeakMap,I=new WeakMap,Oe=new WeakMap,S=new WeakMap,Ee=new WeakMap,K=new WeakMap,Fe=new WeakMap,x=new WeakSet,Ot=function(){return l(this,ve,"f")||l(this,J,"f")<l(this,We,"f")},Ft=function(){return l(this,S,"f")<l(this,Ee,"f")},Wt=function(){var e;b(this,S,(e=l(this,S,"f"),e--,e),"f"),l(this,x,"m",je).call(this),this.emit("next")},jt=function(){l(this,x,"m",dt).call(this),l(this,x,"m",ht).call(this),b(this,be,void 0,"f")},Vt=function(){let e=Date.now();if(l(this,M,"f")===void 0){let r=l(this,Me,"f")-e;if(r<0)b(this,J,l(this,xe,"f")?l(this,S,"f"):0,"f");else return l(this,be,"f")===void 0&&b(this,be,setTimeout(()=>{l(this,x,"m",jt).call(this)},r),"f"),!0}return!1},je=function(){if(l(this,I,"f").size===0)return l(this,M,"f")&&clearInterval(l(this,M,"f")),b(this,M,void 0,"f"),this.emit("empty"),l(this,S,"f")===0&&this.emit("idle"),!1;if(!l(this,K,"f")){let e=!l(this,x,"a",Vt);if(l(this,x,"a",Ot)&&l(this,x,"a",Ft)){let r=l(this,I,"f").dequeue();return r?(this.emit("active"),r(),e&&l(this,x,"m",ht).call(this),!0):!1}}return!1},ht=function(){l(this,ve,"f")||l(this,M,"f")!==void 0||(b(this,M,setInterval(()=>{l(this,x,"m",dt).call(this)},l(this,ke,"f")),"f"),b(this,Me,Date.now()+l(this,ke,"f"),"f"))},dt=function(){l(this,J,"f")===0&&l(this,S,"f")===0&&l(this,M,"f")&&(clearInterval(l(this,M,"f")),b(this,M,void 0,"f")),b(this,J,l(this,xe,"f")?l(this,S,"f"):0,"f"),l(this,x,"m",Qe).call(this)},Qe=function(){for(;l(this,x,"m",je).call(this););},Qt=async function(e){return new Promise((r,n)=>{e.addEventListener("abort",()=>{n(new Re("The task was aborted."))},{once:!0})})},Ve=async function(e,r){return new Promise(n=>{let o=()=>{r&&!r()||(this.off(e,o),n())};this.on(e,o)})};var Dn=qt,Ht=128,zn=127,Ln=~zn,Mn=Math.pow(2,31);function qt(t,e,r){e=e||[],r=r||0;for(var n=r;t>=Mn;)e[r++]=t&255|Ht,t/=128;for(;t&Ln;)e[r++]=t&255|Ht,t>>>=7;return e[r]=t|0,qt.bytes=r-n+1,e}var On=lt,Fn=128,Gt=127;function lt(t,n){var r=0,n=n||0,o=0,i=n,s,c=t.length;do{if(i>=c)throw lt.bytes=0,new RangeError("Could not decode varint");s=t[i++],r+=o<28?(s&Gt)<<o:(s&Gt)*Math.pow(2,o),o+=7}while(s>=Fn);return lt.bytes=i-n,r}var jn=Math.pow(2,7),Vn=Math.pow(2,14),Wn=Math.pow(2,21),Qn=Math.pow(2,28),Rn=Math.pow(2,35),Hn=Math.pow(2,42),Gn=Math.pow(2,49),qn=Math.pow(2,56),Kn=Math.pow(2,63),Jn=function(t){return t<jn?1:t<Vn?2:t<Wn?3:t<Qn?4:t<Rn?5:t<Hn?6:t<Gn?7:t<qn?8:t<Kn?9:10},Xn={encode:Dn,decode:On,encodingLength:Jn},Yn=Xn,Te=Yn;var Ae=(t,e=0)=>[Te.decode(t,e),Te.decode.bytes],se=(t,e,r=0)=>(Te.encode(t,e,r),e),ae=t=>Te.encodingLength(t);var ci=new Uint8Array(0);var Jt=(t,e)=>{if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0},ne=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")};var Xt=(t,e)=>{let r=e.byteLength,n=ae(t),o=n+ae(r),i=new Uint8Array(o+r);return se(t,i,0),se(r,i,n),i.set(e,o),new ce(t,r,e,i)},Yt=t=>{let e=ne(t),[r,n]=Ae(e),[o,i]=Ae(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new ce(r,o,s,e)},Zt=(t,e)=>{if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&Jt(t.bytes,r.bytes)}},ce=class{constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};function eo(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<t.length;o++){var i=t.charAt(o),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var c=t.length,u=t.charAt(0),p=Math.log(c)/Math.log(256),w=Math.log(256)/Math.log(c);function m(g){if(g instanceof Uint8Array||(ArrayBuffer.isView(g)?g=new Uint8Array(g.buffer,g.byteOffset,g.byteLength):Array.isArray(g)&&(g=Uint8Array.from(g))),!(g instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(g.length===0)return"";for(var A=0,te=0,z=0,j=g.length;z!==j&&g[z]===0;)z++,A++;for(var V=(j-z)*w+1>>>0,C=new Uint8Array(V);z!==j;){for(var W=g[z],q=0,L=V-1;(W!==0||q<te)&&L!==-1;L--,q++)W+=256*C[L]>>>0,C[L]=W%c>>>0,W=W/c>>>0;if(W!==0)throw new Error("Non-zero carry");te=q,z++}for(var Q=V-te;Q!==V&&C[Q]===0;)Q++;for(var De=u.repeat(A);Q<V;++Q)De+=t.charAt(C[Q]);return De}function ie(g){if(typeof g!="string")throw new TypeError("Expected String");if(g.length===0)return new Uint8Array;var A=0;if(g[A]!==" "){for(var te=0,z=0;g[A]===u;)te++,A++;for(var j=(g.length-A)*p+1>>>0,V=new Uint8Array(j);g[A];){var C=r[g.charCodeAt(A)];if(C===255)return;for(var W=0,q=j-1;(C!==0||W<z)&&q!==-1;q--,W++)C+=c*V[q]>>>0,V[q]=C%256>>>0,C=C/256>>>0;if(C!==0)throw new Error("Non-zero carry");z=W,A++}if(g[A]!==" "){for(var L=j-z;L!==j&&V[L]===0;)L++;for(var Q=new Uint8Array(te+(j-L)),De=te;L!==j;)Q[De++]=V[L++];return Q}}}function ee(g){var A=ie(g);if(A)return A;throw new Error(`Non-${e} character`)}return{encode:m,decodeUnsafe:ie,decode:ee}}var to=eo,ro=to,er=ro;var pt=class{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},mt=class{constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return tr(this,e)}},wt=class{constructor(e){this.decoders=e}or(e){return tr(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},tr=(t,e)=>new wt({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),yt=class{constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new pt(e,r,n),this.decoder=new mt(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},rr=({name:t,prefix:e,encode:r,decode:n})=>new yt(t,e,r,n),gt=({prefix:t,name:e,alphabet:r})=>{let{encode:n,decode:o}=er(r,e);return rr({prefix:t,name:e,encode:n,decode:i=>ne(o(i))})},no=(t,e,r,n)=>{let o={};for(let w=0;w<e.length;++w)o[e[w]]=w;let i=t.length;for(;t[i-1]==="=";)--i;let s=new Uint8Array(i*r/8|0),c=0,u=0,p=0;for(let w=0;w<i;++w){let m=o[t[w]];if(m===void 0)throw new SyntaxError(`Non-${n} character`);u=u<<r|m,c+=r,c>=8&&(c-=8,s[p++]=255&u>>c)}if(c>=r||255&u<<8-c)throw new SyntaxError("Unexpected end of data");return s},oo=(t,e,r)=>{let n=e[e.length-1]==="=",o=(1<<r)-1,i="",s=0,c=0;for(let u=0;u<t.length;++u)for(c=c<<8|t[u],s+=8;s>r;)s-=r,i+=e[o&c>>s];if(s&&(i+=e[o&c<<r-s]),n)for(;i.length*r&7;)i+="=";return i},T=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>rr({prefix:e,name:t,encode(o){return oo(o,n,r)},decode(o){return no(o,n,r,t)}});var H=gt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),wi=gt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ie=T({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),bi=T({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),xi=T({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),vi=T({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),ki=T({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ei=T({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),_i=T({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ti=T({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ai=T({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var nr=(t,e)=>{let{bytes:r,version:n}=t;switch(n){case 0:return so(r,bt(t),e||H.encoder);default:return ao(r,bt(t),e||Ie.encoder)}};var or=new WeakMap,bt=t=>{let e=or.get(t);if(e==null){let r=new Map;return or.set(t,r),r}return e},X=class t{constructor(e,r,n,o){this.code=r,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:r}=this;if(e!==Se)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==co)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:r}=this.multihash,n=Xt(e,r);return t.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return t.equals(this,e)}static equals(e,r){let n=r;return n&&e.code===n.code&&e.version===n.version&&Zt(e.multihash,n.multihash)}toString(e){return nr(this,e)}toJSON(){return{"/":nr(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:i,bytes:s}=r;return new t(n,o,i,s||ir(n,o,i.bytes))}else if(r[uo]===!0){let{version:n,multihash:o,code:i}=r,s=Yt(o);return t.create(n,i,s)}else return null}static create(e,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(r!==Se)throw new Error(`Version 0 CID must use dag-pb (code: ${Se}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=ir(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,Se,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,o=ne(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),s=new ce(r.multihashCode,r.digestSize,i,o);return[r.version===0?t.createV0(s):t.createV1(r.codec,s),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[m,ie]=Ae(e.subarray(r));return r+=ie,m},o=n(),i=Se;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,c=n(),u=n(),p=r+u,w=p-s;return{version:o,codec:i,multihashCode:c,digestSize:u,multihashSize:w,size:p}}static parse(e,r){let[n,o]=io(e,r),i=t.decode(o);if(i.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return bt(i).set(n,e),i}},io=(t,e)=>{switch(t[0]){case"Q":{let r=e||H;return[H.prefix,r.decode(`${H.prefix}${t}`)]}case H.prefix:{let r=e||H;return[H.prefix,r.decode(t)]}case Ie.prefix:{let r=e||Ie;return[Ie.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}},so=(t,e,r)=>{let{prefix:n}=r;if(n!==H.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let i=r.encode(t).slice(1);return e.set(n,i),i}else return o},ao=(t,e,r)=>{let{prefix:n}=r,o=e.get(n);if(o==null){let i=r.encode(t);return e.set(n,i),i}else return o},Se=112,co=18,ir=(t,e,r)=>{let n=ae(t),o=n+ae(e),i=new Uint8Array(o+r.byteLength);return se(t,i,0),se(e,i,n),i.set(r,o),i},uo=Symbol.for("@ipld/js-cid/CID");var fo=new TextDecoder;function xt(t,e){let r=0;for(let n=0;;n+=7){if(n>=64)throw new Error("protobuf: varint overflow");if(e>=t.length)throw new Error("protobuf: unexpected end of data");let o=t[e++];if(r+=n<28?(o&127)<<n:(o&127)*2**n,o<128)break}return[r,e]}function He(t,e){let r;[r,e]=xt(t,e);let n=e+r;if(r<0||n<0)throw new Error("protobuf: invalid length");if(n>t.length)throw new Error("protobuf: unexpected end of data");return[t.subarray(e,n),n]}function sr(t,e){let r;return[r,e]=xt(t,e),[r&7,r>>3,e]}function ho(t){let e={},r=t.length,n=0;for(;n<r;){let o,i;if([o,i,n]=sr(t,n),i===1){if(e.Hash)throw new Error("protobuf: (PBLink) duplicate Hash section");if(o!==2)throw new Error(`protobuf: (PBLink) wrong wireType (${o}) for Hash`);if(e.Name!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Name before Hash");if(e.Tsize!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Tsize before Hash");[e.Hash,n]=He(t,n)}else if(i===2){if(e.Name!==void 0)throw new Error("protobuf: (PBLink) duplicate Name section");if(o!==2)throw new Error(`protobuf: (PBLink) wrong wireType (${o}) for Name`);if(e.Tsize!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Tsize before Name");let s;[s,n]=He(t,n),e.Name=fo.decode(s)}else if(i===3){if(e.Tsize!==void 0)throw new Error("protobuf: (PBLink) duplicate Tsize section");if(o!==0)throw new Error(`protobuf: (PBLink) wrong wireType (${o}) for Tsize`);[e.Tsize,n]=xt(t,n)}else throw new Error(`protobuf: (PBLink) invalid fieldNumber, expected 1, 2 or 3, got ${i}`)}if(n>r)throw new Error("protobuf: (PBLink) unexpected end of data");return e}function ar(t){let e=t.length,r=0,n,o=!1,i;for(;r<e;){let c,u;if([c,u,r]=sr(t,r),c!==2)throw new Error(`protobuf: (PBNode) invalid wireType, expected 2, got ${c}`);if(u===1){if(i)throw new Error("protobuf: (PBNode) duplicate Data section");[i,r]=He(t,r),n&&(o=!0)}else if(u===2){if(o)throw new Error("protobuf: (PBNode) duplicate Links section");n||(n=[]);let p;[p,r]=He(t,r),n.push(ho(p))}else throw new Error(`protobuf: (PBNode) invalid fieldNumber, expected 1 or 2, got ${u}`)}if(r>e)throw new Error("protobuf: (PBNode) unexpected end of data");let s={};return i&&(s.Data=i),s.Links=n||[],s}var $i=new TextEncoder,Di=2**32,zi=2**31;var Oi=new TextEncoder;var cr=112;function ur(t){let e=ar(t),r={};return e.Data&&(r.Data=e.Data),e.Links&&(r.Links=e.Links.map(n=>{let o={};try{o.Hash=X.decode(n.Hash)}catch{}if(!o.Hash)throw new Error("Invalid Hash field found in link, expected CID");return n.Name!==void 0&&(o.Name=n.Name),n.Tsize!==void 0&&(o.Tsize=n.Tsize),o})),r}var po=["string","number","bigint","symbol"],mo=["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 fr(t){if(t===null)return"null";if(t===void 0)return"undefined";if(t===!0||t===!1)return"boolean";let e=typeof t;if(po.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(t))return"Array";if(wo(t))return"Buffer";let r=yo(t);return r||"Object"}function wo(t){return t&&t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer.call(null,t)}function yo(t){let e=Object.prototype.toString.call(t).slice(8,-1);if(mo.includes(e))return e}var a=class{constructor(e,r,n){this.major=e,this.majorEncoded=e<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:this.major>e.major?1:0}};a.uint=new a(0,"uint",!0);a.negint=new a(1,"negint",!0);a.bytes=new a(2,"bytes",!0);a.string=new a(3,"string",!0);a.array=new a(4,"array",!1);a.map=new a(5,"map",!1);a.tag=new a(6,"tag",!1);a.float=new a(7,"float",!0);a.false=new a(7,"false",!0);a.true=new a(7,"true",!0);a.null=new a(7,"null",!0);a.undefined=new a(7,"undefined",!0);a.break=new a(7,"break",!0);var f=class{constructor(e,r,n){this.type=e,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var ue=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",go=new TextDecoder,bo=new TextEncoder;function Ge(t){return ue&&globalThis.Buffer.isBuffer(t)}function qe(t){return t instanceof Uint8Array?Ge(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t:Uint8Array.from(t)}var pr=ue?(t,e,r)=>r-e>64?globalThis.Buffer.from(t.subarray(e,r)).toString("utf8"):dr(t,e,r):(t,e,r)=>r-e>64?go.decode(t.subarray(e,r)):dr(t,e,r),Ke=ue?t=>t.length>64?globalThis.Buffer.from(t):hr(t):t=>t.length>64?bo.encode(t):hr(t);var fe=ue?(t,e,r)=>Ge(t)?new Uint8Array(t.subarray(e,r)):t.slice(e,r):(t,e,r)=>t.slice(e,r),mr=ue?(t,e)=>(t=t.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),qe(globalThis.Buffer.concat(t,e))):(t,e)=>{let r=new Uint8Array(e),n=0;for(let o of t)n+o.length>r.length&&(o=o.subarray(0,r.length-n)),r.set(o,n),n+=o.length;return r},wr=ue?t=>globalThis.Buffer.allocUnsafe(t):t=>new Uint8Array(t);function yr(t,e){if(Ge(t)&&Ge(e))return t.compare(e);for(let r=0;r<t.length;r++)if(t[r]!==e[r])return t[r]<e[r]?-1:1;return 0}function hr(t,e=1/0){let r,n=t.length,o=null,i=[];for(let s=0;s<n;++s){if(r=t.charCodeAt(s),r>55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}else if(s+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=(o-55296<<10|r-56320)+65536}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return i}function dr(t,e,r){let n=[];for(;e<r;){let o=t[e],i=null,s=o>239?4:o>223?3:o>191?2:1;if(e+s<=r){let c,u,p,w;switch(s){case 1:o<128&&(i=o);break;case 2:c=t[e+1],(c&192)===128&&(w=(o&31)<<6|c&63,w>127&&(i=w));break;case 3:c=t[e+1],u=t[e+2],(c&192)===128&&(u&192)===128&&(w=(o&15)<<12|(c&63)<<6|u&63,w>2047&&(w<55296||w>57343)&&(i=w));break;case 4:c=t[e+1],u=t[e+2],p=t[e+3],(c&192)===128&&(u&192)===128&&(p&192)===128&&(w=(o&15)<<18|(c&63)<<12|(u&63)<<6|p&63,w>65535&&w<1114112&&(i=w))}}i===null?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),e+=s}return vt(n)}var lr=4096;function vt(t){let e=t.length;if(e<=lr)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=lr));return r}var xo=256,Je=class{constructor(e=xo){this.chunkSize=e,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(e){let r=this.chunks[this.chunks.length-1];if(this.cursor+e.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(e,o)}else{if(r){let o=r.length-(this.maxCursor-this.cursor)-1;o<r.length&&(this.chunks[this.chunks.length-1]=r.subarray(0,o),this.maxCursor=this.cursor-1)}e.length<64&&e.length<this.chunkSize?(r=wr(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(e,0)):(this.chunks.push(e),this.maxCursor+=e.length)}this.cursor+=e.length}toBytes(e=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];e&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=fe(n,0,this.cursor)}else r=mr(this.chunks,this.cursor);return e&&this.reset(),r}};var d="CBOR decode error:",he="CBOR encode error:",Be=[];Be[23]=1;Be[24]=2;Be[25]=3;Be[26]=5;Be[27]=9;function G(t,e,r){if(t.length-e<r)throw new Error(`${d} not enough data for type`)}var v=[24,256,65536,4294967296,BigInt("18446744073709551616")];function B(t,e,r){G(t,e,1);let n=t[e];if(r.strict===!0&&n<v[0])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);return n}function U(t,e,r){G(t,e,2);let n=t[e]<<8|t[e+1];if(r.strict===!0&&n<v[1])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);return n}function N(t,e,r){G(t,e,4);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3];if(r.strict===!0&&n<v[2])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);return n}function P(t,e,r){G(t,e,8);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3],o=t[e+4]*16777216+(t[e+5]<<16)+(t[e+6]<<8)+t[e+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&i<v[3])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(r.allowBigInt===!0)return i;throw new Error(`${d} integers outside of the safe integer range are not supported`)}function gr(t,e,r,n){return new f(a.uint,B(t,e+1,n),2)}function br(t,e,r,n){return new f(a.uint,U(t,e+1,n),3)}function xr(t,e,r,n){return new f(a.uint,N(t,e+1,n),5)}function vr(t,e,r,n){return new f(a.uint,P(t,e+1,n),9)}function $(t,e){return k(t,0,e.value)}function k(t,e,r){if(r<v[0]){let n=Number(r);t.push([e|n])}else if(r<v[1]){let n=Number(r);t.push([e|24,n])}else if(r<v[2]){let n=Number(r);t.push([e|25,n>>>8,n&255])}else if(r<v[3]){let n=Number(r);t.push([e|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<v[4]){let o=[e|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),s=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]=s&255,s=s>>8,o[3]=s&255,s=s>>8,o[2]=s&255,s=s>>8,o[1]=s&255,t.push(o)}else throw new Error(`${d} encountered BigInt larger than allowable range`)}}$.encodedSize=function(e){return k.encodedSize(e.value)};k.encodedSize=function(e){return e<v[0]?1:e<v[1]?2:e<v[2]?3:e<v[3]?5:9};$.compareTokens=function(e,r){return e.value<r.value?-1:e.value>r.value?1:0};function kr(t,e,r,n){return new f(a.negint,-1-B(t,e+1,n),2)}function Er(t,e,r,n){return new f(a.negint,-1-U(t,e+1,n),3)}function _r(t,e,r,n){return new f(a.negint,-1-N(t,e+1,n),5)}var kt=BigInt(-1),Tr=BigInt(1);function Ar(t,e,r,n){let o=P(t,e+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new f(a.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${d} integers outside of the safe integer range are not supported`);return new f(a.negint,kt-BigInt(o),9)}function Xe(t,e){let r=e.value,n=typeof r=="bigint"?r*kt-Tr:r*-1-1;k(t,e.type.majorEncoded,n)}Xe.encodedSize=function(e){let r=e.value,n=typeof r=="bigint"?r*kt-Tr:r*-1-1;return n<v[0]?1:n<v[1]?2:n<v[2]?3:n<v[3]?5:9};Xe.compareTokens=function(e,r){return e.value<r.value?1:e.value>r.value?-1:0};function Ue(t,e,r,n){G(t,e,r+n);let o=fe(t,e+r,e+r+n);return new f(a.bytes,o,r+n)}function Ir(t,e,r,n){return Ue(t,e,1,r)}function Sr(t,e,r,n){return Ue(t,e,2,B(t,e+1,n))}function Br(t,e,r,n){return Ue(t,e,3,U(t,e+1,n))}function Ur(t,e,r,n){return Ue(t,e,5,N(t,e+1,n))}function Nr(t,e,r,n){let o=P(t,e+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer bytes lengths not supported`);return Ue(t,e,9,o)}function Ye(t){return t.encodedBytes===void 0&&(t.encodedBytes=t.type===a.string?Ke(t.value):t.value),t.encodedBytes}function de(t,e){let r=Ye(e);k(t,e.type.majorEncoded,r.length),t.push(r)}de.encodedSize=function(e){let r=Ye(e);return k.encodedSize(r.length)+r.length};de.compareTokens=function(e,r){return ko(Ye(e),Ye(r))};function ko(t,e){return t.length<e.length?-1:t.length>e.length?1:yr(t,e)}function Ne(t,e,r,n,o){let i=r+n;G(t,e,i);let s=new f(a.string,pr(t,e+r,e+i),i);return o.retainStringBytes===!0&&(s.byteValue=fe(t,e+r,e+i)),s}function Pr(t,e,r,n){return Ne(t,e,1,r,n)}function Cr(t,e,r,n){return Ne(t,e,2,B(t,e+1,n),n)}function $r(t,e,r,n){return Ne(t,e,3,U(t,e+1,n),n)}function Dr(t,e,r,n){return Ne(t,e,5,N(t,e+1,n),n)}function zr(t,e,r,n){let o=P(t,e+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer string lengths not supported`);return Ne(t,e,9,o,n)}var Lr=de;function le(t,e,r,n){return new f(a.array,n,r)}function Mr(t,e,r,n){return le(t,e,1,r)}function Or(t,e,r,n){return le(t,e,2,B(t,e+1,n))}function Fr(t,e,r,n){return le(t,e,3,U(t,e+1,n))}function jr(t,e,r,n){return le(t,e,5,N(t,e+1,n))}function Vr(t,e,r,n){let o=P(t,e+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer array lengths not supported`);return le(t,e,9,o)}function Wr(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${d} indefinite length items not allowed`);return le(t,e,1,1/0)}function Ze(t,e){k(t,a.array.majorEncoded,e.value)}Ze.compareTokens=$.compareTokens;Ze.encodedSize=function(e){return k.encodedSize(e.value)};function pe(t,e,r,n){return new f(a.map,n,r)}function Qr(t,e,r,n){return pe(t,e,1,r)}function Rr(t,e,r,n){return pe(t,e,2,B(t,e+1,n))}function Hr(t,e,r,n){return pe(t,e,3,U(t,e+1,n))}function Gr(t,e,r,n){return pe(t,e,5,N(t,e+1,n))}function qr(t,e,r,n){let o=P(t,e+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer map lengths not supported`);return pe(t,e,9,o)}function Kr(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${d} indefinite length items not allowed`);return pe(t,e,1,1/0)}function et(t,e){k(t,a.map.majorEncoded,e.value)}et.compareTokens=$.compareTokens;et.encodedSize=function(e){return k.encodedSize(e.value)};function Jr(t,e,r,n){return new f(a.tag,r,1)}function Xr(t,e,r,n){return new f(a.tag,B(t,e+1,n),2)}function Yr(t,e,r,n){return new f(a.tag,U(t,e+1,n),3)}function Zr(t,e,r,n){return new f(a.tag,N(t,e+1,n),5)}function en(t,e,r,n){return new f(a.tag,P(t,e+1,n),9)}function tt(t,e){k(t,a.tag.majorEncoded,e.value)}tt.compareTokens=$.compareTokens;tt.encodedSize=function(e){return k.encodedSize(e.value)};var So=20,Bo=21,Uo=22,No=23;function tn(t,e,r,n){if(n.allowUndefined===!1)throw new Error(`${d} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new f(a.null,null,1):new f(a.undefined,void 0,1)}function rn(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${d} indefinite length items not allowed`);return new f(a.break,void 0,1)}function Et(t,e,r){if(r){if(r.allowNaN===!1&&Number.isNaN(t))throw new Error(`${d} NaN values are not supported`);if(r.allowInfinity===!1&&(t===1/0||t===-1/0))throw new Error(`${d} Infinity values are not supported`)}return new f(a.float,t,e)}function nn(t,e,r,n){return Et(_t(t,e+1),3,n)}function on(t,e,r,n){return Et(Tt(t,e+1),5,n)}function sn(t,e,r,n){return Et(fn(t,e+1),9,n)}function rt(t,e,r){let n=e.value;if(n===!1)t.push([a.float.majorEncoded|So]);else if(n===!0)t.push([a.float.majorEncoded|Bo]);else if(n===null)t.push([a.float.majorEncoded|Uo]);else if(n===void 0)t.push([a.float.majorEncoded|No]);else{let o,i=!1;(!r||r.float64!==!0)&&(cn(n),o=_t(O,1),n===o||Number.isNaN(n)?(O[0]=249,t.push(O.slice(0,3)),i=!0):(un(n),o=Tt(O,1),n===o&&(O[0]=250,t.push(O.slice(0,5)),i=!0))),i||(Po(n),o=fn(O,1),O[0]=251,t.push(O.slice(0,9)))}}rt.encodedSize=function(e,r){let n=e.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){cn(n);let o=_t(O,1);if(n===o||Number.isNaN(n))return 3;if(un(n),o=Tt(O,1),n===o)return 5}return 9};var an=new ArrayBuffer(9),D=new DataView(an,1),O=new Uint8Array(an,0);function cn(t){if(t===1/0)D.setUint16(0,31744,!1);else if(t===-1/0)D.setUint16(0,64512,!1);else if(Number.isNaN(t))D.setUint16(0,32256,!1);else{D.setFloat32(0,t);let e=D.getUint32(0),r=(e&2139095040)>>23,n=e&8388607;if(r===255)D.setUint16(0,31744,!1);else if(r===0)D.setUint16(0,(t&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?D.setUint16(0,0):o<-14?D.setUint16(0,(e&2147483648)>>16|1<<24+o,!1):D.setUint16(0,(e&2147483648)>>16|o+15<<10|n>>13,!1)}}}function _t(t,e){if(t.length-e<2)throw new Error(`${d} not enough data for float16`);let r=(t[e]<<8)+t[e+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,o=r&1023,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 un(t){D.setFloat32(0,t,!1)}function Tt(t,e){if(t.length-e<4)throw new Error(`${d} not enough data for float32`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,4).getFloat32(0,!1)}function Po(t){D.setFloat64(0,t,!1)}function fn(t,e){if(t.length-e<8)throw new Error(`${d} not enough data for float64`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,8).getFloat64(0,!1)}rt.compareTokens=$.compareTokens;function y(t,e,r){throw new Error(`${d} encountered invalid minor (${r}) for major ${t[e]>>>5}`)}function nt(t){return()=>{throw new Error(`${d} ${t}`)}}var h=[];for(let t=0;t<=23;t++)h[t]=y;h[24]=gr;h[25]=br;h[26]=xr;h[27]=vr;h[28]=y;h[29]=y;h[30]=y;h[31]=y;for(let t=32;t<=55;t++)h[t]=y;h[56]=kr;h[57]=Er;h[58]=_r;h[59]=Ar;h[60]=y;h[61]=y;h[62]=y;h[63]=y;for(let t=64;t<=87;t++)h[t]=Ir;h[88]=Sr;h[89]=Br;h[90]=Ur;h[91]=Nr;h[92]=y;h[93]=y;h[94]=y;h[95]=nt("indefinite length bytes/strings are not supported");for(let t=96;t<=119;t++)h[t]=Pr;h[120]=Cr;h[121]=$r;h[122]=Dr;h[123]=zr;h[124]=y;h[125]=y;h[126]=y;h[127]=nt("indefinite length bytes/strings are not supported");for(let t=128;t<=151;t++)h[t]=Mr;h[152]=Or;h[153]=Fr;h[154]=jr;h[155]=Vr;h[156]=y;h[157]=y;h[158]=y;h[159]=Wr;for(let t=160;t<=183;t++)h[t]=Qr;h[184]=Rr;h[185]=Hr;h[186]=Gr;h[187]=qr;h[188]=y;h[189]=y;h[190]=y;h[191]=Kr;for(let t=192;t<=215;t++)h[t]=Jr;h[216]=Xr;h[217]=Yr;h[218]=Zr;h[219]=en;h[220]=y;h[221]=y;h[222]=y;h[223]=y;for(let t=224;t<=243;t++)h[t]=nt("simple values are not supported");h[244]=y;h[245]=y;h[246]=y;h[247]=tn;h[248]=nt("simple values are not supported");h[249]=nn;h[250]=on;h[251]=sn;h[252]=y;h[253]=y;h[254]=y;h[255]=rn;var F=[];for(let t=0;t<24;t++)F[t]=new f(a.uint,t,1);for(let t=-1;t>=-24;t--)F[31-t]=new f(a.negint,t,1);F[64]=new f(a.bytes,new Uint8Array(0),1);F[96]=new f(a.string,"",1);F[128]=new f(a.array,0,1);F[160]=new f(a.map,0,1);F[244]=new f(a.false,!1,1);F[245]=new f(a.true,!0,1);F[246]=new f(a.null,null,1);function $o(){let t=[];return t[a.uint.major]=$,t[a.negint.major]=Xe,t[a.bytes.major]=de,t[a.string.major]=Lr,t[a.array.major]=Ze,t[a.map.major]=et,t[a.tag.major]=tt,t[a.float.major]=rt,t}var js=$o(),Vs=new Je,ot=class t{constructor(e,r){this.obj=e,this.parent=r}includes(e){let r=this;do if(r.obj===e)return!0;while(r=r.parent);return!1}static createCheck(e,r){if(e&&e.includes(r))throw new Error(`${he} object contains circular references`);return new t(r,e)}},Y={null:new f(a.null,null),undefined:new f(a.undefined,void 0),true:new f(a.true,!0),false:new f(a.false,!1),emptyArray:new f(a.array,0),emptyMap:new f(a.map,0)},Z={number(t,e,r,n){return!Number.isInteger(t)||!Number.isSafeInteger(t)?new f(a.float,t):t>=0?new f(a.uint,t):new f(a.negint,t)},bigint(t,e,r,n){return t>=BigInt(0)?new f(a.uint,t):new f(a.negint,t)},Uint8Array(t,e,r,n){return new f(a.bytes,t)},string(t,e,r,n){return new f(a.string,t)},boolean(t,e,r,n){return t?Y.true:Y.false},null(t,e,r,n){return Y.null},undefined(t,e,r,n){return Y.undefined},ArrayBuffer(t,e,r,n){return new f(a.bytes,new Uint8Array(t))},DataView(t,e,r,n){return new f(a.bytes,new Uint8Array(t.buffer,t.byteOffset,t.byteLength))},Array(t,e,r,n){if(!t.length)return r.addBreakTokens===!0?[Y.emptyArray,new f(a.break)]:Y.emptyArray;n=ot.createCheck(n,t);let o=[],i=0;for(let s of t)o[i++]=At(s,r,n);return r.addBreakTokens?[new f(a.array,t.length),o,new f(a.break)]:[new f(a.array,t.length),o]},Object(t,e,r,n){let o=e!=="Object",i=o?t.keys():Object.keys(t),s=o?t.size:i.length;if(!s)return r.addBreakTokens===!0?[Y.emptyMap,new f(a.break)]:Y.emptyMap;n=ot.createCheck(n,t);let c=[],u=0;for(let p of i)c[u++]=[At(p,r,n),At(o?t.get(p):t[p],r,n)];return Do(c,r),r.addBreakTokens?[new f(a.map,s),c,new f(a.break)]:[new f(a.map,s),c]}};Z.Map=Z.Object;Z.Buffer=Z.Uint8Array;for(let t of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Z[`${t}Array`]=Z.DataView;function At(t,e={},r){let n=fr(t),o=e&&e.typeEncoders&&e.typeEncoders[n]||Z[n];if(typeof o=="function"){let s=o(t,n,e,r);if(s!=null)return s}let i=Z[n];if(!i)throw new Error(`${he} unsupported type: ${n}`);return i(t,n,e,r)}function Do(t,e){e.mapSorter&&t.sort(e.mapSorter)}var zo={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},It=class{constructor(e,r={}){this.pos=0,this.data=e,this.options=r}done(){return this.pos>=this.data.length}next(){let e=this.data[this.pos],r=F[e];if(r===void 0){let n=h[e];if(!n)throw new Error(`${d} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);let o=e&31;r=n(this.data,this.pos,o,this.options)}return this.pos+=r.encodedLength,r}},Pe=Symbol.for("DONE"),it=Symbol.for("BREAK");function Lo(t,e,r){let n=[];for(let o=0;o<t.value;o++){let i=Ce(e,r);if(i===it){if(t.value===1/0)break;throw new Error(`${d} got unexpected break to lengthed array`)}if(i===Pe)throw new Error(`${d} found array but not enough entries (got ${o}, expected ${t.value})`);n[o]=i}return n}function Mo(t,e,r){let n=r.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let s=0;s<t.value;s++){let c=Ce(e,r);if(c===it){if(t.value===1/0)break;throw new Error(`${d} got unexpected break to lengthed map`)}if(c===Pe)throw new Error(`${d} found map but not enough entries (got ${s} [no key], expected ${t.value})`);if(n!==!0&&typeof c!="string")throw new Error(`${d} non-string keys not supported (got ${typeof c})`);if(r.rejectDuplicateMapKeys===!0&&(n&&i.has(c)||!n&&c in o))throw new Error(`${d} found repeat map key "${c}"`);let u=Ce(e,r);if(u===Pe)throw new Error(`${d} found map but not enough entries (got ${s} [no value], expected ${t.value})`);n?i.set(c,u):o[c]=u}return n?i:o}function Ce(t,e){if(t.done())return Pe;let r=t.next();if(r.type===a.break)return it;if(r.type.terminal)return r.value;if(r.type===a.array)return Lo(r,t,e);if(r.type===a.map)return Mo(r,t,e);if(r.type===a.tag){if(e.tags&&typeof e.tags[r.value]=="function"){let n=Ce(t,e);return e.tags[r.value](n)}throw new Error(`${d} tag not supported (${r.value})`)}throw new Error("unsupported")}function $e(t,e){if(!(t instanceof Uint8Array))throw new Error(`${d} data to decode must be a Uint8Array`);e=Object.assign({},zo,e);let r=e.tokenizer||new It(t,e),n=Ce(r,e);if(n===Pe)throw new Error(`${d} did not find any content to decode`);if(n===it)throw new Error(`${d} got unexpected break`);if(!r.done())throw new Error(`${d} too many terminals, data makes no sense`);return n}var hn=class extends Array{constructor(){super(),this.inRecursive=[]}prefix(e){let r=this.inRecursive[this.inRecursive.length-1];r&&(r.type===a.array&&(r.elements++,r.elements!==1&&e.push([44])),r.type===a.map&&(r.elements++,r.elements!==1&&(r.elements%2===1?e.push([44]):e.push([58]))))}[a.uint.major](e,r){this.prefix(e);let n=String(r.value),o=[];for(let i=0;i<n.length;i++)o[i]=n.charCodeAt(i);e.push(o)}[a.negint.major](e,r){this[a.uint.major](e,r)}[a.bytes.major](e,r){throw new Error(`${he} unsupported type: Uint8Array`)}[a.string.major](e,r){this.prefix(e);let n=Ke(JSON.stringify(r.value));e.push(n.length>32?qe(n):n)}[a.array.major](e,r){this.prefix(e),this.inRecursive.push({type:a.array,elements:0}),e.push([91])}[a.map.major](e,r){this.prefix(e),this.inRecursive.push({type:a.map,elements:0}),e.push([123])}[a.tag.major](e,r){}[a.float.major](e,r){if(r.type.name==="break"){let s=this.inRecursive.pop();if(s){if(s.type===a.array)e.push([93]);else if(s.type===a.map)e.push([125]);else throw new Error("Unexpected recursive type; this should not happen!");return}throw new Error("Unexpected break; this should not happen!")}if(r.value===void 0)throw new Error(`${he} unsupported type: undefined`);if(this.prefix(e),r.type.name==="true"){e.push([116,114,117,101]);return}else if(r.type.name==="false"){e.push([102,97,108,115,101]);return}else if(r.type.name==="null"){e.push([110,117,108,108]);return}let n=String(r.value),o=[],i=!1;for(let s=0;s<n.length;s++)o[s]=n.charCodeAt(s),!i&&(o[s]===46||o[s]===101||o[s]===69)&&(i=!0);i||(o.push(46),o.push(48)),e.push(o)}};var me=class{constructor(e,r={}){this.pos=0,this.data=e,this.options=r,this.modeStack=["value"],this.lastToken=""}done(){return this.pos>=this.data.length}ch(){return this.data[this.pos]}currentMode(){return this.modeStack[this.modeStack.length-1]}skipWhitespace(){let e=this.ch();for(;e===32||e===9||e===13||e===10;)e=this.data[++this.pos]}expect(e){if(this.data.length-this.pos<e.length)throw new Error(`${d} unexpected end of input at position ${this.pos}`);for(let r=0;r<e.length;r++)if(this.data[this.pos++]!==e[r])throw new Error(`${d} unexpected token at position ${this.pos}, expected to find '${String.fromCharCode(...e)}'`)}parseNumber(){let e=this.pos,r=!1,n=!1,o=c=>{for(;!this.done();){let u=this.ch();if(c.includes(u))this.pos++;else break}};if(this.ch()===45&&(r=!0,this.pos++),this.ch()===48)if(this.pos++,this.ch()===46)this.pos++,n=!0;else return new f(a.uint,0,this.pos-e);if(o([48,49,50,51,52,53,54,55,56,57]),r&&this.pos===e+1)throw new Error(`${d} unexpected token at position ${this.pos}`);if(!this.done()&&this.ch()===46){if(n)throw new Error(`${d} unexpected token at position ${this.pos}`);n=!0,this.pos++,o([48,49,50,51,52,53,54,55,56,57])}!this.done()&&(this.ch()===101||this.ch()===69)&&(n=!0,this.pos++,!this.done()&&(this.ch()===43||this.ch()===45)&&this.pos++,o([48,49,50,51,52,53,54,55,56,57]));let i=String.fromCharCode.apply(null,this.data.subarray(e,this.pos)),s=parseFloat(i);return n?new f(a.float,s,this.pos-e):this.options.allowBigInt!==!0||Number.isSafeInteger(s)?new f(s>=0?a.uint:a.negint,s,this.pos-e):new f(s>=0?a.uint:a.negint,BigInt(i),this.pos-e)}parseString(){if(this.ch()!==34)throw new Error(`${d} unexpected character at position ${this.pos}; this shouldn't happen`);this.pos++;for(let i=this.pos,s=0;i<this.data.length&&s<65536;i++,s++){let c=this.data[i];if(c===92||c<32||c>=128)break;if(c===34){let u=String.fromCharCode.apply(null,this.data.subarray(this.pos,i));return this.pos=i+1,new f(a.string,u,s)}}let e=this.pos,r=[],n=()=>{if(this.pos+4>=this.data.length)throw new Error(`${d} unexpected end of unicode escape sequence at position ${this.pos}`);let i=0;for(let s=0;s<4;s++){let c=this.ch();if(c>=48&&c<=57)c-=48;else if(c>=97&&c<=102)c=c-97+10;else if(c>=65&&c<=70)c=c-65+10;else throw new Error(`${d} unexpected unicode escape character at position ${this.pos}`);i=i*16+c,this.pos++}return i},o=()=>{let i=this.ch(),s=null,c=i>239?4:i>223?3:i>191?2:1;if(this.pos+c>this.data.length)throw new Error(`${d} unexpected unicode sequence at position ${this.pos}`);let u,p,w,m;switch(c){case 1:i<128&&(s=i);break;case 2:u=this.data[this.pos+1],(u&192)===128&&(m=(i&31)<<6|u&63,m>127&&(s=m));break;case 3:u=this.data[this.pos+1],p=this.data[this.pos+2],(u&192)===128&&(p&192)===128&&(m=(i&15)<<12|(u&63)<<6|p&63,m>2047&&(m<55296||m>57343)&&(s=m));break;case 4:u=this.data[this.pos+1],p=this.data[this.pos+2],w=this.data[this.pos+3],(u&192)===128&&(p&192)===128&&(w&192)===128&&(m=(i&15)<<18|(u&63)<<12|(p&63)<<6|w&63,m>65535&&m<1114112&&(s=m))}s===null?(s=65533,c=1):s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|s&1023),r.push(s),this.pos+=c};for(;!this.done();){let i=this.ch(),s;switch(i){case 92:if(this.pos++,this.done())throw new Error(`${d} unexpected string termination at position ${this.pos}`);switch(s=this.ch(),this.pos++,s){case 34:case 39:case 92:case 47:r.push(s);break;case 98:r.push(8);break;case 116:r.push(9);break;case 110:r.push(10);break;case 102:r.push(12);break;case 114:r.push(13);break;case 117:r.push(n());break;default:throw new Error(`${d} unexpected string escape character at position ${this.pos}`)}break;case 34:return this.pos++,new f(a.string,vt(r),this.pos-e);default:if(i<32)throw new Error(`${d} invalid control character at position ${this.pos}`);i<128?(r.push(i),this.pos++):o()}}throw new Error(`${d} unexpected end of string at position ${this.pos}`)}parseValue(){switch(this.ch()){case 123:return this.modeStack.push("obj-start"),this.pos++,new f(a.map,1/0,1);case 91:return this.modeStack.push("array-start"),this.pos++,new f(a.array,1/0,1);case 34:return this.parseString();case 110:return this.expect([110,117,108,108]),new f(a.null,null,4);case 102:return this.expect([102,97,108,115,101]),new f(a.false,!1,5);case 116:return this.expect([116,114,117,101]),new f(a.true,!0,4);case 45:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.parseNumber();default:throw new Error(`${d} unexpected character at position ${this.pos}`)}}next(){switch(this.skipWhitespace(),this.currentMode()){case"value":return this.modeStack.pop(),this.parseValue();case"array-value":{if(this.modeStack.pop(),this.ch()===93)return this.pos++,this.skipWhitespace(),new f(a.break,void 0,1);if(this.ch()!==44)throw new Error(`${d} unexpected character at position ${this.pos}, was expecting array delimiter but found '${String.fromCharCode(this.ch())}'`);return this.pos++,this.modeStack.push("array-value"),this.skipWhitespace(),this.parseValue()}case"array-start":return this.modeStack.pop(),this.ch()===93?(this.pos++,this.skipWhitespace(),new f(a.break,void 0,1)):(this.modeStack.push("array-value"),this.skipWhitespace(),this.parseValue());case"obj-key":if(this.ch()===125)return this.modeStack.pop(),this.pos++,this.skipWhitespace(),new f(a.break,void 0,1);if(this.ch()!==44)throw new Error(`${d} unexpected character at position ${this.pos}, was expecting object delimiter but found '${String.fromCharCode(this.ch())}'`);this.pos++,this.skipWhitespace();case"obj-start":{if(this.modeStack.pop(),this.ch()===125)return this.pos++,this.skipWhitespace(),new f(a.break,void 0,1);let e=this.parseString();if(this.skipWhitespace(),this.ch()!==58)throw new Error(`${d} unexpected character at position ${this.pos}, was expecting key/value delimiter ':' but found '${String.fromCharCode(this.ch())}'`);return this.pos++,this.modeStack.push("obj-value"),e}case"obj-value":return this.modeStack.pop(),this.modeStack.push("obj-key"),this.skipWhitespace(),this.parseValue();default:throw new Error(`${d} unexpected parse state at position ${this.pos}; this shouldn't happen`)}}};function St(t,e){return e=Object.assign({tokenizer:new me(t,e)},e),$e(t,e)}var dn=T({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),la=T({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),pa=T({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ma=T({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var ln=85;var pn={codec:cr,async*walk(t){yield*ur(t).Links.map(r=>r.Hash)}},mn={codec:ln,async*walk(){}},wn=42,yn={codec:113,async*walk(t){let e=[],r=[];r[wn]=n=>{if(n[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");let o=X.decode(n.subarray(1));return e.push(o),o},$e(t,{tags:r}),yield*e}},Bt=class extends me{tokenBuffer;constructor(e,r){super(e,r),this.tokenBuffer=[]}done(){return this.tokenBuffer.length===0&&super.done()}_next(){return this.tokenBuffer.length>0?this.tokenBuffer.pop():super.next()}next(){let e=this._next();if(e.type===a.map){let r=this._next();if(r.type===a.string&&r.value==="/"){let n=this._next();if(n.type===a.string){if(this._next().type!==a.break)throw new Error("Invalid encoded CID form");return this.tokenBuffer.push(n),new f(a.tag,42,0)}if(n.type===a.map){let o=this._next();if(o.type===a.string&&o.value==="bytes"){let i=this._next();if(i.type===a.string){for(let c=0;c<2;c++)if(this._next().type!==a.break)throw new Error("Invalid encoded Bytes form");let s=dn.decode(`m${i.value}`);return new f(a.bytes,s,i.value.length)}this.tokenBuffer.push(i)}this.tokenBuffer.push(o)}this.tokenBuffer.push(n)}this.tokenBuffer.push(r)}return e}},gn={codec:297,async*walk(t){let e=[],r=[];r[wn]=n=>{let o=X.parse(n);return e.push(o),o},St(t,{tags:r,tokenizer:new Bt(t,{tags:r,allowIndefinite:!0,allowUndefined:!0,allowNaN:!0,allowInfinity:!0,allowBigInt:!0,strict:!1,rejectDuplicateMapKeys:!1})}),yield*e}};var Vo=[mn,pn,yn,gn],Wo=1,Ut=class{components;dagWalkers;constructor(e,r){this.components=e,this.dagWalkers={},[...Vo,...r.dagWalkers??[]].forEach(n=>{this.dagWalkers[n.codec]=n})}async import(e,r){await Pt(this.components.blockstore.putMany($t(e.blocks(),({cid:n,bytes:o})=>({cid:n,block:o})),r))}async export(e,r,n){let o=st(),i=Array.isArray(e)?e:[e],s=new _e({concurrency:Wo});s.on("idle",()=>{o.resolve()}),s.on("error",c=>{o.resolve(c)});for(let c of i)s.add(async()=>{await this.#e(c,s,async(u,p)=>{await r.put({cid:u,bytes:p})},n)});try{await o.promise}finally{await r.close()}}async#e(e,r,n,o){let i=this.dagWalkers[e.code];if(i==null)throw new Error(`No dag walker found for cid codec ${e.code}`);let s=await this.components.blockstore.get(e,o);await n(e,s);for await(let c of i.walk(s))r.add(async()=>{await this.#e(c,r,n,o)})}};function Qo(t,e={}){return new Ut(t,e)}return In(Ro);})();
|
|
2
|
+
"use strict";var HeliaCar=(()=>{var jr=Object.create;var ve=Object.defineProperty;var Rr=Object.getOwnPropertyDescriptor;var Hr=Object.getOwnPropertyNames;var Gr=Object.getPrototypeOf,qr=Object.prototype.hasOwnProperty;var Wr=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Kr=(t,e)=>{for(var r in e)ve(t,r,{get:e[r],enumerable:!0})},ct=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Hr(e))!qr.call(t,o)&&o!==r&&ve(t,o,{get:()=>e[o],enumerable:!(n=Rr(e,o))||n.enumerable});return t};var Jr=(t,e,r)=>(r=t!=null?jr(Gr(t)):{},ct(e||!t||!t.__esModule?ve(r,"default",{value:t,enumerable:!0}):r,t)),Qr=t=>ct(ve({},"__esModule",{value:!0}),t);var lt=Wr((ko,Oe)=>{"use strict";var rn=Object.prototype.hasOwnProperty,k="~";function se(){}Object.create&&(se.prototype=Object.create(null),new se().__proto__||(k=!1));function nn(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function ht(t,e,r,n,o){if(typeof r!="function")throw new TypeError("The listener must be a function");var i=new nn(r,n||t,o),a=k?k+e:e;return t._events[a]?t._events[a].fn?t._events[a]=[t._events[a],i]:t._events[a].push(i):(t._events[a]=i,t._eventsCount++),t}function ke(t,e){--t._eventsCount===0?t._events=new se:delete t._events[e]}function b(){this._events=new se,this._eventsCount=0}b.prototype.eventNames=function(){var e=[],r,n;if(this._eventsCount===0)return e;for(n in r=this._events)rn.call(r,n)&&e.push(k?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(r)):e};b.prototype.listeners=function(e){var r=k?k+e:e,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(e){var r=k?k+e:e,n=this._events[r];return n?n.fn?1:n.length:0};b.prototype.emit=function(e,r,n,o,i,a){var c=k?k+e:e;if(!this._events[c])return!1;var f=this._events[c],m=arguments.length,l,p;if(f.fn){switch(f.once&&this.removeListener(e,f.fn,void 0,!0),m){case 1:return f.fn.call(f.context),!0;case 2:return f.fn.call(f.context,r),!0;case 3:return f.fn.call(f.context,r,n),!0;case 4:return f.fn.call(f.context,r,n,o),!0;case 5:return f.fn.call(f.context,r,n,o,i),!0;case 6:return f.fn.call(f.context,r,n,o,i,a),!0}for(p=1,l=new Array(m-1);p<m;p++)l[p-1]=arguments[p];f.fn.apply(f.context,l)}else{var v=f.length,q;for(p=0;p<v;p++)switch(f[p].once&&this.removeListener(e,f[p].fn,void 0,!0),m){case 1:f[p].fn.call(f[p].context);break;case 2:f[p].fn.call(f[p].context,r);break;case 3:f[p].fn.call(f[p].context,r,n);break;case 4:f[p].fn.call(f[p].context,r,n,o);break;default:if(!l)for(q=1,l=new Array(m-1);q<m;q++)l[q-1]=arguments[q];f[p].fn.apply(f[p].context,l)}}return!0};b.prototype.on=function(e,r,n){return ht(this,e,r,n,!1)};b.prototype.once=function(e,r,n){return ht(this,e,r,n,!0)};b.prototype.removeListener=function(e,r,n,o){var i=k?k+e:e;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 c=0,f=[],m=a.length;c<m;c++)(a[c].fn!==r||o&&!a[c].once||n&&a[c].context!==n)&&f.push(a[c]);f.length?this._events[i]=f.length===1?f[0]:f:ke(this,i)}return this};b.prototype.removeAllListeners=function(e){var r;return e?(r=k?k+e:e,this._events[r]&&ke(this,r)):(this._events=new se,this._eventsCount=0),this};b.prototype.off=b.prototype.removeListener;b.prototype.addListener=b.prototype.on;b.prefixed=k;b.EventEmitter=b;typeof Oe<"u"&&(Oe.exports=b)});var mo={};Kr(mo,{car:()=>po});function Xr(t){return t[Symbol.asyncIterator]!=null}function Yr(t){if(Xr(t))return(async()=>{for await(let e of t);})();for(let e of t);}var ft=Yr;function Zr(t){let[e,r]=t[Symbol.asyncIterator]!=null?[t[Symbol.asyncIterator](),Symbol.asyncIterator]:[t[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>e.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:e.next(),[r](){return this}}}var ut=Zr;function en(t){return t[Symbol.asyncIterator]!=null}function tn(t,e){if(en(t))return async function*(){for await(let c of t)yield e(c)}();let r=ut(t),{value:n,done:o}=r.next();if(o===!0)return function*(){}();let i=e(n);if(typeof i.then=="function")return async function*(){yield await i;for await(let c of r)yield e(c)}();let a=e;return function*(){yield i;for(let c of r)yield a(c)}()}var dt=tn;function Le(){let t={};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t}var Me=Jr(lt(),1);var ae=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},Fe=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},pt=t=>globalThis.DOMException===void 0?new Fe(t):new DOMException(t),mt=t=>{let e=t.reason===void 0?pt("This operation was aborted."):t.reason;return e instanceof Error?e:pt(e)};function Ve(t,e){let{milliseconds:r,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout}}=e,a,f=new Promise((m,l)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(e.signal){let{signal:v}=e;v.aborted&&l(mt(v)),v.addEventListener("abort",()=>{l(mt(v))})}if(r===Number.POSITIVE_INFINITY){t.then(m,l);return}let p=new ae;a=i.setTimeout.call(void 0,()=>{if(n){try{m(n())}catch(v){l(v)}return}typeof t.cancel=="function"&&t.cancel(),o===!1?m():o instanceof Error?l(o):(p.message=o??`Promise timed out after ${r} milliseconds`,l(p))},r),(async()=>{try{m(await t)}catch(v){l(v)}})()}).finally(()=>{f.clear()});return f.clear=()=>{i.clearTimeout.call(void 0,a),a=void 0},f}function je(t,e,r){let n=0,o=t.length;for(;o>0;){let i=Math.trunc(o/2),a=n+i;r(t[a],e)<=0?(n=++a,o-=i+1):o=i}return n}var ce=class{#e=[];enqueue(e,r){r={priority:0,...r};let n={priority:r.priority,run:e};if(this.size&&this.#e[this.size-1].priority>=r.priority){this.#e.push(n);return}let o=je(this.#e,n,(i,a)=>a.priority-i.priority);this.#e.splice(o,0,n)}dequeue(){return this.#e.shift()?.run}filter(e){return this.#e.filter(r=>r.priority===e.priority).map(r=>r.run)}get size(){return this.#e.length}};var fe=class extends Me.default{#e;#s;#i=0;#l;#a;#p=0;#r;#c;#t;#m;#n=0;#f;#o;#y;timeout;constructor(e){if(super(),e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:ce,...e},!(typeof e.intervalCap=="number"&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${e.intervalCap?.toString()??""}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${e.interval?.toString()??""}\` (${typeof e.interval})`);this.#e=e.carryoverConcurrencyCount,this.#s=e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,this.#l=e.intervalCap,this.#a=e.interval,this.#t=new e.queueClass,this.#m=e.queueClass,this.concurrency=e.concurrency,this.timeout=e.timeout,this.#y=e.throwOnTimeout===!0,this.#o=e.autoStart===!1}get#g(){return this.#s||this.#i<this.#l}get#b(){return this.#n<this.#f}#v(){this.#n--,this.#u(),this.emit("next")}#k(){this.#w(),this.#x(),this.#c=void 0}get#E(){let e=Date.now();if(this.#r===void 0){let r=this.#p-e;if(r<0)this.#i=this.#e?this.#n:0;else return this.#c===void 0&&(this.#c=setTimeout(()=>{this.#k()},r)),!0}return!1}#u(){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 e=!this.#E;if(this.#g&&this.#b){let r=this.#t.dequeue();return r?(this.emit("active"),r(),e&&this.#x(),!0):!1}}return!1}#x(){this.#s||this.#r!==void 0||(this.#r=setInterval(()=>{this.#w()},this.#a),this.#p=Date.now()+this.#a)}#w(){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.#u(););}get concurrency(){return this.#f}set concurrency(e){if(!(typeof e=="number"&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);this.#f=e,this.#d()}async#T(e){return new Promise((r,n)=>{e.addEventListener("abort",()=>{n(e.reason)},{once:!0})})}async add(e,r={}){return r={timeout:this.timeout,throwOnTimeout:this.#y,...r},new Promise((n,o)=>{this.#t.enqueue(async()=>{this.#n++,this.#i++;try{r.signal?.throwIfAborted();let i=e({signal:r.signal});r.timeout&&(i=Ve(Promise.resolve(i),{milliseconds:r.timeout})),r.signal&&(i=Promise.race([i,this.#T(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.#u()})}async addAll(e,r){return Promise.all(e.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.#m}async onEmpty(){this.#t.size!==0&&await this.#h("empty")}async onSizeLessThan(e){this.#t.size<e||await this.#h("next",()=>this.#t.size<e)}async onIdle(){this.#n===0&&this.#t.size===0||await this.#h("idle")}async#h(e,r){return new Promise(n=>{let o=()=>{r&&!r()||(this.off(e,o),n())};this.on(e,o)})}get size(){return this.#t.size}sizeBy(e){return this.#t.filter(e).length}get pending(){return this.#n}get isPaused(){return this.#o}};var Co=new Uint8Array(0);function yt(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function K(t){if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")}function on(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<t.length;o++){var i=t.charAt(o),a=i.charCodeAt(0);if(r[a]!==255)throw new TypeError(i+" is ambiguous");r[a]=o}var c=t.length,f=t.charAt(0),m=Math.log(c)/Math.log(256),l=Math.log(256)/Math.log(c);function p(x){if(x instanceof Uint8Array||(ArrayBuffer.isView(x)?x=new Uint8Array(x.buffer,x.byteOffset,x.byteLength):Array.isArray(x)&&(x=Uint8Array.from(x))),!(x instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(x.length===0)return"";for(var T=0,W=0,C=0,P=x.length;C!==P&&x[C]===0;)C++,T++;for(var L=(P-C)*l+1>>>0,S=new Uint8Array(L);C!==P;){for(var O=x[C],j=0,$=L-1;(O!==0||j<W)&&$!==-1;$--,j++)O+=256*S[$]>>>0,S[$]=O%c>>>0,O=O/c>>>0;if(O!==0)throw new Error("Non-zero carry");W=j,C++}for(var M=L-W;M!==L&&S[M]===0;)M++;for(var be=f.repeat(T);M<L;++M)be+=t.charAt(S[M]);return be}function v(x){if(typeof x!="string")throw new TypeError("Expected String");if(x.length===0)return new Uint8Array;var T=0;if(x[T]!==" "){for(var W=0,C=0;x[T]===f;)W++,T++;for(var P=(x.length-T)*m+1>>>0,L=new Uint8Array(P);x[T];){var S=r[x.charCodeAt(T)];if(S===255)return;for(var O=0,j=P-1;(S!==0||O<C)&&j!==-1;j--,O++)S+=c*L[j]>>>0,L[j]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");C=O,T++}if(x[T]!==" "){for(var $=P-C;$!==P&&L[$]===0;)$++;for(var M=new Uint8Array(W+(P-$)),be=W;$!==P;)M[be++]=L[$++];return M}}}function q(x){var T=v(x);if(T)return T;throw new Error(`Non-${e} character`)}return{encode:p,decodeUnsafe:v,decode:q}}var sn=on,an=sn,xt=an;var Re=class{name;prefix;baseEncode;constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},He=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return wt(this,e)}},Ge=class{decoders;constructor(e){this.decoders=e}or(e){return wt(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function wt(t,e){return new Ge({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var qe=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Re(e,r,n),this.decoder=new He(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function gt({name:t,prefix:e,encode:r,decode:n}){return new qe(t,e,r,n)}function We({name:t,prefix:e,alphabet:r}){let{encode:n,decode:o}=xt(r,t);return gt({prefix:e,name:t,encode:n,decode:i=>K(o(i))})}function cn(t,e,r,n){let o={};for(let l=0;l<e.length;++l)o[e[l]]=l;let i=t.length;for(;t[i-1]==="=";)--i;let a=new Uint8Array(i*r/8|0),c=0,f=0,m=0;for(let l=0;l<i;++l){let p=o[t[l]];if(p===void 0)throw new SyntaxError(`Non-${n} character`);f=f<<r|p,c+=r,c>=8&&(c-=8,a[m++]=255&f>>c)}if(c>=r||255&f<<8-c)throw new SyntaxError("Unexpected end of data");return a}function fn(t,e,r){let n=e[e.length-1]==="=",o=(1<<r)-1,i="",a=0,c=0;for(let f=0;f<t.length;++f)for(c=c<<8|t[f],a+=8;a>r;)a-=r,i+=e[o&c>>a];if(a!==0&&(i+=e[o&c<<r-a]),n)for(;i.length*r&7;)i+="=";return i}function E({name:t,prefix:e,bitsPerChar:r,alphabet:n}){return gt({prefix:e,name:t,encode(o){return fn(o,n,r)},decode(o){return cn(o,n,r,t)}})}var ue=E({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Mo=E({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Fo=E({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Vo=E({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),jo=E({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ro=E({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ho=E({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Go=E({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),qo=E({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var F=We({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Jo=We({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var un=kt,bt=128,dn=127,hn=~dn,ln=Math.pow(2,31);function kt(t,e,r){e=e||[],r=r||0;for(var n=r;t>=ln;)e[r++]=t&255|bt,t/=128;for(;t&hn;)e[r++]=t&255|bt,t>>>=7;return e[r]=t|0,kt.bytes=r-n+1,e}var pn=Ke,mn=128,vt=127;function Ke(t,n){var r=0,n=n||0,o=0,i=n,a,c=t.length;do{if(i>=c)throw Ke.bytes=0,new RangeError("Could not decode varint");a=t[i++],r+=o<28?(a&vt)<<o:(a&vt)*Math.pow(2,o),o+=7}while(a>=mn);return Ke.bytes=i-n,r}var yn=Math.pow(2,7),xn=Math.pow(2,14),wn=Math.pow(2,21),gn=Math.pow(2,28),bn=Math.pow(2,35),vn=Math.pow(2,42),kn=Math.pow(2,49),En=Math.pow(2,56),Tn=Math.pow(2,63),_n=function(t){return t<yn?1:t<xn?2:t<wn?3:t<gn?4:t<bn?5:t<vn?6:t<kn?7:t<En?8:t<Tn?9:10},An={encode:un,decode:pn,encodingLength:_n},In=An,de=In;function he(t,e=0){return[de.decode(t,e),de.decode.bytes]}function Q(t,e,r=0){return de.encode(t,e,r),e}function X(t){return de.encodingLength(t)}function Tt(t,e){let r=e.byteLength,n=X(t),o=n+X(r),i=new Uint8Array(o+r);return Q(t,i,0),Q(r,i,n),i.set(e,o),new Y(t,r,e,i)}function _t(t){let e=K(t),[r,n]=he(e),[o,i]=he(e.subarray(n)),a=e.subarray(n+i);if(a.byteLength!==o)throw new Error("Incorrect length");return new Y(r,o,a,e)}function At(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&yt(t.bytes,r.bytes)}}var Y=class{code;size;digest;bytes;constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};function It(t,e){let{bytes:r,version:n}=t;switch(n){case 0:return Un(r,Je(t),e??F.encoder);default:return Nn(r,Je(t),e??ue.encoder)}}var Bt=new WeakMap;function Je(t){let e=Bt.get(t);if(e==null){let r=new Map;return Bt.set(t,r),r}return e}var R=class t{code;version;multihash;bytes;"/";constructor(e,r,n,o){this.code=r,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:r}=this;if(e!==le)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Cn)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:r}=this.multihash,n=Tt(e,r);return t.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return t.equals(this,e)}static equals(e,r){let n=r;return n!=null&&e.code===n.code&&e.version===n.version&&At(e.multihash,n.multihash)}toString(e){return It(this,e)}toJSON(){return{"/":It(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:i,bytes:a}=r;return new t(n,o,i,a??St(n,o,i.bytes))}else if(r[$n]===!0){let{version:n,multihash:o,code:i}=r,a=_t(o);return t.create(n,i,a)}else return null}static create(e,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(r!==le)throw new Error(`Version 0 CID must use dag-pb (code: ${le}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=St(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,le,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,o=K(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),a=new Y(r.multihashCode,r.digestSize,i,o);return[r.version===0?t.createV0(a):t.createV1(r.codec,a),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[p,v]=he(e.subarray(r));return r+=v,p},o=n(),i=le;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let a=r,c=n(),f=n(),m=r+f,l=m-a;return{version:o,codec:i,multihashCode:c,digestSize:f,multihashSize:l,size:m}}static parse(e,r){let[n,o]=Sn(e,r),i=t.decode(o);if(i.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Je(i).set(n,e),i}};function Sn(t,e){switch(t[0]){case"Q":{let r=e??F;return[F.prefix,r.decode(`${F.prefix}${t}`)]}case F.prefix:{let r=e??F;return[F.prefix,r.decode(t)]}case ue.prefix:{let r=e??ue;return[ue.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}}function Un(t,e,r){let{prefix:n}=r;if(n!==F.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let i=r.encode(t).slice(1);return e.set(n,i),i}else return o}function Nn(t,e,r){let{prefix:n}=r,o=e.get(n);if(o==null){let i=r.encode(t);return e.set(n,i),i}else return o}var le=112,Cn=18;function St(t,e,r){let n=X(t),o=n+X(e),i=new Uint8Array(o+r.byteLength);return Q(t,i,0),Q(e,i,n),i.set(r,o),i}var $n=Symbol.for("@ipld/js-cid/CID");var Dn=new TextDecoder;function Qe(t,e){let r=0;for(let n=0;;n+=7){if(n>=64)throw new Error("protobuf: varint overflow");if(e>=t.length)throw new Error("protobuf: unexpected end of data");let o=t[e++];if(r+=n<28?(o&127)<<n:(o&127)*2**n,o<128)break}return[r,e]}function Ee(t,e){let r;[r,e]=Qe(t,e);let n=e+r;if(r<0||n<0)throw new Error("protobuf: invalid length");if(n>t.length)throw new Error("protobuf: unexpected end of data");return[t.subarray(e,n),n]}function Ut(t,e){let r;return[r,e]=Qe(t,e),[r&7,r>>3,e]}function zn(t){let e={},r=t.length,n=0;for(;n<r;){let o,i;if([o,i,n]=Ut(t,n),i===1){if(e.Hash)throw new Error("protobuf: (PBLink) duplicate Hash section");if(o!==2)throw new Error(`protobuf: (PBLink) wrong wireType (${o}) for Hash`);if(e.Name!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Name before Hash");if(e.Tsize!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Tsize before Hash");[e.Hash,n]=Ee(t,n)}else if(i===2){if(e.Name!==void 0)throw new Error("protobuf: (PBLink) duplicate Name section");if(o!==2)throw new Error(`protobuf: (PBLink) wrong wireType (${o}) for Name`);if(e.Tsize!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Tsize before Name");let a;[a,n]=Ee(t,n),e.Name=Dn.decode(a)}else if(i===3){if(e.Tsize!==void 0)throw new Error("protobuf: (PBLink) duplicate Tsize section");if(o!==0)throw new Error(`protobuf: (PBLink) wrong wireType (${o}) for Tsize`);[e.Tsize,n]=Qe(t,n)}else throw new Error(`protobuf: (PBLink) invalid fieldNumber, expected 1, 2 or 3, got ${i}`)}if(n>r)throw new Error("protobuf: (PBLink) unexpected end of data");return e}function Nt(t){let e=t.length,r=0,n,o=!1,i;for(;r<e;){let c,f;if([c,f,r]=Ut(t,r),c!==2)throw new Error(`protobuf: (PBNode) invalid wireType, expected 2, got ${c}`);if(f===1){if(i)throw new Error("protobuf: (PBNode) duplicate Data section");[i,r]=Ee(t,r),n&&(o=!0)}else if(f===2){if(o)throw new Error("protobuf: (PBNode) duplicate Links section");n||(n=[]);let m;[m,r]=Ee(t,r),n.push(zn(m))}else throw new Error(`protobuf: (PBNode) invalid fieldNumber, expected 1 or 2, got ${f}`)}if(r>e)throw new Error("protobuf: (PBNode) unexpected end of data");let a={};return i&&(a.Data=i),a.Links=n||[],a}var si=new TextEncoder,ai=2**32,ci=2**31;var di=new TextEncoder;var Ct=112;function $t(t){let e=Nt(t),r={};return e.Data&&(r.Data=e.Data),e.Links&&(r.Links=e.Links.map(n=>{let o={};try{o.Hash=R.decode(n.Hash)}catch{}if(!o.Hash)throw new Error("Invalid Hash field found in link, expected CID");return n.Name!==void 0&&(o.Name=n.Name),n.Tsize!==void 0&&(o.Tsize=n.Tsize),o})),r}var Ln=["string","number","bigint","symbol"],On=["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 Dt(t){if(t===null)return"null";if(t===void 0)return"undefined";if(t===!0||t===!1)return"boolean";let e=typeof t;if(Ln.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(t))return"Array";if(Mn(t))return"Buffer";let r=Fn(t);return r||"Object"}function Mn(t){return t&&t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer.call(null,t)}function Fn(t){let e=Object.prototype.toString.call(t).slice(8,-1);if(On.includes(e))return e}var s=class{constructor(e,r,n){this.major=e,this.majorEncoded=e<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:this.major>e.major?1:0}};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 u=class{constructor(e,r,n){this.type=e,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var Z=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Vn=new TextDecoder,jn=new TextEncoder;function Te(t){return Z&&globalThis.Buffer.isBuffer(t)}function _e(t){return t instanceof Uint8Array?Te(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t:Uint8Array.from(t)}var Ot=Z?(t,e,r)=>r-e>64?globalThis.Buffer.from(t.subarray(e,r)).toString("utf8"):Pt(t,e,r):(t,e,r)=>r-e>64?Vn.decode(t.subarray(e,r)):Pt(t,e,r),Ae=Z?t=>t.length>64?globalThis.Buffer.from(t):zt(t):t=>t.length>64?jn.encode(t):zt(t);var ee=Z?(t,e,r)=>Te(t)?new Uint8Array(t.subarray(e,r)):t.slice(e,r):(t,e,r)=>t.slice(e,r),Mt=Z?(t,e)=>(t=t.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),_e(globalThis.Buffer.concat(t,e))):(t,e)=>{let r=new Uint8Array(e),n=0;for(let o of t)n+o.length>r.length&&(o=o.subarray(0,r.length-n)),r.set(o,n),n+=o.length;return r},Ft=Z?t=>globalThis.Buffer.allocUnsafe(t):t=>new Uint8Array(t);function Vt(t,e){if(Te(t)&&Te(e))return t.compare(e);for(let r=0;r<t.length;r++)if(t[r]!==e[r])return t[r]<e[r]?-1:1;return 0}function zt(t){let e=[],r=0;for(let n=0;n<t.length;n++){let o=t.charCodeAt(n);o<128?e[r++]=o:o<2048?(e[r++]=o>>6|192,e[r++]=o&63|128):(o&64512)===55296&&n+1<t.length&&(t.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(t.charCodeAt(++n)&1023),e[r++]=o>>18|240,e[r++]=o>>12&63|128,e[r++]=o>>6&63|128,e[r++]=o&63|128):(e[r++]=o>>12|224,e[r++]=o>>6&63|128,e[r++]=o&63|128)}return e}function Pt(t,e,r){let n=[];for(;e<r;){let o=t[e],i=null,a=o>239?4:o>223?3:o>191?2:1;if(e+a<=r){let c,f,m,l;switch(a){case 1:o<128&&(i=o);break;case 2:c=t[e+1],(c&192)===128&&(l=(o&31)<<6|c&63,l>127&&(i=l));break;case 3:c=t[e+1],f=t[e+2],(c&192)===128&&(f&192)===128&&(l=(o&15)<<12|(c&63)<<6|f&63,l>2047&&(l<55296||l>57343)&&(i=l));break;case 4:c=t[e+1],f=t[e+2],m=t[e+3],(c&192)===128&&(f&192)===128&&(m&192)===128&&(l=(o&15)<<18|(c&63)<<12|(f&63)<<6|m&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),e+=a}return Xe(n)}var Lt=4096;function Xe(t){let e=t.length;if(e<=Lt)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Lt));return r}var Rn=256,Ie=class{constructor(e=Rn){this.chunkSize=e,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(e){let r=this.chunks[this.chunks.length-1];if(this.cursor+e.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(e,o)}else{if(r){let o=r.length-(this.maxCursor-this.cursor)-1;o<r.length&&(this.chunks[this.chunks.length-1]=r.subarray(0,o),this.maxCursor=this.cursor-1)}e.length<64&&e.length<this.chunkSize?(r=Ft(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(e,0)):(this.chunks.push(e),this.maxCursor+=e.length)}this.cursor+=e.length}toBytes(e=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];e&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=ee(n,0,this.cursor)}else r=Mt(this.chunks,this.cursor);return e&&this.reset(),r}};var h="CBOR decode error:",te="CBOR encode error:",pe=[];pe[23]=1;pe[24]=2;pe[25]=3;pe[26]=5;pe[27]=9;function V(t,e,r){if(t.length-e<r)throw new Error(`${h} not enough data for type`)}var w=[24,256,65536,4294967296,BigInt("18446744073709551616")];function _(t,e,r){V(t,e,1);let n=t[e];if(r.strict===!0&&n<w[0])throw new Error(`${h} integer encoded in more bytes than necessary (strict decode)`);return n}function A(t,e,r){V(t,e,2);let n=t[e]<<8|t[e+1];if(r.strict===!0&&n<w[1])throw new Error(`${h} integer encoded in more bytes than necessary (strict decode)`);return n}function I(t,e,r){V(t,e,4);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3];if(r.strict===!0&&n<w[2])throw new Error(`${h} integer encoded in more bytes than necessary (strict decode)`);return n}function B(t,e,r){V(t,e,8);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3],o=t[e+4]*16777216+(t[e+5]<<16)+(t[e+6]<<8)+t[e+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&i<w[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 jt(t,e,r,n){return new u(s.uint,_(t,e+1,n),2)}function Rt(t,e,r,n){return new u(s.uint,A(t,e+1,n),3)}function Ht(t,e,r,n){return new u(s.uint,I(t,e+1,n),5)}function Gt(t,e,r,n){return new u(s.uint,B(t,e+1,n),9)}function U(t,e){return g(t,0,e.value)}function g(t,e,r){if(r<w[0]){let n=Number(r);t.push([e|n])}else if(r<w[1]){let n=Number(r);t.push([e|24,n])}else if(r<w[2]){let n=Number(r);t.push([e|25,n>>>8,n&255])}else if(r<w[3]){let n=Number(r);t.push([e|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<w[4]){let o=[e|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,t.push(o)}else throw new Error(`${h} encountered BigInt larger than allowable range`)}}U.encodedSize=function(e){return g.encodedSize(e.value)};g.encodedSize=function(e){return e<w[0]?1:e<w[1]?2:e<w[2]?3:e<w[3]?5:9};U.compareTokens=function(e,r){return e.value<r.value?-1:e.value>r.value?1:0};function qt(t,e,r,n){return new u(s.negint,-1-_(t,e+1,n),2)}function Wt(t,e,r,n){return new u(s.negint,-1-A(t,e+1,n),3)}function Kt(t,e,r,n){return new u(s.negint,-1-I(t,e+1,n),5)}var Ye=BigInt(-1),Jt=BigInt(1);function Qt(t,e,r,n){let o=B(t,e+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new u(s.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${h} integers outside of the safe integer range are not supported`);return new u(s.negint,Ye-BigInt(o),9)}function Be(t,e){let r=e.value,n=typeof r=="bigint"?r*Ye-Jt:r*-1-1;g(t,e.type.majorEncoded,n)}Be.encodedSize=function(e){let r=e.value,n=typeof r=="bigint"?r*Ye-Jt:r*-1-1;return n<w[0]?1:n<w[1]?2:n<w[2]?3:n<w[3]?5:9};Be.compareTokens=function(e,r){return e.value<r.value?1:e.value>r.value?-1:0};function me(t,e,r,n){V(t,e,r+n);let o=ee(t,e+r,e+r+n);return new u(s.bytes,o,r+n)}function Xt(t,e,r,n){return me(t,e,1,r)}function Yt(t,e,r,n){return me(t,e,2,_(t,e+1,n))}function Zt(t,e,r,n){return me(t,e,3,A(t,e+1,n))}function er(t,e,r,n){return me(t,e,5,I(t,e+1,n))}function tr(t,e,r,n){let o=B(t,e+1,n);if(typeof o=="bigint")throw new Error(`${h} 64-bit integer bytes lengths not supported`);return me(t,e,9,o)}function Se(t){return t.encodedBytes===void 0&&(t.encodedBytes=t.type===s.string?Ae(t.value):t.value),t.encodedBytes}function re(t,e){let r=Se(e);g(t,e.type.majorEncoded,r.length),t.push(r)}re.encodedSize=function(e){let r=Se(e);return g.encodedSize(r.length)+r.length};re.compareTokens=function(e,r){return Gn(Se(e),Se(r))};function Gn(t,e){return t.length<e.length?-1:t.length>e.length?1:Vt(t,e)}function ye(t,e,r,n,o){let i=r+n;V(t,e,i);let a=new u(s.string,Ot(t,e+r,e+i),i);return o.retainStringBytes===!0&&(a.byteValue=ee(t,e+r,e+i)),a}function rr(t,e,r,n){return ye(t,e,1,r,n)}function nr(t,e,r,n){return ye(t,e,2,_(t,e+1,n),n)}function or(t,e,r,n){return ye(t,e,3,A(t,e+1,n),n)}function ir(t,e,r,n){return ye(t,e,5,I(t,e+1,n),n)}function sr(t,e,r,n){let o=B(t,e+1,n);if(typeof o=="bigint")throw new Error(`${h} 64-bit integer string lengths not supported`);return ye(t,e,9,o,n)}var ar=re;function ne(t,e,r,n){return new u(s.array,n,r)}function cr(t,e,r,n){return ne(t,e,1,r)}function fr(t,e,r,n){return ne(t,e,2,_(t,e+1,n))}function ur(t,e,r,n){return ne(t,e,3,A(t,e+1,n))}function dr(t,e,r,n){return ne(t,e,5,I(t,e+1,n))}function hr(t,e,r,n){let o=B(t,e+1,n);if(typeof o=="bigint")throw new Error(`${h} 64-bit integer array lengths not supported`);return ne(t,e,9,o)}function lr(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${h} indefinite length items not allowed`);return ne(t,e,1,1/0)}function Ue(t,e){g(t,s.array.majorEncoded,e.value)}Ue.compareTokens=U.compareTokens;Ue.encodedSize=function(e){return g.encodedSize(e.value)};function oe(t,e,r,n){return new u(s.map,n,r)}function pr(t,e,r,n){return oe(t,e,1,r)}function mr(t,e,r,n){return oe(t,e,2,_(t,e+1,n))}function yr(t,e,r,n){return oe(t,e,3,A(t,e+1,n))}function xr(t,e,r,n){return oe(t,e,5,I(t,e+1,n))}function wr(t,e,r,n){let o=B(t,e+1,n);if(typeof o=="bigint")throw new Error(`${h} 64-bit integer map lengths not supported`);return oe(t,e,9,o)}function gr(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${h} indefinite length items not allowed`);return oe(t,e,1,1/0)}function Ne(t,e){g(t,s.map.majorEncoded,e.value)}Ne.compareTokens=U.compareTokens;Ne.encodedSize=function(e){return g.encodedSize(e.value)};function br(t,e,r,n){return new u(s.tag,r,1)}function vr(t,e,r,n){return new u(s.tag,_(t,e+1,n),2)}function kr(t,e,r,n){return new u(s.tag,A(t,e+1,n),3)}function Er(t,e,r,n){return new u(s.tag,I(t,e+1,n),5)}function Tr(t,e,r,n){return new u(s.tag,B(t,e+1,n),9)}function Ce(t,e){g(t,s.tag.majorEncoded,e.value)}Ce.compareTokens=U.compareTokens;Ce.encodedSize=function(e){return g.encodedSize(e.value)};var Xn=20,Yn=21,Zn=22,eo=23;function _r(t,e,r,n){if(n.allowUndefined===!1)throw new Error(`${h} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new u(s.null,null,1):new u(s.undefined,void 0,1)}function Ar(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${h} indefinite length items not allowed`);return new u(s.break,void 0,1)}function Ze(t,e,r){if(r){if(r.allowNaN===!1&&Number.isNaN(t))throw new Error(`${h} NaN values are not supported`);if(r.allowInfinity===!1&&(t===1/0||t===-1/0))throw new Error(`${h} Infinity values are not supported`)}return new u(s.float,t,e)}function Ir(t,e,r,n){return Ze(et(t,e+1),3,n)}function Br(t,e,r,n){return Ze(tt(t,e+1),5,n)}function Sr(t,e,r,n){return Ze($r(t,e+1),9,n)}function $e(t,e,r){let n=e.value;if(n===!1)t.push([s.float.majorEncoded|Xn]);else if(n===!0)t.push([s.float.majorEncoded|Yn]);else if(n===null)t.push([s.float.majorEncoded|Zn]);else if(n===void 0)t.push([s.float.majorEncoded|eo]);else{let o,i=!1;(!r||r.float64!==!0)&&(Nr(n),o=et(D,1),n===o||Number.isNaN(n)?(D[0]=249,t.push(D.slice(0,3)),i=!0):(Cr(n),o=tt(D,1),n===o&&(D[0]=250,t.push(D.slice(0,5)),i=!0))),i||(to(n),o=$r(D,1),D[0]=251,t.push(D.slice(0,9)))}}$e.encodedSize=function(e,r){let n=e.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){Nr(n);let o=et(D,1);if(n===o||Number.isNaN(n))return 3;if(Cr(n),o=tt(D,1),n===o)return 5}return 9};var Ur=new ArrayBuffer(9),N=new DataView(Ur,1),D=new Uint8Array(Ur,0);function Nr(t){if(t===1/0)N.setUint16(0,31744,!1);else if(t===-1/0)N.setUint16(0,64512,!1);else if(Number.isNaN(t))N.setUint16(0,32256,!1);else{N.setFloat32(0,t);let e=N.getUint32(0),r=(e&2139095040)>>23,n=e&8388607;if(r===255)N.setUint16(0,31744,!1);else if(r===0)N.setUint16(0,(t&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?N.setUint16(0,0):o<-14?N.setUint16(0,(e&2147483648)>>16|1<<24+o,!1):N.setUint16(0,(e&2147483648)>>16|o+15<<10|n>>13,!1)}}}function et(t,e){if(t.length-e<2)throw new Error(`${h} not enough data for float16`);let r=(t[e]<<8)+t[e+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,o=r&1023,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 Cr(t){N.setFloat32(0,t,!1)}function tt(t,e){if(t.length-e<4)throw new Error(`${h} not enough data for float32`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,4).getFloat32(0,!1)}function to(t){N.setFloat64(0,t,!1)}function $r(t,e){if(t.length-e<8)throw new Error(`${h} not enough data for float64`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,8).getFloat64(0,!1)}$e.compareTokens=U.compareTokens;function y(t,e,r){throw new Error(`${h} encountered invalid minor (${r}) for major ${t[e]>>>5}`)}function De(t){return()=>{throw new Error(`${h} ${t}`)}}var d=[];for(let t=0;t<=23;t++)d[t]=y;d[24]=jt;d[25]=Rt;d[26]=Ht;d[27]=Gt;d[28]=y;d[29]=y;d[30]=y;d[31]=y;for(let t=32;t<=55;t++)d[t]=y;d[56]=qt;d[57]=Wt;d[58]=Kt;d[59]=Qt;d[60]=y;d[61]=y;d[62]=y;d[63]=y;for(let t=64;t<=87;t++)d[t]=Xt;d[88]=Yt;d[89]=Zt;d[90]=er;d[91]=tr;d[92]=y;d[93]=y;d[94]=y;d[95]=De("indefinite length bytes/strings are not supported");for(let t=96;t<=119;t++)d[t]=rr;d[120]=nr;d[121]=or;d[122]=ir;d[123]=sr;d[124]=y;d[125]=y;d[126]=y;d[127]=De("indefinite length bytes/strings are not supported");for(let t=128;t<=151;t++)d[t]=cr;d[152]=fr;d[153]=ur;d[154]=dr;d[155]=hr;d[156]=y;d[157]=y;d[158]=y;d[159]=lr;for(let t=160;t<=183;t++)d[t]=pr;d[184]=mr;d[185]=yr;d[186]=xr;d[187]=wr;d[188]=y;d[189]=y;d[190]=y;d[191]=gr;for(let t=192;t<=215;t++)d[t]=br;d[216]=vr;d[217]=kr;d[218]=Er;d[219]=Tr;d[220]=y;d[221]=y;d[222]=y;d[223]=y;for(let t=224;t<=243;t++)d[t]=De("simple values are not supported");d[244]=y;d[245]=y;d[246]=y;d[247]=_r;d[248]=De("simple values are not supported");d[249]=Ir;d[250]=Br;d[251]=Sr;d[252]=y;d[253]=y;d[254]=y;d[255]=Ar;var z=[];for(let t=0;t<24;t++)z[t]=new u(s.uint,t,1);for(let t=-1;t>=-24;t--)z[31-t]=new u(s.negint,t,1);z[64]=new u(s.bytes,new Uint8Array(0),1);z[96]=new u(s.string,"",1);z[128]=new u(s.array,0,1);z[160]=new u(s.map,0,1);z[244]=new u(s.false,!1,1);z[245]=new u(s.true,!0,1);z[246]=new u(s.null,null,1);function no(){let t=[];return t[s.uint.major]=U,t[s.negint.major]=Be,t[s.bytes.major]=re,t[s.string.major]=ar,t[s.array.major]=Ue,t[s.map.major]=Ne,t[s.tag.major]=Ce,t[s.float.major]=$e,t}var ls=no(),ps=new Ie,ze=class t{constructor(e,r){this.obj=e,this.parent=r}includes(e){let r=this;do if(r.obj===e)return!0;while(r=r.parent);return!1}static createCheck(e,r){if(e&&e.includes(r))throw new Error(`${te} object contains circular references`);return new t(r,e)}},H={null:new u(s.null,null),undefined:new u(s.undefined,void 0),true:new u(s.true,!0),false:new u(s.false,!1),emptyArray:new u(s.array,0),emptyMap:new u(s.map,0)},G={number(t,e,r,n){return!Number.isInteger(t)||!Number.isSafeInteger(t)?new u(s.float,t):t>=0?new u(s.uint,t):new u(s.negint,t)},bigint(t,e,r,n){return t>=BigInt(0)?new u(s.uint,t):new u(s.negint,t)},Uint8Array(t,e,r,n){return new u(s.bytes,t)},string(t,e,r,n){return new u(s.string,t)},boolean(t,e,r,n){return t?H.true:H.false},null(t,e,r,n){return H.null},undefined(t,e,r,n){return H.undefined},ArrayBuffer(t,e,r,n){return new u(s.bytes,new Uint8Array(t))},DataView(t,e,r,n){return new u(s.bytes,new Uint8Array(t.buffer,t.byteOffset,t.byteLength))},Array(t,e,r,n){if(!t.length)return r.addBreakTokens===!0?[H.emptyArray,new u(s.break)]:H.emptyArray;n=ze.createCheck(n,t);let o=[],i=0;for(let a of t)o[i++]=rt(a,r,n);return r.addBreakTokens?[new u(s.array,t.length),o,new u(s.break)]:[new u(s.array,t.length),o]},Object(t,e,r,n){let o=e!=="Object",i=o?t.keys():Object.keys(t),a=o?t.size:i.length;if(!a)return r.addBreakTokens===!0?[H.emptyMap,new u(s.break)]:H.emptyMap;n=ze.createCheck(n,t);let c=[],f=0;for(let m of i)c[f++]=[rt(m,r,n),rt(o?t.get(m):t[m],r,n)];return oo(c,r),r.addBreakTokens?[new u(s.map,a),c,new u(s.break)]:[new u(s.map,a),c]}};G.Map=G.Object;G.Buffer=G.Uint8Array;for(let t of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))G[`${t}Array`]=G.DataView;function rt(t,e={},r){let n=Dt(t),o=e&&e.typeEncoders&&e.typeEncoders[n]||G[n];if(typeof o=="function"){let a=o(t,n,e,r);if(a!=null)return a}let i=G[n];if(!i)throw new Error(`${te} unsupported type: ${n}`);return i(t,n,e,r)}function oo(t,e){e.mapSorter&&t.sort(e.mapSorter)}var io={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},nt=class{constructor(e,r={}){this._pos=0,this.data=e,this.options=r}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let e=this.data[this._pos],r=z[e];if(r===void 0){let n=d[e];if(!n)throw new Error(`${h} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);let o=e&31;r=n(this.data,this._pos,o,this.options)}return this._pos+=r.encodedLength,r}},xe=Symbol.for("DONE"),Pe=Symbol.for("BREAK");function so(t,e,r){let n=[];for(let o=0;o<t.value;o++){let i=we(e,r);if(i===Pe){if(t.value===1/0)break;throw new Error(`${h} got unexpected break to lengthed array`)}if(i===xe)throw new Error(`${h} found array but not enough entries (got ${o}, expected ${t.value})`);n[o]=i}return n}function ao(t,e,r){let n=r.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let a=0;a<t.value;a++){let c=we(e,r);if(c===Pe){if(t.value===1/0)break;throw new Error(`${h} got unexpected break to lengthed map`)}if(c===xe)throw new Error(`${h} found map but not enough entries (got ${a} [no key], expected ${t.value})`);if(n!==!0&&typeof c!="string")throw new Error(`${h} non-string keys not supported (got ${typeof c})`);if(r.rejectDuplicateMapKeys===!0&&(n&&i.has(c)||!n&&c in o))throw new Error(`${h} found repeat map key "${c}"`);let f=we(e,r);if(f===xe)throw new Error(`${h} found map but not enough entries (got ${a} [no value], expected ${t.value})`);n?i.set(c,f):o[c]=f}return n?i:o}function we(t,e){if(t.done())return xe;let r=t.next();if(r.type===s.break)return Pe;if(r.type.terminal)return r.value;if(r.type===s.array)return so(r,t,e);if(r.type===s.map)return ao(r,t,e);if(r.type===s.tag){if(e.tags&&typeof e.tags[r.value]=="function"){let n=we(t,e);return e.tags[r.value](n)}throw new Error(`${h} tag not supported (${r.value})`)}throw new Error("unsupported")}function ot(t,e){if(!(t instanceof Uint8Array))throw new Error(`${h} data to decode must be a Uint8Array`);e=Object.assign({},io,e);let r=e.tokenizer||new nt(t,e),n=we(r,e);if(n===xe)throw new Error(`${h} did not find any content to decode`);if(n===Pe)throw new Error(`${h} got unexpected break`);return[n,t.subarray(r.pos())]}function ge(t,e){let[r,n]=ot(t,e);if(n.length>0)throw new Error(`${h} too many terminals, data makes no sense`);return r}var Dr=class extends Array{constructor(){super(),this.inRecursive=[]}prefix(e){let r=this.inRecursive[this.inRecursive.length-1];r&&(r.type===s.array&&(r.elements++,r.elements!==1&&e.push([44])),r.type===s.map&&(r.elements++,r.elements!==1&&(r.elements%2===1?e.push([44]):e.push([58]))))}[s.uint.major](e,r){this.prefix(e);let n=String(r.value),o=[];for(let i=0;i<n.length;i++)o[i]=n.charCodeAt(i);e.push(o)}[s.negint.major](e,r){this[s.uint.major](e,r)}[s.bytes.major](e,r){throw new Error(`${te} unsupported type: Uint8Array`)}[s.string.major](e,r){this.prefix(e);let n=Ae(JSON.stringify(r.value));e.push(n.length>32?_e(n):n)}[s.array.major](e,r){this.prefix(e),this.inRecursive.push({type:s.array,elements:0}),e.push([91])}[s.map.major](e,r){this.prefix(e),this.inRecursive.push({type:s.map,elements:0}),e.push([123])}[s.tag.major](e,r){}[s.float.major](e,r){if(r.type.name==="break"){let a=this.inRecursive.pop();if(a){if(a.type===s.array)e.push([93]);else if(a.type===s.map)e.push([125]);else throw new Error("Unexpected recursive type; this should not happen!");return}throw new Error("Unexpected break; this should not happen!")}if(r.value===void 0)throw new Error(`${te} unsupported type: undefined`);if(this.prefix(e),r.type.name==="true"){e.push([116,114,117,101]);return}else if(r.type.name==="false"){e.push([102,97,108,115,101]);return}else if(r.type.name==="null"){e.push([110,117,108,108]);return}let n=String(r.value),o=[],i=!1;for(let a=0;a<n.length;a++)o[a]=n.charCodeAt(a),!i&&(o[a]===46||o[a]===101||o[a]===69)&&(i=!0);i||(o.push(46),o.push(48)),e.push(o)}};var ie=class{constructor(e,r={}){this._pos=0,this.data=e,this.options=r,this.modeStack=["value"],this.lastToken=""}pos(){return this._pos}done(){return this._pos>=this.data.length}ch(){return this.data[this._pos]}currentMode(){return this.modeStack[this.modeStack.length-1]}skipWhitespace(){let e=this.ch();for(;e===32||e===9||e===13||e===10;)e=this.data[++this._pos]}expect(e){if(this.data.length-this._pos<e.length)throw new Error(`${h} unexpected end of input at position ${this._pos}`);for(let r=0;r<e.length;r++)if(this.data[this._pos++]!==e[r])throw new Error(`${h} unexpected token at position ${this._pos}, expected to find '${String.fromCharCode(...e)}'`)}parseNumber(){let e=this._pos,r=!1,n=!1,o=c=>{for(;!this.done();){let f=this.ch();if(c.includes(f))this._pos++;else break}};if(this.ch()===45&&(r=!0,this._pos++),this.ch()===48)if(this._pos++,this.ch()===46)this._pos++,n=!0;else return new u(s.uint,0,this._pos-e);if(o([48,49,50,51,52,53,54,55,56,57]),r&&this._pos===e+1)throw new Error(`${h} unexpected token at position ${this._pos}`);if(!this.done()&&this.ch()===46){if(n)throw new Error(`${h} unexpected token at position ${this._pos}`);n=!0,this._pos++,o([48,49,50,51,52,53,54,55,56,57])}!this.done()&&(this.ch()===101||this.ch()===69)&&(n=!0,this._pos++,!this.done()&&(this.ch()===43||this.ch()===45)&&this._pos++,o([48,49,50,51,52,53,54,55,56,57]));let i=String.fromCharCode.apply(null,this.data.subarray(e,this._pos)),a=parseFloat(i);return n?new u(s.float,a,this._pos-e):this.options.allowBigInt!==!0||Number.isSafeInteger(a)?new u(a>=0?s.uint:s.negint,a,this._pos-e):new u(a>=0?s.uint:s.negint,BigInt(i),this._pos-e)}parseString(){if(this.ch()!==34)throw new Error(`${h} unexpected character at position ${this._pos}; this shouldn't happen`);this._pos++;for(let i=this._pos,a=0;i<this.data.length&&a<65536;i++,a++){let c=this.data[i];if(c===92||c<32||c>=128)break;if(c===34){let f=String.fromCharCode.apply(null,this.data.subarray(this._pos,i));return this._pos=i+1,new u(s.string,f,a)}}let e=this._pos,r=[],n=()=>{if(this._pos+4>=this.data.length)throw new Error(`${h} unexpected end of unicode escape sequence at position ${this._pos}`);let i=0;for(let a=0;a<4;a++){let c=this.ch();if(c>=48&&c<=57)c-=48;else if(c>=97&&c<=102)c=c-97+10;else if(c>=65&&c<=70)c=c-65+10;else throw new Error(`${h} unexpected unicode escape character at position ${this._pos}`);i=i*16+c,this._pos++}return i},o=()=>{let i=this.ch(),a=null,c=i>239?4:i>223?3:i>191?2:1;if(this._pos+c>this.data.length)throw new Error(`${h} unexpected unicode sequence at position ${this._pos}`);let f,m,l,p;switch(c){case 1:i<128&&(a=i);break;case 2:f=this.data[this._pos+1],(f&192)===128&&(p=(i&31)<<6|f&63,p>127&&(a=p));break;case 3:f=this.data[this._pos+1],m=this.data[this._pos+2],(f&192)===128&&(m&192)===128&&(p=(i&15)<<12|(f&63)<<6|m&63,p>2047&&(p<55296||p>57343)&&(a=p));break;case 4:f=this.data[this._pos+1],m=this.data[this._pos+2],l=this.data[this._pos+3],(f&192)===128&&(m&192)===128&&(l&192)===128&&(p=(i&15)<<18|(f&63)<<12|(m&63)<<6|l&63,p>65535&&p<1114112&&(a=p))}a===null?(a=65533,c=1):a>65535&&(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023),r.push(a),this._pos+=c};for(;!this.done();){let i=this.ch(),a;switch(i){case 92:if(this._pos++,this.done())throw new Error(`${h} unexpected string termination at position ${this._pos}`);switch(a=this.ch(),this._pos++,a){case 34:case 39:case 92:case 47:r.push(a);break;case 98:r.push(8);break;case 116:r.push(9);break;case 110:r.push(10);break;case 102:r.push(12);break;case 114:r.push(13);break;case 117:r.push(n());break;default:throw new Error(`${h} unexpected string escape character at position ${this._pos}`)}break;case 34:return this._pos++,new u(s.string,Xe(r),this._pos-e);default:if(i<32)throw new Error(`${h} invalid control character at position ${this._pos}`);i<128?(r.push(i),this._pos++):o()}}throw new Error(`${h} unexpected end of string at position ${this._pos}`)}parseValue(){switch(this.ch()){case 123:return this.modeStack.push("obj-start"),this._pos++,new u(s.map,1/0,1);case 91:return this.modeStack.push("array-start"),this._pos++,new u(s.array,1/0,1);case 34:return this.parseString();case 110:return this.expect([110,117,108,108]),new u(s.null,null,4);case 102:return this.expect([102,97,108,115,101]),new u(s.false,!1,5);case 116:return this.expect([116,114,117,101]),new u(s.true,!0,4);case 45:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.parseNumber();default:throw new Error(`${h} unexpected character at position ${this._pos}`)}}next(){switch(this.skipWhitespace(),this.currentMode()){case"value":return this.modeStack.pop(),this.parseValue();case"array-value":{if(this.modeStack.pop(),this.ch()===93)return this._pos++,this.skipWhitespace(),new u(s.break,void 0,1);if(this.ch()!==44)throw new Error(`${h} unexpected character at position ${this._pos}, was expecting array delimiter but found '${String.fromCharCode(this.ch())}'`);return this._pos++,this.modeStack.push("array-value"),this.skipWhitespace(),this.parseValue()}case"array-start":return this.modeStack.pop(),this.ch()===93?(this._pos++,this.skipWhitespace(),new u(s.break,void 0,1)):(this.modeStack.push("array-value"),this.skipWhitespace(),this.parseValue());case"obj-key":if(this.ch()===125)return this.modeStack.pop(),this._pos++,this.skipWhitespace(),new u(s.break,void 0,1);if(this.ch()!==44)throw new Error(`${h} unexpected character at position ${this._pos}, was expecting object delimiter but found '${String.fromCharCode(this.ch())}'`);this._pos++,this.skipWhitespace();case"obj-start":{if(this.modeStack.pop(),this.ch()===125)return this._pos++,this.skipWhitespace(),new u(s.break,void 0,1);let e=this.parseString();if(this.skipWhitespace(),this.ch()!==58)throw new Error(`${h} unexpected character at position ${this._pos}, was expecting key/value delimiter ':' but found '${String.fromCharCode(this.ch())}'`);return this._pos++,this.modeStack.push("obj-value"),e}case"obj-value":return this.modeStack.pop(),this.modeStack.push("obj-key"),this.skipWhitespace(),this.parseValue();default:throw new Error(`${h} unexpected parse state at position ${this._pos}; this shouldn't happen`)}}};function it(t,e){return e=Object.assign({tokenizer:new ie(t,e)},e),ge(t,e)}var zr=E({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Fs=E({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Vs=E({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),js=E({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Pr=85;var Lr={codec:Ct,async*walk(t){yield*$t(t).Links.map(r=>r.Hash)}},Or={codec:Pr,async*walk(){}},Mr=42,Fr={codec:113,async*walk(t){let e=[],r=[];r[Mr]=n=>{if(n[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");let o=R.decode(n.subarray(1));return e.push(o),o},ge(t,{tags:r}),yield*e}},st=class extends ie{tokenBuffer;constructor(e,r){super(e,r),this.tokenBuffer=[]}done(){return this.tokenBuffer.length===0&&super.done()}_next(){return this.tokenBuffer.length>0?this.tokenBuffer.pop():super.next()}next(){let e=this._next();if(e.type===s.map){let r=this._next();if(r.type===s.string&&r.value==="/"){let n=this._next();if(n.type===s.string){if(this._next().type!==s.break)throw new Error("Invalid encoded CID form");return this.tokenBuffer.push(n),new u(s.tag,42,0)}if(n.type===s.map){let o=this._next();if(o.type===s.string&&o.value==="bytes"){let i=this._next();if(i.type===s.string){for(let c=0;c<2;c++)if(this._next().type!==s.break)throw new Error("Invalid encoded Bytes form");let a=zr.decode(`m${i.value}`);return new u(s.bytes,a,i.value.length)}this.tokenBuffer.push(i)}this.tokenBuffer.push(o)}this.tokenBuffer.push(n)}this.tokenBuffer.push(r)}return e}},Vr={codec:297,async*walk(t){let e=[],r=[];r[Mr]=n=>{let o=R.parse(n);return e.push(o),o},it(t,{tags:r,tokenizer:new st(t,{tags:r,allowIndefinite:!0,allowUndefined:!0,allowNaN:!0,allowInfinity:!0,allowBigInt:!0,strict:!1,rejectDuplicateMapKeys:!1})}),yield*e}};var ho=[Or,Lr,Fr,Vr],lo=1,at=class{components;dagWalkers;constructor(e,r){this.components=e,this.dagWalkers={},[...ho,...r.dagWalkers??[]].forEach(n=>{this.dagWalkers[n.codec]=n})}async import(e,r){await ft(this.components.blockstore.putMany(dt(e.blocks(),({cid:n,bytes:o})=>({cid:n,block:o})),r))}async export(e,r,n){let o=Le(),i=Array.isArray(e)?e:[e],a=new fe({concurrency:lo});a.on("idle",()=>{o.resolve()}),a.on("error",c=>{o.resolve(c)});for(let c of i)a.add(async()=>{await this.#e(c,a,async(f,m)=>{await r.put({cid:f,bytes:m})},n)});try{await o.promise}finally{await r.close()}}async#e(e,r,n,o){let i=this.dagWalkers[e.code];if(i==null)throw new Error(`No dag walker found for cid codec ${e.code}`);let a=await this.components.blockstore.get(e,o);await n(e,a);for await(let c of i.walk(a))r.add(async()=>{await this.#e(c,r,n,o)})}};function po(t,e={}){return new at(t,e)}return Qr(mo);})();
|
|
3
3
|
return HeliaCar}));
|
package/dist/src/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* By default it supports `dag-pb`, `dag-cbor`, `dag-json` and `raw` CIDs, more esoteric DAG walkers can be passed as an init option.
|
|
9
9
|
*
|
|
10
|
-
* @example
|
|
10
|
+
* @example Exporting a DAG as a CAR file
|
|
11
11
|
*
|
|
12
12
|
* ```typescript
|
|
13
13
|
* import { createHelia } from 'helia'
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
* await c.export(cid, writer)
|
|
37
37
|
* ```
|
|
38
38
|
*
|
|
39
|
-
* @example
|
|
39
|
+
* @example Importing all blocks from a CAR file
|
|
40
40
|
*
|
|
41
41
|
* ```typescript
|
|
42
42
|
* import { createHelia } from 'helia'
|
|
@@ -78,7 +78,7 @@ export interface CarInit {
|
|
|
78
78
|
*/
|
|
79
79
|
export interface DAGWalker {
|
|
80
80
|
codec: number;
|
|
81
|
-
walk
|
|
81
|
+
walk(block: Uint8Array): AsyncGenerator<CID, void, undefined>;
|
|
82
82
|
}
|
|
83
83
|
/**
|
|
84
84
|
* The Car interface provides operations for importing and exporting Car files
|
|
@@ -105,7 +105,7 @@ export interface Car {
|
|
|
105
105
|
* await c.import(reader)
|
|
106
106
|
* ```
|
|
107
107
|
*/
|
|
108
|
-
import
|
|
108
|
+
import(reader: Pick<CarReader, 'blocks'>, options?: AbortOptions & ProgressOptions<PutManyBlocksProgressEvents>): Promise<void>;
|
|
109
109
|
/**
|
|
110
110
|
* Store all blocks that make up one or more DAGs in a car file.
|
|
111
111
|
*
|
|
@@ -132,7 +132,7 @@ export interface Car {
|
|
|
132
132
|
* await eventPromise
|
|
133
133
|
* ```
|
|
134
134
|
*/
|
|
135
|
-
export
|
|
135
|
+
export(root: CID | CID[], writer: Pick<CarWriter, 'put' | 'close'>, options?: AbortOptions & ProgressOptions<GetBlockProgressEvents>): Promise<void>;
|
|
136
136
|
}
|
|
137
137
|
/**
|
|
138
138
|
* Create a {@link Car} instance for use with {@link https://github.com/ipfs/helia Helia}
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AAOH,OAAO,KAAK,EAAE,MAAM,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAA;AAC1G,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,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,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,OAAO;IACtB;;;;OAIG;IACH,UAAU,CAAC,EAAE,SAAS,EAAE,CAAA;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AAOH,OAAO,KAAK,EAAE,MAAM,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAA;AAC1G,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,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,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,OAAO;IACtB;;;;OAIG;IACH,UAAU,CAAC,EAAE,SAAS,EAAE,CAAA;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,cAAc,CAAC,GAAG,EAAE,IAAI,EAAE,SAAS,CAAC,CAAA;CAC9D;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,YAAY,GAAG,eAAe,CAAC,sBAAsB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACrJ;AAuFD;;GAEG;AACH,wBAAgB,GAAG,CAAE,KAAK,EAAE;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,EAAE,IAAI,GAAE,OAAY,GAAG,GAAG,CAE3E"}
|
package/dist/src/index.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* By default it supports `dag-pb`, `dag-cbor`, `dag-json` and `raw` CIDs, more esoteric DAG walkers can be passed as an init option.
|
|
9
9
|
*
|
|
10
|
-
* @example
|
|
10
|
+
* @example Exporting a DAG as a CAR file
|
|
11
11
|
*
|
|
12
12
|
* ```typescript
|
|
13
13
|
* import { createHelia } from 'helia'
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
* await c.export(cid, writer)
|
|
37
37
|
* ```
|
|
38
38
|
*
|
|
39
|
-
* @example
|
|
39
|
+
* @example Importing all blocks from a CAR file
|
|
40
40
|
*
|
|
41
41
|
* ```typescript
|
|
42
42
|
* import { createHelia } from 'helia'
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AAEH,OAAO,KAAK,MAAM,UAAU,CAAA;AAC5B,OAAO,GAAG,MAAM,QAAQ,CAAA;AACxB,OAAO,KAAK,MAAM,SAAS,CAAA;AAC3B,OAAO,MAAM,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAoFvF,MAAM,mBAAmB,GAAG;IAC1B,SAAS;IACT,WAAW;IACX,UAAU;IACV,UAAU;CACX,CAAA;AAED,MAAM,0BAA0B,GAAG,CAAC,CAAA;AAEpC,MAAM,UAAU;IACG,UAAU,CAAe;IAClC,UAAU,CAA2B;IAE7C,YAAa,UAAyB,EAAE,IAAa;QACnD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAE5B,IAAI,CAAC,UAAU,GAAG,EAAE,CAEnB;QAAA,CAAC,GAAG,mBAAmB,EAAE,GAAG,CAAC,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;YACxE,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,SAAS,CAAA;QAC9C,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,KAAK,CAAC,MAAM,CAAE,MAAiC,EAAE,OAAqE;QACpH,MAAM,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,C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G,IAAI,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YAC9C,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,KAA6B,EAAE,OAAgB,EAAE;IACpE,OAAO,IAAI,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;AACpC,CAAC"}
|
|
@@ -4,7 +4,7 @@ import { CID } from 'multiformats/cid';
|
|
|
4
4
|
*/
|
|
5
5
|
export interface DAGWalker {
|
|
6
6
|
codec: number;
|
|
7
|
-
walk
|
|
7
|
+
walk(block: Uint8Array): AsyncGenerator<CID, void, undefined>;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* Dag walker for dag-pb CIDs
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dag-walkers.d.ts","sourceRoot":"","sources":["../../../src/utils/dag-walkers.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAGtC;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,
|
|
1
|
+
{"version":3,"file":"dag-walkers.d.ts","sourceRoot":"","sources":["../../../src/utils/dag-walkers.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAGtC;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,cAAc,CAAC,GAAG,EAAE,IAAI,EAAE,SAAS,CAAC,CAAA;CAC9D;AAED;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,SAOz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CAAC,CAAA;QAED,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE;YACtB,IAAI;YACJ,SAAS,EAAE,IAAI,gBAAgB,CAAC,KAAK,EAAE;gBACrC,IAAI;gBACJ,eAAe,EAAE,IAAI;gBACrB,cAAc,EAAE,IAAI;gBACpB,QAAQ,EAAE,IAAI;gBACd,aAAa,EAAE,IAAI;gBACnB,WAAW,EAAE,IAAI;gBACjB,MAAM,EAAE,KAAK;gBACb,sBAAsB,EAAE,KAAK;aAC9B,CAAC;SACH,CAAC,CAAA;QAEF,KAAM,CAAC,CAAC,IAAI,CAAA;IACd,CAAC;CACF,CAAA"}
|
package/dist/typedoc-urls.json
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"Car": "https://ipfs.github.io/helia-car/interfaces/Car.html",
|
|
3
|
+
".:Car": "https://ipfs.github.io/helia-car/interfaces/Car.html",
|
|
3
4
|
"CarComponents": "https://ipfs.github.io/helia-car/interfaces/CarComponents.html",
|
|
5
|
+
".:CarComponents": "https://ipfs.github.io/helia-car/interfaces/CarComponents.html",
|
|
4
6
|
"CarInit": "https://ipfs.github.io/helia-car/interfaces/CarInit.html",
|
|
7
|
+
".:CarInit": "https://ipfs.github.io/helia-car/interfaces/CarInit.html",
|
|
5
8
|
"DAGWalker": "https://ipfs.github.io/helia-car/interfaces/DAGWalker.html",
|
|
6
|
-
"
|
|
9
|
+
".:DAGWalker": "https://ipfs.github.io/helia-car/interfaces/DAGWalker.html",
|
|
10
|
+
"car": "https://ipfs.github.io/helia-car/functions/car-1.html",
|
|
11
|
+
".:car": "https://ipfs.github.io/helia-car/functions/car-1.html"
|
|
7
12
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helia/car",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Import/export car files from Helia",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
|
-
"homepage": "https://github.com/ipfs/helia-car/tree/
|
|
6
|
+
"homepage": "https://github.com/ipfs/helia-car/tree/main/packages/car#readme",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "git+https://github.com/ipfs/helia-car.git"
|
|
@@ -11,6 +11,10 @@
|
|
|
11
11
|
"bugs": {
|
|
12
12
|
"url": "https://github.com/ipfs/helia-car/issues"
|
|
13
13
|
},
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public",
|
|
16
|
+
"provenance": true
|
|
17
|
+
},
|
|
14
18
|
"keywords": [
|
|
15
19
|
"IPFS"
|
|
16
20
|
],
|
|
@@ -42,15 +46,12 @@
|
|
|
42
46
|
".": {
|
|
43
47
|
"types": "./dist/src/index.d.ts",
|
|
44
48
|
"import": "./dist/src/index.js"
|
|
45
|
-
},
|
|
46
|
-
"./errors": {
|
|
47
|
-
"types": "./dist/src/errors.d.ts",
|
|
48
|
-
"import": "./dist/src/errors.js"
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
51
|
"eslintConfig": {
|
|
52
52
|
"extends": "ipfs",
|
|
53
53
|
"parserOptions": {
|
|
54
|
+
"project": true,
|
|
54
55
|
"sourceType": "module"
|
|
55
56
|
}
|
|
56
57
|
},
|
|
@@ -154,24 +155,24 @@
|
|
|
154
155
|
"release": "aegir release"
|
|
155
156
|
},
|
|
156
157
|
"dependencies": {
|
|
157
|
-
"@helia/interface": "^
|
|
158
|
+
"@helia/interface": "^3.0.0",
|
|
158
159
|
"@ipld/car": "^5.1.1",
|
|
159
160
|
"@ipld/dag-pb": "^4.0.0",
|
|
160
161
|
"@libp2p/interfaces": "^3.3.1",
|
|
161
|
-
"cborg": "^
|
|
162
|
-
"
|
|
162
|
+
"cborg": "^4.0.3",
|
|
163
|
+
"it-drain": "^3.0.5",
|
|
163
164
|
"it-map": "^3.0.3",
|
|
164
|
-
"multiformats": "^
|
|
165
|
+
"multiformats": "^13.0.0",
|
|
165
166
|
"p-defer": "^4.0.0",
|
|
166
|
-
"p-queue": "^
|
|
167
|
+
"p-queue": "^8.0.1",
|
|
167
168
|
"progress-events": "^1.0.0"
|
|
168
169
|
},
|
|
169
170
|
"devDependencies": {
|
|
170
|
-
"@helia/unixfs": "^
|
|
171
|
-
"aegir": "^
|
|
171
|
+
"@helia/unixfs": "^2.0.0",
|
|
172
|
+
"aegir": "^42.0.1",
|
|
172
173
|
"blockstore-core": "^4.0.1",
|
|
174
|
+
"interface-blockstore": "^5.2.9",
|
|
173
175
|
"ipfs-unixfs-importer": "^15.1.0",
|
|
174
|
-
"it-drain": "^3.0.1",
|
|
175
176
|
"it-to-buffer": "^4.0.2"
|
|
176
177
|
}
|
|
177
178
|
}
|
package/src/index.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* By default it supports `dag-pb`, `dag-cbor`, `dag-json` and `raw` CIDs, more esoteric DAG walkers can be passed as an init option.
|
|
9
9
|
*
|
|
10
|
-
* @example
|
|
10
|
+
* @example Exporting a DAG as a CAR file
|
|
11
11
|
*
|
|
12
12
|
* ```typescript
|
|
13
13
|
* import { createHelia } from 'helia'
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
* await c.export(cid, writer)
|
|
37
37
|
* ```
|
|
38
38
|
*
|
|
39
|
-
* @example
|
|
39
|
+
* @example Importing all blocks from a CAR file
|
|
40
40
|
*
|
|
41
41
|
* ```typescript
|
|
42
42
|
* import { createHelia } from 'helia'
|
|
@@ -87,7 +87,7 @@ export interface CarInit {
|
|
|
87
87
|
*/
|
|
88
88
|
export interface DAGWalker {
|
|
89
89
|
codec: number
|
|
90
|
-
walk
|
|
90
|
+
walk(block: Uint8Array): AsyncGenerator<CID, void, undefined>
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
/**
|
|
@@ -115,7 +115,7 @@ export interface Car {
|
|
|
115
115
|
* await c.import(reader)
|
|
116
116
|
* ```
|
|
117
117
|
*/
|
|
118
|
-
import
|
|
118
|
+
import(reader: Pick<CarReader, 'blocks'>, options?: AbortOptions & ProgressOptions<PutManyBlocksProgressEvents>): Promise<void>
|
|
119
119
|
|
|
120
120
|
/**
|
|
121
121
|
* Store all blocks that make up one or more DAGs in a car file.
|
|
@@ -143,7 +143,7 @@ export interface Car {
|
|
|
143
143
|
* await eventPromise
|
|
144
144
|
* ```
|
|
145
145
|
*/
|
|
146
|
-
export
|
|
146
|
+
export(root: CID | CID[], writer: Pick<CarWriter, 'put' | 'close'>, options?: AbortOptions & ProgressOptions<GetBlockProgressEvents>): Promise<void>
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
const DEFAULT_DAG_WALKERS = [
|
package/src/utils/dag-walkers.ts
CHANGED