@helia/ipns 8.1.0-c015793 → 8.1.0-eaf789a
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/package.json +2 -2
package/dist/index.min.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
`).map(o=>` ${o}`).join(`
|
|
5
5
|
`));let r=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${r} :
|
|
6
6
|
${e.join(`
|
|
7
|
-
`)}`:`${r} :`}};kc=$t;L.Constructed=kc;$t.NAME="CONSTRUCTED";var Xn=class extends be{fromBER(e,r,n){return r}toBER(e){return Ge}};Xn.override="EndOfContentValueBlock";var Cc,Qn=class extends de{constructor(e={}){super(e,Xn),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};Cc=Qn;L.EndOfContent=Cc;Qn.NAME=Jr;var Tc,Er=class extends de{constructor(e={}){super(e,be),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,r,n){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=n,r+n>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):r+n}toBER(e,r){let n=new ArrayBuffer(2);if(!e){let o=new Uint8Array(n);o[0]=5,o[1]=0}return r&&r.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}};Tc=Er;L.Null=Tc;Er.NAME="NULL";var eo=class extends xt(be){constructor({value:e,...r}={}){super(r),r.valueHex?this.valueHexView=G.BufferSourceConverter.toUint8Array(r.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}get value(){for(let e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}fromBER(e,r,n){let o=G.BufferSourceConverter.toUint8Array(e);return yt(this,o,r,n)?(this.valueHexView=o.subarray(r,r+n),n>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,Ss.call(this),this.blockLength=n,r+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};eo.NAME="BooleanValueBlock";var Ic,to=class extends de{constructor(e={}){super(e,eo),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};Ic=to;L.Boolean=Ic;to.NAME="BOOLEAN";var ro=class extends xt(et){constructor({isConstructed:e=!1,...r}={}){super(r),this.isConstructed=e}fromBER(e,r,n){let o=0;if(this.isConstructed){if(this.isHexOnly=!1,o=et.prototype.fromBER.call(this,e,r,n),o===-1)return o;for(let i=0;i<this.value.length;i++){let s=this.value[i].constructor.NAME;if(s===Jr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(s!==Ec)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,o=super.fromBER(e,r,n),this.blockLength=n;return o}toBER(e,r){return this.isConstructed?et.prototype.toBER.call(this,e,r):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};ro.NAME="OctetStringValueBlock";var Nc,no=class t extends de{constructor({idBlock:e={},lenBlock:r={},...n}={}){var o,i;(o=n.isConstructed)!==null&&o!==void 0||(n.isConstructed=!!(!((i=n.value)===null||i===void 0)&&i.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...r,isIndefiniteForm:!!n.isIndefiniteForm},...n},ro),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,r,n){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,n===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),r;if(!this.valueBlock.isConstructed){let i=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(r,r+n);try{if(i.byteLength){let s=Ro(i,0,i.byteLength);s.offset!==-1&&s.offset===n&&(this.valueBlock.value=[s.result])}}catch{}}return super.fromBER(e,r,n)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?$t.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${G.Convert.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;let e=[];for(let r of this.valueBlock.value)r instanceof t&&e.push(r.valueBlock.valueHexView);return G.BufferSourceConverter.concat(e)}};Nc=no;L.OctetString=Nc;no.NAME=Ec;var oo=class extends xt(et){constructor({unusedBits:e=0,isConstructed:r=!1,...n}={}){super(n),this.unusedBits=e,this.isConstructed=r,this.blockLength=this.valueHexView.byteLength}fromBER(e,r,n){if(!n)return r;let o=-1;if(this.isConstructed){if(o=et.prototype.fromBER.call(this,e,r,n),o===-1)return o;for(let a of this.value){let c=a.constructor.NAME;if(c===Jr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==Bc)return this.error="BIT STRING may consists of BIT STRINGs only",-1;let l=a.valueBlock;if(this.unusedBits>0&&l.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=l.unusedBits}return o}let i=G.BufferSourceConverter.toUint8Array(e);if(!yt(this,i,r,n))return-1;let s=i.subarray(r,r+n);if(this.unusedBits=s[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){let a=s.subarray(1);try{if(a.byteLength){let c=Ro(a,0,a.byteLength);c.offset!==-1&&c.offset===n-1&&(this.value=[c.result])}}catch{}}return this.valueHexView=s.subarray(1),this.blockLength=s.length,r+n}toBER(e,r){if(this.isConstructed)return et.prototype.toBER.call(this,e,r);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return Ge;let n=new Uint8Array(this.valueHexView.length+1);return n[0]=this.unusedBits,n.set(this.valueHexView,1),n.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}};oo.NAME="BitStringValueBlock";var Uc,Br=class extends de{constructor({idBlock:e={},lenBlock:r={},...n}={}){var o,i;(o=n.isConstructed)!==null&&o!==void 0||(n.isConstructed=!!(!((i=n.value)===null||i===void 0)&&i.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...r,isIndefiniteForm:!!n.isIndefiniteForm},...n},oo),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,r,n){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,r,n)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return $t.prototype.onAsciiEncoding.call(this);{let e=[],r=this.valueBlock.valueHexView;for(let o of r)e.push(o.toString(2).padStart(8,"0"));let n=e.join("");return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}};Uc=Br;L.BitString=Uc;Br.NAME=Bc;var Rc;function f0(t,e){let r=new Uint8Array([0]),n=new Uint8Array(t),o=new Uint8Array(e),i=n.slice(0),s=i.length-1,a=o.slice(0),c=a.length-1,l=0,u=c<s?s:c,f=0;for(let h=u;h>=0;h--,f++){switch(!0){case f<a.length:l=i[s-f]+a[c-f]+r[0];break;default:l=i[s-f]+r[0]}switch(r[0]=l/10,!0){case f>=i.length:i=zn(new Uint8Array([l%10]),i);break;default:i[s-f]=l%10}}return r[0]>0&&(i=zn(r,i)),i}function vc(t){if(t>=jr.length)for(let e=jr.length;e<=t;e++){let r=new Uint8Array([0]),n=jr[e-1].slice(0);for(let o=n.length-1;o>=0;o--){let i=new Uint8Array([(n[o]<<1)+r[0]]);r[0]=i[0]/10,n[o]=i[0]%10}r[0]>0&&(n=zn(r,n)),jr.push(n)}return jr[t]}function h0(t,e){let r=0,n=new Uint8Array(t),o=new Uint8Array(e),i=n.slice(0),s=i.length-1,a=o.slice(0),c=a.length-1,l,u=0;for(let f=c;f>=0;f--,u++)switch(l=i[s-u]-a[c-u]-r,!0){case l<0:r=1,i[s-u]=l+10;break;default:r=0,i[s-u]=l}if(r>0)for(let f=s-c+1;f>=0;f--,u++)if(l=i[s-u]-r,l<0)r=1,i[s-u]=l+10;else{r=0,i[s-u]=l;break}return i.slice()}var Xr=class extends xt(be){constructor({value:e,...r}={}){super(r),this._valueDec=0,r.valueHex&&this.setValueHex(),e!==void 0&&(this.valueDec=e)}setValueHex(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=Ss.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(xc(e))}get valueDec(){return this._valueDec}fromDER(e,r,n,o=0){let i=this.fromBER(e,r,n);if(i===-1)return i;let s=this.valueHexView;return s[0]===0&&s[1]&128?this.valueHexView=s.subarray(1):o!==0&&s.length<o&&(o-s.length>1&&(o=s.length+1),this.valueHexView=s.subarray(o-s.length)),i}toDER(e=!1){let r=this.valueHexView;switch(!0){case(r[0]&128)!==0:{let n=new Uint8Array(this.valueHexView.length+1);n[0]=0,n.set(r,1),this.valueHexView=n}break;case(r[0]===0&&(r[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,r,n){let o=super.fromBER(e,r,n);return o===-1||this.setValueHex(),o}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){let e=this.valueHexView.length*8-1,r=new Uint8Array(this.valueHexView.length*8/3),n=0,o,i=this.valueHexView,s="",a=!1;for(let c=i.byteLength-1;c>=0;c--){o=i[c];for(let l=0;l<8;l++){if((o&1)===1)switch(n){case e:r=h0(vc(n),r),s="-";break;default:r=f0(r,vc(n))}n++,o>>=1}}for(let c=0;c<r.length;c++)r[c]&&(a=!0),a&&(s+=bc.charAt(r[c]));return a===!1&&(s+=bc.charAt(0)),s}};Rc=Xr;Xr.NAME="IntegerValueBlock";Object.defineProperty(Rc.prototype,"valueHex",{set:function(t){this.valueHexView=new Uint8Array(t),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var _c,pe=class t extends de{constructor(e={}){super(e,Xr),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return Gn(),BigInt(this.valueBlock.toString())}static fromBigInt(e){Gn();let r=BigInt(e),n=new Yr,o=r.toString(16).replace(/^-/,""),i=new Uint8Array(G.Convert.FromHex(o));if(r<0){let a=new Uint8Array(i.length+(i[0]&128?1:0));a[0]|=128;let l=BigInt(`0x${G.Convert.ToHex(a)}`)+r,u=G.BufferSourceConverter.toUint8Array(G.Convert.FromHex(l.toString(16)));u[0]|=128,n.write(u)}else i[0]&128&&n.write(new Uint8Array([0])),n.write(i);return new t({valueHex:n.final()})}convertToDER(){let e=new t({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new t({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}};_c=pe;L.Integer=_c;pe.NAME="INTEGER";var Lc,io=class extends pe{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};Lc=io;L.Enumerated=Lc;io.NAME="ENUMERATED";var Qr=class extends xt(be){constructor({valueDec:e=-1,isFirstSid:r=!1,...n}={}){super(n),this.valueDec=e,this.isFirstSid=r}fromBER(e,r,n){if(!n)return r;let o=G.BufferSourceConverter.toUint8Array(e);if(!yt(this,o,r,n))return-1;let i=o.subarray(r,r+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=i[a]&127,this.blockLength++,!!(i[a]&128));a++);let s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength;a++)s[a]=this.valueHexView[a];return this.valueHexView=s,i[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=tr(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),r+this.blockLength)}set valueBigInt(e){Gn();let r=BigInt(e).toString(2);for(;r.length%7;)r="0"+r;let n=new Uint8Array(r.length/7);for(let o=0;o<n.length;o++)n[o]=parseInt(r.slice(o*7,o*7+7),2)+(o+1<n.length?128:0);this.fromBER(n.buffer,0,n.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);let o=this.valueHexView,i=new Uint8Array(this.blockLength);for(let s=0;s<this.blockLength-1;s++)i[s]=o[s]|128;return i[this.blockLength-1]=o[this.blockLength-1],i.buffer}let r=Kt(this.valueDec,7);if(r.byteLength===0)return this.error="Error during encoding SID value",Ge;let n=new Uint8Array(r.byteLength);if(!e){let o=new Uint8Array(r),i=r.byteLength-1;for(let s=0;s<i;s++)n[s]=o[s]|128;n[i]=o[i]}return n}toString(){let e="";if(this.isHexOnly)e=G.Convert.ToHex(this.valueHexView);else if(this.isFirstSid){let r=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",r-=40):(e="2.",r-=80),e+=r.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}};Qr.NAME="sidBlock";var so=class extends be{constructor({value:e=Sr,...r}={}){super(r),this.value=[],e&&this.fromString(e)}fromBER(e,r,n){let o=r;for(;n>0;){let i=new Qr;if(o=i.fromBER(e,o,n),o===-1)return this.blockLength=0,this.error=i.error,o;this.value.length===0&&(i.isFirstSid=!0),this.blockLength+=i.blockLength,n-=i.blockLength,this.value.push(i)}return o}toBER(e){let r=[];for(let n=0;n<this.value.length;n++){let o=this.value[n].toBER(e);if(o.byteLength===0)return this.error=this.value[n].error,Ge;r.push(o)}return ks(r)}fromString(e){this.value=[];let r=0,n=0,o="",i=!1;do if(n=e.indexOf(".",r),n===-1?o=e.substring(r):o=e.substring(r,n),r=n+1,i){let s=this.value[0],a=0;switch(s.valueDec){case 0:break;case 1:a=40;break;case 2:a=80;break;default:this.value=[];return}let c=parseInt(o,10);if(isNaN(c))return;s.valueDec=c+a,i=!1}else{let s=new Qr;if(o>Number.MAX_SAFE_INTEGER){Gn();let a=BigInt(o);s.valueBigInt=a}else if(s.valueDec=parseInt(o,10),isNaN(s.valueDec))return;this.value.length||(s.isFirstSid=!0,i=!0),this.value.push(s)}while(n!==-1)}toString(){let e="",r=!1;for(let n=0;n<this.value.length;n++){r=this.value[n].isHexOnly;let o=this.value[n].toString();n!==0&&(e=`${e}.`),r?(o=`{${o}}`,this.value[n].isFirstSid?e=`2.{${o} - 80}`:e+=o):e+=o}return e}toJSON(){let e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let r=0;r<this.value.length;r++)e.sidArray.push(this.value[r].toJSON());return e}};so.NAME="ObjectIdentifierValueBlock";var Vc,Ar=class extends de{constructor(e={}){super(e,so),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};Vc=Ar;L.ObjectIdentifier=Vc;Ar.NAME="OBJECT IDENTIFIER";var en=class extends xt(pt){constructor({valueDec:e=0,...r}={}){super(r),this.valueDec=e}fromBER(e,r,n){if(n===0)return r;let o=G.BufferSourceConverter.toUint8Array(e);if(!yt(this,o,r,n))return-1;let i=o.subarray(r,r+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=i[a]&127,this.blockLength++,!!(i[a]&128));a++);let s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength;a++)s[a]=this.valueHexView[a];return this.valueHexView=s,i[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=tr(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),r+this.blockLength)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);let o=this.valueHexView,i=new Uint8Array(this.blockLength);for(let s=0;s<this.blockLength-1;s++)i[s]=o[s]|128;return i[this.blockLength-1]=o[this.blockLength-1],i.buffer}let r=Kt(this.valueDec,7);if(r.byteLength===0)return this.error="Error during encoding SID value",Ge;let n=new Uint8Array(r.byteLength);if(!e){let o=new Uint8Array(r),i=r.byteLength-1;for(let s=0;s<i;s++)n[s]=o[s]|128;n[i]=o[i]}return n.buffer}toString(){let e="";return this.isHexOnly?e=G.Convert.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}};en.NAME="relativeSidBlock";var ao=class extends be{constructor({value:e=Sr,...r}={}){super(r),this.value=[],e&&this.fromString(e)}fromBER(e,r,n){let o=r;for(;n>0;){let i=new en;if(o=i.fromBER(e,o,n),o===-1)return this.blockLength=0,this.error=i.error,o;this.blockLength+=i.blockLength,n-=i.blockLength,this.value.push(i)}return o}toBER(e,r){let n=[];for(let o=0;o<this.value.length;o++){let i=this.value[o].toBER(e);if(i.byteLength===0)return this.error=this.value[o].error,Ge;n.push(i)}return ks(n)}fromString(e){this.value=[];let r=0,n=0,o="";do{n=e.indexOf(".",r),n===-1?o=e.substring(r):o=e.substring(r,n),r=n+1;let i=new en;if(i.valueDec=parseInt(o,10),isNaN(i.valueDec))return!0;this.value.push(i)}while(n!==-1);return!0}toString(){let e="",r=!1;for(let n=0;n<this.value.length;n++){r=this.value[n].isHexOnly;let o=this.value[n].toString();n!==0&&(e=`${e}.`),r&&(o=`{${o}}`),e+=o}return e}toJSON(){let e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let r=0;r<this.value.length;r++)e.sidArray.push(this.value[r].toJSON());return e}};ao.NAME="RelativeObjectIdentifierValueBlock";var Dc,co=class extends de{constructor(e={}){super(e,ao),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};Dc=co;L.RelativeObjectIdentifier=Dc;co.NAME="RelativeObjectIdentifier";var Fc,gt=class extends $t{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};Fc=gt;L.Sequence=Fc;gt.NAME="SEQUENCE";var Mc,uo=class extends $t{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};Mc=uo;L.Set=Mc;uo.NAME="SET";var lo=class extends xt(be){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=Sr}toJSON(){return{...super.toJSON(),value:this.value}}};lo.NAME="StringValueBlock";var fo=class extends lo{};fo.NAME="SimpleStringValueBlock";var Ae=class extends jn{constructor({...e}={}){super(e,fo)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,G.BufferSourceConverter.toUint8Array(e))}fromString(e){let r=e.length,n=this.valueBlock.valueHexView=new Uint8Array(r);for(let o=0;o<r;o++)n[o]=e.charCodeAt(o);this.valueBlock.value=e}};Ae.NAME="SIMPLE STRING";var ho=class extends Ae{fromBuffer(e){this.valueBlock.valueHexView=G.BufferSourceConverter.toUint8Array(e);try{this.valueBlock.value=G.Convert.ToUtf8String(e)}catch(r){this.warnings.push(`Error during "decodeURIComponent": ${r}, using raw string`),this.valueBlock.value=G.Convert.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(G.Convert.FromUtf8String(e)),this.valueBlock.value=e}};ho.NAME="Utf8StringValueBlock";var Oc,mt=class extends ho{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};Oc=mt;L.Utf8String=Oc;mt.NAME="UTF8String";var po=class extends Ae{fromBuffer(e){this.valueBlock.value=G.Convert.ToUtf16String(e),this.valueBlock.valueHexView=G.BufferSourceConverter.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(G.Convert.FromUtf16String(e))}};po.NAME="BmpStringValueBlock";var Hc,go=class extends po{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};Hc=go;L.BmpString=Hc;go.NAME="BMPString";var mo=class extends Ae{fromBuffer(e){let r=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),n=new Uint8Array(r);for(let o=0;o<n.length;o+=4)n[o]=n[o+3],n[o+1]=n[o+2],n[o+2]=0,n[o+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(r))}fromString(e){let r=e.length,n=this.valueBlock.valueHexView=new Uint8Array(r*4);for(let o=0;o<r;o++){let i=Kt(e.charCodeAt(o),8),s=new Uint8Array(i);if(s.length>4)continue;let a=4-s.length;for(let c=s.length-1;c>=0;c--)n[o*4+c+a]=s[c]}this.valueBlock.value=e}};mo.NAME="UniversalStringValueBlock";var Pc,yo=class extends mo{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};Pc=yo;L.UniversalString=Pc;yo.NAME="UniversalString";var Kc,xo=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};Kc=xo;L.NumericString=Kc;xo.NAME="NumericString";var $c,wo=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};$c=wo;L.PrintableString=$c;wo.NAME="PrintableString";var qc,bo=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};qc=bo;L.TeletexString=qc;bo.NAME="TeletexString";var zc,vo=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};zc=vo;L.VideotexString=zc;vo.NAME="VideotexString";var Gc,Eo=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};Gc=Eo;L.IA5String=Gc;Eo.NAME="IA5String";var Zc,Bo=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};Zc=Bo;L.GraphicString=Zc;Bo.NAME="GraphicString";var Wc,tn=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};Wc=tn;L.VisibleString=Wc;tn.NAME="VisibleString";var jc,Ao=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};jc=Ao;L.GeneralString=jc;Ao.NAME="GeneralString";var Yc,So=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};Yc=So;L.CharacterString=Yc;So.NAME="CharacterString";var Jc,rn=class extends tn{constructor({value:e,valueDate:r,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let o=0;o<e.length;o++)this.valueBlock.valueHexView[o]=e.charCodeAt(o)}r&&(this.fromDate(r),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,G.BufferSourceConverter.toUint8Array(e)))}toBuffer(){let e=this.toString(),r=new ArrayBuffer(e.length),n=new Uint8Array(r);for(let o=0;o<e.length;o++)n[o]=e.charCodeAt(o);return r}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){let n=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(e);if(n===null){this.error="Wrong input string for conversion";return}let o=parseInt(n[1],10);o>=50?this.year=1900+o:this.year=2e3+o,this.month=parseInt(n[2],10),this.day=parseInt(n[3],10),this.hour=parseInt(n[4],10),this.minute=parseInt(n[5],10),this.second=parseInt(n[6],10)}toString(e="iso"){if(e==="iso"){let r=new Array(7);return r[0]=Ue(this.year<2e3?this.year-1900:this.year-2e3,2),r[1]=Ue(this.month,2),r[2]=Ue(this.day,2),r[3]=Ue(this.hour,2),r[4]=Ue(this.minute,2),r[5]=Ue(this.second,2),r[6]="Z",r.join("")}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}};Jc=rn;L.UTCTime=Jc;rn.NAME="UTCTime";var Xc,ko=class extends rn{constructor(e={}){var r;super(e),(r=this.millisecond)!==null&&r!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(e){let r=!1,n="",o="",i=0,s,a=0,c=0;if(e[e.length-1]==="Z")n=e.substring(0,e.length-1),r=!0;else{let f=new Number(e[e.length-1]);if(isNaN(f.valueOf()))throw new Error("Wrong input string for conversion");n=e}if(r){if(n.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(n.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let f=1,h=n.indexOf("+"),v="";if(h===-1&&(h=n.indexOf("-"),f=-1),h!==-1){if(v=n.substring(h+1),n=n.substring(0,h),v.length!==2&&v.length!==4)throw new Error("Wrong input string for conversion");let E=parseInt(v.substring(0,2),10);if(isNaN(E.valueOf()))throw new Error("Wrong input string for conversion");if(a=f*E,v.length===4){if(E=parseInt(v.substring(2,4),10),isNaN(E.valueOf()))throw new Error("Wrong input string for conversion");c=f*E}}}let l=n.indexOf(".");if(l===-1&&(l=n.indexOf(",")),l!==-1){let f=new Number(`0${n.substring(l)}`);if(isNaN(f.valueOf()))throw new Error("Wrong input string for conversion");i=f.valueOf(),o=n.substring(0,l)}else o=n;switch(!0){case o.length===8:if(s=/(\d{4})(\d{2})(\d{2})/ig,l!==-1)throw new Error("Wrong input string for conversion");break;case o.length===10:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,l!==-1){let f=60*i;this.minute=Math.floor(f),f=60*(f-this.minute),this.second=Math.floor(f),f=1e3*(f-this.second),this.millisecond=Math.floor(f)}break;case o.length===12:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,l!==-1){let f=60*i;this.second=Math.floor(f),f=1e3*(f-this.second),this.millisecond=Math.floor(f)}break;case o.length===14:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,l!==-1){let f=1e3*i;this.millisecond=Math.floor(f)}break;default:throw new Error("Wrong input string for conversion")}let u=s.exec(o);if(u===null)throw new Error("Wrong input string for conversion");for(let f=1;f<u.length;f++)switch(f){case 1:this.year=parseInt(u[f],10);break;case 2:this.month=parseInt(u[f],10);break;case 3:this.day=parseInt(u[f],10);break;case 4:this.hour=parseInt(u[f],10)+a;break;case 5:this.minute=parseInt(u[f],10)+c;break;case 6:this.second=parseInt(u[f],10);break;default:throw new Error("Wrong input string for conversion")}if(r===!1){let f=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=f.getUTCFullYear(),this.month=f.getUTCMonth(),this.day=f.getUTCDay(),this.hour=f.getUTCHours(),this.minute=f.getUTCMinutes(),this.second=f.getUTCSeconds(),this.millisecond=f.getUTCMilliseconds()}}toString(e="iso"){if(e==="iso"){let r=[];return r.push(Ue(this.year,4)),r.push(Ue(this.month,2)),r.push(Ue(this.day,2)),r.push(Ue(this.hour,2)),r.push(Ue(this.minute,2)),r.push(Ue(this.second,2)),this.millisecond!==0&&(r.push("."),r.push(Ue(this.millisecond,3))),r.push("Z"),r.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};Xc=ko;L.GeneralizedTime=Xc;ko.NAME="GeneralizedTime";var Qc,Co=class extends mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};Qc=Co;L.DATE=Qc;Co.NAME="DATE";var eu,To=class extends mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};eu=To;L.TimeOfDay=eu;To.NAME="TimeOfDay";var tu,Io=class extends mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};tu=Io;L.DateTime=tu;Io.NAME="DateTime";var ru,No=class extends mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};ru=No;L.Duration=ru;No.NAME="Duration";var nu,Uo=class extends mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};nu=Uo;L.TIME=nu;Uo.NAME="TIME";function Se(t,e="utf8"){let r=Hn[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return r.encoder.encode(t).substring(1)}var nn=class extends Error{constructor(e="An error occurred while verifying a message"){super(e),this.name="VerificationError"}},_o=class extends Error{constructor(e="Missing Web Crypto API"){super(e),this.name="WebCryptoMissingError"}};var ou={get(t=globalThis){let e=t.crypto;if(e?.subtle==null)throw new _o("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api");return e}};var qt=ou;async function iu(t){let e=await qt.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:t,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),r=await p0(e);return{privateKey:r[0],publicKey:r[1]}}async function su(t,e){let r=await qt.get().subtle.importKey("jwk",t,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await qt.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},r,e instanceof Uint8Array?e:e.subarray());return new Uint8Array(n,0,n.byteLength)}async function au(t,e,r){let n=await qt.get().subtle.importKey("jwk",t,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return qt.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,e,r instanceof Uint8Array?r:r.subarray())}async function p0(t){if(t.privateKey==null||t.publicKey==null)throw new xe("Private and public key are required");return Promise.all([qt.get().subtle.exportKey("jwk",t.privateKey),qt.get().subtle.exportKey("jwk",t.publicKey)])}function Is(t){if(t.kty!=="RSA")throw new xe("invalid key type");if(t.n==null)throw new xe("invalid key modulus");return Y(t.n,"base64url").length*8}var kr=class{type="RSA";_key;_raw;_multihash;constructor(e,r){this._key=e,this._multihash=r}get raw(){return this._raw==null&&(this._raw=on.jwkToPkix(this._key)),this._raw}toMultihash(){return this._multihash}toCID(){return ee.createV1(114,this._multihash)}toString(){return Q.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:he(this.raw,e.raw)}verify(e,r){return au(this._key,r,e)}},sn=class{type="RSA";_key;_raw;publicKey;constructor(e,r){this._key=e,this.publicKey=r}get raw(){return this._raw==null&&(this._raw=on.jwkToPkcs1(this._key)),this._raw}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:he(this.raw,e.raw)}sign(e){return su(this._key,e)}};var Lo=8192,Ns=18;function cu(t){let{result:e}=Ts(t),r=e.valueBlock.value;return{n:tt(r[1]),e:tt(r[2]),d:tt(r[3]),p:tt(r[4]),q:tt(r[5]),dp:tt(r[6]),dq:tt(r[7]),qi:tt(r[8]),kty:"RSA",alg:"RS256"}}function g0(t){if(t.n==null||t.e==null||t.d==null||t.p==null||t.q==null||t.dp==null||t.dq==null||t.qi==null)throw new xe("JWK was missing components");let r=new gt({value:[new pe({value:0}),pe.fromBigInt(rt(Y(t.n,"base64url"))),pe.fromBigInt(rt(Y(t.e,"base64url"))),pe.fromBigInt(rt(Y(t.d,"base64url"))),pe.fromBigInt(rt(Y(t.p,"base64url"))),pe.fromBigInt(rt(Y(t.q,"base64url"))),pe.fromBigInt(rt(Y(t.dp,"base64url"))),pe.fromBigInt(rt(Y(t.dq,"base64url"))),pe.fromBigInt(rt(Y(t.qi,"base64url")))]}).toBER();return new Uint8Array(r,0,r.byteLength)}function uu(t){let{result:e}=Ts(t),r=e.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:tt(r[0]),e:tt(r[1])}}function Us(t){if(t.n==null||t.e==null)throw new xe("JWK was missing components");let r=new gt({value:[new gt({value:[new Ar({value:"1.2.840.113549.1.1.1"}),new Er]}),new Br({valueHex:new gt({value:[pe.fromBigInt(rt(Y(t.n,"base64url"))),pe.fromBigInt(rt(Y(t.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(r,0,r.byteLength)}function tt(t){let e=t.valueBlock.valueHexView;for(;e[0]===0;)e=e.subarray(1);return Se(e,"base64url")}function rt(t){let e=[];return t.forEach(function(r){let n=r.toString(16);n.length%2>0&&(n=`0${n}`),e.push(n)}),BigInt("0x"+e.join(""))}function lu(t){let e=cu(t);return fu(e)}function Rs(t){let e=uu(t);if(Is(e)>Lo)throw new sr("Key size is too large");let r=br(Qe.encode({Type:se.RSA,Data:t})),n=Pe(Ns,r);return new kr(e,n)}function fu(t){if(Is(t)>Lo)throw new xe("Key size is too large");let e=du(t),r=br(Qe.encode({Type:se.RSA,Data:Us(e.publicKey)})),n=Pe(Ns,r);return new sn(e.privateKey,new kr(e.publicKey,n))}async function hu(t){if(t>Lo)throw new xe("Key size is too large");let e=await iu(t),r=br(Qe.encode({Type:se.RSA,Data:Us(e.publicKey)})),n=Pe(Ns,r);return new sn(e.privateKey,new kr(e.publicKey,n))}function du(t){if(t==null)throw new xe("Missing key parameter");return{privateKey:t,publicKey:{kty:t.kty,n:t.n,e:t.e}}}var Vo=class extends gr{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,Ta(e);let n=Hr(r);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,i=new Uint8Array(o);i.set(n.length>o?e.create().update(n).digest():n);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=e.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),i.fill(0)}update(e){return pr(this),this.iHash.update(e),this}digestInto(e){pr(this),dr(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:a}=this;return e=e,e.finished=o,e.destroyed=i,e.blockLen=s,e.outputLen=a,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},_s=(t,e,r)=>new Vo(t,e).update(r).digest();_s.create=(t,e)=>new Vo(t,e);function pu(t){t.lowS!==void 0&&$e("lowS",t.lowS),t.prehash!==void 0&&$e("prehash",t.prehash)}function m0(t){let e=$r(t);Je(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:r,Fp:n,a:o}=e;if(r){if(!n.eql(o,n.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:y0,hexToBytes:x0}=Un,Ls=class extends Error{constructor(e=""){super(e)}},wt={Err:Ls,_tlv:{encode:(t,e)=>{let{Err:r}=wt;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length&1)throw new r("tlv.encode: unpadded data");let n=e.length/2,o=Wt(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?Wt(o.length/2|128):"";return Wt(t)+i+o+e},decode(t,e){let{Err:r}=wt,n=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length<2||e[n++]!==t)throw new r("tlv.decode: wrong tlv");let o=e[n++],i=!!(o&128),s=0;if(!i)s=o;else{let c=o&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let l=e.subarray(n,n+c);if(l.length!==c)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let u of l)s=s<<8|u;if(n+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=e.subarray(n,n+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+s)}}},_int:{encode(t){let{Err:e}=wt;if(t<bt)throw new e("integer: negative integers are not allowed");let r=Wt(t);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return r},decode(t){let{Err:e}=wt;if(t[0]&128)throw new e("invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return y0(t)}},toSig(t){let{Err:e,_int:r,_tlv:n}=wt,o=typeof t=="string"?x0(t):t;yr(o);let{v:i,l:s}=n.decode(48,o);if(s.length)throw new e("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,i),{v:l,l:u}=n.decode(2,c);if(u.length)throw new e("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(l)}},hexFromSig(t){let{_tlv:e,_int:r}=wt,n=e.encode(2,r.encode(t.r)),o=e.encode(2,r.encode(t.s)),i=n+o;return e.encode(48,i)}},bt=BigInt(0),ue=BigInt(1),Qy=BigInt(2),gu=BigInt(3),ex=BigInt(4);function w0(t){let e=m0(t),{Fp:r}=e,n=Lt(e.n,e.nBitLength),o=e.toBytes||((y,d,A)=>{let T=d.toAffine();return ht(Uint8Array.from([4]),r.toBytes(T.x),r.toBytes(T.y))}),i=e.fromBytes||(y=>{let d=y.subarray(1),A=r.fromBytes(d.subarray(0,r.BYTES)),T=r.fromBytes(d.subarray(r.BYTES,2*r.BYTES));return{x:A,y:T}});function s(y){let{a:d,b:A}=e,T=r.sqr(y),x=r.mul(T,y);return r.add(r.add(x,r.mul(y,d)),A)}if(!r.eql(r.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function a(y){return Pr(y,ue,e.n)}function c(y){let{allowedPrivateKeyLengths:d,nByteLength:A,wrapPrivateKey:T,n:x}=e;if(d&&typeof y!="bigint"){if(Ut(y)&&(y=lt(y)),typeof y!="string"||!d.includes(y.length))throw new Error("invalid private key");y=y.padStart(A*2,"0")}let U;try{U=typeof y=="bigint"?y:ft(ne("private key",y,A))}catch{throw new Error("invalid private key, expected hex or "+A+" bytes, got "+typeof y)}return T&&(U=J(U,x)),Ie("private key",U,ue,x),U}function l(y){if(!(y instanceof h))throw new Error("ProjectivePoint expected")}let u=Jt((y,d)=>{let{px:A,py:T,pz:x}=y;if(r.eql(x,r.ONE))return{x:A,y:T};let U=y.is0();d==null&&(d=U?r.ONE:r.inv(x));let F=r.mul(A,d),D=r.mul(T,d),R=r.mul(x,d);if(U)return{x:r.ZERO,y:r.ZERO};if(!r.eql(R,r.ONE))throw new Error("invZ was invalid");return{x:F,y:D}}),f=Jt(y=>{if(y.is0()){if(e.allowInfinityPoint&&!r.is0(y.py))return;throw new Error("bad point: ZERO")}let{x:d,y:A}=y.toAffine();if(!r.isValid(d)||!r.isValid(A))throw new Error("bad point: x or y not FE");let T=r.sqr(A),x=s(d);if(!r.eql(T,x))throw new Error("bad point: equation left != right");if(!y.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class h{constructor(d,A,T){if(this.px=d,this.py=A,this.pz=T,d==null||!r.isValid(d))throw new Error("x required");if(A==null||!r.isValid(A))throw new Error("y required");if(T==null||!r.isValid(T))throw new Error("z required");Object.freeze(this)}static fromAffine(d){let{x:A,y:T}=d||{};if(!d||!r.isValid(A)||!r.isValid(T))throw new Error("invalid affine point");if(d instanceof h)throw new Error("projective point not allowed");let x=U=>r.eql(U,r.ZERO);return x(A)&&x(T)?h.ZERO:new h(A,T,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){let A=r.invertBatch(d.map(T=>T.pz));return d.map((T,x)=>T.toAffine(A[x])).map(h.fromAffine)}static fromHex(d){let A=h.fromAffine(i(ne("pointHex",d)));return A.assertValidity(),A}static fromPrivateKey(d){return h.BASE.multiply(c(d))}static msm(d,A){return Vn(h,n,d,A)}_setWindowSize(d){E.setWindowSize(this,d)}assertValidity(){f(this)}hasEvenY(){let{y:d}=this.toAffine();if(r.isOdd)return!r.isOdd(d);throw new Error("Field doesn't support isOdd")}equals(d){l(d);let{px:A,py:T,pz:x}=this,{px:U,py:F,pz:D}=d,R=r.eql(r.mul(A,D),r.mul(U,x)),w=r.eql(r.mul(T,D),r.mul(F,x));return R&&w}negate(){return new h(this.px,r.neg(this.py),this.pz)}double(){let{a:d,b:A}=e,T=r.mul(A,gu),{px:x,py:U,pz:F}=this,D=r.ZERO,R=r.ZERO,w=r.ZERO,b=r.mul(x,x),M=r.mul(U,U),_=r.mul(F,F),I=r.mul(x,U);return I=r.add(I,I),w=r.mul(x,F),w=r.add(w,w),D=r.mul(d,w),R=r.mul(T,_),R=r.add(D,R),D=r.sub(M,R),R=r.add(M,R),R=r.mul(D,R),D=r.mul(I,D),w=r.mul(T,w),_=r.mul(d,_),I=r.sub(b,_),I=r.mul(d,I),I=r.add(I,w),w=r.add(b,b),b=r.add(w,b),b=r.add(b,_),b=r.mul(b,I),R=r.add(R,b),_=r.mul(U,F),_=r.add(_,_),b=r.mul(_,I),D=r.sub(D,b),w=r.mul(_,M),w=r.add(w,w),w=r.add(w,w),new h(D,R,w)}add(d){l(d);let{px:A,py:T,pz:x}=this,{px:U,py:F,pz:D}=d,R=r.ZERO,w=r.ZERO,b=r.ZERO,M=e.a,_=r.mul(e.b,gu),I=r.mul(A,U),K=r.mul(T,F),S=r.mul(x,D),k=r.add(A,T),m=r.add(U,F);k=r.mul(k,m),m=r.add(I,K),k=r.sub(k,m),m=r.add(A,x);let p=r.add(U,D);return m=r.mul(m,p),p=r.add(I,S),m=r.sub(m,p),p=r.add(T,x),R=r.add(F,D),p=r.mul(p,R),R=r.add(K,S),p=r.sub(p,R),b=r.mul(M,m),R=r.mul(_,S),b=r.add(R,b),R=r.sub(K,b),b=r.add(K,b),w=r.mul(R,b),K=r.add(I,I),K=r.add(K,I),S=r.mul(M,S),m=r.mul(_,m),K=r.add(K,S),S=r.sub(I,S),S=r.mul(M,S),m=r.add(m,S),I=r.mul(K,m),w=r.add(w,I),I=r.mul(p,m),R=r.mul(k,R),R=r.sub(R,I),I=r.mul(k,K),b=r.mul(p,b),b=r.add(b,I),new h(R,w,b)}subtract(d){return this.add(d.negate())}is0(){return this.equals(h.ZERO)}wNAF(d){return E.wNAFCached(this,d,h.normalizeZ)}multiplyUnsafe(d){let{endo:A,n:T}=e;Ie("scalar",d,bt,T);let x=h.ZERO;if(d===bt)return x;if(this.is0()||d===ue)return this;if(!A||E.hasPrecomputes(this))return E.wNAFCachedUnsafe(this,d,h.normalizeZ);let{k1neg:U,k1:F,k2neg:D,k2:R}=A.splitScalar(d),w=x,b=x,M=this;for(;F>bt||R>bt;)F&ue&&(w=w.add(M)),R&ue&&(b=b.add(M)),M=M.double(),F>>=ue,R>>=ue;return U&&(w=w.negate()),D&&(b=b.negate()),b=new h(r.mul(b.px,A.beta),b.py,b.pz),w.add(b)}multiply(d){let{endo:A,n:T}=e;Ie("scalar",d,ue,T);let x,U;if(A){let{k1neg:F,k1:D,k2neg:R,k2:w}=A.splitScalar(d),{p:b,f:M}=this.wNAF(D),{p:_,f:I}=this.wNAF(w);b=E.constTimeNegate(F,b),_=E.constTimeNegate(R,_),_=new h(r.mul(_.px,A.beta),_.py,_.pz),x=b.add(_),U=M.add(I)}else{let{p:F,f:D}=this.wNAF(d);x=F,U=D}return h.normalizeZ([x,U])[0]}multiplyAndAddUnsafe(d,A,T){let x=h.BASE,U=(D,R)=>R===bt||R===ue||!D.equals(x)?D.multiplyUnsafe(R):D.multiply(R),F=U(this,A).add(U(d,T));return F.is0()?void 0:F}toAffine(d){return u(this,d)}isTorsionFree(){let{h:d,isTorsionFree:A}=e;if(d===ue)return!0;if(A)return A(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:d,clearCofactor:A}=e;return d===ue?this:A?A(h,this):this.multiplyUnsafe(e.h)}toRawBytes(d=!0){return $e("isCompressed",d),this.assertValidity(),o(h,this,d)}toHex(d=!0){return $e("isCompressed",d),lt(this.toRawBytes(d))}}h.BASE=new h(e.Gx,e.Gy,r.ONE),h.ZERO=new h(r.ZERO,r.ONE,r.ZERO);let v=e.nBitLength,E=Ln(h,e.endo?Math.ceil(v/2):v);return{CURVE:e,ProjectivePoint:h,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:a}}function b0(t){let e=$r(t);return Je(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function mu(t){let e=b0(t),{Fp:r,n}=e,o=r.BYTES+1,i=2*r.BYTES+1;function s(S){return J(S,n)}function a(S){return Rn(S,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:l,weierstrassEquation:u,isWithinCurveOrder:f}=w0({...e,toBytes(S,k,m){let p=k.toAffine(),B=r.toBytes(p.x),N=ht;return $e("isCompressed",m),m?N(Uint8Array.from([k.hasEvenY()?2:3]),B):N(Uint8Array.from([4]),B,r.toBytes(p.y))},fromBytes(S){let k=S.length,m=S[0],p=S.subarray(1);if(k===o&&(m===2||m===3)){let B=ft(p);if(!Pr(B,ue,r.ORDER))throw new Error("Point is not on curve");let N=u(B),O;try{O=r.sqrt(N)}catch(Z){let $=Z instanceof Error?": "+Z.message:"";throw new Error("Point is not on curve"+$)}let H=(O&ue)===ue;return(m&1)===1!==H&&(O=r.neg(O)),{x:B,y:O}}else if(k===i&&m===4){let B=r.fromBytes(p.subarray(0,r.BYTES)),N=r.fromBytes(p.subarray(r.BYTES,2*r.BYTES));return{x:B,y:N}}else{let B=o,N=i;throw new Error("invalid Point, expected length of "+B+", or uncompressed "+N+", got "+k)}}}),h=S=>lt(_t(S,e.nByteLength));function v(S){let k=n>>ue;return S>k}function E(S){return v(S)?s(-S):S}let y=(S,k,m)=>ft(S.slice(k,m));class d{constructor(k,m,p){this.r=k,this.s=m,this.recovery=p,this.assertValidity()}static fromCompact(k){let m=e.nByteLength;return k=ne("compactSignature",k,m*2),new d(y(k,0,m),y(k,m,2*m))}static fromDER(k){let{r:m,s:p}=wt.toSig(ne("DER",k));return new d(m,p)}assertValidity(){Ie("r",this.r,ue,n),Ie("s",this.s,ue,n)}addRecoveryBit(k){return new d(this.r,this.s,k)}recoverPublicKey(k){let{r:m,s:p,recovery:B}=this,N=D(ne("msgHash",k));if(B==null||![0,1,2,3].includes(B))throw new Error("recovery id invalid");let O=B===2||B===3?m+e.n:m;if(O>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let H=B&1?"03":"02",z=c.fromHex(H+h(O)),Z=a(O),$=s(-N*Z),j=s(p*Z),X=c.BASE.multiplyAndAddUnsafe(z,$,j);if(!X)throw new Error("point at infinify");return X.assertValidity(),X}hasHighS(){return v(this.s)}normalizeS(){return this.hasHighS()?new d(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return jt(this.toDERHex())}toDERHex(){return wt.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return jt(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}let A={isValidPrivateKey(S){try{return l(S),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{let S=qi(e.n);return Pa(e.randomBytes(S),e.n)},precompute(S=8,k=c.BASE){return k._setWindowSize(S),k.multiply(BigInt(3)),k}};function T(S,k=!0){return c.fromPrivateKey(S).toRawBytes(k)}function x(S){let k=Ut(S),m=typeof S=="string",p=(k||m)&&S.length;return k?p===o||p===i:m?p===2*o||p===2*i:S instanceof c}function U(S,k,m=!0){if(x(S))throw new Error("first arg must be private key");if(!x(k))throw new Error("second arg must be public key");return c.fromHex(k).multiply(l(S)).toRawBytes(m)}let F=e.bits2int||function(S){if(S.length>8192)throw new Error("input is too large");let k=ft(S),m=S.length*8-e.nBitLength;return m>0?k>>BigInt(m):k},D=e.bits2int_modN||function(S){return s(F(S))},R=Kr(e.nBitLength);function w(S){return Ie("num < 2^"+e.nBitLength,S,bt,R),_t(S,e.nByteLength)}function b(S,k,m=M){if(["recovered","canonical"].some(ce=>ce in m))throw new Error("sign() legacy options not supported");let{hash:p,randomBytes:B}=e,{lowS:N,prehash:O,extraEntropy:H}=m;N==null&&(N=!0),S=ne("msgHash",S),pu(m),O&&(S=ne("prehashed msgHash",p(S)));let z=D(S),Z=l(k),$=[w(Z),w(z)];if(H!=null&&H!==!1){let ce=H===!0?B(r.BYTES):H;$.push(ne("extraEntropy",ce))}let j=ht(...$),X=z;function ae(ce){let fe=F(ce);if(!f(fe))return;let ye=a(fe),Ce=c.BASE.multiply(fe).toAffine(),ve=s(Ce.x);if(ve===bt)return;let Ye=s(ye*s(X+ve*Z));if(Ye===bt)return;let it=(Ce.x===ve?0:2)|Number(Ce.y&ue),Lr=Ye;return N&&v(Ye)&&(Lr=E(Ye),it^=1),new d(ve,Lr,it)}return{seed:j,k2sig:ae}}let M={lowS:e.lowS,prehash:!1},_={lowS:e.lowS,prehash:!1};function I(S,k,m=M){let{seed:p,k2sig:B}=b(S,k,m),N=e;return Hi(N.hash.outputLen,N.nByteLength,N.hmac)(p,B)}c.BASE._setWindowSize(8);function K(S,k,m,p=_){let B=S;k=ne("msgHash",k),m=ne("publicKey",m);let{lowS:N,prehash:O,format:H}=p;if(pu(p),"strict"in p)throw new Error("options.strict was renamed to lowS");if(H!==void 0&&H!=="compact"&&H!=="der")throw new Error("format must be compact or der");let z=typeof B=="string"||Ut(B),Z=!z&&!H&&typeof B=="object"&&B!==null&&typeof B.r=="bigint"&&typeof B.s=="bigint";if(!z&&!Z)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let $,j;try{if(Z&&($=new d(B.r,B.s)),z){try{H!=="compact"&&($=d.fromDER(B))}catch(it){if(!(it instanceof wt.Err))throw it}!$&&H!=="der"&&($=d.fromCompact(B))}j=c.fromHex(m)}catch{return!1}if(!$||N&&$.hasHighS())return!1;O&&(k=e.hash(k));let{r:X,s:ae}=$,ce=D(k),fe=a(ae),ye=s(ce*fe),Ce=s(X*fe),ve=c.BASE.multiplyAndAddUnsafe(j,ye,Ce)?.toAffine();return ve?s(ve.x)===X:!1}return{CURVE:e,getPublicKey:T,getSharedSecret:U,sign:I,verify:K,ProjectivePoint:c,Signature:d,utils:A}}function v0(t){return{hash:t,hmac:(e,...r)=>_s(t,e,_i(...r)),randomBytes:Cn}}function yu(t,e){let r=n=>mu({...t,...v0(n)});return{...r(e),create:r}}var bu=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),xu=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),E0=BigInt(1),Vs=BigInt(2),wu=(t,e)=>(t+e/Vs)/e;function B0(t){let e=bu,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),l=t*t*t%e,u=l*l*t%e,f=re(u,r,e)*u%e,h=re(f,r,e)*u%e,v=re(h,Vs,e)*l%e,E=re(v,o,e)*v%e,y=re(E,i,e)*E%e,d=re(y,a,e)*y%e,A=re(d,c,e)*d%e,T=re(A,a,e)*y%e,x=re(T,r,e)*u%e,U=re(x,s,e)*E%e,F=re(U,n,e)*l%e,D=re(F,Vs,e);if(!Ds.eql(Ds.sqr(D),t))throw new Error("Cannot find square root");return D}var Ds=Lt(bu,void 0,void 0,{sqrt:B0}),rr=yu({a:BigInt(0),b:BigInt(7),Fp:Ds,n:xu,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{let e=xu,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-E0*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=r,s=BigInt("0x100000000000000000000000000000000"),a=wu(i*t,e),c=wu(-n*t,e),l=J(t-a*r-c*o,e),u=J(-a*n-c*i,e),f=l>s,h=u>s;if(f&&(l=e-l),h&&(u=e-u),l>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:f,k1:l,k2neg:h,k2:u}}}},br),ux=BigInt(0);var lx=rr.ProjectivePoint;function an(t,e){e==null&&(e=t.reduce((o,i)=>o+i.length,0));let r=Xe(e),n=0;for(let o of t)r.set(o,n),n+=o.length;return r}function vu(t){return t==null?!1:typeof t.then=="function"&&typeof t.catch=="function"&&typeof t.finally=="function"}function Eu(t,e,r){let n=zr.digest(r instanceof Uint8Array?r:r.subarray());if(vu(n))return n.then(({digest:o})=>rr.verify(e,o,t)).catch(o=>{throw new nn(String(o))});try{return rr.verify(e,n.digest,t)}catch(o){throw new nn(String(o))}}var Do=class{type="secp256k1";raw;_key;constructor(e){this._key=Au(e),this.raw=Bu(this._key)}toMultihash(){return ct.digest(xr(this))}toCID(){return ee.createV1(114,this.toMultihash())}toString(){return Q.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:he(this.raw,e.raw)}verify(e,r){return Eu(this._key,r,e)}};function Fs(t){return new Do(t)}function Bu(t){return rr.ProjectivePoint.fromHex(t).toRawBytes(!0)}function Au(t){try{return rr.ProjectivePoint.fromHex(t),t}catch(e){throw new sr(String(e))}}function Su(t){let{Type:e,Data:r}=Qe.decode(t),n=r??new Uint8Array;switch(e){case se.RSA:return Rs(n);case se.Ed25519:return Ji(n);case se.secp256k1:return Fs(n);default:throw new cr}}function Fo(t){let{Type:e,Data:r}=Qe.decode(t.digest),n=r??new Uint8Array;switch(e){case se.Ed25519:return Ji(n);case se.secp256k1:return Fs(n);default:throw new cr}}function xr(t){return Qe.encode({Type:se[t.type],Data:t.raw})}var vt="/",ku=new TextEncoder().encode(vt),Mo=ku[0],cn=class t{_buf;constructor(e,r){if(typeof e=="string")this._buf=Y(e);else if(e instanceof Uint8Array)this._buf=e;else throw new Error("Invalid key, should be String of Uint8Array");if(r==null&&(r=!0),r&&this.clean(),this._buf.byteLength===0||this._buf[0]!==Mo)throw new Error("Invalid key")}toString(e="utf8"){return Se(this._buf,e)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(e){return new t(e.join(vt))}static random(){return new t(Math.random().toString().substring(2))}static asKey(e){return e instanceof Uint8Array||typeof e=="string"?new t(e):typeof e.uint8Array=="function"?new t(e.uint8Array()):null}clean(){if((this._buf==null||this._buf.byteLength===0)&&(this._buf=ku),this._buf[0]!==Mo){let e=new Uint8Array(this._buf.byteLength+1);e.fill(Mo,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===Mo;)this._buf=this._buf.subarray(0,-1)}less(e){let r=this.list(),n=e.list();for(let o=0;o<r.length;o++){if(n.length<o+1)return!1;let i=r[o],s=n[o];if(i<s)return!0;if(i>s)return!1}return r.length<n.length}reverse(){return t.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){let e=this.namespaces();return e[e.length-1]}list(){return this.toString().split(vt).slice(1)}type(){return A0(this.baseNamespace())}name(){return S0(this.baseNamespace())}instance(e){return new t(this.toString()+":"+e)}path(){let e=this.parent().toString();return e.endsWith(vt)||(e+=vt),e+=this.type(),new t(e)}parent(){let e=this.list();return e.length===1?new t(vt):new t(e.slice(0,-1).join(vt))}child(e){return this.toString()===vt?e:e.toString()===vt?this:new t(this.toString()+e.toString(),!1)}isAncestorOf(e){return e.toString()===this.toString()?!1:e.toString().startsWith(this.toString())}isDecendantOf(e){return e.toString()===this.toString()?!1:this.toString().startsWith(e.toString())}isTopLevel(){return this.list().length===1}concat(...e){return t.withNamespaces([...this.namespaces(),...k0(e.map(r=>r.namespaces()))])}};function A0(t){let e=t.split(":");return e.length<2?"":e.slice(0,-1).join(":")}function S0(t){let e=t.split(":");return e[e.length-1]}function k0(t){return[].concat(...t)}var Ol=Vr(Oo(),1);var Ho=class extends Error{static name="SignatureCreationError";constructor(e="Record signature creation failed"){super(e),this.name="SignatureCreationError"}},Ze=class extends Error{static name="SignatureVerificationError";constructor(e="Record signature verification failed"){super(e),this.name="SignatureVerificationError"}},Po=class extends Error{static name="RecordExpiredError";constructor(e="Record has expired"){super(e),this.name="RecordExpiredError"}},nr=class extends Error{static name="UnsupportedValidityError";constructor(e="The validity type is unsupported"){super(e),this.name="UnsupportedValidityError"}},Ko=class extends Error{static name="RecordTooLargeError";constructor(e="The record is too large"){super(e),this.name="RecordTooLargeError"}},un=class extends Error{static name="InvalidValueError";constructor(e="Value must be a valid content path starting with /"){super(e),this.name="InvalidValueError"}},$o=class extends Error{static name="InvalidRecordDataError";constructor(e="Invalid record data"){super(e),this.name="InvalidRecordDataError"}},ln=class extends Error{static name="InvalidEmbeddedPublicKeyError";constructor(e="Invalid embedded public key"){super(e),this.name="InvalidEmbeddedPublicKeyError"}};var ge;(function(t){let e;(function(o){o.EOL="EOL"})(e=t.ValidityType||(t.ValidityType={}));let r;(function(o){o[o.EOL=0]="EOL"})(r||(r={})),function(o){o.codec=()=>Wr(r)}(e=t.ValidityType||(t.ValidityType={}));let n;t.codec=()=>(n==null&&(n=Ot((o,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),o.value!=null&&(i.uint32(10),i.bytes(o.value)),o.signatureV1!=null&&(i.uint32(18),i.bytes(o.signatureV1)),o.validityType!=null&&(i.uint32(24),t.ValidityType.codec().encode(o.validityType,i)),o.validity!=null&&(i.uint32(34),i.bytes(o.validity)),o.sequence!=null&&(i.uint32(40),i.uint64(o.sequence)),o.ttl!=null&&(i.uint32(48),i.uint64(o.ttl)),o.pubKey!=null&&(i.uint32(58),i.bytes(o.pubKey)),o.signatureV2!=null&&(i.uint32(66),i.bytes(o.signatureV2)),o.data!=null&&(i.uint32(74),i.bytes(o.data)),s.lengthDelimited!==!1&&i.ldelim()},(o,i,s={})=>{let a={},c=i==null?o.len:o.pos+i;for(;o.pos<c;){let l=o.uint32();switch(l>>>3){case 1:{a.value=o.bytes();break}case 2:{a.signatureV1=o.bytes();break}case 3:{a.validityType=t.ValidityType.codec().decode(o);break}case 4:{a.validity=o.bytes();break}case 5:{a.sequence=o.uint64();break}case 6:{a.ttl=o.uint64();break}case 7:{a.pubKey=o.bytes();break}case 8:{a.signatureV2=o.bytes();break}case 9:{a.data=o.bytes();break}default:{o.skipType(l&7);break}}}return a})),n),t.encode=o=>Mt(o,t.codec()),t.decode=(o,i)=>Ft(o,t.codec(),i)})(ge||(ge={}));var C0=["string","number","bigint","symbol"],T0=["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 Cu(t){if(t===null)return"null";if(t===void 0)return"undefined";if(t===!0||t===!1)return"boolean";let e=typeof t;if(C0.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(t))return"Array";if(I0(t))return"Buffer";let r=N0(t);return r||"Object"}function I0(t){return t&&t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer.call(null,t)}function N0(t){let e=Object.prototype.toString.call(t).slice(8,-1);if(T0.includes(e))return e}var g=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}};g.uint=new g(0,"uint",!0);g.negint=new g(1,"negint",!0);g.bytes=new g(2,"bytes",!0);g.string=new g(3,"string",!0);g.array=new g(4,"array",!1);g.map=new g(5,"map",!1);g.tag=new g(6,"tag",!1);g.float=new g(7,"float",!0);g.false=new g(7,"false",!0);g.true=new g(7,"true",!0);g.null=new g(7,"null",!0);g.undefined=new g(7,"undefined",!0);g.break=new g(7,"break",!0);var V=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 Cr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",U0=new TextDecoder,R0=new TextEncoder;function qo(t){return Cr&&globalThis.Buffer.isBuffer(t)}function Os(t){return t instanceof Uint8Array?qo(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t:Uint8Array.from(t)}var Uu=Cr?(t,e,r)=>r-e>64?globalThis.Buffer.from(t.subarray(e,r)).toString("utf8"):Iu(t,e,r):(t,e,r)=>r-e>64?U0.decode(t.subarray(e,r)):Iu(t,e,r),Ru=Cr?t=>t.length>64?globalThis.Buffer.from(t):Tu(t):t=>t.length>64?R0.encode(t):Tu(t),nt=t=>Uint8Array.from(t),Tr=Cr?(t,e,r)=>qo(t)?new Uint8Array(t.subarray(e,r)):t.slice(e,r):(t,e,r)=>t.slice(e,r),_u=Cr?(t,e)=>(t=t.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),Os(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},Lu=Cr?t=>globalThis.Buffer.allocUnsafe(t):t=>new Uint8Array(t);function Vu(t,e){if(qo(t)&&qo(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 Tu(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 Iu(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,l,u;switch(s){case 1:o<128&&(i=o);break;case 2:a=t[e+1],(a&192)===128&&(u=(o&31)<<6|a&63,u>127&&(i=u));break;case 3:a=t[e+1],c=t[e+2],(a&192)===128&&(c&192)===128&&(u=(o&15)<<12|(a&63)<<6|c&63,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:a=t[e+1],c=t[e+2],l=t[e+3],(a&192)===128&&(c&192)===128&&(l&192)===128&&(u=(o&15)<<18|(a&63)<<12|(c&63)<<6|l&63,u>65535&&u<1114112&&(i=u))}}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 _0(n)}var Nu=4096;function _0(t){let e=t.length;if(e<=Nu)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Nu));return r}var L0=256,fn=class{constructor(e=L0){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=Lu(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=Tr(n,0,this.cursor)}else r=_u(this.chunks,this.cursor);return e&&this.reset(),r}};var P="CBOR decode error:",Hs="CBOR encode error:",hn=[];hn[23]=1;hn[24]=2;hn[25]=3;hn[26]=5;hn[27]=9;function Et(t,e,r){if(t.length-e<r)throw new Error(`${P} not enough data for type`)}var le=[24,256,65536,4294967296,BigInt("18446744073709551616")];function _e(t,e,r){Et(t,e,1);let n=t[e];if(r.strict===!0&&n<le[0])throw new Error(`${P} integer encoded in more bytes than necessary (strict decode)`);return n}function Le(t,e,r){Et(t,e,2);let n=t[e]<<8|t[e+1];if(r.strict===!0&&n<le[1])throw new Error(`${P} integer encoded in more bytes than necessary (strict decode)`);return n}function Ve(t,e,r){Et(t,e,4);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3];if(r.strict===!0&&n<le[2])throw new Error(`${P} integer encoded in more bytes than necessary (strict decode)`);return n}function De(t,e,r){Et(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<le[3])throw new Error(`${P} 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(`${P} integers outside of the safe integer range are not supported`)}function Du(t,e,r,n){return new V(g.uint,_e(t,e+1,n),2)}function Fu(t,e,r,n){return new V(g.uint,Le(t,e+1,n),3)}function Mu(t,e,r,n){return new V(g.uint,Ve(t,e+1,n),5)}function Ou(t,e,r,n){return new V(g.uint,De(t,e+1,n),9)}function Me(t,e){return me(t,0,e.value)}function me(t,e,r){if(r<le[0]){let n=Number(r);t.push([e|n])}else if(r<le[1]){let n=Number(r);t.push([e|24,n])}else if(r<le[2]){let n=Number(r);t.push([e|25,n>>>8,n&255])}else if(r<le[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<le[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(`${P} encountered BigInt larger than allowable range`)}}Me.encodedSize=function(e){return me.encodedSize(e.value)};me.encodedSize=function(e){return e<le[0]?1:e<le[1]?2:e<le[2]?3:e<le[3]?5:9};Me.compareTokens=function(e,r){return e.value<r.value?-1:e.value>r.value?1:0};function Hu(t,e,r,n){return new V(g.negint,-1-_e(t,e+1,n),2)}function Pu(t,e,r,n){return new V(g.negint,-1-Le(t,e+1,n),3)}function Ku(t,e,r,n){return new V(g.negint,-1-Ve(t,e+1,n),5)}var Ps=BigInt(-1),$u=BigInt(1);function qu(t,e,r,n){let o=De(t,e+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new V(g.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${P} integers outside of the safe integer range are not supported`);return new V(g.negint,Ps-BigInt(o),9)}function zo(t,e){let r=e.value,n=typeof r=="bigint"?r*Ps-$u:r*-1-1;me(t,e.type.majorEncoded,n)}zo.encodedSize=function(e){let r=e.value,n=typeof r=="bigint"?r*Ps-$u:r*-1-1;return n<le[0]?1:n<le[1]?2:n<le[2]?3:n<le[3]?5:9};zo.compareTokens=function(e,r){return e.value<r.value?1:e.value>r.value?-1:0};function dn(t,e,r,n){Et(t,e,r+n);let o=Tr(t,e+r,e+r+n);return new V(g.bytes,o,r+n)}function zu(t,e,r,n){return dn(t,e,1,r)}function Gu(t,e,r,n){return dn(t,e,2,_e(t,e+1,n))}function Zu(t,e,r,n){return dn(t,e,3,Le(t,e+1,n))}function Wu(t,e,r,n){return dn(t,e,5,Ve(t,e+1,n))}function ju(t,e,r,n){let o=De(t,e+1,n);if(typeof o=="bigint")throw new Error(`${P} 64-bit integer bytes lengths not supported`);return dn(t,e,9,o)}function Go(t){return t.encodedBytes===void 0&&(t.encodedBytes=t.type===g.string?Ru(t.value):t.value),t.encodedBytes}function Ir(t,e){let r=Go(e);me(t,e.type.majorEncoded,r.length),t.push(r)}Ir.encodedSize=function(e){let r=Go(e);return me.encodedSize(r.length)+r.length};Ir.compareTokens=function(e,r){return D0(Go(e),Go(r))};function D0(t,e){return t.length<e.length?-1:t.length>e.length?1:Vu(t,e)}function pn(t,e,r,n,o){let i=r+n;Et(t,e,i);let s=new V(g.string,Uu(t,e+r,e+i),i);return o.retainStringBytes===!0&&(s.byteValue=Tr(t,e+r,e+i)),s}function Yu(t,e,r,n){return pn(t,e,1,r,n)}function Ju(t,e,r,n){return pn(t,e,2,_e(t,e+1,n),n)}function Xu(t,e,r,n){return pn(t,e,3,Le(t,e+1,n),n)}function Qu(t,e,r,n){return pn(t,e,5,Ve(t,e+1,n),n)}function el(t,e,r,n){let o=De(t,e+1,n);if(typeof o=="bigint")throw new Error(`${P} 64-bit integer string lengths not supported`);return pn(t,e,9,o,n)}var tl=Ir;function Nr(t,e,r,n){return new V(g.array,n,r)}function rl(t,e,r,n){return Nr(t,e,1,r)}function nl(t,e,r,n){return Nr(t,e,2,_e(t,e+1,n))}function ol(t,e,r,n){return Nr(t,e,3,Le(t,e+1,n))}function il(t,e,r,n){return Nr(t,e,5,Ve(t,e+1,n))}function sl(t,e,r,n){let o=De(t,e+1,n);if(typeof o=="bigint")throw new Error(`${P} 64-bit integer array lengths not supported`);return Nr(t,e,9,o)}function al(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${P} indefinite length items not allowed`);return Nr(t,e,1,1/0)}function Zo(t,e){me(t,g.array.majorEncoded,e.value)}Zo.compareTokens=Me.compareTokens;Zo.encodedSize=function(e){return me.encodedSize(e.value)};function Ur(t,e,r,n){return new V(g.map,n,r)}function cl(t,e,r,n){return Ur(t,e,1,r)}function ul(t,e,r,n){return Ur(t,e,2,_e(t,e+1,n))}function ll(t,e,r,n){return Ur(t,e,3,Le(t,e+1,n))}function fl(t,e,r,n){return Ur(t,e,5,Ve(t,e+1,n))}function hl(t,e,r,n){let o=De(t,e+1,n);if(typeof o=="bigint")throw new Error(`${P} 64-bit integer map lengths not supported`);return Ur(t,e,9,o)}function dl(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${P} indefinite length items not allowed`);return Ur(t,e,1,1/0)}function Wo(t,e){me(t,g.map.majorEncoded,e.value)}Wo.compareTokens=Me.compareTokens;Wo.encodedSize=function(e){return me.encodedSize(e.value)};function pl(t,e,r,n){return new V(g.tag,r,1)}function gl(t,e,r,n){return new V(g.tag,_e(t,e+1,n),2)}function ml(t,e,r,n){return new V(g.tag,Le(t,e+1,n),3)}function yl(t,e,r,n){return new V(g.tag,Ve(t,e+1,n),5)}function xl(t,e,r,n){return new V(g.tag,De(t,e+1,n),9)}function jo(t,e){me(t,g.tag.majorEncoded,e.value)}jo.compareTokens=Me.compareTokens;jo.encodedSize=function(e){return me.encodedSize(e.value)};var K0=20,$0=21,q0=22,z0=23;function wl(t,e,r,n){if(n.allowUndefined===!1)throw new Error(`${P} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new V(g.null,null,1):new V(g.undefined,void 0,1)}function bl(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${P} indefinite length items not allowed`);return new V(g.break,void 0,1)}function Ks(t,e,r){if(r){if(r.allowNaN===!1&&Number.isNaN(t))throw new Error(`${P} NaN values are not supported`);if(r.allowInfinity===!1&&(t===1/0||t===-1/0))throw new Error(`${P} Infinity values are not supported`)}return new V(g.float,t,e)}function vl(t,e,r,n){return Ks($s(t,e+1),3,n)}function El(t,e,r,n){return Ks(qs(t,e+1),5,n)}function Bl(t,e,r,n){return Ks(Cl(t,e+1),9,n)}function Yo(t,e,r){let n=e.value;if(n===!1)t.push([g.float.majorEncoded|K0]);else if(n===!0)t.push([g.float.majorEncoded|$0]);else if(n===null)t.push([g.float.majorEncoded|q0]);else if(n===void 0)t.push([g.float.majorEncoded|z0]);else{let o,i=!1;(!r||r.float64!==!0)&&(Sl(n),o=$s(We,1),n===o||Number.isNaN(n)?(We[0]=249,t.push(We.slice(0,3)),i=!0):(kl(n),o=qs(We,1),n===o&&(We[0]=250,t.push(We.slice(0,5)),i=!0))),i||(G0(n),o=Cl(We,1),We[0]=251,t.push(We.slice(0,9)))}}Yo.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){Sl(n);let o=$s(We,1);if(n===o||Number.isNaN(n))return 3;if(kl(n),o=qs(We,1),n===o)return 5}return 9};var Al=new ArrayBuffer(9),Oe=new DataView(Al,1),We=new Uint8Array(Al,0);function Sl(t){if(t===1/0)Oe.setUint16(0,31744,!1);else if(t===-1/0)Oe.setUint16(0,64512,!1);else if(Number.isNaN(t))Oe.setUint16(0,32256,!1);else{Oe.setFloat32(0,t);let e=Oe.getUint32(0),r=(e&2139095040)>>23,n=e&8388607;if(r===255)Oe.setUint16(0,31744,!1);else if(r===0)Oe.setUint16(0,(t&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?Oe.setUint16(0,0):o<-14?Oe.setUint16(0,(e&2147483648)>>16|1<<24+o,!1):Oe.setUint16(0,(e&2147483648)>>16|o+15<<10|n>>13,!1)}}}function $s(t,e){if(t.length-e<2)throw new Error(`${P} 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 kl(t){Oe.setFloat32(0,t,!1)}function qs(t,e){if(t.length-e<4)throw new Error(`${P} not enough data for float32`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,4).getFloat32(0,!1)}function G0(t){Oe.setFloat64(0,t,!1)}function Cl(t,e){if(t.length-e<8)throw new Error(`${P} not enough data for float64`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,8).getFloat64(0,!1)}Yo.compareTokens=Me.compareTokens;function W(t,e,r){throw new Error(`${P} encountered invalid minor (${r}) for major ${t[e]>>>5}`)}function Jo(t){return()=>{throw new Error(`${P} ${t}`)}}var C=[];for(let t=0;t<=23;t++)C[t]=W;C[24]=Du;C[25]=Fu;C[26]=Mu;C[27]=Ou;C[28]=W;C[29]=W;C[30]=W;C[31]=W;for(let t=32;t<=55;t++)C[t]=W;C[56]=Hu;C[57]=Pu;C[58]=Ku;C[59]=qu;C[60]=W;C[61]=W;C[62]=W;C[63]=W;for(let t=64;t<=87;t++)C[t]=zu;C[88]=Gu;C[89]=Zu;C[90]=Wu;C[91]=ju;C[92]=W;C[93]=W;C[94]=W;C[95]=Jo("indefinite length bytes/strings are not supported");for(let t=96;t<=119;t++)C[t]=Yu;C[120]=Ju;C[121]=Xu;C[122]=Qu;C[123]=el;C[124]=W;C[125]=W;C[126]=W;C[127]=Jo("indefinite length bytes/strings are not supported");for(let t=128;t<=151;t++)C[t]=rl;C[152]=nl;C[153]=ol;C[154]=il;C[155]=sl;C[156]=W;C[157]=W;C[158]=W;C[159]=al;for(let t=160;t<=183;t++)C[t]=cl;C[184]=ul;C[185]=ll;C[186]=fl;C[187]=hl;C[188]=W;C[189]=W;C[190]=W;C[191]=dl;for(let t=192;t<=215;t++)C[t]=pl;C[216]=gl;C[217]=ml;C[218]=yl;C[219]=xl;C[220]=W;C[221]=W;C[222]=W;C[223]=W;for(let t=224;t<=243;t++)C[t]=Jo("simple values are not supported");C[244]=W;C[245]=W;C[246]=W;C[247]=wl;C[248]=Jo("simple values are not supported");C[249]=vl;C[250]=El;C[251]=Bl;C[252]=W;C[253]=W;C[254]=W;C[255]=bl;var je=[];for(let t=0;t<24;t++)je[t]=new V(g.uint,t,1);for(let t=-1;t>=-24;t--)je[31-t]=new V(g.negint,t,1);je[64]=new V(g.bytes,new Uint8Array(0),1);je[96]=new V(g.string,"",1);je[128]=new V(g.array,0,1);je[160]=new V(g.map,0,1);je[244]=new V(g.false,!1,1);je[245]=new V(g.true,!0,1);je[246]=new V(g.null,null,1);function Tl(t){switch(t.type){case g.false:return nt([244]);case g.true:return nt([245]);case g.null:return nt([246]);case g.bytes:return t.value.length?void 0:nt([64]);case g.string:return t.value===""?nt([96]):void 0;case g.array:return t.value===0?nt([128]):void 0;case g.map:return t.value===0?nt([160]):void 0;case g.uint:return t.value<24?nt([Number(t.value)]):void 0;case g.negint:if(t.value>=-24)return nt([31-Number(t.value)])}}var W0={float64:!1,mapSorter:J0,quickEncodeToken:Tl};function j0(){let t=[];return t[g.uint.major]=Me,t[g.negint.major]=zo,t[g.bytes.major]=Ir,t[g.string.major]=tl,t[g.array.major]=Zo,t[g.map.major]=Wo,t[g.tag.major]=jo,t[g.float.major]=Yo,t}var Il=j0(),zs=new fn,Qo=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(`${Hs} object contains circular references`);return new t(r,e)}},zt={null:new V(g.null,null),undefined:new V(g.undefined,void 0),true:new V(g.true,!0),false:new V(g.false,!1),emptyArray:new V(g.array,0),emptyMap:new V(g.map,0)},Gt={number(t,e,r,n){return!Number.isInteger(t)||!Number.isSafeInteger(t)?new V(g.float,t):t>=0?new V(g.uint,t):new V(g.negint,t)},bigint(t,e,r,n){return t>=BigInt(0)?new V(g.uint,t):new V(g.negint,t)},Uint8Array(t,e,r,n){return new V(g.bytes,t)},string(t,e,r,n){return new V(g.string,t)},boolean(t,e,r,n){return t?zt.true:zt.false},null(t,e,r,n){return zt.null},undefined(t,e,r,n){return zt.undefined},ArrayBuffer(t,e,r,n){return new V(g.bytes,new Uint8Array(t))},DataView(t,e,r,n){return new V(g.bytes,new Uint8Array(t.buffer,t.byteOffset,t.byteLength))},Array(t,e,r,n){if(!t.length)return r.addBreakTokens===!0?[zt.emptyArray,new V(g.break)]:zt.emptyArray;n=Qo.createCheck(n,t);let o=[],i=0;for(let s of t)o[i++]=Xo(s,r,n);return r.addBreakTokens?[new V(g.array,t.length),o,new V(g.break)]:[new V(g.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?[zt.emptyMap,new V(g.break)]:zt.emptyMap;n=Qo.createCheck(n,t);let a=[],c=0;for(let l of i)a[c++]=[Xo(l,r,n),Xo(o?t.get(l):t[l],r,n)];return Y0(a,r),r.addBreakTokens?[new V(g.map,s),a,new V(g.break)]:[new V(g.map,s),a]}};Gt.Map=Gt.Object;Gt.Buffer=Gt.Uint8Array;for(let t of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Gt[`${t}Array`]=Gt.DataView;function Xo(t,e={},r){let n=Cu(t),o=e&&e.typeEncoders&&e.typeEncoders[n]||Gt[n];if(typeof o=="function"){let s=o(t,n,e,r);if(s!=null)return s}let i=Gt[n];if(!i)throw new Error(`${Hs} unsupported type: ${n}`);return i(t,n,e,r)}function Y0(t,e){e.mapSorter&&t.sort(e.mapSorter)}function J0(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=Il[o].compareTokens(r,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function Nl(t,e,r,n){if(Array.isArray(e))for(let o of e)Nl(t,o,r,n);else r[e.type.major](t,e,n)}function X0(t,e,r){let n=Xo(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 fn(s);if(i(a,n,r),a.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return Os(a.chunks[0])}}return zs.reset(),Nl(zs,n,e,r),zs.toBytes(!0)}function Gs(t,e){return e=Object.assign({},W0,e),X0(t,Il,e)}var Q0={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},ei=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=je[e];if(r===void 0){let n=C[e];if(!n)throw new Error(`${P} 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}},gn=Symbol.for("DONE"),ti=Symbol.for("BREAK");function ep(t,e,r){let n=[];for(let o=0;o<t.value;o++){let i=Rr(e,r);if(i===ti){if(t.value===1/0)break;throw new Error(`${P} got unexpected break to lengthed array`)}if(i===gn)throw new Error(`${P} found array but not enough entries (got ${o}, expected ${t.value})`);n[o]=i}return n}function tp(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=Rr(e,r);if(a===ti){if(t.value===1/0)break;throw new Error(`${P} got unexpected break to lengthed map`)}if(a===gn)throw new Error(`${P} found map but not enough entries (got ${s} [no key], expected ${t.value})`);if(n!==!0&&typeof a!="string")throw new Error(`${P} non-string keys not supported (got ${typeof a})`);if(r.rejectDuplicateMapKeys===!0&&(n&&i.has(a)||!n&&a in o))throw new Error(`${P} found repeat map key "${a}"`);let c=Rr(e,r);if(c===gn)throw new Error(`${P} 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 Rr(t,e){if(t.done())return gn;let r=t.next();if(r.type===g.break)return ti;if(r.type.terminal)return r.value;if(r.type===g.array)return ep(r,t,e);if(r.type===g.map)return tp(r,t,e);if(r.type===g.tag){if(e.tags&&typeof e.tags[r.value]=="function"){let n=Rr(t,e);return e.tags[r.value](n)}throw new Error(`${P} tag not supported (${r.value})`)}throw new Error("unsupported")}function Ul(t,e){if(!(t instanceof Uint8Array))throw new Error(`${P} data to decode must be a Uint8Array`);e=Object.assign({},Q0,e);let r=e.tokenizer||new ei(t,e),n=Rr(r,e);if(n===gn)throw new Error(`${P} did not find any content to decode`);if(n===ti)throw new Error(`${P} got unexpected break`);return[n,t.subarray(r.pos())]}function Zs(t,e){let[r,n]=Ul(t,e);if(n.length>0)throw new Error(`${P} too many terminals, data makes no sense`);return r}var np=Ct("ipns:utils"),Rl=Y("/ipns/"),op=114,ip=0,sp=18;function _l(t){let e;if(t.pubKey!=null)try{e=Su(t.pubKey)}catch(r){throw np.error(r),r}if(e!=null)return e}function Ll(t,e,r){let n=Y(e);return an([t,r,n])}function ni(t){let e=Y("ipns-signature:");return an([e,t])}function Ws(t){return"signatureV1"in t?ge.encode({value:Y(t.value),signatureV1:t.signatureV1,validityType:t.validityType,validity:Y(t.validity),sequence:t.sequence,ttl:t.ttl,pubKey:t.pubKey,signatureV2:t.signatureV2,data:t.data}):ge.encode({pubKey:t.pubKey,signatureV2:t.signatureV2,data:t.data})}function ot(t){let e=ge.decode(t);if(e.sequence!=null&&(e.sequence=BigInt(e.sequence)),e.ttl!=null&&(e.ttl=BigInt(e.ttl)),e.signatureV2==null||e.data==null)throw new Ze("Missing data or signatureV2");let r=Fl(e.data),n=ap(r.Value),o=Se(r.Validity);if(e.value!=null&&e.signatureV1!=null)return cp(e),{value:n,validityType:ge.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:e.pubKey,signatureV1:e.signatureV1,signatureV2:e.signatureV2,data:e.data};if(e.signatureV2!=null)return{value:n,validityType:ge.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data};throw new Error("invalid record: does not include signatureV1 or signatureV2")}function _r(t){return an([Rl,t.bytes])}function Vl(t){let e=at(t.slice(Rl.length));if(!ri(e,ip)&&!ri(e,sp))throw new ar("Multihash in IPNS key was not identity or sha2-256");return e}function Dl(t,e,r,n,o){let i;if(e===ge.ValidityType.EOL)i=0;else throw new nr("The validity type is unsupported");return Gs({Value:t,Validity:r,ValidityType:i,Sequence:n,TTL:o})}function Fl(t){let e=Zs(t);if(e.ValidityType===0)e.ValidityType=ge.ValidityType.EOL;else throw new nr("The validity type is unsupported");return Number.isInteger(e.Sequence)&&(e.Sequence=BigInt(e.Sequence)),Number.isInteger(e.TTL)&&(e.TTL=BigInt(e.TTL)),e}function ap(t){let e=Se(t).trim();if(e.startsWith("/"))return e;try{return`/ipfs/${ee.decode(t).toV1().toString()}`}catch{}try{return`/ipfs/${ee.parse(e).toV1().toString()}`}catch{}throw new un("Value must be a valid content path starting with /")}function Ml(t){if(t!=null){let e=fp(t);if(e!=null)return e.code===op?`/ipns/${e.toString(He)}`:`/ipfs/${e.toV1().toString()}`;if(up(t))return`/ipns/${He.encode(t.bytes)}`;let r=t.toString().trim();if(r.startsWith("/")&&r.length>1)return r}throw new un("Value must be a valid content path starting with /")}function cp(t){if(t.data==null)throw new $o("Record data is missing");let e=Fl(t.data);if(!he(e.Value,t.value??new Uint8Array(0)))throw new Ze('Field "value" did not match between protobuf and CBOR');if(!he(e.Validity,t.validity??new Uint8Array(0)))throw new Ze('Field "validity" did not match between protobuf and CBOR');if(e.ValidityType!==t.validityType)throw new Ze('Field "validityType" did not match between protobuf and CBOR');if(e.Sequence!==t.sequence)throw new Ze('Field "sequence" did not match between protobuf and CBOR');if(e.TTL!==t.ttl)throw new Ze('Field "ttl" did not match between protobuf and CBOR')}function up(t){return t.bytes instanceof Uint8Array}function lp(t){return typeof t?.toCID=="function"}function fp(t){if(lp(t))return t.toCID();try{return ee.parse(t)}catch{}return ee.asCID(t)}function ri(t,e){return t.code===e}var hp=Ct("ipns"),Hl=60*60*1e9,dp="/ipns/",Bb=dp.length,Pl={v1Compatible:!0,ttlNs:Hl};async function Kl(t,e,r,n,o=Pl){let i=new Ol.default(Date.now()+Number(n)),s=ge.ValidityType.EOL,a=BigInt(o.ttlNs??Hl);return pp(t,e,r,s,i.toString(),a,o)}var pp=async(t,e,r,n,o,i,s=Pl)=>{r=BigInt(r);let a=Y(o),c=Ml(e),l=Y(c),u=Dl(l,n,a,r,i),f=ni(u),h=await t.sign(f),v;if(t.type==="RSA"&&(v=xr(t.publicKey)),s.v1Compatible===!0){let E=await gp(t,l,n,a),y={value:c,signatureV1:E,validity:o,validityType:n,sequence:r,ttl:i,signatureV2:h,data:u};return v!=null&&(y.pubKey=v),y}else{let E={value:c,validity:o,validityType:n,sequence:r,ttl:i,signatureV2:h,data:u};return v!=null&&(E.pubKey=v),E}},gp=async(t,e,r,n)=>{try{let o=Ll(e,r,n);return await t.sign(o)}catch(o){throw hp.error("record signature creation failed",o),new Ho("Record signature creation failed")}};var js=Vr(Oo(),1);function oi(t,e){let r=e.map((n,o)=>({record:ot(n),index:o}));return r.sort((n,o)=>{let i=n.record.sequence,s=o.record.sequence;if(i>s)return-1;if(i<s)return 1;if(n.record.validityType===ge.ValidityType.EOL&&o.record.validityType===ge.ValidityType.EOL){let a=js.default.fromString(n.record.validity).toDate(),c=js.default.fromString(o.record.validity).toDate();if(a.getTime()>c.getTime())return-1;if(a.getTime()<c.getTime())return 1}return 0}),r[0].index}var $l=Vr(Oo(),1);var ii=Ct("ipns:validator"),mp=1024*10,yp=async(t,e)=>{let r=ot(e),n;try{let o=ni(r.data);n=await t.verify(o,r.signatureV2)}catch{n=!1}if(!n)throw ii.error("record signature verification failed"),new Ze("Record signature verification failed");if(r.validityType===ge.ValidityType.EOL){if($l.default.fromString(r.validity).toDate().getTime()<Date.now())throw ii.error("record has expired"),new Po("record has expired")}else if(r.validityType!=null)throw ii.error("the validity type is unsupported"),new nr("The validity type is unsupported");ii("ipns record for %s is valid",r.value)};async function si(t,e){if(e.byteLength>mp)throw new Ko("The record is too large");let r=Vl(t),n;ri(r,0)&&(n=Fo(r));let o=ot(e),i=_l(o)??n;if(i==null)throw new ln("Could not extract public key from IPNS record or routing key");let s=_r(i.toMultihash());if(!he(t,s))throw new ln("Embedded public key did not match routing key");await yp(i,e)}var ke=class extends Event{type;detail;constructor(e,r){super(e),this.type=e,this.detail=r}};var ql=Symbol.for("nodejs.util.inspect.custom"),xp=114,mn=class{type;multihash;publicKey;string;constructor(e){this.type=e.type,this.multihash=e.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[wi]=!0;toString(){return this.string==null&&(this.string=Q.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return ee.createV1(xp,this.multihash)}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return he(this.multihash.bytes,e);if(typeof e=="string")return this.toString()===e;if(e?.toMultihash()?.bytes!=null)return he(this.multihash.bytes,e.toMultihash().bytes);throw new Error("not valid Id")}[ql](){return`PeerId(${this.toString()})`}},ai=class extends mn{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},ci=class extends mn{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.publicKey}},ui=class extends mn{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.publicKey}},wp=2336,yn=class{type="url";multihash;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=ct.digest(Y(this.url))}[ql](){return`PeerId(${this.url})`}[wi]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return ee.createV1(wp,this.toMultihash())}toJSON(){return this.toString()}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=Se(e)),e.toString()===this.toString())}};var bp=114,zl=2336;function Gl(t,e){let r;if(t.charAt(0)==="1"||t.charAt(0)==="Q")r=at(Q.decode(`z${t}`));else{if(e==null)throw new xe('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=at(e.decode(t))}return Zl(r)}function Zl(t){if(Ep(t))return new ai({multihash:t});if(vp(t))try{let e=Fo(t);if(e.type==="Ed25519")return new ci({multihash:t,publicKey:e});if(e.type==="secp256k1")return new ui({multihash:t,publicKey:e})}catch{let r=Se(t.digest);return new yn(new URL(r))}throw new ar("Supplied PeerID Multihash is invalid")}function Wl(t){if(t?.multihash==null||t.version==null||t.version===1&&t.code!==bp&&t.code!==zl)throw new bn("Supplied PeerID CID is invalid");if(t.code===zl){let e=Se(t.multihash.digest);return new yn(new URL(e))}return Zl(t.multihash)}function vp(t){return t.code===ct.code}function Ep(t){return t.code===zr.code}var Sp=Vr(Yl(),1);var Bt;(function(t){t[t.A=1]="A",t[t.CNAME=5]="CNAME",t[t.TXT=16]="TXT",t[t.AAAA=28]="AAAA"})(Bt||(Bt={}));var li=class extends Error{static name="DNSLinkNotFoundError";constructor(e="DNSLink not found"){super(e),this.name="DNSLinkNotFoundError"}},fi=class extends Error{static name="RecordsFailedValidationError";constructor(e="Records failed validation"){super(e),this.name="RecordsFailedValidationError"}},hi=class extends Error{static name="UnsupportedMultibasePrefixError";constructor(e="Unsupported multibase prefix"){super(e),this.name="UnsupportedMultibasePrefixError"}},di=class extends Error{static name="UnsupportedMultihashCodecError";constructor(e="Unsupported multihash codec"){super(e),this.name="UnsupportedMultihashCodecError"}},pi=class extends Error{static name="InvalidValueError";constructor(e="Invalid value"){super(e),this.name="InvalidValueError"}};var kp=32;async function Jl(t,e,r,n,o={}){if(e===0)throw new Error("recursion limit exceeded");n("query %s for TXT and CNAME records",t);let s=((await r.query(t,{...o,types:[Bt.TXT]}))?.Answer??[]).sort((l,u)=>l.data.localeCompare(u.data));n("found %d TXT records for %s",s.length,t);for(let l of s)try{let u=l.data;if(u.startsWith('"')&&u.endsWith('"')&&(u=u.substring(1,u.length-1)),!u.startsWith("dnslink="))continue;n("%s TXT %s",l.name,u),u=u.replace("dnslink=","");let[,f,h,...v]=u.split("/");if(f==="ipfs")try{return{value:`/ipfs/${ee.parse(h)}${v.length>0?`/${v.join("/")}`:""}`,answer:l}}catch{}else if(f==="ipns"){try{let E;return h.charAt(0)==="1"||h.charAt(0)==="Q"?E=Gl(h):E=Wl(ee.parse(h)),{value:`/ipns/${E}${v.length>0?`/${v.join("/")}`:""}`,answer:l}}catch{}return await gi(h,e-1,r,n,o)}else{if(f==="dnslink")return await gi(h,e-1,r,n,o);n('unknown protocol "%s" in DNSLink record for domain: %s',f,t);continue}}catch(u){n.error("could not parse DNS link record for domain %s, %s",t,l.data,u)}n("no DNSLink records found for %s, falling back to CNAME",t);let c=((await r.query(t,{...o,types:[Bt.CNAME]}))?.Answer??[]).sort((l,u)=>l.data.localeCompare(u.data));n("found %d CNAME records for %s",c.length,t);for(let l of c)try{return await gi(l.data,e-1,r,n,o)}catch(u){n.error("domain %s cname %s had no DNSLink records",t,l.data,u)}throw new li(`No DNSLink records found for domain: ${t}`)}async function gi(t,e,r,n,o={}){if(e===0)throw new Error("recursion limit exceeded");t.startsWith("_dnslink.")||(t=`_dnslink.${t}`);try{return await Jl(t,e,r,n,o)}catch(i){if(i.code!=="ENOTFOUND"&&i.code!=="ENODATA"&&i.name!=="DNSLinkNotFoundError"&&i.name!=="NotFoundError")throw i;return t.startsWith("_dnslink.")?t=t.replace("_dnslink.",""):t=`_dnslink.${t}`,Jl(t,e,r,n,o)}}async function Xl(t,e,r,n={}){return gi(t,n.maxRecursiveDepth??kp,e,r,n)}var Ys=class{routing;constructor(e){this.routing=e}async put(e,r,n={}){try{await this.routing.put(e,r,n)}catch(o){n.onProgress?.(new ke("ipns:routing:helia:error",o))}}async get(e,r={}){try{return await this.routing.get(e,r)}catch(n){r.onProgress?.(new ke("ipns:routing:helia:error",n))}throw new Error("Not found")}};function Ql(t){return new Ys(t)}var xn;(function(t){let e;t.codec=()=>(e==null&&(e=Ot((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.key!=null&&r.key.byteLength>0&&(n.uint32(10),n.bytes(r.key)),r.value!=null&&r.value.byteLength>0&&(n.uint32(18),n.bytes(r.value)),r.timeReceived!=null&&r.timeReceived!==""&&(n.uint32(42),n.string(r.timeReceived)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={key:Xi(0),value:Xi(0),timeReceived:""},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let a=r.uint32();switch(a>>>3){case 1:{i.key=r.bytes();break}case 2:{i.value=r.bytes();break}case 5:{i.timeReceived=r.string();break}default:{r.skipType(a&7);break}}}return i})),e),t.encode=r=>Mt(r,t.codec()),t.decode=(r,n)=>Ft(r,t.codec(),n)})(xn||(xn={}));function ef(t){let e=t.getUTCFullYear(),r=String(t.getUTCMonth()+1).padStart(2,"0"),n=String(t.getUTCDate()).padStart(2,"0"),o=String(t.getUTCHours()).padStart(2,"0"),i=String(t.getUTCMinutes()).padStart(2,"0"),s=String(t.getUTCSeconds()).padStart(2,"0"),a=t.getUTCMilliseconds(),c=String(a*1e3*1e3).padStart(9,"0");return`${e}-${r}-${n}T${o}:${i}:${s}.${c}Z`}function tf(t){let e=new RegExp("(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})\\.(\\d+)Z"),r=String(t).trim().match(e);if(r==null)throw new Error("Invalid format");let n=parseInt(r[1],10),o=parseInt(r[2],10)-1,i=parseInt(r[3],10),s=parseInt(r[4],10),a=parseInt(r[5],10),c=parseInt(r[6],10),l=parseInt(r[7].slice(0,-6),10);return new Date(Date.UTC(n,o,i,s,a,c,l))}var ir=class t{key;value;timeReceived;constructor(e,r,n){if(!(e instanceof Uint8Array))throw new Error("key must be a Uint8Array");if(!(r instanceof Uint8Array))throw new Error("value must be a Uint8Array");this.key=e,this.value=r,this.timeReceived=n}serialize(){return xn.encode(this.prepareSerialize())}prepareSerialize(){return{key:this.key,value:this.value,timeReceived:ef(this.timeReceived)}}static deserialize(e){let r=xn.decode(e);return new t(r.key,r.value,new Date(r.timeReceived))}static fromDeserialized(e){let r=tf(e.timeReceived);if(e.key==null)throw new Error("key missing from deserialized object");if(e.value==null)throw new Error("value missing from deserialized object");return new t(e.key,e.value,r)}};var rf;(function(t){t[t.SEND_QUERY=0]="SEND_QUERY",t[t.PEER_RESPONSE=1]="PEER_RESPONSE",t[t.FINAL_PEER=2]="FINAL_PEER",t[t.QUERY_ERROR=3]="QUERY_ERROR",t[t.PROVIDER=4]="PROVIDER",t[t.VALUE=5]="VALUE",t[t.ADD_PEER=6]="ADD_PEER",t[t.DIAL_PEER=7]="DIAL_PEER"})(rf||(rf={}));function mi(t){return new cn("/dht/record/"+Se(t,"base32"),!1)}function nf(t){return{async put(e,r,n={}){try{let o=mi(e);try{let s=await t.get(o),a=ir.deserialize(s);if(he(a.value,r))return}catch(s){if(s.name!=="NotFoundError")throw s}let i=new ir(e,r,new Date);n.onProgress?.(new ke("ipns:routing:datastore:put")),await t.put(o,i.serialize(),n)}catch(o){throw n.onProgress?.(new ke("ipns:routing:datastore:error",o)),o}},async get(e,r={}){try{let n=mi(e);r.onProgress?.(new ke("ipns:routing:datastore:get"));let o=await t.get(n,r),i=ir.deserialize(o);return{record:i.value,created:i.timeReceived}}catch(n){throw r.onProgress?.(new ke("ipns:routing:datastore:error",n)),n}},async has(e,r={}){let n=mi(e);return t.has(n,r)},async delete(e,r){let n=mi(e);return t.delete(n,r)}}}function Js(t,e){return t.code===e}var At=Ct("helia:ipns"),Np=60*1e3,ea=60*Np,Up=24*ea,Xs=23*ea,of=BigInt(ea)*1000000n,sf={[He.prefix]:He,[Q.prefix]:Q},Qs=class{routers;localStore;timeout;dns;log;constructor(e,r=[]){this.routers=[Ql(e.routing),...r],this.localStore=nf(e.datastore),this.dns=e.dns,this.log=e.logger.forComponent("helia:ipns")}async publish(e,r,n={}){try{let o=1n,i=_r(e.publicKey.toMultihash());if(await this.localStore.has(i,n)){let{record:l}=await this.localStore.get(i,n);o=ot(l).sequence+1n}let s=n.ttl!=null?BigInt(n.ttl)*1000000n:of,a=await Kl(e,r,o,n.lifetime??Up,{...n,ttlNs:s}),c=Ws(a);return await this.localStore.put(i,c,n),n.offline!==!0&&await Promise.all(this.routers.map(async l=>{await l.put(i,c,n)})),a}catch(o){throw n.onProgress?.(new ke("ipns:publish:error",o)),o}}async resolve(e,r={}){let n=ua(e)?e.toMultihash():e,o=_r(n),i=await this.#t(o,r);return{...await this.#e(i.value,r),record:i}}async resolveDNSLink(e,r={}){let n=await Xl(e,this.dns,this.log,r);return{...await this.#e(n.value,r),answer:n.answer}}republish(e={}){if(this.timeout!=null)throw new Error("Republish is already running");e.signal?.addEventListener("abort",()=>{clearTimeout(this.timeout)});async function r(){let n=Date.now();e.onProgress?.(new ke("ipns:republish:start"));let i=Date.now()-n,s=Xs-i;s<0&&(s=e.interval??Xs),setTimeout(()=>{r().catch(a=>{At.error("error republishing",a)})},s)}this.timeout=setTimeout(()=>{r().catch(n=>{At.error("error republishing",n)})},e.interval??Xs)}async#e(e,r={}){let n=e.split("/");try{let o=n[1];if(o==="ipns"){let i=n[2],s=i.substring(0,1),a;if(s==="1"||s==="Q")a=Q.decode(`z${i}`);else if(sf[s]!=null)a=sf[s].decode(i);else throw new hi(`Unsupported multibase prefix "${s}"`);let c;try{c=at(a)}catch{c=ee.decode(a).multihash}if(!Js(c,0)&&!Js(c,18))throw new di(`Unsupported multihash codec "${c.code}"`);let{cid:l}=await this.resolve(c,r),u=n.slice(3).join("/");return{cid:l,path:u}}else if(o==="ipfs"){let i=ee.parse(n[2]),s=n.slice(3).join("/");return{cid:i,path:s}}}catch(o){At.error("error parsing ipfs path",o)}throw At.error("invalid ipfs path %s",e),new pi("Invalid value")}async#t(e,r={}){let n=[];if(await this.localStore.has(e,r))if(At("record is present in the cache"),r.nocache!==!0)try{let{record:a,created:c}=await this.localStore.get(e,r);this.log("record retrieved from cache"),await si(e,a),this.log("record was valid");let l=ot(a),u=Number((l.ttl??of)/1000000n);if(c.getTime()+u>Date.now())return this.log("record TTL was valid"),l;if(r.offline===!0)return this.log("record TTL has been reached but we are resolving offline-only, returning record"),l;this.log("record TTL has been reached, searching routing for updates"),n.push(a)}catch(a){this.log("cached record was invalid",a),await this.localStore.delete(e,r)}else At("ignoring local cache due to nocache=true option");if(r.offline===!0)throw new Dr("Record was not present in the cache or has expired");At("did not have record locally");let i=0;if(await Promise.all(this.routers.map(async a=>{let c;try{c=await a.get(e,{...r,validate:!1})}catch(l){At.error("error finding IPNS record",l);return}try{await si(e,c),n.push(c)}catch(l){i++,At.error("error finding IPNS record",l)}})),n.length===0)throw i>0?new fi(`${i>1?`${i} records`:"Record"} found for routing key ${i>1?"were":"was"} invalid`):new Dr("Could not find record for routing key");let s=n[oi(e,n)];return await this.localStore.put(e,s,r),ot(s)}};function Rp(t,{routers:e=[]}={}){return new Qs(t,e)}return bf(_p);})();
|
|
7
|
+
`)}`:`${r} :`}};kc=$t;L.Constructed=kc;$t.NAME="CONSTRUCTED";var Xn=class extends be{fromBER(e,r,n){return r}toBER(e){return Ge}};Xn.override="EndOfContentValueBlock";var Cc,Qn=class extends de{constructor(e={}){super(e,Xn),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};Cc=Qn;L.EndOfContent=Cc;Qn.NAME=Jr;var Tc,Er=class extends de{constructor(e={}){super(e,be),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,r,n){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=n,r+n>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):r+n}toBER(e,r){let n=new ArrayBuffer(2);if(!e){let o=new Uint8Array(n);o[0]=5,o[1]=0}return r&&r.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}};Tc=Er;L.Null=Tc;Er.NAME="NULL";var eo=class extends xt(be){constructor({value:e,...r}={}){super(r),r.valueHex?this.valueHexView=G.BufferSourceConverter.toUint8Array(r.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}get value(){for(let e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}fromBER(e,r,n){let o=G.BufferSourceConverter.toUint8Array(e);return yt(this,o,r,n)?(this.valueHexView=o.subarray(r,r+n),n>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,Ss.call(this),this.blockLength=n,r+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};eo.NAME="BooleanValueBlock";var Ic,to=class extends de{constructor(e={}){super(e,eo),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};Ic=to;L.Boolean=Ic;to.NAME="BOOLEAN";var ro=class extends xt(et){constructor({isConstructed:e=!1,...r}={}){super(r),this.isConstructed=e}fromBER(e,r,n){let o=0;if(this.isConstructed){if(this.isHexOnly=!1,o=et.prototype.fromBER.call(this,e,r,n),o===-1)return o;for(let i=0;i<this.value.length;i++){let s=this.value[i].constructor.NAME;if(s===Jr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(s!==Ec)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,o=super.fromBER(e,r,n),this.blockLength=n;return o}toBER(e,r){return this.isConstructed?et.prototype.toBER.call(this,e,r):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};ro.NAME="OctetStringValueBlock";var Nc,no=class t extends de{constructor({idBlock:e={},lenBlock:r={},...n}={}){var o,i;(o=n.isConstructed)!==null&&o!==void 0||(n.isConstructed=!!(!((i=n.value)===null||i===void 0)&&i.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...r,isIndefiniteForm:!!n.isIndefiniteForm},...n},ro),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,r,n){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,n===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),r;if(!this.valueBlock.isConstructed){let i=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(r,r+n);try{if(i.byteLength){let s=Ro(i,0,i.byteLength);s.offset!==-1&&s.offset===n&&(this.valueBlock.value=[s.result])}}catch{}}return super.fromBER(e,r,n)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?$t.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${G.Convert.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;let e=[];for(let r of this.valueBlock.value)r instanceof t&&e.push(r.valueBlock.valueHexView);return G.BufferSourceConverter.concat(e)}};Nc=no;L.OctetString=Nc;no.NAME=Ec;var oo=class extends xt(et){constructor({unusedBits:e=0,isConstructed:r=!1,...n}={}){super(n),this.unusedBits=e,this.isConstructed=r,this.blockLength=this.valueHexView.byteLength}fromBER(e,r,n){if(!n)return r;let o=-1;if(this.isConstructed){if(o=et.prototype.fromBER.call(this,e,r,n),o===-1)return o;for(let a of this.value){let c=a.constructor.NAME;if(c===Jr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==Bc)return this.error="BIT STRING may consists of BIT STRINGs only",-1;let l=a.valueBlock;if(this.unusedBits>0&&l.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=l.unusedBits}return o}let i=G.BufferSourceConverter.toUint8Array(e);if(!yt(this,i,r,n))return-1;let s=i.subarray(r,r+n);if(this.unusedBits=s[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){let a=s.subarray(1);try{if(a.byteLength){let c=Ro(a,0,a.byteLength);c.offset!==-1&&c.offset===n-1&&(this.value=[c.result])}}catch{}}return this.valueHexView=s.subarray(1),this.blockLength=s.length,r+n}toBER(e,r){if(this.isConstructed)return et.prototype.toBER.call(this,e,r);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return Ge;let n=new Uint8Array(this.valueHexView.length+1);return n[0]=this.unusedBits,n.set(this.valueHexView,1),n.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}};oo.NAME="BitStringValueBlock";var Uc,Br=class extends de{constructor({idBlock:e={},lenBlock:r={},...n}={}){var o,i;(o=n.isConstructed)!==null&&o!==void 0||(n.isConstructed=!!(!((i=n.value)===null||i===void 0)&&i.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...r,isIndefiniteForm:!!n.isIndefiniteForm},...n},oo),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,r,n){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,r,n)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return $t.prototype.onAsciiEncoding.call(this);{let e=[],r=this.valueBlock.valueHexView;for(let o of r)e.push(o.toString(2).padStart(8,"0"));let n=e.join("");return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}};Uc=Br;L.BitString=Uc;Br.NAME=Bc;var Rc;function f0(t,e){let r=new Uint8Array([0]),n=new Uint8Array(t),o=new Uint8Array(e),i=n.slice(0),s=i.length-1,a=o.slice(0),c=a.length-1,l=0,u=c<s?s:c,f=0;for(let h=u;h>=0;h--,f++){switch(!0){case f<a.length:l=i[s-f]+a[c-f]+r[0];break;default:l=i[s-f]+r[0]}switch(r[0]=l/10,!0){case f>=i.length:i=zn(new Uint8Array([l%10]),i);break;default:i[s-f]=l%10}}return r[0]>0&&(i=zn(r,i)),i}function vc(t){if(t>=jr.length)for(let e=jr.length;e<=t;e++){let r=new Uint8Array([0]),n=jr[e-1].slice(0);for(let o=n.length-1;o>=0;o--){let i=new Uint8Array([(n[o]<<1)+r[0]]);r[0]=i[0]/10,n[o]=i[0]%10}r[0]>0&&(n=zn(r,n)),jr.push(n)}return jr[t]}function h0(t,e){let r=0,n=new Uint8Array(t),o=new Uint8Array(e),i=n.slice(0),s=i.length-1,a=o.slice(0),c=a.length-1,l,u=0;for(let f=c;f>=0;f--,u++)switch(l=i[s-u]-a[c-u]-r,!0){case l<0:r=1,i[s-u]=l+10;break;default:r=0,i[s-u]=l}if(r>0)for(let f=s-c+1;f>=0;f--,u++)if(l=i[s-u]-r,l<0)r=1,i[s-u]=l+10;else{r=0,i[s-u]=l;break}return i.slice()}var Xr=class extends xt(be){constructor({value:e,...r}={}){super(r),this._valueDec=0,r.valueHex&&this.setValueHex(),e!==void 0&&(this.valueDec=e)}setValueHex(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=Ss.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(xc(e))}get valueDec(){return this._valueDec}fromDER(e,r,n,o=0){let i=this.fromBER(e,r,n);if(i===-1)return i;let s=this.valueHexView;return s[0]===0&&s[1]&128?this.valueHexView=s.subarray(1):o!==0&&s.length<o&&(o-s.length>1&&(o=s.length+1),this.valueHexView=s.subarray(o-s.length)),i}toDER(e=!1){let r=this.valueHexView;switch(!0){case(r[0]&128)!==0:{let n=new Uint8Array(this.valueHexView.length+1);n[0]=0,n.set(r,1),this.valueHexView=n}break;case(r[0]===0&&(r[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,r,n){let o=super.fromBER(e,r,n);return o===-1||this.setValueHex(),o}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){let e=this.valueHexView.length*8-1,r=new Uint8Array(this.valueHexView.length*8/3),n=0,o,i=this.valueHexView,s="",a=!1;for(let c=i.byteLength-1;c>=0;c--){o=i[c];for(let l=0;l<8;l++){if((o&1)===1)switch(n){case e:r=h0(vc(n),r),s="-";break;default:r=f0(r,vc(n))}n++,o>>=1}}for(let c=0;c<r.length;c++)r[c]&&(a=!0),a&&(s+=bc.charAt(r[c]));return a===!1&&(s+=bc.charAt(0)),s}};Rc=Xr;Xr.NAME="IntegerValueBlock";Object.defineProperty(Rc.prototype,"valueHex",{set:function(t){this.valueHexView=new Uint8Array(t),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var _c,pe=class t extends de{constructor(e={}){super(e,Xr),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return Gn(),BigInt(this.valueBlock.toString())}static fromBigInt(e){Gn();let r=BigInt(e),n=new Yr,o=r.toString(16).replace(/^-/,""),i=new Uint8Array(G.Convert.FromHex(o));if(r<0){let a=new Uint8Array(i.length+(i[0]&128?1:0));a[0]|=128;let l=BigInt(`0x${G.Convert.ToHex(a)}`)+r,u=G.BufferSourceConverter.toUint8Array(G.Convert.FromHex(l.toString(16)));u[0]|=128,n.write(u)}else i[0]&128&&n.write(new Uint8Array([0])),n.write(i);return new t({valueHex:n.final()})}convertToDER(){let e=new t({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new t({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}};_c=pe;L.Integer=_c;pe.NAME="INTEGER";var Lc,io=class extends pe{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};Lc=io;L.Enumerated=Lc;io.NAME="ENUMERATED";var Qr=class extends xt(be){constructor({valueDec:e=-1,isFirstSid:r=!1,...n}={}){super(n),this.valueDec=e,this.isFirstSid=r}fromBER(e,r,n){if(!n)return r;let o=G.BufferSourceConverter.toUint8Array(e);if(!yt(this,o,r,n))return-1;let i=o.subarray(r,r+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=i[a]&127,this.blockLength++,!!(i[a]&128));a++);let s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength;a++)s[a]=this.valueHexView[a];return this.valueHexView=s,i[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=tr(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),r+this.blockLength)}set valueBigInt(e){Gn();let r=BigInt(e).toString(2);for(;r.length%7;)r="0"+r;let n=new Uint8Array(r.length/7);for(let o=0;o<n.length;o++)n[o]=parseInt(r.slice(o*7,o*7+7),2)+(o+1<n.length?128:0);this.fromBER(n.buffer,0,n.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);let o=this.valueHexView,i=new Uint8Array(this.blockLength);for(let s=0;s<this.blockLength-1;s++)i[s]=o[s]|128;return i[this.blockLength-1]=o[this.blockLength-1],i.buffer}let r=Kt(this.valueDec,7);if(r.byteLength===0)return this.error="Error during encoding SID value",Ge;let n=new Uint8Array(r.byteLength);if(!e){let o=new Uint8Array(r),i=r.byteLength-1;for(let s=0;s<i;s++)n[s]=o[s]|128;n[i]=o[i]}return n}toString(){let e="";if(this.isHexOnly)e=G.Convert.ToHex(this.valueHexView);else if(this.isFirstSid){let r=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",r-=40):(e="2.",r-=80),e+=r.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}};Qr.NAME="sidBlock";var so=class extends be{constructor({value:e=Sr,...r}={}){super(r),this.value=[],e&&this.fromString(e)}fromBER(e,r,n){let o=r;for(;n>0;){let i=new Qr;if(o=i.fromBER(e,o,n),o===-1)return this.blockLength=0,this.error=i.error,o;this.value.length===0&&(i.isFirstSid=!0),this.blockLength+=i.blockLength,n-=i.blockLength,this.value.push(i)}return o}toBER(e){let r=[];for(let n=0;n<this.value.length;n++){let o=this.value[n].toBER(e);if(o.byteLength===0)return this.error=this.value[n].error,Ge;r.push(o)}return ks(r)}fromString(e){this.value=[];let r=0,n=0,o="",i=!1;do if(n=e.indexOf(".",r),n===-1?o=e.substring(r):o=e.substring(r,n),r=n+1,i){let s=this.value[0],a=0;switch(s.valueDec){case 0:break;case 1:a=40;break;case 2:a=80;break;default:this.value=[];return}let c=parseInt(o,10);if(isNaN(c))return;s.valueDec=c+a,i=!1}else{let s=new Qr;if(o>Number.MAX_SAFE_INTEGER){Gn();let a=BigInt(o);s.valueBigInt=a}else if(s.valueDec=parseInt(o,10),isNaN(s.valueDec))return;this.value.length||(s.isFirstSid=!0,i=!0),this.value.push(s)}while(n!==-1)}toString(){let e="",r=!1;for(let n=0;n<this.value.length;n++){r=this.value[n].isHexOnly;let o=this.value[n].toString();n!==0&&(e=`${e}.`),r?(o=`{${o}}`,this.value[n].isFirstSid?e=`2.{${o} - 80}`:e+=o):e+=o}return e}toJSON(){let e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let r=0;r<this.value.length;r++)e.sidArray.push(this.value[r].toJSON());return e}};so.NAME="ObjectIdentifierValueBlock";var Vc,Ar=class extends de{constructor(e={}){super(e,so),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};Vc=Ar;L.ObjectIdentifier=Vc;Ar.NAME="OBJECT IDENTIFIER";var en=class extends xt(pt){constructor({valueDec:e=0,...r}={}){super(r),this.valueDec=e}fromBER(e,r,n){if(n===0)return r;let o=G.BufferSourceConverter.toUint8Array(e);if(!yt(this,o,r,n))return-1;let i=o.subarray(r,r+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=i[a]&127,this.blockLength++,!!(i[a]&128));a++);let s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength;a++)s[a]=this.valueHexView[a];return this.valueHexView=s,i[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=tr(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),r+this.blockLength)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);let o=this.valueHexView,i=new Uint8Array(this.blockLength);for(let s=0;s<this.blockLength-1;s++)i[s]=o[s]|128;return i[this.blockLength-1]=o[this.blockLength-1],i.buffer}let r=Kt(this.valueDec,7);if(r.byteLength===0)return this.error="Error during encoding SID value",Ge;let n=new Uint8Array(r.byteLength);if(!e){let o=new Uint8Array(r),i=r.byteLength-1;for(let s=0;s<i;s++)n[s]=o[s]|128;n[i]=o[i]}return n.buffer}toString(){let e="";return this.isHexOnly?e=G.Convert.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}};en.NAME="relativeSidBlock";var ao=class extends be{constructor({value:e=Sr,...r}={}){super(r),this.value=[],e&&this.fromString(e)}fromBER(e,r,n){let o=r;for(;n>0;){let i=new en;if(o=i.fromBER(e,o,n),o===-1)return this.blockLength=0,this.error=i.error,o;this.blockLength+=i.blockLength,n-=i.blockLength,this.value.push(i)}return o}toBER(e,r){let n=[];for(let o=0;o<this.value.length;o++){let i=this.value[o].toBER(e);if(i.byteLength===0)return this.error=this.value[o].error,Ge;n.push(i)}return ks(n)}fromString(e){this.value=[];let r=0,n=0,o="";do{n=e.indexOf(".",r),n===-1?o=e.substring(r):o=e.substring(r,n),r=n+1;let i=new en;if(i.valueDec=parseInt(o,10),isNaN(i.valueDec))return!0;this.value.push(i)}while(n!==-1);return!0}toString(){let e="",r=!1;for(let n=0;n<this.value.length;n++){r=this.value[n].isHexOnly;let o=this.value[n].toString();n!==0&&(e=`${e}.`),r&&(o=`{${o}}`),e+=o}return e}toJSON(){let e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let r=0;r<this.value.length;r++)e.sidArray.push(this.value[r].toJSON());return e}};ao.NAME="RelativeObjectIdentifierValueBlock";var Dc,co=class extends de{constructor(e={}){super(e,ao),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};Dc=co;L.RelativeObjectIdentifier=Dc;co.NAME="RelativeObjectIdentifier";var Fc,gt=class extends $t{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};Fc=gt;L.Sequence=Fc;gt.NAME="SEQUENCE";var Mc,uo=class extends $t{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};Mc=uo;L.Set=Mc;uo.NAME="SET";var lo=class extends xt(be){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=Sr}toJSON(){return{...super.toJSON(),value:this.value}}};lo.NAME="StringValueBlock";var fo=class extends lo{};fo.NAME="SimpleStringValueBlock";var Ae=class extends jn{constructor({...e}={}){super(e,fo)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,G.BufferSourceConverter.toUint8Array(e))}fromString(e){let r=e.length,n=this.valueBlock.valueHexView=new Uint8Array(r);for(let o=0;o<r;o++)n[o]=e.charCodeAt(o);this.valueBlock.value=e}};Ae.NAME="SIMPLE STRING";var ho=class extends Ae{fromBuffer(e){this.valueBlock.valueHexView=G.BufferSourceConverter.toUint8Array(e);try{this.valueBlock.value=G.Convert.ToUtf8String(e)}catch(r){this.warnings.push(`Error during "decodeURIComponent": ${r}, using raw string`),this.valueBlock.value=G.Convert.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(G.Convert.FromUtf8String(e)),this.valueBlock.value=e}};ho.NAME="Utf8StringValueBlock";var Oc,mt=class extends ho{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};Oc=mt;L.Utf8String=Oc;mt.NAME="UTF8String";var po=class extends Ae{fromBuffer(e){this.valueBlock.value=G.Convert.ToUtf16String(e),this.valueBlock.valueHexView=G.BufferSourceConverter.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(G.Convert.FromUtf16String(e))}};po.NAME="BmpStringValueBlock";var Hc,go=class extends po{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};Hc=go;L.BmpString=Hc;go.NAME="BMPString";var mo=class extends Ae{fromBuffer(e){let r=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),n=new Uint8Array(r);for(let o=0;o<n.length;o+=4)n[o]=n[o+3],n[o+1]=n[o+2],n[o+2]=0,n[o+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(r))}fromString(e){let r=e.length,n=this.valueBlock.valueHexView=new Uint8Array(r*4);for(let o=0;o<r;o++){let i=Kt(e.charCodeAt(o),8),s=new Uint8Array(i);if(s.length>4)continue;let a=4-s.length;for(let c=s.length-1;c>=0;c--)n[o*4+c+a]=s[c]}this.valueBlock.value=e}};mo.NAME="UniversalStringValueBlock";var Pc,yo=class extends mo{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};Pc=yo;L.UniversalString=Pc;yo.NAME="UniversalString";var Kc,xo=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};Kc=xo;L.NumericString=Kc;xo.NAME="NumericString";var $c,wo=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};$c=wo;L.PrintableString=$c;wo.NAME="PrintableString";var qc,bo=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};qc=bo;L.TeletexString=qc;bo.NAME="TeletexString";var zc,vo=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};zc=vo;L.VideotexString=zc;vo.NAME="VideotexString";var Gc,Eo=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};Gc=Eo;L.IA5String=Gc;Eo.NAME="IA5String";var Zc,Bo=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};Zc=Bo;L.GraphicString=Zc;Bo.NAME="GraphicString";var Wc,tn=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};Wc=tn;L.VisibleString=Wc;tn.NAME="VisibleString";var jc,Ao=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};jc=Ao;L.GeneralString=jc;Ao.NAME="GeneralString";var Yc,So=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};Yc=So;L.CharacterString=Yc;So.NAME="CharacterString";var Jc,rn=class extends tn{constructor({value:e,valueDate:r,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let o=0;o<e.length;o++)this.valueBlock.valueHexView[o]=e.charCodeAt(o)}r&&(this.fromDate(r),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,G.BufferSourceConverter.toUint8Array(e)))}toBuffer(){let e=this.toString(),r=new ArrayBuffer(e.length),n=new Uint8Array(r);for(let o=0;o<e.length;o++)n[o]=e.charCodeAt(o);return r}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){let n=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(e);if(n===null){this.error="Wrong input string for conversion";return}let o=parseInt(n[1],10);o>=50?this.year=1900+o:this.year=2e3+o,this.month=parseInt(n[2],10),this.day=parseInt(n[3],10),this.hour=parseInt(n[4],10),this.minute=parseInt(n[5],10),this.second=parseInt(n[6],10)}toString(e="iso"){if(e==="iso"){let r=new Array(7);return r[0]=Ue(this.year<2e3?this.year-1900:this.year-2e3,2),r[1]=Ue(this.month,2),r[2]=Ue(this.day,2),r[3]=Ue(this.hour,2),r[4]=Ue(this.minute,2),r[5]=Ue(this.second,2),r[6]="Z",r.join("")}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}};Jc=rn;L.UTCTime=Jc;rn.NAME="UTCTime";var Xc,ko=class extends rn{constructor(e={}){var r;super(e),(r=this.millisecond)!==null&&r!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(e){let r=!1,n="",o="",i=0,s,a=0,c=0;if(e[e.length-1]==="Z")n=e.substring(0,e.length-1),r=!0;else{let f=new Number(e[e.length-1]);if(isNaN(f.valueOf()))throw new Error("Wrong input string for conversion");n=e}if(r){if(n.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(n.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let f=1,h=n.indexOf("+"),v="";if(h===-1&&(h=n.indexOf("-"),f=-1),h!==-1){if(v=n.substring(h+1),n=n.substring(0,h),v.length!==2&&v.length!==4)throw new Error("Wrong input string for conversion");let E=parseInt(v.substring(0,2),10);if(isNaN(E.valueOf()))throw new Error("Wrong input string for conversion");if(a=f*E,v.length===4){if(E=parseInt(v.substring(2,4),10),isNaN(E.valueOf()))throw new Error("Wrong input string for conversion");c=f*E}}}let l=n.indexOf(".");if(l===-1&&(l=n.indexOf(",")),l!==-1){let f=new Number(`0${n.substring(l)}`);if(isNaN(f.valueOf()))throw new Error("Wrong input string for conversion");i=f.valueOf(),o=n.substring(0,l)}else o=n;switch(!0){case o.length===8:if(s=/(\d{4})(\d{2})(\d{2})/ig,l!==-1)throw new Error("Wrong input string for conversion");break;case o.length===10:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,l!==-1){let f=60*i;this.minute=Math.floor(f),f=60*(f-this.minute),this.second=Math.floor(f),f=1e3*(f-this.second),this.millisecond=Math.floor(f)}break;case o.length===12:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,l!==-1){let f=60*i;this.second=Math.floor(f),f=1e3*(f-this.second),this.millisecond=Math.floor(f)}break;case o.length===14:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,l!==-1){let f=1e3*i;this.millisecond=Math.floor(f)}break;default:throw new Error("Wrong input string for conversion")}let u=s.exec(o);if(u===null)throw new Error("Wrong input string for conversion");for(let f=1;f<u.length;f++)switch(f){case 1:this.year=parseInt(u[f],10);break;case 2:this.month=parseInt(u[f],10);break;case 3:this.day=parseInt(u[f],10);break;case 4:this.hour=parseInt(u[f],10)+a;break;case 5:this.minute=parseInt(u[f],10)+c;break;case 6:this.second=parseInt(u[f],10);break;default:throw new Error("Wrong input string for conversion")}if(r===!1){let f=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=f.getUTCFullYear(),this.month=f.getUTCMonth(),this.day=f.getUTCDay(),this.hour=f.getUTCHours(),this.minute=f.getUTCMinutes(),this.second=f.getUTCSeconds(),this.millisecond=f.getUTCMilliseconds()}}toString(e="iso"){if(e==="iso"){let r=[];return r.push(Ue(this.year,4)),r.push(Ue(this.month,2)),r.push(Ue(this.day,2)),r.push(Ue(this.hour,2)),r.push(Ue(this.minute,2)),r.push(Ue(this.second,2)),this.millisecond!==0&&(r.push("."),r.push(Ue(this.millisecond,3))),r.push("Z"),r.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};Xc=ko;L.GeneralizedTime=Xc;ko.NAME="GeneralizedTime";var Qc,Co=class extends mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};Qc=Co;L.DATE=Qc;Co.NAME="DATE";var eu,To=class extends mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};eu=To;L.TimeOfDay=eu;To.NAME="TimeOfDay";var tu,Io=class extends mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};tu=Io;L.DateTime=tu;Io.NAME="DateTime";var ru,No=class extends mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};ru=No;L.Duration=ru;No.NAME="Duration";var nu,Uo=class extends mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};nu=Uo;L.TIME=nu;Uo.NAME="TIME";function Se(t,e="utf8"){let r=Hn[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return r.encoder.encode(t).substring(1)}var nn=class extends Error{constructor(e="An error occurred while verifying a message"){super(e),this.name="VerificationError"}},_o=class extends Error{constructor(e="Missing Web Crypto API"){super(e),this.name="WebCryptoMissingError"}};var ou={get(t=globalThis){let e=t.crypto;if(e?.subtle==null)throw new _o("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api");return e}};var qt=ou;async function iu(t){let e=await qt.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:t,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),r=await p0(e);return{privateKey:r[0],publicKey:r[1]}}async function su(t,e){let r=await qt.get().subtle.importKey("jwk",t,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await qt.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},r,e instanceof Uint8Array?e:e.subarray());return new Uint8Array(n,0,n.byteLength)}async function au(t,e,r){let n=await qt.get().subtle.importKey("jwk",t,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return qt.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,e,r instanceof Uint8Array?r:r.subarray())}async function p0(t){if(t.privateKey==null||t.publicKey==null)throw new xe("Private and public key are required");return Promise.all([qt.get().subtle.exportKey("jwk",t.privateKey),qt.get().subtle.exportKey("jwk",t.publicKey)])}function Is(t){if(t.kty!=="RSA")throw new xe("invalid key type");if(t.n==null)throw new xe("invalid key modulus");return Y(t.n,"base64url").length*8}var kr=class{type="RSA";_key;_raw;_multihash;constructor(e,r){this._key=e,this._multihash=r}get raw(){return this._raw==null&&(this._raw=on.jwkToPkix(this._key)),this._raw}toMultihash(){return this._multihash}toCID(){return ee.createV1(114,this._multihash)}toString(){return Q.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:he(this.raw,e.raw)}verify(e,r){return au(this._key,r,e)}},sn=class{type="RSA";_key;_raw;publicKey;constructor(e,r){this._key=e,this.publicKey=r}get raw(){return this._raw==null&&(this._raw=on.jwkToPkcs1(this._key)),this._raw}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:he(this.raw,e.raw)}sign(e){return su(this._key,e)}};var Lo=8192,Ns=18;function cu(t){let{result:e}=Ts(t),r=e.valueBlock.value;return{n:tt(r[1]),e:tt(r[2]),d:tt(r[3]),p:tt(r[4]),q:tt(r[5]),dp:tt(r[6]),dq:tt(r[7]),qi:tt(r[8]),kty:"RSA",alg:"RS256"}}function g0(t){if(t.n==null||t.e==null||t.d==null||t.p==null||t.q==null||t.dp==null||t.dq==null||t.qi==null)throw new xe("JWK was missing components");let r=new gt({value:[new pe({value:0}),pe.fromBigInt(rt(Y(t.n,"base64url"))),pe.fromBigInt(rt(Y(t.e,"base64url"))),pe.fromBigInt(rt(Y(t.d,"base64url"))),pe.fromBigInt(rt(Y(t.p,"base64url"))),pe.fromBigInt(rt(Y(t.q,"base64url"))),pe.fromBigInt(rt(Y(t.dp,"base64url"))),pe.fromBigInt(rt(Y(t.dq,"base64url"))),pe.fromBigInt(rt(Y(t.qi,"base64url")))]}).toBER();return new Uint8Array(r,0,r.byteLength)}function uu(t){let{result:e}=Ts(t),r=e.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:tt(r[0]),e:tt(r[1])}}function Us(t){if(t.n==null||t.e==null)throw new xe("JWK was missing components");let r=new gt({value:[new gt({value:[new Ar({value:"1.2.840.113549.1.1.1"}),new Er]}),new Br({valueHex:new gt({value:[pe.fromBigInt(rt(Y(t.n,"base64url"))),pe.fromBigInt(rt(Y(t.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(r,0,r.byteLength)}function tt(t){let e=t.valueBlock.valueHexView;for(;e[0]===0;)e=e.subarray(1);return Se(e,"base64url")}function rt(t){let e=[];return t.forEach(function(r){let n=r.toString(16);n.length%2>0&&(n=`0${n}`),e.push(n)}),BigInt("0x"+e.join(""))}function lu(t){let e=cu(t);return fu(e)}function Rs(t){let e=uu(t);if(Is(e)>Lo)throw new sr("Key size is too large");let r=br(Qe.encode({Type:se.RSA,Data:t})),n=Pe(Ns,r);return new kr(e,n)}function fu(t){if(Is(t)>Lo)throw new xe("Key size is too large");let e=du(t),r=br(Qe.encode({Type:se.RSA,Data:Us(e.publicKey)})),n=Pe(Ns,r);return new sn(e.privateKey,new kr(e.publicKey,n))}async function hu(t){if(t>Lo)throw new xe("Key size is too large");let e=await iu(t),r=br(Qe.encode({Type:se.RSA,Data:Us(e.publicKey)})),n=Pe(Ns,r);return new sn(e.privateKey,new kr(e.publicKey,n))}function du(t){if(t==null)throw new xe("Missing key parameter");return{privateKey:t,publicKey:{kty:t.kty,n:t.n,e:t.e}}}var Vo=class extends gr{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,Ta(e);let n=Hr(r);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,i=new Uint8Array(o);i.set(n.length>o?e.create().update(n).digest():n);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=e.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),i.fill(0)}update(e){return pr(this),this.iHash.update(e),this}digestInto(e){pr(this),dr(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:a}=this;return e=e,e.finished=o,e.destroyed=i,e.blockLen=s,e.outputLen=a,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},_s=(t,e,r)=>new Vo(t,e).update(r).digest();_s.create=(t,e)=>new Vo(t,e);function pu(t){t.lowS!==void 0&&$e("lowS",t.lowS),t.prehash!==void 0&&$e("prehash",t.prehash)}function m0(t){let e=$r(t);Je(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:r,Fp:n,a:o}=e;if(r){if(!n.eql(o,n.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:y0,hexToBytes:x0}=Un,Ls=class extends Error{constructor(e=""){super(e)}},wt={Err:Ls,_tlv:{encode:(t,e)=>{let{Err:r}=wt;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length&1)throw new r("tlv.encode: unpadded data");let n=e.length/2,o=Wt(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?Wt(o.length/2|128):"";return Wt(t)+i+o+e},decode(t,e){let{Err:r}=wt,n=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length<2||e[n++]!==t)throw new r("tlv.decode: wrong tlv");let o=e[n++],i=!!(o&128),s=0;if(!i)s=o;else{let c=o&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let l=e.subarray(n,n+c);if(l.length!==c)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let u of l)s=s<<8|u;if(n+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=e.subarray(n,n+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+s)}}},_int:{encode(t){let{Err:e}=wt;if(t<bt)throw new e("integer: negative integers are not allowed");let r=Wt(t);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return r},decode(t){let{Err:e}=wt;if(t[0]&128)throw new e("invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return y0(t)}},toSig(t){let{Err:e,_int:r,_tlv:n}=wt,o=typeof t=="string"?x0(t):t;yr(o);let{v:i,l:s}=n.decode(48,o);if(s.length)throw new e("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,i),{v:l,l:u}=n.decode(2,c);if(u.length)throw new e("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(l)}},hexFromSig(t){let{_tlv:e,_int:r}=wt,n=e.encode(2,r.encode(t.r)),o=e.encode(2,r.encode(t.s)),i=n+o;return e.encode(48,i)}},bt=BigInt(0),ue=BigInt(1),Qy=BigInt(2),gu=BigInt(3),ex=BigInt(4);function w0(t){let e=m0(t),{Fp:r}=e,n=Lt(e.n,e.nBitLength),o=e.toBytes||((y,d,A)=>{let T=d.toAffine();return ht(Uint8Array.from([4]),r.toBytes(T.x),r.toBytes(T.y))}),i=e.fromBytes||(y=>{let d=y.subarray(1),A=r.fromBytes(d.subarray(0,r.BYTES)),T=r.fromBytes(d.subarray(r.BYTES,2*r.BYTES));return{x:A,y:T}});function s(y){let{a:d,b:A}=e,T=r.sqr(y),x=r.mul(T,y);return r.add(r.add(x,r.mul(y,d)),A)}if(!r.eql(r.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function a(y){return Pr(y,ue,e.n)}function c(y){let{allowedPrivateKeyLengths:d,nByteLength:A,wrapPrivateKey:T,n:x}=e;if(d&&typeof y!="bigint"){if(Ut(y)&&(y=lt(y)),typeof y!="string"||!d.includes(y.length))throw new Error("invalid private key");y=y.padStart(A*2,"0")}let U;try{U=typeof y=="bigint"?y:ft(ne("private key",y,A))}catch{throw new Error("invalid private key, expected hex or "+A+" bytes, got "+typeof y)}return T&&(U=J(U,x)),Ie("private key",U,ue,x),U}function l(y){if(!(y instanceof h))throw new Error("ProjectivePoint expected")}let u=Jt((y,d)=>{let{px:A,py:T,pz:x}=y;if(r.eql(x,r.ONE))return{x:A,y:T};let U=y.is0();d==null&&(d=U?r.ONE:r.inv(x));let F=r.mul(A,d),D=r.mul(T,d),R=r.mul(x,d);if(U)return{x:r.ZERO,y:r.ZERO};if(!r.eql(R,r.ONE))throw new Error("invZ was invalid");return{x:F,y:D}}),f=Jt(y=>{if(y.is0()){if(e.allowInfinityPoint&&!r.is0(y.py))return;throw new Error("bad point: ZERO")}let{x:d,y:A}=y.toAffine();if(!r.isValid(d)||!r.isValid(A))throw new Error("bad point: x or y not FE");let T=r.sqr(A),x=s(d);if(!r.eql(T,x))throw new Error("bad point: equation left != right");if(!y.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class h{constructor(d,A,T){if(this.px=d,this.py=A,this.pz=T,d==null||!r.isValid(d))throw new Error("x required");if(A==null||!r.isValid(A))throw new Error("y required");if(T==null||!r.isValid(T))throw new Error("z required");Object.freeze(this)}static fromAffine(d){let{x:A,y:T}=d||{};if(!d||!r.isValid(A)||!r.isValid(T))throw new Error("invalid affine point");if(d instanceof h)throw new Error("projective point not allowed");let x=U=>r.eql(U,r.ZERO);return x(A)&&x(T)?h.ZERO:new h(A,T,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){let A=r.invertBatch(d.map(T=>T.pz));return d.map((T,x)=>T.toAffine(A[x])).map(h.fromAffine)}static fromHex(d){let A=h.fromAffine(i(ne("pointHex",d)));return A.assertValidity(),A}static fromPrivateKey(d){return h.BASE.multiply(c(d))}static msm(d,A){return Vn(h,n,d,A)}_setWindowSize(d){E.setWindowSize(this,d)}assertValidity(){f(this)}hasEvenY(){let{y:d}=this.toAffine();if(r.isOdd)return!r.isOdd(d);throw new Error("Field doesn't support isOdd")}equals(d){l(d);let{px:A,py:T,pz:x}=this,{px:U,py:F,pz:D}=d,R=r.eql(r.mul(A,D),r.mul(U,x)),w=r.eql(r.mul(T,D),r.mul(F,x));return R&&w}negate(){return new h(this.px,r.neg(this.py),this.pz)}double(){let{a:d,b:A}=e,T=r.mul(A,gu),{px:x,py:U,pz:F}=this,D=r.ZERO,R=r.ZERO,w=r.ZERO,b=r.mul(x,x),M=r.mul(U,U),_=r.mul(F,F),I=r.mul(x,U);return I=r.add(I,I),w=r.mul(x,F),w=r.add(w,w),D=r.mul(d,w),R=r.mul(T,_),R=r.add(D,R),D=r.sub(M,R),R=r.add(M,R),R=r.mul(D,R),D=r.mul(I,D),w=r.mul(T,w),_=r.mul(d,_),I=r.sub(b,_),I=r.mul(d,I),I=r.add(I,w),w=r.add(b,b),b=r.add(w,b),b=r.add(b,_),b=r.mul(b,I),R=r.add(R,b),_=r.mul(U,F),_=r.add(_,_),b=r.mul(_,I),D=r.sub(D,b),w=r.mul(_,M),w=r.add(w,w),w=r.add(w,w),new h(D,R,w)}add(d){l(d);let{px:A,py:T,pz:x}=this,{px:U,py:F,pz:D}=d,R=r.ZERO,w=r.ZERO,b=r.ZERO,M=e.a,_=r.mul(e.b,gu),I=r.mul(A,U),K=r.mul(T,F),S=r.mul(x,D),k=r.add(A,T),m=r.add(U,F);k=r.mul(k,m),m=r.add(I,K),k=r.sub(k,m),m=r.add(A,x);let p=r.add(U,D);return m=r.mul(m,p),p=r.add(I,S),m=r.sub(m,p),p=r.add(T,x),R=r.add(F,D),p=r.mul(p,R),R=r.add(K,S),p=r.sub(p,R),b=r.mul(M,m),R=r.mul(_,S),b=r.add(R,b),R=r.sub(K,b),b=r.add(K,b),w=r.mul(R,b),K=r.add(I,I),K=r.add(K,I),S=r.mul(M,S),m=r.mul(_,m),K=r.add(K,S),S=r.sub(I,S),S=r.mul(M,S),m=r.add(m,S),I=r.mul(K,m),w=r.add(w,I),I=r.mul(p,m),R=r.mul(k,R),R=r.sub(R,I),I=r.mul(k,K),b=r.mul(p,b),b=r.add(b,I),new h(R,w,b)}subtract(d){return this.add(d.negate())}is0(){return this.equals(h.ZERO)}wNAF(d){return E.wNAFCached(this,d,h.normalizeZ)}multiplyUnsafe(d){let{endo:A,n:T}=e;Ie("scalar",d,bt,T);let x=h.ZERO;if(d===bt)return x;if(this.is0()||d===ue)return this;if(!A||E.hasPrecomputes(this))return E.wNAFCachedUnsafe(this,d,h.normalizeZ);let{k1neg:U,k1:F,k2neg:D,k2:R}=A.splitScalar(d),w=x,b=x,M=this;for(;F>bt||R>bt;)F&ue&&(w=w.add(M)),R&ue&&(b=b.add(M)),M=M.double(),F>>=ue,R>>=ue;return U&&(w=w.negate()),D&&(b=b.negate()),b=new h(r.mul(b.px,A.beta),b.py,b.pz),w.add(b)}multiply(d){let{endo:A,n:T}=e;Ie("scalar",d,ue,T);let x,U;if(A){let{k1neg:F,k1:D,k2neg:R,k2:w}=A.splitScalar(d),{p:b,f:M}=this.wNAF(D),{p:_,f:I}=this.wNAF(w);b=E.constTimeNegate(F,b),_=E.constTimeNegate(R,_),_=new h(r.mul(_.px,A.beta),_.py,_.pz),x=b.add(_),U=M.add(I)}else{let{p:F,f:D}=this.wNAF(d);x=F,U=D}return h.normalizeZ([x,U])[0]}multiplyAndAddUnsafe(d,A,T){let x=h.BASE,U=(D,R)=>R===bt||R===ue||!D.equals(x)?D.multiplyUnsafe(R):D.multiply(R),F=U(this,A).add(U(d,T));return F.is0()?void 0:F}toAffine(d){return u(this,d)}isTorsionFree(){let{h:d,isTorsionFree:A}=e;if(d===ue)return!0;if(A)return A(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:d,clearCofactor:A}=e;return d===ue?this:A?A(h,this):this.multiplyUnsafe(e.h)}toRawBytes(d=!0){return $e("isCompressed",d),this.assertValidity(),o(h,this,d)}toHex(d=!0){return $e("isCompressed",d),lt(this.toRawBytes(d))}}h.BASE=new h(e.Gx,e.Gy,r.ONE),h.ZERO=new h(r.ZERO,r.ONE,r.ZERO);let v=e.nBitLength,E=Ln(h,e.endo?Math.ceil(v/2):v);return{CURVE:e,ProjectivePoint:h,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:a}}function b0(t){let e=$r(t);return Je(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function mu(t){let e=b0(t),{Fp:r,n}=e,o=r.BYTES+1,i=2*r.BYTES+1;function s(S){return J(S,n)}function a(S){return Rn(S,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:l,weierstrassEquation:u,isWithinCurveOrder:f}=w0({...e,toBytes(S,k,m){let p=k.toAffine(),B=r.toBytes(p.x),N=ht;return $e("isCompressed",m),m?N(Uint8Array.from([k.hasEvenY()?2:3]),B):N(Uint8Array.from([4]),B,r.toBytes(p.y))},fromBytes(S){let k=S.length,m=S[0],p=S.subarray(1);if(k===o&&(m===2||m===3)){let B=ft(p);if(!Pr(B,ue,r.ORDER))throw new Error("Point is not on curve");let N=u(B),O;try{O=r.sqrt(N)}catch(Z){let $=Z instanceof Error?": "+Z.message:"";throw new Error("Point is not on curve"+$)}let H=(O&ue)===ue;return(m&1)===1!==H&&(O=r.neg(O)),{x:B,y:O}}else if(k===i&&m===4){let B=r.fromBytes(p.subarray(0,r.BYTES)),N=r.fromBytes(p.subarray(r.BYTES,2*r.BYTES));return{x:B,y:N}}else{let B=o,N=i;throw new Error("invalid Point, expected length of "+B+", or uncompressed "+N+", got "+k)}}}),h=S=>lt(_t(S,e.nByteLength));function v(S){let k=n>>ue;return S>k}function E(S){return v(S)?s(-S):S}let y=(S,k,m)=>ft(S.slice(k,m));class d{constructor(k,m,p){this.r=k,this.s=m,this.recovery=p,this.assertValidity()}static fromCompact(k){let m=e.nByteLength;return k=ne("compactSignature",k,m*2),new d(y(k,0,m),y(k,m,2*m))}static fromDER(k){let{r:m,s:p}=wt.toSig(ne("DER",k));return new d(m,p)}assertValidity(){Ie("r",this.r,ue,n),Ie("s",this.s,ue,n)}addRecoveryBit(k){return new d(this.r,this.s,k)}recoverPublicKey(k){let{r:m,s:p,recovery:B}=this,N=D(ne("msgHash",k));if(B==null||![0,1,2,3].includes(B))throw new Error("recovery id invalid");let O=B===2||B===3?m+e.n:m;if(O>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let H=B&1?"03":"02",z=c.fromHex(H+h(O)),Z=a(O),$=s(-N*Z),j=s(p*Z),X=c.BASE.multiplyAndAddUnsafe(z,$,j);if(!X)throw new Error("point at infinify");return X.assertValidity(),X}hasHighS(){return v(this.s)}normalizeS(){return this.hasHighS()?new d(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return jt(this.toDERHex())}toDERHex(){return wt.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return jt(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}let A={isValidPrivateKey(S){try{return l(S),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{let S=qi(e.n);return Pa(e.randomBytes(S),e.n)},precompute(S=8,k=c.BASE){return k._setWindowSize(S),k.multiply(BigInt(3)),k}};function T(S,k=!0){return c.fromPrivateKey(S).toRawBytes(k)}function x(S){let k=Ut(S),m=typeof S=="string",p=(k||m)&&S.length;return k?p===o||p===i:m?p===2*o||p===2*i:S instanceof c}function U(S,k,m=!0){if(x(S))throw new Error("first arg must be private key");if(!x(k))throw new Error("second arg must be public key");return c.fromHex(k).multiply(l(S)).toRawBytes(m)}let F=e.bits2int||function(S){if(S.length>8192)throw new Error("input is too large");let k=ft(S),m=S.length*8-e.nBitLength;return m>0?k>>BigInt(m):k},D=e.bits2int_modN||function(S){return s(F(S))},R=Kr(e.nBitLength);function w(S){return Ie("num < 2^"+e.nBitLength,S,bt,R),_t(S,e.nByteLength)}function b(S,k,m=M){if(["recovered","canonical"].some(ce=>ce in m))throw new Error("sign() legacy options not supported");let{hash:p,randomBytes:B}=e,{lowS:N,prehash:O,extraEntropy:H}=m;N==null&&(N=!0),S=ne("msgHash",S),pu(m),O&&(S=ne("prehashed msgHash",p(S)));let z=D(S),Z=l(k),$=[w(Z),w(z)];if(H!=null&&H!==!1){let ce=H===!0?B(r.BYTES):H;$.push(ne("extraEntropy",ce))}let j=ht(...$),X=z;function ae(ce){let fe=F(ce);if(!f(fe))return;let ye=a(fe),Ce=c.BASE.multiply(fe).toAffine(),ve=s(Ce.x);if(ve===bt)return;let Ye=s(ye*s(X+ve*Z));if(Ye===bt)return;let it=(Ce.x===ve?0:2)|Number(Ce.y&ue),Lr=Ye;return N&&v(Ye)&&(Lr=E(Ye),it^=1),new d(ve,Lr,it)}return{seed:j,k2sig:ae}}let M={lowS:e.lowS,prehash:!1},_={lowS:e.lowS,prehash:!1};function I(S,k,m=M){let{seed:p,k2sig:B}=b(S,k,m),N=e;return Hi(N.hash.outputLen,N.nByteLength,N.hmac)(p,B)}c.BASE._setWindowSize(8);function K(S,k,m,p=_){let B=S;k=ne("msgHash",k),m=ne("publicKey",m);let{lowS:N,prehash:O,format:H}=p;if(pu(p),"strict"in p)throw new Error("options.strict was renamed to lowS");if(H!==void 0&&H!=="compact"&&H!=="der")throw new Error("format must be compact or der");let z=typeof B=="string"||Ut(B),Z=!z&&!H&&typeof B=="object"&&B!==null&&typeof B.r=="bigint"&&typeof B.s=="bigint";if(!z&&!Z)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let $,j;try{if(Z&&($=new d(B.r,B.s)),z){try{H!=="compact"&&($=d.fromDER(B))}catch(it){if(!(it instanceof wt.Err))throw it}!$&&H!=="der"&&($=d.fromCompact(B))}j=c.fromHex(m)}catch{return!1}if(!$||N&&$.hasHighS())return!1;O&&(k=e.hash(k));let{r:X,s:ae}=$,ce=D(k),fe=a(ae),ye=s(ce*fe),Ce=s(X*fe),ve=c.BASE.multiplyAndAddUnsafe(j,ye,Ce)?.toAffine();return ve?s(ve.x)===X:!1}return{CURVE:e,getPublicKey:T,getSharedSecret:U,sign:I,verify:K,ProjectivePoint:c,Signature:d,utils:A}}function v0(t){return{hash:t,hmac:(e,...r)=>_s(t,e,_i(...r)),randomBytes:Cn}}function yu(t,e){let r=n=>mu({...t,...v0(n)});return{...r(e),create:r}}var bu=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),xu=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),E0=BigInt(1),Vs=BigInt(2),wu=(t,e)=>(t+e/Vs)/e;function B0(t){let e=bu,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),l=t*t*t%e,u=l*l*t%e,f=re(u,r,e)*u%e,h=re(f,r,e)*u%e,v=re(h,Vs,e)*l%e,E=re(v,o,e)*v%e,y=re(E,i,e)*E%e,d=re(y,a,e)*y%e,A=re(d,c,e)*d%e,T=re(A,a,e)*y%e,x=re(T,r,e)*u%e,U=re(x,s,e)*E%e,F=re(U,n,e)*l%e,D=re(F,Vs,e);if(!Ds.eql(Ds.sqr(D),t))throw new Error("Cannot find square root");return D}var Ds=Lt(bu,void 0,void 0,{sqrt:B0}),rr=yu({a:BigInt(0),b:BigInt(7),Fp:Ds,n:xu,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{let e=xu,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-E0*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=r,s=BigInt("0x100000000000000000000000000000000"),a=wu(i*t,e),c=wu(-n*t,e),l=J(t-a*r-c*o,e),u=J(-a*n-c*i,e),f=l>s,h=u>s;if(f&&(l=e-l),h&&(u=e-u),l>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:f,k1:l,k2neg:h,k2:u}}}},br),ux=BigInt(0);var lx=rr.ProjectivePoint;function an(t,e){e==null&&(e=t.reduce((o,i)=>o+i.length,0));let r=Xe(e),n=0;for(let o of t)r.set(o,n),n+=o.length;return r}function vu(t){return t==null?!1:typeof t.then=="function"&&typeof t.catch=="function"&&typeof t.finally=="function"}function Eu(t,e,r){let n=zr.digest(r instanceof Uint8Array?r:r.subarray());if(vu(n))return n.then(({digest:o})=>rr.verify(e,o,t)).catch(o=>{throw new nn(String(o))});try{return rr.verify(e,n.digest,t)}catch(o){throw new nn(String(o))}}var Do=class{type="secp256k1";raw;_key;constructor(e){this._key=Au(e),this.raw=Bu(this._key)}toMultihash(){return ct.digest(xr(this))}toCID(){return ee.createV1(114,this.toMultihash())}toString(){return Q.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:he(this.raw,e.raw)}verify(e,r){return Eu(this._key,r,e)}};function Fs(t){return new Do(t)}function Bu(t){return rr.ProjectivePoint.fromHex(t).toRawBytes(!0)}function Au(t){try{return rr.ProjectivePoint.fromHex(t),t}catch(e){throw new sr(String(e))}}function Su(t){let{Type:e,Data:r}=Qe.decode(t),n=r??new Uint8Array;switch(e){case se.RSA:return Rs(n);case se.Ed25519:return Ji(n);case se.secp256k1:return Fs(n);default:throw new cr}}function Fo(t){let{Type:e,Data:r}=Qe.decode(t.digest),n=r??new Uint8Array;switch(e){case se.Ed25519:return Ji(n);case se.secp256k1:return Fs(n);default:throw new cr}}function xr(t){return Qe.encode({Type:se[t.type],Data:t.raw})}var vt="/",ku=new TextEncoder().encode(vt),Mo=ku[0],cn=class t{_buf;constructor(e,r){if(typeof e=="string")this._buf=Y(e);else if(e instanceof Uint8Array)this._buf=e;else throw new Error("Invalid key, should be String of Uint8Array");if(r==null&&(r=!0),r&&this.clean(),this._buf.byteLength===0||this._buf[0]!==Mo)throw new Error("Invalid key")}toString(e="utf8"){return Se(this._buf,e)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(e){return new t(e.join(vt))}static random(){return new t(Math.random().toString().substring(2))}static asKey(e){return e instanceof Uint8Array||typeof e=="string"?new t(e):typeof e.uint8Array=="function"?new t(e.uint8Array()):null}clean(){if((this._buf==null||this._buf.byteLength===0)&&(this._buf=ku),this._buf[0]!==Mo){let e=new Uint8Array(this._buf.byteLength+1);e.fill(Mo,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===Mo;)this._buf=this._buf.subarray(0,-1)}less(e){let r=this.list(),n=e.list();for(let o=0;o<r.length;o++){if(n.length<o+1)return!1;let i=r[o],s=n[o];if(i<s)return!0;if(i>s)return!1}return r.length<n.length}reverse(){return t.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){let e=this.namespaces();return e[e.length-1]}list(){return this.toString().split(vt).slice(1)}type(){return A0(this.baseNamespace())}name(){return S0(this.baseNamespace())}instance(e){return new t(this.toString()+":"+e)}path(){let e=this.parent().toString();return e.endsWith(vt)||(e+=vt),e+=this.type(),new t(e)}parent(){let e=this.list();return e.length===1?new t(vt):new t(e.slice(0,-1).join(vt))}child(e){return this.toString()===vt?e:e.toString()===vt?this:new t(this.toString()+e.toString(),!1)}isAncestorOf(e){return e.toString()===this.toString()?!1:e.toString().startsWith(this.toString())}isDecendantOf(e){return e.toString()===this.toString()?!1:this.toString().startsWith(e.toString())}isTopLevel(){return this.list().length===1}concat(...e){return t.withNamespaces([...this.namespaces(),...k0(e.map(r=>r.namespaces()))])}};function A0(t){let e=t.split(":");return e.length<2?"":e.slice(0,-1).join(":")}function S0(t){let e=t.split(":");return e[e.length-1]}function k0(t){return[].concat(...t)}var Ol=Vr(Oo(),1);var Ho=class extends Error{static name="SignatureCreationError";constructor(e="Record signature creation failed"){super(e),this.name="SignatureCreationError"}},Ze=class extends Error{static name="SignatureVerificationError";constructor(e="Record signature verification failed"){super(e),this.name="SignatureVerificationError"}},Po=class extends Error{static name="RecordExpiredError";constructor(e="Record has expired"){super(e),this.name="RecordExpiredError"}},nr=class extends Error{static name="UnsupportedValidityError";constructor(e="The validity type is unsupported"){super(e),this.name="UnsupportedValidityError"}},Ko=class extends Error{static name="RecordTooLargeError";constructor(e="The record is too large"){super(e),this.name="RecordTooLargeError"}},un=class extends Error{static name="InvalidValueError";constructor(e="Value must be a valid content path starting with /"){super(e),this.name="InvalidValueError"}},$o=class extends Error{static name="InvalidRecordDataError";constructor(e="Invalid record data"){super(e),this.name="InvalidRecordDataError"}},ln=class extends Error{static name="InvalidEmbeddedPublicKeyError";constructor(e="Invalid embedded public key"){super(e),this.name="InvalidEmbeddedPublicKeyError"}};var ge;(function(t){let e;(function(o){o.EOL="EOL"})(e=t.ValidityType||(t.ValidityType={}));let r;(function(o){o[o.EOL=0]="EOL"})(r||(r={})),function(o){o.codec=()=>Wr(r)}(e=t.ValidityType||(t.ValidityType={}));let n;t.codec=()=>(n==null&&(n=Ot((o,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),o.value!=null&&(i.uint32(10),i.bytes(o.value)),o.signatureV1!=null&&(i.uint32(18),i.bytes(o.signatureV1)),o.validityType!=null&&(i.uint32(24),t.ValidityType.codec().encode(o.validityType,i)),o.validity!=null&&(i.uint32(34),i.bytes(o.validity)),o.sequence!=null&&(i.uint32(40),i.uint64(o.sequence)),o.ttl!=null&&(i.uint32(48),i.uint64(o.ttl)),o.pubKey!=null&&(i.uint32(58),i.bytes(o.pubKey)),o.signatureV2!=null&&(i.uint32(66),i.bytes(o.signatureV2)),o.data!=null&&(i.uint32(74),i.bytes(o.data)),s.lengthDelimited!==!1&&i.ldelim()},(o,i,s={})=>{let a={},c=i==null?o.len:o.pos+i;for(;o.pos<c;){let l=o.uint32();switch(l>>>3){case 1:{a.value=o.bytes();break}case 2:{a.signatureV1=o.bytes();break}case 3:{a.validityType=t.ValidityType.codec().decode(o);break}case 4:{a.validity=o.bytes();break}case 5:{a.sequence=o.uint64();break}case 6:{a.ttl=o.uint64();break}case 7:{a.pubKey=o.bytes();break}case 8:{a.signatureV2=o.bytes();break}case 9:{a.data=o.bytes();break}default:{o.skipType(l&7);break}}}return a})),n),t.encode=o=>Mt(o,t.codec()),t.decode=(o,i)=>Ft(o,t.codec(),i)})(ge||(ge={}));var C0=["string","number","bigint","symbol"],T0=["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 Cu(t){if(t===null)return"null";if(t===void 0)return"undefined";if(t===!0||t===!1)return"boolean";let e=typeof t;if(C0.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(t))return"Array";if(I0(t))return"Buffer";let r=N0(t);return r||"Object"}function I0(t){return t&&t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer.call(null,t)}function N0(t){let e=Object.prototype.toString.call(t).slice(8,-1);if(T0.includes(e))return e}var g=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}};g.uint=new g(0,"uint",!0);g.negint=new g(1,"negint",!0);g.bytes=new g(2,"bytes",!0);g.string=new g(3,"string",!0);g.array=new g(4,"array",!1);g.map=new g(5,"map",!1);g.tag=new g(6,"tag",!1);g.float=new g(7,"float",!0);g.false=new g(7,"false",!0);g.true=new g(7,"true",!0);g.null=new g(7,"null",!0);g.undefined=new g(7,"undefined",!0);g.break=new g(7,"break",!0);var V=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 Cr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",U0=new TextDecoder,R0=new TextEncoder;function qo(t){return Cr&&globalThis.Buffer.isBuffer(t)}function Os(t){return t instanceof Uint8Array?qo(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t:Uint8Array.from(t)}var Uu=Cr?(t,e,r)=>r-e>64?globalThis.Buffer.from(t.subarray(e,r)).toString("utf8"):Iu(t,e,r):(t,e,r)=>r-e>64?U0.decode(t.subarray(e,r)):Iu(t,e,r),Ru=Cr?t=>t.length>64?globalThis.Buffer.from(t):Tu(t):t=>t.length>64?R0.encode(t):Tu(t),nt=t=>Uint8Array.from(t),Tr=Cr?(t,e,r)=>qo(t)?new Uint8Array(t.subarray(e,r)):t.slice(e,r):(t,e,r)=>t.slice(e,r),_u=Cr?(t,e)=>(t=t.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),Os(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},Lu=Cr?t=>globalThis.Buffer.allocUnsafe(t):t=>new Uint8Array(t);function Vu(t,e){if(qo(t)&&qo(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 Tu(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 Iu(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,l,u;switch(s){case 1:o<128&&(i=o);break;case 2:a=t[e+1],(a&192)===128&&(u=(o&31)<<6|a&63,u>127&&(i=u));break;case 3:a=t[e+1],c=t[e+2],(a&192)===128&&(c&192)===128&&(u=(o&15)<<12|(a&63)<<6|c&63,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:a=t[e+1],c=t[e+2],l=t[e+3],(a&192)===128&&(c&192)===128&&(l&192)===128&&(u=(o&15)<<18|(a&63)<<12|(c&63)<<6|l&63,u>65535&&u<1114112&&(i=u))}}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 _0(n)}var Nu=4096;function _0(t){let e=t.length;if(e<=Nu)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Nu));return r}var L0=256,fn=class{constructor(e=L0){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=Lu(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=Tr(n,0,this.cursor)}else r=_u(this.chunks,this.cursor);return e&&this.reset(),r}};var P="CBOR decode error:",Hs="CBOR encode error:",hn=[];hn[23]=1;hn[24]=2;hn[25]=3;hn[26]=5;hn[27]=9;function Et(t,e,r){if(t.length-e<r)throw new Error(`${P} not enough data for type`)}var le=[24,256,65536,4294967296,BigInt("18446744073709551616")];function _e(t,e,r){Et(t,e,1);let n=t[e];if(r.strict===!0&&n<le[0])throw new Error(`${P} integer encoded in more bytes than necessary (strict decode)`);return n}function Le(t,e,r){Et(t,e,2);let n=t[e]<<8|t[e+1];if(r.strict===!0&&n<le[1])throw new Error(`${P} integer encoded in more bytes than necessary (strict decode)`);return n}function Ve(t,e,r){Et(t,e,4);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3];if(r.strict===!0&&n<le[2])throw new Error(`${P} integer encoded in more bytes than necessary (strict decode)`);return n}function De(t,e,r){Et(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<le[3])throw new Error(`${P} 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(`${P} integers outside of the safe integer range are not supported`)}function Du(t,e,r,n){return new V(g.uint,_e(t,e+1,n),2)}function Fu(t,e,r,n){return new V(g.uint,Le(t,e+1,n),3)}function Mu(t,e,r,n){return new V(g.uint,Ve(t,e+1,n),5)}function Ou(t,e,r,n){return new V(g.uint,De(t,e+1,n),9)}function Me(t,e){return me(t,0,e.value)}function me(t,e,r){if(r<le[0]){let n=Number(r);t.push([e|n])}else if(r<le[1]){let n=Number(r);t.push([e|24,n])}else if(r<le[2]){let n=Number(r);t.push([e|25,n>>>8,n&255])}else if(r<le[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<le[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(`${P} encountered BigInt larger than allowable range`)}}Me.encodedSize=function(e){return me.encodedSize(e.value)};me.encodedSize=function(e){return e<le[0]?1:e<le[1]?2:e<le[2]?3:e<le[3]?5:9};Me.compareTokens=function(e,r){return e.value<r.value?-1:e.value>r.value?1:0};function Hu(t,e,r,n){return new V(g.negint,-1-_e(t,e+1,n),2)}function Pu(t,e,r,n){return new V(g.negint,-1-Le(t,e+1,n),3)}function Ku(t,e,r,n){return new V(g.negint,-1-Ve(t,e+1,n),5)}var Ps=BigInt(-1),$u=BigInt(1);function qu(t,e,r,n){let o=De(t,e+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new V(g.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${P} integers outside of the safe integer range are not supported`);return new V(g.negint,Ps-BigInt(o),9)}function zo(t,e){let r=e.value,n=typeof r=="bigint"?r*Ps-$u:r*-1-1;me(t,e.type.majorEncoded,n)}zo.encodedSize=function(e){let r=e.value,n=typeof r=="bigint"?r*Ps-$u:r*-1-1;return n<le[0]?1:n<le[1]?2:n<le[2]?3:n<le[3]?5:9};zo.compareTokens=function(e,r){return e.value<r.value?1:e.value>r.value?-1:0};function dn(t,e,r,n){Et(t,e,r+n);let o=Tr(t,e+r,e+r+n);return new V(g.bytes,o,r+n)}function zu(t,e,r,n){return dn(t,e,1,r)}function Gu(t,e,r,n){return dn(t,e,2,_e(t,e+1,n))}function Zu(t,e,r,n){return dn(t,e,3,Le(t,e+1,n))}function Wu(t,e,r,n){return dn(t,e,5,Ve(t,e+1,n))}function ju(t,e,r,n){let o=De(t,e+1,n);if(typeof o=="bigint")throw new Error(`${P} 64-bit integer bytes lengths not supported`);return dn(t,e,9,o)}function Go(t){return t.encodedBytes===void 0&&(t.encodedBytes=t.type===g.string?Ru(t.value):t.value),t.encodedBytes}function Ir(t,e){let r=Go(e);me(t,e.type.majorEncoded,r.length),t.push(r)}Ir.encodedSize=function(e){let r=Go(e);return me.encodedSize(r.length)+r.length};Ir.compareTokens=function(e,r){return D0(Go(e),Go(r))};function D0(t,e){return t.length<e.length?-1:t.length>e.length?1:Vu(t,e)}function pn(t,e,r,n,o){let i=r+n;Et(t,e,i);let s=new V(g.string,Uu(t,e+r,e+i),i);return o.retainStringBytes===!0&&(s.byteValue=Tr(t,e+r,e+i)),s}function Yu(t,e,r,n){return pn(t,e,1,r,n)}function Ju(t,e,r,n){return pn(t,e,2,_e(t,e+1,n),n)}function Xu(t,e,r,n){return pn(t,e,3,Le(t,e+1,n),n)}function Qu(t,e,r,n){return pn(t,e,5,Ve(t,e+1,n),n)}function el(t,e,r,n){let o=De(t,e+1,n);if(typeof o=="bigint")throw new Error(`${P} 64-bit integer string lengths not supported`);return pn(t,e,9,o,n)}var tl=Ir;function Nr(t,e,r,n){return new V(g.array,n,r)}function rl(t,e,r,n){return Nr(t,e,1,r)}function nl(t,e,r,n){return Nr(t,e,2,_e(t,e+1,n))}function ol(t,e,r,n){return Nr(t,e,3,Le(t,e+1,n))}function il(t,e,r,n){return Nr(t,e,5,Ve(t,e+1,n))}function sl(t,e,r,n){let o=De(t,e+1,n);if(typeof o=="bigint")throw new Error(`${P} 64-bit integer array lengths not supported`);return Nr(t,e,9,o)}function al(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${P} indefinite length items not allowed`);return Nr(t,e,1,1/0)}function Zo(t,e){me(t,g.array.majorEncoded,e.value)}Zo.compareTokens=Me.compareTokens;Zo.encodedSize=function(e){return me.encodedSize(e.value)};function Ur(t,e,r,n){return new V(g.map,n,r)}function cl(t,e,r,n){return Ur(t,e,1,r)}function ul(t,e,r,n){return Ur(t,e,2,_e(t,e+1,n))}function ll(t,e,r,n){return Ur(t,e,3,Le(t,e+1,n))}function fl(t,e,r,n){return Ur(t,e,5,Ve(t,e+1,n))}function hl(t,e,r,n){let o=De(t,e+1,n);if(typeof o=="bigint")throw new Error(`${P} 64-bit integer map lengths not supported`);return Ur(t,e,9,o)}function dl(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${P} indefinite length items not allowed`);return Ur(t,e,1,1/0)}function Wo(t,e){me(t,g.map.majorEncoded,e.value)}Wo.compareTokens=Me.compareTokens;Wo.encodedSize=function(e){return me.encodedSize(e.value)};function pl(t,e,r,n){return new V(g.tag,r,1)}function gl(t,e,r,n){return new V(g.tag,_e(t,e+1,n),2)}function ml(t,e,r,n){return new V(g.tag,Le(t,e+1,n),3)}function yl(t,e,r,n){return new V(g.tag,Ve(t,e+1,n),5)}function xl(t,e,r,n){return new V(g.tag,De(t,e+1,n),9)}function jo(t,e){me(t,g.tag.majorEncoded,e.value)}jo.compareTokens=Me.compareTokens;jo.encodedSize=function(e){return me.encodedSize(e.value)};var K0=20,$0=21,q0=22,z0=23;function wl(t,e,r,n){if(n.allowUndefined===!1)throw new Error(`${P} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new V(g.null,null,1):new V(g.undefined,void 0,1)}function bl(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${P} indefinite length items not allowed`);return new V(g.break,void 0,1)}function Ks(t,e,r){if(r){if(r.allowNaN===!1&&Number.isNaN(t))throw new Error(`${P} NaN values are not supported`);if(r.allowInfinity===!1&&(t===1/0||t===-1/0))throw new Error(`${P} Infinity values are not supported`)}return new V(g.float,t,e)}function vl(t,e,r,n){return Ks($s(t,e+1),3,n)}function El(t,e,r,n){return Ks(qs(t,e+1),5,n)}function Bl(t,e,r,n){return Ks(Cl(t,e+1),9,n)}function Yo(t,e,r){let n=e.value;if(n===!1)t.push([g.float.majorEncoded|K0]);else if(n===!0)t.push([g.float.majorEncoded|$0]);else if(n===null)t.push([g.float.majorEncoded|q0]);else if(n===void 0)t.push([g.float.majorEncoded|z0]);else{let o,i=!1;(!r||r.float64!==!0)&&(Sl(n),o=$s(We,1),n===o||Number.isNaN(n)?(We[0]=249,t.push(We.slice(0,3)),i=!0):(kl(n),o=qs(We,1),n===o&&(We[0]=250,t.push(We.slice(0,5)),i=!0))),i||(G0(n),o=Cl(We,1),We[0]=251,t.push(We.slice(0,9)))}}Yo.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){Sl(n);let o=$s(We,1);if(n===o||Number.isNaN(n))return 3;if(kl(n),o=qs(We,1),n===o)return 5}return 9};var Al=new ArrayBuffer(9),Oe=new DataView(Al,1),We=new Uint8Array(Al,0);function Sl(t){if(t===1/0)Oe.setUint16(0,31744,!1);else if(t===-1/0)Oe.setUint16(0,64512,!1);else if(Number.isNaN(t))Oe.setUint16(0,32256,!1);else{Oe.setFloat32(0,t);let e=Oe.getUint32(0),r=(e&2139095040)>>23,n=e&8388607;if(r===255)Oe.setUint16(0,31744,!1);else if(r===0)Oe.setUint16(0,(t&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?Oe.setUint16(0,0):o<-14?Oe.setUint16(0,(e&2147483648)>>16|1<<24+o,!1):Oe.setUint16(0,(e&2147483648)>>16|o+15<<10|n>>13,!1)}}}function $s(t,e){if(t.length-e<2)throw new Error(`${P} 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 kl(t){Oe.setFloat32(0,t,!1)}function qs(t,e){if(t.length-e<4)throw new Error(`${P} not enough data for float32`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,4).getFloat32(0,!1)}function G0(t){Oe.setFloat64(0,t,!1)}function Cl(t,e){if(t.length-e<8)throw new Error(`${P} not enough data for float64`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,8).getFloat64(0,!1)}Yo.compareTokens=Me.compareTokens;function W(t,e,r){throw new Error(`${P} encountered invalid minor (${r}) for major ${t[e]>>>5}`)}function Jo(t){return()=>{throw new Error(`${P} ${t}`)}}var C=[];for(let t=0;t<=23;t++)C[t]=W;C[24]=Du;C[25]=Fu;C[26]=Mu;C[27]=Ou;C[28]=W;C[29]=W;C[30]=W;C[31]=W;for(let t=32;t<=55;t++)C[t]=W;C[56]=Hu;C[57]=Pu;C[58]=Ku;C[59]=qu;C[60]=W;C[61]=W;C[62]=W;C[63]=W;for(let t=64;t<=87;t++)C[t]=zu;C[88]=Gu;C[89]=Zu;C[90]=Wu;C[91]=ju;C[92]=W;C[93]=W;C[94]=W;C[95]=Jo("indefinite length bytes/strings are not supported");for(let t=96;t<=119;t++)C[t]=Yu;C[120]=Ju;C[121]=Xu;C[122]=Qu;C[123]=el;C[124]=W;C[125]=W;C[126]=W;C[127]=Jo("indefinite length bytes/strings are not supported");for(let t=128;t<=151;t++)C[t]=rl;C[152]=nl;C[153]=ol;C[154]=il;C[155]=sl;C[156]=W;C[157]=W;C[158]=W;C[159]=al;for(let t=160;t<=183;t++)C[t]=cl;C[184]=ul;C[185]=ll;C[186]=fl;C[187]=hl;C[188]=W;C[189]=W;C[190]=W;C[191]=dl;for(let t=192;t<=215;t++)C[t]=pl;C[216]=gl;C[217]=ml;C[218]=yl;C[219]=xl;C[220]=W;C[221]=W;C[222]=W;C[223]=W;for(let t=224;t<=243;t++)C[t]=Jo("simple values are not supported");C[244]=W;C[245]=W;C[246]=W;C[247]=wl;C[248]=Jo("simple values are not supported");C[249]=vl;C[250]=El;C[251]=Bl;C[252]=W;C[253]=W;C[254]=W;C[255]=bl;var je=[];for(let t=0;t<24;t++)je[t]=new V(g.uint,t,1);for(let t=-1;t>=-24;t--)je[31-t]=new V(g.negint,t,1);je[64]=new V(g.bytes,new Uint8Array(0),1);je[96]=new V(g.string,"",1);je[128]=new V(g.array,0,1);je[160]=new V(g.map,0,1);je[244]=new V(g.false,!1,1);je[245]=new V(g.true,!0,1);je[246]=new V(g.null,null,1);function Tl(t){switch(t.type){case g.false:return nt([244]);case g.true:return nt([245]);case g.null:return nt([246]);case g.bytes:return t.value.length?void 0:nt([64]);case g.string:return t.value===""?nt([96]):void 0;case g.array:return t.value===0?nt([128]):void 0;case g.map:return t.value===0?nt([160]):void 0;case g.uint:return t.value<24?nt([Number(t.value)]):void 0;case g.negint:if(t.value>=-24)return nt([31-Number(t.value)])}}var W0={float64:!1,mapSorter:J0,quickEncodeToken:Tl};function j0(){let t=[];return t[g.uint.major]=Me,t[g.negint.major]=zo,t[g.bytes.major]=Ir,t[g.string.major]=tl,t[g.array.major]=Zo,t[g.map.major]=Wo,t[g.tag.major]=jo,t[g.float.major]=Yo,t}var Il=j0(),zs=new fn,Qo=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(`${Hs} object contains circular references`);return new t(r,e)}},zt={null:new V(g.null,null),undefined:new V(g.undefined,void 0),true:new V(g.true,!0),false:new V(g.false,!1),emptyArray:new V(g.array,0),emptyMap:new V(g.map,0)},Gt={number(t,e,r,n){return!Number.isInteger(t)||!Number.isSafeInteger(t)?new V(g.float,t):t>=0?new V(g.uint,t):new V(g.negint,t)},bigint(t,e,r,n){return t>=BigInt(0)?new V(g.uint,t):new V(g.negint,t)},Uint8Array(t,e,r,n){return new V(g.bytes,t)},string(t,e,r,n){return new V(g.string,t)},boolean(t,e,r,n){return t?zt.true:zt.false},null(t,e,r,n){return zt.null},undefined(t,e,r,n){return zt.undefined},ArrayBuffer(t,e,r,n){return new V(g.bytes,new Uint8Array(t))},DataView(t,e,r,n){return new V(g.bytes,new Uint8Array(t.buffer,t.byteOffset,t.byteLength))},Array(t,e,r,n){if(!t.length)return r.addBreakTokens===!0?[zt.emptyArray,new V(g.break)]:zt.emptyArray;n=Qo.createCheck(n,t);let o=[],i=0;for(let s of t)o[i++]=Xo(s,r,n);return r.addBreakTokens?[new V(g.array,t.length),o,new V(g.break)]:[new V(g.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?[zt.emptyMap,new V(g.break)]:zt.emptyMap;n=Qo.createCheck(n,t);let a=[],c=0;for(let l of i)a[c++]=[Xo(l,r,n),Xo(o?t.get(l):t[l],r,n)];return Y0(a,r),r.addBreakTokens?[new V(g.map,s),a,new V(g.break)]:[new V(g.map,s),a]}};Gt.Map=Gt.Object;Gt.Buffer=Gt.Uint8Array;for(let t of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Gt[`${t}Array`]=Gt.DataView;function Xo(t,e={},r){let n=Cu(t),o=e&&e.typeEncoders&&e.typeEncoders[n]||Gt[n];if(typeof o=="function"){let s=o(t,n,e,r);if(s!=null)return s}let i=Gt[n];if(!i)throw new Error(`${Hs} unsupported type: ${n}`);return i(t,n,e,r)}function Y0(t,e){e.mapSorter&&t.sort(e.mapSorter)}function J0(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=Il[o].compareTokens(r,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function Nl(t,e,r,n){if(Array.isArray(e))for(let o of e)Nl(t,o,r,n);else r[e.type.major](t,e,n)}function X0(t,e,r){let n=Xo(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 fn(s);if(i(a,n,r),a.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return Os(a.chunks[0])}}return zs.reset(),Nl(zs,n,e,r),zs.toBytes(!0)}function Gs(t,e){return e=Object.assign({},W0,e),X0(t,Il,e)}var Q0={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},ei=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=je[e];if(r===void 0){let n=C[e];if(!n)throw new Error(`${P} 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}},gn=Symbol.for("DONE"),ti=Symbol.for("BREAK");function ep(t,e,r){let n=[];for(let o=0;o<t.value;o++){let i=Rr(e,r);if(i===ti){if(t.value===1/0)break;throw new Error(`${P} got unexpected break to lengthed array`)}if(i===gn)throw new Error(`${P} found array but not enough entries (got ${o}, expected ${t.value})`);n[o]=i}return n}function tp(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=Rr(e,r);if(a===ti){if(t.value===1/0)break;throw new Error(`${P} got unexpected break to lengthed map`)}if(a===gn)throw new Error(`${P} found map but not enough entries (got ${s} [no key], expected ${t.value})`);if(n!==!0&&typeof a!="string")throw new Error(`${P} non-string keys not supported (got ${typeof a})`);if(r.rejectDuplicateMapKeys===!0&&(n&&i.has(a)||!n&&a in o))throw new Error(`${P} found repeat map key "${a}"`);let c=Rr(e,r);if(c===gn)throw new Error(`${P} 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 Rr(t,e){if(t.done())return gn;let r=t.next();if(r.type===g.break)return ti;if(r.type.terminal)return r.value;if(r.type===g.array)return ep(r,t,e);if(r.type===g.map)return tp(r,t,e);if(r.type===g.tag){if(e.tags&&typeof e.tags[r.value]=="function"){let n=Rr(t,e);return e.tags[r.value](n)}throw new Error(`${P} tag not supported (${r.value})`)}throw new Error("unsupported")}function Ul(t,e){if(!(t instanceof Uint8Array))throw new Error(`${P} data to decode must be a Uint8Array`);e=Object.assign({},Q0,e);let r=e.tokenizer||new ei(t,e),n=Rr(r,e);if(n===gn)throw new Error(`${P} did not find any content to decode`);if(n===ti)throw new Error(`${P} got unexpected break`);return[n,t.subarray(r.pos())]}function Zs(t,e){let[r,n]=Ul(t,e);if(n.length>0)throw new Error(`${P} too many terminals, data makes no sense`);return r}var np=Ct("ipns:utils"),Rl=Y("/ipns/"),op=114,ip=0,sp=18;function _l(t){let e;if(t.pubKey!=null)try{e=Su(t.pubKey)}catch(r){throw np.error(r),r}if(e!=null)return e}function Ll(t,e,r){let n=Y(e);return an([t,r,n])}function ni(t){let e=Y("ipns-signature:");return an([e,t])}function Ws(t){return"signatureV1"in t?ge.encode({value:Y(t.value),signatureV1:t.signatureV1,validityType:t.validityType,validity:Y(t.validity),sequence:t.sequence,ttl:t.ttl,pubKey:t.pubKey,signatureV2:t.signatureV2,data:t.data}):ge.encode({pubKey:t.pubKey,signatureV2:t.signatureV2,data:t.data})}function ot(t){let e=ge.decode(t);if(e.sequence!=null&&(e.sequence=BigInt(e.sequence)),e.ttl!=null&&(e.ttl=BigInt(e.ttl)),e.signatureV2==null||e.data==null)throw new Ze("Missing data or signatureV2");let r=Fl(e.data),n=ap(r.Value),o=Se(r.Validity);if(e.value!=null&&e.signatureV1!=null)return cp(e),{value:n,validityType:ge.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:e.pubKey,signatureV1:e.signatureV1,signatureV2:e.signatureV2,data:e.data};if(e.signatureV2!=null)return{value:n,validityType:ge.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data};throw new Error("invalid record: does not include signatureV1 or signatureV2")}function _r(t){return an([Rl,t.bytes])}function Vl(t){let e=at(t.slice(Rl.length));if(!ri(e,ip)&&!ri(e,sp))throw new ar("Multihash in IPNS key was not identity or sha2-256");return e}function Dl(t,e,r,n,o){let i;if(e===ge.ValidityType.EOL)i=0;else throw new nr("The validity type is unsupported");return Gs({Value:t,Validity:r,ValidityType:i,Sequence:n,TTL:o})}function Fl(t){let e=Zs(t);if(e.ValidityType===0)e.ValidityType=ge.ValidityType.EOL;else throw new nr("The validity type is unsupported");return Number.isInteger(e.Sequence)&&(e.Sequence=BigInt(e.Sequence)),Number.isInteger(e.TTL)&&(e.TTL=BigInt(e.TTL)),e}function ap(t){let e=Se(t).trim();if(e.startsWith("/"))return e;try{return`/ipfs/${ee.decode(t).toV1().toString()}`}catch{}try{return`/ipfs/${ee.parse(e).toV1().toString()}`}catch{}throw new un("Value must be a valid content path starting with /")}function Ml(t){if(t!=null){let e=fp(t);if(e!=null)return e.code===op?`/ipns/${e.toString(He)}`:`/ipfs/${e.toV1().toString()}`;if(up(t))return`/ipns/${He.encode(t.bytes)}`;let r=t.toString().trim();if(r.startsWith("/")&&r.length>1)return r}throw new un("Value must be a valid content path starting with /")}function cp(t){if(t.data==null)throw new $o("Record data is missing");let e=Fl(t.data);if(!he(e.Value,t.value??new Uint8Array(0)))throw new Ze('Field "value" did not match between protobuf and CBOR');if(!he(e.Validity,t.validity??new Uint8Array(0)))throw new Ze('Field "validity" did not match between protobuf and CBOR');if(e.ValidityType!==t.validityType)throw new Ze('Field "validityType" did not match between protobuf and CBOR');if(e.Sequence!==t.sequence)throw new Ze('Field "sequence" did not match between protobuf and CBOR');if(e.TTL!==t.ttl)throw new Ze('Field "ttl" did not match between protobuf and CBOR')}function up(t){return t.bytes instanceof Uint8Array}function lp(t){return typeof t?.toCID=="function"}function fp(t){if(lp(t))return t.toCID();try{return ee.parse(t)}catch{}return ee.asCID(t)}function ri(t,e){return t.code===e}var hp=Ct("ipns"),Hl=60*60*1e9,dp="/ipns/",Bb=dp.length,Pl={v1Compatible:!0,ttlNs:Hl};async function Kl(t,e,r,n,o=Pl){let i=new Ol.default(Date.now()+Number(n)),s=ge.ValidityType.EOL,a=BigInt(o.ttlNs??Hl);return pp(t,e,r,s,i.toString(),a,o)}var pp=async(t,e,r,n,o,i,s=Pl)=>{r=BigInt(r);let a=Y(o),c=Ml(e),l=Y(c),u=Dl(l,n,a,r,i),f=ni(u),h=await t.sign(f),v;if(t.type==="RSA"&&(v=xr(t.publicKey)),s.v1Compatible===!0){let E=await gp(t,l,n,a),y={value:c,signatureV1:E,validity:o,validityType:n,sequence:r,ttl:i,signatureV2:h,data:u};return v!=null&&(y.pubKey=v),y}else{let E={value:c,validity:o,validityType:n,sequence:r,ttl:i,signatureV2:h,data:u};return v!=null&&(E.pubKey=v),E}},gp=async(t,e,r,n)=>{try{let o=Ll(e,r,n);return await t.sign(o)}catch(o){throw hp.error("record signature creation failed",o),new Ho("Record signature creation failed")}};var js=Vr(Oo(),1);function oi(t,e){let r=e.map((n,o)=>({record:ot(n),index:o}));return r.sort((n,o)=>{let i=n.record.sequence,s=o.record.sequence;if(i>s)return-1;if(i<s)return 1;if(n.record.validityType===ge.ValidityType.EOL&&o.record.validityType===ge.ValidityType.EOL){let a=js.default.fromString(n.record.validity).toDate(),c=js.default.fromString(o.record.validity).toDate();if(a.getTime()>c.getTime())return-1;if(a.getTime()<c.getTime())return 1}return 0}),r[0].index}var $l=Vr(Oo(),1);var ii=Ct("ipns:validator"),mp=1024*10,yp=async(t,e)=>{let r=ot(e),n;try{let o=ni(r.data);n=await t.verify(o,r.signatureV2)}catch{n=!1}if(!n)throw ii.error("record signature verification failed"),new Ze("Record signature verification failed");if(r.validityType===ge.ValidityType.EOL){if($l.default.fromString(r.validity).toDate().getTime()<Date.now())throw ii.error("record has expired"),new Po("record has expired")}else if(r.validityType!=null)throw ii.error("the validity type is unsupported"),new nr("The validity type is unsupported");ii("ipns record for %s is valid",r.value)};async function si(t,e){if(e.byteLength>mp)throw new Ko("The record is too large");let r=Vl(t),n;ri(r,0)&&(n=Fo(r));let o=ot(e),i=_l(o)??n;if(i==null)throw new ln("Could not extract public key from IPNS record or routing key");let s=_r(i.toMultihash());if(!he(s,t))throw new ln("Embedded public key did not match routing key");await yp(i,e)}var ke=class extends Event{type;detail;constructor(e,r){super(e),this.type=e,this.detail=r}};var ql=Symbol.for("nodejs.util.inspect.custom"),xp=114,mn=class{type;multihash;publicKey;string;constructor(e){this.type=e.type,this.multihash=e.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[wi]=!0;toString(){return this.string==null&&(this.string=Q.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return ee.createV1(xp,this.multihash)}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return he(this.multihash.bytes,e);if(typeof e=="string")return this.toString()===e;if(e?.toMultihash()?.bytes!=null)return he(this.multihash.bytes,e.toMultihash().bytes);throw new Error("not valid Id")}[ql](){return`PeerId(${this.toString()})`}},ai=class extends mn{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},ci=class extends mn{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.publicKey}},ui=class extends mn{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.publicKey}},wp=2336,yn=class{type="url";multihash;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=ct.digest(Y(this.url))}[ql](){return`PeerId(${this.url})`}[wi]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return ee.createV1(wp,this.toMultihash())}toJSON(){return this.toString()}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=Se(e)),e.toString()===this.toString())}};var bp=114,zl=2336;function Gl(t,e){let r;if(t.charAt(0)==="1"||t.charAt(0)==="Q")r=at(Q.decode(`z${t}`));else{if(e==null)throw new xe('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=at(e.decode(t))}return Zl(r)}function Zl(t){if(Ep(t))return new ai({multihash:t});if(vp(t))try{let e=Fo(t);if(e.type==="Ed25519")return new ci({multihash:t,publicKey:e});if(e.type==="secp256k1")return new ui({multihash:t,publicKey:e})}catch{let r=Se(t.digest);return new yn(new URL(r))}throw new ar("Supplied PeerID Multihash is invalid")}function Wl(t){if(t?.multihash==null||t.version==null||t.version===1&&t.code!==bp&&t.code!==zl)throw new bn("Supplied PeerID CID is invalid");if(t.code===zl){let e=Se(t.multihash.digest);return new yn(new URL(e))}return Zl(t.multihash)}function vp(t){return t.code===ct.code}function Ep(t){return t.code===zr.code}var Sp=Vr(Yl(),1);var Bt;(function(t){t[t.A=1]="A",t[t.CNAME=5]="CNAME",t[t.TXT=16]="TXT",t[t.AAAA=28]="AAAA"})(Bt||(Bt={}));var li=class extends Error{static name="DNSLinkNotFoundError";constructor(e="DNSLink not found"){super(e),this.name="DNSLinkNotFoundError"}},fi=class extends Error{static name="RecordsFailedValidationError";constructor(e="Records failed validation"){super(e),this.name="RecordsFailedValidationError"}},hi=class extends Error{static name="UnsupportedMultibasePrefixError";constructor(e="Unsupported multibase prefix"){super(e),this.name="UnsupportedMultibasePrefixError"}},di=class extends Error{static name="UnsupportedMultihashCodecError";constructor(e="Unsupported multihash codec"){super(e),this.name="UnsupportedMultihashCodecError"}},pi=class extends Error{static name="InvalidValueError";constructor(e="Invalid value"){super(e),this.name="InvalidValueError"}};var kp=32;async function Jl(t,e,r,n,o={}){if(e===0)throw new Error("recursion limit exceeded");n("query %s for TXT and CNAME records",t);let s=((await r.query(t,{...o,types:[Bt.TXT]}))?.Answer??[]).sort((l,u)=>l.data.localeCompare(u.data));n("found %d TXT records for %s",s.length,t);for(let l of s)try{let u=l.data;if(u.startsWith('"')&&u.endsWith('"')&&(u=u.substring(1,u.length-1)),!u.startsWith("dnslink="))continue;n("%s TXT %s",l.name,u),u=u.replace("dnslink=","");let[,f,h,...v]=u.split("/");if(f==="ipfs")try{return{value:`/ipfs/${ee.parse(h)}${v.length>0?`/${v.join("/")}`:""}`,answer:l}}catch{}else if(f==="ipns"){try{let E;return h.charAt(0)==="1"||h.charAt(0)==="Q"?E=Gl(h):E=Wl(ee.parse(h)),{value:`/ipns/${E}${v.length>0?`/${v.join("/")}`:""}`,answer:l}}catch{}return await gi(h,e-1,r,n,o)}else{if(f==="dnslink")return await gi(h,e-1,r,n,o);n('unknown protocol "%s" in DNSLink record for domain: %s',f,t);continue}}catch(u){n.error("could not parse DNS link record for domain %s, %s",t,l.data,u)}n("no DNSLink records found for %s, falling back to CNAME",t);let c=((await r.query(t,{...o,types:[Bt.CNAME]}))?.Answer??[]).sort((l,u)=>l.data.localeCompare(u.data));n("found %d CNAME records for %s",c.length,t);for(let l of c)try{return await gi(l.data,e-1,r,n,o)}catch(u){n.error("domain %s cname %s had no DNSLink records",t,l.data,u)}throw new li(`No DNSLink records found for domain: ${t}`)}async function gi(t,e,r,n,o={}){if(e===0)throw new Error("recursion limit exceeded");t.startsWith("_dnslink.")||(t=`_dnslink.${t}`);try{return await Jl(t,e,r,n,o)}catch(i){if(i.code!=="ENOTFOUND"&&i.code!=="ENODATA"&&i.name!=="DNSLinkNotFoundError"&&i.name!=="NotFoundError")throw i;return t.startsWith("_dnslink.")?t=t.replace("_dnslink.",""):t=`_dnslink.${t}`,Jl(t,e,r,n,o)}}async function Xl(t,e,r,n={}){return gi(t,n.maxRecursiveDepth??kp,e,r,n)}var Ys=class{routing;constructor(e){this.routing=e}async put(e,r,n={}){try{await this.routing.put(e,r,n)}catch(o){n.onProgress?.(new ke("ipns:routing:helia:error",o))}}async get(e,r={}){try{return await this.routing.get(e,r)}catch(n){r.onProgress?.(new ke("ipns:routing:helia:error",n))}throw new Error("Not found")}};function Ql(t){return new Ys(t)}var xn;(function(t){let e;t.codec=()=>(e==null&&(e=Ot((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.key!=null&&r.key.byteLength>0&&(n.uint32(10),n.bytes(r.key)),r.value!=null&&r.value.byteLength>0&&(n.uint32(18),n.bytes(r.value)),r.timeReceived!=null&&r.timeReceived!==""&&(n.uint32(42),n.string(r.timeReceived)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={key:Xi(0),value:Xi(0),timeReceived:""},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let a=r.uint32();switch(a>>>3){case 1:{i.key=r.bytes();break}case 2:{i.value=r.bytes();break}case 5:{i.timeReceived=r.string();break}default:{r.skipType(a&7);break}}}return i})),e),t.encode=r=>Mt(r,t.codec()),t.decode=(r,n)=>Ft(r,t.codec(),n)})(xn||(xn={}));function ef(t){let e=t.getUTCFullYear(),r=String(t.getUTCMonth()+1).padStart(2,"0"),n=String(t.getUTCDate()).padStart(2,"0"),o=String(t.getUTCHours()).padStart(2,"0"),i=String(t.getUTCMinutes()).padStart(2,"0"),s=String(t.getUTCSeconds()).padStart(2,"0"),a=t.getUTCMilliseconds(),c=String(a*1e3*1e3).padStart(9,"0");return`${e}-${r}-${n}T${o}:${i}:${s}.${c}Z`}function tf(t){let e=new RegExp("(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})\\.(\\d+)Z"),r=String(t).trim().match(e);if(r==null)throw new Error("Invalid format");let n=parseInt(r[1],10),o=parseInt(r[2],10)-1,i=parseInt(r[3],10),s=parseInt(r[4],10),a=parseInt(r[5],10),c=parseInt(r[6],10),l=parseInt(r[7].slice(0,-6),10);return new Date(Date.UTC(n,o,i,s,a,c,l))}var ir=class t{key;value;timeReceived;constructor(e,r,n){if(!(e instanceof Uint8Array))throw new Error("key must be a Uint8Array");if(!(r instanceof Uint8Array))throw new Error("value must be a Uint8Array");this.key=e,this.value=r,this.timeReceived=n}serialize(){return xn.encode(this.prepareSerialize())}prepareSerialize(){return{key:this.key,value:this.value,timeReceived:ef(this.timeReceived)}}static deserialize(e){let r=xn.decode(e);return new t(r.key,r.value,new Date(r.timeReceived))}static fromDeserialized(e){let r=tf(e.timeReceived);if(e.key==null)throw new Error("key missing from deserialized object");if(e.value==null)throw new Error("value missing from deserialized object");return new t(e.key,e.value,r)}};var rf;(function(t){t[t.SEND_QUERY=0]="SEND_QUERY",t[t.PEER_RESPONSE=1]="PEER_RESPONSE",t[t.FINAL_PEER=2]="FINAL_PEER",t[t.QUERY_ERROR=3]="QUERY_ERROR",t[t.PROVIDER=4]="PROVIDER",t[t.VALUE=5]="VALUE",t[t.ADD_PEER=6]="ADD_PEER",t[t.DIAL_PEER=7]="DIAL_PEER"})(rf||(rf={}));function mi(t){return new cn("/dht/record/"+Se(t,"base32"),!1)}function nf(t){return{async put(e,r,n={}){try{let o=mi(e);try{let s=await t.get(o),a=ir.deserialize(s);if(he(a.value,r))return}catch(s){if(s.name!=="NotFoundError")throw s}let i=new ir(e,r,new Date);n.onProgress?.(new ke("ipns:routing:datastore:put")),await t.put(o,i.serialize(),n)}catch(o){throw n.onProgress?.(new ke("ipns:routing:datastore:error",o)),o}},async get(e,r={}){try{let n=mi(e);r.onProgress?.(new ke("ipns:routing:datastore:get"));let o=await t.get(n,r),i=ir.deserialize(o);return{record:i.value,created:i.timeReceived}}catch(n){throw r.onProgress?.(new ke("ipns:routing:datastore:error",n)),n}},async has(e,r={}){let n=mi(e);return t.has(n,r)},async delete(e,r){let n=mi(e);return t.delete(n,r)}}}function Js(t,e){return t.code===e}var At=Ct("helia:ipns"),Np=60*1e3,ea=60*Np,Up=24*ea,Xs=23*ea,of=BigInt(ea)*1000000n,sf={[He.prefix]:He,[Q.prefix]:Q},Qs=class{routers;localStore;timeout;dns;log;constructor(e,r=[]){this.routers=[Ql(e.routing),...r],this.localStore=nf(e.datastore),this.dns=e.dns,this.log=e.logger.forComponent("helia:ipns")}async publish(e,r,n={}){try{let o=1n,i=_r(e.publicKey.toMultihash());if(await this.localStore.has(i,n)){let{record:l}=await this.localStore.get(i,n);o=ot(l).sequence+1n}let s=n.ttl!=null?BigInt(n.ttl)*1000000n:of,a=await Kl(e,r,o,n.lifetime??Up,{...n,ttlNs:s}),c=Ws(a);return await this.localStore.put(i,c,n),n.offline!==!0&&await Promise.all(this.routers.map(async l=>{await l.put(i,c,n)})),a}catch(o){throw n.onProgress?.(new ke("ipns:publish:error",o)),o}}async resolve(e,r={}){let n=ua(e)?e.toMultihash():e,o=_r(n),i=await this.#t(o,r);return{...await this.#e(i.value,r),record:i}}async resolveDNSLink(e,r={}){let n=await Xl(e,this.dns,this.log,r);return{...await this.#e(n.value,r),answer:n.answer}}republish(e={}){if(this.timeout!=null)throw new Error("Republish is already running");e.signal?.addEventListener("abort",()=>{clearTimeout(this.timeout)});async function r(){let n=Date.now();e.onProgress?.(new ke("ipns:republish:start"));let i=Date.now()-n,s=Xs-i;s<0&&(s=e.interval??Xs),setTimeout(()=>{r().catch(a=>{At.error("error republishing",a)})},s)}this.timeout=setTimeout(()=>{r().catch(n=>{At.error("error republishing",n)})},e.interval??Xs)}async#e(e,r={}){let n=e.split("/");try{let o=n[1];if(o==="ipns"){let i=n[2],s=i.substring(0,1),a;if(s==="1"||s==="Q")a=Q.decode(`z${i}`);else if(sf[s]!=null)a=sf[s].decode(i);else throw new hi(`Unsupported multibase prefix "${s}"`);let c;try{c=at(a)}catch{c=ee.decode(a).multihash}if(!Js(c,0)&&!Js(c,18))throw new di(`Unsupported multihash codec "${c.code}"`);let{cid:l}=await this.resolve(c,r),u=n.slice(3).join("/");return{cid:l,path:u}}else if(o==="ipfs"){let i=ee.parse(n[2]),s=n.slice(3).join("/");return{cid:i,path:s}}}catch(o){At.error("error parsing ipfs path",o)}throw At.error("invalid ipfs path %s",e),new pi("Invalid value")}async#t(e,r={}){let n=[];if(await this.localStore.has(e,r))if(At("record is present in the cache"),r.nocache!==!0)try{let{record:a,created:c}=await this.localStore.get(e,r);this.log("record retrieved from cache"),await si(e,a),this.log("record was valid");let l=ot(a),u=Number((l.ttl??of)/1000000n);if(c.getTime()+u>Date.now())return this.log("record TTL was valid"),l;if(r.offline===!0)return this.log("record TTL has been reached but we are resolving offline-only, returning record"),l;this.log("record TTL has been reached, searching routing for updates"),n.push(a)}catch(a){this.log("cached record was invalid",a),await this.localStore.delete(e,r)}else At("ignoring local cache due to nocache=true option");if(r.offline===!0)throw new Dr("Record was not present in the cache or has expired");At("did not have record locally");let i=0;if(await Promise.all(this.routers.map(async a=>{let c;try{c=await a.get(e,{...r,validate:!1})}catch(l){At.error("error finding IPNS record",l);return}try{await si(e,c),n.push(c)}catch(l){i++,At.error("error finding IPNS record",l)}})),n.length===0)throw i>0?new fi(`${i>1?`${i} records`:"Record"} found for routing key ${i>1?"were":"was"} invalid`):new Dr("Could not find record for routing key");let s=n[oi(e,n)];return await this.localStore.put(e,s,r),ot(s)}};function Rp(t,{routers:e=[]}={}){return new Qs(t,e)}return bf(_p);})();
|
|
8
8
|
/*! Bundled license information:
|
|
9
9
|
|
|
10
10
|
pvtsutils/build/index.js:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helia/ipns",
|
|
3
|
-
"version": "8.1.0-
|
|
3
|
+
"version": "8.1.0-eaf789a",
|
|
4
4
|
"description": "An implementation of IPNS for Helia",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/ipfs/helia/tree/main/packages/ipns#readme",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"test:electron-main": "aegir test -t electron-main"
|
|
80
80
|
},
|
|
81
81
|
"dependencies": {
|
|
82
|
-
"@helia/interface": "5.2.0-
|
|
82
|
+
"@helia/interface": "5.2.0-eaf789a",
|
|
83
83
|
"@libp2p/interface": "^2.2.1",
|
|
84
84
|
"@libp2p/kad-dht": "^14.1.3",
|
|
85
85
|
"@libp2p/logger": "^5.1.4",
|