@enbox/dids 0.0.5 → 0.0.7
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/did.js +4 -0
- package/dist/esm/did.js.map +1 -1
- package/dist/esm/methods/did-dht-pkarr.js +3 -2
- package/dist/esm/methods/did-dht-pkarr.js.map +1 -1
- package/dist/esm/methods/did-ion.js +3 -2
- package/dist/esm/methods/did-ion.js.map +1 -1
- package/dist/esm/methods/did-web.js +64 -1
- package/dist/esm/methods/did-web.js.map +1 -1
- package/dist/esm/utils.js +15 -19
- package/dist/esm/utils.js.map +1 -1
- package/dist/types/did.d.ts.map +1 -1
- package/dist/types/methods/did-dht-pkarr.d.ts.map +1 -1
- package/dist/types/methods/did-ion.d.ts.map +1 -1
- package/dist/types/methods/did-web.d.ts.map +1 -1
- package/dist/types/utils.d.ts +25 -25
- package/dist/types/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/utils.js.map +4 -4
- package/package.json +4 -4
- package/src/did.ts +3 -0
- package/src/methods/did-dht-pkarr.ts +3 -2
- package/src/methods/did-ion.ts +3 -2
- package/src/methods/did-web.ts +52 -1
- package/src/utils.ts +31 -30
package/dist/utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Ho=Object.create;var br=Object.defineProperty;var Wo=Object.getOwnPropertyDescriptor;var zo=Object.getOwnPropertyNames;var Xo=Object.getPrototypeOf,Yo=Object.prototype.hasOwnProperty;var x=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports),Zo=(n,t)=>{for(var e in t)br(n,e,{get:t[e],enumerable:!0})},Qo=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of zo(t))!Yo.call(n,i)&&i!==e&&br(n,i,{get:()=>t[i],enumerable:!(r=Wo(t,i))||r.enumerable});return n};var Hn=(n,t,e)=>(e=n!=null?Ho(Xo(n)):{},Qo(t||!n||!n.__esModule?br(e,"default",{value:n,enumerable:!0}):e,n));var zn=x((Tu,Wn)=>{var ts=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Le=()=>ts.now(),es=n=>n&&n===Math.floor(n)&&n>0&&isFinite(n),Er=n=>n===1/0||es(n),Tr=class n{constructor({max:t=1/0,ttl:e,updateAgeOnGet:r=!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&&!Er(e))throw new TypeError("ttl must be positive integer or Infinity if set");if(!Er(t))throw new TypeError("max must be positive integer or Infinity");if(this.ttl=e,this.max=t,this.updateAgeOnGet=!!r,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 r=setTimeout(()=>{this.timer=void 0,this.timerExpiration=void 0,this.purgeStale();for(let i in this.expirations){this.setTimer(i,i-Le());break}},e);r.unref&&r.unref(),this.timerExpiration=t,this.timer=r}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!==n.prototype.dispose?[...this]:[];this.data.clear(),this.expirationMap.clear(),this.cancelTimer(),this.expirations=Object.create(null);for(let[e,r]of t)this.dispose(r,e,"delete")}setTTL(t,e=this.ttl){let r=this.expirationMap.get(t);if(r!==void 0){let i=this.expirations[r];!i||i.length<=1?delete this.expirations[r]:this.expirations[r]=i.filter(o=>o!==t)}if(e!==1/0){let i=Math.floor(Le()+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:r=this.ttl,noUpdateTTL:i=this.noUpdateTTL,noDisposeOnSet:o=this.noDisposeOnSet}={}){if(!Er(r))throw new TypeError("ttl must be positive integer or Infinity");if(this.expirationMap.has(t)){i||this.setTTL(t,r);let s=this.data.get(t);s!==e&&(this.data.set(t,e),o||this.dispose(s,t,"set"))}else this.setTTL(t,r),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-Le())):0}get(t,{updateAgeOnGet:e=this.updateAgeOnGet,ttl:r=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,r),o}dispose(t,e){}delete(t){let e=this.expirationMap.get(t);if(e!==void 0){let r=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(r,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 r=[];for(let i of e)r.push([i,this.data.get(i)]),this.data.delete(i),this.expirationMap.delete(i);for(let[i,o]of r)this.dispose(o,i,"evict")}else{let r=this.size-this.max,i=[];for(let o of e.splice(0,r))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(Le());for(let e in this.expirations){if(e==="Infinity"||e>t)return;let r=[...this.expirations[e]||[]],i=[];delete this.expirations[e];for(let o of r)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()}};Wn.exports=Tr});var di=x(hi=>{"use strict";hi.supports=function(...t){let e=t.reduce((r,i)=>Object.assign(r,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 V=x((ba,li)=>{"use strict";li.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 mi=x(Ne=>{"use strict";Ne.byteLength=Ds;Ne.toByteArray=Ms;Ne.fromByteArray=Rs;var z=[],L=[],Ps=typeof Uint8Array<"u"?Uint8Array:Array,Mr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Kt=0,pi=Mr.length;Kt<pi;++Kt)z[Kt]=Mr[Kt],L[Mr.charCodeAt(Kt)]=Kt;var Kt,pi;L[45]=62;L[95]=63;function yi(n){var t=n.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=n.indexOf("=");e===-1&&(e=t);var r=e===t?0:4-e%4;return[e,r]}function Ds(n){var t=yi(n),e=t[0],r=t[1];return(e+r)*3/4-r}function Ls(n,t,e){return(t+e)*3/4-e}function Ms(n){var t,e=yi(n),r=e[0],i=e[1],o=new Ps(Ls(n,r,i)),s=0,c=i>0?r-4:r,u;for(u=0;u<c;u+=4)t=L[n.charCodeAt(u)]<<18|L[n.charCodeAt(u+1)]<<12|L[n.charCodeAt(u+2)]<<6|L[n.charCodeAt(u+3)],o[s++]=t>>16&255,o[s++]=t>>8&255,o[s++]=t&255;return i===2&&(t=L[n.charCodeAt(u)]<<2|L[n.charCodeAt(u+1)]>>4,o[s++]=t&255),i===1&&(t=L[n.charCodeAt(u)]<<10|L[n.charCodeAt(u+1)]<<4|L[n.charCodeAt(u+2)]>>2,o[s++]=t>>8&255,o[s++]=t&255),o}function Fs(n){return z[n>>18&63]+z[n>>12&63]+z[n>>6&63]+z[n&63]}function Ns(n,t,e){for(var r,i=[],o=t;o<e;o+=3)r=(n[o]<<16&16711680)+(n[o+1]<<8&65280)+(n[o+2]&255),i.push(Fs(r));return i.join("")}function Rs(n){for(var t,e=n.length,r=e%3,i=[],o=16383,s=0,c=e-r;s<c;s+=o)i.push(Ns(n,s,s+o>c?c:s+o));return r===1?(t=n[e-1],i.push(z[t>>2]+z[t<<4&63]+"==")):r===2&&(t=(n[e-2]<<8)+n[e-1],i.push(z[t>>10]+z[t>>4&63]+z[t<<2&63]+"=")),i.join("")}});var wi=x(Fr=>{Fr.read=function(n,t,e,r,i){var o,s,c=i*8-r-1,u=(1<<c)-1,a=u>>1,h=-7,f=e?i-1:0,l=e?-1:1,p=n[t+f];for(f+=l,o=p&(1<<-h)-1,p>>=-h,h+=c;h>0;o=o*256+n[t+f],f+=l,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=r;h>0;s=s*256+n[t+f],f+=l,h-=8);if(o===0)o=1-a;else{if(o===u)return s?NaN:(p?-1:1)*(1/0);s=s+Math.pow(2,r),o=o-a}return(p?-1:1)*s*Math.pow(2,o-r)};Fr.write=function(n,t,e,r,i,o){var s,c,u,a=o*8-i-1,h=(1<<a)-1,f=h>>1,l=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,y=r?1:-1,g=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=h):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),s+f>=1?t+=l/u:t+=l*Math.pow(2,1-f),t*u>=2&&(s++,u/=2),s+f>=h?(c=0,s=h):s+f>=1?(c=(t*u-1)*Math.pow(2,i),s=s+f):(c=t*Math.pow(2,f-1)*Math.pow(2,i),s=0));i>=8;n[e+p]=c&255,p+=y,c/=256,i-=8);for(s=s<<i|c,a+=i;a>0;n[e+p]=s&255,p+=y,s/=256,a-=8);n[e+p-y]|=g*128}});var je=x(Xt=>{"use strict";var Nr=mi(),Wt=wi(),gi=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Xt.Buffer=d;Xt.SlowBuffer=Gs;Xt.INSPECT_MAX_BYTES=50;var Re=2147483647;Xt.kMaxLength=Re;d.TYPED_ARRAY_SUPPORT=Vs();!d.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 Vs(){try{let n=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(n,t),n.foo()===42}catch{return!1}}Object.defineProperty(d.prototype,"parent",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.buffer}});Object.defineProperty(d.prototype,"offset",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.byteOffset}});function rt(n){if(n>Re)throw new RangeError('The value "'+n+'" is invalid for option "size"');let t=new Uint8Array(n);return Object.setPrototypeOf(t,d.prototype),t}function d(n,t,e){if(typeof n=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return $r(n)}return Ei(n,t,e)}d.poolSize=8192;function Ei(n,t,e){if(typeof n=="string")return $s(n,t);if(ArrayBuffer.isView(n))return qs(n);if(n==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof n);if(X(n,ArrayBuffer)||n&&X(n.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(X(n,SharedArrayBuffer)||n&&X(n.buffer,SharedArrayBuffer)))return Vr(n,t,e);if(typeof n=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let r=n.valueOf&&n.valueOf();if(r!=null&&r!==n)return d.from(r,t,e);let i=Js(n);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof n[Symbol.toPrimitive]=="function")return d.from(n[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 n)}d.from=function(n,t,e){return Ei(n,t,e)};Object.setPrototypeOf(d.prototype,Uint8Array.prototype);Object.setPrototypeOf(d,Uint8Array);function Ti(n){if(typeof n!="number")throw new TypeError('"size" argument must be of type number');if(n<0)throw new RangeError('The value "'+n+'" is invalid for option "size"')}function js(n,t,e){return Ti(n),n<=0?rt(n):t!==void 0?typeof e=="string"?rt(n).fill(t,e):rt(n).fill(t):rt(n)}d.alloc=function(n,t,e){return js(n,t,e)};function $r(n){return Ti(n),rt(n<0?0:qr(n)|0)}d.allocUnsafe=function(n){return $r(n)};d.allocUnsafeSlow=function(n){return $r(n)};function $s(n,t){if((typeof t!="string"||t==="")&&(t="utf8"),!d.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let e=Ai(n,t)|0,r=rt(e),i=r.write(n,t);return i!==e&&(r=r.slice(0,i)),r}function Rr(n){let t=n.length<0?0:qr(n.length)|0,e=rt(t);for(let r=0;r<t;r+=1)e[r]=n[r]&255;return e}function qs(n){if(X(n,Uint8Array)){let t=new Uint8Array(n);return Vr(t.buffer,t.byteOffset,t.byteLength)}return Rr(n)}function Vr(n,t,e){if(t<0||n.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(n.byteLength<t+(e||0))throw new RangeError('"length" is outside of buffer bounds');let r;return t===void 0&&e===void 0?r=new Uint8Array(n):e===void 0?r=new Uint8Array(n,t):r=new Uint8Array(n,t,e),Object.setPrototypeOf(r,d.prototype),r}function Js(n){if(d.isBuffer(n)){let t=qr(n.length)|0,e=rt(t);return e.length===0||n.copy(e,0,0,t),e}if(n.length!==void 0)return typeof n.length!="number"||Gr(n.length)?rt(0):Rr(n);if(n.type==="Buffer"&&Array.isArray(n.data))return Rr(n.data)}function qr(n){if(n>=Re)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Re.toString(16)+" bytes");return n|0}function Gs(n){return+n!=n&&(n=0),d.alloc(+n)}d.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==d.prototype};d.compare=function(t,e){if(X(t,Uint8Array)&&(t=d.from(t,t.offset,t.byteLength)),X(e,Uint8Array)&&(e=d.from(e,e.offset,e.byteLength)),!d.isBuffer(t)||!d.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,i=e.length;for(let o=0,s=Math.min(r,i);o<s;++o)if(t[o]!==e[o]){r=t[o],i=e[o];break}return r<i?-1:i<r?1:0};d.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}};d.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return d.alloc(0);let r;if(e===void 0)for(e=0,r=0;r<t.length;++r)e+=t[r].length;let i=d.allocUnsafe(e),o=0;for(r=0;r<t.length;++r){let s=t[r];if(X(s,Uint8Array))o+s.length>i.length?(d.isBuffer(s)||(s=d.from(s)),s.copy(i,o)):Uint8Array.prototype.set.call(i,s,o);else if(d.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function Ai(n,t){if(d.isBuffer(n))return n.length;if(ArrayBuffer.isView(n)||X(n,ArrayBuffer))return n.byteLength;if(typeof n!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof n);let e=n.length,r=arguments.length>2&&arguments[2]===!0;if(!r&&e===0)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":return jr(n).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return Ui(n).length;default:if(i)return r?-1:jr(n).length;t=(""+t).toLowerCase(),i=!0}}d.byteLength=Ai;function Hs(n,t,e){let r=!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(n||(n="utf8");;)switch(n){case"hex":return nc(this,t,e);case"utf8":case"utf-8":return Bi(this,t,e);case"ascii":return ec(this,t,e);case"latin1":case"binary":return rc(this,t,e);case"base64":return Qs(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ic(this,t,e);default:if(r)throw new TypeError("Unknown encoding: "+n);n=(n+"").toLowerCase(),r=!0}}d.prototype._isBuffer=!0;function St(n,t,e){let r=n[t];n[t]=n[e],n[e]=r}d.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)St(this,e,e+1);return this};d.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)St(this,e,e+3),St(this,e+1,e+2);return this};d.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)St(this,e,e+7),St(this,e+1,e+6),St(this,e+2,e+5),St(this,e+3,e+4);return this};d.prototype.toString=function(){let t=this.length;return t===0?"":arguments.length===0?Bi(this,0,t):Hs.apply(this,arguments)};d.prototype.toLocaleString=d.prototype.toString;d.prototype.equals=function(t){if(!d.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:d.compare(this,t)===0};d.prototype.inspect=function(){let t="",e=Xt.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),"<Buffer "+t+">"};gi&&(d.prototype[gi]=d.prototype.inspect);d.prototype.compare=function(t,e,r,i,o){if(X(t,Uint8Array)&&(t=d.from(t,t.offset,t.byteLength)),!d.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),r===void 0&&(r=t?t.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),e<0||r>t.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&e>=r)return 0;if(i>=o)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,i>>>=0,o>>>=0,this===t)return 0;let s=o-i,c=r-e,u=Math.min(s,c),a=this.slice(i,o),h=t.slice(e,r);for(let f=0;f<u;++f)if(a[f]!==h[f]){s=a[f],c=h[f];break}return s<c?-1:c<s?1:0};function _i(n,t,e,r,i){if(n.length===0)return-1;if(typeof e=="string"?(r=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,Gr(e)&&(e=i?0:n.length-1),e<0&&(e=n.length+e),e>=n.length){if(i)return-1;e=n.length-1}else if(e<0)if(i)e=0;else return-1;if(typeof t=="string"&&(t=d.from(t,r)),d.isBuffer(t))return t.length===0?-1:xi(n,t,e,r,i);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(n,t,e):Uint8Array.prototype.lastIndexOf.call(n,t,e):xi(n,[t],e,r,i);throw new TypeError("val must be string, number or Buffer")}function xi(n,t,e,r,i){let o=1,s=n.length,c=t.length;if(r!==void 0&&(r=String(r).toLowerCase(),r==="ucs2"||r==="ucs-2"||r==="utf16le"||r==="utf-16le")){if(n.length<2||t.length<2)return-1;o=2,s/=2,c/=2,e/=2}function u(h,f){return o===1?h[f]:h.readUInt16BE(f*o)}let a;if(i){let h=-1;for(a=e;a<s;a++)if(u(n,a)===u(t,h===-1?0:a-h)){if(h===-1&&(h=a),a-h+1===c)return h*o}else h!==-1&&(a-=a-h),h=-1}else for(e+c>s&&(e=s-c),a=e;a>=0;a--){let h=!0;for(let f=0;f<c;f++)if(u(n,a+f)!==u(t,f)){h=!1;break}if(h)return a}return-1}d.prototype.includes=function(t,e,r){return this.indexOf(t,e,r)!==-1};d.prototype.indexOf=function(t,e,r){return _i(this,t,e,r,!0)};d.prototype.lastIndexOf=function(t,e,r){return _i(this,t,e,r,!1)};function Ws(n,t,e,r){e=Number(e)||0;let i=n.length-e;r?(r=Number(r),r>i&&(r=i)):r=i;let o=t.length;r>o/2&&(r=o/2);let s;for(s=0;s<r;++s){let c=parseInt(t.substr(s*2,2),16);if(Gr(c))return s;n[e+s]=c}return s}function zs(n,t,e,r){return Ve(jr(t,n.length-e),n,e,r)}function Xs(n,t,e,r){return Ve(uc(t),n,e,r)}function Ys(n,t,e,r){return Ve(Ui(t),n,e,r)}function Zs(n,t,e,r){return Ve(ac(t,n.length-e),n,e,r)}d.prototype.write=function(t,e,r,i){if(e===void 0)i="utf8",r=this.length,e=0;else if(r===void 0&&typeof e=="string")i=e,r=this.length,e=0;else if(isFinite(e))e=e>>>0,isFinite(r)?(r=r>>>0,i===void 0&&(i="utf8")):(i=r,r=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-e;if((r===void 0||r>o)&&(r=o),t.length>0&&(r<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 Ws(this,t,e,r);case"utf8":case"utf-8":return zs(this,t,e,r);case"ascii":case"latin1":case"binary":return Xs(this,t,e,r);case"base64":return Ys(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Zs(this,t,e,r);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};d.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Qs(n,t,e){return t===0&&e===n.length?Nr.fromByteArray(n):Nr.fromByteArray(n.slice(t,e))}function Bi(n,t,e){e=Math.min(n.length,e);let r=[],i=t;for(;i<e;){let o=n[i],s=null,c=o>239?4:o>223?3:o>191?2:1;if(i+c<=e){let u,a,h,f;switch(c){case 1:o<128&&(s=o);break;case 2:u=n[i+1],(u&192)===128&&(f=(o&31)<<6|u&63,f>127&&(s=f));break;case 3:u=n[i+1],a=n[i+2],(u&192)===128&&(a&192)===128&&(f=(o&15)<<12|(u&63)<<6|a&63,f>2047&&(f<55296||f>57343)&&(s=f));break;case 4:u=n[i+1],a=n[i+2],h=n[i+3],(u&192)===128&&(a&192)===128&&(h&192)===128&&(f=(o&15)<<18|(u&63)<<12|(a&63)<<6|h&63,f>65535&&f<1114112&&(s=f))}}s===null?(s=65533,c=1):s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|s&1023),r.push(s),i+=c}return tc(r)}var vi=4096;function tc(n){let t=n.length;if(t<=vi)return String.fromCharCode.apply(String,n);let e="",r=0;for(;r<t;)e+=String.fromCharCode.apply(String,n.slice(r,r+=vi));return e}function ec(n,t,e){let r="";e=Math.min(n.length,e);for(let i=t;i<e;++i)r+=String.fromCharCode(n[i]&127);return r}function rc(n,t,e){let r="";e=Math.min(n.length,e);for(let i=t;i<e;++i)r+=String.fromCharCode(n[i]);return r}function nc(n,t,e){let r=n.length;(!t||t<0)&&(t=0),(!e||e<0||e>r)&&(e=r);let i="";for(let o=t;o<e;++o)i+=fc[n[o]];return i}function ic(n,t,e){let r=n.slice(t,e),i="";for(let o=0;o<r.length-1;o+=2)i+=String.fromCharCode(r[o]+r[o+1]*256);return i}d.prototype.slice=function(t,e){let r=this.length;t=~~t,e=e===void 0?r:~~e,t<0?(t+=r,t<0&&(t=0)):t>r&&(t=r),e<0?(e+=r,e<0&&(e=0)):e>r&&(e=r),e<t&&(e=t);let i=this.subarray(t,e);return Object.setPrototypeOf(i,d.prototype),i};function b(n,t,e){if(n%1!==0||n<0)throw new RangeError("offset is not uint");if(n+t>e)throw new RangeError("Trying to access beyond buffer length")}d.prototype.readUintLE=d.prototype.readUIntLE=function(t,e,r){t=t>>>0,e=e>>>0,r||b(t,e,this.length);let i=this[t],o=1,s=0;for(;++s<e&&(o*=256);)i+=this[t+s]*o;return i};d.prototype.readUintBE=d.prototype.readUIntBE=function(t,e,r){t=t>>>0,e=e>>>0,r||b(t,e,this.length);let i=this[t+--e],o=1;for(;e>0&&(o*=256);)i+=this[t+--e]*o;return i};d.prototype.readUint8=d.prototype.readUInt8=function(t,e){return t=t>>>0,e||b(t,1,this.length),this[t]};d.prototype.readUint16LE=d.prototype.readUInt16LE=function(t,e){return t=t>>>0,e||b(t,2,this.length),this[t]|this[t+1]<<8};d.prototype.readUint16BE=d.prototype.readUInt16BE=function(t,e){return t=t>>>0,e||b(t,2,this.length),this[t]<<8|this[t+1]};d.prototype.readUint32LE=d.prototype.readUInt32LE=function(t,e){return t=t>>>0,e||b(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};d.prototype.readUint32BE=d.prototype.readUInt32BE=function(t,e){return t=t>>>0,e||b(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};d.prototype.readBigUInt64LE=ht(function(t){t=t>>>0,zt(t,"offset");let e=this[t],r=this[t+7];(e===void 0||r===void 0)&&de(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+r*2**24;return BigInt(i)+(BigInt(o)<<BigInt(32))});d.prototype.readBigUInt64BE=ht(function(t){t=t>>>0,zt(t,"offset");let e=this[t],r=this[t+7];(e===void 0||r===void 0)&&de(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+r;return(BigInt(i)<<BigInt(32))+BigInt(o)});d.prototype.readIntLE=function(t,e,r){t=t>>>0,e=e>>>0,r||b(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};d.prototype.readIntBE=function(t,e,r){t=t>>>0,e=e>>>0,r||b(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};d.prototype.readInt8=function(t,e){return t=t>>>0,e||b(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};d.prototype.readInt16LE=function(t,e){t=t>>>0,e||b(t,2,this.length);let r=this[t]|this[t+1]<<8;return r&32768?r|4294901760:r};d.prototype.readInt16BE=function(t,e){t=t>>>0,e||b(t,2,this.length);let r=this[t+1]|this[t]<<8;return r&32768?r|4294901760:r};d.prototype.readInt32LE=function(t,e){return t=t>>>0,e||b(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};d.prototype.readInt32BE=function(t,e){return t=t>>>0,e||b(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};d.prototype.readBigInt64LE=ht(function(t){t=t>>>0,zt(t,"offset");let e=this[t],r=this[t+7];(e===void 0||r===void 0)&&de(t,this.length-8);let i=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(r<<24);return(BigInt(i)<<BigInt(32))+BigInt(e+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24)});d.prototype.readBigInt64BE=ht(function(t){t=t>>>0,zt(t,"offset");let e=this[t],r=this[t+7];(e===void 0||r===void 0)&&de(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+r)});d.prototype.readFloatLE=function(t,e){return t=t>>>0,e||b(t,4,this.length),Wt.read(this,t,!0,23,4)};d.prototype.readFloatBE=function(t,e){return t=t>>>0,e||b(t,4,this.length),Wt.read(this,t,!1,23,4)};d.prototype.readDoubleLE=function(t,e){return t=t>>>0,e||b(t,8,this.length),Wt.read(this,t,!0,52,8)};d.prototype.readDoubleBE=function(t,e){return t=t>>>0,e||b(t,8,this.length),Wt.read(this,t,!1,52,8)};function S(n,t,e,r,i,o){if(!d.isBuffer(n))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+r>n.length)throw new RangeError("Index out of range")}d.prototype.writeUintLE=d.prototype.writeUIntLE=function(t,e,r,i){if(t=+t,e=e>>>0,r=r>>>0,!i){let c=Math.pow(2,8*r)-1;S(this,t,e,r,c,0)}let o=1,s=0;for(this[e]=t&255;++s<r&&(o*=256);)this[e+s]=t/o&255;return e+r};d.prototype.writeUintBE=d.prototype.writeUIntBE=function(t,e,r,i){if(t=+t,e=e>>>0,r=r>>>0,!i){let c=Math.pow(2,8*r)-1;S(this,t,e,r,c,0)}let o=r-1,s=1;for(this[e+o]=t&255;--o>=0&&(s*=256);)this[e+o]=t/s&255;return e+r};d.prototype.writeUint8=d.prototype.writeUInt8=function(t,e,r){return t=+t,e=e>>>0,r||S(this,t,e,1,255,0),this[e]=t&255,e+1};d.prototype.writeUint16LE=d.prototype.writeUInt16LE=function(t,e,r){return t=+t,e=e>>>0,r||S(this,t,e,2,65535,0),this[e]=t&255,this[e+1]=t>>>8,e+2};d.prototype.writeUint16BE=d.prototype.writeUInt16BE=function(t,e,r){return t=+t,e=e>>>0,r||S(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=t&255,e+2};d.prototype.writeUint32LE=d.prototype.writeUInt32LE=function(t,e,r){return t=+t,e=e>>>0,r||S(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};d.prototype.writeUint32BE=d.prototype.writeUInt32BE=function(t,e,r){return t=+t,e=e>>>0,r||S(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 Ki(n,t,e,r,i){Ci(t,r,i,n,e,7);let o=Number(t&BigInt(4294967295));n[e++]=o,o=o>>8,n[e++]=o,o=o>>8,n[e++]=o,o=o>>8,n[e++]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return n[e++]=s,s=s>>8,n[e++]=s,s=s>>8,n[e++]=s,s=s>>8,n[e++]=s,e}function Si(n,t,e,r,i){Ci(t,r,i,n,e,7);let o=Number(t&BigInt(4294967295));n[e+7]=o,o=o>>8,n[e+6]=o,o=o>>8,n[e+5]=o,o=o>>8,n[e+4]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return n[e+3]=s,s=s>>8,n[e+2]=s,s=s>>8,n[e+1]=s,s=s>>8,n[e]=s,e+8}d.prototype.writeBigUInt64LE=ht(function(t,e=0){return Ki(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))});d.prototype.writeBigUInt64BE=ht(function(t,e=0){return Si(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))});d.prototype.writeIntLE=function(t,e,r,i){if(t=+t,e=e>>>0,!i){let u=Math.pow(2,8*r-1);S(this,t,e,r,u-1,-u)}let o=0,s=1,c=0;for(this[e]=t&255;++o<r&&(s*=256);)t<0&&c===0&&this[e+o-1]!==0&&(c=1),this[e+o]=(t/s>>0)-c&255;return e+r};d.prototype.writeIntBE=function(t,e,r,i){if(t=+t,e=e>>>0,!i){let u=Math.pow(2,8*r-1);S(this,t,e,r,u-1,-u)}let o=r-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+r};d.prototype.writeInt8=function(t,e,r){return t=+t,e=e>>>0,r||S(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=t&255,e+1};d.prototype.writeInt16LE=function(t,e,r){return t=+t,e=e>>>0,r||S(this,t,e,2,32767,-32768),this[e]=t&255,this[e+1]=t>>>8,e+2};d.prototype.writeInt16BE=function(t,e,r){return t=+t,e=e>>>0,r||S(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=t&255,e+2};d.prototype.writeInt32LE=function(t,e,r){return t=+t,e=e>>>0,r||S(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};d.prototype.writeInt32BE=function(t,e,r){return t=+t,e=e>>>0,r||S(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};d.prototype.writeBigInt64LE=ht(function(t,e=0){return Ki(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});d.prototype.writeBigInt64BE=ht(function(t,e=0){return Si(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function ki(n,t,e,r,i,o){if(e+r>n.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function Oi(n,t,e,r,i){return t=+t,e=e>>>0,i||ki(n,t,e,4,34028234663852886e22,-34028234663852886e22),Wt.write(n,t,e,r,23,4),e+4}d.prototype.writeFloatLE=function(t,e,r){return Oi(this,t,e,!0,r)};d.prototype.writeFloatBE=function(t,e,r){return Oi(this,t,e,!1,r)};function Ii(n,t,e,r,i){return t=+t,e=e>>>0,i||ki(n,t,e,8,17976931348623157e292,-17976931348623157e292),Wt.write(n,t,e,r,52,8),e+8}d.prototype.writeDoubleLE=function(t,e,r){return Ii(this,t,e,!0,r)};d.prototype.writeDoubleBE=function(t,e,r){return Ii(this,t,e,!1,r)};d.prototype.copy=function(t,e,r,i){if(!d.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),!i&&i!==0&&(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i<r&&(i=r),i===r||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=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-r&&(i=t.length-e+r);let o=i-r;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,r,i):Uint8Array.prototype.set.call(t,this.subarray(r,i),e),o};d.prototype.fill=function(t,e,r,i){if(typeof t=="string"){if(typeof e=="string"?(i=e,e=0,r=this.length):typeof r=="string"&&(i=r,r=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!d.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<r)throw new RangeError("Out of range index");if(r<=e)return this;e=e>>>0,r=r===void 0?this.length:r>>>0,t||(t=0);let o;if(typeof t=="number")for(o=e;o<r;++o)this[o]=t;else{let s=d.isBuffer(t)?t:d.from(t,i),c=s.length;if(c===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<r-e;++o)this[o+e]=s[o%c]}return this};var Ht={};function Jr(n,t,e){Ht[n]=class extends e{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${n}]`,this.stack,delete this.name}get code(){return n}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${n}]: ${this.message}`}}}Jr("ERR_BUFFER_OUT_OF_BOUNDS",function(n){return n?`${n} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Jr("ERR_INVALID_ARG_TYPE",function(n,t){return`The "${n}" argument must be of type number. Received type ${typeof t}`},TypeError);Jr("ERR_OUT_OF_RANGE",function(n,t,e){let r=`The value of "${n}" is out of range.`,i=e;return Number.isInteger(e)&&Math.abs(e)>2**32?i=bi(String(e)):typeof e=="bigint"&&(i=String(e),(e>BigInt(2)**BigInt(32)||e<-(BigInt(2)**BigInt(32)))&&(i=bi(i)),i+="n"),r+=` It must be ${t}. Received ${i}`,r},RangeError);function bi(n){let t="",e=n.length,r=n[0]==="-"?1:0;for(;e>=r+4;e-=3)t=`_${n.slice(e-3,e)}${t}`;return`${n.slice(0,e)}${t}`}function oc(n,t,e){zt(t,"offset"),(n[t]===void 0||n[t+e]===void 0)&&de(t,n.length-(e+1))}function Ci(n,t,e,r,i,o){if(n>e||n<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 Ht.ERR_OUT_OF_RANGE("value",c,n)}oc(r,i,o)}function zt(n,t){if(typeof n!="number")throw new Ht.ERR_INVALID_ARG_TYPE(t,"number",n)}function de(n,t,e){throw Math.floor(n)!==n?(zt(n,e),new Ht.ERR_OUT_OF_RANGE(e||"offset","an integer",n)):t<0?new Ht.ERR_BUFFER_OUT_OF_BOUNDS:new Ht.ERR_OUT_OF_RANGE(e||"offset",`>= ${e?1:0} and <= ${t}`,n)}var sc=/[^+/0-9A-Za-z-_]/g;function cc(n){if(n=n.split("=")[0],n=n.trim().replace(sc,""),n.length<2)return"";for(;n.length%4!==0;)n=n+"=";return n}function jr(n,t){t=t||1/0;let e,r=n.length,i=null,o=[];for(let s=0;s<r;++s){if(e=n.charCodeAt(s),e>55295&&e<57344){if(!i){if(e>56319){(t-=3)>-1&&o.push(239,191,189);continue}else if(s+1===r){(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 uc(n){let t=[];for(let e=0;e<n.length;++e)t.push(n.charCodeAt(e)&255);return t}function ac(n,t){let e,r,i,o=[];for(let s=0;s<n.length&&!((t-=2)<0);++s)e=n.charCodeAt(s),r=e>>8,i=e%256,o.push(i),o.push(r);return o}function Ui(n){return Nr.toByteArray(cc(n))}function Ve(n,t,e,r){let i;for(i=0;i<r&&!(i+e>=t.length||i>=n.length);++i)t[i+e]=n[i];return i}function X(n,t){return n instanceof t||n!=null&&n.constructor!=null&&n.constructor.name!=null&&n.constructor.name===t.name}function Gr(n){return n!==n}var fc=function(){let n="0123456789abcdef",t=new Array(256);for(let e=0;e<16;++e){let r=e*16;for(let i=0;i<16;++i)t[r+i]=n[e]+n[i]}return t}();function ht(n){return typeof BigInt>"u"?hc:n}function hc(){throw new Error("BigInt not supported")}});var Wr=x((Ba,Pi)=>{"use strict";var Hr=null;Pi.exports=function(){return Hr===null&&(Hr={textEncoder:new TextEncoder,textDecoder:new TextDecoder}),Hr}});var Yr=x(Di=>{"use strict";var zr=V(),dc=new Set(["buffer","view","utf8"]),Xr=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"||!dc.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 zr(`Encoding '${this.name}' cannot be transcoded to 'buffer'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createViewTranscoder(){throw new zr(`Encoding '${this.name}' cannot be transcoded to 'view'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createUTF8Transcoder(){throw new zr(`Encoding '${this.name}' cannot be transcoded to 'utf8'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}};Di.Encoding=Xr});var en=x($e=>{"use strict";var{Buffer:Qr}=je()||{},{Encoding:tn}=Yr(),lc=Wr(),le=class extends tn{constructor(t){super({...t,format:"buffer"})}createViewTranscoder(){return new pe({encode:this.encode,decode:t=>this.decode(Qr.from(t.buffer,t.byteOffset,t.byteLength)),name:`${this.name}+view`})}createBufferTranscoder(){return this}},pe=class extends tn{constructor(t){super({...t,format:"view"})}createBufferTranscoder(){return new le({encode:t=>{let e=this.encode(t);return Qr.from(e.buffer,e.byteOffset,e.byteLength)},decode:this.decode,name:`${this.name}+buffer`})}createViewTranscoder(){return this}},Zr=class extends tn{constructor(t){super({...t,format:"utf8"})}createBufferTranscoder(){return new le({encode:t=>Qr.from(this.encode(t),"utf8"),decode:t=>this.decode(t.toString("utf8")),name:`${this.name}+buffer`})}createViewTranscoder(){let{textEncoder:t,textDecoder:e}=lc();return new pe({encode:r=>t.encode(this.encode(r)),decode:r=>this.decode(e.decode(r)),name:`${this.name}+view`})}createUTF8Transcoder(){return this}};$e.BufferFormat=le;$e.ViewFormat=pe;$e.UTF8Format=Zr});var Ni=x(kt=>{"use strict";var{Buffer:E}=je()||{Buffer:{isBuffer:()=>!1}},{textEncoder:Mi,textDecoder:Li}=Wr()(),{BufferFormat:ye,ViewFormat:rn,UTF8Format:Fi}=en(),qe=n=>n;kt.utf8=new Fi({encode:function(n){return E.isBuffer(n)?n.toString("utf8"):ArrayBuffer.isView(n)?Li.decode(n):String(n)},decode:qe,name:"utf8",createViewTranscoder(){return new rn({encode:function(n){return ArrayBuffer.isView(n)?n:Mi.encode(n)},decode:function(n){return Li.decode(n)},name:`${this.name}+view`})},createBufferTranscoder(){return new ye({encode:function(n){return E.isBuffer(n)?n:ArrayBuffer.isView(n)?E.from(n.buffer,n.byteOffset,n.byteLength):E.from(String(n),"utf8")},decode:function(n){return n.toString("utf8")},name:`${this.name}+buffer`})}});kt.json=new Fi({encode:JSON.stringify,decode:JSON.parse,name:"json"});kt.buffer=new ye({encode:function(n){return E.isBuffer(n)?n:ArrayBuffer.isView(n)?E.from(n.buffer,n.byteOffset,n.byteLength):E.from(String(n),"utf8")},decode:qe,name:"buffer",createViewTranscoder(){return new rn({encode:function(n){return ArrayBuffer.isView(n)?n:E.from(String(n),"utf8")},decode:function(n){return E.from(n.buffer,n.byteOffset,n.byteLength)},name:`${this.name}+view`})}});kt.view=new rn({encode:function(n){return ArrayBuffer.isView(n)?n:Mi.encode(n)},decode:qe,name:"view",createBufferTranscoder(){return new ye({encode:function(n){return E.isBuffer(n)?n:ArrayBuffer.isView(n)?E.from(n.buffer,n.byteOffset,n.byteLength):E.from(String(n),"utf8")},decode:qe,name:`${this.name}+buffer`})}});kt.hex=new ye({encode:function(n){return E.isBuffer(n)?n:E.from(String(n),"hex")},decode:function(n){return n.toString("hex")},name:"hex"});kt.base64=new ye({encode:function(n){return E.isBuffer(n)?n:E.from(String(n),"base64")},decode:function(n){return n.toString("base64")},name:"base64"})});var ji=x(Vi=>{"use strict";var Ri=V(),Ge=Ni(),{Encoding:pc}=Yr(),{BufferFormat:yc,ViewFormat:mc,UTF8Format:wc}=en(),me=Symbol("formats"),Je=Symbol("encodings"),gc=new Set(["buffer","view","utf8"]),nn=class{constructor(t){if(Array.isArray(t)){if(!t.every(e=>gc.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[Je]=new Map,this[me]=new Set(t);for(let e in Ge)try{this.encoding(e)}catch(r){if(r.code!=="LEVEL_ENCODING_NOT_SUPPORTED")throw r}}encodings(){return Array.from(new Set(this[Je].values()))}encoding(t){let e=this[Je].get(t);if(e===void 0){if(typeof t=="string"&&t!==""){if(e=Ec[t],!e)throw new Ri(`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=xc(t)}let{name:r,format:i}=e;if(!this[me].has(i))if(this[me].has("view"))e=e.createViewTranscoder();else if(this[me].has("buffer"))e=e.createBufferTranscoder();else if(this[me].has("utf8"))e=e.createUTF8Transcoder();else throw new Ri(`Encoding '${r}' cannot be transcoded`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"});for(let o of[t,r,e.name,e.commonName])this[Je].set(o,e)}return e}};Vi.Transcoder=nn;function xc(n){if(n instanceof pc)return n;let t="type"in n&&typeof n.type=="string"?n.type:void 0,e=n.name||t||`anonymous-${Tc++}`;switch(vc(n)){case"view":return new mc({...n,name:e});case"utf8":return new wc({...n,name:e});case"buffer":return new yc({...n,name:e});default:throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'")}}function vc(n){return"format"in n&&n.format!==void 0?n.format:"buffer"in n&&typeof n.buffer=="boolean"?n.buffer?"buffer":"utf8":"code"in n&&Number.isInteger(n.code)?"view":"buffer"}var bc={binary:Ge.buffer,"utf-8":Ge.utf8},Ec={...Ge,...bc},Tc=0});var qi=x((Ia,on)=>{"use strict";var Ac=Object.prototype.hasOwnProperty,B="~";function we(){}Object.create&&(we.prototype=Object.create(null),new we().__proto__||(B=!1));function _c(n,t,e){this.fn=n,this.context=t,this.once=e||!1}function $i(n,t,e,r,i){if(typeof e!="function")throw new TypeError("The listener must be a function");var o=new _c(e,r||n,i),s=B?B+t:t;return n._events[s]?n._events[s].fn?n._events[s]=[n._events[s],o]:n._events[s].push(o):(n._events[s]=o,n._eventsCount++),n}function He(n,t){--n._eventsCount===0?n._events=new we:delete n._events[t]}function T(){this._events=new we,this._eventsCount=0}T.prototype.eventNames=function(){var t=[],e,r;if(this._eventsCount===0)return t;for(r in e=this._events)Ac.call(e,r)&&t.push(B?r.slice(1):r);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(e)):t};T.prototype.listeners=function(t){var e=B?B+t:t,r=this._events[e];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,o=r.length,s=new Array(o);i<o;i++)s[i]=r[i].fn;return s};T.prototype.listenerCount=function(t){var e=B?B+t:t,r=this._events[e];return r?r.fn?1:r.length:0};T.prototype.emit=function(t,e,r,i,o,s){var c=B?B+t:t;if(!this._events[c])return!1;var u=this._events[c],a=arguments.length,h,f;if(u.fn){switch(u.once&&this.removeListener(t,u.fn,void 0,!0),a){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,e),!0;case 3:return u.fn.call(u.context,e,r),!0;case 4:return u.fn.call(u.context,e,r,i),!0;case 5:return u.fn.call(u.context,e,r,i,o),!0;case 6:return u.fn.call(u.context,e,r,i,o,s),!0}for(f=1,h=new Array(a-1);f<a;f++)h[f-1]=arguments[f];u.fn.apply(u.context,h)}else{var l=u.length,p;for(f=0;f<l;f++)switch(u[f].once&&this.removeListener(t,u[f].fn,void 0,!0),a){case 1:u[f].fn.call(u[f].context);break;case 2:u[f].fn.call(u[f].context,e);break;case 3:u[f].fn.call(u[f].context,e,r);break;case 4:u[f].fn.call(u[f].context,e,r,i);break;default:if(!h)for(p=1,h=new Array(a-1);p<a;p++)h[p-1]=arguments[p];u[f].fn.apply(u[f].context,h)}}return!0};T.prototype.on=function(t,e,r){return $i(this,t,e,r,!1)};T.prototype.once=function(t,e,r){return $i(this,t,e,r,!0)};T.prototype.removeListener=function(t,e,r,i){var o=B?B+t:t;if(!this._events[o])return this;if(!e)return He(this,o),this;var s=this._events[o];if(s.fn)s.fn===e&&(!i||s.once)&&(!r||s.context===r)&&He(this,o);else{for(var c=0,u=[],a=s.length;c<a;c++)(s[c].fn!==e||i&&!s[c].once||r&&s[c].context!==r)&&u.push(s[c]);u.length?this._events[o]=u.length===1?u[0]:u:He(this,o)}return this};T.prototype.removeAllListeners=function(t){var e;return t?(e=B?B+t:t,this._events[e]&&He(this,e)):(this._events=new we,this._eventsCount=0),this};T.prototype.off=T.prototype.removeListener;T.prototype.addListener=T.prototype.on;T.prefixed=B;T.EventEmitter=T;typeof on<"u"&&(on.exports=T)});var Gi=x((Ca,Ji)=>{Ji.exports=typeof queueMicrotask=="function"?queueMicrotask:n=>Promise.resolve().then(n)});var ge=x(sn=>{"use strict";var Hi=Gi();sn.fromCallback=function(n,t){if(n===void 0){var e=new Promise(function(r,i){n=function(o,s){o?i(o):r(s)}});n[t!==void 0?t:"promise"]=e}else if(typeof n!="function")throw new TypeError("Callback must be a function");return n};sn.fromPromise=function(n,t){if(t===void 0)return n;n.then(function(e){Hi(()=>t(null,e))}).catch(function(e){Hi(()=>t(e))})}});var We=x(cn=>{"use strict";cn.getCallback=function(n,t){return typeof n=="function"?n:t};cn.getOptions=function(n,t){return typeof n=="object"&&n!==null?n:t!==void 0?t:{}}});var wt=x(Ze=>{"use strict";var{fromCallback:un}=ge(),I=V(),{getOptions:an,getCallback:Wi}=We(),Ot=Symbol("promise"),Yt=Symbol("callback"),Y=Symbol("working"),It=Symbol("handleOne"),nt=Symbol("handleMany"),fn=Symbol("autoClose"),yt=Symbol("finishWork"),Z=Symbol("returnMany"),dt=Symbol("closing"),xe=Symbol("handleClose"),ze=Symbol("closed"),ve=Symbol("closeCallbacks"),pt=Symbol("keyEncoding"),Ct=Symbol("valueEncoding"),hn=Symbol("abortOnClose"),Xe=Symbol("legacy"),dn=Symbol("keys"),ln=Symbol("values"),lt=Symbol("limit"),M=Symbol("count"),Ye=Object.freeze({}),Bc=()=>{},zi=!1,be=class{constructor(t,e,r){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[ze]=!1,this[ve]=[],this[Y]=!1,this[dt]=!1,this[fn]=!1,this[Yt]=null,this[It]=this[It].bind(this),this[nt]=this[nt].bind(this),this[xe]=this[xe].bind(this),this[pt]=e[pt],this[Ct]=e[Ct],this[Xe]=r,this[lt]=Number.isInteger(e.limit)&&e.limit>=0?e.limit:1/0,this[M]=0,this[hn]=!!e.abortOnClose,this.db=t,this.db.attachResource(this),this.nextTick=t.nextTick}get count(){return this[M]}get limit(){return this[lt]}next(t){let e;if(t===void 0)e=new Promise((r,i)=>{t=(o,s,c)=>{o?i(o):this[Xe]?s===void 0&&c===void 0?r():r([s,c]):r(s)}});else if(typeof t!="function")throw new TypeError("Callback must be a function");return this[dt]?this.nextTick(t,new I("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[Y]?this.nextTick(t,new I("Iterator is busy: cannot call next() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[Y]=!0,this[Yt]=t,this[M]>=this[lt]?this.nextTick(this[It],null):this._next(this[It])),e}_next(t){this.nextTick(t)}nextv(t,e,r){return r=Wi(e,r),r=un(r,Ot),e=an(e,Ye),Number.isInteger(t)?(this[dt]?this.nextTick(r,new I("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[Y]?this.nextTick(r,new I("Iterator is busy: cannot call nextv() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(t<1&&(t=1),this[lt]<1/0&&(t=Math.min(t,this[lt]-this[M])),this[Y]=!0,this[Yt]=r,t<=0?this.nextTick(this[nt],null,[]):this._nextv(t,e,this[nt])),r[Ot]):(this.nextTick(r,new TypeError("The first argument 'size' must be an integer")),r[Ot])}_nextv(t,e,r){let i=[],o=(s,c,u)=>{if(s)return r(s);if(this[Xe]?c===void 0&&u===void 0:c===void 0)return r(null,i);i.push(this[Xe]?[c,u]:c),i.length===t?r(null,i):this._next(o)};this._next(o)}all(t,e){return e=Wi(t,e),e=un(e,Ot),t=an(t,Ye),this[dt]?this.nextTick(e,new I("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[Y]?this.nextTick(e,new I("Iterator is busy: cannot call all() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[Y]=!0,this[Yt]=e,this[fn]=!0,this[M]>=this[lt]?this.nextTick(this[nt],null,[]):this._all(t,this[nt])),e[Ot]}_all(t,e){let r=this[M],i=[],o=()=>{let c=this[lt]<1/0?Math.min(1e3,this[lt]-r):1e3;c<=0?this.nextTick(e,null,i):this._nextv(c,Ye,s)},s=(c,u)=>{c?e(c):u.length===0?e(null,i):(i.push.apply(i,u),r+=u.length,o())};o()}[yt](){let t=this[Yt];return this[hn]&&t===null?Bc:(this[Y]=!1,this[Yt]=null,this[dt]&&this._close(this[xe]),t)}[Z](t,e,r){this[fn]?this.close(t.bind(null,e,r)):t(e,r)}seek(t,e){if(e=an(e,Ye),!this[dt]){if(this[Y])throw new I("Iterator is busy: cannot call seek() until next() has completed",{code:"LEVEL_ITERATOR_BUSY"});{let r=this.db.keyEncoding(e.keyEncoding||this[pt]),i=r.format;e.keyEncoding!==i&&(e={...e,keyEncoding:i});let o=this.db.prefixKey(r.encode(t),i);this._seek(o,e)}}}_seek(t,e){throw new I("Iterator does not support seek()",{code:"LEVEL_NOT_SUPPORTED"})}close(t){return t=un(t,Ot),this[ze]?this.nextTick(t):this[dt]?this[ve].push(t):(this[dt]=!0,this[ve].push(t),this[Y]?this[hn]&&this[yt]()(new I("Aborted on iterator close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this._close(this[xe])),t[Ot]}_close(t){this.nextTick(t)}[xe](){this[ze]=!0,this.db.detachResource(this);let t=this[ve];this[ve]=[];for(let e of t)e()}async*[Symbol.asyncIterator](){try{let t;for(;(t=await this.next())!==void 0;)yield t}finally{this[ze]||await this.close()}}},Zt=class extends be{constructor(t,e){super(t,e,!0),this[dn]=e.keys!==!1,this[ln]=e.values!==!1}[It](t,e,r){let i=this[yt]();if(t)return i(t);try{e=this[dn]&&e!==void 0?this[pt].decode(e):void 0,r=this[ln]&&r!==void 0?this[Ct].decode(r):void 0}catch(o){return i(new mt("entry",o))}e===void 0&&r===void 0||this[M]++,i(null,e,r)}[nt](t,e){let r=this[yt]();if(t)return this[Z](r,t);try{for(let i of e){let o=i[0],s=i[1];i[0]=this[dn]&&o!==void 0?this[pt].decode(o):void 0,i[1]=this[ln]&&s!==void 0?this[Ct].decode(s):void 0}}catch(i){return this[Z](r,new mt("entries",i))}this[M]+=e.length,this[Z](r,null,e)}end(t){return!zi&&typeof console<"u"&&(zi=!0,console.warn(new I("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)}},pn=class extends be{constructor(t,e){super(t,e,!1)}[It](t,e){let r=this[yt]();if(t)return r(t);try{e=e!==void 0?this[pt].decode(e):void 0}catch(i){return r(new mt("key",i))}e!==void 0&&this[M]++,r(null,e)}[nt](t,e){let r=this[yt]();if(t)return this[Z](r,t);try{for(let i=0;i<e.length;i++){let o=e[i];e[i]=o!==void 0?this[pt].decode(o):void 0}}catch(i){return this[Z](r,new mt("keys",i))}this[M]+=e.length,this[Z](r,null,e)}},yn=class extends be{constructor(t,e){super(t,e,!1)}[It](t,e){let r=this[yt]();if(t)return r(t);try{e=e!==void 0?this[Ct].decode(e):void 0}catch(i){return r(new mt("value",i))}e!==void 0&&this[M]++,r(null,e)}[nt](t,e){let r=this[yt]();if(t)return this[Z](r,t);try{for(let i=0;i<e.length;i++){let o=e[i];e[i]=o!==void 0?this[Ct].decode(o):void 0}}catch(i){return this[Z](r,new mt("values",i))}this[M]+=e.length,this[Z](r,null,e)}},mt=class extends I{constructor(t,e){super(`Iterator could not decode ${t}`,{code:"LEVEL_DECODE_ERROR",cause:e})}};for(let n of["_ended property","_nexting property","_end method"])Object.defineProperty(Zt.prototype,n.split(" ")[0],{get(){throw new I(`The ${n} has been removed`,{code:"LEVEL_LEGACY"})},set(){throw new I(`The ${n} has been removed`,{code:"LEVEL_LEGACY"})}});Zt.keyEncoding=pt;Zt.valueEncoding=Ct;Ze.AbstractIterator=Zt;Ze.AbstractKeyIterator=pn;Ze.AbstractValueIterator=yn});var Xi=x(mn=>{"use strict";var{AbstractKeyIterator:Kc,AbstractValueIterator:Sc}=wt(),Ut=Symbol("iterator"),Ee=Symbol("callback"),Qt=Symbol("handleOne"),Pt=Symbol("handleMany"),Te=class extends Kc{constructor(t,e){super(t,e),this[Ut]=t.iterator({...e,keys:!0,values:!1}),this[Qt]=this[Qt].bind(this),this[Pt]=this[Pt].bind(this)}},Qe=class extends Sc{constructor(t,e){super(t,e),this[Ut]=t.iterator({...e,keys:!1,values:!0}),this[Qt]=this[Qt].bind(this),this[Pt]=this[Pt].bind(this)}};for(let n of[Te,Qe]){let t=n===Te,e=t?r=>r[0]:r=>r[1];n.prototype._next=function(r){this[Ee]=r,this[Ut].next(this[Qt])},n.prototype[Qt]=function(r,i,o){let s=this[Ee];r?s(r):s(null,t?i:o)},n.prototype._nextv=function(r,i,o){this[Ee]=o,this[Ut].nextv(r,i,this[Pt])},n.prototype._all=function(r,i){this[Ee]=i,this[Ut].all(r,this[Pt])},n.prototype[Pt]=function(r,i){let o=this[Ee];r?o(r):o(null,i.map(e))},n.prototype._seek=function(r,i){this[Ut].seek(r,i)},n.prototype._close=function(r){this[Ut].close(r)}}mn.DefaultKeyIterator=Te;mn.DefaultValueIterator=Qe});var Yi=x(or=>{"use strict";var{AbstractIterator:kc,AbstractKeyIterator:Oc,AbstractValueIterator:Ic}=wt(),wn=V(),k=Symbol("nut"),nr=Symbol("undefer"),ir=Symbol("factory"),tr=class extends kc{constructor(t,e){super(t,e),this[k]=null,this[ir]=()=>t.iterator(e),this.db.defer(()=>this[nr]())}},er=class extends Oc{constructor(t,e){super(t,e),this[k]=null,this[ir]=()=>t.keys(e),this.db.defer(()=>this[nr]())}},rr=class extends Ic{constructor(t,e){super(t,e),this[k]=null,this[ir]=()=>t.values(e),this.db.defer(()=>this[nr]())}};for(let n of[tr,er,rr])n.prototype[nr]=function(){this.db.status==="open"&&(this[k]=this[ir]())},n.prototype._next=function(t){this[k]!==null?this[k].next(t):this.db.status==="opening"?this.db.defer(()=>this._next(t)):this.nextTick(t,new wn("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},n.prototype._nextv=function(t,e,r){this[k]!==null?this[k].nextv(t,e,r):this.db.status==="opening"?this.db.defer(()=>this._nextv(t,e,r)):this.nextTick(r,new wn("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},n.prototype._all=function(t,e){this[k]!==null?this[k].all(e):this.db.status==="opening"?this.db.defer(()=>this._all(t,e)):this.nextTick(e,new wn("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},n.prototype._seek=function(t,e){this[k]!==null?this[k]._seek(t,e):this.db.status==="opening"&&this.db.defer(()=>this._seek(t,e))},n.prototype._close=function(t){this[k]!==null?this[k].close(t):this.db.status==="opening"?this.db.defer(()=>this._close(t)):this.nextTick(t)};or.DeferredIterator=tr;or.DeferredKeyIterator=er;or.DeferredValueIterator=rr});var xn=x(Qi=>{"use strict";var{fromCallback:Zi}=ge(),sr=V(),{getCallback:Cc,getOptions:Uc}=We(),cr=Symbol("promise"),F=Symbol("status"),te=Symbol("operations"),Ae=Symbol("finishClose"),ee=Symbol("closeCallbacks"),gn=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[te]=[],this[ee]=[],this[F]="open",this[Ae]=this[Ae].bind(this),this.db=t,this.db.attachResource(this),this.nextTick=t.nextTick}get length(){return this[te].length}put(t,e,r){if(this[F]!=="open")throw new sr("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=r&&r.sublevel!=null?r.sublevel:this.db,s=r,c=o.keyEncoding(r&&r.keyEncoding),u=o.valueEncoding(r&&r.valueEncoding),a=c.format;r={...r,keyEncoding:a,valueEncoding:u.format},o!==this.db&&(r.sublevel=null);let h=o.prefixKey(c.encode(t),a),f=u.encode(e);return this._put(h,f,r),this[te].push({...s,type:"put",key:t,value:e}),this}_put(t,e,r){}del(t,e){if(this[F]!=="open")throw new sr("Batch is not open: cannot call del() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});let r=this.db._checkKey(t);if(r)throw r;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[te].push({...o,type:"del",key:t}),this}_del(t,e){}clear(){if(this[F]!=="open")throw new sr("Batch is not open: cannot call clear() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});return this._clear(),this[te]=[],this}_clear(){}write(t,e){return e=Cc(t,e),e=Zi(e,cr),t=Uc(t),this[F]!=="open"?this.nextTick(e,new sr("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"})):this.length===0?this.close(e):(this[F]="writing",this._write(t,r=>{this[F]="closing",this[ee].push(()=>e(r)),r||this.db.emit("batch",this[te]),this._close(this[Ae])})),e[cr]}_write(t,e){}close(t){return t=Zi(t,cr),this[F]==="closing"?this[ee].push(t):this[F]==="closed"?this.nextTick(t):(this[ee].push(t),this[F]!=="writing"&&(this[F]="closing",this._close(this[Ae]))),t[cr]}_close(t){this.nextTick(t)}[Ae](){this[F]="closed",this.db.detachResource(this);let t=this[ee];this[ee]=[];for(let e of t)e()}};Qi.AbstractChainedBatch=gn});var eo=x(to=>{"use strict";var{AbstractChainedBatch:Pc}=xn(),Dc=V(),re=Symbol("encoded"),vn=class extends Pc{constructor(t){super(t),this[re]=[]}_put(t,e,r){this[re].push({...r,type:"put",key:t,value:e})}_del(t,e){this[re].push({...e,type:"del",key:t})}_clear(){this[re]=[]}_write(t,e){this.db.status==="opening"?this.db.defer(()=>this._write(t,e)):this.db.status==="open"?this[re].length===0?this.nextTick(e):this.db._batch(this[re],t,e):this.nextTick(e,new Dc("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"}))}};to.DefaultChainedBatch=vn});var io=x((Ra,no)=>{"use strict";var ro=V(),Lc=Object.prototype.hasOwnProperty,Mc=new Set(["lt","lte","gt","gte"]);no.exports=function(n,t){let e={};for(let r in n)if(Lc.call(n,r)&&!(r==="keyEncoding"||r==="valueEncoding")){if(r==="start"||r==="end")throw new ro(`The legacy range option '${r}' has been removed`,{code:"LEVEL_LEGACY"});if(r==="encoding")throw new ro("The levelup-style 'encoding' alias has been removed, use 'valueEncoding' instead",{code:"LEVEL_LEGACY"});Mc.has(r)?e[r]=t.encode(n[r]):e[r]=n[r]}return e.reverse=!!e.reverse,e.limit=Number.isInteger(e.limit)&&e.limit>=0?e.limit:-1,e}});var bn=x((Va,so)=>{var oo;so.exports=typeof queueMicrotask=="function"?queueMicrotask.bind(typeof window<"u"?window:globalThis):n=>(oo||(oo=Promise.resolve())).then(n).catch(t=>setTimeout(()=>{throw t},0))});var ao=x((ja,uo)=>{"use strict";var co=bn();uo.exports=function(n,...t){t.length===0?co(n):co(()=>n(...t))}});var fo=x(ur=>{"use strict";var{AbstractIterator:Fc,AbstractKeyIterator:Nc,AbstractValueIterator:Rc}=wt(),ne=Symbol("unfix"),j=Symbol("iterator"),Dt=Symbol("handleOne"),gt=Symbol("handleMany"),it=Symbol("callback"),_e=class extends Fc{constructor(t,e,r,i){super(t,e),this[j]=r,this[ne]=i,this[Dt]=this[Dt].bind(this),this[gt]=this[gt].bind(this),this[it]=null}[Dt](t,e,r){let i=this[it];if(t)return i(t);e!==void 0&&(e=this[ne](e)),i(t,e,r)}[gt](t,e){let r=this[it];if(t)return r(t);for(let i of e){let o=i[0];o!==void 0&&(i[0]=this[ne](o))}r(t,e)}},Be=class extends Nc{constructor(t,e,r,i){super(t,e),this[j]=r,this[ne]=i,this[Dt]=this[Dt].bind(this),this[gt]=this[gt].bind(this),this[it]=null}[Dt](t,e){let r=this[it];if(t)return r(t);e!==void 0&&(e=this[ne](e)),r(t,e)}[gt](t,e){let r=this[it];if(t)return r(t);for(let i=0;i<e.length;i++){let o=e[i];o!==void 0&&(e[i]=this[ne](o))}r(t,e)}},Ke=class extends Rc{constructor(t,e,r){super(t,e),this[j]=r}};for(let n of[_e,Be])n.prototype._next=function(t){this[it]=t,this[j].next(this[Dt])},n.prototype._nextv=function(t,e,r){this[it]=r,this[j].nextv(t,e,this[gt])},n.prototype._all=function(t,e){this[it]=e,this[j].all(t,this[gt])};for(let n of[Ke])n.prototype._next=function(t){this[j].next(t)},n.prototype._nextv=function(t,e,r){this[j].nextv(t,e,r)},n.prototype._all=function(t,e){this[j].all(t,e)};for(let n of[_e,Be,Ke])n.prototype._seek=function(t,e){this[j].seek(t,e)},n.prototype._close=function(t){this[j].close(t)};ur.AbstractSublevelIterator=_e;ur.AbstractSublevelKeyIterator=Be;ur.AbstractSublevelValueIterator=Ke});var yo=x((qa,po)=>{"use strict";var En=V(),{Buffer:_n}=je()||{},{AbstractSublevelIterator:Vc,AbstractSublevelKeyIterator:jc,AbstractSublevelValueIterator:$c}=fo(),ot=Symbol("prefix"),ho=Symbol("upperBound"),Se=Symbol("prefixRange"),C=Symbol("parent"),Tn=Symbol("unfix"),lo=new TextEncoder,qc={separator:"!"};po.exports=function({AbstractLevel:n}){class t extends n{static defaults(r){if(typeof r=="string")throw new En("The subleveldown string shorthand for { separator } has been removed",{code:"LEVEL_LEGACY"});if(r&&r.open)throw new En("The subleveldown open option has been removed",{code:"LEVEL_LEGACY"});return r==null?qc:r.separator?r:{...r,separator:"!"}}constructor(r,i,o){let{separator:s,manifest:c,...u}=t.defaults(o);i=Gc(i,s);let a=s.charCodeAt(0)+1,h=r[C]||r;if(!lo.encode(i).every(p=>p>a&&p<127))throw new En(`Prefix must use bytes > ${a} < 127`,{code:"LEVEL_INVALID_PREFIX"});super(Jc(h,c),u);let f=(r.prefix||"")+s+i+s,l=f.slice(0,-1)+String.fromCharCode(a);this[C]=h,this[ot]=new ar(f),this[ho]=new ar(l),this[Tn]=new Bn,this.nextTick=h.nextTick}prefixKey(r,i){if(i==="utf8")return this[ot].utf8+r;if(r.byteLength===0)return this[ot][i];if(i==="view"){let o=this[ot].view,s=new Uint8Array(o.byteLength+r.byteLength);return s.set(o,0),s.set(r,o.byteLength),s}else{let o=this[ot].buffer;return _n.concat([o,r],o.byteLength+r.byteLength)}}[Se](r,i){r.gte!==void 0?r.gte=this.prefixKey(r.gte,i):r.gt!==void 0?r.gt=this.prefixKey(r.gt,i):r.gte=this[ot][i],r.lte!==void 0?r.lte=this.prefixKey(r.lte,i):r.lt!==void 0?r.lt=this.prefixKey(r.lt,i):r.lte=this[ho][i]}get prefix(){return this[ot].utf8}get db(){return this[C]}_open(r,i){this[C].open({passive:!0},i)}_put(r,i,o,s){this[C].put(r,i,o,s)}_get(r,i,o){this[C].get(r,i,o)}_getMany(r,i,o){this[C].getMany(r,i,o)}_del(r,i,o){this[C].del(r,i,o)}_batch(r,i,o){this[C].batch(r,i,o)}_clear(r,i){this[Se](r,r.keyEncoding),this[C].clear(r,i)}_iterator(r){this[Se](r,r.keyEncoding);let i=this[C].iterator(r),o=this[Tn].get(this[ot].utf8.length,r.keyEncoding);return new Vc(this,r,i,o)}_keys(r){this[Se](r,r.keyEncoding);let i=this[C].keys(r),o=this[Tn].get(this[ot].utf8.length,r.keyEncoding);return new jc(this,r,i,o)}_values(r){this[Se](r,r.keyEncoding);let i=this[C].values(r);return new $c(this,r,i)}}return{AbstractSublevel:t}};var Jc=function(n,t){return{...n.supports,createIfMissing:!1,errorIfExists:!1,events:{},additionalMethods:{},...t,encodings:{utf8:An(n,"utf8"),buffer:An(n,"buffer"),view:An(n,"view")}}},An=function(n,t){return n.supports.encodings[t]?n.keyEncoding(t).name===t:!1},ar=class{constructor(t){this.utf8=t,this.view=lo.encode(t),this.buffer=_n?_n.from(this.view.buffer,0,this.view.byteLength):{}}},Bn=class{constructor(){this.cache=new Map}get(t,e){let r=this.cache.get(e);return r===void 0&&(e==="view"?r=(function(i,o){return o.subarray(i)}).bind(null,t):r=(function(i,o){return o.slice(i)}).bind(null,t),this.cache.set(e,r)),r}},Gc=function(n,t){let e=0,r=n.length;for(;e<r&&n[e]===t;)e++;for(;r>e&&n[r-1]===t;)r--;return n.slice(e,r)}});var In=x(On=>{"use strict";var{supports:Hc}=di(),{Transcoder:Wc}=ji(),{EventEmitter:zc}=qi(),{fromCallback:xt}=ge(),$=V(),{AbstractIterator:Lt}=wt(),{DefaultKeyIterator:Xc,DefaultValueIterator:Yc}=Xi(),{DeferredIterator:Zc,DeferredKeyIterator:Qc,DeferredValueIterator:tu}=Yi(),{DefaultChainedBatch:mo}=eo(),{getCallback:Mt,getOptions:vt}=We(),fr=io(),m=Symbol("promise"),st=Symbol("landed"),Ft=Symbol("resources"),Kn=Symbol("closeResources"),ke=Symbol("operations"),Oe=Symbol("undefer"),hr=Symbol("deferOpen"),wo=Symbol("options"),w=Symbol("status"),Nt=Symbol("defaultOptions"),ie=Symbol("transcoder"),dr=Symbol("keyEncoding"),Sn=Symbol("valueEncoding"),eu=()=>{},Ie=class extends zc{constructor(t,e){if(super(),typeof t!="object"||t===null)throw new TypeError("The first argument 'manifest' must be an object");e=vt(e);let{keyEncoding:r,valueEncoding:i,passive:o,...s}=e;this[Ft]=new Set,this[ke]=[],this[hr]=!0,this[wo]=s,this[w]="opening",this.supports=Hc(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[ie]=new Wc(ru(this)),this[dr]=this[ie].encoding(r||"utf8"),this[Sn]=this[ie].encoding(i||"utf8");for(let c of this[ie].encodings())this.supports.encodings[c.commonName]||(this.supports.encodings[c.commonName]=!0);this[Nt]={empty:Object.freeze({}),entry:Object.freeze({keyEncoding:this[dr].commonName,valueEncoding:this[Sn].commonName}),key:Object.freeze({keyEncoding:this[dr].commonName})},this.nextTick(()=>{this[hr]&&this.open({passive:!1},eu)})}get status(){return this[w]}keyEncoding(t){return this[ie].encoding(t??this[dr])}valueEncoding(t){return this[ie].encoding(t??this[Sn])}open(t,e){e=Mt(t,e),e=xt(e,m),t={...this[wo],...vt(t)},t.createIfMissing=t.createIfMissing!==!1,t.errorIfExists=!!t.errorIfExists;let r=i=>{this[w]==="closing"||this[w]==="opening"?this.once(st,i?()=>r(i):r):this[w]!=="open"?e(new $("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN",cause:i})):e()};return t.passive?this[w]==="opening"?this.once(st,r):this.nextTick(r):this[w]==="closed"||this[hr]?(this[hr]=!1,this[w]="opening",this.emit("opening"),this._open(t,i=>{if(i){this[w]="closed",this[Kn](()=>{this.emit(st),r(i)}),this[Oe]();return}this[w]="open",this[Oe](),this.emit(st),this[w]==="open"&&this.emit("open"),this[w]==="open"&&this.emit("ready"),r()})):this[w]==="open"?this.nextTick(r):this.once(st,()=>this.open(t,e)),e[m]}_open(t,e){this.nextTick(e)}close(t){t=xt(t,m);let e=r=>{this[w]==="opening"||this[w]==="closing"?this.once(st,r?e(r):e):this[w]!=="closed"?t(new $("Database is not closed",{code:"LEVEL_DATABASE_NOT_CLOSED",cause:r})):t()};if(this[w]==="open"){this[w]="closing",this.emit("closing");let r=i=>{this[w]="open",this[Oe](),this.emit(st),e(i)};this[Kn](()=>{this._close(i=>{if(i)return r(i);this[w]="closed",this[Oe](),this.emit(st),this[w]==="closed"&&this.emit("closed"),e()})})}else this[w]==="closed"?this.nextTick(e):this.once(st,()=>this.close(t));return t[m]}[Kn](t){if(this[Ft].size===0)return this.nextTick(t);let e=this[Ft].size,r=!0,i=()=>{--e===0&&(r?this.nextTick(t):t())};for(let o of this[Ft])o.close(i);r=!1,this[Ft].clear()}_close(t){this.nextTick(t)}get(t,e,r){if(r=Mt(e,r),r=xt(r,m),e=vt(e,this[Nt].entry),this[w]==="opening")return this.defer(()=>this.get(t,e,r)),r[m];if(oe(this,r))return r[m];let i=this._checkKey(t);if(i)return this.nextTick(r,i),r[m];let o=this.keyEncoding(e.keyEncoding),s=this.valueEncoding(e.valueEncoding),c=o.format,u=s.format;return(e.keyEncoding!==c||e.valueEncoding!==u)&&(e=Object.assign({},e,{keyEncoding:c,valueEncoding:u})),this._get(this.prefixKey(o.encode(t),c),e,(a,h)=>{if(a)return(a.code==="LEVEL_NOT_FOUND"||a.notFound||/NotFound/i.test(a))&&(a.code||(a.code="LEVEL_NOT_FOUND"),a.notFound||(a.notFound=!0),a.status||(a.status=404)),r(a);try{h=s.decode(h)}catch(f){return r(new $("Could not decode value",{code:"LEVEL_DECODE_ERROR",cause:f}))}r(null,h)}),r[m]}_get(t,e,r){this.nextTick(r,new Error("NotFound"))}getMany(t,e,r){if(r=Mt(e,r),r=xt(r,m),e=vt(e,this[Nt].entry),this[w]==="opening")return this.defer(()=>this.getMany(t,e,r)),r[m];if(oe(this,r))return r[m];if(!Array.isArray(t))return this.nextTick(r,new TypeError("The first argument 'keys' must be an array")),r[m];if(t.length===0)return this.nextTick(r,null,[]),r[m];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 u=new Array(t.length);for(let a=0;a<t.length;a++){let h=t[a],f=this._checkKey(h);if(f)return this.nextTick(r,f),r[m];u[a]=this.prefixKey(i.encode(h),s)}return this._getMany(u,e,(a,h)=>{if(a)return r(a);try{for(let f=0;f<h.length;f++)h[f]!==void 0&&(h[f]=o.decode(h[f]))}catch(f){return r(new $(`Could not decode one or more of ${h.length} value(s)`,{code:"LEVEL_DECODE_ERROR",cause:f}))}r(null,h)}),r[m]}_getMany(t,e,r){this.nextTick(r,null,new Array(t.length).fill(void 0))}put(t,e,r,i){if(i=Mt(r,i),i=xt(i,m),r=vt(r,this[Nt].entry),this[w]==="opening")return this.defer(()=>this.put(t,e,r,i)),i[m];if(oe(this,i))return i[m];let o=this._checkKey(t)||this._checkValue(e);if(o)return this.nextTick(i,o),i[m];let s=this.keyEncoding(r.keyEncoding),c=this.valueEncoding(r.valueEncoding),u=s.format,a=c.format;(r.keyEncoding!==u||r.valueEncoding!==a)&&(r=Object.assign({},r,{keyEncoding:u,valueEncoding:a}));let h=this.prefixKey(s.encode(t),u),f=c.encode(e);return this._put(h,f,r,l=>{if(l)return i(l);this.emit("put",t,e),i()}),i[m]}_put(t,e,r,i){this.nextTick(i)}del(t,e,r){if(r=Mt(e,r),r=xt(r,m),e=vt(e,this[Nt].key),this[w]==="opening")return this.defer(()=>this.del(t,e,r)),r[m];if(oe(this,r))return r[m];let i=this._checkKey(t);if(i)return this.nextTick(r,i),r[m];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 r(c);this.emit("del",t),r()}),r[m]}_del(t,e,r){this.nextTick(r)}batch(t,e,r){if(!arguments.length){if(this[w]==="opening")return new mo(this);if(this[w]!=="open")throw new $("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._chainedBatch()}if(typeof t=="function"?r=t:r=Mt(e,r),r=xt(r,m),e=vt(e,this[Nt].empty),this[w]==="opening")return this.defer(()=>this.batch(t,e,r)),r[m];if(oe(this,r))return r[m];if(!Array.isArray(t))return this.nextTick(r,new TypeError("The first argument 'operations' must be an array")),r[m];if(t.length===0)return this.nextTick(r),r[m];let i=new Array(t.length),{keyEncoding:o,valueEncoding:s,...c}=e;for(let u=0;u<t.length;u++){if(typeof t[u]!="object"||t[u]===null)return this.nextTick(r,new TypeError("A batch operation must be an object")),r[m];let a=Object.assign({},t[u]);if(a.type!=="put"&&a.type!=="del")return this.nextTick(r,new TypeError("A batch operation must have a type property that is 'put' or 'del'")),r[m];let h=this._checkKey(a.key);if(h)return this.nextTick(r,h),r[m];let f=a.sublevel!=null?a.sublevel:this,l=f.keyEncoding(a.keyEncoding||o),p=l.format;if(a.key=f.prefixKey(l.encode(a.key),p),a.keyEncoding=p,a.type==="put"){let y=this._checkValue(a.value);if(y)return this.nextTick(r,y),r[m];let g=f.valueEncoding(a.valueEncoding||s);a.value=g.encode(a.value),a.valueEncoding=g.format}f!==this&&(a.sublevel=null),i[u]=a}return this._batch(i,c,u=>{if(u)return r(u);this.emit("batch",t),r()}),r[m]}_batch(t,e,r){this.nextTick(r)}sublevel(t,e){return this._sublevel(t,kn.defaults(e))}_sublevel(t,e){return new kn(this,t,e)}prefixKey(t,e){return t}clear(t,e){if(e=Mt(t,e),e=xt(e,m),t=vt(t,this[Nt].empty),this[w]==="opening")return this.defer(()=>this.clear(t,e)),e[m];if(oe(this,e))return e[m];let r=t,i=this.keyEncoding(t.keyEncoding);return t=fr(t,i),t.keyEncoding=i.format,t.limit===0?this.nextTick(e):this._clear(t,o=>{if(o)return e(o);this.emit("clear",r),e()}),e[m]}_clear(t,e){this.nextTick(e)}iterator(t){let e=this.keyEncoding(t&&t.keyEncoding),r=this.valueEncoding(t&&t.valueEncoding);if(t=fr(t,e),t.keys=t.keys!==!1,t.values=t.values!==!1,t[Lt.keyEncoding]=e,t[Lt.valueEncoding]=r,t.keyEncoding=e.format,t.valueEncoding=r.format,this[w]==="opening")return new Zc(this,t);if(this[w]!=="open")throw new $("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._iterator(t)}_iterator(t){return new Lt(this,t)}keys(t){let e=this.keyEncoding(t&&t.keyEncoding),r=this.valueEncoding(t&&t.valueEncoding);if(t=fr(t,e),t[Lt.keyEncoding]=e,t[Lt.valueEncoding]=r,t.keyEncoding=e.format,t.valueEncoding=r.format,this[w]==="opening")return new Qc(this,t);if(this[w]!=="open")throw new $("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._keys(t)}_keys(t){return new Xc(this,t)}values(t){let e=this.keyEncoding(t&&t.keyEncoding),r=this.valueEncoding(t&&t.valueEncoding);if(t=fr(t,e),t[Lt.keyEncoding]=e,t[Lt.valueEncoding]=r,t.keyEncoding=e.format,t.valueEncoding=r.format,this[w]==="opening")return new tu(this,t);if(this[w]!=="open")throw new $("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._values(t)}_values(t){return new Yc(this,t)}defer(t){if(typeof t!="function")throw new TypeError("The first argument must be a function");this[ke].push(t)}[Oe](){if(this[ke].length===0)return;let t=this[ke];this[ke]=[];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[Ft].add(t)}detachResource(t){this[Ft].delete(t)}_chainedBatch(){return new mo(this)}_checkKey(t){if(t==null)return new $("Key cannot be null or undefined",{code:"LEVEL_INVALID_KEY"})}_checkValue(t){if(t==null)return new $("Value cannot be null or undefined",{code:"LEVEL_INVALID_VALUE"})}};Ie.prototype.nextTick=ao();var{AbstractSublevel:kn}=yo()({AbstractLevel:Ie});On.AbstractLevel=Ie;On.AbstractSublevel=kn;var oe=function(n,t){return n[w]!=="open"?(n.nextTick(t,new $("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"})),!0):!1},ru=function(n){return Object.keys(n.supports.encodings).filter(t=>!!n.supports.encodings[t])}});var Cn=x(Rt=>{"use strict";Rt.AbstractLevel=In().AbstractLevel;Rt.AbstractSublevel=In().AbstractSublevel;Rt.AbstractIterator=wt().AbstractIterator;Rt.AbstractKeyIterator=wt().AbstractKeyIterator;Rt.AbstractValueIterator=wt().AbstractValueIterator;Rt.AbstractChainedBatch=xn().AbstractChainedBatch});var xo=x((Ha,go)=>{go.exports=iu;var nu=bn();function iu(n,t,e){if(typeof t!="number")throw new Error("second argument must be a Number");let r,i,o,s,c,u=!0,a;Array.isArray(n)?(r=[],o=i=n.length):(s=Object.keys(n),r={},o=i=s.length);function h(l){function p(){e&&e(l,r),e=null}u?nu(p):p()}function f(l,p,y){if(r[l]=y,p&&(c=!0),--o===0||p)h(p);else if(!c&&a<i){let g;s?(g=s[a],a+=1,n[g](function(N,A){f(g,N,A)})):(g=a,a+=1,n[g](function(N,A){f(g,N,A)}))}}a=t,o?s?s.some(function(l,p){return n[l](function(y,g){f(l,y,g)}),p===t-1}):n.some(function(l,p){return l(function(y,g){f(p,y,g)}),p===t-1}):h(null),u=!1}});var Un=x((Wa,vo)=>{"use strict";vo.exports=function(t){let e=t.gte!==void 0?t.gte:t.gt!==void 0?t.gt:void 0,r=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&&r!==void 0?IDBKeyRange.bound(e,r,i,o):e!==void 0?IDBKeyRange.lowerBound(e,i):r!==void 0?IDBKeyRange.upperBound(r,o):null}});var Pn=x((za,bo)=>{"use strict";var ou=new TextEncoder;bo.exports=function(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):ou.encode(n)}});var Bo=x(_o=>{"use strict";var{AbstractIterator:su}=Cn(),Eo=Un(),lr=Pn(),Q=Symbol("cache"),ct=Symbol("finished"),U=Symbol("options"),ut=Symbol("currentOptions"),Vt=Symbol("position"),Dn=Symbol("location"),se=Symbol("first"),To={},Ln=class extends su{constructor(t,e,r){super(t,r),this[Q]=[],this[ct]=this.limit===0,this[U]=r,this[ut]={...r},this[Vt]=void 0,this[Dn]=e,this[se]=!0}_nextv(t,e,r){if(this[se]=!1,this[ct])return this.nextTick(r,null,[]);if(this[Q].length>0)return t=Math.min(t,this[Q].length),this.nextTick(r,null,this[Q].splice(0,t));this[Vt]!==void 0&&(this[U].reverse?(this[ut].lt=this[Vt],this[ut].lte=void 0):(this[ut].gt=this[Vt],this[ut].gte=void 0));let i;try{i=Eo(this[ut])}catch{return this[ct]=!0,this.nextTick(r,null,[])}let o=this.db.db.transaction([this[Dn]],"readonly"),s=o.objectStore(this[Dn]),c=[];if(this[U].reverse){let u=!this[U].values&&s.openKeyCursor?"openKeyCursor":"openCursor";s[u](i,"prev").onsuccess=a=>{let h=a.target.result;if(h){let{key:f,value:l}=h;this[Vt]=f,c.push([this[U].keys&&f!==void 0?lr(f):void 0,this[U].values&&l!==void 0?lr(l):void 0]),c.length<t?h.continue():Ao(o)}else this[ct]=!0}}else{let u,a,h=()=>{if(u===void 0||a===void 0)return;let f=Math.max(u.length,a.length);f===0||t===1/0?this[ct]=!0:this[Vt]=u[f-1],c.length=f;for(let l=0;l<f;l++){let p=u[l],y=a[l];c[l]=[this[U].keys&&p!==void 0?lr(p):void 0,this[U].values&&y!==void 0?lr(y):void 0]}Ao(o)};this[U].keys||t<1/0?s.getAllKeys(i,t<1/0?t:void 0).onsuccess=f=>{u=f.target.result,h()}:(u=[],this.nextTick(h)),this[U].values?s.getAll(i,t<1/0?t:void 0).onsuccess=f=>{a=f.target.result,h()}:(a=[],this.nextTick(h))}o.onabort=()=>{r(o.error||new Error("aborted by user")),r=null},o.oncomplete=()=>{r(null,c),r=null}}_next(t){if(this[Q].length>0){let[e,r]=this[Q].shift();this.nextTick(t,null,e,r)}else if(this[ct])this.nextTick(t);else{let e=Math.min(100,this.limit-this.count);this[se]&&(this[se]=!1,e=1),this._nextv(e,To,(r,i)=>{if(r)return t(r);this[Q]=i,this._next(t)})}}_all(t,e){this[se]=!1;let r=this[Q].splice(0,this[Q].length),i=this.limit-this.count-r.length;if(i<=0)return this.nextTick(e,null,r);this._nextv(i,To,(o,s)=>{if(o)return e(o);r.length>0&&(s=r.concat(s)),e(null,s)})}_seek(t,e){this[se]=!0,this[Q]=[],this[ct]=!1,this[Vt]=void 0,this[ut]={...this[U]};let r;try{r=Eo(this[U])}catch{this[ct]=!0;return}r!==null&&!r.includes(t)?this[ct]=!0:this[U].reverse?this[ut].lte=t:this[ut].gte=t}};_o.Iterator=Ln;function Ao(n){typeof n.commit=="function"&&n.commit()}});var So=x((Ya,Ko)=>{"use strict";Ko.exports=function(t,e,r,i,o){if(i.limit===0)return t.nextTick(o);let s=t.db.transaction([e],"readwrite"),c=s.objectStore(e),u=0;s.oncomplete=function(){o()},s.onabort=function(){o(s.error||new Error("aborted by user"))};let a=c.openKeyCursor?"openKeyCursor":"openCursor",h=i.reverse?"prev":"next";c[a](r,h).onsuccess=function(f){let l=f.target.result;l&&(c.delete(l.key).onsuccess=function(){(i.limit<=0||++u<i.limit)&&l.continue()})}}});var Po=x(Uo=>{"use strict";var{AbstractLevel:cu}=Cn(),ko=V(),uu=xo(),{fromCallback:au}=ge(),{Iterator:fu}=Bo(),Oo=Pn(),hu=So(),du=Un(),Co="level-js-",Ce=Symbol("idb"),Mn=Symbol("namePrefix"),at=Symbol("location"),Fn=Symbol("version"),jt=Symbol("store"),Ue=Symbol("onComplete"),Io=Symbol("promise"),pr=class extends cu{constructor(t,e,r){if(typeof e=="function"||typeof r=="function")throw new ko("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[at]=t,this[Mn]=i??Co,this[Fn]=parseInt(o||1,10),this[Ce]=null}get location(){return this[at]}get namePrefix(){return this[Mn]}get version(){return this[Fn]}get db(){return this[Ce]}get type(){return"browser-level"}_open(t,e){let r=indexedDB.open(this[Mn]+this[at],this[Fn]);r.onerror=function(){e(r.error||new Error("unknown error"))},r.onsuccess=()=>{this[Ce]=r.result,e()},r.onupgradeneeded=i=>{let o=i.target.result;o.objectStoreNames.contains(this[at])||o.createObjectStore(this[at])}}[jt](t){return this[Ce].transaction([this[at]],t).objectStore(this[at])}[Ue](t,e){let r=t.transaction;r.onabort=function(){e(r.error||new Error("aborted by user"))},r.oncomplete=function(){e(null,t.result)}}_get(t,e,r){let i=this[jt]("readonly"),o;try{o=i.get(t)}catch(s){return this.nextTick(r,s)}this[Ue](o,function(s,c){if(s)return r(s);if(c===void 0)return r(new ko("Entry not found",{code:"LEVEL_NOT_FOUND"}));r(null,Oo(c))})}_getMany(t,e,r){let i=this[jt]("readonly"),o=t.map(s=>c=>{let u;try{u=i.get(s)}catch(a){return c(a)}u.onsuccess=()=>{let a=u.result;c(null,a===void 0?a:Oo(a))},u.onerror=a=>{a.stopPropagation(),c(u.error)}});uu(o,16,r)}_del(t,e,r){let i=this[jt]("readwrite"),o;try{o=i.delete(t)}catch(s){return this.nextTick(r,s)}this[Ue](o,r)}_put(t,e,r,i){let o=this[jt]("readwrite"),s;try{s=o.put(e,t)}catch(c){return this.nextTick(i,c)}this[Ue](s,i)}_iterator(t){return new fu(this,this[at],t)}_batch(t,e,r){let i=this[jt]("readwrite"),o=i.transaction,s=0,c;o.onabort=function(){r(c||o.error||new Error("aborted by user"))},o.oncomplete=function(){r()};function u(){let a=t[s++],h=a.key,f;try{f=a.type==="del"?i.delete(h):i.put(a.value,h)}catch(l){c=l,o.abort();return}s<t.length?f.onsuccess=u:typeof o.commit=="function"&&o.commit()}u()}_clear(t,e){let r,i;try{r=du(t)}catch{return this.nextTick(e)}if(t.limit>=0)return hu(this,this[at],r,t,e);try{let o=this[jt]("readwrite");i=r?o.delete(r):o.clear()}catch(o){return this.nextTick(e,o)}this[Ue](i,e)}_close(t){this[Ce].close(),this.nextTick(t)}};pr.destroy=function(n,t,e){typeof t=="function"&&(e=t,t=Co),e=au(e,Io);let r=indexedDB.deleteDatabase(t+n);return r.onsuccess=function(){e()},r.onerror=function(i){e(i)},e[Io]};Uo.BrowserLevel=pr});var Lo=x(Do=>{Do.Level=Po().BrowserLevel});var $t;(function(n){n.AlgorithmNotSupported="algorithmNotSupported",n.EncodingError="encodingError",n.InvalidJwe="invalidJwe",n.InvalidJwk="invalidJwk",n.OperationNotSupported="operationNotSupported"})($t||($t={}));var rs=Hn(zn(),1);var _u=new Uint8Array(0);function Xn(n,t){if(n===t)return!0;if(n.byteLength!==t.byteLength)return!1;for(let e=0;e<n.byteLength;e++)if(n[e]!==t[e])return!1;return!0}function qt(n){if(n instanceof Uint8Array&&n.constructor.name==="Uint8Array")return n;if(n instanceof ArrayBuffer)return new Uint8Array(n);if(ArrayBuffer.isView(n))return new Uint8Array(n.buffer,n.byteOffset,n.byteLength);throw new Error("Unknown type, must be binary type")}function is(n,t){if(n.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r<e.length;r++)e[r]=255;for(var i=0;i<n.length;i++){var o=n.charAt(i),s=o.charCodeAt(0);if(e[s]!==255)throw new TypeError(o+" is ambiguous");e[s]=i}var c=n.length,u=n.charAt(0),a=Math.log(c)/Math.log(256),h=Math.log(256)/Math.log(c);function f(y){if(y instanceof Uint8Array||(ArrayBuffer.isView(y)?y=new Uint8Array(y.buffer,y.byteOffset,y.byteLength):Array.isArray(y)&&(y=Uint8Array.from(y))),!(y instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(y.length===0)return"";for(var g=0,N=0,A=0,J=y.length;A!==J&&y[A]===0;)A++,g++;for(var G=(J-A)*h+1>>>0,D=new Uint8Array(G);A!==J;){for(var H=y[A],ft=0,R=G-1;(H!==0||ft<N)&&R!==-1;R--,ft++)H+=256*D[R]>>>0,D[R]=H%c>>>0,H=H/c>>>0;if(H!==0)throw new Error("Non-zero carry");N=ft,A++}for(var tt=G-N;tt!==G&&D[tt]===0;)tt++;for(var De=u.repeat(g);tt<G;++tt)De+=n.charAt(D[tt]);return De}function l(y){if(typeof y!="string")throw new TypeError("Expected String");if(y.length===0)return new Uint8Array;var g=0;if(y[g]!==" "){for(var N=0,A=0;y[g]===u;)N++,g++;for(var J=(y.length-g)*a+1>>>0,G=new Uint8Array(J);y[g];){var D=e[y.charCodeAt(g)];if(D===255)return;for(var H=0,ft=J-1;(D!==0||H<A)&&ft!==-1;ft--,H++)D+=c*G[ft]>>>0,G[ft]=D%256>>>0,D=D/256>>>0;if(D!==0)throw new Error("Non-zero carry");A=H,g++}if(y[g]!==" "){for(var R=J-A;R!==J&&G[R]===0;)R++;for(var tt=new Uint8Array(N+(J-R)),De=N;R!==J;)tt[De++]=G[R++];return tt}}}function p(y){var g=l(y);if(g)return g;throw new Error(`Non-${t} character`)}return{encode:f,decodeUnsafe:l,decode:p}}var os=is,ss=os,Yn=ss;var Ar=class{name;prefix;baseEncode;constructor(t,e,r){this.name=t,this.prefix=e,this.baseEncode=r}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},_r=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,r){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=r}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 Zn(this,t)}},Br=class{decoders;constructor(t){this.decoders=t}or(t){return Zn(this,t)}decode(t){let e=t[0],r=this.decoders[e];if(r!=null)return r.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Zn(n,t){return new Br({...n.decoders??{[n.prefix]:n},...t.decoders??{[t.prefix]:t}})}var Kr=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,r,i){this.name=t,this.prefix=e,this.baseEncode=r,this.baseDecode=i,this.encoder=new Ar(t,e,r),this.decoder=new _r(t,e,i)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Qn({name:n,prefix:t,encode:e,decode:r}){return new Kr(n,t,e,r)}function Sr({name:n,prefix:t,alphabet:e}){let{encode:r,decode:i}=Yn(e,n);return Qn({prefix:t,name:n,encode:r,decode:o=>qt(i(o))})}function cs(n,t,e,r){let i={};for(let h=0;h<t.length;++h)i[t[h]]=h;let o=n.length;for(;n[o-1]==="=";)--o;let s=new Uint8Array(o*e/8|0),c=0,u=0,a=0;for(let h=0;h<o;++h){let f=i[n[h]];if(f===void 0)throw new SyntaxError(`Non-${r} character`);u=u<<e|f,c+=e,c>=8&&(c-=8,s[a++]=255&u>>c)}if(c>=e||255&u<<8-c)throw new SyntaxError("Unexpected end of data");return s}function us(n,t,e){let r=t[t.length-1]==="=",i=(1<<e)-1,o="",s=0,c=0;for(let u=0;u<n.length;++u)for(c=c<<8|n[u],s+=8;s>e;)s-=e,o+=t[i&c>>s];if(s!==0&&(o+=t[i&c<<e-s]),r)for(;o.length*e&7;)o+="=";return o}function _({name:n,prefix:t,bitsPerChar:e,alphabet:r}){return Qn({prefix:t,name:n,encode(i){return us(i,r,e)},decode(i){return cs(i,r,e,n)}})}var ce=_({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Iu=_({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Cu=_({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Uu=_({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Pu=_({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Du=_({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Lu=_({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Mu=_({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),kr=_({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var K=Sr({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ru=Sr({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var $u=_({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),qu=_({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),W=_({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ju=_({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function ti(n){return n.byteOffset!==0||n.byteLength!==n.buffer.byteLength}function ei(n){return typeof n!="object"||n===null?!1:typeof n[Symbol.asyncIterator]=="function"}function Me(n){let e=Object.prototype.toString.call(n).match(/\s([a-zA-Z0-9]+)/),[r,i]=e;return i}var ue=function(n,t,e,r){function i(o){return o instanceof e?o:new e(function(s){s(o)})}return new(e||(e=Promise))(function(o,s){function c(h){try{a(r.next(h))}catch(f){s(f)}}function u(h){try{a(r.throw(h))}catch(f){s(f)}}function a(h){h.done?o(h.value):i(h.value).then(c,u)}a((r=r.apply(n,t||[])).next())})},ri=function(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=n[Symbol.asyncIterator],e;return t?t.call(n):(n=typeof __values=="function"?__values(n):n[Symbol.iterator](),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(o){e[o]=n[o]&&function(s){return new Promise(function(c,u){s=n[o](s),i(c,u,s.done,s.value)})}}function i(o,s,c,u){Promise.resolve(u).then(function(a){o({value:a,done:c})},s)}},Fe=new TextEncoder,At=new TextDecoder,v=class n{constructor(t,e){this.data=t,this.format=e}static arrayBuffer(t){return new n(t,"ArrayBuffer")}static asyncIterable(t){if(!ei(t))throw new TypeError("Input must be of type AsyncIterable.");return new n(t,"AsyncIterable")}static base32Z(t){return new n(t,"Base32Z")}static base58Btc(t){return new n(t,"Base58Btc")}static base64Url(t){return new n(t,"Base64Url")}static bufferSource(t){return new n(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 n(t,"Hex")}static multibase(t){return new n(t,"Multibase")}static object(t){return new n(t,"Object")}static string(t){return new n(t,"String")}static uint8Array(t){return new n(t,"Uint8Array")}toArrayBuffer(){switch(this.format){case"Base58Btc":return K.baseDecode(this.data).buffer;case"Base64Url":return W.baseDecode(this.data).buffer;case"BufferSource":{if(Me(this.data)==="ArrayBuffer")return this.data;if(ArrayBuffer.isView(this.data))return ti(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 ue(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 kr.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 K.baseEncode(t)}case"Multibase":return this.data.substring(1);case"Uint8Array":return K.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 W.baseEncode(t)}case"BufferSource":{let t=this.toUint8Array();return W.baseEncode(t)}case"Object":{let t=JSON.stringify(this.data),e=Fe.encode(t);return W.baseEncode(e)}case"String":{let t=Fe.encode(this.data);return W.baseEncode(t)}case"Uint8Array":return W.baseEncode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Base64Url is not supported.`)}}toBlobAsync(){return ue(this,void 0,void 0,function*(){var t,e,r,i;switch(this.format){case"AsyncIterable":{let u=[];try{for(var o=!0,s=ri(this.data),c;c=yield s.next(),t=c.done,!t;o=!0){i=c.value,o=!1;let h=i;u.push(h)}}catch(h){e={error:h}}finally{try{!o&&!t&&(r=s.return)&&(yield r.call(s))}finally{if(e)throw e.error}}return new Blob(u)}default:throw new TypeError(`Asynchronous conversion from ${this.format} to Blob is not supported.`)}})}toHex(){let t=Array.from({length:256},(e,r)=>r.toString(16).padStart(2,"0"));switch(this.format){case"ArrayBuffer":{let e=this.toUint8Array();return n.uint8Array(e).toHex()}case"Base64Url":{let e=this.toUint8Array();return n.uint8Array(e).toHex()}case"Uint8Array":{let e="";for(let r=0;r<this.data.length;r++)e+=t[this.data[r]];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=W.baseDecode(this.data),e=At.decode(t);return JSON.parse(e)}case"String":return JSON.parse(this.data);case"Uint8Array":{let t=At.decode(this.data);return JSON.parse(t)}default:throw new TypeError(`Conversion from ${this.format} to Object is not supported.`)}}toObjectAsync(){return ue(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 At.decode(this.data);case"Base64Url":{let t=W.baseDecode(this.data);return At.decode(t)}case"Object":return JSON.stringify(this.data);case"Uint8Array":return At.decode(this.data);default:throw new TypeError(`Conversion from ${this.format} to String is not supported.`)}}toStringAsync(){return ue(this,void 0,void 0,function*(){var t,e,r,i;switch(this.format){case"AsyncIterable":{let u="";try{for(var o=!0,s=ri(this.data),c;c=yield s.next(),t=c.done,!t;o=!0){i=c.value,o=!1;let a=i;typeof a=="string"?u+=a:u+=At.decode(a,{stream:!0})}}catch(a){e={error:a}}finally{try{!o&&!t&&(r=s.return)&&(yield r.call(s))}finally{if(e)throw e.error}}return u+=At.decode(void 0,{stream:!1}),u}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 kr.baseDecode(this.data);case"Base58Btc":return K.baseDecode(this.data);case"Base64Url":return W.baseDecode(this.data);case"BufferSource":{let t=Me(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 r=parseInt(this.data.substring(e,e+2),16);if(isNaN(r))throw new TypeError("Input is not a valid hexadecimal string.");t[e/2]=r}return t}case"Object":{let t=JSON.stringify(this.data);return Fe.encode(t)}case"String":return Fe.encode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Uint8Array is not supported.`)}}toUint8ArrayAsync(){return ue(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 ae;(function(n){n.Debug="debug",n.Silent="silent"})(ae||(ae={}));var Or=class{constructor(){this.logLevel=ae.Silent}setLogLevel(t){this.logLevel=t}log(t){this.info(t)}info(t){this.logLevel!==ae.Silent&&console.info(t)}error(t){this.logLevel!==ae.Silent&&console.error(t)}},as=new Or;typeof window<"u"&&(window.web5logger=as);var et={};Zo(et,{decode:()=>Jt,encodeTo:()=>_t,encodingLength:()=>Bt});var fs=oi,ni=128,hs=127,ds=~hs,ls=Math.pow(2,31);function oi(n,t,e){t=t||[],e=e||0;for(var r=e;n>=ls;)t[e++]=n&255|ni,n/=128;for(;n&ds;)t[e++]=n&255|ni,n>>>=7;return t[e]=n|0,oi.bytes=e-r+1,t}var ps=Ir,ys=128,ii=127;function Ir(n,r){var e=0,r=r||0,i=0,o=r,s,c=n.length;do{if(o>=c)throw Ir.bytes=0,new RangeError("Could not decode varint");s=n[o++],e+=i<28?(s&ii)<<i:(s&ii)*Math.pow(2,i),i+=7}while(s>=ys);return Ir.bytes=o-r,e}var ms=Math.pow(2,7),ws=Math.pow(2,14),gs=Math.pow(2,21),xs=Math.pow(2,28),vs=Math.pow(2,35),bs=Math.pow(2,42),Es=Math.pow(2,49),Ts=Math.pow(2,56),As=Math.pow(2,63),_s=function(n){return n<ms?1:n<ws?2:n<gs?3:n<xs?4:n<vs?5:n<bs?6:n<Es?7:n<Ts?8:n<As?9:10},Bs={encode:fs,decode:ps,encodingLength:_s},Ks=Bs,fe=Ks;function Jt(n,t=0){return[fe.decode(n,t),fe.decode.bytes]}function _t(n,t,e=0){return fe.encode(n,t,e),t}function Bt(n){return fe.encodingLength(n)}function Cr(n,t){let e=t.byteLength,r=Bt(n),i=r+Bt(e),o=new Uint8Array(i+e);return _t(n,o,0),_t(e,o,r),o.set(t,i),new Gt(n,e,t,o)}function si(n){let t=qt(n),[e,r]=Jt(t),[i,o]=Jt(t.subarray(r)),s=t.subarray(r+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new Gt(e,i,s,t)}function ci(n,t){if(n===t)return!0;{let e=t;return n.code===e.code&&n.size===e.size&&e.bytes instanceof Uint8Array&&Xn(n.bytes,e.bytes)}}var Gt=class{code;size;digest;bytes;constructor(t,e,r,i){this.code=t,this.size=e,this.digest=r,this.bytes=i}};function ui(n,t){let{bytes:e,version:r}=n;switch(r){case 0:return ks(e,Pr(n),t??K.encoder);default:return Os(e,Pr(n),t??ce.encoder)}}var ai=new WeakMap;function Pr(n){let t=ai.get(n);if(t==null){let e=new Map;return ai.set(n,e),e}return t}var Dr=class n{code;version;multihash;bytes;"/";constructor(t,e,r,i){this.code=e,this.version=t,this.multihash=r,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!==he)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Is)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return n.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,r=Cr(t,e);return n.createV1(this.code,r)}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 n.equals(this,t)}static equals(t,e){let r=e;return r!=null&&t.code===r.code&&t.version===r.version&&ci(t.multihash,r.multihash)}toString(t){return ui(this,t)}toJSON(){return{"/":ui(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 n)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:r,code:i,multihash:o,bytes:s}=e;return new n(r,i,o,s??fi(r,i,o.bytes))}else if(e[Cs]===!0){let{version:r,multihash:i,code:o}=e,s=si(i);return n.create(r,o,s)}else return null}static create(t,e,r){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(r.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==he)throw new Error(`Version 0 CID must use dag-pb (code: ${he}) block encoding`);return new n(t,e,r,r.bytes)}case 1:{let i=fi(t,e,r.bytes);return new n(t,e,r,i)}default:throw new Error("Invalid version")}}static createV0(t){return n.create(0,he,t)}static createV1(t,e){return n.create(1,t,e)}static decode(t){let[e,r]=n.decodeFirst(t);if(r.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=n.inspectBytes(t),r=e.size-e.multihashSize,i=qt(t.subarray(r,r+e.multihashSize));if(i.byteLength!==e.multihashSize)throw new Error("Incorrect length");let o=i.subarray(e.multihashSize-e.digestSize),s=new Gt(e.multihashCode,e.digestSize,o,i);return[e.version===0?n.createV0(s):n.createV1(e.codec,s),t.subarray(e.size)]}static inspectBytes(t){let e=0,r=()=>{let[f,l]=Jt(t.subarray(e));return e+=l,f},i=r(),o=he;if(i===18?(i=0,e=0):o=r(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let s=e,c=r(),u=r(),a=e+u,h=a-s;return{version:i,codec:o,multihashCode:c,digestSize:u,multihashSize:h,size:a}}static parse(t,e){let[r,i]=Ss(t,e),o=n.decode(i);if(o.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Pr(o).set(r,t),o}};function Ss(n,t){switch(n[0]){case"Q":{let e=t??K;return[K.prefix,e.decode(`${K.prefix}${n}`)]}case K.prefix:{let e=t??K;return[K.prefix,e.decode(n)]}case ce.prefix:{let e=t??ce;return[ce.prefix,e.decode(n)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[n[0],t.decode(n)]}}}function ks(n,t,e){let{prefix:r}=e;if(r!==K.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let i=t.get(r);if(i==null){let o=e.encode(n).slice(1);return t.set(r,o),o}else return i}function Os(n,t,e){let{prefix:r}=e,i=t.get(r);if(i==null){let o=e.encode(n);return t.set(r,o),o}else return i}var he=112,Is=18;function fi(n,t,e){let r=Bt(n),i=r+Bt(t),o=new Uint8Array(i+e.byteLength);return _t(n,o,0),_t(t,o,r),o.set(e,i),o}var Cs=Symbol.for("@ipld/js-cid/CID");var O=class n{static addPrefix(t){var e;let{code:r,data:i,name:o}=t;if(!(o?!r:r))throw new Error("Either 'name' or 'code' must be defined, but not both.");if(r=n.codeToName.has(r)?r:n.nameToCode.get(o),r===void 0)throw new Error(`Unsupported multicodec: ${(e=t.name)!==null&&e!==void 0?e:t.code}`);let s=et.encodingLength(r),c=new Uint8Array(s+i.byteLength);return c.set(i,s),et.encodeTo(r,c),c}static getCodeFromData(t){let{prefixedData:e}=t,[r,i]=et.decode(e);return r}static getCodeFromName(t){let{name:e}=t,r=n.nameToCode.get(e);if(r===void 0)throw new Error(`Unsupported multicodec: ${e}`);return r}static getNameFromCode(t){let{code:e}=t,r=n.codeToName.get(e);if(r===void 0)throw new Error(`Unsupported multicodec: ${e}`);return r}static registerCodec(t){n.codeToName.set(t.code,t.name),n.nameToCode.set(t.name,t.code)}static removePrefix(t){let{prefixedData:e}=t,[r,i]=et.decode(e),o=n.codeToName.get(r);if(o===void 0)throw new Error(`Unsupported multicodec: ${r}`);return{code:r,data:e.slice(i),name:o}}};O.codeToName=new Map;O.nameToCode=new Map;O.registerCodec({code:237,name:"ed25519-pub"});O.registerCodec({code:4864,name:"ed25519-priv"});O.registerCodec({code:236,name:"x25519-pub"});O.registerCodec({code:4866,name:"x25519-priv"});O.registerCodec({code:231,name:"secp256k1-pub"});O.registerCodec({code:4865,name:"secp256k1-priv"});function Lr(n){Object.keys(n).forEach(t=>{n[t]===void 0?delete n[t]:typeof n[t]=="object"&&Lr(n[t])})}var lu=Hn(Lo(),1);function pu(n){return n instanceof Uint8Array||n!=null&&typeof n=="object"&&n.constructor.name==="Uint8Array"}function Nn(n,...t){if(!pu(n))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(n.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${n.length}`)}function Rn(n,t=!0){if(n.destroyed)throw new Error("Hash instance has been destroyed");if(t&&n.finished)throw new Error("Hash#digest() has already been called")}function Mo(n,t){Nn(n);let e=t.outputLen;if(n.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}var mr=n=>new DataView(n.buffer,n.byteOffset,n.byteLength),q=(n,t)=>n<<32-t|n>>>t;var mf=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function yu(n){if(typeof n!="string")throw new Error(`utf8ToBytes expected string, got ${typeof n}`);return new Uint8Array(new TextEncoder().encode(n))}function Vn(n){return typeof n=="string"&&(n=yu(n)),Nn(n),n}var yr=class{clone(){return this._cloneInto()}},wf={}.toString;function Fo(n){let t=r=>n().update(Vn(r)).digest(),e=n();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>n(),t}function mu(n,t,e,r){if(typeof n.setBigUint64=="function")return n.setBigUint64(t,e,r);let i=BigInt(32),o=BigInt(4294967295),s=Number(e>>i&o),c=Number(e&o),u=r?4:0,a=r?0:4;n.setUint32(t+u,s,r),n.setUint32(t+a,c,r)}var No=(n,t,e)=>n&t^~n&e,Ro=(n,t,e)=>n&t^n&e^t&e,wr=class extends yr{constructor(t,e,r,i){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=mr(this.buffer)}update(t){Rn(this);let{view:e,buffer:r,blockLen:i}=this;t=Vn(t);let o=t.length;for(let s=0;s<o;){let c=Math.min(i-this.pos,o-s);if(c===i){let u=mr(t);for(;i<=o-s;s+=i)this.process(u,s);continue}r.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){Rn(this),Mo(t,this),this.finished=!0;let{buffer:e,view:r,blockLen:i,isLE:o}=this,{pos:s}=this;e[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(r,0),s=0);for(let f=s;f<i;f++)e[f]=0;mu(r,i-8,BigInt(this.length*8),o),this.process(r,0);let c=mr(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let a=u/4,h=this.get();if(a>h.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<a;f++)c.setUint32(4*f,h[f],o)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:r,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(r),t}};var wu=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]),bt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Et=new Uint32Array(64),jn=class extends wr{constructor(){super(64,32,8,!1),this.A=bt[0]|0,this.B=bt[1]|0,this.C=bt[2]|0,this.D=bt[3]|0,this.E=bt[4]|0,this.F=bt[5]|0,this.G=bt[6]|0,this.H=bt[7]|0}get(){let{A:t,B:e,C:r,D:i,E:o,F:s,G:c,H:u}=this;return[t,e,r,i,o,s,c,u]}set(t,e,r,i,o,s,c,u){this.A=t|0,this.B=e|0,this.C=r|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=c|0,this.H=u|0}process(t,e){for(let f=0;f<16;f++,e+=4)Et[f]=t.getUint32(e,!1);for(let f=16;f<64;f++){let l=Et[f-15],p=Et[f-2],y=q(l,7)^q(l,18)^l>>>3,g=q(p,17)^q(p,19)^p>>>10;Et[f]=g+Et[f-7]+y+Et[f-16]|0}let{A:r,B:i,C:o,D:s,E:c,F:u,G:a,H:h}=this;for(let f=0;f<64;f++){let l=q(c,6)^q(c,11)^q(c,25),p=h+l+No(c,u,a)+wu[f]+Et[f]|0,g=(q(r,2)^q(r,13)^q(r,22))+Ro(r,i,o)|0;h=a,a=u,u=c,c=s+p|0,s=o,o=i,i=r,r=p+g|0}r=r+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,c=c+this.E|0,u=u+this.F|0,a=a+this.G|0,h=h+this.H|0,this.set(r,i,o,s,c,u,a,h)}roundClean(){Et.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Vo=Fo(()=>new jn);function jo(n){let t=r=>{if(r!==null&&typeof r=="object"&&!Array.isArray(r)){let i=Object.keys(r).sort(),o={};for(let s of i)o[s]=t(r[s]);return o}return r},e=t(n);return JSON.stringify(e)}var gu=function(n,t,e,r){function i(o){return o instanceof e?o:new e(function(s){s(o)})}return new(e||(e=Promise))(function(o,s){function c(h){try{a(r.next(h))}catch(f){s(f)}}function u(h){try{a(r.throw(h))}catch(f){s(f)}}function a(h){h.done?o(h.value):i(h.value).then(c,u)}a((r=r.apply(n,t||[])).next())})},Pe=class{static digest(t){return gu(this,arguments,void 0,function*({data:e}){return Vo(e)})}};var xu=function(n,t,e,r){function i(o){return o instanceof e?o:new e(function(s){s(o)})}return new(e||(e=Promise))(function(o,s){function c(h){try{a(r.next(h))}catch(f){s(f)}}function u(h){try{a(r.throw(h))}catch(f){s(f)}}function a(h){h.done?o(h.value):i(h.value).then(c,u)}a((r=r.apply(n,t||[])).next())})};function P(n){return xu(this,arguments,void 0,function*({jwk:t}){let e=t.kty,r;if(e==="EC")r={crv:t.crv,kty:t.kty,x:t.x,y:t.y};else if(e==="oct")r={k:t.k,kty:t.kty};else if(e==="OKP")r={crv:t.crv,kty:t.kty,x:t.x};else if(e==="RSA")r={e:t.e,kty:t.kty,n:t.n};else throw new Error(`Unsupported key type: ${e}`);Lr(r);let i=jo(r),o=v.string(i).toUint8Array(),s=yield Pe.digest({data:o});return v.uint8Array(s).toBase64Url()})}var xr=(o=>(o.authentication="authentication",o.assertionMethod="assertionMethod",o.keyAgreement="keyAgreement",o.capabilityInvocation="capabilityInvocation",o.capabilityDelegation="capabilityDelegation",o))(xr||{});var vr=class n extends Error{constructor(e,r){super(`${e}: ${r}`);this.code=e;this.name="DidError",Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,n)}};function Jn(n){if(typeof n=="string"&&n.length!==0)return n.split("#").pop()}function rl({didDocument:n,id:t,type:e}){return n?.service?.filter(r=>!(t&&r.id!==t||e&&r.type!==e))??[]}async function nl({didDocument:n,publicKeyJwk:t,publicKeyMultibase:e}){let r=Go({didDocument:n});for(let i of r)if(t&&i.publicKeyJwk){if(await P({jwk:t})===await P({jwk:i.publicKeyJwk}))return i}else if(e&&i.publicKeyMultibase&&e===i.publicKeyMultibase)return i;return null}function Go({didDocument:n}){if(!n)throw new TypeError("Required parameter missing: 'didDocument'");let t=[];return t.push(...n.verificationMethod?.filter(Gn)??[]),Object.keys(xr).forEach(e=>{t.push(...n[e]?.filter(Gn)??[])}),t}function il({didDocument:n}){let e=Go({didDocument:n}).map(r=>r.type);return[...new Set(e)]}function ol({didDocument:n,methodId:t}){let e=[];return Object.keys(xr).forEach(r=>{if(Array.isArray(n[r])){let i=n[r],o=Jn(t);i.some(c=>{let u=Jn(c)===o,a=Gn(c)&&Jn(c.id)===o;return u||a})&&e.push(r)}}),e}function vu(n){return!n||typeof n!="object"||n===null?!1:"id"in n&&"type"in n&&"serviceEndpoint"in n}function sl(n){if(!vu(n)||n.type!=="DecentralizedWebNode"||!("enc"in n&&"sig"in n))return!1;let t=e=>typeof e=="string"||Array.isArray(e)&&e.every(r=>typeof r=="string");return t(n.enc)&&t(n.sig)}function Gn(n){return!(!n||typeof n!="object"||n===null||!("id"in n&&"type"in n&&"controller"in n)||typeof n.id!="string"||typeof n.type!="string"||typeof n.controller!="string")}function cl(n){return!(!n||typeof n!="object"||n===null)&&"uri"in n&&"document"in n&&"metadata"in n&&(!("keyManager"in n)||n.keyManager===void 0)}function ul({keyBytes:n,multicodecCode:t,multicodecName:e}){let r=O.addPrefix({code:t,data:n,name:e}),i=v.uint8Array(r).toBase58Btc();return v.base58Btc(i).toMultibase()}function al({multibaseKeyId:n}){try{let t=v.multibase(n).toBase58Btc(),e=v.base58Btc(t).toUint8Array(),{code:r,data:i,name:o}=O.removePrefix({prefixedData:e});return{keyBytes:i,multicodecCode:r,multicodecName:o}}catch{throw new vr("invalidDid",`Invalid multibase identifier: ${n}`)}}export{Jn as extractDidFragment,rl as getServices,nl as getVerificationMethodByKey,il as getVerificationMethodTypes,Go as getVerificationMethods,ol as getVerificationRelationshipsById,vu as isDidService,Gn as isDidVerificationMethod,sl as isDwnDidService,cl as isPortableDid,ul as keyBytesToMultibaseId,al as multibaseIdToKeyBytes};
|
|
1
|
+
var tu=Object.create;var hn=Object.defineProperty;var ru=Object.getOwnPropertyDescriptor;var nu=Object.getOwnPropertyNames;var iu=Object.getPrototypeOf,ou=Object.prototype.hasOwnProperty;var E=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),su=(r,e)=>{for(var t in e)hn(r,t,{get:e[t],enumerable:!0})},cu=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of nu(e))!ou.call(r,i)&&i!==t&&hn(r,i,{get:()=>e[i],enumerable:!(n=ru(e,i))||n.enumerable});return r};var Ji=(r,e,t)=>(t=r!=null?tu(iu(r)):{},cu(e||!r||!r.__esModule?hn(t,"default",{value:r,enumerable:!0}):t,r));var zi=E((sd,Gi)=>{var uu=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,lr=()=>uu.now(),au=r=>r&&r===Math.floor(r)&&r>0&&isFinite(r),ln=r=>r===1/0||au(r),pn=class r{constructor({max:e=1/0,ttl:t,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,t!==void 0&&!ln(t))throw new TypeError("ttl must be positive integer or Infinity if set");if(!ln(e))throw new TypeError("max must be positive integer or Infinity");if(this.ttl=t,this.max=e,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(e,t){if(this.timerExpiration<e)return;this.timer&&clearTimeout(this.timer);let n=setTimeout(()=>{this.timer=void 0,this.timerExpiration=void 0,this.purgeStale();for(let i in this.expirations){this.setTimer(i,i-lr());break}},t);n.unref&&n.unref(),this.timerExpiration=e,this.timer=n}cancelTimer(){this.timer&&(clearTimeout(this.timer),this.timerExpiration=void 0,this.timer=void 0)}cancelTimers(){return process.emitWarning('TTLCache.cancelTimers has been renamed to TTLCache.cancelTimer (no "s"), and will be removed in the next major version update'),this.cancelTimer()}clear(){let e=this.dispose!==r.prototype.dispose?[...this]:[];this.data.clear(),this.expirationMap.clear(),this.cancelTimer(),this.expirations=Object.create(null);for(let[t,n]of e)this.dispose(n,t,"delete")}setTTL(e,t=this.ttl){let n=this.expirationMap.get(e);if(n!==void 0){let i=this.expirations[n];!i||i.length<=1?delete this.expirations[n]:this.expirations[n]=i.filter(o=>o!==e)}if(t!==1/0){let i=Math.floor(lr()+t);this.expirationMap.set(e,i),this.expirations[i]||(this.expirations[i]=[],this.setTimer(i,t)),this.expirations[i].push(e)}else this.expirationMap.set(e,1/0)}set(e,t,{ttl:n=this.ttl,noUpdateTTL:i=this.noUpdateTTL,noDisposeOnSet:o=this.noDisposeOnSet}={}){if(!ln(n))throw new TypeError("ttl must be positive integer or Infinity");if(this.expirationMap.has(e)){i||this.setTTL(e,n);let s=this.data.get(e);s!==t&&(this.data.set(e,t),o||this.dispose(s,e,"set"))}else this.setTTL(e,n),this.data.set(e,t);for(;this.size>this.max;)this.purgeToCapacity();return this}has(e){return this.data.has(e)}getRemainingTTL(e){let t=this.expirationMap.get(e);return t===1/0?t:t!==void 0?Math.max(0,Math.ceil(t-lr())):0}get(e,{updateAgeOnGet:t=this.updateAgeOnGet,ttl:n=this.ttl,checkAgeOnGet:i=this.checkAgeOnGet}={}){let o=this.data.get(e);if(i&&this.getRemainingTTL(e)===0){this.delete(e);return}return t&&this.setTTL(e,n),o}dispose(e,t){}delete(e){let t=this.expirationMap.get(e);if(t!==void 0){let n=this.data.get(e);this.data.delete(e),this.expirationMap.delete(e);let i=this.expirations[t];return i&&(i.length<=1?delete this.expirations[t]:this.expirations[t]=i.filter(o=>o!==e)),this.dispose(n,e,"delete"),this.size===0&&this.cancelTimer(),!0}return!1}purgeToCapacity(){for(let e in this.expirations){let t=this.expirations[e];if(this.size-t.length>=this.max){delete this.expirations[e];let n=[];for(let i of t)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 t.splice(0,n))i.push([o,this.data.get(o)]),this.data.delete(o),this.expirationMap.delete(o);for(let[o,s]of i)this.dispose(s,o,"evict");return}}}get size(){return this.data.size}purgeStale(){let e=Math.ceil(lr());for(let t in this.expirations){if(t==="Infinity"||t>e)return;let n=[...this.expirations[t]||[]],i=[];delete this.expirations[t];for(let o of n)i.push([o,this.data.get(o)]),this.data.delete(o),this.expirationMap.delete(o);for(let[o,s]of i)this.dispose(s,o,"stale")}this.size===0&&this.cancelTimer()}*entries(){for(let e in this.expirations)for(let t of this.expirations[e])yield[t,this.data.get(t)]}*keys(){for(let e in this.expirations)for(let t of this.expirations[e])yield t}*values(){for(let e in this.expirations)for(let t of this.expirations[e])yield this.data.get(t)}[Symbol.iterator](){return this.entries()}};Gi.exports=pn});var ho=E(fo=>{"use strict";fo.supports=function(...e){let t=e.reduce((n,i)=>Object.assign(n,i),{});return Object.assign(t,{snapshots:t.snapshots||!1,permanence:t.permanence||!1,seek:t.seek||!1,clear:t.clear||!1,getMany:t.getMany||!1,keyIterator:t.keyIterator||!1,valueIterator:t.valueIterator||!1,iteratorNextv:t.iteratorNextv||!1,iteratorAll:t.iteratorAll||!1,status:t.status||!1,createIfMissing:t.createIfMissing||!1,errorIfExists:t.errorIfExists||!1,deferredOpen:t.deferredOpen||!1,promises:t.promises||!1,streams:t.streams||!1,encodings:Object.assign({},t.encodings),events:Object.assign({},t.events),additionalMethods:Object.assign({},t.additionalMethods)})}});var re=E((ih,lo)=>{"use strict";lo.exports=class extends Error{constructor(e,t){super(e||""),typeof t=="object"&&t!==null&&(t.code&&(this.code=String(t.code)),t.expected&&(this.expected=!0),t.transient&&(this.transient=!0),t.cause&&(this.cause=t.cause)),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}}});var mo=E(mr=>{"use strict";mr.byteLength=ju;mr.toByteArray=Hu;mr.fromByteArray=zu;var de=[],W=[],Vu=typeof Uint8Array<"u"?Uint8Array:Array,kn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(We=0,po=kn.length;We<po;++We)de[We]=kn[We],W[kn.charCodeAt(We)]=We;var We,po;W[45]=62;W[95]=63;function yo(r){var e=r.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=r.indexOf("=");t===-1&&(t=e);var n=t===e?0:4-t%4;return[t,n]}function ju(r){var e=yo(r),t=e[0],n=e[1];return(t+n)*3/4-n}function qu(r,e,t){return(e+t)*3/4-t}function Hu(r){var e,t=yo(r),n=t[0],i=t[1],o=new Vu(qu(r,n,i)),s=0,c=i>0?n-4:n,u;for(u=0;u<c;u+=4)e=W[r.charCodeAt(u)]<<18|W[r.charCodeAt(u+1)]<<12|W[r.charCodeAt(u+2)]<<6|W[r.charCodeAt(u+3)],o[s++]=e>>16&255,o[s++]=e>>8&255,o[s++]=e&255;return i===2&&(e=W[r.charCodeAt(u)]<<2|W[r.charCodeAt(u+1)]>>4,o[s++]=e&255),i===1&&(e=W[r.charCodeAt(u)]<<10|W[r.charCodeAt(u+1)]<<4|W[r.charCodeAt(u+2)]>>2,o[s++]=e>>8&255,o[s++]=e&255),o}function Ju(r){return de[r>>18&63]+de[r>>12&63]+de[r>>6&63]+de[r&63]}function Gu(r,e,t){for(var n,i=[],o=e;o<t;o+=3)n=(r[o]<<16&16711680)+(r[o+1]<<8&65280)+(r[o+2]&255),i.push(Ju(n));return i.join("")}function zu(r){for(var e,t=r.length,n=t%3,i=[],o=16383,s=0,c=t-n;s<c;s+=o)i.push(Gu(r,s,s+o>c?c:s+o));return n===1?(e=r[t-1],i.push(de[e>>2]+de[e<<4&63]+"==")):n===2&&(e=(r[t-2]<<8)+r[t-1],i.push(de[e>>10]+de[e>>4&63]+de[e<<2&63]+"=")),i.join("")}});var go=E(In=>{In.read=function(r,e,t,n,i){var o,s,c=i*8-n-1,u=(1<<c)-1,a=u>>1,d=-7,f=t?i-1:0,m=t?-1:1,g=r[e+f];for(f+=m,o=g&(1<<-d)-1,g>>=-d,d+=c;d>0;o=o*256+r[e+f],f+=m,d-=8);for(s=o&(1<<-d)-1,o>>=-d,d+=n;d>0;s=s*256+r[e+f],f+=m,d-=8);if(o===0)o=1-a;else{if(o===u)return s?NaN:(g?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-a}return(g?-1:1)*s*Math.pow(2,o-n)};In.write=function(r,e,t,n,i,o){var s,c,u,a=o*8-i-1,d=(1<<a)-1,f=d>>1,m=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,g=n?0:o-1,w=n?1:-1,b=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(c=isNaN(e)?1:0,s=d):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),s+f>=1?e+=m/u:e+=m*Math.pow(2,1-f),e*u>=2&&(s++,u/=2),s+f>=d?(c=0,s=d):s+f>=1?(c=(e*u-1)*Math.pow(2,i),s=s+f):(c=e*Math.pow(2,f-1)*Math.pow(2,i),s=0));i>=8;r[t+g]=c&255,g+=w,c/=256,i-=8);for(s=s<<i|c,a+=i;a>0;r[t+g]=s&255,g+=w,s/=256,a-=8);r[t+g-w]|=b*128}});var xr=E(wt=>{"use strict";var Un=mo(),mt=go(),wo=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;wt.Buffer=l;wt.SlowBuffer=ea;wt.INSPECT_MAX_BYTES=50;var gr=2147483647;wt.kMaxLength=gr;l.TYPED_ARRAY_SUPPORT=Wu();!l.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 Wu(){try{let r=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(r,e),r.foo()===42}catch{return!1}}Object.defineProperty(l.prototype,"parent",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.buffer}});Object.defineProperty(l.prototype,"offset",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.byteOffset}});function be(r){if(r>gr)throw new RangeError('The value "'+r+'" is invalid for option "size"');let e=new Uint8Array(r);return Object.setPrototypeOf(e,l.prototype),e}function l(r,e,t){if(typeof r=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Pn(r)}return Eo(r,e,t)}l.poolSize=8192;function Eo(r,e,t){if(typeof r=="string")return Yu(r,e);if(ArrayBuffer.isView(r))return Zu(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(he(r,ArrayBuffer)||r&&he(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(he(r,SharedArrayBuffer)||r&&he(r.buffer,SharedArrayBuffer)))return Kn(r,e,t);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 l.from(n,e,t);let i=Qu(r);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return l.from(r[Symbol.toPrimitive]("string"),e,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}l.from=function(r,e,t){return Eo(r,e,t)};Object.setPrototypeOf(l.prototype,Uint8Array.prototype);Object.setPrototypeOf(l,Uint8Array);function Ao(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,e,t){return Ao(r),r<=0?be(r):e!==void 0?typeof t=="string"?be(r).fill(e,t):be(r).fill(e):be(r)}l.alloc=function(r,e,t){return Xu(r,e,t)};function Pn(r){return Ao(r),be(r<0?0:Dn(r)|0)}l.allocUnsafe=function(r){return Pn(r)};l.allocUnsafeSlow=function(r){return Pn(r)};function Yu(r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!l.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let t=_o(r,e)|0,n=be(t),i=n.write(r,e);return i!==t&&(n=n.slice(0,i)),n}function On(r){let e=r.length<0?0:Dn(r.length)|0,t=be(e);for(let n=0;n<e;n+=1)t[n]=r[n]&255;return t}function Zu(r){if(he(r,Uint8Array)){let e=new Uint8Array(r);return Kn(e.buffer,e.byteOffset,e.byteLength)}return On(r)}function Kn(r,e,t){if(e<0||r.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<e+(t||0))throw new RangeError('"length" is outside of buffer bounds');let n;return e===void 0&&t===void 0?n=new Uint8Array(r):t===void 0?n=new Uint8Array(r,e):n=new Uint8Array(r,e,t),Object.setPrototypeOf(n,l.prototype),n}function Qu(r){if(l.isBuffer(r)){let e=Dn(r.length)|0,t=be(e);return t.length===0||r.copy(t,0,0,e),t}if(r.length!==void 0)return typeof r.length!="number"||Nn(r.length)?be(0):On(r);if(r.type==="Buffer"&&Array.isArray(r.data))return On(r.data)}function Dn(r){if(r>=gr)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+gr.toString(16)+" bytes");return r|0}function ea(r){return+r!=r&&(r=0),l.alloc(+r)}l.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==l.prototype};l.compare=function(e,t){if(he(e,Uint8Array)&&(e=l.from(e,e.offset,e.byteLength)),he(t,Uint8Array)&&(t=l.from(t,t.offset,t.byteLength)),!l.isBuffer(e)||!l.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let n=e.length,i=t.length;for(let o=0,s=Math.min(n,i);o<s;++o)if(e[o]!==t[o]){n=e[o],i=t[o];break}return n<i?-1:i<n?1:0};l.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};l.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return l.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;let i=l.allocUnsafe(t),o=0;for(n=0;n<e.length;++n){let s=e[n];if(he(s,Uint8Array))o+s.length>i.length?(l.isBuffer(s)||(s=l.from(s)),s.copy(i,o)):Uint8Array.prototype.set.call(i,s,o);else if(l.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function _o(r,e){if(l.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||he(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 t=r.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&t===0)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return Cn(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return Co(r).length;default:if(i)return n?-1:Cn(r).length;e=(""+e).toLowerCase(),i=!0}}l.byteLength=_o;function ta(r,e,t){let n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,e>>>=0,t<=e))return"";for(r||(r="utf8");;)switch(r){case"hex":return da(this,e,t);case"utf8":case"utf-8":return Bo(this,e,t);case"ascii":return aa(this,e,t);case"latin1":case"binary":return fa(this,e,t);case"base64":return ca(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ha(this,e,t);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}l.prototype._isBuffer=!0;function Xe(r,e,t){let n=r[e];r[e]=r[t],r[t]=n}l.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)Xe(this,t,t+1);return this};l.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)Xe(this,t,t+3),Xe(this,t+1,t+2);return this};l.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)Xe(this,t,t+7),Xe(this,t+1,t+6),Xe(this,t+2,t+5),Xe(this,t+3,t+4);return this};l.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?Bo(this,0,e):ta.apply(this,arguments)};l.prototype.toLocaleString=l.prototype.toString;l.prototype.equals=function(e){if(!l.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:l.compare(this,e)===0};l.prototype.inspect=function(){let e="",t=wt.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"};wo&&(l.prototype[wo]=l.prototype.inspect);l.prototype.compare=function(e,t,n,i,o){if(he(e,Uint8Array)&&(e=l.from(e,e.offset,e.byteLength)),!l.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(t===void 0&&(t=0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),t<0||n>e.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&t>=n)return 0;if(i>=o)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,i>>>=0,o>>>=0,this===e)return 0;let s=o-i,c=n-t,u=Math.min(s,c),a=this.slice(i,o),d=e.slice(t,n);for(let f=0;f<u;++f)if(a[f]!==d[f]){s=a[f],c=d[f];break}return s<c?-1:c<s?1:0};function To(r,e,t,n,i){if(r.length===0)return-1;if(typeof t=="string"?(n=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,Nn(t)&&(t=i?0:r.length-1),t<0&&(t=r.length+t),t>=r.length){if(i)return-1;t=r.length-1}else if(t<0)if(i)t=0;else return-1;if(typeof e=="string"&&(e=l.from(e,n)),l.isBuffer(e))return e.length===0?-1:xo(r,e,t,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(r,e,t):Uint8Array.prototype.lastIndexOf.call(r,e,t):xo(r,[e],t,n,i);throw new TypeError("val must be string, number or Buffer")}function xo(r,e,t,n,i){let o=1,s=r.length,c=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(r.length<2||e.length<2)return-1;o=2,s/=2,c/=2,t/=2}function u(d,f){return o===1?d[f]:d.readUInt16BE(f*o)}let a;if(i){let d=-1;for(a=t;a<s;a++)if(u(r,a)===u(e,d===-1?0:a-d)){if(d===-1&&(d=a),a-d+1===c)return d*o}else d!==-1&&(a-=a-d),d=-1}else for(t+c>s&&(t=s-c),a=t;a>=0;a--){let d=!0;for(let f=0;f<c;f++)if(u(r,a+f)!==u(e,f)){d=!1;break}if(d)return a}return-1}l.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1};l.prototype.indexOf=function(e,t,n){return To(this,e,t,n,!0)};l.prototype.lastIndexOf=function(e,t,n){return To(this,e,t,n,!1)};function ra(r,e,t,n){t=Number(t)||0;let i=r.length-t;n?(n=Number(n),n>i&&(n=i)):n=i;let o=e.length;n>o/2&&(n=o/2);let s;for(s=0;s<n;++s){let c=parseInt(e.substr(s*2,2),16);if(Nn(c))return s;r[t+s]=c}return s}function na(r,e,t,n){return wr(Cn(e,r.length-t),r,t,n)}function ia(r,e,t,n){return wr(ma(e),r,t,n)}function oa(r,e,t,n){return wr(Co(e),r,t,n)}function sa(r,e,t,n){return wr(ga(e,r.length-t),r,t,n)}l.prototype.write=function(e,t,n,i){if(t===void 0)i="utf8",n=this.length,t=0;else if(n===void 0&&typeof t=="string")i=t,n=this.length,t=0;else if(isFinite(t))t=t>>>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-t;if((n===void 0||n>o)&&(n=o),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let s=!1;for(;;)switch(i){case"hex":return ra(this,e,t,n);case"utf8":case"utf-8":return na(this,e,t,n);case"ascii":case"latin1":case"binary":return ia(this,e,t,n);case"base64":return oa(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return sa(this,e,t,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ca(r,e,t){return e===0&&t===r.length?Un.fromByteArray(r):Un.fromByteArray(r.slice(e,t))}function Bo(r,e,t){t=Math.min(r.length,t);let n=[],i=e;for(;i<t;){let o=r[i],s=null,c=o>239?4:o>223?3:o>191?2:1;if(i+c<=t){let u,a,d,f;switch(c){case 1:o<128&&(s=o);break;case 2:u=r[i+1],(u&192)===128&&(f=(o&31)<<6|u&63,f>127&&(s=f));break;case 3:u=r[i+1],a=r[i+2],(u&192)===128&&(a&192)===128&&(f=(o&15)<<12|(u&63)<<6|a&63,f>2047&&(f<55296||f>57343)&&(s=f));break;case 4:u=r[i+1],a=r[i+2],d=r[i+3],(u&192)===128&&(a&192)===128&&(d&192)===128&&(f=(o&15)<<18|(u&63)<<12|(a&63)<<6|d&63,f>65535&&f<1114112&&(s=f))}}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 ua(n)}var vo=4096;function ua(r){let e=r.length;if(e<=vo)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=vo));return t}function aa(r,e,t){let n="";t=Math.min(r.length,t);for(let i=e;i<t;++i)n+=String.fromCharCode(r[i]&127);return n}function fa(r,e,t){let n="";t=Math.min(r.length,t);for(let i=e;i<t;++i)n+=String.fromCharCode(r[i]);return n}function da(r,e,t){let n=r.length;(!e||e<0)&&(e=0),(!t||t<0||t>n)&&(t=n);let i="";for(let o=e;o<t;++o)i+=wa[r[o]];return i}function ha(r,e,t){let n=r.slice(e,t),i="";for(let o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}l.prototype.slice=function(e,t){let n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);let i=this.subarray(e,t);return Object.setPrototypeOf(i,l.prototype),i};function B(r,e,t){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+e>t)throw new RangeError("Trying to access beyond buffer length")}l.prototype.readUintLE=l.prototype.readUIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||B(e,t,this.length);let i=this[e],o=1,s=0;for(;++s<t&&(o*=256);)i+=this[e+s]*o;return i};l.prototype.readUintBE=l.prototype.readUIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||B(e,t,this.length);let i=this[e+--t],o=1;for(;t>0&&(o*=256);)i+=this[e+--t]*o;return i};l.prototype.readUint8=l.prototype.readUInt8=function(e,t){return e=e>>>0,t||B(e,1,this.length),this[e]};l.prototype.readUint16LE=l.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||B(e,2,this.length),this[e]|this[e+1]<<8};l.prototype.readUint16BE=l.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||B(e,2,this.length),this[e]<<8|this[e+1]};l.prototype.readUint32LE=l.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||B(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};l.prototype.readUint32BE=l.prototype.readUInt32BE=function(e,t){return e=e>>>0,t||B(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};l.prototype.readBigUInt64LE=Oe(function(e){e=e>>>0,gt(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Lt(e,this.length-8);let i=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,o=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(i)+(BigInt(o)<<BigInt(32))});l.prototype.readBigUInt64BE=Oe(function(e){e=e>>>0,gt(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Lt(e,this.length-8);let i=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],o=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(o)});l.prototype.readIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||B(e,t,this.length);let i=this[e],o=1,s=0;for(;++s<t&&(o*=256);)i+=this[e+s]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*t)),i};l.prototype.readIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||B(e,t,this.length);let i=t,o=1,s=this[e+--i];for(;i>0&&(o*=256);)s+=this[e+--i]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*t)),s};l.prototype.readInt8=function(e,t){return e=e>>>0,t||B(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};l.prototype.readInt16LE=function(e,t){e=e>>>0,t||B(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};l.prototype.readInt16BE=function(e,t){e=e>>>0,t||B(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};l.prototype.readInt32LE=function(e,t){return e=e>>>0,t||B(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};l.prototype.readInt32BE=function(e,t){return e=e>>>0,t||B(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};l.prototype.readBigInt64LE=Oe(function(e){e=e>>>0,gt(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Lt(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});l.prototype.readBigInt64BE=Oe(function(e){e=e>>>0,gt(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Lt(e,this.length-8);let i=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(i)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)});l.prototype.readFloatLE=function(e,t){return e=e>>>0,t||B(e,4,this.length),mt.read(this,e,!0,23,4)};l.prototype.readFloatBE=function(e,t){return e=e>>>0,t||B(e,4,this.length),mt.read(this,e,!1,23,4)};l.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||B(e,8,this.length),mt.read(this,e,!0,52,8)};l.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||B(e,8,this.length),mt.read(this,e,!1,52,8)};function M(r,e,t,n,i,o){if(!l.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(t+n>r.length)throw new RangeError("Index out of range")}l.prototype.writeUintLE=l.prototype.writeUIntLE=function(e,t,n,i){if(e=+e,t=t>>>0,n=n>>>0,!i){let c=Math.pow(2,8*n)-1;M(this,e,t,n,c,0)}let o=1,s=0;for(this[t]=e&255;++s<n&&(o*=256);)this[t+s]=e/o&255;return t+n};l.prototype.writeUintBE=l.prototype.writeUIntBE=function(e,t,n,i){if(e=+e,t=t>>>0,n=n>>>0,!i){let c=Math.pow(2,8*n)-1;M(this,e,t,n,c,0)}let o=n-1,s=1;for(this[t+o]=e&255;--o>=0&&(s*=256);)this[t+o]=e/s&255;return t+n};l.prototype.writeUint8=l.prototype.writeUInt8=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,1,255,0),this[t]=e&255,t+1};l.prototype.writeUint16LE=l.prototype.writeUInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2};l.prototype.writeUint16BE=l.prototype.writeUInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2};l.prototype.writeUint32LE=l.prototype.writeUInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4};l.prototype.writeUint32BE=l.prototype.writeUInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function So(r,e,t,n,i){Ko(e,n,i,r,t,7);let o=Number(e&BigInt(4294967295));r[t++]=o,o=o>>8,r[t++]=o,o=o>>8,r[t++]=o,o=o>>8,r[t++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return r[t++]=s,s=s>>8,r[t++]=s,s=s>>8,r[t++]=s,s=s>>8,r[t++]=s,t}function ko(r,e,t,n,i){Ko(e,n,i,r,t,7);let o=Number(e&BigInt(4294967295));r[t+7]=o,o=o>>8,r[t+6]=o,o=o>>8,r[t+5]=o,o=o>>8,r[t+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return r[t+3]=s,s=s>>8,r[t+2]=s,s=s>>8,r[t+1]=s,s=s>>8,r[t]=s,t+8}l.prototype.writeBigUInt64LE=Oe(function(e,t=0){return So(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});l.prototype.writeBigUInt64BE=Oe(function(e,t=0){return ko(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});l.prototype.writeIntLE=function(e,t,n,i){if(e=+e,t=t>>>0,!i){let u=Math.pow(2,8*n-1);M(this,e,t,n,u-1,-u)}let o=0,s=1,c=0;for(this[t]=e&255;++o<n&&(s*=256);)e<0&&c===0&&this[t+o-1]!==0&&(c=1),this[t+o]=(e/s>>0)-c&255;return t+n};l.prototype.writeIntBE=function(e,t,n,i){if(e=+e,t=t>>>0,!i){let u=Math.pow(2,8*n-1);M(this,e,t,n,u-1,-u)}let o=n-1,s=1,c=0;for(this[t+o]=e&255;--o>=0&&(s*=256);)e<0&&c===0&&this[t+o+1]!==0&&(c=1),this[t+o]=(e/s>>0)-c&255;return t+n};l.prototype.writeInt8=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1};l.prototype.writeInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2};l.prototype.writeInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2};l.prototype.writeInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4};l.prototype.writeInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};l.prototype.writeBigInt64LE=Oe(function(e,t=0){return So(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});l.prototype.writeBigInt64BE=Oe(function(e,t=0){return ko(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Io(r,e,t,n,i,o){if(t+n>r.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function Uo(r,e,t,n,i){return e=+e,t=t>>>0,i||Io(r,e,t,4,34028234663852886e22,-34028234663852886e22),mt.write(r,e,t,n,23,4),t+4}l.prototype.writeFloatLE=function(e,t,n){return Uo(this,e,t,!0,n)};l.prototype.writeFloatBE=function(e,t,n){return Uo(this,e,t,!1,n)};function Oo(r,e,t,n,i){return e=+e,t=t>>>0,i||Io(r,e,t,8,17976931348623157e292,-17976931348623157e292),mt.write(r,e,t,n,52,8),t+8}l.prototype.writeDoubleLE=function(e,t,n){return Oo(this,e,t,!0,n)};l.prototype.writeDoubleBE=function(e,t,n){return Oo(this,e,t,!1,n)};l.prototype.copy=function(e,t,n,i){if(!l.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&i<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-t<i-n&&(i=e.length-t+n);let o=i-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,n,i):Uint8Array.prototype.set.call(e,this.subarray(n,i),t),o};l.prototype.fill=function(e,t,n,i){if(typeof e=="string"){if(typeof t=="string"?(i=t,t=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"&&!l.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(e.length===1){let s=e.charCodeAt(0);(i==="utf8"&&s<128||i==="latin1")&&(e=s)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;t=t>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let o;if(typeof e=="number")for(o=t;o<n;++o)this[o]=e;else{let s=l.isBuffer(e)?e:l.from(e,i),c=s.length;if(c===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<n-t;++o)this[o+t]=s[o%c]}return this};var yt={};function Mn(r,e,t){yt[r]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:e.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}`}}}Mn("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Mn("ERR_INVALID_ARG_TYPE",function(r,e){return`The "${r}" argument must be of type number. Received type ${typeof e}`},TypeError);Mn("ERR_OUT_OF_RANGE",function(r,e,t){let n=`The value of "${r}" is out of range.`,i=t;return Number.isInteger(t)&&Math.abs(t)>2**32?i=bo(String(t)):typeof t=="bigint"&&(i=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(i=bo(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function bo(r){let e="",t=r.length,n=r[0]==="-"?1:0;for(;t>=n+4;t-=3)e=`_${r.slice(t-3,t)}${e}`;return`${r.slice(0,t)}${e}`}function la(r,e,t){gt(e,"offset"),(r[e]===void 0||r[e+t]===void 0)&&Lt(e,r.length-(t+1))}function Ko(r,e,t,n,i,o){if(r>t||r<e){let s=typeof e=="bigint"?"n":"",c;throw o>3?e===0||e===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=`>= ${e}${s} and <= ${t}${s}`,new yt.ERR_OUT_OF_RANGE("value",c,r)}la(n,i,o)}function gt(r,e){if(typeof r!="number")throw new yt.ERR_INVALID_ARG_TYPE(e,"number",r)}function Lt(r,e,t){throw Math.floor(r)!==r?(gt(r,t),new yt.ERR_OUT_OF_RANGE(t||"offset","an integer",r)):e<0?new yt.ERR_BUFFER_OUT_OF_BOUNDS:new yt.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${e}`,r)}var pa=/[^+/0-9A-Za-z-_]/g;function ya(r){if(r=r.split("=")[0],r=r.trim().replace(pa,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function Cn(r,e){e=e||1/0;let t,n=r.length,i=null,o=[];for(let s=0;s<n;++s){if(t=r.charCodeAt(s),t>55295&&t<57344){if(!i){if(t>56319){(e-=3)>-1&&o.push(239,191,189);continue}else if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=t;continue}if(t<56320){(e-=3)>-1&&o.push(239,191,189),i=t;continue}t=(i-55296<<10|t-56320)+65536}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,t<128){if((e-=1)<0)break;o.push(t)}else if(t<2048){if((e-=2)<0)break;o.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;o.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;o.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return o}function ma(r){let e=[];for(let t=0;t<r.length;++t)e.push(r.charCodeAt(t)&255);return e}function ga(r,e){let t,n,i,o=[];for(let s=0;s<r.length&&!((e-=2)<0);++s)t=r.charCodeAt(s),n=t>>8,i=t%256,o.push(i),o.push(n);return o}function Co(r){return Un.toByteArray(ya(r))}function wr(r,e,t,n){let i;for(i=0;i<n&&!(i+t>=e.length||i>=r.length);++i)e[i+t]=r[i];return i}function he(r,e){return r instanceof e||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===e.name}function Nn(r){return r!==r}var wa=function(){let r="0123456789abcdef",e=new Array(256);for(let t=0;t<16;++t){let n=t*16;for(let i=0;i<16;++i)e[n+i]=r[t]+r[i]}return e}();function Oe(r){return typeof BigInt>"u"?xa:r}function xa(){throw new Error("BigInt not supported")}});var Fn=E((ah,Po)=>{"use strict";var Ln=null;Po.exports=function(){return Ln===null&&(Ln={textEncoder:new TextEncoder,textDecoder:new TextDecoder}),Ln}});var Vn=E(Do=>{"use strict";var Rn=re(),va=new Set(["buffer","view","utf8"]),$n=class{constructor(e){if(this.encode=e.encode||this.encode,this.decode=e.decode||this.decode,this.name=e.name||this.name,this.format=e.format||this.format,typeof this.encode!="function")throw new TypeError("The 'encode' property must be a function");if(typeof this.decode!="function")throw new TypeError("The 'decode' property must be a function");if(this.encode=this.encode.bind(this),this.decode=this.decode.bind(this),typeof this.name!="string"||this.name==="")throw new TypeError("The 'name' property must be a string");if(typeof this.format!="string"||!va.has(this.format))throw new TypeError("The 'format' property must be one of 'buffer', 'view', 'utf8'");e.createViewTranscoder&&(this.createViewTranscoder=e.createViewTranscoder),e.createBufferTranscoder&&(this.createBufferTranscoder=e.createBufferTranscoder),e.createUTF8Transcoder&&(this.createUTF8Transcoder=e.createUTF8Transcoder)}get commonName(){return this.name.split("+")[0]}createBufferTranscoder(){throw new Rn(`Encoding '${this.name}' cannot be transcoded to 'buffer'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createViewTranscoder(){throw new Rn(`Encoding '${this.name}' cannot be transcoded to 'view'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createUTF8Transcoder(){throw new Rn(`Encoding '${this.name}' cannot be transcoded to 'utf8'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}};Do.Encoding=$n});var Jn=E(vr=>{"use strict";var{Buffer:qn}=xr()||{},{Encoding:Hn}=Vn(),ba=Fn(),Ft=class extends Hn{constructor(e){super({...e,format:"buffer"})}createViewTranscoder(){return new Rt({encode:this.encode,decode:e=>this.decode(qn.from(e.buffer,e.byteOffset,e.byteLength)),name:`${this.name}+view`})}createBufferTranscoder(){return this}},Rt=class extends Hn{constructor(e){super({...e,format:"view"})}createBufferTranscoder(){return new Ft({encode:e=>{let t=this.encode(e);return qn.from(t.buffer,t.byteOffset,t.byteLength)},decode:this.decode,name:`${this.name}+buffer`})}createViewTranscoder(){return this}},jn=class extends Hn{constructor(e){super({...e,format:"utf8"})}createBufferTranscoder(){return new Ft({encode:e=>qn.from(this.encode(e),"utf8"),decode:e=>this.decode(e.toString("utf8")),name:`${this.name}+buffer`})}createViewTranscoder(){let{textEncoder:e,textDecoder:t}=ba();return new Rt({encode:n=>e.encode(this.encode(n)),decode:n=>this.decode(t.decode(n)),name:`${this.name}+view`})}createUTF8Transcoder(){return this}};vr.BufferFormat=Ft;vr.ViewFormat=Rt;vr.UTF8Format=jn});var Fo=E(Ye=>{"use strict";var{Buffer:I}=xr()||{Buffer:{isBuffer:()=>!1}},{textEncoder:No,textDecoder:Mo}=Fn()(),{BufferFormat:$t,ViewFormat:Gn,UTF8Format:Lo}=Jn(),br=r=>r;Ye.utf8=new Lo({encode:function(r){return I.isBuffer(r)?r.toString("utf8"):ArrayBuffer.isView(r)?Mo.decode(r):String(r)},decode:br,name:"utf8",createViewTranscoder(){return new Gn({encode:function(r){return ArrayBuffer.isView(r)?r:No.encode(r)},decode:function(r){return Mo.decode(r)},name:`${this.name}+view`})},createBufferTranscoder(){return new $t({encode:function(r){return I.isBuffer(r)?r:ArrayBuffer.isView(r)?I.from(r.buffer,r.byteOffset,r.byteLength):I.from(String(r),"utf8")},decode:function(r){return r.toString("utf8")},name:`${this.name}+buffer`})}});Ye.json=new Lo({encode:JSON.stringify,decode:JSON.parse,name:"json"});Ye.buffer=new $t({encode:function(r){return I.isBuffer(r)?r:ArrayBuffer.isView(r)?I.from(r.buffer,r.byteOffset,r.byteLength):I.from(String(r),"utf8")},decode:br,name:"buffer",createViewTranscoder(){return new Gn({encode:function(r){return ArrayBuffer.isView(r)?r:I.from(String(r),"utf8")},decode:function(r){return I.from(r.buffer,r.byteOffset,r.byteLength)},name:`${this.name}+view`})}});Ye.view=new Gn({encode:function(r){return ArrayBuffer.isView(r)?r:No.encode(r)},decode:br,name:"view",createBufferTranscoder(){return new $t({encode:function(r){return I.isBuffer(r)?r:ArrayBuffer.isView(r)?I.from(r.buffer,r.byteOffset,r.byteLength):I.from(String(r),"utf8")},decode:br,name:`${this.name}+buffer`})}});Ye.hex=new $t({encode:function(r){return I.isBuffer(r)?r:I.from(String(r),"hex")},decode:function(r){return r.toString("hex")},name:"hex"});Ye.base64=new $t({encode:function(r){return I.isBuffer(r)?r:I.from(String(r),"base64")},decode:function(r){return r.toString("base64")},name:"base64"})});var Vo=E($o=>{"use strict";var Ro=re(),Ar=Fo(),{Encoding:Ea}=Vn(),{BufferFormat:Aa,ViewFormat:_a,UTF8Format:Ta}=Jn(),Vt=Symbol("formats"),Er=Symbol("encodings"),Ba=new Set(["buffer","view","utf8"]),zn=class{constructor(e){if(Array.isArray(e)){if(!e.every(t=>Ba.has(t)))throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'")}else throw new TypeError("The first argument 'formats' must be an array");this[Er]=new Map,this[Vt]=new Set(e);for(let t in Ar)try{this.encoding(t)}catch(n){if(n.code!=="LEVEL_ENCODING_NOT_SUPPORTED")throw n}}encodings(){return Array.from(new Set(this[Er].values()))}encoding(e){let t=this[Er].get(e);if(t===void 0){if(typeof e=="string"&&e!==""){if(t=Ua[e],!t)throw new Ro(`Encoding '${e}' is not found`,{code:"LEVEL_ENCODING_NOT_FOUND"})}else{if(typeof e!="object"||e===null)throw new TypeError("First argument 'encoding' must be a string or object");t=Sa(e)}let{name:n,format:i}=t;if(!this[Vt].has(i))if(this[Vt].has("view"))t=t.createViewTranscoder();else if(this[Vt].has("buffer"))t=t.createBufferTranscoder();else if(this[Vt].has("utf8"))t=t.createUTF8Transcoder();else throw new Ro(`Encoding '${n}' cannot be transcoded`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"});for(let o of[e,n,t.name,t.commonName])this[Er].set(o,t)}return t}};$o.Transcoder=zn;function Sa(r){if(r instanceof Ea)return r;let e="type"in r&&typeof r.type=="string"?r.type:void 0,t=r.name||e||`anonymous-${Oa++}`;switch(ka(r)){case"view":return new _a({...r,name:t});case"utf8":return new Ta({...r,name:t});case"buffer":return new Aa({...r,name:t});default:throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'")}}function ka(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 Ia={binary:Ar.buffer,"utf-8":Ar.utf8},Ua={...Ar,...Ia},Oa=0});var qo=E((ph,Wn)=>{"use strict";var Ka=Object.prototype.hasOwnProperty,P="~";function jt(){}Object.create&&(jt.prototype=Object.create(null),new jt().__proto__||(P=!1));function Ca(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function jo(r,e,t,n,i){if(typeof t!="function")throw new TypeError("The listener must be a function");var o=new Ca(t,n||r,i),s=P?P+e:e;return r._events[s]?r._events[s].fn?r._events[s]=[r._events[s],o]:r._events[s].push(o):(r._events[s]=o,r._eventsCount++),r}function _r(r,e){--r._eventsCount===0?r._events=new jt:delete r._events[e]}function U(){this._events=new jt,this._eventsCount=0}U.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)Ka.call(t,n)&&e.push(P?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};U.prototype.listeners=function(e){var t=P?P+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,o=n.length,s=new Array(o);i<o;i++)s[i]=n[i].fn;return s};U.prototype.listenerCount=function(e){var t=P?P+e:e,n=this._events[t];return n?n.fn?1:n.length:0};U.prototype.emit=function(e,t,n,i,o,s){var c=P?P+e:e;if(!this._events[c])return!1;var u=this._events[c],a=arguments.length,d,f;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),a){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,n),!0;case 4:return u.fn.call(u.context,t,n,i),!0;case 5:return u.fn.call(u.context,t,n,i,o),!0;case 6:return u.fn.call(u.context,t,n,i,o,s),!0}for(f=1,d=new Array(a-1);f<a;f++)d[f-1]=arguments[f];u.fn.apply(u.context,d)}else{var m=u.length,g;for(f=0;f<m;f++)switch(u[f].once&&this.removeListener(e,u[f].fn,void 0,!0),a){case 1:u[f].fn.call(u[f].context);break;case 2:u[f].fn.call(u[f].context,t);break;case 3:u[f].fn.call(u[f].context,t,n);break;case 4:u[f].fn.call(u[f].context,t,n,i);break;default:if(!d)for(g=1,d=new Array(a-1);g<a;g++)d[g-1]=arguments[g];u[f].fn.apply(u[f].context,d)}}return!0};U.prototype.on=function(e,t,n){return jo(this,e,t,n,!1)};U.prototype.once=function(e,t,n){return jo(this,e,t,n,!0)};U.prototype.removeListener=function(e,t,n,i){var o=P?P+e:e;if(!this._events[o])return this;if(!t)return _r(this,o),this;var s=this._events[o];if(s.fn)s.fn===t&&(!i||s.once)&&(!n||s.context===n)&&_r(this,o);else{for(var c=0,u=[],a=s.length;c<a;c++)(s[c].fn!==t||i&&!s[c].once||n&&s[c].context!==n)&&u.push(s[c]);u.length?this._events[o]=u.length===1?u[0]:u:_r(this,o)}return this};U.prototype.removeAllListeners=function(e){var t;return e?(t=P?P+e:e,this._events[t]&&_r(this,t)):(this._events=new jt,this._eventsCount=0),this};U.prototype.off=U.prototype.removeListener;U.prototype.addListener=U.prototype.on;U.prefixed=P;U.EventEmitter=U;typeof Wn<"u"&&(Wn.exports=U)});var Jo=E((yh,Ho)=>{Ho.exports=typeof queueMicrotask=="function"?queueMicrotask:r=>Promise.resolve().then(r)});var qt=E(Xn=>{"use strict";var Go=Jo();Xn.fromCallback=function(r,e){if(r===void 0){var t=new Promise(function(n,i){r=function(o,s){o?i(o):n(s)}});r[e!==void 0?e:"promise"]=t}else if(typeof r!="function")throw new TypeError("Callback must be a function");return r};Xn.fromPromise=function(r,e){if(e===void 0)return r;r.then(function(t){Go(()=>e(null,t))}).catch(function(t){Go(()=>e(t))})}});var Tr=E(Yn=>{"use strict";Yn.getCallback=function(r,e){return typeof r=="function"?r:e};Yn.getOptions=function(r,e){return typeof r=="object"&&r!==null?r:e!==void 0?e:{}}});var Ne=E(Ir=>{"use strict";var{fromCallback:Zn}=qt(),F=re(),{getOptions:Qn,getCallback:zo}=Tr(),Ze=Symbol("promise"),xt=Symbol("callback"),le=Symbol("working"),Qe=Symbol("handleOne"),Ee=Symbol("handleMany"),ei=Symbol("autoClose"),De=Symbol("finishWork"),pe=Symbol("returnMany"),Ke=Symbol("closing"),Ht=Symbol("handleClose"),Br=Symbol("closed"),Jt=Symbol("closeCallbacks"),Pe=Symbol("keyEncoding"),et=Symbol("valueEncoding"),ti=Symbol("abortOnClose"),Sr=Symbol("legacy"),ri=Symbol("keys"),ni=Symbol("values"),Ce=Symbol("limit"),X=Symbol("count"),kr=Object.freeze({}),Pa=()=>{},Wo=!1,Gt=class{constructor(e,t,n){if(typeof e!="object"||e===null){let i=e===null?"null":typeof e;throw new TypeError(`The first argument must be an abstract-level database, received ${i}`)}if(typeof t!="object"||t===null)throw new TypeError("The second argument must be an options object");this[Br]=!1,this[Jt]=[],this[le]=!1,this[Ke]=!1,this[ei]=!1,this[xt]=null,this[Qe]=this[Qe].bind(this),this[Ee]=this[Ee].bind(this),this[Ht]=this[Ht].bind(this),this[Pe]=t[Pe],this[et]=t[et],this[Sr]=n,this[Ce]=Number.isInteger(t.limit)&&t.limit>=0?t.limit:1/0,this[X]=0,this[ti]=!!t.abortOnClose,this.db=e,this.db.attachResource(this),this.nextTick=e.nextTick}get count(){return this[X]}get limit(){return this[Ce]}next(e){let t;if(e===void 0)t=new Promise((n,i)=>{e=(o,s,c)=>{o?i(o):this[Sr]?s===void 0&&c===void 0?n():n([s,c]):n(s)}});else if(typeof e!="function")throw new TypeError("Callback must be a function");return this[Ke]?this.nextTick(e,new F("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[le]?this.nextTick(e,new F("Iterator is busy: cannot call next() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[le]=!0,this[xt]=e,this[X]>=this[Ce]?this.nextTick(this[Qe],null):this._next(this[Qe])),t}_next(e){this.nextTick(e)}nextv(e,t,n){return n=zo(t,n),n=Zn(n,Ze),t=Qn(t,kr),Number.isInteger(e)?(this[Ke]?this.nextTick(n,new F("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[le]?this.nextTick(n,new F("Iterator is busy: cannot call nextv() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(e<1&&(e=1),this[Ce]<1/0&&(e=Math.min(e,this[Ce]-this[X])),this[le]=!0,this[xt]=n,e<=0?this.nextTick(this[Ee],null,[]):this._nextv(e,t,this[Ee])),n[Ze]):(this.nextTick(n,new TypeError("The first argument 'size' must be an integer")),n[Ze])}_nextv(e,t,n){let i=[],o=(s,c,u)=>{if(s)return n(s);if(this[Sr]?c===void 0&&u===void 0:c===void 0)return n(null,i);i.push(this[Sr]?[c,u]:c),i.length===e?n(null,i):this._next(o)};this._next(o)}all(e,t){return t=zo(e,t),t=Zn(t,Ze),e=Qn(e,kr),this[Ke]?this.nextTick(t,new F("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[le]?this.nextTick(t,new F("Iterator is busy: cannot call all() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[le]=!0,this[xt]=t,this[ei]=!0,this[X]>=this[Ce]?this.nextTick(this[Ee],null,[]):this._all(e,this[Ee])),t[Ze]}_all(e,t){let n=this[X],i=[],o=()=>{let c=this[Ce]<1/0?Math.min(1e3,this[Ce]-n):1e3;c<=0?this.nextTick(t,null,i):this._nextv(c,kr,s)},s=(c,u)=>{c?t(c):u.length===0?t(null,i):(i.push.apply(i,u),n+=u.length,o())};o()}[De](){let e=this[xt];return this[ti]&&e===null?Pa:(this[le]=!1,this[xt]=null,this[Ke]&&this._close(this[Ht]),e)}[pe](e,t,n){this[ei]?this.close(e.bind(null,t,n)):e(t,n)}seek(e,t){if(t=Qn(t,kr),!this[Ke]){if(this[le])throw new F("Iterator is busy: cannot call seek() until next() has completed",{code:"LEVEL_ITERATOR_BUSY"});{let n=this.db.keyEncoding(t.keyEncoding||this[Pe]),i=n.format;t.keyEncoding!==i&&(t={...t,keyEncoding:i});let o=this.db.prefixKey(n.encode(e),i);this._seek(o,t)}}}_seek(e,t){throw new F("Iterator does not support seek()",{code:"LEVEL_NOT_SUPPORTED"})}close(e){return e=Zn(e,Ze),this[Br]?this.nextTick(e):this[Ke]?this[Jt].push(e):(this[Ke]=!0,this[Jt].push(e),this[le]?this[ti]&&this[De]()(new F("Aborted on iterator close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this._close(this[Ht])),e[Ze]}_close(e){this.nextTick(e)}[Ht](){this[Br]=!0,this.db.detachResource(this);let e=this[Jt];this[Jt]=[];for(let t of e)t()}async*[Symbol.asyncIterator](){try{let e;for(;(e=await this.next())!==void 0;)yield e}finally{this[Br]||await this.close()}}},vt=class extends Gt{constructor(e,t){super(e,t,!0),this[ri]=t.keys!==!1,this[ni]=t.values!==!1}[Qe](e,t,n){let i=this[De]();if(e)return i(e);try{t=this[ri]&&t!==void 0?this[Pe].decode(t):void 0,n=this[ni]&&n!==void 0?this[et].decode(n):void 0}catch(o){return i(new Me("entry",o))}t===void 0&&n===void 0||this[X]++,i(null,t,n)}[Ee](e,t){let n=this[De]();if(e)return this[pe](n,e);try{for(let i of t){let o=i[0],s=i[1];i[0]=this[ri]&&o!==void 0?this[Pe].decode(o):void 0,i[1]=this[ni]&&s!==void 0?this[et].decode(s):void 0}}catch(i){return this[pe](n,new Me("entries",i))}this[X]+=t.length,this[pe](n,null,t)}end(e){return!Wo&&typeof console<"u"&&(Wo=!0,console.warn(new F("The iterator.end() method was renamed to close() and end() is an alias that will be removed in a future version",{code:"LEVEL_LEGACY"}))),this.close(e)}},ii=class extends Gt{constructor(e,t){super(e,t,!1)}[Qe](e,t){let n=this[De]();if(e)return n(e);try{t=t!==void 0?this[Pe].decode(t):void 0}catch(i){return n(new Me("key",i))}t!==void 0&&this[X]++,n(null,t)}[Ee](e,t){let n=this[De]();if(e)return this[pe](n,e);try{for(let i=0;i<t.length;i++){let o=t[i];t[i]=o!==void 0?this[Pe].decode(o):void 0}}catch(i){return this[pe](n,new Me("keys",i))}this[X]+=t.length,this[pe](n,null,t)}},oi=class extends Gt{constructor(e,t){super(e,t,!1)}[Qe](e,t){let n=this[De]();if(e)return n(e);try{t=t!==void 0?this[et].decode(t):void 0}catch(i){return n(new Me("value",i))}t!==void 0&&this[X]++,n(null,t)}[Ee](e,t){let n=this[De]();if(e)return this[pe](n,e);try{for(let i=0;i<t.length;i++){let o=t[i];t[i]=o!==void 0?this[et].decode(o):void 0}}catch(i){return this[pe](n,new Me("values",i))}this[X]+=t.length,this[pe](n,null,t)}},Me=class extends F{constructor(e,t){super(`Iterator could not decode ${e}`,{code:"LEVEL_DECODE_ERROR",cause:t})}};for(let r of["_ended property","_nexting property","_end method"])Object.defineProperty(vt.prototype,r.split(" ")[0],{get(){throw new F(`The ${r} has been removed`,{code:"LEVEL_LEGACY"})},set(){throw new F(`The ${r} has been removed`,{code:"LEVEL_LEGACY"})}});vt.keyEncoding=Pe;vt.valueEncoding=et;Ir.AbstractIterator=vt;Ir.AbstractKeyIterator=ii;Ir.AbstractValueIterator=oi});var Xo=E(si=>{"use strict";var{AbstractKeyIterator:Da,AbstractValueIterator:Ma}=Ne(),tt=Symbol("iterator"),zt=Symbol("callback"),bt=Symbol("handleOne"),rt=Symbol("handleMany"),Wt=class extends Da{constructor(e,t){super(e,t),this[tt]=e.iterator({...t,keys:!0,values:!1}),this[bt]=this[bt].bind(this),this[rt]=this[rt].bind(this)}},Ur=class extends Ma{constructor(e,t){super(e,t),this[tt]=e.iterator({...t,keys:!1,values:!0}),this[bt]=this[bt].bind(this),this[rt]=this[rt].bind(this)}};for(let r of[Wt,Ur]){let e=r===Wt,t=e?n=>n[0]:n=>n[1];r.prototype._next=function(n){this[zt]=n,this[tt].next(this[bt])},r.prototype[bt]=function(n,i,o){let s=this[zt];n?s(n):s(null,e?i:o)},r.prototype._nextv=function(n,i,o){this[zt]=o,this[tt].nextv(n,i,this[rt])},r.prototype._all=function(n,i){this[zt]=i,this[tt].all(n,this[rt])},r.prototype[rt]=function(n,i){let o=this[zt];n?o(n):o(null,i.map(t))},r.prototype._seek=function(n,i){this[tt].seek(n,i)},r.prototype._close=function(n){this[tt].close(n)}}si.DefaultKeyIterator=Wt;si.DefaultValueIterator=Ur});var Yo=E(Mr=>{"use strict";var{AbstractIterator:Na,AbstractKeyIterator:La,AbstractValueIterator:Fa}=Ne(),ci=re(),N=Symbol("nut"),Pr=Symbol("undefer"),Dr=Symbol("factory"),Or=class extends Na{constructor(e,t){super(e,t),this[N]=null,this[Dr]=()=>e.iterator(t),this.db.defer(()=>this[Pr]())}},Kr=class extends La{constructor(e,t){super(e,t),this[N]=null,this[Dr]=()=>e.keys(t),this.db.defer(()=>this[Pr]())}},Cr=class extends Fa{constructor(e,t){super(e,t),this[N]=null,this[Dr]=()=>e.values(t),this.db.defer(()=>this[Pr]())}};for(let r of[Or,Kr,Cr])r.prototype[Pr]=function(){this.db.status==="open"&&(this[N]=this[Dr]())},r.prototype._next=function(e){this[N]!==null?this[N].next(e):this.db.status==="opening"?this.db.defer(()=>this._next(e)):this.nextTick(e,new ci("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},r.prototype._nextv=function(e,t,n){this[N]!==null?this[N].nextv(e,t,n):this.db.status==="opening"?this.db.defer(()=>this._nextv(e,t,n)):this.nextTick(n,new ci("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},r.prototype._all=function(e,t){this[N]!==null?this[N].all(t):this.db.status==="opening"?this.db.defer(()=>this._all(e,t)):this.nextTick(t,new ci("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},r.prototype._seek=function(e,t){this[N]!==null?this[N]._seek(e,t):this.db.status==="opening"&&this.db.defer(()=>this._seek(e,t))},r.prototype._close=function(e){this[N]!==null?this[N].close(e):this.db.status==="opening"?this.db.defer(()=>this._close(e)):this.nextTick(e)};Mr.DeferredIterator=Or;Mr.DeferredKeyIterator=Kr;Mr.DeferredValueIterator=Cr});var ai=E(Qo=>{"use strict";var{fromCallback:Zo}=qt(),Nr=re(),{getCallback:Ra,getOptions:$a}=Tr(),Lr=Symbol("promise"),Y=Symbol("status"),Et=Symbol("operations"),Xt=Symbol("finishClose"),At=Symbol("closeCallbacks"),ui=class{constructor(e){if(typeof e!="object"||e===null){let t=e===null?"null":typeof e;throw new TypeError(`The first argument must be an abstract-level database, received ${t}`)}this[Et]=[],this[At]=[],this[Y]="open",this[Xt]=this[Xt].bind(this),this.db=e,this.db.attachResource(this),this.nextTick=e.nextTick}get length(){return this[Et].length}put(e,t,n){if(this[Y]!=="open")throw new Nr("Batch is not open: cannot call put() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});let i=this.db._checkKey(e)||this.db._checkValue(t);if(i)throw i;let o=n&&n.sublevel!=null?n.sublevel:this.db,s=n,c=o.keyEncoding(n&&n.keyEncoding),u=o.valueEncoding(n&&n.valueEncoding),a=c.format;n={...n,keyEncoding:a,valueEncoding:u.format},o!==this.db&&(n.sublevel=null);let d=o.prefixKey(c.encode(e),a),f=u.encode(t);return this._put(d,f,n),this[Et].push({...s,type:"put",key:e,value:t}),this}_put(e,t,n){}del(e,t){if(this[Y]!=="open")throw new Nr("Batch is not open: cannot call del() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});let n=this.db._checkKey(e);if(n)throw n;let i=t&&t.sublevel!=null?t.sublevel:this.db,o=t,s=i.keyEncoding(t&&t.keyEncoding),c=s.format;return t={...t,keyEncoding:c},i!==this.db&&(t.sublevel=null),this._del(i.prefixKey(s.encode(e),c),t),this[Et].push({...o,type:"del",key:e}),this}_del(e,t){}clear(){if(this[Y]!=="open")throw new Nr("Batch is not open: cannot call clear() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});return this._clear(),this[Et]=[],this}_clear(){}write(e,t){return t=Ra(e,t),t=Zo(t,Lr),e=$a(e),this[Y]!=="open"?this.nextTick(t,new Nr("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"})):this.length===0?this.close(t):(this[Y]="writing",this._write(e,n=>{this[Y]="closing",this[At].push(()=>t(n)),n||this.db.emit("batch",this[Et]),this._close(this[Xt])})),t[Lr]}_write(e,t){}close(e){return e=Zo(e,Lr),this[Y]==="closing"?this[At].push(e):this[Y]==="closed"?this.nextTick(e):(this[At].push(e),this[Y]!=="writing"&&(this[Y]="closing",this._close(this[Xt]))),e[Lr]}_close(e){this.nextTick(e)}[Xt](){this[Y]="closed",this.db.detachResource(this);let e=this[At];this[At]=[];for(let t of e)t()}};Qo.AbstractChainedBatch=ui});var ts=E(es=>{"use strict";var{AbstractChainedBatch:Va}=ai(),ja=re(),_t=Symbol("encoded"),fi=class extends Va{constructor(e){super(e),this[_t]=[]}_put(e,t,n){this[_t].push({...n,type:"put",key:e,value:t})}_del(e,t){this[_t].push({...t,type:"del",key:e})}_clear(){this[_t]=[]}_write(e,t){this.db.status==="opening"?this.db.defer(()=>this._write(e,t)):this.db.status==="open"?this[_t].length===0?this.nextTick(t):this.db._batch(this[_t],e,t):this.nextTick(t,new ja("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"}))}};es.DefaultChainedBatch=fi});var is=E((Ah,ns)=>{"use strict";var rs=re(),qa=Object.prototype.hasOwnProperty,Ha=new Set(["lt","lte","gt","gte"]);ns.exports=function(r,e){let t={};for(let n in r)if(qa.call(r,n)&&!(n==="keyEncoding"||n==="valueEncoding")){if(n==="start"||n==="end")throw new rs(`The legacy range option '${n}' has been removed`,{code:"LEVEL_LEGACY"});if(n==="encoding")throw new rs("The levelup-style 'encoding' alias has been removed, use 'valueEncoding' instead",{code:"LEVEL_LEGACY"});Ha.has(n)?t[n]=e.encode(r[n]):t[n]=r[n]}return t.reverse=!!t.reverse,t.limit=Number.isInteger(t.limit)&&t.limit>=0?t.limit:-1,t}});var di=E((_h,ss)=>{var os;ss.exports=typeof queueMicrotask=="function"?queueMicrotask.bind(typeof window<"u"?window:globalThis):r=>(os||(os=Promise.resolve())).then(r).catch(e=>setTimeout(()=>{throw e},0))});var as=E((Th,us)=>{"use strict";var cs=di();us.exports=function(r,...e){e.length===0?cs(r):cs(()=>r(...e))}});var fs=E(Fr=>{"use strict";var{AbstractIterator:Ja,AbstractKeyIterator:Ga,AbstractValueIterator:za}=Ne(),Tt=Symbol("unfix"),ne=Symbol("iterator"),nt=Symbol("handleOne"),Le=Symbol("handleMany"),Ae=Symbol("callback"),Yt=class extends Ja{constructor(e,t,n,i){super(e,t),this[ne]=n,this[Tt]=i,this[nt]=this[nt].bind(this),this[Le]=this[Le].bind(this),this[Ae]=null}[nt](e,t,n){let i=this[Ae];if(e)return i(e);t!==void 0&&(t=this[Tt](t)),i(e,t,n)}[Le](e,t){let n=this[Ae];if(e)return n(e);for(let i of t){let o=i[0];o!==void 0&&(i[0]=this[Tt](o))}n(e,t)}},Zt=class extends Ga{constructor(e,t,n,i){super(e,t),this[ne]=n,this[Tt]=i,this[nt]=this[nt].bind(this),this[Le]=this[Le].bind(this),this[Ae]=null}[nt](e,t){let n=this[Ae];if(e)return n(e);t!==void 0&&(t=this[Tt](t)),n(e,t)}[Le](e,t){let n=this[Ae];if(e)return n(e);for(let i=0;i<t.length;i++){let o=t[i];o!==void 0&&(t[i]=this[Tt](o))}n(e,t)}},Qt=class extends za{constructor(e,t,n){super(e,t),this[ne]=n}};for(let r of[Yt,Zt])r.prototype._next=function(e){this[Ae]=e,this[ne].next(this[nt])},r.prototype._nextv=function(e,t,n){this[Ae]=n,this[ne].nextv(e,t,this[Le])},r.prototype._all=function(e,t){this[Ae]=t,this[ne].all(e,this[Le])};for(let r of[Qt])r.prototype._next=function(e){this[ne].next(e)},r.prototype._nextv=function(e,t,n){this[ne].nextv(e,t,n)},r.prototype._all=function(e,t){this[ne].all(e,t)};for(let r of[Yt,Zt,Qt])r.prototype._seek=function(e,t){this[ne].seek(e,t)},r.prototype._close=function(e){this[ne].close(e)};Fr.AbstractSublevelIterator=Yt;Fr.AbstractSublevelKeyIterator=Zt;Fr.AbstractSublevelValueIterator=Qt});var ps=E((Sh,ls)=>{"use strict";var hi=re(),{Buffer:yi}=xr()||{},{AbstractSublevelIterator:Wa,AbstractSublevelKeyIterator:Xa,AbstractSublevelValueIterator:Ya}=fs(),_e=Symbol("prefix"),ds=Symbol("upperBound"),er=Symbol("prefixRange"),R=Symbol("parent"),li=Symbol("unfix"),hs=new TextEncoder,Za={separator:"!"};ls.exports=function({AbstractLevel:r}){class e extends r{static defaults(n){if(typeof n=="string")throw new hi("The subleveldown string shorthand for { separator } has been removed",{code:"LEVEL_LEGACY"});if(n&&n.open)throw new hi("The subleveldown open option has been removed",{code:"LEVEL_LEGACY"});return n==null?Za:n.separator?n:{...n,separator:"!"}}constructor(n,i,o){let{separator:s,manifest:c,...u}=e.defaults(o);i=ef(i,s);let a=s.charCodeAt(0)+1,d=n[R]||n;if(!hs.encode(i).every(g=>g>a&&g<127))throw new hi(`Prefix must use bytes > ${a} < 127`,{code:"LEVEL_INVALID_PREFIX"});super(Qa(d,c),u);let f=(n.prefix||"")+s+i+s,m=f.slice(0,-1)+String.fromCharCode(a);this[R]=d,this[_e]=new Rr(f),this[ds]=new Rr(m),this[li]=new mi,this.nextTick=d.nextTick}prefixKey(n,i){if(i==="utf8")return this[_e].utf8+n;if(n.byteLength===0)return this[_e][i];if(i==="view"){let o=this[_e].view,s=new Uint8Array(o.byteLength+n.byteLength);return s.set(o,0),s.set(n,o.byteLength),s}else{let o=this[_e].buffer;return yi.concat([o,n],o.byteLength+n.byteLength)}}[er](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[_e][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[ds][i]}get prefix(){return this[_e].utf8}get db(){return this[R]}_open(n,i){this[R].open({passive:!0},i)}_put(n,i,o,s){this[R].put(n,i,o,s)}_get(n,i,o){this[R].get(n,i,o)}_getMany(n,i,o){this[R].getMany(n,i,o)}_del(n,i,o){this[R].del(n,i,o)}_batch(n,i,o){this[R].batch(n,i,o)}_clear(n,i){this[er](n,n.keyEncoding),this[R].clear(n,i)}_iterator(n){this[er](n,n.keyEncoding);let i=this[R].iterator(n),o=this[li].get(this[_e].utf8.length,n.keyEncoding);return new Wa(this,n,i,o)}_keys(n){this[er](n,n.keyEncoding);let i=this[R].keys(n),o=this[li].get(this[_e].utf8.length,n.keyEncoding);return new Xa(this,n,i,o)}_values(n){this[er](n,n.keyEncoding);let i=this[R].values(n);return new Ya(this,n,i)}}return{AbstractSublevel:e}};var Qa=function(r,e){return{...r.supports,createIfMissing:!1,errorIfExists:!1,events:{},additionalMethods:{},...e,encodings:{utf8:pi(r,"utf8"),buffer:pi(r,"buffer"),view:pi(r,"view")}}},pi=function(r,e){return r.supports.encodings[e]?r.keyEncoding(e).name===e:!1},Rr=class{constructor(e){this.utf8=e,this.view=hs.encode(e),this.buffer=yi?yi.from(this.view.buffer,0,this.view.byteLength):{}}},mi=class{constructor(){this.cache=new Map}get(e,t){let n=this.cache.get(t);return n===void 0&&(t==="view"?n=(function(i,o){return o.subarray(i)}).bind(null,e):n=(function(i,o){return o.slice(i)}).bind(null,e),this.cache.set(t,n)),n}},ef=function(r,e){let t=0,n=r.length;for(;t<n&&r[t]===e;)t++;for(;n>t&&r[n-1]===e;)n--;return r.slice(t,n)}});var bi=E(vi=>{"use strict";var{supports:tf}=ho(),{Transcoder:rf}=Vo(),{EventEmitter:nf}=qo(),{fromCallback:Fe}=qt(),ie=re(),{AbstractIterator:it}=Ne(),{DefaultKeyIterator:of,DefaultValueIterator:sf}=Xo(),{DeferredIterator:cf,DeferredKeyIterator:uf,DeferredValueIterator:af}=Yo(),{DefaultChainedBatch:ys}=ts(),{getCallback:ot,getOptions:Re}=Tr(),$r=is(),x=Symbol("promise"),Te=Symbol("landed"),st=Symbol("resources"),gi=Symbol("closeResources"),tr=Symbol("operations"),rr=Symbol("undefer"),Vr=Symbol("deferOpen"),ms=Symbol("options"),v=Symbol("status"),ct=Symbol("defaultOptions"),Bt=Symbol("transcoder"),jr=Symbol("keyEncoding"),wi=Symbol("valueEncoding"),ff=()=>{},nr=class extends nf{constructor(e,t){if(super(),typeof e!="object"||e===null)throw new TypeError("The first argument 'manifest' must be an object");t=Re(t);let{keyEncoding:n,valueEncoding:i,passive:o,...s}=t;this[st]=new Set,this[tr]=[],this[Vr]=!0,this[ms]=s,this[v]="opening",this.supports=tf(e,{status:!0,promises:!0,clear:!0,getMany:!0,deferredOpen:!0,snapshots:e.snapshots!==!1,permanence:e.permanence!==!1,keyIterator:!0,valueIterator:!0,iteratorNextv:!0,iteratorAll:!0,encodings:e.encodings||{},events:Object.assign({},e.events,{opening:!0,open:!0,closing:!0,closed:!0,put:!0,del:!0,batch:!0,clear:!0})}),this[Bt]=new rf(df(this)),this[jr]=this[Bt].encoding(n||"utf8"),this[wi]=this[Bt].encoding(i||"utf8");for(let c of this[Bt].encodings())this.supports.encodings[c.commonName]||(this.supports.encodings[c.commonName]=!0);this[ct]={empty:Object.freeze({}),entry:Object.freeze({keyEncoding:this[jr].commonName,valueEncoding:this[wi].commonName}),key:Object.freeze({keyEncoding:this[jr].commonName})},this.nextTick(()=>{this[Vr]&&this.open({passive:!1},ff)})}get status(){return this[v]}keyEncoding(e){return this[Bt].encoding(e??this[jr])}valueEncoding(e){return this[Bt].encoding(e??this[wi])}open(e,t){t=ot(e,t),t=Fe(t,x),e={...this[ms],...Re(e)},e.createIfMissing=e.createIfMissing!==!1,e.errorIfExists=!!e.errorIfExists;let n=i=>{this[v]==="closing"||this[v]==="opening"?this.once(Te,i?()=>n(i):n):this[v]!=="open"?t(new ie("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN",cause:i})):t()};return e.passive?this[v]==="opening"?this.once(Te,n):this.nextTick(n):this[v]==="closed"||this[Vr]?(this[Vr]=!1,this[v]="opening",this.emit("opening"),this._open(e,i=>{if(i){this[v]="closed",this[gi](()=>{this.emit(Te),n(i)}),this[rr]();return}this[v]="open",this[rr](),this.emit(Te),this[v]==="open"&&this.emit("open"),this[v]==="open"&&this.emit("ready"),n()})):this[v]==="open"?this.nextTick(n):this.once(Te,()=>this.open(e,t)),t[x]}_open(e,t){this.nextTick(t)}close(e){e=Fe(e,x);let t=n=>{this[v]==="opening"||this[v]==="closing"?this.once(Te,n?t(n):t):this[v]!=="closed"?e(new ie("Database is not closed",{code:"LEVEL_DATABASE_NOT_CLOSED",cause:n})):e()};if(this[v]==="open"){this[v]="closing",this.emit("closing");let n=i=>{this[v]="open",this[rr](),this.emit(Te),t(i)};this[gi](()=>{this._close(i=>{if(i)return n(i);this[v]="closed",this[rr](),this.emit(Te),this[v]==="closed"&&this.emit("closed"),t()})})}else this[v]==="closed"?this.nextTick(t):this.once(Te,()=>this.close(e));return e[x]}[gi](e){if(this[st].size===0)return this.nextTick(e);let t=this[st].size,n=!0,i=()=>{--t===0&&(n?this.nextTick(e):e())};for(let o of this[st])o.close(i);n=!1,this[st].clear()}_close(e){this.nextTick(e)}get(e,t,n){if(n=ot(t,n),n=Fe(n,x),t=Re(t,this[ct].entry),this[v]==="opening")return this.defer(()=>this.get(e,t,n)),n[x];if(St(this,n))return n[x];let i=this._checkKey(e);if(i)return this.nextTick(n,i),n[x];let o=this.keyEncoding(t.keyEncoding),s=this.valueEncoding(t.valueEncoding),c=o.format,u=s.format;return(t.keyEncoding!==c||t.valueEncoding!==u)&&(t=Object.assign({},t,{keyEncoding:c,valueEncoding:u})),this._get(this.prefixKey(o.encode(e),c),t,(a,d)=>{if(a)return(a.code==="LEVEL_NOT_FOUND"||a.notFound||/NotFound/i.test(a))&&(a.code||(a.code="LEVEL_NOT_FOUND"),a.notFound||(a.notFound=!0),a.status||(a.status=404)),n(a);try{d=s.decode(d)}catch(f){return n(new ie("Could not decode value",{code:"LEVEL_DECODE_ERROR",cause:f}))}n(null,d)}),n[x]}_get(e,t,n){this.nextTick(n,new Error("NotFound"))}getMany(e,t,n){if(n=ot(t,n),n=Fe(n,x),t=Re(t,this[ct].entry),this[v]==="opening")return this.defer(()=>this.getMany(e,t,n)),n[x];if(St(this,n))return n[x];if(!Array.isArray(e))return this.nextTick(n,new TypeError("The first argument 'keys' must be an array")),n[x];if(e.length===0)return this.nextTick(n,null,[]),n[x];let i=this.keyEncoding(t.keyEncoding),o=this.valueEncoding(t.valueEncoding),s=i.format,c=o.format;(t.keyEncoding!==s||t.valueEncoding!==c)&&(t=Object.assign({},t,{keyEncoding:s,valueEncoding:c}));let u=new Array(e.length);for(let a=0;a<e.length;a++){let d=e[a],f=this._checkKey(d);if(f)return this.nextTick(n,f),n[x];u[a]=this.prefixKey(i.encode(d),s)}return this._getMany(u,t,(a,d)=>{if(a)return n(a);try{for(let f=0;f<d.length;f++)d[f]!==void 0&&(d[f]=o.decode(d[f]))}catch(f){return n(new ie(`Could not decode one or more of ${d.length} value(s)`,{code:"LEVEL_DECODE_ERROR",cause:f}))}n(null,d)}),n[x]}_getMany(e,t,n){this.nextTick(n,null,new Array(e.length).fill(void 0))}put(e,t,n,i){if(i=ot(n,i),i=Fe(i,x),n=Re(n,this[ct].entry),this[v]==="opening")return this.defer(()=>this.put(e,t,n,i)),i[x];if(St(this,i))return i[x];let o=this._checkKey(e)||this._checkValue(t);if(o)return this.nextTick(i,o),i[x];let s=this.keyEncoding(n.keyEncoding),c=this.valueEncoding(n.valueEncoding),u=s.format,a=c.format;(n.keyEncoding!==u||n.valueEncoding!==a)&&(n=Object.assign({},n,{keyEncoding:u,valueEncoding:a}));let d=this.prefixKey(s.encode(e),u),f=c.encode(t);return this._put(d,f,n,m=>{if(m)return i(m);this.emit("put",e,t),i()}),i[x]}_put(e,t,n,i){this.nextTick(i)}del(e,t,n){if(n=ot(t,n),n=Fe(n,x),t=Re(t,this[ct].key),this[v]==="opening")return this.defer(()=>this.del(e,t,n)),n[x];if(St(this,n))return n[x];let i=this._checkKey(e);if(i)return this.nextTick(n,i),n[x];let o=this.keyEncoding(t.keyEncoding),s=o.format;return t.keyEncoding!==s&&(t=Object.assign({},t,{keyEncoding:s})),this._del(this.prefixKey(o.encode(e),s),t,c=>{if(c)return n(c);this.emit("del",e),n()}),n[x]}_del(e,t,n){this.nextTick(n)}batch(e,t,n){if(!arguments.length){if(this[v]==="opening")return new ys(this);if(this[v]!=="open")throw new ie("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._chainedBatch()}if(typeof e=="function"?n=e:n=ot(t,n),n=Fe(n,x),t=Re(t,this[ct].empty),this[v]==="opening")return this.defer(()=>this.batch(e,t,n)),n[x];if(St(this,n))return n[x];if(!Array.isArray(e))return this.nextTick(n,new TypeError("The first argument 'operations' must be an array")),n[x];if(e.length===0)return this.nextTick(n),n[x];let i=new Array(e.length),{keyEncoding:o,valueEncoding:s,...c}=t;for(let u=0;u<e.length;u++){if(typeof e[u]!="object"||e[u]===null)return this.nextTick(n,new TypeError("A batch operation must be an object")),n[x];let a=Object.assign({},e[u]);if(a.type!=="put"&&a.type!=="del")return this.nextTick(n,new TypeError("A batch operation must have a type property that is 'put' or 'del'")),n[x];let d=this._checkKey(a.key);if(d)return this.nextTick(n,d),n[x];let f=a.sublevel!=null?a.sublevel:this,m=f.keyEncoding(a.keyEncoding||o),g=m.format;if(a.key=f.prefixKey(m.encode(a.key),g),a.keyEncoding=g,a.type==="put"){let w=this._checkValue(a.value);if(w)return this.nextTick(n,w),n[x];let b=f.valueEncoding(a.valueEncoding||s);a.value=b.encode(a.value),a.valueEncoding=b.format}f!==this&&(a.sublevel=null),i[u]=a}return this._batch(i,c,u=>{if(u)return n(u);this.emit("batch",e),n()}),n[x]}_batch(e,t,n){this.nextTick(n)}sublevel(e,t){return this._sublevel(e,xi.defaults(t))}_sublevel(e,t){return new xi(this,e,t)}prefixKey(e,t){return e}clear(e,t){if(t=ot(e,t),t=Fe(t,x),e=Re(e,this[ct].empty),this[v]==="opening")return this.defer(()=>this.clear(e,t)),t[x];if(St(this,t))return t[x];let n=e,i=this.keyEncoding(e.keyEncoding);return e=$r(e,i),e.keyEncoding=i.format,e.limit===0?this.nextTick(t):this._clear(e,o=>{if(o)return t(o);this.emit("clear",n),t()}),t[x]}_clear(e,t){this.nextTick(t)}iterator(e){let t=this.keyEncoding(e&&e.keyEncoding),n=this.valueEncoding(e&&e.valueEncoding);if(e=$r(e,t),e.keys=e.keys!==!1,e.values=e.values!==!1,e[it.keyEncoding]=t,e[it.valueEncoding]=n,e.keyEncoding=t.format,e.valueEncoding=n.format,this[v]==="opening")return new cf(this,e);if(this[v]!=="open")throw new ie("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._iterator(e)}_iterator(e){return new it(this,e)}keys(e){let t=this.keyEncoding(e&&e.keyEncoding),n=this.valueEncoding(e&&e.valueEncoding);if(e=$r(e,t),e[it.keyEncoding]=t,e[it.valueEncoding]=n,e.keyEncoding=t.format,e.valueEncoding=n.format,this[v]==="opening")return new uf(this,e);if(this[v]!=="open")throw new ie("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._keys(e)}_keys(e){return new of(this,e)}values(e){let t=this.keyEncoding(e&&e.keyEncoding),n=this.valueEncoding(e&&e.valueEncoding);if(e=$r(e,t),e[it.keyEncoding]=t,e[it.valueEncoding]=n,e.keyEncoding=t.format,e.valueEncoding=n.format,this[v]==="opening")return new af(this,e);if(this[v]!=="open")throw new ie("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._values(e)}_values(e){return new sf(this,e)}defer(e){if(typeof e!="function")throw new TypeError("The first argument must be a function");this[tr].push(e)}[rr](){if(this[tr].length===0)return;let e=this[tr];this[tr]=[];for(let t of e)t()}attachResource(e){if(typeof e!="object"||e===null||typeof e.close!="function")throw new TypeError("The first argument must be a resource object");this[st].add(e)}detachResource(e){this[st].delete(e)}_chainedBatch(){return new ys(this)}_checkKey(e){if(e==null)return new ie("Key cannot be null or undefined",{code:"LEVEL_INVALID_KEY"})}_checkValue(e){if(e==null)return new ie("Value cannot be null or undefined",{code:"LEVEL_INVALID_VALUE"})}};nr.prototype.nextTick=as();var{AbstractSublevel:xi}=ps()({AbstractLevel:nr});vi.AbstractLevel=nr;vi.AbstractSublevel=xi;var St=function(r,e){return r[v]!=="open"?(r.nextTick(e,new ie("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"})),!0):!1},df=function(r){return Object.keys(r.supports.encodings).filter(e=>!!r.supports.encodings[e])}});var Ei=E(ut=>{"use strict";ut.AbstractLevel=bi().AbstractLevel;ut.AbstractSublevel=bi().AbstractSublevel;ut.AbstractIterator=Ne().AbstractIterator;ut.AbstractKeyIterator=Ne().AbstractKeyIterator;ut.AbstractValueIterator=Ne().AbstractValueIterator;ut.AbstractChainedBatch=ai().AbstractChainedBatch});var ws=E((Uh,gs)=>{gs.exports=lf;var hf=di();function lf(r,e,t){if(typeof e!="number")throw new Error("second argument must be a Number");let n,i,o,s,c,u=!0,a;Array.isArray(r)?(n=[],o=i=r.length):(s=Object.keys(r),n={},o=i=s.length);function d(m){function g(){t&&t(m,n),t=null}u?hf(g):g()}function f(m,g,w){if(n[m]=w,g&&(c=!0),--o===0||g)d(g);else if(!c&&a<i){let b;s?(b=s[a],a+=1,r[b](function(ee,K){f(b,ee,K)})):(b=a,a+=1,r[b](function(ee,K){f(b,ee,K)}))}}a=e,o?s?s.some(function(m,g){return r[m](function(w,b){f(m,w,b)}),g===e-1}):r.some(function(m,g){return m(function(w,b){f(g,w,b)}),g===e-1}):d(null),u=!1}});var Ai=E((Oh,xs)=>{"use strict";xs.exports=function(e){let t=e.gte!==void 0?e.gte:e.gt!==void 0?e.gt:void 0,n=e.lte!==void 0?e.lte:e.lt!==void 0?e.lt:void 0,i=e.gte===void 0,o=e.lte===void 0;return t!==void 0&&n!==void 0?IDBKeyRange.bound(t,n,i,o):t!==void 0?IDBKeyRange.lowerBound(t,i):n!==void 0?IDBKeyRange.upperBound(n,o):null}});var _i=E((Kh,vs)=>{"use strict";var pf=new TextEncoder;vs.exports=function(r){return r instanceof Uint8Array?r:r instanceof ArrayBuffer?new Uint8Array(r):pf.encode(r)}});var Ts=E(_s=>{"use strict";var{AbstractIterator:yf}=Ei(),bs=Ai(),qr=_i(),ye=Symbol("cache"),Be=Symbol("finished"),$=Symbol("options"),Se=Symbol("currentOptions"),at=Symbol("position"),Ti=Symbol("location"),kt=Symbol("first"),Es={},Bi=class extends yf{constructor(e,t,n){super(e,n),this[ye]=[],this[Be]=this.limit===0,this[$]=n,this[Se]={...n},this[at]=void 0,this[Ti]=t,this[kt]=!0}_nextv(e,t,n){if(this[kt]=!1,this[Be])return this.nextTick(n,null,[]);if(this[ye].length>0)return e=Math.min(e,this[ye].length),this.nextTick(n,null,this[ye].splice(0,e));this[at]!==void 0&&(this[$].reverse?(this[Se].lt=this[at],this[Se].lte=void 0):(this[Se].gt=this[at],this[Se].gte=void 0));let i;try{i=bs(this[Se])}catch{return this[Be]=!0,this.nextTick(n,null,[])}let o=this.db.db.transaction([this[Ti]],"readonly"),s=o.objectStore(this[Ti]),c=[];if(this[$].reverse){let u=!this[$].values&&s.openKeyCursor?"openKeyCursor":"openCursor";s[u](i,"prev").onsuccess=a=>{let d=a.target.result;if(d){let{key:f,value:m}=d;this[at]=f,c.push([this[$].keys&&f!==void 0?qr(f):void 0,this[$].values&&m!==void 0?qr(m):void 0]),c.length<e?d.continue():As(o)}else this[Be]=!0}}else{let u,a,d=()=>{if(u===void 0||a===void 0)return;let f=Math.max(u.length,a.length);f===0||e===1/0?this[Be]=!0:this[at]=u[f-1],c.length=f;for(let m=0;m<f;m++){let g=u[m],w=a[m];c[m]=[this[$].keys&&g!==void 0?qr(g):void 0,this[$].values&&w!==void 0?qr(w):void 0]}As(o)};this[$].keys||e<1/0?s.getAllKeys(i,e<1/0?e:void 0).onsuccess=f=>{u=f.target.result,d()}:(u=[],this.nextTick(d)),this[$].values?s.getAll(i,e<1/0?e:void 0).onsuccess=f=>{a=f.target.result,d()}:(a=[],this.nextTick(d))}o.onabort=()=>{n(o.error||new Error("aborted by user")),n=null},o.oncomplete=()=>{n(null,c),n=null}}_next(e){if(this[ye].length>0){let[t,n]=this[ye].shift();this.nextTick(e,null,t,n)}else if(this[Be])this.nextTick(e);else{let t=Math.min(100,this.limit-this.count);this[kt]&&(this[kt]=!1,t=1),this._nextv(t,Es,(n,i)=>{if(n)return e(n);this[ye]=i,this._next(e)})}}_all(e,t){this[kt]=!1;let n=this[ye].splice(0,this[ye].length),i=this.limit-this.count-n.length;if(i<=0)return this.nextTick(t,null,n);this._nextv(i,Es,(o,s)=>{if(o)return t(o);n.length>0&&(s=n.concat(s)),t(null,s)})}_seek(e,t){this[kt]=!0,this[ye]=[],this[Be]=!1,this[at]=void 0,this[Se]={...this[$]};let n;try{n=bs(this[$])}catch{this[Be]=!0;return}n!==null&&!n.includes(e)?this[Be]=!0:this[$].reverse?this[Se].lte=e:this[Se].gte=e}};_s.Iterator=Bi;function As(r){typeof r.commit=="function"&&r.commit()}});var Ss=E((Ph,Bs)=>{"use strict";Bs.exports=function(e,t,n,i,o){if(i.limit===0)return e.nextTick(o);let s=e.db.transaction([t],"readwrite"),c=s.objectStore(t),u=0;s.oncomplete=function(){o()},s.onabort=function(){o(s.error||new Error("aborted by user"))};let a=c.openKeyCursor?"openKeyCursor":"openCursor",d=i.reverse?"prev":"next";c[a](n,d).onsuccess=function(f){let m=f.target.result;m&&(c.delete(m.key).onsuccess=function(){(i.limit<=0||++u<i.limit)&&m.continue()})}}});var Cs=E(Ks=>{"use strict";var{AbstractLevel:mf}=Ei(),ks=re(),gf=ws(),{fromCallback:wf}=qt(),{Iterator:xf}=Ts(),Is=_i(),vf=Ss(),bf=Ai(),Os="level-js-",ir=Symbol("idb"),Si=Symbol("namePrefix"),ke=Symbol("location"),ki=Symbol("version"),ft=Symbol("store"),or=Symbol("onComplete"),Us=Symbol("promise"),Hr=class extends mf{constructor(e,t,n){if(typeof t=="function"||typeof n=="function")throw new ks("The levelup-style callback argument has been removed",{code:"LEVEL_LEGACY"});let{prefix:i,version:o,...s}=t||{};if(super({encodings:{view:!0},snapshots:!1,createIfMissing:!1,errorIfExists:!1,seek:!0},s),typeof e!="string")throw new Error("constructor requires a location string argument");this[ke]=e,this[Si]=i??Os,this[ki]=parseInt(o||1,10),this[ir]=null}get location(){return this[ke]}get namePrefix(){return this[Si]}get version(){return this[ki]}get db(){return this[ir]}get type(){return"browser-level"}_open(e,t){let n=indexedDB.open(this[Si]+this[ke],this[ki]);n.onerror=function(){t(n.error||new Error("unknown error"))},n.onsuccess=()=>{this[ir]=n.result,t()},n.onupgradeneeded=i=>{let o=i.target.result;o.objectStoreNames.contains(this[ke])||o.createObjectStore(this[ke])}}[ft](e){return this[ir].transaction([this[ke]],e).objectStore(this[ke])}[or](e,t){let n=e.transaction;n.onabort=function(){t(n.error||new Error("aborted by user"))},n.oncomplete=function(){t(null,e.result)}}_get(e,t,n){let i=this[ft]("readonly"),o;try{o=i.get(e)}catch(s){return this.nextTick(n,s)}this[or](o,function(s,c){if(s)return n(s);if(c===void 0)return n(new ks("Entry not found",{code:"LEVEL_NOT_FOUND"}));n(null,Is(c))})}_getMany(e,t,n){let i=this[ft]("readonly"),o=e.map(s=>c=>{let u;try{u=i.get(s)}catch(a){return c(a)}u.onsuccess=()=>{let a=u.result;c(null,a===void 0?a:Is(a))},u.onerror=a=>{a.stopPropagation(),c(u.error)}});gf(o,16,n)}_del(e,t,n){let i=this[ft]("readwrite"),o;try{o=i.delete(e)}catch(s){return this.nextTick(n,s)}this[or](o,n)}_put(e,t,n,i){let o=this[ft]("readwrite"),s;try{s=o.put(t,e)}catch(c){return this.nextTick(i,c)}this[or](s,i)}_iterator(e){return new xf(this,this[ke],e)}_batch(e,t,n){let i=this[ft]("readwrite"),o=i.transaction,s=0,c;o.onabort=function(){n(c||o.error||new Error("aborted by user"))},o.oncomplete=function(){n()};function u(){let a=e[s++],d=a.key,f;try{f=a.type==="del"?i.delete(d):i.put(a.value,d)}catch(m){c=m,o.abort();return}s<e.length?f.onsuccess=u:typeof o.commit=="function"&&o.commit()}u()}_clear(e,t){let n,i;try{n=bf(e)}catch{return this.nextTick(t)}if(e.limit>=0)return vf(this,this[ke],n,e,t);try{let o=this[ft]("readwrite");i=n?o.delete(n):o.clear()}catch(o){return this.nextTick(t,o)}this[or](i,t)}_close(e){this[ir].close(),this.nextTick(e)}};Hr.destroy=function(r,e,t){typeof e=="function"&&(t=e,e=Os),t=wf(t,Us);let n=indexedDB.deleteDatabase(e+r);return n.onsuccess=function(){t()},n.onerror=function(i){t(i)},t[Us]};Ks.BrowserLevel=Hr});var Ds=E(Ps=>{Ps.Level=Cs().BrowserLevel});var xe;(function(r){r.AlgorithmNotSupported="algorithmNotSupported",r.EncodingError="encodingError",r.InvalidCoseSign1="invalidCoseSign1",r.InvalidEat="invalidEat",r.InvalidJwe="invalidJwe",r.InvalidJwk="invalidJwk",r.OperationNotSupported="operationNotSupported"})(xe||(xe={}));var fu=Ji(zi(),1);var ud=new Uint8Array(0);function Wi(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function ht(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 hu(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var i=0;i<r.length;i++){var o=r.charAt(i),s=o.charCodeAt(0);if(t[s]!==255)throw new TypeError(o+" is ambiguous");t[s]=i}var c=r.length,u=r.charAt(0),a=Math.log(c)/Math.log(256),d=Math.log(256)/Math.log(c);function f(w){if(w instanceof Uint8Array||(ArrayBuffer.isView(w)?w=new Uint8Array(w.buffer,w.byteOffset,w.byteLength):Array.isArray(w)&&(w=Uint8Array.from(w))),!(w instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(w.length===0)return"";for(var b=0,ee=0,K=0,ce=w.length;K!==ce&&w[K]===0;)K++,b++;for(var ue=(ce-K)*d+1>>>0,z=new Uint8Array(ue);K!==ce;){for(var ae=w[K],Ue=0,te=ue-1;(ae!==0||Ue<ee)&&te!==-1;te--,Ue++)ae+=256*z[te]>>>0,z[te]=ae%c>>>0,ae=ae/c>>>0;if(ae!==0)throw new Error("Non-zero carry");ee=Ue,K++}for(var we=ue-ee;we!==ue&&z[we]===0;)we++;for(var hr=u.repeat(b);we<ue;++we)hr+=r.charAt(z[we]);return hr}function m(w){if(typeof w!="string")throw new TypeError("Expected String");if(w.length===0)return new Uint8Array;var b=0;if(w[b]!==" "){for(var ee=0,K=0;w[b]===u;)ee++,b++;for(var ce=(w.length-b)*a+1>>>0,ue=new Uint8Array(ce);w[b];){var z=t[w.charCodeAt(b)];if(z===255)return;for(var ae=0,Ue=ce-1;(z!==0||ae<K)&&Ue!==-1;Ue--,ae++)z+=c*ue[Ue]>>>0,ue[Ue]=z%256>>>0,z=z/256>>>0;if(z!==0)throw new Error("Non-zero carry");K=ae,b++}if(w[b]!==" "){for(var te=ce-K;te!==ce&&ue[te]===0;)te++;for(var we=new Uint8Array(ee+(ce-te)),hr=ee;te!==ce;)we[hr++]=ue[te++];return we}}}function g(w){var b=m(w);if(b)return b;throw new Error(`Non-${e} character`)}return{encode:f,decodeUnsafe:m,decode:g}}var lu=hu,pu=lu,Xi=pu;var yn=class{name;prefix;baseEncode;constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},mn=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Yi(this,e)}},gn=class{decoders;constructor(e){this.decoders=e}or(e){return Yi(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Yi(r,e){return new gn({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var wn=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,i){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=i,this.encoder=new yn(e,t,n),this.decoder=new mn(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Zi({name:r,prefix:e,encode:t,decode:n}){return new wn(r,e,t,n)}function xn({name:r,prefix:e,alphabet:t}){let{encode:n,decode:i}=Xi(t,r);return Zi({prefix:e,name:r,encode:n,decode:o=>ht(i(o))})}function yu(r,e,t,n){let i={};for(let d=0;d<e.length;++d)i[e[d]]=d;let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*t/8|0),c=0,u=0,a=0;for(let d=0;d<o;++d){let f=i[r[d]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);u=u<<t|f,c+=t,c>=8&&(c-=8,s[a++]=255&u>>c)}if(c>=t||255&u<<8-c)throw new SyntaxError("Unexpected end of data");return s}function mu(r,e,t){let n=e[e.length-1]==="=",i=(1<<t)-1,o="",s=0,c=0;for(let u=0;u<r.length;++u)for(c=c<<8|r[u],s+=8;s>t;)s-=t,o+=e[i&c>>s];if(s!==0&&(o+=e[i&c<<t-s]),n)for(;o.length*t&7;)o+="=";return o}function C({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return Zi({prefix:e,name:r,encode(i){return mu(i,n,t)},decode(i){return yu(i,n,t,r)}})}var Ct=C({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),pd=C({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),yd=C({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),md=C({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),gd=C({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),wd=C({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),xd=C({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),vd=C({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),vn=C({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var D=xn({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ad=xn({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Bd=C({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Sd=C({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),fe=C({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),kd=C({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function Qi(r){return r.byteOffset!==0||r.byteLength!==r.buffer.byteLength}function eo(r){return typeof r!="object"||r===null?!1:typeof r[Symbol.asyncIterator]=="function"}function pr(r){let t=Object.prototype.toString.call(r).match(/\s([a-zA-Z0-9]+)/),[n,i]=t;return i}var Pt=function(r,e,t,n){function i(o){return o instanceof t?o:new t(function(s){s(o)})}return new(t||(t=Promise))(function(o,s){function c(d){try{a(n.next(d))}catch(f){s(f)}}function u(d){try{a(n.throw(d))}catch(f){s(f)}}function a(d){d.done?o(d.value):i(d.value).then(c,u)}a((n=n.apply(r,e||[])).next())})},to=function(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof __values=="function"?__values(r):r[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(o){t[o]=r[o]&&function(s){return new Promise(function(c,u){s=r[o](s),i(c,u,s.done,s.value)})}}function i(o,s,c,u){Promise.resolve(u).then(function(a){o({value:a,done:c})},s)}},yr=new TextEncoder,Je=new TextDecoder,T=class r{constructor(e,t){this.data=e,this.format=t}static arrayBuffer(e){return new r(e,"ArrayBuffer")}static asyncIterable(e){if(!eo(e))throw new TypeError("Input must be of type AsyncIterable.");return new r(e,"AsyncIterable")}static base32Z(e){return new r(e,"Base32Z")}static base58Btc(e){return new r(e,"Base58Btc")}static base64Url(e){return new r(e,"Base64Url")}static bufferSource(e){return new r(e,"BufferSource")}static hex(e){if(typeof e!="string")throw new TypeError("Hex input must be a string.");if(e.length%2!==0)throw new TypeError("Hex input must have an even number of characters.");return new r(e,"Hex")}static multibase(e){return new r(e,"Multibase")}static object(e){return new r(e,"Object")}static string(e){return new r(e,"String")}static uint8Array(e){return new r(e,"Uint8Array")}toArrayBuffer(){switch(this.format){case"Base58Btc":return D.baseDecode(this.data).buffer;case"Base64Url":return fe.baseDecode(this.data).buffer;case"BufferSource":{if(pr(this.data)==="ArrayBuffer")return this.data;if(ArrayBuffer.isView(this.data))return Qi(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 Pt(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 vn.baseEncode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Base64Z is not supported.`)}}toBase58Btc(){switch(this.format){case"ArrayBuffer":{let e=new Uint8Array(this.data);return D.baseEncode(e)}case"Multibase":return this.data.substring(1);case"Uint8Array":return D.baseEncode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Base58Btc is not supported.`)}}toBase64Url(){switch(this.format){case"ArrayBuffer":{let e=new Uint8Array(this.data);return fe.baseEncode(e)}case"BufferSource":{let e=this.toUint8Array();return fe.baseEncode(e)}case"Object":{let e=JSON.stringify(this.data),t=yr.encode(e);return fe.baseEncode(t)}case"String":{let e=yr.encode(this.data);return fe.baseEncode(e)}case"Uint8Array":return fe.baseEncode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Base64Url is not supported.`)}}toBlobAsync(){return Pt(this,void 0,void 0,function*(){var e,t,n,i;switch(this.format){case"AsyncIterable":{let u=[];try{for(var o=!0,s=to(this.data),c;c=yield s.next(),e=c.done,!e;o=!0){i=c.value,o=!1;let d=i;u.push(d)}}catch(d){t={error:d}}finally{try{!o&&!e&&(n=s.return)&&(yield n.call(s))}finally{if(t)throw t.error}}return new Blob(u)}default:throw new TypeError(`Asynchronous conversion from ${this.format} to Blob is not supported.`)}})}toHex(){let e=Array.from({length:256},(t,n)=>n.toString(16).padStart(2,"0"));switch(this.format){case"ArrayBuffer":{let t=this.toUint8Array();return r.uint8Array(t).toHex()}case"Base64Url":{let t=this.toUint8Array();return r.uint8Array(t).toHex()}case"Uint8Array":{let t="";for(let n=0;n<this.data.length;n++)t+=e[this.data[n]];return t}default:throw new TypeError(`Conversion from ${this.format} to Hex is not supported.`)}}toMultibase(){switch(this.format){case"Base58Btc":return`z${this.data}`;default:throw new TypeError(`Conversion from ${this.format} to Multibase is not supported.`)}}toObject(){switch(this.format){case"Base64Url":{let e=fe.baseDecode(this.data),t=Je.decode(e);return JSON.parse(t)}case"String":return JSON.parse(this.data);case"Uint8Array":{let e=Je.decode(this.data);return JSON.parse(e)}default:throw new TypeError(`Conversion from ${this.format} to Object is not supported.`)}}toObjectAsync(){return Pt(this,void 0,void 0,function*(){switch(this.format){case"AsyncIterable":{let e=yield this.toStringAsync();return JSON.parse(e)}default:throw new TypeError(`Asynchronous conversion from ${this.format} to Object is not supported.`)}})}toString(){switch(this.format){case"ArrayBuffer":return Je.decode(this.data);case"Base64Url":{let e=fe.baseDecode(this.data);return Je.decode(e)}case"Object":return JSON.stringify(this.data);case"Uint8Array":return Je.decode(this.data);default:throw new TypeError(`Conversion from ${this.format} to String is not supported.`)}}toStringAsync(){return Pt(this,void 0,void 0,function*(){var e,t,n,i;switch(this.format){case"AsyncIterable":{let u="";try{for(var o=!0,s=to(this.data),c;c=yield s.next(),e=c.done,!e;o=!0){i=c.value,o=!1;let a=i;typeof a=="string"?u+=a:u+=Je.decode(a,{stream:!0})}}catch(a){t={error:a}}finally{try{!o&&!e&&(n=s.return)&&(yield n.call(s))}finally{if(t)throw t.error}}return u+=Je.decode(void 0,{stream:!1}),u}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 vn.baseDecode(this.data);case"Base58Btc":return D.baseDecode(this.data);case"Base64Url":return fe.baseDecode(this.data);case"BufferSource":{let e=pr(this.data);if(e==="Uint8Array")return this.data;if(e==="ArrayBuffer")return new Uint8Array(this.data);if(ArrayBuffer.isView(this.data))return new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength);throw new TypeError(`${this.format} value is not of type: ArrayBuffer, DataView, or TypedArray.`)}case"Hex":{let e=new Uint8Array(this.data.length/2);for(let t=0;t<this.data.length;t+=2){let n=parseInt(this.data.substring(t,t+2),16);if(isNaN(n))throw new TypeError("Input is not a valid hexadecimal string.");e[t/2]=n}return e}case"Object":{let e=JSON.stringify(this.data);return yr.encode(e)}case"String":return yr.encode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Uint8Array is not supported.`)}}toUint8ArrayAsync(){return Pt(this,void 0,void 0,function*(){switch(this.format){case"AsyncIterable":{let e=yield this.toArrayBufferAsync();return new Uint8Array(e)}default:throw new TypeError(`Asynchronous conversion from ${this.format} to Uint8Array is not supported.`)}})}};var Dt;(function(r){r.Debug="debug",r.Silent="silent"})(Dt||(Dt={}));var bn=class{constructor(){this.logLevel=Dt.Silent}setLogLevel(e){this.logLevel=e}log(e){this.info(e)}info(e){this.logLevel!==Dt.Silent&&console.info(e)}error(e){this.logLevel!==Dt.Silent&&console.error(e)}},gu=new bn;typeof window<"u"&&(window.web5logger=gu);var ve={};su(ve,{decode:()=>lt,encodeTo:()=>Ge,encodingLength:()=>ze});var wu=io,ro=128,xu=127,vu=~xu,bu=Math.pow(2,31);function io(r,e,t){e=e||[],t=t||0;for(var n=t;r>=bu;)e[t++]=r&255|ro,r/=128;for(;r&vu;)e[t++]=r&255|ro,r>>>=7;return e[t]=r|0,io.bytes=t-n+1,e}var Eu=En,Au=128,no=127;function En(r,n){var t=0,n=n||0,i=0,o=n,s,c=r.length;do{if(o>=c)throw En.bytes=0,new RangeError("Could not decode varint");s=r[o++],t+=i<28?(s&no)<<i:(s&no)*Math.pow(2,i),i+=7}while(s>=Au);return En.bytes=o-n,t}var _u=Math.pow(2,7),Tu=Math.pow(2,14),Bu=Math.pow(2,21),Su=Math.pow(2,28),ku=Math.pow(2,35),Iu=Math.pow(2,42),Uu=Math.pow(2,49),Ou=Math.pow(2,56),Ku=Math.pow(2,63),Cu=function(r){return r<_u?1:r<Tu?2:r<Bu?3:r<Su?4:r<ku?5:r<Iu?6:r<Uu?7:r<Ou?8:r<Ku?9:10},Pu={encode:wu,decode:Eu,encodingLength:Cu},Du=Pu,Mt=Du;function lt(r,e=0){return[Mt.decode(r,e),Mt.decode.bytes]}function Ge(r,e,t=0){return Mt.encode(r,e,t),e}function ze(r){return Mt.encodingLength(r)}function An(r,e){let t=e.byteLength,n=ze(r),i=n+ze(t),o=new Uint8Array(i+t);return Ge(r,o,0),Ge(t,o,n),o.set(e,i),new pt(r,t,e,o)}function oo(r){let e=ht(r),[t,n]=lt(e),[i,o]=lt(e.subarray(n)),s=e.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new pt(t,i,s,e)}function so(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&Wi(r.bytes,t.bytes)}}var pt=class{code;size;digest;bytes;constructor(e,t,n,i){this.code=e,this.size=t,this.digest=n,this.bytes=i}};function co(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return Nu(t,Tn(r),e??D.encoder);default:return Lu(t,Tn(r),e??Ct.encoder)}}var uo=new WeakMap;function Tn(r){let e=uo.get(r);if(e==null){let t=new Map;return uo.set(r,t),t}return e}var Bn=class r{code;version;multihash;bytes;"/";constructor(e,t,n,i){this.code=t,this.version=e,this.multihash=n,this.bytes=i,this["/"]=i}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:t}=this;if(e!==Nt)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Fu)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,n=An(e,t);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return r.equals(this,e)}static equals(e,t){let n=t;return n!=null&&e.code===n.code&&e.version===n.version&&so(e.multihash,n.multihash)}toString(e){return co(this,e)}toJSON(){return{"/":co(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:i,multihash:o,bytes:s}=t;return new r(n,i,o,s??ao(n,i,o.bytes))}else if(t[Ru]===!0){let{version:n,multihash:i,code:o}=t,s=oo(i);return r.create(n,o,s)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==Nt)throw new Error(`Version 0 CID must use dag-pb (code: ${Nt}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let i=ao(e,t,n.bytes);return new r(e,t,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,Nt,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,i=ht(e.subarray(n,n+t.multihashSize));if(i.byteLength!==t.multihashSize)throw new Error("Incorrect length");let o=i.subarray(t.multihashSize-t.digestSize),s=new pt(t.multihashCode,t.digestSize,o,i);return[t.version===0?r.createV0(s):r.createV1(t.codec,s),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[f,m]=lt(e.subarray(t));return t+=m,f},i=n(),o=Nt;if(i===18?(i=0,t=0):o=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let s=t,c=n(),u=n(),a=t+u,d=a-s;return{version:i,codec:o,multihashCode:c,digestSize:u,multihashSize:d,size:a}}static parse(e,t){let[n,i]=Mu(e,t),o=r.decode(i);if(o.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Tn(o).set(n,e),o}};function Mu(r,e){switch(r[0]){case"Q":{let t=e??D;return[D.prefix,t.decode(`${D.prefix}${r}`)]}case D.prefix:{let t=e??D;return[D.prefix,t.decode(r)]}case Ct.prefix:{let t=e??Ct;return[Ct.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function Nu(r,e,t){let{prefix:n}=t;if(n!==D.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let i=e.get(n);if(i==null){let o=t.encode(r).slice(1);return e.set(n,o),o}else return i}function Lu(r,e,t){let{prefix:n}=t,i=e.get(n);if(i==null){let o=t.encode(r);return e.set(n,o),o}else return i}var Nt=112,Fu=18;function ao(r,e,t){let n=ze(r),i=n+ze(e),o=new Uint8Array(i+t.byteLength);return Ge(r,o,0),Ge(e,o,n),o.set(t,i),o}var Ru=Symbol.for("@ipld/js-cid/CID");var L=class r{static addPrefix(e){var t;let{code:n,data:i,name:o}=e;if(!(o?!n:n))throw new Error("Either 'name' or 'code' must be defined, but not both.");if(n=r.codeToName.has(n)?n:r.nameToCode.get(o),n===void 0)throw new Error(`Unsupported multicodec: ${(t=e.name)!==null&&t!==void 0?t:e.code}`);let s=ve.encodingLength(n),c=new Uint8Array(s+i.byteLength);return c.set(i,s),ve.encodeTo(n,c),c}static getCodeFromData(e){let{prefixedData:t}=e,[n,i]=ve.decode(t);return n}static getCodeFromName(e){let{name:t}=e,n=r.nameToCode.get(t);if(n===void 0)throw new Error(`Unsupported multicodec: ${t}`);return n}static getNameFromCode(e){let{code:t}=e,n=r.codeToName.get(t);if(n===void 0)throw new Error(`Unsupported multicodec: ${t}`);return n}static registerCodec(e){r.codeToName.set(e.code,e.name),r.nameToCode.set(e.name,e.code)}static removePrefix(e){let{prefixedData:t}=e,[n,i]=ve.decode(t),o=r.codeToName.get(n);if(o===void 0)throw new Error(`Unsupported multicodec: ${n}`);return{code:n,data:t.slice(i),name:o}}};L.codeToName=new Map;L.nameToCode=new Map;L.registerCodec({code:237,name:"ed25519-pub"});L.registerCodec({code:4864,name:"ed25519-priv"});L.registerCodec({code:236,name:"x25519-pub"});L.registerCodec({code:4866,name:"x25519-priv"});L.registerCodec({code:231,name:"secp256k1-pub"});L.registerCodec({code:4865,name:"secp256k1-priv"});function Sn(r){Object.keys(r).forEach(e=>{r[e]===void 0?delete r[e]:typeof r[e]=="object"&&Sn(r[e])})}var Ef=Ji(Ds(),1);function Af(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Ii(r,...e){if(!Af(r))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(r.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${r.length}`)}function Ui(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function Ms(r,e){Ii(r);let t=e.outputLen;if(r.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}var Gr=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),oe=(r,e)=>r<<32-e|r>>>e;var Zh=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function _f(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Oi(r){return typeof r=="string"&&(r=_f(r)),Ii(r),r}var Jr=class{clone(){return this._cloneInto()}},Qh={}.toString;function Ns(r){let e=n=>r().update(Oi(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function Tf(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);let i=BigInt(32),o=BigInt(4294967295),s=Number(t>>i&o),c=Number(t&o),u=n?4:0,a=n?0:4;r.setUint32(e+u,s,n),r.setUint32(e+a,c,n)}var Ls=(r,e,t)=>r&e^~r&t,Fs=(r,e,t)=>r&e^r&t^e&t,zr=class extends Jr{constructor(e,t,n,i){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Gr(this.buffer)}update(e){Ui(this);let{view:t,buffer:n,blockLen:i}=this;e=Oi(e);let o=e.length;for(let s=0;s<o;){let c=Math.min(i-this.pos,o-s);if(c===i){let u=Gr(e);for(;i<=o-s;s+=i)this.process(u,s);continue}n.set(e.subarray(s,s+c),this.pos),this.pos+=c,s+=c,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Ui(this),Ms(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:i,isLE:o}=this,{pos:s}=this;t[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let f=s;f<i;f++)t[f]=0;Tf(n,i-8,BigInt(this.length*8),o),this.process(n,0);let c=Gr(e),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let a=u/4,d=this.get();if(a>d.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<a;f++)c.setUint32(4*f,d[f],o)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:t,buffer:n,length:i,finished:o,destroyed:s,pos:c}=this;return e.length=i,e.pos=c,e.finished=o,e.destroyed=s,i%t&&e.buffer.set(n),e}};var Bf=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),$e=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ve=new Uint32Array(64),Ki=class extends zr{constructor(){super(64,32,8,!1),this.A=$e[0]|0,this.B=$e[1]|0,this.C=$e[2]|0,this.D=$e[3]|0,this.E=$e[4]|0,this.F=$e[5]|0,this.G=$e[6]|0,this.H=$e[7]|0}get(){let{A:e,B:t,C:n,D:i,E:o,F:s,G:c,H:u}=this;return[e,t,n,i,o,s,c,u]}set(e,t,n,i,o,s,c,u){this.A=e|0,this.B=t|0,this.C=n|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=c|0,this.H=u|0}process(e,t){for(let f=0;f<16;f++,t+=4)Ve[f]=e.getUint32(t,!1);for(let f=16;f<64;f++){let m=Ve[f-15],g=Ve[f-2],w=oe(m,7)^oe(m,18)^m>>>3,b=oe(g,17)^oe(g,19)^g>>>10;Ve[f]=b+Ve[f-7]+w+Ve[f-16]|0}let{A:n,B:i,C:o,D:s,E:c,F:u,G:a,H:d}=this;for(let f=0;f<64;f++){let m=oe(c,6)^oe(c,11)^oe(c,25),g=d+m+Ls(c,u,a)+Bf[f]+Ve[f]|0,b=(oe(n,2)^oe(n,13)^oe(n,22))+Fs(n,i,o)|0;d=a,a=u,u=c,c=s+g|0,s=o,o=i,i=n,n=g+b|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,u=u+this.F|0,a=a+this.G|0,d=d+this.H|0,this.set(n,i,o,s,c,u,a,d)}roundClean(){Ve.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Rs=Ns(()=>new Ki);function $s(r){let e=n=>{if(n!==null&&typeof n=="object"&&!Array.isArray(n)){let i=Object.keys(n).sort(),o={};for(let s of i)o[s]=e(n[s]);return o}return n},t=e(r);return JSON.stringify(t)}var Sf=function(r,e,t,n){function i(o){return o instanceof t?o:new t(function(s){s(o)})}return new(t||(t=Promise))(function(o,s){function c(d){try{a(n.next(d))}catch(f){s(f)}}function u(d){try{a(n.throw(d))}catch(f){s(f)}}function a(d){d.done?o(d.value):i(d.value).then(c,u)}a((n=n.apply(r,e||[])).next())})},sr=class{static digest(e){return Sf(this,arguments,void 0,function*({data:t}){return Rs(t)})}};var kf=function(r,e,t,n){function i(o){return o instanceof t?o:new t(function(s){s(o)})}return new(t||(t=Promise))(function(o,s){function c(d){try{a(n.next(d))}catch(f){s(f)}}function u(d){try{a(n.throw(d))}catch(f){s(f)}}function a(d){d.done?o(d.value):i(d.value).then(c,u)}a((n=n.apply(r,e||[])).next())})};function V(r){return kf(this,arguments,void 0,function*({jwk:e}){let t=e.kty,n;if(t==="EC")n={crv:e.crv,kty:e.kty,x:e.x,y:e.y};else if(t==="oct")n={k:e.k,kty:e.kty};else if(t==="OKP")n={crv:e.crv,kty:e.kty,x:e.x};else if(t==="RSA")n={e:e.e,kty:e.kty,n:e.n};else throw new Error(`Unsupported key type: ${t}`);Sn(n);let i=$s(n),o=T.string(i).toUint8Array(),s=yield sr.digest({data:o});return T.uint8Array(s).toBase64Url()})}var Of=["Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function Hs(r){if(r===null)return"null";if(r===void 0)return"undefined";if(r===!0||r===!1)return"boolean";let e=typeof r;if(e==="string"||e==="number"||e==="bigint"||e==="symbol")return e;if(e==="function")return"Function";if(Array.isArray(r))return"Array";if(r instanceof Uint8Array)return"Uint8Array";if(r.constructor===Object)return"Object";let t=Kf(r);return t||"Object"}function Kf(r){let e=Object.prototype.toString.call(r).slice(8,-1);if(Of.includes(e))return e}var h=class{constructor(e,t,n){this.major=e,this.majorEncoded=e<<5,this.name=t,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:this.major>e.major?1:0}static equals(e,t){return e===t||e.major===t.major&&e.name===t.name}};h.uint=new h(0,"uint",!0);h.negint=new h(1,"negint",!0);h.bytes=new h(2,"bytes",!0);h.string=new h(3,"string",!0);h.array=new h(4,"array",!1);h.map=new h(5,"map",!1);h.tag=new h(6,"tag",!1);h.float=new h(7,"float",!0);h.false=new h(7,"false",!0);h.true=new h(7,"true",!0);h.null=new h(7,"null",!0);h.undefined=new h(7,"undefined",!0);h.break=new h(7,"break",!0);var y=class{constructor(e,t,n){this.type=e,this.value=t,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var cr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Cf=new TextEncoder;function Wr(r){return cr&&globalThis.Buffer.isBuffer(r)}function Xr(r){return r instanceof Uint8Array?Wr(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r:Uint8Array.from(r)}var Pf=24,Df=200,Pi=cr?r=>r.length>=Pf?globalThis.Buffer.from(r):Js(r):r=>r.length>=Df?Cf.encode(r):Js(r),me=r=>Uint8Array.from(r),Gs=cr?(r,e,t)=>Wr(r)?new Uint8Array(r.subarray(e,t)):r.slice(e,t):(r,e,t)=>r.slice(e,t),zs=cr?(r,e)=>(r=r.map(t=>t instanceof Uint8Array?t:globalThis.Buffer.from(t)),Xr(globalThis.Buffer.concat(r,e))):(r,e)=>{let t=new Uint8Array(e),n=0;for(let i of r)n+i.length>t.length&&(i=i.subarray(0,t.length-n)),t.set(i,n),n+=i.length;return t},Ws=cr?r=>globalThis.Buffer.allocUnsafe(r):r=>new Uint8Array(r);function Yr(r,e){if(Wr(r)&&Wr(e))return r.compare(e);for(let t=0;t<r.length;t++)if(r[t]!==e[t])return r[t]<e[t]?-1:1;return 0}function Js(r){let e=[],t=0;for(let n=0;n<r.length;n++){let i=r.charCodeAt(n);i<128?e[t++]=i:i<2048?(e[t++]=i>>6|192,e[t++]=i&63|128):(i&64512)===55296&&n+1<r.length&&(r.charCodeAt(n+1)&64512)===56320?(i=65536+((i&1023)<<10)+(r.charCodeAt(++n)&1023),e[t++]=i>>18|240,e[t++]=i>>12&63|128,e[t++]=i>>6&63|128,e[t++]=i&63|128):(i>=55296&&i<=57343&&(i=65533),e[t++]=i>>12|224,e[t++]=i>>6&63|128,e[t++]=i&63|128)}return e}var Mf=256,ur=class{constructor(e=Mf){this.chunkSize=e,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(e){let t=this.chunks[this.chunks.length-1];if(this.cursor+e.length<=this.maxCursor+1){let i=t.length-(this.maxCursor-this.cursor)-1;t.set(e,i)}else{if(t){let i=t.length-(this.maxCursor-this.cursor)-1;i<t.length&&(this.chunks[this.chunks.length-1]=t.subarray(0,i),this.maxCursor=this.cursor-1)}e.length<64&&e.length<this.chunkSize?(t=Ws(this.chunkSize),this.chunks.push(t),this.maxCursor+=t.length,this._initReuseChunk===null&&(this._initReuseChunk=t),t.set(e,0)):(this.chunks.push(e),this.maxCursor+=e.length)}this.cursor+=e.length}toBytes(e=!1){let t;if(this.chunks.length===1){let n=this.chunks[0];e&&this.cursor>n.length/2?(t=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):t=Gs(n,0,this.cursor)}else t=zs(this.chunks,this.cursor);return e&&this.reset(),t}},Zr=class{constructor(e){this.dest=e,this.cursor=0,this.chunks=[e]}reset(){this.cursor=0}push(e){if(this.cursor+e.length>this.dest.length)throw new Error("write out of bounds, destination buffer is too small");this.dest.set(e,this.cursor),this.cursor+=e.length}toBytes(e=!1){let t=this.dest.subarray(0,this.cursor);return e&&this.reset(),t}};var A="CBOR decode error:",Di="CBOR encode error:",ar=[];ar[23]=1;ar[24]=2;ar[25]=3;ar[26]=5;ar[27]=9;function Ie(r,e,t){if(r.length-e<t)throw new Error(`${A} not enough data for type`)}var S=[24,256,65536,4294967296,BigInt("18446744073709551616")];function j(r,e,t){Ie(r,e,1);let n=r[e];if(t.strict===!0&&n<S[0])throw new Error(`${A} integer encoded in more bytes than necessary (strict decode)`);return n}function q(r,e,t){Ie(r,e,2);let n=r[e]<<8|r[e+1];if(t.strict===!0&&n<S[1])throw new Error(`${A} integer encoded in more bytes than necessary (strict decode)`);return n}function H(r,e,t){Ie(r,e,4);let n=r[e]*16777216+(r[e+1]<<16)+(r[e+2]<<8)+r[e+3];if(t.strict===!0&&n<S[2])throw new Error(`${A} integer encoded in more bytes than necessary (strict decode)`);return n}function J(r,e,t){Ie(r,e,8);let n=r[e]*16777216+(r[e+1]<<16)+(r[e+2]<<8)+r[e+3],i=r[e+4]*16777216+(r[e+5]<<16)+(r[e+6]<<8)+r[e+7],o=(BigInt(n)<<BigInt(32))+BigInt(i);if(t.strict===!0&&o<S[3])throw new Error(`${A} integer encoded in more bytes than necessary (strict decode)`);if(o<=Number.MAX_SAFE_INTEGER)return Number(o);if(t.allowBigInt===!0)return o;throw new Error(`${A} integers outside of the safe integer range are not supported`)}function Xs(r,e,t,n){return new y(h.uint,j(r,e+1,n),2)}function Ys(r,e,t,n){return new y(h.uint,q(r,e+1,n),3)}function Zs(r,e,t,n){return new y(h.uint,H(r,e+1,n),5)}function Qs(r,e,t,n){return new y(h.uint,J(r,e+1,n),9)}function Z(r,e){return k(r,0,e.value)}function k(r,e,t){if(t<S[0]){let n=Number(t);r.push([e|n])}else if(t<S[1]){let n=Number(t);r.push([e|24,n])}else if(t<S[2]){let n=Number(t);r.push([e|25,n>>>8,n&255])}else if(t<S[3]){let n=Number(t);r.push([e|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(t);if(n<S[4]){let i=[e|27,0,0,0,0,0,0,0],o=Number(n&BigInt(4294967295)),s=Number(n>>BigInt(32)&BigInt(4294967295));i[8]=o&255,o=o>>8,i[7]=o&255,o=o>>8,i[6]=o&255,o=o>>8,i[5]=o&255,i[4]=s&255,s=s>>8,i[3]=s&255,s=s>>8,i[2]=s&255,s=s>>8,i[1]=s&255,r.push(i)}else throw new Error(`${A} encountered BigInt larger than allowable range`)}}Z.encodedSize=function(e){return k.encodedSize(e.value)};k.encodedSize=function(e){return e<S[0]?1:e<S[1]?2:e<S[2]?3:e<S[3]?5:9};Z.compareTokens=function(e,t){return e.value<t.value?-1:e.value>t.value?1:0};function ec(r,e,t,n){return new y(h.negint,-1-j(r,e+1,n),2)}function tc(r,e,t,n){return new y(h.negint,-1-q(r,e+1,n),3)}function rc(r,e,t,n){return new y(h.negint,-1-H(r,e+1,n),5)}var Mi=BigInt(-1),nc=BigInt(1);function ic(r,e,t,n){let i=J(r,e+1,n);if(typeof i!="bigint"){let o=-1-i;if(o>=Number.MIN_SAFE_INTEGER)return new y(h.negint,o,9)}if(n.allowBigInt!==!0)throw new Error(`${A} integers outside of the safe integer range are not supported`);return new y(h.negint,Mi-BigInt(i),9)}function Qr(r,e){let t=e.value,n=typeof t=="bigint"?t*Mi-nc:t*-1-1;k(r,e.type.majorEncoded,n)}Qr.encodedSize=function(e){let t=e.value,n=typeof t=="bigint"?t*Mi-nc:t*-1-1;return n<S[0]?1:n<S[1]?2:n<S[2]?3:n<S[3]?5:9};Qr.compareTokens=function(e,t){return e.value<t.value?1:e.value>t.value?-1:0};function fr(r,e,t,n){Ie(r,e,t+n);let i=r.slice(e+t,e+t+n);return new y(h.bytes,i,t+n)}function oc(r,e,t,n){return fr(r,e,1,t)}function sc(r,e,t,n){return fr(r,e,2,j(r,e+1,n))}function cc(r,e,t,n){return fr(r,e,3,q(r,e+1,n))}function uc(r,e,t,n){return fr(r,e,5,H(r,e+1,n))}function ac(r,e,t,n){let i=J(r,e+1,n);if(typeof i=="bigint")throw new Error(`${A} 64-bit integer bytes lengths not supported`);return fr(r,e,9,i)}function en(r){return r.encodedBytes===void 0&&(r.encodedBytes=h.equals(r.type,h.string)?Pi(r.value):r.value),r.encodedBytes}function Ut(r,e){let t=en(e);k(r,e.type.majorEncoded,t.length),r.push(t)}Ut.encodedSize=function(e){let t=en(e);return k.encodedSize(t.length)+t.length};Ut.compareTokens=function(e,t){return Lf(en(e),en(t))};function Lf(r,e){return r.length<e.length?-1:r.length>e.length?1:Yr(r,e)}var fc=new TextDecoder,Rf=32;function $f(r,e,t){if(t-e<Rf){let i="";for(let o=e;o<t;o++){let s=r[o];if(s&128)return fc.decode(r.subarray(e,t));i+=String.fromCharCode(s)}return i}return fc.decode(r.subarray(e,t))}function dr(r,e,t,n,i){let o=t+n;Ie(r,e,o);let s=new y(h.string,$f(r,e+t,e+o),o);return i.retainStringBytes===!0&&(s.byteValue=r.slice(e+t,e+o)),s}function dc(r,e,t,n){return dr(r,e,1,t,n)}function hc(r,e,t,n){return dr(r,e,2,j(r,e+1,n),n)}function lc(r,e,t,n){return dr(r,e,3,q(r,e+1,n),n)}function pc(r,e,t,n){return dr(r,e,5,H(r,e+1,n),n)}function yc(r,e,t,n){let i=J(r,e+1,n);if(typeof i=="bigint")throw new Error(`${A} 64-bit integer string lengths not supported`);return dr(r,e,9,i,n)}var mc=Ut;function Ot(r,e,t,n){return new y(h.array,n,t)}function gc(r,e,t,n){return Ot(r,e,1,t)}function wc(r,e,t,n){return Ot(r,e,2,j(r,e+1,n))}function xc(r,e,t,n){return Ot(r,e,3,q(r,e+1,n))}function vc(r,e,t,n){return Ot(r,e,5,H(r,e+1,n))}function bc(r,e,t,n){let i=J(r,e+1,n);if(typeof i=="bigint")throw new Error(`${A} 64-bit integer array lengths not supported`);return Ot(r,e,9,i)}function Ec(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${A} indefinite length items not allowed`);return Ot(r,e,1,1/0)}function tn(r,e){k(r,h.array.majorEncoded,e.value)}tn.compareTokens=Z.compareTokens;tn.encodedSize=function(e){return k.encodedSize(e.value)};function Kt(r,e,t,n){return new y(h.map,n,t)}function Ac(r,e,t,n){return Kt(r,e,1,t)}function _c(r,e,t,n){return Kt(r,e,2,j(r,e+1,n))}function Tc(r,e,t,n){return Kt(r,e,3,q(r,e+1,n))}function Bc(r,e,t,n){return Kt(r,e,5,H(r,e+1,n))}function Sc(r,e,t,n){let i=J(r,e+1,n);if(typeof i=="bigint")throw new Error(`${A} 64-bit integer map lengths not supported`);return Kt(r,e,9,i)}function kc(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${A} indefinite length items not allowed`);return Kt(r,e,1,1/0)}function rn(r,e){k(r,h.map.majorEncoded,e.value)}rn.compareTokens=Z.compareTokens;rn.encodedSize=function(e){return k.encodedSize(e.value)};function Ic(r,e,t,n){return new y(h.tag,t,1)}function Uc(r,e,t,n){return new y(h.tag,j(r,e+1,n),2)}function Oc(r,e,t,n){return new y(h.tag,q(r,e+1,n),3)}function Kc(r,e,t,n){return new y(h.tag,H(r,e+1,n),5)}function Cc(r,e,t,n){return new y(h.tag,J(r,e+1,n),9)}function nn(r,e){k(r,h.tag.majorEncoded,e.value)}nn.compareTokens=Z.compareTokens;nn.encodedSize=function(e){return k.encodedSize(e.value)};var Ni=20,Li=21,Fi=22,Ri=23;function Pc(r,e,t,n){if(n.allowUndefined===!1)throw new Error(`${A} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new y(h.null,null,1):new y(h.undefined,void 0,1)}function Dc(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${A} indefinite length items not allowed`);return new y(h.break,void 0,1)}function $i(r,e,t){if(t){if(t.allowNaN===!1&&Number.isNaN(r))throw new Error(`${A} NaN values are not supported`);if(t.allowInfinity===!1&&(r===1/0||r===-1/0))throw new Error(`${A} Infinity values are not supported`)}return new y(h.float,r,e)}function Mc(r,e,t,n){return $i(Vi(r,e+1),3,n)}function Nc(r,e,t,n){return $i(ji(r,e+1),5,n)}function Lc(r,e,t,n){return $i(Vc(r,e+1),9,n)}function on(r,e,t){let n=e.value;if(n===!1)r.push([h.float.majorEncoded|Ni]);else if(n===!0)r.push([h.float.majorEncoded|Li]);else if(n===null)r.push([h.float.majorEncoded|Fi]);else if(n===void 0)r.push([h.float.majorEncoded|Ri]);else{let i,o=!1;(!t||t.float64!==!0)&&(Rc(n),i=Vi(se,1),n===i||Number.isNaN(n)?(se[0]=249,r.push(se.slice(0,3)),o=!0):($c(n),i=ji(se,1),n===i&&(se[0]=250,r.push(se.slice(0,5)),o=!0))),o||(Jf(n),i=Vc(se,1),se[0]=251,r.push(se.slice(0,9)))}}on.encodedSize=function(e,t){let n=e.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!t||t.float64!==!0){Rc(n);let i=Vi(se,1);if(n===i||Number.isNaN(n))return 3;if($c(n),i=ji(se,1),n===i)return 5}return 9};var Fc=new ArrayBuffer(9),Q=new DataView(Fc,1),se=new Uint8Array(Fc,0);function Rc(r){if(r===1/0)Q.setUint16(0,31744,!1);else if(r===-1/0)Q.setUint16(0,64512,!1);else if(Number.isNaN(r))Q.setUint16(0,32256,!1);else{Q.setFloat32(0,r);let e=Q.getUint32(0),t=(e&2139095040)>>23,n=e&8388607;if(t===255)Q.setUint16(0,31744,!1);else if(t===0)Q.setUint16(0,(r&2147483648)>>16|n>>13,!1);else{let i=t-127;i<-24?Q.setUint16(0,0):i<-14?Q.setUint16(0,(e&2147483648)>>16|1<<24+i,!1):Q.setUint16(0,(e&2147483648)>>16|i+15<<10|n>>13,!1)}}}function Vi(r,e){if(r.length-e<2)throw new Error(`${A} not enough data for float16`);let t=(r[e]<<8)+r[e+1];if(t===31744)return 1/0;if(t===64512)return-1/0;if(t===32256)return NaN;let n=t>>10&31,i=t&1023,o;return n===0?o=i*2**-24:n!==31?o=(i+1024)*2**(n-25):o=i===0?1/0:NaN,t&32768?-o:o}function $c(r){Q.setFloat32(0,r,!1)}function ji(r,e){if(r.length-e<4)throw new Error(`${A} not enough data for float32`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,4).getFloat32(0,!1)}function Jf(r){Q.setFloat64(0,r,!1)}function Vc(r,e){if(r.length-e<8)throw new Error(`${A} not enough data for float64`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,8).getFloat64(0,!1)}on.compareTokens=Z.compareTokens;function _(r,e,t){throw new Error(`${A} encountered invalid minor (${t}) for major ${r[e]>>>5}`)}function sn(r){return()=>{throw new Error(`${A} ${r}`)}}var p=[];for(let r=0;r<=23;r++)p[r]=_;p[24]=Xs;p[25]=Ys;p[26]=Zs;p[27]=Qs;p[28]=_;p[29]=_;p[30]=_;p[31]=_;for(let r=32;r<=55;r++)p[r]=_;p[56]=ec;p[57]=tc;p[58]=rc;p[59]=ic;p[60]=_;p[61]=_;p[62]=_;p[63]=_;for(let r=64;r<=87;r++)p[r]=oc;p[88]=sc;p[89]=cc;p[90]=uc;p[91]=ac;p[92]=_;p[93]=_;p[94]=_;p[95]=sn("indefinite length bytes/strings are not supported");for(let r=96;r<=119;r++)p[r]=dc;p[120]=hc;p[121]=lc;p[122]=pc;p[123]=yc;p[124]=_;p[125]=_;p[126]=_;p[127]=sn("indefinite length bytes/strings are not supported");for(let r=128;r<=151;r++)p[r]=gc;p[152]=wc;p[153]=xc;p[154]=vc;p[155]=bc;p[156]=_;p[157]=_;p[158]=_;p[159]=Ec;for(let r=160;r<=183;r++)p[r]=Ac;p[184]=_c;p[185]=Tc;p[186]=Bc;p[187]=Sc;p[188]=_;p[189]=_;p[190]=_;p[191]=kc;for(let r=192;r<=215;r++)p[r]=Ic;p[216]=Uc;p[217]=Oc;p[218]=Kc;p[219]=Cc;p[220]=_;p[221]=_;p[222]=_;p[223]=_;for(let r=224;r<=243;r++)p[r]=sn("simple values are not supported");p[244]=_;p[245]=_;p[246]=_;p[247]=Pc;p[248]=sn("simple values are not supported");p[249]=Mc;p[250]=Nc;p[251]=Lc;p[252]=_;p[253]=_;p[254]=_;p[255]=Dc;var ge=[];for(let r=0;r<24;r++)ge[r]=new y(h.uint,r,1);for(let r=-1;r>=-24;r--)ge[31-r]=new y(h.negint,r,1);ge[64]=new y(h.bytes,new Uint8Array(0),1);ge[96]=new y(h.string,"",1);ge[128]=new y(h.array,0,1);ge[160]=new y(h.map,0,1);ge[244]=new y(h.false,!1,1);ge[245]=new y(h.true,!0,1);ge[246]=new y(h.null,null,1);function jc(r){switch(r.type){case h.false:return me([244]);case h.true:return me([245]);case h.null:return me([246]);case h.bytes:return r.value.length?void 0:me([64]);case h.string:return r.value===""?me([96]):void 0;case h.array:return r.value===0?me([128]):void 0;case h.map:return r.value===0?me([160]):void 0;case h.uint:return r.value<24?me([Number(r.value)]):void 0;case h.negint:if(r.value>=-24)return me([31-Number(r.value)])}}var Hc=Object.freeze({float64:!0,mapSorter:Zf,quickEncodeToken:jc});function zf(){let r=[];return r[h.uint.major]=Z,r[h.negint.major]=Qr,r[h.bytes.major]=Ut,r[h.string.major]=mc,r[h.array.major]=tn,r[h.map.major]=rn,r[h.tag.major]=nn,r[h.float.major]=on,r}var Wf=zf(),Xf=new ur,un=class r{constructor(e,t){this.obj=e,this.parent=t}includes(e){let t=this;do if(t.obj===e)return!0;while(t=t.parent);return!1}static createCheck(e,t){if(e&&e.includes(t))throw new Error(`${Di} object contains circular references`);return new r(t,e)}},qe={null:new y(h.null,null),undefined:new y(h.undefined,void 0),true:new y(h.true,!0),false:new y(h.false,!1),emptyArray:new y(h.array,0),emptyMap:new y(h.map,0)},He={number(r,e,t,n){return!Number.isInteger(r)||!Number.isSafeInteger(r)?new y(h.float,r):r>=0?new y(h.uint,r):new y(h.negint,r)},bigint(r,e,t,n){return r>=BigInt(0)?new y(h.uint,r):new y(h.negint,r)},Uint8Array(r,e,t,n){return new y(h.bytes,r)},string(r,e,t,n){return new y(h.string,r)},boolean(r,e,t,n){return r?qe.true:qe.false},null(r,e,t,n){return qe.null},undefined(r,e,t,n){return qe.undefined},ArrayBuffer(r,e,t,n){return new y(h.bytes,new Uint8Array(r))},DataView(r,e,t,n){return new y(h.bytes,new Uint8Array(r.buffer,r.byteOffset,r.byteLength))},Array(r,e,t,n){if(!r.length)return t.addBreakTokens===!0?[qe.emptyArray,new y(h.break)]:qe.emptyArray;n=un.createCheck(n,r);let i=[],o=0;for(let s of r)i[o++]=cn(s,t,n);return t.addBreakTokens?[new y(h.array,r.length),i,new y(h.break)]:[new y(h.array,r.length),i]},Object(r,e,t,n){let i=e!=="Object",o=i?r.keys():Object.keys(r),s=i?r.size:o.length,c;if(s){c=new Array(s),n=un.createCheck(n,r);let u=!i&&t.ignoreUndefinedProperties,a=0;for(let d of o){let f=i?r.get(d):r[d];u&&f===void 0||(c[a++]=[cn(d,t,n),cn(f,t,n)])}a<s&&(c.length=a)}return c?.length?(Yf(c,t),t.addBreakTokens?[new y(h.map,c.length),c,new y(h.break)]:[new y(h.map,c.length),c]):t.addBreakTokens===!0?[qe.emptyMap,new y(h.break)]:qe.emptyMap}};He.Map=He.Object;He.Buffer=He.Uint8Array;for(let r of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))He[`${r}Array`]=He.DataView;function cn(r,e={},t){let n=Hs(r),i=e&&e.typeEncoders&&e.typeEncoders[n]||He[n];if(typeof i=="function"){let s=i(r,n,e,t);if(s!=null)return s}let o=He[n];if(!o)throw new Error(`${Di} unsupported type: ${n}`);return o(r,n,e,t)}function Yf(r,e){e.mapSorter&&r.sort(e.mapSorter)}function Zf(r,e){if(r[0]instanceof y&&e[0]instanceof y){let t=r[0],n=e[0];return t._keyBytes||(t._keyBytes=qc(t.value)),n._keyBytes||(n._keyBytes=qc(n.value)),Yr(t._keyBytes,n._keyBytes)}throw new Error("rfc8949MapSorter: complex key types are not supported yet")}function qc(r){return Qf(r,Wf,Hc)}function Jc(r,e,t,n){if(Array.isArray(e))for(let i of e)Jc(r,i,t,n);else t[e.type.major](r,e,n)}var Xp=h.uint.majorEncoded,Yp=h.negint.majorEncoded,Zp=h.bytes.majorEncoded,Qp=h.string.majorEncoded,ey=h.array.majorEncoded,ty=h.float.majorEncoded|Ni,ry=h.float.majorEncoded|Li,ny=h.float.majorEncoded|Fi,iy=h.float.majorEncoded|Ri,oy=BigInt(-1),sy=BigInt(1);function Qf(r,e,t,n){let i=n instanceof Uint8Array,o=i?new Zr(n):Xf,s=cn(r,t);if(!Array.isArray(s)&&t.quickEncodeToken){let c=t.quickEncodeToken(s);if(c)return i?(o.push(c),o.toBytes()):c;let u=e[s.type.major];if(u.encodedSize){let a=u.encodedSize(s,t);if(i||(o=new ur(a)),u(o,s,t),o.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${s} was wrong`);return i?o.toBytes():Xr(o.chunks[0])}}return o.reset(),Jc(o,s,e,t),o.toBytes(!0)}var hy=Symbol.for("DONE"),ly=Symbol.for("BREAK");var Gc;(function(r){r[r.OKP=1]="OKP",r[r.EC2=2]="EC2",r[r.Symmetric=4]="Symmetric"})(Gc||(Gc={}));var O;(function(r){r[r.P256=1]="P256",r[r.P384=2]="P384",r[r.P521=3]="P521",r[r.X25519=4]="X25519",r[r.X448=5]="X448",r[r.Ed25519=6]="Ed25519",r[r.Ed448=7]="Ed448",r[r.Secp256k1=8]="Secp256k1"})(O||(O={}));var G;(function(r){r[r.EdDSA=-8]="EdDSA",r[r.ES256=-7]="ES256",r[r.ES384=-35]="ES384",r[r.ES512=-36]="ES512",r[r.ES256K=-47]="ES256K"})(G||(G={}));var zc;(function(r){r[r.Kty=1]="Kty",r[r.Kid=2]="Kid",r[r.Alg=3]="Alg",r[r.KeyOps=4]="KeyOps",r[r.BaseIv=5]="BaseIv"})(zc||(zc={}));var Wc;(function(r){r[r.Crv=-1]="Crv",r[r.X=-2]="X",r[r.Y=-3]="Y",r[r.D=-4]="D"})(Wc||(Wc={}));var Sy={"P-256":O.P256,"P-384":O.P384,"P-521":O.P521,X25519:O.X25519,Ed25519:O.Ed25519,Ed448:O.Ed448,secp256k1:O.Secp256k1},ky={[O.P256]:"P-256",[O.P384]:"P-384",[O.P521]:"P-521",[O.X25519]:"X25519",[O.Ed25519]:"Ed25519",[O.Ed448]:"Ed448",[O.Secp256k1]:"secp256k1"},Iy={EdDSA:G.EdDSA,ES256:G.ES256,ES384:G.ES384,ES512:G.ES512,ES256K:G.ES256K},Uy={[G.EdDSA]:"EdDSA",[G.ES256]:"ES256",[G.ES384]:"ES384",[G.ES512]:"ES512",[G.ES256K]:"ES256K"};var Xc;(function(r){r[r.Alg=1]="Alg",r[r.Crit=2]="Crit",r[r.ContentType=3]="ContentType",r[r.Kid=4]="Kid"})(Xc||(Xc={}));var Yc;(function(r){r[r.Iss=1]="Iss",r[r.Sub=2]="Sub",r[r.Aud=3]="Aud",r[r.Exp=4]="Exp",r[r.Nbf=5]="Nbf",r[r.Iat=6]="Iat",r[r.Cti=7]="Cti",r[r.Nonce=10]="Nonce",r[r.Ueid=256]="Ueid",r[r.Sueids=257]="Sueids",r[r.Oemid=258]="Oemid",r[r.Hwmodel=259]="Hwmodel",r[r.Hwversion=260]="Hwversion",r[r.Secboot=262]="Secboot",r[r.Dbgstat=263]="Dbgstat",r[r.Location=264]="Location",r[r.Profile=265]="Profile",r[r.Submods=266]="Submods",r[r.Measres=272]="Measres",r[r.Intuse=268]="Intuse"})(Yc||(Yc={}));var Zc;(function(r){r[r.Enabled=0]="Enabled",r[r.Disabled=1]="Disabled",r[r.DisabledSinceBoot=2]="DisabledSinceBoot",r[r.DisabledPermanently=3]="DisabledPermanently",r[r.DisabledFullyAndPermanently=4]="DisabledFullyAndPermanently"})(Zc||(Zc={}));var Qc;(function(r){r[r.Unrestricted=1]="Unrestricted",r[r.Restricted=2]="Restricted",r[r.SecureRestricted=3]="SecureRestricted",r[r.Hardware=4]="Hardware"})(Qc||(Qc={}));var fn=(o=>(o.authentication="authentication",o.assertionMethod="assertionMethod",o.keyAgreement="keyAgreement",o.capabilityInvocation="capabilityInvocation",o.capabilityDelegation="capabilityDelegation",o))(fn||{});var dn=class r extends Error{constructor(t,n){super(`${t}: ${n}`);this.code=t;this.name="DidError",Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,r)}};function qi(r){if(typeof r=="string"&&r.length!==0)return r.split("#").pop()}function Eg({didDocument:r,id:e,type:t}){return r?.service?.filter(n=>!(e&&n.id!==e||t&&n.type!==t))??[]}async function Ag({didDocument:r,publicKeyJwk:e,publicKeyMultibase:t}){let n=eu({didDocument:r});for(let i of n)if(e&&i.publicKeyJwk){if(await V({jwk:e})===await V({jwk:i.publicKeyJwk}))return i}else if(t&&i.publicKeyMultibase&&t===i.publicKeyMultibase)return i;return null}function eu({didDocument:r}){if(!r)throw new TypeError("Required parameter missing: 'didDocument'");let e=[];return e.push(...r.verificationMethod?.filter(Hi)??[]),Object.keys(fn).forEach(t=>{e.push(...r[t]?.filter(Hi)??[])}),e}function _g({didDocument:r}){let t=eu({didDocument:r}).map(n=>n.type);return[...new Set(t)]}function Tg({didDocument:r,methodId:e}){let t=[];return Object.keys(fn).forEach(n=>{if(Array.isArray(r[n])){let i=r[n],o=qi(e);i.some(c=>{let u=qi(c)===o,a=Hi(c)&&qi(c.id)===o;return u||a})&&t.push(n)}}),t}function nd(r){return!r||typeof r!="object"||r===null?!1:"id"in r&&"type"in r&&"serviceEndpoint"in r}function Bg(r){if(!nd(r)||r.type!=="DecentralizedWebNode")return!1;let e=t=>typeof t=="string"||Array.isArray(t)&&t.every(n=>typeof n=="string");return!("enc"in r&&r.enc!==void 0&&!e(r.enc)||"sig"in r&&r.sig!==void 0&&!e(r.sig))}function Hi(r){return!(!r||typeof r!="object"||r===null||!("id"in r&&"type"in r&&"controller"in r)||typeof r.id!="string"||typeof r.type!="string"||typeof r.controller!="string")}function Sg(r){return!(!r||typeof r!="object"||r===null)&&"uri"in r&&"document"in r&&"metadata"in r&&(!("keyManager"in r)||r.keyManager===void 0)}function kg({keyBytes:r,multicodecCode:e,multicodecName:t}){let n=L.addPrefix({code:e,data:r,name:t}),i=T.uint8Array(n).toBase58Btc();return T.base58Btc(i).toMultibase()}function Ig({multibaseKeyId:r}){try{let e=T.multibase(r).toBase58Btc(),t=T.base58Btc(e).toUint8Array(),{code:n,data:i,name:o}=L.removePrefix({prefixedData:t});return{keyBytes:i,multicodecCode:n,multicodecName:o}}catch{throw new dn("invalidDid",`Invalid multibase identifier: ${r}`)}}export{qi as extractDidFragment,Eg as getServices,Ag as getVerificationMethodByKey,_g as getVerificationMethodTypes,eu as getVerificationMethods,Tg as getVerificationRelationshipsById,nd as isDidService,Hi as isDidVerificationMethod,Bg as isDwnDidService,Sg as isPortableDid,kg as keyBytesToMultibaseId,Ig as multibaseIdToKeyBytes};
|
|
2
2
|
/*! Bundled license information:
|
|
3
3
|
|
|
4
4
|
ieee754/index.js:
|