@helia/verified-fetch 5.0.1 → 5.0.3

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,6 +1,6 @@
1
1
  (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.HeliaVerifiedFetch = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
2
  "use strict";var HeliaVerifiedFetch=(()=>{var gF=Object.create;var F0=Object.defineProperty;var yF=Object.getOwnPropertyDescriptor;var wF=Object.getOwnPropertyNames;var xF=Object.getPrototypeOf,bF=Object.prototype.hasOwnProperty;var Rt=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Dt=(r,e)=>{for(var t in e)F0(r,t,{get:e[t],enumerable:!0})},WS=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of wF(e))!bF.call(r,o)&&o!==t&&F0(r,o,{get:()=>e[o],enumerable:!(n=yF(e,o))||n.enumerable});return r};var gt=(r,e,t)=>(t=r!=null?gF(xF(r)):{},WS(e||!r||!r.__esModule?F0(t,"default",{value:r,enumerable:!0}):t,r)),vF=r=>WS(F0({},"__esModule",{value:!0}),r);var bT=Rt(cp=>{(function(){var r,e,t,n,o,i,s,a;a=function(c){var l,f,u,h;return l=(c&255<<24)>>>24,f=(c&255<<16)>>>16,u=(c&65280)>>>8,h=c&255,[l,f,u,h].join(".")},s=function(c){var l,f,u,h,d,m;for(l=[],u=h=0;h<=3&&c.length!==0;u=++h){if(u>0){if(c[0]!==".")throw new Error("Invalid IP");c=c.substring(1)}m=e(c),d=m[0],f=m[1],c=c.substring(f),l.push(d)}if(c.length!==0)throw new Error("Invalid IP");switch(l.length){case 1:if(l[0]>4294967295)throw new Error("Invalid IP");return l[0]>>>0;case 2:if(l[0]>255||l[1]>16777215)throw new Error("Invalid IP");return(l[0]<<24|l[1])>>>0;case 3:if(l[0]>255||l[1]>255||l[2]>65535)throw new Error("Invalid IP");return(l[0]<<24|l[1]<<16|l[2])>>>0;case 4:if(l[0]>255||l[1]>255||l[2]>255||l[3]>255)throw new Error("Invalid IP");return(l[0]<<24|l[1]<<16|l[2]<<8|l[3])>>>0;default:throw new Error("Invalid IP")}},t=function(c){return c.charCodeAt(0)},n=t("0"),i=t("a"),o=t("A"),e=function(c){var l,f,u,h,d;for(h=0,l=10,f="9",u=0,c.length>1&&c[u]==="0"&&(c[u+1]==="x"||c[u+1]==="X"?(u+=2,l=16):"0"<=c[u+1]&&c[u+1]<="9"&&(u++,l=8,f="7")),d=u;u<c.length;){if("0"<=c[u]&&c[u]<=f)h=h*l+(t(c[u])-n)>>>0;else if(l===16)if("a"<=c[u]&&c[u]<="f")h=h*l+(10+t(c[u])-i)>>>0;else if("A"<=c[u]&&c[u]<="F")h=h*l+(10+t(c[u])-o)>>>0;else break;else break;if(h>4294967295)throw new Error("too large");u++}if(u===d)throw new Error("empty octet");return[h,u]},r=(function(){function c(l,f){var u,h,d,m;if(typeof l!="string")throw new Error("Missing `net' parameter");if(f||(m=l.split("/",2),l=m[0],f=m[1]),f||(f=32),typeof f=="string"&&f.indexOf(".")>-1){try{this.maskLong=s(f)}catch(y){throw u=y,new Error("Invalid mask: "+f)}for(h=d=32;d>=0;h=--d)if(this.maskLong===4294967295<<32-h>>>0){this.bitmask=h;break}}else if(f||f===0)this.bitmask=parseInt(f,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(s(l)&this.maskLong)>>>0}catch(y){throw u=y,new Error("Invalid net address: "+l)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+f);this.size=Math.pow(2,32-this.bitmask),this.base=a(this.netLong),this.mask=a(this.maskLong),this.hostmask=a(~this.maskLong),this.first=this.bitmask<=30?a(this.netLong+1):this.base,this.last=this.bitmask<=30?a(this.netLong+this.size-2):a(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?a(this.netLong+this.size-1):void 0}return c.prototype.contains=function(l){return typeof l=="string"&&(l.indexOf("/")>0||l.split(".").length!==4)&&(l=new c(l)),l instanceof c?this.contains(l.base)&&this.contains(l.broadcast||l.last):(s(l)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},c.prototype.next=function(l){return l==null&&(l=1),new c(a(this.netLong+this.size*l),this.mask)},c.prototype.forEach=function(l){var f,u,h;for(h=s(this.first),u=s(this.last),f=0;h<=u;)l(a(h),h,f),f++,h++},c.prototype.toString=function(){return this.base+"/"+this.bitmask},c})(),cp.ip2long=s,cp.long2ip=a,cp.Netmask=r}).call(cp)});var iI=Rt((ide,Sx)=>{"use strict";var Iq=Object.prototype.hasOwnProperty,dn="~";function Pp(){}Object.create&&(Pp.prototype=Object.create(null),new Pp().__proto__||(dn=!1));function kq(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function oI(r,e,t,n,o){if(typeof t!="function")throw new TypeError("The listener must be a function");var i=new kq(t,n||r,o),s=dn?dn+e:e;return r._events[s]?r._events[s].fn?r._events[s]=[r._events[s],i]:r._events[s].push(i):(r._events[s]=i,r._eventsCount++),r}function w2(r,e){--r._eventsCount===0?r._events=new Pp:delete r._events[e]}function Qr(){this._events=new Pp,this._eventsCount=0}Qr.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)Iq.call(t,n)&&e.push(dn?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};Qr.prototype.listeners=function(e){var t=dn?dn+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,i=n.length,s=new Array(i);o<i;o++)s[o]=n[o].fn;return s};Qr.prototype.listenerCount=function(e){var t=dn?dn+e:e,n=this._events[t];return n?n.fn?1:n.length:0};Qr.prototype.emit=function(e,t,n,o,i,s){var a=dn?dn+e:e;if(!this._events[a])return!1;var c=this._events[a],l=arguments.length,f,u;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,o),!0;case 5:return c.fn.call(c.context,t,n,o,i),!0;case 6:return c.fn.call(c.context,t,n,o,i,s),!0}for(u=1,f=new Array(l-1);u<l;u++)f[u-1]=arguments[u];c.fn.apply(c.context,f)}else{var h=c.length,d;for(u=0;u<h;u++)switch(c[u].once&&this.removeListener(e,c[u].fn,void 0,!0),l){case 1:c[u].fn.call(c[u].context);break;case 2:c[u].fn.call(c[u].context,t);break;case 3:c[u].fn.call(c[u].context,t,n);break;case 4:c[u].fn.call(c[u].context,t,n,o);break;default:if(!f)for(d=1,f=new Array(l-1);d<l;d++)f[d-1]=arguments[d];c[u].fn.apply(c[u].context,f)}}return!0};Qr.prototype.on=function(e,t,n){return oI(this,e,t,n,!1)};Qr.prototype.once=function(e,t,n){return oI(this,e,t,n,!0)};Qr.prototype.removeListener=function(e,t,n,o){var i=dn?dn+e:e;if(!this._events[i])return this;if(!t)return w2(this,i),this;var s=this._events[i];if(s.fn)s.fn===t&&(!o||s.once)&&(!n||s.context===n)&&w2(this,i);else{for(var a=0,c=[],l=s.length;a<l;a++)(s[a].fn!==t||o&&!s[a].once||n&&s[a].context!==n)&&c.push(s[a]);c.length?this._events[i]=c.length===1?c[0]:c:w2(this,i)}return this};Qr.prototype.removeAllListeners=function(e){var t;return e?(t=dn?dn+e:e,this._events[t]&&w2(this,t)):(this._events=new Pp,this._eventsCount=0),this};Qr.prototype.off=Qr.prototype.removeListener;Qr.prototype.addListener=Qr.prototype.on;Qr.prefixed=dn;Qr.EventEmitter=Qr;typeof Sx<"u"&&(Sx.exports=Qr)});var lI=Rt((Ide,cI)=>{cI.exports=function(r){if(!r)throw Error("hashlru must have a max value, of type number, greater than 0");var e=0,t=Object.create(null),n=Object.create(null);function o(i,s){t[i]=s,e++,e>=r&&(e=0,n=t,t=Object.create(null))}return{has:function(i){return t[i]!==void 0||n[i]!==void 0},remove:function(i){t[i]!==void 0&&(t[i]=void 0),n[i]!==void 0&&(n[i]=void 0)},get:function(i){var s=t[i];if(s!==void 0)return s;if((s=n[i])!==void 0)return o(i,s),s},set:function(i,s){t[i]!==void 0?t[i]=s:o(i,s)},clear:function(){t=Object.create(null),n=Object.create(null)}}}});var Ey=Rt((Z1e,h9)=>{var Q1e=(function(){typeof h9<"u"&&(h9.exports=y);var r=86400,e=3200,t=146097*e/400,n=r*t,o=1e3*n,i=864e13,s=4294967296,a=1e6,c="000000000",l=Math.trunc||function(T){var k=T-T%1;return k==0&&(T<0||T===0&&1/T!=1/0)?-0:k},f=y.prototype,u=(y.fromDate=function(T){return new y(+T)},y.fromInt64BE=I(0,1,2,3,0,4),y.fromInt64LE=I(3,2,1,0,4,0),y.fromString=function(W){var k,z=new y,W=(W+="").replace(/^\s*[+\-]?\d+/,function(S){var S=+S,C=1970+(S-1970)%400;return z.year=S-C,C}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function($,S,C){return S<0&&(C*=-1),k=6e4*(60*+S+ +C),""}).replace(/\.\d+$/,function($){return z.nano=+($+c).substr(1,9),""}).split(/\D+/);if(1<W.length?W[1]--:W[1]=0,z.time=k=Date.UTC.apply(Date,W)-(k||0),isNaN(k))throw new TypeError("Invalid Date");return w(z)},y.fromTimeT=function(T){return E(T,0)},f.year=0,f.time=0,f.nano=0,f.addNano=function(T){return this.nano+=+T||0,this},f.getNano=function(){var T=w(this);return(T.time%1e3*a+ +T.nano+1e9)%1e9},f.getTimeT=function(){var k=w(this),T=Math.floor(k.time/1e3),k=k.year;return k&&(T+=k*t*r/e),T},f.getYear=function(){return this.toDate().getUTCFullYear()+this.year},f.toDate=function(){return x(w(this).time)},f.toJSON=function(){return this.toString().replace(/0{1,6}Z$/,"Z")},f.toString=function(T){var k=this,z=k.toDate(),W={H:function(){return V(z.getUTCHours())},L:function(){return M(z.getUTCMilliseconds(),3)},M:function(){return V(z.getUTCMinutes())},N:function(){return M(k.getNano(),9)},S:function(){return V(z.getUTCSeconds())},Y:function(){var $=k.getYear();return 999999<$?"+"+$:9999<$?"+"+M($,6):0<=$?M($,4):-999999<=$?"-"+M(-$,6):$},a:function(){return d[z.getUTCDay()]},b:function(){return h[z.getUTCMonth()]},d:function(){return V(z.getUTCDate())},e:function(){return(function($){return(9<$?"":" ")+(0|$)})(z.getUTCDate())},m:function(){return V(z.getUTCMonth()+1)}};return(function $(S){return S.replace(/%./g,function(C){var B=C[1],_=m[B],B=W[B];return _?$(_):B?B():C})})(T||u)},f.writeInt64BE=v(0,1,2,3,0,4),f.writeInt64LE=v(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"],d=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],m={"%":"%",F:"%Y-%m-%d",n:`
3
- `,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return y;function y(T,k,z){var W=this;if(!(W instanceof y))return new y(T,k,z);W.time=+T||0,W.nano=+k||0,W.year=+z||0,w(W)}function w(T){var k,z,W,$=T.year,S=T.time,C=T.nano,_=((C<0||a<=C)&&(C-=(z=Math.floor(C/a))*a,S+=z,z=1),$%e);return(S<-i||i<S||_)&&((k=l(S/o))&&($+=k*e,S-=k*o),(W=x(S)).setUTCFullYear(_+W.getUTCFullYear()),W=(S=+W)+(k=l(($-=_)/e))*o,k&&-i<=W&&W<=i&&($-=k*e,S=W),z=1),z&&(T.year=$,T.time=S,T.nano=C),T}function x(T){var k=new Date(0);return k.setTime(T),k}function E($,W){$=+$||0;var z=l((W=(W|0)*s)/n)+l($/n),W=W%n+$%n,$=l(W/n);return $&&(z+=$,W-=$*n),new y(1e3*W,0,z*e)}function v(T,k,z,W,$,S){return function(_,B){var G=w(this);_=_||new Array(8),F(_,B|=0);var U=Math.floor(G.time/1e3),G=G.year*(t*r/e),X=l(G/s)+l(U/s),G=G%s+U%s,U=Math.floor(G/s);return U&&(X+=U,G-=U*s),C(_,B+$,X),C(_,B+S,G),_};function C(_,B,X){_[B+T]=X>>24&255,_[B+k]=X>>16&255,_[B+z]=X>>8&255,_[B+W]=255&X}}function I(T,k,z,W,$,S){return function(_,B){F(_,B|=0);var X=C(_,B+$);return E(C(_,B+S),X)};function C(_,B){return 16777216*_[B+T]+(_[B+k]<<16|_[B+z]<<8|_[B+W])}}function F(T,k){if(T=T&&T.length,T==null)throw new TypeError("Invalid Buffer");if(T<k+8)throw new RangeError("Out of range")}function V(T){return(9<T?"":"0")+(0|T)}function M(T,k){return(c+(0|T)).substr(-k)}})()});var dP=Rt((d8e,fP)=>{"use strict";function uW(r){return r>=55296&&r<=56319}function fW(r){return r>=56320&&r<=57343}fP.exports=function(e,t,n){if(typeof t!="string")throw new Error("Input must be string");for(var o=t.length,i=0,s,a,c=0;c<o;c+=1){if(s=t.charCodeAt(c),a=t[c],uW(s)&&fW(t.charCodeAt(c+1))&&(c+=1,a+=t[c]),i+=e(a),i===n)return t.slice(0,c+1);if(i>n)return t.slice(0,c-a.length+1)}return t}});var pP=Rt((h8e,hP)=>{"use strict";function dW(r){return r>=55296&&r<=56319}function hW(r){return r>=56320&&r<=57343}hP.exports=function(e){if(typeof e!="string")throw new Error("Input must be string");for(var t=e.length,n=0,o=null,i=null,s=0;s<t;s++)o=e.charCodeAt(s),hW(o)?i!=null&&dW(i)?n+=1:n+=3:o<=127?n+=1:o>=128&&o<=2047?n+=2:o>=2048&&o<=65535&&(n+=3),i=o;return n}});var gP=Rt((p8e,mP)=>{"use strict";var pW=dP(),mW=pP();mP.exports=pW.bind(null,mW)});var xP=Rt((m8e,wP)=>{"use strict";var gW=gP(),yW=/[\/\?<>\\:\*\|"]/g,wW=/[\x00-\x1f\x80-\x9f]/g,xW=/^\.+$/,bW=/^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\..*)?$/i,vW=/[\. ]+$/;function yP(r,e){if(typeof r!="string")throw new Error("Input must be string");var t=r.replace(yW,e).replace(wW,e).replace(xW,e).replace(bW,e).replace(vW,e);return gW(t,255)}wP.exports=function(r,e){var t=e&&e.replacement||"",n=yP(r,t);return t===""?n:yP(n,"")}});var Ks=Rt(Qf=>{"use strict";var SW="[object ArrayBuffer]",Hs=class r{static isArrayBuffer(e){return Object.prototype.toString.call(e)===SW}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,t){if(e.constructor===t)return e;if(this.isArrayBuffer(e))return new t(e);if(this.isArrayBufferView(e))return new t(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(e,t){let n=r.toUint8Array(e),o=r.toUint8Array(t);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(...e){let t;Array.isArray(e[0])&&!(e[1]instanceof Function)||Array.isArray(e[0])&&e[1]instanceof Function?t=e[0]:e[e.length-1]instanceof Function?t=e.slice(0,e.length-1):t=e;let n=0;for(let s of t)n+=s.byteLength;let o=new Uint8Array(n),i=0;for(let s of t){let a=this.toUint8Array(s);o.set(a,i),i+=a.length}return e[e.length-1]instanceof Function?this.toView(o,e[e.length-1]):o.buffer}},z9="string",AW=/^[0-9a-f\s]+$/i,_W=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,TW=/^[a-zA-Z0-9-_]+$/,C3=class{static fromString(e){let t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);for(let o=0;o<t.length;o++)n[o]=t.charCodeAt(o);return n.buffer}static toString(e){let t=Hs.toUint8Array(e),n="";for(let i=0;i<t.length;i++)n+=String.fromCharCode(t[i]);return decodeURIComponent(escape(n))}},Oo=class{static toString(e,t=!1){let n=Hs.toArrayBuffer(e),o=new DataView(n),i="";for(let s=0;s<n.byteLength;s+=2){let a=o.getUint16(s,t);i+=String.fromCharCode(a)}return i}static fromString(e,t=!1){let n=new ArrayBuffer(e.length*2),o=new DataView(n);for(let i=0;i<e.length;i++)o.setUint16(i*2,e.charCodeAt(i),t);return n}},I3=class r{static isHex(e){return typeof e===z9&&AW.test(e)}static isBase64(e){return typeof e===z9&&_W.test(e)}static isBase64Url(e){return typeof e===z9&&TW.test(e)}static ToString(e,t="utf8"){let n=Hs.toUint8Array(e);switch(t.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 Oo.toString(n,!0);case"utf16":case"utf16be":return Oo.toString(n);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromString(e,t="utf8"){if(!e)return new ArrayBuffer(0);switch(t.toLowerCase()){case"utf8":return this.FromUtf8String(e);case"binary":return this.FromBinary(e);case"hex":return this.FromHex(e);case"base64":return this.FromBase64(e);case"base64url":return this.FromBase64Url(e);case"utf16le":return Oo.fromString(e,!0);case"utf16":case"utf16be":return Oo.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){let t=Hs.toUint8Array(e);if(typeof btoa<"u"){let n=this.ToString(t,"binary");return btoa(n)}else return Buffer.from(t).toString("base64")}static FromBase64(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!r.isBase64(t))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob<"u"?this.FromBinary(atob(t)):new Uint8Array(Buffer.from(t,"base64")).buffer}static FromBase64Url(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!r.isBase64Url(t))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(t.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(e,t=r.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.FromBinary(e);case"utf8":return C3.fromString(e);case"utf16":case"utf16be":return Oo.fromString(e);case"utf16le":case"usc2":return Oo.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToUtf8String(e,t=r.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.ToBinary(e);case"utf8":return C3.toString(e);case"utf16":case"utf16be":return Oo.toString(e);case"utf16le":case"usc2":return Oo.toString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromBinary(e){let t=e.length,n=new Uint8Array(t);for(let o=0;o<t;o++)n[o]=e.charCodeAt(o);return n.buffer}static ToBinary(e){let t=Hs.toUint8Array(e),n="";for(let o=0;o<t.length;o++)n+=String.fromCharCode(t[o]);return n}static ToHex(e){let t=Hs.toUint8Array(e),n="",o=t.length;for(let i=0;i<o;i++){let s=t[i];s<16&&(n+="0"),n+=s.toString(16)}return n}static FromHex(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!r.isHex(t))throw new TypeError("Argument 'hexString' is not HEX encoded");t.length%2&&(t=`0${t}`);let n=new Uint8Array(t.length/2);for(let o=0;o<t.length;o=o+2){let i=t.slice(o,o+2);n[o/2]=parseInt(i,16)}return n.buffer}static ToUtf16String(e,t=!1){return Oo.toString(e,t)}static FromUtf16String(e,t=!1){return Oo.fromString(e,t)}static Base64Padding(e){let t=4-e.length%4;if(t<4)for(let n=0;n<t;n++)e+="=";return e}static formatString(e){return e?.replace(/[\n\r\t ]/g,"")||""}};I3.DEFAULT_UTF8_ENCODING="utf8";function CW(r,...e){let t=arguments[0];for(let n=1;n<arguments.length;n++){let o=arguments[n];for(let i in o)t[i]=o[i]}return t}function IW(...r){let e=r.map(o=>o.byteLength).reduce((o,i)=>o+i),t=new Uint8Array(e),n=0;return r.map(o=>new Uint8Array(o)).forEach(o=>{for(let i of o)t[n++]=i}),t.buffer}function kW(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;let t=new Uint8Array(r),n=new Uint8Array(e);for(let o=0;o<r.byteLength;o++)if(t[o]!==n[o])return!1;return!0}Qf.BufferSourceConverter=Hs;Qf.Convert=I3;Qf.assign=CW;Qf.combine=IW;Qf.isEqual=kW});var LO=Rt(Gi=>{"use strict";Object.defineProperty(Gi,"__esModule",{value:!0});Gi.parseCookie=DO;Gi.parse=DO;Gi.stringifyCookie=sX;Gi.stringifySetCookie=L4;Gi.serialize=L4;Gi.parseSetCookie=aX;Gi.stringifySetCookie=L4;Gi.serialize=L4;var RO=/^[\u0021-\u003A\u003C\u003E-\u007E]+$/,OO=/^[\u0021-\u003A\u003C-\u007E]*$/,tX=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,rX=/^[\u0020-\u003A\u003D-\u007E]*$/,nX=/^-?\d+$/,oX=Object.prototype.toString,iX=(()=>{let r=function(){};return r.prototype=Object.create(null),r})();function DO(r,e){let t=new iX,n=r.length;if(n<2)return t;let o=e?.decode||NO,i=0;do{let s=$b(r,i,n);if(s===-1)break;let a=Fb(r,i,n);if(s>a){i=r.lastIndexOf(";",s-1)+1;continue}let c=Wa(r,i,s);t[c]===void 0&&(t[c]=o(Wa(r,s+1,a))),i=a+1}while(i<n);return t}function sX(r,e){let t=e?.encode||encodeURIComponent,n=[];for(let o of Object.keys(r)){let i=r[o];if(i===void 0)continue;if(!RO.test(o))throw new TypeError(`cookie name is invalid: ${o}`);let s=t(i);if(!OO.test(s))throw new TypeError(`cookie val is invalid: ${i}`);n.push(`${o}=${s}`)}return n.join("; ")}function L4(r,e,t){let n=typeof r=="object"?r:{...t,name:r,value:String(e)},i=(typeof e=="object"?e:t)?.encode||encodeURIComponent;if(!RO.test(n.name))throw new TypeError(`argument name is invalid: ${n.name}`);let s=n.value?i(n.value):"";if(!OO.test(s))throw new TypeError(`argument val is invalid: ${n.value}`);let a=n.name+"="+s;if(n.maxAge!==void 0){if(!Number.isInteger(n.maxAge))throw new TypeError(`option maxAge is invalid: ${n.maxAge}`);a+="; Max-Age="+n.maxAge}if(n.domain){if(!tX.test(n.domain))throw new TypeError(`option domain is invalid: ${n.domain}`);a+="; Domain="+n.domain}if(n.path){if(!rX.test(n.path))throw new TypeError(`option path is invalid: ${n.path}`);a+="; Path="+n.path}if(n.expires){if(!cX(n.expires)||!Number.isFinite(n.expires.valueOf()))throw new TypeError(`option expires is invalid: ${n.expires}`);a+="; Expires="+n.expires.toUTCString()}if(n.httpOnly&&(a+="; HttpOnly"),n.secure&&(a+="; Secure"),n.partitioned&&(a+="; Partitioned"),n.priority)switch(typeof n.priority=="string"?n.priority.toLowerCase():void 0){case"low":a+="; Priority=Low";break;case"medium":a+="; Priority=Medium";break;case"high":a+="; Priority=High";break;default:throw new TypeError(`option priority is invalid: ${n.priority}`)}if(n.sameSite)switch(typeof n.sameSite=="string"?n.sameSite.toLowerCase():n.sameSite){case!0:case"strict":a+="; SameSite=Strict";break;case"lax":a+="; SameSite=Lax";break;case"none":a+="; SameSite=None";break;default:throw new TypeError(`option sameSite is invalid: ${n.sameSite}`)}return a}function aX(r,e){let t=e?.decode||NO,n=r.length,o=Fb(r,0,n),i=$b(r,0,o),s=i===-1?{name:"",value:t(Wa(r,0,o))}:{name:Wa(r,0,i),value:t(Wa(r,i+1,o))},a=o+1;for(;a<n;){let c=Fb(r,a,n),l=$b(r,a,c),f=l===-1?Wa(r,a,c):Wa(r,a,l),u=l===-1?void 0:Wa(r,l+1,c);switch(f.toLowerCase()){case"httponly":s.httpOnly=!0;break;case"secure":s.secure=!0;break;case"partitioned":s.partitioned=!0;break;case"domain":s.domain=u;break;case"path":s.path=u;break;case"max-age":u&&nX.test(u)&&(s.maxAge=Number(u));break;case"expires":if(!u)break;let h=new Date(u);Number.isFinite(h.valueOf())&&(s.expires=h);break;case"priority":if(!u)break;let d=u.toLowerCase();(d==="low"||d==="medium"||d==="high")&&(s.priority=d);break;case"samesite":if(!u)break;let m=u.toLowerCase();(m==="lax"||m==="strict"||m==="none")&&(s.sameSite=m);break}a=c+1}return s}function Fb(r,e,t){let n=r.indexOf(";",e);return n===-1?t:n}function $b(r,e,t){let n=r.indexOf("=",e);return n<t?n:-1}function Wa(r,e,t){let n=e,o=t;do{let i=r.charCodeAt(n);if(i!==32&&i!==9)break}while(++n<o);for(;o>n;){let i=r.charCodeAt(o-1);if(i!==32&&i!==9)break;o--}return r.slice(n,o)}function NO(r){if(r.indexOf("%")===-1)return r;try{return decodeURIComponent(r)}catch{return r}}function cX(r){return oX.call(r)==="[object Date]"}});var sN=Rt(()=>{var iN;(function(r){(function(e){var t=typeof globalThis=="object"||typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof this=="object"?this:a(),n=o(r);typeof t.Reflect<"u"&&(n=o(t.Reflect,n)),e(n,t),typeof t.Reflect>"u"&&(t.Reflect=r);function o(c,l){return function(f,u){Object.defineProperty(c,f,{configurable:!0,writable:!0,value:u}),l&&l(f,u)}}function i(){try{return Function("return this;")()}catch{}}function s(){try{return(0,eval)("(function() { return this; })()")}catch{}}function a(){return i()||s()}})(function(e,t){var n=Object.prototype.hasOwnProperty,o=typeof Symbol=="function",i=o&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",s=o&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",a=typeof Object.create=="function",c={__proto__:[]}instanceof Array,l=!a&&!c,f={create:a?function(){return z8(Object.create(null))}:c?function(){return z8({__proto__:null})}:function(){return z8({})},has:l?function(P,L){return n.call(P,L)}:function(P,L){return L in P},get:l?function(P,L){return n.call(P,L)?P[L]:void 0}:function(P,L){return P[L]}},u=Object.getPrototypeOf(Function),h=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:fF(),d=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:dF(),m=typeof WeakMap=="function"?WeakMap:hF(),y=o?Symbol.for("@reflect-metadata:registry"):void 0,w=cF(),x=lF(w);function E(P,L,q,te){if(K(q)){if(!ls(P))throw new TypeError;if(!fa(L))throw new TypeError;return $(P,L)}else{if(!ls(P))throw new TypeError;if(!he(L))throw new TypeError;if(!he(te)&&!K(te)&&!De(te))throw new TypeError;return De(te)&&(te=void 0),q=ct(q),S(P,L,q,te)}}e("decorate",E);function v(P,L){function q(te,Se){if(!he(te))throw new TypeError;if(!K(Se)&&!U0(Se))throw new TypeError;G(P,L,te,Se)}return q}e("metadata",v);function I(P,L,q,te){if(!he(q))throw new TypeError;return K(te)||(te=ct(te)),G(P,L,q,te)}e("defineMetadata",I);function F(P,L,q){if(!he(L))throw new TypeError;return K(q)||(q=ct(q)),C(P,L,q)}e("hasMetadata",F);function V(P,L,q){if(!he(L))throw new TypeError;return K(q)||(q=ct(q)),_(P,L,q)}e("hasOwnMetadata",V);function M(P,L,q){if(!he(L))throw new TypeError;return K(q)||(q=ct(q)),B(P,L,q)}e("getMetadata",M);function T(P,L,q){if(!he(L))throw new TypeError;return K(q)||(q=ct(q)),X(P,L,q)}e("getOwnMetadata",T);function k(P,L){if(!he(P))throw new TypeError;return K(L)||(L=ct(L)),U(P,L)}e("getMetadataKeys",k);function z(P,L){if(!he(P))throw new TypeError;return K(L)||(L=ct(L)),Q(P,L)}e("getOwnMetadataKeys",z);function W(P,L,q){if(!he(L))throw new TypeError;if(K(q)||(q=ct(q)),!he(L))throw new TypeError;K(q)||(q=ct(q));var te=vh(L,q,!1);return K(te)?!1:te.OrdinaryDeleteMetadata(P,L,q)}e("deleteMetadata",W);function $(P,L){for(var q=P.length-1;q>=0;--q){var te=P[q],Se=te(L);if(!K(Se)&&!De(Se)){if(!fa(Se))throw new TypeError;L=Se}}return L}function S(P,L,q,te){for(var Se=P.length-1;Se>=0;--Se){var zt=P[Se],ar=zt(L,q,te);if(!K(ar)&&!De(ar)){if(!he(ar))throw new TypeError;te=ar}}return te}function C(P,L,q){var te=_(P,L,q);if(te)return!0;var Se=q8(L);return De(Se)?!1:C(P,Se,q)}function _(P,L,q){var te=vh(L,q,!1);return K(te)?!1:Pt(te.OrdinaryHasOwnMetadata(P,L,q))}function B(P,L,q){var te=_(P,L,q);if(te)return X(P,L,q);var Se=q8(L);if(!De(Se))return B(P,Se,q)}function X(P,L,q){var te=vh(L,q,!1);if(!K(te))return te.OrdinaryGetOwnMetadata(P,L,q)}function G(P,L,q,te){var Se=vh(q,te,!0);Se.OrdinaryDefineOwnMetadata(P,L,q,te)}function U(P,L){var q=Q(P,L),te=q8(P);if(te===null)return q;var Se=U(te,L);if(Se.length<=0)return q;if(q.length<=0)return Se;for(var zt=new d,ar=[],Ue=0,ae=q;Ue<ae.length;Ue++){var fe=ae[Ue],pe=zt.has(fe);pe||(zt.add(fe),ar.push(fe))}for(var ye=0,$e=Se;ye<$e.length;ye++){var fe=$e[ye],pe=zt.has(fe);pe||(zt.add(fe),ar.push(fe))}return ar}function Q(P,L){var q=vh(P,L,!1);return q?q.OrdinaryOwnMetadataKeys(P,L):[]}function ne(P){if(P===null)return 1;switch(typeof P){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return P===null?1:6;default:return 6}}function K(P){return P===void 0}function De(P){return P===null}function Me(P){return typeof P=="symbol"}function he(P){return typeof P=="object"?P!==null:typeof P=="function"}function Ke(P,L){switch(ne(P)){case 0:return P;case 1:return P;case 2:return P;case 3:return P;case 4:return P;case 5:return P}var q=L===3?"string":L===5?"number":"default",te=bh(P,i);if(te!==void 0){var Se=te.call(P,q);if(he(Se))throw new TypeError;return Se}return at(P,q==="default"?"number":q)}function at(P,L){if(L==="string"){var q=P.toString;if(Go(q)){var te=q.call(P);if(!he(te))return te}var Se=P.valueOf;if(Go(Se)){var te=Se.call(P);if(!he(te))return te}}else{var Se=P.valueOf;if(Go(Se)){var te=Se.call(P);if(!he(te))return te}var zt=P.toString;if(Go(zt)){var te=zt.call(P);if(!he(te))return te}}throw new TypeError}function Pt(P){return!!P}function We(P){return""+P}function ct(P){var L=Ke(P,3);return Me(L)?L:We(L)}function ls(P){return Array.isArray?Array.isArray(P):P instanceof Object?P instanceof Array:Object.prototype.toString.call(P)==="[object Array]"}function Go(P){return typeof P=="function"}function fa(P){return typeof P=="function"}function U0(P){switch(ne(P)){case 3:return!0;case 4:return!0;default:return!1}}function Bu(P,L){return P===L||P!==P&&L!==L}function bh(P,L){var q=P[L];if(q!=null){if(!Go(q))throw new TypeError;return q}}function KS(P){var L=bh(P,s);if(!Go(L))throw new TypeError;var q=L.call(P);if(!he(q))throw new TypeError;return q}function VS(P){return P.value}function qS(P){var L=P.next();return L.done?!1:L}function zS(P){var L=P.return;L&&L.call(P)}function q8(P){var L=Object.getPrototypeOf(P);if(typeof P!="function"||P===u||L!==u)return L;var q=P.prototype,te=q&&Object.getPrototypeOf(q);if(te==null||te===Object.prototype)return L;var Se=te.constructor;return typeof Se!="function"||Se===P?L:Se}function aF(){var P;!K(y)&&typeof t.Reflect<"u"&&!(y in t.Reflect)&&typeof t.Reflect.defineMetadata=="function"&&(P=uF(t.Reflect));var L,q,te,Se=new m,zt={registerProvider:ar,getProvider:ae,setProvider:pe};return zt;function ar(ye){if(!Object.isExtensible(zt))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case P===ye:break;case K(L):L=ye;break;case L===ye:break;case K(q):q=ye;break;case q===ye:break;default:te===void 0&&(te=new d),te.add(ye);break}}function Ue(ye,$e){if(!K(L)){if(L.isProviderFor(ye,$e))return L;if(!K(q)){if(q.isProviderFor(ye,$e))return L;if(!K(te))for(var St=KS(te);;){var jt=qS(St);if(!jt)return;var Xo=VS(jt);if(Xo.isProviderFor(ye,$e))return zS(St),Xo}}}if(!K(P)&&P.isProviderFor(ye,$e))return P}function ae(ye,$e){var St=Se.get(ye),jt;return K(St)||(jt=St.get($e)),K(jt)&&(jt=Ue(ye,$e),K(jt)||(K(St)&&(St=new h,Se.set(ye,St)),St.set($e,jt))),jt}function fe(ye){if(K(ye))throw new TypeError;return L===ye||q===ye||!K(te)&&te.has(ye)}function pe(ye,$e,St){if(!fe(St))throw new Error("Metadata provider not registered.");var jt=ae(ye,$e);if(jt!==St){if(!K(jt))return!1;var Xo=Se.get(ye);K(Xo)&&(Xo=new h,Se.set(ye,Xo)),Xo.set($e,St)}return!0}}function cF(){var P;return!K(y)&&he(t.Reflect)&&Object.isExtensible(t.Reflect)&&(P=t.Reflect[y]),K(P)&&(P=aF()),!K(y)&&he(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,y,{enumerable:!1,configurable:!1,writable:!1,value:P}),P}function lF(P){var L=new m,q={isProviderFor:function(fe,pe){var ye=L.get(fe);return K(ye)?!1:ye.has(pe)},OrdinaryDefineOwnMetadata:ar,OrdinaryHasOwnMetadata:Se,OrdinaryGetOwnMetadata:zt,OrdinaryOwnMetadataKeys:Ue,OrdinaryDeleteMetadata:ae};return w.registerProvider(q),q;function te(fe,pe,ye){var $e=L.get(fe),St=!1;if(K($e)){if(!ye)return;$e=new h,L.set(fe,$e),St=!0}var jt=$e.get(pe);if(K(jt)){if(!ye)return;if(jt=new h,$e.set(pe,jt),!P.setProvider(fe,pe,q))throw $e.delete(pe),St&&L.delete(fe),new Error("Wrong provider for target.")}return jt}function Se(fe,pe,ye){var $e=te(pe,ye,!1);return K($e)?!1:Pt($e.has(fe))}function zt(fe,pe,ye){var $e=te(pe,ye,!1);if(!K($e))return $e.get(fe)}function ar(fe,pe,ye,$e){var St=te(ye,$e,!0);St.set(fe,pe)}function Ue(fe,pe){var ye=[],$e=te(fe,pe,!1);if(K($e))return ye;for(var St=$e.keys(),jt=KS(St),Xo=0;;){var jS=qS(jt);if(!jS)return ye.length=Xo,ye;var pF=VS(jS);try{ye[Xo]=pF}catch(mF){try{zS(jt)}finally{throw mF}}Xo++}}function ae(fe,pe,ye){var $e=te(pe,ye,!1);if(K($e)||!$e.delete(fe))return!1;if($e.size===0){var St=L.get(pe);K(St)||(St.delete(ye),St.size===0&&L.delete(St))}return!0}}function uF(P){var L=P.defineMetadata,q=P.hasOwnMetadata,te=P.getOwnMetadata,Se=P.getOwnMetadataKeys,zt=P.deleteMetadata,ar=new m,Ue={isProviderFor:function(ae,fe){var pe=ar.get(ae);return!K(pe)&&pe.has(fe)?!0:Se(ae,fe).length?(K(pe)&&(pe=new d,ar.set(ae,pe)),pe.add(fe),!0):!1},OrdinaryDefineOwnMetadata:L,OrdinaryHasOwnMetadata:q,OrdinaryGetOwnMetadata:te,OrdinaryOwnMetadataKeys:Se,OrdinaryDeleteMetadata:zt};return Ue}function vh(P,L,q){var te=w.getProvider(P,L);if(!K(te))return te;if(q){if(w.setProvider(P,L,x))return x;throw new Error("Illegal state.")}}function fF(){var P={},L=[],q=(function(){function Ue(ae,fe,pe){this._index=0,this._keys=ae,this._values=fe,this._selector=pe}return Ue.prototype["@@iterator"]=function(){return this},Ue.prototype[s]=function(){return this},Ue.prototype.next=function(){var ae=this._index;if(ae>=0&&ae<this._keys.length){var fe=this._selector(this._keys[ae],this._values[ae]);return ae+1>=this._keys.length?(this._index=-1,this._keys=L,this._values=L):this._index++,{value:fe,done:!1}}return{value:void 0,done:!0}},Ue.prototype.throw=function(ae){throw this._index>=0&&(this._index=-1,this._keys=L,this._values=L),ae},Ue.prototype.return=function(ae){return this._index>=0&&(this._index=-1,this._keys=L,this._values=L),{value:ae,done:!0}},Ue})(),te=(function(){function Ue(){this._keys=[],this._values=[],this._cacheKey=P,this._cacheIndex=-2}return Object.defineProperty(Ue.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),Ue.prototype.has=function(ae){return this._find(ae,!1)>=0},Ue.prototype.get=function(ae){var fe=this._find(ae,!1);return fe>=0?this._values[fe]:void 0},Ue.prototype.set=function(ae,fe){var pe=this._find(ae,!0);return this._values[pe]=fe,this},Ue.prototype.delete=function(ae){var fe=this._find(ae,!1);if(fe>=0){for(var pe=this._keys.length,ye=fe+1;ye<pe;ye++)this._keys[ye-1]=this._keys[ye],this._values[ye-1]=this._values[ye];return this._keys.length--,this._values.length--,Bu(ae,this._cacheKey)&&(this._cacheKey=P,this._cacheIndex=-2),!0}return!1},Ue.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=P,this._cacheIndex=-2},Ue.prototype.keys=function(){return new q(this._keys,this._values,Se)},Ue.prototype.values=function(){return new q(this._keys,this._values,zt)},Ue.prototype.entries=function(){return new q(this._keys,this._values,ar)},Ue.prototype["@@iterator"]=function(){return this.entries()},Ue.prototype[s]=function(){return this.entries()},Ue.prototype._find=function(ae,fe){if(!Bu(this._cacheKey,ae)){this._cacheIndex=-1;for(var pe=0;pe<this._keys.length;pe++)if(Bu(this._keys[pe],ae)){this._cacheIndex=pe;break}}return this._cacheIndex<0&&fe&&(this._cacheIndex=this._keys.length,this._keys.push(ae),this._values.push(void 0)),this._cacheIndex},Ue})();return te;function Se(Ue,ae){return Ue}function zt(Ue,ae){return ae}function ar(Ue,ae){return[Ue,ae]}}function dF(){var P=(function(){function L(){this._map=new h}return Object.defineProperty(L.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),L.prototype.has=function(q){return this._map.has(q)},L.prototype.add=function(q){return this._map.set(q,q),this},L.prototype.delete=function(q){return this._map.delete(q)},L.prototype.clear=function(){this._map.clear()},L.prototype.keys=function(){return this._map.keys()},L.prototype.values=function(){return this._map.keys()},L.prototype.entries=function(){return this._map.entries()},L.prototype["@@iterator"]=function(){return this.keys()},L.prototype[s]=function(){return this.keys()},L})();return P}function hF(){var P=16,L=f.create(),q=te();return(function(){function ae(){this._key=te()}return ae.prototype.has=function(fe){var pe=Se(fe,!1);return pe!==void 0?f.has(pe,this._key):!1},ae.prototype.get=function(fe){var pe=Se(fe,!1);return pe!==void 0?f.get(pe,this._key):void 0},ae.prototype.set=function(fe,pe){var ye=Se(fe,!0);return ye[this._key]=pe,this},ae.prototype.delete=function(fe){var pe=Se(fe,!1);return pe!==void 0?delete pe[this._key]:!1},ae.prototype.clear=function(){this._key=te()},ae})();function te(){var ae;do ae="@@WeakMap@@"+Ue();while(f.has(L,ae));return L[ae]=!0,ae}function Se(ae,fe){if(!n.call(ae,q)){if(!fe)return;Object.defineProperty(ae,q,{value:f.create()})}return ae[q]}function zt(ae,fe){for(var pe=0;pe<fe;++pe)ae[pe]=Math.random()*255|0;return ae}function ar(ae){if(typeof Uint8Array=="function"){var fe=new Uint8Array(ae);return typeof crypto<"u"?crypto.getRandomValues(fe):typeof msCrypto<"u"?msCrypto.getRandomValues(fe):zt(fe,ae),fe}return zt(new Array(ae),ae)}function Ue(){var ae=ar(P);ae[6]=ae[6]&79|64,ae[8]=ae[8]&191|128;for(var fe="",pe=0;pe<P;++pe){var ye=ae[pe];(pe===4||pe===6||pe===8)&&(fe+="-"),ye<16&&(fe+="0"),fe+=ye.toString(16).toLowerCase()}return fe}}function z8(P){return P.__=void 0,delete P.__,P}})})(iN||(iN={}))});var mL=Rt((rKe,p5)=>{var XN,YN,QN,ZN,JN,eL,tL,rL,nL,h5,dE,oL,iL,zd,sL,aL,cL,lL,uL,fL,dL,hL,pL;(function(r){var e=typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof this=="object"?this:{};typeof define=="function"&&define.amd?define("tslib",["exports"],function(n){r(t(e,t(n)))}):typeof p5=="object"&&typeof p5.exports=="object"?r(t(e,t(p5.exports))):r(t(e));function t(n,o){return n!==e&&(typeof Object.create=="function"?Object.defineProperty(n,"__esModule",{value:!0}):n.__esModule=!0),function(i,s){return n[i]=o?o(i,s):s}}})(function(r){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var o in n)n.hasOwnProperty(o)&&(t[o]=n[o])};XN=function(t,n){e(t,n);function o(){this.constructor=t}t.prototype=n===null?Object.create(n):(o.prototype=n.prototype,new o)},YN=Object.assign||function(t){for(var n,o=1,i=arguments.length;o<i;o++){n=arguments[o];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},QN=function(t,n){var o={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&n.indexOf(i)<0&&(o[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(t);s<i.length;s++)n.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(o[i[s]]=t[i[s]]);return o},ZN=function(t,n,o,i){var s=arguments.length,a=s<3?n:i===null?i=Object.getOwnPropertyDescriptor(n,o):i,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,n,o,i);else for(var l=t.length-1;l>=0;l--)(c=t[l])&&(a=(s<3?c(a):s>3?c(n,o,a):c(n,o))||a);return s>3&&a&&Object.defineProperty(n,o,a),a},JN=function(t,n){return function(o,i){n(o,i,t)}},eL=function(t,n){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,n)},tL=function(t,n,o,i){function s(a){return a instanceof o?a:new o(function(c){c(a)})}return new(o||(o=Promise))(function(a,c){function l(h){try{u(i.next(h))}catch(d){c(d)}}function f(h){try{u(i.throw(h))}catch(d){c(d)}}function u(h){h.done?a(h.value):s(h.value).then(l,f)}u((i=i.apply(t,n||[])).next())})},rL=function(t,n){var o={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,s,a,c;return c={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(c[Symbol.iterator]=function(){return this}),c;function l(u){return function(h){return f([u,h])}}function f(u){if(i)throw new TypeError("Generator is already executing.");for(;o;)try{if(i=1,s&&(a=u[0]&2?s.return:u[0]?s.throw||((a=s.return)&&a.call(s),0):s.next)&&!(a=a.call(s,u[1])).done)return a;switch(s=0,a&&(u=[u[0]&2,a.value]),u[0]){case 0:case 1:a=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,s=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(a=o.trys,!(a=a.length>0&&a[a.length-1])&&(u[0]===6||u[0]===2)){o=0;continue}if(u[0]===3&&(!a||u[1]>a[0]&&u[1]<a[3])){o.label=u[1];break}if(u[0]===6&&o.label<a[1]){o.label=a[1],a=u;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(u);break}a[2]&&o.ops.pop(),o.trys.pop();continue}u=n.call(t,o)}catch(h){u=[6,h],s=0}finally{i=a=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}},pL=function(t,n,o,i){i===void 0&&(i=o),t[i]=n[o]},nL=function(t,n){for(var o in t)o!=="default"&&!n.hasOwnProperty(o)&&(n[o]=t[o])},h5=function(t){var n=typeof Symbol=="function"&&Symbol.iterator,o=n&&t[n],i=0;if(o)return o.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")},dE=function(t,n){var o=typeof Symbol=="function"&&t[Symbol.iterator];if(!o)return t;var i=o.call(t),s,a=[],c;try{for(;(n===void 0||n-- >0)&&!(s=i.next()).done;)a.push(s.value)}catch(l){c={error:l}}finally{try{s&&!s.done&&(o=i.return)&&o.call(i)}finally{if(c)throw c.error}}return a},oL=function(){for(var t=[],n=0;n<arguments.length;n++)t=t.concat(dE(arguments[n]));return t},iL=function(){for(var t=0,n=0,o=arguments.length;n<o;n++)t+=arguments[n].length;for(var i=Array(t),s=0,n=0;n<o;n++)for(var a=arguments[n],c=0,l=a.length;c<l;c++,s++)i[s]=a[c];return i},zd=function(t){return this instanceof zd?(this.v=t,this):new zd(t)},sL=function(t,n,o){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=o.apply(t,n||[]),s,a=[];return s={},c("next"),c("throw"),c("return"),s[Symbol.asyncIterator]=function(){return this},s;function c(m){i[m]&&(s[m]=function(y){return new Promise(function(w,x){a.push([m,y,w,x])>1||l(m,y)})})}function l(m,y){try{f(i[m](y))}catch(w){d(a[0][3],w)}}function f(m){m.value instanceof zd?Promise.resolve(m.value.v).then(u,h):d(a[0][2],m)}function u(m){l("next",m)}function h(m){l("throw",m)}function d(m,y){m(y),a.shift(),a.length&&l(a[0][0],a[0][1])}},aL=function(t){var n,o;return n={},i("next"),i("throw",function(s){throw s}),i("return"),n[Symbol.iterator]=function(){return this},n;function i(s,a){n[s]=t[s]?function(c){return(o=!o)?{value:zd(t[s](c)),done:s==="return"}:a?a(c):c}:a}},cL=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=t[Symbol.asyncIterator],o;return n?n.call(t):(t=typeof h5=="function"?h5(t):t[Symbol.iterator](),o={},i("next"),i("throw"),i("return"),o[Symbol.asyncIterator]=function(){return this},o);function i(a){o[a]=t[a]&&function(c){return new Promise(function(l,f){c=t[a](c),s(l,f,c.done,c.value)})}}function s(a,c,l,f){Promise.resolve(f).then(function(u){a({value:u,done:l})},c)}},lL=function(t,n){return Object.defineProperty?Object.defineProperty(t,"raw",{value:n}):t.raw=n,t},uL=function(t){if(t&&t.__esModule)return t;var n={};if(t!=null)for(var o in t)Object.hasOwnProperty.call(t,o)&&(n[o]=t[o]);return n.default=t,n},fL=function(t){return t&&t.__esModule?t:{default:t}},dL=function(t,n){if(!n.has(t))throw new TypeError("attempted to get private field on non-instance");return n.get(t)},hL=function(t,n,o){if(!n.has(t))throw new TypeError("attempted to set private field on non-instance");return n.set(t,o),o},r("__extends",XN),r("__assign",YN),r("__rest",QN),r("__decorate",ZN),r("__param",JN),r("__metadata",eL),r("__awaiter",tL),r("__generator",rL),r("__exportStar",nL),r("__createBinding",pL),r("__values",h5),r("__read",dE),r("__spread",oL),r("__spreadArrays",iL),r("__await",zd),r("__asyncGenerator",sL),r("__asyncDelegator",aL),r("__asyncValues",cL),r("__makeTemplateObject",lL),r("__importStar",uL),r("__importDefault",fL),r("__classPrivateFieldGet",dL),r("__classPrivateFieldSet",hL)})});var fM=Rt((VYe,uM)=>{uM.exports=fS;var lM=128,LQ=127,BQ=~LQ,MQ=Math.pow(2,31);function fS(r,e,t){if(Number.MAX_SAFE_INTEGER&&r>Number.MAX_SAFE_INTEGER)throw fS.bytes=0,new RangeError("Could not encode varint");e=e||[],t=t||0;for(var n=t;r>=MQ;)e[t++]=r&255|lM,r/=128;for(;r&BQ;)e[t++]=r&255|lM,r>>>=7;return e[t]=r|0,fS.bytes=t-n+1,e}});var pM=Rt((qYe,hM)=>{hM.exports=dS;var UQ=128,dM=127;function dS(r,n){var t=0,n=n||0,o=0,i=n,s,a=r.length;do{if(i>=a||o>49)throw dS.bytes=0,new RangeError("Could not decode varint");s=r[i++],t+=o<28?(s&dM)<<o:(s&dM)*Math.pow(2,o),o+=7}while(s>=UQ);return dS.bytes=i-n,t}});var gM=Rt((zYe,mM)=>{var FQ=Math.pow(2,7),$Q=Math.pow(2,14),HQ=Math.pow(2,21),KQ=Math.pow(2,28),VQ=Math.pow(2,35),qQ=Math.pow(2,42),zQ=Math.pow(2,49),jQ=Math.pow(2,56),WQ=Math.pow(2,63);mM.exports=function(r){return r<FQ?1:r<$Q?2:r<HQ?3:r<KQ?4:r<VQ?5:r<qQ?6:r<zQ?7:r<jQ?8:r<WQ?9:10}});var r8=Rt((jYe,yM)=>{yM.exports={encode:fM(),decode:pM(),encodingLength:gM()}});var BM=Rt((T0,g8)=>{(function(r,e){"use strict";var t={version:"3.0.0",x86:{},x64:{},inputValidation:!0};function n(d){if(!Array.isArray(d)&&!ArrayBuffer.isView(d))return!1;for(var m=0;m<d.length;m++)if(!Number.isInteger(d[m])||d[m]<0||d[m]>255)return!1;return!0}function o(d,m){return(d&65535)*m+(((d>>>16)*m&65535)<<16)}function i(d,m){return d<<m|d>>>32-m}function s(d){return d^=d>>>16,d=o(d,2246822507),d^=d>>>13,d=o(d,3266489909),d^=d>>>16,d}function a(d,m){d=[d[0]>>>16,d[0]&65535,d[1]>>>16,d[1]&65535],m=[m[0]>>>16,m[0]&65535,m[1]>>>16,m[1]&65535];var y=[0,0,0,0];return y[3]+=d[3]+m[3],y[2]+=y[3]>>>16,y[3]&=65535,y[2]+=d[2]+m[2],y[1]+=y[2]>>>16,y[2]&=65535,y[1]+=d[1]+m[1],y[0]+=y[1]>>>16,y[1]&=65535,y[0]+=d[0]+m[0],y[0]&=65535,[y[0]<<16|y[1],y[2]<<16|y[3]]}function c(d,m){d=[d[0]>>>16,d[0]&65535,d[1]>>>16,d[1]&65535],m=[m[0]>>>16,m[0]&65535,m[1]>>>16,m[1]&65535];var y=[0,0,0,0];return y[3]+=d[3]*m[3],y[2]+=y[3]>>>16,y[3]&=65535,y[2]+=d[2]*m[3],y[1]+=y[2]>>>16,y[2]&=65535,y[2]+=d[3]*m[2],y[1]+=y[2]>>>16,y[2]&=65535,y[1]+=d[1]*m[3],y[0]+=y[1]>>>16,y[1]&=65535,y[1]+=d[2]*m[2],y[0]+=y[1]>>>16,y[1]&=65535,y[1]+=d[3]*m[1],y[0]+=y[1]>>>16,y[1]&=65535,y[0]+=d[0]*m[3]+d[1]*m[2]+d[2]*m[1]+d[3]*m[0],y[0]&=65535,[y[0]<<16|y[1],y[2]<<16|y[3]]}function l(d,m){return m%=64,m===32?[d[1],d[0]]:m<32?[d[0]<<m|d[1]>>>32-m,d[1]<<m|d[0]>>>32-m]:(m-=32,[d[1]<<m|d[0]>>>32-m,d[0]<<m|d[1]>>>32-m])}function f(d,m){return m%=64,m===0?d:m<32?[d[0]<<m|d[1]>>>32-m,d[1]<<m]:[d[1]<<m-32,0]}function u(d,m){return[d[0]^m[0],d[1]^m[1]]}function h(d){return d=u(d,[0,d[0]>>>1]),d=c(d,[4283543511,3981806797]),d=u(d,[0,d[0]>>>1]),d=c(d,[3301882366,444984403]),d=u(d,[0,d[0]>>>1]),d}t.x86.hash32=function(d,m){if(t.inputValidation&&!n(d))return e;m=m||0;for(var y=d.length%4,w=d.length-y,x=m,E=0,v=3432918353,I=461845907,F=0;F<w;F=F+4)E=d[F]|d[F+1]<<8|d[F+2]<<16|d[F+3]<<24,E=o(E,v),E=i(E,15),E=o(E,I),x^=E,x=i(x,13),x=o(x,5)+3864292196;switch(E=0,y){case 3:E^=d[F+2]<<16;case 2:E^=d[F+1]<<8;case 1:E^=d[F],E=o(E,v),E=i(E,15),E=o(E,I),x^=E}return x^=d.length,x=s(x),x>>>0},t.x86.hash128=function(d,m){if(t.inputValidation&&!n(d))return e;m=m||0;for(var y=d.length%16,w=d.length-y,x=m,E=m,v=m,I=m,F=0,V=0,M=0,T=0,k=597399067,z=2869860233,W=951274213,$=2716044179,S=0;S<w;S=S+16)F=d[S]|d[S+1]<<8|d[S+2]<<16|d[S+3]<<24,V=d[S+4]|d[S+5]<<8|d[S+6]<<16|d[S+7]<<24,M=d[S+8]|d[S+9]<<8|d[S+10]<<16|d[S+11]<<24,T=d[S+12]|d[S+13]<<8|d[S+14]<<16|d[S+15]<<24,F=o(F,k),F=i(F,15),F=o(F,z),x^=F,x=i(x,19),x+=E,x=o(x,5)+1444728091,V=o(V,z),V=i(V,16),V=o(V,W),E^=V,E=i(E,17),E+=v,E=o(E,5)+197830471,M=o(M,W),M=i(M,17),M=o(M,$),v^=M,v=i(v,15),v+=I,v=o(v,5)+2530024501,T=o(T,$),T=i(T,18),T=o(T,k),I^=T,I=i(I,13),I+=x,I=o(I,5)+850148119;switch(F=0,V=0,M=0,T=0,y){case 15:T^=d[S+14]<<16;case 14:T^=d[S+13]<<8;case 13:T^=d[S+12],T=o(T,$),T=i(T,18),T=o(T,k),I^=T;case 12:M^=d[S+11]<<24;case 11:M^=d[S+10]<<16;case 10:M^=d[S+9]<<8;case 9:M^=d[S+8],M=o(M,W),M=i(M,17),M=o(M,$),v^=M;case 8:V^=d[S+7]<<24;case 7:V^=d[S+6]<<16;case 6:V^=d[S+5]<<8;case 5:V^=d[S+4],V=o(V,z),V=i(V,16),V=o(V,W),E^=V;case 4:F^=d[S+3]<<24;case 3:F^=d[S+2]<<16;case 2:F^=d[S+1]<<8;case 1:F^=d[S],F=o(F,k),F=i(F,15),F=o(F,z),x^=F}return x^=d.length,E^=d.length,v^=d.length,I^=d.length,x+=E,x+=v,x+=I,E+=x,v+=x,I+=x,x=s(x),E=s(E),v=s(v),I=s(I),x+=E,x+=v,x+=I,E+=x,v+=x,I+=x,("00000000"+(x>>>0).toString(16)).slice(-8)+("00000000"+(E>>>0).toString(16)).slice(-8)+("00000000"+(v>>>0).toString(16)).slice(-8)+("00000000"+(I>>>0).toString(16)).slice(-8)},t.x64.hash128=function(d,m){if(t.inputValidation&&!n(d))return e;m=m||0;for(var y=d.length%16,w=d.length-y,x=[0,m],E=[0,m],v=[0,0],I=[0,0],F=[2277735313,289559509],V=[1291169091,658871167],M=0;M<w;M=M+16)v=[d[M+4]|d[M+5]<<8|d[M+6]<<16|d[M+7]<<24,d[M]|d[M+1]<<8|d[M+2]<<16|d[M+3]<<24],I=[d[M+12]|d[M+13]<<8|d[M+14]<<16|d[M+15]<<24,d[M+8]|d[M+9]<<8|d[M+10]<<16|d[M+11]<<24],v=c(v,F),v=l(v,31),v=c(v,V),x=u(x,v),x=l(x,27),x=a(x,E),x=a(c(x,[0,5]),[0,1390208809]),I=c(I,V),I=l(I,33),I=c(I,F),E=u(E,I),E=l(E,31),E=a(E,x),E=a(c(E,[0,5]),[0,944331445]);switch(v=[0,0],I=[0,0],y){case 15:I=u(I,f([0,d[M+14]],48));case 14:I=u(I,f([0,d[M+13]],40));case 13:I=u(I,f([0,d[M+12]],32));case 12:I=u(I,f([0,d[M+11]],24));case 11:I=u(I,f([0,d[M+10]],16));case 10:I=u(I,f([0,d[M+9]],8));case 9:I=u(I,[0,d[M+8]]),I=c(I,V),I=l(I,33),I=c(I,F),E=u(E,I);case 8:v=u(v,f([0,d[M+7]],56));case 7:v=u(v,f([0,d[M+6]],48));case 6:v=u(v,f([0,d[M+5]],40));case 5:v=u(v,f([0,d[M+4]],32));case 4:v=u(v,f([0,d[M+3]],24));case 3:v=u(v,f([0,d[M+2]],16));case 2:v=u(v,f([0,d[M+1]],8));case 1:v=u(v,[0,d[M]]),v=c(v,F),v=l(v,31),v=c(v,V),x=u(x,v)}return x=u(x,[0,d.length]),E=u(E,[0,d.length]),x=a(x,E),E=a(E,x),x=h(x),E=h(E),x=a(x,E),E=a(E,x),("00000000"+(x[0]>>>0).toString(16)).slice(-8)+("00000000"+(x[1]>>>0).toString(16)).slice(-8)+("00000000"+(E[0]>>>0).toString(16)).slice(-8)+("00000000"+(E[1]>>>0).toString(16)).slice(-8)},typeof T0<"u"?(typeof g8<"u"&&g8.exports&&(T0=g8.exports=t),T0.murmurHash3=t):typeof define=="function"&&define.amd?define([],function(){return t}):(t._murmurHash3=r.murmurHash3,t.noConflict=function(){return r.murmurHash3=t._murmurHash3,t._murmurHash3=e,t.noConflict=e,t},r.murmurHash3=t)})(T0)});var UM=Rt((GZe,MM)=>{MM.exports=BM()});var KM=Rt((tJe,HM)=>{"use strict";HM.exports=class{constructor(){this._bitArrays=[],this._data=[],this._length=0,this._changedLength=!1,this._changedData=!1}set(e,t){let n=this._internalPositionFor(e,!1);if(t===void 0)n!==-1&&(this._unsetInternalPos(n),this._unsetBit(e),this._changedLength=!0,this._changedData=!0);else{let o=!1;n===-1?(n=this._data.length,this._setBit(e),this._changedData=!0):o=!0,this._setInternalPos(n,e,t,o),this._changedLength=!0}}unset(e){this.set(e,void 0)}get(e){this._sortData();let t=this._internalPositionFor(e,!0);if(t!==-1)return this._data[t][1]}push(e){return this.set(this.length,e),this.length}get length(){if(this._sortData(),this._changedLength){let e=this._data[this._data.length-1];this._length=e?e[0]+1:0,this._changedLength=!1}return this._length}forEach(e){let t=0;for(;t<this.length;)e(this.get(t),t,this),t++}map(e){let t=0,n=new Array(this.length);for(;t<this.length;)n[t]=e(this.get(t),t,this),t++;return n}reduce(e,t){let n=0,o=t;for(;n<this.length;){let i=this.get(n);o=e(o,i,n),n++}return o}find(e){let t=0,n,o;for(;t<this.length&&!n;)o=this.get(t),n=e(o),t++;return n?o:void 0}_internalPositionFor(e,t){let n=this._bytePosFor(e,t);if(n>=this._bitArrays.length)return-1;let o=this._bitArrays[n],i=e-n*7;if(!((o&1<<i)>0))return-1;let a=this._bitArrays.slice(0,n).reduce(bZ,0),c=~(4294967295<<i+1),l=$M(o&c);return a+l-1}_bytePosFor(e,t){let n=Math.floor(e/7),o=n+1;for(;!t&&this._bitArrays.length<o;)this._bitArrays.push(0);return n}_setBit(e){let t=this._bytePosFor(e,!1);this._bitArrays[t]|=1<<e-t*7}_unsetBit(e){let t=this._bytePosFor(e,!1);this._bitArrays[t]&=~(1<<e-t*7)}_setInternalPos(e,t,n,o){let i=this._data,s=[t,n];if(o)this._sortData(),i[e]=s;else{if(i.length)if(i[i.length-1][0]>=t)i.push(s);else if(i[0][0]<=t)i.unshift(s);else{let a=Math.round(i.length/2);this._data=i.slice(0,a).concat(s).concat(i.slice(a))}else this._data.push(s);this._changedData=!0,this._changedLength=!0}}_unsetInternalPos(e){this._data.splice(e,1)}_sortData(){this._changedData&&this._data.sort(vZ),this._changedData=!1}bitField(){let e=[],t=8,n=0,o=0,i,s=this._bitArrays.slice();for(;s.length||n;){n===0&&(i=s.shift(),n=7);let c=Math.min(n,t),l=~(255<<c),f=i&l;o|=f<<8-t,i=i>>>c,n-=c,t-=c,(!t||!n&&!s.length)&&(e.push(o),o=0,t=8)}for(var a=e.length-1;a>0&&e[a]===0;a--)e.pop();return e}compactArray(){return this._sortData(),this._data.map(EZ)}};function bZ(r,e){return r+$M(e)}function $M(r){let e=r;return e=e-(e>>1&1431655765),e=(e&858993459)+(e>>2&858993459),(e+(e>>4)&252645135)*16843009>>24}function vZ(r,e){return r[0]-e[0]}function EZ(r){return r[1]}});var wU=Rt((Ftt,yU)=>{"use strict";yU.exports={RTLD_LAZY:1,RTLD_NOW:2,RTLD_GLOBAL:256,RTLD_LOCAL:0,RTLD_DEEPBIND:8,E2BIG:7,EACCES:13,EADDRINUSE:98,EADDRNOTAVAIL:99,EAFNOSUPPORT:97,EAGAIN:11,EALREADY:114,EBADF:9,EBADMSG:74,EBUSY:16,ECANCELED:125,ECHILD:10,ECONNABORTED:103,ECONNREFUSED:111,ECONNRESET:104,EDEADLK:35,EDESTADDRREQ:89,EDOM:33,EDQUOT:122,EEXIST:17,EFAULT:14,EFBIG:27,EHOSTUNREACH:113,EIDRM:43,EILSEQ:84,EINPROGRESS:115,EINTR:4,EINVAL:22,EIO:5,EISCONN:106,EISDIR:21,ELOOP:40,EMFILE:24,EMLINK:31,EMSGSIZE:90,EMULTIHOP:72,ENAMETOOLONG:36,ENETDOWN:100,ENETRESET:102,ENETUNREACH:101,ENFILE:23,ENOBUFS:105,ENODATA:61,ENODEV:19,ENOENT:2,ENOEXEC:8,ENOLCK:37,ENOLINK:67,ENOMEM:12,ENOMSG:42,ENOPROTOOPT:92,ENOSPC:28,ENOSR:63,ENOSTR:60,ENOSYS:38,ENOTCONN:107,ENOTDIR:20,ENOTEMPTY:39,ENOTSOCK:88,ENOTSUP:95,ENOTTY:25,ENXIO:6,EOPNOTSUPP:95,EOVERFLOW:75,EPERM:1,EPIPE:32,EPROTO:71,EPROTONOSUPPORT:93,EPROTOTYPE:91,ERANGE:34,EROFS:30,ESPIPE:29,ESRCH:3,ESTALE:116,ETIME:62,ETIMEDOUT:110,ETXTBSY:26,EWOULDBLOCK:11,EXDEV:18,PRIORITY_LOW:19,PRIORITY_BELOW_NORMAL:10,PRIORITY_NORMAL:0,PRIORITY_ABOVE_NORMAL:-7,PRIORITY_HIGH:-14,PRIORITY_HIGHEST:-20,SIGHUP:1,SIGINT:2,SIGQUIT:3,SIGILL:4,SIGTRAP:5,SIGABRT:6,SIGIOT:6,SIGBUS:7,SIGFPE:8,SIGKILL:9,SIGUSR1:10,SIGSEGV:11,SIGUSR2:12,SIGPIPE:13,SIGALRM:14,SIGTERM:15,SIGCHLD:17,SIGSTKFLT:16,SIGCONT:18,SIGSTOP:19,SIGTSTP:20,SIGTTIN:21,SIGTTOU:22,SIGURG:23,SIGXCPU:24,SIGXFSZ:25,SIGVTALRM:26,SIGPROF:27,SIGWINCH:28,SIGIO:29,SIGPOLL:29,SIGPWR:30,SIGSYS:31,UV_FS_SYMLINK_DIR:1,UV_FS_SYMLINK_JUNCTION:2,O_RDONLY:0,O_WRONLY:1,O_RDWR:2,UV_DIRENT_UNKNOWN:0,UV_DIRENT_FILE:1,UV_DIRENT_DIR:2,UV_DIRENT_LINK:3,UV_DIRENT_FIFO:4,UV_DIRENT_SOCKET:5,UV_DIRENT_CHAR:6,UV_DIRENT_BLOCK:7,S_IFMT:61440,S_IFREG:32768,S_IFDIR:16384,S_IFCHR:8192,S_IFBLK:24576,S_IFIFO:4096,S_IFLNK:40960,S_IFSOCK:49152,O_CREAT:64,O_EXCL:128,UV_FS_O_FILEMAP:0,O_NOCTTY:256,O_TRUNC:512,O_APPEND:1024,O_DIRECTORY:65536,O_NOATIME:262144,O_NOFOLLOW:131072,O_SYNC:1052672,O_DSYNC:4096,O_DIRECT:16384,O_NONBLOCK:2048,S_IRWXU:448,S_IRUSR:256,S_IWUSR:128,S_IXUSR:64,S_IRWXG:56,S_IRGRP:32,S_IWGRP:16,S_IXGRP:8,S_IRWXO:7,S_IROTH:4,S_IWOTH:2,S_IXOTH:1,F_OK:0,R_OK:4,W_OK:2,X_OK:1,UV_FS_COPYFILE_EXCL:1,COPYFILE_EXCL:1,UV_FS_COPYFILE_FICLONE:2,COPYFILE_FICLONE:2,UV_FS_COPYFILE_FICLONE_FORCE:4,COPYFILE_FICLONE_FORCE:4,OPENSSL_VERSION_NUMBER:810549312,SSL_OP_ALL:2147485776,SSL_OP_ALLOW_NO_DHE_KEX:1024,SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION:262144,SSL_OP_CIPHER_SERVER_PREFERENCE:4194304,SSL_OP_CISCO_ANYCONNECT:32768,SSL_OP_COOKIE_EXCHANGE:8192,SSL_OP_CRYPTOPRO_TLSEXT_BUG:2147483648,SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS:2048,SSL_OP_LEGACY_SERVER_CONNECT:4,SSL_OP_NO_COMPRESSION:131072,SSL_OP_NO_ENCRYPT_THEN_MAC:524288,SSL_OP_NO_QUERY_MTU:4096,SSL_OP_NO_RENEGOTIATION:1073741824,SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION:65536,SSL_OP_NO_SSLv2:0,SSL_OP_NO_SSLv3:33554432,SSL_OP_NO_TICKET:16384,SSL_OP_NO_TLSv1:67108864,SSL_OP_NO_TLSv1_1:268435456,SSL_OP_NO_TLSv1_2:134217728,SSL_OP_NO_TLSv1_3:536870912,SSL_OP_PRIORITIZE_CHACHA:2097152,SSL_OP_TLS_ROLLBACK_BUG:8388608,ENGINE_METHOD_RSA:1,ENGINE_METHOD_DSA:2,ENGINE_METHOD_DH:4,ENGINE_METHOD_RAND:8,ENGINE_METHOD_EC:2048,ENGINE_METHOD_CIPHERS:64,ENGINE_METHOD_DIGESTS:128,ENGINE_METHOD_PKEY_METHS:512,ENGINE_METHOD_PKEY_ASN1_METHS:1024,ENGINE_METHOD_ALL:65535,ENGINE_METHOD_NONE:0,DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8,RSA_PKCS1_PADDING:1,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_X931_PADDING:5,RSA_PKCS1_PSS_PADDING:6,RSA_PSS_SALTLEN_DIGEST:-1,RSA_PSS_SALTLEN_MAX_SIGN:-2,RSA_PSS_SALTLEN_AUTO:-2,defaultCoreCipherList:"TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:DHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA256:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!SRP:!CAMELLIA",TLS1_VERSION:769,TLS1_1_VERSION:770,TLS1_2_VERSION:771,TLS1_3_VERSION:772,POINT_CONVERSION_COMPRESSED:2,POINT_CONVERSION_UNCOMPRESSED:4,POINT_CONVERSION_HYBRID:6}});var PU=Rt(RS=>{RS.read=function(r,e,t,n,o){var i,s,a=o*8-n-1,c=(1<<a)-1,l=c>>1,f=-7,u=t?o-1:0,h=t?-1:1,d=r[e+u];for(u+=h,i=d&(1<<-f)-1,d>>=-f,f+=a;f>0;i=i*256+r[e+u],u+=h,f-=8);for(s=i&(1<<-f)-1,i>>=-f,f+=n;f>0;s=s*256+r[e+u],u+=h,f-=8);if(i===0)i=1-l;else{if(i===c)return s?NaN:(d?-1:1)*(1/0);s=s+Math.pow(2,n),i=i-l}return(d?-1:1)*s*Math.pow(2,i-n)};RS.write=function(r,e,t,n,o,i){var s,a,c,l=i*8-o-1,f=(1<<l)-1,u=f>>1,h=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:i-1,m=n?1:-1,y=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),s+u>=1?e+=h/c:e+=h*Math.pow(2,1-u),e*c>=2&&(s++,c/=2),s+u>=f?(a=0,s=f):s+u>=1?(a=(e*c-1)*Math.pow(2,o),s=s+u):(a=e*Math.pow(2,u-1)*Math.pow(2,o),s=0));o>=8;r[t+d]=a&255,d+=m,a/=256,o-=8);for(s=s<<o|a,l+=o;l>0;r[t+d]=s&255,d+=m,s/=256,l-=8);r[t+d-m]|=y*128}});var HU=Rt(($nt,$U)=>{var yh=1e3,wh=yh*60,xh=wh*60,Nu=xh*24,WJ=Nu*7,GJ=Nu*365.25;$U.exports=function(r,e){e=e||{};var t=typeof r;if(t==="string"&&r.length>0)return XJ(r);if(t==="number"&&isFinite(r))return e.long?QJ(r):YJ(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function XJ(r){if(r=String(r),!(r.length>100)){var e=/^(-?(?:\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(e){var t=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return t*GJ;case"weeks":case"week":case"w":return t*WJ;case"days":case"day":case"d":return t*Nu;case"hours":case"hour":case"hrs":case"hr":case"h":return t*xh;case"minutes":case"minute":case"mins":case"min":case"m":return t*wh;case"seconds":case"second":case"secs":case"sec":case"s":return t*yh;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function YJ(r){var e=Math.abs(r);return e>=Nu?Math.round(r/Nu)+"d":e>=xh?Math.round(r/xh)+"h":e>=wh?Math.round(r/wh)+"m":e>=yh?Math.round(r/yh)+"s":r+"ms"}function QJ(r){var e=Math.abs(r);return e>=Nu?U8(r,e,Nu,"day"):e>=xh?U8(r,e,xh,"hour"):e>=wh?U8(r,e,wh,"minute"):e>=yh?U8(r,e,yh,"second"):r+" ms"}function U8(r,e,t,n){var o=e>=t*1.5;return Math.round(r/t)+" "+n+(o?"s":"")}});var VU=Rt((Hnt,KU)=>{function ZJ(r){t.debug=t,t.default=t,t.coerce=c,t.disable=s,t.enable=o,t.enabled=a,t.humanize=HU(),t.destroy=l,Object.keys(r).forEach(f=>{t[f]=r[f]}),t.names=[],t.skips=[],t.formatters={};function e(f){let u=0;for(let h=0;h<f.length;h++)u=(u<<5)-u+f.charCodeAt(h),u|=0;return t.colors[Math.abs(u)%t.colors.length]}t.selectColor=e;function t(f){let u,h=null,d,m;function y(...w){if(!y.enabled)return;let x=y,E=Number(new Date),v=E-(u||E);x.diff=v,x.prev=u,x.curr=E,u=E,w[0]=t.coerce(w[0]),typeof w[0]!="string"&&w.unshift("%O");let I=0;w[0]=w[0].replace(/%([a-zA-Z%])/g,(V,M)=>{if(V==="%%")return"%";I++;let T=t.formatters[M];if(typeof T=="function"){let k=w[I];V=T.call(x,k),w.splice(I,1),I--}return V}),t.formatArgs.call(x,w),(x.log||t.log).apply(x,w)}return y.namespace=f,y.useColors=t.useColors(),y.color=t.selectColor(f),y.extend=n,y.destroy=t.destroy,Object.defineProperty(y,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(d!==t.namespaces&&(d=t.namespaces,m=t.enabled(f)),m),set:w=>{h=w}}),typeof t.init=="function"&&t.init(y),y}function n(f,u){let h=t(this.namespace+(typeof u>"u"?":":u)+f);return h.log=this.log,h}function o(f){t.save(f),t.namespaces=f,t.names=[],t.skips=[];let u=(typeof f=="string"?f:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let h of u)h[0]==="-"?t.skips.push(h.slice(1)):t.names.push(h)}function i(f,u){let h=0,d=0,m=-1,y=0;for(;h<f.length;)if(d<u.length&&(u[d]===f[h]||u[d]==="*"))u[d]==="*"?(m=d,y=h,d++):(h++,d++);else if(m!==-1)d=m+1,y++,h=y;else return!1;for(;d<u.length&&u[d]==="*";)d++;return d===u.length}function s(){let f=[...t.names,...t.skips.map(u=>"-"+u)].join(",");return t.enable(""),f}function a(f){for(let u of t.skips)if(i(f,u))return!1;for(let u of t.names)if(i(f,u))return!0;return!1}function c(f){return f instanceof Error?f.stack||f.message:f}function l(){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 t.enable(t.load()),t}KU.exports=ZJ});var qU=Rt((jn,F8)=>{jn.formatArgs=eee;jn.save=tee;jn.load=ree;jn.useColors=JJ;jn.storage=nee();jn.destroy=(()=>{let r=!1;return()=>{r||(r=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();jn.colors=["#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 JJ(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let r;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(r=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(r[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function eee(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+F8.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;r.splice(1,0,e,"color: inherit");let t=0,n=0;r[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(t++,o==="%c"&&(n=t))}),r.splice(n,0,e)}jn.log=console.debug||console.log||(()=>{});function tee(r){try{r?jn.storage.setItem("debug",r):jn.storage.removeItem("debug")}catch{}}function ree(){let r;try{r=jn.storage.getItem("debug")||jn.storage.getItem("DEBUG")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function nee(){try{return localStorage}catch{}}F8.exports=VU()(jn);var{formatters:oee}=F8.exports;oee.j=function(r){try{return JSON.stringify(r)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var xee={};Dt(xee,{BasePlugin:()=>Vn,MEDIA_TYPE_CAR:()=>Pu,MEDIA_TYPE_CBOR:()=>wo,MEDIA_TYPE_DAG_CBOR:()=>yo,MEDIA_TYPE_DAG_JSON:()=>xo,MEDIA_TYPE_DAG_PB:()=>I0,MEDIA_TYPE_IPNS_RECORD:()=>ku,MEDIA_TYPE_JSON:()=>bo,MEDIA_TYPE_OCTET_STREAM:()=>Kr,MEDIA_TYPE_RAW:()=>En,MEDIA_TYPE_TAR:()=>fh,createVerifiedFetch:()=>HS,verifiedFetch:()=>V8});var GS=Symbol.for("@libp2p/connection");var us=Symbol.for("@libp2p/content-routing");var Tr=class extends Error{static name="AbortError";constructor(e="The operation was aborted"){super(e),this.name="AbortError"}},$0=class extends Error{static name="UnexpectedPeerError";constructor(e="Unexpected Peer"){super(e),this.name="UnexpectedPeerError"}},H0=class extends Error{static name="InvalidCryptoExchangeError";constructor(e="Invalid crypto exchange"){super(e),this.name="InvalidCryptoExchangeError"}},O=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}},fs=class extends Error{static name="InvalidPublicKeyError";constructor(e="Invalid public key"){super(e),this.name="InvalidPublicKeyError"}},Eh=class extends Error{static name="InvalidPrivateKeyError";constructor(e="Invalid private key"){super(e),this.name="InvalidPrivateKeyError"}},Sh=class extends Error{static name="UnsupportedOperationError";constructor(e="Unsupported operation"){super(e),this.name="UnsupportedOperationError"}};var Ic=class extends Error{static name="ConnectionClosedError";constructor(e="The connection is closed"){super(e),this.name="ConnectionClosedError"}},Mu=class extends Error{static name="ConnectionFailedError";constructor(e="Connection failed"){super(e),this.name="ConnectionFailedError"}},Yo=class extends Error{static name="MuxerClosedError";constructor(e="The muxer is closed"){super(e),this.name="MuxerClosedError"}},Uu=class extends Error{static name="StreamResetError";constructor(e="The stream has been reset"){super(e),this.name="StreamResetError"}};var Ti=class extends Error{static name="StreamStateError";constructor(e="The stream is in an invalid state"){super(e),this.name="StreamStateError"}},Ah=class extends Error{static name="StreamBufferError";constructor(e="The stream buffer was full"){super(e),this.name="StreamBufferError"}},Ye=class extends Error{static name="NotFoundError";constructor(e="Not found"){super(e),this.name="NotFoundError"}},Fu=class extends Error{static name="InvalidPeerIdError";constructor(e="Invalid PeerID"){super(e),this.name="InvalidPeerIdError"}},Ci=class extends Error{static name="InvalidMultiaddrError";constructor(e="Invalid multiaddr"){super(e),this.name="InvalidMultiaddrError"}},K0=class extends Error{static name="InvalidCIDError";constructor(e="Invalid CID"){super(e),this.name="InvalidCIDError"}},da=class extends Error{static name="InvalidMultihashError";constructor(e="Invalid Multihash"){super(e),this.name="InvalidMultihashError"}},$u=class extends Error{static name="UnsupportedProtocolError";constructor(e="Unsupported protocol error"){super(e),this.name="UnsupportedProtocolError"}},Ne=class extends Error{static name="InvalidMessageError";constructor(e="Invalid message"){super(e),this.name="InvalidMessageError"}},kc=class extends Error{static name="ProtocolError";constructor(e="Protocol error"){super(e),this.name="ProtocolError"}},Ii=class extends Error{static name="TimeoutError";constructor(e="Timed out"){super(e),this.name="TimeoutError"}},Wn=class extends Error{static name="NotStartedError";constructor(e="Not started"){super(e),this.name="NotStartedError"}};var ha=class extends Error{static name="DialError";constructor(e="Dial error"){super(e),this.name="DialError"}},Pc=class extends Error{static name="ListenError";constructor(e="Listen error"){super(e),this.name="ListenError"}},_h=class extends Error{static name="LimitedConnectionError";constructor(e="Limited connection"){super(e),this.name="LimitedConnectionError"}},V0=class extends Error{static name="TooManyInboundProtocolStreamsError";constructor(e="Too many inbound protocol streams"){super(e),this.name="TooManyInboundProtocolStreamsError"}},Hu=class extends Error{static name="TooManyOutboundProtocolStreamsError";constructor(e="Too many outbound protocol streams"){super(e),this.name="TooManyOutboundProtocolStreamsError"}},Qo=class extends Error{static name="UnsupportedKeyTypeError";constructor(e="Unsupported key type"){super(e),this.name="UnsupportedKeyTypeError"}};var q0=class extends Event{data;constructor(e,t){super("message",t),this.data=e}},pa=class extends Event{error;local;constructor(e,t,n){super("close",n),this.error=t,this.local=e}},z0=class extends pa{constructor(e,t){super(!0,e,t)}},j0=class extends pa{constructor(e,t){super(!1,e,t)}};function XS(r){return r==null?!1:(r.type==="RSA"||r.type==="Ed25519"||r.type==="secp256k1"||r.type==="ECDSA")&&r.raw instanceof Uint8Array&&typeof r.equals=="function"&&typeof r.toMultihash=="function"&&typeof r.toCID=="function"&&typeof r.verify=="function"}var Rc=Symbol.for("@libp2p/peer-discovery");var W0=Symbol.for("@libp2p/peer-id");function Vr(r){return!!r?.[W0]}var ds=Symbol.for("@libp2p/peer-routing");var Oc="keep-alive";function G0(r){return r!=null&&typeof r.start=="function"&&typeof r.stop=="function"}async function cr(...r){let e=[];for(let t of r)G0(t)&&e.push(t);await Promise.all(e.map(async t=>{t.beforeStart!=null&&await t.beforeStart()})),await Promise.all(e.map(async t=>{await t.start()})),await Promise.all(e.map(async t=>{t.afterStart!=null&&await t.afterStart()}))}async function mr(...r){let e=[];for(let t of r)G0(t)&&e.push(t);await Promise.all(e.map(async t=>{t.beforeStop!=null&&await t.beforeStop()})),await Promise.all(e.map(async t=>{await t.stop()})),await Promise.all(e.map(async t=>{t.afterStop!=null&&await t.afterStop()}))}var ma=Symbol.for("@libp2p/transport");var Th;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(Th||(Th={}));var _e=class extends EventTarget{#t=new Map;constructor(){super()}listenerCount(e){let t=this.#t.get(e);return t==null?0:t.length}addEventListener(e,t,n){super.addEventListener(e,t,n);let o=this.#t.get(e);o==null&&(o=[],this.#t.set(e,o)),o.push({callback:t,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(e,t,n){super.removeEventListener(e.toString(),t??null,n);let o=this.#t.get(e);o!=null&&(o=o.filter(({callback:i})=>i!==t),this.#t.set(e,o))}dispatchEvent(e){let t=super.dispatchEvent(e),n=this.#t.get(e.type);return n==null||(n=n.filter(({once:o})=>!o),this.#t.set(e.type,n)),t}safeDispatchEvent(e,t={}){return this.dispatchEvent(new CustomEvent(e,t))}};var Ve=Symbol.for("@libp2p/service-capabilities"),Gn=Symbol.for("@libp2p/service-dependencies");function Re(r){let e=new globalThis.AbortController;function t(){e.abort();for(let i of r)i?.removeEventListener!=null&&i.removeEventListener("abort",t)}for(let i of r){if(i?.aborted===!0){t();break}i?.addEventListener!=null&&i.addEventListener("abort",t)}function n(){for(let i of r)i?.removeEventListener!=null&&i.removeEventListener("abort",t)}let o=e.signal;return o.clear=n,o}var Y=class extends Event{type;detail;constructor(e,t){super(e),this.type=e,this.detail=t}};var Ch=class extends Error{constructor(e="An error occurred while signing a message"){super(e),this.name="SigningError"}},Ih=class extends Error{constructor(e="An error occurred while verifying a message"){super(e),this.name="VerificationError"}},X0=class extends Error{constructor(e="Missing Web Crypto API"){super(e),this.name="WebCryptoMissingError"}};var YS={get(r=globalThis){let e=r.crypto;if(e?.subtle==null)throw new X0("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api");return e}};var Qt=YS;var J8={};Dt(J8,{base58btc:()=>Qe,base58flickr:()=>RF});var Dc={};Dt(Dc,{coerce:()=>vo,empty:()=>QS,equals:()=>j8,fromHex:()=>SF,fromString:()=>W8,isBinary:()=>AF,toHex:()=>EF,toString:()=>G8});var QS=new Uint8Array(0);function EF(r){return r.reduce((e,t)=>e+t.toString(16).padStart(2,"0"),"")}function SF(r){let e=r.match(/../g);return e!=null?new Uint8Array(e.map(t=>parseInt(t,16))):QS}function j8(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function vo(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 AF(r){return r instanceof ArrayBuffer||ArrayBuffer.isView(r)}function W8(r){return new TextEncoder().encode(r)}function G8(r){return new TextDecoder().decode(r)}function _F(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var o=0;o<r.length;o++){var i=r.charAt(o),s=i.charCodeAt(0);if(t[s]!==255)throw new TypeError(i+" is ambiguous");t[s]=o}var a=r.length,c=r.charAt(0),l=Math.log(a)/Math.log(256),f=Math.log(256)/Math.log(a);function u(m){if(m instanceof Uint8Array||(ArrayBuffer.isView(m)?m=new Uint8Array(m.buffer,m.byteOffset,m.byteLength):Array.isArray(m)&&(m=Uint8Array.from(m))),!(m instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(m.length===0)return"";for(var y=0,w=0,x=0,E=m.length;x!==E&&m[x]===0;)x++,y++;for(var v=(E-x)*f+1>>>0,I=new Uint8Array(v);x!==E;){for(var F=m[x],V=0,M=v-1;(F!==0||V<w)&&M!==-1;M--,V++)F+=256*I[M]>>>0,I[M]=F%a>>>0,F=F/a>>>0;if(F!==0)throw new Error("Non-zero carry");w=V,x++}for(var T=v-w;T!==v&&I[T]===0;)T++;for(var k=c.repeat(y);T<v;++T)k+=r.charAt(I[T]);return k}function h(m){if(typeof m!="string")throw new TypeError("Expected String");if(m.length===0)return new Uint8Array;var y=0;if(m[y]!==" "){for(var w=0,x=0;m[y]===c;)w++,y++;for(var E=(m.length-y)*l+1>>>0,v=new Uint8Array(E);m[y];){var I=t[m.charCodeAt(y)];if(I===255)return;for(var F=0,V=E-1;(I!==0||F<x)&&V!==-1;V--,F++)I+=a*v[V]>>>0,v[V]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");x=F,y++}if(m[y]!==" "){for(var M=E-x;M!==E&&v[M]===0;)M++;for(var T=new Uint8Array(w+(E-M)),k=w;M!==E;)T[k++]=v[M++];return T}}}function d(m){var y=h(m);if(y)return y;throw new Error(`Non-${e} character`)}return{encode:u,decodeUnsafe:h,decode:d}}var TF=_F,CF=TF,ZS=CF;var X8=class{name;prefix;baseEncode;constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Y8=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){this.name=e,this.prefix=t;let o=t.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return JS(this,e)}},Q8=class{decoders;constructor(e){this.decoders=e}or(e){return JS(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function JS(r,e){return new Q8({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var Z8=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new X8(e,t,n),this.decoder=new Y8(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Ku({name:r,prefix:e,encode:t,decode:n}){return new Z8(r,e,t,n)}function ga({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=ZS(t,r);return Ku({prefix:e,name:r,encode:n,decode:i=>vo(o(i))})}function IF(r,e,t,n){let o=r.length;for(;r[o-1]==="=";)--o;let i=new Uint8Array(o*t/8|0),s=0,a=0,c=0;for(let l=0;l<o;++l){let f=e[r[l]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<t|f,s+=t,s>=8&&(s-=8,i[c++]=255&a>>s)}if(s>=t||(255&a<<8-s)!==0)throw new SyntaxError("Unexpected end of data");return i}function kF(r,e,t){let n=e[e.length-1]==="=",o=(1<<t)-1,i="",s=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],s+=8;s>t;)s-=t,i+=e[o&a>>s];if(s!==0&&(i+=e[o&a<<t-s]),n)for(;(i.length*t&7)!==0;)i+="=";return i}function PF(r){let e={};for(let t=0;t<r.length;++t)e[r[t]]=t;return e}function Ft({name:r,prefix:e,bitsPerChar:t,alphabet:n}){let o=PF(n);return Ku({prefix:e,name:r,encode(i){return kF(i,n,t)},decode(i){return IF(i,o,t,r)}})}var Qe=ga({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),RF=ga({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ew={};Dt(ew,{base32:()=>gr,base32hex:()=>LF,base32hexpad:()=>MF,base32hexpadupper:()=>UF,base32hexupper:()=>BF,base32pad:()=>DF,base32padupper:()=>NF,base32upper:()=>OF,base32z:()=>FF});var gr=Ft({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),OF=Ft({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),DF=Ft({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),NF=Ft({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),LF=Ft({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),BF=Ft({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),MF=Ft({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),UF=Ft({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),FF=Ft({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var tw={};Dt(tw,{base36:()=>rn,base36upper:()=>$F});var rn=ga({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),$F=ga({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var yt={};Dt(yt,{Digest:()=>Nc,create:()=>nn,decode:()=>qe,equals:()=>nw,hasCode:()=>i$});var HF=rA,eA=128,KF=127,VF=~KF,qF=Math.pow(2,31);function rA(r,e,t){e=e||[],t=t||0;for(var n=t;r>=qF;)e[t++]=r&255|eA,r/=128;for(;r&VF;)e[t++]=r&255|eA,r>>>=7;return e[t]=r|0,rA.bytes=t-n+1,e}var zF=rw,jF=128,tA=127;function rw(r,n){var t=0,n=n||0,o=0,i=n,s,a=r.length;do{if(i>=a)throw rw.bytes=0,new RangeError("Could not decode varint");s=r[i++],t+=o<28?(s&tA)<<o:(s&tA)*Math.pow(2,o),o+=7}while(s>=jF);return rw.bytes=i-n,t}var WF=Math.pow(2,7),GF=Math.pow(2,14),XF=Math.pow(2,21),YF=Math.pow(2,28),QF=Math.pow(2,35),ZF=Math.pow(2,42),JF=Math.pow(2,49),e$=Math.pow(2,56),t$=Math.pow(2,63),r$=function(r){return r<WF?1:r<GF?2:r<XF?3:r<YF?4:r<QF?5:r<ZF?6:r<JF?7:r<e$?8:r<t$?9:10},n$={encode:HF,decode:zF,encodingLength:r$},o$=n$,kh=o$;function Ph(r,e=0){return[kh.decode(r,e),kh.decode.bytes]}function Vu(r,e,t=0){return kh.encode(r,e,t),e}function qu(r){return kh.encodingLength(r)}function nn(r,e){let t=e.byteLength,n=qu(r),o=n+qu(t),i=new Uint8Array(o+t);return Vu(r,i,0),Vu(t,i,n),i.set(e,o),new Nc(r,t,e,i)}function qe(r){let e=vo(r),[t,n]=Ph(e),[o,i]=Ph(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Nc(t,o,s,e)}function nw(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&j8(r.bytes,t.bytes)}}var Nc=class{code;size;digest;bytes;constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};function i$(r,e){return r.code===e}function nA(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return a$(t,ow(r),e??Qe.encoder);default:return c$(t,ow(r),e??gr.encoder)}}var oA=new WeakMap;function ow(r){let e=oA.get(r);if(e==null){let t=new Map;return oA.set(r,t),t}return e}var Z=class r{code;version;multihash;bytes;"/";constructor(e,t,n,o){this.code=t,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:t}=this;if(e!==Rh)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==l$)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,n=nn(e,t);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return r.equals(this,e)}static equals(e,t){let n=t;return n!=null&&e.code===n.code&&e.version===n.version&&nw(e.multihash,n.multihash)}toString(e){return nA(this,e)}toJSON(){return{"/":nA(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:i,bytes:s}=t;return new r(n,o,i,s??iA(n,o,i.bytes))}else if(t[u$]===!0){let{version:n,multihash:o,code:i}=t,s=qe(o);return r.create(n,i,s)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==Rh)throw new Error(`Version 0 CID must use dag-pb (code: ${Rh}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=iA(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,Rh,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,o=vo(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let i=o.subarray(t.multihashSize-t.digestSize),s=new Nc(t.multihashCode,t.digestSize,i,o);return[t.version===0?r.createV0(s):r.createV1(t.codec,s),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[u,h]=Ph(e.subarray(t));return t+=h,u},o=n(),i=Rh;if(o===18?(o=0,t=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=t,a=n(),c=n(),l=t+c,f=l-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:f,size:l}}static parse(e,t){let[n,o]=s$(e,t),i=r.decode(o);if(i.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return ow(i).set(n,e),i}};function s$(r,e){switch(r[0]){case"Q":{let t=e??Qe;return[Qe.prefix,t.decode(`${Qe.prefix}${r}`)]}case Qe.prefix:{let t=e??Qe;return[Qe.prefix,t.decode(r)]}case gr.prefix:{let t=e??gr;return[gr.prefix,t.decode(r)]}case rn.prefix:{let t=e??rn;return[rn.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function a$(r,e,t){let{prefix:n}=t;if(n!==Qe.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let i=t.encode(r).slice(1);return e.set(n,i),i}else return o}function c$(r,e,t){let{prefix:n}=t,o=e.get(n);if(o==null){let i=t.encode(r);return e.set(n,i),i}else return o}var Rh=112,l$=18;function iA(r,e,t){let n=qu(r),o=n+qu(e),i=new Uint8Array(o+t.byteLength);return Vu(r,i,0),Vu(e,i,n),i.set(t,o),i}var u$=Symbol.for("@ipld/js-cid/CID");var iw={};Dt(iw,{identity:()=>$t});var sA=0,f$="identity",aA=vo;function d$(r,e){if(e?.truncate!=null&&e.truncate!==r.byteLength){if(e.truncate<0||e.truncate>r.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${r.byteLength}`);r=r.subarray(0,e.truncate)}return nn(sA,aA(r))}var $t={code:sA,name:f$,encode:aA,digest:d$};function me(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function Ie(r=0){return new Uint8Array(r)}function Nt(r=0){return new Uint8Array(r)}function dt(r,e){e==null&&(e=r.reduce((o,i)=>o+i.length,0));let t=Nt(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return t}var lA=Symbol.for("@achingbrain/uint8arraylist");function cA(r,e){if(e==null||e<0)throw new RangeError("index is out of bounds");let t=0;for(let n of r){let o=t+n.byteLength;if(e<o)return{buf:n,index:e-t};t=o}throw new RangeError("index is out of bounds")}function Eo(r){return!!r?.[lA]}var se=class r{bufs;length;[lA]=!0;constructor(...e){this.bufs=[],this.length=0,e.length>0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let t=0;for(let n of e)if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.push(n);else if(Eo(n))t+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=t}prepend(...e){this.prependAll(e)}prependAll(e){let t=0;for(let n of e.reverse())if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.unshift(n);else if(Eo(n))t+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=t}get(e){let t=cA(this.bufs,e);return t.buf[t.index]}set(e,t){let n=cA(this.bufs,e);n.buf[n.index]=t}write(e,t=0){if(e instanceof Uint8Array)for(let n=0;n<e.length;n++)this.set(t+n,e[n]);else if(Eo(e))for(let n=0;n<e.length;n++)this.set(t+n,e.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(e){if(e=Math.trunc(e),!(Number.isNaN(e)||e<=0)){if(e===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(e>=this.bufs[0].byteLength)e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}}}slice(e,t){let{bufs:n,length:o}=this._subList(e,t);return dt(n,o)}subarray(e,t){let{bufs:n,length:o}=this._subList(e,t);return n.length===1?n[0]:dt(n,o)}sublist(e,t){let{bufs:n,length:o}=this._subList(e,t),i=new r;return i.length=o,i.bufs=[...n],i}_subList(e,t){if(e=e??0,t=t??this.length,e<0&&(e=this.length+e),t<0&&(t=this.length+t),e<0||t>this.length)throw new RangeError("index is out of bounds");if(e===t)return{bufs:[],length:0};if(e===0&&t===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let i=0;i<this.bufs.length;i++){let s=this.bufs[i],a=o,c=a+s.byteLength;if(o=c,e>=c)continue;let l=e>=a&&e<c,f=t>a&&t<=c;if(l&&f){if(e===a&&t===c){n.push(s);break}let u=e-a;n.push(s.subarray(u,u+(t-e)));break}if(l){if(e===0){n.push(s);continue}n.push(s.subarray(e-a));continue}if(f){if(t===c){n.push(s);break}n.push(s.subarray(0,t-a));break}n.push(s)}return{bufs:n,length:t-e}}indexOf(e,t=0){if(!Eo(e)&&!(e instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=e instanceof Uint8Array?e:e.subarray();if(t=Number(t??0),isNaN(t)&&(t=0),t<0&&(t=this.length+t),t<0&&(t=0),e.length===0)return t>this.length?this.length:t;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let i=256,s=new Int32Array(i);for(let u=0;u<i;u++)s[u]=-1;for(let u=0;u<o;u++)s[n[u]]=u;let a=s,c=this.byteLength-n.byteLength,l=n.byteLength-1,f;for(let u=t;u<=c;u+=f){f=0;for(let h=l;h>=0;h--){let d=this.get(u+h);if(n[h]!==d){f=Math.max(1,h-a[d]);break}}if(f===0)return u}return-1}getInt8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getInt8(0)}setInt8(e,t){let n=Nt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,t),this.write(n,e)}getInt16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,t)}setInt16(e,t,n){let o=Ie(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,t,n),this.write(o,e)}getInt32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,t)}setInt32(e,t,n){let o=Ie(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,t,n),this.write(o,e)}getBigInt64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,t)}setBigInt64(e,t,n){let o=Ie(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,t,n),this.write(o,e)}getUint8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint8(0)}setUint8(e,t){let n=Nt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,t),this.write(n,e)}getUint16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,t)}setUint16(e,t,n){let o=Ie(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,t,n),this.write(o,e)}getUint32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,t)}setUint32(e,t,n){let o=Ie(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,t,n),this.write(o,e)}getBigUint64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,t)}setBigUint64(e,t,n){let o=Ie(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,t,n),this.write(o,e)}getFloat32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,t)}setFloat32(e,t,n){let o=Ie(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,t,n),this.write(o,e)}getFloat64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,t)}setFloat64(e,t,n){let o=Ie(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,t,n),this.write(o,e)}equals(e){if(e==null||!(e instanceof r)||e.bufs.length!==this.bufs.length)return!1;for(let t=0;t<this.bufs.length;t++)if(!me(this.bufs[t],e.bufs[t]))return!1;return!0}static fromUint8Arrays(e,t){let n=new r;return n.bufs=e,t==null&&(t=e.reduce((o,i)=>o+i.byteLength,0)),n.length=t,n}};var sw={};Dt(sw,{base10:()=>p$});var p$=ga({prefix:"9",name:"base10",alphabet:"0123456789"});var aw={};Dt(aw,{base16:()=>m$,base16upper:()=>g$});var m$=Ft({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),g$=Ft({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var cw={};Dt(cw,{base2:()=>y$});var y$=Ft({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var lw={};Dt(lw,{base256emoji:()=>E$});var uA=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}"),w$=uA.reduce((r,e,t)=>(r[t]=e,r),[]),x$=uA.reduce((r,e,t)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return r[n]=t,r},[]);function b$(r){return r.reduce((e,t)=>(e+=w$[t],e),"")}function v$(r){let e=[];for(let t of r){let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);let o=x$[n];if(o==null)throw new Error(`Non-base256emoji character: ${t}`);e.push(o)}return new Uint8Array(e)}var E$=Ku({prefix:"\u{1F680}",name:"base256emoji",encode:b$,decode:v$});var uw={};Dt(uw,{base64:()=>Zt,base64pad:()=>Oh,base64url:()=>Lc,base64urlpad:()=>S$});var Zt=Ft({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Oh=Ft({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Lc=Ft({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),S$=Ft({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var fw={};Dt(fw,{base8:()=>A$});var A$=Ft({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var dw={};Dt(dw,{identity:()=>_$});var _$=Ku({prefix:"\0",name:"identity",encode:r=>G8(r),decode:r=>W8(r)});var hs={};Dt(hs,{code:()=>lr,decode:()=>zu,encode:()=>k$,name:()=>I$});var T$=new TextEncoder,C$=new TextDecoder,I$="json",lr=512;function k$(r){return T$.encode(JSON.stringify(r))}function zu(r){return JSON.parse(C$.decode(r))}var So={};Dt(So,{code:()=>rt,decode:()=>O$,encode:()=>R$,name:()=>P$});var P$="raw",rt=85;function R$(r){return vo(r)}function O$(r){return vo(r)}var pw={};Dt(pw,{sha256:()=>At,sha512:()=>Q0});var D$=20;function ps({name:r,code:e,encode:t,minDigestLength:n,maxDigestLength:o}){return new hw(r,e,t,n,o)}var hw=class{name;code;encode;minDigestLength;maxDigestLength;constructor(e,t,n,o,i){this.name=e,this.code=t,this.encode=n,this.minDigestLength=o??D$,this.maxDigestLength=i}digest(e,t){if(t?.truncate!=null){if(t.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&t.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(e instanceof Uint8Array){let n=this.encode(e);return n instanceof Uint8Array?fA(n,this.code,t?.truncate):n.then(o=>fA(o,this.code,t?.truncate))}else throw Error("Unknown type, must be binary type")}};function fA(r,e,t){if(t!=null&&t!==r.byteLength){if(t>r.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${r.byteLength}`);r=r.subarray(0,t)}return nn(e,r)}function hA(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var At=ps({name:"sha2-256",code:18,encode:hA("SHA-256")}),Q0=ps({name:"sha2-512",code:19,encode:hA("SHA-512")});var Bc={...dw,...cw,...fw,...sw,...aw,...ew,...tw,...J8,...uw,...lw},nre={...pw,...iw};function mA(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var pA=mA("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),mw=mA("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=Nt(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),N$={utf8:pA,"utf-8":pA,hex:Bc.base16,latin1:mw,ascii:mw,binary:mw,...Bc},Z0=N$;function D(r,e="utf8"){let t=Z0[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${r}`)}function H(r,e="utf8"){let t=Z0[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.encoder.encode(r).substring(1)}var L$=parseInt("11111",2),gw=parseInt("10000000",2),B$=parseInt("01111111",2),gA={0:Dh,1:Dh,2:M$,3:$$,4:H$,5:F$,6:U$,16:Dh,22:Dh,48:Dh};function Ao(r,e={offset:0}){let t=r[e.offset]&L$;if(e.offset++,gA[t]!=null)return gA[t](r,e);throw new Error("No decoder for tag "+t)}function Nh(r,e){let t=0;if((r[e.offset]&gw)===gw){let n=r[e.offset]&B$,o="0x";e.offset++;for(let i=0;i<n;i++,e.offset++)o+=r[e.offset].toString(16).padStart(2,"0");t=parseInt(o,16)}else t=r[e.offset],e.offset++;return t}function Dh(r,e){Nh(r,e);let t=[];for(;!(e.offset>=r.byteLength);){let n=Ao(r,e);if(n===null)break;t.push(n)}return t}function M$(r,e){let t=Nh(r,e),n=e.offset,o=e.offset+t,i=[];for(let s=n;s<o;s++)s===n&&r[s]===0||i.push(r[s]);return e.offset+=t,Uint8Array.from(i)}function U$(r,e){let t=Nh(r,e),n=e.offset+t,o=r[e.offset];e.offset++;let i=0,s=0;o<40?(i=0,s=o):o<80?(i=1,s=o-40):(i=2,s=o-80);let a=`${i}.${s}`,c=[];for(;e.offset<n;){let l=r[e.offset];if(e.offset++,c.push(l&127),l<128){c.reverse();let f=0;for(let u=0;u<c.length;u++)f+=c[u]<<u*7;a+=`.${f}`,c=[]}}return a}function F$(r,e){return e.offset++,null}function $$(r,e){let t=Nh(r,e),n=r[e.offset];e.offset++;let o=r.subarray(e.offset,e.offset+t-1);if(e.offset+=t,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function H$(r,e){let t=Nh(r,e),n=r.subarray(e.offset,e.offset+t);return e.offset+=t,n}function K$(r){let e=r.toString(16);e.length%2===1&&(e="0"+e);let t=new se;for(let n=0;n<e.length;n+=2)t.append(Uint8Array.from([parseInt(`${e[n]}${e[n+1]}`,16)]));return t}function J0(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let e=K$(r.byteLength);return new se(Uint8Array.from([e.byteLength|gw]),e)}function on(r){let e=new se,t=128;return(r.subarray()[0]&t)===t&&e.append(Uint8Array.from([0])),e.append(r),new se(Uint8Array.from([2]),J0(e),e)}function Lh(r){let e=Uint8Array.from([0]),t=new se(e,r);return new se(Uint8Array.from([3]),J0(t),t)}function yA(r){return new se(Uint8Array.from([4]),J0(r),r)}function Zo(r,e=48){let t=new se;for(let n of r)t.append(n);return new se(Uint8Array.from([e]),J0(t),t)}var wA="1.2.840.10045.3.1.7",xA="1.3.132.0.34",bA="1.3.132.0.35";async function vA(r="P-256"){let e=await crypto.subtle.generateKey({name:"ECDSA",namedCurve:r},!0,["sign","verify"]);return{publicKey:await crypto.subtle.exportKey("jwk",e.publicKey),privateKey:await crypto.subtle.exportKey("jwk",e.privateKey)}}async function EA(r,e,t){let n=await crypto.subtle.importKey("jwk",r,{name:"ECDSA",namedCurve:r.crv??"P-256"},!1,["sign"]);t?.signal?.throwIfAborted();let o=await crypto.subtle.sign({name:"ECDSA",hash:{name:"SHA-256"}},n,e.subarray());return t?.signal?.throwIfAborted(),new Uint8Array(o,0,o.byteLength)}async function SA(r,e,t,n){let o=await crypto.subtle.importKey("jwk",r,{name:"ECDSA",namedCurve:r.crv??"P-256"},!1,["verify"]);n?.signal?.throwIfAborted();let i=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},o,e,t.subarray());return n?.signal?.throwIfAborted(),i}var V$=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),q$=Uint8Array.from([6,5,43,129,4,0,34]),z$=Uint8Array.from([6,5,43,129,4,0,35]),AA={ext:!0,kty:"EC",crv:"P-256"},_A={ext:!0,kty:"EC",crv:"P-384"},TA={ext:!0,kty:"EC",crv:"P-521"},ju=32,Wu=48,Gu=66;function CA(r){let e=Ao(r);return yw(e)}function yw(r){let e=r[1],t=H(e,"base64url"),n=r[2][1][0],o=1,i,s;if(e.byteLength===ju)return i=H(n.subarray(o,o+ju),"base64url"),s=H(n.subarray(o+ju),"base64url"),new Uc({...AA,key_ops:["sign"],d:t,x:i,y:s});if(e.byteLength===Wu)return i=H(n.subarray(o,o+Wu),"base64url"),s=H(n.subarray(o+Wu),"base64url"),new Uc({..._A,key_ops:["sign"],d:t,x:i,y:s});if(e.byteLength===Gu)return i=H(n.subarray(o,o+Gu),"base64url"),s=H(n.subarray(o+Gu),"base64url"),new Uc({...TA,key_ops:["sign"],d:t,x:i,y:s});throw new O(`Private key length was wrong length, got ${e.byteLength}, expected 32, 48 or 66`)}function ww(r){let e=Ao(r);return IA(e)}function IA(r){let e=r[1][1][0],t=1,n,o;if(e.byteLength===ju*2+1)return n=H(e.subarray(t,t+ju),"base64url"),o=H(e.subarray(t+ju),"base64url"),new Mc({...AA,key_ops:["verify"],x:n,y:o});if(e.byteLength===Wu*2+1)return n=H(e.subarray(t,t+Wu),"base64url"),o=H(e.subarray(t+Wu),"base64url"),new Mc({..._A,key_ops:["verify"],x:n,y:o});if(e.byteLength===Gu*2+1)return n=H(e.subarray(t,t+Gu),"base64url"),o=H(e.subarray(t+Gu),"base64url"),new Mc({...TA,key_ops:["verify"],x:n,y:o});throw new O(`coordinates were wrong length, got ${e.byteLength}, expected 65, 97 or 133`)}function kA(r){return Zo([on(Uint8Array.from([1])),yA(D(r.d??"","base64url")),Zo([RA(r.crv)],160),Zo([Lh(new se(Uint8Array.from([4]),D(r.x??"","base64url"),D(r.y??"","base64url")))],161)]).subarray()}function PA(r){return Zo([on(Uint8Array.from([1])),Zo([RA(r.crv)],160),Zo([Lh(new se(Uint8Array.from([4]),D(r.x??"","base64url"),D(r.y??"","base64url")))],161)]).subarray()}function RA(r){if(r==="P-256")return V$;if(r==="P-384")return q$;if(r==="P-521")return z$;throw new O(`Invalid curve ${r}`)}async function OA(r="P-256"){let e=await vA(r);return new Uc(e.privateKey)}var Mc=class{type="ECDSA";jwk;_raw;constructor(e){this.jwk=e}get raw(){return this._raw==null&&(this._raw=PA(this.jwk)),this._raw}toMultihash(){return $t.digest(yr(this))}toCID(){return Z.createV1(114,this.toMultihash())}toString(){return Qe.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:me(this.raw,e.raw)}async verify(e,t,n){return SA(this.jwk,t,e,n)}},Uc=class{type="ECDSA";jwk;publicKey;_raw;constructor(e){this.jwk=e,this.publicKey=new Mc({crv:e.crv,ext:e.ext,key_ops:["verify"],kty:"EC",x:e.x,y:e.y})}get raw(){return this._raw==null&&(this._raw=kA(this.jwk)),this._raw}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:me(this.raw,e.raw)}async sign(e,t){return EA(this.jwk,e,t)}};function Fc(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function qr(r,e=""){if(!Number.isSafeInteger(r)||r<0){let t=e&&`"${e}" `;throw new Error(`${t}expected integer >= 0, got ${r}`)}}function ke(r,e,t=""){let n=Fc(r),o=r?.length,i=e!==void 0;if(!n||i&&o!==e){let s=t&&`"${t}" `,a=i?` of length ${e}`:"",c=n?`length=${o}`:`type=${typeof r}`;throw new Error(s+"expected Uint8Array"+a+", got "+c)}return r}function gs(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash must wrapped by utils.createHasher");qr(r.outputLen),qr(r.blockLen)}function Xu(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function NA(r,e){ke(r,void 0,"digestInto() output");let t=e.outputLen;if(r.length<t)throw new Error('"digestInto() output" expected to be of length >='+t)}function zr(...r){for(let e=0;e<r.length;e++)r[e].fill(0)}function $c(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function Jo(r,e){return r<<32-e|r>>>e}function eg(r,e){return r<<e|r>>>32-e>>>0}var LA=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",j$=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function ys(r){if(ke(r),LA)return r.toHex();let e="";for(let t=0;t<r.length;t++)e+=j$[r[t]];return e}var ms={_0:48,_9:57,A:65,F:70,a:97,f:102};function DA(r){if(r>=ms._0&&r<=ms._9)return r-ms._0;if(r>=ms.A&&r<=ms.F)return r-(ms.A-10);if(r>=ms.a&&r<=ms.f)return r-(ms.a-10)}function ws(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);if(LA)return Uint8Array.fromHex(r);let e=r.length,t=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(t);for(let o=0,i=0;o<t;o++,i+=2){let s=DA(r.charCodeAt(i)),a=DA(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}var W$=async()=>{};async function BA(r,e,t){let n=Date.now();for(let o=0;o<r;o++){t(o);let i=Date.now()-n;i>=0&&i<e||(await W$(),n+=i)}}function G$(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}function xw(r,e=""){return typeof r=="string"?G$(r):ke(r,void 0,e)}function Sn(...r){let e=0;for(let n=0;n<r.length;n++){let o=r[n];ke(o),e+=o.length}let t=new Uint8Array(e);for(let n=0,o=0;n<r.length;n++){let i=r[n];t.set(i,o),o+=i.length}return t}function MA(r,e){if(e!==void 0&&{}.toString.call(e)!=="[object Object]")throw new Error("options must be object or undefined");return Object.assign(r,e)}function Bh(r,e={}){let t=(o,i)=>r(i).update(o).digest(),n=r(void 0);return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=o=>r(o),Object.assign(t,e),Object.freeze(t)}function ki(r=32){let e=typeof globalThis=="object"?globalThis.crypto:null;if(typeof e?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");return e.getRandomValues(new Uint8Array(r))}var bw=r=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,r])});function tg(r,e,t){return r&e^~r&t}function rg(r,e,t){return r&e^r&t^e&t}var Hc=class{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,n,o){this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(e),this.view=$c(this.buffer)}update(e){Xu(this),ke(e);let{view:t,buffer:n,blockLen:o}=this,i=e.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let c=$c(e);for(;o<=i-s;s+=o)this.process(c,s);continue}n.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Xu(this),NA(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;t[s++]=128,zr(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(n,0),s=0);for(let u=s;u<o;u++)t[u]=0;n.setBigUint64(o-8,BigInt(this.length*8),i),this.process(n,0);let a=$c(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let l=c/4,f=this.get();if(l>f.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<l;u++)a.setUint32(4*u,f[u],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:n,length:o,finished:i,destroyed:s,pos:a}=this;return e.destroyed=s,e.finished=i,e.length=o,e.pos=a,o%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}},xs=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var Cr=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var ng=BigInt(4294967295),UA=BigInt(32);function X$(r,e=!1){return e?{h:Number(r&ng),l:Number(r>>UA&ng)}:{h:Number(r>>UA&ng)|0,l:Number(r&ng)|0}}function FA(r,e=!1){let t=r.length,n=new Uint32Array(t),o=new Uint32Array(t);for(let i=0;i<t;i++){let{h:s,l:a}=X$(r[i],e);[n[i],o[i]]=[s,a]}return[n,o]}var vw=(r,e,t)=>r>>>t,Ew=(r,e,t)=>r<<32-t|e>>>t,Kc=(r,e,t)=>r>>>t|e<<32-t,Vc=(r,e,t)=>r<<32-t|e>>>t,Mh=(r,e,t)=>r<<64-t|e>>>t-32,Uh=(r,e,t)=>r>>>t-32|e<<64-t;function Pi(r,e,t,n){let o=(e>>>0)+(n>>>0);return{h:r+t+(o/2**32|0)|0,l:o|0}}var $A=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),HA=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,KA=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),VA=(r,e,t,n,o)=>e+t+n+o+(r/2**32|0)|0,qA=(r,e,t,n,o)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(o>>>0),zA=(r,e,t,n,o,i)=>e+t+n+o+i+(r/2**32|0)|0;var Q$=Uint32Array.from([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]),ya=new Uint32Array(64),Sw=class extends Hc{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:t,C:n,D:o,E:i,F:s,G:a,H:c}=this;return[e,t,n,o,i,s,a,c]}set(e,t,n,o,i,s,a,c){this.A=e|0,this.B=t|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(e,t){for(let u=0;u<16;u++,t+=4)ya[u]=e.getUint32(t,!1);for(let u=16;u<64;u++){let h=ya[u-15],d=ya[u-2],m=Jo(h,7)^Jo(h,18)^h>>>3,y=Jo(d,17)^Jo(d,19)^d>>>10;ya[u]=y+ya[u-7]+m+ya[u-16]|0}let{A:n,B:o,C:i,D:s,E:a,F:c,G:l,H:f}=this;for(let u=0;u<64;u++){let h=Jo(a,6)^Jo(a,11)^Jo(a,25),d=f+h+tg(a,c,l)+Q$[u]+ya[u]|0,y=(Jo(n,2)^Jo(n,13)^Jo(n,22))+rg(n,o,i)|0;f=l,l=c,c=a,a=s+d|0,s=i,i=o,o=n,n=d+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,l=l+this.G|0,f=f+this.H|0,this.set(n,o,i,s,a,c,l,f)}roundClean(){zr(ya)}destroy(){this.set(0,0,0,0,0,0,0,0),zr(this.buffer)}},Aw=class extends Sw{A=xs[0]|0;B=xs[1]|0;C=xs[2]|0;D=xs[3]|0;E=xs[4]|0;F=xs[5]|0;G=xs[6]|0;H=xs[7]|0;constructor(){super(32)}};var jA=FA(["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))),Z$=jA[0],J$=jA[1],wa=new Uint32Array(80),xa=new Uint32Array(80),_w=class extends Hc{constructor(e){super(128,e,16,!1)}get(){let{Ah:e,Al:t,Bh:n,Bl:o,Ch:i,Cl:s,Dh:a,Dl:c,Eh:l,El:f,Fh:u,Fl:h,Gh:d,Gl:m,Hh:y,Hl:w}=this;return[e,t,n,o,i,s,a,c,l,f,u,h,d,m,y,w]}set(e,t,n,o,i,s,a,c,l,f,u,h,d,m,y,w){this.Ah=e|0,this.Al=t|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=l|0,this.El=f|0,this.Fh=u|0,this.Fl=h|0,this.Gh=d|0,this.Gl=m|0,this.Hh=y|0,this.Hl=w|0}process(e,t){for(let v=0;v<16;v++,t+=4)wa[v]=e.getUint32(t),xa[v]=e.getUint32(t+=4);for(let v=16;v<80;v++){let I=wa[v-15]|0,F=xa[v-15]|0,V=Kc(I,F,1)^Kc(I,F,8)^vw(I,F,7),M=Vc(I,F,1)^Vc(I,F,8)^Ew(I,F,7),T=wa[v-2]|0,k=xa[v-2]|0,z=Kc(T,k,19)^Mh(T,k,61)^vw(T,k,6),W=Vc(T,k,19)^Uh(T,k,61)^Ew(T,k,6),$=KA(M,W,xa[v-7],xa[v-16]),S=VA($,V,z,wa[v-7],wa[v-16]);wa[v]=S|0,xa[v]=$|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:l,Dl:f,Eh:u,El:h,Fh:d,Fl:m,Gh:y,Gl:w,Hh:x,Hl:E}=this;for(let v=0;v<80;v++){let I=Kc(u,h,14)^Kc(u,h,18)^Mh(u,h,41),F=Vc(u,h,14)^Vc(u,h,18)^Uh(u,h,41),V=u&d^~u&y,M=h&m^~h&w,T=qA(E,F,M,J$[v],xa[v]),k=zA(T,x,I,V,Z$[v],wa[v]),z=T|0,W=Kc(n,o,28)^Mh(n,o,34)^Mh(n,o,39),$=Vc(n,o,28)^Uh(n,o,34)^Uh(n,o,39),S=n&i^n&a^i&a,C=o&s^o&c^s&c;x=y|0,E=w|0,y=d|0,w=m|0,d=u|0,m=h|0,{h:u,l:h}=Pi(l|0,f|0,k|0,z|0),l=a|0,f=c|0,a=i|0,c=s|0,i=n|0,s=o|0;let _=$A(z,$,C);n=HA(_,k,W,S),o=_|0}({h:n,l:o}=Pi(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=Pi(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=Pi(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:f}=Pi(this.Dh|0,this.Dl|0,l|0,f|0),{h:u,l:h}=Pi(this.Eh|0,this.El|0,u|0,h|0),{h:d,l:m}=Pi(this.Fh|0,this.Fl|0,d|0,m|0),{h:y,l:w}=Pi(this.Gh|0,this.Gl|0,y|0,w|0),{h:x,l:E}=Pi(this.Hh|0,this.Hl|0,x|0,E|0),this.set(n,o,i,s,a,c,l,f,u,h,d,m,y,w,x,E)}roundClean(){zr(wa,xa)}destroy(){zr(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},Tw=class extends _w{Ah=Cr[0]|0;Al=Cr[1]|0;Bh=Cr[2]|0;Bl=Cr[3]|0;Ch=Cr[4]|0;Cl=Cr[5]|0;Dh=Cr[6]|0;Dl=Cr[7]|0;Eh=Cr[8]|0;El=Cr[9]|0;Fh=Cr[10]|0;Fl=Cr[11]|0;Gh=Cr[12]|0;Gl=Cr[13]|0;Hh=Cr[14]|0;Hl=Cr[15]|0;constructor(){super(64)}};var _o=Bh(()=>new Aw,bw(1));var ba=Bh(()=>new Tw,bw(3));var Iw=BigInt(0),Cw=BigInt(1);function bs(r,e=""){if(typeof r!="boolean"){let t=e&&`"${e}" `;throw new Error(t+"expected boolean, got type="+typeof r)}return r}function WA(r){if(typeof r=="bigint"){if(!og(r))throw new Error("positive bigint expected, got "+r)}else qr(r);return r}function Fh(r){let e=WA(r).toString(16);return e.length&1?"0"+e:e}function GA(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?Iw:BigInt("0x"+r)}function Yu(r){return GA(ys(r))}function Ri(r){return GA(ys(qc(ke(r)).reverse()))}function ig(r,e){qr(e),r=WA(r);let t=ws(r.toString(16).padStart(e*2,"0"));if(t.length!==e)throw new Error("number too large");return t}function $h(r,e){return ig(r,e).reverse()}function qc(r){return Uint8Array.from(r)}var og=r=>typeof r=="bigint"&&Iw<=r;function eH(r,e,t){return og(r)&&og(e)&&og(t)&&e<=r&&r<t}function va(r,e,t,n){if(!eH(e,t,n))throw new Error("expected valid "+r+": "+t+" <= n < "+n+", got "+e)}function kw(r){let e;for(e=0;r>Iw;r>>=Cw,e+=1);return e}var Hh=r=>(Cw<<BigInt(r))-Cw;function XA(r,e,t){if(qr(r,"hashLen"),qr(e,"qByteLen"),typeof t!="function")throw new Error("hmacFn must be a function");let n=w=>new Uint8Array(w),o=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),a=1e3,c=n(r),l=n(r),f=0,u=()=>{c.fill(1),l.fill(0),f=0},h=(...w)=>t(l,Sn(c,...w)),d=(w=o)=>{l=h(i,w),c=h(),w.length!==0&&(l=h(s,w),c=h())},m=()=>{if(f++>=a)throw new Error("drbg: tried max amount of iterations");let w=0,x=[];for(;w<e;){c=h();let E=c.slice();x.push(E),w+=c.length}return Sn(...x)};return(w,x)=>{u(),d(w);let E;for(;!(E=x(m()));)d();return u(),E}}function Oi(r,e={},t={}){if(!r||typeof r!="object")throw new Error("expected valid options object");function n(i,s,a){let c=r[i];if(a&&c===void 0)return;let l=typeof c;if(l!==s||c===null)throw new Error(`param "${i}" is invalid: expected ${s}, got ${l}`)}let o=(i,s)=>Object.entries(i).forEach(([a,c])=>n(a,c,s));o(e,!1),o(t,!0)}function Qu(r){let e=new WeakMap;return(t,...n)=>{let o=e.get(t);if(o!==void 0)return o;let i=r(t,...n);return e.set(t,i),i}}var sn=BigInt(0),wr=BigInt(1),zc=BigInt(2),ZA=BigInt(3),JA=BigInt(4),e_=BigInt(5),tH=BigInt(7),t_=BigInt(8),rH=BigInt(9),r_=BigInt(16);function Ot(r,e){let t=r%e;return t>=sn?t:e+t}function _t(r,e,t){let n=r;for(;e-- >sn;)n*=n,n%=t;return n}function YA(r,e){if(r===sn)throw new Error("invert: expected non-zero number");if(e<=sn)throw new Error("invert: expected positive modulus, got "+e);let t=Ot(r,e),n=e,o=sn,i=wr,s=wr,a=sn;for(;t!==sn;){let l=n/t,f=n%t,u=o-s*l,h=i-a*l;n=t,t=f,o=s,i=a,s=u,a=h}if(n!==wr)throw new Error("invert: does not exist");return Ot(o,e)}function Rw(r,e,t){if(!r.eql(r.sqr(e),t))throw new Error("Cannot find square root")}function n_(r,e){let t=(r.ORDER+wr)/JA,n=r.pow(e,t);return Rw(r,n,e),n}function nH(r,e){let t=(r.ORDER-e_)/t_,n=r.mul(e,zc),o=r.pow(n,t),i=r.mul(e,o),s=r.mul(r.mul(i,zc),o),a=r.mul(i,r.sub(s,r.ONE));return Rw(r,a,e),a}function oH(r){let e=Zu(r),t=o_(r),n=t(e,e.neg(e.ONE)),o=t(e,n),i=t(e,e.neg(n)),s=(r+tH)/r_;return(a,c)=>{let l=a.pow(c,s),f=a.mul(l,n),u=a.mul(l,o),h=a.mul(l,i),d=a.eql(a.sqr(f),c),m=a.eql(a.sqr(u),c);l=a.cmov(l,f,d),f=a.cmov(h,u,m);let y=a.eql(a.sqr(f),c),w=a.cmov(l,f,y);return Rw(a,w,c),w}}function o_(r){if(r<ZA)throw new Error("sqrt is not defined for small field");let e=r-wr,t=0;for(;e%zc===sn;)e/=zc,t++;let n=zc,o=Zu(r);for(;QA(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(t===1)return n_;let i=o.pow(n,e),s=(e+wr)/zc;return function(c,l){if(c.is0(l))return l;if(QA(c,l)!==1)throw new Error("Cannot find square root");let f=t,u=c.mul(c.ONE,i),h=c.pow(l,e),d=c.pow(l,s);for(;!c.eql(h,c.ONE);){if(c.is0(h))return c.ZERO;let m=1,y=c.sqr(h);for(;!c.eql(y,c.ONE);)if(m++,y=c.sqr(y),m===f)throw new Error("Cannot find square root");let w=wr<<BigInt(f-m-1),x=c.pow(u,w);f=m,u=c.sqr(x),h=c.mul(h,u),d=c.mul(d,x)}return d}}function iH(r){return r%JA===ZA?n_:r%t_===e_?nH:r%r_===rH?oH(r):o_(r)}var i_=(r,e)=>(Ot(r,e)&wr)===wr,sH=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ow(r){let e={ORDER:"bigint",BYTES:"number",BITS:"number"},t=sH.reduce((n,o)=>(n[o]="function",n),e);return Oi(r,t),r}function aH(r,e,t){if(t<sn)throw new Error("invalid exponent, negatives unsupported");if(t===sn)return r.ONE;if(t===wr)return e;let n=r.ONE,o=e;for(;t>sn;)t&wr&&(n=r.mul(n,o)),o=r.sqr(o),t>>=wr;return n}function Kh(r,e,t=!1){let n=new Array(e.length).fill(t?r.ZERO:void 0),o=e.reduce((s,a,c)=>r.is0(a)?s:(n[c]=s,r.mul(s,a)),r.ONE),i=r.inv(o);return e.reduceRight((s,a,c)=>r.is0(a)?s:(n[c]=r.mul(s,n[c]),r.mul(s,a)),i),n}function QA(r,e){let t=(r.ORDER-wr)/zc,n=r.pow(e,t),o=r.eql(n,r.ONE),i=r.eql(n,r.ZERO),s=r.eql(n,r.neg(r.ONE));if(!o&&!i&&!s)throw new Error("invalid Legendre symbol result");return o?1:i?0:-1}function cH(r,e){e!==void 0&&qr(e);let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}var Pw=class{ORDER;BITS;BYTES;isLE;ZERO=sn;ONE=wr;_lengths;_sqrt;_mod;constructor(e,t={}){if(e<=sn)throw new Error("invalid field: expected ORDER > 0, got "+e);let n;this.isLE=!1,t!=null&&typeof t=="object"&&(typeof t.BITS=="number"&&(n=t.BITS),typeof t.sqrt=="function"&&(this.sqrt=t.sqrt),typeof t.isLE=="boolean"&&(this.isLE=t.isLE),t.allowedLengths&&(this._lengths=t.allowedLengths?.slice()),typeof t.modFromBytes=="boolean"&&(this._mod=t.modFromBytes));let{nBitLength:o,nByteLength:i}=cH(e,n);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=o,this.BYTES=i,this._sqrt=void 0,Object.preventExtensions(this)}create(e){return Ot(e,this.ORDER)}isValid(e){if(typeof e!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof e);return sn<=e&&e<this.ORDER}is0(e){return e===sn}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&wr)===wr}neg(e){return Ot(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return Ot(e*e,this.ORDER)}add(e,t){return Ot(e+t,this.ORDER)}sub(e,t){return Ot(e-t,this.ORDER)}mul(e,t){return Ot(e*t,this.ORDER)}pow(e,t){return aH(this,e,t)}div(e,t){return Ot(e*YA(t,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,t){return e+t}subN(e,t){return e-t}mulN(e,t){return e*t}inv(e){return YA(e,this.ORDER)}sqrt(e){return this._sqrt||(this._sqrt=iH(this.ORDER)),this._sqrt(this,e)}toBytes(e){return this.isLE?$h(e,this.BYTES):ig(e,this.BYTES)}fromBytes(e,t=!1){ke(e);let{_lengths:n,BYTES:o,isLE:i,ORDER:s,_mod:a}=this;if(n){if(!n.includes(e.length)||e.length>o)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+e.length);let l=new Uint8Array(o);l.set(e,i?0:l.length-e.length),e=l}if(e.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);let c=i?Ri(e):Yu(e);if(a&&(c=Ot(c,s)),!t&&!this.isValid(c))throw new Error("invalid field element: outside of range 0..ORDER");return c}invertBatch(e){return Kh(this,e)}cmov(e,t,n){return n?t:e}};function Zu(r,e={}){return new Pw(r,e)}function s_(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let e=r.toString(2).length;return Math.ceil(e/8)}function Dw(r){let e=s_(r);return e+Math.ceil(e/2)}function Nw(r,e,t=!1){ke(r);let n=r.length,o=s_(e),i=Dw(e);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=t?Ri(r):Yu(r),a=Ot(s,e-wr)+wr;return t?$h(a,o):ig(a,o)}var Ju=BigInt(0),jc=BigInt(1);function Vh(r,e){let t=e.negate();return r?t:e}function Wc(r,e){let t=Kh(r.Fp,e.map(n=>n.Z));return e.map((n,o)=>r.fromAffine(n.toAffine(t[o])))}function u_(r,e){if(!Number.isSafeInteger(r)||r<=0||r>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+r)}function Lw(r,e){u_(r,e);let t=Math.ceil(e/r)+1,n=2**(r-1),o=2**r,i=Hh(r),s=BigInt(r);return{windows:t,windowSize:n,mask:i,maxNumber:o,shiftBy:s}}function a_(r,e,t){let{windowSize:n,mask:o,maxNumber:i,shiftBy:s}=t,a=Number(r&o),c=r>>s;a>n&&(a-=i,c+=jc);let l=e*n,f=l+Math.abs(a)-1,u=a===0,h=a<0,d=e%2!==0;return{nextN:c,offset:f,isZero:u,isNeg:h,isNegF:d,offsetF:l}}var Bw=new WeakMap,f_=new WeakMap;function Mw(r){return f_.get(r)||1}function c_(r){if(r!==Ju)throw new Error("invalid wNAF")}var ef=class{BASE;ZERO;Fn;bits;constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,n=this.ZERO){let o=e;for(;t>Ju;)t&jc&&(n=n.add(o)),o=o.double(),t>>=jc;return n}precomputeWindow(e,t){let{windows:n,windowSize:o}=Lw(t,this.bits),i=[],s=e,a=s;for(let c=0;c<n;c++){a=s,i.push(a);for(let l=1;l<o;l++)a=a.add(s),i.push(a);s=a.double()}return i}wNAF(e,t,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let o=this.ZERO,i=this.BASE,s=Lw(e,this.bits);for(let a=0;a<s.windows;a++){let{nextN:c,offset:l,isZero:f,isNeg:u,isNegF:h,offsetF:d}=a_(n,a,s);n=c,f?i=i.add(Vh(h,t[d])):o=o.add(Vh(u,t[l]))}return c_(n),{p:o,f:i}}wNAFUnsafe(e,t,n,o=this.ZERO){let i=Lw(e,this.bits);for(let s=0;s<i.windows&&n!==Ju;s++){let{nextN:a,offset:c,isZero:l,isNeg:f}=a_(n,s,i);if(n=a,!l){let u=t[c];o=o.add(f?u.negate():u)}}return c_(n),o}getPrecomputes(e,t,n){let o=Bw.get(t);return o||(o=this.precomputeWindow(t,e),e!==1&&(typeof n=="function"&&(o=n(o)),Bw.set(t,o))),o}cached(e,t,n){let o=Mw(e);return this.wNAF(o,this.getPrecomputes(o,e,n),t)}unsafe(e,t,n,o){let i=Mw(e);return i===1?this._unsafeLadder(e,t,o):this.wNAFUnsafe(i,this.getPrecomputes(i,e,n),t,o)}createCache(e,t){u_(t,this.bits),f_.set(e,t),Bw.delete(e)}hasCache(e){return Mw(e)!==1}};function d_(r,e,t,n){let o=e,i=r.ZERO,s=r.ZERO;for(;t>Ju||n>Ju;)t&jc&&(i=i.add(o)),n&jc&&(s=s.add(o)),o=o.double(),t>>=jc,n>>=jc;return{p1:i,p2:s}}function l_(r,e,t){if(e){if(e.ORDER!==r)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Ow(e),e}else return Zu(r,{isLE:t})}function sg(r,e,t={},n){if(n===void 0&&(n=r==="edwards"),!e||typeof e!="object")throw new Error(`expected valid ${r} CURVE object`);for(let c of["p","n","h"]){let l=e[c];if(!(typeof l=="bigint"&&l>Ju))throw new Error(`CURVE.${c} must be positive bigint`)}let o=l_(e.p,t.Fp,n),i=l_(e.n,t.Fn,n),a=["Gx","Gy","a",r==="weierstrass"?"b":"d"];for(let c of a)if(!o.isValid(e[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:o,Fn:i}}function tf(r,e){return function(n){let o=r(n);return{secretKey:o,publicKey:e(o)}}}var Ea=BigInt(0),xr=BigInt(1),Uw=BigInt(2),lH=BigInt(8);function uH(r,e,t,n){let o=r.sqr(t),i=r.sqr(n),s=r.add(r.mul(e.a,o),i),a=r.add(r.ONE,r.mul(e.d,r.mul(o,i)));return r.eql(s,a)}function h_(r,e={}){let t=sg("edwards",r,e,e.FpFnLE),{Fp:n,Fn:o}=t,i=t.CURVE,{h:s}=i;Oi(e,{},{uvRatio:"function"});let a=Uw<<BigInt(o.BYTES*8)-xr,c=w=>n.create(w),l=e.uvRatio||((w,x)=>{try{return{isValid:!0,value:n.sqrt(n.div(w,x))}}catch{return{isValid:!1,value:Ea}}});if(!uH(n,i,i.Gx,i.Gy))throw new Error("bad curve params: generator point");function f(w,x,E=!1){let v=E?xr:Ea;return va("coordinate "+w,x,v,a),x}function u(w){if(!(w instanceof m))throw new Error("EdwardsPoint expected")}let h=Qu((w,x)=>{let{X:E,Y:v,Z:I}=w,F=w.is0();x==null&&(x=F?lH:n.inv(I));let V=c(E*x),M=c(v*x),T=n.mul(I,x);if(F)return{x:Ea,y:xr};if(T!==xr)throw new Error("invZ was invalid");return{x:V,y:M}}),d=Qu(w=>{let{a:x,d:E}=i;if(w.is0())throw new Error("bad point: ZERO");let{X:v,Y:I,Z:F,T:V}=w,M=c(v*v),T=c(I*I),k=c(F*F),z=c(k*k),W=c(M*x),$=c(k*c(W+T)),S=c(z+c(E*c(M*T)));if($!==S)throw new Error("bad point: equation left != right (1)");let C=c(v*I),_=c(F*V);if(C!==_)throw new Error("bad point: equation left != right (2)");return!0});class m{static BASE=new m(i.Gx,i.Gy,xr,c(i.Gx*i.Gy));static ZERO=new m(Ea,xr,xr,Ea);static Fp=n;static Fn=o;X;Y;Z;T;constructor(x,E,v,I){this.X=f("x",x),this.Y=f("y",E),this.Z=f("z",v,!0),this.T=f("t",I),Object.freeze(this)}static CURVE(){return i}static fromAffine(x){if(x instanceof m)throw new Error("extended point not allowed");let{x:E,y:v}=x||{};return f("x",E),f("y",v),new m(E,v,xr,c(E*v))}static fromBytes(x,E=!1){let v=n.BYTES,{a:I,d:F}=i;x=qc(ke(x,v,"point")),bs(E,"zip215");let V=qc(x),M=x[v-1];V[v-1]=M&-129;let T=Ri(V),k=E?a:n.ORDER;va("point.y",T,Ea,k);let z=c(T*T),W=c(z-xr),$=c(F*z-I),{isValid:S,value:C}=l(W,$);if(!S)throw new Error("bad point: invalid y coordinate");let _=(C&xr)===xr,B=(M&128)!==0;if(!E&&C===Ea&&B)throw new Error("bad point: x=0 and x_0=1");return B!==_&&(C=c(-C)),m.fromAffine({x:C,y:T})}static fromHex(x,E=!1){return m.fromBytes(ws(x),E)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(x=8,E=!0){return y.createCache(this,x),E||this.multiply(Uw),this}assertValidity(){d(this)}equals(x){u(x);let{X:E,Y:v,Z:I}=this,{X:F,Y:V,Z:M}=x,T=c(E*M),k=c(F*I),z=c(v*M),W=c(V*I);return T===k&&z===W}is0(){return this.equals(m.ZERO)}negate(){return new m(c(-this.X),this.Y,this.Z,c(-this.T))}double(){let{a:x}=i,{X:E,Y:v,Z:I}=this,F=c(E*E),V=c(v*v),M=c(Uw*c(I*I)),T=c(x*F),k=E+v,z=c(c(k*k)-F-V),W=T+V,$=W-M,S=T-V,C=c(z*$),_=c(W*S),B=c(z*S),X=c($*W);return new m(C,_,X,B)}add(x){u(x);let{a:E,d:v}=i,{X:I,Y:F,Z:V,T:M}=this,{X:T,Y:k,Z:z,T:W}=x,$=c(I*T),S=c(F*k),C=c(M*v*W),_=c(V*z),B=c((I+F)*(T+k)-$-S),X=_-C,G=_+C,U=c(S-E*$),Q=c(B*X),ne=c(G*U),K=c(B*U),De=c(X*G);return new m(Q,ne,De,K)}subtract(x){return this.add(x.negate())}multiply(x){if(!o.isValidNot0(x))throw new Error("invalid scalar: expected 1 <= sc < curve.n");let{p:E,f:v}=y.cached(this,x,I=>Wc(m,I));return Wc(m,[E,v])[0]}multiplyUnsafe(x,E=m.ZERO){if(!o.isValid(x))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return x===Ea?m.ZERO:this.is0()||x===xr?this:y.unsafe(this,x,v=>Wc(m,v),E)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}isTorsionFree(){return y.unsafe(this,i.n).is0()}toAffine(x){return h(this,x)}clearCofactor(){return s===xr?this:this.multiplyUnsafe(s)}toBytes(){let{x,y:E}=this.toAffine(),v=n.toBytes(E);return v[v.length-1]|=x&xr?128:0,v}toHex(){return ys(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let y=new ef(m,o.BITS);return m.BASE.precompute(8),m}function p_(r,e,t={}){if(typeof e!="function")throw new Error('"hash" function param is required');Oi(t,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});let{prehash:n}=t,{BASE:o,Fp:i,Fn:s}=r,a=t.randomBytes||ki,c=t.adjustScalarBytes||(T=>T),l=t.domain||((T,k,z)=>{if(bs(z,"phflag"),k.length||z)throw new Error("Contexts/pre-hash are not supported");return T});function f(T){return s.create(Ri(T))}function u(T){let k=v.secretKey;ke(T,v.secretKey,"secretKey");let z=ke(e(T),2*k,"hashedSecretKey"),W=c(z.slice(0,k)),$=z.slice(k,2*k),S=f(W);return{head:W,prefix:$,scalar:S}}function h(T){let{head:k,prefix:z,scalar:W}=u(T),$=o.multiply(W),S=$.toBytes();return{head:k,prefix:z,scalar:W,point:$,pointBytes:S}}function d(T){return h(T).pointBytes}function m(T=Uint8Array.of(),...k){let z=Sn(...k);return f(e(l(z,ke(T,void 0,"context"),!!n)))}function y(T,k,z={}){T=ke(T,void 0,"message"),n&&(T=n(T));let{prefix:W,scalar:$,pointBytes:S}=h(k),C=m(z.context,W,T),_=o.multiply(C).toBytes(),B=m(z.context,_,S,T),X=s.create(C+B*$);if(!s.isValid(X))throw new Error("sign failed: invalid s");let G=Sn(_,s.toBytes(X));return ke(G,v.signature,"result")}let w={zip215:!0};function x(T,k,z,W=w){let{context:$,zip215:S}=W,C=v.signature;T=ke(T,C,"signature"),k=ke(k,void 0,"message"),z=ke(z,v.publicKey,"publicKey"),S!==void 0&&bs(S,"zip215"),n&&(k=n(k));let _=C/2,B=T.subarray(0,_),X=Ri(T.subarray(_,C)),G,U,Q;try{G=r.fromBytes(z,S),U=r.fromBytes(B,S),Q=o.multiplyUnsafe(X)}catch{return!1}if(!S&&G.isSmallOrder())return!1;let ne=m($,U.toBytes(),G.toBytes(),k);return U.add(G.multiplyUnsafe(ne)).subtract(Q).clearCofactor().is0()}let E=i.BYTES,v={secretKey:E,publicKey:E,signature:2*E,seed:E};function I(T=a(v.seed)){return ke(T,v.seed,"seed")}function F(T){return Fc(T)&&T.length===s.BYTES}function V(T,k){try{return!!r.fromBytes(T,k)}catch{return!1}}let M={getExtendedPublicKey:h,randomSecretKey:I,isValidSecretKey:F,isValidPublicKey:V,toMontgomery(T){let{y:k}=r.fromBytes(T),z=v.publicKey,W=z===32;if(!W&&z!==57)throw new Error("only defined for 25519 and 448");let $=W?i.div(xr+k,xr-k):i.div(k-xr,k+xr);return i.toBytes($)},toMontgomerySecret(T){let k=v.secretKey;ke(T,k);let z=e(T.subarray(0,k));return c(z).subarray(0,k)}};return Object.freeze({keygen:tf(I,d),getPublicKey:d,sign:y,verify:x,utils:M,Point:r,lengths:v})}var qh=BigInt(0),rf=BigInt(1),ag=BigInt(2);function fH(r){return Oi(r,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze({...r})}function m_(r){let e=fH(r),{P:t,type:n,adjustScalarBytes:o,powPminus2:i,randomBytes:s}=e,a=n==="x25519";if(!a&&n!=="x448")throw new Error("invalid type");let c=s||ki,l=a?255:448,f=a?32:56,u=BigInt(a?9:5),h=BigInt(a?121665:39081),d=a?ag**BigInt(254):ag**BigInt(447),m=a?BigInt(8)*ag**BigInt(251)-rf:BigInt(4)*ag**BigInt(445)-rf,y=d+m+rf,w=C=>Ot(C,t),x=E(u);function E(C){return $h(w(C),f)}function v(C){let _=qc(ke(C,f,"uCoordinate"));return a&&(_[31]&=127),w(Ri(_))}function I(C){return Ri(o(qc(ke(C,f,"scalar"))))}function F(C,_){let B=z(v(_),I(C));if(B===qh)throw new Error("invalid private or public key received");return E(B)}function V(C){return F(C,x)}let M=V,T=F;function k(C,_,B){let X=w(C*(_-B));return _=w(_-X),B=w(B+X),{x_2:_,x_3:B}}function z(C,_){va("u",C,qh,t),va("scalar",_,d,y);let B=_,X=C,G=rf,U=qh,Q=C,ne=rf,K=qh;for(let Me=BigInt(l-1);Me>=qh;Me--){let he=B>>Me&rf;K^=he,{x_2:G,x_3:Q}=k(K,G,Q),{x_2:U,x_3:ne}=k(K,U,ne),K=he;let Ke=G+U,at=w(Ke*Ke),Pt=G-U,We=w(Pt*Pt),ct=at-We,ls=Q+ne,Go=Q-ne,fa=w(Go*Ke),U0=w(ls*Pt),Bu=fa+U0,bh=fa-U0;Q=w(Bu*Bu),ne=w(X*w(bh*bh)),G=w(at*We),U=w(ct*(at+w(h*ct)))}({x_2:G,x_3:Q}=k(K,G,Q)),{x_2:U,x_3:ne}=k(K,U,ne);let De=i(U);return w(G*De)}let W={secretKey:f,publicKey:f,seed:f},$=(C=c(f))=>(ke(C,W.seed,"seed"),C),S={randomSecretKey:$};return Object.freeze({keygen:tf($,M),getSharedSecret:T,getPublicKey:M,scalarMult:F,scalarMultBase:V,utils:S,GuBytes:x.slice(),lengths:W})}var dH=BigInt(1),g_=BigInt(2),hH=BigInt(3),pH=BigInt(5),mH=BigInt(8),cg=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),gH={p:cg,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:mH,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function w_(r){let e=BigInt(10),t=BigInt(20),n=BigInt(40),o=BigInt(80),i=cg,a=r*r%i*r%i,c=_t(a,g_,i)*a%i,l=_t(c,dH,i)*r%i,f=_t(l,pH,i)*l%i,u=_t(f,e,i)*f%i,h=_t(u,t,i)*u%i,d=_t(h,n,i)*h%i,m=_t(d,o,i)*d%i,y=_t(m,o,i)*d%i,w=_t(y,e,i)*f%i;return{pow_p_5_8:_t(w,g_,i)*r%i,b2:a}}function x_(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}var y_=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function yH(r,e){let t=cg,n=Ot(e*e*e,t),o=Ot(n*n*e,t),i=w_(r*o).pow_p_5_8,s=Ot(r*n*i,t),a=Ot(e*s*s,t),c=s,l=Ot(s*y_,t),f=a===r,u=a===Ot(-r,t),h=a===Ot(-r*y_,t);return f&&(s=c),(u||h)&&(s=l),i_(s,t)&&(s=Ot(-s,t)),{isValid:f||u,value:s}}var wH=h_(gH,{uvRatio:yH});function xH(r){return p_(wH,ba,Object.assign({adjustScalarBytes:x_},r))}var zh=xH({});var jh=(()=>{let r=cg;return m_({P:r,type:"x25519",powPminus2:e=>{let{pow_p_5_8:t,b2:n}=w_(e);return Ot(_t(t,hH,r)*n,r)},adjustScalarBytes:x_})})();var Gc=32,Xn=64,Fw=32;var nf,b_=(async()=>{try{return await Qt.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();function v_(){let r=zh.utils.randomSecretKey(),e=zh.getPublicKey(r);return{privateKey:AH(r,e),publicKey:e}}async function bH(r,e){let t;r.length===Xn?t=r.subarray(0,32):t=r;let n={crv:"Ed25519",kty:"OKP",x:H(r.subarray(32),"base64url"),d:H(t,"base64url"),ext:!0,key_ops:["sign"]},o=await Qt.get().subtle.importKey("jwk",n,{name:"Ed25519"},!0,["sign"]),i=await Qt.get().subtle.sign({name:"Ed25519"},o,e instanceof Uint8Array?e:e.subarray());return new Uint8Array(i,0,i.byteLength)}function vH(r,e){let t=r.subarray(0,Fw);return zh.sign(e instanceof Uint8Array?e:e.subarray(),t)}async function E_(r,e){return nf==null&&(nf=await b_),nf?bH(r,e):vH(r,e)}async function EH(r,e,t){if(r.buffer instanceof ArrayBuffer){let n=await Qt.get().subtle.importKey("raw",r.buffer,{name:"Ed25519"},!1,["verify"]);return await Qt.get().subtle.verify({name:"Ed25519"},n,e,t instanceof Uint8Array?t:t.subarray())}throw new TypeError("WebCrypto does not support SharedArrayBuffer for Ed25519 keys")}function SH(r,e,t){return zh.verify(e,t instanceof Uint8Array?t:t.subarray(),r)}async function S_(r,e,t){return nf==null&&(nf=await b_),nf?EH(r,e,t):SH(r,e,t)}function AH(r,e){let t=new Uint8Array(Xn);for(let n=0;n<Fw;n++)t[n]=r[n],t[Fw+n]=e[n];return t}function of(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}var Wh=class{type="Ed25519";raw;constructor(e){this.raw=af(e,Gc)}toMultihash(){return $t.digest(yr(this))}toCID(){return Z.createV1(114,this.toMultihash())}toString(){return Qe.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:me(this.raw,e.raw)}verify(e,t,n){n?.signal?.throwIfAborted();let o=S_(this.raw,t,e);return of(o)?o.then(i=>(n?.signal?.throwIfAborted(),i)):o}},sf=class{type="Ed25519";raw;publicKey;constructor(e,t){this.raw=af(e,Xn),this.publicKey=new Wh(t)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:me(this.raw,e.raw)}sign(e,t){t?.signal?.throwIfAborted();let n=E_(this.raw,e);return of(n)?n.then(o=>(t?.signal?.throwIfAborted(),o)):(t?.signal?.throwIfAborted(),n)}};function $w(r){if(r.length>Xn){r=af(r,Xn+Gc);let n=r.subarray(0,Xn),o=r.subarray(Xn,r.length);return new sf(n,o)}r=af(r,Xn);let e=r.subarray(0,Xn),t=r.subarray(Gc);return new sf(e,t)}function Hw(r){return r=af(r,Gc),new Wh(r)}async function __(){let{privateKey:r,publicKey:e}=v_();return new sf(r,e)}function af(r,e){if(r=Uint8Array.from(r??[]),r.length!==e)throw new O(`Key must be a Uint8Array of length ${e}, got ${r.length}`);return r}var _H=Math.pow(2,7),TH=Math.pow(2,14),CH=Math.pow(2,21),Kw=Math.pow(2,28),Vw=Math.pow(2,35),qw=Math.pow(2,42),zw=Math.pow(2,49),lt=128,jr=127;function Fe(r){if(r<_H)return 1;if(r<TH)return 2;if(r<CH)return 3;if(r<Kw)return 4;if(r<Vw)return 5;if(r<qw)return 6;if(r<zw)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function cf(r,e,t=0){switch(Fe(r)){case 8:e[t++]=r&255|lt,r/=128;case 7:e[t++]=r&255|lt,r/=128;case 6:e[t++]=r&255|lt,r/=128;case 5:e[t++]=r&255|lt,r/=128;case 4:e[t++]=r&255|lt,r>>>=7;case 3:e[t++]=r&255|lt,r>>>=7;case 2:e[t++]=r&255|lt,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function IH(r,e,t=0){switch(Fe(r)){case 8:e.set(t++,r&255|lt),r/=128;case 7:e.set(t++,r&255|lt),r/=128;case 6:e.set(t++,r&255|lt),r/=128;case 5:e.set(t++,r&255|lt),r/=128;case 4:e.set(t++,r&255|lt),r>>>=7;case 3:e.set(t++,r&255|lt),r>>>=7;case 2:e.set(t++,r&255|lt),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function jw(r,e){let t=r[e],n=0;if(n+=t&jr,t<lt||(t=r[e+1],n+=(t&jr)<<7,t<lt)||(t=r[e+2],n+=(t&jr)<<14,t<lt)||(t=r[e+3],n+=(t&jr)<<21,t<lt)||(t=r[e+4],n+=(t&jr)*Kw,t<lt)||(t=r[e+5],n+=(t&jr)*Vw,t<lt)||(t=r[e+6],n+=(t&jr)*qw,t<lt)||(t=r[e+7],n+=(t&jr)*zw,t<lt))return n;throw new RangeError("Could not decode varint")}function kH(r,e){let t=r.get(e),n=0;if(n+=t&jr,t<lt||(t=r.get(e+1),n+=(t&jr)<<7,t<lt)||(t=r.get(e+2),n+=(t&jr)<<14,t<lt)||(t=r.get(e+3),n+=(t&jr)<<21,t<lt)||(t=r.get(e+4),n+=(t&jr)*Kw,t<lt)||(t=r.get(e+5),n+=(t&jr)*Vw,t<lt)||(t=r.get(e+6),n+=(t&jr)*qw,t<lt)||(t=r.get(e+7),n+=(t&jr)*zw,t<lt))return n;throw new RangeError("Could not decode varint")}function Wr(r,e,t=0){return e==null&&(e=Nt(Fe(r))),e instanceof Uint8Array?cf(r,e,t):IH(r,e,t)}function Yn(r,e=0){return r instanceof Uint8Array?jw(r,e):kH(r,e)}var Ww=new Float32Array([-0]),Sa=new Uint8Array(Ww.buffer);function T_(r,e,t){Ww[0]=r,e[t]=Sa[0],e[t+1]=Sa[1],e[t+2]=Sa[2],e[t+3]=Sa[3]}function C_(r,e){return Sa[0]=r[e],Sa[1]=r[e+1],Sa[2]=r[e+2],Sa[3]=r[e+3],Ww[0]}var Gw=new Float64Array([-0]),Gr=new Uint8Array(Gw.buffer);function I_(r,e,t){Gw[0]=r,e[t]=Gr[0],e[t+1]=Gr[1],e[t+2]=Gr[2],e[t+3]=Gr[3],e[t+4]=Gr[4],e[t+5]=Gr[5],e[t+6]=Gr[6],e[t+7]=Gr[7]}function k_(r,e){return Gr[0]=r[e],Gr[1]=r[e+1],Gr[2]=r[e+2],Gr[3]=r[e+3],Gr[4]=r[e+4],Gr[5]=r[e+5],Gr[6]=r[e+6],Gr[7]=r[e+7],Gw[0]}var PH=BigInt(Number.MAX_SAFE_INTEGER),RH=BigInt(Number.MIN_SAFE_INTEGER),Qn=class r{lo;hi;constructor(e,t){this.lo=e|0,this.hi=t|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(t+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(BigInt(t)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?t===0?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return Xc;if(e<PH&&e>RH)return this.fromNumber(Number(e));let t=e<0n;t&&(e=-e);let n=e>>32n,o=e-(n<<32n);return t&&(n=~n|0n,o=~o|0n,++o>P_&&(o=0n,++n>P_&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(e){if(e===0)return Xc;let t=e<0;t&&(e=-e);let n=e>>>0,o=(e-n)/4294967296>>>0;return t&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}static from(e){return typeof e=="number"?r.fromNumber(e):typeof e=="bigint"?r.fromBigInt(e):typeof e=="string"?r.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new r(e.low>>>0,e.high>>>0):Xc}},Xc=new Qn(0,0);Xc.toBigInt=function(){return 0n};Xc.zzEncode=Xc.zzDecode=function(){return this};Xc.length=function(){return 1};var P_=4294967296n;function R_(r){let e=0,t=0;for(let n=0;n<r.length;++n)t=r.charCodeAt(n),t<128?e+=1:t<2048?e+=2:(t&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,e+=4):e+=3;return e}function O_(r,e,t){if(t-e<1)return"";let o,i=[],s=0,a;for(;e<t;)a=r[e++],a<128?i[s++]=a:a>191&&a<224?i[s++]=(a&31)<<6|r[e++]&63:a>239&&a<365?(a=((a&7)<<18|(r[e++]&63)<<12|(r[e++]&63)<<6|r[e++]&63)-65536,i[s++]=55296+(a>>10),i[s++]=56320+(a&1023)):i[s++]=(a&15)<<12|(r[e++]&63)<<6|r[e++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function Xw(r,e,t){let n=t,o,i;for(let s=0;s<r.length;++s)o=r.charCodeAt(s),o<128?e[t++]=o:o<2048?(e[t++]=o>>6|192,e[t++]=o&63|128):(o&64512)===55296&&((i=r.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,e[t++]=o>>18|240,e[t++]=o>>12&63|128,e[t++]=o>>6&63|128,e[t++]=o&63|128):(e[t++]=o>>12|224,e[t++]=o>>6&63|128,e[t++]=o&63|128);return t-n}function ei(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function lg(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}var Yw=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,ei(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw ei(this,4);return lg(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw ei(this,4);return lg(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw ei(this,4);let e=C_(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw ei(this,4);let e=k_(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),t=this.pos,n=this.pos+e;if(n>this.len)throw ei(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return O_(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw ei(this,e);this.pos+=e}else do if(this.pos>=this.len)throw ei(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new Qn(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw ei(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<t*7)>>>0,e}if(this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw ei(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw ei(this,8);let e=lg(this.buf,this.pos+=4),t=lg(this.buf,this.pos+=4);return new Qn(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=jw(this.buf,this.pos);return this.pos+=Fe(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function Qw(r){return new Yw(r instanceof Uint8Array?r:r.subarray())}function xe(r,e,t){let n=Qw(r);return e.decode(n,void 0,t)}function Zw(r){let e=r??8192,t=e>>>1,n,o=e;return function(s){if(s<1||s>t)return Nt(s);o+s>e&&(n=Nt(e),o=0);let a=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),a}}var Yc=class{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}};function Jw(){}var t7=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},OH=Zw();function DH(r){return globalThis.Buffer!=null?Nt(r):OH(r)}var Xh=class{len;head;tail;states;constructor(){this.len=0,this.head=new Yc(Jw,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new Yc(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new r7((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(ug,10,Qn.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=Qn.fromBigInt(e);return this._push(ug,t.length(),t)}uint64Number(e){return this._push(cf,Fe(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let t=Qn.fromBigInt(e).zzEncode();return this._push(ug,t.length(),t)}sint64Number(e){let t=Qn.fromNumber(e).zzEncode();return this._push(ug,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(e7,1,e?1:0)}fixed32(e){return this._push(Gh,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=Qn.fromBigInt(e);return this._push(Gh,4,t.lo)._push(Gh,4,t.hi)}fixed64Number(e){let t=Qn.fromNumber(e);return this._push(Gh,4,t.lo)._push(Gh,4,t.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(T_,4,e)}double(e){return this._push(I_,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(e7,1,0):this.uint32(t)._push(LH,t,e)}string(e){let t=R_(e);return t!==0?this.uint32(t)._push(Xw,t,e):this._push(e7,1,0)}fork(){return this.states=new t7(this),this.head=this.tail=new Yc(Jw,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 Yc(Jw,0,0),this.len=0),this}ldelim(){let e=this.head,t=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=t,this.len+=n),this}finish(){let e=this.head.next,t=DH(this.len),n=0;for(;e!=null;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}};function e7(r,e,t){e[t]=r&255}function NH(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var r7=class extends Yc{next;constructor(e,t){super(NH,e,t),this.next=void 0}};function ug(r,e,t){for(;r.hi!==0;)e[t++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)e[t++]=r.lo&127|128,r.lo=r.lo>>>7;e[t++]=r.lo}function Gh(r,e,t){e[t]=r&255,e[t+1]=r>>>8&255,e[t+2]=r>>>16&255,e[t+3]=r>>>24}function LH(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(Xh.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(BH,e,r),this},Xh.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(MH,e,r),this});function BH(r,e,t){e.set(r,t)}function MH(r,e,t){r.length<40?Xw(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(D(r),t)}function n7(){return new Xh}function be(r,e){let t=n7();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var lf;(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"})(lf||(lf={}));function fg(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function wt(r){function e(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let t=function(i,s){let a=e(i);s.int32(a)},n=function(i){let s=i.int32();return e(s)};return fg("enum",lf.VARINT,t,n)}function ve(r,e){return fg("message",lf.LENGTH_DELIMITED,r,e)}var ht=class extends Error{code="ERR_MAX_LENGTH";name="MaxLengthError"},Yh=class extends Error{code="ERR_MAX_SIZE";name="MaxSizeError"};var xt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(xt||(xt={}));var o7;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(o7||(o7={}));(function(r){r.codec=()=>wt(o7)})(xt||(xt={}));var Di;(function(r){let e;r.codec=()=>(e==null&&(e=ve((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),xt.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),o.lengthDelimited!==!1&&n.ldelim()},(t,n,o={})=>{let i={},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let a=t.uint32();switch(a>>>3){case 1:{i.Type=xt.codec().decode(t);break}case 2:{i.Data=t.bytes();break}default:{t.skipType(a&7);break}}}return i})),e),r.encode=t=>be(t,r.codec()),r.decode=(t,n)=>xe(t,r.codec(),n)})(Di||(Di={}));var Qh;(function(r){let e;r.codec=()=>(e==null&&(e=ve((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),xt.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),o.lengthDelimited!==!1&&n.ldelim()},(t,n,o={})=>{let i={},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let a=t.uint32();switch(a>>>3){case 1:{i.Type=xt.codec().decode(t);break}case 2:{i.Data=t.bytes();break}default:{t.skipType(a&7);break}}}return i})),e),r.encode=t=>be(t,r.codec()),r.decode=(t,n)=>xe(t,r.codec(),n)})(Qh||(Qh={}));function an(r){if(isNaN(r)||r<=0)throw new O("random bytes length must be a Number bigger than 0");return ki(r)}var Jh={};Dt(Jh,{MAX_RSA_KEY_SIZE:()=>i7,generateRSAKeyPair:()=>p7,jwkToJWKKeyPair:()=>M_,jwkToPkcs1:()=>HH,jwkToPkix:()=>l7,jwkToRSAPrivateKey:()=>h7,pkcs1MessageToJwk:()=>a7,pkcs1MessageToRSAPrivateKey:()=>dg,pkcs1ToJwk:()=>$H,pkcs1ToRSAPrivateKey:()=>u7,pkixMessageToJwk:()=>c7,pkixMessageToRSAPublicKey:()=>d7,pkixToJwk:()=>KH,pkixToRSAPublicKey:()=>f7});var uf=class{type="RSA";jwk;_raw;_multihash;constructor(e,t){this.jwk=e,this._multihash=t}get raw(){return this._raw==null&&(this._raw=Jh.jwkToPkix(this.jwk)),this._raw}toMultihash(){return this._multihash}toCID(){return Z.createV1(114,this._multihash)}toString(){return Qe.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:me(this.raw,e.raw)}verify(e,t,n){return B_(this.jwk,t,e,n)}},Zh=class{type="RSA";jwk;_raw;publicKey;constructor(e,t){this.jwk=e,this.publicKey=t}get raw(){return this._raw==null&&(this._raw=Jh.jwkToPkcs1(this.jwk)),this._raw}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:me(this.raw,e.raw)}sign(e,t){return L_(this.jwk,e,t)}};var i7=8192,s7=18,UH=1062,FH=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function $H(r){let e=Ao(r);return a7(e)}function a7(r){return{n:H(r[1],"base64url"),e:H(r[2],"base64url"),d:H(r[3],"base64url"),p:H(r[4],"base64url"),q:H(r[5],"base64url"),dp:H(r[6],"base64url"),dq:H(r[7],"base64url"),qi:H(r[8],"base64url"),kty:"RSA"}}function HH(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 O("JWK was missing components");return Zo([on(Uint8Array.from([0])),on(D(r.n,"base64url")),on(D(r.e,"base64url")),on(D(r.d,"base64url")),on(D(r.p,"base64url")),on(D(r.q,"base64url")),on(D(r.dp,"base64url")),on(D(r.dq,"base64url")),on(D(r.qi,"base64url"))]).subarray()}function KH(r){let e=Ao(r,{offset:0});return c7(e)}function c7(r){let e=Ao(r[1],{offset:0});return{kty:"RSA",n:H(e[0],"base64url"),e:H(e[1],"base64url")}}function l7(r){if(r.n==null||r.e==null)throw new O("JWK was missing components");return Zo([FH,Lh(Zo([on(D(r.n,"base64url")),on(D(r.e,"base64url"))]))]).subarray()}function u7(r){let e=Ao(r);return dg(e)}function dg(r){let e=a7(r);return h7(e)}function f7(r,e){if(r.byteLength>=UH)throw new fs("Key size is too large");let t=Ao(r,{offset:0});return d7(t,r,e)}function d7(r,e,t){let n=c7(r);if(t==null){let o=_o(Di.encode({Type:xt.RSA,Data:e}));t=nn(s7,o)}return new uf(n,t)}function h7(r){if(F_(r)>i7)throw new O("Key size is too large");let e=M_(r),t=_o(Di.encode({Type:xt.RSA,Data:l7(e.publicKey)})),n=nn(s7,t);return new Zh(e.privateKey,new uf(e.publicKey,n))}async function p7(r){if(r>i7)throw new O("Key size is too large");let e=await U_(r),t=_o(Di.encode({Type:xt.RSA,Data:l7(e.publicKey)})),n=nn(s7,t);return new Zh(e.privateKey,new uf(e.publicKey,n))}function M_(r){if(r==null)throw new O("Missing key parameter");return{privateKey:r,publicKey:{kty:r.kty,n:r.n,e:r.e}}}async function U_(r,e){let t=await Qt.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:r,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]);e?.signal?.throwIfAborted();let n=await VH(t,e);return{privateKey:n[0],publicKey:n[1]}}async function L_(r,e,t){let n=await Qt.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]);t?.signal?.throwIfAborted();let o=await Qt.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},n,e instanceof Uint8Array?e:e.subarray());return t?.signal?.throwIfAborted(),new Uint8Array(o,0,o.byteLength)}async function B_(r,e,t,n){let o=await Qt.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);n?.signal?.throwIfAborted();let i=await Qt.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},o,e,t instanceof Uint8Array?t:t.subarray());return n?.signal?.throwIfAborted(),i}async function VH(r,e){if(r.privateKey==null||r.publicKey==null)throw new O("Private and public key are required");let t=await Promise.all([Qt.get().subtle.exportKey("jwk",r.privateKey),Qt.get().subtle.exportKey("jwk",r.publicKey)]);return e?.signal?.throwIfAborted(),t}function F_(r){if(r.kty!=="RSA")throw new O("invalid key type");if(r.n==null)throw new O("invalid key modulus");return D(r.n,"base64url").length*8}var hg=class{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(e,t){if(gs(e),ke(t,void 0,"key"),this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,o=new Uint8Array(n);o.set(t.length>n?e.create().update(t).digest():t);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=e.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),zr(o)}update(e){return Xu(this),this.iHash.update(e),this}digestInto(e){Xu(this),ke(e,this.outputLen,"output"),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:a}=this;return e=e,e.finished=o,e.destroyed=i,e.blockLen=s,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Aa=(r,e,t)=>new hg(r,e).update(t).digest();Aa.create=(r,e)=>new hg(r,e);var $_=(r,e)=>(r+(r>=0?e:-e)/H_)/e;function qH(r,e,t){let[[n,o],[i,s]]=e,a=$_(s*r,t),c=$_(-o*r,t),l=r-a*n-c*i,f=-a*o-c*s,u=l<Es,h=f<Es;u&&(l=-l),h&&(f=-f);let d=Hh(Math.ceil(kw(t)/2))+ff;if(l<Es||l>=d||f<Es||f>=d)throw new Error("splitScalar (endomorphism): failed, k="+r);return{k1neg:u,k1:l,k2neg:h,k2:f}}function g7(r){if(!["compact","recovered","der"].includes(r))throw new Error('Signature format must be "compact", "recovered", or "der"');return r}function m7(r,e){let t={};for(let n of Object.keys(e))t[n]=r[n]===void 0?e[n]:r[n];return bs(t.lowS,"lowS"),bs(t.prehash,"prehash"),t.format!==void 0&&g7(t.format),t}var y7=class extends Error{constructor(e=""){super(e)}},_a={Err:y7,_tlv:{encode:(r,e)=>{let{Err:t}=_a;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length&1)throw new t("tlv.encode: unpadded data");let n=e.length/2,o=Fh(n);if(o.length/2&128)throw new t("tlv.encode: long form length too big");let i=n>127?Fh(o.length/2|128):"";return Fh(r)+i+o+e},decode(r,e){let{Err:t}=_a,n=0;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length<2||e[n++]!==r)throw new t("tlv.decode: wrong tlv");let o=e[n++],i=!!(o&128),s=0;if(!i)s=o;else{let c=o&127;if(!c)throw new t("tlv.decode(long): indefinite length not supported");if(c>4)throw new t("tlv.decode(long): byte length is too big");let l=e.subarray(n,n+c);if(l.length!==c)throw new t("tlv.decode: length bytes not complete");if(l[0]===0)throw new t("tlv.decode(long): zero leftmost byte");for(let f of l)s=s<<8|f;if(n+=c,s<128)throw new t("tlv.decode(long): not minimal encoding")}let a=e.subarray(n,n+s);if(a.length!==s)throw new t("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+s)}}},_int:{encode(r){let{Err:e}=_a;if(r<Es)throw new e("integer: negative integers are not allowed");let t=Fh(r);if(Number.parseInt(t[0],16)&8&&(t="00"+t),t.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return t},decode(r){let{Err:e}=_a;if(r[0]&128)throw new e("invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return Yu(r)}},toSig(r){let{Err:e,_int:t,_tlv:n}=_a,o=ke(r,void 0,"signature"),{v:i,l:s}=n.decode(48,o);if(s.length)throw new e("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,i),{v:l,l:f}=n.decode(2,c);if(f.length)throw new e("invalid signature: left bytes after parsing");return{r:t.decode(a),s:t.decode(l)}},hexFromSig(r){let{_tlv:e,_int:t}=_a,n=e.encode(2,t.encode(r.r)),o=e.encode(2,t.encode(r.s)),i=n+o;return e.encode(48,i)}},Es=BigInt(0),ff=BigInt(1),H_=BigInt(2),pg=BigInt(3),zH=BigInt(4);function K_(r,e={}){let t=sg("weierstrass",r,e),{Fp:n,Fn:o}=t,i=t.CURVE,{h:s,n:a}=i;Oi(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:c}=e;if(c&&(!n.is0(i.a)||typeof c.beta!="bigint"||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let l=q_(n,o);function f(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function u($,S,C){let{x:_,y:B}=S.toAffine(),X=n.toBytes(_);if(bs(C,"isCompressed"),C){f();let G=!n.isOdd(B);return Sn(V_(G),X)}else return Sn(Uint8Array.of(4),X,n.toBytes(B))}function h($){ke($,void 0,"Point");let{publicKey:S,publicKeyUncompressed:C}=l,_=$.length,B=$[0],X=$.subarray(1);if(_===S&&(B===2||B===3)){let G=n.fromBytes(X);if(!n.isValid(G))throw new Error("bad point: is not on curve, wrong x");let U=y(G),Q;try{Q=n.sqrt(U)}catch(De){let Me=De instanceof Error?": "+De.message:"";throw new Error("bad point: is not on curve, sqrt error"+Me)}f();let ne=n.isOdd(Q);return(B&1)===1!==ne&&(Q=n.neg(Q)),{x:G,y:Q}}else if(_===C&&B===4){let G=n.BYTES,U=n.fromBytes(X.subarray(0,G)),Q=n.fromBytes(X.subarray(G,G*2));if(!w(U,Q))throw new Error("bad point: is not on curve");return{x:U,y:Q}}else throw new Error(`bad point: got length ${_}, expected compressed=${S} or uncompressed=${C}`)}let d=e.toBytes||u,m=e.fromBytes||h;function y($){let S=n.sqr($),C=n.mul(S,$);return n.add(n.add(C,n.mul($,i.a)),i.b)}function w($,S){let C=n.sqr(S),_=y($);return n.eql(C,_)}if(!w(i.Gx,i.Gy))throw new Error("bad curve params: generator point");let x=n.mul(n.pow(i.a,pg),zH),E=n.mul(n.sqr(i.b),BigInt(27));if(n.is0(n.add(x,E)))throw new Error("bad curve params: a or b");function v($,S,C=!1){if(!n.isValid(S)||C&&n.is0(S))throw new Error(`bad point coordinate ${$}`);return S}function I($){if(!($ instanceof k))throw new Error("Weierstrass Point expected")}function F($){if(!c||!c.basises)throw new Error("no endo");return qH($,c.basises,o.ORDER)}let V=Qu(($,S)=>{let{X:C,Y:_,Z:B}=$;if(n.eql(B,n.ONE))return{x:C,y:_};let X=$.is0();S==null&&(S=X?n.ONE:n.inv(B));let G=n.mul(C,S),U=n.mul(_,S),Q=n.mul(B,S);if(X)return{x:n.ZERO,y:n.ZERO};if(!n.eql(Q,n.ONE))throw new Error("invZ was invalid");return{x:G,y:U}}),M=Qu($=>{if($.is0()){if(e.allowInfinityPoint&&!n.is0($.Y))return;throw new Error("bad point: ZERO")}let{x:S,y:C}=$.toAffine();if(!n.isValid(S)||!n.isValid(C))throw new Error("bad point: x or y not field elements");if(!w(S,C))throw new Error("bad point: equation left != right");if(!$.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function T($,S,C,_,B){return C=new k(n.mul(C.X,$),C.Y,C.Z),S=Vh(_,S),C=Vh(B,C),S.add(C)}class k{static BASE=new k(i.Gx,i.Gy,n.ONE);static ZERO=new k(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=o;X;Y;Z;constructor(S,C,_){this.X=v("x",S),this.Y=v("y",C,!0),this.Z=v("z",_),Object.freeze(this)}static CURVE(){return i}static fromAffine(S){let{x:C,y:_}=S||{};if(!S||!n.isValid(C)||!n.isValid(_))throw new Error("invalid affine point");if(S instanceof k)throw new Error("projective point not allowed");return n.is0(C)&&n.is0(_)?k.ZERO:new k(C,_,n.ONE)}static fromBytes(S){let C=k.fromAffine(m(ke(S,void 0,"point")));return C.assertValidity(),C}static fromHex(S){return k.fromBytes(ws(S))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(S=8,C=!0){return W.createCache(this,S),C||this.multiply(pg),this}assertValidity(){M(this)}hasEvenY(){let{y:S}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(S)}equals(S){I(S);let{X:C,Y:_,Z:B}=this,{X,Y:G,Z:U}=S,Q=n.eql(n.mul(C,U),n.mul(X,B)),ne=n.eql(n.mul(_,U),n.mul(G,B));return Q&&ne}negate(){return new k(this.X,n.neg(this.Y),this.Z)}double(){let{a:S,b:C}=i,_=n.mul(C,pg),{X:B,Y:X,Z:G}=this,U=n.ZERO,Q=n.ZERO,ne=n.ZERO,K=n.mul(B,B),De=n.mul(X,X),Me=n.mul(G,G),he=n.mul(B,X);return he=n.add(he,he),ne=n.mul(B,G),ne=n.add(ne,ne),U=n.mul(S,ne),Q=n.mul(_,Me),Q=n.add(U,Q),U=n.sub(De,Q),Q=n.add(De,Q),Q=n.mul(U,Q),U=n.mul(he,U),ne=n.mul(_,ne),Me=n.mul(S,Me),he=n.sub(K,Me),he=n.mul(S,he),he=n.add(he,ne),ne=n.add(K,K),K=n.add(ne,K),K=n.add(K,Me),K=n.mul(K,he),Q=n.add(Q,K),Me=n.mul(X,G),Me=n.add(Me,Me),K=n.mul(Me,he),U=n.sub(U,K),ne=n.mul(Me,De),ne=n.add(ne,ne),ne=n.add(ne,ne),new k(U,Q,ne)}add(S){I(S);let{X:C,Y:_,Z:B}=this,{X,Y:G,Z:U}=S,Q=n.ZERO,ne=n.ZERO,K=n.ZERO,De=i.a,Me=n.mul(i.b,pg),he=n.mul(C,X),Ke=n.mul(_,G),at=n.mul(B,U),Pt=n.add(C,_),We=n.add(X,G);Pt=n.mul(Pt,We),We=n.add(he,Ke),Pt=n.sub(Pt,We),We=n.add(C,B);let ct=n.add(X,U);return We=n.mul(We,ct),ct=n.add(he,at),We=n.sub(We,ct),ct=n.add(_,B),Q=n.add(G,U),ct=n.mul(ct,Q),Q=n.add(Ke,at),ct=n.sub(ct,Q),K=n.mul(De,We),Q=n.mul(Me,at),K=n.add(Q,K),Q=n.sub(Ke,K),K=n.add(Ke,K),ne=n.mul(Q,K),Ke=n.add(he,he),Ke=n.add(Ke,he),at=n.mul(De,at),We=n.mul(Me,We),Ke=n.add(Ke,at),at=n.sub(he,at),at=n.mul(De,at),We=n.add(We,at),he=n.mul(Ke,We),ne=n.add(ne,he),he=n.mul(ct,We),Q=n.mul(Pt,Q),Q=n.sub(Q,he),he=n.mul(Pt,Ke),K=n.mul(ct,K),K=n.add(K,he),new k(Q,ne,K)}subtract(S){return this.add(S.negate())}is0(){return this.equals(k.ZERO)}multiply(S){let{endo:C}=e;if(!o.isValidNot0(S))throw new Error("invalid scalar: out of range");let _,B,X=G=>W.cached(this,G,U=>Wc(k,U));if(C){let{k1neg:G,k1:U,k2neg:Q,k2:ne}=F(S),{p:K,f:De}=X(U),{p:Me,f:he}=X(ne);B=De.add(he),_=T(C.beta,K,Me,G,Q)}else{let{p:G,f:U}=X(S);_=G,B=U}return Wc(k,[_,B])[0]}multiplyUnsafe(S){let{endo:C}=e,_=this;if(!o.isValid(S))throw new Error("invalid scalar: out of range");if(S===Es||_.is0())return k.ZERO;if(S===ff)return _;if(W.hasCache(this))return this.multiply(S);if(C){let{k1neg:B,k1:X,k2neg:G,k2:U}=F(S),{p1:Q,p2:ne}=d_(k,_,X,U);return T(C.beta,Q,ne,B,G)}else return W.unsafe(_,S)}toAffine(S){return V(this,S)}isTorsionFree(){let{isTorsionFree:S}=e;return s===ff?!0:S?S(k,this):W.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:S}=e;return s===ff?this:S?S(k,this):this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(S=!0){return bs(S,"isCompressed"),this.assertValidity(),d(k,this,S)}toHex(S=!0){return ys(this.toBytes(S))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let z=o.BITS,W=new ef(k,e.endo?Math.ceil(z/2):z);return k.BASE.precompute(8),k}function V_(r){return Uint8Array.of(r?2:3)}function q_(r,e){return{secretKey:e.BYTES,publicKey:1+r.BYTES,publicKeyUncompressed:1+2*r.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function jH(r,e={}){let{Fn:t}=r,n=e.randomBytes||ki,o=Object.assign(q_(r.Fp,t),{seed:Dw(t.ORDER)});function i(d){try{let m=t.fromBytes(d);return t.isValidNot0(m)}catch{return!1}}function s(d,m){let{publicKey:y,publicKeyUncompressed:w}=o;try{let x=d.length;return m===!0&&x!==y||m===!1&&x!==w?!1:!!r.fromBytes(d)}catch{return!1}}function a(d=n(o.seed)){return Nw(ke(d,o.seed,"seed"),t.ORDER)}function c(d,m=!0){return r.BASE.multiply(t.fromBytes(d)).toBytes(m)}function l(d){let{secretKey:m,publicKey:y,publicKeyUncompressed:w}=o;if(!Fc(d)||"_lengths"in t&&t._lengths||m===y)return;let x=ke(d,void 0,"key").length;return x===y||x===w}function f(d,m,y=!0){if(l(d)===!0)throw new Error("first arg must be private key");if(l(m)===!1)throw new Error("second arg must be public key");let w=t.fromBytes(d);return r.fromBytes(m).multiply(w).toBytes(y)}let u={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:a},h=tf(a,c);return Object.freeze({getPublicKey:c,getSharedSecret:f,keygen:h,Point:r,utils:u,lengths:o})}function z_(r,e,t={}){gs(e),Oi(t,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),t=Object.assign({},t);let n=t.randomBytes||ki,o=t.hmac||((C,_)=>Aa(e,C,_)),{Fp:i,Fn:s}=r,{ORDER:a,BITS:c}=s,{keygen:l,getPublicKey:f,getSharedSecret:u,utils:h,lengths:d}=jH(r,t),m={prehash:!0,lowS:typeof t.lowS=="boolean"?t.lowS:!0,format:"compact",extraEntropy:!1},y=a*H_<i.ORDER;function w(C){let _=a>>ff;return C>_}function x(C,_){if(!s.isValidNot0(_))throw new Error(`invalid signature ${C}: out of range 1..Point.Fn.ORDER`);return _}function E(){if(y)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function v(C,_){g7(_);let B=d.signature,X=_==="compact"?B:_==="recovered"?B+1:void 0;return ke(C,X)}class I{r;s;recovery;constructor(_,B,X){if(this.r=x("r",_),this.s=x("s",B),X!=null){if(E(),![0,1,2,3].includes(X))throw new Error("invalid recovery id");this.recovery=X}Object.freeze(this)}static fromBytes(_,B=m.format){v(_,B);let X;if(B==="der"){let{r:ne,s:K}=_a.toSig(ke(_));return new I(ne,K)}B==="recovered"&&(X=_[0],B="compact",_=_.subarray(1));let G=d.signature/2,U=_.subarray(0,G),Q=_.subarray(G,G*2);return new I(s.fromBytes(U),s.fromBytes(Q),X)}static fromHex(_,B){return this.fromBytes(ws(_),B)}assertRecovery(){let{recovery:_}=this;if(_==null)throw new Error("invalid recovery id: must be present");return _}addRecoveryBit(_){return new I(this.r,this.s,_)}recoverPublicKey(_){let{r:B,s:X}=this,G=this.assertRecovery(),U=G===2||G===3?B+a:B;if(!i.isValid(U))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let Q=i.toBytes(U),ne=r.fromBytes(Sn(V_((G&1)===0),Q)),K=s.inv(U),De=V(ke(_,void 0,"msgHash")),Me=s.create(-De*K),he=s.create(X*K),Ke=r.BASE.multiplyUnsafe(Me).add(ne.multiplyUnsafe(he));if(Ke.is0())throw new Error("invalid recovery: point at infinify");return Ke.assertValidity(),Ke}hasHighS(){return w(this.s)}toBytes(_=m.format){if(g7(_),_==="der")return ws(_a.hexFromSig(this));let{r:B,s:X}=this,G=s.toBytes(B),U=s.toBytes(X);return _==="recovered"?(E(),Sn(Uint8Array.of(this.assertRecovery()),G,U)):Sn(G,U)}toHex(_){return ys(this.toBytes(_))}}let F=t.bits2int||function(_){if(_.length>8192)throw new Error("input is too large");let B=Yu(_),X=_.length*8-c;return X>0?B>>BigInt(X):B},V=t.bits2int_modN||function(_){return s.create(F(_))},M=Hh(c);function T(C){return va("num < 2^"+c,C,Es,M),s.toBytes(C)}function k(C,_){return ke(C,void 0,"message"),_?ke(e(C),void 0,"prehashed message"):C}function z(C,_,B){let{lowS:X,prehash:G,extraEntropy:U}=m7(B,m);C=k(C,G);let Q=V(C),ne=s.fromBytes(_);if(!s.isValidNot0(ne))throw new Error("invalid private key");let K=[T(ne),T(Q)];if(U!=null&&U!==!1){let Ke=U===!0?n(d.secretKey):U;K.push(ke(Ke,void 0,"extraEntropy"))}let De=Sn(...K),Me=Q;function he(Ke){let at=F(Ke);if(!s.isValidNot0(at))return;let Pt=s.inv(at),We=r.BASE.multiply(at).toAffine(),ct=s.create(We.x);if(ct===Es)return;let ls=s.create(Pt*s.create(Me+ct*ne));if(ls===Es)return;let Go=(We.x===ct?0:2)|Number(We.y&ff),fa=ls;return X&&w(ls)&&(fa=s.neg(ls),Go^=1),new I(ct,fa,y?void 0:Go)}return{seed:De,k2sig:he}}function W(C,_,B={}){let{seed:X,k2sig:G}=z(C,_,B);return XA(e.outputLen,s.BYTES,o)(X,G).toBytes(B.format)}function $(C,_,B,X={}){let{lowS:G,prehash:U,format:Q}=m7(X,m);if(B=ke(B,void 0,"publicKey"),_=k(_,U),!Fc(C)){let ne=C instanceof I?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+ne)}v(C,Q);try{let ne=I.fromBytes(C,Q),K=r.fromBytes(B);if(G&&ne.hasHighS())return!1;let{r:De,s:Me}=ne,he=V(_),Ke=s.inv(Me),at=s.create(he*Ke),Pt=s.create(De*Ke),We=r.BASE.multiplyUnsafe(at).add(K.multiplyUnsafe(Pt));return We.is0()?!1:s.create(We.x)===De}catch{return!1}}function S(C,_,B={}){let{prehash:X}=m7(B,m);return _=k(_,X),I.fromBytes(C,"recovered").recoverPublicKey(_).toBytes()}return Object.freeze({keygen:l,getPublicKey:f,getSharedSecret:u,utils:h,lengths:d,Point:r,sign:W,verify:$,recoverPublicKey:S,Signature:I,hash:e})}var x7={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},WH={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var j_=BigInt(2);function GH(r){let e=x7.p,t=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),l=r*r*r%e,f=l*l*r%e,u=_t(f,t,e)*f%e,h=_t(u,t,e)*f%e,d=_t(h,j_,e)*l%e,m=_t(d,o,e)*d%e,y=_t(m,i,e)*m%e,w=_t(y,a,e)*y%e,x=_t(w,c,e)*w%e,E=_t(x,a,e)*y%e,v=_t(E,t,e)*f%e,I=_t(v,s,e)*m%e,F=_t(I,n,e)*l%e,V=_t(F,j_,e);if(!w7.eql(w7.sqr(V),r))throw new Error("Cannot find square root");return V}var w7=Zu(x7.p,{sqrt:GH}),XH=K_(x7,{Fp:w7,endo:WH}),ti=z_(XH,_o);var W_=32;function G_(r,e,t){let n=At.digest(e instanceof Uint8Array?e:e.subarray());if(of(n))return n.then(({digest:o})=>(t?.signal?.throwIfAborted(),ti.sign(o,r,{prehash:!1,format:"der"}))).catch(o=>{throw o.name==="AbortError"?o:new Ch(String(o))});try{return ti.sign(n.digest,r,{prehash:!1,format:"der"})}catch(o){throw new Ch(String(o))}}function X_(r,e,t,n){let o=At.digest(t instanceof Uint8Array?t:t.subarray());if(of(o))return o.then(({digest:i})=>(n?.signal?.throwIfAborted(),ti.verify(e,i,r,{prehash:!1,format:"der"}))).catch(i=>{throw i.name==="AbortError"?i:new Ih(String(i))});try{return n?.signal?.throwIfAborted(),ti.verify(e,o.digest,r,{prehash:!1,format:"der"})}catch(i){throw new Ih(String(i))}}var ep=class{type="secp256k1";raw;_key;constructor(e){this._key=Z_(e),this.raw=Y_(this._key)}toMultihash(){return $t.digest(yr(this))}toCID(){return Z.createV1(114,this.toMultihash())}toString(){return Qe.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:me(this.raw,e.raw)}verify(e,t,n){return X_(this._key,t,e,n)}},tp=class{type="secp256k1";raw;publicKey;constructor(e,t){this.raw=Q_(e),this.publicKey=new ep(t??J_(e))}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:me(this.raw,e.raw)}sign(e,t){return G_(this.raw,e,t)}};function b7(r){return new tp(r)}function v7(r){return new ep(r)}async function eT(){let r=YH();return new tp(r)}function Y_(r){return ti.Point.fromBytes(r).toBytes()}function Q_(r){try{return ti.getPublicKey(r,!0),r}catch(e){throw new Eh(String(e))}}function Z_(r){try{return ti.Point.fromBytes(r),r}catch(e){throw new fs(String(e))}}function J_(r){try{return ti.getPublicKey(r,!0)}catch(e){throw new Eh(String(e))}}function YH(){return ti.utils.randomSecretKey()}async function df(r,e){if(r==="Ed25519")return __();if(r==="secp256k1")return eT();if(r==="RSA")return p7(QH(e));if(r==="ECDSA")return OA(ZH(e));throw new Qo}function Wt(r,e){let{Type:t,Data:n}=Di.decode(r),o=n??new Uint8Array;switch(t){case xt.RSA:return f7(o,e);case xt.Ed25519:return Hw(o);case xt.secp256k1:return v7(o);case xt.ECDSA:return ww(o);default:throw new Qo}}function mg(r){let{Type:e,Data:t}=Di.decode(r.digest),n=t??new Uint8Array;switch(e){case xt.Ed25519:return Hw(n);case xt.secp256k1:return v7(n);case xt.ECDSA:return ww(n);default:throw new Qo}}function yr(r){return Di.encode({Type:xt[r.type],Data:r.raw})}function tT(r){let e=Qh.decode(r),t=e.Data??new Uint8Array;switch(e.Type){case xt.RSA:return u7(t);case xt.Ed25519:return $w(t);case xt.secp256k1:return b7(t);case xt.ECDSA:return CA(t);default:throw new Qo}}function rT(r){if(r.byteLength===Xn)return $w(r);if(r.byteLength===W_)return b7(r);let e=Ao(r),t=e[2]?.[0];if(t===wA||t===xA||t===bA)return yw(e);if(e.length>8)return dg(e);throw new O("Could not extract private key from raw bytes")}function Qc(r){return Qh.encode({Type:xt[r.type],Data:r.raw})}function QH(r){return r==null?2048:parseInt(r,10)}function ZH(r){if(r==="P-256"||r==null)return"P-256";if(r==="P-384")return"P-384";if(r==="P-521")return"P-521";throw new O("Unsupported curve, should be P-256, P-384 or P-521")}async function gg(r){if(r.type==="RSA")return{privateKey:await crypto.subtle.importKey("jwk",r.jwk,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),publicKey:await crypto.subtle.importKey("jwk",r.publicKey.jwk,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])};if(r.type==="ECDSA")return{privateKey:await crypto.subtle.importKey("jwk",r.jwk,{name:"ECDSA",namedCurve:r.jwk.crv??"P-256"},!0,["sign"]),publicKey:await crypto.subtle.importKey("jwk",r.publicKey.jwk,{name:"ECDSA",namedCurve:r.publicKey.jwk.crv??"P-256"},!0,["verify"])};throw new O("Only RSA and ECDSA keys are supported")}var rp=Uint32Array.from([1732584193,4023233417,2562383102,271733878,3285377520]),Ta=new Uint32Array(80),E7=class extends Hc{A=rp[0]|0;B=rp[1]|0;C=rp[2]|0;D=rp[3]|0;E=rp[4]|0;constructor(){super(64,20,8,!1)}get(){let{A:e,B:t,C:n,D:o,E:i}=this;return[e,t,n,o,i]}set(e,t,n,o,i){this.A=e|0,this.B=t|0,this.C=n|0,this.D=o|0,this.E=i|0}process(e,t){for(let c=0;c<16;c++,t+=4)Ta[c]=e.getUint32(t,!1);for(let c=16;c<80;c++)Ta[c]=eg(Ta[c-3]^Ta[c-8]^Ta[c-14]^Ta[c-16],1);let{A:n,B:o,C:i,D:s,E:a}=this;for(let c=0;c<80;c++){let l,f;c<20?(l=tg(o,i,s),f=1518500249):c<40?(l=o^i^s,f=1859775393):c<60?(l=rg(o,i,s),f=2400959708):(l=o^i^s,f=3395469782);let u=eg(n,5)+l+a+f+Ta[c]|0;a=s,s=i,i=eg(o,30),o=n,n=u}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,this.set(n,o,i,s,a)}roundClean(){zr(Ta)}destroy(){this.set(0,0,0,0,0),zr(this.buffer)}},nT=Bh(()=>new E7);function oT(r,e,t,n){gs(r);let o=MA({dkLen:32,asyncTick:10},n),{c:i,dkLen:s,asyncTick:a}=o;if(qr(i,"c"),qr(s,"dkLen"),qr(a,"asyncTick"),i<1)throw new Error("iterations (c) must be >= 1");let c=xw(e,"password"),l=xw(t,"salt"),f=new Uint8Array(s),u=Aa.create(r,c),h=u._cloneInto().update(l);return{c:i,dkLen:s,asyncTick:a,DK:f,PRF:u,PRFSalt:h}}function iT(r,e,t,n,o){return r.destroy(),e.destroy(),n&&n.destroy(),zr(o),t}function sT(r,e,t,n){let{c:o,dkLen:i,DK:s,PRF:a,PRFSalt:c}=oT(r,e,t,n),l,f=new Uint8Array(4),u=$c(f),h=new Uint8Array(a.outputLen);for(let d=1,m=0;m<i;d++,m+=a.outputLen){let y=s.subarray(m,m+a.outputLen);u.setInt32(0,d,!1),(l=c._cloneInto(l)).update(f).digestInto(h),y.set(h.subarray(0,y.length));for(let w=1;w<o;w++){a._cloneInto(l).update(h).digestInto(h);for(let x=0;x<y.length;x++)y[x]^=h[x]}}return iT(a,c,s,l,h)}async function yg(r,e,t,n){let{c:o,dkLen:i,asyncTick:s,DK:a,PRF:c,PRFSalt:l}=oT(r,e,t,n),f,u=new Uint8Array(4),h=$c(u),d=new Uint8Array(c.outputLen);for(let m=1,y=0;y<i;m++,y+=c.outputLen){let w=a.subarray(y,y+c.outputLen);h.setInt32(0,m,!1),(f=l._cloneInto(f)).update(u).digestInto(d),w.set(d.subarray(0,w.length)),await BA(o-1,s,()=>{c._cloneInto(f).update(d).digestInto(d);for(let x=0;x<w.length;x++)w[x]^=d[x]})}return iT(c,l,a,f,d)}var aT={sha1:nT,"sha2-256":_o,"sha2-512":ba};function np(r,e,t,n,o){if(o!=="sha1"&&o!=="sha2-256"&&o!=="sha2-512"){let a=Object.keys(aT).join(" / ");throw new O(`Hash '${o}' is unknown or not supported. Must be ${a}`)}let i=aT[o],s=sT(i,r,e,{c:t,dkLen:n});return Zt.encode(s).substring(1)}var S7={32:16777619n,64:1099511628211n,128:309485009821345068724781371n,256:374144419156711147060143317175368453031918731002211n,512:35835915874844867368919076489095108449946327955754392558399825615420669938882575126094039892345713852759n,1024:5016456510113118655434598811035278955030765345404790744303017523831112055108147451509157692220295382716162651878526895249385292291816524375083746691371804094271873160484737966720260389217684476157468082573n},cT={32:2166136261n,64:14695981039346656037n,128:144066263297769815596495629667062367629n,256:100029257958052580907070968620625704837092796014241193945225284501741471925557n,512:9659303129496669498009435400716310466090418745672637896108374329434462657994582932197716438449813051892206539805784495328239340083876191928701583869517785n,1024:14197795064947621068722070641403218320880622795441933960878474914617582723252296732303717722150864096521202355549365628174669108571814760471015076148029755969804077320157692458563003215304957150157403644460363550505412711285966361610267868082893823963790439336411086884584107735010676915n},lT=new globalThis.TextEncoder;function JH(r,e){let t=S7[e],n=cT[e];for(let o=0;o<r.length;o++)n^=BigInt(r[o]),n=BigInt.asUintN(e,n*t);return n}function eK(r,e,t){if(t.length===0)throw new Error("The `utf8Buffer` option must have a length greater than zero");let n=S7[e],o=cT[e],i=r;for(;i.length>0;){let s=lT.encodeInto(i,t);i=i.slice(s.read);for(let a=0;a<s.written;a++)o^=BigInt(t[a]),o=BigInt.asUintN(e,o*n)}return o}function A7(r,{size:e=32,utf8Buffer:t}={}){if(!S7[e])throw new Error("The `size` option must be one of 32, 64, 128, 256, 512, or 1024");if(typeof r=="string"){if(t)return eK(r,e,t);r=lT.encode(r)}return JH(r,e)}var op={hash:r=>Number(A7(r,{size:32})),hashV:(r,e)=>tK(op.hash(r,e))};function tK(r){let e=r.toString(16);return e.length%2===1&&(e=`0${e}`),D(e,"base16")}var _7=64,ri=class{fp;h;seed;constructor(e,t,n,o=2){if(o>_7)throw new TypeError("Invalid Fingerprint Size");let i=t.hashV(e,n),s=Ie(o);for(let a=0;a<s.length;a++)s[a]=i[a];s.length===0&&(s[0]=7),this.fp=s,this.h=t,this.seed=n}hash(){return this.h.hash(this.fp,this.seed)}equals(e){return e?.fp instanceof Uint8Array?me(this.fp,e.fp):!1}};function Zc(r,e){return Math.floor(Math.random()*(e-r))+r}var Jc=class{contents;constructor(e){this.contents=new Array(e).fill(null)}has(e){if(!(e instanceof ri))throw new TypeError("Invalid Fingerprint");return this.contents.some(t=>e.equals(t))}add(e){if(!(e instanceof ri))throw new TypeError("Invalid Fingerprint");for(let t=0;t<this.contents.length;t++)if(this.contents[t]==null)return this.contents[t]=e,!0;return!0}swap(e){if(!(e instanceof ri))throw new TypeError("Invalid Fingerprint");let t=Zc(0,this.contents.length-1),n=this.contents[t];return this.contents[t]=e,n}remove(e){if(!(e instanceof ri))throw new TypeError("Invalid Fingerprint");let t=this.contents.findIndex(n=>e.equals(n));return t>-1?(this.contents[t]=null,!0):!1}};var rK=500,ip=class{bucketSize;filterSize;fingerprintSize;buckets;count;hash;seed;constructor(e){this.filterSize=e.filterSize,this.bucketSize=e.bucketSize??4,this.fingerprintSize=e.fingerprintSize??2,this.count=0,this.buckets=[],this.hash=e.hash??op,this.seed=e.seed??Zc(0,Math.pow(2,10))}add(e){typeof e=="string"&&(e=D(e));let t=new ri(e,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(e,this.seed)%this.filterSize,o=(n^t.hash())%this.filterSize;if(this.buckets[n]==null&&(this.buckets[n]=new Jc(this.bucketSize)),this.buckets[o]==null&&(this.buckets[o]=new Jc(this.bucketSize)),this.buckets[n].add(t)||this.buckets[o].add(t))return this.count++,!0;let i=[n,o],s=i[Zc(0,i.length-1)];this.buckets[s]==null&&(this.buckets[s]=new Jc(this.bucketSize));for(let a=0;a<rK;a++){let c=this.buckets[s].swap(t);if(c!=null&&(s=(s^c.hash())%this.filterSize,this.buckets[s]==null&&(this.buckets[s]=new Jc(this.bucketSize)),this.buckets[s].add(c)))return this.count++,!0}return!1}has(e){typeof e=="string"&&(e=D(e));let t=new ri(e,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(e,this.seed)%this.filterSize,o=this.buckets[n]?.has(t)??!1;if(o)return o;let i=(n^t.hash())%this.filterSize;return this.buckets[i]?.has(t)??!1}remove(e){typeof e=="string"&&(e=D(e));let t=new ri(e,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(e,this.seed)%this.filterSize,o=this.buckets[n]?.remove(t)??!1;if(o)return this.count--,o;let i=(n^t.hash())%this.filterSize,s=this.buckets[i]?.remove(t)??!1;return s&&this.count--,s}get reliable(){return Math.floor(100*(this.count/this.filterSize))<=90}},nK={1:.5,2:.84,4:.95,8:.98};function oK(r=.001){return r>.002?2:r>1e-5?4:8}function uT(r,e=.001){let t=oK(e),n=nK[t],o=Math.round(r/n),i=Math.min(Math.ceil(Math.log2(1/e)+Math.log2(2*t)),_7);return{filterSize:o,bucketSize:t,fingerprintSize:i}}var wg=class{filterSize;bucketSize;fingerprintSize;scale;filterSeries;hash;seed;constructor(e){this.bucketSize=e.bucketSize??4,this.filterSize=e.filterSize??(1<<18)/this.bucketSize,this.fingerprintSize=e.fingerprintSize??2,this.scale=e.scale??2,this.hash=e.hash??op,this.seed=e.seed??Zc(0,Math.pow(2,10)),this.filterSeries=[new ip({filterSize:this.filterSize,bucketSize:this.bucketSize,fingerprintSize:this.fingerprintSize,hash:this.hash,seed:this.seed})]}add(e){if(typeof e=="string"&&(e=D(e)),this.has(e))return!0;let t=this.filterSeries.find(n=>n.reliable);if(t==null){let n=this.filterSize*Math.pow(this.scale,this.filterSeries.length);t=new ip({filterSize:n,bucketSize:this.bucketSize,fingerprintSize:this.fingerprintSize,hash:this.hash,seed:this.seed}),this.filterSeries.push(t)}return t.add(e)}has(e){typeof e=="string"&&(e=D(e));for(let t=0;t<this.filterSeries.length;t++)if(this.filterSeries[t].has(e))return!0;return!1}remove(e){typeof e=="string"&&(e=D(e));for(let t=0;t<this.filterSeries.length;t++)if(this.filterSeries[t].remove(e))return!0;return!1}get count(){return this.filterSeries.reduce((e,t)=>e+t.count,0)}};function br(r,e=.001,t){return new wg({...uT(r,e),...t??{}})}function Te(r){let e=r.getComponents(),t={},n=0;if(e[n]?.name==="ip6zone"&&(t.zone=`${e[n].value}`,n++),e[n].name==="ip4"||e[n].name==="ip6"||e[n].name==="dns"||e[n].name==="dns4"||e[n].name==="dns6"?(t.type=e[n].name,t.host=e[n].value,n++):e[n].name==="dnsaddr"&&(t.type=e[n].name,t.host=`_dnsaddr.${e[n].value}`,n++),(e[n]?.name==="tcp"||e[n]?.name==="udp")&&(t.protocol=e[n].name==="tcp"?"tcp":"udp",t.port=parseInt(`${e[n].value}`),n++),e[n]?.name==="ipcidr"&&(t.type==="ip4"?t.cidr=parseInt(`${e[n].value}`):t.type==="ip6"&&(t.cidr=`${e[n].value}`),n++),t.type==null||t.host==null)throw new O(`Multiaddr ${r} was not an IPv4, IPv6, DNS, DNS4, DNS6 or DNSADDR address`);return e[n]?.name==="tls"&&e[n+1]?.name==="sni"&&(t.sni=e[n+1].value,n+=2),t}var xg=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let t=this.index,n=e();return n===void 0&&(this.index=t),n}parseWith(e){let t=e();if(this.index===this.input.length)return t}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(e){return this.readAtomically(()=>{let t=this.readChar();if(t===e)return t})}readSeparator(e,t,n){return this.readAtomically(()=>{if(!(t>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,t,n,o){return this.readAtomically(()=>{let i=0,s=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",l=2**(8*o)-1;for(;;){let f=this.readAtomically(()=>{let u=this.readChar();if(u===void 0)return;let h=Number.parseInt(u,e);if(!Number.isNaN(h))return h});if(f===void 0)break;if(i*=e,i+=f,i>l||(s+=1,t!==void 0&&s>t))return}if(s!==0)return!n&&c&&s>1?void 0:i})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let t=0;t<e.length;t++){let n=this.readSeparator(".",t,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[t]=n}return e})}readIPv6Addr(){let e=t=>{for(let n=0;n<t.length/2;n++){let o=n*2;if(n<t.length-3){let s=this.readSeparator(":",n,()=>this.readIPv4Addr());if(s!==void 0)return t[o]=s[0],t[o+1]=s[1],t[o+2]=s[2],t[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];t[o]=i>>8,t[o+1]=i&255}return[t.length,!1]};return this.readAtomically(()=>{let t=new Uint8Array(16),[n,o]=e(t);if(n===16)return t;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let i=new Uint8Array(14),s=16-(n+2),[a]=e(i.subarray(0,s));return t.set(i.subarray(0,a),16-a),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var fT=45,iK=15,hf=new xg;function bg(r){if(!(r.length>iK))return hf.new(r).parseWith(()=>hf.readIPv4Addr())}function vg(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>fT))return hf.new(r).parseWith(()=>hf.readIPv6Addr())}function pf(r,e=!1){if(r.includes("%")&&(r=r.split("%")[0]),r.length>fT)return;let t=hf.new(r).parseWith(()=>hf.readIPAddr());if(t)return e&&t.length===4?Uint8Array.from([0,0,0,0,0,0,0,0,0,0,255,255,t[0],t[1],t[2],t[3]]):t}function dT(r,e,t){let n=0;for(let o of r)if(!(n<e)){if(n>t)break;if(o!==255)return!1;n++}return!0}function hT(r,e,t,n){let o=0;for(let i of r)if(!(o<t)){if(o>n)break;if(i!==e[o])return!1;o++}return!0}function T7(r){switch(r.length){case el:return r.join(".");case tl:{let e=[];for(let t=0;t<r.length;t++)t%2===0&&e.push(r[t].toString(16).padStart(2,"0")+r[t+1].toString(16).padStart(2,"0"));return e.join(":")}default:throw new Error("Invalid ip length")}}function pT(r){let e=0;for(let[t,n]of r.entries()){if(n===255){e+=8;continue}for(;(n&128)!=0;)e++,n=n<<1;if((n&128)!=0)return-1;for(let o=t+1;o<r.length;o++)if(r[o]!=0)return-1;break}return e}function mT(r){let e="0x";for(let t of r)e+=(t>>4).toString(16)+(t&15).toString(16);return e}var el=4,tl=16,ase=parseInt("0xFFFF",16),sK=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function sp(r,e){e.length===tl&&r.length===el&&dT(e,0,11)&&(e=e.slice(12)),e.length===el&&r.length===tl&&hT(r,sK,0,11)&&(r=r.slice(12));let t=r.length;if(t!=e.length)throw new Error("Failed to mask ip");let n=new Uint8Array(t);for(let o=0;o<t;o++)n[o]=r[o]&e[o];return n}function gT(r,e){if(typeof e=="string"&&(e=pf(e)),e==null)throw new Error("Invalid ip");if(e.length!==r.network.length)return!1;for(let t=0;t<e.length;t++)if((r.network[t]&r.mask[t])!==(e[t]&r.mask[t]))return!1;return!0}function C7(r){let[e,t]=r.split("/");if(!e||!t)throw new Error("Failed to parse given CIDR: "+r);let n=el,o=bg(e);if(o==null&&(n=tl,o=vg(e),o==null))throw new Error("Failed to parse given CIDR: "+r);let i=parseInt(t,10);if(Number.isNaN(i)||String(i).length!==t.length||i<0||i>n*8)throw new Error("Failed to parse given CIDR: "+r);let s=I7(i,8*n);return{network:sp(o,s),mask:s}}function I7(r,e){if(e!==8*el&&e!==8*tl)throw new Error("Invalid CIDR mask");if(r<0||r>e)throw new Error("Invalid CIDR mask");let t=e/8,n=new Uint8Array(t);for(let o=0;o<t;o++){if(r>=8){n[o]=255,r-=8;continue}n[o]=255-(255>>r),r=0}return n}var rl=class{constructor(e,t){if(t==null)({network:this.network,mask:this.mask}=C7(e));else{let n=pf(e);if(n==null)throw new Error("Failed to parse network");t=String(t);let o=parseInt(t,10);if(Number.isNaN(o)||String(o).length!==t.length||o<0||o>n.length*8){let i=pf(t);if(i==null)throw new Error("Failed to parse mask");this.mask=i}else this.mask=I7(o,8*n.length);this.network=sp(n,this.mask)}}contains(e){return gT({network:this.network,mask:this.mask},e)}toString(){let e=pT(this.mask),t=e!==-1?String(e):mT(this.mask);return T7(this.network)+"/"+t}};function yT(r,e){return new rl(r).contains(e)}function Eg(r){try{let e=Te(r);switch(e.type){case"ip6":return yT("2000::/3",e.host);default:return!1}}catch{return!1}}function wT(r){try{let e=Te(r);switch(e.type){case"ip4":return e.host.startsWith("169.254.");case"ip6":return e.host.toLowerCase().startsWith("fe80");default:return!1}}catch{return!1}}function xT(r){return/^127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(r)||/^::1$/.test(r)}function ap(r){try{let e=Te(r);switch(e.type){case"ip4":case"ip6":return xT(e.host);default:return!1}}catch{return!1}}function Ir(r){try{return Te(r),!0}catch{return!1}}function ni(r){return!!bg(r)}function Sg(r){return!!vg(r)}var vT=gt(bT(),1),aK=["0.0.0.0/8","10.0.0.0/8","100.64.0.0/10","127.0.0.0/8","169.254.0.0/16","172.16.0.0/12","192.0.0.0/24","192.0.0.0/29","192.0.0.8/32","192.0.0.9/32","192.0.0.10/32","192.0.0.170/32","192.0.0.171/32","192.0.2.0/24","192.31.196.0/24","192.52.193.0/24","192.88.99.0/24","192.168.0.0/16","192.175.48.0/24","198.18.0.0/15","198.51.100.0/24","203.0.113.0/24","240.0.0.0/4","255.255.255.255/32"],cK=aK.map(r=>new vT.Netmask(r));function k7(r){for(let e of cK)if(e.contains(r))return!0;return!1}function lK(r){return/^::ffff:([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,4})$/.test(r)}function uK(r){let e=r.split(":");if(e.length<2)return!1;let t=e[e.length-1].padStart(4,"0"),n=e[e.length-2].padStart(4,"0"),o=`${parseInt(n.substring(0,2),16)}.${parseInt(n.substring(2),16)}.${parseInt(t.substring(0,2),16)}.${parseInt(t.substring(2),16)}`;return k7(o)}function fK(r){return/^::ffff:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)}function dK(r){let e=r.split(":"),t=e[e.length-1];return k7(t)}function hK(r){return/^::$/.test(r)||/^::1$/.test(r)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(r)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(r)||/^ff([0-9a-fA-F]{2,2}):/i.test(r)}function mf(r){if(ni(r))return k7(r);if(lK(r))return uK(r);if(fK(r))return dK(r);if(Sg(r))return hK(r)}function Ht(r){try{let e=Te(r);switch(e.type){case"ip4":case"ip6":return mf(e.host)??!1;default:return e.host==="localhost"}}catch{return!1}}function He(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}var Ag=class{buffer;mask;top;btm;next;constructor(e){if(!(e>0)||(e-1&e)!==0)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return this.buffer[this.btm]===void 0}},gf=class{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new Ag(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return e?.byteLength!=null?e.byteLength:1}push(e){if(e?.value!=null&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){let t=this.head;this.head=t.next=new Ag(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next!=null){let t=this.tail.next;this.tail.next=null,this.tail=t,e=this.tail.shift()}return e?.value!=null&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}};var P7=class extends Error{type;code;constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.code=t??"ABORT_ERR"}};function ur(r={}){return pK(t=>{let n=t.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},r)}function pK(r,e){e=e??{};let t=e.onEnd,n=new gf,o,i,s,a=He(),c=async()=>{try{return n.isEmpty()?s?{done:!0}:await new Promise((w,x)=>{i=E=>{i=null,n.push(E);try{w(r(n))}catch(v){x(v)}return o}}):r(n)}finally{n.isEmpty()&&queueMicrotask(()=>{a.resolve(),a=He()})}},l=w=>i!=null?i(w):(n.push(w),o),f=w=>(n=new gf,i!=null?i({error:w}):(n.push({error:w}),o)),u=w=>{if(s)return o;if(e?.objectMode!==!0&&w?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return l({done:!1,value:w})},h=w=>s?o:(s=!0,w!=null?f(w):l({done:!0})),d=()=>(n=new gf,h(),{done:!0}),m=w=>(h(w),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:c,return:d,throw:m,push:u,end:h,get readableLength(){return n.size},onEmpty:async w=>{let x=w?.signal;if(x?.throwIfAborted(),n.isEmpty())return;let E,v;x!=null&&(E=new Promise((I,F)=>{v=()=>{F(new P7)},x.addEventListener("abort",v)}));try{await Promise.race([a.promise,E])}finally{v!=null&&x!=null&&x?.removeEventListener("abort",v)}}},t==null)return o;let y=o;return o={[Symbol.asyncIterator](){return this},next(){return y.next()},throw(w){return y.throw(w),t!=null&&(t(w),t=void 0),{done:!0}},return(){return y.return(),t!=null&&(t(),t=void 0),{done:!0}},push:u,end(w){return y.end(w),t!=null&&(t(w),t=void 0),o},get readableLength(){return y.readableLength},onEmpty:w=>y.onEmpty(w)},o}var R7=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},O7=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},ET=r=>globalThis.DOMException===void 0?new O7(r):new DOMException(r),ST=r=>{let e=r.reason===void 0?ET("This operation was aborted."):r.reason;return e instanceof Error?e:ET(e)};function D7(r,e){let{milliseconds:t,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout}}=e,s,a,l=new Promise((f,u)=>{if(typeof t!="number"||Math.sign(t)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(e.signal){let{signal:d}=e;d.aborted&&u(ST(d)),a=()=>{u(ST(d))},d.addEventListener("abort",a,{once:!0})}if(t===Number.POSITIVE_INFINITY){r.then(f,u);return}let h=new R7;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):(h.message=o??`Promise timed out after ${t} milliseconds`,u(h))},t),(async()=>{try{f(await r)}catch(d){u(d)}})()}).finally(()=>{l.clear(),a&&e.signal&&e.signal.removeEventListener("abort",a)});return l.clear=()=>{i.clearTimeout.call(void 0,s),s=void 0},l}var mK=r=>{let e=r.addEventListener||r.on||r.addListener,t=r.removeEventListener||r.off||r.removeListener;if(!e||!t)throw new TypeError("Emitter is not compatible");return{addListener:e.bind(r),removeListener:t.bind(r)}};function gK(r,e,t){let n,o=new Promise((i,s)=>{if(t={rejectionEvents:["error"],multiArgs:!1,rejectionMultiArgs:!1,resolveImmediately:!1,...t},!(t.count>=0&&(t.count===Number.POSITIVE_INFINITY||Number.isInteger(t.count))))throw new TypeError("The `count` option should be at least 0 or more");t.signal?.throwIfAborted();let a=[e].flat(),c=[],{addListener:l,removeListener:f}=mK(r),u=async(...d)=>{let m=t.multiArgs?d:d[0];if(t.filter)try{if(!await t.filter(m))return}catch(y){n(),s(y);return}c.push(m),t.count===c.length&&(n(),i(c))},h=(...d)=>{n(),s(t.rejectionMultiArgs?d:d[0])};n=()=>{for(let d of a)f(d,u);for(let d of t.rejectionEvents)a.includes(d)||f(d,h)};for(let d of a)l(d,u);for(let d of t.rejectionEvents)a.includes(d)||l(d,h);t.signal&&t.signal.addEventListener("abort",()=>{h(t.signal.reason)},{once:!0}),t.resolveImmediately&&i(c)});if(o.cancel=n,typeof t.timeout=="number"){let i=D7(o,{milliseconds:t.timeout});return i.cancel=()=>{n(),i.clear()},i}return o}function Ze(r,e,t){typeof t=="function"&&(t={filter:t}),t={...t,count:1,resolveImmediately:!1};let n=gK(r,e,t),o=n.then(i=>i[0]);return o.cancel=n.cancel,o}function Ss(r,e){let t,n=function(){let o=function(){t=void 0,r()};clearTimeout(t),t=setTimeout(o,e)};return n.start=()=>{},n.stop=()=>{clearTimeout(t)},n}var _g=class extends Error{remainingPoints;msBeforeNext;consumedPoints;isFirstInDuration;constructor(e="Rate limit exceeded",t){super(e),this.name="RateLimitError",this.remainingPoints=t.remainingPoints,this.msBeforeNext=t.msBeforeNext,this.consumedPoints=t.consumedPoints,this.isFirstInDuration=t.isFirstInDuration}},Tg=class extends Error{static name="QueueFullError";constructor(e="The queue was full"){super(e),this.name="QueueFullError"}},nl=class extends Error{static name="UnexpectedEOFError";name="UnexpectedEOFError"},Cg=class extends Error{static name="MaxEarlyStreamsError";name="MaxEarlyStreamsError"},Ig=class extends Error{static name="StreamClosedError";name="StreamClosedError"};function yK(r){return r.reason}async function nt(r,e,t){if(e==null)return r;let n=t?.translateError??yK;if(e.aborted)return r.catch(()=>{}),Promise.reject(n(e));let o;try{return await Promise.race([r,new Promise((i,s)=>{o=()=>{s(n(e))},e.addEventListener("abort",o)})])}finally{o!=null&&e.removeEventListener("abort",o)}}var kg=class{deferred;signal;constructor(e){this.signal=e,this.deferred=He(),this.onAbort=this.onAbort.bind(this),this.signal?.addEventListener("abort",this.onAbort)}onAbort(){this.deferred.reject(this.signal?.reason??new Tr)}cleanup(){this.signal?.removeEventListener("abort",this.onAbort)}};function wK(){return`${parseInt(String(Math.random()*1e9),10).toString()}${Date.now()}`}var Pg=class{id;fn;options;recipients;status;timeline;controller;constructor(e,t){this.id=wK(),this.status="queued",this.fn=e,this.options=t,this.recipients=[],this.timeline={created:Date.now()},this.controller=new AbortController,this.controller.signal,this.onAbort=this.onAbort.bind(this)}abort(e){this.controller.abort(e)}onAbort(){this.recipients.reduce((t,n)=>t&&n.signal?.aborted===!0,!0)&&(this.controller.abort(new Tr),this.cleanup())}async join(e={}){let t=new kg(e.signal);return this.recipients.push(t),e.signal?.addEventListener("abort",this.onAbort),t.deferred.promise}async run(){this.status="running",this.timeline.started=Date.now();try{this.controller.signal.throwIfAborted();let e=await nt(this.fn({...this.options??{},signal:this.controller.signal}),this.controller.signal);this.recipients.forEach(t=>{t.deferred.resolve(e)}),this.status="complete"}catch(e){this.recipients.forEach(t=>{t.deferred.reject(e)}),this.status="errored"}finally{this.timeline.finished=Date.now(),this.cleanup()}}cleanup(){this.recipients.forEach(e=>{e.cleanup(),e.signal?.removeEventListener("abort",this.onAbort)})}};var Gt=class extends _e{concurrency;maxSize;queue;pending;sort;paused;constructor(e={}){super(),this.concurrency=e.concurrency??Number.POSITIVE_INFINITY,this.maxSize=e.maxSize??Number.POSITIVE_INFINITY,this.pending=0,this.paused=!1,e.metricName!=null&&e.metrics?.registerMetricGroup(e.metricName,{calculate:()=>({size:this.queue.length,running:this.pending,queued:this.queue.length-this.pending})}),this.sort=e.sort,this.queue=[],this.emitEmpty=Ss(this.emitEmpty.bind(this),1),this.emitIdle=Ss(this.emitIdle.bind(this),1)}emitEmpty(){this.size===0&&this.safeDispatchEvent("empty")}emitIdle(){this.running===0&&this.safeDispatchEvent("idle")}pause(){this.paused=!0}resume(){this.paused&&(this.paused=!1,this.tryToStartAnother())}tryToStartAnother(){if(this.paused)return!1;if(this.size===0)return this.emitEmpty(),this.running===0&&this.emitIdle(),!1;if(this.pending<this.concurrency){let e;for(let t of this.queue)if(t.status==="queued"){e=t;break}return e==null?!1:(this.safeDispatchEvent("active"),this.pending++,e.run().finally(()=>{for(let t=0;t<this.queue.length;t++)if(this.queue[t]===e){this.queue.splice(t,1);break}this.pending--,this.tryToStartAnother(),this.safeDispatchEvent("next")}),!0)}return!1}enqueue(e){this.queue.push(e),this.sort!=null&&this.queue.sort(this.sort)}async add(e,t){if(t?.signal?.throwIfAborted(),this.size===this.maxSize)throw new Tg;let n=new Pg(e,t);return this.enqueue(n),this.safeDispatchEvent("add"),this.tryToStartAnother(),n.join(t).then(o=>(this.safeDispatchEvent("completed",{detail:o}),this.safeDispatchEvent("success",{detail:{job:n,result:o}}),o)).catch(o=>{if(n.status==="queued"){for(let i=0;i<this.queue.length;i++)if(this.queue[i]===n){this.queue.splice(i,1);break}}throw this.safeDispatchEvent("failure",{detail:{job:n,error:o}}),o})}clear(){this.queue.splice(0,this.queue.length)}abort(){this.queue.forEach(e=>{e.abort(new Tr)}),this.clear()}async onEmpty(e){this.size!==0&&await Ze(this,"empty",e)}async onSizeLessThan(e,t){this.size<e||await Ze(this,"next",{...t,filter:()=>this.size<e})}async onIdle(e){this.pending===0&&this.size===0||await Ze(this,"idle",e)}get size(){return this.queue.length}get queued(){return this.queue.length-this.pending}get running(){return this.pending}async*toGenerator(e){e?.signal?.throwIfAborted();let t=ur({objectMode:!0}),n=c=>{c!=null?this.abort():this.clear(),t.end(c)},o=c=>{c.detail!=null&&t.push(c.detail)},i=c=>{n(c.detail.error)},s=()=>{n()},a=()=>{n(new Tr("Queue aborted"))};this.addEventListener("completed",o),this.addEventListener("failure",i),this.addEventListener("idle",s),e?.signal?.addEventListener("abort",a);try{yield*t}finally{this.removeEventListener("completed",o),this.removeEventListener("failure",i),this.removeEventListener("idle",s),e?.signal?.removeEventListener("abort",a),n()}}};var xK=Math.pow(2,20)*4,Ca=class extends _e{status;timeline;inactivityTimeout;maxReadBufferLength;maxWriteBufferLength;log;direction;maxMessageSize;readStatus;writeStatus;remoteReadStatus;remoteWriteStatus;writableNeedsDrain;readBuffer;writeBuffer;sendingData;onDrainPromise;constructor(e){super(),this.status="open",this.log=e.log,this.direction=e.direction??"outbound",this.inactivityTimeout=e.inactivityTimeout??12e4,this.maxReadBufferLength=e.maxReadBufferLength??xK,this.maxWriteBufferLength=e.maxWriteBufferLength,this.maxMessageSize=e.maxMessageSize,this.readBuffer=new se,this.writeBuffer=new se,this.readStatus="readable",this.remoteReadStatus="readable",this.writeStatus="writable",this.remoteWriteStatus="writable",this.sendingData=!1,this.writableNeedsDrain=!1,this.timeline={open:Date.now()},this.processSendQueue=this.processSendQueue.bind(this);let t=()=>{this.writableNeedsDrain&&(this.log.trace("drain event received, continue sending data"),this.writableNeedsDrain=!1,this.processSendQueue()),this.onDrainPromise?.resolve()};this.addEventListener("drain",t);let n=o=>{this.onDrainPromise?.reject(o.error??new Ig)};this.addEventListener("close",n)}get readBufferLength(){return this.readBuffer.byteLength}get writeBufferLength(){return this.writeBuffer.byteLength}async onDrain(e){return this.writableNeedsDrain!==!0?Promise.resolve():(this.onDrainPromise==null&&(this.onDrainPromise=Promise.withResolvers()),nt(this.onDrainPromise.promise,e?.signal))}async*[Symbol.asyncIterator](){if(this.readStatus!=="readable"&&this.readStatus!=="paused")return;let e=ur(),t=i=>{e.push(i.data)};this.addEventListener("message",t);let n=i=>{e.end(i.error)};this.addEventListener("close",n);let o=()=>{e.end()};this.addEventListener("remoteCloseWrite",o);try{yield*e}finally{this.removeEventListener("message",t),this.removeEventListener("close",n),this.removeEventListener("remoteCloseWrite",o)}}isReadable(){return this.status==="open"}send(e){if(this.writeStatus==="closed"||this.writeStatus==="closing")throw new Ti(`Cannot write to a stream that is ${this.writeStatus}`);return this.log.trace("append %d bytes to write buffer",e.byteLength),this.writeBuffer.append(e),this.processSendQueue()}abort(e){if(!(this.status==="aborted"||this.status==="reset"||this.status==="closed")){this.log.error("abort with error - %e",e),this.status="aborted",this.readBuffer.byteLength>0&&this.readBuffer.consume(this.readBuffer.byteLength),this.writeBuffer.byteLength>0&&(this.writeBuffer.consume(this.writeBuffer.byteLength),this.safeDispatchEvent("idle")),this.writeStatus="closed",this.remoteWriteStatus="closed",this.readStatus="closed",this.remoteReadStatus="closed",this.timeline.close=Date.now();try{this.sendReset(e)}catch(t){this.log("failed to send reset to remote - %e",t)}this.dispatchEvent(new z0(e))}}pause(){if(this.readStatus==="closed"||this.readStatus==="closing")throw new Ti("Cannot pause a stream that is closing/closed");this.readStatus!=="paused"&&(this.readStatus="paused",this.sendPause())}resume(){if(this.readStatus==="closed"||this.readStatus==="closing")throw new Ti("Cannot resume a stream that is closing/closed");this.readStatus!=="readable"&&(this.readStatus="readable",this.dispatchReadBuffer(),this.sendResume())}push(e){if(this.readStatus==="closed"||this.readStatus==="closing")throw new Ti(`Cannot push data onto a stream that is ${this.readStatus}`);if(e.byteLength!==0){if(this.readBuffer.append(e),this.readStatus==="paused"||this.listenerCount("message")===0){this.checkReadBufferLength();return}setTimeout(()=>{this.dispatchReadBuffer()},0)}}unshift(e){if(this.readStatus==="closed"||this.readStatus==="closing")throw new Ti(`Cannot push data onto a stream that is ${this.readStatus}`);if(e.byteLength!==0){if(this.readBuffer.prepend(e),this.readStatus==="paused"||this.listenerCount("message")===0){this.checkReadBufferLength();return}setTimeout(()=>{this.dispatchReadBuffer()},0)}}onData(e){if(e.byteLength!==0){if(this.readStatus==="closing"||this.readStatus==="closed"){this.log("ignoring data - read status %s",this.readStatus);return}this.readBuffer.append(e),this.dispatchReadBuffer()}}addEventListener(...e){super.addEventListener.apply(this,e),e[0]==="message"&&this.readBuffer.byteLength>0&&queueMicrotask(()=>{this.dispatchReadBuffer()})}onRemoteReset(){this.log("remote reset"),this.status="reset",this.writeStatus="closed",this.remoteWriteStatus="closed",this.remoteReadStatus="closed",this.timeline.close=Date.now(),this.readBuffer.byteLength===0&&(this.readStatus="closed");let e=new Uu;this.dispatchEvent(new j0(e))}onTransportClosed(e){this.log("transport closed"),this.readStatus==="readable"&&this.readBuffer.byteLength===0&&(this.log("close readable end after transport closed and read buffer is empty"),this.readStatus="closed"),this.remoteReadStatus!=="closed"&&(this.remoteReadStatus="closed"),this.remoteWriteStatus!=="closed"&&(this.remoteWriteStatus="closed"),this.writeStatus!=="closed"&&(this.writeStatus="closed"),e!=null?this.abort(e):(this.status==="open"||this.status==="closing")&&(this.timeline.close=Date.now(),this.status="closed",this.writeStatus="closed",this.remoteWriteStatus="closed",this.remoteReadStatus="closed",this.dispatchEvent(new pa))}onRemoteCloseWrite(){this.remoteWriteStatus!=="closed"&&(this.log.trace("on remote close write"),this.remoteWriteStatus="closed",this.safeDispatchEvent("remoteCloseWrite"),this.writeStatus==="closed"&&this.onTransportClosed())}onRemoteCloseRead(){this.log.trace("on remote close read"),this.remoteReadStatus="closed",this.writeBuffer.byteLength>0&&(this.writeBuffer.consume(this.writeBuffer.byteLength),this.safeDispatchEvent("idle"))}processSendQueue(){if(this.writableNeedsDrain)return this.log.trace("not processing send queue as drain is required"),this.checkWriteBufferLength(),!1;if(this.writeBuffer.byteLength===0)return this.log.trace("not processing send queue as no bytes to send"),!0;if(this.sendingData)return this.log.trace("not processing send queue as already sending data"),!0;this.sendingData=!0,this.log.trace("processing send queue with %d queued bytes",this.writeBuffer.byteLength);try{let e=!0,t=this.writeBuffer.byteLength,n=0;for(;this.writeBuffer.byteLength>0;){let o=Math.min(this.maxMessageSize??this.writeBuffer.byteLength,this.writeBuffer.byteLength);if(o===0){e=!1;break}let i=this.writeBuffer.sublist(0,o),s=new se(i);this.writeBuffer.consume(i.byteLength);let a=this.sendData(i);if(e=a.canSendMore,n+=a.sentBytes,a.sentBytes!==s.byteLength&&(s.consume(a.sentBytes),this.writeBuffer.prepend(s)),!e)break}return e||(this.log.trace("sent %d/%d bytes, pausing sending because underlying stream is full, %d bytes left in the write buffer",n,t,this.writeBuffer.byteLength),this.writableNeedsDrain=!0,this.checkWriteBufferLength()),this.writeBuffer.byteLength===0&&this.safeDispatchEvent("idle"),e}finally{this.sendingData=!1}}dispatchReadBuffer(){try{if(this.listenerCount("message")===0){this.log.trace("not dispatching pause buffer as there are no listeners for the message event");return}if(this.readBuffer.byteLength===0){this.log.trace("not dispatching pause buffer as there is no data to dispatch");return}if(this.readStatus==="paused"){this.log.trace("not dispatching pause buffer we are paused");return}if(this.readStatus==="closing"||this.readStatus==="closed"){this.log("dropping %d bytes because the readable end is %s",this.readBuffer.byteLength,this.readStatus),this.readBuffer.consume(this.readBuffer.byteLength);return}let e=this.readBuffer.sublist();this.readBuffer.consume(e.byteLength),this.dispatchEvent(new q0(e))}finally{this.readBuffer.byteLength===0&&this.remoteWriteStatus==="closed"&&(this.log("close readable end after dispatching read buffer and remote writable end is closed"),this.readStatus="closed"),this.checkReadBufferLength()}}checkReadBufferLength(){this.readBuffer.byteLength>this.maxReadBufferLength&&this.abort(new Ah(`Read buffer length of ${this.readBuffer.byteLength} exceeded limit of ${this.maxReadBufferLength}, read status is ${this.readStatus}`))}checkWriteBufferLength(){this.maxWriteBufferLength!=null&&this.writeBuffer.byteLength>this.maxWriteBufferLength&&this.abort(new Ah(`Write buffer length of ${this.writeBuffer.byteLength} exceeded limit of ${this.maxWriteBufferLength}, write status is ${this.writeStatus}`))}onMuxerNeedsDrain(){this.writableNeedsDrain=!0}onMuxerDrain(){this.safeDispatchEvent("drain")}};var Ia=class extends Ca{remoteAddr;metricPrefix;metrics;constructor(e){super(e),this.metricPrefix=e.metricPrefix??"",this.metrics=e.metrics,this.remoteAddr=e.remoteAddr,this.addEventListener("close",t=>{this.metrics?.increment({[`${this.metricPrefix}end`]:!0}),t.error!=null?t.local?this.metrics?.increment({[`${this.metricPrefix}abort`]:!0}):this.metrics?.increment({[`${this.metricPrefix}reset`]:!0}):t.local?this.metrics?.increment({[`${this.metricPrefix}_local_close`]:!0}):this.metrics?.increment({[`${this.metricPrefix}_remote_close`]:!0})})}async close(e){this.status==="open"&&(this.status="closing",this.writeStatus="closing",this.remoteWriteStatus="closing",this.remoteReadStatus="closing",(this.sendingData||this.writeBuffer.byteLength>0)&&(this.log("waiting for write queue to become idle before closing writable end of stream, %d unsent bytes",this.writeBuffer.byteLength),await Ze(this,"idle",{...e,rejectionEvents:["close"]})),this.writableNeedsDrain&&(this.log("waiting for write queue to drain before closing writable end of stream, %d unsent bytes",this.writeBuffer.byteLength),await Ze(this,"drain",{...e,rejectionEvents:["close"]})),await this.sendClose(e),this.onTransportClosed())}};function yf(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}var ka=class extends _e{streams;protocol;status;log;maConn;streamOptions;earlyStreams;maxEarlyStreams;metrics;constructor(e,t){super(),this.maConn=e,this.protocol=t.protocol,this.streams=[],this.earlyStreams=[],this.status="open",this.log=e.log.newScope(t.name),this.streamOptions=t.streamOptions,this.maxEarlyStreams=t.maxEarlyStreams??10,this.metrics=t.metrics;let n=s=>{try{this.onData(s.data)}catch(a){this.abort(a),this.maConn.abort(a)}};this.maConn.addEventListener("message",n);let o=()=>{this.log("underlying stream drained, signal %d streams to continue writing",this.streams.length),this.streams.forEach(s=>{s.onMuxerDrain()})};this.maConn.addEventListener("drain",o);let i=()=>{this.log("underlying stream closed with status %s and %d streams",this.status,this.streams.length),this.onTransportClosed()};this.maConn.addEventListener("close",i)}send(e){let t=this.maConn.send(e);return t===!1&&(this.log("underlying stream saturated, signal %d streams to pause writing",this.streams.length),this.streams.forEach(n=>{n.onMuxerNeedsDrain()})),t}async close(e){this.status==="closed"||this.status==="closing"||(this.status="closing",await nt(Promise.all([...this.streams].map(async t=>{await t.close(e)})),e?.signal),this.status="closed")}abort(e){this.status!=="closed"&&(this.status="closing",[...this.streams].forEach(t=>{t.abort(e)}),this.status="closed")}onTransportClosed(e){this.status="closing";try{[...this.streams].forEach(t=>{t.onTransportClosed(e)})}catch(t){this.abort(t)}this.status="closed"}async createStream(e){if(this.status!=="open")throw new Yo;let t=this.onCreateStream({...this.streamOptions,...e});return yf(t)&&(t=await t),this.streams.push(t),this.cleanUpStream(t),t}onRemoteStream(e){if(this.streams.push(e),this.cleanUpStream(e),this.listenerCount("stream")===0){this.earlyStreams.push(e),this.earlyStreams.length>this.maxEarlyStreams&&this.abort(new Cg(`Too many early streams were opened - ${this.earlyStreams.length}/${this.maxEarlyStreams}`));return}this.safeDispatchEvent("stream",{detail:e})}cleanUpStream(e){let t=n=>{let o=this.streams.findIndex(i=>i===e);o!==-1&&this.streams.splice(o,1),n.error!=null?n.local?this.metrics?.increment({[`${e.direction}_stream_reset`]:!0}):this.metrics?.increment({[`${e.direction}_stream_abort`]:!0}):this.metrics?.increment({[`${e.direction}_stream_end`]:!0})};e.addEventListener("close",t),this.metrics?.increment({[`${e.direction}_stream`]:!0})}addEventListener(...e){super.addEventListener.apply(this,e),e[0]==="stream"&&this.earlyStreams.length>0&&queueMicrotask(()=>{this.earlyStreams.forEach(t=>{this.safeDispatchEvent("stream",{detail:t})}),this.earlyStreams=[]})}};var Pa=class extends Ca{id;protocol;constructor(e){super(e),this.id=e.id,this.protocol=e.protocol??""}async close(e){this.writeStatus==="closing"||this.writeStatus==="closed"||(this.writeStatus="closing",(this.sendingData||this.writeBuffer.byteLength>0)&&(this.log("waiting for write queue to become idle before closing writable end of stream, %d unsent bytes",this.writeBuffer.byteLength),await Ze(this,"idle",{...e,rejectionEvents:["close"]})),this.writableNeedsDrain&&(this.log("waiting for write queue to drain before closing writable end of stream, %d unsent bytes, sending %s",this.writeBuffer.byteLength,this.sendingData),await Ze(this,"drain",{...e,rejectionEvents:["close"]}),this.log("write queue drained, closing writable end of stream, %d unsent bytes, sending %s",this.writeBuffer.byteLength,this.sendingData)),await this.sendCloseWrite(e),this.writeStatus="closed",this.log("closed writable end gracefully"),this.remoteWriteStatus==="closed"&&this.onTransportClosed())}async closeRead(e){this.readStatus==="closing"||this.readStatus==="closed"||(this.readBuffer.byteLength>0&&this.readBuffer.consume(this.readBuffer.byteLength),this.readStatus="closing",await this.sendCloseRead(e),this.readStatus="closed",this.log("closed readable end gracefully"))}};var wf=class{movingAverage;variance;deviation;forecast;timeSpan;previousTime;constructor(e){this.timeSpan=e,this.movingAverage=0,this.variance=0,this.deviation=0,this.forecast=0}alpha(e,t){return 1-Math.exp(-(e-t)/this.timeSpan)}push(e,t=Date.now()){if(this.previousTime!=null){let n=this.alpha(t,this.previousTime),o=e-this.movingAverage,i=n*o;this.movingAverage=n*e+(1-n)*this.movingAverage,this.variance=(1-n)*(this.variance+o*i),this.deviation=Math.sqrt(this.variance),this.forecast=this.movingAverage+n*o}else this.movingAverage=e;this.previousTime=t}};var bK=1.2,vK=2,EK=5e3,SK=6e4,AK=5e3,oi=class{success;failure;next;metric;timeoutMultiplier;failureMultiplier;minTimeout;maxTimeout;constructor(e={}){let t=e.interval??AK;this.success=new wf(t),this.failure=new wf(t),this.next=new wf(t),this.failureMultiplier=e.failureMultiplier??vK,this.timeoutMultiplier=e.timeoutMultiplier??bK,this.minTimeout=e.minTimeout??EK,this.maxTimeout=e.maxTimeout??SK,e.metricName!=null&&(this.metric=e.metrics?.registerMetricGroup(e.metricName))}getTimeoutSignal(e={}){let t=Math.round(this.next.movingAverage*(e.timeoutFactor??this.timeoutMultiplier));t<this.minTimeout&&(t=this.minTimeout),t>this.maxTimeout&&(t=this.maxTimeout);let n=AbortSignal.timeout(t),o=Re([e.signal,n]);return o.start=Date.now(),o.timeout=t,o}cleanUp(e){let t=Date.now()-e.start;e.aborted?(this.failure.push(t),this.next.push(t*this.failureMultiplier),this.metric?.update({failureMovingAverage:this.failure.movingAverage,failureDeviation:this.failure.deviation,failureForecast:this.failure.forecast,failureVariance:this.failure.variance,failure:t})):(this.success.push(t),this.next.push(t),this.metric?.update({successMovingAverage:this.success.movingAverage,successDeviation:this.success.deviation,successForecast:this.success.forecast,successVariance:this.success.variance,success:t}))}};var kr=class extends Error{static name="InvalidMultiaddrError";name="InvalidMultiaddrError"},As=class extends Error{static name="ValidationError";name="ValidationError"},Rg=class extends Error{static name="InvalidParametersError";name="InvalidParametersError"},Og=class extends Error{static name="UnknownProtocolError";name="UnknownProtocolError"};function L7(r){return e=>H(e,r)}function B7(r){return e=>D(e,r)}function xf(r){return new DataView(r.buffer).getUint16(r.byteOffset).toString()}function ol(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,typeof r=="string"?parseInt(r):r),new Uint8Array(e)}function AT(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let t=D(e[0],"base32"),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ol(n);return dt([t,o],t.length+o.length)}function _T(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let t=gr.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ol(n);return dt([t,o],t.length+o.length)}function M7(r){let e=r.subarray(0,r.length-2),t=r.subarray(r.length-2),n=H(e,"base32"),o=xf(t);return`${n}:${o}`}var U7=function(r){r=r.toString().trim();let e=new Uint8Array(4);return r.split(/\./g).forEach((t,n)=>{let o=parseInt(t,10);if(isNaN(o)||o<0||o>255)throw new kr("Invalid byte value in IP address");e[n]=o}),e},TT=function(r){let e=0;r=r.toString().trim();let t=r.split(":",8),n;for(n=0;n<t.length;n++){let i=ni(t[n]),s;i&&(s=U7(t[n]),t[n]=H(s.subarray(0,2),"base16")),s!=null&&++n<8&&t.splice(n,0,H(s.subarray(2,4),"base16"))}if(t[0]==="")for(;t.length<8;)t.unshift("0");else if(t[t.length-1]==="")for(;t.length<8;)t.push("0");else if(t.length<8){for(n=0;n<t.length&&t[n]!=="";n++);let i=[n,1];for(n=9-t.length;n>0;n--)i.push("0");t.splice.apply(t,i)}let o=new Uint8Array(e+16);for(n=0;n<t.length;n++){t[n]===""&&(t[n]="0");let i=parseInt(t[n],16);if(isNaN(i)||i<0||i>65535)throw new kr("Invalid byte value in IP address");o[e++]=i>>8&255,o[e++]=i&255}return o},CT=function(r){if(r.byteLength!==4)throw new kr("IPv4 address was incorrect length");let e=[];for(let t=0;t<r.byteLength;t++)e.push(r[t]);return e.join(".")},IT=function(r){if(r.byteLength!==16)throw new kr("IPv6 address was incorrect length");let e=[];for(let n=0;n<r.byteLength;n+=2){let o=r[n],i=r[n+1],s=`${o.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`;e.push(s)}let t=e.join(":");try{let n=new URL(`http://[${t}]`);return n.hostname.substring(1,n.hostname.length-1)}catch{throw new kr(`Invalid IPv6 address "${t}"`)}};function kT(r){try{let e=new URL(`http://[${r}]`);return e.hostname.substring(1,e.hostname.length-1)}catch{throw new kr(`Invalid IPv6 address "${r}"`)}}var N7=Object.values(Bc).map(r=>r.decoder),_K=(function(){let r=N7[0].or(N7[1]);return N7.slice(2).forEach(e=>r=r.or(e)),r})();function PT(r){return _K.decode(r)}function RT(r){return e=>r.encoder.encode(e)}function TK(r){if(parseInt(r).toString()!==r)throw new As("Value must be an integer")}function CK(r){if(r<0)throw new As("Value must be a positive integer, or zero")}function IK(r){return e=>{if(e>r)throw new As(`Value must be smaller than or equal to ${r}`)}}function kK(...r){return e=>{for(let t of r)t(e)}}var lp=kK(TK,CK,IK(65535));var vr=-1,F7=class{protocolsByCode=new Map;protocolsByName=new Map;getProtocol(e){let t;if(typeof e=="string"?t=this.protocolsByName.get(e):t=this.protocolsByCode.get(e),t==null)throw new Og(`Protocol ${e} was unknown`);return t}addProtocol(e){this.protocolsByCode.set(e.code,e),this.protocolsByName.set(e.name,e),e.aliases?.forEach(t=>{this.protocolsByName.set(t,e)})}removeProtocol(e){let t=this.protocolsByCode.get(e);t!=null&&(this.protocolsByCode.delete(t.code),this.protocolsByName.delete(t.name),t.aliases?.forEach(n=>{this.protocolsByName.delete(n)}))}},Cs=new F7,qK=[{code:4,name:"ip4",size:32,valueToBytes:U7,bytesToValue:CT,validate:r=>{if(!ni(r))throw new As(`Invalid IPv4 address "${r}"`)}},{code:6,name:"tcp",size:16,valueToBytes:ol,bytesToValue:xf,validate:lp},{code:273,name:"udp",size:16,valueToBytes:ol,bytesToValue:xf,validate:lp},{code:33,name:"dccp",size:16,valueToBytes:ol,bytesToValue:xf,validate:lp},{code:41,name:"ip6",size:128,valueToBytes:TT,bytesToValue:IT,stringToValue:kT,validate:r=>{if(!Sg(r))throw new As(`Invalid IPv6 address "${r}"`)}},{code:42,name:"ip6zone",size:vr},{code:43,name:"ipcidr",size:8,bytesToValue:L7("base10"),valueToBytes:B7("base10")},{code:53,name:"dns",size:vr},{code:54,name:"dns4",size:vr},{code:55,name:"dns6",size:vr},{code:56,name:"dnsaddr",size:vr},{code:132,name:"sctp",size:16,valueToBytes:ol,bytesToValue:xf,validate:lp},{code:301,name:"udt"},{code:302,name:"utp"},{code:400,name:"unix",size:vr,stringToValue:r=>decodeURIComponent(r),valueToString:r=>encodeURIComponent(r)},{code:421,name:"p2p",aliases:["ipfs"],size:vr,bytesToValue:L7("base58btc"),valueToBytes:r=>r.startsWith("Q")||r.startsWith("1")?B7("base58btc")(r):Z.parse(r).multihash.bytes},{code:444,name:"onion",size:96,bytesToValue:M7,valueToBytes:AT},{code:445,name:"onion3",size:296,bytesToValue:M7,valueToBytes:_T},{code:446,name:"garlic64",size:vr},{code:447,name:"garlic32",size:vr},{code:448,name:"tls"},{code:449,name:"sni",size:vr},{code:454,name:"noise"},{code:460,name:"quic"},{code:461,name:"quic-v1"},{code:465,name:"webtransport"},{code:466,name:"certhash",size:vr,bytesToValue:RT(Lc),valueToBytes:PT},{code:480,name:"http"},{code:481,name:"http-path",size:vr,stringToValue:r=>`/${decodeURIComponent(r)}`,valueToString:r=>encodeURIComponent(r.substring(1))},{code:443,name:"https"},{code:477,name:"ws"},{code:478,name:"wss"},{code:479,name:"p2p-websocket-star"},{code:277,name:"p2p-stardust"},{code:275,name:"p2p-webrtc-star"},{code:276,name:"p2p-webrtc-direct"},{code:280,name:"webrtc-direct"},{code:281,name:"webrtc"},{code:290,name:"p2p-circuit"},{code:777,name:"memory",size:vr}];qK.forEach(r=>{Cs.addProtocol(r)});function OT(r){let e=[],t=0;for(;t<r.length;){let n=Yn(r,t),o=Cs.getProtocol(n),i=Fe(n),s=zK(o,r,t+i),a=0;s>0&&o.size===vr&&(a=Fe(s));let c=i+a+s,l={code:n,name:o.name,bytes:r.subarray(t,t+c)};if(s>0){let f=t+i+a,u=r.subarray(f,f+s);l.value=o.bytesToValue?.(u)??H(u)}e.push(l),t+=c}return e}function DT(r){let e=0,t=[];for(let n of r){if(n.bytes==null){let o=Cs.getProtocol(n.code),i=Fe(n.code),s,a=0,c=0;n.value!=null&&(s=o.valueToBytes?.(n.value)??D(n.value),a=s.byteLength,o.size===vr&&(c=Fe(a)));let l=new Uint8Array(i+c+a),f=0;cf(n.code,l,f),f+=i,s!=null&&(o.size===vr&&(cf(a,l,f),f+=c),l.set(s,f)),n.bytes=l}t.push(n.bytes),e+=n.bytes.byteLength}return dt(t,e)}function NT(r){if(r.charAt(0)!=="/")throw new kr('String multiaddr must start with "/"');let e=[],t="protocol",n="",o="";for(let i=1;i<r.length;i++){let s=r.charAt(i);s!=="/"&&(t==="protocol"?o+=r.charAt(i):n+=r.charAt(i));let a=i===r.length-1;if(s==="/"||a){let c=Cs.getProtocol(o);if(t==="protocol"){if(c.size==null||c.size===0){e.push({code:c.code,name:c.name}),n="",o="",t="protocol";continue}else if(a)throw new kr(`Component ${o} was missing value`);t="value"}else if(t==="value"){let l={code:c.code,name:c.name};if(c.size!=null&&c.size!==0){if(n==="")throw new kr(`Component ${o} was missing value`);l.value=c.stringToValue?.(n)??n}e.push(l),n="",o="",t="protocol"}}}if(o!==""&&n!=="")throw new kr("Incomplete multiaddr");return e}function LT(r){return`/${r.flatMap(e=>{if(e.value==null)return e.name;let t=Cs.getProtocol(e.code);if(t==null)throw new kr(`Unknown protocol code ${e.code}`);return[e.name,t.valueToString?.(e.value)??e.value]}).join("/")}`}function zK(r,e,t){return r.size==null||r.size===0?0:r.size>0?r.size/8:Yn(e,t)}var jK=Symbol.for("nodejs.util.inspect.custom"),G7=Symbol.for("@multiformats/multiaddr");function WK(r){if(r==null&&(r="/"),Li(r))return r.getComponents();if(r instanceof Uint8Array)return OT(r);if(typeof r=="string")return r=r.replace(/\/(\/)+/,"/").replace(/(\/)+$/,""),r===""&&(r="/"),NT(r);if(Array.isArray(r))return r;throw new kr("Must be a string, Uint8Array, Component[], or another Multiaddr")}var Bg=class r{[G7]=!0;#t;#e;#r;constructor(e="/",t={}){this.#t=WK(e),t.validate!==!1&&GK(this)}get bytes(){return this.#r==null&&(this.#r=DT(this.#t)),this.#r}toString(){return this.#e==null&&(this.#e=LT(this.#t)),this.#e}toJSON(){return this.toString()}getComponents(){return[...this.#t.map(e=>({...e}))]}encapsulate(e){let t=new r(e);return new r([...this.#t,...t.getComponents()],{validate:!1})}decapsulate(e){let t=e.toString(),n=this.toString(),o=n.lastIndexOf(t);if(o<0)throw new Rg(`Address ${this.toString()} does not contain subaddress: ${t}`);return new r(n.slice(0,o),{validate:!1})}decapsulateCode(e){let t;for(let n=this.#t.length-1;n>-1;n--)if(this.#t[n].code===e){t=n;break}return new r(this.#t.slice(0,t),{validate:!1})}equals(e){return me(this.bytes,e.bytes)}[jK](){return`Multiaddr(${this.toString()})`}};function GK(r){r.getComponents().forEach(e=>{let t=Cs.getProtocol(e.code);e.value!=null&&t.validate?.(e.value)})}function Li(r){return!!r?.[G7]}function ie(r){return new Bg(r)}var X7=class{readNext;haveNext;ended;nextResult;error;constructor(){this.ended=!1,this.readNext=He(),this.haveNext=He()}[Symbol.asyncIterator](){return this}async next(){if(this.nextResult==null&&await this.haveNext.promise,this.nextResult==null)throw new Error("HaveNext promise resolved but nextResult was undefined");let e=this.nextResult;return this.nextResult=void 0,this.readNext.resolve(),this.readNext=He(),e}async throw(e){return this.ended=!0,this.error=e,e!=null&&(this.haveNext.promise.catch(()=>{}),this.haveNext.reject(e)),{done:!0,value:void 0}}async return(){let e={done:!0,value:void 0};return this.ended=!0,this.nextResult=e,this.haveNext.resolve(),e}async push(e,t){await this._push(e,t)}async end(e,t){e!=null?await this.throw(e):await this._push(void 0,t)}async _push(e,t){if(e!=null&&this.ended)throw this.error??new Error("Cannot push value onto an ended pushable");for(;this.nextResult!=null;)await this.readNext.promise;e!=null?this.nextResult={done:!1,value:e}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=He(),await nt(this.readNext.promise,t?.signal,t)}};function BT(){return new X7}function XK(r){return r[Symbol.asyncIterator]!=null}async function YK(r,e,t){try{await Promise.all(r.map(async n=>{for await(let o of n)await e.push(o,{signal:t}),t.throwIfAborted()})),await e.end(void 0,{signal:t})}catch(n){await e.end(n,{signal:t}).catch(()=>{})}}async function*QK(r){let e=new AbortController,t=BT();YK(r,t,e.signal).catch(()=>{});try{yield*t}finally{e.abort()}}function*ZK(r){for(let e of r)yield*e}function JK(...r){let e=[];for(let t of r)XK(t)||e.push(t);return e.length===r.length?ZK(e):QK(r)}var cn=JK;function ln(r,...e){if(r==null)throw new Error("Empty pipeline");if(Y7(r)){let n=r;r=()=>n.source}else if(UT(r)||MT(r)){let n=r;r=()=>n}let t=[r,...e];if(t.length>1&&Y7(t[t.length-1])&&(t[t.length-1]=t[t.length-1].sink),t.length>2)for(let n=1;n<t.length-1;n++)Y7(t[n])&&(t[n]=tV(t[n]));return eV(...t)}var eV=(...r)=>{let e;for(;r.length>0;)e=r.shift()(e);return e},MT=r=>r?.[Symbol.asyncIterator]!=null,UT=r=>r?.[Symbol.iterator]!=null,Y7=r=>r==null?!1:r.sink!=null&&r.source!=null,tV=r=>e=>{let t=r.sink(e);if(t?.then!=null){let n=ur({objectMode:!0});t.then(()=>{n.end()},s=>{n.end(s)});let o,i=r.source;if(MT(i))o=async function*(){yield*i,n.end()};else if(UT(i))o=function*(){yield*i,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return cn(n,o())}return r.source};var rV=4194304,Mg=class extends Error{static name="UnwrappedError";name="UnwrappedError"},mp=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},Z7=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},J7=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"};function nV(r){return typeof r?.closeRead=="function"}function oV(r){return typeof r?.close=="function"}function Q7(r){return nV(r)?r.remoteWriteStatus!=="writable"&&r.readBufferLength===0:oV(r)?r.status!=="open":!1}function iV(r){return r?.addEventListener!=null&&r?.removeEventListener!=null&&r?.send!=null&&r?.push!=null&&r?.log!=null}function Ug(r,e){let t=e?.maxBufferSize??rV,n=new se,o,i=!1;if(!iV(r))throw new O("Argument should be a Stream or a Multiaddr");let s=f=>{if(n.append(f.data),n.byteLength>t){let u=n.byteLength;n.consume(n.byteLength),o?.reject(new Error(`Read buffer overflow - ${u} > ${t}`))}o?.resolve()};r.addEventListener("message",s);let a=f=>{f.error!=null?o?.reject(f.error):o?.resolve()};r.addEventListener("close",a);let c=()=>{o?.resolve()};r.addEventListener("remoteCloseWrite",c);let l={readBuffer:n,async read(f){if(i===!0)throw new Mg("Stream was unwrapped");if(Q7(r)){if(f?.bytes==null)return null;if(n.byteLength<f.bytes)throw r.log.error("closed after reading %d/%d bytes",n.byteLength,f.bytes),new nl(`Unexpected EOF - stream closed after reading ${n.byteLength}/${f.bytes} bytes`)}let u=f?.bytes??1;for(o=Promise.withResolvers();;){if(n.byteLength>=u){o.resolve();break}if(await nt(o.promise,f?.signal),Q7(r)){if(n.byteLength===0&&f?.bytes==null)return null;break}o=Promise.withResolvers()}let h=f?.bytes??n.byteLength;if(n.byteLength<h){if(Q7(r))throw r.log.error("closed while reading %d/%d bytes",n.byteLength,h),new nl(`Unexpected EOF - stream closed while reading ${n.byteLength}/${h} bytes`);return l.read(f)}let d=n.sublist(0,h);return n.consume(h),d},async write(f,u){if(i===!0)throw new Mg("Stream was unwrapped");r.send(f)||await Ze(r,"drain",{signal:u?.signal,rejectionEvents:["close"]})},unwrap(){return i||(i=!0,r.removeEventListener("message",s),r.removeEventListener("close",a),r.removeEventListener("remoteCloseWrite",c),n.byteLength>0&&(r.log("stream unwrapped with %d unread bytes",n.byteLength),r.push(n))),r}};return l}function Oa(r,e={}){let t=Ug(r,e);e.maxDataLength!=null&&e.maxLengthLength==null&&(e.maxLengthLength=Fe(e.maxDataLength));let n=e?.lengthDecoder??Yn,o=e?.lengthEncoder??Wr;return{async read(s){let a=-1,c=new se;for(;;){let f=await t.read({...s,bytes:1});if(f==null)break;c.append(f);try{a=n(c)}catch(u){if(u instanceof RangeError)continue;throw u}if(a<0)throw new mp("Invalid message length");if(e?.maxLengthLength!=null&&c.byteLength>e.maxLengthLength)throw new J7(`Message length length too long - ${c.byteLength} > ${e.maxLengthLength}`);if(a>-1)break}if(e?.maxDataLength!=null&&a>e.maxDataLength)throw new Z7(`Message length too long - ${a} > ${e.maxDataLength}`);let l=await t.read({...s,bytes:a});if(l==null)throw r.log.error("tried to read %d bytes but the stream closed",a),new nl(`Unexpected EOF - tried to read ${a} bytes but the stream closed`);if(l.byteLength!==a)throw r.log.error("read %d/%d bytes before the stream closed",l.byteLength,a),new nl(`Unexpected EOF - read ${l.byteLength}/${a} bytes before the stream closed`);return l},async write(s,a){await t.write(new se(o(s.byteLength),s),a)},async writeV(s,a){let c=new se(...s.flatMap(l=>[o(l.byteLength),l]));await t.write(c,a)},unwrap(){return t.unwrap()}}}function bt(r,e){let t=Oa(r,e),n={read:async(o,i)=>{let s=await t.read(i);return o.decode(s)},write:async(o,i,s)=>{await t.write(i.encode(o),s)},writeV:async(o,i,s)=>{await t.writeV(o.map(a=>i.encode(a)),s)},pb:o=>({read:async i=>n.read(o,i),write:async(i,s)=>n.write(i,o,s),writeV:async(i,s)=>n.writeV(i,o,s),unwrap:()=>n}),unwrap:()=>t.unwrap()};return n}var sV=1024*1024*4,aV=1024*1024*4,Fg=class{buffer;maxBufferSize;lengthDecoder;maxDataLength;encodingLength;constructor(e={}){this.buffer=new se,this.maxBufferSize=e.maxBufferSize??sV,this.maxDataLength=e.maxDataLength??aV,this.lengthDecoder=e.lengthDecoder??Yn,this.encodingLength=e.encodingLength??Fe}*decode(e){if(this.buffer.append(e),this.buffer.byteLength>this.maxBufferSize)throw new O(`Buffer length limit exceeded - ${this.buffer.byteLength}/${this.maxBufferSize}`);for(;;){let t;try{t=this.lengthDecoder(this.buffer)}catch(i){if(i instanceof RangeError)break;throw i}if(t<0||t>this.maxDataLength)throw new mp("Invalid message length");let n=this.encodingLength(t),o=n+t;if(this.buffer.byteLength>=o){let i=this.buffer.sublist(n,o);this.buffer.consume(o),i.byteLength>0&&(yield i)}else break}}};var cV=["string","number","bigint","symbol"],lV=["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 FT(r){if(r===null)return"null";if(r===void 0)return"undefined";if(r===!0||r===!1)return"boolean";let e=typeof r;if(cV.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(r))return"Array";if(uV(r))return"Buffer";let t=fV(r);return t||"Object"}function uV(r){return r&&r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer.call(null,r)}function fV(r){let e=Object.prototype.toString.call(r).slice(8,-1);if(lV.includes(e))return e}var A=class{constructor(e,t,n){this.major=e,this.majorEncoded=e<<5,this.name=t,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:this.major>e.major?1:0}};A.uint=new A(0,"uint",!0);A.negint=new A(1,"negint",!0);A.bytes=new A(2,"bytes",!0);A.string=new A(3,"string",!0);A.array=new A(4,"array",!1);A.map=new A(5,"map",!1);A.tag=new A(6,"tag",!1);A.float=new A(7,"float",!0);A.false=new A(7,"false",!0);A.true=new A(7,"true",!0);A.null=new A(7,"null",!0);A.undefined=new A(7,"undefined",!0);A.break=new A(7,"break",!0);var j=class{constructor(e,t,n){this.type=e,this.value=t,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var Sf=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",dV=new TextDecoder,hV=new TextEncoder;function $g(r){return Sf&&globalThis.Buffer.isBuffer(r)}function gp(r){return r instanceof Uint8Array?$g(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r:Uint8Array.from(r)}var VT=Sf?(r,e,t)=>t-e>64?globalThis.Buffer.from(r.subarray(e,t)).toString("utf8"):HT(r,e,t):(r,e,t)=>t-e>64?dV.decode(r.subarray(e,t)):HT(r,e,t),Hg=Sf?r=>r.length>64?globalThis.Buffer.from(r):$T(r):r=>r.length>64?hV.encode(r):$T(r),Bi=r=>Uint8Array.from(r),Af=Sf?(r,e,t)=>$g(r)?new Uint8Array(r.subarray(e,t)):r.slice(e,t):(r,e,t)=>r.slice(e,t),qT=Sf?(r,e)=>(r=r.map(t=>t instanceof Uint8Array?t:globalThis.Buffer.from(t)),gp(globalThis.Buffer.concat(r,e))):(r,e)=>{let t=new Uint8Array(e),n=0;for(let o of r)n+o.length>t.length&&(o=o.subarray(0,t.length-n)),t.set(o,n),n+=o.length;return t},zT=Sf?r=>globalThis.Buffer.allocUnsafe(r):r=>new Uint8Array(r);function Kg(r,e){if($g(r)&&$g(e))return r.compare(e);for(let t=0;t<r.length;t++)if(r[t]!==e[t])return r[t]<e[t]?-1:1;return 0}function $T(r){let e=[],t=0;for(let n=0;n<r.length;n++){let o=r.charCodeAt(n);o<128?e[t++]=o:o<2048?(e[t++]=o>>6|192,e[t++]=o&63|128):(o&64512)===55296&&n+1<r.length&&(r.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(r.charCodeAt(++n)&1023),e[t++]=o>>18|240,e[t++]=o>>12&63|128,e[t++]=o>>6&63|128,e[t++]=o&63|128):(e[t++]=o>>12|224,e[t++]=o>>6&63|128,e[t++]=o&63|128)}return e}function HT(r,e,t){let n=[];for(;e<t;){let o=r[e],i=null,s=o>239?4:o>223?3:o>191?2:1;if(e+s<=t){let a,c,l,f;switch(s){case 1:o<128&&(i=o);break;case 2:a=r[e+1],(a&192)===128&&(f=(o&31)<<6|a&63,f>127&&(i=f));break;case 3:a=r[e+1],c=r[e+2],(a&192)===128&&(c&192)===128&&(f=(o&15)<<12|(a&63)<<6|c&63,f>2047&&(f<55296||f>57343)&&(i=f));break;case 4:a=r[e+1],c=r[e+2],l=r[e+3],(a&192)===128&&(c&192)===128&&(l&192)===128&&(f=(o&15)<<18|(a&63)<<12|(c&63)<<6|l&63,f>65535&&f<1114112&&(i=f))}}i===null?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),e+=s}return ex(n)}var KT=4096;function ex(r){let e=r.length;if(e<=KT)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=KT));return t}var pV=256,yp=class{constructor(e=pV){this.chunkSize=e,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(e){let t=this.chunks[this.chunks.length-1];if(this.cursor+e.length<=this.maxCursor+1){let o=t.length-(this.maxCursor-this.cursor)-1;t.set(e,o)}else{if(t){let o=t.length-(this.maxCursor-this.cursor)-1;o<t.length&&(this.chunks[this.chunks.length-1]=t.subarray(0,o),this.maxCursor=this.cursor-1)}e.length<64&&e.length<this.chunkSize?(t=zT(this.chunkSize),this.chunks.push(t),this.maxCursor+=t.length,this._initReuseChunk===null&&(this._initReuseChunk=t),t.set(e,0)):(this.chunks.push(e),this.maxCursor+=e.length)}this.cursor+=e.length}toBytes(e=!1){let t;if(this.chunks.length===1){let n=this.chunks[0];e&&this.cursor>n.length/2?(t=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):t=Af(n,0,this.cursor)}else t=qT(this.chunks,this.cursor);return e&&this.reset(),t}};var ge="CBOR decode error:",Is="CBOR encode error:",wp=[];wp[23]=1;wp[24]=2;wp[25]=3;wp[26]=5;wp[27]=9;function ks(r,e,t){if(r.length-e<t)throw new Error(`${ge} not enough data for type`)}var Er=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Zn(r,e,t){ks(r,e,1);let n=r[e];if(t.strict===!0&&n<Er[0])throw new Error(`${ge} integer encoded in more bytes than necessary (strict decode)`);return n}function Jn(r,e,t){ks(r,e,2);let n=r[e]<<8|r[e+1];if(t.strict===!0&&n<Er[1])throw new Error(`${ge} integer encoded in more bytes than necessary (strict decode)`);return n}function eo(r,e,t){ks(r,e,4);let n=r[e]*16777216+(r[e+1]<<16)+(r[e+2]<<8)+r[e+3];if(t.strict===!0&&n<Er[2])throw new Error(`${ge} integer encoded in more bytes than necessary (strict decode)`);return n}function to(r,e,t){ks(r,e,8);let n=r[e]*16777216+(r[e+1]<<16)+(r[e+2]<<8)+r[e+3],o=r[e+4]*16777216+(r[e+5]<<16)+(r[e+6]<<8)+r[e+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(t.strict===!0&&i<Er[3])throw new Error(`${ge} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(t.allowBigInt===!0)return i;throw new Error(`${ge} integers outside of the safe integer range are not supported`)}function jT(r,e,t,n){return new j(A.uint,Zn(r,e+1,n),2)}function WT(r,e,t,n){return new j(A.uint,Jn(r,e+1,n),3)}function GT(r,e,t,n){return new j(A.uint,eo(r,e+1,n),5)}function XT(r,e,t,n){return new j(A.uint,to(r,e+1,n),9)}function To(r,e){return Pr(r,0,e.value)}function Pr(r,e,t){if(t<Er[0]){let n=Number(t);r.push([e|n])}else if(t<Er[1]){let n=Number(t);r.push([e|24,n])}else if(t<Er[2]){let n=Number(t);r.push([e|25,n>>>8,n&255])}else if(t<Er[3]){let n=Number(t);r.push([e|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(t);if(n<Er[4]){let o=[e|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),s=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=s&255,s=s>>8,o[3]=s&255,s=s>>8,o[2]=s&255,s=s>>8,o[1]=s&255,r.push(o)}else throw new Error(`${ge} encountered BigInt larger than allowable range`)}}To.encodedSize=function(e){return Pr.encodedSize(e.value)};Pr.encodedSize=function(e){return e<Er[0]?1:e<Er[1]?2:e<Er[2]?3:e<Er[3]?5:9};To.compareTokens=function(e,t){return e.value<t.value?-1:e.value>t.value?1:0};function YT(r,e,t,n){return new j(A.negint,-1-Zn(r,e+1,n),2)}function QT(r,e,t,n){return new j(A.negint,-1-Jn(r,e+1,n),3)}function ZT(r,e,t,n){return new j(A.negint,-1-eo(r,e+1,n),5)}var tx=BigInt(-1),JT=BigInt(1);function eC(r,e,t,n){let o=to(r,e+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new j(A.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${ge} integers outside of the safe integer range are not supported`);return new j(A.negint,tx-BigInt(o),9)}function Vg(r,e){let t=e.value,n=typeof t=="bigint"?t*tx-JT:t*-1-1;Pr(r,e.type.majorEncoded,n)}Vg.encodedSize=function(e){let t=e.value,n=typeof t=="bigint"?t*tx-JT:t*-1-1;return n<Er[0]?1:n<Er[1]?2:n<Er[2]?3:n<Er[3]?5:9};Vg.compareTokens=function(e,t){return e.value<t.value?1:e.value>t.value?-1:0};function xp(r,e,t,n){ks(r,e,t+n);let o=Af(r,e+t,e+t+n);return new j(A.bytes,o,t+n)}function tC(r,e,t,n){return xp(r,e,1,t)}function rC(r,e,t,n){return xp(r,e,2,Zn(r,e+1,n))}function nC(r,e,t,n){return xp(r,e,3,Jn(r,e+1,n))}function oC(r,e,t,n){return xp(r,e,5,eo(r,e+1,n))}function iC(r,e,t,n){let o=to(r,e+1,n);if(typeof o=="bigint")throw new Error(`${ge} 64-bit integer bytes lengths not supported`);return xp(r,e,9,o)}function qg(r){return r.encodedBytes===void 0&&(r.encodedBytes=r.type===A.string?Hg(r.value):r.value),r.encodedBytes}function _f(r,e){let t=qg(e);Pr(r,e.type.majorEncoded,t.length),r.push(t)}_f.encodedSize=function(e){let t=qg(e);return Pr.encodedSize(t.length)+t.length};_f.compareTokens=function(e,t){return gV(qg(e),qg(t))};function gV(r,e){return r.length<e.length?-1:r.length>e.length?1:Kg(r,e)}function bp(r,e,t,n,o){let i=t+n;ks(r,e,i);let s=new j(A.string,VT(r,e+t,e+i),i);return o.retainStringBytes===!0&&(s.byteValue=Af(r,e+t,e+i)),s}function sC(r,e,t,n){return bp(r,e,1,t,n)}function aC(r,e,t,n){return bp(r,e,2,Zn(r,e+1,n),n)}function cC(r,e,t,n){return bp(r,e,3,Jn(r,e+1,n),n)}function lC(r,e,t,n){return bp(r,e,5,eo(r,e+1,n),n)}function uC(r,e,t,n){let o=to(r,e+1,n);if(typeof o=="bigint")throw new Error(`${ge} 64-bit integer string lengths not supported`);return bp(r,e,9,o,n)}var fC=_f;function Tf(r,e,t,n){return new j(A.array,n,t)}function dC(r,e,t,n){return Tf(r,e,1,t)}function hC(r,e,t,n){return Tf(r,e,2,Zn(r,e+1,n))}function pC(r,e,t,n){return Tf(r,e,3,Jn(r,e+1,n))}function mC(r,e,t,n){return Tf(r,e,5,eo(r,e+1,n))}function gC(r,e,t,n){let o=to(r,e+1,n);if(typeof o=="bigint")throw new Error(`${ge} 64-bit integer array lengths not supported`);return Tf(r,e,9,o)}function yC(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${ge} indefinite length items not allowed`);return Tf(r,e,1,1/0)}function zg(r,e){Pr(r,A.array.majorEncoded,e.value)}zg.compareTokens=To.compareTokens;zg.encodedSize=function(e){return Pr.encodedSize(e.value)};function Cf(r,e,t,n){return new j(A.map,n,t)}function wC(r,e,t,n){return Cf(r,e,1,t)}function xC(r,e,t,n){return Cf(r,e,2,Zn(r,e+1,n))}function bC(r,e,t,n){return Cf(r,e,3,Jn(r,e+1,n))}function vC(r,e,t,n){return Cf(r,e,5,eo(r,e+1,n))}function EC(r,e,t,n){let o=to(r,e+1,n);if(typeof o=="bigint")throw new Error(`${ge} 64-bit integer map lengths not supported`);return Cf(r,e,9,o)}function SC(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${ge} indefinite length items not allowed`);return Cf(r,e,1,1/0)}function jg(r,e){Pr(r,A.map.majorEncoded,e.value)}jg.compareTokens=To.compareTokens;jg.encodedSize=function(e){return Pr.encodedSize(e.value)};function AC(r,e,t,n){return new j(A.tag,t,1)}function _C(r,e,t,n){return new j(A.tag,Zn(r,e+1,n),2)}function TC(r,e,t,n){return new j(A.tag,Jn(r,e+1,n),3)}function CC(r,e,t,n){return new j(A.tag,eo(r,e+1,n),5)}function IC(r,e,t,n){return new j(A.tag,to(r,e+1,n),9)}function Wg(r,e){Pr(r,A.tag.majorEncoded,e.value)}Wg.compareTokens=To.compareTokens;Wg.encodedSize=function(e){return Pr.encodedSize(e.value)};var EV=20,SV=21,AV=22,_V=23;function kC(r,e,t,n){if(n.allowUndefined===!1)throw new Error(`${ge} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new j(A.null,null,1):new j(A.undefined,void 0,1)}function PC(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${ge} indefinite length items not allowed`);return new j(A.break,void 0,1)}function rx(r,e,t){if(t){if(t.allowNaN===!1&&Number.isNaN(r))throw new Error(`${ge} NaN values are not supported`);if(t.allowInfinity===!1&&(r===1/0||r===-1/0))throw new Error(`${ge} Infinity values are not supported`)}return new j(A.float,r,e)}function RC(r,e,t,n){return rx(nx(r,e+1),3,n)}function OC(r,e,t,n){return rx(ox(r,e+1),5,n)}function DC(r,e,t,n){return rx(MC(r,e+1),9,n)}function Gg(r,e,t){let n=e.value;if(n===!1)r.push([A.float.majorEncoded|EV]);else if(n===!0)r.push([A.float.majorEncoded|SV]);else if(n===null)r.push([A.float.majorEncoded|AV]);else if(n===void 0)r.push([A.float.majorEncoded|_V]);else{let o,i=!1;(!t||t.float64!==!0)&&(LC(n),o=nx(si,1),n===o||Number.isNaN(n)?(si[0]=249,r.push(si.slice(0,3)),i=!0):(BC(n),o=ox(si,1),n===o&&(si[0]=250,r.push(si.slice(0,5)),i=!0))),i||(TV(n),o=MC(si,1),si[0]=251,r.push(si.slice(0,9)))}}Gg.encodedSize=function(e,t){let n=e.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!t||t.float64!==!0){LC(n);let o=nx(si,1);if(n===o||Number.isNaN(n))return 3;if(BC(n),o=ox(si,1),n===o)return 5}return 9};var NC=new ArrayBuffer(9),Co=new DataView(NC,1),si=new Uint8Array(NC,0);function LC(r){if(r===1/0)Co.setUint16(0,31744,!1);else if(r===-1/0)Co.setUint16(0,64512,!1);else if(Number.isNaN(r))Co.setUint16(0,32256,!1);else{Co.setFloat32(0,r);let e=Co.getUint32(0),t=(e&2139095040)>>23,n=e&8388607;if(t===255)Co.setUint16(0,31744,!1);else if(t===0)Co.setUint16(0,(r&2147483648)>>16|n>>13,!1);else{let o=t-127;o<-24?Co.setUint16(0,0):o<-14?Co.setUint16(0,(e&2147483648)>>16|1<<24+o,!1):Co.setUint16(0,(e&2147483648)>>16|o+15<<10|n>>13,!1)}}}function nx(r,e){if(r.length-e<2)throw new Error(`${ge} not enough data for float16`);let t=(r[e]<<8)+r[e+1];if(t===31744)return 1/0;if(t===64512)return-1/0;if(t===32256)return NaN;let n=t>>10&31,o=t&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,t&32768?-i:i}function BC(r){Co.setFloat32(0,r,!1)}function ox(r,e){if(r.length-e<4)throw new Error(`${ge} not enough data for float32`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,4).getFloat32(0,!1)}function TV(r){Co.setFloat64(0,r,!1)}function MC(r,e){if(r.length-e<8)throw new Error(`${ge} not enough data for float64`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,8).getFloat64(0,!1)}Gg.compareTokens=To.compareTokens;function Je(r,e,t){throw new Error(`${ge} encountered invalid minor (${t}) for major ${r[e]>>>5}`)}function Xg(r){return()=>{throw new Error(`${ge} ${r}`)}}var oe=[];for(let r=0;r<=23;r++)oe[r]=Je;oe[24]=jT;oe[25]=WT;oe[26]=GT;oe[27]=XT;oe[28]=Je;oe[29]=Je;oe[30]=Je;oe[31]=Je;for(let r=32;r<=55;r++)oe[r]=Je;oe[56]=YT;oe[57]=QT;oe[58]=ZT;oe[59]=eC;oe[60]=Je;oe[61]=Je;oe[62]=Je;oe[63]=Je;for(let r=64;r<=87;r++)oe[r]=tC;oe[88]=rC;oe[89]=nC;oe[90]=oC;oe[91]=iC;oe[92]=Je;oe[93]=Je;oe[94]=Je;oe[95]=Xg("indefinite length bytes/strings are not supported");for(let r=96;r<=119;r++)oe[r]=sC;oe[120]=aC;oe[121]=cC;oe[122]=lC;oe[123]=uC;oe[124]=Je;oe[125]=Je;oe[126]=Je;oe[127]=Xg("indefinite length bytes/strings are not supported");for(let r=128;r<=151;r++)oe[r]=dC;oe[152]=hC;oe[153]=pC;oe[154]=mC;oe[155]=gC;oe[156]=Je;oe[157]=Je;oe[158]=Je;oe[159]=yC;for(let r=160;r<=183;r++)oe[r]=wC;oe[184]=xC;oe[185]=bC;oe[186]=vC;oe[187]=EC;oe[188]=Je;oe[189]=Je;oe[190]=Je;oe[191]=SC;for(let r=192;r<=215;r++)oe[r]=AC;oe[216]=_C;oe[217]=TC;oe[218]=CC;oe[219]=IC;oe[220]=Je;oe[221]=Je;oe[222]=Je;oe[223]=Je;for(let r=224;r<=243;r++)oe[r]=Xg("simple values are not supported");oe[244]=Je;oe[245]=Je;oe[246]=Je;oe[247]=kC;oe[248]=Xg("simple values are not supported");oe[249]=RC;oe[250]=OC;oe[251]=DC;oe[252]=Je;oe[253]=Je;oe[254]=Je;oe[255]=PC;var ai=[];for(let r=0;r<24;r++)ai[r]=new j(A.uint,r,1);for(let r=-1;r>=-24;r--)ai[31-r]=new j(A.negint,r,1);ai[64]=new j(A.bytes,new Uint8Array(0),1);ai[96]=new j(A.string,"",1);ai[128]=new j(A.array,0,1);ai[160]=new j(A.map,0,1);ai[244]=new j(A.false,!1,1);ai[245]=new j(A.true,!0,1);ai[246]=new j(A.null,null,1);function Yg(r){switch(r.type){case A.false:return Bi([244]);case A.true:return Bi([245]);case A.null:return Bi([246]);case A.bytes:return r.value.length?void 0:Bi([64]);case A.string:return r.value===""?Bi([96]):void 0;case A.array:return r.value===0?Bi([128]):void 0;case A.map:return r.value===0?Bi([160]):void 0;case A.uint:return r.value<24?Bi([Number(r.value)]):void 0;case A.negint:if(r.value>=-24)return Bi([31-Number(r.value)])}}var IV={float64:!1,mapSorter:PV,quickEncodeToken:Yg},FC=Object.freeze({float64:!0,mapSorter:RV,quickEncodeToken:Yg});function sx(){let r=[];return r[A.uint.major]=To,r[A.negint.major]=Vg,r[A.bytes.major]=_f,r[A.string.major]=fC,r[A.array.major]=zg,r[A.map.major]=jg,r[A.tag.major]=Wg,r[A.float.major]=Gg,r}var ax=sx(),ix=new yp,Qg=class r{constructor(e,t){this.obj=e,this.parent=t}includes(e){let t=this;do if(t.obj===e)return!0;while(t=t.parent);return!1}static createCheck(e,t){if(e&&e.includes(t))throw new Error(`${Is} object contains circular references`);return new r(t,e)}},Da={null:new j(A.null,null),undefined:new j(A.undefined,void 0),true:new j(A.true,!0),false:new j(A.false,!1),emptyArray:new j(A.array,0),emptyMap:new j(A.map,0)},Na={number(r,e,t,n){return!Number.isInteger(r)||!Number.isSafeInteger(r)?new j(A.float,r):r>=0?new j(A.uint,r):new j(A.negint,r)},bigint(r,e,t,n){return r>=BigInt(0)?new j(A.uint,r):new j(A.negint,r)},Uint8Array(r,e,t,n){return new j(A.bytes,r)},string(r,e,t,n){return new j(A.string,r)},boolean(r,e,t,n){return r?Da.true:Da.false},null(r,e,t,n){return Da.null},undefined(r,e,t,n){return Da.undefined},ArrayBuffer(r,e,t,n){return new j(A.bytes,new Uint8Array(r))},DataView(r,e,t,n){return new j(A.bytes,new Uint8Array(r.buffer,r.byteOffset,r.byteLength))},Array(r,e,t,n){if(!r.length)return t.addBreakTokens===!0?[Da.emptyArray,new j(A.break)]:Da.emptyArray;n=Qg.createCheck(n,r);let o=[],i=0;for(let s of r)o[i++]=vp(s,t,n);return t.addBreakTokens?[new j(A.array,r.length),o,new j(A.break)]:[new j(A.array,r.length),o]},Object(r,e,t,n){let o=e!=="Object",i=o?r.keys():Object.keys(r),s=o?r.size:i.length;if(!s)return t.addBreakTokens===!0?[Da.emptyMap,new j(A.break)]:Da.emptyMap;n=Qg.createCheck(n,r);let a=[],c=0;for(let l of i)a[c++]=[vp(l,t,n),vp(o?r.get(l):r[l],t,n)];return kV(a,t),t.addBreakTokens?[new j(A.map,s),a,new j(A.break)]:[new j(A.map,s),a]}};Na.Map=Na.Object;Na.Buffer=Na.Uint8Array;for(let r of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Na[`${r}Array`]=Na.DataView;function vp(r,e={},t){let n=FT(r),o=e&&e.typeEncoders&&e.typeEncoders[n]||Na[n];if(typeof o=="function"){let s=o(r,n,e,t);if(s!=null)return s}let i=Na[n];if(!i)throw new Error(`${Is} unsupported type: ${n}`);return i(r,n,e,t)}function kV(r,e){e.mapSorter&&r.sort(e.mapSorter)}function PV(r,e){let t=Array.isArray(r[0])?r[0][0]:r[0],n=Array.isArray(e[0])?e[0][0]:e[0];if(t.type!==n.type)return t.type.compare(n.type);let o=t.type.major,i=ax[o].compareTokens(t,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function RV(r,e){if(r[0]instanceof j&&e[0]instanceof j){let t=r[0],n=e[0];return t._keyBytes||(t._keyBytes=UC(t.value)),n._keyBytes||(n._keyBytes=UC(n.value)),Kg(t._keyBytes,n._keyBytes)}throw new Error("rfc8949MapSorter: complex key types are not supported yet")}function UC(r){return Zg(r,ax,FC)}function $C(r,e,t,n){if(Array.isArray(e))for(let o of e)$C(r,o,t,n);else t[e.type.major](r,e,n)}function Zg(r,e,t){let n=vp(r,t);if(!Array.isArray(n)&&t.quickEncodeToken){let o=t.quickEncodeToken(n);if(o)return o;let i=e[n.type.major];if(i.encodedSize){let s=i.encodedSize(n,t),a=new yp(s);if(i(a,n,t),a.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return gp(a.chunks[0])}}return ix.reset(),$C(ix,n,e,t),ix.toBytes(!0)}function La(r,e){return e=Object.assign({},IV,e),Zg(r,ax,e)}var OV={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Jg=class{constructor(e,t={}){this._pos=0,this.data=e,this.options=t}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let e=this.data[this._pos],t=ai[e];if(t===void 0){let n=oe[e];if(!n)throw new Error(`${ge} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);let o=e&31;t=n(this.data,this._pos,o,this.options)}return this._pos+=t.encodedLength,t}},Ep=Symbol.for("DONE"),e2=Symbol.for("BREAK");function DV(r,e,t){let n=[];for(let o=0;o<r.value;o++){let i=If(e,t);if(i===e2){if(r.value===1/0)break;throw new Error(`${ge} got unexpected break to lengthed array`)}if(i===Ep)throw new Error(`${ge} found array but not enough entries (got ${o}, expected ${r.value})`);n[o]=i}return n}function NV(r,e,t){let n=t.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let s=0;s<r.value;s++){let a=If(e,t);if(a===e2){if(r.value===1/0)break;throw new Error(`${ge} got unexpected break to lengthed map`)}if(a===Ep)throw new Error(`${ge} found map but not enough entries (got ${s} [no key], expected ${r.value})`);if(n!==!0&&typeof a!="string")throw new Error(`${ge} non-string keys not supported (got ${typeof a})`);if(t.rejectDuplicateMapKeys===!0&&(n&&i.has(a)||!n&&a in o))throw new Error(`${ge} found repeat map key "${a}"`);let c=If(e,t);if(c===Ep)throw new Error(`${ge} 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 If(r,e){if(r.done())return Ep;let t=r.next();if(t.type===A.break)return e2;if(t.type.terminal)return t.value;if(t.type===A.array)return DV(t,r,e);if(t.type===A.map)return NV(t,r,e);if(t.type===A.tag){if(e.tags&&typeof e.tags[t.value]=="function"){let n=If(r,e);return e.tags[t.value](n)}throw new Error(`${ge} tag not supported (${t.value})`)}throw new Error("unsupported")}function cx(r,e){if(!(r instanceof Uint8Array))throw new Error(`${ge} data to decode must be a Uint8Array`);e=Object.assign({},OV,e);let t=e.tokenizer||new Jg(r,e),n=If(t,e);if(n===Ep)throw new Error(`${ge} did not find any content to decode`);if(n===e2)throw new Error(`${ge} got unexpected break`);return[n,r.subarray(t.pos())]}function ro(r,e){let[t,n]=cx(r,e);if(n.length>0)throw new Error(`${ge} too many terminals, data makes no sense`);return t}var t2=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},kf=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},r2=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"},Sp=class extends Error{name="UnexpectedEOFError";code="ERR_UNEXPECTED_EOF"};function n2(r){return r[Symbol.asyncIterator]!=null}function HC(r,e){if(r.byteLength>e)throw new kf("Message length too long")}var i2=r=>{let e=Fe(r),t=Nt(e);return Wr(r,t),i2.bytes=e,t};i2.bytes=0;function Ps(r,e){e=e??{};let t=e.lengthEncoder??i2,n=e?.maxDataLength??4194304;function*o(i){HC(i,n);let s=t(i.byteLength);s instanceof Uint8Array?yield s:yield*s,i instanceof Uint8Array?yield i:yield*i}return n2(r)?(async function*(){for await(let i of r)yield*o(i)})():(function*(){for(let i of r)yield*o(i)})()}Ps.single=(r,e)=>{e=e??{};let t=e.lengthEncoder??i2,n=e?.maxDataLength??4194304;return HC(r,n),new se(t(r.byteLength),r)};var al;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(al||(al={}));var ux=r=>{let e=Yn(r);return ux.bytes=Fe(e),e};ux.bytes=0;function cl(r,e){let t=new se,n=al.LENGTH,o=-1,i=e?.lengthDecoder??ux,s=e?.maxLengthLength??8,a=e?.maxDataLength??4194304;function*c(){for(;t.byteLength>0;){if(n===al.LENGTH)try{if(o=i(t),o<0)throw new t2("Invalid message length");if(o>a)throw new kf("Message length too long");let l=i.bytes;t.consume(l),e?.onLength!=null&&e.onLength(o),n=al.DATA}catch(l){if(l instanceof RangeError){if(t.byteLength>s)throw new r2("Message length length too long");break}throw l}if(n===al.DATA){if(t.byteLength<o)break;let l=t.sublist(0,o);t.consume(o),e?.onData!=null&&e.onData(l),yield l,n=al.LENGTH}}}return n2(r)?(async function*(){for await(let l of r)t.append(l),yield*c();if(t.byteLength>0)throw new Sp("Unexpected end of input")})():(function*(){for(let l of r)t.append(l),yield*c();if(t.byteLength>0)throw new Sp("Unexpected end of input")})()}cl.fromReader=(r,e)=>{let t=1,n=(async function*(){for(;;)try{let{done:i,value:s}=await r.next(t);if(i===!0)return;s!=null&&(yield s)}catch(i){if(i.code==="ERR_UNDER_READ")return{done:!0,value:null};throw i}finally{t=1}})();return cl(n,{...e??{},onLength:i=>{t=i}})};function BV(r,e){if(typeof r=="string")return MV(r);if(typeof r=="number")return $V(r,e);throw Error(`Value provided to ms() must be a string or number. value=${JSON.stringify(r)}`)}var s2=BV;function MV(r){if(typeof r!="string"||r.length===0||r.length>100)throw Error(`Value provided to ms.parse() must be a string with length between 1 and 99. value=${JSON.stringify(r)}`);let e=/^(?<value>-?\d*\.?\d+) *(?<unit>milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|months?|mo|years?|yrs?|y)?$/i.exec(r);if(!e?.groups)return NaN;let{value:t,unit:n="ms"}=e.groups,o=parseFloat(t),i=n.toLowerCase();switch(i){case"years":case"year":case"yrs":case"yr":case"y":return o*315576e5;case"months":case"month":case"mo":return o*26298e5;case"weeks":case"week":case"w":return o*6048e5;case"days":case"day":case"d":return o*864e5;case"hours":case"hour":case"hrs":case"hr":case"h":return o*36e5;case"minutes":case"minute":case"mins":case"min":case"m":return o*6e4;case"seconds":case"second":case"secs":case"sec":case"s":return o*1e3;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return o;default:throw Error(`Unknown unit "${i}" provided to ms.parse(). value=${JSON.stringify(r)}`)}}function UV(r){let e=Math.abs(r);return e>=315576e5?`${Math.round(r/315576e5)}y`:e>=26298e5?`${Math.round(r/26298e5)}mo`:e>=6048e5?`${Math.round(r/6048e5)}w`:e>=864e5?`${Math.round(r/864e5)}d`:e>=36e5?`${Math.round(r/36e5)}h`:e>=6e4?`${Math.round(r/6e4)}m`:e>=1e3?`${Math.round(r/1e3)}s`:`${r}ms`}function FV(r){let e=Math.abs(r);return e>=315576e5?ll(r,e,315576e5,"year"):e>=26298e5?ll(r,e,26298e5,"month"):e>=6048e5?ll(r,e,6048e5,"week"):e>=864e5?ll(r,e,864e5,"day"):e>=36e5?ll(r,e,36e5,"hour"):e>=6e4?ll(r,e,6e4,"minute"):e>=1e3?ll(r,e,1e3,"second"):`${r} ms`}function $V(r,e){if(typeof r!="number"||!Number.isFinite(r))throw Error("Value provided to ms.format() must be of type number.");return e?.long?FV(r):UV(r)}function ll(r,e,t,n){let o=e>=t*1.5;return`${Math.round(r/t)} ${n}${o?"s":""}`}function fx(r){t.debug=t,t.default=t,t.coerce=c,t.disable=i,t.enable=o,t.enabled=s,t.humanize=s2,t.destroy=l,Object.keys(r).forEach(f=>{t[f]=r[f]}),t.names=[],t.skips=[],t.formatters={};function e(f){let u=0;for(let h=0;h<f.length;h++)u=(u<<5)-u+f.charCodeAt(h),u|=0;return t.colors[Math.abs(u)%t.colors.length]}t.selectColor=e;function t(f,u){let h,d=null,m,y;function w(...x){if(!w.enabled)return;let E=w,v=Number(new Date),I=v-(h||v);E.diff=I,E.prev=h,E.curr=v,h=v,x[0]=t.coerce(x[0]),typeof x[0]!="string"&&x.unshift("%O");let F=0;x[0]=x[0].replace(/%([a-zA-Z%])/g,(M,T)=>{if(M==="%%")return"%";F++;let k=t.formatters[T];if(typeof k=="function"){let z=x[F];M=k.call(E,z),x.splice(F,1),F--}return M}),t.formatArgs.call(E,x),u?.onLog!=null&&u.onLog(...x),(E.log||t.log).apply(E,x)}return w.namespace=f,w.useColors=t.useColors(),w.color=t.selectColor(f),w.extend=n,w.destroy=t.destroy,Object.defineProperty(w,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(m!==t.namespaces&&(m=t.namespaces,y=t.enabled(f)),y),set:x=>{d=x}}),typeof t.init=="function"&&t.init(w),w}function n(f,u){let h=t(this.namespace+(typeof u>"u"?":":u)+f);return h.log=this.log,h}function o(f){t.save(f),t.namespaces=f,t.names=[],t.skips=[];let u,h=(typeof f=="string"?f:"").split(/[\s,]+/),d=h.length;for(u=0;u<d;u++)h[u]&&(f=h[u].replace(/\*/g,".*?"),f[0]==="-"?t.skips.push(new RegExp("^"+f.substr(1)+"$")):t.names.push(new RegExp("^"+f+"$")))}function i(){let f=[...t.names.map(a),...t.skips.map(a).map(u=>"-"+u)].join(",");return t.enable(""),f}function s(f){if(f[f.length-1]==="*")return!0;let u,h;for(u=0,h=t.skips.length;u<h;u++)if(t.skips[u].test(f))return!1;for(u=0,h=t.names.length;u<h;u++)if(t.names[u].test(f))return!0;return!1}function a(f){return f.toString().substring(2,f.toString().length-2).replace(/\.\*\?$/,"*")}function c(f){return f instanceof Error?f.stack??f.message:f}function l(){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 t.setupFormatters(t.formatters),t.enable(t.load()),t}var a2=WV(),HV=["#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 KV(){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 VV(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+s2(this.diff),!this.useColors)return;let e="color: "+this.color;r.splice(1,0,e,"color: inherit");let t=0,n=0;r[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(t++,o==="%c"&&(n=t))}),r.splice(n,0,e)}var qV=console.debug??console.log??(()=>{});function zV(r){try{r?a2?.setItem("debug",r):a2?.removeItem("debug")}catch{}}function jV(){let r;try{r=a2?.getItem("debug")}catch{}return!r&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(r=globalThis.process.env.DEBUG),r}function WV(){try{return localStorage}catch{}}function GV(r){r.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}}var VC=fx({formatArgs:VV,save:zV,load:jV,useColors:KV,setupFormatters:GV,colors:HV,storage:a2,log:qV});var An=VC;An.formatters.b=r=>r==null?"undefined":Qe.baseEncode(r);An.formatters.t=r=>r==null?"undefined":gr.baseEncode(r);An.formatters.m=r=>r==null?"undefined":Zt.baseEncode(r);An.formatters.p=r=>r==null?"undefined":r.toString();An.formatters.c=r=>r==null?"undefined":r.toString();An.formatters.k=r=>r==null?"undefined":r.toString();An.formatters.a=r=>r==null?"undefined":r.toString();function qC(r,e=""){let t=zC(r.message),n=zC(r.stack);return t!=null&&n!=null?n.includes(t)?`${n.split(`
3
+ `,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return y;function y(T,k,z){var W=this;if(!(W instanceof y))return new y(T,k,z);W.time=+T||0,W.nano=+k||0,W.year=+z||0,w(W)}function w(T){var k,z,W,$=T.year,S=T.time,C=T.nano,_=((C<0||a<=C)&&(C-=(z=Math.floor(C/a))*a,S+=z,z=1),$%e);return(S<-i||i<S||_)&&((k=l(S/o))&&($+=k*e,S-=k*o),(W=x(S)).setUTCFullYear(_+W.getUTCFullYear()),W=(S=+W)+(k=l(($-=_)/e))*o,k&&-i<=W&&W<=i&&($-=k*e,S=W),z=1),z&&(T.year=$,T.time=S,T.nano=C),T}function x(T){var k=new Date(0);return k.setTime(T),k}function E($,W){$=+$||0;var z=l((W=(W|0)*s)/n)+l($/n),W=W%n+$%n,$=l(W/n);return $&&(z+=$,W-=$*n),new y(1e3*W,0,z*e)}function v(T,k,z,W,$,S){return function(_,B){var G=w(this);_=_||new Array(8),F(_,B|=0);var U=Math.floor(G.time/1e3),G=G.year*(t*r/e),X=l(G/s)+l(U/s),G=G%s+U%s,U=Math.floor(G/s);return U&&(X+=U,G-=U*s),C(_,B+$,X),C(_,B+S,G),_};function C(_,B,X){_[B+T]=X>>24&255,_[B+k]=X>>16&255,_[B+z]=X>>8&255,_[B+W]=255&X}}function I(T,k,z,W,$,S){return function(_,B){F(_,B|=0);var X=C(_,B+$);return E(C(_,B+S),X)};function C(_,B){return 16777216*_[B+T]+(_[B+k]<<16|_[B+z]<<8|_[B+W])}}function F(T,k){if(T=T&&T.length,T==null)throw new TypeError("Invalid Buffer");if(T<k+8)throw new RangeError("Out of range")}function V(T){return(9<T?"":"0")+(0|T)}function M(T,k){return(c+(0|T)).substr(-k)}})()});var dP=Rt((d8e,fP)=>{"use strict";function uW(r){return r>=55296&&r<=56319}function fW(r){return r>=56320&&r<=57343}fP.exports=function(e,t,n){if(typeof t!="string")throw new Error("Input must be string");for(var o=t.length,i=0,s,a,c=0;c<o;c+=1){if(s=t.charCodeAt(c),a=t[c],uW(s)&&fW(t.charCodeAt(c+1))&&(c+=1,a+=t[c]),i+=e(a),i===n)return t.slice(0,c+1);if(i>n)return t.slice(0,c-a.length+1)}return t}});var pP=Rt((h8e,hP)=>{"use strict";function dW(r){return r>=55296&&r<=56319}function hW(r){return r>=56320&&r<=57343}hP.exports=function(e){if(typeof e!="string")throw new Error("Input must be string");for(var t=e.length,n=0,o=null,i=null,s=0;s<t;s++)o=e.charCodeAt(s),hW(o)?i!=null&&dW(i)?n+=1:n+=3:o<=127?n+=1:o>=128&&o<=2047?n+=2:o>=2048&&o<=65535&&(n+=3),i=o;return n}});var gP=Rt((p8e,mP)=>{"use strict";var pW=dP(),mW=pP();mP.exports=pW.bind(null,mW)});var xP=Rt((m8e,wP)=>{"use strict";var gW=gP(),yW=/[\/\?<>\\:\*\|"]/g,wW=/[\x00-\x1f\x80-\x9f]/g,xW=/^\.+$/,bW=/^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\..*)?$/i,vW=/[\. ]+$/;function yP(r,e){if(typeof r!="string")throw new Error("Input must be string");var t=r.replace(yW,e).replace(wW,e).replace(xW,e).replace(bW,e).replace(vW,e);return gW(t,255)}wP.exports=function(r,e){var t=e&&e.replacement||"",n=yP(r,t);return t===""?n:yP(n,"")}});var Ks=Rt(Qf=>{"use strict";var SW="[object ArrayBuffer]",Hs=class r{static isArrayBuffer(e){return Object.prototype.toString.call(e)===SW}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,t){if(e.constructor===t)return e;if(this.isArrayBuffer(e))return new t(e);if(this.isArrayBufferView(e))return new t(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(e,t){let n=r.toUint8Array(e),o=r.toUint8Array(t);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(...e){let t;Array.isArray(e[0])&&!(e[1]instanceof Function)||Array.isArray(e[0])&&e[1]instanceof Function?t=e[0]:e[e.length-1]instanceof Function?t=e.slice(0,e.length-1):t=e;let n=0;for(let s of t)n+=s.byteLength;let o=new Uint8Array(n),i=0;for(let s of t){let a=this.toUint8Array(s);o.set(a,i),i+=a.length}return e[e.length-1]instanceof Function?this.toView(o,e[e.length-1]):o.buffer}},z9="string",AW=/^[0-9a-f\s]+$/i,_W=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,TW=/^[a-zA-Z0-9-_]+$/,C3=class{static fromString(e){let t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);for(let o=0;o<t.length;o++)n[o]=t.charCodeAt(o);return n.buffer}static toString(e){let t=Hs.toUint8Array(e),n="";for(let i=0;i<t.length;i++)n+=String.fromCharCode(t[i]);return decodeURIComponent(escape(n))}},Oo=class{static toString(e,t=!1){let n=Hs.toArrayBuffer(e),o=new DataView(n),i="";for(let s=0;s<n.byteLength;s+=2){let a=o.getUint16(s,t);i+=String.fromCharCode(a)}return i}static fromString(e,t=!1){let n=new ArrayBuffer(e.length*2),o=new DataView(n);for(let i=0;i<e.length;i++)o.setUint16(i*2,e.charCodeAt(i),t);return n}},I3=class r{static isHex(e){return typeof e===z9&&AW.test(e)}static isBase64(e){return typeof e===z9&&_W.test(e)}static isBase64Url(e){return typeof e===z9&&TW.test(e)}static ToString(e,t="utf8"){let n=Hs.toUint8Array(e);switch(t.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 Oo.toString(n,!0);case"utf16":case"utf16be":return Oo.toString(n);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromString(e,t="utf8"){if(!e)return new ArrayBuffer(0);switch(t.toLowerCase()){case"utf8":return this.FromUtf8String(e);case"binary":return this.FromBinary(e);case"hex":return this.FromHex(e);case"base64":return this.FromBase64(e);case"base64url":return this.FromBase64Url(e);case"utf16le":return Oo.fromString(e,!0);case"utf16":case"utf16be":return Oo.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){let t=Hs.toUint8Array(e);if(typeof btoa<"u"){let n=this.ToString(t,"binary");return btoa(n)}else return Buffer.from(t).toString("base64")}static FromBase64(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!r.isBase64(t))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob<"u"?this.FromBinary(atob(t)):new Uint8Array(Buffer.from(t,"base64")).buffer}static FromBase64Url(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!r.isBase64Url(t))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(t.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(e,t=r.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.FromBinary(e);case"utf8":return C3.fromString(e);case"utf16":case"utf16be":return Oo.fromString(e);case"utf16le":case"usc2":return Oo.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToUtf8String(e,t=r.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.ToBinary(e);case"utf8":return C3.toString(e);case"utf16":case"utf16be":return Oo.toString(e);case"utf16le":case"usc2":return Oo.toString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromBinary(e){let t=e.length,n=new Uint8Array(t);for(let o=0;o<t;o++)n[o]=e.charCodeAt(o);return n.buffer}static ToBinary(e){let t=Hs.toUint8Array(e),n="";for(let o=0;o<t.length;o++)n+=String.fromCharCode(t[o]);return n}static ToHex(e){let t=Hs.toUint8Array(e),n="",o=t.length;for(let i=0;i<o;i++){let s=t[i];s<16&&(n+="0"),n+=s.toString(16)}return n}static FromHex(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!r.isHex(t))throw new TypeError("Argument 'hexString' is not HEX encoded");t.length%2&&(t=`0${t}`);let n=new Uint8Array(t.length/2);for(let o=0;o<t.length;o=o+2){let i=t.slice(o,o+2);n[o/2]=parseInt(i,16)}return n.buffer}static ToUtf16String(e,t=!1){return Oo.toString(e,t)}static FromUtf16String(e,t=!1){return Oo.fromString(e,t)}static Base64Padding(e){let t=4-e.length%4;if(t<4)for(let n=0;n<t;n++)e+="=";return e}static formatString(e){return e?.replace(/[\n\r\t ]/g,"")||""}};I3.DEFAULT_UTF8_ENCODING="utf8";function CW(r,...e){let t=arguments[0];for(let n=1;n<arguments.length;n++){let o=arguments[n];for(let i in o)t[i]=o[i]}return t}function IW(...r){let e=r.map(o=>o.byteLength).reduce((o,i)=>o+i),t=new Uint8Array(e),n=0;return r.map(o=>new Uint8Array(o)).forEach(o=>{for(let i of o)t[n++]=i}),t.buffer}function kW(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;let t=new Uint8Array(r),n=new Uint8Array(e);for(let o=0;o<r.byteLength;o++)if(t[o]!==n[o])return!1;return!0}Qf.BufferSourceConverter=Hs;Qf.Convert=I3;Qf.assign=CW;Qf.combine=IW;Qf.isEqual=kW});var LO=Rt(Gi=>{"use strict";Object.defineProperty(Gi,"__esModule",{value:!0});Gi.parseCookie=DO;Gi.parse=DO;Gi.stringifyCookie=sX;Gi.stringifySetCookie=L4;Gi.serialize=L4;Gi.parseSetCookie=aX;Gi.stringifySetCookie=L4;Gi.serialize=L4;var RO=/^[\u0021-\u003A\u003C\u003E-\u007E]+$/,OO=/^[\u0021-\u003A\u003C-\u007E]*$/,tX=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,rX=/^[\u0020-\u003A\u003D-\u007E]*$/,nX=/^-?\d+$/,oX=Object.prototype.toString,iX=(()=>{let r=function(){};return r.prototype=Object.create(null),r})();function DO(r,e){let t=new iX,n=r.length;if(n<2)return t;let o=e?.decode||NO,i=0;do{let s=$b(r,i,n);if(s===-1)break;let a=Fb(r,i,n);if(s>a){i=r.lastIndexOf(";",s-1)+1;continue}let c=Wa(r,i,s);t[c]===void 0&&(t[c]=o(Wa(r,s+1,a))),i=a+1}while(i<n);return t}function sX(r,e){let t=e?.encode||encodeURIComponent,n=[];for(let o of Object.keys(r)){let i=r[o];if(i===void 0)continue;if(!RO.test(o))throw new TypeError(`cookie name is invalid: ${o}`);let s=t(i);if(!OO.test(s))throw new TypeError(`cookie val is invalid: ${i}`);n.push(`${o}=${s}`)}return n.join("; ")}function L4(r,e,t){let n=typeof r=="object"?r:{...t,name:r,value:String(e)},i=(typeof e=="object"?e:t)?.encode||encodeURIComponent;if(!RO.test(n.name))throw new TypeError(`argument name is invalid: ${n.name}`);let s=n.value?i(n.value):"";if(!OO.test(s))throw new TypeError(`argument val is invalid: ${n.value}`);let a=n.name+"="+s;if(n.maxAge!==void 0){if(!Number.isInteger(n.maxAge))throw new TypeError(`option maxAge is invalid: ${n.maxAge}`);a+="; Max-Age="+n.maxAge}if(n.domain){if(!tX.test(n.domain))throw new TypeError(`option domain is invalid: ${n.domain}`);a+="; Domain="+n.domain}if(n.path){if(!rX.test(n.path))throw new TypeError(`option path is invalid: ${n.path}`);a+="; Path="+n.path}if(n.expires){if(!cX(n.expires)||!Number.isFinite(n.expires.valueOf()))throw new TypeError(`option expires is invalid: ${n.expires}`);a+="; Expires="+n.expires.toUTCString()}if(n.httpOnly&&(a+="; HttpOnly"),n.secure&&(a+="; Secure"),n.partitioned&&(a+="; Partitioned"),n.priority)switch(typeof n.priority=="string"?n.priority.toLowerCase():void 0){case"low":a+="; Priority=Low";break;case"medium":a+="; Priority=Medium";break;case"high":a+="; Priority=High";break;default:throw new TypeError(`option priority is invalid: ${n.priority}`)}if(n.sameSite)switch(typeof n.sameSite=="string"?n.sameSite.toLowerCase():n.sameSite){case!0:case"strict":a+="; SameSite=Strict";break;case"lax":a+="; SameSite=Lax";break;case"none":a+="; SameSite=None";break;default:throw new TypeError(`option sameSite is invalid: ${n.sameSite}`)}return a}function aX(r,e){let t=e?.decode||NO,n=r.length,o=Fb(r,0,n),i=$b(r,0,o),s=i===-1?{name:"",value:t(Wa(r,0,o))}:{name:Wa(r,0,i),value:t(Wa(r,i+1,o))},a=o+1;for(;a<n;){let c=Fb(r,a,n),l=$b(r,a,c),f=l===-1?Wa(r,a,c):Wa(r,a,l),u=l===-1?void 0:Wa(r,l+1,c);switch(f.toLowerCase()){case"httponly":s.httpOnly=!0;break;case"secure":s.secure=!0;break;case"partitioned":s.partitioned=!0;break;case"domain":s.domain=u;break;case"path":s.path=u;break;case"max-age":u&&nX.test(u)&&(s.maxAge=Number(u));break;case"expires":if(!u)break;let h=new Date(u);Number.isFinite(h.valueOf())&&(s.expires=h);break;case"priority":if(!u)break;let d=u.toLowerCase();(d==="low"||d==="medium"||d==="high")&&(s.priority=d);break;case"samesite":if(!u)break;let m=u.toLowerCase();(m==="lax"||m==="strict"||m==="none")&&(s.sameSite=m);break}a=c+1}return s}function Fb(r,e,t){let n=r.indexOf(";",e);return n===-1?t:n}function $b(r,e,t){let n=r.indexOf("=",e);return n<t?n:-1}function Wa(r,e,t){let n=e,o=t;do{let i=r.charCodeAt(n);if(i!==32&&i!==9)break}while(++n<o);for(;o>n;){let i=r.charCodeAt(o-1);if(i!==32&&i!==9)break;o--}return r.slice(n,o)}function NO(r){if(r.indexOf("%")===-1)return r;try{return decodeURIComponent(r)}catch{return r}}function cX(r){return oX.call(r)==="[object Date]"}});var sN=Rt(()=>{var iN;(function(r){(function(e){var t=typeof globalThis=="object"||typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof this=="object"?this:a(),n=o(r);typeof t.Reflect<"u"&&(n=o(t.Reflect,n)),e(n,t),typeof t.Reflect>"u"&&(t.Reflect=r);function o(c,l){return function(f,u){Object.defineProperty(c,f,{configurable:!0,writable:!0,value:u}),l&&l(f,u)}}function i(){try{return Function("return this;")()}catch{}}function s(){try{return(0,eval)("(function() { return this; })()")}catch{}}function a(){return i()||s()}})(function(e,t){var n=Object.prototype.hasOwnProperty,o=typeof Symbol=="function",i=o&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",s=o&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",a=typeof Object.create=="function",c={__proto__:[]}instanceof Array,l=!a&&!c,f={create:a?function(){return z8(Object.create(null))}:c?function(){return z8({__proto__:null})}:function(){return z8({})},has:l?function(P,L){return n.call(P,L)}:function(P,L){return L in P},get:l?function(P,L){return n.call(P,L)?P[L]:void 0}:function(P,L){return P[L]}},u=Object.getPrototypeOf(Function),h=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:fF(),d=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:dF(),m=typeof WeakMap=="function"?WeakMap:hF(),y=o?Symbol.for("@reflect-metadata:registry"):void 0,w=cF(),x=lF(w);function E(P,L,q,te){if(K(q)){if(!ls(P))throw new TypeError;if(!fa(L))throw new TypeError;return $(P,L)}else{if(!ls(P))throw new TypeError;if(!he(L))throw new TypeError;if(!he(te)&&!K(te)&&!De(te))throw new TypeError;return De(te)&&(te=void 0),q=ct(q),S(P,L,q,te)}}e("decorate",E);function v(P,L){function q(te,Se){if(!he(te))throw new TypeError;if(!K(Se)&&!U0(Se))throw new TypeError;G(P,L,te,Se)}return q}e("metadata",v);function I(P,L,q,te){if(!he(q))throw new TypeError;return K(te)||(te=ct(te)),G(P,L,q,te)}e("defineMetadata",I);function F(P,L,q){if(!he(L))throw new TypeError;return K(q)||(q=ct(q)),C(P,L,q)}e("hasMetadata",F);function V(P,L,q){if(!he(L))throw new TypeError;return K(q)||(q=ct(q)),_(P,L,q)}e("hasOwnMetadata",V);function M(P,L,q){if(!he(L))throw new TypeError;return K(q)||(q=ct(q)),B(P,L,q)}e("getMetadata",M);function T(P,L,q){if(!he(L))throw new TypeError;return K(q)||(q=ct(q)),X(P,L,q)}e("getOwnMetadata",T);function k(P,L){if(!he(P))throw new TypeError;return K(L)||(L=ct(L)),U(P,L)}e("getMetadataKeys",k);function z(P,L){if(!he(P))throw new TypeError;return K(L)||(L=ct(L)),Q(P,L)}e("getOwnMetadataKeys",z);function W(P,L,q){if(!he(L))throw new TypeError;if(K(q)||(q=ct(q)),!he(L))throw new TypeError;K(q)||(q=ct(q));var te=vh(L,q,!1);return K(te)?!1:te.OrdinaryDeleteMetadata(P,L,q)}e("deleteMetadata",W);function $(P,L){for(var q=P.length-1;q>=0;--q){var te=P[q],Se=te(L);if(!K(Se)&&!De(Se)){if(!fa(Se))throw new TypeError;L=Se}}return L}function S(P,L,q,te){for(var Se=P.length-1;Se>=0;--Se){var zt=P[Se],ar=zt(L,q,te);if(!K(ar)&&!De(ar)){if(!he(ar))throw new TypeError;te=ar}}return te}function C(P,L,q){var te=_(P,L,q);if(te)return!0;var Se=q8(L);return De(Se)?!1:C(P,Se,q)}function _(P,L,q){var te=vh(L,q,!1);return K(te)?!1:Pt(te.OrdinaryHasOwnMetadata(P,L,q))}function B(P,L,q){var te=_(P,L,q);if(te)return X(P,L,q);var Se=q8(L);if(!De(Se))return B(P,Se,q)}function X(P,L,q){var te=vh(L,q,!1);if(!K(te))return te.OrdinaryGetOwnMetadata(P,L,q)}function G(P,L,q,te){var Se=vh(q,te,!0);Se.OrdinaryDefineOwnMetadata(P,L,q,te)}function U(P,L){var q=Q(P,L),te=q8(P);if(te===null)return q;var Se=U(te,L);if(Se.length<=0)return q;if(q.length<=0)return Se;for(var zt=new d,ar=[],Ue=0,ae=q;Ue<ae.length;Ue++){var fe=ae[Ue],pe=zt.has(fe);pe||(zt.add(fe),ar.push(fe))}for(var ye=0,$e=Se;ye<$e.length;ye++){var fe=$e[ye],pe=zt.has(fe);pe||(zt.add(fe),ar.push(fe))}return ar}function Q(P,L){var q=vh(P,L,!1);return q?q.OrdinaryOwnMetadataKeys(P,L):[]}function ne(P){if(P===null)return 1;switch(typeof P){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return P===null?1:6;default:return 6}}function K(P){return P===void 0}function De(P){return P===null}function Me(P){return typeof P=="symbol"}function he(P){return typeof P=="object"?P!==null:typeof P=="function"}function Ke(P,L){switch(ne(P)){case 0:return P;case 1:return P;case 2:return P;case 3:return P;case 4:return P;case 5:return P}var q=L===3?"string":L===5?"number":"default",te=bh(P,i);if(te!==void 0){var Se=te.call(P,q);if(he(Se))throw new TypeError;return Se}return at(P,q==="default"?"number":q)}function at(P,L){if(L==="string"){var q=P.toString;if(Go(q)){var te=q.call(P);if(!he(te))return te}var Se=P.valueOf;if(Go(Se)){var te=Se.call(P);if(!he(te))return te}}else{var Se=P.valueOf;if(Go(Se)){var te=Se.call(P);if(!he(te))return te}var zt=P.toString;if(Go(zt)){var te=zt.call(P);if(!he(te))return te}}throw new TypeError}function Pt(P){return!!P}function We(P){return""+P}function ct(P){var L=Ke(P,3);return Me(L)?L:We(L)}function ls(P){return Array.isArray?Array.isArray(P):P instanceof Object?P instanceof Array:Object.prototype.toString.call(P)==="[object Array]"}function Go(P){return typeof P=="function"}function fa(P){return typeof P=="function"}function U0(P){switch(ne(P)){case 3:return!0;case 4:return!0;default:return!1}}function Bu(P,L){return P===L||P!==P&&L!==L}function bh(P,L){var q=P[L];if(q!=null){if(!Go(q))throw new TypeError;return q}}function KS(P){var L=bh(P,s);if(!Go(L))throw new TypeError;var q=L.call(P);if(!he(q))throw new TypeError;return q}function VS(P){return P.value}function qS(P){var L=P.next();return L.done?!1:L}function zS(P){var L=P.return;L&&L.call(P)}function q8(P){var L=Object.getPrototypeOf(P);if(typeof P!="function"||P===u||L!==u)return L;var q=P.prototype,te=q&&Object.getPrototypeOf(q);if(te==null||te===Object.prototype)return L;var Se=te.constructor;return typeof Se!="function"||Se===P?L:Se}function aF(){var P;!K(y)&&typeof t.Reflect<"u"&&!(y in t.Reflect)&&typeof t.Reflect.defineMetadata=="function"&&(P=uF(t.Reflect));var L,q,te,Se=new m,zt={registerProvider:ar,getProvider:ae,setProvider:pe};return zt;function ar(ye){if(!Object.isExtensible(zt))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case P===ye:break;case K(L):L=ye;break;case L===ye:break;case K(q):q=ye;break;case q===ye:break;default:te===void 0&&(te=new d),te.add(ye);break}}function Ue(ye,$e){if(!K(L)){if(L.isProviderFor(ye,$e))return L;if(!K(q)){if(q.isProviderFor(ye,$e))return L;if(!K(te))for(var St=KS(te);;){var jt=qS(St);if(!jt)return;var Xo=VS(jt);if(Xo.isProviderFor(ye,$e))return zS(St),Xo}}}if(!K(P)&&P.isProviderFor(ye,$e))return P}function ae(ye,$e){var St=Se.get(ye),jt;return K(St)||(jt=St.get($e)),K(jt)&&(jt=Ue(ye,$e),K(jt)||(K(St)&&(St=new h,Se.set(ye,St)),St.set($e,jt))),jt}function fe(ye){if(K(ye))throw new TypeError;return L===ye||q===ye||!K(te)&&te.has(ye)}function pe(ye,$e,St){if(!fe(St))throw new Error("Metadata provider not registered.");var jt=ae(ye,$e);if(jt!==St){if(!K(jt))return!1;var Xo=Se.get(ye);K(Xo)&&(Xo=new h,Se.set(ye,Xo)),Xo.set($e,St)}return!0}}function cF(){var P;return!K(y)&&he(t.Reflect)&&Object.isExtensible(t.Reflect)&&(P=t.Reflect[y]),K(P)&&(P=aF()),!K(y)&&he(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,y,{enumerable:!1,configurable:!1,writable:!1,value:P}),P}function lF(P){var L=new m,q={isProviderFor:function(fe,pe){var ye=L.get(fe);return K(ye)?!1:ye.has(pe)},OrdinaryDefineOwnMetadata:ar,OrdinaryHasOwnMetadata:Se,OrdinaryGetOwnMetadata:zt,OrdinaryOwnMetadataKeys:Ue,OrdinaryDeleteMetadata:ae};return w.registerProvider(q),q;function te(fe,pe,ye){var $e=L.get(fe),St=!1;if(K($e)){if(!ye)return;$e=new h,L.set(fe,$e),St=!0}var jt=$e.get(pe);if(K(jt)){if(!ye)return;if(jt=new h,$e.set(pe,jt),!P.setProvider(fe,pe,q))throw $e.delete(pe),St&&L.delete(fe),new Error("Wrong provider for target.")}return jt}function Se(fe,pe,ye){var $e=te(pe,ye,!1);return K($e)?!1:Pt($e.has(fe))}function zt(fe,pe,ye){var $e=te(pe,ye,!1);if(!K($e))return $e.get(fe)}function ar(fe,pe,ye,$e){var St=te(ye,$e,!0);St.set(fe,pe)}function Ue(fe,pe){var ye=[],$e=te(fe,pe,!1);if(K($e))return ye;for(var St=$e.keys(),jt=KS(St),Xo=0;;){var jS=qS(jt);if(!jS)return ye.length=Xo,ye;var pF=VS(jS);try{ye[Xo]=pF}catch(mF){try{zS(jt)}finally{throw mF}}Xo++}}function ae(fe,pe,ye){var $e=te(pe,ye,!1);if(K($e)||!$e.delete(fe))return!1;if($e.size===0){var St=L.get(pe);K(St)||(St.delete(ye),St.size===0&&L.delete(St))}return!0}}function uF(P){var L=P.defineMetadata,q=P.hasOwnMetadata,te=P.getOwnMetadata,Se=P.getOwnMetadataKeys,zt=P.deleteMetadata,ar=new m,Ue={isProviderFor:function(ae,fe){var pe=ar.get(ae);return!K(pe)&&pe.has(fe)?!0:Se(ae,fe).length?(K(pe)&&(pe=new d,ar.set(ae,pe)),pe.add(fe),!0):!1},OrdinaryDefineOwnMetadata:L,OrdinaryHasOwnMetadata:q,OrdinaryGetOwnMetadata:te,OrdinaryOwnMetadataKeys:Se,OrdinaryDeleteMetadata:zt};return Ue}function vh(P,L,q){var te=w.getProvider(P,L);if(!K(te))return te;if(q){if(w.setProvider(P,L,x))return x;throw new Error("Illegal state.")}}function fF(){var P={},L=[],q=(function(){function Ue(ae,fe,pe){this._index=0,this._keys=ae,this._values=fe,this._selector=pe}return Ue.prototype["@@iterator"]=function(){return this},Ue.prototype[s]=function(){return this},Ue.prototype.next=function(){var ae=this._index;if(ae>=0&&ae<this._keys.length){var fe=this._selector(this._keys[ae],this._values[ae]);return ae+1>=this._keys.length?(this._index=-1,this._keys=L,this._values=L):this._index++,{value:fe,done:!1}}return{value:void 0,done:!0}},Ue.prototype.throw=function(ae){throw this._index>=0&&(this._index=-1,this._keys=L,this._values=L),ae},Ue.prototype.return=function(ae){return this._index>=0&&(this._index=-1,this._keys=L,this._values=L),{value:ae,done:!0}},Ue})(),te=(function(){function Ue(){this._keys=[],this._values=[],this._cacheKey=P,this._cacheIndex=-2}return Object.defineProperty(Ue.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),Ue.prototype.has=function(ae){return this._find(ae,!1)>=0},Ue.prototype.get=function(ae){var fe=this._find(ae,!1);return fe>=0?this._values[fe]:void 0},Ue.prototype.set=function(ae,fe){var pe=this._find(ae,!0);return this._values[pe]=fe,this},Ue.prototype.delete=function(ae){var fe=this._find(ae,!1);if(fe>=0){for(var pe=this._keys.length,ye=fe+1;ye<pe;ye++)this._keys[ye-1]=this._keys[ye],this._values[ye-1]=this._values[ye];return this._keys.length--,this._values.length--,Bu(ae,this._cacheKey)&&(this._cacheKey=P,this._cacheIndex=-2),!0}return!1},Ue.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=P,this._cacheIndex=-2},Ue.prototype.keys=function(){return new q(this._keys,this._values,Se)},Ue.prototype.values=function(){return new q(this._keys,this._values,zt)},Ue.prototype.entries=function(){return new q(this._keys,this._values,ar)},Ue.prototype["@@iterator"]=function(){return this.entries()},Ue.prototype[s]=function(){return this.entries()},Ue.prototype._find=function(ae,fe){if(!Bu(this._cacheKey,ae)){this._cacheIndex=-1;for(var pe=0;pe<this._keys.length;pe++)if(Bu(this._keys[pe],ae)){this._cacheIndex=pe;break}}return this._cacheIndex<0&&fe&&(this._cacheIndex=this._keys.length,this._keys.push(ae),this._values.push(void 0)),this._cacheIndex},Ue})();return te;function Se(Ue,ae){return Ue}function zt(Ue,ae){return ae}function ar(Ue,ae){return[Ue,ae]}}function dF(){var P=(function(){function L(){this._map=new h}return Object.defineProperty(L.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),L.prototype.has=function(q){return this._map.has(q)},L.prototype.add=function(q){return this._map.set(q,q),this},L.prototype.delete=function(q){return this._map.delete(q)},L.prototype.clear=function(){this._map.clear()},L.prototype.keys=function(){return this._map.keys()},L.prototype.values=function(){return this._map.keys()},L.prototype.entries=function(){return this._map.entries()},L.prototype["@@iterator"]=function(){return this.keys()},L.prototype[s]=function(){return this.keys()},L})();return P}function hF(){var P=16,L=f.create(),q=te();return(function(){function ae(){this._key=te()}return ae.prototype.has=function(fe){var pe=Se(fe,!1);return pe!==void 0?f.has(pe,this._key):!1},ae.prototype.get=function(fe){var pe=Se(fe,!1);return pe!==void 0?f.get(pe,this._key):void 0},ae.prototype.set=function(fe,pe){var ye=Se(fe,!0);return ye[this._key]=pe,this},ae.prototype.delete=function(fe){var pe=Se(fe,!1);return pe!==void 0?delete pe[this._key]:!1},ae.prototype.clear=function(){this._key=te()},ae})();function te(){var ae;do ae="@@WeakMap@@"+Ue();while(f.has(L,ae));return L[ae]=!0,ae}function Se(ae,fe){if(!n.call(ae,q)){if(!fe)return;Object.defineProperty(ae,q,{value:f.create()})}return ae[q]}function zt(ae,fe){for(var pe=0;pe<fe;++pe)ae[pe]=Math.random()*255|0;return ae}function ar(ae){if(typeof Uint8Array=="function"){var fe=new Uint8Array(ae);return typeof crypto<"u"?crypto.getRandomValues(fe):typeof msCrypto<"u"?msCrypto.getRandomValues(fe):zt(fe,ae),fe}return zt(new Array(ae),ae)}function Ue(){var ae=ar(P);ae[6]=ae[6]&79|64,ae[8]=ae[8]&191|128;for(var fe="",pe=0;pe<P;++pe){var ye=ae[pe];(pe===4||pe===6||pe===8)&&(fe+="-"),ye<16&&(fe+="0"),fe+=ye.toString(16).toLowerCase()}return fe}}function z8(P){return P.__=void 0,delete P.__,P}})})(iN||(iN={}))});var mL=Rt((rKe,p5)=>{var XN,YN,QN,ZN,JN,eL,tL,rL,nL,h5,dE,oL,iL,zd,sL,aL,cL,lL,uL,fL,dL,hL,pL;(function(r){var e=typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof this=="object"?this:{};typeof define=="function"&&define.amd?define("tslib",["exports"],function(n){r(t(e,t(n)))}):typeof p5=="object"&&typeof p5.exports=="object"?r(t(e,t(p5.exports))):r(t(e));function t(n,o){return n!==e&&(typeof Object.create=="function"?Object.defineProperty(n,"__esModule",{value:!0}):n.__esModule=!0),function(i,s){return n[i]=o?o(i,s):s}}})(function(r){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var o in n)n.hasOwnProperty(o)&&(t[o]=n[o])};XN=function(t,n){e(t,n);function o(){this.constructor=t}t.prototype=n===null?Object.create(n):(o.prototype=n.prototype,new o)},YN=Object.assign||function(t){for(var n,o=1,i=arguments.length;o<i;o++){n=arguments[o];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},QN=function(t,n){var o={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&n.indexOf(i)<0&&(o[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(t);s<i.length;s++)n.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(o[i[s]]=t[i[s]]);return o},ZN=function(t,n,o,i){var s=arguments.length,a=s<3?n:i===null?i=Object.getOwnPropertyDescriptor(n,o):i,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,n,o,i);else for(var l=t.length-1;l>=0;l--)(c=t[l])&&(a=(s<3?c(a):s>3?c(n,o,a):c(n,o))||a);return s>3&&a&&Object.defineProperty(n,o,a),a},JN=function(t,n){return function(o,i){n(o,i,t)}},eL=function(t,n){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,n)},tL=function(t,n,o,i){function s(a){return a instanceof o?a:new o(function(c){c(a)})}return new(o||(o=Promise))(function(a,c){function l(h){try{u(i.next(h))}catch(d){c(d)}}function f(h){try{u(i.throw(h))}catch(d){c(d)}}function u(h){h.done?a(h.value):s(h.value).then(l,f)}u((i=i.apply(t,n||[])).next())})},rL=function(t,n){var o={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,s,a,c;return c={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(c[Symbol.iterator]=function(){return this}),c;function l(u){return function(h){return f([u,h])}}function f(u){if(i)throw new TypeError("Generator is already executing.");for(;o;)try{if(i=1,s&&(a=u[0]&2?s.return:u[0]?s.throw||((a=s.return)&&a.call(s),0):s.next)&&!(a=a.call(s,u[1])).done)return a;switch(s=0,a&&(u=[u[0]&2,a.value]),u[0]){case 0:case 1:a=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,s=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(a=o.trys,!(a=a.length>0&&a[a.length-1])&&(u[0]===6||u[0]===2)){o=0;continue}if(u[0]===3&&(!a||u[1]>a[0]&&u[1]<a[3])){o.label=u[1];break}if(u[0]===6&&o.label<a[1]){o.label=a[1],a=u;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(u);break}a[2]&&o.ops.pop(),o.trys.pop();continue}u=n.call(t,o)}catch(h){u=[6,h],s=0}finally{i=a=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}},pL=function(t,n,o,i){i===void 0&&(i=o),t[i]=n[o]},nL=function(t,n){for(var o in t)o!=="default"&&!n.hasOwnProperty(o)&&(n[o]=t[o])},h5=function(t){var n=typeof Symbol=="function"&&Symbol.iterator,o=n&&t[n],i=0;if(o)return o.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")},dE=function(t,n){var o=typeof Symbol=="function"&&t[Symbol.iterator];if(!o)return t;var i=o.call(t),s,a=[],c;try{for(;(n===void 0||n-- >0)&&!(s=i.next()).done;)a.push(s.value)}catch(l){c={error:l}}finally{try{s&&!s.done&&(o=i.return)&&o.call(i)}finally{if(c)throw c.error}}return a},oL=function(){for(var t=[],n=0;n<arguments.length;n++)t=t.concat(dE(arguments[n]));return t},iL=function(){for(var t=0,n=0,o=arguments.length;n<o;n++)t+=arguments[n].length;for(var i=Array(t),s=0,n=0;n<o;n++)for(var a=arguments[n],c=0,l=a.length;c<l;c++,s++)i[s]=a[c];return i},zd=function(t){return this instanceof zd?(this.v=t,this):new zd(t)},sL=function(t,n,o){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=o.apply(t,n||[]),s,a=[];return s={},c("next"),c("throw"),c("return"),s[Symbol.asyncIterator]=function(){return this},s;function c(m){i[m]&&(s[m]=function(y){return new Promise(function(w,x){a.push([m,y,w,x])>1||l(m,y)})})}function l(m,y){try{f(i[m](y))}catch(w){d(a[0][3],w)}}function f(m){m.value instanceof zd?Promise.resolve(m.value.v).then(u,h):d(a[0][2],m)}function u(m){l("next",m)}function h(m){l("throw",m)}function d(m,y){m(y),a.shift(),a.length&&l(a[0][0],a[0][1])}},aL=function(t){var n,o;return n={},i("next"),i("throw",function(s){throw s}),i("return"),n[Symbol.iterator]=function(){return this},n;function i(s,a){n[s]=t[s]?function(c){return(o=!o)?{value:zd(t[s](c)),done:s==="return"}:a?a(c):c}:a}},cL=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=t[Symbol.asyncIterator],o;return n?n.call(t):(t=typeof h5=="function"?h5(t):t[Symbol.iterator](),o={},i("next"),i("throw"),i("return"),o[Symbol.asyncIterator]=function(){return this},o);function i(a){o[a]=t[a]&&function(c){return new Promise(function(l,f){c=t[a](c),s(l,f,c.done,c.value)})}}function s(a,c,l,f){Promise.resolve(f).then(function(u){a({value:u,done:l})},c)}},lL=function(t,n){return Object.defineProperty?Object.defineProperty(t,"raw",{value:n}):t.raw=n,t},uL=function(t){if(t&&t.__esModule)return t;var n={};if(t!=null)for(var o in t)Object.hasOwnProperty.call(t,o)&&(n[o]=t[o]);return n.default=t,n},fL=function(t){return t&&t.__esModule?t:{default:t}},dL=function(t,n){if(!n.has(t))throw new TypeError("attempted to get private field on non-instance");return n.get(t)},hL=function(t,n,o){if(!n.has(t))throw new TypeError("attempted to set private field on non-instance");return n.set(t,o),o},r("__extends",XN),r("__assign",YN),r("__rest",QN),r("__decorate",ZN),r("__param",JN),r("__metadata",eL),r("__awaiter",tL),r("__generator",rL),r("__exportStar",nL),r("__createBinding",pL),r("__values",h5),r("__read",dE),r("__spread",oL),r("__spreadArrays",iL),r("__await",zd),r("__asyncGenerator",sL),r("__asyncDelegator",aL),r("__asyncValues",cL),r("__makeTemplateObject",lL),r("__importStar",uL),r("__importDefault",fL),r("__classPrivateFieldGet",dL),r("__classPrivateFieldSet",hL)})});var fM=Rt((VYe,uM)=>{uM.exports=fS;var lM=128,LQ=127,BQ=~LQ,MQ=Math.pow(2,31);function fS(r,e,t){if(Number.MAX_SAFE_INTEGER&&r>Number.MAX_SAFE_INTEGER)throw fS.bytes=0,new RangeError("Could not encode varint");e=e||[],t=t||0;for(var n=t;r>=MQ;)e[t++]=r&255|lM,r/=128;for(;r&BQ;)e[t++]=r&255|lM,r>>>=7;return e[t]=r|0,fS.bytes=t-n+1,e}});var pM=Rt((qYe,hM)=>{hM.exports=dS;var UQ=128,dM=127;function dS(r,n){var t=0,n=n||0,o=0,i=n,s,a=r.length;do{if(i>=a||o>49)throw dS.bytes=0,new RangeError("Could not decode varint");s=r[i++],t+=o<28?(s&dM)<<o:(s&dM)*Math.pow(2,o),o+=7}while(s>=UQ);return dS.bytes=i-n,t}});var gM=Rt((zYe,mM)=>{var FQ=Math.pow(2,7),$Q=Math.pow(2,14),HQ=Math.pow(2,21),KQ=Math.pow(2,28),VQ=Math.pow(2,35),qQ=Math.pow(2,42),zQ=Math.pow(2,49),jQ=Math.pow(2,56),WQ=Math.pow(2,63);mM.exports=function(r){return r<FQ?1:r<$Q?2:r<HQ?3:r<KQ?4:r<VQ?5:r<qQ?6:r<zQ?7:r<jQ?8:r<WQ?9:10}});var r8=Rt((jYe,yM)=>{yM.exports={encode:fM(),decode:pM(),encodingLength:gM()}});var BM=Rt((T0,g8)=>{(function(r,e){"use strict";var t={version:"3.0.0",x86:{},x64:{},inputValidation:!0};function n(d){if(!Array.isArray(d)&&!ArrayBuffer.isView(d))return!1;for(var m=0;m<d.length;m++)if(!Number.isInteger(d[m])||d[m]<0||d[m]>255)return!1;return!0}function o(d,m){return(d&65535)*m+(((d>>>16)*m&65535)<<16)}function i(d,m){return d<<m|d>>>32-m}function s(d){return d^=d>>>16,d=o(d,2246822507),d^=d>>>13,d=o(d,3266489909),d^=d>>>16,d}function a(d,m){d=[d[0]>>>16,d[0]&65535,d[1]>>>16,d[1]&65535],m=[m[0]>>>16,m[0]&65535,m[1]>>>16,m[1]&65535];var y=[0,0,0,0];return y[3]+=d[3]+m[3],y[2]+=y[3]>>>16,y[3]&=65535,y[2]+=d[2]+m[2],y[1]+=y[2]>>>16,y[2]&=65535,y[1]+=d[1]+m[1],y[0]+=y[1]>>>16,y[1]&=65535,y[0]+=d[0]+m[0],y[0]&=65535,[y[0]<<16|y[1],y[2]<<16|y[3]]}function c(d,m){d=[d[0]>>>16,d[0]&65535,d[1]>>>16,d[1]&65535],m=[m[0]>>>16,m[0]&65535,m[1]>>>16,m[1]&65535];var y=[0,0,0,0];return y[3]+=d[3]*m[3],y[2]+=y[3]>>>16,y[3]&=65535,y[2]+=d[2]*m[3],y[1]+=y[2]>>>16,y[2]&=65535,y[2]+=d[3]*m[2],y[1]+=y[2]>>>16,y[2]&=65535,y[1]+=d[1]*m[3],y[0]+=y[1]>>>16,y[1]&=65535,y[1]+=d[2]*m[2],y[0]+=y[1]>>>16,y[1]&=65535,y[1]+=d[3]*m[1],y[0]+=y[1]>>>16,y[1]&=65535,y[0]+=d[0]*m[3]+d[1]*m[2]+d[2]*m[1]+d[3]*m[0],y[0]&=65535,[y[0]<<16|y[1],y[2]<<16|y[3]]}function l(d,m){return m%=64,m===32?[d[1],d[0]]:m<32?[d[0]<<m|d[1]>>>32-m,d[1]<<m|d[0]>>>32-m]:(m-=32,[d[1]<<m|d[0]>>>32-m,d[0]<<m|d[1]>>>32-m])}function f(d,m){return m%=64,m===0?d:m<32?[d[0]<<m|d[1]>>>32-m,d[1]<<m]:[d[1]<<m-32,0]}function u(d,m){return[d[0]^m[0],d[1]^m[1]]}function h(d){return d=u(d,[0,d[0]>>>1]),d=c(d,[4283543511,3981806797]),d=u(d,[0,d[0]>>>1]),d=c(d,[3301882366,444984403]),d=u(d,[0,d[0]>>>1]),d}t.x86.hash32=function(d,m){if(t.inputValidation&&!n(d))return e;m=m||0;for(var y=d.length%4,w=d.length-y,x=m,E=0,v=3432918353,I=461845907,F=0;F<w;F=F+4)E=d[F]|d[F+1]<<8|d[F+2]<<16|d[F+3]<<24,E=o(E,v),E=i(E,15),E=o(E,I),x^=E,x=i(x,13),x=o(x,5)+3864292196;switch(E=0,y){case 3:E^=d[F+2]<<16;case 2:E^=d[F+1]<<8;case 1:E^=d[F],E=o(E,v),E=i(E,15),E=o(E,I),x^=E}return x^=d.length,x=s(x),x>>>0},t.x86.hash128=function(d,m){if(t.inputValidation&&!n(d))return e;m=m||0;for(var y=d.length%16,w=d.length-y,x=m,E=m,v=m,I=m,F=0,V=0,M=0,T=0,k=597399067,z=2869860233,W=951274213,$=2716044179,S=0;S<w;S=S+16)F=d[S]|d[S+1]<<8|d[S+2]<<16|d[S+3]<<24,V=d[S+4]|d[S+5]<<8|d[S+6]<<16|d[S+7]<<24,M=d[S+8]|d[S+9]<<8|d[S+10]<<16|d[S+11]<<24,T=d[S+12]|d[S+13]<<8|d[S+14]<<16|d[S+15]<<24,F=o(F,k),F=i(F,15),F=o(F,z),x^=F,x=i(x,19),x+=E,x=o(x,5)+1444728091,V=o(V,z),V=i(V,16),V=o(V,W),E^=V,E=i(E,17),E+=v,E=o(E,5)+197830471,M=o(M,W),M=i(M,17),M=o(M,$),v^=M,v=i(v,15),v+=I,v=o(v,5)+2530024501,T=o(T,$),T=i(T,18),T=o(T,k),I^=T,I=i(I,13),I+=x,I=o(I,5)+850148119;switch(F=0,V=0,M=0,T=0,y){case 15:T^=d[S+14]<<16;case 14:T^=d[S+13]<<8;case 13:T^=d[S+12],T=o(T,$),T=i(T,18),T=o(T,k),I^=T;case 12:M^=d[S+11]<<24;case 11:M^=d[S+10]<<16;case 10:M^=d[S+9]<<8;case 9:M^=d[S+8],M=o(M,W),M=i(M,17),M=o(M,$),v^=M;case 8:V^=d[S+7]<<24;case 7:V^=d[S+6]<<16;case 6:V^=d[S+5]<<8;case 5:V^=d[S+4],V=o(V,z),V=i(V,16),V=o(V,W),E^=V;case 4:F^=d[S+3]<<24;case 3:F^=d[S+2]<<16;case 2:F^=d[S+1]<<8;case 1:F^=d[S],F=o(F,k),F=i(F,15),F=o(F,z),x^=F}return x^=d.length,E^=d.length,v^=d.length,I^=d.length,x+=E,x+=v,x+=I,E+=x,v+=x,I+=x,x=s(x),E=s(E),v=s(v),I=s(I),x+=E,x+=v,x+=I,E+=x,v+=x,I+=x,("00000000"+(x>>>0).toString(16)).slice(-8)+("00000000"+(E>>>0).toString(16)).slice(-8)+("00000000"+(v>>>0).toString(16)).slice(-8)+("00000000"+(I>>>0).toString(16)).slice(-8)},t.x64.hash128=function(d,m){if(t.inputValidation&&!n(d))return e;m=m||0;for(var y=d.length%16,w=d.length-y,x=[0,m],E=[0,m],v=[0,0],I=[0,0],F=[2277735313,289559509],V=[1291169091,658871167],M=0;M<w;M=M+16)v=[d[M+4]|d[M+5]<<8|d[M+6]<<16|d[M+7]<<24,d[M]|d[M+1]<<8|d[M+2]<<16|d[M+3]<<24],I=[d[M+12]|d[M+13]<<8|d[M+14]<<16|d[M+15]<<24,d[M+8]|d[M+9]<<8|d[M+10]<<16|d[M+11]<<24],v=c(v,F),v=l(v,31),v=c(v,V),x=u(x,v),x=l(x,27),x=a(x,E),x=a(c(x,[0,5]),[0,1390208809]),I=c(I,V),I=l(I,33),I=c(I,F),E=u(E,I),E=l(E,31),E=a(E,x),E=a(c(E,[0,5]),[0,944331445]);switch(v=[0,0],I=[0,0],y){case 15:I=u(I,f([0,d[M+14]],48));case 14:I=u(I,f([0,d[M+13]],40));case 13:I=u(I,f([0,d[M+12]],32));case 12:I=u(I,f([0,d[M+11]],24));case 11:I=u(I,f([0,d[M+10]],16));case 10:I=u(I,f([0,d[M+9]],8));case 9:I=u(I,[0,d[M+8]]),I=c(I,V),I=l(I,33),I=c(I,F),E=u(E,I);case 8:v=u(v,f([0,d[M+7]],56));case 7:v=u(v,f([0,d[M+6]],48));case 6:v=u(v,f([0,d[M+5]],40));case 5:v=u(v,f([0,d[M+4]],32));case 4:v=u(v,f([0,d[M+3]],24));case 3:v=u(v,f([0,d[M+2]],16));case 2:v=u(v,f([0,d[M+1]],8));case 1:v=u(v,[0,d[M]]),v=c(v,F),v=l(v,31),v=c(v,V),x=u(x,v)}return x=u(x,[0,d.length]),E=u(E,[0,d.length]),x=a(x,E),E=a(E,x),x=h(x),E=h(E),x=a(x,E),E=a(E,x),("00000000"+(x[0]>>>0).toString(16)).slice(-8)+("00000000"+(x[1]>>>0).toString(16)).slice(-8)+("00000000"+(E[0]>>>0).toString(16)).slice(-8)+("00000000"+(E[1]>>>0).toString(16)).slice(-8)},typeof T0<"u"?(typeof g8<"u"&&g8.exports&&(T0=g8.exports=t),T0.murmurHash3=t):typeof define=="function"&&define.amd?define([],function(){return t}):(t._murmurHash3=r.murmurHash3,t.noConflict=function(){return r.murmurHash3=t._murmurHash3,t._murmurHash3=e,t.noConflict=e,t},r.murmurHash3=t)})(T0)});var UM=Rt((GZe,MM)=>{MM.exports=BM()});var KM=Rt((tJe,HM)=>{"use strict";HM.exports=class{constructor(){this._bitArrays=[],this._data=[],this._length=0,this._changedLength=!1,this._changedData=!1}set(e,t){let n=this._internalPositionFor(e,!1);if(t===void 0)n!==-1&&(this._unsetInternalPos(n),this._unsetBit(e),this._changedLength=!0,this._changedData=!0);else{let o=!1;n===-1?(n=this._data.length,this._setBit(e),this._changedData=!0):o=!0,this._setInternalPos(n,e,t,o),this._changedLength=!0}}unset(e){this.set(e,void 0)}get(e){this._sortData();let t=this._internalPositionFor(e,!0);if(t!==-1)return this._data[t][1]}push(e){return this.set(this.length,e),this.length}get length(){if(this._sortData(),this._changedLength){let e=this._data[this._data.length-1];this._length=e?e[0]+1:0,this._changedLength=!1}return this._length}forEach(e){let t=0;for(;t<this.length;)e(this.get(t),t,this),t++}map(e){let t=0,n=new Array(this.length);for(;t<this.length;)n[t]=e(this.get(t),t,this),t++;return n}reduce(e,t){let n=0,o=t;for(;n<this.length;){let i=this.get(n);o=e(o,i,n),n++}return o}find(e){let t=0,n,o;for(;t<this.length&&!n;)o=this.get(t),n=e(o),t++;return n?o:void 0}_internalPositionFor(e,t){let n=this._bytePosFor(e,t);if(n>=this._bitArrays.length)return-1;let o=this._bitArrays[n],i=e-n*7;if(!((o&1<<i)>0))return-1;let a=this._bitArrays.slice(0,n).reduce(bZ,0),c=~(4294967295<<i+1),l=$M(o&c);return a+l-1}_bytePosFor(e,t){let n=Math.floor(e/7),o=n+1;for(;!t&&this._bitArrays.length<o;)this._bitArrays.push(0);return n}_setBit(e){let t=this._bytePosFor(e,!1);this._bitArrays[t]|=1<<e-t*7}_unsetBit(e){let t=this._bytePosFor(e,!1);this._bitArrays[t]&=~(1<<e-t*7)}_setInternalPos(e,t,n,o){let i=this._data,s=[t,n];if(o)this._sortData(),i[e]=s;else{if(i.length)if(i[i.length-1][0]>=t)i.push(s);else if(i[0][0]<=t)i.unshift(s);else{let a=Math.round(i.length/2);this._data=i.slice(0,a).concat(s).concat(i.slice(a))}else this._data.push(s);this._changedData=!0,this._changedLength=!0}}_unsetInternalPos(e){this._data.splice(e,1)}_sortData(){this._changedData&&this._data.sort(vZ),this._changedData=!1}bitField(){let e=[],t=8,n=0,o=0,i,s=this._bitArrays.slice();for(;s.length||n;){n===0&&(i=s.shift(),n=7);let c=Math.min(n,t),l=~(255<<c),f=i&l;o|=f<<8-t,i=i>>>c,n-=c,t-=c,(!t||!n&&!s.length)&&(e.push(o),o=0,t=8)}for(var a=e.length-1;a>0&&e[a]===0;a--)e.pop();return e}compactArray(){return this._sortData(),this._data.map(EZ)}};function bZ(r,e){return r+$M(e)}function $M(r){let e=r;return e=e-(e>>1&1431655765),e=(e&858993459)+(e>>2&858993459),(e+(e>>4)&252645135)*16843009>>24}function vZ(r,e){return r[0]-e[0]}function EZ(r){return r[1]}});var wU=Rt((Ftt,yU)=>{"use strict";yU.exports={RTLD_LAZY:1,RTLD_NOW:2,RTLD_GLOBAL:256,RTLD_LOCAL:0,RTLD_DEEPBIND:8,E2BIG:7,EACCES:13,EADDRINUSE:98,EADDRNOTAVAIL:99,EAFNOSUPPORT:97,EAGAIN:11,EALREADY:114,EBADF:9,EBADMSG:74,EBUSY:16,ECANCELED:125,ECHILD:10,ECONNABORTED:103,ECONNREFUSED:111,ECONNRESET:104,EDEADLK:35,EDESTADDRREQ:89,EDOM:33,EDQUOT:122,EEXIST:17,EFAULT:14,EFBIG:27,EHOSTUNREACH:113,EIDRM:43,EILSEQ:84,EINPROGRESS:115,EINTR:4,EINVAL:22,EIO:5,EISCONN:106,EISDIR:21,ELOOP:40,EMFILE:24,EMLINK:31,EMSGSIZE:90,EMULTIHOP:72,ENAMETOOLONG:36,ENETDOWN:100,ENETRESET:102,ENETUNREACH:101,ENFILE:23,ENOBUFS:105,ENODATA:61,ENODEV:19,ENOENT:2,ENOEXEC:8,ENOLCK:37,ENOLINK:67,ENOMEM:12,ENOMSG:42,ENOPROTOOPT:92,ENOSPC:28,ENOSR:63,ENOSTR:60,ENOSYS:38,ENOTCONN:107,ENOTDIR:20,ENOTEMPTY:39,ENOTSOCK:88,ENOTSUP:95,ENOTTY:25,ENXIO:6,EOPNOTSUPP:95,EOVERFLOW:75,EPERM:1,EPIPE:32,EPROTO:71,EPROTONOSUPPORT:93,EPROTOTYPE:91,ERANGE:34,EROFS:30,ESPIPE:29,ESRCH:3,ESTALE:116,ETIME:62,ETIMEDOUT:110,ETXTBSY:26,EWOULDBLOCK:11,EXDEV:18,PRIORITY_LOW:19,PRIORITY_BELOW_NORMAL:10,PRIORITY_NORMAL:0,PRIORITY_ABOVE_NORMAL:-7,PRIORITY_HIGH:-14,PRIORITY_HIGHEST:-20,SIGHUP:1,SIGINT:2,SIGQUIT:3,SIGILL:4,SIGTRAP:5,SIGABRT:6,SIGIOT:6,SIGBUS:7,SIGFPE:8,SIGKILL:9,SIGUSR1:10,SIGSEGV:11,SIGUSR2:12,SIGPIPE:13,SIGALRM:14,SIGTERM:15,SIGCHLD:17,SIGSTKFLT:16,SIGCONT:18,SIGSTOP:19,SIGTSTP:20,SIGTTIN:21,SIGTTOU:22,SIGURG:23,SIGXCPU:24,SIGXFSZ:25,SIGVTALRM:26,SIGPROF:27,SIGWINCH:28,SIGIO:29,SIGPOLL:29,SIGPWR:30,SIGSYS:31,UV_FS_SYMLINK_DIR:1,UV_FS_SYMLINK_JUNCTION:2,O_RDONLY:0,O_WRONLY:1,O_RDWR:2,UV_DIRENT_UNKNOWN:0,UV_DIRENT_FILE:1,UV_DIRENT_DIR:2,UV_DIRENT_LINK:3,UV_DIRENT_FIFO:4,UV_DIRENT_SOCKET:5,UV_DIRENT_CHAR:6,UV_DIRENT_BLOCK:7,S_IFMT:61440,S_IFREG:32768,S_IFDIR:16384,S_IFCHR:8192,S_IFBLK:24576,S_IFIFO:4096,S_IFLNK:40960,S_IFSOCK:49152,O_CREAT:64,O_EXCL:128,UV_FS_O_FILEMAP:0,O_NOCTTY:256,O_TRUNC:512,O_APPEND:1024,O_DIRECTORY:65536,O_NOATIME:262144,O_NOFOLLOW:131072,O_SYNC:1052672,O_DSYNC:4096,O_DIRECT:16384,O_NONBLOCK:2048,S_IRWXU:448,S_IRUSR:256,S_IWUSR:128,S_IXUSR:64,S_IRWXG:56,S_IRGRP:32,S_IWGRP:16,S_IXGRP:8,S_IRWXO:7,S_IROTH:4,S_IWOTH:2,S_IXOTH:1,F_OK:0,R_OK:4,W_OK:2,X_OK:1,UV_FS_COPYFILE_EXCL:1,COPYFILE_EXCL:1,UV_FS_COPYFILE_FICLONE:2,COPYFILE_FICLONE:2,UV_FS_COPYFILE_FICLONE_FORCE:4,COPYFILE_FICLONE_FORCE:4,OPENSSL_VERSION_NUMBER:810549312,SSL_OP_ALL:2147485776,SSL_OP_ALLOW_NO_DHE_KEX:1024,SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION:262144,SSL_OP_CIPHER_SERVER_PREFERENCE:4194304,SSL_OP_CISCO_ANYCONNECT:32768,SSL_OP_COOKIE_EXCHANGE:8192,SSL_OP_CRYPTOPRO_TLSEXT_BUG:2147483648,SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS:2048,SSL_OP_LEGACY_SERVER_CONNECT:4,SSL_OP_NO_COMPRESSION:131072,SSL_OP_NO_ENCRYPT_THEN_MAC:524288,SSL_OP_NO_QUERY_MTU:4096,SSL_OP_NO_RENEGOTIATION:1073741824,SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION:65536,SSL_OP_NO_SSLv2:0,SSL_OP_NO_SSLv3:33554432,SSL_OP_NO_TICKET:16384,SSL_OP_NO_TLSv1:67108864,SSL_OP_NO_TLSv1_1:268435456,SSL_OP_NO_TLSv1_2:134217728,SSL_OP_NO_TLSv1_3:536870912,SSL_OP_PRIORITIZE_CHACHA:2097152,SSL_OP_TLS_ROLLBACK_BUG:8388608,ENGINE_METHOD_RSA:1,ENGINE_METHOD_DSA:2,ENGINE_METHOD_DH:4,ENGINE_METHOD_RAND:8,ENGINE_METHOD_EC:2048,ENGINE_METHOD_CIPHERS:64,ENGINE_METHOD_DIGESTS:128,ENGINE_METHOD_PKEY_METHS:512,ENGINE_METHOD_PKEY_ASN1_METHS:1024,ENGINE_METHOD_ALL:65535,ENGINE_METHOD_NONE:0,DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8,RSA_PKCS1_PADDING:1,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_X931_PADDING:5,RSA_PKCS1_PSS_PADDING:6,RSA_PSS_SALTLEN_DIGEST:-1,RSA_PSS_SALTLEN_MAX_SIGN:-2,RSA_PSS_SALTLEN_AUTO:-2,defaultCoreCipherList:"TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:DHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA256:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!SRP:!CAMELLIA",TLS1_VERSION:769,TLS1_1_VERSION:770,TLS1_2_VERSION:771,TLS1_3_VERSION:772,POINT_CONVERSION_COMPRESSED:2,POINT_CONVERSION_UNCOMPRESSED:4,POINT_CONVERSION_HYBRID:6}});var PU=Rt(RS=>{RS.read=function(r,e,t,n,o){var i,s,a=o*8-n-1,c=(1<<a)-1,l=c>>1,f=-7,u=t?o-1:0,h=t?-1:1,d=r[e+u];for(u+=h,i=d&(1<<-f)-1,d>>=-f,f+=a;f>0;i=i*256+r[e+u],u+=h,f-=8);for(s=i&(1<<-f)-1,i>>=-f,f+=n;f>0;s=s*256+r[e+u],u+=h,f-=8);if(i===0)i=1-l;else{if(i===c)return s?NaN:(d?-1:1)*(1/0);s=s+Math.pow(2,n),i=i-l}return(d?-1:1)*s*Math.pow(2,i-n)};RS.write=function(r,e,t,n,o,i){var s,a,c,l=i*8-o-1,f=(1<<l)-1,u=f>>1,h=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:i-1,m=n?1:-1,y=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),s+u>=1?e+=h/c:e+=h*Math.pow(2,1-u),e*c>=2&&(s++,c/=2),s+u>=f?(a=0,s=f):s+u>=1?(a=(e*c-1)*Math.pow(2,o),s=s+u):(a=e*Math.pow(2,u-1)*Math.pow(2,o),s=0));o>=8;r[t+d]=a&255,d+=m,a/=256,o-=8);for(s=s<<o|a,l+=o;l>0;r[t+d]=s&255,d+=m,s/=256,l-=8);r[t+d-m]|=y*128}});var HU=Rt(($nt,$U)=>{var yh=1e3,wh=yh*60,xh=wh*60,Nu=xh*24,WJ=Nu*7,GJ=Nu*365.25;$U.exports=function(r,e){e=e||{};var t=typeof r;if(t==="string"&&r.length>0)return XJ(r);if(t==="number"&&isFinite(r))return e.long?QJ(r):YJ(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function XJ(r){if(r=String(r),!(r.length>100)){var e=/^(-?(?:\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(e){var t=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return t*GJ;case"weeks":case"week":case"w":return t*WJ;case"days":case"day":case"d":return t*Nu;case"hours":case"hour":case"hrs":case"hr":case"h":return t*xh;case"minutes":case"minute":case"mins":case"min":case"m":return t*wh;case"seconds":case"second":case"secs":case"sec":case"s":return t*yh;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function YJ(r){var e=Math.abs(r);return e>=Nu?Math.round(r/Nu)+"d":e>=xh?Math.round(r/xh)+"h":e>=wh?Math.round(r/wh)+"m":e>=yh?Math.round(r/yh)+"s":r+"ms"}function QJ(r){var e=Math.abs(r);return e>=Nu?U8(r,e,Nu,"day"):e>=xh?U8(r,e,xh,"hour"):e>=wh?U8(r,e,wh,"minute"):e>=yh?U8(r,e,yh,"second"):r+" ms"}function U8(r,e,t,n){var o=e>=t*1.5;return Math.round(r/t)+" "+n+(o?"s":"")}});var VU=Rt((Hnt,KU)=>{function ZJ(r){t.debug=t,t.default=t,t.coerce=c,t.disable=s,t.enable=o,t.enabled=a,t.humanize=HU(),t.destroy=l,Object.keys(r).forEach(f=>{t[f]=r[f]}),t.names=[],t.skips=[],t.formatters={};function e(f){let u=0;for(let h=0;h<f.length;h++)u=(u<<5)-u+f.charCodeAt(h),u|=0;return t.colors[Math.abs(u)%t.colors.length]}t.selectColor=e;function t(f){let u,h=null,d,m;function y(...w){if(!y.enabled)return;let x=y,E=Number(new Date),v=E-(u||E);x.diff=v,x.prev=u,x.curr=E,u=E,w[0]=t.coerce(w[0]),typeof w[0]!="string"&&w.unshift("%O");let I=0;w[0]=w[0].replace(/%([a-zA-Z%])/g,(V,M)=>{if(V==="%%")return"%";I++;let T=t.formatters[M];if(typeof T=="function"){let k=w[I];V=T.call(x,k),w.splice(I,1),I--}return V}),t.formatArgs.call(x,w),(x.log||t.log).apply(x,w)}return y.namespace=f,y.useColors=t.useColors(),y.color=t.selectColor(f),y.extend=n,y.destroy=t.destroy,Object.defineProperty(y,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(d!==t.namespaces&&(d=t.namespaces,m=t.enabled(f)),m),set:w=>{h=w}}),typeof t.init=="function"&&t.init(y),y}function n(f,u){let h=t(this.namespace+(typeof u>"u"?":":u)+f);return h.log=this.log,h}function o(f){t.save(f),t.namespaces=f,t.names=[],t.skips=[];let u=(typeof f=="string"?f:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let h of u)h[0]==="-"?t.skips.push(h.slice(1)):t.names.push(h)}function i(f,u){let h=0,d=0,m=-1,y=0;for(;h<f.length;)if(d<u.length&&(u[d]===f[h]||u[d]==="*"))u[d]==="*"?(m=d,y=h,d++):(h++,d++);else if(m!==-1)d=m+1,y++,h=y;else return!1;for(;d<u.length&&u[d]==="*";)d++;return d===u.length}function s(){let f=[...t.names,...t.skips.map(u=>"-"+u)].join(",");return t.enable(""),f}function a(f){for(let u of t.skips)if(i(f,u))return!1;for(let u of t.names)if(i(f,u))return!0;return!1}function c(f){return f instanceof Error?f.stack||f.message:f}function l(){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 t.enable(t.load()),t}KU.exports=ZJ});var qU=Rt((jn,F8)=>{jn.formatArgs=eee;jn.save=tee;jn.load=ree;jn.useColors=JJ;jn.storage=nee();jn.destroy=(()=>{let r=!1;return()=>{r||(r=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();jn.colors=["#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 JJ(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let r;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(r=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(r[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function eee(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+F8.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;r.splice(1,0,e,"color: inherit");let t=0,n=0;r[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(t++,o==="%c"&&(n=t))}),r.splice(n,0,e)}jn.log=console.debug||console.log||(()=>{});function tee(r){try{r?jn.storage.setItem("debug",r):jn.storage.removeItem("debug")}catch{}}function ree(){let r;try{r=jn.storage.getItem("debug")||jn.storage.getItem("DEBUG")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function nee(){try{return localStorage}catch{}}F8.exports=VU()(jn);var{formatters:oee}=F8.exports;oee.j=function(r){try{return JSON.stringify(r)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var xee={};Dt(xee,{BasePlugin:()=>Vn,MEDIA_TYPE_CAR:()=>Pu,MEDIA_TYPE_CBOR:()=>wo,MEDIA_TYPE_DAG_CBOR:()=>yo,MEDIA_TYPE_DAG_JSON:()=>xo,MEDIA_TYPE_DAG_PB:()=>I0,MEDIA_TYPE_IPNS_RECORD:()=>ku,MEDIA_TYPE_JSON:()=>bo,MEDIA_TYPE_OCTET_STREAM:()=>Kr,MEDIA_TYPE_RAW:()=>En,MEDIA_TYPE_TAR:()=>fh,createVerifiedFetch:()=>HS,verifiedFetch:()=>V8});var GS=Symbol.for("@libp2p/connection");var us=Symbol.for("@libp2p/content-routing");var Tr=class extends Error{static name="AbortError";constructor(e="The operation was aborted"){super(e),this.name="AbortError"}},$0=class extends Error{static name="UnexpectedPeerError";constructor(e="Unexpected Peer"){super(e),this.name="UnexpectedPeerError"}},H0=class extends Error{static name="InvalidCryptoExchangeError";constructor(e="Invalid crypto exchange"){super(e),this.name="InvalidCryptoExchangeError"}},O=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}},fs=class extends Error{static name="InvalidPublicKeyError";constructor(e="Invalid public key"){super(e),this.name="InvalidPublicKeyError"}},Eh=class extends Error{static name="InvalidPrivateKeyError";constructor(e="Invalid private key"){super(e),this.name="InvalidPrivateKeyError"}},Sh=class extends Error{static name="UnsupportedOperationError";constructor(e="Unsupported operation"){super(e),this.name="UnsupportedOperationError"}};var Ic=class extends Error{static name="ConnectionClosedError";constructor(e="The connection is closed"){super(e),this.name="ConnectionClosedError"}},Mu=class extends Error{static name="ConnectionFailedError";constructor(e="Connection failed"){super(e),this.name="ConnectionFailedError"}},Yo=class extends Error{static name="MuxerClosedError";constructor(e="The muxer is closed"){super(e),this.name="MuxerClosedError"}},Uu=class extends Error{static name="StreamResetError";constructor(e="The stream has been reset"){super(e),this.name="StreamResetError"}};var Ti=class extends Error{static name="StreamStateError";constructor(e="The stream is in an invalid state"){super(e),this.name="StreamStateError"}},Ah=class extends Error{static name="StreamBufferError";constructor(e="The stream buffer was full"){super(e),this.name="StreamBufferError"}},Ye=class extends Error{static name="NotFoundError";constructor(e="Not found"){super(e),this.name="NotFoundError"}},Fu=class extends Error{static name="InvalidPeerIdError";constructor(e="Invalid PeerID"){super(e),this.name="InvalidPeerIdError"}},Ci=class extends Error{static name="InvalidMultiaddrError";constructor(e="Invalid multiaddr"){super(e),this.name="InvalidMultiaddrError"}},K0=class extends Error{static name="InvalidCIDError";constructor(e="Invalid CID"){super(e),this.name="InvalidCIDError"}},da=class extends Error{static name="InvalidMultihashError";constructor(e="Invalid Multihash"){super(e),this.name="InvalidMultihashError"}},$u=class extends Error{static name="UnsupportedProtocolError";constructor(e="Unsupported protocol error"){super(e),this.name="UnsupportedProtocolError"}},Ne=class extends Error{static name="InvalidMessageError";constructor(e="Invalid message"){super(e),this.name="InvalidMessageError"}},kc=class extends Error{static name="ProtocolError";constructor(e="Protocol error"){super(e),this.name="ProtocolError"}},Ii=class extends Error{static name="TimeoutError";constructor(e="Timed out"){super(e),this.name="TimeoutError"}},Wn=class extends Error{static name="NotStartedError";constructor(e="Not started"){super(e),this.name="NotStartedError"}};var ha=class extends Error{static name="DialError";constructor(e="Dial error"){super(e),this.name="DialError"}},Pc=class extends Error{static name="ListenError";constructor(e="Listen error"){super(e),this.name="ListenError"}},_h=class extends Error{static name="LimitedConnectionError";constructor(e="Limited connection"){super(e),this.name="LimitedConnectionError"}},V0=class extends Error{static name="TooManyInboundProtocolStreamsError";constructor(e="Too many inbound protocol streams"){super(e),this.name="TooManyInboundProtocolStreamsError"}},Hu=class extends Error{static name="TooManyOutboundProtocolStreamsError";constructor(e="Too many outbound protocol streams"){super(e),this.name="TooManyOutboundProtocolStreamsError"}},Qo=class extends Error{static name="UnsupportedKeyTypeError";constructor(e="Unsupported key type"){super(e),this.name="UnsupportedKeyTypeError"}};var q0=class extends Event{data;constructor(e,t){super("message",t),this.data=e}},pa=class extends Event{error;local;constructor(e,t,n){super("close",n),this.error=t,this.local=e}},z0=class extends pa{constructor(e,t){super(!0,e,t)}},j0=class extends pa{constructor(e,t){super(!1,e,t)}};function XS(r){return r==null?!1:(r.type==="RSA"||r.type==="Ed25519"||r.type==="secp256k1"||r.type==="ECDSA")&&r.raw instanceof Uint8Array&&typeof r.equals=="function"&&typeof r.toMultihash=="function"&&typeof r.toCID=="function"&&typeof r.verify=="function"}var Rc=Symbol.for("@libp2p/peer-discovery");var W0=Symbol.for("@libp2p/peer-id");function Vr(r){return!!r?.[W0]}var ds=Symbol.for("@libp2p/peer-routing");var Oc="keep-alive";function G0(r){return r!=null&&typeof r.start=="function"&&typeof r.stop=="function"}async function cr(...r){let e=[];for(let t of r)G0(t)&&e.push(t);await Promise.all(e.map(async t=>{t.beforeStart!=null&&await t.beforeStart()})),await Promise.all(e.map(async t=>{await t.start()})),await Promise.all(e.map(async t=>{t.afterStart!=null&&await t.afterStart()}))}async function mr(...r){let e=[];for(let t of r)G0(t)&&e.push(t);await Promise.all(e.map(async t=>{t.beforeStop!=null&&await t.beforeStop()})),await Promise.all(e.map(async t=>{await t.stop()})),await Promise.all(e.map(async t=>{t.afterStop!=null&&await t.afterStop()}))}var ma=Symbol.for("@libp2p/transport");var Th;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(Th||(Th={}));var _e=class extends EventTarget{#t=new Map;constructor(){super()}listenerCount(e){let t=this.#t.get(e);return t==null?0:t.length}addEventListener(e,t,n){super.addEventListener(e,t,n);let o=this.#t.get(e);o==null&&(o=[],this.#t.set(e,o)),o.push({callback:t,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(e,t,n){super.removeEventListener(e.toString(),t??null,n);let o=this.#t.get(e);o!=null&&(o=o.filter(({callback:i})=>i!==t),this.#t.set(e,o))}dispatchEvent(e){let t=super.dispatchEvent(e),n=this.#t.get(e.type);return n==null||(n=n.filter(({once:o})=>!o),this.#t.set(e.type,n)),t}safeDispatchEvent(e,t={}){return this.dispatchEvent(new CustomEvent(e,t))}};var Ve=Symbol.for("@libp2p/service-capabilities"),Gn=Symbol.for("@libp2p/service-dependencies");function Re(r){let e=new globalThis.AbortController;function t(){let i=r.filter(s=>s?.aborted===!0).map(s=>s?.reason).pop();e.abort(i);for(let s of r)s?.removeEventListener!=null&&s.removeEventListener("abort",t)}for(let i of r){if(i?.aborted===!0){t();break}i?.addEventListener!=null&&i.addEventListener("abort",t)}function n(){for(let i of r)i?.removeEventListener!=null&&i.removeEventListener("abort",t)}let o=e.signal;return o.clear=n,o}var Y=class extends Event{type;detail;constructor(e,t){super(e),this.type=e,this.detail=t}};var Ch=class extends Error{constructor(e="An error occurred while signing a message"){super(e),this.name="SigningError"}},Ih=class extends Error{constructor(e="An error occurred while verifying a message"){super(e),this.name="VerificationError"}},X0=class extends Error{constructor(e="Missing Web Crypto API"){super(e),this.name="WebCryptoMissingError"}};var YS={get(r=globalThis){let e=r.crypto;if(e?.subtle==null)throw new X0("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api");return e}};var Qt=YS;var J8={};Dt(J8,{base58btc:()=>Qe,base58flickr:()=>RF});var Dc={};Dt(Dc,{coerce:()=>vo,empty:()=>QS,equals:()=>j8,fromHex:()=>SF,fromString:()=>W8,isBinary:()=>AF,toHex:()=>EF,toString:()=>G8});var QS=new Uint8Array(0);function EF(r){return r.reduce((e,t)=>e+t.toString(16).padStart(2,"0"),"")}function SF(r){let e=r.match(/../g);return e!=null?new Uint8Array(e.map(t=>parseInt(t,16))):QS}function j8(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function vo(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 AF(r){return r instanceof ArrayBuffer||ArrayBuffer.isView(r)}function W8(r){return new TextEncoder().encode(r)}function G8(r){return new TextDecoder().decode(r)}function _F(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var o=0;o<r.length;o++){var i=r.charAt(o),s=i.charCodeAt(0);if(t[s]!==255)throw new TypeError(i+" is ambiguous");t[s]=o}var a=r.length,c=r.charAt(0),l=Math.log(a)/Math.log(256),f=Math.log(256)/Math.log(a);function u(m){if(m instanceof Uint8Array||(ArrayBuffer.isView(m)?m=new Uint8Array(m.buffer,m.byteOffset,m.byteLength):Array.isArray(m)&&(m=Uint8Array.from(m))),!(m instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(m.length===0)return"";for(var y=0,w=0,x=0,E=m.length;x!==E&&m[x]===0;)x++,y++;for(var v=(E-x)*f+1>>>0,I=new Uint8Array(v);x!==E;){for(var F=m[x],V=0,M=v-1;(F!==0||V<w)&&M!==-1;M--,V++)F+=256*I[M]>>>0,I[M]=F%a>>>0,F=F/a>>>0;if(F!==0)throw new Error("Non-zero carry");w=V,x++}for(var T=v-w;T!==v&&I[T]===0;)T++;for(var k=c.repeat(y);T<v;++T)k+=r.charAt(I[T]);return k}function h(m){if(typeof m!="string")throw new TypeError("Expected String");if(m.length===0)return new Uint8Array;var y=0;if(m[y]!==" "){for(var w=0,x=0;m[y]===c;)w++,y++;for(var E=(m.length-y)*l+1>>>0,v=new Uint8Array(E);m[y];){var I=t[m.charCodeAt(y)];if(I===255)return;for(var F=0,V=E-1;(I!==0||F<x)&&V!==-1;V--,F++)I+=a*v[V]>>>0,v[V]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");x=F,y++}if(m[y]!==" "){for(var M=E-x;M!==E&&v[M]===0;)M++;for(var T=new Uint8Array(w+(E-M)),k=w;M!==E;)T[k++]=v[M++];return T}}}function d(m){var y=h(m);if(y)return y;throw new Error(`Non-${e} character`)}return{encode:u,decodeUnsafe:h,decode:d}}var TF=_F,CF=TF,ZS=CF;var X8=class{name;prefix;baseEncode;constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Y8=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){this.name=e,this.prefix=t;let o=t.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return JS(this,e)}},Q8=class{decoders;constructor(e){this.decoders=e}or(e){return JS(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function JS(r,e){return new Q8({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var Z8=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new X8(e,t,n),this.decoder=new Y8(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Ku({name:r,prefix:e,encode:t,decode:n}){return new Z8(r,e,t,n)}function ga({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=ZS(t,r);return Ku({prefix:e,name:r,encode:n,decode:i=>vo(o(i))})}function IF(r,e,t,n){let o=r.length;for(;r[o-1]==="=";)--o;let i=new Uint8Array(o*t/8|0),s=0,a=0,c=0;for(let l=0;l<o;++l){let f=e[r[l]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<t|f,s+=t,s>=8&&(s-=8,i[c++]=255&a>>s)}if(s>=t||(255&a<<8-s)!==0)throw new SyntaxError("Unexpected end of data");return i}function kF(r,e,t){let n=e[e.length-1]==="=",o=(1<<t)-1,i="",s=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],s+=8;s>t;)s-=t,i+=e[o&a>>s];if(s!==0&&(i+=e[o&a<<t-s]),n)for(;(i.length*t&7)!==0;)i+="=";return i}function PF(r){let e={};for(let t=0;t<r.length;++t)e[r[t]]=t;return e}function Ft({name:r,prefix:e,bitsPerChar:t,alphabet:n}){let o=PF(n);return Ku({prefix:e,name:r,encode(i){return kF(i,n,t)},decode(i){return IF(i,o,t,r)}})}var Qe=ga({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),RF=ga({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ew={};Dt(ew,{base32:()=>gr,base32hex:()=>LF,base32hexpad:()=>MF,base32hexpadupper:()=>UF,base32hexupper:()=>BF,base32pad:()=>DF,base32padupper:()=>NF,base32upper:()=>OF,base32z:()=>FF});var gr=Ft({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),OF=Ft({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),DF=Ft({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),NF=Ft({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),LF=Ft({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),BF=Ft({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),MF=Ft({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),UF=Ft({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),FF=Ft({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var tw={};Dt(tw,{base36:()=>rn,base36upper:()=>$F});var rn=ga({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),$F=ga({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var yt={};Dt(yt,{Digest:()=>Nc,create:()=>nn,decode:()=>qe,equals:()=>nw,hasCode:()=>i$});var HF=rA,eA=128,KF=127,VF=~KF,qF=Math.pow(2,31);function rA(r,e,t){e=e||[],t=t||0;for(var n=t;r>=qF;)e[t++]=r&255|eA,r/=128;for(;r&VF;)e[t++]=r&255|eA,r>>>=7;return e[t]=r|0,rA.bytes=t-n+1,e}var zF=rw,jF=128,tA=127;function rw(r,n){var t=0,n=n||0,o=0,i=n,s,a=r.length;do{if(i>=a)throw rw.bytes=0,new RangeError("Could not decode varint");s=r[i++],t+=o<28?(s&tA)<<o:(s&tA)*Math.pow(2,o),o+=7}while(s>=jF);return rw.bytes=i-n,t}var WF=Math.pow(2,7),GF=Math.pow(2,14),XF=Math.pow(2,21),YF=Math.pow(2,28),QF=Math.pow(2,35),ZF=Math.pow(2,42),JF=Math.pow(2,49),e$=Math.pow(2,56),t$=Math.pow(2,63),r$=function(r){return r<WF?1:r<GF?2:r<XF?3:r<YF?4:r<QF?5:r<ZF?6:r<JF?7:r<e$?8:r<t$?9:10},n$={encode:HF,decode:zF,encodingLength:r$},o$=n$,kh=o$;function Ph(r,e=0){return[kh.decode(r,e),kh.decode.bytes]}function Vu(r,e,t=0){return kh.encode(r,e,t),e}function qu(r){return kh.encodingLength(r)}function nn(r,e){let t=e.byteLength,n=qu(r),o=n+qu(t),i=new Uint8Array(o+t);return Vu(r,i,0),Vu(t,i,n),i.set(e,o),new Nc(r,t,e,i)}function qe(r){let e=vo(r),[t,n]=Ph(e),[o,i]=Ph(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Nc(t,o,s,e)}function nw(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&j8(r.bytes,t.bytes)}}var Nc=class{code;size;digest;bytes;constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};function i$(r,e){return r.code===e}function nA(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return a$(t,ow(r),e??Qe.encoder);default:return c$(t,ow(r),e??gr.encoder)}}var oA=new WeakMap;function ow(r){let e=oA.get(r);if(e==null){let t=new Map;return oA.set(r,t),t}return e}var Z=class r{code;version;multihash;bytes;"/";constructor(e,t,n,o){this.code=t,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:t}=this;if(e!==Rh)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==l$)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,n=nn(e,t);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return r.equals(this,e)}static equals(e,t){let n=t;return n!=null&&e.code===n.code&&e.version===n.version&&nw(e.multihash,n.multihash)}toString(e){return nA(this,e)}toJSON(){return{"/":nA(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:i,bytes:s}=t;return new r(n,o,i,s??iA(n,o,i.bytes))}else if(t[u$]===!0){let{version:n,multihash:o,code:i}=t,s=qe(o);return r.create(n,i,s)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==Rh)throw new Error(`Version 0 CID must use dag-pb (code: ${Rh}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=iA(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,Rh,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,o=vo(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let i=o.subarray(t.multihashSize-t.digestSize),s=new Nc(t.multihashCode,t.digestSize,i,o);return[t.version===0?r.createV0(s):r.createV1(t.codec,s),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[u,h]=Ph(e.subarray(t));return t+=h,u},o=n(),i=Rh;if(o===18?(o=0,t=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=t,a=n(),c=n(),l=t+c,f=l-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:f,size:l}}static parse(e,t){let[n,o]=s$(e,t),i=r.decode(o);if(i.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return ow(i).set(n,e),i}};function s$(r,e){switch(r[0]){case"Q":{let t=e??Qe;return[Qe.prefix,t.decode(`${Qe.prefix}${r}`)]}case Qe.prefix:{let t=e??Qe;return[Qe.prefix,t.decode(r)]}case gr.prefix:{let t=e??gr;return[gr.prefix,t.decode(r)]}case rn.prefix:{let t=e??rn;return[rn.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function a$(r,e,t){let{prefix:n}=t;if(n!==Qe.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let i=t.encode(r).slice(1);return e.set(n,i),i}else return o}function c$(r,e,t){let{prefix:n}=t,o=e.get(n);if(o==null){let i=t.encode(r);return e.set(n,i),i}else return o}var Rh=112,l$=18;function iA(r,e,t){let n=qu(r),o=n+qu(e),i=new Uint8Array(o+t.byteLength);return Vu(r,i,0),Vu(e,i,n),i.set(t,o),i}var u$=Symbol.for("@ipld/js-cid/CID");var iw={};Dt(iw,{identity:()=>$t});var sA=0,f$="identity",aA=vo;function d$(r,e){if(e?.truncate!=null&&e.truncate!==r.byteLength){if(e.truncate<0||e.truncate>r.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${r.byteLength}`);r=r.subarray(0,e.truncate)}return nn(sA,aA(r))}var $t={code:sA,name:f$,encode:aA,digest:d$};function me(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function Ie(r=0){return new Uint8Array(r)}function Nt(r=0){return new Uint8Array(r)}function dt(r,e){e==null&&(e=r.reduce((o,i)=>o+i.length,0));let t=Nt(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return t}var lA=Symbol.for("@achingbrain/uint8arraylist");function cA(r,e){if(e==null||e<0)throw new RangeError("index is out of bounds");let t=0;for(let n of r){let o=t+n.byteLength;if(e<o)return{buf:n,index:e-t};t=o}throw new RangeError("index is out of bounds")}function Eo(r){return!!r?.[lA]}var se=class r{bufs;length;[lA]=!0;constructor(...e){this.bufs=[],this.length=0,e.length>0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let t=0;for(let n of e)if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.push(n);else if(Eo(n))t+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=t}prepend(...e){this.prependAll(e)}prependAll(e){let t=0;for(let n of e.reverse())if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.unshift(n);else if(Eo(n))t+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=t}get(e){let t=cA(this.bufs,e);return t.buf[t.index]}set(e,t){let n=cA(this.bufs,e);n.buf[n.index]=t}write(e,t=0){if(e instanceof Uint8Array)for(let n=0;n<e.length;n++)this.set(t+n,e[n]);else if(Eo(e))for(let n=0;n<e.length;n++)this.set(t+n,e.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(e){if(e=Math.trunc(e),!(Number.isNaN(e)||e<=0)){if(e===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(e>=this.bufs[0].byteLength)e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}}}slice(e,t){let{bufs:n,length:o}=this._subList(e,t);return dt(n,o)}subarray(e,t){let{bufs:n,length:o}=this._subList(e,t);return n.length===1?n[0]:dt(n,o)}sublist(e,t){let{bufs:n,length:o}=this._subList(e,t),i=new r;return i.length=o,i.bufs=[...n],i}_subList(e,t){if(e=e??0,t=t??this.length,e<0&&(e=this.length+e),t<0&&(t=this.length+t),e<0||t>this.length)throw new RangeError("index is out of bounds");if(e===t)return{bufs:[],length:0};if(e===0&&t===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let i=0;i<this.bufs.length;i++){let s=this.bufs[i],a=o,c=a+s.byteLength;if(o=c,e>=c)continue;let l=e>=a&&e<c,f=t>a&&t<=c;if(l&&f){if(e===a&&t===c){n.push(s);break}let u=e-a;n.push(s.subarray(u,u+(t-e)));break}if(l){if(e===0){n.push(s);continue}n.push(s.subarray(e-a));continue}if(f){if(t===c){n.push(s);break}n.push(s.subarray(0,t-a));break}n.push(s)}return{bufs:n,length:t-e}}indexOf(e,t=0){if(!Eo(e)&&!(e instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=e instanceof Uint8Array?e:e.subarray();if(t=Number(t??0),isNaN(t)&&(t=0),t<0&&(t=this.length+t),t<0&&(t=0),e.length===0)return t>this.length?this.length:t;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let i=256,s=new Int32Array(i);for(let u=0;u<i;u++)s[u]=-1;for(let u=0;u<o;u++)s[n[u]]=u;let a=s,c=this.byteLength-n.byteLength,l=n.byteLength-1,f;for(let u=t;u<=c;u+=f){f=0;for(let h=l;h>=0;h--){let d=this.get(u+h);if(n[h]!==d){f=Math.max(1,h-a[d]);break}}if(f===0)return u}return-1}getInt8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getInt8(0)}setInt8(e,t){let n=Nt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,t),this.write(n,e)}getInt16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,t)}setInt16(e,t,n){let o=Ie(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,t,n),this.write(o,e)}getInt32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,t)}setInt32(e,t,n){let o=Ie(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,t,n),this.write(o,e)}getBigInt64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,t)}setBigInt64(e,t,n){let o=Ie(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,t,n),this.write(o,e)}getUint8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint8(0)}setUint8(e,t){let n=Nt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,t),this.write(n,e)}getUint16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,t)}setUint16(e,t,n){let o=Ie(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,t,n),this.write(o,e)}getUint32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,t)}setUint32(e,t,n){let o=Ie(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,t,n),this.write(o,e)}getBigUint64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,t)}setBigUint64(e,t,n){let o=Ie(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,t,n),this.write(o,e)}getFloat32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,t)}setFloat32(e,t,n){let o=Ie(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,t,n),this.write(o,e)}getFloat64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,t)}setFloat64(e,t,n){let o=Ie(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,t,n),this.write(o,e)}equals(e){if(e==null||!(e instanceof r)||e.bufs.length!==this.bufs.length)return!1;for(let t=0;t<this.bufs.length;t++)if(!me(this.bufs[t],e.bufs[t]))return!1;return!0}static fromUint8Arrays(e,t){let n=new r;return n.bufs=e,t==null&&(t=e.reduce((o,i)=>o+i.byteLength,0)),n.length=t,n}};var sw={};Dt(sw,{base10:()=>p$});var p$=ga({prefix:"9",name:"base10",alphabet:"0123456789"});var aw={};Dt(aw,{base16:()=>m$,base16upper:()=>g$});var m$=Ft({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),g$=Ft({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var cw={};Dt(cw,{base2:()=>y$});var y$=Ft({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var lw={};Dt(lw,{base256emoji:()=>E$});var uA=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}"),w$=uA.reduce((r,e,t)=>(r[t]=e,r),[]),x$=uA.reduce((r,e,t)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return r[n]=t,r},[]);function b$(r){return r.reduce((e,t)=>(e+=w$[t],e),"")}function v$(r){let e=[];for(let t of r){let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);let o=x$[n];if(o==null)throw new Error(`Non-base256emoji character: ${t}`);e.push(o)}return new Uint8Array(e)}var E$=Ku({prefix:"\u{1F680}",name:"base256emoji",encode:b$,decode:v$});var uw={};Dt(uw,{base64:()=>Zt,base64pad:()=>Oh,base64url:()=>Lc,base64urlpad:()=>S$});var Zt=Ft({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Oh=Ft({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Lc=Ft({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),S$=Ft({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var fw={};Dt(fw,{base8:()=>A$});var A$=Ft({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var dw={};Dt(dw,{identity:()=>_$});var _$=Ku({prefix:"\0",name:"identity",encode:r=>G8(r),decode:r=>W8(r)});var hs={};Dt(hs,{code:()=>lr,decode:()=>zu,encode:()=>k$,name:()=>I$});var T$=new TextEncoder,C$=new TextDecoder,I$="json",lr=512;function k$(r){return T$.encode(JSON.stringify(r))}function zu(r){return JSON.parse(C$.decode(r))}var So={};Dt(So,{code:()=>rt,decode:()=>O$,encode:()=>R$,name:()=>P$});var P$="raw",rt=85;function R$(r){return vo(r)}function O$(r){return vo(r)}var pw={};Dt(pw,{sha256:()=>At,sha512:()=>Q0});var D$=20;function ps({name:r,code:e,encode:t,minDigestLength:n,maxDigestLength:o}){return new hw(r,e,t,n,o)}var hw=class{name;code;encode;minDigestLength;maxDigestLength;constructor(e,t,n,o,i){this.name=e,this.code=t,this.encode=n,this.minDigestLength=o??D$,this.maxDigestLength=i}digest(e,t){if(t?.truncate!=null){if(t.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&t.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(e instanceof Uint8Array){let n=this.encode(e);return n instanceof Uint8Array?fA(n,this.code,t?.truncate):n.then(o=>fA(o,this.code,t?.truncate))}else throw Error("Unknown type, must be binary type")}};function fA(r,e,t){if(t!=null&&t!==r.byteLength){if(t>r.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${r.byteLength}`);r=r.subarray(0,t)}return nn(e,r)}function hA(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var At=ps({name:"sha2-256",code:18,encode:hA("SHA-256")}),Q0=ps({name:"sha2-512",code:19,encode:hA("SHA-512")});var Bc={...dw,...cw,...fw,...sw,...aw,...ew,...tw,...J8,...uw,...lw},nre={...pw,...iw};function mA(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var pA=mA("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),mw=mA("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=Nt(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),N$={utf8:pA,"utf-8":pA,hex:Bc.base16,latin1:mw,ascii:mw,binary:mw,...Bc},Z0=N$;function D(r,e="utf8"){let t=Z0[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${r}`)}function H(r,e="utf8"){let t=Z0[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.encoder.encode(r).substring(1)}var L$=parseInt("11111",2),gw=parseInt("10000000",2),B$=parseInt("01111111",2),gA={0:Dh,1:Dh,2:M$,3:$$,4:H$,5:F$,6:U$,16:Dh,22:Dh,48:Dh};function Ao(r,e={offset:0}){let t=r[e.offset]&L$;if(e.offset++,gA[t]!=null)return gA[t](r,e);throw new Error("No decoder for tag "+t)}function Nh(r,e){let t=0;if((r[e.offset]&gw)===gw){let n=r[e.offset]&B$,o="0x";e.offset++;for(let i=0;i<n;i++,e.offset++)o+=r[e.offset].toString(16).padStart(2,"0");t=parseInt(o,16)}else t=r[e.offset],e.offset++;return t}function Dh(r,e){Nh(r,e);let t=[];for(;!(e.offset>=r.byteLength);){let n=Ao(r,e);if(n===null)break;t.push(n)}return t}function M$(r,e){let t=Nh(r,e),n=e.offset,o=e.offset+t,i=[];for(let s=n;s<o;s++)s===n&&r[s]===0||i.push(r[s]);return e.offset+=t,Uint8Array.from(i)}function U$(r,e){let t=Nh(r,e),n=e.offset+t,o=r[e.offset];e.offset++;let i=0,s=0;o<40?(i=0,s=o):o<80?(i=1,s=o-40):(i=2,s=o-80);let a=`${i}.${s}`,c=[];for(;e.offset<n;){let l=r[e.offset];if(e.offset++,c.push(l&127),l<128){c.reverse();let f=0;for(let u=0;u<c.length;u++)f+=c[u]<<u*7;a+=`.${f}`,c=[]}}return a}function F$(r,e){return e.offset++,null}function $$(r,e){let t=Nh(r,e),n=r[e.offset];e.offset++;let o=r.subarray(e.offset,e.offset+t-1);if(e.offset+=t,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function H$(r,e){let t=Nh(r,e),n=r.subarray(e.offset,e.offset+t);return e.offset+=t,n}function K$(r){let e=r.toString(16);e.length%2===1&&(e="0"+e);let t=new se;for(let n=0;n<e.length;n+=2)t.append(Uint8Array.from([parseInt(`${e[n]}${e[n+1]}`,16)]));return t}function J0(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let e=K$(r.byteLength);return new se(Uint8Array.from([e.byteLength|gw]),e)}function on(r){let e=new se,t=128;return(r.subarray()[0]&t)===t&&e.append(Uint8Array.from([0])),e.append(r),new se(Uint8Array.from([2]),J0(e),e)}function Lh(r){let e=Uint8Array.from([0]),t=new se(e,r);return new se(Uint8Array.from([3]),J0(t),t)}function yA(r){return new se(Uint8Array.from([4]),J0(r),r)}function Zo(r,e=48){let t=new se;for(let n of r)t.append(n);return new se(Uint8Array.from([e]),J0(t),t)}var wA="1.2.840.10045.3.1.7",xA="1.3.132.0.34",bA="1.3.132.0.35";async function vA(r="P-256"){let e=await crypto.subtle.generateKey({name:"ECDSA",namedCurve:r},!0,["sign","verify"]);return{publicKey:await crypto.subtle.exportKey("jwk",e.publicKey),privateKey:await crypto.subtle.exportKey("jwk",e.privateKey)}}async function EA(r,e,t){let n=await crypto.subtle.importKey("jwk",r,{name:"ECDSA",namedCurve:r.crv??"P-256"},!1,["sign"]);t?.signal?.throwIfAborted();let o=await crypto.subtle.sign({name:"ECDSA",hash:{name:"SHA-256"}},n,e.subarray());return t?.signal?.throwIfAborted(),new Uint8Array(o,0,o.byteLength)}async function SA(r,e,t,n){let o=await crypto.subtle.importKey("jwk",r,{name:"ECDSA",namedCurve:r.crv??"P-256"},!1,["verify"]);n?.signal?.throwIfAborted();let i=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},o,e,t.subarray());return n?.signal?.throwIfAborted(),i}var V$=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),q$=Uint8Array.from([6,5,43,129,4,0,34]),z$=Uint8Array.from([6,5,43,129,4,0,35]),AA={ext:!0,kty:"EC",crv:"P-256"},_A={ext:!0,kty:"EC",crv:"P-384"},TA={ext:!0,kty:"EC",crv:"P-521"},ju=32,Wu=48,Gu=66;function CA(r){let e=Ao(r);return yw(e)}function yw(r){let e=r[1],t=H(e,"base64url"),n=r[2][1][0],o=1,i,s;if(e.byteLength===ju)return i=H(n.subarray(o,o+ju),"base64url"),s=H(n.subarray(o+ju),"base64url"),new Uc({...AA,key_ops:["sign"],d:t,x:i,y:s});if(e.byteLength===Wu)return i=H(n.subarray(o,o+Wu),"base64url"),s=H(n.subarray(o+Wu),"base64url"),new Uc({..._A,key_ops:["sign"],d:t,x:i,y:s});if(e.byteLength===Gu)return i=H(n.subarray(o,o+Gu),"base64url"),s=H(n.subarray(o+Gu),"base64url"),new Uc({...TA,key_ops:["sign"],d:t,x:i,y:s});throw new O(`Private key length was wrong length, got ${e.byteLength}, expected 32, 48 or 66`)}function ww(r){let e=Ao(r);return IA(e)}function IA(r){let e=r[1][1][0],t=1,n,o;if(e.byteLength===ju*2+1)return n=H(e.subarray(t,t+ju),"base64url"),o=H(e.subarray(t+ju),"base64url"),new Mc({...AA,key_ops:["verify"],x:n,y:o});if(e.byteLength===Wu*2+1)return n=H(e.subarray(t,t+Wu),"base64url"),o=H(e.subarray(t+Wu),"base64url"),new Mc({..._A,key_ops:["verify"],x:n,y:o});if(e.byteLength===Gu*2+1)return n=H(e.subarray(t,t+Gu),"base64url"),o=H(e.subarray(t+Gu),"base64url"),new Mc({...TA,key_ops:["verify"],x:n,y:o});throw new O(`coordinates were wrong length, got ${e.byteLength}, expected 65, 97 or 133`)}function kA(r){return Zo([on(Uint8Array.from([1])),yA(D(r.d??"","base64url")),Zo([RA(r.crv)],160),Zo([Lh(new se(Uint8Array.from([4]),D(r.x??"","base64url"),D(r.y??"","base64url")))],161)]).subarray()}function PA(r){return Zo([on(Uint8Array.from([1])),Zo([RA(r.crv)],160),Zo([Lh(new se(Uint8Array.from([4]),D(r.x??"","base64url"),D(r.y??"","base64url")))],161)]).subarray()}function RA(r){if(r==="P-256")return V$;if(r==="P-384")return q$;if(r==="P-521")return z$;throw new O(`Invalid curve ${r}`)}async function OA(r="P-256"){let e=await vA(r);return new Uc(e.privateKey)}var Mc=class{type="ECDSA";jwk;_raw;constructor(e){this.jwk=e}get raw(){return this._raw==null&&(this._raw=PA(this.jwk)),this._raw}toMultihash(){return $t.digest(yr(this))}toCID(){return Z.createV1(114,this.toMultihash())}toString(){return Qe.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:me(this.raw,e.raw)}async verify(e,t,n){return SA(this.jwk,t,e,n)}},Uc=class{type="ECDSA";jwk;publicKey;_raw;constructor(e){this.jwk=e,this.publicKey=new Mc({crv:e.crv,ext:e.ext,key_ops:["verify"],kty:"EC",x:e.x,y:e.y})}get raw(){return this._raw==null&&(this._raw=kA(this.jwk)),this._raw}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:me(this.raw,e.raw)}async sign(e,t){return EA(this.jwk,e,t)}};function Fc(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function qr(r,e=""){if(!Number.isSafeInteger(r)||r<0){let t=e&&`"${e}" `;throw new Error(`${t}expected integer >= 0, got ${r}`)}}function ke(r,e,t=""){let n=Fc(r),o=r?.length,i=e!==void 0;if(!n||i&&o!==e){let s=t&&`"${t}" `,a=i?` of length ${e}`:"",c=n?`length=${o}`:`type=${typeof r}`;throw new Error(s+"expected Uint8Array"+a+", got "+c)}return r}function gs(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash must wrapped by utils.createHasher");qr(r.outputLen),qr(r.blockLen)}function Xu(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function NA(r,e){ke(r,void 0,"digestInto() output");let t=e.outputLen;if(r.length<t)throw new Error('"digestInto() output" expected to be of length >='+t)}function zr(...r){for(let e=0;e<r.length;e++)r[e].fill(0)}function $c(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function Jo(r,e){return r<<32-e|r>>>e}function eg(r,e){return r<<e|r>>>32-e>>>0}var LA=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",j$=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function ys(r){if(ke(r),LA)return r.toHex();let e="";for(let t=0;t<r.length;t++)e+=j$[r[t]];return e}var ms={_0:48,_9:57,A:65,F:70,a:97,f:102};function DA(r){if(r>=ms._0&&r<=ms._9)return r-ms._0;if(r>=ms.A&&r<=ms.F)return r-(ms.A-10);if(r>=ms.a&&r<=ms.f)return r-(ms.a-10)}function ws(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);if(LA)return Uint8Array.fromHex(r);let e=r.length,t=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(t);for(let o=0,i=0;o<t;o++,i+=2){let s=DA(r.charCodeAt(i)),a=DA(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}var W$=async()=>{};async function BA(r,e,t){let n=Date.now();for(let o=0;o<r;o++){t(o);let i=Date.now()-n;i>=0&&i<e||(await W$(),n+=i)}}function G$(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}function xw(r,e=""){return typeof r=="string"?G$(r):ke(r,void 0,e)}function Sn(...r){let e=0;for(let n=0;n<r.length;n++){let o=r[n];ke(o),e+=o.length}let t=new Uint8Array(e);for(let n=0,o=0;n<r.length;n++){let i=r[n];t.set(i,o),o+=i.length}return t}function MA(r,e){if(e!==void 0&&{}.toString.call(e)!=="[object Object]")throw new Error("options must be object or undefined");return Object.assign(r,e)}function Bh(r,e={}){let t=(o,i)=>r(i).update(o).digest(),n=r(void 0);return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=o=>r(o),Object.assign(t,e),Object.freeze(t)}function ki(r=32){let e=typeof globalThis=="object"?globalThis.crypto:null;if(typeof e?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");return e.getRandomValues(new Uint8Array(r))}var bw=r=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,r])});function tg(r,e,t){return r&e^~r&t}function rg(r,e,t){return r&e^r&t^e&t}var Hc=class{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,n,o){this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(e),this.view=$c(this.buffer)}update(e){Xu(this),ke(e);let{view:t,buffer:n,blockLen:o}=this,i=e.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let c=$c(e);for(;o<=i-s;s+=o)this.process(c,s);continue}n.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Xu(this),NA(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;t[s++]=128,zr(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(n,0),s=0);for(let u=s;u<o;u++)t[u]=0;n.setBigUint64(o-8,BigInt(this.length*8),i),this.process(n,0);let a=$c(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let l=c/4,f=this.get();if(l>f.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<l;u++)a.setUint32(4*u,f[u],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:n,length:o,finished:i,destroyed:s,pos:a}=this;return e.destroyed=s,e.finished=i,e.length=o,e.pos=a,o%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}},xs=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var Cr=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var ng=BigInt(4294967295),UA=BigInt(32);function X$(r,e=!1){return e?{h:Number(r&ng),l:Number(r>>UA&ng)}:{h:Number(r>>UA&ng)|0,l:Number(r&ng)|0}}function FA(r,e=!1){let t=r.length,n=new Uint32Array(t),o=new Uint32Array(t);for(let i=0;i<t;i++){let{h:s,l:a}=X$(r[i],e);[n[i],o[i]]=[s,a]}return[n,o]}var vw=(r,e,t)=>r>>>t,Ew=(r,e,t)=>r<<32-t|e>>>t,Kc=(r,e,t)=>r>>>t|e<<32-t,Vc=(r,e,t)=>r<<32-t|e>>>t,Mh=(r,e,t)=>r<<64-t|e>>>t-32,Uh=(r,e,t)=>r>>>t-32|e<<64-t;function Pi(r,e,t,n){let o=(e>>>0)+(n>>>0);return{h:r+t+(o/2**32|0)|0,l:o|0}}var $A=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),HA=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,KA=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),VA=(r,e,t,n,o)=>e+t+n+o+(r/2**32|0)|0,qA=(r,e,t,n,o)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(o>>>0),zA=(r,e,t,n,o,i)=>e+t+n+o+i+(r/2**32|0)|0;var Q$=Uint32Array.from([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]),ya=new Uint32Array(64),Sw=class extends Hc{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:t,C:n,D:o,E:i,F:s,G:a,H:c}=this;return[e,t,n,o,i,s,a,c]}set(e,t,n,o,i,s,a,c){this.A=e|0,this.B=t|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(e,t){for(let u=0;u<16;u++,t+=4)ya[u]=e.getUint32(t,!1);for(let u=16;u<64;u++){let h=ya[u-15],d=ya[u-2],m=Jo(h,7)^Jo(h,18)^h>>>3,y=Jo(d,17)^Jo(d,19)^d>>>10;ya[u]=y+ya[u-7]+m+ya[u-16]|0}let{A:n,B:o,C:i,D:s,E:a,F:c,G:l,H:f}=this;for(let u=0;u<64;u++){let h=Jo(a,6)^Jo(a,11)^Jo(a,25),d=f+h+tg(a,c,l)+Q$[u]+ya[u]|0,y=(Jo(n,2)^Jo(n,13)^Jo(n,22))+rg(n,o,i)|0;f=l,l=c,c=a,a=s+d|0,s=i,i=o,o=n,n=d+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,l=l+this.G|0,f=f+this.H|0,this.set(n,o,i,s,a,c,l,f)}roundClean(){zr(ya)}destroy(){this.set(0,0,0,0,0,0,0,0),zr(this.buffer)}},Aw=class extends Sw{A=xs[0]|0;B=xs[1]|0;C=xs[2]|0;D=xs[3]|0;E=xs[4]|0;F=xs[5]|0;G=xs[6]|0;H=xs[7]|0;constructor(){super(32)}};var jA=FA(["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))),Z$=jA[0],J$=jA[1],wa=new Uint32Array(80),xa=new Uint32Array(80),_w=class extends Hc{constructor(e){super(128,e,16,!1)}get(){let{Ah:e,Al:t,Bh:n,Bl:o,Ch:i,Cl:s,Dh:a,Dl:c,Eh:l,El:f,Fh:u,Fl:h,Gh:d,Gl:m,Hh:y,Hl:w}=this;return[e,t,n,o,i,s,a,c,l,f,u,h,d,m,y,w]}set(e,t,n,o,i,s,a,c,l,f,u,h,d,m,y,w){this.Ah=e|0,this.Al=t|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=l|0,this.El=f|0,this.Fh=u|0,this.Fl=h|0,this.Gh=d|0,this.Gl=m|0,this.Hh=y|0,this.Hl=w|0}process(e,t){for(let v=0;v<16;v++,t+=4)wa[v]=e.getUint32(t),xa[v]=e.getUint32(t+=4);for(let v=16;v<80;v++){let I=wa[v-15]|0,F=xa[v-15]|0,V=Kc(I,F,1)^Kc(I,F,8)^vw(I,F,7),M=Vc(I,F,1)^Vc(I,F,8)^Ew(I,F,7),T=wa[v-2]|0,k=xa[v-2]|0,z=Kc(T,k,19)^Mh(T,k,61)^vw(T,k,6),W=Vc(T,k,19)^Uh(T,k,61)^Ew(T,k,6),$=KA(M,W,xa[v-7],xa[v-16]),S=VA($,V,z,wa[v-7],wa[v-16]);wa[v]=S|0,xa[v]=$|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:l,Dl:f,Eh:u,El:h,Fh:d,Fl:m,Gh:y,Gl:w,Hh:x,Hl:E}=this;for(let v=0;v<80;v++){let I=Kc(u,h,14)^Kc(u,h,18)^Mh(u,h,41),F=Vc(u,h,14)^Vc(u,h,18)^Uh(u,h,41),V=u&d^~u&y,M=h&m^~h&w,T=qA(E,F,M,J$[v],xa[v]),k=zA(T,x,I,V,Z$[v],wa[v]),z=T|0,W=Kc(n,o,28)^Mh(n,o,34)^Mh(n,o,39),$=Vc(n,o,28)^Uh(n,o,34)^Uh(n,o,39),S=n&i^n&a^i&a,C=o&s^o&c^s&c;x=y|0,E=w|0,y=d|0,w=m|0,d=u|0,m=h|0,{h:u,l:h}=Pi(l|0,f|0,k|0,z|0),l=a|0,f=c|0,a=i|0,c=s|0,i=n|0,s=o|0;let _=$A(z,$,C);n=HA(_,k,W,S),o=_|0}({h:n,l:o}=Pi(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=Pi(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=Pi(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:f}=Pi(this.Dh|0,this.Dl|0,l|0,f|0),{h:u,l:h}=Pi(this.Eh|0,this.El|0,u|0,h|0),{h:d,l:m}=Pi(this.Fh|0,this.Fl|0,d|0,m|0),{h:y,l:w}=Pi(this.Gh|0,this.Gl|0,y|0,w|0),{h:x,l:E}=Pi(this.Hh|0,this.Hl|0,x|0,E|0),this.set(n,o,i,s,a,c,l,f,u,h,d,m,y,w,x,E)}roundClean(){zr(wa,xa)}destroy(){zr(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},Tw=class extends _w{Ah=Cr[0]|0;Al=Cr[1]|0;Bh=Cr[2]|0;Bl=Cr[3]|0;Ch=Cr[4]|0;Cl=Cr[5]|0;Dh=Cr[6]|0;Dl=Cr[7]|0;Eh=Cr[8]|0;El=Cr[9]|0;Fh=Cr[10]|0;Fl=Cr[11]|0;Gh=Cr[12]|0;Gl=Cr[13]|0;Hh=Cr[14]|0;Hl=Cr[15]|0;constructor(){super(64)}};var _o=Bh(()=>new Aw,bw(1));var ba=Bh(()=>new Tw,bw(3));var Iw=BigInt(0),Cw=BigInt(1);function bs(r,e=""){if(typeof r!="boolean"){let t=e&&`"${e}" `;throw new Error(t+"expected boolean, got type="+typeof r)}return r}function WA(r){if(typeof r=="bigint"){if(!og(r))throw new Error("positive bigint expected, got "+r)}else qr(r);return r}function Fh(r){let e=WA(r).toString(16);return e.length&1?"0"+e:e}function GA(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?Iw:BigInt("0x"+r)}function Yu(r){return GA(ys(r))}function Ri(r){return GA(ys(qc(ke(r)).reverse()))}function ig(r,e){qr(e),r=WA(r);let t=ws(r.toString(16).padStart(e*2,"0"));if(t.length!==e)throw new Error("number too large");return t}function $h(r,e){return ig(r,e).reverse()}function qc(r){return Uint8Array.from(r)}var og=r=>typeof r=="bigint"&&Iw<=r;function eH(r,e,t){return og(r)&&og(e)&&og(t)&&e<=r&&r<t}function va(r,e,t,n){if(!eH(e,t,n))throw new Error("expected valid "+r+": "+t+" <= n < "+n+", got "+e)}function kw(r){let e;for(e=0;r>Iw;r>>=Cw,e+=1);return e}var Hh=r=>(Cw<<BigInt(r))-Cw;function XA(r,e,t){if(qr(r,"hashLen"),qr(e,"qByteLen"),typeof t!="function")throw new Error("hmacFn must be a function");let n=w=>new Uint8Array(w),o=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),a=1e3,c=n(r),l=n(r),f=0,u=()=>{c.fill(1),l.fill(0),f=0},h=(...w)=>t(l,Sn(c,...w)),d=(w=o)=>{l=h(i,w),c=h(),w.length!==0&&(l=h(s,w),c=h())},m=()=>{if(f++>=a)throw new Error("drbg: tried max amount of iterations");let w=0,x=[];for(;w<e;){c=h();let E=c.slice();x.push(E),w+=c.length}return Sn(...x)};return(w,x)=>{u(),d(w);let E;for(;!(E=x(m()));)d();return u(),E}}function Oi(r,e={},t={}){if(!r||typeof r!="object")throw new Error("expected valid options object");function n(i,s,a){let c=r[i];if(a&&c===void 0)return;let l=typeof c;if(l!==s||c===null)throw new Error(`param "${i}" is invalid: expected ${s}, got ${l}`)}let o=(i,s)=>Object.entries(i).forEach(([a,c])=>n(a,c,s));o(e,!1),o(t,!0)}function Qu(r){let e=new WeakMap;return(t,...n)=>{let o=e.get(t);if(o!==void 0)return o;let i=r(t,...n);return e.set(t,i),i}}var sn=BigInt(0),wr=BigInt(1),zc=BigInt(2),ZA=BigInt(3),JA=BigInt(4),e_=BigInt(5),tH=BigInt(7),t_=BigInt(8),rH=BigInt(9),r_=BigInt(16);function Ot(r,e){let t=r%e;return t>=sn?t:e+t}function _t(r,e,t){let n=r;for(;e-- >sn;)n*=n,n%=t;return n}function YA(r,e){if(r===sn)throw new Error("invert: expected non-zero number");if(e<=sn)throw new Error("invert: expected positive modulus, got "+e);let t=Ot(r,e),n=e,o=sn,i=wr,s=wr,a=sn;for(;t!==sn;){let l=n/t,f=n%t,u=o-s*l,h=i-a*l;n=t,t=f,o=s,i=a,s=u,a=h}if(n!==wr)throw new Error("invert: does not exist");return Ot(o,e)}function Rw(r,e,t){if(!r.eql(r.sqr(e),t))throw new Error("Cannot find square root")}function n_(r,e){let t=(r.ORDER+wr)/JA,n=r.pow(e,t);return Rw(r,n,e),n}function nH(r,e){let t=(r.ORDER-e_)/t_,n=r.mul(e,zc),o=r.pow(n,t),i=r.mul(e,o),s=r.mul(r.mul(i,zc),o),a=r.mul(i,r.sub(s,r.ONE));return Rw(r,a,e),a}function oH(r){let e=Zu(r),t=o_(r),n=t(e,e.neg(e.ONE)),o=t(e,n),i=t(e,e.neg(n)),s=(r+tH)/r_;return(a,c)=>{let l=a.pow(c,s),f=a.mul(l,n),u=a.mul(l,o),h=a.mul(l,i),d=a.eql(a.sqr(f),c),m=a.eql(a.sqr(u),c);l=a.cmov(l,f,d),f=a.cmov(h,u,m);let y=a.eql(a.sqr(f),c),w=a.cmov(l,f,y);return Rw(a,w,c),w}}function o_(r){if(r<ZA)throw new Error("sqrt is not defined for small field");let e=r-wr,t=0;for(;e%zc===sn;)e/=zc,t++;let n=zc,o=Zu(r);for(;QA(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(t===1)return n_;let i=o.pow(n,e),s=(e+wr)/zc;return function(c,l){if(c.is0(l))return l;if(QA(c,l)!==1)throw new Error("Cannot find square root");let f=t,u=c.mul(c.ONE,i),h=c.pow(l,e),d=c.pow(l,s);for(;!c.eql(h,c.ONE);){if(c.is0(h))return c.ZERO;let m=1,y=c.sqr(h);for(;!c.eql(y,c.ONE);)if(m++,y=c.sqr(y),m===f)throw new Error("Cannot find square root");let w=wr<<BigInt(f-m-1),x=c.pow(u,w);f=m,u=c.sqr(x),h=c.mul(h,u),d=c.mul(d,x)}return d}}function iH(r){return r%JA===ZA?n_:r%t_===e_?nH:r%r_===rH?oH(r):o_(r)}var i_=(r,e)=>(Ot(r,e)&wr)===wr,sH=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ow(r){let e={ORDER:"bigint",BYTES:"number",BITS:"number"},t=sH.reduce((n,o)=>(n[o]="function",n),e);return Oi(r,t),r}function aH(r,e,t){if(t<sn)throw new Error("invalid exponent, negatives unsupported");if(t===sn)return r.ONE;if(t===wr)return e;let n=r.ONE,o=e;for(;t>sn;)t&wr&&(n=r.mul(n,o)),o=r.sqr(o),t>>=wr;return n}function Kh(r,e,t=!1){let n=new Array(e.length).fill(t?r.ZERO:void 0),o=e.reduce((s,a,c)=>r.is0(a)?s:(n[c]=s,r.mul(s,a)),r.ONE),i=r.inv(o);return e.reduceRight((s,a,c)=>r.is0(a)?s:(n[c]=r.mul(s,n[c]),r.mul(s,a)),i),n}function QA(r,e){let t=(r.ORDER-wr)/zc,n=r.pow(e,t),o=r.eql(n,r.ONE),i=r.eql(n,r.ZERO),s=r.eql(n,r.neg(r.ONE));if(!o&&!i&&!s)throw new Error("invalid Legendre symbol result");return o?1:i?0:-1}function cH(r,e){e!==void 0&&qr(e);let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}var Pw=class{ORDER;BITS;BYTES;isLE;ZERO=sn;ONE=wr;_lengths;_sqrt;_mod;constructor(e,t={}){if(e<=sn)throw new Error("invalid field: expected ORDER > 0, got "+e);let n;this.isLE=!1,t!=null&&typeof t=="object"&&(typeof t.BITS=="number"&&(n=t.BITS),typeof t.sqrt=="function"&&(this.sqrt=t.sqrt),typeof t.isLE=="boolean"&&(this.isLE=t.isLE),t.allowedLengths&&(this._lengths=t.allowedLengths?.slice()),typeof t.modFromBytes=="boolean"&&(this._mod=t.modFromBytes));let{nBitLength:o,nByteLength:i}=cH(e,n);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=o,this.BYTES=i,this._sqrt=void 0,Object.preventExtensions(this)}create(e){return Ot(e,this.ORDER)}isValid(e){if(typeof e!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof e);return sn<=e&&e<this.ORDER}is0(e){return e===sn}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&wr)===wr}neg(e){return Ot(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return Ot(e*e,this.ORDER)}add(e,t){return Ot(e+t,this.ORDER)}sub(e,t){return Ot(e-t,this.ORDER)}mul(e,t){return Ot(e*t,this.ORDER)}pow(e,t){return aH(this,e,t)}div(e,t){return Ot(e*YA(t,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,t){return e+t}subN(e,t){return e-t}mulN(e,t){return e*t}inv(e){return YA(e,this.ORDER)}sqrt(e){return this._sqrt||(this._sqrt=iH(this.ORDER)),this._sqrt(this,e)}toBytes(e){return this.isLE?$h(e,this.BYTES):ig(e,this.BYTES)}fromBytes(e,t=!1){ke(e);let{_lengths:n,BYTES:o,isLE:i,ORDER:s,_mod:a}=this;if(n){if(!n.includes(e.length)||e.length>o)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+e.length);let l=new Uint8Array(o);l.set(e,i?0:l.length-e.length),e=l}if(e.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);let c=i?Ri(e):Yu(e);if(a&&(c=Ot(c,s)),!t&&!this.isValid(c))throw new Error("invalid field element: outside of range 0..ORDER");return c}invertBatch(e){return Kh(this,e)}cmov(e,t,n){return n?t:e}};function Zu(r,e={}){return new Pw(r,e)}function s_(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let e=r.toString(2).length;return Math.ceil(e/8)}function Dw(r){let e=s_(r);return e+Math.ceil(e/2)}function Nw(r,e,t=!1){ke(r);let n=r.length,o=s_(e),i=Dw(e);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=t?Ri(r):Yu(r),a=Ot(s,e-wr)+wr;return t?$h(a,o):ig(a,o)}var Ju=BigInt(0),jc=BigInt(1);function Vh(r,e){let t=e.negate();return r?t:e}function Wc(r,e){let t=Kh(r.Fp,e.map(n=>n.Z));return e.map((n,o)=>r.fromAffine(n.toAffine(t[o])))}function u_(r,e){if(!Number.isSafeInteger(r)||r<=0||r>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+r)}function Lw(r,e){u_(r,e);let t=Math.ceil(e/r)+1,n=2**(r-1),o=2**r,i=Hh(r),s=BigInt(r);return{windows:t,windowSize:n,mask:i,maxNumber:o,shiftBy:s}}function a_(r,e,t){let{windowSize:n,mask:o,maxNumber:i,shiftBy:s}=t,a=Number(r&o),c=r>>s;a>n&&(a-=i,c+=jc);let l=e*n,f=l+Math.abs(a)-1,u=a===0,h=a<0,d=e%2!==0;return{nextN:c,offset:f,isZero:u,isNeg:h,isNegF:d,offsetF:l}}var Bw=new WeakMap,f_=new WeakMap;function Mw(r){return f_.get(r)||1}function c_(r){if(r!==Ju)throw new Error("invalid wNAF")}var ef=class{BASE;ZERO;Fn;bits;constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,n=this.ZERO){let o=e;for(;t>Ju;)t&jc&&(n=n.add(o)),o=o.double(),t>>=jc;return n}precomputeWindow(e,t){let{windows:n,windowSize:o}=Lw(t,this.bits),i=[],s=e,a=s;for(let c=0;c<n;c++){a=s,i.push(a);for(let l=1;l<o;l++)a=a.add(s),i.push(a);s=a.double()}return i}wNAF(e,t,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let o=this.ZERO,i=this.BASE,s=Lw(e,this.bits);for(let a=0;a<s.windows;a++){let{nextN:c,offset:l,isZero:f,isNeg:u,isNegF:h,offsetF:d}=a_(n,a,s);n=c,f?i=i.add(Vh(h,t[d])):o=o.add(Vh(u,t[l]))}return c_(n),{p:o,f:i}}wNAFUnsafe(e,t,n,o=this.ZERO){let i=Lw(e,this.bits);for(let s=0;s<i.windows&&n!==Ju;s++){let{nextN:a,offset:c,isZero:l,isNeg:f}=a_(n,s,i);if(n=a,!l){let u=t[c];o=o.add(f?u.negate():u)}}return c_(n),o}getPrecomputes(e,t,n){let o=Bw.get(t);return o||(o=this.precomputeWindow(t,e),e!==1&&(typeof n=="function"&&(o=n(o)),Bw.set(t,o))),o}cached(e,t,n){let o=Mw(e);return this.wNAF(o,this.getPrecomputes(o,e,n),t)}unsafe(e,t,n,o){let i=Mw(e);return i===1?this._unsafeLadder(e,t,o):this.wNAFUnsafe(i,this.getPrecomputes(i,e,n),t,o)}createCache(e,t){u_(t,this.bits),f_.set(e,t),Bw.delete(e)}hasCache(e){return Mw(e)!==1}};function d_(r,e,t,n){let o=e,i=r.ZERO,s=r.ZERO;for(;t>Ju||n>Ju;)t&jc&&(i=i.add(o)),n&jc&&(s=s.add(o)),o=o.double(),t>>=jc,n>>=jc;return{p1:i,p2:s}}function l_(r,e,t){if(e){if(e.ORDER!==r)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Ow(e),e}else return Zu(r,{isLE:t})}function sg(r,e,t={},n){if(n===void 0&&(n=r==="edwards"),!e||typeof e!="object")throw new Error(`expected valid ${r} CURVE object`);for(let c of["p","n","h"]){let l=e[c];if(!(typeof l=="bigint"&&l>Ju))throw new Error(`CURVE.${c} must be positive bigint`)}let o=l_(e.p,t.Fp,n),i=l_(e.n,t.Fn,n),a=["Gx","Gy","a",r==="weierstrass"?"b":"d"];for(let c of a)if(!o.isValid(e[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:o,Fn:i}}function tf(r,e){return function(n){let o=r(n);return{secretKey:o,publicKey:e(o)}}}var Ea=BigInt(0),xr=BigInt(1),Uw=BigInt(2),lH=BigInt(8);function uH(r,e,t,n){let o=r.sqr(t),i=r.sqr(n),s=r.add(r.mul(e.a,o),i),a=r.add(r.ONE,r.mul(e.d,r.mul(o,i)));return r.eql(s,a)}function h_(r,e={}){let t=sg("edwards",r,e,e.FpFnLE),{Fp:n,Fn:o}=t,i=t.CURVE,{h:s}=i;Oi(e,{},{uvRatio:"function"});let a=Uw<<BigInt(o.BYTES*8)-xr,c=w=>n.create(w),l=e.uvRatio||((w,x)=>{try{return{isValid:!0,value:n.sqrt(n.div(w,x))}}catch{return{isValid:!1,value:Ea}}});if(!uH(n,i,i.Gx,i.Gy))throw new Error("bad curve params: generator point");function f(w,x,E=!1){let v=E?xr:Ea;return va("coordinate "+w,x,v,a),x}function u(w){if(!(w instanceof m))throw new Error("EdwardsPoint expected")}let h=Qu((w,x)=>{let{X:E,Y:v,Z:I}=w,F=w.is0();x==null&&(x=F?lH:n.inv(I));let V=c(E*x),M=c(v*x),T=n.mul(I,x);if(F)return{x:Ea,y:xr};if(T!==xr)throw new Error("invZ was invalid");return{x:V,y:M}}),d=Qu(w=>{let{a:x,d:E}=i;if(w.is0())throw new Error("bad point: ZERO");let{X:v,Y:I,Z:F,T:V}=w,M=c(v*v),T=c(I*I),k=c(F*F),z=c(k*k),W=c(M*x),$=c(k*c(W+T)),S=c(z+c(E*c(M*T)));if($!==S)throw new Error("bad point: equation left != right (1)");let C=c(v*I),_=c(F*V);if(C!==_)throw new Error("bad point: equation left != right (2)");return!0});class m{static BASE=new m(i.Gx,i.Gy,xr,c(i.Gx*i.Gy));static ZERO=new m(Ea,xr,xr,Ea);static Fp=n;static Fn=o;X;Y;Z;T;constructor(x,E,v,I){this.X=f("x",x),this.Y=f("y",E),this.Z=f("z",v,!0),this.T=f("t",I),Object.freeze(this)}static CURVE(){return i}static fromAffine(x){if(x instanceof m)throw new Error("extended point not allowed");let{x:E,y:v}=x||{};return f("x",E),f("y",v),new m(E,v,xr,c(E*v))}static fromBytes(x,E=!1){let v=n.BYTES,{a:I,d:F}=i;x=qc(ke(x,v,"point")),bs(E,"zip215");let V=qc(x),M=x[v-1];V[v-1]=M&-129;let T=Ri(V),k=E?a:n.ORDER;va("point.y",T,Ea,k);let z=c(T*T),W=c(z-xr),$=c(F*z-I),{isValid:S,value:C}=l(W,$);if(!S)throw new Error("bad point: invalid y coordinate");let _=(C&xr)===xr,B=(M&128)!==0;if(!E&&C===Ea&&B)throw new Error("bad point: x=0 and x_0=1");return B!==_&&(C=c(-C)),m.fromAffine({x:C,y:T})}static fromHex(x,E=!1){return m.fromBytes(ws(x),E)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(x=8,E=!0){return y.createCache(this,x),E||this.multiply(Uw),this}assertValidity(){d(this)}equals(x){u(x);let{X:E,Y:v,Z:I}=this,{X:F,Y:V,Z:M}=x,T=c(E*M),k=c(F*I),z=c(v*M),W=c(V*I);return T===k&&z===W}is0(){return this.equals(m.ZERO)}negate(){return new m(c(-this.X),this.Y,this.Z,c(-this.T))}double(){let{a:x}=i,{X:E,Y:v,Z:I}=this,F=c(E*E),V=c(v*v),M=c(Uw*c(I*I)),T=c(x*F),k=E+v,z=c(c(k*k)-F-V),W=T+V,$=W-M,S=T-V,C=c(z*$),_=c(W*S),B=c(z*S),X=c($*W);return new m(C,_,X,B)}add(x){u(x);let{a:E,d:v}=i,{X:I,Y:F,Z:V,T:M}=this,{X:T,Y:k,Z:z,T:W}=x,$=c(I*T),S=c(F*k),C=c(M*v*W),_=c(V*z),B=c((I+F)*(T+k)-$-S),X=_-C,G=_+C,U=c(S-E*$),Q=c(B*X),ne=c(G*U),K=c(B*U),De=c(X*G);return new m(Q,ne,De,K)}subtract(x){return this.add(x.negate())}multiply(x){if(!o.isValidNot0(x))throw new Error("invalid scalar: expected 1 <= sc < curve.n");let{p:E,f:v}=y.cached(this,x,I=>Wc(m,I));return Wc(m,[E,v])[0]}multiplyUnsafe(x,E=m.ZERO){if(!o.isValid(x))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return x===Ea?m.ZERO:this.is0()||x===xr?this:y.unsafe(this,x,v=>Wc(m,v),E)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}isTorsionFree(){return y.unsafe(this,i.n).is0()}toAffine(x){return h(this,x)}clearCofactor(){return s===xr?this:this.multiplyUnsafe(s)}toBytes(){let{x,y:E}=this.toAffine(),v=n.toBytes(E);return v[v.length-1]|=x&xr?128:0,v}toHex(){return ys(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let y=new ef(m,o.BITS);return m.BASE.precompute(8),m}function p_(r,e,t={}){if(typeof e!="function")throw new Error('"hash" function param is required');Oi(t,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});let{prehash:n}=t,{BASE:o,Fp:i,Fn:s}=r,a=t.randomBytes||ki,c=t.adjustScalarBytes||(T=>T),l=t.domain||((T,k,z)=>{if(bs(z,"phflag"),k.length||z)throw new Error("Contexts/pre-hash are not supported");return T});function f(T){return s.create(Ri(T))}function u(T){let k=v.secretKey;ke(T,v.secretKey,"secretKey");let z=ke(e(T),2*k,"hashedSecretKey"),W=c(z.slice(0,k)),$=z.slice(k,2*k),S=f(W);return{head:W,prefix:$,scalar:S}}function h(T){let{head:k,prefix:z,scalar:W}=u(T),$=o.multiply(W),S=$.toBytes();return{head:k,prefix:z,scalar:W,point:$,pointBytes:S}}function d(T){return h(T).pointBytes}function m(T=Uint8Array.of(),...k){let z=Sn(...k);return f(e(l(z,ke(T,void 0,"context"),!!n)))}function y(T,k,z={}){T=ke(T,void 0,"message"),n&&(T=n(T));let{prefix:W,scalar:$,pointBytes:S}=h(k),C=m(z.context,W,T),_=o.multiply(C).toBytes(),B=m(z.context,_,S,T),X=s.create(C+B*$);if(!s.isValid(X))throw new Error("sign failed: invalid s");let G=Sn(_,s.toBytes(X));return ke(G,v.signature,"result")}let w={zip215:!0};function x(T,k,z,W=w){let{context:$,zip215:S}=W,C=v.signature;T=ke(T,C,"signature"),k=ke(k,void 0,"message"),z=ke(z,v.publicKey,"publicKey"),S!==void 0&&bs(S,"zip215"),n&&(k=n(k));let _=C/2,B=T.subarray(0,_),X=Ri(T.subarray(_,C)),G,U,Q;try{G=r.fromBytes(z,S),U=r.fromBytes(B,S),Q=o.multiplyUnsafe(X)}catch{return!1}if(!S&&G.isSmallOrder())return!1;let ne=m($,U.toBytes(),G.toBytes(),k);return U.add(G.multiplyUnsafe(ne)).subtract(Q).clearCofactor().is0()}let E=i.BYTES,v={secretKey:E,publicKey:E,signature:2*E,seed:E};function I(T=a(v.seed)){return ke(T,v.seed,"seed")}function F(T){return Fc(T)&&T.length===s.BYTES}function V(T,k){try{return!!r.fromBytes(T,k)}catch{return!1}}let M={getExtendedPublicKey:h,randomSecretKey:I,isValidSecretKey:F,isValidPublicKey:V,toMontgomery(T){let{y:k}=r.fromBytes(T),z=v.publicKey,W=z===32;if(!W&&z!==57)throw new Error("only defined for 25519 and 448");let $=W?i.div(xr+k,xr-k):i.div(k-xr,k+xr);return i.toBytes($)},toMontgomerySecret(T){let k=v.secretKey;ke(T,k);let z=e(T.subarray(0,k));return c(z).subarray(0,k)}};return Object.freeze({keygen:tf(I,d),getPublicKey:d,sign:y,verify:x,utils:M,Point:r,lengths:v})}var qh=BigInt(0),rf=BigInt(1),ag=BigInt(2);function fH(r){return Oi(r,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze({...r})}function m_(r){let e=fH(r),{P:t,type:n,adjustScalarBytes:o,powPminus2:i,randomBytes:s}=e,a=n==="x25519";if(!a&&n!=="x448")throw new Error("invalid type");let c=s||ki,l=a?255:448,f=a?32:56,u=BigInt(a?9:5),h=BigInt(a?121665:39081),d=a?ag**BigInt(254):ag**BigInt(447),m=a?BigInt(8)*ag**BigInt(251)-rf:BigInt(4)*ag**BigInt(445)-rf,y=d+m+rf,w=C=>Ot(C,t),x=E(u);function E(C){return $h(w(C),f)}function v(C){let _=qc(ke(C,f,"uCoordinate"));return a&&(_[31]&=127),w(Ri(_))}function I(C){return Ri(o(qc(ke(C,f,"scalar"))))}function F(C,_){let B=z(v(_),I(C));if(B===qh)throw new Error("invalid private or public key received");return E(B)}function V(C){return F(C,x)}let M=V,T=F;function k(C,_,B){let X=w(C*(_-B));return _=w(_-X),B=w(B+X),{x_2:_,x_3:B}}function z(C,_){va("u",C,qh,t),va("scalar",_,d,y);let B=_,X=C,G=rf,U=qh,Q=C,ne=rf,K=qh;for(let Me=BigInt(l-1);Me>=qh;Me--){let he=B>>Me&rf;K^=he,{x_2:G,x_3:Q}=k(K,G,Q),{x_2:U,x_3:ne}=k(K,U,ne),K=he;let Ke=G+U,at=w(Ke*Ke),Pt=G-U,We=w(Pt*Pt),ct=at-We,ls=Q+ne,Go=Q-ne,fa=w(Go*Ke),U0=w(ls*Pt),Bu=fa+U0,bh=fa-U0;Q=w(Bu*Bu),ne=w(X*w(bh*bh)),G=w(at*We),U=w(ct*(at+w(h*ct)))}({x_2:G,x_3:Q}=k(K,G,Q)),{x_2:U,x_3:ne}=k(K,U,ne);let De=i(U);return w(G*De)}let W={secretKey:f,publicKey:f,seed:f},$=(C=c(f))=>(ke(C,W.seed,"seed"),C),S={randomSecretKey:$};return Object.freeze({keygen:tf($,M),getSharedSecret:T,getPublicKey:M,scalarMult:F,scalarMultBase:V,utils:S,GuBytes:x.slice(),lengths:W})}var dH=BigInt(1),g_=BigInt(2),hH=BigInt(3),pH=BigInt(5),mH=BigInt(8),cg=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),gH={p:cg,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:mH,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function w_(r){let e=BigInt(10),t=BigInt(20),n=BigInt(40),o=BigInt(80),i=cg,a=r*r%i*r%i,c=_t(a,g_,i)*a%i,l=_t(c,dH,i)*r%i,f=_t(l,pH,i)*l%i,u=_t(f,e,i)*f%i,h=_t(u,t,i)*u%i,d=_t(h,n,i)*h%i,m=_t(d,o,i)*d%i,y=_t(m,o,i)*d%i,w=_t(y,e,i)*f%i;return{pow_p_5_8:_t(w,g_,i)*r%i,b2:a}}function x_(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}var y_=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function yH(r,e){let t=cg,n=Ot(e*e*e,t),o=Ot(n*n*e,t),i=w_(r*o).pow_p_5_8,s=Ot(r*n*i,t),a=Ot(e*s*s,t),c=s,l=Ot(s*y_,t),f=a===r,u=a===Ot(-r,t),h=a===Ot(-r*y_,t);return f&&(s=c),(u||h)&&(s=l),i_(s,t)&&(s=Ot(-s,t)),{isValid:f||u,value:s}}var wH=h_(gH,{uvRatio:yH});function xH(r){return p_(wH,ba,Object.assign({adjustScalarBytes:x_},r))}var zh=xH({});var jh=(()=>{let r=cg;return m_({P:r,type:"x25519",powPminus2:e=>{let{pow_p_5_8:t,b2:n}=w_(e);return Ot(_t(t,hH,r)*n,r)},adjustScalarBytes:x_})})();var Gc=32,Xn=64,Fw=32;var nf,b_=(async()=>{try{return await Qt.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();function v_(){let r=zh.utils.randomSecretKey(),e=zh.getPublicKey(r);return{privateKey:AH(r,e),publicKey:e}}async function bH(r,e){let t;r.length===Xn?t=r.subarray(0,32):t=r;let n={crv:"Ed25519",kty:"OKP",x:H(r.subarray(32),"base64url"),d:H(t,"base64url"),ext:!0,key_ops:["sign"]},o=await Qt.get().subtle.importKey("jwk",n,{name:"Ed25519"},!0,["sign"]),i=await Qt.get().subtle.sign({name:"Ed25519"},o,e instanceof Uint8Array?e:e.subarray());return new Uint8Array(i,0,i.byteLength)}function vH(r,e){let t=r.subarray(0,Fw);return zh.sign(e instanceof Uint8Array?e:e.subarray(),t)}async function E_(r,e){return nf==null&&(nf=await b_),nf?bH(r,e):vH(r,e)}async function EH(r,e,t){if(r.buffer instanceof ArrayBuffer){let n=await Qt.get().subtle.importKey("raw",r.buffer,{name:"Ed25519"},!1,["verify"]);return await Qt.get().subtle.verify({name:"Ed25519"},n,e,t instanceof Uint8Array?t:t.subarray())}throw new TypeError("WebCrypto does not support SharedArrayBuffer for Ed25519 keys")}function SH(r,e,t){return zh.verify(e,t instanceof Uint8Array?t:t.subarray(),r)}async function S_(r,e,t){return nf==null&&(nf=await b_),nf?EH(r,e,t):SH(r,e,t)}function AH(r,e){let t=new Uint8Array(Xn);for(let n=0;n<Fw;n++)t[n]=r[n],t[Fw+n]=e[n];return t}function of(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}var Wh=class{type="Ed25519";raw;constructor(e){this.raw=af(e,Gc)}toMultihash(){return $t.digest(yr(this))}toCID(){return Z.createV1(114,this.toMultihash())}toString(){return Qe.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:me(this.raw,e.raw)}verify(e,t,n){n?.signal?.throwIfAborted();let o=S_(this.raw,t,e);return of(o)?o.then(i=>(n?.signal?.throwIfAborted(),i)):o}},sf=class{type="Ed25519";raw;publicKey;constructor(e,t){this.raw=af(e,Xn),this.publicKey=new Wh(t)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:me(this.raw,e.raw)}sign(e,t){t?.signal?.throwIfAborted();let n=E_(this.raw,e);return of(n)?n.then(o=>(t?.signal?.throwIfAborted(),o)):(t?.signal?.throwIfAborted(),n)}};function $w(r){if(r.length>Xn){r=af(r,Xn+Gc);let n=r.subarray(0,Xn),o=r.subarray(Xn,r.length);return new sf(n,o)}r=af(r,Xn);let e=r.subarray(0,Xn),t=r.subarray(Gc);return new sf(e,t)}function Hw(r){return r=af(r,Gc),new Wh(r)}async function __(){let{privateKey:r,publicKey:e}=v_();return new sf(r,e)}function af(r,e){if(r=Uint8Array.from(r??[]),r.length!==e)throw new O(`Key must be a Uint8Array of length ${e}, got ${r.length}`);return r}var _H=Math.pow(2,7),TH=Math.pow(2,14),CH=Math.pow(2,21),Kw=Math.pow(2,28),Vw=Math.pow(2,35),qw=Math.pow(2,42),zw=Math.pow(2,49),lt=128,jr=127;function Fe(r){if(r<_H)return 1;if(r<TH)return 2;if(r<CH)return 3;if(r<Kw)return 4;if(r<Vw)return 5;if(r<qw)return 6;if(r<zw)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function cf(r,e,t=0){switch(Fe(r)){case 8:e[t++]=r&255|lt,r/=128;case 7:e[t++]=r&255|lt,r/=128;case 6:e[t++]=r&255|lt,r/=128;case 5:e[t++]=r&255|lt,r/=128;case 4:e[t++]=r&255|lt,r>>>=7;case 3:e[t++]=r&255|lt,r>>>=7;case 2:e[t++]=r&255|lt,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function IH(r,e,t=0){switch(Fe(r)){case 8:e.set(t++,r&255|lt),r/=128;case 7:e.set(t++,r&255|lt),r/=128;case 6:e.set(t++,r&255|lt),r/=128;case 5:e.set(t++,r&255|lt),r/=128;case 4:e.set(t++,r&255|lt),r>>>=7;case 3:e.set(t++,r&255|lt),r>>>=7;case 2:e.set(t++,r&255|lt),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function jw(r,e){let t=r[e],n=0;if(n+=t&jr,t<lt||(t=r[e+1],n+=(t&jr)<<7,t<lt)||(t=r[e+2],n+=(t&jr)<<14,t<lt)||(t=r[e+3],n+=(t&jr)<<21,t<lt)||(t=r[e+4],n+=(t&jr)*Kw,t<lt)||(t=r[e+5],n+=(t&jr)*Vw,t<lt)||(t=r[e+6],n+=(t&jr)*qw,t<lt)||(t=r[e+7],n+=(t&jr)*zw,t<lt))return n;throw new RangeError("Could not decode varint")}function kH(r,e){let t=r.get(e),n=0;if(n+=t&jr,t<lt||(t=r.get(e+1),n+=(t&jr)<<7,t<lt)||(t=r.get(e+2),n+=(t&jr)<<14,t<lt)||(t=r.get(e+3),n+=(t&jr)<<21,t<lt)||(t=r.get(e+4),n+=(t&jr)*Kw,t<lt)||(t=r.get(e+5),n+=(t&jr)*Vw,t<lt)||(t=r.get(e+6),n+=(t&jr)*qw,t<lt)||(t=r.get(e+7),n+=(t&jr)*zw,t<lt))return n;throw new RangeError("Could not decode varint")}function Wr(r,e,t=0){return e==null&&(e=Nt(Fe(r))),e instanceof Uint8Array?cf(r,e,t):IH(r,e,t)}function Yn(r,e=0){return r instanceof Uint8Array?jw(r,e):kH(r,e)}var Ww=new Float32Array([-0]),Sa=new Uint8Array(Ww.buffer);function T_(r,e,t){Ww[0]=r,e[t]=Sa[0],e[t+1]=Sa[1],e[t+2]=Sa[2],e[t+3]=Sa[3]}function C_(r,e){return Sa[0]=r[e],Sa[1]=r[e+1],Sa[2]=r[e+2],Sa[3]=r[e+3],Ww[0]}var Gw=new Float64Array([-0]),Gr=new Uint8Array(Gw.buffer);function I_(r,e,t){Gw[0]=r,e[t]=Gr[0],e[t+1]=Gr[1],e[t+2]=Gr[2],e[t+3]=Gr[3],e[t+4]=Gr[4],e[t+5]=Gr[5],e[t+6]=Gr[6],e[t+7]=Gr[7]}function k_(r,e){return Gr[0]=r[e],Gr[1]=r[e+1],Gr[2]=r[e+2],Gr[3]=r[e+3],Gr[4]=r[e+4],Gr[5]=r[e+5],Gr[6]=r[e+6],Gr[7]=r[e+7],Gw[0]}var PH=BigInt(Number.MAX_SAFE_INTEGER),RH=BigInt(Number.MIN_SAFE_INTEGER),Qn=class r{lo;hi;constructor(e,t){this.lo=e|0,this.hi=t|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(t+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(BigInt(t)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?t===0?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return Xc;if(e<PH&&e>RH)return this.fromNumber(Number(e));let t=e<0n;t&&(e=-e);let n=e>>32n,o=e-(n<<32n);return t&&(n=~n|0n,o=~o|0n,++o>P_&&(o=0n,++n>P_&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(e){if(e===0)return Xc;let t=e<0;t&&(e=-e);let n=e>>>0,o=(e-n)/4294967296>>>0;return t&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}static from(e){return typeof e=="number"?r.fromNumber(e):typeof e=="bigint"?r.fromBigInt(e):typeof e=="string"?r.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new r(e.low>>>0,e.high>>>0):Xc}},Xc=new Qn(0,0);Xc.toBigInt=function(){return 0n};Xc.zzEncode=Xc.zzDecode=function(){return this};Xc.length=function(){return 1};var P_=4294967296n;function R_(r){let e=0,t=0;for(let n=0;n<r.length;++n)t=r.charCodeAt(n),t<128?e+=1:t<2048?e+=2:(t&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,e+=4):e+=3;return e}function O_(r,e,t){if(t-e<1)return"";let o,i=[],s=0,a;for(;e<t;)a=r[e++],a<128?i[s++]=a:a>191&&a<224?i[s++]=(a&31)<<6|r[e++]&63:a>239&&a<365?(a=((a&7)<<18|(r[e++]&63)<<12|(r[e++]&63)<<6|r[e++]&63)-65536,i[s++]=55296+(a>>10),i[s++]=56320+(a&1023)):i[s++]=(a&15)<<12|(r[e++]&63)<<6|r[e++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function Xw(r,e,t){let n=t,o,i;for(let s=0;s<r.length;++s)o=r.charCodeAt(s),o<128?e[t++]=o:o<2048?(e[t++]=o>>6|192,e[t++]=o&63|128):(o&64512)===55296&&((i=r.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,e[t++]=o>>18|240,e[t++]=o>>12&63|128,e[t++]=o>>6&63|128,e[t++]=o&63|128):(e[t++]=o>>12|224,e[t++]=o>>6&63|128,e[t++]=o&63|128);return t-n}function ei(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function lg(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}var Yw=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,ei(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw ei(this,4);return lg(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw ei(this,4);return lg(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw ei(this,4);let e=C_(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw ei(this,4);let e=k_(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),t=this.pos,n=this.pos+e;if(n>this.len)throw ei(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return O_(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw ei(this,e);this.pos+=e}else do if(this.pos>=this.len)throw ei(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new Qn(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw ei(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<t*7)>>>0,e}if(this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw ei(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw ei(this,8);let e=lg(this.buf,this.pos+=4),t=lg(this.buf,this.pos+=4);return new Qn(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=jw(this.buf,this.pos);return this.pos+=Fe(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function Qw(r){return new Yw(r instanceof Uint8Array?r:r.subarray())}function xe(r,e,t){let n=Qw(r);return e.decode(n,void 0,t)}function Zw(r){let e=r??8192,t=e>>>1,n,o=e;return function(s){if(s<1||s>t)return Nt(s);o+s>e&&(n=Nt(e),o=0);let a=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),a}}var Yc=class{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}};function Jw(){}var t7=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},OH=Zw();function DH(r){return globalThis.Buffer!=null?Nt(r):OH(r)}var Xh=class{len;head;tail;states;constructor(){this.len=0,this.head=new Yc(Jw,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new Yc(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new r7((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(ug,10,Qn.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=Qn.fromBigInt(e);return this._push(ug,t.length(),t)}uint64Number(e){return this._push(cf,Fe(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let t=Qn.fromBigInt(e).zzEncode();return this._push(ug,t.length(),t)}sint64Number(e){let t=Qn.fromNumber(e).zzEncode();return this._push(ug,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(e7,1,e?1:0)}fixed32(e){return this._push(Gh,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=Qn.fromBigInt(e);return this._push(Gh,4,t.lo)._push(Gh,4,t.hi)}fixed64Number(e){let t=Qn.fromNumber(e);return this._push(Gh,4,t.lo)._push(Gh,4,t.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(T_,4,e)}double(e){return this._push(I_,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(e7,1,0):this.uint32(t)._push(LH,t,e)}string(e){let t=R_(e);return t!==0?this.uint32(t)._push(Xw,t,e):this._push(e7,1,0)}fork(){return this.states=new t7(this),this.head=this.tail=new Yc(Jw,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 Yc(Jw,0,0),this.len=0),this}ldelim(){let e=this.head,t=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=t,this.len+=n),this}finish(){let e=this.head.next,t=DH(this.len),n=0;for(;e!=null;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}};function e7(r,e,t){e[t]=r&255}function NH(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var r7=class extends Yc{next;constructor(e,t){super(NH,e,t),this.next=void 0}};function ug(r,e,t){for(;r.hi!==0;)e[t++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)e[t++]=r.lo&127|128,r.lo=r.lo>>>7;e[t++]=r.lo}function Gh(r,e,t){e[t]=r&255,e[t+1]=r>>>8&255,e[t+2]=r>>>16&255,e[t+3]=r>>>24}function LH(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(Xh.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(BH,e,r),this},Xh.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(MH,e,r),this});function BH(r,e,t){e.set(r,t)}function MH(r,e,t){r.length<40?Xw(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(D(r),t)}function n7(){return new Xh}function be(r,e){let t=n7();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var lf;(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"})(lf||(lf={}));function fg(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function wt(r){function e(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let t=function(i,s){let a=e(i);s.int32(a)},n=function(i){let s=i.int32();return e(s)};return fg("enum",lf.VARINT,t,n)}function ve(r,e){return fg("message",lf.LENGTH_DELIMITED,r,e)}var ht=class extends Error{code="ERR_MAX_LENGTH";name="MaxLengthError"},Yh=class extends Error{code="ERR_MAX_SIZE";name="MaxSizeError"};var xt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(xt||(xt={}));var o7;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(o7||(o7={}));(function(r){r.codec=()=>wt(o7)})(xt||(xt={}));var Di;(function(r){let e;r.codec=()=>(e==null&&(e=ve((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),xt.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),o.lengthDelimited!==!1&&n.ldelim()},(t,n,o={})=>{let i={},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let a=t.uint32();switch(a>>>3){case 1:{i.Type=xt.codec().decode(t);break}case 2:{i.Data=t.bytes();break}default:{t.skipType(a&7);break}}}return i})),e),r.encode=t=>be(t,r.codec()),r.decode=(t,n)=>xe(t,r.codec(),n)})(Di||(Di={}));var Qh;(function(r){let e;r.codec=()=>(e==null&&(e=ve((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),xt.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),o.lengthDelimited!==!1&&n.ldelim()},(t,n,o={})=>{let i={},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let a=t.uint32();switch(a>>>3){case 1:{i.Type=xt.codec().decode(t);break}case 2:{i.Data=t.bytes();break}default:{t.skipType(a&7);break}}}return i})),e),r.encode=t=>be(t,r.codec()),r.decode=(t,n)=>xe(t,r.codec(),n)})(Qh||(Qh={}));function an(r){if(isNaN(r)||r<=0)throw new O("random bytes length must be a Number bigger than 0");return ki(r)}var Jh={};Dt(Jh,{MAX_RSA_KEY_SIZE:()=>i7,generateRSAKeyPair:()=>p7,jwkToJWKKeyPair:()=>M_,jwkToPkcs1:()=>HH,jwkToPkix:()=>l7,jwkToRSAPrivateKey:()=>h7,pkcs1MessageToJwk:()=>a7,pkcs1MessageToRSAPrivateKey:()=>dg,pkcs1ToJwk:()=>$H,pkcs1ToRSAPrivateKey:()=>u7,pkixMessageToJwk:()=>c7,pkixMessageToRSAPublicKey:()=>d7,pkixToJwk:()=>KH,pkixToRSAPublicKey:()=>f7});var uf=class{type="RSA";jwk;_raw;_multihash;constructor(e,t){this.jwk=e,this._multihash=t}get raw(){return this._raw==null&&(this._raw=Jh.jwkToPkix(this.jwk)),this._raw}toMultihash(){return this._multihash}toCID(){return Z.createV1(114,this._multihash)}toString(){return Qe.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:me(this.raw,e.raw)}verify(e,t,n){return B_(this.jwk,t,e,n)}},Zh=class{type="RSA";jwk;_raw;publicKey;constructor(e,t){this.jwk=e,this.publicKey=t}get raw(){return this._raw==null&&(this._raw=Jh.jwkToPkcs1(this.jwk)),this._raw}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:me(this.raw,e.raw)}sign(e,t){return L_(this.jwk,e,t)}};var i7=8192,s7=18,UH=1062,FH=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function $H(r){let e=Ao(r);return a7(e)}function a7(r){return{n:H(r[1],"base64url"),e:H(r[2],"base64url"),d:H(r[3],"base64url"),p:H(r[4],"base64url"),q:H(r[5],"base64url"),dp:H(r[6],"base64url"),dq:H(r[7],"base64url"),qi:H(r[8],"base64url"),kty:"RSA"}}function HH(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 O("JWK was missing components");return Zo([on(Uint8Array.from([0])),on(D(r.n,"base64url")),on(D(r.e,"base64url")),on(D(r.d,"base64url")),on(D(r.p,"base64url")),on(D(r.q,"base64url")),on(D(r.dp,"base64url")),on(D(r.dq,"base64url")),on(D(r.qi,"base64url"))]).subarray()}function KH(r){let e=Ao(r,{offset:0});return c7(e)}function c7(r){let e=Ao(r[1],{offset:0});return{kty:"RSA",n:H(e[0],"base64url"),e:H(e[1],"base64url")}}function l7(r){if(r.n==null||r.e==null)throw new O("JWK was missing components");return Zo([FH,Lh(Zo([on(D(r.n,"base64url")),on(D(r.e,"base64url"))]))]).subarray()}function u7(r){let e=Ao(r);return dg(e)}function dg(r){let e=a7(r);return h7(e)}function f7(r,e){if(r.byteLength>=UH)throw new fs("Key size is too large");let t=Ao(r,{offset:0});return d7(t,r,e)}function d7(r,e,t){let n=c7(r);if(t==null){let o=_o(Di.encode({Type:xt.RSA,Data:e}));t=nn(s7,o)}return new uf(n,t)}function h7(r){if(F_(r)>i7)throw new O("Key size is too large");let e=M_(r),t=_o(Di.encode({Type:xt.RSA,Data:l7(e.publicKey)})),n=nn(s7,t);return new Zh(e.privateKey,new uf(e.publicKey,n))}async function p7(r){if(r>i7)throw new O("Key size is too large");let e=await U_(r),t=_o(Di.encode({Type:xt.RSA,Data:l7(e.publicKey)})),n=nn(s7,t);return new Zh(e.privateKey,new uf(e.publicKey,n))}function M_(r){if(r==null)throw new O("Missing key parameter");return{privateKey:r,publicKey:{kty:r.kty,n:r.n,e:r.e}}}async function U_(r,e){let t=await Qt.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:r,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]);e?.signal?.throwIfAborted();let n=await VH(t,e);return{privateKey:n[0],publicKey:n[1]}}async function L_(r,e,t){let n=await Qt.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]);t?.signal?.throwIfAborted();let o=await Qt.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},n,e instanceof Uint8Array?e:e.subarray());return t?.signal?.throwIfAborted(),new Uint8Array(o,0,o.byteLength)}async function B_(r,e,t,n){let o=await Qt.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);n?.signal?.throwIfAborted();let i=await Qt.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},o,e,t instanceof Uint8Array?t:t.subarray());return n?.signal?.throwIfAborted(),i}async function VH(r,e){if(r.privateKey==null||r.publicKey==null)throw new O("Private and public key are required");let t=await Promise.all([Qt.get().subtle.exportKey("jwk",r.privateKey),Qt.get().subtle.exportKey("jwk",r.publicKey)]);return e?.signal?.throwIfAborted(),t}function F_(r){if(r.kty!=="RSA")throw new O("invalid key type");if(r.n==null)throw new O("invalid key modulus");return D(r.n,"base64url").length*8}var hg=class{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(e,t){if(gs(e),ke(t,void 0,"key"),this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,o=new Uint8Array(n);o.set(t.length>n?e.create().update(t).digest():t);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=e.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),zr(o)}update(e){return Xu(this),this.iHash.update(e),this}digestInto(e){Xu(this),ke(e,this.outputLen,"output"),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:a}=this;return e=e,e.finished=o,e.destroyed=i,e.blockLen=s,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Aa=(r,e,t)=>new hg(r,e).update(t).digest();Aa.create=(r,e)=>new hg(r,e);var $_=(r,e)=>(r+(r>=0?e:-e)/H_)/e;function qH(r,e,t){let[[n,o],[i,s]]=e,a=$_(s*r,t),c=$_(-o*r,t),l=r-a*n-c*i,f=-a*o-c*s,u=l<Es,h=f<Es;u&&(l=-l),h&&(f=-f);let d=Hh(Math.ceil(kw(t)/2))+ff;if(l<Es||l>=d||f<Es||f>=d)throw new Error("splitScalar (endomorphism): failed, k="+r);return{k1neg:u,k1:l,k2neg:h,k2:f}}function g7(r){if(!["compact","recovered","der"].includes(r))throw new Error('Signature format must be "compact", "recovered", or "der"');return r}function m7(r,e){let t={};for(let n of Object.keys(e))t[n]=r[n]===void 0?e[n]:r[n];return bs(t.lowS,"lowS"),bs(t.prehash,"prehash"),t.format!==void 0&&g7(t.format),t}var y7=class extends Error{constructor(e=""){super(e)}},_a={Err:y7,_tlv:{encode:(r,e)=>{let{Err:t}=_a;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length&1)throw new t("tlv.encode: unpadded data");let n=e.length/2,o=Fh(n);if(o.length/2&128)throw new t("tlv.encode: long form length too big");let i=n>127?Fh(o.length/2|128):"";return Fh(r)+i+o+e},decode(r,e){let{Err:t}=_a,n=0;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length<2||e[n++]!==r)throw new t("tlv.decode: wrong tlv");let o=e[n++],i=!!(o&128),s=0;if(!i)s=o;else{let c=o&127;if(!c)throw new t("tlv.decode(long): indefinite length not supported");if(c>4)throw new t("tlv.decode(long): byte length is too big");let l=e.subarray(n,n+c);if(l.length!==c)throw new t("tlv.decode: length bytes not complete");if(l[0]===0)throw new t("tlv.decode(long): zero leftmost byte");for(let f of l)s=s<<8|f;if(n+=c,s<128)throw new t("tlv.decode(long): not minimal encoding")}let a=e.subarray(n,n+s);if(a.length!==s)throw new t("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+s)}}},_int:{encode(r){let{Err:e}=_a;if(r<Es)throw new e("integer: negative integers are not allowed");let t=Fh(r);if(Number.parseInt(t[0],16)&8&&(t="00"+t),t.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return t},decode(r){let{Err:e}=_a;if(r[0]&128)throw new e("invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return Yu(r)}},toSig(r){let{Err:e,_int:t,_tlv:n}=_a,o=ke(r,void 0,"signature"),{v:i,l:s}=n.decode(48,o);if(s.length)throw new e("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,i),{v:l,l:f}=n.decode(2,c);if(f.length)throw new e("invalid signature: left bytes after parsing");return{r:t.decode(a),s:t.decode(l)}},hexFromSig(r){let{_tlv:e,_int:t}=_a,n=e.encode(2,t.encode(r.r)),o=e.encode(2,t.encode(r.s)),i=n+o;return e.encode(48,i)}},Es=BigInt(0),ff=BigInt(1),H_=BigInt(2),pg=BigInt(3),zH=BigInt(4);function K_(r,e={}){let t=sg("weierstrass",r,e),{Fp:n,Fn:o}=t,i=t.CURVE,{h:s,n:a}=i;Oi(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:c}=e;if(c&&(!n.is0(i.a)||typeof c.beta!="bigint"||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let l=q_(n,o);function f(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function u($,S,C){let{x:_,y:B}=S.toAffine(),X=n.toBytes(_);if(bs(C,"isCompressed"),C){f();let G=!n.isOdd(B);return Sn(V_(G),X)}else return Sn(Uint8Array.of(4),X,n.toBytes(B))}function h($){ke($,void 0,"Point");let{publicKey:S,publicKeyUncompressed:C}=l,_=$.length,B=$[0],X=$.subarray(1);if(_===S&&(B===2||B===3)){let G=n.fromBytes(X);if(!n.isValid(G))throw new Error("bad point: is not on curve, wrong x");let U=y(G),Q;try{Q=n.sqrt(U)}catch(De){let Me=De instanceof Error?": "+De.message:"";throw new Error("bad point: is not on curve, sqrt error"+Me)}f();let ne=n.isOdd(Q);return(B&1)===1!==ne&&(Q=n.neg(Q)),{x:G,y:Q}}else if(_===C&&B===4){let G=n.BYTES,U=n.fromBytes(X.subarray(0,G)),Q=n.fromBytes(X.subarray(G,G*2));if(!w(U,Q))throw new Error("bad point: is not on curve");return{x:U,y:Q}}else throw new Error(`bad point: got length ${_}, expected compressed=${S} or uncompressed=${C}`)}let d=e.toBytes||u,m=e.fromBytes||h;function y($){let S=n.sqr($),C=n.mul(S,$);return n.add(n.add(C,n.mul($,i.a)),i.b)}function w($,S){let C=n.sqr(S),_=y($);return n.eql(C,_)}if(!w(i.Gx,i.Gy))throw new Error("bad curve params: generator point");let x=n.mul(n.pow(i.a,pg),zH),E=n.mul(n.sqr(i.b),BigInt(27));if(n.is0(n.add(x,E)))throw new Error("bad curve params: a or b");function v($,S,C=!1){if(!n.isValid(S)||C&&n.is0(S))throw new Error(`bad point coordinate ${$}`);return S}function I($){if(!($ instanceof k))throw new Error("Weierstrass Point expected")}function F($){if(!c||!c.basises)throw new Error("no endo");return qH($,c.basises,o.ORDER)}let V=Qu(($,S)=>{let{X:C,Y:_,Z:B}=$;if(n.eql(B,n.ONE))return{x:C,y:_};let X=$.is0();S==null&&(S=X?n.ONE:n.inv(B));let G=n.mul(C,S),U=n.mul(_,S),Q=n.mul(B,S);if(X)return{x:n.ZERO,y:n.ZERO};if(!n.eql(Q,n.ONE))throw new Error("invZ was invalid");return{x:G,y:U}}),M=Qu($=>{if($.is0()){if(e.allowInfinityPoint&&!n.is0($.Y))return;throw new Error("bad point: ZERO")}let{x:S,y:C}=$.toAffine();if(!n.isValid(S)||!n.isValid(C))throw new Error("bad point: x or y not field elements");if(!w(S,C))throw new Error("bad point: equation left != right");if(!$.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function T($,S,C,_,B){return C=new k(n.mul(C.X,$),C.Y,C.Z),S=Vh(_,S),C=Vh(B,C),S.add(C)}class k{static BASE=new k(i.Gx,i.Gy,n.ONE);static ZERO=new k(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=o;X;Y;Z;constructor(S,C,_){this.X=v("x",S),this.Y=v("y",C,!0),this.Z=v("z",_),Object.freeze(this)}static CURVE(){return i}static fromAffine(S){let{x:C,y:_}=S||{};if(!S||!n.isValid(C)||!n.isValid(_))throw new Error("invalid affine point");if(S instanceof k)throw new Error("projective point not allowed");return n.is0(C)&&n.is0(_)?k.ZERO:new k(C,_,n.ONE)}static fromBytes(S){let C=k.fromAffine(m(ke(S,void 0,"point")));return C.assertValidity(),C}static fromHex(S){return k.fromBytes(ws(S))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(S=8,C=!0){return W.createCache(this,S),C||this.multiply(pg),this}assertValidity(){M(this)}hasEvenY(){let{y:S}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(S)}equals(S){I(S);let{X:C,Y:_,Z:B}=this,{X,Y:G,Z:U}=S,Q=n.eql(n.mul(C,U),n.mul(X,B)),ne=n.eql(n.mul(_,U),n.mul(G,B));return Q&&ne}negate(){return new k(this.X,n.neg(this.Y),this.Z)}double(){let{a:S,b:C}=i,_=n.mul(C,pg),{X:B,Y:X,Z:G}=this,U=n.ZERO,Q=n.ZERO,ne=n.ZERO,K=n.mul(B,B),De=n.mul(X,X),Me=n.mul(G,G),he=n.mul(B,X);return he=n.add(he,he),ne=n.mul(B,G),ne=n.add(ne,ne),U=n.mul(S,ne),Q=n.mul(_,Me),Q=n.add(U,Q),U=n.sub(De,Q),Q=n.add(De,Q),Q=n.mul(U,Q),U=n.mul(he,U),ne=n.mul(_,ne),Me=n.mul(S,Me),he=n.sub(K,Me),he=n.mul(S,he),he=n.add(he,ne),ne=n.add(K,K),K=n.add(ne,K),K=n.add(K,Me),K=n.mul(K,he),Q=n.add(Q,K),Me=n.mul(X,G),Me=n.add(Me,Me),K=n.mul(Me,he),U=n.sub(U,K),ne=n.mul(Me,De),ne=n.add(ne,ne),ne=n.add(ne,ne),new k(U,Q,ne)}add(S){I(S);let{X:C,Y:_,Z:B}=this,{X,Y:G,Z:U}=S,Q=n.ZERO,ne=n.ZERO,K=n.ZERO,De=i.a,Me=n.mul(i.b,pg),he=n.mul(C,X),Ke=n.mul(_,G),at=n.mul(B,U),Pt=n.add(C,_),We=n.add(X,G);Pt=n.mul(Pt,We),We=n.add(he,Ke),Pt=n.sub(Pt,We),We=n.add(C,B);let ct=n.add(X,U);return We=n.mul(We,ct),ct=n.add(he,at),We=n.sub(We,ct),ct=n.add(_,B),Q=n.add(G,U),ct=n.mul(ct,Q),Q=n.add(Ke,at),ct=n.sub(ct,Q),K=n.mul(De,We),Q=n.mul(Me,at),K=n.add(Q,K),Q=n.sub(Ke,K),K=n.add(Ke,K),ne=n.mul(Q,K),Ke=n.add(he,he),Ke=n.add(Ke,he),at=n.mul(De,at),We=n.mul(Me,We),Ke=n.add(Ke,at),at=n.sub(he,at),at=n.mul(De,at),We=n.add(We,at),he=n.mul(Ke,We),ne=n.add(ne,he),he=n.mul(ct,We),Q=n.mul(Pt,Q),Q=n.sub(Q,he),he=n.mul(Pt,Ke),K=n.mul(ct,K),K=n.add(K,he),new k(Q,ne,K)}subtract(S){return this.add(S.negate())}is0(){return this.equals(k.ZERO)}multiply(S){let{endo:C}=e;if(!o.isValidNot0(S))throw new Error("invalid scalar: out of range");let _,B,X=G=>W.cached(this,G,U=>Wc(k,U));if(C){let{k1neg:G,k1:U,k2neg:Q,k2:ne}=F(S),{p:K,f:De}=X(U),{p:Me,f:he}=X(ne);B=De.add(he),_=T(C.beta,K,Me,G,Q)}else{let{p:G,f:U}=X(S);_=G,B=U}return Wc(k,[_,B])[0]}multiplyUnsafe(S){let{endo:C}=e,_=this;if(!o.isValid(S))throw new Error("invalid scalar: out of range");if(S===Es||_.is0())return k.ZERO;if(S===ff)return _;if(W.hasCache(this))return this.multiply(S);if(C){let{k1neg:B,k1:X,k2neg:G,k2:U}=F(S),{p1:Q,p2:ne}=d_(k,_,X,U);return T(C.beta,Q,ne,B,G)}else return W.unsafe(_,S)}toAffine(S){return V(this,S)}isTorsionFree(){let{isTorsionFree:S}=e;return s===ff?!0:S?S(k,this):W.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:S}=e;return s===ff?this:S?S(k,this):this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(S=!0){return bs(S,"isCompressed"),this.assertValidity(),d(k,this,S)}toHex(S=!0){return ys(this.toBytes(S))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let z=o.BITS,W=new ef(k,e.endo?Math.ceil(z/2):z);return k.BASE.precompute(8),k}function V_(r){return Uint8Array.of(r?2:3)}function q_(r,e){return{secretKey:e.BYTES,publicKey:1+r.BYTES,publicKeyUncompressed:1+2*r.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function jH(r,e={}){let{Fn:t}=r,n=e.randomBytes||ki,o=Object.assign(q_(r.Fp,t),{seed:Dw(t.ORDER)});function i(d){try{let m=t.fromBytes(d);return t.isValidNot0(m)}catch{return!1}}function s(d,m){let{publicKey:y,publicKeyUncompressed:w}=o;try{let x=d.length;return m===!0&&x!==y||m===!1&&x!==w?!1:!!r.fromBytes(d)}catch{return!1}}function a(d=n(o.seed)){return Nw(ke(d,o.seed,"seed"),t.ORDER)}function c(d,m=!0){return r.BASE.multiply(t.fromBytes(d)).toBytes(m)}function l(d){let{secretKey:m,publicKey:y,publicKeyUncompressed:w}=o;if(!Fc(d)||"_lengths"in t&&t._lengths||m===y)return;let x=ke(d,void 0,"key").length;return x===y||x===w}function f(d,m,y=!0){if(l(d)===!0)throw new Error("first arg must be private key");if(l(m)===!1)throw new Error("second arg must be public key");let w=t.fromBytes(d);return r.fromBytes(m).multiply(w).toBytes(y)}let u={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:a},h=tf(a,c);return Object.freeze({getPublicKey:c,getSharedSecret:f,keygen:h,Point:r,utils:u,lengths:o})}function z_(r,e,t={}){gs(e),Oi(t,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),t=Object.assign({},t);let n=t.randomBytes||ki,o=t.hmac||((C,_)=>Aa(e,C,_)),{Fp:i,Fn:s}=r,{ORDER:a,BITS:c}=s,{keygen:l,getPublicKey:f,getSharedSecret:u,utils:h,lengths:d}=jH(r,t),m={prehash:!0,lowS:typeof t.lowS=="boolean"?t.lowS:!0,format:"compact",extraEntropy:!1},y=a*H_<i.ORDER;function w(C){let _=a>>ff;return C>_}function x(C,_){if(!s.isValidNot0(_))throw new Error(`invalid signature ${C}: out of range 1..Point.Fn.ORDER`);return _}function E(){if(y)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function v(C,_){g7(_);let B=d.signature,X=_==="compact"?B:_==="recovered"?B+1:void 0;return ke(C,X)}class I{r;s;recovery;constructor(_,B,X){if(this.r=x("r",_),this.s=x("s",B),X!=null){if(E(),![0,1,2,3].includes(X))throw new Error("invalid recovery id");this.recovery=X}Object.freeze(this)}static fromBytes(_,B=m.format){v(_,B);let X;if(B==="der"){let{r:ne,s:K}=_a.toSig(ke(_));return new I(ne,K)}B==="recovered"&&(X=_[0],B="compact",_=_.subarray(1));let G=d.signature/2,U=_.subarray(0,G),Q=_.subarray(G,G*2);return new I(s.fromBytes(U),s.fromBytes(Q),X)}static fromHex(_,B){return this.fromBytes(ws(_),B)}assertRecovery(){let{recovery:_}=this;if(_==null)throw new Error("invalid recovery id: must be present");return _}addRecoveryBit(_){return new I(this.r,this.s,_)}recoverPublicKey(_){let{r:B,s:X}=this,G=this.assertRecovery(),U=G===2||G===3?B+a:B;if(!i.isValid(U))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let Q=i.toBytes(U),ne=r.fromBytes(Sn(V_((G&1)===0),Q)),K=s.inv(U),De=V(ke(_,void 0,"msgHash")),Me=s.create(-De*K),he=s.create(X*K),Ke=r.BASE.multiplyUnsafe(Me).add(ne.multiplyUnsafe(he));if(Ke.is0())throw new Error("invalid recovery: point at infinify");return Ke.assertValidity(),Ke}hasHighS(){return w(this.s)}toBytes(_=m.format){if(g7(_),_==="der")return ws(_a.hexFromSig(this));let{r:B,s:X}=this,G=s.toBytes(B),U=s.toBytes(X);return _==="recovered"?(E(),Sn(Uint8Array.of(this.assertRecovery()),G,U)):Sn(G,U)}toHex(_){return ys(this.toBytes(_))}}let F=t.bits2int||function(_){if(_.length>8192)throw new Error("input is too large");let B=Yu(_),X=_.length*8-c;return X>0?B>>BigInt(X):B},V=t.bits2int_modN||function(_){return s.create(F(_))},M=Hh(c);function T(C){return va("num < 2^"+c,C,Es,M),s.toBytes(C)}function k(C,_){return ke(C,void 0,"message"),_?ke(e(C),void 0,"prehashed message"):C}function z(C,_,B){let{lowS:X,prehash:G,extraEntropy:U}=m7(B,m);C=k(C,G);let Q=V(C),ne=s.fromBytes(_);if(!s.isValidNot0(ne))throw new Error("invalid private key");let K=[T(ne),T(Q)];if(U!=null&&U!==!1){let Ke=U===!0?n(d.secretKey):U;K.push(ke(Ke,void 0,"extraEntropy"))}let De=Sn(...K),Me=Q;function he(Ke){let at=F(Ke);if(!s.isValidNot0(at))return;let Pt=s.inv(at),We=r.BASE.multiply(at).toAffine(),ct=s.create(We.x);if(ct===Es)return;let ls=s.create(Pt*s.create(Me+ct*ne));if(ls===Es)return;let Go=(We.x===ct?0:2)|Number(We.y&ff),fa=ls;return X&&w(ls)&&(fa=s.neg(ls),Go^=1),new I(ct,fa,y?void 0:Go)}return{seed:De,k2sig:he}}function W(C,_,B={}){let{seed:X,k2sig:G}=z(C,_,B);return XA(e.outputLen,s.BYTES,o)(X,G).toBytes(B.format)}function $(C,_,B,X={}){let{lowS:G,prehash:U,format:Q}=m7(X,m);if(B=ke(B,void 0,"publicKey"),_=k(_,U),!Fc(C)){let ne=C instanceof I?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+ne)}v(C,Q);try{let ne=I.fromBytes(C,Q),K=r.fromBytes(B);if(G&&ne.hasHighS())return!1;let{r:De,s:Me}=ne,he=V(_),Ke=s.inv(Me),at=s.create(he*Ke),Pt=s.create(De*Ke),We=r.BASE.multiplyUnsafe(at).add(K.multiplyUnsafe(Pt));return We.is0()?!1:s.create(We.x)===De}catch{return!1}}function S(C,_,B={}){let{prehash:X}=m7(B,m);return _=k(_,X),I.fromBytes(C,"recovered").recoverPublicKey(_).toBytes()}return Object.freeze({keygen:l,getPublicKey:f,getSharedSecret:u,utils:h,lengths:d,Point:r,sign:W,verify:$,recoverPublicKey:S,Signature:I,hash:e})}var x7={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},WH={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var j_=BigInt(2);function GH(r){let e=x7.p,t=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),l=r*r*r%e,f=l*l*r%e,u=_t(f,t,e)*f%e,h=_t(u,t,e)*f%e,d=_t(h,j_,e)*l%e,m=_t(d,o,e)*d%e,y=_t(m,i,e)*m%e,w=_t(y,a,e)*y%e,x=_t(w,c,e)*w%e,E=_t(x,a,e)*y%e,v=_t(E,t,e)*f%e,I=_t(v,s,e)*m%e,F=_t(I,n,e)*l%e,V=_t(F,j_,e);if(!w7.eql(w7.sqr(V),r))throw new Error("Cannot find square root");return V}var w7=Zu(x7.p,{sqrt:GH}),XH=K_(x7,{Fp:w7,endo:WH}),ti=z_(XH,_o);var W_=32;function G_(r,e,t){let n=At.digest(e instanceof Uint8Array?e:e.subarray());if(of(n))return n.then(({digest:o})=>(t?.signal?.throwIfAborted(),ti.sign(o,r,{prehash:!1,format:"der"}))).catch(o=>{throw o.name==="AbortError"?o:new Ch(String(o))});try{return ti.sign(n.digest,r,{prehash:!1,format:"der"})}catch(o){throw new Ch(String(o))}}function X_(r,e,t,n){let o=At.digest(t instanceof Uint8Array?t:t.subarray());if(of(o))return o.then(({digest:i})=>(n?.signal?.throwIfAborted(),ti.verify(e,i,r,{prehash:!1,format:"der"}))).catch(i=>{throw i.name==="AbortError"?i:new Ih(String(i))});try{return n?.signal?.throwIfAborted(),ti.verify(e,o.digest,r,{prehash:!1,format:"der"})}catch(i){throw new Ih(String(i))}}var ep=class{type="secp256k1";raw;_key;constructor(e){this._key=Z_(e),this.raw=Y_(this._key)}toMultihash(){return $t.digest(yr(this))}toCID(){return Z.createV1(114,this.toMultihash())}toString(){return Qe.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:me(this.raw,e.raw)}verify(e,t,n){return X_(this._key,t,e,n)}},tp=class{type="secp256k1";raw;publicKey;constructor(e,t){this.raw=Q_(e),this.publicKey=new ep(t??J_(e))}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:me(this.raw,e.raw)}sign(e,t){return G_(this.raw,e,t)}};function b7(r){return new tp(r)}function v7(r){return new ep(r)}async function eT(){let r=YH();return new tp(r)}function Y_(r){return ti.Point.fromBytes(r).toBytes()}function Q_(r){try{return ti.getPublicKey(r,!0),r}catch(e){throw new Eh(String(e))}}function Z_(r){try{return ti.Point.fromBytes(r),r}catch(e){throw new fs(String(e))}}function J_(r){try{return ti.getPublicKey(r,!0)}catch(e){throw new Eh(String(e))}}function YH(){return ti.utils.randomSecretKey()}async function df(r,e){if(r==="Ed25519")return __();if(r==="secp256k1")return eT();if(r==="RSA")return p7(QH(e));if(r==="ECDSA")return OA(ZH(e));throw new Qo}function Wt(r,e){let{Type:t,Data:n}=Di.decode(r),o=n??new Uint8Array;switch(t){case xt.RSA:return f7(o,e);case xt.Ed25519:return Hw(o);case xt.secp256k1:return v7(o);case xt.ECDSA:return ww(o);default:throw new Qo}}function mg(r){let{Type:e,Data:t}=Di.decode(r.digest),n=t??new Uint8Array;switch(e){case xt.Ed25519:return Hw(n);case xt.secp256k1:return v7(n);case xt.ECDSA:return ww(n);default:throw new Qo}}function yr(r){return Di.encode({Type:xt[r.type],Data:r.raw})}function tT(r){let e=Qh.decode(r),t=e.Data??new Uint8Array;switch(e.Type){case xt.RSA:return u7(t);case xt.Ed25519:return $w(t);case xt.secp256k1:return b7(t);case xt.ECDSA:return CA(t);default:throw new Qo}}function rT(r){if(r.byteLength===Xn)return $w(r);if(r.byteLength===W_)return b7(r);let e=Ao(r),t=e[2]?.[0];if(t===wA||t===xA||t===bA)return yw(e);if(e.length>8)return dg(e);throw new O("Could not extract private key from raw bytes")}function Qc(r){return Qh.encode({Type:xt[r.type],Data:r.raw})}function QH(r){return r==null?2048:parseInt(r,10)}function ZH(r){if(r==="P-256"||r==null)return"P-256";if(r==="P-384")return"P-384";if(r==="P-521")return"P-521";throw new O("Unsupported curve, should be P-256, P-384 or P-521")}async function gg(r){if(r.type==="RSA")return{privateKey:await crypto.subtle.importKey("jwk",r.jwk,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),publicKey:await crypto.subtle.importKey("jwk",r.publicKey.jwk,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])};if(r.type==="ECDSA")return{privateKey:await crypto.subtle.importKey("jwk",r.jwk,{name:"ECDSA",namedCurve:r.jwk.crv??"P-256"},!0,["sign"]),publicKey:await crypto.subtle.importKey("jwk",r.publicKey.jwk,{name:"ECDSA",namedCurve:r.publicKey.jwk.crv??"P-256"},!0,["verify"])};throw new O("Only RSA and ECDSA keys are supported")}var rp=Uint32Array.from([1732584193,4023233417,2562383102,271733878,3285377520]),Ta=new Uint32Array(80),E7=class extends Hc{A=rp[0]|0;B=rp[1]|0;C=rp[2]|0;D=rp[3]|0;E=rp[4]|0;constructor(){super(64,20,8,!1)}get(){let{A:e,B:t,C:n,D:o,E:i}=this;return[e,t,n,o,i]}set(e,t,n,o,i){this.A=e|0,this.B=t|0,this.C=n|0,this.D=o|0,this.E=i|0}process(e,t){for(let c=0;c<16;c++,t+=4)Ta[c]=e.getUint32(t,!1);for(let c=16;c<80;c++)Ta[c]=eg(Ta[c-3]^Ta[c-8]^Ta[c-14]^Ta[c-16],1);let{A:n,B:o,C:i,D:s,E:a}=this;for(let c=0;c<80;c++){let l,f;c<20?(l=tg(o,i,s),f=1518500249):c<40?(l=o^i^s,f=1859775393):c<60?(l=rg(o,i,s),f=2400959708):(l=o^i^s,f=3395469782);let u=eg(n,5)+l+a+f+Ta[c]|0;a=s,s=i,i=eg(o,30),o=n,n=u}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,this.set(n,o,i,s,a)}roundClean(){zr(Ta)}destroy(){this.set(0,0,0,0,0),zr(this.buffer)}},nT=Bh(()=>new E7);function oT(r,e,t,n){gs(r);let o=MA({dkLen:32,asyncTick:10},n),{c:i,dkLen:s,asyncTick:a}=o;if(qr(i,"c"),qr(s,"dkLen"),qr(a,"asyncTick"),i<1)throw new Error("iterations (c) must be >= 1");let c=xw(e,"password"),l=xw(t,"salt"),f=new Uint8Array(s),u=Aa.create(r,c),h=u._cloneInto().update(l);return{c:i,dkLen:s,asyncTick:a,DK:f,PRF:u,PRFSalt:h}}function iT(r,e,t,n,o){return r.destroy(),e.destroy(),n&&n.destroy(),zr(o),t}function sT(r,e,t,n){let{c:o,dkLen:i,DK:s,PRF:a,PRFSalt:c}=oT(r,e,t,n),l,f=new Uint8Array(4),u=$c(f),h=new Uint8Array(a.outputLen);for(let d=1,m=0;m<i;d++,m+=a.outputLen){let y=s.subarray(m,m+a.outputLen);u.setInt32(0,d,!1),(l=c._cloneInto(l)).update(f).digestInto(h),y.set(h.subarray(0,y.length));for(let w=1;w<o;w++){a._cloneInto(l).update(h).digestInto(h);for(let x=0;x<y.length;x++)y[x]^=h[x]}}return iT(a,c,s,l,h)}async function yg(r,e,t,n){let{c:o,dkLen:i,asyncTick:s,DK:a,PRF:c,PRFSalt:l}=oT(r,e,t,n),f,u=new Uint8Array(4),h=$c(u),d=new Uint8Array(c.outputLen);for(let m=1,y=0;y<i;m++,y+=c.outputLen){let w=a.subarray(y,y+c.outputLen);h.setInt32(0,m,!1),(f=l._cloneInto(f)).update(u).digestInto(d),w.set(d.subarray(0,w.length)),await BA(o-1,s,()=>{c._cloneInto(f).update(d).digestInto(d);for(let x=0;x<w.length;x++)w[x]^=d[x]})}return iT(c,l,a,f,d)}var aT={sha1:nT,"sha2-256":_o,"sha2-512":ba};function np(r,e,t,n,o){if(o!=="sha1"&&o!=="sha2-256"&&o!=="sha2-512"){let a=Object.keys(aT).join(" / ");throw new O(`Hash '${o}' is unknown or not supported. Must be ${a}`)}let i=aT[o],s=sT(i,r,e,{c:t,dkLen:n});return Zt.encode(s).substring(1)}var S7={32:16777619n,64:1099511628211n,128:309485009821345068724781371n,256:374144419156711147060143317175368453031918731002211n,512:35835915874844867368919076489095108449946327955754392558399825615420669938882575126094039892345713852759n,1024:5016456510113118655434598811035278955030765345404790744303017523831112055108147451509157692220295382716162651878526895249385292291816524375083746691371804094271873160484737966720260389217684476157468082573n},cT={32:2166136261n,64:14695981039346656037n,128:144066263297769815596495629667062367629n,256:100029257958052580907070968620625704837092796014241193945225284501741471925557n,512:9659303129496669498009435400716310466090418745672637896108374329434462657994582932197716438449813051892206539805784495328239340083876191928701583869517785n,1024:14197795064947621068722070641403218320880622795441933960878474914617582723252296732303717722150864096521202355549365628174669108571814760471015076148029755969804077320157692458563003215304957150157403644460363550505412711285966361610267868082893823963790439336411086884584107735010676915n},lT=new globalThis.TextEncoder;function JH(r,e){let t=S7[e],n=cT[e];for(let o=0;o<r.length;o++)n^=BigInt(r[o]),n=BigInt.asUintN(e,n*t);return n}function eK(r,e,t){if(t.length===0)throw new Error("The `utf8Buffer` option must have a length greater than zero");let n=S7[e],o=cT[e],i=r;for(;i.length>0;){let s=lT.encodeInto(i,t);i=i.slice(s.read);for(let a=0;a<s.written;a++)o^=BigInt(t[a]),o=BigInt.asUintN(e,o*n)}return o}function A7(r,{size:e=32,utf8Buffer:t}={}){if(!S7[e])throw new Error("The `size` option must be one of 32, 64, 128, 256, 512, or 1024");if(typeof r=="string"){if(t)return eK(r,e,t);r=lT.encode(r)}return JH(r,e)}var op={hash:r=>Number(A7(r,{size:32})),hashV:(r,e)=>tK(op.hash(r,e))};function tK(r){let e=r.toString(16);return e.length%2===1&&(e=`0${e}`),D(e,"base16")}var _7=64,ri=class{fp;h;seed;constructor(e,t,n,o=2){if(o>_7)throw new TypeError("Invalid Fingerprint Size");let i=t.hashV(e,n),s=Ie(o);for(let a=0;a<s.length;a++)s[a]=i[a];s.length===0&&(s[0]=7),this.fp=s,this.h=t,this.seed=n}hash(){return this.h.hash(this.fp,this.seed)}equals(e){return e?.fp instanceof Uint8Array?me(this.fp,e.fp):!1}};function Zc(r,e){return Math.floor(Math.random()*(e-r))+r}var Jc=class{contents;constructor(e){this.contents=new Array(e).fill(null)}has(e){if(!(e instanceof ri))throw new TypeError("Invalid Fingerprint");return this.contents.some(t=>e.equals(t))}add(e){if(!(e instanceof ri))throw new TypeError("Invalid Fingerprint");for(let t=0;t<this.contents.length;t++)if(this.contents[t]==null)return this.contents[t]=e,!0;return!0}swap(e){if(!(e instanceof ri))throw new TypeError("Invalid Fingerprint");let t=Zc(0,this.contents.length-1),n=this.contents[t];return this.contents[t]=e,n}remove(e){if(!(e instanceof ri))throw new TypeError("Invalid Fingerprint");let t=this.contents.findIndex(n=>e.equals(n));return t>-1?(this.contents[t]=null,!0):!1}};var rK=500,ip=class{bucketSize;filterSize;fingerprintSize;buckets;count;hash;seed;constructor(e){this.filterSize=e.filterSize,this.bucketSize=e.bucketSize??4,this.fingerprintSize=e.fingerprintSize??2,this.count=0,this.buckets=[],this.hash=e.hash??op,this.seed=e.seed??Zc(0,Math.pow(2,10))}add(e){typeof e=="string"&&(e=D(e));let t=new ri(e,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(e,this.seed)%this.filterSize,o=(n^t.hash())%this.filterSize;if(this.buckets[n]==null&&(this.buckets[n]=new Jc(this.bucketSize)),this.buckets[o]==null&&(this.buckets[o]=new Jc(this.bucketSize)),this.buckets[n].add(t)||this.buckets[o].add(t))return this.count++,!0;let i=[n,o],s=i[Zc(0,i.length-1)];this.buckets[s]==null&&(this.buckets[s]=new Jc(this.bucketSize));for(let a=0;a<rK;a++){let c=this.buckets[s].swap(t);if(c!=null&&(s=(s^c.hash())%this.filterSize,this.buckets[s]==null&&(this.buckets[s]=new Jc(this.bucketSize)),this.buckets[s].add(c)))return this.count++,!0}return!1}has(e){typeof e=="string"&&(e=D(e));let t=new ri(e,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(e,this.seed)%this.filterSize,o=this.buckets[n]?.has(t)??!1;if(o)return o;let i=(n^t.hash())%this.filterSize;return this.buckets[i]?.has(t)??!1}remove(e){typeof e=="string"&&(e=D(e));let t=new ri(e,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(e,this.seed)%this.filterSize,o=this.buckets[n]?.remove(t)??!1;if(o)return this.count--,o;let i=(n^t.hash())%this.filterSize,s=this.buckets[i]?.remove(t)??!1;return s&&this.count--,s}get reliable(){return Math.floor(100*(this.count/this.filterSize))<=90}},nK={1:.5,2:.84,4:.95,8:.98};function oK(r=.001){return r>.002?2:r>1e-5?4:8}function uT(r,e=.001){let t=oK(e),n=nK[t],o=Math.round(r/n),i=Math.min(Math.ceil(Math.log2(1/e)+Math.log2(2*t)),_7);return{filterSize:o,bucketSize:t,fingerprintSize:i}}var wg=class{filterSize;bucketSize;fingerprintSize;scale;filterSeries;hash;seed;constructor(e){this.bucketSize=e.bucketSize??4,this.filterSize=e.filterSize??(1<<18)/this.bucketSize,this.fingerprintSize=e.fingerprintSize??2,this.scale=e.scale??2,this.hash=e.hash??op,this.seed=e.seed??Zc(0,Math.pow(2,10)),this.filterSeries=[new ip({filterSize:this.filterSize,bucketSize:this.bucketSize,fingerprintSize:this.fingerprintSize,hash:this.hash,seed:this.seed})]}add(e){if(typeof e=="string"&&(e=D(e)),this.has(e))return!0;let t=this.filterSeries.find(n=>n.reliable);if(t==null){let n=this.filterSize*Math.pow(this.scale,this.filterSeries.length);t=new ip({filterSize:n,bucketSize:this.bucketSize,fingerprintSize:this.fingerprintSize,hash:this.hash,seed:this.seed}),this.filterSeries.push(t)}return t.add(e)}has(e){typeof e=="string"&&(e=D(e));for(let t=0;t<this.filterSeries.length;t++)if(this.filterSeries[t].has(e))return!0;return!1}remove(e){typeof e=="string"&&(e=D(e));for(let t=0;t<this.filterSeries.length;t++)if(this.filterSeries[t].remove(e))return!0;return!1}get count(){return this.filterSeries.reduce((e,t)=>e+t.count,0)}};function br(r,e=.001,t){return new wg({...uT(r,e),...t??{}})}function Te(r){let e=r.getComponents(),t={},n=0;if(e[n]?.name==="ip6zone"&&(t.zone=`${e[n].value}`,n++),e[n].name==="ip4"||e[n].name==="ip6"||e[n].name==="dns"||e[n].name==="dns4"||e[n].name==="dns6"?(t.type=e[n].name,t.host=e[n].value,n++):e[n].name==="dnsaddr"&&(t.type=e[n].name,t.host=`_dnsaddr.${e[n].value}`,n++),(e[n]?.name==="tcp"||e[n]?.name==="udp")&&(t.protocol=e[n].name==="tcp"?"tcp":"udp",t.port=parseInt(`${e[n].value}`),n++),e[n]?.name==="ipcidr"&&(t.type==="ip4"?t.cidr=parseInt(`${e[n].value}`):t.type==="ip6"&&(t.cidr=`${e[n].value}`),n++),t.type==null||t.host==null)throw new O(`Multiaddr ${r} was not an IPv4, IPv6, DNS, DNS4, DNS6 or DNSADDR address`);return e[n]?.name==="tls"&&e[n+1]?.name==="sni"&&(t.sni=e[n+1].value,n+=2),t}var xg=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let t=this.index,n=e();return n===void 0&&(this.index=t),n}parseWith(e){let t=e();if(this.index===this.input.length)return t}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(e){return this.readAtomically(()=>{let t=this.readChar();if(t===e)return t})}readSeparator(e,t,n){return this.readAtomically(()=>{if(!(t>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,t,n,o){return this.readAtomically(()=>{let i=0,s=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",l=2**(8*o)-1;for(;;){let f=this.readAtomically(()=>{let u=this.readChar();if(u===void 0)return;let h=Number.parseInt(u,e);if(!Number.isNaN(h))return h});if(f===void 0)break;if(i*=e,i+=f,i>l||(s+=1,t!==void 0&&s>t))return}if(s!==0)return!n&&c&&s>1?void 0:i})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let t=0;t<e.length;t++){let n=this.readSeparator(".",t,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[t]=n}return e})}readIPv6Addr(){let e=t=>{for(let n=0;n<t.length/2;n++){let o=n*2;if(n<t.length-3){let s=this.readSeparator(":",n,()=>this.readIPv4Addr());if(s!==void 0)return t[o]=s[0],t[o+1]=s[1],t[o+2]=s[2],t[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];t[o]=i>>8,t[o+1]=i&255}return[t.length,!1]};return this.readAtomically(()=>{let t=new Uint8Array(16),[n,o]=e(t);if(n===16)return t;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let i=new Uint8Array(14),s=16-(n+2),[a]=e(i.subarray(0,s));return t.set(i.subarray(0,a),16-a),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var fT=45,iK=15,hf=new xg;function bg(r){if(!(r.length>iK))return hf.new(r).parseWith(()=>hf.readIPv4Addr())}function vg(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>fT))return hf.new(r).parseWith(()=>hf.readIPv6Addr())}function pf(r,e=!1){if(r.includes("%")&&(r=r.split("%")[0]),r.length>fT)return;let t=hf.new(r).parseWith(()=>hf.readIPAddr());if(t)return e&&t.length===4?Uint8Array.from([0,0,0,0,0,0,0,0,0,0,255,255,t[0],t[1],t[2],t[3]]):t}function dT(r,e,t){let n=0;for(let o of r)if(!(n<e)){if(n>t)break;if(o!==255)return!1;n++}return!0}function hT(r,e,t,n){let o=0;for(let i of r)if(!(o<t)){if(o>n)break;if(i!==e[o])return!1;o++}return!0}function T7(r){switch(r.length){case el:return r.join(".");case tl:{let e=[];for(let t=0;t<r.length;t++)t%2===0&&e.push(r[t].toString(16).padStart(2,"0")+r[t+1].toString(16).padStart(2,"0"));return e.join(":")}default:throw new Error("Invalid ip length")}}function pT(r){let e=0;for(let[t,n]of r.entries()){if(n===255){e+=8;continue}for(;(n&128)!=0;)e++,n=n<<1;if((n&128)!=0)return-1;for(let o=t+1;o<r.length;o++)if(r[o]!=0)return-1;break}return e}function mT(r){let e="0x";for(let t of r)e+=(t>>4).toString(16)+(t&15).toString(16);return e}var el=4,tl=16,ase=parseInt("0xFFFF",16),sK=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function sp(r,e){e.length===tl&&r.length===el&&dT(e,0,11)&&(e=e.slice(12)),e.length===el&&r.length===tl&&hT(r,sK,0,11)&&(r=r.slice(12));let t=r.length;if(t!=e.length)throw new Error("Failed to mask ip");let n=new Uint8Array(t);for(let o=0;o<t;o++)n[o]=r[o]&e[o];return n}function gT(r,e){if(typeof e=="string"&&(e=pf(e)),e==null)throw new Error("Invalid ip");if(e.length!==r.network.length)return!1;for(let t=0;t<e.length;t++)if((r.network[t]&r.mask[t])!==(e[t]&r.mask[t]))return!1;return!0}function C7(r){let[e,t]=r.split("/");if(!e||!t)throw new Error("Failed to parse given CIDR: "+r);let n=el,o=bg(e);if(o==null&&(n=tl,o=vg(e),o==null))throw new Error("Failed to parse given CIDR: "+r);let i=parseInt(t,10);if(Number.isNaN(i)||String(i).length!==t.length||i<0||i>n*8)throw new Error("Failed to parse given CIDR: "+r);let s=I7(i,8*n);return{network:sp(o,s),mask:s}}function I7(r,e){if(e!==8*el&&e!==8*tl)throw new Error("Invalid CIDR mask");if(r<0||r>e)throw new Error("Invalid CIDR mask");let t=e/8,n=new Uint8Array(t);for(let o=0;o<t;o++){if(r>=8){n[o]=255,r-=8;continue}n[o]=255-(255>>r),r=0}return n}var rl=class{constructor(e,t){if(t==null)({network:this.network,mask:this.mask}=C7(e));else{let n=pf(e);if(n==null)throw new Error("Failed to parse network");t=String(t);let o=parseInt(t,10);if(Number.isNaN(o)||String(o).length!==t.length||o<0||o>n.length*8){let i=pf(t);if(i==null)throw new Error("Failed to parse mask");this.mask=i}else this.mask=I7(o,8*n.length);this.network=sp(n,this.mask)}}contains(e){return gT({network:this.network,mask:this.mask},e)}toString(){let e=pT(this.mask),t=e!==-1?String(e):mT(this.mask);return T7(this.network)+"/"+t}};function yT(r,e){return new rl(r).contains(e)}function Eg(r){try{let e=Te(r);switch(e.type){case"ip6":return yT("2000::/3",e.host);default:return!1}}catch{return!1}}function wT(r){try{let e=Te(r);switch(e.type){case"ip4":return e.host.startsWith("169.254.");case"ip6":return e.host.toLowerCase().startsWith("fe80");default:return!1}}catch{return!1}}function xT(r){return/^127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(r)||/^::1$/.test(r)}function ap(r){try{let e=Te(r);switch(e.type){case"ip4":case"ip6":return xT(e.host);default:return!1}}catch{return!1}}function Ir(r){try{return Te(r),!0}catch{return!1}}function ni(r){return!!bg(r)}function Sg(r){return!!vg(r)}var vT=gt(bT(),1),aK=["0.0.0.0/8","10.0.0.0/8","100.64.0.0/10","127.0.0.0/8","169.254.0.0/16","172.16.0.0/12","192.0.0.0/24","192.0.0.0/29","192.0.0.8/32","192.0.0.9/32","192.0.0.10/32","192.0.0.170/32","192.0.0.171/32","192.0.2.0/24","192.31.196.0/24","192.52.193.0/24","192.88.99.0/24","192.168.0.0/16","192.175.48.0/24","198.18.0.0/15","198.51.100.0/24","203.0.113.0/24","240.0.0.0/4","255.255.255.255/32"],cK=aK.map(r=>new vT.Netmask(r));function k7(r){for(let e of cK)if(e.contains(r))return!0;return!1}function lK(r){return/^::ffff:([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,4})$/.test(r)}function uK(r){let e=r.split(":");if(e.length<2)return!1;let t=e[e.length-1].padStart(4,"0"),n=e[e.length-2].padStart(4,"0"),o=`${parseInt(n.substring(0,2),16)}.${parseInt(n.substring(2),16)}.${parseInt(t.substring(0,2),16)}.${parseInt(t.substring(2),16)}`;return k7(o)}function fK(r){return/^::ffff:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)}function dK(r){let e=r.split(":"),t=e[e.length-1];return k7(t)}function hK(r){return/^::$/.test(r)||/^::1$/.test(r)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(r)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(r)||/^ff([0-9a-fA-F]{2,2}):/i.test(r)}function mf(r){if(ni(r))return k7(r);if(lK(r))return uK(r);if(fK(r))return dK(r);if(Sg(r))return hK(r)}function Ht(r){try{let e=Te(r);switch(e.type){case"ip4":case"ip6":return mf(e.host)??!1;default:return e.host==="localhost"}}catch{return!1}}function He(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}var Ag=class{buffer;mask;top;btm;next;constructor(e){if(!(e>0)||(e-1&e)!==0)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return this.buffer[this.btm]===void 0}},gf=class{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new Ag(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return e?.byteLength!=null?e.byteLength:1}push(e){if(e?.value!=null&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){let t=this.head;this.head=t.next=new Ag(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next!=null){let t=this.tail.next;this.tail.next=null,this.tail=t,e=this.tail.shift()}return e?.value!=null&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}};var P7=class extends Error{type;code;constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.code=t??"ABORT_ERR"}};function ur(r={}){return pK(t=>{let n=t.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},r)}function pK(r,e){e=e??{};let t=e.onEnd,n=new gf,o,i,s,a=He(),c=async()=>{try{return n.isEmpty()?s?{done:!0}:await new Promise((w,x)=>{i=E=>{i=null,n.push(E);try{w(r(n))}catch(v){x(v)}return o}}):r(n)}finally{n.isEmpty()&&queueMicrotask(()=>{a.resolve(),a=He()})}},l=w=>i!=null?i(w):(n.push(w),o),f=w=>(n=new gf,i!=null?i({error:w}):(n.push({error:w}),o)),u=w=>{if(s)return o;if(e?.objectMode!==!0&&w?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return l({done:!1,value:w})},h=w=>s?o:(s=!0,w!=null?f(w):l({done:!0})),d=()=>(n=new gf,h(),{done:!0}),m=w=>(h(w),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:c,return:d,throw:m,push:u,end:h,get readableLength(){return n.size},onEmpty:async w=>{let x=w?.signal;if(x?.throwIfAborted(),n.isEmpty())return;let E,v;x!=null&&(E=new Promise((I,F)=>{v=()=>{F(new P7)},x.addEventListener("abort",v)}));try{await Promise.race([a.promise,E])}finally{v!=null&&x!=null&&x?.removeEventListener("abort",v)}}},t==null)return o;let y=o;return o={[Symbol.asyncIterator](){return this},next(){return y.next()},throw(w){return y.throw(w),t!=null&&(t(w),t=void 0),{done:!0}},return(){return y.return(),t!=null&&(t(),t=void 0),{done:!0}},push:u,end(w){return y.end(w),t!=null&&(t(w),t=void 0),o},get readableLength(){return y.readableLength},onEmpty:w=>y.onEmpty(w)},o}var R7=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},O7=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},ET=r=>globalThis.DOMException===void 0?new O7(r):new DOMException(r),ST=r=>{let e=r.reason===void 0?ET("This operation was aborted."):r.reason;return e instanceof Error?e:ET(e)};function D7(r,e){let{milliseconds:t,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout}}=e,s,a,l=new Promise((f,u)=>{if(typeof t!="number"||Math.sign(t)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(e.signal){let{signal:d}=e;d.aborted&&u(ST(d)),a=()=>{u(ST(d))},d.addEventListener("abort",a,{once:!0})}if(t===Number.POSITIVE_INFINITY){r.then(f,u);return}let h=new R7;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):(h.message=o??`Promise timed out after ${t} milliseconds`,u(h))},t),(async()=>{try{f(await r)}catch(d){u(d)}})()}).finally(()=>{l.clear(),a&&e.signal&&e.signal.removeEventListener("abort",a)});return l.clear=()=>{i.clearTimeout.call(void 0,s),s=void 0},l}var mK=r=>{let e=r.addEventListener||r.on||r.addListener,t=r.removeEventListener||r.off||r.removeListener;if(!e||!t)throw new TypeError("Emitter is not compatible");return{addListener:e.bind(r),removeListener:t.bind(r)}};function gK(r,e,t){let n,o=new Promise((i,s)=>{if(t={rejectionEvents:["error"],multiArgs:!1,rejectionMultiArgs:!1,resolveImmediately:!1,...t},!(t.count>=0&&(t.count===Number.POSITIVE_INFINITY||Number.isInteger(t.count))))throw new TypeError("The `count` option should be at least 0 or more");t.signal?.throwIfAborted();let a=[e].flat(),c=[],{addListener:l,removeListener:f}=mK(r),u=async(...d)=>{let m=t.multiArgs?d:d[0];if(t.filter)try{if(!await t.filter(m))return}catch(y){n(),s(y);return}c.push(m),t.count===c.length&&(n(),i(c))},h=(...d)=>{n(),s(t.rejectionMultiArgs?d:d[0])};n=()=>{for(let d of a)f(d,u);for(let d of t.rejectionEvents)a.includes(d)||f(d,h)};for(let d of a)l(d,u);for(let d of t.rejectionEvents)a.includes(d)||l(d,h);t.signal&&t.signal.addEventListener("abort",()=>{h(t.signal.reason)},{once:!0}),t.resolveImmediately&&i(c)});if(o.cancel=n,typeof t.timeout=="number"){let i=D7(o,{milliseconds:t.timeout});return i.cancel=()=>{n(),i.clear()},i}return o}function Ze(r,e,t){typeof t=="function"&&(t={filter:t}),t={...t,count:1,resolveImmediately:!1};let n=gK(r,e,t),o=n.then(i=>i[0]);return o.cancel=n.cancel,o}function Ss(r,e){let t,n=function(){let o=function(){t=void 0,r()};clearTimeout(t),t=setTimeout(o,e)};return n.start=()=>{},n.stop=()=>{clearTimeout(t)},n}var _g=class extends Error{remainingPoints;msBeforeNext;consumedPoints;isFirstInDuration;constructor(e="Rate limit exceeded",t){super(e),this.name="RateLimitError",this.remainingPoints=t.remainingPoints,this.msBeforeNext=t.msBeforeNext,this.consumedPoints=t.consumedPoints,this.isFirstInDuration=t.isFirstInDuration}},Tg=class extends Error{static name="QueueFullError";constructor(e="The queue was full"){super(e),this.name="QueueFullError"}},nl=class extends Error{static name="UnexpectedEOFError";name="UnexpectedEOFError"},Cg=class extends Error{static name="MaxEarlyStreamsError";name="MaxEarlyStreamsError"},Ig=class extends Error{static name="StreamClosedError";name="StreamClosedError"};function yK(r){return r.reason}async function nt(r,e,t){if(e==null)return r;let n=t?.translateError??yK;if(e.aborted)return r.catch(()=>{}),Promise.reject(n(e));let o;try{return await Promise.race([r,new Promise((i,s)=>{o=()=>{s(n(e))},e.addEventListener("abort",o)})])}finally{o!=null&&e.removeEventListener("abort",o)}}var kg=class{deferred;signal;constructor(e){this.signal=e,this.deferred=He(),this.onAbort=this.onAbort.bind(this),this.signal?.addEventListener("abort",this.onAbort)}onAbort(){this.deferred.reject(this.signal?.reason??new Tr)}cleanup(){this.signal?.removeEventListener("abort",this.onAbort)}};function wK(){return`${parseInt(String(Math.random()*1e9),10).toString()}${Date.now()}`}var Pg=class{id;fn;options;recipients;status;timeline;controller;constructor(e,t){this.id=wK(),this.status="queued",this.fn=e,this.options=t,this.recipients=[],this.timeline={created:Date.now()},this.controller=new AbortController,this.controller.signal,this.onAbort=this.onAbort.bind(this)}abort(e){this.controller.abort(e)}onAbort(){this.recipients.reduce((t,n)=>t&&n.signal?.aborted===!0,!0)&&(this.controller.abort(new Tr),this.cleanup())}async join(e={}){let t=new kg(e.signal);return this.recipients.push(t),e.signal?.addEventListener("abort",this.onAbort),t.deferred.promise}async run(){this.status="running",this.timeline.started=Date.now();try{this.controller.signal.throwIfAborted();let e=await nt(this.fn({...this.options??{},signal:this.controller.signal}),this.controller.signal);this.recipients.forEach(t=>{t.deferred.resolve(e)}),this.status="complete"}catch(e){this.recipients.forEach(t=>{t.deferred.reject(e)}),this.status="errored"}finally{this.timeline.finished=Date.now(),this.cleanup()}}cleanup(){this.recipients.forEach(e=>{e.cleanup(),e.signal?.removeEventListener("abort",this.onAbort)})}};var Gt=class extends _e{concurrency;maxSize;queue;pending;sort;paused;constructor(e={}){super(),this.concurrency=e.concurrency??Number.POSITIVE_INFINITY,this.maxSize=e.maxSize??Number.POSITIVE_INFINITY,this.pending=0,this.paused=!1,e.metricName!=null&&e.metrics?.registerMetricGroup(e.metricName,{calculate:()=>({size:this.queue.length,running:this.pending,queued:this.queue.length-this.pending})}),this.sort=e.sort,this.queue=[],this.emitEmpty=Ss(this.emitEmpty.bind(this),1),this.emitIdle=Ss(this.emitIdle.bind(this),1)}emitEmpty(){this.size===0&&this.safeDispatchEvent("empty")}emitIdle(){this.running===0&&this.safeDispatchEvent("idle")}pause(){this.paused=!0}resume(){this.paused&&(this.paused=!1,this.tryToStartAnother())}tryToStartAnother(){if(this.paused)return!1;if(this.size===0)return this.emitEmpty(),this.running===0&&this.emitIdle(),!1;if(this.pending<this.concurrency){let e;for(let t of this.queue)if(t.status==="queued"){e=t;break}return e==null?!1:(this.safeDispatchEvent("active"),this.pending++,e.run().finally(()=>{for(let t=0;t<this.queue.length;t++)if(this.queue[t]===e){this.queue.splice(t,1);break}this.pending--,this.tryToStartAnother(),this.safeDispatchEvent("next")}),!0)}return!1}enqueue(e){this.queue.push(e),this.sort!=null&&this.queue.sort(this.sort)}async add(e,t){if(t?.signal?.throwIfAborted(),this.size===this.maxSize)throw new Tg;let n=new Pg(e,t);return this.enqueue(n),this.safeDispatchEvent("add"),this.tryToStartAnother(),n.join(t).then(o=>(this.safeDispatchEvent("completed",{detail:o}),this.safeDispatchEvent("success",{detail:{job:n,result:o}}),o)).catch(o=>{if(n.status==="queued"){for(let i=0;i<this.queue.length;i++)if(this.queue[i]===n){this.queue.splice(i,1);break}}throw this.safeDispatchEvent("failure",{detail:{job:n,error:o}}),o})}clear(){this.queue.splice(0,this.queue.length)}abort(){this.queue.forEach(e=>{e.abort(new Tr)}),this.clear()}async onEmpty(e){this.size!==0&&await Ze(this,"empty",e)}async onSizeLessThan(e,t){this.size<e||await Ze(this,"next",{...t,filter:()=>this.size<e})}async onIdle(e){this.pending===0&&this.size===0||await Ze(this,"idle",e)}get size(){return this.queue.length}get queued(){return this.queue.length-this.pending}get running(){return this.pending}async*toGenerator(e){e?.signal?.throwIfAborted();let t=ur({objectMode:!0}),n=c=>{c!=null?this.abort():this.clear(),t.end(c)},o=c=>{c.detail!=null&&t.push(c.detail)},i=c=>{n(c.detail.error)},s=()=>{n()},a=()=>{n(new Tr("Queue aborted"))};this.addEventListener("completed",o),this.addEventListener("failure",i),this.addEventListener("idle",s),e?.signal?.addEventListener("abort",a);try{yield*t}finally{this.removeEventListener("completed",o),this.removeEventListener("failure",i),this.removeEventListener("idle",s),e?.signal?.removeEventListener("abort",a),n()}}};var xK=Math.pow(2,20)*4,Ca=class extends _e{status;timeline;inactivityTimeout;maxReadBufferLength;maxWriteBufferLength;log;direction;maxMessageSize;readStatus;writeStatus;remoteReadStatus;remoteWriteStatus;writableNeedsDrain;readBuffer;writeBuffer;sendingData;onDrainPromise;constructor(e){super(),this.status="open",this.log=e.log,this.direction=e.direction??"outbound",this.inactivityTimeout=e.inactivityTimeout??12e4,this.maxReadBufferLength=e.maxReadBufferLength??xK,this.maxWriteBufferLength=e.maxWriteBufferLength,this.maxMessageSize=e.maxMessageSize,this.readBuffer=new se,this.writeBuffer=new se,this.readStatus="readable",this.remoteReadStatus="readable",this.writeStatus="writable",this.remoteWriteStatus="writable",this.sendingData=!1,this.writableNeedsDrain=!1,this.timeline={open:Date.now()},this.processSendQueue=this.processSendQueue.bind(this);let t=()=>{this.writableNeedsDrain&&(this.log.trace("drain event received, continue sending data"),this.writableNeedsDrain=!1,this.processSendQueue()),this.onDrainPromise?.resolve()};this.addEventListener("drain",t);let n=o=>{this.onDrainPromise?.reject(o.error??new Ig)};this.addEventListener("close",n)}get readBufferLength(){return this.readBuffer.byteLength}get writeBufferLength(){return this.writeBuffer.byteLength}async onDrain(e){return this.writableNeedsDrain!==!0?Promise.resolve():(this.onDrainPromise==null&&(this.onDrainPromise=Promise.withResolvers()),nt(this.onDrainPromise.promise,e?.signal))}async*[Symbol.asyncIterator](){if(this.readStatus!=="readable"&&this.readStatus!=="paused")return;let e=ur(),t=i=>{e.push(i.data)};this.addEventListener("message",t);let n=i=>{e.end(i.error)};this.addEventListener("close",n);let o=()=>{e.end()};this.addEventListener("remoteCloseWrite",o);try{yield*e}finally{this.removeEventListener("message",t),this.removeEventListener("close",n),this.removeEventListener("remoteCloseWrite",o)}}isReadable(){return this.status==="open"}send(e){if(this.writeStatus==="closed"||this.writeStatus==="closing")throw new Ti(`Cannot write to a stream that is ${this.writeStatus}`);return this.log.trace("append %d bytes to write buffer",e.byteLength),this.writeBuffer.append(e),this.processSendQueue()}abort(e){if(!(this.status==="aborted"||this.status==="reset"||this.status==="closed")){this.log.error("abort with error - %e",e),this.status="aborted",this.readBuffer.byteLength>0&&this.readBuffer.consume(this.readBuffer.byteLength),this.writeBuffer.byteLength>0&&(this.writeBuffer.consume(this.writeBuffer.byteLength),this.safeDispatchEvent("idle")),this.writeStatus="closed",this.remoteWriteStatus="closed",this.readStatus="closed",this.remoteReadStatus="closed",this.timeline.close=Date.now();try{this.sendReset(e)}catch(t){this.log("failed to send reset to remote - %e",t)}this.dispatchEvent(new z0(e))}}pause(){if(this.readStatus==="closed"||this.readStatus==="closing")throw new Ti("Cannot pause a stream that is closing/closed");this.readStatus!=="paused"&&(this.readStatus="paused",this.sendPause())}resume(){if(this.readStatus==="closed"||this.readStatus==="closing")throw new Ti("Cannot resume a stream that is closing/closed");this.readStatus!=="readable"&&(this.readStatus="readable",this.dispatchReadBuffer(),this.sendResume())}push(e){if(this.readStatus==="closed"||this.readStatus==="closing")throw new Ti(`Cannot push data onto a stream that is ${this.readStatus}`);if(e.byteLength!==0){if(this.readBuffer.append(e),this.readStatus==="paused"||this.listenerCount("message")===0){this.checkReadBufferLength();return}setTimeout(()=>{this.dispatchReadBuffer()},0)}}unshift(e){if(this.readStatus==="closed"||this.readStatus==="closing")throw new Ti(`Cannot push data onto a stream that is ${this.readStatus}`);if(e.byteLength!==0){if(this.readBuffer.prepend(e),this.readStatus==="paused"||this.listenerCount("message")===0){this.checkReadBufferLength();return}setTimeout(()=>{this.dispatchReadBuffer()},0)}}onData(e){if(e.byteLength!==0){if(this.readStatus==="closing"||this.readStatus==="closed"){this.log("ignoring data - read status %s",this.readStatus);return}this.readBuffer.append(e),this.dispatchReadBuffer()}}addEventListener(...e){super.addEventListener.apply(this,e),e[0]==="message"&&this.readBuffer.byteLength>0&&queueMicrotask(()=>{this.dispatchReadBuffer()})}onRemoteReset(){this.log("remote reset"),this.status="reset",this.writeStatus="closed",this.remoteWriteStatus="closed",this.remoteReadStatus="closed",this.timeline.close=Date.now(),this.readBuffer.byteLength===0&&(this.readStatus="closed");let e=new Uu;this.dispatchEvent(new j0(e))}onTransportClosed(e){this.log("transport closed"),this.readStatus==="readable"&&this.readBuffer.byteLength===0&&(this.log("close readable end after transport closed and read buffer is empty"),this.readStatus="closed"),this.remoteReadStatus!=="closed"&&(this.remoteReadStatus="closed"),this.remoteWriteStatus!=="closed"&&(this.remoteWriteStatus="closed"),this.writeStatus!=="closed"&&(this.writeStatus="closed"),e!=null?this.abort(e):(this.status==="open"||this.status==="closing")&&(this.timeline.close=Date.now(),this.status="closed",this.writeStatus="closed",this.remoteWriteStatus="closed",this.remoteReadStatus="closed",this.dispatchEvent(new pa))}onRemoteCloseWrite(){this.remoteWriteStatus!=="closed"&&(this.log.trace("on remote close write"),this.remoteWriteStatus="closed",this.safeDispatchEvent("remoteCloseWrite"),this.writeStatus==="closed"&&this.onTransportClosed())}onRemoteCloseRead(){this.log.trace("on remote close read"),this.remoteReadStatus="closed",this.writeBuffer.byteLength>0&&(this.writeBuffer.consume(this.writeBuffer.byteLength),this.safeDispatchEvent("idle"))}processSendQueue(){if(this.writableNeedsDrain)return this.log.trace("not processing send queue as drain is required"),this.checkWriteBufferLength(),!1;if(this.writeBuffer.byteLength===0)return this.log.trace("not processing send queue as no bytes to send"),!0;if(this.sendingData)return this.log.trace("not processing send queue as already sending data"),!0;this.sendingData=!0,this.log.trace("processing send queue with %d queued bytes",this.writeBuffer.byteLength);try{let e=!0,t=this.writeBuffer.byteLength,n=0;for(;this.writeBuffer.byteLength>0;){let o=Math.min(this.maxMessageSize??this.writeBuffer.byteLength,this.writeBuffer.byteLength);if(o===0){e=!1;break}let i=this.writeBuffer.sublist(0,o),s=new se(i);this.writeBuffer.consume(i.byteLength);let a=this.sendData(i);if(e=a.canSendMore,n+=a.sentBytes,a.sentBytes!==s.byteLength&&(s.consume(a.sentBytes),this.writeBuffer.prepend(s)),!e)break}return e||(this.log.trace("sent %d/%d bytes, pausing sending because underlying stream is full, %d bytes left in the write buffer",n,t,this.writeBuffer.byteLength),this.writableNeedsDrain=!0,this.checkWriteBufferLength()),this.writeBuffer.byteLength===0&&this.safeDispatchEvent("idle"),e}finally{this.sendingData=!1}}dispatchReadBuffer(){try{if(this.listenerCount("message")===0){this.log.trace("not dispatching pause buffer as there are no listeners for the message event");return}if(this.readBuffer.byteLength===0){this.log.trace("not dispatching pause buffer as there is no data to dispatch");return}if(this.readStatus==="paused"){this.log.trace("not dispatching pause buffer we are paused");return}if(this.readStatus==="closing"||this.readStatus==="closed"){this.log("dropping %d bytes because the readable end is %s",this.readBuffer.byteLength,this.readStatus),this.readBuffer.consume(this.readBuffer.byteLength);return}let e=this.readBuffer.sublist();this.readBuffer.consume(e.byteLength),this.dispatchEvent(new q0(e))}finally{this.readBuffer.byteLength===0&&this.remoteWriteStatus==="closed"&&(this.log("close readable end after dispatching read buffer and remote writable end is closed"),this.readStatus="closed"),this.checkReadBufferLength()}}checkReadBufferLength(){this.readBuffer.byteLength>this.maxReadBufferLength&&this.abort(new Ah(`Read buffer length of ${this.readBuffer.byteLength} exceeded limit of ${this.maxReadBufferLength}, read status is ${this.readStatus}`))}checkWriteBufferLength(){this.maxWriteBufferLength!=null&&this.writeBuffer.byteLength>this.maxWriteBufferLength&&this.abort(new Ah(`Write buffer length of ${this.writeBuffer.byteLength} exceeded limit of ${this.maxWriteBufferLength}, write status is ${this.writeStatus}`))}onMuxerNeedsDrain(){this.writableNeedsDrain=!0}onMuxerDrain(){this.safeDispatchEvent("drain")}};var Ia=class extends Ca{remoteAddr;metricPrefix;metrics;constructor(e){super(e),this.metricPrefix=e.metricPrefix??"",this.metrics=e.metrics,this.remoteAddr=e.remoteAddr,this.addEventListener("close",t=>{this.metrics?.increment({[`${this.metricPrefix}end`]:!0}),t.error!=null?t.local?this.metrics?.increment({[`${this.metricPrefix}abort`]:!0}):this.metrics?.increment({[`${this.metricPrefix}reset`]:!0}):t.local?this.metrics?.increment({[`${this.metricPrefix}_local_close`]:!0}):this.metrics?.increment({[`${this.metricPrefix}_remote_close`]:!0})})}async close(e){this.status==="open"&&(this.status="closing",this.writeStatus="closing",this.remoteWriteStatus="closing",this.remoteReadStatus="closing",(this.sendingData||this.writeBuffer.byteLength>0)&&(this.log("waiting for write queue to become idle before closing writable end of stream, %d unsent bytes",this.writeBuffer.byteLength),await Ze(this,"idle",{...e,rejectionEvents:["close"]})),this.writableNeedsDrain&&(this.log("waiting for write queue to drain before closing writable end of stream, %d unsent bytes",this.writeBuffer.byteLength),await Ze(this,"drain",{...e,rejectionEvents:["close"]})),await this.sendClose(e),this.onTransportClosed())}};function yf(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}var ka=class extends _e{streams;protocol;status;log;maConn;streamOptions;earlyStreams;maxEarlyStreams;metrics;constructor(e,t){super(),this.maConn=e,this.protocol=t.protocol,this.streams=[],this.earlyStreams=[],this.status="open",this.log=e.log.newScope(t.name),this.streamOptions=t.streamOptions,this.maxEarlyStreams=t.maxEarlyStreams??10,this.metrics=t.metrics;let n=s=>{try{this.onData(s.data)}catch(a){this.abort(a),this.maConn.abort(a)}};this.maConn.addEventListener("message",n);let o=()=>{this.log("underlying stream drained, signal %d streams to continue writing",this.streams.length),this.streams.forEach(s=>{s.onMuxerDrain()})};this.maConn.addEventListener("drain",o);let i=()=>{this.log("underlying stream closed with status %s and %d streams",this.status,this.streams.length),this.onTransportClosed()};this.maConn.addEventListener("close",i)}send(e){let t=this.maConn.send(e);return t===!1&&(this.log("underlying stream saturated, signal %d streams to pause writing",this.streams.length),this.streams.forEach(n=>{n.onMuxerNeedsDrain()})),t}async close(e){this.status==="closed"||this.status==="closing"||(this.status="closing",await nt(Promise.all([...this.streams].map(async t=>{await t.close(e)})),e?.signal),this.status="closed")}abort(e){this.status!=="closed"&&(this.status="closing",[...this.streams].forEach(t=>{t.abort(e)}),this.status="closed")}onTransportClosed(e){this.status="closing";try{[...this.streams].forEach(t=>{t.onTransportClosed(e)})}catch(t){this.abort(t)}this.status="closed"}async createStream(e){if(this.status!=="open")throw new Yo;let t=this.onCreateStream({...this.streamOptions,...e});return yf(t)&&(t=await t),this.streams.push(t),this.cleanUpStream(t),t}onRemoteStream(e){if(this.streams.push(e),this.cleanUpStream(e),this.listenerCount("stream")===0){this.earlyStreams.push(e),this.earlyStreams.length>this.maxEarlyStreams&&this.abort(new Cg(`Too many early streams were opened - ${this.earlyStreams.length}/${this.maxEarlyStreams}`));return}this.safeDispatchEvent("stream",{detail:e})}cleanUpStream(e){let t=n=>{let o=this.streams.findIndex(i=>i===e);o!==-1&&this.streams.splice(o,1),n.error!=null?n.local?this.metrics?.increment({[`${e.direction}_stream_reset`]:!0}):this.metrics?.increment({[`${e.direction}_stream_abort`]:!0}):this.metrics?.increment({[`${e.direction}_stream_end`]:!0})};e.addEventListener("close",t),this.metrics?.increment({[`${e.direction}_stream`]:!0})}addEventListener(...e){super.addEventListener.apply(this,e),e[0]==="stream"&&this.earlyStreams.length>0&&queueMicrotask(()=>{this.earlyStreams.forEach(t=>{this.safeDispatchEvent("stream",{detail:t})}),this.earlyStreams=[]})}};var Pa=class extends Ca{id;protocol;constructor(e){super(e),this.id=e.id,this.protocol=e.protocol??""}async close(e){this.writeStatus==="closing"||this.writeStatus==="closed"||(this.writeStatus="closing",(this.sendingData||this.writeBuffer.byteLength>0)&&(this.log("waiting for write queue to become idle before closing writable end of stream, %d unsent bytes",this.writeBuffer.byteLength),await Ze(this,"idle",{...e,rejectionEvents:["close"]})),this.writableNeedsDrain&&(this.log("waiting for write queue to drain before closing writable end of stream, %d unsent bytes, sending %s",this.writeBuffer.byteLength,this.sendingData),await Ze(this,"drain",{...e,rejectionEvents:["close"]}),this.log("write queue drained, closing writable end of stream, %d unsent bytes, sending %s",this.writeBuffer.byteLength,this.sendingData)),await this.sendCloseWrite(e),this.writeStatus="closed",this.log("closed writable end gracefully"),this.remoteWriteStatus==="closed"&&this.onTransportClosed())}async closeRead(e){this.readStatus==="closing"||this.readStatus==="closed"||(this.readBuffer.byteLength>0&&this.readBuffer.consume(this.readBuffer.byteLength),this.readStatus="closing",await this.sendCloseRead(e),this.readStatus="closed",this.log("closed readable end gracefully"))}};var wf=class{movingAverage;variance;deviation;forecast;timeSpan;previousTime;constructor(e){this.timeSpan=e,this.movingAverage=0,this.variance=0,this.deviation=0,this.forecast=0}alpha(e,t){return 1-Math.exp(-(e-t)/this.timeSpan)}push(e,t=Date.now()){if(this.previousTime!=null){let n=this.alpha(t,this.previousTime),o=e-this.movingAverage,i=n*o;this.movingAverage=n*e+(1-n)*this.movingAverage,this.variance=(1-n)*(this.variance+o*i),this.deviation=Math.sqrt(this.variance),this.forecast=this.movingAverage+n*o}else this.movingAverage=e;this.previousTime=t}};var bK=1.2,vK=2,EK=5e3,SK=6e4,AK=5e3,oi=class{success;failure;next;metric;timeoutMultiplier;failureMultiplier;minTimeout;maxTimeout;constructor(e={}){let t=e.interval??AK;this.success=new wf(t),this.failure=new wf(t),this.next=new wf(t),this.failureMultiplier=e.failureMultiplier??vK,this.timeoutMultiplier=e.timeoutMultiplier??bK,this.minTimeout=e.minTimeout??EK,this.maxTimeout=e.maxTimeout??SK,e.metricName!=null&&(this.metric=e.metrics?.registerMetricGroup(e.metricName))}getTimeoutSignal(e={}){let t=Math.round(this.next.movingAverage*(e.timeoutFactor??this.timeoutMultiplier));t<this.minTimeout&&(t=this.minTimeout),t>this.maxTimeout&&(t=this.maxTimeout);let n=AbortSignal.timeout(t),o=Re([e.signal,n]);return o.start=Date.now(),o.timeout=t,o}cleanUp(e){let t=Date.now()-e.start;e.aborted?(this.failure.push(t),this.next.push(t*this.failureMultiplier),this.metric?.update({failureMovingAverage:this.failure.movingAverage,failureDeviation:this.failure.deviation,failureForecast:this.failure.forecast,failureVariance:this.failure.variance,failure:t})):(this.success.push(t),this.next.push(t),this.metric?.update({successMovingAverage:this.success.movingAverage,successDeviation:this.success.deviation,successForecast:this.success.forecast,successVariance:this.success.variance,success:t}))}};var kr=class extends Error{static name="InvalidMultiaddrError";name="InvalidMultiaddrError"},As=class extends Error{static name="ValidationError";name="ValidationError"},Rg=class extends Error{static name="InvalidParametersError";name="InvalidParametersError"},Og=class extends Error{static name="UnknownProtocolError";name="UnknownProtocolError"};function L7(r){return e=>H(e,r)}function B7(r){return e=>D(e,r)}function xf(r){return new DataView(r.buffer).getUint16(r.byteOffset).toString()}function ol(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,typeof r=="string"?parseInt(r):r),new Uint8Array(e)}function AT(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let t=D(e[0],"base32"),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ol(n);return dt([t,o],t.length+o.length)}function _T(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let t=gr.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ol(n);return dt([t,o],t.length+o.length)}function M7(r){let e=r.subarray(0,r.length-2),t=r.subarray(r.length-2),n=H(e,"base32"),o=xf(t);return`${n}:${o}`}var U7=function(r){r=r.toString().trim();let e=new Uint8Array(4);return r.split(/\./g).forEach((t,n)=>{let o=parseInt(t,10);if(isNaN(o)||o<0||o>255)throw new kr("Invalid byte value in IP address");e[n]=o}),e},TT=function(r){let e=0;r=r.toString().trim();let t=r.split(":",8),n;for(n=0;n<t.length;n++){let i=ni(t[n]),s;i&&(s=U7(t[n]),t[n]=H(s.subarray(0,2),"base16")),s!=null&&++n<8&&t.splice(n,0,H(s.subarray(2,4),"base16"))}if(t[0]==="")for(;t.length<8;)t.unshift("0");else if(t[t.length-1]==="")for(;t.length<8;)t.push("0");else if(t.length<8){for(n=0;n<t.length&&t[n]!=="";n++);let i=[n,1];for(n=9-t.length;n>0;n--)i.push("0");t.splice.apply(t,i)}let o=new Uint8Array(e+16);for(n=0;n<t.length;n++){t[n]===""&&(t[n]="0");let i=parseInt(t[n],16);if(isNaN(i)||i<0||i>65535)throw new kr("Invalid byte value in IP address");o[e++]=i>>8&255,o[e++]=i&255}return o},CT=function(r){if(r.byteLength!==4)throw new kr("IPv4 address was incorrect length");let e=[];for(let t=0;t<r.byteLength;t++)e.push(r[t]);return e.join(".")},IT=function(r){if(r.byteLength!==16)throw new kr("IPv6 address was incorrect length");let e=[];for(let n=0;n<r.byteLength;n+=2){let o=r[n],i=r[n+1],s=`${o.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`;e.push(s)}let t=e.join(":");try{let n=new URL(`http://[${t}]`);return n.hostname.substring(1,n.hostname.length-1)}catch{throw new kr(`Invalid IPv6 address "${t}"`)}};function kT(r){try{let e=new URL(`http://[${r}]`);return e.hostname.substring(1,e.hostname.length-1)}catch{throw new kr(`Invalid IPv6 address "${r}"`)}}var N7=Object.values(Bc).map(r=>r.decoder),_K=(function(){let r=N7[0].or(N7[1]);return N7.slice(2).forEach(e=>r=r.or(e)),r})();function PT(r){return _K.decode(r)}function RT(r){return e=>r.encoder.encode(e)}function TK(r){if(parseInt(r).toString()!==r)throw new As("Value must be an integer")}function CK(r){if(r<0)throw new As("Value must be a positive integer, or zero")}function IK(r){return e=>{if(e>r)throw new As(`Value must be smaller than or equal to ${r}`)}}function kK(...r){return e=>{for(let t of r)t(e)}}var lp=kK(TK,CK,IK(65535));var vr=-1,F7=class{protocolsByCode=new Map;protocolsByName=new Map;getProtocol(e){let t;if(typeof e=="string"?t=this.protocolsByName.get(e):t=this.protocolsByCode.get(e),t==null)throw new Og(`Protocol ${e} was unknown`);return t}addProtocol(e){this.protocolsByCode.set(e.code,e),this.protocolsByName.set(e.name,e),e.aliases?.forEach(t=>{this.protocolsByName.set(t,e)})}removeProtocol(e){let t=this.protocolsByCode.get(e);t!=null&&(this.protocolsByCode.delete(t.code),this.protocolsByName.delete(t.name),t.aliases?.forEach(n=>{this.protocolsByName.delete(n)}))}},Cs=new F7,qK=[{code:4,name:"ip4",size:32,valueToBytes:U7,bytesToValue:CT,validate:r=>{if(!ni(r))throw new As(`Invalid IPv4 address "${r}"`)}},{code:6,name:"tcp",size:16,valueToBytes:ol,bytesToValue:xf,validate:lp},{code:273,name:"udp",size:16,valueToBytes:ol,bytesToValue:xf,validate:lp},{code:33,name:"dccp",size:16,valueToBytes:ol,bytesToValue:xf,validate:lp},{code:41,name:"ip6",size:128,valueToBytes:TT,bytesToValue:IT,stringToValue:kT,validate:r=>{if(!Sg(r))throw new As(`Invalid IPv6 address "${r}"`)}},{code:42,name:"ip6zone",size:vr},{code:43,name:"ipcidr",size:8,bytesToValue:L7("base10"),valueToBytes:B7("base10")},{code:53,name:"dns",size:vr},{code:54,name:"dns4",size:vr},{code:55,name:"dns6",size:vr},{code:56,name:"dnsaddr",size:vr},{code:132,name:"sctp",size:16,valueToBytes:ol,bytesToValue:xf,validate:lp},{code:301,name:"udt"},{code:302,name:"utp"},{code:400,name:"unix",size:vr,stringToValue:r=>decodeURIComponent(r),valueToString:r=>encodeURIComponent(r)},{code:421,name:"p2p",aliases:["ipfs"],size:vr,bytesToValue:L7("base58btc"),valueToBytes:r=>r.startsWith("Q")||r.startsWith("1")?B7("base58btc")(r):Z.parse(r).multihash.bytes},{code:444,name:"onion",size:96,bytesToValue:M7,valueToBytes:AT},{code:445,name:"onion3",size:296,bytesToValue:M7,valueToBytes:_T},{code:446,name:"garlic64",size:vr},{code:447,name:"garlic32",size:vr},{code:448,name:"tls"},{code:449,name:"sni",size:vr},{code:454,name:"noise"},{code:460,name:"quic"},{code:461,name:"quic-v1"},{code:465,name:"webtransport"},{code:466,name:"certhash",size:vr,bytesToValue:RT(Lc),valueToBytes:PT},{code:480,name:"http"},{code:481,name:"http-path",size:vr,stringToValue:r=>`/${decodeURIComponent(r)}`,valueToString:r=>encodeURIComponent(r.substring(1))},{code:443,name:"https"},{code:477,name:"ws"},{code:478,name:"wss"},{code:479,name:"p2p-websocket-star"},{code:277,name:"p2p-stardust"},{code:275,name:"p2p-webrtc-star"},{code:276,name:"p2p-webrtc-direct"},{code:280,name:"webrtc-direct"},{code:281,name:"webrtc"},{code:290,name:"p2p-circuit"},{code:777,name:"memory",size:vr}];qK.forEach(r=>{Cs.addProtocol(r)});function OT(r){let e=[],t=0;for(;t<r.length;){let n=Yn(r,t),o=Cs.getProtocol(n),i=Fe(n),s=zK(o,r,t+i),a=0;s>0&&o.size===vr&&(a=Fe(s));let c=i+a+s,l={code:n,name:o.name,bytes:r.subarray(t,t+c)};if(s>0){let f=t+i+a,u=r.subarray(f,f+s);l.value=o.bytesToValue?.(u)??H(u)}e.push(l),t+=c}return e}function DT(r){let e=0,t=[];for(let n of r){if(n.bytes==null){let o=Cs.getProtocol(n.code),i=Fe(n.code),s,a=0,c=0;n.value!=null&&(s=o.valueToBytes?.(n.value)??D(n.value),a=s.byteLength,o.size===vr&&(c=Fe(a)));let l=new Uint8Array(i+c+a),f=0;cf(n.code,l,f),f+=i,s!=null&&(o.size===vr&&(cf(a,l,f),f+=c),l.set(s,f)),n.bytes=l}t.push(n.bytes),e+=n.bytes.byteLength}return dt(t,e)}function NT(r){if(r.charAt(0)!=="/")throw new kr('String multiaddr must start with "/"');let e=[],t="protocol",n="",o="";for(let i=1;i<r.length;i++){let s=r.charAt(i);s!=="/"&&(t==="protocol"?o+=r.charAt(i):n+=r.charAt(i));let a=i===r.length-1;if(s==="/"||a){let c=Cs.getProtocol(o);if(t==="protocol"){if(c.size==null||c.size===0){e.push({code:c.code,name:c.name}),n="",o="",t="protocol";continue}else if(a)throw new kr(`Component ${o} was missing value`);t="value"}else if(t==="value"){let l={code:c.code,name:c.name};if(c.size!=null&&c.size!==0){if(n==="")throw new kr(`Component ${o} was missing value`);l.value=c.stringToValue?.(n)??n}e.push(l),n="",o="",t="protocol"}}}if(o!==""&&n!=="")throw new kr("Incomplete multiaddr");return e}function LT(r){return`/${r.flatMap(e=>{if(e.value==null)return e.name;let t=Cs.getProtocol(e.code);if(t==null)throw new kr(`Unknown protocol code ${e.code}`);return[e.name,t.valueToString?.(e.value)??e.value]}).join("/")}`}function zK(r,e,t){return r.size==null||r.size===0?0:r.size>0?r.size/8:Yn(e,t)}var jK=Symbol.for("nodejs.util.inspect.custom"),G7=Symbol.for("@multiformats/multiaddr");function WK(r){if(r==null&&(r="/"),Li(r))return r.getComponents();if(r instanceof Uint8Array)return OT(r);if(typeof r=="string")return r=r.replace(/\/(\/)+/,"/").replace(/(\/)+$/,""),r===""&&(r="/"),NT(r);if(Array.isArray(r))return r;throw new kr("Must be a string, Uint8Array, Component[], or another Multiaddr")}var Bg=class r{[G7]=!0;#t;#e;#r;constructor(e="/",t={}){this.#t=WK(e),t.validate!==!1&&GK(this)}get bytes(){return this.#r==null&&(this.#r=DT(this.#t)),this.#r}toString(){return this.#e==null&&(this.#e=LT(this.#t)),this.#e}toJSON(){return this.toString()}getComponents(){return[...this.#t.map(e=>({...e}))]}encapsulate(e){let t=new r(e);return new r([...this.#t,...t.getComponents()],{validate:!1})}decapsulate(e){let t=e.toString(),n=this.toString(),o=n.lastIndexOf(t);if(o<0)throw new Rg(`Address ${this.toString()} does not contain subaddress: ${t}`);return new r(n.slice(0,o),{validate:!1})}decapsulateCode(e){let t;for(let n=this.#t.length-1;n>-1;n--)if(this.#t[n].code===e){t=n;break}return new r(this.#t.slice(0,t),{validate:!1})}equals(e){return me(this.bytes,e.bytes)}[jK](){return`Multiaddr(${this.toString()})`}};function GK(r){r.getComponents().forEach(e=>{let t=Cs.getProtocol(e.code);e.value!=null&&t.validate?.(e.value)})}function Li(r){return!!r?.[G7]}function ie(r){return new Bg(r)}var X7=class{readNext;haveNext;ended;nextResult;error;constructor(){this.ended=!1,this.readNext=He(),this.haveNext=He()}[Symbol.asyncIterator](){return this}async next(){if(this.nextResult==null&&await this.haveNext.promise,this.nextResult==null)throw new Error("HaveNext promise resolved but nextResult was undefined");let e=this.nextResult;return this.nextResult=void 0,this.readNext.resolve(),this.readNext=He(),e}async throw(e){return this.ended=!0,this.error=e,e!=null&&(this.haveNext.promise.catch(()=>{}),this.haveNext.reject(e)),{done:!0,value:void 0}}async return(){let e={done:!0,value:void 0};return this.ended=!0,this.nextResult=e,this.haveNext.resolve(),e}async push(e,t){await this._push(e,t)}async end(e,t){e!=null?await this.throw(e):await this._push(void 0,t)}async _push(e,t){if(e!=null&&this.ended)throw this.error??new Error("Cannot push value onto an ended pushable");for(;this.nextResult!=null;)await this.readNext.promise;e!=null?this.nextResult={done:!1,value:e}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=He(),await nt(this.readNext.promise,t?.signal,t)}};function BT(){return new X7}function XK(r){return r[Symbol.asyncIterator]!=null}async function YK(r,e,t){try{await Promise.all(r.map(async n=>{for await(let o of n)await e.push(o,{signal:t}),t.throwIfAborted()})),await e.end(void 0,{signal:t})}catch(n){await e.end(n,{signal:t}).catch(()=>{})}}async function*QK(r){let e=new AbortController,t=BT();YK(r,t,e.signal).catch(()=>{});try{yield*t}finally{e.abort()}}function*ZK(r){for(let e of r)yield*e}function JK(...r){let e=[];for(let t of r)XK(t)||e.push(t);return e.length===r.length?ZK(e):QK(r)}var cn=JK;function ln(r,...e){if(r==null)throw new Error("Empty pipeline");if(Y7(r)){let n=r;r=()=>n.source}else if(UT(r)||MT(r)){let n=r;r=()=>n}let t=[r,...e];if(t.length>1&&Y7(t[t.length-1])&&(t[t.length-1]=t[t.length-1].sink),t.length>2)for(let n=1;n<t.length-1;n++)Y7(t[n])&&(t[n]=tV(t[n]));return eV(...t)}var eV=(...r)=>{let e;for(;r.length>0;)e=r.shift()(e);return e},MT=r=>r?.[Symbol.asyncIterator]!=null,UT=r=>r?.[Symbol.iterator]!=null,Y7=r=>r==null?!1:r.sink!=null&&r.source!=null,tV=r=>e=>{let t=r.sink(e);if(t?.then!=null){let n=ur({objectMode:!0});t.then(()=>{n.end()},s=>{n.end(s)});let o,i=r.source;if(MT(i))o=async function*(){yield*i,n.end()};else if(UT(i))o=function*(){yield*i,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return cn(n,o())}return r.source};var rV=4194304,Mg=class extends Error{static name="UnwrappedError";name="UnwrappedError"},mp=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},Z7=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},J7=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"};function nV(r){return typeof r?.closeRead=="function"}function oV(r){return typeof r?.close=="function"}function Q7(r){return nV(r)?r.remoteWriteStatus!=="writable"&&r.readBufferLength===0:oV(r)?r.status!=="open":!1}function iV(r){return r?.addEventListener!=null&&r?.removeEventListener!=null&&r?.send!=null&&r?.push!=null&&r?.log!=null}function Ug(r,e){let t=e?.maxBufferSize??rV,n=new se,o,i=!1;if(!iV(r))throw new O("Argument should be a Stream or a Multiaddr");let s=f=>{if(n.append(f.data),n.byteLength>t){let u=n.byteLength;n.consume(n.byteLength),o?.reject(new Error(`Read buffer overflow - ${u} > ${t}`))}o?.resolve()};r.addEventListener("message",s);let a=f=>{f.error!=null?o?.reject(f.error):o?.resolve()};r.addEventListener("close",a);let c=()=>{o?.resolve()};r.addEventListener("remoteCloseWrite",c);let l={readBuffer:n,async read(f){if(i===!0)throw new Mg("Stream was unwrapped");if(Q7(r)){if(f?.bytes==null)return null;if(n.byteLength<f.bytes)throw r.log.error("closed after reading %d/%d bytes",n.byteLength,f.bytes),new nl(`Unexpected EOF - stream closed after reading ${n.byteLength}/${f.bytes} bytes`)}let u=f?.bytes??1;for(o=Promise.withResolvers();;){if(n.byteLength>=u){o.resolve();break}if(await nt(o.promise,f?.signal),Q7(r)){if(n.byteLength===0&&f?.bytes==null)return null;break}o=Promise.withResolvers()}let h=f?.bytes??n.byteLength;if(n.byteLength<h){if(Q7(r))throw r.log.error("closed while reading %d/%d bytes",n.byteLength,h),new nl(`Unexpected EOF - stream closed while reading ${n.byteLength}/${h} bytes`);return l.read(f)}let d=n.sublist(0,h);return n.consume(h),d},async write(f,u){if(i===!0)throw new Mg("Stream was unwrapped");r.send(f)||await Ze(r,"drain",{signal:u?.signal,rejectionEvents:["close"]})},unwrap(){return i||(i=!0,r.removeEventListener("message",s),r.removeEventListener("close",a),r.removeEventListener("remoteCloseWrite",c),n.byteLength>0&&(r.log("stream unwrapped with %d unread bytes",n.byteLength),r.push(n))),r}};return l}function Oa(r,e={}){let t=Ug(r,e);e.maxDataLength!=null&&e.maxLengthLength==null&&(e.maxLengthLength=Fe(e.maxDataLength));let n=e?.lengthDecoder??Yn,o=e?.lengthEncoder??Wr;return{async read(s){let a=-1,c=new se;for(;;){let f=await t.read({...s,bytes:1});if(f==null)break;c.append(f);try{a=n(c)}catch(u){if(u instanceof RangeError)continue;throw u}if(a<0)throw new mp("Invalid message length");if(e?.maxLengthLength!=null&&c.byteLength>e.maxLengthLength)throw new J7(`Message length length too long - ${c.byteLength} > ${e.maxLengthLength}`);if(a>-1)break}if(e?.maxDataLength!=null&&a>e.maxDataLength)throw new Z7(`Message length too long - ${a} > ${e.maxDataLength}`);let l=await t.read({...s,bytes:a});if(l==null)throw r.log.error("tried to read %d bytes but the stream closed",a),new nl(`Unexpected EOF - tried to read ${a} bytes but the stream closed`);if(l.byteLength!==a)throw r.log.error("read %d/%d bytes before the stream closed",l.byteLength,a),new nl(`Unexpected EOF - read ${l.byteLength}/${a} bytes before the stream closed`);return l},async write(s,a){await t.write(new se(o(s.byteLength),s),a)},async writeV(s,a){let c=new se(...s.flatMap(l=>[o(l.byteLength),l]));await t.write(c,a)},unwrap(){return t.unwrap()}}}function bt(r,e){let t=Oa(r,e),n={read:async(o,i)=>{let s=await t.read(i);return o.decode(s)},write:async(o,i,s)=>{await t.write(i.encode(o),s)},writeV:async(o,i,s)=>{await t.writeV(o.map(a=>i.encode(a)),s)},pb:o=>({read:async i=>n.read(o,i),write:async(i,s)=>n.write(i,o,s),writeV:async(i,s)=>n.writeV(i,o,s),unwrap:()=>n}),unwrap:()=>t.unwrap()};return n}var sV=1024*1024*4,aV=1024*1024*4,Fg=class{buffer;maxBufferSize;lengthDecoder;maxDataLength;encodingLength;constructor(e={}){this.buffer=new se,this.maxBufferSize=e.maxBufferSize??sV,this.maxDataLength=e.maxDataLength??aV,this.lengthDecoder=e.lengthDecoder??Yn,this.encodingLength=e.encodingLength??Fe}*decode(e){if(this.buffer.append(e),this.buffer.byteLength>this.maxBufferSize)throw new O(`Buffer length limit exceeded - ${this.buffer.byteLength}/${this.maxBufferSize}`);for(;;){let t;try{t=this.lengthDecoder(this.buffer)}catch(i){if(i instanceof RangeError)break;throw i}if(t<0||t>this.maxDataLength)throw new mp("Invalid message length");let n=this.encodingLength(t),o=n+t;if(this.buffer.byteLength>=o){let i=this.buffer.sublist(n,o);this.buffer.consume(o),i.byteLength>0&&(yield i)}else break}}};var cV=["string","number","bigint","symbol"],lV=["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 FT(r){if(r===null)return"null";if(r===void 0)return"undefined";if(r===!0||r===!1)return"boolean";let e=typeof r;if(cV.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(r))return"Array";if(uV(r))return"Buffer";let t=fV(r);return t||"Object"}function uV(r){return r&&r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer.call(null,r)}function fV(r){let e=Object.prototype.toString.call(r).slice(8,-1);if(lV.includes(e))return e}var A=class{constructor(e,t,n){this.major=e,this.majorEncoded=e<<5,this.name=t,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:this.major>e.major?1:0}};A.uint=new A(0,"uint",!0);A.negint=new A(1,"negint",!0);A.bytes=new A(2,"bytes",!0);A.string=new A(3,"string",!0);A.array=new A(4,"array",!1);A.map=new A(5,"map",!1);A.tag=new A(6,"tag",!1);A.float=new A(7,"float",!0);A.false=new A(7,"false",!0);A.true=new A(7,"true",!0);A.null=new A(7,"null",!0);A.undefined=new A(7,"undefined",!0);A.break=new A(7,"break",!0);var j=class{constructor(e,t,n){this.type=e,this.value=t,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var Sf=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",dV=new TextDecoder,hV=new TextEncoder;function $g(r){return Sf&&globalThis.Buffer.isBuffer(r)}function gp(r){return r instanceof Uint8Array?$g(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r:Uint8Array.from(r)}var VT=Sf?(r,e,t)=>t-e>64?globalThis.Buffer.from(r.subarray(e,t)).toString("utf8"):HT(r,e,t):(r,e,t)=>t-e>64?dV.decode(r.subarray(e,t)):HT(r,e,t),Hg=Sf?r=>r.length>64?globalThis.Buffer.from(r):$T(r):r=>r.length>64?hV.encode(r):$T(r),Bi=r=>Uint8Array.from(r),Af=Sf?(r,e,t)=>$g(r)?new Uint8Array(r.subarray(e,t)):r.slice(e,t):(r,e,t)=>r.slice(e,t),qT=Sf?(r,e)=>(r=r.map(t=>t instanceof Uint8Array?t:globalThis.Buffer.from(t)),gp(globalThis.Buffer.concat(r,e))):(r,e)=>{let t=new Uint8Array(e),n=0;for(let o of r)n+o.length>t.length&&(o=o.subarray(0,t.length-n)),t.set(o,n),n+=o.length;return t},zT=Sf?r=>globalThis.Buffer.allocUnsafe(r):r=>new Uint8Array(r);function Kg(r,e){if($g(r)&&$g(e))return r.compare(e);for(let t=0;t<r.length;t++)if(r[t]!==e[t])return r[t]<e[t]?-1:1;return 0}function $T(r){let e=[],t=0;for(let n=0;n<r.length;n++){let o=r.charCodeAt(n);o<128?e[t++]=o:o<2048?(e[t++]=o>>6|192,e[t++]=o&63|128):(o&64512)===55296&&n+1<r.length&&(r.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(r.charCodeAt(++n)&1023),e[t++]=o>>18|240,e[t++]=o>>12&63|128,e[t++]=o>>6&63|128,e[t++]=o&63|128):(e[t++]=o>>12|224,e[t++]=o>>6&63|128,e[t++]=o&63|128)}return e}function HT(r,e,t){let n=[];for(;e<t;){let o=r[e],i=null,s=o>239?4:o>223?3:o>191?2:1;if(e+s<=t){let a,c,l,f;switch(s){case 1:o<128&&(i=o);break;case 2:a=r[e+1],(a&192)===128&&(f=(o&31)<<6|a&63,f>127&&(i=f));break;case 3:a=r[e+1],c=r[e+2],(a&192)===128&&(c&192)===128&&(f=(o&15)<<12|(a&63)<<6|c&63,f>2047&&(f<55296||f>57343)&&(i=f));break;case 4:a=r[e+1],c=r[e+2],l=r[e+3],(a&192)===128&&(c&192)===128&&(l&192)===128&&(f=(o&15)<<18|(a&63)<<12|(c&63)<<6|l&63,f>65535&&f<1114112&&(i=f))}}i===null?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),e+=s}return ex(n)}var KT=4096;function ex(r){let e=r.length;if(e<=KT)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=KT));return t}var pV=256,yp=class{constructor(e=pV){this.chunkSize=e,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(e){let t=this.chunks[this.chunks.length-1];if(this.cursor+e.length<=this.maxCursor+1){let o=t.length-(this.maxCursor-this.cursor)-1;t.set(e,o)}else{if(t){let o=t.length-(this.maxCursor-this.cursor)-1;o<t.length&&(this.chunks[this.chunks.length-1]=t.subarray(0,o),this.maxCursor=this.cursor-1)}e.length<64&&e.length<this.chunkSize?(t=zT(this.chunkSize),this.chunks.push(t),this.maxCursor+=t.length,this._initReuseChunk===null&&(this._initReuseChunk=t),t.set(e,0)):(this.chunks.push(e),this.maxCursor+=e.length)}this.cursor+=e.length}toBytes(e=!1){let t;if(this.chunks.length===1){let n=this.chunks[0];e&&this.cursor>n.length/2?(t=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):t=Af(n,0,this.cursor)}else t=qT(this.chunks,this.cursor);return e&&this.reset(),t}};var ge="CBOR decode error:",Is="CBOR encode error:",wp=[];wp[23]=1;wp[24]=2;wp[25]=3;wp[26]=5;wp[27]=9;function ks(r,e,t){if(r.length-e<t)throw new Error(`${ge} not enough data for type`)}var Er=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Zn(r,e,t){ks(r,e,1);let n=r[e];if(t.strict===!0&&n<Er[0])throw new Error(`${ge} integer encoded in more bytes than necessary (strict decode)`);return n}function Jn(r,e,t){ks(r,e,2);let n=r[e]<<8|r[e+1];if(t.strict===!0&&n<Er[1])throw new Error(`${ge} integer encoded in more bytes than necessary (strict decode)`);return n}function eo(r,e,t){ks(r,e,4);let n=r[e]*16777216+(r[e+1]<<16)+(r[e+2]<<8)+r[e+3];if(t.strict===!0&&n<Er[2])throw new Error(`${ge} integer encoded in more bytes than necessary (strict decode)`);return n}function to(r,e,t){ks(r,e,8);let n=r[e]*16777216+(r[e+1]<<16)+(r[e+2]<<8)+r[e+3],o=r[e+4]*16777216+(r[e+5]<<16)+(r[e+6]<<8)+r[e+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(t.strict===!0&&i<Er[3])throw new Error(`${ge} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(t.allowBigInt===!0)return i;throw new Error(`${ge} integers outside of the safe integer range are not supported`)}function jT(r,e,t,n){return new j(A.uint,Zn(r,e+1,n),2)}function WT(r,e,t,n){return new j(A.uint,Jn(r,e+1,n),3)}function GT(r,e,t,n){return new j(A.uint,eo(r,e+1,n),5)}function XT(r,e,t,n){return new j(A.uint,to(r,e+1,n),9)}function To(r,e){return Pr(r,0,e.value)}function Pr(r,e,t){if(t<Er[0]){let n=Number(t);r.push([e|n])}else if(t<Er[1]){let n=Number(t);r.push([e|24,n])}else if(t<Er[2]){let n=Number(t);r.push([e|25,n>>>8,n&255])}else if(t<Er[3]){let n=Number(t);r.push([e|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(t);if(n<Er[4]){let o=[e|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),s=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=s&255,s=s>>8,o[3]=s&255,s=s>>8,o[2]=s&255,s=s>>8,o[1]=s&255,r.push(o)}else throw new Error(`${ge} encountered BigInt larger than allowable range`)}}To.encodedSize=function(e){return Pr.encodedSize(e.value)};Pr.encodedSize=function(e){return e<Er[0]?1:e<Er[1]?2:e<Er[2]?3:e<Er[3]?5:9};To.compareTokens=function(e,t){return e.value<t.value?-1:e.value>t.value?1:0};function YT(r,e,t,n){return new j(A.negint,-1-Zn(r,e+1,n),2)}function QT(r,e,t,n){return new j(A.negint,-1-Jn(r,e+1,n),3)}function ZT(r,e,t,n){return new j(A.negint,-1-eo(r,e+1,n),5)}var tx=BigInt(-1),JT=BigInt(1);function eC(r,e,t,n){let o=to(r,e+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new j(A.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${ge} integers outside of the safe integer range are not supported`);return new j(A.negint,tx-BigInt(o),9)}function Vg(r,e){let t=e.value,n=typeof t=="bigint"?t*tx-JT:t*-1-1;Pr(r,e.type.majorEncoded,n)}Vg.encodedSize=function(e){let t=e.value,n=typeof t=="bigint"?t*tx-JT:t*-1-1;return n<Er[0]?1:n<Er[1]?2:n<Er[2]?3:n<Er[3]?5:9};Vg.compareTokens=function(e,t){return e.value<t.value?1:e.value>t.value?-1:0};function xp(r,e,t,n){ks(r,e,t+n);let o=Af(r,e+t,e+t+n);return new j(A.bytes,o,t+n)}function tC(r,e,t,n){return xp(r,e,1,t)}function rC(r,e,t,n){return xp(r,e,2,Zn(r,e+1,n))}function nC(r,e,t,n){return xp(r,e,3,Jn(r,e+1,n))}function oC(r,e,t,n){return xp(r,e,5,eo(r,e+1,n))}function iC(r,e,t,n){let o=to(r,e+1,n);if(typeof o=="bigint")throw new Error(`${ge} 64-bit integer bytes lengths not supported`);return xp(r,e,9,o)}function qg(r){return r.encodedBytes===void 0&&(r.encodedBytes=r.type===A.string?Hg(r.value):r.value),r.encodedBytes}function _f(r,e){let t=qg(e);Pr(r,e.type.majorEncoded,t.length),r.push(t)}_f.encodedSize=function(e){let t=qg(e);return Pr.encodedSize(t.length)+t.length};_f.compareTokens=function(e,t){return gV(qg(e),qg(t))};function gV(r,e){return r.length<e.length?-1:r.length>e.length?1:Kg(r,e)}function bp(r,e,t,n,o){let i=t+n;ks(r,e,i);let s=new j(A.string,VT(r,e+t,e+i),i);return o.retainStringBytes===!0&&(s.byteValue=Af(r,e+t,e+i)),s}function sC(r,e,t,n){return bp(r,e,1,t,n)}function aC(r,e,t,n){return bp(r,e,2,Zn(r,e+1,n),n)}function cC(r,e,t,n){return bp(r,e,3,Jn(r,e+1,n),n)}function lC(r,e,t,n){return bp(r,e,5,eo(r,e+1,n),n)}function uC(r,e,t,n){let o=to(r,e+1,n);if(typeof o=="bigint")throw new Error(`${ge} 64-bit integer string lengths not supported`);return bp(r,e,9,o,n)}var fC=_f;function Tf(r,e,t,n){return new j(A.array,n,t)}function dC(r,e,t,n){return Tf(r,e,1,t)}function hC(r,e,t,n){return Tf(r,e,2,Zn(r,e+1,n))}function pC(r,e,t,n){return Tf(r,e,3,Jn(r,e+1,n))}function mC(r,e,t,n){return Tf(r,e,5,eo(r,e+1,n))}function gC(r,e,t,n){let o=to(r,e+1,n);if(typeof o=="bigint")throw new Error(`${ge} 64-bit integer array lengths not supported`);return Tf(r,e,9,o)}function yC(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${ge} indefinite length items not allowed`);return Tf(r,e,1,1/0)}function zg(r,e){Pr(r,A.array.majorEncoded,e.value)}zg.compareTokens=To.compareTokens;zg.encodedSize=function(e){return Pr.encodedSize(e.value)};function Cf(r,e,t,n){return new j(A.map,n,t)}function wC(r,e,t,n){return Cf(r,e,1,t)}function xC(r,e,t,n){return Cf(r,e,2,Zn(r,e+1,n))}function bC(r,e,t,n){return Cf(r,e,3,Jn(r,e+1,n))}function vC(r,e,t,n){return Cf(r,e,5,eo(r,e+1,n))}function EC(r,e,t,n){let o=to(r,e+1,n);if(typeof o=="bigint")throw new Error(`${ge} 64-bit integer map lengths not supported`);return Cf(r,e,9,o)}function SC(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${ge} indefinite length items not allowed`);return Cf(r,e,1,1/0)}function jg(r,e){Pr(r,A.map.majorEncoded,e.value)}jg.compareTokens=To.compareTokens;jg.encodedSize=function(e){return Pr.encodedSize(e.value)};function AC(r,e,t,n){return new j(A.tag,t,1)}function _C(r,e,t,n){return new j(A.tag,Zn(r,e+1,n),2)}function TC(r,e,t,n){return new j(A.tag,Jn(r,e+1,n),3)}function CC(r,e,t,n){return new j(A.tag,eo(r,e+1,n),5)}function IC(r,e,t,n){return new j(A.tag,to(r,e+1,n),9)}function Wg(r,e){Pr(r,A.tag.majorEncoded,e.value)}Wg.compareTokens=To.compareTokens;Wg.encodedSize=function(e){return Pr.encodedSize(e.value)};var EV=20,SV=21,AV=22,_V=23;function kC(r,e,t,n){if(n.allowUndefined===!1)throw new Error(`${ge} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new j(A.null,null,1):new j(A.undefined,void 0,1)}function PC(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${ge} indefinite length items not allowed`);return new j(A.break,void 0,1)}function rx(r,e,t){if(t){if(t.allowNaN===!1&&Number.isNaN(r))throw new Error(`${ge} NaN values are not supported`);if(t.allowInfinity===!1&&(r===1/0||r===-1/0))throw new Error(`${ge} Infinity values are not supported`)}return new j(A.float,r,e)}function RC(r,e,t,n){return rx(nx(r,e+1),3,n)}function OC(r,e,t,n){return rx(ox(r,e+1),5,n)}function DC(r,e,t,n){return rx(MC(r,e+1),9,n)}function Gg(r,e,t){let n=e.value;if(n===!1)r.push([A.float.majorEncoded|EV]);else if(n===!0)r.push([A.float.majorEncoded|SV]);else if(n===null)r.push([A.float.majorEncoded|AV]);else if(n===void 0)r.push([A.float.majorEncoded|_V]);else{let o,i=!1;(!t||t.float64!==!0)&&(LC(n),o=nx(si,1),n===o||Number.isNaN(n)?(si[0]=249,r.push(si.slice(0,3)),i=!0):(BC(n),o=ox(si,1),n===o&&(si[0]=250,r.push(si.slice(0,5)),i=!0))),i||(TV(n),o=MC(si,1),si[0]=251,r.push(si.slice(0,9)))}}Gg.encodedSize=function(e,t){let n=e.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!t||t.float64!==!0){LC(n);let o=nx(si,1);if(n===o||Number.isNaN(n))return 3;if(BC(n),o=ox(si,1),n===o)return 5}return 9};var NC=new ArrayBuffer(9),Co=new DataView(NC,1),si=new Uint8Array(NC,0);function LC(r){if(r===1/0)Co.setUint16(0,31744,!1);else if(r===-1/0)Co.setUint16(0,64512,!1);else if(Number.isNaN(r))Co.setUint16(0,32256,!1);else{Co.setFloat32(0,r);let e=Co.getUint32(0),t=(e&2139095040)>>23,n=e&8388607;if(t===255)Co.setUint16(0,31744,!1);else if(t===0)Co.setUint16(0,(r&2147483648)>>16|n>>13,!1);else{let o=t-127;o<-24?Co.setUint16(0,0):o<-14?Co.setUint16(0,(e&2147483648)>>16|1<<24+o,!1):Co.setUint16(0,(e&2147483648)>>16|o+15<<10|n>>13,!1)}}}function nx(r,e){if(r.length-e<2)throw new Error(`${ge} not enough data for float16`);let t=(r[e]<<8)+r[e+1];if(t===31744)return 1/0;if(t===64512)return-1/0;if(t===32256)return NaN;let n=t>>10&31,o=t&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,t&32768?-i:i}function BC(r){Co.setFloat32(0,r,!1)}function ox(r,e){if(r.length-e<4)throw new Error(`${ge} not enough data for float32`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,4).getFloat32(0,!1)}function TV(r){Co.setFloat64(0,r,!1)}function MC(r,e){if(r.length-e<8)throw new Error(`${ge} not enough data for float64`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,8).getFloat64(0,!1)}Gg.compareTokens=To.compareTokens;function Je(r,e,t){throw new Error(`${ge} encountered invalid minor (${t}) for major ${r[e]>>>5}`)}function Xg(r){return()=>{throw new Error(`${ge} ${r}`)}}var oe=[];for(let r=0;r<=23;r++)oe[r]=Je;oe[24]=jT;oe[25]=WT;oe[26]=GT;oe[27]=XT;oe[28]=Je;oe[29]=Je;oe[30]=Je;oe[31]=Je;for(let r=32;r<=55;r++)oe[r]=Je;oe[56]=YT;oe[57]=QT;oe[58]=ZT;oe[59]=eC;oe[60]=Je;oe[61]=Je;oe[62]=Je;oe[63]=Je;for(let r=64;r<=87;r++)oe[r]=tC;oe[88]=rC;oe[89]=nC;oe[90]=oC;oe[91]=iC;oe[92]=Je;oe[93]=Je;oe[94]=Je;oe[95]=Xg("indefinite length bytes/strings are not supported");for(let r=96;r<=119;r++)oe[r]=sC;oe[120]=aC;oe[121]=cC;oe[122]=lC;oe[123]=uC;oe[124]=Je;oe[125]=Je;oe[126]=Je;oe[127]=Xg("indefinite length bytes/strings are not supported");for(let r=128;r<=151;r++)oe[r]=dC;oe[152]=hC;oe[153]=pC;oe[154]=mC;oe[155]=gC;oe[156]=Je;oe[157]=Je;oe[158]=Je;oe[159]=yC;for(let r=160;r<=183;r++)oe[r]=wC;oe[184]=xC;oe[185]=bC;oe[186]=vC;oe[187]=EC;oe[188]=Je;oe[189]=Je;oe[190]=Je;oe[191]=SC;for(let r=192;r<=215;r++)oe[r]=AC;oe[216]=_C;oe[217]=TC;oe[218]=CC;oe[219]=IC;oe[220]=Je;oe[221]=Je;oe[222]=Je;oe[223]=Je;for(let r=224;r<=243;r++)oe[r]=Xg("simple values are not supported");oe[244]=Je;oe[245]=Je;oe[246]=Je;oe[247]=kC;oe[248]=Xg("simple values are not supported");oe[249]=RC;oe[250]=OC;oe[251]=DC;oe[252]=Je;oe[253]=Je;oe[254]=Je;oe[255]=PC;var ai=[];for(let r=0;r<24;r++)ai[r]=new j(A.uint,r,1);for(let r=-1;r>=-24;r--)ai[31-r]=new j(A.negint,r,1);ai[64]=new j(A.bytes,new Uint8Array(0),1);ai[96]=new j(A.string,"",1);ai[128]=new j(A.array,0,1);ai[160]=new j(A.map,0,1);ai[244]=new j(A.false,!1,1);ai[245]=new j(A.true,!0,1);ai[246]=new j(A.null,null,1);function Yg(r){switch(r.type){case A.false:return Bi([244]);case A.true:return Bi([245]);case A.null:return Bi([246]);case A.bytes:return r.value.length?void 0:Bi([64]);case A.string:return r.value===""?Bi([96]):void 0;case A.array:return r.value===0?Bi([128]):void 0;case A.map:return r.value===0?Bi([160]):void 0;case A.uint:return r.value<24?Bi([Number(r.value)]):void 0;case A.negint:if(r.value>=-24)return Bi([31-Number(r.value)])}}var IV={float64:!1,mapSorter:PV,quickEncodeToken:Yg},FC=Object.freeze({float64:!0,mapSorter:RV,quickEncodeToken:Yg});function sx(){let r=[];return r[A.uint.major]=To,r[A.negint.major]=Vg,r[A.bytes.major]=_f,r[A.string.major]=fC,r[A.array.major]=zg,r[A.map.major]=jg,r[A.tag.major]=Wg,r[A.float.major]=Gg,r}var ax=sx(),ix=new yp,Qg=class r{constructor(e,t){this.obj=e,this.parent=t}includes(e){let t=this;do if(t.obj===e)return!0;while(t=t.parent);return!1}static createCheck(e,t){if(e&&e.includes(t))throw new Error(`${Is} object contains circular references`);return new r(t,e)}},Da={null:new j(A.null,null),undefined:new j(A.undefined,void 0),true:new j(A.true,!0),false:new j(A.false,!1),emptyArray:new j(A.array,0),emptyMap:new j(A.map,0)},Na={number(r,e,t,n){return!Number.isInteger(r)||!Number.isSafeInteger(r)?new j(A.float,r):r>=0?new j(A.uint,r):new j(A.negint,r)},bigint(r,e,t,n){return r>=BigInt(0)?new j(A.uint,r):new j(A.negint,r)},Uint8Array(r,e,t,n){return new j(A.bytes,r)},string(r,e,t,n){return new j(A.string,r)},boolean(r,e,t,n){return r?Da.true:Da.false},null(r,e,t,n){return Da.null},undefined(r,e,t,n){return Da.undefined},ArrayBuffer(r,e,t,n){return new j(A.bytes,new Uint8Array(r))},DataView(r,e,t,n){return new j(A.bytes,new Uint8Array(r.buffer,r.byteOffset,r.byteLength))},Array(r,e,t,n){if(!r.length)return t.addBreakTokens===!0?[Da.emptyArray,new j(A.break)]:Da.emptyArray;n=Qg.createCheck(n,r);let o=[],i=0;for(let s of r)o[i++]=vp(s,t,n);return t.addBreakTokens?[new j(A.array,r.length),o,new j(A.break)]:[new j(A.array,r.length),o]},Object(r,e,t,n){let o=e!=="Object",i=o?r.keys():Object.keys(r),s=o?r.size:i.length;if(!s)return t.addBreakTokens===!0?[Da.emptyMap,new j(A.break)]:Da.emptyMap;n=Qg.createCheck(n,r);let a=[],c=0;for(let l of i)a[c++]=[vp(l,t,n),vp(o?r.get(l):r[l],t,n)];return kV(a,t),t.addBreakTokens?[new j(A.map,s),a,new j(A.break)]:[new j(A.map,s),a]}};Na.Map=Na.Object;Na.Buffer=Na.Uint8Array;for(let r of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Na[`${r}Array`]=Na.DataView;function vp(r,e={},t){let n=FT(r),o=e&&e.typeEncoders&&e.typeEncoders[n]||Na[n];if(typeof o=="function"){let s=o(r,n,e,t);if(s!=null)return s}let i=Na[n];if(!i)throw new Error(`${Is} unsupported type: ${n}`);return i(r,n,e,t)}function kV(r,e){e.mapSorter&&r.sort(e.mapSorter)}function PV(r,e){let t=Array.isArray(r[0])?r[0][0]:r[0],n=Array.isArray(e[0])?e[0][0]:e[0];if(t.type!==n.type)return t.type.compare(n.type);let o=t.type.major,i=ax[o].compareTokens(t,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function RV(r,e){if(r[0]instanceof j&&e[0]instanceof j){let t=r[0],n=e[0];return t._keyBytes||(t._keyBytes=UC(t.value)),n._keyBytes||(n._keyBytes=UC(n.value)),Kg(t._keyBytes,n._keyBytes)}throw new Error("rfc8949MapSorter: complex key types are not supported yet")}function UC(r){return Zg(r,ax,FC)}function $C(r,e,t,n){if(Array.isArray(e))for(let o of e)$C(r,o,t,n);else t[e.type.major](r,e,n)}function Zg(r,e,t){let n=vp(r,t);if(!Array.isArray(n)&&t.quickEncodeToken){let o=t.quickEncodeToken(n);if(o)return o;let i=e[n.type.major];if(i.encodedSize){let s=i.encodedSize(n,t),a=new yp(s);if(i(a,n,t),a.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return gp(a.chunks[0])}}return ix.reset(),$C(ix,n,e,t),ix.toBytes(!0)}function La(r,e){return e=Object.assign({},IV,e),Zg(r,ax,e)}var OV={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Jg=class{constructor(e,t={}){this._pos=0,this.data=e,this.options=t}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let e=this.data[this._pos],t=ai[e];if(t===void 0){let n=oe[e];if(!n)throw new Error(`${ge} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);let o=e&31;t=n(this.data,this._pos,o,this.options)}return this._pos+=t.encodedLength,t}},Ep=Symbol.for("DONE"),e2=Symbol.for("BREAK");function DV(r,e,t){let n=[];for(let o=0;o<r.value;o++){let i=If(e,t);if(i===e2){if(r.value===1/0)break;throw new Error(`${ge} got unexpected break to lengthed array`)}if(i===Ep)throw new Error(`${ge} found array but not enough entries (got ${o}, expected ${r.value})`);n[o]=i}return n}function NV(r,e,t){let n=t.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let s=0;s<r.value;s++){let a=If(e,t);if(a===e2){if(r.value===1/0)break;throw new Error(`${ge} got unexpected break to lengthed map`)}if(a===Ep)throw new Error(`${ge} found map but not enough entries (got ${s} [no key], expected ${r.value})`);if(n!==!0&&typeof a!="string")throw new Error(`${ge} non-string keys not supported (got ${typeof a})`);if(t.rejectDuplicateMapKeys===!0&&(n&&i.has(a)||!n&&a in o))throw new Error(`${ge} found repeat map key "${a}"`);let c=If(e,t);if(c===Ep)throw new Error(`${ge} 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 If(r,e){if(r.done())return Ep;let t=r.next();if(t.type===A.break)return e2;if(t.type.terminal)return t.value;if(t.type===A.array)return DV(t,r,e);if(t.type===A.map)return NV(t,r,e);if(t.type===A.tag){if(e.tags&&typeof e.tags[t.value]=="function"){let n=If(r,e);return e.tags[t.value](n)}throw new Error(`${ge} tag not supported (${t.value})`)}throw new Error("unsupported")}function cx(r,e){if(!(r instanceof Uint8Array))throw new Error(`${ge} data to decode must be a Uint8Array`);e=Object.assign({},OV,e);let t=e.tokenizer||new Jg(r,e),n=If(t,e);if(n===Ep)throw new Error(`${ge} did not find any content to decode`);if(n===e2)throw new Error(`${ge} got unexpected break`);return[n,r.subarray(t.pos())]}function ro(r,e){let[t,n]=cx(r,e);if(n.length>0)throw new Error(`${ge} too many terminals, data makes no sense`);return t}var t2=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},kf=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},r2=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"},Sp=class extends Error{name="UnexpectedEOFError";code="ERR_UNEXPECTED_EOF"};function n2(r){return r[Symbol.asyncIterator]!=null}function HC(r,e){if(r.byteLength>e)throw new kf("Message length too long")}var i2=r=>{let e=Fe(r),t=Nt(e);return Wr(r,t),i2.bytes=e,t};i2.bytes=0;function Ps(r,e){e=e??{};let t=e.lengthEncoder??i2,n=e?.maxDataLength??4194304;function*o(i){HC(i,n);let s=t(i.byteLength);s instanceof Uint8Array?yield s:yield*s,i instanceof Uint8Array?yield i:yield*i}return n2(r)?(async function*(){for await(let i of r)yield*o(i)})():(function*(){for(let i of r)yield*o(i)})()}Ps.single=(r,e)=>{e=e??{};let t=e.lengthEncoder??i2,n=e?.maxDataLength??4194304;return HC(r,n),new se(t(r.byteLength),r)};var al;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(al||(al={}));var ux=r=>{let e=Yn(r);return ux.bytes=Fe(e),e};ux.bytes=0;function cl(r,e){let t=new se,n=al.LENGTH,o=-1,i=e?.lengthDecoder??ux,s=e?.maxLengthLength??8,a=e?.maxDataLength??4194304;function*c(){for(;t.byteLength>0;){if(n===al.LENGTH)try{if(o=i(t),o<0)throw new t2("Invalid message length");if(o>a)throw new kf("Message length too long");let l=i.bytes;t.consume(l),e?.onLength!=null&&e.onLength(o),n=al.DATA}catch(l){if(l instanceof RangeError){if(t.byteLength>s)throw new r2("Message length length too long");break}throw l}if(n===al.DATA){if(t.byteLength<o)break;let l=t.sublist(0,o);t.consume(o),e?.onData!=null&&e.onData(l),yield l,n=al.LENGTH}}}return n2(r)?(async function*(){for await(let l of r)t.append(l),yield*c();if(t.byteLength>0)throw new Sp("Unexpected end of input")})():(function*(){for(let l of r)t.append(l),yield*c();if(t.byteLength>0)throw new Sp("Unexpected end of input")})()}cl.fromReader=(r,e)=>{let t=1,n=(async function*(){for(;;)try{let{done:i,value:s}=await r.next(t);if(i===!0)return;s!=null&&(yield s)}catch(i){if(i.code==="ERR_UNDER_READ")return{done:!0,value:null};throw i}finally{t=1}})();return cl(n,{...e??{},onLength:i=>{t=i}})};function BV(r,e){if(typeof r=="string")return MV(r);if(typeof r=="number")return $V(r,e);throw Error(`Value provided to ms() must be a string or number. value=${JSON.stringify(r)}`)}var s2=BV;function MV(r){if(typeof r!="string"||r.length===0||r.length>100)throw Error(`Value provided to ms.parse() must be a string with length between 1 and 99. value=${JSON.stringify(r)}`);let e=/^(?<value>-?\d*\.?\d+) *(?<unit>milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|months?|mo|years?|yrs?|y)?$/i.exec(r);if(!e?.groups)return NaN;let{value:t,unit:n="ms"}=e.groups,o=parseFloat(t),i=n.toLowerCase();switch(i){case"years":case"year":case"yrs":case"yr":case"y":return o*315576e5;case"months":case"month":case"mo":return o*26298e5;case"weeks":case"week":case"w":return o*6048e5;case"days":case"day":case"d":return o*864e5;case"hours":case"hour":case"hrs":case"hr":case"h":return o*36e5;case"minutes":case"minute":case"mins":case"min":case"m":return o*6e4;case"seconds":case"second":case"secs":case"sec":case"s":return o*1e3;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return o;default:throw Error(`Unknown unit "${i}" provided to ms.parse(). value=${JSON.stringify(r)}`)}}function UV(r){let e=Math.abs(r);return e>=315576e5?`${Math.round(r/315576e5)}y`:e>=26298e5?`${Math.round(r/26298e5)}mo`:e>=6048e5?`${Math.round(r/6048e5)}w`:e>=864e5?`${Math.round(r/864e5)}d`:e>=36e5?`${Math.round(r/36e5)}h`:e>=6e4?`${Math.round(r/6e4)}m`:e>=1e3?`${Math.round(r/1e3)}s`:`${r}ms`}function FV(r){let e=Math.abs(r);return e>=315576e5?ll(r,e,315576e5,"year"):e>=26298e5?ll(r,e,26298e5,"month"):e>=6048e5?ll(r,e,6048e5,"week"):e>=864e5?ll(r,e,864e5,"day"):e>=36e5?ll(r,e,36e5,"hour"):e>=6e4?ll(r,e,6e4,"minute"):e>=1e3?ll(r,e,1e3,"second"):`${r} ms`}function $V(r,e){if(typeof r!="number"||!Number.isFinite(r))throw Error("Value provided to ms.format() must be of type number.");return e?.long?FV(r):UV(r)}function ll(r,e,t,n){let o=e>=t*1.5;return`${Math.round(r/t)} ${n}${o?"s":""}`}function fx(r){t.debug=t,t.default=t,t.coerce=c,t.disable=i,t.enable=o,t.enabled=s,t.humanize=s2,t.destroy=l,Object.keys(r).forEach(f=>{t[f]=r[f]}),t.names=[],t.skips=[],t.formatters={};function e(f){let u=0;for(let h=0;h<f.length;h++)u=(u<<5)-u+f.charCodeAt(h),u|=0;return t.colors[Math.abs(u)%t.colors.length]}t.selectColor=e;function t(f,u){let h,d=null,m,y;function w(...x){if(!w.enabled)return;let E=w,v=Number(new Date),I=v-(h||v);E.diff=I,E.prev=h,E.curr=v,h=v,x[0]=t.coerce(x[0]),typeof x[0]!="string"&&x.unshift("%O");let F=0;x[0]=x[0].replace(/%([a-zA-Z%])/g,(M,T)=>{if(M==="%%")return"%";F++;let k=t.formatters[T];if(typeof k=="function"){let z=x[F];M=k.call(E,z),x.splice(F,1),F--}return M}),t.formatArgs.call(E,x),u?.onLog!=null&&u.onLog(...x),(E.log||t.log).apply(E,x)}return w.namespace=f,w.useColors=t.useColors(),w.color=t.selectColor(f),w.extend=n,w.destroy=t.destroy,Object.defineProperty(w,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(m!==t.namespaces&&(m=t.namespaces,y=t.enabled(f)),y),set:x=>{d=x}}),typeof t.init=="function"&&t.init(w),w}function n(f,u){let h=t(this.namespace+(typeof u>"u"?":":u)+f);return h.log=this.log,h}function o(f){t.save(f),t.namespaces=f,t.names=[],t.skips=[];let u,h=(typeof f=="string"?f:"").split(/[\s,]+/),d=h.length;for(u=0;u<d;u++)h[u]&&(f=h[u].replace(/\*/g,".*?"),f[0]==="-"?t.skips.push(new RegExp("^"+f.substr(1)+"$")):t.names.push(new RegExp("^"+f+"$")))}function i(){let f=[...t.names.map(a),...t.skips.map(a).map(u=>"-"+u)].join(",");return t.enable(""),f}function s(f){if(f[f.length-1]==="*")return!0;let u,h;for(u=0,h=t.skips.length;u<h;u++)if(t.skips[u].test(f))return!1;for(u=0,h=t.names.length;u<h;u++)if(t.names[u].test(f))return!0;return!1}function a(f){return f.toString().substring(2,f.toString().length-2).replace(/\.\*\?$/,"*")}function c(f){return f instanceof Error?f.stack??f.message:f}function l(){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 t.setupFormatters(t.formatters),t.enable(t.load()),t}var a2=WV(),HV=["#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 KV(){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 VV(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+s2(this.diff),!this.useColors)return;let e="color: "+this.color;r.splice(1,0,e,"color: inherit");let t=0,n=0;r[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(t++,o==="%c"&&(n=t))}),r.splice(n,0,e)}var qV=console.debug??console.log??(()=>{});function zV(r){try{r?a2?.setItem("debug",r):a2?.removeItem("debug")}catch{}}function jV(){let r;try{r=a2?.getItem("debug")}catch{}return!r&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(r=globalThis.process.env.DEBUG),r}function WV(){try{return localStorage}catch{}}function GV(r){r.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}}var VC=fx({formatArgs:VV,save:zV,load:jV,useColors:KV,setupFormatters:GV,colors:HV,storage:a2,log:qV});var An=VC;An.formatters.b=r=>r==null?"undefined":Qe.baseEncode(r);An.formatters.t=r=>r==null?"undefined":gr.baseEncode(r);An.formatters.m=r=>r==null?"undefined":Zt.baseEncode(r);An.formatters.p=r=>r==null?"undefined":r.toString();An.formatters.c=r=>r==null?"undefined":r.toString();An.formatters.k=r=>r==null?"undefined":r.toString();An.formatters.a=r=>r==null?"undefined":r.toString();function qC(r,e=""){let t=zC(r.message),n=zC(r.stack);return t!=null&&n!=null?n.includes(t)?`${n.split(`
4
4
  `).join(`
5
5
  ${e}`)}`:`${t}
6
6
  ${e}${n.split(`
@@ -116,7 +116,7 @@ a=ice-pwd:`+e+t)}catch{}return r}var tS=D("libp2p-webrtc-noise:");function $B(r,
116
116
  `));return D(e)}function I8(r){let e=new Uint8Array(512),t=r.name,n="";if(r.typeflag===5&&t[t.length-1]!=="/"&&(t+="/"),D(t).byteLength!==t.length)return null;for(;D(t).byteLength>100;){let o=t.indexOf("/");if(o===-1)return null;n+=n!==""?"/"+t.slice(0,o):t.slice(0,o),t=t.slice(o+1)}return D(t).byteLength>100||D(n).byteLength>155||r.linkname!=null&&D(r.linkname).byteLength>100?null:(e.set(D(t),0),e.set(Cc(r.mode&sJ,6),100),e.set(Cc(r.uid,6),108),e.set(Cc(r.gid,6),116),e.set(Cc(r.size,11),124),e.set(Cc(r.mtime.getTime()/1e3|0,11),136),e[156]=nJ+lJ(r.type),r.linkname!=null&&e.set(D(r.linkname),157),e.set(oJ,aJ),e.set(iJ,cJ),r.uname!=null&&e.set(D(r.uname),265),r.gname!=null&&e.set(D(r.gname),297),e.set(Cc(r.devmajor??0,6),329),e.set(Cc(r.devminor??0,6),337),n!=null&&e.set(D(n),345),e.set(Cc(uJ(e),6),148),e)}var{S_IFMT:dJ,S_IFBLK:hJ,S_IFCHR:pJ,S_IFDIR:mJ,S_IFIFO:gJ,S_IFLNK:yJ}=bU.default,wJ=parseInt("755",8),xJ=parseInt("644",8),vU=new Uint8Array(1024);function bJ(r=0){switch(r&dJ){case hJ:return"block-device";case pJ:return"character-device";case mJ:return"directory";case gJ:return"fifo";case yJ:return"symlink";default:return"file"}}function PS(r){return r&=511,r!==0?vU.subarray(0,512-r):new Uint8Array(0)}function kS(r){if(r.pax==null){let e=I8(r);if(e!=null)return e}return vJ(r)}function vJ(r){let e=xU(r),t={name:"PaxHeader",mode:r.mode,uid:r.uid,gid:r.gid,size:e.length,mtime:r.mtime,type:"pax-header",linkname:r.linkname,uname:r.uname,gname:r.gname,devmajor:r.devmajor,devminor:r.devminor};return new se(I8(t)??new Uint8Array(0),e,PS(e.length),I8({...t,size:r.size,type:r.type})??new Uint8Array(0)).subarray()}function k8(){return async function*(r){for await(let{header:e,body:t}of r){let n={...e,size:e.type==="symlink"?0:e.size??0,type:e.type??bJ(e.mode),mode:e.mode??(e.type==="directory"?wJ:xJ),uid:e.uid??0,gid:e.gid??0,mtime:e.mtime??new Date};if(typeof t=="string"&&(t=D(t)),t instanceof Uint8Array||Eo(t)){n.size=t.length,yield kS(n),yield Eo(t)?t.subarray():t,yield PS(n.size);continue}if(n.type==="symlink"&&n.linkname==null){if(t==null)throw new Error("type was symlink but no linkname or body specified");n.linkname=H(await Ge(t)),yield kS(n);continue}if(yield kS(n),n.type!=="file"&&n.type!=="contiguous-file")continue;let o=0;for await(let i of t??[])o+=i.length,yield Eo(i)?i.subarray():i;if(o!==n.size)throw new Error(`size mismatch, wrote ${o} of ${n.size} bytes`);yield PS(n.size)}yield vU}}var EJ=["file","raw","directory"];function SJ(r){let e,t;return(r.type==="file"||r.type==="directory")&&(e=r.unixfs.mode,t=r.unixfs.mtime!=null?new Date(Number(r.unixfs.mtime.secs*1000n)):void 0),{name:r.path,mode:e,mtime:t,size:Number(r.size),type:r.type==="directory"?"directory":"file"}}function EU(r){if(!EJ.includes(r.type))throw new Ru(`${r.type} is not a UnixFS node`);let e={header:SJ(r)};return(r.type==="file"||r.type==="raw")&&(e.body=r.content()),e}async function*SU(r,e,t){let n=await C0(r,e,t);if(n.type==="file"||n.type==="raw"){yield*ln([EU(n)],k8());return}if(n.type==="directory"){yield*ln(nU(r,e,t),o=>Kt(o,i=>EU(i)),k8());return}throw new Ru("Not a UnixFS node")}var P8=class extends Vn{id="tar-plugin";codes=[];canHandle({accept:e}){return e.some(t=>t.contentType.mediaType===fh)}async handle(e){let{terminalElement:t,url:n,resource:o,options:i,blockstore:s,range:a}=e;if(t.cid.code!==pt&&t.cid.code!==rt)return Kn(o,new Ru("Only UnixFS data can be returned in a TAR file"));if(a!=null)return Kn(o,new Error("Range requests are not supported for TAR files"));let c=Lo(SU(`/ipfs/${t.cid}${n.pathname}`,s,i));return _i(o,c,{headers:{"content-type":fh,"content-disposition":`attachment; ${zo(n.searchParams.get("filename")??`${t.cid.toString()}.tar`)}`,"accept-ranges":"none"}})}};function AJ(r,e,t){let n;try{n=new URL(r)}catch{n=e}if(t?.type==="directory"&&!n.pathname.endsWith("/"))return n.pathname+="/",n.toString()}var R8=class extends Vn{id="unixfs-plugin";codes=[pt,rt];canHandle({terminalElement:e,accept:t}){let n=this.codes.includes(e.cid.code),o=t.length===0||t.some(i=>i.contentType.mediaType===Kr||i.contentType.mediaType===I0);return n&&o}async handle(e){let{url:t,resource:n,terminalElement:o,ipfsRoots:i}=e,s=t.searchParams.get("filename")??o.name,a;if(o.type==="directory"){let c=AJ(n,t,o);if(c!=null){if(this.log.trace("directory url normalization spec requires redirect"),e.options?.redirect==="error")throw this.log('could not redirect to %s as redirect option was set to "error"',c),new TypeError("Failed to fetch");if(e.options?.redirect==="manual")return this.log("returning 301 permanent redirect to %s",c),pU(e.resource,c);this.log("following redirect to %s",c),n=c,a=!0}let l=o.cid;if(e.options?.supportDirectoryIndexes!==!1){let u="index.html";try{this.log.trace("found directory at %c/%s, looking for index.html",l,t.pathname);let h=await e.serverTiming.time("exporter-dir","",C0(`/ipfs/${l}/${u}`,e.blockstore,e.options));return h.type==="directory"||h.type==="object"?hh(n,"Unable to stream content"):(s=u,this.log.trace("found directory index at %c/%s with cid %c",l,u,h.cid),await this.streamFile(n,h,s,a,e.range,e.options))}catch(h){if(h.name!=="NotFoundError")throw this.log.error("error loading path %c/%s - %e",l,u,h),h}}let f=await Ge(e.blockstore.get(l,e.options));return _i(n,f,{headers:{"content-type":I0,"content-length":`${f.byteLength}`,"content-disposition":`${t.searchParams.get("download")==="true"?"attachment":"inline"}; ${zo(`${l}.dir`)}`,"x-ipfs-roots":i.map(u=>u.toV1()).join(","),"accept-ranges":"bytes"},redirected:a})}else return o.type==="file"||o.type==="raw"||o.type==="identity"?(this.log("streaming file"),this.streamFile(n,o,s,a,e.range,e.options)):(this.log.error("cannot stream terminal element type %s",o.type),hh(n,"Unable to stream content"))}async streamFile(e,t,n,o,i,s){let a=Kr;return i==null&&(a=await this.detectContentType(t,n,s)),i!=null?v8(e,(c,l)=>t.content({...s??{},offset:c,length:l}),i,t.size,{headers:{"content-type":a,"content-disposition":`inline; ${zo(n)}`,"x-ipfs-roots":t.cid.toString(),"accept-ranges":"bytes"},redirected:o}):_i(e,Lo(t.content(s)),{headers:{"content-type":a,"content-length":`${t.size}`,"content-disposition":`inline; ${zo(n)}`,"x-ipfs-roots":t.cid.toString(),"accept-ranges":"bytes"},redirected:o})}async detectContentType(e,t,n){let o;if(e.type==="raw"||e.type==="identity"?o=e.node:o=await Py(e.content(n)),o==null)throw new Error("stream ended before first block was read");let i;if(this.pluginOptions.contentTypeParser!=null)try{let s=this.pluginOptions.contentTypeParser(o,t);if(yf(s)){let a=await s;a!=null&&(i=a)}else s!=null&&(i=s);this.log.trace("contentTypeParser returned %s for file with name %s",i,t)}catch(s){this.log.error("error parsing content type - %e",s)}return i??Kr}};var D0=class extends Map{#t=0;#e=new Map;#r=new Map;#s;#c;#a;constructor(e={}){if(super(),!(e.maxSize&&e.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");if(typeof e.maxAge=="number"&&e.maxAge===0)throw new TypeError("`maxAge` must be a number greater than 0");this.#s=e.maxSize,this.#c=e.maxAge||Number.POSITIVE_INFINITY,this.#a=e.onEviction}get __oldCache(){return this.#r}#l(e){if(typeof this.#a=="function")for(let[t,n]of e)this.#a(t,n.value)}#n(e,t){return typeof t.expiry=="number"&&t.expiry<=Date.now()?(typeof this.#a=="function"&&this.#a(e,t.value),this.delete(e)):!1}#d(e,t){if(this.#n(e,t)===!1)return t.value}#u(e,t){return t.expiry?this.#d(e,t):t.value}#f(e,t){let n=t.get(e);return this.#u(e,n)}#o(e,t){this.#e.set(e,t),this.#t++,this.#t>=this.#s&&(this.#t=0,this.#l(this.#r),this.#r=this.#e,this.#e=new Map)}#h(e,t){this.#r.delete(e),this.#o(e,t)}*#i(){for(let e of this.#r){let[t,n]=e;this.#e.has(t)||this.#n(t,n)===!1&&(yield e)}for(let e of this.#e){let[t,n]=e;this.#n(t,n)===!1&&(yield e)}}get(e){if(this.#e.has(e)){let t=this.#e.get(e);return this.#u(e,t)}if(this.#r.has(e)){let t=this.#r.get(e);if(this.#n(e,t)===!1)return this.#h(e,t),t.value}}set(e,t,{maxAge:n=this.#c}={}){let o=typeof n=="number"&&n!==Number.POSITIVE_INFINITY?Date.now()+n:void 0;return this.#e.has(e)?this.#e.set(e,{value:t,expiry:o}):this.#o(e,{value:t,expiry:o}),this}has(e){return this.#e.has(e)?!this.#n(e,this.#e.get(e)):this.#r.has(e)?!this.#n(e,this.#r.get(e)):!1}peek(e){if(this.#e.has(e))return this.#f(e,this.#e);if(this.#r.has(e))return this.#f(e,this.#r)}expiresIn(e){let t=this.#e.get(e)??this.#r.get(e);if(t)return t.expiry?t.expiry-Date.now():Number.POSITIVE_INFINITY}delete(e){let t=this.#e.delete(e);return t&&this.#t--,this.#r.delete(e)||t}clear(){this.#e.clear(),this.#r.clear(),this.#t=0}resize(e){if(!(e&&e>0))throw new TypeError("`maxSize` must be a number greater than 0");let t=[...this.#i()],n=t.length-e;n<0?(this.#e=new Map(t),this.#r=new Map,this.#t=t.length):(n>0&&this.#l(t.slice(0,n)),this.#r=new Map(t.slice(n)),this.#e=new Map,this.#t=0),this.#s=e}evict(e=1){let t=Number(e);if(!t||t<=0)return;let n=[...this.#i()],o=Math.trunc(Math.min(t,Math.max(n.length-1,0)));o<=0||(this.#l(n.slice(0,o)),this.#r=new Map(n.slice(o)),this.#e=new Map,this.#t=0)}*keys(){for(let[e]of this)yield e}*values(){for(let[,e]of this)yield e}*[Symbol.iterator](){for(let e of this.#e){let[t,n]=e;this.#n(t,n)===!1&&(yield[t,n.value])}for(let e of this.#r){let[t,n]=e;this.#e.has(t)||this.#n(t,n)===!1&&(yield[t,n.value])}}*entriesDescending(){let e=[...this.#e];for(let t=e.length-1;t>=0;--t){let n=e[t],[o,i]=n;this.#n(o,i)===!1&&(yield[o,i.value])}e=[...this.#r];for(let t=e.length-1;t>=0;--t){let n=e[t],[o,i]=n;this.#e.has(o)||this.#n(o,i)===!1&&(yield[o,i.value])}}*entriesAscending(){for(let[e,t]of this.#i())yield[e,t.value]}get size(){if(!this.#t)return this.#r.size;let e=0;for(let t of this.#r.keys())this.#e.has(t)||e++;return Math.min(this.#t+e,this.#s)}get maxSize(){return this.#s}get maxAge(){return this.#c}entries(){return this.entriesAscending()}forEach(e,t=this){for(let[n,o]of this.entriesAscending())e.call(t,o,n,this)}get[Symbol.toStringTag](){return"QuickLRU"}toString(){return`QuickLRU(${this.size}/${this.maxSize})`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}};var _J=/^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$/;function AU(r){return _J.test(r)&&r.includes("-")&&!r.includes(".")}function _U(r){return r.replace(/--/g,"%").replace(/-/g,".").replace(/%/g,"-")}function TU(r){if(!r.startsWith("/ipfs/")&&!r.startsWith("/ipns/"))throw new O(`Path ${r} did not start with /ipfs/ or /ipns/`);let e=r.indexOf("#"),t="";e>-1&&(t=r.substring(e),r=r.substring(0,e));let n=r.indexOf("?"),o="";n>-1&&(o=r.substring(n),r=r.substring(0,n));let i=r.substring(1,5),s=r.substring(6);return`https://example.org/${i}/${s}${o}${t}`}function CU(r){if(!r.startsWith("ipfs://")&&!r.startsWith("ipns://"))throw new O(`URL ${r} did not start with ipfs:// or ipns://`);let e=r.substring(0,4),t=r.substring(7);return`https://example.org/${e}/${t}`}var TJ=/^(?<cidOrPeerIdOrDnsLink>[^/?]+)\.(?<protocol>ip[fn]s)\.([^/?]+)$/,CJ=114;function IJ(r){let e=r?.protocol;return!(e!=="ipfs"&&e!=="ipns"||r?.cidOrPeerIdOrDnsLink==null)}function kJ(r,e){let t=e.toLowerCase().indexOf(r);return t===-1?r:e.substring(t,t+r.length)}function PJ(r){if(r instanceof URL)return r;if((r.startsWith("/ipfs/")||r.startsWith("/ipns/"))&&(r=TU(r)),(r.startsWith("ipfs://")||r.startsWith("ipns://"))&&(r=CU(r)),r.startsWith("http://")||r.startsWith("https://"))return new URL(r);throw new O(`Invalid URL: ${r}`)}function RJ(r){let e=PJ(r),t=e.hostname.match(TJ);if(IJ(t?.groups)){let n=t.groups;n.protocol==="ipns"&&AU(n.cidOrPeerIdOrDnsLink)&&(n.cidOrPeerIdOrDnsLink=_U(n.cidOrPeerIdOrDnsLink));let o=kJ(n.cidOrPeerIdOrDnsLink,r),i=new URL(`not-${r}`);return new URL(`${n.protocol}://${o}${i.pathname}${e.search}${e.hash}`)}if(e.pathname.startsWith("/ipfs/")){let o=e.pathname.substring(6).split("/").shift();if(o==null)throw new O(`Path gateway URL ${r} had no CID`);return new URL(`ipfs://${o}${e.pathname.replace(`/ipfs/${o}`,"")}${e.search}${e.hash}`)}if(e.pathname.startsWith("/ipns/")){let o=e.pathname.substring(6).split("/").shift();if(o==null)throw new O(`Path gateway URL ${r} had no name`);return new URL(`ipns://${o}${e.pathname.replace(`/ipns/${o}`,"")}${e.search}${e.hash}`)}throw new TypeError(`Invalid URL: ${r}, please use ipfs://, ipns://, or gateway URLs only`)}function O8(r){let e=RJ(r);if(e.protocol==="ipns:")try{ze(e.hostname)}catch{e.protocol="dnslink:"}if(e.protocol==="ipfs:"){let t=Z.parse(e.hostname);if(t.code===CJ)return new URL(`ipns://${oo(t)}${e.pathname}${e.search}${e.hash}`)}return e}function IU(r){let e=Z.asCID(r);if(e!=null)return`ipfs://${e}`;try{return`ipfs://${Z.parse(r.toString())}`}catch{}let{protocol:t,host:n}=O8(r.toString());return`${t}//${n}`}var ph=class{headers;constructor(){this.headers=[]}getHeader(){return this.headers.join(",")}async time(e,t,n){let o=performance.now();try{return await n}finally{let s=(performance.now()-o).toFixed(1);this.headers.push(`${e};dur=${s};desc="${t}"`)}}};var OJ=29030400,DJ=[81,lr,rt],NJ=[pt,fr,dr,rt];function kU(r,e,t){return{name:e.toString(),path:e.toString(),depth:0,type:r,node:t,cid:e,size:BigInt(t.byteLength),content:async function*(){yield t}}}var D8=class{components;blockstoreSessions;constructor(e,t={}){this.components=e,this.blockstoreSessions=new D0({maxSize:t.sessionCacheSize??100,maxAge:t.sessionTTLms??6e4,onEviction:(n,o)=>{o.close()}})}async resolve(e,t=new ph,n={}){if(e.protocol==="ipfs:")return this.resolveIPFSPath(e,t,n);if(e.protocol==="ipns:")return this.resolveIPNSName(e,t,n);if(e.protocol==="dnslink:")return this.resolveDNSLink(e,t,n);throw new ca(`Invalid resource. Unsupported protocol in URL, must be ipfs:, ipns:, or dnslink: ${e}`)}getBlockstore(e,t={}){if(t.session===!1)return this.components.helia.blockstore;let n=IU(e),o=this.blockstoreSessions.get(n);return o==null&&(o=this.components.helia.blockstore.createSession(e,t),this.blockstoreSessions.set(n,o)),o}async resolveDNSLink(e,t,n){let i=(await t.time("dnsLink.resolve",`Resolve DNSLink ${e.hostname}`,this.components.dnsLink.resolve(e.hostname,n)))?.[0];if(i==null)throw new TypeError(`Invalid resource. Cannot resolve DNSLink from domain: ${e.hostname}`);if(i.namespace==="ipns")return this.resolveIPNSName(e,t,n);if(i.namespace!=="ipfs")throw new TypeError(`Invalid resource. Unexpected DNSLink namespace ${i.namespace} from domain: ${domain}`);i.path!=null&&e.pathname!==""&&e.pathname;let s=new URL(`ipfs://${i.cid}/${e.pathname}`);return{...await this.resolveIPFSPath(s,t,n),url:e,ttl:i.answer.TTL}}async resolveIPNSName(e,t,n){let o=ze(e.hostname),i=await t.time("ipns.resolve",`Resolve IPNS name ${o}`,this.components.ipnsResolver.resolve(o,n));i.path!=null&&e.pathname!==""&&e.pathname;let s=new URL(`ipfs://${i.cid}/${e.pathname}`);return{...await this.resolveIPFSPath(s,t,n),url:e,ttl:Number((i.record.ttl??0n)/BigInt(1e9))}}async resolveIPFSPath(e,t,n){let o=await t.time("ipfs.resolve","",this.walkPath(e,n));return{...o,url:e,ttl:OJ,blockstore:o.blockstore}}async walkPath(e,t={}){let n=Z.parse(e.hostname),o=this.getBlockstore(n,t);if(NJ.includes(n.code)){let s=[],a,c=LJ(e);for await(let l of ES(c,o,{...t,offline:t.onlyIfCached===!0,extended:t.isRawBlockRequest!==!0}))s.push(l.cid),a=l;if(a==null)throw new C8("No terminal element found");return{ipfsRoots:s,terminalElement:a,blockstore:o}}let i;return n.multihash.code===0?i=n.multihash.digest:i=await Ge(o.get(n,t)),DJ.includes(n.code)?{ipfsRoots:[n],terminalElement:kU("object",n,i),blockstore:o}:{ipfsRoots:[n],terminalElement:kU("raw",n,i),blockstore:o}}};function LJ(r){return`/ipfs/${r.hostname}${decodeURI(r.pathname)}`}var OU=gt(PU(),1);var OS={128:"\u20AC",130:"\u201A",131:"\u0192",132:"\u201E",133:"\u2026",134:"\u2020",135:"\u2021",136:"\u02C6",137:"\u2030",138:"\u0160",139:"\u2039",140:"\u0152",142:"\u017D",145:"\u2018",146:"\u2019",147:"\u201C",148:"\u201D",149:"\u2022",150:"\u2013",151:"\u2014",152:"\u02DC",153:"\u2122",154:"\u0161",155:"\u203A",156:"\u0153",158:"\u017E",159:"\u0178"},BJ={};for(let[r,e]of Object.entries(OS))BJ[e]=Number.parseInt(r);function RU(r,e="utf-8"){switch(e.toLowerCase()){case"utf-8":case"utf8":return typeof globalThis.TextDecoder<"u"?new globalThis.TextDecoder("utf-8").decode(r):MJ(r);case"utf-16le":return UJ(r);case"ascii":return FJ(r);case"latin1":case"iso-8859-1":return $J(r);case"windows-1252":return HJ(r);default:throw new RangeError(`Encoding '${e}' not supported`)}}function MJ(r){let e="",t=0;for(;t<r.length;){let n=r[t++];if(n<128)e+=String.fromCharCode(n);else if(n<224){let o=r[t++]&63;e+=String.fromCharCode((n&31)<<6|o)}else if(n<240){let o=r[t++]&63,i=r[t++]&63;e+=String.fromCharCode((n&15)<<12|o<<6|i)}else{let o=r[t++]&63,i=r[t++]&63,s=r[t++]&63,a=(n&7)<<18|o<<12|i<<6|s;a-=65536,e+=String.fromCharCode(55296+(a>>10&1023),56320+(a&1023))}}return e}function UJ(r){let e="";for(let t=0;t<r.length;t+=2)e+=String.fromCharCode(r[t]|r[t+1]<<8);return e}function FJ(r){return String.fromCharCode(...r.map(e=>e&127))}function $J(r){return String.fromCharCode(...r)}function HJ(r){let e="";for(let t of r)t>=128&&t<=159&&OS[t]?e+=OS[t]:e+=String.fromCharCode(t);return e}function qn(r){return new DataView(r.buffer,r.byteOffset)}var DU={len:1,get(r,e){return qn(r).getUint8(e)},put(r,e,t){return qn(r).setUint8(e,t),e+1}},Ut={len:2,get(r,e){return qn(r).getUint16(e,!0)},put(r,e,t){return qn(r).setUint16(e,t,!0),e+2}},mh={len:2,get(r,e){return qn(r).getUint16(e)},put(r,e,t){return qn(r).setUint16(e,t),e+2}};var Yt={len:4,get(r,e){return qn(r).getUint32(e,!0)},put(r,e,t){return qn(r).setUint32(e,t,!0),e+4}},NU={len:4,get(r,e){return qn(r).getUint32(e)},put(r,e,t){return qn(r).setUint32(e,t),e+4}};var LU={len:4,get(r,e){return qn(r).getInt32(e)},put(r,e,t){return qn(r).setInt32(e,t),e+4}};var BU={len:8,get(r,e){return qn(r).getBigUint64(e,!0)},put(r,e,t){return qn(r).setBigUint64(e,t,!0),e+8}};var zn=class{constructor(e,t){this.len=e,this.encoding=t}get(e,t=0){let n=e.subarray(t,t+this.len);return RU(n,this.encoding)}};var VJ="End-Of-Stream",kt=class extends Error{constructor(){super(VJ),this.name="EndOfStreamError"}},Ou=class extends Error{constructor(e="The operation was aborted"){super(e),this.name="AbortError"}};var Du=class{constructor(){this.endOfStream=!1,this.interrupted=!1,this.peekQueue=[]}async peek(e,t=!1){let n=await this.read(e,t);return this.peekQueue.push(e.subarray(0,n)),n}async read(e,t=!1){if(e.length===0)return 0;let n=this.readFromPeekBuffer(e);if(this.endOfStream||(n+=await this.readRemainderFromStream(e.subarray(n),t)),n===0&&!t)throw new kt;return n}readFromPeekBuffer(e){let t=e.length,n=0;for(;this.peekQueue.length>0&&t>0;){let o=this.peekQueue.pop();if(!o)throw new Error("peekData should be defined");let i=Math.min(o.length,t);e.set(o.subarray(0,i),n),n+=i,t-=i,i<o.length&&this.peekQueue.push(o.subarray(i))}return n}async readRemainderFromStream(e,t){let n=0;for(;n<e.length&&!this.endOfStream;){if(this.interrupted)throw new Ou;let o=await this.readFromStream(e.subarray(n),t);if(o===0)break;n+=o}if(!t&&n<e.length)throw new kt;return n}};var N8=class extends Du{constructor(e){super(),this.reader=e}async abort(){return this.close()}async close(){this.reader.releaseLock()}};var N0=class extends N8{async readFromStream(e,t){if(e.length===0)return 0;let n=await this.reader.read(new Uint8Array(e.length),{min:t?void 0:e.length});return n.done&&(this.endOfStream=n.done),n.value?(e.set(n.value),n.value.length):0}};var gh=class extends Du{constructor(e){super(),this.reader=e,this.buffer=null}writeChunk(e,t){let n=Math.min(t.length,e.length);return e.set(t.subarray(0,n)),n<t.length?this.buffer=t.subarray(n):this.buffer=null,n}async readFromStream(e,t){if(e.length===0)return 0;let n=0;for(this.buffer&&(n+=this.writeChunk(e,this.buffer));n<e.length&&!this.endOfStream;){let o=await this.reader.read();if(o.done){this.endOfStream=!0;break}o.value&&(n+=this.writeChunk(e.subarray(n),o.value))}if(!t&&n===0&&this.endOfStream)throw new kt;return n}abort(){return this.interrupted=!0,this.reader.cancel()}async close(){await this.abort(),this.reader.releaseLock()}};function DS(r){try{let e=r.getReader({mode:"byob"});return e instanceof ReadableStreamDefaultReader?new gh(e):new N0(e)}catch(e){if(e instanceof TypeError)return new gh(r.getReader());throw e}}var ua=class{constructor(e){this.numBuffer=new Uint8Array(8),this.position=0,this.onClose=e?.onClose,e?.abortSignal&&e.abortSignal.addEventListener("abort",()=>{this.abort()})}async readToken(e,t=this.position){let n=new Uint8Array(e.len);if(await this.readBuffer(n,{position:t})<e.len)throw new kt;return e.get(n,0)}async peekToken(e,t=this.position){let n=new Uint8Array(e.len);if(await this.peekBuffer(n,{position:t})<e.len)throw new kt;return e.get(n,0)}async readNumber(e){if(await this.readBuffer(this.numBuffer,{length:e.len})<e.len)throw new kt;return e.get(this.numBuffer,0)}async peekNumber(e){if(await this.peekBuffer(this.numBuffer,{length:e.len})<e.len)throw new kt;return e.get(this.numBuffer,0)}async ignore(e){if(this.fileInfo.size!==void 0){let t=this.fileInfo.size-this.position;if(e>t)return this.position+=t,t}return this.position+=e,e}async close(){await this.abort(),await this.onClose?.()}normalizeOptions(e,t){if(!this.supportsRandomAccess()&&t&&t.position!==void 0&&t.position<this.position)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");return{mayBeLess:!1,offset:0,length:e.length,position:this.position,...t}}abort(){return Promise.resolve()}};var zJ=256e3,L8=class extends ua{constructor(e,t){super(t),this.streamReader=e,this.fileInfo=t?.fileInfo??{}}async readBuffer(e,t){let n=this.normalizeOptions(e,t),o=n.position-this.position;if(o>0)return await this.ignore(o),this.readBuffer(e,t);if(o<0)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");if(n.length===0)return 0;let i=await this.streamReader.read(e.subarray(0,n.length),n.mayBeLess);if(this.position+=i,(!t||!t.mayBeLess)&&i<n.length)throw new kt;return i}async peekBuffer(e,t){let n=this.normalizeOptions(e,t),o=0;if(n.position){let i=n.position-this.position;if(i>0){let s=new Uint8Array(n.length+i);return o=await this.peekBuffer(s,{mayBeLess:n.mayBeLess}),e.set(s.subarray(i)),o-i}if(i<0)throw new Error("Cannot peek from a negative offset in a stream")}if(n.length>0){try{o=await this.streamReader.peek(e.subarray(0,n.length),n.mayBeLess)}catch(i){if(t?.mayBeLess&&i instanceof kt)return 0;throw i}if(!n.mayBeLess&&o<n.length)throw new kt}return o}async ignore(e){let t=Math.min(zJ,e),n=new Uint8Array(t),o=0;for(;o<e;){let i=e-o,s=await this.readBuffer(n,{length:Math.min(t,i)});if(s<0)return s;o+=s}return o}abort(){return this.streamReader.abort()}async close(){return this.streamReader.close()}supportsRandomAccess(){return!1}};var B8=class extends ua{constructor(e,t){super(t),this.uint8Array=e,this.fileInfo={...t?.fileInfo??{},size:e.length}}async readBuffer(e,t){t?.position&&(this.position=t.position);let n=await this.peekBuffer(e,t);return this.position+=n,n}async peekBuffer(e,t){let n=this.normalizeOptions(e,t),o=Math.min(this.uint8Array.length-n.position,n.length);if(!n.mayBeLess&&o<n.length)throw new kt;return e.set(this.uint8Array.subarray(n.position,n.position+o)),o}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(e){this.position=e}};var M8=class extends ua{constructor(e,t){super(t),this.blob=e,this.fileInfo={...t?.fileInfo??{},size:e.size,mimeType:e.type}}async readBuffer(e,t){t?.position&&(this.position=t.position);let n=await this.peekBuffer(e,t);return this.position+=n,n}async peekBuffer(e,t){let n=this.normalizeOptions(e,t),o=Math.min(this.blob.size-n.position,n.length);if(!n.mayBeLess&&o<n.length)throw new kt;let i=await this.blob.slice(n.position,n.position+o).arrayBuffer();return e.set(new Uint8Array(i)),o}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(e){this.position=e}};function MU(r,e){let t=DS(r),n=e??{},o=n.onClose;return n.onClose=async()=>{if(await t.close(),o)return o()},new L8(t,n)}function UU(r,e){return new B8(r,e)}function FU(r,e){return new M8(r,e)}var GU=gt(qU(),1);var Lu={LocalFileHeader:67324752,DataDescriptor:134695760,CentralFileHeader:33639248,EndOfCentralDirectory:101010256},NS={get(r){return{signature:Yt.get(r,0),compressedSize:Yt.get(r,8),uncompressedSize:Yt.get(r,12)}},len:16},zU={get(r){let e=Ut.get(r,6);return{signature:Yt.get(r,0),minVersion:Ut.get(r,4),dataDescriptor:!!(e&8),compressedMethod:Ut.get(r,8),compressedSize:Yt.get(r,18),uncompressedSize:Yt.get(r,22),filenameLength:Ut.get(r,26),extraFieldLength:Ut.get(r,28),filename:null}},len:30},jU={get(r){return{signature:Yt.get(r,0),nrOfThisDisk:Ut.get(r,4),nrOfThisDiskWithTheStart:Ut.get(r,6),nrOfEntriesOnThisDisk:Ut.get(r,8),nrOfEntriesOfSize:Ut.get(r,10),sizeOfCd:Yt.get(r,12),offsetOfStartOfCd:Yt.get(r,16),zipFileCommentLength:Ut.get(r,20)}},len:22},WU={get(r){let e=Ut.get(r,8);return{signature:Yt.get(r,0),minVersion:Ut.get(r,6),dataDescriptor:!!(e&8),compressedMethod:Ut.get(r,10),compressedSize:Yt.get(r,20),uncompressedSize:Yt.get(r,24),filenameLength:Ut.get(r,28),extraFieldLength:Ut.get(r,30),fileCommentLength:Ut.get(r,32),relativeOffsetOfLocalHeader:Yt.get(r,42),filename:null}},len:46};function XU(r){let e=new Uint8Array(Yt.len);return Yt.put(e,0,r),e}var as=(0,GU.default)("tokenizer:inflate"),LS=256*1024,iee=XU(Lu.DataDescriptor),$8=XU(Lu.EndOfCentralDirectory),L0=class r{constructor(e){this.tokenizer=e,this.syncBuffer=new Uint8Array(LS)}async isZip(){return await this.peekSignature()===Lu.LocalFileHeader}peekSignature(){return this.tokenizer.peekToken(Yt)}async findEndOfCentralDirectoryLocator(){let e=this.tokenizer,t=Math.min(16*1024,e.fileInfo.size),n=this.syncBuffer.subarray(0,t);await this.tokenizer.readBuffer(n,{position:e.fileInfo.size-t});for(let o=n.length-4;o>=0;o--)if(n[o]===$8[0]&&n[o+1]===$8[1]&&n[o+2]===$8[2]&&n[o+3]===$8[3])return e.fileInfo.size-t+o;return-1}async readCentralDirectory(){if(!this.tokenizer.supportsRandomAccess()){as("Cannot reading central-directory without random-read support");return}as("Reading central-directory...");let e=this.tokenizer.position,t=await this.findEndOfCentralDirectoryLocator();if(t>0){as("Central-directory 32-bit signature found");let n=await this.tokenizer.readToken(jU,t),o=[];this.tokenizer.setPosition(n.offsetOfStartOfCd);for(let i=0;i<n.nrOfEntriesOfSize;++i){let s=await this.tokenizer.readToken(WU);if(s.signature!==Lu.CentralFileHeader)throw new Error("Expected Central-File-Header signature");s.filename=await this.tokenizer.readToken(new zn(s.filenameLength,"utf-8")),await this.tokenizer.ignore(s.extraFieldLength),await this.tokenizer.ignore(s.fileCommentLength),o.push(s),as(`Add central-directory file-entry: n=${i+1}/${o.length}: filename=${o[i].filename}`)}return this.tokenizer.setPosition(e),o}this.tokenizer.setPosition(e)}async unzip(e){let t=await this.readCentralDirectory();if(t)return this.iterateOverCentralDirectory(t,e);let n=!1;do{let o=await this.readLocalFileHeader();if(!o)break;let i=e(o);n=!!i.stop;let s;if(await this.tokenizer.ignore(o.extraFieldLength),o.dataDescriptor&&o.compressedSize===0){let a=[],c=LS;as("Compressed-file-size unknown, scanning for next data-descriptor-signature....");let l=-1;for(;l<0&&c===LS;){c=await this.tokenizer.peekBuffer(this.syncBuffer,{mayBeLess:!0}),l=see(this.syncBuffer.subarray(0,c),iee);let f=l>=0?l:c;if(i.handler){let u=new Uint8Array(f);await this.tokenizer.readBuffer(u),a.push(u)}else await this.tokenizer.ignore(f)}as(`Found data-descriptor-signature at pos=${this.tokenizer.position}`),i.handler&&await this.inflate(o,aee(a),i.handler)}else i.handler?(as(`Reading compressed-file-data: ${o.compressedSize} bytes`),s=new Uint8Array(o.compressedSize),await this.tokenizer.readBuffer(s),await this.inflate(o,s,i.handler)):(as(`Ignoring compressed-file-data: ${o.compressedSize} bytes`),await this.tokenizer.ignore(o.compressedSize));if(as(`Reading data-descriptor at pos=${this.tokenizer.position}`),o.dataDescriptor&&(await this.tokenizer.readToken(NS)).signature!==134695760)throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-NS.len}`)}while(!n)}async iterateOverCentralDirectory(e,t){for(let n of e){let o=t(n);if(o.handler){this.tokenizer.setPosition(n.relativeOffsetOfLocalHeader);let i=await this.readLocalFileHeader();if(i){await this.tokenizer.ignore(i.extraFieldLength);let s=new Uint8Array(n.compressedSize);await this.tokenizer.readBuffer(s),await this.inflate(i,s,o.handler)}}if(o.stop)break}}async inflate(e,t,n){if(e.compressedMethod===0)return n(t);if(e.compressedMethod!==8)throw new Error(`Unsupported ZIP compression method: ${e.compressedMethod}`);as(`Decompress filename=${e.filename}, compressed-size=${t.length}`);let o=await r.decompressDeflateRaw(t);return n(o)}static async decompressDeflateRaw(e){let t=new ReadableStream({start(i){i.enqueue(e),i.close()}}),n=new DecompressionStream("deflate-raw"),o=t.pipeThrough(n);try{let s=await new Response(o).arrayBuffer();return new Uint8Array(s)}catch(i){let s=i instanceof Error?`Failed to deflate ZIP entry: ${i.message}`:"Unknown decompression error in ZIP entry";throw new TypeError(s)}}async readLocalFileHeader(){let e=await this.tokenizer.peekToken(Yt);if(e===Lu.LocalFileHeader){let t=await this.tokenizer.readToken(zU);return t.filename=await this.tokenizer.readToken(new zn(t.filenameLength,"utf-8")),t}if(e===Lu.CentralFileHeader)return!1;throw e===3759263696?new Error("Encrypted ZIP"):new Error("Unexpected signature")}};function see(r,e){let t=r.length,n=e.length;if(n>t)return-1;for(let o=0;o<=t-n;o++){let i=!0;for(let s=0;s<n;s++)if(r[o+s]!==e[s]){i=!1;break}if(i)return o}return-1}function aee(r){let e=r.reduce((o,i)=>o+i.length,0),t=new Uint8Array(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return t}var B0=class{constructor(e){this.tokenizer=e}inflate(){let e=this.tokenizer;return new ReadableStream({async pull(t){let n=new Uint8Array(1024),o=await e.readBuffer(n,{mayBeLess:!0});if(o===0){t.close();return}t.enqueue(n.subarray(0,o))}}).pipeThrough(new DecompressionStream("gzip"))}};var Qnt={utf8:new globalThis.TextDecoder("utf8")};var Znt=new globalThis.TextEncoder;var Jnt=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function BS(r){let{byteLength:e}=r;if(e===6)return r.getUint16(0)*2**32+r.getUint32(2);if(e===5)return r.getUint8(0)*2**32+r.getUint32(1);if(e===4)return r.getUint32(0);if(e===3)return r.getUint8(0)*2**16+r.getUint16(1);if(e===2)return r.getUint16(0);if(e===1)return r.getUint8(0)}function YU(r,e){if(e==="utf-16le"){let t=[];for(let n=0;n<r.length;n++){let o=r.charCodeAt(n);t.push(o&255,o>>8&255)}return t}if(e==="utf-16be"){let t=[];for(let n=0;n<r.length;n++){let o=r.charCodeAt(n);t.push(o>>8&255,o&255)}return t}return[...r].map(t=>t.charCodeAt(0))}function QU(r,e=0){let t=Number.parseInt(new zn(6).get(r,148).replace(/\0.*$/,"").trim(),8);if(Number.isNaN(t))return!1;let n=256;for(let o=e;o<e+148;o++)n+=r[o];for(let o=e+156;o<e+512;o++)n+=r[o];return t===n}var ZU={get:(r,e)=>r[e+3]&127|r[e+2]<<7|r[e+1]<<14|r[e]<<21,len:4};var JU=["jpg","png","apng","gif","webp","flif","xcf","cr2","cr3","orf","arw","dng","nef","rw2","raf","tif","bmp","icns","jxr","psd","indd","zip","tar","rar","gz","bz2","7z","dmg","mp4","mid","mkv","webm","mov","avi","mpg","mp2","mp3","m4a","oga","ogg","ogv","opus","flac","wav","spx","amr","pdf","epub","elf","macho","exe","swf","rtf","wasm","woff","woff2","eot","ttf","otf","ttc","ico","flv","ps","xz","sqlite","nes","crx","xpi","cab","deb","ar","rpm","Z","lz","cfb","mxf","mts","blend","bpg","docx","pptx","xlsx","3gp","3g2","j2c","jp2","jpm","jpx","mj2","aif","qcp","odt","ods","odp","xml","mobi","heic","cur","ktx","ape","wv","dcm","ics","glb","pcap","dsf","lnk","alias","voc","ac3","m4v","m4p","m4b","f4v","f4p","f4b","f4a","mie","asf","ogm","ogx","mpc","arrow","shp","aac","mp1","it","s3m","xm","skp","avif","eps","lzh","pgp","asar","stl","chm","3mf","zst","jxl","vcf","jls","pst","dwg","parquet","class","arj","cpio","ace","avro","icc","fbx","vsdx","vtt","apk","drc","lz4","potx","xltx","dotx","xltm","ott","ots","otp","odg","otg","xlsm","docm","dotm","potm","pptm","jar","rm","ppsm","ppsx","tar.gz","reg","dat"],eF=["image/jpeg","image/png","image/gif","image/webp","image/flif","image/x-xcf","image/x-canon-cr2","image/x-canon-cr3","image/tiff","image/bmp","image/vnd.ms-photo","image/vnd.adobe.photoshop","application/x-indesign","application/epub+zip","application/x-xpinstall","application/vnd.ms-powerpoint.slideshow.macroenabled.12","application/vnd.oasis.opendocument.text","application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.presentation","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.presentationml.slideshow","application/zip","application/x-tar","application/x-rar-compressed","application/gzip","application/x-bzip2","application/x-7z-compressed","application/x-apple-diskimage","application/vnd.apache.arrow.file","video/mp4","audio/midi","video/matroska","video/webm","video/quicktime","video/vnd.avi","audio/wav","audio/qcelp","audio/x-ms-asf","video/x-ms-asf","application/vnd.ms-asf","video/mpeg","video/3gpp","audio/mpeg","audio/mp4","video/ogg","audio/ogg","audio/ogg; codecs=opus","application/ogg","audio/flac","audio/ape","audio/wavpack","audio/amr","application/pdf","application/x-elf","application/x-mach-binary","application/x-msdownload","application/x-shockwave-flash","application/rtf","application/wasm","font/woff","font/woff2","application/vnd.ms-fontobject","font/ttf","font/otf","font/collection","image/x-icon","video/x-flv","application/postscript","application/eps","application/x-xz","application/x-sqlite3","application/x-nintendo-nes-rom","application/x-google-chrome-extension","application/vnd.ms-cab-compressed","application/x-deb","application/x-unix-archive","application/x-rpm","application/x-compress","application/x-lzip","application/x-cfb","application/x-mie","application/mxf","video/mp2t","application/x-blender","image/bpg","image/j2c","image/jp2","image/jpx","image/jpm","image/mj2","audio/aiff","application/xml","application/x-mobipocket-ebook","image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/icns","image/ktx","application/dicom","audio/x-musepack","text/calendar","text/vcard","text/vtt","model/gltf-binary","application/vnd.tcpdump.pcap","audio/x-dsf","application/x.ms.shortcut","application/x.apple.alias","audio/x-voc","audio/vnd.dolby.dd-raw","audio/x-m4a","image/apng","image/x-olympus-orf","image/x-sony-arw","image/x-adobe-dng","image/x-nikon-nef","image/x-panasonic-rw2","image/x-fujifilm-raf","video/x-m4v","video/3gpp2","application/x-esri-shape","audio/aac","audio/x-it","audio/x-s3m","audio/x-xm","video/MP1S","video/MP2P","application/vnd.sketchup.skp","image/avif","application/x-lzh-compressed","application/pgp-encrypted","application/x-asar","model/stl","application/vnd.ms-htmlhelp","model/3mf","image/jxl","application/zstd","image/jls","application/vnd.ms-outlook","image/vnd.dwg","application/vnd.apache.parquet","application/java-vm","application/x-arj","application/x-cpio","application/x-ace-compressed","application/avro","application/vnd.iccprofile","application/x.autodesk.fbx","application/vnd.visio","application/vnd.android.package-archive","application/vnd.google.draco","application/x-lz4","application/vnd.openxmlformats-officedocument.presentationml.template","application/vnd.openxmlformats-officedocument.spreadsheetml.template","application/vnd.openxmlformats-officedocument.wordprocessingml.template","application/vnd.ms-excel.template.macroenabled.12","application/vnd.oasis.opendocument.text-template","application/vnd.oasis.opendocument.spreadsheet-template","application/vnd.oasis.opendocument.presentation-template","application/vnd.oasis.opendocument.graphics","application/vnd.oasis.opendocument.graphics-template","application/vnd.ms-excel.sheet.macroenabled.12","application/vnd.ms-word.document.macroenabled.12","application/vnd.ms-word.template.macroenabled.12","application/vnd.ms-powerpoint.template.macroenabled.12","application/vnd.ms-powerpoint.presentation.macroenabled.12","application/java-archive","application/vnd.rn-realmedia","application/x-ms-regedit","application/x-ft-windows-registry-hive"];var MS=4100;async function tF(r,e){return new FS(e).fromBuffer(r)}function US(r){switch(r=r.toLowerCase(),r){case"application/epub+zip":return{ext:"epub",mime:r};case"application/vnd.oasis.opendocument.text":return{ext:"odt",mime:r};case"application/vnd.oasis.opendocument.text-template":return{ext:"ott",mime:r};case"application/vnd.oasis.opendocument.spreadsheet":return{ext:"ods",mime:r};case"application/vnd.oasis.opendocument.spreadsheet-template":return{ext:"ots",mime:r};case"application/vnd.oasis.opendocument.presentation":return{ext:"odp",mime:r};case"application/vnd.oasis.opendocument.presentation-template":return{ext:"otp",mime:r};case"application/vnd.oasis.opendocument.graphics":return{ext:"odg",mime:r};case"application/vnd.oasis.opendocument.graphics-template":return{ext:"otg",mime:r};case"application/vnd.openxmlformats-officedocument.presentationml.slideshow":return{ext:"ppsx",mime:r};case"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":return{ext:"xlsx",mime:r};case"application/vnd.ms-excel.sheet.macroenabled":return{ext:"xlsm",mime:"application/vnd.ms-excel.sheet.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.spreadsheetml.template":return{ext:"xltx",mime:r};case"application/vnd.ms-excel.template.macroenabled":return{ext:"xltm",mime:"application/vnd.ms-excel.template.macroenabled.12"};case"application/vnd.ms-powerpoint.slideshow.macroenabled":return{ext:"ppsm",mime:"application/vnd.ms-powerpoint.slideshow.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":return{ext:"docx",mime:r};case"application/vnd.ms-word.document.macroenabled":return{ext:"docm",mime:"application/vnd.ms-word.document.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.template":return{ext:"dotx",mime:r};case"application/vnd.ms-word.template.macroenabledtemplate":return{ext:"dotm",mime:"application/vnd.ms-word.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.template":return{ext:"potx",mime:r};case"application/vnd.ms-powerpoint.template.macroenabled":return{ext:"potm",mime:"application/vnd.ms-powerpoint.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.presentation":return{ext:"pptx",mime:r};case"application/vnd.ms-powerpoint.presentation.macroenabled":return{ext:"pptm",mime:"application/vnd.ms-powerpoint.presentation.macroenabled.12"};case"application/vnd.ms-visio.drawing":return{ext:"vsdx",mime:"application/vnd.visio"};case"application/vnd.ms-package.3dmanufacturing-3dmodel+xml":return{ext:"3mf",mime:"model/3mf"};default:}}function cs(r,e,t){t={offset:0,...t};for(let[n,o]of e.entries())if(t.mask){if(o!==(t.mask[n]&r[n+t.offset]))return!1}else if(o!==r[n+t.offset])return!1;return!0}var FS=class{constructor(e){this.options={mpegOffsetTolerance:0,...e},this.detectors=[...e?.customDetectors??[],{id:"core",detect:this.detectConfident},{id:"core.imprecise",detect:this.detectImprecise}],this.tokenizerOptions={abortSignal:e?.signal}}async fromTokenizer(e){let t=e.position;for(let n of this.detectors){let o=await n.detect(e);if(o)return o;if(t!==e.position)return}}async fromBuffer(e){if(!(e instanceof Uint8Array||e instanceof ArrayBuffer))throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof e}\``);let t=e instanceof Uint8Array?e:new Uint8Array(e);if(t?.length>1)return this.fromTokenizer(UU(t,this.tokenizerOptions))}async fromBlob(e){let t=FU(e,this.tokenizerOptions);try{return await this.fromTokenizer(t)}finally{await t.close()}}async fromStream(e){let t=MU(e,this.tokenizerOptions);try{return await this.fromTokenizer(t)}finally{await t.close()}}async toDetectionStream(e,t){let{sampleSize:n=MS}=t,o,i,s=e.getReader({mode:"byob"});try{let{value:l,done:f}=await s.read(new Uint8Array(n));if(i=l,!f&&l)try{o=await this.fromBuffer(l.subarray(0,n))}catch(u){if(!(u instanceof kt))throw u;o=void 0}i=l}finally{s.releaseLock()}let a=new TransformStream({async start(l){l.enqueue(i)},transform(l,f){f.enqueue(l)}}),c=e.pipeThrough(a);return c.fileType=o,c}check(e,t){return cs(this.buffer,e,t)}checkString(e,t){return this.check(YU(e,t?.encoding),t)}detectConfident=async e=>{if(this.buffer=new Uint8Array(MS),e.fileInfo.size===void 0&&(e.fileInfo.size=Number.MAX_SAFE_INTEGER),this.tokenizer=e,await e.peekBuffer(this.buffer,{length:32,mayBeLess:!0}),this.check([66,77]))return{ext:"bmp",mime:"image/bmp"};if(this.check([11,119]))return{ext:"ac3",mime:"audio/vnd.dolby.dd-raw"};if(this.check([120,1]))return{ext:"dmg",mime:"application/x-apple-diskimage"};if(this.check([77,90]))return{ext:"exe",mime:"application/x-msdownload"};if(this.check([37,33]))return await e.peekBuffer(this.buffer,{length:24,mayBeLess:!0}),this.checkString("PS-Adobe-",{offset:2})&&this.checkString(" EPSF-",{offset:14})?{ext:"eps",mime:"application/eps"}:{ext:"ps",mime:"application/postscript"};if(this.check([31,160])||this.check([31,157]))return{ext:"Z",mime:"application/x-compress"};if(this.check([199,113]))return{ext:"cpio",mime:"application/x-cpio"};if(this.check([96,234]))return{ext:"arj",mime:"application/x-arj"};if(this.check([239,187,191]))return this.tokenizer.ignore(3),this.detectConfident(e);if(this.check([71,73,70]))return{ext:"gif",mime:"image/gif"};if(this.check([73,73,188]))return{ext:"jxr",mime:"image/vnd.ms-photo"};if(this.check([31,139,8])){let n=new B0(e).inflate(),o=!0;try{let i;try{i=await this.fromStream(n)}catch{o=!1}if(i&&i.ext==="tar")return{ext:"tar.gz",mime:"application/gzip"}}finally{o&&await n.cancel()}return{ext:"gz",mime:"application/gzip"}}if(this.check([66,90,104]))return{ext:"bz2",mime:"application/x-bzip2"};if(this.checkString("ID3")){await e.ignore(6);let t=await e.readToken(ZU);return e.position+t>e.fileInfo.size?{ext:"mp3",mime:"audio/mpeg"}:(await e.ignore(t),this.fromTokenizer(e))}if(this.checkString("MP+"))return{ext:"mpc",mime:"audio/x-musepack"};if((this.buffer[0]===67||this.buffer[0]===70)&&this.check([87,83],{offset:1}))return{ext:"swf",mime:"application/x-shockwave-flash"};if(this.check([255,216,255]))return this.check([247],{offset:3})?{ext:"jls",mime:"image/jls"}:{ext:"jpg",mime:"image/jpeg"};if(this.check([79,98,106,1]))return{ext:"avro",mime:"application/avro"};if(this.checkString("FLIF"))return{ext:"flif",mime:"image/flif"};if(this.checkString("8BPS"))return{ext:"psd",mime:"image/vnd.adobe.photoshop"};if(this.checkString("MPCK"))return{ext:"mpc",mime:"audio/x-musepack"};if(this.checkString("FORM"))return{ext:"aif",mime:"audio/aiff"};if(this.checkString("icns",{offset:0}))return{ext:"icns",mime:"image/icns"};if(this.check([80,75,3,4])){let t;return await new L0(e).unzip(n=>{switch(n.filename){case"META-INF/mozilla.rsa":return t={ext:"xpi",mime:"application/x-xpinstall"},{stop:!0};case"META-INF/MANIFEST.MF":return t={ext:"jar",mime:"application/java-archive"},{stop:!0};case"mimetype":return{async handler(o){let i=new TextDecoder("utf-8").decode(o).trim();t=US(i)},stop:!0};case"[Content_Types].xml":return{async handler(o){let i=new TextDecoder("utf-8").decode(o),s=i.indexOf('.main+xml"');if(s===-1){let a="application/vnd.ms-package.3dmanufacturing-3dmodel+xml";i.includes(`ContentType="${a}"`)&&(t=US(a))}else{i=i.slice(0,Math.max(0,s));let a=i.lastIndexOf('"'),c=i.slice(Math.max(0,a+1));t=US(c)}},stop:!0};default:return/classes\d*\.dex/.test(n.filename)?(t={ext:"apk",mime:"application/vnd.android.package-archive"},{stop:!0}):{}}}).catch(n=>{if(!(n instanceof kt))throw n}),t??{ext:"zip",mime:"application/zip"}}if(this.checkString("OggS")){await e.ignore(28);let t=new Uint8Array(8);return await e.readBuffer(t),cs(t,[79,112,117,115,72,101,97,100])?{ext:"opus",mime:"audio/ogg; codecs=opus"}:cs(t,[128,116,104,101,111,114,97])?{ext:"ogv",mime:"video/ogg"}:cs(t,[1,118,105,100,101,111,0])?{ext:"ogm",mime:"video/ogg"}:cs(t,[127,70,76,65,67])?{ext:"oga",mime:"audio/ogg"}:cs(t,[83,112,101,101,120,32,32])?{ext:"spx",mime:"audio/ogg"}:cs(t,[1,118,111,114,98,105,115])?{ext:"ogg",mime:"audio/ogg"}:{ext:"ogx",mime:"application/ogg"}}if(this.check([80,75])&&(this.buffer[2]===3||this.buffer[2]===5||this.buffer[2]===7)&&(this.buffer[3]===4||this.buffer[3]===6||this.buffer[3]===8))return{ext:"zip",mime:"application/zip"};if(this.checkString("MThd"))return{ext:"mid",mime:"audio/midi"};if(this.checkString("wOFF")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff",mime:"font/woff"};if(this.checkString("wOF2")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff2",mime:"font/woff2"};if(this.check([212,195,178,161])||this.check([161,178,195,212]))return{ext:"pcap",mime:"application/vnd.tcpdump.pcap"};if(this.checkString("DSD "))return{ext:"dsf",mime:"audio/x-dsf"};if(this.checkString("LZIP"))return{ext:"lz",mime:"application/x-lzip"};if(this.checkString("fLaC"))return{ext:"flac",mime:"audio/flac"};if(this.check([66,80,71,251]))return{ext:"bpg",mime:"image/bpg"};if(this.checkString("wvpk"))return{ext:"wv",mime:"audio/wavpack"};if(this.checkString("%PDF"))return{ext:"pdf",mime:"application/pdf"};if(this.check([0,97,115,109]))return{ext:"wasm",mime:"application/wasm"};if(this.check([73,73])){let t=await this.readTiffHeader(!1);if(t)return t}if(this.check([77,77])){let t=await this.readTiffHeader(!0);if(t)return t}if(this.checkString("MAC "))return{ext:"ape",mime:"audio/ape"};if(this.check([26,69,223,163])){async function t(){let a=await e.peekNumber(DU),c=128,l=0;for(;(a&c)===0&&c!==0;)++l,c>>=1;let f=new Uint8Array(l+1);return await e.readBuffer(f),f}async function n(){let a=await t(),c=await t();c[0]^=128>>c.length-1;let l=Math.min(6,c.length),f=new DataView(a.buffer),u=new DataView(c.buffer,c.length-l,l);return{id:BS(f),len:BS(u)}}async function o(a){for(;a>0;){let c=await n();if(c.id===17026)return(await e.readToken(new zn(c.len))).replaceAll(/\00.*$/g,"");await e.ignore(c.len),--a}}let i=await n();switch(await o(i.len)){case"webm":return{ext:"webm",mime:"video/webm"};case"matroska":return{ext:"mkv",mime:"video/matroska"};default:return}}if(this.checkString("SQLi"))return{ext:"sqlite",mime:"application/x-sqlite3"};if(this.check([78,69,83,26]))return{ext:"nes",mime:"application/x-nintendo-nes-rom"};if(this.checkString("Cr24"))return{ext:"crx",mime:"application/x-google-chrome-extension"};if(this.checkString("MSCF")||this.checkString("ISc("))return{ext:"cab",mime:"application/vnd.ms-cab-compressed"};if(this.check([237,171,238,219]))return{ext:"rpm",mime:"application/x-rpm"};if(this.check([197,208,211,198]))return{ext:"eps",mime:"application/eps"};if(this.check([40,181,47,253]))return{ext:"zst",mime:"application/zstd"};if(this.check([127,69,76,70]))return{ext:"elf",mime:"application/x-elf"};if(this.check([33,66,68,78]))return{ext:"pst",mime:"application/vnd.ms-outlook"};if(this.checkString("PAR1")||this.checkString("PARE"))return{ext:"parquet",mime:"application/vnd.apache.parquet"};if(this.checkString("ttcf"))return{ext:"ttc",mime:"font/collection"};if(this.check([207,250,237,254]))return{ext:"macho",mime:"application/x-mach-binary"};if(this.check([4,34,77,24]))return{ext:"lz4",mime:"application/x-lz4"};if(this.checkString("regf"))return{ext:"dat",mime:"application/x-ft-windows-registry-hive"};if(this.check([79,84,84,79,0]))return{ext:"otf",mime:"font/otf"};if(this.checkString("#!AMR"))return{ext:"amr",mime:"audio/amr"};if(this.checkString("{\\rtf"))return{ext:"rtf",mime:"application/rtf"};if(this.check([70,76,86,1]))return{ext:"flv",mime:"video/x-flv"};if(this.checkString("IMPM"))return{ext:"it",mime:"audio/x-it"};if(this.checkString("-lh0-",{offset:2})||this.checkString("-lh1-",{offset:2})||this.checkString("-lh2-",{offset:2})||this.checkString("-lh3-",{offset:2})||this.checkString("-lh4-",{offset:2})||this.checkString("-lh5-",{offset:2})||this.checkString("-lh6-",{offset:2})||this.checkString("-lh7-",{offset:2})||this.checkString("-lzs-",{offset:2})||this.checkString("-lz4-",{offset:2})||this.checkString("-lz5-",{offset:2})||this.checkString("-lhd-",{offset:2}))return{ext:"lzh",mime:"application/x-lzh-compressed"};if(this.check([0,0,1,186])){if(this.check([33],{offset:4,mask:[241]}))return{ext:"mpg",mime:"video/MP1S"};if(this.check([68],{offset:4,mask:[196]}))return{ext:"mpg",mime:"video/MP2P"}}if(this.checkString("ITSF"))return{ext:"chm",mime:"application/vnd.ms-htmlhelp"};if(this.check([202,254,186,190]))return{ext:"class",mime:"application/java-vm"};if(this.checkString(".RMF"))return{ext:"rm",mime:"application/vnd.rn-realmedia"};if(this.checkString("DRACO"))return{ext:"drc",mime:"application/vnd.google.draco"};if(this.check([253,55,122,88,90,0]))return{ext:"xz",mime:"application/x-xz"};if(this.checkString("<?xml "))return{ext:"xml",mime:"application/xml"};if(this.check([55,122,188,175,39,28]))return{ext:"7z",mime:"application/x-7z-compressed"};if(this.check([82,97,114,33,26,7])&&(this.buffer[6]===0||this.buffer[6]===1))return{ext:"rar",mime:"application/x-rar-compressed"};if(this.checkString("solid "))return{ext:"stl",mime:"model/stl"};if(this.checkString("AC")){let t=new zn(4,"latin1").get(this.buffer,2);if(t.match("^d*")&&t>=1e3&&t<=1050)return{ext:"dwg",mime:"image/vnd.dwg"}}if(this.checkString("070707"))return{ext:"cpio",mime:"application/x-cpio"};if(this.checkString("BLENDER"))return{ext:"blend",mime:"application/x-blender"};if(this.checkString("!<arch>"))return await e.ignore(8),await e.readToken(new zn(13,"ascii"))==="debian-binary"?{ext:"deb",mime:"application/x-deb"}:{ext:"ar",mime:"application/x-unix-archive"};if(this.checkString("WEBVTT")&&[`
117
117
  `,"\r"," "," ","\0"].some(t=>this.checkString(t,{offset:6})))return{ext:"vtt",mime:"text/vtt"};if(this.check([137,80,78,71,13,10,26,10])){await e.ignore(8);async function t(){return{length:await e.readToken(LU),type:await e.readToken(new zn(4,"latin1"))}}do{let n=await t();if(n.length<0)return;switch(n.type){case"IDAT":return{ext:"png",mime:"image/png"};case"acTL":return{ext:"apng",mime:"image/apng"};default:await e.ignore(n.length+4)}}while(e.position+8<e.fileInfo.size);return{ext:"png",mime:"image/png"}}if(this.check([65,82,82,79,87,49,0,0]))return{ext:"arrow",mime:"application/vnd.apache.arrow.file"};if(this.check([103,108,84,70,2,0,0,0]))return{ext:"glb",mime:"model/gltf-binary"};if(this.check([102,114,101,101],{offset:4})||this.check([109,100,97,116],{offset:4})||this.check([109,111,111,118],{offset:4})||this.check([119,105,100,101],{offset:4}))return{ext:"mov",mime:"video/quicktime"};if(this.check([73,73,82,79,8,0,0,0,24]))return{ext:"orf",mime:"image/x-olympus-orf"};if(this.checkString("gimp xcf "))return{ext:"xcf",mime:"image/x-xcf"};if(this.checkString("ftyp",{offset:4})&&(this.buffer[8]&96)!==0){let t=new zn(4,"latin1").get(this.buffer,8).replace("\0"," ").trim();switch(t){case"avif":case"avis":return{ext:"avif",mime:"image/avif"};case"mif1":return{ext:"heic",mime:"image/heif"};case"msf1":return{ext:"heic",mime:"image/heif-sequence"};case"heic":case"heix":return{ext:"heic",mime:"image/heic"};case"hevc":case"hevx":return{ext:"heic",mime:"image/heic-sequence"};case"qt":return{ext:"mov",mime:"video/quicktime"};case"M4V":case"M4VH":case"M4VP":return{ext:"m4v",mime:"video/x-m4v"};case"M4P":return{ext:"m4p",mime:"video/mp4"};case"M4B":return{ext:"m4b",mime:"audio/mp4"};case"M4A":return{ext:"m4a",mime:"audio/x-m4a"};case"F4V":return{ext:"f4v",mime:"video/mp4"};case"F4P":return{ext:"f4p",mime:"video/mp4"};case"F4A":return{ext:"f4a",mime:"audio/mp4"};case"F4B":return{ext:"f4b",mime:"audio/mp4"};case"crx":return{ext:"cr3",mime:"image/x-canon-cr3"};default:return t.startsWith("3g")?t.startsWith("3g2")?{ext:"3g2",mime:"video/3gpp2"}:{ext:"3gp",mime:"video/3gpp"}:{ext:"mp4",mime:"video/mp4"}}}if(this.checkString(`REGEDIT4\r
118
118
  `))return{ext:"reg",mime:"application/x-ms-regedit"};if(this.check([82,73,70,70])){if(this.checkString("WEBP",{offset:8}))return{ext:"webp",mime:"image/webp"};if(this.check([65,86,73],{offset:8}))return{ext:"avi",mime:"video/vnd.avi"};if(this.check([87,65,86,69],{offset:8}))return{ext:"wav",mime:"audio/wav"};if(this.check([81,76,67,77],{offset:8}))return{ext:"qcp",mime:"audio/qcelp"}}if(this.check([73,73,85,0,24,0,0,0,136,231,116,216]))return{ext:"rw2",mime:"image/x-panasonic-rw2"};if(this.check([48,38,178,117,142,102,207,17,166,217])){async function t(){let n=new Uint8Array(16);return await e.readBuffer(n),{id:n,size:Number(await e.readToken(BU))}}for(await e.ignore(30);e.position+24<e.fileInfo.size;){let n=await t(),o=n.size-24;if(cs(n.id,[145,7,220,183,183,169,207,17,142,230,0,192,12,32,83,101])){let i=new Uint8Array(16);if(o-=await e.readBuffer(i),cs(i,[64,158,105,248,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"audio/x-ms-asf"};if(cs(i,[192,239,25,188,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"video/x-ms-asf"};break}await e.ignore(o)}return{ext:"asf",mime:"application/vnd.ms-asf"}}if(this.check([171,75,84,88,32,49,49,187,13,10,26,10]))return{ext:"ktx",mime:"image/ktx"};if((this.check([126,16,4])||this.check([126,24,4]))&&this.check([48,77,73,69],{offset:4}))return{ext:"mie",mime:"application/x-mie"};if(this.check([39,10,0,0,0,0,0,0,0,0,0,0],{offset:2}))return{ext:"shp",mime:"application/x-esri-shape"};if(this.check([255,79,255,81]))return{ext:"j2c",mime:"image/j2c"};if(this.check([0,0,0,12,106,80,32,32,13,10,135,10]))switch(await e.ignore(20),await e.readToken(new zn(4,"ascii"))){case"jp2 ":return{ext:"jp2",mime:"image/jp2"};case"jpx ":return{ext:"jpx",mime:"image/jpx"};case"jpm ":return{ext:"jpm",mime:"image/jpm"};case"mjp2":return{ext:"mj2",mime:"image/mj2"};default:return}if(this.check([255,10])||this.check([0,0,0,12,74,88,76,32,13,10,135,10]))return{ext:"jxl",mime:"image/jxl"};if(this.check([254,255]))return this.checkString("<?xml ",{offset:2,encoding:"utf-16be"})?{ext:"xml",mime:"application/xml"}:void 0;if(this.check([208,207,17,224,161,177,26,225]))return{ext:"cfb",mime:"application/x-cfb"};if(await e.peekBuffer(this.buffer,{length:Math.min(256,e.fileInfo.size),mayBeLess:!0}),this.check([97,99,115,112],{offset:36}))return{ext:"icc",mime:"application/vnd.iccprofile"};if(this.checkString("**ACE",{offset:7})&&this.checkString("**",{offset:12}))return{ext:"ace",mime:"application/x-ace-compressed"};if(this.checkString("BEGIN:")){if(this.checkString("VCARD",{offset:6}))return{ext:"vcf",mime:"text/vcard"};if(this.checkString("VCALENDAR",{offset:6}))return{ext:"ics",mime:"text/calendar"}}if(this.checkString("FUJIFILMCCD-RAW"))return{ext:"raf",mime:"image/x-fujifilm-raf"};if(this.checkString("Extended Module:"))return{ext:"xm",mime:"audio/x-xm"};if(this.checkString("Creative Voice File"))return{ext:"voc",mime:"audio/x-voc"};if(this.check([4,0,0,0])&&this.buffer.length>=16){let t=new DataView(this.buffer.buffer).getUint32(12,!0);if(t>12&&this.buffer.length>=t+16)try{let n=new TextDecoder().decode(this.buffer.subarray(16,t+16));if(JSON.parse(n).files)return{ext:"asar",mime:"application/x-asar"}}catch{}}if(this.check([6,14,43,52,2,5,1,1,13,1,2,1,1,2]))return{ext:"mxf",mime:"application/mxf"};if(this.checkString("SCRM",{offset:44}))return{ext:"s3m",mime:"audio/x-s3m"};if(this.check([71])&&this.check([71],{offset:188}))return{ext:"mts",mime:"video/mp2t"};if(this.check([71],{offset:4})&&this.check([71],{offset:196}))return{ext:"mts",mime:"video/mp2t"};if(this.check([66,79,79,75,77,79,66,73],{offset:60}))return{ext:"mobi",mime:"application/x-mobipocket-ebook"};if(this.check([68,73,67,77],{offset:128}))return{ext:"dcm",mime:"application/dicom"};if(this.check([76,0,0,0,1,20,2,0,0,0,0,0,192,0,0,0,0,0,0,70]))return{ext:"lnk",mime:"application/x.ms.shortcut"};if(this.check([98,111,111,107,0,0,0,0,109,97,114,107,0,0,0,0]))return{ext:"alias",mime:"application/x.apple.alias"};if(this.checkString("Kaydara FBX Binary \0"))return{ext:"fbx",mime:"application/x.autodesk.fbx"};if(this.check([76,80],{offset:34})&&(this.check([0,0,1],{offset:8})||this.check([1,0,2],{offset:8})||this.check([2,0,2],{offset:8})))return{ext:"eot",mime:"application/vnd.ms-fontobject"};if(this.check([6,6,237,245,216,29,70,229,189,49,239,231,254,116,183,29]))return{ext:"indd",mime:"application/x-indesign"};if(await e.peekBuffer(this.buffer,{length:Math.min(512,e.fileInfo.size),mayBeLess:!0}),this.checkString("ustar",{offset:257})&&(this.checkString("\0",{offset:262})||this.checkString(" ",{offset:262}))||this.check([0,0,0,0,0,0],{offset:257})&&QU(this.buffer))return{ext:"tar",mime:"application/x-tar"};if(this.check([255,254])){let t="utf-16le";return this.checkString("<?xml ",{offset:2,encoding:t})?{ext:"xml",mime:"application/xml"}:this.check([255,14],{offset:2})&&this.checkString("SketchUp Model",{offset:4,encoding:t})?{ext:"skp",mime:"application/vnd.sketchup.skp"}:this.checkString(`Windows Registry Editor Version 5.00\r
119
- `,{offset:2,encoding:t})?{ext:"reg",mime:"application/x-ms-regedit"}:void 0}if(this.checkString("-----BEGIN PGP MESSAGE-----"))return{ext:"pgp",mime:"application/pgp-encrypted"}};detectImprecise=async e=>{if(this.buffer=new Uint8Array(MS),await e.peekBuffer(this.buffer,{length:Math.min(8,e.fileInfo.size),mayBeLess:!0}),this.check([0,0,1,186])||this.check([0,0,1,179]))return{ext:"mpg",mime:"video/mpeg"};if(this.check([0,1,0,0,0]))return{ext:"ttf",mime:"font/ttf"};if(this.check([0,0,1,0]))return{ext:"ico",mime:"image/x-icon"};if(this.check([0,0,2,0]))return{ext:"cur",mime:"image/x-icon"};if(await e.peekBuffer(this.buffer,{length:Math.min(2+this.options.mpegOffsetTolerance,e.fileInfo.size),mayBeLess:!0}),this.buffer.length>=2+this.options.mpegOffsetTolerance)for(let t=0;t<=this.options.mpegOffsetTolerance;++t){let n=this.scanMpeg(t);if(n)return n}};async readTiffTag(e){let t=await this.tokenizer.readToken(e?mh:Ut);switch(this.tokenizer.ignore(10),t){case 50341:return{ext:"arw",mime:"image/x-sony-arw"};case 50706:return{ext:"dng",mime:"image/x-adobe-dng"};default:}}async readTiffIFD(e){let t=await this.tokenizer.readToken(e?mh:Ut);for(let n=0;n<t;++n){let o=await this.readTiffTag(e);if(o)return o}}async readTiffHeader(e){let t=(e?mh:Ut).get(this.buffer,2),n=(e?NU:Yt).get(this.buffer,4);if(t===42){if(n>=6){if(this.checkString("CR",{offset:8}))return{ext:"cr2",mime:"image/x-canon-cr2"};if(n>=8){let i=(e?mh:Ut).get(this.buffer,8),s=(e?mh:Ut).get(this.buffer,10);if(i===28&&s===254||i===31&&s===11)return{ext:"nef",mime:"image/x-nikon-nef"}}}return await this.tokenizer.ignore(n),await this.readTiffIFD(e)??{ext:"tif",mime:"image/tiff"}}if(t===43)return{ext:"tif",mime:"image/tiff"}}scanMpeg(e){if(this.check([255,224],{offset:e,mask:[255,224]})){if(this.check([16],{offset:e+1,mask:[22]}))return this.check([8],{offset:e+1,mask:[8]})?{ext:"aac",mime:"audio/aac"}:{ext:"aac",mime:"audio/aac"};if(this.check([2],{offset:e+1,mask:[6]}))return{ext:"mp3",mime:"audio/mpeg"};if(this.check([4],{offset:e+1,mask:[6]}))return{ext:"mp2",mime:"audio/mpeg"};if(this.check([6],{offset:e+1,mask:[6]}))return{ext:"mp1",mime:"audio/mpeg"}}}},cot=new Set(JU),lot=new Set(eF);var rF="application/octet-stream";function cee(r){return/^(<\?xml[^>]+>)?[^<^\w]+<svg/ig.test(r)}async function lee(r){try{return JSON.parse(r),!0}catch{return!1}}function uee(r){let e=new TextDecoder("utf-8",{fatal:!0});try{return e.decode(r)}catch{return null}}async function fee(r){return/^\s*<(?:!doctype\s+html|html|head|body)\b/i.test(r)}async function nF(r,e){let t=(await tF(r))?.mime;if(t!=null)return t==="application/xml"&&e?.toLowerCase().endsWith(".svg")?"image/svg+xml":t;if(e==null||e.includes(".")===!1){let n=uee(r);return n!=null?cee(n)?"image/svg+xml":await lee(n)?"application/json":await fee(n)?"text/html; charset=utf-8":"text/plain; charset=utf-8":rF}switch(e.split(".").pop()){case"css":return"text/css";case"html":return"text/html; charset=utf-8";case"js":return"application/javascript";case"json":return"application/json";case"txt":return"text/plain";case"woff2":return"font/woff2";case"svg":return"image/svg+xml";case"csv":return"text/csv";case"doc":return"application/msword";case"xls":return"application/vnd.ms-excel";case"ppt":return"application/vnd.ms-powerpoint";case"msi":return"application/x-msdownload";default:return rF}}function dee(r){return r instanceof AggregateError||r?.name==="AggregateError"&&Array.isArray(r?.errors)}function H8(r){let e;return dee(r)&&(e=r.errors.map(t=>H8(t))),{name:r.name,message:r.message,stack:r.stack,errors:e}}function oF(r,e){if(e.name==="AbortError")throw e;return e.code==="ECONNREFUSED"||e.code==="ECANCELLED"||e.name==="DNSQueryFailedError"?hh(r.toString(),e):["NotUnixFSError"].includes(e.name)?ss(r.toString(),[b8,dh]):e.code==="ETIMEOUT"||e.name==="TimeoutError"?hU(r.toString(),e):["ERR_NO_PROP","ERR_NO_TERMINAL_ELEMENT","ERR_NOT_FOUND"].includes(e.code)?CS(r.toString()):["DoesNotExistError"].includes(e.name)?CS(r.toString()):["BlockNotFoundWhileOfflineError"].includes(e.name)?mU(r.toString()):["RecordNotFoundError"].includes("err.name")?hh(r.toString(),e):O0(r.toString(),e)}function iF({cid:r,contentType:e,rangeStart:t,rangeEnd:n,contentPrefix:o}){let i=e.immutable?"":"W/",s=e.etag;return(t!=null||n!=null)&&(s+=`.${t??"0"}-${n??"N"}`),`${i}"${o??""}${r.toString()}${s}"`}function $S(r){if(r==null||r==="")return;let e=Number(r);if(isNaN(e))throw new Hn(`Invalid range specification: could not parse "${e}" as number`);return e}function hee(r){if(r==null||r==="")return[];if(!r.startsWith("bytes="))throw new Hn("Invalid range request");let t=r.substring(6).split(",").map(o=>o.trim()),n=[];for(let o of t){let i=o.match(/^(?<start>\d+)?-(?<end>\d+)?$/);if(i?.groups==null)throw new Hn(`Invalid range specification: ${o}`);if(o.startsWith("-"))n.push({end:$S(o)});else{let{start:s,end:a}=i.groups;n.push({start:$S(s),end:$S(a)})}}return n}function sF(r,e){let t=e.get("range");if(t!=null)try{let n=hee(t);return n.length===0?void 0:{multipartBoundary:`multipart_byteranges_${Math.floor(Math.random()*1e9)}`,ranges:n}}catch(n){return n.name==="InvalidRangeError"?E8(r):Kn(r,n)}}function pee(r){if(r!=null)return{...r,signal:r?.signal==null?void 0:r?.signal}}function mee(r){let e=r.get("accept")?.split(",")??[];return e.length!==1?!1:e[0].split(";")[0]===ku}function gee(r){let e=r.get("accept")?.split(",")??[];return e.length!==1?!1:e[0].split(";")[0]===En}var K8=class{helia;ipnsResolver;dnsLink;log;contentTypeParser;withServerTiming;plugins=[];urlResolver;constructor(e,t={}){this.helia=e,this.log=e.logger.forComponent("helia:verified-fetch"),this.ipnsResolver=t.ipnsResolver??cM(e),this.dnsLink=t.dnsLink??rM(e),this.contentTypeParser=t.contentTypeParser??nF,this.withServerTiming=t?.withServerTiming??!1,this.urlResolver=new D8({ipnsResolver:this.ipnsResolver,dnsLink:this.dnsLink,helia:this.helia},t);let n={...t,logger:e.logger.forComponent("verified-fetch"),helia:e,contentTypeParser:this.contentTypeParser,ipnsResolver:this.ipnsResolver},o=[new R8(n),new A8(n),new S8(n),new P8(n),new _8(n)],i=t.plugins?.map(s=>s(n))??[];if(i.length>0){let s=new Map(o.map(c=>[c.id,c])),a=new Map(i.map(c=>[c.id,c]));this.plugins=o.map(c=>a.get(c.id)??c),this.plugins.unshift(...i.filter(c=>!s.has(c.id)))}else this.plugins=o}async fetch(e,t){if(this.log("fetch %s %s",t?.method??"GET",e),t?.method==="OPTIONS")return this.handleFinalResponse(new Response(null,{status:200}));let n=pee(t),o=new Headers(n?.headers),i=new ph;n?.onProgress?.(new Y("verified-fetch:request:start",{resource:e}));let s=sF(e.toString(),o);if(s instanceof Response)return this.handleFinalResponse(s);let a;try{a=O8(typeof e=="string"?e:`ipfs://${e}`)}catch(h){return this.handleFinalResponse(Kn(e.toString(),h))}let c;if(mee(o)){if(a.protocol!=="ipns:")return ss(a,[]);let h=this.plugins.find(d=>d.id==="ipns-record-plugin");return h==null?ss(a,[]):this.handleFinalResponse(await h.handle({range:s,url:a,resource:e.toString(),options:n}))}else try{c=await this.urlResolver.resolve(a,i,{...n,isRawBlockRequest:gee(o),onlyIfCached:o.get("cache-control")==="only-if-cached"})}catch(h){return n?.signal?.throwIfAborted(),this.log.error("error parsing resource %s - %e",e,h),this.handleFinalResponse(oF(e,h))}n?.onProgress?.(new Y("verified-fetch:request:resolve",{cid:c.terminalElement.cid,path:c.url.pathname}));let l=this.getAcceptHeader(c.url,o.get("accept"),c.terminalElement.cid);if(l instanceof Response)return this.log("allowed media types for requested CID did not contain anything the client can understand"),this.handleFinalResponse(l);let f={...c,resource:e.toString(),accept:l,range:s,options:n,onProgress:n?.onProgress,serverTiming:i,headers:o};this.log.trace('finding handler for cid code "0x%s" and response content types %s',c.terminalElement.cid.code.toString(16),l.map(h=>h.contentType.mediaType).join(", "));let u=await this.runPluginPipeline(f);return n?.onProgress?.(new Y("verified-fetch:request:end",{cid:c.terminalElement.cid,path:c.url.pathname})),u==null&&this.log.error("no plugin could handle request for %s",e),this.handleFinalResponse(u,!!n?.withServerTiming||!!this.withServerTiming,f)}getAcceptHeader(e,t,n){if(t==null||t===""){try{let a=e.searchParams.get("dag-scope"),c=e.searchParams.get("entity-bytes"),l=e.searchParams.get("car-dups"),f=e.searchParams.get("car-order"),u=e.searchParams.get("car-version");if(a!=null||c!=null||l!=null||c!=null||f!=null){let h={};return l!=null&&(h.dups=l),f!=null&&(h.order=f),u!=null&&(h.version=u),[{contentType:P0,options:h}]}}catch{}t="*/*"}let o=[],i=t.split(",").map(a=>{let c=a.trim().split(";"),l={q:"1"};for(let f=1;f<c.length;f++){let[u,h]=c[f].split("=").map(d=>d.trim());l[u]=h}return{mediaType:`${c[0]}`.trim(),options:l}}).sort((a,c)=>a.options.q===c.options.q?0:a.options.q>c.options.q?-1:1),s=aU(e.protocol,n);for(let a of i){let[c,l]=a.mediaType.split("/");for(let f of s){let[u,h]=f.mediaType.split("/");a.mediaType.includes(f.mediaType)&&o.push({contentType:f,options:a.options}),a.mediaType==="*/*"&&o.push({contentType:f,options:a.options}),a.mediaType.startsWith("*/")&&h===l&&o.push({contentType:f,options:a.options}),a.mediaType.endsWith("/*")&&u===c&&o.push({contentType:f,options:a.options})}}return o.length===0?(this.log("requested %o",i.map(({mediaType:a})=>a)),this.log("supported %o",s.map(({mediaType:a})=>a)),ss(e,s)):o}handleFinalResponse(e,t,n){let o=sU(e.headers.get("content-type"))??dh;if(t===!0&&n?.serverTiming!=null){let i=n?.serverTiming.getHeader();i!==""&&e.headers.set("server-timing",i)}if(n?.terminalElement.cid!=null&&e.headers.get("etag")==null&&e.headers.set("etag",iF({cid:n.terminalElement.cid,contentType:o})),n?.url?.protocol!=null&&n.ttl!=null&&fU({response:e,ttl:n.ttl,protocol:n.url.protocol}),n?.terminalElement.cid!=null){let i=decodeURI(n?.url.pathname),s=H(D(i),"ascii");e.headers.set("x-ipfs-path",`/${n.url.protocol==="ipfs:"?"ipfs":"ipns"}/${n?.url.hostname}${s}`)}return e.headers.set("access-control-allow-origin","*"),e.headers.set("access-control-allow-methods","GET, HEAD, OPTIONS"),e.headers.set("access-control-allow-headers","Range, X-Requested-With"),e.headers.set("access-control-expose-headers","Content-Range, Content-Length, X-Ipfs-Path, X-Ipfs-Roots, X-Stream-Output"),n?.options?.method==="HEAD"?new Response(null,{status:200,headers:e.headers}):(e.status>399&&e.headers.delete("content-disposition"),e)}async runPluginPipeline(e){let t,n=new Set;this.log.trace("checking which plugins can handle %c%s with accept %s",e.terminalElement.cid,e.url.pathname,e.accept.map(a=>a.contentType.mediaType).join(", "));let o=this.plugins.filter(a=>!n.has(a.id)).filter(a=>a.canHandle(e));if(o.length===0)return this.log.trace("no plugins found that can handle request; exiting pipeline"),TS(e.resource);this.log.trace("plugins ready to handle request: %s",o.map(a=>a.id).join(", "));let i=!1,s=!1;for(let a of o){try{this.log("invoking plugin: %s",a.id),n.add(a.id);let c=await a.handle(e);if(this.log("plugin response %s %o",a.id,c),c!=null){t=c,s=!0;break}}catch(c){if(e.options?.signal?.aborted)throw new Tr(e.options?.signal?.reason);return this.log.error("error in plugin %s - %e",a.id,c),O0(e.resource,JSON.stringify({error:H8(c)}),{headers:{"content-type":"application/json"}})}if(t!=null){this.log.trace("plugin %s produced final response",a.id);break}if(s&&t!=null)break;if(!i){this.log.trace("no context changes and no final response; exiting pipeline.");break}}return t??TS(e.resource,JSON.stringify({error:H8(new Error("No verified fetch plugin could handle the request"))}),{headers:{"content-type":"application/json"}})}async start(){await this.helia.start()}async stop(){await this.helia.stop()}};var M0,V8=async function(e,t){return M0==null&&(M0=await HS()),M0(e,t)};V8.start=async function(){await M0?.start()};V8.stop=async function(){await M0?.stop()};async function HS(r,e){let t;if(!yee(r)){let i=wee(r?.dnsResolvers),s=JB();s.dns=i;let a=r?.routers??["https://delegated-ipfs.dev"];for(let f=0;f<a.length;f++)s.services[`delegatedRouting${f}`]=xk({url:a[f]});r?.libp2pConfig!=null&&Object.assign(s,r.libp2pConfig),t=await _3(s);let c=[Fp()],l=[Gp(t)];(r?.gateways==null||r.gateways.length>0)&&(c.push(Vp({allowInsecure:r?.allowInsecure,allowLocal:r?.allowLocal})),l.push(Wp({gateways:r?.gateways??["https://trustless-gateway.link"]}))),r=await ZB({libp2p:t,blockBrokers:c,dns:i,routers:l,hashers:r?.hashers}),r.logger.forComponent("helia:verified-fetch").trace("created verified-fetch with libp2p config: %j",s)}let n=new K8(r,e);async function o(i,s){return n.fetch(i,s)}return o.start=n.start.bind(n),o.stop=n.stop.bind(n),o}function yee(r){return r?.blockstore!=null&&r?.datastore!=null&&r?.gc!=null&&r?.stop!=null&&r?.start!=null}function wee(r){if(r!=null)return Array.isArray(r)?dl({resolvers:{".":r}}):dl({resolvers:r})}return vF(xee);})();
119
+ `,{offset:2,encoding:t})?{ext:"reg",mime:"application/x-ms-regedit"}:void 0}if(this.checkString("-----BEGIN PGP MESSAGE-----"))return{ext:"pgp",mime:"application/pgp-encrypted"}};detectImprecise=async e=>{if(this.buffer=new Uint8Array(MS),await e.peekBuffer(this.buffer,{length:Math.min(8,e.fileInfo.size),mayBeLess:!0}),this.check([0,0,1,186])||this.check([0,0,1,179]))return{ext:"mpg",mime:"video/mpeg"};if(this.check([0,1,0,0,0]))return{ext:"ttf",mime:"font/ttf"};if(this.check([0,0,1,0]))return{ext:"ico",mime:"image/x-icon"};if(this.check([0,0,2,0]))return{ext:"cur",mime:"image/x-icon"};if(await e.peekBuffer(this.buffer,{length:Math.min(2+this.options.mpegOffsetTolerance,e.fileInfo.size),mayBeLess:!0}),this.buffer.length>=2+this.options.mpegOffsetTolerance)for(let t=0;t<=this.options.mpegOffsetTolerance;++t){let n=this.scanMpeg(t);if(n)return n}};async readTiffTag(e){let t=await this.tokenizer.readToken(e?mh:Ut);switch(this.tokenizer.ignore(10),t){case 50341:return{ext:"arw",mime:"image/x-sony-arw"};case 50706:return{ext:"dng",mime:"image/x-adobe-dng"};default:}}async readTiffIFD(e){let t=await this.tokenizer.readToken(e?mh:Ut);for(let n=0;n<t;++n){let o=await this.readTiffTag(e);if(o)return o}}async readTiffHeader(e){let t=(e?mh:Ut).get(this.buffer,2),n=(e?NU:Yt).get(this.buffer,4);if(t===42){if(n>=6){if(this.checkString("CR",{offset:8}))return{ext:"cr2",mime:"image/x-canon-cr2"};if(n>=8){let i=(e?mh:Ut).get(this.buffer,8),s=(e?mh:Ut).get(this.buffer,10);if(i===28&&s===254||i===31&&s===11)return{ext:"nef",mime:"image/x-nikon-nef"}}}return await this.tokenizer.ignore(n),await this.readTiffIFD(e)??{ext:"tif",mime:"image/tiff"}}if(t===43)return{ext:"tif",mime:"image/tiff"}}scanMpeg(e){if(this.check([255,224],{offset:e,mask:[255,224]})){if(this.check([16],{offset:e+1,mask:[22]}))return this.check([8],{offset:e+1,mask:[8]})?{ext:"aac",mime:"audio/aac"}:{ext:"aac",mime:"audio/aac"};if(this.check([2],{offset:e+1,mask:[6]}))return{ext:"mp3",mime:"audio/mpeg"};if(this.check([4],{offset:e+1,mask:[6]}))return{ext:"mp2",mime:"audio/mpeg"};if(this.check([6],{offset:e+1,mask:[6]}))return{ext:"mp1",mime:"audio/mpeg"}}}},cot=new Set(JU),lot=new Set(eF);var rF="application/octet-stream";function cee(r){return/^(<\?xml[^>]+>)?[^<^\w]+<svg/ig.test(r)}async function lee(r){try{return JSON.parse(r),!0}catch{return!1}}function uee(r){let e=new TextDecoder("utf-8",{fatal:!0});try{return e.decode(r)}catch{return null}}async function fee(r){return/^\s*<(?:!doctype\s+html|html|head|body)\b/i.test(r)}async function nF(r,e){let t=(await tF(r))?.mime;if(t!=null)return t==="application/xml"&&e?.toLowerCase().endsWith(".svg")?"image/svg+xml":t;if(e==null||e.includes(".")===!1){let n=uee(r);return n!=null?cee(n)?"image/svg+xml":await lee(n)?"application/json":await fee(n)?"text/html; charset=utf-8":"text/plain; charset=utf-8":rF}switch(e.split(".").pop()){case"css":return"text/css";case"html":return"text/html; charset=utf-8";case"js":return"application/javascript";case"json":return"application/json";case"txt":return"text/plain";case"woff2":return"font/woff2";case"svg":return"image/svg+xml";case"csv":return"text/csv";case"doc":return"application/msword";case"xls":return"application/vnd.ms-excel";case"ppt":return"application/vnd.ms-powerpoint";case"msi":return"application/x-msdownload";default:return rF}}function dee(r){return r instanceof AggregateError||r?.name==="AggregateError"&&Array.isArray(r?.errors)}function H8(r){let e;return dee(r)&&(e=r.errors.map(t=>H8(t))),{name:r.name,message:r.message,stack:r.stack,errors:e}}function oF(r,e){if(e.name==="AbortError")throw e;return e.code==="ECONNREFUSED"||e.code==="ECANCELLED"||e.name==="DNSQueryFailedError"?hh(r.toString(),e):["NotUnixFSError"].includes(e.name)?ss(r.toString(),[b8,dh]):e.code==="ETIMEOUT"||e.name==="TimeoutError"?hU(r.toString(),e):["ERR_NO_PROP","ERR_NO_TERMINAL_ELEMENT","ERR_NOT_FOUND"].includes(e.code)?CS(r.toString()):["DoesNotExistError"].includes(e.name)?CS(r.toString()):["BlockNotFoundWhileOfflineError"].includes(e.name)?mU(r.toString()):["RecordNotFoundError","LoadBlockFailedError"].includes(e.name)?hh(r.toString(),e):O0(r.toString(),e)}function iF({cid:r,contentType:e,ranges:t,contentPrefix:n}){let o=e.immutable?"":"W/",i=e.etag;if(t?.length!=null&&t?.length>0){let s=t.filter(a=>a.start!=null||a.end!=null);s.length>0&&(i+="."+s.map(a=>`${a.start??0}-${a.end??"N"}`).join(","))}return`${o}"${n??""}${r.toString()}${i}"`}function $S(r){if(r==null||r==="")return;let e=Number(r);if(isNaN(e))throw new Hn(`Invalid range specification: could not parse "${e}" as number`);return e}function hee(r){if(r==null||r==="")return[];if(!r.startsWith("bytes="))throw new Hn("Invalid range request");let t=r.substring(6).split(",").map(o=>o.trim()),n=[];for(let o of t){let i=o.match(/^(?<start>\d+)?-(?<end>\d+)?$/);if(i?.groups==null)throw new Hn(`Invalid range specification: ${o}`);if(o.startsWith("-"))n.push({end:$S(o)});else{let{start:s,end:a}=i.groups;n.push({start:$S(s),end:$S(a)})}}return n}function sF(r,e){let t=e.get("range");if(t!=null)try{let n=hee(t);return n.length===0?void 0:{multipartBoundary:`multipart_byteranges_${Math.floor(Math.random()*1e9)}`,ranges:n}}catch(n){return n.name==="InvalidRangeError"?E8(r):Kn(r,n)}}function pee(r){if(r!=null)return{...r,signal:r?.signal==null?void 0:r?.signal}}function mee(r){let e=r.get("accept")?.split(",")??[];return e.length!==1?!1:e[0].split(";")[0]===ku}function gee(r){let e=r.get("accept")?.split(",")??[];return e.length!==1?!1:e[0].split(";")[0]===En}var K8=class{helia;ipnsResolver;dnsLink;log;contentTypeParser;withServerTiming;plugins=[];urlResolver;constructor(e,t={}){this.helia=e,this.log=e.logger.forComponent("helia:verified-fetch"),this.ipnsResolver=t.ipnsResolver??cM(e),this.dnsLink=t.dnsLink??rM(e),this.contentTypeParser=t.contentTypeParser??nF,this.withServerTiming=t?.withServerTiming??!1,this.urlResolver=new D8({ipnsResolver:this.ipnsResolver,dnsLink:this.dnsLink,helia:this.helia},t);let n={...t,logger:e.logger.forComponent("verified-fetch"),helia:e,contentTypeParser:this.contentTypeParser,ipnsResolver:this.ipnsResolver},o=[new R8(n),new A8(n),new S8(n),new P8(n),new _8(n)],i=t.plugins?.map(s=>s(n))??[];if(i.length>0){let s=new Map(o.map(c=>[c.id,c])),a=new Map(i.map(c=>[c.id,c]));this.plugins=o.map(c=>a.get(c.id)??c),this.plugins.unshift(...i.filter(c=>!s.has(c.id)))}else this.plugins=o}async fetch(e,t){if(this.log("fetch %s %s",t?.method??"GET",e),t?.method==="OPTIONS")return this.handleFinalResponse(new Response(null,{status:200}));let n=pee(t),o=new Headers(n?.headers),i=new ph;n?.onProgress?.(new Y("verified-fetch:request:start",{resource:e}));let s=sF(e.toString(),o);if(s instanceof Response)return this.handleFinalResponse(s);let a;try{a=O8(typeof e=="string"?e:`ipfs://${e}`)}catch(h){return this.handleFinalResponse(Kn(e.toString(),h))}let c;if(mee(o)){if(a.protocol!=="ipns:")return ss(a,[]);let h=this.plugins.find(d=>d.id==="ipns-record-plugin");return h==null?ss(a,[]):this.handleFinalResponse(await h.handle({range:s,url:a,resource:e.toString(),options:n}))}else try{c=await this.urlResolver.resolve(a,i,{...n,isRawBlockRequest:gee(o),onlyIfCached:o.get("cache-control")==="only-if-cached"})}catch(h){return n?.signal?.throwIfAborted(),this.log.error("error parsing resource %s - %e",e,h),this.handleFinalResponse(oF(e,h))}n?.onProgress?.(new Y("verified-fetch:request:resolve",{cid:c.terminalElement.cid,path:c.url.pathname}));let l=this.getAcceptHeader(c.url,o.get("accept"),c.terminalElement.cid);if(l instanceof Response)return this.log("allowed media types for requested CID did not contain anything the client can understand"),this.handleFinalResponse(l);let f={...c,resource:e.toString(),accept:l,range:s,options:n,onProgress:n?.onProgress,serverTiming:i,headers:o};this.log.trace('finding handler for cid code "0x%s" and response content types %s',c.terminalElement.cid.code.toString(16),l.map(h=>h.contentType.mediaType).join(", "));let u=await this.runPluginPipeline(f);return n?.onProgress?.(new Y("verified-fetch:request:end",{cid:c.terminalElement.cid,path:c.url.pathname})),u==null&&this.log.error("no plugin could handle request for %s",e),this.handleFinalResponse(u,!!n?.withServerTiming||!!this.withServerTiming,f)}getAcceptHeader(e,t,n){if(t==null||t===""){try{let a=e.searchParams.get("dag-scope"),c=e.searchParams.get("entity-bytes"),l=e.searchParams.get("car-dups"),f=e.searchParams.get("car-order"),u=e.searchParams.get("car-version");if(a!=null||c!=null||l!=null||c!=null||f!=null){let h={};return l!=null&&(h.dups=l),f!=null&&(h.order=f),u!=null&&(h.version=u),[{contentType:P0,options:h}]}}catch{}t="*/*"}let o=[],i=t.split(",").map(a=>{let c=a.trim().split(";"),l={q:"1"};for(let f=1;f<c.length;f++){let[u,h]=c[f].split("=").map(d=>d.trim());l[u]=h}return{mediaType:`${c[0]}`.trim(),options:l}}).sort((a,c)=>a.options.q===c.options.q?0:a.options.q>c.options.q?-1:1),s=aU(e.protocol,n);for(let a of i){let[c,l]=a.mediaType.split("/");for(let f of s){let[u,h]=f.mediaType.split("/");a.mediaType.includes(f.mediaType)&&o.push({contentType:f,options:a.options}),a.mediaType==="*/*"&&o.push({contentType:f,options:a.options}),a.mediaType.startsWith("*/")&&h===l&&o.push({contentType:f,options:a.options}),a.mediaType.endsWith("/*")&&u===c&&o.push({contentType:f,options:a.options})}}return o.length===0?(this.log("requested %o",i.map(({mediaType:a})=>a)),this.log("supported %o",s.map(({mediaType:a})=>a)),ss(e,s)):o}handleFinalResponse(e,t,n){let o=sU(e.headers.get("content-type"))??dh;if(t===!0&&n?.serverTiming!=null){let i=n?.serverTiming.getHeader();i!==""&&e.headers.set("server-timing",i)}if(n?.terminalElement.cid!=null&&e.headers.get("etag")==null&&e.headers.set("etag",iF({cid:n.terminalElement.cid,contentType:o,ranges:n?.range?.ranges})),n?.url?.protocol!=null&&n.ttl!=null&&fU({response:e,ttl:n.ttl,protocol:n.url.protocol}),n?.terminalElement.cid!=null){let i=decodeURI(n?.url.pathname),s=H(D(i),"ascii");e.headers.set("x-ipfs-path",`/${n.url.protocol==="ipfs:"?"ipfs":"ipns"}/${n?.url.hostname}${s}`)}return e.headers.set("access-control-allow-origin","*"),e.headers.set("access-control-allow-methods","GET, HEAD, OPTIONS"),e.headers.set("access-control-allow-headers","Range, X-Requested-With"),e.headers.set("access-control-expose-headers","Content-Range, Content-Length, X-Ipfs-Path, X-Ipfs-Roots, X-Stream-Output"),n?.options?.method==="HEAD"?new Response(null,{status:200,headers:e.headers}):(e.status>399&&e.headers.delete("content-disposition"),e)}async runPluginPipeline(e){let t,n=new Set;this.log.trace("checking which plugins can handle %c%s with accept %s",e.terminalElement.cid,e.url.pathname,e.accept.map(a=>a.contentType.mediaType).join(", "));let o=this.plugins.filter(a=>!n.has(a.id)).filter(a=>a.canHandle(e));if(o.length===0)return this.log.trace("no plugins found that can handle request; exiting pipeline"),TS(e.resource);this.log.trace("plugins ready to handle request: %s",o.map(a=>a.id).join(", "));let i=!1,s=!1;for(let a of o){try{this.log("invoking plugin: %s",a.id),n.add(a.id);let c=await a.handle(e);if(this.log("plugin response %s %o",a.id,c),c!=null){t=c,s=!0;break}}catch(c){if(e.options?.signal?.aborted)throw new Tr(e.options?.signal?.reason);return this.log.error("error in plugin %s - %e",a.id,c),O0(e.resource,JSON.stringify({error:H8(c)}),{headers:{"content-type":"application/json"}})}if(t!=null){this.log.trace("plugin %s produced final response",a.id);break}if(s&&t!=null)break;if(!i){this.log.trace("no context changes and no final response; exiting pipeline.");break}}return t??TS(e.resource,JSON.stringify({error:H8(new Error("No verified fetch plugin could handle the request"))}),{headers:{"content-type":"application/json"}})}async start(){await this.helia.start()}async stop(){await this.helia.stop()}};var M0,V8=async function(e,t){return M0==null&&(M0=await HS()),M0(e,t)};V8.start=async function(){await M0?.start()};V8.stop=async function(){await M0?.stop()};async function HS(r,e){let t;if(!yee(r)){let i=wee(r?.dnsResolvers),s=JB();s.dns=i;let a=r?.routers??["https://delegated-ipfs.dev"];for(let f=0;f<a.length;f++)s.services[`delegatedRouting${f}`]=xk({url:a[f]});r?.libp2pConfig!=null&&Object.assign(s,r.libp2pConfig),t=await _3(s);let c=[Fp()],l=[Gp(t)];(r?.gateways==null||r.gateways.length>0)&&(c.push(Vp({allowInsecure:r?.allowInsecure,allowLocal:r?.allowLocal})),l.push(Wp({gateways:r?.gateways??["https://trustless-gateway.link"]}))),r=await ZB({libp2p:t,blockBrokers:c,dns:i,routers:l,hashers:r?.hashers}),r.logger.forComponent("helia:verified-fetch").trace("created verified-fetch with libp2p config: %j",s)}let n=new K8(r,e);async function o(i,s){return n.fetch(i,s)}return o.start=n.start.bind(n),o.stop=n.stop.bind(n),o}function yee(r){return r?.blockstore!=null&&r?.datastore!=null&&r?.gc!=null&&r?.stop!=null&&r?.start!=null}function wee(r){if(r!=null)return Array.isArray(r)?dl({resolvers:{".":r}}):dl({resolvers:r})}return vF(xee);})();
120
120
  /*! Bundled license information:
121
121
 
122
122
  pvtsutils/build/index.js: