@enbox/crypto 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -102
- package/dist/browser.js +6 -10
- package/dist/browser.js.map +4 -4
- package/dist/browser.mjs +6 -10
- package/dist/browser.mjs.map +4 -4
- package/dist/esm/algorithms/aes-gcm.js +1 -1
- package/dist/esm/algorithms/aes-gcm.js.map +1 -1
- package/dist/esm/algorithms/ecdsa.js +9 -5
- package/dist/esm/algorithms/ecdsa.js.map +1 -1
- package/dist/esm/algorithms/eddsa.js +9 -5
- package/dist/esm/algorithms/eddsa.js.map +1 -1
- package/dist/esm/algorithms/sha-2.js +1 -1
- package/dist/esm/algorithms/sha-2.js.map +1 -1
- package/dist/esm/crypto-error.js +41 -0
- package/dist/esm/crypto-error.js.map +1 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/jose/jwk.js +52 -26
- package/dist/esm/jose/jwk.js.map +1 -1
- package/dist/esm/local-key-manager.js +3 -2
- package/dist/esm/local-key-manager.js.map +1 -1
- package/dist/esm/primitives/aes-ctr.js.map +1 -1
- package/dist/esm/primitives/aes-gcm.js.map +1 -1
- package/dist/esm/primitives/aes-kw.js +246 -0
- package/dist/esm/primitives/aes-kw.js.map +1 -0
- package/dist/esm/primitives/concat-kdf.js +1 -1
- package/dist/esm/primitives/concat-kdf.js.map +1 -1
- package/dist/esm/primitives/ed25519.js +3 -3
- package/dist/esm/primitives/ed25519.js.map +1 -1
- package/dist/esm/primitives/hkdf.js +79 -0
- package/dist/esm/primitives/hkdf.js.map +1 -0
- package/dist/esm/primitives/pbkdf2.js +49 -0
- package/dist/esm/primitives/pbkdf2.js.map +1 -1
- package/dist/esm/primitives/secp256k1.js +4 -4
- package/dist/esm/primitives/secp256k1.js.map +1 -1
- package/dist/esm/primitives/secp256r1.js +4 -4
- package/dist/esm/primitives/secp256r1.js.map +1 -1
- package/dist/esm/primitives/x25519.js +1 -1
- package/dist/esm/primitives/x25519.js.map +1 -1
- package/dist/esm/primitives/xchacha20-poly1305.js +48 -3
- package/dist/esm/primitives/xchacha20-poly1305.js.map +1 -1
- package/dist/esm/primitives/xchacha20.js +1 -1
- package/dist/esm/primitives/xchacha20.js.map +1 -1
- package/dist/esm/utils.js.map +1 -1
- package/dist/types/algorithms/aes-ctr.d.ts +1 -1
- package/dist/types/algorithms/aes-ctr.d.ts.map +1 -1
- package/dist/types/algorithms/aes-gcm.d.ts +2 -2
- package/dist/types/algorithms/aes-gcm.d.ts.map +1 -1
- package/dist/types/algorithms/ecdsa.d.ts +1 -1
- package/dist/types/algorithms/ecdsa.d.ts.map +1 -1
- package/dist/types/algorithms/eddsa.d.ts +2 -2
- package/dist/types/algorithms/eddsa.d.ts.map +1 -1
- package/dist/types/algorithms/sha-2.d.ts +1 -1
- package/dist/types/algorithms/sha-2.d.ts.map +1 -1
- package/dist/types/crypto-error.d.ts +29 -0
- package/dist/types/crypto-error.d.ts.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/jose/jwk.d.ts.map +1 -1
- package/dist/types/local-key-manager.d.ts +3 -3
- package/dist/types/local-key-manager.d.ts.map +1 -1
- package/dist/types/primitives/aes-kw.d.ts +103 -0
- package/dist/types/primitives/aes-kw.d.ts.map +1 -0
- package/dist/types/primitives/concat-kdf.d.ts +1 -1
- package/dist/types/primitives/concat-kdf.d.ts.map +1 -1
- package/dist/types/primitives/hkdf.d.ts +90 -0
- package/dist/types/primitives/hkdf.d.ts.map +1 -0
- package/dist/types/primitives/pbkdf2.d.ts +58 -0
- package/dist/types/primitives/pbkdf2.d.ts.map +1 -1
- package/dist/types/primitives/xchacha20-poly1305.d.ts +47 -0
- package/dist/types/primitives/xchacha20-poly1305.d.ts.map +1 -1
- package/dist/types/types/cipher.d.ts +1 -1
- package/dist/types/types/crypto-api.d.ts +3 -3
- package/dist/types/types/crypto-api.d.ts.map +1 -1
- package/dist/types/types/params-direct.d.ts +79 -1
- package/dist/types/types/params-direct.d.ts.map +1 -1
- package/dist/utils.js.map +2 -2
- package/package.json +26 -39
- package/src/algorithms/aes-ctr.ts +1 -1
- package/src/algorithms/aes-gcm.ts +3 -2
- package/src/algorithms/ecdsa.ts +13 -7
- package/src/algorithms/eddsa.ts +9 -9
- package/src/algorithms/sha-2.ts +2 -2
- package/src/crypto-error.ts +45 -0
- package/src/index.ts +3 -0
- package/src/jose/jwk.ts +32 -32
- package/src/local-key-manager.ts +14 -13
- package/src/primitives/aes-ctr.ts +1 -1
- package/src/primitives/aes-gcm.ts +5 -5
- package/src/primitives/aes-kw.ts +269 -0
- package/src/primitives/concat-kdf.ts +4 -2
- package/src/primitives/ed25519.ts +6 -6
- package/src/primitives/hkdf.ts +121 -0
- package/src/primitives/pbkdf2.ts +91 -0
- package/src/primitives/secp256k1.ts +6 -6
- package/src/primitives/secp256r1.ts +6 -6
- package/src/primitives/x25519.ts +3 -3
- package/src/primitives/xchacha20-poly1305.ts +57 -4
- package/src/primitives/xchacha20.ts +1 -1
- package/src/types/cipher.ts +1 -1
- package/src/types/crypto-api.ts +5 -5
- package/src/types/params-direct.ts +97 -1
- package/src/utils.ts +2 -2
- package/dist/cjs/algorithms/aes-ctr.js +0 -188
- package/dist/cjs/algorithms/aes-ctr.js.map +0 -1
- package/dist/cjs/algorithms/aes-gcm.js +0 -196
- package/dist/cjs/algorithms/aes-gcm.js.map +0 -1
- package/dist/cjs/algorithms/crypto-algorithm.js +0 -13
- package/dist/cjs/algorithms/crypto-algorithm.js.map +0 -1
- package/dist/cjs/algorithms/ecdsa.js +0 -352
- package/dist/cjs/algorithms/ecdsa.js.map +0 -1
- package/dist/cjs/algorithms/eddsa.js +0 -325
- package/dist/cjs/algorithms/eddsa.js.map +0 -1
- package/dist/cjs/algorithms/sha-2.js +0 -119
- package/dist/cjs/algorithms/sha-2.js.map +0 -1
- package/dist/cjs/index.js +0 -41
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/jose/jwe.js +0 -3
- package/dist/cjs/jose/jwe.js.map +0 -1
- package/dist/cjs/jose/jwk.js +0 -278
- package/dist/cjs/jose/jwk.js.map +0 -1
- package/dist/cjs/jose/jws.js +0 -3
- package/dist/cjs/jose/jws.js.map +0 -1
- package/dist/cjs/jose/jwt.js +0 -3
- package/dist/cjs/jose/jwt.js.map +0 -1
- package/dist/cjs/jose/utils.js +0 -60
- package/dist/cjs/jose/utils.js.map +0 -1
- package/dist/cjs/local-key-manager.js +0 -521
- package/dist/cjs/local-key-manager.js.map +0 -1
- package/dist/cjs/package.json +0 -1
- package/dist/cjs/primitives/aes-ctr.js +0 -398
- package/dist/cjs/primitives/aes-ctr.js.map +0 -1
- package/dist/cjs/primitives/aes-gcm.js +0 -425
- package/dist/cjs/primitives/aes-gcm.js.map +0 -1
- package/dist/cjs/primitives/concat-kdf.js +0 -215
- package/dist/cjs/primitives/concat-kdf.js.map +0 -1
- package/dist/cjs/primitives/ed25519.js +0 -651
- package/dist/cjs/primitives/ed25519.js.map +0 -1
- package/dist/cjs/primitives/pbkdf2.js +0 -120
- package/dist/cjs/primitives/pbkdf2.js.map +0 -1
- package/dist/cjs/primitives/secp256k1.js +0 -958
- package/dist/cjs/primitives/secp256k1.js.map +0 -1
- package/dist/cjs/primitives/secp256r1.js +0 -959
- package/dist/cjs/primitives/secp256r1.js.map +0 -1
- package/dist/cjs/primitives/sha256.js +0 -93
- package/dist/cjs/primitives/sha256.js.map +0 -1
- package/dist/cjs/primitives/x25519.js +0 -498
- package/dist/cjs/primitives/x25519.js.map +0 -1
- package/dist/cjs/primitives/xchacha20-poly1305.js +0 -340
- package/dist/cjs/primitives/xchacha20-poly1305.js.map +0 -1
- package/dist/cjs/primitives/xchacha20.js +0 -316
- package/dist/cjs/primitives/xchacha20.js.map +0 -1
- package/dist/cjs/types/cipher.js +0 -3
- package/dist/cjs/types/cipher.js.map +0 -1
- package/dist/cjs/types/crypto-api.js +0 -3
- package/dist/cjs/types/crypto-api.js.map +0 -1
- package/dist/cjs/types/hasher.js +0 -3
- package/dist/cjs/types/hasher.js.map +0 -1
- package/dist/cjs/types/identifier.js +0 -3
- package/dist/cjs/types/identifier.js.map +0 -1
- package/dist/cjs/types/key-compressor.js +0 -3
- package/dist/cjs/types/key-compressor.js.map +0 -1
- package/dist/cjs/types/key-converter.js +0 -3
- package/dist/cjs/types/key-converter.js.map +0 -1
- package/dist/cjs/types/key-deriver.js +0 -3
- package/dist/cjs/types/key-deriver.js.map +0 -1
- package/dist/cjs/types/key-generator.js +0 -3
- package/dist/cjs/types/key-generator.js.map +0 -1
- package/dist/cjs/types/key-io.js +0 -3
- package/dist/cjs/types/key-io.js.map +0 -1
- package/dist/cjs/types/key-wrapper.js +0 -3
- package/dist/cjs/types/key-wrapper.js.map +0 -1
- package/dist/cjs/types/params-direct.js +0 -3
- package/dist/cjs/types/params-direct.js.map +0 -1
- package/dist/cjs/types/params-enclosed.js +0 -3
- package/dist/cjs/types/params-enclosed.js.map +0 -1
- package/dist/cjs/types/params-kms.js +0 -3
- package/dist/cjs/types/params-kms.js.map +0 -1
- package/dist/cjs/types/signer.js +0 -3
- package/dist/cjs/types/signer.js.map +0 -1
- package/dist/cjs/utils.js +0 -173
- package/dist/cjs/utils.js.map +0 -1
package/dist/browser.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
var a0=Object.create;var ks=Object.defineProperty;var c0=Object.getOwnPropertyDescriptor;var f0=Object.getOwnPropertyNames;var u0=Object.getPrototypeOf,l0=Object.prototype.hasOwnProperty;var M=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Yf=(t,e)=>{for(var r in e)ks(t,r,{get:e[r],enumerable:!0})},d0=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of f0(e))!l0.call(t,i)&&i!==r&&ks(t,i,{get:()=>e[i],enumerable:!(n=c0(e,i))||n.enumerable});return t};var ji=(t,e,r)=>(r=t!=null?a0(u0(t)):{},d0(e||!t||!t.__esModule?ks(r,"default",{value:t,enumerable:!0}):r,t));var Xf=M((R_,Zf)=>{var h0=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Fi=()=>h0.now(),p0=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),Ps=t=>t===1/0||p0(t),Is=class t{constructor({max:e=1/0,ttl:r,updateAgeOnGet:n=!1,checkAgeOnGet:i=!1,noUpdateTTL:o=!1,dispose:s,noDisposeOnSet:a=!1}={}){if(this.expirations=Object.create(null),this.data=new Map,this.expirationMap=new Map,r!==void 0&&!Ps(r))throw new TypeError("ttl must be positive integer or Infinity if set");if(!Ps(e))throw new TypeError("max must be positive integer or Infinity");if(this.ttl=r,this.max=e,this.updateAgeOnGet=!!n,this.checkAgeOnGet=!!i,this.noUpdateTTL=!!o,this.noDisposeOnSet=!!a,s!==void 0){if(typeof s!="function")throw new TypeError("dispose must be function if set");this.dispose=s}this.timer=void 0,this.timerExpiration=void 0}setTimer(e,r){if(this.timerExpiration<e)return;this.timer&&clearTimeout(this.timer);let n=setTimeout(()=>{this.timer=void 0,this.timerExpiration=void 0,this.purgeStale();for(let i in this.expirations){this.setTimer(i,i-Fi());break}},r);n.unref&&n.unref(),this.timerExpiration=e,this.timer=n}cancelTimer(){this.timer&&(clearTimeout(this.timer),this.timerExpiration=void 0,this.timer=void 0)}cancelTimers(){return process.emitWarning('TTLCache.cancelTimers has been renamed to TTLCache.cancelTimer (no "s"), and will be removed in the next major version update'),this.cancelTimer()}clear(){let e=this.dispose!==t.prototype.dispose?[...this]:[];this.data.clear(),this.expirationMap.clear(),this.cancelTimer(),this.expirations=Object.create(null);for(let[r,n]of e)this.dispose(n,r,"delete")}setTTL(e,r=this.ttl){let n=this.expirationMap.get(e);if(n!==void 0){let i=this.expirations[n];!i||i.length<=1?delete this.expirations[n]:this.expirations[n]=i.filter(o=>o!==e)}if(r!==1/0){let i=Math.floor(Fi()+r);this.expirationMap.set(e,i),this.expirations[i]||(this.expirations[i]=[],this.setTimer(i,r)),this.expirations[i].push(e)}else this.expirationMap.set(e,1/0)}set(e,r,{ttl:n=this.ttl,noUpdateTTL:i=this.noUpdateTTL,noDisposeOnSet:o=this.noDisposeOnSet}={}){if(!Ps(n))throw new TypeError("ttl must be positive integer or Infinity");if(this.expirationMap.has(e)){i||this.setTTL(e,n);let s=this.data.get(e);s!==r&&(this.data.set(e,r),o||this.dispose(s,e,"set"))}else this.setTTL(e,n),this.data.set(e,r);for(;this.size>this.max;)this.purgeToCapacity();return this}has(e){return this.data.has(e)}getRemainingTTL(e){let r=this.expirationMap.get(e);return r===1/0?r:r!==void 0?Math.max(0,Math.ceil(r-Fi())):0}get(e,{updateAgeOnGet:r=this.updateAgeOnGet,ttl:n=this.ttl,checkAgeOnGet:i=this.checkAgeOnGet}={}){let o=this.data.get(e);if(i&&this.getRemainingTTL(e)===0){this.delete(e);return}return r&&this.setTTL(e,n),o}dispose(e,r){}delete(e){let r=this.expirationMap.get(e);if(r!==void 0){let n=this.data.get(e);this.data.delete(e),this.expirationMap.delete(e);let i=this.expirations[r];return i&&(i.length<=1?delete this.expirations[r]:this.expirations[r]=i.filter(o=>o!==e)),this.dispose(n,e,"delete"),this.size===0&&this.cancelTimer(),!0}return!1}purgeToCapacity(){for(let e in this.expirations){let r=this.expirations[e];if(this.size-r.length>=this.max){delete this.expirations[e];let n=[];for(let i of r)n.push([i,this.data.get(i)]),this.data.delete(i),this.expirationMap.delete(i);for(let[i,o]of n)this.dispose(o,i,"evict")}else{let n=this.size-this.max,i=[];for(let o of r.splice(0,n))i.push([o,this.data.get(o)]),this.data.delete(o),this.expirationMap.delete(o);for(let[o,s]of i)this.dispose(s,o,"evict");return}}}get size(){return this.data.size}purgeStale(){let e=Math.ceil(Fi());for(let r in this.expirations){if(r==="Infinity"||r>e)return;let n=[...this.expirations[r]||[]],i=[];delete this.expirations[r];for(let o of n)i.push([o,this.data.get(o)]),this.data.delete(o),this.expirationMap.delete(o);for(let[o,s]of i)this.dispose(s,o,"stale")}this.size===0&&this.cancelTimer()}*entries(){for(let e in this.expirations)for(let r of this.expirations[e])yield[r,this.data.get(r)]}*keys(){for(let e in this.expirations)for(let r of this.expirations[e])yield r}*values(){for(let e in this.expirations)for(let r of this.expirations[e])yield this.data.get(r)}[Symbol.iterator](){return this.entries()}};Zf.exports=Is});var yu=M(pu=>{"use strict";pu.supports=function(...e){let r=e.reduce((n,i)=>Object.assign(n,i),{});return Object.assign(r,{snapshots:r.snapshots||!1,permanence:r.permanence||!1,seek:r.seek||!1,clear:r.clear||!1,getMany:r.getMany||!1,keyIterator:r.keyIterator||!1,valueIterator:r.valueIterator||!1,iteratorNextv:r.iteratorNextv||!1,iteratorAll:r.iteratorAll||!1,status:r.status||!1,createIfMissing:r.createIfMissing||!1,errorIfExists:r.errorIfExists||!1,deferredOpen:r.deferredOpen||!1,promises:r.promises||!1,streams:r.streams||!1,encodings:Object.assign({},r.encodings),events:Object.assign({},r.events),additionalMethods:Object.assign({},r.additionalMethods)})}});var ze=M((PA,wu)=>{"use strict";wu.exports=class extends Error{constructor(e,r){super(e||""),typeof r=="object"&&r!==null&&(r.code&&(this.code=String(r.code)),r.expected&&(this.expected=!0),r.transient&&(this.transient=!0),r.cause&&(this.cause=r.cause)),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}}});var gu=M(Vi=>{"use strict";Vi.byteLength=J0;Vi.toByteArray=Y0;Vi.fromByteArray=Q0;var at=[],Me=[],W0=typeof Uint8Array<"u"?Uint8Array:Array,Vs="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Ar=0,mu=Vs.length;Ar<mu;++Ar)at[Ar]=Vs[Ar],Me[Vs.charCodeAt(Ar)]=Ar;var Ar,mu;Me[45]=62;Me[95]=63;function bu(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var n=r===e?0:4-r%4;return[r,n]}function J0(t){var e=bu(t),r=e[0],n=e[1];return(r+n)*3/4-n}function z0(t,e,r){return(e+r)*3/4-r}function Y0(t){var e,r=bu(t),n=r[0],i=r[1],o=new W0(z0(t,n,i)),s=0,a=i>0?n-4:n,c;for(c=0;c<a;c+=4)e=Me[t.charCodeAt(c)]<<18|Me[t.charCodeAt(c+1)]<<12|Me[t.charCodeAt(c+2)]<<6|Me[t.charCodeAt(c+3)],o[s++]=e>>16&255,o[s++]=e>>8&255,o[s++]=e&255;return i===2&&(e=Me[t.charCodeAt(c)]<<2|Me[t.charCodeAt(c+1)]>>4,o[s++]=e&255),i===1&&(e=Me[t.charCodeAt(c)]<<10|Me[t.charCodeAt(c+1)]<<4|Me[t.charCodeAt(c+2)]>>2,o[s++]=e>>8&255,o[s++]=e&255),o}function Z0(t){return at[t>>18&63]+at[t>>12&63]+at[t>>6&63]+at[t&63]}function X0(t,e,r){for(var n,i=[],o=e;o<r;o+=3)n=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(t[o+2]&255),i.push(Z0(n));return i.join("")}function Q0(t){for(var e,r=t.length,n=r%3,i=[],o=16383,s=0,a=r-n;s<a;s+=o)i.push(X0(t,s,s+o>a?a:s+o));return n===1?(e=t[r-1],i.push(at[e>>2]+at[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(at[e>>10]+at[e>>4&63]+at[e<<2&63]+"=")),i.join("")}});var xu=M(Hs=>{Hs.read=function(t,e,r,n,i){var o,s,a=i*8-n-1,c=(1<<a)-1,f=c>>1,u=-7,l=r?i-1:0,p=r?-1:1,h=t[e+l];for(l+=p,o=h&(1<<-u)-1,h>>=-u,u+=a;u>0;o=o*256+t[e+l],l+=p,u-=8);for(s=o&(1<<-u)-1,o>>=-u,u+=n;u>0;s=s*256+t[e+l],l+=p,u-=8);if(o===0)o=1-f;else{if(o===c)return s?NaN:(h?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-f}return(h?-1:1)*s*Math.pow(2,o-n)};Hs.write=function(t,e,r,n,i,o){var s,a,c,f=o*8-i-1,u=(1<<f)-1,l=u>>1,p=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,h=n?0:o-1,y=n?1:-1,d=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=u):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),s+l>=1?e+=p/c:e+=p*Math.pow(2,1-l),e*c>=2&&(s++,c/=2),s+l>=u?(a=0,s=u):s+l>=1?(a=(e*c-1)*Math.pow(2,i),s=s+l):(a=e*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;t[r+h]=a&255,h+=y,a/=256,i-=8);for(s=s<<i|a,f+=i;f>0;t[r+h]=s&255,h+=y,s/=256,f-=8);t[r+h-y]|=d*128}});var qe=M(fn=>{"use strict";var Gs=gu(),an=xu(),Eu=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;fn.Buffer=x;fn.SlowBuffer=ow;fn.INSPECT_MAX_BYTES=50;var Hi=2147483647;fn.kMaxLength=Hi;x.TYPED_ARRAY_SUPPORT=ew();!x.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function ew(){try{let t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),t.foo()===42}catch{return!1}}Object.defineProperty(x.prototype,"parent",{enumerable:!0,get:function(){if(x.isBuffer(this))return this.buffer}});Object.defineProperty(x.prototype,"offset",{enumerable:!0,get:function(){if(x.isBuffer(this))return this.byteOffset}});function Bt(t){if(t>Hi)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,x.prototype),e}function x(t,e,r){if(typeof t=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Ys(t)}return vu(t,e,r)}x.poolSize=8192;function vu(t,e,r){if(typeof t=="string")return rw(t,e);if(ArrayBuffer.isView(t))return nw(t);if(t==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(ct(t,ArrayBuffer)||t&&ct(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(ct(t,SharedArrayBuffer)||t&&ct(t.buffer,SharedArrayBuffer)))return Js(t,e,r);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=t.valueOf&&t.valueOf();if(n!=null&&n!==t)return x.from(n,e,r);let i=iw(t);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return x.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}x.from=function(t,e,r){return vu(t,e,r)};Object.setPrototypeOf(x.prototype,Uint8Array.prototype);Object.setPrototypeOf(x,Uint8Array);function Bu(t){if(typeof t!="number")throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function tw(t,e,r){return Bu(t),t<=0?Bt(t):e!==void 0?typeof r=="string"?Bt(t).fill(e,r):Bt(t).fill(e):Bt(t)}x.alloc=function(t,e,r){return tw(t,e,r)};function Ys(t){return Bu(t),Bt(t<0?0:Zs(t)|0)}x.allocUnsafe=function(t){return Ys(t)};x.allocUnsafeSlow=function(t){return Ys(t)};function rw(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!x.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=Tu(t,e)|0,n=Bt(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function Ws(t){let e=t.length<0?0:Zs(t.length)|0,r=Bt(e);for(let n=0;n<e;n+=1)r[n]=t[n]&255;return r}function nw(t){if(ct(t,Uint8Array)){let e=new Uint8Array(t);return Js(e.buffer,e.byteOffset,e.byteLength)}return Ws(t)}function Js(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return e===void 0&&r===void 0?n=new Uint8Array(t):r===void 0?n=new Uint8Array(t,e):n=new Uint8Array(t,e,r),Object.setPrototypeOf(n,x.prototype),n}function iw(t){if(x.isBuffer(t)){let e=Zs(t.length)|0,r=Bt(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||Qs(t.length)?Bt(0):Ws(t);if(t.type==="Buffer"&&Array.isArray(t.data))return Ws(t.data)}function Zs(t){if(t>=Hi)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Hi.toString(16)+" bytes");return t|0}function ow(t){return+t!=t&&(t=0),x.alloc(+t)}x.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==x.prototype};x.compare=function(e,r){if(ct(e,Uint8Array)&&(e=x.from(e,e.offset,e.byteLength)),ct(r,Uint8Array)&&(r=x.from(r,r.offset,r.byteLength)),!x.isBuffer(e)||!x.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===r)return 0;let n=e.length,i=r.length;for(let o=0,s=Math.min(n,i);o<s;++o)if(e[o]!==r[o]){n=e[o],i=r[o];break}return n<i?-1:i<n?1:0};x.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};x.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return x.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;let i=x.allocUnsafe(r),o=0;for(n=0;n<e.length;++n){let s=e[n];if(ct(s,Uint8Array))o+s.length>i.length?(x.isBuffer(s)||(s=x.from(s)),s.copy(i,o)):Uint8Array.prototype.set.call(i,s,o);else if(x.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function Tu(t,e){if(x.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||ct(t,ArrayBuffer))return t.byteLength;if(typeof t!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);let r=t.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return zs(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Ku(t).length;default:if(i)return n?-1:zs(t).length;e=(""+e).toLowerCase(),i=!0}}x.byteLength=Tu;function sw(t,e,r){let n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,e>>>=0,r<=e))return"";for(t||(t="utf8");;)switch(t){case"hex":return ww(this,e,r);case"utf8":case"utf-8":return Pu(this,e,r);case"ascii":return pw(this,e,r);case"latin1":case"binary":return yw(this,e,r);case"base64":return dw(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return mw(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}x.prototype._isBuffer=!0;function Sr(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}x.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<e;r+=2)Sr(this,r,r+1);return this};x.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<e;r+=4)Sr(this,r,r+3),Sr(this,r+1,r+2);return this};x.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<e;r+=8)Sr(this,r,r+7),Sr(this,r+1,r+6),Sr(this,r+2,r+5),Sr(this,r+3,r+4);return this};x.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?Pu(this,0,e):sw.apply(this,arguments)};x.prototype.toLocaleString=x.prototype.toString;x.prototype.equals=function(e){if(!x.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:x.compare(this,e)===0};x.prototype.inspect=function(){let e="",r=fn.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};Eu&&(x.prototype[Eu]=x.prototype.inspect);x.prototype.compare=function(e,r,n,i,o){if(ct(e,Uint8Array)&&(e=x.from(e,e.offset,e.byteLength)),!x.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(r===void 0&&(r=0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),r<0||n>e.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&r>=n)return 0;if(i>=o)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,o>>>=0,this===e)return 0;let s=o-i,a=n-r,c=Math.min(s,a),f=this.slice(i,o),u=e.slice(r,n);for(let l=0;l<c;++l)if(f[l]!==u[l]){s=f[l],a=u[l];break}return s<a?-1:a<s?1:0};function ku(t,e,r,n,i){if(t.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,Qs(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof e=="string"&&(e=x.from(e,n)),x.isBuffer(e))return e.length===0?-1:_u(t,e,r,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):_u(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function _u(t,e,r,n,i){let o=1,s=t.length,a=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||e.length<2)return-1;o=2,s/=2,a/=2,r/=2}function c(u,l){return o===1?u[l]:u.readUInt16BE(l*o)}let f;if(i){let u=-1;for(f=r;f<s;f++)if(c(t,f)===c(e,u===-1?0:f-u)){if(u===-1&&(u=f),f-u+1===a)return u*o}else u!==-1&&(f-=f-u),u=-1}else for(r+a>s&&(r=s-a),f=r;f>=0;f--){let u=!0;for(let l=0;l<a;l++)if(c(t,f+l)!==c(e,l)){u=!1;break}if(u)return f}return-1}x.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};x.prototype.indexOf=function(e,r,n){return ku(this,e,r,n,!0)};x.prototype.lastIndexOf=function(e,r,n){return ku(this,e,r,n,!1)};function aw(t,e,r,n){r=Number(r)||0;let i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let o=e.length;n>o/2&&(n=o/2);let s;for(s=0;s<n;++s){let a=parseInt(e.substr(s*2,2),16);if(Qs(a))return s;t[r+s]=a}return s}function cw(t,e,r,n){return Gi(zs(e,t.length-r),t,r,n)}function fw(t,e,r,n){return Gi(Ew(e),t,r,n)}function uw(t,e,r,n){return Gi(Ku(e),t,r,n)}function lw(t,e,r,n){return Gi(_w(e,t.length-r),t,r,n)}x.prototype.write=function(e,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-r;if((n===void 0||n>o)&&(n=o),e.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let s=!1;for(;;)switch(i){case"hex":return aw(this,e,r,n);case"utf8":case"utf-8":return cw(this,e,r,n);case"ascii":case"latin1":case"binary":return fw(this,e,r,n);case"base64":return uw(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return lw(this,e,r,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};x.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function dw(t,e,r){return e===0&&r===t.length?Gs.fromByteArray(t):Gs.fromByteArray(t.slice(e,r))}function Pu(t,e,r){r=Math.min(t.length,r);let n=[],i=e;for(;i<r;){let o=t[i],s=null,a=o>239?4:o>223?3:o>191?2:1;if(i+a<=r){let c,f,u,l;switch(a){case 1:o<128&&(s=o);break;case 2:c=t[i+1],(c&192)===128&&(l=(o&31)<<6|c&63,l>127&&(s=l));break;case 3:c=t[i+1],f=t[i+2],(c&192)===128&&(f&192)===128&&(l=(o&15)<<12|(c&63)<<6|f&63,l>2047&&(l<55296||l>57343)&&(s=l));break;case 4:c=t[i+1],f=t[i+2],u=t[i+3],(c&192)===128&&(f&192)===128&&(u&192)===128&&(l=(o&15)<<18|(c&63)<<12|(f&63)<<6|u&63,l>65535&&l<1114112&&(s=l))}}s===null?(s=65533,a=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),i+=a}return hw(n)}var Au=4096;function hw(t){let e=t.length;if(e<=Au)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Au));return r}function pw(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]&127);return n}function yw(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function ww(t,e,r){let n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let o=e;o<r;++o)i+=Aw[t[o]];return i}function mw(t,e,r){let n=t.slice(e,r),i="";for(let o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}x.prototype.slice=function(e,r){let n=this.length;e=~~e,r=r===void 0?n:~~r,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<e&&(r=e);let i=this.subarray(e,r);return Object.setPrototypeOf(i,x.prototype),i};function me(t,e,r){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}x.prototype.readUintLE=x.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||me(e,r,this.length);let i=this[e],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[e+s]*o;return i};x.prototype.readUintBE=x.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||me(e,r,this.length);let i=this[e+--r],o=1;for(;r>0&&(o*=256);)i+=this[e+--r]*o;return i};x.prototype.readUint8=x.prototype.readUInt8=function(e,r){return e=e>>>0,r||me(e,1,this.length),this[e]};x.prototype.readUint16LE=x.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||me(e,2,this.length),this[e]|this[e+1]<<8};x.prototype.readUint16BE=x.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||me(e,2,this.length),this[e]<<8|this[e+1]};x.prototype.readUint32LE=x.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||me(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};x.prototype.readUint32BE=x.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||me(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};x.prototype.readBigUInt64LE=Jt(function(e){e=e>>>0,cn(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Xn(e,this.length-8);let i=r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,o=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(i)+(BigInt(o)<<BigInt(32))});x.prototype.readBigUInt64BE=Jt(function(e){e=e>>>0,cn(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Xn(e,this.length-8);let i=r*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],o=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(o)});x.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||me(e,r,this.length);let i=this[e],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[e+s]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*r)),i};x.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||me(e,r,this.length);let i=r,o=1,s=this[e+--i];for(;i>0&&(o*=256);)s+=this[e+--i]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*r)),s};x.prototype.readInt8=function(e,r){return e=e>>>0,r||me(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};x.prototype.readInt16LE=function(e,r){e=e>>>0,r||me(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};x.prototype.readInt16BE=function(e,r){e=e>>>0,r||me(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};x.prototype.readInt32LE=function(e,r){return e=e>>>0,r||me(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};x.prototype.readInt32BE=function(e,r){return e=e>>>0,r||me(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};x.prototype.readBigInt64LE=Jt(function(e){e=e>>>0,cn(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Xn(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});x.prototype.readBigInt64BE=Jt(function(e){e=e>>>0,cn(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Xn(e,this.length-8);let i=(r<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(i)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)});x.prototype.readFloatLE=function(e,r){return e=e>>>0,r||me(e,4,this.length),an.read(this,e,!0,23,4)};x.prototype.readFloatBE=function(e,r){return e=e>>>0,r||me(e,4,this.length),an.read(this,e,!1,23,4)};x.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||me(e,8,this.length),an.read(this,e,!0,52,8)};x.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||me(e,8,this.length),an.read(this,e,!1,52,8)};function Ie(t,e,r,n,i,o){if(!x.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}x.prototype.writeUintLE=x.prototype.writeUIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;Ie(this,e,r,n,a,0)}let o=1,s=0;for(this[r]=e&255;++s<n&&(o*=256);)this[r+s]=e/o&255;return r+n};x.prototype.writeUintBE=x.prototype.writeUIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;Ie(this,e,r,n,a,0)}let o=n-1,s=1;for(this[r+o]=e&255;--o>=0&&(s*=256);)this[r+o]=e/s&255;return r+n};x.prototype.writeUint8=x.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||Ie(this,e,r,1,255,0),this[r]=e&255,r+1};x.prototype.writeUint16LE=x.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||Ie(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};x.prototype.writeUint16BE=x.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||Ie(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};x.prototype.writeUint32LE=x.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||Ie(this,e,r,4,4294967295,0),this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=e&255,r+4};x.prototype.writeUint32BE=x.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||Ie(this,e,r,4,4294967295,0),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};function Iu(t,e,r,n,i){Ou(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s,r}function Ru(t,e,r,n,i){Ou(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o=o>>8,t[r+6]=o,o=o>>8,t[r+5]=o,o=o>>8,t[r+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=s,s=s>>8,t[r+2]=s,s=s>>8,t[r+1]=s,s=s>>8,t[r]=s,r+8}x.prototype.writeBigUInt64LE=Jt(function(e,r=0){return Iu(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});x.prototype.writeBigUInt64BE=Jt(function(e,r=0){return Ru(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});x.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);Ie(this,e,r,n,c-1,-c)}let o=0,s=1,a=0;for(this[r]=e&255;++o<n&&(s*=256);)e<0&&a===0&&this[r+o-1]!==0&&(a=1),this[r+o]=(e/s>>0)-a&255;return r+n};x.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);Ie(this,e,r,n,c-1,-c)}let o=n-1,s=1,a=0;for(this[r+o]=e&255;--o>=0&&(s*=256);)e<0&&a===0&&this[r+o+1]!==0&&(a=1),this[r+o]=(e/s>>0)-a&255;return r+n};x.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||Ie(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};x.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||Ie(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};x.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||Ie(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};x.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||Ie(this,e,r,4,2147483647,-2147483648),this[r]=e&255,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24,r+4};x.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||Ie(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};x.prototype.writeBigInt64LE=Jt(function(e,r=0){return Iu(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});x.prototype.writeBigInt64BE=Jt(function(e,r=0){return Ru(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Uu(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Cu(t,e,r,n,i){return e=+e,r=r>>>0,i||Uu(t,e,r,4,34028234663852886e22,-34028234663852886e22),an.write(t,e,r,n,23,4),r+4}x.prototype.writeFloatLE=function(e,r,n){return Cu(this,e,r,!0,n)};x.prototype.writeFloatBE=function(e,r,n){return Cu(this,e,r,!1,n)};function Lu(t,e,r,n,i){return e=+e,r=r>>>0,i||Uu(t,e,r,8,17976931348623157e292,-17976931348623157e292),an.write(t,e,r,n,52,8),r+8}x.prototype.writeDoubleLE=function(e,r,n){return Lu(this,e,r,!0,n)};x.prototype.writeDoubleBE=function(e,r,n){return Lu(this,e,r,!1,n)};x.prototype.copy=function(e,r,n,i){if(!x.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=e.length&&(r=e.length),r||(r=0),i>0&&i<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-r<i-n&&(i=e.length-r+n);let o=i-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(e,this.subarray(n,i),r),o};x.prototype.fill=function(e,r,n,i){if(typeof e=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!x.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(e.length===1){let s=e.charCodeAt(0);(i==="utf8"&&s<128||i==="latin1")&&(e=s)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let o;if(typeof e=="number")for(o=r;o<n;++o)this[o]=e;else{let s=x.isBuffer(e)?e:x.from(e,i),a=s.length;if(a===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<n-r;++o)this[o+r]=s[o%a]}return this};var sn={};function Xs(t,e,r){sn[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}Xs("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Xs("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);Xs("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=Su(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=Su(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function Su(t){let e="",r=t.length,n=t[0]==="-"?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function bw(t,e,r){cn(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&Xn(e,t.length-(r+1))}function Ou(t,e,r,n,i,o){if(t>r||t<e){let s=typeof e=="bigint"?"n":"",a;throw o>3?e===0||e===BigInt(0)?a=`>= 0${s} and < 2${s} ** ${(o+1)*8}${s}`:a=`>= -(2${s} ** ${(o+1)*8-1}${s}) and < 2 ** ${(o+1)*8-1}${s}`:a=`>= ${e}${s} and <= ${r}${s}`,new sn.ERR_OUT_OF_RANGE("value",a,t)}bw(n,i,o)}function cn(t,e){if(typeof t!="number")throw new sn.ERR_INVALID_ARG_TYPE(e,"number",t)}function Xn(t,e,r){throw Math.floor(t)!==t?(cn(t,r),new sn.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new sn.ERR_BUFFER_OUT_OF_BOUNDS:new sn.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var gw=/[^+/0-9A-Za-z-_]/g;function xw(t){if(t=t.split("=")[0],t=t.trim().replace(gw,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function zs(t,e){e=e||1/0;let r,n=t.length,i=null,o=[];for(let s=0;s<n;++s){if(r=t.charCodeAt(s),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}else if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return o}function Ew(t){let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function _w(t,e){let r,n,i,o=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}function Ku(t){return Gs.toByteArray(xw(t))}function Gi(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function ct(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function Qs(t){return t!==t}var Aw=function(){let t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function Jt(t){return typeof BigInt>"u"?Sw:t}function Sw(){throw new Error("BigInt not supported")}});var ta=M((LA,Nu)=>{"use strict";var ea=null;Nu.exports=function(){return ea===null&&(ea={textEncoder:new TextEncoder,textDecoder:new TextDecoder}),ea}});var ia=M(Du=>{"use strict";var ra=ze(),vw=new Set(["buffer","view","utf8"]),na=class{constructor(e){if(this.encode=e.encode||this.encode,this.decode=e.decode||this.decode,this.name=e.name||this.name,this.format=e.format||this.format,typeof this.encode!="function")throw new TypeError("The 'encode' property must be a function");if(typeof this.decode!="function")throw new TypeError("The 'decode' property must be a function");if(this.encode=this.encode.bind(this),this.decode=this.decode.bind(this),typeof this.name!="string"||this.name==="")throw new TypeError("The 'name' property must be a string");if(typeof this.format!="string"||!vw.has(this.format))throw new TypeError("The 'format' property must be one of 'buffer', 'view', 'utf8'");e.createViewTranscoder&&(this.createViewTranscoder=e.createViewTranscoder),e.createBufferTranscoder&&(this.createBufferTranscoder=e.createBufferTranscoder),e.createUTF8Transcoder&&(this.createUTF8Transcoder=e.createUTF8Transcoder)}get commonName(){return this.name.split("+")[0]}createBufferTranscoder(){throw new ra(`Encoding '${this.name}' cannot be transcoded to 'buffer'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createViewTranscoder(){throw new ra(`Encoding '${this.name}' cannot be transcoded to 'view'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createUTF8Transcoder(){throw new ra(`Encoding '${this.name}' cannot be transcoded to 'utf8'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}};Du.Encoding=na});var ca=M(Wi=>{"use strict";var{Buffer:sa}=qe()||{},{Encoding:aa}=ia(),Bw=ta(),Qn=class extends aa{constructor(e){super({...e,format:"buffer"})}createViewTranscoder(){return new ei({encode:this.encode,decode:e=>this.decode(sa.from(e.buffer,e.byteOffset,e.byteLength)),name:`${this.name}+view`})}createBufferTranscoder(){return this}},ei=class extends aa{constructor(e){super({...e,format:"view"})}createBufferTranscoder(){return new Qn({encode:e=>{let r=this.encode(e);return sa.from(r.buffer,r.byteOffset,r.byteLength)},decode:this.decode,name:`${this.name}+buffer`})}createViewTranscoder(){return this}},oa=class extends aa{constructor(e){super({...e,format:"utf8"})}createBufferTranscoder(){return new Qn({encode:e=>sa.from(this.encode(e),"utf8"),decode:e=>this.decode(e.toString("utf8")),name:`${this.name}+buffer`})}createViewTranscoder(){let{textEncoder:e,textDecoder:r}=Bw();return new ei({encode:n=>e.encode(this.encode(n)),decode:n=>this.decode(r.decode(n)),name:`${this.name}+view`})}createUTF8Transcoder(){return this}};Wi.BufferFormat=Qn;Wi.ViewFormat=ei;Wi.UTF8Format=oa});var Fu=M(vr=>{"use strict";var{Buffer:Ae}=qe()||{Buffer:{isBuffer:()=>!1}},{textEncoder:qu,textDecoder:Mu}=ta()(),{BufferFormat:ti,ViewFormat:fa,UTF8Format:ju}=ca(),Ji=t=>t;vr.utf8=new ju({encode:function(t){return Ae.isBuffer(t)?t.toString("utf8"):ArrayBuffer.isView(t)?Mu.decode(t):String(t)},decode:Ji,name:"utf8",createViewTranscoder(){return new fa({encode:function(t){return ArrayBuffer.isView(t)?t:qu.encode(t)},decode:function(t){return Mu.decode(t)},name:`${this.name}+view`})},createBufferTranscoder(){return new ti({encode:function(t){return Ae.isBuffer(t)?t:ArrayBuffer.isView(t)?Ae.from(t.buffer,t.byteOffset,t.byteLength):Ae.from(String(t),"utf8")},decode:function(t){return t.toString("utf8")},name:`${this.name}+buffer`})}});vr.json=new ju({encode:JSON.stringify,decode:JSON.parse,name:"json"});vr.buffer=new ti({encode:function(t){return Ae.isBuffer(t)?t:ArrayBuffer.isView(t)?Ae.from(t.buffer,t.byteOffset,t.byteLength):Ae.from(String(t),"utf8")},decode:Ji,name:"buffer",createViewTranscoder(){return new fa({encode:function(t){return ArrayBuffer.isView(t)?t:Ae.from(String(t),"utf8")},decode:function(t){return Ae.from(t.buffer,t.byteOffset,t.byteLength)},name:`${this.name}+view`})}});vr.view=new fa({encode:function(t){return ArrayBuffer.isView(t)?t:qu.encode(t)},decode:Ji,name:"view",createBufferTranscoder(){return new ti({encode:function(t){return Ae.isBuffer(t)?t:ArrayBuffer.isView(t)?Ae.from(t.buffer,t.byteOffset,t.byteLength):Ae.from(String(t),"utf8")},decode:Ji,name:`${this.name}+buffer`})}});vr.hex=new ti({encode:function(t){return Ae.isBuffer(t)?t:Ae.from(String(t),"hex")},decode:function(t){return t.toString("hex")},name:"hex"});vr.base64=new ti({encode:function(t){return Ae.isBuffer(t)?t:Ae.from(String(t),"base64")},decode:function(t){return t.toString("base64")},name:"base64"})});var Hu=M(Vu=>{"use strict";var $u=ze(),Yi=Fu(),{Encoding:Tw}=ia(),{BufferFormat:kw,ViewFormat:Pw,UTF8Format:Iw}=ca(),ri=Symbol("formats"),zi=Symbol("encodings"),Rw=new Set(["buffer","view","utf8"]),ua=class{constructor(e){if(Array.isArray(e)){if(!e.every(r=>Rw.has(r)))throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'")}else throw new TypeError("The first argument 'formats' must be an array");this[zi]=new Map,this[ri]=new Set(e);for(let r in Yi)try{this.encoding(r)}catch(n){if(n.code!=="LEVEL_ENCODING_NOT_SUPPORTED")throw n}}encodings(){return Array.from(new Set(this[zi].values()))}encoding(e){let r=this[zi].get(e);if(r===void 0){if(typeof e=="string"&&e!==""){if(r=Ow[e],!r)throw new $u(`Encoding '${e}' is not found`,{code:"LEVEL_ENCODING_NOT_FOUND"})}else{if(typeof e!="object"||e===null)throw new TypeError("First argument 'encoding' must be a string or object");r=Uw(e)}let{name:n,format:i}=r;if(!this[ri].has(i))if(this[ri].has("view"))r=r.createViewTranscoder();else if(this[ri].has("buffer"))r=r.createBufferTranscoder();else if(this[ri].has("utf8"))r=r.createUTF8Transcoder();else throw new $u(`Encoding '${n}' cannot be transcoded`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"});for(let o of[e,n,r.name,r.commonName])this[zi].set(o,r)}return r}};Vu.Transcoder=ua;function Uw(t){if(t instanceof Tw)return t;let e="type"in t&&typeof t.type=="string"?t.type:void 0,r=t.name||e||`anonymous-${Kw++}`;switch(Cw(t)){case"view":return new Pw({...t,name:r});case"utf8":return new Iw({...t,name:r});case"buffer":return new kw({...t,name:r});default:throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'")}}function Cw(t){return"format"in t&&t.format!==void 0?t.format:"buffer"in t&&typeof t.buffer=="boolean"?t.buffer?"buffer":"utf8":"code"in t&&Number.isInteger(t.code)?"view":"buffer"}var Lw={binary:Yi.buffer,"utf-8":Yi.utf8},Ow={...Yi,...Lw},Kw=0});var ln=M((MA,la)=>{"use strict";var un=typeof Reflect=="object"?Reflect:null,Gu=un&&typeof un.apply=="function"?un.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},Zi;un&&typeof un.ownKeys=="function"?Zi=un.ownKeys:Object.getOwnPropertySymbols?Zi=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Zi=function(e){return Object.getOwnPropertyNames(e)};function Nw(t){console&&console.warn&&console.warn(t)}var Ju=Number.isNaN||function(e){return e!==e};function re(){re.init.call(this)}la.exports=re;la.exports.once=jw;re.EventEmitter=re;re.prototype._events=void 0;re.prototype._eventsCount=0;re.prototype._maxListeners=void 0;var Wu=10;function Xi(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(re,"defaultMaxListeners",{enumerable:!0,get:function(){return Wu},set:function(t){if(typeof t!="number"||t<0||Ju(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Wu=t}});re.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};re.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Ju(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function zu(t){return t._maxListeners===void 0?re.defaultMaxListeners:t._maxListeners}re.prototype.getMaxListeners=function(){return zu(this)};re.prototype.emit=function(e){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=e==="error",o=this._events;if(o!==void 0)i=i&&o.error===void 0;else if(!i)return!1;if(i){var s;if(r.length>0&&(s=r[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=o[e];if(c===void 0)return!1;if(typeof c=="function")Gu(c,this,r);else for(var f=c.length,u=el(c,f),n=0;n<f;++n)Gu(u[n],this,r);return!0};function Yu(t,e,r,n){var i,o,s;if(Xi(r),o=t._events,o===void 0?(o=t._events=Object.create(null),t._eventsCount=0):(o.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),o=t._events),s=o[e]),s===void 0)s=o[e]=r,++t._eventsCount;else if(typeof s=="function"?s=o[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),i=zu(t),i>0&&s.length>i&&!s.warned){s.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=t,a.type=e,a.count=s.length,Nw(a)}return t}re.prototype.addListener=function(e,r){return Yu(this,e,r,!1)};re.prototype.on=re.prototype.addListener;re.prototype.prependListener=function(e,r){return Yu(this,e,r,!0)};function Dw(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Zu(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=Dw.bind(n);return i.listener=r,n.wrapFn=i,i}re.prototype.once=function(e,r){return Xi(r),this.on(e,Zu(this,e,r)),this};re.prototype.prependOnceListener=function(e,r){return Xi(r),this.prependListener(e,Zu(this,e,r)),this};re.prototype.removeListener=function(e,r){var n,i,o,s,a;if(Xi(r),i=this._events,i===void 0)return this;if(n=i[e],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(o=-1,s=n.length-1;s>=0;s--)if(n[s]===r||n[s].listener===r){a=n[s].listener,o=s;break}if(o<0)return this;o===0?n.shift():Mw(n,o),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this};re.prototype.off=re.prototype.removeListener;re.prototype.removeAllListeners=function(e){var r,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var o=Object.keys(n),s;for(i=0;i<o.length;++i)s=o[i],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(i=r.length-1;i>=0;i--)this.removeListener(e,r[i]);return this};function Xu(t,e,r){var n=t._events;if(n===void 0)return[];var i=n[e];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?qw(i):el(i,i.length)}re.prototype.listeners=function(e){return Xu(this,e,!0)};re.prototype.rawListeners=function(e){return Xu(this,e,!1)};re.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Qu.call(t,e)};re.prototype.listenerCount=Qu;function Qu(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}re.prototype.eventNames=function(){return this._eventsCount>0?Zi(this._events):[]};function el(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function Mw(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function qw(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function jw(t,e){return new Promise(function(r,n){function i(s){t.removeListener(e,o),n(s)}function o(){typeof t.removeListener=="function"&&t.removeListener("error",i),r([].slice.call(arguments))}tl(t,e,o,{once:!0}),e!=="error"&&Fw(t,i,{once:!0})})}function Fw(t,e,r){typeof t.on=="function"&&tl(t,"error",e,r)}function tl(t,e,r,n){if(typeof t.on=="function")n.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function i(o){n.once&&t.removeEventListener(e,i),r(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}});var nl=M((qA,rl)=>{rl.exports=typeof queueMicrotask=="function"?queueMicrotask:t=>Promise.resolve().then(t)});var ni=M(da=>{"use strict";var il=nl();da.fromCallback=function(t,e){if(t===void 0){var r=new Promise(function(n,i){t=function(o,s){o?i(o):n(s)}});t[e!==void 0?e:"promise"]=r}else if(typeof t!="function")throw new TypeError("Callback must be a function");return t};da.fromPromise=function(t,e){if(e===void 0)return t;t.then(function(r){il(()=>e(null,r))}).catch(function(r){il(()=>e(r))})}});var Qi=M(ha=>{"use strict";ha.getCallback=function(t,e){return typeof t=="function"?t:e};ha.getOptions=function(t,e){return typeof t=="object"&&t!==null?t:e!==void 0?e:{}}});var er=M(no=>{"use strict";var{fromCallback:pa}=ni(),Le=ze(),{getOptions:ya,getCallback:ol}=Qi(),Br=Symbol("promise"),dn=Symbol("callback"),ft=Symbol("working"),Tr=Symbol("handleOne"),Tt=Symbol("handleMany"),wa=Symbol("autoClose"),Xt=Symbol("finishWork"),ut=Symbol("returnMany"),zt=Symbol("closing"),ii=Symbol("handleClose"),eo=Symbol("closed"),oi=Symbol("closeCallbacks"),Zt=Symbol("keyEncoding"),kr=Symbol("valueEncoding"),ma=Symbol("abortOnClose"),to=Symbol("legacy"),ba=Symbol("keys"),ga=Symbol("values"),Yt=Symbol("limit"),je=Symbol("count"),ro=Object.freeze({}),$w=()=>{},sl=!1,si=class{constructor(e,r,n){if(typeof e!="object"||e===null){let i=e===null?"null":typeof e;throw new TypeError(`The first argument must be an abstract-level database, received ${i}`)}if(typeof r!="object"||r===null)throw new TypeError("The second argument must be an options object");this[eo]=!1,this[oi]=[],this[ft]=!1,this[zt]=!1,this[wa]=!1,this[dn]=null,this[Tr]=this[Tr].bind(this),this[Tt]=this[Tt].bind(this),this[ii]=this[ii].bind(this),this[Zt]=r[Zt],this[kr]=r[kr],this[to]=n,this[Yt]=Number.isInteger(r.limit)&&r.limit>=0?r.limit:1/0,this[je]=0,this[ma]=!!r.abortOnClose,this.db=e,this.db.attachResource(this),this.nextTick=e.nextTick}get count(){return this[je]}get limit(){return this[Yt]}next(e){let r;if(e===void 0)r=new Promise((n,i)=>{e=(o,s,a)=>{o?i(o):this[to]?s===void 0&&a===void 0?n():n([s,a]):n(s)}});else if(typeof e!="function")throw new TypeError("Callback must be a function");return this[zt]?this.nextTick(e,new Le("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[ft]?this.nextTick(e,new Le("Iterator is busy: cannot call next() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[ft]=!0,this[dn]=e,this[je]>=this[Yt]?this.nextTick(this[Tr],null):this._next(this[Tr])),r}_next(e){this.nextTick(e)}nextv(e,r,n){return n=ol(r,n),n=pa(n,Br),r=ya(r,ro),Number.isInteger(e)?(this[zt]?this.nextTick(n,new Le("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[ft]?this.nextTick(n,new Le("Iterator is busy: cannot call nextv() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(e<1&&(e=1),this[Yt]<1/0&&(e=Math.min(e,this[Yt]-this[je])),this[ft]=!0,this[dn]=n,e<=0?this.nextTick(this[Tt],null,[]):this._nextv(e,r,this[Tt])),n[Br]):(this.nextTick(n,new TypeError("The first argument 'size' must be an integer")),n[Br])}_nextv(e,r,n){let i=[],o=(s,a,c)=>{if(s)return n(s);if(this[to]?a===void 0&&c===void 0:a===void 0)return n(null,i);i.push(this[to]?[a,c]:a),i.length===e?n(null,i):this._next(o)};this._next(o)}all(e,r){return r=ol(e,r),r=pa(r,Br),e=ya(e,ro),this[zt]?this.nextTick(r,new Le("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[ft]?this.nextTick(r,new Le("Iterator is busy: cannot call all() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[ft]=!0,this[dn]=r,this[wa]=!0,this[je]>=this[Yt]?this.nextTick(this[Tt],null,[]):this._all(e,this[Tt])),r[Br]}_all(e,r){let n=this[je],i=[],o=()=>{let a=this[Yt]<1/0?Math.min(1e3,this[Yt]-n):1e3;a<=0?this.nextTick(r,null,i):this._nextv(a,ro,s)},s=(a,c)=>{a?r(a):c.length===0?r(null,i):(i.push.apply(i,c),n+=c.length,o())};o()}[Xt](){let e=this[dn];return this[ma]&&e===null?$w:(this[ft]=!1,this[dn]=null,this[zt]&&this._close(this[ii]),e)}[ut](e,r,n){this[wa]?this.close(e.bind(null,r,n)):e(r,n)}seek(e,r){if(r=ya(r,ro),!this[zt]){if(this[ft])throw new Le("Iterator is busy: cannot call seek() until next() has completed",{code:"LEVEL_ITERATOR_BUSY"});{let n=this.db.keyEncoding(r.keyEncoding||this[Zt]),i=n.format;r.keyEncoding!==i&&(r={...r,keyEncoding:i});let o=this.db.prefixKey(n.encode(e),i);this._seek(o,r)}}}_seek(e,r){throw new Le("Iterator does not support seek()",{code:"LEVEL_NOT_SUPPORTED"})}close(e){return e=pa(e,Br),this[eo]?this.nextTick(e):this[zt]?this[oi].push(e):(this[zt]=!0,this[oi].push(e),this[ft]?this[ma]&&this[Xt]()(new Le("Aborted on iterator close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this._close(this[ii])),e[Br]}_close(e){this.nextTick(e)}[ii](){this[eo]=!0,this.db.detachResource(this);let e=this[oi];this[oi]=[];for(let r of e)r()}async*[Symbol.asyncIterator](){try{let e;for(;(e=await this.next())!==void 0;)yield e}finally{this[eo]||await this.close()}}},hn=class extends si{constructor(e,r){super(e,r,!0),this[ba]=r.keys!==!1,this[ga]=r.values!==!1}[Tr](e,r,n){let i=this[Xt]();if(e)return i(e);try{r=this[ba]&&r!==void 0?this[Zt].decode(r):void 0,n=this[ga]&&n!==void 0?this[kr].decode(n):void 0}catch(o){return i(new Qt("entry",o))}r===void 0&&n===void 0||this[je]++,i(null,r,n)}[Tt](e,r){let n=this[Xt]();if(e)return this[ut](n,e);try{for(let i of r){let o=i[0],s=i[1];i[0]=this[ba]&&o!==void 0?this[Zt].decode(o):void 0,i[1]=this[ga]&&s!==void 0?this[kr].decode(s):void 0}}catch(i){return this[ut](n,new Qt("entries",i))}this[je]+=r.length,this[ut](n,null,r)}end(e){return!sl&&typeof console<"u"&&(sl=!0,console.warn(new Le("The iterator.end() method was renamed to close() and end() is an alias that will be removed in a future version",{code:"LEVEL_LEGACY"}))),this.close(e)}},xa=class extends si{constructor(e,r){super(e,r,!1)}[Tr](e,r){let n=this[Xt]();if(e)return n(e);try{r=r!==void 0?this[Zt].decode(r):void 0}catch(i){return n(new Qt("key",i))}r!==void 0&&this[je]++,n(null,r)}[Tt](e,r){let n=this[Xt]();if(e)return this[ut](n,e);try{for(let i=0;i<r.length;i++){let o=r[i];r[i]=o!==void 0?this[Zt].decode(o):void 0}}catch(i){return this[ut](n,new Qt("keys",i))}this[je]+=r.length,this[ut](n,null,r)}},Ea=class extends si{constructor(e,r){super(e,r,!1)}[Tr](e,r){let n=this[Xt]();if(e)return n(e);try{r=r!==void 0?this[kr].decode(r):void 0}catch(i){return n(new Qt("value",i))}r!==void 0&&this[je]++,n(null,r)}[Tt](e,r){let n=this[Xt]();if(e)return this[ut](n,e);try{for(let i=0;i<r.length;i++){let o=r[i];r[i]=o!==void 0?this[kr].decode(o):void 0}}catch(i){return this[ut](n,new Qt("values",i))}this[je]+=r.length,this[ut](n,null,r)}},Qt=class extends Le{constructor(e,r){super(`Iterator could not decode ${e}`,{code:"LEVEL_DECODE_ERROR",cause:r})}};for(let t of["_ended property","_nexting property","_end method"])Object.defineProperty(hn.prototype,t.split(" ")[0],{get(){throw new Le(`The ${t} has been removed`,{code:"LEVEL_LEGACY"})},set(){throw new Le(`The ${t} has been removed`,{code:"LEVEL_LEGACY"})}});hn.keyEncoding=Zt;hn.valueEncoding=kr;no.AbstractIterator=hn;no.AbstractKeyIterator=xa;no.AbstractValueIterator=Ea});var al=M(_a=>{"use strict";var{AbstractKeyIterator:Vw,AbstractValueIterator:Hw}=er(),Pr=Symbol("iterator"),ai=Symbol("callback"),pn=Symbol("handleOne"),Ir=Symbol("handleMany"),ci=class extends Vw{constructor(e,r){super(e,r),this[Pr]=e.iterator({...r,keys:!0,values:!1}),this[pn]=this[pn].bind(this),this[Ir]=this[Ir].bind(this)}},io=class extends Hw{constructor(e,r){super(e,r),this[Pr]=e.iterator({...r,keys:!1,values:!0}),this[pn]=this[pn].bind(this),this[Ir]=this[Ir].bind(this)}};for(let t of[ci,io]){let e=t===ci,r=e?n=>n[0]:n=>n[1];t.prototype._next=function(n){this[ai]=n,this[Pr].next(this[pn])},t.prototype[pn]=function(n,i,o){let s=this[ai];n?s(n):s(null,e?i:o)},t.prototype._nextv=function(n,i,o){this[ai]=o,this[Pr].nextv(n,i,this[Ir])},t.prototype._all=function(n,i){this[ai]=i,this[Pr].all(n,this[Ir])},t.prototype[Ir]=function(n,i){let o=this[ai];n?o(n):o(null,i.map(r))},t.prototype._seek=function(n,i){this[Pr].seek(n,i)},t.prototype._close=function(n){this[Pr].close(n)}}_a.DefaultKeyIterator=ci;_a.DefaultValueIterator=io});var cl=M(uo=>{"use strict";var{AbstractIterator:Gw,AbstractKeyIterator:Ww,AbstractValueIterator:Jw}=er(),Aa=ze(),Re=Symbol("nut"),co=Symbol("undefer"),fo=Symbol("factory"),oo=class extends Gw{constructor(e,r){super(e,r),this[Re]=null,this[fo]=()=>e.iterator(r),this.db.defer(()=>this[co]())}},so=class extends Ww{constructor(e,r){super(e,r),this[Re]=null,this[fo]=()=>e.keys(r),this.db.defer(()=>this[co]())}},ao=class extends Jw{constructor(e,r){super(e,r),this[Re]=null,this[fo]=()=>e.values(r),this.db.defer(()=>this[co]())}};for(let t of[oo,so,ao])t.prototype[co]=function(){this.db.status==="open"&&(this[Re]=this[fo]())},t.prototype._next=function(e){this[Re]!==null?this[Re].next(e):this.db.status==="opening"?this.db.defer(()=>this._next(e)):this.nextTick(e,new Aa("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},t.prototype._nextv=function(e,r,n){this[Re]!==null?this[Re].nextv(e,r,n):this.db.status==="opening"?this.db.defer(()=>this._nextv(e,r,n)):this.nextTick(n,new Aa("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},t.prototype._all=function(e,r){this[Re]!==null?this[Re].all(r):this.db.status==="opening"?this.db.defer(()=>this._all(e,r)):this.nextTick(r,new Aa("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},t.prototype._seek=function(e,r){this[Re]!==null?this[Re]._seek(e,r):this.db.status==="opening"&&this.db.defer(()=>this._seek(e,r))},t.prototype._close=function(e){this[Re]!==null?this[Re].close(e):this.db.status==="opening"?this.db.defer(()=>this._close(e)):this.nextTick(e)};uo.DeferredIterator=oo;uo.DeferredKeyIterator=so;uo.DeferredValueIterator=ao});var va=M(ul=>{"use strict";var{fromCallback:fl}=ni(),lo=ze(),{getCallback:zw,getOptions:Yw}=Qi(),ho=Symbol("promise"),Fe=Symbol("status"),yn=Symbol("operations"),fi=Symbol("finishClose"),wn=Symbol("closeCallbacks"),Sa=class{constructor(e){if(typeof e!="object"||e===null){let r=e===null?"null":typeof e;throw new TypeError(`The first argument must be an abstract-level database, received ${r}`)}this[yn]=[],this[wn]=[],this[Fe]="open",this[fi]=this[fi].bind(this),this.db=e,this.db.attachResource(this),this.nextTick=e.nextTick}get length(){return this[yn].length}put(e,r,n){if(this[Fe]!=="open")throw new lo("Batch is not open: cannot call put() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});let i=this.db._checkKey(e)||this.db._checkValue(r);if(i)throw i;let o=n&&n.sublevel!=null?n.sublevel:this.db,s=n,a=o.keyEncoding(n&&n.keyEncoding),c=o.valueEncoding(n&&n.valueEncoding),f=a.format;n={...n,keyEncoding:f,valueEncoding:c.format},o!==this.db&&(n.sublevel=null);let u=o.prefixKey(a.encode(e),f),l=c.encode(r);return this._put(u,l,n),this[yn].push({...s,type:"put",key:e,value:r}),this}_put(e,r,n){}del(e,r){if(this[Fe]!=="open")throw new lo("Batch is not open: cannot call del() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});let n=this.db._checkKey(e);if(n)throw n;let i=r&&r.sublevel!=null?r.sublevel:this.db,o=r,s=i.keyEncoding(r&&r.keyEncoding),a=s.format;return r={...r,keyEncoding:a},i!==this.db&&(r.sublevel=null),this._del(i.prefixKey(s.encode(e),a),r),this[yn].push({...o,type:"del",key:e}),this}_del(e,r){}clear(){if(this[Fe]!=="open")throw new lo("Batch is not open: cannot call clear() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});return this._clear(),this[yn]=[],this}_clear(){}write(e,r){return r=zw(e,r),r=fl(r,ho),e=Yw(e),this[Fe]!=="open"?this.nextTick(r,new lo("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"})):this.length===0?this.close(r):(this[Fe]="writing",this._write(e,n=>{this[Fe]="closing",this[wn].push(()=>r(n)),n||this.db.emit("batch",this[yn]),this._close(this[fi])})),r[ho]}_write(e,r){}close(e){return e=fl(e,ho),this[Fe]==="closing"?this[wn].push(e):this[Fe]==="closed"?this.nextTick(e):(this[wn].push(e),this[Fe]!=="writing"&&(this[Fe]="closing",this._close(this[fi]))),e[ho]}_close(e){this.nextTick(e)}[fi](){this[Fe]="closed",this.db.detachResource(this);let e=this[wn];this[wn]=[];for(let r of e)r()}};ul.AbstractChainedBatch=Sa});var dl=M(ll=>{"use strict";var{AbstractChainedBatch:Zw}=va(),Xw=ze(),mn=Symbol("encoded"),Ba=class extends Zw{constructor(e){super(e),this[mn]=[]}_put(e,r,n){this[mn].push({...n,type:"put",key:e,value:r})}_del(e,r){this[mn].push({...r,type:"del",key:e})}_clear(){this[mn]=[]}_write(e,r){this.db.status==="opening"?this.db.defer(()=>this._write(e,r)):this.db.status==="open"?this[mn].length===0?this.nextTick(r):this.db._batch(this[mn],e,r):this.nextTick(r,new Xw("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"}))}};ll.DefaultChainedBatch=Ba});var yl=M((JA,pl)=>{"use strict";var hl=ze(),Qw=Object.prototype.hasOwnProperty,em=new Set(["lt","lte","gt","gte"]);pl.exports=function(t,e){let r={};for(let n in t)if(Qw.call(t,n)&&!(n==="keyEncoding"||n==="valueEncoding")){if(n==="start"||n==="end")throw new hl(`The legacy range option '${n}' has been removed`,{code:"LEVEL_LEGACY"});if(n==="encoding")throw new hl("The levelup-style 'encoding' alias has been removed, use 'valueEncoding' instead",{code:"LEVEL_LEGACY"});em.has(n)?r[n]=e.encode(t[n]):r[n]=t[n]}return r.reverse=!!r.reverse,r.limit=Number.isInteger(r.limit)&&r.limit>=0?r.limit:-1,r}});var Ta=M((zA,ml)=>{var wl;ml.exports=typeof queueMicrotask=="function"?queueMicrotask.bind(typeof window<"u"?window:globalThis):t=>(wl||(wl=Promise.resolve())).then(t).catch(e=>setTimeout(()=>{throw e},0))});var xl=M((YA,gl)=>{"use strict";var bl=Ta();gl.exports=function(t,...e){e.length===0?bl(t):bl(()=>t(...e))}});var El=M(po=>{"use strict";var{AbstractIterator:tm,AbstractKeyIterator:rm,AbstractValueIterator:nm}=er(),bn=Symbol("unfix"),Ye=Symbol("iterator"),Rr=Symbol("handleOne"),tr=Symbol("handleMany"),kt=Symbol("callback"),ui=class extends tm{constructor(e,r,n,i){super(e,r),this[Ye]=n,this[bn]=i,this[Rr]=this[Rr].bind(this),this[tr]=this[tr].bind(this),this[kt]=null}[Rr](e,r,n){let i=this[kt];if(e)return i(e);r!==void 0&&(r=this[bn](r)),i(e,r,n)}[tr](e,r){let n=this[kt];if(e)return n(e);for(let i of r){let o=i[0];o!==void 0&&(i[0]=this[bn](o))}n(e,r)}},li=class extends rm{constructor(e,r,n,i){super(e,r),this[Ye]=n,this[bn]=i,this[Rr]=this[Rr].bind(this),this[tr]=this[tr].bind(this),this[kt]=null}[Rr](e,r){let n=this[kt];if(e)return n(e);r!==void 0&&(r=this[bn](r)),n(e,r)}[tr](e,r){let n=this[kt];if(e)return n(e);for(let i=0;i<r.length;i++){let o=r[i];o!==void 0&&(r[i]=this[bn](o))}n(e,r)}},di=class extends nm{constructor(e,r,n){super(e,r),this[Ye]=n}};for(let t of[ui,li])t.prototype._next=function(e){this[kt]=e,this[Ye].next(this[Rr])},t.prototype._nextv=function(e,r,n){this[kt]=n,this[Ye].nextv(e,r,this[tr])},t.prototype._all=function(e,r){this[kt]=r,this[Ye].all(e,this[tr])};for(let t of[di])t.prototype._next=function(e){this[Ye].next(e)},t.prototype._nextv=function(e,r,n){this[Ye].nextv(e,r,n)},t.prototype._all=function(e,r){this[Ye].all(e,r)};for(let t of[ui,li,di])t.prototype._seek=function(e,r){this[Ye].seek(e,r)},t.prototype._close=function(e){this[Ye].close(e)};po.AbstractSublevelIterator=ui;po.AbstractSublevelKeyIterator=li;po.AbstractSublevelValueIterator=di});var vl=M((XA,Sl)=>{"use strict";var ka=ze(),{Buffer:Ra}=qe()||{},{AbstractSublevelIterator:im,AbstractSublevelKeyIterator:om,AbstractSublevelValueIterator:sm}=El(),Pt=Symbol("prefix"),_l=Symbol("upperBound"),hi=Symbol("prefixRange"),Oe=Symbol("parent"),Pa=Symbol("unfix"),Al=new TextEncoder,am={separator:"!"};Sl.exports=function({AbstractLevel:t}){class e extends t{static defaults(n){if(typeof n=="string")throw new ka("The subleveldown string shorthand for { separator } has been removed",{code:"LEVEL_LEGACY"});if(n&&n.open)throw new ka("The subleveldown open option has been removed",{code:"LEVEL_LEGACY"});return n==null?am:n.separator?n:{...n,separator:"!"}}constructor(n,i,o){let{separator:s,manifest:a,...c}=e.defaults(o);i=fm(i,s);let f=s.charCodeAt(0)+1,u=n[Oe]||n;if(!Al.encode(i).every(h=>h>f&&h<127))throw new ka(`Prefix must use bytes > ${f} < 127`,{code:"LEVEL_INVALID_PREFIX"});super(cm(u,a),c);let l=(n.prefix||"")+s+i+s,p=l.slice(0,-1)+String.fromCharCode(f);this[Oe]=u,this[Pt]=new yo(l),this[_l]=new yo(p),this[Pa]=new Ua,this.nextTick=u.nextTick}prefixKey(n,i){if(i==="utf8")return this[Pt].utf8+n;if(n.byteLength===0)return this[Pt][i];if(i==="view"){let o=this[Pt].view,s=new Uint8Array(o.byteLength+n.byteLength);return s.set(o,0),s.set(n,o.byteLength),s}else{let o=this[Pt].buffer;return Ra.concat([o,n],o.byteLength+n.byteLength)}}[hi](n,i){n.gte!==void 0?n.gte=this.prefixKey(n.gte,i):n.gt!==void 0?n.gt=this.prefixKey(n.gt,i):n.gte=this[Pt][i],n.lte!==void 0?n.lte=this.prefixKey(n.lte,i):n.lt!==void 0?n.lt=this.prefixKey(n.lt,i):n.lte=this[_l][i]}get prefix(){return this[Pt].utf8}get db(){return this[Oe]}_open(n,i){this[Oe].open({passive:!0},i)}_put(n,i,o,s){this[Oe].put(n,i,o,s)}_get(n,i,o){this[Oe].get(n,i,o)}_getMany(n,i,o){this[Oe].getMany(n,i,o)}_del(n,i,o){this[Oe].del(n,i,o)}_batch(n,i,o){this[Oe].batch(n,i,o)}_clear(n,i){this[hi](n,n.keyEncoding),this[Oe].clear(n,i)}_iterator(n){this[hi](n,n.keyEncoding);let i=this[Oe].iterator(n),o=this[Pa].get(this[Pt].utf8.length,n.keyEncoding);return new im(this,n,i,o)}_keys(n){this[hi](n,n.keyEncoding);let i=this[Oe].keys(n),o=this[Pa].get(this[Pt].utf8.length,n.keyEncoding);return new om(this,n,i,o)}_values(n){this[hi](n,n.keyEncoding);let i=this[Oe].values(n);return new sm(this,n,i)}}return{AbstractSublevel:e}};var cm=function(t,e){return{...t.supports,createIfMissing:!1,errorIfExists:!1,events:{},additionalMethods:{},...e,encodings:{utf8:Ia(t,"utf8"),buffer:Ia(t,"buffer"),view:Ia(t,"view")}}},Ia=function(t,e){return t.supports.encodings[e]?t.keyEncoding(e).name===e:!1},yo=class{constructor(e){this.utf8=e,this.view=Al.encode(e),this.buffer=Ra?Ra.from(this.view.buffer,0,this.view.byteLength):{}}},Ua=class{constructor(){this.cache=new Map}get(e,r){let n=this.cache.get(r);return n===void 0&&(r==="view"?n=(function(i,o){return o.subarray(i)}).bind(null,e):n=(function(i,o){return o.slice(i)}).bind(null,e),this.cache.set(r,n)),n}},fm=function(t,e){let r=0,n=t.length;for(;r<n&&t[r]===e;)r++;for(;n>r&&t[n-1]===e;)n--;return t.slice(r,n)}});var Na=M(Ka=>{"use strict";var{supports:um}=yu(),{Transcoder:lm}=Hu(),{EventEmitter:dm}=ln(),{fromCallback:rr}=ni(),Ze=ze(),{AbstractIterator:Ur}=er(),{DefaultKeyIterator:hm,DefaultValueIterator:pm}=al(),{DeferredIterator:ym,DeferredKeyIterator:wm,DeferredValueIterator:mm}=cl(),{DefaultChainedBatch:Bl}=dl(),{getCallback:Cr,getOptions:nr}=Qi(),wo=yl(),J=Symbol("promise"),It=Symbol("landed"),Lr=Symbol("resources"),Ca=Symbol("closeResources"),pi=Symbol("operations"),yi=Symbol("undefer"),mo=Symbol("deferOpen"),Tl=Symbol("options"),X=Symbol("status"),Or=Symbol("defaultOptions"),gn=Symbol("transcoder"),bo=Symbol("keyEncoding"),La=Symbol("valueEncoding"),bm=()=>{},wi=class extends dm{constructor(e,r){if(super(),typeof e!="object"||e===null)throw new TypeError("The first argument 'manifest' must be an object");r=nr(r);let{keyEncoding:n,valueEncoding:i,passive:o,...s}=r;this[Lr]=new Set,this[pi]=[],this[mo]=!0,this[Tl]=s,this[X]="opening",this.supports=um(e,{status:!0,promises:!0,clear:!0,getMany:!0,deferredOpen:!0,snapshots:e.snapshots!==!1,permanence:e.permanence!==!1,keyIterator:!0,valueIterator:!0,iteratorNextv:!0,iteratorAll:!0,encodings:e.encodings||{},events:Object.assign({},e.events,{opening:!0,open:!0,closing:!0,closed:!0,put:!0,del:!0,batch:!0,clear:!0})}),this[gn]=new lm(gm(this)),this[bo]=this[gn].encoding(n||"utf8"),this[La]=this[gn].encoding(i||"utf8");for(let a of this[gn].encodings())this.supports.encodings[a.commonName]||(this.supports.encodings[a.commonName]=!0);this[Or]={empty:Object.freeze({}),entry:Object.freeze({keyEncoding:this[bo].commonName,valueEncoding:this[La].commonName}),key:Object.freeze({keyEncoding:this[bo].commonName})},this.nextTick(()=>{this[mo]&&this.open({passive:!1},bm)})}get status(){return this[X]}keyEncoding(e){return this[gn].encoding(e??this[bo])}valueEncoding(e){return this[gn].encoding(e??this[La])}open(e,r){r=Cr(e,r),r=rr(r,J),e={...this[Tl],...nr(e)},e.createIfMissing=e.createIfMissing!==!1,e.errorIfExists=!!e.errorIfExists;let n=i=>{this[X]==="closing"||this[X]==="opening"?this.once(It,i?()=>n(i):n):this[X]!=="open"?r(new Ze("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN",cause:i})):r()};return e.passive?this[X]==="opening"?this.once(It,n):this.nextTick(n):this[X]==="closed"||this[mo]?(this[mo]=!1,this[X]="opening",this.emit("opening"),this._open(e,i=>{if(i){this[X]="closed",this[Ca](()=>{this.emit(It),n(i)}),this[yi]();return}this[X]="open",this[yi](),this.emit(It),this[X]==="open"&&this.emit("open"),this[X]==="open"&&this.emit("ready"),n()})):this[X]==="open"?this.nextTick(n):this.once(It,()=>this.open(e,r)),r[J]}_open(e,r){this.nextTick(r)}close(e){e=rr(e,J);let r=n=>{this[X]==="opening"||this[X]==="closing"?this.once(It,n?r(n):r):this[X]!=="closed"?e(new Ze("Database is not closed",{code:"LEVEL_DATABASE_NOT_CLOSED",cause:n})):e()};if(this[X]==="open"){this[X]="closing",this.emit("closing");let n=i=>{this[X]="open",this[yi](),this.emit(It),r(i)};this[Ca](()=>{this._close(i=>{if(i)return n(i);this[X]="closed",this[yi](),this.emit(It),this[X]==="closed"&&this.emit("closed"),r()})})}else this[X]==="closed"?this.nextTick(r):this.once(It,()=>this.close(e));return e[J]}[Ca](e){if(this[Lr].size===0)return this.nextTick(e);let r=this[Lr].size,n=!0,i=()=>{--r===0&&(n?this.nextTick(e):e())};for(let o of this[Lr])o.close(i);n=!1,this[Lr].clear()}_close(e){this.nextTick(e)}get(e,r,n){if(n=Cr(r,n),n=rr(n,J),r=nr(r,this[Or].entry),this[X]==="opening")return this.defer(()=>this.get(e,r,n)),n[J];if(xn(this,n))return n[J];let i=this._checkKey(e);if(i)return this.nextTick(n,i),n[J];let o=this.keyEncoding(r.keyEncoding),s=this.valueEncoding(r.valueEncoding),a=o.format,c=s.format;return(r.keyEncoding!==a||r.valueEncoding!==c)&&(r=Object.assign({},r,{keyEncoding:a,valueEncoding:c})),this._get(this.prefixKey(o.encode(e),a),r,(f,u)=>{if(f)return(f.code==="LEVEL_NOT_FOUND"||f.notFound||/NotFound/i.test(f))&&(f.code||(f.code="LEVEL_NOT_FOUND"),f.notFound||(f.notFound=!0),f.status||(f.status=404)),n(f);try{u=s.decode(u)}catch(l){return n(new Ze("Could not decode value",{code:"LEVEL_DECODE_ERROR",cause:l}))}n(null,u)}),n[J]}_get(e,r,n){this.nextTick(n,new Error("NotFound"))}getMany(e,r,n){if(n=Cr(r,n),n=rr(n,J),r=nr(r,this[Or].entry),this[X]==="opening")return this.defer(()=>this.getMany(e,r,n)),n[J];if(xn(this,n))return n[J];if(!Array.isArray(e))return this.nextTick(n,new TypeError("The first argument 'keys' must be an array")),n[J];if(e.length===0)return this.nextTick(n,null,[]),n[J];let i=this.keyEncoding(r.keyEncoding),o=this.valueEncoding(r.valueEncoding),s=i.format,a=o.format;(r.keyEncoding!==s||r.valueEncoding!==a)&&(r=Object.assign({},r,{keyEncoding:s,valueEncoding:a}));let c=new Array(e.length);for(let f=0;f<e.length;f++){let u=e[f],l=this._checkKey(u);if(l)return this.nextTick(n,l),n[J];c[f]=this.prefixKey(i.encode(u),s)}return this._getMany(c,r,(f,u)=>{if(f)return n(f);try{for(let l=0;l<u.length;l++)u[l]!==void 0&&(u[l]=o.decode(u[l]))}catch(l){return n(new Ze(`Could not decode one or more of ${u.length} value(s)`,{code:"LEVEL_DECODE_ERROR",cause:l}))}n(null,u)}),n[J]}_getMany(e,r,n){this.nextTick(n,null,new Array(e.length).fill(void 0))}put(e,r,n,i){if(i=Cr(n,i),i=rr(i,J),n=nr(n,this[Or].entry),this[X]==="opening")return this.defer(()=>this.put(e,r,n,i)),i[J];if(xn(this,i))return i[J];let o=this._checkKey(e)||this._checkValue(r);if(o)return this.nextTick(i,o),i[J];let s=this.keyEncoding(n.keyEncoding),a=this.valueEncoding(n.valueEncoding),c=s.format,f=a.format;(n.keyEncoding!==c||n.valueEncoding!==f)&&(n=Object.assign({},n,{keyEncoding:c,valueEncoding:f}));let u=this.prefixKey(s.encode(e),c),l=a.encode(r);return this._put(u,l,n,p=>{if(p)return i(p);this.emit("put",e,r),i()}),i[J]}_put(e,r,n,i){this.nextTick(i)}del(e,r,n){if(n=Cr(r,n),n=rr(n,J),r=nr(r,this[Or].key),this[X]==="opening")return this.defer(()=>this.del(e,r,n)),n[J];if(xn(this,n))return n[J];let i=this._checkKey(e);if(i)return this.nextTick(n,i),n[J];let o=this.keyEncoding(r.keyEncoding),s=o.format;return r.keyEncoding!==s&&(r=Object.assign({},r,{keyEncoding:s})),this._del(this.prefixKey(o.encode(e),s),r,a=>{if(a)return n(a);this.emit("del",e),n()}),n[J]}_del(e,r,n){this.nextTick(n)}batch(e,r,n){if(!arguments.length){if(this[X]==="opening")return new Bl(this);if(this[X]!=="open")throw new Ze("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._chainedBatch()}if(typeof e=="function"?n=e:n=Cr(r,n),n=rr(n,J),r=nr(r,this[Or].empty),this[X]==="opening")return this.defer(()=>this.batch(e,r,n)),n[J];if(xn(this,n))return n[J];if(!Array.isArray(e))return this.nextTick(n,new TypeError("The first argument 'operations' must be an array")),n[J];if(e.length===0)return this.nextTick(n),n[J];let i=new Array(e.length),{keyEncoding:o,valueEncoding:s,...a}=r;for(let c=0;c<e.length;c++){if(typeof e[c]!="object"||e[c]===null)return this.nextTick(n,new TypeError("A batch operation must be an object")),n[J];let f=Object.assign({},e[c]);if(f.type!=="put"&&f.type!=="del")return this.nextTick(n,new TypeError("A batch operation must have a type property that is 'put' or 'del'")),n[J];let u=this._checkKey(f.key);if(u)return this.nextTick(n,u),n[J];let l=f.sublevel!=null?f.sublevel:this,p=l.keyEncoding(f.keyEncoding||o),h=p.format;if(f.key=l.prefixKey(p.encode(f.key),h),f.keyEncoding=h,f.type==="put"){let y=this._checkValue(f.value);if(y)return this.nextTick(n,y),n[J];let d=l.valueEncoding(f.valueEncoding||s);f.value=d.encode(f.value),f.valueEncoding=d.format}l!==this&&(f.sublevel=null),i[c]=f}return this._batch(i,a,c=>{if(c)return n(c);this.emit("batch",e),n()}),n[J]}_batch(e,r,n){this.nextTick(n)}sublevel(e,r){return this._sublevel(e,Oa.defaults(r))}_sublevel(e,r){return new Oa(this,e,r)}prefixKey(e,r){return e}clear(e,r){if(r=Cr(e,r),r=rr(r,J),e=nr(e,this[Or].empty),this[X]==="opening")return this.defer(()=>this.clear(e,r)),r[J];if(xn(this,r))return r[J];let n=e,i=this.keyEncoding(e.keyEncoding);return e=wo(e,i),e.keyEncoding=i.format,e.limit===0?this.nextTick(r):this._clear(e,o=>{if(o)return r(o);this.emit("clear",n),r()}),r[J]}_clear(e,r){this.nextTick(r)}iterator(e){let r=this.keyEncoding(e&&e.keyEncoding),n=this.valueEncoding(e&&e.valueEncoding);if(e=wo(e,r),e.keys=e.keys!==!1,e.values=e.values!==!1,e[Ur.keyEncoding]=r,e[Ur.valueEncoding]=n,e.keyEncoding=r.format,e.valueEncoding=n.format,this[X]==="opening")return new ym(this,e);if(this[X]!=="open")throw new Ze("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._iterator(e)}_iterator(e){return new Ur(this,e)}keys(e){let r=this.keyEncoding(e&&e.keyEncoding),n=this.valueEncoding(e&&e.valueEncoding);if(e=wo(e,r),e[Ur.keyEncoding]=r,e[Ur.valueEncoding]=n,e.keyEncoding=r.format,e.valueEncoding=n.format,this[X]==="opening")return new wm(this,e);if(this[X]!=="open")throw new Ze("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._keys(e)}_keys(e){return new hm(this,e)}values(e){let r=this.keyEncoding(e&&e.keyEncoding),n=this.valueEncoding(e&&e.valueEncoding);if(e=wo(e,r),e[Ur.keyEncoding]=r,e[Ur.valueEncoding]=n,e.keyEncoding=r.format,e.valueEncoding=n.format,this[X]==="opening")return new mm(this,e);if(this[X]!=="open")throw new Ze("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._values(e)}_values(e){return new pm(this,e)}defer(e){if(typeof e!="function")throw new TypeError("The first argument must be a function");this[pi].push(e)}[yi](){if(this[pi].length===0)return;let e=this[pi];this[pi]=[];for(let r of e)r()}attachResource(e){if(typeof e!="object"||e===null||typeof e.close!="function")throw new TypeError("The first argument must be a resource object");this[Lr].add(e)}detachResource(e){this[Lr].delete(e)}_chainedBatch(){return new Bl(this)}_checkKey(e){if(e==null)return new Ze("Key cannot be null or undefined",{code:"LEVEL_INVALID_KEY"})}_checkValue(e){if(e==null)return new Ze("Value cannot be null or undefined",{code:"LEVEL_INVALID_VALUE"})}};wi.prototype.nextTick=xl();var{AbstractSublevel:Oa}=vl()({AbstractLevel:wi});Ka.AbstractLevel=wi;Ka.AbstractSublevel=Oa;var xn=function(t,e){return t[X]!=="open"?(t.nextTick(e,new Ze("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"})),!0):!1},gm=function(t){return Object.keys(t.supports.encodings).filter(e=>!!t.supports.encodings[e])}});var Da=M(Kr=>{"use strict";Kr.AbstractLevel=Na().AbstractLevel;Kr.AbstractSublevel=Na().AbstractSublevel;Kr.AbstractIterator=er().AbstractIterator;Kr.AbstractKeyIterator=er().AbstractKeyIterator;Kr.AbstractValueIterator=er().AbstractValueIterator;Kr.AbstractChainedBatch=va().AbstractChainedBatch});var Pl=M((tS,kl)=>{kl.exports=Em;var xm=Ta();function Em(t,e,r){if(typeof e!="number")throw new Error("second argument must be a Number");let n,i,o,s,a,c=!0,f;Array.isArray(t)?(n=[],o=i=t.length):(s=Object.keys(t),n={},o=i=s.length);function u(p){function h(){r&&r(p,n),r=null}c?xm(h):h()}function l(p,h,y){if(n[p]=y,h&&(a=!0),--o===0||h)u(h);else if(!a&&f<i){let d;s?(d=s[f],f+=1,t[d](function(w,m){l(d,w,m)})):(d=f,f+=1,t[d](function(w,m){l(d,w,m)}))}}f=e,o?s?s.some(function(p,h){return t[p](function(y,d){l(p,y,d)}),h===e-1}):t.some(function(p,h){return p(function(y,d){l(h,y,d)}),h===e-1}):u(null),c=!1}});var Ma=M((rS,Il)=>{"use strict";Il.exports=function(e){let r=e.gte!==void 0?e.gte:e.gt!==void 0?e.gt:void 0,n=e.lte!==void 0?e.lte:e.lt!==void 0?e.lt:void 0,i=e.gte===void 0,o=e.lte===void 0;return r!==void 0&&n!==void 0?IDBKeyRange.bound(r,n,i,o):r!==void 0?IDBKeyRange.lowerBound(r,i):n!==void 0?IDBKeyRange.upperBound(n,o):null}});var qa=M((nS,Rl)=>{"use strict";var _m=new TextEncoder;Rl.exports=function(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):_m.encode(t)}});var Kl=M(Ol=>{"use strict";var{AbstractIterator:Am}=Da(),Ul=Ma(),go=qa(),lt=Symbol("cache"),Rt=Symbol("finished"),Ke=Symbol("options"),Ut=Symbol("currentOptions"),Nr=Symbol("position"),ja=Symbol("location"),En=Symbol("first"),Cl={},Fa=class extends Am{constructor(e,r,n){super(e,n),this[lt]=[],this[Rt]=this.limit===0,this[Ke]=n,this[Ut]={...n},this[Nr]=void 0,this[ja]=r,this[En]=!0}_nextv(e,r,n){if(this[En]=!1,this[Rt])return this.nextTick(n,null,[]);if(this[lt].length>0)return e=Math.min(e,this[lt].length),this.nextTick(n,null,this[lt].splice(0,e));this[Nr]!==void 0&&(this[Ke].reverse?(this[Ut].lt=this[Nr],this[Ut].lte=void 0):(this[Ut].gt=this[Nr],this[Ut].gte=void 0));let i;try{i=Ul(this[Ut])}catch{return this[Rt]=!0,this.nextTick(n,null,[])}let o=this.db.db.transaction([this[ja]],"readonly"),s=o.objectStore(this[ja]),a=[];if(this[Ke].reverse){let c=!this[Ke].values&&s.openKeyCursor?"openKeyCursor":"openCursor";s[c](i,"prev").onsuccess=f=>{let u=f.target.result;if(u){let{key:l,value:p}=u;this[Nr]=l,a.push([this[Ke].keys&&l!==void 0?go(l):void 0,this[Ke].values&&p!==void 0?go(p):void 0]),a.length<e?u.continue():Ll(o)}else this[Rt]=!0}}else{let c,f,u=()=>{if(c===void 0||f===void 0)return;let l=Math.max(c.length,f.length);l===0||e===1/0?this[Rt]=!0:this[Nr]=c[l-1],a.length=l;for(let p=0;p<l;p++){let h=c[p],y=f[p];a[p]=[this[Ke].keys&&h!==void 0?go(h):void 0,this[Ke].values&&y!==void 0?go(y):void 0]}Ll(o)};this[Ke].keys||e<1/0?s.getAllKeys(i,e<1/0?e:void 0).onsuccess=l=>{c=l.target.result,u()}:(c=[],this.nextTick(u)),this[Ke].values?s.getAll(i,e<1/0?e:void 0).onsuccess=l=>{f=l.target.result,u()}:(f=[],this.nextTick(u))}o.onabort=()=>{n(o.error||new Error("aborted by user")),n=null},o.oncomplete=()=>{n(null,a),n=null}}_next(e){if(this[lt].length>0){let[r,n]=this[lt].shift();this.nextTick(e,null,r,n)}else if(this[Rt])this.nextTick(e);else{let r=Math.min(100,this.limit-this.count);this[En]&&(this[En]=!1,r=1),this._nextv(r,Cl,(n,i)=>{if(n)return e(n);this[lt]=i,this._next(e)})}}_all(e,r){this[En]=!1;let n=this[lt].splice(0,this[lt].length),i=this.limit-this.count-n.length;if(i<=0)return this.nextTick(r,null,n);this._nextv(i,Cl,(o,s)=>{if(o)return r(o);n.length>0&&(s=n.concat(s)),r(null,s)})}_seek(e,r){this[En]=!0,this[lt]=[],this[Rt]=!1,this[Nr]=void 0,this[Ut]={...this[Ke]};let n;try{n=Ul(this[Ke])}catch{this[Rt]=!0;return}n!==null&&!n.includes(e)?this[Rt]=!0:this[Ke].reverse?this[Ut].lte=e:this[Ut].gte=e}};Ol.Iterator=Fa;function Ll(t){typeof t.commit=="function"&&t.commit()}});var Dl=M((oS,Nl)=>{"use strict";Nl.exports=function(e,r,n,i,o){if(i.limit===0)return e.nextTick(o);let s=e.db.transaction([r],"readwrite"),a=s.objectStore(r),c=0;s.oncomplete=function(){o()},s.onabort=function(){o(s.error||new Error("aborted by user"))};let f=a.openKeyCursor?"openKeyCursor":"openCursor",u=i.reverse?"prev":"next";a[f](n,u).onsuccess=function(l){let p=l.target.result;p&&(a.delete(p.key).onsuccess=function(){(i.limit<=0||++c<i.limit)&&p.continue()})}}});var Vl=M($l=>{"use strict";var{AbstractLevel:Sm}=Da(),Ml=ze(),vm=Pl(),{fromCallback:Bm}=ni(),{Iterator:Tm}=Kl(),ql=qa(),km=Dl(),Pm=Ma(),Fl="level-js-",mi=Symbol("idb"),$a=Symbol("namePrefix"),Ct=Symbol("location"),Va=Symbol("version"),Dr=Symbol("store"),bi=Symbol("onComplete"),jl=Symbol("promise"),xo=class extends Sm{constructor(e,r,n){if(typeof r=="function"||typeof n=="function")throw new Ml("The levelup-style callback argument has been removed",{code:"LEVEL_LEGACY"});let{prefix:i,version:o,...s}=r||{};if(super({encodings:{view:!0},snapshots:!1,createIfMissing:!1,errorIfExists:!1,seek:!0},s),typeof e!="string")throw new Error("constructor requires a location string argument");this[Ct]=e,this[$a]=i??Fl,this[Va]=parseInt(o||1,10),this[mi]=null}get location(){return this[Ct]}get namePrefix(){return this[$a]}get version(){return this[Va]}get db(){return this[mi]}get type(){return"browser-level"}_open(e,r){let n=indexedDB.open(this[$a]+this[Ct],this[Va]);n.onerror=function(){r(n.error||new Error("unknown error"))},n.onsuccess=()=>{this[mi]=n.result,r()},n.onupgradeneeded=i=>{let o=i.target.result;o.objectStoreNames.contains(this[Ct])||o.createObjectStore(this[Ct])}}[Dr](e){return this[mi].transaction([this[Ct]],e).objectStore(this[Ct])}[bi](e,r){let n=e.transaction;n.onabort=function(){r(n.error||new Error("aborted by user"))},n.oncomplete=function(){r(null,e.result)}}_get(e,r,n){let i=this[Dr]("readonly"),o;try{o=i.get(e)}catch(s){return this.nextTick(n,s)}this[bi](o,function(s,a){if(s)return n(s);if(a===void 0)return n(new Ml("Entry not found",{code:"LEVEL_NOT_FOUND"}));n(null,ql(a))})}_getMany(e,r,n){let i=this[Dr]("readonly"),o=e.map(s=>a=>{let c;try{c=i.get(s)}catch(f){return a(f)}c.onsuccess=()=>{let f=c.result;a(null,f===void 0?f:ql(f))},c.onerror=f=>{f.stopPropagation(),a(c.error)}});vm(o,16,n)}_del(e,r,n){let i=this[Dr]("readwrite"),o;try{o=i.delete(e)}catch(s){return this.nextTick(n,s)}this[bi](o,n)}_put(e,r,n,i){let o=this[Dr]("readwrite"),s;try{s=o.put(r,e)}catch(a){return this.nextTick(i,a)}this[bi](s,i)}_iterator(e){return new Tm(this,this[Ct],e)}_batch(e,r,n){let i=this[Dr]("readwrite"),o=i.transaction,s=0,a;o.onabort=function(){n(a||o.error||new Error("aborted by user"))},o.oncomplete=function(){n()};function c(){let f=e[s++],u=f.key,l;try{l=f.type==="del"?i.delete(u):i.put(f.value,u)}catch(p){a=p,o.abort();return}s<e.length?l.onsuccess=c:typeof o.commit=="function"&&o.commit()}c()}_clear(e,r){let n,i;try{n=Pm(e)}catch{return this.nextTick(r)}if(e.limit>=0)return km(this,this[Ct],n,e,r);try{let o=this[Dr]("readwrite");i=n?o.delete(n):o.clear()}catch(o){return this.nextTick(r,o)}this[bi](i,r)}_close(e){this[mi].close(),this.nextTick(e)}};xo.destroy=function(t,e,r){typeof e=="function"&&(r=e,e=Fl),r=Bm(r,jl);let n=indexedDB.deleteDatabase(e+t);return n.onsuccess=function(){r()},n.onerror=function(i){r(i)},r[jl]};$l.BrowserLevel=xo});var Gl=M(Hl=>{Hl.Level=Vl().BrowserLevel});var ce=M((lS,Wl)=>{"use strict";Wl.exports={ArrayIsArray(t){return Array.isArray(t)},ArrayPrototypeIncludes(t,e){return t.includes(e)},ArrayPrototypeIndexOf(t,e){return t.indexOf(e)},ArrayPrototypeJoin(t,e){return t.join(e)},ArrayPrototypeMap(t,e){return t.map(e)},ArrayPrototypePop(t,e){return t.pop(e)},ArrayPrototypePush(t,e){return t.push(e)},ArrayPrototypeSlice(t,e,r){return t.slice(e,r)},Error,FunctionPrototypeCall(t,e,...r){return t.call(e,...r)},FunctionPrototypeSymbolHasInstance(t,e){return Function.prototype[Symbol.hasInstance].call(t,e)},MathFloor:Math.floor,Number,NumberIsInteger:Number.isInteger,NumberIsNaN:Number.isNaN,NumberMAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,NumberMIN_SAFE_INTEGER:Number.MIN_SAFE_INTEGER,NumberParseInt:Number.parseInt,ObjectDefineProperties(t,e){return Object.defineProperties(t,e)},ObjectDefineProperty(t,e,r){return Object.defineProperty(t,e,r)},ObjectGetOwnPropertyDescriptor(t,e){return Object.getOwnPropertyDescriptor(t,e)},ObjectKeys(t){return Object.keys(t)},ObjectSetPrototypeOf(t,e){return Object.setPrototypeOf(t,e)},Promise,PromisePrototypeCatch(t,e){return t.catch(e)},PromisePrototypeThen(t,e,r){return t.then(e,r)},PromiseReject(t){return Promise.reject(t)},PromiseResolve(t){return Promise.resolve(t)},ReflectApply:Reflect.apply,RegExpPrototypeTest(t,e){return t.test(e)},SafeSet:Set,String,StringPrototypeSlice(t,e,r){return t.slice(e,r)},StringPrototypeToLowerCase(t){return t.toLowerCase()},StringPrototypeToUpperCase(t){return t.toUpperCase()},StringPrototypeTrim(t){return t.trim()},Symbol,SymbolFor:Symbol.for,SymbolAsyncIterator:Symbol.asyncIterator,SymbolHasInstance:Symbol.hasInstance,SymbolIterator:Symbol.iterator,SymbolDispose:Symbol.dispose||Symbol("Symbol.dispose"),SymbolAsyncDispose:Symbol.asyncDispose||Symbol("Symbol.asyncDispose"),TypedArrayPrototypeSet(t,e,r){return t.set(e,r)},Boolean,Uint8Array}});var _n=M((dS,_o)=>{"use strict";var{AbortController:Jl,AbortSignal:Rm}=typeof self<"u"?self:typeof window<"u"?window:void 0;_o.exports=Jl;_o.exports.AbortSignal=Rm;_o.exports.default=Jl});var Se=M((hS,Ga)=>{"use strict";var Um=qe(),{kResistStopPropagation:Cm,SymbolDispose:Lm}=ce(),Om=globalThis.AbortSignal||_n().AbortSignal,Km=globalThis.AbortController||_n().AbortController,Nm=Object.getPrototypeOf(async function(){}).constructor,zl=globalThis.Blob||Um.Blob,Dm=typeof zl<"u"?function(e){return e instanceof zl}:function(e){return!1},Yl=(t,e)=>{if(t!==void 0&&(t===null||typeof t!="object"||!("aborted"in t)))throw new ERR_INVALID_ARG_TYPE(e,"AbortSignal",t)},Mm=(t,e)=>{if(typeof t!="function")throw new ERR_INVALID_ARG_TYPE(e,"Function",t)},Ha=class extends Error{constructor(e){if(!Array.isArray(e))throw new TypeError(`Expected input to be an Array, got ${typeof e}`);let r="";for(let n=0;n<e.length;n++)r+=` ${e[n].stack}
|
|
2
|
-
`;super(r),this.name="AggregateError",this.errors=e}};Ga.exports={AggregateError:Ha,kEmptyObject:Object.freeze({}),once(t){let e=!1;return function(...r){e||(e=!0,t.apply(this,r))}},createDeferredPromise:function(){let t,e;return{promise:new Promise((n,i)=>{t=n,e=i}),resolve:t,reject:e}},promisify(t){return new Promise((e,r)=>{t((n,...i)=>n?r(n):e(...i))})},debuglog(){return function(){}},format(t,...e){return t.replace(/%([sdifj])/g,function(...[r,n]){let i=e.shift();return n==="f"?i.toFixed(6):n==="j"?JSON.stringify(i):n==="s"&&typeof i=="object"?`${i.constructor!==Object?i.constructor.name:""} {}`.trim():i.toString()})},inspect(t){switch(typeof t){case"string":if(t.includes("'"))if(t.includes('"')){if(!t.includes("`")&&!t.includes("${"))return`\`${t}\``}else return`"${t}"`;return`'${t}'`;case"number":return isNaN(t)?"NaN":Object.is(t,-0)?String(t):t;case"bigint":return`${String(t)}n`;case"boolean":case"undefined":return String(t);case"object":return"{}"}},types:{isAsyncFunction(t){return t instanceof Nm},isArrayBufferView(t){return ArrayBuffer.isView(t)}},isBlob:Dm,deprecate(t,e){return t},addAbortListener:ln().addAbortListener||function(e,r){if(e===void 0)throw new ERR_INVALID_ARG_TYPE("signal","AbortSignal",e);Yl(e,"signal"),Mm(r,"listener");let n;return e.aborted?queueMicrotask(()=>r()):(e.addEventListener("abort",r,{__proto__:null,once:!0,[Cm]:!0}),n=()=>{e.removeEventListener("abort",r)}),{__proto__:null,[Lm](){var i;(i=n)===null||i===void 0||i()}}},AbortSignalAny:Om.any||function(e){if(e.length===1)return e[0];let r=new Km,n=()=>r.abort();return e.forEach(i=>{Yl(i,"signals"),i.addEventListener("abort",n,{once:!0})}),r.signal.addEventListener("abort",()=>{e.forEach(i=>i.removeEventListener("abort",n))},{once:!0}),r.signal}};Ga.exports.promisify.custom=Symbol.for("nodejs.util.promisify.custom")});var Te=M((pS,Ql)=>{"use strict";var{format:qm,inspect:Ao,AggregateError:jm}=Se(),Fm=globalThis.AggregateError||jm,$m=Symbol("kIsNodeError"),Vm=["string","function","number","object","Function","Object","boolean","bigint","symbol"],Hm=/^([A-Z][a-z0-9]*)+$/,Gm="__node_internal_",So={};function qr(t,e){if(!t)throw new So.ERR_INTERNAL_ASSERTION(e)}function Zl(t){let e="",r=t.length,n=t[0]==="-"?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function Wm(t,e,r){if(typeof e=="function")return qr(e.length<=r.length,`Code: ${t}; The provided arguments length (${r.length}) does not match the required ones (${e.length}).`),e(...r);let n=(e.match(/%[dfijoOs]/g)||[]).length;return qr(n===r.length,`Code: ${t}; The provided arguments length (${r.length}) does not match the required ones (${n}).`),r.length===0?e:qm(e,...r)}function xe(t,e,r){r||(r=Error);class n extends r{constructor(...o){super(Wm(t,e,o))}toString(){return`${this.name} [${t}]: ${this.message}`}}Object.defineProperties(n.prototype,{name:{value:r.name,writable:!0,enumerable:!1,configurable:!0},toString:{value(){return`${this.name} [${t}]: ${this.message}`},writable:!0,enumerable:!1,configurable:!0}}),n.prototype.code=t,n.prototype[$m]=!0,So[t]=n}function Xl(t){let e=Gm+t.name;return Object.defineProperty(t,"name",{value:e}),t}function Jm(t,e){if(t&&e&&t!==e){if(Array.isArray(e.errors))return e.errors.push(t),e;let r=new Fm([e,t],e.message);return r.code=e.code,r}return t||e}var Wa=class extends Error{constructor(e="The operation was aborted",r=void 0){if(r!==void 0&&typeof r!="object")throw new So.ERR_INVALID_ARG_TYPE("options","Object",r);super(e,r),this.code="ABORT_ERR",this.name="AbortError"}};xe("ERR_ASSERTION","%s",Error);xe("ERR_INVALID_ARG_TYPE",(t,e,r)=>{qr(typeof t=="string","'name' must be a string"),Array.isArray(e)||(e=[e]);let n="The ";t.endsWith(" argument")?n+=`${t} `:n+=`"${t}" ${t.includes(".")?"property":"argument"} `,n+="must be ";let i=[],o=[],s=[];for(let c of e)qr(typeof c=="string","All expected entries have to be of type string"),Vm.includes(c)?i.push(c.toLowerCase()):Hm.test(c)?o.push(c):(qr(c!=="object",'The value "object" should be written as "Object"'),s.push(c));if(o.length>0){let c=i.indexOf("object");c!==-1&&(i.splice(i,c,1),o.push("Object"))}if(i.length>0){switch(i.length){case 1:n+=`of type ${i[0]}`;break;case 2:n+=`one of type ${i[0]} or ${i[1]}`;break;default:{let c=i.pop();n+=`one of type ${i.join(", ")}, or ${c}`}}(o.length>0||s.length>0)&&(n+=" or ")}if(o.length>0){switch(o.length){case 1:n+=`an instance of ${o[0]}`;break;case 2:n+=`an instance of ${o[0]} or ${o[1]}`;break;default:{let c=o.pop();n+=`an instance of ${o.join(", ")}, or ${c}`}}s.length>0&&(n+=" or ")}switch(s.length){case 0:break;case 1:s[0].toLowerCase()!==s[0]&&(n+="an "),n+=`${s[0]}`;break;case 2:n+=`one of ${s[0]} or ${s[1]}`;break;default:{let c=s.pop();n+=`one of ${s.join(", ")}, or ${c}`}}if(r==null)n+=`. Received ${r}`;else if(typeof r=="function"&&r.name)n+=`. Received function ${r.name}`;else if(typeof r=="object"){var a;if((a=r.constructor)!==null&&a!==void 0&&a.name)n+=`. Received an instance of ${r.constructor.name}`;else{let c=Ao(r,{depth:-1});n+=`. Received ${c}`}}else{let c=Ao(r,{colors:!1});c.length>25&&(c=`${c.slice(0,25)}...`),n+=`. Received type ${typeof r} (${c})`}return n},TypeError);xe("ERR_INVALID_ARG_VALUE",(t,e,r="is invalid")=>{let n=Ao(e);return n.length>128&&(n=n.slice(0,128)+"..."),`The ${t.includes(".")?"property":"argument"} '${t}' ${r}. Received ${n}`},TypeError);xe("ERR_INVALID_RETURN_VALUE",(t,e,r)=>{var n;let i=r!=null&&(n=r.constructor)!==null&&n!==void 0&&n.name?`instance of ${r.constructor.name}`:`type ${typeof r}`;return`Expected ${t} to be returned from the "${e}" function but got ${i}.`},TypeError);xe("ERR_MISSING_ARGS",(...t)=>{qr(t.length>0,"At least one arg needs to be specified");let e,r=t.length;switch(t=(Array.isArray(t)?t:[t]).map(n=>`"${n}"`).join(" or "),r){case 1:e+=`The ${t[0]} argument`;break;case 2:e+=`The ${t[0]} and ${t[1]} arguments`;break;default:{let n=t.pop();e+=`The ${t.join(", ")}, and ${n} arguments`}break}return`${e} must be specified`},TypeError);xe("ERR_OUT_OF_RANGE",(t,e,r)=>{qr(e,'Missing "range" argument');let n;return Number.isInteger(r)&&Math.abs(r)>2**32?n=Zl(String(r)):typeof r=="bigint"?(n=String(r),(r>2n**32n||r<-(2n**32n))&&(n=Zl(n)),n+="n"):n=Ao(r),`The value of "${t}" is out of range. It must be ${e}. Received ${n}`},RangeError);xe("ERR_MULTIPLE_CALLBACK","Callback called multiple times",Error);xe("ERR_METHOD_NOT_IMPLEMENTED","The %s method is not implemented",Error);xe("ERR_STREAM_ALREADY_FINISHED","Cannot call %s after a stream was finished",Error);xe("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable",Error);xe("ERR_STREAM_DESTROYED","Cannot call %s after a stream was destroyed",Error);xe("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);xe("ERR_STREAM_PREMATURE_CLOSE","Premature close",Error);xe("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF",Error);xe("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event",Error);xe("ERR_STREAM_WRITE_AFTER_END","write after end",Error);xe("ERR_UNKNOWN_ENCODING","Unknown encoding: %s",TypeError);Ql.exports={AbortError:Wa,aggregateTwoErrors:Xl(Jm),hideStackFrames:Xl,codes:So}});var Sn=M((yS,fd)=>{"use strict";var{ArrayIsArray:za,ArrayPrototypeIncludes:nd,ArrayPrototypeJoin:id,ArrayPrototypeMap:zm,NumberIsInteger:Ya,NumberIsNaN:Ym,NumberMAX_SAFE_INTEGER:Zm,NumberMIN_SAFE_INTEGER:Xm,NumberParseInt:Qm,ObjectPrototypeHasOwnProperty:eb,RegExpPrototypeExec:od,String:tb,StringPrototypeToUpperCase:rb,StringPrototypeTrim:nb}=ce(),{hideStackFrames:$e,codes:{ERR_SOCKET_BAD_PORT:ib,ERR_INVALID_ARG_TYPE:ve,ERR_INVALID_ARG_VALUE:An,ERR_OUT_OF_RANGE:jr,ERR_UNKNOWN_SIGNAL:ed}}=Te(),{normalizeEncoding:ob}=Se(),{isAsyncFunction:sb,isArrayBufferView:ab}=Se().types,td={};function cb(t){return t===(t|0)}function fb(t){return t===t>>>0}var ub=/^[0-7]+$/,lb="must be a 32-bit unsigned integer or an octal string";function db(t,e,r){if(typeof t>"u"&&(t=r),typeof t=="string"){if(od(ub,t)===null)throw new An(e,t,lb);t=Qm(t,8)}return sd(t,e),t}var hb=$e((t,e,r=Xm,n=Zm)=>{if(typeof t!="number")throw new ve(e,"number",t);if(!Ya(t))throw new jr(e,"an integer",t);if(t<r||t>n)throw new jr(e,`>= ${r} && <= ${n}`,t)}),pb=$e((t,e,r=-2147483648,n=2147483647)=>{if(typeof t!="number")throw new ve(e,"number",t);if(!Ya(t))throw new jr(e,"an integer",t);if(t<r||t>n)throw new jr(e,`>= ${r} && <= ${n}`,t)}),sd=$e((t,e,r=!1)=>{if(typeof t!="number")throw new ve(e,"number",t);if(!Ya(t))throw new jr(e,"an integer",t);let n=r?1:0,i=4294967295;if(t<n||t>i)throw new jr(e,`>= ${n} && <= ${i}`,t)});function Za(t,e){if(typeof t!="string")throw new ve(e,"string",t)}function yb(t,e,r=void 0,n){if(typeof t!="number")throw new ve(e,"number",t);if(r!=null&&t<r||n!=null&&t>n||(r!=null||n!=null)&&Ym(t))throw new jr(e,`${r!=null?`>= ${r}`:""}${r!=null&&n!=null?" && ":""}${n!=null?`<= ${n}`:""}`,t)}var wb=$e((t,e,r)=>{if(!nd(r,t)){let i="must be one of: "+id(zm(r,o=>typeof o=="string"?`'${o}'`:tb(o)),", ");throw new An(e,t,i)}});function ad(t,e){if(typeof t!="boolean")throw new ve(e,"boolean",t)}function Ja(t,e,r){return t==null||!eb(t,e)?r:t[e]}var mb=$e((t,e,r=null)=>{let n=Ja(r,"allowArray",!1),i=Ja(r,"allowFunction",!1);if(!Ja(r,"nullable",!1)&&t===null||!n&&za(t)||typeof t!="object"&&(!i||typeof t!="function"))throw new ve(e,"Object",t)}),bb=$e((t,e)=>{if(t!=null&&typeof t!="object"&&typeof t!="function")throw new ve(e,"a dictionary",t)}),vo=$e((t,e,r=0)=>{if(!za(t))throw new ve(e,"Array",t);if(t.length<r){let n=`must be longer than ${r}`;throw new An(e,t,n)}});function gb(t,e){vo(t,e);for(let r=0;r<t.length;r++)Za(t[r],`${e}[${r}]`)}function xb(t,e){vo(t,e);for(let r=0;r<t.length;r++)ad(t[r],`${e}[${r}]`)}function Eb(t,e){vo(t,e);for(let r=0;r<t.length;r++){let n=t[r],i=`${e}[${r}]`;if(n==null)throw new ve(i,"AbortSignal",n);cd(n,i)}}function _b(t,e="signal"){if(Za(t,e),td[t]===void 0)throw td[rb(t)]!==void 0?new ed(t+" (signals must use all capital letters)"):new ed(t)}var Ab=$e((t,e="buffer")=>{if(!ab(t))throw new ve(e,["Buffer","TypedArray","DataView"],t)});function Sb(t,e){let r=ob(e),n=t.length;if(r==="hex"&&n%2!==0)throw new An("encoding",e,`is invalid for data of length ${n}`)}function vb(t,e="Port",r=!0){if(typeof t!="number"&&typeof t!="string"||typeof t=="string"&&nb(t).length===0||+t!==+t>>>0||t>65535||t===0&&!r)throw new ib(e,t,r);return t|0}var cd=$e((t,e)=>{if(t!==void 0&&(t===null||typeof t!="object"||!("aborted"in t)))throw new ve(e,"AbortSignal",t)}),Bb=$e((t,e)=>{if(typeof t!="function")throw new ve(e,"Function",t)}),Tb=$e((t,e)=>{if(typeof t!="function"||sb(t))throw new ve(e,"Function",t)}),kb=$e((t,e)=>{if(t!==void 0)throw new ve(e,"undefined",t)});function Pb(t,e,r){if(!nd(r,t))throw new ve(e,`('${id(r,"|")}')`,t)}var Ib=/^(?:<[^>]*>)(?:\s*;\s*[^;"\s]+(?:=(")?[^;"\s]*\1)?)*$/;function rd(t,e){if(typeof t>"u"||!od(Ib,t))throw new An(e,t,'must be an array or string of format "</styles.css>; rel=preload; as=style"')}function Rb(t){if(typeof t=="string")return rd(t,"hints"),t;if(za(t)){let e=t.length,r="";if(e===0)return r;for(let n=0;n<e;n++){let i=t[n];rd(i,"hints"),r+=i,n!==e-1&&(r+=", ")}return r}throw new An("hints",t,'must be an array or string of format "</styles.css>; rel=preload; as=style"')}fd.exports={isInt32:cb,isUint32:fb,parseFileMode:db,validateArray:vo,validateStringArray:gb,validateBooleanArray:xb,validateAbortSignalArray:Eb,validateBoolean:ad,validateBuffer:Ab,validateDictionary:bb,validateEncoding:Sb,validateFunction:Bb,validateInt32:pb,validateInteger:hb,validateNumber:yb,validateObject:mb,validateOneOf:wb,validatePlainFunction:Tb,validatePort:vb,validateSignalName:_b,validateString:Za,validateUint32:sd,validateUndefined:kb,validateUnion:Pb,validateAbortSignal:cd,validateLinkHeaderValue:Rb}});var ir=M((wS,hd)=>{var ue=hd.exports={},dt,ht;function Xa(){throw new Error("setTimeout has not been defined")}function Qa(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?dt=setTimeout:dt=Xa}catch{dt=Xa}try{typeof clearTimeout=="function"?ht=clearTimeout:ht=Qa}catch{ht=Qa}})();function ud(t){if(dt===setTimeout)return setTimeout(t,0);if((dt===Xa||!dt)&&setTimeout)return dt=setTimeout,setTimeout(t,0);try{return dt(t,0)}catch{try{return dt.call(null,t,0)}catch{return dt.call(this,t,0)}}}function Ub(t){if(ht===clearTimeout)return clearTimeout(t);if((ht===Qa||!ht)&&clearTimeout)return ht=clearTimeout,clearTimeout(t);try{return ht(t)}catch{try{return ht.call(null,t)}catch{return ht.call(this,t)}}}var Lt=[],vn=!1,Fr,Bo=-1;function Cb(){!vn||!Fr||(vn=!1,Fr.length?Lt=Fr.concat(Lt):Bo=-1,Lt.length&&ld())}function ld(){if(!vn){var t=ud(Cb);vn=!0;for(var e=Lt.length;e;){for(Fr=Lt,Lt=[];++Bo<e;)Fr&&Fr[Bo].run();Bo=-1,e=Lt.length}Fr=null,vn=!1,Ub(t)}}ue.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];Lt.push(new dd(t,e)),Lt.length===1&&!vn&&ud(ld)};function dd(t,e){this.fun=t,this.array=e}dd.prototype.run=function(){this.fun.apply(null,this.array)};ue.title="browser";ue.browser=!0;ue.env={};ue.argv=[];ue.version="";ue.versions={};function Ot(){}ue.on=Ot;ue.addListener=Ot;ue.once=Ot;ue.off=Ot;ue.removeListener=Ot;ue.removeAllListeners=Ot;ue.emit=Ot;ue.prependListener=Ot;ue.prependOnceListener=Ot;ue.listeners=function(t){return[]};ue.binding=function(t){throw new Error("process.binding is not supported")};ue.cwd=function(){return"/"};ue.chdir=function(t){throw new Error("process.chdir is not supported")};ue.umask=function(){return 0}});var yt=M((mS,kd)=>{"use strict";var{SymbolAsyncIterator:pd,SymbolIterator:yd,SymbolFor:$r}=ce(),wd=$r("nodejs.stream.destroyed"),md=$r("nodejs.stream.errored"),ec=$r("nodejs.stream.readable"),tc=$r("nodejs.stream.writable"),bd=$r("nodejs.stream.disturbed"),Lb=$r("nodejs.webstream.isClosedPromise"),Ob=$r("nodejs.webstream.controllerErrorFunction");function To(t,e=!1){var r;return!!(t&&typeof t.pipe=="function"&&typeof t.on=="function"&&(!e||typeof t.pause=="function"&&typeof t.resume=="function")&&(!t._writableState||((r=t._readableState)===null||r===void 0?void 0:r.readable)!==!1)&&(!t._writableState||t._readableState))}function ko(t){var e;return!!(t&&typeof t.write=="function"&&typeof t.on=="function"&&(!t._readableState||((e=t._writableState)===null||e===void 0?void 0:e.writable)!==!1))}function Kb(t){return!!(t&&typeof t.pipe=="function"&&t._readableState&&typeof t.on=="function"&&typeof t.write=="function")}function pt(t){return t&&(t._readableState||t._writableState||typeof t.write=="function"&&typeof t.on=="function"||typeof t.pipe=="function"&&typeof t.on=="function")}function gd(t){return!!(t&&!pt(t)&&typeof t.pipeThrough=="function"&&typeof t.getReader=="function"&&typeof t.cancel=="function")}function xd(t){return!!(t&&!pt(t)&&typeof t.getWriter=="function"&&typeof t.abort=="function")}function Ed(t){return!!(t&&!pt(t)&&typeof t.readable=="object"&&typeof t.writable=="object")}function Nb(t){return gd(t)||xd(t)||Ed(t)}function Db(t,e){return t==null?!1:e===!0?typeof t[pd]=="function":e===!1?typeof t[yd]=="function":typeof t[pd]=="function"||typeof t[yd]=="function"}function Po(t){if(!pt(t))return null;let e=t._writableState,r=t._readableState,n=e||r;return!!(t.destroyed||t[wd]||n!=null&&n.destroyed)}function _d(t){if(!ko(t))return null;if(t.writableEnded===!0)return!0;let e=t._writableState;return e!=null&&e.errored?!1:typeof e?.ended!="boolean"?null:e.ended}function Mb(t,e){if(!ko(t))return null;if(t.writableFinished===!0)return!0;let r=t._writableState;return r!=null&&r.errored?!1:typeof r?.finished!="boolean"?null:!!(r.finished||e===!1&&r.ended===!0&&r.length===0)}function qb(t){if(!To(t))return null;if(t.readableEnded===!0)return!0;let e=t._readableState;return!e||e.errored?!1:typeof e?.ended!="boolean"?null:e.ended}function Ad(t,e){if(!To(t))return null;let r=t._readableState;return r!=null&&r.errored?!1:typeof r?.endEmitted!="boolean"?null:!!(r.endEmitted||e===!1&&r.ended===!0&&r.length===0)}function Sd(t){return t&&t[ec]!=null?t[ec]:typeof t?.readable!="boolean"?null:Po(t)?!1:To(t)&&t.readable&&!Ad(t)}function vd(t){return t&&t[tc]!=null?t[tc]:typeof t?.writable!="boolean"?null:Po(t)?!1:ko(t)&&t.writable&&!_d(t)}function jb(t,e){return pt(t)?Po(t)?!0:!(e?.readable!==!1&&Sd(t)||e?.writable!==!1&&vd(t)):null}function Fb(t){var e,r;return pt(t)?t.writableErrored?t.writableErrored:(e=(r=t._writableState)===null||r===void 0?void 0:r.errored)!==null&&e!==void 0?e:null:null}function $b(t){var e,r;return pt(t)?t.readableErrored?t.readableErrored:(e=(r=t._readableState)===null||r===void 0?void 0:r.errored)!==null&&e!==void 0?e:null:null}function Vb(t){if(!pt(t))return null;if(typeof t.closed=="boolean")return t.closed;let e=t._writableState,r=t._readableState;return typeof e?.closed=="boolean"||typeof r?.closed=="boolean"?e?.closed||r?.closed:typeof t._closed=="boolean"&&Bd(t)?t._closed:null}function Bd(t){return typeof t._closed=="boolean"&&typeof t._defaultKeepAlive=="boolean"&&typeof t._removedConnection=="boolean"&&typeof t._removedContLen=="boolean"}function Td(t){return typeof t._sent100=="boolean"&&Bd(t)}function Hb(t){var e;return typeof t._consuming=="boolean"&&typeof t._dumped=="boolean"&&((e=t.req)===null||e===void 0?void 0:e.upgradeOrConnect)===void 0}function Gb(t){if(!pt(t))return null;let e=t._writableState,r=t._readableState,n=e||r;return!n&&Td(t)||!!(n&&n.autoDestroy&&n.emitClose&&n.closed===!1)}function Wb(t){var e;return!!(t&&((e=t[bd])!==null&&e!==void 0?e:t.readableDidRead||t.readableAborted))}function Jb(t){var e,r,n,i,o,s,a,c,f,u;return!!(t&&((e=(r=(n=(i=(o=(s=t[md])!==null&&s!==void 0?s:t.readableErrored)!==null&&o!==void 0?o:t.writableErrored)!==null&&i!==void 0?i:(a=t._readableState)===null||a===void 0?void 0:a.errorEmitted)!==null&&n!==void 0?n:(c=t._writableState)===null||c===void 0?void 0:c.errorEmitted)!==null&&r!==void 0?r:(f=t._readableState)===null||f===void 0?void 0:f.errored)!==null&&e!==void 0?e:!((u=t._writableState)===null||u===void 0)&&u.errored))}kd.exports={isDestroyed:Po,kIsDestroyed:wd,isDisturbed:Wb,kIsDisturbed:bd,isErrored:Jb,kIsErrored:md,isReadable:Sd,kIsReadable:ec,kIsClosedPromise:Lb,kControllerErrorFunction:Ob,kIsWritable:tc,isClosed:Vb,isDuplexNodeStream:Kb,isFinished:jb,isIterable:Db,isReadableNodeStream:To,isReadableStream:gd,isReadableEnded:qb,isReadableFinished:Ad,isReadableErrored:$b,isNodeStream:pt,isWebStream:Nb,isWritable:vd,isWritableNodeStream:ko,isWritableStream:xd,isWritableEnded:_d,isWritableFinished:Mb,isWritableErrored:Fb,isServerRequest:Hb,isServerResponse:Td,willEmitClose:Gb,isTransformStream:Ed}});var Kt=M((bS,sc)=>{var or=ir(),{AbortError:Nd,codes:zb}=Te(),{ERR_INVALID_ARG_TYPE:Yb,ERR_STREAM_PREMATURE_CLOSE:Pd}=zb,{kEmptyObject:nc,once:ic}=Se(),{validateAbortSignal:Zb,validateFunction:Xb,validateObject:Qb,validateBoolean:eg}=Sn(),{Promise:tg,PromisePrototypeThen:rg,SymbolDispose:Dd}=ce(),{isClosed:ng,isReadable:Id,isReadableNodeStream:rc,isReadableStream:ig,isReadableFinished:Rd,isReadableErrored:Ud,isWritable:Cd,isWritableNodeStream:Ld,isWritableStream:og,isWritableFinished:Od,isWritableErrored:Kd,isNodeStream:sg,willEmitClose:ag,kIsClosedPromise:cg}=yt(),Bn;function fg(t){return t.setHeader&&typeof t.abort=="function"}var oc=()=>{};function Md(t,e,r){var n,i;if(arguments.length===2?(r=e,e=nc):e==null?e=nc:Qb(e,"options"),Xb(r,"callback"),Zb(e.signal,"options.signal"),r=ic(r),ig(t)||og(t))return ug(t,e,r);if(!sg(t))throw new Yb("stream",["ReadableStream","WritableStream","Stream"],t);let o=(n=e.readable)!==null&&n!==void 0?n:rc(t),s=(i=e.writable)!==null&&i!==void 0?i:Ld(t),a=t._writableState,c=t._readableState,f=()=>{t.writable||p()},u=ag(t)&&rc(t)===o&&Ld(t)===s,l=Od(t,!1),p=()=>{l=!0,t.destroyed&&(u=!1),!(u&&(!t.readable||o))&&(!o||h)&&r.call(t)},h=Rd(t,!1),y=()=>{h=!0,t.destroyed&&(u=!1),!(u&&(!t.writable||s))&&(!s||l)&&r.call(t)},d=E=>{r.call(t,E)},w=ng(t),m=()=>{w=!0;let E=Kd(t)||Ud(t);if(E&&typeof E!="boolean")return r.call(t,E);if(o&&!h&&rc(t,!0)&&!Rd(t,!1))return r.call(t,new Pd);if(s&&!l&&!Od(t,!1))return r.call(t,new Pd);r.call(t)},A=()=>{w=!0;let E=Kd(t)||Ud(t);if(E&&typeof E!="boolean")return r.call(t,E);r.call(t)},g=()=>{t.req.on("finish",p)};fg(t)?(t.on("complete",p),u||t.on("abort",m),t.req?g():t.on("request",g)):s&&!a&&(t.on("end",f),t.on("close",f)),!u&&typeof t.aborted=="boolean"&&t.on("aborted",m),t.on("end",y),t.on("finish",p),e.error!==!1&&t.on("error",d),t.on("close",m),w?or.nextTick(m):a!=null&&a.errorEmitted||c!=null&&c.errorEmitted?u||or.nextTick(A):(!o&&(!u||Id(t))&&(l||Cd(t)===!1)||!s&&(!u||Cd(t))&&(h||Id(t)===!1)||c&&t.req&&t.aborted)&&or.nextTick(A);let _=()=>{r=oc,t.removeListener("aborted",m),t.removeListener("complete",p),t.removeListener("abort",m),t.removeListener("request",g),t.req&&t.req.removeListener("finish",p),t.removeListener("end",f),t.removeListener("close",f),t.removeListener("finish",p),t.removeListener("end",y),t.removeListener("error",d),t.removeListener("close",m)};if(e.signal&&!w){let E=()=>{let B=r;_(),B.call(t,new Nd(void 0,{cause:e.signal.reason}))};if(e.signal.aborted)or.nextTick(E);else{Bn=Bn||Se().addAbortListener;let B=Bn(e.signal,E),T=r;r=ic((...k)=>{B[Dd](),T.apply(t,k)})}}return _}function ug(t,e,r){let n=!1,i=oc;if(e.signal)if(i=()=>{n=!0,r.call(t,new Nd(void 0,{cause:e.signal.reason}))},e.signal.aborted)or.nextTick(i);else{Bn=Bn||Se().addAbortListener;let s=Bn(e.signal,i),a=r;r=ic((...c)=>{s[Dd](),a.apply(t,c)})}let o=(...s)=>{n||or.nextTick(()=>r.apply(t,s))};return rg(t[cg].promise,o,o),oc}function lg(t,e){var r;let n=!1;return e===null&&(e=nc),(r=e)!==null&&r!==void 0&&r.cleanup&&(eg(e.cleanup,"cleanup"),n=e.cleanup),new tg((i,o)=>{let s=Md(t,e,a=>{n&&s(),a?o(a):i()})})}sc.exports=Md;sc.exports.finished=lg});var Vr=M((gS,Wd)=>{"use strict";var wt=ir(),{aggregateTwoErrors:dg,codes:{ERR_MULTIPLE_CALLBACK:hg},AbortError:pg}=Te(),{Symbol:Fd}=ce(),{kIsDestroyed:yg,isDestroyed:wg,isFinished:mg,isServerRequest:bg}=yt(),$d=Fd("kDestroy"),ac=Fd("kConstruct");function Vd(t,e,r){t&&(t.stack,e&&!e.errored&&(e.errored=t),r&&!r.errored&&(r.errored=t))}function gg(t,e){let r=this._readableState,n=this._writableState,i=n||r;return n!=null&&n.destroyed||r!=null&&r.destroyed?(typeof e=="function"&&e(),this):(Vd(t,n,r),n&&(n.destroyed=!0),r&&(r.destroyed=!0),i.constructed?qd(this,t,e):this.once($d,function(o){qd(this,dg(o,t),e)}),this)}function qd(t,e,r){let n=!1;function i(o){if(n)return;n=!0;let s=t._readableState,a=t._writableState;Vd(o,a,s),a&&(a.closed=!0),s&&(s.closed=!0),typeof r=="function"&&r(o),o?wt.nextTick(xg,t,o):wt.nextTick(Hd,t)}try{t._destroy(e||null,i)}catch(o){i(o)}}function xg(t,e){cc(t,e),Hd(t)}function Hd(t){let e=t._readableState,r=t._writableState;r&&(r.closeEmitted=!0),e&&(e.closeEmitted=!0),(r!=null&&r.emitClose||e!=null&&e.emitClose)&&t.emit("close")}function cc(t,e){let r=t._readableState,n=t._writableState;n!=null&&n.errorEmitted||r!=null&&r.errorEmitted||(n&&(n.errorEmitted=!0),r&&(r.errorEmitted=!0),t.emit("error",e))}function Eg(){let t=this._readableState,e=this._writableState;t&&(t.constructed=!0,t.closed=!1,t.closeEmitted=!1,t.destroyed=!1,t.errored=null,t.errorEmitted=!1,t.reading=!1,t.ended=t.readable===!1,t.endEmitted=t.readable===!1),e&&(e.constructed=!0,e.destroyed=!1,e.closed=!1,e.closeEmitted=!1,e.errored=null,e.errorEmitted=!1,e.finalCalled=!1,e.prefinished=!1,e.ended=e.writable===!1,e.ending=e.writable===!1,e.finished=e.writable===!1)}function fc(t,e,r){let n=t._readableState,i=t._writableState;if(i!=null&&i.destroyed||n!=null&&n.destroyed)return this;n!=null&&n.autoDestroy||i!=null&&i.autoDestroy?t.destroy(e):e&&(e.stack,i&&!i.errored&&(i.errored=e),n&&!n.errored&&(n.errored=e),r?wt.nextTick(cc,t,e):cc(t,e))}function _g(t,e){if(typeof t._construct!="function")return;let r=t._readableState,n=t._writableState;r&&(r.constructed=!1),n&&(n.constructed=!1),t.once(ac,e),!(t.listenerCount(ac)>1)&&wt.nextTick(Ag,t)}function Ag(t){let e=!1;function r(n){if(e){fc(t,n??new hg);return}e=!0;let i=t._readableState,o=t._writableState,s=o||i;i&&(i.constructed=!0),o&&(o.constructed=!0),s.destroyed?t.emit($d,n):n?fc(t,n,!0):wt.nextTick(Sg,t)}try{t._construct(n=>{wt.nextTick(r,n)})}catch(n){wt.nextTick(r,n)}}function Sg(t){t.emit(ac)}function jd(t){return t?.setHeader&&typeof t.abort=="function"}function Gd(t){t.emit("close")}function vg(t,e){t.emit("error",e),wt.nextTick(Gd,t)}function Bg(t,e){!t||wg(t)||(!e&&!mg(t)&&(e=new pg),bg(t)?(t.socket=null,t.destroy(e)):jd(t)?t.abort():jd(t.req)?t.req.abort():typeof t.destroy=="function"?t.destroy(e):typeof t.close=="function"?t.close():e?wt.nextTick(vg,t,e):wt.nextTick(Gd,t),t.destroyed||(t[yg]=!0))}Wd.exports={construct:_g,destroyer:Bg,destroy:gg,undestroy:Eg,errorOrDestroy:fc}});var Uo=M((xS,zd)=>{"use strict";var{ArrayIsArray:Tg,ObjectSetPrototypeOf:Jd}=ce(),{EventEmitter:Io}=ln();function Ro(t){Io.call(this,t)}Jd(Ro.prototype,Io.prototype);Jd(Ro,Io);Ro.prototype.pipe=function(t,e){let r=this;function n(u){t.writable&&t.write(u)===!1&&r.pause&&r.pause()}r.on("data",n);function i(){r.readable&&r.resume&&r.resume()}t.on("drain",i),!t._isStdio&&(!e||e.end!==!1)&&(r.on("end",s),r.on("close",a));let o=!1;function s(){o||(o=!0,t.end())}function a(){o||(o=!0,typeof t.destroy=="function"&&t.destroy())}function c(u){f(),Io.listenerCount(this,"error")===0&&this.emit("error",u)}uc(r,"error",c),uc(t,"error",c);function f(){r.removeListener("data",n),t.removeListener("drain",i),r.removeListener("end",s),r.removeListener("close",a),r.removeListener("error",c),t.removeListener("error",c),r.removeListener("end",f),r.removeListener("close",f),t.removeListener("close",f)}return r.on("end",f),r.on("close",f),t.on("close",f),t.emit("pipe",r),t};function uc(t,e,r){if(typeof t.prependListener=="function")return t.prependListener(e,r);!t._events||!t._events[e]?t.on(e,r):Tg(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]}zd.exports={Stream:Ro,prependListener:uc}});var gi=M((ES,Co)=>{"use strict";var{SymbolDispose:kg}=ce(),{AbortError:Yd,codes:Pg}=Te(),{isNodeStream:Zd,isWebStream:Ig,kControllerErrorFunction:Rg}=yt(),Ug=Kt(),{ERR_INVALID_ARG_TYPE:Xd}=Pg,lc,Cg=(t,e)=>{if(typeof t!="object"||!("aborted"in t))throw new Xd(e,"AbortSignal",t)};Co.exports.addAbortSignal=function(e,r){if(Cg(e,"signal"),!Zd(r)&&!Ig(r))throw new Xd("stream",["ReadableStream","WritableStream","Stream"],r);return Co.exports.addAbortSignalNoValidate(e,r)};Co.exports.addAbortSignalNoValidate=function(t,e){if(typeof t!="object"||!("aborted"in t))return e;let r=Zd(e)?()=>{e.destroy(new Yd(void 0,{cause:t.reason}))}:()=>{e[Rg](new Yd(void 0,{cause:t.reason}))};if(t.aborted)r();else{lc=lc||Se().addAbortListener;let n=lc(t,r);Ug(e,n[kg])}return e}});var th=M((AS,eh)=>{"use strict";var{StringPrototypeSlice:Qd,SymbolIterator:Lg,TypedArrayPrototypeSet:Lo,Uint8Array:Og}=ce(),{Buffer:dc}=qe(),{inspect:Kg}=Se();eh.exports=class{constructor(){this.head=null,this.tail=null,this.length=0}push(e){let r={data:e,next:null};this.length>0?this.tail.next=r:this.head=r,this.tail=r,++this.length}unshift(e){let r={data:e,next:this.head};this.length===0&&(this.tail=r),this.head=r,++this.length}shift(){if(this.length===0)return;let e=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,e}clear(){this.head=this.tail=null,this.length=0}join(e){if(this.length===0)return"";let r=this.head,n=""+r.data;for(;(r=r.next)!==null;)n+=e+r.data;return n}concat(e){if(this.length===0)return dc.alloc(0);let r=dc.allocUnsafe(e>>>0),n=this.head,i=0;for(;n;)Lo(r,n.data,i),i+=n.data.length,n=n.next;return r}consume(e,r){let n=this.head.data;if(e<n.length){let i=n.slice(0,e);return this.head.data=n.slice(e),i}return e===n.length?this.shift():r?this._getString(e):this._getBuffer(e)}first(){return this.head.data}*[Lg](){for(let e=this.head;e;e=e.next)yield e.data}_getString(e){let r="",n=this.head,i=0;do{let o=n.data;if(e>o.length)r+=o,e-=o.length;else{e===o.length?(r+=o,++i,n.next?this.head=n.next:this.head=this.tail=null):(r+=Qd(o,0,e),this.head=n,n.data=Qd(o,e));break}++i}while((n=n.next)!==null);return this.length-=i,r}_getBuffer(e){let r=dc.allocUnsafe(e),n=e,i=this.head,o=0;do{let s=i.data;if(e>s.length)Lo(r,s,n-e),e-=s.length;else{e===s.length?(Lo(r,s,n-e),++o,i.next?this.head=i.next:this.head=this.tail=null):(Lo(r,new Og(s.buffer,s.byteOffset,e),n-e),this.head=i,i.data=s.slice(e));break}++o}while((i=i.next)!==null);return this.length-=o,r}[Symbol.for("nodejs.util.inspect.custom")](e,r){return Kg(this,{...r,depth:0,customInspect:!1})}}});var xi=M((SS,oh)=>{"use strict";var{MathFloor:Ng,NumberIsInteger:Dg}=ce(),{validateInteger:Mg}=Sn(),{ERR_INVALID_ARG_VALUE:qg}=Te().codes,rh=16*1024,nh=16;function jg(t,e,r){return t.highWaterMark!=null?t.highWaterMark:e?t[r]:null}function ih(t){return t?nh:rh}function Fg(t,e){Mg(e,"value",0),t?nh=e:rh=e}function $g(t,e,r,n){let i=jg(e,n,r);if(i!=null){if(!Dg(i)||i<0){let o=n?`options.${r}`:"options.highWaterMark";throw new qg(o,i)}return Ng(i)}return ih(t.objectMode)}oh.exports={getHighWaterMark:$g,getDefaultHighWaterMark:ih,setDefaultHighWaterMark:Fg}});var ch=M((hc,ah)=>{var Oo=qe(),mt=Oo.Buffer;function sh(t,e){for(var r in t)e[r]=t[r]}mt.from&&mt.alloc&&mt.allocUnsafe&&mt.allocUnsafeSlow?ah.exports=Oo:(sh(Oo,hc),hc.Buffer=Hr);function Hr(t,e,r){return mt(t,e,r)}Hr.prototype=Object.create(mt.prototype);sh(mt,Hr);Hr.from=function(t,e,r){if(typeof t=="number")throw new TypeError("Argument must not be a number");return mt(t,e,r)};Hr.alloc=function(t,e,r){if(typeof t!="number")throw new TypeError("Argument must be a number");var n=mt(t);return e!==void 0?typeof r=="string"?n.fill(e,r):n.fill(e):n.fill(0),n};Hr.allocUnsafe=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return mt(t)};Hr.allocUnsafeSlow=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return Oo.SlowBuffer(t)}});var lh=M(uh=>{"use strict";var yc=ch().Buffer,fh=yc.isEncoding||function(t){switch(t=""+t,t&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function Vg(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}function Hg(t){var e=Vg(t);if(typeof e!="string"&&(yc.isEncoding===fh||!fh(t)))throw new Error("Unknown encoding: "+t);return e||t}uh.StringDecoder=Ei;function Ei(t){this.encoding=Hg(t);var e;switch(this.encoding){case"utf16le":this.text=Zg,this.end=Xg,e=4;break;case"utf8":this.fillLast=Jg,e=4;break;case"base64":this.text=Qg,this.end=ex,e=3;break;default:this.write=tx,this.end=rx;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=yc.allocUnsafe(e)}Ei.prototype.write=function(t){if(t.length===0)return"";var e,r;if(this.lastNeed){if(e=this.fillLast(t),e===void 0)return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<t.length?e?e+this.text(t,r):this.text(t,r):e||""};Ei.prototype.end=Yg;Ei.prototype.text=zg;Ei.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length};function pc(t){return t<=127?0:t>>5===6?2:t>>4===14?3:t>>3===30?4:t>>6===2?-1:-2}function Gg(t,e,r){var n=e.length-1;if(n<r)return 0;var i=pc(e[n]);return i>=0?(i>0&&(t.lastNeed=i-1),i):--n<r||i===-2?0:(i=pc(e[n]),i>=0?(i>0&&(t.lastNeed=i-2),i):--n<r||i===-2?0:(i=pc(e[n]),i>=0?(i>0&&(i===2?i=0:t.lastNeed=i-3),i):0))}function Wg(t,e,r){if((e[0]&192)!==128)return t.lastNeed=0,"\uFFFD";if(t.lastNeed>1&&e.length>1){if((e[1]&192)!==128)return t.lastNeed=1,"\uFFFD";if(t.lastNeed>2&&e.length>2&&(e[2]&192)!==128)return t.lastNeed=2,"\uFFFD"}}function Jg(t){var e=this.lastTotal-this.lastNeed,r=Wg(this,t,e);if(r!==void 0)return r;if(this.lastNeed<=t.length)return t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,e,0,t.length),this.lastNeed-=t.length}function zg(t,e){var r=Gg(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)}function Yg(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"\uFFFD":e}function Zg(t,e){if((t.length-e)%2===0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function Xg(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function Qg(t,e){var r=(t.length-e)%3;return r===0?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,r===1?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function ex(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function tx(t){return t.toString(this.encoding)}function rx(t){return t&&t.length?this.write(t):""}});var wc=M((BS,yh)=>{"use strict";var dh=ir(),{PromisePrototypeThen:nx,SymbolAsyncIterator:hh,SymbolIterator:ph}=ce(),{Buffer:ix}=qe(),{ERR_INVALID_ARG_TYPE:ox,ERR_STREAM_NULL_VALUES:sx}=Te().codes;function ax(t,e,r){let n;if(typeof e=="string"||e instanceof ix)return new t({objectMode:!0,...r,read(){this.push(e),this.push(null)}});let i;if(e&&e[hh])i=!0,n=e[hh]();else if(e&&e[ph])i=!1,n=e[ph]();else throw new ox("iterable",["Iterable"],e);let o=new t({objectMode:!0,highWaterMark:1,...r}),s=!1;o._read=function(){s||(s=!0,c())},o._destroy=function(f,u){nx(a(f),()=>dh.nextTick(u,f),l=>dh.nextTick(u,l||f))};async function a(f){let u=f!=null,l=typeof n.throw=="function";if(u&&l){let{value:p,done:h}=await n.throw(f);if(await p,h)return}if(typeof n.return=="function"){let{value:p}=await n.return();await p}}async function c(){for(;;){try{let{value:f,done:u}=i?await n.next():n.next();if(u)o.push(null);else{let l=f&&typeof f.then=="function"?await f:f;if(l===null)throw s=!1,new sx;if(o.push(l))continue;s=!1}}catch(f){o.destroy(f)}break}}return o}yh.exports=ax});var Ai=M((TS,Ch)=>{var Xe=ir(),{ArrayPrototypeIndexOf:cx,NumberIsInteger:fx,NumberIsNaN:ux,NumberParseInt:lx,ObjectDefineProperties:Sc,ObjectKeys:dx,ObjectSetPrototypeOf:bh,Promise:gh,SafeSet:hx,SymbolAsyncDispose:px,SymbolAsyncIterator:yx,Symbol:wx}=ce();Ch.exports=z;z.ReadableState=Mo;var{EventEmitter:mx}=ln(),{Stream:sr,prependListener:bx}=Uo(),{Buffer:mc}=qe(),{addAbortSignal:gx}=gi(),xh=Kt(),Q=Se().debuglog("stream",t=>{Q=t}),xx=th(),Pn=Vr(),{getHighWaterMark:Ex,getDefaultHighWaterMark:_x}=xi(),{aggregateTwoErrors:wh,codes:{ERR_INVALID_ARG_TYPE:Ax,ERR_METHOD_NOT_IMPLEMENTED:Sx,ERR_OUT_OF_RANGE:vx,ERR_STREAM_PUSH_AFTER_EOF:Bx,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:Tx},AbortError:kx}=Te(),{validateObject:Px}=Sn(),Gr=wx("kPaused"),{StringDecoder:Eh}=lh(),Ix=wc();bh(z.prototype,sr.prototype);bh(z,sr);var bc=()=>{},{errorOrDestroy:Tn}=Pn,kn=1,Rx=2,_h=4,_i=8,Ah=16,Ko=32,No=64,Sh=128,Ux=256,Cx=512,Lx=1024,_c=2048,Ac=4096,Ox=8192,Kx=16384,Nx=32768,vh=65536,Dx=1<<17,Mx=1<<18;function he(t){return{enumerable:!1,get(){return(this.state&t)!==0},set(e){e?this.state|=t:this.state&=~t}}}Sc(Mo.prototype,{objectMode:he(kn),ended:he(Rx),endEmitted:he(_h),reading:he(_i),constructed:he(Ah),sync:he(Ko),needReadable:he(No),emittedReadable:he(Sh),readableListening:he(Ux),resumeScheduled:he(Cx),errorEmitted:he(Lx),emitClose:he(_c),autoDestroy:he(Ac),destroyed:he(Ox),closed:he(Kx),closeEmitted:he(Nx),multiAwaitDrain:he(vh),readingMore:he(Dx),dataEmitted:he(Mx)});function Mo(t,e,r){typeof r!="boolean"&&(r=e instanceof bt()),this.state=_c|Ac|Ah|Ko,t&&t.objectMode&&(this.state|=kn),r&&t&&t.readableObjectMode&&(this.state|=kn),this.highWaterMark=t?Ex(this,t,"readableHighWaterMark",r):_x(!1),this.buffer=new xx,this.length=0,this.pipes=[],this.flowing=null,this[Gr]=null,t&&t.emitClose===!1&&(this.state&=~_c),t&&t.autoDestroy===!1&&(this.state&=~Ac),this.errored=null,this.defaultEncoding=t&&t.defaultEncoding||"utf8",this.awaitDrainWriters=null,this.decoder=null,this.encoding=null,t&&t.encoding&&(this.decoder=new Eh(t.encoding),this.encoding=t.encoding)}function z(t){if(!(this instanceof z))return new z(t);let e=this instanceof bt();this._readableState=new Mo(t,this,e),t&&(typeof t.read=="function"&&(this._read=t.read),typeof t.destroy=="function"&&(this._destroy=t.destroy),typeof t.construct=="function"&&(this._construct=t.construct),t.signal&&!e&&gx(t.signal,this)),sr.call(this,t),Pn.construct(this,()=>{this._readableState.needReadable&&Do(this,this._readableState)})}z.prototype.destroy=Pn.destroy;z.prototype._undestroy=Pn.undestroy;z.prototype._destroy=function(t,e){e(t)};z.prototype[mx.captureRejectionSymbol]=function(t){this.destroy(t)};z.prototype[px]=function(){let t;return this.destroyed||(t=this.readableEnded?null:new kx,this.destroy(t)),new gh((e,r)=>xh(this,n=>n&&n!==t?r(n):e(null)))};z.prototype.push=function(t,e){return Bh(this,t,e,!1)};z.prototype.unshift=function(t,e){return Bh(this,t,e,!0)};function Bh(t,e,r,n){Q("readableAddChunk",e);let i=t._readableState,o;if(i.state&kn||(typeof e=="string"?(r=r||i.defaultEncoding,i.encoding!==r&&(n&&i.encoding?e=mc.from(e,r).toString(i.encoding):(e=mc.from(e,r),r=""))):e instanceof mc?r="":sr._isUint8Array(e)?(e=sr._uint8ArrayToBuffer(e),r=""):e!=null&&(o=new Ax("chunk",["string","Buffer","Uint8Array"],e))),o)Tn(t,o);else if(e===null)i.state&=~_i,Fx(t,i);else if(i.state&kn||e&&e.length>0)if(n)if(i.state&_h)Tn(t,new Tx);else{if(i.destroyed||i.errored)return!1;gc(t,i,e,!0)}else if(i.ended)Tn(t,new Bx);else{if(i.destroyed||i.errored)return!1;i.state&=~_i,i.decoder&&!r?(e=i.decoder.write(e),i.objectMode||e.length!==0?gc(t,i,e,!1):Do(t,i)):gc(t,i,e,!1)}else n||(i.state&=~_i,Do(t,i));return!i.ended&&(i.length<i.highWaterMark||i.length===0)}function gc(t,e,r,n){e.flowing&&e.length===0&&!e.sync&&t.listenerCount("data")>0?(e.state&vh?e.awaitDrainWriters.clear():e.awaitDrainWriters=null,e.dataEmitted=!0,t.emit("data",r)):(e.length+=e.objectMode?1:r.length,n?e.buffer.unshift(r):e.buffer.push(r),e.state&No&&qo(t)),Do(t,e)}z.prototype.isPaused=function(){let t=this._readableState;return t[Gr]===!0||t.flowing===!1};z.prototype.setEncoding=function(t){let e=new Eh(t);this._readableState.decoder=e,this._readableState.encoding=this._readableState.decoder.encoding;let r=this._readableState.buffer,n="";for(let i of r)n+=e.write(i);return r.clear(),n!==""&&r.push(n),this._readableState.length=n.length,this};var qx=1073741824;function jx(t){if(t>qx)throw new vx("size","<= 1GiB",t);return t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++,t}function mh(t,e){return t<=0||e.length===0&&e.ended?0:e.state&kn?1:ux(t)?e.flowing&&e.length?e.buffer.first().length:e.length:t<=e.length?t:e.ended?e.length:0}z.prototype.read=function(t){Q("read",t),t===void 0?t=NaN:fx(t)||(t=lx(t,10));let e=this._readableState,r=t;if(t>e.highWaterMark&&(e.highWaterMark=jx(t)),t!==0&&(e.state&=~Sh),t===0&&e.needReadable&&((e.highWaterMark!==0?e.length>=e.highWaterMark:e.length>0)||e.ended))return Q("read: emitReadable",e.length,e.ended),e.length===0&&e.ended?xc(this):qo(this),null;if(t=mh(t,e),t===0&&e.ended)return e.length===0&&xc(this),null;let n=(e.state&No)!==0;if(Q("need readable",n),(e.length===0||e.length-t<e.highWaterMark)&&(n=!0,Q("length less than watermark",n)),e.ended||e.reading||e.destroyed||e.errored||!e.constructed)n=!1,Q("reading, ended or constructing",n);else if(n){Q("do read"),e.state|=_i|Ko,e.length===0&&(e.state|=No);try{this._read(e.highWaterMark)}catch(o){Tn(this,o)}e.state&=~Ko,e.reading||(t=mh(r,e))}let i;return t>0?i=Rh(t,e):i=null,i===null?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.multiAwaitDrain?e.awaitDrainWriters.clear():e.awaitDrainWriters=null),e.length===0&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&xc(this)),i!==null&&!e.errorEmitted&&!e.closeEmitted&&(e.dataEmitted=!0,this.emit("data",i)),i};function Fx(t,e){if(Q("onEofChunk"),!e.ended){if(e.decoder){let r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.sync?qo(t):(e.needReadable=!1,e.emittedReadable=!0,Th(t))}}function qo(t){let e=t._readableState;Q("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(Q("emitReadable",e.flowing),e.emittedReadable=!0,Xe.nextTick(Th,t))}function Th(t){let e=t._readableState;Q("emitReadable_",e.destroyed,e.length,e.ended),!e.destroyed&&!e.errored&&(e.length||e.ended)&&(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,Ph(t)}function Do(t,e){!e.readingMore&&e.constructed&&(e.readingMore=!0,Xe.nextTick($x,t,e))}function $x(t,e){for(;!e.reading&&!e.ended&&(e.length<e.highWaterMark||e.flowing&&e.length===0);){let r=e.length;if(Q("maybeReadMore read 0"),t.read(0),r===e.length)break}e.readingMore=!1}z.prototype._read=function(t){throw new Sx("_read()")};z.prototype.pipe=function(t,e){let r=this,n=this._readableState;n.pipes.length===1&&(n.multiAwaitDrain||(n.multiAwaitDrain=!0,n.awaitDrainWriters=new hx(n.awaitDrainWriters?[n.awaitDrainWriters]:[]))),n.pipes.push(t),Q("pipe count=%d opts=%j",n.pipes.length,e);let o=(!e||e.end!==!1)&&t!==Xe.stdout&&t!==Xe.stderr?a:w;n.endEmitted?Xe.nextTick(o):r.once("end",o),t.on("unpipe",s);function s(m,A){Q("onunpipe"),m===r&&A&&A.hasUnpiped===!1&&(A.hasUnpiped=!0,u())}function a(){Q("onend"),t.end()}let c,f=!1;function u(){Q("cleanup"),t.removeListener("close",y),t.removeListener("finish",d),c&&t.removeListener("drain",c),t.removeListener("error",h),t.removeListener("unpipe",s),r.removeListener("end",a),r.removeListener("end",w),r.removeListener("data",p),f=!0,c&&n.awaitDrainWriters&&(!t._writableState||t._writableState.needDrain)&&c()}function l(){f||(n.pipes.length===1&&n.pipes[0]===t?(Q("false write response, pause",0),n.awaitDrainWriters=t,n.multiAwaitDrain=!1):n.pipes.length>1&&n.pipes.includes(t)&&(Q("false write response, pause",n.awaitDrainWriters.size),n.awaitDrainWriters.add(t)),r.pause()),c||(c=Vx(r,t),t.on("drain",c))}r.on("data",p);function p(m){Q("ondata");let A=t.write(m);Q("dest.write",A),A===!1&&l()}function h(m){if(Q("onerror",m),w(),t.removeListener("error",h),t.listenerCount("error")===0){let A=t._writableState||t._readableState;A&&!A.errorEmitted?Tn(t,m):t.emit("error",m)}}bx(t,"error",h);function y(){t.removeListener("finish",d),w()}t.once("close",y);function d(){Q("onfinish"),t.removeListener("close",y),w()}t.once("finish",d);function w(){Q("unpipe"),r.unpipe(t)}return t.emit("pipe",r),t.writableNeedDrain===!0?l():n.flowing||(Q("pipe resume"),r.resume()),t};function Vx(t,e){return function(){let n=t._readableState;n.awaitDrainWriters===e?(Q("pipeOnDrain",1),n.awaitDrainWriters=null):n.multiAwaitDrain&&(Q("pipeOnDrain",n.awaitDrainWriters.size),n.awaitDrainWriters.delete(e)),(!n.awaitDrainWriters||n.awaitDrainWriters.size===0)&&t.listenerCount("data")&&t.resume()}}z.prototype.unpipe=function(t){let e=this._readableState,r={hasUnpiped:!1};if(e.pipes.length===0)return this;if(!t){let i=e.pipes;e.pipes=[],this.pause();for(let o=0;o<i.length;o++)i[o].emit("unpipe",this,{hasUnpiped:!1});return this}let n=cx(e.pipes,t);return n===-1?this:(e.pipes.splice(n,1),e.pipes.length===0&&this.pause(),t.emit("unpipe",this,r),this)};z.prototype.on=function(t,e){let r=sr.prototype.on.call(this,t,e),n=this._readableState;return t==="data"?(n.readableListening=this.listenerCount("readable")>0,n.flowing!==!1&&this.resume()):t==="readable"&&!n.endEmitted&&!n.readableListening&&(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,Q("on readable",n.length,n.reading),n.length?qo(this):n.reading||Xe.nextTick(Hx,this)),r};z.prototype.addListener=z.prototype.on;z.prototype.removeListener=function(t,e){let r=sr.prototype.removeListener.call(this,t,e);return t==="readable"&&Xe.nextTick(kh,this),r};z.prototype.off=z.prototype.removeListener;z.prototype.removeAllListeners=function(t){let e=sr.prototype.removeAllListeners.apply(this,arguments);return(t==="readable"||t===void 0)&&Xe.nextTick(kh,this),e};function kh(t){let e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&e[Gr]===!1?e.flowing=!0:t.listenerCount("data")>0?t.resume():e.readableListening||(e.flowing=null)}function Hx(t){Q("readable nexttick read 0"),t.read(0)}z.prototype.resume=function(){let t=this._readableState;return t.flowing||(Q("resume"),t.flowing=!t.readableListening,Gx(this,t)),t[Gr]=!1,this};function Gx(t,e){e.resumeScheduled||(e.resumeScheduled=!0,Xe.nextTick(Wx,t,e))}function Wx(t,e){Q("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),Ph(t),e.flowing&&!e.reading&&t.read(0)}z.prototype.pause=function(){return Q("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(Q("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState[Gr]=!0,this};function Ph(t){let e=t._readableState;for(Q("flow",e.flowing);e.flowing&&t.read()!==null;);}z.prototype.wrap=function(t){let e=!1;t.on("data",n=>{!this.push(n)&&t.pause&&(e=!0,t.pause())}),t.on("end",()=>{this.push(null)}),t.on("error",n=>{Tn(this,n)}),t.on("close",()=>{this.destroy()}),t.on("destroy",()=>{this.destroy()}),this._read=()=>{e&&t.resume&&(e=!1,t.resume())};let r=dx(t);for(let n=1;n<r.length;n++){let i=r[n];this[i]===void 0&&typeof t[i]=="function"&&(this[i]=t[i].bind(t))}return this};z.prototype[yx]=function(){return Ih(this)};z.prototype.iterator=function(t){return t!==void 0&&Px(t,"options"),Ih(this,t)};function Ih(t,e){typeof t.read!="function"&&(t=z.wrap(t,{objectMode:!0}));let r=Jx(t,e);return r.stream=t,r}async function*Jx(t,e){let r=bc;function n(s){this===t?(r(),r=bc):r=s}t.on("readable",n);let i,o=xh(t,{writable:!1},s=>{i=s?wh(i,s):null,r(),r=bc});try{for(;;){let s=t.destroyed?null:t.read();if(s!==null)yield s;else{if(i)throw i;if(i===null)return;await new gh(n)}}}catch(s){throw i=wh(i,s),i}finally{(i||e?.destroyOnReturn!==!1)&&(i===void 0||t._readableState.autoDestroy)?Pn.destroyer(t,null):(t.off("readable",n),o())}}Sc(z.prototype,{readable:{__proto__:null,get(){let t=this._readableState;return!!t&&t.readable!==!1&&!t.destroyed&&!t.errorEmitted&&!t.endEmitted},set(t){this._readableState&&(this._readableState.readable=!!t)}},readableDidRead:{__proto__:null,enumerable:!1,get:function(){return this._readableState.dataEmitted}},readableAborted:{__proto__:null,enumerable:!1,get:function(){return!!(this._readableState.readable!==!1&&(this._readableState.destroyed||this._readableState.errored)&&!this._readableState.endEmitted)}},readableHighWaterMark:{__proto__:null,enumerable:!1,get:function(){return this._readableState.highWaterMark}},readableBuffer:{__proto__:null,enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}},readableFlowing:{__proto__:null,enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}},readableLength:{__proto__:null,enumerable:!1,get(){return this._readableState.length}},readableObjectMode:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.objectMode:!1}},readableEncoding:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.encoding:null}},errored:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.errored:null}},closed:{__proto__:null,get(){return this._readableState?this._readableState.closed:!1}},destroyed:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.destroyed:!1},set(t){this._readableState&&(this._readableState.destroyed=t)}},readableEnded:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.endEmitted:!1}}});Sc(Mo.prototype,{pipesCount:{__proto__:null,get(){return this.pipes.length}},paused:{__proto__:null,get(){return this[Gr]!==!1},set(t){this[Gr]=!!t}}});z._fromList=Rh;function Rh(t,e){if(e.length===0)return null;let r;return e.objectMode?r=e.buffer.shift():!t||t>=e.length?(e.decoder?r=e.buffer.join(""):e.buffer.length===1?r=e.buffer.first():r=e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r}function xc(t){let e=t._readableState;Q("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,Xe.nextTick(zx,e,t))}function zx(t,e){if(Q("endReadableNT",t.endEmitted,t.length),!t.errored&&!t.closeEmitted&&!t.endEmitted&&t.length===0){if(t.endEmitted=!0,e.emit("end"),e.writable&&e.allowHalfOpen===!1)Xe.nextTick(Yx,e);else if(t.autoDestroy){let r=e._writableState;(!r||r.autoDestroy&&(r.finished||r.writable===!1))&&e.destroy()}}}function Yx(t){t.writable&&!t.writableEnded&&!t.destroyed&&t.end()}z.from=function(t,e){return Ix(z,t,e)};var Ec;function Uh(){return Ec===void 0&&(Ec={}),Ec}z.fromWeb=function(t,e){return Uh().newStreamReadableFromReadableStream(t,e)};z.toWeb=function(t,e){return Uh().newReadableStreamFromStreamReadable(t,e)};z.wrap=function(t,e){var r,n;return new z({objectMode:(r=(n=t.readableObjectMode)!==null&&n!==void 0?n:t.objectMode)!==null&&r!==void 0?r:!0,...e,destroy(i,o){Pn.destroyer(t,i),o(i)}}).wrap(t)}});var Ho=M((kS,Hh)=>{var Wr=ir(),{ArrayPrototypeSlice:Kh,Error:Zx,FunctionPrototypeSymbolHasInstance:Nh,ObjectDefineProperty:Dh,ObjectDefineProperties:Xx,ObjectSetPrototypeOf:Mh,StringPrototypeToLowerCase:Qx,Symbol:eE,SymbolHasInstance:tE}=ce();Hh.exports=fe;fe.WritableState=Bi;var{EventEmitter:rE}=ln(),Si=Uo().Stream,{Buffer:jo}=qe(),Vo=Vr(),{addAbortSignal:nE}=gi(),{getHighWaterMark:iE,getDefaultHighWaterMark:oE}=xi(),{ERR_INVALID_ARG_TYPE:sE,ERR_METHOD_NOT_IMPLEMENTED:aE,ERR_MULTIPLE_CALLBACK:qh,ERR_STREAM_CANNOT_PIPE:cE,ERR_STREAM_DESTROYED:vi,ERR_STREAM_ALREADY_FINISHED:fE,ERR_STREAM_NULL_VALUES:uE,ERR_STREAM_WRITE_AFTER_END:lE,ERR_UNKNOWN_ENCODING:jh}=Te().codes,{errorOrDestroy:In}=Vo;Mh(fe.prototype,Si.prototype);Mh(fe,Si);function Tc(){}var Rn=eE("kOnFinished");function Bi(t,e,r){typeof r!="boolean"&&(r=e instanceof bt()),this.objectMode=!!(t&&t.objectMode),r&&(this.objectMode=this.objectMode||!!(t&&t.writableObjectMode)),this.highWaterMark=t?iE(this,t,"writableHighWaterMark",r):oE(!1),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;let n=!!(t&&t.decodeStrings===!1);this.decodeStrings=!n,this.defaultEncoding=t&&t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=hE.bind(void 0,e),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,$o(this),this.pendingcb=0,this.constructed=!0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!t||t.emitClose!==!1,this.autoDestroy=!t||t.autoDestroy!==!1,this.errored=null,this.closed=!1,this.closeEmitted=!1,this[Rn]=[]}function $o(t){t.buffered=[],t.bufferedIndex=0,t.allBuffers=!0,t.allNoop=!0}Bi.prototype.getBuffer=function(){return Kh(this.buffered,this.bufferedIndex)};Dh(Bi.prototype,"bufferedRequestCount",{__proto__:null,get(){return this.buffered.length-this.bufferedIndex}});function fe(t){let e=this instanceof bt();if(!e&&!Nh(fe,this))return new fe(t);this._writableState=new Bi(t,this,e),t&&(typeof t.write=="function"&&(this._write=t.write),typeof t.writev=="function"&&(this._writev=t.writev),typeof t.destroy=="function"&&(this._destroy=t.destroy),typeof t.final=="function"&&(this._final=t.final),typeof t.construct=="function"&&(this._construct=t.construct),t.signal&&nE(t.signal,this)),Si.call(this,t),Vo.construct(this,()=>{let r=this._writableState;r.writing||Pc(this,r),Ic(this,r)})}Dh(fe,tE,{__proto__:null,value:function(t){return Nh(this,t)?!0:this!==fe?!1:t&&t._writableState instanceof Bi}});fe.prototype.pipe=function(){In(this,new cE)};function Fh(t,e,r,n){let i=t._writableState;if(typeof r=="function")n=r,r=i.defaultEncoding;else{if(!r)r=i.defaultEncoding;else if(r!=="buffer"&&!jo.isEncoding(r))throw new jh(r);typeof n!="function"&&(n=Tc)}if(e===null)throw new uE;if(!i.objectMode)if(typeof e=="string")i.decodeStrings!==!1&&(e=jo.from(e,r),r="buffer");else if(e instanceof jo)r="buffer";else if(Si._isUint8Array(e))e=Si._uint8ArrayToBuffer(e),r="buffer";else throw new sE("chunk",["string","Buffer","Uint8Array"],e);let o;return i.ending?o=new lE:i.destroyed&&(o=new vi("write")),o?(Wr.nextTick(n,o),In(t,o,!0),o):(i.pendingcb++,dE(t,i,e,r,n))}fe.prototype.write=function(t,e,r){return Fh(this,t,e,r)===!0};fe.prototype.cork=function(){this._writableState.corked++};fe.prototype.uncork=function(){let t=this._writableState;t.corked&&(t.corked--,t.writing||Pc(this,t))};fe.prototype.setDefaultEncoding=function(e){if(typeof e=="string"&&(e=Qx(e)),!jo.isEncoding(e))throw new jh(e);return this._writableState.defaultEncoding=e,this};function dE(t,e,r,n,i){let o=e.objectMode?1:r.length;e.length+=o;let s=e.length<e.highWaterMark;return s||(e.needDrain=!0),e.writing||e.corked||e.errored||!e.constructed?(e.buffered.push({chunk:r,encoding:n,callback:i}),e.allBuffers&&n!=="buffer"&&(e.allBuffers=!1),e.allNoop&&i!==Tc&&(e.allNoop=!1)):(e.writelen=o,e.writecb=i,e.writing=!0,e.sync=!0,t._write(r,n,e.onwrite),e.sync=!1),s&&!e.errored&&!e.destroyed}function Lh(t,e,r,n,i,o,s){e.writelen=n,e.writecb=s,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new vi("write")):r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function Oh(t,e,r,n){--e.pendingcb,n(r),kc(e),In(t,r)}function hE(t,e){let r=t._writableState,n=r.sync,i=r.writecb;if(typeof i!="function"){In(t,new qh);return}r.writing=!1,r.writecb=null,r.length-=r.writelen,r.writelen=0,e?(e.stack,r.errored||(r.errored=e),t._readableState&&!t._readableState.errored&&(t._readableState.errored=e),n?Wr.nextTick(Oh,t,r,e,i):Oh(t,r,e,i)):(r.buffered.length>r.bufferedIndex&&Pc(t,r),n?r.afterWriteTickInfo!==null&&r.afterWriteTickInfo.cb===i?r.afterWriteTickInfo.count++:(r.afterWriteTickInfo={count:1,cb:i,stream:t,state:r},Wr.nextTick(pE,r.afterWriteTickInfo)):$h(t,r,1,i))}function pE({stream:t,state:e,count:r,cb:n}){return e.afterWriteTickInfo=null,$h(t,e,r,n)}function $h(t,e,r,n){for(!e.ending&&!t.destroyed&&e.length===0&&e.needDrain&&(e.needDrain=!1,t.emit("drain"));r-- >0;)e.pendingcb--,n();e.destroyed&&kc(e),Ic(t,e)}function kc(t){if(t.writing)return;for(let i=t.bufferedIndex;i<t.buffered.length;++i){var e;let{chunk:o,callback:s}=t.buffered[i],a=t.objectMode?1:o.length;t.length-=a,s((e=t.errored)!==null&&e!==void 0?e:new vi("write"))}let r=t[Rn].splice(0);for(let i=0;i<r.length;i++){var n;r[i]((n=t.errored)!==null&&n!==void 0?n:new vi("end"))}$o(t)}function Pc(t,e){if(e.corked||e.bufferProcessing||e.destroyed||!e.constructed)return;let{buffered:r,bufferedIndex:n,objectMode:i}=e,o=r.length-n;if(!o)return;let s=n;if(e.bufferProcessing=!0,o>1&&t._writev){e.pendingcb-=o-1;let a=e.allNoop?Tc:f=>{for(let u=s;u<r.length;++u)r[u].callback(f)},c=e.allNoop&&s===0?r:Kh(r,s);c.allBuffers=e.allBuffers,Lh(t,e,!0,e.length,c,"",a),$o(e)}else{do{let{chunk:a,encoding:c,callback:f}=r[s];r[s++]=null;let u=i?1:a.length;Lh(t,e,!1,u,a,c,f)}while(s<r.length&&!e.writing);s===r.length?$o(e):s>256?(r.splice(0,s),e.bufferedIndex=0):e.bufferedIndex=s}e.bufferProcessing=!1}fe.prototype._write=function(t,e,r){if(this._writev)this._writev([{chunk:t,encoding:e}],r);else throw new aE("_write()")};fe.prototype._writev=null;fe.prototype.end=function(t,e,r){let n=this._writableState;typeof t=="function"?(r=t,t=null,e=null):typeof e=="function"&&(r=e,e=null);let i;if(t!=null){let o=Fh(this,t,e);o instanceof Zx&&(i=o)}return n.corked&&(n.corked=1,this.uncork()),i||(!n.errored&&!n.ending?(n.ending=!0,Ic(this,n,!0),n.ended=!0):n.finished?i=new fE("end"):n.destroyed&&(i=new vi("end"))),typeof r=="function"&&(i||n.finished?Wr.nextTick(r,i):n[Rn].push(r)),this};function Fo(t){return t.ending&&!t.destroyed&&t.constructed&&t.length===0&&!t.errored&&t.buffered.length===0&&!t.finished&&!t.writing&&!t.errorEmitted&&!t.closeEmitted}function yE(t,e){let r=!1;function n(i){if(r){In(t,i??qh());return}if(r=!0,e.pendingcb--,i){let o=e[Rn].splice(0);for(let s=0;s<o.length;s++)o[s](i);In(t,i,e.sync)}else Fo(e)&&(e.prefinished=!0,t.emit("prefinish"),e.pendingcb++,Wr.nextTick(Bc,t,e))}e.sync=!0,e.pendingcb++;try{t._final(n)}catch(i){n(i)}e.sync=!1}function wE(t,e){!e.prefinished&&!e.finalCalled&&(typeof t._final=="function"&&!e.destroyed?(e.finalCalled=!0,yE(t,e)):(e.prefinished=!0,t.emit("prefinish")))}function Ic(t,e,r){Fo(e)&&(wE(t,e),e.pendingcb===0&&(r?(e.pendingcb++,Wr.nextTick((n,i)=>{Fo(i)?Bc(n,i):i.pendingcb--},t,e)):Fo(e)&&(e.pendingcb++,Bc(t,e))))}function Bc(t,e){e.pendingcb--,e.finished=!0;let r=e[Rn].splice(0);for(let n=0;n<r.length;n++)r[n]();if(t.emit("finish"),e.autoDestroy){let n=t._readableState;(!n||n.autoDestroy&&(n.endEmitted||n.readable===!1))&&t.destroy()}}Xx(fe.prototype,{closed:{__proto__:null,get(){return this._writableState?this._writableState.closed:!1}},destroyed:{__proto__:null,get(){return this._writableState?this._writableState.destroyed:!1},set(t){this._writableState&&(this._writableState.destroyed=t)}},writable:{__proto__:null,get(){let t=this._writableState;return!!t&&t.writable!==!1&&!t.destroyed&&!t.errored&&!t.ending&&!t.ended},set(t){this._writableState&&(this._writableState.writable=!!t)}},writableFinished:{__proto__:null,get(){return this._writableState?this._writableState.finished:!1}},writableObjectMode:{__proto__:null,get(){return this._writableState?this._writableState.objectMode:!1}},writableBuffer:{__proto__:null,get(){return this._writableState&&this._writableState.getBuffer()}},writableEnded:{__proto__:null,get(){return this._writableState?this._writableState.ending:!1}},writableNeedDrain:{__proto__:null,get(){let t=this._writableState;return t?!t.destroyed&&!t.ending&&t.needDrain:!1}},writableHighWaterMark:{__proto__:null,get(){return this._writableState&&this._writableState.highWaterMark}},writableCorked:{__proto__:null,get(){return this._writableState?this._writableState.corked:0}},writableLength:{__proto__:null,get(){return this._writableState&&this._writableState.length}},errored:{__proto__:null,enumerable:!1,get(){return this._writableState?this._writableState.errored:null}},writableAborted:{__proto__:null,enumerable:!1,get:function(){return!!(this._writableState.writable!==!1&&(this._writableState.destroyed||this._writableState.errored)&&!this._writableState.finished)}}});var mE=Vo.destroy;fe.prototype.destroy=function(t,e){let r=this._writableState;return!r.destroyed&&(r.bufferedIndex<r.buffered.length||r[Rn].length)&&Wr.nextTick(kc,r),mE.call(this,t,e),this};fe.prototype._undestroy=Vo.undestroy;fe.prototype._destroy=function(t,e){e(t)};fe.prototype[rE.captureRejectionSymbol]=function(t){this.destroy(t)};var vc;function Vh(){return vc===void 0&&(vc={}),vc}fe.fromWeb=function(t,e){return Vh().newStreamWritableFromWritableStream(t,e)};fe.toWeb=function(t){return Vh().newWritableStreamFromStreamWritable(t)}});var sp=M((PS,op)=>{var Rc=ir(),bE=qe(),{isReadable:gE,isWritable:xE,isIterable:Gh,isNodeStream:EE,isReadableNodeStream:Wh,isWritableNodeStream:Jh,isDuplexNodeStream:_E,isReadableStream:zh,isWritableStream:Yh}=yt(),Zh=Kt(),{AbortError:np,codes:{ERR_INVALID_ARG_TYPE:AE,ERR_INVALID_RETURN_VALUE:Xh}}=Te(),{destroyer:Cn}=Vr(),SE=bt(),ip=Ai(),vE=Ho(),{createDeferredPromise:Qh}=Se(),ep=wc(),tp=globalThis.Blob||bE.Blob,BE=typeof tp<"u"?function(e){return e instanceof tp}:function(e){return!1},TE=globalThis.AbortController||_n().AbortController,{FunctionPrototypeCall:rp}=ce(),ar=class extends SE{constructor(e){super(e),e?.readable===!1&&(this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0),e?.writable===!1&&(this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0)}};op.exports=function t(e,r){if(_E(e))return e;if(Wh(e))return Un({readable:e});if(Jh(e))return Un({writable:e});if(EE(e))return Un({writable:!1,readable:!1});if(zh(e))return Un({readable:ip.fromWeb(e)});if(Yh(e))return Un({writable:vE.fromWeb(e)});if(typeof e=="function"){let{value:i,write:o,final:s,destroy:a}=kE(e);if(Gh(i))return ep(ar,i,{objectMode:!0,write:o,final:s,destroy:a});let c=i?.then;if(typeof c=="function"){let f,u=rp(c,i,l=>{if(l!=null)throw new Xh("nully","body",l)},l=>{Cn(f,l)});return f=new ar({objectMode:!0,readable:!1,write:o,final(l){s(async()=>{try{await u,Rc.nextTick(l,null)}catch(p){Rc.nextTick(l,p)}})},destroy:a})}throw new Xh("Iterable, AsyncIterable or AsyncFunction",r,i)}if(BE(e))return t(e.arrayBuffer());if(Gh(e))return ep(ar,e,{objectMode:!0,writable:!1});if(zh(e?.readable)&&Yh(e?.writable))return ar.fromWeb(e);if(typeof e?.writable=="object"||typeof e?.readable=="object"){let i=e!=null&&e.readable?Wh(e?.readable)?e?.readable:t(e.readable):void 0,o=e!=null&&e.writable?Jh(e?.writable)?e?.writable:t(e.writable):void 0;return Un({readable:i,writable:o})}let n=e?.then;if(typeof n=="function"){let i;return rp(n,e,o=>{o!=null&&i.push(o),i.push(null)},o=>{Cn(i,o)}),i=new ar({objectMode:!0,writable:!1,read(){}})}throw new AE(r,["Blob","ReadableStream","WritableStream","Stream","Iterable","AsyncIterable","Function","{ readable, writable } pair","Promise"],e)};function kE(t){let{promise:e,resolve:r}=Qh(),n=new TE,i=n.signal;return{value:t(async function*(){for(;;){let s=e;e=null;let{chunk:a,done:c,cb:f}=await s;if(Rc.nextTick(f),c)return;if(i.aborted)throw new np(void 0,{cause:i.reason});({promise:e,resolve:r}=Qh()),yield a}}(),{signal:i}),write(s,a,c){let f=r;r=null,f({chunk:s,done:!1,cb:c})},final(s){let a=r;r=null,a({done:!0,cb:s})},destroy(s,a){n.abort(),a(s)}}}function Un(t){let e=t.readable&&typeof t.readable.read!="function"?ip.wrap(t.readable):t.readable,r=t.writable,n=!!gE(e),i=!!xE(r),o,s,a,c,f;function u(l){let p=c;c=null,p?p(l):l&&f.destroy(l)}return f=new ar({readableObjectMode:!!(e!=null&&e.readableObjectMode),writableObjectMode:!!(r!=null&&r.writableObjectMode),readable:n,writable:i}),i&&(Zh(r,l=>{i=!1,l&&Cn(e,l),u(l)}),f._write=function(l,p,h){r.write(l,p)?h():o=h},f._final=function(l){r.end(),s=l},r.on("drain",function(){if(o){let l=o;o=null,l()}}),r.on("finish",function(){if(s){let l=s;s=null,l()}})),n&&(Zh(e,l=>{n=!1,l&&Cn(e,l),u(l)}),e.on("readable",function(){if(a){let l=a;a=null,l()}}),e.on("end",function(){f.push(null)}),f._read=function(){for(;;){let l=e.read();if(l===null){a=f._read;return}if(!f.push(l))return}}),f._destroy=function(l,p){!l&&c!==null&&(l=new np),a=null,o=null,s=null,c===null?p(l):(c=p,Cn(r,l),Cn(e,l))},f}});var bt=M((IS,fp)=>{"use strict";var{ObjectDefineProperties:PE,ObjectGetOwnPropertyDescriptor:Nt,ObjectKeys:IE,ObjectSetPrototypeOf:ap}=ce();fp.exports=Qe;var Lc=Ai(),Ve=Ho();ap(Qe.prototype,Lc.prototype);ap(Qe,Lc);{let t=IE(Ve.prototype);for(let e=0;e<t.length;e++){let r=t[e];Qe.prototype[r]||(Qe.prototype[r]=Ve.prototype[r])}}function Qe(t){if(!(this instanceof Qe))return new Qe(t);Lc.call(this,t),Ve.call(this,t),t?(this.allowHalfOpen=t.allowHalfOpen!==!1,t.readable===!1&&(this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0),t.writable===!1&&(this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0)):this.allowHalfOpen=!0}PE(Qe.prototype,{writable:{__proto__:null,...Nt(Ve.prototype,"writable")},writableHighWaterMark:{__proto__:null,...Nt(Ve.prototype,"writableHighWaterMark")},writableObjectMode:{__proto__:null,...Nt(Ve.prototype,"writableObjectMode")},writableBuffer:{__proto__:null,...Nt(Ve.prototype,"writableBuffer")},writableLength:{__proto__:null,...Nt(Ve.prototype,"writableLength")},writableFinished:{__proto__:null,...Nt(Ve.prototype,"writableFinished")},writableCorked:{__proto__:null,...Nt(Ve.prototype,"writableCorked")},writableEnded:{__proto__:null,...Nt(Ve.prototype,"writableEnded")},writableNeedDrain:{__proto__:null,...Nt(Ve.prototype,"writableNeedDrain")},destroyed:{__proto__:null,get(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set(t){this._readableState&&this._writableState&&(this._readableState.destroyed=t,this._writableState.destroyed=t)}}});var Uc;function cp(){return Uc===void 0&&(Uc={}),Uc}Qe.fromWeb=function(t,e){return cp().newStreamDuplexFromReadableWritablePair(t,e)};Qe.toWeb=function(t){return cp().newReadableWritablePairFromDuplex(t)};var Cc;Qe.from=function(t){return Cc||(Cc=sp()),Cc(t,"body")}});var Nc=M((RS,lp)=>{"use strict";var{ObjectSetPrototypeOf:up,Symbol:RE}=ce();lp.exports=Dt;var{ERR_METHOD_NOT_IMPLEMENTED:UE}=Te().codes,Kc=bt(),{getHighWaterMark:CE}=xi();up(Dt.prototype,Kc.prototype);up(Dt,Kc);var Ti=RE("kCallback");function Dt(t){if(!(this instanceof Dt))return new Dt(t);let e=t?CE(this,t,"readableHighWaterMark",!0):null;e===0&&(t={...t,highWaterMark:null,readableHighWaterMark:e,writableHighWaterMark:t.writableHighWaterMark||0}),Kc.call(this,t),this._readableState.sync=!1,this[Ti]=null,t&&(typeof t.transform=="function"&&(this._transform=t.transform),typeof t.flush=="function"&&(this._flush=t.flush)),this.on("prefinish",LE)}function Oc(t){typeof this._flush=="function"&&!this.destroyed?this._flush((e,r)=>{if(e){t?t(e):this.destroy(e);return}r!=null&&this.push(r),this.push(null),t&&t()}):(this.push(null),t&&t())}function LE(){this._final!==Oc&&Oc.call(this)}Dt.prototype._final=Oc;Dt.prototype._transform=function(t,e,r){throw new UE("_transform()")};Dt.prototype._write=function(t,e,r){let n=this._readableState,i=this._writableState,o=n.length;this._transform(t,e,(s,a)=>{if(s){r(s);return}a!=null&&this.push(a),i.ended||o===n.length||n.length<n.highWaterMark?r():this[Ti]=r})};Dt.prototype._read=function(){if(this[Ti]){let t=this[Ti];this[Ti]=null,t()}}});var Mc=M((US,hp)=>{"use strict";var{ObjectSetPrototypeOf:dp}=ce();hp.exports=Ln;var Dc=Nc();dp(Ln.prototype,Dc.prototype);dp(Ln,Dc);function Ln(t){if(!(this instanceof Ln))return new Ln(t);Dc.call(this,t)}Ln.prototype._transform=function(t,e,r){r(null,t)}});var zo=M((CS,bp)=>{var ki=ir(),{ArrayIsArray:OE,Promise:KE,SymbolAsyncIterator:NE,SymbolDispose:DE}=ce(),Jo=Kt(),{once:ME}=Se(),qE=Vr(),pp=bt(),{aggregateTwoErrors:jE,codes:{ERR_INVALID_ARG_TYPE:Jc,ERR_INVALID_RETURN_VALUE:qc,ERR_MISSING_ARGS:FE,ERR_STREAM_DESTROYED:$E,ERR_STREAM_PREMATURE_CLOSE:VE},AbortError:HE}=Te(),{validateFunction:GE,validateAbortSignal:WE}=Sn(),{isIterable:Jr,isReadable:jc,isReadableNodeStream:Wo,isNodeStream:yp,isTransformStream:On,isWebStream:JE,isReadableStream:Fc,isReadableFinished:zE}=yt(),YE=globalThis.AbortController||_n().AbortController,$c,Vc,Hc;function wp(t,e,r){let n=!1;t.on("close",()=>{n=!0});let i=Jo(t,{readable:e,writable:r},o=>{n=!o});return{destroy:o=>{n||(n=!0,qE.destroyer(t,o||new $E("pipe")))},cleanup:i}}function ZE(t){return GE(t[t.length-1],"streams[stream.length - 1]"),t.pop()}function Gc(t){if(Jr(t))return t;if(Wo(t))return XE(t);throw new Jc("val",["Readable","Iterable","AsyncIterable"],t)}async function*XE(t){Vc||(Vc=Ai()),yield*Vc.prototype[NE].call(t)}async function Go(t,e,r,{end:n}){let i,o=null,s=f=>{if(f&&(i=f),o){let u=o;o=null,u()}},a=()=>new KE((f,u)=>{i?u(i):o=()=>{i?u(i):f()}});e.on("drain",s);let c=Jo(e,{readable:!1},s);try{e.writableNeedDrain&&await a();for await(let f of t)e.write(f)||await a();n&&(e.end(),await a()),r()}catch(f){r(i!==f?jE(i,f):f)}finally{c(),e.off("drain",s)}}async function Wc(t,e,r,{end:n}){On(e)&&(e=e.writable);let i=e.getWriter();try{for await(let o of t)await i.ready,i.write(o).catch(()=>{});await i.ready,n&&await i.close(),r()}catch(o){try{await i.abort(o),r(o)}catch(s){r(s)}}}function QE(...t){return mp(t,ME(ZE(t)))}function mp(t,e,r){if(t.length===1&&OE(t[0])&&(t=t[0]),t.length<2)throw new FE("streams");let n=new YE,i=n.signal,o=r?.signal,s=[];WE(o,"options.signal");function a(){y(new HE)}Hc=Hc||Se().addAbortListener;let c;o&&(c=Hc(o,a));let f,u,l=[],p=0;function h(g){y(g,--p===0)}function y(g,_){var E;if(g&&(!f||f.code==="ERR_STREAM_PREMATURE_CLOSE")&&(f=g),!(!f&&!_)){for(;l.length;)l.shift()(f);(E=c)===null||E===void 0||E[DE](),n.abort(),_&&(f||s.forEach(B=>B()),ki.nextTick(e,f,u))}}let d;for(let g=0;g<t.length;g++){let _=t[g],E=g<t.length-1,B=g>0,T=E||r?.end!==!1,k=g===t.length-1;if(yp(_)){let R=function(C){C&&C.name!=="AbortError"&&C.code!=="ERR_STREAM_PREMATURE_CLOSE"&&h(C)};var A=R;if(T){let{destroy:C,cleanup:L}=wp(_,E,B);l.push(C),jc(_)&&k&&s.push(L)}_.on("error",R),jc(_)&&k&&s.push(()=>{_.removeListener("error",R)})}if(g===0)if(typeof _=="function"){if(d=_({signal:i}),!Jr(d))throw new qc("Iterable, AsyncIterable or Stream","source",d)}else Jr(_)||Wo(_)||On(_)?d=_:d=pp.from(_);else if(typeof _=="function"){if(On(d)){var w;d=Gc((w=d)===null||w===void 0?void 0:w.readable)}else d=Gc(d);if(d=_(d,{signal:i}),E){if(!Jr(d,!0))throw new qc("AsyncIterable",`transform[${g-1}]`,d)}else{var m;$c||($c=Mc());let R=new $c({objectMode:!0}),C=(m=d)===null||m===void 0?void 0:m.then;if(typeof C=="function")p++,C.call(d,K=>{u=K,K!=null&&R.write(K),T&&R.end(),ki.nextTick(h)},K=>{R.destroy(K),ki.nextTick(h,K)});else if(Jr(d,!0))p++,Go(d,R,h,{end:T});else if(Fc(d)||On(d)){let K=d.readable||d;p++,Go(K,R,h,{end:T})}else throw new qc("AsyncIterable or Promise","destination",d);d=R;let{destroy:L,cleanup:j}=wp(d,!1,!0);l.push(L),k&&s.push(j)}}else if(yp(_)){if(Wo(d)){p+=2;let R=e1(d,_,h,{end:T});jc(_)&&k&&s.push(R)}else if(On(d)||Fc(d)){let R=d.readable||d;p++,Go(R,_,h,{end:T})}else if(Jr(d))p++,Go(d,_,h,{end:T});else throw new Jc("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],d);d=_}else if(JE(_)){if(Wo(d))p++,Wc(Gc(d),_,h,{end:T});else if(Fc(d)||Jr(d))p++,Wc(d,_,h,{end:T});else if(On(d))p++,Wc(d.readable,_,h,{end:T});else throw new Jc("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],d);d=_}else d=pp.from(_)}return(i!=null&&i.aborted||o!=null&&o.aborted)&&ki.nextTick(a),d}function e1(t,e,r,{end:n}){let i=!1;if(e.on("close",()=>{i||r(new VE)}),t.pipe(e,{end:!1}),n){let s=function(){i=!0,e.end()};var o=s;zE(t)?ki.nextTick(s):t.once("end",s)}else r();return Jo(t,{readable:!0,writable:!1},s=>{let a=t._readableState;s&&s.code==="ERR_STREAM_PREMATURE_CLOSE"&&a&&a.ended&&!a.errored&&!a.errorEmitted?t.once("end",r).once("error",r):r(s)}),Jo(e,{readable:!1,writable:!0},r)}bp.exports={pipelineImpl:mp,pipeline:QE}});var Yc=M((LS,Sp)=>{"use strict";var{pipeline:t1}=zo(),Yo=bt(),{destroyer:r1}=Vr(),{isNodeStream:Zo,isReadable:gp,isWritable:xp,isWebStream:zc,isTransformStream:zr,isWritableStream:Ep,isReadableStream:_p}=yt(),{AbortError:n1,codes:{ERR_INVALID_ARG_VALUE:Ap,ERR_MISSING_ARGS:i1}}=Te(),o1=Kt();Sp.exports=function(...e){if(e.length===0)throw new i1("streams");if(e.length===1)return Yo.from(e[0]);let r=[...e];if(typeof e[0]=="function"&&(e[0]=Yo.from(e[0])),typeof e[e.length-1]=="function"){let h=e.length-1;e[h]=Yo.from(e[h])}for(let h=0;h<e.length;++h)if(!(!Zo(e[h])&&!zc(e[h]))){if(h<e.length-1&&!(gp(e[h])||_p(e[h])||zr(e[h])))throw new Ap(`streams[${h}]`,r[h],"must be readable");if(h>0&&!(xp(e[h])||Ep(e[h])||zr(e[h])))throw new Ap(`streams[${h}]`,r[h],"must be writable")}let n,i,o,s,a;function c(h){let y=s;s=null,y?y(h):h?a.destroy(h):!p&&!l&&a.destroy()}let f=e[0],u=t1(e,c),l=!!(xp(f)||Ep(f)||zr(f)),p=!!(gp(u)||_p(u)||zr(u));if(a=new Yo({writableObjectMode:!!(f!=null&&f.writableObjectMode),readableObjectMode:!!(u!=null&&u.readableObjectMode),writable:l,readable:p}),l){if(Zo(f))a._write=function(y,d,w){f.write(y,d)?w():n=w},a._final=function(y){f.end(),i=y},f.on("drain",function(){if(n){let y=n;n=null,y()}});else if(zc(f)){let d=(zr(f)?f.writable:f).getWriter();a._write=async function(w,m,A){try{await d.ready,d.write(w).catch(()=>{}),A()}catch(g){A(g)}},a._final=async function(w){try{await d.ready,d.close().catch(()=>{}),i=w}catch(m){w(m)}}}let h=zr(u)?u.readable:u;o1(h,()=>{if(i){let y=i;i=null,y()}})}if(p){if(Zo(u))u.on("readable",function(){if(o){let h=o;o=null,h()}}),u.on("end",function(){a.push(null)}),a._read=function(){for(;;){let h=u.read();if(h===null){o=a._read;return}if(!a.push(h))return}};else if(zc(u)){let y=(zr(u)?u.readable:u).getReader();a._read=async function(){for(;;)try{let{value:d,done:w}=await y.read();if(!a.push(d))return;if(w){a.push(null);return}}catch{return}}}}return a._destroy=function(h,y){!h&&s!==null&&(h=new n1),o=null,n=null,i=null,s===null?y(h):(s=y,Zo(u)&&r1(u,h))},a}});var Lp=M((OS,Qc)=>{"use strict";var s1=globalThis.AbortController||_n().AbortController,{codes:{ERR_INVALID_ARG_VALUE:a1,ERR_INVALID_ARG_TYPE:Pi,ERR_MISSING_ARGS:c1,ERR_OUT_OF_RANGE:f1},AbortError:gt}=Te(),{validateAbortSignal:Yr,validateInteger:vp,validateObject:Zr}=Sn(),u1=ce().Symbol("kWeak"),l1=ce().Symbol("kResistStopPropagation"),{finished:d1}=Kt(),h1=Yc(),{addAbortSignalNoValidate:p1}=gi(),{isWritable:y1,isNodeStream:w1}=yt(),{deprecate:m1}=Se(),{ArrayPrototypePush:b1,Boolean:g1,MathFloor:Bp,Number:x1,NumberIsNaN:E1,Promise:Tp,PromiseReject:kp,PromiseResolve:_1,PromisePrototypeThen:Pp,Symbol:Rp}=ce(),Xo=Rp("kEmpty"),Ip=Rp("kEof");function A1(t,e){if(e!=null&&Zr(e,"options"),e?.signal!=null&&Yr(e.signal,"options.signal"),w1(t)&&!y1(t))throw new a1("stream",t,"must be writable");let r=h1(this,t);return e!=null&&e.signal&&p1(e.signal,r),r}function Qo(t,e){if(typeof t!="function")throw new Pi("fn",["Function","AsyncFunction"],t);e!=null&&Zr(e,"options"),e?.signal!=null&&Yr(e.signal,"options.signal");let r=1;e?.concurrency!=null&&(r=Bp(e.concurrency));let n=r-1;return e?.highWaterMark!=null&&(n=Bp(e.highWaterMark)),vp(r,"options.concurrency",1),vp(n,"options.highWaterMark",0),n+=r,(async function*(){let o=Se().AbortSignalAny([e?.signal].filter(g1)),s=this,a=[],c={signal:o},f,u,l=!1,p=0;function h(){l=!0,y()}function y(){p-=1,d()}function d(){u&&!l&&p<r&&a.length<n&&(u(),u=null)}async function w(){try{for await(let m of s){if(l)return;if(o.aborted)throw new gt;try{if(m=t(m,c),m===Xo)continue;m=_1(m)}catch(A){m=kp(A)}p+=1,Pp(m,y,h),a.push(m),f&&(f(),f=null),!l&&(a.length>=n||p>=r)&&await new Tp(A=>{u=A})}a.push(Ip)}catch(m){let A=kp(m);Pp(A,y,h),a.push(A)}finally{l=!0,f&&(f(),f=null)}}w();try{for(;;){for(;a.length>0;){let m=await a[0];if(m===Ip)return;if(o.aborted)throw new gt;m!==Xo&&(yield m),a.shift(),d()}await new Tp(m=>{f=m})}}finally{l=!0,u&&(u(),u=null)}}).call(this)}function S1(t=void 0){return t!=null&&Zr(t,"options"),t?.signal!=null&&Yr(t.signal,"options.signal"),(async function*(){let r=0;for await(let i of this){var n;if(t!=null&&(n=t.signal)!==null&&n!==void 0&&n.aborted)throw new gt({cause:t.signal.reason});yield[r++,i]}}).call(this)}async function Up(t,e=void 0){for await(let r of Xc.call(this,t,e))return!0;return!1}async function v1(t,e=void 0){if(typeof t!="function")throw new Pi("fn",["Function","AsyncFunction"],t);return!await Up.call(this,async(...r)=>!await t(...r),e)}async function B1(t,e){for await(let r of Xc.call(this,t,e))return r}async function T1(t,e){if(typeof t!="function")throw new Pi("fn",["Function","AsyncFunction"],t);async function r(n,i){return await t(n,i),Xo}for await(let n of Qo.call(this,r,e));}function Xc(t,e){if(typeof t!="function")throw new Pi("fn",["Function","AsyncFunction"],t);async function r(n,i){return await t(n,i)?n:Xo}return Qo.call(this,r,e)}var Zc=class extends c1{constructor(){super("reduce"),this.message="Reduce of an empty stream requires an initial value"}};async function k1(t,e,r){var n;if(typeof t!="function")throw new Pi("reducer",["Function","AsyncFunction"],t);r!=null&&Zr(r,"options"),r?.signal!=null&&Yr(r.signal,"options.signal");let i=arguments.length>1;if(r!=null&&(n=r.signal)!==null&&n!==void 0&&n.aborted){let f=new gt(void 0,{cause:r.signal.reason});throw this.once("error",()=>{}),await d1(this.destroy(f)),f}let o=new s1,s=o.signal;if(r!=null&&r.signal){let f={once:!0,[u1]:this,[l1]:!0};r.signal.addEventListener("abort",()=>o.abort(),f)}let a=!1;try{for await(let f of this){var c;if(a=!0,r!=null&&(c=r.signal)!==null&&c!==void 0&&c.aborted)throw new gt;i?e=await t(e,f,{signal:s}):(e=f,i=!0)}if(!a&&!i)throw new Zc}finally{o.abort()}return e}async function P1(t){t!=null&&Zr(t,"options"),t?.signal!=null&&Yr(t.signal,"options.signal");let e=[];for await(let n of this){var r;if(t!=null&&(r=t.signal)!==null&&r!==void 0&&r.aborted)throw new gt(void 0,{cause:t.signal.reason});b1(e,n)}return e}function I1(t,e){let r=Qo.call(this,t,e);return(async function*(){for await(let i of r)yield*i}).call(this)}function Cp(t){if(t=x1(t),E1(t))return 0;if(t<0)throw new f1("number",">= 0",t);return t}function R1(t,e=void 0){return e!=null&&Zr(e,"options"),e?.signal!=null&&Yr(e.signal,"options.signal"),t=Cp(t),(async function*(){var n;if(e!=null&&(n=e.signal)!==null&&n!==void 0&&n.aborted)throw new gt;for await(let o of this){var i;if(e!=null&&(i=e.signal)!==null&&i!==void 0&&i.aborted)throw new gt;t--<=0&&(yield o)}}).call(this)}function U1(t,e=void 0){return e!=null&&Zr(e,"options"),e?.signal!=null&&Yr(e.signal,"options.signal"),t=Cp(t),(async function*(){var n;if(e!=null&&(n=e.signal)!==null&&n!==void 0&&n.aborted)throw new gt;for await(let o of this){var i;if(e!=null&&(i=e.signal)!==null&&i!==void 0&&i.aborted)throw new gt;if(t-- >0&&(yield o),t<=0)return}}).call(this)}Qc.exports.streamReturningOperators={asIndexedPairs:m1(S1,"readable.asIndexedPairs will be removed in a future version."),drop:R1,filter:Xc,flatMap:I1,map:Qo,take:U1,compose:A1};Qc.exports.promiseReturningOperators={every:v1,forEach:T1,reduce:k1,toArray:P1,some:Up,find:B1}});var ef=M((KS,Op)=>{"use strict";var{ArrayPrototypePop:C1,Promise:L1}=ce(),{isIterable:O1,isNodeStream:K1,isWebStream:N1}=yt(),{pipelineImpl:D1}=zo(),{finished:M1}=Kt();tf();function q1(...t){return new L1((e,r)=>{let n,i,o=t[t.length-1];if(o&&typeof o=="object"&&!K1(o)&&!O1(o)&&!N1(o)){let s=C1(t);n=s.signal,i=s.end}D1(t,(s,a)=>{s?r(s):e(a)},{signal:n,end:i})})}Op.exports={finished:M1,pipeline:q1}});var tf=M((NS,Vp)=>{var{Buffer:j1}=qe(),{ObjectDefineProperty:Mt,ObjectKeys:Dp,ReflectApply:Mp}=ce(),{promisify:{custom:qp}}=Se(),{streamReturningOperators:Kp,promiseReturningOperators:Np}=Lp(),{codes:{ERR_ILLEGAL_CONSTRUCTOR:jp}}=Te(),F1=Yc(),{setDefaultHighWaterMark:$1,getDefaultHighWaterMark:V1}=xi(),{pipeline:Fp}=zo(),{destroyer:H1}=Vr(),$p=Kt(),rf=ef(),Ii=yt(),ie=Vp.exports=Uo().Stream;ie.isDestroyed=Ii.isDestroyed;ie.isDisturbed=Ii.isDisturbed;ie.isErrored=Ii.isErrored;ie.isReadable=Ii.isReadable;ie.isWritable=Ii.isWritable;ie.Readable=Ai();for(let t of Dp(Kp)){let r=function(...n){if(new.target)throw jp();return ie.Readable.from(Mp(e,this,n))};nf=r;let e=Kp[t];Mt(r,"name",{__proto__:null,value:e.name}),Mt(r,"length",{__proto__:null,value:e.length}),Mt(ie.Readable.prototype,t,{__proto__:null,value:r,enumerable:!1,configurable:!0,writable:!0})}var nf;for(let t of Dp(Np)){let r=function(...i){if(new.target)throw jp();return Mp(e,this,i)};nf=r;let e=Np[t];Mt(r,"name",{__proto__:null,value:e.name}),Mt(r,"length",{__proto__:null,value:e.length}),Mt(ie.Readable.prototype,t,{__proto__:null,value:r,enumerable:!1,configurable:!0,writable:!0})}var nf;ie.Writable=Ho();ie.Duplex=bt();ie.Transform=Nc();ie.PassThrough=Mc();ie.pipeline=Fp;var{addAbortSignal:G1}=gi();ie.addAbortSignal=G1;ie.finished=$p;ie.destroy=H1;ie.compose=F1;ie.setDefaultHighWaterMark=$1;ie.getDefaultHighWaterMark=V1;Mt(ie,"promises",{__proto__:null,configurable:!0,enumerable:!0,get(){return rf}});Mt(Fp,qp,{__proto__:null,enumerable:!0,get(){return rf.pipeline}});Mt($p,qp,{__proto__:null,enumerable:!0,get(){return rf.finished}});ie.Stream=ie;ie._isUint8Array=function(e){return e instanceof Uint8Array};ie._uint8ArrayToBuffer=function(e){return j1.from(e.buffer,e.byteOffset,e.byteLength)}});var of=M((DS,le)=>{"use strict";var pe=tf(),W1=ef(),J1=pe.Readable.destroy;le.exports=pe.Readable;le.exports._uint8ArrayToBuffer=pe._uint8ArrayToBuffer;le.exports._isUint8Array=pe._isUint8Array;le.exports.isDisturbed=pe.isDisturbed;le.exports.isErrored=pe.isErrored;le.exports.isReadable=pe.isReadable;le.exports.Readable=pe.Readable;le.exports.Writable=pe.Writable;le.exports.Duplex=pe.Duplex;le.exports.Transform=pe.Transform;le.exports.PassThrough=pe.PassThrough;le.exports.addAbortSignal=pe.addAbortSignal;le.exports.finished=pe.finished;le.exports.destroy=pe.destroy;le.exports.destroy=J1;le.exports.pipeline=pe.pipeline;le.exports.compose=pe.compose;Object.defineProperty(pe,"promises",{configurable:!0,enumerable:!0,get(){return W1}});le.exports.Stream=pe.Stream;le.exports.default=le.exports});var y0=ji(Xf(),1);var C_=new Uint8Array(0);function Qf(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function rn(t){if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")}function m0(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<t.length;i++){var o=t.charAt(i),s=o.charCodeAt(0);if(r[s]!==255)throw new TypeError(o+" is ambiguous");r[s]=i}var a=t.length,c=t.charAt(0),f=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function l(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 d=0,w=0,m=0,A=y.length;m!==A&&y[m]===0;)m++,d++;for(var g=(A-m)*u+1>>>0,_=new Uint8Array(g);m!==A;){for(var E=y[m],B=0,T=g-1;(E!==0||B<w)&&T!==-1;T--,B++)E+=256*_[T]>>>0,_[T]=E%a>>>0,E=E/a>>>0;if(E!==0)throw new Error("Non-zero carry");w=B,m++}for(var k=g-w;k!==g&&_[k]===0;)k++;for(var R=c.repeat(d);k<g;++k)R+=t.charAt(_[k]);return R}function p(y){if(typeof y!="string")throw new TypeError("Expected String");if(y.length===0)return new Uint8Array;var d=0;if(y[d]!==" "){for(var w=0,m=0;y[d]===c;)w++,d++;for(var A=(y.length-d)*f+1>>>0,g=new Uint8Array(A);y[d];){var _=r[y.charCodeAt(d)];if(_===255)return;for(var E=0,B=A-1;(_!==0||E<m)&&B!==-1;B--,E++)_+=a*g[B]>>>0,g[B]=_%256>>>0,_=_/256>>>0;if(_!==0)throw new Error("Non-zero carry");m=E,d++}if(y[d]!==" "){for(var T=A-m;T!==A&&g[T]===0;)T++;for(var k=new Uint8Array(w+(A-T)),R=w;T!==A;)k[R++]=g[T++];return k}}}function h(y){var d=p(y);if(d)return d;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:p,decode:h}}var b0=m0,g0=b0,eu=g0;var Rs=class{name;prefix;baseEncode;constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Us=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.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 tu(this,e)}},Cs=class{decoders;constructor(e){this.decoders=e}or(e){return tu(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function tu(t,e){return new Cs({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var Ls=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new Rs(e,r,n),this.decoder=new Us(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function ru({name:t,prefix:e,encode:r,decode:n}){return new Ls(t,e,r,n)}function Os({name:t,prefix:e,alphabet:r}){let{encode:n,decode:i}=eu(r,t);return ru({prefix:e,name:t,encode:n,decode:o=>rn(i(o))})}function x0(t,e,r,n){let i={};for(let u=0;u<e.length;++u)i[e[u]]=u;let o=t.length;for(;t[o-1]==="=";)--o;let s=new Uint8Array(o*r/8|0),a=0,c=0,f=0;for(let u=0;u<o;++u){let l=i[t[u]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|l,a+=r,a>=8&&(a-=8,s[f++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s}function E0(t,e,r){let n=e[e.length-1]==="=",i=(1<<r)-1,o="",s=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],s+=8;s>r;)s-=r,o+=e[i&a>>s];if(s!==0&&(o+=e[i&a<<r-s]),n)for(;o.length*r&7;)o+="=";return o}function Be({name:t,prefix:e,bitsPerChar:r,alphabet:n}){return ru({prefix:e,name:t,encode(i){return E0(i,n,r)},decode(i){return x0(i,n,r,t)}})}var Gn=Be({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),M_=Be({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),q_=Be({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),j_=Be({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),F_=Be({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),$_=Be({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),V_=Be({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),H_=Be({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ks=Be({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Pe=Os({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),J_=Os({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Z_=Be({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),X_=Be({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ot=Be({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Q_=Be({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function nu(t){return t.byteOffset!==0||t.byteLength!==t.buffer.byteLength}function iu(t){return typeof t!="object"||t===null?!1:typeof t[Symbol.asyncIterator]=="function"}function Wn(t){let r=Object.prototype.toString.call(t).match(/\s([a-zA-Z0-9]+)/),[n,i]=r;return i}var Jn=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(u){try{f(n.next(u))}catch(l){s(l)}}function c(u){try{f(n.throw(u))}catch(l){s(l)}}function f(u){u.done?o(u.value):i(u.value).then(a,c)}f((n=n.apply(t,e||[])).next())})},ou=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof __values=="function"?__values(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(o){r[o]=t[o]&&function(s){return new Promise(function(a,c){s=t[o](s),i(a,c,s.done,s.value)})}}function i(o,s,a,c){Promise.resolve(c).then(function(f){o({value:f,done:a})},s)}},$i=new TextEncoder,xr=new TextDecoder,q=class t{constructor(e,r){this.data=e,this.format=r}static arrayBuffer(e){return new t(e,"ArrayBuffer")}static asyncIterable(e){if(!iu(e))throw new TypeError("Input must be of type AsyncIterable.");return new t(e,"AsyncIterable")}static base32Z(e){return new t(e,"Base32Z")}static base58Btc(e){return new t(e,"Base58Btc")}static base64Url(e){return new t(e,"Base64Url")}static bufferSource(e){return new t(e,"BufferSource")}static hex(e){if(typeof e!="string")throw new TypeError("Hex input must be a string.");if(e.length%2!==0)throw new TypeError("Hex input must have an even number of characters.");return new t(e,"Hex")}static multibase(e){return new t(e,"Multibase")}static object(e){return new t(e,"Object")}static string(e){return new t(e,"String")}static uint8Array(e){return new t(e,"Uint8Array")}toArrayBuffer(){switch(this.format){case"Base58Btc":return Pe.baseDecode(this.data).buffer;case"Base64Url":return ot.baseDecode(this.data).buffer;case"BufferSource":{if(Wn(this.data)==="ArrayBuffer")return this.data;if(ArrayBuffer.isView(this.data))return nu(this.data)?this.data.buffer.slice(this.data.byteOffset,this.data.byteOffset+this.data.byteLength):this.data.buffer;throw new TypeError(`${this.format} value is not of type: ArrayBuffer, DataView, or TypedArray.`)}case"Hex":return this.toUint8Array().buffer;case"String":return this.toUint8Array().buffer;case"Uint8Array":return this.data.buffer;default:throw new TypeError(`Conversion from ${this.format} to ArrayBuffer is not supported.`)}}toArrayBufferAsync(){return Jn(this,void 0,void 0,function*(){switch(this.format){case"AsyncIterable":return yield(yield this.toBlobAsync()).arrayBuffer();default:throw new TypeError(`Asynchronous conversion from ${this.format} to ArrayBuffer is not supported.`)}})}toBase32Z(){switch(this.format){case"Uint8Array":return Ks.baseEncode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Base64Z is not supported.`)}}toBase58Btc(){switch(this.format){case"ArrayBuffer":{let e=new Uint8Array(this.data);return Pe.baseEncode(e)}case"Multibase":return this.data.substring(1);case"Uint8Array":return Pe.baseEncode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Base58Btc is not supported.`)}}toBase64Url(){switch(this.format){case"ArrayBuffer":{let e=new Uint8Array(this.data);return ot.baseEncode(e)}case"BufferSource":{let e=this.toUint8Array();return ot.baseEncode(e)}case"Object":{let e=JSON.stringify(this.data),r=$i.encode(e);return ot.baseEncode(r)}case"String":{let e=$i.encode(this.data);return ot.baseEncode(e)}case"Uint8Array":return ot.baseEncode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Base64Url is not supported.`)}}toBlobAsync(){return Jn(this,void 0,void 0,function*(){var e,r,n,i;switch(this.format){case"AsyncIterable":{let c=[];try{for(var o=!0,s=ou(this.data),a;a=yield s.next(),e=a.done,!e;o=!0){i=a.value,o=!1;let u=i;c.push(u)}}catch(u){r={error:u}}finally{try{!o&&!e&&(n=s.return)&&(yield n.call(s))}finally{if(r)throw r.error}}return new Blob(c)}default:throw new TypeError(`Asynchronous conversion from ${this.format} to Blob is not supported.`)}})}toHex(){let e=Array.from({length:256},(r,n)=>n.toString(16).padStart(2,"0"));switch(this.format){case"ArrayBuffer":{let r=this.toUint8Array();return t.uint8Array(r).toHex()}case"Base64Url":{let r=this.toUint8Array();return t.uint8Array(r).toHex()}case"Uint8Array":{let r="";for(let n=0;n<this.data.length;n++)r+=e[this.data[n]];return r}default:throw new TypeError(`Conversion from ${this.format} to Hex is not supported.`)}}toMultibase(){switch(this.format){case"Base58Btc":return`z${this.data}`;default:throw new TypeError(`Conversion from ${this.format} to Multibase is not supported.`)}}toObject(){switch(this.format){case"Base64Url":{let e=ot.baseDecode(this.data),r=xr.decode(e);return JSON.parse(r)}case"String":return JSON.parse(this.data);case"Uint8Array":{let e=xr.decode(this.data);return JSON.parse(e)}default:throw new TypeError(`Conversion from ${this.format} to Object is not supported.`)}}toObjectAsync(){return Jn(this,void 0,void 0,function*(){switch(this.format){case"AsyncIterable":{let e=yield this.toStringAsync();return JSON.parse(e)}default:throw new TypeError(`Asynchronous conversion from ${this.format} to Object is not supported.`)}})}toString(){switch(this.format){case"ArrayBuffer":return xr.decode(this.data);case"Base64Url":{let e=ot.baseDecode(this.data);return xr.decode(e)}case"Object":return JSON.stringify(this.data);case"Uint8Array":return xr.decode(this.data);default:throw new TypeError(`Conversion from ${this.format} to String is not supported.`)}}toStringAsync(){return Jn(this,void 0,void 0,function*(){var e,r,n,i;switch(this.format){case"AsyncIterable":{let c="";try{for(var o=!0,s=ou(this.data),a;a=yield s.next(),e=a.done,!e;o=!0){i=a.value,o=!1;let f=i;typeof f=="string"?c+=f:c+=xr.decode(f,{stream:!0})}}catch(f){r={error:f}}finally{try{!o&&!e&&(n=s.return)&&(yield n.call(s))}finally{if(r)throw r.error}}return c+=xr.decode(void 0,{stream:!1}),c}default:throw new TypeError(`Asynchronous conversion from ${this.format} to String is not supported.`)}})}toUint8Array(){switch(this.format){case"ArrayBuffer":return new Uint8Array(this.data);case"Base32Z":return Ks.baseDecode(this.data);case"Base58Btc":return Pe.baseDecode(this.data);case"Base64Url":return ot.baseDecode(this.data);case"BufferSource":{let e=Wn(this.data);if(e==="Uint8Array")return this.data;if(e==="ArrayBuffer")return new Uint8Array(this.data);if(ArrayBuffer.isView(this.data))return new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength);throw new TypeError(`${this.format} value is not of type: ArrayBuffer, DataView, or TypedArray.`)}case"Hex":{let e=new Uint8Array(this.data.length/2);for(let r=0;r<this.data.length;r+=2){let n=parseInt(this.data.substring(r,r+2),16);if(isNaN(n))throw new TypeError("Input is not a valid hexadecimal string.");e[r/2]=n}return e}case"Object":{let e=JSON.stringify(this.data);return $i.encode(e)}case"String":return $i.encode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Uint8Array is not supported.`)}}toUint8ArrayAsync(){return Jn(this,void 0,void 0,function*(){switch(this.format){case"AsyncIterable":{let e=yield this.toArrayBufferAsync();return new Uint8Array(e)}default:throw new TypeError(`Asynchronous conversion from ${this.format} to Uint8Array is not supported.`)}})}};var zn;(function(t){t.Debug="debug",t.Silent="silent"})(zn||(zn={}));var Ns=class{constructor(){this.logLevel=zn.Silent}setLogLevel(e){this.logLevel=e}log(e){this.info(e)}info(e){this.logLevel!==zn.Silent&&console.info(e)}error(e){this.logLevel!==zn.Silent&&console.error(e)}},_0=new Ns;typeof window<"u"&&(window.web5logger=_0);var vt={};Yf(vt,{decode:()=>nn,encodeTo:()=>Er,encodingLength:()=>_r});var A0=cu,su=128,S0=127,v0=~S0,B0=Math.pow(2,31);function cu(t,e,r){e=e||[],r=r||0;for(var n=r;t>=B0;)e[r++]=t&255|su,t/=128;for(;t&v0;)e[r++]=t&255|su,t>>>=7;return e[r]=t|0,cu.bytes=r-n+1,e}var T0=Ds,k0=128,au=127;function Ds(t,n){var r=0,n=n||0,i=0,o=n,s,a=t.length;do{if(o>=a)throw Ds.bytes=0,new RangeError("Could not decode varint");s=t[o++],r+=i<28?(s&au)<<i:(s&au)*Math.pow(2,i),i+=7}while(s>=k0);return Ds.bytes=o-n,r}var P0=Math.pow(2,7),I0=Math.pow(2,14),R0=Math.pow(2,21),U0=Math.pow(2,28),C0=Math.pow(2,35),L0=Math.pow(2,42),O0=Math.pow(2,49),K0=Math.pow(2,56),N0=Math.pow(2,63),D0=function(t){return t<P0?1:t<I0?2:t<R0?3:t<U0?4:t<C0?5:t<L0?6:t<O0?7:t<K0?8:t<N0?9:10},M0={encode:A0,decode:T0,encodingLength:D0},q0=M0,Yn=q0;function nn(t,e=0){return[Yn.decode(t,e),Yn.decode.bytes]}function Er(t,e,r=0){return Yn.encode(t,e,r),e}function _r(t){return Yn.encodingLength(t)}function Ms(t,e){let r=e.byteLength,n=_r(t),i=n+_r(r),o=new Uint8Array(i+r);return Er(t,o,0),Er(r,o,n),o.set(e,i),new on(t,r,e,o)}function fu(t){let e=rn(t),[r,n]=nn(e),[i,o]=nn(e.subarray(n)),s=e.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new on(r,i,s,e)}function uu(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&Qf(t.bytes,r.bytes)}}var on=class{code;size;digest;bytes;constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}};function lu(t,e){let{bytes:r,version:n}=t;switch(n){case 0:return F0(r,js(t),e??Pe.encoder);default:return $0(r,js(t),e??Gn.encoder)}}var du=new WeakMap;function js(t){let e=du.get(t);if(e==null){let r=new Map;return du.set(t,r),r}return e}var Fs=class t{code;version;multihash;bytes;"/";constructor(e,r,n,i){this.code=r,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:r}=this;if(e!==Zn)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==V0)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:r}=this.multihash,n=Ms(e,r);return t.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return t.equals(this,e)}static equals(e,r){let n=r;return n!=null&&e.code===n.code&&e.version===n.version&&uu(e.multihash,n.multihash)}toString(e){return lu(this,e)}toJSON(){return{"/":lu(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:i,multihash:o,bytes:s}=r;return new t(n,i,o,s??hu(n,i,o.bytes))}else if(r[H0]===!0){let{version:n,multihash:i,code:o}=r,s=fu(i);return t.create(n,o,s)}else return null}static create(e,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(r!==Zn)throw new Error(`Version 0 CID must use dag-pb (code: ${Zn}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let i=hu(e,r,n.bytes);return new t(e,r,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,Zn,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,i=rn(e.subarray(n,n+r.multihashSize));if(i.byteLength!==r.multihashSize)throw new Error("Incorrect length");let o=i.subarray(r.multihashSize-r.digestSize),s=new on(r.multihashCode,r.digestSize,o,i);return[r.version===0?t.createV0(s):t.createV1(r.codec,s),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[l,p]=nn(e.subarray(r));return r+=p,l},i=n(),o=Zn;if(i===18?(i=0,r=0):o=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let s=r,a=n(),c=n(),f=r+c,u=f-s;return{version:i,codec:o,multihashCode:a,digestSize:c,multihashSize:u,size:f}}static parse(e,r){let[n,i]=j0(e,r),o=t.decode(i);if(o.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return js(o).set(n,e),o}};function j0(t,e){switch(t[0]){case"Q":{let r=e??Pe;return[Pe.prefix,r.decode(`${Pe.prefix}${t}`)]}case Pe.prefix:{let r=e??Pe;return[Pe.prefix,r.decode(t)]}case Gn.prefix:{let r=e??Gn;return[Gn.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}}function F0(t,e,r){let{prefix:n}=r;if(n!==Pe.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let i=e.get(n);if(i==null){let o=r.encode(t).slice(1);return e.set(n,o),o}else return i}function $0(t,e,r){let{prefix:n}=r,i=e.get(n);if(i==null){let o=r.encode(t);return e.set(n,o),o}else return i}var Zn=112,V0=18;function hu(t,e,r){let n=_r(t),i=n+_r(e),o=new Uint8Array(i+r.byteLength);return Er(t,o,0),Er(e,o,n),o.set(r,i),o}var H0=Symbol.for("@ipld/js-cid/CID");var st=class t{static addPrefix(e){var r;let{code:n,data:i,name:o}=e;if(!(o?!n:n))throw new Error("Either 'name' or 'code' must be defined, but not both.");if(n=t.codeToName.has(n)?n:t.nameToCode.get(o),n===void 0)throw new Error(`Unsupported multicodec: ${(r=e.name)!==null&&r!==void 0?r:e.code}`);let s=vt.encodingLength(n),a=new Uint8Array(s+i.byteLength);return a.set(i,s),vt.encodeTo(n,a),a}static getCodeFromData(e){let{prefixedData:r}=e,[n,i]=vt.decode(r);return n}static getCodeFromName(e){let{name:r}=e,n=t.nameToCode.get(r);if(n===void 0)throw new Error(`Unsupported multicodec: ${r}`);return n}static getNameFromCode(e){let{code:r}=e,n=t.codeToName.get(r);if(n===void 0)throw new Error(`Unsupported multicodec: ${r}`);return n}static registerCodec(e){t.codeToName.set(e.code,e.name),t.nameToCode.set(e.name,e.code)}static removePrefix(e){let{prefixedData:r}=e,[n,i]=vt.decode(r),o=t.codeToName.get(n);if(o===void 0)throw new Error(`Unsupported multicodec: ${n}`);return{code:n,data:r.slice(i),name:o}}};st.codeToName=new Map;st.nameToCode=new Map;st.registerCodec({code:237,name:"ed25519-pub"});st.registerCodec({code:4864,name:"ed25519-priv"});st.registerCodec({code:236,name:"x25519-pub"});st.registerCodec({code:4866,name:"x25519-priv"});st.registerCodec({code:231,name:"secp256k1-pub"});st.registerCodec({code:4865,name:"secp256k1-priv"});function $s(t){Object.keys(t).forEach(e=>{t[e]===void 0?delete t[e]:typeof t[e]=="object"&&$s(t[e])})}var Im=ji(Gl(),1),Mr=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(u){try{f(n.next(u))}catch(l){s(l)}}function c(u){try{f(n.throw(u))}catch(l){s(l)}}function f(u){u.done?o(u.value):i(u.value).then(a,c)}f((n=n.apply(t,e||[])).next())})};var Eo=class{constructor(){this.store=new Map}clear(){return Mr(this,void 0,void 0,function*(){this.store.clear()})}close(){return Mr(this,void 0,void 0,function*(){})}delete(e){return Mr(this,void 0,void 0,function*(){return this.store.delete(e)})}get(e){return Mr(this,void 0,void 0,function*(){return this.store.get(e)})}has(e){return Mr(this,void 0,void 0,function*(){return this.store.has(e)})}list(){return Mr(this,void 0,void 0,function*(){return Array.from(this.store.values())})}set(e,r){return Mr(this,void 0,void 0,function*(){this.store.set(e,r)})}};var z1=ji(of(),1);var Y1=ji(of(),1);function Z1(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function es(t,...e){if(!Z1(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function sf(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Hp(t,e){es(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var qt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var rs=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),et=(t,e)=>t<<32-e|t>>>e;var nv=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function X1(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function af(t){return typeof t=="string"&&(t=X1(t)),es(t),t}function cf(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];es(i),e+=i.length}let r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){let o=t[n];r.set(o,i),i+=o.length}return r}var ts=class{clone(){return this._cloneInto()}},iv={}.toString;function Gp(t){let e=n=>t().update(af(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Wp(t=32){if(qt&&typeof qt.getRandomValues=="function")return qt.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function Q1(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),c=n?4:0,f=n?0:4;t.setUint32(e+c,s,n),t.setUint32(e+f,a,n)}var Jp=(t,e,r)=>t&e^~t&r,zp=(t,e,r)=>t&e^t&r^e&r,ns=class extends ts{constructor(e,r,n,i){super(),this.blockLen=e,this.outputLen=r,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=rs(this.buffer)}update(e){sf(this);let{view:r,buffer:n,blockLen:i}=this;e=af(e);let o=e.length;for(let s=0;s<o;){let a=Math.min(i-this.pos,o-s);if(a===i){let c=rs(e);for(;i<=o-s;s+=i)this.process(c,s);continue}n.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){sf(this),Hp(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:o}=this,{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let l=s;l<i;l++)r[l]=0;Q1(n,i-8,BigInt(this.length*8),o),this.process(n,0);let a=rs(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=c/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<f;l++)a.setUint32(4*l,u[l],o)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:i,finished:o,destroyed:s,pos:a}=this;return e.length=i,e.pos=a,e.finished=o,e.destroyed=s,i%r&&e.buffer.set(n),e}};var e2=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]),cr=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),fr=new Uint32Array(64),ff=class extends ns{constructor(){super(64,32,8,!1),this.A=cr[0]|0,this.B=cr[1]|0,this.C=cr[2]|0,this.D=cr[3]|0,this.E=cr[4]|0,this.F=cr[5]|0,this.G=cr[6]|0,this.H=cr[7]|0}get(){let{A:e,B:r,C:n,D:i,E:o,F:s,G:a,H:c}=this;return[e,r,n,i,o,s,a,c]}set(e,r,n,i,o,s,a,c){this.A=e|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=a|0,this.H=c|0}process(e,r){for(let l=0;l<16;l++,r+=4)fr[l]=e.getUint32(r,!1);for(let l=16;l<64;l++){let p=fr[l-15],h=fr[l-2],y=et(p,7)^et(p,18)^p>>>3,d=et(h,17)^et(h,19)^h>>>10;fr[l]=d+fr[l-7]+y+fr[l-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:c,G:f,H:u}=this;for(let l=0;l<64;l++){let p=et(a,6)^et(a,11)^et(a,25),h=u+p+Jp(a,c,f)+e2[l]+fr[l]|0,d=(et(n,2)^et(n,13)^et(n,22))+zp(n,i,o)|0;u=f,f=c,c=a,a=s+h|0,s=o,o=i,i=n,n=h+d|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(n,i,o,s,a,c,f,u)}roundClean(){fr.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var xt=Gp(()=>new ff);var Kn=class{static async digest({data:e}){return xt(e)}};var He=class{};var is=class extends He{async digest({algorithm:e,data:r}){switch(e){case"SHA-256":return await Kn.digest({data:r})}}};function Yp(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function t2(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function uf(t,...e){if(!t2(t))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function Zp(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Yp(t.outputLen),Yp(t.blockLen)}function Nn(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Xp(t,e){uf(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var os=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Qp(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}var ss=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),tt=(t,e)=>t<<32-e|t>>>e,r2=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!r2)throw new Error("Non little-endian hardware is not supported");function lf(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function Ri(t){if(typeof t=="string"&&(t=lf(t)),!Qp(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}function as(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];if(!Qp(i))throw new Error("Uint8Array expected");e+=i.length}let r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){let o=t[n];r.set(o,i),i+=o.length}return r}var Dn=class{clone(){return this._cloneInto()}},Ev={}.toString;function cs(t){let e=n=>t().update(Ri(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Ui(t=32){if(os&&typeof os.getRandomValues=="function")return os.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function n2(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),c=n?4:0,f=n?0:4;t.setUint32(e+c,s,n),t.setUint32(e+f,a,n)}var Mn=class extends Dn{constructor(e,r,n,i){super(),this.blockLen=e,this.outputLen=r,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=ss(this.buffer)}update(e){Nn(this);let{view:r,buffer:n,blockLen:i}=this;e=Ri(e);let o=e.length;for(let s=0;s<o;){let a=Math.min(i-this.pos,o-s);if(a===i){let c=ss(e);for(;i<=o-s;s+=i)this.process(c,s);continue}n.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Nn(this),Xp(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:o}=this,{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let l=s;l<i;l++)r[l]=0;n2(n,i-8,BigInt(this.length*8),o),this.process(n,0);let a=ss(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=c/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<f;l++)a.setUint32(4*l,u[l],o)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:i,finished:o,destroyed:s,pos:a}=this;return e.length=i,e.pos=a,e.finished=o,e.destroyed=s,i%r&&e.buffer.set(n),e}};var i2=(t,e,r)=>t&e^~t&r,o2=(t,e,r)=>t&e^t&r^e&r,s2=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]),ur=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),lr=new Uint32Array(64),df=class extends Mn{constructor(){super(64,32,8,!1),this.A=ur[0]|0,this.B=ur[1]|0,this.C=ur[2]|0,this.D=ur[3]|0,this.E=ur[4]|0,this.F=ur[5]|0,this.G=ur[6]|0,this.H=ur[7]|0}get(){let{A:e,B:r,C:n,D:i,E:o,F:s,G:a,H:c}=this;return[e,r,n,i,o,s,a,c]}set(e,r,n,i,o,s,a,c){this.A=e|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=a|0,this.H=c|0}process(e,r){for(let l=0;l<16;l++,r+=4)lr[l]=e.getUint32(r,!1);for(let l=16;l<64;l++){let p=lr[l-15],h=lr[l-2],y=tt(p,7)^tt(p,18)^p>>>3,d=tt(h,17)^tt(h,19)^h>>>10;lr[l]=d+lr[l-7]+y+lr[l-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:c,G:f,H:u}=this;for(let l=0;l<64;l++){let p=tt(a,6)^tt(a,11)^tt(a,25),h=u+p+i2(a,c,f)+s2[l]+lr[l]|0,d=(tt(n,2)^tt(n,13)^tt(n,22))+o2(n,i,o)|0;u=f,f=c,c=a,a=s+h|0,s=o,o=i,i=n,n=h+d|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(n,i,o,s,a,c,f,u)}roundClean(){lr.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var fs=cs(()=>new df);var ls={};Yf(ls,{bitGet:()=>h2,bitLen:()=>d2,bitMask:()=>Ci,bitSet:()=>p2,bytesToHex:()=>Ft,bytesToNumberBE:()=>$t,bytesToNumberLE:()=>nt,concatBytes:()=>Ht,createHmacDrbg:()=>yf,ensureBytes:()=>oe,equalBytes:()=>u2,hexToBytes:()=>Xr,hexToNumber:()=>pf,isBytes:()=>rt,numberToBytesBE:()=>Ue,numberToBytesLE:()=>Vt,numberToHexUnpadded:()=>ny,numberToVarBytesBE:()=>f2,utf8ToBytes:()=>l2,validateObject:()=>Ge});var ry=BigInt(0),us=BigInt(1),a2=BigInt(2);function rt(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}var c2=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Ft(t){if(!rt(t))throw new Error("Uint8Array expected");let e="";for(let r=0;r<t.length;r++)e+=c2[t[r]];return e}function ny(t){let e=t.toString(16);return e.length&1?`0${e}`:e}function pf(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}var jt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function ey(t){if(t>=jt._0&&t<=jt._9)return t-jt._0;if(t>=jt._A&&t<=jt._F)return t-(jt._A-10);if(t>=jt._a&&t<=jt._f)return t-(jt._a-10)}function Xr(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let i=0,o=0;i<r;i++,o+=2){let s=ey(t.charCodeAt(o)),a=ey(t.charCodeAt(o+1));if(s===void 0||a===void 0){let c=t[o]+t[o+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+o)}n[i]=s*16+a}return n}function $t(t){return pf(Ft(t))}function nt(t){if(!rt(t))throw new Error("Uint8Array expected");return pf(Ft(Uint8Array.from(t).reverse()))}function Ue(t,e){return Xr(t.toString(16).padStart(e*2,"0"))}function Vt(t,e){return Ue(t,e).reverse()}function f2(t){return Xr(ny(t))}function oe(t,e,r){let n;if(typeof e=="string")try{n=Xr(e)}catch(o){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${o}`)}else if(rt(e))n=Uint8Array.from(e);else throw new Error(`${t} must be hex string or Uint8Array`);let i=n.length;if(typeof r=="number"&&i!==r)throw new Error(`${t} expected ${r} bytes, got ${i}`);return n}function Ht(...t){let e=0;for(let i=0;i<t.length;i++){let o=t[i];if(!rt(o))throw new Error("Uint8Array expected");e+=o.length}let r=new Uint8Array(e),n=0;for(let i=0;i<t.length;i++){let o=t[i];r.set(o,n),n+=o.length}return r}function u2(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return r===0}function l2(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function d2(t){let e;for(e=0;t>ry;t>>=us,e+=1);return e}function h2(t,e){return t>>BigInt(e)&us}var p2=(t,e,r)=>t|(r?us:ry)<<BigInt(e),Ci=t=>(a2<<BigInt(t-1))-us,hf=t=>new Uint8Array(t),ty=t=>Uint8Array.from(t);function yf(t,e,r){if(typeof t!="number"||t<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 r!="function")throw new Error("hmacFn must be a function");let n=hf(t),i=hf(t),o=0,s=()=>{n.fill(1),i.fill(0),o=0},a=(...l)=>r(i,n,...l),c=(l=hf())=>{i=a(ty([0]),l),n=a(),l.length!==0&&(i=a(ty([1]),l),n=a())},f=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,p=[];for(;l<e;){n=a();let h=n.slice();p.push(h),l+=n.length}return Ht(...p)};return(l,p)=>{s(),c(l);let h;for(;!(h=p(f()));)c();return s(),h}}var y2={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||rt(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function Ge(t,e,r={}){let n=(i,o,s)=>{let a=y2[o];if(typeof a!="function")throw new Error(`Invalid validator "${o}", expected function`);let c=t[i];if(!(s&&c===void 0)&&!a(c,t))throw new Error(`Invalid param ${String(i)}=${c} (${typeof c}), expected ${o}`)};for(let[i,o]of Object.entries(e))n(i,o,!1);for(let[i,o]of Object.entries(r))n(i,o,!0);return t}var ye=BigInt(0),ae=BigInt(1),Qr=BigInt(2),w2=BigInt(3),wf=BigInt(4),iy=BigInt(5),oy=BigInt(8),m2=BigInt(9),b2=BigInt(16);function ee(t,e){let r=t%e;return r>=ye?r:e+r}function mf(t,e,r){if(r<=ye||e<ye)throw new Error("Expected power/modulo > 0");if(r===ae)return ye;let n=ae;for(;e>ye;)e&ae&&(n=n*t%r),t=t*t%r,e>>=ae;return n}function se(t,e,r){let n=t;for(;e-- >ye;)n*=n,n%=r;return n}function ds(t,e){if(t===ye||e<=ye)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=ee(t,e),n=e,i=ye,o=ae,s=ae,a=ye;for(;r!==ye;){let f=n/r,u=n%r,l=i-s*f,p=o-a*f;n=r,r=u,i=s,o=a,s=l,a=p}if(n!==ae)throw new Error("invert: does not exist");return ee(i,e)}function g2(t){let e=(t-ae)/Qr,r,n,i;for(r=t-ae,n=0;r%Qr===ye;r/=Qr,n++);for(i=Qr;i<t&&mf(i,e,t)!==t-ae;i++);if(n===1){let s=(t+ae)/wf;return function(c,f){let u=c.pow(f,s);if(!c.eql(c.sqr(u),f))throw new Error("Cannot find square root");return u}}let o=(r+ae)/Qr;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let f=n,u=a.pow(a.mul(a.ONE,i),r),l=a.pow(c,o),p=a.pow(c,r);for(;!a.eql(p,a.ONE);){if(a.eql(p,a.ZERO))return a.ZERO;let h=1;for(let d=a.sqr(p);h<f&&!a.eql(d,a.ONE);h++)d=a.sqr(d);let y=a.pow(u,ae<<BigInt(f-h-1));u=a.sqr(y),l=a.mul(l,y),p=a.mul(p,u),f=h}return l}}function x2(t){if(t%wf===w2){let e=(t+ae)/wf;return function(n,i){let o=n.pow(i,e);if(!n.eql(n.sqr(o),i))throw new Error("Cannot find square root");return o}}if(t%oy===iy){let e=(t-iy)/oy;return function(n,i){let o=n.mul(i,Qr),s=n.pow(o,e),a=n.mul(i,s),c=n.mul(n.mul(a,Qr),s),f=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(f),i))throw new Error("Cannot find square root");return f}}return t%b2,g2(t)}var sy=(t,e)=>(ee(t,e)&ae)===ae,E2=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function bf(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=E2.reduce((n,i)=>(n[i]="function",n),e);return Ge(t,r)}function _2(t,e,r){if(r<ye)throw new Error("Expected power > 0");if(r===ye)return t.ONE;if(r===ae)return e;let n=t.ONE,i=e;for(;r>ye;)r&ae&&(n=t.mul(n,i)),i=t.sqr(i),r>>=ae;return n}function A2(t,e){let r=new Array(e.length),n=e.reduce((o,s,a)=>t.is0(s)?o:(r[a]=o,t.mul(o,s)),t.ONE),i=t.inv(n);return e.reduceRight((o,s,a)=>t.is0(s)?o:(r[a]=t.mul(o,r[a]),t.mul(o,s)),i),r}function gf(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function qn(t,e,r=!1,n={}){if(t<=ye)throw new Error(`Expected Field ORDER > 0, got ${t}`);let{nBitLength:i,nByteLength:o}=gf(t,e);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=x2(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:o,MASK:Ci(i),ZERO:ye,ONE:ae,create:c=>ee(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return ye<=c&&c<t},is0:c=>c===ye,isOdd:c=>(c&ae)===ae,neg:c=>ee(-c,t),eql:(c,f)=>c===f,sqr:c=>ee(c*c,t),add:(c,f)=>ee(c+f,t),sub:(c,f)=>ee(c-f,t),mul:(c,f)=>ee(c*f,t),pow:(c,f)=>_2(a,c,f),div:(c,f)=>ee(c*ds(f,t),t),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>ds(c,t),sqrt:n.sqrt||(c=>s(a,c)),invertBatch:c=>A2(a,c),cmov:(c,f,u)=>u?f:c,toBytes:c=>r?Vt(c,o):Ue(c,o),fromBytes:c=>{if(c.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${c.length}`);return r?nt(c):$t(c)}});return Object.freeze(a)}function ay(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");let r=t.sqrt(e);return t.isOdd(r)?t.neg(r):r}function cy(t){if(typeof t!="bigint")throw new Error("field order must be bigint");let e=t.toString(2).length;return Math.ceil(e/8)}function xf(t){let e=cy(t);return e+Math.ceil(e/2)}function fy(t,e,r=!1){let n=t.length,i=cy(e),o=xf(e);if(n<16||n<o||n>1024)throw new Error(`expected ${o}-1024 bytes of input, got ${n}`);let s=r?$t(t):nt(t),a=ee(s,e-ae)+ae;return r?Vt(a,i):Ue(a,i)}var v2=BigInt(0),Ef=BigInt(1);function hs(t,e){let r=(i,o)=>{let s=o.negate();return i?s:o},n=i=>{let o=Math.ceil(e/i)+1,s=2**(i-1);return{windows:o,windowSize:s}};return{constTimeNegate:r,unsafeLadder(i,o){let s=t.ZERO,a=i;for(;o>v2;)o&Ef&&(s=s.add(a)),a=a.double(),o>>=Ef;return s},precomputeWindow(i,o){let{windows:s,windowSize:a}=n(o),c=[],f=i,u=f;for(let l=0;l<s;l++){u=f,c.push(u);for(let p=1;p<a;p++)u=u.add(f),c.push(u);f=u.double()}return c},wNAF(i,o,s){let{windows:a,windowSize:c}=n(i),f=t.ZERO,u=t.BASE,l=BigInt(2**i-1),p=2**i,h=BigInt(i);for(let y=0;y<a;y++){let d=y*c,w=Number(s&l);s>>=h,w>c&&(w-=p,s+=Ef);let m=d,A=d+Math.abs(w)-1,g=y%2!==0,_=w<0;w===0?u=u.add(r(g,o[m])):f=f.add(r(_,o[A]))}return{p:f,f:u}},wNAFCached(i,o,s,a){let c=i._WINDOW_SIZE||1,f=o.get(i);return f||(f=this.precomputeWindow(i,c),c!==1&&o.set(i,a(f))),this.wNAF(c,f,s)}}}function Li(t){return bf(t.Fp),Ge(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...gf(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}function B2(t){let e=Li(t);Ge(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:r,Fp:n,a:i}=e;if(r){if(!n.eql(i,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:T2,hexToBytes:k2}=ls,en={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(t){let{Err:e}=en;if(t.length<2||t[0]!==2)throw new e("Invalid signature integer tag");let r=t[1],n=t.subarray(2,r+2);if(!r||n.length!==r)throw new e("Invalid signature integer: wrong length");if(n[0]&128)throw new e("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:T2(n),l:t.subarray(r+2)}},toSig(t){let{Err:e}=en,r=typeof t=="string"?k2(t):t;if(!rt(r))throw new Error("ui8a expected");let n=r.length;if(n<2||r[0]!=48)throw new e("Invalid signature tag");if(r[1]!==n-2)throw new e("Invalid signature: incorrect length");let{d:i,l:o}=en._parseInt(r.subarray(2)),{d:s,l:a}=en._parseInt(o);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:i,s}},hexFromSig(t){let e=f=>Number.parseInt(f[0],16)&8?"00"+f:f,r=f=>{let u=f.toString(16);return u.length&1?`0${u}`:u},n=e(r(t.s)),i=e(r(t.r)),o=n.length/2,s=i.length/2,a=r(o),c=r(s);return`30${r(s+o+4)}02${c}${i}02${a}${n}`}},Gt=BigInt(0),We=BigInt(1),Kv=BigInt(2),uy=BigInt(3),Nv=BigInt(4);function P2(t){let e=B2(t),{Fp:r}=e,n=e.toBytes||((y,d,w)=>{let m=d.toAffine();return Ht(Uint8Array.from([4]),r.toBytes(m.x),r.toBytes(m.y))}),i=e.fromBytes||(y=>{let d=y.subarray(1),w=r.fromBytes(d.subarray(0,r.BYTES)),m=r.fromBytes(d.subarray(r.BYTES,2*r.BYTES));return{x:w,y:m}});function o(y){let{a:d,b:w}=e,m=r.sqr(y),A=r.mul(m,y);return r.add(r.add(A,r.mul(y,d)),w)}if(!r.eql(r.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function s(y){return typeof y=="bigint"&&Gt<y&&y<e.n}function a(y){if(!s(y))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(y){let{allowedPrivateKeyLengths:d,nByteLength:w,wrapPrivateKey:m,n:A}=e;if(d&&typeof y!="bigint"){if(rt(y)&&(y=Ft(y)),typeof y!="string"||!d.includes(y.length))throw new Error("Invalid key");y=y.padStart(w*2,"0")}let g;try{g=typeof y=="bigint"?y:$t(oe("private key",y,w))}catch{throw new Error(`private key must be ${w} bytes, hex or bigint, not ${typeof y}`)}return m&&(g=ee(g,A)),a(g),g}let f=new Map;function u(y){if(!(y instanceof l))throw new Error("ProjectivePoint expected")}class l{constructor(d,w,m){if(this.px=d,this.py=w,this.pz=m,d==null||!r.isValid(d))throw new Error("x required");if(w==null||!r.isValid(w))throw new Error("y required");if(m==null||!r.isValid(m))throw new Error("z required")}static fromAffine(d){let{x:w,y:m}=d||{};if(!d||!r.isValid(w)||!r.isValid(m))throw new Error("invalid affine point");if(d instanceof l)throw new Error("projective point not allowed");let A=g=>r.eql(g,r.ZERO);return A(w)&&A(m)?l.ZERO:new l(w,m,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){let w=r.invertBatch(d.map(m=>m.pz));return d.map((m,A)=>m.toAffine(w[A])).map(l.fromAffine)}static fromHex(d){let w=l.fromAffine(i(oe("pointHex",d)));return w.assertValidity(),w}static fromPrivateKey(d){return l.BASE.multiply(c(d))}_setWindowSize(d){this._WINDOW_SIZE=d,f.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}let{x:d,y:w}=this.toAffine();if(!r.isValid(d)||!r.isValid(w))throw new Error("bad point: x or y not FE");let m=r.sqr(w),A=o(d);if(!r.eql(m,A))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:d}=this.toAffine();if(r.isOdd)return!r.isOdd(d);throw new Error("Field doesn't support isOdd")}equals(d){u(d);let{px:w,py:m,pz:A}=this,{px:g,py:_,pz:E}=d,B=r.eql(r.mul(w,E),r.mul(g,A)),T=r.eql(r.mul(m,E),r.mul(_,A));return B&&T}negate(){return new l(this.px,r.neg(this.py),this.pz)}double(){let{a:d,b:w}=e,m=r.mul(w,uy),{px:A,py:g,pz:_}=this,E=r.ZERO,B=r.ZERO,T=r.ZERO,k=r.mul(A,A),R=r.mul(g,g),C=r.mul(_,_),L=r.mul(A,g);return L=r.add(L,L),T=r.mul(A,_),T=r.add(T,T),E=r.mul(d,T),B=r.mul(m,C),B=r.add(E,B),E=r.sub(R,B),B=r.add(R,B),B=r.mul(E,B),E=r.mul(L,E),T=r.mul(m,T),C=r.mul(d,C),L=r.sub(k,C),L=r.mul(d,L),L=r.add(L,T),T=r.add(k,k),k=r.add(T,k),k=r.add(k,C),k=r.mul(k,L),B=r.add(B,k),C=r.mul(g,_),C=r.add(C,C),k=r.mul(C,L),E=r.sub(E,k),T=r.mul(C,R),T=r.add(T,T),T=r.add(T,T),new l(E,B,T)}add(d){u(d);let{px:w,py:m,pz:A}=this,{px:g,py:_,pz:E}=d,B=r.ZERO,T=r.ZERO,k=r.ZERO,R=e.a,C=r.mul(e.b,uy),L=r.mul(w,g),j=r.mul(m,_),K=r.mul(A,E),Y=r.add(w,m),S=r.add(g,_);Y=r.mul(Y,S),S=r.add(L,j),Y=r.sub(Y,S),S=r.add(w,A);let I=r.add(g,E);return S=r.mul(S,I),I=r.add(L,K),S=r.sub(S,I),I=r.add(m,A),B=r.add(_,E),I=r.mul(I,B),B=r.add(j,K),I=r.sub(I,B),k=r.mul(R,S),B=r.mul(C,K),k=r.add(B,k),B=r.sub(j,k),k=r.add(j,k),T=r.mul(B,k),j=r.add(L,L),j=r.add(j,L),K=r.mul(R,K),S=r.mul(C,S),j=r.add(j,K),K=r.sub(L,K),K=r.mul(R,K),S=r.add(S,K),L=r.mul(j,S),T=r.add(T,L),L=r.mul(I,S),B=r.mul(Y,B),B=r.sub(B,L),L=r.mul(Y,j),k=r.mul(I,k),k=r.add(k,L),new l(B,T,k)}subtract(d){return this.add(d.negate())}is0(){return this.equals(l.ZERO)}wNAF(d){return h.wNAFCached(this,f,d,w=>{let m=r.invertBatch(w.map(A=>A.pz));return w.map((A,g)=>A.toAffine(m[g])).map(l.fromAffine)})}multiplyUnsafe(d){let w=l.ZERO;if(d===Gt)return w;if(a(d),d===We)return this;let{endo:m}=e;if(!m)return h.unsafeLadder(this,d);let{k1neg:A,k1:g,k2neg:_,k2:E}=m.splitScalar(d),B=w,T=w,k=this;for(;g>Gt||E>Gt;)g&We&&(B=B.add(k)),E&We&&(T=T.add(k)),k=k.double(),g>>=We,E>>=We;return A&&(B=B.negate()),_&&(T=T.negate()),T=new l(r.mul(T.px,m.beta),T.py,T.pz),B.add(T)}multiply(d){a(d);let w=d,m,A,{endo:g}=e;if(g){let{k1neg:_,k1:E,k2neg:B,k2:T}=g.splitScalar(w),{p:k,f:R}=this.wNAF(E),{p:C,f:L}=this.wNAF(T);k=h.constTimeNegate(_,k),C=h.constTimeNegate(B,C),C=new l(r.mul(C.px,g.beta),C.py,C.pz),m=k.add(C),A=R.add(L)}else{let{p:_,f:E}=this.wNAF(w);m=_,A=E}return l.normalizeZ([m,A])[0]}multiplyAndAddUnsafe(d,w,m){let A=l.BASE,g=(E,B)=>B===Gt||B===We||!E.equals(A)?E.multiplyUnsafe(B):E.multiply(B),_=g(this,w).add(g(d,m));return _.is0()?void 0:_}toAffine(d){let{px:w,py:m,pz:A}=this,g=this.is0();d==null&&(d=g?r.ONE:r.inv(A));let _=r.mul(w,d),E=r.mul(m,d),B=r.mul(A,d);if(g)return{x:r.ZERO,y:r.ZERO};if(!r.eql(B,r.ONE))throw new Error("invZ was invalid");return{x:_,y:E}}isTorsionFree(){let{h:d,isTorsionFree:w}=e;if(d===We)return!0;if(w)return w(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:d,clearCofactor:w}=e;return d===We?this:w?w(l,this):this.multiplyUnsafe(e.h)}toRawBytes(d=!0){return this.assertValidity(),n(l,this,d)}toHex(d=!0){return Ft(this.toRawBytes(d))}}l.BASE=new l(e.Gx,e.Gy,r.ONE),l.ZERO=new l(r.ZERO,r.ONE,r.ZERO);let p=e.nBitLength,h=hs(l,e.endo?Math.ceil(p/2):p);return{CURVE:e,ProjectivePoint:l,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:s}}function I2(t){let e=Li(t);return Ge(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function ly(t){let e=I2(t),{Fp:r,n}=e,i=r.BYTES+1,o=2*r.BYTES+1;function s(S){return Gt<S&&S<r.ORDER}function a(S){return ee(S,n)}function c(S){return ds(S,n)}let{ProjectivePoint:f,normPrivateKeyToScalar:u,weierstrassEquation:l,isWithinCurveOrder:p}=P2({...e,toBytes(S,I,N){let v=I.toAffine(),b=r.toBytes(v.x),P=Ht;return N?P(Uint8Array.from([I.hasEvenY()?2:3]),b):P(Uint8Array.from([4]),b,r.toBytes(v.y))},fromBytes(S){let I=S.length,N=S[0],v=S.subarray(1);if(I===i&&(N===2||N===3)){let b=$t(v);if(!s(b))throw new Error("Point is not on curve");let P=l(b),U=r.sqrt(P),O=(U&We)===We;return(N&1)===1!==O&&(U=r.neg(U)),{x:b,y:U}}else if(I===o&&N===4){let b=r.fromBytes(v.subarray(0,r.BYTES)),P=r.fromBytes(v.subarray(r.BYTES,2*r.BYTES));return{x:b,y:P}}else throw new Error(`Point of length ${I} was invalid. Expected ${i} compressed bytes or ${o} uncompressed bytes`)}}),h=S=>Ft(Ue(S,e.nByteLength));function y(S){let I=n>>We;return S>I}function d(S){return y(S)?a(-S):S}let w=(S,I,N)=>$t(S.slice(I,N));class m{constructor(I,N,v){this.r=I,this.s=N,this.recovery=v,this.assertValidity()}static fromCompact(I){let N=e.nByteLength;return I=oe("compactSignature",I,N*2),new m(w(I,0,N),w(I,N,2*N))}static fromDER(I){let{r:N,s:v}=en.toSig(oe("DER",I));return new m(N,v)}assertValidity(){if(!p(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!p(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(I){return new m(this.r,this.s,I)}recoverPublicKey(I){let{r:N,s:v,recovery:b}=this,P=T(oe("msgHash",I));if(b==null||![0,1,2,3].includes(b))throw new Error("recovery id invalid");let U=b===2||b===3?N+e.n:N;if(U>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let O=b&1?"03":"02",F=f.fromHex(O+h(U)),$=c(U),Z=a(-P*$),V=a(v*$),H=f.BASE.multiplyAndAddUnsafe(F,Z,V);if(!H)throw new Error("point at infinify");return H.assertValidity(),H}hasHighS(){return y(this.s)}normalizeS(){return this.hasHighS()?new m(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return Xr(this.toDERHex())}toDERHex(){return en.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Xr(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}let A={isValidPrivateKey(S){try{return u(S),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{let S=xf(e.n);return fy(e.randomBytes(S),e.n)},precompute(S=8,I=f.BASE){return I._setWindowSize(S),I.multiply(BigInt(3)),I}};function g(S,I=!0){return f.fromPrivateKey(S).toRawBytes(I)}function _(S){let I=rt(S),N=typeof S=="string",v=(I||N)&&S.length;return I?v===i||v===o:N?v===2*i||v===2*o:S instanceof f}function E(S,I,N=!0){if(_(S))throw new Error("first arg must be private key");if(!_(I))throw new Error("second arg must be public key");return f.fromHex(I).multiply(u(S)).toRawBytes(N)}let B=e.bits2int||function(S){let I=$t(S),N=S.length*8-e.nBitLength;return N>0?I>>BigInt(N):I},T=e.bits2int_modN||function(S){return a(B(S))},k=Ci(e.nBitLength);function R(S){if(typeof S!="bigint")throw new Error("bigint expected");if(!(Gt<=S&&S<k))throw new Error(`bigint expected < 2^${e.nBitLength}`);return Ue(S,e.nByteLength)}function C(S,I,N=L){if(["recovered","canonical"].some(te=>te in N))throw new Error("sign() legacy options not supported");let{hash:v,randomBytes:b}=e,{lowS:P,prehash:U,extraEntropy:O}=N;P==null&&(P=!0),S=oe("msgHash",S),U&&(S=oe("prehashed msgHash",v(S)));let F=T(S),$=u(I),Z=[R($),R(F)];if(O!=null){let te=O===!0?b(r.BYTES):O;Z.push(oe("extraEntropy",te))}let V=Ht(...Z),H=F;function ne(te){let be=B(te);if(!p(be))return;let ge=c(be),de=f.BASE.multiply(be).toAffine(),_e=a(de.x);if(_e===Gt)return;let St=a(ge*a(H+_e*$));if(St===Gt)return;let gr=(de.x===_e?0:2)|Number(de.y&We),Hn=St;return P&&y(St)&&(Hn=d(St),gr^=1),new m(_e,Hn,gr)}return{seed:V,k2sig:ne}}let L={lowS:e.lowS,prehash:!1},j={lowS:e.lowS,prehash:!1};function K(S,I,N=L){let{seed:v,k2sig:b}=C(S,I,N),P=e;return yf(P.hash.outputLen,P.nByteLength,P.hmac)(v,b)}f.BASE._setWindowSize(8);function Y(S,I,N,v=j){let b=S;if(I=oe("msgHash",I),N=oe("publicKey",N),"strict"in v)throw new Error("options.strict was renamed to lowS");let{lowS:P,prehash:U}=v,O,F;try{if(typeof b=="string"||rt(b))try{O=m.fromDER(b)}catch(de){if(!(de instanceof en.Err))throw de;O=m.fromCompact(b)}else if(typeof b=="object"&&typeof b.r=="bigint"&&typeof b.s=="bigint"){let{r:de,s:_e}=b;O=new m(de,_e)}else throw new Error("PARSE");F=f.fromHex(N)}catch(de){if(de.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(P&&O.hasHighS())return!1;U&&(I=e.hash(I));let{r:$,s:Z}=O,V=T(I),H=c(Z),ne=a(V*H),te=a($*H),be=f.BASE.multiplyAndAddUnsafe(F,ne,te)?.toAffine();return be?a(be.x)===$:!1}return{CURVE:e,getPublicKey:g,getSharedSecret:E,sign:K,verify:Y,ProjectivePoint:f,Signature:m,utils:A}}var ps=class extends Dn{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,Zp(e);let n=Ri(r);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let i=this.blockLen,o=new Uint8Array(i);o.set(n.length>i?e.create().update(n).digest():n);for(let s=0;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=e.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),o.fill(0)}update(e){return Nn(this),this.iHash.update(e),this}digestInto(e){Nn(this),uf(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:n,finished:i,destroyed:o,blockLen:s,outputLen:a}=this;return e=e,e.finished=i,e.destroyed=o,e.blockLen=s,e.outputLen=a,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},_f=(t,e,r)=>new ps(t,e).update(r).digest();_f.create=(t,e)=>new ps(t,e);function R2(t){return{hash:t,hmac:(e,...r)=>_f(t,e,as(...r)),randomBytes:Ui}}function ys(t,e){let r=n=>ly({...t,...R2(n)});return Object.freeze({...r(e),create:r})}var py=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),dy=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),U2=BigInt(1),Af=BigInt(2),hy=(t,e)=>(t+e/Af)/e;function C2(t){let e=py,r=BigInt(3),n=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),f=t*t*t%e,u=f*f*t%e,l=se(u,r,e)*u%e,p=se(l,r,e)*u%e,h=se(p,Af,e)*f%e,y=se(h,i,e)*h%e,d=se(y,o,e)*y%e,w=se(d,a,e)*d%e,m=se(w,c,e)*w%e,A=se(m,a,e)*d%e,g=se(A,r,e)*u%e,_=se(g,s,e)*y%e,E=se(_,n,e)*f%e,B=se(E,Af,e);if(!Sf.eql(Sf.sqr(B),t))throw new Error("Cannot find square root");return B}var Sf=qn(py,void 0,void 0,{sqrt:C2}),Ce=ys({a:BigInt(0),b:BigInt(7),Fp:Sf,n:dy,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{let e=dy,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-U2*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=r,s=BigInt("0x100000000000000000000000000000000"),a=hy(o*t,e),c=hy(-n*t,e),f=ee(t-a*r-c*i,e),u=ee(-a*n-c*o,e),l=f>s,p=u>s;if(l&&(f=e-f),p&&(u=e-u),f>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:l,k1:f,k2neg:p,k2:u}}}},fs),zv=BigInt(0);var Yv=Ce.ProjectivePoint;function yy(t){let e=n=>{if(n!==null&&typeof n=="object"&&!Array.isArray(n)){let i=Object.keys(n).sort(),o={};for(let s of i)o[s]=e(n[s]);return o}return n},r=e(t);return JSON.stringify(r)}var vf="urn:jwk:";async function G({jwk:t}){let e=t.kty,r;if(e==="EC")r={crv:t.crv,kty:t.kty,x:t.x,y:t.y};else if(e==="oct")r={k:t.k,kty:t.kty};else if(e==="OKP")r={crv:t.crv,kty:t.kty,x:t.x};else if(e==="RSA")r={e:t.e,kty:t.kty,n:t.n};else throw new Error(`Unsupported key type: ${e}`);$s(r);let n=yy(r),i=q.string(n).toUint8Array(),o=await Kn.digest({data:i});return q.uint8Array(o).toBase64Url()}function Et(t){return!(!t||typeof t!="object"||!("kty"in t&&"crv"in t&&"x"in t&&"d"in t)||t.kty!=="EC"||typeof t.d!="string"||typeof t.x!="string")}function jn(t){return!(!t||typeof t!="object"||!("kty"in t&&"crv"in t&&"x"in t)||"d"in t||t.kty!=="EC"||typeof t.x!="string")}function dr(t){return!(!t||typeof t!="object"||!("kty"in t&&"k"in t)||t.kty!=="oct"||typeof t.k!="string")}function _t(t){return!(!t||typeof t!="object"||!("kty"in t&&"crv"in t&&"x"in t&&"d"in t)||t.kty!=="OKP"||typeof t.d!="string"||typeof t.x!="string")}function Fn(t){return!(!t||typeof t!="object"||"d"in t||!("kty"in t&&"crv"in t&&"x"in t)||t.kty!=="OKP"||typeof t.x!="string")}function wy(t){if(!t||typeof t!="object")return!1;switch(t.kty){case"EC":case"OKP":case"RSA":return"d"in t;case"oct":return"k"in t;default:return!1}}function r8(t){if(!t||typeof t!="object")return!1;switch(t.kty){case"EC":case"OKP":return"x"in t&&!("d"in t);case"RSA":return"n"in t&&"e"in t&&!("d"in t);default:return!1}}var hr=class t{static async adjustSignatureToLowS({signature:e}){let r=Ce.Signature.fromCompact(e);return r.hasHighS()?r.normalizeS().toCompactRawBytes():e}static async bytesToPrivateKey({privateKeyBytes:e}){let r=await t.getCurvePoint({keyBytes:e}),n={kty:"EC",crv:"secp256k1",d:q.uint8Array(e).toBase64Url(),x:q.uint8Array(r.x).toBase64Url(),y:q.uint8Array(r.y).toBase64Url()};return n.kid=await G({jwk:n}),n}static async bytesToPublicKey({publicKeyBytes:e}){let r=await t.getCurvePoint({keyBytes:e}),n={kty:"EC",crv:"secp256k1",x:q.uint8Array(r.x).toBase64Url(),y:q.uint8Array(r.y).toBase64Url()};return n.kid=await G({jwk:n}),n}static async compressPublicKey({publicKeyBytes:e}){return Ce.ProjectivePoint.fromHex(e).toRawBytes(!0)}static async computePublicKey({key:e}){let r=await t.privateKeyToBytes({privateKey:e}),n=await t.getCurvePoint({keyBytes:r}),i={kty:"EC",crv:"secp256k1",x:q.uint8Array(n.x).toBase64Url(),y:q.uint8Array(n.y).toBase64Url()};return i.kid=await G({jwk:i}),i}static async convertDerToCompactSignature({derSignature:e}){return Ce.Signature.fromDER(e).toCompactRawBytes()}static async decompressPublicKey({publicKeyBytes:e}){return Ce.ProjectivePoint.fromHex(e).toRawBytes(!1)}static async generateKey(){let e=Ce.utils.randomPrivateKey(),r=await t.bytesToPrivateKey({privateKeyBytes:e});return r.kid=await G({jwk:r}),r}static async getPublicKey({key:e}){if(!(Et(e)&&e.crv==="secp256k1"))throw new Error("Secp256k1: The provided key is not a secp256k1 private JWK.");let{d:r,...n}=e;return n.kid??=await G({jwk:n}),n}static async privateKeyToBytes({privateKey:e}){if(!Et(e))throw new Error("Secp256k1: The provided key is not a valid EC private key.");return q.base64Url(e.d).toUint8Array()}static async publicKeyToBytes({publicKey:e}){if(!(jn(e)&&e.y))throw new Error("Secp256k1: The provided key is not a valid EC public key.");let r=new Uint8Array([4]),n=q.base64Url(e.x).toUint8Array(),i=q.base64Url(e.y).toUint8Array();return new Uint8Array([...r,...n,...i])}static async sharedSecret({privateKeyA:e,publicKeyB:r}){if("x"in e&&"x"in r&&e.x===r.x)throw new Error("Secp256k1: ECDH shared secret cannot be computed from a single key pair's public and private keys.");let n=await t.privateKeyToBytes({privateKey:e}),i=await t.publicKeyToBytes({publicKey:r});return Ce.getSharedSecret(n,i,!0).slice(1)}static async sign({data:e,key:r}){let n=await t.privateKeyToBytes({privateKey:r}),i=xt(e);return Ce.sign(i,n).toCompactRawBytes()}static async validatePrivateKey({privateKeyBytes:e}){return Ce.utils.isValidPrivateKey(e)}static async validatePublicKey({publicKeyBytes:e}){try{Ce.ProjectivePoint.fromHex(e).assertValidity()}catch{return!1}return!0}static async verify({key:e,signature:r,data:n}){let i=await t.publicKeyToBytes({publicKey:e}),o=xt(n);return Ce.verify(r,o,i,{lowS:!1})}static async getCurvePoint({keyBytes:e}){e.byteLength===32&&(e=Ce.getPublicKey(e));let r=Ce.ProjectivePoint.fromHex(e),n=Ue(r.x,32),i=Ue(r.y,32);return{x:n,y:i}}};var my=qn(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),L2=my.create(BigInt("-3")),O2=BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),K2=ys({a:L2,b:O2,Fp:my,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},fs),Ne=K2;var pr=class t{static async adjustSignatureToLowS({signature:e}){let r=Ne.Signature.fromCompact(e);return r.hasHighS()?r.normalizeS().toCompactRawBytes():e}static async bytesToPrivateKey({privateKeyBytes:e}){let r=await t.getCurvePoint({keyBytes:e}),n={kty:"EC",crv:"P-256",d:q.uint8Array(e).toBase64Url(),x:q.uint8Array(r.x).toBase64Url(),y:q.uint8Array(r.y).toBase64Url()};return n.kid=await G({jwk:n}),n}static async bytesToPublicKey({publicKeyBytes:e}){let r=await t.getCurvePoint({keyBytes:e}),n={kty:"EC",crv:"P-256",x:q.uint8Array(r.x).toBase64Url(),y:q.uint8Array(r.y).toBase64Url()};return n.kid=await G({jwk:n}),n}static async compressPublicKey({publicKeyBytes:e}){return Ne.ProjectivePoint.fromHex(e).toRawBytes(!0)}static async computePublicKey({key:e}){let r=await t.privateKeyToBytes({privateKey:e}),n=await t.getCurvePoint({keyBytes:r}),i={kty:"EC",crv:"P-256",x:q.uint8Array(n.x).toBase64Url(),y:q.uint8Array(n.y).toBase64Url()};return i.kid=await G({jwk:i}),i}static async convertDerToCompactSignature({derSignature:e}){return Ne.Signature.fromDER(e).toCompactRawBytes()}static async decompressPublicKey({publicKeyBytes:e}){return Ne.ProjectivePoint.fromHex(e).toRawBytes(!1)}static async generateKey(){let e=Ne.utils.randomPrivateKey(),r=await t.bytesToPrivateKey({privateKeyBytes:e});return r.kid=await G({jwk:r}),r}static async getPublicKey({key:e}){if(!(Et(e)&&e.crv==="P-256"))throw new Error("Secp256r1: The provided key is not a 'P-256' private JWK.");let{d:r,...n}=e;return n.kid??=await G({jwk:n}),n}static async privateKeyToBytes({privateKey:e}){if(!Et(e))throw new Error("Secp256r1: The provided key is not a valid EC private key.");return q.base64Url(e.d).toUint8Array()}static async publicKeyToBytes({publicKey:e}){if(!(jn(e)&&e.y))throw new Error("Secp256r1: The provided key is not a valid EC public key.");let r=new Uint8Array([4]),n=q.base64Url(e.x).toUint8Array(),i=q.base64Url(e.y).toUint8Array();return new Uint8Array([...r,...n,...i])}static async sharedSecret({privateKeyA:e,publicKeyB:r}){if("x"in e&&"x"in r&&e.x===r.x)throw new Error("Secp256r1: ECDH shared secret cannot be computed from a single key pair's public and private keys.");let n=await t.privateKeyToBytes({privateKey:e}),i=await t.publicKeyToBytes({publicKey:r});return Ne.getSharedSecret(n,i,!0).slice(1)}static async sign({data:e,key:r}){let n=await t.privateKeyToBytes({privateKey:r}),i=xt(e);return Ne.sign(i,n).toCompactRawBytes()}static async validatePrivateKey({privateKeyBytes:e}){return Ne.utils.isValidPrivateKey(e)}static async validatePublicKey({publicKeyBytes:e}){try{Ne.ProjectivePoint.fromHex(e).assertValidity()}catch{return!1}return!0}static async verify({key:e,signature:r,data:n}){let i=await t.publicKeyToBytes({publicKey:e}),o=xt(n);return Ne.verify(r,o,i,{lowS:!1})}static async getCurvePoint({keyBytes:e}){e.byteLength===32&&(e=Ne.getPublicKey(e));let r=Ne.ProjectivePoint.fromHex(e),n=Ue(r.x,32),i=Ue(r.y,32);return{x:n,y:i}}};var Oi=class extends He{async computePublicKey({key:e}){if(!Et(e))throw new TypeError("Invalid key provided. Must be an elliptic curve (EC) private key.");switch(e.crv){case"secp256k1":{let r=await hr.computePublicKey({key:e});return r.alg="ES256K",r}case"P-256":{let r=await pr.computePublicKey({key:e});return r.alg="ES256",r}default:throw new Error(`Unsupported curve: ${e.crv}`)}}async generateKey({algorithm:e}){switch(e){case"ES256K":case"secp256k1":{let r=await hr.generateKey();return r.alg="ES256K",r}case"ES256":case"secp256r1":{let r=await pr.generateKey();return r.alg="ES256",r}}}async getPublicKey({key:e}){if(!Et(e))throw new TypeError("Invalid key provided. Must be an elliptic curve (EC) private key.");switch(e.crv){case"secp256k1":{let r=await hr.getPublicKey({key:e});return r.alg="ES256K",r}case"P-256":{let r=await pr.getPublicKey({key:e});return r.alg="ES256",r}default:throw new Error(`Unsupported curve: ${e.crv}`)}}async sign({key:e,data:r}){if(!Et(e))throw new TypeError("Invalid key provided. Must be an elliptic curve (EC) private key.");switch(e.crv){case"secp256k1":return await hr.sign({key:e,data:r});case"P-256":return await pr.sign({key:e,data:r});default:throw new Error(`Unsupported curve: ${e.crv}`)}}async verify({key:e,signature:r,data:n}){if(!jn(e))throw new TypeError("Invalid key provided. Must be an elliptic curve (EC) public key.");switch(e.crv){case"secp256k1":return await hr.verify({key:e,signature:r,data:n});case"P-256":return await pr.verify({key:e,signature:r,data:n});default:throw new Error(`Unsupported curve: ${e.crv}`)}}};var ws=BigInt(4294967295),Bf=BigInt(32);function by(t,e=!1){return e?{h:Number(t&ws),l:Number(t>>Bf&ws)}:{h:Number(t>>Bf&ws)|0,l:Number(t&ws)|0}}function N2(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){let{h:o,l:s}=by(t[i],e);[r[i],n[i]]=[o,s]}return[r,n]}var D2=(t,e)=>BigInt(t>>>0)<<Bf|BigInt(e>>>0),M2=(t,e,r)=>t>>>r,q2=(t,e,r)=>t<<32-r|e>>>r,j2=(t,e,r)=>t>>>r|e<<32-r,F2=(t,e,r)=>t<<32-r|e>>>r,$2=(t,e,r)=>t<<64-r|e>>>r-32,V2=(t,e,r)=>t>>>r-32|e<<64-r,H2=(t,e)=>e,G2=(t,e)=>t,W2=(t,e,r)=>t<<r|e>>>32-r,J2=(t,e,r)=>e<<r|t>>>32-r,z2=(t,e,r)=>e<<r-32|t>>>64-r,Y2=(t,e,r)=>t<<r-32|e>>>64-r;function Z2(t,e,r,n){let i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}var X2=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),Q2=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,e_=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),t_=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0,r_=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0),n_=(t,e,r,n,i,o)=>e+r+n+i+o+(t/2**32|0)|0;var i_={fromBig:by,split:N2,toBig:D2,shrSH:M2,shrSL:q2,rotrSH:j2,rotrSL:F2,rotrBH:$2,rotrBL:V2,rotr32H:H2,rotr32L:G2,rotlSH:W2,rotlSL:J2,rotlBH:z2,rotlBL:Y2,add:Z2,add3L:X2,add3H:Q2,add4L:e_,add4H:t_,add5H:n_,add5L:r_},W=i_;var[o_,s_]=W.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(t=>BigInt(t))),yr=new Uint32Array(80),wr=new Uint32Array(80),Tf=class extends Mn{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:r,Bh:n,Bl:i,Ch:o,Cl:s,Dh:a,Dl:c,Eh:f,El:u,Fh:l,Fl:p,Gh:h,Gl:y,Hh:d,Hl:w}=this;return[e,r,n,i,o,s,a,c,f,u,l,p,h,y,d,w]}set(e,r,n,i,o,s,a,c,f,u,l,p,h,y,d,w){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=o|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=u|0,this.Fh=l|0,this.Fl=p|0,this.Gh=h|0,this.Gl=y|0,this.Hh=d|0,this.Hl=w|0}process(e,r){for(let g=0;g<16;g++,r+=4)yr[g]=e.getUint32(r),wr[g]=e.getUint32(r+=4);for(let g=16;g<80;g++){let _=yr[g-15]|0,E=wr[g-15]|0,B=W.rotrSH(_,E,1)^W.rotrSH(_,E,8)^W.shrSH(_,E,7),T=W.rotrSL(_,E,1)^W.rotrSL(_,E,8)^W.shrSL(_,E,7),k=yr[g-2]|0,R=wr[g-2]|0,C=W.rotrSH(k,R,19)^W.rotrBH(k,R,61)^W.shrSH(k,R,6),L=W.rotrSL(k,R,19)^W.rotrBL(k,R,61)^W.shrSL(k,R,6),j=W.add4L(T,L,wr[g-7],wr[g-16]),K=W.add4H(j,B,C,yr[g-7],yr[g-16]);yr[g]=K|0,wr[g]=j|0}let{Ah:n,Al:i,Bh:o,Bl:s,Ch:a,Cl:c,Dh:f,Dl:u,Eh:l,El:p,Fh:h,Fl:y,Gh:d,Gl:w,Hh:m,Hl:A}=this;for(let g=0;g<80;g++){let _=W.rotrSH(l,p,14)^W.rotrSH(l,p,18)^W.rotrBH(l,p,41),E=W.rotrSL(l,p,14)^W.rotrSL(l,p,18)^W.rotrBL(l,p,41),B=l&h^~l&d,T=p&y^~p&w,k=W.add5L(A,E,T,s_[g],wr[g]),R=W.add5H(k,m,_,B,o_[g],yr[g]),C=k|0,L=W.rotrSH(n,i,28)^W.rotrBH(n,i,34)^W.rotrBH(n,i,39),j=W.rotrSL(n,i,28)^W.rotrBL(n,i,34)^W.rotrBL(n,i,39),K=n&o^n&a^o&a,Y=i&s^i&c^s&c;m=d|0,A=w|0,d=h|0,w=y|0,h=l|0,y=p|0,{h:l,l:p}=W.add(f|0,u|0,R|0,C|0),f=a|0,u=c|0,a=o|0,c=s|0,o=n|0,s=i|0;let S=W.add3L(C,j,Y);n=W.add3H(S,R,L,K),i=S|0}({h:n,l:i}=W.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:o,l:s}=W.add(this.Bh|0,this.Bl|0,o|0,s|0),{h:a,l:c}=W.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:u}=W.add(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:p}=W.add(this.Eh|0,this.El|0,l|0,p|0),{h,l:y}=W.add(this.Fh|0,this.Fl|0,h|0,y|0),{h:d,l:w}=W.add(this.Gh|0,this.Gl|0,d|0,w|0),{h:m,l:A}=W.add(this.Hh|0,this.Hl|0,m|0,A|0),this.set(n,i,o,s,a,c,f,u,l,p,h,y,d,w,m,A)}roundClean(){yr.fill(0),wr.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 kf=cs(()=>new Tf);var it=BigInt(0),De=BigInt(1),ms=BigInt(2),a_=BigInt(8),c_={zip215:!0};function f_(t){let e=Li(t);return Ge(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function bs(t){let e=f_(t),{Fp:r,n,prehash:i,hash:o,randomBytes:s,nByteLength:a,h:c}=e,f=ms<<BigInt(a*8)-De,u=r.create,l=e.uvRatio||((v,b)=>{try{return{isValid:!0,value:r.sqrt(v*r.inv(b))}}catch{return{isValid:!1,value:it}}}),p=e.adjustScalarBytes||(v=>v),h=e.domain||((v,b,P)=>{if(b.length||P)throw new Error("Contexts/pre-hash are not supported");return v}),y=v=>typeof v=="bigint"&&it<v,d=(v,b)=>y(v)&&y(b)&&v<b,w=v=>v===it||d(v,f);function m(v,b){if(d(v,b))return v;throw new Error(`Expected valid scalar < ${b}, got ${typeof v} ${v}`)}function A(v){return v===it?v:m(v,n)}let g=new Map;function _(v){if(!(v instanceof E))throw new Error("ExtendedPoint expected")}class E{constructor(b,P,U,O){if(this.ex=b,this.ey=P,this.ez=U,this.et=O,!w(b))throw new Error("x required");if(!w(P))throw new Error("y required");if(!w(U))throw new Error("z required");if(!w(O))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(b){if(b instanceof E)throw new Error("extended point not allowed");let{x:P,y:U}=b||{};if(!w(P)||!w(U))throw new Error("invalid affine point");return new E(P,U,De,u(P*U))}static normalizeZ(b){let P=r.invertBatch(b.map(U=>U.ez));return b.map((U,O)=>U.toAffine(P[O])).map(E.fromAffine)}_setWindowSize(b){this._WINDOW_SIZE=b,g.delete(this)}assertValidity(){let{a:b,d:P}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:U,ey:O,ez:F,et:$}=this,Z=u(U*U),V=u(O*O),H=u(F*F),ne=u(H*H),te=u(Z*b),be=u(H*u(te+V)),ge=u(ne+u(P*u(Z*V)));if(be!==ge)throw new Error("bad point: equation left != right (1)");let de=u(U*O),_e=u(F*$);if(de!==_e)throw new Error("bad point: equation left != right (2)")}equals(b){_(b);let{ex:P,ey:U,ez:O}=this,{ex:F,ey:$,ez:Z}=b,V=u(P*Z),H=u(F*O),ne=u(U*Z),te=u($*O);return V===H&&ne===te}is0(){return this.equals(E.ZERO)}negate(){return new E(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:b}=e,{ex:P,ey:U,ez:O}=this,F=u(P*P),$=u(U*U),Z=u(ms*u(O*O)),V=u(b*F),H=P+U,ne=u(u(H*H)-F-$),te=V+$,be=te-Z,ge=V-$,de=u(ne*be),_e=u(te*ge),St=u(ne*ge),gr=u(be*te);return new E(de,_e,gr,St)}add(b){_(b);let{a:P,d:U}=e,{ex:O,ey:F,ez:$,et:Z}=this,{ex:V,ey:H,ez:ne,et:te}=b;if(P===BigInt(-1)){let $f=u((F-O)*(H+V)),Vf=u((F+O)*(H-V)),Ts=u(Vf-$f);if(Ts===it)return this.double();let Hf=u($*ms*te),Gf=u(Z*ms*ne),Wf=Gf+Hf,Jf=Vf+$f,zf=Gf-Hf,n0=u(Wf*Ts),i0=u(Jf*zf),o0=u(Wf*zf),s0=u(Ts*Jf);return new E(n0,i0,s0,o0)}let be=u(O*V),ge=u(F*H),de=u(Z*U*te),_e=u($*ne),St=u((O+F)*(V+H)-be-ge),gr=_e-de,Hn=_e+de,Ff=u(ge-P*be),Qy=u(St*gr),e0=u(Hn*Ff),t0=u(St*Ff),r0=u(gr*Hn);return new E(Qy,e0,r0,t0)}subtract(b){return this.add(b.negate())}wNAF(b){return k.wNAFCached(this,g,b,E.normalizeZ)}multiply(b){let{p:P,f:U}=this.wNAF(m(b,n));return E.normalizeZ([P,U])[0]}multiplyUnsafe(b){let P=A(b);return P===it?T:this.equals(T)||P===De?this:this.equals(B)?this.wNAF(P).p:k.unsafeLadder(this,P)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return k.unsafeLadder(this,n).is0()}toAffine(b){let{ex:P,ey:U,ez:O}=this,F=this.is0();b==null&&(b=F?a_:r.inv(O));let $=u(P*b),Z=u(U*b),V=u(O*b);if(F)return{x:it,y:De};if(V!==De)throw new Error("invZ was invalid");return{x:$,y:Z}}clearCofactor(){let{h:b}=e;return b===De?this:this.multiplyUnsafe(b)}static fromHex(b,P=!1){let{d:U,a:O}=e,F=r.BYTES;b=oe("pointHex",b,F);let $=b.slice(),Z=b[F-1];$[F-1]=Z&-129;let V=nt($);V===it||(P?m(V,f):m(V,r.ORDER));let H=u(V*V),ne=u(H-De),te=u(U*H-O),{isValid:be,value:ge}=l(ne,te);if(!be)throw new Error("Point.fromHex: invalid y coordinate");let de=(ge&De)===De,_e=(Z&128)!==0;if(!P&&ge===it&&_e)throw new Error("Point.fromHex: x=0 and x_0=1");return _e!==de&&(ge=u(-ge)),E.fromAffine({x:ge,y:V})}static fromPrivateKey(b){return L(b).point}toRawBytes(){let{x:b,y:P}=this.toAffine(),U=Vt(P,r.BYTES);return U[U.length-1]|=b&De?128:0,U}toHex(){return Ft(this.toRawBytes())}}E.BASE=new E(e.Gx,e.Gy,De,u(e.Gx*e.Gy)),E.ZERO=new E(it,De,De,it);let{BASE:B,ZERO:T}=E,k=hs(E,a*8);function R(v){return ee(v,n)}function C(v){return R(nt(v))}function L(v){let b=a;v=oe("private key",v,b);let P=oe("hashed private key",o(v),2*b),U=p(P.slice(0,b)),O=P.slice(b,2*b),F=C(U),$=B.multiply(F),Z=$.toRawBytes();return{head:U,prefix:O,scalar:F,point:$,pointBytes:Z}}function j(v){return L(v).pointBytes}function K(v=new Uint8Array,...b){let P=Ht(...b);return C(o(h(P,oe("context",v),!!i)))}function Y(v,b,P={}){v=oe("message",v),i&&(v=i(v));let{prefix:U,scalar:O,pointBytes:F}=L(b),$=K(P.context,U,v),Z=B.multiply($).toRawBytes(),V=K(P.context,Z,F,v),H=R($+V*O);A(H);let ne=Ht(Z,Vt(H,r.BYTES));return oe("result",ne,a*2)}let S=c_;function I(v,b,P,U=S){let{context:O,zip215:F}=U,$=r.BYTES;v=oe("signature",v,2*$),b=oe("message",b),i&&(b=i(b));let Z=nt(v.slice($,2*$)),V,H,ne;try{V=E.fromHex(P,F),H=E.fromHex(v.slice(0,$),F),ne=B.multiplyUnsafe(Z)}catch{return!1}if(!F&&V.isSmallOrder())return!1;let te=K(O,H.toRawBytes(),V.toRawBytes(),b);return H.add(V.multiplyUnsafe(te)).subtract(ne).clearCofactor().equals(E.ZERO)}return B._setWindowSize(8),{CURVE:e,getPublicKey:j,sign:Y,verify:I,ExtendedPoint:E,utils:{getExtendedPublicKey:L,randomPrivateKey:()=>s(r.BYTES),precompute(v=8,b=E.BASE){return b._setWindowSize(v),b.multiply(BigInt(3)),b}}}}var Ki=BigInt(0),Pf=BigInt(1);function u_(t){return Ge(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function gy(t){let e=u_(t),{P:r}=e,n=g=>ee(g,r),i=e.montgomeryBits,o=Math.ceil(i/8),s=e.nByteLength,a=e.adjustScalarBytes||(g=>g),c=e.powPminus2||(g=>mf(g,r-BigInt(2),r));function f(g,_,E){let B=n(g*(_-E));return _=n(_-B),E=n(E+B),[_,E]}function u(g){if(typeof g=="bigint"&&Ki<=g&&g<r)return g;throw new Error("Expected valid scalar 0 < scalar < CURVE.P")}let l=(e.a-BigInt(2))/BigInt(4);function p(g,_){let E=u(g),B=u(_),T=E,k=Pf,R=Ki,C=E,L=Pf,j=Ki,K;for(let S=BigInt(i-1);S>=Ki;S--){let I=B>>S&Pf;j^=I,K=f(j,k,C),k=K[0],C=K[1],K=f(j,R,L),R=K[0],L=K[1],j=I;let N=k+R,v=n(N*N),b=k-R,P=n(b*b),U=v-P,O=C+L,F=C-L,$=n(F*N),Z=n(O*b),V=$+Z,H=$-Z;C=n(V*V),L=n(T*n(H*H)),k=n(v*P),R=n(U*(v+n(l*U)))}K=f(j,k,C),k=K[0],C=K[1],K=f(j,R,L),R=K[0],L=K[1];let Y=c(R);return n(k*Y)}function h(g){return Vt(n(g),o)}function y(g){let _=oe("u coordinate",g,o);return s===32&&(_[31]&=127),nt(_)}function d(g){let _=oe("scalar",g),E=_.length;if(E!==o&&E!==s)throw new Error(`Expected ${o} or ${s} bytes, got ${E}`);return nt(a(_))}function w(g,_){let E=y(_),B=d(g),T=p(E,B);if(T===Ki)throw new Error("Invalid private or public key received");return h(T)}let m=h(e.Gu);function A(g){return w(g,m)}return{scalarMult:w,scalarMultBase:A,getSharedSecret:(g,_)=>w(g,_),getPublicKey:g=>A(g),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:m}}var Ni=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),xy=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),F8=BigInt(0),l_=BigInt(1),If=BigInt(2),d_=BigInt(5),Ey=BigInt(10),h_=BigInt(20),p_=BigInt(40),_y=BigInt(80);function Ay(t){let e=Ni,n=t*t%e*t%e,i=se(n,If,e)*n%e,o=se(i,l_,e)*t%e,s=se(o,d_,e)*o%e,a=se(s,Ey,e)*s%e,c=se(a,h_,e)*a%e,f=se(c,p_,e)*c%e,u=se(f,_y,e)*f%e,l=se(u,_y,e)*f%e,p=se(l,Ey,e)*s%e;return{pow_p_5_8:se(p,If,e)*t%e,b2:n}}function Sy(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function y_(t,e){let r=Ni,n=ee(e*e*e,r),i=ee(n*n*e,r),o=Ay(t*i).pow_p_5_8,s=ee(t*n*o,r),a=ee(e*s*s,r),c=s,f=ee(s*xy,r),u=a===t,l=a===ee(-t,r),p=a===ee(-t*xy,r);return u&&(s=c),(l||p)&&(s=f),sy(s,r)&&(s=ee(-s,r)),{isValid:u||l,value:s}}var Je=qn(Ni,void 0,!0),Di={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Je,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:kf,randomBytes:Ui,adjustScalarBytes:Sy,uvRatio:y_},mr=bs(Di);function vy(t,e,r){if(e.length>255)throw new Error("Context is too big");return as(lf("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,e.length]),e,t)}var $8=bs({...Di,domain:vy}),V8=bs({...Di,domain:vy,prehash:kf}),tn=gy({P:Ni,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{let e=Ni,{pow_p_5_8:r,b2:n}=Ay(t);return ee(se(r,BigInt(3),e)*n,e)},adjustScalarBytes:Sy,randomBytes:Ui});function By(t){let{y:e}=mr.ExtendedPoint.fromHex(t),r=BigInt(1);return Je.toBytes(Je.create((r+e)*Je.inv(r-e)))}function Ty(t){let e=Di.hash(t.subarray(0,32));return Di.adjustScalarBytes(e).subarray(0,32)}var w_=(Je.ORDER+BigInt(3))/BigInt(8),H8=Je.pow(If,w_),G8=Je.sqrt(Je.neg(Je.ONE)),W8=(Je.ORDER-BigInt(5))/BigInt(8),J8=BigInt(486662);var z8=ay(Je,Je.neg(BigInt(486664)));var Y8=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),Z8=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),X8=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),Q8=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");var eB=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var br=class t{static async bytesToPrivateKey({privateKeyBytes:e}){let r=mr.getPublicKey(e),n={crv:"Ed25519",d:q.uint8Array(e).toBase64Url(),kty:"OKP",x:q.uint8Array(r).toBase64Url()};return n.kid=await G({jwk:n}),n}static async bytesToPublicKey({publicKeyBytes:e}){let r={kty:"OKP",crv:"Ed25519",x:q.uint8Array(e).toBase64Url()};return r.kid=await G({jwk:r}),r}static async computePublicKey({key:e}){let r=await t.privateKeyToBytes({privateKey:e}),n=mr.getPublicKey(r),i={kty:"OKP",crv:"Ed25519",x:q.uint8Array(n).toBase64Url()};return i.kid=await G({jwk:i}),i}static async convertPrivateKeyToX25519({privateKey:e}){let r=await t.privateKeyToBytes({privateKey:e}),n=Ty(r),i=tn.getPublicKey(n),o={kty:"OKP",crv:"X25519",d:q.uint8Array(n).toBase64Url(),x:q.uint8Array(i).toBase64Url()};return o.kid=await G({jwk:o}),o}static async convertPublicKeyToX25519({publicKey:e}){let r=await t.publicKeyToBytes({publicKey:e});if(!await t.validatePublicKey({publicKeyBytes:r}))throw new Error("Ed25519: Invalid public key.");let i=By(r),o={kty:"OKP",crv:"X25519",x:q.uint8Array(i).toBase64Url()};return o.kid=await G({jwk:o}),o}static async generateKey(){let e=mr.utils.randomPrivateKey(),r=await t.bytesToPrivateKey({privateKeyBytes:e});return r.kid=await G({jwk:r}),r}static async getPublicKey({key:e}){if(!(_t(e)&&e.crv==="Ed25519"))throw new Error("Ed25519: The provided key is not an Ed25519 private JWK.");let{d:r,...n}=e;return n.kid??=await G({jwk:n}),n}static async privateKeyToBytes({privateKey:e}){if(!_t(e))throw new Error("Ed25519: The provided key is not a valid OKP private key.");return q.base64Url(e.d).toUint8Array()}static async publicKeyToBytes({publicKey:e}){if(!Fn(e))throw new Error("Ed25519: The provided key is not a valid OKP public key.");return q.base64Url(e.x).toUint8Array()}static async sign({key:e,data:r}){let n=await t.privateKeyToBytes({privateKey:e});return mr.sign(r,n)}static async validatePublicKey({publicKeyBytes:e}){try{mr.ExtendedPoint.fromHex(e).assertValidity()}catch{return!1}return!0}static async verify({key:e,signature:r,data:n}){let i=await t.publicKeyToBytes({publicKey:e});return mr.verify(r,n,i)}};var gs=class extends He{async computePublicKey({key:e}){if(!_t(e))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) private key.");switch(e.crv){case"Ed25519":{let r=await br.computePublicKey({key:e});return r.alg="EdDSA",r}default:throw new Error(`Unsupported curve: ${e.crv}`)}}async generateKey({algorithm:e}){switch(e){case"Ed25519":{let r=await br.generateKey();return r.alg="EdDSA",r}}}async getPublicKey({key:e}){if(!_t(e))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) private key.");switch(e.crv){case"Ed25519":{let r=await br.getPublicKey({key:e});return r.alg="EdDSA",r}default:throw new Error(`Unsupported curve: ${e.crv}`)}}async sign({key:e,data:r}){if(!_t(e))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) private key.");switch(e.crv){case"Ed25519":return await br.sign({key:e,data:r});default:throw new Error(`Unsupported curve: ${e.crv}`)}}async verify({key:e,signature:r,data:n}){if(!Fn(e))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) public key.");switch(e.crv){case"Ed25519":return await br.verify({key:e,signature:r,data:n});default:throw new Error(`Unsupported curve: ${e.crv}`)}}};var Rf={Ed25519:{implementation:gs,names:["Ed25519"]},secp256k1:{implementation:Oi,names:["ES256K","secp256k1"]},secp256r1:{implementation:Oi,names:["ES256","secp256r1"]},"SHA-256":{implementation:is,names:["SHA-256"]}},ky=class{constructor(e){this._algorithmInstances=new Map;this._keyStore=e?.keyStore??new Eo}async digest({algorithm:e,data:r}){return await this.getAlgorithm({algorithm:e}).digest({algorithm:e,data:r})}async exportKey({keyUri:e}){return await this.getPrivateKey({keyUri:e})}async generateKey({algorithm:e}){let n=await this.getAlgorithm({algorithm:e}).generateKey({algorithm:e});if(n?.kid===void 0)throw new Error("Generated key is missing a required property: kid");let i=`${vf}${n.kid}`;return await this._keyStore.set(i,n),i}async getKeyUri({key:e}){let r=await G({jwk:e});return`${vf}${r}`}async getPublicKey({keyUri:e}){let r=await this.getPrivateKey({keyUri:e}),n=this.getAlgorithmName({key:r});return await this.getAlgorithm({algorithm:n}).getPublicKey({key:r})}async importKey({key:e}){if(!wy(e))throw new TypeError("Invalid key provided. Must be a private key in JWK format.");let r=structuredClone(e);r.kid??=await G({jwk:r});let n=await this.getKeyUri({key:r});return await this._keyStore.set(n,r),n}async sign({keyUri:e,data:r}){let n=await this.getPrivateKey({keyUri:e}),i=this.getAlgorithmName({key:n});return this.getAlgorithm({algorithm:i}).sign({data:r,key:n})}async verify({key:e,signature:r,data:n}){let i=this.getAlgorithmName({key:e});return this.getAlgorithm({algorithm:i}).verify({key:e,signature:r,data:n})}getAlgorithm({algorithm:e}){let r=Rf[e]?.implementation;if(!r)throw new Error(`Algorithm not supported: ${e}`);return this._algorithmInstances.has(r)||this._algorithmInstances.set(r,new r),this._algorithmInstances.get(r)}getAlgorithmName({key:e}){let r=e.alg,n=e.crv;for(let i in Rf){let o=Rf[i];if(r&&o.names.includes(r))return i;if(n&&o.names.includes(n))return i}throw new Error(`Unable to determine algorithm based on provided input: alg=${r}, crv=${n}`)}async getPrivateKey({keyUri:e}){let r=await this._keyStore.get(e);if(!r)throw new Error(`Key not found: ${e}`);return r}};var Py=class t{static getJoseSignatureAlgorithmFromPublicKey(e){let r={Ed25519:"EdDSA","P-256":"ES256","P-384":"ES384","P-521":"ES512",secp256k1:"ES256K"};if(e.alg&&Object.values(r).includes(e.alg))return e.alg;if(e.crv&&Object.keys(r).includes(e.crv))return r[e.crv];throw new Error(`Unable to determine algorithm based on provided input: alg=${e.alg}, crv=${e.crv}. Supported 'alg' values: ${Object.values(r).join(", ")}. Supported 'crv' values: ${Object.keys(r).join(", ")}.`)}static randomBytes(e){return Wp(e)}static randomUuid(){return qt.randomUUID()}static randomPin({length:e}){if(3>e||e>10)throw new Error("randomPin() can securely generate a PIN between 3 to 10 digits.");let r=Math.pow(10,e)-1,n;if(e<=6){let i=Math.pow(10,e);do{let o=t.randomBytes(Math.ceil(e/2));n=new DataView(o.buffer).getUint16(0,!1)%i}while(n>r)}else{let i=Math.pow(10,10);do{let o=t.randomBytes(4);n=new DataView(o.buffer).getUint32(0,!1)%i}while(n>r)}return n.toString().padStart(e,"0")}};var xs=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function ke(){if(xs&&typeof xs.subtle=="object"&&xs.subtle!=null)return xs.subtle;throw new Error("crypto.subtle must be defined")}var Mi=128,Iy=[128,192,256],Es=Mi,$n=class{static async bytesToPrivateKey({privateKeyBytes:e}){let r={k:q.uint8Array(e).toBase64Url(),kty:"oct"};return r.kid=await G({jwk:r}),r}static async decrypt({key:e,data:r,counter:n,length:i}){if(n.byteLength!==Mi/8)throw new TypeError(`The counter must be ${Mi} bits in length`);if(i===0||i>Es)throw new TypeError(`The 'length' property must be in the range 1 to ${Es}`);let o=ke(),s=await o.importKey("jwk",e,{name:"AES-CTR"},!0,["decrypt"]),a=await o.decrypt({name:"AES-CTR",counter:n,length:i},s,r);return new Uint8Array(a)}static async encrypt({key:e,data:r,counter:n,length:i}){if(n.byteLength!==Mi/8)throw new TypeError(`The counter must be ${Mi} bits in length`);if(i===0||i>Es)throw new TypeError(`The 'length' property must be in the range 1 to ${Es}`);let o=ke(),s=await o.importKey("jwk",e,{name:"AES-CTR"},!0,["encrypt","decrypt"]),a=await o.encrypt({name:"AES-CTR",counter:n,length:i},s,r);return new Uint8Array(a)}static async generateKey({length:e}){if(!Iy.includes(e))throw new RangeError(`The key length is invalid: Must be ${Iy.join(", ")} bits`);let r=ke(),n=await r.generateKey({name:"AES-CTR",length:e},!0,["encrypt"]),{ext:i,key_ops:o,...s}=await r.exportKey("jwk",n);return s.kid=await G({jwk:s}),s}static async privateKeyToBytes({privateKey:e}){if(!dr(e))throw new Error("AesCtr: The provided key is not a valid oct private key.");return q.base64Url(e.k).toUint8Array()}};var Ry=class extends He{async decrypt(e){return $n.decrypt(e)}async encrypt(e){return $n.encrypt(e)}async generateKey({algorithm:e}){let r={A128CTR:128,A192CTR:192,A256CTR:256}[e],n=await $n.generateKey({length:r});return n.alg=e,n}};function qi(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function Uf(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}function Cf(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function we(t,...e){if(!Cf(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function Lf(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Uy(t,e){we(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var Wt=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),Cy=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),m_=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!m_)throw new Error("Non little-endian hardware is not supported");function b_(t){if(typeof t!="string")throw new Error(`string expected, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function _s(t){if(typeof t=="string")t=b_(t);else if(Cf(t))t=t.slice();else throw new Error(`Uint8Array expected, got ${typeof t}`);return t}function Ly(t,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(t,e)}function Oy(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return r===0}var Of=(t,e)=>(Object.assign(e,t),e);function Kf(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),c=n?4:0,f=n?0:4;t.setUint32(e+c,s,n),t.setUint32(e+f,a,n)}var Ky={async encrypt(t,e,r,n){let i=ke(),o=await i.importKey("raw",t,e,!0,["encrypt"]),s=await i.encrypt(r,o,n);return new Uint8Array(s)},async decrypt(t,e,r,n){let i=ke(),o=await i.importKey("raw",t,e,!0,["decrypt"]),s=await i.decrypt(r,o,n);return new Uint8Array(s)}},At={CBC:"AES-CBC",CTR:"AES-CTR",GCM:"AES-GCM"};function g_(t,e,r){if(t===At.CBC)return{name:At.CBC,iv:e};if(t===At.CTR)return{name:At.CTR,counter:e,length:64};if(t===At.GCM)return r?{name:At.GCM,iv:e,additionalData:r}:{name:At.GCM,iv:e};throw new Error("unknown aes block mode")}function Nf(t){return(e,r,n)=>{we(e),we(r);let i={name:t,length:e.length*8},o=g_(t,r,n);return{encrypt(s){return we(s),Ky.encrypt(e,i,o,s)},decrypt(s){return we(s),Ky.decrypt(e,i,o,s)}}}}var LB=Nf(At.CBC),OB=Nf(At.CTR),KB=Nf(At.GCM);var As=96,Ny=[128,192,256],Ss=[96,104,112,120,128],Vn=class{static async bytesToPrivateKey({privateKeyBytes:e}){let r={k:q.uint8Array(e).toBase64Url(),kty:"oct"};return r.kid=await G({jwk:r}),r}static async decrypt({key:e,data:r,iv:n,additionalData:i,tagLength:o}){if(n.byteLength!==As/8)throw new TypeError(`The initialization vector must be ${As} bits in length`);if(o&&!Ss.includes(o))throw new RangeError(`The tag length is invalid: Must be ${Ss.join(", ")} bits`);let s=ke(),a=await s.importKey("jwk",e,{name:"AES-GCM"},!0,["decrypt"]),c={name:"AES-GCM",iv:n,...o&&{tagLength:o},...i&&{additionalData:i}},f=await s.decrypt(c,a,r);return new Uint8Array(f)}static async encrypt({data:e,iv:r,key:n,additionalData:i,tagLength:o}){if(r.byteLength!==As/8)throw new TypeError(`The initialization vector must be ${As} bits in length`);if(o&&!Ss.includes(o))throw new RangeError(`The tag length is invalid: Must be ${Ss.join(", ")} bits`);let s=ke(),a=await s.importKey("jwk",n,{name:"AES-GCM"},!0,["encrypt"]),c={name:"AES-GCM",iv:r,...o&&{tagLength:o},...i&&{additionalData:i}},f=await s.encrypt(c,a,e);return new Uint8Array(f)}static async generateKey({length:e}){if(!Ny.includes(e))throw new RangeError(`The key length is invalid: Must be ${Ny.join(", ")} bits`);let r=ke(),n=await r.generateKey({name:"AES-GCM",length:e},!0,["encrypt"]),{ext:i,key_ops:o,...s}=await r.exportKey("jwk",n);return s.kid=await G({jwk:s}),s}static async privateKeyToBytes({privateKey:e}){if(!dr(e))throw new Error("AesGcm: The provided key is not a valid oct private key.");return q.base64Url(e.k).toUint8Array()}};var Dy=class extends He{async decrypt(e){return Vn.decrypt(e)}async encrypt(e){return Vn.encrypt(e)}async generateKey({algorithm:e}){let r={A128GCM:128,A192GCM:192,A256GCM:256}[e],n=await Vn.generateKey({length:r});return n.alg=e,n}};var My=class t{static async deriveKey({keyDataLen:e,fixedInfo:r,sharedSecret:n}){let o=Math.ceil(e/256);if(o!==1)throw new Error(`Concat KDF with ${o} rounds not supported.`);let s=new Uint8Array(4);new DataView(s.buffer).setUint32(0,o);let a=t.computeFixedInfo(r);return xt(cf(s,n,a)).slice(0,e/8)}static computeFixedInfo(e){let r=t.toDataLenData({data:e.algorithmId}),n=t.toDataLenData({data:e.partyUInfo}),i=t.toDataLenData({data:e.partyVInfo}),o=t.toDataLenData({data:e.suppPubInfo,variableLength:!1}),s=t.toDataLenData({data:e.suppPrivInfo});return cf(r,n,i,o,s)}static toDataLenData({data:e,variableLength:r=!0}){let n,i=Wn(e);if(i==="Undefined")return new Uint8Array(0);if(r){let o=i==="Uint8Array"?e:new q(e,i).toUint8Array(),s=o.length;n=new Uint8Array(4+s),new DataView(n.buffer).setUint32(0,s),n.set(o,4)}else{if(typeof e!="number")throw TypeError("Fixed length input must be a number.");n=new Uint8Array(4),new DataView(n.buffer).setUint32(0,e)}return n}};var qy=class{static async deriveKey({hash:e,password:r,salt:n,iterations:i,length:o}){let s=await qt.subtle.importKey("raw",r,{name:"PBKDF2"},!1,["deriveBits"]),a=await qt.subtle.deriveBits({name:"PBKDF2",hash:e,salt:n,iterations:i},s,o);return new Uint8Array(a)}};var jy=class t{static async bytesToPrivateKey({privateKeyBytes:e}){let r=tn.getPublicKey(e),n={kty:"OKP",crv:"X25519",d:q.uint8Array(e).toBase64Url(),x:q.uint8Array(r).toBase64Url()};return n.kid=await G({jwk:n}),n}static async bytesToPublicKey({publicKeyBytes:e}){let r={kty:"OKP",crv:"X25519",x:q.uint8Array(e).toBase64Url()};return r.kid=await G({jwk:r}),r}static async computePublicKey({key:e}){let r=await t.privateKeyToBytes({privateKey:e}),n=tn.getPublicKey(r),i={kty:"OKP",crv:"X25519",x:q.uint8Array(n).toBase64Url()};return i.kid=await G({jwk:i}),i}static async generateKey(){let e=tn.utils.randomPrivateKey(),r=await t.bytesToPrivateKey({privateKeyBytes:e});return r.kid=await G({jwk:r}),r}static async getPublicKey({key:e}){if(!(_t(e)&&e.crv==="X25519"))throw new Error("X25519: The provided key is not an X25519 private JWK.");let{d:r,...n}=e;return n.kid??=await G({jwk:n}),n}static async privateKeyToBytes({privateKey:e}){if(!_t(e))throw new Error("X25519: The provided key is not a valid OKP private key.");return q.base64Url(e.d).toUint8Array()}static async publicKeyToBytes({publicKey:e}){if(!Fn(e))throw new Error("X25519: The provided key is not a valid OKP public key.");return q.base64Url(e.x).toUint8Array()}static async sharedSecret({privateKeyA:e,publicKeyB:r}){if("x"in e&&"x"in r&&e.x===r.x)throw new Error("X25519: ECDH shared secret cannot be computed from a single key pair's public and private keys.");let n=await t.privateKeyToBytes({privateKey:e}),i=await t.publicKeyToBytes({publicKey:r});return tn.getSharedSecret(n,i)}};var Ee=(t,e)=>t[e++]&255|(t[e++]&255)<<8,Df=class{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,e=_s(e),we(e,32);let r=Ee(e,0),n=Ee(e,2),i=Ee(e,4),o=Ee(e,6),s=Ee(e,8),a=Ee(e,10),c=Ee(e,12),f=Ee(e,14);this.r[0]=r&8191,this.r[1]=(r>>>13|n<<3)&8191,this.r[2]=(n>>>10|i<<6)&7939,this.r[3]=(i>>>7|o<<9)&8191,this.r[4]=(o>>>4|s<<12)&255,this.r[5]=s>>>1&8190,this.r[6]=(s>>>14|a<<2)&8191,this.r[7]=(a>>>11|c<<5)&8065,this.r[8]=(c>>>8|f<<8)&8191,this.r[9]=f>>>5&127;for(let u=0;u<8;u++)this.pad[u]=Ee(e,16+2*u)}process(e,r,n=!1){let i=n?0:2048,{h:o,r:s}=this,a=s[0],c=s[1],f=s[2],u=s[3],l=s[4],p=s[5],h=s[6],y=s[7],d=s[8],w=s[9],m=Ee(e,r+0),A=Ee(e,r+2),g=Ee(e,r+4),_=Ee(e,r+6),E=Ee(e,r+8),B=Ee(e,r+10),T=Ee(e,r+12),k=Ee(e,r+14),R=o[0]+(m&8191),C=o[1]+((m>>>13|A<<3)&8191),L=o[2]+((A>>>10|g<<6)&8191),j=o[3]+((g>>>7|_<<9)&8191),K=o[4]+((_>>>4|E<<12)&8191),Y=o[5]+(E>>>1&8191),S=o[6]+((E>>>14|B<<2)&8191),I=o[7]+((B>>>11|T<<5)&8191),N=o[8]+((T>>>8|k<<8)&8191),v=o[9]+(k>>>5|i),b=0,P=b+R*a+C*(5*w)+L*(5*d)+j*(5*y)+K*(5*h);b=P>>>13,P&=8191,P+=Y*(5*p)+S*(5*l)+I*(5*u)+N*(5*f)+v*(5*c),b+=P>>>13,P&=8191;let U=b+R*c+C*a+L*(5*w)+j*(5*d)+K*(5*y);b=U>>>13,U&=8191,U+=Y*(5*h)+S*(5*p)+I*(5*l)+N*(5*u)+v*(5*f),b+=U>>>13,U&=8191;let O=b+R*f+C*c+L*a+j*(5*w)+K*(5*d);b=O>>>13,O&=8191,O+=Y*(5*y)+S*(5*h)+I*(5*p)+N*(5*l)+v*(5*u),b+=O>>>13,O&=8191;let F=b+R*u+C*f+L*c+j*a+K*(5*w);b=F>>>13,F&=8191,F+=Y*(5*d)+S*(5*y)+I*(5*h)+N*(5*p)+v*(5*l),b+=F>>>13,F&=8191;let $=b+R*l+C*u+L*f+j*c+K*a;b=$>>>13,$&=8191,$+=Y*(5*w)+S*(5*d)+I*(5*y)+N*(5*h)+v*(5*p),b+=$>>>13,$&=8191;let Z=b+R*p+C*l+L*u+j*f+K*c;b=Z>>>13,Z&=8191,Z+=Y*a+S*(5*w)+I*(5*d)+N*(5*y)+v*(5*h),b+=Z>>>13,Z&=8191;let V=b+R*h+C*p+L*l+j*u+K*f;b=V>>>13,V&=8191,V+=Y*c+S*a+I*(5*w)+N*(5*d)+v*(5*y),b+=V>>>13,V&=8191;let H=b+R*y+C*h+L*p+j*l+K*u;b=H>>>13,H&=8191,H+=Y*f+S*c+I*a+N*(5*w)+v*(5*d),b+=H>>>13,H&=8191;let ne=b+R*d+C*y+L*h+j*p+K*l;b=ne>>>13,ne&=8191,ne+=Y*u+S*f+I*c+N*a+v*(5*w),b+=ne>>>13,ne&=8191;let te=b+R*w+C*d+L*y+j*h+K*p;b=te>>>13,te&=8191,te+=Y*l+S*u+I*f+N*c+v*a,b+=te>>>13,te&=8191,b=(b<<2)+b|0,b=b+P|0,P=b&8191,b=b>>>13,U+=b,o[0]=P,o[1]=U,o[2]=O,o[3]=F,o[4]=$,o[5]=Z,o[6]=V,o[7]=H,o[8]=ne,o[9]=te}finalize(){let{h:e,pad:r}=this,n=new Uint16Array(10),i=e[1]>>>13;e[1]&=8191;for(let a=2;a<10;a++)e[a]+=i,i=e[a]>>>13,e[a]&=8191;e[0]+=i*5,i=e[0]>>>13,e[0]&=8191,e[1]+=i,i=e[1]>>>13,e[1]&=8191,e[2]+=i,n[0]=e[0]+5,i=n[0]>>>13,n[0]&=8191;for(let a=1;a<10;a++)n[a]=e[a]+i,i=n[a]>>>13,n[a]&=8191;n[9]-=8192;let o=(i^1)-1;for(let a=0;a<10;a++)n[a]&=o;o=~o;for(let a=0;a<10;a++)e[a]=e[a]&o|n[a];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let s=e[0]+r[0];e[0]=s&65535;for(let a=1;a<8;a++)s=(e[a]+r[a]|0)+(s>>>16)|0,e[a]=s&65535}update(e){Lf(this);let{buffer:r,blockLen:n}=this;e=_s(e);let i=e.length;for(let o=0;o<i;){let s=Math.min(n-this.pos,i-o);if(s===n){for(;n<=i-o;o+=n)this.process(e,o);continue}r.set(e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===n&&(this.process(r,0,!1),this.pos=0)}return this}destroy(){this.h.fill(0),this.r.fill(0),this.buffer.fill(0),this.pad.fill(0)}digestInto(e){Lf(this),Uy(e,this),this.finished=!0;let{buffer:r,h:n}=this,{pos:i}=this;if(i){for(r[i++]=1;i<16;i++)r[i]=0;this.process(r,0,!0)}this.finalize();let o=0;for(let s=0;s<8;s++)e[o++]=n[s]>>>0,e[o++]=n[s]>>>8;return e}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}};function x_(t){let e=(n,i)=>t(i).update(_s(n)).digest(),r=t(new Uint8Array(32));return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}var Fy=x_(t=>new Df(t));var Vy=t=>Uint8Array.from(t.split("").map(e=>e.charCodeAt(0))),E_=Vy("expand 16-byte k"),__=Vy("expand 32-byte k"),A_=Wt(E_),Hy=Wt(__),cT=Hy.slice();function D(t,e){return t<<e|t>>>32-e}function Mf(t){return t.byteOffset%4===0}var vs=64,S_=16,Gy=2**32-1,$y=new Uint32Array;function v_(t,e,r,n,i,o,s,a){let c=i.length,f=new Uint8Array(vs),u=Wt(f),l=Mf(i)&&Mf(o),p=l?Wt(i):$y,h=l?Wt(o):$y;for(let y=0;y<c;s++){if(t(e,r,n,u,s,a),s>=Gy)throw new Error("arx: counter overflow");let d=Math.min(vs,c-y);if(l&&d===vs){let w=y/4;if(y%4!==0)throw new Error("arx: invalid block position");for(let m=0,A;m<S_;m++)A=w+m,h[A]=p[A]^u[m];y+=vs;continue}for(let w=0,m;w<d;w++)m=y+w,o[m]=i[m]^f[w];y+=d}}function qf(t,e){let{allowShortKeys:r,extendNonceFn:n,counterLength:i,counterRight:o,rounds:s}=Ly({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof t!="function")throw new Error("core must be a function");return qi(i),qi(s),Uf(o),Uf(r),(a,c,f,u,l=0)=>{we(a),we(c),we(f);let p=f.length;if(u||(u=new Uint8Array(p)),we(u),qi(l),l<0||l>=Gy)throw new Error("arx: counter overflow");if(u.length<p)throw new Error(`arx: output (${u.length}) is shorter than data (${p})`);let h=[],y=a.length,d,w;if(y===32)d=a.slice(),h.push(d),w=Hy;else if(y===16&&r)d=new Uint8Array(32),d.set(a),d.set(a,16),w=A_,h.push(d);else throw new Error(`arx: invalid 32-byte key, got length=${y}`);Mf(c)||(c=c.slice(),h.push(c));let m=Wt(d);if(n){if(c.length!==24)throw new Error("arx: extended nonce must be 24 bytes");n(w,m,Wt(c.subarray(0,16)),m),c=c.subarray(16)}let A=16-i;if(A!==c.length)throw new Error(`arx: nonce must be ${A} or 16 bytes`);if(A!==12){let _=new Uint8Array(12);_.set(c,o?0:12-c.length),c=_,h.push(c)}let g=Wt(c);for(v_(t,w,m,g,f,u,l,s);h.length>0;)h.pop().fill(0);return u}}function zy(t,e,r,n,i,o=20){let s=t[0],a=t[1],c=t[2],f=t[3],u=e[0],l=e[1],p=e[2],h=e[3],y=e[4],d=e[5],w=e[6],m=e[7],A=i,g=r[0],_=r[1],E=r[2],B=s,T=a,k=c,R=f,C=u,L=l,j=p,K=h,Y=y,S=d,I=w,N=m,v=A,b=g,P=_,U=E;for(let F=0;F<o;F+=2)B=B+C|0,v=D(v^B,16),Y=Y+v|0,C=D(C^Y,12),B=B+C|0,v=D(v^B,8),Y=Y+v|0,C=D(C^Y,7),T=T+L|0,b=D(b^T,16),S=S+b|0,L=D(L^S,12),T=T+L|0,b=D(b^T,8),S=S+b|0,L=D(L^S,7),k=k+j|0,P=D(P^k,16),I=I+P|0,j=D(j^I,12),k=k+j|0,P=D(P^k,8),I=I+P|0,j=D(j^I,7),R=R+K|0,U=D(U^R,16),N=N+U|0,K=D(K^N,12),R=R+K|0,U=D(U^R,8),N=N+U|0,K=D(K^N,7),B=B+L|0,U=D(U^B,16),I=I+U|0,L=D(L^I,12),B=B+L|0,U=D(U^B,8),I=I+U|0,L=D(L^I,7),T=T+j|0,v=D(v^T,16),N=N+v|0,j=D(j^N,12),T=T+j|0,v=D(v^T,8),N=N+v|0,j=D(j^N,7),k=k+K|0,b=D(b^k,16),Y=Y+b|0,K=D(K^Y,12),k=k+K|0,b=D(b^k,8),Y=Y+b|0,K=D(K^Y,7),R=R+C|0,P=D(P^R,16),S=S+P|0,C=D(C^S,12),R=R+C|0,P=D(P^R,8),S=S+P|0,C=D(C^S,7);let O=0;n[O++]=s+B|0,n[O++]=a+T|0,n[O++]=c+k|0,n[O++]=f+R|0,n[O++]=u+C|0,n[O++]=l+L|0,n[O++]=p+j|0,n[O++]=h+K|0,n[O++]=y+Y|0,n[O++]=d+S|0,n[O++]=w+I|0,n[O++]=m+N|0,n[O++]=A+v|0,n[O++]=g+b|0,n[O++]=_+P|0,n[O++]=E+U|0}function B_(t,e,r,n){let i=t[0],o=t[1],s=t[2],a=t[3],c=e[0],f=e[1],u=e[2],l=e[3],p=e[4],h=e[5],y=e[6],d=e[7],w=r[0],m=r[1],A=r[2],g=r[3];for(let E=0;E<20;E+=2)i=i+c|0,w=D(w^i,16),p=p+w|0,c=D(c^p,12),i=i+c|0,w=D(w^i,8),p=p+w|0,c=D(c^p,7),o=o+f|0,m=D(m^o,16),h=h+m|0,f=D(f^h,12),o=o+f|0,m=D(m^o,8),h=h+m|0,f=D(f^h,7),s=s+u|0,A=D(A^s,16),y=y+A|0,u=D(u^y,12),s=s+u|0,A=D(A^s,8),y=y+A|0,u=D(u^y,7),a=a+l|0,g=D(g^a,16),d=d+g|0,l=D(l^d,12),a=a+l|0,g=D(g^a,8),d=d+g|0,l=D(l^d,7),i=i+f|0,g=D(g^i,16),y=y+g|0,f=D(f^y,12),i=i+f|0,g=D(g^i,8),y=y+g|0,f=D(f^y,7),o=o+u|0,w=D(w^o,16),d=d+w|0,u=D(u^d,12),o=o+u|0,w=D(w^o,8),d=d+w|0,u=D(u^d,7),s=s+l|0,m=D(m^s,16),p=p+m|0,l=D(l^p,12),s=s+l|0,m=D(m^s,8),p=p+m|0,l=D(l^p,7),a=a+c|0,A=D(A^a,16),h=h+A|0,c=D(c^h,12),a=a+c|0,A=D(A^a,8),h=h+A|0,c=D(c^h,7);let _=0;n[_++]=i,n[_++]=o,n[_++]=s,n[_++]=a,n[_++]=w,n[_++]=m,n[_++]=A,n[_++]=g}var T_=qf(zy,{counterRight:!1,counterLength:4,allowShortKeys:!1}),Bs=qf(zy,{counterRight:!1,counterLength:8,extendNonceFn:B_,allowShortKeys:!1});var k_=new Uint8Array(16),Wy=(t,e)=>{t.update(e);let r=e.length%16;r&&t.update(k_.subarray(r))},P_=new Uint8Array(32);function Jy(t,e,r,n,i){let o=t(e,r,P_),s=Fy.create(o);i&&Wy(s,i),Wy(s,n);let a=new Uint8Array(16),c=Cy(a);Kf(c,0,BigInt(i?i.length:0),!0),Kf(c,8,BigInt(n.length),!0),s.update(a);let f=s.digest();return o.fill(0),f}var Yy=t=>(e,r,n)=>(we(e,32),we(r),{encrypt:(o,s)=>{let a=o.length,c=a+16;s?we(s,c):s=new Uint8Array(c),t(e,r,o,s,1);let f=Jy(t,e,r,s.subarray(0,-16),n);return s.set(f,a),s},decrypt:(o,s)=>{let a=o.length,c=a-16;if(a<16)throw new Error("encrypted data must be at least 16 bytes");s?we(s,c):s=new Uint8Array(c);let f=o.subarray(0,-16),u=o.subarray(-16),l=Jy(t,e,r,f,n);if(!Oy(u,l))throw new Error("invalid tag");return t(e,r,f,s,1),s}}),pT=Of({blockSize:64,nonceLength:12,tagLength:16},Yy(T_)),jf=Of({blockSize:64,nonceLength:24,tagLength:16},Yy(Bs));var Zy=class t{static async bytesToPrivateKey({privateKeyBytes:e}){let r={k:q.uint8Array(e).toBase64Url(),kty:"oct"};return r.kid=await G({jwk:r}),r}static async decrypt({data:e,key:r,nonce:n}){let i=await t.privateKeyToBytes({privateKey:r});return Bs(i,n,e)}static async encrypt({data:e,key:r,nonce:n}){let i=await t.privateKeyToBytes({privateKey:r});return Bs(i,n,e)}static async generateKey(){let e=ke(),r=await e.generateKey({name:"AES-CTR",length:256},!0,["encrypt"]),{alg:n,ext:i,key_ops:o,...s}=await e.exportKey("jwk",r);return s.kid=await G({jwk:s}),s}static async privateKeyToBytes({privateKey:e}){if(!dr(e))throw new Error("XChaCha20: The provided key is not a valid oct private key.");return q.base64Url(e.k).toUint8Array()}};var vT=16,Xy=class t{static async bytesToPrivateKey({privateKeyBytes:e}){let r={k:q.uint8Array(e).toBase64Url(),kty:"oct"};return r.kid=await G({jwk:r}),r}static async decrypt({data:e,key:r,nonce:n,additionalData:i}){let o=await t.privateKeyToBytes({privateKey:r});return jf(o,n,i).decrypt(e)}static async encrypt({data:e,key:r,nonce:n,additionalData:i}){let o=await t.privateKeyToBytes({privateKey:r});return jf(o,n,i).encrypt(e)}static async generateKey(){let e=ke(),r=await e.generateKey({name:"AES-CTR",length:256},!0,["encrypt"]),{alg:n,ext:i,key_ops:o,...s}=await e.exportKey("jwk",r);return s.kid=await G({jwk:s}),s}static async privateKeyToBytes({privateKey:e}){if(!dr(e))throw new Error("XChaCha20Poly1305: The provided key is not a valid oct private key.");return q.base64Url(e.k).toUint8Array()}};export{Ss as AES_GCM_TAG_LENGTHS,$n as AesCtr,Ry as AesCtrAlgorithm,Vn as AesGcm,Dy as AesGcmAlgorithm,My as ConcatKdf,He as CryptoAlgorithm,Py as CryptoUtils,Oi as EcdsaAlgorithm,br as Ed25519,gs as EdDsaAlgorithm,vf as KEY_URI_PREFIX_JWK,ky as LocalKeyManager,pr as P256,vT as POLY1305_TAG_LENGTH,qy as Pbkdf2,hr as Secp256k1,pr as Secp256r1,Kn as Sha256,is as Sha2Algorithm,jy as X25519,Zy as XChaCha20,Xy as XChaCha20Poly1305,yy as canonicalize,G as computeJwkThumbprint,Et as isEcPrivateJwk,jn as isEcPublicJwk,dr as isOctPrivateJwk,_t as isOkpPrivateJwk,Fn as isOkpPublicJwk,wy as isPrivateJwk,r8 as isPublicJwk};
|
|
1
|
+
var nu=Object.create;var Ui=Object.defineProperty;var iu=Object.getOwnPropertyDescriptor;var ou=Object.getOwnPropertyNames;var su=Object.getPrototypeOf,cu=Object.prototype.hasOwnProperty;var Y=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),Ns=(r,t)=>{for(var e in t)Ui(r,e,{get:t[e],enumerable:!0})},au=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of ou(t))!cu.call(r,i)&&i!==e&&Ui(r,i,{get:()=>t[i],enumerable:!(n=iu(t,i))||n.enumerable});return r};var Ds=(r,t,e)=>(e=r!=null?nu(su(r)):{},au(t||!r||!r.__esModule?Ui(e,"default",{value:r,enumerable:!0}):e,r));var Js=Y((ap,js)=>{var fu=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,En=()=>fu.now(),uu=r=>r&&r===Math.floor(r)&&r>0&&isFinite(r),Ki=r=>r===1/0||uu(r),Ii=class r{constructor({max:t=1/0,ttl:e,updateAgeOnGet:n=!1,checkAgeOnGet:i=!1,noUpdateTTL:o=!1,dispose:s,noDisposeOnSet:c=!1}={}){if(this.expirations=Object.create(null),this.data=new Map,this.expirationMap=new Map,e!==void 0&&!Ki(e))throw new TypeError("ttl must be positive integer or Infinity if set");if(!Ki(t))throw new TypeError("max must be positive integer or Infinity");if(this.ttl=e,this.max=t,this.updateAgeOnGet=!!n,this.checkAgeOnGet=!!i,this.noUpdateTTL=!!o,this.noDisposeOnSet=!!c,s!==void 0){if(typeof s!="function")throw new TypeError("dispose must be function if set");this.dispose=s}this.timer=void 0,this.timerExpiration=void 0}setTimer(t,e){if(this.timerExpiration<t)return;this.timer&&clearTimeout(this.timer);let n=setTimeout(()=>{this.timer=void 0,this.timerExpiration=void 0,this.purgeStale();for(let i in this.expirations){this.setTimer(i,i-En());break}},e);n.unref&&n.unref(),this.timerExpiration=t,this.timer=n}cancelTimer(){this.timer&&(clearTimeout(this.timer),this.timerExpiration=void 0,this.timer=void 0)}cancelTimers(){return process.emitWarning('TTLCache.cancelTimers has been renamed to TTLCache.cancelTimer (no "s"), and will be removed in the next major version update'),this.cancelTimer()}clear(){let t=this.dispose!==r.prototype.dispose?[...this]:[];this.data.clear(),this.expirationMap.clear(),this.cancelTimer(),this.expirations=Object.create(null);for(let[e,n]of t)this.dispose(n,e,"delete")}setTTL(t,e=this.ttl){let n=this.expirationMap.get(t);if(n!==void 0){let i=this.expirations[n];!i||i.length<=1?delete this.expirations[n]:this.expirations[n]=i.filter(o=>o!==t)}if(e!==1/0){let i=Math.floor(En()+e);this.expirationMap.set(t,i),this.expirations[i]||(this.expirations[i]=[],this.setTimer(i,e)),this.expirations[i].push(t)}else this.expirationMap.set(t,1/0)}set(t,e,{ttl:n=this.ttl,noUpdateTTL:i=this.noUpdateTTL,noDisposeOnSet:o=this.noDisposeOnSet}={}){if(!Ki(n))throw new TypeError("ttl must be positive integer or Infinity");if(this.expirationMap.has(t)){i||this.setTTL(t,n);let s=this.data.get(t);s!==e&&(this.data.set(t,e),o||this.dispose(s,t,"set"))}else this.setTTL(t,n),this.data.set(t,e);for(;this.size>this.max;)this.purgeToCapacity();return this}has(t){return this.data.has(t)}getRemainingTTL(t){let e=this.expirationMap.get(t);return e===1/0?e:e!==void 0?Math.max(0,Math.ceil(e-En())):0}get(t,{updateAgeOnGet:e=this.updateAgeOnGet,ttl:n=this.ttl,checkAgeOnGet:i=this.checkAgeOnGet}={}){let o=this.data.get(t);if(i&&this.getRemainingTTL(t)===0){this.delete(t);return}return e&&this.setTTL(t,n),o}dispose(t,e){}delete(t){let e=this.expirationMap.get(t);if(e!==void 0){let n=this.data.get(t);this.data.delete(t),this.expirationMap.delete(t);let i=this.expirations[e];return i&&(i.length<=1?delete this.expirations[e]:this.expirations[e]=i.filter(o=>o!==t)),this.dispose(n,t,"delete"),this.size===0&&this.cancelTimer(),!0}return!1}purgeToCapacity(){for(let t in this.expirations){let e=this.expirations[t];if(this.size-e.length>=this.max){delete this.expirations[t];let n=[];for(let i of e)n.push([i,this.data.get(i)]),this.data.delete(i),this.expirationMap.delete(i);for(let[i,o]of n)this.dispose(o,i,"evict")}else{let n=this.size-this.max,i=[];for(let o of e.splice(0,n))i.push([o,this.data.get(o)]),this.data.delete(o),this.expirationMap.delete(o);for(let[o,s]of i)this.dispose(s,o,"evict");return}}}get size(){return this.data.size}purgeStale(){let t=Math.ceil(En());for(let e in this.expirations){if(e==="Infinity"||e>t)return;let n=[...this.expirations[e]||[]],i=[];delete this.expirations[e];for(let o of n)i.push([o,this.data.get(o)]),this.data.delete(o),this.expirationMap.delete(o);for(let[o,s]of i)this.dispose(s,o,"stale")}this.size===0&&this.cancelTimer()}*entries(){for(let t in this.expirations)for(let e of this.expirations[t])yield[e,this.data.get(e)]}*keys(){for(let t in this.expirations)for(let e of this.expirations[t])yield e}*values(){for(let t in this.expirations)for(let e of this.expirations[t])yield this.data.get(e)}[Symbol.iterator](){return this.entries()}};js.exports=Ii});var ic=Y(nc=>{"use strict";nc.supports=function(...t){let e=t.reduce((n,i)=>Object.assign(n,i),{});return Object.assign(e,{snapshots:e.snapshots||!1,permanence:e.permanence||!1,seek:e.seek||!1,clear:e.clear||!1,getMany:e.getMany||!1,keyIterator:e.keyIterator||!1,valueIterator:e.valueIterator||!1,iteratorNextv:e.iteratorNextv||!1,iteratorAll:e.iteratorAll||!1,status:e.status||!1,createIfMissing:e.createIfMissing||!1,errorIfExists:e.errorIfExists||!1,deferredOpen:e.deferredOpen||!1,promises:e.promises||!1,streams:e.streams||!1,encodings:Object.assign({},e.encodings),events:Object.assign({},e.events),additionalMethods:Object.assign({},e.additionalMethods)})}});var Ct=Y((sy,oc)=>{"use strict";oc.exports=class extends Error{constructor(t,e){super(t||""),typeof e=="object"&&e!==null&&(e.code&&(this.code=String(e.code)),e.expected&&(this.expected=!0),e.transient&&(this.transient=!0),e.cause&&(this.cause=e.cause)),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}}});var ac=Y(An=>{"use strict";An.byteLength=Gu;An.toByteArray=Fu;An.fromByteArray=zu;var Gt=[],St=[],Hu=typeof Uint8Array<"u"?Uint8Array:Array,qi="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Ve=0,sc=qi.length;Ve<sc;++Ve)Gt[Ve]=qi[Ve],St[qi.charCodeAt(Ve)]=Ve;var Ve,sc;St[45]=62;St[95]=63;function cc(r){var t=r.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=r.indexOf("=");e===-1&&(e=t);var n=e===t?0:4-e%4;return[e,n]}function Gu(r){var t=cc(r),e=t[0],n=t[1];return(e+n)*3/4-n}function qu(r,t,e){return(t+e)*3/4-e}function Fu(r){var t,e=cc(r),n=e[0],i=e[1],o=new Hu(qu(r,n,i)),s=0,c=i>0?n-4:n,a;for(a=0;a<c;a+=4)t=St[r.charCodeAt(a)]<<18|St[r.charCodeAt(a+1)]<<12|St[r.charCodeAt(a+2)]<<6|St[r.charCodeAt(a+3)],o[s++]=t>>16&255,o[s++]=t>>8&255,o[s++]=t&255;return i===2&&(t=St[r.charCodeAt(a)]<<2|St[r.charCodeAt(a+1)]>>4,o[s++]=t&255),i===1&&(t=St[r.charCodeAt(a)]<<10|St[r.charCodeAt(a+1)]<<4|St[r.charCodeAt(a+2)]>>2,o[s++]=t>>8&255,o[s++]=t&255),o}function $u(r){return Gt[r>>18&63]+Gt[r>>12&63]+Gt[r>>6&63]+Gt[r&63]}function Wu(r,t,e){for(var n,i=[],o=t;o<e;o+=3)n=(r[o]<<16&16711680)+(r[o+1]<<8&65280)+(r[o+2]&255),i.push($u(n));return i.join("")}function zu(r){for(var t,e=r.length,n=e%3,i=[],o=16383,s=0,c=e-n;s<c;s+=o)i.push(Wu(r,s,s+o>c?c:s+o));return n===1?(t=r[e-1],i.push(Gt[t>>2]+Gt[t<<4&63]+"==")):n===2&&(t=(r[e-2]<<8)+r[e-1],i.push(Gt[t>>10]+Gt[t>>4&63]+Gt[t<<2&63]+"=")),i.join("")}});var fc=Y(Fi=>{Fi.read=function(r,t,e,n,i){var o,s,c=i*8-n-1,a=(1<<c)-1,f=a>>1,u=-7,h=e?i-1:0,y=e?-1:1,x=r[t+h];for(h+=y,o=x&(1<<-u)-1,x>>=-u,u+=c;u>0;o=o*256+r[t+h],h+=y,u-=8);for(s=o&(1<<-u)-1,o>>=-u,u+=n;u>0;s=s*256+r[t+h],h+=y,u-=8);if(o===0)o=1-f;else{if(o===a)return s?NaN:(x?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-f}return(x?-1:1)*s*Math.pow(2,o-n)};Fi.write=function(r,t,e,n,i,o){var s,c,a,f=o*8-i-1,u=(1<<f)-1,h=u>>1,y=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,x=n?0:o-1,p=n?1:-1,l=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(c=isNaN(t)?1:0,s=u):(s=Math.floor(Math.log(t)/Math.LN2),t*(a=Math.pow(2,-s))<1&&(s--,a*=2),s+h>=1?t+=y/a:t+=y*Math.pow(2,1-h),t*a>=2&&(s++,a/=2),s+h>=u?(c=0,s=u):s+h>=1?(c=(t*a-1)*Math.pow(2,i),s=s+h):(c=t*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;r[e+x]=c&255,x+=p,c/=256,i-=8);for(s=s<<i|c,f+=i;f>0;r[e+x]=s&255,x+=p,s/=256,f-=8);r[e+x-p]|=l*128}});var Sn=Y(yr=>{"use strict";var $i=ac(),dr=fc(),uc=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;yr.Buffer=g;yr.SlowBuffer=eh;yr.INSPECT_MAX_BYTES=50;var Bn=2147483647;yr.kMaxLength=Bn;g.TYPED_ARRAY_SUPPORT=Zu();!g.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function Zu(){try{let r=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(r,t),r.foo()===42}catch{return!1}}Object.defineProperty(g.prototype,"parent",{enumerable:!0,get:function(){if(g.isBuffer(this))return this.buffer}});Object.defineProperty(g.prototype,"offset",{enumerable:!0,get:function(){if(g.isBuffer(this))return this.byteOffset}});function re(r){if(r>Bn)throw new RangeError('The value "'+r+'" is invalid for option "size"');let t=new Uint8Array(r);return Object.setPrototypeOf(t,g.prototype),t}function g(r,t,e){if(typeof r=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Yi(r)}return pc(r,t,e)}g.poolSize=8192;function pc(r,t,e){if(typeof r=="string")return Xu(r,t);if(ArrayBuffer.isView(r))return Qu(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(qt(r,ArrayBuffer)||r&&qt(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(qt(r,SharedArrayBuffer)||r&&qt(r.buffer,SharedArrayBuffer)))return zi(r,t,e);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=r.valueOf&&r.valueOf();if(n!=null&&n!==r)return g.from(n,t,e);let i=th(r);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return g.from(r[Symbol.toPrimitive]("string"),t,e);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}g.from=function(r,t,e){return pc(r,t,e)};Object.setPrototypeOf(g.prototype,Uint8Array.prototype);Object.setPrototypeOf(g,Uint8Array);function yc(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid for option "size"')}function Yu(r,t,e){return yc(r),r<=0?re(r):t!==void 0?typeof e=="string"?re(r).fill(t,e):re(r).fill(t):re(r)}g.alloc=function(r,t,e){return Yu(r,t,e)};function Yi(r){return yc(r),re(r<0?0:Xi(r)|0)}g.allocUnsafe=function(r){return Yi(r)};g.allocUnsafeSlow=function(r){return Yi(r)};function Xu(r,t){if((typeof t!="string"||t==="")&&(t="utf8"),!g.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let e=mc(r,t)|0,n=re(e),i=n.write(r,t);return i!==e&&(n=n.slice(0,i)),n}function Wi(r){let t=r.length<0?0:Xi(r.length)|0,e=re(t);for(let n=0;n<t;n+=1)e[n]=r[n]&255;return e}function Qu(r){if(qt(r,Uint8Array)){let t=new Uint8Array(r);return zi(t.buffer,t.byteOffset,t.byteLength)}return Wi(r)}function zi(r,t,e){if(t<0||r.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<t+(e||0))throw new RangeError('"length" is outside of buffer bounds');let n;return t===void 0&&e===void 0?n=new Uint8Array(r):e===void 0?n=new Uint8Array(r,t):n=new Uint8Array(r,t,e),Object.setPrototypeOf(n,g.prototype),n}function th(r){if(g.isBuffer(r)){let t=Xi(r.length)|0,e=re(t);return e.length===0||r.copy(e,0,0,t),e}if(r.length!==void 0)return typeof r.length!="number"||to(r.length)?re(0):Wi(r);if(r.type==="Buffer"&&Array.isArray(r.data))return Wi(r.data)}function Xi(r){if(r>=Bn)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Bn.toString(16)+" bytes");return r|0}function eh(r){return+r!=r&&(r=0),g.alloc(+r)}g.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==g.prototype};g.compare=function(t,e){if(qt(t,Uint8Array)&&(t=g.from(t,t.offset,t.byteLength)),qt(e,Uint8Array)&&(e=g.from(e,e.offset,e.byteLength)),!g.isBuffer(t)||!g.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let n=t.length,i=e.length;for(let o=0,s=Math.min(n,i);o<s;++o)if(t[o]!==e[o]){n=t[o],i=e[o];break}return n<i?-1:i<n?1:0};g.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};g.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return g.alloc(0);let n;if(e===void 0)for(e=0,n=0;n<t.length;++n)e+=t[n].length;let i=g.allocUnsafe(e),o=0;for(n=0;n<t.length;++n){let s=t[n];if(qt(s,Uint8Array))o+s.length>i.length?(g.isBuffer(s)||(s=g.from(s)),s.copy(i,o)):Uint8Array.prototype.set.call(i,s,o);else if(g.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function mc(r,t){if(g.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||qt(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);let e=r.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&e===0)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":return Zi(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return Tc(r).length;default:if(i)return n?-1:Zi(r).length;t=(""+t).toLowerCase(),i=!0}}g.byteLength=mc;function rh(r,t,e){let n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,t>>>=0,e<=t))return"";for(r||(r="utf8");;)switch(r){case"hex":return lh(this,t,e);case"utf8":case"utf-8":return gc(this,t,e);case"ascii":return uh(this,t,e);case"latin1":case"binary":return hh(this,t,e);case"base64":return ah(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return dh(this,t,e);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}g.prototype._isBuffer=!0;function He(r,t,e){let n=r[t];r[t]=r[e],r[e]=n}g.prototype.swap16=function(){let t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)He(this,e,e+1);return this};g.prototype.swap32=function(){let t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)He(this,e,e+3),He(this,e+1,e+2);return this};g.prototype.swap64=function(){let t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)He(this,e,e+7),He(this,e+1,e+6),He(this,e+2,e+5),He(this,e+3,e+4);return this};g.prototype.toString=function(){let t=this.length;return t===0?"":arguments.length===0?gc(this,0,t):rh.apply(this,arguments)};g.prototype.toLocaleString=g.prototype.toString;g.prototype.equals=function(t){if(!g.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:g.compare(this,t)===0};g.prototype.inspect=function(){let t="",e=yr.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),"<Buffer "+t+">"};uc&&(g.prototype[uc]=g.prototype.inspect);g.prototype.compare=function(t,e,n,i,o){if(qt(t,Uint8Array)&&(t=g.from(t,t.offset,t.byteLength)),!g.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(e===void 0&&(e=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),e<0||n>t.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&e>=n)return 0;if(i>=o)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,i>>>=0,o>>>=0,this===t)return 0;let s=o-i,c=n-e,a=Math.min(s,c),f=this.slice(i,o),u=t.slice(e,n);for(let h=0;h<a;++h)if(f[h]!==u[h]){s=f[h],c=u[h];break}return s<c?-1:c<s?1:0};function wc(r,t,e,n,i){if(r.length===0)return-1;if(typeof e=="string"?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,to(e)&&(e=i?0:r.length-1),e<0&&(e=r.length+e),e>=r.length){if(i)return-1;e=r.length-1}else if(e<0)if(i)e=0;else return-1;if(typeof t=="string"&&(t=g.from(t,n)),g.isBuffer(t))return t.length===0?-1:hc(r,t,e,n,i);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(r,t,e):Uint8Array.prototype.lastIndexOf.call(r,t,e):hc(r,[t],e,n,i);throw new TypeError("val must be string, number or Buffer")}function hc(r,t,e,n,i){let o=1,s=r.length,c=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(r.length<2||t.length<2)return-1;o=2,s/=2,c/=2,e/=2}function a(u,h){return o===1?u[h]:u.readUInt16BE(h*o)}let f;if(i){let u=-1;for(f=e;f<s;f++)if(a(r,f)===a(t,u===-1?0:f-u)){if(u===-1&&(u=f),f-u+1===c)return u*o}else u!==-1&&(f-=f-u),u=-1}else for(e+c>s&&(e=s-c),f=e;f>=0;f--){let u=!0;for(let h=0;h<c;h++)if(a(r,f+h)!==a(t,h)){u=!1;break}if(u)return f}return-1}g.prototype.includes=function(t,e,n){return this.indexOf(t,e,n)!==-1};g.prototype.indexOf=function(t,e,n){return wc(this,t,e,n,!0)};g.prototype.lastIndexOf=function(t,e,n){return wc(this,t,e,n,!1)};function nh(r,t,e,n){e=Number(e)||0;let i=r.length-e;n?(n=Number(n),n>i&&(n=i)):n=i;let o=t.length;n>o/2&&(n=o/2);let s;for(s=0;s<n;++s){let c=parseInt(t.substr(s*2,2),16);if(to(c))return s;r[e+s]=c}return s}function ih(r,t,e,n){return Tn(Zi(t,r.length-e),r,e,n)}function oh(r,t,e,n){return Tn(wh(t),r,e,n)}function sh(r,t,e,n){return Tn(Tc(t),r,e,n)}function ch(r,t,e,n){return Tn(gh(t,r.length-e),r,e,n)}g.prototype.write=function(t,e,n,i){if(e===void 0)i="utf8",n=this.length,e=0;else if(n===void 0&&typeof e=="string")i=e,n=this.length,e=0;else if(isFinite(e))e=e>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-e;if((n===void 0||n>o)&&(n=o),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let s=!1;for(;;)switch(i){case"hex":return nh(this,t,e,n);case"utf8":case"utf-8":return ih(this,t,e,n);case"ascii":case"latin1":case"binary":return oh(this,t,e,n);case"base64":return sh(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ch(this,t,e,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};g.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ah(r,t,e){return t===0&&e===r.length?$i.fromByteArray(r):$i.fromByteArray(r.slice(t,e))}function gc(r,t,e){e=Math.min(r.length,e);let n=[],i=t;for(;i<e;){let o=r[i],s=null,c=o>239?4:o>223?3:o>191?2:1;if(i+c<=e){let a,f,u,h;switch(c){case 1:o<128&&(s=o);break;case 2:a=r[i+1],(a&192)===128&&(h=(o&31)<<6|a&63,h>127&&(s=h));break;case 3:a=r[i+1],f=r[i+2],(a&192)===128&&(f&192)===128&&(h=(o&15)<<12|(a&63)<<6|f&63,h>2047&&(h<55296||h>57343)&&(s=h));break;case 4:a=r[i+1],f=r[i+2],u=r[i+3],(a&192)===128&&(f&192)===128&&(u&192)===128&&(h=(o&15)<<18|(a&63)<<12|(f&63)<<6|u&63,h>65535&&h<1114112&&(s=h))}}s===null?(s=65533,c=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),i+=c}return fh(n)}var lc=4096;function fh(r){let t=r.length;if(t<=lc)return String.fromCharCode.apply(String,r);let e="",n=0;for(;n<t;)e+=String.fromCharCode.apply(String,r.slice(n,n+=lc));return e}function uh(r,t,e){let n="";e=Math.min(r.length,e);for(let i=t;i<e;++i)n+=String.fromCharCode(r[i]&127);return n}function hh(r,t,e){let n="";e=Math.min(r.length,e);for(let i=t;i<e;++i)n+=String.fromCharCode(r[i]);return n}function lh(r,t,e){let n=r.length;(!t||t<0)&&(t=0),(!e||e<0||e>n)&&(e=n);let i="";for(let o=t;o<e;++o)i+=xh[r[o]];return i}function dh(r,t,e){let n=r.slice(t,e),i="";for(let o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}g.prototype.slice=function(t,e){let n=this.length;t=~~t,e=e===void 0?n:~~e,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),e<t&&(e=t);let i=this.subarray(t,e);return Object.setPrototypeOf(i,g.prototype),i};function ft(r,t,e){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+t>e)throw new RangeError("Trying to access beyond buffer length")}g.prototype.readUintLE=g.prototype.readUIntLE=function(t,e,n){t=t>>>0,e=e>>>0,n||ft(t,e,this.length);let i=this[t],o=1,s=0;for(;++s<e&&(o*=256);)i+=this[t+s]*o;return i};g.prototype.readUintBE=g.prototype.readUIntBE=function(t,e,n){t=t>>>0,e=e>>>0,n||ft(t,e,this.length);let i=this[t+--e],o=1;for(;e>0&&(o*=256);)i+=this[t+--e]*o;return i};g.prototype.readUint8=g.prototype.readUInt8=function(t,e){return t=t>>>0,e||ft(t,1,this.length),this[t]};g.prototype.readUint16LE=g.prototype.readUInt16LE=function(t,e){return t=t>>>0,e||ft(t,2,this.length),this[t]|this[t+1]<<8};g.prototype.readUint16BE=g.prototype.readUInt16BE=function(t,e){return t=t>>>0,e||ft(t,2,this.length),this[t]<<8|this[t+1]};g.prototype.readUint32LE=g.prototype.readUInt32LE=function(t,e){return t=t>>>0,e||ft(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};g.prototype.readUint32BE=g.prototype.readUInt32BE=function(t,e){return t=t>>>0,e||ft(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};g.prototype.readBigUInt64LE=ge(function(t){t=t>>>0,pr(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&Hr(t,this.length-8);let i=e+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,o=this[++t]+this[++t]*2**8+this[++t]*2**16+n*2**24;return BigInt(i)+(BigInt(o)<<BigInt(32))});g.prototype.readBigUInt64BE=ge(function(t){t=t>>>0,pr(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&Hr(t,this.length-8);let i=e*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],o=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(o)});g.prototype.readIntLE=function(t,e,n){t=t>>>0,e=e>>>0,n||ft(t,e,this.length);let i=this[t],o=1,s=0;for(;++s<e&&(o*=256);)i+=this[t+s]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i};g.prototype.readIntBE=function(t,e,n){t=t>>>0,e=e>>>0,n||ft(t,e,this.length);let i=e,o=1,s=this[t+--i];for(;i>0&&(o*=256);)s+=this[t+--i]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*e)),s};g.prototype.readInt8=function(t,e){return t=t>>>0,e||ft(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};g.prototype.readInt16LE=function(t,e){t=t>>>0,e||ft(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};g.prototype.readInt16BE=function(t,e){t=t>>>0,e||ft(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};g.prototype.readInt32LE=function(t,e){return t=t>>>0,e||ft(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};g.prototype.readInt32BE=function(t,e){return t=t>>>0,e||ft(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};g.prototype.readBigInt64LE=ge(function(t){t=t>>>0,pr(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&Hr(t,this.length-8);let i=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(e+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24)});g.prototype.readBigInt64BE=ge(function(t){t=t>>>0,pr(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&Hr(t,this.length-8);let i=(e<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(i)<<BigInt(32))+BigInt(this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n)});g.prototype.readFloatLE=function(t,e){return t=t>>>0,e||ft(t,4,this.length),dr.read(this,t,!0,23,4)};g.prototype.readFloatBE=function(t,e){return t=t>>>0,e||ft(t,4,this.length),dr.read(this,t,!1,23,4)};g.prototype.readDoubleLE=function(t,e){return t=t>>>0,e||ft(t,8,this.length),dr.read(this,t,!0,52,8)};g.prototype.readDoubleBE=function(t,e){return t=t>>>0,e||ft(t,8,this.length),dr.read(this,t,!1,52,8)};function wt(r,t,e,n,i,o){if(!g.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(e+n>r.length)throw new RangeError("Index out of range")}g.prototype.writeUintLE=g.prototype.writeUIntLE=function(t,e,n,i){if(t=+t,e=e>>>0,n=n>>>0,!i){let c=Math.pow(2,8*n)-1;wt(this,t,e,n,c,0)}let o=1,s=0;for(this[e]=t&255;++s<n&&(o*=256);)this[e+s]=t/o&255;return e+n};g.prototype.writeUintBE=g.prototype.writeUIntBE=function(t,e,n,i){if(t=+t,e=e>>>0,n=n>>>0,!i){let c=Math.pow(2,8*n)-1;wt(this,t,e,n,c,0)}let o=n-1,s=1;for(this[e+o]=t&255;--o>=0&&(s*=256);)this[e+o]=t/s&255;return e+n};g.prototype.writeUint8=g.prototype.writeUInt8=function(t,e,n){return t=+t,e=e>>>0,n||wt(this,t,e,1,255,0),this[e]=t&255,e+1};g.prototype.writeUint16LE=g.prototype.writeUInt16LE=function(t,e,n){return t=+t,e=e>>>0,n||wt(this,t,e,2,65535,0),this[e]=t&255,this[e+1]=t>>>8,e+2};g.prototype.writeUint16BE=g.prototype.writeUInt16BE=function(t,e,n){return t=+t,e=e>>>0,n||wt(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=t&255,e+2};g.prototype.writeUint32LE=g.prototype.writeUInt32LE=function(t,e,n){return t=+t,e=e>>>0,n||wt(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255,e+4};g.prototype.writeUint32BE=g.prototype.writeUInt32BE=function(t,e,n){return t=+t,e=e>>>0,n||wt(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};function xc(r,t,e,n,i){Bc(t,n,i,r,e,7);let o=Number(t&BigInt(4294967295));r[e++]=o,o=o>>8,r[e++]=o,o=o>>8,r[e++]=o,o=o>>8,r[e++]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return r[e++]=s,s=s>>8,r[e++]=s,s=s>>8,r[e++]=s,s=s>>8,r[e++]=s,e}function bc(r,t,e,n,i){Bc(t,n,i,r,e,7);let o=Number(t&BigInt(4294967295));r[e+7]=o,o=o>>8,r[e+6]=o,o=o>>8,r[e+5]=o,o=o>>8,r[e+4]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return r[e+3]=s,s=s>>8,r[e+2]=s,s=s>>8,r[e+1]=s,s=s>>8,r[e]=s,e+8}g.prototype.writeBigUInt64LE=ge(function(t,e=0){return xc(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))});g.prototype.writeBigUInt64BE=ge(function(t,e=0){return bc(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))});g.prototype.writeIntLE=function(t,e,n,i){if(t=+t,e=e>>>0,!i){let a=Math.pow(2,8*n-1);wt(this,t,e,n,a-1,-a)}let o=0,s=1,c=0;for(this[e]=t&255;++o<n&&(s*=256);)t<0&&c===0&&this[e+o-1]!==0&&(c=1),this[e+o]=(t/s>>0)-c&255;return e+n};g.prototype.writeIntBE=function(t,e,n,i){if(t=+t,e=e>>>0,!i){let a=Math.pow(2,8*n-1);wt(this,t,e,n,a-1,-a)}let o=n-1,s=1,c=0;for(this[e+o]=t&255;--o>=0&&(s*=256);)t<0&&c===0&&this[e+o+1]!==0&&(c=1),this[e+o]=(t/s>>0)-c&255;return e+n};g.prototype.writeInt8=function(t,e,n){return t=+t,e=e>>>0,n||wt(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=t&255,e+1};g.prototype.writeInt16LE=function(t,e,n){return t=+t,e=e>>>0,n||wt(this,t,e,2,32767,-32768),this[e]=t&255,this[e+1]=t>>>8,e+2};g.prototype.writeInt16BE=function(t,e,n){return t=+t,e=e>>>0,n||wt(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=t&255,e+2};g.prototype.writeInt32LE=function(t,e,n){return t=+t,e=e>>>0,n||wt(this,t,e,4,2147483647,-2147483648),this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4};g.prototype.writeInt32BE=function(t,e,n){return t=+t,e=e>>>0,n||wt(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};g.prototype.writeBigInt64LE=ge(function(t,e=0){return xc(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});g.prototype.writeBigInt64BE=ge(function(t,e=0){return bc(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Ec(r,t,e,n,i,o){if(e+n>r.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function vc(r,t,e,n,i){return t=+t,e=e>>>0,i||Ec(r,t,e,4,34028234663852886e22,-34028234663852886e22),dr.write(r,t,e,n,23,4),e+4}g.prototype.writeFloatLE=function(t,e,n){return vc(this,t,e,!0,n)};g.prototype.writeFloatBE=function(t,e,n){return vc(this,t,e,!1,n)};function Ac(r,t,e,n,i){return t=+t,e=e>>>0,i||Ec(r,t,e,8,17976931348623157e292,-17976931348623157e292),dr.write(r,t,e,n,52,8),e+8}g.prototype.writeDoubleLE=function(t,e,n){return Ac(this,t,e,!0,n)};g.prototype.writeDoubleBE=function(t,e,n){return Ac(this,t,e,!1,n)};g.prototype.copy=function(t,e,n,i){if(!g.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i<n&&(i=n),i===n||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e<i-n&&(i=t.length-e+n);let o=i-n;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,n,i):Uint8Array.prototype.set.call(t,this.subarray(n,i),e),o};g.prototype.fill=function(t,e,n,i){if(typeof t=="string"){if(typeof e=="string"?(i=e,e=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!g.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(t.length===1){let s=t.charCodeAt(0);(i==="utf8"&&s<128||i==="latin1")&&(t=s)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;e=e>>>0,n=n===void 0?this.length:n>>>0,t||(t=0);let o;if(typeof t=="number")for(o=e;o<n;++o)this[o]=t;else{let s=g.isBuffer(t)?t:g.from(t,i),c=s.length;if(c===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<n-e;++o)this[o+e]=s[o%c]}return this};var lr={};function Qi(r,t,e){lr[r]=class extends e{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${r}]`,this.stack,delete this.name}get code(){return r}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${r}]: ${this.message}`}}}Qi("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Qi("ERR_INVALID_ARG_TYPE",function(r,t){return`The "${r}" argument must be of type number. Received type ${typeof t}`},TypeError);Qi("ERR_OUT_OF_RANGE",function(r,t,e){let n=`The value of "${r}" is out of range.`,i=e;return Number.isInteger(e)&&Math.abs(e)>2**32?i=dc(String(e)):typeof e=="bigint"&&(i=String(e),(e>BigInt(2)**BigInt(32)||e<-(BigInt(2)**BigInt(32)))&&(i=dc(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n},RangeError);function dc(r){let t="",e=r.length,n=r[0]==="-"?1:0;for(;e>=n+4;e-=3)t=`_${r.slice(e-3,e)}${t}`;return`${r.slice(0,e)}${t}`}function ph(r,t,e){pr(t,"offset"),(r[t]===void 0||r[t+e]===void 0)&&Hr(t,r.length-(e+1))}function Bc(r,t,e,n,i,o){if(r>e||r<t){let s=typeof t=="bigint"?"n":"",c;throw o>3?t===0||t===BigInt(0)?c=`>= 0${s} and < 2${s} ** ${(o+1)*8}${s}`:c=`>= -(2${s} ** ${(o+1)*8-1}${s}) and < 2 ** ${(o+1)*8-1}${s}`:c=`>= ${t}${s} and <= ${e}${s}`,new lr.ERR_OUT_OF_RANGE("value",c,r)}ph(n,i,o)}function pr(r,t){if(typeof r!="number")throw new lr.ERR_INVALID_ARG_TYPE(t,"number",r)}function Hr(r,t,e){throw Math.floor(r)!==r?(pr(r,e),new lr.ERR_OUT_OF_RANGE(e||"offset","an integer",r)):t<0?new lr.ERR_BUFFER_OUT_OF_BOUNDS:new lr.ERR_OUT_OF_RANGE(e||"offset",`>= ${e?1:0} and <= ${t}`,r)}var yh=/[^+/0-9A-Za-z-_]/g;function mh(r){if(r=r.split("=")[0],r=r.trim().replace(yh,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function Zi(r,t){t=t||1/0;let e,n=r.length,i=null,o=[];for(let s=0;s<n;++s){if(e=r.charCodeAt(s),e>55295&&e<57344){if(!i){if(e>56319){(t-=3)>-1&&o.push(239,191,189);continue}else if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=e;continue}if(e<56320){(t-=3)>-1&&o.push(239,191,189),i=e;continue}e=(i-55296<<10|e-56320)+65536}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,e<128){if((t-=1)<0)break;o.push(e)}else if(e<2048){if((t-=2)<0)break;o.push(e>>6|192,e&63|128)}else if(e<65536){if((t-=3)<0)break;o.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((t-=4)<0)break;o.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return o}function wh(r){let t=[];for(let e=0;e<r.length;++e)t.push(r.charCodeAt(e)&255);return t}function gh(r,t){let e,n,i,o=[];for(let s=0;s<r.length&&!((t-=2)<0);++s)e=r.charCodeAt(s),n=e>>8,i=e%256,o.push(i),o.push(n);return o}function Tc(r){return $i.toByteArray(mh(r))}function Tn(r,t,e,n){let i;for(i=0;i<n&&!(i+e>=t.length||i>=r.length);++i)t[i+e]=r[i];return i}function qt(r,t){return r instanceof t||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===t.name}function to(r){return r!==r}var xh=function(){let r="0123456789abcdef",t=new Array(256);for(let e=0;e<16;++e){let n=e*16;for(let i=0;i<16;++i)t[n+i]=r[e]+r[i]}return t}();function ge(r){return typeof BigInt>"u"?bh:r}function bh(){throw new Error("BigInt not supported")}});var ro=Y((hy,Sc)=>{"use strict";var eo=null;Sc.exports=function(){return eo===null&&(eo={textEncoder:new TextEncoder,textDecoder:new TextDecoder}),eo}});var oo=Y(kc=>{"use strict";var no=Ct(),Eh=new Set(["buffer","view","utf8"]),io=class{constructor(t){if(this.encode=t.encode||this.encode,this.decode=t.decode||this.decode,this.name=t.name||this.name,this.format=t.format||this.format,typeof this.encode!="function")throw new TypeError("The 'encode' property must be a function");if(typeof this.decode!="function")throw new TypeError("The 'decode' property must be a function");if(this.encode=this.encode.bind(this),this.decode=this.decode.bind(this),typeof this.name!="string"||this.name==="")throw new TypeError("The 'name' property must be a string");if(typeof this.format!="string"||!Eh.has(this.format))throw new TypeError("The 'format' property must be one of 'buffer', 'view', 'utf8'");t.createViewTranscoder&&(this.createViewTranscoder=t.createViewTranscoder),t.createBufferTranscoder&&(this.createBufferTranscoder=t.createBufferTranscoder),t.createUTF8Transcoder&&(this.createUTF8Transcoder=t.createUTF8Transcoder)}get commonName(){return this.name.split("+")[0]}createBufferTranscoder(){throw new no(`Encoding '${this.name}' cannot be transcoded to 'buffer'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createViewTranscoder(){throw new no(`Encoding '${this.name}' cannot be transcoded to 'view'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createUTF8Transcoder(){throw new no(`Encoding '${this.name}' cannot be transcoded to 'utf8'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}};kc.Encoding=io});var fo=Y(kn=>{"use strict";var{Buffer:co}=Sn()||{},{Encoding:ao}=oo(),vh=ro(),Gr=class extends ao{constructor(t){super({...t,format:"buffer"})}createViewTranscoder(){return new qr({encode:this.encode,decode:t=>this.decode(co.from(t.buffer,t.byteOffset,t.byteLength)),name:`${this.name}+view`})}createBufferTranscoder(){return this}},qr=class extends ao{constructor(t){super({...t,format:"view"})}createBufferTranscoder(){return new Gr({encode:t=>{let e=this.encode(t);return co.from(e.buffer,e.byteOffset,e.byteLength)},decode:this.decode,name:`${this.name}+buffer`})}createViewTranscoder(){return this}},so=class extends ao{constructor(t){super({...t,format:"utf8"})}createBufferTranscoder(){return new Gr({encode:t=>co.from(this.encode(t),"utf8"),decode:t=>this.decode(t.toString("utf8")),name:`${this.name}+buffer`})}createViewTranscoder(){let{textEncoder:t,textDecoder:e}=vh();return new qr({encode:n=>t.encode(this.encode(n)),decode:n=>this.decode(e.decode(n)),name:`${this.name}+view`})}createUTF8Transcoder(){return this}};kn.BufferFormat=Gr;kn.ViewFormat=qr;kn.UTF8Format=so});var Ic=Y(Ge=>{"use strict";var{Buffer:pt}=Sn()||{Buffer:{isBuffer:()=>!1}},{textEncoder:Uc,textDecoder:Pc}=ro()(),{BufferFormat:Fr,ViewFormat:uo,UTF8Format:Kc}=fo(),Pn=r=>r;Ge.utf8=new Kc({encode:function(r){return pt.isBuffer(r)?r.toString("utf8"):ArrayBuffer.isView(r)?Pc.decode(r):String(r)},decode:Pn,name:"utf8",createViewTranscoder(){return new uo({encode:function(r){return ArrayBuffer.isView(r)?r:Uc.encode(r)},decode:function(r){return Pc.decode(r)},name:`${this.name}+view`})},createBufferTranscoder(){return new Fr({encode:function(r){return pt.isBuffer(r)?r:ArrayBuffer.isView(r)?pt.from(r.buffer,r.byteOffset,r.byteLength):pt.from(String(r),"utf8")},decode:function(r){return r.toString("utf8")},name:`${this.name}+buffer`})}});Ge.json=new Kc({encode:JSON.stringify,decode:JSON.parse,name:"json"});Ge.buffer=new Fr({encode:function(r){return pt.isBuffer(r)?r:ArrayBuffer.isView(r)?pt.from(r.buffer,r.byteOffset,r.byteLength):pt.from(String(r),"utf8")},decode:Pn,name:"buffer",createViewTranscoder(){return new uo({encode:function(r){return ArrayBuffer.isView(r)?r:pt.from(String(r),"utf8")},decode:function(r){return pt.from(r.buffer,r.byteOffset,r.byteLength)},name:`${this.name}+view`})}});Ge.view=new uo({encode:function(r){return ArrayBuffer.isView(r)?r:Uc.encode(r)},decode:Pn,name:"view",createBufferTranscoder(){return new Fr({encode:function(r){return pt.isBuffer(r)?r:ArrayBuffer.isView(r)?pt.from(r.buffer,r.byteOffset,r.byteLength):pt.from(String(r),"utf8")},decode:Pn,name:`${this.name}+buffer`})}});Ge.hex=new Fr({encode:function(r){return pt.isBuffer(r)?r:pt.from(String(r),"hex")},decode:function(r){return r.toString("hex")},name:"hex"});Ge.base64=new Fr({encode:function(r){return pt.isBuffer(r)?r:pt.from(String(r),"base64")},decode:function(r){return r.toString("base64")},name:"base64"})});var Lc=Y(Cc=>{"use strict";var _c=Ct(),Kn=Ic(),{Encoding:Ah}=oo(),{BufferFormat:Bh,ViewFormat:Th,UTF8Format:Sh}=fo(),$r=Symbol("formats"),Un=Symbol("encodings"),kh=new Set(["buffer","view","utf8"]),ho=class{constructor(t){if(Array.isArray(t)){if(!t.every(e=>kh.has(e)))throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'")}else throw new TypeError("The first argument 'formats' must be an array");this[Un]=new Map,this[$r]=new Set(t);for(let e in Kn)try{this.encoding(e)}catch(n){if(n.code!=="LEVEL_ENCODING_NOT_SUPPORTED")throw n}}encodings(){return Array.from(new Set(this[Un].values()))}encoding(t){let e=this[Un].get(t);if(e===void 0){if(typeof t=="string"&&t!==""){if(e=Ih[t],!e)throw new _c(`Encoding '${t}' is not found`,{code:"LEVEL_ENCODING_NOT_FOUND"})}else{if(typeof t!="object"||t===null)throw new TypeError("First argument 'encoding' must be a string or object");e=Ph(t)}let{name:n,format:i}=e;if(!this[$r].has(i))if(this[$r].has("view"))e=e.createViewTranscoder();else if(this[$r].has("buffer"))e=e.createBufferTranscoder();else if(this[$r].has("utf8"))e=e.createUTF8Transcoder();else throw new _c(`Encoding '${n}' cannot be transcoded`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"});for(let o of[t,n,e.name,e.commonName])this[Un].set(o,e)}return e}};Cc.Transcoder=ho;function Ph(r){if(r instanceof Ah)return r;let t="type"in r&&typeof r.type=="string"?r.type:void 0,e=r.name||t||`anonymous-${_h++}`;switch(Uh(r)){case"view":return new Th({...r,name:e});case"utf8":return new Sh({...r,name:e});case"buffer":return new Bh({...r,name:e});default:throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'")}}function Uh(r){return"format"in r&&r.format!==void 0?r.format:"buffer"in r&&typeof r.buffer=="boolean"?r.buffer?"buffer":"utf8":"code"in r&&Number.isInteger(r.code)?"view":"buffer"}var Kh={binary:Kn.buffer,"utf-8":Kn.utf8},Ih={...Kn,...Kh},_h=0});var qc=Y((my,lo)=>{"use strict";var mr=typeof Reflect=="object"?Reflect:null,Oc=mr&&typeof mr.apply=="function"?mr.apply:function(t,e,n){return Function.prototype.apply.call(t,e,n)},In;mr&&typeof mr.ownKeys=="function"?In=mr.ownKeys:Object.getOwnPropertySymbols?In=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:In=function(t){return Object.getOwnPropertyNames(t)};function Ch(r){console&&console.warn&&console.warn(r)}var Nc=Number.isNaN||function(t){return t!==t};function tt(){tt.init.call(this)}lo.exports=tt;lo.exports.once=Nh;tt.EventEmitter=tt;tt.prototype._events=void 0;tt.prototype._eventsCount=0;tt.prototype._maxListeners=void 0;var Rc=10;function _n(r){if(typeof r!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r)}Object.defineProperty(tt,"defaultMaxListeners",{enumerable:!0,get:function(){return Rc},set:function(r){if(typeof r!="number"||r<0||Nc(r))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+r+".");Rc=r}});tt.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};tt.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||Nc(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this};function Dc(r){return r._maxListeners===void 0?tt.defaultMaxListeners:r._maxListeners}tt.prototype.getMaxListeners=function(){return Dc(this)};tt.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++)e.push(arguments[n]);var i=t==="error",o=this._events;if(o!==void 0)i=i&&o.error===void 0;else if(!i)return!1;if(i){var s;if(e.length>0&&(s=e[0]),s instanceof Error)throw s;var c=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw c.context=s,c}var a=o[t];if(a===void 0)return!1;if(typeof a=="function")Oc(a,this,e);else for(var f=a.length,u=Hc(a,f),n=0;n<f;++n)Oc(u[n],this,e);return!0};function Mc(r,t,e,n){var i,o,s;if(_n(e),o=r._events,o===void 0?(o=r._events=Object.create(null),r._eventsCount=0):(o.newListener!==void 0&&(r.emit("newListener",t,e.listener?e.listener:e),o=r._events),s=o[t]),s===void 0)s=o[t]=e,++r._eventsCount;else if(typeof s=="function"?s=o[t]=n?[e,s]:[s,e]:n?s.unshift(e):s.push(e),i=Dc(r),i>0&&s.length>i&&!s.warned){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=r,c.type=t,c.count=s.length,Ch(c)}return r}tt.prototype.addListener=function(t,e){return Mc(this,t,e,!1)};tt.prototype.on=tt.prototype.addListener;tt.prototype.prependListener=function(t,e){return Mc(this,t,e,!0)};function Lh(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function jc(r,t,e){var n={fired:!1,wrapFn:void 0,target:r,type:t,listener:e},i=Lh.bind(n);return i.listener=e,n.wrapFn=i,i}tt.prototype.once=function(t,e){return _n(e),this.on(t,jc(this,t,e)),this};tt.prototype.prependOnceListener=function(t,e){return _n(e),this.prependListener(t,jc(this,t,e)),this};tt.prototype.removeListener=function(t,e){var n,i,o,s,c;if(_n(e),i=this._events,i===void 0)return this;if(n=i[t],n===void 0)return this;if(n===e||n.listener===e)--this._eventsCount===0?this._events=Object.create(null):(delete i[t],i.removeListener&&this.emit("removeListener",t,n.listener||e));else if(typeof n!="function"){for(o=-1,s=n.length-1;s>=0;s--)if(n[s]===e||n[s].listener===e){c=n[s].listener,o=s;break}if(o<0)return this;o===0?n.shift():Oh(n,o),n.length===1&&(i[t]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",t,c||e)}return this};tt.prototype.off=tt.prototype.removeListener;tt.prototype.removeAllListeners=function(t){var e,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[t]),this;if(arguments.length===0){var o=Object.keys(n),s;for(i=0;i<o.length;++i)s=o[i],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(e=n[t],typeof e=="function")this.removeListener(t,e);else if(e!==void 0)for(i=e.length-1;i>=0;i--)this.removeListener(t,e[i]);return this};function Jc(r,t,e){var n=r._events;if(n===void 0)return[];var i=n[t];return i===void 0?[]:typeof i=="function"?e?[i.listener||i]:[i]:e?Rh(i):Hc(i,i.length)}tt.prototype.listeners=function(t){return Jc(this,t,!0)};tt.prototype.rawListeners=function(t){return Jc(this,t,!1)};tt.listenerCount=function(r,t){return typeof r.listenerCount=="function"?r.listenerCount(t):Vc.call(r,t)};tt.prototype.listenerCount=Vc;function Vc(r){var t=this._events;if(t!==void 0){var e=t[r];if(typeof e=="function")return 1;if(e!==void 0)return e.length}return 0}tt.prototype.eventNames=function(){return this._eventsCount>0?In(this._events):[]};function Hc(r,t){for(var e=new Array(t),n=0;n<t;++n)e[n]=r[n];return e}function Oh(r,t){for(;t+1<r.length;t++)r[t]=r[t+1];r.pop()}function Rh(r){for(var t=new Array(r.length),e=0;e<t.length;++e)t[e]=r[e].listener||r[e];return t}function Nh(r,t){return new Promise(function(e,n){function i(s){r.removeListener(t,o),n(s)}function o(){typeof r.removeListener=="function"&&r.removeListener("error",i),e([].slice.call(arguments))}Gc(r,t,o,{once:!0}),t!=="error"&&Dh(r,i,{once:!0})})}function Dh(r,t,e){typeof r.on=="function"&&Gc(r,"error",t,e)}function Gc(r,t,e,n){if(typeof r.on=="function")n.once?r.once(t,e):r.on(t,e);else if(typeof r.addEventListener=="function")r.addEventListener(t,function i(o){n.once&&r.removeEventListener(t,i),e(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof r)}});var $c=Y((wy,Fc)=>{Fc.exports=typeof queueMicrotask=="function"?queueMicrotask:r=>Promise.resolve().then(r)});var Wr=Y(po=>{"use strict";var Wc=$c();po.fromCallback=function(r,t){if(r===void 0){var e=new Promise(function(n,i){r=function(o,s){o?i(o):n(s)}});r[t!==void 0?t:"promise"]=e}else if(typeof r!="function")throw new TypeError("Callback must be a function");return r};po.fromPromise=function(r,t){if(t===void 0)return r;r.then(function(e){Wc(()=>t(null,e))}).catch(function(e){Wc(()=>t(e))})}});var Cn=Y(yo=>{"use strict";yo.getCallback=function(r,t){return typeof r=="function"?r:t};yo.getOptions=function(r,t){return typeof r=="object"&&r!==null?r:t!==void 0?t:{}}});var Be=Y(Nn=>{"use strict";var{fromCallback:mo}=Wr(),Et=Ct(),{getOptions:wo,getCallback:zc}=Cn(),qe=Symbol("promise"),wr=Symbol("callback"),Ft=Symbol("working"),Fe=Symbol("handleOne"),ne=Symbol("handleMany"),go=Symbol("autoClose"),ve=Symbol("finishWork"),$t=Symbol("returnMany"),xe=Symbol("closing"),zr=Symbol("handleClose"),Ln=Symbol("closed"),Zr=Symbol("closeCallbacks"),Ee=Symbol("keyEncoding"),$e=Symbol("valueEncoding"),xo=Symbol("abortOnClose"),On=Symbol("legacy"),bo=Symbol("keys"),Eo=Symbol("values"),be=Symbol("limit"),kt=Symbol("count"),Rn=Object.freeze({}),Mh=()=>{},Zc=!1,Yr=class{constructor(t,e,n){if(typeof t!="object"||t===null){let i=t===null?"null":typeof t;throw new TypeError(`The first argument must be an abstract-level database, received ${i}`)}if(typeof e!="object"||e===null)throw new TypeError("The second argument must be an options object");this[Ln]=!1,this[Zr]=[],this[Ft]=!1,this[xe]=!1,this[go]=!1,this[wr]=null,this[Fe]=this[Fe].bind(this),this[ne]=this[ne].bind(this),this[zr]=this[zr].bind(this),this[Ee]=e[Ee],this[$e]=e[$e],this[On]=n,this[be]=Number.isInteger(e.limit)&&e.limit>=0?e.limit:1/0,this[kt]=0,this[xo]=!!e.abortOnClose,this.db=t,this.db.attachResource(this),this.nextTick=t.nextTick}get count(){return this[kt]}get limit(){return this[be]}next(t){let e;if(t===void 0)e=new Promise((n,i)=>{t=(o,s,c)=>{o?i(o):this[On]?s===void 0&&c===void 0?n():n([s,c]):n(s)}});else if(typeof t!="function")throw new TypeError("Callback must be a function");return this[xe]?this.nextTick(t,new Et("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[Ft]?this.nextTick(t,new Et("Iterator is busy: cannot call next() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[Ft]=!0,this[wr]=t,this[kt]>=this[be]?this.nextTick(this[Fe],null):this._next(this[Fe])),e}_next(t){this.nextTick(t)}nextv(t,e,n){return n=zc(e,n),n=mo(n,qe),e=wo(e,Rn),Number.isInteger(t)?(this[xe]?this.nextTick(n,new Et("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[Ft]?this.nextTick(n,new Et("Iterator is busy: cannot call nextv() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(t<1&&(t=1),this[be]<1/0&&(t=Math.min(t,this[be]-this[kt])),this[Ft]=!0,this[wr]=n,t<=0?this.nextTick(this[ne],null,[]):this._nextv(t,e,this[ne])),n[qe]):(this.nextTick(n,new TypeError("The first argument 'size' must be an integer")),n[qe])}_nextv(t,e,n){let i=[],o=(s,c,a)=>{if(s)return n(s);if(this[On]?c===void 0&&a===void 0:c===void 0)return n(null,i);i.push(this[On]?[c,a]:c),i.length===t?n(null,i):this._next(o)};this._next(o)}all(t,e){return e=zc(t,e),e=mo(e,qe),t=wo(t,Rn),this[xe]?this.nextTick(e,new Et("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[Ft]?this.nextTick(e,new Et("Iterator is busy: cannot call all() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[Ft]=!0,this[wr]=e,this[go]=!0,this[kt]>=this[be]?this.nextTick(this[ne],null,[]):this._all(t,this[ne])),e[qe]}_all(t,e){let n=this[kt],i=[],o=()=>{let c=this[be]<1/0?Math.min(1e3,this[be]-n):1e3;c<=0?this.nextTick(e,null,i):this._nextv(c,Rn,s)},s=(c,a)=>{c?e(c):a.length===0?e(null,i):(i.push.apply(i,a),n+=a.length,o())};o()}[ve](){let t=this[wr];return this[xo]&&t===null?Mh:(this[Ft]=!1,this[wr]=null,this[xe]&&this._close(this[zr]),t)}[$t](t,e,n){this[go]?this.close(t.bind(null,e,n)):t(e,n)}seek(t,e){if(e=wo(e,Rn),!this[xe]){if(this[Ft])throw new Et("Iterator is busy: cannot call seek() until next() has completed",{code:"LEVEL_ITERATOR_BUSY"});{let n=this.db.keyEncoding(e.keyEncoding||this[Ee]),i=n.format;e.keyEncoding!==i&&(e={...e,keyEncoding:i});let o=this.db.prefixKey(n.encode(t),i);this._seek(o,e)}}}_seek(t,e){throw new Et("Iterator does not support seek()",{code:"LEVEL_NOT_SUPPORTED"})}close(t){return t=mo(t,qe),this[Ln]?this.nextTick(t):this[xe]?this[Zr].push(t):(this[xe]=!0,this[Zr].push(t),this[Ft]?this[xo]&&this[ve]()(new Et("Aborted on iterator close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this._close(this[zr])),t[qe]}_close(t){this.nextTick(t)}[zr](){this[Ln]=!0,this.db.detachResource(this);let t=this[Zr];this[Zr]=[];for(let e of t)e()}async*[Symbol.asyncIterator](){try{let t;for(;(t=await this.next())!==void 0;)yield t}finally{this[Ln]||await this.close()}}},gr=class extends Yr{constructor(t,e){super(t,e,!0),this[bo]=e.keys!==!1,this[Eo]=e.values!==!1}[Fe](t,e,n){let i=this[ve]();if(t)return i(t);try{e=this[bo]&&e!==void 0?this[Ee].decode(e):void 0,n=this[Eo]&&n!==void 0?this[$e].decode(n):void 0}catch(o){return i(new Ae("entry",o))}e===void 0&&n===void 0||this[kt]++,i(null,e,n)}[ne](t,e){let n=this[ve]();if(t)return this[$t](n,t);try{for(let i of e){let o=i[0],s=i[1];i[0]=this[bo]&&o!==void 0?this[Ee].decode(o):void 0,i[1]=this[Eo]&&s!==void 0?this[$e].decode(s):void 0}}catch(i){return this[$t](n,new Ae("entries",i))}this[kt]+=e.length,this[$t](n,null,e)}end(t){return!Zc&&typeof console<"u"&&(Zc=!0,console.warn(new Et("The iterator.end() method was renamed to close() and end() is an alias that will be removed in a future version",{code:"LEVEL_LEGACY"}))),this.close(t)}},vo=class extends Yr{constructor(t,e){super(t,e,!1)}[Fe](t,e){let n=this[ve]();if(t)return n(t);try{e=e!==void 0?this[Ee].decode(e):void 0}catch(i){return n(new Ae("key",i))}e!==void 0&&this[kt]++,n(null,e)}[ne](t,e){let n=this[ve]();if(t)return this[$t](n,t);try{for(let i=0;i<e.length;i++){let o=e[i];e[i]=o!==void 0?this[Ee].decode(o):void 0}}catch(i){return this[$t](n,new Ae("keys",i))}this[kt]+=e.length,this[$t](n,null,e)}},Ao=class extends Yr{constructor(t,e){super(t,e,!1)}[Fe](t,e){let n=this[ve]();if(t)return n(t);try{e=e!==void 0?this[$e].decode(e):void 0}catch(i){return n(new Ae("value",i))}e!==void 0&&this[kt]++,n(null,e)}[ne](t,e){let n=this[ve]();if(t)return this[$t](n,t);try{for(let i=0;i<e.length;i++){let o=e[i];e[i]=o!==void 0?this[$e].decode(o):void 0}}catch(i){return this[$t](n,new Ae("values",i))}this[kt]+=e.length,this[$t](n,null,e)}},Ae=class extends Et{constructor(t,e){super(`Iterator could not decode ${t}`,{code:"LEVEL_DECODE_ERROR",cause:e})}};for(let r of["_ended property","_nexting property","_end method"])Object.defineProperty(gr.prototype,r.split(" ")[0],{get(){throw new Et(`The ${r} has been removed`,{code:"LEVEL_LEGACY"})},set(){throw new Et(`The ${r} has been removed`,{code:"LEVEL_LEGACY"})}});gr.keyEncoding=Ee;gr.valueEncoding=$e;Nn.AbstractIterator=gr;Nn.AbstractKeyIterator=vo;Nn.AbstractValueIterator=Ao});var Yc=Y(Bo=>{"use strict";var{AbstractKeyIterator:jh,AbstractValueIterator:Jh}=Be(),We=Symbol("iterator"),Xr=Symbol("callback"),xr=Symbol("handleOne"),ze=Symbol("handleMany"),Qr=class extends jh{constructor(t,e){super(t,e),this[We]=t.iterator({...e,keys:!0,values:!1}),this[xr]=this[xr].bind(this),this[ze]=this[ze].bind(this)}},Dn=class extends Jh{constructor(t,e){super(t,e),this[We]=t.iterator({...e,keys:!1,values:!0}),this[xr]=this[xr].bind(this),this[ze]=this[ze].bind(this)}};for(let r of[Qr,Dn]){let t=r===Qr,e=t?n=>n[0]:n=>n[1];r.prototype._next=function(n){this[Xr]=n,this[We].next(this[xr])},r.prototype[xr]=function(n,i,o){let s=this[Xr];n?s(n):s(null,t?i:o)},r.prototype._nextv=function(n,i,o){this[Xr]=o,this[We].nextv(n,i,this[ze])},r.prototype._all=function(n,i){this[Xr]=i,this[We].all(n,this[ze])},r.prototype[ze]=function(n,i){let o=this[Xr];n?o(n):o(null,i.map(e))},r.prototype._seek=function(n,i){this[We].seek(n,i)},r.prototype._close=function(n){this[We].close(n)}}Bo.DefaultKeyIterator=Qr;Bo.DefaultValueIterator=Dn});var Xc=Y(Gn=>{"use strict";var{AbstractIterator:Vh,AbstractKeyIterator:Hh,AbstractValueIterator:Gh}=Be(),To=Ct(),gt=Symbol("nut"),Vn=Symbol("undefer"),Hn=Symbol("factory"),Mn=class extends Vh{constructor(t,e){super(t,e),this[gt]=null,this[Hn]=()=>t.iterator(e),this.db.defer(()=>this[Vn]())}},jn=class extends Hh{constructor(t,e){super(t,e),this[gt]=null,this[Hn]=()=>t.keys(e),this.db.defer(()=>this[Vn]())}},Jn=class extends Gh{constructor(t,e){super(t,e),this[gt]=null,this[Hn]=()=>t.values(e),this.db.defer(()=>this[Vn]())}};for(let r of[Mn,jn,Jn])r.prototype[Vn]=function(){this.db.status==="open"&&(this[gt]=this[Hn]())},r.prototype._next=function(t){this[gt]!==null?this[gt].next(t):this.db.status==="opening"?this.db.defer(()=>this._next(t)):this.nextTick(t,new To("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},r.prototype._nextv=function(t,e,n){this[gt]!==null?this[gt].nextv(t,e,n):this.db.status==="opening"?this.db.defer(()=>this._nextv(t,e,n)):this.nextTick(n,new To("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},r.prototype._all=function(t,e){this[gt]!==null?this[gt].all(e):this.db.status==="opening"?this.db.defer(()=>this._all(t,e)):this.nextTick(e,new To("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},r.prototype._seek=function(t,e){this[gt]!==null?this[gt]._seek(t,e):this.db.status==="opening"&&this.db.defer(()=>this._seek(t,e))},r.prototype._close=function(t){this[gt]!==null?this[gt].close(t):this.db.status==="opening"?this.db.defer(()=>this._close(t)):this.nextTick(t)};Gn.DeferredIterator=Mn;Gn.DeferredKeyIterator=jn;Gn.DeferredValueIterator=Jn});var ko=Y(ta=>{"use strict";var{fromCallback:Qc}=Wr(),qn=Ct(),{getCallback:qh,getOptions:Fh}=Cn(),Fn=Symbol("promise"),Pt=Symbol("status"),br=Symbol("operations"),tn=Symbol("finishClose"),Er=Symbol("closeCallbacks"),So=class{constructor(t){if(typeof t!="object"||t===null){let e=t===null?"null":typeof t;throw new TypeError(`The first argument must be an abstract-level database, received ${e}`)}this[br]=[],this[Er]=[],this[Pt]="open",this[tn]=this[tn].bind(this),this.db=t,this.db.attachResource(this),this.nextTick=t.nextTick}get length(){return this[br].length}put(t,e,n){if(this[Pt]!=="open")throw new qn("Batch is not open: cannot call put() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});let i=this.db._checkKey(t)||this.db._checkValue(e);if(i)throw i;let o=n&&n.sublevel!=null?n.sublevel:this.db,s=n,c=o.keyEncoding(n&&n.keyEncoding),a=o.valueEncoding(n&&n.valueEncoding),f=c.format;n={...n,keyEncoding:f,valueEncoding:a.format},o!==this.db&&(n.sublevel=null);let u=o.prefixKey(c.encode(t),f),h=a.encode(e);return this._put(u,h,n),this[br].push({...s,type:"put",key:t,value:e}),this}_put(t,e,n){}del(t,e){if(this[Pt]!=="open")throw new qn("Batch is not open: cannot call del() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});let n=this.db._checkKey(t);if(n)throw n;let i=e&&e.sublevel!=null?e.sublevel:this.db,o=e,s=i.keyEncoding(e&&e.keyEncoding),c=s.format;return e={...e,keyEncoding:c},i!==this.db&&(e.sublevel=null),this._del(i.prefixKey(s.encode(t),c),e),this[br].push({...o,type:"del",key:t}),this}_del(t,e){}clear(){if(this[Pt]!=="open")throw new qn("Batch is not open: cannot call clear() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});return this._clear(),this[br]=[],this}_clear(){}write(t,e){return e=qh(t,e),e=Qc(e,Fn),t=Fh(t),this[Pt]!=="open"?this.nextTick(e,new qn("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"})):this.length===0?this.close(e):(this[Pt]="writing",this._write(t,n=>{this[Pt]="closing",this[Er].push(()=>e(n)),n||this.db.emit("batch",this[br]),this._close(this[tn])})),e[Fn]}_write(t,e){}close(t){return t=Qc(t,Fn),this[Pt]==="closing"?this[Er].push(t):this[Pt]==="closed"?this.nextTick(t):(this[Er].push(t),this[Pt]!=="writing"&&(this[Pt]="closing",this._close(this[tn]))),t[Fn]}_close(t){this.nextTick(t)}[tn](){this[Pt]="closed",this.db.detachResource(this);let t=this[Er];this[Er]=[];for(let e of t)e()}};ta.AbstractChainedBatch=So});var ra=Y(ea=>{"use strict";var{AbstractChainedBatch:$h}=ko(),Wh=Ct(),vr=Symbol("encoded"),Po=class extends $h{constructor(t){super(t),this[vr]=[]}_put(t,e,n){this[vr].push({...n,type:"put",key:t,value:e})}_del(t,e){this[vr].push({...e,type:"del",key:t})}_clear(){this[vr]=[]}_write(t,e){this.db.status==="opening"?this.db.defer(()=>this._write(t,e)):this.db.status==="open"?this[vr].length===0?this.nextTick(e):this.db._batch(this[vr],t,e):this.nextTick(e,new Wh("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"}))}};ea.DefaultChainedBatch=Po});var oa=Y((Ty,ia)=>{"use strict";var na=Ct(),zh=Object.prototype.hasOwnProperty,Zh=new Set(["lt","lte","gt","gte"]);ia.exports=function(r,t){let e={};for(let n in r)if(zh.call(r,n)&&!(n==="keyEncoding"||n==="valueEncoding")){if(n==="start"||n==="end")throw new na(`The legacy range option '${n}' has been removed`,{code:"LEVEL_LEGACY"});if(n==="encoding")throw new na("The levelup-style 'encoding' alias has been removed, use 'valueEncoding' instead",{code:"LEVEL_LEGACY"});Zh.has(n)?e[n]=t.encode(r[n]):e[n]=r[n]}return e.reverse=!!e.reverse,e.limit=Number.isInteger(e.limit)&&e.limit>=0?e.limit:-1,e}});var Uo=Y((Sy,ca)=>{var sa;ca.exports=typeof queueMicrotask=="function"?queueMicrotask.bind(typeof window<"u"?window:globalThis):r=>(sa||(sa=Promise.resolve())).then(r).catch(t=>setTimeout(()=>{throw t},0))});var ua=Y((ky,fa)=>{"use strict";var aa=Uo();fa.exports=function(r,...t){t.length===0?aa(r):aa(()=>r(...t))}});var ha=Y($n=>{"use strict";var{AbstractIterator:Yh,AbstractKeyIterator:Xh,AbstractValueIterator:Qh}=Be(),Ar=Symbol("unfix"),Lt=Symbol("iterator"),Ze=Symbol("handleOne"),Te=Symbol("handleMany"),ie=Symbol("callback"),en=class extends Yh{constructor(t,e,n,i){super(t,e),this[Lt]=n,this[Ar]=i,this[Ze]=this[Ze].bind(this),this[Te]=this[Te].bind(this),this[ie]=null}[Ze](t,e,n){let i=this[ie];if(t)return i(t);e!==void 0&&(e=this[Ar](e)),i(t,e,n)}[Te](t,e){let n=this[ie];if(t)return n(t);for(let i of e){let o=i[0];o!==void 0&&(i[0]=this[Ar](o))}n(t,e)}},rn=class extends Xh{constructor(t,e,n,i){super(t,e),this[Lt]=n,this[Ar]=i,this[Ze]=this[Ze].bind(this),this[Te]=this[Te].bind(this),this[ie]=null}[Ze](t,e){let n=this[ie];if(t)return n(t);e!==void 0&&(e=this[Ar](e)),n(t,e)}[Te](t,e){let n=this[ie];if(t)return n(t);for(let i=0;i<e.length;i++){let o=e[i];o!==void 0&&(e[i]=this[Ar](o))}n(t,e)}},nn=class extends Qh{constructor(t,e,n){super(t,e),this[Lt]=n}};for(let r of[en,rn])r.prototype._next=function(t){this[ie]=t,this[Lt].next(this[Ze])},r.prototype._nextv=function(t,e,n){this[ie]=n,this[Lt].nextv(t,e,this[Te])},r.prototype._all=function(t,e){this[ie]=e,this[Lt].all(t,this[Te])};for(let r of[nn])r.prototype._next=function(t){this[Lt].next(t)},r.prototype._nextv=function(t,e,n){this[Lt].nextv(t,e,n)},r.prototype._all=function(t,e){this[Lt].all(t,e)};for(let r of[en,rn,nn])r.prototype._seek=function(t,e){this[Lt].seek(t,e)},r.prototype._close=function(t){this[Lt].close(t)};$n.AbstractSublevelIterator=en;$n.AbstractSublevelKeyIterator=rn;$n.AbstractSublevelValueIterator=nn});var ya=Y((Uy,pa)=>{"use strict";var Ko=Ct(),{Buffer:Co}=Sn()||{},{AbstractSublevelIterator:tl,AbstractSublevelKeyIterator:el,AbstractSublevelValueIterator:rl}=ha(),oe=Symbol("prefix"),la=Symbol("upperBound"),on=Symbol("prefixRange"),vt=Symbol("parent"),Io=Symbol("unfix"),da=new TextEncoder,nl={separator:"!"};pa.exports=function({AbstractLevel:r}){class t extends r{static defaults(n){if(typeof n=="string")throw new Ko("The subleveldown string shorthand for { separator } has been removed",{code:"LEVEL_LEGACY"});if(n&&n.open)throw new Ko("The subleveldown open option has been removed",{code:"LEVEL_LEGACY"});return n==null?nl:n.separator?n:{...n,separator:"!"}}constructor(n,i,o){let{separator:s,manifest:c,...a}=t.defaults(o);i=ol(i,s);let f=s.charCodeAt(0)+1,u=n[vt]||n;if(!da.encode(i).every(x=>x>f&&x<127))throw new Ko(`Prefix must use bytes > ${f} < 127`,{code:"LEVEL_INVALID_PREFIX"});super(il(u,c),a);let h=(n.prefix||"")+s+i+s,y=h.slice(0,-1)+String.fromCharCode(f);this[vt]=u,this[oe]=new Wn(h),this[la]=new Wn(y),this[Io]=new Lo,this.nextTick=u.nextTick}prefixKey(n,i){if(i==="utf8")return this[oe].utf8+n;if(n.byteLength===0)return this[oe][i];if(i==="view"){let o=this[oe].view,s=new Uint8Array(o.byteLength+n.byteLength);return s.set(o,0),s.set(n,o.byteLength),s}else{let o=this[oe].buffer;return Co.concat([o,n],o.byteLength+n.byteLength)}}[on](n,i){n.gte!==void 0?n.gte=this.prefixKey(n.gte,i):n.gt!==void 0?n.gt=this.prefixKey(n.gt,i):n.gte=this[oe][i],n.lte!==void 0?n.lte=this.prefixKey(n.lte,i):n.lt!==void 0?n.lt=this.prefixKey(n.lt,i):n.lte=this[la][i]}get prefix(){return this[oe].utf8}get db(){return this[vt]}_open(n,i){this[vt].open({passive:!0},i)}_put(n,i,o,s){this[vt].put(n,i,o,s)}_get(n,i,o){this[vt].get(n,i,o)}_getMany(n,i,o){this[vt].getMany(n,i,o)}_del(n,i,o){this[vt].del(n,i,o)}_batch(n,i,o){this[vt].batch(n,i,o)}_clear(n,i){this[on](n,n.keyEncoding),this[vt].clear(n,i)}_iterator(n){this[on](n,n.keyEncoding);let i=this[vt].iterator(n),o=this[Io].get(this[oe].utf8.length,n.keyEncoding);return new tl(this,n,i,o)}_keys(n){this[on](n,n.keyEncoding);let i=this[vt].keys(n),o=this[Io].get(this[oe].utf8.length,n.keyEncoding);return new el(this,n,i,o)}_values(n){this[on](n,n.keyEncoding);let i=this[vt].values(n);return new rl(this,n,i)}}return{AbstractSublevel:t}};var il=function(r,t){return{...r.supports,createIfMissing:!1,errorIfExists:!1,events:{},additionalMethods:{},...t,encodings:{utf8:_o(r,"utf8"),buffer:_o(r,"buffer"),view:_o(r,"view")}}},_o=function(r,t){return r.supports.encodings[t]?r.keyEncoding(t).name===t:!1},Wn=class{constructor(t){this.utf8=t,this.view=da.encode(t),this.buffer=Co?Co.from(this.view.buffer,0,this.view.byteLength):{}}},Lo=class{constructor(){this.cache=new Map}get(t,e){let n=this.cache.get(e);return n===void 0&&(e==="view"?n=(function(i,o){return o.subarray(i)}).bind(null,t):n=(function(i,o){return o.slice(i)}).bind(null,t),this.cache.set(e,n)),n}},ol=function(r,t){let e=0,n=r.length;for(;e<n&&r[e]===t;)e++;for(;n>e&&r[n-1]===t;)n--;return r.slice(e,n)}});var Mo=Y(Do=>{"use strict";var{supports:sl}=ic(),{Transcoder:cl}=Lc(),{EventEmitter:al}=qc(),{fromCallback:Se}=Wr(),Ot=Ct(),{AbstractIterator:Ye}=Be(),{DefaultKeyIterator:fl,DefaultValueIterator:ul}=Yc(),{DeferredIterator:hl,DeferredKeyIterator:ll,DeferredValueIterator:dl}=Xc(),{DefaultChainedBatch:ma}=ra(),{getCallback:Xe,getOptions:ke}=Cn(),zn=oa(),$=Symbol("promise"),se=Symbol("landed"),Qe=Symbol("resources"),Oo=Symbol("closeResources"),sn=Symbol("operations"),cn=Symbol("undefer"),Zn=Symbol("deferOpen"),wa=Symbol("options"),Z=Symbol("status"),tr=Symbol("defaultOptions"),Br=Symbol("transcoder"),Yn=Symbol("keyEncoding"),Ro=Symbol("valueEncoding"),pl=()=>{},an=class extends al{constructor(t,e){if(super(),typeof t!="object"||t===null)throw new TypeError("The first argument 'manifest' must be an object");e=ke(e);let{keyEncoding:n,valueEncoding:i,passive:o,...s}=e;this[Qe]=new Set,this[sn]=[],this[Zn]=!0,this[wa]=s,this[Z]="opening",this.supports=sl(t,{status:!0,promises:!0,clear:!0,getMany:!0,deferredOpen:!0,snapshots:t.snapshots!==!1,permanence:t.permanence!==!1,keyIterator:!0,valueIterator:!0,iteratorNextv:!0,iteratorAll:!0,encodings:t.encodings||{},events:Object.assign({},t.events,{opening:!0,open:!0,closing:!0,closed:!0,put:!0,del:!0,batch:!0,clear:!0})}),this[Br]=new cl(yl(this)),this[Yn]=this[Br].encoding(n||"utf8"),this[Ro]=this[Br].encoding(i||"utf8");for(let c of this[Br].encodings())this.supports.encodings[c.commonName]||(this.supports.encodings[c.commonName]=!0);this[tr]={empty:Object.freeze({}),entry:Object.freeze({keyEncoding:this[Yn].commonName,valueEncoding:this[Ro].commonName}),key:Object.freeze({keyEncoding:this[Yn].commonName})},this.nextTick(()=>{this[Zn]&&this.open({passive:!1},pl)})}get status(){return this[Z]}keyEncoding(t){return this[Br].encoding(t??this[Yn])}valueEncoding(t){return this[Br].encoding(t??this[Ro])}open(t,e){e=Xe(t,e),e=Se(e,$),t={...this[wa],...ke(t)},t.createIfMissing=t.createIfMissing!==!1,t.errorIfExists=!!t.errorIfExists;let n=i=>{this[Z]==="closing"||this[Z]==="opening"?this.once(se,i?()=>n(i):n):this[Z]!=="open"?e(new Ot("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN",cause:i})):e()};return t.passive?this[Z]==="opening"?this.once(se,n):this.nextTick(n):this[Z]==="closed"||this[Zn]?(this[Zn]=!1,this[Z]="opening",this.emit("opening"),this._open(t,i=>{if(i){this[Z]="closed",this[Oo](()=>{this.emit(se),n(i)}),this[cn]();return}this[Z]="open",this[cn](),this.emit(se),this[Z]==="open"&&this.emit("open"),this[Z]==="open"&&this.emit("ready"),n()})):this[Z]==="open"?this.nextTick(n):this.once(se,()=>this.open(t,e)),e[$]}_open(t,e){this.nextTick(e)}close(t){t=Se(t,$);let e=n=>{this[Z]==="opening"||this[Z]==="closing"?this.once(se,n?e(n):e):this[Z]!=="closed"?t(new Ot("Database is not closed",{code:"LEVEL_DATABASE_NOT_CLOSED",cause:n})):t()};if(this[Z]==="open"){this[Z]="closing",this.emit("closing");let n=i=>{this[Z]="open",this[cn](),this.emit(se),e(i)};this[Oo](()=>{this._close(i=>{if(i)return n(i);this[Z]="closed",this[cn](),this.emit(se),this[Z]==="closed"&&this.emit("closed"),e()})})}else this[Z]==="closed"?this.nextTick(e):this.once(se,()=>this.close(t));return t[$]}[Oo](t){if(this[Qe].size===0)return this.nextTick(t);let e=this[Qe].size,n=!0,i=()=>{--e===0&&(n?this.nextTick(t):t())};for(let o of this[Qe])o.close(i);n=!1,this[Qe].clear()}_close(t){this.nextTick(t)}get(t,e,n){if(n=Xe(e,n),n=Se(n,$),e=ke(e,this[tr].entry),this[Z]==="opening")return this.defer(()=>this.get(t,e,n)),n[$];if(Tr(this,n))return n[$];let i=this._checkKey(t);if(i)return this.nextTick(n,i),n[$];let o=this.keyEncoding(e.keyEncoding),s=this.valueEncoding(e.valueEncoding),c=o.format,a=s.format;return(e.keyEncoding!==c||e.valueEncoding!==a)&&(e=Object.assign({},e,{keyEncoding:c,valueEncoding:a})),this._get(this.prefixKey(o.encode(t),c),e,(f,u)=>{if(f)return(f.code==="LEVEL_NOT_FOUND"||f.notFound||/NotFound/i.test(f))&&(f.code||(f.code="LEVEL_NOT_FOUND"),f.notFound||(f.notFound=!0),f.status||(f.status=404)),n(f);try{u=s.decode(u)}catch(h){return n(new Ot("Could not decode value",{code:"LEVEL_DECODE_ERROR",cause:h}))}n(null,u)}),n[$]}_get(t,e,n){this.nextTick(n,new Error("NotFound"))}getMany(t,e,n){if(n=Xe(e,n),n=Se(n,$),e=ke(e,this[tr].entry),this[Z]==="opening")return this.defer(()=>this.getMany(t,e,n)),n[$];if(Tr(this,n))return n[$];if(!Array.isArray(t))return this.nextTick(n,new TypeError("The first argument 'keys' must be an array")),n[$];if(t.length===0)return this.nextTick(n,null,[]),n[$];let i=this.keyEncoding(e.keyEncoding),o=this.valueEncoding(e.valueEncoding),s=i.format,c=o.format;(e.keyEncoding!==s||e.valueEncoding!==c)&&(e=Object.assign({},e,{keyEncoding:s,valueEncoding:c}));let a=new Array(t.length);for(let f=0;f<t.length;f++){let u=t[f],h=this._checkKey(u);if(h)return this.nextTick(n,h),n[$];a[f]=this.prefixKey(i.encode(u),s)}return this._getMany(a,e,(f,u)=>{if(f)return n(f);try{for(let h=0;h<u.length;h++)u[h]!==void 0&&(u[h]=o.decode(u[h]))}catch(h){return n(new Ot(`Could not decode one or more of ${u.length} value(s)`,{code:"LEVEL_DECODE_ERROR",cause:h}))}n(null,u)}),n[$]}_getMany(t,e,n){this.nextTick(n,null,new Array(t.length).fill(void 0))}put(t,e,n,i){if(i=Xe(n,i),i=Se(i,$),n=ke(n,this[tr].entry),this[Z]==="opening")return this.defer(()=>this.put(t,e,n,i)),i[$];if(Tr(this,i))return i[$];let o=this._checkKey(t)||this._checkValue(e);if(o)return this.nextTick(i,o),i[$];let s=this.keyEncoding(n.keyEncoding),c=this.valueEncoding(n.valueEncoding),a=s.format,f=c.format;(n.keyEncoding!==a||n.valueEncoding!==f)&&(n=Object.assign({},n,{keyEncoding:a,valueEncoding:f}));let u=this.prefixKey(s.encode(t),a),h=c.encode(e);return this._put(u,h,n,y=>{if(y)return i(y);this.emit("put",t,e),i()}),i[$]}_put(t,e,n,i){this.nextTick(i)}del(t,e,n){if(n=Xe(e,n),n=Se(n,$),e=ke(e,this[tr].key),this[Z]==="opening")return this.defer(()=>this.del(t,e,n)),n[$];if(Tr(this,n))return n[$];let i=this._checkKey(t);if(i)return this.nextTick(n,i),n[$];let o=this.keyEncoding(e.keyEncoding),s=o.format;return e.keyEncoding!==s&&(e=Object.assign({},e,{keyEncoding:s})),this._del(this.prefixKey(o.encode(t),s),e,c=>{if(c)return n(c);this.emit("del",t),n()}),n[$]}_del(t,e,n){this.nextTick(n)}batch(t,e,n){if(!arguments.length){if(this[Z]==="opening")return new ma(this);if(this[Z]!=="open")throw new Ot("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._chainedBatch()}if(typeof t=="function"?n=t:n=Xe(e,n),n=Se(n,$),e=ke(e,this[tr].empty),this[Z]==="opening")return this.defer(()=>this.batch(t,e,n)),n[$];if(Tr(this,n))return n[$];if(!Array.isArray(t))return this.nextTick(n,new TypeError("The first argument 'operations' must be an array")),n[$];if(t.length===0)return this.nextTick(n),n[$];let i=new Array(t.length),{keyEncoding:o,valueEncoding:s,...c}=e;for(let a=0;a<t.length;a++){if(typeof t[a]!="object"||t[a]===null)return this.nextTick(n,new TypeError("A batch operation must be an object")),n[$];let f=Object.assign({},t[a]);if(f.type!=="put"&&f.type!=="del")return this.nextTick(n,new TypeError("A batch operation must have a type property that is 'put' or 'del'")),n[$];let u=this._checkKey(f.key);if(u)return this.nextTick(n,u),n[$];let h=f.sublevel!=null?f.sublevel:this,y=h.keyEncoding(f.keyEncoding||o),x=y.format;if(f.key=h.prefixKey(y.encode(f.key),x),f.keyEncoding=x,f.type==="put"){let p=this._checkValue(f.value);if(p)return this.nextTick(n,p),n[$];let l=h.valueEncoding(f.valueEncoding||s);f.value=l.encode(f.value),f.valueEncoding=l.format}h!==this&&(f.sublevel=null),i[a]=f}return this._batch(i,c,a=>{if(a)return n(a);this.emit("batch",t),n()}),n[$]}_batch(t,e,n){this.nextTick(n)}sublevel(t,e){return this._sublevel(t,No.defaults(e))}_sublevel(t,e){return new No(this,t,e)}prefixKey(t,e){return t}clear(t,e){if(e=Xe(t,e),e=Se(e,$),t=ke(t,this[tr].empty),this[Z]==="opening")return this.defer(()=>this.clear(t,e)),e[$];if(Tr(this,e))return e[$];let n=t,i=this.keyEncoding(t.keyEncoding);return t=zn(t,i),t.keyEncoding=i.format,t.limit===0?this.nextTick(e):this._clear(t,o=>{if(o)return e(o);this.emit("clear",n),e()}),e[$]}_clear(t,e){this.nextTick(e)}iterator(t){let e=this.keyEncoding(t&&t.keyEncoding),n=this.valueEncoding(t&&t.valueEncoding);if(t=zn(t,e),t.keys=t.keys!==!1,t.values=t.values!==!1,t[Ye.keyEncoding]=e,t[Ye.valueEncoding]=n,t.keyEncoding=e.format,t.valueEncoding=n.format,this[Z]==="opening")return new hl(this,t);if(this[Z]!=="open")throw new Ot("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._iterator(t)}_iterator(t){return new Ye(this,t)}keys(t){let e=this.keyEncoding(t&&t.keyEncoding),n=this.valueEncoding(t&&t.valueEncoding);if(t=zn(t,e),t[Ye.keyEncoding]=e,t[Ye.valueEncoding]=n,t.keyEncoding=e.format,t.valueEncoding=n.format,this[Z]==="opening")return new ll(this,t);if(this[Z]!=="open")throw new Ot("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._keys(t)}_keys(t){return new fl(this,t)}values(t){let e=this.keyEncoding(t&&t.keyEncoding),n=this.valueEncoding(t&&t.valueEncoding);if(t=zn(t,e),t[Ye.keyEncoding]=e,t[Ye.valueEncoding]=n,t.keyEncoding=e.format,t.valueEncoding=n.format,this[Z]==="opening")return new dl(this,t);if(this[Z]!=="open")throw new Ot("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._values(t)}_values(t){return new ul(this,t)}defer(t){if(typeof t!="function")throw new TypeError("The first argument must be a function");this[sn].push(t)}[cn](){if(this[sn].length===0)return;let t=this[sn];this[sn]=[];for(let e of t)e()}attachResource(t){if(typeof t!="object"||t===null||typeof t.close!="function")throw new TypeError("The first argument must be a resource object");this[Qe].add(t)}detachResource(t){this[Qe].delete(t)}_chainedBatch(){return new ma(this)}_checkKey(t){if(t==null)return new Ot("Key cannot be null or undefined",{code:"LEVEL_INVALID_KEY"})}_checkValue(t){if(t==null)return new Ot("Value cannot be null or undefined",{code:"LEVEL_INVALID_VALUE"})}};an.prototype.nextTick=ua();var{AbstractSublevel:No}=ya()({AbstractLevel:an});Do.AbstractLevel=an;Do.AbstractSublevel=No;var Tr=function(r,t){return r[Z]!=="open"?(r.nextTick(t,new Ot("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"})),!0):!1},yl=function(r){return Object.keys(r.supports.encodings).filter(t=>!!r.supports.encodings[t])}});var jo=Y(er=>{"use strict";er.AbstractLevel=Mo().AbstractLevel;er.AbstractSublevel=Mo().AbstractSublevel;er.AbstractIterator=Be().AbstractIterator;er.AbstractKeyIterator=Be().AbstractKeyIterator;er.AbstractValueIterator=Be().AbstractValueIterator;er.AbstractChainedBatch=ko().AbstractChainedBatch});var xa=Y((_y,ga)=>{ga.exports=wl;var ml=Uo();function wl(r,t,e){if(typeof t!="number")throw new Error("second argument must be a Number");let n,i,o,s,c,a=!0,f;Array.isArray(r)?(n=[],o=i=r.length):(s=Object.keys(r),n={},o=i=s.length);function u(y){function x(){e&&e(y,n),e=null}a?ml(x):x()}function h(y,x,p){if(n[y]=p,x&&(c=!0),--o===0||x)u(x);else if(!c&&f<i){let l;s?(l=s[f],f+=1,r[l](function(m,b){h(l,m,b)})):(l=f,f+=1,r[l](function(m,b){h(l,m,b)}))}}f=t,o?s?s.some(function(y,x){return r[y](function(p,l){h(y,p,l)}),x===t-1}):r.some(function(y,x){return y(function(p,l){h(x,p,l)}),x===t-1}):u(null),a=!1}});var Jo=Y((Cy,ba)=>{"use strict";ba.exports=function(t){let e=t.gte!==void 0?t.gte:t.gt!==void 0?t.gt:void 0,n=t.lte!==void 0?t.lte:t.lt!==void 0?t.lt:void 0,i=t.gte===void 0,o=t.lte===void 0;return e!==void 0&&n!==void 0?IDBKeyRange.bound(e,n,i,o):e!==void 0?IDBKeyRange.lowerBound(e,i):n!==void 0?IDBKeyRange.upperBound(n,o):null}});var Vo=Y((Ly,Ea)=>{"use strict";var gl=new TextEncoder;Ea.exports=function(r){return r instanceof Uint8Array?r:r instanceof ArrayBuffer?new Uint8Array(r):gl.encode(r)}});var Sa=Y(Ta=>{"use strict";var{AbstractIterator:xl}=jo(),va=Jo(),Xn=Vo(),Wt=Symbol("cache"),ce=Symbol("finished"),At=Symbol("options"),ae=Symbol("currentOptions"),rr=Symbol("position"),Ho=Symbol("location"),Sr=Symbol("first"),Aa={},Go=class extends xl{constructor(t,e,n){super(t,n),this[Wt]=[],this[ce]=this.limit===0,this[At]=n,this[ae]={...n},this[rr]=void 0,this[Ho]=e,this[Sr]=!0}_nextv(t,e,n){if(this[Sr]=!1,this[ce])return this.nextTick(n,null,[]);if(this[Wt].length>0)return t=Math.min(t,this[Wt].length),this.nextTick(n,null,this[Wt].splice(0,t));this[rr]!==void 0&&(this[At].reverse?(this[ae].lt=this[rr],this[ae].lte=void 0):(this[ae].gt=this[rr],this[ae].gte=void 0));let i;try{i=va(this[ae])}catch{return this[ce]=!0,this.nextTick(n,null,[])}let o=this.db.db.transaction([this[Ho]],"readonly"),s=o.objectStore(this[Ho]),c=[];if(this[At].reverse){let a=!this[At].values&&s.openKeyCursor?"openKeyCursor":"openCursor";s[a](i,"prev").onsuccess=f=>{let u=f.target.result;if(u){let{key:h,value:y}=u;this[rr]=h,c.push([this[At].keys&&h!==void 0?Xn(h):void 0,this[At].values&&y!==void 0?Xn(y):void 0]),c.length<t?u.continue():Ba(o)}else this[ce]=!0}}else{let a,f,u=()=>{if(a===void 0||f===void 0)return;let h=Math.max(a.length,f.length);h===0||t===1/0?this[ce]=!0:this[rr]=a[h-1],c.length=h;for(let y=0;y<h;y++){let x=a[y],p=f[y];c[y]=[this[At].keys&&x!==void 0?Xn(x):void 0,this[At].values&&p!==void 0?Xn(p):void 0]}Ba(o)};this[At].keys||t<1/0?s.getAllKeys(i,t<1/0?t:void 0).onsuccess=h=>{a=h.target.result,u()}:(a=[],this.nextTick(u)),this[At].values?s.getAll(i,t<1/0?t:void 0).onsuccess=h=>{f=h.target.result,u()}:(f=[],this.nextTick(u))}o.onabort=()=>{n(o.error||new Error("aborted by user")),n=null},o.oncomplete=()=>{n(null,c),n=null}}_next(t){if(this[Wt].length>0){let[e,n]=this[Wt].shift();this.nextTick(t,null,e,n)}else if(this[ce])this.nextTick(t);else{let e=Math.min(100,this.limit-this.count);this[Sr]&&(this[Sr]=!1,e=1),this._nextv(e,Aa,(n,i)=>{if(n)return t(n);this[Wt]=i,this._next(t)})}}_all(t,e){this[Sr]=!1;let n=this[Wt].splice(0,this[Wt].length),i=this.limit-this.count-n.length;if(i<=0)return this.nextTick(e,null,n);this._nextv(i,Aa,(o,s)=>{if(o)return e(o);n.length>0&&(s=n.concat(s)),e(null,s)})}_seek(t,e){this[Sr]=!0,this[Wt]=[],this[ce]=!1,this[rr]=void 0,this[ae]={...this[At]};let n;try{n=va(this[At])}catch{this[ce]=!0;return}n!==null&&!n.includes(t)?this[ce]=!0:this[At].reverse?this[ae].lte=t:this[ae].gte=t}};Ta.Iterator=Go;function Ba(r){typeof r.commit=="function"&&r.commit()}});var Pa=Y((Ry,ka)=>{"use strict";ka.exports=function(t,e,n,i,o){if(i.limit===0)return t.nextTick(o);let s=t.db.transaction([e],"readwrite"),c=s.objectStore(e),a=0;s.oncomplete=function(){o()},s.onabort=function(){o(s.error||new Error("aborted by user"))};let f=c.openKeyCursor?"openKeyCursor":"openCursor",u=i.reverse?"prev":"next";c[f](n,u).onsuccess=function(h){let y=h.target.result;y&&(c.delete(y.key).onsuccess=function(){(i.limit<=0||++a<i.limit)&&y.continue()})}}});var La=Y(Ca=>{"use strict";var{AbstractLevel:bl}=jo(),Ua=Ct(),El=xa(),{fromCallback:vl}=Wr(),{Iterator:Al}=Sa(),Ka=Vo(),Bl=Pa(),Tl=Jo(),_a="level-js-",fn=Symbol("idb"),qo=Symbol("namePrefix"),fe=Symbol("location"),Fo=Symbol("version"),nr=Symbol("store"),un=Symbol("onComplete"),Ia=Symbol("promise"),Qn=class extends bl{constructor(t,e,n){if(typeof e=="function"||typeof n=="function")throw new Ua("The levelup-style callback argument has been removed",{code:"LEVEL_LEGACY"});let{prefix:i,version:o,...s}=e||{};if(super({encodings:{view:!0},snapshots:!1,createIfMissing:!1,errorIfExists:!1,seek:!0},s),typeof t!="string")throw new Error("constructor requires a location string argument");this[fe]=t,this[qo]=i??_a,this[Fo]=parseInt(o||1,10),this[fn]=null}get location(){return this[fe]}get namePrefix(){return this[qo]}get version(){return this[Fo]}get db(){return this[fn]}get type(){return"browser-level"}_open(t,e){let n=indexedDB.open(this[qo]+this[fe],this[Fo]);n.onerror=function(){e(n.error||new Error("unknown error"))},n.onsuccess=()=>{this[fn]=n.result,e()},n.onupgradeneeded=i=>{let o=i.target.result;o.objectStoreNames.contains(this[fe])||o.createObjectStore(this[fe])}}[nr](t){return this[fn].transaction([this[fe]],t).objectStore(this[fe])}[un](t,e){let n=t.transaction;n.onabort=function(){e(n.error||new Error("aborted by user"))},n.oncomplete=function(){e(null,t.result)}}_get(t,e,n){let i=this[nr]("readonly"),o;try{o=i.get(t)}catch(s){return this.nextTick(n,s)}this[un](o,function(s,c){if(s)return n(s);if(c===void 0)return n(new Ua("Entry not found",{code:"LEVEL_NOT_FOUND"}));n(null,Ka(c))})}_getMany(t,e,n){let i=this[nr]("readonly"),o=t.map(s=>c=>{let a;try{a=i.get(s)}catch(f){return c(f)}a.onsuccess=()=>{let f=a.result;c(null,f===void 0?f:Ka(f))},a.onerror=f=>{f.stopPropagation(),c(a.error)}});El(o,16,n)}_del(t,e,n){let i=this[nr]("readwrite"),o;try{o=i.delete(t)}catch(s){return this.nextTick(n,s)}this[un](o,n)}_put(t,e,n,i){let o=this[nr]("readwrite"),s;try{s=o.put(e,t)}catch(c){return this.nextTick(i,c)}this[un](s,i)}_iterator(t){return new Al(this,this[fe],t)}_batch(t,e,n){let i=this[nr]("readwrite"),o=i.transaction,s=0,c;o.onabort=function(){n(c||o.error||new Error("aborted by user"))},o.oncomplete=function(){n()};function a(){let f=t[s++],u=f.key,h;try{h=f.type==="del"?i.delete(u):i.put(f.value,u)}catch(y){c=y,o.abort();return}s<t.length?h.onsuccess=a:typeof o.commit=="function"&&o.commit()}a()}_clear(t,e){let n,i;try{n=Tl(t)}catch{return this.nextTick(e)}if(t.limit>=0)return Bl(this,this[fe],n,t,e);try{let o=this[nr]("readwrite");i=n?o.delete(n):o.clear()}catch(o){return this.nextTick(e,o)}this[un](i,e)}_close(t){this[fn].close(),this.nextTick(t)}};Qn.destroy=function(r,t,e){typeof t=="function"&&(e=t,t=_a),e=vl(e,Ia);let n=indexedDB.deleteDatabase(t+r);return n.onsuccess=function(){e()},n.onerror=function(i){e(i)},e[Ia]};Ca.BrowserLevel=Qn});var Ra=Y(Oa=>{Oa.Level=La().BrowserLevel});var Jt=class r extends Error{constructor(e,n){super(n);this.code=e;this.name="CryptoError",Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,r)}},Ms=(o=>(o.AlgorithmNotSupported="algorithmNotSupported",o.EncodingError="encodingError",o.InvalidJwe="invalidJwe",o.InvalidJwk="invalidJwk",o.OperationNotSupported="operationNotSupported",o))(Ms||{});var hu=Ds(Js(),1);var up=new Uint8Array(0);function Vs(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function fr(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 du(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var i=0;i<r.length;i++){var o=r.charAt(i),s=o.charCodeAt(0);if(e[s]!==255)throw new TypeError(o+" is ambiguous");e[s]=i}var c=r.length,a=r.charAt(0),f=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function h(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var l=0,m=0,b=0,B=p.length;b!==B&&p[b]===0;)b++,l++;for(var w=(B-b)*u+1>>>0,P=new Uint8Array(w);b!==B;){for(var A=p[b],T=0,K=w-1;(A!==0||T<m)&&K!==-1;K--,T++)A+=256*P[K]>>>0,P[K]=A%c>>>0,A=A/c>>>0;if(A!==0)throw new Error("Non-zero carry");m=T,b++}for(var U=w-m;U!==w&&P[U]===0;)U++;for(var D=a.repeat(l);U<w;++U)D+=r.charAt(P[U]);return D}function y(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var l=0;if(p[l]!==" "){for(var m=0,b=0;p[l]===a;)m++,l++;for(var B=(p.length-l)*f+1>>>0,w=new Uint8Array(B);p[l];){var P=e[p.charCodeAt(l)];if(P===255)return;for(var A=0,T=B-1;(P!==0||A<b)&&T!==-1;T--,A++)P+=c*w[T]>>>0,w[T]=P%256>>>0,P=P/256>>>0;if(P!==0)throw new Error("Non-zero carry");b=A,l++}if(p[l]!==" "){for(var K=B-b;K!==B&&w[K]===0;)K++;for(var U=new Uint8Array(m+(B-K)),D=m;K!==B;)U[D++]=w[K++];return U}}}function x(p){var l=y(p);if(l)return l;throw new Error(`Non-${t} character`)}return{encode:h,decodeUnsafe:y,decode:x}}var pu=du,yu=pu,Hs=yu;var _i=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Ci=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Gs(this,t)}},Li=class{decoders;constructor(t){this.decoders=t}or(t){return Gs(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Gs(r,t){return new Li({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Oi=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,i){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=i,this.encoder=new _i(t,e,n),this.decoder=new Ci(t,e,i)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function qs({name:r,prefix:t,encode:e,decode:n}){return new Oi(r,t,e,n)}function Ri({name:r,prefix:t,alphabet:e}){let{encode:n,decode:i}=Hs(e,r);return qs({prefix:t,name:r,encode:n,decode:o=>fr(i(o))})}function mu(r,t,e,n){let i={};for(let u=0;u<t.length;++u)i[t[u]]=u;let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*e/8|0),c=0,a=0,f=0;for(let u=0;u<o;++u){let h=i[r[u]];if(h===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<e|h,c+=e,c>=8&&(c-=8,s[f++]=255&a>>c)}if(c>=e||255&a<<8-c)throw new SyntaxError("Unexpected end of data");return s}function wu(r,t,e){let n=t[t.length-1]==="=",i=(1<<e)-1,o="",s=0,c=0;for(let a=0;a<r.length;++a)for(c=c<<8|r[a],s+=8;s>e;)s-=e,o+=t[i&c>>s];if(s!==0&&(o+=t[i&c<<e-s]),n)for(;o.length*e&7;)o+="=";return o}function yt({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return qs({prefix:t,name:r,encode(i){return wu(i,n,e)},decode(i){return mu(i,n,e,r)}})}var Nr=yt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),mp=yt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),wp=yt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),gp=yt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),xp=yt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),bp=yt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ep=yt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),vp=yt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ni=yt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var mt=Ri({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Tp=Ri({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Pp=yt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Up=yt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Vt=yt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Kp=yt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function Fs(r){return r.byteOffset!==0||r.byteLength!==r.buffer.byteLength}function $s(r){return typeof r!="object"||r===null?!1:typeof r[Symbol.asyncIterator]=="function"}function Dr(r){let e=Object.prototype.toString.call(r).match(/\s([a-zA-Z0-9]+)/),[n,i]=e;return i}var Mr=function(r,t,e,n){function i(o){return o instanceof e?o:new e(function(s){s(o)})}return new(e||(e=Promise))(function(o,s){function c(u){try{f(n.next(u))}catch(h){s(h)}}function a(u){try{f(n.throw(u))}catch(h){s(h)}}function f(u){u.done?o(u.value):i(u.value).then(c,a)}f((n=n.apply(r,t||[])).next())})},Ws=function(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=r[Symbol.asyncIterator],e;return t?t.call(r):(r=typeof __values=="function"?__values(r):r[Symbol.iterator](),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(o){e[o]=r[o]&&function(s){return new Promise(function(c,a){s=r[o](s),i(c,a,s.done,s.value)})}}function i(o,s,c,a){Promise.resolve(a).then(function(f){o({value:f,done:c})},s)}},vn=new TextEncoder,Me=new TextDecoder,R=class r{constructor(t,e){this.data=t,this.format=e}static arrayBuffer(t){return new r(t,"ArrayBuffer")}static asyncIterable(t){if(!$s(t))throw new TypeError("Input must be of type AsyncIterable.");return new r(t,"AsyncIterable")}static base32Z(t){return new r(t,"Base32Z")}static base58Btc(t){return new r(t,"Base58Btc")}static base64Url(t){return new r(t,"Base64Url")}static bufferSource(t){return new r(t,"BufferSource")}static hex(t){if(typeof t!="string")throw new TypeError("Hex input must be a string.");if(t.length%2!==0)throw new TypeError("Hex input must have an even number of characters.");return new r(t,"Hex")}static multibase(t){return new r(t,"Multibase")}static object(t){return new r(t,"Object")}static string(t){return new r(t,"String")}static uint8Array(t){return new r(t,"Uint8Array")}toArrayBuffer(){switch(this.format){case"Base58Btc":return mt.baseDecode(this.data).buffer;case"Base64Url":return Vt.baseDecode(this.data).buffer;case"BufferSource":{if(Dr(this.data)==="ArrayBuffer")return this.data;if(ArrayBuffer.isView(this.data))return Fs(this.data)?this.data.buffer.slice(this.data.byteOffset,this.data.byteOffset+this.data.byteLength):this.data.buffer;throw new TypeError(`${this.format} value is not of type: ArrayBuffer, DataView, or TypedArray.`)}case"Hex":return this.toUint8Array().buffer;case"String":return this.toUint8Array().buffer;case"Uint8Array":return this.data.buffer;default:throw new TypeError(`Conversion from ${this.format} to ArrayBuffer is not supported.`)}}toArrayBufferAsync(){return Mr(this,void 0,void 0,function*(){switch(this.format){case"AsyncIterable":return yield(yield this.toBlobAsync()).arrayBuffer();default:throw new TypeError(`Asynchronous conversion from ${this.format} to ArrayBuffer is not supported.`)}})}toBase32Z(){switch(this.format){case"Uint8Array":return Ni.baseEncode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Base64Z is not supported.`)}}toBase58Btc(){switch(this.format){case"ArrayBuffer":{let t=new Uint8Array(this.data);return mt.baseEncode(t)}case"Multibase":return this.data.substring(1);case"Uint8Array":return mt.baseEncode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Base58Btc is not supported.`)}}toBase64Url(){switch(this.format){case"ArrayBuffer":{let t=new Uint8Array(this.data);return Vt.baseEncode(t)}case"BufferSource":{let t=this.toUint8Array();return Vt.baseEncode(t)}case"Object":{let t=JSON.stringify(this.data),e=vn.encode(t);return Vt.baseEncode(e)}case"String":{let t=vn.encode(this.data);return Vt.baseEncode(t)}case"Uint8Array":return Vt.baseEncode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Base64Url is not supported.`)}}toBlobAsync(){return Mr(this,void 0,void 0,function*(){var t,e,n,i;switch(this.format){case"AsyncIterable":{let a=[];try{for(var o=!0,s=Ws(this.data),c;c=yield s.next(),t=c.done,!t;o=!0){i=c.value,o=!1;let u=i;a.push(u)}}catch(u){e={error:u}}finally{try{!o&&!t&&(n=s.return)&&(yield n.call(s))}finally{if(e)throw e.error}}return new Blob(a)}default:throw new TypeError(`Asynchronous conversion from ${this.format} to Blob is not supported.`)}})}toHex(){let t=Array.from({length:256},(e,n)=>n.toString(16).padStart(2,"0"));switch(this.format){case"ArrayBuffer":{let e=this.toUint8Array();return r.uint8Array(e).toHex()}case"Base64Url":{let e=this.toUint8Array();return r.uint8Array(e).toHex()}case"Uint8Array":{let e="";for(let n=0;n<this.data.length;n++)e+=t[this.data[n]];return e}default:throw new TypeError(`Conversion from ${this.format} to Hex is not supported.`)}}toMultibase(){switch(this.format){case"Base58Btc":return`z${this.data}`;default:throw new TypeError(`Conversion from ${this.format} to Multibase is not supported.`)}}toObject(){switch(this.format){case"Base64Url":{let t=Vt.baseDecode(this.data),e=Me.decode(t);return JSON.parse(e)}case"String":return JSON.parse(this.data);case"Uint8Array":{let t=Me.decode(this.data);return JSON.parse(t)}default:throw new TypeError(`Conversion from ${this.format} to Object is not supported.`)}}toObjectAsync(){return Mr(this,void 0,void 0,function*(){switch(this.format){case"AsyncIterable":{let t=yield this.toStringAsync();return JSON.parse(t)}default:throw new TypeError(`Asynchronous conversion from ${this.format} to Object is not supported.`)}})}toString(){switch(this.format){case"ArrayBuffer":return Me.decode(this.data);case"Base64Url":{let t=Vt.baseDecode(this.data);return Me.decode(t)}case"Object":return JSON.stringify(this.data);case"Uint8Array":return Me.decode(this.data);default:throw new TypeError(`Conversion from ${this.format} to String is not supported.`)}}toStringAsync(){return Mr(this,void 0,void 0,function*(){var t,e,n,i;switch(this.format){case"AsyncIterable":{let a="";try{for(var o=!0,s=Ws(this.data),c;c=yield s.next(),t=c.done,!t;o=!0){i=c.value,o=!1;let f=i;typeof f=="string"?a+=f:a+=Me.decode(f,{stream:!0})}}catch(f){e={error:f}}finally{try{!o&&!t&&(n=s.return)&&(yield n.call(s))}finally{if(e)throw e.error}}return a+=Me.decode(void 0,{stream:!1}),a}default:throw new TypeError(`Asynchronous conversion from ${this.format} to String is not supported.`)}})}toUint8Array(){switch(this.format){case"ArrayBuffer":return new Uint8Array(this.data);case"Base32Z":return Ni.baseDecode(this.data);case"Base58Btc":return mt.baseDecode(this.data);case"Base64Url":return Vt.baseDecode(this.data);case"BufferSource":{let t=Dr(this.data);if(t==="Uint8Array")return this.data;if(t==="ArrayBuffer")return new Uint8Array(this.data);if(ArrayBuffer.isView(this.data))return new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength);throw new TypeError(`${this.format} value is not of type: ArrayBuffer, DataView, or TypedArray.`)}case"Hex":{let t=new Uint8Array(this.data.length/2);for(let e=0;e<this.data.length;e+=2){let n=parseInt(this.data.substring(e,e+2),16);if(isNaN(n))throw new TypeError("Input is not a valid hexadecimal string.");t[e/2]=n}return t}case"Object":{let t=JSON.stringify(this.data);return vn.encode(t)}case"String":return vn.encode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Uint8Array is not supported.`)}}toUint8ArrayAsync(){return Mr(this,void 0,void 0,function*(){switch(this.format){case"AsyncIterable":{let t=yield this.toArrayBufferAsync();return new Uint8Array(t)}default:throw new TypeError(`Asynchronous conversion from ${this.format} to Uint8Array is not supported.`)}})}};var jr;(function(r){r.Debug="debug",r.Silent="silent"})(jr||(jr={}));var Di=class{constructor(){this.logLevel=jr.Silent}setLogLevel(t){this.logLevel=t}log(t){this.info(t)}info(t){this.logLevel!==jr.Silent&&console.info(t)}error(t){this.logLevel!==jr.Silent&&console.error(t)}},gu=new Di;typeof window<"u"&&(window.web5logger=gu);var ee={};Ns(ee,{decode:()=>ur,encodeTo:()=>je,encodingLength:()=>Je});var xu=Ys,zs=128,bu=127,Eu=~bu,vu=Math.pow(2,31);function Ys(r,t,e){t=t||[],e=e||0;for(var n=e;r>=vu;)t[e++]=r&255|zs,r/=128;for(;r&Eu;)t[e++]=r&255|zs,r>>>=7;return t[e]=r|0,Ys.bytes=e-n+1,t}var Au=Mi,Bu=128,Zs=127;function Mi(r,n){var e=0,n=n||0,i=0,o=n,s,c=r.length;do{if(o>=c)throw Mi.bytes=0,new RangeError("Could not decode varint");s=r[o++],e+=i<28?(s&Zs)<<i:(s&Zs)*Math.pow(2,i),i+=7}while(s>=Bu);return Mi.bytes=o-n,e}var Tu=Math.pow(2,7),Su=Math.pow(2,14),ku=Math.pow(2,21),Pu=Math.pow(2,28),Uu=Math.pow(2,35),Ku=Math.pow(2,42),Iu=Math.pow(2,49),_u=Math.pow(2,56),Cu=Math.pow(2,63),Lu=function(r){return r<Tu?1:r<Su?2:r<ku?3:r<Pu?4:r<Uu?5:r<Ku?6:r<Iu?7:r<_u?8:r<Cu?9:10},Ou={encode:xu,decode:Au,encodingLength:Lu},Ru=Ou,Jr=Ru;function ur(r,t=0){return[Jr.decode(r,t),Jr.decode.bytes]}function je(r,t,e=0){return Jr.encode(r,t,e),t}function Je(r){return Jr.encodingLength(r)}function ji(r,t){let e=t.byteLength,n=Je(r),i=n+Je(e),o=new Uint8Array(i+e);return je(r,o,0),je(e,o,n),o.set(t,i),new hr(r,e,t,o)}function Xs(r){let t=fr(r),[e,n]=ur(t),[i,o]=ur(t.subarray(n)),s=t.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new hr(e,i,s,t)}function Qs(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Vs(r.bytes,e.bytes)}}var hr=class{code;size;digest;bytes;constructor(t,e,n,i){this.code=t,this.size=e,this.digest=n,this.bytes=i}};function tc(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return Du(e,Vi(r),t??mt.encoder);default:return Mu(e,Vi(r),t??Nr.encoder)}}var ec=new WeakMap;function Vi(r){let t=ec.get(r);if(t==null){let e=new Map;return ec.set(r,e),e}return t}var Hi=class r{code;version;multihash;bytes;"/";constructor(t,e,n,i){this.code=e,this.version=t,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:t,multihash:e}=this;if(t!==Vr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==ju)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=ji(t,e);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&Qs(t.multihash,n.multihash)}toString(t){return tc(this,t)}toJSON(){return{"/":tc(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:i,multihash:o,bytes:s}=e;return new r(n,i,o,s??rc(n,i,o.bytes))}else if(e[Ju]===!0){let{version:n,multihash:i,code:o}=e,s=Xs(i);return r.create(n,o,s)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==Vr)throw new Error(`Version 0 CID must use dag-pb (code: ${Vr}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let i=rc(t,e,n.bytes);return new r(t,e,n,i)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Vr,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,i=fr(t.subarray(n,n+e.multihashSize));if(i.byteLength!==e.multihashSize)throw new Error("Incorrect length");let o=i.subarray(e.multihashSize-e.digestSize),s=new hr(e.multihashCode,e.digestSize,o,i);return[e.version===0?r.createV0(s):r.createV1(e.codec,s),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[h,y]=ur(t.subarray(e));return e+=y,h},i=n(),o=Vr;if(i===18?(i=0,e=0):o=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let s=e,c=n(),a=n(),f=e+a,u=f-s;return{version:i,codec:o,multihashCode:c,digestSize:a,multihashSize:u,size:f}}static parse(t,e){let[n,i]=Nu(t,e),o=r.decode(i);if(o.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Vi(o).set(n,t),o}};function Nu(r,t){switch(r[0]){case"Q":{let e=t??mt;return[mt.prefix,e.decode(`${mt.prefix}${r}`)]}case mt.prefix:{let e=t??mt;return[mt.prefix,e.decode(r)]}case Nr.prefix:{let e=t??Nr;return[Nr.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function Du(r,t,e){let{prefix:n}=e;if(n!==mt.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let i=t.get(n);if(i==null){let o=e.encode(r).slice(1);return t.set(n,o),o}else return i}function Mu(r,t,e){let{prefix:n}=e,i=t.get(n);if(i==null){let o=e.encode(r);return t.set(n,o),o}else return i}var Vr=112,ju=18;function rc(r,t,e){let n=Je(r),i=n+Je(t),o=new Uint8Array(i+e.byteLength);return je(r,o,0),je(t,o,n),o.set(e,i),o}var Ju=Symbol.for("@ipld/js-cid/CID");var Ht=class r{static addPrefix(t){var e;let{code:n,data:i,name:o}=t;if(!(o?!n:n))throw new Error("Either 'name' or 'code' must be defined, but not both.");if(n=r.codeToName.has(n)?n:r.nameToCode.get(o),n===void 0)throw new Error(`Unsupported multicodec: ${(e=t.name)!==null&&e!==void 0?e:t.code}`);let s=ee.encodingLength(n),c=new Uint8Array(s+i.byteLength);return c.set(i,s),ee.encodeTo(n,c),c}static getCodeFromData(t){let{prefixedData:e}=t,[n,i]=ee.decode(e);return n}static getCodeFromName(t){let{name:e}=t,n=r.nameToCode.get(e);if(n===void 0)throw new Error(`Unsupported multicodec: ${e}`);return n}static getNameFromCode(t){let{code:e}=t,n=r.codeToName.get(e);if(n===void 0)throw new Error(`Unsupported multicodec: ${e}`);return n}static registerCodec(t){r.codeToName.set(t.code,t.name),r.nameToCode.set(t.name,t.code)}static removePrefix(t){let{prefixedData:e}=t,[n,i]=ee.decode(e),o=r.codeToName.get(n);if(o===void 0)throw new Error(`Unsupported multicodec: ${n}`);return{code:n,data:e.slice(i),name:o}}};Ht.codeToName=new Map;Ht.nameToCode=new Map;Ht.registerCodec({code:237,name:"ed25519-pub"});Ht.registerCodec({code:4864,name:"ed25519-priv"});Ht.registerCodec({code:236,name:"x25519-pub"});Ht.registerCodec({code:4866,name:"x25519-priv"});Ht.registerCodec({code:231,name:"secp256k1-pub"});Ht.registerCodec({code:4865,name:"secp256k1-priv"});function Gi(r){Object.keys(r).forEach(t=>{r[t]===void 0?delete r[t]:typeof r[t]=="object"&&Gi(r[t])})}var Sl=Ds(Ra(),1),ir=function(r,t,e,n){function i(o){return o instanceof e?o:new e(function(s){s(o)})}return new(e||(e=Promise))(function(o,s){function c(u){try{f(n.next(u))}catch(h){s(h)}}function a(u){try{f(n.throw(u))}catch(h){s(h)}}function f(u){u.done?o(u.value):i(u.value).then(c,a)}f((n=n.apply(r,t||[])).next())})};var ti=class{constructor(){this.store=new Map}clear(){return ir(this,void 0,void 0,function*(){this.store.clear()})}close(){return ir(this,void 0,void 0,function*(){})}delete(t){return ir(this,void 0,void 0,function*(){return this.store.delete(t)})}get(t){return ir(this,void 0,void 0,function*(){return this.store.get(t)})}has(t){return ir(this,void 0,void 0,function*(){return this.store.has(t)})}list(){return ir(this,void 0,void 0,function*(){return Array.from(this.store.values())})}set(t,e){return ir(this,void 0,void 0,function*(){this.store.set(t,e)})}};var Ut=class{};var ri={};Ns(ri,{bitGet:()=>Cl,bitLen:()=>_l,bitMask:()=>hn,bitSet:()=>Ll,bytesToHex:()=>he,bytesToNumberBE:()=>le,bytesToNumberLE:()=>Nt,concatBytes:()=>pe,createHmacDrbg:()=>zo,ensureBytes:()=>rt,equalBytes:()=>Kl,hexToBytes:()=>or,hexToNumber:()=>Wo,isBytes:()=>Rt,numberToBytesBE:()=>xt,numberToBytesLE:()=>de,numberToHexUnpadded:()=>ja,numberToVarBytesBE:()=>Ul,utf8ToBytes:()=>Il,validateObject:()=>Kt});var Ma=BigInt(0),ei=BigInt(1),kl=BigInt(2);function Rt(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}var Pl=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function he(r){if(!Rt(r))throw new Error("Uint8Array expected");let t="";for(let e=0;e<r.length;e++)t+=Pl[r[e]];return t}function ja(r){let t=r.toString(16);return t.length&1?`0${t}`:t}function Wo(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var ue={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Na(r){if(r>=ue._0&&r<=ue._9)return r-ue._0;if(r>=ue._A&&r<=ue._F)return r-(ue._A-10);if(r>=ue._a&&r<=ue._f)return r-(ue._a-10)}function or(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let t=r.length,e=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let i=0,o=0;i<e;i++,o+=2){let s=Na(r.charCodeAt(o)),c=Na(r.charCodeAt(o+1));if(s===void 0||c===void 0){let a=r[o]+r[o+1];throw new Error('hex string expected, got non-hex character "'+a+'" at index '+o)}n[i]=s*16+c}return n}function le(r){return Wo(he(r))}function Nt(r){if(!Rt(r))throw new Error("Uint8Array expected");return Wo(he(Uint8Array.from(r).reverse()))}function xt(r,t){return or(r.toString(16).padStart(t*2,"0"))}function de(r,t){return xt(r,t).reverse()}function Ul(r){return or(ja(r))}function rt(r,t,e){let n;if(typeof t=="string")try{n=or(t)}catch(o){throw new Error(`${r} must be valid hex string, got "${t}". Cause: ${o}`)}else if(Rt(t))n=Uint8Array.from(t);else throw new Error(`${r} must be hex string or Uint8Array`);let i=n.length;if(typeof e=="number"&&i!==e)throw new Error(`${r} expected ${e} bytes, got ${i}`);return n}function pe(...r){let t=0;for(let i=0;i<r.length;i++){let o=r[i];if(!Rt(o))throw new Error("Uint8Array expected");t+=o.length}let e=new Uint8Array(t),n=0;for(let i=0;i<r.length;i++){let o=r[i];e.set(o,n),n+=o.length}return e}function Kl(r,t){if(r.length!==t.length)return!1;let e=0;for(let n=0;n<r.length;n++)e|=r[n]^t[n];return e===0}function Il(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function _l(r){let t;for(t=0;r>Ma;r>>=ei,t+=1);return t}function Cl(r,t){return r>>BigInt(t)&ei}var Ll=(r,t,e)=>r|(e?ei:Ma)<<BigInt(t),hn=r=>(kl<<BigInt(r-1))-ei,$o=r=>new Uint8Array(r),Da=r=>Uint8Array.from(r);function zo(r,t,e){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let n=$o(r),i=$o(r),o=0,s=()=>{n.fill(1),i.fill(0),o=0},c=(...h)=>e(i,n,...h),a=(h=$o())=>{i=c(Da([0]),h),n=c(),h.length!==0&&(i=c(Da([1]),h),n=c())},f=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let h=0,y=[];for(;h<t;){n=c();let x=n.slice();y.push(x),h+=n.length}return pe(...y)};return(h,y)=>{s(),a(h);let x;for(;!(x=y(f()));)a();return s(),x}}var Ol={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"||Rt(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,t)=>t.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function Kt(r,t,e={}){let n=(i,o,s)=>{let c=Ol[o];if(typeof c!="function")throw new Error(`Invalid validator "${o}", expected function`);let a=r[i];if(!(s&&a===void 0)&&!c(a,r))throw new Error(`Invalid param ${String(i)}=${a} (${typeof a}), expected ${o}`)};for(let[i,o]of Object.entries(t))n(i,o,!1);for(let[i,o]of Object.entries(e))n(i,o,!0);return r}function Ja(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`Wrong positive integer: ${r}`)}function Rl(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Zo(r,...t){if(!Rl(r))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(r.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${r.length}`)}function Va(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Ja(r.outputLen),Ja(r.blockLen)}function kr(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function Ha(r,t){Zo(r);let e=t.outputLen;if(r.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}var ni=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Ga(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}var ii=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),Dt=(r,t)=>r<<32-t|r>>>t,Nl=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Nl)throw new Error("Non little-endian hardware is not supported");function Yo(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function ln(r){if(typeof r=="string"&&(r=Yo(r)),!Ga(r))throw new Error(`expected Uint8Array, got ${typeof r}`);return r}function oi(...r){let t=0;for(let n=0;n<r.length;n++){let i=r[n];if(!Ga(i))throw new Error("Uint8Array expected");t+=i.length}let e=new Uint8Array(t);for(let n=0,i=0;n<r.length;n++){let o=r[n];e.set(o,i),i+=o.length}return e}var Pr=class{clone(){return this._cloneInto()}},e0={}.toString;function si(r){let t=n=>r().update(ln(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function dn(r=32){if(ni&&typeof ni.getRandomValues=="function")return ni.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}function Dl(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let i=BigInt(32),o=BigInt(4294967295),s=Number(e>>i&o),c=Number(e&o),a=n?4:0,f=n?0:4;r.setUint32(t+a,s,n),r.setUint32(t+f,c,n)}var Ur=class extends Pr{constructor(t,e,n,i){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=ii(this.buffer)}update(t){kr(this);let{view:e,buffer:n,blockLen:i}=this;t=ln(t);let o=t.length;for(let s=0;s<o;){let c=Math.min(i-this.pos,o-s);if(c===i){let a=ii(t);for(;i<=o-s;s+=i)this.process(a,s);continue}n.set(t.subarray(s,s+c),this.pos),this.pos+=c,s+=c,this.pos===i&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){kr(this),Ha(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:i,isLE:o}=this,{pos:s}=this;e[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let h=s;h<i;h++)e[h]=0;Dl(n,i-8,BigInt(this.length*8),o),this.process(n,0);let c=ii(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=a/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<f;h++)c.setUint32(4*h,u[h],o)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:i,finished:o,destroyed:s,pos:c}=this;return t.length=i,t.pos=c,t.finished=o,t.destroyed=s,i%e&&t.buffer.set(n),t}};var Ml=(r,t,e)=>r&t^~r&e,jl=(r,t,e)=>r&t^r&e^t&e,Jl=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]),Pe=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ue=new Uint32Array(64),Xo=class extends Ur{constructor(){super(64,32,8,!1),this.A=Pe[0]|0,this.B=Pe[1]|0,this.C=Pe[2]|0,this.D=Pe[3]|0,this.E=Pe[4]|0,this.F=Pe[5]|0,this.G=Pe[6]|0,this.H=Pe[7]|0}get(){let{A:t,B:e,C:n,D:i,E:o,F:s,G:c,H:a}=this;return[t,e,n,i,o,s,c,a]}set(t,e,n,i,o,s,c,a){this.A=t|0,this.B=e|0,this.C=n|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=c|0,this.H=a|0}process(t,e){for(let h=0;h<16;h++,e+=4)Ue[h]=t.getUint32(e,!1);for(let h=16;h<64;h++){let y=Ue[h-15],x=Ue[h-2],p=Dt(y,7)^Dt(y,18)^y>>>3,l=Dt(x,17)^Dt(x,19)^x>>>10;Ue[h]=l+Ue[h-7]+p+Ue[h-16]|0}let{A:n,B:i,C:o,D:s,E:c,F:a,G:f,H:u}=this;for(let h=0;h<64;h++){let y=Dt(c,6)^Dt(c,11)^Dt(c,25),x=u+y+Ml(c,a,f)+Jl[h]+Ue[h]|0,l=(Dt(n,2)^Dt(n,13)^Dt(n,22))+jl(n,i,o)|0;u=f,f=a,a=c,c=s+x|0,s=o,o=i,i=n,n=x+l|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,c=c+this.E|0,a=a+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(n,i,o,s,c,a,f,u)}roundClean(){Ue.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var ci=si(()=>new Xo);var ct=BigInt(0),it=BigInt(1),sr=BigInt(2),Vl=BigInt(3),Qo=BigInt(4),qa=BigInt(5),Fa=BigInt(8),Hl=BigInt(9),Gl=BigInt(16);function X(r,t){let e=r%t;return e>=ct?e:t+e}function ts(r,t,e){if(e<=ct||t<ct)throw new Error("Expected power/modulo > 0");if(e===it)return ct;let n=it;for(;t>ct;)t&it&&(n=n*r%e),r=r*r%e,t>>=it;return n}function nt(r,t,e){let n=r;for(;t-- >ct;)n*=n,n%=e;return n}function ai(r,t){if(r===ct||t<=ct)throw new Error(`invert: expected positive integers, got n=${r} mod=${t}`);let e=X(r,t),n=t,i=ct,o=it,s=it,c=ct;for(;e!==ct;){let f=n/e,u=n%e,h=i-s*f,y=o-c*f;n=e,e=u,i=s,o=c,s=h,c=y}if(n!==it)throw new Error("invert: does not exist");return X(i,t)}function ql(r){let t=(r-it)/sr,e,n,i;for(e=r-it,n=0;e%sr===ct;e/=sr,n++);for(i=sr;i<r&&ts(i,t,r)!==r-it;i++);if(n===1){let s=(r+it)/Qo;return function(a,f){let u=a.pow(f,s);if(!a.eql(a.sqr(u),f))throw new Error("Cannot find square root");return u}}let o=(e+it)/sr;return function(c,a){if(c.pow(a,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let f=n,u=c.pow(c.mul(c.ONE,i),e),h=c.pow(a,o),y=c.pow(a,e);for(;!c.eql(y,c.ONE);){if(c.eql(y,c.ZERO))return c.ZERO;let x=1;for(let l=c.sqr(y);x<f&&!c.eql(l,c.ONE);x++)l=c.sqr(l);let p=c.pow(u,it<<BigInt(f-x-1));u=c.sqr(p),h=c.mul(h,p),y=c.mul(y,u),f=x}return h}}function Fl(r){if(r%Qo===Vl){let t=(r+it)/Qo;return function(n,i){let o=n.pow(i,t);if(!n.eql(n.sqr(o),i))throw new Error("Cannot find square root");return o}}if(r%Fa===qa){let t=(r-qa)/Fa;return function(n,i){let o=n.mul(i,sr),s=n.pow(o,t),c=n.mul(i,s),a=n.mul(n.mul(c,sr),s),f=n.mul(c,n.sub(a,n.ONE));if(!n.eql(n.sqr(f),i))throw new Error("Cannot find square root");return f}}return r%Gl,ql(r)}var $a=(r,t)=>(X(r,t)&it)===it,$l=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function es(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=$l.reduce((n,i)=>(n[i]="function",n),t);return Kt(r,e)}function Wl(r,t,e){if(e<ct)throw new Error("Expected power > 0");if(e===ct)return r.ONE;if(e===it)return t;let n=r.ONE,i=t;for(;e>ct;)e&it&&(n=r.mul(n,i)),i=r.sqr(i),e>>=it;return n}function zl(r,t){let e=new Array(t.length),n=t.reduce((o,s,c)=>r.is0(s)?o:(e[c]=o,r.mul(o,s)),r.ONE),i=r.inv(n);return t.reduceRight((o,s,c)=>r.is0(s)?o:(e[c]=r.mul(o,e[c]),r.mul(o,s)),i),e}function rs(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function Kr(r,t,e=!1,n={}){if(r<=ct)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:i,nByteLength:o}=rs(r,t);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=Fl(r),c=Object.freeze({ORDER:r,BITS:i,BYTES:o,MASK:hn(i),ZERO:ct,ONE:it,create:a=>X(a,r),isValid:a=>{if(typeof a!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof a}`);return ct<=a&&a<r},is0:a=>a===ct,isOdd:a=>(a&it)===it,neg:a=>X(-a,r),eql:(a,f)=>a===f,sqr:a=>X(a*a,r),add:(a,f)=>X(a+f,r),sub:(a,f)=>X(a-f,r),mul:(a,f)=>X(a*f,r),pow:(a,f)=>Wl(c,a,f),div:(a,f)=>X(a*ai(f,r),r),sqrN:a=>a*a,addN:(a,f)=>a+f,subN:(a,f)=>a-f,mulN:(a,f)=>a*f,inv:a=>ai(a,r),sqrt:n.sqrt||(a=>s(c,a)),invertBatch:a=>zl(c,a),cmov:(a,f,u)=>u?f:a,toBytes:a=>e?de(a,o):xt(a,o),fromBytes:a=>{if(a.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${a.length}`);return e?Nt(a):le(a)}});return Object.freeze(c)}function Wa(r,t){if(!r.isOdd)throw new Error("Field doesn't have isOdd");let e=r.sqrt(t);return r.isOdd(e)?r.neg(e):e}function za(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let t=r.toString(2).length;return Math.ceil(t/8)}function ns(r){let t=za(r);return t+Math.ceil(t/2)}function Za(r,t,e=!1){let n=r.length,i=za(t),o=ns(t);if(n<16||n<o||n>1024)throw new Error(`expected ${o}-1024 bytes of input, got ${n}`);let s=e?le(r):Nt(r),c=X(s,t-it)+it;return e?de(c,i):xt(c,i)}var Yl=BigInt(0),is=BigInt(1);function fi(r,t){let e=(i,o)=>{let s=o.negate();return i?s:o},n=i=>{let o=Math.ceil(t/i)+1,s=2**(i-1);return{windows:o,windowSize:s}};return{constTimeNegate:e,unsafeLadder(i,o){let s=r.ZERO,c=i;for(;o>Yl;)o&is&&(s=s.add(c)),c=c.double(),o>>=is;return s},precomputeWindow(i,o){let{windows:s,windowSize:c}=n(o),a=[],f=i,u=f;for(let h=0;h<s;h++){u=f,a.push(u);for(let y=1;y<c;y++)u=u.add(f),a.push(u);f=u.double()}return a},wNAF(i,o,s){let{windows:c,windowSize:a}=n(i),f=r.ZERO,u=r.BASE,h=BigInt(2**i-1),y=2**i,x=BigInt(i);for(let p=0;p<c;p++){let l=p*a,m=Number(s&h);s>>=x,m>a&&(m-=y,s+=is);let b=l,B=l+Math.abs(m)-1,w=p%2!==0,P=m<0;m===0?u=u.add(e(w,o[b])):f=f.add(e(P,o[B]))}return{p:f,f:u}},wNAFCached(i,o,s,c){let a=i._WINDOW_SIZE||1,f=o.get(i);return f||(f=this.precomputeWindow(i,a),a!==1&&o.set(i,c(f))),this.wNAF(a,f,s)}}}function pn(r){return es(r.Fp),Kt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...rs(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}function Xl(r){let t=pn(r);Kt(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:e,Fp:n,a:i}=t;if(e){if(!n.eql(i,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}var{bytesToNumberBE:Ql,hexToBytes:td}=ri,cr={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(r){let{Err:t}=cr;if(r.length<2||r[0]!==2)throw new t("Invalid signature integer tag");let e=r[1],n=r.subarray(2,e+2);if(!e||n.length!==e)throw new t("Invalid signature integer: wrong length");if(n[0]&128)throw new t("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new t("Invalid signature integer: unnecessary leading zero");return{d:Ql(n),l:r.subarray(e+2)}},toSig(r){let{Err:t}=cr,e=typeof r=="string"?td(r):r;if(!Rt(e))throw new Error("ui8a expected");let n=e.length;if(n<2||e[0]!=48)throw new t("Invalid signature tag");if(e[1]!==n-2)throw new t("Invalid signature: incorrect length");let{d:i,l:o}=cr._parseInt(e.subarray(2)),{d:s,l:c}=cr._parseInt(o);if(c.length)throw new t("Invalid signature: left bytes after parsing");return{r:i,s}},hexFromSig(r){let t=f=>Number.parseInt(f[0],16)&8?"00"+f:f,e=f=>{let u=f.toString(16);return u.length&1?`0${u}`:u},n=t(e(r.s)),i=t(e(r.r)),o=n.length/2,s=i.length/2,c=e(o),a=e(s);return`30${e(s+o+4)}02${a}${i}02${c}${n}`}},ye=BigInt(0),It=BigInt(1),m0=BigInt(2),Ya=BigInt(3),w0=BigInt(4);function ed(r){let t=Xl(r),{Fp:e}=t,n=t.toBytes||((p,l,m)=>{let b=l.toAffine();return pe(Uint8Array.from([4]),e.toBytes(b.x),e.toBytes(b.y))}),i=t.fromBytes||(p=>{let l=p.subarray(1),m=e.fromBytes(l.subarray(0,e.BYTES)),b=e.fromBytes(l.subarray(e.BYTES,2*e.BYTES));return{x:m,y:b}});function o(p){let{a:l,b:m}=t,b=e.sqr(p),B=e.mul(b,p);return e.add(e.add(B,e.mul(p,l)),m)}if(!e.eql(e.sqr(t.Gy),o(t.Gx)))throw new Error("bad generator point: equation left != right");function s(p){return typeof p=="bigint"&&ye<p&&p<t.n}function c(p){if(!s(p))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function a(p){let{allowedPrivateKeyLengths:l,nByteLength:m,wrapPrivateKey:b,n:B}=t;if(l&&typeof p!="bigint"){if(Rt(p)&&(p=he(p)),typeof p!="string"||!l.includes(p.length))throw new Error("Invalid key");p=p.padStart(m*2,"0")}let w;try{w=typeof p=="bigint"?p:le(rt("private key",p,m))}catch{throw new Error(`private key must be ${m} bytes, hex or bigint, not ${typeof p}`)}return b&&(w=X(w,B)),c(w),w}let f=new Map;function u(p){if(!(p instanceof h))throw new Error("ProjectivePoint expected")}class h{constructor(l,m,b){if(this.px=l,this.py=m,this.pz=b,l==null||!e.isValid(l))throw new Error("x required");if(m==null||!e.isValid(m))throw new Error("y required");if(b==null||!e.isValid(b))throw new Error("z required")}static fromAffine(l){let{x:m,y:b}=l||{};if(!l||!e.isValid(m)||!e.isValid(b))throw new Error("invalid affine point");if(l instanceof h)throw new Error("projective point not allowed");let B=w=>e.eql(w,e.ZERO);return B(m)&&B(b)?h.ZERO:new h(m,b,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(l){let m=e.invertBatch(l.map(b=>b.pz));return l.map((b,B)=>b.toAffine(m[B])).map(h.fromAffine)}static fromHex(l){let m=h.fromAffine(i(rt("pointHex",l)));return m.assertValidity(),m}static fromPrivateKey(l){return h.BASE.multiply(a(l))}_setWindowSize(l){this._WINDOW_SIZE=l,f.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!e.is0(this.py))return;throw new Error("bad point: ZERO")}let{x:l,y:m}=this.toAffine();if(!e.isValid(l)||!e.isValid(m))throw new Error("bad point: x or y not FE");let b=e.sqr(m),B=o(l);if(!e.eql(b,B))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:l}=this.toAffine();if(e.isOdd)return!e.isOdd(l);throw new Error("Field doesn't support isOdd")}equals(l){u(l);let{px:m,py:b,pz:B}=this,{px:w,py:P,pz:A}=l,T=e.eql(e.mul(m,A),e.mul(w,B)),K=e.eql(e.mul(b,A),e.mul(P,B));return T&&K}negate(){return new h(this.px,e.neg(this.py),this.pz)}double(){let{a:l,b:m}=t,b=e.mul(m,Ya),{px:B,py:w,pz:P}=this,A=e.ZERO,T=e.ZERO,K=e.ZERO,U=e.mul(B,B),D=e.mul(w,w),O=e.mul(P,P),_=e.mul(B,w);return _=e.add(_,_),K=e.mul(B,P),K=e.add(K,K),A=e.mul(l,K),T=e.mul(b,O),T=e.add(A,T),A=e.sub(D,T),T=e.add(D,T),T=e.mul(A,T),A=e.mul(_,A),K=e.mul(b,K),O=e.mul(l,O),_=e.sub(U,O),_=e.mul(l,_),_=e.add(_,K),K=e.add(U,U),U=e.add(K,U),U=e.add(U,O),U=e.mul(U,_),T=e.add(T,U),O=e.mul(w,P),O=e.add(O,O),U=e.mul(O,_),A=e.sub(A,U),K=e.mul(O,D),K=e.add(K,K),K=e.add(K,K),new h(A,T,K)}add(l){u(l);let{px:m,py:b,pz:B}=this,{px:w,py:P,pz:A}=l,T=e.ZERO,K=e.ZERO,U=e.ZERO,D=t.a,O=e.mul(t.b,Ya),_=e.mul(m,w),j=e.mul(b,P),M=e.mul(B,A),W=e.add(m,b),E=e.add(w,P);W=e.mul(W,E),E=e.add(_,j),W=e.sub(W,E),E=e.add(m,B);let k=e.add(w,A);return E=e.mul(E,k),k=e.add(_,M),E=e.sub(E,k),k=e.add(b,B),T=e.add(P,A),k=e.mul(k,T),T=e.add(j,M),k=e.sub(k,T),U=e.mul(D,E),T=e.mul(O,M),U=e.add(T,U),T=e.sub(j,U),U=e.add(j,U),K=e.mul(T,U),j=e.add(_,_),j=e.add(j,_),M=e.mul(D,M),E=e.mul(O,E),j=e.add(j,M),M=e.sub(_,M),M=e.mul(D,M),E=e.add(E,M),_=e.mul(j,E),K=e.add(K,_),_=e.mul(k,E),T=e.mul(W,T),T=e.sub(T,_),_=e.mul(W,j),U=e.mul(k,U),U=e.add(U,_),new h(T,K,U)}subtract(l){return this.add(l.negate())}is0(){return this.equals(h.ZERO)}wNAF(l){return x.wNAFCached(this,f,l,m=>{let b=e.invertBatch(m.map(B=>B.pz));return m.map((B,w)=>B.toAffine(b[w])).map(h.fromAffine)})}multiplyUnsafe(l){let m=h.ZERO;if(l===ye)return m;if(c(l),l===It)return this;let{endo:b}=t;if(!b)return x.unsafeLadder(this,l);let{k1neg:B,k1:w,k2neg:P,k2:A}=b.splitScalar(l),T=m,K=m,U=this;for(;w>ye||A>ye;)w&It&&(T=T.add(U)),A&It&&(K=K.add(U)),U=U.double(),w>>=It,A>>=It;return B&&(T=T.negate()),P&&(K=K.negate()),K=new h(e.mul(K.px,b.beta),K.py,K.pz),T.add(K)}multiply(l){c(l);let m=l,b,B,{endo:w}=t;if(w){let{k1neg:P,k1:A,k2neg:T,k2:K}=w.splitScalar(m),{p:U,f:D}=this.wNAF(A),{p:O,f:_}=this.wNAF(K);U=x.constTimeNegate(P,U),O=x.constTimeNegate(T,O),O=new h(e.mul(O.px,w.beta),O.py,O.pz),b=U.add(O),B=D.add(_)}else{let{p:P,f:A}=this.wNAF(m);b=P,B=A}return h.normalizeZ([b,B])[0]}multiplyAndAddUnsafe(l,m,b){let B=h.BASE,w=(A,T)=>T===ye||T===It||!A.equals(B)?A.multiplyUnsafe(T):A.multiply(T),P=w(this,m).add(w(l,b));return P.is0()?void 0:P}toAffine(l){let{px:m,py:b,pz:B}=this,w=this.is0();l==null&&(l=w?e.ONE:e.inv(B));let P=e.mul(m,l),A=e.mul(b,l),T=e.mul(B,l);if(w)return{x:e.ZERO,y:e.ZERO};if(!e.eql(T,e.ONE))throw new Error("invZ was invalid");return{x:P,y:A}}isTorsionFree(){let{h:l,isTorsionFree:m}=t;if(l===It)return!0;if(m)return m(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:l,clearCofactor:m}=t;return l===It?this:m?m(h,this):this.multiplyUnsafe(t.h)}toRawBytes(l=!0){return this.assertValidity(),n(h,this,l)}toHex(l=!0){return he(this.toRawBytes(l))}}h.BASE=new h(t.Gx,t.Gy,e.ONE),h.ZERO=new h(e.ZERO,e.ONE,e.ZERO);let y=t.nBitLength,x=fi(h,t.endo?Math.ceil(y/2):y);return{CURVE:t,ProjectivePoint:h,normPrivateKeyToScalar:a,weierstrassEquation:o,isWithinCurveOrder:s}}function rd(r){let t=pn(r);return Kt(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Xa(r){let t=rd(r),{Fp:e,n}=t,i=e.BYTES+1,o=2*e.BYTES+1;function s(E){return ye<E&&E<e.ORDER}function c(E){return X(E,n)}function a(E){return ai(E,n)}let{ProjectivePoint:f,normPrivateKeyToScalar:u,weierstrassEquation:h,isWithinCurveOrder:y}=ed({...t,toBytes(E,k,L){let v=k.toAffine(),d=e.toBytes(v.x),S=pe;return L?S(Uint8Array.from([k.hasEvenY()?2:3]),d):S(Uint8Array.from([4]),d,e.toBytes(v.y))},fromBytes(E){let k=E.length,L=E[0],v=E.subarray(1);if(k===i&&(L===2||L===3)){let d=le(v);if(!s(d))throw new Error("Point is not on curve");let S=h(d),I=e.sqrt(S),C=(I&It)===It;return(L&1)===1!==C&&(I=e.neg(I)),{x:d,y:I}}else if(k===o&&L===4){let d=e.fromBytes(v.subarray(0,e.BYTES)),S=e.fromBytes(v.subarray(e.BYTES,2*e.BYTES));return{x:d,y:S}}else throw new Error(`Point of length ${k} was invalid. Expected ${i} compressed bytes or ${o} uncompressed bytes`)}}),x=E=>he(xt(E,t.nByteLength));function p(E){let k=n>>It;return E>k}function l(E){return p(E)?c(-E):E}let m=(E,k,L)=>le(E.slice(k,L));class b{constructor(k,L,v){this.r=k,this.s=L,this.recovery=v,this.assertValidity()}static fromCompact(k){let L=t.nByteLength;return k=rt("compactSignature",k,L*2),new b(m(k,0,L),m(k,L,2*L))}static fromDER(k){let{r:L,s:v}=cr.toSig(rt("DER",k));return new b(L,v)}assertValidity(){if(!y(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!y(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(k){return new b(this.r,this.s,k)}recoverPublicKey(k){let{r:L,s:v,recovery:d}=this,S=K(rt("msgHash",k));if(d==null||![0,1,2,3].includes(d))throw new Error("recovery id invalid");let I=d===2||d===3?L+t.n:L;if(I>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let C=d&1?"03":"02",J=f.fromHex(C+x(I)),V=a(I),z=c(-S*V),G=c(v*V),q=f.BASE.multiplyAndAddUnsafe(J,z,G);if(!q)throw new Error("point at infinify");return q.assertValidity(),q}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new b(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return or(this.toDERHex())}toDERHex(){return cr.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return or(this.toCompactHex())}toCompactHex(){return x(this.r)+x(this.s)}}let B={isValidPrivateKey(E){try{return u(E),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{let E=ns(t.n);return Za(t.randomBytes(E),t.n)},precompute(E=8,k=f.BASE){return k._setWindowSize(E),k.multiply(BigInt(3)),k}};function w(E,k=!0){return f.fromPrivateKey(E).toRawBytes(k)}function P(E){let k=Rt(E),L=typeof E=="string",v=(k||L)&&E.length;return k?v===i||v===o:L?v===2*i||v===2*o:E instanceof f}function A(E,k,L=!0){if(P(E))throw new Error("first arg must be private key");if(!P(k))throw new Error("second arg must be public key");return f.fromHex(k).multiply(u(E)).toRawBytes(L)}let T=t.bits2int||function(E){let k=le(E),L=E.length*8-t.nBitLength;return L>0?k>>BigInt(L):k},K=t.bits2int_modN||function(E){return c(T(E))},U=hn(t.nBitLength);function D(E){if(typeof E!="bigint")throw new Error("bigint expected");if(!(ye<=E&&E<U))throw new Error(`bigint expected < 2^${t.nBitLength}`);return xt(E,t.nByteLength)}function O(E,k,L=_){if(["recovered","canonical"].some(Q=>Q in L))throw new Error("sign() legacy options not supported");let{hash:v,randomBytes:d}=t,{lowS:S,prehash:I,extraEntropy:C}=L;S==null&&(S=!0),E=rt("msgHash",E),I&&(E=rt("prehashed msgHash",v(E)));let J=K(E),V=u(k),z=[D(V),D(J)];if(C!=null){let Q=C===!0?d(e.BYTES):C;z.push(rt("extraEntropy",Q))}let G=pe(...z),q=J;function et(Q){let ut=T(Q);if(!y(ut))return;let ht=a(ut),st=f.BASE.multiply(ut).toAffine(),dt=c(st.x);if(dt===ye)return;let te=c(ht*c(q+dt*V));if(te===ye)return;let De=(st.x===dt?0:2)|Number(st.y&It),Rr=te;return S&&p(te)&&(Rr=l(te),De^=1),new b(dt,Rr,De)}return{seed:G,k2sig:et}}let _={lowS:t.lowS,prehash:!1},j={lowS:t.lowS,prehash:!1};function M(E,k,L=_){let{seed:v,k2sig:d}=O(E,k,L),S=t;return zo(S.hash.outputLen,S.nByteLength,S.hmac)(v,d)}f.BASE._setWindowSize(8);function W(E,k,L,v=j){let d=E;if(k=rt("msgHash",k),L=rt("publicKey",L),"strict"in v)throw new Error("options.strict was renamed to lowS");let{lowS:S,prehash:I}=v,C,J;try{if(typeof d=="string"||Rt(d))try{C=b.fromDER(d)}catch(st){if(!(st instanceof cr.Err))throw st;C=b.fromCompact(d)}else if(typeof d=="object"&&typeof d.r=="bigint"&&typeof d.s=="bigint"){let{r:st,s:dt}=d;C=new b(st,dt)}else throw new Error("PARSE");J=f.fromHex(L)}catch(st){if(st.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(S&&C.hasHighS())return!1;I&&(k=t.hash(k));let{r:V,s:z}=C,G=K(k),q=a(z),et=c(G*q),Q=c(V*q),ut=f.BASE.multiplyAndAddUnsafe(J,et,Q)?.toAffine();return ut?c(ut.x)===V:!1}return{CURVE:t,getPublicKey:w,getSharedSecret:A,sign:M,verify:W,ProjectivePoint:f,Signature:b,utils:B}}var ui=class extends Pr{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,Va(t);let n=ln(e);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let i=this.blockLen,o=new Uint8Array(i);o.set(n.length>i?t.create().update(n).digest():n);for(let s=0;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=t.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),o.fill(0)}update(t){return kr(this),this.iHash.update(t),this}digestInto(t){kr(this),Zo(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:e,iHash:n,finished:i,destroyed:o,blockLen:s,outputLen:c}=this;return t=t,t.finished=i,t.destroyed=o,t.blockLen=s,t.outputLen=c,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},os=(r,t,e)=>new ui(r,t).update(e).digest();os.create=(r,t)=>new ui(r,t);function nd(r){return{hash:r,hmac:(t,...e)=>os(r,t,oi(...e)),randomBytes:dn}}function hi(r,t){let e=n=>Xa({...r,...nd(n)});return Object.freeze({...e(t),create:e})}var ef=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Qa=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),id=BigInt(1),ss=BigInt(2),tf=(r,t)=>(r+t/ss)/t;function od(r){let t=ef,e=BigInt(3),n=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),c=BigInt(44),a=BigInt(88),f=r*r*r%t,u=f*f*r%t,h=nt(u,e,t)*u%t,y=nt(h,e,t)*u%t,x=nt(y,ss,t)*f%t,p=nt(x,i,t)*x%t,l=nt(p,o,t)*p%t,m=nt(l,c,t)*l%t,b=nt(m,a,t)*m%t,B=nt(b,c,t)*l%t,w=nt(B,e,t)*u%t,P=nt(w,s,t)*p%t,A=nt(P,n,t)*f%t,T=nt(A,ss,t);if(!cs.eql(cs.sqr(T),r))throw new Error("Cannot find square root");return T}var cs=Kr(ef,void 0,void 0,{sqrt:od}),bt=hi({a:BigInt(0),b:BigInt(7),Fp:cs,n:Qa,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=Qa,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-id*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=e,s=BigInt("0x100000000000000000000000000000000"),c=tf(o*r,t),a=tf(-n*r,t),f=X(r-c*e-a*i,t),u=X(-c*n-a*o,t),h=f>s,y=u>s;if(h&&(f=t-f),y&&(u=t-u),f>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:h,k1:f,k2neg:y,k2:u}}}},ci),U0=BigInt(0);var K0=bt.ProjectivePoint;function sd(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function li(r,...t){if(!sd(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${r.length}`)}function as(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function rf(r,t){li(r);let e=t.outputLen;if(r.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}var me=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var pi=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),Mt=(r,t)=>r<<32-t|r>>>t;var R0=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function cd(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function fs(r){return typeof r=="string"&&(r=cd(r)),li(r),r}function us(...r){let t=0;for(let n=0;n<r.length;n++){let i=r[n];li(i),t+=i.length}let e=new Uint8Array(t);for(let n=0,i=0;n<r.length;n++){let o=r[n];e.set(o,i),i+=o.length}return e}var di=class{clone(){return this._cloneInto()}},N0={}.toString;function nf(r){let t=n=>r().update(fs(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function of(r=32){if(me&&typeof me.getRandomValues=="function")return me.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}function ad(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let i=BigInt(32),o=BigInt(4294967295),s=Number(e>>i&o),c=Number(e&o),a=n?4:0,f=n?0:4;r.setUint32(t+a,s,n),r.setUint32(t+f,c,n)}var sf=(r,t,e)=>r&t^~r&e,cf=(r,t,e)=>r&t^r&e^t&e,yi=class extends di{constructor(t,e,n,i){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=pi(this.buffer)}update(t){as(this);let{view:e,buffer:n,blockLen:i}=this;t=fs(t);let o=t.length;for(let s=0;s<o;){let c=Math.min(i-this.pos,o-s);if(c===i){let a=pi(t);for(;i<=o-s;s+=i)this.process(a,s);continue}n.set(t.subarray(s,s+c),this.pos),this.pos+=c,s+=c,this.pos===i&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){as(this),rf(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:i,isLE:o}=this,{pos:s}=this;e[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let h=s;h<i;h++)e[h]=0;ad(n,i-8,BigInt(this.length*8),o),this.process(n,0);let c=pi(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=a/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<f;h++)c.setUint32(4*h,u[h],o)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:i,finished:o,destroyed:s,pos:c}=this;return t.length=i,t.pos=c,t.finished=o,t.destroyed=s,i%e&&t.buffer.set(n),t}};var fd=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ke=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ie=new Uint32Array(64),hs=class extends yi{constructor(){super(64,32,8,!1),this.A=Ke[0]|0,this.B=Ke[1]|0,this.C=Ke[2]|0,this.D=Ke[3]|0,this.E=Ke[4]|0,this.F=Ke[5]|0,this.G=Ke[6]|0,this.H=Ke[7]|0}get(){let{A:t,B:e,C:n,D:i,E:o,F:s,G:c,H:a}=this;return[t,e,n,i,o,s,c,a]}set(t,e,n,i,o,s,c,a){this.A=t|0,this.B=e|0,this.C=n|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=c|0,this.H=a|0}process(t,e){for(let h=0;h<16;h++,e+=4)Ie[h]=t.getUint32(e,!1);for(let h=16;h<64;h++){let y=Ie[h-15],x=Ie[h-2],p=Mt(y,7)^Mt(y,18)^y>>>3,l=Mt(x,17)^Mt(x,19)^x>>>10;Ie[h]=l+Ie[h-7]+p+Ie[h-16]|0}let{A:n,B:i,C:o,D:s,E:c,F:a,G:f,H:u}=this;for(let h=0;h<64;h++){let y=Mt(c,6)^Mt(c,11)^Mt(c,25),x=u+y+sf(c,a,f)+fd[h]+Ie[h]|0,l=(Mt(n,2)^Mt(n,13)^Mt(n,22))+cf(n,i,o)|0;u=f,f=a,a=c,c=s+x|0,s=o,o=i,i=n,n=x+l|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,c=c+this.E|0,a=a+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(n,i,o,s,c,a,f,u)}roundClean(){Ie.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var zt=nf(()=>new hs);function af(r){let t=n=>{if(n!==null&&typeof n=="object"&&!Array.isArray(n)){let i=Object.keys(n).sort(),o={};for(let s of i)o[s]=t(n[s]);return o}return n},e=t(r);return JSON.stringify(e)}var Ir=class{static async digest({data:t}){return zt(t)}};var ls="urn:jwk:";async function H({jwk:r}){let t=r.kty,e;if(t==="EC")e={crv:r.crv,kty:r.kty,x:r.x,y:r.y};else if(t==="oct")e={k:r.k,kty:r.kty};else if(t==="OKP")e={crv:r.crv,kty:r.kty,x:r.x};else if(t==="RSA")e={e:r.e,kty:r.kty,n:r.n};else throw new Error(`Unsupported key type: ${t}`);Gi(e);let n=af(e),i=R.string(n).toUint8Array(),o=await Ir.digest({data:i});return R.uint8Array(o).toBase64Url()}function Zt(r){return!(!r||typeof r!="object"||!("kty"in r&&"crv"in r&&"x"in r&&"d"in r)||r.kty!=="EC"||typeof r.d!="string"||typeof r.x!="string")}function _r(r){return!(!r||typeof r!="object"||!("kty"in r&&"crv"in r&&"x"in r)||"d"in r||r.kty!=="EC"||typeof r.x!="string")}function Yt(r){return!(!r||typeof r!="object"||!("kty"in r&&"k"in r)||r.kty!=="oct"||typeof r.k!="string")}function Xt(r){return!(!r||typeof r!="object"||!("kty"in r&&"crv"in r&&"x"in r&&"d"in r)||r.kty!=="OKP"||typeof r.d!="string"||typeof r.x!="string")}function Cr(r){return!(!r||typeof r!="object"||"d"in r||!("kty"in r&&"crv"in r&&"x"in r)||r.kty!=="OKP"||typeof r.x!="string")}function ff(r){if(!r||typeof r!="object")return!1;switch(r.kty){case"EC":case"OKP":case"RSA":return"d"in r;case"oct":return"k"in r;default:return!1}}function Y0(r){if(!r||typeof r!="object")return!1;switch(r.kty){case"EC":case"OKP":return"x"in r&&!("d"in r);case"RSA":return"n"in r&&"e"in r&&!("d"in r);default:return!1}}var _e=class r{static async adjustSignatureToLowS({signature:t}){let e=bt.Signature.fromCompact(t);return e.hasHighS()?e.normalizeS().toCompactRawBytes():t}static async bytesToPrivateKey({privateKeyBytes:t}){let e=await r.getCurvePoint({keyBytes:t}),n={kty:"EC",crv:"secp256k1",d:R.uint8Array(t).toBase64Url(),x:R.uint8Array(e.x).toBase64Url(),y:R.uint8Array(e.y).toBase64Url()};return n.kid=await H({jwk:n}),n}static async bytesToPublicKey({publicKeyBytes:t}){let e=await r.getCurvePoint({keyBytes:t}),n={kty:"EC",crv:"secp256k1",x:R.uint8Array(e.x).toBase64Url(),y:R.uint8Array(e.y).toBase64Url()};return n.kid=await H({jwk:n}),n}static async compressPublicKey({publicKeyBytes:t}){return bt.ProjectivePoint.fromHex(t).toRawBytes(!0)}static async computePublicKey({key:t}){let e=await r.privateKeyToBytes({privateKey:t}),n=await r.getCurvePoint({keyBytes:e}),i={kty:"EC",crv:"secp256k1",x:R.uint8Array(n.x).toBase64Url(),y:R.uint8Array(n.y).toBase64Url()};return i.kid=await H({jwk:i}),i}static async convertDerToCompactSignature({derSignature:t}){return bt.Signature.fromDER(t).toCompactRawBytes()}static async decompressPublicKey({publicKeyBytes:t}){return bt.ProjectivePoint.fromHex(t).toRawBytes(!1)}static async generateKey(){let t=bt.utils.randomPrivateKey(),e=await r.bytesToPrivateKey({privateKeyBytes:t});return e.kid=await H({jwk:e}),e}static async getPublicKey({key:t}){if(!(Zt(t)&&t.crv==="secp256k1"))throw new Error("Secp256k1: The provided key is not a secp256k1 private JWK.");let{d:e,...n}=t;return n.kid??=await H({jwk:n}),n}static async privateKeyToBytes({privateKey:t}){if(!Zt(t))throw new Error("Secp256k1: The provided key is not a valid EC private key.");return R.base64Url(t.d).toUint8Array()}static async publicKeyToBytes({publicKey:t}){if(!(_r(t)&&t.y))throw new Error("Secp256k1: The provided key is not a valid EC public key.");let e=new Uint8Array([4]),n=R.base64Url(t.x).toUint8Array(),i=R.base64Url(t.y).toUint8Array();return new Uint8Array([...e,...n,...i])}static async sharedSecret({privateKeyA:t,publicKeyB:e}){if("x"in t&&"x"in e&&t.x===e.x)throw new Error("Secp256k1: ECDH shared secret cannot be computed from a single key pair's public and private keys.");let n=await r.privateKeyToBytes({privateKey:t}),i=await r.publicKeyToBytes({publicKey:e});return bt.getSharedSecret(n,i,!0).slice(1)}static async sign({data:t,key:e}){let n=await r.privateKeyToBytes({privateKey:e}),i=zt(t);return bt.sign(i,n).toCompactRawBytes()}static async validatePrivateKey({privateKeyBytes:t}){return bt.utils.isValidPrivateKey(t)}static async validatePublicKey({publicKeyBytes:t}){try{bt.ProjectivePoint.fromHex(t).assertValidity()}catch{return!1}return!0}static async verify({key:t,signature:e,data:n}){let i=await r.publicKeyToBytes({publicKey:t}),o=zt(n);return bt.verify(e,o,i,{lowS:!1})}static async getCurvePoint({keyBytes:t}){t.byteLength===32&&(t=bt.getPublicKey(t));let e=bt.ProjectivePoint.fromHex(t),n=xt(e.x,32),i=xt(e.y,32);return{x:n,y:i}}};var uf=Kr(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),ud=uf.create(BigInt("-3")),hd=BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),ld=hi({a:ud,b:hd,Fp:uf,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},ci),Bt=ld;var Ce=class r{static async adjustSignatureToLowS({signature:t}){let e=Bt.Signature.fromCompact(t);return e.hasHighS()?e.normalizeS().toCompactRawBytes():t}static async bytesToPrivateKey({privateKeyBytes:t}){let e=await r.getCurvePoint({keyBytes:t}),n={kty:"EC",crv:"P-256",d:R.uint8Array(t).toBase64Url(),x:R.uint8Array(e.x).toBase64Url(),y:R.uint8Array(e.y).toBase64Url()};return n.kid=await H({jwk:n}),n}static async bytesToPublicKey({publicKeyBytes:t}){let e=await r.getCurvePoint({keyBytes:t}),n={kty:"EC",crv:"P-256",x:R.uint8Array(e.x).toBase64Url(),y:R.uint8Array(e.y).toBase64Url()};return n.kid=await H({jwk:n}),n}static async compressPublicKey({publicKeyBytes:t}){return Bt.ProjectivePoint.fromHex(t).toRawBytes(!0)}static async computePublicKey({key:t}){let e=await r.privateKeyToBytes({privateKey:t}),n=await r.getCurvePoint({keyBytes:e}),i={kty:"EC",crv:"P-256",x:R.uint8Array(n.x).toBase64Url(),y:R.uint8Array(n.y).toBase64Url()};return i.kid=await H({jwk:i}),i}static async convertDerToCompactSignature({derSignature:t}){return Bt.Signature.fromDER(t).toCompactRawBytes()}static async decompressPublicKey({publicKeyBytes:t}){return Bt.ProjectivePoint.fromHex(t).toRawBytes(!1)}static async generateKey(){let t=Bt.utils.randomPrivateKey(),e=await r.bytesToPrivateKey({privateKeyBytes:t});return e.kid=await H({jwk:e}),e}static async getPublicKey({key:t}){if(!(Zt(t)&&t.crv==="P-256"))throw new Error("Secp256r1: The provided key is not a 'P-256' private JWK.");let{d:e,...n}=t;return n.kid??=await H({jwk:n}),n}static async privateKeyToBytes({privateKey:t}){if(!Zt(t))throw new Error("Secp256r1: The provided key is not a valid EC private key.");return R.base64Url(t.d).toUint8Array()}static async publicKeyToBytes({publicKey:t}){if(!(_r(t)&&t.y))throw new Error("Secp256r1: The provided key is not a valid EC public key.");let e=new Uint8Array([4]),n=R.base64Url(t.x).toUint8Array(),i=R.base64Url(t.y).toUint8Array();return new Uint8Array([...e,...n,...i])}static async sharedSecret({privateKeyA:t,publicKeyB:e}){if("x"in t&&"x"in e&&t.x===e.x)throw new Error("Secp256r1: ECDH shared secret cannot be computed from a single key pair's public and private keys.");let n=await r.privateKeyToBytes({privateKey:t}),i=await r.publicKeyToBytes({publicKey:e});return Bt.getSharedSecret(n,i,!0).slice(1)}static async sign({data:t,key:e}){let n=await r.privateKeyToBytes({privateKey:e}),i=zt(t);return Bt.sign(i,n).toCompactRawBytes()}static async validatePrivateKey({privateKeyBytes:t}){return Bt.utils.isValidPrivateKey(t)}static async validatePublicKey({publicKeyBytes:t}){try{Bt.ProjectivePoint.fromHex(t).assertValidity()}catch{return!1}return!0}static async verify({key:t,signature:e,data:n}){let i=await r.publicKeyToBytes({publicKey:t}),o=zt(n);return Bt.verify(e,o,i,{lowS:!1})}static async getCurvePoint({keyBytes:t}){t.byteLength===32&&(t=Bt.getPublicKey(t));let e=Bt.ProjectivePoint.fromHex(t),n=xt(e.x,32),i=xt(e.y,32);return{x:n,y:i}}};var yn=class extends Ut{async computePublicKey({key:t}){if(!Zt(t))throw new TypeError("Invalid key provided. Must be an elliptic curve (EC) private key.");switch(t.crv){case"secp256k1":{let e=await _e.computePublicKey({key:t});return e.alg="ES256K",e}case"P-256":{let e=await Ce.computePublicKey({key:t});return e.alg="ES256",e}default:throw new Error(`Unsupported curve: ${t.crv}`)}}async generateKey({algorithm:t}){switch(t){case"ES256K":case"secp256k1":{let e=await _e.generateKey();return e.alg="ES256K",e}case"ES256":case"secp256r1":{let e=await Ce.generateKey();return e.alg="ES256",e}}}async getPublicKey({key:t}){if(!Zt(t))throw new TypeError("Invalid key provided. Must be an elliptic curve (EC) private key.");switch(t.crv){case"secp256k1":{let e=await _e.getPublicKey({key:t});return e.alg="ES256K",e}case"P-256":{let e=await Ce.getPublicKey({key:t});return e.alg="ES256",e}default:throw new Error(`Unsupported curve: ${t.crv}`)}}async sign({key:t,data:e}){if(!Zt(t))throw new TypeError("Invalid key provided. Must be an elliptic curve (EC) private key.");switch(t.crv){case"secp256k1":return await _e.sign({key:t,data:e});case"P-256":return await Ce.sign({key:t,data:e});default:throw new Error(`Unsupported curve: ${t.crv}`)}}async verify({key:t,signature:e,data:n}){if(!_r(t))throw new TypeError("Invalid key provided. Must be an elliptic curve (EC) public key.");switch(t.crv){case"secp256k1":return await _e.verify({key:t,signature:e,data:n});case"P-256":return await Ce.verify({key:t,signature:e,data:n});default:throw new Error(`Unsupported curve: ${t.crv}`)}}};var mi=BigInt(4294967295),ds=BigInt(32);function hf(r,t=!1){return t?{h:Number(r&mi),l:Number(r>>ds&mi)}:{h:Number(r>>ds&mi)|0,l:Number(r&mi)|0}}function dd(r,t=!1){let e=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let i=0;i<r.length;i++){let{h:o,l:s}=hf(r[i],t);[e[i],n[i]]=[o,s]}return[e,n]}var pd=(r,t)=>BigInt(r>>>0)<<ds|BigInt(t>>>0),yd=(r,t,e)=>r>>>e,md=(r,t,e)=>r<<32-e|t>>>e,wd=(r,t,e)=>r>>>e|t<<32-e,gd=(r,t,e)=>r<<32-e|t>>>e,xd=(r,t,e)=>r<<64-e|t>>>e-32,bd=(r,t,e)=>r>>>e-32|t<<64-e,Ed=(r,t)=>t,vd=(r,t)=>r,Ad=(r,t,e)=>r<<e|t>>>32-e,Bd=(r,t,e)=>t<<e|r>>>32-e,Td=(r,t,e)=>t<<e-32|r>>>64-e,Sd=(r,t,e)=>r<<e-32|t>>>64-e;function kd(r,t,e,n){let i=(t>>>0)+(n>>>0);return{h:r+e+(i/2**32|0)|0,l:i|0}}var Pd=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),Ud=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,Kd=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),Id=(r,t,e,n,i)=>t+e+n+i+(r/2**32|0)|0,_d=(r,t,e,n,i)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(i>>>0),Cd=(r,t,e,n,i,o)=>t+e+n+i+o+(r/2**32|0)|0;var Ld={fromBig:hf,split:dd,toBig:pd,shrSH:yd,shrSL:md,rotrSH:wd,rotrSL:gd,rotrBH:xd,rotrBL:bd,rotr32H:Ed,rotr32L:vd,rotlSH:Ad,rotlSL:Bd,rotlBH:Td,rotlBL:Sd,add:kd,add3L:Pd,add3H:Ud,add4L:Kd,add4H:Id,add5H:Cd,add5L:_d},F=Ld;var[Od,Rd]=F.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),Le=new Uint32Array(80),Oe=new Uint32Array(80),ps=class extends Ur{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:t,Al:e,Bh:n,Bl:i,Ch:o,Cl:s,Dh:c,Dl:a,Eh:f,El:u,Fh:h,Fl:y,Gh:x,Gl:p,Hh:l,Hl:m}=this;return[t,e,n,i,o,s,c,a,f,u,h,y,x,p,l,m]}set(t,e,n,i,o,s,c,a,f,u,h,y,x,p,l,m){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=i|0,this.Ch=o|0,this.Cl=s|0,this.Dh=c|0,this.Dl=a|0,this.Eh=f|0,this.El=u|0,this.Fh=h|0,this.Fl=y|0,this.Gh=x|0,this.Gl=p|0,this.Hh=l|0,this.Hl=m|0}process(t,e){for(let w=0;w<16;w++,e+=4)Le[w]=t.getUint32(e),Oe[w]=t.getUint32(e+=4);for(let w=16;w<80;w++){let P=Le[w-15]|0,A=Oe[w-15]|0,T=F.rotrSH(P,A,1)^F.rotrSH(P,A,8)^F.shrSH(P,A,7),K=F.rotrSL(P,A,1)^F.rotrSL(P,A,8)^F.shrSL(P,A,7),U=Le[w-2]|0,D=Oe[w-2]|0,O=F.rotrSH(U,D,19)^F.rotrBH(U,D,61)^F.shrSH(U,D,6),_=F.rotrSL(U,D,19)^F.rotrBL(U,D,61)^F.shrSL(U,D,6),j=F.add4L(K,_,Oe[w-7],Oe[w-16]),M=F.add4H(j,T,O,Le[w-7],Le[w-16]);Le[w]=M|0,Oe[w]=j|0}let{Ah:n,Al:i,Bh:o,Bl:s,Ch:c,Cl:a,Dh:f,Dl:u,Eh:h,El:y,Fh:x,Fl:p,Gh:l,Gl:m,Hh:b,Hl:B}=this;for(let w=0;w<80;w++){let P=F.rotrSH(h,y,14)^F.rotrSH(h,y,18)^F.rotrBH(h,y,41),A=F.rotrSL(h,y,14)^F.rotrSL(h,y,18)^F.rotrBL(h,y,41),T=h&x^~h&l,K=y&p^~y&m,U=F.add5L(B,A,K,Rd[w],Oe[w]),D=F.add5H(U,b,P,T,Od[w],Le[w]),O=U|0,_=F.rotrSH(n,i,28)^F.rotrBH(n,i,34)^F.rotrBH(n,i,39),j=F.rotrSL(n,i,28)^F.rotrBL(n,i,34)^F.rotrBL(n,i,39),M=n&o^n&c^o&c,W=i&s^i&a^s&a;b=l|0,B=m|0,l=x|0,m=p|0,x=h|0,p=y|0,{h,l:y}=F.add(f|0,u|0,D|0,O|0),f=c|0,u=a|0,c=o|0,a=s|0,o=n|0,s=i|0;let E=F.add3L(O,j,W);n=F.add3H(E,D,_,M),i=E|0}({h:n,l:i}=F.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:o,l:s}=F.add(this.Bh|0,this.Bl|0,o|0,s|0),{h:c,l:a}=F.add(this.Ch|0,this.Cl|0,c|0,a|0),{h:f,l:u}=F.add(this.Dh|0,this.Dl|0,f|0,u|0),{h,l:y}=F.add(this.Eh|0,this.El|0,h|0,y|0),{h:x,l:p}=F.add(this.Fh|0,this.Fl|0,x|0,p|0),{h:l,l:m}=F.add(this.Gh|0,this.Gl|0,l|0,m|0),{h:b,l:B}=F.add(this.Hh|0,this.Hl|0,b|0,B|0),this.set(n,i,o,s,c,a,f,u,h,y,x,p,l,m,b,B)}roundClean(){Le.fill(0),Oe.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 ys=si(()=>new ps);var jt=BigInt(0),Tt=BigInt(1),wi=BigInt(2),Nd=BigInt(8),Dd={zip215:!0};function Md(r){let t=pn(r);return Kt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function gi(r){let t=Md(r),{Fp:e,n,prehash:i,hash:o,randomBytes:s,nByteLength:c,h:a}=t,f=wi<<BigInt(c*8)-Tt,u=e.create,h=t.uvRatio||((v,d)=>{try{return{isValid:!0,value:e.sqrt(v*e.inv(d))}}catch{return{isValid:!1,value:jt}}}),y=t.adjustScalarBytes||(v=>v),x=t.domain||((v,d,S)=>{if(d.length||S)throw new Error("Contexts/pre-hash are not supported");return v}),p=v=>typeof v=="bigint"&&jt<v,l=(v,d)=>p(v)&&p(d)&&v<d,m=v=>v===jt||l(v,f);function b(v,d){if(l(v,d))return v;throw new Error(`Expected valid scalar < ${d}, got ${typeof v} ${v}`)}function B(v){return v===jt?v:b(v,n)}let w=new Map;function P(v){if(!(v instanceof A))throw new Error("ExtendedPoint expected")}class A{constructor(d,S,I,C){if(this.ex=d,this.ey=S,this.ez=I,this.et=C,!m(d))throw new Error("x required");if(!m(S))throw new Error("y required");if(!m(I))throw new Error("z required");if(!m(C))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(d){if(d instanceof A)throw new Error("extended point not allowed");let{x:S,y:I}=d||{};if(!m(S)||!m(I))throw new Error("invalid affine point");return new A(S,I,Tt,u(S*I))}static normalizeZ(d){let S=e.invertBatch(d.map(I=>I.ez));return d.map((I,C)=>I.toAffine(S[C])).map(A.fromAffine)}_setWindowSize(d){this._WINDOW_SIZE=d,w.delete(this)}assertValidity(){let{a:d,d:S}=t;if(this.is0())throw new Error("bad point: ZERO");let{ex:I,ey:C,ez:J,et:V}=this,z=u(I*I),G=u(C*C),q=u(J*J),et=u(q*q),Q=u(z*d),ut=u(q*u(Q+G)),ht=u(et+u(S*u(z*G)));if(ut!==ht)throw new Error("bad point: equation left != right (1)");let st=u(I*C),dt=u(J*V);if(st!==dt)throw new Error("bad point: equation left != right (2)")}equals(d){P(d);let{ex:S,ey:I,ez:C}=this,{ex:J,ey:V,ez:z}=d,G=u(S*z),q=u(J*C),et=u(I*z),Q=u(V*C);return G===q&&et===Q}is0(){return this.equals(A.ZERO)}negate(){return new A(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:d}=t,{ex:S,ey:I,ez:C}=this,J=u(S*S),V=u(I*I),z=u(wi*u(C*C)),G=u(d*J),q=S+I,et=u(u(q*q)-J-V),Q=G+V,ut=Q-z,ht=G-V,st=u(et*ut),dt=u(Q*ht),te=u(et*ht),De=u(ut*Q);return new A(st,dt,De,te)}add(d){P(d);let{a:S,d:I}=t,{ex:C,ey:J,ez:V,et:z}=this,{ex:G,ey:q,ez:et,et:Q}=d;if(S===BigInt(-1)){let Ks=u((J-C)*(q+G)),Is=u((J+C)*(q-G)),Pi=u(Is-Ks);if(Pi===jt)return this.double();let _s=u(V*wi*Q),Cs=u(z*wi*et),Ls=Cs+_s,Os=Is+Ks,Rs=Cs-_s,Qf=u(Ls*Pi),tu=u(Os*Rs),eu=u(Ls*Rs),ru=u(Pi*Os);return new A(Qf,tu,ru,eu)}let ut=u(C*G),ht=u(J*q),st=u(z*I*Q),dt=u(V*et),te=u((C+J)*(G+q)-ut-ht),De=dt-st,Rr=dt+st,Us=u(ht-S*ut),zf=u(te*De),Zf=u(Rr*Us),Yf=u(te*Us),Xf=u(De*Rr);return new A(zf,Zf,Xf,Yf)}subtract(d){return this.add(d.negate())}wNAF(d){return U.wNAFCached(this,w,d,A.normalizeZ)}multiply(d){let{p:S,f:I}=this.wNAF(b(d,n));return A.normalizeZ([S,I])[0]}multiplyUnsafe(d){let S=B(d);return S===jt?K:this.equals(K)||S===Tt?this:this.equals(T)?this.wNAF(S).p:U.unsafeLadder(this,S)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return U.unsafeLadder(this,n).is0()}toAffine(d){let{ex:S,ey:I,ez:C}=this,J=this.is0();d==null&&(d=J?Nd:e.inv(C));let V=u(S*d),z=u(I*d),G=u(C*d);if(J)return{x:jt,y:Tt};if(G!==Tt)throw new Error("invZ was invalid");return{x:V,y:z}}clearCofactor(){let{h:d}=t;return d===Tt?this:this.multiplyUnsafe(d)}static fromHex(d,S=!1){let{d:I,a:C}=t,J=e.BYTES;d=rt("pointHex",d,J);let V=d.slice(),z=d[J-1];V[J-1]=z&-129;let G=Nt(V);G===jt||(S?b(G,f):b(G,e.ORDER));let q=u(G*G),et=u(q-Tt),Q=u(I*q-C),{isValid:ut,value:ht}=h(et,Q);if(!ut)throw new Error("Point.fromHex: invalid y coordinate");let st=(ht&Tt)===Tt,dt=(z&128)!==0;if(!S&&ht===jt&&dt)throw new Error("Point.fromHex: x=0 and x_0=1");return dt!==st&&(ht=u(-ht)),A.fromAffine({x:ht,y:G})}static fromPrivateKey(d){return _(d).point}toRawBytes(){let{x:d,y:S}=this.toAffine(),I=de(S,e.BYTES);return I[I.length-1]|=d&Tt?128:0,I}toHex(){return he(this.toRawBytes())}}A.BASE=new A(t.Gx,t.Gy,Tt,u(t.Gx*t.Gy)),A.ZERO=new A(jt,Tt,Tt,jt);let{BASE:T,ZERO:K}=A,U=fi(A,c*8);function D(v){return X(v,n)}function O(v){return D(Nt(v))}function _(v){let d=c;v=rt("private key",v,d);let S=rt("hashed private key",o(v),2*d),I=y(S.slice(0,d)),C=S.slice(d,2*d),J=O(I),V=T.multiply(J),z=V.toRawBytes();return{head:I,prefix:C,scalar:J,point:V,pointBytes:z}}function j(v){return _(v).pointBytes}function M(v=new Uint8Array,...d){let S=pe(...d);return O(o(x(S,rt("context",v),!!i)))}function W(v,d,S={}){v=rt("message",v),i&&(v=i(v));let{prefix:I,scalar:C,pointBytes:J}=_(d),V=M(S.context,I,v),z=T.multiply(V).toRawBytes(),G=M(S.context,z,J,v),q=D(V+G*C);B(q);let et=pe(z,de(q,e.BYTES));return rt("result",et,c*2)}let E=Dd;function k(v,d,S,I=E){let{context:C,zip215:J}=I,V=e.BYTES;v=rt("signature",v,2*V),d=rt("message",d),i&&(d=i(d));let z=Nt(v.slice(V,2*V)),G,q,et;try{G=A.fromHex(S,J),q=A.fromHex(v.slice(0,V),J),et=T.multiplyUnsafe(z)}catch{return!1}if(!J&&G.isSmallOrder())return!1;let Q=M(C,q.toRawBytes(),G.toRawBytes(),d);return q.add(G.multiplyUnsafe(Q)).subtract(et).clearCofactor().equals(A.ZERO)}return T._setWindowSize(8),{CURVE:t,getPublicKey:j,sign:W,verify:k,ExtendedPoint:A,utils:{getExtendedPublicKey:_,randomPrivateKey:()=>s(e.BYTES),precompute(v=8,d=A.BASE){return d._setWindowSize(v),d.multiply(BigInt(3)),d}}}}var mn=BigInt(0),ms=BigInt(1);function jd(r){return Kt(r,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...r})}function lf(r){let t=jd(r),{P:e}=t,n=w=>X(w,e),i=t.montgomeryBits,o=Math.ceil(i/8),s=t.nByteLength,c=t.adjustScalarBytes||(w=>w),a=t.powPminus2||(w=>ts(w,e-BigInt(2),e));function f(w,P,A){let T=n(w*(P-A));return P=n(P-T),A=n(A+T),[P,A]}function u(w){if(typeof w=="bigint"&&mn<=w&&w<e)return w;throw new Error("Expected valid scalar 0 < scalar < CURVE.P")}let h=(t.a-BigInt(2))/BigInt(4);function y(w,P){let A=u(w),T=u(P),K=A,U=ms,D=mn,O=A,_=ms,j=mn,M;for(let E=BigInt(i-1);E>=mn;E--){let k=T>>E&ms;j^=k,M=f(j,U,O),U=M[0],O=M[1],M=f(j,D,_),D=M[0],_=M[1],j=k;let L=U+D,v=n(L*L),d=U-D,S=n(d*d),I=v-S,C=O+_,J=O-_,V=n(J*L),z=n(C*d),G=V+z,q=V-z;O=n(G*G),_=n(K*n(q*q)),U=n(v*S),D=n(I*(v+n(h*I)))}M=f(j,U,O),U=M[0],O=M[1],M=f(j,D,_),D=M[0],_=M[1];let W=a(D);return n(U*W)}function x(w){return de(n(w),o)}function p(w){let P=rt("u coordinate",w,o);return s===32&&(P[31]&=127),Nt(P)}function l(w){let P=rt("scalar",w),A=P.length;if(A!==o&&A!==s)throw new Error(`Expected ${o} or ${s} bytes, got ${A}`);return Nt(c(P))}function m(w,P){let A=p(P),T=l(w),K=y(A,T);if(K===mn)throw new Error("Invalid private or public key received");return x(K)}let b=x(t.Gu);function B(w){return m(w,b)}return{scalarMult:m,scalarMultBase:B,getSharedSecret:(w,P)=>m(w,P),getPublicKey:w=>B(w),utils:{randomPrivateKey:()=>t.randomBytes(t.nByteLength)},GuBytes:b}}var wn=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),df=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Nm=BigInt(0),Jd=BigInt(1),ws=BigInt(2),Vd=BigInt(5),pf=BigInt(10),Hd=BigInt(20),Gd=BigInt(40),yf=BigInt(80);function mf(r){let t=wn,n=r*r%t*r%t,i=nt(n,ws,t)*n%t,o=nt(i,Jd,t)*r%t,s=nt(o,Vd,t)*o%t,c=nt(s,pf,t)*s%t,a=nt(c,Hd,t)*c%t,f=nt(a,Gd,t)*a%t,u=nt(f,yf,t)*f%t,h=nt(u,yf,t)*f%t,y=nt(h,pf,t)*s%t;return{pow_p_5_8:nt(y,ws,t)*r%t,b2:n}}function wf(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function qd(r,t){let e=wn,n=X(t*t*t,e),i=X(n*n*t,e),o=mf(r*i).pow_p_5_8,s=X(r*n*o,e),c=X(t*s*s,e),a=s,f=X(s*df,e),u=c===r,h=c===X(-r,e),y=c===X(-r*df,e);return u&&(s=a),(h||y)&&(s=f),$a(s,e)&&(s=X(-s,e)),{isValid:u||h,value:s}}var _t=Kr(wn,void 0,!0),gn={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:_t,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:ys,randomBytes:dn,adjustScalarBytes:wf,uvRatio:qd},Re=gi(gn);function gf(r,t,e){if(t.length>255)throw new Error("Context is too big");return oi(Yo("SigEd25519 no Ed25519 collisions"),new Uint8Array([e?1:0,t.length]),t,r)}var Dm=gi({...gn,domain:gf}),Mm=gi({...gn,domain:gf,prehash:ys}),ar=lf({P:wn,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:r=>{let t=wn,{pow_p_5_8:e,b2:n}=mf(r);return X(nt(e,BigInt(3),t)*n,t)},adjustScalarBytes:wf,randomBytes:dn});function xf(r){let{y:t}=Re.ExtendedPoint.fromHex(r),e=BigInt(1);return _t.toBytes(_t.create((e+t)*_t.inv(e-t)))}function bf(r){let t=gn.hash(r.subarray(0,32));return gn.adjustScalarBytes(t).subarray(0,32)}var Fd=(_t.ORDER+BigInt(3))/BigInt(8),jm=_t.pow(ws,Fd),Jm=_t.sqrt(_t.neg(_t.ONE)),Vm=(_t.ORDER-BigInt(5))/BigInt(8),Hm=BigInt(486662);var Gm=Wa(_t,_t.neg(BigInt(486664)));var qm=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),Fm=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),$m=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),Wm=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");var zm=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var Ne=class r{static async bytesToPrivateKey({privateKeyBytes:t}){let e=Re.getPublicKey(t),n={crv:"Ed25519",d:R.uint8Array(t).toBase64Url(),kty:"OKP",x:R.uint8Array(e).toBase64Url()};return n.kid=await H({jwk:n}),n}static async bytesToPublicKey({publicKeyBytes:t}){let e={kty:"OKP",crv:"Ed25519",x:R.uint8Array(t).toBase64Url()};return e.kid=await H({jwk:e}),e}static async computePublicKey({key:t}){let e=await r.privateKeyToBytes({privateKey:t}),n=Re.getPublicKey(e),i={kty:"OKP",crv:"Ed25519",x:R.uint8Array(n).toBase64Url()};return i.kid=await H({jwk:i}),i}static async convertPrivateKeyToX25519({privateKey:t}){let e=await r.privateKeyToBytes({privateKey:t}),n=bf(e),i=ar.getPublicKey(n),o={kty:"OKP",crv:"X25519",d:R.uint8Array(n).toBase64Url(),x:R.uint8Array(i).toBase64Url()};return o.kid=await H({jwk:o}),o}static async convertPublicKeyToX25519({publicKey:t}){let e=await r.publicKeyToBytes({publicKey:t});if(!await r.validatePublicKey({publicKeyBytes:e}))throw new Error("Ed25519: Invalid public key.");let i=xf(e),o={kty:"OKP",crv:"X25519",x:R.uint8Array(i).toBase64Url()};return o.kid=await H({jwk:o}),o}static async generateKey(){let t=Re.utils.randomPrivateKey(),e=await r.bytesToPrivateKey({privateKeyBytes:t});return e.kid=await H({jwk:e}),e}static async getPublicKey({key:t}){if(!(Xt(t)&&t.crv==="Ed25519"))throw new Error("Ed25519: The provided key is not an Ed25519 private JWK.");let{d:e,...n}=t;return n.kid??=await H({jwk:n}),n}static async privateKeyToBytes({privateKey:t}){if(!Xt(t))throw new Error("Ed25519: The provided key is not a valid OKP private key.");return R.base64Url(t.d).toUint8Array()}static async publicKeyToBytes({publicKey:t}){if(!Cr(t))throw new Error("Ed25519: The provided key is not a valid OKP public key.");return R.base64Url(t.x).toUint8Array()}static async sign({key:t,data:e}){let n=await r.privateKeyToBytes({privateKey:t});return Re.sign(e,n)}static async validatePublicKey({publicKeyBytes:t}){try{Re.ExtendedPoint.fromHex(t).assertValidity()}catch{return!1}return!0}static async verify({key:t,signature:e,data:n}){let i=await r.publicKeyToBytes({publicKey:t});return Re.verify(e,n,i)}};var xi=class extends Ut{async computePublicKey({key:t}){if(!Xt(t))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) private key.");switch(t.crv){case"Ed25519":{let e=await Ne.computePublicKey({key:t});return e.alg="EdDSA",e}default:throw new Error(`Unsupported curve: ${t.crv}`)}}async generateKey({algorithm:t}){switch(t){case"Ed25519":{let e=await Ne.generateKey();return e.alg="EdDSA",e}}}async getPublicKey({key:t}){if(!Xt(t))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) private key.");switch(t.crv){case"Ed25519":{let e=await Ne.getPublicKey({key:t});return e.alg="EdDSA",e}default:throw new Error(`Unsupported curve: ${t.crv}`)}}async sign({key:t,data:e}){if(!Xt(t))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) private key.");switch(t.crv){case"Ed25519":return await Ne.sign({key:t,data:e});default:throw new Error(`Unsupported curve: ${t.crv}`)}}async verify({key:t,signature:e,data:n}){if(!Cr(t))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) public key.");switch(t.crv){case"Ed25519":return await Ne.verify({key:t,signature:e,data:n});default:throw new Error(`Unsupported curve: ${t.crv}`)}}};var bi=class extends Ut{async digest({algorithm:t,data:e}){switch(t){case"SHA-256":return await Ir.digest({data:e})}}};var gs={Ed25519:{implementation:xi,names:["Ed25519"]},secp256k1:{implementation:yn,names:["ES256K","secp256k1"]},secp256r1:{implementation:yn,names:["ES256","secp256r1"]},"SHA-256":{implementation:bi,names:["SHA-256"]}},Ef=class{constructor(t){this._algorithmInstances=new Map;this._keyStore=t?.keyStore??new ti}async digest({algorithm:t,data:e}){return await this.getAlgorithm({algorithm:t}).digest({algorithm:t,data:e})}async exportKey({keyUri:t}){return await this.getPrivateKey({keyUri:t})}async generateKey({algorithm:t}){let n=await this.getAlgorithm({algorithm:t}).generateKey({algorithm:t});if(n?.kid===void 0)throw new Error("Generated key is missing a required property: kid");let i=`${ls}${n.kid}`;return await this._keyStore.set(i,n),i}async getKeyUri({key:t}){let e=await H({jwk:t});return`${ls}${e}`}async getPublicKey({keyUri:t}){let e=await this.getPrivateKey({keyUri:t}),n=this.getAlgorithmName({key:e});return await this.getAlgorithm({algorithm:n}).getPublicKey({key:e})}async importKey({key:t}){if(!ff(t))throw new TypeError("Invalid key provided. Must be a private key in JWK format.");let e=structuredClone(t);e.kid??=await H({jwk:e});let n=await this.getKeyUri({key:e});return await this._keyStore.set(n,e),n}async sign({keyUri:t,data:e}){let n=await this.getPrivateKey({keyUri:t}),i=this.getAlgorithmName({key:n});return this.getAlgorithm({algorithm:i}).sign({data:e,key:n})}async verify({key:t,signature:e,data:n}){let i=this.getAlgorithmName({key:t});return this.getAlgorithm({algorithm:i}).verify({key:t,signature:e,data:n})}getAlgorithm({algorithm:t}){let e=gs[t]?.implementation;if(!e)throw new Error(`Algorithm not supported: ${t}`);return this._algorithmInstances.has(e)||this._algorithmInstances.set(e,new e),this._algorithmInstances.get(e)}getAlgorithmName({key:t}){let e=t.alg,n=t.crv;for(let i in gs){let o=gs[i];if(e&&o.names.includes(e))return i;if(n&&o.names.includes(n))return i}throw new Error(`Unable to determine algorithm based on provided input: alg=${e}, crv=${n}`)}async getPrivateKey({keyUri:t}){let e=await this._keyStore.get(t);if(!e)throw new Error(`Key not found: ${t}`);return e}};var vf=class r{static getJoseSignatureAlgorithmFromPublicKey(t){let e={Ed25519:"EdDSA","P-256":"ES256","P-384":"ES384","P-521":"ES512",secp256k1:"ES256K"};if(t.alg&&Object.values(e).includes(t.alg))return t.alg;if(t.crv&&Object.keys(e).includes(t.crv))return e[t.crv];throw new Error(`Unable to determine algorithm based on provided input: alg=${t.alg}, crv=${t.crv}. Supported 'alg' values: ${Object.values(e).join(", ")}. Supported 'crv' values: ${Object.keys(e).join(", ")}.`)}static randomBytes(t){return of(t)}static randomUuid(){return me.randomUUID()}static randomPin({length:t}){if(3>t||t>10)throw new Error("randomPin() can securely generate a PIN between 3 to 10 digits.");let e=Math.pow(10,t)-1,n;if(t<=6){let i=Math.pow(10,t);do{let o=r.randomBytes(Math.ceil(t/2));n=new DataView(o.buffer).getUint16(0,!1)%i}while(n>e)}else{let i=Math.pow(10,10);do{let o=r.randomBytes(4);n=new DataView(o.buffer).getUint32(0,!1)%i}while(n>e)}return n.toString().padStart(t,"0")}};var Ei=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function ot(){if(Ei&&typeof Ei.subtle=="object"&&Ei.subtle!=null)return Ei.subtle;throw new Error("crypto.subtle must be defined")}var xn=128,Af=[128,192,256],vi=xn,Lr=class{static async bytesToPrivateKey({privateKeyBytes:t}){let e={k:R.uint8Array(t).toBase64Url(),kty:"oct"};return e.kid=await H({jwk:e}),e}static async decrypt({key:t,data:e,counter:n,length:i}){if(n.byteLength!==xn/8)throw new TypeError(`The counter must be ${xn} bits in length`);if(i===0||i>vi)throw new TypeError(`The 'length' property must be in the range 1 to ${vi}`);let o=ot(),s=await o.importKey("jwk",t,{name:"AES-CTR"},!0,["decrypt"]),c=await o.decrypt({name:"AES-CTR",counter:n,length:i},s,e);return new Uint8Array(c)}static async encrypt({key:t,data:e,counter:n,length:i}){if(n.byteLength!==xn/8)throw new TypeError(`The counter must be ${xn} bits in length`);if(i===0||i>vi)throw new TypeError(`The 'length' property must be in the range 1 to ${vi}`);let o=ot(),s=await o.importKey("jwk",t,{name:"AES-CTR"},!0,["encrypt","decrypt"]),c=await o.encrypt({name:"AES-CTR",counter:n,length:i},s,e);return new Uint8Array(c)}static async generateKey({length:t}){if(!Af.includes(t))throw new RangeError(`The key length is invalid: Must be ${Af.join(", ")} bits`);let e=ot(),n=await e.generateKey({name:"AES-CTR",length:t},!0,["encrypt"]),{ext:i,key_ops:o,...s}=await e.exportKey("jwk",n);return s.kid=await H({jwk:s}),s}static async privateKeyToBytes({privateKey:t}){if(!Yt(t))throw new Error("AesCtr: The provided key is not a valid oct private key.");return R.base64Url(t.k).toUint8Array()}};var Bf=class extends Ut{async decrypt(t){return Lr.decrypt(t)}async encrypt(t){return Lr.encrypt(t)}async generateKey({algorithm:t}){let e={A128CTR:128,A192CTR:192,A256CTR:256}[t],n=await Lr.generateKey({length:e});return n.alg=t,n}};function bn(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`positive integer expected, not ${r}`)}function xs(r){if(typeof r!="boolean")throw new Error(`boolean expected, not ${r}`)}function bs(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function at(r,...t){if(!bs(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${r.length}`)}function Es(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function Tf(r,t){at(r);let e=t.outputLen;if(r.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}var we=r=>new Uint32Array(r.buffer,r.byteOffset,Math.floor(r.byteLength/4)),Sf=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),$d=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!$d)throw new Error("Non little-endian hardware is not supported");function Wd(r){if(typeof r!="string")throw new Error(`string expected, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Ai(r){if(typeof r=="string")r=Wd(r);else if(bs(r))r=r.slice();else throw new Error(`Uint8Array expected, got ${typeof r}`);return r}function kf(r,t){if(t==null||typeof t!="object")throw new Error("options must be defined");return Object.assign(r,t)}function Pf(r,t){if(r.length!==t.length)return!1;let e=0;for(let n=0;n<r.length;n++)e|=r[n]^t[n];return e===0}var vs=(r,t)=>(Object.assign(t,r),t);function As(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let i=BigInt(32),o=BigInt(4294967295),s=Number(e>>i&o),c=Number(e&o),a=n?4:0,f=n?0:4;r.setUint32(t+a,s,n),r.setUint32(t+f,c,n)}var Uf={async encrypt(r,t,e,n){let i=ot(),o=await i.importKey("raw",r,t,!0,["encrypt"]),s=await i.encrypt(e,o,n);return new Uint8Array(s)},async decrypt(r,t,e,n){let i=ot(),o=await i.importKey("raw",r,t,!0,["decrypt"]),s=await i.decrypt(e,o,n);return new Uint8Array(s)}},Qt={CBC:"AES-CBC",CTR:"AES-CTR",GCM:"AES-GCM"};function zd(r,t,e){if(r===Qt.CBC)return{name:Qt.CBC,iv:t};if(r===Qt.CTR)return{name:Qt.CTR,counter:t,length:64};if(r===Qt.GCM)return e?{name:Qt.GCM,iv:t,additionalData:e}:{name:Qt.GCM,iv:t};throw new Error("unknown aes block mode")}function Bs(r){return(t,e,n)=>{at(t),at(e);let i={name:r,length:t.length*8},o=zd(r,e,n);return{encrypt(s){return at(s),Uf.encrypt(t,i,o,s)},decrypt(s){return at(s),Uf.decrypt(t,i,o,s)}}}}var Iw=Bs(Qt.CBC),_w=Bs(Qt.CTR),Cw=Bs(Qt.GCM);var Bi=96,Kf=[128,192,256],Ti=[96,104,112,120,128],Or=class{static async bytesToPrivateKey({privateKeyBytes:t}){let e={k:R.uint8Array(t).toBase64Url(),kty:"oct"};return e.kid=await H({jwk:e}),e}static async decrypt({key:t,data:e,iv:n,additionalData:i,tagLength:o}){if(n.byteLength!==Bi/8)throw new TypeError(`The initialization vector must be ${Bi} bits in length`);if(o&&!Ti.includes(o))throw new RangeError(`The tag length is invalid: Must be ${Ti.join(", ")} bits`);let s=ot(),c=await s.importKey("jwk",t,{name:"AES-GCM"},!0,["decrypt"]),a={name:"AES-GCM",iv:n,...o&&{tagLength:o},...i&&{additionalData:i}},f=await s.decrypt(a,c,e);return new Uint8Array(f)}static async encrypt({data:t,iv:e,key:n,additionalData:i,tagLength:o}){if(e.byteLength!==Bi/8)throw new TypeError(`The initialization vector must be ${Bi} bits in length`);if(o&&!Ti.includes(o))throw new RangeError(`The tag length is invalid: Must be ${Ti.join(", ")} bits`);let s=ot(),c=await s.importKey("jwk",n,{name:"AES-GCM"},!0,["encrypt"]),a={name:"AES-GCM",iv:e,...o&&{tagLength:o},...i&&{additionalData:i}},f=await s.encrypt(a,c,t);return new Uint8Array(f)}static async generateKey({length:t}){if(!Kf.includes(t))throw new RangeError(`The key length is invalid: Must be ${Kf.join(", ")} bits`);let e=ot(),n=await e.generateKey({name:"AES-GCM",length:t},!0,["encrypt"]),{ext:i,key_ops:o,...s}=await e.exportKey("jwk",n);return s.kid=await H({jwk:s}),s}static async privateKeyToBytes({privateKey:t}){if(!Yt(t))throw new Error("AesGcm: The provided key is not a valid oct private key.");return R.base64Url(t.k).toUint8Array()}};var If=class extends Ut{async decrypt(t){return Or.decrypt(t)}async encrypt(t){return Or.encrypt(t)}async generateKey({algorithm:t}){let e={A128GCM:128,A192GCM:192,A256GCM:256}[t],n=await Or.generateKey({length:e});return n.alg=t,n}};var _f=[128,192,256],Cf=class{static async bytesToPrivateKey({privateKeyBytes:t}){let e={k:R.uint8Array(t).toBase64Url(),kty:"oct"};e.kid=await H({jwk:e});let n=t.length*8;return e.alg={128:"A128KW",192:"A192KW",256:"A256KW"}[n],e}static async generateKey({length:t}){if(!_f.includes(t))throw new RangeError(`The key length is invalid: Must be ${_f.join(", ")} bits`);let e=ot(),n=await e.generateKey({name:"AES-KW",length:t},!0,["wrapKey","unwrapKey"]),{ext:i,key_ops:o,...s}=await e.exportKey("jwk",n);return s.kid=await H({jwk:s}),s}static async privateKeyToBytes({privateKey:t}){if(!Yt(t))throw new Error("AesKw: The provided key is not a valid oct private key.");return R.base64Url(t.k).toUint8Array()}static async unwrapKey({wrappedKeyBytes:t,wrappedKeyAlgorithm:e,decryptionKey:n}){if(!("alg"in n&&n.alg))throw new Jt("invalidJwk","The decryption key is missing the 'alg' property.");if(!["A128KW","A192KW","A256KW"].includes(n.alg))throw new Jt("algorithmNotSupported",`The 'decryptionKey' algorithm is not supported: ${n.alg}`);let i=ot(),o=await i.importKey("jwk",n,{name:"AES-KW"},!0,["unwrapKey"]),s={A128KW:"AES-KW",A192KW:"AES-KW",A256KW:"AES-KW",A128GCM:"AES-GCM",A192GCM:"AES-GCM",A256GCM:"AES-GCM"}[e];if(!s)throw new Jt("algorithmNotSupported",`The 'wrappedKeyAlgorithm' is not supported: ${e}`);let c=await i.unwrapKey("raw",t.buffer,o,"AES-KW",{name:s},!0,["unwrapKey"]),{ext:a,key_ops:f,...u}=await i.exportKey("jwk",c),h=u;return h.kid=await H({jwk:h}),h}static async wrapKey({unwrappedKey:t,encryptionKey:e}){if(!("alg"in e&&e.alg))throw new Jt("invalidJwk","The encryption key is missing the 'alg' property.");if(!["A128KW","A192KW","A256KW"].includes(e.alg))throw new Jt("algorithmNotSupported",`The 'encryptionKey' algorithm is not supported: ${e.alg}`);if(!("alg"in t&&t.alg))throw new Jt("invalidJwk","The private key to wrap is missing the 'alg' property.");let n=ot(),i=await n.importKey("jwk",e,{name:"AES-KW"},!0,["wrapKey"]),o={A128KW:"AES-KW",A192KW:"AES-KW",A256KW:"AES-KW",A128GCM:"AES-GCM",A192GCM:"AES-GCM",A256GCM:"AES-GCM"}[t.alg];if(!o)throw new Jt("algorithmNotSupported",`The 'unwrappedKey' algorithm is not supported: ${t.alg}`);let s=await n.importKey("jwk",t,{name:o},!0,["unwrapKey"]),c=await n.wrapKey("raw",s,i,"AES-KW");return new Uint8Array(c)}};var Lf=class r{static async deriveKey({keyDataLen:t,fixedInfo:e,sharedSecret:n}){let o=Math.ceil(t/256);if(o!==1)throw new Error(`Concat KDF with ${o} rounds not supported.`);let s=new Uint8Array(4);new DataView(s.buffer).setUint32(0,o);let c=r.computeFixedInfo(e);return zt(us(s,n,c)).slice(0,t/8)}static computeFixedInfo(t){let e=r.toDataLenData({data:t.algorithmId}),n=r.toDataLenData({data:t.partyUInfo}),i=r.toDataLenData({data:t.partyVInfo}),o=r.toDataLenData({data:t.suppPubInfo,variableLength:!1}),s=r.toDataLenData({data:t.suppPrivInfo});return us(e,n,i,o,s)}static toDataLenData({data:t,variableLength:e=!0}){let n,i=Dr(t);if(i==="Undefined")return new Uint8Array(0);if(e){let o=i==="Uint8Array"?t:new R(t,i).toUint8Array(),s=o.length;n=new Uint8Array(4+s),new DataView(n.buffer).setUint32(0,s),n.set(o,4)}else{if(typeof t!="number")throw TypeError("Fixed length input must be a number.");n=new Uint8Array(4),new DataView(n.buffer).setUint32(0,t)}return n}};var Of=class{static async deriveKeyBytes({baseKeyBytes:t,length:e,hash:n,salt:i,info:o=new Uint8Array}){let s=ot(),c=await s.importKey("raw",t,{name:"HKDF"},!1,["deriveBits"]),a=typeof i=="string"?R.string(i).toUint8Array():i,f=typeof o=="string"?R.string(o).toUint8Array():o,u=await s.deriveBits({name:"HKDF",hash:n,salt:a,info:f},c,e);return new Uint8Array(u)}};var Rf=class{static async deriveKey({hash:t,password:e,salt:n,iterations:i,length:o}){let s=await me.subtle.importKey("raw",e,{name:"PBKDF2"},!1,["deriveBits"]),c=await me.subtle.deriveBits({name:"PBKDF2",hash:t,salt:n,iterations:i},s,o);return new Uint8Array(c)}static async deriveKeyBytes({baseKeyBytes:t,hash:e,salt:n,iterations:i,length:o}){let s=ot(),c=await s.importKey("raw",t,{name:"PBKDF2"},!1,["deriveBits"]),a=await s.deriveBits({name:"PBKDF2",hash:e,salt:n,iterations:i},c,o);return new Uint8Array(a)}};var Nf=class r{static async bytesToPrivateKey({privateKeyBytes:t}){let e=ar.getPublicKey(t),n={kty:"OKP",crv:"X25519",d:R.uint8Array(t).toBase64Url(),x:R.uint8Array(e).toBase64Url()};return n.kid=await H({jwk:n}),n}static async bytesToPublicKey({publicKeyBytes:t}){let e={kty:"OKP",crv:"X25519",x:R.uint8Array(t).toBase64Url()};return e.kid=await H({jwk:e}),e}static async computePublicKey({key:t}){let e=await r.privateKeyToBytes({privateKey:t}),n=ar.getPublicKey(e),i={kty:"OKP",crv:"X25519",x:R.uint8Array(n).toBase64Url()};return i.kid=await H({jwk:i}),i}static async generateKey(){let t=ar.utils.randomPrivateKey(),e=await r.bytesToPrivateKey({privateKeyBytes:t});return e.kid=await H({jwk:e}),e}static async getPublicKey({key:t}){if(!(Xt(t)&&t.crv==="X25519"))throw new Error("X25519: The provided key is not an X25519 private JWK.");let{d:e,...n}=t;return n.kid??=await H({jwk:n}),n}static async privateKeyToBytes({privateKey:t}){if(!Xt(t))throw new Error("X25519: The provided key is not a valid OKP private key.");return R.base64Url(t.d).toUint8Array()}static async publicKeyToBytes({publicKey:t}){if(!Cr(t))throw new Error("X25519: The provided key is not a valid OKP public key.");return R.base64Url(t.x).toUint8Array()}static async sharedSecret({privateKeyA:t,publicKeyB:e}){if("x"in t&&"x"in e&&t.x===e.x)throw new Error("X25519: ECDH shared secret cannot be computed from a single key pair's public and private keys.");let n=await r.privateKeyToBytes({privateKey:t}),i=await r.publicKeyToBytes({publicKey:e});return ar.getSharedSecret(n,i)}};var lt=(r,t)=>r[t++]&255|(r[t++]&255)<<8,Ts=class{constructor(t){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,t=Ai(t),at(t,32);let e=lt(t,0),n=lt(t,2),i=lt(t,4),o=lt(t,6),s=lt(t,8),c=lt(t,10),a=lt(t,12),f=lt(t,14);this.r[0]=e&8191,this.r[1]=(e>>>13|n<<3)&8191,this.r[2]=(n>>>10|i<<6)&7939,this.r[3]=(i>>>7|o<<9)&8191,this.r[4]=(o>>>4|s<<12)&255,this.r[5]=s>>>1&8190,this.r[6]=(s>>>14|c<<2)&8191,this.r[7]=(c>>>11|a<<5)&8065,this.r[8]=(a>>>8|f<<8)&8191,this.r[9]=f>>>5&127;for(let u=0;u<8;u++)this.pad[u]=lt(t,16+2*u)}process(t,e,n=!1){let i=n?0:2048,{h:o,r:s}=this,c=s[0],a=s[1],f=s[2],u=s[3],h=s[4],y=s[5],x=s[6],p=s[7],l=s[8],m=s[9],b=lt(t,e+0),B=lt(t,e+2),w=lt(t,e+4),P=lt(t,e+6),A=lt(t,e+8),T=lt(t,e+10),K=lt(t,e+12),U=lt(t,e+14),D=o[0]+(b&8191),O=o[1]+((b>>>13|B<<3)&8191),_=o[2]+((B>>>10|w<<6)&8191),j=o[3]+((w>>>7|P<<9)&8191),M=o[4]+((P>>>4|A<<12)&8191),W=o[5]+(A>>>1&8191),E=o[6]+((A>>>14|T<<2)&8191),k=o[7]+((T>>>11|K<<5)&8191),L=o[8]+((K>>>8|U<<8)&8191),v=o[9]+(U>>>5|i),d=0,S=d+D*c+O*(5*m)+_*(5*l)+j*(5*p)+M*(5*x);d=S>>>13,S&=8191,S+=W*(5*y)+E*(5*h)+k*(5*u)+L*(5*f)+v*(5*a),d+=S>>>13,S&=8191;let I=d+D*a+O*c+_*(5*m)+j*(5*l)+M*(5*p);d=I>>>13,I&=8191,I+=W*(5*x)+E*(5*y)+k*(5*h)+L*(5*u)+v*(5*f),d+=I>>>13,I&=8191;let C=d+D*f+O*a+_*c+j*(5*m)+M*(5*l);d=C>>>13,C&=8191,C+=W*(5*p)+E*(5*x)+k*(5*y)+L*(5*h)+v*(5*u),d+=C>>>13,C&=8191;let J=d+D*u+O*f+_*a+j*c+M*(5*m);d=J>>>13,J&=8191,J+=W*(5*l)+E*(5*p)+k*(5*x)+L*(5*y)+v*(5*h),d+=J>>>13,J&=8191;let V=d+D*h+O*u+_*f+j*a+M*c;d=V>>>13,V&=8191,V+=W*(5*m)+E*(5*l)+k*(5*p)+L*(5*x)+v*(5*y),d+=V>>>13,V&=8191;let z=d+D*y+O*h+_*u+j*f+M*a;d=z>>>13,z&=8191,z+=W*c+E*(5*m)+k*(5*l)+L*(5*p)+v*(5*x),d+=z>>>13,z&=8191;let G=d+D*x+O*y+_*h+j*u+M*f;d=G>>>13,G&=8191,G+=W*a+E*c+k*(5*m)+L*(5*l)+v*(5*p),d+=G>>>13,G&=8191;let q=d+D*p+O*x+_*y+j*h+M*u;d=q>>>13,q&=8191,q+=W*f+E*a+k*c+L*(5*m)+v*(5*l),d+=q>>>13,q&=8191;let et=d+D*l+O*p+_*x+j*y+M*h;d=et>>>13,et&=8191,et+=W*u+E*f+k*a+L*c+v*(5*m),d+=et>>>13,et&=8191;let Q=d+D*m+O*l+_*p+j*x+M*y;d=Q>>>13,Q&=8191,Q+=W*h+E*u+k*f+L*a+v*c,d+=Q>>>13,Q&=8191,d=(d<<2)+d|0,d=d+S|0,S=d&8191,d=d>>>13,I+=d,o[0]=S,o[1]=I,o[2]=C,o[3]=J,o[4]=V,o[5]=z,o[6]=G,o[7]=q,o[8]=et,o[9]=Q}finalize(){let{h:t,pad:e}=this,n=new Uint16Array(10),i=t[1]>>>13;t[1]&=8191;for(let c=2;c<10;c++)t[c]+=i,i=t[c]>>>13,t[c]&=8191;t[0]+=i*5,i=t[0]>>>13,t[0]&=8191,t[1]+=i,i=t[1]>>>13,t[1]&=8191,t[2]+=i,n[0]=t[0]+5,i=n[0]>>>13,n[0]&=8191;for(let c=1;c<10;c++)n[c]=t[c]+i,i=n[c]>>>13,n[c]&=8191;n[9]-=8192;let o=(i^1)-1;for(let c=0;c<10;c++)n[c]&=o;o=~o;for(let c=0;c<10;c++)t[c]=t[c]&o|n[c];t[0]=(t[0]|t[1]<<13)&65535,t[1]=(t[1]>>>3|t[2]<<10)&65535,t[2]=(t[2]>>>6|t[3]<<7)&65535,t[3]=(t[3]>>>9|t[4]<<4)&65535,t[4]=(t[4]>>>12|t[5]<<1|t[6]<<14)&65535,t[5]=(t[6]>>>2|t[7]<<11)&65535,t[6]=(t[7]>>>5|t[8]<<8)&65535,t[7]=(t[8]>>>8|t[9]<<5)&65535;let s=t[0]+e[0];t[0]=s&65535;for(let c=1;c<8;c++)s=(t[c]+e[c]|0)+(s>>>16)|0,t[c]=s&65535}update(t){Es(this);let{buffer:e,blockLen:n}=this;t=Ai(t);let i=t.length;for(let o=0;o<i;){let s=Math.min(n-this.pos,i-o);if(s===n){for(;n<=i-o;o+=n)this.process(t,o);continue}e.set(t.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===n&&(this.process(e,0,!1),this.pos=0)}return this}destroy(){this.h.fill(0),this.r.fill(0),this.buffer.fill(0),this.pad.fill(0)}digestInto(t){Es(this),Tf(t,this),this.finished=!0;let{buffer:e,h:n}=this,{pos:i}=this;if(i){for(e[i++]=1;i<16;i++)e[i]=0;this.process(e,0,!0)}this.finalize();let o=0;for(let s=0;s<8;s++)t[o++]=n[s]>>>0,t[o++]=n[s]>>>8;return t}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}};function Zd(r){let t=(n,i)=>r(i).update(Ai(n)).digest(),e=r(new Uint8Array(32));return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=n=>r(n),t}var Df=Zd(r=>new Ts(r));var jf=r=>Uint8Array.from(r.split("").map(t=>t.charCodeAt(0))),Yd=jf("expand 16-byte k"),Xd=jf("expand 32-byte k"),Qd=we(Yd),Jf=we(Xd),lg=Jf.slice();function N(r,t){return r<<t|r>>>32-t}function Ss(r){return r.byteOffset%4===0}var Si=64,tp=16,Vf=2**32-1,Mf=new Uint32Array;function ep(r,t,e,n,i,o,s,c){let a=i.length,f=new Uint8Array(Si),u=we(f),h=Ss(i)&&Ss(o),y=h?we(i):Mf,x=h?we(o):Mf;for(let p=0;p<a;s++){if(r(t,e,n,u,s,c),s>=Vf)throw new Error("arx: counter overflow");let l=Math.min(Si,a-p);if(h&&l===Si){let m=p/4;if(p%4!==0)throw new Error("arx: invalid block position");for(let b=0,B;b<tp;b++)B=m+b,x[B]=y[B]^u[b];p+=Si;continue}for(let m=0,b;m<l;m++)b=p+m,o[b]=i[b]^f[m];p+=l}}function ks(r,t){let{allowShortKeys:e,extendNonceFn:n,counterLength:i,counterRight:o,rounds:s}=kf({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if(typeof r!="function")throw new Error("core must be a function");return bn(i),bn(s),xs(o),xs(e),(c,a,f,u,h=0)=>{at(c),at(a),at(f);let y=f.length;if(u||(u=new Uint8Array(y)),at(u),bn(h),h<0||h>=Vf)throw new Error("arx: counter overflow");if(u.length<y)throw new Error(`arx: output (${u.length}) is shorter than data (${y})`);let x=[],p=c.length,l,m;if(p===32)l=c.slice(),x.push(l),m=Jf;else if(p===16&&e)l=new Uint8Array(32),l.set(c),l.set(c,16),m=Qd,x.push(l);else throw new Error(`arx: invalid 32-byte key, got length=${p}`);Ss(a)||(a=a.slice(),x.push(a));let b=we(l);if(n){if(a.length!==24)throw new Error("arx: extended nonce must be 24 bytes");n(m,b,we(a.subarray(0,16)),b),a=a.subarray(16)}let B=16-i;if(B!==a.length)throw new Error(`arx: nonce must be ${B} or 16 bytes`);if(B!==12){let P=new Uint8Array(12);P.set(a,o?0:12-a.length),a=P,x.push(a)}let w=we(a);for(ep(r,m,b,w,f,u,h,s);x.length>0;)x.pop().fill(0);return u}}function qf(r,t,e,n,i,o=20){let s=r[0],c=r[1],a=r[2],f=r[3],u=t[0],h=t[1],y=t[2],x=t[3],p=t[4],l=t[5],m=t[6],b=t[7],B=i,w=e[0],P=e[1],A=e[2],T=s,K=c,U=a,D=f,O=u,_=h,j=y,M=x,W=p,E=l,k=m,L=b,v=B,d=w,S=P,I=A;for(let J=0;J<o;J+=2)T=T+O|0,v=N(v^T,16),W=W+v|0,O=N(O^W,12),T=T+O|0,v=N(v^T,8),W=W+v|0,O=N(O^W,7),K=K+_|0,d=N(d^K,16),E=E+d|0,_=N(_^E,12),K=K+_|0,d=N(d^K,8),E=E+d|0,_=N(_^E,7),U=U+j|0,S=N(S^U,16),k=k+S|0,j=N(j^k,12),U=U+j|0,S=N(S^U,8),k=k+S|0,j=N(j^k,7),D=D+M|0,I=N(I^D,16),L=L+I|0,M=N(M^L,12),D=D+M|0,I=N(I^D,8),L=L+I|0,M=N(M^L,7),T=T+_|0,I=N(I^T,16),k=k+I|0,_=N(_^k,12),T=T+_|0,I=N(I^T,8),k=k+I|0,_=N(_^k,7),K=K+j|0,v=N(v^K,16),L=L+v|0,j=N(j^L,12),K=K+j|0,v=N(v^K,8),L=L+v|0,j=N(j^L,7),U=U+M|0,d=N(d^U,16),W=W+d|0,M=N(M^W,12),U=U+M|0,d=N(d^U,8),W=W+d|0,M=N(M^W,7),D=D+O|0,S=N(S^D,16),E=E+S|0,O=N(O^E,12),D=D+O|0,S=N(S^D,8),E=E+S|0,O=N(O^E,7);let C=0;n[C++]=s+T|0,n[C++]=c+K|0,n[C++]=a+U|0,n[C++]=f+D|0,n[C++]=u+O|0,n[C++]=h+_|0,n[C++]=y+j|0,n[C++]=x+M|0,n[C++]=p+W|0,n[C++]=l+E|0,n[C++]=m+k|0,n[C++]=b+L|0,n[C++]=B+v|0,n[C++]=w+d|0,n[C++]=P+S|0,n[C++]=A+I|0}function rp(r,t,e,n){let i=r[0],o=r[1],s=r[2],c=r[3],a=t[0],f=t[1],u=t[2],h=t[3],y=t[4],x=t[5],p=t[6],l=t[7],m=e[0],b=e[1],B=e[2],w=e[3];for(let A=0;A<20;A+=2)i=i+a|0,m=N(m^i,16),y=y+m|0,a=N(a^y,12),i=i+a|0,m=N(m^i,8),y=y+m|0,a=N(a^y,7),o=o+f|0,b=N(b^o,16),x=x+b|0,f=N(f^x,12),o=o+f|0,b=N(b^o,8),x=x+b|0,f=N(f^x,7),s=s+u|0,B=N(B^s,16),p=p+B|0,u=N(u^p,12),s=s+u|0,B=N(B^s,8),p=p+B|0,u=N(u^p,7),c=c+h|0,w=N(w^c,16),l=l+w|0,h=N(h^l,12),c=c+h|0,w=N(w^c,8),l=l+w|0,h=N(h^l,7),i=i+f|0,w=N(w^i,16),p=p+w|0,f=N(f^p,12),i=i+f|0,w=N(w^i,8),p=p+w|0,f=N(f^p,7),o=o+u|0,m=N(m^o,16),l=l+m|0,u=N(u^l,12),o=o+u|0,m=N(m^o,8),l=l+m|0,u=N(u^l,7),s=s+h|0,b=N(b^s,16),y=y+b|0,h=N(h^y,12),s=s+h|0,b=N(b^s,8),y=y+b|0,h=N(h^y,7),c=c+a|0,B=N(B^c,16),x=x+B|0,a=N(a^x,12),c=c+a|0,B=N(B^c,8),x=x+B|0,a=N(a^x,7);let P=0;n[P++]=i,n[P++]=o,n[P++]=s,n[P++]=c,n[P++]=m,n[P++]=b,n[P++]=B,n[P++]=w}var np=ks(qf,{counterRight:!1,counterLength:4,allowShortKeys:!1}),ki=ks(qf,{counterRight:!1,counterLength:8,extendNonceFn:rp,allowShortKeys:!1});var ip=new Uint8Array(16),Hf=(r,t)=>{r.update(t);let e=t.length%16;e&&r.update(ip.subarray(e))},op=new Uint8Array(32);function Gf(r,t,e,n,i){let o=r(t,e,op),s=Df.create(o);i&&Hf(s,i),Hf(s,n);let c=new Uint8Array(16),a=Sf(c);As(a,0,BigInt(i?i.length:0),!0),As(a,8,BigInt(n.length),!0),s.update(c);let f=s.digest();return o.fill(0),f}var Ff=r=>(t,e,n)=>(at(t,32),at(e),{encrypt:(o,s)=>{let c=o.length,a=c+16;s?at(s,a):s=new Uint8Array(a),r(t,e,o,s,1);let f=Gf(r,t,e,s.subarray(0,-16),n);return s.set(f,c),s},decrypt:(o,s)=>{let c=o.length,a=c-16;if(c<16)throw new Error("encrypted data must be at least 16 bytes");s?at(s,a):s=new Uint8Array(a);let f=o.subarray(0,-16),u=o.subarray(-16),h=Gf(r,t,e,f,n);if(!Pf(u,h))throw new Error("invalid tag");return r(t,e,f,s,1),s}}),gg=vs({blockSize:64,nonceLength:12,tagLength:16},Ff(np)),Ps=vs({blockSize:64,nonceLength:24,tagLength:16},Ff(ki));var $f=class r{static async bytesToPrivateKey({privateKeyBytes:t}){let e={k:R.uint8Array(t).toBase64Url(),kty:"oct"};return e.kid=await H({jwk:e}),e}static async decrypt({data:t,key:e,nonce:n}){let i=await r.privateKeyToBytes({privateKey:e});return ki(i,n,t)}static async encrypt({data:t,key:e,nonce:n}){let i=await r.privateKeyToBytes({privateKey:e});return ki(i,n,t)}static async generateKey(){let t=ot(),e=await t.generateKey({name:"AES-CTR",length:256},!0,["encrypt"]),{alg:n,ext:i,key_ops:o,...s}=await t.exportKey("jwk",e);return s.kid=await H({jwk:s}),s}static async privateKeyToBytes({privateKey:t}){if(!Yt(t))throw new Error("XChaCha20: The provided key is not a valid oct private key.");return R.base64Url(t.k).toUint8Array()}};var Ug=16,Wf=class r{static async bytesToPrivateKey({privateKeyBytes:t}){let e={k:R.uint8Array(t).toBase64Url(),kty:"oct"};return e.kid=await H({jwk:e}),e}static async decrypt({data:t,key:e,nonce:n,additionalData:i}){let o=await r.privateKeyToBytes({privateKey:e});return r.decryptRaw({data:t,keyBytes:o,nonce:n,additionalData:i})}static async decryptRaw({data:t,keyBytes:e,nonce:n,additionalData:i}){return Ps(e,n,i).decrypt(t)}static async encrypt({data:t,key:e,nonce:n,additionalData:i}){let o=await r.privateKeyToBytes({privateKey:e});return r.encryptRaw({data:t,keyBytes:o,nonce:n,additionalData:i})}static async encryptRaw({data:t,keyBytes:e,nonce:n,additionalData:i}){return Ps(e,n,i).encrypt(t)}static async generateKey(){let t=ot(),e=await t.generateKey({name:"AES-CTR",length:256},!0,["encrypt"]),{alg:n,ext:i,key_ops:o,...s}=await t.exportKey("jwk",e);return s.kid=await H({jwk:s}),s}static async privateKeyToBytes({privateKey:t}){if(!Yt(t))throw new Error("XChaCha20Poly1305: The provided key is not a valid oct private key.");return R.base64Url(t.k).toUint8Array()}};export{Ti as AES_GCM_TAG_LENGTHS,Lr as AesCtr,Bf as AesCtrAlgorithm,Or as AesGcm,If as AesGcmAlgorithm,Cf as AesKw,Lf as ConcatKdf,Ut as CryptoAlgorithm,Jt as CryptoError,Ms as CryptoErrorCode,vf as CryptoUtils,yn as EcdsaAlgorithm,Ne as Ed25519,xi as EdDsaAlgorithm,Of as Hkdf,ls as KEY_URI_PREFIX_JWK,Ef as LocalKeyManager,Ce as P256,Ug as POLY1305_TAG_LENGTH,Rf as Pbkdf2,_e as Secp256k1,Ce as Secp256r1,Ir as Sha256,bi as Sha2Algorithm,Nf as X25519,$f as XChaCha20,Wf as XChaCha20Poly1305,af as canonicalize,H as computeJwkThumbprint,Zt as isEcPrivateJwk,_r as isEcPublicJwk,Yt as isOctPrivateJwk,Xt as isOkpPrivateJwk,Cr as isOkpPublicJwk,ff as isPrivateJwk,Y0 as isPublicJwk};
|
|
3
2
|
/*! Bundled license information:
|
|
4
3
|
|
|
5
4
|
ieee754/index.js:
|
|
@@ -19,18 +18,12 @@ queue-microtask/index.js:
|
|
|
19
18
|
run-parallel-limit/index.js:
|
|
20
19
|
(*! run-parallel-limit. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
(*!
|
|
24
|
-
|
|
25
|
-
@noble/hashes/esm/utils.js:
|
|
26
|
-
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
21
|
+
@noble/curves/esm/abstract/utils.js:
|
|
22
|
+
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
27
23
|
|
|
28
24
|
@noble/hashes/esm/utils.js:
|
|
29
25
|
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
30
26
|
|
|
31
|
-
@noble/curves/esm/abstract/utils.js:
|
|
32
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
33
|
-
|
|
34
27
|
@noble/curves/esm/abstract/modular.js:
|
|
35
28
|
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
36
29
|
|
|
@@ -46,6 +39,9 @@ safe-buffer/index.js:
|
|
|
46
39
|
@noble/curves/esm/secp256k1.js:
|
|
47
40
|
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
48
41
|
|
|
42
|
+
@noble/hashes/esm/utils.js:
|
|
43
|
+
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
44
|
+
|
|
49
45
|
@noble/curves/esm/p256.js:
|
|
50
46
|
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
51
47
|
|