@helia/routers 2.1.0 → 2.2.0-075b6ca

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 CHANGED
@@ -1,28 +1,28 @@
1
1
  (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.HeliaRouters = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- "use strict";var HeliaRouters=(()=>{var ud=Object.create;var Rn=Object.defineProperty;var ld=Object.getOwnPropertyDescriptor;var fd=Object.getOwnPropertyNames;var dd=Object.getPrototypeOf,hd=Object.prototype.hasOwnProperty;var Ui=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),kt=(r,t)=>{for(var e in t)Rn(r,e,{get:t[e],enumerable:!0})},za=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of fd(t))!hd.call(r,o)&&o!==e&&Rn(r,o,{get:()=>t[o],enumerable:!(n=ld(t,o))||n.enumerable});return r};var _n=(r,t,e)=>(e=r!=null?ud(dd(r)):{},za(t||!r||!r.__esModule?Rn(e,"default",{value:r,enumerable:!0}):e,r)),pd=r=>za(Rn({},"__esModule",{value:!0}),r);var Zc=Ui(Nr=>{"use strict";var J0="[object ArrayBuffer]",ve=class r{static isArrayBuffer(t){return Object.prototype.toString.call(t)===J0}static toArrayBuffer(t){return this.isArrayBuffer(t)?t:t.byteLength===t.buffer.byteLength||t.byteOffset===0&&t.byteLength===t.buffer.byteLength?t.buffer:this.toUint8Array(t.buffer).slice(t.byteOffset,t.byteOffset+t.byteLength).buffer}static toUint8Array(t){return this.toView(t,Uint8Array)}static toView(t,e){if(t.constructor===e)return t;if(this.isArrayBuffer(t))return new e(t);if(this.isArrayBufferView(t))return new e(t.buffer,t.byteOffset,t.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(t){return this.isArrayBufferView(t)||this.isArrayBuffer(t)}static isArrayBufferView(t){return ArrayBuffer.isView(t)||t&&this.isArrayBuffer(t.buffer)}static isEqual(t,e){let n=r.toUint8Array(t),o=r.toUint8Array(e);if(n.length!==o.byteLength)return!1;for(let i=0;i<n.length;i++)if(n[i]!==o[i])return!1;return!0}static concat(...t){let e;Array.isArray(t[0])&&!(t[1]instanceof Function)||Array.isArray(t[0])&&t[1]instanceof Function?e=t[0]:t[t.length-1]instanceof Function?e=t.slice(0,t.length-1):e=t;let n=0;for(let s of e)n+=s.byteLength;let o=new Uint8Array(n),i=0;for(let s of e){let a=this.toUint8Array(s);o.set(a,i),i+=a.length}return t[t.length-1]instanceof Function?this.toView(o,t[t.length-1]):o.buffer}},Ms="string",X0=/^[0-9a-f]+$/i,Q0=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,tp=/^[a-zA-Z0-9-_]+$/,ro=class{static fromString(t){let e=unescape(encodeURIComponent(t)),n=new Uint8Array(e.length);for(let o=0;o<e.length;o++)n[o]=e.charCodeAt(o);return n.buffer}static toString(t){let e=ve.toUint8Array(t),n="";for(let i=0;i<e.length;i++)n+=String.fromCharCode(e[i]);return decodeURIComponent(escape(n))}},qt=class{static toString(t,e=!1){let n=ve.toArrayBuffer(t),o=new DataView(n),i="";for(let s=0;s<n.byteLength;s+=2){let a=o.getUint16(s,e);i+=String.fromCharCode(a)}return i}static fromString(t,e=!1){let n=new ArrayBuffer(t.length*2),o=new DataView(n);for(let i=0;i<t.length;i++)o.setUint16(i*2,t.charCodeAt(i),e);return n}},no=class r{static isHex(t){return typeof t===Ms&&X0.test(t)}static isBase64(t){return typeof t===Ms&&Q0.test(t)}static isBase64Url(t){return typeof t===Ms&&tp.test(t)}static ToString(t,e="utf8"){let n=ve.toUint8Array(t);switch(e.toLowerCase()){case"utf8":return this.ToUtf8String(n);case"binary":return this.ToBinary(n);case"hex":return this.ToHex(n);case"base64":return this.ToBase64(n);case"base64url":return this.ToBase64Url(n);case"utf16le":return qt.toString(n,!0);case"utf16":case"utf16be":return qt.toString(n);default:throw new Error(`Unknown type of encoding '${e}'`)}}static FromString(t,e="utf8"){if(!t)return new ArrayBuffer(0);switch(e.toLowerCase()){case"utf8":return this.FromUtf8String(t);case"binary":return this.FromBinary(t);case"hex":return this.FromHex(t);case"base64":return this.FromBase64(t);case"base64url":return this.FromBase64Url(t);case"utf16le":return qt.fromString(t,!0);case"utf16":case"utf16be":return qt.fromString(t);default:throw new Error(`Unknown type of encoding '${e}'`)}}static ToBase64(t){let e=ve.toUint8Array(t);if(typeof btoa<"u"){let n=this.ToString(e,"binary");return btoa(n)}else return Buffer.from(e).toString("base64")}static FromBase64(t){let e=this.formatString(t);if(!e)return new ArrayBuffer(0);if(!r.isBase64(e))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob<"u"?this.FromBinary(atob(e)):new Uint8Array(Buffer.from(e,"base64")).buffer}static FromBase64Url(t){let e=this.formatString(t);if(!e)return new ArrayBuffer(0);if(!r.isBase64Url(e))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(e.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(t){return this.ToBase64(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(t,e=r.DEFAULT_UTF8_ENCODING){switch(e){case"ascii":return this.FromBinary(t);case"utf8":return ro.fromString(t);case"utf16":case"utf16be":return qt.fromString(t);case"utf16le":case"usc2":return qt.fromString(t,!0);default:throw new Error(`Unknown type of encoding '${e}'`)}}static ToUtf8String(t,e=r.DEFAULT_UTF8_ENCODING){switch(e){case"ascii":return this.ToBinary(t);case"utf8":return ro.toString(t);case"utf16":case"utf16be":return qt.toString(t);case"utf16le":case"usc2":return qt.toString(t,!0);default:throw new Error(`Unknown type of encoding '${e}'`)}}static FromBinary(t){let e=t.length,n=new Uint8Array(e);for(let o=0;o<e;o++)n[o]=t.charCodeAt(o);return n.buffer}static ToBinary(t){let e=ve.toUint8Array(t),n="";for(let o=0;o<e.length;o++)n+=String.fromCharCode(e[o]);return n}static ToHex(t){let e=ve.toUint8Array(t),n="",o=e.length;for(let i=0;i<o;i++){let s=e[i];s<16&&(n+="0"),n+=s.toString(16)}return n}static FromHex(t){let e=this.formatString(t);if(!e)return new ArrayBuffer(0);if(!r.isHex(e))throw new TypeError("Argument 'hexString' is not HEX encoded");e.length%2&&(e=`0${e}`);let n=new Uint8Array(e.length/2);for(let o=0;o<e.length;o=o+2){let i=e.slice(o,o+2);n[o/2]=parseInt(i,16)}return n.buffer}static ToUtf16String(t,e=!1){return qt.toString(t,e)}static FromUtf16String(t,e=!1){return qt.fromString(t,e)}static Base64Padding(t){let e=4-t.length%4;if(e<4)for(let n=0;n<e;n++)t+="=";return t}static formatString(t){return t?.replace(/[\n\r\t ]/g,"")||""}};no.DEFAULT_UTF8_ENCODING="utf8";function ep(r,...t){let e=arguments[0];for(let n=1;n<arguments.length;n++){let o=arguments[n];for(let i in o)e[i]=o[i]}return e}function rp(...r){let t=r.map(o=>o.byteLength).reduce((o,i)=>o+i),e=new Uint8Array(t),n=0;return r.map(o=>new Uint8Array(o)).forEach(o=>{for(let i of o)e[n++]=i}),e.buffer}function np(r,t){if(!(r&&t)||r.byteLength!==t.byteLength)return!1;let e=new Uint8Array(r),n=new Uint8Array(t);for(let o=0;o<r.byteLength;o++)if(e[o]!==n[o])return!1;return!0}Nr.BufferSourceConverter=ve;Nr.Convert=no;Nr.assign=ep;Nr.combine=rp;Nr.isEqual=np});var ma=Ui((u2,pa)=>{var c2=function(){typeof pa<"u"&&(pa.exports=w);var r=86400,t=3200,e=146097*t/400,n=r*e,o=1e3*n,i=864e13,s=4294967296,a=1e6,c="000000000",f=Math.trunc||function(g){var v=g-g%1;return v==0&&(g<0||g===0&&1/g!=1/0)?-0:v},u=w.prototype,l=(w.fromDate=function(g){return new w(+g)},w.fromInt64BE=T(0,1,2,3,0,4),w.fromInt64LE=T(3,2,1,0,4,0),w.fromString=function(R){var v,O=new w,R=(R+="").replace(/^\s*[+\-]?\d+/,function(H){var H=+H,A=1970+(H-1970)%400;return O.year=H-A,A}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function(N,H,A){return H<0&&(A*=-1),v=6e4*(60*+H+ +A),""}).replace(/\.\d+$/,function(N){return O.nano=+(N+c).substr(1,9),""}).split(/\D+/);if(1<R.length?R[1]--:R[1]=0,O.time=v=Date.UTC.apply(Date,R)-(v||0),isNaN(v))throw new TypeError("Invalid Date");return h(O)},w.fromTimeT=function(g){return C(g,0)},u.year=0,u.time=0,u.nano=0,u.addNano=function(g){return this.nano+=+g||0,this},u.getNano=function(){var g=h(this);return(g.time%1e3*a+ +g.nano+1e9)%1e9},u.getTimeT=function(){var v=h(this),g=Math.floor(v.time/1e3),v=v.year;return v&&(g+=v*e*r/t),g},u.getYear=function(){return this.toDate().getUTCFullYear()+this.year},u.toDate=function(){return E(h(this).time)},u.toJSON=function(){return this.toString().replace(/0{1,6}Z$/,"Z")},u.toString=function(g){var v=this,O=v.toDate(),R={H:function(){return V(O.getUTCHours())},L:function(){return U(O.getUTCMilliseconds(),3)},M:function(){return V(O.getUTCMinutes())},N:function(){return U(v.getNano(),9)},S:function(){return V(O.getUTCSeconds())},Y:function(){var N=v.getYear();return 999999<N?"+"+N:9999<N?"+"+U(N,6):0<=N?U(N,4):-999999<=N?"-"+U(-N,6):N},a:function(){return b[O.getUTCDay()]},b:function(){return d[O.getUTCMonth()]},d:function(){return V(O.getUTCDate())},e:function(){return function(N){return(9<N?"":" ")+(0|N)}(O.getUTCDate())},m:function(){return V(O.getUTCMonth()+1)}};return function N(H){return H.replace(/%./g,function(A){var m=A[1],S=I[m],m=R[m];return S?N(S):m?m():A})}(g||l)},u.writeInt64BE=x(0,1,2,3,0,4),u.writeInt64LE=x(3,2,1,0,4,0),"%Y-%m-%dT%H:%M:%S.%NZ"),d=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],b=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],I={"%":"%",F:"%Y-%m-%d",n:`
3
- `,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return w;function w(g,v,O){var R=this;if(!(R instanceof w))return new w(g,v,O);R.time=+g||0,R.nano=+v||0,R.year=+O||0,h(R)}function h(g){var v,O,R,N=g.year,H=g.time,A=g.nano,S=((A<0||a<=A)&&(A-=(O=Math.floor(A/a))*a,H+=O,O=1),N%t);return(H<-i||i<H||S)&&((v=f(H/o))&&(N+=v*t,H-=v*o),(R=E(H)).setUTCFullYear(S+R.getUTCFullYear()),R=(H=+R)+(v=f((N-=S)/t))*o,v&&-i<=R&&R<=i&&(N-=v*t,H=R),O=1),O&&(g.year=N,g.time=H,g.nano=A),g}function E(g){var v=new Date(0);return v.setTime(g),v}function C(N,R){N=+N||0;var O=f((R=(R|0)*s)/n)+f(N/n),R=R%n+N%n,N=f(R/n);return N&&(O+=N,R-=N*n),new w(1e3*R,0,O*t)}function x(g,v,O,R,N,H){return function(S,m){var B=h(this);S=S||new Array(8),F(S,m|=0);var P=Math.floor(B.time/1e3),B=B.year*(e*r/t),p=f(B/s)+f(P/s),B=B%s+P%s,P=Math.floor(B/s);return P&&(p+=P,B-=P*s),A(S,m+N,p),A(S,m+H,B),S};function A(S,m,p){S[m+g]=p>>24&255,S[m+v]=p>>16&255,S[m+O]=p>>8&255,S[m+R]=255&p}}function T(g,v,O,R,N,H){return function(S,m){F(S,m|=0);var p=A(S,m+N);return C(A(S,m+H),p)};function A(S,m){return 16777216*S[m+g]+(S[m+v]<<16|S[m+O]<<8|S[m+R])}}function F(g,v){if(g=g&&g.length,g==null)throw new TypeError("Invalid Buffer");if(g<v+8)throw new RangeError("Out of range")}function V(g){return(9<g?"":"0")+(0|g)}function U(g,v){return(c+(0|g)).substr(-v)}}()});var Lf=Ui((Jv,Ba)=>{"use strict";var Nm=Object.prototype.hasOwnProperty,Tt="~";function Cn(){}Object.create&&(Cn.prototype=Object.create(null),new Cn().__proto__||(Tt=!1));function Um(r,t,e){this.fn=r,this.context=t,this.once=e||!1}function _f(r,t,e,n,o){if(typeof e!="function")throw new TypeError("The listener must be a function");var i=new Um(e,n||r,o),s=Tt?Tt+t:t;return r._events[s]?r._events[s].fn?r._events[s]=[r._events[s],i]:r._events[s].push(i):(r._events[s]=i,r._eventsCount++),r}function Bi(r,t){--r._eventsCount===0?r._events=new Cn:delete r._events[t]}function St(){this._events=new Cn,this._eventsCount=0}St.prototype.eventNames=function(){var t=[],e,n;if(this._eventsCount===0)return t;for(n in e=this._events)Nm.call(e,n)&&t.push(Tt?n.slice(1):n);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(e)):t};St.prototype.listeners=function(t){var e=Tt?Tt+t:t,n=this._events[e];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,i=n.length,s=new Array(i);o<i;o++)s[o]=n[o].fn;return s};St.prototype.listenerCount=function(t){var e=Tt?Tt+t:t,n=this._events[e];return n?n.fn?1:n.length:0};St.prototype.emit=function(t,e,n,o,i,s){var a=Tt?Tt+t:t;if(!this._events[a])return!1;var c=this._events[a],f=arguments.length,u,l;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),f){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,e),!0;case 3:return c.fn.call(c.context,e,n),!0;case 4:return c.fn.call(c.context,e,n,o),!0;case 5:return c.fn.call(c.context,e,n,o,i),!0;case 6:return c.fn.call(c.context,e,n,o,i,s),!0}for(l=1,u=new Array(f-1);l<f;l++)u[l-1]=arguments[l];c.fn.apply(c.context,u)}else{var d=c.length,b;for(l=0;l<d;l++)switch(c[l].once&&this.removeListener(t,c[l].fn,void 0,!0),f){case 1:c[l].fn.call(c[l].context);break;case 2:c[l].fn.call(c[l].context,e);break;case 3:c[l].fn.call(c[l].context,e,n);break;case 4:c[l].fn.call(c[l].context,e,n,o);break;default:if(!u)for(b=1,u=new Array(f-1);b<f;b++)u[b-1]=arguments[b];c[l].fn.apply(c[l].context,u)}}return!0};St.prototype.on=function(t,e,n){return _f(this,t,e,n,!1)};St.prototype.once=function(t,e,n){return _f(this,t,e,n,!0)};St.prototype.removeListener=function(t,e,n,o){var i=Tt?Tt+t:t;if(!this._events[i])return this;if(!e)return Bi(this,i),this;var s=this._events[i];if(s.fn)s.fn===e&&(!o||s.once)&&(!n||s.context===n)&&Bi(this,i);else{for(var a=0,c=[],f=s.length;a<f;a++)(s[a].fn!==e||o&&!s[a].once||n&&s[a].context!==n)&&c.push(s[a]);c.length?this._events[i]=c.length===1?c[0]:c:Bi(this,i)}return this};St.prototype.removeAllListeners=function(t){var e;return t?(e=Tt?Tt+t:t,this._events[e]&&Bi(this,e)):(this._events=new Cn,this._eventsCount=0),this};St.prototype.off=St.prototype.removeListener;St.prototype.addListener=St.prototype.on;St.prefixed=Tt;St.EventEmitter=St;typeof Ba<"u"&&(Ba.exports=St)});var Xm={};kt(Xm,{delegatedHTTPRouting:()=>zf,httpGatewayRouting:()=>Qf,libp2pRouting:()=>td});var ja=Symbol.for("@libp2p/content-routing");var Ri=Symbol.for("@libp2p/peer-id");var Ga=Symbol.for("@libp2p/peer-routing");var vt=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},lr=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var Rt=class extends Error{static name="NotFoundError";constructor(t="Not found"){super(t),this.name="NotFoundError"}};var Ln=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},fr=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var dr=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var hr=(r,...t)=>{try{[...t]}catch{}};var Fi={};kt(Fi,{base32:()=>Gt,base32hex:()=>Bd,base32hexpad:()=>Sd,base32hexpadupper:()=>Id,base32hexupper:()=>Ad,base32pad:()=>vd,base32padupper:()=>Ed,base32upper:()=>bd,base32z:()=>kd});var ig=new Uint8Array(0);function Za(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function me(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function Wa(r){return new TextEncoder().encode(r)}function Ya(r){return new TextDecoder().decode(r)}function md(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var i=r.charAt(o),s=i.charCodeAt(0);if(e[s]!==255)throw new TypeError(i+" is ambiguous");e[s]=o}var a=r.length,c=r.charAt(0),f=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function l(I){if(I instanceof Uint8Array||(ArrayBuffer.isView(I)?I=new Uint8Array(I.buffer,I.byteOffset,I.byteLength):Array.isArray(I)&&(I=Uint8Array.from(I))),!(I instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(I.length===0)return"";for(var w=0,h=0,E=0,C=I.length;E!==C&&I[E]===0;)E++,w++;for(var x=(C-E)*u+1>>>0,T=new Uint8Array(x);E!==C;){for(var F=I[E],V=0,U=x-1;(F!==0||V<h)&&U!==-1;U--,V++)F+=256*T[U]>>>0,T[U]=F%a>>>0,F=F/a>>>0;if(F!==0)throw new Error("Non-zero carry");h=V,E++}for(var g=x-h;g!==x&&T[g]===0;)g++;for(var v=c.repeat(w);g<x;++g)v+=r.charAt(T[g]);return v}function d(I){if(typeof I!="string")throw new TypeError("Expected String");if(I.length===0)return new Uint8Array;var w=0;if(I[w]!==" "){for(var h=0,E=0;I[w]===c;)h++,w++;for(var C=(I.length-w)*f+1>>>0,x=new Uint8Array(C);I[w];){var T=e[I.charCodeAt(w)];if(T===255)return;for(var F=0,V=C-1;(T!==0||F<E)&&V!==-1;V--,F++)T+=a*x[V]>>>0,x[V]=T%256>>>0,T=T/256>>>0;if(T!==0)throw new Error("Non-zero carry");E=F,w++}if(I[w]!==" "){for(var U=C-E;U!==C&&x[U]===0;)U++;for(var g=new Uint8Array(h+(C-U)),v=h;U!==C;)g[v++]=x[U++];return g}}}function b(I){var w=d(I);if(w)return w;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:d,decode:b}}var gd=md,yd=gd,Xa=yd;var _i=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Li=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){this.name=t,this.prefix=e;let o=e.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Qa(this,t)}},Vi=class{decoders;constructor(t){this.decoders=t}or(t){return Qa(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Qa(r,t){return new Vi({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Pi=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new _i(t,e,n),this.decoder=new Li(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function pr({name:r,prefix:t,encode:e,decode:n}){return new Pi(r,t,e,n)}function Ue({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=Xa(e,r);return pr({prefix:t,name:r,encode:n,decode:i=>me(o(i))})}function wd(r,t,e,n){let o={};for(let u=0;u<t.length;++u)o[t[u]]=u;let i=r.length;for(;r[i-1]==="=";)--i;let s=new Uint8Array(i*e/8|0),a=0,c=0,f=0;for(let u=0;u<i;++u){let l=o[r[u]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<e|l,a+=e,a>=8&&(a-=8,s[f++]=255&c>>a)}if(a>=e||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s}function xd(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,i="",s=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],s+=8;s>e;)s-=e,i+=t[o&a>>s];if(s!==0&&(i+=t[o&a<<e-s]),n)for(;i.length*e&7;)i+="=";return i}function st({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return pr({prefix:t,name:r,encode(o){return xd(o,n,e)},decode(o){return wd(o,n,e,r)}})}var Gt=st({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),bd=st({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),vd=st({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ed=st({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Bd=st({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ad=st({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Sd=st({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Id=st({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),kd=st({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Oi={};kt(Oi,{base58btc:()=>nt,base58flickr:()=>Cd});var nt=Ue({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Cd=Ue({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Mi={};kt(Mi,{base64:()=>Di,base64pad:()=>Td,base64url:()=>Nd,base64urlpad:()=>Ud});var Di=st({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Td=st({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Nd=st({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ud=st({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function Rd(r,t){try{if(typeof r=="string"&&r.length>0)return _d(r);if(typeof r=="number"&&isFinite(r))return t?.long?Vd(r):Ld(r);throw new Error("Value is not a string or number.")}catch(e){let n=Pd(e)?`${e.message}. value=${JSON.stringify(r)}`:"An unknown error has occured.";throw new Error(n)}}function _d(r){if(r=String(r),r.length>100)throw new Error("Value exceeds the maximum length of 100 characters.");let t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(r);if(!t)return NaN;let e=parseFloat(t[1]),n=(t[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return e*315576e5;case"weeks":case"week":case"w":return e*6048e5;case"days":case"day":case"d":return e*864e5;case"hours":case"hour":case"hrs":case"hr":case"h":return e*36e5;case"minutes":case"minute":case"mins":case"min":case"m":return e*6e4;case"seconds":case"second":case"secs":case"sec":case"s":return e*1e3;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return e;default:throw new Error(`The unit ${n} was matched, but no matching case exists.`)}}var Pn=Rd;function Ld(r){let t=Math.abs(r);return t>=864e5?`${Math.round(r/864e5)}d`:t>=36e5?`${Math.round(r/36e5)}h`:t>=6e4?`${Math.round(r/6e4)}m`:t>=1e3?`${Math.round(r/1e3)}s`:`${r}ms`}function Vd(r){let t=Math.abs(r);return t>=864e5?Vn(r,t,864e5,"day"):t>=36e5?Vn(r,t,36e5,"hour"):t>=6e4?Vn(r,t,6e4,"minute"):t>=1e3?Vn(r,t,1e3,"second"):`${r} ms`}function Vn(r,t,e,n){let o=t>=e*1.5;return`${Math.round(r/e)} ${n}${o?"s":""}`}function Pd(r){return typeof r=="object"&&r!==null&&"message"in r}function $i(r){e.debug=e,e.default=e,e.coerce=c,e.disable=i,e.enable=o,e.enabled=s,e.humanize=Pn,e.destroy=f,Object.keys(r).forEach(u=>{e[u]=r[u]}),e.names=[],e.skips=[],e.formatters={};function t(u){let l=0;for(let d=0;d<u.length;d++)l=(l<<5)-l+u.charCodeAt(d),l|=0;return e.colors[Math.abs(l)%e.colors.length]}e.selectColor=t;function e(u){let l,d=null,b,I;function w(...h){if(!w.enabled)return;let E=w,C=Number(new Date),x=C-(l||C);E.diff=x,E.prev=l,E.curr=C,l=C,h[0]=e.coerce(h[0]),typeof h[0]!="string"&&h.unshift("%O");let T=0;h[0]=h[0].replace(/%([a-zA-Z%])/g,(V,U)=>{if(V==="%%")return"%";T++;let g=e.formatters[U];if(typeof g=="function"){let v=h[T];V=g.call(E,v),h.splice(T,1),T--}return V}),e.formatArgs.call(E,h),(E.log||e.log).apply(E,h)}return w.namespace=u,w.useColors=e.useColors(),w.color=e.selectColor(u),w.extend=n,w.destroy=e.destroy,Object.defineProperty(w,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(b!==e.namespaces&&(b=e.namespaces,I=e.enabled(u)),I),set:h=>{d=h}}),typeof e.init=="function"&&e.init(w),w}function n(u,l){let d=e(this.namespace+(typeof l>"u"?":":l)+u);return d.log=this.log,d}function o(u){e.save(u),e.namespaces=u,e.names=[],e.skips=[];let l,d=(typeof u=="string"?u:"").split(/[\s,]+/),b=d.length;for(l=0;l<b;l++)d[l]&&(u=d[l].replace(/\*/g,".*?"),u[0]==="-"?e.skips.push(new RegExp("^"+u.substr(1)+"$")):e.names.push(new RegExp("^"+u+"$")))}function i(){let u=[...e.names.map(a),...e.skips.map(a).map(l=>"-"+l)].join(",");return e.enable(""),u}function s(u){if(u[u.length-1]==="*")return!0;let l,d;for(l=0,d=e.skips.length;l<d;l++)if(e.skips[l].test(u))return!1;for(l=0,d=e.names.length;l<d;l++)if(e.names[l].test(u))return!0;return!1}function a(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}function c(u){return u instanceof Error?u.stack??u.message:u}function f(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return e.setupFormatters(e.formatters),e.enable(e.load()),e}var Fn=Kd(),Fd=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function Od(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/(edge|trident)\/(\d+)/)!=null?!1:typeof document<"u"&&document.documentElement?.style?.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/firefox\/(\d+)/)!=null&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/applewebkit\/(\d+)/)}function Dd(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Pn(this.diff),!this.useColors)return;let t="color: "+this.color;r.splice(1,0,t,"color: inherit");let e=0,n=0;r[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(e++,o==="%c"&&(n=e))}),r.splice(n,0,t)}var Md=console.debug??console.log??(()=>{});function $d(r){try{r?Fn?.setItem("debug",r):Fn?.removeItem("debug")}catch{}}function Hd(){let r;try{r=Fn?.getItem("debug")}catch{}return!r&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(r=globalThis.process.env.DEBUG),r}function Kd(){try{return localStorage}catch{}}function qd(r){r.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}var tc=$i({formatArgs:Dd,save:$d,load:Hd,useColors:Od,setupFormatters:qd,colors:Fd,storage:Fn,log:Md});var _t=tc;_t.formatters.b=r=>r==null?"undefined":nt.baseEncode(r);_t.formatters.t=r=>r==null?"undefined":Gt.baseEncode(r);_t.formatters.m=r=>r==null?"undefined":Di.baseEncode(r);_t.formatters.p=r=>r==null?"undefined":r.toString();_t.formatters.c=r=>r==null?"undefined":r.toString();_t.formatters.k=r=>r==null?"undefined":r.toString();_t.formatters.a=r=>r==null?"undefined":r.toString();_t.formatters.e=r=>r==null?"undefined":ec(r.stack)??ec(r.message)??r.toString();function zd(r){let t=()=>{};return t.enabled=!1,t.color="",t.diff=0,t.log=()=>{},t.namespace=r,t.destroy=()=>!0,t.extend=()=>t,t}function Re(r){let t=zd(`${r}:trace`);return _t.enabled(`${r}:trace`)&&_t.names.map(e=>e.toString()).find(e=>e.includes(":trace"))!=null&&(t=_t(`${r}:trace`)),Object.assign(_t(r),{error:_t(`${r}:error`),trace:t})}function ec(r){if(r!=null&&(r=r.trim(),r.length!==0))return r}var Hi={};kt(Hi,{base36:()=>mr,base36upper:()=>jd});var mr=Ue({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),jd=Ue({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Gd=oc,rc=128,Zd=127,Wd=~Zd,Yd=Math.pow(2,31);function oc(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Yd;)t[e++]=r&255|rc,r/=128;for(;r&Wd;)t[e++]=r&255|rc,r>>>=7;return t[e]=r|0,oc.bytes=e-n+1,t}var Jd=Ki,Xd=128,nc=127;function Ki(r,n){var e=0,n=n||0,o=0,i=n,s,a=r.length;do{if(i>=a)throw Ki.bytes=0,new RangeError("Could not decode varint");s=r[i++],e+=o<28?(s&nc)<<o:(s&nc)*Math.pow(2,o),o+=7}while(s>=Xd);return Ki.bytes=i-n,e}var Qd=Math.pow(2,7),th=Math.pow(2,14),eh=Math.pow(2,21),rh=Math.pow(2,28),nh=Math.pow(2,35),oh=Math.pow(2,42),ih=Math.pow(2,49),sh=Math.pow(2,56),ah=Math.pow(2,63),ch=function(r){return r<Qd?1:r<th?2:r<eh?3:r<rh?4:r<nh?5:r<oh?6:r<ih?7:r<sh?8:r<ah?9:10},uh={encode:Gd,decode:Jd,encodingLength:ch},lh=uh,Zr=lh;function Wr(r,t=0){return[Zr.decode(r,t),Zr.decode.bytes]}function gr(r,t,e=0){return Zr.encode(r,t,e),t}function yr(r){return Zr.encodingLength(r)}function Zt(r,t){let e=t.byteLength,n=yr(r),o=n+yr(e),i=new Uint8Array(o+e);return gr(r,i,0),gr(e,i,n),i.set(t,o),new wr(r,e,t,i)}function ge(r){let t=me(r),[e,n]=Wr(t),[o,i]=Wr(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new wr(e,o,s,t)}function ic(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Za(r.bytes,e.bytes)}}var wr=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function sc(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return dh(e,qi(r),t??nt.encoder);default:return hh(e,qi(r),t??Gt.encoder)}}var ac=new WeakMap;function qi(r){let t=ac.get(r);if(t==null){let e=new Map;return ac.set(r,e),e}return t}var Q=class r{code;version;multihash;bytes;"/";constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==Yr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==ph)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=Zt(t,e);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&ic(t.multihash,n.multihash)}toString(t){return sc(this,t)}toJSON(){return{"/":sc(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:i,bytes:s}=e;return new r(n,o,i,s??cc(n,o,i.bytes))}else if(e[mh]===!0){let{version:n,multihash:o,code:i}=e,s=ge(o);return r.create(n,i,s)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==Yr)throw new Error(`Version 0 CID must use dag-pb (code: ${Yr}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=cc(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Yr,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=me(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let i=o.subarray(e.multihashSize-e.digestSize),s=new wr(e.multihashCode,e.digestSize,i,o);return[e.version===0?r.createV0(s):r.createV1(e.codec,s),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[l,d]=Wr(t.subarray(e));return e+=d,l},o=n(),i=Yr;if(o===18?(o=0,e=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=e,a=n(),c=n(),f=e+c,u=f-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:u,size:f}}static parse(t,e){let[n,o]=fh(t,e),i=r.decode(o);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return qi(i).set(n,t),i}};function fh(r,t){switch(r[0]){case"Q":{let e=t??nt;return[nt.prefix,e.decode(`${nt.prefix}${r}`)]}case nt.prefix:{let e=t??nt;return[nt.prefix,e.decode(r)]}case Gt.prefix:{let e=t??Gt;return[Gt.prefix,e.decode(r)]}case mr.prefix:{let e=t??mr;return[mr.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function dh(r,t,e){let{prefix:n}=e;if(n!==nt.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let i=e.encode(r).slice(1);return t.set(n,i),i}else return o}function hh(r,t,e){let{prefix:n}=e,o=t.get(n);if(o==null){let i=e.encode(r);return t.set(n,i),i}else return o}var Yr=112,ph=18;function cc(r,t,e){let n=yr(r),o=n+yr(t),i=new Uint8Array(o+e.byteLength);return gr(r,i,0),gr(t,i,n),i.set(e,o),i}var mh=Symbol.for("@ipld/js-cid/CID");var zi={};kt(zi,{identity:()=>Wt});var uc=0,gh="identity",lc=me;function yh(r){return Zt(uc,lc(r))}var Wt={code:uc,name:gh,encode:lc,digest:yh};function ct(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function fc(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`positive integer expected, not ${r}`)}function wh(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function xr(r,...t){if(!wh(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${r.length}`)}function dc(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");fc(r.outputLen),fc(r.blockLen)}function br(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function hc(r,t){xr(r);let e=t.outputLen;if(r.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}var We=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var Dn=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),Yt=(r,t)=>r<<32-t|r>>>t;var Hg=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function pc(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Jr(r){return typeof r=="string"&&(r=pc(r)),xr(r),r}function ji(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];xr(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let i=r[n];e.set(i,o),o+=i.length}return e}var vr=class{clone(){return this._cloneInto()}},Kg={}.toString;function Mn(r){let t=n=>r().update(Jr(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function $n(r=32){if(We&&typeof We.getRandomValues=="function")return We.getRandomValues(new Uint8Array(r));if(We&&typeof We.randomBytes=="function")return We.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function xh(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let o=BigInt(32),i=BigInt(4294967295),s=Number(e>>o&i),a=Number(e&i),c=n?4:0,f=n?0:4;r.setUint32(t+c,s,n),r.setUint32(t+f,a,n)}var mc=(r,t,e)=>r&t^~r&e,gc=(r,t,e)=>r&t^r&e^t&e,Er=class extends vr{constructor(t,e,n,o){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Dn(this.buffer)}update(t){br(this);let{view:e,buffer:n,blockLen:o}=this;t=Jr(t);let i=t.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let c=Dn(t);for(;o<=i-s;s+=o)this.process(c,s);continue}n.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){br(this),hc(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;e[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>o-s&&(this.process(n,0),s=0);for(let l=s;l<o;l++)e[l]=0;xh(n,o-8,BigInt(this.length*8),i),this.process(n,0);let a=Dn(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=c/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<f;l++)a.setUint32(4*l,u[l],i)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:o,finished:i,destroyed:s,pos:a}=this;return t.length=o,t.pos=a,t.finished=i,t.destroyed=s,o%e&&t.buffer.set(n),t}};var Hn=BigInt(4294967295),Gi=BigInt(32);function yc(r,t=!1){return t?{h:Number(r&Hn),l:Number(r>>Gi&Hn)}:{h:Number(r>>Gi&Hn)|0,l:Number(r&Hn)|0}}function bh(r,t=!1){let e=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let o=0;o<r.length;o++){let{h:i,l:s}=yc(r[o],t);[e[o],n[o]]=[i,s]}return[e,n]}var vh=(r,t)=>BigInt(r>>>0)<<Gi|BigInt(t>>>0),Eh=(r,t,e)=>r>>>e,Bh=(r,t,e)=>r<<32-e|t>>>e,Ah=(r,t,e)=>r>>>e|t<<32-e,Sh=(r,t,e)=>r<<32-e|t>>>e,Ih=(r,t,e)=>r<<64-e|t>>>e-32,kh=(r,t,e)=>r>>>e-32|t<<64-e,Ch=(r,t)=>t,Th=(r,t)=>r,Nh=(r,t,e)=>r<<e|t>>>32-e,Uh=(r,t,e)=>t<<e|r>>>32-e,Rh=(r,t,e)=>t<<e-32|r>>>64-e,_h=(r,t,e)=>r<<e-32|t>>>64-e;function Lh(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var Vh=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),Ph=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,Fh=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),Oh=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,Dh=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),Mh=(r,t,e,n,o,i)=>t+e+n+o+i+(r/2**32|0)|0;var $h={fromBig:yc,split:bh,toBig:vh,shrSH:Eh,shrSL:Bh,rotrSH:Ah,rotrSL:Sh,rotrBH:Ih,rotrBL:kh,rotr32H:Ch,rotr32L:Th,rotlSH:Nh,rotlSL:Uh,rotlBH:Rh,rotlBL:_h,add:Lh,add3L:Vh,add3H:Ph,add4L:Fh,add4H:Oh,add5H:Mh,add5L:Dh},K=$h;var[Hh,Kh]=K.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),Le=new Uint32Array(80),Ve=new Uint32Array(80),Zi=class extends Er{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:t,Al:e,Bh:n,Bl:o,Ch:i,Cl:s,Dh:a,Dl:c,Eh:f,El:u,Fh:l,Fl:d,Gh:b,Gl:I,Hh:w,Hl:h}=this;return[t,e,n,o,i,s,a,c,f,u,l,d,b,I,w,h]}set(t,e,n,o,i,s,a,c,f,u,l,d,b,I,w,h){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=u|0,this.Fh=l|0,this.Fl=d|0,this.Gh=b|0,this.Gl=I|0,this.Hh=w|0,this.Hl=h|0}process(t,e){for(let x=0;x<16;x++,e+=4)Le[x]=t.getUint32(e),Ve[x]=t.getUint32(e+=4);for(let x=16;x<80;x++){let T=Le[x-15]|0,F=Ve[x-15]|0,V=K.rotrSH(T,F,1)^K.rotrSH(T,F,8)^K.shrSH(T,F,7),U=K.rotrSL(T,F,1)^K.rotrSL(T,F,8)^K.shrSL(T,F,7),g=Le[x-2]|0,v=Ve[x-2]|0,O=K.rotrSH(g,v,19)^K.rotrBH(g,v,61)^K.shrSH(g,v,6),R=K.rotrSL(g,v,19)^K.rotrBL(g,v,61)^K.shrSL(g,v,6),N=K.add4L(U,R,Ve[x-7],Ve[x-16]),H=K.add4H(N,V,O,Le[x-7],Le[x-16]);Le[x]=H|0,Ve[x]=N|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:f,Dl:u,Eh:l,El:d,Fh:b,Fl:I,Gh:w,Gl:h,Hh:E,Hl:C}=this;for(let x=0;x<80;x++){let T=K.rotrSH(l,d,14)^K.rotrSH(l,d,18)^K.rotrBH(l,d,41),F=K.rotrSL(l,d,14)^K.rotrSL(l,d,18)^K.rotrBL(l,d,41),V=l&b^~l&w,U=d&I^~d&h,g=K.add5L(C,F,U,Kh[x],Ve[x]),v=K.add5H(g,E,T,V,Hh[x],Le[x]),O=g|0,R=K.rotrSH(n,o,28)^K.rotrBH(n,o,34)^K.rotrBH(n,o,39),N=K.rotrSL(n,o,28)^K.rotrBL(n,o,34)^K.rotrBL(n,o,39),H=n&i^n&a^i&a,A=o&s^o&c^s&c;E=w|0,C=h|0,w=b|0,h=I|0,b=l|0,I=d|0,{h:l,l:d}=K.add(f|0,u|0,v|0,O|0),f=a|0,u=c|0,a=i|0,c=s|0,i=n|0,s=o|0;let S=K.add3L(O,N,A);n=K.add3H(S,v,R,H),o=S|0}({h:n,l:o}=K.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=K.add(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=K.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:u}=K.add(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:d}=K.add(this.Eh|0,this.El|0,l|0,d|0),{h:b,l:I}=K.add(this.Fh|0,this.Fl|0,b|0,I|0),{h:w,l:h}=K.add(this.Gh|0,this.Gl|0,w|0,h|0),{h:E,l:C}=K.add(this.Hh|0,this.Hl|0,E|0,C|0),this.set(n,o,i,s,a,c,f,u,l,d,b,I,w,h,E,C)}roundClean(){Le.fill(0),Ve.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var wc=Mn(()=>new Zi);var qn={};kt(qn,{aInRange:()=>Lt,abool:()=>Jt,abytes:()=>Br,bitGet:()=>Wh,bitLen:()=>Qi,bitMask:()=>Qr,bitSet:()=>Yh,bytesToHex:()=>we,bytesToNumberBE:()=>xe,bytesToNumberLE:()=>Fe,concatBytes:()=>be,createHmacDrbg:()=>ts,ensureBytes:()=>at,equalBytes:()=>Gh,hexToBytes:()=>Je,hexToNumber:()=>Xi,inRange:()=>Xr,isBytes:()=>Pe,memoized:()=>Qe,notImplemented:()=>Xh,numberToBytesBE:()=>Oe,numberToBytesLE:()=>Xe,numberToHexUnpadded:()=>Ye,numberToVarBytesBE:()=>jh,utf8ToBytes:()=>Zh,validateObject:()=>ae});var Ji=BigInt(0),Kn=BigInt(1),qh=BigInt(2);function Pe(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Br(r){if(!Pe(r))throw new Error("Uint8Array expected")}function Jt(r,t){if(typeof t!="boolean")throw new Error(`${r} must be valid boolean, got "${t}".`)}var zh=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function we(r){Br(r);let t="";for(let e=0;e<r.length;e++)t+=zh[r[e]];return t}function Ye(r){let t=r.toString(16);return t.length&1?`0${t}`:t}function Xi(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var ye={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function xc(r){if(r>=ye._0&&r<=ye._9)return r-ye._0;if(r>=ye._A&&r<=ye._F)return r-(ye._A-10);if(r>=ye._a&&r<=ye._f)return r-(ye._a-10)}function Je(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let t=r.length,e=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let o=0,i=0;o<e;o++,i+=2){let s=xc(r.charCodeAt(i)),a=xc(r.charCodeAt(i+1));if(s===void 0||a===void 0){let c=r[i]+r[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}n[o]=s*16+a}return n}function xe(r){return Xi(we(r))}function Fe(r){return Br(r),Xi(we(Uint8Array.from(r).reverse()))}function Oe(r,t){return Je(r.toString(16).padStart(t*2,"0"))}function Xe(r,t){return Oe(r,t).reverse()}function jh(r){return Je(Ye(r))}function at(r,t,e){let n;if(typeof t=="string")try{n=Je(t)}catch(i){throw new Error(`${r} must be valid hex string, got "${t}". Cause: ${i}`)}else if(Pe(t))n=Uint8Array.from(t);else throw new Error(`${r} must be hex string or Uint8Array`);let o=n.length;if(typeof e=="number"&&o!==e)throw new Error(`${r} expected ${e} bytes, got ${o}`);return n}function be(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];Br(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let i=r[n];e.set(i,o),o+=i.length}return e}function Gh(r,t){if(r.length!==t.length)return!1;let e=0;for(let n=0;n<r.length;n++)e|=r[n]^t[n];return e===0}function Zh(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}var Wi=r=>typeof r=="bigint"&&Ji<=r;function Xr(r,t,e){return Wi(r)&&Wi(t)&&Wi(e)&&t<=r&&r<e}function Lt(r,t,e,n){if(!Xr(t,e,n))throw new Error(`expected valid ${r}: ${e} <= n < ${n}, got ${typeof t} ${t}`)}function Qi(r){let t;for(t=0;r>Ji;r>>=Kn,t+=1);return t}function Wh(r,t){return r>>BigInt(t)&Kn}function Yh(r,t,e){return r|(e?Kn:Ji)<<BigInt(t)}var Qr=r=>(qh<<BigInt(r-1))-Kn,Yi=r=>new Uint8Array(r),bc=r=>Uint8Array.from(r);function ts(r,t,e){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let n=Yi(r),o=Yi(r),i=0,s=()=>{n.fill(1),o.fill(0),i=0},a=(...l)=>e(o,n,...l),c=(l=Yi())=>{o=a(bc([0]),l),n=a(),l.length!==0&&(o=a(bc([1]),l),n=a())},f=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,d=[];for(;l<t;){n=a();let b=n.slice();d.push(b),l+=n.length}return be(...d)};return(l,d)=>{s(),c(l);let b;for(;!(b=d(f()));)c();return s(),b}}var Jh={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||Pe(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,t)=>t.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function ae(r,t,e={}){let n=(o,i,s)=>{let a=Jh[i];if(typeof a!="function")throw new Error(`Invalid validator "${i}", expected function`);let c=r[o];if(!(s&&c===void 0)&&!a(c,r))throw new Error(`Invalid param ${String(o)}=${c} (${typeof c}), expected ${i}`)};for(let[o,i]of Object.entries(t))n(o,i,!1);for(let[o,i]of Object.entries(e))n(o,i,!0);return r}var Xh=()=>{throw new Error("not implemented")};function Qe(r){let t=new WeakMap;return(e,...n)=>{let o=t.get(e);if(o!==void 0)return o;let i=r(e,...n);return t.set(e,i),i}}var ft=BigInt(0),ot=BigInt(1),tr=BigInt(2),Qh=BigInt(3),es=BigInt(4),vc=BigInt(5),Ec=BigInt(8),t0=BigInt(9),e0=BigInt(16);function tt(r,t){let e=r%t;return e>=ft?e:t+e}function r0(r,t,e){if(e<=ft||t<ft)throw new Error("Expected power/modulo > 0");if(e===ot)return ft;let n=ot;for(;t>ft;)t&ot&&(n=n*r%e),r=r*r%e,t>>=ot;return n}function it(r,t,e){let n=r;for(;t-- >ft;)n*=n,n%=e;return n}function zn(r,t){if(r===ft||t<=ft)throw new Error(`invert: expected positive integers, got n=${r} mod=${t}`);let e=tt(r,t),n=t,o=ft,i=ot,s=ot,a=ft;for(;e!==ft;){let f=n/e,u=n%e,l=o-s*f,d=i-a*f;n=e,e=u,o=s,i=a,s=l,a=d}if(n!==ot)throw new Error("invert: does not exist");return tt(o,t)}function n0(r){let t=(r-ot)/tr,e,n,o;for(e=r-ot,n=0;e%tr===ft;e/=tr,n++);for(o=tr;o<r&&r0(o,t,r)!==r-ot;o++);if(n===1){let s=(r+ot)/es;return function(c,f){let u=c.pow(f,s);if(!c.eql(c.sqr(u),f))throw new Error("Cannot find square root");return u}}let i=(e+ot)/tr;return function(a,c){if(a.pow(c,t)===a.neg(a.ONE))throw new Error("Cannot find square root");let f=n,u=a.pow(a.mul(a.ONE,o),e),l=a.pow(c,i),d=a.pow(c,e);for(;!a.eql(d,a.ONE);){if(a.eql(d,a.ZERO))return a.ZERO;let b=1;for(let w=a.sqr(d);b<f&&!a.eql(w,a.ONE);b++)w=a.sqr(w);let I=a.pow(u,ot<<BigInt(f-b-1));u=a.sqr(I),l=a.mul(l,I),d=a.mul(d,u),f=b}return l}}function o0(r){if(r%es===Qh){let t=(r+ot)/es;return function(n,o){let i=n.pow(o,t);if(!n.eql(n.sqr(i),o))throw new Error("Cannot find square root");return i}}if(r%Ec===vc){let t=(r-vc)/Ec;return function(n,o){let i=n.mul(o,tr),s=n.pow(i,t),a=n.mul(o,s),c=n.mul(n.mul(a,tr),s),f=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(f),o))throw new Error("Cannot find square root");return f}}return r%e0,n0(r)}var Bc=(r,t)=>(tt(r,t)&ot)===ot,i0=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function rs(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=i0.reduce((n,o)=>(n[o]="function",n),t);return ae(r,e)}function s0(r,t,e){if(e<ft)throw new Error("Expected power > 0");if(e===ft)return r.ONE;if(e===ot)return t;let n=r.ONE,o=t;for(;e>ft;)e&ot&&(n=r.mul(n,o)),o=r.sqr(o),e>>=ot;return n}function a0(r,t){let e=new Array(t.length),n=t.reduce((i,s,a)=>r.is0(s)?i:(e[a]=i,r.mul(i,s)),r.ONE),o=r.inv(n);return t.reduceRight((i,s,a)=>r.is0(s)?i:(e[a]=r.mul(i,e[a]),r.mul(i,s)),o),e}function ns(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function De(r,t,e=!1,n={}){if(r<=ft)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:o,nByteLength:i}=ns(r,t);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=o0(r),a=Object.freeze({ORDER:r,BITS:o,BYTES:i,MASK:Qr(o),ZERO:ft,ONE:ot,create:c=>tt(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return ft<=c&&c<r},is0:c=>c===ft,isOdd:c=>(c&ot)===ot,neg:c=>tt(-c,r),eql:(c,f)=>c===f,sqr:c=>tt(c*c,r),add:(c,f)=>tt(c+f,r),sub:(c,f)=>tt(c-f,r),mul:(c,f)=>tt(c*f,r),pow:(c,f)=>s0(a,c,f),div:(c,f)=>tt(c*zn(f,r),r),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>zn(c,r),sqrt:n.sqrt||(c=>s(a,c)),invertBatch:c=>a0(a,c),cmov:(c,f,u)=>u?f:c,toBytes:c=>e?Xe(c,i):Oe(c,i),fromBytes:c=>{if(c.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${c.length}`);return e?Fe(c):xe(c)}});return Object.freeze(a)}function Ac(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let t=r.toString(2).length;return Math.ceil(t/8)}function os(r){let t=Ac(r);return t+Math.ceil(t/2)}function Sc(r,t,e=!1){let n=r.length,o=Ac(t),i=os(t);if(n<16||n<i||n>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${n}`);let s=e?xe(r):Fe(r),a=tt(s,t-ot)+ot;return e?Xe(a,o):Oe(a,o)}var u0=BigInt(0),is=BigInt(1),ss=new WeakMap,Ic=new WeakMap;function jn(r,t){let e=(i,s)=>{let a=s.negate();return i?a:s},n=i=>{if(!Number.isSafeInteger(i)||i<=0||i>t)throw new Error(`Wrong window size=${i}, should be [1..${t}]`)},o=i=>{n(i);let s=Math.ceil(t/i)+1,a=2**(i-1);return{windows:s,windowSize:a}};return{constTimeNegate:e,unsafeLadder(i,s){let a=r.ZERO,c=i;for(;s>u0;)s&is&&(a=a.add(c)),c=c.double(),s>>=is;return a},precomputeWindow(i,s){let{windows:a,windowSize:c}=o(s),f=[],u=i,l=u;for(let d=0;d<a;d++){l=u,f.push(l);for(let b=1;b<c;b++)l=l.add(u),f.push(l);u=l.double()}return f},wNAF(i,s,a){let{windows:c,windowSize:f}=o(i),u=r.ZERO,l=r.BASE,d=BigInt(2**i-1),b=2**i,I=BigInt(i);for(let w=0;w<c;w++){let h=w*f,E=Number(a&d);a>>=I,E>f&&(E-=b,a+=is);let C=h,x=h+Math.abs(E)-1,T=w%2!==0,F=E<0;E===0?l=l.add(e(T,s[C])):u=u.add(e(F,s[x]))}return{p:u,f:l}},wNAFCached(i,s,a){let c=Ic.get(i)||1,f=ss.get(i);return f||(f=this.precomputeWindow(i,c),c!==1&&ss.set(i,a(f))),this.wNAF(c,f,s)},setWindowSize(i,s){n(s),Ic.set(i,s),ss.delete(i)}}}function Gn(r,t,e,n){if(!Array.isArray(e)||!Array.isArray(n)||n.length!==e.length)throw new Error("arrays of points and scalars must have equal length");n.forEach((u,l)=>{if(!t.isValid(u))throw new Error(`wrong scalar at index ${l}`)}),e.forEach((u,l)=>{if(!(u instanceof r))throw new Error(`wrong point at index ${l}`)});let o=Qi(BigInt(e.length)),i=o>12?o-3:o>4?o-2:o?2:1,s=(1<<i)-1,a=new Array(s+1).fill(r.ZERO),c=Math.floor((t.BITS-1)/i)*i,f=r.ZERO;for(let u=c;u>=0;u-=i){a.fill(r.ZERO);for(let d=0;d<n.length;d++){let b=n[d],I=Number(b>>BigInt(u)&BigInt(s));a[I]=a[I].add(e[d])}let l=r.ZERO;for(let d=a.length-1,b=r.ZERO;d>0;d--)b=b.add(a[d]),l=l.add(b);if(f=f.add(l),u!==0)for(let d=0;d<i;d++)f=f.double()}return f}function tn(r){return rs(r.Fp),ae(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...ns(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Xt=BigInt(0),Vt=BigInt(1),Zn=BigInt(2),l0=BigInt(8),f0={zip215:!0};function d0(r){let t=tn(r);return ae(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function kc(r){let t=d0(r),{Fp:e,n,prehash:o,hash:i,randomBytes:s,nByteLength:a,h:c}=t,f=Zn<<BigInt(a*8)-Vt,u=e.create,l=De(t.n,t.nBitLength),d=t.uvRatio||((m,p)=>{try{return{isValid:!0,value:e.sqrt(m*e.inv(p))}}catch{return{isValid:!1,value:Xt}}}),b=t.adjustScalarBytes||(m=>m),I=t.domain||((m,p,B)=>{if(Jt("phflag",B),p.length||B)throw new Error("Contexts/pre-hash are not supported");return m});function w(m,p){Lt("coordinate "+m,p,Xt,f)}function h(m){if(!(m instanceof x))throw new Error("ExtendedPoint expected")}let E=Qe((m,p)=>{let{ex:B,ey:P,ez:D}=m,M=m.is0();p==null&&(p=M?l0:e.inv(D));let q=u(B*p),G=u(P*p),z=u(D*p);if(M)return{x:Xt,y:Vt};if(z!==Vt)throw new Error("invZ was invalid");return{x:q,y:G}}),C=Qe(m=>{let{a:p,d:B}=t;if(m.is0())throw new Error("bad point: ZERO");let{ex:P,ey:D,ez:M,et:q}=m,G=u(P*P),z=u(D*D),X=u(M*M),rt=u(X*X),ht=u(G*p),pt=u(X*u(ht+z)),yt=u(rt+u(B*u(G*z)));if(pt!==yt)throw new Error("bad point: equation left != right (1)");let It=u(P*D),lt=u(M*q);if(It!==lt)throw new Error("bad point: equation left != right (2)");return!0});class x{constructor(p,B,P,D){this.ex=p,this.ey=B,this.ez=P,this.et=D,w("x",p),w("y",B),w("z",P),w("t",D),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(p){if(p instanceof x)throw new Error("extended point not allowed");let{x:B,y:P}=p||{};return w("x",B),w("y",P),new x(B,P,Vt,u(B*P))}static normalizeZ(p){let B=e.invertBatch(p.map(P=>P.ez));return p.map((P,D)=>P.toAffine(B[D])).map(x.fromAffine)}static msm(p,B){return Gn(x,l,p,B)}_setWindowSize(p){V.setWindowSize(this,p)}assertValidity(){C(this)}equals(p){h(p);let{ex:B,ey:P,ez:D}=this,{ex:M,ey:q,ez:G}=p,z=u(B*G),X=u(M*D),rt=u(P*G),ht=u(q*D);return z===X&&rt===ht}is0(){return this.equals(x.ZERO)}negate(){return new x(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:p}=t,{ex:B,ey:P,ez:D}=this,M=u(B*B),q=u(P*P),G=u(Zn*u(D*D)),z=u(p*M),X=B+P,rt=u(u(X*X)-M-q),ht=z+q,pt=ht-G,yt=z-q,It=u(rt*pt),lt=u(ht*yt),Ut=u(rt*yt),pe=u(pt*ht);return new x(It,lt,pe,Ut)}add(p){h(p);let{a:B,d:P}=t,{ex:D,ey:M,ez:q,et:G}=this,{ex:z,ey:X,ez:rt,et:ht}=p;if(B===BigInt(-1)){let Oa=u((M-D)*(X+z)),Da=u((M+D)*(X-z)),Ni=u(Da-Oa);if(Ni===Xt)return this.double();let Ma=u(q*Zn*ht),$a=u(G*Zn*rt),Ha=$a+Ma,Ka=Da+Oa,qa=$a-Ma,id=u(Ha*Ni),sd=u(Ka*qa),ad=u(Ha*qa),cd=u(Ni*Ka);return new x(id,sd,cd,ad)}let pt=u(D*z),yt=u(M*X),It=u(G*P*ht),lt=u(q*rt),Ut=u((D+M)*(z+X)-pt-yt),pe=lt-It,jr=lt+It,Gr=u(yt-B*pt),ed=u(Ut*pe),rd=u(jr*Gr),nd=u(Ut*Gr),od=u(pe*jr);return new x(ed,rd,od,nd)}subtract(p){return this.add(p.negate())}wNAF(p){return V.wNAFCached(this,p,x.normalizeZ)}multiply(p){let B=p;Lt("scalar",B,Vt,n);let{p:P,f:D}=this.wNAF(B);return x.normalizeZ([P,D])[0]}multiplyUnsafe(p){let B=p;return Lt("scalar",B,Xt,n),B===Xt?F:this.equals(F)||B===Vt?this:this.equals(T)?this.wNAF(B).p:V.unsafeLadder(this,B)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return V.unsafeLadder(this,n).is0()}toAffine(p){return E(this,p)}clearCofactor(){let{h:p}=t;return p===Vt?this:this.multiplyUnsafe(p)}static fromHex(p,B=!1){let{d:P,a:D}=t,M=e.BYTES;p=at("pointHex",p,M),Jt("zip215",B);let q=p.slice(),G=p[M-1];q[M-1]=G&-129;let z=Fe(q),X=B?f:e.ORDER;Lt("pointHex.y",z,Xt,X);let rt=u(z*z),ht=u(rt-Vt),pt=u(P*rt-D),{isValid:yt,value:It}=d(ht,pt);if(!yt)throw new Error("Point.fromHex: invalid y coordinate");let lt=(It&Vt)===Vt,Ut=(G&128)!==0;if(!B&&It===Xt&&Ut)throw new Error("Point.fromHex: x=0 and x_0=1");return Ut!==lt&&(It=u(-It)),x.fromAffine({x:It,y:z})}static fromPrivateKey(p){return v(p).point}toRawBytes(){let{x:p,y:B}=this.toAffine(),P=Xe(B,e.BYTES);return P[P.length-1]|=p&Vt?128:0,P}toHex(){return we(this.toRawBytes())}}x.BASE=new x(t.Gx,t.Gy,Vt,u(t.Gx*t.Gy)),x.ZERO=new x(Xt,Vt,Vt,Xt);let{BASE:T,ZERO:F}=x,V=jn(x,a*8);function U(m){return tt(m,n)}function g(m){return U(Fe(m))}function v(m){let p=a;m=at("private key",m,p);let B=at("hashed private key",i(m),2*p),P=b(B.slice(0,p)),D=B.slice(p,2*p),M=g(P),q=T.multiply(M),G=q.toRawBytes();return{head:P,prefix:D,scalar:M,point:q,pointBytes:G}}function O(m){return v(m).pointBytes}function R(m=new Uint8Array,...p){let B=be(...p);return g(i(I(B,at("context",m),!!o)))}function N(m,p,B={}){m=at("message",m),o&&(m=o(m));let{prefix:P,scalar:D,pointBytes:M}=v(p),q=R(B.context,P,m),G=T.multiply(q).toRawBytes(),z=R(B.context,G,M,m),X=U(q+z*D);Lt("signature.s",X,Xt,n);let rt=be(G,Xe(X,e.BYTES));return at("result",rt,a*2)}let H=f0;function A(m,p,B,P=H){let{context:D,zip215:M}=P,q=e.BYTES;m=at("signature",m,2*q),p=at("message",p),M!==void 0&&Jt("zip215",M),o&&(p=o(p));let G=Fe(m.slice(q,2*q)),z,X,rt;try{z=x.fromHex(B,M),X=x.fromHex(m.slice(0,q),M),rt=T.multiplyUnsafe(G)}catch{return!1}if(!M&&z.isSmallOrder())return!1;let ht=R(D,X.toRawBytes(),z.toRawBytes(),p);return X.add(z.multiplyUnsafe(ht)).subtract(rt).clearCofactor().equals(x.ZERO)}return T._setWindowSize(8),{CURVE:t,getPublicKey:O,sign:N,verify:A,ExtendedPoint:x,utils:{getExtendedPublicKey:v,randomPrivateKey:()=>s(e.BYTES),precompute(m=8,p=x.BASE){return p._setWindowSize(m),p.multiply(BigInt(3)),p}}}}var as=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Cc=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),dy=BigInt(0),h0=BigInt(1),Tc=BigInt(2),hy=BigInt(3),p0=BigInt(5),m0=BigInt(8);function g0(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),i=as,a=r*r%i*r%i,c=it(a,Tc,i)*a%i,f=it(c,h0,i)*r%i,u=it(f,p0,i)*f%i,l=it(u,t,i)*u%i,d=it(l,e,i)*l%i,b=it(d,n,i)*d%i,I=it(b,o,i)*b%i,w=it(I,o,i)*b%i,h=it(w,t,i)*u%i;return{pow_p_5_8:it(h,Tc,i)*r%i,b2:a}}function y0(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function w0(r,t){let e=as,n=tt(t*t*t,e),o=tt(n*n*t,e),i=g0(r*o).pow_p_5_8,s=tt(r*n*i,e),a=tt(t*s*s,e),c=s,f=tt(s*Cc,e),u=a===r,l=a===tt(-r,e),d=a===tt(-r*Cc,e);return u&&(s=c),(l||d)&&(s=f),Bc(s,e)&&(s=tt(-s,e)),{isValid:u||l,value:s}}var x0=De(as,void 0,!0),b0={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:x0,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:m0,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:wc,randomBytes:$n,adjustScalarBytes:y0,uvRatio:w0},Nc=kc(b0);var Wn=32;function Uc(r,t,e){return Nc.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}var Yn=class{type="Ed25519";raw;constructor(t){this.raw=cs(t,Wn)}toMultihash(){return Wt.digest(Jn(this))}toCID(){return Q.createV1(114,this.toMultihash())}toString(){return nt.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ct(this.raw,t.raw)}verify(t,e){return Uc(this.raw,e,t)}};function us(r){return r=cs(r,Wn),new Yn(r)}function cs(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new vt(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}function Qt(r=0){return new Uint8Array(r)}var E0=Math.pow(2,7),B0=Math.pow(2,14),A0=Math.pow(2,21),ls=Math.pow(2,28),fs=Math.pow(2,35),ds=Math.pow(2,42),hs=Math.pow(2,49),J=128,Et=127;function Pt(r){if(r<E0)return 1;if(r<B0)return 2;if(r<A0)return 3;if(r<ls)return 4;if(r<fs)return 5;if(r<ds)return 6;if(r<hs)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function ps(r,t,e=0){switch(Pt(r)){case 8:t[e++]=r&255|J,r/=128;case 7:t[e++]=r&255|J,r/=128;case 6:t[e++]=r&255|J,r/=128;case 5:t[e++]=r&255|J,r/=128;case 4:t[e++]=r&255|J,r>>>=7;case 3:t[e++]=r&255|J,r>>>=7;case 2:t[e++]=r&255|J,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function S0(r,t,e=0){switch(Pt(r)){case 8:t.set(e++,r&255|J),r/=128;case 7:t.set(e++,r&255|J),r/=128;case 6:t.set(e++,r&255|J),r/=128;case 5:t.set(e++,r&255|J),r/=128;case 4:t.set(e++,r&255|J),r>>>=7;case 3:t.set(e++,r&255|J),r>>>=7;case 2:t.set(e++,r&255|J),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function ms(r,t){let e=r[t],n=0;if(n+=e&Et,e<J||(e=r[t+1],n+=(e&Et)<<7,e<J)||(e=r[t+2],n+=(e&Et)<<14,e<J)||(e=r[t+3],n+=(e&Et)<<21,e<J)||(e=r[t+4],n+=(e&Et)*ls,e<J)||(e=r[t+5],n+=(e&Et)*fs,e<J)||(e=r[t+6],n+=(e&Et)*ds,e<J)||(e=r[t+7],n+=(e&Et)*hs,e<J))return n;throw new RangeError("Could not decode varint")}function I0(r,t){let e=r.get(t),n=0;if(n+=e&Et,e<J||(e=r.get(t+1),n+=(e&Et)<<7,e<J)||(e=r.get(t+2),n+=(e&Et)<<14,e<J)||(e=r.get(t+3),n+=(e&Et)<<21,e<J)||(e=r.get(t+4),n+=(e&Et)*ls,e<J)||(e=r.get(t+5),n+=(e&Et)*fs,e<J)||(e=r.get(t+6),n+=(e&Et)*ds,e<J)||(e=r.get(t+7),n+=(e&Et)*hs,e<J))return n;throw new RangeError("Could not decode varint")}function Ar(r,t,e=0){return t==null&&(t=Qt(Pt(r))),t instanceof Uint8Array?ps(r,t,e):S0(r,t,e)}function er(r,t=0){return r instanceof Uint8Array?ms(r,t):I0(r,t)}var gs=new Float32Array([-0]),Me=new Uint8Array(gs.buffer);function Lc(r,t,e){gs[0]=r,t[e]=Me[0],t[e+1]=Me[1],t[e+2]=Me[2],t[e+3]=Me[3]}function Vc(r,t){return Me[0]=r[t],Me[1]=r[t+1],Me[2]=r[t+2],Me[3]=r[t+3],gs[0]}var ys=new Float64Array([-0]),Bt=new Uint8Array(ys.buffer);function Pc(r,t,e){ys[0]=r,t[e]=Bt[0],t[e+1]=Bt[1],t[e+2]=Bt[2],t[e+3]=Bt[3],t[e+4]=Bt[4],t[e+5]=Bt[5],t[e+6]=Bt[6],t[e+7]=Bt[7]}function Fc(r,t){return Bt[0]=r[t],Bt[1]=r[t+1],Bt[2]=r[t+2],Bt[3]=r[t+3],Bt[4]=r[t+4],Bt[5]=r[t+5],Bt[6]=r[t+6],Bt[7]=r[t+7],ys[0]}var k0=BigInt(Number.MAX_SAFE_INTEGER),C0=BigInt(Number.MIN_SAFE_INTEGER),Ot=class r{lo;hi;constructor(t,e){this.lo=t|0,this.hi=e|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(e+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return rr;if(t<k0&&t>C0)return this.fromNumber(Number(t));let e=t<0n;e&&(t=-t);let n=t>>32n,o=t-(n<<32n);return e&&(n=~n|0n,o=~o|0n,++o>Oc&&(o=0n,++n>Oc&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return rr;let e=t<0;e&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return e&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}static from(t){return typeof t=="number"?r.fromNumber(t):typeof t=="bigint"?r.fromBigInt(t):typeof t=="string"?r.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new r(t.low>>>0,t.high>>>0):rr}},rr=new Ot(0,0);rr.toBigInt=function(){return 0n};rr.zzEncode=rr.zzDecode=function(){return this};rr.length=function(){return 1};var Oc=4294967296n;function Dc(r){let t=0,e=0;for(let n=0;n<r.length;++n)e=r.charCodeAt(n),e<128?t+=1:e<2048?t+=2:(e&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function Mc(r,t,e){if(e-t<1)return"";let o,i=[],s=0,a;for(;t<e;)a=r[t++],a<128?i[s++]=a:a>191&&a<224?i[s++]=(a&31)<<6|r[t++]&63:a>239&&a<365?(a=((a&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,i[s++]=55296+(a>>10),i[s++]=56320+(a&1023)):i[s++]=(a&15)<<12|(r[t++]&63)<<6|r[t++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function ws(r,t,e){let n=e,o,i;for(let s=0;s<r.length;++s)o=r.charCodeAt(s),o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&((i=r.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,t[e++]=o>>18|240,t[e++]=o>>12&63|128,t[e++]=o>>6&63|128,t[e++]=o&63|128):(t[e++]=o>>12|224,t[e++]=o>>6&63|128,t[e++]=o&63|128);return e-n}function te(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function Xn(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var xs=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,te(this,10);return t}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw te(this,4);return Xn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw te(this,4);return Xn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw te(this,4);let t=Vc(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw te(this,4);let t=Fc(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw te(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return Mc(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw te(this,t);this.pos+=t}else do if(this.pos>=this.len)throw te(this);while(this.buf[this.pos++]&128);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new Ot(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw te(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,t}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw te(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw te(this,8);let t=Xn(this.buf,this.pos+=4),e=Xn(this.buf,this.pos+=4);return new Ot(t,e)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=ms(this.buf,this.pos);return this.pos+=Pt(t),t}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function bs(r){return new xs(r instanceof Uint8Array?r:r.subarray())}function Sr(r,t,e){let n=bs(r);return t.decode(n,void 0,e)}var vs={};kt(vs,{base10:()=>T0});var T0=Ue({prefix:"9",name:"base10",alphabet:"0123456789"});var Es={};kt(Es,{base16:()=>N0,base16upper:()=>U0});var N0=st({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),U0=st({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Bs={};kt(Bs,{base2:()=>R0});var R0=st({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var As={};kt(As,{base256emoji:()=>F0});var Hc=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),_0=Hc.reduce((r,t,e)=>(r[e]=t,r),[]),L0=Hc.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function V0(r){return r.reduce((t,e)=>(t+=_0[e],t),"")}function P0(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=L0[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var F0=pr({prefix:"\u{1F680}",name:"base256emoji",encode:V0,decode:P0});var Ss={};kt(Ss,{base8:()=>O0});var O0=st({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Is={};kt(Is,{identity:()=>D0});var D0=pr({prefix:"\0",name:"identity",encode:r=>Ya(r),decode:r=>Wa(r)});var Zy=new TextEncoder,Wy=new TextDecoder;var Ts={};kt(Ts,{sha256:()=>en,sha512:()=>H0});function Cs({name:r,code:t,encode:e}){return new ks(r,t,e)}var ks=class{name;code;encode;constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?Zt(this.code,e):e.then(n=>Zt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function qc(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var en=Cs({name:"sha2-256",code:18,encode:qc("SHA-256")}),H0=Cs({name:"sha2-512",code:19,encode:qc("SHA-512")});var rn={...Is,...Bs,...Ss,...vs,...Es,...Fi,...Hi,...Oi,...Mi,...As},aw={...Ts,...zi};function jc(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var zc=jc("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Ns=jc("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=Qt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),K0={utf8:zc,"utf-8":zc,hex:rn.base16,latin1:Ns,ascii:Ns,binary:Ns,...rn},Qn=K0;function Z(r,t="utf8"){let e=Qn[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function Us(r){let t=r??8192,e=t>>>1,n,o=t;return function(s){if(s<1||s>e)return Qt(s);o+s>t&&(n=Qt(t),o=0);let a=n.subarray(o,o+=s);return o&7&&(o=(o|7)+1),a}}var nr=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function Rs(){}var Ls=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},q0=Us();function z0(r){return globalThis.Buffer!=null?Qt(r):q0(r)}var on=class{len;head;tail;states;constructor(){this.len=0,this.head=new nr(Rs,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new nr(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Vs((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this}int32(t){return t<0?this._push(to,10,Ot.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=Ot.fromBigInt(t);return this._push(to,e.length(),e)}uint64Number(t){return this._push(ps,Pt(t),t)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let e=Ot.fromBigInt(t).zzEncode();return this._push(to,e.length(),e)}sint64Number(t){let e=Ot.fromNumber(t).zzEncode();return this._push(to,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(_s,1,t?1:0)}fixed32(t){return this._push(nn,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=Ot.fromBigInt(t);return this._push(nn,4,e.lo)._push(nn,4,e.hi)}fixed64Number(t){let e=Ot.fromNumber(t);return this._push(nn,4,e.lo)._push(nn,4,e.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(Lc,4,t)}double(t){return this._push(Pc,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(_s,1,0):this.uint32(e)._push(G0,e,t)}string(t){let e=Dc(t);return e!==0?this.uint32(e)._push(ws,e,t):this._push(_s,1,0)}fork(){return this.states=new Ls(this),this.head=this.tail=new nr(Rs,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new nr(Rs,0,0),this.len=0),this}ldelim(){let t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=e,this.len+=n),this}finish(){let t=this.head.next,e=z0(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function _s(r,t,e){t[e]=r&255}function j0(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var Vs=class extends nr{next;constructor(t,e){super(j0,t,e),this.next=void 0}};function to(r,t,e){for(;r.hi!==0;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}function nn(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function G0(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(on.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(Z0,t,r),this},on.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(W0,t,r),this});function Z0(r,t,e){t.set(r,e)}function W0(r,t,e){r.length<40?ws(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(Z(r),e)}function Ps(){return new on}function Ir(r,t){let e=Ps();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var kr;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(kr||(kr={}));function eo(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function sn(r){function t(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let e=function(i,s){let a=t(i);s.int32(a)},n=function(i){let s=i.int32();return t(s)};return eo("enum",kr.VARINT,e,n)}function Cr(r,t){return eo("message",kr.LENGTH_DELIMITED,r,t)}var dt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1"})(dt||(dt={}));var Fs;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1"})(Fs||(Fs={}));(function(r){r.codec=()=>sn(Fs)})(dt||(dt={}));var ce;(function(r){let t;r.codec=()=>(t==null&&(t=Cr((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),dt.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let a=e.uint32();switch(a>>>3){case 1:{i.Type=dt.codec().decode(e);break}case 2:{i.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return i})),t),r.encode=e=>Ir(e,r.codec()),r.decode=(e,n)=>Sr(e,r.codec(),n)})(ce||(ce={}));var Os;(function(r){let t;r.codec=()=>(t==null&&(t=Cr((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),dt.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let a=e.uint32();switch(a>>>3){case 1:{i.Type=dt.codec().decode(e);break}case 2:{i.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return i})),t),r.encode=e=>Ir(e,r.codec()),r.decode=(e,n)=>Sr(e,r.codec(),n)})(Os||(Os={}));var gn={};kt(gn,{MAX_RSA_KEY_SIZE:()=>Go,generateRSAKeyPair:()=>Ku,jwkToJWKKeyPair:()=>qu,jwkToPkcs1:()=>fp,jwkToPkix:()=>Gs,jwkToRSAPrivateKey:()=>Hu,pkcs1ToJwk:()=>Du,pkcs1ToRSAPrivateKey:()=>$u,pkixToJwk:()=>Mu,pkixToRSAPublicKey:()=>Zs});var Y0=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),$e=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),He=new Uint32Array(64),Ds=class extends Er{constructor(){super(64,32,8,!1),this.A=$e[0]|0,this.B=$e[1]|0,this.C=$e[2]|0,this.D=$e[3]|0,this.E=$e[4]|0,this.F=$e[5]|0,this.G=$e[6]|0,this.H=$e[7]|0}get(){let{A:t,B:e,C:n,D:o,E:i,F:s,G:a,H:c}=this;return[t,e,n,o,i,s,a,c]}set(t,e,n,o,i,s,a,c){this.A=t|0,this.B=e|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(t,e){for(let l=0;l<16;l++,e+=4)He[l]=t.getUint32(e,!1);for(let l=16;l<64;l++){let d=He[l-15],b=He[l-2],I=Yt(d,7)^Yt(d,18)^d>>>3,w=Yt(b,17)^Yt(b,19)^b>>>10;He[l]=w+He[l-7]+I+He[l-16]|0}let{A:n,B:o,C:i,D:s,E:a,F:c,G:f,H:u}=this;for(let l=0;l<64;l++){let d=Yt(a,6)^Yt(a,11)^Yt(a,25),b=u+d+mc(a,c,f)+Y0[l]+He[l]|0,w=(Yt(n,2)^Yt(n,13)^Yt(n,22))+gc(n,o,i)|0;u=f,f=c,c=a,a=s+b|0,s=i,i=o,o=n,n=b+w|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(n,o,i,s,a,c,f,u)}roundClean(){He.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Tr=Mn(()=>new Ds);var j=_n(Zc());function or(r,t){let e=0;if(r.length===1)return r[0];for(let n=r.length-1;n>=0;n--)e+=r[r.length-1-n]*Math.pow(2,t*n);return e}function Ke(r,t,e=-1){let n=e,o=r,i=0,s=Math.pow(2,t);for(let a=1;a<8;a++){if(r<s){let c;if(n<0)c=new ArrayBuffer(a),i=a;else{if(n<a)return new ArrayBuffer(0);c=new ArrayBuffer(n),i=n}let f=new Uint8Array(c);for(let u=a-1;u>=0;u--){let l=Math.pow(2,u*t);f[i-u-1]=Math.floor(o/l),o-=f[i-u-1]*l}return c}s*=Math.pow(2,t)}return new ArrayBuffer(0)}function oo(...r){let t=0,e=0;for(let i of r)t+=i.length;let n=new ArrayBuffer(t),o=new Uint8Array(n);for(let i of r)o.set(i,e),e+=i.length;return o}function $s(){let r=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){let a=r[0]===255&&r[1]&128,c=r[0]===0&&(r[1]&128)===0;(a||c)&&this.warnings.push("Needlessly long format")}let t=new ArrayBuffer(this.valueHex.byteLength),e=new Uint8Array(t);for(let a=0;a<this.valueHex.byteLength;a++)e[a]=0;e[0]=r[0]&128;let n=or(e,8),o=new ArrayBuffer(this.valueHex.byteLength),i=new Uint8Array(o);for(let a=0;a<this.valueHex.byteLength;a++)i[a]=r[a];return i[0]&=127,or(i,8)-n}function Wc(r){let t=r<0?r*-1:r,e=128;for(let n=1;n<8;n++){if(t<=e){if(r<0){let s=e-t,a=Ke(s,8,n),c=new Uint8Array(a);return c[0]|=128,a}let o=Ke(t,8,n),i=new Uint8Array(o);if(i[0]&128){let s=o.slice(0),a=new Uint8Array(s);o=new ArrayBuffer(o.byteLength+1),i=new Uint8Array(o);for(let c=0;c<s.byteLength;c++)i[c+1]=a[c];i[0]=0}return o}e*=Math.pow(2,8)}return new ArrayBuffer(0)}function Yc(r,t){if(r.byteLength!==t.byteLength)return!1;let e=new Uint8Array(r),n=new Uint8Array(t);for(let o=0;o<e.length;o++)if(e[o]!==n[o])return!1;return!0}function Ft(r,t){let e=r.toString(10);if(t<e.length)return"";let n=t-e.length,o=new Array(n);for(let s=0;s<n;s++)o[s]="0";return o.join("").concat(e)}var Hw=Math.log(2);function io(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function Hs(r){let t=0,e=0;for(let o=0;o<r.length;o++){let i=r[o];t+=i.byteLength}let n=new Uint8Array(t);for(let o=0;o<r.length;o++){let i=r[o];n.set(new Uint8Array(i),e),e+=i.byteLength}return n.buffer}function Se(r,t,e,n){return t instanceof Uint8Array?t.byteLength?e<0?(r.error="Wrong parameter: inputOffset less than zero",!1):n<0?(r.error="Wrong parameter: inputLength less than zero",!1):t.byteLength-e-n<0?(r.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(r.error="Wrong parameter: inputBuffer has zero length",!1):(r.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}var cn=class{constructor(){this.items=[]}write(t){this.items.push(t)}final(){return Hs(this.items)}},an=[new Uint8Array([1])],Jc="0123456789";var Lr="",ee=new ArrayBuffer(0),Ks=new Uint8Array(0),un="EndOfContent",Qc="OCTET STRING",tu="BIT STRING";function Ie(r){var t;return t=class extends r{constructor(...n){var o;super(...n);let i=n[0]||{};this.isHexOnly=(o=i.isHexOnly)!==null&&o!==void 0?o:!1,this.valueHexView=i.valueHex?j.BufferSourceConverter.toUint8Array(i.valueHex):Ks}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(n){this.valueHexView=new Uint8Array(n)}fromBER(n,o,i){let s=n instanceof ArrayBuffer?new Uint8Array(n):n;if(!Se(this,s,o,i))return-1;let a=o+i;return this.valueHexView=s.subarray(o,a),this.valueHexView.length?(this.blockLength=i,a):(this.warnings.push("Zero buffer length"),o)}toBER(n=!1){return this.isHexOnly?n?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",ee)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:j.Convert.ToHex(this.valueHexView)}}},t.NAME="hexBlock",t}var Ee=class{constructor({blockLength:t=0,error:e=Lr,warnings:n=[],valueBeforeDecode:o=Ks}={}){this.blockLength=t,this.error=e,this.warnings=n,this.valueBeforeDecodeView=j.BufferSourceConverter.toUint8Array(o)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(t){this.valueBeforeDecodeView=new Uint8Array(t)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:j.Convert.ToHex(this.valueBeforeDecodeView)}}};Ee.NAME="baseBlock";var At=class extends Ee{fromBER(t,e,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(t,e){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}};At.NAME="valueBlock";var so=class extends Ie(Ee){constructor({idBlock:t={}}={}){var e,n,o,i;super(),t?(this.isHexOnly=(e=t.isHexOnly)!==null&&e!==void 0?e:!1,this.valueHexView=t.valueHex?j.BufferSourceConverter.toUint8Array(t.valueHex):Ks,this.tagClass=(n=t.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(o=t.tagNumber)!==null&&o!==void 0?o:-1,this.isConstructed=(i=t.isConstructed)!==null&&i!==void 0?i:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(t=!1){let e=0;switch(this.tagClass){case 1:e|=0;break;case 2:e|=64;break;case 3:e|=128;break;case 4:e|=192;break;default:return this.error="Unknown tag class",ee}if(this.isConstructed&&(e|=32),this.tagNumber<31&&!this.isHexOnly){let o=new Uint8Array(1);if(!t){let i=this.tagNumber;i&=31,e|=i,o[0]=e}return o.buffer}if(!this.isHexOnly){let o=Ke(this.tagNumber,7),i=new Uint8Array(o),s=o.byteLength,a=new Uint8Array(s+1);if(a[0]=e|31,!t){for(let c=0;c<s-1;c++)a[c+1]=i[c]|128;a[s]=i[s-1]}return a.buffer}let n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=e|31,!t){let o=this.valueHexView;for(let i=0;i<o.length-1;i++)n[i+1]=o[i]|128;n[this.valueHexView.byteLength]=o[o.length-1]}return n.buffer}fromBER(t,e,n){let o=j.BufferSourceConverter.toUint8Array(t);if(!Se(this,o,e,n))return-1;let i=o.subarray(e,e+n);if(i.length===0)return this.error="Zero buffer length",-1;switch(i[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(i[0]&32)===32,this.isHexOnly=!1;let a=i[0]&31;if(a!==31)this.tagNumber=a,this.blockLength=1;else{let c=1,f=this.valueHexView=new Uint8Array(255),u=255;for(;i[c]&128;){if(f[c-1]=i[c]&127,c++,c>=i.length)return this.error="End of input reached before message was fully decoded",-1;if(c===u){u+=255;let d=new Uint8Array(u);for(let b=0;b<f.length;b++)d[b]=f[b];f=this.valueHexView=new Uint8Array(u)}}this.blockLength=c+1,f[c-1]=i[c]&127;let l=new Uint8Array(c);for(let d=0;d<c;d++)l[d]=f[d];f=this.valueHexView=new Uint8Array(c),f.set(l),this.blockLength<=9?this.tagNumber=or(f,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return e+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}};so.NAME="identificationBlock";var ao=class extends Ee{constructor({lenBlock:t={}}={}){var e,n,o;super(),this.isIndefiniteForm=(e=t.isIndefiniteForm)!==null&&e!==void 0?e:!1,this.longFormUsed=(n=t.longFormUsed)!==null&&n!==void 0?n:!1,this.length=(o=t.length)!==null&&o!==void 0?o:0}fromBER(t,e,n){let o=j.BufferSourceConverter.toUint8Array(t);if(!Se(this,o,e,n))return-1;let i=o.subarray(e,e+n);if(i.length===0)return this.error="Zero buffer length",-1;if(i[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=i[0]===128,this.isIndefiniteForm)return this.blockLength=1,e+this.blockLength;if(this.longFormUsed=!!(i[0]&128),this.longFormUsed===!1)return this.length=i[0],this.blockLength=1,e+this.blockLength;let s=i[0]&127;if(s>8)return this.error="Too big integer",-1;if(s+1>i.length)return this.error="End of input reached before message was fully decoded",-1;let a=e+1,c=o.subarray(a,a+s);return c[s-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=or(c,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=s+1,e+this.blockLength}toBER(t=!1){let e,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return e=new ArrayBuffer(1),t===!1&&(n=new Uint8Array(e),n[0]=128),e;if(this.longFormUsed){let o=Ke(this.length,8);if(o.byteLength>127)return this.error="Too big length",ee;if(e=new ArrayBuffer(o.byteLength+1),t)return e;let i=new Uint8Array(o);n=new Uint8Array(e),n[0]=o.byteLength|128;for(let s=0;s<o.byteLength;s++)n[s+1]=i[s];return e}return e=new ArrayBuffer(1),t===!1&&(n=new Uint8Array(e),n[0]=this.length),e}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}};ao.NAME="lengthBlock";var _={},wt=class extends Ee{constructor({name:t=Lr,optional:e=!1,primitiveSchema:n,...o}={},i){super(o),this.name=t,this.optional=e,n&&(this.primitiveSchema=n),this.idBlock=new so(o),this.lenBlock=new ao(o),this.valueBlock=i?new i(o):new At(o)}fromBER(t,e,n){let o=this.valueBlock.fromBER(t,e,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),o)}toBER(t,e){let n=e||new cn;e||eu(this);let o=this.idBlock.toBER(t);if(n.write(o),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(t,n),n.write(new ArrayBuffer(2));else{let i=this.valueBlock.toBER(t);this.lenBlock.length=i.byteLength;let s=this.lenBlock.toBER(t);n.write(s),n.write(i)}return e?ee:n.final()}toJSON(){let t={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(t.primitiveSchema=this.primitiveSchema.toJSON()),t}toString(t="ascii"){return t==="ascii"?this.onAsciiEncoding():j.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${j.Convert.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(t){if(this===t)return!0;if(!(t instanceof this.constructor))return!1;let e=this.toBER(),n=t.toBER();return Yc(e,n)}};wt.NAME="BaseBlock";function eu(r){if(r instanceof _.Constructed)for(let t of r.valueBlock.value)eu(t)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}var co=class extends wt{constructor({value:t=Lr,...e}={},n){super(e,n),t&&this.fromString(t)}getValue(){return this.valueBlock.value}setValue(t){this.valueBlock.value=t}fromBER(t,e,n){let o=this.valueBlock.fromBER(t,e,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),o)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}};co.NAME="BaseStringBlock";var uo=class extends Ie(At){constructor({isHexOnly:t=!0,...e}={}){super(e),this.isHexOnly=t}};uo.NAME="PrimitiveValueBlock";var ru,lo=class extends wt{constructor(t={}){super(t,uo),this.idBlock.isConstructed=!1}};ru=lo;_.Primitive=ru;lo.NAME="PRIMITIVE";function ip(r,t){if(r instanceof t)return r;let e=new t;return e.idBlock=r.idBlock,e.lenBlock=r.lenBlock,e.warnings=r.warnings,e.valueBeforeDecodeView=r.valueBeforeDecodeView,e}function zo(r,t=0,e=r.length){let n=t,o=new wt({},At),i=new Ee;if(!Se(i,r,t,e))return o.error=i.error,{offset:-1,result:o};if(!r.subarray(t,t+e).length)return o.error="Zero buffer length",{offset:-1,result:o};let a=o.idBlock.fromBER(r,t,e);if(o.idBlock.warnings.length&&o.warnings.concat(o.idBlock.warnings),a===-1)return o.error=o.idBlock.error,{offset:-1,result:o};if(t=a,e-=o.idBlock.blockLength,a=o.lenBlock.fromBER(r,t,e),o.lenBlock.warnings.length&&o.warnings.concat(o.lenBlock.warnings),a===-1)return o.error=o.lenBlock.error,{offset:-1,result:o};if(t=a,e-=o.lenBlock.blockLength,!o.idBlock.isConstructed&&o.lenBlock.isIndefiniteForm)return o.error="Indefinite length form used for primitive encoding form",{offset:-1,result:o};let c=wt;switch(o.idBlock.tagClass){case 1:if(o.idBlock.tagNumber>=37&&o.idBlock.isHexOnly===!1)return o.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:o};switch(o.idBlock.tagNumber){case 0:if(o.idBlock.isConstructed&&o.lenBlock.length>0)return o.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:o};c=_.EndOfContent;break;case 1:c=_.Boolean;break;case 2:c=_.Integer;break;case 3:c=_.BitString;break;case 4:c=_.OctetString;break;case 5:c=_.Null;break;case 6:c=_.ObjectIdentifier;break;case 10:c=_.Enumerated;break;case 12:c=_.Utf8String;break;case 13:c=_.RelativeObjectIdentifier;break;case 14:c=_.TIME;break;case 15:return o.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:o};case 16:c=_.Sequence;break;case 17:c=_.Set;break;case 18:c=_.NumericString;break;case 19:c=_.PrintableString;break;case 20:c=_.TeletexString;break;case 21:c=_.VideotexString;break;case 22:c=_.IA5String;break;case 23:c=_.UTCTime;break;case 24:c=_.GeneralizedTime;break;case 25:c=_.GraphicString;break;case 26:c=_.VisibleString;break;case 27:c=_.GeneralString;break;case 28:c=_.UniversalString;break;case 29:c=_.CharacterString;break;case 30:c=_.BmpString;break;case 31:c=_.DATE;break;case 32:c=_.TimeOfDay;break;case 33:c=_.DateTime;break;case 34:c=_.Duration;break;default:{let f=o.idBlock.isConstructed?new _.Constructed:new _.Primitive;f.idBlock=o.idBlock,f.lenBlock=o.lenBlock,f.warnings=o.warnings,o=f}}break;case 2:case 3:case 4:default:c=o.idBlock.isConstructed?_.Constructed:_.Primitive}return o=ip(o,c),a=o.fromBER(r,t,o.lenBlock.isIndefiniteForm?e:o.lenBlock.length),o.valueBeforeDecodeView=r.subarray(n,n+o.blockLength),{offset:a,result:o}}function qs(r){if(!r.byteLength){let t=new wt({},At);return t.error="Input buffer has zero length",{offset:-1,result:t}}return zo(j.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function sp(r,t){return r?1:t}var ue=class extends At{constructor({value:t=[],isIndefiniteForm:e=!1,...n}={}){super(n),this.value=t,this.isIndefiniteForm=e}fromBER(t,e,n){let o=j.BufferSourceConverter.toUint8Array(t);if(!Se(this,o,e,n))return-1;if(this.valueBeforeDecodeView=o.subarray(e,e+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),e;let i=e;for(;sp(this.isIndefiniteForm,n)>0;){let s=zo(o,i,n);if(s.offset===-1)return this.error=s.result.error,this.warnings.concat(s.result.warnings),-1;if(i=s.offset,this.blockLength+=s.result.blockLength,n-=s.result.blockLength,this.value.push(s.result),this.isIndefiniteForm&&s.result.constructor.NAME===un)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===un?this.value.pop():this.warnings.push("No EndOfContent block encoded")),i}toBER(t,e){let n=e||new cn;for(let o=0;o<this.value.length;o++)this.value[o].toBER(t,n);return e?ee:n.final()}toJSON(){let t={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let e of this.value)t.value.push(e.toJSON());return t}};ue.NAME="ConstructedValueBlock";var nu,qe=class extends wt{constructor(t={}){super(t,ue),this.idBlock.isConstructed=!0}fromBER(t,e,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;let o=this.valueBlock.fromBER(t,e,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),o)}onAsciiEncoding(){let t=[];for(let n of this.valueBlock.value)t.push(n.toString("ascii").split(`
2
+ "use strict";var HeliaRouters=(()=>{var Ch=Object.create;var Ln=Object.defineProperty;var Nh=Object.getOwnPropertyDescriptor;var Uh=Object.getOwnPropertyNames;var Rh=Object.getPrototypeOf,_h=Object.prototype.hasOwnProperty;var Hi=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),Tt=(r,t)=>{for(var e in t)Ln(r,e,{get:t[e],enumerable:!0})},sc=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Uh(t))!_h.call(r,o)&&o!==e&&Ln(r,o,{get:()=>t[o],enumerable:!(n=Nh(t,o))||n.enumerable});return r};var Vn=(r,t,e)=>(e=r!=null?Ch(Rh(r)):{},sc(t||!r||!r.__esModule?Ln(e,"default",{value:r,enumerable:!0}):e,r)),Lh=r=>sc(Ln({},"__esModule",{value:!0}),r);var mu=Hi(_r=>{"use strict";var vp="[object ArrayBuffer]",Be=class r{static isArrayBuffer(t){return Object.prototype.toString.call(t)===vp}static toArrayBuffer(t){return this.isArrayBuffer(t)?t:t.byteLength===t.buffer.byteLength||t.byteOffset===0&&t.byteLength===t.buffer.byteLength?t.buffer:this.toUint8Array(t.buffer).slice(t.byteOffset,t.byteOffset+t.byteLength).buffer}static toUint8Array(t){return this.toView(t,Uint8Array)}static toView(t,e){if(t.constructor===e)return t;if(this.isArrayBuffer(t))return new e(t);if(this.isArrayBufferView(t))return new e(t.buffer,t.byteOffset,t.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(t){return this.isArrayBufferView(t)||this.isArrayBuffer(t)}static isArrayBufferView(t){return ArrayBuffer.isView(t)||t&&this.isArrayBuffer(t.buffer)}static isEqual(t,e){let n=r.toUint8Array(t),o=r.toUint8Array(e);if(n.length!==o.byteLength)return!1;for(let i=0;i<n.length;i++)if(n[i]!==o[i])return!1;return!0}static concat(...t){let e;Array.isArray(t[0])&&!(t[1]instanceof Function)||Array.isArray(t[0])&&t[1]instanceof Function?e=t[0]:t[t.length-1]instanceof Function?e=t.slice(0,t.length-1):e=t;let n=0;for(let s of e)n+=s.byteLength;let o=new Uint8Array(n),i=0;for(let s of e){let a=this.toUint8Array(s);o.set(a,i),i+=a.length}return t[t.length-1]instanceof Function?this.toView(o,t[t.length-1]):o.buffer}},ta="string",Ep=/^[0-9a-f\s]+$/i,Bp=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,Ap=/^[a-zA-Z0-9-_]+$/,lo=class{static fromString(t){let e=unescape(encodeURIComponent(t)),n=new Uint8Array(e.length);for(let o=0;o<e.length;o++)n[o]=e.charCodeAt(o);return n.buffer}static toString(t){let e=Be.toUint8Array(t),n="";for(let i=0;i<e.length;i++)n+=String.fromCharCode(e[i]);return decodeURIComponent(escape(n))}},qt=class{static toString(t,e=!1){let n=Be.toArrayBuffer(t),o=new DataView(n),i="";for(let s=0;s<n.byteLength;s+=2){let a=o.getUint16(s,e);i+=String.fromCharCode(a)}return i}static fromString(t,e=!1){let n=new ArrayBuffer(t.length*2),o=new DataView(n);for(let i=0;i<t.length;i++)o.setUint16(i*2,t.charCodeAt(i),e);return n}},fo=class r{static isHex(t){return typeof t===ta&&Ep.test(t)}static isBase64(t){return typeof t===ta&&Bp.test(t)}static isBase64Url(t){return typeof t===ta&&Ap.test(t)}static ToString(t,e="utf8"){let n=Be.toUint8Array(t);switch(e.toLowerCase()){case"utf8":return this.ToUtf8String(n);case"binary":return this.ToBinary(n);case"hex":return this.ToHex(n);case"base64":return this.ToBase64(n);case"base64url":return this.ToBase64Url(n);case"utf16le":return qt.toString(n,!0);case"utf16":case"utf16be":return qt.toString(n);default:throw new Error(`Unknown type of encoding '${e}'`)}}static FromString(t,e="utf8"){if(!t)return new ArrayBuffer(0);switch(e.toLowerCase()){case"utf8":return this.FromUtf8String(t);case"binary":return this.FromBinary(t);case"hex":return this.FromHex(t);case"base64":return this.FromBase64(t);case"base64url":return this.FromBase64Url(t);case"utf16le":return qt.fromString(t,!0);case"utf16":case"utf16be":return qt.fromString(t);default:throw new Error(`Unknown type of encoding '${e}'`)}}static ToBase64(t){let e=Be.toUint8Array(t);if(typeof btoa<"u"){let n=this.ToString(e,"binary");return btoa(n)}else return Buffer.from(e).toString("base64")}static FromBase64(t){let e=this.formatString(t);if(!e)return new ArrayBuffer(0);if(!r.isBase64(e))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob<"u"?this.FromBinary(atob(e)):new Uint8Array(Buffer.from(e,"base64")).buffer}static FromBase64Url(t){let e=this.formatString(t);if(!e)return new ArrayBuffer(0);if(!r.isBase64Url(e))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(e.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(t){return this.ToBase64(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(t,e=r.DEFAULT_UTF8_ENCODING){switch(e){case"ascii":return this.FromBinary(t);case"utf8":return lo.fromString(t);case"utf16":case"utf16be":return qt.fromString(t);case"utf16le":case"usc2":return qt.fromString(t,!0);default:throw new Error(`Unknown type of encoding '${e}'`)}}static ToUtf8String(t,e=r.DEFAULT_UTF8_ENCODING){switch(e){case"ascii":return this.ToBinary(t);case"utf8":return lo.toString(t);case"utf16":case"utf16be":return qt.toString(t);case"utf16le":case"usc2":return qt.toString(t,!0);default:throw new Error(`Unknown type of encoding '${e}'`)}}static FromBinary(t){let e=t.length,n=new Uint8Array(e);for(let o=0;o<e;o++)n[o]=t.charCodeAt(o);return n.buffer}static ToBinary(t){let e=Be.toUint8Array(t),n="";for(let o=0;o<e.length;o++)n+=String.fromCharCode(e[o]);return n}static ToHex(t){let e=Be.toUint8Array(t),n="",o=e.length;for(let i=0;i<o;i++){let s=e[i];s<16&&(n+="0"),n+=s.toString(16)}return n}static FromHex(t){let e=this.formatString(t);if(!e)return new ArrayBuffer(0);if(!r.isHex(e))throw new TypeError("Argument 'hexString' is not HEX encoded");e.length%2&&(e=`0${e}`);let n=new Uint8Array(e.length/2);for(let o=0;o<e.length;o=o+2){let i=e.slice(o,o+2);n[o/2]=parseInt(i,16)}return n.buffer}static ToUtf16String(t,e=!1){return qt.toString(t,e)}static FromUtf16String(t,e=!1){return qt.fromString(t,e)}static Base64Padding(t){let e=4-t.length%4;if(e<4)for(let n=0;n<e;n++)t+="=";return t}static formatString(t){return t?.replace(/[\n\r\t ]/g,"")||""}};fo.DEFAULT_UTF8_ENCODING="utf8";function Sp(r,...t){let e=arguments[0];for(let n=1;n<arguments.length;n++){let o=arguments[n];for(let i in o)e[i]=o[i]}return e}function Ip(...r){let t=r.map(o=>o.byteLength).reduce((o,i)=>o+i),e=new Uint8Array(t),n=0;return r.map(o=>new Uint8Array(o)).forEach(o=>{for(let i of o)e[n++]=i}),e.buffer}function kp(r,t){if(!(r&&t)||r.byteLength!==t.byteLength)return!1;let e=new Uint8Array(r),n=new Uint8Array(t);for(let o=0;o<r.byteLength;o++)if(e[o]!==n[o])return!1;return!0}_r.BufferSourceConverter=Be;_r.Convert=fo;_r.assign=Sp;_r.combine=Ip;_r.isEqual=kp});var Na=Hi((H2,Ca)=>{var M2=function(){typeof Ca<"u"&&(Ca.exports=y);var r=86400,t=3200,e=146097*t/400,n=r*e,o=1e3*n,i=864e13,s=4294967296,a=1e6,c="000000000",f=Math.trunc||function(b){var v=b-b%1;return v==0&&(b<0||b===0&&1/b!=1/0)?-0:v},u=y.prototype,l=(y.fromDate=function(b){return new y(+b)},y.fromInt64BE=U(0,1,2,3,0,4),y.fromInt64LE=U(3,2,1,0,4,0),y.fromString=function(_){var v,D=new y,_=(_+="").replace(/^\s*[+\-]?\d+/,function($){var $=+$,S=1970+($-1970)%400;return D.year=$-S,S}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function(C,$,S){return $<0&&(S*=-1),v=6e4*(60*+$+ +S),""}).replace(/\.\d+$/,function(C){return D.nano=+(C+c).substr(1,9),""}).split(/\D+/);if(1<_.length?_[1]--:_[1]=0,D.time=v=Date.UTC.apply(Date,_)-(v||0),isNaN(v))throw new TypeError("Invalid Date");return d(D)},y.fromTimeT=function(b){return T(b,0)},u.year=0,u.time=0,u.nano=0,u.addNano=function(b){return this.nano+=+b||0,this},u.getNano=function(){var b=d(this);return(b.time%1e3*a+ +b.nano+1e9)%1e9},u.getTimeT=function(){var v=d(this),b=Math.floor(v.time/1e3),v=v.year;return v&&(b+=v*e*r/t),b},u.getYear=function(){return this.toDate().getUTCFullYear()+this.year},u.toDate=function(){return A(d(this).time)},u.toJSON=function(){return this.toString().replace(/0{1,6}Z$/,"Z")},u.toString=function(b){var v=this,D=v.toDate(),_={H:function(){return P(D.getUTCHours())},L:function(){return R(D.getUTCMilliseconds(),3)},M:function(){return P(D.getUTCMinutes())},N:function(){return R(v.getNano(),9)},S:function(){return P(D.getUTCSeconds())},Y:function(){var C=v.getYear();return 999999<C?"+"+C:9999<C?"+"+R(C,6):0<=C?R(C,4):-999999<=C?"-"+R(-C,6):C},a:function(){return g[D.getUTCDay()]},b:function(){return h[D.getUTCMonth()]},d:function(){return P(D.getUTCDate())},e:function(){return function(C){return(9<C?"":" ")+(0|C)}(D.getUTCDate())},m:function(){return P(D.getUTCMonth()+1)}};return function C($){return $.replace(/%./g,function(S){var m=S[1],I=E[m],m=_[m];return I?C(I):m?m():S})}(b||l)},u.writeInt64BE=w(0,1,2,3,0,4),u.writeInt64LE=w(3,2,1,0,4,0),"%Y-%m-%dT%H:%M:%S.%NZ"),h=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],g=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],E={"%":"%",F:"%Y-%m-%d",n:`
3
+ `,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return y;function y(b,v,D){var _=this;if(!(_ instanceof y))return new y(b,v,D);_.time=+b||0,_.nano=+v||0,_.year=+D||0,d(_)}function d(b){var v,D,_,C=b.year,$=b.time,S=b.nano,I=((S<0||a<=S)&&(S-=(D=Math.floor(S/a))*a,$+=D,D=1),C%t);return($<-i||i<$||I)&&((v=f($/o))&&(C+=v*t,$-=v*o),(_=A($)).setUTCFullYear(I+_.getUTCFullYear()),_=($=+_)+(v=f((C-=I)/t))*o,v&&-i<=_&&_<=i&&(C-=v*t,$=_),D=1),D&&(b.year=C,b.time=$,b.nano=S),b}function A(b){var v=new Date(0);return v.setTime(b),v}function T(C,_){C=+C||0;var D=f((_=(_|0)*s)/n)+f(C/n),_=_%n+C%n,C=f(_/n);return C&&(D+=C,_-=C*n),new y(1e3*_,0,D*t)}function w(b,v,D,_,C,$){return function(I,m){var B=d(this);I=I||new Array(8),F(I,m|=0);var N=Math.floor(B.time/1e3),B=B.year*(e*r/t),p=f(B/s)+f(N/s),B=B%s+N%s,N=Math.floor(B/s);return N&&(p+=N,B-=N*s),S(I,m+C,p),S(I,m+$,B),I};function S(I,m,p){I[m+b]=p>>24&255,I[m+v]=p>>16&255,I[m+D]=p>>8&255,I[m+_]=255&p}}function U(b,v,D,_,C,$){return function(I,m){F(I,m|=0);var p=S(I,m+C);return T(S(I,m+$),p)};function S(I,m){return 16777216*I[m+b]+(I[m+v]<<16|I[m+D]<<8|I[m+_])}}function F(b,v){if(b=b&&b.length,b==null)throw new TypeError("Invalid Buffer");if(b<v+8)throw new RangeError("Out of range")}function P(b){return(9<b?"":"0")+(0|b)}function R(b,v){return(c+(0|b)).substr(-v)}}()});var rh=Hi((CE,Da)=>{"use strict";var eg=Object.prototype.hasOwnProperty,Nt="~";function Nn(){}Object.create&&(Nn.prototype=Object.create(null),new Nn().__proto__||(Nt=!1));function rg(r,t,e){this.fn=r,this.context=t,this.once=e||!1}function eh(r,t,e,n,o){if(typeof e!="function")throw new TypeError("The listener must be a function");var i=new rg(e,n||r,o),s=Nt?Nt+t:t;return r._events[s]?r._events[s].fn?r._events[s]=[r._events[s],i]:r._events[s].push(i):(r._events[s]=i,r._eventsCount++),r}function Ui(r,t){--r._eventsCount===0?r._events=new Nn:delete r._events[t]}function It(){this._events=new Nn,this._eventsCount=0}It.prototype.eventNames=function(){var t=[],e,n;if(this._eventsCount===0)return t;for(n in e=this._events)eg.call(e,n)&&t.push(Nt?n.slice(1):n);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(e)):t};It.prototype.listeners=function(t){var e=Nt?Nt+t:t,n=this._events[e];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,i=n.length,s=new Array(i);o<i;o++)s[o]=n[o].fn;return s};It.prototype.listenerCount=function(t){var e=Nt?Nt+t:t,n=this._events[e];return n?n.fn?1:n.length:0};It.prototype.emit=function(t,e,n,o,i,s){var a=Nt?Nt+t:t;if(!this._events[a])return!1;var c=this._events[a],f=arguments.length,u,l;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),f){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,e),!0;case 3:return c.fn.call(c.context,e,n),!0;case 4:return c.fn.call(c.context,e,n,o),!0;case 5:return c.fn.call(c.context,e,n,o,i),!0;case 6:return c.fn.call(c.context,e,n,o,i,s),!0}for(l=1,u=new Array(f-1);l<f;l++)u[l-1]=arguments[l];c.fn.apply(c.context,u)}else{var h=c.length,g;for(l=0;l<h;l++)switch(c[l].once&&this.removeListener(t,c[l].fn,void 0,!0),f){case 1:c[l].fn.call(c[l].context);break;case 2:c[l].fn.call(c[l].context,e);break;case 3:c[l].fn.call(c[l].context,e,n);break;case 4:c[l].fn.call(c[l].context,e,n,o);break;default:if(!u)for(g=1,u=new Array(f-1);g<f;g++)u[g-1]=arguments[g];c[l].fn.apply(c[l].context,u)}}return!0};It.prototype.on=function(t,e,n){return eh(this,t,e,n,!1)};It.prototype.once=function(t,e,n){return eh(this,t,e,n,!0)};It.prototype.removeListener=function(t,e,n,o){var i=Nt?Nt+t:t;if(!this._events[i])return this;if(!e)return Ui(this,i),this;var s=this._events[i];if(s.fn)s.fn===e&&(!o||s.once)&&(!n||s.context===n)&&Ui(this,i);else{for(var a=0,c=[],f=s.length;a<f;a++)(s[a].fn!==e||o&&!s[a].once||n&&s[a].context!==n)&&c.push(s[a]);c.length?this._events[i]=c.length===1?c[0]:c:Ui(this,i)}return this};It.prototype.removeAllListeners=function(t){var e;return t?(e=Nt?Nt+t:t,this._events[e]&&Ui(this,e)):(this._events=new Nn,this._eventsCount=0),this};It.prototype.off=It.prototype.removeListener;It.prototype.addListener=It.prototype.on;It.prefixed=Nt;It.EventEmitter=It;typeof Da<"u"&&(Da.exports=It)});var Bg={};Tt(Bg,{delegatedHTTPRouting:()=>fh,delegatedHTTPRoutingDefaults:()=>Di,httpGatewayRouting:()=>wh,libp2pRouting:()=>bh});var ac=Symbol.for("@libp2p/content-routing");var $i=Symbol.for("@libp2p/peer-id");var cc=Symbol.for("@libp2p/peer-routing");var Et=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},pr=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var Rt=class extends Error{static name="NotFoundError";constructor(t="Not found"){super(t),this.name="NotFoundError"}};var Pn=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},mr=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var gr=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var yr=(r,...t)=>{try{[...t]}catch{}};var Gi={};Tt(Gi,{base32:()=>Gt,base32hex:()=>Kh,base32hexpad:()=>zh,base32hexpadupper:()=>jh,base32hexupper:()=>qh,base32pad:()=>Hh,base32padupper:()=>$h,base32upper:()=>Mh,base32z:()=>Gh});var Ng=new Uint8Array(0);function uc(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function ye(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function lc(r){return new TextEncoder().encode(r)}function fc(r){return new TextDecoder().decode(r)}function Vh(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var i=r.charAt(o),s=i.charCodeAt(0);if(e[s]!==255)throw new TypeError(i+" is ambiguous");e[s]=o}var a=r.length,c=r.charAt(0),f=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function l(E){if(E instanceof Uint8Array||(ArrayBuffer.isView(E)?E=new Uint8Array(E.buffer,E.byteOffset,E.byteLength):Array.isArray(E)&&(E=Uint8Array.from(E))),!(E instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(E.length===0)return"";for(var y=0,d=0,A=0,T=E.length;A!==T&&E[A]===0;)A++,y++;for(var w=(T-A)*u+1>>>0,U=new Uint8Array(w);A!==T;){for(var F=E[A],P=0,R=w-1;(F!==0||P<d)&&R!==-1;R--,P++)F+=256*U[R]>>>0,U[R]=F%a>>>0,F=F/a>>>0;if(F!==0)throw new Error("Non-zero carry");d=P,A++}for(var b=w-d;b!==w&&U[b]===0;)b++;for(var v=c.repeat(y);b<w;++b)v+=r.charAt(U[b]);return v}function h(E){if(typeof E!="string")throw new TypeError("Expected String");if(E.length===0)return new Uint8Array;var y=0;if(E[y]!==" "){for(var d=0,A=0;E[y]===c;)d++,y++;for(var T=(E.length-y)*f+1>>>0,w=new Uint8Array(T);E[y];){var U=e[E.charCodeAt(y)];if(U===255)return;for(var F=0,P=T-1;(U!==0||F<A)&&P!==-1;P--,F++)U+=a*w[P]>>>0,w[P]=U%256>>>0,U=U/256>>>0;if(U!==0)throw new Error("Non-zero carry");A=F,y++}if(E[y]!==" "){for(var R=T-A;R!==T&&w[R]===0;)R++;for(var b=new Uint8Array(d+(T-R)),v=d;R!==T;)b[v++]=w[R++];return b}}}function g(E){var y=h(E);if(y)return y;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:h,decode:g}}var Ph=Vh,Fh=Ph,dc=Fh;var Ki=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},qi=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){this.name=t,this.prefix=e;let o=e.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return pc(this,t)}},zi=class{decoders;constructor(t){this.decoders=t}or(t){return pc(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function pc(r,t){return new zi({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var ji=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new Ki(t,e,n),this.decoder=new qi(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function xr({name:r,prefix:t,encode:e,decode:n}){return new ji(r,t,e,n)}function _e({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=dc(e,r);return xr({prefix:t,name:r,encode:n,decode:i=>ye(o(i))})}function Dh(r,t,e,n){let o={};for(let u=0;u<t.length;++u)o[t[u]]=u;let i=r.length;for(;r[i-1]==="=";)--i;let s=new Uint8Array(i*e/8|0),a=0,c=0,f=0;for(let u=0;u<i;++u){let l=o[r[u]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<e|l,a+=e,a>=8&&(a-=8,s[f++]=255&c>>a)}if(a>=e||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s}function Oh(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,i="",s=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],s+=8;s>e;)s-=e,i+=t[o&a>>s];if(s!==0&&(i+=t[o&a<<e-s]),n)for(;i.length*e&7;)i+="=";return i}function at({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return xr({prefix:t,name:r,encode(o){return Oh(o,n,e)},decode(o){return Dh(o,n,e,r)}})}var Gt=at({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Mh=at({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Hh=at({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),$h=at({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Kh=at({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),qh=at({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),zh=at({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),jh=at({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Gh=at({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Wi={};Tt(Wi,{base58btc:()=>rt,base58flickr:()=>Wh});var rt=_e({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Wh=_e({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Yi={};Tt(Yi,{base64:()=>Zi,base64pad:()=>Zh,base64url:()=>Yh,base64urlpad:()=>Jh});var Zi=at({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Zh=at({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Yh=at({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Jh=at({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function Xh(r,t){try{if(typeof r=="string"&&r.length>0)return Qh(r);if(typeof r=="number"&&isFinite(r))return t?.long?ed(r):td(r);throw new Error("Value is not a string or number.")}catch(e){let n=rd(e)?`${e.message}. value=${JSON.stringify(r)}`:"An unknown error has occured.";throw new Error(n)}}function Qh(r){if(r=String(r),r.length>100)throw new Error("Value exceeds the maximum length of 100 characters.");let t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(r);if(!t)return NaN;let e=parseFloat(t[1]),n=(t[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return e*315576e5;case"weeks":case"week":case"w":return e*6048e5;case"days":case"day":case"d":return e*864e5;case"hours":case"hour":case"hrs":case"hr":case"h":return e*36e5;case"minutes":case"minute":case"mins":case"min":case"m":return e*6e4;case"seconds":case"second":case"secs":case"sec":case"s":return e*1e3;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return e;default:throw new Error(`The unit ${n} was matched, but no matching case exists.`)}}var Dn=Xh;function td(r){let t=Math.abs(r);return t>=864e5?`${Math.round(r/864e5)}d`:t>=36e5?`${Math.round(r/36e5)}h`:t>=6e4?`${Math.round(r/6e4)}m`:t>=1e3?`${Math.round(r/1e3)}s`:`${r}ms`}function ed(r){let t=Math.abs(r);return t>=864e5?Fn(r,t,864e5,"day"):t>=36e5?Fn(r,t,36e5,"hour"):t>=6e4?Fn(r,t,6e4,"minute"):t>=1e3?Fn(r,t,1e3,"second"):`${r} ms`}function Fn(r,t,e,n){let o=t>=e*1.5;return`${Math.round(r/e)} ${n}${o?"s":""}`}function rd(r){return typeof r=="object"&&r!==null&&"message"in r}function Ji(r){e.debug=e,e.default=e,e.coerce=c,e.disable=i,e.enable=o,e.enabled=s,e.humanize=Dn,e.destroy=f,Object.keys(r).forEach(u=>{e[u]=r[u]}),e.names=[],e.skips=[],e.formatters={};function t(u){let l=0;for(let h=0;h<u.length;h++)l=(l<<5)-l+u.charCodeAt(h),l|=0;return e.colors[Math.abs(l)%e.colors.length]}e.selectColor=t;function e(u){let l,h=null,g,E;function y(...d){if(!y.enabled)return;let A=y,T=Number(new Date),w=T-(l||T);A.diff=w,A.prev=l,A.curr=T,l=T,d[0]=e.coerce(d[0]),typeof d[0]!="string"&&d.unshift("%O");let U=0;d[0]=d[0].replace(/%([a-zA-Z%])/g,(P,R)=>{if(P==="%%")return"%";U++;let b=e.formatters[R];if(typeof b=="function"){let v=d[U];P=b.call(A,v),d.splice(U,1),U--}return P}),e.formatArgs.call(A,d),(A.log||e.log).apply(A,d)}return y.namespace=u,y.useColors=e.useColors(),y.color=e.selectColor(u),y.extend=n,y.destroy=e.destroy,Object.defineProperty(y,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(g!==e.namespaces&&(g=e.namespaces,E=e.enabled(u)),E),set:d=>{h=d}}),typeof e.init=="function"&&e.init(y),y}function n(u,l){let h=e(this.namespace+(typeof l>"u"?":":l)+u);return h.log=this.log,h}function o(u){e.save(u),e.namespaces=u,e.names=[],e.skips=[];let l,h=(typeof u=="string"?u:"").split(/[\s,]+/),g=h.length;for(l=0;l<g;l++)h[l]&&(u=h[l].replace(/\*/g,".*?"),u[0]==="-"?e.skips.push(new RegExp("^"+u.substr(1)+"$")):e.names.push(new RegExp("^"+u+"$")))}function i(){let u=[...e.names.map(a),...e.skips.map(a).map(l=>"-"+l)].join(",");return e.enable(""),u}function s(u){if(u[u.length-1]==="*")return!0;let l,h;for(l=0,h=e.skips.length;l<h;l++)if(e.skips[l].test(u))return!1;for(l=0,h=e.names.length;l<h;l++)if(e.names[l].test(u))return!0;return!1}function a(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}function c(u){return u instanceof Error?u.stack??u.message:u}function f(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return e.setupFormatters(e.formatters),e.enable(e.load()),e}var On=ud(),nd=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function od(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/(edge|trident)\/(\d+)/)!=null?!1:typeof document<"u"&&document.documentElement?.style?.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/firefox\/(\d+)/)!=null&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/applewebkit\/(\d+)/)}function id(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Dn(this.diff),!this.useColors)return;let t="color: "+this.color;r.splice(1,0,t,"color: inherit");let e=0,n=0;r[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(e++,o==="%c"&&(n=e))}),r.splice(n,0,t)}var sd=console.debug??console.log??(()=>{});function ad(r){try{r?On?.setItem("debug",r):On?.removeItem("debug")}catch{}}function cd(){let r;try{r=On?.getItem("debug")}catch{}return!r&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(r=globalThis.process.env.DEBUG),r}function ud(){try{return localStorage}catch{}}function ld(r){r.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}var mc=Ji({formatArgs:id,save:ad,load:cd,useColors:od,setupFormatters:ld,colors:nd,storage:On,log:sd});var _t=mc;_t.formatters.b=r=>r==null?"undefined":rt.baseEncode(r);_t.formatters.t=r=>r==null?"undefined":Gt.baseEncode(r);_t.formatters.m=r=>r==null?"undefined":Zi.baseEncode(r);_t.formatters.p=r=>r==null?"undefined":r.toString();_t.formatters.c=r=>r==null?"undefined":r.toString();_t.formatters.k=r=>r==null?"undefined":r.toString();_t.formatters.a=r=>r==null?"undefined":r.toString();_t.formatters.e=r=>r==null?"undefined":gc(r.stack)??gc(r.message)??r.toString();function fd(r){let t=()=>{};return t.enabled=!1,t.color="",t.diff=0,t.log=()=>{},t.namespace=r,t.destroy=()=>!0,t.extend=()=>t,t}function Le(r){let t=fd(`${r}:trace`);return _t.enabled(`${r}:trace`)&&_t.names.map(e=>e.toString()).find(e=>e.includes(":trace"))!=null&&(t=_t(`${r}:trace`)),Object.assign(_t(r),{error:_t(`${r}:error`),trace:t})}function gc(r){if(r!=null&&(r=r.trim(),r.length!==0))return r}var Xi={};Tt(Xi,{base36:()=>wr,base36upper:()=>hd});var wr=_e({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),hd=_e({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var dd=wc,yc=128,pd=127,md=~pd,gd=Math.pow(2,31);function wc(r,t,e){t=t||[],e=e||0;for(var n=e;r>=gd;)t[e++]=r&255|yc,r/=128;for(;r&md;)t[e++]=r&255|yc,r>>>=7;return t[e]=r|0,wc.bytes=e-n+1,t}var yd=Qi,xd=128,xc=127;function Qi(r,n){var e=0,n=n||0,o=0,i=n,s,a=r.length;do{if(i>=a)throw Qi.bytes=0,new RangeError("Could not decode varint");s=r[i++],e+=o<28?(s&xc)<<o:(s&xc)*Math.pow(2,o),o+=7}while(s>=xd);return Qi.bytes=i-n,e}var wd=Math.pow(2,7),bd=Math.pow(2,14),vd=Math.pow(2,21),Ed=Math.pow(2,28),Bd=Math.pow(2,35),Ad=Math.pow(2,42),Sd=Math.pow(2,49),Id=Math.pow(2,56),kd=Math.pow(2,63),Td=function(r){return r<wd?1:r<bd?2:r<vd?3:r<Ed?4:r<Bd?5:r<Ad?6:r<Sd?7:r<Id?8:r<kd?9:10},Cd={encode:dd,decode:yd,encodingLength:Td},Nd=Cd,Yr=Nd;function Jr(r,t=0){return[Yr.decode(r,t),Yr.decode.bytes]}function br(r,t,e=0){return Yr.encode(r,t,e),t}function vr(r){return Yr.encodingLength(r)}function Wt(r,t){let e=t.byteLength,n=vr(r),o=n+vr(e),i=new Uint8Array(o+e);return br(r,i,0),br(e,i,n),i.set(t,o),new Er(r,e,t,i)}function xe(r){let t=ye(r),[e,n]=Jr(t),[o,i]=Jr(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Er(e,o,s,t)}function bc(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&uc(r.bytes,e.bytes)}}var Er=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function vc(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return Rd(e,ts(r),t??rt.encoder);default:return _d(e,ts(r),t??Gt.encoder)}}var Ec=new WeakMap;function ts(r){let t=Ec.get(r);if(t==null){let e=new Map;return Ec.set(r,e),e}return t}var X=class r{code;version;multihash;bytes;"/";constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==Xr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Ld)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=Wt(t,e);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&bc(t.multihash,n.multihash)}toString(t){return vc(this,t)}toJSON(){return{"/":vc(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:i,bytes:s}=e;return new r(n,o,i,s??Bc(n,o,i.bytes))}else if(e[Vd]===!0){let{version:n,multihash:o,code:i}=e,s=xe(o);return r.create(n,i,s)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==Xr)throw new Error(`Version 0 CID must use dag-pb (code: ${Xr}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=Bc(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Xr,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=ye(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let i=o.subarray(e.multihashSize-e.digestSize),s=new Er(e.multihashCode,e.digestSize,i,o);return[e.version===0?r.createV0(s):r.createV1(e.codec,s),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[l,h]=Jr(t.subarray(e));return e+=h,l},o=n(),i=Xr;if(o===18?(o=0,e=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=e,a=n(),c=n(),f=e+c,u=f-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:u,size:f}}static parse(t,e){let[n,o]=Ud(t,e),i=r.decode(o);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return ts(i).set(n,t),i}};function Ud(r,t){switch(r[0]){case"Q":{let e=t??rt;return[rt.prefix,e.decode(`${rt.prefix}${r}`)]}case rt.prefix:{let e=t??rt;return[rt.prefix,e.decode(r)]}case Gt.prefix:{let e=t??Gt;return[Gt.prefix,e.decode(r)]}case wr.prefix:{let e=t??wr;return[wr.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function Rd(r,t,e){let{prefix:n}=e;if(n!==rt.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let i=e.encode(r).slice(1);return t.set(n,i),i}else return o}function _d(r,t,e){let{prefix:n}=e,o=t.get(n);if(o==null){let i=e.encode(r);return t.set(n,i),i}else return o}var Xr=112,Ld=18;function Bc(r,t,e){let n=vr(r),o=n+vr(t),i=new Uint8Array(o+e.byteLength);return br(r,i,0),br(t,i,n),i.set(e,o),i}var Vd=Symbol.for("@ipld/js-cid/CID");var es={};Tt(es,{identity:()=>Zt});var Ac=0,Pd="identity",Sc=ye;function Fd(r){return Wt(Ac,Sc(r))}var Zt={code:Ac,name:Pd,encode:Sc,digest:Fd};function ct(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function Ic(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function Dd(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Br(r,...t){if(!Dd(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error("Uint8Array expected of length "+t+", got length="+r.length)}function kc(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Ic(r.outputLen),Ic(r.blockLen)}function Ar(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function Tc(r,t){Br(r);let e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}var Qe=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var Hn=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),Yt=(r,t)=>r<<32-t|r>>>t;function Cc(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function Qr(r){return typeof r=="string"&&(r=Cc(r)),Br(r),r}function rs(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];Br(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let i=r[n];e.set(i,o),o+=i.length}return e}var Sr=class{clone(){return this._cloneInto()}};function $n(r){let t=n=>r().update(Qr(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function Kn(r=32){if(Qe&&typeof Qe.getRandomValues=="function")return Qe.getRandomValues(new Uint8Array(r));if(Qe&&typeof Qe.randomBytes=="function")return Qe.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function Od(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let o=BigInt(32),i=BigInt(4294967295),s=Number(e>>o&i),a=Number(e&i),c=n?4:0,f=n?0:4;r.setUint32(t+c,s,n),r.setUint32(t+f,a,n)}var Nc=(r,t,e)=>r&t^~r&e,Uc=(r,t,e)=>r&t^r&e^t&e,Ir=class extends Sr{constructor(t,e,n,o){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Hn(this.buffer)}update(t){Ar(this);let{view:e,buffer:n,blockLen:o}=this;t=Qr(t);let i=t.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let c=Hn(t);for(;o<=i-s;s+=o)this.process(c,s);continue}n.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Ar(this),Tc(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;e[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>o-s&&(this.process(n,0),s=0);for(let l=s;l<o;l++)e[l]=0;Od(n,o-8,BigInt(this.length*8),i),this.process(n,0);let a=Hn(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=c/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<f;l++)a.setUint32(4*l,u[l],i)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:o,finished:i,destroyed:s,pos:a}=this;return t.length=o,t.pos=a,t.finished=i,t.destroyed=s,o%e&&t.buffer.set(n),t}};var qn=BigInt(4294967295),ns=BigInt(32);function Rc(r,t=!1){return t?{h:Number(r&qn),l:Number(r>>ns&qn)}:{h:Number(r>>ns&qn)|0,l:Number(r&qn)|0}}function Md(r,t=!1){let e=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let o=0;o<r.length;o++){let{h:i,l:s}=Rc(r[o],t);[e[o],n[o]]=[i,s]}return[e,n]}var Hd=(r,t)=>BigInt(r>>>0)<<ns|BigInt(t>>>0),$d=(r,t,e)=>r>>>e,Kd=(r,t,e)=>r<<32-e|t>>>e,qd=(r,t,e)=>r>>>e|t<<32-e,zd=(r,t,e)=>r<<32-e|t>>>e,jd=(r,t,e)=>r<<64-e|t>>>e-32,Gd=(r,t,e)=>r>>>e-32|t<<64-e,Wd=(r,t)=>t,Zd=(r,t)=>r,Yd=(r,t,e)=>r<<e|t>>>32-e,Jd=(r,t,e)=>t<<e|r>>>32-e,Xd=(r,t,e)=>t<<e-32|r>>>64-e,Qd=(r,t,e)=>r<<e-32|t>>>64-e;function t0(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var e0=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),r0=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,n0=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),o0=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,i0=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),s0=(r,t,e,n,o,i)=>t+e+n+o+i+(r/2**32|0)|0;var a0={fromBig:Rc,split:Md,toBig:Hd,shrSH:$d,shrSL:Kd,rotrSH:qd,rotrSL:zd,rotrBH:jd,rotrBL:Gd,rotr32H:Wd,rotr32L:Zd,rotlSH:Yd,rotlSL:Jd,rotlBH:Xd,rotlBL:Qd,add:t0,add3L:e0,add3H:r0,add4L:n0,add4H:o0,add5H:s0,add5L:i0},q=a0;var[c0,u0]=q.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),Pe=new Uint32Array(80),Fe=new Uint32Array(80),os=class extends Ir{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:t,Al:e,Bh:n,Bl:o,Ch:i,Cl:s,Dh:a,Dl:c,Eh:f,El:u,Fh:l,Fl:h,Gh:g,Gl:E,Hh:y,Hl:d}=this;return[t,e,n,o,i,s,a,c,f,u,l,h,g,E,y,d]}set(t,e,n,o,i,s,a,c,f,u,l,h,g,E,y,d){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=u|0,this.Fh=l|0,this.Fl=h|0,this.Gh=g|0,this.Gl=E|0,this.Hh=y|0,this.Hl=d|0}process(t,e){for(let w=0;w<16;w++,e+=4)Pe[w]=t.getUint32(e),Fe[w]=t.getUint32(e+=4);for(let w=16;w<80;w++){let U=Pe[w-15]|0,F=Fe[w-15]|0,P=q.rotrSH(U,F,1)^q.rotrSH(U,F,8)^q.shrSH(U,F,7),R=q.rotrSL(U,F,1)^q.rotrSL(U,F,8)^q.shrSL(U,F,7),b=Pe[w-2]|0,v=Fe[w-2]|0,D=q.rotrSH(b,v,19)^q.rotrBH(b,v,61)^q.shrSH(b,v,6),_=q.rotrSL(b,v,19)^q.rotrBL(b,v,61)^q.shrSL(b,v,6),C=q.add4L(R,_,Fe[w-7],Fe[w-16]),$=q.add4H(C,P,D,Pe[w-7],Pe[w-16]);Pe[w]=$|0,Fe[w]=C|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:f,Dl:u,Eh:l,El:h,Fh:g,Fl:E,Gh:y,Gl:d,Hh:A,Hl:T}=this;for(let w=0;w<80;w++){let U=q.rotrSH(l,h,14)^q.rotrSH(l,h,18)^q.rotrBH(l,h,41),F=q.rotrSL(l,h,14)^q.rotrSL(l,h,18)^q.rotrBL(l,h,41),P=l&g^~l&y,R=h&E^~h&d,b=q.add5L(T,F,R,u0[w],Fe[w]),v=q.add5H(b,A,U,P,c0[w],Pe[w]),D=b|0,_=q.rotrSH(n,o,28)^q.rotrBH(n,o,34)^q.rotrBH(n,o,39),C=q.rotrSL(n,o,28)^q.rotrBL(n,o,34)^q.rotrBL(n,o,39),$=n&i^n&a^i&a,S=o&s^o&c^s&c;A=y|0,T=d|0,y=g|0,d=E|0,g=l|0,E=h|0,{h:l,l:h}=q.add(f|0,u|0,v|0,D|0),f=a|0,u=c|0,a=i|0,c=s|0,i=n|0,s=o|0;let I=q.add3L(D,C,S);n=q.add3H(I,v,_,$),o=I|0}({h:n,l:o}=q.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=q.add(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=q.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:u}=q.add(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:h}=q.add(this.Eh|0,this.El|0,l|0,h|0),{h:g,l:E}=q.add(this.Fh|0,this.Fl|0,g|0,E|0),{h:y,l:d}=q.add(this.Gh|0,this.Gl|0,y|0,d|0),{h:A,l:T}=q.add(this.Hh|0,this.Hl|0,A|0,T|0),this.set(n,o,i,s,a,c,f,u,l,h,g,E,y,d,A,T)}roundClean(){Pe.fill(0),Fe.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var _c=$n(()=>new os);var Gn={};Tt(Gn,{aInRange:()=>Lt,abool:()=>Jt,abytes:()=>kr,bitGet:()=>m0,bitLen:()=>cs,bitMask:()=>en,bitSet:()=>g0,bytesToHex:()=>be,bytesToNumberBE:()=>ve,bytesToNumberLE:()=>Oe,concatBytes:()=>Ee,createHmacDrbg:()=>us,ensureBytes:()=>st,equalBytes:()=>d0,hexToBytes:()=>er,hexToNumber:()=>as,inRange:()=>tn,isBytes:()=>De,memoized:()=>nr,notImplemented:()=>x0,numberToBytesBE:()=>Me,numberToBytesLE:()=>rr,numberToHexUnpadded:()=>tr,numberToVarBytesBE:()=>h0,utf8ToBytes:()=>p0,validateObject:()=>ue});var zn=BigInt(0),jn=BigInt(1),l0=BigInt(2);function De(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function kr(r){if(!De(r))throw new Error("Uint8Array expected")}function Jt(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}var f0=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function be(r){kr(r);let t="";for(let e=0;e<r.length;e++)t+=f0[r[e]];return t}function tr(r){let t=r.toString(16);return t.length&1?"0"+t:t}function as(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?zn:BigInt("0x"+r)}var we={_0:48,_9:57,A:65,F:70,a:97,f:102};function Lc(r){if(r>=we._0&&r<=we._9)return r-we._0;if(r>=we.A&&r<=we.F)return r-(we.A-10);if(r>=we.a&&r<=we.f)return r-(we.a-10)}function er(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let t=r.length,e=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let o=0,i=0;o<e;o++,i+=2){let s=Lc(r.charCodeAt(i)),a=Lc(r.charCodeAt(i+1));if(s===void 0||a===void 0){let c=r[i]+r[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}n[o]=s*16+a}return n}function ve(r){return as(be(r))}function Oe(r){return kr(r),as(be(Uint8Array.from(r).reverse()))}function Me(r,t){return er(r.toString(16).padStart(t*2,"0"))}function rr(r,t){return Me(r,t).reverse()}function h0(r){return er(tr(r))}function st(r,t,e){let n;if(typeof t=="string")try{n=er(t)}catch(i){throw new Error(r+" must be hex string or Uint8Array, cause: "+i)}else if(De(t))n=Uint8Array.from(t);else throw new Error(r+" must be hex string or Uint8Array");let o=n.length;if(typeof e=="number"&&o!==e)throw new Error(r+" of length "+e+" expected, got "+o);return n}function Ee(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];kr(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let i=r[n];e.set(i,o),o+=i.length}return e}function d0(r,t){if(r.length!==t.length)return!1;let e=0;for(let n=0;n<r.length;n++)e|=r[n]^t[n];return e===0}function p0(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}var is=r=>typeof r=="bigint"&&zn<=r;function tn(r,t,e){return is(r)&&is(t)&&is(e)&&t<=r&&r<e}function Lt(r,t,e,n){if(!tn(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function cs(r){let t;for(t=0;r>zn;r>>=jn,t+=1);return t}function m0(r,t){return r>>BigInt(t)&jn}function g0(r,t,e){return r|(e?jn:zn)<<BigInt(t)}var en=r=>(l0<<BigInt(r-1))-jn,ss=r=>new Uint8Array(r),Vc=r=>Uint8Array.from(r);function us(r,t,e){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let n=ss(r),o=ss(r),i=0,s=()=>{n.fill(1),o.fill(0),i=0},a=(...l)=>e(o,n,...l),c=(l=ss())=>{o=a(Vc([0]),l),n=a(),l.length!==0&&(o=a(Vc([1]),l),n=a())},f=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,h=[];for(;l<t;){n=a();let g=n.slice();h.push(g),l+=n.length}return Ee(...h)};return(l,h)=>{s(),c(l);let g;for(;!(g=h(f()));)c();return s(),g}}var y0={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||De(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,t)=>t.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function ue(r,t,e={}){let n=(o,i,s)=>{let a=y0[i];if(typeof a!="function")throw new Error("invalid validator function");let c=r[o];if(!(s&&c===void 0)&&!a(c,r))throw new Error("param "+String(o)+" is invalid. Expected "+i+", got "+c)};for(let[o,i]of Object.entries(t))n(o,i,!1);for(let[o,i]of Object.entries(e))n(o,i,!0);return r}var x0=()=>{throw new Error("not implemented")};function nr(r){let t=new WeakMap;return(e,...n)=>{let o=t.get(e);if(o!==void 0)return o;let i=r(e,...n);return t.set(e,i),i}}var lt=BigInt(0),ot=BigInt(1),or=BigInt(2),w0=BigInt(3),ls=BigInt(4),Pc=BigInt(5),Fc=BigInt(8),b0=BigInt(9),v0=BigInt(16);function Q(r,t){let e=r%t;return e>=lt?e:t+e}function E0(r,t,e){if(t<lt)throw new Error("invalid exponent, negatives unsupported");if(e<=lt)throw new Error("invalid modulus");if(e===ot)return lt;let n=ot;for(;t>lt;)t&ot&&(n=n*r%e),r=r*r%e,t>>=ot;return n}function it(r,t,e){let n=r;for(;t-- >lt;)n*=n,n%=e;return n}function Wn(r,t){if(r===lt)throw new Error("invert: expected non-zero number");if(t<=lt)throw new Error("invert: expected positive modulus, got "+t);let e=Q(r,t),n=t,o=lt,i=ot,s=ot,a=lt;for(;e!==lt;){let f=n/e,u=n%e,l=o-s*f,h=i-a*f;n=e,e=u,o=s,i=a,s=l,a=h}if(n!==ot)throw new Error("invert: does not exist");return Q(o,t)}function B0(r){let t=(r-ot)/or,e,n,o;for(e=r-ot,n=0;e%or===lt;e/=or,n++);for(o=or;o<r&&E0(o,t,r)!==r-ot;o++)if(o>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let s=(r+ot)/ls;return function(c,f){let u=c.pow(f,s);if(!c.eql(c.sqr(u),f))throw new Error("Cannot find square root");return u}}let i=(e+ot)/or;return function(a,c){if(a.pow(c,t)===a.neg(a.ONE))throw new Error("Cannot find square root");let f=n,u=a.pow(a.mul(a.ONE,o),e),l=a.pow(c,i),h=a.pow(c,e);for(;!a.eql(h,a.ONE);){if(a.eql(h,a.ZERO))return a.ZERO;let g=1;for(let y=a.sqr(h);g<f&&!a.eql(y,a.ONE);g++)y=a.sqr(y);let E=a.pow(u,ot<<BigInt(f-g-1));u=a.sqr(E),l=a.mul(l,E),h=a.mul(h,u),f=g}return l}}function A0(r){if(r%ls===w0){let t=(r+ot)/ls;return function(n,o){let i=n.pow(o,t);if(!n.eql(n.sqr(i),o))throw new Error("Cannot find square root");return i}}if(r%Fc===Pc){let t=(r-Pc)/Fc;return function(n,o){let i=n.mul(o,or),s=n.pow(i,t),a=n.mul(o,s),c=n.mul(n.mul(a,or),s),f=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(f),o))throw new Error("Cannot find square root");return f}}return r%v0,B0(r)}var Dc=(r,t)=>(Q(r,t)&ot)===ot,S0=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function fs(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=S0.reduce((n,o)=>(n[o]="function",n),t);return ue(r,e)}function I0(r,t,e){if(e<lt)throw new Error("invalid exponent, negatives unsupported");if(e===lt)return r.ONE;if(e===ot)return t;let n=r.ONE,o=t;for(;e>lt;)e&ot&&(n=r.mul(n,o)),o=r.sqr(o),e>>=ot;return n}function k0(r,t){let e=new Array(t.length),n=t.reduce((i,s,a)=>r.is0(s)?i:(e[a]=i,r.mul(i,s)),r.ONE),o=r.inv(n);return t.reduceRight((i,s,a)=>r.is0(s)?i:(e[a]=r.mul(i,e[a]),r.mul(i,s)),o),e}function hs(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function He(r,t,e=!1,n={}){if(r<=lt)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:o,nByteLength:i}=hs(r,t);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let s,a=Object.freeze({ORDER:r,BITS:o,BYTES:i,MASK:en(o),ZERO:lt,ONE:ot,create:c=>Q(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return lt<=c&&c<r},is0:c=>c===lt,isOdd:c=>(c&ot)===ot,neg:c=>Q(-c,r),eql:(c,f)=>c===f,sqr:c=>Q(c*c,r),add:(c,f)=>Q(c+f,r),sub:(c,f)=>Q(c-f,r),mul:(c,f)=>Q(c*f,r),pow:(c,f)=>I0(a,c,f),div:(c,f)=>Q(c*Wn(f,r),r),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>Wn(c,r),sqrt:n.sqrt||(c=>(s||(s=A0(r)),s(a,c))),invertBatch:c=>k0(a,c),cmov:(c,f,u)=>u?f:c,toBytes:c=>e?rr(c,i):Me(c,i),fromBytes:c=>{if(c.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+c.length);return e?Oe(c):ve(c)}});return Object.freeze(a)}function Oc(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let t=r.toString(2).length;return Math.ceil(t/8)}function ds(r){let t=Oc(r);return t+Math.ceil(t/2)}function Mc(r,t,e=!1){let n=r.length,o=Oc(t),i=ds(t);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=e?ve(r):Oe(r),a=Q(s,t-ot)+ot;return e?rr(a,o):Me(a,o)}var Hc=BigInt(0),Zn=BigInt(1);function ps(r,t){let e=t.negate();return r?e:t}function $c(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function ms(r,t){$c(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1);return{windows:e,windowSize:n}}function C0(r,t){if(!Array.isArray(r))throw new Error("array expected");r.forEach((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)})}function N0(r,t){if(!Array.isArray(r))throw new Error("array of scalars expected");r.forEach((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)})}var gs=new WeakMap,Kc=new WeakMap;function ys(r){return Kc.get(r)||1}function Yn(r,t){return{constTimeNegate:ps,hasPrecomputes(e){return ys(e)!==1},unsafeLadder(e,n,o=r.ZERO){let i=e;for(;n>Hc;)n&Zn&&(o=o.add(i)),i=i.double(),n>>=Zn;return o},precomputeWindow(e,n){let{windows:o,windowSize:i}=ms(n,t),s=[],a=e,c=a;for(let f=0;f<o;f++){c=a,s.push(c);for(let u=1;u<i;u++)c=c.add(a),s.push(c);a=c.double()}return s},wNAF(e,n,o){let{windows:i,windowSize:s}=ms(e,t),a=r.ZERO,c=r.BASE,f=BigInt(2**e-1),u=2**e,l=BigInt(e);for(let h=0;h<i;h++){let g=h*s,E=Number(o&f);o>>=l,E>s&&(E-=u,o+=Zn);let y=g,d=g+Math.abs(E)-1,A=h%2!==0,T=E<0;E===0?c=c.add(ps(A,n[y])):a=a.add(ps(T,n[d]))}return{p:a,f:c}},wNAFUnsafe(e,n,o,i=r.ZERO){let{windows:s,windowSize:a}=ms(e,t),c=BigInt(2**e-1),f=2**e,u=BigInt(e);for(let l=0;l<s;l++){let h=l*a;if(o===Hc)break;let g=Number(o&c);if(o>>=u,g>a&&(g-=f,o+=Zn),g===0)continue;let E=n[h+Math.abs(g)-1];g<0&&(E=E.negate()),i=i.add(E)}return i},getPrecomputes(e,n,o){let i=gs.get(n);return i||(i=this.precomputeWindow(n,e),e!==1&&gs.set(n,o(i))),i},wNAFCached(e,n,o){let i=ys(e);return this.wNAF(i,this.getPrecomputes(i,e,o),n)},wNAFCachedUnsafe(e,n,o,i){let s=ys(e);return s===1?this.unsafeLadder(e,n,i):this.wNAFUnsafe(s,this.getPrecomputes(s,e,o),n,i)},setWindowSize(e,n){$c(n,t),Kc.set(e,n),gs.delete(e)}}}function Jn(r,t,e,n){if(C0(e,r),N0(n,t),e.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=r.ZERO,i=cs(BigInt(e.length)),s=i>12?i-3:i>4?i-2:i?2:1,a=(1<<s)-1,c=new Array(a+1).fill(o),f=Math.floor((t.BITS-1)/s)*s,u=o;for(let l=f;l>=0;l-=s){c.fill(o);for(let g=0;g<n.length;g++){let E=n[g],y=Number(E>>BigInt(l)&BigInt(a));c[y]=c[y].add(e[g])}let h=o;for(let g=c.length-1,E=o;g>0;g--)E=E.add(c[g]),h=h.add(E);if(u=u.add(h),l!==0)for(let g=0;g<s;g++)u=u.double()}return u}function rn(r){return fs(r.Fp),ue(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...hs(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Xt=BigInt(0),Vt=BigInt(1),Xn=BigInt(2),U0=BigInt(8),R0={zip215:!0};function _0(r){let t=rn(r);return ue(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function qc(r){let t=_0(r),{Fp:e,n,prehash:o,hash:i,randomBytes:s,nByteLength:a,h:c}=t,f=Xn<<BigInt(a*8)-Vt,u=e.create,l=He(t.n,t.nBitLength),h=t.uvRatio||((m,p)=>{try{return{isValid:!0,value:e.sqrt(m*e.inv(p))}}catch{return{isValid:!1,value:Xt}}}),g=t.adjustScalarBytes||(m=>m),E=t.domain||((m,p,B)=>{if(Jt("phflag",B),p.length||B)throw new Error("Contexts/pre-hash are not supported");return m});function y(m,p){Lt("coordinate "+m,p,Xt,f)}function d(m){if(!(m instanceof w))throw new Error("ExtendedPoint expected")}let A=nr((m,p)=>{let{ex:B,ey:N,ez:O}=m,M=m.is0();p==null&&(p=M?U0:e.inv(O));let z=u(B*p),G=u(N*p),K=u(O*p);if(M)return{x:Xt,y:Vt};if(K!==Vt)throw new Error("invZ was invalid");return{x:z,y:G}}),T=nr(m=>{let{a:p,d:B}=t;if(m.is0())throw new Error("bad point: ZERO");let{ex:N,ey:O,ez:M,et:z}=m,G=u(N*N),K=u(O*O),J=u(M*M),et=u(J*J),ht=u(G*p),dt=u(J*u(ht+K)),yt=u(et+u(B*u(G*K)));if(dt!==yt)throw new Error("bad point: equation left != right (1)");let vt=u(N*O),Ut=u(M*z);if(vt!==Ut)throw new Error("bad point: equation left != right (2)");return!0});class w{constructor(p,B,N,O){this.ex=p,this.ey=B,this.ez=N,this.et=O,y("x",p),y("y",B),y("z",N),y("t",O),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(p){if(p instanceof w)throw new Error("extended point not allowed");let{x:B,y:N}=p||{};return y("x",B),y("y",N),new w(B,N,Vt,u(B*N))}static normalizeZ(p){let B=e.invertBatch(p.map(N=>N.ez));return p.map((N,O)=>N.toAffine(B[O])).map(w.fromAffine)}static msm(p,B){return Jn(w,l,p,B)}_setWindowSize(p){P.setWindowSize(this,p)}assertValidity(){T(this)}equals(p){d(p);let{ex:B,ey:N,ez:O}=this,{ex:M,ey:z,ez:G}=p,K=u(B*G),J=u(M*O),et=u(N*G),ht=u(z*O);return K===J&&et===ht}is0(){return this.equals(w.ZERO)}negate(){return new w(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:p}=t,{ex:B,ey:N,ez:O}=this,M=u(B*B),z=u(N*N),G=u(Xn*u(O*O)),K=u(p*M),J=B+N,et=u(u(J*J)-M-z),ht=K+z,dt=ht-G,yt=K-z,vt=u(et*dt),Ut=u(ht*yt),kt=u(et*yt),ce=u(dt*ht);return new w(vt,Ut,ce,kt)}add(p){d(p);let{a:B,d:N}=t,{ex:O,ey:M,ez:z,et:G}=this,{ex:K,ey:J,ez:et,et:ht}=p;if(B===BigInt(-1)){let Qa=u((M-O)*(J+K)),tc=u((M+O)*(J-K)),Mi=u(tc-Qa);if(Mi===Xt)return this.double();let ec=u(z*Xn*ht),rc=u(G*Xn*et),nc=rc+ec,oc=tc+Qa,ic=rc-ec,Sh=u(nc*Mi),Ih=u(oc*ic),kh=u(nc*ic),Th=u(Mi*oc);return new w(Sh,Ih,Th,kh)}let dt=u(O*K),yt=u(M*J),vt=u(G*N*ht),Ut=u(z*et),kt=u((O+M)*(K+J)-dt-yt),ce=Ut-vt,ge=Ut+vt,Zr=u(yt-B*dt),vh=u(kt*ce),Eh=u(ge*Zr),Bh=u(kt*Zr),Ah=u(ce*ge);return new w(vh,Eh,Ah,Bh)}subtract(p){return this.add(p.negate())}wNAF(p){return P.wNAFCached(this,p,w.normalizeZ)}multiply(p){let B=p;Lt("scalar",B,Vt,n);let{p:N,f:O}=this.wNAF(B);return w.normalizeZ([N,O])[0]}multiplyUnsafe(p,B=w.ZERO){let N=p;return Lt("scalar",N,Xt,n),N===Xt?F:this.is0()||N===Vt?this:P.wNAFCachedUnsafe(this,N,w.normalizeZ,B)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return P.unsafeLadder(this,n).is0()}toAffine(p){return A(this,p)}clearCofactor(){let{h:p}=t;return p===Vt?this:this.multiplyUnsafe(p)}static fromHex(p,B=!1){let{d:N,a:O}=t,M=e.BYTES;p=st("pointHex",p,M),Jt("zip215",B);let z=p.slice(),G=p[M-1];z[M-1]=G&-129;let K=Oe(z),J=B?f:e.ORDER;Lt("pointHex.y",K,Xt,J);let et=u(K*K),ht=u(et-Vt),dt=u(N*et-O),{isValid:yt,value:vt}=h(ht,dt);if(!yt)throw new Error("Point.fromHex: invalid y coordinate");let Ut=(vt&Vt)===Vt,kt=(G&128)!==0;if(!B&&vt===Xt&&kt)throw new Error("Point.fromHex: x=0 and x_0=1");return kt!==Ut&&(vt=u(-vt)),w.fromAffine({x:vt,y:K})}static fromPrivateKey(p){return v(p).point}toRawBytes(){let{x:p,y:B}=this.toAffine(),N=rr(B,e.BYTES);return N[N.length-1]|=p&Vt?128:0,N}toHex(){return be(this.toRawBytes())}}w.BASE=new w(t.Gx,t.Gy,Vt,u(t.Gx*t.Gy)),w.ZERO=new w(Xt,Vt,Vt,Xt);let{BASE:U,ZERO:F}=w,P=Yn(w,a*8);function R(m){return Q(m,n)}function b(m){return R(Oe(m))}function v(m){let p=e.BYTES;m=st("private key",m,p);let B=st("hashed private key",i(m),2*p),N=g(B.slice(0,p)),O=B.slice(p,2*p),M=b(N),z=U.multiply(M),G=z.toRawBytes();return{head:N,prefix:O,scalar:M,point:z,pointBytes:G}}function D(m){return v(m).pointBytes}function _(m=new Uint8Array,...p){let B=Ee(...p);return b(i(E(B,st("context",m),!!o)))}function C(m,p,B={}){m=st("message",m),o&&(m=o(m));let{prefix:N,scalar:O,pointBytes:M}=v(p),z=_(B.context,N,m),G=U.multiply(z).toRawBytes(),K=_(B.context,G,M,m),J=R(z+K*O);Lt("signature.s",J,Xt,n);let et=Ee(G,rr(J,e.BYTES));return st("result",et,e.BYTES*2)}let $=R0;function S(m,p,B,N=$){let{context:O,zip215:M}=N,z=e.BYTES;m=st("signature",m,2*z),p=st("message",p),B=st("publicKey",B,z),M!==void 0&&Jt("zip215",M),o&&(p=o(p));let G=Oe(m.slice(z,2*z)),K,J,et;try{K=w.fromHex(B,M),J=w.fromHex(m.slice(0,z),M),et=U.multiplyUnsafe(G)}catch{return!1}if(!M&&K.isSmallOrder())return!1;let ht=_(O,J.toRawBytes(),K.toRawBytes(),p);return J.add(K.multiplyUnsafe(ht)).subtract(et).clearCofactor().equals(w.ZERO)}return U._setWindowSize(8),{CURVE:t,getPublicKey:D,sign:C,verify:S,ExtendedPoint:w,utils:{getExtendedPublicKey:v,randomPrivateKey:()=>s(e.BYTES),precompute(m=8,p=w.BASE){return p._setWindowSize(m),p.multiply(BigInt(3)),p}}}}var xs=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),zc=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Vy=BigInt(0),L0=BigInt(1),jc=BigInt(2),Py=BigInt(3),V0=BigInt(5),P0=BigInt(8);function F0(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),i=xs,a=r*r%i*r%i,c=it(a,jc,i)*a%i,f=it(c,L0,i)*r%i,u=it(f,V0,i)*f%i,l=it(u,t,i)*u%i,h=it(l,e,i)*l%i,g=it(h,n,i)*h%i,E=it(g,o,i)*g%i,y=it(E,o,i)*g%i,d=it(y,t,i)*u%i;return{pow_p_5_8:it(d,jc,i)*r%i,b2:a}}function D0(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function O0(r,t){let e=xs,n=Q(t*t*t,e),o=Q(n*n*t,e),i=F0(r*o).pow_p_5_8,s=Q(r*n*i,e),a=Q(t*s*s,e),c=s,f=Q(s*zc,e),u=a===r,l=a===Q(-r,e),h=a===Q(-r*zc,e);return u&&(s=c),(l||h)&&(s=f),Dc(s,e)&&(s=Q(-s,e)),{isValid:u||l,value:s}}var M0=He(xs,void 0,!0),H0={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:M0,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:P0,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:_c,randomBytes:Kn,adjustScalarBytes:D0,uvRatio:O0},Gc=qc(H0);var Qn=32;function Wc(r,t,e){return Gc.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}var to=class{type="Ed25519";raw;constructor(t){this.raw=ws(t,Qn)}toMultihash(){return Zt.digest(eo(this))}toCID(){return X.createV1(114,this.toMultihash())}toString(){return rt.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ct(this.raw,t.raw)}verify(t,e){return Wc(this.raw,e,t)}};function bs(r){return r=ws(r,Qn),new to(r)}function ws(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new Et(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}function Qt(r=0){return new Uint8Array(r)}var K0=Math.pow(2,7),q0=Math.pow(2,14),z0=Math.pow(2,21),vs=Math.pow(2,28),Es=Math.pow(2,35),Bs=Math.pow(2,42),As=Math.pow(2,49),Y=128,Bt=127;function Pt(r){if(r<K0)return 1;if(r<q0)return 2;if(r<z0)return 3;if(r<vs)return 4;if(r<Es)return 5;if(r<Bs)return 6;if(r<As)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Ss(r,t,e=0){switch(Pt(r)){case 8:t[e++]=r&255|Y,r/=128;case 7:t[e++]=r&255|Y,r/=128;case 6:t[e++]=r&255|Y,r/=128;case 5:t[e++]=r&255|Y,r/=128;case 4:t[e++]=r&255|Y,r>>>=7;case 3:t[e++]=r&255|Y,r>>>=7;case 2:t[e++]=r&255|Y,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function j0(r,t,e=0){switch(Pt(r)){case 8:t.set(e++,r&255|Y),r/=128;case 7:t.set(e++,r&255|Y),r/=128;case 6:t.set(e++,r&255|Y),r/=128;case 5:t.set(e++,r&255|Y),r/=128;case 4:t.set(e++,r&255|Y),r>>>=7;case 3:t.set(e++,r&255|Y),r>>>=7;case 2:t.set(e++,r&255|Y),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function Is(r,t){let e=r[t],n=0;if(n+=e&Bt,e<Y||(e=r[t+1],n+=(e&Bt)<<7,e<Y)||(e=r[t+2],n+=(e&Bt)<<14,e<Y)||(e=r[t+3],n+=(e&Bt)<<21,e<Y)||(e=r[t+4],n+=(e&Bt)*vs,e<Y)||(e=r[t+5],n+=(e&Bt)*Es,e<Y)||(e=r[t+6],n+=(e&Bt)*Bs,e<Y)||(e=r[t+7],n+=(e&Bt)*As,e<Y))return n;throw new RangeError("Could not decode varint")}function G0(r,t){let e=r.get(t),n=0;if(n+=e&Bt,e<Y||(e=r.get(t+1),n+=(e&Bt)<<7,e<Y)||(e=r.get(t+2),n+=(e&Bt)<<14,e<Y)||(e=r.get(t+3),n+=(e&Bt)<<21,e<Y)||(e=r.get(t+4),n+=(e&Bt)*vs,e<Y)||(e=r.get(t+5),n+=(e&Bt)*Es,e<Y)||(e=r.get(t+6),n+=(e&Bt)*Bs,e<Y)||(e=r.get(t+7),n+=(e&Bt)*As,e<Y))return n;throw new RangeError("Could not decode varint")}function Tr(r,t,e=0){return t==null&&(t=Qt(Pt(r))),t instanceof Uint8Array?Ss(r,t,e):j0(r,t,e)}function ir(r,t=0){return r instanceof Uint8Array?Is(r,t):G0(r,t)}var ks=new Float32Array([-0]),$e=new Uint8Array(ks.buffer);function Jc(r,t,e){ks[0]=r,t[e]=$e[0],t[e+1]=$e[1],t[e+2]=$e[2],t[e+3]=$e[3]}function Xc(r,t){return $e[0]=r[t],$e[1]=r[t+1],$e[2]=r[t+2],$e[3]=r[t+3],ks[0]}var Ts=new Float64Array([-0]),At=new Uint8Array(Ts.buffer);function Qc(r,t,e){Ts[0]=r,t[e]=At[0],t[e+1]=At[1],t[e+2]=At[2],t[e+3]=At[3],t[e+4]=At[4],t[e+5]=At[5],t[e+6]=At[6],t[e+7]=At[7]}function tu(r,t){return At[0]=r[t],At[1]=r[t+1],At[2]=r[t+2],At[3]=r[t+3],At[4]=r[t+4],At[5]=r[t+5],At[6]=r[t+6],At[7]=r[t+7],Ts[0]}var W0=BigInt(Number.MAX_SAFE_INTEGER),Z0=BigInt(Number.MIN_SAFE_INTEGER),Dt=class r{lo;hi;constructor(t,e){this.lo=t|0,this.hi=e|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(e+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return sr;if(t<W0&&t>Z0)return this.fromNumber(Number(t));let e=t<0n;e&&(t=-t);let n=t>>32n,o=t-(n<<32n);return e&&(n=~n|0n,o=~o|0n,++o>eu&&(o=0n,++n>eu&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return sr;let e=t<0;e&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return e&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}static from(t){return typeof t=="number"?r.fromNumber(t):typeof t=="bigint"?r.fromBigInt(t):typeof t=="string"?r.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new r(t.low>>>0,t.high>>>0):sr}},sr=new Dt(0,0);sr.toBigInt=function(){return 0n};sr.zzEncode=sr.zzDecode=function(){return this};sr.length=function(){return 1};var eu=4294967296n;function ru(r){let t=0,e=0;for(let n=0;n<r.length;++n)e=r.charCodeAt(n),e<128?t+=1:e<2048?t+=2:(e&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function nu(r,t,e){if(e-t<1)return"";let o,i=[],s=0,a;for(;t<e;)a=r[t++],a<128?i[s++]=a:a>191&&a<224?i[s++]=(a&31)<<6|r[t++]&63:a>239&&a<365?(a=((a&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,i[s++]=55296+(a>>10),i[s++]=56320+(a&1023)):i[s++]=(a&15)<<12|(r[t++]&63)<<6|r[t++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function Cs(r,t,e){let n=e,o,i;for(let s=0;s<r.length;++s)o=r.charCodeAt(s),o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&((i=r.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,t[e++]=o>>18|240,t[e++]=o>>12&63|128,t[e++]=o>>6&63|128,t[e++]=o&63|128):(t[e++]=o>>12|224,t[e++]=o>>6&63|128,t[e++]=o&63|128);return e-n}function te(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function ro(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var Ns=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,te(this,10);return t}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw te(this,4);return ro(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw te(this,4);return ro(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw te(this,4);let t=Xc(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw te(this,4);let t=tu(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw te(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return nu(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw te(this,t);this.pos+=t}else do if(this.pos>=this.len)throw te(this);while(this.buf[this.pos++]&128);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new Dt(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw te(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,t}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw te(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw te(this,8);let t=ro(this.buf,this.pos+=4),e=ro(this.buf,this.pos+=4);return new Dt(t,e)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=Is(this.buf,this.pos);return this.pos+=Pt(t),t}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function Us(r){return new Ns(r instanceof Uint8Array?r:r.subarray())}function Cr(r,t,e){let n=Us(r);return t.decode(n,void 0,e)}var Rs={};Tt(Rs,{base10:()=>Y0});var Y0=_e({prefix:"9",name:"base10",alphabet:"0123456789"});var _s={};Tt(_s,{base16:()=>J0,base16upper:()=>X0});var J0=at({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),X0=at({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ls={};Tt(Ls,{base2:()=>Q0});var Q0=at({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Vs={};Tt(Vs,{base256emoji:()=>op});var iu=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),tp=iu.reduce((r,t,e)=>(r[e]=t,r),[]),ep=iu.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function rp(r){return r.reduce((t,e)=>(t+=tp[e],t),"")}function np(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=ep[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var op=xr({prefix:"\u{1F680}",name:"base256emoji",encode:rp,decode:np});var Ps={};Tt(Ps,{base8:()=>ip});var ip=at({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Fs={};Tt(Fs,{identity:()=>sp});var sp=xr({prefix:"\0",name:"identity",encode:r=>fc(r),decode:r=>lc(r)});var yx=new TextEncoder,xx=new TextDecoder;var Ms={};Tt(Ms,{sha256:()=>nn,sha512:()=>up});function Os({name:r,code:t,encode:e}){return new Ds(r,t,e)}var Ds=class{name;code;encode;constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?Wt(this.code,e):e.then(n=>Wt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function au(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var nn=Os({name:"sha2-256",code:18,encode:au("SHA-256")}),up=Os({name:"sha2-512",code:19,encode:au("SHA-512")});var on={...Fs,...Ls,...Ps,...Rs,..._s,...Gi,...Xi,...Wi,...Yi,...Vs},Nx={...Ms,...es};function uu(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var cu=uu("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Hs=uu("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=Qt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),lp={utf8:cu,"utf-8":cu,hex:on.base16,latin1:Hs,ascii:Hs,binary:Hs,...on},no=lp;function W(r,t="utf8"){let e=no[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function $s(r){let t=r??8192,e=t>>>1,n,o=t;return function(s){if(s<1||s>e)return Qt(s);o+s>t&&(n=Qt(t),o=0);let a=n.subarray(o,o+=s);return o&7&&(o=(o|7)+1),a}}var ar=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function Ks(){}var zs=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},fp=$s();function hp(r){return globalThis.Buffer!=null?Qt(r):fp(r)}var an=class{len;head;tail;states;constructor(){this.len=0,this.head=new ar(Ks,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new ar(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new js((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this}int32(t){return t<0?this._push(oo,10,Dt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=Dt.fromBigInt(t);return this._push(oo,e.length(),e)}uint64Number(t){return this._push(Ss,Pt(t),t)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let e=Dt.fromBigInt(t).zzEncode();return this._push(oo,e.length(),e)}sint64Number(t){let e=Dt.fromNumber(t).zzEncode();return this._push(oo,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(qs,1,t?1:0)}fixed32(t){return this._push(sn,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=Dt.fromBigInt(t);return this._push(sn,4,e.lo)._push(sn,4,e.hi)}fixed64Number(t){let e=Dt.fromNumber(t);return this._push(sn,4,e.lo)._push(sn,4,e.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(Jc,4,t)}double(t){return this._push(Qc,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(qs,1,0):this.uint32(e)._push(pp,e,t)}string(t){let e=ru(t);return e!==0?this.uint32(e)._push(Cs,e,t):this._push(qs,1,0)}fork(){return this.states=new zs(this),this.head=this.tail=new ar(Ks,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new ar(Ks,0,0),this.len=0),this}ldelim(){let t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=e,this.len+=n),this}finish(){let t=this.head.next,e=hp(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function qs(r,t,e){t[e]=r&255}function dp(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var js=class extends ar{next;constructor(t,e){super(dp,t,e),this.next=void 0}};function oo(r,t,e){for(;r.hi!==0;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}function sn(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function pp(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(an.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(mp,t,r),this},an.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(gp,t,r),this});function mp(r,t,e){t.set(r,e)}function gp(r,t,e){r.length<40?Cs(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(W(r),e)}function Gs(){return new an}function Nr(r,t){let e=Gs();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var Ur;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(Ur||(Ur={}));function io(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function cn(r){function t(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let e=function(i,s){let a=t(i);s.int32(a)},n=function(i){let s=i.int32();return t(s)};return io("enum",Ur.VARINT,e,n)}function Rr(r,t){return io("message",Ur.LENGTH_DELIMITED,r,t)}var ft;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1"})(ft||(ft={}));var Ws;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1"})(Ws||(Ws={}));(function(r){r.codec=()=>cn(Ws)})(ft||(ft={}));var le;(function(r){let t;r.codec=()=>(t==null&&(t=Rr((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),ft.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let a=e.uint32();switch(a>>>3){case 1:{i.Type=ft.codec().decode(e);break}case 2:{i.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return i})),t),r.encode=e=>Nr(e,r.codec()),r.decode=(e,n)=>Cr(e,r.codec(),n)})(le||(le={}));var Zs;(function(r){let t;r.codec=()=>(t==null&&(t=Rr((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),ft.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let a=e.uint32();switch(a>>>3){case 1:{i.Type=ft.codec().decode(e);break}case 2:{i.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return i})),t),r.encode=e=>Nr(e,r.codec()),r.decode=(e,n)=>Cr(e,r.codec(),n)})(Zs||(Zs={}));var xn={};Tt(xn,{MAX_RSA_KEY_SIZE:()=>ei,generateRSAKeyPair:()=>ll,jwkToJWKKeyPair:()=>fl,jwkToPkcs1:()=>Vp,jwkToPkix:()=>aa,jwkToRSAPrivateKey:()=>ul,pkcs1ToJwk:()=>sl,pkcs1ToRSAPrivateKey:()=>cl,pkixToJwk:()=>al,pkixToRSAPublicKey:()=>ca});function yp(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Ys(r,...t){if(!yp(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error("Uint8Array expected of length "+t+", got length="+r.length)}function Js(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function fu(r,t){Ys(r);let e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}var ao=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),ee=(r,t)=>r<<32-t|r>>>t;function xp(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function Xs(r){return typeof r=="string"&&(r=xp(r)),Ys(r),r}var so=class{clone(){return this._cloneInto()}};function hu(r){let t=n=>r().update(Xs(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function wp(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let o=BigInt(32),i=BigInt(4294967295),s=Number(e>>o&i),a=Number(e&i),c=n?4:0,f=n?0:4;r.setUint32(t+c,s,n),r.setUint32(t+f,a,n)}var du=(r,t,e)=>r&t^~r&e,pu=(r,t,e)=>r&t^r&e^t&e,co=class extends so{constructor(t,e,n,o){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=ao(this.buffer)}update(t){Js(this);let{view:e,buffer:n,blockLen:o}=this;t=Xs(t);let i=t.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let c=ao(t);for(;o<=i-s;s+=o)this.process(c,s);continue}n.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Js(this),fu(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;e[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>o-s&&(this.process(n,0),s=0);for(let l=s;l<o;l++)e[l]=0;wp(n,o-8,BigInt(this.length*8),i),this.process(n,0);let a=ao(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=c/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<f;l++)a.setUint32(4*l,u[l],i)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:o,finished:i,destroyed:s,pos:a}=this;return t.length=o,t.pos=a,t.finished=i,t.destroyed=s,o%e&&t.buffer.set(n),t}};var bp=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ke=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),qe=new Uint32Array(64),Qs=class extends co{constructor(){super(64,32,8,!1),this.A=Ke[0]|0,this.B=Ke[1]|0,this.C=Ke[2]|0,this.D=Ke[3]|0,this.E=Ke[4]|0,this.F=Ke[5]|0,this.G=Ke[6]|0,this.H=Ke[7]|0}get(){let{A:t,B:e,C:n,D:o,E:i,F:s,G:a,H:c}=this;return[t,e,n,o,i,s,a,c]}set(t,e,n,o,i,s,a,c){this.A=t|0,this.B=e|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(t,e){for(let l=0;l<16;l++,e+=4)qe[l]=t.getUint32(e,!1);for(let l=16;l<64;l++){let h=qe[l-15],g=qe[l-2],E=ee(h,7)^ee(h,18)^h>>>3,y=ee(g,17)^ee(g,19)^g>>>10;qe[l]=y+qe[l-7]+E+qe[l-16]|0}let{A:n,B:o,C:i,D:s,E:a,F:c,G:f,H:u}=this;for(let l=0;l<64;l++){let h=ee(a,6)^ee(a,11)^ee(a,25),g=u+h+du(a,c,f)+bp[l]+qe[l]|0,y=(ee(n,2)^ee(n,13)^ee(n,22))+pu(n,o,i)|0;u=f,f=c,c=a,a=s+g|0,s=i,i=o,o=n,n=g+y|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(n,o,i,s,a,c,f,u)}roundClean(){qe.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var uo=hu(()=>new Qs);var j=Vn(mu());function cr(r,t){let e=0;if(r.length===1)return r[0];for(let n=r.length-1;n>=0;n--)e+=r[r.length-1-n]*Math.pow(2,t*n);return e}function ze(r,t,e=-1){let n=e,o=r,i=0,s=Math.pow(2,t);for(let a=1;a<8;a++){if(r<s){let c;if(n<0)c=new ArrayBuffer(a),i=a;else{if(n<a)return new ArrayBuffer(0);c=new ArrayBuffer(n),i=n}let f=new Uint8Array(c);for(let u=a-1;u>=0;u--){let l=Math.pow(2,u*t);f[i-u-1]=Math.floor(o/l),o-=f[i-u-1]*l}return c}s*=Math.pow(2,t)}return new ArrayBuffer(0)}function ho(...r){let t=0,e=0;for(let i of r)t+=i.length;let n=new ArrayBuffer(t),o=new Uint8Array(n);for(let i of r)o.set(i,e),e+=i.length;return o}function ea(){let r=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){let a=r[0]===255&&r[1]&128,c=r[0]===0&&(r[1]&128)===0;(a||c)&&this.warnings.push("Needlessly long format")}let t=new ArrayBuffer(this.valueHex.byteLength),e=new Uint8Array(t);for(let a=0;a<this.valueHex.byteLength;a++)e[a]=0;e[0]=r[0]&128;let n=cr(e,8),o=new ArrayBuffer(this.valueHex.byteLength),i=new Uint8Array(o);for(let a=0;a<this.valueHex.byteLength;a++)i[a]=r[a];return i[0]&=127,cr(i,8)-n}function gu(r){let t=r<0?r*-1:r,e=128;for(let n=1;n<8;n++){if(t<=e){if(r<0){let s=e-t,a=ze(s,8,n),c=new Uint8Array(a);return c[0]|=128,a}let o=ze(t,8,n),i=new Uint8Array(o);if(i[0]&128){let s=o.slice(0),a=new Uint8Array(s);o=new ArrayBuffer(o.byteLength+1),i=new Uint8Array(o);for(let c=0;c<s.byteLength;c++)i[c+1]=a[c];i[0]=0}return o}e*=Math.pow(2,8)}return new ArrayBuffer(0)}function yu(r,t){if(r.byteLength!==t.byteLength)return!1;let e=new Uint8Array(r),n=new Uint8Array(t);for(let o=0;o<e.length;o++)if(e[o]!==n[o])return!1;return!0}function Ft(r,t){let e=r.toString(10);if(t<e.length)return"";let n=t-e.length,o=new Array(n);for(let s=0;s<n;s++)o[s]="0";return o.join("").concat(e)}var yw=Math.log(2);function po(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function ra(r){let t=0,e=0;for(let o=0;o<r.length;o++){let i=r[o];t+=i.byteLength}let n=new Uint8Array(t);for(let o=0;o<r.length;o++){let i=r[o];n.set(new Uint8Array(i),e),e+=i.byteLength}return n.buffer}function ke(r,t,e,n){return t instanceof Uint8Array?t.byteLength?e<0?(r.error="Wrong parameter: inputOffset less than zero",!1):n<0?(r.error="Wrong parameter: inputLength less than zero",!1):t.byteLength-e-n<0?(r.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(r.error="Wrong parameter: inputBuffer has zero length",!1):(r.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}var ln=class{constructor(){this.items=[]}write(t){this.items.push(t)}final(){return ra(this.items)}},un=[new Uint8Array([1])],xu="0123456789";var Fr="",re=new ArrayBuffer(0),na=new Uint8Array(0),fn="EndOfContent",bu="OCTET STRING",vu="BIT STRING";function Te(r){var t;return t=class extends r{constructor(...n){var o;super(...n);let i=n[0]||{};this.isHexOnly=(o=i.isHexOnly)!==null&&o!==void 0?o:!1,this.valueHexView=i.valueHex?j.BufferSourceConverter.toUint8Array(i.valueHex):na}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(n){this.valueHexView=new Uint8Array(n)}fromBER(n,o,i){let s=n instanceof ArrayBuffer?new Uint8Array(n):n;if(!ke(this,s,o,i))return-1;let a=o+i;return this.valueHexView=s.subarray(o,a),this.valueHexView.length?(this.blockLength=i,a):(this.warnings.push("Zero buffer length"),o)}toBER(n=!1){return this.isHexOnly?n?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",re)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:j.Convert.ToHex(this.valueHexView)}}},t.NAME="hexBlock",t}var Ae=class{constructor({blockLength:t=0,error:e=Fr,warnings:n=[],valueBeforeDecode:o=na}={}){this.blockLength=t,this.error=e,this.warnings=n,this.valueBeforeDecodeView=j.BufferSourceConverter.toUint8Array(o)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(t){this.valueBeforeDecodeView=new Uint8Array(t)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:j.Convert.ToHex(this.valueBeforeDecodeView)}}};Ae.NAME="baseBlock";var St=class extends Ae{fromBER(t,e,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(t,e){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}};St.NAME="valueBlock";var mo=class extends Te(Ae){constructor({idBlock:t={}}={}){var e,n,o,i;super(),t?(this.isHexOnly=(e=t.isHexOnly)!==null&&e!==void 0?e:!1,this.valueHexView=t.valueHex?j.BufferSourceConverter.toUint8Array(t.valueHex):na,this.tagClass=(n=t.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(o=t.tagNumber)!==null&&o!==void 0?o:-1,this.isConstructed=(i=t.isConstructed)!==null&&i!==void 0?i:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(t=!1){let e=0;switch(this.tagClass){case 1:e|=0;break;case 2:e|=64;break;case 3:e|=128;break;case 4:e|=192;break;default:return this.error="Unknown tag class",re}if(this.isConstructed&&(e|=32),this.tagNumber<31&&!this.isHexOnly){let o=new Uint8Array(1);if(!t){let i=this.tagNumber;i&=31,e|=i,o[0]=e}return o.buffer}if(!this.isHexOnly){let o=ze(this.tagNumber,7),i=new Uint8Array(o),s=o.byteLength,a=new Uint8Array(s+1);if(a[0]=e|31,!t){for(let c=0;c<s-1;c++)a[c+1]=i[c]|128;a[s]=i[s-1]}return a.buffer}let n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=e|31,!t){let o=this.valueHexView;for(let i=0;i<o.length-1;i++)n[i+1]=o[i]|128;n[this.valueHexView.byteLength]=o[o.length-1]}return n.buffer}fromBER(t,e,n){let o=j.BufferSourceConverter.toUint8Array(t);if(!ke(this,o,e,n))return-1;let i=o.subarray(e,e+n);if(i.length===0)return this.error="Zero buffer length",-1;switch(i[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(i[0]&32)===32,this.isHexOnly=!1;let a=i[0]&31;if(a!==31)this.tagNumber=a,this.blockLength=1;else{let c=1,f=this.valueHexView=new Uint8Array(255),u=255;for(;i[c]&128;){if(f[c-1]=i[c]&127,c++,c>=i.length)return this.error="End of input reached before message was fully decoded",-1;if(c===u){u+=255;let h=new Uint8Array(u);for(let g=0;g<f.length;g++)h[g]=f[g];f=this.valueHexView=new Uint8Array(u)}}this.blockLength=c+1,f[c-1]=i[c]&127;let l=new Uint8Array(c);for(let h=0;h<c;h++)l[h]=f[h];f=this.valueHexView=new Uint8Array(c),f.set(l),this.blockLength<=9?this.tagNumber=cr(f,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return e+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}};mo.NAME="identificationBlock";var go=class extends Ae{constructor({lenBlock:t={}}={}){var e,n,o;super(),this.isIndefiniteForm=(e=t.isIndefiniteForm)!==null&&e!==void 0?e:!1,this.longFormUsed=(n=t.longFormUsed)!==null&&n!==void 0?n:!1,this.length=(o=t.length)!==null&&o!==void 0?o:0}fromBER(t,e,n){let o=j.BufferSourceConverter.toUint8Array(t);if(!ke(this,o,e,n))return-1;let i=o.subarray(e,e+n);if(i.length===0)return this.error="Zero buffer length",-1;if(i[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=i[0]===128,this.isIndefiniteForm)return this.blockLength=1,e+this.blockLength;if(this.longFormUsed=!!(i[0]&128),this.longFormUsed===!1)return this.length=i[0],this.blockLength=1,e+this.blockLength;let s=i[0]&127;if(s>8)return this.error="Too big integer",-1;if(s+1>i.length)return this.error="End of input reached before message was fully decoded",-1;let a=e+1,c=o.subarray(a,a+s);return c[s-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=cr(c,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=s+1,e+this.blockLength}toBER(t=!1){let e,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return e=new ArrayBuffer(1),t===!1&&(n=new Uint8Array(e),n[0]=128),e;if(this.longFormUsed){let o=ze(this.length,8);if(o.byteLength>127)return this.error="Too big length",re;if(e=new ArrayBuffer(o.byteLength+1),t)return e;let i=new Uint8Array(o);n=new Uint8Array(e),n[0]=o.byteLength|128;for(let s=0;s<o.byteLength;s++)n[s+1]=i[s];return e}return e=new ArrayBuffer(1),t===!1&&(n=new Uint8Array(e),n[0]=this.length),e}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}};go.NAME="lengthBlock";var L={},xt=class extends Ae{constructor({name:t=Fr,optional:e=!1,primitiveSchema:n,...o}={},i){super(o),this.name=t,this.optional=e,n&&(this.primitiveSchema=n),this.idBlock=new mo(o),this.lenBlock=new go(o),this.valueBlock=i?new i(o):new St(o)}fromBER(t,e,n){let o=this.valueBlock.fromBER(t,e,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),o)}toBER(t,e){let n=e||new ln;e||Eu(this);let o=this.idBlock.toBER(t);if(n.write(o),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(t,n),n.write(new ArrayBuffer(2));else{let i=this.valueBlock.toBER(t);this.lenBlock.length=i.byteLength;let s=this.lenBlock.toBER(t);n.write(s),n.write(i)}return e?re:n.final()}toJSON(){let t={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(t.primitiveSchema=this.primitiveSchema.toJSON()),t}toString(t="ascii"){return t==="ascii"?this.onAsciiEncoding():j.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${j.Convert.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(t){if(this===t)return!0;if(!(t instanceof this.constructor))return!1;let e=this.toBER(),n=t.toBER();return yu(e,n)}};xt.NAME="BaseBlock";function Eu(r){if(r instanceof L.Constructed)for(let t of r.valueBlock.value)Eu(t)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}var yo=class extends xt{constructor({value:t=Fr,...e}={},n){super(e,n),t&&this.fromString(t)}getValue(){return this.valueBlock.value}setValue(t){this.valueBlock.value=t}fromBER(t,e,n){let o=this.valueBlock.fromBER(t,e,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),o)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}};yo.NAME="BaseStringBlock";var xo=class extends Te(St){constructor({isHexOnly:t=!0,...e}={}){super(e),this.isHexOnly=t}};xo.NAME="PrimitiveValueBlock";var Bu,wo=class extends xt{constructor(t={}){super(t,xo),this.idBlock.isConstructed=!1}};Bu=wo;L.Primitive=Bu;wo.NAME="PRIMITIVE";function Cp(r,t){if(r instanceof t)return r;let e=new t;return e.idBlock=r.idBlock,e.lenBlock=r.lenBlock,e.warnings=r.warnings,e.valueBeforeDecodeView=r.valueBeforeDecodeView,e}function Qo(r,t=0,e=r.length){let n=t,o=new xt({},St),i=new Ae;if(!ke(i,r,t,e))return o.error=i.error,{offset:-1,result:o};if(!r.subarray(t,t+e).length)return o.error="Zero buffer length",{offset:-1,result:o};let a=o.idBlock.fromBER(r,t,e);if(o.idBlock.warnings.length&&o.warnings.concat(o.idBlock.warnings),a===-1)return o.error=o.idBlock.error,{offset:-1,result:o};if(t=a,e-=o.idBlock.blockLength,a=o.lenBlock.fromBER(r,t,e),o.lenBlock.warnings.length&&o.warnings.concat(o.lenBlock.warnings),a===-1)return o.error=o.lenBlock.error,{offset:-1,result:o};if(t=a,e-=o.lenBlock.blockLength,!o.idBlock.isConstructed&&o.lenBlock.isIndefiniteForm)return o.error="Indefinite length form used for primitive encoding form",{offset:-1,result:o};let c=xt;switch(o.idBlock.tagClass){case 1:if(o.idBlock.tagNumber>=37&&o.idBlock.isHexOnly===!1)return o.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:o};switch(o.idBlock.tagNumber){case 0:if(o.idBlock.isConstructed&&o.lenBlock.length>0)return o.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:o};c=L.EndOfContent;break;case 1:c=L.Boolean;break;case 2:c=L.Integer;break;case 3:c=L.BitString;break;case 4:c=L.OctetString;break;case 5:c=L.Null;break;case 6:c=L.ObjectIdentifier;break;case 10:c=L.Enumerated;break;case 12:c=L.Utf8String;break;case 13:c=L.RelativeObjectIdentifier;break;case 14:c=L.TIME;break;case 15:return o.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:o};case 16:c=L.Sequence;break;case 17:c=L.Set;break;case 18:c=L.NumericString;break;case 19:c=L.PrintableString;break;case 20:c=L.TeletexString;break;case 21:c=L.VideotexString;break;case 22:c=L.IA5String;break;case 23:c=L.UTCTime;break;case 24:c=L.GeneralizedTime;break;case 25:c=L.GraphicString;break;case 26:c=L.VisibleString;break;case 27:c=L.GeneralString;break;case 28:c=L.UniversalString;break;case 29:c=L.CharacterString;break;case 30:c=L.BmpString;break;case 31:c=L.DATE;break;case 32:c=L.TimeOfDay;break;case 33:c=L.DateTime;break;case 34:c=L.Duration;break;default:{let f=o.idBlock.isConstructed?new L.Constructed:new L.Primitive;f.idBlock=o.idBlock,f.lenBlock=o.lenBlock,f.warnings=o.warnings,o=f}}break;case 2:case 3:case 4:default:c=o.idBlock.isConstructed?L.Constructed:L.Primitive}return o=Cp(o,c),a=o.fromBER(r,t,o.lenBlock.isIndefiniteForm?e:o.lenBlock.length),o.valueBeforeDecodeView=r.subarray(n,n+o.blockLength),{offset:a,result:o}}function oa(r){if(!r.byteLength){let t=new xt({},St);return t.error="Input buffer has zero length",{offset:-1,result:t}}return Qo(j.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function Np(r,t){return r?1:t}var fe=class extends St{constructor({value:t=[],isIndefiniteForm:e=!1,...n}={}){super(n),this.value=t,this.isIndefiniteForm=e}fromBER(t,e,n){let o=j.BufferSourceConverter.toUint8Array(t);if(!ke(this,o,e,n))return-1;if(this.valueBeforeDecodeView=o.subarray(e,e+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),e;let i=e;for(;Np(this.isIndefiniteForm,n)>0;){let s=Qo(o,i,n);if(s.offset===-1)return this.error=s.result.error,this.warnings.concat(s.result.warnings),-1;if(i=s.offset,this.blockLength+=s.result.blockLength,n-=s.result.blockLength,this.value.push(s.result),this.isIndefiniteForm&&s.result.constructor.NAME===fn)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===fn?this.value.pop():this.warnings.push("No EndOfContent block encoded")),i}toBER(t,e){let n=e||new ln;for(let o=0;o<this.value.length;o++)this.value[o].toBER(t,n);return e?re:n.final()}toJSON(){let t={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let e of this.value)t.value.push(e.toJSON());return t}};fe.NAME="ConstructedValueBlock";var Au,je=class extends xt{constructor(t={}){super(t,fe),this.idBlock.isConstructed=!0}fromBER(t,e,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;let o=this.valueBlock.fromBER(t,e,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),o)}onAsciiEncoding(){let t=[];for(let n of this.valueBlock.value)t.push(n.toString("ascii").split(`
4
4
  `).map(o=>` ${o}`).join(`
5
5
  `));let e=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return t.length?`${e} :
6
6
  ${t.join(`
7
- `)}`:`${e} :`}};nu=qe;_.Constructed=nu;qe.NAME="CONSTRUCTED";var fo=class extends At{fromBER(t,e,n){return e}toBER(t){return ee}};fo.override="EndOfContentValueBlock";var ou,ho=class extends wt{constructor(t={}){super(t,fo),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};ou=ho;_.EndOfContent=ou;ho.NAME=un;var iu,Ur=class extends wt{constructor(t={}){super(t,At),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(t,e,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,e+n>t.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):e+n}toBER(t,e){let n=new ArrayBuffer(2);if(!t){let o=new Uint8Array(n);o[0]=5,o[1]=0}return e&&e.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}};iu=Ur;_.Null=iu;Ur.NAME="NULL";var po=class extends Ie(At){constructor({value:t,...e}={}){super(e),e.valueHex?this.valueHexView=j.BufferSourceConverter.toUint8Array(e.valueHex):this.valueHexView=new Uint8Array(1),t&&(this.value=t)}get value(){for(let t of this.valueHexView)if(t>0)return!0;return!1}set value(t){this.valueHexView[0]=t?255:0}fromBER(t,e,n){let o=j.BufferSourceConverter.toUint8Array(t);return Se(this,o,e,n)?(this.valueHexView=o.subarray(e,e+n),n>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,$s.call(this),this.blockLength=n,e+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};po.NAME="BooleanValueBlock";var su,mo=class extends wt{constructor(t={}){super(t,po),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(t){this.valueBlock.value=t}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};su=mo;_.Boolean=su;mo.NAME="BOOLEAN";var go=class extends Ie(ue){constructor({isConstructed:t=!1,...e}={}){super(e),this.isConstructed=t}fromBER(t,e,n){let o=0;if(this.isConstructed){if(this.isHexOnly=!1,o=ue.prototype.fromBER.call(this,t,e,n),o===-1)return o;for(let i=0;i<this.value.length;i++){let s=this.value[i].constructor.NAME;if(s===un){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(s!==Qc)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,o=super.fromBER(t,e,n),this.blockLength=n;return o}toBER(t,e){return this.isConstructed?ue.prototype.toBER.call(this,t,e):t?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};go.NAME="OctetStringValueBlock";var au,yo=class r extends wt{constructor({idBlock:t={},lenBlock:e={},...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,...t},lenBlock:{...e,isIndefiniteForm:!!n.isIndefiniteForm},...n},go),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(t,e,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),e;if(!this.valueBlock.isConstructed){let i=(t instanceof ArrayBuffer?new Uint8Array(t):t).subarray(e,e+n);try{if(i.byteLength){let s=zo(i,0,i.byteLength);s.offset!==-1&&s.offset===n&&(this.valueBlock.value=[s.result])}}catch{}}return super.fromBER(t,e,n)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?qe.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${j.Convert.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;let t=[];for(let e of this.valueBlock.value)e instanceof r&&t.push(e.valueBlock.valueHexView);return j.BufferSourceConverter.concat(t)}};au=yo;_.OctetString=au;yo.NAME=Qc;var wo=class extends Ie(ue){constructor({unusedBits:t=0,isConstructed:e=!1,...n}={}){super(n),this.unusedBits=t,this.isConstructed=e,this.blockLength=this.valueHexView.byteLength}fromBER(t,e,n){if(!n)return e;let o=-1;if(this.isConstructed){if(o=ue.prototype.fromBER.call(this,t,e,n),o===-1)return o;for(let a of this.value){let c=a.constructor.NAME;if(c===un){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==tu)return this.error="BIT STRING may consists of BIT STRINGs only",-1;let f=a.valueBlock;if(this.unusedBits>0&&f.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=f.unusedBits}return o}let i=j.BufferSourceConverter.toUint8Array(t);if(!Se(this,i,e,n))return-1;let s=i.subarray(e,e+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=zo(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,e+n}toBER(t,e){if(this.isConstructed)return ue.prototype.toBER.call(this,t,e);if(t)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return ee;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}}};wo.NAME="BitStringValueBlock";var cu,Rr=class extends wt{constructor({idBlock:t={},lenBlock:e={},...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,...t},lenBlock:{...e,isIndefiniteForm:!!n.isIndefiniteForm},...n},wo),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(t,e,n){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(t,e,n)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return qe.prototype.onAsciiEncoding.call(this);{let t=[],e=this.valueBlock.valueHexView;for(let o of e)t.push(o.toString(2).padStart(8,"0"));let n=t.join("");return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}};cu=Rr;_.BitString=cu;Rr.NAME=tu;var uu;function ap(r,t){let e=new Uint8Array([0]),n=new Uint8Array(r),o=new Uint8Array(t),i=n.slice(0),s=i.length-1,a=o.slice(0),c=a.length-1,f=0,u=c<s?s:c,l=0;for(let d=u;d>=0;d--,l++){switch(!0){case l<a.length:f=i[s-l]+a[c-l]+e[0];break;default:f=i[s-l]+e[0]}switch(e[0]=f/10,!0){case l>=i.length:i=oo(new Uint8Array([f%10]),i);break;default:i[s-l]=f%10}}return e[0]>0&&(i=oo(e,i)),i}function Xc(r){if(r>=an.length)for(let t=an.length;t<=r;t++){let e=new Uint8Array([0]),n=an[t-1].slice(0);for(let o=n.length-1;o>=0;o--){let i=new Uint8Array([(n[o]<<1)+e[0]]);e[0]=i[0]/10,n[o]=i[0]%10}e[0]>0&&(n=oo(e,n)),an.push(n)}return an[r]}function cp(r,t){let e=0,n=new Uint8Array(r),o=new Uint8Array(t),i=n.slice(0),s=i.length-1,a=o.slice(0),c=a.length-1,f,u=0;for(let l=c;l>=0;l--,u++)switch(f=i[s-u]-a[c-u]-e,!0){case f<0:e=1,i[s-u]=f+10;break;default:e=0,i[s-u]=f}if(e>0)for(let l=s-c+1;l>=0;l--,u++)if(f=i[s-u]-e,f<0)e=1,i[s-u]=f+10;else{e=0,i[s-u]=f;break}return i.slice()}var ln=class extends Ie(At){constructor({value:t,...e}={}){super(e),this._valueDec=0,e.valueHex&&this.setValueHex(),t!==void 0&&(this.valueDec=t)}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=$s.call(this)))}set valueDec(t){this._valueDec=t,this.isHexOnly=!1,this.valueHexView=new Uint8Array(Wc(t))}get valueDec(){return this._valueDec}fromDER(t,e,n,o=0){let i=this.fromBER(t,e,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(t=!1){let e=this.valueHexView;switch(!0){case(e[0]&128)!==0:{let n=new Uint8Array(this.valueHexView.length+1);n[0]=0,n.set(e,1),this.valueHexView=n}break;case(e[0]===0&&(e[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(t)}fromBER(t,e,n){let o=super.fromBER(t,e,n);return o===-1||this.setValueHex(),o}toBER(t){return t?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){let t=this.valueHexView.length*8-1,e=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 f=0;f<8;f++){if((o&1)===1)switch(n){case t:e=cp(Xc(n),e),s="-";break;default:e=ap(e,Xc(n))}n++,o>>=1}}for(let c=0;c<e.length;c++)e[c]&&(a=!0),a&&(s+=Jc.charAt(e[c]));return a===!1&&(s+=Jc.charAt(0)),s}};uu=ln;ln.NAME="IntegerValueBlock";Object.defineProperty(uu.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var lu,xt=class r extends wt{constructor(t={}){super(t,ln),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return io(),BigInt(this.valueBlock.toString())}static fromBigInt(t){io();let e=BigInt(t),n=new cn,o=e.toString(16).replace(/^-/,""),i=new Uint8Array(j.Convert.FromHex(o));if(e<0){let a=new Uint8Array(i.length+(i[0]&128?1:0));a[0]|=128;let f=BigInt(`0x${j.Convert.ToHex(a)}`)+e,u=j.BufferSourceConverter.toUint8Array(j.Convert.FromHex(f.toString(16)));u[0]|=128,n.write(u)}else i[0]&128&&n.write(new Uint8Array([0])),n.write(i);return new r({valueHex:n.final()})}convertToDER(){let t=new r({valueHex:this.valueBlock.valueHexView});return t.valueBlock.toDER(),t}convertFromDER(){return new r({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}};lu=xt;_.Integer=lu;xt.NAME="INTEGER";var fu,xo=class extends xt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};fu=xo;_.Enumerated=fu;xo.NAME="ENUMERATED";var fn=class extends Ie(At){constructor({valueDec:t=-1,isFirstSid:e=!1,...n}={}){super(n),this.valueDec=t,this.isFirstSid=e}fromBER(t,e,n){if(!n)return e;let o=j.BufferSourceConverter.toUint8Array(t);if(!Se(this,o,e,n))return-1;let i=o.subarray(e,e+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=or(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),e+this.blockLength)}set valueBigInt(t){io();let e=BigInt(t).toString(2);for(;e.length%7;)e="0"+e;let n=new Uint8Array(e.length/7);for(let o=0;o<n.length;o++)n[o]=parseInt(e.slice(o*7,o*7+7),2)+(o+1<n.length?128:0);this.fromBER(n.buffer,0,n.length)}toBER(t){if(this.isHexOnly){if(t)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 e=Ke(this.valueDec,7);if(e.byteLength===0)return this.error="Error during encoding SID value",ee;let n=new Uint8Array(e.byteLength);if(!t){let o=new Uint8Array(e),i=e.byteLength-1;for(let s=0;s<i;s++)n[s]=o[s]|128;n[i]=o[i]}return n}toString(){let t="";if(this.isHexOnly)t=j.Convert.ToHex(this.valueHexView);else if(this.isFirstSid){let e=this.valueDec;this.valueDec<=39?t="0.":this.valueDec<=79?(t="1.",e-=40):(t="2.",e-=80),t+=e.toString()}else t=this.valueDec.toString();return t}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}};fn.NAME="sidBlock";var bo=class extends At{constructor({value:t=Lr,...e}={}){super(e),this.value=[],t&&this.fromString(t)}fromBER(t,e,n){let o=e;for(;n>0;){let i=new fn;if(o=i.fromBER(t,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(t){let e=[];for(let n=0;n<this.value.length;n++){let o=this.value[n].toBER(t);if(o.byteLength===0)return this.error=this.value[n].error,ee;e.push(o)}return Hs(e)}fromString(t){this.value=[];let e=0,n=0,o="",i=!1;do if(n=t.indexOf(".",e),n===-1?o=t.substring(e):o=t.substring(e,n),e=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 fn;if(o>Number.MAX_SAFE_INTEGER){io();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 t="",e=!1;for(let n=0;n<this.value.length;n++){e=this.value[n].isHexOnly;let o=this.value[n].toString();n!==0&&(t=`${t}.`),e?(o=`{${o}}`,this.value[n].isFirstSid?t=`2.{${o} - 80}`:t+=o):t+=o}return t}toJSON(){let t={...super.toJSON(),value:this.toString(),sidArray:[]};for(let e=0;e<this.value.length;e++)t.sidArray.push(this.value[e].toJSON());return t}};bo.NAME="ObjectIdentifierValueBlock";var du,_r=class extends wt{constructor(t={}){super(t,bo),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}getValue(){return this.valueBlock.toString()}setValue(t){this.valueBlock.fromString(t)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};du=_r;_.ObjectIdentifier=du;_r.NAME="OBJECT IDENTIFIER";var dn=class extends Ie(Ee){constructor({valueDec:t=0,...e}={}){super(e),this.valueDec=t}fromBER(t,e,n){if(n===0)return e;let o=j.BufferSourceConverter.toUint8Array(t);if(!Se(this,o,e,n))return-1;let i=o.subarray(e,e+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=or(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),e+this.blockLength)}toBER(t){if(this.isHexOnly){if(t)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 e=Ke(this.valueDec,7);if(e.byteLength===0)return this.error="Error during encoding SID value",ee;let n=new Uint8Array(e.byteLength);if(!t){let o=new Uint8Array(e),i=e.byteLength-1;for(let s=0;s<i;s++)n[s]=o[s]|128;n[i]=o[i]}return n.buffer}toString(){let t="";return this.isHexOnly?t=j.Convert.ToHex(this.valueHexView):t=this.valueDec.toString(),t}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}};dn.NAME="relativeSidBlock";var vo=class extends At{constructor({value:t=Lr,...e}={}){super(e),this.value=[],t&&this.fromString(t)}fromBER(t,e,n){let o=e;for(;n>0;){let i=new dn;if(o=i.fromBER(t,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(t,e){let n=[];for(let o=0;o<this.value.length;o++){let i=this.value[o].toBER(t);if(i.byteLength===0)return this.error=this.value[o].error,ee;n.push(i)}return Hs(n)}fromString(t){this.value=[];let e=0,n=0,o="";do{n=t.indexOf(".",e),n===-1?o=t.substring(e):o=t.substring(e,n),e=n+1;let i=new dn;if(i.valueDec=parseInt(o,10),isNaN(i.valueDec))return!0;this.value.push(i)}while(n!==-1);return!0}toString(){let t="",e=!1;for(let n=0;n<this.value.length;n++){e=this.value[n].isHexOnly;let o=this.value[n].toString();n!==0&&(t=`${t}.`),e&&(o=`{${o}}`),t+=o}return t}toJSON(){let t={...super.toJSON(),value:this.toString(),sidArray:[]};for(let e=0;e<this.value.length;e++)t.sidArray.push(this.value[e].toJSON());return t}};vo.NAME="RelativeObjectIdentifierValueBlock";var hu,Eo=class extends wt{constructor(t={}){super(t,vo),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}getValue(){return this.valueBlock.toString()}setValue(t){this.valueBlock.fromString(t)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};hu=Eo;_.RelativeObjectIdentifier=hu;Eo.NAME="RelativeObjectIdentifier";var pu,Be=class extends qe{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};pu=Be;_.Sequence=pu;Be.NAME="SEQUENCE";var mu,Bo=class extends qe{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};mu=Bo;_.Set=mu;Bo.NAME="SET";var Ao=class extends Ie(At){constructor({...t}={}){super(t),this.isHexOnly=!0,this.value=Lr}toJSON(){return{...super.toJSON(),value:this.value}}};Ao.NAME="StringValueBlock";var So=class extends Ao{};So.NAME="SimpleStringValueBlock";var Ct=class extends co{constructor({...t}={}){super(t,So)}fromBuffer(t){this.valueBlock.value=String.fromCharCode.apply(null,j.BufferSourceConverter.toUint8Array(t))}fromString(t){let e=t.length,n=this.valueBlock.valueHexView=new Uint8Array(e);for(let o=0;o<e;o++)n[o]=t.charCodeAt(o);this.valueBlock.value=t}};Ct.NAME="SIMPLE STRING";var Io=class extends Ct{fromBuffer(t){this.valueBlock.valueHexView=j.BufferSourceConverter.toUint8Array(t);try{this.valueBlock.value=j.Convert.ToUtf8String(t)}catch(e){this.warnings.push(`Error during "decodeURIComponent": ${e}, using raw string`),this.valueBlock.value=j.Convert.ToBinary(t)}}fromString(t){this.valueBlock.valueHexView=new Uint8Array(j.Convert.FromUtf8String(t)),this.valueBlock.value=t}};Io.NAME="Utf8StringValueBlock";var gu,Ae=class extends Io{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};gu=Ae;_.Utf8String=gu;Ae.NAME="UTF8String";var ko=class extends Ct{fromBuffer(t){this.valueBlock.value=j.Convert.ToUtf16String(t),this.valueBlock.valueHexView=j.BufferSourceConverter.toUint8Array(t)}fromString(t){this.valueBlock.value=t,this.valueBlock.valueHexView=new Uint8Array(j.Convert.FromUtf16String(t))}};ko.NAME="BmpStringValueBlock";var yu,Co=class extends ko{constructor({...t}={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};yu=Co;_.BmpString=yu;Co.NAME="BMPString";var To=class extends Ct{fromBuffer(t){let e=ArrayBuffer.isView(t)?t.slice().buffer:t.slice(0),n=new Uint8Array(e);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(e))}fromString(t){let e=t.length,n=this.valueBlock.valueHexView=new Uint8Array(e*4);for(let o=0;o<e;o++){let i=Ke(t.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=t}};To.NAME="UniversalStringValueBlock";var wu,No=class extends To{constructor({...t}={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};wu=No;_.UniversalString=wu;No.NAME="UniversalString";var xu,Uo=class extends Ct{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};xu=Uo;_.NumericString=xu;Uo.NAME="NumericString";var bu,Ro=class extends Ct{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};bu=Ro;_.PrintableString=bu;Ro.NAME="PrintableString";var vu,_o=class extends Ct{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};vu=_o;_.TeletexString=vu;_o.NAME="TeletexString";var Eu,Lo=class extends Ct{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};Eu=Lo;_.VideotexString=Eu;Lo.NAME="VideotexString";var Bu,Vo=class extends Ct{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};Bu=Vo;_.IA5String=Bu;Vo.NAME="IA5String";var Au,Po=class extends Ct{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};Au=Po;_.GraphicString=Au;Po.NAME="GraphicString";var Su,hn=class extends Ct{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};Su=hn;_.VisibleString=Su;hn.NAME="VisibleString";var Iu,Fo=class extends Ct{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};Iu=Fo;_.GeneralString=Iu;Fo.NAME="GeneralString";var ku,Oo=class extends Ct{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};ku=Oo;_.CharacterString=ku;Oo.NAME="CharacterString";var Cu,pn=class extends hn{constructor({value:t,valueDate:e,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,t){this.fromString(t),this.valueBlock.valueHexView=new Uint8Array(t.length);for(let o=0;o<t.length;o++)this.valueBlock.valueHexView[o]=t.charCodeAt(o)}e&&(this.fromDate(e),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(t){this.fromString(String.fromCharCode.apply(null,j.BufferSourceConverter.toUint8Array(t)))}toBuffer(){let t=this.toString(),e=new ArrayBuffer(t.length),n=new Uint8Array(e);for(let o=0;o<t.length;o++)n[o]=t.charCodeAt(o);return e}fromDate(t){this.year=t.getUTCFullYear(),this.month=t.getUTCMonth()+1,this.day=t.getUTCDate(),this.hour=t.getUTCHours(),this.minute=t.getUTCMinutes(),this.second=t.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(t){let n=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(t);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(t="iso"){if(t==="iso"){let e=new Array(7);return e[0]=Ft(this.year<2e3?this.year-1900:this.year-2e3,2),e[1]=Ft(this.month,2),e[2]=Ft(this.day,2),e[3]=Ft(this.hour,2),e[4]=Ft(this.minute,2),e[5]=Ft(this.second,2),e[6]="Z",e.join("")}return super.toString(t)}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}}};Cu=pn;_.UTCTime=Cu;pn.NAME="UTCTime";var Tu,Do=class extends pn{constructor(t={}){var e;super(t),(e=this.millisecond)!==null&&e!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(t){super.fromDate(t),this.millisecond=t.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(t){let e=!1,n="",o="",i=0,s,a=0,c=0;if(t[t.length-1]==="Z")n=t.substring(0,t.length-1),e=!0;else{let l=new Number(t[t.length-1]);if(isNaN(l.valueOf()))throw new Error("Wrong input string for conversion");n=t}if(e){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 l=1,d=n.indexOf("+"),b="";if(d===-1&&(d=n.indexOf("-"),l=-1),d!==-1){if(b=n.substring(d+1),n=n.substring(0,d),b.length!==2&&b.length!==4)throw new Error("Wrong input string for conversion");let I=parseInt(b.substring(0,2),10);if(isNaN(I.valueOf()))throw new Error("Wrong input string for conversion");if(a=l*I,b.length===4){if(I=parseInt(b.substring(2,4),10),isNaN(I.valueOf()))throw new Error("Wrong input string for conversion");c=l*I}}}let f=n.indexOf(".");if(f===-1&&(f=n.indexOf(",")),f!==-1){let l=new Number(`0${n.substring(f)}`);if(isNaN(l.valueOf()))throw new Error("Wrong input string for conversion");i=l.valueOf(),o=n.substring(0,f)}else o=n;switch(!0){case o.length===8:if(s=/(\d{4})(\d{2})(\d{2})/ig,f!==-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,f!==-1){let l=60*i;this.minute=Math.floor(l),l=60*(l-this.minute),this.second=Math.floor(l),l=1e3*(l-this.second),this.millisecond=Math.floor(l)}break;case o.length===12:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=60*i;this.second=Math.floor(l),l=1e3*(l-this.second),this.millisecond=Math.floor(l)}break;case o.length===14:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=1e3*i;this.millisecond=Math.floor(l)}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 l=1;l<u.length;l++)switch(l){case 1:this.year=parseInt(u[l],10);break;case 2:this.month=parseInt(u[l],10);break;case 3:this.day=parseInt(u[l],10);break;case 4:this.hour=parseInt(u[l],10)+a;break;case 5:this.minute=parseInt(u[l],10)+c;break;case 6:this.second=parseInt(u[l],10);break;default:throw new Error("Wrong input string for conversion")}if(e===!1){let l=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=l.getUTCFullYear(),this.month=l.getUTCMonth(),this.day=l.getUTCDay(),this.hour=l.getUTCHours(),this.minute=l.getUTCMinutes(),this.second=l.getUTCSeconds(),this.millisecond=l.getUTCMilliseconds()}}toString(t="iso"){if(t==="iso"){let e=[];return e.push(Ft(this.year,4)),e.push(Ft(this.month,2)),e.push(Ft(this.day,2)),e.push(Ft(this.hour,2)),e.push(Ft(this.minute,2)),e.push(Ft(this.second,2)),this.millisecond!==0&&(e.push("."),e.push(Ft(this.millisecond,3))),e.push("Z"),e.join("")}return super.toString(t)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};Tu=Do;_.GeneralizedTime=Tu;Do.NAME="GeneralizedTime";var Nu,Mo=class extends Ae{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};Nu=Mo;_.DATE=Nu;Mo.NAME="DATE";var Uu,$o=class extends Ae{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};Uu=$o;_.TimeOfDay=Uu;$o.NAME="TimeOfDay";var Ru,Ho=class extends Ae{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};Ru=Ho;_.DateTime=Ru;Ho.NAME="DateTime";var _u,Ko=class extends Ae{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};_u=Ko;_.Duration=_u;Ko.NAME="Duration";var Lu,qo=class extends Ae{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};Lu=qo;_.TIME=Lu;qo.NAME="TIME";function W(r,t="utf8"){let e=Qn[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var mn=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},jo=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var Vu={get(r=globalThis){let t=r.crypto;if(t?.subtle==null)throw new jo("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 t}};var ze=Vu;async function Pu(r){let t=await ze.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:r,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),e=await lp(t);return{privateKey:e[0],publicKey:e[1]}}async function Fu(r,t){let e=await ze.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await ze.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},e,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(n,0,n.byteLength)}async function Ou(r,t,e){let n=await ze.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return ze.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,e instanceof Uint8Array?e:e.subarray())}async function lp(r){if(r.privateKey==null||r.publicKey==null)throw new vt("Private and public key are required");return Promise.all([ze.get().subtle.exportKey("jwk",r.privateKey),ze.get().subtle.exportKey("jwk",r.publicKey)])}function zs(r){if(r.kty!=="RSA")throw new vt("invalid key type");if(r.n==null)throw new vt("invalid key modulus");return Z(r.n,"base64url").length*8}var Vr=class{type="RSA";_key;_raw;_multihash;constructor(t,e){this._key=t,this._multihash=e}get raw(){return this._raw==null&&(this._raw=gn.jwkToPkix(this._key)),this._raw}toMultihash(){return this._multihash}toCID(){return Q.createV1(114,this._multihash)}toString(){return nt.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ct(this.raw,t.raw)}verify(t,e){return Ou(this._key,e,t)}},yn=class{type="RSA";_key;_raw;publicKey;constructor(t,e){this._key=t,this.publicKey=e}get raw(){return this._raw==null&&(this._raw=gn.jwkToPkcs1(this._key)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ct(this.raw,t.raw)}sign(t){return Fu(this._key,t)}};var Go=8192,js=18;function Du(r){let{result:t}=qs(r),e=t.valueBlock.value;return{n:W(le(e[1].toBigInt()),"base64url"),e:W(le(e[2].toBigInt()),"base64url"),d:W(le(e[3].toBigInt()),"base64url"),p:W(le(e[4].toBigInt()),"base64url"),q:W(le(e[5].toBigInt()),"base64url"),dp:W(le(e[6].toBigInt()),"base64url"),dq:W(le(e[7].toBigInt()),"base64url"),qi:W(le(e[8].toBigInt()),"base64url"),kty:"RSA",alg:"RS256"}}function fp(r){if(r.n==null||r.e==null||r.d==null||r.p==null||r.q==null||r.dp==null||r.dq==null||r.qi==null)throw new vt("JWK was missing components");let e=new Be({value:[new xt({value:0}),xt.fromBigInt(fe(Z(r.n,"base64url"))),xt.fromBigInt(fe(Z(r.e,"base64url"))),xt.fromBigInt(fe(Z(r.d,"base64url"))),xt.fromBigInt(fe(Z(r.p,"base64url"))),xt.fromBigInt(fe(Z(r.q,"base64url"))),xt.fromBigInt(fe(Z(r.dp,"base64url"))),xt.fromBigInt(fe(Z(r.dq,"base64url"))),xt.fromBigInt(fe(Z(r.qi,"base64url")))]}).toBER();return new Uint8Array(e,0,e.byteLength)}function Mu(r){let{result:t}=qs(r),e=t.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:W(le(e[0].toBigInt()),"base64url"),e:W(le(e[1].toBigInt()),"base64url")}}function Gs(r){if(r.n==null||r.e==null)throw new vt("JWK was missing components");let e=new Be({value:[new Be({value:[new _r({value:"1.2.840.113549.1.1.1"}),new Ur]}),new Rr({valueHex:new Be({value:[xt.fromBigInt(fe(Z(r.n,"base64url"))),xt.fromBigInt(fe(Z(r.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(e,0,e.byteLength)}function le(r){let t=r.toString(16);t.length%2>0&&(t=`0${t}`);let e=t.length/2,n=new Uint8Array(e),o=0,i=0;for(;o<e;)n[o]=parseInt(t.slice(i,i+2),16),o+=1,i+=2;return n}function fe(r){let t=[];return r.forEach(function(e){let n=e.toString(16);n.length%2>0&&(n=`0${n}`),t.push(n)}),BigInt("0x"+t.join(""))}function $u(r){let t=Du(r);return Hu(t)}function Zs(r){let t=Mu(r);if(zs(t)>Go)throw new lr("Key size is too large");let e=Tr(ce.encode({Type:dt.RSA,Data:r})),n=Zt(js,e);return new Vr(t,n)}function Hu(r){if(zs(r)>Go)throw new vt("Key size is too large");let t=qu(r),e=Tr(ce.encode({Type:dt.RSA,Data:Gs(t.publicKey)})),n=Zt(js,e);return new yn(t.privateKey,new Vr(t.publicKey,n))}async function Ku(r){if(r>Go)throw new vt("Key size is too large");let t=await Pu(r),e=Tr(ce.encode({Type:dt.RSA,Data:Gs(t.publicKey)})),n=Zt(js,e);return new yn(t.privateKey,new Vr(t.publicKey,n))}function qu(r){if(r==null)throw new vt("Missing key parameter");return{privateKey:r,publicKey:{kty:r.kty,n:r.n,e:r.e}}}var Zo=class extends vr{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,dc(t);let n=Jr(e);if(this.iHash=t.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?t.create().update(n).digest():n);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=t.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),i.fill(0)}update(t){return br(this),this.iHash.update(t),this}digestInto(t){br(this),xr(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:e,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:a}=this;return t=t,t.finished=o,t.destroyed=i,t.blockLen=s,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Ws=(r,t,e)=>new Zo(r,t).update(e).digest();Ws.create=(r,t)=>new Zo(r,t);function zu(r){r.lowS!==void 0&&Jt("lowS",r.lowS),r.prehash!==void 0&&Jt("prehash",r.prehash)}function dp(r){let t=tn(r);ae(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:e,Fp:n,a:o}=t;if(e){if(!n.eql(o,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}var{bytesToNumberBE:hp,hexToBytes:pp}=qn,ke={Err:class extends Error{constructor(t=""){super(t)}},_tlv:{encode:(r,t)=>{let{Err:e}=ke;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length&1)throw new e("tlv.encode: unpadded data");let n=t.length/2,o=Ye(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let i=n>127?Ye(o.length/2|128):"";return`${Ye(r)}${i}${o}${t}`},decode(r,t){let{Err:e}=ke,n=0;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length<2||t[n++]!==r)throw new e("tlv.decode: wrong tlv");let o=t[n++],i=!!(o&128),s=0;if(!i)s=o;else{let c=o&127;if(!c)throw new e("tlv.decode(long): indefinite length not supported");if(c>4)throw new e("tlv.decode(long): byte length is too big");let f=t.subarray(n,n+c);if(f.length!==c)throw new e("tlv.decode: length bytes not complete");if(f[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let u of f)s=s<<8|u;if(n+=c,s<128)throw new e("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+s);if(a.length!==s)throw new e("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+s)}}},_int:{encode(r){let{Err:t}=ke;if(r<Ce)throw new t("integer: negative integers are not allowed");let e=Ye(r);if(Number.parseInt(e[0],16)&8&&(e="00"+e),e.length&1)throw new t("unexpected assertion");return e},decode(r){let{Err:t}=ke;if(r[0]&128)throw new t("Invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new t("Invalid signature integer: unnecessary leading zero");return hp(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=ke,o=typeof r=="string"?pp(r):r;Br(o);let{v:i,l:s}=n.decode(48,o);if(s.length)throw new t("Invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,i),{v:f,l:u}=n.decode(2,c);if(u.length)throw new t("Invalid signature: left bytes after parsing");return{r:e.decode(a),s:e.decode(f)}},hexFromSig(r){let{_tlv:t,_int:e}=ke,n=`${t.encode(2,e.encode(r.r))}${t.encode(2,e.encode(r.s))}`;return t.encode(48,n)}},Ce=BigInt(0),mt=BigInt(1),bx=BigInt(2),ju=BigInt(3),vx=BigInt(4);function mp(r){let t=dp(r),{Fp:e}=t,n=De(t.n,t.nBitLength),o=t.toBytes||((w,h,E)=>{let C=h.toAffine();return be(Uint8Array.from([4]),e.toBytes(C.x),e.toBytes(C.y))}),i=t.fromBytes||(w=>{let h=w.subarray(1),E=e.fromBytes(h.subarray(0,e.BYTES)),C=e.fromBytes(h.subarray(e.BYTES,2*e.BYTES));return{x:E,y:C}});function s(w){let{a:h,b:E}=t,C=e.sqr(w),x=e.mul(C,w);return e.add(e.add(x,e.mul(w,h)),E)}if(!e.eql(e.sqr(t.Gy),s(t.Gx)))throw new Error("bad generator point: equation left != right");function a(w){return Xr(w,mt,t.n)}function c(w){let{allowedPrivateKeyLengths:h,nByteLength:E,wrapPrivateKey:C,n:x}=t;if(h&&typeof w!="bigint"){if(Pe(w)&&(w=we(w)),typeof w!="string"||!h.includes(w.length))throw new Error("Invalid key");w=w.padStart(E*2,"0")}let T;try{T=typeof w=="bigint"?w:xe(at("private key",w,E))}catch{throw new Error(`private key must be ${E} bytes, hex or bigint, not ${typeof w}`)}return C&&(T=tt(T,x)),Lt("private key",T,mt,x),T}function f(w){if(!(w instanceof d))throw new Error("ProjectivePoint expected")}let u=Qe((w,h)=>{let{px:E,py:C,pz:x}=w;if(e.eql(x,e.ONE))return{x:E,y:C};let T=w.is0();h==null&&(h=T?e.ONE:e.inv(x));let F=e.mul(E,h),V=e.mul(C,h),U=e.mul(x,h);if(T)return{x:e.ZERO,y:e.ZERO};if(!e.eql(U,e.ONE))throw new Error("invZ was invalid");return{x:F,y:V}}),l=Qe(w=>{if(w.is0()){if(t.allowInfinityPoint&&!e.is0(w.py))return;throw new Error("bad point: ZERO")}let{x:h,y:E}=w.toAffine();if(!e.isValid(h)||!e.isValid(E))throw new Error("bad point: x or y not FE");let C=e.sqr(E),x=s(h);if(!e.eql(C,x))throw new Error("bad point: equation left != right");if(!w.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class d{constructor(h,E,C){if(this.px=h,this.py=E,this.pz=C,h==null||!e.isValid(h))throw new Error("x required");if(E==null||!e.isValid(E))throw new Error("y required");if(C==null||!e.isValid(C))throw new Error("z required");Object.freeze(this)}static fromAffine(h){let{x:E,y:C}=h||{};if(!h||!e.isValid(E)||!e.isValid(C))throw new Error("invalid affine point");if(h instanceof d)throw new Error("projective point not allowed");let x=T=>e.eql(T,e.ZERO);return x(E)&&x(C)?d.ZERO:new d(E,C,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(h){let E=e.invertBatch(h.map(C=>C.pz));return h.map((C,x)=>C.toAffine(E[x])).map(d.fromAffine)}static fromHex(h){let E=d.fromAffine(i(at("pointHex",h)));return E.assertValidity(),E}static fromPrivateKey(h){return d.BASE.multiply(c(h))}static msm(h,E){return Gn(d,n,h,E)}_setWindowSize(h){I.setWindowSize(this,h)}assertValidity(){l(this)}hasEvenY(){let{y:h}=this.toAffine();if(e.isOdd)return!e.isOdd(h);throw new Error("Field doesn't support isOdd")}equals(h){f(h);let{px:E,py:C,pz:x}=this,{px:T,py:F,pz:V}=h,U=e.eql(e.mul(E,V),e.mul(T,x)),g=e.eql(e.mul(C,V),e.mul(F,x));return U&&g}negate(){return new d(this.px,e.neg(this.py),this.pz)}double(){let{a:h,b:E}=t,C=e.mul(E,ju),{px:x,py:T,pz:F}=this,V=e.ZERO,U=e.ZERO,g=e.ZERO,v=e.mul(x,x),O=e.mul(T,T),R=e.mul(F,F),N=e.mul(x,T);return N=e.add(N,N),g=e.mul(x,F),g=e.add(g,g),V=e.mul(h,g),U=e.mul(C,R),U=e.add(V,U),V=e.sub(O,U),U=e.add(O,U),U=e.mul(V,U),V=e.mul(N,V),g=e.mul(C,g),R=e.mul(h,R),N=e.sub(v,R),N=e.mul(h,N),N=e.add(N,g),g=e.add(v,v),v=e.add(g,v),v=e.add(v,R),v=e.mul(v,N),U=e.add(U,v),R=e.mul(T,F),R=e.add(R,R),v=e.mul(R,N),V=e.sub(V,v),g=e.mul(R,O),g=e.add(g,g),g=e.add(g,g),new d(V,U,g)}add(h){f(h);let{px:E,py:C,pz:x}=this,{px:T,py:F,pz:V}=h,U=e.ZERO,g=e.ZERO,v=e.ZERO,O=t.a,R=e.mul(t.b,ju),N=e.mul(E,T),H=e.mul(C,F),A=e.mul(x,V),S=e.add(E,C),m=e.add(T,F);S=e.mul(S,m),m=e.add(N,H),S=e.sub(S,m),m=e.add(E,x);let p=e.add(T,V);return m=e.mul(m,p),p=e.add(N,A),m=e.sub(m,p),p=e.add(C,x),U=e.add(F,V),p=e.mul(p,U),U=e.add(H,A),p=e.sub(p,U),v=e.mul(O,m),U=e.mul(R,A),v=e.add(U,v),U=e.sub(H,v),v=e.add(H,v),g=e.mul(U,v),H=e.add(N,N),H=e.add(H,N),A=e.mul(O,A),m=e.mul(R,m),H=e.add(H,A),A=e.sub(N,A),A=e.mul(O,A),m=e.add(m,A),N=e.mul(H,m),g=e.add(g,N),N=e.mul(p,m),U=e.mul(S,U),U=e.sub(U,N),N=e.mul(S,H),v=e.mul(p,v),v=e.add(v,N),new d(U,g,v)}subtract(h){return this.add(h.negate())}is0(){return this.equals(d.ZERO)}wNAF(h){return I.wNAFCached(this,h,d.normalizeZ)}multiplyUnsafe(h){Lt("scalar",h,Ce,t.n);let E=d.ZERO;if(h===Ce)return E;if(h===mt)return this;let{endo:C}=t;if(!C)return I.unsafeLadder(this,h);let{k1neg:x,k1:T,k2neg:F,k2:V}=C.splitScalar(h),U=E,g=E,v=this;for(;T>Ce||V>Ce;)T&mt&&(U=U.add(v)),V&mt&&(g=g.add(v)),v=v.double(),T>>=mt,V>>=mt;return x&&(U=U.negate()),F&&(g=g.negate()),g=new d(e.mul(g.px,C.beta),g.py,g.pz),U.add(g)}multiply(h){let{endo:E,n:C}=t;Lt("scalar",h,mt,C);let x,T;if(E){let{k1neg:F,k1:V,k2neg:U,k2:g}=E.splitScalar(h),{p:v,f:O}=this.wNAF(V),{p:R,f:N}=this.wNAF(g);v=I.constTimeNegate(F,v),R=I.constTimeNegate(U,R),R=new d(e.mul(R.px,E.beta),R.py,R.pz),x=v.add(R),T=O.add(N)}else{let{p:F,f:V}=this.wNAF(h);x=F,T=V}return d.normalizeZ([x,T])[0]}multiplyAndAddUnsafe(h,E,C){let x=d.BASE,T=(V,U)=>U===Ce||U===mt||!V.equals(x)?V.multiplyUnsafe(U):V.multiply(U),F=T(this,E).add(T(h,C));return F.is0()?void 0:F}toAffine(h){return u(this,h)}isTorsionFree(){let{h,isTorsionFree:E}=t;if(h===mt)return!0;if(E)return E(d,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h,clearCofactor:E}=t;return h===mt?this:E?E(d,this):this.multiplyUnsafe(t.h)}toRawBytes(h=!0){return Jt("isCompressed",h),this.assertValidity(),o(d,this,h)}toHex(h=!0){return Jt("isCompressed",h),we(this.toRawBytes(h))}}d.BASE=new d(t.Gx,t.Gy,e.ONE),d.ZERO=new d(e.ZERO,e.ONE,e.ZERO);let b=t.nBitLength,I=jn(d,t.endo?Math.ceil(b/2):b);return{CURVE:t,ProjectivePoint:d,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:a}}function gp(r){let t=tn(r);return ae(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Gu(r){let t=gp(r),{Fp:e,n}=t,o=e.BYTES+1,i=2*e.BYTES+1;function s(A){return tt(A,n)}function a(A){return zn(A,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:f,weierstrassEquation:u,isWithinCurveOrder:l}=mp({...t,toBytes(A,S,m){let p=S.toAffine(),B=e.toBytes(p.x),P=be;return Jt("isCompressed",m),m?P(Uint8Array.from([S.hasEvenY()?2:3]),B):P(Uint8Array.from([4]),B,e.toBytes(p.y))},fromBytes(A){let S=A.length,m=A[0],p=A.subarray(1);if(S===o&&(m===2||m===3)){let B=xe(p);if(!Xr(B,mt,e.ORDER))throw new Error("Point is not on curve");let P=u(B),D;try{D=e.sqrt(P)}catch(G){let z=G instanceof Error?": "+G.message:"";throw new Error("Point is not on curve"+z)}let M=(D&mt)===mt;return(m&1)===1!==M&&(D=e.neg(D)),{x:B,y:D}}else if(S===i&&m===4){let B=e.fromBytes(p.subarray(0,e.BYTES)),P=e.fromBytes(p.subarray(e.BYTES,2*e.BYTES));return{x:B,y:P}}else throw new Error(`Point of length ${S} was invalid. Expected ${o} compressed bytes or ${i} uncompressed bytes`)}}),d=A=>we(Oe(A,t.nByteLength));function b(A){let S=n>>mt;return A>S}function I(A){return b(A)?s(-A):A}let w=(A,S,m)=>xe(A.slice(S,m));class h{constructor(S,m,p){this.r=S,this.s=m,this.recovery=p,this.assertValidity()}static fromCompact(S){let m=t.nByteLength;return S=at("compactSignature",S,m*2),new h(w(S,0,m),w(S,m,2*m))}static fromDER(S){let{r:m,s:p}=ke.toSig(at("DER",S));return new h(m,p)}assertValidity(){Lt("r",this.r,mt,n),Lt("s",this.s,mt,n)}addRecoveryBit(S){return new h(this.r,this.s,S)}recoverPublicKey(S){let{r:m,s:p,recovery:B}=this,P=V(at("msgHash",S));if(B==null||![0,1,2,3].includes(B))throw new Error("recovery id invalid");let D=B===2||B===3?m+t.n:m;if(D>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let M=B&1?"03":"02",q=c.fromHex(M+d(D)),G=a(D),z=s(-P*G),X=s(p*G),rt=c.BASE.multiplyAndAddUnsafe(q,z,X);if(!rt)throw new Error("point at infinify");return rt.assertValidity(),rt}hasHighS(){return b(this.s)}normalizeS(){return this.hasHighS()?new h(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return Je(this.toDERHex())}toDERHex(){return ke.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Je(this.toCompactHex())}toCompactHex(){return d(this.r)+d(this.s)}}let E={isValidPrivateKey(A){try{return f(A),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let A=os(t.n);return Sc(t.randomBytes(A),t.n)},precompute(A=8,S=c.BASE){return S._setWindowSize(A),S.multiply(BigInt(3)),S}};function C(A,S=!0){return c.fromPrivateKey(A).toRawBytes(S)}function x(A){let S=Pe(A),m=typeof A=="string",p=(S||m)&&A.length;return S?p===o||p===i:m?p===2*o||p===2*i:A instanceof c}function T(A,S,m=!0){if(x(A))throw new Error("first arg must be private key");if(!x(S))throw new Error("second arg must be public key");return c.fromHex(S).multiply(f(A)).toRawBytes(m)}let F=t.bits2int||function(A){let S=xe(A),m=A.length*8-t.nBitLength;return m>0?S>>BigInt(m):S},V=t.bits2int_modN||function(A){return s(F(A))},U=Qr(t.nBitLength);function g(A){return Lt(`num < 2^${t.nBitLength}`,A,Ce,U),Oe(A,t.nByteLength)}function v(A,S,m=O){if(["recovered","canonical"].some(pt=>pt in m))throw new Error("sign() legacy options not supported");let{hash:p,randomBytes:B}=t,{lowS:P,prehash:D,extraEntropy:M}=m;P==null&&(P=!0),A=at("msgHash",A),zu(m),D&&(A=at("prehashed msgHash",p(A)));let q=V(A),G=f(S),z=[g(G),g(q)];if(M!=null&&M!==!1){let pt=M===!0?B(e.BYTES):M;z.push(at("extraEntropy",pt))}let X=be(...z),rt=q;function ht(pt){let yt=F(pt);if(!l(yt))return;let It=a(yt),lt=c.BASE.multiply(yt).toAffine(),Ut=s(lt.x);if(Ut===Ce)return;let pe=s(It*s(rt+Ut*G));if(pe===Ce)return;let jr=(lt.x===Ut?0:2)|Number(lt.y&mt),Gr=pe;return P&&b(pe)&&(Gr=I(pe),jr^=1),new h(Ut,Gr,jr)}return{seed:X,k2sig:ht}}let O={lowS:t.lowS,prehash:!1},R={lowS:t.lowS,prehash:!1};function N(A,S,m=O){let{seed:p,k2sig:B}=v(A,S,m),P=t;return ts(P.hash.outputLen,P.nByteLength,P.hmac)(p,B)}c.BASE._setWindowSize(8);function H(A,S,m,p=R){let B=A;if(S=at("msgHash",S),m=at("publicKey",m),"strict"in p)throw new Error("options.strict was renamed to lowS");zu(p);let{lowS:P,prehash:D}=p,M,q;try{if(typeof B=="string"||Pe(B))try{M=h.fromDER(B)}catch(lt){if(!(lt instanceof ke.Err))throw lt;M=h.fromCompact(B)}else if(typeof B=="object"&&typeof B.r=="bigint"&&typeof B.s=="bigint"){let{r:lt,s:Ut}=B;M=new h(lt,Ut)}else throw new Error("PARSE");q=c.fromHex(m)}catch(lt){if(lt.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(P&&M.hasHighS())return!1;D&&(S=t.hash(S));let{r:G,s:z}=M,X=V(S),rt=a(z),ht=s(X*rt),pt=s(G*rt),yt=c.BASE.multiplyAndAddUnsafe(q,ht,pt)?.toAffine();return yt?s(yt.x)===G:!1}return{CURVE:t,getPublicKey:C,getSharedSecret:T,sign:N,verify:H,ProjectivePoint:c,Signature:h,utils:E}}function yp(r){return{hash:r,hmac:(t,...e)=>Ws(r,t,ji(...e)),randomBytes:$n}}function Zu(r,t){let e=n=>Gu({...r,...yp(n)});return Object.freeze({...e(t),create:e})}var Ju=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Wu=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),wp=BigInt(1),Ys=BigInt(2),Yu=(r,t)=>(r+t/Ys)/t;function xp(r){let t=Ju,e=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),f=r*r*r%t,u=f*f*r%t,l=it(u,e,t)*u%t,d=it(l,e,t)*u%t,b=it(d,Ys,t)*f%t,I=it(b,o,t)*b%t,w=it(I,i,t)*I%t,h=it(w,a,t)*w%t,E=it(h,c,t)*h%t,C=it(E,a,t)*w%t,x=it(C,e,t)*u%t,T=it(x,s,t)*I%t,F=it(T,n,t)*f%t,V=it(F,Ys,t);if(!Js.eql(Js.sqr(V),r))throw new Error("Cannot find square root");return V}var Js=De(Ju,void 0,void 0,{sqrt:xp}),ir=Zu({a:BigInt(0),b:BigInt(7),Fp:Js,n:Wu,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=Wu,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-wp*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=e,s=BigInt("0x100000000000000000000000000000000"),a=Yu(i*r,t),c=Yu(-n*r,t),f=tt(r-a*e-c*o,t),u=tt(-a*n-c*i,t),l=f>s,d=u>s;if(l&&(f=t-f),d&&(u=t-u),f>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:l,k1:f,k2neg:d,k2:u}}}},Tr),Nx=BigInt(0);var Ux=ir.ProjectivePoint;function Dt(r,t){t==null&&(t=r.reduce((o,i)=>o+i.length,0));let e=Qt(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}function Xu(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function Qu(r,t,e){let n=en.digest(e instanceof Uint8Array?e:e.subarray());if(Xu(n))return n.then(({digest:o})=>ir.verify(t,o,r)).catch(o=>{throw new mn(String(o))});try{return ir.verify(t,n.digest,r)}catch(o){throw new mn(String(o))}}var Wo=class{type="secp256k1";raw;_key;constructor(t){this._key=el(t),this.raw=tl(this._key)}toMultihash(){return Wt.digest(Jn(this))}toCID(){return Q.createV1(114,this.toMultihash())}toString(){return nt.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ct(this.raw,t.raw)}verify(t,e){return Qu(this._key,e,t)}};function Xs(r){return new Wo(r)}function tl(r){return ir.ProjectivePoint.fromHex(r).toRawBytes(!0)}function el(r){try{return ir.ProjectivePoint.fromHex(r),r}catch(t){throw new lr(String(t))}}function rl(r){let{Type:t,Data:e}=ce.decode(r),n=e??new Uint8Array;switch(t){case dt.RSA:return Zs(n);case dt.Ed25519:return us(n);case dt.secp256k1:return Xs(n);default:throw new dr}}function Yo(r){let{Type:t,Data:e}=ce.decode(r.digest),n=e??new Uint8Array;switch(t){case dt.Ed25519:return us(n);case dt.secp256k1:return Xs(n);default:throw new dr}}function Jn(r){return ce.encode({Type:dt[r.type],Data:r.raw})}var nl=Symbol.for("nodejs.util.inspect.custom"),bp=114,wn=class{type;multihash;publicKey;string;constructor(t){this.type=t.type,this.multihash=t.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[Ri]=!0;toString(){return this.string==null&&(this.string=nt.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return Q.createV1(bp,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return ct(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return ct(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[nl](){return`PeerId(${this.toString()})`}},Jo=class extends wn{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Xo=class extends wn{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Qo=class extends wn{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},vp=2336,xn=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=Wt.digest(Z(this.url))}[nl](){return`PeerId(${this.url})`}[Ri]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return Q.createV1(vp,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=W(t)),t.toString()===this.toString())}};var Ep=114,ol=2336;function il(r,t){let e;if(r.charAt(0)==="1"||r.charAt(0)==="Q")e=ge(nt.decode(`z${r}`));else{if(t==null)throw new vt('Please pass a multibase decoder for strings that do not start with "1" or "Q"');e=ge(t.decode(r))}return sl(e)}function sl(r){if(Ap(r))return new Jo({multihash:r});if(Bp(r))try{let t=Yo(r);if(t.type==="Ed25519")return new Xo({multihash:r,publicKey:t});if(t.type==="secp256k1")return new Qo({multihash:r,publicKey:t})}catch{let e=W(r.digest);return new xn(new URL(e))}throw new fr("Supplied PeerID Multihash is invalid")}function al(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==Ep&&r.code!==ol)throw new Ln("Supplied PeerID CID is invalid");if(r.code===ol){let t=W(r.multihash.digest);return new xn(new URL(t))}return sl(r.multihash)}function Bp(r){return r.code===Wt.code}function Ap(r){return r.code===en.code}var ti=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let e=this.index,n=t();return n===void 0&&(this.index=e),n}parseWith(t){let e=t();if(this.index===this.input.length)return e}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let e=this.readChar();if(e===t)return e})}readSeparator(t,e,n){return this.readAtomically(()=>{if(!(e>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,e,n,o){return this.readAtomically(()=>{let i=0,s=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",f=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let d=Number.parseInt(l,t);if(!Number.isNaN(d))return d});if(u===void 0)break;if(i*=t,i+=u,i>f||(s+=1,e!==void 0&&s>e))return}if(s!==0)return!n&&c&&s>1?void 0:i})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let e=0;e<t.length;e++){let n=this.readSeparator(".",e,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[e]=n}return t})}readIPv6Addr(){let t=e=>{for(let n=0;n<e.length/2;n++){let o=n*2;if(n<e.length-3){let s=this.readSeparator(":",n,()=>this.readIPv4Addr());if(s!==void 0)return e[o]=s[0],e[o+1]=s[1],e[o+2]=s[2],e[o+3]=s[3],[o+4,!0]}let i=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(i===void 0)return[o,!1];e[o]=i>>8,e[o+1]=i&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[n,o]=t(e);if(n===16)return e;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let i=new Uint8Array(14),s=16-(n+2),[a]=t(i.subarray(0,s));return e.set(i.subarray(0,a),16-a),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var cl=45,Sp=15,Pr=new ti;function Qs(r){if(!(r.length>Sp))return Pr.new(r).parseWith(()=>Pr.readIPv4Addr())}function ta(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>cl))return Pr.new(r).parseWith(()=>Pr.readIPv6Addr())}function ei(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>cl))return Pr.new(r).parseWith(()=>Pr.readIPAddr())}var jb=parseInt("0xFFFF",16),Gb=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function fl(r){return!!Qs(r)}function dl(r){return!!ta(r)}function ri(r){return!!ei(r)}var hl=fl,Np=dl,ea=function(r){let t=0;if(r=r.toString().trim(),hl(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(Np(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let i=hl(e[n]),s;i&&(s=ea(e[n]),e[n]=W(s.slice(0,2),"base16")),s!=null&&++n<8&&e.splice(n,0,W(s.slice(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let i=[n,1];for(n=9-e.length;n>0;n--)i.push("0");e.splice.apply(e,i)}let o=new Uint8Array(t+16);for(n=0;n<e.length;n++){let i=parseInt(e[n],16);o[t++]=i>>8&255,o[t++]=i&255}return o}throw new Error("invalid ip address")},pl=function(r,t=0,e){t=~~t,e=e??r.length-t;let n=new DataView(r.buffer);if(e===4){let o=[];for(let i=0;i<e;i++)o.push(r[t+i]);return o.join(".")}if(e===16){let o=[];for(let i=0;i<e;i+=2)o.push(n.getUint16(t+i).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Fr={},ra={},Rp=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[481,-1,"http-path"],[777,-1,"memory"]];Rp.forEach(r=>{let t=_p(...r);ra[t.code]=t,Fr[t.name]=t});function _p(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function et(r){if(typeof r=="number"){if(ra[r]!=null)return ra[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Fr[r]!=null)return Fr[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var N1=et("ip4"),U1=et("ip6"),R1=et("ipcidr");function sa(r,t){switch(et(r).code){case 4:case 41:return Vp(t);case 42:return ia(t);case 6:case 273:case 33:case 132:return yl(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return ia(t);case 421:return Dp(t);case 444:return gl(t);case 445:return gl(t);case 466:return Op(t);case 481:return globalThis.encodeURIComponent(ia(t));default:return W(t,"base16")}}function aa(r,t){switch(et(r).code){case 4:return ml(t);case 41:return ml(t);case 42:return oa(t);case 6:case 273:case 33:case 132:return ca(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return oa(t);case 421:return Pp(t);case 444:return Mp(t);case 445:return $p(t);case 466:return Fp(t);case 481:return oa(globalThis.decodeURIComponent(t));default:return Z(t,"base16")}}var na=Object.values(rn).map(r=>r.decoder),Lp=function(){let r=na[0].or(na[1]);return na.slice(2).forEach(t=>r=r.or(t)),r}();function ml(r){if(!ri(r))throw new Error("invalid ip address");return ea(r)}function Vp(r){let t=pl(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!ri(t))throw new Error("invalid ip address");return t}function ca(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function yl(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function oa(r){let t=Z(r),e=Uint8Array.from(Ar(t.length));return Dt([e,t],e.length+t.length)}function ia(r){let t=er(r);if(r=r.slice(Pt(t)),r.length!==t)throw new Error("inconsistent lengths");return W(r)}function Pp(r){let t;r[0]==="Q"||r[0]==="1"?t=ge(nt.decode(`z${r}`)).bytes:t=Q.parse(r).multihash.bytes;let e=Uint8Array.from(Ar(t.length));return Dt([e,t],e.length+t.length)}function Fp(r){let t=Lp.decode(r),e=Uint8Array.from(Ar(t.length));return Dt([e,t],e.length+t.length)}function Op(r){let t=er(r),e=r.slice(Pt(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+W(e,"base64url")}function Dp(r){let t=er(r),e=r.slice(Pt(t));if(e.length!==t)throw new Error("inconsistent lengths");return W(e,"base58btc")}function Mp(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=Gt.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ca(n);return Dt([e,o],e.length+o.length)}function $p(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=Gt.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ca(n);return Dt([e,o],e.length+o.length)}function gl(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=W(t,"base32"),o=yl(e);return`${n}:${o}`}function wl(r){r=ua(r);let t=[],e=[],n=null,o=r.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let i=0;i<o.length;i++){let s=o[i],a=et(s);if(a.size===0){t.push([a.code]),e.push([a.code]);continue}if(i++,i>=o.length)throw bl("invalid address: "+r);if(a.path===!0){n=ua(o.slice(i).join("/")),t.push([a.code,aa(a.code,n)]),e.push([a.code,n]);break}let c=aa(a.code,o[i]);t.push([a.code,c]),e.push([a.code,sa(a.code,c)])}return{string:xl(e),bytes:fa(t),tuples:t,stringTuples:e,path:n}}function la(r){let t=[],e=[],n=null,o=0;for(;o<r.length;){let i=er(r,o),s=Pt(i),a=et(i),c=Hp(a,r.slice(o+s));if(c===0){t.push([i]),e.push([i]),o+=s;continue}let f=r.slice(o+s,o+s+c);if(o+=c+s,o>r.length)throw bl("Invalid address Uint8Array: "+W(r,"base16"));t.push([i,f]);let u=sa(i,f);if(e.push([i,u]),a.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:xl(e),tuples:t,stringTuples:e,path:n}}function xl(r){let t=[];return r.map(e=>{let n=et(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),ua(t.join("/"))}function fa(r){return Dt(r.map(t=>{let e=et(t[0]),n=Uint8Array.from(Ar(e.code));return t.length>1&&t[1]!=null&&(n=Dt([n,t[1]])),n}))}function Hp(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=er(t instanceof Uint8Array?t:Uint8Array.from(t));return e+Pt(e)}}function ua(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function bl(r){return new Error("Error parsing address: "+r)}var Kp=Symbol.for("nodejs.util.inspect.custom"),ha=Symbol.for("@multiformats/js-multiaddr/multiaddr"),qp=[et("dns").code,et("dns4").code,et("dns6").code,et("dnsaddr").code],da=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}},ni=class r{bytes;#t;#e;#i;#a;[ha]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=la(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=wl(t)}else if(El(t))e=la(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=e.bytes,this.#t=e.string,this.#e=e.tuples,this.#i=e.stringTuples,this.#a=e.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let t,e,n,o,i="",s=et("tcp"),a=et("udp"),c=et("ip4"),f=et("ip6"),u=et("dns6"),l=et("ip6zone");for(let[b,I]of this.stringTuples())b===l.code&&(i=`%${I??""}`),qp.includes(b)&&(e=s.name,o=443,n=`${I??""}${i}`,t=b===u.code?6:4),(b===s.code||b===a.code)&&(e=et(b).name,o=parseInt(I??"")),(b===c.code||b===f.code)&&(e=et(b).name,n=`${I??""}${i}`,t=b===f.code?6:4);if(t==null||e==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:e,port:o}}protos(){return this.#e.map(([t])=>Object.assign({},et(t)))}protoCodes(){return this.#e.map(([t])=>t)}protoNames(){return this.#e.map(([t])=>et(t).name)}tuples(){return this.#e}stringTuples(){return this.#i}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),o=n.lastIndexOf(e);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,o))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new r(fa(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===Fr.p2p.code&&t.push([n,o]),n===Fr["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?W(nt.decode(`z${n}`),"base58btc"):W(Q.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#a}equals(t){return ct(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(i=>i.resolvable);if(e==null)return[this];let n=vl.get(e.name);if(n==null)throw new da(`no available resolver for ${e.name}`);return(await n(this,t)).map(i=>sr(i))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let e=(t??this).protos();return!(e.length!==2||e[0].code!==4&&e[0].code!==41||e[1].code!==6&&e[1].code!==273)}[Kp](){return`Multiaddr(${this.#t})`}};var vl=new Map;function El(r){return!!r?.[ha]}function sr(r){return new ni(r)}function bn(r){let t=new globalThis.AbortController;function e(){t.abort();for(let i of r)i?.removeEventListener!=null&&i.removeEventListener("abort",e)}for(let i of r){if(i?.aborted===!0){e();break}i?.addEventListener!=null&&i.addEventListener("abort",e)}function n(){for(let i of r)i?.removeEventListener!=null&&i.removeEventListener("abort",e)}let o=t.signal;return o.clear=n,o}async function*oi(r,t={}){let e=r.getReader();try{for(;;){let n=await e.read();if(n.done)return;yield n.value}}finally{t.preventCancel!==!0&&await e.cancel(),e.releaseLock()}}var zp="/",jp=new TextEncoder().encode(zp),s2=jp[0];var Im=_n(ma(),1);var re=class extends Error{static name="SignatureVerificationError";constructor(t="Record signature verification failed"){super(t),this.name="SignatureVerificationError"}},ii=class extends Error{static name="RecordExpiredError";constructor(t="Record has expired"){super(t),this.name="RecordExpiredError"}},Or=class extends Error{static name="UnsupportedValidityError";constructor(t="The validity type is unsupported"){super(t),this.name="UnsupportedValidityError"}},si=class extends Error{static name="RecordTooLargeError";constructor(t="The record is too large"){super(t),this.name="RecordTooLargeError"}},ai=class extends Error{static name="InvalidValueError";constructor(t="Value must be a valid content path starting with /"){super(t),this.name="InvalidValueError"}},ci=class extends Error{static name="InvalidRecordDataError";constructor(t="Invalid record data"){super(t),this.name="InvalidRecordDataError"}},vn=class extends Error{static name="InvalidEmbeddedPublicKeyError";constructor(t="Invalid embedded public key"){super(t),this.name="InvalidEmbeddedPublicKeyError"}};var ne;(function(r){let t;(function(o){o.EOL="EOL"})(t=r.ValidityType||(r.ValidityType={}));let e;(function(o){o[o.EOL=0]="EOL"})(e||(e={})),function(o){o.codec=()=>sn(e)}(t=r.ValidityType||(r.ValidityType={}));let n;r.codec=()=>(n==null&&(n=Cr((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),r.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 f=o.uint32();switch(f>>>3){case 1:{a.value=o.bytes();break}case 2:{a.signatureV1=o.bytes();break}case 3:{a.validityType=r.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(f&7);break}}}return a})),n),r.encode=o=>Ir(o,r.codec()),r.decode=(o,i)=>Sr(o,r.codec(),i)})(ne||(ne={}));var Gp=["string","number","bigint","symbol"],Zp=["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 Bl(r){if(r===null)return"null";if(r===void 0)return"undefined";if(r===!0||r===!1)return"boolean";let t=typeof r;if(Gp.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(r))return"Array";if(Wp(r))return"Buffer";let e=Yp(r);return e||"Object"}function Wp(r){return r&&r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer.call(null,r)}function Yp(r){let t=Object.prototype.toString.call(r).slice(8,-1);if(Zp.includes(t))return t}var y=class{constructor(t,e,n){this.major=t,this.majorEncoded=t<<5,this.name=e,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(t){return this.major<t.major?-1:this.major>t.major?1:0}};y.uint=new y(0,"uint",!0);y.negint=new y(1,"negint",!0);y.bytes=new y(2,"bytes",!0);y.string=new y(3,"string",!0);y.array=new y(4,"array",!1);y.map=new y(5,"map",!1);y.tag=new y(6,"tag",!1);y.float=new y(7,"float",!0);y.false=new y(7,"false",!0);y.true=new y(7,"true",!0);y.null=new y(7,"null",!0);y.undefined=new y(7,"undefined",!0);y.break=new y(7,"break",!0);var L=class{constructor(t,e,n){this.type=t,this.value=e,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var Dr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Jp=new TextDecoder,Xp=new TextEncoder;function ui(r){return Dr&&globalThis.Buffer.isBuffer(r)}function kl(r){return r instanceof Uint8Array?ui(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r:Uint8Array.from(r)}var Cl=Dr?(r,t,e)=>e-t>64?globalThis.Buffer.from(r.subarray(t,e)).toString("utf8"):Sl(r,t,e):(r,t,e)=>e-t>64?Jp.decode(r.subarray(t,e)):Sl(r,t,e),Tl=Dr?r=>r.length>64?globalThis.Buffer.from(r):Al(r):r=>r.length>64?Xp.encode(r):Al(r);var Mr=Dr?(r,t,e)=>ui(r)?new Uint8Array(r.subarray(t,e)):r.slice(t,e):(r,t,e)=>r.slice(t,e),Nl=Dr?(r,t)=>(r=r.map(e=>e instanceof Uint8Array?e:globalThis.Buffer.from(e)),kl(globalThis.Buffer.concat(r,t))):(r,t)=>{let e=new Uint8Array(t),n=0;for(let o of r)n+o.length>e.length&&(o=o.subarray(0,e.length-n)),e.set(o,n),n+=o.length;return e},Ul=Dr?r=>globalThis.Buffer.allocUnsafe(r):r=>new Uint8Array(r);function Rl(r,t){if(ui(r)&&ui(t))return r.compare(t);for(let e=0;e<r.length;e++)if(r[e]!==t[e])return r[e]<t[e]?-1:1;return 0}function Al(r){let t=[],e=0;for(let n=0;n<r.length;n++){let o=r.charCodeAt(n);o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&n+1<r.length&&(r.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(r.charCodeAt(++n)&1023),t[e++]=o>>18|240,t[e++]=o>>12&63|128,t[e++]=o>>6&63|128,t[e++]=o&63|128):(t[e++]=o>>12|224,t[e++]=o>>6&63|128,t[e++]=o&63|128)}return t}function Sl(r,t,e){let n=[];for(;t<e;){let o=r[t],i=null,s=o>239?4:o>223?3:o>191?2:1;if(t+s<=e){let a,c,f,u;switch(s){case 1:o<128&&(i=o);break;case 2:a=r[t+1],(a&192)===128&&(u=(o&31)<<6|a&63,u>127&&(i=u));break;case 3:a=r[t+1],c=r[t+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=r[t+1],c=r[t+2],f=r[t+3],(a&192)===128&&(c&192)===128&&(f&192)===128&&(u=(o&15)<<18|(a&63)<<12|(c&63)<<6|f&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),t+=s}return Qp(n)}var Il=4096;function Qp(r){let t=r.length;if(t<=Il)return String.fromCharCode.apply(String,r);let e="",n=0;for(;n<t;)e+=String.fromCharCode.apply(String,r.slice(n,n+=Il));return e}var tm=256,li=class{constructor(t=tm){this.chunkSize=t,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(t){let e=this.chunks[this.chunks.length-1];if(this.cursor+t.length<=this.maxCursor+1){let o=e.length-(this.maxCursor-this.cursor)-1;e.set(t,o)}else{if(e){let o=e.length-(this.maxCursor-this.cursor)-1;o<e.length&&(this.chunks[this.chunks.length-1]=e.subarray(0,o),this.maxCursor=this.cursor-1)}t.length<64&&t.length<this.chunkSize?(e=Ul(this.chunkSize),this.chunks.push(e),this.maxCursor+=e.length,this._initReuseChunk===null&&(this._initReuseChunk=e),e.set(t,0)):(this.chunks.push(t),this.maxCursor+=t.length)}this.cursor+=t.length}toBytes(t=!1){let e;if(this.chunks.length===1){let n=this.chunks[0];t&&this.cursor>n.length/2?(e=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):e=Mr(n,0,this.cursor)}else e=Nl(this.chunks,this.cursor);return t&&this.reset(),e}};var $="CBOR decode error:",ga="CBOR encode error:",En=[];En[23]=1;En[24]=2;En[25]=3;En[26]=5;En[27]=9;function Te(r,t,e){if(r.length-t<e)throw new Error(`${$} not enough data for type`)}var gt=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Mt(r,t,e){Te(r,t,1);let n=r[t];if(e.strict===!0&&n<gt[0])throw new Error(`${$} integer encoded in more bytes than necessary (strict decode)`);return n}function $t(r,t,e){Te(r,t,2);let n=r[t]<<8|r[t+1];if(e.strict===!0&&n<gt[1])throw new Error(`${$} integer encoded in more bytes than necessary (strict decode)`);return n}function Ht(r,t,e){Te(r,t,4);let n=r[t]*16777216+(r[t+1]<<16)+(r[t+2]<<8)+r[t+3];if(e.strict===!0&&n<gt[2])throw new Error(`${$} integer encoded in more bytes than necessary (strict decode)`);return n}function Kt(r,t,e){Te(r,t,8);let n=r[t]*16777216+(r[t+1]<<16)+(r[t+2]<<8)+r[t+3],o=r[t+4]*16777216+(r[t+5]<<16)+(r[t+6]<<8)+r[t+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(e.strict===!0&&i<gt[3])throw new Error(`${$} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(e.allowBigInt===!0)return i;throw new Error(`${$} integers outside of the safe integer range are not supported`)}function _l(r,t,e,n){return new L(y.uint,Mt(r,t+1,n),2)}function Ll(r,t,e,n){return new L(y.uint,$t(r,t+1,n),3)}function Vl(r,t,e,n){return new L(y.uint,Ht(r,t+1,n),5)}function Pl(r,t,e,n){return new L(y.uint,Kt(r,t+1,n),9)}function zt(r,t){return bt(r,0,t.value)}function bt(r,t,e){if(e<gt[0]){let n=Number(e);r.push([t|n])}else if(e<gt[1]){let n=Number(e);r.push([t|24,n])}else if(e<gt[2]){let n=Number(e);r.push([t|25,n>>>8,n&255])}else if(e<gt[3]){let n=Number(e);r.push([t|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(e);if(n<gt[4]){let o=[t|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),s=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=s&255,s=s>>8,o[3]=s&255,s=s>>8,o[2]=s&255,s=s>>8,o[1]=s&255,r.push(o)}else throw new Error(`${$} encountered BigInt larger than allowable range`)}}zt.encodedSize=function(t){return bt.encodedSize(t.value)};bt.encodedSize=function(t){return t<gt[0]?1:t<gt[1]?2:t<gt[2]?3:t<gt[3]?5:9};zt.compareTokens=function(t,e){return t.value<e.value?-1:t.value>e.value?1:0};function Fl(r,t,e,n){return new L(y.negint,-1-Mt(r,t+1,n),2)}function Ol(r,t,e,n){return new L(y.negint,-1-$t(r,t+1,n),3)}function Dl(r,t,e,n){return new L(y.negint,-1-Ht(r,t+1,n),5)}var ya=BigInt(-1),Ml=BigInt(1);function $l(r,t,e,n){let o=Kt(r,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new L(y.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${$} integers outside of the safe integer range are not supported`);return new L(y.negint,ya-BigInt(o),9)}function fi(r,t){let e=t.value,n=typeof e=="bigint"?e*ya-Ml:e*-1-1;bt(r,t.type.majorEncoded,n)}fi.encodedSize=function(t){let e=t.value,n=typeof e=="bigint"?e*ya-Ml:e*-1-1;return n<gt[0]?1:n<gt[1]?2:n<gt[2]?3:n<gt[3]?5:9};fi.compareTokens=function(t,e){return t.value<e.value?1:t.value>e.value?-1:0};function Bn(r,t,e,n){Te(r,t,e+n);let o=Mr(r,t+e,t+e+n);return new L(y.bytes,o,e+n)}function Hl(r,t,e,n){return Bn(r,t,1,e)}function Kl(r,t,e,n){return Bn(r,t,2,Mt(r,t+1,n))}function ql(r,t,e,n){return Bn(r,t,3,$t(r,t+1,n))}function zl(r,t,e,n){return Bn(r,t,5,Ht(r,t+1,n))}function jl(r,t,e,n){let o=Kt(r,t+1,n);if(typeof o=="bigint")throw new Error(`${$} 64-bit integer bytes lengths not supported`);return Bn(r,t,9,o)}function di(r){return r.encodedBytes===void 0&&(r.encodedBytes=r.type===y.string?Tl(r.value):r.value),r.encodedBytes}function $r(r,t){let e=di(t);bt(r,t.type.majorEncoded,e.length),r.push(e)}$r.encodedSize=function(t){let e=di(t);return bt.encodedSize(e.length)+e.length};$r.compareTokens=function(t,e){return rm(di(t),di(e))};function rm(r,t){return r.length<t.length?-1:r.length>t.length?1:Rl(r,t)}function An(r,t,e,n,o){let i=e+n;Te(r,t,i);let s=new L(y.string,Cl(r,t+e,t+i),i);return o.retainStringBytes===!0&&(s.byteValue=Mr(r,t+e,t+i)),s}function Gl(r,t,e,n){return An(r,t,1,e,n)}function Zl(r,t,e,n){return An(r,t,2,Mt(r,t+1,n),n)}function Wl(r,t,e,n){return An(r,t,3,$t(r,t+1,n),n)}function Yl(r,t,e,n){return An(r,t,5,Ht(r,t+1,n),n)}function Jl(r,t,e,n){let o=Kt(r,t+1,n);if(typeof o=="bigint")throw new Error(`${$} 64-bit integer string lengths not supported`);return An(r,t,9,o,n)}var Xl=$r;function Hr(r,t,e,n){return new L(y.array,n,e)}function Ql(r,t,e,n){return Hr(r,t,1,e)}function tf(r,t,e,n){return Hr(r,t,2,Mt(r,t+1,n))}function ef(r,t,e,n){return Hr(r,t,3,$t(r,t+1,n))}function rf(r,t,e,n){return Hr(r,t,5,Ht(r,t+1,n))}function nf(r,t,e,n){let o=Kt(r,t+1,n);if(typeof o=="bigint")throw new Error(`${$} 64-bit integer array lengths not supported`);return Hr(r,t,9,o)}function of(r,t,e,n){if(n.allowIndefinite===!1)throw new Error(`${$} indefinite length items not allowed`);return Hr(r,t,1,1/0)}function hi(r,t){bt(r,y.array.majorEncoded,t.value)}hi.compareTokens=zt.compareTokens;hi.encodedSize=function(t){return bt.encodedSize(t.value)};function Kr(r,t,e,n){return new L(y.map,n,e)}function sf(r,t,e,n){return Kr(r,t,1,e)}function af(r,t,e,n){return Kr(r,t,2,Mt(r,t+1,n))}function cf(r,t,e,n){return Kr(r,t,3,$t(r,t+1,n))}function uf(r,t,e,n){return Kr(r,t,5,Ht(r,t+1,n))}function lf(r,t,e,n){let o=Kt(r,t+1,n);if(typeof o=="bigint")throw new Error(`${$} 64-bit integer map lengths not supported`);return Kr(r,t,9,o)}function ff(r,t,e,n){if(n.allowIndefinite===!1)throw new Error(`${$} indefinite length items not allowed`);return Kr(r,t,1,1/0)}function pi(r,t){bt(r,y.map.majorEncoded,t.value)}pi.compareTokens=zt.compareTokens;pi.encodedSize=function(t){return bt.encodedSize(t.value)};function df(r,t,e,n){return new L(y.tag,e,1)}function hf(r,t,e,n){return new L(y.tag,Mt(r,t+1,n),2)}function pf(r,t,e,n){return new L(y.tag,$t(r,t+1,n),3)}function mf(r,t,e,n){return new L(y.tag,Ht(r,t+1,n),5)}function gf(r,t,e,n){return new L(y.tag,Kt(r,t+1,n),9)}function mi(r,t){bt(r,y.tag.majorEncoded,t.value)}mi.compareTokens=zt.compareTokens;mi.encodedSize=function(t){return bt.encodedSize(t.value)};var cm=20,um=21,lm=22,fm=23;function yf(r,t,e,n){if(n.allowUndefined===!1)throw new Error(`${$} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new L(y.null,null,1):new L(y.undefined,void 0,1)}function wf(r,t,e,n){if(n.allowIndefinite===!1)throw new Error(`${$} indefinite length items not allowed`);return new L(y.break,void 0,1)}function wa(r,t,e){if(e){if(e.allowNaN===!1&&Number.isNaN(r))throw new Error(`${$} NaN values are not supported`);if(e.allowInfinity===!1&&(r===1/0||r===-1/0))throw new Error(`${$} Infinity values are not supported`)}return new L(y.float,r,t)}function xf(r,t,e,n){return wa(xa(r,t+1),3,n)}function bf(r,t,e,n){return wa(ba(r,t+1),5,n)}function vf(r,t,e,n){return wa(Sf(r,t+1),9,n)}function gi(r,t,e){let n=t.value;if(n===!1)r.push([y.float.majorEncoded|cm]);else if(n===!0)r.push([y.float.majorEncoded|um]);else if(n===null)r.push([y.float.majorEncoded|lm]);else if(n===void 0)r.push([y.float.majorEncoded|fm]);else{let o,i=!1;(!e||e.float64!==!0)&&(Bf(n),o=xa(oe,1),n===o||Number.isNaN(n)?(oe[0]=249,r.push(oe.slice(0,3)),i=!0):(Af(n),o=ba(oe,1),n===o&&(oe[0]=250,r.push(oe.slice(0,5)),i=!0))),i||(dm(n),o=Sf(oe,1),oe[0]=251,r.push(oe.slice(0,9)))}}gi.encodedSize=function(t,e){let n=t.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!e||e.float64!==!0){Bf(n);let o=xa(oe,1);if(n===o||Number.isNaN(n))return 3;if(Af(n),o=ba(oe,1),n===o)return 5}return 9};var Ef=new ArrayBuffer(9),jt=new DataView(Ef,1),oe=new Uint8Array(Ef,0);function Bf(r){if(r===1/0)jt.setUint16(0,31744,!1);else if(r===-1/0)jt.setUint16(0,64512,!1);else if(Number.isNaN(r))jt.setUint16(0,32256,!1);else{jt.setFloat32(0,r);let t=jt.getUint32(0),e=(t&2139095040)>>23,n=t&8388607;if(e===255)jt.setUint16(0,31744,!1);else if(e===0)jt.setUint16(0,(r&2147483648)>>16|n>>13,!1);else{let o=e-127;o<-24?jt.setUint16(0,0):o<-14?jt.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):jt.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function xa(r,t){if(r.length-t<2)throw new Error(`${$} not enough data for float16`);let e=(r[t]<<8)+r[t+1];if(e===31744)return 1/0;if(e===64512)return-1/0;if(e===32256)return NaN;let n=e>>10&31,o=e&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,e&32768?-i:i}function Af(r){jt.setFloat32(0,r,!1)}function ba(r,t){if(r.length-t<4)throw new Error(`${$} not enough data for float32`);let e=(r.byteOffset||0)+t;return new DataView(r.buffer,e,4).getFloat32(0,!1)}function dm(r){jt.setFloat64(0,r,!1)}function Sf(r,t){if(r.length-t<8)throw new Error(`${$} not enough data for float64`);let e=(r.byteOffset||0)+t;return new DataView(r.buffer,e,8).getFloat64(0,!1)}gi.compareTokens=zt.compareTokens;function Y(r,t,e){throw new Error(`${$} encountered invalid minor (${e}) for major ${r[t]>>>5}`)}function yi(r){return()=>{throw new Error(`${$} ${r}`)}}var k=[];for(let r=0;r<=23;r++)k[r]=Y;k[24]=_l;k[25]=Ll;k[26]=Vl;k[27]=Pl;k[28]=Y;k[29]=Y;k[30]=Y;k[31]=Y;for(let r=32;r<=55;r++)k[r]=Y;k[56]=Fl;k[57]=Ol;k[58]=Dl;k[59]=$l;k[60]=Y;k[61]=Y;k[62]=Y;k[63]=Y;for(let r=64;r<=87;r++)k[r]=Hl;k[88]=Kl;k[89]=ql;k[90]=zl;k[91]=jl;k[92]=Y;k[93]=Y;k[94]=Y;k[95]=yi("indefinite length bytes/strings are not supported");for(let r=96;r<=119;r++)k[r]=Gl;k[120]=Zl;k[121]=Wl;k[122]=Yl;k[123]=Jl;k[124]=Y;k[125]=Y;k[126]=Y;k[127]=yi("indefinite length bytes/strings are not supported");for(let r=128;r<=151;r++)k[r]=Ql;k[152]=tf;k[153]=ef;k[154]=rf;k[155]=nf;k[156]=Y;k[157]=Y;k[158]=Y;k[159]=of;for(let r=160;r<=183;r++)k[r]=sf;k[184]=af;k[185]=cf;k[186]=uf;k[187]=lf;k[188]=Y;k[189]=Y;k[190]=Y;k[191]=ff;for(let r=192;r<=215;r++)k[r]=df;k[216]=hf;k[217]=pf;k[218]=mf;k[219]=gf;k[220]=Y;k[221]=Y;k[222]=Y;k[223]=Y;for(let r=224;r<=243;r++)k[r]=yi("simple values are not supported");k[244]=Y;k[245]=Y;k[246]=Y;k[247]=yf;k[248]=yi("simple values are not supported");k[249]=xf;k[250]=bf;k[251]=vf;k[252]=Y;k[253]=Y;k[254]=Y;k[255]=wf;var ie=[];for(let r=0;r<24;r++)ie[r]=new L(y.uint,r,1);for(let r=-1;r>=-24;r--)ie[31-r]=new L(y.negint,r,1);ie[64]=new L(y.bytes,new Uint8Array(0),1);ie[96]=new L(y.string,"",1);ie[128]=new L(y.array,0,1);ie[160]=new L(y.map,0,1);ie[244]=new L(y.false,!1,1);ie[245]=new L(y.true,!0,1);ie[246]=new L(y.null,null,1);function pm(){let r=[];return r[y.uint.major]=zt,r[y.negint.major]=fi,r[y.bytes.major]=$r,r[y.string.major]=Xl,r[y.array.major]=hi,r[y.map.major]=pi,r[y.tag.major]=mi,r[y.float.major]=gi,r}var ov=pm(),iv=new li,wi=class r{constructor(t,e){this.obj=t,this.parent=e}includes(t){let e=this;do if(e.obj===t)return!0;while(e=e.parent);return!1}static createCheck(t,e){if(t&&t.includes(e))throw new Error(`${ga} object contains circular references`);return new r(e,t)}},je={null:new L(y.null,null),undefined:new L(y.undefined,void 0),true:new L(y.true,!0),false:new L(y.false,!1),emptyArray:new L(y.array,0),emptyMap:new L(y.map,0)},Ge={number(r,t,e,n){return!Number.isInteger(r)||!Number.isSafeInteger(r)?new L(y.float,r):r>=0?new L(y.uint,r):new L(y.negint,r)},bigint(r,t,e,n){return r>=BigInt(0)?new L(y.uint,r):new L(y.negint,r)},Uint8Array(r,t,e,n){return new L(y.bytes,r)},string(r,t,e,n){return new L(y.string,r)},boolean(r,t,e,n){return r?je.true:je.false},null(r,t,e,n){return je.null},undefined(r,t,e,n){return je.undefined},ArrayBuffer(r,t,e,n){return new L(y.bytes,new Uint8Array(r))},DataView(r,t,e,n){return new L(y.bytes,new Uint8Array(r.buffer,r.byteOffset,r.byteLength))},Array(r,t,e,n){if(!r.length)return e.addBreakTokens===!0?[je.emptyArray,new L(y.break)]:je.emptyArray;n=wi.createCheck(n,r);let o=[],i=0;for(let s of r)o[i++]=va(s,e,n);return e.addBreakTokens?[new L(y.array,r.length),o,new L(y.break)]:[new L(y.array,r.length),o]},Object(r,t,e,n){let o=t!=="Object",i=o?r.keys():Object.keys(r),s=o?r.size:i.length;if(!s)return e.addBreakTokens===!0?[je.emptyMap,new L(y.break)]:je.emptyMap;n=wi.createCheck(n,r);let a=[],c=0;for(let f of i)a[c++]=[va(f,e,n),va(o?r.get(f):r[f],e,n)];return mm(a,e),e.addBreakTokens?[new L(y.map,s),a,new L(y.break)]:[new L(y.map,s),a]}};Ge.Map=Ge.Object;Ge.Buffer=Ge.Uint8Array;for(let r of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Ge[`${r}Array`]=Ge.DataView;function va(r,t={},e){let n=Bl(r),o=t&&t.typeEncoders&&t.typeEncoders[n]||Ge[n];if(typeof o=="function"){let s=o(r,n,t,e);if(s!=null)return s}let i=Ge[n];if(!i)throw new Error(`${ga} unsupported type: ${n}`);return i(r,n,t,e)}function mm(r,t){t.mapSorter&&r.sort(t.mapSorter)}var gm={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},xi=class{constructor(t,e={}){this._pos=0,this.data=t,this.options=e}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let t=this.data[this._pos],e=ie[t];if(e===void 0){let n=k[t];if(!n)throw new Error(`${$} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let o=t&31;e=n(this.data,this._pos,o,this.options)}return this._pos+=e.encodedLength,e}},Sn=Symbol.for("DONE"),bi=Symbol.for("BREAK");function ym(r,t,e){let n=[];for(let o=0;o<r.value;o++){let i=qr(t,e);if(i===bi){if(r.value===1/0)break;throw new Error(`${$} got unexpected break to lengthed array`)}if(i===Sn)throw new Error(`${$} found array but not enough entries (got ${o}, expected ${r.value})`);n[o]=i}return n}function wm(r,t,e){let n=e.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let s=0;s<r.value;s++){let a=qr(t,e);if(a===bi){if(r.value===1/0)break;throw new Error(`${$} got unexpected break to lengthed map`)}if(a===Sn)throw new Error(`${$} found map but not enough entries (got ${s} [no key], expected ${r.value})`);if(n!==!0&&typeof a!="string")throw new Error(`${$} non-string keys not supported (got ${typeof a})`);if(e.rejectDuplicateMapKeys===!0&&(n&&i.has(a)||!n&&a in o))throw new Error(`${$} found repeat map key "${a}"`);let c=qr(t,e);if(c===Sn)throw new Error(`${$} found map but not enough entries (got ${s} [no value], expected ${r.value})`);n?i.set(a,c):o[a]=c}return n?i:o}function qr(r,t){if(r.done())return Sn;let e=r.next();if(e.type===y.break)return bi;if(e.type.terminal)return e.value;if(e.type===y.array)return ym(e,r,t);if(e.type===y.map)return wm(e,r,t);if(e.type===y.tag){if(t.tags&&typeof t.tags[e.value]=="function"){let n=qr(r,t);return t.tags[e.value](n)}throw new Error(`${$} tag not supported (${e.value})`)}throw new Error("unsupported")}function If(r,t){if(!(r instanceof Uint8Array))throw new Error(`${$} data to decode must be a Uint8Array`);t=Object.assign({},gm,t);let e=t.tokenizer||new xi(r,t),n=qr(e,t);if(n===Sn)throw new Error(`${$} did not find any content to decode`);if(n===bi)throw new Error(`${$} got unexpected break`);return[n,r.subarray(e.pos())]}function Ea(r,t){let[e,n]=If(r,t);if(n.length>0)throw new Error(`${$} too many terminals, data makes no sense`);return e}var vm=Re("ipns:utils"),kf=Z("/ipns/");var Em=0,Bm=18;function Cf(r){let t;if(r.pubKey!=null)try{t=rl(r.pubKey)}catch(e){throw vm.error(e),e}if(t!=null)return t}function Tf(r){let t=Z("ipns-signature:");return Dt([t,r])}function cr(r){return"signatureV1"in r?ne.encode({value:Z(r.value),signatureV1:r.signatureV1,validityType:r.validityType,validity:Z(r.validity),sequence:r.sequence,ttl:r.ttl,pubKey:r.pubKey,signatureV2:r.signatureV2,data:r.data}):ne.encode({pubKey:r.pubKey,signatureV2:r.signatureV2,data:r.data})}function de(r){let t=ne.decode(r);if(t.sequence!=null&&(t.sequence=BigInt(t.sequence)),t.ttl!=null&&(t.ttl=BigInt(t.ttl)),t.signatureV2==null||t.data==null)throw new re("Missing data or signatureV2");let e=Nf(t.data),n=Am(e.Value),o=W(e.Validity);if(t.value!=null&&t.signatureV1!=null)return Sm(t),{value:n,validityType:ne.ValidityType.EOL,validity:o,sequence:e.Sequence,ttl:e.TTL,pubKey:t.pubKey,signatureV1:t.signatureV1,signatureV2:t.signatureV2,data:t.data};if(t.signatureV2!=null)return{value:n,validityType:ne.ValidityType.EOL,validity:o,sequence:e.Sequence,ttl:e.TTL,pubKey:t.pubKey,signatureV2:t.signatureV2,data:t.data};throw new Error("invalid record: does not include signatureV1 or signatureV2")}function In(r){return Dt([kf,r.bytes])}function Ne(r){let t=ge(r.slice(kf.length));if(!vi(t,Em)&&!vi(t,Bm))throw new fr("Multihash in IPNS key was not identity or sha2-256");return t}function Nf(r){let t=Ea(r);if(t.ValidityType===0)t.ValidityType=ne.ValidityType.EOL;else throw new Or("The validity type is unsupported");return Number.isInteger(t.Sequence)&&(t.Sequence=BigInt(t.Sequence)),Number.isInteger(t.TTL)&&(t.TTL=BigInt(t.TTL)),t}function Am(r){let t=W(r).trim();if(t.startsWith("/"))return t;try{return`/ipfs/${Q.decode(r).toV1().toString()}`}catch{}try{return`/ipfs/${Q.parse(t).toV1().toString()}`}catch{}throw new ai("Value must be a valid content path starting with /")}function Sm(r){if(r.data==null)throw new ci("Record data is missing");let t=Nf(r.data);if(!ct(t.Value,r.value??new Uint8Array(0)))throw new re('Field "value" did not match between protobuf and CBOR');if(!ct(t.Validity,r.validity??new Uint8Array(0)))throw new re('Field "validity" did not match between protobuf and CBOR');if(t.ValidityType!==r.validityType)throw new re('Field "validityType" did not match between protobuf and CBOR');if(t.Sequence!==r.sequence)throw new re('Field "sequence" did not match between protobuf and CBOR');if(t.TTL!==r.ttl)throw new re('Field "ttl" did not match between protobuf and CBOR')}function vi(r,t){return r.code===t}var Tv=Re("ipns"),Nv=60*60*1e9,km="/ipns/",Uv=km.length;var Uf=_n(ma(),1);var Ei=Re("ipns:validator"),Cm=1024*10,Tm=async(r,t)=>{let e=de(t),n;try{let o=Tf(e.data);n=await r.verify(o,e.signatureV2)}catch{n=!1}if(!n)throw Ei.error("record signature verification failed"),new re("Record signature verification failed");if(e.validityType===ne.ValidityType.EOL){if(Uf.default.fromString(e.validity).toDate().getTime()<Date.now())throw Ei.error("record has expired"),new ii("record has expired")}else if(e.validityType!=null)throw Ei.error("the validity type is unsupported"),new Or("The validity type is unsupported");Ei("ipns record for %s is valid",e.value)};async function Rf(r,t){if(t.byteLength>Cm)throw new si("The record is too large");let e=Ne(r),n;vi(e,0)&&(n=Yo(e));let o=de(t),i=Cf(o)??n;if(i==null)throw new vn("Could not extract public key from IPNS record or routing key");let s=In(i.toMultihash());if(!ct(r,s))throw new vn("Embedded public key did not match routing key");await Tm(i,t)}async function*kn(r){let t=/\r?\n/,e=new TextDecoder("utf8"),n="";for await(let o of r){typeof o=="string"&&(o=new TextEncoder().encode(o)),n+=e.decode(o,{stream:!0});let i=n.split(t);n=i.pop()??"";for(let s=0;s<i.length;s++)yield JSON.parse(i[s])}n+=e.decode(),n!==""&&(yield JSON.parse(n))}function he(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var Aa=_n(Lf(),1);var Tn=class extends Error{constructor(t){super(t),this.name="TimeoutError"}},Sa=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t}},Vf=r=>globalThis.DOMException===void 0?new Sa(r):new DOMException(r),Pf=r=>{let t=r.reason===void 0?Vf("This operation was aborted."):r.reason;return t instanceof Error?t:Vf(t)};function Ia(r,t){let{milliseconds:e,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout}}=t,s,c=new Promise((f,u)=>{if(typeof e!="number"||Math.sign(e)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${e}\``);if(t.signal){let{signal:d}=t;d.aborted&&u(Pf(d));let b=()=>{u(Pf(d))};d.addEventListener("abort",b,{once:!0}),r.finally(()=>{d.removeEventListener("abort",b)})}if(e===Number.POSITIVE_INFINITY){r.then(f,u);return}let l=new Tn;s=i.setTimeout.call(void 0,()=>{if(n){try{f(n())}catch(d){u(d)}return}typeof r.cancel=="function"&&r.cancel(),o===!1?f():o instanceof Error?u(o):(l.message=o??`Promise timed out after ${e} milliseconds`,u(l))},e),(async()=>{try{f(await r)}catch(d){u(d)}})()}).finally(()=>{c.clear()});return c.clear=()=>{i.clearTimeout.call(void 0,s),s=void 0},c}function ka(r,t,e){let n=0,o=r.length;for(;o>0;){let i=Math.trunc(o/2),s=n+i;e(r[s],t)<=0?(n=++s,o-=i+1):o=i}return n}var Nn=class{#t=[];enqueue(t,e){e={priority:0,...e};let n={priority:e.priority,run:t};if(this.size&&this.#t[this.size-1].priority>=e.priority){this.#t.push(n);return}let o=ka(this.#t,n,(i,s)=>s.priority-i.priority);this.#t.splice(o,0,n)}dequeue(){return this.#t.shift()?.run}filter(t){return this.#t.filter(e=>e.priority===t.priority).map(e=>e.run)}get size(){return this.#t.length}};var Un=class extends Aa.default{#t;#e;#i=0;#a;#c;#p=0;#n;#u;#r;#m;#o=0;#l;#s;#g;timeout;constructor(t){if(super(),t={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:Nn,...t},!(typeof t.intervalCap=="number"&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${t.intervalCap?.toString()??""}\` (${typeof t.intervalCap})`);if(t.interval===void 0||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${t.interval?.toString()??""}\` (${typeof t.interval})`);this.#t=t.carryoverConcurrencyCount,this.#e=t.intervalCap===Number.POSITIVE_INFINITY||t.interval===0,this.#a=t.intervalCap,this.#c=t.interval,this.#r=new t.queueClass,this.#m=t.queueClass,this.concurrency=t.concurrency,this.timeout=t.timeout,this.#g=t.throwOnTimeout===!0,this.#s=t.autoStart===!1}get#x(){return this.#e||this.#i<this.#a}get#b(){return this.#o<this.#l}#v(){this.#o--,this.#f(),this.emit("next")}#E(){this.#w(),this.#y(),this.#u=void 0}get#B(){let t=Date.now();if(this.#n===void 0){let e=this.#p-t;if(e<0)this.#i=this.#t?this.#o:0;else return this.#u===void 0&&(this.#u=setTimeout(()=>{this.#E()},e)),!0}return!1}#f(){if(this.#r.size===0)return this.#n&&clearInterval(this.#n),this.#n=void 0,this.emit("empty"),this.#o===0&&this.emit("idle"),!1;if(!this.#s){let t=!this.#B;if(this.#x&&this.#b){let e=this.#r.dequeue();return e?(this.emit("active"),e(),t&&this.#y(),!0):!1}}return!1}#y(){this.#e||this.#n!==void 0||(this.#n=setInterval(()=>{this.#w()},this.#c),this.#p=Date.now()+this.#c)}#w(){this.#i===0&&this.#o===0&&this.#n&&(clearInterval(this.#n),this.#n=void 0),this.#i=this.#t?this.#o:0,this.#d()}#d(){for(;this.#f(););}get concurrency(){return this.#l}set concurrency(t){if(!(typeof t=="number"&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);this.#l=t,this.#d()}async#A(t){return new Promise((e,n)=>{t.addEventListener("abort",()=>{n(t.reason)},{once:!0})})}async add(t,e={}){return e={timeout:this.timeout,throwOnTimeout:this.#g,...e},new Promise((n,o)=>{this.#r.enqueue(async()=>{this.#o++,this.#i++;try{e.signal?.throwIfAborted();let i=t({signal:e.signal});e.timeout&&(i=Ia(Promise.resolve(i),{milliseconds:e.timeout})),e.signal&&(i=Promise.race([i,this.#A(e.signal)]));let s=await i;n(s),this.emit("completed",s)}catch(i){if(i instanceof Tn&&!e.throwOnTimeout){n();return}o(i),this.emit("error",i)}finally{this.#v()}},e),this.emit("add"),this.#f()})}async addAll(t,e){return Promise.all(t.map(async n=>this.add(n,e)))}start(){return this.#s?(this.#s=!1,this.#d(),this):this}pause(){this.#s=!0}clear(){this.#r=new this.#m}async onEmpty(){this.#r.size!==0&&await this.#h("empty")}async onSizeLessThan(t){this.#r.size<t||await this.#h("next",()=>this.#r.size<t)}async onIdle(){this.#o===0&&this.#r.size===0||await this.#h("idle")}async#h(t,e){return new Promise(n=>{let o=()=>{e&&!e()||(this.off(t,o),n())};this.on(t,o)})}get size(){return this.#r.size}sizeBy(t){return this.#r.filter(t).length}get pending(){return this.#o}get isPaused(){return this.#s}};var zr=class extends Error{static name="InvalidRequestError";constructor(t="Invalid request"){super(t),this.name="InvalidRequestError"}},ur=class extends Error{static name="BadResponseError";constructor(t="Bad response"){super(t),this.name="BadResponseError"}};function Rm(r){return r[Symbol.asyncIterator]!=null}function _m(r){if(Rm(r))return(async()=>{for await(let t of r)return t})();for(let t of r)return t}var Ai=_m;function Lm(r){let[t,e]=r[Symbol.asyncIterator]!=null?[r[Symbol.asyncIterator](),Symbol.asyncIterator]:[r[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>t.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:t.next(),[e](){return this}}}var Ff=Lm;function Vm(r){return r[Symbol.asyncIterator]!=null}function Pm(r,t){let e=0;if(Vm(r))return async function*(){for await(let c of r)yield t(c,e++)}();let n=Ff(r),{value:o,done:i}=n.next();if(i===!0)return function*(){}();let s=t(o,e++);if(typeof s.then=="function")return async function*(){yield await s;for await(let c of n)yield t(c,e++)}();let a=t;return function*(){yield s;for(let c of n)yield a(c,e++)}()}var Si=Pm;var Of=Z("/ipns/");function Df(r){return ct(r.subarray(0,Of.byteLength),Of)}var Ii=class{client;constructor(t){this.client=t}async*findProviders(t,e={}){yield*Si(this.client.getProviders(t,e),n=>({id:n.ID,multiaddrs:n.Addrs??[]}))}async provide(){}async put(t,e,n){if(!Df(t))return;let o=Ne(t),i=Q.createV1(114,o),s=de(e);await this.client.putIPNS(i,s,n)}async get(t,e){if(!Df(t))throw new Rt("Not found");let n=Ne(t),o=Q.createV1(114,n);try{let i=await this.client.getIPNS(o,e);return cr(i)}catch(i){throw i.name==="BadResponseError"?new Rt("Not found"):i}}},ki=class{client;constructor(t){this.client=t}async findPeer(t,e={}){let n=await Ai(this.client.getPeers(t,e));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new Rt("Not found")}async*getClosestPeers(t,e={}){}};var Nt=Re("delegated-routing-v1-http-api-client"),Mf={concurrentRequests:4,timeout:3e4},Ci=class{started;httpQueue;shutDownController;clientUrl;timeout;contentRouting;peerRouting;filterAddrs;filterProtocols;constructor(t,e={}){this.started=!1,this.shutDownController=new AbortController,hr(1/0,this.shutDownController.signal),this.httpQueue=new Un({concurrency:e.concurrentRequests??Mf.concurrentRequests}),this.clientUrl=t instanceof URL?t:new URL(t),this.timeout=e.timeout??Mf.timeout,this.filterAddrs=e.filterAddrs,this.filterProtocols=e.filterProtocols,this.contentRouting=new Ii(this),this.peerRouting=new ki(this)}get[ja](){return this.contentRouting}get[Ga](){return this.peerRouting}isStarted(){return this.started}start(){this.started=!0}stop(){this.httpQueue.clear(),this.shutDownController.abort(),this.started=!1}async*getProviders(t,e={}){Nt("getProviders starts: %c",t);let n=AbortSignal.timeout(this.timeout),o=bn([this.shutDownController.signal,n,e.signal]);hr(1/0,n,o);let i=he(),s=he();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let a=new URL(`${this.clientUrl}routing/v1/providers/${t.toString()}`);this.#e(a,e.filterAddrs,e.filterProtocols);let f=await fetch(a,{headers:{Accept:"application/x-ndjson"},signal:o});if(f.status===404)throw new Rt("No matching records found");if(f.status===422)throw new zr("Request does not conform to schema or semantic constraints");if(f.body==null)throw new ur("Routing response had no body");if(f.headers.get("Content-Type")==="application/json"){let l=await f.json();for(let d of l.Providers){let b=this.#t(d);b!=null&&(yield b)}}else for await(let l of kn(oi(f.body))){let d=this.#t(l);d!=null&&(yield d)}}catch(a){Nt.error("getProviders errored:",a)}finally{o.clear(),s.resolve(),Nt("getProviders finished: %c",t)}}async*getPeers(t,e={}){Nt("getPeers starts: %c",t);let n=AbortSignal.timeout(this.timeout),o=bn([this.shutDownController.signal,n,e.signal]);hr(1/0,n,o);let i=he(),s=he();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let a=new URL(`${this.clientUrl}routing/v1/peers/${t.toCID().toString()}`);this.#e(a,e.filterAddrs,e.filterProtocols);let f=await fetch(a,{headers:{Accept:"application/x-ndjson"},signal:o});if(f.status===404)throw new Rt("No matching records found");if(f.status===422)throw new zr("Request does not conform to schema or semantic constraints");if(f.body==null)throw new ur("Routing response had no body");if(f.headers.get("Content-Type")==="application/json"){let l=await f.json();for(let d of l.Peers){let b=this.#t(d);b!=null&&(yield b)}}else for await(let l of kn(oi(f.body))){let d=this.#t(l);d!=null&&(yield d)}}catch(a){Nt.error("getPeers errored:",a)}finally{o.clear(),s.resolve(),Nt("getPeers finished: %c",t)}}async getIPNS(t,e={}){Nt("getIPNS starts: %s",t);let n=AbortSignal.timeout(this.timeout),o=bn([this.shutDownController.signal,n,e.signal]);hr(1/0,n,o);let i=he(),s=he();this.httpQueue.add(async()=>(i.resolve(),s.promise));let a=`${this.clientUrl}routing/v1/ipns/${t}`;try{await i.promise;let f=await fetch(a,{headers:{Accept:"application/vnd.ipfs.ipns-record"},signal:o});if(Nt("getIPNS GET %s %d",a,f.status),f.status===404)throw new Rt("No matching records found");if(f.status===422)throw new zr("Request does not conform to schema or semantic constraints");if(f.body==null)throw new ur("GET ipns response had no body");let u=await f.arrayBuffer(),l=new Uint8Array(u,0,u.byteLength);return e.validate!==!1&&await Rf(In(t.multihash),l),de(l)}catch(c){throw Nt.error("getIPNS GET %s error:",a,c),c}finally{o.clear(),s.resolve(),Nt("getIPNS finished: %s",t)}}async putIPNS(t,e,n={}){Nt("putIPNS starts: %c",t);let o=AbortSignal.timeout(this.timeout),i=bn([this.shutDownController.signal,o,n.signal]);hr(1/0,o,i);let s=he(),a=he();this.httpQueue.add(async()=>(s.resolve(),a.promise));let c=`${this.clientUrl}routing/v1/ipns/${t}`;try{await s.promise;let f=cr(e),l=await fetch(c,{method:"PUT",headers:{"Content-Type":"application/vnd.ipfs.ipns-record"},body:f,signal:i});if(Nt("putIPNS PUT %s %d",c,l.status),l.status!==200)throw new ur("PUT ipns response had status other than 200")}catch(f){throw Nt.error("putIPNS PUT %s error:",c,f.stack),f}finally{i.clear(),a.resolve(),Nt("putIPNS finished: %c",t)}}#t(t){try{let e=[],n=t.Addrs?.map(sr)??[];return t.Protocols!=null&&e.push(...t.Protocols),t.Protocol!=null&&(e.push(t.Protocol),delete t.Protocol),{...t,Schema:"peer",ID:il(t.ID),Addrs:n,Protocols:e}}catch(e){Nt.error("could not conform record to peer schema",e)}}#e(t,e,n){if(e!=null||this.filterAddrs!=null){let o=e?.join(",")??this.filterAddrs?.join(",")??"";o!==""&&t.searchParams.set("filter-addrs",o)}if(n!=null||this.filterProtocols!=null){let o=n?.join(",")??this.filterProtocols?.join(",")??"";o!==""&&t.searchParams.set("filter-protocols",o)}}};function $f(r,t={}){return new Ci(new URL(r),t)}function Hf(){return{filterProtocols:["unknown","transport-bitswap","transport-ipfs-gateway-http"],filterAddrs:["https","webtransport","webrtc","webrtc-direct","wss"]}}var Kf=Z("/ipns/");function qf(r){return ct(r.subarray(0,Kf.byteLength),Kf)}var Ca=class{client;constructor(t,e={}){this.client=$f(t,e)}async provide(t,e){}async*findProviders(t,e){yield*Si(this.client.getProviders(t,e),n=>({id:n.ID,multiaddrs:n.Addrs,protocols:n.Protocols}))}async put(t,e,n){if(!qf(t))return;let o=Ne(t),i=Q.createV1(114,o),s=de(e);await this.client.putIPNS(i,s,n)}async get(t,e){if(!qf(t))throw new Rt("Not found");let n=Ne(t),o=Q.createV1(114,n);try{let i=await this.client.getIPNS(o,e);return cr(i)}catch(i){throw i.name==="BadResponseError"?new Rt("Not found"):i}}async findPeer(t,e){let n=await Ai(this.client.getPeers(t,e));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new Rt("Not found")}async*getClosestPeers(t,e){}};function zf(r,t){let e=t??Hf();return new Ca(new URL(r),e)}var jf="[a-fA-F\\d:]",Ze=r=>r&&r.includeBoundaries?`(?:(?<=\\s|^)(?=${jf})|(?<=${jf})(?=\\s|$))`:"",se="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",ut="[a-fA-F\\d]{1,4}",Ti=`
7
+ `)}`:`${e} :`}};Au=je;L.Constructed=Au;je.NAME="CONSTRUCTED";var bo=class extends St{fromBER(t,e,n){return e}toBER(t){return re}};bo.override="EndOfContentValueBlock";var Su,vo=class extends xt{constructor(t={}){super(t,bo),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};Su=vo;L.EndOfContent=Su;vo.NAME=fn;var Iu,Lr=class extends xt{constructor(t={}){super(t,St),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(t,e,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,e+n>t.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):e+n}toBER(t,e){let n=new ArrayBuffer(2);if(!t){let o=new Uint8Array(n);o[0]=5,o[1]=0}return e&&e.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}};Iu=Lr;L.Null=Iu;Lr.NAME="NULL";var Eo=class extends Te(St){constructor({value:t,...e}={}){super(e),e.valueHex?this.valueHexView=j.BufferSourceConverter.toUint8Array(e.valueHex):this.valueHexView=new Uint8Array(1),t&&(this.value=t)}get value(){for(let t of this.valueHexView)if(t>0)return!0;return!1}set value(t){this.valueHexView[0]=t?255:0}fromBER(t,e,n){let o=j.BufferSourceConverter.toUint8Array(t);return ke(this,o,e,n)?(this.valueHexView=o.subarray(e,e+n),n>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,ea.call(this),this.blockLength=n,e+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};Eo.NAME="BooleanValueBlock";var ku,Bo=class extends xt{constructor(t={}){super(t,Eo),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(t){this.valueBlock.value=t}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};ku=Bo;L.Boolean=ku;Bo.NAME="BOOLEAN";var Ao=class extends Te(fe){constructor({isConstructed:t=!1,...e}={}){super(e),this.isConstructed=t}fromBER(t,e,n){let o=0;if(this.isConstructed){if(this.isHexOnly=!1,o=fe.prototype.fromBER.call(this,t,e,n),o===-1)return o;for(let i=0;i<this.value.length;i++){let s=this.value[i].constructor.NAME;if(s===fn){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(s!==bu)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,o=super.fromBER(t,e,n),this.blockLength=n;return o}toBER(t,e){return this.isConstructed?fe.prototype.toBER.call(this,t,e):t?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};Ao.NAME="OctetStringValueBlock";var Tu,So=class r extends xt{constructor({idBlock:t={},lenBlock:e={},...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,...t},lenBlock:{...e,isIndefiniteForm:!!n.isIndefiniteForm},...n},Ao),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(t,e,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),e;if(!this.valueBlock.isConstructed){let i=(t instanceof ArrayBuffer?new Uint8Array(t):t).subarray(e,e+n);try{if(i.byteLength){let s=Qo(i,0,i.byteLength);s.offset!==-1&&s.offset===n&&(this.valueBlock.value=[s.result])}}catch{}}return super.fromBER(t,e,n)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?je.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${j.Convert.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;let t=[];for(let e of this.valueBlock.value)e instanceof r&&t.push(e.valueBlock.valueHexView);return j.BufferSourceConverter.concat(t)}};Tu=So;L.OctetString=Tu;So.NAME=bu;var Io=class extends Te(fe){constructor({unusedBits:t=0,isConstructed:e=!1,...n}={}){super(n),this.unusedBits=t,this.isConstructed=e,this.blockLength=this.valueHexView.byteLength}fromBER(t,e,n){if(!n)return e;let o=-1;if(this.isConstructed){if(o=fe.prototype.fromBER.call(this,t,e,n),o===-1)return o;for(let a of this.value){let c=a.constructor.NAME;if(c===fn){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==vu)return this.error="BIT STRING may consists of BIT STRINGs only",-1;let f=a.valueBlock;if(this.unusedBits>0&&f.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=f.unusedBits}return o}let i=j.BufferSourceConverter.toUint8Array(t);if(!ke(this,i,e,n))return-1;let s=i.subarray(e,e+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=Qo(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,e+n}toBER(t,e){if(this.isConstructed)return fe.prototype.toBER.call(this,t,e);if(t)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return re;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}}};Io.NAME="BitStringValueBlock";var Cu,Vr=class extends xt{constructor({idBlock:t={},lenBlock:e={},...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,...t},lenBlock:{...e,isIndefiniteForm:!!n.isIndefiniteForm},...n},Io),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(t,e,n){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(t,e,n)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return je.prototype.onAsciiEncoding.call(this);{let t=[],e=this.valueBlock.valueHexView;for(let o of e)t.push(o.toString(2).padStart(8,"0"));let n=t.join("");return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}};Cu=Vr;L.BitString=Cu;Vr.NAME=vu;var Nu;function Up(r,t){let e=new Uint8Array([0]),n=new Uint8Array(r),o=new Uint8Array(t),i=n.slice(0),s=i.length-1,a=o.slice(0),c=a.length-1,f=0,u=c<s?s:c,l=0;for(let h=u;h>=0;h--,l++){switch(!0){case l<a.length:f=i[s-l]+a[c-l]+e[0];break;default:f=i[s-l]+e[0]}switch(e[0]=f/10,!0){case l>=i.length:i=ho(new Uint8Array([f%10]),i);break;default:i[s-l]=f%10}}return e[0]>0&&(i=ho(e,i)),i}function wu(r){if(r>=un.length)for(let t=un.length;t<=r;t++){let e=new Uint8Array([0]),n=un[t-1].slice(0);for(let o=n.length-1;o>=0;o--){let i=new Uint8Array([(n[o]<<1)+e[0]]);e[0]=i[0]/10,n[o]=i[0]%10}e[0]>0&&(n=ho(e,n)),un.push(n)}return un[r]}function Rp(r,t){let e=0,n=new Uint8Array(r),o=new Uint8Array(t),i=n.slice(0),s=i.length-1,a=o.slice(0),c=a.length-1,f,u=0;for(let l=c;l>=0;l--,u++)switch(f=i[s-u]-a[c-u]-e,!0){case f<0:e=1,i[s-u]=f+10;break;default:e=0,i[s-u]=f}if(e>0)for(let l=s-c+1;l>=0;l--,u++)if(f=i[s-u]-e,f<0)e=1,i[s-u]=f+10;else{e=0,i[s-u]=f;break}return i.slice()}var hn=class extends Te(St){constructor({value:t,...e}={}){super(e),this._valueDec=0,e.valueHex&&this.setValueHex(),t!==void 0&&(this.valueDec=t)}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=ea.call(this)))}set valueDec(t){this._valueDec=t,this.isHexOnly=!1,this.valueHexView=new Uint8Array(gu(t))}get valueDec(){return this._valueDec}fromDER(t,e,n,o=0){let i=this.fromBER(t,e,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(t=!1){let e=this.valueHexView;switch(!0){case(e[0]&128)!==0:{let n=new Uint8Array(this.valueHexView.length+1);n[0]=0,n.set(e,1),this.valueHexView=n}break;case(e[0]===0&&(e[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(t)}fromBER(t,e,n){let o=super.fromBER(t,e,n);return o===-1||this.setValueHex(),o}toBER(t){return t?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){let t=this.valueHexView.length*8-1,e=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 f=0;f<8;f++){if((o&1)===1)switch(n){case t:e=Rp(wu(n),e),s="-";break;default:e=Up(e,wu(n))}n++,o>>=1}}for(let c=0;c<e.length;c++)e[c]&&(a=!0),a&&(s+=xu.charAt(e[c]));return a===!1&&(s+=xu.charAt(0)),s}};Nu=hn;hn.NAME="IntegerValueBlock";Object.defineProperty(Nu.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var Uu,wt=class r extends xt{constructor(t={}){super(t,hn),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return po(),BigInt(this.valueBlock.toString())}static fromBigInt(t){po();let e=BigInt(t),n=new ln,o=e.toString(16).replace(/^-/,""),i=new Uint8Array(j.Convert.FromHex(o));if(e<0){let a=new Uint8Array(i.length+(i[0]&128?1:0));a[0]|=128;let f=BigInt(`0x${j.Convert.ToHex(a)}`)+e,u=j.BufferSourceConverter.toUint8Array(j.Convert.FromHex(f.toString(16)));u[0]|=128,n.write(u)}else i[0]&128&&n.write(new Uint8Array([0])),n.write(i);return new r({valueHex:n.final()})}convertToDER(){let t=new r({valueHex:this.valueBlock.valueHexView});return t.valueBlock.toDER(),t}convertFromDER(){return new r({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}};Uu=wt;L.Integer=Uu;wt.NAME="INTEGER";var Ru,ko=class extends wt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};Ru=ko;L.Enumerated=Ru;ko.NAME="ENUMERATED";var dn=class extends Te(St){constructor({valueDec:t=-1,isFirstSid:e=!1,...n}={}){super(n),this.valueDec=t,this.isFirstSid=e}fromBER(t,e,n){if(!n)return e;let o=j.BufferSourceConverter.toUint8Array(t);if(!ke(this,o,e,n))return-1;let i=o.subarray(e,e+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=cr(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),e+this.blockLength)}set valueBigInt(t){po();let e=BigInt(t).toString(2);for(;e.length%7;)e="0"+e;let n=new Uint8Array(e.length/7);for(let o=0;o<n.length;o++)n[o]=parseInt(e.slice(o*7,o*7+7),2)+(o+1<n.length?128:0);this.fromBER(n.buffer,0,n.length)}toBER(t){if(this.isHexOnly){if(t)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 e=ze(this.valueDec,7);if(e.byteLength===0)return this.error="Error during encoding SID value",re;let n=new Uint8Array(e.byteLength);if(!t){let o=new Uint8Array(e),i=e.byteLength-1;for(let s=0;s<i;s++)n[s]=o[s]|128;n[i]=o[i]}return n}toString(){let t="";if(this.isHexOnly)t=j.Convert.ToHex(this.valueHexView);else if(this.isFirstSid){let e=this.valueDec;this.valueDec<=39?t="0.":this.valueDec<=79?(t="1.",e-=40):(t="2.",e-=80),t+=e.toString()}else t=this.valueDec.toString();return t}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}};dn.NAME="sidBlock";var To=class extends St{constructor({value:t=Fr,...e}={}){super(e),this.value=[],t&&this.fromString(t)}fromBER(t,e,n){let o=e;for(;n>0;){let i=new dn;if(o=i.fromBER(t,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(t){let e=[];for(let n=0;n<this.value.length;n++){let o=this.value[n].toBER(t);if(o.byteLength===0)return this.error=this.value[n].error,re;e.push(o)}return ra(e)}fromString(t){this.value=[];let e=0,n=0,o="",i=!1;do if(n=t.indexOf(".",e),n===-1?o=t.substring(e):o=t.substring(e,n),e=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 dn;if(o>Number.MAX_SAFE_INTEGER){po();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 t="",e=!1;for(let n=0;n<this.value.length;n++){e=this.value[n].isHexOnly;let o=this.value[n].toString();n!==0&&(t=`${t}.`),e?(o=`{${o}}`,this.value[n].isFirstSid?t=`2.{${o} - 80}`:t+=o):t+=o}return t}toJSON(){let t={...super.toJSON(),value:this.toString(),sidArray:[]};for(let e=0;e<this.value.length;e++)t.sidArray.push(this.value[e].toJSON());return t}};To.NAME="ObjectIdentifierValueBlock";var _u,Pr=class extends xt{constructor(t={}){super(t,To),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}getValue(){return this.valueBlock.toString()}setValue(t){this.valueBlock.fromString(t)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};_u=Pr;L.ObjectIdentifier=_u;Pr.NAME="OBJECT IDENTIFIER";var pn=class extends Te(Ae){constructor({valueDec:t=0,...e}={}){super(e),this.valueDec=t}fromBER(t,e,n){if(n===0)return e;let o=j.BufferSourceConverter.toUint8Array(t);if(!ke(this,o,e,n))return-1;let i=o.subarray(e,e+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=cr(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),e+this.blockLength)}toBER(t){if(this.isHexOnly){if(t)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 e=ze(this.valueDec,7);if(e.byteLength===0)return this.error="Error during encoding SID value",re;let n=new Uint8Array(e.byteLength);if(!t){let o=new Uint8Array(e),i=e.byteLength-1;for(let s=0;s<i;s++)n[s]=o[s]|128;n[i]=o[i]}return n.buffer}toString(){let t="";return this.isHexOnly?t=j.Convert.ToHex(this.valueHexView):t=this.valueDec.toString(),t}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}};pn.NAME="relativeSidBlock";var Co=class extends St{constructor({value:t=Fr,...e}={}){super(e),this.value=[],t&&this.fromString(t)}fromBER(t,e,n){let o=e;for(;n>0;){let i=new pn;if(o=i.fromBER(t,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(t,e){let n=[];for(let o=0;o<this.value.length;o++){let i=this.value[o].toBER(t);if(i.byteLength===0)return this.error=this.value[o].error,re;n.push(i)}return ra(n)}fromString(t){this.value=[];let e=0,n=0,o="";do{n=t.indexOf(".",e),n===-1?o=t.substring(e):o=t.substring(e,n),e=n+1;let i=new pn;if(i.valueDec=parseInt(o,10),isNaN(i.valueDec))return!0;this.value.push(i)}while(n!==-1);return!0}toString(){let t="",e=!1;for(let n=0;n<this.value.length;n++){e=this.value[n].isHexOnly;let o=this.value[n].toString();n!==0&&(t=`${t}.`),e&&(o=`{${o}}`),t+=o}return t}toJSON(){let t={...super.toJSON(),value:this.toString(),sidArray:[]};for(let e=0;e<this.value.length;e++)t.sidArray.push(this.value[e].toJSON());return t}};Co.NAME="RelativeObjectIdentifierValueBlock";var Lu,No=class extends xt{constructor(t={}){super(t,Co),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}getValue(){return this.valueBlock.toString()}setValue(t){this.valueBlock.fromString(t)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};Lu=No;L.RelativeObjectIdentifier=Lu;No.NAME="RelativeObjectIdentifier";var Vu,Se=class extends je{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};Vu=Se;L.Sequence=Vu;Se.NAME="SEQUENCE";var Pu,Uo=class extends je{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};Pu=Uo;L.Set=Pu;Uo.NAME="SET";var Ro=class extends Te(St){constructor({...t}={}){super(t),this.isHexOnly=!0,this.value=Fr}toJSON(){return{...super.toJSON(),value:this.value}}};Ro.NAME="StringValueBlock";var _o=class extends Ro{};_o.NAME="SimpleStringValueBlock";var Ct=class extends yo{constructor({...t}={}){super(t,_o)}fromBuffer(t){this.valueBlock.value=String.fromCharCode.apply(null,j.BufferSourceConverter.toUint8Array(t))}fromString(t){let e=t.length,n=this.valueBlock.valueHexView=new Uint8Array(e);for(let o=0;o<e;o++)n[o]=t.charCodeAt(o);this.valueBlock.value=t}};Ct.NAME="SIMPLE STRING";var Lo=class extends Ct{fromBuffer(t){this.valueBlock.valueHexView=j.BufferSourceConverter.toUint8Array(t);try{this.valueBlock.value=j.Convert.ToUtf8String(t)}catch(e){this.warnings.push(`Error during "decodeURIComponent": ${e}, using raw string`),this.valueBlock.value=j.Convert.ToBinary(t)}}fromString(t){this.valueBlock.valueHexView=new Uint8Array(j.Convert.FromUtf8String(t)),this.valueBlock.value=t}};Lo.NAME="Utf8StringValueBlock";var Fu,Ie=class extends Lo{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};Fu=Ie;L.Utf8String=Fu;Ie.NAME="UTF8String";var Vo=class extends Ct{fromBuffer(t){this.valueBlock.value=j.Convert.ToUtf16String(t),this.valueBlock.valueHexView=j.BufferSourceConverter.toUint8Array(t)}fromString(t){this.valueBlock.value=t,this.valueBlock.valueHexView=new Uint8Array(j.Convert.FromUtf16String(t))}};Vo.NAME="BmpStringValueBlock";var Du,Po=class extends Vo{constructor({...t}={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};Du=Po;L.BmpString=Du;Po.NAME="BMPString";var Fo=class extends Ct{fromBuffer(t){let e=ArrayBuffer.isView(t)?t.slice().buffer:t.slice(0),n=new Uint8Array(e);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(e))}fromString(t){let e=t.length,n=this.valueBlock.valueHexView=new Uint8Array(e*4);for(let o=0;o<e;o++){let i=ze(t.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=t}};Fo.NAME="UniversalStringValueBlock";var Ou,Do=class extends Fo{constructor({...t}={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};Ou=Do;L.UniversalString=Ou;Do.NAME="UniversalString";var Mu,Oo=class extends Ct{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};Mu=Oo;L.NumericString=Mu;Oo.NAME="NumericString";var Hu,Mo=class extends Ct{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};Hu=Mo;L.PrintableString=Hu;Mo.NAME="PrintableString";var $u,Ho=class extends Ct{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};$u=Ho;L.TeletexString=$u;Ho.NAME="TeletexString";var Ku,$o=class extends Ct{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};Ku=$o;L.VideotexString=Ku;$o.NAME="VideotexString";var qu,Ko=class extends Ct{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};qu=Ko;L.IA5String=qu;Ko.NAME="IA5String";var zu,qo=class extends Ct{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};zu=qo;L.GraphicString=zu;qo.NAME="GraphicString";var ju,mn=class extends Ct{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};ju=mn;L.VisibleString=ju;mn.NAME="VisibleString";var Gu,zo=class extends Ct{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};Gu=zo;L.GeneralString=Gu;zo.NAME="GeneralString";var Wu,jo=class extends Ct{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};Wu=jo;L.CharacterString=Wu;jo.NAME="CharacterString";var Zu,gn=class extends mn{constructor({value:t,valueDate:e,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,t){this.fromString(t),this.valueBlock.valueHexView=new Uint8Array(t.length);for(let o=0;o<t.length;o++)this.valueBlock.valueHexView[o]=t.charCodeAt(o)}e&&(this.fromDate(e),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(t){this.fromString(String.fromCharCode.apply(null,j.BufferSourceConverter.toUint8Array(t)))}toBuffer(){let t=this.toString(),e=new ArrayBuffer(t.length),n=new Uint8Array(e);for(let o=0;o<t.length;o++)n[o]=t.charCodeAt(o);return e}fromDate(t){this.year=t.getUTCFullYear(),this.month=t.getUTCMonth()+1,this.day=t.getUTCDate(),this.hour=t.getUTCHours(),this.minute=t.getUTCMinutes(),this.second=t.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(t){let n=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(t);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(t="iso"){if(t==="iso"){let e=new Array(7);return e[0]=Ft(this.year<2e3?this.year-1900:this.year-2e3,2),e[1]=Ft(this.month,2),e[2]=Ft(this.day,2),e[3]=Ft(this.hour,2),e[4]=Ft(this.minute,2),e[5]=Ft(this.second,2),e[6]="Z",e.join("")}return super.toString(t)}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}}};Zu=gn;L.UTCTime=Zu;gn.NAME="UTCTime";var Yu,Go=class extends gn{constructor(t={}){var e;super(t),(e=this.millisecond)!==null&&e!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(t){super.fromDate(t),this.millisecond=t.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(t){let e=!1,n="",o="",i=0,s,a=0,c=0;if(t[t.length-1]==="Z")n=t.substring(0,t.length-1),e=!0;else{let l=new Number(t[t.length-1]);if(isNaN(l.valueOf()))throw new Error("Wrong input string for conversion");n=t}if(e){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 l=1,h=n.indexOf("+"),g="";if(h===-1&&(h=n.indexOf("-"),l=-1),h!==-1){if(g=n.substring(h+1),n=n.substring(0,h),g.length!==2&&g.length!==4)throw new Error("Wrong input string for conversion");let E=parseInt(g.substring(0,2),10);if(isNaN(E.valueOf()))throw new Error("Wrong input string for conversion");if(a=l*E,g.length===4){if(E=parseInt(g.substring(2,4),10),isNaN(E.valueOf()))throw new Error("Wrong input string for conversion");c=l*E}}}let f=n.indexOf(".");if(f===-1&&(f=n.indexOf(",")),f!==-1){let l=new Number(`0${n.substring(f)}`);if(isNaN(l.valueOf()))throw new Error("Wrong input string for conversion");i=l.valueOf(),o=n.substring(0,f)}else o=n;switch(!0){case o.length===8:if(s=/(\d{4})(\d{2})(\d{2})/ig,f!==-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,f!==-1){let l=60*i;this.minute=Math.floor(l),l=60*(l-this.minute),this.second=Math.floor(l),l=1e3*(l-this.second),this.millisecond=Math.floor(l)}break;case o.length===12:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=60*i;this.second=Math.floor(l),l=1e3*(l-this.second),this.millisecond=Math.floor(l)}break;case o.length===14:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=1e3*i;this.millisecond=Math.floor(l)}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 l=1;l<u.length;l++)switch(l){case 1:this.year=parseInt(u[l],10);break;case 2:this.month=parseInt(u[l],10);break;case 3:this.day=parseInt(u[l],10);break;case 4:this.hour=parseInt(u[l],10)+a;break;case 5:this.minute=parseInt(u[l],10)+c;break;case 6:this.second=parseInt(u[l],10);break;default:throw new Error("Wrong input string for conversion")}if(e===!1){let l=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=l.getUTCFullYear(),this.month=l.getUTCMonth(),this.day=l.getUTCDay(),this.hour=l.getUTCHours(),this.minute=l.getUTCMinutes(),this.second=l.getUTCSeconds(),this.millisecond=l.getUTCMilliseconds()}}toString(t="iso"){if(t==="iso"){let e=[];return e.push(Ft(this.year,4)),e.push(Ft(this.month,2)),e.push(Ft(this.day,2)),e.push(Ft(this.hour,2)),e.push(Ft(this.minute,2)),e.push(Ft(this.second,2)),this.millisecond!==0&&(e.push("."),e.push(Ft(this.millisecond,3))),e.push("Z"),e.join("")}return super.toString(t)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};Yu=Go;L.GeneralizedTime=Yu;Go.NAME="GeneralizedTime";var Ju,Wo=class extends Ie{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};Ju=Wo;L.DATE=Ju;Wo.NAME="DATE";var Xu,Zo=class extends Ie{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};Xu=Zo;L.TimeOfDay=Xu;Zo.NAME="TimeOfDay";var Qu,Yo=class extends Ie{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};Qu=Yo;L.DateTime=Qu;Yo.NAME="DateTime";var tl,Jo=class extends Ie{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};tl=Jo;L.Duration=tl;Jo.NAME="Duration";var el,Xo=class extends Ie{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};el=Xo;L.TIME=el;Xo.NAME="TIME";function nt(r,t="utf8"){let e=no[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var yn=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},ti=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var rl={get(r=globalThis){let t=r.crypto;if(t?.subtle==null)throw new ti("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 t}};var Ge=rl;async function nl(r){let t=await Ge.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:r,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),e=await Lp(t);return{privateKey:e[0],publicKey:e[1]}}async function ol(r,t){let e=await Ge.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await Ge.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},e,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(n,0,n.byteLength)}async function il(r,t,e){let n=await Ge.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return Ge.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,e instanceof Uint8Array?e:e.subarray())}async function Lp(r){if(r.privateKey==null||r.publicKey==null)throw new Et("Private and public key are required");return Promise.all([Ge.get().subtle.exportKey("jwk",r.privateKey),Ge.get().subtle.exportKey("jwk",r.publicKey)])}function ia(r){if(r.kty!=="RSA")throw new Et("invalid key type");if(r.n==null)throw new Et("invalid key modulus");return W(r.n,"base64url").length*8}var Dr=class{type="RSA";_key;_raw;_multihash;constructor(t,e){this._key=t,this._multihash=e}get raw(){return this._raw==null&&(this._raw=xn.jwkToPkix(this._key)),this._raw}toMultihash(){return this._multihash}toCID(){return X.createV1(114,this._multihash)}toString(){return rt.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ct(this.raw,t.raw)}verify(t,e){return il(this._key,e,t)}},wn=class{type="RSA";_key;_raw;publicKey;constructor(t,e){this._key=t,this.publicKey=e}get raw(){return this._raw==null&&(this._raw=xn.jwkToPkcs1(this._key)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ct(this.raw,t.raw)}sign(t){return ol(this._key,t)}};var ei=8192,sa=18;function sl(r){let{result:t}=oa(r),e=t.valueBlock.value;return{n:he(e[1]),e:he(e[2]),d:he(e[3]),p:he(e[4]),q:he(e[5]),dp:he(e[6]),dq:he(e[7]),qi:he(e[8]),kty:"RSA",alg:"RS256"}}function Vp(r){if(r.n==null||r.e==null||r.d==null||r.p==null||r.q==null||r.dp==null||r.dq==null||r.qi==null)throw new Et("JWK was missing components");let e=new Se({value:[new wt({value:0}),wt.fromBigInt(de(W(r.n,"base64url"))),wt.fromBigInt(de(W(r.e,"base64url"))),wt.fromBigInt(de(W(r.d,"base64url"))),wt.fromBigInt(de(W(r.p,"base64url"))),wt.fromBigInt(de(W(r.q,"base64url"))),wt.fromBigInt(de(W(r.dp,"base64url"))),wt.fromBigInt(de(W(r.dq,"base64url"))),wt.fromBigInt(de(W(r.qi,"base64url")))]}).toBER();return new Uint8Array(e,0,e.byteLength)}function al(r){let{result:t}=oa(r),e=t.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:he(e[0]),e:he(e[1])}}function aa(r){if(r.n==null||r.e==null)throw new Et("JWK was missing components");let e=new Se({value:[new Se({value:[new Pr({value:"1.2.840.113549.1.1.1"}),new Lr]}),new Vr({valueHex:new Se({value:[wt.fromBigInt(de(W(r.n,"base64url"))),wt.fromBigInt(de(W(r.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(e,0,e.byteLength)}function he(r){let t=r.valueBlock.valueHexView;for(;t[0]===0;)t=t.subarray(1);return nt(t,"base64url")}function de(r){let t=[];return r.forEach(function(e){let n=e.toString(16);n.length%2>0&&(n=`0${n}`),t.push(n)}),BigInt("0x"+t.join(""))}function cl(r){let t=sl(r);return ul(t)}function ca(r){let t=al(r);if(ia(t)>ei)throw new pr("Key size is too large");let e=uo(le.encode({Type:ft.RSA,Data:r})),n=Wt(sa,e);return new Dr(t,n)}function ul(r){if(ia(r)>ei)throw new Et("Key size is too large");let t=fl(r),e=uo(le.encode({Type:ft.RSA,Data:aa(t.publicKey)})),n=Wt(sa,e);return new wn(t.privateKey,new Dr(t.publicKey,n))}async function ll(r){if(r>ei)throw new Et("Key size is too large");let t=await nl(r),e=uo(le.encode({Type:ft.RSA,Data:aa(t.publicKey)})),n=Wt(sa,e);return new wn(t.privateKey,new Dr(t.publicKey,n))}function fl(r){if(r==null)throw new Et("Missing key parameter");return{privateKey:r,publicKey:{kty:r.kty,n:r.n,e:r.e}}}var Pp=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),We=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ze=new Uint32Array(64),ua=class extends Ir{constructor(){super(64,32,8,!1),this.A=We[0]|0,this.B=We[1]|0,this.C=We[2]|0,this.D=We[3]|0,this.E=We[4]|0,this.F=We[5]|0,this.G=We[6]|0,this.H=We[7]|0}get(){let{A:t,B:e,C:n,D:o,E:i,F:s,G:a,H:c}=this;return[t,e,n,o,i,s,a,c]}set(t,e,n,o,i,s,a,c){this.A=t|0,this.B=e|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(t,e){for(let l=0;l<16;l++,e+=4)Ze[l]=t.getUint32(e,!1);for(let l=16;l<64;l++){let h=Ze[l-15],g=Ze[l-2],E=Yt(h,7)^Yt(h,18)^h>>>3,y=Yt(g,17)^Yt(g,19)^g>>>10;Ze[l]=y+Ze[l-7]+E+Ze[l-16]|0}let{A:n,B:o,C:i,D:s,E:a,F:c,G:f,H:u}=this;for(let l=0;l<64;l++){let h=Yt(a,6)^Yt(a,11)^Yt(a,25),g=u+h+Nc(a,c,f)+Pp[l]+Ze[l]|0,y=(Yt(n,2)^Yt(n,13)^Yt(n,22))+Uc(n,o,i)|0;u=f,f=c,c=a,a=s+g|0,s=i,i=o,o=n,n=g+y|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(n,o,i,s,a,c,f,u)}roundClean(){Ze.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var hl=$n(()=>new ua);var ri=class extends Sr{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,kc(t);let n=Qr(e);if(this.iHash=t.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?t.create().update(n).digest():n);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=t.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),i.fill(0)}update(t){return Ar(this),this.iHash.update(t),this}digestInto(t){Ar(this),Br(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:e,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:a}=this;return t=t,t.finished=o,t.destroyed=i,t.blockLen=s,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},la=(r,t,e)=>new ri(r,t).update(e).digest();la.create=(r,t)=>new ri(r,t);function dl(r){r.lowS!==void 0&&Jt("lowS",r.lowS),r.prehash!==void 0&&Jt("prehash",r.prehash)}function Fp(r){let t=rn(r);ue(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:e,Fp:n,a:o}=t;if(e){if(!n.eql(o,n.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...t})}var{bytesToNumberBE:Dp,hexToBytes:Op}=Gn,Ce={Err:class extends Error{constructor(t=""){super(t)}},_tlv:{encode:(r,t)=>{let{Err:e}=Ce;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length&1)throw new e("tlv.encode: unpadded data");let n=t.length/2,o=tr(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let i=n>127?tr(o.length/2|128):"";return tr(r)+i+o+t},decode(r,t){let{Err:e}=Ce,n=0;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length<2||t[n++]!==r)throw new e("tlv.decode: wrong tlv");let o=t[n++],i=!!(o&128),s=0;if(!i)s=o;else{let c=o&127;if(!c)throw new e("tlv.decode(long): indefinite length not supported");if(c>4)throw new e("tlv.decode(long): byte length is too big");let f=t.subarray(n,n+c);if(f.length!==c)throw new e("tlv.decode: length bytes not complete");if(f[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let u of f)s=s<<8|u;if(n+=c,s<128)throw new e("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+s);if(a.length!==s)throw new e("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+s)}}},_int:{encode(r){let{Err:t}=Ce;if(r<Ne)throw new t("integer: negative integers are not allowed");let e=tr(r);if(Number.parseInt(e[0],16)&8&&(e="00"+e),e.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return e},decode(r){let{Err:t}=Ce;if(r[0]&128)throw new t("invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Dp(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=Ce,o=typeof r=="string"?Op(r):r;kr(o);let{v:i,l:s}=n.decode(48,o);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,i),{v:f,l:u}=n.decode(2,c);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(a),s:e.decode(f)}},hexFromSig(r){let{_tlv:t,_int:e}=Ce,n=t.encode(2,e.encode(r.r)),o=t.encode(2,e.encode(r.s)),i=n+o;return t.encode(48,i)}},Ne=BigInt(0),pt=BigInt(1),Xw=BigInt(2),pl=BigInt(3),Qw=BigInt(4);function Mp(r){let t=Fp(r),{Fp:e}=t,n=He(t.n,t.nBitLength),o=t.toBytes||((y,d,A)=>{let T=d.toAffine();return Ee(Uint8Array.from([4]),e.toBytes(T.x),e.toBytes(T.y))}),i=t.fromBytes||(y=>{let d=y.subarray(1),A=e.fromBytes(d.subarray(0,e.BYTES)),T=e.fromBytes(d.subarray(e.BYTES,2*e.BYTES));return{x:A,y:T}});function s(y){let{a:d,b:A}=t,T=e.sqr(y),w=e.mul(T,y);return e.add(e.add(w,e.mul(y,d)),A)}if(!e.eql(e.sqr(t.Gy),s(t.Gx)))throw new Error("bad generator point: equation left != right");function a(y){return tn(y,pt,t.n)}function c(y){let{allowedPrivateKeyLengths:d,nByteLength:A,wrapPrivateKey:T,n:w}=t;if(d&&typeof y!="bigint"){if(De(y)&&(y=be(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:ve(st("private key",y,A))}catch{throw new Error("invalid private key, expected hex or "+A+" bytes, got "+typeof y)}return T&&(U=Q(U,w)),Lt("private key",U,pt,w),U}function f(y){if(!(y instanceof h))throw new Error("ProjectivePoint expected")}let u=nr((y,d)=>{let{px:A,py:T,pz:w}=y;if(e.eql(w,e.ONE))return{x:A,y:T};let U=y.is0();d==null&&(d=U?e.ONE:e.inv(w));let F=e.mul(A,d),P=e.mul(T,d),R=e.mul(w,d);if(U)return{x:e.ZERO,y:e.ZERO};if(!e.eql(R,e.ONE))throw new Error("invZ was invalid");return{x:F,y:P}}),l=nr(y=>{if(y.is0()){if(t.allowInfinityPoint&&!e.is0(y.py))return;throw new Error("bad point: ZERO")}let{x:d,y:A}=y.toAffine();if(!e.isValid(d)||!e.isValid(A))throw new Error("bad point: x or y not FE");let T=e.sqr(A),w=s(d);if(!e.eql(T,w))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||!e.isValid(d))throw new Error("x required");if(A==null||!e.isValid(A))throw new Error("y required");if(T==null||!e.isValid(T))throw new Error("z required");Object.freeze(this)}static fromAffine(d){let{x:A,y:T}=d||{};if(!d||!e.isValid(A)||!e.isValid(T))throw new Error("invalid affine point");if(d instanceof h)throw new Error("projective point not allowed");let w=U=>e.eql(U,e.ZERO);return w(A)&&w(T)?h.ZERO:new h(A,T,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){let A=e.invertBatch(d.map(T=>T.pz));return d.map((T,w)=>T.toAffine(A[w])).map(h.fromAffine)}static fromHex(d){let A=h.fromAffine(i(st("pointHex",d)));return A.assertValidity(),A}static fromPrivateKey(d){return h.BASE.multiply(c(d))}static msm(d,A){return Jn(h,n,d,A)}_setWindowSize(d){E.setWindowSize(this,d)}assertValidity(){l(this)}hasEvenY(){let{y:d}=this.toAffine();if(e.isOdd)return!e.isOdd(d);throw new Error("Field doesn't support isOdd")}equals(d){f(d);let{px:A,py:T,pz:w}=this,{px:U,py:F,pz:P}=d,R=e.eql(e.mul(A,P),e.mul(U,w)),b=e.eql(e.mul(T,P),e.mul(F,w));return R&&b}negate(){return new h(this.px,e.neg(this.py),this.pz)}double(){let{a:d,b:A}=t,T=e.mul(A,pl),{px:w,py:U,pz:F}=this,P=e.ZERO,R=e.ZERO,b=e.ZERO,v=e.mul(w,w),D=e.mul(U,U),_=e.mul(F,F),C=e.mul(w,U);return C=e.add(C,C),b=e.mul(w,F),b=e.add(b,b),P=e.mul(d,b),R=e.mul(T,_),R=e.add(P,R),P=e.sub(D,R),R=e.add(D,R),R=e.mul(P,R),P=e.mul(C,P),b=e.mul(T,b),_=e.mul(d,_),C=e.sub(v,_),C=e.mul(d,C),C=e.add(C,b),b=e.add(v,v),v=e.add(b,v),v=e.add(v,_),v=e.mul(v,C),R=e.add(R,v),_=e.mul(U,F),_=e.add(_,_),v=e.mul(_,C),P=e.sub(P,v),b=e.mul(_,D),b=e.add(b,b),b=e.add(b,b),new h(P,R,b)}add(d){f(d);let{px:A,py:T,pz:w}=this,{px:U,py:F,pz:P}=d,R=e.ZERO,b=e.ZERO,v=e.ZERO,D=t.a,_=e.mul(t.b,pl),C=e.mul(A,U),$=e.mul(T,F),S=e.mul(w,P),I=e.add(A,T),m=e.add(U,F);I=e.mul(I,m),m=e.add(C,$),I=e.sub(I,m),m=e.add(A,w);let p=e.add(U,P);return m=e.mul(m,p),p=e.add(C,S),m=e.sub(m,p),p=e.add(T,w),R=e.add(F,P),p=e.mul(p,R),R=e.add($,S),p=e.sub(p,R),v=e.mul(D,m),R=e.mul(_,S),v=e.add(R,v),R=e.sub($,v),v=e.add($,v),b=e.mul(R,v),$=e.add(C,C),$=e.add($,C),S=e.mul(D,S),m=e.mul(_,m),$=e.add($,S),S=e.sub(C,S),S=e.mul(D,S),m=e.add(m,S),C=e.mul($,m),b=e.add(b,C),C=e.mul(p,m),R=e.mul(I,R),R=e.sub(R,C),C=e.mul(I,$),v=e.mul(p,v),v=e.add(v,C),new h(R,b,v)}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}=t;Lt("scalar",d,Ne,T);let w=h.ZERO;if(d===Ne)return w;if(this.is0()||d===pt)return this;if(!A||E.hasPrecomputes(this))return E.wNAFCachedUnsafe(this,d,h.normalizeZ);let{k1neg:U,k1:F,k2neg:P,k2:R}=A.splitScalar(d),b=w,v=w,D=this;for(;F>Ne||R>Ne;)F&pt&&(b=b.add(D)),R&pt&&(v=v.add(D)),D=D.double(),F>>=pt,R>>=pt;return U&&(b=b.negate()),P&&(v=v.negate()),v=new h(e.mul(v.px,A.beta),v.py,v.pz),b.add(v)}multiply(d){let{endo:A,n:T}=t;Lt("scalar",d,pt,T);let w,U;if(A){let{k1neg:F,k1:P,k2neg:R,k2:b}=A.splitScalar(d),{p:v,f:D}=this.wNAF(P),{p:_,f:C}=this.wNAF(b);v=E.constTimeNegate(F,v),_=E.constTimeNegate(R,_),_=new h(e.mul(_.px,A.beta),_.py,_.pz),w=v.add(_),U=D.add(C)}else{let{p:F,f:P}=this.wNAF(d);w=F,U=P}return h.normalizeZ([w,U])[0]}multiplyAndAddUnsafe(d,A,T){let w=h.BASE,U=(P,R)=>R===Ne||R===pt||!P.equals(w)?P.multiplyUnsafe(R):P.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}=t;if(d===pt)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}=t;return d===pt?this:A?A(h,this):this.multiplyUnsafe(t.h)}toRawBytes(d=!0){return Jt("isCompressed",d),this.assertValidity(),o(h,this,d)}toHex(d=!0){return Jt("isCompressed",d),be(this.toRawBytes(d))}}h.BASE=new h(t.Gx,t.Gy,e.ONE),h.ZERO=new h(e.ZERO,e.ONE,e.ZERO);let g=t.nBitLength,E=Yn(h,t.endo?Math.ceil(g/2):g);return{CURVE:t,ProjectivePoint:h,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:a}}function Hp(r){let t=rn(r);return ue(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function ml(r){let t=Hp(r),{Fp:e,n}=t,o=e.BYTES+1,i=2*e.BYTES+1;function s(S){return Q(S,n)}function a(S){return Wn(S,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:f,weierstrassEquation:u,isWithinCurveOrder:l}=Mp({...t,toBytes(S,I,m){let p=I.toAffine(),B=e.toBytes(p.x),N=Ee;return Jt("isCompressed",m),m?N(Uint8Array.from([I.hasEvenY()?2:3]),B):N(Uint8Array.from([4]),B,e.toBytes(p.y))},fromBytes(S){let I=S.length,m=S[0],p=S.subarray(1);if(I===o&&(m===2||m===3)){let B=ve(p);if(!tn(B,pt,e.ORDER))throw new Error("Point is not on curve");let N=u(B),O;try{O=e.sqrt(N)}catch(G){let K=G instanceof Error?": "+G.message:"";throw new Error("Point is not on curve"+K)}let M=(O&pt)===pt;return(m&1)===1!==M&&(O=e.neg(O)),{x:B,y:O}}else if(I===i&&m===4){let B=e.fromBytes(p.subarray(0,e.BYTES)),N=e.fromBytes(p.subarray(e.BYTES,2*e.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 "+I)}}}),h=S=>be(Me(S,t.nByteLength));function g(S){let I=n>>pt;return S>I}function E(S){return g(S)?s(-S):S}let y=(S,I,m)=>ve(S.slice(I,m));class d{constructor(I,m,p){this.r=I,this.s=m,this.recovery=p,this.assertValidity()}static fromCompact(I){let m=t.nByteLength;return I=st("compactSignature",I,m*2),new d(y(I,0,m),y(I,m,2*m))}static fromDER(I){let{r:m,s:p}=Ce.toSig(st("DER",I));return new d(m,p)}assertValidity(){Lt("r",this.r,pt,n),Lt("s",this.s,pt,n)}addRecoveryBit(I){return new d(this.r,this.s,I)}recoverPublicKey(I){let{r:m,s:p,recovery:B}=this,N=P(st("msgHash",I));if(B==null||![0,1,2,3].includes(B))throw new Error("recovery id invalid");let O=B===2||B===3?m+t.n:m;if(O>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let M=B&1?"03":"02",z=c.fromHex(M+h(O)),G=a(O),K=s(-N*G),J=s(p*G),et=c.BASE.multiplyAndAddUnsafe(z,K,J);if(!et)throw new Error("point at infinify");return et.assertValidity(),et}hasHighS(){return g(this.s)}normalizeS(){return this.hasHighS()?new d(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return er(this.toDERHex())}toDERHex(){return Ce.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return er(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}let A={isValidPrivateKey(S){try{return f(S),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let S=ds(t.n);return Mc(t.randomBytes(S),t.n)},precompute(S=8,I=c.BASE){return I._setWindowSize(S),I.multiply(BigInt(3)),I}};function T(S,I=!0){return c.fromPrivateKey(S).toRawBytes(I)}function w(S){let I=De(S),m=typeof S=="string",p=(I||m)&&S.length;return I?p===o||p===i:m?p===2*o||p===2*i:S instanceof c}function U(S,I,m=!0){if(w(S))throw new Error("first arg must be private key");if(!w(I))throw new Error("second arg must be public key");return c.fromHex(I).multiply(f(S)).toRawBytes(m)}let F=t.bits2int||function(S){if(S.length>8192)throw new Error("input is too large");let I=ve(S),m=S.length*8-t.nBitLength;return m>0?I>>BigInt(m):I},P=t.bits2int_modN||function(S){return s(F(S))},R=en(t.nBitLength);function b(S){return Lt("num < 2^"+t.nBitLength,S,Ne,R),Me(S,t.nByteLength)}function v(S,I,m=D){if(["recovered","canonical"].some(dt=>dt in m))throw new Error("sign() legacy options not supported");let{hash:p,randomBytes:B}=t,{lowS:N,prehash:O,extraEntropy:M}=m;N==null&&(N=!0),S=st("msgHash",S),dl(m),O&&(S=st("prehashed msgHash",p(S)));let z=P(S),G=f(I),K=[b(G),b(z)];if(M!=null&&M!==!1){let dt=M===!0?B(e.BYTES):M;K.push(st("extraEntropy",dt))}let J=Ee(...K),et=z;function ht(dt){let yt=F(dt);if(!l(yt))return;let vt=a(yt),Ut=c.BASE.multiply(yt).toAffine(),kt=s(Ut.x);if(kt===Ne)return;let ce=s(vt*s(et+kt*G));if(ce===Ne)return;let ge=(Ut.x===kt?0:2)|Number(Ut.y&pt),Zr=ce;return N&&g(ce)&&(Zr=E(ce),ge^=1),new d(kt,Zr,ge)}return{seed:J,k2sig:ht}}let D={lowS:t.lowS,prehash:!1},_={lowS:t.lowS,prehash:!1};function C(S,I,m=D){let{seed:p,k2sig:B}=v(S,I,m),N=t;return us(N.hash.outputLen,N.nByteLength,N.hmac)(p,B)}c.BASE._setWindowSize(8);function $(S,I,m,p=_){let B=S;I=st("msgHash",I),m=st("publicKey",m);let{lowS:N,prehash:O,format:M}=p;if(dl(p),"strict"in p)throw new Error("options.strict was renamed to lowS");if(M!==void 0&&M!=="compact"&&M!=="der")throw new Error("format must be compact or der");let z=typeof B=="string"||De(B),G=!z&&!M&&typeof B=="object"&&B!==null&&typeof B.r=="bigint"&&typeof B.s=="bigint";if(!z&&!G)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let K,J;try{if(G&&(K=new d(B.r,B.s)),z){try{M!=="compact"&&(K=d.fromDER(B))}catch(ge){if(!(ge instanceof Ce.Err))throw ge}!K&&M!=="der"&&(K=d.fromCompact(B))}J=c.fromHex(m)}catch{return!1}if(!K||N&&K.hasHighS())return!1;O&&(I=t.hash(I));let{r:et,s:ht}=K,dt=P(I),yt=a(ht),vt=s(dt*yt),Ut=s(et*yt),kt=c.BASE.multiplyAndAddUnsafe(J,vt,Ut)?.toAffine();return kt?s(kt.x)===et:!1}return{CURVE:t,getPublicKey:T,getSharedSecret:U,sign:C,verify:$,ProjectivePoint:c,Signature:d,utils:A}}function $p(r){return{hash:r,hmac:(t,...e)=>la(r,t,rs(...e)),randomBytes:Kn}}function gl(r,t){let e=n=>ml({...r,...$p(n)});return Object.freeze({...e(t),create:e})}var wl=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),yl=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Kp=BigInt(1),fa=BigInt(2),xl=(r,t)=>(r+t/fa)/t;function qp(r){let t=wl,e=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),f=r*r*r%t,u=f*f*r%t,l=it(u,e,t)*u%t,h=it(l,e,t)*u%t,g=it(h,fa,t)*f%t,E=it(g,o,t)*g%t,y=it(E,i,t)*E%t,d=it(y,a,t)*y%t,A=it(d,c,t)*d%t,T=it(A,a,t)*y%t,w=it(T,e,t)*u%t,U=it(w,s,t)*E%t,F=it(U,n,t)*f%t,P=it(F,fa,t);if(!ha.eql(ha.sqr(P),r))throw new Error("Cannot find square root");return P}var ha=He(wl,void 0,void 0,{sqrt:qp}),ur=gl({a:BigInt(0),b:BigInt(7),Fp:ha,n:yl,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=yl,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Kp*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=e,s=BigInt("0x100000000000000000000000000000000"),a=xl(i*r,t),c=xl(-n*r,t),f=Q(r-a*e-c*o,t),u=Q(-a*n-c*i,t),l=f>s,h=u>s;if(l&&(f=t-f),h&&(u=t-u),f>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:l,k1:f,k2neg:h,k2:u}}}},hl),cb=BigInt(0);var ub=ur.ProjectivePoint;function Ot(r,t){t==null&&(t=r.reduce((o,i)=>o+i.length,0));let e=Qt(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}function bl(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function vl(r,t,e){let n=nn.digest(e instanceof Uint8Array?e:e.subarray());if(bl(n))return n.then(({digest:o})=>ur.verify(t,o,r)).catch(o=>{throw new yn(String(o))});try{return ur.verify(t,n.digest,r)}catch(o){throw new yn(String(o))}}var ni=class{type="secp256k1";raw;_key;constructor(t){this._key=Bl(t),this.raw=El(this._key)}toMultihash(){return Zt.digest(eo(this))}toCID(){return X.createV1(114,this.toMultihash())}toString(){return rt.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ct(this.raw,t.raw)}verify(t,e){return vl(this._key,e,t)}};function da(r){return new ni(r)}function El(r){return ur.ProjectivePoint.fromHex(r).toRawBytes(!0)}function Bl(r){try{return ur.ProjectivePoint.fromHex(r),r}catch(t){throw new pr(String(t))}}function Al(r){let{Type:t,Data:e}=le.decode(r),n=e??new Uint8Array;switch(t){case ft.RSA:return ca(n);case ft.Ed25519:return bs(n);case ft.secp256k1:return da(n);default:throw new gr}}function oi(r){let{Type:t,Data:e}=le.decode(r.digest),n=e??new Uint8Array;switch(t){case ft.Ed25519:return bs(n);case ft.secp256k1:return da(n);default:throw new gr}}function eo(r){return le.encode({Type:ft[r.type],Data:r.raw})}var Sl=Symbol.for("nodejs.util.inspect.custom"),zp=114,bn=class{type;multihash;publicKey;string;constructor(t){this.type=t.type,this.multihash=t.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[$i]=!0;toString(){return this.string==null&&(this.string=rt.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return X.createV1(zp,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return ct(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return ct(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[Sl](){return`PeerId(${this.toString()})`}},ii=class extends bn{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},si=class extends bn{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},ai=class extends bn{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},jp=2336,vn=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=Zt.digest(W(this.url))}[Sl](){return`PeerId(${this.url})`}[$i]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return X.createV1(jp,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=nt(t)),t.toString()===this.toString())}};var Gp=114,Il=2336;function kl(r,t){let e;if(r.charAt(0)==="1"||r.charAt(0)==="Q")e=xe(rt.decode(`z${r}`));else{if(t==null)throw new Et('Please pass a multibase decoder for strings that do not start with "1" or "Q"');e=xe(t.decode(r))}return Tl(e)}function Tl(r){if(Zp(r))return new ii({multihash:r});if(Wp(r))try{let t=oi(r);if(t.type==="Ed25519")return new si({multihash:r,publicKey:t});if(t.type==="secp256k1")return new ai({multihash:r,publicKey:t})}catch{let e=nt(r.digest);return new vn(new URL(e))}throw new mr("Supplied PeerID Multihash is invalid")}function Cl(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==Gp&&r.code!==Il)throw new Pn("Supplied PeerID CID is invalid");if(r.code===Il){let t=nt(r.multihash.digest);return new vn(new URL(t))}return Tl(r.multihash)}function Wp(r){return r.code===Zt.code}function Zp(r){return r.code===nn.code}var ci=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let e=this.index,n=t();return n===void 0&&(this.index=e),n}parseWith(t){let e=t();if(this.index===this.input.length)return e}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let e=this.readChar();if(e===t)return e})}readSeparator(t,e,n){return this.readAtomically(()=>{if(!(e>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,e,n,o){return this.readAtomically(()=>{let i=0,s=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",f=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let h=Number.parseInt(l,t);if(!Number.isNaN(h))return h});if(u===void 0)break;if(i*=t,i+=u,i>f||(s+=1,e!==void 0&&s>e))return}if(s!==0)return!n&&c&&s>1?void 0:i})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let e=0;e<t.length;e++){let n=this.readSeparator(".",e,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[e]=n}return t})}readIPv6Addr(){let t=e=>{for(let n=0;n<e.length/2;n++){let o=n*2;if(n<e.length-3){let s=this.readSeparator(":",n,()=>this.readIPv4Addr());if(s!==void 0)return e[o]=s[0],e[o+1]=s[1],e[o+2]=s[2],e[o+3]=s[3],[o+4,!0]}let i=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(i===void 0)return[o,!1];e[o]=i>>8,e[o+1]=i&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[n,o]=t(e);if(n===16)return e;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let i=new Uint8Array(14),s=16-(n+2),[a]=t(i.subarray(0,s));return e.set(i.subarray(0,a),16-a),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Nl=45,Yp=15,Or=new ci;function pa(r){if(!(r.length>Yp))return Or.new(r).parseWith(()=>Or.readIPv4Addr())}function ma(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Nl))return Or.new(r).parseWith(()=>Or.readIPv6Addr())}function ui(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Nl))return Or.new(r).parseWith(()=>Or.readIPAddr())}var A1=parseInt("0xFFFF",16),S1=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function _l(r){return!!pa(r)}function Ll(r){return!!ma(r)}function li(r){return!!ui(r)}var Vl=_l,em=Ll,ga=function(r){let t=0;if(r=r.toString().trim(),Vl(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(em(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let i=Vl(e[n]),s;i&&(s=ga(e[n]),e[n]=nt(s.slice(0,2),"base16")),s!=null&&++n<8&&e.splice(n,0,nt(s.slice(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let i=[n,1];for(n=9-e.length;n>0;n--)i.push("0");e.splice.apply(e,i)}let o=new Uint8Array(t+16);for(n=0;n<e.length;n++){let i=parseInt(e[n],16);o[t++]=i>>8&255,o[t++]=i&255}return o}throw new Error("invalid ip address")},Pl=function(r,t=0,e){t=~~t,e=e??r.length-t;let n=new DataView(r.buffer);if(e===4){let o=[];for(let i=0;i<e;i++)o.push(r[t+i]);return o.join(".")}if(e===16){let o=[];for(let i=0;i<e;i+=2)o.push(n.getUint16(t+i).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Mr={},ya={},nm=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[481,-1,"http-path"],[777,-1,"memory"]];nm.forEach(r=>{let t=om(...r);ya[t.code]=t,Mr[t.name]=t});function om(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function tt(r){if(typeof r=="number"){if(ya[r]!=null)return ya[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Mr[r]!=null)return Mr[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var c2=tt("ip4"),u2=tt("ip6"),l2=tt("ipcidr");function va(r,t){switch(tt(r).code){case 4:case 41:return sm(t);case 42:return ba(t);case 6:case 273:case 33:case 132:return Ol(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return ba(t);case 421:return lm(t);case 444:return Dl(t);case 445:return Dl(t);case 466:return um(t);case 481:return globalThis.encodeURIComponent(ba(t));default:return nt(t,"base16")}}function Ea(r,t){switch(tt(r).code){case 4:return Fl(t);case 41:return Fl(t);case 42:return wa(t);case 6:case 273:case 33:case 132:return Ba(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return wa(t);case 421:return am(t);case 444:return fm(t);case 445:return hm(t);case 466:return cm(t);case 481:return wa(globalThis.decodeURIComponent(t));default:return W(t,"base16")}}var xa=Object.values(on).map(r=>r.decoder),im=function(){let r=xa[0].or(xa[1]);return xa.slice(2).forEach(t=>r=r.or(t)),r}();function Fl(r){if(!li(r))throw new Error("invalid ip address");return ga(r)}function sm(r){let t=Pl(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!li(t))throw new Error("invalid ip address");return t}function Ba(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function Ol(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function wa(r){let t=W(r),e=Uint8Array.from(Tr(t.length));return Ot([e,t],e.length+t.length)}function ba(r){let t=ir(r);if(r=r.slice(Pt(t)),r.length!==t)throw new Error("inconsistent lengths");return nt(r)}function am(r){let t;r[0]==="Q"||r[0]==="1"?t=xe(rt.decode(`z${r}`)).bytes:t=X.parse(r).multihash.bytes;let e=Uint8Array.from(Tr(t.length));return Ot([e,t],e.length+t.length)}function cm(r){let t=im.decode(r),e=Uint8Array.from(Tr(t.length));return Ot([e,t],e.length+t.length)}function um(r){let t=ir(r),e=r.slice(Pt(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+nt(e,"base64url")}function lm(r){let t=ir(r),e=r.slice(Pt(t));if(e.length!==t)throw new Error("inconsistent lengths");return nt(e,"base58btc")}function fm(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=Gt.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Ba(n);return Ot([e,o],e.length+o.length)}function hm(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=Gt.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Ba(n);return Ot([e,o],e.length+o.length)}function Dl(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=nt(t,"base32"),o=Ol(e);return`${n}:${o}`}function Ml(r){r=Aa(r);let t=[],e=[],n=null,o=r.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let i=0;i<o.length;i++){let s=o[i],a=tt(s);if(a.size===0){t.push([a.code]),e.push([a.code]);continue}if(i++,i>=o.length)throw $l("invalid address: "+r);if(a.path===!0){n=Aa(o.slice(i).join("/")),t.push([a.code,Ea(a.code,n)]),e.push([a.code,n]);break}let c=Ea(a.code,o[i]);t.push([a.code,c]),e.push([a.code,va(a.code,c)])}return{string:Hl(e),bytes:Ia(t),tuples:t,stringTuples:e,path:n}}function Sa(r){let t=[],e=[],n=null,o=0;for(;o<r.length;){let i=ir(r,o),s=Pt(i),a=tt(i),c=dm(a,r.slice(o+s));if(c===0){t.push([i]),e.push([i]),o+=s;continue}let f=r.slice(o+s,o+s+c);if(o+=c+s,o>r.length)throw $l("Invalid address Uint8Array: "+nt(r,"base16"));t.push([i,f]);let u=va(i,f);if(e.push([i,u]),a.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:Hl(e),tuples:t,stringTuples:e,path:n}}function Hl(r){let t=[];return r.map(e=>{let n=tt(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),Aa(t.join("/"))}function Ia(r){return Ot(r.map(t=>{let e=tt(t[0]),n=Uint8Array.from(Tr(e.code));return t.length>1&&t[1]!=null&&(n=Ot([n,t[1]])),n}))}function dm(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=ir(t instanceof Uint8Array?t:Uint8Array.from(t));return e+Pt(e)}}function Aa(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function $l(r){return new Error("Error parsing address: "+r)}var pm=Symbol.for("nodejs.util.inspect.custom"),Ta=Symbol.for("@multiformats/js-multiaddr/multiaddr"),mm=[tt("dns").code,tt("dns4").code,tt("dns6").code,tt("dnsaddr").code],ka=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}},fi=class r{bytes;#t;#r;#e;#a;[Ta]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=Sa(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=Ml(t)}else if(ql(t))e=Sa(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=e.bytes,this.#t=e.string,this.#r=e.tuples,this.#e=e.stringTuples,this.#a=e.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let t,e,n,o,i="",s=tt("tcp"),a=tt("udp"),c=tt("ip4"),f=tt("ip6"),u=tt("dns6"),l=tt("ip6zone");for(let[g,E]of this.stringTuples())g===l.code&&(i=`%${E??""}`),mm.includes(g)&&(e=s.name,o=443,n=`${E??""}${i}`,t=g===u.code?6:4),(g===s.code||g===a.code)&&(e=tt(g).name,o=parseInt(E??"")),(g===c.code||g===f.code)&&(e=tt(g).name,n=`${E??""}${i}`,t=g===f.code?6:4);if(t==null||e==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:e,port:o}}protos(){return this.#r.map(([t])=>Object.assign({},tt(t)))}protoCodes(){return this.#r.map(([t])=>t)}protoNames(){return this.#r.map(([t])=>tt(t).name)}tuples(){return this.#r.map(([t,e])=>e==null?[t]:[t,e])}stringTuples(){return this.#e.map(([t,e])=>e==null?[t]:[t,e])}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),o=n.lastIndexOf(e);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,o))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new r(Ia(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===Mr.p2p.code&&t.push([n,o]),n===Mr["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?nt(rt.decode(`z${n}`),"base58btc"):nt(X.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#a}equals(t){return ct(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(i=>i.resolvable);if(e==null)return[this];let n=Kl.get(e.name);if(n==null)throw new ka(`no available resolver for ${e.name}`);return(await n(this,t)).map(i=>lr(i))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let e=(t??this).protos();return!(e.length!==2||e[0].code!==4&&e[0].code!==41||e[1].code!==6&&e[1].code!==273)}[pm](){return`Multiaddr(${this.#t})`}};var Kl=new Map;function ql(r){return!!r?.[Ta]}function lr(r){return new fi(r)}function En(r){let t=new globalThis.AbortController;function e(){t.abort();for(let i of r)i?.removeEventListener!=null&&i.removeEventListener("abort",e)}for(let i of r){if(i?.aborted===!0){e();break}i?.addEventListener!=null&&i.addEventListener("abort",e)}function n(){for(let i of r)i?.removeEventListener!=null&&i.removeEventListener("abort",e)}let o=t.signal;return o.clear=n,o}async function*hi(r,t={}){let e=r.getReader();try{for(;;){let n=await e.read();if(n.done)return;yield n.value}}finally{t.preventCancel!==!0&&await e.cancel(),e.releaseLock()}}var gm="/",ym=new TextEncoder().encode(gm),D2=ym[0];var Jm=Vn(Na(),1);var ne=class extends Error{static name="SignatureVerificationError";constructor(t="Record signature verification failed"){super(t),this.name="SignatureVerificationError"}},di=class extends Error{static name="RecordExpiredError";constructor(t="Record has expired"){super(t),this.name="RecordExpiredError"}},Hr=class extends Error{static name="UnsupportedValidityError";constructor(t="The validity type is unsupported"){super(t),this.name="UnsupportedValidityError"}},pi=class extends Error{static name="RecordTooLargeError";constructor(t="The record is too large"){super(t),this.name="RecordTooLargeError"}},mi=class extends Error{static name="InvalidValueError";constructor(t="Value must be a valid content path starting with /"){super(t),this.name="InvalidValueError"}},gi=class extends Error{static name="InvalidRecordDataError";constructor(t="Invalid record data"){super(t),this.name="InvalidRecordDataError"}},Bn=class extends Error{static name="InvalidEmbeddedPublicKeyError";constructor(t="Invalid embedded public key"){super(t),this.name="InvalidEmbeddedPublicKeyError"}};var oe;(function(r){let t;(function(o){o.EOL="EOL"})(t=r.ValidityType||(r.ValidityType={}));let e;(function(o){o[o.EOL=0]="EOL"})(e||(e={})),function(o){o.codec=()=>cn(e)}(t=r.ValidityType||(r.ValidityType={}));let n;r.codec=()=>(n==null&&(n=Rr((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),r.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 f=o.uint32();switch(f>>>3){case 1:{a.value=o.bytes();break}case 2:{a.signatureV1=o.bytes();break}case 3:{a.validityType=r.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(f&7);break}}}return a})),n),r.encode=o=>Nr(o,r.codec()),r.decode=(o,i)=>Cr(o,r.codec(),i)})(oe||(oe={}));var xm=["string","number","bigint","symbol"],wm=["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 zl(r){if(r===null)return"null";if(r===void 0)return"undefined";if(r===!0||r===!1)return"boolean";let t=typeof r;if(xm.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(r))return"Array";if(bm(r))return"Buffer";let e=vm(r);return e||"Object"}function bm(r){return r&&r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer.call(null,r)}function vm(r){let t=Object.prototype.toString.call(r).slice(8,-1);if(wm.includes(t))return t}var x=class{constructor(t,e,n){this.major=t,this.majorEncoded=t<<5,this.name=e,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(t){return this.major<t.major?-1:this.major>t.major?1:0}};x.uint=new x(0,"uint",!0);x.negint=new x(1,"negint",!0);x.bytes=new x(2,"bytes",!0);x.string=new x(3,"string",!0);x.array=new x(4,"array",!1);x.map=new x(5,"map",!1);x.tag=new x(6,"tag",!1);x.float=new x(7,"float",!0);x.false=new x(7,"false",!0);x.true=new x(7,"true",!0);x.null=new x(7,"null",!0);x.undefined=new x(7,"undefined",!0);x.break=new x(7,"break",!0);var V=class{constructor(t,e,n){this.type=t,this.value=e,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var $r=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Em=new TextDecoder,Bm=new TextEncoder;function yi(r){return $r&&globalThis.Buffer.isBuffer(r)}function Zl(r){return r instanceof Uint8Array?yi(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r:Uint8Array.from(r)}var Yl=$r?(r,t,e)=>e-t>64?globalThis.Buffer.from(r.subarray(t,e)).toString("utf8"):Gl(r,t,e):(r,t,e)=>e-t>64?Em.decode(r.subarray(t,e)):Gl(r,t,e),Jl=$r?r=>r.length>64?globalThis.Buffer.from(r):jl(r):r=>r.length>64?Bm.encode(r):jl(r);var Kr=$r?(r,t,e)=>yi(r)?new Uint8Array(r.subarray(t,e)):r.slice(t,e):(r,t,e)=>r.slice(t,e),Xl=$r?(r,t)=>(r=r.map(e=>e instanceof Uint8Array?e:globalThis.Buffer.from(e)),Zl(globalThis.Buffer.concat(r,t))):(r,t)=>{let e=new Uint8Array(t),n=0;for(let o of r)n+o.length>e.length&&(o=o.subarray(0,e.length-n)),e.set(o,n),n+=o.length;return e},Ql=$r?r=>globalThis.Buffer.allocUnsafe(r):r=>new Uint8Array(r);function tf(r,t){if(yi(r)&&yi(t))return r.compare(t);for(let e=0;e<r.length;e++)if(r[e]!==t[e])return r[e]<t[e]?-1:1;return 0}function jl(r){let t=[],e=0;for(let n=0;n<r.length;n++){let o=r.charCodeAt(n);o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&n+1<r.length&&(r.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(r.charCodeAt(++n)&1023),t[e++]=o>>18|240,t[e++]=o>>12&63|128,t[e++]=o>>6&63|128,t[e++]=o&63|128):(t[e++]=o>>12|224,t[e++]=o>>6&63|128,t[e++]=o&63|128)}return t}function Gl(r,t,e){let n=[];for(;t<e;){let o=r[t],i=null,s=o>239?4:o>223?3:o>191?2:1;if(t+s<=e){let a,c,f,u;switch(s){case 1:o<128&&(i=o);break;case 2:a=r[t+1],(a&192)===128&&(u=(o&31)<<6|a&63,u>127&&(i=u));break;case 3:a=r[t+1],c=r[t+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=r[t+1],c=r[t+2],f=r[t+3],(a&192)===128&&(c&192)===128&&(f&192)===128&&(u=(o&15)<<18|(a&63)<<12|(c&63)<<6|f&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),t+=s}return Am(n)}var Wl=4096;function Am(r){let t=r.length;if(t<=Wl)return String.fromCharCode.apply(String,r);let e="",n=0;for(;n<t;)e+=String.fromCharCode.apply(String,r.slice(n,n+=Wl));return e}var Sm=256,xi=class{constructor(t=Sm){this.chunkSize=t,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(t){let e=this.chunks[this.chunks.length-1];if(this.cursor+t.length<=this.maxCursor+1){let o=e.length-(this.maxCursor-this.cursor)-1;e.set(t,o)}else{if(e){let o=e.length-(this.maxCursor-this.cursor)-1;o<e.length&&(this.chunks[this.chunks.length-1]=e.subarray(0,o),this.maxCursor=this.cursor-1)}t.length<64&&t.length<this.chunkSize?(e=Ql(this.chunkSize),this.chunks.push(e),this.maxCursor+=e.length,this._initReuseChunk===null&&(this._initReuseChunk=e),e.set(t,0)):(this.chunks.push(t),this.maxCursor+=t.length)}this.cursor+=t.length}toBytes(t=!1){let e;if(this.chunks.length===1){let n=this.chunks[0];t&&this.cursor>n.length/2?(e=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):e=Kr(n,0,this.cursor)}else e=Xl(this.chunks,this.cursor);return t&&this.reset(),e}};var H="CBOR decode error:",Ua="CBOR encode error:",An=[];An[23]=1;An[24]=2;An[25]=3;An[26]=5;An[27]=9;function Ue(r,t,e){if(r.length-t<e)throw new Error(`${H} not enough data for type`)}var mt=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Mt(r,t,e){Ue(r,t,1);let n=r[t];if(e.strict===!0&&n<mt[0])throw new Error(`${H} integer encoded in more bytes than necessary (strict decode)`);return n}function Ht(r,t,e){Ue(r,t,2);let n=r[t]<<8|r[t+1];if(e.strict===!0&&n<mt[1])throw new Error(`${H} integer encoded in more bytes than necessary (strict decode)`);return n}function $t(r,t,e){Ue(r,t,4);let n=r[t]*16777216+(r[t+1]<<16)+(r[t+2]<<8)+r[t+3];if(e.strict===!0&&n<mt[2])throw new Error(`${H} integer encoded in more bytes than necessary (strict decode)`);return n}function Kt(r,t,e){Ue(r,t,8);let n=r[t]*16777216+(r[t+1]<<16)+(r[t+2]<<8)+r[t+3],o=r[t+4]*16777216+(r[t+5]<<16)+(r[t+6]<<8)+r[t+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(e.strict===!0&&i<mt[3])throw new Error(`${H} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(e.allowBigInt===!0)return i;throw new Error(`${H} integers outside of the safe integer range are not supported`)}function ef(r,t,e,n){return new V(x.uint,Mt(r,t+1,n),2)}function rf(r,t,e,n){return new V(x.uint,Ht(r,t+1,n),3)}function nf(r,t,e,n){return new V(x.uint,$t(r,t+1,n),5)}function of(r,t,e,n){return new V(x.uint,Kt(r,t+1,n),9)}function zt(r,t){return bt(r,0,t.value)}function bt(r,t,e){if(e<mt[0]){let n=Number(e);r.push([t|n])}else if(e<mt[1]){let n=Number(e);r.push([t|24,n])}else if(e<mt[2]){let n=Number(e);r.push([t|25,n>>>8,n&255])}else if(e<mt[3]){let n=Number(e);r.push([t|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(e);if(n<mt[4]){let o=[t|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),s=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=s&255,s=s>>8,o[3]=s&255,s=s>>8,o[2]=s&255,s=s>>8,o[1]=s&255,r.push(o)}else throw new Error(`${H} encountered BigInt larger than allowable range`)}}zt.encodedSize=function(t){return bt.encodedSize(t.value)};bt.encodedSize=function(t){return t<mt[0]?1:t<mt[1]?2:t<mt[2]?3:t<mt[3]?5:9};zt.compareTokens=function(t,e){return t.value<e.value?-1:t.value>e.value?1:0};function sf(r,t,e,n){return new V(x.negint,-1-Mt(r,t+1,n),2)}function af(r,t,e,n){return new V(x.negint,-1-Ht(r,t+1,n),3)}function cf(r,t,e,n){return new V(x.negint,-1-$t(r,t+1,n),5)}var Ra=BigInt(-1),uf=BigInt(1);function lf(r,t,e,n){let o=Kt(r,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new V(x.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${H} integers outside of the safe integer range are not supported`);return new V(x.negint,Ra-BigInt(o),9)}function wi(r,t){let e=t.value,n=typeof e=="bigint"?e*Ra-uf:e*-1-1;bt(r,t.type.majorEncoded,n)}wi.encodedSize=function(t){let e=t.value,n=typeof e=="bigint"?e*Ra-uf:e*-1-1;return n<mt[0]?1:n<mt[1]?2:n<mt[2]?3:n<mt[3]?5:9};wi.compareTokens=function(t,e){return t.value<e.value?1:t.value>e.value?-1:0};function Sn(r,t,e,n){Ue(r,t,e+n);let o=Kr(r,t+e,t+e+n);return new V(x.bytes,o,e+n)}function ff(r,t,e,n){return Sn(r,t,1,e)}function hf(r,t,e,n){return Sn(r,t,2,Mt(r,t+1,n))}function df(r,t,e,n){return Sn(r,t,3,Ht(r,t+1,n))}function pf(r,t,e,n){return Sn(r,t,5,$t(r,t+1,n))}function mf(r,t,e,n){let o=Kt(r,t+1,n);if(typeof o=="bigint")throw new Error(`${H} 64-bit integer bytes lengths not supported`);return Sn(r,t,9,o)}function bi(r){return r.encodedBytes===void 0&&(r.encodedBytes=r.type===x.string?Jl(r.value):r.value),r.encodedBytes}function qr(r,t){let e=bi(t);bt(r,t.type.majorEncoded,e.length),r.push(e)}qr.encodedSize=function(t){let e=bi(t);return bt.encodedSize(e.length)+e.length};qr.compareTokens=function(t,e){return km(bi(t),bi(e))};function km(r,t){return r.length<t.length?-1:r.length>t.length?1:tf(r,t)}function In(r,t,e,n,o){let i=e+n;Ue(r,t,i);let s=new V(x.string,Yl(r,t+e,t+i),i);return o.retainStringBytes===!0&&(s.byteValue=Kr(r,t+e,t+i)),s}function gf(r,t,e,n){return In(r,t,1,e,n)}function yf(r,t,e,n){return In(r,t,2,Mt(r,t+1,n),n)}function xf(r,t,e,n){return In(r,t,3,Ht(r,t+1,n),n)}function wf(r,t,e,n){return In(r,t,5,$t(r,t+1,n),n)}function bf(r,t,e,n){let o=Kt(r,t+1,n);if(typeof o=="bigint")throw new Error(`${H} 64-bit integer string lengths not supported`);return In(r,t,9,o,n)}var vf=qr;function zr(r,t,e,n){return new V(x.array,n,e)}function Ef(r,t,e,n){return zr(r,t,1,e)}function Bf(r,t,e,n){return zr(r,t,2,Mt(r,t+1,n))}function Af(r,t,e,n){return zr(r,t,3,Ht(r,t+1,n))}function Sf(r,t,e,n){return zr(r,t,5,$t(r,t+1,n))}function If(r,t,e,n){let o=Kt(r,t+1,n);if(typeof o=="bigint")throw new Error(`${H} 64-bit integer array lengths not supported`);return zr(r,t,9,o)}function kf(r,t,e,n){if(n.allowIndefinite===!1)throw new Error(`${H} indefinite length items not allowed`);return zr(r,t,1,1/0)}function vi(r,t){bt(r,x.array.majorEncoded,t.value)}vi.compareTokens=zt.compareTokens;vi.encodedSize=function(t){return bt.encodedSize(t.value)};function jr(r,t,e,n){return new V(x.map,n,e)}function Tf(r,t,e,n){return jr(r,t,1,e)}function Cf(r,t,e,n){return jr(r,t,2,Mt(r,t+1,n))}function Nf(r,t,e,n){return jr(r,t,3,Ht(r,t+1,n))}function Uf(r,t,e,n){return jr(r,t,5,$t(r,t+1,n))}function Rf(r,t,e,n){let o=Kt(r,t+1,n);if(typeof o=="bigint")throw new Error(`${H} 64-bit integer map lengths not supported`);return jr(r,t,9,o)}function _f(r,t,e,n){if(n.allowIndefinite===!1)throw new Error(`${H} indefinite length items not allowed`);return jr(r,t,1,1/0)}function Ei(r,t){bt(r,x.map.majorEncoded,t.value)}Ei.compareTokens=zt.compareTokens;Ei.encodedSize=function(t){return bt.encodedSize(t.value)};function Lf(r,t,e,n){return new V(x.tag,e,1)}function Vf(r,t,e,n){return new V(x.tag,Mt(r,t+1,n),2)}function Pf(r,t,e,n){return new V(x.tag,Ht(r,t+1,n),3)}function Ff(r,t,e,n){return new V(x.tag,$t(r,t+1,n),5)}function Df(r,t,e,n){return new V(x.tag,Kt(r,t+1,n),9)}function Bi(r,t){bt(r,x.tag.majorEncoded,t.value)}Bi.compareTokens=zt.compareTokens;Bi.encodedSize=function(t){return bt.encodedSize(t.value)};var _m=20,Lm=21,Vm=22,Pm=23;function Of(r,t,e,n){if(n.allowUndefined===!1)throw new Error(`${H} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new V(x.null,null,1):new V(x.undefined,void 0,1)}function Mf(r,t,e,n){if(n.allowIndefinite===!1)throw new Error(`${H} indefinite length items not allowed`);return new V(x.break,void 0,1)}function _a(r,t,e){if(e){if(e.allowNaN===!1&&Number.isNaN(r))throw new Error(`${H} NaN values are not supported`);if(e.allowInfinity===!1&&(r===1/0||r===-1/0))throw new Error(`${H} Infinity values are not supported`)}return new V(x.float,r,t)}function Hf(r,t,e,n){return _a(La(r,t+1),3,n)}function $f(r,t,e,n){return _a(Va(r,t+1),5,n)}function Kf(r,t,e,n){return _a(Gf(r,t+1),9,n)}function Ai(r,t,e){let n=t.value;if(n===!1)r.push([x.float.majorEncoded|_m]);else if(n===!0)r.push([x.float.majorEncoded|Lm]);else if(n===null)r.push([x.float.majorEncoded|Vm]);else if(n===void 0)r.push([x.float.majorEncoded|Pm]);else{let o,i=!1;(!e||e.float64!==!0)&&(zf(n),o=La(ie,1),n===o||Number.isNaN(n)?(ie[0]=249,r.push(ie.slice(0,3)),i=!0):(jf(n),o=Va(ie,1),n===o&&(ie[0]=250,r.push(ie.slice(0,5)),i=!0))),i||(Fm(n),o=Gf(ie,1),ie[0]=251,r.push(ie.slice(0,9)))}}Ai.encodedSize=function(t,e){let n=t.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!e||e.float64!==!0){zf(n);let o=La(ie,1);if(n===o||Number.isNaN(n))return 3;if(jf(n),o=Va(ie,1),n===o)return 5}return 9};var qf=new ArrayBuffer(9),jt=new DataView(qf,1),ie=new Uint8Array(qf,0);function zf(r){if(r===1/0)jt.setUint16(0,31744,!1);else if(r===-1/0)jt.setUint16(0,64512,!1);else if(Number.isNaN(r))jt.setUint16(0,32256,!1);else{jt.setFloat32(0,r);let t=jt.getUint32(0),e=(t&2139095040)>>23,n=t&8388607;if(e===255)jt.setUint16(0,31744,!1);else if(e===0)jt.setUint16(0,(r&2147483648)>>16|n>>13,!1);else{let o=e-127;o<-24?jt.setUint16(0,0):o<-14?jt.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):jt.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function La(r,t){if(r.length-t<2)throw new Error(`${H} not enough data for float16`);let e=(r[t]<<8)+r[t+1];if(e===31744)return 1/0;if(e===64512)return-1/0;if(e===32256)return NaN;let n=e>>10&31,o=e&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,e&32768?-i:i}function jf(r){jt.setFloat32(0,r,!1)}function Va(r,t){if(r.length-t<4)throw new Error(`${H} not enough data for float32`);let e=(r.byteOffset||0)+t;return new DataView(r.buffer,e,4).getFloat32(0,!1)}function Fm(r){jt.setFloat64(0,r,!1)}function Gf(r,t){if(r.length-t<8)throw new Error(`${H} not enough data for float64`);let e=(r.byteOffset||0)+t;return new DataView(r.buffer,e,8).getFloat64(0,!1)}Ai.compareTokens=zt.compareTokens;function Z(r,t,e){throw new Error(`${H} encountered invalid minor (${e}) for major ${r[t]>>>5}`)}function Si(r){return()=>{throw new Error(`${H} ${r}`)}}var k=[];for(let r=0;r<=23;r++)k[r]=Z;k[24]=ef;k[25]=rf;k[26]=nf;k[27]=of;k[28]=Z;k[29]=Z;k[30]=Z;k[31]=Z;for(let r=32;r<=55;r++)k[r]=Z;k[56]=sf;k[57]=af;k[58]=cf;k[59]=lf;k[60]=Z;k[61]=Z;k[62]=Z;k[63]=Z;for(let r=64;r<=87;r++)k[r]=ff;k[88]=hf;k[89]=df;k[90]=pf;k[91]=mf;k[92]=Z;k[93]=Z;k[94]=Z;k[95]=Si("indefinite length bytes/strings are not supported");for(let r=96;r<=119;r++)k[r]=gf;k[120]=yf;k[121]=xf;k[122]=wf;k[123]=bf;k[124]=Z;k[125]=Z;k[126]=Z;k[127]=Si("indefinite length bytes/strings are not supported");for(let r=128;r<=151;r++)k[r]=Ef;k[152]=Bf;k[153]=Af;k[154]=Sf;k[155]=If;k[156]=Z;k[157]=Z;k[158]=Z;k[159]=kf;for(let r=160;r<=183;r++)k[r]=Tf;k[184]=Cf;k[185]=Nf;k[186]=Uf;k[187]=Rf;k[188]=Z;k[189]=Z;k[190]=Z;k[191]=_f;for(let r=192;r<=215;r++)k[r]=Lf;k[216]=Vf;k[217]=Pf;k[218]=Ff;k[219]=Df;k[220]=Z;k[221]=Z;k[222]=Z;k[223]=Z;for(let r=224;r<=243;r++)k[r]=Si("simple values are not supported");k[244]=Z;k[245]=Z;k[246]=Z;k[247]=Of;k[248]=Si("simple values are not supported");k[249]=Hf;k[250]=$f;k[251]=Kf;k[252]=Z;k[253]=Z;k[254]=Z;k[255]=Mf;var se=[];for(let r=0;r<24;r++)se[r]=new V(x.uint,r,1);for(let r=-1;r>=-24;r--)se[31-r]=new V(x.negint,r,1);se[64]=new V(x.bytes,new Uint8Array(0),1);se[96]=new V(x.string,"",1);se[128]=new V(x.array,0,1);se[160]=new V(x.map,0,1);se[244]=new V(x.false,!1,1);se[245]=new V(x.true,!0,1);se[246]=new V(x.null,null,1);function Om(){let r=[];return r[x.uint.major]=zt,r[x.negint.major]=wi,r[x.bytes.major]=qr,r[x.string.major]=vf,r[x.array.major]=vi,r[x.map.major]=Ei,r[x.tag.major]=Bi,r[x.float.major]=Ai,r}var Pv=Om(),Fv=new xi,Ii=class r{constructor(t,e){this.obj=t,this.parent=e}includes(t){let e=this;do if(e.obj===t)return!0;while(e=e.parent);return!1}static createCheck(t,e){if(t&&t.includes(e))throw new Error(`${Ua} object contains circular references`);return new r(e,t)}},Ye={null:new V(x.null,null),undefined:new V(x.undefined,void 0),true:new V(x.true,!0),false:new V(x.false,!1),emptyArray:new V(x.array,0),emptyMap:new V(x.map,0)},Je={number(r,t,e,n){return!Number.isInteger(r)||!Number.isSafeInteger(r)?new V(x.float,r):r>=0?new V(x.uint,r):new V(x.negint,r)},bigint(r,t,e,n){return r>=BigInt(0)?new V(x.uint,r):new V(x.negint,r)},Uint8Array(r,t,e,n){return new V(x.bytes,r)},string(r,t,e,n){return new V(x.string,r)},boolean(r,t,e,n){return r?Ye.true:Ye.false},null(r,t,e,n){return Ye.null},undefined(r,t,e,n){return Ye.undefined},ArrayBuffer(r,t,e,n){return new V(x.bytes,new Uint8Array(r))},DataView(r,t,e,n){return new V(x.bytes,new Uint8Array(r.buffer,r.byteOffset,r.byteLength))},Array(r,t,e,n){if(!r.length)return e.addBreakTokens===!0?[Ye.emptyArray,new V(x.break)]:Ye.emptyArray;n=Ii.createCheck(n,r);let o=[],i=0;for(let s of r)o[i++]=Pa(s,e,n);return e.addBreakTokens?[new V(x.array,r.length),o,new V(x.break)]:[new V(x.array,r.length),o]},Object(r,t,e,n){let o=t!=="Object",i=o?r.keys():Object.keys(r),s=o?r.size:i.length;if(!s)return e.addBreakTokens===!0?[Ye.emptyMap,new V(x.break)]:Ye.emptyMap;n=Ii.createCheck(n,r);let a=[],c=0;for(let f of i)a[c++]=[Pa(f,e,n),Pa(o?r.get(f):r[f],e,n)];return Mm(a,e),e.addBreakTokens?[new V(x.map,s),a,new V(x.break)]:[new V(x.map,s),a]}};Je.Map=Je.Object;Je.Buffer=Je.Uint8Array;for(let r of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Je[`${r}Array`]=Je.DataView;function Pa(r,t={},e){let n=zl(r),o=t&&t.typeEncoders&&t.typeEncoders[n]||Je[n];if(typeof o=="function"){let s=o(r,n,t,e);if(s!=null)return s}let i=Je[n];if(!i)throw new Error(`${Ua} unsupported type: ${n}`);return i(r,n,t,e)}function Mm(r,t){t.mapSorter&&r.sort(t.mapSorter)}var Hm={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},ki=class{constructor(t,e={}){this._pos=0,this.data=t,this.options=e}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let t=this.data[this._pos],e=se[t];if(e===void 0){let n=k[t];if(!n)throw new Error(`${H} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let o=t&31;e=n(this.data,this._pos,o,this.options)}return this._pos+=e.encodedLength,e}},kn=Symbol.for("DONE"),Ti=Symbol.for("BREAK");function $m(r,t,e){let n=[];for(let o=0;o<r.value;o++){let i=Gr(t,e);if(i===Ti){if(r.value===1/0)break;throw new Error(`${H} got unexpected break to lengthed array`)}if(i===kn)throw new Error(`${H} found array but not enough entries (got ${o}, expected ${r.value})`);n[o]=i}return n}function Km(r,t,e){let n=e.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let s=0;s<r.value;s++){let a=Gr(t,e);if(a===Ti){if(r.value===1/0)break;throw new Error(`${H} got unexpected break to lengthed map`)}if(a===kn)throw new Error(`${H} found map but not enough entries (got ${s} [no key], expected ${r.value})`);if(n!==!0&&typeof a!="string")throw new Error(`${H} non-string keys not supported (got ${typeof a})`);if(e.rejectDuplicateMapKeys===!0&&(n&&i.has(a)||!n&&a in o))throw new Error(`${H} found repeat map key "${a}"`);let c=Gr(t,e);if(c===kn)throw new Error(`${H} found map but not enough entries (got ${s} [no value], expected ${r.value})`);n?i.set(a,c):o[a]=c}return n?i:o}function Gr(r,t){if(r.done())return kn;let e=r.next();if(e.type===x.break)return Ti;if(e.type.terminal)return e.value;if(e.type===x.array)return $m(e,r,t);if(e.type===x.map)return Km(e,r,t);if(e.type===x.tag){if(t.tags&&typeof t.tags[e.value]=="function"){let n=Gr(r,t);return t.tags[e.value](n)}throw new Error(`${H} tag not supported (${e.value})`)}throw new Error("unsupported")}function Wf(r,t){if(!(r instanceof Uint8Array))throw new Error(`${H} data to decode must be a Uint8Array`);t=Object.assign({},Hm,t);let e=t.tokenizer||new ki(r,t),n=Gr(e,t);if(n===kn)throw new Error(`${H} did not find any content to decode`);if(n===Ti)throw new Error(`${H} got unexpected break`);return[n,r.subarray(e.pos())]}function Fa(r,t){let[e,n]=Wf(r,t);if(n.length>0)throw new Error(`${H} too many terminals, data makes no sense`);return e}var jm=Le("ipns:utils"),Zf=W("/ipns/");var Gm=0,Wm=18;function Yf(r){let t;if(r.pubKey!=null)try{t=Al(r.pubKey)}catch(e){throw jm.error(e),e}if(t!=null)return t}function Jf(r){let t=W("ipns-signature:");return Ot([t,r])}function hr(r){return"signatureV1"in r?oe.encode({value:W(r.value),signatureV1:r.signatureV1,validityType:r.validityType,validity:W(r.validity),sequence:r.sequence,ttl:r.ttl,pubKey:r.pubKey,signatureV2:r.signatureV2,data:r.data}):oe.encode({pubKey:r.pubKey,signatureV2:r.signatureV2,data:r.data})}function pe(r){let t=oe.decode(r);if(t.sequence!=null&&(t.sequence=BigInt(t.sequence)),t.ttl!=null&&(t.ttl=BigInt(t.ttl)),t.signatureV2==null||t.data==null)throw new ne("Missing data or signatureV2");let e=Xf(t.data),n=Zm(e.Value),o=nt(e.Validity);if(t.value!=null&&t.signatureV1!=null)return Ym(t),{value:n,validityType:oe.ValidityType.EOL,validity:o,sequence:e.Sequence,ttl:e.TTL,pubKey:t.pubKey,signatureV1:t.signatureV1,signatureV2:t.signatureV2,data:t.data};if(t.signatureV2!=null)return{value:n,validityType:oe.ValidityType.EOL,validity:o,sequence:e.Sequence,ttl:e.TTL,pubKey:t.pubKey,signatureV2:t.signatureV2,data:t.data};throw new Error("invalid record: does not include signatureV1 or signatureV2")}function Tn(r){return Ot([Zf,r.bytes])}function Re(r){let t=xe(r.slice(Zf.length));if(!Ci(t,Gm)&&!Ci(t,Wm))throw new mr("Multihash in IPNS key was not identity or sha2-256");return t}function Xf(r){let t=Fa(r);if(t.ValidityType===0)t.ValidityType=oe.ValidityType.EOL;else throw new Hr("The validity type is unsupported");return Number.isInteger(t.Sequence)&&(t.Sequence=BigInt(t.Sequence)),Number.isInteger(t.TTL)&&(t.TTL=BigInt(t.TTL)),t}function Zm(r){let t=nt(r).trim();if(t.startsWith("/"))return t;try{return`/ipfs/${X.decode(r).toV1().toString()}`}catch{}try{return`/ipfs/${X.parse(t).toV1().toString()}`}catch{}throw new mi("Value must be a valid content path starting with /")}function Ym(r){if(r.data==null)throw new gi("Record data is missing");let t=Xf(r.data);if(!ct(t.Value,r.value??new Uint8Array(0)))throw new ne('Field "value" did not match between protobuf and CBOR');if(!ct(t.Validity,r.validity??new Uint8Array(0)))throw new ne('Field "validity" did not match between protobuf and CBOR');if(t.ValidityType!==r.validityType)throw new ne('Field "validityType" did not match between protobuf and CBOR');if(t.Sequence!==r.sequence)throw new ne('Field "sequence" did not match between protobuf and CBOR');if(t.TTL!==r.ttl)throw new ne('Field "ttl" did not match between protobuf and CBOR')}function Ci(r,t){return r.code===t}var aE=Le("ipns"),cE=60*60*1e9,Xm="/ipns/",uE=Xm.length;var Qf=Vn(Na(),1);var Ni=Le("ipns:validator"),Qm=1024*10,tg=async(r,t)=>{let e=pe(t),n;try{let o=Jf(e.data);n=await r.verify(o,e.signatureV2)}catch{n=!1}if(!n)throw Ni.error("record signature verification failed"),new ne("Record signature verification failed");if(e.validityType===oe.ValidityType.EOL){if(Qf.default.fromString(e.validity).toDate().getTime()<Date.now())throw Ni.error("record has expired"),new di("record has expired")}else if(e.validityType!=null)throw Ni.error("the validity type is unsupported"),new Hr("The validity type is unsupported");Ni("ipns record for %s is valid",e.value)};async function th(r,t){if(t.byteLength>Qm)throw new pi("The record is too large");let e=Re(r),n;Ci(e,0)&&(n=oi(e));let o=pe(t),i=Yf(o)??n;if(i==null)throw new Bn("Could not extract public key from IPNS record or routing key");let s=Tn(i.toMultihash());if(!ct(r,s))throw new Bn("Embedded public key did not match routing key");await tg(i,t)}async function*Cn(r){let t=/\r?\n/,e=new TextDecoder("utf8"),n="";for await(let o of r){typeof o=="string"&&(o=new TextEncoder().encode(o)),n+=e.decode(o,{stream:!0});let i=n.split(t);n=i.pop()??"";for(let s=0;s<i.length;s++)yield JSON.parse(i[s])}n+=e.decode(),n!==""&&(yield JSON.parse(n))}function me(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var Oa=Vn(rh(),1);var Un=class extends Error{constructor(t){super(t),this.name="TimeoutError"}},Ma=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t}},nh=r=>globalThis.DOMException===void 0?new Ma(r):new DOMException(r),oh=r=>{let t=r.reason===void 0?nh("This operation was aborted."):r.reason;return t instanceof Error?t:nh(t)};function Ha(r,t){let{milliseconds:e,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout}}=t,s,c=new Promise((f,u)=>{if(typeof e!="number"||Math.sign(e)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${e}\``);if(t.signal){let{signal:h}=t;h.aborted&&u(oh(h));let g=()=>{u(oh(h))};h.addEventListener("abort",g,{once:!0}),r.finally(()=>{h.removeEventListener("abort",g)})}if(e===Number.POSITIVE_INFINITY){r.then(f,u);return}let l=new Un;s=i.setTimeout.call(void 0,()=>{if(n){try{f(n())}catch(h){u(h)}return}typeof r.cancel=="function"&&r.cancel(),o===!1?f():o instanceof Error?u(o):(l.message=o??`Promise timed out after ${e} milliseconds`,u(l))},e),(async()=>{try{f(await r)}catch(h){u(h)}})()}).finally(()=>{c.clear()});return c.clear=()=>{i.clearTimeout.call(void 0,s),s=void 0},c}function $a(r,t,e){let n=0,o=r.length;for(;o>0;){let i=Math.trunc(o/2),s=n+i;e(r[s],t)<=0?(n=++s,o-=i+1):o=i}return n}var Rn=class{#t=[];enqueue(t,e){e={priority:0,...e};let n={priority:e.priority,run:t};if(this.size&&this.#t[this.size-1].priority>=e.priority){this.#t.push(n);return}let o=$a(this.#t,n,(i,s)=>s.priority-i.priority);this.#t.splice(o,0,n)}dequeue(){return this.#t.shift()?.run}filter(t){return this.#t.filter(e=>e.priority===t.priority).map(e=>e.run)}get size(){return this.#t.length}};var _n=class extends Oa.default{#t;#r;#e=0;#a;#c;#p=0;#o;#u;#n;#m;#i=0;#l;#s;#g;timeout;constructor(t){if(super(),t={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:Rn,...t},!(typeof t.intervalCap=="number"&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${t.intervalCap?.toString()??""}\` (${typeof t.intervalCap})`);if(t.interval===void 0||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${t.interval?.toString()??""}\` (${typeof t.interval})`);this.#t=t.carryoverConcurrencyCount,this.#r=t.intervalCap===Number.POSITIVE_INFINITY||t.interval===0,this.#a=t.intervalCap,this.#c=t.interval,this.#n=new t.queueClass,this.#m=t.queueClass,this.concurrency=t.concurrency,this.timeout=t.timeout,this.#g=t.throwOnTimeout===!0,this.#s=t.autoStart===!1}get#w(){return this.#r||this.#e<this.#a}get#b(){return this.#i<this.#l}#v(){this.#i--,this.#f(),this.emit("next")}#E(){this.#x(),this.#y(),this.#u=void 0}get#B(){let t=Date.now();if(this.#o===void 0){let e=this.#p-t;if(e<0)this.#e=this.#t?this.#i:0;else return this.#u===void 0&&(this.#u=setTimeout(()=>{this.#E()},e)),!0}return!1}#f(){if(this.#n.size===0)return this.#o&&clearInterval(this.#o),this.#o=void 0,this.emit("empty"),this.#i===0&&this.emit("idle"),!1;if(!this.#s){let t=!this.#B;if(this.#w&&this.#b){let e=this.#n.dequeue();return e?(this.emit("active"),e(),t&&this.#y(),!0):!1}}return!1}#y(){this.#r||this.#o!==void 0||(this.#o=setInterval(()=>{this.#x()},this.#c),this.#p=Date.now()+this.#c)}#x(){this.#e===0&&this.#i===0&&this.#o&&(clearInterval(this.#o),this.#o=void 0),this.#e=this.#t?this.#i:0,this.#h()}#h(){for(;this.#f(););}get concurrency(){return this.#l}set concurrency(t){if(!(typeof t=="number"&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);this.#l=t,this.#h()}async#A(t){return new Promise((e,n)=>{t.addEventListener("abort",()=>{n(t.reason)},{once:!0})})}async add(t,e={}){return e={timeout:this.timeout,throwOnTimeout:this.#g,...e},new Promise((n,o)=>{this.#n.enqueue(async()=>{this.#i++,this.#e++;try{e.signal?.throwIfAborted();let i=t({signal:e.signal});e.timeout&&(i=Ha(Promise.resolve(i),{milliseconds:e.timeout})),e.signal&&(i=Promise.race([i,this.#A(e.signal)]));let s=await i;n(s),this.emit("completed",s)}catch(i){if(i instanceof Un&&!e.throwOnTimeout){n();return}o(i),this.emit("error",i)}finally{this.#v()}},e),this.emit("add"),this.#f()})}async addAll(t,e){return Promise.all(t.map(async n=>this.add(n,e)))}start(){return this.#s?(this.#s=!1,this.#h(),this):this}pause(){this.#s=!0}clear(){this.#n=new this.#m}async onEmpty(){this.#n.size!==0&&await this.#d("empty")}async onSizeLessThan(t){this.#n.size<t||await this.#d("next",()=>this.#n.size<t)}async onIdle(){this.#i===0&&this.#n.size===0||await this.#d("idle")}async#d(t,e){return new Promise(n=>{let o=()=>{e&&!e()||(this.off(t,o),n())};this.on(t,o)})}get size(){return this.#n.size}sizeBy(t){return this.#n.filter(t).length}get pending(){return this.#i}get isPaused(){return this.#s}};var Wr=class extends Error{static name="InvalidRequestError";constructor(t="Invalid request"){super(t),this.name="InvalidRequestError"}},dr=class extends Error{static name="BadResponseError";constructor(t="Bad response"){super(t),this.name="BadResponseError"}};function ng(r){return r[Symbol.asyncIterator]!=null}function og(r){if(ng(r))return(async()=>{for await(let t of r)return t})();for(let t of r)return t}var Ri=og;function ig(r){let[t,e]=r[Symbol.asyncIterator]!=null?[r[Symbol.asyncIterator](),Symbol.asyncIterator]:[r[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>t.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:t.next(),[e](){return this}}}var ih=ig;function sg(r){return r[Symbol.asyncIterator]!=null}function ag(r,t){let e=0;if(sg(r))return async function*(){for await(let c of r)yield t(c,e++)}();let n=ih(r),{value:o,done:i}=n.next();if(i===!0)return function*(){}();let s=t(o,e++);if(typeof s.then=="function")return async function*(){yield await s;for await(let c of n)yield t(c,e++)}();let a=t;return function*(){yield s;for(let c of n)yield a(c,e++)}()}var _i=ag;var sh=W("/ipns/");function ah(r){return ct(r.subarray(0,sh.byteLength),sh)}var Li=class{client;constructor(t){this.client=t}async*findProviders(t,e={}){yield*_i(this.client.getProviders(t,e),n=>({id:n.ID,multiaddrs:n.Addrs??[]}))}async provide(){}async cancelReprovide(){}async put(t,e,n){if(!ah(t))return;let o=Re(t),i=X.createV1(114,o),s=pe(e);await this.client.putIPNS(i,s,n)}async get(t,e){if(!ah(t))throw new Rt("Not found");let n=Re(t),o=X.createV1(114,n);try{let i=await this.client.getIPNS(o,e);return hr(i)}catch(i){throw i.name==="BadResponseError"?new Rt("Not found"):i}}},Vi=class{client;constructor(t){this.client=t}async findPeer(t,e={}){let n=await Ri(this.client.getPeers(t,e));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new Rt("Not found")}async*getClosestPeers(t,e={}){}};var gt=Le("delegated-routing-v1-http-api-client"),Pi={concurrentRequests:4,timeout:3e4,cacheTTL:5*60*1e3,cacheName:"delegated-routing-v1-cache"},Fi=class{started;httpQueue;shutDownController;clientUrl;timeout;contentRouting;peerRouting;filterAddrs;filterProtocols;inFlightRequests;cacheName;cache;cacheTTL;constructor(t,e={}){this.started=!1,this.shutDownController=new AbortController,yr(1/0,this.shutDownController.signal),this.httpQueue=new _n({concurrency:e.concurrentRequests??Pi.concurrentRequests}),this.inFlightRequests=new Map,this.clientUrl=t instanceof URL?t:new URL(t),this.timeout=e.timeout??Pi.timeout,this.filterAddrs=e.filterAddrs,this.filterProtocols=e.filterProtocols,this.contentRouting=new Li(this),this.peerRouting=new Vi(this),this.cacheName=e.cacheName??Pi.cacheName,this.cacheTTL=e.cacheTTL??Pi.cacheTTL}get[ac](){return this.contentRouting}get[cc](){return this.peerRouting}isStarted(){return this.started}async start(){this.started||(this.started=!0,this.cacheTTL>0&&(this.cache=await globalThis.caches?.open(this.cacheName),this.cache!=null&&gt("cache enabled with ttl %d",this.cacheTTL)))}async stop(){this.httpQueue.clear(),this.shutDownController.abort(),await globalThis.caches?.delete(this.cacheName),this.started=!1}async*getProviders(t,e={}){gt("getProviders starts: %c",t);let n=AbortSignal.timeout(this.timeout),o=En([this.shutDownController.signal,n,e.signal]);yr(1/0,n,o);let i=me(),s=me();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let a=new URL(`${this.clientUrl}routing/v1/providers/${t.toString()}`);this.#r(a,e.filterAddrs,e.filterProtocols);let c={headers:{Accept:"application/x-ndjson"},signal:o},f=await this.#e(a.toString(),c);if(f.status===404)throw new Rt("No matching records found");if(f.status===422)throw new Wr("Request does not conform to schema or semantic constraints");if(f.body==null)throw new dr("Routing response had no body");if(f.headers.get("Content-Type")==="application/json"){let l=await f.json();for(let h of l.Providers){let g=this.#t(h);g!=null&&(yield g)}}else for await(let l of Cn(hi(f.body))){let h=this.#t(l);h!=null&&(yield h)}}catch(a){gt.error("getProviders errored:",a)}finally{o.clear(),s.resolve(),gt("getProviders finished: %c",t)}}async*getPeers(t,e={}){gt("getPeers starts: %c",t);let n=AbortSignal.timeout(this.timeout),o=En([this.shutDownController.signal,n,e.signal]);yr(1/0,n,o);let i=me(),s=me();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let a=new URL(`${this.clientUrl}routing/v1/peers/${t.toCID().toString()}`);this.#r(a,e.filterAddrs,e.filterProtocols);let c={headers:{Accept:"application/x-ndjson"},signal:o},f=await this.#e(a.toString(),c);if(f.status===404)throw new Rt("No matching records found");if(f.status===422)throw new Wr("Request does not conform to schema or semantic constraints");if(f.body==null)throw new dr("Routing response had no body");if(f.headers.get("Content-Type")==="application/json"){let l=await f.json();for(let h of l.Peers){let g=this.#t(h);g!=null&&(yield g)}}else for await(let l of Cn(hi(f.body))){let h=this.#t(l);h!=null&&(yield h)}}catch(a){gt.error("getPeers errored:",a)}finally{o.clear(),s.resolve(),gt("getPeers finished: %c",t)}}async getIPNS(t,e={}){gt("getIPNS starts: %s",t);let n=AbortSignal.timeout(this.timeout),o=En([this.shutDownController.signal,n,e.signal]);yr(1/0,n,o);let i=me(),s=me();this.httpQueue.add(async()=>(i.resolve(),s.promise));let a=`${this.clientUrl}routing/v1/ipns/${t}`;try{await i.promise;let c={headers:{Accept:"application/vnd.ipfs.ipns-record"},signal:o},f=await this.#e(a,c);if(gt("getIPNS GET %s %d",a,f.status),f.status===404)throw new Rt("No matching records found");if(f.status===422)throw new Wr("Request does not conform to schema or semantic constraints");if(f.body==null)throw new dr("GET ipns response had no body");let u=await f.arrayBuffer(),l=new Uint8Array(u,0,u.byteLength);return e.validate!==!1&&await th(Tn(t.multihash),l),pe(l)}catch(c){throw gt.error("getIPNS GET %s error:",a,c),c}finally{o.clear(),s.resolve(),gt("getIPNS finished: %s",t)}}async putIPNS(t,e,n={}){gt("putIPNS starts: %c",t);let o=AbortSignal.timeout(this.timeout),i=En([this.shutDownController.signal,o,n.signal]);yr(1/0,o,i);let s=me(),a=me();this.httpQueue.add(async()=>(s.resolve(),a.promise));let c=`${this.clientUrl}routing/v1/ipns/${t}`;try{await s.promise;let f=hr(e),u={method:"PUT",headers:{"Content-Type":"application/vnd.ipfs.ipns-record"},body:f,signal:i},l=await this.#e(c,u);if(gt("putIPNS PUT %s %d",c,l.status),l.status!==200)throw new dr("PUT ipns response had status other than 200")}catch(f){throw gt.error("putIPNS PUT %s error:",c,f.stack),f}finally{i.clear(),a.resolve(),gt("putIPNS finished: %c",t)}}#t(t){try{let e=[],n=t.Addrs?.map(lr)??[];return t.Protocols!=null&&e.push(...t.Protocols),t.Protocol!=null&&(e.push(t.Protocol),delete t.Protocol),{...t,Schema:"peer",ID:kl(t.ID),Addrs:n,Protocols:e}}catch(e){gt.error("could not conform record to peer schema",e)}}#r(t,e,n){if(e!=null||this.filterAddrs!=null){let o=e?.join(",")??this.filterAddrs?.join(",")??"";o!==""&&t.searchParams.set("filter-addrs",o)}if(n!=null||this.filterProtocols!=null){let o=n?.join(",")??this.filterProtocols?.join(",")??"";o!==""&&t.searchParams.set("filter-protocols",o)}}async#e(t,e){let n=e.method??"GET",o=`${n}-${t}`;if(n==="GET"){let c=await this.cache?.match(t);if(c!=null){if(parseInt(c.headers.get("x-cache-expires")??"0",10)>Date.now())return gt("returning cached response for %s",o),c;await this.cache?.delete(t)}}let i=this.inFlightRequests.get(o);if(i!=null){let c=await i;return gt("deduplicating outgoing request for %s",o),c.clone()}let s=fetch(t,e).then(async c=>{if(this.cache!=null&&c.ok&&n==="GET"){let f=Date.now()+this.cacheTTL,u=new Headers(c.headers);u.set("x-cache-expires",f.toString());let l=new Response(c.clone().body,{status:c.status,statusText:c.statusText,headers:u});await this.cache.put(t,l)}return c}).finally(()=>{this.inFlightRequests.delete(o)});return this.inFlightRequests.set(o,s),await s}};function ch(r,t={}){return new Fi(new URL(r),t)}function Di(){return{filterProtocols:["unknown","transport-bitswap","transport-ipfs-gateway-http"],filterAddrs:["https","webtransport","webrtc","webrtc-direct","wss","tls"]}}var uh=W("/ipns/");function lh(r){return ct(r.subarray(0,uh.byteLength),uh)}var Ka=class{client;constructor(t,e={}){this.client=ch(t,e)}async provide(t,e){}async cancelReprovide(t,e){}async*findProviders(t,e){yield*_i(this.client.getProviders(t,e),n=>({id:n.ID,multiaddrs:n.Addrs,protocols:n.Protocols}))}async put(t,e,n){if(!lh(t))return;let o=Re(t),i=X.createV1(114,o),s=pe(e);await this.client.putIPNS(i,s,n)}async get(t,e){if(!lh(t))throw new Rt("Not found");let n=Re(t),o=X.createV1(114,n);try{let i=await this.client.getIPNS(o,e);return hr(i)}catch(i){throw i.name==="BadResponseError"?new Rt("Not found"):i}}async findPeer(t,e){let n=await Ri(this.client.getPeers(t,e));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new Rt("Not found")}async*getClosestPeers(t,e){}};function fh(r,t){let e=t??Di();return new Ka(new URL(r),e)}var hh="[a-fA-F\\d:]",Xe=r=>r&&r.includeBoundaries?`(?:(?<=\\s|^)(?=${hh})|(?<=${hh})(?=\\s|$))`:"",ae="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",ut="[a-fA-F\\d]{1,4}",Oi=`
8
8
  (?:
9
9
  (?:${ut}:){7}(?:${ut}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
10
- (?:${ut}:){6}(?:${se}|:${ut}|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4
11
- (?:${ut}:){5}(?::${se}|(?::${ut}){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4
12
- (?:${ut}:){4}(?:(?::${ut}){0,1}:${se}|(?::${ut}){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4
13
- (?:${ut}:){3}(?:(?::${ut}){0,2}:${se}|(?::${ut}){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4
14
- (?:${ut}:){2}(?:(?::${ut}){0,3}:${se}|(?::${ut}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4
15
- (?:${ut}:){1}(?:(?::${ut}){0,4}:${se}|(?::${ut}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
16
- (?::(?:(?::${ut}){0,5}:${se}|(?::${ut}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
10
+ (?:${ut}:){6}(?:${ae}|:${ut}|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4
11
+ (?:${ut}:){5}(?::${ae}|(?::${ut}){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4
12
+ (?:${ut}:){4}(?:(?::${ut}){0,1}:${ae}|(?::${ut}){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4
13
+ (?:${ut}:){3}(?:(?::${ut}){0,2}:${ae}|(?::${ut}){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4
14
+ (?:${ut}:){2}(?:(?::${ut}){0,3}:${ae}|(?::${ut}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4
15
+ (?:${ut}:){1}(?:(?::${ut}){0,4}:${ae}|(?::${ut}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
16
+ (?::(?:(?::${ut}){0,5}:${ae}|(?::${ut}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
17
17
  )(?:%[0-9a-zA-Z]{1,})? // %eth0 %1
18
- `.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),Fm=new RegExp(`(?:^${se}$)|(?:^${Ti}$)`),Om=new RegExp(`^${se}$`),Dm=new RegExp(`^${Ti}$`),Ta=r=>r&&r.exact?Fm:new RegExp(`(?:${Ze(r)}${se}${Ze(r)})|(?:${Ze(r)}${Ti}${Ze(r)})`,"g");Ta.v4=r=>r&&r.exact?Om:new RegExp(`${Ze(r)}${se}${Ze(r)}`,"g");Ta.v6=r=>r&&r.exact?Dm:new RegExp(`${Ze(r)}${Ti}${Ze(r)}`,"g");var Na=Ta;function Ua(r){let t=(...e)=>r(...e);return Object.defineProperty(t,"name",{value:`functionTimeout(${r.name||"<anonymous>"})`,configurable:!0}),t}function Gf(){return!1}var{toString:Mm}=Object.prototype;function Ra(r){return Mm.call(r)==="[object RegExp]"}var Zf={global:"g",ignoreCase:"i",multiline:"m",dotAll:"s",sticky:"y",unicode:"u"};function _a(r,t={}){if(!Ra(r))throw new TypeError("Expected a RegExp instance");let e=Object.keys(Zf).map(o=>(typeof t[o]=="boolean"?t[o]:r[o])?Zf[o]:"").join(""),n=new RegExp(t.source||r.source,e);return n.lastIndex=typeof t.lastIndex=="number"?t.lastIndex:r.lastIndex,n}function La(r,t,{timeout:e}={}){try{return Ua(()=>_a(r).test(t),{timeout:e})()}catch(n){if(Gf(n))return!1;throw n}}var $m=15,Hm=45,Wf={timeout:400};function Va(r){return r.length>Hm?!1:La(Na.v6({exact:!0}),r,Wf)}function Yf(r){return r.length>$m?!1:La(Na.v4({exact:!0}),r,Wf)}var Jf={http:"80",https:"443",ws:"80",wss:"443"},Km=["http","https","ws","wss"];function Xf(r,t){t=t??{};let e=t.defaultDnsType??"dns4",{scheme:n,hostname:o,port:i}=qm(r),a="/"+[zm(o,e),jm(i,n),Gm(n)].filter(c=>!!c).reduce((c,f)=>c.concat(f),[]).join("/");return sr(a)}function qm(r){let[t]=r.split(":");Km.includes(t)||(r="http"+r.substring(t.length));let{protocol:e,hostname:n,port:o}=new URL(r);if(o==null||o===""){let i=Zm(t);i!=null&&(o=i),i==null&&e==="http:"&&(o="80")}return{scheme:t,hostname:n,port:o}}function zm(r,t){if(!(r==null||r==="")){if(Yf(r))return["ip4",r];if(Va(r))return["ip6",r];if(r[0]==="["){let e=r.substring(1,r.length-1);if(Va(e))return["ip6",e]}return[t,r]}}function jm(r,t){if(!(r==null||r===""))return t==="udp"?["udp",r]:["tcp",r]}function Gm(r){if(r.match(/^tcp$|^udp$/)==null)return[r]}function Zm(r){if(!(r==null||r===""||Jf[r]==null))return Jf[r]}var Wm=["https://trustless-gateway.link","https://4everland.io"],Ym=2336;function Jm(r){return r=r.toString(),{id:al(Q.createV1(Ym,Wt.digest(Z(r)))),multiaddrs:[Xf(r)]}}var Pa=class{gateways;constructor(t={}){this.gateways=(t.gateways??Wm).map(e=>Jm(e))}async*findProviders(t,e){yield*this.gateways.toSorted(()=>Math.random()>.5?1:-1).map(n=>({...n,protocols:["transport-ipfs-gateway-http"]}))}};function Qf(r={}){return new Pa(r)}var Fa=class{libp2p;constructor(t){this.libp2p=t}async provide(t,e){await this.libp2p.contentRouting.provide(t,e)}async*findProviders(t,e){yield*this.libp2p.contentRouting.findProviders(t,e)}async put(t,e,n){await this.libp2p.contentRouting.put(t,e,n)}async get(t,e){return this.libp2p.contentRouting.get(t,e)}async findPeer(t,e){return this.libp2p.peerRouting.findPeer(t,e)}async*getClosestPeers(t,e){yield*this.libp2p.peerRouting.getClosestPeers(t,e)}};function td(r){return new Fa(r)}return pd(Xm);})();
18
+ `.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),cg=new RegExp(`(?:^${ae}$)|(?:^${Oi}$)`),ug=new RegExp(`^${ae}$`),lg=new RegExp(`^${Oi}$`),qa=r=>r&&r.exact?cg:new RegExp(`(?:${Xe(r)}${ae}${Xe(r)})|(?:${Xe(r)}${Oi}${Xe(r)})`,"g");qa.v4=r=>r&&r.exact?ug:new RegExp(`${Xe(r)}${ae}${Xe(r)}`,"g");qa.v6=r=>r&&r.exact?lg:new RegExp(`${Xe(r)}${Oi}${Xe(r)}`,"g");var za=qa;function ja(r){let t=(...e)=>r(...e);return Object.defineProperty(t,"name",{value:`functionTimeout(${r.name||"<anonymous>"})`,configurable:!0}),t}function dh(){return!1}var{toString:fg}=Object.prototype;function Ga(r){return fg.call(r)==="[object RegExp]"}var ph={global:"g",ignoreCase:"i",multiline:"m",dotAll:"s",sticky:"y",unicode:"u"};function Wa(r,t={}){if(!Ga(r))throw new TypeError("Expected a RegExp instance");let e=Object.keys(ph).map(o=>(typeof t[o]=="boolean"?t[o]:r[o])?ph[o]:"").join(""),n=new RegExp(t.source||r.source,e);return n.lastIndex=typeof t.lastIndex=="number"?t.lastIndex:r.lastIndex,n}function Za(r,t,{timeout:e}={}){try{return ja(()=>Wa(r).test(t),{timeout:e})()}catch(n){if(dh(n))return!1;throw n}}var hg=15,dg=45,mh={timeout:400};function Ya(r){return r.length>dg?!1:Za(za.v6({exact:!0}),r,mh)}function gh(r){return r.length>hg?!1:Za(za.v4({exact:!0}),r,mh)}var yh={http:"80",https:"443",ws:"80",wss:"443"},pg=["http","https","ws","wss"];function xh(r,t){t=t??{};let e=t.defaultDnsType??"dns4",{scheme:n,hostname:o,port:i}=mg(r),a="/"+[gg(o,e),yg(i,n),xg(n)].filter(c=>!!c).reduce((c,f)=>c.concat(f),[]).join("/");return lr(a)}function mg(r){let[t]=r.split(":");pg.includes(t)||(r="http"+r.substring(t.length));let{protocol:e,hostname:n,port:o}=new URL(r);if(o==null||o===""){let i=wg(t);i!=null&&(o=i),i==null&&e==="http:"&&(o="80")}return{scheme:t,hostname:n,port:o}}function gg(r,t){if(!(r==null||r==="")){if(gh(r))return["ip4",r];if(Ya(r))return["ip6",r];if(r[0]==="["){let e=r.substring(1,r.length-1);if(Ya(e))return["ip6",e]}return[t,r]}}function yg(r,t){if(!(r==null||r===""))return t==="udp"?["udp",r]:["tcp",r]}function xg(r){if(r.match(/^tcp$|^udp$/)==null)return[r]}function wg(r){if(!(r==null||r===""||yh[r]==null))return yh[r]}var bg=["https://trustless-gateway.link","https://4everland.io"],vg=2336;function Eg(r){return r=r.toString(),{id:Cl(X.createV1(vg,Zt.digest(W(r)))),multiaddrs:[xh(r)]}}var Ja=class{gateways;constructor(t={}){this.gateways=(t.gateways??bg).map(e=>Eg(e))}async*findProviders(t,e){yield*this.gateways.toSorted(()=>Math.random()>.5?1:-1).map(n=>({...n,protocols:["transport-ipfs-gateway-http"]}))}};function wh(r={}){return new Ja(r)}var Xa=class{libp2p;constructor(t){this.libp2p=t}async provide(t,e){await this.libp2p.contentRouting.provide(t,e)}async cancelReprovide(t,e){await this.libp2p.contentRouting.cancelReprovide(t,e)}async*findProviders(t,e){yield*this.libp2p.contentRouting.findProviders(t,e)}async put(t,e,n){await this.libp2p.contentRouting.put(t,e,n)}async get(t,e){return this.libp2p.contentRouting.get(t,e)}async findPeer(t,e){return this.libp2p.peerRouting.findPeer(t,e)}async*getClosestPeers(t,e){yield*this.libp2p.peerRouting.getClosestPeers(t,e)}};function bh(r){return new Xa(r)}return Lh(Bg);})();
19
19
  /*! Bundled license information:
20
20
 
21
21
  pvtsutils/build/index.js:
22
22
  (*!
23
23
  * MIT License
24
24
  *
25
- * Copyright (c) 2017-2022 Peculiar Ventures, LLC
25
+ * Copyright (c) 2017-2024 Peculiar Ventures, LLC
26
26
  *
27
27
  * Permission is hereby granted, free of charge, to any person obtaining a copy
28
28
  * of this software and associated documentation files (the "Software"), to deal
@@ -62,6 +62,9 @@ pvtsutils/build/index.js:
62
62
  @noble/curves/esm/ed25519.js:
63
63
  (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
64
64
 
65
+ @noble/hashes/esm/utils.js:
66
+ (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
67
+
65
68
  pvutils/build/utils.es.js:
66
69
  (*!
67
70
  Copyright (c) Peculiar Ventures, LLC