@libp2p/kad-dht 13.0.1-34455b5f2 → 13.0.1-6ccbb06f0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/dist/index.min.js +1 -1
  2. package/package.json +11 -11
package/dist/index.min.js CHANGED
@@ -1,5 +1,5 @@
1
1
  (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PKadDht = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- "use strict";var Libp2PKadDht=(()=>{var H4=Object.create;var Un=Object.defineProperty;var q4=Object.getOwnPropertyDescriptor;var K4=Object.getOwnPropertyNames;var $4=Object.getPrototypeOf,z4=Object.prototype.hasOwnProperty;var Dn=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Te=(r,e)=>{for(var t in e)Un(r,t,{get:e[t],enumerable:!0})},d2=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of K4(e))!z4.call(r,i)&&i!==t&&Un(r,i,{get:()=>e[i],enumerable:!(n=q4(e,i))||n.enumerable});return r};var Mn=(r,e,t)=>(t=r!=null?H4($4(r)):{},d2(e||!r||!r.__esModule?Un(t,"default",{value:r,enumerable:!0}):t,r)),G4=r=>d2(Un({},"__esModule",{value:!0}),r);var R0=Dn(Tr=>{"use strict";var Ta="[object ArrayBuffer]",vt=class r{static isArrayBuffer(e){return Object.prototype.toString.call(e)===Ta}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),i=r.toUint8Array(t);if(n.length!==i.byteLength)return!1;for(let s=0;s<n.length;s++)if(n[s]!==i[s])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 o of t)n+=o.byteLength;let i=new Uint8Array(n),s=0;for(let o of t){let a=this.toUint8Array(o);i.set(a,s),s+=a.length}return e[e.length-1]instanceof Function?this.toView(i,e[e.length-1]):i.buffer}},mo="string",Ra=/^[0-9a-f]+$/i,Na=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,La=/^[a-zA-Z0-9-_]+$/,l1=class{static fromString(e){let t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);return n.buffer}static toString(e){let t=vt.toUint8Array(e),n="";for(let s=0;s<t.length;s++)n+=String.fromCharCode(t[s]);return decodeURIComponent(escape(n))}},$e=class{static toString(e,t=!1){let n=vt.toArrayBuffer(e),i=new DataView(n),s="";for(let o=0;o<n.byteLength;o+=2){let a=i.getUint16(o,t);s+=String.fromCharCode(a)}return s}static fromString(e,t=!1){let n=new ArrayBuffer(e.length*2),i=new DataView(n);for(let s=0;s<e.length;s++)i.setUint16(s*2,e.charCodeAt(s),t);return n}},u1=class r{static isHex(e){return typeof e===mo&&Ra.test(e)}static isBase64(e){return typeof e===mo&&Na.test(e)}static isBase64Url(e){return typeof e===mo&&La.test(e)}static ToString(e,t="utf8"){let n=vt.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 $e.toString(n,!0);case"utf16":case"utf16be":return $e.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 $e.fromString(e,!0);case"utf16":case"utf16be":return $e.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){let t=vt.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 l1.fromString(e);case"utf16":case"utf16be":return $e.fromString(e);case"utf16le":case"usc2":return $e.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 l1.toString(e);case"utf16":case"utf16be":return $e.toString(e);case"utf16le":case"usc2":return $e.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 i=0;i<t;i++)n[i]=e.charCodeAt(i);return n.buffer}static ToBinary(e){let t=vt.toUint8Array(e),n="";for(let i=0;i<t.length;i++)n+=String.fromCharCode(t[i]);return n}static ToHex(e){let t=vt.toUint8Array(e),n="",i=t.length;for(let s=0;s<i;s++){let o=t[s];o<16&&(n+="0"),n+=o.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 i=0;i<t.length;i=i+2){let s=t.slice(i,i+2);n[i/2]=parseInt(s,16)}return n.buffer}static ToUtf16String(e,t=!1){return $e.toString(e,t)}static FromUtf16String(e,t=!1){return $e.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,"")||""}};u1.DEFAULT_UTF8_ENCODING="utf8";function Pa(r,...e){let t=arguments[0];for(let n=1;n<arguments.length;n++){let i=arguments[n];for(let s in i)t[s]=i[s]}return t}function Ca(...r){let e=r.map(i=>i.byteLength).reduce((i,s)=>i+s),t=new Uint8Array(e),n=0;return r.map(i=>new Uint8Array(i)).forEach(i=>{for(let s of i)t[n++]=s}),t.buffer}function _a(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;let t=new Uint8Array(r),n=new Uint8Array(e);for(let i=0;i<r.byteLength;i++)if(t[i]!==n[i])return!1;return!0}Tr.BufferSourceConverter=vt;Tr.Convert=u1;Tr.assign=Pa;Tr.combine=Ca;Tr.isEqual=_a});var K3=Dn(An=>{(function(){var r,e,t,n,i,s,o,a;a=function(c){var l,u,f,h;return l=(c&255<<24)>>>24,u=(c&255<<16)>>>16,f=(c&65280)>>>8,h=c&255,[l,u,f,h].join(".")},o=function(c){var l,u,f,h,g,y;for(l=[],f=h=0;h<=3&&c.length!==0;f=++h){if(f>0){if(c[0]!==".")throw new Error("Invalid IP");c=c.substring(1)}y=e(c),g=y[0],u=y[1],c=c.substring(u),l.push(g)}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"),s=t("a"),i=t("A"),e=function(c){var l,u,f,h,g;for(h=0,l=10,u="9",f=0,c.length>1&&c[f]==="0"&&(c[f+1]==="x"||c[f+1]==="X"?(f+=2,l=16):"0"<=c[f+1]&&c[f+1]<="9"&&(f++,l=8,u="7")),g=f;f<c.length;){if("0"<=c[f]&&c[f]<=u)h=h*l+(t(c[f])-n)>>>0;else if(l===16)if("a"<=c[f]&&c[f]<="f")h=h*l+(10+t(c[f])-s)>>>0;else if("A"<=c[f]&&c[f]<="F")h=h*l+(10+t(c[f])-i)>>>0;else break;else break;if(h>4294967295)throw new Error("too large");f++}if(f===g)throw new Error("empty octet");return[h,f]},r=function(){function c(l,u){var f,h,g,y;if(typeof l!="string")throw new Error("Missing `net' parameter");if(u||(y=l.split("/",2),l=y[0],u=y[1]),u||(u=32),typeof u=="string"&&u.indexOf(".")>-1){try{this.maskLong=o(u)}catch(p){throw f=p,new Error("Invalid mask: "+u)}for(h=g=32;g>=0;h=--g)if(this.maskLong===4294967295<<32-h>>>0){this.bitmask=h;break}}else if(u||u===0)this.bitmask=parseInt(u,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(o(l)&this.maskLong)>>>0}catch(p){throw f=p,new Error("Invalid net address: "+l)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+u);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):(o(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 u,f,h;for(h=o(this.first),f=o(this.last),u=0;h<=f;)l(a(h),h,u),u++,h++},c.prototype.toString=function(){return this.base+"/"+this.bitmask},c}(),An.ip2long=o,An.long2ip=a,An.Netmask=r}).call(An)});var w4=Dn((dg,b4)=>{b4.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 i(s,o){t[s]=o,e++,e>=r&&(e=0,n=t,t=Object.create(null))}return{has:function(s){return t[s]!==void 0||n[s]!==void 0},remove:function(s){t[s]!==void 0&&(t[s]=void 0),n[s]!==void 0&&(n[s]=void 0)},get:function(s){var o=t[s];if(o!==void 0)return o;if((o=n[s])!==void 0)return i(s,o),o},set:function(s,o){t[s]!==void 0?t[s]=o:i(s,o)},clear:function(){t=Object.create(null),n=Object.create(null)}}}});var v4=Dn((pg,Yo)=>{"use strict";var K8=Object.prototype.hasOwnProperty,Ne="~";function In(){}Object.create&&(In.prototype=Object.create(null),new In().__proto__||(Ne=!1));function $8(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function x4(r,e,t,n,i){if(typeof t!="function")throw new TypeError("The listener must be a function");var s=new $8(t,n||r,i),o=Ne?Ne+e:e;return r._events[o]?r._events[o].fn?r._events[o]=[r._events[o],s]:r._events[o].push(s):(r._events[o]=s,r._eventsCount++),r}function Ii(r,e){--r._eventsCount===0?r._events=new In:delete r._events[e]}function Ie(){this._events=new In,this._eventsCount=0}Ie.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)K8.call(t,n)&&e.push(Ne?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};Ie.prototype.listeners=function(e){var t=Ne?Ne+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,s=n.length,o=new Array(s);i<s;i++)o[i]=n[i].fn;return o};Ie.prototype.listenerCount=function(e){var t=Ne?Ne+e:e,n=this._events[t];return n?n.fn?1:n.length:0};Ie.prototype.emit=function(e,t,n,i,s,o){var a=Ne?Ne+e:e;if(!this._events[a])return!1;var c=this._events[a],l=arguments.length,u,f;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,i),!0;case 5:return c.fn.call(c.context,t,n,i,s),!0;case 6:return c.fn.call(c.context,t,n,i,s,o),!0}for(f=1,u=new Array(l-1);f<l;f++)u[f-1]=arguments[f];c.fn.apply(c.context,u)}else{var h=c.length,g;for(f=0;f<h;f++)switch(c[f].once&&this.removeListener(e,c[f].fn,void 0,!0),l){case 1:c[f].fn.call(c[f].context);break;case 2:c[f].fn.call(c[f].context,t);break;case 3:c[f].fn.call(c[f].context,t,n);break;case 4:c[f].fn.call(c[f].context,t,n,i);break;default:if(!u)for(g=1,u=new Array(l-1);g<l;g++)u[g-1]=arguments[g];c[f].fn.apply(c[f].context,u)}}return!0};Ie.prototype.on=function(e,t,n){return x4(this,e,t,n,!1)};Ie.prototype.once=function(e,t,n){return x4(this,e,t,n,!0)};Ie.prototype.removeListener=function(e,t,n,i){var s=Ne?Ne+e:e;if(!this._events[s])return this;if(!t)return Ii(this,s),this;var o=this._events[s];if(o.fn)o.fn===t&&(!i||o.once)&&(!n||o.context===n)&&Ii(this,s);else{for(var a=0,c=[],l=o.length;a<l;a++)(o[a].fn!==t||i&&!o[a].once||n&&o[a].context!==n)&&c.push(o[a]);c.length?this._events[s]=c.length===1?c[0]:c:Ii(this,s)}return this};Ie.prototype.removeAllListeners=function(e){var t;return e?(t=Ne?Ne+e:e,this._events[t]&&Ii(this,t)):(this._events=new In,this._eventsCount=0),this};Ie.prototype.off=Ie.prototype.removeListener;Ie.prototype.addListener=Ie.prototype.on;Ie.prefixed=Ne;Ie.EventEmitter=Ie;typeof Yo<"u"&&(Yo.exports=Ie)});var g7={};Te(g7,{EventTypes:()=>s2,MessageType:()=>M,Record:()=>le,kadDHT:()=>p7,passthroughMapper:()=>j3,removePrivateAddressesMapper:()=>hi,removePublicAddressesMapper:()=>G3});var p2=Symbol.for("@libp2p/content-routing");var g2=Symbol.for("@libp2p/peer-discovery");var ts=Symbol.for("@libp2p/peer-id");var m2=Symbol.for("@libp2p/peer-routing");var ft=class extends Error{static name="AbortError";constructor(e="The operation was aborted"){super(e),this.name="AbortError"}};var $=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}},ht=class extends Error{static name="InvalidPublicKeyError";constructor(e="Invalid public key"){super(e),this.name="InvalidPublicKeyError"}};var Ge=class extends Error{static name="NotFoundError";constructor(e="Not found"){super(e),this.name="NotFoundError"}};var On=class extends Error{static name="InvalidMultihashError";constructor(e="Invalid Multihash"){super(e),this.name="InvalidMultihashError"}};var ve=class extends Error{static name="InvalidMessageError";constructor(e="Invalid message"){super(e),this.name="InvalidMessageError"}};var Zt=class extends Error{static name="UnsupportedKeyTypeError";constructor(e="Unsupported key type"){super(e),this.name="UnsupportedKeyTypeError"}};var ye=(r,...e)=>{try{[...e]}catch{}};var Pe=class extends EventTarget{#e=new Map;constructor(){super(),ye(1/0,this)}listenerCount(e){let t=this.#e.get(e);return t==null?0:t.length}addEventListener(e,t,n){super.addEventListener(e,t,n);let i=this.#e.get(e);i==null&&(i=[],this.#e.set(e,i)),i.push({callback:t,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(e,t,n){super.removeEventListener(e.toString(),t??null,n);let i=this.#e.get(e);i!=null&&(i=i.filter(({callback:s})=>s!==t),this.#e.set(e,i))}dispatchEvent(e){let t=super.dispatchEvent(e),n=this.#e.get(e.type);return n==null||(n=n.filter(({once:i})=>!i),this.#e.set(e.type,n)),t}safeDispatchEvent(e,t={}){return this.dispatchEvent(new CustomEvent(e,t))}};function y2(r){return r!=null&&typeof r.start=="function"&&typeof r.stop=="function"}async function b2(...r){let e=[];for(let t of r)y2(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 w2(...r){let e=[];for(let t of r)y2(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 x2=Symbol.for("@libp2p/service-capabilities"),v2=Symbol.for("@libp2p/service-dependencies");function j4(r){return r[Symbol.asyncIterator]!=null}function Z4(r){if(j4(r))return(async()=>{for await(let e of r);})();for(let e of r);}var rs=Z4;function ie(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}var E2="/ipfs/kad/1.0.0",A2="/dht/record",ns="/dht/provider";function Ce(r=0){return new Uint8Array(r)}function pe(r=0){return new Uint8Array(r)}var W4=Math.pow(2,7),Q4=Math.pow(2,14),Y4=Math.pow(2,21),is=Math.pow(2,28),ss=Math.pow(2,35),os=Math.pow(2,42),as=Math.pow(2,49),z=128,Ee=127;function se(r){if(r<W4)return 1;if(r<Q4)return 2;if(r<Y4)return 3;if(r<is)return 4;if(r<ss)return 5;if(r<os)return 6;if(r<as)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function cs(r,e,t=0){switch(se(r)){case 8:e[t++]=r&255|z,r/=128;case 7:e[t++]=r&255|z,r/=128;case 6:e[t++]=r&255|z,r/=128;case 5:e[t++]=r&255|z,r/=128;case 4:e[t++]=r&255|z,r>>>=7;case 3:e[t++]=r&255|z,r>>>=7;case 2:e[t++]=r&255|z,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function X4(r,e,t=0){switch(se(r)){case 8:e.set(t++,r&255|z),r/=128;case 7:e.set(t++,r&255|z),r/=128;case 6:e.set(t++,r&255|z),r/=128;case 5:e.set(t++,r&255|z),r/=128;case 4:e.set(t++,r&255|z),r>>>=7;case 3:e.set(t++,r&255|z),r>>>=7;case 2:e.set(t++,r&255|z),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function ls(r,e){let t=r[e],n=0;if(n+=t&Ee,t<z||(t=r[e+1],n+=(t&Ee)<<7,t<z)||(t=r[e+2],n+=(t&Ee)<<14,t<z)||(t=r[e+3],n+=(t&Ee)<<21,t<z)||(t=r[e+4],n+=(t&Ee)*is,t<z)||(t=r[e+5],n+=(t&Ee)*ss,t<z)||(t=r[e+6],n+=(t&Ee)*os,t<z)||(t=r[e+7],n+=(t&Ee)*as,t<z))return n;throw new RangeError("Could not decode varint")}function J4(r,e){let t=r.get(e),n=0;if(n+=t&Ee,t<z||(t=r.get(e+1),n+=(t&Ee)<<7,t<z)||(t=r.get(e+2),n+=(t&Ee)<<14,t<z)||(t=r.get(e+3),n+=(t&Ee)<<21,t<z)||(t=r.get(e+4),n+=(t&Ee)*is,t<z)||(t=r.get(e+5),n+=(t&Ee)*ss,t<z)||(t=r.get(e+6),n+=(t&Ee)*os,t<z)||(t=r.get(e+7),n+=(t&Ee)*as,t<z))return n;throw new RangeError("Could not decode varint")}function He(r,e,t=0){return e==null&&(e=pe(se(r))),e instanceof Uint8Array?cs(r,e,t):X4(r,e,t)}function Me(r,e=0){return r instanceof Uint8Array?ls(r,e):J4(r,e)}var us=new Float32Array([-0]),Nt=new Uint8Array(us.buffer);function B2(r,e,t){us[0]=r,e[t]=Nt[0],e[t+1]=Nt[1],e[t+2]=Nt[2],e[t+3]=Nt[3]}function S2(r,e){return Nt[0]=r[e],Nt[1]=r[e+1],Nt[2]=r[e+2],Nt[3]=r[e+3],us[0]}var fs=new Float64Array([-0]),Ae=new Uint8Array(fs.buffer);function I2(r,e,t){fs[0]=r,e[t]=Ae[0],e[t+1]=Ae[1],e[t+2]=Ae[2],e[t+3]=Ae[3],e[t+4]=Ae[4],e[t+5]=Ae[5],e[t+6]=Ae[6],e[t+7]=Ae[7]}function k2(r,e){return Ae[0]=r[e],Ae[1]=r[e+1],Ae[2]=r[e+2],Ae[3]=r[e+3],Ae[4]=r[e+4],Ae[5]=r[e+5],Ae[6]=r[e+6],Ae[7]=r[e+7],fs[0]}var e5=BigInt(Number.MAX_SAFE_INTEGER),t5=BigInt(Number.MIN_SAFE_INTEGER),Oe=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 Wt;if(e<e5&&e>t5)return this.fromNumber(Number(e));let t=e<0n;t&&(e=-e);let n=e>>32n,i=e-(n<<32n);return t&&(n=~n|0n,i=~i|0n,++i>T2&&(i=0n,++n>T2&&(n=0n))),new r(Number(i),Number(n))}static fromNumber(e){if(e===0)return Wt;let t=e<0;t&&(e=-e);let n=e>>>0,i=(e-n)/4294967296>>>0;return t&&(i=~i>>>0,n=~n>>>0,++n>4294967295&&(n=0,++i>4294967295&&(i=0))),new r(n,i)}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):Wt}},Wt=new Oe(0,0);Wt.toBigInt=function(){return 0n};Wt.zzEncode=Wt.zzDecode=function(){return this};Wt.length=function(){return 1};var T2=4294967296n;function R2(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 N2(r,e,t){if(t-e<1)return"";let i,s=[],o=0,a;for(;e<t;)a=r[e++],a<128?s[o++]=a:a>191&&a<224?s[o++]=(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,s[o++]=55296+(a>>10),s[o++]=56320+(a&1023)):s[o++]=(a&15)<<12|(r[e++]&63)<<6|r[e++]&63,o>8191&&((i??(i=[])).push(String.fromCharCode.apply(String,s)),o=0);return i!=null?(o>0&&i.push(String.fromCharCode.apply(String,s.slice(0,o))),i.join("")):String.fromCharCode.apply(String,s.slice(0,o))}function hs(r,e,t){let n=t,i,s;for(let o=0;o<r.length;++o)i=r.charCodeAt(o),i<128?e[t++]=i:i<2048?(e[t++]=i>>6|192,e[t++]=i&63|128):(i&64512)===55296&&((s=r.charCodeAt(o+1))&64512)===56320?(i=65536+((i&1023)<<10)+(s&1023),++o,e[t++]=i>>18|240,e[t++]=i>>12&63|128,e[t++]=i>>6&63|128,e[t++]=i&63|128):(e[t++]=i>>12|224,e[t++]=i>>6&63|128,e[t++]=i&63|128);return t-n}function je(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function Vn(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}var ds=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,je(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 je(this,4);return Vn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw je(this,4);return Vn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw je(this,4);let e=S2(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw je(this,4);let e=k2(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 je(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return N2(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw je(this,e);this.pos+=e}else do if(this.pos>=this.len)throw je(this);while(this.buf[this.pos++]&128);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 Oe(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 je(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 je(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 je(this,8);let e=Vn(this.buf,this.pos+=4),t=Vn(this.buf,this.pos+=4);return new Oe(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=ls(this.buf,this.pos);return this.pos+=se(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 ps(r){return new ds(r instanceof Uint8Array?r:r.subarray())}function tt(r,e,t){let n=ps(r);return e.decode(n,void 0,t)}var ws={};Te(ws,{base10:()=>a5});var c9=new Uint8Array(0);function P2(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 dt(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 C2(r){return new TextEncoder().encode(r)}function _2(r){return new TextDecoder().decode(r)}function r5(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 i=0;i<r.length;i++){var s=r.charAt(i),o=s.charCodeAt(0);if(t[o]!==255)throw new TypeError(s+" is ambiguous");t[o]=i}var a=r.length,c=r.charAt(0),l=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function f(y){if(y instanceof Uint8Array||(ArrayBuffer.isView(y)?y=new Uint8Array(y.buffer,y.byteOffset,y.byteLength):Array.isArray(y)&&(y=Uint8Array.from(y))),!(y instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(y.length===0)return"";for(var p=0,d=0,w=0,v=y.length;w!==v&&y[w]===0;)w++,p++;for(var m=(v-w)*u+1>>>0,A=new Uint8Array(m);w!==v;){for(var R=y[w],T=0,I=m-1;(R!==0||T<d)&&I!==-1;I--,T++)R+=256*A[I]>>>0,A[I]=R%a>>>0,R=R/a>>>0;if(R!==0)throw new Error("Non-zero carry");d=T,w++}for(var k=m-d;k!==m&&A[k]===0;)k++;for(var P=c.repeat(p);k<m;++k)P+=r.charAt(A[k]);return P}function h(y){if(typeof y!="string")throw new TypeError("Expected String");if(y.length===0)return new Uint8Array;var p=0;if(y[p]!==" "){for(var d=0,w=0;y[p]===c;)d++,p++;for(var v=(y.length-p)*l+1>>>0,m=new Uint8Array(v);y[p];){var A=t[y.charCodeAt(p)];if(A===255)return;for(var R=0,T=v-1;(A!==0||R<w)&&T!==-1;T--,R++)A+=a*m[T]>>>0,m[T]=A%256>>>0,A=A/256>>>0;if(A!==0)throw new Error("Non-zero carry");w=R,p++}if(y[p]!==" "){for(var I=v-w;I!==v&&m[I]===0;)I++;for(var k=new Uint8Array(d+(v-I)),P=d;I!==v;)k[P++]=m[I++];return k}}}function g(y){var p=h(y);if(p)return p;throw new Error(`Non-${e} character`)}return{encode:f,decodeUnsafe:h,decode:g}}var n5=r5,i5=n5,D2=i5;var gs=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")}},ms=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return M2(this,e)}},ys=class{decoders;constructor(e){this.decoders=e}or(e){return M2(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 M2(r,e){return new ys({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var bs=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,i){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=i,this.encoder=new gs(e,t,n),this.decoder=new ms(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function cr({name:r,prefix:e,encode:t,decode:n}){return new bs(r,e,t,n)}function Lt({name:r,prefix:e,alphabet:t}){let{encode:n,decode:i}=D2(t,r);return cr({prefix:e,name:r,encode:n,decode:s=>dt(i(s))})}function s5(r,e,t,n){let i={};for(let u=0;u<e.length;++u)i[e[u]]=u;let s=r.length;for(;r[s-1]==="=";)--s;let o=new Uint8Array(s*t/8|0),a=0,c=0,l=0;for(let u=0;u<s;++u){let f=i[r[u]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<t|f,a+=t,a>=8&&(a-=8,o[l++]=255&c>>a)}if(a>=t||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o}function o5(r,e,t){let n=e[e.length-1]==="=",i=(1<<t)-1,s="",o=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],o+=8;o>t;)o-=t,s+=e[i&a>>o];if(o!==0&&(s+=e[i&a<<t-o]),n)for(;s.length*t&7;)s+="=";return s}function te({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return cr({prefix:e,name:r,encode(i){return o5(i,n,t)},decode(i){return s5(i,n,t,r)}})}var a5=Lt({prefix:"9",name:"base10",alphabet:"0123456789"});var xs={};Te(xs,{base16:()=>c5,base16upper:()=>l5});var c5=te({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),l5=te({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var vs={};Te(vs,{base2:()=>u5});var u5=te({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Es={};Te(Es,{base256emoji:()=>g5});var O2=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}"),f5=O2.reduce((r,e,t)=>(r[t]=e,r),[]),h5=O2.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function d5(r){return r.reduce((e,t)=>(e+=f5[t],e),"")}function p5(r){let e=[];for(let t of r){let n=h5[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var g5=cr({prefix:"\u{1F680}",name:"base256emoji",encode:d5,decode:p5});var As={};Te(As,{base32:()=>pt,base32hex:()=>w5,base32hexpad:()=>v5,base32hexpadupper:()=>E5,base32hexupper:()=>x5,base32pad:()=>y5,base32padupper:()=>b5,base32upper:()=>m5,base32z:()=>A5});var pt=te({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),m5=te({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),y5=te({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),b5=te({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),w5=te({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),x5=te({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),v5=te({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),E5=te({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),A5=te({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Bs={};Te(Bs,{base36:()=>Gr,base36upper:()=>B5});var Gr=Lt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),B5=Lt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ss={};Te(Ss,{base58btc:()=>Q,base58flickr:()=>S5});var Q=Lt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),S5=Lt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Is={};Te(Is,{base64:()=>I5,base64pad:()=>k5,base64url:()=>T5,base64urlpad:()=>R5});var I5=te({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),k5=te({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),T5=te({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),R5=te({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var ks={};Te(ks,{base8:()=>N5});var N5=te({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Ts={};Te(Ts,{identity:()=>L5});var L5=cr({prefix:"\0",name:"identity",encode:r=>_2(r),decode:r=>C2(r)});var B9=new TextEncoder,S9=new TextDecoder;var Ns={};Te(Ns,{identity:()=>gt});var _5=H2,V2=128,U5=127,D5=~U5,M5=Math.pow(2,31);function H2(r,e,t){e=e||[],t=t||0;for(var n=t;r>=M5;)e[t++]=r&255|V2,r/=128;for(;r&D5;)e[t++]=r&255|V2,r>>>=7;return e[t]=r|0,H2.bytes=t-n+1,e}var O5=Rs,V5=128,F2=127;function Rs(r,n){var t=0,n=n||0,i=0,s=n,o,a=r.length;do{if(s>=a)throw Rs.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=i<28?(o&F2)<<i:(o&F2)*Math.pow(2,i),i+=7}while(o>=V5);return Rs.bytes=s-n,t}var F5=Math.pow(2,7),H5=Math.pow(2,14),q5=Math.pow(2,21),K5=Math.pow(2,28),$5=Math.pow(2,35),z5=Math.pow(2,42),G5=Math.pow(2,49),j5=Math.pow(2,56),Z5=Math.pow(2,63),W5=function(r){return r<F5?1:r<H5?2:r<q5?3:r<K5?4:r<$5?5:r<z5?6:r<G5?7:r<j5?8:r<Z5?9:10},Q5={encode:_5,decode:O5,encodingLength:W5},Y5=Q5,jr=Y5;function Zr(r,e=0){return[jr.decode(r,e),jr.decode.bytes]}function lr(r,e,t=0){return jr.encode(r,e,t),e}function ur(r){return jr.encodingLength(r)}function Ze(r,e){let t=e.byteLength,n=ur(r),i=n+ur(t),s=new Uint8Array(i+t);return lr(r,s,0),lr(t,s,n),s.set(e,i),new fr(r,t,e,s)}function be(r){let e=dt(r),[t,n]=Zr(e),[i,s]=Zr(e.subarray(n)),o=e.subarray(n+s);if(o.byteLength!==i)throw new Error("Incorrect length");return new fr(t,i,o,e)}function q2(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&P2(r.bytes,t.bytes)}}var fr=class{code;size;digest;bytes;constructor(e,t,n,i){this.code=e,this.size=t,this.digest=n,this.bytes=i}};var K2=0,X5="identity",$2=dt;function J5(r){return Ze(K2,$2(r))}var gt={code:K2,name:X5,encode:$2,digest:J5};var Cs={};Te(Cs,{sha256:()=>mt,sha512:()=>e6});function Ps({name:r,code:e,encode:t}){return new Ls(r,e,t)}var Ls=class{name;code;encode;constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?Ze(this.code,t):t.then(n=>Ze(this.code,n))}else throw Error("Unknown type, must be binary type")}};function G2(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var mt=Ps({name:"sha2-256",code:18,encode:G2("SHA-256")}),e6=Ps({name:"sha2-512",code:19,encode:G2("SHA-512")});function j2(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return r6(t,_s(r),e??Q.encoder);default:return n6(t,_s(r),e??pt.encoder)}}var Z2=new WeakMap;function _s(r){let e=Z2.get(r);if(e==null){let t=new Map;return Z2.set(r,t),t}return e}var ne=class r{code;version;multihash;bytes;"/";constructor(e,t,n,i){this.code=t,this.version=e,this.multihash=n,this.bytes=i,this["/"]=i}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!==Wr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==i6)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=Ze(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&&q2(e.multihash,n.multihash)}toString(e){return j2(this,e)}toJSON(){return{"/":j2(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:i,multihash:s,bytes:o}=t;return new r(n,i,s,o??W2(n,i,s.bytes))}else if(t[s6]===!0){let{version:n,multihash:i,code:s}=t,o=be(i);return r.create(n,s,o)}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!==Wr)throw new Error(`Version 0 CID must use dag-pb (code: ${Wr}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let i=W2(e,t,n.bytes);return new r(e,t,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,Wr,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,i=dt(e.subarray(n,n+t.multihashSize));if(i.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=i.subarray(t.multihashSize-t.digestSize),o=new fr(t.multihashCode,t.digestSize,s,i);return[t.version===0?r.createV0(o):r.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[f,h]=Zr(e.subarray(t));return t+=h,f},i=n(),s=Wr;if(i===18?(i=0,t=0):s=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let o=t,a=n(),c=n(),l=t+c,u=l-o;return{version:i,codec:s,multihashCode:a,digestSize:c,multihashSize:u,size:l}}static parse(e,t){let[n,i]=t6(e,t),s=r.decode(i);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return _s(s).set(n,e),s}};function t6(r,e){switch(r[0]){case"Q":{let t=e??Q;return[Q.prefix,t.decode(`${Q.prefix}${r}`)]}case Q.prefix:{let t=e??Q;return[Q.prefix,t.decode(r)]}case pt.prefix:{let t=e??pt;return[pt.prefix,t.decode(r)]}case Gr.prefix:{let t=e??Gr;return[Gr.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 r6(r,e,t){let{prefix:n}=t;if(n!==Q.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let i=e.get(n);if(i==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return i}function n6(r,e,t){let{prefix:n}=t,i=e.get(n);if(i==null){let s=t.encode(r);return e.set(n,s),s}else return i}var Wr=112,i6=18;function W2(r,e,t){let n=ur(r),i=n+ur(e),s=new Uint8Array(i+t.byteLength);return lr(r,s,0),lr(e,s,n),s.set(t,i),s}var s6=Symbol.for("@ipld/js-cid/CID");var Qr={...Ts,...vs,...ks,...ws,...xs,...As,...Bs,...Ss,...Is,...Es},j9={...Cs,...Ns};function Y2(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var Q2=Y2("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Us=Y2("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=pe(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),o6={utf8:Q2,"utf-8":Q2,hex:Qr.base16,latin1:Us,ascii:Us,binary:Us,...Qr},Hn=o6;function Y(r,e="utf8"){let t=Hn[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${r}`)}function Ds(r){let e=r??8192,t=e>>>1,n,i=e;return function(o){if(o<1||o>t)return pe(o);i+o>e&&(n=pe(e),i=0);let a=n.subarray(i,i+=o);return i&7&&(i=(i|7)+1),a}}var Qt=class{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}};function Ms(){}var Vs=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},a6=Ds();function c6(r){return globalThis.Buffer!=null?pe(r):a6(r)}var Xr=class{len;head;tail;states;constructor(){this.len=0,this.head=new Qt(Ms,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new Qt(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new Fs((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(qn,10,Oe.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=Oe.fromBigInt(e);return this._push(qn,t.length(),t)}uint64Number(e){return this._push(cs,se(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=Oe.fromBigInt(e).zzEncode();return this._push(qn,t.length(),t)}sint64Number(e){let t=Oe.fromNumber(e).zzEncode();return this._push(qn,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Os,1,e?1:0)}fixed32(e){return this._push(Yr,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=Oe.fromBigInt(e);return this._push(Yr,4,t.lo)._push(Yr,4,t.hi)}fixed64Number(e){let t=Oe.fromNumber(e);return this._push(Yr,4,t.lo)._push(Yr,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(B2,4,e)}double(e){return this._push(I2,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(Os,1,0):this.uint32(t)._push(u6,t,e)}string(e){let t=R2(e);return t!==0?this.uint32(t)._push(hs,t,e):this._push(Os,1,0)}fork(){return this.states=new Vs(this),this.head=this.tail=new Qt(Ms,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 Qt(Ms,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=c6(this.len),n=0;for(;e!=null;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}};function Os(r,e,t){e[t]=r&255}function l6(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var Fs=class extends Qt{next;constructor(e,t){super(l6,e,t),this.next=void 0}};function qn(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 Yr(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 u6(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(Xr.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(f6,e,r),this},Xr.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(h6,e,r),this});function f6(r,e,t){e.set(r,t)}function h6(r,e,t){r.length<40?hs(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(Y(r),t)}function Hs(){return new Xr}function rt(r,e){let t=Hs();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var hr;(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"})(hr||(hr={}));function Kn(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function dr(r){function e(i){if(r[i.toString()]==null)throw new Error("Invalid enum value");return r[i]}let t=function(s,o){let a=e(s);o.int32(a)},n=function(s){let o=s.int32();return e(o)};return Kn("enum",hr.VARINT,t,n)}function nt(r,e){return Kn("message",hr.LENGTH_DELIMITED,r,e)}var pr=class extends Error{code="ERR_MAX_LENGTH";name="MaxLengthError"};var Jr;(function(r){let e;r.codec=()=>(e==null&&(e=nt((t,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),t.key!=null&&t.key.byteLength>0&&(n.uint32(10),n.bytes(t.key)),t.value!=null&&t.value.byteLength>0&&(n.uint32(18),n.bytes(t.value)),t.timeReceived!=null&&t.timeReceived!==""&&(n.uint32(42),n.string(t.timeReceived)),i.lengthDelimited!==!1&&n.ldelim()},(t,n,i={})=>{let s={key:Ce(0),value:Ce(0),timeReceived:""},o=n==null?t.len:t.pos+n;for(;t.pos<o;){let a=t.uint32();switch(a>>>3){case 1:{s.key=t.bytes();break}case 2:{s.value=t.bytes();break}case 5:{s.timeReceived=t.string();break}default:{t.skipType(a&7);break}}}return s})),e),r.encode=t=>rt(t,r.codec()),r.decode=(t,n)=>tt(t,r.codec(),n)})(Jr||(Jr={}));function X2(r){let e=r.getUTCFullYear(),t=String(r.getUTCMonth()+1).padStart(2,"0"),n=String(r.getUTCDate()).padStart(2,"0"),i=String(r.getUTCHours()).padStart(2,"0"),s=String(r.getUTCMinutes()).padStart(2,"0"),o=String(r.getUTCSeconds()).padStart(2,"0"),a=r.getUTCMilliseconds(),c=String(a*1e3*1e3).padStart(9,"0");return`${e}-${t}-${n}T${i}:${s}:${o}.${c}Z`}function J2(r){let e=new RegExp("(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})\\.(\\d+)Z"),t=String(r).trim().match(e);if(t==null)throw new Error("Invalid format");let n=parseInt(t[1],10),i=parseInt(t[2],10)-1,s=parseInt(t[3],10),o=parseInt(t[4],10),a=parseInt(t[5],10),c=parseInt(t[6],10),l=parseInt(t[7].slice(0,-6),10);return new Date(Date.UTC(n,i,s,o,a,c,l))}var le=class r{key;value;timeReceived;constructor(e,t,n){if(!(e instanceof Uint8Array))throw new Error("key must be a Uint8Array");if(!(t instanceof Uint8Array))throw new Error("value must be a Uint8Array");this.key=e,this.value=t,this.timeReceived=n}serialize(){return Jr.encode(this.prepareSerialize())}prepareSerialize(){return{key:this.key,value:this.value,timeReceived:X2(this.timeReceived)}}static deserialize(e){let t=Jr.decode(e);return new r(t.key,t.value,new Date(t.timeReceived))}static fromDeserialized(e){let t=J2(e.timeReceived);if(e.key==null)throw new Error("key missing from deserialized object");if(e.value==null)throw new Error("value missing from deserialized object");return new r(e.key,e.value,t)}};function p6(r){let[e,t]=r[Symbol.asyncIterator]!=null?[r[Symbol.asyncIterator](),Symbol.asyncIterator]:[r[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>e.next(),push:i=>{n.push(i)},next:()=>n.length>0?{done:!1,value:n.shift()}:e.next(),[t](){return this}}}var e0=p6;function g6(r){return r[Symbol.asyncIterator]!=null}function m6(r,e){let t=0;if(g6(r))return async function*(){for await(let c of r)yield e(c,t++)}();let n=e0(r),{value:i,done:s}=n.next();if(s===!0)return function*(){}();let o=e(i,t++);if(typeof o.then=="function")return async function*(){yield await o;for await(let c of n)yield e(c,t++)}();let a=e;return function*(){yield o;for(let c of n)yield a(c,t++)}()}var gr=m6;var $n=globalThis.CustomEvent??Event;async function*en(r,e={}){let t=e.concurrency??1/0;t<1&&(t=1/0);let n=e.ordered==null?!1:e.ordered,i=new EventTarget,s=[],o=ie(),a=ie(),c=!1,l,u=!1;i.addEventListener("task-complete",()=>{a.resolve()}),Promise.resolve().then(async()=>{try{for await(let y of r){if(s.length===t&&(o=ie(),await o.promise),u)break;let p={done:!1};s.push(p),y().then(d=>{p.done=!0,p.ok=!0,p.value=d,i.dispatchEvent(new $n("task-complete"))},d=>{p.done=!0,p.err=d,i.dispatchEvent(new $n("task-complete"))})}c=!0,i.dispatchEvent(new $n("task-complete"))}catch(y){l=y,i.dispatchEvent(new $n("task-complete"))}});function f(){return n?s[0]?.done:!!s.find(y=>y.done)}function*h(){for(;s.length>0&&s[0].done;){let y=s[0];if(s.shift(),y.ok)yield y.value;else throw u=!0,o.resolve(),y.err;o.resolve()}}function*g(){for(;f();)for(let y=0;y<s.length;y++)if(s[y].done){let p=s[y];if(s.splice(y,1),y--,p.ok)yield p.value;else throw u=!0,o.resolve(),p.err;o.resolve()}}for(;;){if(f()||(a=ie(),await a.promise),l!=null)throw l;if(n?yield*h():yield*g(),c&&s.length===0)break}}var zn=class{buffer;mask;top;btm;next;constructor(e){if(!(e>0)||e-1&e)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}},mr=class{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new zn(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 zn(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 qs=class extends Error{type;code;constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.code=t??"ABORT_ERR"}};function yr(r={}){return y6(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 y6(r,e){e=e??{};let t=e.onEnd,n=new mr,i,s,o,a=ie(),c=async()=>{try{return n.isEmpty()?o?{done:!0}:await new Promise((d,w)=>{s=v=>{s=null,n.push(v);try{d(r(n))}catch(m){w(m)}return i}}):r(n)}finally{n.isEmpty()&&queueMicrotask(()=>{a.resolve(),a=ie()})}},l=d=>s!=null?s(d):(n.push(d),i),u=d=>(n=new mr,s!=null?s({error:d}):(n.push({error:d}),i)),f=d=>{if(o)return i;if(e?.objectMode!==!0&&d?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return l({done:!1,value:d})},h=d=>o?i:(o=!0,d!=null?u(d):l({done:!0})),g=()=>(n=new mr,h(),{done:!0}),y=d=>(h(d),{done:!0});if(i={[Symbol.asyncIterator](){return this},next:c,return:g,throw:y,push:f,end:h,get readableLength(){return n.size},onEmpty:async d=>{let w=d?.signal;if(w?.throwIfAborted(),n.isEmpty())return;let v,m;w!=null&&(v=new Promise((A,R)=>{m=()=>{R(new qs)},w.addEventListener("abort",m)}));try{await Promise.race([a.promise,v])}finally{m!=null&&w!=null&&w?.removeEventListener("abort",m)}}},t==null)return i;let p=i;return i={[Symbol.asyncIterator](){return this},next(){return p.next()},throw(d){return p.throw(d),t!=null&&(t(d),t=void 0),{done:!0}},return(){return p.return(),t!=null&&(t(),t=void 0),{done:!0}},push:f,end(d){return p.end(d),t!=null&&(t(d),t=void 0),i},get readableLength(){return p.readableLength},onEmpty:d=>p.onEmpty(d)},i}function b6(r){return r[Symbol.asyncIterator]!=null}function w6(...r){let e=[];for(let t of r)b6(t)||e.push(t);return e.length===r.length?function*(){for(let t of e)yield*t}():async function*(){let t=yr({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(r.map(async n=>{for await(let i of n)t.push(i)})),t.end()}catch(n){t.end(n)}}),yield*t}()}var Gn=w6;function Pt(r,...e){if(r==null)throw new Error("Empty pipeline");if(Ks(r)){let n=r;r=()=>n.source}else if(r0(r)||t0(r)){let n=r;r=()=>n}let t=[r,...e];if(t.length>1&&Ks(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++)Ks(t[n])&&(t[n]=v6(t[n]));return x6(...t)}var x6=(...r)=>{let e;for(;r.length>0;)e=r.shift()(e);return e},t0=r=>r?.[Symbol.asyncIterator]!=null,r0=r=>r?.[Symbol.iterator]!=null,Ks=r=>r==null?!1:r.sink!=null&&r.source!=null,v6=r=>e=>{let t=r.sink(e);if(t?.then!=null){let n=yr({objectMode:!0});t.then(()=>{n.end()},o=>{n.end(o)});let i,s=r.source;if(t0(s))i=async function*(){yield*s,n.end()};else if(r0(s))i=function*(){yield*s,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return Gn(n,i())}return r.source};function ee(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}var Ct=class extends Error{constructor(e="Query error"){super(e),this.name="QueryError"}},jn=class extends Error{constructor(e="Query aborted"){super(e),this.name="QueryAbortedError"}},Zn=class extends Error{constructor(e="Invalid record"){super(e),this.name="InvalidRecordError"}},Wn=class extends Error{constructor(e="No selector function configured for prefix"){super(e),this.name="MissingSelectorError"}};var n0;(function(r){let e;r.codec=()=>(e==null&&(e=nt((t,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),t.key!=null&&(n.uint32(10),n.bytes(t.key)),t.value!=null&&(n.uint32(18),n.bytes(t.value)),t.author!=null&&(n.uint32(26),n.bytes(t.author)),t.signature!=null&&(n.uint32(34),n.bytes(t.signature)),t.timeReceived!=null&&(n.uint32(42),n.string(t.timeReceived)),i.lengthDelimited!==!1&&n.ldelim()},(t,n,i={})=>{let s={},o=n==null?t.len:t.pos+n;for(;t.pos<o;){let a=t.uint32();switch(a>>>3){case 1:{s.key=t.bytes();break}case 2:{s.value=t.bytes();break}case 3:{s.author=t.bytes();break}case 4:{s.signature=t.bytes();break}case 5:{s.timeReceived=t.string();break}default:{t.skipType(a&7);break}}}return s})),e),r.encode=t=>rt(t,r.codec()),r.decode=(t,n)=>tt(t,r.codec(),n)})(n0||(n0={}));var M;(function(r){r.PUT_VALUE="PUT_VALUE",r.GET_VALUE="GET_VALUE",r.ADD_PROVIDER="ADD_PROVIDER",r.GET_PROVIDERS="GET_PROVIDERS",r.FIND_NODE="FIND_NODE",r.PING="PING"})(M||(M={}));var Qn;(function(r){r[r.PUT_VALUE=0]="PUT_VALUE",r[r.GET_VALUE=1]="GET_VALUE",r[r.ADD_PROVIDER=2]="ADD_PROVIDER",r[r.GET_PROVIDERS=3]="GET_PROVIDERS",r[r.FIND_NODE=4]="FIND_NODE",r[r.PING=5]="PING"})(Qn||(Qn={}));(function(r){r.codec=()=>dr(Qn)})(M||(M={}));var wr;(function(r){r.NOT_CONNECTED="NOT_CONNECTED",r.CONNECTED="CONNECTED",r.CAN_CONNECT="CAN_CONNECT",r.CANNOT_CONNECT="CANNOT_CONNECT"})(wr||(wr={}));var $s;(function(r){r[r.NOT_CONNECTED=0]="NOT_CONNECTED",r[r.CONNECTED=1]="CONNECTED",r[r.CAN_CONNECT=2]="CAN_CONNECT",r[r.CANNOT_CONNECT=3]="CANNOT_CONNECT"})($s||($s={}));(function(r){r.codec=()=>dr($s)})(wr||(wr={}));var br;(function(r){let e;r.codec=()=>(e==null&&(e=nt((t,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),t.id!=null&&t.id.byteLength>0&&(n.uint32(10),n.bytes(t.id)),t.multiaddrs!=null)for(let s of t.multiaddrs)n.uint32(18),n.bytes(s);t.connection!=null&&(n.uint32(24),wr.codec().encode(t.connection,n)),i.lengthDelimited!==!1&&n.ldelim()},(t,n,i={})=>{let s={id:Ce(0),multiaddrs:[]},o=n==null?t.len:t.pos+n;for(;t.pos<o;){let a=t.uint32();switch(a>>>3){case 1:{s.id=t.bytes();break}case 2:{if(i.limits?.multiaddrs!=null&&s.multiaddrs.length===i.limits.multiaddrs)throw new pr('Decode error - map field "multiaddrs" had too many elements');s.multiaddrs.push(t.bytes());break}case 3:{s.connection=wr.codec().decode(t);break}default:{t.skipType(a&7);break}}}return s})),e),r.encode=t=>rt(t,r.codec()),r.decode=(t,n)=>tt(t,r.codec(),n)})(br||(br={}));var Ke;(function(r){let e;r.codec=()=>(e==null&&(e=nt((t,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),t.type!=null&&Qn[t.type]!==0&&(n.uint32(8),M.codec().encode(t.type,n)),t.clusterLevel!=null&&(n.uint32(80),n.int32(t.clusterLevel)),t.key!=null&&(n.uint32(18),n.bytes(t.key)),t.record!=null&&(n.uint32(26),n.bytes(t.record)),t.closer!=null)for(let s of t.closer)n.uint32(66),br.codec().encode(s,n);if(t.providers!=null)for(let s of t.providers)n.uint32(74),br.codec().encode(s,n);i.lengthDelimited!==!1&&n.ldelim()},(t,n,i={})=>{let s={type:M.PUT_VALUE,closer:[],providers:[]},o=n==null?t.len:t.pos+n;for(;t.pos<o;){let a=t.uint32();switch(a>>>3){case 1:{s.type=M.codec().decode(t);break}case 10:{s.clusterLevel=t.int32();break}case 2:{s.key=t.bytes();break}case 3:{s.record=t.bytes();break}case 8:{if(i.limits?.closer!=null&&s.closer.length===i.limits.closer)throw new pr('Decode error - map field "closer" had too many elements');s.closer.push(br.codec().decode(t,t.uint32(),{limits:i.limits?.closer$}));break}case 9:{if(i.limits?.providers!=null&&s.providers.length===i.limits.providers)throw new pr('Decode error - map field "providers" had too many elements');s.providers.push(br.codec().decode(t,t.uint32(),{limits:i.limits?.providers$}));break}default:{t.skipType(a&7);break}}}return s})),e),r.encode=t=>rt(t,r.codec()),r.decode=(t,n)=>tt(t,r.codec(),n)})(Ke||(Ke={}));function zs(r,e={}){let t={...r,name:"SEND_QUERY",type:0,messageName:r.type,messageType:r.type};return e.onProgress?.(new CustomEvent("kad-dht:query:send-query",{detail:t})),t}function tn(r,e={}){let t={...r,name:"PEER_RESPONSE",type:1,messageName:r.messageType,closer:r.closer??[],providers:r.providers??[]};return e.onProgress?.(new CustomEvent("kad-dht:query:peer-response",{detail:t})),t}function Yn(r,e={}){let t={...r,name:"FINAL_PEER",type:2};return e.onProgress?.(new CustomEvent("kad-dht:query:final-peer",{detail:t})),t}function Ve(r,e={}){let t={...r,name:"QUERY_ERROR",type:3};return e.onProgress?.(new CustomEvent("kad-dht:query:query-error",{detail:t})),t}function Gs(r,e={}){let t={...r,name:"PROVIDER",type:4};return e.onProgress?.(new CustomEvent("kad-dht:query:provider",{detail:t})),t}function rn(r,e={}){let t={...r,name:"VALUE",type:5};return e.onProgress?.(new CustomEvent("kad-dht:query:value",{detail:t})),t}function js(r,e={}){let t={...r,name:"DIAL_PEER",type:7};return e.onProgress?.(new CustomEvent("kad-dht:query:dial-peer",{detail:t})),t}function C(r,e="utf8"){let t=Hn[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.encoder.encode(r).substring(1)}function i0(r,e,t){if(t.length===0)throw new $("No records given");let i=C(e).split("/");if(i.length<3)throw new $("Record key does not have a selector function");let s=r[i[1].toString()];if(s==null)throw new Wn(`No selector function configured for key type "${i[1]}"`);return t.length===1?0:s(e,t)}function E6(r,e){return 0}var s0={pk:E6};function o0(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`positive integer expected, not ${r}`)}function A6(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function xr(r,...e){if(!A6(r))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(r.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${r.length}`)}function a0(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");o0(r.outputLen),o0(r.blockLen)}function vr(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 c0(r,e){xr(r);let t=e.outputLen;if(r.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}var Yt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var Xn=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),We=(r,e)=>r<<32-e|r>>>e;var il=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function l0(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function nn(r){return typeof r=="string"&&(r=l0(r)),xr(r),r}function Zs(...r){let e=0;for(let n=0;n<r.length;n++){let i=r[n];xr(i),e+=i.length}let t=new Uint8Array(e);for(let n=0,i=0;n<r.length;n++){let s=r[n];t.set(s,i),i+=s.length}return t}var Er=class{clone(){return this._cloneInto()}},sl={}.toString;function Jn(r){let e=n=>r().update(nn(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function Ar(r=32){if(Yt&&typeof Yt.getRandomValues=="function")return Yt.getRandomValues(new Uint8Array(r));if(Yt&&typeof Yt.randomBytes=="function")return Yt.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function B6(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);let i=BigInt(32),s=BigInt(4294967295),o=Number(t>>i&s),a=Number(t&s),c=n?4:0,l=n?0:4;r.setUint32(e+c,o,n),r.setUint32(e+l,a,n)}var u0=(r,e,t)=>r&e^~r&t,f0=(r,e,t)=>r&e^r&t^e&t,Br=class extends Er{constructor(e,t,n,i){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Xn(this.buffer)}update(e){vr(this);let{view:t,buffer:n,blockLen:i}=this;e=nn(e);let s=e.length;for(let o=0;o<s;){let a=Math.min(i-this.pos,s-o);if(a===i){let c=Xn(e);for(;i<=s-o;o+=i)this.process(c,o);continue}n.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){vr(this),c0(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:i,isLE:s}=this,{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(n,0),o=0);for(let f=o;f<i;f++)t[f]=0;B6(n,i-8,BigInt(this.length*8),s),this.process(n,0);let a=Xn(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=c/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<l;f++)a.setUint32(4*f,u[f],s)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:t,buffer:n,length:i,finished:s,destroyed:o,pos:a}=this;return e.length=i,e.pos=a,e.finished=s,e.destroyed=o,i%t&&e.buffer.set(n),e}};var e1=BigInt(4294967295),Ws=BigInt(32);function h0(r,e=!1){return e?{h:Number(r&e1),l:Number(r>>Ws&e1)}:{h:Number(r>>Ws&e1)|0,l:Number(r&e1)|0}}function S6(r,e=!1){let t=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let i=0;i<r.length;i++){let{h:s,l:o}=h0(r[i],e);[t[i],n[i]]=[s,o]}return[t,n]}var I6=(r,e)=>BigInt(r>>>0)<<Ws|BigInt(e>>>0),k6=(r,e,t)=>r>>>t,T6=(r,e,t)=>r<<32-t|e>>>t,R6=(r,e,t)=>r>>>t|e<<32-t,N6=(r,e,t)=>r<<32-t|e>>>t,L6=(r,e,t)=>r<<64-t|e>>>t-32,P6=(r,e,t)=>r>>>t-32|e<<64-t,C6=(r,e)=>e,_6=(r,e)=>r,U6=(r,e,t)=>r<<t|e>>>32-t,D6=(r,e,t)=>e<<t|r>>>32-t,M6=(r,e,t)=>e<<t-32|r>>>64-t,O6=(r,e,t)=>r<<t-32|e>>>64-t;function V6(r,e,t,n){let i=(e>>>0)+(n>>>0);return{h:r+t+(i/2**32|0)|0,l:i|0}}var F6=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),H6=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,q6=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),K6=(r,e,t,n,i)=>e+t+n+i+(r/2**32|0)|0,$6=(r,e,t,n,i)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(i>>>0),z6=(r,e,t,n,i,s)=>e+t+n+i+s+(r/2**32|0)|0;var G6={fromBig:h0,split:S6,toBig:I6,shrSH:k6,shrSL:T6,rotrSH:R6,rotrSL:N6,rotrBH:L6,rotrBL:P6,rotr32H:C6,rotr32L:_6,rotlSH:U6,rotlSL:D6,rotlBH:M6,rotlBL:O6,add:V6,add3L:F6,add3H:H6,add4L:q6,add4H:K6,add5H:z6,add5L:$6},D=G6;var[j6,Z6]=D.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),_t=new Uint32Array(80),Ut=new Uint32Array(80),Qs=class extends Br{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:t,Bh:n,Bl:i,Ch:s,Cl:o,Dh:a,Dl:c,Eh:l,El:u,Fh:f,Fl:h,Gh:g,Gl:y,Hh:p,Hl:d}=this;return[e,t,n,i,s,o,a,c,l,u,f,h,g,y,p,d]}set(e,t,n,i,s,o,a,c,l,u,f,h,g,y,p,d){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=l|0,this.El=u|0,this.Fh=f|0,this.Fl=h|0,this.Gh=g|0,this.Gl=y|0,this.Hh=p|0,this.Hl=d|0}process(e,t){for(let m=0;m<16;m++,t+=4)_t[m]=e.getUint32(t),Ut[m]=e.getUint32(t+=4);for(let m=16;m<80;m++){let A=_t[m-15]|0,R=Ut[m-15]|0,T=D.rotrSH(A,R,1)^D.rotrSH(A,R,8)^D.shrSH(A,R,7),I=D.rotrSL(A,R,1)^D.rotrSL(A,R,8)^D.shrSL(A,R,7),k=_t[m-2]|0,P=Ut[m-2]|0,oe=D.rotrSH(k,P,19)^D.rotrBH(k,P,61)^D.shrSH(k,P,6),K=D.rotrSL(k,P,19)^D.rotrBL(k,P,61)^D.shrSL(k,P,6),O=D.add4L(I,K,Ut[m-7],Ut[m-16]),ae=D.add4H(O,T,oe,_t[m-7],_t[m-16]);_t[m]=ae|0,Ut[m]=O|0}let{Ah:n,Al:i,Bh:s,Bl:o,Ch:a,Cl:c,Dh:l,Dl:u,Eh:f,El:h,Fh:g,Fl:y,Gh:p,Gl:d,Hh:w,Hl:v}=this;for(let m=0;m<80;m++){let A=D.rotrSH(f,h,14)^D.rotrSH(f,h,18)^D.rotrBH(f,h,41),R=D.rotrSL(f,h,14)^D.rotrSL(f,h,18)^D.rotrBL(f,h,41),T=f&g^~f&p,I=h&y^~h&d,k=D.add5L(v,R,I,Z6[m],Ut[m]),P=D.add5H(k,w,A,T,j6[m],_t[m]),oe=k|0,K=D.rotrSH(n,i,28)^D.rotrBH(n,i,34)^D.rotrBH(n,i,39),O=D.rotrSL(n,i,28)^D.rotrBL(n,i,34)^D.rotrBL(n,i,39),ae=n&s^n&a^s&a,B=i&o^i&c^o&c;w=p|0,v=d|0,p=g|0,d=y|0,g=f|0,y=h|0,{h:f,l:h}=D.add(l|0,u|0,P|0,oe|0),l=a|0,u=c|0,a=s|0,c=o|0,s=n|0,o=i|0;let N=D.add3L(oe,O,B);n=D.add3H(N,P,K,ae),i=N|0}({h:n,l:i}=D.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:o}=D.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:c}=D.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:u}=D.add(this.Dh|0,this.Dl|0,l|0,u|0),{h:f,l:h}=D.add(this.Eh|0,this.El|0,f|0,h|0),{h:g,l:y}=D.add(this.Fh|0,this.Fl|0,g|0,y|0),{h:p,l:d}=D.add(this.Gh|0,this.Gl|0,p|0,d|0),{h:w,l:v}=D.add(this.Hh|0,this.Hl|0,w|0,v|0),this.set(n,i,s,o,a,c,l,u,f,h,g,y,p,d,w,v)}roundClean(){_t.fill(0),Ut.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var d0=Jn(()=>new Qs);var r1={};Te(r1,{aInRange:()=>_e,abool:()=>Qe,abytes:()=>Sr,bitGet:()=>ea,bitLen:()=>to,bitMask:()=>on,bitSet:()=>ta,bytesToHex:()=>bt,bytesToNumberBE:()=>wt,bytesToNumberLE:()=>Mt,concatBytes:()=>xt,createHmacDrbg:()=>ro,ensureBytes:()=>re,equalBytes:()=>X6,hexToBytes:()=>Jt,hexToNumber:()=>eo,inRange:()=>sn,isBytes:()=>Dt,memoized:()=>tr,notImplemented:()=>na,numberToBytesBE:()=>Ot,numberToBytesLE:()=>er,numberToHexUnpadded:()=>Xt,numberToVarBytesBE:()=>Y6,utf8ToBytes:()=>J6,validateObject:()=>it});var Js=BigInt(0),t1=BigInt(1),W6=BigInt(2);function Dt(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Sr(r){if(!Dt(r))throw new Error("Uint8Array expected")}function Qe(r,e){if(typeof e!="boolean")throw new Error(`${r} must be valid boolean, got "${e}".`)}var Q6=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function bt(r){Sr(r);let e="";for(let t=0;t<r.length;t++)e+=Q6[r[t]];return e}function Xt(r){let e=r.toString(16);return e.length&1?`0${e}`:e}function eo(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var yt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function p0(r){if(r>=yt._0&&r<=yt._9)return r-yt._0;if(r>=yt._A&&r<=yt._F)return r-(yt._A-10);if(r>=yt._a&&r<=yt._f)return r-(yt._a-10)}function Jt(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let e=r.length,t=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(t);for(let i=0,s=0;i<t;i++,s+=2){let o=p0(r.charCodeAt(s)),a=p0(r.charCodeAt(s+1));if(o===void 0||a===void 0){let c=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[i]=o*16+a}return n}function wt(r){return eo(bt(r))}function Mt(r){return Sr(r),eo(bt(Uint8Array.from(r).reverse()))}function Ot(r,e){return Jt(r.toString(16).padStart(e*2,"0"))}function er(r,e){return Ot(r,e).reverse()}function Y6(r){return Jt(Xt(r))}function re(r,e,t){let n;if(typeof e=="string")try{n=Jt(e)}catch(s){throw new Error(`${r} must be valid hex string, got "${e}". Cause: ${s}`)}else if(Dt(e))n=Uint8Array.from(e);else throw new Error(`${r} must be hex string or Uint8Array`);let i=n.length;if(typeof t=="number"&&i!==t)throw new Error(`${r} expected ${t} bytes, got ${i}`);return n}function xt(...r){let e=0;for(let n=0;n<r.length;n++){let i=r[n];Sr(i),e+=i.length}let t=new Uint8Array(e);for(let n=0,i=0;n<r.length;n++){let s=r[n];t.set(s,i),i+=s.length}return t}function X6(r,e){if(r.length!==e.length)return!1;let t=0;for(let n=0;n<r.length;n++)t|=r[n]^e[n];return t===0}function J6(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}var Ys=r=>typeof r=="bigint"&&Js<=r;function sn(r,e,t){return Ys(r)&&Ys(e)&&Ys(t)&&e<=r&&r<t}function _e(r,e,t,n){if(!sn(e,t,n))throw new Error(`expected valid ${r}: ${t} <= n < ${n}, got ${typeof e} ${e}`)}function to(r){let e;for(e=0;r>Js;r>>=t1,e+=1);return e}function ea(r,e){return r>>BigInt(e)&t1}function ta(r,e,t){return r|(t?t1:Js)<<BigInt(e)}var on=r=>(W6<<BigInt(r-1))-t1,Xs=r=>new Uint8Array(r),g0=r=>Uint8Array.from(r);function ro(r,e,t){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let n=Xs(r),i=Xs(r),s=0,o=()=>{n.fill(1),i.fill(0),s=0},a=(...f)=>t(i,n,...f),c=(f=Xs())=>{i=a(g0([0]),f),n=a(),f.length!==0&&(i=a(g0([1]),f),n=a())},l=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let f=0,h=[];for(;f<e;){n=a();let g=n.slice();h.push(g),f+=n.length}return xt(...h)};return(f,h)=>{o(),c(f);let g;for(;!(g=h(l()));)c();return o(),g}}var ra={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||Dt(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,e)=>e.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function it(r,e,t={}){let n=(i,s,o)=>{let a=ra[s];if(typeof a!="function")throw new Error(`Invalid validator "${s}", expected function`);let c=r[i];if(!(o&&c===void 0)&&!a(c,r))throw new Error(`Invalid param ${String(i)}=${c} (${typeof c}), expected ${s}`)};for(let[i,s]of Object.entries(e))n(i,s,!1);for(let[i,s]of Object.entries(t))n(i,s,!0);return r}var na=()=>{throw new Error("not implemented")};function tr(r){let e=new WeakMap;return(t,...n)=>{let i=e.get(t);if(i!==void 0)return i;let s=r(t,...n);return e.set(t,s),s}}var ue=BigInt(0),X=BigInt(1),rr=BigInt(2),ia=BigInt(3),no=BigInt(4),m0=BigInt(5),y0=BigInt(8),sa=BigInt(9),oa=BigInt(16);function Z(r,e){let t=r%e;return t>=ue?t:e+t}function aa(r,e,t){if(t<=ue||e<ue)throw new Error("Expected power/modulo > 0");if(t===X)return ue;let n=X;for(;e>ue;)e&X&&(n=n*r%t),r=r*r%t,e>>=X;return n}function J(r,e,t){let n=r;for(;e-- >ue;)n*=n,n%=t;return n}function n1(r,e){if(r===ue||e<=ue)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=Z(r,e),n=e,i=ue,s=X,o=X,a=ue;for(;t!==ue;){let l=n/t,u=n%t,f=i-o*l,h=s-a*l;n=t,t=u,i=o,s=a,o=f,a=h}if(n!==X)throw new Error("invert: does not exist");return Z(i,e)}function ca(r){let e=(r-X)/rr,t,n,i;for(t=r-X,n=0;t%rr===ue;t/=rr,n++);for(i=rr;i<r&&aa(i,e,r)!==r-X;i++);if(n===1){let o=(r+X)/no;return function(c,l){let u=c.pow(l,o);if(!c.eql(c.sqr(u),l))throw new Error("Cannot find square root");return u}}let s=(t+X)/rr;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let l=n,u=a.pow(a.mul(a.ONE,i),t),f=a.pow(c,s),h=a.pow(c,t);for(;!a.eql(h,a.ONE);){if(a.eql(h,a.ZERO))return a.ZERO;let g=1;for(let p=a.sqr(h);g<l&&!a.eql(p,a.ONE);g++)p=a.sqr(p);let y=a.pow(u,X<<BigInt(l-g-1));u=a.sqr(y),f=a.mul(f,y),h=a.mul(h,u),l=g}return f}}function la(r){if(r%no===ia){let e=(r+X)/no;return function(n,i){let s=n.pow(i,e);if(!n.eql(n.sqr(s),i))throw new Error("Cannot find square root");return s}}if(r%y0===m0){let e=(r-m0)/y0;return function(n,i){let s=n.mul(i,rr),o=n.pow(s,e),a=n.mul(i,o),c=n.mul(n.mul(a,rr),o),l=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(l),i))throw new Error("Cannot find square root");return l}}return r%oa,ca(r)}var b0=(r,e)=>(Z(r,e)&X)===X,ua=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function io(r){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=ua.reduce((n,i)=>(n[i]="function",n),e);return it(r,t)}function fa(r,e,t){if(t<ue)throw new Error("Expected power > 0");if(t===ue)return r.ONE;if(t===X)return e;let n=r.ONE,i=e;for(;t>ue;)t&X&&(n=r.mul(n,i)),i=r.sqr(i),t>>=X;return n}function ha(r,e){let t=new Array(e.length),n=e.reduce((s,o,a)=>r.is0(o)?s:(t[a]=s,r.mul(s,o)),r.ONE),i=r.inv(n);return e.reduceRight((s,o,a)=>r.is0(o)?s:(t[a]=r.mul(s,t[a]),r.mul(s,o)),i),t}function so(r,e){let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function Vt(r,e,t=!1,n={}){if(r<=ue)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:i,nByteLength:s}=so(r,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let o=la(r),a=Object.freeze({ORDER:r,BITS:i,BYTES:s,MASK:on(i),ZERO:ue,ONE:X,create:c=>Z(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return ue<=c&&c<r},is0:c=>c===ue,isOdd:c=>(c&X)===X,neg:c=>Z(-c,r),eql:(c,l)=>c===l,sqr:c=>Z(c*c,r),add:(c,l)=>Z(c+l,r),sub:(c,l)=>Z(c-l,r),mul:(c,l)=>Z(c*l,r),pow:(c,l)=>fa(a,c,l),div:(c,l)=>Z(c*n1(l,r),r),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>n1(c,r),sqrt:n.sqrt||(c=>o(a,c)),invertBatch:c=>ha(a,c),cmov:(c,l,u)=>u?l:c,toBytes:c=>t?er(c,s):Ot(c,s),fromBytes:c=>{if(c.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${c.length}`);return t?Mt(c):wt(c)}});return Object.freeze(a)}function w0(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 oo(r){let e=w0(r);return e+Math.ceil(e/2)}function x0(r,e,t=!1){let n=r.length,i=w0(e),s=oo(e);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let o=t?wt(r):Mt(r),a=Z(o,e-X)+X;return t?er(a,i):Ot(a,i)}var pa=BigInt(0),ao=BigInt(1),co=new WeakMap,v0=new WeakMap;function i1(r,e){let t=(s,o)=>{let a=o.negate();return s?a:o},n=s=>{if(!Number.isSafeInteger(s)||s<=0||s>e)throw new Error(`Wrong window size=${s}, should be [1..${e}]`)},i=s=>{n(s);let o=Math.ceil(e/s)+1,a=2**(s-1);return{windows:o,windowSize:a}};return{constTimeNegate:t,unsafeLadder(s,o){let a=r.ZERO,c=s;for(;o>pa;)o&ao&&(a=a.add(c)),c=c.double(),o>>=ao;return a},precomputeWindow(s,o){let{windows:a,windowSize:c}=i(o),l=[],u=s,f=u;for(let h=0;h<a;h++){f=u,l.push(f);for(let g=1;g<c;g++)f=f.add(u),l.push(f);u=f.double()}return l},wNAF(s,o,a){let{windows:c,windowSize:l}=i(s),u=r.ZERO,f=r.BASE,h=BigInt(2**s-1),g=2**s,y=BigInt(s);for(let p=0;p<c;p++){let d=p*l,w=Number(a&h);a>>=y,w>l&&(w-=g,a+=ao);let v=d,m=d+Math.abs(w)-1,A=p%2!==0,R=w<0;w===0?f=f.add(t(A,o[v])):u=u.add(t(R,o[m]))}return{p:u,f}},wNAFCached(s,o,a){let c=v0.get(s)||1,l=co.get(s);return l||(l=this.precomputeWindow(s,c),c!==1&&co.set(s,a(l))),this.wNAF(c,l,o)},setWindowSize(s,o){n(o),v0.set(s,o),co.delete(s)}}}function s1(r,e,t,n){if(!Array.isArray(t)||!Array.isArray(n)||n.length!==t.length)throw new Error("arrays of points and scalars must have equal length");n.forEach((u,f)=>{if(!e.isValid(u))throw new Error(`wrong scalar at index ${f}`)}),t.forEach((u,f)=>{if(!(u instanceof r))throw new Error(`wrong point at index ${f}`)});let i=to(BigInt(t.length)),s=i>12?i-3:i>4?i-2:i?2:1,o=(1<<s)-1,a=new Array(o+1).fill(r.ZERO),c=Math.floor((e.BITS-1)/s)*s,l=r.ZERO;for(let u=c;u>=0;u-=s){a.fill(r.ZERO);for(let h=0;h<n.length;h++){let g=n[h],y=Number(g>>BigInt(u)&BigInt(o));a[y]=a[y].add(t[h])}let f=r.ZERO;for(let h=a.length-1,g=r.ZERO;h>0;h--)g=g.add(a[h]),f=f.add(g);if(l=l.add(f),u!==0)for(let h=0;h<s;h++)l=l.double()}return l}function an(r){return io(r.Fp),it(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...so(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Ye=BigInt(0),Ue=BigInt(1),o1=BigInt(2),ga=BigInt(8),ma={zip215:!0};function ya(r){let e=an(r);return it(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function E0(r){let e=ya(r),{Fp:t,n,prehash:i,hash:s,randomBytes:o,nByteLength:a,h:c}=e,l=o1<<BigInt(a*8)-Ue,u=t.create,f=Vt(e.n,e.nBitLength),h=e.uvRatio||((x,b)=>{try{return{isValid:!0,value:t.sqrt(x*t.inv(b))}}catch{return{isValid:!1,value:Ye}}}),g=e.adjustScalarBytes||(x=>x),y=e.domain||((x,b,E)=>{if(Qe("phflag",E),b.length||E)throw new Error("Contexts/pre-hash are not supported");return x});function p(x,b){_e("coordinate "+x,b,Ye,l)}function d(x){if(!(x instanceof m))throw new Error("ExtendedPoint expected")}let w=tr((x,b)=>{let{ex:E,ey:L,ez:_}=x,U=x.is0();b==null&&(b=U?ga:t.inv(_));let V=u(E*b),q=u(L*b),F=u(_*b);if(U)return{x:Ye,y:Ue};if(F!==Ue)throw new Error("invZ was invalid");return{x:V,y:q}}),v=tr(x=>{let{a:b,d:E}=e;if(x.is0())throw new Error("bad point: ZERO");let{ex:L,ey:_,ez:U,et:V}=x,q=u(L*L),F=u(_*_),j=u(U*U),W=u(j*j),he=u(q*b),de=u(j*u(he+F)),me=u(W+u(E*u(q*F)));if(de!==me)throw new Error("bad point: equation left != right (1)");let ke=u(L*_),ce=u(U*V);if(ke!==ce)throw new Error("bad point: equation left != right (2)");return!0});class m{constructor(b,E,L,_){this.ex=b,this.ey=E,this.ez=L,this.et=_,p("x",b),p("y",E),p("z",L),p("t",_),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(b){if(b instanceof m)throw new Error("extended point not allowed");let{x:E,y:L}=b||{};return p("x",E),p("y",L),new m(E,L,Ue,u(E*L))}static normalizeZ(b){let E=t.invertBatch(b.map(L=>L.ez));return b.map((L,_)=>L.toAffine(E[_])).map(m.fromAffine)}static msm(b,E){return s1(m,f,b,E)}_setWindowSize(b){T.setWindowSize(this,b)}assertValidity(){v(this)}equals(b){d(b);let{ex:E,ey:L,ez:_}=this,{ex:U,ey:V,ez:q}=b,F=u(E*q),j=u(U*_),W=u(L*q),he=u(V*_);return F===j&&W===he}is0(){return this.equals(m.ZERO)}negate(){return new m(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:b}=e,{ex:E,ey:L,ez:_}=this,U=u(E*E),V=u(L*L),q=u(o1*u(_*_)),F=u(b*U),j=E+L,W=u(u(j*j)-U-V),he=F+V,de=he-q,me=F-V,ke=u(W*de),ce=u(he*me),Le=u(W*me),ut=u(de*he);return new m(ke,ce,ut,Le)}add(b){d(b);let{a:E,d:L}=e,{ex:_,ey:U,ez:V,et:q}=this,{ex:F,ey:j,ez:W,et:he}=b;if(E===BigInt(-1)){let o2=u((U-_)*(j+F)),a2=u((U+_)*(j-F)),es=u(a2-o2);if(es===Ye)return this.double();let c2=u(V*o1*he),l2=u(q*o1*W),u2=l2+c2,f2=a2+o2,h2=l2-c2,M4=u(u2*es),O4=u(f2*h2),V4=u(u2*h2),F4=u(es*f2);return new m(M4,O4,F4,V4)}let de=u(_*F),me=u(U*j),ke=u(q*L*he),ce=u(V*W),Le=u((_+U)*(F+j)-de-me),ut=ce-ke,$r=ce+ke,zr=u(me-E*de),C4=u(Le*ut),_4=u($r*zr),U4=u(Le*zr),D4=u(ut*$r);return new m(C4,_4,D4,U4)}subtract(b){return this.add(b.negate())}wNAF(b){return T.wNAFCached(this,b,m.normalizeZ)}multiply(b){let E=b;_e("scalar",E,Ue,n);let{p:L,f:_}=this.wNAF(E);return m.normalizeZ([L,_])[0]}multiplyUnsafe(b){let E=b;return _e("scalar",E,Ye,n),E===Ye?R:this.equals(R)||E===Ue?this:this.equals(A)?this.wNAF(E).p:T.unsafeLadder(this,E)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return T.unsafeLadder(this,n).is0()}toAffine(b){return w(this,b)}clearCofactor(){let{h:b}=e;return b===Ue?this:this.multiplyUnsafe(b)}static fromHex(b,E=!1){let{d:L,a:_}=e,U=t.BYTES;b=re("pointHex",b,U),Qe("zip215",E);let V=b.slice(),q=b[U-1];V[U-1]=q&-129;let F=Mt(V),j=E?l:t.ORDER;_e("pointHex.y",F,Ye,j);let W=u(F*F),he=u(W-Ue),de=u(L*W-_),{isValid:me,value:ke}=h(he,de);if(!me)throw new Error("Point.fromHex: invalid y coordinate");let ce=(ke&Ue)===Ue,Le=(q&128)!==0;if(!E&&ke===Ye&&Le)throw new Error("Point.fromHex: x=0 and x_0=1");return Le!==ce&&(ke=u(-ke)),m.fromAffine({x:ke,y:F})}static fromPrivateKey(b){return P(b).point}toRawBytes(){let{x:b,y:E}=this.toAffine(),L=er(E,t.BYTES);return L[L.length-1]|=b&Ue?128:0,L}toHex(){return bt(this.toRawBytes())}}m.BASE=new m(e.Gx,e.Gy,Ue,u(e.Gx*e.Gy)),m.ZERO=new m(Ye,Ue,Ue,Ye);let{BASE:A,ZERO:R}=m,T=i1(m,a*8);function I(x){return Z(x,n)}function k(x){return I(Mt(x))}function P(x){let b=a;x=re("private key",x,b);let E=re("hashed private key",s(x),2*b),L=g(E.slice(0,b)),_=E.slice(b,2*b),U=k(L),V=A.multiply(U),q=V.toRawBytes();return{head:L,prefix:_,scalar:U,point:V,pointBytes:q}}function oe(x){return P(x).pointBytes}function K(x=new Uint8Array,...b){let E=xt(...b);return k(s(y(E,re("context",x),!!i)))}function O(x,b,E={}){x=re("message",x),i&&(x=i(x));let{prefix:L,scalar:_,pointBytes:U}=P(b),V=K(E.context,L,x),q=A.multiply(V).toRawBytes(),F=K(E.context,q,U,x),j=I(V+F*_);_e("signature.s",j,Ye,n);let W=xt(q,er(j,t.BYTES));return re("result",W,a*2)}let ae=ma;function B(x,b,E,L=ae){let{context:_,zip215:U}=L,V=t.BYTES;x=re("signature",x,2*V),b=re("message",b),U!==void 0&&Qe("zip215",U),i&&(b=i(b));let q=Mt(x.slice(V,2*V)),F,j,W;try{F=m.fromHex(E,U),j=m.fromHex(x.slice(0,V),U),W=A.multiplyUnsafe(q)}catch{return!1}if(!U&&F.isSmallOrder())return!1;let he=K(_,j.toRawBytes(),F.toRawBytes(),b);return j.add(F.multiplyUnsafe(he)).subtract(W).clearCofactor().equals(m.ZERO)}return A._setWindowSize(8),{CURVE:e,getPublicKey:oe,sign:O,verify:B,ExtendedPoint:m,utils:{getExtendedPublicKey:P,randomPrivateKey:()=>o(t.BYTES),precompute(x=8,b=m.BASE){return b._setWindowSize(x),b.multiply(BigInt(3)),b}}}}var lo=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),A0=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Tl=BigInt(0),ba=BigInt(1),B0=BigInt(2),Rl=BigInt(3),wa=BigInt(5),xa=BigInt(8);function va(r){let e=BigInt(10),t=BigInt(20),n=BigInt(40),i=BigInt(80),s=lo,a=r*r%s*r%s,c=J(a,B0,s)*a%s,l=J(c,ba,s)*r%s,u=J(l,wa,s)*l%s,f=J(u,e,s)*u%s,h=J(f,t,s)*f%s,g=J(h,n,s)*h%s,y=J(g,i,s)*g%s,p=J(y,i,s)*g%s,d=J(p,e,s)*u%s;return{pow_p_5_8:J(d,B0,s)*r%s,b2:a}}function Ea(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Aa(r,e){let t=lo,n=Z(e*e*e,t),i=Z(n*n*e,t),s=va(r*i).pow_p_5_8,o=Z(r*n*s,t),a=Z(e*o*o,t),c=o,l=Z(o*A0,t),u=a===r,f=a===Z(-r,t),h=a===Z(-r*A0,t);return u&&(o=c),(f||h)&&(o=l),b0(o,t)&&(o=Z(-o,t)),{isValid:u||f,value:o}}var Ba=Vt(lo,void 0,!0),Sa={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Ba,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:xa,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:d0,randomBytes:Ar,adjustScalarBytes:Ea,uvRatio:Aa},S0=E0(Sa);var a1=32;function I0(r,e,t){return S0.verify(e,t instanceof Uint8Array?t:t.subarray(),r)}var c1=class{type="Ed25519";raw;constructor(e){this.raw=uo(e,a1)}toMultihash(){return gt.digest(Ir(this))}toCID(){return ne.createV1(114,this.toMultihash())}toString(){return Q.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ee(this.raw,e.raw)}verify(e,t){return I0(this.raw,t,e)}};function fo(r){return r=uo(r,a1),new c1(r)}function uo(r,e){if(r=Uint8Array.from(r??[]),r.length!==e)throw new $(`Key must be a Uint8Array of length ${e}, got ${r.length}`);return r}var fe;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1"})(fe||(fe={}));var ho;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1"})(ho||(ho={}));(function(r){r.codec=()=>dr(ho)})(fe||(fe={}));var st;(function(r){let e;r.codec=()=>(e==null&&(e=nt((t,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),fe.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),i.lengthDelimited!==!1&&n.ldelim()},(t,n,i={})=>{let s={},o=n==null?t.len:t.pos+n;for(;t.pos<o;){let a=t.uint32();switch(a>>>3){case 1:{s.Type=fe.codec().decode(t);break}case 2:{s.Data=t.bytes();break}default:{t.skipType(a&7);break}}}return s})),e),r.encode=t=>rt(t,r.codec()),r.decode=(t,n)=>tt(t,r.codec(),n)})(st||(st={}));var po;(function(r){let e;r.codec=()=>(e==null&&(e=nt((t,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),fe.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),i.lengthDelimited!==!1&&n.ldelim()},(t,n,i={})=>{let s={},o=n==null?t.len:t.pos+n;for(;t.pos<o;){let a=t.uint32();switch(a>>>3){case 1:{s.Type=fe.codec().decode(t);break}case 2:{s.Data=t.bytes();break}default:{t.skipType(a&7);break}}}return s})),e),r.encode=t=>rt(t,r.codec()),r.decode=(t,n)=>tt(t,r.codec(),n)})(po||(po={}));var yn={};Te(yn,{MAX_RSA_KEY_SIZE:()=>ei,generateRSAKeyPair:()=>B3,jwkToJWKKeyPair:()=>S3,jwkToPkcs1:()=>qa,jwkToPkix:()=>Ao,jwkToRSAPrivateKey:()=>A3,pkcs1ToJwk:()=>x3,pkcs1ToRSAPrivateKey:()=>E3,pkixToJwk:()=>v3,pkixToRSAPublicKey:()=>Bo});var ka=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ft=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ht=new Uint32Array(64),go=class extends Br{constructor(){super(64,32,8,!1),this.A=Ft[0]|0,this.B=Ft[1]|0,this.C=Ft[2]|0,this.D=Ft[3]|0,this.E=Ft[4]|0,this.F=Ft[5]|0,this.G=Ft[6]|0,this.H=Ft[7]|0}get(){let{A:e,B:t,C:n,D:i,E:s,F:o,G:a,H:c}=this;return[e,t,n,i,s,o,a,c]}set(e,t,n,i,s,o,a,c){this.A=e|0,this.B=t|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,t){for(let f=0;f<16;f++,t+=4)Ht[f]=e.getUint32(t,!1);for(let f=16;f<64;f++){let h=Ht[f-15],g=Ht[f-2],y=We(h,7)^We(h,18)^h>>>3,p=We(g,17)^We(g,19)^g>>>10;Ht[f]=p+Ht[f-7]+y+Ht[f-16]|0}let{A:n,B:i,C:s,D:o,E:a,F:c,G:l,H:u}=this;for(let f=0;f<64;f++){let h=We(a,6)^We(a,11)^We(a,25),g=u+h+u0(a,c,l)+ka[f]+Ht[f]|0,p=(We(n,2)^We(n,13)^We(n,22))+f0(n,i,s)|0;u=l,l=c,c=a,a=o+g|0,o=s,s=i,i=n,n=g+p|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(n,i,s,o,a,c,l,u)}roundClean(){Ht.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var kr=Jn(()=>new go);var H=Mn(R0());function nr(r,e){let t=0;if(r.length===1)return r[0];for(let n=r.length-1;n>=0;n--)t+=r[r.length-1-n]*Math.pow(2,e*n);return t}function qt(r,e,t=-1){let n=t,i=r,s=0,o=Math.pow(2,e);for(let a=1;a<8;a++){if(r<o){let c;if(n<0)c=new ArrayBuffer(a),s=a;else{if(n<a)return new ArrayBuffer(0);c=new ArrayBuffer(n),s=n}let l=new Uint8Array(c);for(let u=a-1;u>=0;u--){let f=Math.pow(2,u*e);l[s-u-1]=Math.floor(i/f),i-=l[s-u-1]*f}return c}o*=Math.pow(2,e)}return new ArrayBuffer(0)}function f1(...r){let e=0,t=0;for(let s of r)e+=s.length;let n=new ArrayBuffer(e),i=new Uint8Array(n);for(let s of r)i.set(s,t),t+=s.length;return i}function yo(){let r=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){let a=r[0]===255&&r[1]&128,c=r[0]===0&&(r[1]&128)===0;(a||c)&&this.warnings.push("Needlessly long format")}let e=new ArrayBuffer(this.valueHex.byteLength),t=new Uint8Array(e);for(let a=0;a<this.valueHex.byteLength;a++)t[a]=0;t[0]=r[0]&128;let n=nr(t,8),i=new ArrayBuffer(this.valueHex.byteLength),s=new Uint8Array(i);for(let a=0;a<this.valueHex.byteLength;a++)s[a]=r[a];return s[0]&=127,nr(s,8)-n}function N0(r){let e=r<0?r*-1:r,t=128;for(let n=1;n<8;n++){if(e<=t){if(r<0){let o=t-e,a=qt(o,8,n),c=new Uint8Array(a);return c[0]|=128,a}let i=qt(e,8,n),s=new Uint8Array(i);if(s[0]&128){let o=i.slice(0),a=new Uint8Array(o);i=new ArrayBuffer(i.byteLength+1),s=new Uint8Array(i);for(let c=0;c<o.byteLength;c++)s[c+1]=a[c];s[0]=0}return i}t*=Math.pow(2,8)}return new ArrayBuffer(0)}function L0(r,e){if(r.byteLength!==e.byteLength)return!1;let t=new Uint8Array(r),n=new Uint8Array(e);for(let i=0;i<t.length;i++)if(t[i]!==n[i])return!1;return!0}function De(r,e){let t=r.toString(10);if(e<t.length)return"";let n=e-t.length,i=new Array(n);for(let o=0;o<n;o++)i[o]="0";return i.join("").concat(t)}var Xl=Math.log(2);function h1(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function bo(r){let e=0,t=0;for(let i=0;i<r.length;i++){let s=r[i];e+=s.byteLength}let n=new Uint8Array(e);for(let i=0;i<r.length;i++){let s=r[i];n.set(new Uint8Array(s),t),t+=s.byteLength}return n.buffer}function St(r,e,t,n){return e instanceof Uint8Array?e.byteLength?t<0?(r.error="Wrong parameter: inputOffset less than zero",!1):n<0?(r.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-t-n<0?(r.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(r.error="Wrong parameter: inputBuffer has zero length",!1):(r.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}var ln=class{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return bo(this.items)}},cn=[new Uint8Array([1])],P0="0123456789";var Pr="",Xe=new ArrayBuffer(0),wo=new Uint8Array(0),un="EndOfContent",_0="OCTET STRING",U0="BIT STRING";function It(r){var e;return e=class extends r{constructor(...n){var i;super(...n);let s=n[0]||{};this.isHexOnly=(i=s.isHexOnly)!==null&&i!==void 0?i:!1,this.valueHexView=s.valueHex?H.BufferSourceConverter.toUint8Array(s.valueHex):wo}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(n){this.valueHexView=new Uint8Array(n)}fromBER(n,i,s){let o=n instanceof ArrayBuffer?new Uint8Array(n):n;if(!St(this,o,i,s))return-1;let a=i+s;return this.valueHexView=o.subarray(i,a),this.valueHexView.length?(this.blockLength=s,a):(this.warnings.push("Zero buffer length"),i)}toBER(n=!1){return this.isHexOnly?n?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",Xe)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:H.Convert.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}var Et=class{constructor({blockLength:e=0,error:t=Pr,warnings:n=[],valueBeforeDecode:i=wo}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=H.BufferSourceConverter.toUint8Array(i)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:H.Convert.ToHex(this.valueBeforeDecodeView)}}};Et.NAME="baseBlock";var Be=class extends Et{fromBER(e,t,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,t){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}};Be.NAME="valueBlock";var d1=class extends It(Et){constructor({idBlock:e={}}={}){var t,n,i,s;super(),e?(this.isHexOnly=(t=e.isHexOnly)!==null&&t!==void 0?t:!1,this.valueHexView=e.valueHex?H.BufferSourceConverter.toUint8Array(e.valueHex):wo,this.tagClass=(n=e.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(i=e.tagNumber)!==null&&i!==void 0?i:-1,this.isConstructed=(s=e.isConstructed)!==null&&s!==void 0?s:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let t=0;switch(this.tagClass){case 1:t|=0;break;case 2:t|=64;break;case 3:t|=128;break;case 4:t|=192;break;default:return this.error="Unknown tag class",Xe}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){let i=new Uint8Array(1);if(!e){let s=this.tagNumber;s&=31,t|=s,i[0]=t}return i.buffer}if(!this.isHexOnly){let i=qt(this.tagNumber,7),s=new Uint8Array(i),o=i.byteLength,a=new Uint8Array(o+1);if(a[0]=t|31,!e){for(let c=0;c<o-1;c++)a[c+1]=s[c]|128;a[o]=s[o-1]}return a.buffer}let n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=t|31,!e){let i=this.valueHexView;for(let s=0;s<i.length-1;s++)n[s+1]=i[s]|128;n[this.valueHexView.byteLength]=i[i.length-1]}return n.buffer}fromBER(e,t,n){let i=H.BufferSourceConverter.toUint8Array(e);if(!St(this,i,t,n))return-1;let s=i.subarray(t,t+n);if(s.length===0)return this.error="Zero buffer length",-1;switch(s[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(s[0]&32)===32,this.isHexOnly=!1;let a=s[0]&31;if(a!==31)this.tagNumber=a,this.blockLength=1;else{let c=1,l=this.valueHexView=new Uint8Array(255),u=255;for(;s[c]&128;){if(l[c-1]=s[c]&127,c++,c>=s.length)return this.error="End of input reached before message was fully decoded",-1;if(c===u){u+=255;let h=new Uint8Array(u);for(let g=0;g<l.length;g++)h[g]=l[g];l=this.valueHexView=new Uint8Array(u)}}this.blockLength=c+1,l[c-1]=s[c]&127;let f=new Uint8Array(c);for(let h=0;h<c;h++)f[h]=l[h];l=this.valueHexView=new Uint8Array(c),l.set(f),this.blockLength<=9?this.tagNumber=nr(l,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return t+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}};d1.NAME="identificationBlock";var p1=class extends Et{constructor({lenBlock:e={}}={}){var t,n,i;super(),this.isIndefiniteForm=(t=e.isIndefiniteForm)!==null&&t!==void 0?t:!1,this.longFormUsed=(n=e.longFormUsed)!==null&&n!==void 0?n:!1,this.length=(i=e.length)!==null&&i!==void 0?i:0}fromBER(e,t,n){let i=H.BufferSourceConverter.toUint8Array(e);if(!St(this,i,t,n))return-1;let s=i.subarray(t,t+n);if(s.length===0)return this.error="Zero buffer length",-1;if(s[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=s[0]===128,this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(s[0]&128),this.longFormUsed===!1)return this.length=s[0],this.blockLength=1,t+this.blockLength;let o=s[0]&127;if(o>8)return this.error="Too big integer",-1;if(o+1>s.length)return this.error="End of input reached before message was fully decoded",-1;let a=t+1,c=i.subarray(a,a+o);return c[o-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=nr(c,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=o+1,t+this.blockLength}toBER(e=!1){let t,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=128),t;if(this.longFormUsed){let i=qt(this.length,8);if(i.byteLength>127)return this.error="Too big length",Xe;if(t=new ArrayBuffer(i.byteLength+1),e)return t;let s=new Uint8Array(i);n=new Uint8Array(t),n[0]=i.byteLength|128;for(let o=0;o<i.byteLength;o++)n[o+1]=s[o];return t}return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=this.length),t}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}};p1.NAME="lengthBlock";var S={},we=class extends Et{constructor({name:e=Pr,optional:t=!1,primitiveSchema:n,...i}={},s){super(i),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new d1(i),this.lenBlock=new p1(i),this.valueBlock=s?new s(i):new Be(i)}fromBER(e,t,n){let i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}toBER(e,t){let n=t||new ln;t||D0(this);let i=this.idBlock.toBER(e);if(n.write(i),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,n),n.write(new ArrayBuffer(2));else{let s=this.valueBlock.toBER(e);this.lenBlock.length=s.byteLength;let o=this.lenBlock.toBER(e);n.write(o),n.write(s)}return t?Xe:n.final()}toJSON(){let e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return e==="ascii"?this.onAsciiEncoding():H.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${H.Convert.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;let t=this.toBER(),n=e.toBER();return L0(t,n)}};we.NAME="BaseBlock";function D0(r){if(r instanceof S.Constructed)for(let e of r.valueBlock.value)D0(e)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}var g1=class extends we{constructor({value:e=Pr,...t}={},n){super(t,n),e&&this.fromString(e)}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}fromBER(e,t,n){let i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}};g1.NAME="BaseStringBlock";var m1=class extends It(Be){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}};m1.NAME="PrimitiveValueBlock";var M0,y1=class extends we{constructor(e={}){super(e,m1),this.idBlock.isConstructed=!1}};M0=y1;S.Primitive=M0;y1.NAME="PRIMITIVE";function Da(r,e){if(r instanceof e)return r;let t=new e;return t.idBlock=r.idBlock,t.lenBlock=r.lenBlock,t.warnings=r.warnings,t.valueBeforeDecodeView=r.valueBeforeDecodeView,t}function Y1(r,e=0,t=r.length){let n=e,i=new we({},Be),s=new Et;if(!St(s,r,e,t))return i.error=s.error,{offset:-1,result:i};if(!r.subarray(e,e+t).length)return i.error="Zero buffer length",{offset:-1,result:i};let a=i.idBlock.fromBER(r,e,t);if(i.idBlock.warnings.length&&i.warnings.concat(i.idBlock.warnings),a===-1)return i.error=i.idBlock.error,{offset:-1,result:i};if(e=a,t-=i.idBlock.blockLength,a=i.lenBlock.fromBER(r,e,t),i.lenBlock.warnings.length&&i.warnings.concat(i.lenBlock.warnings),a===-1)return i.error=i.lenBlock.error,{offset:-1,result:i};if(e=a,t-=i.lenBlock.blockLength,!i.idBlock.isConstructed&&i.lenBlock.isIndefiniteForm)return i.error="Indefinite length form used for primitive encoding form",{offset:-1,result:i};let c=we;switch(i.idBlock.tagClass){case 1:if(i.idBlock.tagNumber>=37&&i.idBlock.isHexOnly===!1)return i.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:i};switch(i.idBlock.tagNumber){case 0:if(i.idBlock.isConstructed&&i.lenBlock.length>0)return i.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:i};c=S.EndOfContent;break;case 1:c=S.Boolean;break;case 2:c=S.Integer;break;case 3:c=S.BitString;break;case 4:c=S.OctetString;break;case 5:c=S.Null;break;case 6:c=S.ObjectIdentifier;break;case 10:c=S.Enumerated;break;case 12:c=S.Utf8String;break;case 13:c=S.RelativeObjectIdentifier;break;case 14:c=S.TIME;break;case 15:return i.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:i};case 16:c=S.Sequence;break;case 17:c=S.Set;break;case 18:c=S.NumericString;break;case 19:c=S.PrintableString;break;case 20:c=S.TeletexString;break;case 21:c=S.VideotexString;break;case 22:c=S.IA5String;break;case 23:c=S.UTCTime;break;case 24:c=S.GeneralizedTime;break;case 25:c=S.GraphicString;break;case 26:c=S.VisibleString;break;case 27:c=S.GeneralString;break;case 28:c=S.UniversalString;break;case 29:c=S.CharacterString;break;case 30:c=S.BmpString;break;case 31:c=S.DATE;break;case 32:c=S.TimeOfDay;break;case 33:c=S.DateTime;break;case 34:c=S.Duration;break;default:{let l=i.idBlock.isConstructed?new S.Constructed:new S.Primitive;l.idBlock=i.idBlock,l.lenBlock=i.lenBlock,l.warnings=i.warnings,i=l}}break;case 2:case 3:case 4:default:c=i.idBlock.isConstructed?S.Constructed:S.Primitive}return i=Da(i,c),a=i.fromBER(r,e,i.lenBlock.isIndefiniteForm?t:i.lenBlock.length),i.valueBeforeDecodeView=r.subarray(n,n+i.blockLength),{offset:a,result:i}}function xo(r){if(!r.byteLength){let e=new we({},Be);return e.error="Input buffer has zero length",{offset:-1,result:e}}return Y1(H.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function Ma(r,e){return r?1:e}var ot=class extends Be{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n){let i=H.BufferSourceConverter.toUint8Array(e);if(!St(this,i,t,n))return-1;if(this.valueBeforeDecodeView=i.subarray(t,t+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),t;let s=t;for(;Ma(this.isIndefiniteForm,n)>0;){let o=Y1(i,s,n);if(o.offset===-1)return this.error=o.result.error,this.warnings.concat(o.result.warnings),-1;if(s=o.offset,this.blockLength+=o.result.blockLength,n-=o.result.blockLength,this.value.push(o.result),this.isIndefiniteForm&&o.result.constructor.NAME===un)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===un?this.value.pop():this.warnings.push("No EndOfContent block encoded")),s}toBER(e,t){let n=t||new ln;for(let i=0;i<this.value.length;i++)this.value[i].toBER(e,n);return t?Xe:n.final()}toJSON(){let e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let t of this.value)e.value.push(t.toJSON());return e}};ot.NAME="ConstructedValueBlock";var O0,Kt=class extends we{constructor(e={}){super(e,ot),this.idBlock.isConstructed=!0}fromBER(e,t,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;let i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}onAsciiEncoding(){let e=[];for(let n of this.valueBlock.value)e.push(n.toString("ascii").split(`
2
+ "use strict";var Libp2PKadDht=(()=>{var H4=Object.create;var Un=Object.defineProperty;var q4=Object.getOwnPropertyDescriptor;var K4=Object.getOwnPropertyNames;var $4=Object.getPrototypeOf,z4=Object.prototype.hasOwnProperty;var Dn=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Te=(r,e)=>{for(var t in e)Un(r,t,{get:e[t],enumerable:!0})},d2=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of K4(e))!z4.call(r,i)&&i!==t&&Un(r,i,{get:()=>e[i],enumerable:!(n=q4(e,i))||n.enumerable});return r};var Mn=(r,e,t)=>(t=r!=null?H4($4(r)):{},d2(e||!r||!r.__esModule?Un(t,"default",{value:r,enumerable:!0}):t,r)),G4=r=>d2(Un({},"__esModule",{value:!0}),r);var R0=Dn(Tr=>{"use strict";var Ta="[object ArrayBuffer]",vt=class r{static isArrayBuffer(e){return Object.prototype.toString.call(e)===Ta}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),i=r.toUint8Array(t);if(n.length!==i.byteLength)return!1;for(let s=0;s<n.length;s++)if(n[s]!==i[s])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 o of t)n+=o.byteLength;let i=new Uint8Array(n),s=0;for(let o of t){let a=this.toUint8Array(o);i.set(a,s),s+=a.length}return e[e.length-1]instanceof Function?this.toView(i,e[e.length-1]):i.buffer}},mo="string",Ra=/^[0-9a-f]+$/i,Na=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,La=/^[a-zA-Z0-9-_]+$/,l1=class{static fromString(e){let t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);return n.buffer}static toString(e){let t=vt.toUint8Array(e),n="";for(let s=0;s<t.length;s++)n+=String.fromCharCode(t[s]);return decodeURIComponent(escape(n))}},$e=class{static toString(e,t=!1){let n=vt.toArrayBuffer(e),i=new DataView(n),s="";for(let o=0;o<n.byteLength;o+=2){let a=i.getUint16(o,t);s+=String.fromCharCode(a)}return s}static fromString(e,t=!1){let n=new ArrayBuffer(e.length*2),i=new DataView(n);for(let s=0;s<e.length;s++)i.setUint16(s*2,e.charCodeAt(s),t);return n}},u1=class r{static isHex(e){return typeof e===mo&&Ra.test(e)}static isBase64(e){return typeof e===mo&&Na.test(e)}static isBase64Url(e){return typeof e===mo&&La.test(e)}static ToString(e,t="utf8"){let n=vt.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 $e.toString(n,!0);case"utf16":case"utf16be":return $e.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 $e.fromString(e,!0);case"utf16":case"utf16be":return $e.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){let t=vt.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 l1.fromString(e);case"utf16":case"utf16be":return $e.fromString(e);case"utf16le":case"usc2":return $e.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 l1.toString(e);case"utf16":case"utf16be":return $e.toString(e);case"utf16le":case"usc2":return $e.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 i=0;i<t;i++)n[i]=e.charCodeAt(i);return n.buffer}static ToBinary(e){let t=vt.toUint8Array(e),n="";for(let i=0;i<t.length;i++)n+=String.fromCharCode(t[i]);return n}static ToHex(e){let t=vt.toUint8Array(e),n="",i=t.length;for(let s=0;s<i;s++){let o=t[s];o<16&&(n+="0"),n+=o.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 i=0;i<t.length;i=i+2){let s=t.slice(i,i+2);n[i/2]=parseInt(s,16)}return n.buffer}static ToUtf16String(e,t=!1){return $e.toString(e,t)}static FromUtf16String(e,t=!1){return $e.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,"")||""}};u1.DEFAULT_UTF8_ENCODING="utf8";function Pa(r,...e){let t=arguments[0];for(let n=1;n<arguments.length;n++){let i=arguments[n];for(let s in i)t[s]=i[s]}return t}function Ca(...r){let e=r.map(i=>i.byteLength).reduce((i,s)=>i+s),t=new Uint8Array(e),n=0;return r.map(i=>new Uint8Array(i)).forEach(i=>{for(let s of i)t[n++]=s}),t.buffer}function _a(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;let t=new Uint8Array(r),n=new Uint8Array(e);for(let i=0;i<r.byteLength;i++)if(t[i]!==n[i])return!1;return!0}Tr.BufferSourceConverter=vt;Tr.Convert=u1;Tr.assign=Pa;Tr.combine=Ca;Tr.isEqual=_a});var K3=Dn(An=>{(function(){var r,e,t,n,i,s,o,a;a=function(c){var l,u,f,h;return l=(c&255<<24)>>>24,u=(c&255<<16)>>>16,f=(c&65280)>>>8,h=c&255,[l,u,f,h].join(".")},o=function(c){var l,u,f,h,g,y;for(l=[],f=h=0;h<=3&&c.length!==0;f=++h){if(f>0){if(c[0]!==".")throw new Error("Invalid IP");c=c.substring(1)}y=e(c),g=y[0],u=y[1],c=c.substring(u),l.push(g)}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"),s=t("a"),i=t("A"),e=function(c){var l,u,f,h,g;for(h=0,l=10,u="9",f=0,c.length>1&&c[f]==="0"&&(c[f+1]==="x"||c[f+1]==="X"?(f+=2,l=16):"0"<=c[f+1]&&c[f+1]<="9"&&(f++,l=8,u="7")),g=f;f<c.length;){if("0"<=c[f]&&c[f]<=u)h=h*l+(t(c[f])-n)>>>0;else if(l===16)if("a"<=c[f]&&c[f]<="f")h=h*l+(10+t(c[f])-s)>>>0;else if("A"<=c[f]&&c[f]<="F")h=h*l+(10+t(c[f])-i)>>>0;else break;else break;if(h>4294967295)throw new Error("too large");f++}if(f===g)throw new Error("empty octet");return[h,f]},r=function(){function c(l,u){var f,h,g,y;if(typeof l!="string")throw new Error("Missing `net' parameter");if(u||(y=l.split("/",2),l=y[0],u=y[1]),u||(u=32),typeof u=="string"&&u.indexOf(".")>-1){try{this.maskLong=o(u)}catch(p){throw f=p,new Error("Invalid mask: "+u)}for(h=g=32;g>=0;h=--g)if(this.maskLong===4294967295<<32-h>>>0){this.bitmask=h;break}}else if(u||u===0)this.bitmask=parseInt(u,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(o(l)&this.maskLong)>>>0}catch(p){throw f=p,new Error("Invalid net address: "+l)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+u);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):(o(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 u,f,h;for(h=o(this.first),f=o(this.last),u=0;h<=f;)l(a(h),h,u),u++,h++},c.prototype.toString=function(){return this.base+"/"+this.bitmask},c}(),An.ip2long=o,An.long2ip=a,An.Netmask=r}).call(An)});var w4=Dn((dg,b4)=>{b4.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 i(s,o){t[s]=o,e++,e>=r&&(e=0,n=t,t=Object.create(null))}return{has:function(s){return t[s]!==void 0||n[s]!==void 0},remove:function(s){t[s]!==void 0&&(t[s]=void 0),n[s]!==void 0&&(n[s]=void 0)},get:function(s){var o=t[s];if(o!==void 0)return o;if((o=n[s])!==void 0)return i(s,o),o},set:function(s,o){t[s]!==void 0?t[s]=o:i(s,o)},clear:function(){t=Object.create(null),n=Object.create(null)}}}});var v4=Dn((pg,Yo)=>{"use strict";var K8=Object.prototype.hasOwnProperty,Ne="~";function In(){}Object.create&&(In.prototype=Object.create(null),new In().__proto__||(Ne=!1));function $8(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function x4(r,e,t,n,i){if(typeof t!="function")throw new TypeError("The listener must be a function");var s=new $8(t,n||r,i),o=Ne?Ne+e:e;return r._events[o]?r._events[o].fn?r._events[o]=[r._events[o],s]:r._events[o].push(s):(r._events[o]=s,r._eventsCount++),r}function Ii(r,e){--r._eventsCount===0?r._events=new In:delete r._events[e]}function Ie(){this._events=new In,this._eventsCount=0}Ie.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)K8.call(t,n)&&e.push(Ne?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};Ie.prototype.listeners=function(e){var t=Ne?Ne+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,s=n.length,o=new Array(s);i<s;i++)o[i]=n[i].fn;return o};Ie.prototype.listenerCount=function(e){var t=Ne?Ne+e:e,n=this._events[t];return n?n.fn?1:n.length:0};Ie.prototype.emit=function(e,t,n,i,s,o){var a=Ne?Ne+e:e;if(!this._events[a])return!1;var c=this._events[a],l=arguments.length,u,f;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,i),!0;case 5:return c.fn.call(c.context,t,n,i,s),!0;case 6:return c.fn.call(c.context,t,n,i,s,o),!0}for(f=1,u=new Array(l-1);f<l;f++)u[f-1]=arguments[f];c.fn.apply(c.context,u)}else{var h=c.length,g;for(f=0;f<h;f++)switch(c[f].once&&this.removeListener(e,c[f].fn,void 0,!0),l){case 1:c[f].fn.call(c[f].context);break;case 2:c[f].fn.call(c[f].context,t);break;case 3:c[f].fn.call(c[f].context,t,n);break;case 4:c[f].fn.call(c[f].context,t,n,i);break;default:if(!u)for(g=1,u=new Array(l-1);g<l;g++)u[g-1]=arguments[g];c[f].fn.apply(c[f].context,u)}}return!0};Ie.prototype.on=function(e,t,n){return x4(this,e,t,n,!1)};Ie.prototype.once=function(e,t,n){return x4(this,e,t,n,!0)};Ie.prototype.removeListener=function(e,t,n,i){var s=Ne?Ne+e:e;if(!this._events[s])return this;if(!t)return Ii(this,s),this;var o=this._events[s];if(o.fn)o.fn===t&&(!i||o.once)&&(!n||o.context===n)&&Ii(this,s);else{for(var a=0,c=[],l=o.length;a<l;a++)(o[a].fn!==t||i&&!o[a].once||n&&o[a].context!==n)&&c.push(o[a]);c.length?this._events[s]=c.length===1?c[0]:c:Ii(this,s)}return this};Ie.prototype.removeAllListeners=function(e){var t;return e?(t=Ne?Ne+e:e,this._events[t]&&Ii(this,t)):(this._events=new In,this._eventsCount=0),this};Ie.prototype.off=Ie.prototype.removeListener;Ie.prototype.addListener=Ie.prototype.on;Ie.prefixed=Ne;Ie.EventEmitter=Ie;typeof Yo<"u"&&(Yo.exports=Ie)});var g7={};Te(g7,{EventTypes:()=>s2,MessageType:()=>M,Record:()=>le,kadDHT:()=>p7,passthroughMapper:()=>j3,removePrivateAddressesMapper:()=>hi,removePublicAddressesMapper:()=>G3});var p2=Symbol.for("@libp2p/content-routing");var g2=Symbol.for("@libp2p/peer-discovery");var ts=Symbol.for("@libp2p/peer-id");var m2=Symbol.for("@libp2p/peer-routing");var ft=class extends Error{static name="AbortError";constructor(e="The operation was aborted"){super(e),this.name="AbortError"}};var $=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}},ht=class extends Error{static name="InvalidPublicKeyError";constructor(e="Invalid public key"){super(e),this.name="InvalidPublicKeyError"}};var Ge=class extends Error{static name="NotFoundError";constructor(e="Not found"){super(e),this.name="NotFoundError"}};var On=class extends Error{static name="InvalidMultihashError";constructor(e="Invalid Multihash"){super(e),this.name="InvalidMultihashError"}};var ve=class extends Error{static name="InvalidMessageError";constructor(e="Invalid message"){super(e),this.name="InvalidMessageError"}};var Zt=class extends Error{static name="UnsupportedKeyTypeError";constructor(e="Unsupported key type"){super(e),this.name="UnsupportedKeyTypeError"}};var ye=(r,...e)=>{try{[...e]}catch{}};var Pe=class extends EventTarget{#e=new Map;constructor(){super(),ye(1/0,this)}listenerCount(e){let t=this.#e.get(e);return t==null?0:t.length}addEventListener(e,t,n){super.addEventListener(e,t,n);let i=this.#e.get(e);i==null&&(i=[],this.#e.set(e,i)),i.push({callback:t,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(e,t,n){super.removeEventListener(e.toString(),t??null,n);let i=this.#e.get(e);i!=null&&(i=i.filter(({callback:s})=>s!==t),this.#e.set(e,i))}dispatchEvent(e){let t=super.dispatchEvent(e),n=this.#e.get(e.type);return n==null||(n=n.filter(({once:i})=>!i),this.#e.set(e.type,n)),t}safeDispatchEvent(e,t={}){return this.dispatchEvent(new CustomEvent(e,t))}};function y2(r){return r!=null&&typeof r.start=="function"&&typeof r.stop=="function"}async function b2(...r){let e=[];for(let t of r)y2(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 w2(...r){let e=[];for(let t of r)y2(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 x2=Symbol.for("@libp2p/service-capabilities"),v2=Symbol.for("@libp2p/service-dependencies");function j4(r){return r[Symbol.asyncIterator]!=null}function Z4(r){if(j4(r))return(async()=>{for await(let e of r);})();for(let e of r);}var rs=Z4;function ie(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}var E2="/ipfs/kad/1.0.0",A2="/dht/record",ns="/dht/provider";function Ce(r=0){return new Uint8Array(r)}function pe(r=0){return new Uint8Array(r)}var W4=Math.pow(2,7),Q4=Math.pow(2,14),Y4=Math.pow(2,21),is=Math.pow(2,28),ss=Math.pow(2,35),os=Math.pow(2,42),as=Math.pow(2,49),z=128,Ee=127;function se(r){if(r<W4)return 1;if(r<Q4)return 2;if(r<Y4)return 3;if(r<is)return 4;if(r<ss)return 5;if(r<os)return 6;if(r<as)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function cs(r,e,t=0){switch(se(r)){case 8:e[t++]=r&255|z,r/=128;case 7:e[t++]=r&255|z,r/=128;case 6:e[t++]=r&255|z,r/=128;case 5:e[t++]=r&255|z,r/=128;case 4:e[t++]=r&255|z,r>>>=7;case 3:e[t++]=r&255|z,r>>>=7;case 2:e[t++]=r&255|z,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function X4(r,e,t=0){switch(se(r)){case 8:e.set(t++,r&255|z),r/=128;case 7:e.set(t++,r&255|z),r/=128;case 6:e.set(t++,r&255|z),r/=128;case 5:e.set(t++,r&255|z),r/=128;case 4:e.set(t++,r&255|z),r>>>=7;case 3:e.set(t++,r&255|z),r>>>=7;case 2:e.set(t++,r&255|z),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function ls(r,e){let t=r[e],n=0;if(n+=t&Ee,t<z||(t=r[e+1],n+=(t&Ee)<<7,t<z)||(t=r[e+2],n+=(t&Ee)<<14,t<z)||(t=r[e+3],n+=(t&Ee)<<21,t<z)||(t=r[e+4],n+=(t&Ee)*is,t<z)||(t=r[e+5],n+=(t&Ee)*ss,t<z)||(t=r[e+6],n+=(t&Ee)*os,t<z)||(t=r[e+7],n+=(t&Ee)*as,t<z))return n;throw new RangeError("Could not decode varint")}function J4(r,e){let t=r.get(e),n=0;if(n+=t&Ee,t<z||(t=r.get(e+1),n+=(t&Ee)<<7,t<z)||(t=r.get(e+2),n+=(t&Ee)<<14,t<z)||(t=r.get(e+3),n+=(t&Ee)<<21,t<z)||(t=r.get(e+4),n+=(t&Ee)*is,t<z)||(t=r.get(e+5),n+=(t&Ee)*ss,t<z)||(t=r.get(e+6),n+=(t&Ee)*os,t<z)||(t=r.get(e+7),n+=(t&Ee)*as,t<z))return n;throw new RangeError("Could not decode varint")}function He(r,e,t=0){return e==null&&(e=pe(se(r))),e instanceof Uint8Array?cs(r,e,t):X4(r,e,t)}function Me(r,e=0){return r instanceof Uint8Array?ls(r,e):J4(r,e)}var us=new Float32Array([-0]),Nt=new Uint8Array(us.buffer);function B2(r,e,t){us[0]=r,e[t]=Nt[0],e[t+1]=Nt[1],e[t+2]=Nt[2],e[t+3]=Nt[3]}function S2(r,e){return Nt[0]=r[e],Nt[1]=r[e+1],Nt[2]=r[e+2],Nt[3]=r[e+3],us[0]}var fs=new Float64Array([-0]),Ae=new Uint8Array(fs.buffer);function I2(r,e,t){fs[0]=r,e[t]=Ae[0],e[t+1]=Ae[1],e[t+2]=Ae[2],e[t+3]=Ae[3],e[t+4]=Ae[4],e[t+5]=Ae[5],e[t+6]=Ae[6],e[t+7]=Ae[7]}function k2(r,e){return Ae[0]=r[e],Ae[1]=r[e+1],Ae[2]=r[e+2],Ae[3]=r[e+3],Ae[4]=r[e+4],Ae[5]=r[e+5],Ae[6]=r[e+6],Ae[7]=r[e+7],fs[0]}var e5=BigInt(Number.MAX_SAFE_INTEGER),t5=BigInt(Number.MIN_SAFE_INTEGER),Oe=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 Wt;if(e<e5&&e>t5)return this.fromNumber(Number(e));let t=e<0n;t&&(e=-e);let n=e>>32n,i=e-(n<<32n);return t&&(n=~n|0n,i=~i|0n,++i>T2&&(i=0n,++n>T2&&(n=0n))),new r(Number(i),Number(n))}static fromNumber(e){if(e===0)return Wt;let t=e<0;t&&(e=-e);let n=e>>>0,i=(e-n)/4294967296>>>0;return t&&(i=~i>>>0,n=~n>>>0,++n>4294967295&&(n=0,++i>4294967295&&(i=0))),new r(n,i)}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):Wt}},Wt=new Oe(0,0);Wt.toBigInt=function(){return 0n};Wt.zzEncode=Wt.zzDecode=function(){return this};Wt.length=function(){return 1};var T2=4294967296n;function R2(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 N2(r,e,t){if(t-e<1)return"";let i,s=[],o=0,a;for(;e<t;)a=r[e++],a<128?s[o++]=a:a>191&&a<224?s[o++]=(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,s[o++]=55296+(a>>10),s[o++]=56320+(a&1023)):s[o++]=(a&15)<<12|(r[e++]&63)<<6|r[e++]&63,o>8191&&((i??(i=[])).push(String.fromCharCode.apply(String,s)),o=0);return i!=null?(o>0&&i.push(String.fromCharCode.apply(String,s.slice(0,o))),i.join("")):String.fromCharCode.apply(String,s.slice(0,o))}function hs(r,e,t){let n=t,i,s;for(let o=0;o<r.length;++o)i=r.charCodeAt(o),i<128?e[t++]=i:i<2048?(e[t++]=i>>6|192,e[t++]=i&63|128):(i&64512)===55296&&((s=r.charCodeAt(o+1))&64512)===56320?(i=65536+((i&1023)<<10)+(s&1023),++o,e[t++]=i>>18|240,e[t++]=i>>12&63|128,e[t++]=i>>6&63|128,e[t++]=i&63|128):(e[t++]=i>>12|224,e[t++]=i>>6&63|128,e[t++]=i&63|128);return t-n}function je(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function Vn(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}var ds=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,je(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 je(this,4);return Vn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw je(this,4);return Vn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw je(this,4);let e=S2(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw je(this,4);let e=k2(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 je(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return N2(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw je(this,e);this.pos+=e}else do if(this.pos>=this.len)throw je(this);while(this.buf[this.pos++]&128);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 Oe(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 je(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 je(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 je(this,8);let e=Vn(this.buf,this.pos+=4),t=Vn(this.buf,this.pos+=4);return new Oe(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=ls(this.buf,this.pos);return this.pos+=se(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 ps(r){return new ds(r instanceof Uint8Array?r:r.subarray())}function tt(r,e,t){let n=ps(r);return e.decode(n,void 0,t)}var ws={};Te(ws,{base10:()=>a5});var c9=new Uint8Array(0);function P2(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 dt(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 C2(r){return new TextEncoder().encode(r)}function _2(r){return new TextDecoder().decode(r)}function r5(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 i=0;i<r.length;i++){var s=r.charAt(i),o=s.charCodeAt(0);if(t[o]!==255)throw new TypeError(s+" is ambiguous");t[o]=i}var a=r.length,c=r.charAt(0),l=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function f(y){if(y instanceof Uint8Array||(ArrayBuffer.isView(y)?y=new Uint8Array(y.buffer,y.byteOffset,y.byteLength):Array.isArray(y)&&(y=Uint8Array.from(y))),!(y instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(y.length===0)return"";for(var p=0,d=0,w=0,v=y.length;w!==v&&y[w]===0;)w++,p++;for(var m=(v-w)*u+1>>>0,A=new Uint8Array(m);w!==v;){for(var R=y[w],T=0,I=m-1;(R!==0||T<d)&&I!==-1;I--,T++)R+=256*A[I]>>>0,A[I]=R%a>>>0,R=R/a>>>0;if(R!==0)throw new Error("Non-zero carry");d=T,w++}for(var k=m-d;k!==m&&A[k]===0;)k++;for(var P=c.repeat(p);k<m;++k)P+=r.charAt(A[k]);return P}function h(y){if(typeof y!="string")throw new TypeError("Expected String");if(y.length===0)return new Uint8Array;var p=0;if(y[p]!==" "){for(var d=0,w=0;y[p]===c;)d++,p++;for(var v=(y.length-p)*l+1>>>0,m=new Uint8Array(v);y[p];){var A=t[y.charCodeAt(p)];if(A===255)return;for(var R=0,T=v-1;(A!==0||R<w)&&T!==-1;T--,R++)A+=a*m[T]>>>0,m[T]=A%256>>>0,A=A/256>>>0;if(A!==0)throw new Error("Non-zero carry");w=R,p++}if(y[p]!==" "){for(var I=v-w;I!==v&&m[I]===0;)I++;for(var k=new Uint8Array(d+(v-I)),P=d;I!==v;)k[P++]=m[I++];return k}}}function g(y){var p=h(y);if(p)return p;throw new Error(`Non-${e} character`)}return{encode:f,decodeUnsafe:h,decode:g}}var n5=r5,i5=n5,D2=i5;var gs=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")}},ms=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){this.name=e,this.prefix=t;let i=t.codePointAt(0);if(i===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=i,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 M2(this,e)}},ys=class{decoders;constructor(e){this.decoders=e}or(e){return M2(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 M2(r,e){return new ys({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var bs=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,i){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=i,this.encoder=new gs(e,t,n),this.decoder=new ms(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function cr({name:r,prefix:e,encode:t,decode:n}){return new bs(r,e,t,n)}function Lt({name:r,prefix:e,alphabet:t}){let{encode:n,decode:i}=D2(t,r);return cr({prefix:e,name:r,encode:n,decode:s=>dt(i(s))})}function s5(r,e,t,n){let i={};for(let u=0;u<e.length;++u)i[e[u]]=u;let s=r.length;for(;r[s-1]==="=";)--s;let o=new Uint8Array(s*t/8|0),a=0,c=0,l=0;for(let u=0;u<s;++u){let f=i[r[u]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<t|f,a+=t,a>=8&&(a-=8,o[l++]=255&c>>a)}if(a>=t||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o}function o5(r,e,t){let n=e[e.length-1]==="=",i=(1<<t)-1,s="",o=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],o+=8;o>t;)o-=t,s+=e[i&a>>o];if(o!==0&&(s+=e[i&a<<t-o]),n)for(;s.length*t&7;)s+="=";return s}function te({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return cr({prefix:e,name:r,encode(i){return o5(i,n,t)},decode(i){return s5(i,n,t,r)}})}var a5=Lt({prefix:"9",name:"base10",alphabet:"0123456789"});var xs={};Te(xs,{base16:()=>c5,base16upper:()=>l5});var c5=te({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),l5=te({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var vs={};Te(vs,{base2:()=>u5});var u5=te({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Es={};Te(Es,{base256emoji:()=>g5});var O2=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}"),f5=O2.reduce((r,e,t)=>(r[t]=e,r),[]),h5=O2.reduce((r,e,t)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return r[n]=t,r},[]);function d5(r){return r.reduce((e,t)=>(e+=f5[t],e),"")}function p5(r){let e=[];for(let t of r){let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);let i=h5[n];if(i==null)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}var g5=cr({prefix:"\u{1F680}",name:"base256emoji",encode:d5,decode:p5});var As={};Te(As,{base32:()=>pt,base32hex:()=>w5,base32hexpad:()=>v5,base32hexpadupper:()=>E5,base32hexupper:()=>x5,base32pad:()=>y5,base32padupper:()=>b5,base32upper:()=>m5,base32z:()=>A5});var pt=te({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),m5=te({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),y5=te({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),b5=te({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),w5=te({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),x5=te({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),v5=te({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),E5=te({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),A5=te({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Bs={};Te(Bs,{base36:()=>Gr,base36upper:()=>B5});var Gr=Lt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),B5=Lt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ss={};Te(Ss,{base58btc:()=>Q,base58flickr:()=>S5});var Q=Lt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),S5=Lt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Is={};Te(Is,{base64:()=>I5,base64pad:()=>k5,base64url:()=>T5,base64urlpad:()=>R5});var I5=te({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),k5=te({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),T5=te({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),R5=te({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var ks={};Te(ks,{base8:()=>N5});var N5=te({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Ts={};Te(Ts,{identity:()=>L5});var L5=cr({prefix:"\0",name:"identity",encode:r=>_2(r),decode:r=>C2(r)});var B9=new TextEncoder,S9=new TextDecoder;var Ns={};Te(Ns,{identity:()=>gt});var _5=H2,V2=128,U5=127,D5=~U5,M5=Math.pow(2,31);function H2(r,e,t){e=e||[],t=t||0;for(var n=t;r>=M5;)e[t++]=r&255|V2,r/=128;for(;r&D5;)e[t++]=r&255|V2,r>>>=7;return e[t]=r|0,H2.bytes=t-n+1,e}var O5=Rs,V5=128,F2=127;function Rs(r,n){var t=0,n=n||0,i=0,s=n,o,a=r.length;do{if(s>=a)throw Rs.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=i<28?(o&F2)<<i:(o&F2)*Math.pow(2,i),i+=7}while(o>=V5);return Rs.bytes=s-n,t}var F5=Math.pow(2,7),H5=Math.pow(2,14),q5=Math.pow(2,21),K5=Math.pow(2,28),$5=Math.pow(2,35),z5=Math.pow(2,42),G5=Math.pow(2,49),j5=Math.pow(2,56),Z5=Math.pow(2,63),W5=function(r){return r<F5?1:r<H5?2:r<q5?3:r<K5?4:r<$5?5:r<z5?6:r<G5?7:r<j5?8:r<Z5?9:10},Q5={encode:_5,decode:O5,encodingLength:W5},Y5=Q5,jr=Y5;function Zr(r,e=0){return[jr.decode(r,e),jr.decode.bytes]}function lr(r,e,t=0){return jr.encode(r,e,t),e}function ur(r){return jr.encodingLength(r)}function Ze(r,e){let t=e.byteLength,n=ur(r),i=n+ur(t),s=new Uint8Array(i+t);return lr(r,s,0),lr(t,s,n),s.set(e,i),new fr(r,t,e,s)}function be(r){let e=dt(r),[t,n]=Zr(e),[i,s]=Zr(e.subarray(n)),o=e.subarray(n+s);if(o.byteLength!==i)throw new Error("Incorrect length");return new fr(t,i,o,e)}function q2(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&P2(r.bytes,t.bytes)}}var fr=class{code;size;digest;bytes;constructor(e,t,n,i){this.code=e,this.size=t,this.digest=n,this.bytes=i}};var K2=0,X5="identity",$2=dt;function J5(r){return Ze(K2,$2(r))}var gt={code:K2,name:X5,encode:$2,digest:J5};var Cs={};Te(Cs,{sha256:()=>mt,sha512:()=>e6});function Ps({name:r,code:e,encode:t}){return new Ls(r,e,t)}var Ls=class{name;code;encode;constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?Ze(this.code,t):t.then(n=>Ze(this.code,n))}else throw Error("Unknown type, must be binary type")}};function G2(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var mt=Ps({name:"sha2-256",code:18,encode:G2("SHA-256")}),e6=Ps({name:"sha2-512",code:19,encode:G2("SHA-512")});function j2(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return r6(t,_s(r),e??Q.encoder);default:return n6(t,_s(r),e??pt.encoder)}}var Z2=new WeakMap;function _s(r){let e=Z2.get(r);if(e==null){let t=new Map;return Z2.set(r,t),t}return e}var ne=class r{code;version;multihash;bytes;"/";constructor(e,t,n,i){this.code=t,this.version=e,this.multihash=n,this.bytes=i,this["/"]=i}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!==Wr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==i6)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=Ze(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&&q2(e.multihash,n.multihash)}toString(e){return j2(this,e)}toJSON(){return{"/":j2(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:i,multihash:s,bytes:o}=t;return new r(n,i,s,o??W2(n,i,s.bytes))}else if(t[s6]===!0){let{version:n,multihash:i,code:s}=t,o=be(i);return r.create(n,s,o)}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!==Wr)throw new Error(`Version 0 CID must use dag-pb (code: ${Wr}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let i=W2(e,t,n.bytes);return new r(e,t,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,Wr,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,i=dt(e.subarray(n,n+t.multihashSize));if(i.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=i.subarray(t.multihashSize-t.digestSize),o=new fr(t.multihashCode,t.digestSize,s,i);return[t.version===0?r.createV0(o):r.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[f,h]=Zr(e.subarray(t));return t+=h,f},i=n(),s=Wr;if(i===18?(i=0,t=0):s=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let o=t,a=n(),c=n(),l=t+c,u=l-o;return{version:i,codec:s,multihashCode:a,digestSize:c,multihashSize:u,size:l}}static parse(e,t){let[n,i]=t6(e,t),s=r.decode(i);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return _s(s).set(n,e),s}};function t6(r,e){switch(r[0]){case"Q":{let t=e??Q;return[Q.prefix,t.decode(`${Q.prefix}${r}`)]}case Q.prefix:{let t=e??Q;return[Q.prefix,t.decode(r)]}case pt.prefix:{let t=e??pt;return[pt.prefix,t.decode(r)]}case Gr.prefix:{let t=e??Gr;return[Gr.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 r6(r,e,t){let{prefix:n}=t;if(n!==Q.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let i=e.get(n);if(i==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return i}function n6(r,e,t){let{prefix:n}=t,i=e.get(n);if(i==null){let s=t.encode(r);return e.set(n,s),s}else return i}var Wr=112,i6=18;function W2(r,e,t){let n=ur(r),i=n+ur(e),s=new Uint8Array(i+t.byteLength);return lr(r,s,0),lr(e,s,n),s.set(t,i),s}var s6=Symbol.for("@ipld/js-cid/CID");var Qr={...Ts,...vs,...ks,...ws,...xs,...As,...Bs,...Ss,...Is,...Es},j9={...Cs,...Ns};function Y2(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var Q2=Y2("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Us=Y2("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=pe(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),o6={utf8:Q2,"utf-8":Q2,hex:Qr.base16,latin1:Us,ascii:Us,binary:Us,...Qr},Hn=o6;function Y(r,e="utf8"){let t=Hn[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${r}`)}function Ds(r){let e=r??8192,t=e>>>1,n,i=e;return function(o){if(o<1||o>t)return pe(o);i+o>e&&(n=pe(e),i=0);let a=n.subarray(i,i+=o);return i&7&&(i=(i|7)+1),a}}var Qt=class{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}};function Ms(){}var Vs=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},a6=Ds();function c6(r){return globalThis.Buffer!=null?pe(r):a6(r)}var Xr=class{len;head;tail;states;constructor(){this.len=0,this.head=new Qt(Ms,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new Qt(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new Fs((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(qn,10,Oe.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=Oe.fromBigInt(e);return this._push(qn,t.length(),t)}uint64Number(e){return this._push(cs,se(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=Oe.fromBigInt(e).zzEncode();return this._push(qn,t.length(),t)}sint64Number(e){let t=Oe.fromNumber(e).zzEncode();return this._push(qn,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Os,1,e?1:0)}fixed32(e){return this._push(Yr,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=Oe.fromBigInt(e);return this._push(Yr,4,t.lo)._push(Yr,4,t.hi)}fixed64Number(e){let t=Oe.fromNumber(e);return this._push(Yr,4,t.lo)._push(Yr,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(B2,4,e)}double(e){return this._push(I2,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(Os,1,0):this.uint32(t)._push(u6,t,e)}string(e){let t=R2(e);return t!==0?this.uint32(t)._push(hs,t,e):this._push(Os,1,0)}fork(){return this.states=new Vs(this),this.head=this.tail=new Qt(Ms,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 Qt(Ms,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=c6(this.len),n=0;for(;e!=null;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}};function Os(r,e,t){e[t]=r&255}function l6(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var Fs=class extends Qt{next;constructor(e,t){super(l6,e,t),this.next=void 0}};function qn(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 Yr(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 u6(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(Xr.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(f6,e,r),this},Xr.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(h6,e,r),this});function f6(r,e,t){e.set(r,t)}function h6(r,e,t){r.length<40?hs(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(Y(r),t)}function Hs(){return new Xr}function rt(r,e){let t=Hs();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var hr;(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"})(hr||(hr={}));function Kn(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function dr(r){function e(i){if(r[i.toString()]==null)throw new Error("Invalid enum value");return r[i]}let t=function(s,o){let a=e(s);o.int32(a)},n=function(s){let o=s.int32();return e(o)};return Kn("enum",hr.VARINT,t,n)}function nt(r,e){return Kn("message",hr.LENGTH_DELIMITED,r,e)}var pr=class extends Error{code="ERR_MAX_LENGTH";name="MaxLengthError"};var Jr;(function(r){let e;r.codec=()=>(e==null&&(e=nt((t,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),t.key!=null&&t.key.byteLength>0&&(n.uint32(10),n.bytes(t.key)),t.value!=null&&t.value.byteLength>0&&(n.uint32(18),n.bytes(t.value)),t.timeReceived!=null&&t.timeReceived!==""&&(n.uint32(42),n.string(t.timeReceived)),i.lengthDelimited!==!1&&n.ldelim()},(t,n,i={})=>{let s={key:Ce(0),value:Ce(0),timeReceived:""},o=n==null?t.len:t.pos+n;for(;t.pos<o;){let a=t.uint32();switch(a>>>3){case 1:{s.key=t.bytes();break}case 2:{s.value=t.bytes();break}case 5:{s.timeReceived=t.string();break}default:{t.skipType(a&7);break}}}return s})),e),r.encode=t=>rt(t,r.codec()),r.decode=(t,n)=>tt(t,r.codec(),n)})(Jr||(Jr={}));function X2(r){let e=r.getUTCFullYear(),t=String(r.getUTCMonth()+1).padStart(2,"0"),n=String(r.getUTCDate()).padStart(2,"0"),i=String(r.getUTCHours()).padStart(2,"0"),s=String(r.getUTCMinutes()).padStart(2,"0"),o=String(r.getUTCSeconds()).padStart(2,"0"),a=r.getUTCMilliseconds(),c=String(a*1e3*1e3).padStart(9,"0");return`${e}-${t}-${n}T${i}:${s}:${o}.${c}Z`}function J2(r){let e=new RegExp("(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})\\.(\\d+)Z"),t=String(r).trim().match(e);if(t==null)throw new Error("Invalid format");let n=parseInt(t[1],10),i=parseInt(t[2],10)-1,s=parseInt(t[3],10),o=parseInt(t[4],10),a=parseInt(t[5],10),c=parseInt(t[6],10),l=parseInt(t[7].slice(0,-6),10);return new Date(Date.UTC(n,i,s,o,a,c,l))}var le=class r{key;value;timeReceived;constructor(e,t,n){if(!(e instanceof Uint8Array))throw new Error("key must be a Uint8Array");if(!(t instanceof Uint8Array))throw new Error("value must be a Uint8Array");this.key=e,this.value=t,this.timeReceived=n}serialize(){return Jr.encode(this.prepareSerialize())}prepareSerialize(){return{key:this.key,value:this.value,timeReceived:X2(this.timeReceived)}}static deserialize(e){let t=Jr.decode(e);return new r(t.key,t.value,new Date(t.timeReceived))}static fromDeserialized(e){let t=J2(e.timeReceived);if(e.key==null)throw new Error("key missing from deserialized object");if(e.value==null)throw new Error("value missing from deserialized object");return new r(e.key,e.value,t)}};function p6(r){let[e,t]=r[Symbol.asyncIterator]!=null?[r[Symbol.asyncIterator](),Symbol.asyncIterator]:[r[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>e.next(),push:i=>{n.push(i)},next:()=>n.length>0?{done:!1,value:n.shift()}:e.next(),[t](){return this}}}var e0=p6;function g6(r){return r[Symbol.asyncIterator]!=null}function m6(r,e){let t=0;if(g6(r))return async function*(){for await(let c of r)yield e(c,t++)}();let n=e0(r),{value:i,done:s}=n.next();if(s===!0)return function*(){}();let o=e(i,t++);if(typeof o.then=="function")return async function*(){yield await o;for await(let c of n)yield e(c,t++)}();let a=e;return function*(){yield o;for(let c of n)yield a(c,t++)}()}var gr=m6;var $n=globalThis.CustomEvent??Event;async function*en(r,e={}){let t=e.concurrency??1/0;t<1&&(t=1/0);let n=e.ordered==null?!1:e.ordered,i=new EventTarget,s=[],o=ie(),a=ie(),c=!1,l,u=!1;i.addEventListener("task-complete",()=>{a.resolve()}),Promise.resolve().then(async()=>{try{for await(let y of r){if(s.length===t&&(o=ie(),await o.promise),u)break;let p={done:!1};s.push(p),y().then(d=>{p.done=!0,p.ok=!0,p.value=d,i.dispatchEvent(new $n("task-complete"))},d=>{p.done=!0,p.err=d,i.dispatchEvent(new $n("task-complete"))})}c=!0,i.dispatchEvent(new $n("task-complete"))}catch(y){l=y,i.dispatchEvent(new $n("task-complete"))}});function f(){return n?s[0]?.done:!!s.find(y=>y.done)}function*h(){for(;s.length>0&&s[0].done;){let y=s[0];if(s.shift(),y.ok)yield y.value;else throw u=!0,o.resolve(),y.err;o.resolve()}}function*g(){for(;f();)for(let y=0;y<s.length;y++)if(s[y].done){let p=s[y];if(s.splice(y,1),y--,p.ok)yield p.value;else throw u=!0,o.resolve(),p.err;o.resolve()}}for(;;){if(f()||(a=ie(),await a.promise),l!=null)throw l;if(n?yield*h():yield*g(),c&&s.length===0)break}}var zn=class{buffer;mask;top;btm;next;constructor(e){if(!(e>0)||e-1&e)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}},mr=class{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new zn(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 zn(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 qs=class extends Error{type;code;constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.code=t??"ABORT_ERR"}};function yr(r={}){return y6(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 y6(r,e){e=e??{};let t=e.onEnd,n=new mr,i,s,o,a=ie(),c=async()=>{try{return n.isEmpty()?o?{done:!0}:await new Promise((d,w)=>{s=v=>{s=null,n.push(v);try{d(r(n))}catch(m){w(m)}return i}}):r(n)}finally{n.isEmpty()&&queueMicrotask(()=>{a.resolve(),a=ie()})}},l=d=>s!=null?s(d):(n.push(d),i),u=d=>(n=new mr,s!=null?s({error:d}):(n.push({error:d}),i)),f=d=>{if(o)return i;if(e?.objectMode!==!0&&d?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return l({done:!1,value:d})},h=d=>o?i:(o=!0,d!=null?u(d):l({done:!0})),g=()=>(n=new mr,h(),{done:!0}),y=d=>(h(d),{done:!0});if(i={[Symbol.asyncIterator](){return this},next:c,return:g,throw:y,push:f,end:h,get readableLength(){return n.size},onEmpty:async d=>{let w=d?.signal;if(w?.throwIfAborted(),n.isEmpty())return;let v,m;w!=null&&(v=new Promise((A,R)=>{m=()=>{R(new qs)},w.addEventListener("abort",m)}));try{await Promise.race([a.promise,v])}finally{m!=null&&w!=null&&w?.removeEventListener("abort",m)}}},t==null)return i;let p=i;return i={[Symbol.asyncIterator](){return this},next(){return p.next()},throw(d){return p.throw(d),t!=null&&(t(d),t=void 0),{done:!0}},return(){return p.return(),t!=null&&(t(),t=void 0),{done:!0}},push:f,end(d){return p.end(d),t!=null&&(t(d),t=void 0),i},get readableLength(){return p.readableLength},onEmpty:d=>p.onEmpty(d)},i}function b6(r){return r[Symbol.asyncIterator]!=null}function w6(...r){let e=[];for(let t of r)b6(t)||e.push(t);return e.length===r.length?function*(){for(let t of e)yield*t}():async function*(){let t=yr({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(r.map(async n=>{for await(let i of n)t.push(i)})),t.end()}catch(n){t.end(n)}}),yield*t}()}var Gn=w6;function Pt(r,...e){if(r==null)throw new Error("Empty pipeline");if(Ks(r)){let n=r;r=()=>n.source}else if(r0(r)||t0(r)){let n=r;r=()=>n}let t=[r,...e];if(t.length>1&&Ks(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++)Ks(t[n])&&(t[n]=v6(t[n]));return x6(...t)}var x6=(...r)=>{let e;for(;r.length>0;)e=r.shift()(e);return e},t0=r=>r?.[Symbol.asyncIterator]!=null,r0=r=>r?.[Symbol.iterator]!=null,Ks=r=>r==null?!1:r.sink!=null&&r.source!=null,v6=r=>e=>{let t=r.sink(e);if(t?.then!=null){let n=yr({objectMode:!0});t.then(()=>{n.end()},o=>{n.end(o)});let i,s=r.source;if(t0(s))i=async function*(){yield*s,n.end()};else if(r0(s))i=function*(){yield*s,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return Gn(n,i())}return r.source};function ee(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}var Ct=class extends Error{constructor(e="Query error"){super(e),this.name="QueryError"}},jn=class extends Error{constructor(e="Query aborted"){super(e),this.name="QueryAbortedError"}},Zn=class extends Error{constructor(e="Invalid record"){super(e),this.name="InvalidRecordError"}},Wn=class extends Error{constructor(e="No selector function configured for prefix"){super(e),this.name="MissingSelectorError"}};var n0;(function(r){let e;r.codec=()=>(e==null&&(e=nt((t,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),t.key!=null&&(n.uint32(10),n.bytes(t.key)),t.value!=null&&(n.uint32(18),n.bytes(t.value)),t.author!=null&&(n.uint32(26),n.bytes(t.author)),t.signature!=null&&(n.uint32(34),n.bytes(t.signature)),t.timeReceived!=null&&(n.uint32(42),n.string(t.timeReceived)),i.lengthDelimited!==!1&&n.ldelim()},(t,n,i={})=>{let s={},o=n==null?t.len:t.pos+n;for(;t.pos<o;){let a=t.uint32();switch(a>>>3){case 1:{s.key=t.bytes();break}case 2:{s.value=t.bytes();break}case 3:{s.author=t.bytes();break}case 4:{s.signature=t.bytes();break}case 5:{s.timeReceived=t.string();break}default:{t.skipType(a&7);break}}}return s})),e),r.encode=t=>rt(t,r.codec()),r.decode=(t,n)=>tt(t,r.codec(),n)})(n0||(n0={}));var M;(function(r){r.PUT_VALUE="PUT_VALUE",r.GET_VALUE="GET_VALUE",r.ADD_PROVIDER="ADD_PROVIDER",r.GET_PROVIDERS="GET_PROVIDERS",r.FIND_NODE="FIND_NODE",r.PING="PING"})(M||(M={}));var Qn;(function(r){r[r.PUT_VALUE=0]="PUT_VALUE",r[r.GET_VALUE=1]="GET_VALUE",r[r.ADD_PROVIDER=2]="ADD_PROVIDER",r[r.GET_PROVIDERS=3]="GET_PROVIDERS",r[r.FIND_NODE=4]="FIND_NODE",r[r.PING=5]="PING"})(Qn||(Qn={}));(function(r){r.codec=()=>dr(Qn)})(M||(M={}));var wr;(function(r){r.NOT_CONNECTED="NOT_CONNECTED",r.CONNECTED="CONNECTED",r.CAN_CONNECT="CAN_CONNECT",r.CANNOT_CONNECT="CANNOT_CONNECT"})(wr||(wr={}));var $s;(function(r){r[r.NOT_CONNECTED=0]="NOT_CONNECTED",r[r.CONNECTED=1]="CONNECTED",r[r.CAN_CONNECT=2]="CAN_CONNECT",r[r.CANNOT_CONNECT=3]="CANNOT_CONNECT"})($s||($s={}));(function(r){r.codec=()=>dr($s)})(wr||(wr={}));var br;(function(r){let e;r.codec=()=>(e==null&&(e=nt((t,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),t.id!=null&&t.id.byteLength>0&&(n.uint32(10),n.bytes(t.id)),t.multiaddrs!=null)for(let s of t.multiaddrs)n.uint32(18),n.bytes(s);t.connection!=null&&(n.uint32(24),wr.codec().encode(t.connection,n)),i.lengthDelimited!==!1&&n.ldelim()},(t,n,i={})=>{let s={id:Ce(0),multiaddrs:[]},o=n==null?t.len:t.pos+n;for(;t.pos<o;){let a=t.uint32();switch(a>>>3){case 1:{s.id=t.bytes();break}case 2:{if(i.limits?.multiaddrs!=null&&s.multiaddrs.length===i.limits.multiaddrs)throw new pr('Decode error - map field "multiaddrs" had too many elements');s.multiaddrs.push(t.bytes());break}case 3:{s.connection=wr.codec().decode(t);break}default:{t.skipType(a&7);break}}}return s})),e),r.encode=t=>rt(t,r.codec()),r.decode=(t,n)=>tt(t,r.codec(),n)})(br||(br={}));var Ke;(function(r){let e;r.codec=()=>(e==null&&(e=nt((t,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),t.type!=null&&Qn[t.type]!==0&&(n.uint32(8),M.codec().encode(t.type,n)),t.clusterLevel!=null&&(n.uint32(80),n.int32(t.clusterLevel)),t.key!=null&&(n.uint32(18),n.bytes(t.key)),t.record!=null&&(n.uint32(26),n.bytes(t.record)),t.closer!=null)for(let s of t.closer)n.uint32(66),br.codec().encode(s,n);if(t.providers!=null)for(let s of t.providers)n.uint32(74),br.codec().encode(s,n);i.lengthDelimited!==!1&&n.ldelim()},(t,n,i={})=>{let s={type:M.PUT_VALUE,closer:[],providers:[]},o=n==null?t.len:t.pos+n;for(;t.pos<o;){let a=t.uint32();switch(a>>>3){case 1:{s.type=M.codec().decode(t);break}case 10:{s.clusterLevel=t.int32();break}case 2:{s.key=t.bytes();break}case 3:{s.record=t.bytes();break}case 8:{if(i.limits?.closer!=null&&s.closer.length===i.limits.closer)throw new pr('Decode error - map field "closer" had too many elements');s.closer.push(br.codec().decode(t,t.uint32(),{limits:i.limits?.closer$}));break}case 9:{if(i.limits?.providers!=null&&s.providers.length===i.limits.providers)throw new pr('Decode error - map field "providers" had too many elements');s.providers.push(br.codec().decode(t,t.uint32(),{limits:i.limits?.providers$}));break}default:{t.skipType(a&7);break}}}return s})),e),r.encode=t=>rt(t,r.codec()),r.decode=(t,n)=>tt(t,r.codec(),n)})(Ke||(Ke={}));function zs(r,e={}){let t={...r,name:"SEND_QUERY",type:0,messageName:r.type,messageType:r.type};return e.onProgress?.(new CustomEvent("kad-dht:query:send-query",{detail:t})),t}function tn(r,e={}){let t={...r,name:"PEER_RESPONSE",type:1,messageName:r.messageType,closer:r.closer??[],providers:r.providers??[]};return e.onProgress?.(new CustomEvent("kad-dht:query:peer-response",{detail:t})),t}function Yn(r,e={}){let t={...r,name:"FINAL_PEER",type:2};return e.onProgress?.(new CustomEvent("kad-dht:query:final-peer",{detail:t})),t}function Ve(r,e={}){let t={...r,name:"QUERY_ERROR",type:3};return e.onProgress?.(new CustomEvent("kad-dht:query:query-error",{detail:t})),t}function Gs(r,e={}){let t={...r,name:"PROVIDER",type:4};return e.onProgress?.(new CustomEvent("kad-dht:query:provider",{detail:t})),t}function rn(r,e={}){let t={...r,name:"VALUE",type:5};return e.onProgress?.(new CustomEvent("kad-dht:query:value",{detail:t})),t}function js(r,e={}){let t={...r,name:"DIAL_PEER",type:7};return e.onProgress?.(new CustomEvent("kad-dht:query:dial-peer",{detail:t})),t}function C(r,e="utf8"){let t=Hn[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.encoder.encode(r).substring(1)}function i0(r,e,t){if(t.length===0)throw new $("No records given");let i=C(e).split("/");if(i.length<3)throw new $("Record key does not have a selector function");let s=r[i[1].toString()];if(s==null)throw new Wn(`No selector function configured for key type "${i[1]}"`);return t.length===1?0:s(e,t)}function E6(r,e){return 0}var s0={pk:E6};function o0(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`positive integer expected, not ${r}`)}function A6(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function xr(r,...e){if(!A6(r))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(r.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${r.length}`)}function a0(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");o0(r.outputLen),o0(r.blockLen)}function vr(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 c0(r,e){xr(r);let t=e.outputLen;if(r.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}var Yt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var Xn=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),We=(r,e)=>r<<32-e|r>>>e;var il=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function l0(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function nn(r){return typeof r=="string"&&(r=l0(r)),xr(r),r}function Zs(...r){let e=0;for(let n=0;n<r.length;n++){let i=r[n];xr(i),e+=i.length}let t=new Uint8Array(e);for(let n=0,i=0;n<r.length;n++){let s=r[n];t.set(s,i),i+=s.length}return t}var Er=class{clone(){return this._cloneInto()}},sl={}.toString;function Jn(r){let e=n=>r().update(nn(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function Ar(r=32){if(Yt&&typeof Yt.getRandomValues=="function")return Yt.getRandomValues(new Uint8Array(r));if(Yt&&typeof Yt.randomBytes=="function")return Yt.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function B6(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);let i=BigInt(32),s=BigInt(4294967295),o=Number(t>>i&s),a=Number(t&s),c=n?4:0,l=n?0:4;r.setUint32(e+c,o,n),r.setUint32(e+l,a,n)}var u0=(r,e,t)=>r&e^~r&t,f0=(r,e,t)=>r&e^r&t^e&t,Br=class extends Er{constructor(e,t,n,i){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Xn(this.buffer)}update(e){vr(this);let{view:t,buffer:n,blockLen:i}=this;e=nn(e);let s=e.length;for(let o=0;o<s;){let a=Math.min(i-this.pos,s-o);if(a===i){let c=Xn(e);for(;i<=s-o;o+=i)this.process(c,o);continue}n.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){vr(this),c0(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:i,isLE:s}=this,{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(n,0),o=0);for(let f=o;f<i;f++)t[f]=0;B6(n,i-8,BigInt(this.length*8),s),this.process(n,0);let a=Xn(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=c/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<l;f++)a.setUint32(4*f,u[f],s)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:t,buffer:n,length:i,finished:s,destroyed:o,pos:a}=this;return e.length=i,e.pos=a,e.finished=s,e.destroyed=o,i%t&&e.buffer.set(n),e}};var e1=BigInt(4294967295),Ws=BigInt(32);function h0(r,e=!1){return e?{h:Number(r&e1),l:Number(r>>Ws&e1)}:{h:Number(r>>Ws&e1)|0,l:Number(r&e1)|0}}function S6(r,e=!1){let t=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let i=0;i<r.length;i++){let{h:s,l:o}=h0(r[i],e);[t[i],n[i]]=[s,o]}return[t,n]}var I6=(r,e)=>BigInt(r>>>0)<<Ws|BigInt(e>>>0),k6=(r,e,t)=>r>>>t,T6=(r,e,t)=>r<<32-t|e>>>t,R6=(r,e,t)=>r>>>t|e<<32-t,N6=(r,e,t)=>r<<32-t|e>>>t,L6=(r,e,t)=>r<<64-t|e>>>t-32,P6=(r,e,t)=>r>>>t-32|e<<64-t,C6=(r,e)=>e,_6=(r,e)=>r,U6=(r,e,t)=>r<<t|e>>>32-t,D6=(r,e,t)=>e<<t|r>>>32-t,M6=(r,e,t)=>e<<t-32|r>>>64-t,O6=(r,e,t)=>r<<t-32|e>>>64-t;function V6(r,e,t,n){let i=(e>>>0)+(n>>>0);return{h:r+t+(i/2**32|0)|0,l:i|0}}var F6=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),H6=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,q6=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),K6=(r,e,t,n,i)=>e+t+n+i+(r/2**32|0)|0,$6=(r,e,t,n,i)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(i>>>0),z6=(r,e,t,n,i,s)=>e+t+n+i+s+(r/2**32|0)|0;var G6={fromBig:h0,split:S6,toBig:I6,shrSH:k6,shrSL:T6,rotrSH:R6,rotrSL:N6,rotrBH:L6,rotrBL:P6,rotr32H:C6,rotr32L:_6,rotlSH:U6,rotlSL:D6,rotlBH:M6,rotlBL:O6,add:V6,add3L:F6,add3H:H6,add4L:q6,add4H:K6,add5H:z6,add5L:$6},D=G6;var[j6,Z6]=D.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),_t=new Uint32Array(80),Ut=new Uint32Array(80),Qs=class extends Br{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:t,Bh:n,Bl:i,Ch:s,Cl:o,Dh:a,Dl:c,Eh:l,El:u,Fh:f,Fl:h,Gh:g,Gl:y,Hh:p,Hl:d}=this;return[e,t,n,i,s,o,a,c,l,u,f,h,g,y,p,d]}set(e,t,n,i,s,o,a,c,l,u,f,h,g,y,p,d){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=l|0,this.El=u|0,this.Fh=f|0,this.Fl=h|0,this.Gh=g|0,this.Gl=y|0,this.Hh=p|0,this.Hl=d|0}process(e,t){for(let m=0;m<16;m++,t+=4)_t[m]=e.getUint32(t),Ut[m]=e.getUint32(t+=4);for(let m=16;m<80;m++){let A=_t[m-15]|0,R=Ut[m-15]|0,T=D.rotrSH(A,R,1)^D.rotrSH(A,R,8)^D.shrSH(A,R,7),I=D.rotrSL(A,R,1)^D.rotrSL(A,R,8)^D.shrSL(A,R,7),k=_t[m-2]|0,P=Ut[m-2]|0,oe=D.rotrSH(k,P,19)^D.rotrBH(k,P,61)^D.shrSH(k,P,6),K=D.rotrSL(k,P,19)^D.rotrBL(k,P,61)^D.shrSL(k,P,6),O=D.add4L(I,K,Ut[m-7],Ut[m-16]),ae=D.add4H(O,T,oe,_t[m-7],_t[m-16]);_t[m]=ae|0,Ut[m]=O|0}let{Ah:n,Al:i,Bh:s,Bl:o,Ch:a,Cl:c,Dh:l,Dl:u,Eh:f,El:h,Fh:g,Fl:y,Gh:p,Gl:d,Hh:w,Hl:v}=this;for(let m=0;m<80;m++){let A=D.rotrSH(f,h,14)^D.rotrSH(f,h,18)^D.rotrBH(f,h,41),R=D.rotrSL(f,h,14)^D.rotrSL(f,h,18)^D.rotrBL(f,h,41),T=f&g^~f&p,I=h&y^~h&d,k=D.add5L(v,R,I,Z6[m],Ut[m]),P=D.add5H(k,w,A,T,j6[m],_t[m]),oe=k|0,K=D.rotrSH(n,i,28)^D.rotrBH(n,i,34)^D.rotrBH(n,i,39),O=D.rotrSL(n,i,28)^D.rotrBL(n,i,34)^D.rotrBL(n,i,39),ae=n&s^n&a^s&a,B=i&o^i&c^o&c;w=p|0,v=d|0,p=g|0,d=y|0,g=f|0,y=h|0,{h:f,l:h}=D.add(l|0,u|0,P|0,oe|0),l=a|0,u=c|0,a=s|0,c=o|0,s=n|0,o=i|0;let N=D.add3L(oe,O,B);n=D.add3H(N,P,K,ae),i=N|0}({h:n,l:i}=D.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:o}=D.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:c}=D.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:u}=D.add(this.Dh|0,this.Dl|0,l|0,u|0),{h:f,l:h}=D.add(this.Eh|0,this.El|0,f|0,h|0),{h:g,l:y}=D.add(this.Fh|0,this.Fl|0,g|0,y|0),{h:p,l:d}=D.add(this.Gh|0,this.Gl|0,p|0,d|0),{h:w,l:v}=D.add(this.Hh|0,this.Hl|0,w|0,v|0),this.set(n,i,s,o,a,c,l,u,f,h,g,y,p,d,w,v)}roundClean(){_t.fill(0),Ut.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var d0=Jn(()=>new Qs);var r1={};Te(r1,{aInRange:()=>_e,abool:()=>Qe,abytes:()=>Sr,bitGet:()=>ea,bitLen:()=>to,bitMask:()=>on,bitSet:()=>ta,bytesToHex:()=>bt,bytesToNumberBE:()=>wt,bytesToNumberLE:()=>Mt,concatBytes:()=>xt,createHmacDrbg:()=>ro,ensureBytes:()=>re,equalBytes:()=>X6,hexToBytes:()=>Jt,hexToNumber:()=>eo,inRange:()=>sn,isBytes:()=>Dt,memoized:()=>tr,notImplemented:()=>na,numberToBytesBE:()=>Ot,numberToBytesLE:()=>er,numberToHexUnpadded:()=>Xt,numberToVarBytesBE:()=>Y6,utf8ToBytes:()=>J6,validateObject:()=>it});var Js=BigInt(0),t1=BigInt(1),W6=BigInt(2);function Dt(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Sr(r){if(!Dt(r))throw new Error("Uint8Array expected")}function Qe(r,e){if(typeof e!="boolean")throw new Error(`${r} must be valid boolean, got "${e}".`)}var Q6=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function bt(r){Sr(r);let e="";for(let t=0;t<r.length;t++)e+=Q6[r[t]];return e}function Xt(r){let e=r.toString(16);return e.length&1?`0${e}`:e}function eo(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var yt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function p0(r){if(r>=yt._0&&r<=yt._9)return r-yt._0;if(r>=yt._A&&r<=yt._F)return r-(yt._A-10);if(r>=yt._a&&r<=yt._f)return r-(yt._a-10)}function Jt(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let e=r.length,t=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(t);for(let i=0,s=0;i<t;i++,s+=2){let o=p0(r.charCodeAt(s)),a=p0(r.charCodeAt(s+1));if(o===void 0||a===void 0){let c=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[i]=o*16+a}return n}function wt(r){return eo(bt(r))}function Mt(r){return Sr(r),eo(bt(Uint8Array.from(r).reverse()))}function Ot(r,e){return Jt(r.toString(16).padStart(e*2,"0"))}function er(r,e){return Ot(r,e).reverse()}function Y6(r){return Jt(Xt(r))}function re(r,e,t){let n;if(typeof e=="string")try{n=Jt(e)}catch(s){throw new Error(`${r} must be valid hex string, got "${e}". Cause: ${s}`)}else if(Dt(e))n=Uint8Array.from(e);else throw new Error(`${r} must be hex string or Uint8Array`);let i=n.length;if(typeof t=="number"&&i!==t)throw new Error(`${r} expected ${t} bytes, got ${i}`);return n}function xt(...r){let e=0;for(let n=0;n<r.length;n++){let i=r[n];Sr(i),e+=i.length}let t=new Uint8Array(e);for(let n=0,i=0;n<r.length;n++){let s=r[n];t.set(s,i),i+=s.length}return t}function X6(r,e){if(r.length!==e.length)return!1;let t=0;for(let n=0;n<r.length;n++)t|=r[n]^e[n];return t===0}function J6(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}var Ys=r=>typeof r=="bigint"&&Js<=r;function sn(r,e,t){return Ys(r)&&Ys(e)&&Ys(t)&&e<=r&&r<t}function _e(r,e,t,n){if(!sn(e,t,n))throw new Error(`expected valid ${r}: ${t} <= n < ${n}, got ${typeof e} ${e}`)}function to(r){let e;for(e=0;r>Js;r>>=t1,e+=1);return e}function ea(r,e){return r>>BigInt(e)&t1}function ta(r,e,t){return r|(t?t1:Js)<<BigInt(e)}var on=r=>(W6<<BigInt(r-1))-t1,Xs=r=>new Uint8Array(r),g0=r=>Uint8Array.from(r);function ro(r,e,t){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let n=Xs(r),i=Xs(r),s=0,o=()=>{n.fill(1),i.fill(0),s=0},a=(...f)=>t(i,n,...f),c=(f=Xs())=>{i=a(g0([0]),f),n=a(),f.length!==0&&(i=a(g0([1]),f),n=a())},l=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let f=0,h=[];for(;f<e;){n=a();let g=n.slice();h.push(g),f+=n.length}return xt(...h)};return(f,h)=>{o(),c(f);let g;for(;!(g=h(l()));)c();return o(),g}}var ra={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||Dt(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,e)=>e.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function it(r,e,t={}){let n=(i,s,o)=>{let a=ra[s];if(typeof a!="function")throw new Error(`Invalid validator "${s}", expected function`);let c=r[i];if(!(o&&c===void 0)&&!a(c,r))throw new Error(`Invalid param ${String(i)}=${c} (${typeof c}), expected ${s}`)};for(let[i,s]of Object.entries(e))n(i,s,!1);for(let[i,s]of Object.entries(t))n(i,s,!0);return r}var na=()=>{throw new Error("not implemented")};function tr(r){let e=new WeakMap;return(t,...n)=>{let i=e.get(t);if(i!==void 0)return i;let s=r(t,...n);return e.set(t,s),s}}var ue=BigInt(0),X=BigInt(1),rr=BigInt(2),ia=BigInt(3),no=BigInt(4),m0=BigInt(5),y0=BigInt(8),sa=BigInt(9),oa=BigInt(16);function Z(r,e){let t=r%e;return t>=ue?t:e+t}function aa(r,e,t){if(t<=ue||e<ue)throw new Error("Expected power/modulo > 0");if(t===X)return ue;let n=X;for(;e>ue;)e&X&&(n=n*r%t),r=r*r%t,e>>=X;return n}function J(r,e,t){let n=r;for(;e-- >ue;)n*=n,n%=t;return n}function n1(r,e){if(r===ue||e<=ue)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=Z(r,e),n=e,i=ue,s=X,o=X,a=ue;for(;t!==ue;){let l=n/t,u=n%t,f=i-o*l,h=s-a*l;n=t,t=u,i=o,s=a,o=f,a=h}if(n!==X)throw new Error("invert: does not exist");return Z(i,e)}function ca(r){let e=(r-X)/rr,t,n,i;for(t=r-X,n=0;t%rr===ue;t/=rr,n++);for(i=rr;i<r&&aa(i,e,r)!==r-X;i++);if(n===1){let o=(r+X)/no;return function(c,l){let u=c.pow(l,o);if(!c.eql(c.sqr(u),l))throw new Error("Cannot find square root");return u}}let s=(t+X)/rr;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let l=n,u=a.pow(a.mul(a.ONE,i),t),f=a.pow(c,s),h=a.pow(c,t);for(;!a.eql(h,a.ONE);){if(a.eql(h,a.ZERO))return a.ZERO;let g=1;for(let p=a.sqr(h);g<l&&!a.eql(p,a.ONE);g++)p=a.sqr(p);let y=a.pow(u,X<<BigInt(l-g-1));u=a.sqr(y),f=a.mul(f,y),h=a.mul(h,u),l=g}return f}}function la(r){if(r%no===ia){let e=(r+X)/no;return function(n,i){let s=n.pow(i,e);if(!n.eql(n.sqr(s),i))throw new Error("Cannot find square root");return s}}if(r%y0===m0){let e=(r-m0)/y0;return function(n,i){let s=n.mul(i,rr),o=n.pow(s,e),a=n.mul(i,o),c=n.mul(n.mul(a,rr),o),l=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(l),i))throw new Error("Cannot find square root");return l}}return r%oa,ca(r)}var b0=(r,e)=>(Z(r,e)&X)===X,ua=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function io(r){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=ua.reduce((n,i)=>(n[i]="function",n),e);return it(r,t)}function fa(r,e,t){if(t<ue)throw new Error("Expected power > 0");if(t===ue)return r.ONE;if(t===X)return e;let n=r.ONE,i=e;for(;t>ue;)t&X&&(n=r.mul(n,i)),i=r.sqr(i),t>>=X;return n}function ha(r,e){let t=new Array(e.length),n=e.reduce((s,o,a)=>r.is0(o)?s:(t[a]=s,r.mul(s,o)),r.ONE),i=r.inv(n);return e.reduceRight((s,o,a)=>r.is0(o)?s:(t[a]=r.mul(s,t[a]),r.mul(s,o)),i),t}function so(r,e){let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function Vt(r,e,t=!1,n={}){if(r<=ue)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:i,nByteLength:s}=so(r,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let o=la(r),a=Object.freeze({ORDER:r,BITS:i,BYTES:s,MASK:on(i),ZERO:ue,ONE:X,create:c=>Z(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return ue<=c&&c<r},is0:c=>c===ue,isOdd:c=>(c&X)===X,neg:c=>Z(-c,r),eql:(c,l)=>c===l,sqr:c=>Z(c*c,r),add:(c,l)=>Z(c+l,r),sub:(c,l)=>Z(c-l,r),mul:(c,l)=>Z(c*l,r),pow:(c,l)=>fa(a,c,l),div:(c,l)=>Z(c*n1(l,r),r),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>n1(c,r),sqrt:n.sqrt||(c=>o(a,c)),invertBatch:c=>ha(a,c),cmov:(c,l,u)=>u?l:c,toBytes:c=>t?er(c,s):Ot(c,s),fromBytes:c=>{if(c.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${c.length}`);return t?Mt(c):wt(c)}});return Object.freeze(a)}function w0(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 oo(r){let e=w0(r);return e+Math.ceil(e/2)}function x0(r,e,t=!1){let n=r.length,i=w0(e),s=oo(e);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let o=t?wt(r):Mt(r),a=Z(o,e-X)+X;return t?er(a,i):Ot(a,i)}var pa=BigInt(0),ao=BigInt(1),co=new WeakMap,v0=new WeakMap;function i1(r,e){let t=(s,o)=>{let a=o.negate();return s?a:o},n=s=>{if(!Number.isSafeInteger(s)||s<=0||s>e)throw new Error(`Wrong window size=${s}, should be [1..${e}]`)},i=s=>{n(s);let o=Math.ceil(e/s)+1,a=2**(s-1);return{windows:o,windowSize:a}};return{constTimeNegate:t,unsafeLadder(s,o){let a=r.ZERO,c=s;for(;o>pa;)o&ao&&(a=a.add(c)),c=c.double(),o>>=ao;return a},precomputeWindow(s,o){let{windows:a,windowSize:c}=i(o),l=[],u=s,f=u;for(let h=0;h<a;h++){f=u,l.push(f);for(let g=1;g<c;g++)f=f.add(u),l.push(f);u=f.double()}return l},wNAF(s,o,a){let{windows:c,windowSize:l}=i(s),u=r.ZERO,f=r.BASE,h=BigInt(2**s-1),g=2**s,y=BigInt(s);for(let p=0;p<c;p++){let d=p*l,w=Number(a&h);a>>=y,w>l&&(w-=g,a+=ao);let v=d,m=d+Math.abs(w)-1,A=p%2!==0,R=w<0;w===0?f=f.add(t(A,o[v])):u=u.add(t(R,o[m]))}return{p:u,f}},wNAFCached(s,o,a){let c=v0.get(s)||1,l=co.get(s);return l||(l=this.precomputeWindow(s,c),c!==1&&co.set(s,a(l))),this.wNAF(c,l,o)},setWindowSize(s,o){n(o),v0.set(s,o),co.delete(s)}}}function s1(r,e,t,n){if(!Array.isArray(t)||!Array.isArray(n)||n.length!==t.length)throw new Error("arrays of points and scalars must have equal length");n.forEach((u,f)=>{if(!e.isValid(u))throw new Error(`wrong scalar at index ${f}`)}),t.forEach((u,f)=>{if(!(u instanceof r))throw new Error(`wrong point at index ${f}`)});let i=to(BigInt(t.length)),s=i>12?i-3:i>4?i-2:i?2:1,o=(1<<s)-1,a=new Array(o+1).fill(r.ZERO),c=Math.floor((e.BITS-1)/s)*s,l=r.ZERO;for(let u=c;u>=0;u-=s){a.fill(r.ZERO);for(let h=0;h<n.length;h++){let g=n[h],y=Number(g>>BigInt(u)&BigInt(o));a[y]=a[y].add(t[h])}let f=r.ZERO;for(let h=a.length-1,g=r.ZERO;h>0;h--)g=g.add(a[h]),f=f.add(g);if(l=l.add(f),u!==0)for(let h=0;h<s;h++)l=l.double()}return l}function an(r){return io(r.Fp),it(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...so(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Ye=BigInt(0),Ue=BigInt(1),o1=BigInt(2),ga=BigInt(8),ma={zip215:!0};function ya(r){let e=an(r);return it(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function E0(r){let e=ya(r),{Fp:t,n,prehash:i,hash:s,randomBytes:o,nByteLength:a,h:c}=e,l=o1<<BigInt(a*8)-Ue,u=t.create,f=Vt(e.n,e.nBitLength),h=e.uvRatio||((x,b)=>{try{return{isValid:!0,value:t.sqrt(x*t.inv(b))}}catch{return{isValid:!1,value:Ye}}}),g=e.adjustScalarBytes||(x=>x),y=e.domain||((x,b,E)=>{if(Qe("phflag",E),b.length||E)throw new Error("Contexts/pre-hash are not supported");return x});function p(x,b){_e("coordinate "+x,b,Ye,l)}function d(x){if(!(x instanceof m))throw new Error("ExtendedPoint expected")}let w=tr((x,b)=>{let{ex:E,ey:L,ez:_}=x,U=x.is0();b==null&&(b=U?ga:t.inv(_));let V=u(E*b),q=u(L*b),F=u(_*b);if(U)return{x:Ye,y:Ue};if(F!==Ue)throw new Error("invZ was invalid");return{x:V,y:q}}),v=tr(x=>{let{a:b,d:E}=e;if(x.is0())throw new Error("bad point: ZERO");let{ex:L,ey:_,ez:U,et:V}=x,q=u(L*L),F=u(_*_),j=u(U*U),W=u(j*j),he=u(q*b),de=u(j*u(he+F)),me=u(W+u(E*u(q*F)));if(de!==me)throw new Error("bad point: equation left != right (1)");let ke=u(L*_),ce=u(U*V);if(ke!==ce)throw new Error("bad point: equation left != right (2)");return!0});class m{constructor(b,E,L,_){this.ex=b,this.ey=E,this.ez=L,this.et=_,p("x",b),p("y",E),p("z",L),p("t",_),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(b){if(b instanceof m)throw new Error("extended point not allowed");let{x:E,y:L}=b||{};return p("x",E),p("y",L),new m(E,L,Ue,u(E*L))}static normalizeZ(b){let E=t.invertBatch(b.map(L=>L.ez));return b.map((L,_)=>L.toAffine(E[_])).map(m.fromAffine)}static msm(b,E){return s1(m,f,b,E)}_setWindowSize(b){T.setWindowSize(this,b)}assertValidity(){v(this)}equals(b){d(b);let{ex:E,ey:L,ez:_}=this,{ex:U,ey:V,ez:q}=b,F=u(E*q),j=u(U*_),W=u(L*q),he=u(V*_);return F===j&&W===he}is0(){return this.equals(m.ZERO)}negate(){return new m(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:b}=e,{ex:E,ey:L,ez:_}=this,U=u(E*E),V=u(L*L),q=u(o1*u(_*_)),F=u(b*U),j=E+L,W=u(u(j*j)-U-V),he=F+V,de=he-q,me=F-V,ke=u(W*de),ce=u(he*me),Le=u(W*me),ut=u(de*he);return new m(ke,ce,ut,Le)}add(b){d(b);let{a:E,d:L}=e,{ex:_,ey:U,ez:V,et:q}=this,{ex:F,ey:j,ez:W,et:he}=b;if(E===BigInt(-1)){let o2=u((U-_)*(j+F)),a2=u((U+_)*(j-F)),es=u(a2-o2);if(es===Ye)return this.double();let c2=u(V*o1*he),l2=u(q*o1*W),u2=l2+c2,f2=a2+o2,h2=l2-c2,M4=u(u2*es),O4=u(f2*h2),V4=u(u2*h2),F4=u(es*f2);return new m(M4,O4,F4,V4)}let de=u(_*F),me=u(U*j),ke=u(q*L*he),ce=u(V*W),Le=u((_+U)*(F+j)-de-me),ut=ce-ke,$r=ce+ke,zr=u(me-E*de),C4=u(Le*ut),_4=u($r*zr),U4=u(Le*zr),D4=u(ut*$r);return new m(C4,_4,D4,U4)}subtract(b){return this.add(b.negate())}wNAF(b){return T.wNAFCached(this,b,m.normalizeZ)}multiply(b){let E=b;_e("scalar",E,Ue,n);let{p:L,f:_}=this.wNAF(E);return m.normalizeZ([L,_])[0]}multiplyUnsafe(b){let E=b;return _e("scalar",E,Ye,n),E===Ye?R:this.equals(R)||E===Ue?this:this.equals(A)?this.wNAF(E).p:T.unsafeLadder(this,E)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return T.unsafeLadder(this,n).is0()}toAffine(b){return w(this,b)}clearCofactor(){let{h:b}=e;return b===Ue?this:this.multiplyUnsafe(b)}static fromHex(b,E=!1){let{d:L,a:_}=e,U=t.BYTES;b=re("pointHex",b,U),Qe("zip215",E);let V=b.slice(),q=b[U-1];V[U-1]=q&-129;let F=Mt(V),j=E?l:t.ORDER;_e("pointHex.y",F,Ye,j);let W=u(F*F),he=u(W-Ue),de=u(L*W-_),{isValid:me,value:ke}=h(he,de);if(!me)throw new Error("Point.fromHex: invalid y coordinate");let ce=(ke&Ue)===Ue,Le=(q&128)!==0;if(!E&&ke===Ye&&Le)throw new Error("Point.fromHex: x=0 and x_0=1");return Le!==ce&&(ke=u(-ke)),m.fromAffine({x:ke,y:F})}static fromPrivateKey(b){return P(b).point}toRawBytes(){let{x:b,y:E}=this.toAffine(),L=er(E,t.BYTES);return L[L.length-1]|=b&Ue?128:0,L}toHex(){return bt(this.toRawBytes())}}m.BASE=new m(e.Gx,e.Gy,Ue,u(e.Gx*e.Gy)),m.ZERO=new m(Ye,Ue,Ue,Ye);let{BASE:A,ZERO:R}=m,T=i1(m,a*8);function I(x){return Z(x,n)}function k(x){return I(Mt(x))}function P(x){let b=a;x=re("private key",x,b);let E=re("hashed private key",s(x),2*b),L=g(E.slice(0,b)),_=E.slice(b,2*b),U=k(L),V=A.multiply(U),q=V.toRawBytes();return{head:L,prefix:_,scalar:U,point:V,pointBytes:q}}function oe(x){return P(x).pointBytes}function K(x=new Uint8Array,...b){let E=xt(...b);return k(s(y(E,re("context",x),!!i)))}function O(x,b,E={}){x=re("message",x),i&&(x=i(x));let{prefix:L,scalar:_,pointBytes:U}=P(b),V=K(E.context,L,x),q=A.multiply(V).toRawBytes(),F=K(E.context,q,U,x),j=I(V+F*_);_e("signature.s",j,Ye,n);let W=xt(q,er(j,t.BYTES));return re("result",W,a*2)}let ae=ma;function B(x,b,E,L=ae){let{context:_,zip215:U}=L,V=t.BYTES;x=re("signature",x,2*V),b=re("message",b),U!==void 0&&Qe("zip215",U),i&&(b=i(b));let q=Mt(x.slice(V,2*V)),F,j,W;try{F=m.fromHex(E,U),j=m.fromHex(x.slice(0,V),U),W=A.multiplyUnsafe(q)}catch{return!1}if(!U&&F.isSmallOrder())return!1;let he=K(_,j.toRawBytes(),F.toRawBytes(),b);return j.add(F.multiplyUnsafe(he)).subtract(W).clearCofactor().equals(m.ZERO)}return A._setWindowSize(8),{CURVE:e,getPublicKey:oe,sign:O,verify:B,ExtendedPoint:m,utils:{getExtendedPublicKey:P,randomPrivateKey:()=>o(t.BYTES),precompute(x=8,b=m.BASE){return b._setWindowSize(x),b.multiply(BigInt(3)),b}}}}var lo=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),A0=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Tl=BigInt(0),ba=BigInt(1),B0=BigInt(2),Rl=BigInt(3),wa=BigInt(5),xa=BigInt(8);function va(r){let e=BigInt(10),t=BigInt(20),n=BigInt(40),i=BigInt(80),s=lo,a=r*r%s*r%s,c=J(a,B0,s)*a%s,l=J(c,ba,s)*r%s,u=J(l,wa,s)*l%s,f=J(u,e,s)*u%s,h=J(f,t,s)*f%s,g=J(h,n,s)*h%s,y=J(g,i,s)*g%s,p=J(y,i,s)*g%s,d=J(p,e,s)*u%s;return{pow_p_5_8:J(d,B0,s)*r%s,b2:a}}function Ea(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Aa(r,e){let t=lo,n=Z(e*e*e,t),i=Z(n*n*e,t),s=va(r*i).pow_p_5_8,o=Z(r*n*s,t),a=Z(e*o*o,t),c=o,l=Z(o*A0,t),u=a===r,f=a===Z(-r,t),h=a===Z(-r*A0,t);return u&&(o=c),(f||h)&&(o=l),b0(o,t)&&(o=Z(-o,t)),{isValid:u||f,value:o}}var Ba=Vt(lo,void 0,!0),Sa={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Ba,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:xa,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:d0,randomBytes:Ar,adjustScalarBytes:Ea,uvRatio:Aa},S0=E0(Sa);var a1=32;function I0(r,e,t){return S0.verify(e,t instanceof Uint8Array?t:t.subarray(),r)}var c1=class{type="Ed25519";raw;constructor(e){this.raw=uo(e,a1)}toMultihash(){return gt.digest(Ir(this))}toCID(){return ne.createV1(114,this.toMultihash())}toString(){return Q.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ee(this.raw,e.raw)}verify(e,t){return I0(this.raw,t,e)}};function fo(r){return r=uo(r,a1),new c1(r)}function uo(r,e){if(r=Uint8Array.from(r??[]),r.length!==e)throw new $(`Key must be a Uint8Array of length ${e}, got ${r.length}`);return r}var fe;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1"})(fe||(fe={}));var ho;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1"})(ho||(ho={}));(function(r){r.codec=()=>dr(ho)})(fe||(fe={}));var st;(function(r){let e;r.codec=()=>(e==null&&(e=nt((t,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),fe.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),i.lengthDelimited!==!1&&n.ldelim()},(t,n,i={})=>{let s={},o=n==null?t.len:t.pos+n;for(;t.pos<o;){let a=t.uint32();switch(a>>>3){case 1:{s.Type=fe.codec().decode(t);break}case 2:{s.Data=t.bytes();break}default:{t.skipType(a&7);break}}}return s})),e),r.encode=t=>rt(t,r.codec()),r.decode=(t,n)=>tt(t,r.codec(),n)})(st||(st={}));var po;(function(r){let e;r.codec=()=>(e==null&&(e=nt((t,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),fe.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),i.lengthDelimited!==!1&&n.ldelim()},(t,n,i={})=>{let s={},o=n==null?t.len:t.pos+n;for(;t.pos<o;){let a=t.uint32();switch(a>>>3){case 1:{s.Type=fe.codec().decode(t);break}case 2:{s.Data=t.bytes();break}default:{t.skipType(a&7);break}}}return s})),e),r.encode=t=>rt(t,r.codec()),r.decode=(t,n)=>tt(t,r.codec(),n)})(po||(po={}));var yn={};Te(yn,{MAX_RSA_KEY_SIZE:()=>ei,generateRSAKeyPair:()=>B3,jwkToJWKKeyPair:()=>S3,jwkToPkcs1:()=>qa,jwkToPkix:()=>Ao,jwkToRSAPrivateKey:()=>A3,pkcs1ToJwk:()=>x3,pkcs1ToRSAPrivateKey:()=>E3,pkixToJwk:()=>v3,pkixToRSAPublicKey:()=>Bo});var ka=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ft=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ht=new Uint32Array(64),go=class extends Br{constructor(){super(64,32,8,!1),this.A=Ft[0]|0,this.B=Ft[1]|0,this.C=Ft[2]|0,this.D=Ft[3]|0,this.E=Ft[4]|0,this.F=Ft[5]|0,this.G=Ft[6]|0,this.H=Ft[7]|0}get(){let{A:e,B:t,C:n,D:i,E:s,F:o,G:a,H:c}=this;return[e,t,n,i,s,o,a,c]}set(e,t,n,i,s,o,a,c){this.A=e|0,this.B=t|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,t){for(let f=0;f<16;f++,t+=4)Ht[f]=e.getUint32(t,!1);for(let f=16;f<64;f++){let h=Ht[f-15],g=Ht[f-2],y=We(h,7)^We(h,18)^h>>>3,p=We(g,17)^We(g,19)^g>>>10;Ht[f]=p+Ht[f-7]+y+Ht[f-16]|0}let{A:n,B:i,C:s,D:o,E:a,F:c,G:l,H:u}=this;for(let f=0;f<64;f++){let h=We(a,6)^We(a,11)^We(a,25),g=u+h+u0(a,c,l)+ka[f]+Ht[f]|0,p=(We(n,2)^We(n,13)^We(n,22))+f0(n,i,s)|0;u=l,l=c,c=a,a=o+g|0,o=s,s=i,i=n,n=g+p|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(n,i,s,o,a,c,l,u)}roundClean(){Ht.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var kr=Jn(()=>new go);var H=Mn(R0());function nr(r,e){let t=0;if(r.length===1)return r[0];for(let n=r.length-1;n>=0;n--)t+=r[r.length-1-n]*Math.pow(2,e*n);return t}function qt(r,e,t=-1){let n=t,i=r,s=0,o=Math.pow(2,e);for(let a=1;a<8;a++){if(r<o){let c;if(n<0)c=new ArrayBuffer(a),s=a;else{if(n<a)return new ArrayBuffer(0);c=new ArrayBuffer(n),s=n}let l=new Uint8Array(c);for(let u=a-1;u>=0;u--){let f=Math.pow(2,u*e);l[s-u-1]=Math.floor(i/f),i-=l[s-u-1]*f}return c}o*=Math.pow(2,e)}return new ArrayBuffer(0)}function f1(...r){let e=0,t=0;for(let s of r)e+=s.length;let n=new ArrayBuffer(e),i=new Uint8Array(n);for(let s of r)i.set(s,t),t+=s.length;return i}function yo(){let r=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){let a=r[0]===255&&r[1]&128,c=r[0]===0&&(r[1]&128)===0;(a||c)&&this.warnings.push("Needlessly long format")}let e=new ArrayBuffer(this.valueHex.byteLength),t=new Uint8Array(e);for(let a=0;a<this.valueHex.byteLength;a++)t[a]=0;t[0]=r[0]&128;let n=nr(t,8),i=new ArrayBuffer(this.valueHex.byteLength),s=new Uint8Array(i);for(let a=0;a<this.valueHex.byteLength;a++)s[a]=r[a];return s[0]&=127,nr(s,8)-n}function N0(r){let e=r<0?r*-1:r,t=128;for(let n=1;n<8;n++){if(e<=t){if(r<0){let o=t-e,a=qt(o,8,n),c=new Uint8Array(a);return c[0]|=128,a}let i=qt(e,8,n),s=new Uint8Array(i);if(s[0]&128){let o=i.slice(0),a=new Uint8Array(o);i=new ArrayBuffer(i.byteLength+1),s=new Uint8Array(i);for(let c=0;c<o.byteLength;c++)s[c+1]=a[c];s[0]=0}return i}t*=Math.pow(2,8)}return new ArrayBuffer(0)}function L0(r,e){if(r.byteLength!==e.byteLength)return!1;let t=new Uint8Array(r),n=new Uint8Array(e);for(let i=0;i<t.length;i++)if(t[i]!==n[i])return!1;return!0}function De(r,e){let t=r.toString(10);if(e<t.length)return"";let n=e-t.length,i=new Array(n);for(let o=0;o<n;o++)i[o]="0";return i.join("").concat(t)}var Xl=Math.log(2);function h1(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function bo(r){let e=0,t=0;for(let i=0;i<r.length;i++){let s=r[i];e+=s.byteLength}let n=new Uint8Array(e);for(let i=0;i<r.length;i++){let s=r[i];n.set(new Uint8Array(s),t),t+=s.byteLength}return n.buffer}function St(r,e,t,n){return e instanceof Uint8Array?e.byteLength?t<0?(r.error="Wrong parameter: inputOffset less than zero",!1):n<0?(r.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-t-n<0?(r.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(r.error="Wrong parameter: inputBuffer has zero length",!1):(r.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}var ln=class{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return bo(this.items)}},cn=[new Uint8Array([1])],P0="0123456789";var Pr="",Xe=new ArrayBuffer(0),wo=new Uint8Array(0),un="EndOfContent",_0="OCTET STRING",U0="BIT STRING";function It(r){var e;return e=class extends r{constructor(...n){var i;super(...n);let s=n[0]||{};this.isHexOnly=(i=s.isHexOnly)!==null&&i!==void 0?i:!1,this.valueHexView=s.valueHex?H.BufferSourceConverter.toUint8Array(s.valueHex):wo}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(n){this.valueHexView=new Uint8Array(n)}fromBER(n,i,s){let o=n instanceof ArrayBuffer?new Uint8Array(n):n;if(!St(this,o,i,s))return-1;let a=i+s;return this.valueHexView=o.subarray(i,a),this.valueHexView.length?(this.blockLength=s,a):(this.warnings.push("Zero buffer length"),i)}toBER(n=!1){return this.isHexOnly?n?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",Xe)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:H.Convert.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}var Et=class{constructor({blockLength:e=0,error:t=Pr,warnings:n=[],valueBeforeDecode:i=wo}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=H.BufferSourceConverter.toUint8Array(i)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:H.Convert.ToHex(this.valueBeforeDecodeView)}}};Et.NAME="baseBlock";var Be=class extends Et{fromBER(e,t,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,t){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}};Be.NAME="valueBlock";var d1=class extends It(Et){constructor({idBlock:e={}}={}){var t,n,i,s;super(),e?(this.isHexOnly=(t=e.isHexOnly)!==null&&t!==void 0?t:!1,this.valueHexView=e.valueHex?H.BufferSourceConverter.toUint8Array(e.valueHex):wo,this.tagClass=(n=e.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(i=e.tagNumber)!==null&&i!==void 0?i:-1,this.isConstructed=(s=e.isConstructed)!==null&&s!==void 0?s:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let t=0;switch(this.tagClass){case 1:t|=0;break;case 2:t|=64;break;case 3:t|=128;break;case 4:t|=192;break;default:return this.error="Unknown tag class",Xe}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){let i=new Uint8Array(1);if(!e){let s=this.tagNumber;s&=31,t|=s,i[0]=t}return i.buffer}if(!this.isHexOnly){let i=qt(this.tagNumber,7),s=new Uint8Array(i),o=i.byteLength,a=new Uint8Array(o+1);if(a[0]=t|31,!e){for(let c=0;c<o-1;c++)a[c+1]=s[c]|128;a[o]=s[o-1]}return a.buffer}let n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=t|31,!e){let i=this.valueHexView;for(let s=0;s<i.length-1;s++)n[s+1]=i[s]|128;n[this.valueHexView.byteLength]=i[i.length-1]}return n.buffer}fromBER(e,t,n){let i=H.BufferSourceConverter.toUint8Array(e);if(!St(this,i,t,n))return-1;let s=i.subarray(t,t+n);if(s.length===0)return this.error="Zero buffer length",-1;switch(s[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(s[0]&32)===32,this.isHexOnly=!1;let a=s[0]&31;if(a!==31)this.tagNumber=a,this.blockLength=1;else{let c=1,l=this.valueHexView=new Uint8Array(255),u=255;for(;s[c]&128;){if(l[c-1]=s[c]&127,c++,c>=s.length)return this.error="End of input reached before message was fully decoded",-1;if(c===u){u+=255;let h=new Uint8Array(u);for(let g=0;g<l.length;g++)h[g]=l[g];l=this.valueHexView=new Uint8Array(u)}}this.blockLength=c+1,l[c-1]=s[c]&127;let f=new Uint8Array(c);for(let h=0;h<c;h++)f[h]=l[h];l=this.valueHexView=new Uint8Array(c),l.set(f),this.blockLength<=9?this.tagNumber=nr(l,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return t+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}};d1.NAME="identificationBlock";var p1=class extends Et{constructor({lenBlock:e={}}={}){var t,n,i;super(),this.isIndefiniteForm=(t=e.isIndefiniteForm)!==null&&t!==void 0?t:!1,this.longFormUsed=(n=e.longFormUsed)!==null&&n!==void 0?n:!1,this.length=(i=e.length)!==null&&i!==void 0?i:0}fromBER(e,t,n){let i=H.BufferSourceConverter.toUint8Array(e);if(!St(this,i,t,n))return-1;let s=i.subarray(t,t+n);if(s.length===0)return this.error="Zero buffer length",-1;if(s[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=s[0]===128,this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(s[0]&128),this.longFormUsed===!1)return this.length=s[0],this.blockLength=1,t+this.blockLength;let o=s[0]&127;if(o>8)return this.error="Too big integer",-1;if(o+1>s.length)return this.error="End of input reached before message was fully decoded",-1;let a=t+1,c=i.subarray(a,a+o);return c[o-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=nr(c,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=o+1,t+this.blockLength}toBER(e=!1){let t,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=128),t;if(this.longFormUsed){let i=qt(this.length,8);if(i.byteLength>127)return this.error="Too big length",Xe;if(t=new ArrayBuffer(i.byteLength+1),e)return t;let s=new Uint8Array(i);n=new Uint8Array(t),n[0]=i.byteLength|128;for(let o=0;o<i.byteLength;o++)n[o+1]=s[o];return t}return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=this.length),t}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}};p1.NAME="lengthBlock";var S={},we=class extends Et{constructor({name:e=Pr,optional:t=!1,primitiveSchema:n,...i}={},s){super(i),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new d1(i),this.lenBlock=new p1(i),this.valueBlock=s?new s(i):new Be(i)}fromBER(e,t,n){let i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}toBER(e,t){let n=t||new ln;t||D0(this);let i=this.idBlock.toBER(e);if(n.write(i),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,n),n.write(new ArrayBuffer(2));else{let s=this.valueBlock.toBER(e);this.lenBlock.length=s.byteLength;let o=this.lenBlock.toBER(e);n.write(o),n.write(s)}return t?Xe:n.final()}toJSON(){let e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return e==="ascii"?this.onAsciiEncoding():H.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${H.Convert.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;let t=this.toBER(),n=e.toBER();return L0(t,n)}};we.NAME="BaseBlock";function D0(r){if(r instanceof S.Constructed)for(let e of r.valueBlock.value)D0(e)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}var g1=class extends we{constructor({value:e=Pr,...t}={},n){super(t,n),e&&this.fromString(e)}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}fromBER(e,t,n){let i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}};g1.NAME="BaseStringBlock";var m1=class extends It(Be){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}};m1.NAME="PrimitiveValueBlock";var M0,y1=class extends we{constructor(e={}){super(e,m1),this.idBlock.isConstructed=!1}};M0=y1;S.Primitive=M0;y1.NAME="PRIMITIVE";function Da(r,e){if(r instanceof e)return r;let t=new e;return t.idBlock=r.idBlock,t.lenBlock=r.lenBlock,t.warnings=r.warnings,t.valueBeforeDecodeView=r.valueBeforeDecodeView,t}function Y1(r,e=0,t=r.length){let n=e,i=new we({},Be),s=new Et;if(!St(s,r,e,t))return i.error=s.error,{offset:-1,result:i};if(!r.subarray(e,e+t).length)return i.error="Zero buffer length",{offset:-1,result:i};let a=i.idBlock.fromBER(r,e,t);if(i.idBlock.warnings.length&&i.warnings.concat(i.idBlock.warnings),a===-1)return i.error=i.idBlock.error,{offset:-1,result:i};if(e=a,t-=i.idBlock.blockLength,a=i.lenBlock.fromBER(r,e,t),i.lenBlock.warnings.length&&i.warnings.concat(i.lenBlock.warnings),a===-1)return i.error=i.lenBlock.error,{offset:-1,result:i};if(e=a,t-=i.lenBlock.blockLength,!i.idBlock.isConstructed&&i.lenBlock.isIndefiniteForm)return i.error="Indefinite length form used for primitive encoding form",{offset:-1,result:i};let c=we;switch(i.idBlock.tagClass){case 1:if(i.idBlock.tagNumber>=37&&i.idBlock.isHexOnly===!1)return i.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:i};switch(i.idBlock.tagNumber){case 0:if(i.idBlock.isConstructed&&i.lenBlock.length>0)return i.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:i};c=S.EndOfContent;break;case 1:c=S.Boolean;break;case 2:c=S.Integer;break;case 3:c=S.BitString;break;case 4:c=S.OctetString;break;case 5:c=S.Null;break;case 6:c=S.ObjectIdentifier;break;case 10:c=S.Enumerated;break;case 12:c=S.Utf8String;break;case 13:c=S.RelativeObjectIdentifier;break;case 14:c=S.TIME;break;case 15:return i.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:i};case 16:c=S.Sequence;break;case 17:c=S.Set;break;case 18:c=S.NumericString;break;case 19:c=S.PrintableString;break;case 20:c=S.TeletexString;break;case 21:c=S.VideotexString;break;case 22:c=S.IA5String;break;case 23:c=S.UTCTime;break;case 24:c=S.GeneralizedTime;break;case 25:c=S.GraphicString;break;case 26:c=S.VisibleString;break;case 27:c=S.GeneralString;break;case 28:c=S.UniversalString;break;case 29:c=S.CharacterString;break;case 30:c=S.BmpString;break;case 31:c=S.DATE;break;case 32:c=S.TimeOfDay;break;case 33:c=S.DateTime;break;case 34:c=S.Duration;break;default:{let l=i.idBlock.isConstructed?new S.Constructed:new S.Primitive;l.idBlock=i.idBlock,l.lenBlock=i.lenBlock,l.warnings=i.warnings,i=l}}break;case 2:case 3:case 4:default:c=i.idBlock.isConstructed?S.Constructed:S.Primitive}return i=Da(i,c),a=i.fromBER(r,e,i.lenBlock.isIndefiniteForm?t:i.lenBlock.length),i.valueBeforeDecodeView=r.subarray(n,n+i.blockLength),{offset:a,result:i}}function xo(r){if(!r.byteLength){let e=new we({},Be);return e.error="Input buffer has zero length",{offset:-1,result:e}}return Y1(H.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function Ma(r,e){return r?1:e}var ot=class extends Be{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n){let i=H.BufferSourceConverter.toUint8Array(e);if(!St(this,i,t,n))return-1;if(this.valueBeforeDecodeView=i.subarray(t,t+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),t;let s=t;for(;Ma(this.isIndefiniteForm,n)>0;){let o=Y1(i,s,n);if(o.offset===-1)return this.error=o.result.error,this.warnings.concat(o.result.warnings),-1;if(s=o.offset,this.blockLength+=o.result.blockLength,n-=o.result.blockLength,this.value.push(o.result),this.isIndefiniteForm&&o.result.constructor.NAME===un)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===un?this.value.pop():this.warnings.push("No EndOfContent block encoded")),s}toBER(e,t){let n=t||new ln;for(let i=0;i<this.value.length;i++)this.value[i].toBER(e,n);return t?Xe:n.final()}toJSON(){let e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let t of this.value)e.value.push(t.toJSON());return e}};ot.NAME="ConstructedValueBlock";var O0,Kt=class extends we{constructor(e={}){super(e,ot),this.idBlock.isConstructed=!0}fromBER(e,t,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;let i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}onAsciiEncoding(){let e=[];for(let n of this.valueBlock.value)e.push(n.toString("ascii").split(`
3
3
  `).map(i=>` ${i}`).join(`
4
4
  `));let t=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${t} :
5
5
  ${e.join(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/kad-dht",
3
- "version": "13.0.1-34455b5f2",
3
+ "version": "13.0.1-6ccbb06f0",
4
4
  "description": "JavaScript implementation of the Kad-DHT for libp2p",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/kad-dht#readme",
@@ -57,13 +57,13 @@
57
57
  "doc-check": "aegir doc-check"
58
58
  },
59
59
  "dependencies": {
60
- "@libp2p/crypto": "5.0.1-34455b5f2",
61
- "@libp2p/interface": "2.0.1-34455b5f2",
62
- "@libp2p/interface-internal": "2.0.1-34455b5f2",
63
- "@libp2p/peer-collections": "6.0.1-34455b5f2",
64
- "@libp2p/peer-id": "5.0.1-34455b5f2",
65
- "@libp2p/record": "4.0.4-34455b5f2",
66
- "@libp2p/utils": "6.0.1-34455b5f2",
60
+ "@libp2p/crypto": "5.0.1-6ccbb06f0",
61
+ "@libp2p/interface": "2.0.1-6ccbb06f0",
62
+ "@libp2p/interface-internal": "2.0.1-6ccbb06f0",
63
+ "@libp2p/peer-collections": "6.0.1-6ccbb06f0",
64
+ "@libp2p/peer-id": "5.0.1-6ccbb06f0",
65
+ "@libp2p/record": "4.0.4-6ccbb06f0",
66
+ "@libp2p/utils": "6.0.1-6ccbb06f0",
67
67
  "@multiformats/multiaddr": "^12.2.3",
68
68
  "any-signal": "^4.1.1",
69
69
  "hashlru": "^2.3.0",
@@ -89,9 +89,9 @@
89
89
  "uint8arrays": "^5.1.0"
90
90
  },
91
91
  "devDependencies": {
92
- "@libp2p/interface-compliance-tests": "6.0.1-34455b5f2",
93
- "@libp2p/logger": "5.0.1-34455b5f2",
94
- "@libp2p/peer-store": "11.0.1-34455b5f2",
92
+ "@libp2p/interface-compliance-tests": "6.0.1-6ccbb06f0",
93
+ "@libp2p/logger": "5.0.1-6ccbb06f0",
94
+ "@libp2p/peer-store": "11.0.1-6ccbb06f0",
95
95
  "@types/lodash.random": "^3.2.9",
96
96
  "@types/lodash.range": "^3.2.9",
97
97
  "@types/sinon": "^17.0.3",