@helia/car 5.1.0 → 5.1.1-760ed27f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +3 -3
- package/package.json +5 -5
- package/dist/typedoc-urls.json +0 -21
package/dist/index.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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 Ca=Object.create;var $t=Object.defineProperty;var Da=Object.getOwnPropertyDescriptor;var La=Object.getOwnPropertyNames;var Pa=Object.getPrototypeOf,Ua=Object.prototype.hasOwnProperty;var ue=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),V=(t,e)=>{for(var r in e)$t(t,r,{get:e[r],enumerable:!0})},_o=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of La(e))!Ua.call(t,o)&&o!==r&&$t(t,o,{get:()=>e[o],enumerable:!(n=Da(e,o))||n.enumerable});return t};var Ee=(t,e,r)=>(r=t!=null?Ca(Pa(t)):{},_o(e||!t||!t.__esModule?$t(r,"default",{value:t,enumerable:!0}):r,t)),Ra=t=>_o($t({},"__esModule",{value:!0}),t);var Hi=ue((jh,Oi)=>{Oi.exports=fn;var $i=128,ou=127,iu=~ou,su=Math.pow(2,31);function fn(t,e,r){if(Number.MAX_SAFE_INTEGER&&t>Number.MAX_SAFE_INTEGER)throw fn.bytes=0,new RangeError("Could not encode varint");e=e||[],r=r||0;for(var n=r;t>=su;)e[r++]=t&255|$i,t/=128;for(;t&iu;)e[r++]=t&255|$i,t>>>=7;return e[r]=t|0,fn.bytes=r-n+1,e}});var Gi=ue((Wh,qi)=>{qi.exports=ln;var au=128,Vi=127;function ln(t,n){var r=0,n=n||0,o=0,i=n,s,a=t.length;do{if(i>=a||o>49)throw ln.bytes=0,new RangeError("Could not decode varint");s=t[i++],r+=o<28?(s&Vi)<<o:(s&Vi)*Math.pow(2,o),o+=7}while(s>=au);return ln.bytes=i-n,r}});var Wi=ue((Jh,ji)=>{var cu=Math.pow(2,7),uu=Math.pow(2,14),fu=Math.pow(2,21),lu=Math.pow(2,28),hu=Math.pow(2,35),du=Math.pow(2,42),pu=Math.pow(2,49),mu=Math.pow(2,56),yu=Math.pow(2,63);ji.exports=function(t){return t<cu?1:t<uu?2:t<fu?3:t<lu?4:t<hu?5:t<du?6:t<pu?7:t<mu?8:t<yu?9:10}});var tr=ue((Xh,Ji)=>{Ji.exports={encode:Hi(),decode:Gi(),encodingLength:Wi()}});var rs=ue((rp,kn)=>{"use strict";var Pu=Object.prototype.hasOwnProperty,O="~";function xt(){}Object.create&&(xt.prototype=Object.create(null),new xt().__proto__||(O=!1));function Uu(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function ts(t,e,r,n,o){if(typeof r!="function")throw new TypeError("The listener must be a function");var i=new Uu(r,n||t,o),s=O?O+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 cr(t,e){--t._eventsCount===0?t._events=new xt:delete t._events[e]}function z(){this._events=new xt,this._eventsCount=0}z.prototype.eventNames=function(){var e=[],r,n;if(this._eventsCount===0)return e;for(n in r=this._events)Pu.call(r,n)&&e.push(O?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(r)):e};z.prototype.listeners=function(e){var r=O?O+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};z.prototype.listenerCount=function(e){var r=O?O+e:e,n=this._events[r];return n?n.fn?1:n.length:0};z.prototype.emit=function(e,r,n,o,i,s){var a=O?O+e:e;if(!this._events[a])return!1;var c=this._events[a],h=arguments.length,d,p;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),h){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,r),!0;case 3:return c.fn.call(c.context,r,n),!0;case 4:return c.fn.call(c.context,r,n,o),!0;case 5:return c.fn.call(c.context,r,n,o,i),!0;case 6:return c.fn.call(c.context,r,n,o,i,s),!0}for(p=1,d=new Array(h-1);p<h;p++)d[p-1]=arguments[p];c.fn.apply(c.context,d)}else{var k=c.length,u;for(p=0;p<k;p++)switch(c[p].once&&this.removeListener(e,c[p].fn,void 0,!0),h){case 1:c[p].fn.call(c[p].context);break;case 2:c[p].fn.call(c[p].context,r);break;case 3:c[p].fn.call(c[p].context,r,n);break;case 4:c[p].fn.call(c[p].context,r,n,o);break;default:if(!d)for(u=1,d=new Array(h-1);u<h;u++)d[u-1]=arguments[u];c[p].fn.apply(c[p].context,d)}}return!0};z.prototype.on=function(e,r,n){return ts(this,e,r,n,!1)};z.prototype.once=function(e,r,n){return ts(this,e,r,n,!0)};z.prototype.removeListener=function(e,r,n,o){var i=O?O+e:e;if(!this._events[i])return this;if(!r)return cr(this,i),this;var s=this._events[i];if(s.fn)s.fn===r&&(!o||s.once)&&(!n||s.context===n)&&cr(this,i);else{for(var a=0,c=[],h=s.length;a<h;a++)(s[a].fn!==r||o&&!s[a].once||n&&s[a].context!==n)&&c.push(s[a]);c.length?this._events[i]=c.length===1?c[0]:c:cr(this,i)}return this};z.prototype.removeAllListeners=function(e){var r;return e?(r=O?O+e:e,this._events[r]&&cr(this,r)):(this._events=new xt,this._eventsCount=0),this};z.prototype.off=z.prototype.removeListener;z.prototype.addListener=z.prototype.on;z.prefixed=O;z.EventEmitter=z;typeof kn<"u"&&(kn.exports=z)});var ms=ue((em,ps)=>{ps.exports=function(t){if(!t)throw Error("hashlru must have a max value, of type number, greater than 0");var e=0,r=Object.create(null),n=Object.create(null);function o(i,s){r[i]=s,e++,e>=t&&(e=0,n=r,r=Object.create(null))}return{has:function(i){return r[i]!==void 0||n[i]!==void 0},remove:function(i){r[i]!==void 0&&(r[i]=void 0),n[i]!==void 0&&(n[i]=void 0)},get:function(i){var s=r[i];if(s!==void 0)return s;if((s=n[i])!==void 0)return o(i,s),s},set:function(i,s){r[i]!==void 0?r[i]=s:o(i,s)},clear:function(){r=Object.create(null),n=Object.create(null)}}}});var ua=ue((Rt,Lr)=>{(function(t,e){"use strict";var r={version:"3.0.0",x86:{},x64:{},inputValidation:!0};function n(u){if(!Array.isArray(u)&&!ArrayBuffer.isView(u))return!1;for(var l=0;l<u.length;l++)if(!Number.isInteger(u[l])||u[l]<0||u[l]>255)return!1;return!0}function o(u,l){return(u&65535)*l+(((u>>>16)*l&65535)<<16)}function i(u,l){return u<<l|u>>>32-l}function s(u){return u^=u>>>16,u=o(u,2246822507),u^=u>>>13,u=o(u,3266489909),u^=u>>>16,u}function a(u,l){u=[u[0]>>>16,u[0]&65535,u[1]>>>16,u[1]&65535],l=[l[0]>>>16,l[0]&65535,l[1]>>>16,l[1]&65535];var m=[0,0,0,0];return m[3]+=u[3]+l[3],m[2]+=m[3]>>>16,m[3]&=65535,m[2]+=u[2]+l[2],m[1]+=m[2]>>>16,m[2]&=65535,m[1]+=u[1]+l[1],m[0]+=m[1]>>>16,m[1]&=65535,m[0]+=u[0]+l[0],m[0]&=65535,[m[0]<<16|m[1],m[2]<<16|m[3]]}function c(u,l){u=[u[0]>>>16,u[0]&65535,u[1]>>>16,u[1]&65535],l=[l[0]>>>16,l[0]&65535,l[1]>>>16,l[1]&65535];var m=[0,0,0,0];return m[3]+=u[3]*l[3],m[2]+=m[3]>>>16,m[3]&=65535,m[2]+=u[2]*l[3],m[1]+=m[2]>>>16,m[2]&=65535,m[2]+=u[3]*l[2],m[1]+=m[2]>>>16,m[2]&=65535,m[1]+=u[1]*l[3],m[0]+=m[1]>>>16,m[1]&=65535,m[1]+=u[2]*l[2],m[0]+=m[1]>>>16,m[1]&=65535,m[1]+=u[3]*l[1],m[0]+=m[1]>>>16,m[1]&=65535,m[0]+=u[0]*l[3]+u[1]*l[2]+u[2]*l[1]+u[3]*l[0],m[0]&=65535,[m[0]<<16|m[1],m[2]<<16|m[3]]}function h(u,l){return l%=64,l===32?[u[1],u[0]]:l<32?[u[0]<<l|u[1]>>>32-l,u[1]<<l|u[0]>>>32-l]:(l-=32,[u[1]<<l|u[0]>>>32-l,u[0]<<l|u[1]>>>32-l])}function d(u,l){return l%=64,l===0?u:l<32?[u[0]<<l|u[1]>>>32-l,u[1]<<l]:[u[1]<<l-32,0]}function p(u,l){return[u[0]^l[0],u[1]^l[1]]}function k(u){return u=p(u,[0,u[0]>>>1]),u=c(u,[4283543511,3981806797]),u=p(u,[0,u[0]>>>1]),u=c(u,[3301882366,444984403]),u=p(u,[0,u[0]>>>1]),u}r.x86.hash32=function(u,l){if(r.inputValidation&&!n(u))return e;l=l||0;for(var m=u.length%4,I=u.length-m,g=l,x=0,b=3432918353,v=461845907,A=0;A<I;A=A+4)x=u[A]|u[A+1]<<8|u[A+2]<<16|u[A+3]<<24,x=o(x,b),x=i(x,15),x=o(x,v),g^=x,g=i(g,13),g=o(g,5)+3864292196;switch(x=0,m){case 3:x^=u[A+2]<<16;case 2:x^=u[A+1]<<8;case 1:x^=u[A],x=o(x,b),x=i(x,15),x=o(x,v),g^=x}return g^=u.length,g=s(g),g>>>0},r.x86.hash128=function(u,l){if(r.inputValidation&&!n(u))return e;l=l||0;for(var m=u.length%16,I=u.length-m,g=l,x=l,b=l,v=l,A=0,T=0,E=0,C=0,ce=597399067,Ft=2869860233,zt=951274213,Mt=2716044179,S=0;S<I;S=S+16)A=u[S]|u[S+1]<<8|u[S+2]<<16|u[S+3]<<24,T=u[S+4]|u[S+5]<<8|u[S+6]<<16|u[S+7]<<24,E=u[S+8]|u[S+9]<<8|u[S+10]<<16|u[S+11]<<24,C=u[S+12]|u[S+13]<<8|u[S+14]<<16|u[S+15]<<24,A=o(A,ce),A=i(A,15),A=o(A,Ft),g^=A,g=i(g,19),g+=x,g=o(g,5)+1444728091,T=o(T,Ft),T=i(T,16),T=o(T,zt),x^=T,x=i(x,17),x+=b,x=o(x,5)+197830471,E=o(E,zt),E=i(E,17),E=o(E,Mt),b^=E,b=i(b,15),b+=v,b=o(b,5)+2530024501,C=o(C,Mt),C=i(C,18),C=o(C,ce),v^=C,v=i(v,13),v+=g,v=o(v,5)+850148119;switch(A=0,T=0,E=0,C=0,m){case 15:C^=u[S+14]<<16;case 14:C^=u[S+13]<<8;case 13:C^=u[S+12],C=o(C,Mt),C=i(C,18),C=o(C,ce),v^=C;case 12:E^=u[S+11]<<24;case 11:E^=u[S+10]<<16;case 10:E^=u[S+9]<<8;case 9:E^=u[S+8],E=o(E,zt),E=i(E,17),E=o(E,Mt),b^=E;case 8:T^=u[S+7]<<24;case 7:T^=u[S+6]<<16;case 6:T^=u[S+5]<<8;case 5:T^=u[S+4],T=o(T,Ft),T=i(T,16),T=o(T,zt),x^=T;case 4:A^=u[S+3]<<24;case 3:A^=u[S+2]<<16;case 2:A^=u[S+1]<<8;case 1:A^=u[S],A=o(A,ce),A=i(A,15),A=o(A,Ft),g^=A}return g^=u.length,x^=u.length,b^=u.length,v^=u.length,g+=x,g+=b,g+=v,x+=g,b+=g,v+=g,g=s(g),x=s(x),b=s(b),v=s(v),g+=x,g+=b,g+=v,x+=g,b+=g,v+=g,("00000000"+(g>>>0).toString(16)).slice(-8)+("00000000"+(x>>>0).toString(16)).slice(-8)+("00000000"+(b>>>0).toString(16)).slice(-8)+("00000000"+(v>>>0).toString(16)).slice(-8)},r.x64.hash128=function(u,l){if(r.inputValidation&&!n(u))return e;l=l||0;for(var m=u.length%16,I=u.length-m,g=[0,l],x=[0,l],b=[0,0],v=[0,0],A=[2277735313,289559509],T=[1291169091,658871167],E=0;E<I;E=E+16)b=[u[E+4]|u[E+5]<<8|u[E+6]<<16|u[E+7]<<24,u[E]|u[E+1]<<8|u[E+2]<<16|u[E+3]<<24],v=[u[E+12]|u[E+13]<<8|u[E+14]<<16|u[E+15]<<24,u[E+8]|u[E+9]<<8|u[E+10]<<16|u[E+11]<<24],b=c(b,A),b=h(b,31),b=c(b,T),g=p(g,b),g=h(g,27),g=a(g,x),g=a(c(g,[0,5]),[0,1390208809]),v=c(v,T),v=h(v,33),v=c(v,A),x=p(x,v),x=h(x,31),x=a(x,g),x=a(c(x,[0,5]),[0,944331445]);switch(b=[0,0],v=[0,0],m){case 15:v=p(v,d([0,u[E+14]],48));case 14:v=p(v,d([0,u[E+13]],40));case 13:v=p(v,d([0,u[E+12]],32));case 12:v=p(v,d([0,u[E+11]],24));case 11:v=p(v,d([0,u[E+10]],16));case 10:v=p(v,d([0,u[E+9]],8));case 9:v=p(v,[0,u[E+8]]),v=c(v,T),v=h(v,33),v=c(v,A),x=p(x,v);case 8:b=p(b,d([0,u[E+7]],56));case 7:b=p(b,d([0,u[E+6]],48));case 6:b=p(b,d([0,u[E+5]],40));case 5:b=p(b,d([0,u[E+4]],32));case 4:b=p(b,d([0,u[E+3]],24));case 3:b=p(b,d([0,u[E+2]],16));case 2:b=p(b,d([0,u[E+1]],8));case 1:b=p(b,[0,u[E]]),b=c(b,A),b=h(b,31),b=c(b,T),g=p(g,b)}return g=p(g,[0,u.length]),x=p(x,[0,u.length]),g=a(g,x),x=a(x,g),g=k(g),x=k(x),g=a(g,x),x=a(x,g),("00000000"+(g[0]>>>0).toString(16)).slice(-8)+("00000000"+(g[1]>>>0).toString(16)).slice(-8)+("00000000"+(x[0]>>>0).toString(16)).slice(-8)+("00000000"+(x[1]>>>0).toString(16)).slice(-8)},typeof Rt<"u"?(typeof Lr<"u"&&Lr.exports&&(Rt=Lr.exports=r),Rt.murmurHash3=r):typeof define=="function"&&define.amd?define([],function(){return r}):(r._murmurHash3=t.murmurHash3,r.noConflict=function(){return t.murmurHash3=r._murmurHash3,r._murmurHash3=e,r.noConflict=e,r},t.murmurHash3=r)})(Rt)});var la=ue((Pg,fa)=>{fa.exports=ua()});var ma=ue((Og,pa)=>{"use strict";pa.exports=class{constructor(){this._bitArrays=[],this._data=[],this._length=0,this._changedLength=!1,this._changedData=!1}set(e,r){let n=this._internalPositionFor(e,!1);if(r===void 0)n!==-1&&(this._unsetInternalPos(n),this._unsetBit(e),this._changedLength=!0,this._changedData=!0);else{let o=!1;n===-1?(n=this._data.length,this._setBit(e),this._changedData=!0):o=!0,this._setInternalPos(n,e,r,o),this._changedLength=!0}}unset(e){this.set(e,void 0)}get(e){this._sortData();let r=this._internalPositionFor(e,!0);if(r!==-1)return this._data[r][1]}push(e){return this.set(this.length,e),this.length}get length(){if(this._sortData(),this._changedLength){let e=this._data[this._data.length-1];this._length=e?e[0]+1:0,this._changedLength=!1}return this._length}forEach(e){let r=0;for(;r<this.length;)e(this.get(r),r,this),r++}map(e){let r=0,n=new Array(this.length);for(;r<this.length;)n[r]=e(this.get(r),r,this),r++;return n}reduce(e,r){let n=0,o=r;for(;n<this.length;){let i=this.get(n);o=e(o,i,n),n++}return o}find(e){let r=0,n,o;for(;r<this.length&&!n;)o=this.get(r),n=e(o),r++;return n?o:void 0}_internalPositionFor(e,r){let n=this._bytePosFor(e,r);if(n>=this._bitArrays.length)return-1;let o=this._bitArrays[n],i=e-n*7;if(!((o&1<<i)>0))return-1;let a=this._bitArrays.slice(0,n).reduce(il,0),c=~(4294967295<<i+1),h=da(o&c);return a+h-1}_bytePosFor(e,r){let n=Math.floor(e/7),o=n+1;for(;!r&&this._bitArrays.length<o;)this._bitArrays.push(0);return n}_setBit(e){let r=this._bytePosFor(e,!1);this._bitArrays[r]|=1<<e-r*7}_unsetBit(e){let r=this._bytePosFor(e,!1);this._bitArrays[r]&=~(1<<e-r*7)}_setInternalPos(e,r,n,o){let i=this._data,s=[r,n];if(o)this._sortData(),i[e]=s;else{if(i.length)if(i[i.length-1][0]>=r)i.push(s);else if(i[0][0]<=r)i.unshift(s);else{let a=Math.round(i.length/2);this._data=i.slice(0,a).concat(s).concat(i.slice(a))}else this._data.push(s);this._changedData=!0,this._changedLength=!0}}_unsetInternalPos(e){this._data.splice(e,1)}_sortData(){this._changedData&&this._data.sort(sl),this._changedData=!1}bitField(){let e=[],r=8,n=0,o=0,i,s=this._bitArrays.slice();for(;s.length||n;){n===0&&(i=s.shift(),n=7);let c=Math.min(n,r),h=~(255<<c),d=i&h;o|=d<<8-r,i=i>>>c,n-=c,r-=c,(!r||!n&&!s.length)&&(e.push(o),o=0,r=8)}for(var a=e.length-1;a>0&&e[a]===0;a--)e.pop();return e}compactArray(){return this._sortData(),this._data.map(al)}};function il(t,e){return t+da(e)}function da(t){let e=t;return e=e-(e>>1&1431655765),e=(e&858993459)+(e>>2&858993459),(e+(e>>4)&252645135)*16843009>>24}function sl(t,e){return t[0]-e[0]}function al(t){return t[1]}});var Sl={};V(Sl,{BlockExporter:()=>xo,CIDPath:()=>Eo,GraphSearch:()=>bo,SubgraphExporter:()=>Lt,UnixFSExporter:()=>Pt,UnixFSPath:()=>ko,car:()=>Tl});var Fa=["string","number","bigint","symbol"],za=["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 Ao(t){if(t===null)return"null";if(t===void 0)return"undefined";if(t===!0||t===!1)return"boolean";let e=typeof t;if(Fa.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(t))return"Array";if(Ma(t))return"Buffer";let r=$a(t);return r||"Object"}function Ma(t){return t&&t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer.call(null,t)}function $a(t){let e=Object.prototype.toString.call(t).slice(8,-1);if(za.includes(e))return e}var f=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}};f.uint=new f(0,"uint",!0);f.negint=new f(1,"negint",!0);f.bytes=new f(2,"bytes",!0);f.string=new f(3,"string",!0);f.array=new f(4,"array",!1);f.map=new f(5,"map",!1);f.tag=new f(6,"tag",!1);f.float=new f(7,"float",!0);f.false=new f(7,"false",!0);f.true=new f(7,"true",!0);f.null=new f(7,"null",!0);f.undefined=new f(7,"undefined",!0);f.break=new f(7,"break",!0);var y=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 Ce=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Oa=new TextDecoder,Ha=new TextEncoder;function Ot(t){return Ce&&globalThis.Buffer.isBuffer(t)}function rt(t){return t instanceof Uint8Array?Ot(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t:Uint8Array.from(t)}var Bo=Ce?(t,e,r)=>r-e>64?globalThis.Buffer.from(t.subarray(e,r)).toString("utf8"):To(t,e,r):(t,e,r)=>r-e>64?Oa.decode(t.subarray(e,r)):To(t,e,r),Ht=Ce?t=>t.length>64?globalThis.Buffer.from(t):Io(t):t=>t.length>64?Ha.encode(t):Io(t),ne=t=>Uint8Array.from(t),De=Ce?(t,e,r)=>Ot(t)?new Uint8Array(t.subarray(e,r)):t.slice(e,r):(t,e,r)=>t.slice(e,r),No=Ce?(t,e)=>(t=t.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),rt(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},Co=Ce?t=>globalThis.Buffer.allocUnsafe(t):t=>new Uint8Array(t);function Do(t,e){if(Ot(t)&&Ot(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 Io(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 To(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 a,c,h,d;switch(s){case 1:o<128&&(i=o);break;case 2:a=t[e+1],(a&192)===128&&(d=(o&31)<<6|a&63,d>127&&(i=d));break;case 3:a=t[e+1],c=t[e+2],(a&192)===128&&(c&192)===128&&(d=(o&15)<<12|(a&63)<<6|c&63,d>2047&&(d<55296||d>57343)&&(i=d));break;case 4:a=t[e+1],c=t[e+2],h=t[e+3],(a&192)===128&&(c&192)===128&&(h&192)===128&&(d=(o&15)<<18|(a&63)<<12|(c&63)<<6|h&63,d>65535&&d<1114112&&(i=d))}}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 zr(n)}var So=4096;function zr(t){let e=t.length;if(e<=So)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=So));return r}var Va=256,nt=class{constructor(e=Va){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=Co(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=De(n,0,this.cursor)}else r=No(this.chunks,this.cursor);return e&&this.reset(),r}};var _="CBOR decode error:",Le="CBOR encode error:",ot=[];ot[23]=1;ot[24]=2;ot[25]=3;ot[26]=5;ot[27]=9;function fe(t,e,r){if(t.length-e<r)throw new Error(`${_} not enough data for type`)}var U=[24,256,65536,4294967296,BigInt("18446744073709551616")];function q(t,e,r){fe(t,e,1);let n=t[e];if(r.strict===!0&&n<U[0])throw new Error(`${_} integer encoded in more bytes than necessary (strict decode)`);return n}function G(t,e,r){fe(t,e,2);let n=t[e]<<8|t[e+1];if(r.strict===!0&&n<U[1])throw new Error(`${_} integer encoded in more bytes than necessary (strict decode)`);return n}function j(t,e,r){fe(t,e,4);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3];if(r.strict===!0&&n<U[2])throw new Error(`${_} integer encoded in more bytes than necessary (strict decode)`);return n}function W(t,e,r){fe(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<U[3])throw new Error(`${_} 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(`${_} integers outside of the safe integer range are not supported`)}function Lo(t,e,r,n){return new y(f.uint,q(t,e+1,n),2)}function Po(t,e,r,n){return new y(f.uint,G(t,e+1,n),3)}function Uo(t,e,r,n){return new y(f.uint,j(t,e+1,n),5)}function Ro(t,e,r,n){return new y(f.uint,W(t,e+1,n),9)}function X(t,e){return F(t,0,e.value)}function F(t,e,r){if(r<U[0]){let n=Number(r);t.push([e|n])}else if(r<U[1]){let n=Number(r);t.push([e|24,n])}else if(r<U[2]){let n=Number(r);t.push([e|25,n>>>8,n&255])}else if(r<U[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<U[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(`${_} encountered BigInt larger than allowable range`)}}X.encodedSize=function(e){return F.encodedSize(e.value)};F.encodedSize=function(e){return e<U[0]?1:e<U[1]?2:e<U[2]?3:e<U[3]?5:9};X.compareTokens=function(e,r){return e.value<r.value?-1:e.value>r.value?1:0};function Fo(t,e,r,n){return new y(f.negint,-1-q(t,e+1,n),2)}function zo(t,e,r,n){return new y(f.negint,-1-G(t,e+1,n),3)}function Mo(t,e,r,n){return new y(f.negint,-1-j(t,e+1,n),5)}var Mr=BigInt(-1),$o=BigInt(1);function Oo(t,e,r,n){let o=W(t,e+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new y(f.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${_} integers outside of the safe integer range are not supported`);return new y(f.negint,Mr-BigInt(o),9)}function Vt(t,e){let r=e.value,n=typeof r=="bigint"?r*Mr-$o:r*-1-1;F(t,e.type.majorEncoded,n)}Vt.encodedSize=function(e){let r=e.value,n=typeof r=="bigint"?r*Mr-$o:r*-1-1;return n<U[0]?1:n<U[1]?2:n<U[2]?3:n<U[3]?5:9};Vt.compareTokens=function(e,r){return e.value<r.value?1:e.value>r.value?-1:0};function it(t,e,r,n){fe(t,e,r+n);let o=De(t,e+r,e+r+n);return new y(f.bytes,o,r+n)}function Ho(t,e,r,n){return it(t,e,1,r)}function Vo(t,e,r,n){return it(t,e,2,q(t,e+1,n))}function qo(t,e,r,n){return it(t,e,3,G(t,e+1,n))}function Go(t,e,r,n){return it(t,e,5,j(t,e+1,n))}function jo(t,e,r,n){let o=W(t,e+1,n);if(typeof o=="bigint")throw new Error(`${_} 64-bit integer bytes lengths not supported`);return it(t,e,9,o)}function qt(t){return t.encodedBytes===void 0&&(t.encodedBytes=t.type===f.string?Ht(t.value):t.value),t.encodedBytes}function Pe(t,e){let r=qt(e);F(t,e.type.majorEncoded,r.length),t.push(r)}Pe.encodedSize=function(e){let r=qt(e);return F.encodedSize(r.length)+r.length};Pe.compareTokens=function(e,r){return Ga(qt(e),qt(r))};function Ga(t,e){return t.length<e.length?-1:t.length>e.length?1:Do(t,e)}function st(t,e,r,n,o){let i=r+n;fe(t,e,i);let s=new y(f.string,Bo(t,e+r,e+i),i);return o.retainStringBytes===!0&&(s.byteValue=De(t,e+r,e+i)),s}function Wo(t,e,r,n){return st(t,e,1,r,n)}function Jo(t,e,r,n){return st(t,e,2,q(t,e+1,n),n)}function Xo(t,e,r,n){return st(t,e,3,G(t,e+1,n),n)}function Qo(t,e,r,n){return st(t,e,5,j(t,e+1,n),n)}function Ko(t,e,r,n){let o=W(t,e+1,n);if(typeof o=="bigint")throw new Error(`${_} 64-bit integer string lengths not supported`);return st(t,e,9,o,n)}var Yo=Pe;function Ue(t,e,r,n){return new y(f.array,n,r)}function Zo(t,e,r,n){return Ue(t,e,1,r)}function ei(t,e,r,n){return Ue(t,e,2,q(t,e+1,n))}function ti(t,e,r,n){return Ue(t,e,3,G(t,e+1,n))}function ri(t,e,r,n){return Ue(t,e,5,j(t,e+1,n))}function ni(t,e,r,n){let o=W(t,e+1,n);if(typeof o=="bigint")throw new Error(`${_} 64-bit integer array lengths not supported`);return Ue(t,e,9,o)}function oi(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${_} indefinite length items not allowed`);return Ue(t,e,1,1/0)}function Gt(t,e){F(t,f.array.majorEncoded,e.value)}Gt.compareTokens=X.compareTokens;Gt.encodedSize=function(e){return F.encodedSize(e.value)};function Re(t,e,r,n){return new y(f.map,n,r)}function ii(t,e,r,n){return Re(t,e,1,r)}function si(t,e,r,n){return Re(t,e,2,q(t,e+1,n))}function ai(t,e,r,n){return Re(t,e,3,G(t,e+1,n))}function ci(t,e,r,n){return Re(t,e,5,j(t,e+1,n))}function ui(t,e,r,n){let o=W(t,e+1,n);if(typeof o=="bigint")throw new Error(`${_} 64-bit integer map lengths not supported`);return Re(t,e,9,o)}function fi(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${_} indefinite length items not allowed`);return Re(t,e,1,1/0)}function jt(t,e){F(t,f.map.majorEncoded,e.value)}jt.compareTokens=X.compareTokens;jt.encodedSize=function(e){return F.encodedSize(e.value)};function li(t,e,r,n){return new y(f.tag,r,1)}function hi(t,e,r,n){return new y(f.tag,q(t,e+1,n),2)}function di(t,e,r,n){return new y(f.tag,G(t,e+1,n),3)}function pi(t,e,r,n){return new y(f.tag,j(t,e+1,n),5)}function mi(t,e,r,n){return new y(f.tag,W(t,e+1,n),9)}function Wt(t,e){F(t,f.tag.majorEncoded,e.value)}Wt.compareTokens=X.compareTokens;Wt.encodedSize=function(e){return F.encodedSize(e.value)};var Ka=20,Ya=21,Za=22,ec=23;function yi(t,e,r,n){if(n.allowUndefined===!1)throw new Error(`${_} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new y(f.null,null,1):new y(f.undefined,void 0,1)}function gi(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${_} indefinite length items not allowed`);return new y(f.break,void 0,1)}function $r(t,e,r){if(r){if(r.allowNaN===!1&&Number.isNaN(t))throw new Error(`${_} NaN values are not supported`);if(r.allowInfinity===!1&&(t===1/0||t===-1/0))throw new Error(`${_} Infinity values are not supported`)}return new y(f.float,t,e)}function wi(t,e,r,n){return $r(Or(t,e+1),3,n)}function xi(t,e,r,n){return $r(Hr(t,e+1),5,n)}function bi(t,e,r,n){return $r(_i(t,e+1),9,n)}function Jt(t,e,r){let n=e.value;if(n===!1)t.push([f.float.majorEncoded|Ka]);else if(n===!0)t.push([f.float.majorEncoded|Ya]);else if(n===null)t.push([f.float.majorEncoded|Za]);else if(n===void 0)t.push([f.float.majorEncoded|ec]);else{let o,i=!1;(!r||r.float64!==!0)&&(vi(n),o=Or(K,1),n===o||Number.isNaN(n)?(K[0]=249,t.push(K.slice(0,3)),i=!0):(ki(n),o=Hr(K,1),n===o&&(K[0]=250,t.push(K.slice(0,5)),i=!0))),i||(tc(n),o=_i(K,1),K[0]=251,t.push(K.slice(0,9)))}}Jt.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){vi(n);let o=Or(K,1);if(n===o||Number.isNaN(n))return 3;if(ki(n),o=Hr(K,1),n===o)return 5}return 9};var Ei=new ArrayBuffer(9),Q=new DataView(Ei,1),K=new Uint8Array(Ei,0);function vi(t){if(t===1/0)Q.setUint16(0,31744,!1);else if(t===-1/0)Q.setUint16(0,64512,!1);else if(Number.isNaN(t))Q.setUint16(0,32256,!1);else{Q.setFloat32(0,t);let e=Q.getUint32(0),r=(e&2139095040)>>23,n=e&8388607;if(r===255)Q.setUint16(0,31744,!1);else if(r===0)Q.setUint16(0,(t&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?Q.setUint16(0,0):o<-14?Q.setUint16(0,(e&2147483648)>>16|1<<24+o,!1):Q.setUint16(0,(e&2147483648)>>16|o+15<<10|n>>13,!1)}}}function Or(t,e){if(t.length-e<2)throw new Error(`${_} 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 ki(t){Q.setFloat32(0,t,!1)}function Hr(t,e){if(t.length-e<4)throw new Error(`${_} not enough data for float32`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,4).getFloat32(0,!1)}function tc(t){Q.setFloat64(0,t,!1)}function _i(t,e){if(t.length-e<8)throw new Error(`${_} not enough data for float64`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,8).getFloat64(0,!1)}Jt.compareTokens=X.compareTokens;function B(t,e,r){throw new Error(`${_} encountered invalid minor (${r}) for major ${t[e]>>>5}`)}function Xt(t){return()=>{throw new Error(`${_} ${t}`)}}var w=[];for(let t=0;t<=23;t++)w[t]=B;w[24]=Lo;w[25]=Po;w[26]=Uo;w[27]=Ro;w[28]=B;w[29]=B;w[30]=B;w[31]=B;for(let t=32;t<=55;t++)w[t]=B;w[56]=Fo;w[57]=zo;w[58]=Mo;w[59]=Oo;w[60]=B;w[61]=B;w[62]=B;w[63]=B;for(let t=64;t<=87;t++)w[t]=Ho;w[88]=Vo;w[89]=qo;w[90]=Go;w[91]=jo;w[92]=B;w[93]=B;w[94]=B;w[95]=Xt("indefinite length bytes/strings are not supported");for(let t=96;t<=119;t++)w[t]=Wo;w[120]=Jo;w[121]=Xo;w[122]=Qo;w[123]=Ko;w[124]=B;w[125]=B;w[126]=B;w[127]=Xt("indefinite length bytes/strings are not supported");for(let t=128;t<=151;t++)w[t]=Zo;w[152]=ei;w[153]=ti;w[154]=ri;w[155]=ni;w[156]=B;w[157]=B;w[158]=B;w[159]=oi;for(let t=160;t<=183;t++)w[t]=ii;w[184]=si;w[185]=ai;w[186]=ci;w[187]=ui;w[188]=B;w[189]=B;w[190]=B;w[191]=fi;for(let t=192;t<=215;t++)w[t]=li;w[216]=hi;w[217]=di;w[218]=pi;w[219]=mi;w[220]=B;w[221]=B;w[222]=B;w[223]=B;for(let t=224;t<=243;t++)w[t]=Xt("simple values are not supported");w[244]=B;w[245]=B;w[246]=B;w[247]=yi;w[248]=Xt("simple values are not supported");w[249]=wi;w[250]=xi;w[251]=bi;w[252]=B;w[253]=B;w[254]=B;w[255]=gi;var Y=[];for(let t=0;t<24;t++)Y[t]=new y(f.uint,t,1);for(let t=-1;t>=-24;t--)Y[31-t]=new y(f.negint,t,1);Y[64]=new y(f.bytes,new Uint8Array(0),1);Y[96]=new y(f.string,"",1);Y[128]=new y(f.array,0,1);Y[160]=new y(f.map,0,1);Y[244]=new y(f.false,!1,1);Y[245]=new y(f.true,!0,1);Y[246]=new y(f.null,null,1);function Vr(t){switch(t.type){case f.false:return ne([244]);case f.true:return ne([245]);case f.null:return ne([246]);case f.bytes:return t.value.length?void 0:ne([64]);case f.string:return t.value===""?ne([96]):void 0;case f.array:return t.value===0?ne([128]):void 0;case f.map:return t.value===0?ne([160]):void 0;case f.uint:return t.value<24?ne([Number(t.value)]):void 0;case f.negint:if(t.value>=-24)return ne([31-Number(t.value)])}}var nc={float64:!1,mapSorter:ic,quickEncodeToken:Vr};function Gr(){let t=[];return t[f.uint.major]=X,t[f.negint.major]=Vt,t[f.bytes.major]=Pe,t[f.string.major]=Yo,t[f.array.major]=Gt,t[f.map.major]=jt,t[f.tag.major]=Wt,t[f.float.major]=Jt,t}var Ai=Gr(),qr=new nt,Qt=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(`${Le} object contains circular references`);return new t(r,e)}},he={null:new y(f.null,null),undefined:new y(f.undefined,void 0),true:new y(f.true,!0),false:new y(f.false,!1),emptyArray:new y(f.array,0),emptyMap:new y(f.map,0)},de={number(t,e,r,n){return!Number.isInteger(t)||!Number.isSafeInteger(t)?new y(f.float,t):t>=0?new y(f.uint,t):new y(f.negint,t)},bigint(t,e,r,n){return t>=BigInt(0)?new y(f.uint,t):new y(f.negint,t)},Uint8Array(t,e,r,n){return new y(f.bytes,t)},string(t,e,r,n){return new y(f.string,t)},boolean(t,e,r,n){return t?he.true:he.false},null(t,e,r,n){return he.null},undefined(t,e,r,n){return he.undefined},ArrayBuffer(t,e,r,n){return new y(f.bytes,new Uint8Array(t))},DataView(t,e,r,n){return new y(f.bytes,new Uint8Array(t.buffer,t.byteOffset,t.byteLength))},Array(t,e,r,n){if(!t.length)return r.addBreakTokens===!0?[he.emptyArray,new y(f.break)]:he.emptyArray;n=Qt.createCheck(n,t);let o=[],i=0;for(let s of t)o[i++]=at(s,r,n);return r.addBreakTokens?[new y(f.array,t.length),o,new y(f.break)]:[new y(f.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?[he.emptyMap,new y(f.break)]:he.emptyMap;n=Qt.createCheck(n,t);let a=[],c=0;for(let h of i)a[c++]=[at(h,r,n),at(o?t.get(h):t[h],r,n)];return oc(a,r),r.addBreakTokens?[new y(f.map,s),a,new y(f.break)]:[new y(f.map,s),a]}};de.Map=de.Object;de.Buffer=de.Uint8Array;for(let t of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))de[`${t}Array`]=de.DataView;function at(t,e={},r){let n=Ao(t),o=e&&e.typeEncoders&&e.typeEncoders[n]||de[n];if(typeof o=="function"){let s=o(t,n,e,r);if(s!=null)return s}let i=de[n];if(!i)throw new Error(`${Le} unsupported type: ${n}`);return i(t,n,e,r)}function oc(t,e){e.mapSorter&&t.sort(e.mapSorter)}function ic(t,e){let r=Array.isArray(t[0])?t[0][0]:t[0],n=Array.isArray(e[0])?e[0][0]:e[0];if(r.type!==n.type)return r.type.compare(n.type);let o=r.type.major,i=Ai[o].compareTokens(r,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function Ii(t,e,r,n){if(Array.isArray(e))for(let o of e)Ii(t,o,r,n);else r[e.type.major](t,e,n)}function Ti(t,e,r){let n=at(t,r);if(!Array.isArray(n)&&r.quickEncodeToken){let o=r.quickEncodeToken(n);if(o)return o;let i=e[n.type.major];if(i.encodedSize){let s=i.encodedSize(n,r),a=new nt(s);if(i(a,n,r),a.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return rt(a.chunks[0])}}return qr.reset(),Ii(qr,n,e,r),qr.toBytes(!0)}function jr(t,e){return e=Object.assign({},nc,e),Ti(t,Ai,e)}var sc={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Kt=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=Y[e];if(r===void 0){let n=w[e];if(!n)throw new Error(`${_} 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}},ct=Symbol.for("DONE"),Yt=Symbol.for("BREAK");function ac(t,e,r){let n=[];for(let o=0;o<t.value;o++){let i=Fe(e,r);if(i===Yt){if(t.value===1/0)break;throw new Error(`${_} got unexpected break to lengthed array`)}if(i===ct)throw new Error(`${_} found array but not enough entries (got ${o}, expected ${t.value})`);n[o]=i}return n}function cc(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 a=Fe(e,r);if(a===Yt){if(t.value===1/0)break;throw new Error(`${_} got unexpected break to lengthed map`)}if(a===ct)throw new Error(`${_} found map but not enough entries (got ${s} [no key], expected ${t.value})`);if(n!==!0&&typeof a!="string")throw new Error(`${_} non-string keys not supported (got ${typeof a})`);if(r.rejectDuplicateMapKeys===!0&&(n&&i.has(a)||!n&&a in o))throw new Error(`${_} found repeat map key "${a}"`);let c=Fe(e,r);if(c===ct)throw new Error(`${_} found map but not enough entries (got ${s} [no value], expected ${t.value})`);n?i.set(a,c):o[a]=c}return n?i:o}function Fe(t,e){if(t.done())return ct;let r=t.next();if(r.type===f.break)return Yt;if(r.type.terminal)return r.value;if(r.type===f.array)return ac(r,t,e);if(r.type===f.map)return cc(r,t,e);if(r.type===f.tag){if(e.tags&&typeof e.tags[r.value]=="function"){let n=Fe(t,e);return e.tags[r.value](n)}throw new Error(`${_} tag not supported (${r.value})`)}throw new Error("unsupported")}function Wr(t,e){if(!(t instanceof Uint8Array))throw new Error(`${_} data to decode must be a Uint8Array`);e=Object.assign({},sc,e);let r=e.tokenizer||new Kt(t,e),n=Fe(r,e);if(n===ct)throw new Error(`${_} did not find any content to decode`);if(n===Yt)throw new Error(`${_} got unexpected break`);return[n,t.subarray(r.pos())]}function ut(t,e){let[r,n]=Wr(t,e);if(n.length>0)throw new Error(`${_} too many terminals, data makes no sense`);return r}var tn={};V(tn,{base32:()=>Me,base32hex:()=>vc,base32hexpad:()=>_c,base32hexpadupper:()=>Ac,base32hexupper:()=>kc,base32pad:()=>bc,base32padupper:()=>Ec,base32upper:()=>xc,base32z:()=>Ic});var ke={};V(ke,{coerce:()=>oe,empty:()=>Si,equals:()=>Jr,fromHex:()=>lc,fromString:()=>Xr,isBinary:()=>hc,toHex:()=>fc,toString:()=>Qr});var Si=new Uint8Array(0);function fc(t){return t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")}function lc(t){let e=t.match(/../g);return e!=null?new Uint8Array(e.map(r=>parseInt(r,16))):Si}function Jr(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 oe(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 hc(t){return t instanceof ArrayBuffer||ArrayBuffer.isView(t)}function Xr(t){return new TextEncoder().encode(t)}function Qr(t){return new TextDecoder().decode(t)}function dc(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 a=t.length,c=t.charAt(0),h=Math.log(a)/Math.log(256),d=Math.log(256)/Math.log(a);function p(l){if(l instanceof Uint8Array||(ArrayBuffer.isView(l)?l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):Array.isArray(l)&&(l=Uint8Array.from(l))),!(l instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(l.length===0)return"";for(var m=0,I=0,g=0,x=l.length;g!==x&&l[g]===0;)g++,m++;for(var b=(x-g)*d+1>>>0,v=new Uint8Array(b);g!==x;){for(var A=l[g],T=0,E=b-1;(A!==0||T<I)&&E!==-1;E--,T++)A+=256*v[E]>>>0,v[E]=A%a>>>0,A=A/a>>>0;if(A!==0)throw new Error("Non-zero carry");I=T,g++}for(var C=b-I;C!==b&&v[C]===0;)C++;for(var ce=c.repeat(m);C<b;++C)ce+=t.charAt(v[C]);return ce}function k(l){if(typeof l!="string")throw new TypeError("Expected String");if(l.length===0)return new Uint8Array;var m=0;if(l[m]!==" "){for(var I=0,g=0;l[m]===c;)I++,m++;for(var x=(l.length-m)*h+1>>>0,b=new Uint8Array(x);l[m];){var v=r[l.charCodeAt(m)];if(v===255)return;for(var A=0,T=x-1;(v!==0||A<g)&&T!==-1;T--,A++)v+=a*b[T]>>>0,b[T]=v%256>>>0,v=v/256>>>0;if(v!==0)throw new Error("Non-zero carry");g=A,m++}if(l[m]!==" "){for(var E=x-g;E!==x&&b[E]===0;)E++;for(var C=new Uint8Array(I+(x-E)),ce=I;E!==x;)C[ce++]=b[E++];return C}}}function u(l){var m=k(l);if(m)return m;throw new Error(`Non-${e} character`)}return{encode:p,decodeUnsafe:k,decode:u}}var pc=dc,mc=pc,Bi=mc;var Kr=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")}},Yr=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,r,n){this.name=e,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(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 Ni(this,e)}},Zr=class{decoders;constructor(e){this.decoders=e}or(e){return Ni(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 Ni(t,e){return new Zr({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var en=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 Kr(e,r,n),this.decoder=new Yr(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function ze({name:t,prefix:e,encode:r,decode:n}){return new en(t,e,r,n)}function pe({name:t,prefix:e,alphabet:r}){let{encode:n,decode:o}=Bi(r,t);return ze({prefix:e,name:t,encode:n,decode:i=>oe(o(i))})}function yc(t,e,r,n){let o=t.length;for(;t[o-1]==="=";)--o;let i=new Uint8Array(o*r/8|0),s=0,a=0,c=0;for(let h=0;h<o;++h){let d=e[t[h]];if(d===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<r|d,s+=r,s>=8&&(s-=8,i[c++]=255&a>>s)}if(s>=r||(255&a<<8-s)!==0)throw new SyntaxError("Unexpected end of data");return i}function gc(t,e,r){let n=e[e.length-1]==="=",o=(1<<r)-1,i="",s=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],s+=8;s>r;)s-=r,i+=e[o&a>>s];if(s!==0&&(i+=e[o&a<<r-s]),n)for(;(i.length*r&7)!==0;)i+="=";return i}function wc(t){let e={};for(let r=0;r<t.length;++r)e[t[r]]=r;return e}function L({name:t,prefix:e,bitsPerChar:r,alphabet:n}){let o=wc(n);return ze({prefix:e,name:t,encode(i){return gc(i,n,r)},decode(i){return yc(i,o,r,t)}})}var Me=L({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),xc=L({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),bc=L({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ec=L({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),vc=L({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),kc=L({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),_c=L({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ac=L({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ic=L({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var rn={};V(rn,{base36:()=>ft,base36upper:()=>Tc});var ft=pe({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Tc=pe({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var nn={};V(nn,{base58btc:()=>ie,base58flickr:()=>Sc});var ie=pe({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Sc=pe({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Bc=Li,Ci=128,Nc=127,Cc=~Nc,Dc=Math.pow(2,31);function Li(t,e,r){e=e||[],r=r||0;for(var n=r;t>=Dc;)e[r++]=t&255|Ci,t/=128;for(;t&Cc;)e[r++]=t&255|Ci,t>>>=7;return e[r]=t|0,Li.bytes=r-n+1,e}var Lc=on,Pc=128,Di=127;function on(t,n){var r=0,n=n||0,o=0,i=n,s,a=t.length;do{if(i>=a)throw on.bytes=0,new RangeError("Could not decode varint");s=t[i++],r+=o<28?(s&Di)<<o:(s&Di)*Math.pow(2,o),o+=7}while(s>=Pc);return on.bytes=i-n,r}var Uc=Math.pow(2,7),Rc=Math.pow(2,14),Fc=Math.pow(2,21),zc=Math.pow(2,28),Mc=Math.pow(2,35),$c=Math.pow(2,42),Oc=Math.pow(2,49),Hc=Math.pow(2,56),Vc=Math.pow(2,63),qc=function(t){return t<Uc?1:t<Rc?2:t<Fc?3:t<zc?4:t<Mc?5:t<$c?6:t<Oc?7:t<Hc?8:t<Vc?9:10},Gc={encode:Bc,decode:Lc,encodingLength:qc},jc=Gc,lt=jc;function ht(t,e=0){return[lt.decode(t,e),lt.decode.bytes]}function $e(t,e,r=0){return lt.encode(t,e,r),e}function Oe(t){return lt.encodingLength(t)}function Ve(t,e){let r=e.byteLength,n=Oe(t),o=n+Oe(r),i=new Uint8Array(o+r);return $e(t,i,0),$e(r,i,n),i.set(e,o),new He(t,r,e,i)}function qe(t){let e=oe(t),[r,n]=ht(e),[o,i]=ht(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new He(r,o,s,e)}function Pi(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&Jr(t.bytes,r.bytes)}}var He=class{code;size;digest;bytes;constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};function Ui(t,e){let{bytes:r,version:n}=t;switch(n){case 0:return Jc(r,sn(t),e??ie.encoder);default:return Xc(r,sn(t),e??Me.encoder)}}var Ri=new WeakMap;function sn(t){let e=Ri.get(t);if(e==null){let r=new Map;return Ri.set(t,r),r}return e}var N=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!==dt)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Qc)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=Ve(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&&Pi(e.multihash,n.multihash)}toString(e){return Ui(this,e)}toJSON(){return{"/":Ui(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:s}=r;return new t(n,o,i,s??Fi(n,o,i.bytes))}else if(r[Kc]===!0){let{version:n,multihash:o,code:i}=r,s=qe(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!==dt)throw new Error(`Version 0 CID must use dag-pb (code: ${dt}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=Fi(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,dt,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=oe(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 He(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[p,k]=ht(e.subarray(r));return r+=k,p},o=n(),i=dt;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,a=n(),c=n(),h=r+c,d=h-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:d,size:h}}static parse(e,r){let[n,o]=Wc(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 sn(i).set(n,e),i}};function Wc(t,e){switch(t[0]){case"Q":{let r=e??ie;return[ie.prefix,r.decode(`${ie.prefix}${t}`)]}case ie.prefix:{let r=e??ie;return[ie.prefix,r.decode(t)]}case Me.prefix:{let r=e??Me;return[Me.prefix,r.decode(t)]}case ft.prefix:{let r=e??ft;return[ft.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}}function Jc(t,e,r){let{prefix:n}=r;if(n!==ie.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 Xc(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 dt=112,Qc=18;function Fi(t,e,r){let n=Oe(t),o=n+Oe(e),i=new Uint8Array(o+r.byteLength);return $e(t,i,0),$e(e,i,n),i.set(r,o),i}var Kc=Symbol.for("@ipld/js-cid/CID");var zi=42;function Yc(t){return t instanceof ArrayBuffer?new Uint8Array(t,0,t.byteLength):t}function Zc(t){if(t.asCID!==t&&t["/"]!==t.bytes)return null;let e=N.asCID(t);if(!e)return null;let r=new Uint8Array(e.bytes.byteLength+1);return r.set(e.bytes,1),[new y(f.tag,zi),new y(f.bytes,r)]}function eu(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function tu(t){if(Number.isNaN(t))throw new Error("`NaN` is not supported by the IPLD Data Model and cannot be encoded");if(t===1/0||t===-1/0)throw new Error("`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded");return null}function ru(t){for(let e of t.keys())if(typeof e!="string"||e.length===0)throw new Error("Non-string Map keys are not supported by the IPLD Data Model and cannot be encoded");return null}var an={float64:!0,typeEncoders:{Map:ru,Object:Zc,undefined:eu,number:tu}},qh={...an,typeEncoders:{...an.typeEncoders}};function nu(t){if(t[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return N.decode(t.subarray(1))}var er={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:[]};er.tags[zi]=nu;var Gh={...er,tags:er.tags.slice()};var Mi=113,cn=t=>jr(t,an),pt=t=>ut(Yc(t),er);var hn=Ee(tr(),1);var dn=40;function pn(t,e){if(!t.length)throw new Error("Unexpected end of data");let r=hn.default.decode(t);return e.seek(hn.default.decode.bytes),r}function mn(t){let e=new DataView(t.buffer,t.byteOffset,t.byteLength),r=0;return{version:2,characteristics:[e.getBigUint64(r,!0),e.getBigUint64(r+=8,!0)],dataOffset:Number(e.getBigUint64(r+=8,!0)),dataSize:Number(e.getBigUint64(r+=8,!0)),indexOffset:Number(e.getBigUint64(r+=8,!0))}}var ye={Null:t=>t===null?t:void 0,Int:t=>Number.isInteger(t)?t:void 0,Float:t=>typeof t=="number"&&Number.isFinite(t)?t:void 0,String:t=>typeof t=="string"?t:void 0,Bool:t=>typeof t=="boolean"?t:void 0,Bytes:t=>t instanceof Uint8Array?t:void 0,Link:t=>t!==null&&typeof t=="object"&&t.asCID===t?t:void 0,List:t=>Array.isArray(t)?t:void 0,Map:t=>t!==null&&typeof t=="object"&&t.asCID!==t&&!Array.isArray(t)&&!(t instanceof Uint8Array)?t:void 0},mt={"CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)":ye.Link,"CarV1HeaderOrV2Pragma > roots (anon)":t=>{if(ye.List(t)!==void 0){for(let e=0;e<t.length;e++){let r=t[e];if(r=mt["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](r),r===void 0)return;if(r!==t[e]){let n=t.slice(0,e);for(let o=e;o<t.length;o++){let i=t[o];if(i=mt["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](i),i===void 0)return;n.push(i)}return n}}return t}},Int:ye.Int,CarV1HeaderOrV2Pragma:t=>{if(ye.Map(t)===void 0)return;let e=Object.entries(t),r=t,n=1;for(let o=0;o<e.length;o++){let[i,s]=e[o];switch(i){case"roots":{let a=mt["CarV1HeaderOrV2Pragma > roots (anon)"](t[i]);if(a===void 0)return;if(a!==s||r!==t){if(r===t){r={};for(let c=0;c<o;c++)r[e[c][0]]=e[c][1]}r.roots=a}}break;case"version":{n--;let a=mt.Int(t[i]);if(a===void 0)return;if(a!==s||r!==t){if(r===t){r={};for(let c=0;c<o;c++)r[e[c][0]]=e[c][1]}r.version=a}}break;default:return}}if(!(n>0))return r}},yt={"CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)":ye.Link,"CarV1HeaderOrV2Pragma > roots (anon)":t=>{if(ye.List(t)!==void 0){for(let e=0;e<t.length;e++){let r=t[e];if(r=yt["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](r),r===void 0)return;if(r!==t[e]){let n=t.slice(0,e);for(let o=e;o<t.length;o++){let i=t[o];if(i=yt["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](i),i===void 0)return;n.push(i)}return n}}return t}},Int:ye.Int,CarV1HeaderOrV2Pragma:t=>{if(ye.Map(t)===void 0)return;let e=Object.entries(t),r=t,n=1;for(let o=0;o<e.length;o++){let[i,s]=e[o];switch(i){case"roots":{let a=yt["CarV1HeaderOrV2Pragma > roots (anon)"](s);if(a===void 0)return;if(a!==s||r!==t){if(r===t){r={};for(let c=0;c<o;c++)r[e[c][0]]=e[c][1]}r.roots=a}}break;case"version":{n--;let a=yt.Int(s);if(a===void 0)return;if(a!==s||r!==t){if(r===t){r={};for(let c=0;c<o;c++)r[e[c][0]]=e[c][1]}r.version=a}}break;default:return}}if(!(n>0))return r}},yn={toTyped:mt.CarV1HeaderOrV2Pragma,toRepresentation:yt.CarV1HeaderOrV2Pragma};var sd=Gr();var bu=Ee(tr(),1);var ld=[new y(f.map,2),new y(f.string,"version"),new y(f.uint,1),new y(f.string,"roots")],hd=new y(f.tag,42);async function gn(t,e){let r=pn(await t.upTo(8),t);if(r===0)throw new Error("Invalid CAR header (zero length)");let n=await t.exactly(r,!0),o=pt(n);if(yn.toTyped(o)===void 0)throw new Error("Invalid CAR header format");if(o.version!==1&&o.version!==2||e!==void 0&&o.version!==e)throw new Error(`Invalid CAR version: ${o.version}${e!==void 0?` (expected ${e})`:""}`);if(o.version===1){if(!Array.isArray(o.roots))throw new Error("Invalid CAR header format");return o}if(o.roots!==void 0)throw new Error("Invalid CAR header format");let i=mn(await t.exactly(dn,!0));t.seek(i.dataOffset-t.pos);let s=await gn(t,1);return Object.assign(s,i)}function gt(t){let e=0;return{async upTo(r){return t.subarray(e,e+Math.min(r,t.length-e))},async exactly(r,n=!1){if(r>t.length-e)throw new Error("Unexpected end of data");let o=t.subarray(e,e+r);return n&&(e+=r),o},seek(r){e+=r},get pos(){return e}}}var wn=Ee(tr(),1),Ki=1;function xn(t){let e=cn({version:Ki,roots:t}),r=wn.default.encode(e.length),n=new Uint8Array(r.length+e.length);return n.set(r,0),n.set(e,r.length),n}function Yi(t){return{async setRoots(e){let r=xn(e);await t.write(r)},async writeBlock(e){let{cid:r,bytes:n}=e;await t.write(new Uint8Array(wn.default.encode(r.bytes.length+n.length))),await t.write(r.bytes),n.length&&await t.write(n)},async close(){await t.end()},version(){return Ki}}}function rr(){}function Zi(){let t=[],e=null,r=rr,n=!1,o=null,i=rr,s=()=>(e||(e=new Promise(h=>{r=()=>{e=null,r=rr,h()}})),e),a={write(h){t.push(h);let d=s();return i(),d},async end(){n=!0;let h=s();i(),await h}},c={async next(){let h=t.shift();return h?(t.length===0&&r(),{done:!1,value:h}):n?(r(),{done:!0,value:void 0}):(o||(o=new Promise(d=>{i=()=>(o=null,i=rr,d(c.next()))})),o)}};return{writer:a,iterator:c}}var wt=class t{constructor(e,r){this._encoder=r,this._mutex=r.setRoots(e),this._ended=!1}async put(e){if(!(e.bytes instanceof Uint8Array)||!e.cid)throw new TypeError("Can only write {cid, bytes} objects");if(this._ended)throw new Error("Already closed");let r=N.asCID(e.cid);if(!r)throw new TypeError("Can only write {cid, bytes} objects");return this._mutex=this._mutex.then(()=>this._encoder.writeBlock({cid:r,bytes:e.bytes})),this._mutex}async close(){if(this._ended)throw new Error("Already closed");return await this._mutex,this._ended=!0,this._encoder.close()}version(){return this._encoder.version()}static create(e){e=_u(e);let{encoder:r,iterator:n}=es(),o=new t(e,r),i=new nr(n);return{writer:o,out:i}}static createAppender(){let{encoder:e,iterator:r}=es();e.setRoots=()=>Promise.resolve();let n=new t([],e),o=new nr(r);return{writer:n,out:o}}static async updateRootsInBytes(e,r){let n=gt(e);await gn(n);let o=xn(r);if(Number(n.pos)!==o.length)throw new Error(`updateRoots() can only overwrite a header of the same length (old header is ${n.pos} bytes, new header is ${o.length} bytes)`);return e.set(o,0),e}},nr=class{constructor(e){this._iterator=e}[Symbol.asyncIterator](){if(this._iterating)throw new Error("Multiple iterator not supported");return this._iterating=!0,this._iterator}};function es(){let t=Zi(),{writer:e,iterator:r}=t;return{encoder:Yi(e),iterator:r}}function _u(t){if(t===void 0)return[];if(!Array.isArray(t)){let r=N.asCID(t);if(!r)throw new TypeError("roots must be a single CID or an array of CIDs");return[r]}let e=[];for(let r of t){let n=N.asCID(r);if(!n)throw new TypeError("roots must be a single CID or an array of CIDs");e.push(n)}return e}function Au(t){return t[Symbol.asyncIterator]!=null}function Iu(t){if(Au(t))return(async()=>{for await(let e of t);})();for(let e of t);}var bn=Iu;function Tu(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 or=Tu;function Su(t){return t[Symbol.asyncIterator]!=null}function Bu(t,e){let r=0;if(Su(t))return(async function*(){for await(let c of t)yield e(c,r++)})();let n=or(t),{value:o,done:i}=n.next();if(i===!0)return(function*(){})();let s=e(o,r++);if(typeof s.then=="function")return(async function*(){yield await s;for(let c of n)yield e(c,r++)})();let a=e;return(function*(){yield s;for(let c of n)yield a(c,r++)})()}var ge=Bu;function Nu(t){return t.reason}async function ir(t,e,r){if(e==null)return t;let n=r?.translateError??Nu;if(e.aborted)return t.catch(()=>{}),Promise.reject(n(e));let o;try{return await Promise.race([t,new Promise((i,s)=>{o=()=>{s(n(e))},e.addEventListener("abort",o)})])}finally{o!=null&&e.removeEventListener("abort",o)}}var le=class extends Error{static name="AbortError";constructor(e="The operation was aborted"){super(e),this.name="AbortError"}};var sr=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}};var ar=class extends EventTarget{#e=new Map;constructor(){super()}listenerCount(e){let r=this.#e.get(e);return r==null?0:r.length}addEventListener(e,r,n){super.addEventListener(e,r,n);let o=this.#e.get(e);o==null&&(o=[],this.#e.set(e,o)),o.push({callback:r,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(e,r,n){super.removeEventListener(e.toString(),r??null,n);let o=this.#e.get(e);o!=null&&(o=o.filter(({callback:i})=>i!==r),this.#e.set(e,o))}dispatchEvent(e){let r=super.dispatchEvent(e),n=this.#e.get(e.type);return n==null||(n=n.filter(({once:o})=>!o),this.#e.set(e.type,n)),r}safeDispatchEvent(e,r={}){return this.dispatchEvent(new CustomEvent(e,r))}};var vn={};V(vn,{base64:()=>En,base64pad:()=>Cu,base64url:()=>Du,base64urlpad:()=>Lu});var En=L({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Cu=L({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Du=L({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Lu=L({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var R=class extends Event{type;detail;constructor(e,r){super(e),this.type=e,this.detail=r}};var _n=Ee(rs(),1);var An=class t extends Error{name="TimeoutError";constructor(e,r){super(e,r),Error.captureStackTrace?.(this,t)}},ns=t=>t.reason??new DOMException("This operation was aborted.","AbortError");function In(t,e){let{milliseconds:r,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout},signal:s}=e,a,c,d=new Promise((p,k)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(s?.aborted){k(ns(s));return}if(s&&(c=()=>{k(ns(s))},s.addEventListener("abort",c,{once:!0})),t.then(p,k),r===Number.POSITIVE_INFINITY)return;let u=new An;a=i.setTimeout.call(void 0,()=>{if(n){try{p(n())}catch(l){k(l)}return}typeof t.cancel=="function"&&t.cancel(),o===!1?p():o instanceof Error?k(o):(u.message=o??`Promise timed out after ${r} milliseconds`,k(u))},r)}).finally(()=>{d.clear(),c&&s&&s.removeEventListener("abort",c)});return d.clear=()=>{i.clearTimeout.call(void 0,a),a=void 0},d}function Tn(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 bt=class{#e=[];enqueue(e,r){let{priority:n=0,id:o}=r??{},i={priority:n,id:o,run:e};if(this.size===0||this.#e[this.size-1].priority>=n){this.#e.push(i);return}let s=Tn(this.#e,i,(a,c)=>c.priority-a.priority);this.#e.splice(s,0,i)}setPriority(e,r){let n=this.#e.findIndex(i=>i.id===e);if(n===-1)throw new ReferenceError(`No promise function with the id "${e}" exists in the queue.`);let[o]=this.#e.splice(n,1);this.enqueue(o.run,{priority:r,id:e})}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 Et=class extends _n.default{#e;#n;#o=0;#d;#p=!1;#m=!1;#u;#x=0;#y=0;#i;#s;#t;#b;#r=0;#f;#a;#I=1n;#l=new Map;timeout;constructor(e){if(super(),e={carryoverIntervalCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:bt,...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})`);if(this.#e=e.carryoverIntervalCount??e.carryoverConcurrencyCount??!1,this.#n=e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,this.#d=e.intervalCap,this.#u=e.interval,this.#t=new e.queueClass,this.#b=e.queueClass,this.concurrency=e.concurrency,e.timeout!==void 0&&!(Number.isFinite(e.timeout)&&e.timeout>0))throw new TypeError(`Expected \`timeout\` to be a positive finite number, got \`${e.timeout}\` (${typeof e.timeout})`);this.timeout=e.timeout,this.#a=e.autoStart===!1,this.#P()}get#T(){return this.#n||this.#o<this.#d}get#S(){return this.#r<this.#f}#B(){this.#r--,this.#r===0&&this.emit("pendingZero"),this.#g(),this.emit("next")}#N(){this.#_(),this.#k(),this.#s=void 0}get#C(){let e=Date.now();if(this.#i===void 0){let r=this.#x-e;if(r<0){if(this.#y>0){let n=e-this.#y;if(n<this.#u)return this.#E(this.#u-n),!0}this.#o=this.#e?this.#r:0}else return this.#E(r),!0}return!1}#E(e){this.#s===void 0&&(this.#s=setTimeout(()=>{this.#N()},e))}#v(){this.#i&&(clearInterval(this.#i),this.#i=void 0)}#D(){this.#s&&(clearTimeout(this.#s),this.#s=void 0)}#g(){if(this.#t.size===0)return this.#v(),this.emit("empty"),this.#r===0&&(this.#D(),this.emit("idle")),!1;let e=!1;if(!this.#a){let r=!this.#C;if(this.#T&&this.#S){let n=this.#t.dequeue();this.#n||(this.#o++,this.#h()),this.emit("active"),this.#y=Date.now(),n(),r&&this.#k(),e=!0}}return e}#k(){this.#n||this.#i!==void 0||(this.#i=setInterval(()=>{this.#_()},this.#u),this.#x=Date.now()+this.#u)}#_(){this.#o===0&&this.#r===0&&this.#i&&this.#v(),this.#o=this.#e?this.#r:0,this.#w(),this.#h()}#w(){for(;this.#g(););}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.#w()}async#L(e){return new Promise((r,n)=>{e.addEventListener("abort",()=>{n(e.reason)},{once:!0})})}setPriority(e,r){if(typeof r!="number"||!Number.isFinite(r))throw new TypeError(`Expected \`priority\` to be a finite number, got \`${r}\` (${typeof r})`);this.#t.setPriority(e,r)}async add(e,r={}){return r.id??=(this.#I++).toString(),r={timeout:this.timeout,...r},new Promise((n,o)=>{let i=Symbol(`task-${r.id}`);this.#t.enqueue(async()=>{this.#r++,this.#l.set(i,{id:r.id,priority:r.priority??0,startTime:Date.now(),timeout:r.timeout});try{try{r.signal?.throwIfAborted()}catch(c){throw this.#n||this.#o--,this.#l.delete(i),c}let s=e({signal:r.signal});r.timeout&&(s=In(Promise.resolve(s),{milliseconds:r.timeout,message:`Task timed out after ${r.timeout}ms (queue has ${this.#r} running, ${this.#t.size} waiting)`})),r.signal&&(s=Promise.race([s,this.#L(r.signal)]));let a=await s;n(a),this.emit("completed",a)}catch(s){o(s),this.emit("error",s)}finally{this.#l.delete(i),queueMicrotask(()=>{this.#B()})}},r),this.emit("add"),this.#g()})}async addAll(e,r){return Promise.all(e.map(async n=>this.add(n,r)))}start(){return this.#a?(this.#a=!1,this.#w(),this):this}pause(){this.#a=!0}clear(){this.#t=new this.#b,this.#A()}async onEmpty(){this.#t.size!==0&&await this.#c("empty")}async onSizeLessThan(e){this.#t.size<e||await this.#c("next",()=>this.#t.size<e)}async onIdle(){this.#r===0&&this.#t.size===0||await this.#c("idle")}async onPendingZero(){this.#r!==0&&await this.#c("pendingZero")}async onRateLimit(){this.isRateLimited||await this.#c("rateLimit")}async onRateLimitCleared(){this.isRateLimited&&await this.#c("rateLimitCleared")}async onError(){return new Promise((e,r)=>{let n=o=>{this.off("error",n),r(o)};this.on("error",n)})}async#c(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.#r}get isPaused(){return this.#a}#P(){this.#n||(this.on("add",()=>{this.#t.size>0&&this.#h()}),this.on("next",()=>{this.#h()}))}#h(){this.#n||this.#m||(this.#m=!0,queueMicrotask(()=>{this.#m=!1,this.#A()}))}#A(){let e=this.#p,r=!this.#n&&this.#o>=this.#d&&this.#t.size>0;r!==e&&(this.#p=r,this.emit(r?"rateLimit":"rateLimitCleared"))}get isRateLimited(){return this.#p}get isSaturated(){return this.#r===this.#f&&this.#t.size>0||this.isRateLimited&&this.#t.size>0}get runningTasks(){return[...this.#l.values()].map(e=>({...e}))}};var Sn={};V(Sn,{base10:()=>Ru});var Ru=pe({prefix:"9",name:"base10",alphabet:"0123456789"});var Bn={};V(Bn,{base16:()=>Fu,base16upper:()=>zu});var Fu=L({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),zu=L({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Nn={};V(Nn,{base2:()=>Mu});var Mu=L({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Cn={};V(Cn,{base256emoji:()=>qu});var os=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),$u=os.reduce((t,e,r)=>(t[r]=e,t),[]),Ou=os.reduce((t,e,r)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return t[n]=r,t},[]);function Hu(t){return t.reduce((e,r)=>(e+=$u[r],e),"")}function Vu(t){let e=[];for(let r of t){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=Ou[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);e.push(o)}return new Uint8Array(e)}var qu=ze({prefix:"\u{1F680}",name:"base256emoji",encode:Hu,decode:Vu});var Dn={};V(Dn,{base8:()=>Gu});var Gu=L({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Ln={};V(Ln,{identity:()=>ju});var ju=ze({prefix:"\0",name:"identity",encode:t=>Qr(t),decode:t=>Xr(t)});var Ep=new TextEncoder,Wu=new TextDecoder;var is=512;function ss(t){return JSON.parse(Wu.decode(t))}var ur=85;var Fn={};V(Fn,{identity:()=>Rn});var as=0,Ju="identity",cs=oe;function Xu(t,e){if(e?.truncate!=null&&e.truncate!==t.byteLength){if(e.truncate<0||e.truncate>t.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${t.byteLength}`);t=t.subarray(0,e.truncate)}return Ve(as,cs(t))}var Rn={code:as,name:Ju,encode:cs,digest:Xu};var Mn={};V(Mn,{sha256:()=>Ku,sha512:()=>Yu});var Qu=20;function _e({name:t,code:e,encode:r,minDigestLength:n,maxDigestLength:o}){return new zn(t,e,r,n,o)}var zn=class{name;code;encode;minDigestLength;maxDigestLength;constructor(e,r,n,o,i){this.name=e,this.code=r,this.encode=n,this.minDigestLength=o??Qu,this.maxDigestLength=i}digest(e,r){if(r?.truncate!=null){if(r.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&r.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(e instanceof Uint8Array){let n=this.encode(e);return n instanceof Uint8Array?us(n,this.code,r?.truncate):n.then(o=>us(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function us(t,e,r){if(r!=null&&r!==t.byteLength){if(r>t.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${t.byteLength}`);t=t.subarray(0,r)}return Ve(e,t)}function ls(t){return async e=>new Uint8Array(await crypto.subtle.digest(t,e))}var Ku=_e({name:"sha2-256",code:18,encode:ls("SHA-256")}),Yu=_e({name:"sha2-512",code:19,encode:ls("SHA-512")});var $n={...Ln,...Nn,...Dn,...Sn,...Bn,...tn,...rn,...nn,...vn,...Cn},Pp={...Mn,...Fn};function se(t=0){return new Uint8Array(t)}function ds(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var hs=ds("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),On=ds("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=se(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Zu={utf8:hs,"utf-8":hs,hex:$n.base16,latin1:On,ascii:On,binary:On,...$n},Hn=Zu;var rf=Ee(ms(),1);var Ge;(function(t){t[t.A=1]="A",t[t.CNAME=5]="CNAME",t[t.TXT=16]="TXT",t[t.AAAA=28]="AAAA"})(Ge||(Ge={}));function vt(t,e){e==null&&(e=t.reduce((o,i)=>o+i.length,0));let r=se(e),n=0;for(let o of t)r.set(o,n),n+=o.length;return r}function fr(t,e="utf8"){let r=Hn[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return r.decoder.decode(`${r.prefix}${t}`)}var nf=Math.pow(2,7),of=Math.pow(2,14),sf=Math.pow(2,21),ys=Math.pow(2,28),gs=Math.pow(2,35),ws=Math.pow(2,42),xs=Math.pow(2,49),H=128,we=127;function kt(t){if(t<nf)return 1;if(t<of)return 2;if(t<sf)return 3;if(t<ys)return 4;if(t<gs)return 5;if(t<ws)return 6;if(t<xs)return 7;if(Number.MAX_SAFE_INTEGER!=null&&t>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function bs(t,e,r=0){switch(kt(t)){case 8:e[r++]=t&255|H,t/=128;case 7:e[r++]=t&255|H,t/=128;case 6:e[r++]=t&255|H,t/=128;case 5:e[r++]=t&255|H,t/=128;case 4:e[r++]=t&255|H,t>>>=7;case 3:e[r++]=t&255|H,t>>>=7;case 2:e[r++]=t&255|H,t>>>=7;case 1:{e[r++]=t&255,t>>>=7;break}default:throw new Error("unreachable")}return e}function Es(t,e){let r=t[e],n=0;if(n+=r&we,r<H||(r=t[e+1],n+=(r&we)<<7,r<H)||(r=t[e+2],n+=(r&we)<<14,r<H)||(r=t[e+3],n+=(r&we)<<21,r<H)||(r=t[e+4],n+=(r&we)*ys,r<H)||(r=t[e+5],n+=(r&we)*gs,r<H)||(r=t[e+6],n+=(r&we)*ws,r<H)||(r=t[e+7],n+=(r&we)*xs,r<H))return n;throw new RangeError("Could not decode varint")}var Vn=new Float32Array([-0]),xe=new Uint8Array(Vn.buffer);function vs(t,e,r){Vn[0]=t,e[r]=xe[0],e[r+1]=xe[1],e[r+2]=xe[2],e[r+3]=xe[3]}function ks(t,e){return xe[0]=t[e],xe[1]=t[e+1],xe[2]=t[e+2],xe[3]=t[e+3],Vn[0]}var qn=new Float64Array([-0]),M=new Uint8Array(qn.buffer);function _s(t,e,r){qn[0]=t,e[r]=M[0],e[r+1]=M[1],e[r+2]=M[2],e[r+3]=M[3],e[r+4]=M[4],e[r+5]=M[5],e[r+6]=M[6],e[r+7]=M[7]}function As(t,e){return M[0]=t[e],M[1]=t[e+1],M[2]=t[e+2],M[3]=t[e+3],M[4]=t[e+4],M[5]=t[e+5],M[6]=t[e+6],M[7]=t[e+7],qn[0]}var af=BigInt(Number.MAX_SAFE_INTEGER),cf=BigInt(Number.MIN_SAFE_INTEGER),J=class t{lo;hi;constructor(e,r){this.lo=e|0,this.hi=r|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?e<16384?e<128?1:2:e<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return Ae;if(e<af&&e>cf)return this.fromNumber(Number(e));let r=e<0n;r&&(e=-e);let n=e>>32n,o=e-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>Is&&(o=0n,++n>Is&&(n=0n))),new t(Number(o),Number(n))}static fromNumber(e){if(e===0)return Ae;let r=e<0;r&&(e=-e);let n=e>>>0,o=(e-n)/4294967296>>>0;return r&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new t(n,o)}static from(e){return typeof e=="number"?t.fromNumber(e):typeof e=="bigint"?t.fromBigInt(e):typeof e=="string"?t.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new t(e.low>>>0,e.high>>>0):Ae}},Ae=new J(0,0);Ae.toBigInt=function(){return 0n};Ae.zzEncode=Ae.zzDecode=function(){return this};Ae.length=function(){return 1};var Is=4294967296n;function Ts(t){let e=0,r=0;for(let n=0;n<t.length;++n)r=t.charCodeAt(n),r<128?e+=1:r<2048?e+=2:(r&64512)===55296&&(t.charCodeAt(n+1)&64512)===56320?(++n,e+=4):e+=3;return e}function Ss(t,e,r){if(r-e<1)return"";let o,i=[],s=0,a;for(;e<r;)a=t[e++],a<128?i[s++]=a:a>191&&a<224?i[s++]=(a&31)<<6|t[e++]&63:a>239&&a<365?(a=((a&7)<<18|(t[e++]&63)<<12|(t[e++]&63)<<6|t[e++]&63)-65536,i[s++]=55296+(a>>10),i[s++]=56320+(a&1023)):i[s++]=(a&15)<<12|(t[e++]&63)<<6|t[e++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function Gn(t,e,r){let n=r,o,i;for(let s=0;s<t.length;++s)o=t.charCodeAt(s),o<128?e[r++]=o:o<2048?(e[r++]=o>>6|192,e[r++]=o&63|128):(o&64512)===55296&&((i=t.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,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 r-n}function Z(t,e){return RangeError(`index out of range: ${t.pos} + ${e??1} > ${t.len}`)}function lr(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}var jn=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,Z(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw Z(this,4);return lr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Z(this,4);return lr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Z(this,4);let e=ks(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw Z(this,4);let e=As(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),r=this.pos,n=this.pos+e;if(n>this.len)throw Z(this,e);return this.pos+=e,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let e=this.bytes();return Ss(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw Z(this,e);this.pos+=e}else do if(this.pos>=this.len)throw Z(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new J(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw Z(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,e}if(this.len-this.pos>4){for(;r<5;++r)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;r<5;++r){if(this.pos>=this.len)throw Z(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Z(this,8);let e=lr(this.buf,this.pos+=4),r=lr(this.buf,this.pos+=4);return new J(e,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=Es(this.buf,this.pos);return this.pos+=kt(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function Wn(t){return new jn(t instanceof Uint8Array?t:t.subarray())}function _t(t,e,r){let n=Wn(t);return e.decode(n,void 0,r)}function Jn(t){let e=t??8192,r=e>>>1,n,o=e;return function(s){if(s<1||s>r)return se(s);o+s>e&&(n=se(e),o=0);let a=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),a}}var Ie=class{fn;len;next;val;constructor(e,r,n){this.fn=e,this.len=r,this.next=void 0,this.val=n}};function Xn(){}var Kn=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},uf=Jn();function ff(t){return globalThis.Buffer!=null?se(t):uf(t)}var It=class{len;head;tail;states;constructor(){this.len=0,this.head=new Ie(Xn,0,0),this.tail=this.head,this.states=null}_push(e,r,n){return this.tail=this.tail.next=new Ie(e,r,n),this.len+=r,this}uint32(e){return this.len+=(this.tail=this.tail.next=new Yn((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(hr,10,J.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let r=J.fromBigInt(e);return this._push(hr,r.length(),r)}uint64Number(e){return this._push(bs,kt(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let r=J.fromBigInt(e).zzEncode();return this._push(hr,r.length(),r)}sint64Number(e){let r=J.fromNumber(e).zzEncode();return this._push(hr,r.length(),r)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Qn,1,e?1:0)}fixed32(e){return this._push(At,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let r=J.fromBigInt(e);return this._push(At,4,r.lo)._push(At,4,r.hi)}fixed64Number(e){let r=J.fromNumber(e);return this._push(At,4,r.lo)._push(At,4,r.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(vs,4,e)}double(e){return this._push(_s,8,e)}bytes(e){let r=e.length>>>0;return r===0?this._push(Qn,1,0):this.uint32(r)._push(hf,r,e)}string(e){let r=Ts(e);return r!==0?this.uint32(r)._push(Gn,r,e):this._push(Qn,1,0)}fork(){return this.states=new Kn(this),this.head=this.tail=new Ie(Xn,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new Ie(Xn,0,0),this.len=0),this}ldelim(){let e=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=r,this.len+=n),this}finish(){let e=this.head.next,r=ff(this.len),n=0;for(;e!=null;)e.fn(e.val,r,n),n+=e.len,e=e.next;return r}};function Qn(t,e,r){e[r]=t&255}function lf(t,e,r){for(;t>127;)e[r++]=t&127|128,t>>>=7;e[r]=t}var Yn=class extends Ie{next;constructor(e,r){super(lf,e,r),this.next=void 0}};function hr(t,e,r){for(;t.hi!==0;)e[r++]=t.lo&127|128,t.lo=(t.lo>>>7|t.hi<<25)>>>0,t.hi>>>=7;for(;t.lo>127;)e[r++]=t.lo&127|128,t.lo=t.lo>>>7;e[r++]=t.lo}function At(t,e,r){e[r]=t&255,e[r+1]=t>>>8&255,e[r+2]=t>>>16&255,e[r+3]=t>>>24}function hf(t,e,r){e.set(t,r)}globalThis.Buffer!=null&&(It.prototype.bytes=function(t){let e=t.length>>>0;return this.uint32(e),e>0&&this._push(df,e,t),this},It.prototype.string=function(t){let e=globalThis.Buffer.byteLength(t);return this.uint32(e),e>0&&this._push(pf,e,t),this});function df(t,e,r){e.set(t,r)}function pf(t,e,r){t.length<40?Gn(t,e,r):e.utf8Write!=null?e.utf8Write(t,r):e.set(fr(t),r)}function Zn(){return new It}function Tt(t,e){let r=Zn();return e.encode(t,r,{lengthDelimited:!1}),r.finish()}var je;(function(t){t[t.VARINT=0]="VARINT",t[t.BIT64=1]="BIT64",t[t.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",t[t.START_GROUP=3]="START_GROUP",t[t.END_GROUP=4]="END_GROUP",t[t.BIT32=5]="BIT32"})(je||(je={}));function dr(t,e,r,n){return{name:t,type:e,encode:r,decode:n}}function eo(t){function e(o){if(t[o.toString()]==null)throw new Error("Invalid enum value");return t[o]}let r=function(i,s){let a=e(i);s.int32(a)},n=function(i){let s=i.int32();return e(s)};return dr("enum",je.VARINT,r,n)}function St(t,e){return dr("message",je.LENGTH_DELIMITED,t,e)}function $(){let t={};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t}var pr=class{buffer;mask;top;btm;next;constructor(e){if(!(e>0)||(e-1&e)!==0)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return this.buffer[this.btm]===void 0}},We=class{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new pr(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return e?.byteLength!=null?e.byteLength:1}push(e){if(e?.value!=null&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){let r=this.head;this.head=r.next=new pr(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next!=null){let r=this.tail.next;this.tail.next=null,this.tail=r,e=this.tail.shift()}return e?.value!=null&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}};var to=class extends Error{type;code;constructor(e,r){super(e??"The operation was aborted"),this.type="aborted",this.code=r??"ABORT_ERR"}};function Je(t={}){return mf(r=>{let n=r.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},t)}function mf(t,e){e=e??{};let r=e.onEnd,n=new We,o,i,s,a=$(),c=async()=>{try{return n.isEmpty()?s?{done:!0}:await new Promise((I,g)=>{i=x=>{i=null,n.push(x);try{I(t(n))}catch(b){g(b)}return o}}):t(n)}finally{n.isEmpty()&&queueMicrotask(()=>{a.resolve(),a=$()})}},h=I=>i!=null?i(I):(n.push(I),o),d=I=>(n=new We,i!=null?i({error:I}):(n.push({error:I}),o)),p=I=>{if(s)return o;if(e?.objectMode!==!0&&I?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return h({done:!1,value:I})},k=I=>s?o:(s=!0,I!=null?d(I):h({done:!0})),u=()=>(n=new We,k(),{done:!0}),l=I=>(k(I),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:c,return:u,throw:l,push:p,end:k,get readableLength(){return n.size},onEmpty:async I=>{let g=I?.signal;if(g?.throwIfAborted(),n.isEmpty())return;let x,b;g!=null&&(x=new Promise((v,A)=>{b=()=>{A(new to)},g.addEventListener("abort",b)}));try{await Promise.race([a.promise,x])}finally{b!=null&&g!=null&&g?.removeEventListener("abort",b)}}},r==null)return o;let m=o;return o={[Symbol.asyncIterator](){return this},next(){return m.next()},throw(I){return m.throw(I),r!=null&&(r(I),r=void 0),{done:!0}},return(){return m.return(),r!=null&&(r(),r=void 0),{done:!0}},push:p,end(I){return m.end(I),r!=null&&(r(I),r=void 0),o},get readableLength(){return m.readableLength},onEmpty:I=>m.onEmpty(I)},o}var ro=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},no=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},Ns=t=>globalThis.DOMException===void 0?new no(t):new DOMException(t),Cs=t=>{let e=t.reason===void 0?Ns("This operation was aborted."):t.reason;return e instanceof Error?e:Ns(e)};function oo(t,e){let{milliseconds:r,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout}}=e,s,a,h=new Promise((d,p)=>{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:u}=e;u.aborted&&p(Cs(u)),a=()=>{p(Cs(u))},u.addEventListener("abort",a,{once:!0})}if(r===Number.POSITIVE_INFINITY){t.then(d,p);return}let k=new ro;s=i.setTimeout.call(void 0,()=>{if(n){try{d(n())}catch(u){p(u)}return}typeof t.cancel=="function"&&t.cancel(),o===!1?d():o instanceof Error?p(o):(k.message=o??`Promise timed out after ${r} milliseconds`,p(k))},r),(async()=>{try{d(await t)}catch(u){p(u)}})()}).finally(()=>{h.clear(),a&&e.signal&&e.signal.removeEventListener("abort",a)});return h.clear=()=>{i.clearTimeout.call(void 0,s),s=void 0},h}var yf=t=>{let e=t.addEventListener||t.on||t.addListener,r=t.removeEventListener||t.off||t.removeListener;if(!e||!r)throw new TypeError("Emitter is not compatible");return{addListener:e.bind(t),removeListener:r.bind(t)}};function gf(t,e,r){let n,o=new Promise((i,s)=>{if(r={rejectionEvents:["error"],multiArgs:!1,rejectionMultiArgs:!1,resolveImmediately:!1,...r},!(r.count>=0&&(r.count===Number.POSITIVE_INFINITY||Number.isInteger(r.count))))throw new TypeError("The `count` option should be at least 0 or more");r.signal?.throwIfAborted();let a=[e].flat(),c=[],{addListener:h,removeListener:d}=yf(t),p=async(...u)=>{let l=r.multiArgs?u:u[0];if(r.filter)try{if(!await r.filter(l))return}catch(m){n(),s(m);return}c.push(l),r.count===c.length&&(n(),i(c))},k=(...u)=>{n(),s(r.rejectionMultiArgs?u:u[0])};n=()=>{for(let u of a)d(u,p);for(let u of r.rejectionEvents)a.includes(u)||d(u,k)};for(let u of a)h(u,p);for(let u of r.rejectionEvents)a.includes(u)||h(u,k);r.signal&&r.signal.addEventListener("abort",()=>{k(r.signal.reason)},{once:!0}),r.resolveImmediately&&i(c)});if(o.cancel=n,typeof r.timeout=="number"){let i=oo(o,{milliseconds:r.timeout});return i.cancel=()=>{n(),i.clear()},i}return o}function mr(t,e,r){typeof r=="function"&&(r={filter:r}),r={...r,count:1,resolveImmediately:!1};let n=gf(t,e,r),o=n.then(i=>i[0]);return o.cancel=n.cancel,o}function io(t,e){let r,n=function(){let o=function(){r=void 0,t()};clearTimeout(r),r=setTimeout(o,e)};return n.start=()=>{},n.stop=()=>{clearTimeout(r)},n}var yr=class extends Error{static name="QueueFullError";constructor(e="The queue was full"){super(e),this.name="QueueFullError"}};var gr=class{deferred;signal;constructor(e){this.signal=e,this.deferred=$(),this.onAbort=this.onAbort.bind(this),this.signal?.addEventListener("abort",this.onAbort)}onAbort(){this.deferred.reject(this.signal?.reason??new le)}cleanup(){this.signal?.removeEventListener("abort",this.onAbort)}};function wf(){return`${parseInt(String(Math.random()*1e9),10).toString()}${Date.now()}`}var wr=class{id;fn;options;recipients;status;timeline;controller;constructor(e,r){this.id=wf(),this.status="queued",this.fn=e,this.options=r,this.recipients=[],this.timeline={created:Date.now()},this.controller=new AbortController,this.controller.signal,this.onAbort=this.onAbort.bind(this)}abort(e){this.controller.abort(e)}onAbort(){this.recipients.reduce((r,n)=>r&&n.signal?.aborted===!0,!0)&&(this.controller.abort(new le),this.cleanup())}async join(e={}){let r=new gr(e.signal);return this.recipients.push(r),e.signal?.addEventListener("abort",this.onAbort),r.deferred.promise}async run(){this.status="running",this.timeline.started=Date.now();try{this.controller.signal.throwIfAborted();let e=await ir(this.fn({...this.options??{},signal:this.controller.signal}),this.controller.signal);this.recipients.forEach(r=>{r.deferred.resolve(e)}),this.status="complete"}catch(e){this.recipients.forEach(r=>{r.deferred.reject(e)}),this.status="errored"}finally{this.timeline.finished=Date.now(),this.cleanup()}}cleanup(){this.recipients.forEach(e=>{e.cleanup(),e.signal?.removeEventListener("abort",this.onAbort)})}};var Bt=class extends ar{concurrency;maxSize;queue;pending;sort;paused;constructor(e={}){super(),this.concurrency=e.concurrency??Number.POSITIVE_INFINITY,this.maxSize=e.maxSize??Number.POSITIVE_INFINITY,this.pending=0,this.paused=!1,e.metricName!=null&&e.metrics?.registerMetricGroup(e.metricName,{calculate:()=>({size:this.queue.length,running:this.pending,queued:this.queue.length-this.pending})}),this.sort=e.sort,this.queue=[],this.emitEmpty=io(this.emitEmpty.bind(this),1),this.emitIdle=io(this.emitIdle.bind(this),1)}emitEmpty(){this.size===0&&this.safeDispatchEvent("empty")}emitIdle(){this.running===0&&this.safeDispatchEvent("idle")}pause(){this.paused=!0}resume(){this.paused&&(this.paused=!1,this.tryToStartAnother())}tryToStartAnother(){if(this.paused)return!1;if(this.size===0)return this.emitEmpty(),this.running===0&&this.emitIdle(),!1;if(this.pending<this.concurrency){let e;for(let r of this.queue)if(r.status==="queued"){e=r;break}return e==null?!1:(this.safeDispatchEvent("active"),this.pending++,e.run().finally(()=>{for(let r=0;r<this.queue.length;r++)if(this.queue[r]===e){this.queue.splice(r,1);break}this.pending--,this.tryToStartAnother(),this.safeDispatchEvent("next")}),!0)}return!1}enqueue(e){this.queue.push(e),this.sort!=null&&this.queue.sort(this.sort)}async add(e,r){if(r?.signal?.throwIfAborted(),this.size===this.maxSize)throw new yr;let n=new wr(e,r);return this.enqueue(n),this.safeDispatchEvent("add"),this.tryToStartAnother(),n.join(r).then(o=>(this.safeDispatchEvent("completed",{detail:o}),this.safeDispatchEvent("success",{detail:{job:n,result:o}}),o)).catch(o=>{if(n.status==="queued"){for(let i=0;i<this.queue.length;i++)if(this.queue[i]===n){this.queue.splice(i,1);break}}throw this.safeDispatchEvent("failure",{detail:{job:n,error:o}}),o})}clear(){this.queue.splice(0,this.queue.length)}abort(){this.queue.forEach(e=>{e.abort(new le)}),this.clear()}async onEmpty(e){this.size!==0&&await mr(this,"empty",e)}async onSizeLessThan(e,r){this.size<e||await mr(this,"next",{...r,filter:()=>this.size<e})}async onIdle(e){this.pending===0&&this.size===0||await mr(this,"idle",e)}get size(){return this.queue.length}get queued(){return this.queue.length-this.pending}get running(){return this.pending}async*toGenerator(e){e?.signal?.throwIfAborted();let r=Je({objectMode:!0}),n=c=>{c!=null?this.abort():this.clear(),r.end(c)},o=c=>{c.detail!=null&&r.push(c.detail)},i=c=>{n(c.detail.error)},s=()=>{n()},a=()=>{n(new le("Queue aborted"))};this.addEventListener("completed",o),this.addEventListener("failure",i),this.addEventListener("idle",s),e?.signal?.addEventListener("abort",a);try{yield*r}finally{this.removeEventListener("completed",o),this.removeEventListener("failure",i),this.removeEventListener("idle",s),e?.signal?.removeEventListener("abort",a),n()}}};var xr=class extends Error{type;code;constructor(e,r,n){super(e??"The operation was aborted"),this.type="aborted",this.name=n??"AbortError",this.code=r??"ABORT_ERR"}};async function Ds(t,e,r){if(e==null)return t;if(e.aborted)return t.catch(()=>{}),Promise.reject(new xr(r?.errorMessage,r?.errorCode,r?.errorName));let n,o=new xr(r?.errorMessage,r?.errorCode,r?.errorName);try{return await Promise.race([t,new Promise((i,s)=>{n=()=>{s(o)},e.addEventListener("abort",n)})])}finally{n!=null&&e.removeEventListener("abort",n)}}var so=class{readNext;haveNext;ended;nextResult;error;constructor(){this.ended=!1,this.readNext=$(),this.haveNext=$()}[Symbol.asyncIterator](){return this}async next(){if(this.nextResult==null&&await this.haveNext.promise,this.nextResult==null)throw new Error("HaveNext promise resolved but nextResult was undefined");let e=this.nextResult;return this.nextResult=void 0,this.readNext.resolve(),this.readNext=$(),e}async throw(e){return this.ended=!0,this.error=e,e!=null&&(this.haveNext.promise.catch(()=>{}),this.haveNext.reject(e)),{done:!0,value:void 0}}async return(){let e={done:!0,value:void 0};return this.ended=!0,this.nextResult=e,this.haveNext.resolve(),e}async push(e,r){await this._push(e,r)}async end(e,r){e!=null?await this.throw(e):await this._push(void 0,r)}async _push(e,r){if(e!=null&&this.ended)throw this.error??new Error("Cannot push value onto an ended pushable");for(;this.nextResult!=null;)await this.readNext.promise;e!=null?this.nextResult={done:!1,value:e}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=$(),await Ds(this.readNext.promise,r?.signal,r)}};function Ls(){return new so}function xf(t){return t[Symbol.asyncIterator]!=null}async function bf(t,e,r){try{await Promise.all(t.map(async n=>{for await(let o of n)await e.push(o,{signal:r}),r.throwIfAborted()})),await e.end(void 0,{signal:r})}catch(n){await e.end(n,{signal:r}).catch(()=>{})}}async function*Ef(t){let e=new AbortController,r=Ls();bf(t,r,e.signal).catch(()=>{});try{yield*r}finally{e.abort()}}function*vf(t){for(let e of t)yield*e}function kf(...t){let e=[];for(let r of t)xf(r)||e.push(r);return e.length===t.length?vf(e):Ef(t)}var Ps=kf;function Xe(t,...e){if(t==null)throw new Error("Empty pipeline");if(ao(t)){let n=t;t=()=>n.source}else if(Rs(t)||Us(t)){let n=t;t=()=>n}let r=[t,...e];if(r.length>1&&ao(r[r.length-1])&&(r[r.length-1]=r[r.length-1].sink),r.length>2)for(let n=1;n<r.length-1;n++)ao(r[n])&&(r[n]=Af(r[n]));return _f(...r)}var _f=(...t)=>{let e;for(;t.length>0;)e=t.shift()(e);return e},Us=t=>t?.[Symbol.asyncIterator]!=null,Rs=t=>t?.[Symbol.iterator]!=null,ao=t=>t==null?!1:t.sink!=null&&t.source!=null,Af=t=>e=>{let r=t.sink(e);if(r?.then!=null){let n=Je({objectMode:!0});r.then(()=>{n.end()},s=>{n.end(s)});let o,i=t.source;if(Us(i))o=async function*(){yield*i,n.end()};else if(Rs(i))o=function*(){yield*i,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return Ps(n,o())}return t.source};function If(t){return t[Symbol.asyncIterator]!=null}function Tf(t){if(If(t))return(async()=>{let n=new Uint8Array(0);for await(let o of t)n=vt([n,o],n.length+o.length);return n})();let e=[],r=0;for(let n of t)e.push(n),r+=n.byteLength;return vt(e,r)}var D=Tf;function br({enumerable:t=!0,configurable:e=!1}={}){return{enumerable:t,configurable:e,writable:!1}}function*Sf(t,e){if(e!=null&&typeof e=="object")if(Array.isArray(e))for(let[r,n]of e.entries()){let o=[...t,r],i=N.asCID(n);i!=null?yield[o.join("/"),i]:typeof n=="object"&&(yield*co(n,o))}else{let r=N.asCID(e);r!=null?yield[t.join("/"),r]:yield*co(e,t)}}function*co(t,e){if(t==null||t instanceof Uint8Array)return;let r=N.asCID(t);r!=null&&(yield[e.join("/"),r]);for(let[n,o]of Object.entries(t)){let i=[...e,n];yield*Sf(i,o)}}function*Bf(t,e){if(Array.isArray(e))for(let[r,n]of e.entries()){let o=[...t,r];yield o.join("/"),typeof n=="object"&&N.asCID(n)==null&&(yield*uo(n,o))}else yield*uo(e,t)}function*uo(t,e){if(!(t==null||typeof t!="object"))for(let[r,n]of Object.entries(t)){let o=[...e,r];yield o.join("/"),n!=null&&!(n instanceof Uint8Array)&&typeof n=="object"&&N.asCID(n)==null&&(yield*Bf(o,n))}}function Nf(t,e){let r=t;for(let[n,o]of e.entries()){if(r=r[o],r==null)throw new Error(`Object has no property at ${e.slice(0,n+1).map(s=>`[${JSON.stringify(s)}]`).join("")}`);let i=N.asCID(r);if(i!=null)return{value:i,remaining:e.slice(n+1).join("/")}}return{value:r}}var fo=class{cid;bytes;value;asBlock;constructor({cid:e,bytes:r,value:n}){if(e==null||r==null||typeof n>"u")throw new Error("Missing required argument");this.cid=e,this.bytes=r,this.value=n,this.asBlock=this,Object.defineProperties(this,{cid:br(),bytes:br(),value:br(),asBlock:br()})}links(){return co(this.value,[])}tree(){return uo(this.value,[])}get(e="/"){return Nf(this.value,e.split("/").filter(Boolean))}};function ee({bytes:t,cid:e,value:r,codec:n}){let o=r!==void 0?r:n?.decode(t);if(o===void 0)throw new Error('Missing required argument, must either provide "value" or "codec"');return new fo({cid:e,bytes:t,value:o})}var Fs=class extends Array{constructor(){super(),this.inRecursive=[]}prefix(e){let r=this.inRecursive[this.inRecursive.length-1];r&&(r.type===f.array&&(r.elements++,r.elements!==1&&e.push([44])),r.type===f.map&&(r.elements++,r.elements!==1&&(r.elements%2===1?e.push([44]):e.push([58]))))}[f.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)}[f.negint.major](e,r){this[f.uint.major](e,r)}[f.bytes.major](e,r){throw new Error(`${Le} unsupported type: Uint8Array`)}[f.string.major](e,r){this.prefix(e);let n=Ht(JSON.stringify(r.value));e.push(n.length>32?rt(n):n)}[f.array.major](e,r){this.prefix(e),this.inRecursive.push({type:f.array,elements:0}),e.push([91])}[f.map.major](e,r){this.prefix(e),this.inRecursive.push({type:f.map,elements:0}),e.push([123])}[f.tag.major](e,r){}[f.float.major](e,r){if(r.type.name==="break"){let s=this.inRecursive.pop();if(s){if(s.type===f.array)e.push([93]);else if(s.type===f.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(`${Le} 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 Qe=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(`${_} 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(`${_} unexpected token at position ${this._pos}, expected to find '${String.fromCharCode(...e)}'`)}parseNumber(){let e=this._pos,r=!1,n=!1,o=a=>{for(;!this.done();){let c=this.ch();if(a.includes(c))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 y(f.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(`${_} unexpected token at position ${this._pos}`);if(!this.done()&&this.ch()===46){if(n)throw new Error(`${_} 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 y(f.float,s,this._pos-e):this.options.allowBigInt!==!0||Number.isSafeInteger(s)?new y(s>=0?f.uint:f.negint,s,this._pos-e):new y(s>=0?f.uint:f.negint,BigInt(i),this._pos-e)}parseString(){if(this.ch()!==34)throw new Error(`${_} 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 a=this.data[i];if(a===92||a<32||a>=128)break;if(a===34){let c=String.fromCharCode.apply(null,this.data.subarray(this._pos,i));return this._pos=i+1,new y(f.string,c,s)}}let e=this._pos,r=[],n=()=>{if(this._pos+4>=this.data.length)throw new Error(`${_} unexpected end of unicode escape sequence at position ${this._pos}`);let i=0;for(let s=0;s<4;s++){let a=this.ch();if(a>=48&&a<=57)a-=48;else if(a>=97&&a<=102)a=a-97+10;else if(a>=65&&a<=70)a=a-65+10;else throw new Error(`${_} unexpected unicode escape character at position ${this._pos}`);i=i*16+a,this._pos++}return i},o=()=>{let i=this.ch(),s=null,a=i>239?4:i>223?3:i>191?2:1;if(this._pos+a>this.data.length)throw new Error(`${_} unexpected unicode sequence at position ${this._pos}`);let c,h,d,p;switch(a){case 1:i<128&&(s=i);break;case 2:c=this.data[this._pos+1],(c&192)===128&&(p=(i&31)<<6|c&63,p>127&&(s=p));break;case 3:c=this.data[this._pos+1],h=this.data[this._pos+2],(c&192)===128&&(h&192)===128&&(p=(i&15)<<12|(c&63)<<6|h&63,p>2047&&(p<55296||p>57343)&&(s=p));break;case 4:c=this.data[this._pos+1],h=this.data[this._pos+2],d=this.data[this._pos+3],(c&192)===128&&(h&192)===128&&(d&192)===128&&(p=(i&15)<<18|(c&63)<<12|(h&63)<<6|d&63,p>65535&&p<1114112&&(s=p))}s===null?(s=65533,a=1):s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|s&1023),r.push(s),this._pos+=a};for(;!this.done();){let i=this.ch(),s;switch(i){case 92:if(this._pos++,this.done())throw new Error(`${_} 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(`${_} unexpected string escape character at position ${this._pos}`)}break;case 34:return this._pos++,new y(f.string,zr(r),this._pos-e);default:if(i<32)throw new Error(`${_} invalid control character at position ${this._pos}`);i<128?(r.push(i),this._pos++):o()}}throw new Error(`${_} unexpected end of string at position ${this._pos}`)}parseValue(){switch(this.ch()){case 123:return this.modeStack.push("obj-start"),this._pos++,new y(f.map,1/0,1);case 91:return this.modeStack.push("array-start"),this._pos++,new y(f.array,1/0,1);case 34:return this.parseString();case 110:return this.expect([110,117,108,108]),new y(f.null,null,4);case 102:return this.expect([102,97,108,115,101]),new y(f.false,!1,5);case 116:return this.expect([116,114,117,101]),new y(f.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(`${_} 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 y(f.break,void 0,1);if(this.ch()!==44)throw new Error(`${_} 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 y(f.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 y(f.break,void 0,1);if(this.ch()!==44)throw new Error(`${_} 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 y(f.break,void 0,1);let e=this.parseString();if(this.skipWhitespace(),this.ch()!==58)throw new Error(`${_} 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(`${_} unexpected parse state at position ${this._pos}; this shouldn't happen`)}}};function lo(t,e){return e=Object.assign({tokenizer:new Qe(t,e)},e),ut(t,e)}function Lf(t){return t instanceof ArrayBuffer?new Uint8Array(t,0,t.byteLength):t}var ho=class extends Qe{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===f.map){let r=this._next();if(r.type===f.string&&r.value==="/"){let n=this._next();if(n.type===f.string){if(this._next().type!==f.break)throw new Error("Invalid encoded CID form");return this.tokenBuffer.push(n),new y(f.tag,42,0)}if(n.type===f.map){let o=this._next();if(o.type===f.string&&o.value==="bytes"){let i=this._next();if(i.type===f.string){for(let a=0;a<2;a++)if(this._next().type!==f.break)throw new Error("Invalid encoded Bytes form");let s=En.decode(`m${i.value}`);return new y(f.bytes,s,i.value.length)}this.tokenBuffer.push(i)}this.tokenBuffer.push(o)}this.tokenBuffer.push(n)}this.tokenBuffer.push(r)}return e}},po={allowIndefinite:!1,allowUndefined:!1,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:[]};po.tags[42]=N.parse;var zs=297;var Ms=t=>{let e=Lf(t),r=Object.assign(po,{tokenizer:new ho(e,po)});return lo(e,r)};var t0=new TextDecoder;var r0=new TextEncoder;var Pf=new TextDecoder;function mo(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 Er(t,e){let r;[r,e]=mo(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 Os(t,e){let r;return[r,e]=mo(t,e),[r&7,r>>3,e]}function Uf(t){let e={},r=t.length,n=0;for(;n<r;){let o,i;if([o,i,n]=Os(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]=Er(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]=Er(t,n),e.Name=Pf.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]=mo(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 Hs(t){let e=t.length,r=0,n,o=!1,i;for(;r<e;){let a,c;if([a,c,r]=Os(t,r),a!==2)throw new Error(`protobuf: (PBNode) invalid wireType, expected 2, got ${a}`);if(c===1){if(i)throw new Error("protobuf: (PBNode) duplicate Data section");[i,r]=Er(t,r),n&&(o=!0)}else if(c===2){if(o)throw new Error("protobuf: (PBNode) duplicate Links section");n||(n=[]);let h;[h,r]=Er(t,r),n.push(Uf(h))}else throw new Error(`protobuf: (PBNode) invalid fieldNumber, expected 1 or 2, got ${c}`)}if(r>e)throw new Error("protobuf: (PBNode) unexpected end of data");let s={};return i&&(s.Data=i),s.Links=n||[],s}var qs=new TextEncoder,Vs=2**32,Rf=2**31;function Ff(t,e){let r=e.length;if(typeof t.Tsize=="number"){if(t.Tsize<0)throw new Error("Tsize cannot be negative");if(!Number.isSafeInteger(t.Tsize))throw new Error("Tsize too large for encoding");r=Nt(e,r,t.Tsize)-1,e[r]=24}if(typeof t.Name=="string"){let n=qs.encode(t.Name);r-=n.length,e.set(n,r),r=Nt(e,r,n.length)-1,e[r]=18}return t.Hash&&(r-=t.Hash.length,e.set(t.Hash,r),r=Nt(e,r,t.Hash.length)-1,e[r]=10),e.length-r}function Gs(t){let e=Mf(t),r=new Uint8Array(e),n=e;if(t.Data&&(n-=t.Data.length,r.set(t.Data,n),n=Nt(r,n,t.Data.length)-1,r[n]=10),t.Links)for(let o=t.Links.length-1;o>=0;o--){let i=Ff(t.Links[o],r.subarray(0,n));n-=i,n=Nt(r,n,i)-1,r[n]=18}return r}function zf(t){let e=0;if(t.Hash){let r=t.Hash.length;e+=1+r+Ke(r)}if(typeof t.Name=="string"){let r=qs.encode(t.Name).length;e+=1+r+Ke(r)}return typeof t.Tsize=="number"&&(e+=1+Ke(t.Tsize)),e}function Mf(t){let e=0;if(t.Data){let r=t.Data.length;e+=1+r+Ke(r)}if(t.Links)for(let r of t.Links){let n=zf(r);e+=1+n+Ke(n)}return e}function Nt(t,e,r){e-=Ke(r);let n=e;for(;r>=Rf;)t[e++]=r&127|128,r/=128;for(;r>=128;)t[e++]=r&127|128,r>>>=7;return t[e]=r,n}function Ke(t){return t%2===0&&t++,Math.floor(($f(t)+6)/7)}function $f(t){let e=0;return t>=Vs&&(t=Math.floor(t/Vs),e=32),t>=65536&&(t>>>=16,e+=16),t>=256&&(t>>>=8,e+=8),e+Of[t]}var Of=[0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8];var Hf=["Data","Links"],Vf=["Hash","Name","Tsize"],js=new TextEncoder;function qf(t,e){if(t===e)return 0;let r=t.Name?js.encode(t.Name):[],n=e.Name?js.encode(e.Name):[],o=r.length,i=n.length;for(let s=0,a=Math.min(o,i);s<a;++s)if(r[s]!==n[s]){o=r[s],i=n[s];break}return o<i?-1:i<o?1:0}function Ws(t,e){return!Object.keys(t).some(r=>!e.includes(r))}function Js(t){if(!t||typeof t!="object"||Array.isArray(t)||t instanceof Uint8Array||t["/"]&&t["/"]===t.bytes)throw new TypeError("Invalid DAG-PB form");if(!Ws(t,Hf))throw new TypeError("Invalid DAG-PB form (extraneous properties)");if(t.Data!==void 0&&!(t.Data instanceof Uint8Array))throw new TypeError("Invalid DAG-PB form (Data must be bytes)");if(!Array.isArray(t.Links))throw new TypeError("Invalid DAG-PB form (Links must be a list)");for(let e=0;e<t.Links.length;e++){let r=t.Links[e];if(!r||typeof r!="object"||Array.isArray(r)||r instanceof Uint8Array||r["/"]&&r["/"]===r.bytes)throw new TypeError("Invalid DAG-PB form (bad link)");if(!Ws(r,Vf))throw new TypeError("Invalid DAG-PB form (extraneous properties on link)");if(r.Hash===void 0)throw new TypeError("Invalid DAG-PB form (link must have a Hash)");if(r.Hash==null||!r.Hash["/"]||r.Hash["/"]!==r.Hash.bytes)throw new TypeError("Invalid DAG-PB form (link Hash must be a CID)");if(r.Name!==void 0&&typeof r.Name!="string")throw new TypeError("Invalid DAG-PB form (link Name must be a string)");if(r.Tsize!==void 0){if(typeof r.Tsize!="number"||r.Tsize%1!==0)throw new TypeError("Invalid DAG-PB form (link Tsize must be an integer)");if(r.Tsize<0)throw new TypeError("Invalid DAG-PB form (link Tsize cannot be negative)")}if(e>0&&qf(r,t.Links[e-1])===-1)throw new TypeError("Invalid DAG-PB form (links must be sorted by Name bytes)")}}function Xs(t){return t instanceof ArrayBuffer?new Uint8Array(t,0,t.byteLength):t}var vr=112;function Qs(t){Js(t);let e={};return t.Links&&(e.Links=t.Links.map(r=>{let n={};return r.Hash&&(n.Hash=r.Hash.bytes),r.Name!==void 0&&(n.Name=r.Name),r.Tsize!==void 0&&(n.Tsize=r.Tsize),n})),t.Data&&(e.Data=t.Data),Gs(e)}function be(t){let e=Xs(t),r=Hs(e),n={};return r.Data&&(n.Data=r.Data),r.Links&&(n.Links=r.Links.map(o=>{let i={};try{i.Hash=N.decode(o.Hash)}catch{}if(!i.Hash)throw new Error("Invalid Hash field found in link, expected CID");return o.Name!==void 0&&(i.Name=o.Name),o.Tsize!==void 0&&(i.Tsize=o.Tsize),i})),n}function Gf(t){return t[Symbol.asyncIterator]!=null}function jf(t,e){let r=0;if(Gf(t))return(async function*(){for await(let c of t)await e(c,r++)&&(yield c)})();let n=or(t),{value:o,done:i}=n.next();if(i===!0)return(function*(){})();let s=e(o,r++);if(typeof s.then=="function")return(async function*(){await s&&(yield o);for(let c of n)await e(c,r++)&&(yield c)})();let a=e;return(function*(){s===!0&&(yield o);for(let c of n)a(c,r++)&&(yield c)})()}var Ks=jf;function Ct(t,e={}){return new go(t,e)}function Dt(t,e={}){return new wo(t,e)}var go=class{components;constructor(e,r={}){this.components=e}async*walk(e,r){let n=new Bt({concurrency:1,sort:(s,a)=>s.options.depth===a.options.depth?0:s.options.depth<a.options.depth?1:-1}),o=n.toGenerator(),i=async s=>{let a=s.cid,c=await D(this.components.blockstore.get(a,s)),h=ee({cid:a,bytes:c,codec:await this.components.getCodec(a.code)});for(let[,d]of h.links())n.add(i,{...s,cid:d,depth:s.depth+1,path:[...s.path,d]}).catch(p=>{o.throw(p),n.abort()});return{block:h,depth:s.depth,path:s.path}};n.add(i,{...r,cid:e,depth:0,path:[e]}).catch(s=>{o.throw(s),n.abort()}),yield*o}},wo=class{components;constructor(e,r={}){this.components=e}async*walk(e,r){let n=new Bt({concurrency:1,sort:(s,a)=>s.options.depth===a.options.depth?0:s.options.depth<a.options.depth?-1:1}),o=n.toGenerator(),i=async s=>{let a=s.cid,c=await D(this.components.blockstore.get(a,s)),h=ee({cid:a,bytes:c,codec:await this.components.getCodec(a.code)});for(let[,d]of h.links())n.add(i,{...s,cid:d,depth:s.depth+1,path:[...s.path,d]}).catch(p=>{o.throw(p),n.abort()});return{block:h,depth:s.depth,path:s.path}};n.add(i,{...r,cid:e,depth:0,path:[e]}).catch(s=>{o.throw(s),n.abort()}),yield*o}};var Lt=class{async*export(e,r,n,o){let i=Dt({blockstore:r,getCodec:n});for await(let s of i.walk(e,o))yield s.block}};var kr=class{components;log;constructor(e){this.components=e,this.log=e.logger.forComponent("helia:car")}async import(e,r){await bn(this.components.blockstore.putMany(ge(e.blocks(),({cid:n,bytes:o})=>({cid:n,bytes:o})),r))}async*export(e,r){let{writer:n,out:o}=wt.create(e),i=o[Symbol.asyncIterator](),s=new AbortController;for(this._export(e,n,r).catch(a=>{this.log.error("error during streaming export - %e",a),s.abort(a)});;){let{done:a,value:c}=await ir(i.next(),s.signal);if(s.signal.aborted)throw s.signal.reason;if(c!=null&&(yield c),a===!0)break}}async _export(e,r,n){let o=Array.isArray(e)?e:[e],i=n?.traversal;for(let s of o){let a=n?.exporter??(s.code===112?new Pt:new Lt),c=s,h=!1;if(i!=null){for await(let{cid:d,bytes:p}of i.traverse(c,this.components.blockstore,this.components.getCodec,n))if(this.log.trace("next CID on path to %c is %c",s,d),c=d,s.equals(d)&&(h=!0),h||n?.includeTraversalBlocks===!0){if(n?.blockFilter?.has(d.multihash.bytes)===!0)continue;n?.blockFilter?.add(d.multihash.bytes),await r.put({cid:d,bytes:p})}}for await(let{cid:d,bytes:p}of a.export(c,this.components.blockstore,this.components.getCodec,n))n?.blockFilter?.has(d.multihash.bytes)!==!0&&(h&&d.equals(c)||(n?.blockFilter?.add(d.multihash.bytes),await r.put({cid:d,bytes:p})))}await r.close()}};var xo=class{async*export(e,r,n,o){let i=await D(r.get(e,o));yield ee({cid:e,bytes:i,codec:await n(e.code)})}};var _r=class extends Error{static code="ERR_NOT_UNIXFS";static message="Not a UnixFS node";static name="NotUnixFSError";code="ERR_NOT_UNIXFS";message="Not a UnixFS node";name="NotUnixFSError"},Ar=class extends Error{static name="NotDescendantError";name="NotDescendantError"},Ye=class extends Error{static name="InvalidTraversalError";name="InvalidTraversalError"};var Pt=class{async*export(e,r,n,o){if(e.code!==112&&e.code!==85)throw new _r("Target CID was not UnixFS - use the SubGraphExporter to export arbitrary graphs");let i=Ct({blockstore:r,getCodec:n});for await(let s of i.walk(e,o))yield s.block}};function Ys(t){return t!=null&&t?.asCID===t}var bo=class{haystack;needle;options;constructor(...e){if(Ys(e[0]))Ys(e[1])?(this.haystack=e[0],this.needle=e[1],this.options=e[2]):(this.needle=e[0],this.options=e[1]);else throw new sr("needle must be specified")}async*traverse(e,r,n,o){let i=this.haystack??e,s;this.options?.strategy==="breadth-first"?s=Dt({blockstore:r,getCodec:n}):s=Ct({blockstore:r,getCodec:n});for await(let a of s.walk(i,o))if(a.block.cid.equals(this.needle)){for(let c of a.path){let h=await D(r.get(c,o));yield ee({cid:c,bytes:h,codec:await n(c.code)})}return}throw new Ye(`${this.needle} was not a child of ${i}`)}};var Eo=class{path;constructor(e){this.path=e}async*traverse(e,r,n,o){if(!this.path.some(s=>s.equals(e)))throw new Ye(`CIDPath traversal must include ${e}`);let i;for(let s of this.path){if(i!=null){let h=!1;for(let[,d]of i.links())if(d.equals(s)){h=!0;break}if(!h)throw new Ar(`${s} is not a child of ${i.cid}`)}let a=await D(r.get(s,o)),c=ee({cid:s,bytes:a,codec:await n(s.code)});i=c,yield c}}};var Ir=class t extends Error{static name="BadPathError";static code="ERR_BAD_PATH";name=t.name;code=t.code;constructor(e="Bad path"){super(e)}},te=class t extends Error{static name="NotFoundError";static code="ERR_NOT_FOUND";name=t.name;code=t.code;constructor(e="Not found"){super(e)}},Tr=class t extends Error{static name="NoResolverError";static code="ERR_NO_RESOLVER";name=t.name;code=t.code;constructor(e="No resolver"){super(e)}},P=class t extends Error{static name="NotUnixFSError";static code="ERR_NOT_UNIXFS";name=t.name;code=t.code;constructor(e="Not UnixFS"){super(e)}},Sr=class t extends Error{static name="OverReadError";static code="ERR_OVER_READ";name=t.name;code=t.code;constructor(e="Over read"){super(e)}},Br=class t extends Error{static name="UnderReadError";static code="ERR_UNDER_READ";name=t.name;code=t.code;constructor(e="Under read"){super(e)}},Nr=class t extends Error{static name="NoPropError";static code="ERR_NO_PROP";name=t.name;code=t.code;constructor(e="No Property found"){super(e)}},Te=class t extends Error{static name="InvalidParametersError";static code="ERR_INVALID_PARAMS";name=t.name;code=t.code;constructor(e="Invalid parameters"){super(e)}};function Ze(t,e,r,n,o,i,s){let a=t,c=o;for(;i.length>0;){let h=i[0];if(h in a){i.shift(),c=`${c}/${h}`;let d=N.asCID(a[h]);if(d!=null)return{entry:{type:"object",name:n,path:o,cid:r,node:e,depth:s,size:BigInt(e.length),content:async function*(){yield t}},next:{cid:d,name:h,path:c,toResolve:i}};a=a[h]}else throw new Nr(`No property named ${h} found in node ${r}`)}return{entry:{type:"object",name:n,path:o,cid:r,node:e,depth:s,size:BigInt(e.length),content:async function*(){yield t}}}}var Jf=async(t,e,r,n,o,i,s,a)=>{let c=await D(s.get(t,a)),h=pt(c);return Ze(h,c,t,e,r,n,i)},Zs=Jf;var Xf=async(t,e,r,n,o,i,s,a)=>{let c=await D(s.get(t,a)),h=Ms(c);return Ze(h,c,t,e,r,n,i)},ea=Xf;function Qf(t,e,r,n){let o=BigInt(t.length),i=BigInt(e+o);return r>=i||n<e?new Uint8Array(0):(n>=e&&n<i&&(t=t.subarray(0,Number(n-e))),r>=e&&r<i&&(t=t.subarray(Number(r-e))),t)}var Se=Qf;var Kf=(t,e=0,r=t)=>{let n=BigInt(t),o=BigInt(e??0),i=BigInt(r);if(i!==n&&(i=o+i),i>n&&(i=n),o<0n)throw new Te("Offset must be greater than or equal to 0");if(o>n)throw new Te("Offset must be less than the file size");if(i<0n)throw new Te("Length must be greater than or equal to 0");if(i>n)throw new Te("Length must be less than the file size");return{start:o,end:i}},et=Kf;var Yf=t=>{async function*e(r={}){let{start:n,end:o}=et(t.length,r.offset,r.length),i=Se(t,0n,n,o);r.onProgress?.(new R("unixfs:exporter:progress:identity",{bytesRead:BigInt(i.byteLength),totalBytes:o-n,fileSize:BigInt(t.byteLength)})),yield i}return e},Zf=async(t,e,r,n,o,i,s,a)=>{if(n.length>0)throw new te(`No link named ${r} found in raw node ${t}`);let c=qe(t.multihash.bytes);return{entry:{type:"identity",name:e,path:r,cid:t,content:Yf(c.digest),depth:i,size:BigInt(c.digest.length),node:c.digest}}},ta=Zf;var el=async(t,e,r,n,o,i,s,a)=>{let c=await D(s.get(t,a)),h=ss(c);return Ze(h,c,t,e,r,n,i)},ra=el;var tl=t=>{async function*e(r={}){let{start:n,end:o}=et(t.length,r.offset,r.length),i=Se(t,0n,n,o);r.onProgress?.(new R("unixfs:exporter:progress:raw",{bytesRead:BigInt(i.byteLength),totalBytes:o-n,fileSize:BigInt(t.byteLength)})),yield i}return e},rl=async(t,e,r,n,o,i,s,a)=>{if(n.length>0)throw new te(`No link named ${r} found in raw node ${t}`);let c=await D(s.get(t,a));return{entry:{type:"raw",name:e,path:r,cid:t,content:tl(c),depth:i,size:BigInt(c.length),node:c}}},na=rl;var Ut=class t extends Error{static name="InvalidTypeError";static code="ERR_INVALID_TYPE";name=t.name;code=t.code;constructor(e="Invalid type"){super(e)}},Cr=class t extends Error{static name="InvalidUnixFSMessageError";static code="ERR_INVALID_MESSAGE";name=t.name;code=t.code;constructor(e="Invalid message"){super(e)}};var re;(function(t){let e;(function(o){o.Raw="Raw",o.Directory="Directory",o.File="File",o.Metadata="Metadata",o.Symlink="Symlink",o.HAMTShard="HAMTShard"})(e=t.DataType||(t.DataType={}));let r;(function(o){o[o.Raw=0]="Raw",o[o.Directory=1]="Directory",o[o.File=2]="File",o[o.Metadata=3]="Metadata",o[o.Symlink=4]="Symlink",o[o.HAMTShard=5]="HAMTShard"})(r||(r={})),(function(o){o.codec=()=>eo(r)})(e=t.DataType||(t.DataType={}));let n;t.codec=()=>(n==null&&(n=St((o,i,s={})=>{if(s.lengthDelimited!==!1&&i.fork(),o.Type!=null&&(i.uint32(8),t.DataType.codec().encode(o.Type,i)),o.Data!=null&&(i.uint32(18),i.bytes(o.Data)),o.filesize!=null&&(i.uint32(24),i.uint64(o.filesize)),o.blocksizes!=null)for(let a of o.blocksizes)i.uint32(32),i.uint64(a);o.hashType!=null&&(i.uint32(40),i.uint64(o.hashType)),o.fanout!=null&&(i.uint32(48),i.uint64(o.fanout)),o.mode!=null&&(i.uint32(56),i.uint32(o.mode)),o.mtime!=null&&(i.uint32(66),Dr.codec().encode(o.mtime,i)),s.lengthDelimited!==!1&&i.ldelim()},(o,i)=>{let s={blocksizes:[]},a=i==null?o.len:o.pos+i;for(;o.pos<a;){let c=o.uint32();switch(c>>>3){case 1:s.Type=t.DataType.codec().decode(o);break;case 2:s.Data=o.bytes();break;case 3:s.filesize=o.uint64();break;case 4:s.blocksizes.push(o.uint64());break;case 5:s.hashType=o.uint64();break;case 6:s.fanout=o.uint64();break;case 7:s.mode=o.uint32();break;case 8:s.mtime=Dr.codec().decode(o,o.uint32());break;default:o.skipType(c&7);break}}return s})),n),t.encode=o=>Tt(o,t.codec()),t.decode=o=>_t(o,t.codec())})(re||(re={}));var Dr;(function(t){let e;t.codec=()=>(e==null&&(e=St((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Seconds!=null&&(n.uint32(8),n.int64(r.Seconds)),r.FractionalNanoseconds!=null&&(n.uint32(21),n.fixed32(r.FractionalNanoseconds)),o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{let o={},i=n==null?r.len:r.pos+n;for(;r.pos<i;){let s=r.uint32();switch(s>>>3){case 1:o.Seconds=r.int64();break;case 2:o.FractionalNanoseconds=r.fixed32();break;default:r.skipType(s&7);break}}return o})),e),t.encode=r=>Tt(r,t.codec()),t.decode=r=>_t(r,t.codec())})(Dr||(Dr={}));var oa;(function(t){let e;t.codec=()=>(e==null&&(e=St((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.MimeType!=null&&(n.uint32(10),n.string(r.MimeType)),o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{let o={},i=n==null?r.len:r.pos+n;for(;r.pos<i;){let s=r.uint32();switch(s>>>3){case 1:o.MimeType=r.string();break;default:r.skipType(s&7);break}}return o})),e),t.encode=r=>Tt(r,t.codec()),t.decode=r=>_t(r,t.codec())})(oa||(oa={}));var ia={Raw:"raw",Directory:"directory",File:"file",Metadata:"metadata",Symlink:"symlink",HAMTShard:"hamt-sharded-directory"},nl=["directory","hamt-sharded-directory"],sa=parseInt("0644",8),aa=parseInt("0755",8),ca=BigInt(1024),ae=class t{static unmarshal(e){let r=re.decode(e);if(r.fanout!=null&&r.fanout>ca)throw new Cr(`Fanout size was too large - ${r.fanout} > ${ca}`);let n=new t({type:ia[r.Type!=null?r.Type.toString():"File"],data:r.Data,blockSizes:r.blocksizes,mode:r.mode,mtime:r.mtime!=null?{secs:r.mtime.Seconds??0n,nsecs:r.mtime.FractionalNanoseconds}:void 0,fanout:r.fanout});return n._originalMode=r.mode??0,n}type;data;blockSizes;hashType;fanout;mtime;_mode;_originalMode;constructor(e={type:"file"}){let{type:r,data:n,blockSizes:o,hashType:i,fanout:s,mtime:a,mode:c}=e;if(r!=null&&!Object.values(ia).includes(r))throw new Ut("Type: "+r+" is not valid");this.type=r??"file",this.data=n,this.hashType=i,this.fanout=s,this.blockSizes=o??[],this._originalMode=0,this.mode=c,this.mtime=a}set mode(e){e==null?this._mode=this.isDirectory()?aa:sa:this._mode=e&4095}get mode(){return this._mode}isDirectory(){return nl.includes(this.type)}addBlockSize(e){this.blockSizes.push(e)}removeBlockSize(e){this.blockSizes.splice(e,1)}fileSize(){if(this.isDirectory())return 0n;let e=0n;return this.blockSizes.forEach(r=>{e+=r}),this.data!=null&&(e+=BigInt(this.data.length)),e}marshal(){let e;switch(this.type){case"raw":e=re.DataType.Raw;break;case"directory":e=re.DataType.Directory;break;case"file":e=re.DataType.File;break;case"metadata":e=re.DataType.Metadata;break;case"symlink":e=re.DataType.Symlink;break;case"hamt-sharded-directory":e=re.DataType.HAMTShard;break;default:throw new Ut(`Type: ${e} is not valid`)}let r=this.data;(this.data==null||this.data.length===0)&&(r=void 0);let n;this.mode!=null&&(n=this._originalMode&4294963200|(this.mode??0),n===sa&&!this.isDirectory()&&(n=void 0),n===aa&&this.isDirectory()&&(n=void 0));let o;return this.mtime!=null&&(o={Seconds:this.mtime.secs,FractionalNanoseconds:this.mtime.nsecs}),re.encode({Type:e,Data:r,filesize:this.isDirectory()?void 0:this.fileSize(),blocksizes:this.blockSizes,hashType:this.hashType,fanout:this.fanout,mode:n,mtime:o})}};var Pr=Ee(la(),1);function ol(t){let e=new Array(4);for(let r=0;r<4;r++)e[r]=t&255,t=t>>8;return new Uint8Array(e)}var Fg=_e({name:"murmur3-32",code:35,encode:t=>ol(Pr.default.x86.hash32(t))}),ha=_e({name:"murmur3-128",code:34,encode:t=>ke.fromHex(Pr.default.x64.hash128(t))}),zg=_e({name:"murmur3-x64-64",code:34,encode:t=>ke.fromHex(Pr.default.x64.hash128(t)).subarray(0,8)});var ya=Ee(ma(),1);var Be=class t{_options;_popCount;_parent;_posAtParent;_children;key;constructor(e,r,n=0){this._options=e,this._popCount=0,this._parent=r,this._posAtParent=n,this._children=new ya.default,this.key=null}async put(e,r){let n=await this._findNewBucketAndPos(e);n.bucket._putAt(n,e,r)}async get(e){let r=await this._findChild(e);if(r!=null)return r.value}async del(e){let r=await this._findPlace(e),n=r.bucket._at(r.pos);n!=null&&n.key===e&&r.bucket._delAt(r.pos)}leafCount(){return this._children.compactArray().reduce((r,n)=>n instanceof t?r+n.leafCount():r+1,0)}childrenCount(){return this._children.length}onlyChild(){return this._children.get(0)}*eachLeafSeries(){let e=this._children.compactArray();for(let r of e)r instanceof t?yield*r.eachLeafSeries():yield r}serialize(e,r){let n=[];return r(this._children.reduce((o,i,s)=>(i!=null&&(i instanceof t?o.push(i.serialize(e,r)):o.push(e(i,s))),o),n))}async asyncTransform(e,r){return ga(this,e,r)}toJSON(){return this.serialize(ul,fl)}prettyPrint(){return JSON.stringify(this.toJSON(),null," ")}tableSize(){return Math.pow(2,this._options.bits)}async _findChild(e){let r=await this._findPlace(e),n=r.bucket._at(r.pos);if(!(n instanceof t)&&n!=null&&n.key===e)return n}async _findPlace(e){let r=this._options.hash(typeof e=="string"?fr(e):e),n=await r.take(this._options.bits),o=this._children.get(n);return o instanceof t?o._findPlace(r):{bucket:this,pos:n,hash:r,existingChild:o}}async _findNewBucketAndPos(e){let r=await this._findPlace(e);if(r.existingChild!=null&&r.existingChild.key!==e){let n=new t(this._options,r.bucket,r.pos);r.bucket._putObjectAt(r.pos,n);let o=await n._findPlace(r.existingChild.hash);return o.bucket._putAt(o,r.existingChild.key,r.existingChild.value),n._findNewBucketAndPos(r.hash)}return r}_putAt(e,r,n){this._putObjectAt(e.pos,{key:r,value:n,hash:e.hash})}_putObjectAt(e,r){this._children.get(e)==null&&this._popCount++,this._children.set(e,r)}_delAt(e){if(e===-1)throw new Error("Invalid position");this._children.get(e)!=null&&this._popCount--,this._children.unset(e),this._level()}_level(){if(this._parent!=null&&this._popCount<=1)if(this._popCount===1){let e=this._children.find(cl);if(e!=null&&!(e instanceof t)){let r=e.hash;r.untake(this._options.bits);let n={pos:this._posAtParent,hash:r,bucket:this._parent};this._parent._putAt(n,e.key,e.value)}}else this._parent._delAt(this._posAtParent)}_at(e){return this._children.get(e)}};function cl(t){return!!t}function ul(t,e){return t.key}function fl(t){return t}async function ga(t,e,r){let n=[];for(let o of t._children.compactArray())if(o instanceof Be)await ga(o,e,r);else{let i=await e(o);n.push({bitField:t._children.bitField(),children:i})}return r(n)}var ll=[255,254,252,248,240,224,192,128],hl=[1,3,7,15,31,63,127,255],Ur=class{_value;_currentBytePos;_currentBitPos;constructor(e){this._value=e,this._currentBytePos=e.length-1,this._currentBitPos=7}availableBits(){return this._currentBitPos+1+this._currentBytePos*8}totalBits(){return this._value.length*8}take(e){let r=e,n=0;for(;r>0&&this._haveBits();){let o=this._value[this._currentBytePos],i=this._currentBitPos+1,s=Math.min(i,r),a=dl(o,i-s,s);n=(n<<s)+a,r-=s,this._currentBitPos-=s,this._currentBitPos<0&&(this._currentBitPos=7,this._currentBytePos--)}return n}untake(e){for(this._currentBitPos+=e;this._currentBitPos>7;)this._currentBitPos-=8,this._currentBytePos+=1}_haveBits(){return this._currentBytePos>=0}};function dl(t,e,r){let n=pl(e,r);return(t&n)>>>e}function pl(t,e){return ll[t]&hl[Math.min(e+t-1,7)]}function wa(t){function e(r){return r instanceof Rr?r:new Rr(r,t)}return e}var Rr=class{_value;_hashFn;_depth;_availableBits;_currentBufferIndex;_buffers;constructor(e,r){if(!(e instanceof Uint8Array))throw new Error("can only hash Uint8Arrays");this._value=e,this._hashFn=r,this._depth=-1,this._availableBits=0,this._currentBufferIndex=0,this._buffers=[]}async take(e){let r=e;for(;this._availableBits<r;)await this._produceMoreBits();let n=0;for(;r>0;){let o=this._buffers[this._currentBufferIndex],i=Math.min(o.availableBits(),r),s=o.take(i);n=(n<<i)+s,r-=i,this._availableBits-=i,o.availableBits()===0&&this._currentBufferIndex++}return n}untake(e){let r=e;for(;r>0;){let n=this._buffers[this._currentBufferIndex],o=Math.min(n.totalBits()-n.availableBits(),r);n.untake(o),r-=o,this._availableBits+=o,this._currentBufferIndex>0&&n.totalBits()===n.availableBits()&&(this._depth--,this._currentBufferIndex--)}}async _produceMoreBits(){this._depth++;let e=this._depth>0?vt([this._value,Uint8Array.from([this._depth])]):this._value,r=await this._hashFn(e),n=new Ur(r);this._buffers.push(n),this._availableBits+=n.availableBits()}};function xa(t){if(t==null||t.hashFn==null)throw new Error("please define an options.hashFn");let e={bits:t.bits??8,hash:wa(t.hashFn)};return new Be(e)}var ml=async function(t){return(await ha.encode(t)).slice(0,8).reverse()},yl=async(t,e,r)=>{let n=(e.tableSize()-1).toString(16).length;await Promise.all(t.map(async o=>{if(o.Name==null)throw new Error("Unexpected Link without a Name");if(o.Name.length===n){let i=parseInt(o.Name,16);e._putObjectAt(i,new Be({hash:r._options.hash,bits:r._options.bits},e,i));return}await r.put(o.Name.substring(2),!0)}))},ba=(t,e)=>t.toString(16).toUpperCase().padStart(e,"0").substring(0,e),gl=t=>{let e=t.bucket,r=[];for(;e._parent!=null;)r.push(e),e=e._parent;return r.push(e),r.reverse()},Ea=async(t,e,r,n,o)=>{if(n==null){if(t.Data==null)throw new P("no data in PBNode");let p;try{p=ae.unmarshal(t.Data)}catch(u){throw new P(u.message)}if(p.type!=="hamt-sharded-directory")throw new P("not a HAMT");if(p.fanout==null)throw new P("missing fanout");let k=xa({hashFn:ml,bits:Math.log2(Number(p.fanout))});n={rootBucket:k,hamtDepth:1,lastBucket:k}}let i=(n.lastBucket.tableSize()-1).toString(16).length;await yl(t.Links,n.lastBucket,n.rootBucket);let s=await n.rootBucket._findNewBucketAndPos(e),a=ba(s.pos,i),c=gl(s);c.length>n.hamtDepth&&(n.lastBucket=c[n.hamtDepth],a=ba(n.lastBucket._posAtParent,i));let h=t.Links.find(p=>{if(p.Name==null)return!1;let k=p.Name.substring(0,i),u=p.Name.substring(i);return!(k!==a||u!==""&&u!==e)});if(h==null)return;if(h.Name!=null&&h.Name.substring(i)===e)return h.Hash;n.hamtDepth++;let d=await D(r.get(h.Hash,o));return t=be(d),Ea(t,e,r,n,o)},va=Ea;function tt(t){return t?.extended===!1}var Fr=globalThis.CustomEvent??Event;async function*Ne(t,e={}){let r=e.concurrency??1/0;r<1&&(r=1/0);let n=e.ordered??!1,o=new EventTarget,i=[],s=$(),a=$(),c=!1,h,d=!1;o.addEventListener("task-complete",()=>{a.resolve()}),Promise.resolve().then(async()=>{try{for await(let l of t){if(i.length===r&&(s=$(),await s.promise),d)break;let m={done:!1};i.push(m),l().then(I=>{m.done=!0,m.ok=!0,m.value=I,o.dispatchEvent(new Fr("task-complete"))},I=>{m.done=!0,m.err=I,o.dispatchEvent(new Fr("task-complete"))})}c=!0,o.dispatchEvent(new Fr("task-complete"))}catch(l){h=l,o.dispatchEvent(new Fr("task-complete"))}});function p(){return n?i[0]?.done:!!i.find(l=>l.done)}function*k(){for(;i.length>0&&i[0].done;){let l=i[0];if(i.shift(),l.ok)yield l.value;else throw d=!0,s.resolve(),l.err;s.resolve()}}function*u(){for(;p();)for(let l=0;l<i.length;l++)if(i[l].done){let m=i[l];if(i.splice(l,1),l--,m.ok)yield m.value;else throw d=!0,s.resolve(),m.err;s.resolve()}}for(;;){if(p()||(a=$(),await a.promise),h!=null||(n?yield*k():yield*u(),h!=null))throw h;if(c&&i.length===0)break}}var wl=(t,e,r,n,o,i,s)=>{async function*a(c={}){let h=c.offset??0,d=c.length??e.Links.length,p=e.Links.slice(h,d);c.onProgress?.(new R("unixfs:exporter:walk:directory",{cid:t})),yield*Xe(p,k=>ge(k,u=>async()=>{let l=u.Name??"",m=`${n}/${l}`;return tt(c)?{cid:u.Hash,name:l,path:m}:(await o(u.Hash,l,m,[],i+1,s,c)).entry}),k=>Ne(k,{ordered:!0,concurrency:c.blockReadConcurrency}),k=>Ks(k,u=>u!=null))}return a},ka=wl;async function _a(t,e,r,n,o,i,s){if(e instanceof Uint8Array){let h=Se(e,n,o,i);r.push(h);return}if(e.Data==null)throw new P("no data in PBNode");let a;try{a=ae.unmarshal(e.Data)}catch(h){throw new P(h.message)}if(a.data!=null){let h=a.data,d=Se(h,n,o,i);r.push(d),n+=BigInt(d.byteLength)}let c=[];if(e.Links.length!==a.blockSizes.length)throw new P("Inconsistent block sizes and dag links");for(let h=0;h<e.Links.length;h++){let d=e.Links[h],p=n,k=p+a.blockSizes[h];if((o>=p&&o<k||i>=p&&i<=k||o<p&&i>k)&&c.push({link:d,blockStart:n}),n=k,n>i)break}await Xe(c,h=>ge(h,d=>async()=>{let p=await D(t.get(d.link.Hash,s));return{...d,block:p}}),h=>Ne(h,{ordered:!0,concurrency:s.blockReadConcurrency}),async h=>{for await(let{link:d,block:p,blockStart:k}of h){let u;switch(d.Hash.code){case vr:u=be(p);break;case ur:u=p;break;default:r.end(new P(`Unsupported codec: ${d.Hash.code}`));return}let l=new Et({concurrency:1});l.on("error",m=>{r.end(m)}),l.add(async()=>{s.onProgress?.(new R("unixfs:exporter:walk:file",{cid:d.Hash})),await _a(t,u,r,k,o,i,s)}),await l.onIdle()}}),n>=i&&r.end()}var xl=(t,e,r,n,o,i,s)=>{async function*a(c={}){let h=r.fileSize();if(h===void 0)throw new Error("File was a directory");let{start:d,end:p}=et(h,c.offset,c.length);if(p===0n)return;let k=0n,u=p-d,l=Je();c.onProgress?.(new R("unixfs:exporter:walk:file",{cid:t})),_a(s,e,l,0n,d,p,c).catch(m=>{l.end(m)});for await(let m of l)if(m!=null){if(k+=BigInt(m.byteLength),k>u)throw l.end(),new Sr("Read too many bytes - the file size reported by the UnixFS data in the root node may be incorrect");k===u&&l.end(),c.onProgress?.(new R("unixfs:exporter:progress:unixfs:file",{bytesRead:k,totalBytes:u,fileSize:h})),yield m}if(k<u)throw new Br("Traversed entire DAG but did not read enough bytes")}return a},vo=xl;var bl=(t,e,r,n,o,i,s)=>{function a(c={}){return c.onProgress?.(new R("unixfs:exporter:walk:hamt-sharded-directory",{cid:t})),Aa(e,n,o,i,s,c)}return a};async function*Aa(t,e,r,n,o,i){let s=t.Links;if(t.Data==null)throw new P("no data in PBNode");let a;try{a=ae.unmarshal(t.Data)}catch(d){throw new P(d.message)}if(a.fanout==null)throw new P("missing fanout");let c=(a.fanout-1n).toString(16).length,h=Xe(s,d=>ge(d,p=>async()=>{let k=p.Name!=null?p.Name.substring(c):null;if(k!=null&&k!==""){let u=`${e}/${k}`;return tt(i)?{entries:[{cid:p.Hash,name:k,path:u}]}:{entries:[(await r(p.Hash,k,u,[],n+1,o,i)).entry].filter(Boolean)}}else{let u=await D(o.get(p.Hash,i));return t=be(u),i.onProgress?.(new R("unixfs:exporter:walk:hamt-sharded-directory",{cid:p.Hash})),{entries:Aa(t,e,r,n,o,i)}}}),d=>Ne(d,{ordered:!0,concurrency:i.blockReadConcurrency}));for await(let{entries:d}of h)yield*d}var Ia=bl;var El=(t,e)=>t.Links.find(n=>n.Name===e)?.Hash,vl={raw:vo,file:vo,directory:ka,"hamt-sharded-directory":Ia,metadata:(t,e,r,n,o,i,s)=>()=>[],symlink:(t,e,r,n,o,i,s)=>()=>[]},kl=async(t,e,r,n,o,i,s,a)=>{if(tt(a)&&n.length===0)return{entry:{cid:t,name:e,path:r}};let c=await D(s.get(t,a)),h=be(c),d,p;if(e==null&&(e=t.toString()),h.Data==null)throw new P("no data in PBNode");try{d=ae.unmarshal(h.Data)}catch(u){throw new P(u.message)}if(r==null&&(r=e),n.length>0){let u;if(d?.type==="hamt-sharded-directory"?u=await va(h,n[0],s):u=El(h,n[0]),u==null)throw new te("file does not exist");let l=n.shift(),m=`${r}/${l}`;p={cid:u,toResolve:n,name:l??"",path:m}}let k=vl[d.type](t,h,d,r,o,i,s);if(k==null)throw new te("could not find content exporter");return d.isDirectory()?{entry:{type:"directory",name:e,path:r,cid:t,content:k,unixfs:d,depth:i,node:h,size:d.fileSize()},next:p}:{entry:{type:"file",name:e,path:r,cid:t,content:k,unixfs:d,depth:i,node:h,size:d.fileSize()},next:p}},Ta=kl;var _l={[vr]:Ta,[ur]:na,[Mi]:Zs,[zs]:ea,[Rn.code]:ta,[is]:ra},Sa=async(t,e,r,n,o,i,s)=>{let a=_l[t.code];if(a==null)throw new Tr(`No resolver for code ${t.code}`);return a(t,e,r,n,Sa,o,i,s)},Ba=Sa;var Al=(t="")=>(t.trim().match(/([^\\^/]|\\\/)+/g)??[]).filter(Boolean),Il=t=>{if(t instanceof Uint8Array)return{cid:N.decode(t),toResolve:[]};let e=N.asCID(t);if(e!=null)return{cid:e,toResolve:[]};if(typeof t=="string"){t.indexOf("/ipfs/")===0&&(t=t.substring(6));let r=Al(t);return{cid:N.parse(r[0]),toResolve:r.slice(1)}}throw new Ir(`Unknown path type ${t}`)};async function*Na(t,e,r={}){let{cid:n,toResolve:o}=Il(t),i=n.toString(),s=i,a=o.length;for(;;){let c=await Ba(n,i,s,o,a,e,r);if(c.entry==null&&c.next==null)throw new te(`Could not resolve ${t}`);if(c.entry!=null&&(yield c.entry),c.next==null)return;o=c.next.toResolve,n=c.next.cid,i=c.next.name,s=c.next.path}}var ko=class{root;path;constructor(...e){let r=e[0],n=e[1];if(typeof r=="string")n=r,r=void 0;else if(e.length<2)throw new Error("path or CID and path must be specified");n.startsWith("/")||(n=`/${n}`),this.root=r,this.path=n}async*traverse(e,r,n,o){for await(let i of Na(`${this.root??e}${this.path}`,r,o))yield ee({cid:i.cid,bytes:i.node instanceof Uint8Array?i.node:Qs(i.node),codec:await n(i.cid.code)})}};function Tl(t){return new kr(t)}return Ra(Sl);})();
|
|
2
|
+
"use strict";var HeliaCar=(()=>{var Da=Object.create;var $t=Object.defineProperty;var La=Object.getOwnPropertyDescriptor;var Pa=Object.getOwnPropertyNames;var Ua=Object.getPrototypeOf,Ra=Object.prototype.hasOwnProperty;var ue=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),V=(r,e)=>{for(var t in e)$t(r,t,{get:e[t],enumerable:!0})},Io=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Pa(e))!Ra.call(r,o)&&o!==t&&$t(r,o,{get:()=>e[o],enumerable:!(n=La(e,o))||n.enumerable});return r};var Ee=(r,e,t)=>(t=r!=null?Da(Ua(r)):{},Io(e||!r||!r.__esModule?$t(t,"default",{value:r,enumerable:!0}):t,r)),Fa=r=>Io($t({},"__esModule",{value:!0}),r);var qi=ue((Wh,Vi)=>{Vi.exports=hn;var Hi=128,iu=127,su=~iu,au=Math.pow(2,31);function hn(r,e,t){if(Number.MAX_SAFE_INTEGER&&r>Number.MAX_SAFE_INTEGER)throw hn.bytes=0,new RangeError("Could not encode varint");e=e||[],t=t||0;for(var n=t;r>=au;)e[t++]=r&255|Hi,r/=128;for(;r&su;)e[t++]=r&255|Hi,r>>>=7;return e[t]=r|0,hn.bytes=t-n+1,e}});var Wi=ue((Jh,ji)=>{ji.exports=dn;var cu=128,Gi=127;function dn(r,n){var t=0,n=n||0,o=0,i=n,s,a=r.length;do{if(i>=a||o>49)throw dn.bytes=0,new RangeError("Could not decode varint");s=r[i++],t+=o<28?(s&Gi)<<o:(s&Gi)*Math.pow(2,o),o+=7}while(s>=cu);return dn.bytes=i-n,t}});var Xi=ue((Xh,Ji)=>{var uu=Math.pow(2,7),fu=Math.pow(2,14),lu=Math.pow(2,21),hu=Math.pow(2,28),du=Math.pow(2,35),pu=Math.pow(2,42),mu=Math.pow(2,49),yu=Math.pow(2,56),gu=Math.pow(2,63);Ji.exports=function(r){return r<uu?1:r<fu?2:r<lu?3:r<hu?4:r<du?5:r<pu?6:r<mu?7:r<yu?8:r<gu?9:10}});var tr=ue((Qh,Qi)=>{Qi.exports={encode:qi(),decode:Wi(),encodingLength:Xi()}});var os=ue((np,An)=>{"use strict";var Uu=Object.prototype.hasOwnProperty,O="~";function wt(){}Object.create&&(wt.prototype=Object.create(null),new wt().__proto__||(O=!1));function Ru(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function ns(r,e,t,n,o){if(typeof t!="function")throw new TypeError("The listener must be a function");var i=new Ru(t,n||r,o),s=O?O+e:e;return r._events[s]?r._events[s].fn?r._events[s]=[r._events[s],i]:r._events[s].push(i):(r._events[s]=i,r._eventsCount++),r}function cr(r,e){--r._eventsCount===0?r._events=new wt:delete r._events[e]}function z(){this._events=new wt,this._eventsCount=0}z.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)Uu.call(t,n)&&e.push(O?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};z.prototype.listeners=function(e){var t=O?O+e:e,n=this._events[t];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};z.prototype.listenerCount=function(e){var t=O?O+e:e,n=this._events[t];return n?n.fn?1:n.length:0};z.prototype.emit=function(e,t,n,o,i,s){var a=O?O+e:e;if(!this._events[a])return!1;var c=this._events[a],h=arguments.length,d,p;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),h){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,o),!0;case 5:return c.fn.call(c.context,t,n,o,i),!0;case 6:return c.fn.call(c.context,t,n,o,i,s),!0}for(p=1,d=new Array(h-1);p<h;p++)d[p-1]=arguments[p];c.fn.apply(c.context,d)}else{var v=c.length,u;for(p=0;p<v;p++)switch(c[p].once&&this.removeListener(e,c[p].fn,void 0,!0),h){case 1:c[p].fn.call(c[p].context);break;case 2:c[p].fn.call(c[p].context,t);break;case 3:c[p].fn.call(c[p].context,t,n);break;case 4:c[p].fn.call(c[p].context,t,n,o);break;default:if(!d)for(u=1,d=new Array(h-1);u<h;u++)d[u-1]=arguments[u];c[p].fn.apply(c[p].context,d)}}return!0};z.prototype.on=function(e,t,n){return ns(this,e,t,n,!1)};z.prototype.once=function(e,t,n){return ns(this,e,t,n,!0)};z.prototype.removeListener=function(e,t,n,o){var i=O?O+e:e;if(!this._events[i])return this;if(!t)return cr(this,i),this;var s=this._events[i];if(s.fn)s.fn===t&&(!o||s.once)&&(!n||s.context===n)&&cr(this,i);else{for(var a=0,c=[],h=s.length;a<h;a++)(s[a].fn!==t||o&&!s[a].once||n&&s[a].context!==n)&&c.push(s[a]);c.length?this._events[i]=c.length===1?c[0]:c:cr(this,i)}return this};z.prototype.removeAllListeners=function(e){var t;return e?(t=O?O+e:e,this._events[t]&&cr(this,t)):(this._events=new wt,this._eventsCount=0),this};z.prototype.off=z.prototype.removeListener;z.prototype.addListener=z.prototype.on;z.prefixed=O;z.EventEmitter=z;typeof An<"u"&&(An.exports=z)});var gs=ue((tm,ys)=>{ys.exports=function(r){if(!r)throw Error("hashlru must have a max value, of type number, greater than 0");var e=0,t=Object.create(null),n=Object.create(null);function o(i,s){t[i]=s,e++,e>=r&&(e=0,n=t,t=Object.create(null))}return{has:function(i){return t[i]!==void 0||n[i]!==void 0},remove:function(i){t[i]!==void 0&&(t[i]=void 0),n[i]!==void 0&&(n[i]=void 0)},get:function(i){var s=t[i];if(s!==void 0)return s;if((s=n[i])!==void 0)return o(i,s),s},set:function(i,s){t[i]!==void 0?t[i]=s:o(i,s)},clear:function(){t=Object.create(null),n=Object.create(null)}}}});var fa=ue((Rt,Ur)=>{(function(r,e){"use strict";var t={version:"3.0.0",x86:{},x64:{},inputValidation:!0};function n(u){if(!Array.isArray(u)&&!ArrayBuffer.isView(u))return!1;for(var l=0;l<u.length;l++)if(!Number.isInteger(u[l])||u[l]<0||u[l]>255)return!1;return!0}function o(u,l){return(u&65535)*l+(((u>>>16)*l&65535)<<16)}function i(u,l){return u<<l|u>>>32-l}function s(u){return u^=u>>>16,u=o(u,2246822507),u^=u>>>13,u=o(u,3266489909),u^=u>>>16,u}function a(u,l){u=[u[0]>>>16,u[0]&65535,u[1]>>>16,u[1]&65535],l=[l[0]>>>16,l[0]&65535,l[1]>>>16,l[1]&65535];var m=[0,0,0,0];return m[3]+=u[3]+l[3],m[2]+=m[3]>>>16,m[3]&=65535,m[2]+=u[2]+l[2],m[1]+=m[2]>>>16,m[2]&=65535,m[1]+=u[1]+l[1],m[0]+=m[1]>>>16,m[1]&=65535,m[0]+=u[0]+l[0],m[0]&=65535,[m[0]<<16|m[1],m[2]<<16|m[3]]}function c(u,l){u=[u[0]>>>16,u[0]&65535,u[1]>>>16,u[1]&65535],l=[l[0]>>>16,l[0]&65535,l[1]>>>16,l[1]&65535];var m=[0,0,0,0];return m[3]+=u[3]*l[3],m[2]+=m[3]>>>16,m[3]&=65535,m[2]+=u[2]*l[3],m[1]+=m[2]>>>16,m[2]&=65535,m[2]+=u[3]*l[2],m[1]+=m[2]>>>16,m[2]&=65535,m[1]+=u[1]*l[3],m[0]+=m[1]>>>16,m[1]&=65535,m[1]+=u[2]*l[2],m[0]+=m[1]>>>16,m[1]&=65535,m[1]+=u[3]*l[1],m[0]+=m[1]>>>16,m[1]&=65535,m[0]+=u[0]*l[3]+u[1]*l[2]+u[2]*l[1]+u[3]*l[0],m[0]&=65535,[m[0]<<16|m[1],m[2]<<16|m[3]]}function h(u,l){return l%=64,l===32?[u[1],u[0]]:l<32?[u[0]<<l|u[1]>>>32-l,u[1]<<l|u[0]>>>32-l]:(l-=32,[u[1]<<l|u[0]>>>32-l,u[0]<<l|u[1]>>>32-l])}function d(u,l){return l%=64,l===0?u:l<32?[u[0]<<l|u[1]>>>32-l,u[1]<<l]:[u[1]<<l-32,0]}function p(u,l){return[u[0]^l[0],u[1]^l[1]]}function v(u){return u=p(u,[0,u[0]>>>1]),u=c(u,[4283543511,3981806797]),u=p(u,[0,u[0]>>>1]),u=c(u,[3301882366,444984403]),u=p(u,[0,u[0]>>>1]),u}t.x86.hash32=function(u,l){if(t.inputValidation&&!n(u))return e;l=l||0;for(var m=u.length%4,I=u.length-m,g=l,w=0,b=3432918353,k=461845907,A=0;A<I;A=A+4)w=u[A]|u[A+1]<<8|u[A+2]<<16|u[A+3]<<24,w=o(w,b),w=i(w,15),w=o(w,k),g^=w,g=i(g,13),g=o(g,5)+3864292196;switch(w=0,m){case 3:w^=u[A+2]<<16;case 2:w^=u[A+1]<<8;case 1:w^=u[A],w=o(w,b),w=i(w,15),w=o(w,k),g^=w}return g^=u.length,g=s(g),g>>>0},t.x86.hash128=function(u,l){if(t.inputValidation&&!n(u))return e;l=l||0;for(var m=u.length%16,I=u.length-m,g=l,w=l,b=l,k=l,A=0,T=0,E=0,C=0,ce=597399067,Ft=2869860233,zt=951274213,Mt=2716044179,S=0;S<I;S=S+16)A=u[S]|u[S+1]<<8|u[S+2]<<16|u[S+3]<<24,T=u[S+4]|u[S+5]<<8|u[S+6]<<16|u[S+7]<<24,E=u[S+8]|u[S+9]<<8|u[S+10]<<16|u[S+11]<<24,C=u[S+12]|u[S+13]<<8|u[S+14]<<16|u[S+15]<<24,A=o(A,ce),A=i(A,15),A=o(A,Ft),g^=A,g=i(g,19),g+=w,g=o(g,5)+1444728091,T=o(T,Ft),T=i(T,16),T=o(T,zt),w^=T,w=i(w,17),w+=b,w=o(w,5)+197830471,E=o(E,zt),E=i(E,17),E=o(E,Mt),b^=E,b=i(b,15),b+=k,b=o(b,5)+2530024501,C=o(C,Mt),C=i(C,18),C=o(C,ce),k^=C,k=i(k,13),k+=g,k=o(k,5)+850148119;switch(A=0,T=0,E=0,C=0,m){case 15:C^=u[S+14]<<16;case 14:C^=u[S+13]<<8;case 13:C^=u[S+12],C=o(C,Mt),C=i(C,18),C=o(C,ce),k^=C;case 12:E^=u[S+11]<<24;case 11:E^=u[S+10]<<16;case 10:E^=u[S+9]<<8;case 9:E^=u[S+8],E=o(E,zt),E=i(E,17),E=o(E,Mt),b^=E;case 8:T^=u[S+7]<<24;case 7:T^=u[S+6]<<16;case 6:T^=u[S+5]<<8;case 5:T^=u[S+4],T=o(T,Ft),T=i(T,16),T=o(T,zt),w^=T;case 4:A^=u[S+3]<<24;case 3:A^=u[S+2]<<16;case 2:A^=u[S+1]<<8;case 1:A^=u[S],A=o(A,ce),A=i(A,15),A=o(A,Ft),g^=A}return g^=u.length,w^=u.length,b^=u.length,k^=u.length,g+=w,g+=b,g+=k,w+=g,b+=g,k+=g,g=s(g),w=s(w),b=s(b),k=s(k),g+=w,g+=b,g+=k,w+=g,b+=g,k+=g,("00000000"+(g>>>0).toString(16)).slice(-8)+("00000000"+(w>>>0).toString(16)).slice(-8)+("00000000"+(b>>>0).toString(16)).slice(-8)+("00000000"+(k>>>0).toString(16)).slice(-8)},t.x64.hash128=function(u,l){if(t.inputValidation&&!n(u))return e;l=l||0;for(var m=u.length%16,I=u.length-m,g=[0,l],w=[0,l],b=[0,0],k=[0,0],A=[2277735313,289559509],T=[1291169091,658871167],E=0;E<I;E=E+16)b=[u[E+4]|u[E+5]<<8|u[E+6]<<16|u[E+7]<<24,u[E]|u[E+1]<<8|u[E+2]<<16|u[E+3]<<24],k=[u[E+12]|u[E+13]<<8|u[E+14]<<16|u[E+15]<<24,u[E+8]|u[E+9]<<8|u[E+10]<<16|u[E+11]<<24],b=c(b,A),b=h(b,31),b=c(b,T),g=p(g,b),g=h(g,27),g=a(g,w),g=a(c(g,[0,5]),[0,1390208809]),k=c(k,T),k=h(k,33),k=c(k,A),w=p(w,k),w=h(w,31),w=a(w,g),w=a(c(w,[0,5]),[0,944331445]);switch(b=[0,0],k=[0,0],m){case 15:k=p(k,d([0,u[E+14]],48));case 14:k=p(k,d([0,u[E+13]],40));case 13:k=p(k,d([0,u[E+12]],32));case 12:k=p(k,d([0,u[E+11]],24));case 11:k=p(k,d([0,u[E+10]],16));case 10:k=p(k,d([0,u[E+9]],8));case 9:k=p(k,[0,u[E+8]]),k=c(k,T),k=h(k,33),k=c(k,A),w=p(w,k);case 8:b=p(b,d([0,u[E+7]],56));case 7:b=p(b,d([0,u[E+6]],48));case 6:b=p(b,d([0,u[E+5]],40));case 5:b=p(b,d([0,u[E+4]],32));case 4:b=p(b,d([0,u[E+3]],24));case 3:b=p(b,d([0,u[E+2]],16));case 2:b=p(b,d([0,u[E+1]],8));case 1:b=p(b,[0,u[E]]),b=c(b,A),b=h(b,31),b=c(b,T),g=p(g,b)}return g=p(g,[0,u.length]),w=p(w,[0,u.length]),g=a(g,w),w=a(w,g),g=v(g),w=v(w),g=a(g,w),w=a(w,g),("00000000"+(g[0]>>>0).toString(16)).slice(-8)+("00000000"+(g[1]>>>0).toString(16)).slice(-8)+("00000000"+(w[0]>>>0).toString(16)).slice(-8)+("00000000"+(w[1]>>>0).toString(16)).slice(-8)},typeof Rt<"u"?(typeof Ur<"u"&&Ur.exports&&(Rt=Ur.exports=t),Rt.murmurHash3=t):typeof define=="function"&&define.amd?define([],function(){return t}):(t._murmurHash3=r.murmurHash3,t.noConflict=function(){return r.murmurHash3=t._murmurHash3,t._murmurHash3=e,t.noConflict=e,t},r.murmurHash3=t)})(Rt)});var ha=ue((Rg,la)=>{la.exports=fa()});var ya=ue((Vg,ma)=>{"use strict";ma.exports=class{constructor(){this._bitArrays=[],this._data=[],this._length=0,this._changedLength=!1,this._changedData=!1}set(e,t){let n=this._internalPositionFor(e,!1);if(t===void 0)n!==-1&&(this._unsetInternalPos(n),this._unsetBit(e),this._changedLength=!0,this._changedData=!0);else{let o=!1;n===-1?(n=this._data.length,this._setBit(e),this._changedData=!0):o=!0,this._setInternalPos(n,e,t,o),this._changedLength=!0}}unset(e){this.set(e,void 0)}get(e){this._sortData();let t=this._internalPositionFor(e,!0);if(t!==-1)return this._data[t][1]}push(e){return this.set(this.length,e),this.length}get length(){if(this._sortData(),this._changedLength){let e=this._data[this._data.length-1];this._length=e?e[0]+1:0,this._changedLength=!1}return this._length}forEach(e){let t=0;for(;t<this.length;)e(this.get(t),t,this),t++}map(e){let t=0,n=new Array(this.length);for(;t<this.length;)n[t]=e(this.get(t),t,this),t++;return n}reduce(e,t){let n=0,o=t;for(;n<this.length;){let i=this.get(n);o=e(o,i,n),n++}return o}find(e){let t=0,n,o;for(;t<this.length&&!n;)o=this.get(t),n=e(o),t++;return n?o:void 0}_internalPositionFor(e,t){let n=this._bytePosFor(e,t);if(n>=this._bitArrays.length)return-1;let o=this._bitArrays[n],i=e-n*7;if(!((o&1<<i)>0))return-1;let a=this._bitArrays.slice(0,n).reduce(sl,0),c=~(4294967295<<i+1),h=pa(o&c);return a+h-1}_bytePosFor(e,t){let n=Math.floor(e/7),o=n+1;for(;!t&&this._bitArrays.length<o;)this._bitArrays.push(0);return n}_setBit(e){let t=this._bytePosFor(e,!1);this._bitArrays[t]|=1<<e-t*7}_unsetBit(e){let t=this._bytePosFor(e,!1);this._bitArrays[t]&=~(1<<e-t*7)}_setInternalPos(e,t,n,o){let i=this._data,s=[t,n];if(o)this._sortData(),i[e]=s;else{if(i.length)if(i[i.length-1][0]>=t)i.push(s);else if(i[0][0]<=t)i.unshift(s);else{let a=Math.round(i.length/2);this._data=i.slice(0,a).concat(s).concat(i.slice(a))}else this._data.push(s);this._changedData=!0,this._changedLength=!0}}_unsetInternalPos(e){this._data.splice(e,1)}_sortData(){this._changedData&&this._data.sort(al),this._changedData=!1}bitField(){let e=[],t=8,n=0,o=0,i,s=this._bitArrays.slice();for(;s.length||n;){n===0&&(i=s.shift(),n=7);let c=Math.min(n,t),h=~(255<<c),d=i&h;o|=d<<8-t,i=i>>>c,n-=c,t-=c,(!t||!n&&!s.length)&&(e.push(o),o=0,t=8)}for(var a=e.length-1;a>0&&e[a]===0;a--)e.pop();return e}compactArray(){return this._sortData(),this._data.map(cl)}};function sl(r,e){return r+pa(e)}function pa(r){let e=r;return e=e-(e>>1&1431655765),e=(e&858993459)+(e>>2&858993459),(e+(e>>4)&252645135)*16843009>>24}function al(r,e){return r[0]-e[0]}function cl(r){return r[1]}});var Bl={};V(Bl,{BlockExporter:()=>Eo,CIDPath:()=>ko,GraphSearch:()=>vo,SubgraphExporter:()=>Lt,UnixFSExporter:()=>Pt,UnixFSPath:()=>Ao,car:()=>Sl});var za=["string","number","bigint","symbol"],Ma=["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 To(r){if(r===null)return"null";if(r===void 0)return"undefined";if(r===!0||r===!1)return"boolean";let e=typeof r;if(za.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(r))return"Array";if($a(r))return"Buffer";let t=Oa(r);return t||"Object"}function $a(r){return r&&r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer.call(null,r)}function Oa(r){let e=Object.prototype.toString.call(r).slice(8,-1);if(Ma.includes(e))return e}var f=class{constructor(e,t,n){this.major=e,this.majorEncoded=e<<5,this.name=t,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:this.major>e.major?1:0}};f.uint=new f(0,"uint",!0);f.negint=new f(1,"negint",!0);f.bytes=new f(2,"bytes",!0);f.string=new f(3,"string",!0);f.array=new f(4,"array",!1);f.map=new f(5,"map",!1);f.tag=new f(6,"tag",!1);f.float=new f(7,"float",!0);f.false=new f(7,"false",!0);f.true=new f(7,"true",!0);f.null=new f(7,"null",!0);f.undefined=new f(7,"undefined",!0);f.break=new f(7,"break",!0);var y=class{constructor(e,t,n){this.type=e,this.value=t,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var Ce=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Ha=new TextDecoder,Va=new TextEncoder;function Ot(r){return Ce&&globalThis.Buffer.isBuffer(r)}function rt(r){return r instanceof Uint8Array?Ot(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r:Uint8Array.from(r)}var Co=Ce?(r,e,t)=>t-e>64?globalThis.Buffer.from(r.subarray(e,t)).toString("utf8"):Bo(r,e,t):(r,e,t)=>t-e>64?Ha.decode(r.subarray(e,t)):Bo(r,e,t),Ht=Ce?r=>r.length>64?globalThis.Buffer.from(r):So(r):r=>r.length>64?Va.encode(r):So(r),re=r=>Uint8Array.from(r),De=Ce?(r,e,t)=>Ot(r)?new Uint8Array(r.subarray(e,t)):r.slice(e,t):(r,e,t)=>r.slice(e,t),Do=Ce?(r,e)=>(r=r.map(t=>t instanceof Uint8Array?t:globalThis.Buffer.from(t)),rt(globalThis.Buffer.concat(r,e))):(r,e)=>{let t=new Uint8Array(e),n=0;for(let o of r)n+o.length>t.length&&(o=o.subarray(0,t.length-n)),t.set(o,n),n+=o.length;return t},Lo=Ce?r=>globalThis.Buffer.allocUnsafe(r):r=>new Uint8Array(r);function Po(r,e){if(Ot(r)&&Ot(e))return r.compare(e);for(let t=0;t<r.length;t++)if(r[t]!==e[t])return r[t]<e[t]?-1:1;return 0}function So(r){let e=[],t=0;for(let n=0;n<r.length;n++){let o=r.charCodeAt(n);o<128?e[t++]=o:o<2048?(e[t++]=o>>6|192,e[t++]=o&63|128):(o&64512)===55296&&n+1<r.length&&(r.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(r.charCodeAt(++n)&1023),e[t++]=o>>18|240,e[t++]=o>>12&63|128,e[t++]=o>>6&63|128,e[t++]=o&63|128):(e[t++]=o>>12|224,e[t++]=o>>6&63|128,e[t++]=o&63|128)}return e}function Bo(r,e,t){let n=[];for(;e<t;){let o=r[e],i=null,s=o>239?4:o>223?3:o>191?2:1;if(e+s<=t){let a,c,h,d;switch(s){case 1:o<128&&(i=o);break;case 2:a=r[e+1],(a&192)===128&&(d=(o&31)<<6|a&63,d>127&&(i=d));break;case 3:a=r[e+1],c=r[e+2],(a&192)===128&&(c&192)===128&&(d=(o&15)<<12|(a&63)<<6|c&63,d>2047&&(d<55296||d>57343)&&(i=d));break;case 4:a=r[e+1],c=r[e+2],h=r[e+3],(a&192)===128&&(c&192)===128&&(h&192)===128&&(d=(o&15)<<18|(a&63)<<12|(c&63)<<6|h&63,d>65535&&d<1114112&&(i=d))}}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 $r(n)}var No=4096;function $r(r){let e=r.length;if(e<=No)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=No));return t}var qa=256,nt=class{constructor(e=qa){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 t=this.chunks[this.chunks.length-1];if(this.cursor+e.length<=this.maxCursor+1){let o=t.length-(this.maxCursor-this.cursor)-1;t.set(e,o)}else{if(t){let o=t.length-(this.maxCursor-this.cursor)-1;o<t.length&&(this.chunks[this.chunks.length-1]=t.subarray(0,o),this.maxCursor=this.cursor-1)}e.length<64&&e.length<this.chunkSize?(t=Lo(this.chunkSize),this.chunks.push(t),this.maxCursor+=t.length,this._initReuseChunk===null&&(this._initReuseChunk=t),t.set(e,0)):(this.chunks.push(e),this.maxCursor+=e.length)}this.cursor+=e.length}toBytes(e=!1){let t;if(this.chunks.length===1){let n=this.chunks[0];e&&this.cursor>n.length/2?(t=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):t=De(n,0,this.cursor)}else t=Do(this.chunks,this.cursor);return e&&this.reset(),t}};var _="CBOR decode error:",Le="CBOR encode error:",ot=[];ot[23]=1;ot[24]=2;ot[25]=3;ot[26]=5;ot[27]=9;function fe(r,e,t){if(r.length-e<t)throw new Error(`${_} not enough data for type`)}var U=[24,256,65536,4294967296,BigInt("18446744073709551616")];function q(r,e,t){fe(r,e,1);let n=r[e];if(t.strict===!0&&n<U[0])throw new Error(`${_} integer encoded in more bytes than necessary (strict decode)`);return n}function G(r,e,t){fe(r,e,2);let n=r[e]<<8|r[e+1];if(t.strict===!0&&n<U[1])throw new Error(`${_} integer encoded in more bytes than necessary (strict decode)`);return n}function j(r,e,t){fe(r,e,4);let n=r[e]*16777216+(r[e+1]<<16)+(r[e+2]<<8)+r[e+3];if(t.strict===!0&&n<U[2])throw new Error(`${_} integer encoded in more bytes than necessary (strict decode)`);return n}function W(r,e,t){fe(r,e,8);let n=r[e]*16777216+(r[e+1]<<16)+(r[e+2]<<8)+r[e+3],o=r[e+4]*16777216+(r[e+5]<<16)+(r[e+6]<<8)+r[e+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(t.strict===!0&&i<U[3])throw new Error(`${_} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(t.allowBigInt===!0)return i;throw new Error(`${_} integers outside of the safe integer range are not supported`)}function Uo(r,e,t,n){return new y(f.uint,q(r,e+1,n),2)}function Ro(r,e,t,n){return new y(f.uint,G(r,e+1,n),3)}function Fo(r,e,t,n){return new y(f.uint,j(r,e+1,n),5)}function zo(r,e,t,n){return new y(f.uint,W(r,e+1,n),9)}function X(r,e){return F(r,0,e.value)}function F(r,e,t){if(t<U[0]){let n=Number(t);r.push([e|n])}else if(t<U[1]){let n=Number(t);r.push([e|24,n])}else if(t<U[2]){let n=Number(t);r.push([e|25,n>>>8,n&255])}else if(t<U[3]){let n=Number(t);r.push([e|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(t);if(n<U[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,r.push(o)}else throw new Error(`${_} encountered BigInt larger than allowable range`)}}X.encodedSize=function(e){return F.encodedSize(e.value)};F.encodedSize=function(e){return e<U[0]?1:e<U[1]?2:e<U[2]?3:e<U[3]?5:9};X.compareTokens=function(e,t){return e.value<t.value?-1:e.value>t.value?1:0};function Mo(r,e,t,n){return new y(f.negint,-1-q(r,e+1,n),2)}function $o(r,e,t,n){return new y(f.negint,-1-G(r,e+1,n),3)}function Oo(r,e,t,n){return new y(f.negint,-1-j(r,e+1,n),5)}var Or=BigInt(-1),Ho=BigInt(1);function Vo(r,e,t,n){let o=W(r,e+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new y(f.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${_} integers outside of the safe integer range are not supported`);return new y(f.negint,Or-BigInt(o),9)}function Vt(r,e){let t=e.value,n=typeof t=="bigint"?t*Or-Ho:t*-1-1;F(r,e.type.majorEncoded,n)}Vt.encodedSize=function(e){let t=e.value,n=typeof t=="bigint"?t*Or-Ho:t*-1-1;return n<U[0]?1:n<U[1]?2:n<U[2]?3:n<U[3]?5:9};Vt.compareTokens=function(e,t){return e.value<t.value?1:e.value>t.value?-1:0};function it(r,e,t,n){fe(r,e,t+n);let o=De(r,e+t,e+t+n);return new y(f.bytes,o,t+n)}function qo(r,e,t,n){return it(r,e,1,t)}function Go(r,e,t,n){return it(r,e,2,q(r,e+1,n))}function jo(r,e,t,n){return it(r,e,3,G(r,e+1,n))}function Wo(r,e,t,n){return it(r,e,5,j(r,e+1,n))}function Jo(r,e,t,n){let o=W(r,e+1,n);if(typeof o=="bigint")throw new Error(`${_} 64-bit integer bytes lengths not supported`);return it(r,e,9,o)}function qt(r){return r.encodedBytes===void 0&&(r.encodedBytes=r.type===f.string?Ht(r.value):r.value),r.encodedBytes}function Pe(r,e){let t=qt(e);F(r,e.type.majorEncoded,t.length),r.push(t)}Pe.encodedSize=function(e){let t=qt(e);return F.encodedSize(t.length)+t.length};Pe.compareTokens=function(e,t){return ja(qt(e),qt(t))};function ja(r,e){return r.length<e.length?-1:r.length>e.length?1:Po(r,e)}function st(r,e,t,n,o){let i=t+n;fe(r,e,i);let s=new y(f.string,Co(r,e+t,e+i),i);return o.retainStringBytes===!0&&(s.byteValue=De(r,e+t,e+i)),s}function Xo(r,e,t,n){return st(r,e,1,t,n)}function Qo(r,e,t,n){return st(r,e,2,q(r,e+1,n),n)}function Ko(r,e,t,n){return st(r,e,3,G(r,e+1,n),n)}function Yo(r,e,t,n){return st(r,e,5,j(r,e+1,n),n)}function Zo(r,e,t,n){let o=W(r,e+1,n);if(typeof o=="bigint")throw new Error(`${_} 64-bit integer string lengths not supported`);return st(r,e,9,o,n)}var ei=Pe;function Ue(r,e,t,n){return new y(f.array,n,t)}function ti(r,e,t,n){return Ue(r,e,1,t)}function ri(r,e,t,n){return Ue(r,e,2,q(r,e+1,n))}function ni(r,e,t,n){return Ue(r,e,3,G(r,e+1,n))}function oi(r,e,t,n){return Ue(r,e,5,j(r,e+1,n))}function ii(r,e,t,n){let o=W(r,e+1,n);if(typeof o=="bigint")throw new Error(`${_} 64-bit integer array lengths not supported`);return Ue(r,e,9,o)}function si(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${_} indefinite length items not allowed`);return Ue(r,e,1,1/0)}function Gt(r,e){F(r,f.array.majorEncoded,e.value)}Gt.compareTokens=X.compareTokens;Gt.encodedSize=function(e){return F.encodedSize(e.value)};function Re(r,e,t,n){return new y(f.map,n,t)}function ai(r,e,t,n){return Re(r,e,1,t)}function ci(r,e,t,n){return Re(r,e,2,q(r,e+1,n))}function ui(r,e,t,n){return Re(r,e,3,G(r,e+1,n))}function fi(r,e,t,n){return Re(r,e,5,j(r,e+1,n))}function li(r,e,t,n){let o=W(r,e+1,n);if(typeof o=="bigint")throw new Error(`${_} 64-bit integer map lengths not supported`);return Re(r,e,9,o)}function hi(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${_} indefinite length items not allowed`);return Re(r,e,1,1/0)}function jt(r,e){F(r,f.map.majorEncoded,e.value)}jt.compareTokens=X.compareTokens;jt.encodedSize=function(e){return F.encodedSize(e.value)};function di(r,e,t,n){return new y(f.tag,t,1)}function pi(r,e,t,n){return new y(f.tag,q(r,e+1,n),2)}function mi(r,e,t,n){return new y(f.tag,G(r,e+1,n),3)}function yi(r,e,t,n){return new y(f.tag,j(r,e+1,n),5)}function gi(r,e,t,n){return new y(f.tag,W(r,e+1,n),9)}function Wt(r,e){F(r,f.tag.majorEncoded,e.value)}Wt.compareTokens=X.compareTokens;Wt.encodedSize=function(e){return F.encodedSize(e.value)};var Ya=20,Za=21,ec=22,tc=23;function xi(r,e,t,n){if(n.allowUndefined===!1)throw new Error(`${_} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new y(f.null,null,1):new y(f.undefined,void 0,1)}function wi(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${_} indefinite length items not allowed`);return new y(f.break,void 0,1)}function Hr(r,e,t){if(t){if(t.allowNaN===!1&&Number.isNaN(r))throw new Error(`${_} NaN values are not supported`);if(t.allowInfinity===!1&&(r===1/0||r===-1/0))throw new Error(`${_} Infinity values are not supported`)}return new y(f.float,r,e)}function bi(r,e,t,n){return Hr(Vr(r,e+1),3,n)}function Ei(r,e,t,n){return Hr(qr(r,e+1),5,n)}function vi(r,e,t,n){return Hr(Ii(r,e+1),9,n)}function Jt(r,e,t){let n=e.value;if(n===!1)r.push([f.float.majorEncoded|Ya]);else if(n===!0)r.push([f.float.majorEncoded|Za]);else if(n===null)r.push([f.float.majorEncoded|ec]);else if(n===void 0)r.push([f.float.majorEncoded|tc]);else{let o,i=!1;(!t||t.float64!==!0)&&(_i(n),o=Vr(K,1),n===o||Number.isNaN(n)?(K[0]=249,r.push(K.slice(0,3)),i=!0):(Ai(n),o=qr(K,1),n===o&&(K[0]=250,r.push(K.slice(0,5)),i=!0))),i||(rc(n),o=Ii(K,1),K[0]=251,r.push(K.slice(0,9)))}}Jt.encodedSize=function(e,t){let n=e.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!t||t.float64!==!0){_i(n);let o=Vr(K,1);if(n===o||Number.isNaN(n))return 3;if(Ai(n),o=qr(K,1),n===o)return 5}return 9};var ki=new ArrayBuffer(9),Q=new DataView(ki,1),K=new Uint8Array(ki,0);function _i(r){if(r===1/0)Q.setUint16(0,31744,!1);else if(r===-1/0)Q.setUint16(0,64512,!1);else if(Number.isNaN(r))Q.setUint16(0,32256,!1);else{Q.setFloat32(0,r);let e=Q.getUint32(0),t=(e&2139095040)>>23,n=e&8388607;if(t===255)Q.setUint16(0,31744,!1);else if(t===0)Q.setUint16(0,(r&2147483648)>>16|n>>13,!1);else{let o=t-127;o<-24?Q.setUint16(0,0):o<-14?Q.setUint16(0,(e&2147483648)>>16|1<<24+o,!1):Q.setUint16(0,(e&2147483648)>>16|o+15<<10|n>>13,!1)}}}function Vr(r,e){if(r.length-e<2)throw new Error(`${_} not enough data for float16`);let t=(r[e]<<8)+r[e+1];if(t===31744)return 1/0;if(t===64512)return-1/0;if(t===32256)return NaN;let n=t>>10&31,o=t&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,t&32768?-i:i}function Ai(r){Q.setFloat32(0,r,!1)}function qr(r,e){if(r.length-e<4)throw new Error(`${_} not enough data for float32`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,4).getFloat32(0,!1)}function rc(r){Q.setFloat64(0,r,!1)}function Ii(r,e){if(r.length-e<8)throw new Error(`${_} not enough data for float64`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,8).getFloat64(0,!1)}Jt.compareTokens=X.compareTokens;function B(r,e,t){throw new Error(`${_} encountered invalid minor (${t}) for major ${r[e]>>>5}`)}function Xt(r){return()=>{throw new Error(`${_} ${r}`)}}var x=[];for(let r=0;r<=23;r++)x[r]=B;x[24]=Uo;x[25]=Ro;x[26]=Fo;x[27]=zo;x[28]=B;x[29]=B;x[30]=B;x[31]=B;for(let r=32;r<=55;r++)x[r]=B;x[56]=Mo;x[57]=$o;x[58]=Oo;x[59]=Vo;x[60]=B;x[61]=B;x[62]=B;x[63]=B;for(let r=64;r<=87;r++)x[r]=qo;x[88]=Go;x[89]=jo;x[90]=Wo;x[91]=Jo;x[92]=B;x[93]=B;x[94]=B;x[95]=Xt("indefinite length bytes/strings are not supported");for(let r=96;r<=119;r++)x[r]=Xo;x[120]=Qo;x[121]=Ko;x[122]=Yo;x[123]=Zo;x[124]=B;x[125]=B;x[126]=B;x[127]=Xt("indefinite length bytes/strings are not supported");for(let r=128;r<=151;r++)x[r]=ti;x[152]=ri;x[153]=ni;x[154]=oi;x[155]=ii;x[156]=B;x[157]=B;x[158]=B;x[159]=si;for(let r=160;r<=183;r++)x[r]=ai;x[184]=ci;x[185]=ui;x[186]=fi;x[187]=li;x[188]=B;x[189]=B;x[190]=B;x[191]=hi;for(let r=192;r<=215;r++)x[r]=di;x[216]=pi;x[217]=mi;x[218]=yi;x[219]=gi;x[220]=B;x[221]=B;x[222]=B;x[223]=B;for(let r=224;r<=243;r++)x[r]=Xt("simple values are not supported");x[244]=B;x[245]=B;x[246]=B;x[247]=xi;x[248]=Xt("simple values are not supported");x[249]=bi;x[250]=Ei;x[251]=vi;x[252]=B;x[253]=B;x[254]=B;x[255]=wi;var Y=[];for(let r=0;r<24;r++)Y[r]=new y(f.uint,r,1);for(let r=-1;r>=-24;r--)Y[31-r]=new y(f.negint,r,1);Y[64]=new y(f.bytes,new Uint8Array(0),1);Y[96]=new y(f.string,"",1);Y[128]=new y(f.array,0,1);Y[160]=new y(f.map,0,1);Y[244]=new y(f.false,!1,1);Y[245]=new y(f.true,!0,1);Y[246]=new y(f.null,null,1);function Gr(r){switch(r.type){case f.false:return re([244]);case f.true:return re([245]);case f.null:return re([246]);case f.bytes:return r.value.length?void 0:re([64]);case f.string:return r.value===""?re([96]):void 0;case f.array:return r.value===0?re([128]):void 0;case f.map:return r.value===0?re([160]):void 0;case f.uint:return r.value<24?re([Number(r.value)]):void 0;case f.negint:if(r.value>=-24)return re([31-Number(r.value)])}}var oc={float64:!1,mapSorter:sc,quickEncodeToken:Gr};function Wr(){let r=[];return r[f.uint.major]=X,r[f.negint.major]=Vt,r[f.bytes.major]=Pe,r[f.string.major]=ei,r[f.array.major]=Gt,r[f.map.major]=jt,r[f.tag.major]=Wt,r[f.float.major]=Jt,r}var Ti=Wr(),jr=new nt,Qt=class r{constructor(e,t){this.obj=e,this.parent=t}includes(e){let t=this;do if(t.obj===e)return!0;while(t=t.parent);return!1}static createCheck(e,t){if(e&&e.includes(t))throw new Error(`${Le} object contains circular references`);return new r(t,e)}},he={null:new y(f.null,null),undefined:new y(f.undefined,void 0),true:new y(f.true,!0),false:new y(f.false,!1),emptyArray:new y(f.array,0),emptyMap:new y(f.map,0)},de={number(r,e,t,n){return!Number.isInteger(r)||!Number.isSafeInteger(r)?new y(f.float,r):r>=0?new y(f.uint,r):new y(f.negint,r)},bigint(r,e,t,n){return r>=BigInt(0)?new y(f.uint,r):new y(f.negint,r)},Uint8Array(r,e,t,n){return new y(f.bytes,r)},string(r,e,t,n){return new y(f.string,r)},boolean(r,e,t,n){return r?he.true:he.false},null(r,e,t,n){return he.null},undefined(r,e,t,n){return he.undefined},ArrayBuffer(r,e,t,n){return new y(f.bytes,new Uint8Array(r))},DataView(r,e,t,n){return new y(f.bytes,new Uint8Array(r.buffer,r.byteOffset,r.byteLength))},Array(r,e,t,n){if(!r.length)return t.addBreakTokens===!0?[he.emptyArray,new y(f.break)]:he.emptyArray;n=Qt.createCheck(n,r);let o=[],i=0;for(let s of r)o[i++]=at(s,t,n);return t.addBreakTokens?[new y(f.array,r.length),o,new y(f.break)]:[new y(f.array,r.length),o]},Object(r,e,t,n){let o=e!=="Object",i=o?r.keys():Object.keys(r),s=o?r.size:i.length;if(!s)return t.addBreakTokens===!0?[he.emptyMap,new y(f.break)]:he.emptyMap;n=Qt.createCheck(n,r);let a=[],c=0;for(let h of i)a[c++]=[at(h,t,n),at(o?r.get(h):r[h],t,n)];return ic(a,t),t.addBreakTokens?[new y(f.map,s),a,new y(f.break)]:[new y(f.map,s),a]}};de.Map=de.Object;de.Buffer=de.Uint8Array;for(let r of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))de[`${r}Array`]=de.DataView;function at(r,e={},t){let n=To(r),o=e&&e.typeEncoders&&e.typeEncoders[n]||de[n];if(typeof o=="function"){let s=o(r,n,e,t);if(s!=null)return s}let i=de[n];if(!i)throw new Error(`${Le} unsupported type: ${n}`);return i(r,n,e,t)}function ic(r,e){e.mapSorter&&r.sort(e.mapSorter)}function sc(r,e){let t=Array.isArray(r[0])?r[0][0]:r[0],n=Array.isArray(e[0])?e[0][0]:e[0];if(t.type!==n.type)return t.type.compare(n.type);let o=t.type.major,i=Ti[o].compareTokens(t,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function Si(r,e,t,n){if(Array.isArray(e))for(let o of e)Si(r,o,t,n);else t[e.type.major](r,e,n)}function Bi(r,e,t){let n=at(r,t);if(!Array.isArray(n)&&t.quickEncodeToken){let o=t.quickEncodeToken(n);if(o)return o;let i=e[n.type.major];if(i.encodedSize){let s=i.encodedSize(n,t),a=new nt(s);if(i(a,n,t),a.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return rt(a.chunks[0])}}return jr.reset(),Si(jr,n,e,t),jr.toBytes(!0)}function Jr(r,e){return e=Object.assign({},oc,e),Bi(r,Ti,e)}var ac={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Kt=class{constructor(e,t={}){this._pos=0,this.data=e,this.options=t}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let e=this.data[this._pos],t=Y[e];if(t===void 0){let n=x[e];if(!n)throw new Error(`${_} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);let o=e&31;t=n(this.data,this._pos,o,this.options)}return this._pos+=t.encodedLength,t}},ct=Symbol.for("DONE"),Yt=Symbol.for("BREAK");function cc(r,e,t){let n=[];for(let o=0;o<r.value;o++){let i=Fe(e,t);if(i===Yt){if(r.value===1/0)break;throw new Error(`${_} got unexpected break to lengthed array`)}if(i===ct)throw new Error(`${_} found array but not enough entries (got ${o}, expected ${r.value})`);n[o]=i}return n}function uc(r,e,t){let n=t.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let s=0;s<r.value;s++){let a=Fe(e,t);if(a===Yt){if(r.value===1/0)break;throw new Error(`${_} got unexpected break to lengthed map`)}if(a===ct)throw new Error(`${_} found map but not enough entries (got ${s} [no key], expected ${r.value})`);if(n!==!0&&typeof a!="string")throw new Error(`${_} non-string keys not supported (got ${typeof a})`);if(t.rejectDuplicateMapKeys===!0&&(n&&i.has(a)||!n&&a in o))throw new Error(`${_} found repeat map key "${a}"`);let c=Fe(e,t);if(c===ct)throw new Error(`${_} found map but not enough entries (got ${s} [no value], expected ${r.value})`);n?i.set(a,c):o[a]=c}return n?i:o}function Fe(r,e){if(r.done())return ct;let t=r.next();if(t.type===f.break)return Yt;if(t.type.terminal)return t.value;if(t.type===f.array)return cc(t,r,e);if(t.type===f.map)return uc(t,r,e);if(t.type===f.tag){if(e.tags&&typeof e.tags[t.value]=="function"){let n=Fe(r,e);return e.tags[t.value](n)}throw new Error(`${_} tag not supported (${t.value})`)}throw new Error("unsupported")}function Xr(r,e){if(!(r instanceof Uint8Array))throw new Error(`${_} data to decode must be a Uint8Array`);e=Object.assign({},ac,e);let t=e.tokenizer||new Kt(r,e),n=Fe(t,e);if(n===ct)throw new Error(`${_} did not find any content to decode`);if(n===Yt)throw new Error(`${_} got unexpected break`);return[n,r.subarray(t.pos())]}function ut(r,e){let[t,n]=Xr(r,e);if(n.length>0)throw new Error(`${_} too many terminals, data makes no sense`);return t}var nn={};V(nn,{base32:()=>Me,base32hex:()=>kc,base32hexpad:()=>Ac,base32hexpadupper:()=>Ic,base32hexupper:()=>_c,base32pad:()=>Ec,base32padupper:()=>vc,base32upper:()=>bc,base32z:()=>Tc});var ke={};V(ke,{coerce:()=>ne,empty:()=>Ni,equals:()=>Qr,fromHex:()=>hc,fromString:()=>Kr,isBinary:()=>dc,toHex:()=>lc,toString:()=>Yr});var Ni=new Uint8Array(0);function lc(r){return r.reduce((e,t)=>e+t.toString(16).padStart(2,"0"),"")}function hc(r){let e=r.match(/../g);return e!=null?new Uint8Array(e.map(t=>parseInt(t,16))):Ni}function Qr(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function ne(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function dc(r){return r instanceof ArrayBuffer||ArrayBuffer.isView(r)}function Kr(r){return new TextEncoder().encode(r)}function Yr(r){return new TextDecoder().decode(r)}function pc(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var o=0;o<r.length;o++){var i=r.charAt(o),s=i.charCodeAt(0);if(t[s]!==255)throw new TypeError(i+" is ambiguous");t[s]=o}var a=r.length,c=r.charAt(0),h=Math.log(a)/Math.log(256),d=Math.log(256)/Math.log(a);function p(l){if(l instanceof Uint8Array||(ArrayBuffer.isView(l)?l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):Array.isArray(l)&&(l=Uint8Array.from(l))),!(l instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(l.length===0)return"";for(var m=0,I=0,g=0,w=l.length;g!==w&&l[g]===0;)g++,m++;for(var b=(w-g)*d+1>>>0,k=new Uint8Array(b);g!==w;){for(var A=l[g],T=0,E=b-1;(A!==0||T<I)&&E!==-1;E--,T++)A+=256*k[E]>>>0,k[E]=A%a>>>0,A=A/a>>>0;if(A!==0)throw new Error("Non-zero carry");I=T,g++}for(var C=b-I;C!==b&&k[C]===0;)C++;for(var ce=c.repeat(m);C<b;++C)ce+=r.charAt(k[C]);return ce}function v(l){if(typeof l!="string")throw new TypeError("Expected String");if(l.length===0)return new Uint8Array;var m=0;if(l[m]!==" "){for(var I=0,g=0;l[m]===c;)I++,m++;for(var w=(l.length-m)*h+1>>>0,b=new Uint8Array(w);l[m];){var k=t[l.charCodeAt(m)];if(k===255)return;for(var A=0,T=w-1;(k!==0||A<g)&&T!==-1;T--,A++)k+=a*b[T]>>>0,b[T]=k%256>>>0,k=k/256>>>0;if(k!==0)throw new Error("Non-zero carry");g=A,m++}if(l[m]!==" "){for(var E=w-g;E!==w&&b[E]===0;)E++;for(var C=new Uint8Array(I+(w-E)),ce=I;E!==w;)C[ce++]=b[E++];return C}}}function u(l){var m=v(l);if(m)return m;throw new Error(`Non-${e} character`)}return{encode:p,decodeUnsafe:v,decode:u}}var mc=pc,yc=mc,Ci=yc;var Zr=class{name;prefix;baseEncode;constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},en=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){this.name=e,this.prefix=t;let o=t.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,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 Di(this,e)}},tn=class{decoders;constructor(e){this.decoders=e}or(e){return Di(this,e)}decode(e){let t=e[0],n=this.decoders[t];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 Di(r,e){return new tn({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var rn=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new Zr(e,t,n),this.decoder=new en(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function ze({name:r,prefix:e,encode:t,decode:n}){return new rn(r,e,t,n)}function pe({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=Ci(t,r);return ze({prefix:e,name:r,encode:n,decode:i=>ne(o(i))})}function gc(r,e,t,n){let o=r.length;for(;r[o-1]==="=";)--o;let i=new Uint8Array(o*t/8|0),s=0,a=0,c=0;for(let h=0;h<o;++h){let d=e[r[h]];if(d===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<t|d,s+=t,s>=8&&(s-=8,i[c++]=255&a>>s)}if(s>=t||(255&a<<8-s)!==0)throw new SyntaxError("Unexpected end of data");return i}function xc(r,e,t){let n=e[e.length-1]==="=",o=(1<<t)-1,i="",s=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],s+=8;s>t;)s-=t,i+=e[o&a>>s];if(s!==0&&(i+=e[o&a<<t-s]),n)for(;(i.length*t&7)!==0;)i+="=";return i}function wc(r){let e={};for(let t=0;t<r.length;++t)e[r[t]]=t;return e}function L({name:r,prefix:e,bitsPerChar:t,alphabet:n}){let o=wc(n);return ze({prefix:e,name:r,encode(i){return xc(i,n,t)},decode(i){return gc(i,o,t,r)}})}var Me=L({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),bc=L({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ec=L({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),vc=L({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),kc=L({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),_c=L({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ac=L({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ic=L({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Tc=L({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var on={};V(on,{base36:()=>ft,base36upper:()=>Sc});var ft=pe({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Sc=pe({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var sn={};V(sn,{base58btc:()=>oe,base58flickr:()=>Bc});var oe=pe({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Bc=pe({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Nc=Ui,Li=128,Cc=127,Dc=~Cc,Lc=Math.pow(2,31);function Ui(r,e,t){e=e||[],t=t||0;for(var n=t;r>=Lc;)e[t++]=r&255|Li,r/=128;for(;r&Dc;)e[t++]=r&255|Li,r>>>=7;return e[t]=r|0,Ui.bytes=t-n+1,e}var Pc=an,Uc=128,Pi=127;function an(r,n){var t=0,n=n||0,o=0,i=n,s,a=r.length;do{if(i>=a)throw an.bytes=0,new RangeError("Could not decode varint");s=r[i++],t+=o<28?(s&Pi)<<o:(s&Pi)*Math.pow(2,o),o+=7}while(s>=Uc);return an.bytes=i-n,t}var Rc=Math.pow(2,7),Fc=Math.pow(2,14),zc=Math.pow(2,21),Mc=Math.pow(2,28),$c=Math.pow(2,35),Oc=Math.pow(2,42),Hc=Math.pow(2,49),Vc=Math.pow(2,56),qc=Math.pow(2,63),Gc=function(r){return r<Rc?1:r<Fc?2:r<zc?3:r<Mc?4:r<$c?5:r<Oc?6:r<Hc?7:r<Vc?8:r<qc?9:10},jc={encode:Nc,decode:Pc,encodingLength:Gc},Wc=jc,lt=Wc;function ht(r,e=0){return[lt.decode(r,e),lt.decode.bytes]}function $e(r,e,t=0){return lt.encode(r,e,t),e}function Oe(r){return lt.encodingLength(r)}function Ve(r,e){let t=e.byteLength,n=Oe(r),o=n+Oe(t),i=new Uint8Array(o+t);return $e(r,i,0),$e(t,i,n),i.set(e,o),new He(r,t,e,i)}function qe(r){let e=ne(r),[t,n]=ht(e),[o,i]=ht(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new He(t,o,s,e)}function Ri(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&Qr(r.bytes,t.bytes)}}var He=class{code;size;digest;bytes;constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};function Fi(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return Xc(t,cn(r),e??oe.encoder);default:return Qc(t,cn(r),e??Me.encoder)}}var zi=new WeakMap;function cn(r){let e=zi.get(r);if(e==null){let t=new Map;return zi.set(r,t),t}return e}var N=class r{code;version;multihash;bytes;"/";constructor(e,t,n,o){this.code=t,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:t}=this;if(e!==dt)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Kc)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}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:t}=this.multihash,n=Ve(e,t);return r.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 r.equals(this,e)}static equals(e,t){let n=t;return n!=null&&e.code===n.code&&e.version===n.version&&Ri(e.multihash,n.multihash)}toString(e){return Fi(this,e)}toJSON(){return{"/":Fi(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 t=e;if(t instanceof r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:i,bytes:s}=t;return new r(n,o,i,s??Mi(n,o,i.bytes))}else if(t[Yc]===!0){let{version:n,multihash:o,code:i}=t,s=qe(o);return r.create(n,i,s)}else return null}static create(e,t,n){if(typeof t!="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(t!==dt)throw new Error(`Version 0 CID must use dag-pb (code: ${dt}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=Mi(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,dt,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,o=ne(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let i=o.subarray(t.multihashSize-t.digestSize),s=new He(t.multihashCode,t.digestSize,i,o);return[t.version===0?r.createV0(s):r.createV1(t.codec,s),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[p,v]=ht(e.subarray(t));return t+=v,p},o=n(),i=dt;if(o===18?(o=0,t=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=t,a=n(),c=n(),h=t+c,d=h-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:d,size:h}}static parse(e,t){let[n,o]=Jc(e,t),i=r.decode(o);if(i.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return cn(i).set(n,e),i}};function Jc(r,e){switch(r[0]){case"Q":{let t=e??oe;return[oe.prefix,t.decode(`${oe.prefix}${r}`)]}case oe.prefix:{let t=e??oe;return[oe.prefix,t.decode(r)]}case Me.prefix:{let t=e??Me;return[Me.prefix,t.decode(r)]}case ft.prefix:{let t=e??ft;return[ft.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function Xc(r,e,t){let{prefix:n}=t;if(n!==oe.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let i=t.encode(r).slice(1);return e.set(n,i),i}else return o}function Qc(r,e,t){let{prefix:n}=t,o=e.get(n);if(o==null){let i=t.encode(r);return e.set(n,i),i}else return o}var dt=112,Kc=18;function Mi(r,e,t){let n=Oe(r),o=n+Oe(e),i=new Uint8Array(o+t.byteLength);return $e(r,i,0),$e(e,i,n),i.set(t,o),i}var Yc=Symbol.for("@ipld/js-cid/CID");var $i=42;function Zc(r){return r instanceof ArrayBuffer?new Uint8Array(r,0,r.byteLength):r}function eu(r){if(r.asCID!==r&&r["/"]!==r.bytes)return null;let e=N.asCID(r);if(!e)return null;let t=new Uint8Array(e.bytes.byteLength+1);return t.set(e.bytes,1),[new y(f.tag,$i),new y(f.bytes,t)]}function tu(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function ru(r){if(Number.isNaN(r))throw new Error("`NaN` is not supported by the IPLD Data Model and cannot be encoded");if(r===1/0||r===-1/0)throw new Error("`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded");return null}function nu(r){for(let e of r.keys())if(typeof e!="string"||e.length===0)throw new Error("Non-string Map keys are not supported by the IPLD Data Model and cannot be encoded");return null}var un={float64:!0,typeEncoders:{Map:nu,Object:eu,undefined:tu,number:ru}},Gh={...un,typeEncoders:{...un.typeEncoders}};function ou(r){if(r[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return N.decode(r.subarray(1))}var er={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:[]};er.tags[$i]=ou;var jh={...er,tags:er.tags.slice()};var Oi=113,fn=r=>Jr(r,un),pt=r=>ut(Zc(r),er);var pn=Ee(tr(),1);var mn=40;function yn(r,e){if(!r.length)throw new Error("Unexpected end of data");let t=pn.default.decode(r);return e.seek(pn.default.decode.bytes),t}function gn(r){let e=new DataView(r.buffer,r.byteOffset,r.byteLength),t=0;return{version:2,characteristics:[e.getBigUint64(t,!0),e.getBigUint64(t+=8,!0)],dataOffset:Number(e.getBigUint64(t+=8,!0)),dataSize:Number(e.getBigUint64(t+=8,!0)),indexOffset:Number(e.getBigUint64(t+=8,!0))}}var ye={Null:r=>r===null?r:void 0,Int:r=>Number.isInteger(r)?r:void 0,Float:r=>typeof r=="number"&&Number.isFinite(r)?r:void 0,String:r=>typeof r=="string"?r:void 0,Bool:r=>typeof r=="boolean"?r:void 0,Bytes:r=>r instanceof Uint8Array?r:void 0,Link:r=>r!==null&&typeof r=="object"&&r.asCID===r?r:void 0,List:r=>Array.isArray(r)?r:void 0,Map:r=>r!==null&&typeof r=="object"&&r.asCID!==r&&!Array.isArray(r)&&!(r instanceof Uint8Array)?r:void 0},mt={"CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)":ye.Link,"CarV1HeaderOrV2Pragma > roots (anon)":r=>{if(ye.List(r)!==void 0){for(let e=0;e<r.length;e++){let t=r[e];if(t=mt["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](t),t===void 0)return;if(t!==r[e]){let n=r.slice(0,e);for(let o=e;o<r.length;o++){let i=r[o];if(i=mt["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](i),i===void 0)return;n.push(i)}return n}}return r}},Int:ye.Int,CarV1HeaderOrV2Pragma:r=>{if(ye.Map(r)===void 0)return;let e=Object.entries(r),t=r,n=1;for(let o=0;o<e.length;o++){let[i,s]=e[o];switch(i){case"roots":{let a=mt["CarV1HeaderOrV2Pragma > roots (anon)"](r[i]);if(a===void 0)return;if(a!==s||t!==r){if(t===r){t={};for(let c=0;c<o;c++)t[e[c][0]]=e[c][1]}t.roots=a}}break;case"version":{n--;let a=mt.Int(r[i]);if(a===void 0)return;if(a!==s||t!==r){if(t===r){t={};for(let c=0;c<o;c++)t[e[c][0]]=e[c][1]}t.version=a}}break;default:return}}if(!(n>0))return t}},yt={"CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)":ye.Link,"CarV1HeaderOrV2Pragma > roots (anon)":r=>{if(ye.List(r)!==void 0){for(let e=0;e<r.length;e++){let t=r[e];if(t=yt["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](t),t===void 0)return;if(t!==r[e]){let n=r.slice(0,e);for(let o=e;o<r.length;o++){let i=r[o];if(i=yt["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](i),i===void 0)return;n.push(i)}return n}}return r}},Int:ye.Int,CarV1HeaderOrV2Pragma:r=>{if(ye.Map(r)===void 0)return;let e=Object.entries(r),t=r,n=1;for(let o=0;o<e.length;o++){let[i,s]=e[o];switch(i){case"roots":{let a=yt["CarV1HeaderOrV2Pragma > roots (anon)"](s);if(a===void 0)return;if(a!==s||t!==r){if(t===r){t={};for(let c=0;c<o;c++)t[e[c][0]]=e[c][1]}t.roots=a}}break;case"version":{n--;let a=yt.Int(s);if(a===void 0)return;if(a!==s||t!==r){if(t===r){t={};for(let c=0;c<o;c++)t[e[c][0]]=e[c][1]}t.version=a}}break;default:return}}if(!(n>0))return t}},xn={toTyped:mt.CarV1HeaderOrV2Pragma,toRepresentation:yt.CarV1HeaderOrV2Pragma};var ad=Wr();var Eu=Ee(tr(),1);var hd=[new y(f.map,2),new y(f.string,"version"),new y(f.uint,1),new y(f.string,"roots")],dd=new y(f.tag,42);async function wn(r,e){let t=yn(await r.upTo(8),r);if(t===0)throw new Error("Invalid CAR header (zero length)");let n=await r.exactly(t,!0),o=pt(n);if(xn.toTyped(o)===void 0)throw new Error("Invalid CAR header format");if(o.version!==1&&o.version!==2||e!==void 0&&o.version!==e)throw new Error(`Invalid CAR version: ${o.version}${e!==void 0?` (expected ${e})`:""}`);if(o.version===1){if(!Array.isArray(o.roots))throw new Error("Invalid CAR header format");return o}if(o.roots!==void 0)throw new Error("Invalid CAR header format");let i=gn(await r.exactly(mn,!0));r.seek(i.dataOffset-r.pos);let s=await wn(r,1);return Object.assign(s,i)}function gt(r){let e=0;return{async upTo(t){return r.subarray(e,e+Math.min(t,r.length-e))},async exactly(t,n=!1){if(t>r.length-e)throw new Error("Unexpected end of data");let o=r.subarray(e,e+t);return n&&(e+=t),o},seek(t){e+=t},get pos(){return e}}}var bn=Ee(tr(),1),Zi=1;function En(r){let e=fn({version:Zi,roots:r}),t=bn.default.encode(e.length),n=new Uint8Array(t.length+e.length);return n.set(t,0),n.set(e,t.length),n}function es(r){return{async setRoots(e){let t=En(e);await r.write(t)},async writeBlock(e){let{cid:t,bytes:n}=e;await r.write(new Uint8Array(bn.default.encode(t.bytes.length+n.length))),await r.write(t.bytes),n.length&&await r.write(n)},async close(){await r.end()},version(){return Zi}}}function rr(){}function ts(){let r=[],e=null,t=rr,n=!1,o=null,i=rr,s=()=>(e||(e=new Promise(h=>{t=()=>{e=null,t=rr,h()}})),e),a={write(h){r.push(h);let d=s();return i(),d},async end(){n=!0;let h=s();i(),await h}},c={async next(){let h=r.shift();return h?(r.length===0&&t(),{done:!1,value:h}):n?(t(),{done:!0,value:void 0}):(o||(o=new Promise(d=>{i=()=>(o=null,i=rr,d(c.next()))})),o)}};return{writer:a,iterator:c}}var xt=class r{constructor(e,t){this._encoder=t,this._mutex=t.setRoots(e),this._ended=!1}async put(e){if(!(e.bytes instanceof Uint8Array)||!e.cid)throw new TypeError("Can only write {cid, bytes} objects");if(this._ended)throw new Error("Already closed");let t=N.asCID(e.cid);if(!t)throw new TypeError("Can only write {cid, bytes} objects");return this._mutex=this._mutex.then(()=>this._encoder.writeBlock({cid:t,bytes:e.bytes})),this._mutex}async close(){if(this._ended)throw new Error("Already closed");return await this._mutex,this._ended=!0,this._encoder.close()}version(){return this._encoder.version()}static create(e){e=Au(e);let{encoder:t,iterator:n}=rs(),o=new r(e,t),i=new nr(n);return{writer:o,out:i}}static createAppender(){let{encoder:e,iterator:t}=rs();e.setRoots=()=>Promise.resolve();let n=new r([],e),o=new nr(t);return{writer:n,out:o}}static async updateRootsInBytes(e,t){let n=gt(e);await wn(n);let o=En(t);if(Number(n.pos)!==o.length)throw new Error(`updateRoots() can only overwrite a header of the same length (old header is ${n.pos} bytes, new header is ${o.length} bytes)`);return e.set(o,0),e}},nr=class{constructor(e){this._iterator=e}[Symbol.asyncIterator](){if(this._iterating)throw new Error("Multiple iterator not supported");return this._iterating=!0,this._iterator}};function rs(){let r=ts(),{writer:e,iterator:t}=r;return{encoder:es(e),iterator:t}}function Au(r){if(r===void 0)return[];if(!Array.isArray(r)){let t=N.asCID(r);if(!t)throw new TypeError("roots must be a single CID or an array of CIDs");return[t]}let e=[];for(let t of r){let n=N.asCID(t);if(!n)throw new TypeError("roots must be a single CID or an array of CIDs");e.push(n)}return e}function Iu(r){return r[Symbol.asyncIterator]!=null}function Tu(r){if(Iu(r))return(async()=>{for await(let e of r);})();for(let e of r);}var vn=Tu;function Su(r){let[e,t]=r[Symbol.asyncIterator]!=null?[r[Symbol.asyncIterator](),Symbol.asyncIterator]:[r[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(),[t](){return this}}}var or=Su;function Bu(r){return r[Symbol.asyncIterator]!=null}function Nu(r,e){let t=0;if(Bu(r))return(async function*(){for await(let c of r)yield e(c,t++)})();let n=or(r),{value:o,done:i}=n.next();if(i===!0)return(function*(){})();let s=e(o,t++);if(typeof s.then=="function")return(async function*(){yield await s;for(let c of n)yield e(c,t++)})();let a=e;return(function*(){yield s;for(let c of n)yield a(c,t++)})()}var ge=Nu;function Cu(r){return r.reason}async function ir(r,e,t){if(e==null)return r;let n=t?.translateError??Cu;if(e.aborted)return r.catch(()=>{}),Promise.reject(n(e));let o;try{return await Promise.race([r,new Promise((i,s)=>{o=()=>{s(n(e))},e.addEventListener("abort",o)})])}finally{o!=null&&e.removeEventListener("abort",o)}}var le=class extends Error{static name="AbortError";constructor(e="The operation was aborted"){super(e),this.name="AbortError"}};var sr=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}};var ar=class extends EventTarget{#e=new Map;constructor(){super()}listenerCount(e){let t=this.#e.get(e);return t==null?0:t.length}addEventListener(e,t,n){super.addEventListener(e,t,n);let o=this.#e.get(e);o==null&&(o=[],this.#e.set(e,o)),o.push({callback:t,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(e,t,n){super.removeEventListener(e.toString(),t??null,n);let o=this.#e.get(e);o!=null&&(o=o.filter(({callback:i})=>i!==t),this.#e.set(e,o))}dispatchEvent(e){let t=super.dispatchEvent(e),n=this.#e.get(e.type);return n==null||(n=n.filter(({once:o})=>!o),this.#e.set(e.type,n)),t}safeDispatchEvent(e,t={}){return this.dispatchEvent(new CustomEvent(e,t))}};var _n={};V(_n,{base64:()=>kn,base64pad:()=>Du,base64url:()=>Lu,base64urlpad:()=>Pu});var kn=L({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Du=L({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Lu=L({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Pu=L({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var R=class extends Event{type;detail;constructor(e,t){super(e),this.type=e,this.detail=t}};var In=Ee(os(),1);var Tn=class r extends Error{name="TimeoutError";constructor(e,t){super(e,t),Error.captureStackTrace?.(this,r)}},is=r=>r.reason??new DOMException("This operation was aborted.","AbortError");function Sn(r,e){let{milliseconds:t,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout},signal:s}=e,a,c,d=new Promise((p,v)=>{if(typeof t!="number"||Math.sign(t)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(s?.aborted){v(is(s));return}if(s&&(c=()=>{v(is(s))},s.addEventListener("abort",c,{once:!0})),r.then(p,v),t===Number.POSITIVE_INFINITY)return;let u=new Tn;a=i.setTimeout.call(void 0,()=>{if(n){try{p(n())}catch(l){v(l)}return}typeof r.cancel=="function"&&r.cancel(),o===!1?p():o instanceof Error?v(o):(u.message=o??`Promise timed out after ${t} milliseconds`,v(u))},t)}).finally(()=>{d.clear(),c&&s&&s.removeEventListener("abort",c)});return d.clear=()=>{i.clearTimeout.call(void 0,a),a=void 0},d}function Bn(r,e,t){let n=0,o=r.length;for(;o>0;){let i=Math.trunc(o/2),s=n+i;t(r[s],e)<=0?(n=++s,o-=i+1):o=i}return n}var bt=class{#e=[];enqueue(e,t){let{priority:n=0,id:o}=t??{},i={priority:n,id:o,run:e};if(this.size===0||this.#e[this.size-1].priority>=n){this.#e.push(i);return}let s=Bn(this.#e,i,(a,c)=>c.priority-a.priority);this.#e.splice(s,0,i)}setPriority(e,t){let n=this.#e.findIndex(i=>i.id===e);if(n===-1)throw new ReferenceError(`No promise function with the id "${e}" exists in the queue.`);let[o]=this.#e.splice(n,1);this.enqueue(o.run,{priority:t,id:e})}dequeue(){return this.#e.shift()?.run}filter(e){return this.#e.filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return this.#e.length}};var Et=class extends In.default{#e;#n;#o=0;#d;#p=!1;#m=!1;#u;#w=0;#y=0;#i;#s;#t;#b;#r=0;#f;#a;#I=1n;#l=new Map;timeout;constructor(e){if(super(),e={carryoverIntervalCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:bt,...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})`);if(this.#e=e.carryoverIntervalCount??e.carryoverConcurrencyCount??!1,this.#n=e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,this.#d=e.intervalCap,this.#u=e.interval,this.#t=new e.queueClass,this.#b=e.queueClass,this.concurrency=e.concurrency,e.timeout!==void 0&&!(Number.isFinite(e.timeout)&&e.timeout>0))throw new TypeError(`Expected \`timeout\` to be a positive finite number, got \`${e.timeout}\` (${typeof e.timeout})`);this.timeout=e.timeout,this.#a=e.autoStart===!1,this.#P()}get#T(){return this.#n||this.#o<this.#d}get#S(){return this.#r<this.#f}#B(){this.#r--,this.#r===0&&this.emit("pendingZero"),this.#g(),this.emit("next")}#N(){this.#_(),this.#k(),this.#s=void 0}get#C(){let e=Date.now();if(this.#i===void 0){let t=this.#w-e;if(t<0){if(this.#y>0){let n=e-this.#y;if(n<this.#u)return this.#E(this.#u-n),!0}this.#o=this.#e?this.#r:0}else return this.#E(t),!0}return!1}#E(e){this.#s===void 0&&(this.#s=setTimeout(()=>{this.#N()},e))}#v(){this.#i&&(clearInterval(this.#i),this.#i=void 0)}#D(){this.#s&&(clearTimeout(this.#s),this.#s=void 0)}#g(){if(this.#t.size===0)return this.#v(),this.emit("empty"),this.#r===0&&(this.#D(),this.emit("idle")),!1;let e=!1;if(!this.#a){let t=!this.#C;if(this.#T&&this.#S){let n=this.#t.dequeue();this.#n||(this.#o++,this.#h()),this.emit("active"),this.#y=Date.now(),n(),t&&this.#k(),e=!0}}return e}#k(){this.#n||this.#i!==void 0||(this.#i=setInterval(()=>{this.#_()},this.#u),this.#w=Date.now()+this.#u)}#_(){this.#o===0&&this.#r===0&&this.#i&&this.#v(),this.#o=this.#e?this.#r:0,this.#x(),this.#h()}#x(){for(;this.#g(););}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.#x()}async#L(e){return new Promise((t,n)=>{e.addEventListener("abort",()=>{n(e.reason)},{once:!0})})}setPriority(e,t){if(typeof t!="number"||!Number.isFinite(t))throw new TypeError(`Expected \`priority\` to be a finite number, got \`${t}\` (${typeof t})`);this.#t.setPriority(e,t)}async add(e,t={}){return t.id??=(this.#I++).toString(),t={timeout:this.timeout,...t},new Promise((n,o)=>{let i=Symbol(`task-${t.id}`);this.#t.enqueue(async()=>{this.#r++,this.#l.set(i,{id:t.id,priority:t.priority??0,startTime:Date.now(),timeout:t.timeout});try{try{t.signal?.throwIfAborted()}catch(c){throw this.#n||this.#o--,this.#l.delete(i),c}let s=e({signal:t.signal});t.timeout&&(s=Sn(Promise.resolve(s),{milliseconds:t.timeout,message:`Task timed out after ${t.timeout}ms (queue has ${this.#r} running, ${this.#t.size} waiting)`})),t.signal&&(s=Promise.race([s,this.#L(t.signal)]));let a=await s;n(a),this.emit("completed",a)}catch(s){o(s),this.emit("error",s)}finally{this.#l.delete(i),queueMicrotask(()=>{this.#B()})}},t),this.emit("add"),this.#g()})}async addAll(e,t){return Promise.all(e.map(async n=>this.add(n,t)))}start(){return this.#a?(this.#a=!1,this.#x(),this):this}pause(){this.#a=!0}clear(){this.#t=new this.#b,this.#A()}async onEmpty(){this.#t.size!==0&&await this.#c("empty")}async onSizeLessThan(e){this.#t.size<e||await this.#c("next",()=>this.#t.size<e)}async onIdle(){this.#r===0&&this.#t.size===0||await this.#c("idle")}async onPendingZero(){this.#r!==0&&await this.#c("pendingZero")}async onRateLimit(){this.isRateLimited||await this.#c("rateLimit")}async onRateLimitCleared(){this.isRateLimited&&await this.#c("rateLimitCleared")}async onError(){return new Promise((e,t)=>{let n=o=>{this.off("error",n),t(o)};this.on("error",n)})}async#c(e,t){return new Promise(n=>{let o=()=>{t&&!t()||(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.#r}get isPaused(){return this.#a}#P(){this.#n||(this.on("add",()=>{this.#t.size>0&&this.#h()}),this.on("next",()=>{this.#h()}))}#h(){this.#n||this.#m||(this.#m=!0,queueMicrotask(()=>{this.#m=!1,this.#A()}))}#A(){let e=this.#p,t=!this.#n&&this.#o>=this.#d&&this.#t.size>0;t!==e&&(this.#p=t,this.emit(t?"rateLimit":"rateLimitCleared"))}get isRateLimited(){return this.#p}get isSaturated(){return this.#r===this.#f&&this.#t.size>0||this.isRateLimited&&this.#t.size>0}get runningTasks(){return[...this.#l.values()].map(e=>({...e}))}};var Nn={};V(Nn,{base10:()=>Fu});var Fu=pe({prefix:"9",name:"base10",alphabet:"0123456789"});var Cn={};V(Cn,{base16:()=>zu,base16upper:()=>Mu});var zu=L({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Mu=L({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Dn={};V(Dn,{base2:()=>$u});var $u=L({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Ln={};V(Ln,{base256emoji:()=>Gu});var ss=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),Ou=ss.reduce((r,e,t)=>(r[t]=e,r),[]),Hu=ss.reduce((r,e,t)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return r[n]=t,r},[]);function Vu(r){return r.reduce((e,t)=>(e+=Ou[t],e),"")}function qu(r){let e=[];for(let t of r){let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);let o=Hu[n];if(o==null)throw new Error(`Non-base256emoji character: ${t}`);e.push(o)}return new Uint8Array(e)}var Gu=ze({prefix:"\u{1F680}",name:"base256emoji",encode:Vu,decode:qu});var Pn={};V(Pn,{base8:()=>ju});var ju=L({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Un={};V(Un,{identity:()=>Wu});var Wu=ze({prefix:"\0",name:"identity",encode:r=>Yr(r),decode:r=>Kr(r)});var vp=new TextEncoder,Ju=new TextDecoder;var as=512;function cs(r){return JSON.parse(Ju.decode(r))}var ur=85;var Mn={};V(Mn,{identity:()=>zn});var us=0,Xu="identity",fs=ne;function Qu(r,e){if(e?.truncate!=null&&e.truncate!==r.byteLength){if(e.truncate<0||e.truncate>r.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${r.byteLength}`);r=r.subarray(0,e.truncate)}return Ve(us,fs(r))}var zn={code:us,name:Xu,encode:fs,digest:Qu};var On={};V(On,{sha256:()=>Yu,sha512:()=>Zu});var Ku=20;function _e({name:r,code:e,encode:t,minDigestLength:n,maxDigestLength:o}){return new $n(r,e,t,n,o)}var $n=class{name;code;encode;minDigestLength;maxDigestLength;constructor(e,t,n,o,i){this.name=e,this.code=t,this.encode=n,this.minDigestLength=o??Ku,this.maxDigestLength=i}digest(e,t){if(t?.truncate!=null){if(t.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&t.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(e instanceof Uint8Array){let n=this.encode(e);return n instanceof Uint8Array?ls(n,this.code,t?.truncate):n.then(o=>ls(o,this.code,t?.truncate))}else throw Error("Unknown type, must be binary type")}};function ls(r,e,t){if(t!=null&&t!==r.byteLength){if(t>r.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${r.byteLength}`);r=r.subarray(0,t)}return Ve(e,r)}function ds(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var Yu=_e({name:"sha2-256",code:18,encode:ds("SHA-256")}),Zu=_e({name:"sha2-512",code:19,encode:ds("SHA-512")});var Hn={...Un,...Dn,...Pn,...Nn,...Cn,...nn,...on,...sn,..._n,...Ln},Up={...On,...Mn};function ie(r=0){return new Uint8Array(r)}function ms(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var ps=ms("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Vn=ms("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=ie(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),ef={utf8:ps,"utf-8":ps,hex:Hn.base16,latin1:Vn,ascii:Vn,binary:Vn,...Hn},qn=ef;var nf=Ee(gs(),1);var Ge;(function(r){r[r.A=1]="A",r[r.CNAME=5]="CNAME",r[r.TXT=16]="TXT",r[r.AAAA=28]="AAAA"})(Ge||(Ge={}));function vt(r,e){e==null&&(e=r.reduce((o,i)=>o+i.length,0));let t=ie(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return t}function fr(r,e="utf8"){let t=qn[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${r}`)}var of=Math.pow(2,7),sf=Math.pow(2,14),af=Math.pow(2,21),xs=Math.pow(2,28),ws=Math.pow(2,35),bs=Math.pow(2,42),Es=Math.pow(2,49),H=128,xe=127;function kt(r){if(r<of)return 1;if(r<sf)return 2;if(r<af)return 3;if(r<xs)return 4;if(r<ws)return 5;if(r<bs)return 6;if(r<Es)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function vs(r,e,t=0){switch(kt(r)){case 8:e[t++]=r&255|H,r/=128;case 7:e[t++]=r&255|H,r/=128;case 6:e[t++]=r&255|H,r/=128;case 5:e[t++]=r&255|H,r/=128;case 4:e[t++]=r&255|H,r>>>=7;case 3:e[t++]=r&255|H,r>>>=7;case 2:e[t++]=r&255|H,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function ks(r,e){let t=r[e],n=0;if(n+=t&xe,t<H||(t=r[e+1],n+=(t&xe)<<7,t<H)||(t=r[e+2],n+=(t&xe)<<14,t<H)||(t=r[e+3],n+=(t&xe)<<21,t<H)||(t=r[e+4],n+=(t&xe)*xs,t<H)||(t=r[e+5],n+=(t&xe)*ws,t<H)||(t=r[e+6],n+=(t&xe)*bs,t<H)||(t=r[e+7],n+=(t&xe)*Es,t<H))return n;throw new RangeError("Could not decode varint")}var Gn=new Float32Array([-0]),we=new Uint8Array(Gn.buffer);function _s(r,e,t){Gn[0]=r,e[t]=we[0],e[t+1]=we[1],e[t+2]=we[2],e[t+3]=we[3]}function As(r,e){return we[0]=r[e],we[1]=r[e+1],we[2]=r[e+2],we[3]=r[e+3],Gn[0]}var jn=new Float64Array([-0]),M=new Uint8Array(jn.buffer);function Is(r,e,t){jn[0]=r,e[t]=M[0],e[t+1]=M[1],e[t+2]=M[2],e[t+3]=M[3],e[t+4]=M[4],e[t+5]=M[5],e[t+6]=M[6],e[t+7]=M[7]}function Ts(r,e){return M[0]=r[e],M[1]=r[e+1],M[2]=r[e+2],M[3]=r[e+3],M[4]=r[e+4],M[5]=r[e+5],M[6]=r[e+6],M[7]=r[e+7],jn[0]}var cf=BigInt(Number.MAX_SAFE_INTEGER),uf=BigInt(Number.MIN_SAFE_INTEGER),J=class r{lo;hi;constructor(e,t){this.lo=e|0,this.hi=t|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(t+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(BigInt(t)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?t===0?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return Ae;if(e<cf&&e>uf)return this.fromNumber(Number(e));let t=e<0n;t&&(e=-e);let n=e>>32n,o=e-(n<<32n);return t&&(n=~n|0n,o=~o|0n,++o>Ss&&(o=0n,++n>Ss&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(e){if(e===0)return Ae;let t=e<0;t&&(e=-e);let n=e>>>0,o=(e-n)/4294967296>>>0;return t&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}static from(e){return typeof e=="number"?r.fromNumber(e):typeof e=="bigint"?r.fromBigInt(e):typeof e=="string"?r.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new r(e.low>>>0,e.high>>>0):Ae}},Ae=new J(0,0);Ae.toBigInt=function(){return 0n};Ae.zzEncode=Ae.zzDecode=function(){return this};Ae.length=function(){return 1};var Ss=4294967296n;function Bs(r){let e=0,t=0;for(let n=0;n<r.length;++n)t=r.charCodeAt(n),t<128?e+=1:t<2048?e+=2:(t&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,e+=4):e+=3;return e}function Ns(r,e,t){if(t-e<1)return"";let o,i=[],s=0,a;for(;e<t;)a=r[e++],a<128?i[s++]=a:a>191&&a<224?i[s++]=(a&31)<<6|r[e++]&63:a>239&&a<365?(a=((a&7)<<18|(r[e++]&63)<<12|(r[e++]&63)<<6|r[e++]&63)-65536,i[s++]=55296+(a>>10),i[s++]=56320+(a&1023)):i[s++]=(a&15)<<12|(r[e++]&63)<<6|r[e++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function Wn(r,e,t){let n=t,o,i;for(let s=0;s<r.length;++s)o=r.charCodeAt(s),o<128?e[t++]=o:o<2048?(e[t++]=o>>6|192,e[t++]=o&63|128):(o&64512)===55296&&((i=r.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,e[t++]=o>>18|240,e[t++]=o>>12&63|128,e[t++]=o>>6&63|128,e[t++]=o&63|128):(e[t++]=o>>12|224,e[t++]=o>>6&63|128,e[t++]=o&63|128);return t-n}function Z(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function lr(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}var Jn=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,Z(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw Z(this,4);return lr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Z(this,4);return lr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Z(this,4);let e=As(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw Z(this,4);let e=Ts(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),t=this.pos,n=this.pos+e;if(n>this.len)throw Z(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return Ns(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw Z(this,e);this.pos+=e}else do if(this.pos>=this.len)throw Z(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new J(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw Z(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<t*7)>>>0,e}if(this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw Z(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Z(this,8);let e=lr(this.buf,this.pos+=4),t=lr(this.buf,this.pos+=4);return new J(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=ks(this.buf,this.pos);return this.pos+=kt(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function Xn(r){return new Jn(r instanceof Uint8Array?r:r.subarray())}function _t(r,e,t){let n=Xn(r);return e.decode(n,void 0,t)}function Qn(r){let e=r??8192,t=e>>>1,n,o=e;return function(s){if(s<1||s>t)return ie(s);o+s>e&&(n=ie(e),o=0);let a=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),a}}var Ie=class{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}};function Kn(){}var Zn=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},ff=Qn();function lf(r){return globalThis.Buffer!=null?ie(r):ff(r)}var It=class{len;head;tail;states;constructor(){this.len=0,this.head=new Ie(Kn,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new Ie(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new eo((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(hr,10,J.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=J.fromBigInt(e);return this._push(hr,t.length(),t)}uint64Number(e){return this._push(vs,kt(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let t=J.fromBigInt(e).zzEncode();return this._push(hr,t.length(),t)}sint64Number(e){let t=J.fromNumber(e).zzEncode();return this._push(hr,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Yn,1,e?1:0)}fixed32(e){return this._push(At,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=J.fromBigInt(e);return this._push(At,4,t.lo)._push(At,4,t.hi)}fixed64Number(e){let t=J.fromNumber(e);return this._push(At,4,t.lo)._push(At,4,t.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(_s,4,e)}double(e){return this._push(Is,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(Yn,1,0):this.uint32(t)._push(df,t,e)}string(e){let t=Bs(e);return t!==0?this.uint32(t)._push(Wn,t,e):this._push(Yn,1,0)}fork(){return this.states=new Zn(this),this.head=this.tail=new Ie(Kn,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new Ie(Kn,0,0),this.len=0),this}ldelim(){let e=this.head,t=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=t,this.len+=n),this}finish(){let e=this.head.next,t=lf(this.len),n=0;for(;e!=null;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}};function Yn(r,e,t){e[t]=r&255}function hf(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var eo=class extends Ie{next;constructor(e,t){super(hf,e,t),this.next=void 0}};function hr(r,e,t){for(;r.hi!==0;)e[t++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)e[t++]=r.lo&127|128,r.lo=r.lo>>>7;e[t++]=r.lo}function At(r,e,t){e[t]=r&255,e[t+1]=r>>>8&255,e[t+2]=r>>>16&255,e[t+3]=r>>>24}function df(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(It.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(pf,e,r),this},It.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(mf,e,r),this});function pf(r,e,t){e.set(r,t)}function mf(r,e,t){r.length<40?Wn(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(fr(r),t)}function to(){return new It}function Tt(r,e){let t=to();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var je;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(je||(je={}));function dr(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function ro(r){function e(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let t=function(i,s){let a=e(i);s.int32(a)},n=function(i){let s=i.int32();return e(s)};return dr("enum",je.VARINT,t,n)}function St(r,e){return dr("message",je.LENGTH_DELIMITED,r,e)}function $(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}var pr=class{buffer;mask;top;btm;next;constructor(e){if(!(e>0)||(e-1&e)!==0)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return this.buffer[this.btm]===void 0}},We=class{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new pr(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return e?.byteLength!=null?e.byteLength:1}push(e){if(e?.value!=null&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){let t=this.head;this.head=t.next=new pr(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next!=null){let t=this.tail.next;this.tail.next=null,this.tail=t,e=this.tail.shift()}return e?.value!=null&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}};var no=class extends Error{type;code;constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.code=t??"ABORT_ERR"}};function Je(r={}){return yf(t=>{let n=t.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},r)}function yf(r,e){e=e??{};let t=e.onEnd,n=new We,o,i,s,a=$(),c=async()=>{try{return n.isEmpty()?s?{done:!0}:await new Promise((I,g)=>{i=w=>{i=null,n.push(w);try{I(r(n))}catch(b){g(b)}return o}}):r(n)}finally{n.isEmpty()&&queueMicrotask(()=>{a.resolve(),a=$()})}},h=I=>i!=null?i(I):(n.push(I),o),d=I=>(n=new We,i!=null?i({error:I}):(n.push({error:I}),o)),p=I=>{if(s)return o;if(e?.objectMode!==!0&&I?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return h({done:!1,value:I})},v=I=>s?o:(s=!0,I!=null?d(I):h({done:!0})),u=()=>(n=new We,v(),{done:!0}),l=I=>(v(I),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:c,return:u,throw:l,push:p,end:v,get readableLength(){return n.size},onEmpty:async I=>{let g=I?.signal;if(g?.throwIfAborted(),n.isEmpty())return;let w,b;g!=null&&(w=new Promise((k,A)=>{b=()=>{A(new no)},g.addEventListener("abort",b)}));try{await Promise.race([a.promise,w])}finally{b!=null&&g!=null&&g?.removeEventListener("abort",b)}}},t==null)return o;let m=o;return o={[Symbol.asyncIterator](){return this},next(){return m.next()},throw(I){return m.throw(I),t!=null&&(t(I),t=void 0),{done:!0}},return(){return m.return(),t!=null&&(t(),t=void 0),{done:!0}},push:p,end(I){return m.end(I),t!=null&&(t(I),t=void 0),o},get readableLength(){return m.readableLength},onEmpty:I=>m.onEmpty(I)},o}var oo=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},io=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},Ds=r=>globalThis.DOMException===void 0?new io(r):new DOMException(r),Ls=r=>{let e=r.reason===void 0?Ds("This operation was aborted."):r.reason;return e instanceof Error?e:Ds(e)};function so(r,e){let{milliseconds:t,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout}}=e,s,a,h=new Promise((d,p)=>{if(typeof t!="number"||Math.sign(t)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(e.signal){let{signal:u}=e;u.aborted&&p(Ls(u)),a=()=>{p(Ls(u))},u.addEventListener("abort",a,{once:!0})}if(t===Number.POSITIVE_INFINITY){r.then(d,p);return}let v=new oo;s=i.setTimeout.call(void 0,()=>{if(n){try{d(n())}catch(u){p(u)}return}typeof r.cancel=="function"&&r.cancel(),o===!1?d():o instanceof Error?p(o):(v.message=o??`Promise timed out after ${t} milliseconds`,p(v))},t),(async()=>{try{d(await r)}catch(u){p(u)}})()}).finally(()=>{h.clear(),a&&e.signal&&e.signal.removeEventListener("abort",a)});return h.clear=()=>{i.clearTimeout.call(void 0,s),s=void 0},h}var gf=r=>{let e=r.addEventListener||r.on||r.addListener,t=r.removeEventListener||r.off||r.removeListener;if(!e||!t)throw new TypeError("Emitter is not compatible");return{addListener:e.bind(r),removeListener:t.bind(r)}};function xf(r,e,t){let n,o=new Promise((i,s)=>{if(t={rejectionEvents:["error"],multiArgs:!1,rejectionMultiArgs:!1,resolveImmediately:!1,...t},!(t.count>=0&&(t.count===Number.POSITIVE_INFINITY||Number.isInteger(t.count))))throw new TypeError("The `count` option should be at least 0 or more");t.signal?.throwIfAborted();let a=[e].flat(),c=[],{addListener:h,removeListener:d}=gf(r),p=async(...u)=>{let l=t.multiArgs?u:u[0];if(t.filter)try{if(!await t.filter(l))return}catch(m){n(),s(m);return}c.push(l),t.count===c.length&&(n(),i(c))},v=(...u)=>{n(),s(t.rejectionMultiArgs?u:u[0])};n=()=>{for(let u of a)d(u,p);for(let u of t.rejectionEvents)a.includes(u)||d(u,v)};for(let u of a)h(u,p);for(let u of t.rejectionEvents)a.includes(u)||h(u,v);t.signal&&t.signal.addEventListener("abort",()=>{v(t.signal.reason)},{once:!0}),t.resolveImmediately&&i(c)});if(o.cancel=n,typeof t.timeout=="number"){let i=so(o,{milliseconds:t.timeout});return i.cancel=()=>{n(),i.clear()},i}return o}function mr(r,e,t){typeof t=="function"&&(t={filter:t}),t={...t,count:1,resolveImmediately:!1};let n=xf(r,e,t),o=n.then(i=>i[0]);return o.cancel=n.cancel,o}function ao(r,e){let t,n=function(){let o=function(){t=void 0,r()};clearTimeout(t),t=setTimeout(o,e)};return n.start=()=>{},n.stop=()=>{clearTimeout(t)},n}var yr=class extends Error{static name="QueueFullError";constructor(e="The queue was full"){super(e),this.name="QueueFullError"}};var gr=class{deferred;signal;constructor(e){this.signal=e,this.deferred=$(),this.onAbort=this.onAbort.bind(this),this.signal?.addEventListener("abort",this.onAbort)}onAbort(){this.deferred.reject(this.signal?.reason??new le)}cleanup(){this.signal?.removeEventListener("abort",this.onAbort)}};function wf(){return`${parseInt(String(Math.random()*1e9),10).toString()}${Date.now()}`}var xr=class{id;fn;options;recipients;status;timeline;controller;constructor(e,t){this.id=wf(),this.status="queued",this.fn=e,this.options=t,this.recipients=[],this.timeline={created:Date.now()},this.controller=new AbortController,this.controller.signal,this.onAbort=this.onAbort.bind(this)}abort(e){this.controller.abort(e)}onAbort(){this.recipients.reduce((t,n)=>t&&n.signal?.aborted===!0,!0)&&(this.controller.abort(new le),this.cleanup())}async join(e={}){let t=new gr(e.signal);return this.recipients.push(t),e.signal?.addEventListener("abort",this.onAbort),t.deferred.promise}async run(){this.status="running",this.timeline.started=Date.now();try{this.controller.signal.throwIfAborted();let e=await ir(this.fn({...this.options??{},signal:this.controller.signal}),this.controller.signal);this.recipients.forEach(t=>{t.deferred.resolve(e)}),this.status="complete"}catch(e){this.recipients.forEach(t=>{t.deferred.reject(e)}),this.status="errored"}finally{this.timeline.finished=Date.now(),this.cleanup()}}cleanup(){this.recipients.forEach(e=>{e.cleanup(),e.signal?.removeEventListener("abort",this.onAbort)})}};var Bt=class extends ar{concurrency;maxSize;queue;pending;sort;paused;constructor(e={}){super(),this.concurrency=e.concurrency??Number.POSITIVE_INFINITY,this.maxSize=e.maxSize??Number.POSITIVE_INFINITY,this.pending=0,this.paused=!1,e.metricName!=null&&e.metrics?.registerMetricGroup(e.metricName,{calculate:()=>({size:this.queue.length,running:this.pending,queued:this.queue.length-this.pending})}),this.sort=e.sort,this.queue=[],this.emitEmpty=ao(this.emitEmpty.bind(this),1),this.emitIdle=ao(this.emitIdle.bind(this),1)}emitEmpty(){this.size===0&&this.safeDispatchEvent("empty")}emitIdle(){this.running===0&&this.safeDispatchEvent("idle")}pause(){this.paused=!0}resume(){this.paused&&(this.paused=!1,this.tryToStartAnother())}tryToStartAnother(){if(this.paused)return!1;if(this.size===0)return this.emitEmpty(),this.running===0&&this.emitIdle(),!1;if(this.pending<this.concurrency){let e;for(let t of this.queue)if(t.status==="queued"){e=t;break}return e==null?!1:(this.safeDispatchEvent("active"),this.pending++,e.run().finally(()=>{for(let t=0;t<this.queue.length;t++)if(this.queue[t]===e){this.queue.splice(t,1);break}this.pending--,this.tryToStartAnother(),this.safeDispatchEvent("next")}),!0)}return!1}enqueue(e){this.queue.push(e),this.sort!=null&&this.queue.sort(this.sort)}async add(e,t){if(t?.signal?.throwIfAborted(),this.size===this.maxSize)throw new yr;let n=new xr(e,t);return this.enqueue(n),this.safeDispatchEvent("add"),this.tryToStartAnother(),n.join(t).then(o=>(this.safeDispatchEvent("completed",{detail:o}),this.safeDispatchEvent("success",{detail:{job:n,result:o}}),o)).catch(o=>{if(n.status==="queued"){for(let i=0;i<this.queue.length;i++)if(this.queue[i]===n){this.queue.splice(i,1);break}}throw this.safeDispatchEvent("failure",{detail:{job:n,error:o}}),o})}clear(){this.queue.splice(0,this.queue.length)}abort(){this.queue.forEach(e=>{e.abort(new le)}),this.clear()}async onEmpty(e){this.size!==0&&await mr(this,"empty",e)}async onSizeLessThan(e,t){this.size<e||await mr(this,"next",{...t,filter:()=>this.size<e})}async onIdle(e){this.pending===0&&this.size===0||await mr(this,"idle",e)}get size(){return this.queue.length}get queued(){return this.queue.length-this.pending}get running(){return this.pending}async*toGenerator(e){e?.signal?.throwIfAborted();let t=Je({objectMode:!0}),n=c=>{c!=null?this.abort():this.clear(),t.end(c)},o=c=>{c.detail!=null&&t.push(c.detail)},i=c=>{n(c.detail.error)},s=()=>{n()},a=()=>{n(new le("Queue aborted"))};this.addEventListener("completed",o),this.addEventListener("failure",i),this.addEventListener("idle",s),e?.signal?.addEventListener("abort",a);try{yield*t}finally{this.removeEventListener("completed",o),this.removeEventListener("failure",i),this.removeEventListener("idle",s),e?.signal?.removeEventListener("abort",a),n()}}};var wr=class extends Error{type;code;constructor(e,t,n){super(e??"The operation was aborted"),this.type="aborted",this.name=n??"AbortError",this.code=t??"ABORT_ERR"}};async function Ps(r,e,t){if(e==null)return r;if(e.aborted)return r.catch(()=>{}),Promise.reject(new wr(t?.errorMessage,t?.errorCode,t?.errorName));let n,o=new wr(t?.errorMessage,t?.errorCode,t?.errorName);try{return await Promise.race([r,new Promise((i,s)=>{n=()=>{s(o)},e.addEventListener("abort",n)})])}finally{n!=null&&e.removeEventListener("abort",n)}}var co=class{readNext;haveNext;ended;nextResult;error;constructor(){this.ended=!1,this.readNext=$(),this.haveNext=$()}[Symbol.asyncIterator](){return this}async next(){if(this.nextResult==null&&await this.haveNext.promise,this.nextResult==null)throw new Error("HaveNext promise resolved but nextResult was undefined");let e=this.nextResult;return this.nextResult=void 0,this.readNext.resolve(),this.readNext=$(),e}async throw(e){return this.ended=!0,this.error=e,e!=null&&(this.haveNext.promise.catch(()=>{}),this.haveNext.reject(e)),{done:!0,value:void 0}}async return(){let e={done:!0,value:void 0};return this.ended=!0,this.nextResult=e,this.haveNext.resolve(),e}async push(e,t){await this._push(e,t)}async end(e,t){e!=null?await this.throw(e):await this._push(void 0,t)}async _push(e,t){if(e!=null&&this.ended)throw this.error??new Error("Cannot push value onto an ended pushable");for(;this.nextResult!=null;)await this.readNext.promise;e!=null?this.nextResult={done:!1,value:e}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=$(),await Ps(this.readNext.promise,t?.signal,t)}};function Us(){return new co}function bf(r){return r[Symbol.asyncIterator]!=null}async function Ef(r,e,t){try{await Promise.all(r.map(async n=>{for await(let o of n)await e.push(o,{signal:t}),t.throwIfAborted()})),await e.end(void 0,{signal:t})}catch(n){await e.end(n,{signal:t}).catch(()=>{})}}async function*vf(r){let e=new AbortController,t=Us();Ef(r,t,e.signal).catch(()=>{});try{yield*t}finally{e.abort()}}function*kf(r){for(let e of r)yield*e}function _f(...r){let e=[];for(let t of r)bf(t)||e.push(t);return e.length===r.length?kf(e):vf(r)}var Rs=_f;function Xe(r,...e){if(r==null)throw new Error("Empty pipeline");if(uo(r)){let n=r;r=()=>n.source}else if(zs(r)||Fs(r)){let n=r;r=()=>n}let t=[r,...e];if(t.length>1&&uo(t[t.length-1])&&(t[t.length-1]=t[t.length-1].sink),t.length>2)for(let n=1;n<t.length-1;n++)uo(t[n])&&(t[n]=If(t[n]));return Af(...t)}var Af=(...r)=>{let e;for(;r.length>0;)e=r.shift()(e);return e},Fs=r=>r?.[Symbol.asyncIterator]!=null,zs=r=>r?.[Symbol.iterator]!=null,uo=r=>r==null?!1:r.sink!=null&&r.source!=null,If=r=>e=>{let t=r.sink(e);if(t?.then!=null){let n=Je({objectMode:!0});t.then(()=>{n.end()},s=>{n.end(s)});let o,i=r.source;if(Fs(i))o=async function*(){yield*i,n.end()};else if(zs(i))o=function*(){yield*i,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return Rs(n,o())}return r.source};function Tf(r){return r[Symbol.asyncIterator]!=null}function Sf(r){if(Tf(r))return(async()=>{let n=new Uint8Array(0);for await(let o of r)n=vt([n,o],n.length+o.length);return n})();let e=[],t=0;for(let n of r)e.push(n),t+=n.byteLength;return vt(e,t)}var D=Sf;function br({enumerable:r=!0,configurable:e=!1}={}){return{enumerable:r,configurable:e,writable:!1}}function*Bf(r,e){if(e!=null&&typeof e=="object")if(Array.isArray(e))for(let[t,n]of e.entries()){let o=[...r,t],i=N.asCID(n);i!=null?yield[o.join("/"),i]:typeof n=="object"&&(yield*fo(n,o))}else{let t=N.asCID(e);t!=null?yield[r.join("/"),t]:yield*fo(e,r)}}function*fo(r,e){if(r==null||r instanceof Uint8Array)return;let t=N.asCID(r);t!=null&&(yield[e.join("/"),t]);for(let[n,o]of Object.entries(r)){let i=[...e,n];yield*Bf(i,o)}}function*Nf(r,e){if(Array.isArray(e))for(let[t,n]of e.entries()){let o=[...r,t];yield o.join("/"),typeof n=="object"&&N.asCID(n)==null&&(yield*lo(n,o))}else yield*lo(e,r)}function*lo(r,e){if(!(r==null||typeof r!="object"))for(let[t,n]of Object.entries(r)){let o=[...e,t];yield o.join("/"),n!=null&&!(n instanceof Uint8Array)&&typeof n=="object"&&N.asCID(n)==null&&(yield*Nf(o,n))}}function Cf(r,e){let t=r;for(let[n,o]of e.entries()){if(t=t[o],t==null)throw new Error(`Object has no property at ${e.slice(0,n+1).map(s=>`[${JSON.stringify(s)}]`).join("")}`);let i=N.asCID(t);if(i!=null)return{value:i,remaining:e.slice(n+1).join("/")}}return{value:t}}var ho=class{cid;bytes;value;asBlock;constructor({cid:e,bytes:t,value:n}){if(e==null||t==null||typeof n>"u")throw new Error("Missing required argument");this.cid=e,this.bytes=t,this.value=n,this.asBlock=this,Object.defineProperties(this,{cid:br(),bytes:br(),value:br(),asBlock:br()})}links(){return fo(this.value,[])}tree(){return lo(this.value,[])}get(e="/"){return Cf(this.value,e.split("/").filter(Boolean))}};function se({bytes:r,cid:e,value:t,codec:n}){let o=t!==void 0?t:n?.decode(r);if(o===void 0)throw new Error('Missing required argument, must either provide "value" or "codec"');return new ho({cid:e,bytes:r,value:o})}var Ms=class extends Array{constructor(){super(),this.inRecursive=[]}prefix(e){let t=this.inRecursive[this.inRecursive.length-1];t&&(t.type===f.array&&(t.elements++,t.elements!==1&&e.push([44])),t.type===f.map&&(t.elements++,t.elements!==1&&(t.elements%2===1?e.push([44]):e.push([58]))))}[f.uint.major](e,t){this.prefix(e);let n=String(t.value),o=[];for(let i=0;i<n.length;i++)o[i]=n.charCodeAt(i);e.push(o)}[f.negint.major](e,t){this[f.uint.major](e,t)}[f.bytes.major](e,t){throw new Error(`${Le} unsupported type: Uint8Array`)}[f.string.major](e,t){this.prefix(e);let n=Ht(JSON.stringify(t.value));e.push(n.length>32?rt(n):n)}[f.array.major](e,t){this.prefix(e),this.inRecursive.push({type:f.array,elements:0}),e.push([91])}[f.map.major](e,t){this.prefix(e),this.inRecursive.push({type:f.map,elements:0}),e.push([123])}[f.tag.major](e,t){}[f.float.major](e,t){if(t.type.name==="break"){let s=this.inRecursive.pop();if(s){if(s.type===f.array)e.push([93]);else if(s.type===f.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(t.value===void 0)throw new Error(`${Le} unsupported type: undefined`);if(this.prefix(e),t.type.name==="true"){e.push([116,114,117,101]);return}else if(t.type.name==="false"){e.push([102,97,108,115,101]);return}else if(t.type.name==="null"){e.push([110,117,108,108]);return}let n=String(t.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 Qe=class{constructor(e,t={}){this._pos=0,this.data=e,this.options=t,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(`${_} unexpected end of input at position ${this._pos}`);for(let t=0;t<e.length;t++)if(this.data[this._pos++]!==e[t])throw new Error(`${_} unexpected token at position ${this._pos}, expected to find '${String.fromCharCode(...e)}'`)}parseNumber(){let e=this._pos,t=!1,n=!1,o=a=>{for(;!this.done();){let c=this.ch();if(a.includes(c))this._pos++;else break}};if(this.ch()===45&&(t=!0,this._pos++),this.ch()===48)if(this._pos++,this.ch()===46)this._pos++,n=!0;else return new y(f.uint,0,this._pos-e);if(o([48,49,50,51,52,53,54,55,56,57]),t&&this._pos===e+1)throw new Error(`${_} unexpected token at position ${this._pos}`);if(!this.done()&&this.ch()===46){if(n)throw new Error(`${_} 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 y(f.float,s,this._pos-e):this.options.allowBigInt!==!0||Number.isSafeInteger(s)?new y(s>=0?f.uint:f.negint,s,this._pos-e):new y(s>=0?f.uint:f.negint,BigInt(i),this._pos-e)}parseString(){if(this.ch()!==34)throw new Error(`${_} 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 a=this.data[i];if(a===92||a<32||a>=128)break;if(a===34){let c=String.fromCharCode.apply(null,this.data.subarray(this._pos,i));return this._pos=i+1,new y(f.string,c,s)}}let e=this._pos,t=[],n=()=>{if(this._pos+4>=this.data.length)throw new Error(`${_} unexpected end of unicode escape sequence at position ${this._pos}`);let i=0;for(let s=0;s<4;s++){let a=this.ch();if(a>=48&&a<=57)a-=48;else if(a>=97&&a<=102)a=a-97+10;else if(a>=65&&a<=70)a=a-65+10;else throw new Error(`${_} unexpected unicode escape character at position ${this._pos}`);i=i*16+a,this._pos++}return i},o=()=>{let i=this.ch(),s=null,a=i>239?4:i>223?3:i>191?2:1;if(this._pos+a>this.data.length)throw new Error(`${_} unexpected unicode sequence at position ${this._pos}`);let c,h,d,p;switch(a){case 1:i<128&&(s=i);break;case 2:c=this.data[this._pos+1],(c&192)===128&&(p=(i&31)<<6|c&63,p>127&&(s=p));break;case 3:c=this.data[this._pos+1],h=this.data[this._pos+2],(c&192)===128&&(h&192)===128&&(p=(i&15)<<12|(c&63)<<6|h&63,p>2047&&(p<55296||p>57343)&&(s=p));break;case 4:c=this.data[this._pos+1],h=this.data[this._pos+2],d=this.data[this._pos+3],(c&192)===128&&(h&192)===128&&(d&192)===128&&(p=(i&15)<<18|(c&63)<<12|(h&63)<<6|d&63,p>65535&&p<1114112&&(s=p))}s===null?(s=65533,a=1):s>65535&&(s-=65536,t.push(s>>>10&1023|55296),s=56320|s&1023),t.push(s),this._pos+=a};for(;!this.done();){let i=this.ch(),s;switch(i){case 92:if(this._pos++,this.done())throw new Error(`${_} unexpected string termination at position ${this._pos}`);switch(s=this.ch(),this._pos++,s){case 34:case 39:case 92:case 47:t.push(s);break;case 98:t.push(8);break;case 116:t.push(9);break;case 110:t.push(10);break;case 102:t.push(12);break;case 114:t.push(13);break;case 117:t.push(n());break;default:throw new Error(`${_} unexpected string escape character at position ${this._pos}`)}break;case 34:return this._pos++,new y(f.string,$r(t),this._pos-e);default:if(i<32)throw new Error(`${_} invalid control character at position ${this._pos}`);i<128?(t.push(i),this._pos++):o()}}throw new Error(`${_} unexpected end of string at position ${this._pos}`)}parseValue(){switch(this.ch()){case 123:return this.modeStack.push("obj-start"),this._pos++,new y(f.map,1/0,1);case 91:return this.modeStack.push("array-start"),this._pos++,new y(f.array,1/0,1);case 34:return this.parseString();case 110:return this.expect([110,117,108,108]),new y(f.null,null,4);case 102:return this.expect([102,97,108,115,101]),new y(f.false,!1,5);case 116:return this.expect([116,114,117,101]),new y(f.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(`${_} 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 y(f.break,void 0,1);if(this.ch()!==44)throw new Error(`${_} 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 y(f.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 y(f.break,void 0,1);if(this.ch()!==44)throw new Error(`${_} 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 y(f.break,void 0,1);let e=this.parseString();if(this.skipWhitespace(),this.ch()!==58)throw new Error(`${_} 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(`${_} unexpected parse state at position ${this._pos}; this shouldn't happen`)}}};function po(r,e){return e=Object.assign({tokenizer:new Qe(r,e)},e),ut(r,e)}function Pf(r){return r instanceof ArrayBuffer?new Uint8Array(r,0,r.byteLength):r}var mo=class extends Qe{constructor(e,t){super(e,t),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===f.map){let t=this._next();if(t.type===f.string&&t.value==="/"){let n=this._next();if(n.type===f.string){if(this._next().type!==f.break)throw new Error("Invalid encoded CID form");return this.tokenBuffer.push(n),new y(f.tag,42,0)}if(n.type===f.map){let o=this._next();if(o.type===f.string&&o.value==="bytes"){let i=this._next();if(i.type===f.string){for(let a=0;a<2;a++)if(this._next().type!==f.break)throw new Error("Invalid encoded Bytes form");let s=kn.decode(`m${i.value}`);return new y(f.bytes,s,i.value.length)}this.tokenBuffer.push(i)}this.tokenBuffer.push(o)}this.tokenBuffer.push(n)}this.tokenBuffer.push(t)}return e}},yo={allowIndefinite:!1,allowUndefined:!1,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:[]};yo.tags[42]=N.parse;var $s=297;var Os=r=>{let e=Pf(r),t=Object.assign(yo,{tokenizer:new mo(e,yo)});return po(e,t)};var r0=new TextDecoder;var n0=new TextEncoder;var Uf=new TextDecoder;function go(r,e){let t=0;for(let n=0;;n+=7){if(n>=64)throw new Error("protobuf: varint overflow");if(e>=r.length)throw new Error("protobuf: unexpected end of data");let o=r[e++];if(t+=n<28?(o&127)<<n:(o&127)*2**n,o<128)break}return[t,e]}function Er(r,e){let t;[t,e]=go(r,e);let n=e+t;if(t<0||n<0)throw new Error("protobuf: invalid length");if(n>r.length)throw new Error("protobuf: unexpected end of data");return[r.subarray(e,n),n]}function Vs(r,e){let t;return[t,e]=go(r,e),[t&7,t>>3,e]}function Rf(r){let e={},t=r.length,n=0;for(;n<t;){let o,i;if([o,i,n]=Vs(r,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]=Er(r,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]=Er(r,n),e.Name=Uf.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]=go(r,n)}else throw new Error(`protobuf: (PBLink) invalid fieldNumber, expected 1, 2 or 3, got ${i}`)}if(n>t)throw new Error("protobuf: (PBLink) unexpected end of data");return e}function qs(r){let e=r.length,t=0,n,o=!1,i;for(;t<e;){let a,c;if([a,c,t]=Vs(r,t),a!==2)throw new Error(`protobuf: (PBNode) invalid wireType, expected 2, got ${a}`);if(c===1){if(i)throw new Error("protobuf: (PBNode) duplicate Data section");[i,t]=Er(r,t),n&&(o=!0)}else if(c===2){if(o)throw new Error("protobuf: (PBNode) duplicate Links section");n||(n=[]);let h;[h,t]=Er(r,t),n.push(Rf(h))}else throw new Error(`protobuf: (PBNode) invalid fieldNumber, expected 1 or 2, got ${c}`)}if(t>e)throw new Error("protobuf: (PBNode) unexpected end of data");let s={};return i&&(s.Data=i),s.Links=n||[],s}var js=new TextEncoder,Gs=2**32,Ff=2**31;function zf(r,e){let t=e.length;if(typeof r.Tsize=="number"){if(r.Tsize<0)throw new Error("Tsize cannot be negative");if(!Number.isSafeInteger(r.Tsize))throw new Error("Tsize too large for encoding");t=Nt(e,t,r.Tsize)-1,e[t]=24}if(typeof r.Name=="string"){let n=js.encode(r.Name);t-=n.length,e.set(n,t),t=Nt(e,t,n.length)-1,e[t]=18}return r.Hash&&(t-=r.Hash.length,e.set(r.Hash,t),t=Nt(e,t,r.Hash.length)-1,e[t]=10),e.length-t}function Ws(r){let e=$f(r),t=new Uint8Array(e),n=e;if(r.Data&&(n-=r.Data.length,t.set(r.Data,n),n=Nt(t,n,r.Data.length)-1,t[n]=10),r.Links)for(let o=r.Links.length-1;o>=0;o--){let i=zf(r.Links[o],t.subarray(0,n));n-=i,n=Nt(t,n,i)-1,t[n]=18}return t}function Mf(r){let e=0;if(r.Hash){let t=r.Hash.length;e+=1+t+Ke(t)}if(typeof r.Name=="string"){let t=js.encode(r.Name).length;e+=1+t+Ke(t)}return typeof r.Tsize=="number"&&(e+=1+Ke(r.Tsize)),e}function $f(r){let e=0;if(r.Data){let t=r.Data.length;e+=1+t+Ke(t)}if(r.Links)for(let t of r.Links){let n=Mf(t);e+=1+n+Ke(n)}return e}function Nt(r,e,t){e-=Ke(t);let n=e;for(;t>=Ff;)r[e++]=t&127|128,t/=128;for(;t>=128;)r[e++]=t&127|128,t>>>=7;return r[e]=t,n}function Ke(r){return r%2===0&&r++,Math.floor((Of(r)+6)/7)}function Of(r){let e=0;return r>=Gs&&(r=Math.floor(r/Gs),e=32),r>=65536&&(r>>>=16,e+=16),r>=256&&(r>>>=8,e+=8),e+Hf[r]}var Hf=[0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8];var Vf=["Data","Links"],qf=["Hash","Name","Tsize"],Js=new TextEncoder;function Gf(r,e){if(r===e)return 0;let t=r.Name?Js.encode(r.Name):[],n=e.Name?Js.encode(e.Name):[],o=t.length,i=n.length;for(let s=0,a=Math.min(o,i);s<a;++s)if(t[s]!==n[s]){o=t[s],i=n[s];break}return o<i?-1:i<o?1:0}function Xs(r,e){return!Object.keys(r).some(t=>!e.includes(t))}function Qs(r){if(!r||typeof r!="object"||Array.isArray(r)||r instanceof Uint8Array||r["/"]&&r["/"]===r.bytes)throw new TypeError("Invalid DAG-PB form");if(!Xs(r,Vf))throw new TypeError("Invalid DAG-PB form (extraneous properties)");if(r.Data!==void 0&&!(r.Data instanceof Uint8Array))throw new TypeError("Invalid DAG-PB form (Data must be bytes)");if(!Array.isArray(r.Links))throw new TypeError("Invalid DAG-PB form (Links must be a list)");for(let e=0;e<r.Links.length;e++){let t=r.Links[e];if(!t||typeof t!="object"||Array.isArray(t)||t instanceof Uint8Array||t["/"]&&t["/"]===t.bytes)throw new TypeError("Invalid DAG-PB form (bad link)");if(!Xs(t,qf))throw new TypeError("Invalid DAG-PB form (extraneous properties on link)");if(t.Hash===void 0)throw new TypeError("Invalid DAG-PB form (link must have a Hash)");if(t.Hash==null||!t.Hash["/"]||t.Hash["/"]!==t.Hash.bytes)throw new TypeError("Invalid DAG-PB form (link Hash must be a CID)");if(t.Name!==void 0&&typeof t.Name!="string")throw new TypeError("Invalid DAG-PB form (link Name must be a string)");if(t.Tsize!==void 0){if(typeof t.Tsize!="number"||t.Tsize%1!==0)throw new TypeError("Invalid DAG-PB form (link Tsize must be an integer)");if(t.Tsize<0)throw new TypeError("Invalid DAG-PB form (link Tsize cannot be negative)")}if(e>0&&Gf(t,r.Links[e-1])===-1)throw new TypeError("Invalid DAG-PB form (links must be sorted by Name bytes)")}}function Ks(r){return r instanceof ArrayBuffer?new Uint8Array(r,0,r.byteLength):r}var vr=112;function Ys(r){Qs(r);let e={};return r.Links&&(e.Links=r.Links.map(t=>{let n={};return t.Hash&&(n.Hash=t.Hash.bytes),t.Name!==void 0&&(n.Name=t.Name),t.Tsize!==void 0&&(n.Tsize=t.Tsize),n})),r.Data&&(e.Data=r.Data),Ws(e)}function be(r){let e=Ks(r),t=qs(e),n={};return t.Data&&(n.Data=t.Data),t.Links&&(n.Links=t.Links.map(o=>{let i={};try{i.Hash=N.decode(o.Hash)}catch{}if(!i.Hash)throw new Error("Invalid Hash field found in link, expected CID");return o.Name!==void 0&&(i.Name=o.Name),o.Tsize!==void 0&&(i.Tsize=o.Tsize),i})),n}function jf(r){return r[Symbol.asyncIterator]!=null}function Wf(r,e){let t=0;if(jf(r))return(async function*(){for await(let c of r)await e(c,t++)&&(yield c)})();let n=or(r),{value:o,done:i}=n.next();if(i===!0)return(function*(){})();let s=e(o,t++);if(typeof s.then=="function")return(async function*(){await s&&(yield o);for(let c of n)await e(c,t++)&&(yield c)})();let a=e;return(function*(){s===!0&&(yield o);for(let c of n)a(c,t++)&&(yield c)})()}var kr=Wf;function Ct(r,e={}){return new wo(r,e)}function Dt(r,e={}){return new bo(r,e)}var _r=class{components;constructor(e,t){this.components=e}async*walk(e,t){let n=this.getQueue(),o=kr(n.toGenerator(t),a=>a!=null),i=!1,s=async a=>{let c=a.cid,h=await D(this.components.blockstore.get(c,a)),d=se({cid:c,bytes:h,codec:await this.components.getCodec(c.code)});for(let[,p]of d.links())n.add(s,{...a,cid:p,depth:a.depth+1,path:[...a.path,p]}).catch(v=>{i||o.throw(v)});return{block:d,depth:a.depth,path:a.path}};n.add(s,{...t,cid:e,depth:0,path:[e]}).catch(a=>{i||o.throw(a)});try{yield*o}finally{i=!0,n.abort()}}},wo=class extends _r{getQueue(){return new Bt({concurrency:1,sort:(e,t)=>e.options.depth===t.options.depth?0:e.options.depth<t.options.depth?1:-1})}},bo=class extends _r{getQueue(){return new Bt({concurrency:1,sort:(e,t)=>e.options.depth===t.options.depth?0:e.options.depth<t.options.depth?-1:1})}};var Lt=class{async*export(e,t,n,o){let i=Dt({blockstore:t,getCodec:n});for await(let s of i.walk(e,o))yield s.block}};var Ar=class{components;log;constructor(e){this.components=e,this.log=e.logger.forComponent("helia:car")}async import(e,t){await vn(this.components.blockstore.putMany(ge(e.blocks(),({cid:n,bytes:o})=>({cid:n,bytes:o})),t))}async*export(e,t){let{writer:n,out:o}=xt.create(e),i=o[Symbol.asyncIterator](),s=new AbortController;for(this._export(e,n,t).catch(a=>{this.log.error("error during streaming export - %e",a),s.abort(a)});;){let{done:a,value:c}=await ir(i.next(),s.signal);if(s.signal.aborted)throw s.signal.reason;if(c!=null&&(yield c),a===!0)break}}async _export(e,t,n){let o=Array.isArray(e)?e:[e],i=n?.traversal;for(let s of o){let a=n?.exporter??(s.code===112?new Pt:new Lt),c=s,h=!1;if(i!=null){for await(let{cid:d,bytes:p}of i.traverse(c,this.components.blockstore,this.components.getCodec,n))if(this.log.trace("next CID on path to %c is %c",s,d),c=d,s.equals(d)&&(h=!0),h||n?.includeTraversalBlocks===!0){if(n?.blockFilter?.has(d.multihash.bytes)===!0)continue;n?.blockFilter?.add(d.multihash.bytes),await t.put({cid:d,bytes:p})}}for await(let{cid:d,bytes:p}of a.export(c,this.components.blockstore,this.components.getCodec,n))n?.blockFilter?.has(d.multihash.bytes)!==!0&&(h&&d.equals(c)||(n?.blockFilter?.add(d.multihash.bytes),await t.put({cid:d,bytes:p})))}await t.close()}};var Eo=class{async*export(e,t,n,o){let i=await D(t.get(e,o));yield se({cid:e,bytes:i,codec:await n(e.code)})}};var Ir=class extends Error{static code="ERR_NOT_UNIXFS";static message="Not a UnixFS node";static name="NotUnixFSError";code="ERR_NOT_UNIXFS";message="Not a UnixFS node";name="NotUnixFSError"},Tr=class extends Error{static name="NotDescendantError";name="NotDescendantError"},Ye=class extends Error{static name="InvalidTraversalError";name="InvalidTraversalError"};var Pt=class{async*export(e,t,n,o){if(e.code!==112&&e.code!==85)throw new Ir("Target CID was not UnixFS - use the SubGraphExporter to export arbitrary graphs");let i=Ct({blockstore:t,getCodec:n});for await(let s of i.walk(e,o))yield s.block}};function Zs(r){return r!=null&&r?.asCID===r}var vo=class{haystack;needle;options;constructor(...e){if(Zs(e[0]))Zs(e[1])?(this.haystack=e[0],this.needle=e[1],this.options=e[2]):(this.needle=e[0],this.options=e[1]);else throw new sr("needle must be specified")}async*traverse(e,t,n,o){let i=this.haystack??e,s;this.options?.strategy==="breadth-first"?s=Dt({blockstore:t,getCodec:n}):s=Ct({blockstore:t,getCodec:n});for await(let a of s.walk(i,o))if(a.block.cid.equals(this.needle)){for(let c of a.path){let h=await D(t.get(c,o));yield se({cid:c,bytes:h,codec:await n(c.code)})}return}throw new Ye(`${this.needle} was not a child of ${i}`)}};var ko=class{path;constructor(e){this.path=e}async*traverse(e,t,n,o){if(!this.path.some(s=>s.equals(e)))throw new Ye(`CIDPath traversal must include ${e}`);let i;for(let s of this.path){if(i!=null){let h=!1;for(let[,d]of i.links())if(d.equals(s)){h=!0;break}if(!h)throw new Tr(`${s} is not a child of ${i.cid}`)}let a=await D(t.get(s,o)),c=se({cid:s,bytes:a,codec:await n(s.code)});i=c,yield c}}};var Sr=class r extends Error{static name="BadPathError";static code="ERR_BAD_PATH";name=r.name;code=r.code;constructor(e="Bad path"){super(e)}},ee=class r extends Error{static name="NotFoundError";static code="ERR_NOT_FOUND";name=r.name;code=r.code;constructor(e="Not found"){super(e)}},Br=class r extends Error{static name="NoResolverError";static code="ERR_NO_RESOLVER";name=r.name;code=r.code;constructor(e="No resolver"){super(e)}},P=class r extends Error{static name="NotUnixFSError";static code="ERR_NOT_UNIXFS";name=r.name;code=r.code;constructor(e="Not UnixFS"){super(e)}},Nr=class r extends Error{static name="OverReadError";static code="ERR_OVER_READ";name=r.name;code=r.code;constructor(e="Over read"){super(e)}},Cr=class r extends Error{static name="UnderReadError";static code="ERR_UNDER_READ";name=r.name;code=r.code;constructor(e="Under read"){super(e)}},Dr=class r extends Error{static name="NoPropError";static code="ERR_NO_PROP";name=r.name;code=r.code;constructor(e="No Property found"){super(e)}},Te=class r extends Error{static name="InvalidParametersError";static code="ERR_INVALID_PARAMS";name=r.name;code=r.code;constructor(e="Invalid parameters"){super(e)}};function Ze(r,e,t,n,o,i,s){let a=r,c=o;for(;i.length>0;){let h=i[0];if(h in a){i.shift(),c=`${c}/${h}`;let d=N.asCID(a[h]);if(d!=null)return{entry:{type:"object",name:n,path:o,cid:t,node:e,depth:s,size:BigInt(e.length),content:async function*(){yield r}},next:{cid:d,name:h,path:c,toResolve:i}};a=a[h]}else throw new Dr(`No property named ${h} found in node ${t}`)}return{entry:{type:"object",name:n,path:o,cid:t,node:e,depth:s,size:BigInt(e.length),content:async function*(){yield r}}}}var Xf=async(r,e,t,n,o,i,s,a)=>{let c=await D(s.get(r,a)),h=pt(c);return Ze(h,c,r,e,t,n,i)},ea=Xf;var Qf=async(r,e,t,n,o,i,s,a)=>{let c=await D(s.get(r,a)),h=Os(c);return Ze(h,c,r,e,t,n,i)},ta=Qf;function Kf(r,e,t,n){let o=BigInt(r.length),i=BigInt(e+o);return t>=i||n<e?new Uint8Array(0):(n>=e&&n<i&&(r=r.subarray(0,Number(n-e))),t>=e&&t<i&&(r=r.subarray(Number(t-e))),r)}var Se=Kf;var Yf=(r,e=0,t=r)=>{let n=BigInt(r),o=BigInt(e??0),i=BigInt(t);if(i!==n&&(i=o+i),i>n&&(i=n),o<0n)throw new Te("Offset must be greater than or equal to 0");if(o>n)throw new Te("Offset must be less than the file size");if(i<0n)throw new Te("Length must be greater than or equal to 0");if(i>n)throw new Te("Length must be less than the file size");return{start:o,end:i}},et=Yf;var Zf=r=>{async function*e(t={}){let{start:n,end:o}=et(r.length,t.offset,t.length),i=Se(r,0n,n,o);t.onProgress?.(new R("unixfs:exporter:progress:identity",{bytesRead:BigInt(i.byteLength),totalBytes:o-n,fileSize:BigInt(r.byteLength)})),yield i}return e},el=async(r,e,t,n,o,i,s,a)=>{if(n.length>0)throw new ee(`No link named ${t} found in raw node ${r}`);let c=qe(r.multihash.bytes);return{entry:{type:"identity",name:e,path:t,cid:r,content:Zf(c.digest),depth:i,size:BigInt(c.digest.length),node:c.digest}}},ra=el;var tl=async(r,e,t,n,o,i,s,a)=>{let c=await D(s.get(r,a)),h=cs(c);return Ze(h,c,r,e,t,n,i)},na=tl;var rl=r=>{async function*e(t={}){let{start:n,end:o}=et(r.length,t.offset,t.length),i=Se(r,0n,n,o);t.onProgress?.(new R("unixfs:exporter:progress:raw",{bytesRead:BigInt(i.byteLength),totalBytes:o-n,fileSize:BigInt(r.byteLength)})),yield i}return e},nl=async(r,e,t,n,o,i,s,a)=>{if(n.length>0)throw new ee(`No link named ${t} found in raw node ${r}`);let c=await D(s.get(r,a));return{entry:{type:"raw",name:e,path:t,cid:r,content:rl(c),depth:i,size:BigInt(c.length),node:c}}},oa=nl;var Ut=class r extends Error{static name="InvalidTypeError";static code="ERR_INVALID_TYPE";name=r.name;code=r.code;constructor(e="Invalid type"){super(e)}},Lr=class r extends Error{static name="InvalidUnixFSMessageError";static code="ERR_INVALID_MESSAGE";name=r.name;code=r.code;constructor(e="Invalid message"){super(e)}};var te;(function(r){let e;(function(o){o.Raw="Raw",o.Directory="Directory",o.File="File",o.Metadata="Metadata",o.Symlink="Symlink",o.HAMTShard="HAMTShard"})(e=r.DataType||(r.DataType={}));let t;(function(o){o[o.Raw=0]="Raw",o[o.Directory=1]="Directory",o[o.File=2]="File",o[o.Metadata=3]="Metadata",o[o.Symlink=4]="Symlink",o[o.HAMTShard=5]="HAMTShard"})(t||(t={})),(function(o){o.codec=()=>ro(t)})(e=r.DataType||(r.DataType={}));let n;r.codec=()=>(n==null&&(n=St((o,i,s={})=>{if(s.lengthDelimited!==!1&&i.fork(),o.Type!=null&&(i.uint32(8),r.DataType.codec().encode(o.Type,i)),o.Data!=null&&(i.uint32(18),i.bytes(o.Data)),o.filesize!=null&&(i.uint32(24),i.uint64(o.filesize)),o.blocksizes!=null)for(let a of o.blocksizes)i.uint32(32),i.uint64(a);o.hashType!=null&&(i.uint32(40),i.uint64(o.hashType)),o.fanout!=null&&(i.uint32(48),i.uint64(o.fanout)),o.mode!=null&&(i.uint32(56),i.uint32(o.mode)),o.mtime!=null&&(i.uint32(66),Pr.codec().encode(o.mtime,i)),s.lengthDelimited!==!1&&i.ldelim()},(o,i)=>{let s={blocksizes:[]},a=i==null?o.len:o.pos+i;for(;o.pos<a;){let c=o.uint32();switch(c>>>3){case 1:s.Type=r.DataType.codec().decode(o);break;case 2:s.Data=o.bytes();break;case 3:s.filesize=o.uint64();break;case 4:s.blocksizes.push(o.uint64());break;case 5:s.hashType=o.uint64();break;case 6:s.fanout=o.uint64();break;case 7:s.mode=o.uint32();break;case 8:s.mtime=Pr.codec().decode(o,o.uint32());break;default:o.skipType(c&7);break}}return s})),n),r.encode=o=>Tt(o,r.codec()),r.decode=o=>_t(o,r.codec())})(te||(te={}));var Pr;(function(r){let e;r.codec=()=>(e==null&&(e=St((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Seconds!=null&&(n.uint32(8),n.int64(t.Seconds)),t.FractionalNanoseconds!=null&&(n.uint32(21),n.fixed32(t.FractionalNanoseconds)),o.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let o={},i=n==null?t.len:t.pos+n;for(;t.pos<i;){let s=t.uint32();switch(s>>>3){case 1:o.Seconds=t.int64();break;case 2:o.FractionalNanoseconds=t.fixed32();break;default:t.skipType(s&7);break}}return o})),e),r.encode=t=>Tt(t,r.codec()),r.decode=t=>_t(t,r.codec())})(Pr||(Pr={}));var ia;(function(r){let e;r.codec=()=>(e==null&&(e=St((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.MimeType!=null&&(n.uint32(10),n.string(t.MimeType)),o.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let o={},i=n==null?t.len:t.pos+n;for(;t.pos<i;){let s=t.uint32();switch(s>>>3){case 1:o.MimeType=t.string();break;default:t.skipType(s&7);break}}return o})),e),r.encode=t=>Tt(t,r.codec()),r.decode=t=>_t(t,r.codec())})(ia||(ia={}));var sa={Raw:"raw",Directory:"directory",File:"file",Metadata:"metadata",Symlink:"symlink",HAMTShard:"hamt-sharded-directory"},ol=["directory","hamt-sharded-directory"],aa=parseInt("0644",8),ca=parseInt("0755",8),ua=BigInt(1024),ae=class r{static unmarshal(e){let t=te.decode(e);if(t.fanout!=null&&t.fanout>ua)throw new Lr(`Fanout size was too large - ${t.fanout} > ${ua}`);let n=new r({type:sa[t.Type!=null?t.Type.toString():"File"],data:t.Data,blockSizes:t.blocksizes,mode:t.mode,mtime:t.mtime!=null?{secs:t.mtime.Seconds??0n,nsecs:t.mtime.FractionalNanoseconds}:void 0,fanout:t.fanout});return n._originalMode=t.mode??0,n}type;data;blockSizes;hashType;fanout;mtime;_mode;_originalMode;constructor(e={type:"file"}){let{type:t,data:n,blockSizes:o,hashType:i,fanout:s,mtime:a,mode:c}=e;if(t!=null&&!Object.values(sa).includes(t))throw new Ut("Type: "+t+" is not valid");this.type=t??"file",this.data=n,this.hashType=i,this.fanout=s,this.blockSizes=o??[],this._originalMode=0,this.mode=c,this.mtime=a}set mode(e){e==null?this._mode=this.isDirectory()?ca:aa:this._mode=e&4095}get mode(){return this._mode}isDirectory(){return ol.includes(this.type)}addBlockSize(e){this.blockSizes.push(e)}removeBlockSize(e){this.blockSizes.splice(e,1)}fileSize(){if(this.isDirectory())return 0n;let e=0n;return this.blockSizes.forEach(t=>{e+=t}),this.data!=null&&(e+=BigInt(this.data.length)),e}marshal(){let e;switch(this.type){case"raw":e=te.DataType.Raw;break;case"directory":e=te.DataType.Directory;break;case"file":e=te.DataType.File;break;case"metadata":e=te.DataType.Metadata;break;case"symlink":e=te.DataType.Symlink;break;case"hamt-sharded-directory":e=te.DataType.HAMTShard;break;default:throw new Ut(`Type: ${e} is not valid`)}let t=this.data;(this.data==null||this.data.length===0)&&(t=void 0);let n;this.mode!=null&&(n=this._originalMode&4294963200|(this.mode??0),n===aa&&!this.isDirectory()&&(n=void 0),n===ca&&this.isDirectory()&&(n=void 0));let o;return this.mtime!=null&&(o={Seconds:this.mtime.secs,FractionalNanoseconds:this.mtime.nsecs}),te.encode({Type:e,Data:t,filesize:this.isDirectory()?void 0:this.fileSize(),blocksizes:this.blockSizes,hashType:this.hashType,fanout:this.fanout,mode:n,mtime:o})}};var Rr=Ee(ha(),1);function il(r){let e=new Array(4);for(let t=0;t<4;t++)e[t]=r&255,r=r>>8;return new Uint8Array(e)}var Mg=_e({name:"murmur3-32",code:35,encode:r=>il(Rr.default.x86.hash32(r))}),da=_e({name:"murmur3-128",code:34,encode:r=>ke.fromHex(Rr.default.x64.hash128(r))}),$g=_e({name:"murmur3-x64-64",code:34,encode:r=>ke.fromHex(Rr.default.x64.hash128(r)).subarray(0,8)});var ga=Ee(ya(),1);var Be=class r{_options;_popCount;_parent;_posAtParent;_children;key;constructor(e,t,n=0){this._options=e,this._popCount=0,this._parent=t,this._posAtParent=n,this._children=new ga.default,this.key=null}async put(e,t){let n=await this._findNewBucketAndPos(e);n.bucket._putAt(n,e,t)}async get(e){let t=await this._findChild(e);if(t!=null)return t.value}async del(e){let t=await this._findPlace(e),n=t.bucket._at(t.pos);n!=null&&n.key===e&&t.bucket._delAt(t.pos)}leafCount(){return this._children.compactArray().reduce((t,n)=>n instanceof r?t+n.leafCount():t+1,0)}childrenCount(){return this._children.length}onlyChild(){return this._children.get(0)}*eachLeafSeries(){let e=this._children.compactArray();for(let t of e)t instanceof r?yield*t.eachLeafSeries():yield t}serialize(e,t){let n=[];return t(this._children.reduce((o,i,s)=>(i!=null&&(i instanceof r?o.push(i.serialize(e,t)):o.push(e(i,s))),o),n))}async asyncTransform(e,t){return xa(this,e,t)}toJSON(){return this.serialize(fl,ll)}prettyPrint(){return JSON.stringify(this.toJSON(),null," ")}tableSize(){return Math.pow(2,this._options.bits)}async _findChild(e){let t=await this._findPlace(e),n=t.bucket._at(t.pos);if(!(n instanceof r)&&n!=null&&n.key===e)return n}async _findPlace(e){let t=this._options.hash(typeof e=="string"?fr(e):e),n=await t.take(this._options.bits),o=this._children.get(n);return o instanceof r?o._findPlace(t):{bucket:this,pos:n,hash:t,existingChild:o}}async _findNewBucketAndPos(e){let t=await this._findPlace(e);if(t.existingChild!=null&&t.existingChild.key!==e){let n=new r(this._options,t.bucket,t.pos);t.bucket._putObjectAt(t.pos,n);let o=await n._findPlace(t.existingChild.hash);return o.bucket._putAt(o,t.existingChild.key,t.existingChild.value),n._findNewBucketAndPos(t.hash)}return t}_putAt(e,t,n){this._putObjectAt(e.pos,{key:t,value:n,hash:e.hash})}_putObjectAt(e,t){this._children.get(e)==null&&this._popCount++,this._children.set(e,t)}_delAt(e){if(e===-1)throw new Error("Invalid position");this._children.get(e)!=null&&this._popCount--,this._children.unset(e),this._level()}_level(){if(this._parent!=null&&this._popCount<=1)if(this._popCount===1){let e=this._children.find(ul);if(e!=null&&!(e instanceof r)){let t=e.hash;t.untake(this._options.bits);let n={pos:this._posAtParent,hash:t,bucket:this._parent};this._parent._putAt(n,e.key,e.value)}}else this._parent._delAt(this._posAtParent)}_at(e){return this._children.get(e)}};function ul(r){return!!r}function fl(r,e){return r.key}function ll(r){return r}async function xa(r,e,t){let n=[];for(let o of r._children.compactArray())if(o instanceof Be)await xa(o,e,t);else{let i=await e(o);n.push({bitField:r._children.bitField(),children:i})}return t(n)}var hl=[255,254,252,248,240,224,192,128],dl=[1,3,7,15,31,63,127,255],Fr=class{_value;_currentBytePos;_currentBitPos;constructor(e){this._value=e,this._currentBytePos=e.length-1,this._currentBitPos=7}availableBits(){return this._currentBitPos+1+this._currentBytePos*8}totalBits(){return this._value.length*8}take(e){let t=e,n=0;for(;t>0&&this._haveBits();){let o=this._value[this._currentBytePos],i=this._currentBitPos+1,s=Math.min(i,t),a=pl(o,i-s,s);n=(n<<s)+a,t-=s,this._currentBitPos-=s,this._currentBitPos<0&&(this._currentBitPos=7,this._currentBytePos--)}return n}untake(e){for(this._currentBitPos+=e;this._currentBitPos>7;)this._currentBitPos-=8,this._currentBytePos+=1}_haveBits(){return this._currentBytePos>=0}};function pl(r,e,t){let n=ml(e,t);return(r&n)>>>e}function ml(r,e){return hl[r]&dl[Math.min(e+r-1,7)]}function wa(r){function e(t){return t instanceof zr?t:new zr(t,r)}return e}var zr=class{_value;_hashFn;_depth;_availableBits;_currentBufferIndex;_buffers;constructor(e,t){if(!(e instanceof Uint8Array))throw new Error("can only hash Uint8Arrays");this._value=e,this._hashFn=t,this._depth=-1,this._availableBits=0,this._currentBufferIndex=0,this._buffers=[]}async take(e){let t=e;for(;this._availableBits<t;)await this._produceMoreBits();let n=0;for(;t>0;){let o=this._buffers[this._currentBufferIndex],i=Math.min(o.availableBits(),t),s=o.take(i);n=(n<<i)+s,t-=i,this._availableBits-=i,o.availableBits()===0&&this._currentBufferIndex++}return n}untake(e){let t=e;for(;t>0;){let n=this._buffers[this._currentBufferIndex],o=Math.min(n.totalBits()-n.availableBits(),t);n.untake(o),t-=o,this._availableBits+=o,this._currentBufferIndex>0&&n.totalBits()===n.availableBits()&&(this._depth--,this._currentBufferIndex--)}}async _produceMoreBits(){this._depth++;let e=this._depth>0?vt([this._value,Uint8Array.from([this._depth])]):this._value,t=await this._hashFn(e),n=new Fr(t);this._buffers.push(n),this._availableBits+=n.availableBits()}};function ba(r){if(r==null||r.hashFn==null)throw new Error("please define an options.hashFn");let e={bits:r.bits??8,hash:wa(r.hashFn)};return new Be(e)}var yl=async function(r){return(await da.encode(r)).slice(0,8).reverse()},gl=async(r,e,t)=>{let n=(e.tableSize()-1).toString(16).length;await Promise.all(r.map(async o=>{if(o.Name==null)throw new Error("Unexpected Link without a Name");if(o.Name.length===n){let i=parseInt(o.Name,16);e._putObjectAt(i,new Be({hash:t._options.hash,bits:t._options.bits},e,i));return}await t.put(o.Name.substring(2),!0)}))},Ea=(r,e)=>r.toString(16).toUpperCase().padStart(e,"0").substring(0,e),xl=r=>{let e=r.bucket,t=[];for(;e._parent!=null;)t.push(e),e=e._parent;return t.push(e),t.reverse()},va=async(r,e,t,n,o)=>{if(n==null){if(r.Data==null)throw new P("no data in PBNode");let p;try{p=ae.unmarshal(r.Data)}catch(u){throw new P(u.message)}if(p.type!=="hamt-sharded-directory")throw new P("not a HAMT");if(p.fanout==null)throw new P("missing fanout");let v=ba({hashFn:yl,bits:Math.log2(Number(p.fanout))});n={rootBucket:v,hamtDepth:1,lastBucket:v}}let i=(n.lastBucket.tableSize()-1).toString(16).length;await gl(r.Links,n.lastBucket,n.rootBucket);let s=await n.rootBucket._findNewBucketAndPos(e),a=Ea(s.pos,i),c=xl(s);c.length>n.hamtDepth&&(n.lastBucket=c[n.hamtDepth],a=Ea(n.lastBucket._posAtParent,i));let h=r.Links.find(p=>{if(p.Name==null)return!1;let v=p.Name.substring(0,i),u=p.Name.substring(i);return!(v!==a||u!==""&&u!==e)});if(h==null)return;if(h.Name!=null&&h.Name.substring(i)===e)return h.Hash;n.hamtDepth++;let d=await D(t.get(h.Hash,o));return r=be(d),va(r,e,t,n,o)},ka=va;function tt(r){return r?.extended===!1}var Mr=globalThis.CustomEvent??Event;async function*Ne(r,e={}){let t=e.concurrency??1/0;t<1&&(t=1/0);let n=e.ordered??!1,o=new EventTarget,i=[],s=$(),a=$(),c=!1,h,d=!1;o.addEventListener("task-complete",()=>{a.resolve()}),Promise.resolve().then(async()=>{try{for await(let l of r){if(i.length===t&&(s=$(),await s.promise),d)break;let m={done:!1};i.push(m),l().then(I=>{m.done=!0,m.ok=!0,m.value=I,o.dispatchEvent(new Mr("task-complete"))},I=>{m.done=!0,m.err=I,o.dispatchEvent(new Mr("task-complete"))})}c=!0,o.dispatchEvent(new Mr("task-complete"))}catch(l){h=l,o.dispatchEvent(new Mr("task-complete"))}});function p(){return n?i[0]?.done:!!i.find(l=>l.done)}function*v(){for(;i.length>0&&i[0].done;){let l=i[0];if(i.shift(),l.ok)yield l.value;else throw d=!0,s.resolve(),l.err;s.resolve()}}function*u(){for(;p();)for(let l=0;l<i.length;l++)if(i[l].done){let m=i[l];if(i.splice(l,1),l--,m.ok)yield m.value;else throw d=!0,s.resolve(),m.err;s.resolve()}}for(;;){if(p()||(a=$(),await a.promise),h!=null||(n?yield*v():yield*u(),h!=null))throw h;if(c&&i.length===0)break}}var wl=(r,e,t,n,o,i,s)=>{async function*a(c={}){let h=c.offset??0,d=c.length??e.Links.length,p=e.Links.slice(h,d);c.onProgress?.(new R("unixfs:exporter:walk:directory",{cid:r})),yield*Xe(p,v=>ge(v,u=>async()=>{let l=u.Name??"",m=`${n}/${l}`;return tt(c)?{cid:u.Hash,name:l,path:m}:(await o(u.Hash,l,m,[],i+1,s,c)).entry}),v=>Ne(v,{ordered:!0,concurrency:c.blockReadConcurrency}),v=>kr(v,u=>u!=null))}return a},_a=wl;async function Aa(r,e,t,n,o,i,s){if(e instanceof Uint8Array){let h=Se(e,n,o,i);t.push(h);return}if(e.Data==null)throw new P("no data in PBNode");let a;try{a=ae.unmarshal(e.Data)}catch(h){throw new P(h.message)}if(a.data!=null){let h=a.data,d=Se(h,n,o,i);t.push(d),n+=BigInt(d.byteLength)}let c=[];if(e.Links.length!==a.blockSizes.length)throw new P("Inconsistent block sizes and dag links");for(let h=0;h<e.Links.length;h++){let d=e.Links[h],p=n,v=p+a.blockSizes[h];if((o>=p&&o<v||i>=p&&i<=v||o<p&&i>v)&&c.push({link:d,blockStart:n}),n=v,n>i)break}await Xe(c,h=>ge(h,d=>async()=>{let p=await D(r.get(d.link.Hash,s));return{...d,block:p}}),h=>Ne(h,{ordered:!0,concurrency:s.blockReadConcurrency}),async h=>{for await(let{link:d,block:p,blockStart:v}of h){let u;switch(d.Hash.code){case vr:u=be(p);break;case ur:u=p;break;default:t.end(new P(`Unsupported codec: ${d.Hash.code}`));return}let l=new Et({concurrency:1});l.on("error",m=>{t.end(m)}),l.add(async()=>{s.onProgress?.(new R("unixfs:exporter:walk:file",{cid:d.Hash})),await Aa(r,u,t,v,o,i,s)}),await l.onIdle()}}),n>=i&&t.end()}var bl=(r,e,t,n,o,i,s)=>{async function*a(c={}){let h=t.fileSize();if(h===void 0)throw new Error("File was a directory");let{start:d,end:p}=et(h,c.offset,c.length);if(p===0n)return;let v=0n,u=p-d,l=Je();c.onProgress?.(new R("unixfs:exporter:walk:file",{cid:r})),Aa(s,e,l,0n,d,p,c).catch(m=>{l.end(m)});for await(let m of l)if(m!=null){if(v+=BigInt(m.byteLength),v>u)throw l.end(),new Nr("Read too many bytes - the file size reported by the UnixFS data in the root node may be incorrect");v===u&&l.end(),c.onProgress?.(new R("unixfs:exporter:progress:unixfs:file",{bytesRead:v,totalBytes:u,fileSize:h})),yield m}if(v<u)throw new Cr("Traversed entire DAG but did not read enough bytes")}return a},_o=bl;var El=(r,e,t,n,o,i,s)=>{function a(c={}){return c.onProgress?.(new R("unixfs:exporter:walk:hamt-sharded-directory",{cid:r})),Ia(e,n,o,i,s,c)}return a};async function*Ia(r,e,t,n,o,i){let s=r.Links;if(r.Data==null)throw new P("no data in PBNode");let a;try{a=ae.unmarshal(r.Data)}catch(d){throw new P(d.message)}if(a.fanout==null)throw new P("missing fanout");let c=(a.fanout-1n).toString(16).length,h=Xe(s,d=>ge(d,p=>async()=>{let v=p.Name!=null?p.Name.substring(c):null;if(v!=null&&v!==""){let u=`${e}/${v}`;return tt(i)?{entries:[{cid:p.Hash,name:v,path:u}]}:{entries:[(await t(p.Hash,v,u,[],n+1,o,i)).entry].filter(Boolean)}}else{let u=await D(o.get(p.Hash,i));return r=be(u),i.onProgress?.(new R("unixfs:exporter:walk:hamt-sharded-directory",{cid:p.Hash})),{entries:Ia(r,e,t,n,o,i)}}}),d=>Ne(d,{ordered:!0,concurrency:i.blockReadConcurrency}));for await(let{entries:d}of h)yield*d}var Ta=El;var vl=(r,e)=>r.Links.find(n=>n.Name===e)?.Hash,kl={raw:_o,file:_o,directory:_a,"hamt-sharded-directory":Ta,metadata:(r,e,t,n,o,i,s)=>()=>[],symlink:(r,e,t,n,o,i,s)=>()=>[]},_l=async(r,e,t,n,o,i,s,a)=>{if(tt(a)&&n.length===0)return{entry:{cid:r,name:e,path:t}};let c=await D(s.get(r,a)),h=be(c),d,p;if(e==null&&(e=r.toString()),h.Data==null)throw new P("no data in PBNode");try{d=ae.unmarshal(h.Data)}catch(u){throw new P(u.message)}if(t==null&&(t=e),n.length>0){let u;if(d?.type==="hamt-sharded-directory"?u=await ka(h,n[0],s):u=vl(h,n[0]),u==null)throw new ee("file does not exist");let l=n.shift(),m=`${t}/${l}`;p={cid:u,toResolve:n,name:l??"",path:m}}let v=kl[d.type](r,h,d,t,o,i,s);if(v==null)throw new ee("could not find content exporter");return d.isDirectory()?{entry:{type:"directory",name:e,path:t,cid:r,content:v,unixfs:d,depth:i,node:h,size:d.fileSize()},next:p}:{entry:{type:"file",name:e,path:t,cid:r,content:v,unixfs:d,depth:i,node:h,size:d.fileSize()},next:p}},Sa=_l;var Al={[vr]:Sa,[ur]:oa,[Oi]:ea,[$s]:ta,[zn.code]:ra,[as]:na},Ba=async(r,e,t,n,o,i,s)=>{let a=Al[r.code];if(a==null)throw new Br(`No resolver for code ${r.code}`);return a(r,e,t,n,Ba,o,i,s)},Na=Ba;var Il=(r="")=>(r.trim().match(/([^\\^/]|\\\/)+/g)??[]).filter(Boolean),Tl=r=>{if(r instanceof Uint8Array)return{cid:N.decode(r),toResolve:[]};let e=N.asCID(r);if(e!=null)return{cid:e,toResolve:[]};if(typeof r=="string"){r.indexOf("/ipfs/")===0&&(r=r.substring(6));let t=Il(r);return{cid:N.parse(t[0]),toResolve:t.slice(1)}}throw new Sr(`Unknown path type ${r}`)};async function*Ca(r,e,t={}){let{cid:n,toResolve:o}=Tl(r),i=n.toString(),s=i,a=o.length;for(;;){let c=await Na(n,i,s,o,a,e,t);if(c.entry==null&&c.next==null)throw new ee(`Could not resolve ${r}`);if(c.entry!=null&&(yield c.entry),c.next==null)return;o=c.next.toResolve,n=c.next.cid,i=c.next.name,s=c.next.path}}var Ao=class{root;path;constructor(...e){let t=e[0],n=e[1];if(typeof t=="string")n=t,t=void 0;else if(e.length<2)throw new Error("path or CID and path must be specified");n.startsWith("/")||(n=`/${n}`),this.root=t,this.path=n}async*traverse(e,t,n,o){for await(let i of Ca(`${this.root??e}${this.path}`,t,o))yield se({cid:i.cid,bytes:i.node instanceof Uint8Array?i.node:Ys(i.node),codec:await n(i.cid.code)})}};function Sl(r){return new Ar(r)}return Fa(Bl);})();
|
|
3
3
|
return HeliaCar}));
|
|
4
4
|
//# sourceMappingURL=index.min.js.map
|