@enbox/crypto 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.mjs +1 -1
- package/dist/browser.mjs.map +4 -4
- package/dist/esm/algorithms/aes-ctr.js +1 -1
- package/dist/esm/algorithms/aes-gcm.js +34 -1
- package/dist/esm/algorithms/aes-gcm.js.map +1 -1
- package/dist/esm/algorithms/aes-kw.js +154 -0
- package/dist/esm/algorithms/aes-kw.js.map +1 -0
- package/dist/esm/algorithms/ecdsa.js +110 -1
- package/dist/esm/algorithms/ecdsa.js.map +1 -1
- package/dist/esm/algorithms/eddsa.js +90 -1
- package/dist/esm/algorithms/eddsa.js.map +1 -1
- package/dist/esm/algorithms/hkdf.js +53 -0
- package/dist/esm/algorithms/hkdf.js.map +1 -0
- package/dist/esm/algorithms/pbkdf2.js +55 -0
- package/dist/esm/algorithms/pbkdf2.js.map +1 -0
- package/dist/esm/algorithms/sha-2.js +1 -1
- package/dist/esm/algorithms/x25519.js +125 -0
- package/dist/esm/algorithms/x25519.js.map +1 -0
- package/dist/esm/cose/cbor.js +35 -0
- package/dist/esm/cose/cbor.js.map +1 -0
- package/dist/esm/cose/cose-key.js +312 -0
- package/dist/esm/cose/cose-key.js.map +1 -0
- package/dist/esm/cose/cose-sign1.js +283 -0
- package/dist/esm/cose/cose-sign1.js.map +1 -0
- package/dist/esm/cose/eat.js +254 -0
- package/dist/esm/cose/eat.js.map +1 -0
- package/dist/esm/crypto-error.js +4 -0
- package/dist/esm/crypto-error.js.map +1 -1
- package/dist/esm/index.js +9 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/local-key-manager.js +6 -1
- package/dist/esm/local-key-manager.js.map +1 -1
- package/dist/esm/primitives/ecies-secp256k1.js +79 -0
- package/dist/esm/primitives/ecies-secp256k1.js.map +1 -0
- package/dist/esm/primitives/x25519.js +9 -16
- package/dist/esm/primitives/x25519.js.map +1 -1
- package/dist/esm/utils.js +30 -0
- package/dist/esm/utils.js.map +1 -1
- package/dist/types/algorithms/aes-ctr.d.ts +1 -1
- package/dist/types/algorithms/aes-gcm.d.ts +23 -3
- package/dist/types/algorithms/aes-gcm.d.ts.map +1 -1
- package/dist/types/algorithms/aes-kw.d.ts +129 -0
- package/dist/types/algorithms/aes-kw.d.ts.map +1 -0
- package/dist/types/algorithms/ecdsa.d.ts +48 -3
- package/dist/types/algorithms/ecdsa.d.ts.map +1 -1
- package/dist/types/algorithms/eddsa.d.ts +48 -3
- package/dist/types/algorithms/eddsa.d.ts.map +1 -1
- package/dist/types/algorithms/hkdf.d.ts +35 -0
- package/dist/types/algorithms/hkdf.d.ts.map +1 -0
- package/dist/types/algorithms/pbkdf2.d.ts +35 -0
- package/dist/types/algorithms/pbkdf2.d.ts.map +1 -0
- package/dist/types/algorithms/sha-2.d.ts +1 -1
- package/dist/types/algorithms/x25519.d.ts +76 -0
- package/dist/types/algorithms/x25519.d.ts.map +1 -0
- package/dist/types/cose/cbor.d.ts +30 -0
- package/dist/types/cose/cbor.d.ts.map +1 -0
- package/dist/types/cose/cose-key.d.ts +106 -0
- package/dist/types/cose/cose-key.d.ts.map +1 -0
- package/dist/types/cose/cose-sign1.d.ts +195 -0
- package/dist/types/cose/cose-sign1.d.ts.map +1 -0
- package/dist/types/cose/eat.d.ts +203 -0
- package/dist/types/cose/eat.d.ts.map +1 -0
- package/dist/types/crypto-error.d.ts +4 -0
- package/dist/types/crypto-error.d.ts.map +1 -1
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/local-key-manager.d.ts +4 -4
- package/dist/types/local-key-manager.d.ts.map +1 -1
- package/dist/types/primitives/ecies-secp256k1.d.ts +53 -0
- package/dist/types/primitives/ecies-secp256k1.d.ts.map +1 -0
- package/dist/types/primitives/x25519.d.ts +9 -16
- package/dist/types/primitives/x25519.d.ts.map +1 -1
- package/dist/types/types/crypto-api.d.ts +52 -4
- package/dist/types/types/crypto-api.d.ts.map +1 -1
- package/dist/types/types/key-converter.d.ts +37 -15
- package/dist/types/types/key-converter.d.ts.map +1 -1
- package/dist/types/types/key-deriver.d.ts +41 -0
- package/dist/types/types/key-deriver.d.ts.map +1 -1
- package/dist/types/types/key-io.d.ts +37 -0
- package/dist/types/types/key-io.d.ts.map +1 -1
- package/dist/types/types/params-direct.d.ts +17 -0
- package/dist/types/types/params-direct.d.ts.map +1 -1
- package/dist/types/types/params-kms.d.ts +55 -0
- package/dist/types/types/params-kms.d.ts.map +1 -1
- package/dist/types/utils.d.ts +19 -0
- package/dist/types/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/utils.js.map +3 -3
- package/package.json +12 -14
- package/src/algorithms/aes-ctr.ts +1 -1
- package/src/algorithms/aes-gcm.ts +38 -2
- package/src/algorithms/aes-kw.ts +182 -0
- package/src/algorithms/ecdsa.ts +132 -1
- package/src/algorithms/eddsa.ts +108 -1
- package/src/algorithms/hkdf.ts +54 -0
- package/src/algorithms/pbkdf2.ts +57 -0
- package/src/algorithms/sha-2.ts +1 -1
- package/src/algorithms/x25519.ts +153 -0
- package/src/cose/cbor.ts +36 -0
- package/src/cose/cose-key.ts +344 -0
- package/src/cose/cose-sign1.ts +473 -0
- package/src/cose/eat.ts +368 -0
- package/src/crypto-error.ts +6 -0
- package/src/index.ts +10 -0
- package/src/local-key-manager.ts +9 -4
- package/src/primitives/ecies-secp256k1.ts +113 -0
- package/src/primitives/x25519.ts +9 -16
- package/src/types/crypto-api.ts +124 -6
- package/src/types/key-converter.ts +33 -7
- package/src/types/key-deriver.ts +49 -0
- package/src/types/key-io.ts +40 -0
- package/src/types/params-direct.ts +21 -0
- package/src/types/params-kms.ts +67 -0
- package/src/utils.ts +53 -0
- package/dist/browser.js +0 -60
- package/dist/browser.js.map +0 -7
package/dist/browser.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";var Web5Crypto=(()=>{var iu=Object.create;var Bn=Object.defineProperty;var ou=Object.getOwnPropertyDescriptor;var su=Object.getOwnPropertyNames;var cu=Object.getPrototypeOf,au=Object.prototype.hasOwnProperty;var Y=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),Ii=(r,t)=>{for(var e in t)Bn(r,e,{get:t[e],enumerable:!0})},Xs=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of su(t))!au.call(r,i)&&i!==e&&Bn(r,i,{get:()=>t[i],enumerable:!(n=ou(t,i))||n.enumerable});return r};var Qs=(r,t,e)=>(e=r!=null?iu(cu(r)):{},Xs(t||!r||!r.__esModule?Bn(e,"default",{value:r,enumerable:!0}):e,r)),fu=r=>Xs(Bn({},"__esModule",{value:!0}),r);var ec=Y((lp,tc)=>{var uu=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Tn=()=>uu.now(),hu=r=>r&&r===Math.floor(r)&&r>0&&isFinite(r),Ci=r=>r===1/0||hu(r),Li=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&&!Ci(e))throw new TypeError("ttl must be positive integer or Infinity if set");if(!Ci(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-Tn());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(Tn()+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(!Ci(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-Tn())):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(Tn());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()}};tc.exports=Li});var gc=Y(wc=>{"use strict";wc.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 Lt=Y((uy,xc)=>{"use strict";xc.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 vc=Y(kn=>{"use strict";kn.byteLength=qu;kn.toByteArray=$u;kn.fromByteArray=Zu;var $t=[],kt=[],Gu=typeof Uint8Array<"u"?Uint8Array:Array,Wi="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Ve=0,bc=Wi.length;Ve<bc;++Ve)$t[Ve]=Wi[Ve],kt[Wi.charCodeAt(Ve)]=Ve;var Ve,bc;kt[45]=62;kt[95]=63;function Ec(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 qu(r){var t=Ec(r),e=t[0],n=t[1];return(e+n)*3/4-n}function Fu(r,t,e){return(t+e)*3/4-e}function $u(r){var t,e=Ec(r),n=e[0],i=e[1],o=new Gu(Fu(r,n,i)),s=0,c=i>0?n-4:n,a;for(a=0;a<c;a+=4)t=kt[r.charCodeAt(a)]<<18|kt[r.charCodeAt(a+1)]<<12|kt[r.charCodeAt(a+2)]<<6|kt[r.charCodeAt(a+3)],o[s++]=t>>16&255,o[s++]=t>>8&255,o[s++]=t&255;return i===2&&(t=kt[r.charCodeAt(a)]<<2|kt[r.charCodeAt(a+1)]>>4,o[s++]=t&255),i===1&&(t=kt[r.charCodeAt(a)]<<10|kt[r.charCodeAt(a+1)]<<4|kt[r.charCodeAt(a+2)]>>2,o[s++]=t>>8&255,o[s++]=t&255),o}function Wu(r){return $t[r>>18&63]+$t[r>>12&63]+$t[r>>6&63]+$t[r&63]}function zu(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(Wu(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(zu(r,s,s+o>c?c:s+o));return n===1?(t=r[e-1],i.push($t[t>>2]+$t[t<<4&63]+"==")):n===2&&(t=(r[e-2]<<8)+r[e-1],i.push($t[t>>10]+$t[t>>4&63]+$t[t<<2&63]+"=")),i.join("")}});var Ac=Y(zi=>{zi.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)};zi.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 Kn=Y(br=>{"use strict";var Zi=vc(),gr=Ac(),Bc=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;br.Buffer=g;br.SlowBuffer=rh;br.INSPECT_MAX_BYTES=50;var Pn=2147483647;br.kMaxLength=Pn;g.TYPED_ARRAY_SUPPORT=Yu();!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 Yu(){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>Pn)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 to(r)}return Pc(r,t,e)}g.poolSize=8192;function Pc(r,t,e){if(typeof r=="string")return Qu(r,t);if(ArrayBuffer.isView(r))return th(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(Wt(r,ArrayBuffer)||r&&Wt(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Wt(r,SharedArrayBuffer)||r&&Wt(r.buffer,SharedArrayBuffer)))return Xi(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=eh(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 Uc(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 Xu(r,t,e){return Uc(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 Xu(r,t,e)};function to(r){return Uc(r),re(r<0?0:eo(r)|0)}g.allocUnsafe=function(r){return to(r)};g.allocUnsafeSlow=function(r){return to(r)};function Qu(r,t){if((typeof t!="string"||t==="")&&(t="utf8"),!g.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let e=Kc(r,t)|0,n=re(e),i=n.write(r,t);return i!==e&&(n=n.slice(0,i)),n}function Yi(r){let t=r.length<0?0:eo(r.length)|0,e=re(t);for(let n=0;n<t;n+=1)e[n]=r[n]&255;return e}function th(r){if(Wt(r,Uint8Array)){let t=new Uint8Array(r);return Xi(t.buffer,t.byteOffset,t.byteLength)}return Yi(r)}function Xi(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 eh(r){if(g.isBuffer(r)){let t=eo(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"||no(r.length)?re(0):Yi(r);if(r.type==="Buffer"&&Array.isArray(r.data))return Yi(r.data)}function eo(r){if(r>=Pn)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Pn.toString(16)+" bytes");return r|0}function rh(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(Wt(t,Uint8Array)&&(t=g.from(t,t.offset,t.byteLength)),Wt(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(Wt(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 Kc(r,t){if(g.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||Wt(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 Qi(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return Mc(r).length;default:if(i)return n?-1:Qi(r).length;t=(""+t).toLowerCase(),i=!0}}g.byteLength=Kc;function nh(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 dh(this,t,e);case"utf8":case"utf-8":return _c(this,t,e);case"ascii":return hh(this,t,e);case"latin1":case"binary":return lh(this,t,e);case"base64":return fh(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ph(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?_c(this,0,t):nh.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=br.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),"<Buffer "+t+">"};Bc&&(g.prototype[Bc]=g.prototype.inspect);g.prototype.compare=function(t,e,n,i,o){if(Wt(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 Ic(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,no(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:Tc(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):Tc(r,[t],e,n,i);throw new TypeError("val must be string, number or Buffer")}function Tc(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 Ic(this,t,e,n,!0)};g.prototype.lastIndexOf=function(t,e,n){return Ic(this,t,e,n,!1)};function ih(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(no(c))return s;r[e+s]=c}return s}function oh(r,t,e,n){return Un(Qi(t,r.length-e),r,e,n)}function sh(r,t,e,n){return Un(gh(t),r,e,n)}function ch(r,t,e,n){return Un(Mc(t),r,e,n)}function ah(r,t,e,n){return Un(xh(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 ih(this,t,e,n);case"utf8":case"utf-8":return oh(this,t,e,n);case"ascii":case"latin1":case"binary":return sh(this,t,e,n);case"base64":return ch(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ah(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 fh(r,t,e){return t===0&&e===r.length?Zi.fromByteArray(r):Zi.fromByteArray(r.slice(t,e))}function _c(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 uh(n)}var Sc=4096;function uh(r){let t=r.length;if(t<=Sc)return String.fromCharCode.apply(String,r);let e="",n=0;for(;n<t;)e+=String.fromCharCode.apply(String,r.slice(n,n+=Sc));return e}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]&127);return n}function lh(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 dh(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+=bh[r[o]];return i}function ph(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=Ee(function(t){t=t>>>0,xr(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&Gr(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=Ee(function(t){t=t>>>0,xr(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&Gr(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=Ee(function(t){t=t>>>0,xr(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&Gr(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=Ee(function(t){t=t>>>0,xr(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&Gr(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),gr.read(this,t,!0,23,4)};g.prototype.readFloatBE=function(t,e){return t=t>>>0,e||ft(t,4,this.length),gr.read(this,t,!1,23,4)};g.prototype.readDoubleLE=function(t,e){return t=t>>>0,e||ft(t,8,this.length),gr.read(this,t,!0,52,8)};g.prototype.readDoubleBE=function(t,e){return t=t>>>0,e||ft(t,8,this.length),gr.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 Cc(r,t,e,n,i){Dc(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 Lc(r,t,e,n,i){Dc(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=Ee(function(t,e=0){return Cc(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))});g.prototype.writeBigUInt64BE=Ee(function(t,e=0){return Lc(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=Ee(function(t,e=0){return Cc(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});g.prototype.writeBigInt64BE=Ee(function(t,e=0){return Lc(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Oc(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 Rc(r,t,e,n,i){return t=+t,e=e>>>0,i||Oc(r,t,e,4,34028234663852886e22,-34028234663852886e22),gr.write(r,t,e,n,23,4),e+4}g.prototype.writeFloatLE=function(t,e,n){return Rc(this,t,e,!0,n)};g.prototype.writeFloatBE=function(t,e,n){return Rc(this,t,e,!1,n)};function Nc(r,t,e,n,i){return t=+t,e=e>>>0,i||Oc(r,t,e,8,17976931348623157e292,-17976931348623157e292),gr.write(r,t,e,n,52,8),e+8}g.prototype.writeDoubleLE=function(t,e,n){return Nc(this,t,e,!0,n)};g.prototype.writeDoubleBE=function(t,e,n){return Nc(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 wr={};function ro(r,t,e){wr[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}`}}}ro("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);ro("ERR_INVALID_ARG_TYPE",function(r,t){return`The "${r}" argument must be of type number. Received type ${typeof t}`},TypeError);ro("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=kc(String(e)):typeof e=="bigint"&&(i=String(e),(e>BigInt(2)**BigInt(32)||e<-(BigInt(2)**BigInt(32)))&&(i=kc(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n},RangeError);function kc(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 yh(r,t,e){xr(t,"offset"),(r[t]===void 0||r[t+e]===void 0)&&Gr(t,r.length-(e+1))}function Dc(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 wr.ERR_OUT_OF_RANGE("value",c,r)}yh(n,i,o)}function xr(r,t){if(typeof r!="number")throw new wr.ERR_INVALID_ARG_TYPE(t,"number",r)}function Gr(r,t,e){throw Math.floor(r)!==r?(xr(r,e),new wr.ERR_OUT_OF_RANGE(e||"offset","an integer",r)):t<0?new wr.ERR_BUFFER_OUT_OF_BOUNDS:new wr.ERR_OUT_OF_RANGE(e||"offset",`>= ${e?1:0} and <= ${t}`,r)}var mh=/[^+/0-9A-Za-z-_]/g;function wh(r){if(r=r.split("=")[0],r=r.trim().replace(mh,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function Qi(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 gh(r){let t=[];for(let e=0;e<r.length;++e)t.push(r.charCodeAt(e)&255);return t}function xh(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 Mc(r){return Zi.toByteArray(wh(r))}function Un(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 Wt(r,t){return r instanceof t||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===t.name}function no(r){return r!==r}var bh=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 Ee(r){return typeof BigInt>"u"?Eh:r}function Eh(){throw new Error("BigInt not supported")}});var oo=Y((yy,jc)=>{"use strict";var io=null;jc.exports=function(){return io===null&&(io={textEncoder:new TextEncoder,textDecoder:new TextDecoder}),io}});var ao=Y(Jc=>{"use strict";var so=Lt(),vh=new Set(["buffer","view","utf8"]),co=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"||!vh.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 so(`Encoding '${this.name}' cannot be transcoded to 'buffer'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createViewTranscoder(){throw new so(`Encoding '${this.name}' cannot be transcoded to 'view'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createUTF8Transcoder(){throw new so(`Encoding '${this.name}' cannot be transcoded to 'utf8'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}};Jc.Encoding=co});var lo=Y(In=>{"use strict";var{Buffer:uo}=Kn()||{},{Encoding:ho}=ao(),Ah=oo(),qr=class extends ho{constructor(t){super({...t,format:"buffer"})}createViewTranscoder(){return new Fr({encode:this.encode,decode:t=>this.decode(uo.from(t.buffer,t.byteOffset,t.byteLength)),name:`${this.name}+view`})}createBufferTranscoder(){return this}},Fr=class extends ho{constructor(t){super({...t,format:"view"})}createBufferTranscoder(){return new qr({encode:t=>{let e=this.encode(t);return uo.from(e.buffer,e.byteOffset,e.byteLength)},decode:this.decode,name:`${this.name}+buffer`})}createViewTranscoder(){return this}},fo=class extends ho{constructor(t){super({...t,format:"utf8"})}createBufferTranscoder(){return new qr({encode:t=>uo.from(this.encode(t),"utf8"),decode:t=>this.decode(t.toString("utf8")),name:`${this.name}+buffer`})}createViewTranscoder(){let{textEncoder:t,textDecoder:e}=Ah();return new Fr({encode:n=>t.encode(this.encode(n)),decode:n=>this.decode(e.decode(n)),name:`${this.name}+view`})}createUTF8Transcoder(){return this}};In.BufferFormat=qr;In.ViewFormat=Fr;In.UTF8Format=fo});var qc=Y(Ge=>{"use strict";var{Buffer:pt}=Kn()||{Buffer:{isBuffer:()=>!1}},{textEncoder:Hc,textDecoder:Vc}=oo()(),{BufferFormat:$r,ViewFormat:po,UTF8Format:Gc}=lo(),_n=r=>r;Ge.utf8=new Gc({encode:function(r){return pt.isBuffer(r)?r.toString("utf8"):ArrayBuffer.isView(r)?Vc.decode(r):String(r)},decode:_n,name:"utf8",createViewTranscoder(){return new po({encode:function(r){return ArrayBuffer.isView(r)?r:Hc.encode(r)},decode:function(r){return Vc.decode(r)},name:`${this.name}+view`})},createBufferTranscoder(){return new $r({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 Gc({encode:JSON.stringify,decode:JSON.parse,name:"json"});Ge.buffer=new $r({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:_n,name:"buffer",createViewTranscoder(){return new po({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 po({encode:function(r){return ArrayBuffer.isView(r)?r:Hc.encode(r)},decode:_n,name:"view",createBufferTranscoder(){return new $r({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:_n,name:`${this.name}+buffer`})}});Ge.hex=new $r({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 $r({encode:function(r){return pt.isBuffer(r)?r:pt.from(String(r),"base64")},decode:function(r){return r.toString("base64")},name:"base64"})});var Wc=Y($c=>{"use strict";var Fc=Lt(),Ln=qc(),{Encoding:Bh}=ao(),{BufferFormat:Th,ViewFormat:Sh,UTF8Format:kh}=lo(),Wr=Symbol("formats"),Cn=Symbol("encodings"),Ph=new Set(["buffer","view","utf8"]),yo=class{constructor(t){if(Array.isArray(t)){if(!t.every(e=>Ph.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[Cn]=new Map,this[Wr]=new Set(t);for(let e in Ln)try{this.encoding(e)}catch(n){if(n.code!=="LEVEL_ENCODING_NOT_SUPPORTED")throw n}}encodings(){return Array.from(new Set(this[Cn].values()))}encoding(t){let e=this[Cn].get(t);if(e===void 0){if(typeof t=="string"&&t!==""){if(e=_h[t],!e)throw new Fc(`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=Uh(t)}let{name:n,format:i}=e;if(!this[Wr].has(i))if(this[Wr].has("view"))e=e.createViewTranscoder();else if(this[Wr].has("buffer"))e=e.createBufferTranscoder();else if(this[Wr].has("utf8"))e=e.createUTF8Transcoder();else throw new Fc(`Encoding '${n}' cannot be transcoded`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"});for(let o of[t,n,e.name,e.commonName])this[Cn].set(o,e)}return e}};$c.Transcoder=yo;function Uh(r){if(r instanceof Bh)return r;let t="type"in r&&typeof r.type=="string"?r.type:void 0,e=r.name||t||`anonymous-${Ch++}`;switch(Kh(r)){case"view":return new Sh({...r,name:e});case"utf8":return new kh({...r,name:e});case"buffer":return new Th({...r,name:e});default:throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'")}}function Kh(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 Ih={binary:Ln.buffer,"utf-8":Ln.utf8},_h={...Ln,...Ih},Ch=0});var oa=Y((by,mo)=>{"use strict";var Er=typeof Reflect=="object"?Reflect:null,zc=Er&&typeof Er.apply=="function"?Er.apply:function(t,e,n){return Function.prototype.apply.call(t,e,n)},On;Er&&typeof Er.ownKeys=="function"?On=Er.ownKeys:Object.getOwnPropertySymbols?On=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:On=function(t){return Object.getOwnPropertyNames(t)};function Lh(r){console&&console.warn&&console.warn(r)}var Yc=Number.isNaN||function(t){return t!==t};function tt(){tt.init.call(this)}mo.exports=tt;mo.exports.once=Dh;tt.EventEmitter=tt;tt.prototype._events=void 0;tt.prototype._eventsCount=0;tt.prototype._maxListeners=void 0;var Zc=10;function Rn(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 Zc},set:function(r){if(typeof r!="number"||r<0||Yc(r))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+r+".");Zc=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||Yc(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 Xc(r){return r._maxListeners===void 0?tt.defaultMaxListeners:r._maxListeners}tt.prototype.getMaxListeners=function(){return Xc(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")zc(a,this,e);else for(var f=a.length,u=na(a,f),n=0;n<f;++n)zc(u[n],this,e);return!0};function Qc(r,t,e,n){var i,o,s;if(Rn(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=Xc(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,Lh(c)}return r}tt.prototype.addListener=function(t,e){return Qc(this,t,e,!1)};tt.prototype.on=tt.prototype.addListener;tt.prototype.prependListener=function(t,e){return Qc(this,t,e,!0)};function Oh(){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 ta(r,t,e){var n={fired:!1,wrapFn:void 0,target:r,type:t,listener:e},i=Oh.bind(n);return i.listener=e,n.wrapFn=i,i}tt.prototype.once=function(t,e){return Rn(e),this.on(t,ta(this,t,e)),this};tt.prototype.prependOnceListener=function(t,e){return Rn(e),this.prependListener(t,ta(this,t,e)),this};tt.prototype.removeListener=function(t,e){var n,i,o,s,c;if(Rn(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():Rh(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 ea(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?Nh(i):na(i,i.length)}tt.prototype.listeners=function(t){return ea(this,t,!0)};tt.prototype.rawListeners=function(t){return ea(this,t,!1)};tt.listenerCount=function(r,t){return typeof r.listenerCount=="function"?r.listenerCount(t):ra.call(r,t)};tt.prototype.listenerCount=ra;function ra(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?On(this._events):[]};function na(r,t){for(var e=new Array(t),n=0;n<t;++n)e[n]=r[n];return e}function Rh(r,t){for(;t+1<r.length;t++)r[t]=r[t+1];r.pop()}function Nh(r){for(var t=new Array(r.length),e=0;e<t.length;++e)t[e]=r[e].listener||r[e];return t}function Dh(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))}ia(r,t,o,{once:!0}),t!=="error"&&Mh(r,i,{once:!0})})}function Mh(r,t,e){typeof r.on=="function"&&ia(r,"error",t,e)}function ia(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 ca=Y((Ey,sa)=>{sa.exports=typeof queueMicrotask=="function"?queueMicrotask:r=>Promise.resolve().then(r)});var zr=Y(wo=>{"use strict";var aa=ca();wo.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};wo.fromPromise=function(r,t){if(t===void 0)return r;r.then(function(e){aa(()=>t(null,e))}).catch(function(e){aa(()=>t(e))})}});var Nn=Y(go=>{"use strict";go.getCallback=function(r,t){return typeof r=="function"?r:t};go.getOptions=function(r,t){return typeof r=="object"&&r!==null?r:t!==void 0?t:{}}});var ke=Y(Jn=>{"use strict";var{fromCallback:xo}=zr(),Et=Lt(),{getOptions:bo,getCallback:fa}=Nn(),qe=Symbol("promise"),vr=Symbol("callback"),zt=Symbol("working"),Fe=Symbol("handleOne"),ne=Symbol("handleMany"),Eo=Symbol("autoClose"),Te=Symbol("finishWork"),Zt=Symbol("returnMany"),ve=Symbol("closing"),Zr=Symbol("handleClose"),Dn=Symbol("closed"),Yr=Symbol("closeCallbacks"),Be=Symbol("keyEncoding"),$e=Symbol("valueEncoding"),vo=Symbol("abortOnClose"),Mn=Symbol("legacy"),Ao=Symbol("keys"),Bo=Symbol("values"),Ae=Symbol("limit"),Pt=Symbol("count"),jn=Object.freeze({}),jh=()=>{},ua=!1,Xr=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[Dn]=!1,this[Yr]=[],this[zt]=!1,this[ve]=!1,this[Eo]=!1,this[vr]=null,this[Fe]=this[Fe].bind(this),this[ne]=this[ne].bind(this),this[Zr]=this[Zr].bind(this),this[Be]=e[Be],this[$e]=e[$e],this[Mn]=n,this[Ae]=Number.isInteger(e.limit)&&e.limit>=0?e.limit:1/0,this[Pt]=0,this[vo]=!!e.abortOnClose,this.db=t,this.db.attachResource(this),this.nextTick=t.nextTick}get count(){return this[Pt]}get limit(){return this[Ae]}next(t){let e;if(t===void 0)e=new Promise((n,i)=>{t=(o,s,c)=>{o?i(o):this[Mn]?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[ve]?this.nextTick(t,new Et("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[zt]?this.nextTick(t,new Et("Iterator is busy: cannot call next() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[zt]=!0,this[vr]=t,this[Pt]>=this[Ae]?this.nextTick(this[Fe],null):this._next(this[Fe])),e}_next(t){this.nextTick(t)}nextv(t,e,n){return n=fa(e,n),n=xo(n,qe),e=bo(e,jn),Number.isInteger(t)?(this[ve]?this.nextTick(n,new Et("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[zt]?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[Ae]<1/0&&(t=Math.min(t,this[Ae]-this[Pt])),this[zt]=!0,this[vr]=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[Mn]?c===void 0&&a===void 0:c===void 0)return n(null,i);i.push(this[Mn]?[c,a]:c),i.length===t?n(null,i):this._next(o)};this._next(o)}all(t,e){return e=fa(t,e),e=xo(e,qe),t=bo(t,jn),this[ve]?this.nextTick(e,new Et("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[zt]?this.nextTick(e,new Et("Iterator is busy: cannot call all() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[zt]=!0,this[vr]=e,this[Eo]=!0,this[Pt]>=this[Ae]?this.nextTick(this[ne],null,[]):this._all(t,this[ne])),e[qe]}_all(t,e){let n=this[Pt],i=[],o=()=>{let c=this[Ae]<1/0?Math.min(1e3,this[Ae]-n):1e3;c<=0?this.nextTick(e,null,i):this._nextv(c,jn,s)},s=(c,a)=>{c?e(c):a.length===0?e(null,i):(i.push.apply(i,a),n+=a.length,o())};o()}[Te](){let t=this[vr];return this[vo]&&t===null?jh:(this[zt]=!1,this[vr]=null,this[ve]&&this._close(this[Zr]),t)}[Zt](t,e,n){this[Eo]?this.close(t.bind(null,e,n)):t(e,n)}seek(t,e){if(e=bo(e,jn),!this[ve]){if(this[zt])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[Be]),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=xo(t,qe),this[Dn]?this.nextTick(t):this[ve]?this[Yr].push(t):(this[ve]=!0,this[Yr].push(t),this[zt]?this[vo]&&this[Te]()(new Et("Aborted on iterator close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this._close(this[Zr])),t[qe]}_close(t){this.nextTick(t)}[Zr](){this[Dn]=!0,this.db.detachResource(this);let t=this[Yr];this[Yr]=[];for(let e of t)e()}async*[Symbol.asyncIterator](){try{let t;for(;(t=await this.next())!==void 0;)yield t}finally{this[Dn]||await this.close()}}},Ar=class extends Xr{constructor(t,e){super(t,e,!0),this[Ao]=e.keys!==!1,this[Bo]=e.values!==!1}[Fe](t,e,n){let i=this[Te]();if(t)return i(t);try{e=this[Ao]&&e!==void 0?this[Be].decode(e):void 0,n=this[Bo]&&n!==void 0?this[$e].decode(n):void 0}catch(o){return i(new Se("entry",o))}e===void 0&&n===void 0||this[Pt]++,i(null,e,n)}[ne](t,e){let n=this[Te]();if(t)return this[Zt](n,t);try{for(let i of e){let o=i[0],s=i[1];i[0]=this[Ao]&&o!==void 0?this[Be].decode(o):void 0,i[1]=this[Bo]&&s!==void 0?this[$e].decode(s):void 0}}catch(i){return this[Zt](n,new Se("entries",i))}this[Pt]+=e.length,this[Zt](n,null,e)}end(t){return!ua&&typeof console<"u"&&(ua=!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)}},To=class extends Xr{constructor(t,e){super(t,e,!1)}[Fe](t,e){let n=this[Te]();if(t)return n(t);try{e=e!==void 0?this[Be].decode(e):void 0}catch(i){return n(new Se("key",i))}e!==void 0&&this[Pt]++,n(null,e)}[ne](t,e){let n=this[Te]();if(t)return this[Zt](n,t);try{for(let i=0;i<e.length;i++){let o=e[i];e[i]=o!==void 0?this[Be].decode(o):void 0}}catch(i){return this[Zt](n,new Se("keys",i))}this[Pt]+=e.length,this[Zt](n,null,e)}},So=class extends Xr{constructor(t,e){super(t,e,!1)}[Fe](t,e){let n=this[Te]();if(t)return n(t);try{e=e!==void 0?this[$e].decode(e):void 0}catch(i){return n(new Se("value",i))}e!==void 0&&this[Pt]++,n(null,e)}[ne](t,e){let n=this[Te]();if(t)return this[Zt](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[Zt](n,new Se("values",i))}this[Pt]+=e.length,this[Zt](n,null,e)}},Se=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(Ar.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"})}});Ar.keyEncoding=Be;Ar.valueEncoding=$e;Jn.AbstractIterator=Ar;Jn.AbstractKeyIterator=To;Jn.AbstractValueIterator=So});var ha=Y(ko=>{"use strict";var{AbstractKeyIterator:Jh,AbstractValueIterator:Vh}=ke(),We=Symbol("iterator"),Qr=Symbol("callback"),Br=Symbol("handleOne"),ze=Symbol("handleMany"),tn=class extends Jh{constructor(t,e){super(t,e),this[We]=t.iterator({...e,keys:!0,values:!1}),this[Br]=this[Br].bind(this),this[ze]=this[ze].bind(this)}},Vn=class extends Vh{constructor(t,e){super(t,e),this[We]=t.iterator({...e,keys:!1,values:!0}),this[Br]=this[Br].bind(this),this[ze]=this[ze].bind(this)}};for(let r of[tn,Vn]){let t=r===tn,e=t?n=>n[0]:n=>n[1];r.prototype._next=function(n){this[Qr]=n,this[We].next(this[Br])},r.prototype[Br]=function(n,i,o){let s=this[Qr];n?s(n):s(null,t?i:o)},r.prototype._nextv=function(n,i,o){this[Qr]=o,this[We].nextv(n,i,this[ze])},r.prototype._all=function(n,i){this[Qr]=i,this[We].all(n,this[ze])},r.prototype[ze]=function(n,i){let o=this[Qr];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)}}ko.DefaultKeyIterator=tn;ko.DefaultValueIterator=Vn});var la=Y(Wn=>{"use strict";var{AbstractIterator:Hh,AbstractKeyIterator:Gh,AbstractValueIterator:qh}=ke(),Po=Lt(),gt=Symbol("nut"),Fn=Symbol("undefer"),$n=Symbol("factory"),Hn=class extends Hh{constructor(t,e){super(t,e),this[gt]=null,this[$n]=()=>t.iterator(e),this.db.defer(()=>this[Fn]())}},Gn=class extends Gh{constructor(t,e){super(t,e),this[gt]=null,this[$n]=()=>t.keys(e),this.db.defer(()=>this[Fn]())}},qn=class extends qh{constructor(t,e){super(t,e),this[gt]=null,this[$n]=()=>t.values(e),this.db.defer(()=>this[Fn]())}};for(let r of[Hn,Gn,qn])r.prototype[Fn]=function(){this.db.status==="open"&&(this[gt]=this[$n]())},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 Po("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 Po("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 Po("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)};Wn.DeferredIterator=Hn;Wn.DeferredKeyIterator=Gn;Wn.DeferredValueIterator=qn});var Ko=Y(pa=>{"use strict";var{fromCallback:da}=zr(),zn=Lt(),{getCallback:Fh,getOptions:$h}=Nn(),Zn=Symbol("promise"),Ut=Symbol("status"),Tr=Symbol("operations"),en=Symbol("finishClose"),Sr=Symbol("closeCallbacks"),Uo=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[Tr]=[],this[Sr]=[],this[Ut]="open",this[en]=this[en].bind(this),this.db=t,this.db.attachResource(this),this.nextTick=t.nextTick}get length(){return this[Tr].length}put(t,e,n){if(this[Ut]!=="open")throw new zn("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[Tr].push({...s,type:"put",key:t,value:e}),this}_put(t,e,n){}del(t,e){if(this[Ut]!=="open")throw new zn("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[Tr].push({...o,type:"del",key:t}),this}_del(t,e){}clear(){if(this[Ut]!=="open")throw new zn("Batch is not open: cannot call clear() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});return this._clear(),this[Tr]=[],this}_clear(){}write(t,e){return e=Fh(t,e),e=da(e,Zn),t=$h(t),this[Ut]!=="open"?this.nextTick(e,new zn("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"})):this.length===0?this.close(e):(this[Ut]="writing",this._write(t,n=>{this[Ut]="closing",this[Sr].push(()=>e(n)),n||this.db.emit("batch",this[Tr]),this._close(this[en])})),e[Zn]}_write(t,e){}close(t){return t=da(t,Zn),this[Ut]==="closing"?this[Sr].push(t):this[Ut]==="closed"?this.nextTick(t):(this[Sr].push(t),this[Ut]!=="writing"&&(this[Ut]="closing",this._close(this[en]))),t[Zn]}_close(t){this.nextTick(t)}[en](){this[Ut]="closed",this.db.detachResource(this);let t=this[Sr];this[Sr]=[];for(let e of t)e()}};pa.AbstractChainedBatch=Uo});var ma=Y(ya=>{"use strict";var{AbstractChainedBatch:Wh}=Ko(),zh=Lt(),kr=Symbol("encoded"),Io=class extends Wh{constructor(t){super(t),this[kr]=[]}_put(t,e,n){this[kr].push({...n,type:"put",key:t,value:e})}_del(t,e){this[kr].push({...e,type:"del",key:t})}_clear(){this[kr]=[]}_write(t,e){this.db.status==="opening"?this.db.defer(()=>this._write(t,e)):this.db.status==="open"?this[kr].length===0?this.nextTick(e):this.db._batch(this[kr],t,e):this.nextTick(e,new zh("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"}))}};ya.DefaultChainedBatch=Io});var xa=Y((Uy,ga)=>{"use strict";var wa=Lt(),Zh=Object.prototype.hasOwnProperty,Yh=new Set(["lt","lte","gt","gte"]);ga.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 wa(`The legacy range option '${n}' has been removed`,{code:"LEVEL_LEGACY"});if(n==="encoding")throw new wa("The levelup-style 'encoding' alias has been removed, use 'valueEncoding' instead",{code:"LEVEL_LEGACY"});Yh.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 _o=Y((Ky,Ea)=>{var ba;Ea.exports=typeof queueMicrotask=="function"?queueMicrotask.bind(typeof window<"u"?window:globalThis):r=>(ba||(ba=Promise.resolve())).then(r).catch(t=>setTimeout(()=>{throw t},0))});var Ba=Y((Iy,Aa)=>{"use strict";var va=_o();Aa.exports=function(r,...t){t.length===0?va(r):va(()=>r(...t))}});var Ta=Y(Yn=>{"use strict";var{AbstractIterator:Xh,AbstractKeyIterator:Qh,AbstractValueIterator:tl}=ke(),Pr=Symbol("unfix"),Ot=Symbol("iterator"),Ze=Symbol("handleOne"),Pe=Symbol("handleMany"),ie=Symbol("callback"),rn=class extends Xh{constructor(t,e,n,i){super(t,e),this[Ot]=n,this[Pr]=i,this[Ze]=this[Ze].bind(this),this[Pe]=this[Pe].bind(this),this[ie]=null}[Ze](t,e,n){let i=this[ie];if(t)return i(t);e!==void 0&&(e=this[Pr](e)),i(t,e,n)}[Pe](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[Pr](o))}n(t,e)}},nn=class extends Qh{constructor(t,e,n,i){super(t,e),this[Ot]=n,this[Pr]=i,this[Ze]=this[Ze].bind(this),this[Pe]=this[Pe].bind(this),this[ie]=null}[Ze](t,e){let n=this[ie];if(t)return n(t);e!==void 0&&(e=this[Pr](e)),n(t,e)}[Pe](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[Pr](o))}n(t,e)}},on=class extends tl{constructor(t,e,n){super(t,e),this[Ot]=n}};for(let r of[rn,nn])r.prototype._next=function(t){this[ie]=t,this[Ot].next(this[Ze])},r.prototype._nextv=function(t,e,n){this[ie]=n,this[Ot].nextv(t,e,this[Pe])},r.prototype._all=function(t,e){this[ie]=e,this[Ot].all(t,this[Pe])};for(let r of[on])r.prototype._next=function(t){this[Ot].next(t)},r.prototype._nextv=function(t,e,n){this[Ot].nextv(t,e,n)},r.prototype._all=function(t,e){this[Ot].all(t,e)};for(let r of[rn,nn,on])r.prototype._seek=function(t,e){this[Ot].seek(t,e)},r.prototype._close=function(t){this[Ot].close(t)};Yn.AbstractSublevelIterator=rn;Yn.AbstractSublevelKeyIterator=nn;Yn.AbstractSublevelValueIterator=on});var Ua=Y((Cy,Pa)=>{"use strict";var Co=Lt(),{Buffer:Ro}=Kn()||{},{AbstractSublevelIterator:el,AbstractSublevelKeyIterator:rl,AbstractSublevelValueIterator:nl}=Ta(),oe=Symbol("prefix"),Sa=Symbol("upperBound"),sn=Symbol("prefixRange"),vt=Symbol("parent"),Lo=Symbol("unfix"),ka=new TextEncoder,il={separator:"!"};Pa.exports=function({AbstractLevel:r}){class t extends r{static defaults(n){if(typeof n=="string")throw new Co("The subleveldown string shorthand for { separator } has been removed",{code:"LEVEL_LEGACY"});if(n&&n.open)throw new Co("The subleveldown open option has been removed",{code:"LEVEL_LEGACY"});return n==null?il:n.separator?n:{...n,separator:"!"}}constructor(n,i,o){let{separator:s,manifest:c,...a}=t.defaults(o);i=sl(i,s);let f=s.charCodeAt(0)+1,u=n[vt]||n;if(!ka.encode(i).every(x=>x>f&&x<127))throw new Co(`Prefix must use bytes > ${f} < 127`,{code:"LEVEL_INVALID_PREFIX"});super(ol(u,c),a);let h=(n.prefix||"")+s+i+s,y=h.slice(0,-1)+String.fromCharCode(f);this[vt]=u,this[oe]=new Xn(h),this[Sa]=new Xn(y),this[Lo]=new No,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 Ro.concat([o,n],o.byteLength+n.byteLength)}}[sn](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[Sa][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[sn](n,n.keyEncoding),this[vt].clear(n,i)}_iterator(n){this[sn](n,n.keyEncoding);let i=this[vt].iterator(n),o=this[Lo].get(this[oe].utf8.length,n.keyEncoding);return new el(this,n,i,o)}_keys(n){this[sn](n,n.keyEncoding);let i=this[vt].keys(n),o=this[Lo].get(this[oe].utf8.length,n.keyEncoding);return new rl(this,n,i,o)}_values(n){this[sn](n,n.keyEncoding);let i=this[vt].values(n);return new nl(this,n,i)}}return{AbstractSublevel:t}};var ol=function(r,t){return{...r.supports,createIfMissing:!1,errorIfExists:!1,events:{},additionalMethods:{},...t,encodings:{utf8:Oo(r,"utf8"),buffer:Oo(r,"buffer"),view:Oo(r,"view")}}},Oo=function(r,t){return r.supports.encodings[t]?r.keyEncoding(t).name===t:!1},Xn=class{constructor(t){this.utf8=t,this.view=ka.encode(t),this.buffer=Ro?Ro.from(this.view.buffer,0,this.view.byteLength):{}}},No=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}},sl=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 Vo=Y(Jo=>{"use strict";var{supports:cl}=gc(),{Transcoder:al}=Wc(),{EventEmitter:fl}=oa(),{fromCallback:Ue}=zr(),Rt=Lt(),{AbstractIterator:Ye}=ke(),{DefaultKeyIterator:ul,DefaultValueIterator:hl}=ha(),{DeferredIterator:ll,DeferredKeyIterator:dl,DeferredValueIterator:pl}=la(),{DefaultChainedBatch:Ka}=ma(),{getCallback:Xe,getOptions:Ke}=Nn(),Qn=xa(),$=Symbol("promise"),se=Symbol("landed"),Qe=Symbol("resources"),Do=Symbol("closeResources"),cn=Symbol("operations"),an=Symbol("undefer"),ti=Symbol("deferOpen"),Ia=Symbol("options"),Z=Symbol("status"),tr=Symbol("defaultOptions"),Ur=Symbol("transcoder"),ei=Symbol("keyEncoding"),Mo=Symbol("valueEncoding"),yl=()=>{},fn=class extends fl{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[cn]=[],this[ti]=!0,this[Ia]=s,this[Z]="opening",this.supports=cl(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[Ur]=new al(ml(this)),this[ei]=this[Ur].encoding(n||"utf8"),this[Mo]=this[Ur].encoding(i||"utf8");for(let c of this[Ur].encodings())this.supports.encodings[c.commonName]||(this.supports.encodings[c.commonName]=!0);this[tr]={empty:Object.freeze({}),entry:Object.freeze({keyEncoding:this[ei].commonName,valueEncoding:this[Mo].commonName}),key:Object.freeze({keyEncoding:this[ei].commonName})},this.nextTick(()=>{this[ti]&&this.open({passive:!1},yl)})}get status(){return this[Z]}keyEncoding(t){return this[Ur].encoding(t??this[ei])}valueEncoding(t){return this[Ur].encoding(t??this[Mo])}open(t,e){e=Xe(t,e),e=Ue(e,$),t={...this[Ia],...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 Rt("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[ti]?(this[ti]=!1,this[Z]="opening",this.emit("opening"),this._open(t,i=>{if(i){this[Z]="closed",this[Do](()=>{this.emit(se),n(i)}),this[an]();return}this[Z]="open",this[an](),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=Ue(t,$);let e=n=>{this[Z]==="opening"||this[Z]==="closing"?this.once(se,n?e(n):e):this[Z]!=="closed"?t(new Rt("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[an](),this.emit(se),e(i)};this[Do](()=>{this._close(i=>{if(i)return n(i);this[Z]="closed",this[an](),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[$]}[Do](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=Ue(n,$),e=Ke(e,this[tr].entry),this[Z]==="opening")return this.defer(()=>this.get(t,e,n)),n[$];if(Kr(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 Rt("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=Ue(n,$),e=Ke(e,this[tr].entry),this[Z]==="opening")return this.defer(()=>this.getMany(t,e,n)),n[$];if(Kr(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 Rt(`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=Ue(i,$),n=Ke(n,this[tr].entry),this[Z]==="opening")return this.defer(()=>this.put(t,e,n,i)),i[$];if(Kr(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=Ue(n,$),e=Ke(e,this[tr].key),this[Z]==="opening")return this.defer(()=>this.del(t,e,n)),n[$];if(Kr(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 Ka(this);if(this[Z]!=="open")throw new Rt("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._chainedBatch()}if(typeof t=="function"?n=t:n=Xe(e,n),n=Ue(n,$),e=Ke(e,this[tr].empty),this[Z]==="opening")return this.defer(()=>this.batch(t,e,n)),n[$];if(Kr(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,jo.defaults(e))}_sublevel(t,e){return new jo(this,t,e)}prefixKey(t,e){return t}clear(t,e){if(e=Xe(t,e),e=Ue(e,$),t=Ke(t,this[tr].empty),this[Z]==="opening")return this.defer(()=>this.clear(t,e)),e[$];if(Kr(this,e))return e[$];let n=t,i=this.keyEncoding(t.keyEncoding);return t=Qn(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=Qn(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 ll(this,t);if(this[Z]!=="open")throw new Rt("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=Qn(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 Rt("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._keys(t)}_keys(t){return new ul(this,t)}values(t){let e=this.keyEncoding(t&&t.keyEncoding),n=this.valueEncoding(t&&t.valueEncoding);if(t=Qn(t,e),t[Ye.keyEncoding]=e,t[Ye.valueEncoding]=n,t.keyEncoding=e.format,t.valueEncoding=n.format,this[Z]==="opening")return new pl(this,t);if(this[Z]!=="open")throw new Rt("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._values(t)}_values(t){return new hl(this,t)}defer(t){if(typeof t!="function")throw new TypeError("The first argument must be a function");this[cn].push(t)}[an](){if(this[cn].length===0)return;let t=this[cn];this[cn]=[];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 Ka(this)}_checkKey(t){if(t==null)return new Rt("Key cannot be null or undefined",{code:"LEVEL_INVALID_KEY"})}_checkValue(t){if(t==null)return new Rt("Value cannot be null or undefined",{code:"LEVEL_INVALID_VALUE"})}};fn.prototype.nextTick=Ba();var{AbstractSublevel:jo}=Ua()({AbstractLevel:fn});Jo.AbstractLevel=fn;Jo.AbstractSublevel=jo;var Kr=function(r,t){return r[Z]!=="open"?(r.nextTick(t,new Rt("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"})),!0):!1},ml=function(r){return Object.keys(r.supports.encodings).filter(t=>!!r.supports.encodings[t])}});var Ho=Y(er=>{"use strict";er.AbstractLevel=Vo().AbstractLevel;er.AbstractSublevel=Vo().AbstractSublevel;er.AbstractIterator=ke().AbstractIterator;er.AbstractKeyIterator=ke().AbstractKeyIterator;er.AbstractValueIterator=ke().AbstractValueIterator;er.AbstractChainedBatch=Ko().AbstractChainedBatch});var Ca=Y((Ry,_a)=>{_a.exports=gl;var wl=_o();function gl(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?wl(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 Go=Y((Ny,La)=>{"use strict";La.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 qo=Y((Dy,Oa)=>{"use strict";var xl=new TextEncoder;Oa.exports=function(r){return r instanceof Uint8Array?r:r instanceof ArrayBuffer?new Uint8Array(r):xl.encode(r)}});var ja=Y(Ma=>{"use strict";var{AbstractIterator:bl}=Ho(),Ra=Go(),ri=qo(),Yt=Symbol("cache"),ce=Symbol("finished"),At=Symbol("options"),ae=Symbol("currentOptions"),rr=Symbol("position"),Fo=Symbol("location"),Ir=Symbol("first"),Na={},$o=class extends bl{constructor(t,e,n){super(t,n),this[Yt]=[],this[ce]=this.limit===0,this[At]=n,this[ae]={...n},this[rr]=void 0,this[Fo]=e,this[Ir]=!0}_nextv(t,e,n){if(this[Ir]=!1,this[ce])return this.nextTick(n,null,[]);if(this[Yt].length>0)return t=Math.min(t,this[Yt].length),this.nextTick(n,null,this[Yt].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=Ra(this[ae])}catch{return this[ce]=!0,this.nextTick(n,null,[])}let o=this.db.db.transaction([this[Fo]],"readonly"),s=o.objectStore(this[Fo]),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?ri(h):void 0,this[At].values&&y!==void 0?ri(y):void 0]),c.length<t?u.continue():Da(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?ri(x):void 0,this[At].values&&p!==void 0?ri(p):void 0]}Da(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[Yt].length>0){let[e,n]=this[Yt].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[Ir]&&(this[Ir]=!1,e=1),this._nextv(e,Na,(n,i)=>{if(n)return t(n);this[Yt]=i,this._next(t)})}}_all(t,e){this[Ir]=!1;let n=this[Yt].splice(0,this[Yt].length),i=this.limit-this.count-n.length;if(i<=0)return this.nextTick(e,null,n);this._nextv(i,Na,(o,s)=>{if(o)return e(o);n.length>0&&(s=n.concat(s)),e(null,s)})}_seek(t,e){this[Ir]=!0,this[Yt]=[],this[ce]=!1,this[rr]=void 0,this[ae]={...this[At]};let n;try{n=Ra(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}};Ma.Iterator=$o;function Da(r){typeof r.commit=="function"&&r.commit()}});var Va=Y((jy,Ja)=>{"use strict";Ja.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 Wa=Y($a=>{"use strict";var{AbstractLevel:El}=Ho(),Ha=Lt(),vl=Ca(),{fromCallback:Al}=zr(),{Iterator:Bl}=ja(),Ga=qo(),Tl=Va(),Sl=Go(),Fa="level-js-",un=Symbol("idb"),Wo=Symbol("namePrefix"),fe=Symbol("location"),zo=Symbol("version"),nr=Symbol("store"),hn=Symbol("onComplete"),qa=Symbol("promise"),ni=class extends El{constructor(t,e,n){if(typeof e=="function"||typeof n=="function")throw new Ha("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[Wo]=i??Fa,this[zo]=parseInt(o||1,10),this[un]=null}get location(){return this[fe]}get namePrefix(){return this[Wo]}get version(){return this[zo]}get db(){return this[un]}get type(){return"browser-level"}_open(t,e){let n=indexedDB.open(this[Wo]+this[fe],this[zo]);n.onerror=function(){e(n.error||new Error("unknown error"))},n.onsuccess=()=>{this[un]=n.result,e()},n.onupgradeneeded=i=>{let o=i.target.result;o.objectStoreNames.contains(this[fe])||o.createObjectStore(this[fe])}}[nr](t){return this[un].transaction([this[fe]],t).objectStore(this[fe])}[hn](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[hn](o,function(s,c){if(s)return n(s);if(c===void 0)return n(new Ha("Entry not found",{code:"LEVEL_NOT_FOUND"}));n(null,Ga(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:Ga(f))},a.onerror=f=>{f.stopPropagation(),c(a.error)}});vl(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[hn](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[hn](s,i)}_iterator(t){return new Bl(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=Sl(t)}catch{return this.nextTick(e)}if(t.limit>=0)return Tl(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[hn](i,e)}_close(t){this[un].close(),this.nextTick(t)}};ni.destroy=function(r,t,e){typeof t=="function"&&(e=t,t=Fa),e=Al(e,qa);let n=indexedDB.deleteDatabase(t+r);return n.onsuccess=function(){e()},n.onerror=function(i){e(i)},e[qa]};$a.BrowserLevel=ni});var Za=Y(za=>{za.Level=Wa().BrowserLevel});var fp={};Ii(fp,{AES_GCM_TAG_LENGTHS:()=>An,AesCtr:()=>lr,AesCtrAlgorithm:()=>Ts,AesGcm:()=>dr,AesGcmAlgorithm:()=>_s,AesKw:()=>Cs,ConcatKdf:()=>Ls,CryptoAlgorithm:()=>Bt,CryptoError:()=>Ct,CryptoErrorCode:()=>_i,CryptoUtils:()=>Bs,EcdsaAlgorithm:()=>Rr,Ed25519:()=>xe,EdDsaAlgorithm:()=>xn,Hkdf:()=>Os,KEY_URI_PREFIX_JWK:()=>bi,LocalKeyManager:()=>As,P256:()=>ge,POLY1305_TAG_LENGTH:()=>ap,Pbkdf2:()=>Rs,Secp256k1:()=>we,Secp256r1:()=>ge,Sha256:()=>ar,Sha2Algorithm:()=>bn,X25519:()=>Ns,XChaCha20:()=>Vs,XChaCha20Poly1305:()=>Hs,canonicalize:()=>ys,computeJwkThumbprint:()=>V,isEcPrivateJwk:()=>Jt,isEcPublicJwk:()=>fr,isOctPrivateJwk:()=>Vt,isOkpPrivateJwk:()=>Ht,isOkpPublicJwk:()=>ur,isPrivateJwk:()=>ms,isPublicJwk:()=>hd});var Ct=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)}},_i=(o=>(o.AlgorithmNotSupported="algorithmNotSupported",o.EncodingError="encodingError",o.InvalidJwe="invalidJwe",o.InvalidJwk="invalidJwk",o.OperationNotSupported="operationNotSupported",o))(_i||{});var lu=Qs(ec(),1);var pp=new Uint8Array(0);function rc(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 pr(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 pu(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 yu=pu,mu=yu,nc=mu;var Oi=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")}},Ri=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 ic(this,t)}},Ni=class{decoders;constructor(t){this.decoders=t}or(t){return ic(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 ic(r,t){return new Ni({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Di=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 Oi(t,e,n),this.decoder=new Ri(t,e,i)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function oc({name:r,prefix:t,encode:e,decode:n}){return new Di(r,t,e,n)}function Mi({name:r,prefix:t,alphabet:e}){let{encode:n,decode:i}=nc(e,r);return oc({prefix:t,name:r,encode:n,decode:o=>pr(i(o))})}function wu(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 gu(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 oc({prefix:t,name:r,encode(i){return gu(i,n,e)},decode(i){return wu(i,n,e,r)}})}var Dr=yt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),bp=yt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ep=yt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),vp=yt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ap=yt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Bp=yt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Tp=yt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Sp=yt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ji=yt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var mt=Mi({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Up=Mi({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var _p=yt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Cp=yt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),qt=yt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Lp=yt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function sc(r){return r.byteOffset!==0||r.byteLength!==r.buffer.byteLength}function cc(r){return typeof r!="object"||r===null?!1:typeof r[Symbol.asyncIterator]=="function"}function Mr(r){let e=Object.prototype.toString.call(r).match(/\s([a-zA-Z0-9]+)/),[n,i]=e;return i}var jr=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())})},ac=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)}},Sn=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(!cc(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 qt.baseDecode(this.data).buffer;case"BufferSource":{if(Mr(this.data)==="ArrayBuffer")return this.data;if(ArrayBuffer.isView(this.data))return sc(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 jr(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 ji.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 qt.baseEncode(t)}case"BufferSource":{let t=this.toUint8Array();return qt.baseEncode(t)}case"Object":{let t=JSON.stringify(this.data),e=Sn.encode(t);return qt.baseEncode(e)}case"String":{let t=Sn.encode(this.data);return qt.baseEncode(t)}case"Uint8Array":return qt.baseEncode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Base64Url is not supported.`)}}toBlobAsync(){return jr(this,void 0,void 0,function*(){var t,e,n,i;switch(this.format){case"AsyncIterable":{let a=[];try{for(var o=!0,s=ac(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=qt.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 jr(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=qt.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 jr(this,void 0,void 0,function*(){var t,e,n,i;switch(this.format){case"AsyncIterable":{let a="";try{for(var o=!0,s=ac(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 ji.baseDecode(this.data);case"Base58Btc":return mt.baseDecode(this.data);case"Base64Url":return qt.baseDecode(this.data);case"BufferSource":{let t=Mr(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 Sn.encode(t)}case"String":return Sn.encode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Uint8Array is not supported.`)}}toUint8ArrayAsync(){return jr(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 Ji=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)}},xu=new Ji;typeof window<"u"&&(window.web5logger=xu);var ee={};Ii(ee,{decode:()=>yr,encodeTo:()=>je,encodingLength:()=>Je});var bu=hc,fc=128,Eu=127,vu=~Eu,Au=Math.pow(2,31);function hc(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Au;)t[e++]=r&255|fc,r/=128;for(;r&vu;)t[e++]=r&255|fc,r>>>=7;return t[e]=r|0,hc.bytes=e-n+1,t}var Bu=Vi,Tu=128,uc=127;function Vi(r,n){var e=0,n=n||0,i=0,o=n,s,c=r.length;do{if(o>=c)throw Vi.bytes=0,new RangeError("Could not decode varint");s=r[o++],e+=i<28?(s&uc)<<i:(s&uc)*Math.pow(2,i),i+=7}while(s>=Tu);return Vi.bytes=o-n,e}var Su=Math.pow(2,7),ku=Math.pow(2,14),Pu=Math.pow(2,21),Uu=Math.pow(2,28),Ku=Math.pow(2,35),Iu=Math.pow(2,42),_u=Math.pow(2,49),Cu=Math.pow(2,56),Lu=Math.pow(2,63),Ou=function(r){return r<Su?1:r<ku?2:r<Pu?3:r<Uu?4:r<Ku?5:r<Iu?6:r<_u?7:r<Cu?8:r<Lu?9:10},Ru={encode:bu,decode:Bu,encodingLength:Ou},Nu=Ru,Vr=Nu;function yr(r,t=0){return[Vr.decode(r,t),Vr.decode.bytes]}function je(r,t,e=0){return Vr.encode(r,t,e),t}function Je(r){return Vr.encodingLength(r)}function Hi(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 mr(r,e,t,o)}function lc(r){let t=pr(r),[e,n]=yr(t),[i,o]=yr(t.subarray(n)),s=t.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new mr(e,i,s,t)}function dc(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&rc(r.bytes,e.bytes)}}var mr=class{code;size;digest;bytes;constructor(t,e,n,i){this.code=t,this.size=e,this.digest=n,this.bytes=i}};function pc(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return Mu(e,qi(r),t??mt.encoder);default:return ju(e,qi(r),t??Dr.encoder)}}var yc=new WeakMap;function qi(r){let t=yc.get(r);if(t==null){let e=new Map;return yc.set(r,e),e}return t}var Fi=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!==Hr)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=Hi(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&&dc(t.multihash,n.multihash)}toString(t){return pc(this,t)}toJSON(){return{"/":pc(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??mc(n,i,o.bytes))}else if(e[Vu]===!0){let{version:n,multihash:i,code:o}=e,s=lc(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!==Hr)throw new Error(`Version 0 CID must use dag-pb (code: ${Hr}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let i=mc(t,e,n.bytes);return new r(t,e,n,i)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Hr,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=pr(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 mr(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]=yr(t.subarray(e));return e+=y,h},i=n(),o=Hr;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]=Du(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 qi(o).set(n,t),o}};function Du(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 Dr.prefix:{let e=t??Dr;return[Dr.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 Mu(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 ju(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 Hr=112,Ju=18;function mc(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 Vu=Symbol.for("@ipld/js-cid/CID");var Ft=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}}};Ft.codeToName=new Map;Ft.nameToCode=new Map;Ft.registerCodec({code:237,name:"ed25519-pub"});Ft.registerCodec({code:4864,name:"ed25519-priv"});Ft.registerCodec({code:236,name:"x25519-pub"});Ft.registerCodec({code:4866,name:"x25519-priv"});Ft.registerCodec({code:231,name:"secp256k1-pub"});Ft.registerCodec({code:4865,name:"secp256k1-priv"});function $i(r){Object.keys(r).forEach(t=>{r[t]===void 0?delete r[t]:typeof r[t]=="object"&&$i(r[t])})}var kl=Qs(Za(),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 ii=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 Bt=class{};var si={};Ii(si,{bitGet:()=>Ll,bitLen:()=>Cl,bitMask:()=>ln,bitSet:()=>Ol,bytesToHex:()=>he,bytesToNumberBE:()=>le,bytesToNumberLE:()=>Dt,concatBytes:()=>pe,createHmacDrbg:()=>Xo,ensureBytes:()=>rt,equalBytes:()=>Il,hexToBytes:()=>or,hexToNumber:()=>Yo,isBytes:()=>Nt,numberToBytesBE:()=>xt,numberToBytesLE:()=>de,numberToHexUnpadded:()=>tf,numberToVarBytesBE:()=>Kl,utf8ToBytes:()=>_l,validateObject:()=>Kt});var Qa=BigInt(0),oi=BigInt(1),Pl=BigInt(2);function Nt(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}var Ul=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function he(r){if(!Nt(r))throw new Error("Uint8Array expected");let t="";for(let e=0;e<r.length;e++)t+=Ul[r[e]];return t}function tf(r){let t=r.toString(16);return t.length&1?`0${t}`:t}function Yo(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 Ya(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=Ya(r.charCodeAt(o)),c=Ya(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 Yo(he(r))}function Dt(r){if(!Nt(r))throw new Error("Uint8Array expected");return Yo(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 Kl(r){return or(tf(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(Nt(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(!Nt(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 Il(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 _l(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Cl(r){let t;for(t=0;r>Qa;r>>=oi,t+=1);return t}function Ll(r,t){return r>>BigInt(t)&oi}var Ol=(r,t,e)=>r|(e?oi:Qa)<<BigInt(t),ln=r=>(Pl<<BigInt(r-1))-oi,Zo=r=>new Uint8Array(r),Xa=r=>Uint8Array.from(r);function Xo(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=Zo(r),i=Zo(r),o=0,s=()=>{n.fill(1),i.fill(0),o=0},c=(...h)=>e(i,n,...h),a=(h=Zo())=>{i=c(Xa([0]),h),n=c(),h.length!==0&&(i=c(Xa([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 Rl={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"||Nt(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=Rl[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 ef(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`Wrong positive integer: ${r}`)}function Nl(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Qo(r,...t){if(!Nl(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 rf(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");ef(r.outputLen),ef(r.blockLen)}function _r(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 nf(r,t){Qo(r);let e=t.outputLen;if(r.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}var ci=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function of(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}var ai=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),Mt=(r,t)=>r<<32-t|r>>>t,Dl=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Dl)throw new Error("Non little-endian hardware is not supported");function ts(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function dn(r){if(typeof r=="string"&&(r=ts(r)),!of(r))throw new Error(`expected Uint8Array, got ${typeof r}`);return r}function fi(...r){let t=0;for(let n=0;n<r.length;n++){let i=r[n];if(!of(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 Cr=class{clone(){return this._cloneInto()}},o0={}.toString;function ui(r){let t=n=>r().update(dn(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function pn(r=32){if(ci&&typeof ci.getRandomValues=="function")return ci.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}function Ml(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 Lr=class extends Cr{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=ai(this.buffer)}update(t){_r(this);let{view:e,buffer:n,blockLen:i}=this;t=dn(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=ai(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){_r(this),nf(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;Ml(n,i-8,BigInt(this.length*8),o),this.process(n,0);let c=ai(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 jl=(r,t,e)=>r&t^~r&e,Jl=(r,t,e)=>r&t^r&e^t&e,Vl=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]),Ie=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),_e=new Uint32Array(64),es=class extends Lr{constructor(){super(64,32,8,!1),this.A=Ie[0]|0,this.B=Ie[1]|0,this.C=Ie[2]|0,this.D=Ie[3]|0,this.E=Ie[4]|0,this.F=Ie[5]|0,this.G=Ie[6]|0,this.H=Ie[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)_e[h]=t.getUint32(e,!1);for(let h=16;h<64;h++){let y=_e[h-15],x=_e[h-2],p=Mt(y,7)^Mt(y,18)^y>>>3,l=Mt(x,17)^Mt(x,19)^x>>>10;_e[h]=l+_e[h-7]+p+_e[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+jl(c,a,f)+Vl[h]+_e[h]|0,l=(Mt(n,2)^Mt(n,13)^Mt(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(){_e.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var hi=ui(()=>new es);var ct=BigInt(0),it=BigInt(1),sr=BigInt(2),Hl=BigInt(3),rs=BigInt(4),sf=BigInt(5),cf=BigInt(8),Gl=BigInt(9),ql=BigInt(16);function X(r,t){let e=r%t;return e>=ct?e:t+e}function ns(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 li(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 Fl(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&&ns(i,t,r)!==r-it;i++);if(n===1){let s=(r+it)/rs;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 $l(r){if(r%rs===Hl){let t=(r+it)/rs;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%cf===sf){let t=(r-sf)/cf;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%ql,Fl(r)}var af=(r,t)=>(X(r,t)&it)===it,Wl=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function is(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=Wl.reduce((n,i)=>(n[i]="function",n),t);return Kt(r,e)}function zl(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 os(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function Or(r,t,e=!1,n={}){if(r<=ct)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:i,nByteLength:o}=os(r,t);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=$l(r),c=Object.freeze({ORDER:r,BITS:i,BYTES:o,MASK:ln(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)=>zl(c,a,f),div:(a,f)=>X(a*li(f,r),r),sqrN:a=>a*a,addN:(a,f)=>a+f,subN:(a,f)=>a-f,mulN:(a,f)=>a*f,inv:a=>li(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?Dt(a):le(a)}});return Object.freeze(c)}function ff(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 uf(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 ss(r){let t=uf(r);return t+Math.ceil(t/2)}function hf(r,t,e=!1){let n=r.length,i=uf(t),o=ss(t);if(n<16||n<o||n>1024)throw new Error(`expected ${o}-1024 bytes of input, got ${n}`);let s=e?le(r):Dt(r),c=X(s,t-it)+it;return e?de(c,i):xt(c,i)}var Xl=BigInt(0),cs=BigInt(1);function di(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>Xl;)o&cs&&(s=s.add(c)),c=c.double(),o>>=cs;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+=cs);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 yn(r){return is(r.Fp),Kt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...os(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}function Ql(r){let t=yn(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:td,hexToBytes:ed}=si,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:td(n),l:r.subarray(e+2)}},toSig(r){let{Err:t}=cr,e=typeof r=="string"?ed(r):r;if(!Nt(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),b0=BigInt(2),lf=BigInt(3),E0=BigInt(4);function rd(r){let t=Ql(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(Nt(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,lf),{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,lf),_=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=di(h,t.endo?Math.ceil(y/2):y);return{CURVE:t,ProjectivePoint:h,normPrivateKeyToScalar:a,weierstrassEquation:o,isWithinCurveOrder:s}}function nd(r){let t=yn(r);return Kt(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function df(r){let t=nd(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 li(E,n)}let{ProjectivePoint:f,normPrivateKeyToScalar:u,weierstrassEquation:h,isWithinCurveOrder:y}=rd({...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)),H=a(I),z=c(-S*H),G=c(v*H),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=ss(t.n);return hf(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=Nt(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=ln(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),H=u(k),z=[D(H),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*H));if(te===ye)return;let De=(st.x===dt?0:2)|Number(st.y&It),Nr=te;return S&&p(te)&&(Nr=l(te),De^=1),new b(dt,Nr,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 Xo(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"||Nt(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:H,s:z}=C,G=K(k),q=a(z),et=c(G*q),Q=c(H*q),ut=f.BASE.multiplyAndAddUnsafe(J,et,Q)?.toAffine();return ut?c(ut.x)===H:!1}return{CURVE:t,getPublicKey:w,getSharedSecret:A,sign:M,verify:W,ProjectivePoint:f,Signature:b,utils:B}}var pi=class extends Cr{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,rf(t);let n=dn(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 _r(this),this.iHash.update(t),this}digestInto(t){_r(this),Qo(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()}},as=(r,t,e)=>new pi(r,t).update(e).digest();as.create=(r,t)=>new pi(r,t);function id(r){return{hash:r,hmac:(t,...e)=>as(r,t,fi(...e)),randomBytes:pn}}function yi(r,t){let e=n=>df({...r,...id(n)});return Object.freeze({...e(t),create:e})}var mf=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),pf=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),od=BigInt(1),fs=BigInt(2),yf=(r,t)=>(r+t/fs)/t;function sd(r){let t=mf,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,fs,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,fs,t);if(!us.eql(us.sqr(T),r))throw new Error("Cannot find square root");return T}var us=Or(mf,void 0,void 0,{sqrt:sd}),bt=yi({a:BigInt(0),b:BigInt(7),Fp:us,n:pf,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=pf,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-od*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=e,s=BigInt("0x100000000000000000000000000000000"),c=yf(o*r,t),a=yf(-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}}}},hi),C0=BigInt(0);var L0=bt.ProjectivePoint;function cd(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function mi(r,...t){if(!cd(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 hs(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 wf(r,t){mi(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 gi=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),jt=(r,t)=>r<<32-t|r>>>t;var j0=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function ad(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function ls(r){return typeof r=="string"&&(r=ad(r)),mi(r),r}function ds(...r){let t=0;for(let n=0;n<r.length;n++){let i=r[n];mi(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 wi=class{clone(){return this._cloneInto()}},J0={}.toString;function gf(r){let t=n=>r().update(ls(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function xf(r=32){if(me&&typeof me.getRandomValues=="function")return me.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}function fd(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 bf=(r,t,e)=>r&t^~r&e,Ef=(r,t,e)=>r&t^r&e^t&e,xi=class extends wi{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=gi(this.buffer)}update(t){hs(this);let{view:e,buffer:n,blockLen:i}=this;t=ls(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=gi(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){hs(this),wf(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;fd(n,i-8,BigInt(this.length*8),o),this.process(n,0);let c=gi(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 ud=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]),Ce=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Le=new Uint32Array(64),ps=class extends xi{constructor(){super(64,32,8,!1),this.A=Ce[0]|0,this.B=Ce[1]|0,this.C=Ce[2]|0,this.D=Ce[3]|0,this.E=Ce[4]|0,this.F=Ce[5]|0,this.G=Ce[6]|0,this.H=Ce[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)Le[h]=t.getUint32(e,!1);for(let h=16;h<64;h++){let y=Le[h-15],x=Le[h-2],p=jt(y,7)^jt(y,18)^y>>>3,l=jt(x,17)^jt(x,19)^x>>>10;Le[h]=l+Le[h-7]+p+Le[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=jt(c,6)^jt(c,11)^jt(c,25),x=u+y+bf(c,a,f)+ud[h]+Le[h]|0,l=(jt(n,2)^jt(n,13)^jt(n,22))+Ef(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(){Le.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Xt=gf(()=>new ps);function ys(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 ar=class{static async digest({data:t}){return Xt(t)}};var bi="urn:jwk:";async function V({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}`);$i(e);let n=ys(e),i=R.string(n).toUint8Array(),o=await ar.digest({data:i});return R.uint8Array(o).toBase64Url()}function Jt(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 fr(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 Vt(r){return!(!r||typeof r!="object"||!("kty"in r&&"k"in r)||r.kty!=="oct"||typeof r.k!="string")}function Ht(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 ur(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 ms(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 hd(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 we=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 V({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 V({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 V({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 V({jwk:e}),e}static async getPublicKey({key:t}){if(!(Jt(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 V({jwk:n}),n}static async privateKeyToBytes({privateKey:t}){if(!Jt(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(!(fr(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=Xt(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=Xt(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 vf=Or(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),ld=vf.create(BigInt("-3")),dd=BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),pd=yi({a:ld,b:dd,Fp:vf,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},hi),Tt=pd;var ge=class r{static async adjustSignatureToLowS({signature:t}){let e=Tt.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 V({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 V({jwk:n}),n}static async compressPublicKey({publicKeyBytes:t}){return Tt.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 V({jwk:i}),i}static async convertDerToCompactSignature({derSignature:t}){return Tt.Signature.fromDER(t).toCompactRawBytes()}static async decompressPublicKey({publicKeyBytes:t}){return Tt.ProjectivePoint.fromHex(t).toRawBytes(!1)}static async generateKey(){let t=Tt.utils.randomPrivateKey(),e=await r.bytesToPrivateKey({privateKeyBytes:t});return e.kid=await V({jwk:e}),e}static async getPublicKey({key:t}){if(!(Jt(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 V({jwk:n}),n}static async privateKeyToBytes({privateKey:t}){if(!Jt(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(!(fr(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 Tt.getSharedSecret(n,i,!0).slice(1)}static async sign({data:t,key:e}){let n=await r.privateKeyToBytes({privateKey:e}),i=Xt(t);return Tt.sign(i,n).toCompactRawBytes()}static async validatePrivateKey({privateKeyBytes:t}){return Tt.utils.isValidPrivateKey(t)}static async validatePublicKey({publicKeyBytes:t}){try{Tt.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=Xt(n);return Tt.verify(e,o,i,{lowS:!1})}static async getCurvePoint({keyBytes:t}){t.byteLength===32&&(t=Tt.getPublicKey(t));let e=Tt.ProjectivePoint.fromHex(t),n=xt(e.x,32),i=xt(e.y,32);return{x:n,y:i}}};var Rr=class extends Bt{async computePublicKey({key:t}){if(!Jt(t))throw new TypeError("Invalid key provided. Must be an elliptic curve (EC) private key.");switch(t.crv){case"secp256k1":{let e=await we.computePublicKey({key:t});return e.alg="ES256K",e}case"P-256":{let e=await ge.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 we.generateKey();return e.alg="ES256K",e}case"ES256":case"secp256r1":{let e=await ge.generateKey();return e.alg="ES256",e}}}async getPublicKey({key:t}){if(!Jt(t))throw new TypeError("Invalid key provided. Must be an elliptic curve (EC) private key.");switch(t.crv){case"secp256k1":{let e=await we.getPublicKey({key:t});return e.alg="ES256K",e}case"P-256":{let e=await ge.getPublicKey({key:t});return e.alg="ES256",e}default:throw new Error(`Unsupported curve: ${t.crv}`)}}async sign({key:t,data:e}){if(!Jt(t))throw new TypeError("Invalid key provided. Must be an elliptic curve (EC) private key.");switch(t.crv){case"secp256k1":return await we.sign({key:t,data:e});case"P-256":return await ge.sign({key:t,data:e});default:throw new Error(`Unsupported curve: ${t.crv}`)}}async verify({key:t,signature:e,data:n}){if(!fr(t))throw new TypeError("Invalid key provided. Must be an elliptic curve (EC) public key.");switch(t.crv){case"secp256k1":return await we.verify({key:t,signature:e,data:n});case"P-256":return await ge.verify({key:t,signature:e,data:n});default:throw new Error(`Unsupported curve: ${t.crv}`)}}};var Ei=BigInt(4294967295),ws=BigInt(32);function Af(r,t=!1){return t?{h:Number(r&Ei),l:Number(r>>ws&Ei)}:{h:Number(r>>ws&Ei)|0,l:Number(r&Ei)|0}}function yd(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}=Af(r[i],t);[e[i],n[i]]=[o,s]}return[e,n]}var md=(r,t)=>BigInt(r>>>0)<<ws|BigInt(t>>>0),wd=(r,t,e)=>r>>>e,gd=(r,t,e)=>r<<32-e|t>>>e,xd=(r,t,e)=>r>>>e|t<<32-e,bd=(r,t,e)=>r<<32-e|t>>>e,Ed=(r,t,e)=>r<<64-e|t>>>e-32,vd=(r,t,e)=>r>>>e-32|t<<64-e,Ad=(r,t)=>t,Bd=(r,t)=>r,Td=(r,t,e)=>r<<e|t>>>32-e,Sd=(r,t,e)=>t<<e|r>>>32-e,kd=(r,t,e)=>t<<e-32|r>>>64-e,Pd=(r,t,e)=>r<<e-32|t>>>64-e;function Ud(r,t,e,n){let i=(t>>>0)+(n>>>0);return{h:r+e+(i/2**32|0)|0,l:i|0}}var Kd=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),Id=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,_d=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),Cd=(r,t,e,n,i)=>t+e+n+i+(r/2**32|0)|0,Ld=(r,t,e,n,i)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(i>>>0),Od=(r,t,e,n,i,o)=>t+e+n+i+o+(r/2**32|0)|0;var Rd={fromBig:Af,split:yd,toBig:md,shrSH:wd,shrSL:gd,rotrSH:xd,rotrSL:bd,rotrBH:Ed,rotrBL:vd,rotr32H:Ad,rotr32L:Bd,rotlSH:Td,rotlSL:Sd,rotlBH:kd,rotlBL:Pd,add:Ud,add3L:Kd,add3H:Id,add4L:_d,add4H:Cd,add5H:Od,add5L:Ld},F=Rd;var[Nd,Dd]=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))),Oe=new Uint32Array(80),Re=new Uint32Array(80),gs=class extends Lr{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)Oe[w]=t.getUint32(e),Re[w]=t.getUint32(e+=4);for(let w=16;w<80;w++){let P=Oe[w-15]|0,A=Re[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=Oe[w-2]|0,D=Re[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,_,Re[w-7],Re[w-16]),M=F.add4H(j,T,O,Oe[w-7],Oe[w-16]);Oe[w]=M|0,Re[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,Dd[w],Re[w]),D=F.add5H(U,b,P,T,Nd[w],Oe[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(){Oe.fill(0),Re.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 xs=ui(()=>new gs);var Gt=BigInt(0),St=BigInt(1),vi=BigInt(2),Md=BigInt(8),jd={zip215:!0};function Jd(r){let t=yn(r);return Kt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function Ai(r){let t=Jd(r),{Fp:e,n,prehash:i,hash:o,randomBytes:s,nByteLength:c,h:a}=t,f=vi<<BigInt(c*8)-St,u=e.create,h=t.uvRatio||((v,d)=>{try{return{isValid:!0,value:e.sqrt(v*e.inv(d))}}catch{return{isValid:!1,value:Gt}}}),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"&&Gt<v,l=(v,d)=>p(v)&&p(d)&&v<d,m=v=>v===Gt||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===Gt?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,St,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:H}=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*H);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:H,ez:z}=d,G=u(S*z),q=u(J*C),et=u(I*z),Q=u(H*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),H=u(I*I),z=u(vi*u(C*C)),G=u(d*J),q=S+I,et=u(u(q*q)-J-H),Q=G+H,ut=Q-z,ht=G-H,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:H,et:z}=this,{ex:G,ey:q,ez:et,et:Q}=d;if(S===BigInt(-1)){let qs=u((J-C)*(q+G)),Fs=u((J+C)*(q-G)),Ki=u(Fs-qs);if(Ki===Gt)return this.double();let $s=u(H*vi*Q),Ws=u(z*vi*et),zs=Ws+$s,Zs=Fs+qs,Ys=Ws-$s,tu=u(zs*Ki),eu=u(Zs*Ys),ru=u(zs*Ys),nu=u(Ki*Zs);return new A(tu,eu,nu,ru)}let ut=u(C*G),ht=u(J*q),st=u(z*I*Q),dt=u(H*et),te=u((C+J)*(G+q)-ut-ht),De=dt-st,Nr=dt+st,Gs=u(ht-S*ut),Zf=u(te*De),Yf=u(Nr*Gs),Xf=u(te*Gs),Qf=u(De*Nr);return new A(Zf,Yf,Qf,Xf)}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===Gt?K:this.equals(K)||S===St?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?Md:e.inv(C));let H=u(S*d),z=u(I*d),G=u(C*d);if(J)return{x:Gt,y:St};if(G!==St)throw new Error("invZ was invalid");return{x:H,y:z}}clearCofactor(){let{h:d}=t;return d===St?this:this.multiplyUnsafe(d)}static fromHex(d,S=!1){let{d:I,a:C}=t,J=e.BYTES;d=rt("pointHex",d,J);let H=d.slice(),z=d[J-1];H[J-1]=z&-129;let G=Dt(H);G===Gt||(S?b(G,f):b(G,e.ORDER));let q=u(G*G),et=u(q-St),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&St)===St,dt=(z&128)!==0;if(!S&&ht===Gt&&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&St?128:0,I}toHex(){return he(this.toRawBytes())}}A.BASE=new A(t.Gx,t.Gy,St,u(t.Gx*t.Gy)),A.ZERO=new A(Gt,St,St,Gt);let{BASE:T,ZERO:K}=A,U=di(A,c*8);function D(v){return X(v,n)}function O(v){return D(Dt(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),H=T.multiply(J),z=H.toRawBytes();return{head:I,prefix:C,scalar:J,point:H,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),H=M(S.context,I,v),z=T.multiply(H).toRawBytes(),G=M(S.context,z,J,v),q=D(H+G*C);B(q);let et=pe(z,de(q,e.BYTES));return rt("result",et,c*2)}let E=jd;function k(v,d,S,I=E){let{context:C,zip215:J}=I,H=e.BYTES;v=rt("signature",v,2*H),d=rt("message",d),i&&(d=i(d));let z=Dt(v.slice(H,2*H)),G,q,et;try{G=A.fromHex(S,J),q=A.fromHex(v.slice(0,H),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),bs=BigInt(1);function Vd(r){return Kt(r,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...r})}function Bf(r){let t=Vd(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=>ns(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=bs,D=mn,O=A,_=bs,j=mn,M;for(let E=BigInt(i-1);E>=mn;E--){let k=T>>E&bs;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-_,H=n(J*L),z=n(C*d),G=H+z,q=H-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),Dt(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 Dt(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"),Tf=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),jm=BigInt(0),Hd=BigInt(1),Es=BigInt(2),Gd=BigInt(5),Sf=BigInt(10),qd=BigInt(20),Fd=BigInt(40),kf=BigInt(80);function Pf(r){let t=wn,n=r*r%t*r%t,i=nt(n,Es,t)*n%t,o=nt(i,Hd,t)*r%t,s=nt(o,Gd,t)*o%t,c=nt(s,Sf,t)*s%t,a=nt(c,qd,t)*c%t,f=nt(a,Fd,t)*a%t,u=nt(f,kf,t)*f%t,h=nt(u,kf,t)*f%t,y=nt(h,Sf,t)*s%t;return{pow_p_5_8:nt(y,Es,t)*r%t,b2:n}}function Uf(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function $d(r,t){let e=wn,n=X(t*t*t,e),i=X(n*n*t,e),o=Pf(r*i).pow_p_5_8,s=X(r*n*o,e),c=X(t*s*s,e),a=s,f=X(s*Tf,e),u=c===r,h=c===X(-r,e),y=c===X(-r*Tf,e);return u&&(s=a),(h||y)&&(s=f),af(s,e)&&(s=X(-s,e)),{isValid:u||h,value:s}}var _t=Or(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:xs,randomBytes:pn,adjustScalarBytes:Uf,uvRatio:$d},Ne=Ai(gn);function Kf(r,t,e){if(t.length>255)throw new Error("Context is too big");return fi(ts("SigEd25519 no Ed25519 collisions"),new Uint8Array([e?1:0,t.length]),t,r)}var Jm=Ai({...gn,domain:Kf}),Vm=Ai({...gn,domain:Kf,prehash:xs}),hr=Bf({P:wn,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:r=>{let t=wn,{pow_p_5_8:e,b2:n}=Pf(r);return X(nt(e,BigInt(3),t)*n,t)},adjustScalarBytes:Uf,randomBytes:pn});function If(r){let{y:t}=Ne.ExtendedPoint.fromHex(r),e=BigInt(1);return _t.toBytes(_t.create((e+t)*_t.inv(e-t)))}function _f(r){let t=gn.hash(r.subarray(0,32));return gn.adjustScalarBytes(t).subarray(0,32)}var Wd=(_t.ORDER+BigInt(3))/BigInt(8),Hm=_t.pow(Es,Wd),Gm=_t.sqrt(_t.neg(_t.ONE)),qm=(_t.ORDER-BigInt(5))/BigInt(8),Fm=BigInt(486662);var $m=ff(_t,_t.neg(BigInt(486664)));var Wm=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),zm=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),Zm=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),Ym=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");var Xm=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var xe=class r{static async bytesToPrivateKey({privateKeyBytes:t}){let e=Ne.getPublicKey(t),n={crv:"Ed25519",d:R.uint8Array(t).toBase64Url(),kty:"OKP",x:R.uint8Array(e).toBase64Url()};return n.kid=await V({jwk:n}),n}static async bytesToPublicKey({publicKeyBytes:t}){let e={kty:"OKP",crv:"Ed25519",x:R.uint8Array(t).toBase64Url()};return e.kid=await V({jwk:e}),e}static async computePublicKey({key:t}){let e=await r.privateKeyToBytes({privateKey:t}),n=Ne.getPublicKey(e),i={kty:"OKP",crv:"Ed25519",x:R.uint8Array(n).toBase64Url()};return i.kid=await V({jwk:i}),i}static async convertPrivateKeyToX25519({privateKey:t}){let e=await r.privateKeyToBytes({privateKey:t}),n=_f(e),i=hr.getPublicKey(n),o={kty:"OKP",crv:"X25519",d:R.uint8Array(n).toBase64Url(),x:R.uint8Array(i).toBase64Url()};return o.kid=await V({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=If(e),o={kty:"OKP",crv:"X25519",x:R.uint8Array(i).toBase64Url()};return o.kid=await V({jwk:o}),o}static async generateKey(){let t=Ne.utils.randomPrivateKey(),e=await r.bytesToPrivateKey({privateKeyBytes:t});return e.kid=await V({jwk:e}),e}static async getPublicKey({key:t}){if(!(Ht(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 V({jwk:n}),n}static async privateKeyToBytes({privateKey:t}){if(!Ht(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(!ur(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 Ne.sign(e,n)}static async validatePublicKey({publicKeyBytes:t}){try{Ne.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 Ne.verify(e,n,i)}};var xn=class extends Bt{async computePublicKey({key:t}){if(!Ht(t))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) private key.");switch(t.crv){case"Ed25519":{let e=await xe.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 xe.generateKey();return e.alg="EdDSA",e}}}async getPublicKey({key:t}){if(!Ht(t))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) private key.");switch(t.crv){case"Ed25519":{let e=await xe.getPublicKey({key:t});return e.alg="EdDSA",e}default:throw new Error(`Unsupported curve: ${t.crv}`)}}async sign({key:t,data:e}){if(!Ht(t))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) private key.");switch(t.crv){case"Ed25519":return await xe.sign({key:t,data:e});default:throw new Error(`Unsupported curve: ${t.crv}`)}}async verify({key:t,signature:e,data:n}){if(!ur(t))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) public key.");switch(t.crv){case"Ed25519":return await xe.verify({key:t,signature:e,data:n});default:throw new Error(`Unsupported curve: ${t.crv}`)}}};var bn=class extends Bt{async digest({algorithm:t,data:e}){switch(t){case"SHA-256":return await ar.digest({data:e})}}};var vs={Ed25519:{implementation:xn,names:["Ed25519"]},secp256k1:{implementation:Rr,names:["ES256K","secp256k1"]},secp256r1:{implementation:Rr,names:["ES256","secp256r1"]},"SHA-256":{implementation:bn,names:["SHA-256"]}},As=class{constructor(t){this._algorithmInstances=new Map;this._keyStore=t?.keyStore??new ii}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=`${bi}${n.kid}`;return await this._keyStore.set(i,n),i}async getKeyUri({key:t}){let e=await V({jwk:t});return`${bi}${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(!ms(t))throw new TypeError("Invalid key provided. Must be a private key in JWK format.");let e=structuredClone(t);e.kid??=await V({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=vs[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 vs){let o=vs[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 Bs=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 xf(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 Bi=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function ot(){if(Bi&&typeof Bi.subtle=="object"&&Bi.subtle!=null)return Bi.subtle;throw new Error("crypto.subtle must be defined")}var En=128,Cf=[128,192,256],Ti=En,lr=class{static async bytesToPrivateKey({privateKeyBytes:t}){let e={k:R.uint8Array(t).toBase64Url(),kty:"oct"};return e.kid=await V({jwk:e}),e}static async decrypt({key:t,data:e,counter:n,length:i}){if(n.byteLength!==En/8)throw new TypeError(`The counter must be ${En} bits in length`);if(i===0||i>Ti)throw new TypeError(`The 'length' property must be in the range 1 to ${Ti}`);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!==En/8)throw new TypeError(`The counter must be ${En} bits in length`);if(i===0||i>Ti)throw new TypeError(`The 'length' property must be in the range 1 to ${Ti}`);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(!Cf.includes(t))throw new RangeError(`The key length is invalid: Must be ${Cf.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 V({jwk:s}),s}static async privateKeyToBytes({privateKey:t}){if(!Vt(t))throw new Error("AesCtr: The provided key is not a valid oct private key.");return R.base64Url(t.k).toUint8Array()}};var Ts=class extends Bt{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 vn(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`positive integer expected, not ${r}`)}function Ss(r){if(typeof r!="boolean")throw new Error(`boolean expected, not ${r}`)}function ks(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function at(r,...t){if(!ks(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 Ps(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 Lf(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 be=r=>new Uint32Array(r.buffer,r.byteOffset,Math.floor(r.byteLength/4)),Of=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),zd=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!zd)throw new Error("Non little-endian hardware is not supported");function Zd(r){if(typeof r!="string")throw new Error(`string expected, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Si(r){if(typeof r=="string")r=Zd(r);else if(ks(r))r=r.slice();else throw new Error(`Uint8Array expected, got ${typeof r}`);return r}function Rf(r,t){if(t==null||typeof t!="object")throw new Error("options must be defined");return Object.assign(r,t)}function Nf(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 Us=(r,t)=>(Object.assign(t,r),t);function Ks(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 Df={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 Yd(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 Is(r){return(t,e,n)=>{at(t),at(e);let i={name:r,length:t.length*8},o=Yd(r,e,n);return{encrypt(s){return at(s),Df.encrypt(t,i,o,s)},decrypt(s){return at(s),Df.decrypt(t,i,o,s)}}}}var Lw=Is(Qt.CBC),Ow=Is(Qt.CTR),Rw=Is(Qt.GCM);var ki=96,Mf=[128,192,256],An=[96,104,112,120,128],dr=class{static async bytesToPrivateKey({privateKeyBytes:t}){let e={k:R.uint8Array(t).toBase64Url(),kty:"oct"};return e.kid=await V({jwk:e}),e}static async decrypt({key:t,data:e,iv:n,additionalData:i,tagLength:o}){if(n.byteLength!==ki/8)throw new TypeError(`The initialization vector must be ${ki} bits in length`);if(o&&!An.includes(o))throw new RangeError(`The tag length is invalid: Must be ${An.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!==ki/8)throw new TypeError(`The initialization vector must be ${ki} bits in length`);if(o&&!An.includes(o))throw new RangeError(`The tag length is invalid: Must be ${An.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(!Mf.includes(t))throw new RangeError(`The key length is invalid: Must be ${Mf.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 V({jwk:s}),s}static async privateKeyToBytes({privateKey:t}){if(!Vt(t))throw new Error("AesGcm: The provided key is not a valid oct private key.");return R.base64Url(t.k).toUint8Array()}};var _s=class extends Bt{async decrypt(t){return dr.decrypt(t)}async encrypt(t){return dr.encrypt(t)}async generateKey({algorithm:t}){let e={A128GCM:128,A192GCM:192,A256GCM:256}[t],n=await dr.generateKey({length:e});return n.alg=t,n}};var jf=[128,192,256],Cs=class{static async bytesToPrivateKey({privateKeyBytes:t}){let e={k:R.uint8Array(t).toBase64Url(),kty:"oct"};e.kid=await V({jwk:e});let n=t.length*8;return e.alg={128:"A128KW",192:"A192KW",256:"A256KW"}[n],e}static async generateKey({length:t}){if(!jf.includes(t))throw new RangeError(`The key length is invalid: Must be ${jf.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 V({jwk:s}),s}static async privateKeyToBytes({privateKey:t}){if(!Vt(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 Ct("invalidJwk","The decryption key is missing the 'alg' property.");if(!["A128KW","A192KW","A256KW"].includes(n.alg))throw new Ct("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 Ct("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 V({jwk:h}),h}static async wrapKey({unwrappedKey:t,encryptionKey:e}){if(!("alg"in e&&e.alg))throw new Ct("invalidJwk","The encryption key is missing the 'alg' property.");if(!["A128KW","A192KW","A256KW"].includes(e.alg))throw new Ct("algorithmNotSupported",`The 'encryptionKey' algorithm is not supported: ${e.alg}`);if(!("alg"in t&&t.alg))throw new Ct("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 Ct("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 Ls=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 Xt(ds(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 ds(e,n,i,o,s)}static toDataLenData({data:t,variableLength:e=!0}){let n,i=Mr(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 Os=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 Rs=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 Ns=class r{static async bytesToPrivateKey({privateKeyBytes:t}){let e=hr.getPublicKey(t),n={kty:"OKP",crv:"X25519",d:R.uint8Array(t).toBase64Url(),x:R.uint8Array(e).toBase64Url()};return n.kid=await V({jwk:n}),n}static async bytesToPublicKey({publicKeyBytes:t}){let e={kty:"OKP",crv:"X25519",x:R.uint8Array(t).toBase64Url()};return e.kid=await V({jwk:e}),e}static async computePublicKey({key:t}){let e=await r.privateKeyToBytes({privateKey:t}),n=hr.getPublicKey(e),i={kty:"OKP",crv:"X25519",x:R.uint8Array(n).toBase64Url()};return i.kid=await V({jwk:i}),i}static async generateKey(){let t=hr.utils.randomPrivateKey(),e=await r.bytesToPrivateKey({privateKeyBytes:t});return e.kid=await V({jwk:e}),e}static async getPublicKey({key:t}){if(!(Ht(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 V({jwk:n}),n}static async privateKeyToBytes({privateKey:t}){if(!Ht(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(!ur(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 hr.getSharedSecret(n,i)}};var lt=(r,t)=>r[t++]&255|(r[t++]&255)<<8,Ds=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=Si(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 H=d+D*h+O*u+_*f+j*a+M*c;d=H>>>13,H&=8191,H+=W*(5*m)+E*(5*l)+k*(5*p)+L*(5*x)+v*(5*y),d+=H>>>13,H&=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]=H,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){Ps(this);let{buffer:e,blockLen:n}=this;t=Si(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){Ps(this),Lf(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 Xd(r){let t=(n,i)=>r(i).update(Si(n)).digest(),e=r(new Uint8Array(32));return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=n=>r(n),t}var Jf=Xd(r=>new Ds(r));var Hf=r=>Uint8Array.from(r.split("").map(t=>t.charCodeAt(0))),Qd=Hf("expand 16-byte k"),tp=Hf("expand 32-byte k"),ep=be(Qd),Gf=be(tp),yg=Gf.slice();function N(r,t){return r<<t|r>>>32-t}function Ms(r){return r.byteOffset%4===0}var Pi=64,rp=16,qf=2**32-1,Vf=new Uint32Array;function np(r,t,e,n,i,o,s,c){let a=i.length,f=new Uint8Array(Pi),u=be(f),h=Ms(i)&&Ms(o),y=h?be(i):Vf,x=h?be(o):Vf;for(let p=0;p<a;s++){if(r(t,e,n,u,s,c),s>=qf)throw new Error("arx: counter overflow");let l=Math.min(Pi,a-p);if(h&&l===Pi){let m=p/4;if(p%4!==0)throw new Error("arx: invalid block position");for(let b=0,B;b<rp;b++)B=m+b,x[B]=y[B]^u[b];p+=Pi;continue}for(let m=0,b;m<l;m++)b=p+m,o[b]=i[b]^f[m];p+=l}}function js(r,t){let{allowShortKeys:e,extendNonceFn:n,counterLength:i,counterRight:o,rounds:s}=Rf({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if(typeof r!="function")throw new Error("core must be a function");return vn(i),vn(s),Ss(o),Ss(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),vn(h),h<0||h>=qf)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=Gf;else if(p===16&&e)l=new Uint8Array(32),l.set(c),l.set(c,16),m=ep,x.push(l);else throw new Error(`arx: invalid 32-byte key, got length=${p}`);Ms(a)||(a=a.slice(),x.push(a));let b=be(l);if(n){if(a.length!==24)throw new Error("arx: extended nonce must be 24 bytes");n(m,b,be(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=be(a);for(np(r,m,b,w,f,u,h,s);x.length>0;)x.pop().fill(0);return u}}function Wf(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 ip(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 op=js(Wf,{counterRight:!1,counterLength:4,allowShortKeys:!1}),Ui=js(Wf,{counterRight:!1,counterLength:8,extendNonceFn:ip,allowShortKeys:!1});var sp=new Uint8Array(16),Ff=(r,t)=>{r.update(t);let e=t.length%16;e&&r.update(sp.subarray(e))},cp=new Uint8Array(32);function $f(r,t,e,n,i){let o=r(t,e,cp),s=Jf.create(o);i&&Ff(s,i),Ff(s,n);let c=new Uint8Array(16),a=Of(c);Ks(a,0,BigInt(i?i.length:0),!0),Ks(a,8,BigInt(n.length),!0),s.update(c);let f=s.digest();return o.fill(0),f}var zf=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=$f(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=$f(r,t,e,f,n);if(!Nf(u,h))throw new Error("invalid tag");return r(t,e,f,s,1),s}}),Eg=Us({blockSize:64,nonceLength:12,tagLength:16},zf(op)),Js=Us({blockSize:64,nonceLength:24,tagLength:16},zf(Ui));var Vs=class r{static async bytesToPrivateKey({privateKeyBytes:t}){let e={k:R.uint8Array(t).toBase64Url(),kty:"oct"};return e.kid=await V({jwk:e}),e}static async decrypt({data:t,key:e,nonce:n}){let i=await r.privateKeyToBytes({privateKey:e});return Ui(i,n,t)}static async encrypt({data:t,key:e,nonce:n}){let i=await r.privateKeyToBytes({privateKey:e});return Ui(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 V({jwk:s}),s}static async privateKeyToBytes({privateKey:t}){if(!Vt(t))throw new Error("XChaCha20: The provided key is not a valid oct private key.");return R.base64Url(t.k).toUint8Array()}};var ap=16,Hs=class r{static async bytesToPrivateKey({privateKeyBytes:t}){let e={k:R.uint8Array(t).toBase64Url(),kty:"oct"};return e.kid=await V({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 Js(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 Js(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 V({jwk:s}),s}static async privateKeyToBytes({privateKey:t}){if(!Vt(t))throw new Error("XChaCha20Poly1305: The provided key is not a valid oct private key.");return R.base64Url(t.k).toUint8Array()}};return fu(fp);})();
|
|
2
|
-
/*! Bundled license information:
|
|
3
|
-
|
|
4
|
-
ieee754/index.js:
|
|
5
|
-
(*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
|
6
|
-
|
|
7
|
-
buffer/index.js:
|
|
8
|
-
(*!
|
|
9
|
-
* The buffer module from node.js, for the browser.
|
|
10
|
-
*
|
|
11
|
-
* @author Feross Aboukhadijeh <https://feross.org>
|
|
12
|
-
* @license MIT
|
|
13
|
-
*)
|
|
14
|
-
|
|
15
|
-
queue-microtask/index.js:
|
|
16
|
-
(*! queue-microtask. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
|
17
|
-
|
|
18
|
-
run-parallel-limit/index.js:
|
|
19
|
-
(*! run-parallel-limit. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
|
20
|
-
|
|
21
|
-
@noble/curves/esm/abstract/utils.js:
|
|
22
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
23
|
-
|
|
24
|
-
@noble/hashes/esm/utils.js:
|
|
25
|
-
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
26
|
-
|
|
27
|
-
@noble/curves/esm/abstract/modular.js:
|
|
28
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
29
|
-
|
|
30
|
-
@noble/curves/esm/abstract/curve.js:
|
|
31
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
32
|
-
|
|
33
|
-
@noble/curves/esm/abstract/weierstrass.js:
|
|
34
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
35
|
-
|
|
36
|
-
@noble/curves/esm/_shortw_utils.js:
|
|
37
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
38
|
-
|
|
39
|
-
@noble/curves/esm/secp256k1.js:
|
|
40
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
41
|
-
|
|
42
|
-
@noble/hashes/esm/utils.js:
|
|
43
|
-
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
44
|
-
|
|
45
|
-
@noble/curves/esm/p256.js:
|
|
46
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
47
|
-
|
|
48
|
-
@noble/curves/esm/abstract/edwards.js:
|
|
49
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
50
|
-
|
|
51
|
-
@noble/curves/esm/abstract/montgomery.js:
|
|
52
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
53
|
-
|
|
54
|
-
@noble/curves/esm/ed25519.js:
|
|
55
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
56
|
-
|
|
57
|
-
@noble/ciphers/esm/utils.js:
|
|
58
|
-
(*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) *)
|
|
59
|
-
*/
|
|
60
|
-
//# sourceMappingURL=browser.js.map
|