@enbox/dids 0.0.2 → 0.0.4

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.
Files changed (78) hide show
  1. package/README.md +41 -1
  2. package/dist/browser.mjs +6 -10
  3. package/dist/browser.mjs.map +4 -4
  4. package/dist/esm/bearer-did.js +5 -5
  5. package/dist/esm/bearer-did.js.map +1 -1
  6. package/dist/esm/did.js +13 -6
  7. package/dist/esm/did.js.map +1 -1
  8. package/dist/esm/index.js +2 -0
  9. package/dist/esm/index.js.map +1 -1
  10. package/dist/esm/methods/did-dht.js +34 -25
  11. package/dist/esm/methods/did-dht.js.map +1 -1
  12. package/dist/esm/methods/did-ion.js +9 -7
  13. package/dist/esm/methods/did-ion.js.map +1 -1
  14. package/dist/esm/methods/did-jwk.js +3 -3
  15. package/dist/esm/methods/did-jwk.js.map +1 -1
  16. package/dist/esm/methods/did-key.js +12 -240
  17. package/dist/esm/methods/did-key.js.map +1 -1
  18. package/dist/esm/methods/did-web.js +3 -2
  19. package/dist/esm/methods/did-web.js.map +1 -1
  20. package/dist/esm/resolver/resolver-cache-level.js +1 -1
  21. package/dist/esm/resolver/resolver-cache-level.js.map +1 -1
  22. package/dist/esm/resolver/resolver-cache-memory.js +77 -0
  23. package/dist/esm/resolver/resolver-cache-memory.js.map +1 -0
  24. package/dist/esm/resolver/resolver-cache-noop.js +10 -10
  25. package/dist/esm/resolver/resolver-cache-noop.js.map +1 -1
  26. package/dist/esm/resolver/universal-resolver.js +3 -3
  27. package/dist/esm/resolver/universal-resolver.js.map +1 -1
  28. package/dist/esm/utils.js +62 -21
  29. package/dist/esm/utils.js.map +1 -1
  30. package/dist/types/bearer-did.d.ts +6 -5
  31. package/dist/types/bearer-did.d.ts.map +1 -1
  32. package/dist/types/did.d.ts.map +1 -1
  33. package/dist/types/index.d.ts +2 -0
  34. package/dist/types/index.d.ts.map +1 -1
  35. package/dist/types/methods/did-dht.d.ts +6 -6
  36. package/dist/types/methods/did-dht.d.ts.map +1 -1
  37. package/dist/types/methods/did-ion.d.ts +6 -5
  38. package/dist/types/methods/did-ion.d.ts.map +1 -1
  39. package/dist/types/methods/did-jwk.d.ts +5 -5
  40. package/dist/types/methods/did-jwk.d.ts.map +1 -1
  41. package/dist/types/methods/did-key.d.ts +6 -55
  42. package/dist/types/methods/did-key.d.ts.map +1 -1
  43. package/dist/types/methods/did-method.d.ts +5 -5
  44. package/dist/types/methods/did-method.d.ts.map +1 -1
  45. package/dist/types/resolver/resolver-cache-level.d.ts.map +1 -1
  46. package/dist/types/resolver/resolver-cache-memory.d.ts +58 -0
  47. package/dist/types/resolver/resolver-cache-memory.d.ts.map +1 -0
  48. package/dist/types/resolver/universal-resolver.d.ts +2 -2
  49. package/dist/types/resolver/universal-resolver.d.ts.map +1 -1
  50. package/dist/types/types/did-core.d.ts +1 -1
  51. package/dist/types/types/did-core.d.ts.map +1 -1
  52. package/dist/types/utils.d.ts +27 -5
  53. package/dist/types/utils.d.ts.map +1 -1
  54. package/dist/utils.js +1 -5
  55. package/dist/utils.js.map +4 -4
  56. package/package.json +35 -47
  57. package/src/bearer-did.ts +15 -14
  58. package/src/did.ts +8 -6
  59. package/src/index.ts +2 -0
  60. package/src/methods/did-dht.ts +37 -37
  61. package/src/methods/did-ion.ts +23 -15
  62. package/src/methods/did-jwk.ts +9 -9
  63. package/src/methods/did-key.ts +29 -310
  64. package/src/methods/did-method.ts +6 -6
  65. package/src/methods/did-web.ts +2 -2
  66. package/src/resolver/resolver-cache-level.ts +4 -4
  67. package/src/resolver/resolver-cache-memory.ts +84 -0
  68. package/src/resolver/resolver-cache-noop.ts +10 -10
  69. package/src/resolver/universal-resolver.ts +5 -5
  70. package/src/types/did-core.ts +3 -3
  71. package/src/utils.ts +55 -26
  72. package/dist/browser.js +0 -77
  73. package/dist/browser.js.map +0 -7
  74. package/dist/cjs/index.js +0 -6303
  75. package/dist/cjs/index.js.map +0 -7
  76. package/dist/cjs/package.json +0 -1
  77. package/dist/cjs/utils.js +0 -245
  78. package/dist/cjs/utils.js.map +0 -7
package/dist/utils.js CHANGED
@@ -1,5 +1,4 @@
1
- var wd=Object.create;var vi=Object.defineProperty;var gd=Object.getOwnPropertyDescriptor;var bd=Object.getOwnPropertyNames;var md=Object.getPrototypeOf,xd=Object.prototype.hasOwnProperty;var m=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Ed=(t,e)=>{for(var r in e)vi(t,r,{get:e[r],enumerable:!0})},_d=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of bd(e))!xd.call(t,i)&&i!==r&&vi(t,i,{get:()=>e[i],enumerable:!(n=gd(e,i))||n.enumerable});return t};var c=(t,e,r)=>(r=t!=null?wd(md(t)):{},_d(e||!t||!t.__esModule?vi(r,"default",{value:t,enumerable:!0}):r,t));var fa=m(on=>{"use strict";var g0=c(f());on.byteLength=Sd;on.toByteArray=Td;on.fromByteArray=kd;var we=[],ie=[],vd=typeof Uint8Array<"u"?Uint8Array:Array,Si="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(ct=0,ua=Si.length;ct<ua;++ct)we[ct]=Si[ct],ie[Si.charCodeAt(ct)]=ct;var ct,ua;ie[45]=62;ie[95]=63;function ca(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var n=r===e?0:4-r%4;return[r,n]}function Sd(t){var e=ca(t),r=e[0],n=e[1];return(r+n)*3/4-n}function Ad(t,e,r){return(e+r)*3/4-r}function Td(t){var e,r=ca(t),n=r[0],i=r[1],o=new vd(Ad(t,n,i)),s=0,a=i>0?n-4:n,l;for(l=0;l<a;l+=4)e=ie[t.charCodeAt(l)]<<18|ie[t.charCodeAt(l+1)]<<12|ie[t.charCodeAt(l+2)]<<6|ie[t.charCodeAt(l+3)],o[s++]=e>>16&255,o[s++]=e>>8&255,o[s++]=e&255;return i===2&&(e=ie[t.charCodeAt(l)]<<2|ie[t.charCodeAt(l+1)]>>4,o[s++]=e&255),i===1&&(e=ie[t.charCodeAt(l)]<<10|ie[t.charCodeAt(l+1)]<<4|ie[t.charCodeAt(l+2)]>>2,o[s++]=e>>8&255,o[s++]=e&255),o}function Bd(t){return we[t>>18&63]+we[t>>12&63]+we[t>>6&63]+we[t&63]}function Id(t,e,r){for(var n,i=[],o=e;o<r;o+=3)n=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(t[o+2]&255),i.push(Bd(n));return i.join("")}function kd(t){for(var e,r=t.length,n=r%3,i=[],o=16383,s=0,a=r-n;s<a;s+=o)i.push(Id(t,s,s+o>a?a:s+o));return n===1?(e=t[r-1],i.push(we[e>>2]+we[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(we[e>>10]+we[e>>4&63]+we[e<<2&63]+"=")),i.join("")}});var la=m(Ai=>{var m0=c(f());Ai.read=function(t,e,r,n,i){var o,s,a=i*8-n-1,l=(1<<a)-1,u=l>>1,d=-7,h=r?i-1:0,g=r?-1:1,y=t[e+h];for(h+=g,o=y&(1<<-d)-1,y>>=-d,d+=a;d>0;o=o*256+t[e+h],h+=g,d-=8);for(s=o&(1<<-d)-1,o>>=-d,d+=n;d>0;s=s*256+t[e+h],h+=g,d-=8);if(o===0)o=1-u;else{if(o===l)return s?NaN:(y?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-u}return(y?-1:1)*s*Math.pow(2,o-n)};Ai.write=function(t,e,r,n,i,o){var s,a,l,u=o*8-i-1,d=(1<<u)-1,h=d>>1,g=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,y=n?0:o-1,b=n?1:-1,w=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=d):(s=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-s))<1&&(s--,l*=2),s+h>=1?e+=g/l:e+=g*Math.pow(2,1-h),e*l>=2&&(s++,l/=2),s+h>=d?(a=0,s=d):s+h>=1?(a=(e*l-1)*Math.pow(2,i),s=s+h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;t[r+y]=a&255,y+=b,a/=256,i-=8);for(s=s<<i|a,u+=i;u>0;t[r+y]=s&255,y+=b,s/=256,u-=8);t[r+y-b]|=w*128}});var X=m($t=>{"use strict";var _0=c(f());var Ti=fa(),qt=la(),da=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;$t.Buffer=p;$t.SlowBuffer=Pd;$t.INSPECT_MAX_BYTES=50;var sn=2147483647;$t.kMaxLength=sn;p.TYPED_ARRAY_SUPPORT=Rd();!p.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 Rd(){try{let t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),t.foo()===42}catch{return!1}}Object.defineProperty(p.prototype,"parent",{enumerable:!0,get:function(){if(p.isBuffer(this))return this.buffer}});Object.defineProperty(p.prototype,"offset",{enumerable:!0,get:function(){if(p.isBuffer(this))return this.byteOffset}});function Oe(t){if(t>sn)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,p.prototype),e}function p(t,e,r){if(typeof t=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Ri(t)}return wa(t,e,r)}p.poolSize=8192;function wa(t,e,r){if(typeof t=="string")return Ld(t,e);if(ArrayBuffer.isView(t))return Cd(t);if(t==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(ge(t,ArrayBuffer)||t&&ge(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(ge(t,SharedArrayBuffer)||t&&ge(t.buffer,SharedArrayBuffer)))return Ii(t,e,r);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=t.valueOf&&t.valueOf();if(n!=null&&n!==t)return p.from(n,e,r);let i=Dd(t);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return p.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}p.from=function(t,e,r){return wa(t,e,r)};Object.setPrototypeOf(p.prototype,Uint8Array.prototype);Object.setPrototypeOf(p,Uint8Array);function ga(t){if(typeof t!="number")throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function Od(t,e,r){return ga(t),t<=0?Oe(t):e!==void 0?typeof r=="string"?Oe(t).fill(e,r):Oe(t).fill(e):Oe(t)}p.alloc=function(t,e,r){return Od(t,e,r)};function Ri(t){return ga(t),Oe(t<0?0:Oi(t)|0)}p.allocUnsafe=function(t){return Ri(t)};p.allocUnsafeSlow=function(t){return Ri(t)};function Ld(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!p.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=ba(t,e)|0,n=Oe(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function Bi(t){let e=t.length<0?0:Oi(t.length)|0,r=Oe(e);for(let n=0;n<e;n+=1)r[n]=t[n]&255;return r}function Cd(t){if(ge(t,Uint8Array)){let e=new Uint8Array(t);return Ii(e.buffer,e.byteOffset,e.byteLength)}return Bi(t)}function Ii(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return e===void 0&&r===void 0?n=new Uint8Array(t):r===void 0?n=new Uint8Array(t,e):n=new Uint8Array(t,e,r),Object.setPrototypeOf(n,p.prototype),n}function Dd(t){if(p.isBuffer(t)){let e=Oi(t.length)|0,r=Oe(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||Ci(t.length)?Oe(0):Bi(t);if(t.type==="Buffer"&&Array.isArray(t.data))return Bi(t.data)}function Oi(t){if(t>=sn)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+sn.toString(16)+" bytes");return t|0}function Pd(t){return+t!=t&&(t=0),p.alloc(+t)}p.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==p.prototype};p.compare=function(e,r){if(ge(e,Uint8Array)&&(e=p.from(e,e.offset,e.byteLength)),ge(r,Uint8Array)&&(r=p.from(r,r.offset,r.byteLength)),!p.isBuffer(e)||!p.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===r)return 0;let n=e.length,i=r.length;for(let o=0,s=Math.min(n,i);o<s;++o)if(e[o]!==r[o]){n=e[o],i=r[o];break}return n<i?-1:i<n?1:0};p.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}};p.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return p.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;let i=p.allocUnsafe(r),o=0;for(n=0;n<e.length;++n){let s=e[n];if(ge(s,Uint8Array))o+s.length>i.length?(p.isBuffer(s)||(s=p.from(s)),s.copy(i,o)):Uint8Array.prototype.set.call(i,s,o);else if(p.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function ba(t,e){if(p.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||ge(t,ArrayBuffer))return t.byteLength;if(typeof t!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);let r=t.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return ki(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Ba(t).length;default:if(i)return n?-1:ki(t).length;e=(""+e).toLowerCase(),i=!0}}p.byteLength=ba;function Ud(t,e,r){let n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,e>>>=0,r<=e))return"";for(t||(t="utf8");;)switch(t){case"hex":return Hd(this,e,r);case"utf8":case"utf-8":return xa(this,e,r);case"ascii":return Vd(this,e,r);case"latin1":case"binary":return Wd(this,e,r);case"base64":return jd(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Gd(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}p.prototype._isBuffer=!0;function ft(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}p.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<e;r+=2)ft(this,r,r+1);return this};p.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<e;r+=4)ft(this,r,r+3),ft(this,r+1,r+2);return this};p.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<e;r+=8)ft(this,r,r+7),ft(this,r+1,r+6),ft(this,r+2,r+5),ft(this,r+3,r+4);return this};p.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?xa(this,0,e):Ud.apply(this,arguments)};p.prototype.toLocaleString=p.prototype.toString;p.prototype.equals=function(e){if(!p.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:p.compare(this,e)===0};p.prototype.inspect=function(){let e="",r=$t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};da&&(p.prototype[da]=p.prototype.inspect);p.prototype.compare=function(e,r,n,i,o){if(ge(e,Uint8Array)&&(e=p.from(e,e.offset,e.byteLength)),!p.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(r===void 0&&(r=0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),r<0||n>e.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&r>=n)return 0;if(i>=o)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,o>>>=0,this===e)return 0;let s=o-i,a=n-r,l=Math.min(s,a),u=this.slice(i,o),d=e.slice(r,n);for(let h=0;h<l;++h)if(u[h]!==d[h]){s=u[h],a=d[h];break}return s<a?-1:a<s?1:0};function ma(t,e,r,n,i){if(t.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,Ci(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof e=="string"&&(e=p.from(e,n)),p.isBuffer(e))return e.length===0?-1:ha(t,e,r,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):ha(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ha(t,e,r,n,i){let o=1,s=t.length,a=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||e.length<2)return-1;o=2,s/=2,a/=2,r/=2}function l(d,h){return o===1?d[h]:d.readUInt16BE(h*o)}let u;if(i){let d=-1;for(u=r;u<s;u++)if(l(t,u)===l(e,d===-1?0:u-d)){if(d===-1&&(d=u),u-d+1===a)return d*o}else d!==-1&&(u-=u-d),d=-1}else for(r+a>s&&(r=s-a),u=r;u>=0;u--){let d=!0;for(let h=0;h<a;h++)if(l(t,u+h)!==l(e,h)){d=!1;break}if(d)return u}return-1}p.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};p.prototype.indexOf=function(e,r,n){return ma(this,e,r,n,!0)};p.prototype.lastIndexOf=function(e,r,n){return ma(this,e,r,n,!1)};function Md(t,e,r,n){r=Number(r)||0;let i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let o=e.length;n>o/2&&(n=o/2);let s;for(s=0;s<n;++s){let a=parseInt(e.substr(s*2,2),16);if(Ci(a))return s;t[r+s]=a}return s}function Nd(t,e,r,n){return an(ki(e,t.length-r),t,r,n)}function Kd(t,e,r,n){return an(Xd(e),t,r,n)}function Fd(t,e,r,n){return an(Ba(e),t,r,n)}function qd(t,e,r,n){return an(Zd(e,t.length-r),t,r,n)}p.prototype.write=function(e,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-r;if((n===void 0||n>o)&&(n=o),e.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let s=!1;for(;;)switch(i){case"hex":return Md(this,e,r,n);case"utf8":case"utf-8":return Nd(this,e,r,n);case"ascii":case"latin1":case"binary":return Kd(this,e,r,n);case"base64":return Fd(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return qd(this,e,r,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};p.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function jd(t,e,r){return e===0&&r===t.length?Ti.fromByteArray(t):Ti.fromByteArray(t.slice(e,r))}function xa(t,e,r){r=Math.min(t.length,r);let n=[],i=e;for(;i<r;){let o=t[i],s=null,a=o>239?4:o>223?3:o>191?2:1;if(i+a<=r){let l,u,d,h;switch(a){case 1:o<128&&(s=o);break;case 2:l=t[i+1],(l&192)===128&&(h=(o&31)<<6|l&63,h>127&&(s=h));break;case 3:l=t[i+1],u=t[i+2],(l&192)===128&&(u&192)===128&&(h=(o&15)<<12|(l&63)<<6|u&63,h>2047&&(h<55296||h>57343)&&(s=h));break;case 4:l=t[i+1],u=t[i+2],d=t[i+3],(l&192)===128&&(u&192)===128&&(d&192)===128&&(h=(o&15)<<18|(l&63)<<12|(u&63)<<6|d&63,h>65535&&h<1114112&&(s=h))}}s===null?(s=65533,a=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),i+=a}return $d(n)}var pa=4096;function $d(t){let e=t.length;if(e<=pa)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=pa));return r}function Vd(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]&127);return n}function Wd(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function Hd(t,e,r){let n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let o=e;o<r;++o)i+=Qd[t[o]];return i}function Gd(t,e,r){let n=t.slice(e,r),i="";for(let o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}p.prototype.slice=function(e,r){let n=this.length;e=~~e,r=r===void 0?n:~~r,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<e&&(r=e);let i=this.subarray(e,r);return Object.setPrototypeOf(i,p.prototype),i};function q(t,e,r){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}p.prototype.readUintLE=p.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||q(e,r,this.length);let i=this[e],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[e+s]*o;return i};p.prototype.readUintBE=p.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||q(e,r,this.length);let i=this[e+--r],o=1;for(;r>0&&(o*=256);)i+=this[e+--r]*o;return i};p.prototype.readUint8=p.prototype.readUInt8=function(e,r){return e=e>>>0,r||q(e,1,this.length),this[e]};p.prototype.readUint16LE=p.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||q(e,2,this.length),this[e]|this[e+1]<<8};p.prototype.readUint16BE=p.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||q(e,2,this.length),this[e]<<8|this[e+1]};p.prototype.readUint32LE=p.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||q(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};p.prototype.readUint32BE=p.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||q(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};p.prototype.readBigUInt64LE=Ge(function(e){e=e>>>0,jt(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&mr(e,this.length-8);let i=r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,o=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(i)+(BigInt(o)<<BigInt(32))});p.prototype.readBigUInt64BE=Ge(function(e){e=e>>>0,jt(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&mr(e,this.length-8);let i=r*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],o=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(o)});p.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||q(e,r,this.length);let i=this[e],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[e+s]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*r)),i};p.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||q(e,r,this.length);let i=r,o=1,s=this[e+--i];for(;i>0&&(o*=256);)s+=this[e+--i]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*r)),s};p.prototype.readInt8=function(e,r){return e=e>>>0,r||q(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};p.prototype.readInt16LE=function(e,r){e=e>>>0,r||q(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};p.prototype.readInt16BE=function(e,r){e=e>>>0,r||q(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};p.prototype.readInt32LE=function(e,r){return e=e>>>0,r||q(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};p.prototype.readInt32BE=function(e,r){return e=e>>>0,r||q(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};p.prototype.readBigInt64LE=Ge(function(e){e=e>>>0,jt(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&mr(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});p.prototype.readBigInt64BE=Ge(function(e){e=e>>>0,jt(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&mr(e,this.length-8);let i=(r<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(i)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)});p.prototype.readFloatLE=function(e,r){return e=e>>>0,r||q(e,4,this.length),qt.read(this,e,!0,23,4)};p.prototype.readFloatBE=function(e,r){return e=e>>>0,r||q(e,4,this.length),qt.read(this,e,!1,23,4)};p.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||q(e,8,this.length),qt.read(this,e,!0,52,8)};p.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||q(e,8,this.length),qt.read(this,e,!1,52,8)};function Y(t,e,r,n,i,o){if(!p.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}p.prototype.writeUintLE=p.prototype.writeUIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;Y(this,e,r,n,a,0)}let o=1,s=0;for(this[r]=e&255;++s<n&&(o*=256);)this[r+s]=e/o&255;return r+n};p.prototype.writeUintBE=p.prototype.writeUIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;Y(this,e,r,n,a,0)}let o=n-1,s=1;for(this[r+o]=e&255;--o>=0&&(s*=256);)this[r+o]=e/s&255;return r+n};p.prototype.writeUint8=p.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||Y(this,e,r,1,255,0),this[r]=e&255,r+1};p.prototype.writeUint16LE=p.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||Y(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};p.prototype.writeUint16BE=p.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||Y(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};p.prototype.writeUint32LE=p.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||Y(this,e,r,4,4294967295,0),this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=e&255,r+4};p.prototype.writeUint32BE=p.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||Y(this,e,r,4,4294967295,0),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};function Ea(t,e,r,n,i){Ta(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s,r}function _a(t,e,r,n,i){Ta(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o=o>>8,t[r+6]=o,o=o>>8,t[r+5]=o,o=o>>8,t[r+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=s,s=s>>8,t[r+2]=s,s=s>>8,t[r+1]=s,s=s>>8,t[r]=s,r+8}p.prototype.writeBigUInt64LE=Ge(function(e,r=0){return Ea(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});p.prototype.writeBigUInt64BE=Ge(function(e,r=0){return _a(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});p.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let l=Math.pow(2,8*n-1);Y(this,e,r,n,l-1,-l)}let o=0,s=1,a=0;for(this[r]=e&255;++o<n&&(s*=256);)e<0&&a===0&&this[r+o-1]!==0&&(a=1),this[r+o]=(e/s>>0)-a&255;return r+n};p.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let l=Math.pow(2,8*n-1);Y(this,e,r,n,l-1,-l)}let o=n-1,s=1,a=0;for(this[r+o]=e&255;--o>=0&&(s*=256);)e<0&&a===0&&this[r+o+1]!==0&&(a=1),this[r+o]=(e/s>>0)-a&255;return r+n};p.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||Y(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};p.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||Y(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};p.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||Y(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};p.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||Y(this,e,r,4,2147483647,-2147483648),this[r]=e&255,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24,r+4};p.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||Y(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};p.prototype.writeBigInt64LE=Ge(function(e,r=0){return Ea(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});p.prototype.writeBigInt64BE=Ge(function(e,r=0){return _a(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function va(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Sa(t,e,r,n,i){return e=+e,r=r>>>0,i||va(t,e,r,4,34028234663852886e22,-34028234663852886e22),qt.write(t,e,r,n,23,4),r+4}p.prototype.writeFloatLE=function(e,r,n){return Sa(this,e,r,!0,n)};p.prototype.writeFloatBE=function(e,r,n){return Sa(this,e,r,!1,n)};function Aa(t,e,r,n,i){return e=+e,r=r>>>0,i||va(t,e,r,8,17976931348623157e292,-17976931348623157e292),qt.write(t,e,r,n,52,8),r+8}p.prototype.writeDoubleLE=function(e,r,n){return Aa(this,e,r,!0,n)};p.prototype.writeDoubleBE=function(e,r,n){return Aa(this,e,r,!1,n)};p.prototype.copy=function(e,r,n,i){if(!p.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=e.length&&(r=e.length),r||(r=0),i>0&&i<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-r<i-n&&(i=e.length-r+n);let o=i-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(e,this.subarray(n,i),r),o};p.prototype.fill=function(e,r,n,i){if(typeof e=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!p.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(e.length===1){let s=e.charCodeAt(0);(i==="utf8"&&s<128||i==="latin1")&&(e=s)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let o;if(typeof e=="number")for(o=r;o<n;++o)this[o]=e;else{let s=p.isBuffer(e)?e:p.from(e,i),a=s.length;if(a===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<n-r;++o)this[o+r]=s[o%a]}return this};var Ft={};function Li(t,e,r){Ft[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}Li("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Li("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);Li("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=ya(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=ya(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function ya(t){let e="",r=t.length,n=t[0]==="-"?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function Jd(t,e,r){jt(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&mr(e,t.length-(r+1))}function Ta(t,e,r,n,i,o){if(t>r||t<e){let s=typeof e=="bigint"?"n":"",a;throw o>3?e===0||e===BigInt(0)?a=`>= 0${s} and < 2${s} ** ${(o+1)*8}${s}`:a=`>= -(2${s} ** ${(o+1)*8-1}${s}) and < 2 ** ${(o+1)*8-1}${s}`:a=`>= ${e}${s} and <= ${r}${s}`,new Ft.ERR_OUT_OF_RANGE("value",a,t)}Jd(n,i,o)}function jt(t,e){if(typeof t!="number")throw new Ft.ERR_INVALID_ARG_TYPE(e,"number",t)}function mr(t,e,r){throw Math.floor(t)!==t?(jt(t,r),new Ft.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new Ft.ERR_BUFFER_OUT_OF_BOUNDS:new Ft.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var zd=/[^+/0-9A-Za-z-_]/g;function Yd(t){if(t=t.split("=")[0],t=t.trim().replace(zd,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function ki(t,e){e=e||1/0;let r,n=t.length,i=null,o=[];for(let s=0;s<n;++s){if(r=t.charCodeAt(s),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}else if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return o}function Xd(t){let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function Zd(t,e){let r,n,i,o=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}function Ba(t){return Ti.toByteArray(Yd(t))}function an(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function ge(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function Ci(t){return t!==t}var Qd=function(){let t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function Ge(t){return typeof BigInt>"u"?eh:t}function eh(){throw new Error("BigInt not supported")}});var f=m(()=>{"use strict";var Ia=X().Buffer,{Buffer:th}=X();Ia.prototype.writeBigUInt64BE=th.prototype.writeBigUInt64BE;globalThis.Buffer=Ia});var Ra=m((A0,ka)=>{var T0=c(f()),rh=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,un=()=>rh.now(),nh=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),Di=t=>t===1/0||nh(t),Pi=class t{constructor({max:e=1/0,ttl:r,updateAgeOnGet:n=!1,checkAgeOnGet:i=!1,noUpdateTTL:o=!1,dispose:s,noDisposeOnSet:a=!1}={}){if(this.expirations=Object.create(null),this.data=new Map,this.expirationMap=new Map,r!==void 0&&!Di(r))throw new TypeError("ttl must be positive integer or Infinity if set");if(!Di(e))throw new TypeError("max must be positive integer or Infinity");if(this.ttl=r,this.max=e,this.updateAgeOnGet=!!n,this.checkAgeOnGet=!!i,this.noUpdateTTL=!!o,this.noDisposeOnSet=!!a,s!==void 0){if(typeof s!="function")throw new TypeError("dispose must be function if set");this.dispose=s}this.timer=void 0,this.timerExpiration=void 0}setTimer(e,r){if(this.timerExpiration<e)return;this.timer&&clearTimeout(this.timer);let n=setTimeout(()=>{this.timer=void 0,this.timerExpiration=void 0,this.purgeStale();for(let i in this.expirations){this.setTimer(i,i-un());break}},r);n.unref&&n.unref(),this.timerExpiration=e,this.timer=n}cancelTimer(){this.timer&&(clearTimeout(this.timer),this.timerExpiration=void 0,this.timer=void 0)}cancelTimers(){return process.emitWarning('TTLCache.cancelTimers has been renamed to TTLCache.cancelTimer (no "s"), and will be removed in the next major version update'),this.cancelTimer()}clear(){let e=this.dispose!==t.prototype.dispose?[...this]:[];this.data.clear(),this.expirationMap.clear(),this.cancelTimer(),this.expirations=Object.create(null);for(let[r,n]of e)this.dispose(n,r,"delete")}setTTL(e,r=this.ttl){let n=this.expirationMap.get(e);if(n!==void 0){let i=this.expirations[n];!i||i.length<=1?delete this.expirations[n]:this.expirations[n]=i.filter(o=>o!==e)}if(r!==1/0){let i=Math.floor(un()+r);this.expirationMap.set(e,i),this.expirations[i]||(this.expirations[i]=[],this.setTimer(i,r)),this.expirations[i].push(e)}else this.expirationMap.set(e,1/0)}set(e,r,{ttl:n=this.ttl,noUpdateTTL:i=this.noUpdateTTL,noDisposeOnSet:o=this.noDisposeOnSet}={}){if(!Di(n))throw new TypeError("ttl must be positive integer or Infinity");if(this.expirationMap.has(e)){i||this.setTTL(e,n);let s=this.data.get(e);s!==r&&(this.data.set(e,r),o||this.dispose(s,e,"set"))}else this.setTTL(e,n),this.data.set(e,r);for(;this.size>this.max;)this.purgeToCapacity();return this}has(e){return this.data.has(e)}getRemainingTTL(e){let r=this.expirationMap.get(e);return r===1/0?r:r!==void 0?Math.max(0,Math.ceil(r-un())):0}get(e,{updateAgeOnGet:r=this.updateAgeOnGet,ttl:n=this.ttl,checkAgeOnGet:i=this.checkAgeOnGet}={}){let o=this.data.get(e);if(i&&this.getRemainingTTL(e)===0){this.delete(e);return}return r&&this.setTTL(e,n),o}dispose(e,r){}delete(e){let r=this.expirationMap.get(e);if(r!==void 0){let n=this.data.get(e);this.data.delete(e),this.expirationMap.delete(e);let i=this.expirations[r];return i&&(i.length<=1?delete this.expirations[r]:this.expirations[r]=i.filter(o=>o!==e)),this.dispose(n,e,"delete"),this.size===0&&this.cancelTimer(),!0}return!1}purgeToCapacity(){for(let e in this.expirations){let r=this.expirations[e];if(this.size-r.length>=this.max){delete this.expirations[e];let n=[];for(let i of r)n.push([i,this.data.get(i)]),this.data.delete(i),this.expirationMap.delete(i);for(let[i,o]of n)this.dispose(o,i,"evict")}else{let n=this.size-this.max,i=[];for(let o of r.splice(0,n))i.push([o,this.data.get(o)]),this.data.delete(o),this.expirationMap.delete(o);for(let[o,s]of i)this.dispose(s,o,"evict");return}}}get size(){return this.data.size}purgeStale(){let e=Math.ceil(un());for(let r in this.expirations){if(r==="Infinity"||r>e)return;let n=[...this.expirations[r]||[]],i=[];delete this.expirations[r];for(let o of n)i.push([o,this.data.get(o)]),this.data.delete(o),this.expirationMap.delete(o);for(let[o,s]of i)this.dispose(s,o,"stale")}this.size===0&&this.cancelTimer()}*entries(){for(let e in this.expirations)for(let r of this.expirations[e])yield[r,this.data.get(r)]}*keys(){for(let e in this.expirations)for(let r of this.expirations[e])yield r}*values(){for(let e in this.expirations)for(let r of this.expirations[e])yield this.data.get(r)}[Symbol.iterator](){return this.entries()}};ka.exports=Pi});var Ga=m(Ha=>{"use strict";var Gx=c(f());Ha.supports=function(...e){let r=e.reduce((n,i)=>Object.assign(n,i),{});return Object.assign(r,{snapshots:r.snapshots||!1,permanence:r.permanence||!1,seek:r.seek||!1,clear:r.clear||!1,getMany:r.getMany||!1,keyIterator:r.keyIterator||!1,valueIterator:r.valueIterator||!1,iteratorNextv:r.iteratorNextv||!1,iteratorAll:r.iteratorAll||!1,status:r.status||!1,createIfMissing:r.createIfMissing||!1,errorIfExists:r.errorIfExists||!1,deferredOpen:r.deferredOpen||!1,promises:r.promises||!1,streams:r.streams||!1,encodings:Object.assign({},r.encodings),events:Object.assign({},r.events),additionalMethods:Object.assign({},r.additionalMethods)})}});var fe=m((zx,Ja)=>{"use strict";var Yx=c(f());Ja.exports=class extends Error{constructor(e,r){super(e||""),typeof r=="object"&&r!==null&&(r.code&&(this.code=String(r.code)),r.expected&&(this.expected=!0),r.transient&&(this.transient=!0),r.cause&&(this.cause=r.cause)),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}}});var Yi=m((Xx,za)=>{"use strict";var Zx=c(f()),zi=null;za.exports=function(){return zi===null&&(zi={textEncoder:new TextEncoder,textDecoder:new TextDecoder}),zi}});var Qi=m(Ya=>{"use strict";var eE=c(f()),Xi=fe(),Uh=new Set(["buffer","view","utf8"]),Zi=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"||!Uh.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 Xi(`Encoding '${this.name}' cannot be transcoded to 'buffer'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createViewTranscoder(){throw new Xi(`Encoding '${this.name}' cannot be transcoded to 'view'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createUTF8Transcoder(){throw new Xi(`Encoding '${this.name}' cannot be transcoded to 'utf8'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}};Ya.Encoding=Zi});var no=m(ln=>{"use strict";var rE=c(f()),{Buffer:to}=X()||{},{Encoding:ro}=Qi(),Mh=Yi(),Ar=class extends ro{constructor(e){super({...e,format:"buffer"})}createViewTranscoder(){return new Tr({encode:this.encode,decode:e=>this.decode(to.from(e.buffer,e.byteOffset,e.byteLength)),name:`${this.name}+view`})}createBufferTranscoder(){return this}},Tr=class extends ro{constructor(e){super({...e,format:"view"})}createBufferTranscoder(){return new Ar({encode:e=>{let r=this.encode(e);return to.from(r.buffer,r.byteOffset,r.byteLength)},decode:this.decode,name:`${this.name}+buffer`})}createViewTranscoder(){return this}},eo=class extends ro{constructor(e){super({...e,format:"utf8"})}createBufferTranscoder(){return new Ar({encode:e=>to.from(this.encode(e),"utf8"),decode:e=>this.decode(e.toString("utf8")),name:`${this.name}+buffer`})}createViewTranscoder(){let{textEncoder:e,textDecoder:r}=Mh();return new Tr({encode:n=>e.encode(this.encode(n)),decode:n=>this.decode(r.decode(n)),name:`${this.name}+view`})}createUTF8Transcoder(){return this}};ln.BufferFormat=Ar;ln.ViewFormat=Tr;ln.UTF8Format=eo});var eu=m(pt=>{"use strict";var iE=c(f()),{Buffer:W}=X()||{Buffer:{isBuffer:()=>!1}},{textEncoder:Za,textDecoder:Xa}=Yi()(),{BufferFormat:Br,ViewFormat:io,UTF8Format:Qa}=no(),dn=t=>t;pt.utf8=new Qa({encode:function(t){return W.isBuffer(t)?t.toString("utf8"):ArrayBuffer.isView(t)?Xa.decode(t):String(t)},decode:dn,name:"utf8",createViewTranscoder(){return new io({encode:function(t){return ArrayBuffer.isView(t)?t:Za.encode(t)},decode:function(t){return Xa.decode(t)},name:`${this.name}+view`})},createBufferTranscoder(){return new Br({encode:function(t){return W.isBuffer(t)?t:ArrayBuffer.isView(t)?W.from(t.buffer,t.byteOffset,t.byteLength):W.from(String(t),"utf8")},decode:function(t){return t.toString("utf8")},name:`${this.name}+buffer`})}});pt.json=new Qa({encode:JSON.stringify,decode:JSON.parse,name:"json"});pt.buffer=new Br({encode:function(t){return W.isBuffer(t)?t:ArrayBuffer.isView(t)?W.from(t.buffer,t.byteOffset,t.byteLength):W.from(String(t),"utf8")},decode:dn,name:"buffer",createViewTranscoder(){return new io({encode:function(t){return ArrayBuffer.isView(t)?t:W.from(String(t),"utf8")},decode:function(t){return W.from(t.buffer,t.byteOffset,t.byteLength)},name:`${this.name}+view`})}});pt.view=new io({encode:function(t){return ArrayBuffer.isView(t)?t:Za.encode(t)},decode:dn,name:"view",createBufferTranscoder(){return new Br({encode:function(t){return W.isBuffer(t)?t:ArrayBuffer.isView(t)?W.from(t.buffer,t.byteOffset,t.byteLength):W.from(String(t),"utf8")},decode:dn,name:`${this.name}+buffer`})}});pt.hex=new Br({encode:function(t){return W.isBuffer(t)?t:W.from(String(t),"hex")},decode:function(t){return t.toString("hex")},name:"hex"});pt.base64=new Br({encode:function(t){return W.isBuffer(t)?t:W.from(String(t),"base64")},decode:function(t){return t.toString("base64")},name:"base64"})});var nu=m(ru=>{"use strict";var sE=c(f()),tu=fe(),pn=eu(),{Encoding:Nh}=Qi(),{BufferFormat:Kh,ViewFormat:Fh,UTF8Format:qh}=no(),Ir=Symbol("formats"),hn=Symbol("encodings"),jh=new Set(["buffer","view","utf8"]),oo=class{constructor(e){if(Array.isArray(e)){if(!e.every(r=>jh.has(r)))throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'")}else throw new TypeError("The first argument 'formats' must be an array");this[hn]=new Map,this[Ir]=new Set(e);for(let r in pn)try{this.encoding(r)}catch(n){if(n.code!=="LEVEL_ENCODING_NOT_SUPPORTED")throw n}}encodings(){return Array.from(new Set(this[hn].values()))}encoding(e){let r=this[hn].get(e);if(r===void 0){if(typeof e=="string"&&e!==""){if(r=Hh[e],!r)throw new tu(`Encoding '${e}' is not found`,{code:"LEVEL_ENCODING_NOT_FOUND"})}else{if(typeof e!="object"||e===null)throw new TypeError("First argument 'encoding' must be a string or object");r=$h(e)}let{name:n,format:i}=r;if(!this[Ir].has(i))if(this[Ir].has("view"))r=r.createViewTranscoder();else if(this[Ir].has("buffer"))r=r.createBufferTranscoder();else if(this[Ir].has("utf8"))r=r.createUTF8Transcoder();else throw new tu(`Encoding '${n}' cannot be transcoded`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"});for(let o of[e,n,r.name,r.commonName])this[hn].set(o,r)}return r}};ru.Transcoder=oo;function $h(t){if(t instanceof Nh)return t;let e="type"in t&&typeof t.type=="string"?t.type:void 0,r=t.name||e||`anonymous-${Gh++}`;switch(Vh(t)){case"view":return new Fh({...t,name:r});case"utf8":return new qh({...t,name:r});case"buffer":return new Kh({...t,name:r});default:throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'")}}function Vh(t){return"format"in t&&t.format!==void 0?t.format:"buffer"in t&&typeof t.buffer=="boolean"?t.buffer?"buffer":"utf8":"code"in t&&Number.isInteger(t.code)?"view":"buffer"}var Wh={binary:pn.buffer,"utf-8":pn.utf8},Hh={...pn,...Wh},Gh=0});var Jt=m((aE,so)=>{"use strict";var uE=c(f()),Gt=typeof Reflect=="object"?Reflect:null,iu=Gt&&typeof Gt.apply=="function"?Gt.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},yn;Gt&&typeof Gt.ownKeys=="function"?yn=Gt.ownKeys:Object.getOwnPropertySymbols?yn=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:yn=function(e){return Object.getOwnPropertyNames(e)};function Jh(t){console&&console.warn&&console.warn(t)}var su=Number.isNaN||function(e){return e!==e};function R(){R.init.call(this)}so.exports=R;so.exports.once=Zh;R.EventEmitter=R;R.prototype._events=void 0;R.prototype._eventsCount=0;R.prototype._maxListeners=void 0;var ou=10;function wn(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(R,"defaultMaxListeners",{enumerable:!0,get:function(){return ou},set:function(t){if(typeof t!="number"||t<0||su(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");ou=t}});R.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};R.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||su(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function au(t){return t._maxListeners===void 0?R.defaultMaxListeners:t._maxListeners}R.prototype.getMaxListeners=function(){return au(this)};R.prototype.emit=function(e){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=e==="error",o=this._events;if(o!==void 0)i=i&&o.error===void 0;else if(!i)return!1;if(i){var s;if(r.length>0&&(s=r[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var l=o[e];if(l===void 0)return!1;if(typeof l=="function")iu(l,this,r);else for(var u=l.length,d=du(l,u),n=0;n<u;++n)iu(d[n],this,r);return!0};function uu(t,e,r,n){var i,o,s;if(wn(r),o=t._events,o===void 0?(o=t._events=Object.create(null),t._eventsCount=0):(o.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),o=t._events),s=o[e]),s===void 0)s=o[e]=r,++t._eventsCount;else if(typeof s=="function"?s=o[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),i=au(t),i>0&&s.length>i&&!s.warned){s.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=t,a.type=e,a.count=s.length,Jh(a)}return t}R.prototype.addListener=function(e,r){return uu(this,e,r,!1)};R.prototype.on=R.prototype.addListener;R.prototype.prependListener=function(e,r){return uu(this,e,r,!0)};function zh(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function cu(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=zh.bind(n);return i.listener=r,n.wrapFn=i,i}R.prototype.once=function(e,r){return wn(r),this.on(e,cu(this,e,r)),this};R.prototype.prependOnceListener=function(e,r){return wn(r),this.prependListener(e,cu(this,e,r)),this};R.prototype.removeListener=function(e,r){var n,i,o,s,a;if(wn(r),i=this._events,i===void 0)return this;if(n=i[e],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(o=-1,s=n.length-1;s>=0;s--)if(n[s]===r||n[s].listener===r){a=n[s].listener,o=s;break}if(o<0)return this;o===0?n.shift():Yh(n,o),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this};R.prototype.off=R.prototype.removeListener;R.prototype.removeAllListeners=function(e){var r,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var o=Object.keys(n),s;for(i=0;i<o.length;++i)s=o[i],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(i=r.length-1;i>=0;i--)this.removeListener(e,r[i]);return this};function fu(t,e,r){var n=t._events;if(n===void 0)return[];var i=n[e];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?Xh(i):du(i,i.length)}R.prototype.listeners=function(e){return fu(this,e,!0)};R.prototype.rawListeners=function(e){return fu(this,e,!1)};R.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):lu.call(t,e)};R.prototype.listenerCount=lu;function lu(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}R.prototype.eventNames=function(){return this._eventsCount>0?yn(this._events):[]};function du(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function Yh(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function Xh(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function Zh(t,e){return new Promise(function(r,n){function i(s){t.removeListener(e,o),n(s)}function o(){typeof t.removeListener=="function"&&t.removeListener("error",i),r([].slice.call(arguments))}hu(t,e,o,{once:!0}),e!=="error"&&Qh(t,i,{once:!0})})}function Qh(t,e,r){typeof t.on=="function"&&hu(t,"error",e,r)}function hu(t,e,r,n){if(typeof t.on=="function")n.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function i(o){n.once&&t.removeEventListener(e,i),r(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}});var yu=m((cE,pu)=>{var fE=c(f());pu.exports=typeof queueMicrotask=="function"?queueMicrotask:t=>Promise.resolve().then(t)});var kr=m(ao=>{"use strict";var dE=c(f()),wu=yu();ao.fromCallback=function(t,e){if(t===void 0){var r=new Promise(function(n,i){t=function(o,s){o?i(o):n(s)}});t[e!==void 0?e:"promise"]=r}else if(typeof t!="function")throw new TypeError("Callback must be a function");return t};ao.fromPromise=function(t,e){if(e===void 0)return t;t.then(function(r){wu(()=>e(null,r))}).catch(function(r){wu(()=>e(r))})}});var gn=m(uo=>{"use strict";var pE=c(f());uo.getCallback=function(t,e){return typeof t=="function"?t:e};uo.getOptions=function(t,e){return typeof t=="object"&&t!==null?t:e!==void 0?e:{}}});var Qe=m(En=>{"use strict";var wE=c(f()),{fromCallback:co}=kr(),te=fe(),{getOptions:fo,getCallback:gu}=gn(),yt=Symbol("promise"),zt=Symbol("callback"),me=Symbol("working"),wt=Symbol("handleOne"),Ce=Symbol("handleMany"),lo=Symbol("autoClose"),Xe=Symbol("finishWork"),xe=Symbol("returnMany"),Je=Symbol("closing"),Rr=Symbol("handleClose"),bn=Symbol("closed"),Or=Symbol("closeCallbacks"),Ye=Symbol("keyEncoding"),gt=Symbol("valueEncoding"),ho=Symbol("abortOnClose"),mn=Symbol("legacy"),po=Symbol("keys"),yo=Symbol("values"),ze=Symbol("limit"),oe=Symbol("count"),xn=Object.freeze({}),ep=()=>{},bu=!1,Lr=class{constructor(e,r,n){if(typeof e!="object"||e===null){let i=e===null?"null":typeof e;throw new TypeError(`The first argument must be an abstract-level database, received ${i}`)}if(typeof r!="object"||r===null)throw new TypeError("The second argument must be an options object");this[bn]=!1,this[Or]=[],this[me]=!1,this[Je]=!1,this[lo]=!1,this[zt]=null,this[wt]=this[wt].bind(this),this[Ce]=this[Ce].bind(this),this[Rr]=this[Rr].bind(this),this[Ye]=r[Ye],this[gt]=r[gt],this[mn]=n,this[ze]=Number.isInteger(r.limit)&&r.limit>=0?r.limit:1/0,this[oe]=0,this[ho]=!!r.abortOnClose,this.db=e,this.db.attachResource(this),this.nextTick=e.nextTick}get count(){return this[oe]}get limit(){return this[ze]}next(e){let r;if(e===void 0)r=new Promise((n,i)=>{e=(o,s,a)=>{o?i(o):this[mn]?s===void 0&&a===void 0?n():n([s,a]):n(s)}});else if(typeof e!="function")throw new TypeError("Callback must be a function");return this[Je]?this.nextTick(e,new te("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[me]?this.nextTick(e,new te("Iterator is busy: cannot call next() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[me]=!0,this[zt]=e,this[oe]>=this[ze]?this.nextTick(this[wt],null):this._next(this[wt])),r}_next(e){this.nextTick(e)}nextv(e,r,n){return n=gu(r,n),n=co(n,yt),r=fo(r,xn),Number.isInteger(e)?(this[Je]?this.nextTick(n,new te("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[me]?this.nextTick(n,new te("Iterator is busy: cannot call nextv() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(e<1&&(e=1),this[ze]<1/0&&(e=Math.min(e,this[ze]-this[oe])),this[me]=!0,this[zt]=n,e<=0?this.nextTick(this[Ce],null,[]):this._nextv(e,r,this[Ce])),n[yt]):(this.nextTick(n,new TypeError("The first argument 'size' must be an integer")),n[yt])}_nextv(e,r,n){let i=[],o=(s,a,l)=>{if(s)return n(s);if(this[mn]?a===void 0&&l===void 0:a===void 0)return n(null,i);i.push(this[mn]?[a,l]:a),i.length===e?n(null,i):this._next(o)};this._next(o)}all(e,r){return r=gu(e,r),r=co(r,yt),e=fo(e,xn),this[Je]?this.nextTick(r,new te("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[me]?this.nextTick(r,new te("Iterator is busy: cannot call all() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[me]=!0,this[zt]=r,this[lo]=!0,this[oe]>=this[ze]?this.nextTick(this[Ce],null,[]):this._all(e,this[Ce])),r[yt]}_all(e,r){let n=this[oe],i=[],o=()=>{let a=this[ze]<1/0?Math.min(1e3,this[ze]-n):1e3;a<=0?this.nextTick(r,null,i):this._nextv(a,xn,s)},s=(a,l)=>{a?r(a):l.length===0?r(null,i):(i.push.apply(i,l),n+=l.length,o())};o()}[Xe](){let e=this[zt];return this[ho]&&e===null?ep:(this[me]=!1,this[zt]=null,this[Je]&&this._close(this[Rr]),e)}[xe](e,r,n){this[lo]?this.close(e.bind(null,r,n)):e(r,n)}seek(e,r){if(r=fo(r,xn),!this[Je]){if(this[me])throw new te("Iterator is busy: cannot call seek() until next() has completed",{code:"LEVEL_ITERATOR_BUSY"});{let n=this.db.keyEncoding(r.keyEncoding||this[Ye]),i=n.format;r.keyEncoding!==i&&(r={...r,keyEncoding:i});let o=this.db.prefixKey(n.encode(e),i);this._seek(o,r)}}}_seek(e,r){throw new te("Iterator does not support seek()",{code:"LEVEL_NOT_SUPPORTED"})}close(e){return e=co(e,yt),this[bn]?this.nextTick(e):this[Je]?this[Or].push(e):(this[Je]=!0,this[Or].push(e),this[me]?this[ho]&&this[Xe]()(new te("Aborted on iterator close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this._close(this[Rr])),e[yt]}_close(e){this.nextTick(e)}[Rr](){this[bn]=!0,this.db.detachResource(this);let e=this[Or];this[Or]=[];for(let r of e)r()}async*[Symbol.asyncIterator](){try{let e;for(;(e=await this.next())!==void 0;)yield e}finally{this[bn]||await this.close()}}},Yt=class extends Lr{constructor(e,r){super(e,r,!0),this[po]=r.keys!==!1,this[yo]=r.values!==!1}[wt](e,r,n){let i=this[Xe]();if(e)return i(e);try{r=this[po]&&r!==void 0?this[Ye].decode(r):void 0,n=this[yo]&&n!==void 0?this[gt].decode(n):void 0}catch(o){return i(new Ze("entry",o))}r===void 0&&n===void 0||this[oe]++,i(null,r,n)}[Ce](e,r){let n=this[Xe]();if(e)return this[xe](n,e);try{for(let i of r){let o=i[0],s=i[1];i[0]=this[po]&&o!==void 0?this[Ye].decode(o):void 0,i[1]=this[yo]&&s!==void 0?this[gt].decode(s):void 0}}catch(i){return this[xe](n,new Ze("entries",i))}this[oe]+=r.length,this[xe](n,null,r)}end(e){return!bu&&typeof console<"u"&&(bu=!0,console.warn(new te("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)}},wo=class extends Lr{constructor(e,r){super(e,r,!1)}[wt](e,r){let n=this[Xe]();if(e)return n(e);try{r=r!==void 0?this[Ye].decode(r):void 0}catch(i){return n(new Ze("key",i))}r!==void 0&&this[oe]++,n(null,r)}[Ce](e,r){let n=this[Xe]();if(e)return this[xe](n,e);try{for(let i=0;i<r.length;i++){let o=r[i];r[i]=o!==void 0?this[Ye].decode(o):void 0}}catch(i){return this[xe](n,new Ze("keys",i))}this[oe]+=r.length,this[xe](n,null,r)}},go=class extends Lr{constructor(e,r){super(e,r,!1)}[wt](e,r){let n=this[Xe]();if(e)return n(e);try{r=r!==void 0?this[gt].decode(r):void 0}catch(i){return n(new Ze("value",i))}r!==void 0&&this[oe]++,n(null,r)}[Ce](e,r){let n=this[Xe]();if(e)return this[xe](n,e);try{for(let i=0;i<r.length;i++){let o=r[i];r[i]=o!==void 0?this[gt].decode(o):void 0}}catch(i){return this[xe](n,new Ze("values",i))}this[oe]+=r.length,this[xe](n,null,r)}},Ze=class extends te{constructor(e,r){super(`Iterator could not decode ${e}`,{code:"LEVEL_DECODE_ERROR",cause:r})}};for(let t of["_ended property","_nexting property","_end method"])Object.defineProperty(Yt.prototype,t.split(" ")[0],{get(){throw new te(`The ${t} has been removed`,{code:"LEVEL_LEGACY"})},set(){throw new te(`The ${t} has been removed`,{code:"LEVEL_LEGACY"})}});Yt.keyEncoding=Ye;Yt.valueEncoding=gt;En.AbstractIterator=Yt;En.AbstractKeyIterator=wo;En.AbstractValueIterator=go});var mu=m(bo=>{"use strict";var bE=c(f()),{AbstractKeyIterator:tp,AbstractValueIterator:rp}=Qe(),bt=Symbol("iterator"),Cr=Symbol("callback"),Xt=Symbol("handleOne"),mt=Symbol("handleMany"),Dr=class extends tp{constructor(e,r){super(e,r),this[bt]=e.iterator({...r,keys:!0,values:!1}),this[Xt]=this[Xt].bind(this),this[mt]=this[mt].bind(this)}},_n=class extends rp{constructor(e,r){super(e,r),this[bt]=e.iterator({...r,keys:!1,values:!0}),this[Xt]=this[Xt].bind(this),this[mt]=this[mt].bind(this)}};for(let t of[Dr,_n]){let e=t===Dr,r=e?n=>n[0]:n=>n[1];t.prototype._next=function(n){this[Cr]=n,this[bt].next(this[Xt])},t.prototype[Xt]=function(n,i,o){let s=this[Cr];n?s(n):s(null,e?i:o)},t.prototype._nextv=function(n,i,o){this[Cr]=o,this[bt].nextv(n,i,this[mt])},t.prototype._all=function(n,i){this[Cr]=i,this[bt].all(n,this[mt])},t.prototype[mt]=function(n,i){let o=this[Cr];n?o(n):o(null,i.map(r))},t.prototype._seek=function(n,i){this[bt].seek(n,i)},t.prototype._close=function(n){this[bt].close(n)}}bo.DefaultKeyIterator=Dr;bo.DefaultValueIterator=_n});var xu=m(In=>{"use strict";var xE=c(f()),{AbstractIterator:np,AbstractKeyIterator:ip,AbstractValueIterator:op}=Qe(),mo=fe(),Q=Symbol("nut"),Tn=Symbol("undefer"),Bn=Symbol("factory"),vn=class extends np{constructor(e,r){super(e,r),this[Q]=null,this[Bn]=()=>e.iterator(r),this.db.defer(()=>this[Tn]())}},Sn=class extends ip{constructor(e,r){super(e,r),this[Q]=null,this[Bn]=()=>e.keys(r),this.db.defer(()=>this[Tn]())}},An=class extends op{constructor(e,r){super(e,r),this[Q]=null,this[Bn]=()=>e.values(r),this.db.defer(()=>this[Tn]())}};for(let t of[vn,Sn,An])t.prototype[Tn]=function(){this.db.status==="open"&&(this[Q]=this[Bn]())},t.prototype._next=function(e){this[Q]!==null?this[Q].next(e):this.db.status==="opening"?this.db.defer(()=>this._next(e)):this.nextTick(e,new mo("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},t.prototype._nextv=function(e,r,n){this[Q]!==null?this[Q].nextv(e,r,n):this.db.status==="opening"?this.db.defer(()=>this._nextv(e,r,n)):this.nextTick(n,new mo("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},t.prototype._all=function(e,r){this[Q]!==null?this[Q].all(r):this.db.status==="opening"?this.db.defer(()=>this._all(e,r)):this.nextTick(r,new mo("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},t.prototype._seek=function(e,r){this[Q]!==null?this[Q]._seek(e,r):this.db.status==="opening"&&this.db.defer(()=>this._seek(e,r))},t.prototype._close=function(e){this[Q]!==null?this[Q].close(e):this.db.status==="opening"?this.db.defer(()=>this._close(e)):this.nextTick(e)};In.DeferredIterator=vn;In.DeferredKeyIterator=Sn;In.DeferredValueIterator=An});var Eo=m(_u=>{"use strict";var _E=c(f()),{fromCallback:Eu}=kr(),kn=fe(),{getCallback:sp,getOptions:ap}=gn(),Rn=Symbol("promise"),se=Symbol("status"),Zt=Symbol("operations"),Pr=Symbol("finishClose"),Qt=Symbol("closeCallbacks"),xo=class{constructor(e){if(typeof e!="object"||e===null){let r=e===null?"null":typeof e;throw new TypeError(`The first argument must be an abstract-level database, received ${r}`)}this[Zt]=[],this[Qt]=[],this[se]="open",this[Pr]=this[Pr].bind(this),this.db=e,this.db.attachResource(this),this.nextTick=e.nextTick}get length(){return this[Zt].length}put(e,r,n){if(this[se]!=="open")throw new kn("Batch is not open: cannot call put() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});let i=this.db._checkKey(e)||this.db._checkValue(r);if(i)throw i;let o=n&&n.sublevel!=null?n.sublevel:this.db,s=n,a=o.keyEncoding(n&&n.keyEncoding),l=o.valueEncoding(n&&n.valueEncoding),u=a.format;n={...n,keyEncoding:u,valueEncoding:l.format},o!==this.db&&(n.sublevel=null);let d=o.prefixKey(a.encode(e),u),h=l.encode(r);return this._put(d,h,n),this[Zt].push({...s,type:"put",key:e,value:r}),this}_put(e,r,n){}del(e,r){if(this[se]!=="open")throw new kn("Batch is not open: cannot call del() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});let n=this.db._checkKey(e);if(n)throw n;let i=r&&r.sublevel!=null?r.sublevel:this.db,o=r,s=i.keyEncoding(r&&r.keyEncoding),a=s.format;return r={...r,keyEncoding:a},i!==this.db&&(r.sublevel=null),this._del(i.prefixKey(s.encode(e),a),r),this[Zt].push({...o,type:"del",key:e}),this}_del(e,r){}clear(){if(this[se]!=="open")throw new kn("Batch is not open: cannot call clear() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});return this._clear(),this[Zt]=[],this}_clear(){}write(e,r){return r=sp(e,r),r=Eu(r,Rn),e=ap(e),this[se]!=="open"?this.nextTick(r,new kn("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"})):this.length===0?this.close(r):(this[se]="writing",this._write(e,n=>{this[se]="closing",this[Qt].push(()=>r(n)),n||this.db.emit("batch",this[Zt]),this._close(this[Pr])})),r[Rn]}_write(e,r){}close(e){return e=Eu(e,Rn),this[se]==="closing"?this[Qt].push(e):this[se]==="closed"?this.nextTick(e):(this[Qt].push(e),this[se]!=="writing"&&(this[se]="closing",this._close(this[Pr]))),e[Rn]}_close(e){this.nextTick(e)}[Pr](){this[se]="closed",this.db.detachResource(this);let e=this[Qt];this[Qt]=[];for(let r of e)r()}};_u.AbstractChainedBatch=xo});var Su=m(vu=>{"use strict";var SE=c(f()),{AbstractChainedBatch:up}=Eo(),cp=fe(),er=Symbol("encoded"),_o=class extends up{constructor(e){super(e),this[er]=[]}_put(e,r,n){this[er].push({...n,type:"put",key:e,value:r})}_del(e,r){this[er].push({...r,type:"del",key:e})}_clear(){this[er]=[]}_write(e,r){this.db.status==="opening"?this.db.defer(()=>this._write(e,r)):this.db.status==="open"?this[er].length===0?this.nextTick(r):this.db._batch(this[er],e,r):this.nextTick(r,new cp("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"}))}};vu.DefaultChainedBatch=_o});var Bu=m((AE,Tu)=>{"use strict";var TE=c(f()),Au=fe(),fp=Object.prototype.hasOwnProperty,lp=new Set(["lt","lte","gt","gte"]);Tu.exports=function(t,e){let r={};for(let n in t)if(fp.call(t,n)&&!(n==="keyEncoding"||n==="valueEncoding")){if(n==="start"||n==="end")throw new Au(`The legacy range option '${n}' has been removed`,{code:"LEVEL_LEGACY"});if(n==="encoding")throw new Au("The levelup-style 'encoding' alias has been removed, use 'valueEncoding' instead",{code:"LEVEL_LEGACY"});lp.has(n)?r[n]=e.encode(t[n]):r[n]=t[n]}return r.reverse=!!r.reverse,r.limit=Number.isInteger(r.limit)&&r.limit>=0?r.limit:-1,r}});var vo=m((BE,ku)=>{var IE=c(f());var Iu;ku.exports=typeof queueMicrotask=="function"?queueMicrotask.bind(typeof window<"u"?window:globalThis):t=>(Iu||(Iu=Promise.resolve())).then(t).catch(e=>setTimeout(()=>{throw e},0))});var Lu=m((kE,Ou)=>{"use strict";var RE=c(f()),Ru=vo();Ou.exports=function(t,...e){e.length===0?Ru(t):Ru(()=>t(...e))}});var Cu=m(On=>{"use strict";var LE=c(f()),{AbstractIterator:dp,AbstractKeyIterator:hp,AbstractValueIterator:pp}=Qe(),tr=Symbol("unfix"),le=Symbol("iterator"),xt=Symbol("handleOne"),et=Symbol("handleMany"),De=Symbol("callback"),Ur=class extends dp{constructor(e,r,n,i){super(e,r),this[le]=n,this[tr]=i,this[xt]=this[xt].bind(this),this[et]=this[et].bind(this),this[De]=null}[xt](e,r,n){let i=this[De];if(e)return i(e);r!==void 0&&(r=this[tr](r)),i(e,r,n)}[et](e,r){let n=this[De];if(e)return n(e);for(let i of r){let o=i[0];o!==void 0&&(i[0]=this[tr](o))}n(e,r)}},Mr=class extends hp{constructor(e,r,n,i){super(e,r),this[le]=n,this[tr]=i,this[xt]=this[xt].bind(this),this[et]=this[et].bind(this),this[De]=null}[xt](e,r){let n=this[De];if(e)return n(e);r!==void 0&&(r=this[tr](r)),n(e,r)}[et](e,r){let n=this[De];if(e)return n(e);for(let i=0;i<r.length;i++){let o=r[i];o!==void 0&&(r[i]=this[tr](o))}n(e,r)}},Nr=class extends pp{constructor(e,r,n){super(e,r),this[le]=n}};for(let t of[Ur,Mr])t.prototype._next=function(e){this[De]=e,this[le].next(this[xt])},t.prototype._nextv=function(e,r,n){this[De]=n,this[le].nextv(e,r,this[et])},t.prototype._all=function(e,r){this[De]=r,this[le].all(e,this[et])};for(let t of[Nr])t.prototype._next=function(e){this[le].next(e)},t.prototype._nextv=function(e,r,n){this[le].nextv(e,r,n)},t.prototype._all=function(e,r){this[le].all(e,r)};for(let t of[Ur,Mr,Nr])t.prototype._seek=function(e,r){this[le].seek(e,r)},t.prototype._close=function(e){this[le].close(e)};On.AbstractSublevelIterator=Ur;On.AbstractSublevelKeyIterator=Mr;On.AbstractSublevelValueIterator=Nr});var Mu=m((CE,Uu)=>{"use strict";var DE=c(f()),So=fe(),{Buffer:Bo}=X()||{},{AbstractSublevelIterator:yp,AbstractSublevelKeyIterator:wp,AbstractSublevelValueIterator:gp}=Cu(),Pe=Symbol("prefix"),Du=Symbol("upperBound"),Kr=Symbol("prefixRange"),re=Symbol("parent"),Ao=Symbol("unfix"),Pu=new TextEncoder,bp={separator:"!"};Uu.exports=function({AbstractLevel:t}){class e extends t{static defaults(n){if(typeof n=="string")throw new So("The subleveldown string shorthand for { separator } has been removed",{code:"LEVEL_LEGACY"});if(n&&n.open)throw new So("The subleveldown open option has been removed",{code:"LEVEL_LEGACY"});return n==null?bp:n.separator?n:{...n,separator:"!"}}constructor(n,i,o){let{separator:s,manifest:a,...l}=e.defaults(o);i=xp(i,s);let u=s.charCodeAt(0)+1,d=n[re]||n;if(!Pu.encode(i).every(y=>y>u&&y<127))throw new So(`Prefix must use bytes > ${u} < 127`,{code:"LEVEL_INVALID_PREFIX"});super(mp(d,a),l);let h=(n.prefix||"")+s+i+s,g=h.slice(0,-1)+String.fromCharCode(u);this[re]=d,this[Pe]=new Ln(h),this[Du]=new Ln(g),this[Ao]=new Io,this.nextTick=d.nextTick}prefixKey(n,i){if(i==="utf8")return this[Pe].utf8+n;if(n.byteLength===0)return this[Pe][i];if(i==="view"){let o=this[Pe].view,s=new Uint8Array(o.byteLength+n.byteLength);return s.set(o,0),s.set(n,o.byteLength),s}else{let o=this[Pe].buffer;return Bo.concat([o,n],o.byteLength+n.byteLength)}}[Kr](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[Pe][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[Du][i]}get prefix(){return this[Pe].utf8}get db(){return this[re]}_open(n,i){this[re].open({passive:!0},i)}_put(n,i,o,s){this[re].put(n,i,o,s)}_get(n,i,o){this[re].get(n,i,o)}_getMany(n,i,o){this[re].getMany(n,i,o)}_del(n,i,o){this[re].del(n,i,o)}_batch(n,i,o){this[re].batch(n,i,o)}_clear(n,i){this[Kr](n,n.keyEncoding),this[re].clear(n,i)}_iterator(n){this[Kr](n,n.keyEncoding);let i=this[re].iterator(n),o=this[Ao].get(this[Pe].utf8.length,n.keyEncoding);return new yp(this,n,i,o)}_keys(n){this[Kr](n,n.keyEncoding);let i=this[re].keys(n),o=this[Ao].get(this[Pe].utf8.length,n.keyEncoding);return new wp(this,n,i,o)}_values(n){this[Kr](n,n.keyEncoding);let i=this[re].values(n);return new gp(this,n,i)}}return{AbstractSublevel:e}};var mp=function(t,e){return{...t.supports,createIfMissing:!1,errorIfExists:!1,events:{},additionalMethods:{},...e,encodings:{utf8:To(t,"utf8"),buffer:To(t,"buffer"),view:To(t,"view")}}},To=function(t,e){return t.supports.encodings[e]?t.keyEncoding(e).name===e:!1},Ln=class{constructor(e){this.utf8=e,this.view=Pu.encode(e),this.buffer=Bo?Bo.from(this.view.buffer,0,this.view.byteLength):{}}},Io=class{constructor(){this.cache=new Map}get(e,r){let n=this.cache.get(r);return n===void 0&&(r==="view"?n=(function(i,o){return o.subarray(i)}).bind(null,e):n=(function(i,o){return o.slice(i)}).bind(null,e),this.cache.set(r,n)),n}},xp=function(t,e){let r=0,n=t.length;for(;r<n&&t[r]===e;)r++;for(;n>r&&t[n-1]===e;)n--;return t.slice(r,n)}});var Co=m(Lo=>{"use strict";var UE=c(f()),{supports:Ep}=Ga(),{Transcoder:_p}=nu(),{EventEmitter:vp}=Jt(),{fromCallback:tt}=kr(),de=fe(),{AbstractIterator:Et}=Qe(),{DefaultKeyIterator:Sp,DefaultValueIterator:Ap}=mu(),{DeferredIterator:Tp,DeferredKeyIterator:Bp,DeferredValueIterator:Ip}=xu(),{DefaultChainedBatch:Nu}=Su(),{getCallback:_t,getOptions:rt}=gn(),Cn=Bu(),_=Symbol("promise"),Ue=Symbol("landed"),vt=Symbol("resources"),ko=Symbol("closeResources"),Fr=Symbol("operations"),qr=Symbol("undefer"),Dn=Symbol("deferOpen"),Ku=Symbol("options"),A=Symbol("status"),St=Symbol("defaultOptions"),rr=Symbol("transcoder"),Pn=Symbol("keyEncoding"),Ro=Symbol("valueEncoding"),kp=()=>{},jr=class extends vp{constructor(e,r){if(super(),typeof e!="object"||e===null)throw new TypeError("The first argument 'manifest' must be an object");r=rt(r);let{keyEncoding:n,valueEncoding:i,passive:o,...s}=r;this[vt]=new Set,this[Fr]=[],this[Dn]=!0,this[Ku]=s,this[A]="opening",this.supports=Ep(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[rr]=new _p(Rp(this)),this[Pn]=this[rr].encoding(n||"utf8"),this[Ro]=this[rr].encoding(i||"utf8");for(let a of this[rr].encodings())this.supports.encodings[a.commonName]||(this.supports.encodings[a.commonName]=!0);this[St]={empty:Object.freeze({}),entry:Object.freeze({keyEncoding:this[Pn].commonName,valueEncoding:this[Ro].commonName}),key:Object.freeze({keyEncoding:this[Pn].commonName})},this.nextTick(()=>{this[Dn]&&this.open({passive:!1},kp)})}get status(){return this[A]}keyEncoding(e){return this[rr].encoding(e??this[Pn])}valueEncoding(e){return this[rr].encoding(e??this[Ro])}open(e,r){r=_t(e,r),r=tt(r,_),e={...this[Ku],...rt(e)},e.createIfMissing=e.createIfMissing!==!1,e.errorIfExists=!!e.errorIfExists;let n=i=>{this[A]==="closing"||this[A]==="opening"?this.once(Ue,i?()=>n(i):n):this[A]!=="open"?r(new de("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN",cause:i})):r()};return e.passive?this[A]==="opening"?this.once(Ue,n):this.nextTick(n):this[A]==="closed"||this[Dn]?(this[Dn]=!1,this[A]="opening",this.emit("opening"),this._open(e,i=>{if(i){this[A]="closed",this[ko](()=>{this.emit(Ue),n(i)}),this[qr]();return}this[A]="open",this[qr](),this.emit(Ue),this[A]==="open"&&this.emit("open"),this[A]==="open"&&this.emit("ready"),n()})):this[A]==="open"?this.nextTick(n):this.once(Ue,()=>this.open(e,r)),r[_]}_open(e,r){this.nextTick(r)}close(e){e=tt(e,_);let r=n=>{this[A]==="opening"||this[A]==="closing"?this.once(Ue,n?r(n):r):this[A]!=="closed"?e(new de("Database is not closed",{code:"LEVEL_DATABASE_NOT_CLOSED",cause:n})):e()};if(this[A]==="open"){this[A]="closing",this.emit("closing");let n=i=>{this[A]="open",this[qr](),this.emit(Ue),r(i)};this[ko](()=>{this._close(i=>{if(i)return n(i);this[A]="closed",this[qr](),this.emit(Ue),this[A]==="closed"&&this.emit("closed"),r()})})}else this[A]==="closed"?this.nextTick(r):this.once(Ue,()=>this.close(e));return e[_]}[ko](e){if(this[vt].size===0)return this.nextTick(e);let r=this[vt].size,n=!0,i=()=>{--r===0&&(n?this.nextTick(e):e())};for(let o of this[vt])o.close(i);n=!1,this[vt].clear()}_close(e){this.nextTick(e)}get(e,r,n){if(n=_t(r,n),n=tt(n,_),r=rt(r,this[St].entry),this[A]==="opening")return this.defer(()=>this.get(e,r,n)),n[_];if(nr(this,n))return n[_];let i=this._checkKey(e);if(i)return this.nextTick(n,i),n[_];let o=this.keyEncoding(r.keyEncoding),s=this.valueEncoding(r.valueEncoding),a=o.format,l=s.format;return(r.keyEncoding!==a||r.valueEncoding!==l)&&(r=Object.assign({},r,{keyEncoding:a,valueEncoding:l})),this._get(this.prefixKey(o.encode(e),a),r,(u,d)=>{if(u)return(u.code==="LEVEL_NOT_FOUND"||u.notFound||/NotFound/i.test(u))&&(u.code||(u.code="LEVEL_NOT_FOUND"),u.notFound||(u.notFound=!0),u.status||(u.status=404)),n(u);try{d=s.decode(d)}catch(h){return n(new de("Could not decode value",{code:"LEVEL_DECODE_ERROR",cause:h}))}n(null,d)}),n[_]}_get(e,r,n){this.nextTick(n,new Error("NotFound"))}getMany(e,r,n){if(n=_t(r,n),n=tt(n,_),r=rt(r,this[St].entry),this[A]==="opening")return this.defer(()=>this.getMany(e,r,n)),n[_];if(nr(this,n))return n[_];if(!Array.isArray(e))return this.nextTick(n,new TypeError("The first argument 'keys' must be an array")),n[_];if(e.length===0)return this.nextTick(n,null,[]),n[_];let i=this.keyEncoding(r.keyEncoding),o=this.valueEncoding(r.valueEncoding),s=i.format,a=o.format;(r.keyEncoding!==s||r.valueEncoding!==a)&&(r=Object.assign({},r,{keyEncoding:s,valueEncoding:a}));let l=new Array(e.length);for(let u=0;u<e.length;u++){let d=e[u],h=this._checkKey(d);if(h)return this.nextTick(n,h),n[_];l[u]=this.prefixKey(i.encode(d),s)}return this._getMany(l,r,(u,d)=>{if(u)return n(u);try{for(let h=0;h<d.length;h++)d[h]!==void 0&&(d[h]=o.decode(d[h]))}catch(h){return n(new de(`Could not decode one or more of ${d.length} value(s)`,{code:"LEVEL_DECODE_ERROR",cause:h}))}n(null,d)}),n[_]}_getMany(e,r,n){this.nextTick(n,null,new Array(e.length).fill(void 0))}put(e,r,n,i){if(i=_t(n,i),i=tt(i,_),n=rt(n,this[St].entry),this[A]==="opening")return this.defer(()=>this.put(e,r,n,i)),i[_];if(nr(this,i))return i[_];let o=this._checkKey(e)||this._checkValue(r);if(o)return this.nextTick(i,o),i[_];let s=this.keyEncoding(n.keyEncoding),a=this.valueEncoding(n.valueEncoding),l=s.format,u=a.format;(n.keyEncoding!==l||n.valueEncoding!==u)&&(n=Object.assign({},n,{keyEncoding:l,valueEncoding:u}));let d=this.prefixKey(s.encode(e),l),h=a.encode(r);return this._put(d,h,n,g=>{if(g)return i(g);this.emit("put",e,r),i()}),i[_]}_put(e,r,n,i){this.nextTick(i)}del(e,r,n){if(n=_t(r,n),n=tt(n,_),r=rt(r,this[St].key),this[A]==="opening")return this.defer(()=>this.del(e,r,n)),n[_];if(nr(this,n))return n[_];let i=this._checkKey(e);if(i)return this.nextTick(n,i),n[_];let o=this.keyEncoding(r.keyEncoding),s=o.format;return r.keyEncoding!==s&&(r=Object.assign({},r,{keyEncoding:s})),this._del(this.prefixKey(o.encode(e),s),r,a=>{if(a)return n(a);this.emit("del",e),n()}),n[_]}_del(e,r,n){this.nextTick(n)}batch(e,r,n){if(!arguments.length){if(this[A]==="opening")return new Nu(this);if(this[A]!=="open")throw new de("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._chainedBatch()}if(typeof e=="function"?n=e:n=_t(r,n),n=tt(n,_),r=rt(r,this[St].empty),this[A]==="opening")return this.defer(()=>this.batch(e,r,n)),n[_];if(nr(this,n))return n[_];if(!Array.isArray(e))return this.nextTick(n,new TypeError("The first argument 'operations' must be an array")),n[_];if(e.length===0)return this.nextTick(n),n[_];let i=new Array(e.length),{keyEncoding:o,valueEncoding:s,...a}=r;for(let l=0;l<e.length;l++){if(typeof e[l]!="object"||e[l]===null)return this.nextTick(n,new TypeError("A batch operation must be an object")),n[_];let u=Object.assign({},e[l]);if(u.type!=="put"&&u.type!=="del")return this.nextTick(n,new TypeError("A batch operation must have a type property that is 'put' or 'del'")),n[_];let d=this._checkKey(u.key);if(d)return this.nextTick(n,d),n[_];let h=u.sublevel!=null?u.sublevel:this,g=h.keyEncoding(u.keyEncoding||o),y=g.format;if(u.key=h.prefixKey(g.encode(u.key),y),u.keyEncoding=y,u.type==="put"){let b=this._checkValue(u.value);if(b)return this.nextTick(n,b),n[_];let w=h.valueEncoding(u.valueEncoding||s);u.value=w.encode(u.value),u.valueEncoding=w.format}h!==this&&(u.sublevel=null),i[l]=u}return this._batch(i,a,l=>{if(l)return n(l);this.emit("batch",e),n()}),n[_]}_batch(e,r,n){this.nextTick(n)}sublevel(e,r){return this._sublevel(e,Oo.defaults(r))}_sublevel(e,r){return new Oo(this,e,r)}prefixKey(e,r){return e}clear(e,r){if(r=_t(e,r),r=tt(r,_),e=rt(e,this[St].empty),this[A]==="opening")return this.defer(()=>this.clear(e,r)),r[_];if(nr(this,r))return r[_];let n=e,i=this.keyEncoding(e.keyEncoding);return e=Cn(e,i),e.keyEncoding=i.format,e.limit===0?this.nextTick(r):this._clear(e,o=>{if(o)return r(o);this.emit("clear",n),r()}),r[_]}_clear(e,r){this.nextTick(r)}iterator(e){let r=this.keyEncoding(e&&e.keyEncoding),n=this.valueEncoding(e&&e.valueEncoding);if(e=Cn(e,r),e.keys=e.keys!==!1,e.values=e.values!==!1,e[Et.keyEncoding]=r,e[Et.valueEncoding]=n,e.keyEncoding=r.format,e.valueEncoding=n.format,this[A]==="opening")return new Tp(this,e);if(this[A]!=="open")throw new de("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._iterator(e)}_iterator(e){return new Et(this,e)}keys(e){let r=this.keyEncoding(e&&e.keyEncoding),n=this.valueEncoding(e&&e.valueEncoding);if(e=Cn(e,r),e[Et.keyEncoding]=r,e[Et.valueEncoding]=n,e.keyEncoding=r.format,e.valueEncoding=n.format,this[A]==="opening")return new Bp(this,e);if(this[A]!=="open")throw new de("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._keys(e)}_keys(e){return new Sp(this,e)}values(e){let r=this.keyEncoding(e&&e.keyEncoding),n=this.valueEncoding(e&&e.valueEncoding);if(e=Cn(e,r),e[Et.keyEncoding]=r,e[Et.valueEncoding]=n,e.keyEncoding=r.format,e.valueEncoding=n.format,this[A]==="opening")return new Ip(this,e);if(this[A]!=="open")throw new de("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._values(e)}_values(e){return new Ap(this,e)}defer(e){if(typeof e!="function")throw new TypeError("The first argument must be a function");this[Fr].push(e)}[qr](){if(this[Fr].length===0)return;let e=this[Fr];this[Fr]=[];for(let r of e)r()}attachResource(e){if(typeof e!="object"||e===null||typeof e.close!="function")throw new TypeError("The first argument must be a resource object");this[vt].add(e)}detachResource(e){this[vt].delete(e)}_chainedBatch(){return new Nu(this)}_checkKey(e){if(e==null)return new de("Key cannot be null or undefined",{code:"LEVEL_INVALID_KEY"})}_checkValue(e){if(e==null)return new de("Value cannot be null or undefined",{code:"LEVEL_INVALID_VALUE"})}};jr.prototype.nextTick=Lu();var{AbstractSublevel:Oo}=Mu()({AbstractLevel:jr});Lo.AbstractLevel=jr;Lo.AbstractSublevel=Oo;var nr=function(t,e){return t[A]!=="open"?(t.nextTick(e,new de("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"})),!0):!1},Rp=function(t){return Object.keys(t.supports.encodings).filter(e=>!!t.supports.encodings[e])}});var Do=m(At=>{"use strict";var NE=c(f());At.AbstractLevel=Co().AbstractLevel;At.AbstractSublevel=Co().AbstractSublevel;At.AbstractIterator=Qe().AbstractIterator;At.AbstractKeyIterator=Qe().AbstractKeyIterator;At.AbstractValueIterator=Qe().AbstractValueIterator;At.AbstractChainedBatch=Eo().AbstractChainedBatch});var qu=m((KE,Fu)=>{var FE=c(f());Fu.exports=Lp;var Op=vo();function Lp(t,e,r){if(typeof e!="number")throw new Error("second argument must be a Number");let n,i,o,s,a,l=!0,u;Array.isArray(t)?(n=[],o=i=t.length):(s=Object.keys(t),n={},o=i=s.length);function d(g){function y(){r&&r(g,n),r=null}l?Op(y):y()}function h(g,y,b){if(n[g]=b,y&&(a=!0),--o===0||y)d(y);else if(!a&&u<i){let w;s?(w=s[u],u+=1,t[w](function(S,x){h(w,S,x)})):(w=u,u+=1,t[w](function(S,x){h(w,S,x)}))}}u=e,o?s?s.some(function(g,y){return t[g](function(b,w){h(g,b,w)}),y===e-1}):t.some(function(g,y){return g(function(b,w){h(y,b,w)}),y===e-1}):d(null),l=!1}});var Po=m((qE,ju)=>{"use strict";var jE=c(f());ju.exports=function(e){let r=e.gte!==void 0?e.gte:e.gt!==void 0?e.gt:void 0,n=e.lte!==void 0?e.lte:e.lt!==void 0?e.lt:void 0,i=e.gte===void 0,o=e.lte===void 0;return r!==void 0&&n!==void 0?IDBKeyRange.bound(r,n,i,o):r!==void 0?IDBKeyRange.lowerBound(r,i):n!==void 0?IDBKeyRange.upperBound(n,o):null}});var Uo=m(($E,$u)=>{"use strict";var VE=c(f()),Cp=new TextEncoder;$u.exports=function(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):Cp.encode(t)}});var Ju=m(Gu=>{"use strict";var HE=c(f()),{AbstractIterator:Dp}=Do(),Vu=Po(),Un=Uo(),Ee=Symbol("cache"),Me=Symbol("finished"),ne=Symbol("options"),Ne=Symbol("currentOptions"),Tt=Symbol("position"),Mo=Symbol("location"),ir=Symbol("first"),Wu={},No=class extends Dp{constructor(e,r,n){super(e,n),this[Ee]=[],this[Me]=this.limit===0,this[ne]=n,this[Ne]={...n},this[Tt]=void 0,this[Mo]=r,this[ir]=!0}_nextv(e,r,n){if(this[ir]=!1,this[Me])return this.nextTick(n,null,[]);if(this[Ee].length>0)return e=Math.min(e,this[Ee].length),this.nextTick(n,null,this[Ee].splice(0,e));this[Tt]!==void 0&&(this[ne].reverse?(this[Ne].lt=this[Tt],this[Ne].lte=void 0):(this[Ne].gt=this[Tt],this[Ne].gte=void 0));let i;try{i=Vu(this[Ne])}catch{return this[Me]=!0,this.nextTick(n,null,[])}let o=this.db.db.transaction([this[Mo]],"readonly"),s=o.objectStore(this[Mo]),a=[];if(this[ne].reverse){let l=!this[ne].values&&s.openKeyCursor?"openKeyCursor":"openCursor";s[l](i,"prev").onsuccess=u=>{let d=u.target.result;if(d){let{key:h,value:g}=d;this[Tt]=h,a.push([this[ne].keys&&h!==void 0?Un(h):void 0,this[ne].values&&g!==void 0?Un(g):void 0]),a.length<e?d.continue():Hu(o)}else this[Me]=!0}}else{let l,u,d=()=>{if(l===void 0||u===void 0)return;let h=Math.max(l.length,u.length);h===0||e===1/0?this[Me]=!0:this[Tt]=l[h-1],a.length=h;for(let g=0;g<h;g++){let y=l[g],b=u[g];a[g]=[this[ne].keys&&y!==void 0?Un(y):void 0,this[ne].values&&b!==void 0?Un(b):void 0]}Hu(o)};this[ne].keys||e<1/0?s.getAllKeys(i,e<1/0?e:void 0).onsuccess=h=>{l=h.target.result,d()}:(l=[],this.nextTick(d)),this[ne].values?s.getAll(i,e<1/0?e:void 0).onsuccess=h=>{u=h.target.result,d()}:(u=[],this.nextTick(d))}o.onabort=()=>{n(o.error||new Error("aborted by user")),n=null},o.oncomplete=()=>{n(null,a),n=null}}_next(e){if(this[Ee].length>0){let[r,n]=this[Ee].shift();this.nextTick(e,null,r,n)}else if(this[Me])this.nextTick(e);else{let r=Math.min(100,this.limit-this.count);this[ir]&&(this[ir]=!1,r=1),this._nextv(r,Wu,(n,i)=>{if(n)return e(n);this[Ee]=i,this._next(e)})}}_all(e,r){this[ir]=!1;let n=this[Ee].splice(0,this[Ee].length),i=this.limit-this.count-n.length;if(i<=0)return this.nextTick(r,null,n);this._nextv(i,Wu,(o,s)=>{if(o)return r(o);n.length>0&&(s=n.concat(s)),r(null,s)})}_seek(e,r){this[ir]=!0,this[Ee]=[],this[Me]=!1,this[Tt]=void 0,this[Ne]={...this[ne]};let n;try{n=Vu(this[ne])}catch{this[Me]=!0;return}n!==null&&!n.includes(e)?this[Me]=!0:this[ne].reverse?this[Ne].lte=e:this[Ne].gte=e}};Gu.Iterator=No;function Hu(t){typeof t.commit=="function"&&t.commit()}});var Yu=m((GE,zu)=>{"use strict";var JE=c(f());zu.exports=function(e,r,n,i,o){if(i.limit===0)return e.nextTick(o);let s=e.db.transaction([r],"readwrite"),a=s.objectStore(r),l=0;s.oncomplete=function(){o()},s.onabort=function(){o(s.error||new Error("aborted by user"))};let u=a.openKeyCursor?"openKeyCursor":"openCursor",d=i.reverse?"prev":"next";a[u](n,d).onsuccess=function(h){let g=h.target.result;g&&(a.delete(g.key).onsuccess=function(){(i.limit<=0||++l<i.limit)&&g.continue()})}}});var rc=m(tc=>{"use strict";var YE=c(f()),{AbstractLevel:Pp}=Do(),Xu=fe(),Up=qu(),{fromCallback:Mp}=kr(),{Iterator:Np}=Ju(),Zu=Uo(),Kp=Yu(),Fp=Po(),ec="level-js-",$r=Symbol("idb"),Ko=Symbol("namePrefix"),Ke=Symbol("location"),Fo=Symbol("version"),Bt=Symbol("store"),Vr=Symbol("onComplete"),Qu=Symbol("promise"),Mn=class extends Pp{constructor(e,r,n){if(typeof r=="function"||typeof n=="function")throw new Xu("The levelup-style callback argument has been removed",{code:"LEVEL_LEGACY"});let{prefix:i,version:o,...s}=r||{};if(super({encodings:{view:!0},snapshots:!1,createIfMissing:!1,errorIfExists:!1,seek:!0},s),typeof e!="string")throw new Error("constructor requires a location string argument");this[Ke]=e,this[Ko]=i??ec,this[Fo]=parseInt(o||1,10),this[$r]=null}get location(){return this[Ke]}get namePrefix(){return this[Ko]}get version(){return this[Fo]}get db(){return this[$r]}get type(){return"browser-level"}_open(e,r){let n=indexedDB.open(this[Ko]+this[Ke],this[Fo]);n.onerror=function(){r(n.error||new Error("unknown error"))},n.onsuccess=()=>{this[$r]=n.result,r()},n.onupgradeneeded=i=>{let o=i.target.result;o.objectStoreNames.contains(this[Ke])||o.createObjectStore(this[Ke])}}[Bt](e){return this[$r].transaction([this[Ke]],e).objectStore(this[Ke])}[Vr](e,r){let n=e.transaction;n.onabort=function(){r(n.error||new Error("aborted by user"))},n.oncomplete=function(){r(null,e.result)}}_get(e,r,n){let i=this[Bt]("readonly"),o;try{o=i.get(e)}catch(s){return this.nextTick(n,s)}this[Vr](o,function(s,a){if(s)return n(s);if(a===void 0)return n(new Xu("Entry not found",{code:"LEVEL_NOT_FOUND"}));n(null,Zu(a))})}_getMany(e,r,n){let i=this[Bt]("readonly"),o=e.map(s=>a=>{let l;try{l=i.get(s)}catch(u){return a(u)}l.onsuccess=()=>{let u=l.result;a(null,u===void 0?u:Zu(u))},l.onerror=u=>{u.stopPropagation(),a(l.error)}});Up(o,16,n)}_del(e,r,n){let i=this[Bt]("readwrite"),o;try{o=i.delete(e)}catch(s){return this.nextTick(n,s)}this[Vr](o,n)}_put(e,r,n,i){let o=this[Bt]("readwrite"),s;try{s=o.put(r,e)}catch(a){return this.nextTick(i,a)}this[Vr](s,i)}_iterator(e){return new Np(this,this[Ke],e)}_batch(e,r,n){let i=this[Bt]("readwrite"),o=i.transaction,s=0,a;o.onabort=function(){n(a||o.error||new Error("aborted by user"))},o.oncomplete=function(){n()};function l(){let u=e[s++],d=u.key,h;try{h=u.type==="del"?i.delete(d):i.put(u.value,d)}catch(g){a=g,o.abort();return}s<e.length?h.onsuccess=l:typeof o.commit=="function"&&o.commit()}l()}_clear(e,r){let n,i;try{n=Fp(e)}catch{return this.nextTick(r)}if(e.limit>=0)return Kp(this,this[Ke],n,e,r);try{let o=this[Bt]("readwrite");i=n?o.delete(n):o.clear()}catch(o){return this.nextTick(r,o)}this[Vr](i,r)}_close(e){this[$r].close(),this.nextTick(e)}};Mn.destroy=function(t,e,r){typeof e=="function"&&(r=e,e=ec),r=Mp(r,Qu);let n=indexedDB.deleteDatabase(e+t);return n.onsuccess=function(){r()},n.onerror=function(i){r(i)},r[Qu]};tc.BrowserLevel=Mn});var ic=m(nc=>{var ZE=c(f());nc.Level=rc().BrowserLevel});var C=m((i_,oc)=>{"use strict";var o_=c(f());oc.exports={ArrayIsArray(t){return Array.isArray(t)},ArrayPrototypeIncludes(t,e){return t.includes(e)},ArrayPrototypeIndexOf(t,e){return t.indexOf(e)},ArrayPrototypeJoin(t,e){return t.join(e)},ArrayPrototypeMap(t,e){return t.map(e)},ArrayPrototypePop(t,e){return t.pop(e)},ArrayPrototypePush(t,e){return t.push(e)},ArrayPrototypeSlice(t,e,r){return t.slice(e,r)},Error,FunctionPrototypeCall(t,e,...r){return t.call(e,...r)},FunctionPrototypeSymbolHasInstance(t,e){return Function.prototype[Symbol.hasInstance].call(t,e)},MathFloor:Math.floor,Number,NumberIsInteger:Number.isInteger,NumberIsNaN:Number.isNaN,NumberMAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,NumberMIN_SAFE_INTEGER:Number.MIN_SAFE_INTEGER,NumberParseInt:Number.parseInt,ObjectDefineProperties(t,e){return Object.defineProperties(t,e)},ObjectDefineProperty(t,e,r){return Object.defineProperty(t,e,r)},ObjectGetOwnPropertyDescriptor(t,e){return Object.getOwnPropertyDescriptor(t,e)},ObjectKeys(t){return Object.keys(t)},ObjectSetPrototypeOf(t,e){return Object.setPrototypeOf(t,e)},Promise,PromisePrototypeCatch(t,e){return t.catch(e)},PromisePrototypeThen(t,e,r){return t.then(e,r)},PromiseReject(t){return Promise.reject(t)},PromiseResolve(t){return Promise.resolve(t)},ReflectApply:Reflect.apply,RegExpPrototypeTest(t,e){return t.test(e)},SafeSet:Set,String,StringPrototypeSlice(t,e,r){return t.slice(e,r)},StringPrototypeToLowerCase(t){return t.toLowerCase()},StringPrototypeToUpperCase(t){return t.toUpperCase()},StringPrototypeTrim(t){return t.trim()},Symbol,SymbolFor:Symbol.for,SymbolAsyncIterator:Symbol.asyncIterator,SymbolHasInstance:Symbol.hasInstance,SymbolIterator:Symbol.iterator,SymbolDispose:Symbol.dispose||Symbol("Symbol.dispose"),SymbolAsyncDispose:Symbol.asyncDispose||Symbol("Symbol.asyncDispose"),TypedArrayPrototypeSet(t,e,r){return t.set(e,r)},Boolean,Uint8Array}});var or=m((s_,Nn)=>{"use strict";var a_=c(f()),{AbortController:sc,AbortSignal:jp}=typeof self<"u"?self:typeof window<"u"?window:void 0;Nn.exports=sc;Nn.exports.AbortSignal=jp;Nn.exports.default=sc});var H=m((u_,jo)=>{"use strict";var c_=c(f()),$p=X(),{kResistStopPropagation:Vp,SymbolDispose:Wp}=C(),Hp=globalThis.AbortSignal||or().AbortSignal,Gp=globalThis.AbortController||or().AbortController,Jp=Object.getPrototypeOf(async function(){}).constructor,ac=globalThis.Blob||$p.Blob,zp=typeof ac<"u"?function(e){return e instanceof ac}:function(e){return!1},uc=(t,e)=>{if(t!==void 0&&(t===null||typeof t!="object"||!("aborted"in t)))throw new ERR_INVALID_ARG_TYPE(e,"AbortSignal",t)},Yp=(t,e)=>{if(typeof t!="function")throw new ERR_INVALID_ARG_TYPE(e,"Function",t)},qo=class extends Error{constructor(e){if(!Array.isArray(e))throw new TypeError(`Expected input to be an Array, got ${typeof e}`);let r="";for(let n=0;n<e.length;n++)r+=` ${e[n].stack}
2
- `;super(r),this.name="AggregateError",this.errors=e}};jo.exports={AggregateError:qo,kEmptyObject:Object.freeze({}),once(t){let e=!1;return function(...r){e||(e=!0,t.apply(this,r))}},createDeferredPromise:function(){let t,e;return{promise:new Promise((n,i)=>{t=n,e=i}),resolve:t,reject:e}},promisify(t){return new Promise((e,r)=>{t((n,...i)=>n?r(n):e(...i))})},debuglog(){return function(){}},format(t,...e){return t.replace(/%([sdifj])/g,function(...[r,n]){let i=e.shift();return n==="f"?i.toFixed(6):n==="j"?JSON.stringify(i):n==="s"&&typeof i=="object"?`${i.constructor!==Object?i.constructor.name:""} {}`.trim():i.toString()})},inspect(t){switch(typeof t){case"string":if(t.includes("'"))if(t.includes('"')){if(!t.includes("`")&&!t.includes("${"))return`\`${t}\``}else return`"${t}"`;return`'${t}'`;case"number":return isNaN(t)?"NaN":Object.is(t,-0)?String(t):t;case"bigint":return`${String(t)}n`;case"boolean":case"undefined":return String(t);case"object":return"{}"}},types:{isAsyncFunction(t){return t instanceof Jp},isArrayBufferView(t){return ArrayBuffer.isView(t)}},isBlob:zp,deprecate(t,e){return t},addAbortListener:Jt().addAbortListener||function(e,r){if(e===void 0)throw new ERR_INVALID_ARG_TYPE("signal","AbortSignal",e);uc(e,"signal"),Yp(r,"listener");let n;return e.aborted?queueMicrotask(()=>r()):(e.addEventListener("abort",r,{__proto__:null,once:!0,[Vp]:!0}),n=()=>{e.removeEventListener("abort",r)}),{__proto__:null,[Wp](){var i;(i=n)===null||i===void 0||i()}}},AbortSignalAny:Hp.any||function(e){if(e.length===1)return e[0];let r=new Gp,n=()=>r.abort();return e.forEach(i=>{uc(i,"signals"),i.addEventListener("abort",n,{once:!0})}),r.signal.addEventListener("abort",()=>{e.forEach(i=>i.removeEventListener("abort",n))},{once:!0}),r.signal}};jo.exports.promisify.custom=Symbol.for("nodejs.util.promisify.custom")});var z=m((f_,lc)=>{"use strict";var l_=c(f()),{format:Xp,inspect:Kn,AggregateError:Zp}=H(),Qp=globalThis.AggregateError||Zp,ey=Symbol("kIsNodeError"),ty=["string","function","number","object","Function","Object","boolean","bigint","symbol"],ry=/^([A-Z][a-z0-9]*)+$/,ny="__node_internal_",Fn={};function It(t,e){if(!t)throw new Fn.ERR_INTERNAL_ASSERTION(e)}function cc(t){let e="",r=t.length,n=t[0]==="-"?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function iy(t,e,r){if(typeof e=="function")return It(e.length<=r.length,`Code: ${t}; The provided arguments length (${r.length}) does not match the required ones (${e.length}).`),e(...r);let n=(e.match(/%[dfijoOs]/g)||[]).length;return It(n===r.length,`Code: ${t}; The provided arguments length (${r.length}) does not match the required ones (${n}).`),r.length===0?e:Xp(e,...r)}function j(t,e,r){r||(r=Error);class n extends r{constructor(...o){super(iy(t,e,o))}toString(){return`${this.name} [${t}]: ${this.message}`}}Object.defineProperties(n.prototype,{name:{value:r.name,writable:!0,enumerable:!1,configurable:!0},toString:{value(){return`${this.name} [${t}]: ${this.message}`},writable:!0,enumerable:!1,configurable:!0}}),n.prototype.code=t,n.prototype[ey]=!0,Fn[t]=n}function fc(t){let e=ny+t.name;return Object.defineProperty(t,"name",{value:e}),t}function oy(t,e){if(t&&e&&t!==e){if(Array.isArray(e.errors))return e.errors.push(t),e;let r=new Qp([e,t],e.message);return r.code=e.code,r}return t||e}var $o=class extends Error{constructor(e="The operation was aborted",r=void 0){if(r!==void 0&&typeof r!="object")throw new Fn.ERR_INVALID_ARG_TYPE("options","Object",r);super(e,r),this.code="ABORT_ERR",this.name="AbortError"}};j("ERR_ASSERTION","%s",Error);j("ERR_INVALID_ARG_TYPE",(t,e,r)=>{It(typeof t=="string","'name' must be a string"),Array.isArray(e)||(e=[e]);let n="The ";t.endsWith(" argument")?n+=`${t} `:n+=`"${t}" ${t.includes(".")?"property":"argument"} `,n+="must be ";let i=[],o=[],s=[];for(let l of e)It(typeof l=="string","All expected entries have to be of type string"),ty.includes(l)?i.push(l.toLowerCase()):ry.test(l)?o.push(l):(It(l!=="object",'The value "object" should be written as "Object"'),s.push(l));if(o.length>0){let l=i.indexOf("object");l!==-1&&(i.splice(i,l,1),o.push("Object"))}if(i.length>0){switch(i.length){case 1:n+=`of type ${i[0]}`;break;case 2:n+=`one of type ${i[0]} or ${i[1]}`;break;default:{let l=i.pop();n+=`one of type ${i.join(", ")}, or ${l}`}}(o.length>0||s.length>0)&&(n+=" or ")}if(o.length>0){switch(o.length){case 1:n+=`an instance of ${o[0]}`;break;case 2:n+=`an instance of ${o[0]} or ${o[1]}`;break;default:{let l=o.pop();n+=`an instance of ${o.join(", ")}, or ${l}`}}s.length>0&&(n+=" or ")}switch(s.length){case 0:break;case 1:s[0].toLowerCase()!==s[0]&&(n+="an "),n+=`${s[0]}`;break;case 2:n+=`one of ${s[0]} or ${s[1]}`;break;default:{let l=s.pop();n+=`one of ${s.join(", ")}, or ${l}`}}if(r==null)n+=`. Received ${r}`;else if(typeof r=="function"&&r.name)n+=`. Received function ${r.name}`;else if(typeof r=="object"){var a;if((a=r.constructor)!==null&&a!==void 0&&a.name)n+=`. Received an instance of ${r.constructor.name}`;else{let l=Kn(r,{depth:-1});n+=`. Received ${l}`}}else{let l=Kn(r,{colors:!1});l.length>25&&(l=`${l.slice(0,25)}...`),n+=`. Received type ${typeof r} (${l})`}return n},TypeError);j("ERR_INVALID_ARG_VALUE",(t,e,r="is invalid")=>{let n=Kn(e);return n.length>128&&(n=n.slice(0,128)+"..."),`The ${t.includes(".")?"property":"argument"} '${t}' ${r}. Received ${n}`},TypeError);j("ERR_INVALID_RETURN_VALUE",(t,e,r)=>{var n;let i=r!=null&&(n=r.constructor)!==null&&n!==void 0&&n.name?`instance of ${r.constructor.name}`:`type ${typeof r}`;return`Expected ${t} to be returned from the "${e}" function but got ${i}.`},TypeError);j("ERR_MISSING_ARGS",(...t)=>{It(t.length>0,"At least one arg needs to be specified");let e,r=t.length;switch(t=(Array.isArray(t)?t:[t]).map(n=>`"${n}"`).join(" or "),r){case 1:e+=`The ${t[0]} argument`;break;case 2:e+=`The ${t[0]} and ${t[1]} arguments`;break;default:{let n=t.pop();e+=`The ${t.join(", ")}, and ${n} arguments`}break}return`${e} must be specified`},TypeError);j("ERR_OUT_OF_RANGE",(t,e,r)=>{It(e,'Missing "range" argument');let n;return Number.isInteger(r)&&Math.abs(r)>2**32?n=cc(String(r)):typeof r=="bigint"?(n=String(r),(r>2n**32n||r<-(2n**32n))&&(n=cc(n)),n+="n"):n=Kn(r),`The value of "${t}" is out of range. It must be ${e}. Received ${n}`},RangeError);j("ERR_MULTIPLE_CALLBACK","Callback called multiple times",Error);j("ERR_METHOD_NOT_IMPLEMENTED","The %s method is not implemented",Error);j("ERR_STREAM_ALREADY_FINISHED","Cannot call %s after a stream was finished",Error);j("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable",Error);j("ERR_STREAM_DESTROYED","Cannot call %s after a stream was destroyed",Error);j("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);j("ERR_STREAM_PREMATURE_CLOSE","Premature close",Error);j("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF",Error);j("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event",Error);j("ERR_STREAM_WRITE_AFTER_END","write after end",Error);j("ERR_UNKNOWN_ENCODING","Unknown encoding: %s",TypeError);lc.exports={AbortError:$o,aggregateTwoErrors:fc(oy),hideStackFrames:fc,codes:Fn}});var ar=m((d_,Ec)=>{"use strict";var h_=c(f()),{ArrayIsArray:Wo,ArrayPrototypeIncludes:yc,ArrayPrototypeJoin:wc,ArrayPrototypeMap:sy,NumberIsInteger:Ho,NumberIsNaN:ay,NumberMAX_SAFE_INTEGER:uy,NumberMIN_SAFE_INTEGER:cy,NumberParseInt:fy,ObjectPrototypeHasOwnProperty:ly,RegExpPrototypeExec:gc,String:dy,StringPrototypeToUpperCase:hy,StringPrototypeTrim:py}=C(),{hideStackFrames:ae,codes:{ERR_SOCKET_BAD_PORT:yy,ERR_INVALID_ARG_TYPE:G,ERR_INVALID_ARG_VALUE:sr,ERR_OUT_OF_RANGE:kt,ERR_UNKNOWN_SIGNAL:dc}}=z(),{normalizeEncoding:wy}=H(),{isAsyncFunction:gy,isArrayBufferView:by}=H().types,hc={};function my(t){return t===(t|0)}function xy(t){return t===t>>>0}var Ey=/^[0-7]+$/,_y="must be a 32-bit unsigned integer or an octal string";function vy(t,e,r){if(typeof t>"u"&&(t=r),typeof t=="string"){if(gc(Ey,t)===null)throw new sr(e,t,_y);t=fy(t,8)}return bc(t,e),t}var Sy=ae((t,e,r=cy,n=uy)=>{if(typeof t!="number")throw new G(e,"number",t);if(!Ho(t))throw new kt(e,"an integer",t);if(t<r||t>n)throw new kt(e,`>= ${r} && <= ${n}`,t)}),Ay=ae((t,e,r=-2147483648,n=2147483647)=>{if(typeof t!="number")throw new G(e,"number",t);if(!Ho(t))throw new kt(e,"an integer",t);if(t<r||t>n)throw new kt(e,`>= ${r} && <= ${n}`,t)}),bc=ae((t,e,r=!1)=>{if(typeof t!="number")throw new G(e,"number",t);if(!Ho(t))throw new kt(e,"an integer",t);let n=r?1:0,i=4294967295;if(t<n||t>i)throw new kt(e,`>= ${n} && <= ${i}`,t)});function Go(t,e){if(typeof t!="string")throw new G(e,"string",t)}function Ty(t,e,r=void 0,n){if(typeof t!="number")throw new G(e,"number",t);if(r!=null&&t<r||n!=null&&t>n||(r!=null||n!=null)&&ay(t))throw new kt(e,`${r!=null?`>= ${r}`:""}${r!=null&&n!=null?" && ":""}${n!=null?`<= ${n}`:""}`,t)}var By=ae((t,e,r)=>{if(!yc(r,t)){let i="must be one of: "+wc(sy(r,o=>typeof o=="string"?`'${o}'`:dy(o)),", ");throw new sr(e,t,i)}});function mc(t,e){if(typeof t!="boolean")throw new G(e,"boolean",t)}function Vo(t,e,r){return t==null||!ly(t,e)?r:t[e]}var Iy=ae((t,e,r=null)=>{let n=Vo(r,"allowArray",!1),i=Vo(r,"allowFunction",!1);if(!Vo(r,"nullable",!1)&&t===null||!n&&Wo(t)||typeof t!="object"&&(!i||typeof t!="function"))throw new G(e,"Object",t)}),ky=ae((t,e)=>{if(t!=null&&typeof t!="object"&&typeof t!="function")throw new G(e,"a dictionary",t)}),qn=ae((t,e,r=0)=>{if(!Wo(t))throw new G(e,"Array",t);if(t.length<r){let n=`must be longer than ${r}`;throw new sr(e,t,n)}});function Ry(t,e){qn(t,e);for(let r=0;r<t.length;r++)Go(t[r],`${e}[${r}]`)}function Oy(t,e){qn(t,e);for(let r=0;r<t.length;r++)mc(t[r],`${e}[${r}]`)}function Ly(t,e){qn(t,e);for(let r=0;r<t.length;r++){let n=t[r],i=`${e}[${r}]`;if(n==null)throw new G(i,"AbortSignal",n);xc(n,i)}}function Cy(t,e="signal"){if(Go(t,e),hc[t]===void 0)throw hc[hy(t)]!==void 0?new dc(t+" (signals must use all capital letters)"):new dc(t)}var Dy=ae((t,e="buffer")=>{if(!by(t))throw new G(e,["Buffer","TypedArray","DataView"],t)});function Py(t,e){let r=wy(e),n=t.length;if(r==="hex"&&n%2!==0)throw new sr("encoding",e,`is invalid for data of length ${n}`)}function Uy(t,e="Port",r=!0){if(typeof t!="number"&&typeof t!="string"||typeof t=="string"&&py(t).length===0||+t!==+t>>>0||t>65535||t===0&&!r)throw new yy(e,t,r);return t|0}var xc=ae((t,e)=>{if(t!==void 0&&(t===null||typeof t!="object"||!("aborted"in t)))throw new G(e,"AbortSignal",t)}),My=ae((t,e)=>{if(typeof t!="function")throw new G(e,"Function",t)}),Ny=ae((t,e)=>{if(typeof t!="function"||gy(t))throw new G(e,"Function",t)}),Ky=ae((t,e)=>{if(t!==void 0)throw new G(e,"undefined",t)});function Fy(t,e,r){if(!yc(r,t))throw new G(e,`('${wc(r,"|")}')`,t)}var qy=/^(?:<[^>]*>)(?:\s*;\s*[^;"\s]+(?:=(")?[^;"\s]*\1)?)*$/;function pc(t,e){if(typeof t>"u"||!gc(qy,t))throw new sr(e,t,'must be an array or string of format "</styles.css>; rel=preload; as=style"')}function jy(t){if(typeof t=="string")return pc(t,"hints"),t;if(Wo(t)){let e=t.length,r="";if(e===0)return r;for(let n=0;n<e;n++){let i=t[n];pc(i,"hints"),r+=i,n!==e-1&&(r+=", ")}return r}throw new sr("hints",t,'must be an array or string of format "</styles.css>; rel=preload; as=style"')}Ec.exports={isInt32:my,isUint32:xy,parseFileMode:vy,validateArray:qn,validateStringArray:Ry,validateBooleanArray:Oy,validateAbortSignalArray:Ly,validateBoolean:mc,validateBuffer:Dy,validateDictionary:ky,validateEncoding:Py,validateFunction:My,validateInt32:Ay,validateInteger:Sy,validateNumber:Ty,validateObject:Iy,validateOneOf:By,validatePlainFunction:Ny,validatePort:Uy,validateSignalName:Cy,validateString:Go,validateUint32:bc,validateUndefined:Ky,validateUnion:Fy,validateAbortSignal:xc,validateLinkHeaderValue:jy}});var nt=m((p_,Ac)=>{var y_=c(f()),U=Ac.exports={},_e,ve;function Jo(){throw new Error("setTimeout has not been defined")}function zo(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?_e=setTimeout:_e=Jo}catch{_e=Jo}try{typeof clearTimeout=="function"?ve=clearTimeout:ve=zo}catch{ve=zo}})();function _c(t){if(_e===setTimeout)return setTimeout(t,0);if((_e===Jo||!_e)&&setTimeout)return _e=setTimeout,setTimeout(t,0);try{return _e(t,0)}catch{try{return _e.call(null,t,0)}catch{return _e.call(this,t,0)}}}function $y(t){if(ve===clearTimeout)return clearTimeout(t);if((ve===zo||!ve)&&clearTimeout)return ve=clearTimeout,clearTimeout(t);try{return ve(t)}catch{try{return ve.call(null,t)}catch{return ve.call(this,t)}}}var Fe=[],ur=!1,Rt,jn=-1;function Vy(){!ur||!Rt||(ur=!1,Rt.length?Fe=Rt.concat(Fe):jn=-1,Fe.length&&vc())}function vc(){if(!ur){var t=_c(Vy);ur=!0;for(var e=Fe.length;e;){for(Rt=Fe,Fe=[];++jn<e;)Rt&&Rt[jn].run();jn=-1,e=Fe.length}Rt=null,ur=!1,$y(t)}}U.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];Fe.push(new Sc(t,e)),Fe.length===1&&!ur&&_c(vc)};function Sc(t,e){this.fun=t,this.array=e}Sc.prototype.run=function(){this.fun.apply(null,this.array)};U.title="browser";U.browser=!0;U.env={};U.argv=[];U.version="";U.versions={};function qe(){}U.on=qe;U.addListener=qe;U.once=qe;U.off=qe;U.removeListener=qe;U.removeAllListeners=qe;U.emit=qe;U.prependListener=qe;U.prependOnceListener=qe;U.listeners=function(t){return[]};U.binding=function(t){throw new Error("process.binding is not supported")};U.cwd=function(){return"/"};U.chdir=function(t){throw new Error("process.chdir is not supported")};U.umask=function(){return 0}});var Ae=m((w_,Fc)=>{"use strict";var g_=c(f()),{SymbolAsyncIterator:Tc,SymbolIterator:Bc,SymbolFor:Ot}=C(),Ic=Ot("nodejs.stream.destroyed"),kc=Ot("nodejs.stream.errored"),Yo=Ot("nodejs.stream.readable"),Xo=Ot("nodejs.stream.writable"),Rc=Ot("nodejs.stream.disturbed"),Wy=Ot("nodejs.webstream.isClosedPromise"),Hy=Ot("nodejs.webstream.controllerErrorFunction");function $n(t,e=!1){var r;return!!(t&&typeof t.pipe=="function"&&typeof t.on=="function"&&(!e||typeof t.pause=="function"&&typeof t.resume=="function")&&(!t._writableState||((r=t._readableState)===null||r===void 0?void 0:r.readable)!==!1)&&(!t._writableState||t._readableState))}function Vn(t){var e;return!!(t&&typeof t.write=="function"&&typeof t.on=="function"&&(!t._readableState||((e=t._writableState)===null||e===void 0?void 0:e.writable)!==!1))}function Gy(t){return!!(t&&typeof t.pipe=="function"&&t._readableState&&typeof t.on=="function"&&typeof t.write=="function")}function Se(t){return t&&(t._readableState||t._writableState||typeof t.write=="function"&&typeof t.on=="function"||typeof t.pipe=="function"&&typeof t.on=="function")}function Oc(t){return!!(t&&!Se(t)&&typeof t.pipeThrough=="function"&&typeof t.getReader=="function"&&typeof t.cancel=="function")}function Lc(t){return!!(t&&!Se(t)&&typeof t.getWriter=="function"&&typeof t.abort=="function")}function Cc(t){return!!(t&&!Se(t)&&typeof t.readable=="object"&&typeof t.writable=="object")}function Jy(t){return Oc(t)||Lc(t)||Cc(t)}function zy(t,e){return t==null?!1:e===!0?typeof t[Tc]=="function":e===!1?typeof t[Bc]=="function":typeof t[Tc]=="function"||typeof t[Bc]=="function"}function Wn(t){if(!Se(t))return null;let e=t._writableState,r=t._readableState,n=e||r;return!!(t.destroyed||t[Ic]||n!=null&&n.destroyed)}function Dc(t){if(!Vn(t))return null;if(t.writableEnded===!0)return!0;let e=t._writableState;return e!=null&&e.errored?!1:typeof e?.ended!="boolean"?null:e.ended}function Yy(t,e){if(!Vn(t))return null;if(t.writableFinished===!0)return!0;let r=t._writableState;return r!=null&&r.errored?!1:typeof r?.finished!="boolean"?null:!!(r.finished||e===!1&&r.ended===!0&&r.length===0)}function Xy(t){if(!$n(t))return null;if(t.readableEnded===!0)return!0;let e=t._readableState;return!e||e.errored?!1:typeof e?.ended!="boolean"?null:e.ended}function Pc(t,e){if(!$n(t))return null;let r=t._readableState;return r!=null&&r.errored?!1:typeof r?.endEmitted!="boolean"?null:!!(r.endEmitted||e===!1&&r.ended===!0&&r.length===0)}function Uc(t){return t&&t[Yo]!=null?t[Yo]:typeof t?.readable!="boolean"?null:Wn(t)?!1:$n(t)&&t.readable&&!Pc(t)}function Mc(t){return t&&t[Xo]!=null?t[Xo]:typeof t?.writable!="boolean"?null:Wn(t)?!1:Vn(t)&&t.writable&&!Dc(t)}function Zy(t,e){return Se(t)?Wn(t)?!0:!(e?.readable!==!1&&Uc(t)||e?.writable!==!1&&Mc(t)):null}function Qy(t){var e,r;return Se(t)?t.writableErrored?t.writableErrored:(e=(r=t._writableState)===null||r===void 0?void 0:r.errored)!==null&&e!==void 0?e:null:null}function ew(t){var e,r;return Se(t)?t.readableErrored?t.readableErrored:(e=(r=t._readableState)===null||r===void 0?void 0:r.errored)!==null&&e!==void 0?e:null:null}function tw(t){if(!Se(t))return null;if(typeof t.closed=="boolean")return t.closed;let e=t._writableState,r=t._readableState;return typeof e?.closed=="boolean"||typeof r?.closed=="boolean"?e?.closed||r?.closed:typeof t._closed=="boolean"&&Nc(t)?t._closed:null}function Nc(t){return typeof t._closed=="boolean"&&typeof t._defaultKeepAlive=="boolean"&&typeof t._removedConnection=="boolean"&&typeof t._removedContLen=="boolean"}function Kc(t){return typeof t._sent100=="boolean"&&Nc(t)}function rw(t){var e;return typeof t._consuming=="boolean"&&typeof t._dumped=="boolean"&&((e=t.req)===null||e===void 0?void 0:e.upgradeOrConnect)===void 0}function nw(t){if(!Se(t))return null;let e=t._writableState,r=t._readableState,n=e||r;return!n&&Kc(t)||!!(n&&n.autoDestroy&&n.emitClose&&n.closed===!1)}function iw(t){var e;return!!(t&&((e=t[Rc])!==null&&e!==void 0?e:t.readableDidRead||t.readableAborted))}function ow(t){var e,r,n,i,o,s,a,l,u,d;return!!(t&&((e=(r=(n=(i=(o=(s=t[kc])!==null&&s!==void 0?s:t.readableErrored)!==null&&o!==void 0?o:t.writableErrored)!==null&&i!==void 0?i:(a=t._readableState)===null||a===void 0?void 0:a.errorEmitted)!==null&&n!==void 0?n:(l=t._writableState)===null||l===void 0?void 0:l.errorEmitted)!==null&&r!==void 0?r:(u=t._readableState)===null||u===void 0?void 0:u.errored)!==null&&e!==void 0?e:!((d=t._writableState)===null||d===void 0)&&d.errored))}Fc.exports={isDestroyed:Wn,kIsDestroyed:Ic,isDisturbed:iw,kIsDisturbed:Rc,isErrored:ow,kIsErrored:kc,isReadable:Uc,kIsReadable:Yo,kIsClosedPromise:Wy,kControllerErrorFunction:Hy,kIsWritable:Xo,isClosed:tw,isDuplexNodeStream:Gy,isFinished:Zy,isIterable:zy,isReadableNodeStream:$n,isReadableStream:Oc,isReadableEnded:Xy,isReadableFinished:Pc,isReadableErrored:ew,isNodeStream:Se,isWebStream:Jy,isWritable:Mc,isWritableNodeStream:Vn,isWritableStream:Lc,isWritableEnded:Dc,isWritableFinished:Yy,isWritableErrored:Qy,isServerRequest:rw,isServerResponse:Kc,willEmitClose:nw,isTransformStream:Cc}});var je=m((b_,rs)=>{var m_=c(f()),it=nt(),{AbortError:zc,codes:sw}=z(),{ERR_INVALID_ARG_TYPE:aw,ERR_STREAM_PREMATURE_CLOSE:qc}=sw,{kEmptyObject:Qo,once:es}=H(),{validateAbortSignal:uw,validateFunction:cw,validateObject:fw,validateBoolean:lw}=ar(),{Promise:dw,PromisePrototypeThen:hw,SymbolDispose:Yc}=C(),{isClosed:pw,isReadable:jc,isReadableNodeStream:Zo,isReadableStream:yw,isReadableFinished:$c,isReadableErrored:Vc,isWritable:Wc,isWritableNodeStream:Hc,isWritableStream:ww,isWritableFinished:Gc,isWritableErrored:Jc,isNodeStream:gw,willEmitClose:bw,kIsClosedPromise:mw}=Ae(),cr;function xw(t){return t.setHeader&&typeof t.abort=="function"}var ts=()=>{};function Xc(t,e,r){var n,i;if(arguments.length===2?(r=e,e=Qo):e==null?e=Qo:fw(e,"options"),cw(r,"callback"),uw(e.signal,"options.signal"),r=es(r),yw(t)||ww(t))return Ew(t,e,r);if(!gw(t))throw new aw("stream",["ReadableStream","WritableStream","Stream"],t);let o=(n=e.readable)!==null&&n!==void 0?n:Zo(t),s=(i=e.writable)!==null&&i!==void 0?i:Hc(t),a=t._writableState,l=t._readableState,u=()=>{t.writable||g()},d=bw(t)&&Zo(t)===o&&Hc(t)===s,h=Gc(t,!1),g=()=>{h=!0,t.destroyed&&(d=!1),!(d&&(!t.readable||o))&&(!o||y)&&r.call(t)},y=$c(t,!1),b=()=>{y=!0,t.destroyed&&(d=!1),!(d&&(!t.writable||s))&&(!s||h)&&r.call(t)},w=I=>{r.call(t,I)},S=pw(t),x=()=>{S=!0;let I=Jc(t)||Vc(t);if(I&&typeof I!="boolean")return r.call(t,I);if(o&&!y&&Zo(t,!0)&&!$c(t,!1))return r.call(t,new qc);if(s&&!h&&!Gc(t,!1))return r.call(t,new qc);r.call(t)},T=()=>{S=!0;let I=Jc(t)||Vc(t);if(I&&typeof I!="boolean")return r.call(t,I);r.call(t)},k=()=>{t.req.on("finish",g)};xw(t)?(t.on("complete",g),d||t.on("abort",x),t.req?k():t.on("request",k)):s&&!a&&(t.on("end",u),t.on("close",u)),!d&&typeof t.aborted=="boolean"&&t.on("aborted",x),t.on("end",b),t.on("finish",g),e.error!==!1&&t.on("error",w),t.on("close",x),S?it.nextTick(x):a!=null&&a.errorEmitted||l!=null&&l.errorEmitted?d||it.nextTick(T):(!o&&(!d||jc(t))&&(h||Wc(t)===!1)||!s&&(!d||Wc(t))&&(y||jc(t)===!1)||l&&t.req&&t.aborted)&&it.nextTick(T);let E=()=>{r=ts,t.removeListener("aborted",x),t.removeListener("complete",g),t.removeListener("abort",x),t.removeListener("request",k),t.req&&t.req.removeListener("finish",g),t.removeListener("end",u),t.removeListener("close",u),t.removeListener("finish",g),t.removeListener("end",b),t.removeListener("error",w),t.removeListener("close",x)};if(e.signal&&!S){let I=()=>{let $=r;E(),$.call(t,new zc(void 0,{cause:e.signal.reason}))};if(e.signal.aborted)it.nextTick(I);else{cr=cr||H().addAbortListener;let $=cr(e.signal,I),L=r;r=es((...V)=>{$[Yc](),L.apply(t,V)})}}return E}function Ew(t,e,r){let n=!1,i=ts;if(e.signal)if(i=()=>{n=!0,r.call(t,new zc(void 0,{cause:e.signal.reason}))},e.signal.aborted)it.nextTick(i);else{cr=cr||H().addAbortListener;let s=cr(e.signal,i),a=r;r=es((...l)=>{s[Yc](),a.apply(t,l)})}let o=(...s)=>{n||it.nextTick(()=>r.apply(t,s))};return hw(t[mw].promise,o,o),ts}function _w(t,e){var r;let n=!1;return e===null&&(e=Qo),(r=e)!==null&&r!==void 0&&r.cleanup&&(lw(e.cleanup,"cleanup"),n=e.cleanup),new dw((i,o)=>{let s=Xc(t,e,a=>{n&&s(),a?o(a):i()})})}rs.exports=Xc;rs.exports.finished=_w});var Lt=m((x_,sf)=>{"use strict";var E_=c(f()),Te=nt(),{aggregateTwoErrors:vw,codes:{ERR_MULTIPLE_CALLBACK:Sw},AbortError:Aw}=z(),{Symbol:ef}=C(),{kIsDestroyed:Tw,isDestroyed:Bw,isFinished:Iw,isServerRequest:kw}=Ae(),tf=ef("kDestroy"),ns=ef("kConstruct");function rf(t,e,r){t&&(t.stack,e&&!e.errored&&(e.errored=t),r&&!r.errored&&(r.errored=t))}function Rw(t,e){let r=this._readableState,n=this._writableState,i=n||r;return n!=null&&n.destroyed||r!=null&&r.destroyed?(typeof e=="function"&&e(),this):(rf(t,n,r),n&&(n.destroyed=!0),r&&(r.destroyed=!0),i.constructed?Zc(this,t,e):this.once(tf,function(o){Zc(this,vw(o,t),e)}),this)}function Zc(t,e,r){let n=!1;function i(o){if(n)return;n=!0;let s=t._readableState,a=t._writableState;rf(o,a,s),a&&(a.closed=!0),s&&(s.closed=!0),typeof r=="function"&&r(o),o?Te.nextTick(Ow,t,o):Te.nextTick(nf,t)}try{t._destroy(e||null,i)}catch(o){i(o)}}function Ow(t,e){is(t,e),nf(t)}function nf(t){let e=t._readableState,r=t._writableState;r&&(r.closeEmitted=!0),e&&(e.closeEmitted=!0),(r!=null&&r.emitClose||e!=null&&e.emitClose)&&t.emit("close")}function is(t,e){let r=t._readableState,n=t._writableState;n!=null&&n.errorEmitted||r!=null&&r.errorEmitted||(n&&(n.errorEmitted=!0),r&&(r.errorEmitted=!0),t.emit("error",e))}function Lw(){let t=this._readableState,e=this._writableState;t&&(t.constructed=!0,t.closed=!1,t.closeEmitted=!1,t.destroyed=!1,t.errored=null,t.errorEmitted=!1,t.reading=!1,t.ended=t.readable===!1,t.endEmitted=t.readable===!1),e&&(e.constructed=!0,e.destroyed=!1,e.closed=!1,e.closeEmitted=!1,e.errored=null,e.errorEmitted=!1,e.finalCalled=!1,e.prefinished=!1,e.ended=e.writable===!1,e.ending=e.writable===!1,e.finished=e.writable===!1)}function os(t,e,r){let n=t._readableState,i=t._writableState;if(i!=null&&i.destroyed||n!=null&&n.destroyed)return this;n!=null&&n.autoDestroy||i!=null&&i.autoDestroy?t.destroy(e):e&&(e.stack,i&&!i.errored&&(i.errored=e),n&&!n.errored&&(n.errored=e),r?Te.nextTick(is,t,e):is(t,e))}function Cw(t,e){if(typeof t._construct!="function")return;let r=t._readableState,n=t._writableState;r&&(r.constructed=!1),n&&(n.constructed=!1),t.once(ns,e),!(t.listenerCount(ns)>1)&&Te.nextTick(Dw,t)}function Dw(t){let e=!1;function r(n){if(e){os(t,n??new Sw);return}e=!0;let i=t._readableState,o=t._writableState,s=o||i;i&&(i.constructed=!0),o&&(o.constructed=!0),s.destroyed?t.emit(tf,n):n?os(t,n,!0):Te.nextTick(Pw,t)}try{t._construct(n=>{Te.nextTick(r,n)})}catch(n){Te.nextTick(r,n)}}function Pw(t){t.emit(ns)}function Qc(t){return t?.setHeader&&typeof t.abort=="function"}function of(t){t.emit("close")}function Uw(t,e){t.emit("error",e),Te.nextTick(of,t)}function Mw(t,e){!t||Bw(t)||(!e&&!Iw(t)&&(e=new Aw),kw(t)?(t.socket=null,t.destroy(e)):Qc(t)?t.abort():Qc(t.req)?t.req.abort():typeof t.destroy=="function"?t.destroy(e):typeof t.close=="function"?t.close():e?Te.nextTick(Uw,t,e):Te.nextTick(of,t),t.destroyed||(t[Tw]=!0))}sf.exports={construct:Cw,destroyer:Mw,destroy:Rw,undestroy:Lw,errorOrDestroy:os}});var Jn=m((__,uf)=>{"use strict";var v_=c(f()),{ArrayIsArray:Nw,ObjectSetPrototypeOf:af}=C(),{EventEmitter:Hn}=Jt();function Gn(t){Hn.call(this,t)}af(Gn.prototype,Hn.prototype);af(Gn,Hn);Gn.prototype.pipe=function(t,e){let r=this;function n(d){t.writable&&t.write(d)===!1&&r.pause&&r.pause()}r.on("data",n);function i(){r.readable&&r.resume&&r.resume()}t.on("drain",i),!t._isStdio&&(!e||e.end!==!1)&&(r.on("end",s),r.on("close",a));let o=!1;function s(){o||(o=!0,t.end())}function a(){o||(o=!0,typeof t.destroy=="function"&&t.destroy())}function l(d){u(),Hn.listenerCount(this,"error")===0&&this.emit("error",d)}ss(r,"error",l),ss(t,"error",l);function u(){r.removeListener("data",n),t.removeListener("drain",i),r.removeListener("end",s),r.removeListener("close",a),r.removeListener("error",l),t.removeListener("error",l),r.removeListener("end",u),r.removeListener("close",u),t.removeListener("close",u)}return r.on("end",u),r.on("close",u),t.on("close",u),t.emit("pipe",r),t};function ss(t,e,r){if(typeof t.prependListener=="function")return t.prependListener(e,r);!t._events||!t._events[e]?t.on(e,r):Nw(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]}uf.exports={Stream:Gn,prependListener:ss}});var Wr=m((S_,zn)=>{"use strict";var A_=c(f()),{SymbolDispose:Kw}=C(),{AbortError:cf,codes:Fw}=z(),{isNodeStream:ff,isWebStream:qw,kControllerErrorFunction:jw}=Ae(),$w=je(),{ERR_INVALID_ARG_TYPE:lf}=Fw,as,Vw=(t,e)=>{if(typeof t!="object"||!("aborted"in t))throw new lf(e,"AbortSignal",t)};zn.exports.addAbortSignal=function(e,r){if(Vw(e,"signal"),!ff(r)&&!qw(r))throw new lf("stream",["ReadableStream","WritableStream","Stream"],r);return zn.exports.addAbortSignalNoValidate(e,r)};zn.exports.addAbortSignalNoValidate=function(t,e){if(typeof t!="object"||!("aborted"in t))return e;let r=ff(e)?()=>{e.destroy(new cf(void 0,{cause:t.reason}))}:()=>{e[jw](new cf(void 0,{cause:t.reason}))};if(t.aborted)r();else{as=as||H().addAbortListener;let n=as(t,r);$w(e,n[Kw])}return e}});var pf=m((B_,hf)=>{"use strict";var I_=c(f()),{StringPrototypeSlice:df,SymbolIterator:Ww,TypedArrayPrototypeSet:Yn,Uint8Array:Hw}=C(),{Buffer:us}=X(),{inspect:Gw}=H();hf.exports=class{constructor(){this.head=null,this.tail=null,this.length=0}push(e){let r={data:e,next:null};this.length>0?this.tail.next=r:this.head=r,this.tail=r,++this.length}unshift(e){let r={data:e,next:this.head};this.length===0&&(this.tail=r),this.head=r,++this.length}shift(){if(this.length===0)return;let e=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,e}clear(){this.head=this.tail=null,this.length=0}join(e){if(this.length===0)return"";let r=this.head,n=""+r.data;for(;(r=r.next)!==null;)n+=e+r.data;return n}concat(e){if(this.length===0)return us.alloc(0);let r=us.allocUnsafe(e>>>0),n=this.head,i=0;for(;n;)Yn(r,n.data,i),i+=n.data.length,n=n.next;return r}consume(e,r){let n=this.head.data;if(e<n.length){let i=n.slice(0,e);return this.head.data=n.slice(e),i}return e===n.length?this.shift():r?this._getString(e):this._getBuffer(e)}first(){return this.head.data}*[Ww](){for(let e=this.head;e;e=e.next)yield e.data}_getString(e){let r="",n=this.head,i=0;do{let o=n.data;if(e>o.length)r+=o,e-=o.length;else{e===o.length?(r+=o,++i,n.next?this.head=n.next:this.head=this.tail=null):(r+=df(o,0,e),this.head=n,n.data=df(o,e));break}++i}while((n=n.next)!==null);return this.length-=i,r}_getBuffer(e){let r=us.allocUnsafe(e),n=e,i=this.head,o=0;do{let s=i.data;if(e>s.length)Yn(r,s,n-e),e-=s.length;else{e===s.length?(Yn(r,s,n-e),++o,i.next?this.head=i.next:this.head=this.tail=null):(Yn(r,new Hw(s.buffer,s.byteOffset,e),n-e),this.head=i,i.data=s.slice(e));break}++o}while((i=i.next)!==null);return this.length-=o,r}[Symbol.for("nodejs.util.inspect.custom")](e,r){return Gw(this,{...r,depth:0,customInspect:!1})}}});var Hr=m((k_,bf)=>{"use strict";var R_=c(f()),{MathFloor:Jw,NumberIsInteger:zw}=C(),{validateInteger:Yw}=ar(),{ERR_INVALID_ARG_VALUE:Xw}=z().codes,yf=16*1024,wf=16;function Zw(t,e,r){return t.highWaterMark!=null?t.highWaterMark:e?t[r]:null}function gf(t){return t?wf:yf}function Qw(t,e){Yw(e,"value",0),t?wf=e:yf=e}function eg(t,e,r,n){let i=Zw(e,n,r);if(i!=null){if(!zw(i)||i<0){let o=n?`options.${r}`:"options.highWaterMark";throw new Xw(o,i)}return Jw(i)}return gf(t.objectMode)}bf.exports={getHighWaterMark:eg,getDefaultHighWaterMark:gf,setDefaultHighWaterMark:Qw}});var Ef=m((cs,xf)=>{var O_=c(f());var Xn=X(),Be=Xn.Buffer;function mf(t,e){for(var r in t)e[r]=t[r]}Be.from&&Be.alloc&&Be.allocUnsafe&&Be.allocUnsafeSlow?xf.exports=Xn:(mf(Xn,cs),cs.Buffer=Ct);function Ct(t,e,r){return Be(t,e,r)}Ct.prototype=Object.create(Be.prototype);mf(Be,Ct);Ct.from=function(t,e,r){if(typeof t=="number")throw new TypeError("Argument must not be a number");return Be(t,e,r)};Ct.alloc=function(t,e,r){if(typeof t!="number")throw new TypeError("Argument must be a number");var n=Be(t);return e!==void 0?typeof r=="string"?n.fill(e,r):n.fill(e):n.fill(0),n};Ct.allocUnsafe=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return Be(t)};Ct.allocUnsafeSlow=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return Xn.SlowBuffer(t)}});var Sf=m(vf=>{"use strict";var C_=c(f()),ls=Ef().Buffer,_f=ls.isEncoding||function(t){switch(t=""+t,t&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function tg(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}function rg(t){var e=tg(t);if(typeof e!="string"&&(ls.isEncoding===_f||!_f(t)))throw new Error("Unknown encoding: "+t);return e||t}vf.StringDecoder=Gr;function Gr(t){this.encoding=rg(t);var e;switch(this.encoding){case"utf16le":this.text=ug,this.end=cg,e=4;break;case"utf8":this.fillLast=og,e=4;break;case"base64":this.text=fg,this.end=lg,e=3;break;default:this.write=dg,this.end=hg;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=ls.allocUnsafe(e)}Gr.prototype.write=function(t){if(t.length===0)return"";var e,r;if(this.lastNeed){if(e=this.fillLast(t),e===void 0)return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<t.length?e?e+this.text(t,r):this.text(t,r):e||""};Gr.prototype.end=ag;Gr.prototype.text=sg;Gr.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length};function fs(t){return t<=127?0:t>>5===6?2:t>>4===14?3:t>>3===30?4:t>>6===2?-1:-2}function ng(t,e,r){var n=e.length-1;if(n<r)return 0;var i=fs(e[n]);return i>=0?(i>0&&(t.lastNeed=i-1),i):--n<r||i===-2?0:(i=fs(e[n]),i>=0?(i>0&&(t.lastNeed=i-2),i):--n<r||i===-2?0:(i=fs(e[n]),i>=0?(i>0&&(i===2?i=0:t.lastNeed=i-3),i):0))}function ig(t,e,r){if((e[0]&192)!==128)return t.lastNeed=0,"\uFFFD";if(t.lastNeed>1&&e.length>1){if((e[1]&192)!==128)return t.lastNeed=1,"\uFFFD";if(t.lastNeed>2&&e.length>2&&(e[2]&192)!==128)return t.lastNeed=2,"\uFFFD"}}function og(t){var e=this.lastTotal-this.lastNeed,r=ig(this,t,e);if(r!==void 0)return r;if(this.lastNeed<=t.length)return t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,e,0,t.length),this.lastNeed-=t.length}function sg(t,e){var r=ng(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)}function ag(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"\uFFFD":e}function ug(t,e){if((t.length-e)%2===0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function cg(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function fg(t,e){var r=(t.length-e)%3;return r===0?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,r===1?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function lg(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function dg(t){return t.toString(this.encoding)}function hg(t){return t&&t.length?this.write(t):""}});var ds=m((D_,If)=>{"use strict";var P_=c(f()),Af=nt(),{PromisePrototypeThen:pg,SymbolAsyncIterator:Tf,SymbolIterator:Bf}=C(),{Buffer:yg}=X(),{ERR_INVALID_ARG_TYPE:wg,ERR_STREAM_NULL_VALUES:gg}=z().codes;function bg(t,e,r){let n;if(typeof e=="string"||e instanceof yg)return new t({objectMode:!0,...r,read(){this.push(e),this.push(null)}});let i;if(e&&e[Tf])i=!0,n=e[Tf]();else if(e&&e[Bf])i=!1,n=e[Bf]();else throw new wg("iterable",["Iterable"],e);let o=new t({objectMode:!0,highWaterMark:1,...r}),s=!1;o._read=function(){s||(s=!0,l())},o._destroy=function(u,d){pg(a(u),()=>Af.nextTick(d,u),h=>Af.nextTick(d,h||u))};async function a(u){let d=u!=null,h=typeof n.throw=="function";if(d&&h){let{value:g,done:y}=await n.throw(u);if(await g,y)return}if(typeof n.return=="function"){let{value:g}=await n.return();await g}}async function l(){for(;;){try{let{value:u,done:d}=i?await n.next():n.next();if(d)o.push(null);else{let h=u&&typeof u.then=="function"?await u:u;if(h===null)throw s=!1,new gg;if(o.push(h))continue;s=!1}}catch(u){o.destroy(u)}break}}return o}If.exports=bg});var zr=m((U_,Hf)=>{var M_=c(f()),he=nt(),{ArrayPrototypeIndexOf:mg,NumberIsInteger:xg,NumberIsNaN:Eg,NumberParseInt:_g,ObjectDefineProperties:xs,ObjectKeys:vg,ObjectSetPrototypeOf:Of,Promise:Lf,SafeSet:Sg,SymbolAsyncDispose:Ag,SymbolAsyncIterator:Tg,Symbol:Bg}=C();Hf.exports=v;v.ReadableState=ti;var{EventEmitter:Ig}=Jt(),{Stream:ot,prependListener:kg}=Jn(),{Buffer:hs}=X(),{addAbortSignal:Rg}=Wr(),Cf=je(),B=H().debuglog("stream",t=>{B=t}),Og=pf(),dr=Lt(),{getHighWaterMark:Lg,getDefaultHighWaterMark:Cg}=Hr(),{aggregateTwoErrors:kf,codes:{ERR_INVALID_ARG_TYPE:Dg,ERR_METHOD_NOT_IMPLEMENTED:Pg,ERR_OUT_OF_RANGE:Ug,ERR_STREAM_PUSH_AFTER_EOF:Mg,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:Ng},AbortError:Kg}=z(),{validateObject:Fg}=ar(),Dt=Bg("kPaused"),{StringDecoder:Df}=Sf(),qg=ds();Of(v.prototype,ot.prototype);Of(v,ot);var ps=()=>{},{errorOrDestroy:fr}=dr,lr=1,jg=2,Pf=4,Jr=8,Uf=16,Zn=32,Qn=64,Mf=128,$g=256,Vg=512,Wg=1024,bs=2048,ms=4096,Hg=8192,Gg=16384,Jg=32768,Nf=65536,zg=1<<17,Yg=1<<18;function K(t){return{enumerable:!1,get(){return(this.state&t)!==0},set(e){e?this.state|=t:this.state&=~t}}}xs(ti.prototype,{objectMode:K(lr),ended:K(jg),endEmitted:K(Pf),reading:K(Jr),constructed:K(Uf),sync:K(Zn),needReadable:K(Qn),emittedReadable:K(Mf),readableListening:K($g),resumeScheduled:K(Vg),errorEmitted:K(Wg),emitClose:K(bs),autoDestroy:K(ms),destroyed:K(Hg),closed:K(Gg),closeEmitted:K(Jg),multiAwaitDrain:K(Nf),readingMore:K(zg),dataEmitted:K(Yg)});function ti(t,e,r){typeof r!="boolean"&&(r=e instanceof Ie()),this.state=bs|ms|Uf|Zn,t&&t.objectMode&&(this.state|=lr),r&&t&&t.readableObjectMode&&(this.state|=lr),this.highWaterMark=t?Lg(this,t,"readableHighWaterMark",r):Cg(!1),this.buffer=new Og,this.length=0,this.pipes=[],this.flowing=null,this[Dt]=null,t&&t.emitClose===!1&&(this.state&=~bs),t&&t.autoDestroy===!1&&(this.state&=~ms),this.errored=null,this.defaultEncoding=t&&t.defaultEncoding||"utf8",this.awaitDrainWriters=null,this.decoder=null,this.encoding=null,t&&t.encoding&&(this.decoder=new Df(t.encoding),this.encoding=t.encoding)}function v(t){if(!(this instanceof v))return new v(t);let e=this instanceof Ie();this._readableState=new ti(t,this,e),t&&(typeof t.read=="function"&&(this._read=t.read),typeof t.destroy=="function"&&(this._destroy=t.destroy),typeof t.construct=="function"&&(this._construct=t.construct),t.signal&&!e&&Rg(t.signal,this)),ot.call(this,t),dr.construct(this,()=>{this._readableState.needReadable&&ei(this,this._readableState)})}v.prototype.destroy=dr.destroy;v.prototype._undestroy=dr.undestroy;v.prototype._destroy=function(t,e){e(t)};v.prototype[Ig.captureRejectionSymbol]=function(t){this.destroy(t)};v.prototype[Ag]=function(){let t;return this.destroyed||(t=this.readableEnded?null:new Kg,this.destroy(t)),new Lf((e,r)=>Cf(this,n=>n&&n!==t?r(n):e(null)))};v.prototype.push=function(t,e){return Kf(this,t,e,!1)};v.prototype.unshift=function(t,e){return Kf(this,t,e,!0)};function Kf(t,e,r,n){B("readableAddChunk",e);let i=t._readableState,o;if(i.state&lr||(typeof e=="string"?(r=r||i.defaultEncoding,i.encoding!==r&&(n&&i.encoding?e=hs.from(e,r).toString(i.encoding):(e=hs.from(e,r),r=""))):e instanceof hs?r="":ot._isUint8Array(e)?(e=ot._uint8ArrayToBuffer(e),r=""):e!=null&&(o=new Dg("chunk",["string","Buffer","Uint8Array"],e))),o)fr(t,o);else if(e===null)i.state&=~Jr,Qg(t,i);else if(i.state&lr||e&&e.length>0)if(n)if(i.state&Pf)fr(t,new Ng);else{if(i.destroyed||i.errored)return!1;ys(t,i,e,!0)}else if(i.ended)fr(t,new Mg);else{if(i.destroyed||i.errored)return!1;i.state&=~Jr,i.decoder&&!r?(e=i.decoder.write(e),i.objectMode||e.length!==0?ys(t,i,e,!1):ei(t,i)):ys(t,i,e,!1)}else n||(i.state&=~Jr,ei(t,i));return!i.ended&&(i.length<i.highWaterMark||i.length===0)}function ys(t,e,r,n){e.flowing&&e.length===0&&!e.sync&&t.listenerCount("data")>0?(e.state&Nf?e.awaitDrainWriters.clear():e.awaitDrainWriters=null,e.dataEmitted=!0,t.emit("data",r)):(e.length+=e.objectMode?1:r.length,n?e.buffer.unshift(r):e.buffer.push(r),e.state&Qn&&ri(t)),ei(t,e)}v.prototype.isPaused=function(){let t=this._readableState;return t[Dt]===!0||t.flowing===!1};v.prototype.setEncoding=function(t){let e=new Df(t);this._readableState.decoder=e,this._readableState.encoding=this._readableState.decoder.encoding;let r=this._readableState.buffer,n="";for(let i of r)n+=e.write(i);return r.clear(),n!==""&&r.push(n),this._readableState.length=n.length,this};var Xg=1073741824;function Zg(t){if(t>Xg)throw new Ug("size","<= 1GiB",t);return t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++,t}function Rf(t,e){return t<=0||e.length===0&&e.ended?0:e.state&lr?1:Eg(t)?e.flowing&&e.length?e.buffer.first().length:e.length:t<=e.length?t:e.ended?e.length:0}v.prototype.read=function(t){B("read",t),t===void 0?t=NaN:xg(t)||(t=_g(t,10));let e=this._readableState,r=t;if(t>e.highWaterMark&&(e.highWaterMark=Zg(t)),t!==0&&(e.state&=~Mf),t===0&&e.needReadable&&((e.highWaterMark!==0?e.length>=e.highWaterMark:e.length>0)||e.ended))return B("read: emitReadable",e.length,e.ended),e.length===0&&e.ended?ws(this):ri(this),null;if(t=Rf(t,e),t===0&&e.ended)return e.length===0&&ws(this),null;let n=(e.state&Qn)!==0;if(B("need readable",n),(e.length===0||e.length-t<e.highWaterMark)&&(n=!0,B("length less than watermark",n)),e.ended||e.reading||e.destroyed||e.errored||!e.constructed)n=!1,B("reading, ended or constructing",n);else if(n){B("do read"),e.state|=Jr|Zn,e.length===0&&(e.state|=Qn);try{this._read(e.highWaterMark)}catch(o){fr(this,o)}e.state&=~Zn,e.reading||(t=Rf(r,e))}let i;return t>0?i=Vf(t,e):i=null,i===null?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.multiAwaitDrain?e.awaitDrainWriters.clear():e.awaitDrainWriters=null),e.length===0&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&ws(this)),i!==null&&!e.errorEmitted&&!e.closeEmitted&&(e.dataEmitted=!0,this.emit("data",i)),i};function Qg(t,e){if(B("onEofChunk"),!e.ended){if(e.decoder){let r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.sync?ri(t):(e.needReadable=!1,e.emittedReadable=!0,Ff(t))}}function ri(t){let e=t._readableState;B("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(B("emitReadable",e.flowing),e.emittedReadable=!0,he.nextTick(Ff,t))}function Ff(t){let e=t._readableState;B("emitReadable_",e.destroyed,e.length,e.ended),!e.destroyed&&!e.errored&&(e.length||e.ended)&&(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,jf(t)}function ei(t,e){!e.readingMore&&e.constructed&&(e.readingMore=!0,he.nextTick(eb,t,e))}function eb(t,e){for(;!e.reading&&!e.ended&&(e.length<e.highWaterMark||e.flowing&&e.length===0);){let r=e.length;if(B("maybeReadMore read 0"),t.read(0),r===e.length)break}e.readingMore=!1}v.prototype._read=function(t){throw new Pg("_read()")};v.prototype.pipe=function(t,e){let r=this,n=this._readableState;n.pipes.length===1&&(n.multiAwaitDrain||(n.multiAwaitDrain=!0,n.awaitDrainWriters=new Sg(n.awaitDrainWriters?[n.awaitDrainWriters]:[]))),n.pipes.push(t),B("pipe count=%d opts=%j",n.pipes.length,e);let o=(!e||e.end!==!1)&&t!==he.stdout&&t!==he.stderr?a:S;n.endEmitted?he.nextTick(o):r.once("end",o),t.on("unpipe",s);function s(x,T){B("onunpipe"),x===r&&T&&T.hasUnpiped===!1&&(T.hasUnpiped=!0,d())}function a(){B("onend"),t.end()}let l,u=!1;function d(){B("cleanup"),t.removeListener("close",b),t.removeListener("finish",w),l&&t.removeListener("drain",l),t.removeListener("error",y),t.removeListener("unpipe",s),r.removeListener("end",a),r.removeListener("end",S),r.removeListener("data",g),u=!0,l&&n.awaitDrainWriters&&(!t._writableState||t._writableState.needDrain)&&l()}function h(){u||(n.pipes.length===1&&n.pipes[0]===t?(B("false write response, pause",0),n.awaitDrainWriters=t,n.multiAwaitDrain=!1):n.pipes.length>1&&n.pipes.includes(t)&&(B("false write response, pause",n.awaitDrainWriters.size),n.awaitDrainWriters.add(t)),r.pause()),l||(l=tb(r,t),t.on("drain",l))}r.on("data",g);function g(x){B("ondata");let T=t.write(x);B("dest.write",T),T===!1&&h()}function y(x){if(B("onerror",x),S(),t.removeListener("error",y),t.listenerCount("error")===0){let T=t._writableState||t._readableState;T&&!T.errorEmitted?fr(t,x):t.emit("error",x)}}kg(t,"error",y);function b(){t.removeListener("finish",w),S()}t.once("close",b);function w(){B("onfinish"),t.removeListener("close",b),S()}t.once("finish",w);function S(){B("unpipe"),r.unpipe(t)}return t.emit("pipe",r),t.writableNeedDrain===!0?h():n.flowing||(B("pipe resume"),r.resume()),t};function tb(t,e){return function(){let n=t._readableState;n.awaitDrainWriters===e?(B("pipeOnDrain",1),n.awaitDrainWriters=null):n.multiAwaitDrain&&(B("pipeOnDrain",n.awaitDrainWriters.size),n.awaitDrainWriters.delete(e)),(!n.awaitDrainWriters||n.awaitDrainWriters.size===0)&&t.listenerCount("data")&&t.resume()}}v.prototype.unpipe=function(t){let e=this._readableState,r={hasUnpiped:!1};if(e.pipes.length===0)return this;if(!t){let i=e.pipes;e.pipes=[],this.pause();for(let o=0;o<i.length;o++)i[o].emit("unpipe",this,{hasUnpiped:!1});return this}let n=mg(e.pipes,t);return n===-1?this:(e.pipes.splice(n,1),e.pipes.length===0&&this.pause(),t.emit("unpipe",this,r),this)};v.prototype.on=function(t,e){let r=ot.prototype.on.call(this,t,e),n=this._readableState;return t==="data"?(n.readableListening=this.listenerCount("readable")>0,n.flowing!==!1&&this.resume()):t==="readable"&&!n.endEmitted&&!n.readableListening&&(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,B("on readable",n.length,n.reading),n.length?ri(this):n.reading||he.nextTick(rb,this)),r};v.prototype.addListener=v.prototype.on;v.prototype.removeListener=function(t,e){let r=ot.prototype.removeListener.call(this,t,e);return t==="readable"&&he.nextTick(qf,this),r};v.prototype.off=v.prototype.removeListener;v.prototype.removeAllListeners=function(t){let e=ot.prototype.removeAllListeners.apply(this,arguments);return(t==="readable"||t===void 0)&&he.nextTick(qf,this),e};function qf(t){let e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&e[Dt]===!1?e.flowing=!0:t.listenerCount("data")>0?t.resume():e.readableListening||(e.flowing=null)}function rb(t){B("readable nexttick read 0"),t.read(0)}v.prototype.resume=function(){let t=this._readableState;return t.flowing||(B("resume"),t.flowing=!t.readableListening,nb(this,t)),t[Dt]=!1,this};function nb(t,e){e.resumeScheduled||(e.resumeScheduled=!0,he.nextTick(ib,t,e))}function ib(t,e){B("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),jf(t),e.flowing&&!e.reading&&t.read(0)}v.prototype.pause=function(){return B("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(B("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState[Dt]=!0,this};function jf(t){let e=t._readableState;for(B("flow",e.flowing);e.flowing&&t.read()!==null;);}v.prototype.wrap=function(t){let e=!1;t.on("data",n=>{!this.push(n)&&t.pause&&(e=!0,t.pause())}),t.on("end",()=>{this.push(null)}),t.on("error",n=>{fr(this,n)}),t.on("close",()=>{this.destroy()}),t.on("destroy",()=>{this.destroy()}),this._read=()=>{e&&t.resume&&(e=!1,t.resume())};let r=vg(t);for(let n=1;n<r.length;n++){let i=r[n];this[i]===void 0&&typeof t[i]=="function"&&(this[i]=t[i].bind(t))}return this};v.prototype[Tg]=function(){return $f(this)};v.prototype.iterator=function(t){return t!==void 0&&Fg(t,"options"),$f(this,t)};function $f(t,e){typeof t.read!="function"&&(t=v.wrap(t,{objectMode:!0}));let r=ob(t,e);return r.stream=t,r}async function*ob(t,e){let r=ps;function n(s){this===t?(r(),r=ps):r=s}t.on("readable",n);let i,o=Cf(t,{writable:!1},s=>{i=s?kf(i,s):null,r(),r=ps});try{for(;;){let s=t.destroyed?null:t.read();if(s!==null)yield s;else{if(i)throw i;if(i===null)return;await new Lf(n)}}}catch(s){throw i=kf(i,s),i}finally{(i||e?.destroyOnReturn!==!1)&&(i===void 0||t._readableState.autoDestroy)?dr.destroyer(t,null):(t.off("readable",n),o())}}xs(v.prototype,{readable:{__proto__:null,get(){let t=this._readableState;return!!t&&t.readable!==!1&&!t.destroyed&&!t.errorEmitted&&!t.endEmitted},set(t){this._readableState&&(this._readableState.readable=!!t)}},readableDidRead:{__proto__:null,enumerable:!1,get:function(){return this._readableState.dataEmitted}},readableAborted:{__proto__:null,enumerable:!1,get:function(){return!!(this._readableState.readable!==!1&&(this._readableState.destroyed||this._readableState.errored)&&!this._readableState.endEmitted)}},readableHighWaterMark:{__proto__:null,enumerable:!1,get:function(){return this._readableState.highWaterMark}},readableBuffer:{__proto__:null,enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}},readableFlowing:{__proto__:null,enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}},readableLength:{__proto__:null,enumerable:!1,get(){return this._readableState.length}},readableObjectMode:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.objectMode:!1}},readableEncoding:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.encoding:null}},errored:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.errored:null}},closed:{__proto__:null,get(){return this._readableState?this._readableState.closed:!1}},destroyed:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.destroyed:!1},set(t){this._readableState&&(this._readableState.destroyed=t)}},readableEnded:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.endEmitted:!1}}});xs(ti.prototype,{pipesCount:{__proto__:null,get(){return this.pipes.length}},paused:{__proto__:null,get(){return this[Dt]!==!1},set(t){this[Dt]=!!t}}});v._fromList=Vf;function Vf(t,e){if(e.length===0)return null;let r;return e.objectMode?r=e.buffer.shift():!t||t>=e.length?(e.decoder?r=e.buffer.join(""):e.buffer.length===1?r=e.buffer.first():r=e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r}function ws(t){let e=t._readableState;B("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,he.nextTick(sb,e,t))}function sb(t,e){if(B("endReadableNT",t.endEmitted,t.length),!t.errored&&!t.closeEmitted&&!t.endEmitted&&t.length===0){if(t.endEmitted=!0,e.emit("end"),e.writable&&e.allowHalfOpen===!1)he.nextTick(ab,e);else if(t.autoDestroy){let r=e._writableState;(!r||r.autoDestroy&&(r.finished||r.writable===!1))&&e.destroy()}}}function ab(t){t.writable&&!t.writableEnded&&!t.destroyed&&t.end()}v.from=function(t,e){return qg(v,t,e)};var gs;function Wf(){return gs===void 0&&(gs={}),gs}v.fromWeb=function(t,e){return Wf().newStreamReadableFromReadableStream(t,e)};v.toWeb=function(t,e){return Wf().newReadableStreamFromStreamReadable(t,e)};v.wrap=function(t,e){var r,n;return new v({objectMode:(r=(n=t.readableObjectMode)!==null&&n!==void 0?n:t.objectMode)!==null&&r!==void 0?r:!0,...e,destroy(i,o){dr.destroyer(t,i),o(i)}}).wrap(t)}});var ai=m((N_,il)=>{var K_=c(f()),Pt=nt(),{ArrayPrototypeSlice:zf,Error:ub,FunctionPrototypeSymbolHasInstance:Yf,ObjectDefineProperty:Xf,ObjectDefineProperties:cb,ObjectSetPrototypeOf:Zf,StringPrototypeToLowerCase:fb,Symbol:lb,SymbolHasInstance:db}=C();il.exports=D;D.WritableState=Zr;var{EventEmitter:hb}=Jt(),Yr=Jn().Stream,{Buffer:ni}=X(),si=Lt(),{addAbortSignal:pb}=Wr(),{getHighWaterMark:yb,getDefaultHighWaterMark:wb}=Hr(),{ERR_INVALID_ARG_TYPE:gb,ERR_METHOD_NOT_IMPLEMENTED:bb,ERR_MULTIPLE_CALLBACK:Qf,ERR_STREAM_CANNOT_PIPE:mb,ERR_STREAM_DESTROYED:Xr,ERR_STREAM_ALREADY_FINISHED:xb,ERR_STREAM_NULL_VALUES:Eb,ERR_STREAM_WRITE_AFTER_END:_b,ERR_UNKNOWN_ENCODING:el}=z().codes,{errorOrDestroy:hr}=si;Zf(D.prototype,Yr.prototype);Zf(D,Yr);function vs(){}var pr=lb("kOnFinished");function Zr(t,e,r){typeof r!="boolean"&&(r=e instanceof Ie()),this.objectMode=!!(t&&t.objectMode),r&&(this.objectMode=this.objectMode||!!(t&&t.writableObjectMode)),this.highWaterMark=t?yb(this,t,"writableHighWaterMark",r):wb(!1),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;let n=!!(t&&t.decodeStrings===!1);this.decodeStrings=!n,this.defaultEncoding=t&&t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=Sb.bind(void 0,e),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,oi(this),this.pendingcb=0,this.constructed=!0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!t||t.emitClose!==!1,this.autoDestroy=!t||t.autoDestroy!==!1,this.errored=null,this.closed=!1,this.closeEmitted=!1,this[pr]=[]}function oi(t){t.buffered=[],t.bufferedIndex=0,t.allBuffers=!0,t.allNoop=!0}Zr.prototype.getBuffer=function(){return zf(this.buffered,this.bufferedIndex)};Xf(Zr.prototype,"bufferedRequestCount",{__proto__:null,get(){return this.buffered.length-this.bufferedIndex}});function D(t){let e=this instanceof Ie();if(!e&&!Yf(D,this))return new D(t);this._writableState=new Zr(t,this,e),t&&(typeof t.write=="function"&&(this._write=t.write),typeof t.writev=="function"&&(this._writev=t.writev),typeof t.destroy=="function"&&(this._destroy=t.destroy),typeof t.final=="function"&&(this._final=t.final),typeof t.construct=="function"&&(this._construct=t.construct),t.signal&&pb(t.signal,this)),Yr.call(this,t),si.construct(this,()=>{let r=this._writableState;r.writing||As(this,r),Ts(this,r)})}Xf(D,db,{__proto__:null,value:function(t){return Yf(this,t)?!0:this!==D?!1:t&&t._writableState instanceof Zr}});D.prototype.pipe=function(){hr(this,new mb)};function tl(t,e,r,n){let i=t._writableState;if(typeof r=="function")n=r,r=i.defaultEncoding;else{if(!r)r=i.defaultEncoding;else if(r!=="buffer"&&!ni.isEncoding(r))throw new el(r);typeof n!="function"&&(n=vs)}if(e===null)throw new Eb;if(!i.objectMode)if(typeof e=="string")i.decodeStrings!==!1&&(e=ni.from(e,r),r="buffer");else if(e instanceof ni)r="buffer";else if(Yr._isUint8Array(e))e=Yr._uint8ArrayToBuffer(e),r="buffer";else throw new gb("chunk",["string","Buffer","Uint8Array"],e);let o;return i.ending?o=new _b:i.destroyed&&(o=new Xr("write")),o?(Pt.nextTick(n,o),hr(t,o,!0),o):(i.pendingcb++,vb(t,i,e,r,n))}D.prototype.write=function(t,e,r){return tl(this,t,e,r)===!0};D.prototype.cork=function(){this._writableState.corked++};D.prototype.uncork=function(){let t=this._writableState;t.corked&&(t.corked--,t.writing||As(this,t))};D.prototype.setDefaultEncoding=function(e){if(typeof e=="string"&&(e=fb(e)),!ni.isEncoding(e))throw new el(e);return this._writableState.defaultEncoding=e,this};function vb(t,e,r,n,i){let o=e.objectMode?1:r.length;e.length+=o;let s=e.length<e.highWaterMark;return s||(e.needDrain=!0),e.writing||e.corked||e.errored||!e.constructed?(e.buffered.push({chunk:r,encoding:n,callback:i}),e.allBuffers&&n!=="buffer"&&(e.allBuffers=!1),e.allNoop&&i!==vs&&(e.allNoop=!1)):(e.writelen=o,e.writecb=i,e.writing=!0,e.sync=!0,t._write(r,n,e.onwrite),e.sync=!1),s&&!e.errored&&!e.destroyed}function Gf(t,e,r,n,i,o,s){e.writelen=n,e.writecb=s,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new Xr("write")):r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function Jf(t,e,r,n){--e.pendingcb,n(r),Ss(e),hr(t,r)}function Sb(t,e){let r=t._writableState,n=r.sync,i=r.writecb;if(typeof i!="function"){hr(t,new Qf);return}r.writing=!1,r.writecb=null,r.length-=r.writelen,r.writelen=0,e?(e.stack,r.errored||(r.errored=e),t._readableState&&!t._readableState.errored&&(t._readableState.errored=e),n?Pt.nextTick(Jf,t,r,e,i):Jf(t,r,e,i)):(r.buffered.length>r.bufferedIndex&&As(t,r),n?r.afterWriteTickInfo!==null&&r.afterWriteTickInfo.cb===i?r.afterWriteTickInfo.count++:(r.afterWriteTickInfo={count:1,cb:i,stream:t,state:r},Pt.nextTick(Ab,r.afterWriteTickInfo)):rl(t,r,1,i))}function Ab({stream:t,state:e,count:r,cb:n}){return e.afterWriteTickInfo=null,rl(t,e,r,n)}function rl(t,e,r,n){for(!e.ending&&!t.destroyed&&e.length===0&&e.needDrain&&(e.needDrain=!1,t.emit("drain"));r-- >0;)e.pendingcb--,n();e.destroyed&&Ss(e),Ts(t,e)}function Ss(t){if(t.writing)return;for(let i=t.bufferedIndex;i<t.buffered.length;++i){var e;let{chunk:o,callback:s}=t.buffered[i],a=t.objectMode?1:o.length;t.length-=a,s((e=t.errored)!==null&&e!==void 0?e:new Xr("write"))}let r=t[pr].splice(0);for(let i=0;i<r.length;i++){var n;r[i]((n=t.errored)!==null&&n!==void 0?n:new Xr("end"))}oi(t)}function As(t,e){if(e.corked||e.bufferProcessing||e.destroyed||!e.constructed)return;let{buffered:r,bufferedIndex:n,objectMode:i}=e,o=r.length-n;if(!o)return;let s=n;if(e.bufferProcessing=!0,o>1&&t._writev){e.pendingcb-=o-1;let a=e.allNoop?vs:u=>{for(let d=s;d<r.length;++d)r[d].callback(u)},l=e.allNoop&&s===0?r:zf(r,s);l.allBuffers=e.allBuffers,Gf(t,e,!0,e.length,l,"",a),oi(e)}else{do{let{chunk:a,encoding:l,callback:u}=r[s];r[s++]=null;let d=i?1:a.length;Gf(t,e,!1,d,a,l,u)}while(s<r.length&&!e.writing);s===r.length?oi(e):s>256?(r.splice(0,s),e.bufferedIndex=0):e.bufferedIndex=s}e.bufferProcessing=!1}D.prototype._write=function(t,e,r){if(this._writev)this._writev([{chunk:t,encoding:e}],r);else throw new bb("_write()")};D.prototype._writev=null;D.prototype.end=function(t,e,r){let n=this._writableState;typeof t=="function"?(r=t,t=null,e=null):typeof e=="function"&&(r=e,e=null);let i;if(t!=null){let o=tl(this,t,e);o instanceof ub&&(i=o)}return n.corked&&(n.corked=1,this.uncork()),i||(!n.errored&&!n.ending?(n.ending=!0,Ts(this,n,!0),n.ended=!0):n.finished?i=new xb("end"):n.destroyed&&(i=new Xr("end"))),typeof r=="function"&&(i||n.finished?Pt.nextTick(r,i):n[pr].push(r)),this};function ii(t){return t.ending&&!t.destroyed&&t.constructed&&t.length===0&&!t.errored&&t.buffered.length===0&&!t.finished&&!t.writing&&!t.errorEmitted&&!t.closeEmitted}function Tb(t,e){let r=!1;function n(i){if(r){hr(t,i??Qf());return}if(r=!0,e.pendingcb--,i){let o=e[pr].splice(0);for(let s=0;s<o.length;s++)o[s](i);hr(t,i,e.sync)}else ii(e)&&(e.prefinished=!0,t.emit("prefinish"),e.pendingcb++,Pt.nextTick(_s,t,e))}e.sync=!0,e.pendingcb++;try{t._final(n)}catch(i){n(i)}e.sync=!1}function Bb(t,e){!e.prefinished&&!e.finalCalled&&(typeof t._final=="function"&&!e.destroyed?(e.finalCalled=!0,Tb(t,e)):(e.prefinished=!0,t.emit("prefinish")))}function Ts(t,e,r){ii(e)&&(Bb(t,e),e.pendingcb===0&&(r?(e.pendingcb++,Pt.nextTick((n,i)=>{ii(i)?_s(n,i):i.pendingcb--},t,e)):ii(e)&&(e.pendingcb++,_s(t,e))))}function _s(t,e){e.pendingcb--,e.finished=!0;let r=e[pr].splice(0);for(let n=0;n<r.length;n++)r[n]();if(t.emit("finish"),e.autoDestroy){let n=t._readableState;(!n||n.autoDestroy&&(n.endEmitted||n.readable===!1))&&t.destroy()}}cb(D.prototype,{closed:{__proto__:null,get(){return this._writableState?this._writableState.closed:!1}},destroyed:{__proto__:null,get(){return this._writableState?this._writableState.destroyed:!1},set(t){this._writableState&&(this._writableState.destroyed=t)}},writable:{__proto__:null,get(){let t=this._writableState;return!!t&&t.writable!==!1&&!t.destroyed&&!t.errored&&!t.ending&&!t.ended},set(t){this._writableState&&(this._writableState.writable=!!t)}},writableFinished:{__proto__:null,get(){return this._writableState?this._writableState.finished:!1}},writableObjectMode:{__proto__:null,get(){return this._writableState?this._writableState.objectMode:!1}},writableBuffer:{__proto__:null,get(){return this._writableState&&this._writableState.getBuffer()}},writableEnded:{__proto__:null,get(){return this._writableState?this._writableState.ending:!1}},writableNeedDrain:{__proto__:null,get(){let t=this._writableState;return t?!t.destroyed&&!t.ending&&t.needDrain:!1}},writableHighWaterMark:{__proto__:null,get(){return this._writableState&&this._writableState.highWaterMark}},writableCorked:{__proto__:null,get(){return this._writableState?this._writableState.corked:0}},writableLength:{__proto__:null,get(){return this._writableState&&this._writableState.length}},errored:{__proto__:null,enumerable:!1,get(){return this._writableState?this._writableState.errored:null}},writableAborted:{__proto__:null,enumerable:!1,get:function(){return!!(this._writableState.writable!==!1&&(this._writableState.destroyed||this._writableState.errored)&&!this._writableState.finished)}}});var Ib=si.destroy;D.prototype.destroy=function(t,e){let r=this._writableState;return!r.destroyed&&(r.bufferedIndex<r.buffered.length||r[pr].length)&&Pt.nextTick(Ss,r),Ib.call(this,t,e),this};D.prototype._undestroy=si.undestroy;D.prototype._destroy=function(t,e){e(t)};D.prototype[hb.captureRejectionSymbol]=function(t){this.destroy(t)};var Es;function nl(){return Es===void 0&&(Es={}),Es}D.fromWeb=function(t,e){return nl().newStreamWritableFromWritableStream(t,e)};D.toWeb=function(t){return nl().newWritableStreamFromStreamWritable(t)}});var ml=m((F_,bl)=>{var q_=c(f()),Bs=nt(),kb=X(),{isReadable:Rb,isWritable:Ob,isIterable:ol,isNodeStream:Lb,isReadableNodeStream:sl,isWritableNodeStream:al,isDuplexNodeStream:Cb,isReadableStream:ul,isWritableStream:cl}=Ae(),fl=je(),{AbortError:wl,codes:{ERR_INVALID_ARG_TYPE:Db,ERR_INVALID_RETURN_VALUE:ll}}=z(),{destroyer:wr}=Lt(),Pb=Ie(),gl=zr(),Ub=ai(),{createDeferredPromise:dl}=H(),hl=ds(),pl=globalThis.Blob||kb.Blob,Mb=typeof pl<"u"?function(e){return e instanceof pl}:function(e){return!1},Nb=globalThis.AbortController||or().AbortController,{FunctionPrototypeCall:yl}=C(),st=class extends Pb{constructor(e){super(e),e?.readable===!1&&(this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0),e?.writable===!1&&(this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0)}};bl.exports=function t(e,r){if(Cb(e))return e;if(sl(e))return yr({readable:e});if(al(e))return yr({writable:e});if(Lb(e))return yr({writable:!1,readable:!1});if(ul(e))return yr({readable:gl.fromWeb(e)});if(cl(e))return yr({writable:Ub.fromWeb(e)});if(typeof e=="function"){let{value:i,write:o,final:s,destroy:a}=Kb(e);if(ol(i))return hl(st,i,{objectMode:!0,write:o,final:s,destroy:a});let l=i?.then;if(typeof l=="function"){let u,d=yl(l,i,h=>{if(h!=null)throw new ll("nully","body",h)},h=>{wr(u,h)});return u=new st({objectMode:!0,readable:!1,write:o,final(h){s(async()=>{try{await d,Bs.nextTick(h,null)}catch(g){Bs.nextTick(h,g)}})},destroy:a})}throw new ll("Iterable, AsyncIterable or AsyncFunction",r,i)}if(Mb(e))return t(e.arrayBuffer());if(ol(e))return hl(st,e,{objectMode:!0,writable:!1});if(ul(e?.readable)&&cl(e?.writable))return st.fromWeb(e);if(typeof e?.writable=="object"||typeof e?.readable=="object"){let i=e!=null&&e.readable?sl(e?.readable)?e?.readable:t(e.readable):void 0,o=e!=null&&e.writable?al(e?.writable)?e?.writable:t(e.writable):void 0;return yr({readable:i,writable:o})}let n=e?.then;if(typeof n=="function"){let i;return yl(n,e,o=>{o!=null&&i.push(o),i.push(null)},o=>{wr(i,o)}),i=new st({objectMode:!0,writable:!1,read(){}})}throw new Db(r,["Blob","ReadableStream","WritableStream","Stream","Iterable","AsyncIterable","Function","{ readable, writable } pair","Promise"],e)};function Kb(t){let{promise:e,resolve:r}=dl(),n=new Nb,i=n.signal;return{value:t(async function*(){for(;;){let s=e;e=null;let{chunk:a,done:l,cb:u}=await s;if(Bs.nextTick(u),l)return;if(i.aborted)throw new wl(void 0,{cause:i.reason});({promise:e,resolve:r}=dl()),yield a}}(),{signal:i}),write(s,a,l){let u=r;r=null,u({chunk:s,done:!1,cb:l})},final(s){let a=r;r=null,a({done:!0,cb:s})},destroy(s,a){n.abort(),a(s)}}}function yr(t){let e=t.readable&&typeof t.readable.read!="function"?gl.wrap(t.readable):t.readable,r=t.writable,n=!!Rb(e),i=!!Ob(r),o,s,a,l,u;function d(h){let g=l;l=null,g?g(h):h&&u.destroy(h)}return u=new st({readableObjectMode:!!(e!=null&&e.readableObjectMode),writableObjectMode:!!(r!=null&&r.writableObjectMode),readable:n,writable:i}),i&&(fl(r,h=>{i=!1,h&&wr(e,h),d(h)}),u._write=function(h,g,y){r.write(h,g)?y():o=y},u._final=function(h){r.end(),s=h},r.on("drain",function(){if(o){let h=o;o=null,h()}}),r.on("finish",function(){if(s){let h=s;s=null,h()}})),n&&(fl(e,h=>{n=!1,h&&wr(e,h),d(h)}),e.on("readable",function(){if(a){let h=a;a=null,h()}}),e.on("end",function(){u.push(null)}),u._read=function(){for(;;){let h=e.read();if(h===null){a=u._read;return}if(!u.push(h))return}}),u._destroy=function(h,g){!h&&l!==null&&(h=new wl),a=null,o=null,s=null,l===null?g(h):(l=g,wr(r,h),wr(e,h))},u}});var Ie=m((j_,_l)=>{"use strict";var $_=c(f()),{ObjectDefineProperties:Fb,ObjectGetOwnPropertyDescriptor:$e,ObjectKeys:qb,ObjectSetPrototypeOf:xl}=C();_l.exports=pe;var Rs=zr(),ue=ai();xl(pe.prototype,Rs.prototype);xl(pe,Rs);{let t=qb(ue.prototype);for(let e=0;e<t.length;e++){let r=t[e];pe.prototype[r]||(pe.prototype[r]=ue.prototype[r])}}function pe(t){if(!(this instanceof pe))return new pe(t);Rs.call(this,t),ue.call(this,t),t?(this.allowHalfOpen=t.allowHalfOpen!==!1,t.readable===!1&&(this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0),t.writable===!1&&(this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0)):this.allowHalfOpen=!0}Fb(pe.prototype,{writable:{__proto__:null,...$e(ue.prototype,"writable")},writableHighWaterMark:{__proto__:null,...$e(ue.prototype,"writableHighWaterMark")},writableObjectMode:{__proto__:null,...$e(ue.prototype,"writableObjectMode")},writableBuffer:{__proto__:null,...$e(ue.prototype,"writableBuffer")},writableLength:{__proto__:null,...$e(ue.prototype,"writableLength")},writableFinished:{__proto__:null,...$e(ue.prototype,"writableFinished")},writableCorked:{__proto__:null,...$e(ue.prototype,"writableCorked")},writableEnded:{__proto__:null,...$e(ue.prototype,"writableEnded")},writableNeedDrain:{__proto__:null,...$e(ue.prototype,"writableNeedDrain")},destroyed:{__proto__:null,get(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set(t){this._readableState&&this._writableState&&(this._readableState.destroyed=t,this._writableState.destroyed=t)}}});var Is;function El(){return Is===void 0&&(Is={}),Is}pe.fromWeb=function(t,e){return El().newStreamDuplexFromReadableWritablePair(t,e)};pe.toWeb=function(t){return El().newReadableWritablePairFromDuplex(t)};var ks;pe.from=function(t){return ks||(ks=ml()),ks(t,"body")}});var Cs=m((V_,Sl)=>{"use strict";var W_=c(f()),{ObjectSetPrototypeOf:vl,Symbol:jb}=C();Sl.exports=Ve;var{ERR_METHOD_NOT_IMPLEMENTED:$b}=z().codes,Ls=Ie(),{getHighWaterMark:Vb}=Hr();vl(Ve.prototype,Ls.prototype);vl(Ve,Ls);var Qr=jb("kCallback");function Ve(t){if(!(this instanceof Ve))return new Ve(t);let e=t?Vb(this,t,"readableHighWaterMark",!0):null;e===0&&(t={...t,highWaterMark:null,readableHighWaterMark:e,writableHighWaterMark:t.writableHighWaterMark||0}),Ls.call(this,t),this._readableState.sync=!1,this[Qr]=null,t&&(typeof t.transform=="function"&&(this._transform=t.transform),typeof t.flush=="function"&&(this._flush=t.flush)),this.on("prefinish",Wb)}function Os(t){typeof this._flush=="function"&&!this.destroyed?this._flush((e,r)=>{if(e){t?t(e):this.destroy(e);return}r!=null&&this.push(r),this.push(null),t&&t()}):(this.push(null),t&&t())}function Wb(){this._final!==Os&&Os.call(this)}Ve.prototype._final=Os;Ve.prototype._transform=function(t,e,r){throw new $b("_transform()")};Ve.prototype._write=function(t,e,r){let n=this._readableState,i=this._writableState,o=n.length;this._transform(t,e,(s,a)=>{if(s){r(s);return}a!=null&&this.push(a),i.ended||o===n.length||n.length<n.highWaterMark?r():this[Qr]=r})};Ve.prototype._read=function(){if(this[Qr]){let t=this[Qr];this[Qr]=null,t()}}});var Ps=m((H_,Tl)=>{"use strict";var G_=c(f()),{ObjectSetPrototypeOf:Al}=C();Tl.exports=gr;var Ds=Cs();Al(gr.prototype,Ds.prototype);Al(gr,Ds);function gr(t){if(!(this instanceof gr))return new gr(t);Ds.call(this,t)}gr.prototype._transform=function(t,e,r){r(null,t)}});var li=m((J_,Ol)=>{var z_=c(f()),en=nt(),{ArrayIsArray:Hb,Promise:Gb,SymbolAsyncIterator:Jb,SymbolDispose:zb}=C(),fi=je(),{once:Yb}=H(),Xb=Lt(),Bl=Ie(),{aggregateTwoErrors:Zb,codes:{ERR_INVALID_ARG_TYPE:Vs,ERR_INVALID_RETURN_VALUE:Us,ERR_MISSING_ARGS:Qb,ERR_STREAM_DESTROYED:em,ERR_STREAM_PREMATURE_CLOSE:tm},AbortError:rm}=z(),{validateFunction:nm,validateAbortSignal:im}=ar(),{isIterable:Ut,isReadable:Ms,isReadableNodeStream:ci,isNodeStream:Il,isTransformStream:br,isWebStream:om,isReadableStream:Ns,isReadableFinished:sm}=Ae(),am=globalThis.AbortController||or().AbortController,Ks,Fs,qs;function kl(t,e,r){let n=!1;t.on("close",()=>{n=!0});let i=fi(t,{readable:e,writable:r},o=>{n=!o});return{destroy:o=>{n||(n=!0,Xb.destroyer(t,o||new em("pipe")))},cleanup:i}}function um(t){return nm(t[t.length-1],"streams[stream.length - 1]"),t.pop()}function js(t){if(Ut(t))return t;if(ci(t))return cm(t);throw new Vs("val",["Readable","Iterable","AsyncIterable"],t)}async function*cm(t){Fs||(Fs=zr()),yield*Fs.prototype[Jb].call(t)}async function ui(t,e,r,{end:n}){let i,o=null,s=u=>{if(u&&(i=u),o){let d=o;o=null,d()}},a=()=>new Gb((u,d)=>{i?d(i):o=()=>{i?d(i):u()}});e.on("drain",s);let l=fi(e,{readable:!1},s);try{e.writableNeedDrain&&await a();for await(let u of t)e.write(u)||await a();n&&(e.end(),await a()),r()}catch(u){r(i!==u?Zb(i,u):u)}finally{l(),e.off("drain",s)}}async function $s(t,e,r,{end:n}){br(e)&&(e=e.writable);let i=e.getWriter();try{for await(let o of t)await i.ready,i.write(o).catch(()=>{});await i.ready,n&&await i.close(),r()}catch(o){try{await i.abort(o),r(o)}catch(s){r(s)}}}function fm(...t){return Rl(t,Yb(um(t)))}function Rl(t,e,r){if(t.length===1&&Hb(t[0])&&(t=t[0]),t.length<2)throw new Qb("streams");let n=new am,i=n.signal,o=r?.signal,s=[];im(o,"options.signal");function a(){b(new rm)}qs=qs||H().addAbortListener;let l;o&&(l=qs(o,a));let u,d,h=[],g=0;function y(k){b(k,--g===0)}function b(k,E){var I;if(k&&(!u||u.code==="ERR_STREAM_PREMATURE_CLOSE")&&(u=k),!(!u&&!E)){for(;h.length;)h.shift()(u);(I=l)===null||I===void 0||I[zb](),n.abort(),E&&(u||s.forEach($=>$()),en.nextTick(e,u,d))}}let w;for(let k=0;k<t.length;k++){let E=t[k],I=k<t.length-1,$=k>0,L=I||r?.end!==!1,V=k===t.length-1;if(Il(E)){let N=function(Re){Re&&Re.name!=="AbortError"&&Re.code!=="ERR_STREAM_PREMATURE_CLOSE"&&y(Re)};var T=N;if(L){let{destroy:Re,cleanup:_i}=kl(E,I,$);h.push(Re),Ms(E)&&V&&s.push(_i)}E.on("error",N),Ms(E)&&V&&s.push(()=>{E.removeListener("error",N)})}if(k===0)if(typeof E=="function"){if(w=E({signal:i}),!Ut(w))throw new Us("Iterable, AsyncIterable or Stream","source",w)}else Ut(E)||ci(E)||br(E)?w=E:w=Bl.from(E);else if(typeof E=="function"){if(br(w)){var S;w=js((S=w)===null||S===void 0?void 0:S.readable)}else w=js(w);if(w=E(w,{signal:i}),I){if(!Ut(w,!0))throw new Us("AsyncIterable",`transform[${k-1}]`,w)}else{var x;Ks||(Ks=Ps());let N=new Ks({objectMode:!0}),Re=(x=w)===null||x===void 0?void 0:x.then;if(typeof Re=="function")g++,Re.call(w,He=>{d=He,He!=null&&N.write(He),L&&N.end(),en.nextTick(y)},He=>{N.destroy(He),en.nextTick(y,He)});else if(Ut(w,!0))g++,ui(w,N,y,{end:L});else if(Ns(w)||br(w)){let He=w.readable||w;g++,ui(He,N,y,{end:L})}else throw new Us("AsyncIterable or Promise","destination",w);w=N;let{destroy:_i,cleanup:yd}=kl(w,!1,!0);h.push(_i),V&&s.push(yd)}}else if(Il(E)){if(ci(w)){g+=2;let N=lm(w,E,y,{end:L});Ms(E)&&V&&s.push(N)}else if(br(w)||Ns(w)){let N=w.readable||w;g++,ui(N,E,y,{end:L})}else if(Ut(w))g++,ui(w,E,y,{end:L});else throw new Vs("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],w);w=E}else if(om(E)){if(ci(w))g++,$s(js(w),E,y,{end:L});else if(Ns(w)||Ut(w))g++,$s(w,E,y,{end:L});else if(br(w))g++,$s(w.readable,E,y,{end:L});else throw new Vs("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],w);w=E}else w=Bl.from(E)}return(i!=null&&i.aborted||o!=null&&o.aborted)&&en.nextTick(a),w}function lm(t,e,r,{end:n}){let i=!1;if(e.on("close",()=>{i||r(new tm)}),t.pipe(e,{end:!1}),n){let s=function(){i=!0,e.end()};var o=s;sm(t)?en.nextTick(s):t.once("end",s)}else r();return fi(t,{readable:!0,writable:!1},s=>{let a=t._readableState;s&&s.code==="ERR_STREAM_PREMATURE_CLOSE"&&a&&a.ended&&!a.errored&&!a.errorEmitted?t.once("end",r).once("error",r):r(s)}),fi(e,{readable:!1,writable:!0},r)}Ol.exports={pipelineImpl:Rl,pipeline:fm}});var Hs=m((Y_,Ml)=>{"use strict";var X_=c(f()),{pipeline:dm}=li(),di=Ie(),{destroyer:hm}=Lt(),{isNodeStream:hi,isReadable:Ll,isWritable:Cl,isWebStream:Ws,isTransformStream:Mt,isWritableStream:Dl,isReadableStream:Pl}=Ae(),{AbortError:pm,codes:{ERR_INVALID_ARG_VALUE:Ul,ERR_MISSING_ARGS:ym}}=z(),wm=je();Ml.exports=function(...e){if(e.length===0)throw new ym("streams");if(e.length===1)return di.from(e[0]);let r=[...e];if(typeof e[0]=="function"&&(e[0]=di.from(e[0])),typeof e[e.length-1]=="function"){let y=e.length-1;e[y]=di.from(e[y])}for(let y=0;y<e.length;++y)if(!(!hi(e[y])&&!Ws(e[y]))){if(y<e.length-1&&!(Ll(e[y])||Pl(e[y])||Mt(e[y])))throw new Ul(`streams[${y}]`,r[y],"must be readable");if(y>0&&!(Cl(e[y])||Dl(e[y])||Mt(e[y])))throw new Ul(`streams[${y}]`,r[y],"must be writable")}let n,i,o,s,a;function l(y){let b=s;s=null,b?b(y):y?a.destroy(y):!g&&!h&&a.destroy()}let u=e[0],d=dm(e,l),h=!!(Cl(u)||Dl(u)||Mt(u)),g=!!(Ll(d)||Pl(d)||Mt(d));if(a=new di({writableObjectMode:!!(u!=null&&u.writableObjectMode),readableObjectMode:!!(d!=null&&d.readableObjectMode),writable:h,readable:g}),h){if(hi(u))a._write=function(b,w,S){u.write(b,w)?S():n=S},a._final=function(b){u.end(),i=b},u.on("drain",function(){if(n){let b=n;n=null,b()}});else if(Ws(u)){let w=(Mt(u)?u.writable:u).getWriter();a._write=async function(S,x,T){try{await w.ready,w.write(S).catch(()=>{}),T()}catch(k){T(k)}},a._final=async function(S){try{await w.ready,w.close().catch(()=>{}),i=S}catch(x){S(x)}}}let y=Mt(d)?d.readable:d;wm(y,()=>{if(i){let b=i;i=null,b()}})}if(g){if(hi(d))d.on("readable",function(){if(o){let y=o;o=null,y()}}),d.on("end",function(){a.push(null)}),a._read=function(){for(;;){let y=d.read();if(y===null){o=a._read;return}if(!a.push(y))return}};else if(Ws(d)){let b=(Mt(d)?d.readable:d).getReader();a._read=async function(){for(;;)try{let{value:w,done:S}=await b.read();if(!a.push(w))return;if(S){a.push(null);return}}catch{return}}}}return a._destroy=function(y,b){!y&&s!==null&&(y=new pm),o=null,n=null,i=null,s===null?b(y):(s=b,hi(d)&&hm(d,y))},a}});var Gl=m((Z_,zs)=>{"use strict";var Q_=c(f()),gm=globalThis.AbortController||or().AbortController,{codes:{ERR_INVALID_ARG_VALUE:bm,ERR_INVALID_ARG_TYPE:tn,ERR_MISSING_ARGS:mm,ERR_OUT_OF_RANGE:xm},AbortError:ke}=z(),{validateAbortSignal:Nt,validateInteger:Nl,validateObject:Kt}=ar(),Em=C().Symbol("kWeak"),_m=C().Symbol("kResistStopPropagation"),{finished:vm}=je(),Sm=Hs(),{addAbortSignalNoValidate:Am}=Wr(),{isWritable:Tm,isNodeStream:Bm}=Ae(),{deprecate:Im}=H(),{ArrayPrototypePush:km,Boolean:Rm,MathFloor:Kl,Number:Om,NumberIsNaN:Lm,Promise:Fl,PromiseReject:ql,PromiseResolve:Cm,PromisePrototypeThen:jl,Symbol:Vl}=C(),pi=Vl("kEmpty"),$l=Vl("kEof");function Dm(t,e){if(e!=null&&Kt(e,"options"),e?.signal!=null&&Nt(e.signal,"options.signal"),Bm(t)&&!Tm(t))throw new bm("stream",t,"must be writable");let r=Sm(this,t);return e!=null&&e.signal&&Am(e.signal,r),r}function yi(t,e){if(typeof t!="function")throw new tn("fn",["Function","AsyncFunction"],t);e!=null&&Kt(e,"options"),e?.signal!=null&&Nt(e.signal,"options.signal");let r=1;e?.concurrency!=null&&(r=Kl(e.concurrency));let n=r-1;return e?.highWaterMark!=null&&(n=Kl(e.highWaterMark)),Nl(r,"options.concurrency",1),Nl(n,"options.highWaterMark",0),n+=r,(async function*(){let o=H().AbortSignalAny([e?.signal].filter(Rm)),s=this,a=[],l={signal:o},u,d,h=!1,g=0;function y(){h=!0,b()}function b(){g-=1,w()}function w(){d&&!h&&g<r&&a.length<n&&(d(),d=null)}async function S(){try{for await(let x of s){if(h)return;if(o.aborted)throw new ke;try{if(x=t(x,l),x===pi)continue;x=Cm(x)}catch(T){x=ql(T)}g+=1,jl(x,b,y),a.push(x),u&&(u(),u=null),!h&&(a.length>=n||g>=r)&&await new Fl(T=>{d=T})}a.push($l)}catch(x){let T=ql(x);jl(T,b,y),a.push(T)}finally{h=!0,u&&(u(),u=null)}}S();try{for(;;){for(;a.length>0;){let x=await a[0];if(x===$l)return;if(o.aborted)throw new ke;x!==pi&&(yield x),a.shift(),w()}await new Fl(x=>{u=x})}}finally{h=!0,d&&(d(),d=null)}}).call(this)}function Pm(t=void 0){return t!=null&&Kt(t,"options"),t?.signal!=null&&Nt(t.signal,"options.signal"),(async function*(){let r=0;for await(let i of this){var n;if(t!=null&&(n=t.signal)!==null&&n!==void 0&&n.aborted)throw new ke({cause:t.signal.reason});yield[r++,i]}}).call(this)}async function Wl(t,e=void 0){for await(let r of Js.call(this,t,e))return!0;return!1}async function Um(t,e=void 0){if(typeof t!="function")throw new tn("fn",["Function","AsyncFunction"],t);return!await Wl.call(this,async(...r)=>!await t(...r),e)}async function Mm(t,e){for await(let r of Js.call(this,t,e))return r}async function Nm(t,e){if(typeof t!="function")throw new tn("fn",["Function","AsyncFunction"],t);async function r(n,i){return await t(n,i),pi}for await(let n of yi.call(this,r,e));}function Js(t,e){if(typeof t!="function")throw new tn("fn",["Function","AsyncFunction"],t);async function r(n,i){return await t(n,i)?n:pi}return yi.call(this,r,e)}var Gs=class extends mm{constructor(){super("reduce"),this.message="Reduce of an empty stream requires an initial value"}};async function Km(t,e,r){var n;if(typeof t!="function")throw new tn("reducer",["Function","AsyncFunction"],t);r!=null&&Kt(r,"options"),r?.signal!=null&&Nt(r.signal,"options.signal");let i=arguments.length>1;if(r!=null&&(n=r.signal)!==null&&n!==void 0&&n.aborted){let u=new ke(void 0,{cause:r.signal.reason});throw this.once("error",()=>{}),await vm(this.destroy(u)),u}let o=new gm,s=o.signal;if(r!=null&&r.signal){let u={once:!0,[Em]:this,[_m]:!0};r.signal.addEventListener("abort",()=>o.abort(),u)}let a=!1;try{for await(let u of this){var l;if(a=!0,r!=null&&(l=r.signal)!==null&&l!==void 0&&l.aborted)throw new ke;i?e=await t(e,u,{signal:s}):(e=u,i=!0)}if(!a&&!i)throw new Gs}finally{o.abort()}return e}async function Fm(t){t!=null&&Kt(t,"options"),t?.signal!=null&&Nt(t.signal,"options.signal");let e=[];for await(let n of this){var r;if(t!=null&&(r=t.signal)!==null&&r!==void 0&&r.aborted)throw new ke(void 0,{cause:t.signal.reason});km(e,n)}return e}function qm(t,e){let r=yi.call(this,t,e);return(async function*(){for await(let i of r)yield*i}).call(this)}function Hl(t){if(t=Om(t),Lm(t))return 0;if(t<0)throw new xm("number",">= 0",t);return t}function jm(t,e=void 0){return e!=null&&Kt(e,"options"),e?.signal!=null&&Nt(e.signal,"options.signal"),t=Hl(t),(async function*(){var n;if(e!=null&&(n=e.signal)!==null&&n!==void 0&&n.aborted)throw new ke;for await(let o of this){var i;if(e!=null&&(i=e.signal)!==null&&i!==void 0&&i.aborted)throw new ke;t--<=0&&(yield o)}}).call(this)}function $m(t,e=void 0){return e!=null&&Kt(e,"options"),e?.signal!=null&&Nt(e.signal,"options.signal"),t=Hl(t),(async function*(){var n;if(e!=null&&(n=e.signal)!==null&&n!==void 0&&n.aborted)throw new ke;for await(let o of this){var i;if(e!=null&&(i=e.signal)!==null&&i!==void 0&&i.aborted)throw new ke;if(t-- >0&&(yield o),t<=0)return}}).call(this)}zs.exports.streamReturningOperators={asIndexedPairs:Im(Pm,"readable.asIndexedPairs will be removed in a future version."),drop:jm,filter:Js,flatMap:qm,map:yi,take:$m,compose:Dm};zs.exports.promiseReturningOperators={every:Um,forEach:Nm,reduce:Km,toArray:Fm,some:Wl,find:Mm}});var Ys=m((ev,Jl)=>{"use strict";var tv=c(f()),{ArrayPrototypePop:Vm,Promise:Wm}=C(),{isIterable:Hm,isNodeStream:Gm,isWebStream:Jm}=Ae(),{pipelineImpl:zm}=li(),{finished:Ym}=je();Xs();function Xm(...t){return new Wm((e,r)=>{let n,i,o=t[t.length-1];if(o&&typeof o=="object"&&!Gm(o)&&!Hm(o)&&!Jm(o)){let s=Vm(t);n=s.signal,i=s.end}zm(t,(s,a)=>{s?r(s):e(a)},{signal:n,end:i})})}Jl.exports={finished:Ym,pipeline:Xm}});var Xs=m((rv,nd)=>{var nv=c(f()),{Buffer:Zm}=X(),{ObjectDefineProperty:We,ObjectKeys:Xl,ReflectApply:Zl}=C(),{promisify:{custom:Ql}}=H(),{streamReturningOperators:zl,promiseReturningOperators:Yl}=Gl(),{codes:{ERR_ILLEGAL_CONSTRUCTOR:ed}}=z(),Qm=Hs(),{setDefaultHighWaterMark:e0,getDefaultHighWaterMark:t0}=Hr(),{pipeline:td}=li(),{destroyer:r0}=Lt(),rd=je(),Zs=Ys(),rn=Ae(),O=nd.exports=Jn().Stream;O.isDestroyed=rn.isDestroyed;O.isDisturbed=rn.isDisturbed;O.isErrored=rn.isErrored;O.isReadable=rn.isReadable;O.isWritable=rn.isWritable;O.Readable=zr();for(let t of Xl(zl)){let r=function(...n){if(new.target)throw ed();return O.Readable.from(Zl(e,this,n))};Qs=r;let e=zl[t];We(r,"name",{__proto__:null,value:e.name}),We(r,"length",{__proto__:null,value:e.length}),We(O.Readable.prototype,t,{__proto__:null,value:r,enumerable:!1,configurable:!0,writable:!0})}var Qs;for(let t of Xl(Yl)){let r=function(...i){if(new.target)throw ed();return Zl(e,this,i)};Qs=r;let e=Yl[t];We(r,"name",{__proto__:null,value:e.name}),We(r,"length",{__proto__:null,value:e.length}),We(O.Readable.prototype,t,{__proto__:null,value:r,enumerable:!1,configurable:!0,writable:!0})}var Qs;O.Writable=ai();O.Duplex=Ie();O.Transform=Cs();O.PassThrough=Ps();O.pipeline=td;var{addAbortSignal:n0}=Wr();O.addAbortSignal=n0;O.finished=rd;O.destroy=r0;O.compose=Qm;O.setDefaultHighWaterMark=e0;O.getDefaultHighWaterMark=t0;We(O,"promises",{__proto__:null,configurable:!0,enumerable:!0,get(){return Zs}});We(td,Ql,{__proto__:null,enumerable:!0,get(){return Zs.pipeline}});We(rd,Ql,{__proto__:null,enumerable:!0,get(){return Zs.finished}});O.Stream=O;O._isUint8Array=function(e){return e instanceof Uint8Array};O._uint8ArrayToBuffer=function(e){return Zm.from(e.buffer,e.byteOffset,e.byteLength)}});var ea=m((iv,M)=>{"use strict";var ov=c(f()),F=Xs(),i0=Ys(),o0=F.Readable.destroy;M.exports=F.Readable;M.exports._uint8ArrayToBuffer=F._uint8ArrayToBuffer;M.exports._isUint8Array=F._isUint8Array;M.exports.isDisturbed=F.isDisturbed;M.exports.isErrored=F.isErrored;M.exports.isReadable=F.isReadable;M.exports.Readable=F.Readable;M.exports.Writable=F.Writable;M.exports.Duplex=F.Duplex;M.exports.Transform=F.Transform;M.exports.PassThrough=F.PassThrough;M.exports.addAbortSignal=F.addAbortSignal;M.exports.finished=F.finished;M.exports.destroy=F.destroy;M.exports.destroy=o0;M.exports.pipeline=F.pipeline;M.exports.compose=F.compose;Object.defineProperty(F,"promises",{configurable:!0,enumerable:!0,get(){return i0}});M.exports.Stream=F.Stream;M.exports.default=M.exports});var wT=c(f(),1);var dv=c(f(),1);var I0=c(f(),1),ih=c(Ra(),1);var fx=c(f(),1);var H0=c(f(),1);var U0=c(f(),1);var R0=c(f(),1),k0=new Uint8Array(0);function Oa(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function Vt(t){if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")}var L0=c(f(),1);function sh(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<t.length;i++){var o=t.charAt(i),s=o.charCodeAt(0);if(r[s]!==255)throw new TypeError(o+" is ambiguous");r[s]=i}var a=t.length,l=t.charAt(0),u=Math.log(a)/Math.log(256),d=Math.log(256)/Math.log(a);function h(b){if(b instanceof Uint8Array||(ArrayBuffer.isView(b)?b=new Uint8Array(b.buffer,b.byteOffset,b.byteLength):Array.isArray(b)&&(b=Uint8Array.from(b))),!(b instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(b.length===0)return"";for(var w=0,S=0,x=0,T=b.length;x!==T&&b[x]===0;)x++,w++;for(var k=(T-x)*d+1>>>0,E=new Uint8Array(k);x!==T;){for(var I=b[x],$=0,L=k-1;(I!==0||$<S)&&L!==-1;L--,$++)I+=256*E[L]>>>0,E[L]=I%a>>>0,I=I/a>>>0;if(I!==0)throw new Error("Non-zero carry");S=$,x++}for(var V=k-S;V!==k&&E[V]===0;)V++;for(var N=l.repeat(w);V<k;++V)N+=t.charAt(E[V]);return N}function g(b){if(typeof b!="string")throw new TypeError("Expected String");if(b.length===0)return new Uint8Array;var w=0;if(b[w]!==" "){for(var S=0,x=0;b[w]===l;)S++,w++;for(var T=(b.length-w)*u+1>>>0,k=new Uint8Array(T);b[w];){var E=r[b.charCodeAt(w)];if(E===255)return;for(var I=0,$=T-1;(E!==0||I<x)&&$!==-1;$--,I++)E+=a*k[$]>>>0,k[$]=E%256>>>0,E=E/256>>>0;if(E!==0)throw new Error("Non-zero carry");x=I,w++}if(b[w]!==" "){for(var L=T-x;L!==T&&k[L]===0;)L++;for(var V=new Uint8Array(S+(T-L)),N=S;L!==T;)V[N++]=k[L++];return V}}}function y(b){var w=g(b);if(w)return w;throw new Error(`Non-${e} character`)}return{encode:h,decodeUnsafe:g,decode:y}}var ah=sh,uh=ah,La=uh;var Ui=class{name;prefix;baseEncode;constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Mi=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Ca(this,e)}},Ni=class{decoders;constructor(e){this.decoders=e}or(e){return Ca(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Ca(t,e){return new Ni({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var Ki=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new Ui(e,r,n),this.decoder=new Mi(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Da({name:t,prefix:e,encode:r,decode:n}){return new Ki(t,e,r,n)}function Fi({name:t,prefix:e,alphabet:r}){let{encode:n,decode:i}=La(r,t);return Da({prefix:e,name:t,encode:n,decode:o=>Vt(i(o))})}function ch(t,e,r,n){let i={};for(let d=0;d<e.length;++d)i[e[d]]=d;let o=t.length;for(;t[o-1]==="=";)--o;let s=new Uint8Array(o*r/8|0),a=0,l=0,u=0;for(let d=0;d<o;++d){let h=i[t[d]];if(h===void 0)throw new SyntaxError(`Non-${n} character`);l=l<<r|h,a+=r,a>=8&&(a-=8,s[u++]=255&l>>a)}if(a>=r||255&l<<8-a)throw new SyntaxError("Unexpected end of data");return s}function fh(t,e,r){let n=e[e.length-1]==="=",i=(1<<r)-1,o="",s=0,a=0;for(let l=0;l<t.length;++l)for(a=a<<8|t[l],s+=8;s>r;)s-=r,o+=e[i&a>>s];if(s!==0&&(o+=e[i&a<<r-s]),n)for(;o.length*r&7;)o+="=";return o}function J({name:t,prefix:e,bitsPerChar:r,alphabet:n}){return Da({prefix:e,name:t,encode(i){return fh(i,n,r)},decode(i){return ch(i,n,r,t)}})}var xr=J({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),N0=J({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),K0=J({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),F0=J({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),q0=J({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),j0=J({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),$0=J({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),V0=J({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),qi=J({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Y0=c(f(),1);var Z=Fi({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),J0=Fi({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var rx=c(f(),1);var Z0=J({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Q0=J({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),be=J({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ex=J({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var ix=c(f(),1);function Pa(t){return t.byteOffset!==0||t.byteLength!==t.buffer.byteLength}function Ua(t){return typeof t!="object"||t===null?!1:typeof t[Symbol.asyncIterator]=="function"}function cn(t){let r=Object.prototype.toString.call(t).match(/\s([a-zA-Z0-9]+)/),[n,i]=r;return i}var Er=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(d){try{u(n.next(d))}catch(h){s(h)}}function l(d){try{u(n.throw(d))}catch(h){s(h)}}function u(d){d.done?o(d.value):i(d.value).then(a,l)}u((n=n.apply(t,e||[])).next())})},Ma=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof __values=="function"?__values(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(o){r[o]=t[o]&&function(s){return new Promise(function(a,l){s=t[o](s),i(a,l,s.done,s.value)})}}function i(o,s,a,l){Promise.resolve(l).then(function(u){o({value:u,done:a})},s)}},fn=new TextEncoder,lt=new TextDecoder,P=class t{constructor(e,r){this.data=e,this.format=r}static arrayBuffer(e){return new t(e,"ArrayBuffer")}static asyncIterable(e){if(!Ua(e))throw new TypeError("Input must be of type AsyncIterable.");return new t(e,"AsyncIterable")}static base32Z(e){return new t(e,"Base32Z")}static base58Btc(e){return new t(e,"Base58Btc")}static base64Url(e){return new t(e,"Base64Url")}static bufferSource(e){return new t(e,"BufferSource")}static hex(e){if(typeof e!="string")throw new TypeError("Hex input must be a string.");if(e.length%2!==0)throw new TypeError("Hex input must have an even number of characters.");return new t(e,"Hex")}static multibase(e){return new t(e,"Multibase")}static object(e){return new t(e,"Object")}static string(e){return new t(e,"String")}static uint8Array(e){return new t(e,"Uint8Array")}toArrayBuffer(){switch(this.format){case"Base58Btc":return Z.baseDecode(this.data).buffer;case"Base64Url":return be.baseDecode(this.data).buffer;case"BufferSource":{if(cn(this.data)==="ArrayBuffer")return this.data;if(ArrayBuffer.isView(this.data))return Pa(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 Er(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 qi.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 Z.baseEncode(e)}case"Multibase":return this.data.substring(1);case"Uint8Array":return Z.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 be.baseEncode(e)}case"BufferSource":{let e=this.toUint8Array();return be.baseEncode(e)}case"Object":{let e=JSON.stringify(this.data),r=fn.encode(e);return be.baseEncode(r)}case"String":{let e=fn.encode(this.data);return be.baseEncode(e)}case"Uint8Array":return be.baseEncode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Base64Url is not supported.`)}}toBlobAsync(){return Er(this,void 0,void 0,function*(){var e,r,n,i;switch(this.format){case"AsyncIterable":{let l=[];try{for(var o=!0,s=Ma(this.data),a;a=yield s.next(),e=a.done,!e;o=!0){i=a.value,o=!1;let d=i;l.push(d)}}catch(d){r={error:d}}finally{try{!o&&!e&&(n=s.return)&&(yield n.call(s))}finally{if(r)throw r.error}}return new Blob(l)}default:throw new TypeError(`Asynchronous conversion from ${this.format} to Blob is not supported.`)}})}toHex(){let e=Array.from({length:256},(r,n)=>n.toString(16).padStart(2,"0"));switch(this.format){case"ArrayBuffer":{let r=this.toUint8Array();return t.uint8Array(r).toHex()}case"Base64Url":{let r=this.toUint8Array();return t.uint8Array(r).toHex()}case"Uint8Array":{let r="";for(let n=0;n<this.data.length;n++)r+=e[this.data[n]];return r}default:throw new TypeError(`Conversion from ${this.format} to Hex is not supported.`)}}toMultibase(){switch(this.format){case"Base58Btc":return`z${this.data}`;default:throw new TypeError(`Conversion from ${this.format} to Multibase is not supported.`)}}toObject(){switch(this.format){case"Base64Url":{let e=be.baseDecode(this.data),r=lt.decode(e);return JSON.parse(r)}case"String":return JSON.parse(this.data);case"Uint8Array":{let e=lt.decode(this.data);return JSON.parse(e)}default:throw new TypeError(`Conversion from ${this.format} to Object is not supported.`)}}toObjectAsync(){return Er(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 lt.decode(this.data);case"Base64Url":{let e=be.baseDecode(this.data);return lt.decode(e)}case"Object":return JSON.stringify(this.data);case"Uint8Array":return lt.decode(this.data);default:throw new TypeError(`Conversion from ${this.format} to String is not supported.`)}}toStringAsync(){return Er(this,void 0,void 0,function*(){var e,r,n,i;switch(this.format){case"AsyncIterable":{let l="";try{for(var o=!0,s=Ma(this.data),a;a=yield s.next(),e=a.done,!e;o=!0){i=a.value,o=!1;let u=i;typeof u=="string"?l+=u:l+=lt.decode(u,{stream:!0})}}catch(u){r={error:u}}finally{try{!o&&!e&&(n=s.return)&&(yield n.call(s))}finally{if(r)throw r.error}}return l+=lt.decode(void 0,{stream:!1}),l}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 qi.baseDecode(this.data);case"Base58Btc":return Z.baseDecode(this.data);case"Base64Url":return be.baseDecode(this.data);case"BufferSource":{let e=cn(this.data);if(e==="Uint8Array")return this.data;if(e==="ArrayBuffer")return new Uint8Array(this.data);if(ArrayBuffer.isView(this.data))return new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength);throw new TypeError(`${this.format} value is not of type: ArrayBuffer, DataView, or TypedArray.`)}case"Hex":{let e=new Uint8Array(this.data.length/2);for(let r=0;r<this.data.length;r+=2){let n=parseInt(this.data.substring(r,r+2),16);if(isNaN(n))throw new TypeError("Input is not a valid hexadecimal string.");e[r/2]=n}return e}case"Object":{let e=JSON.stringify(this.data);return fn.encode(e)}case"String":return fn.encode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Uint8Array is not supported.`)}}toUint8ArrayAsync(){return Er(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 dx=c(f(),1),_r;(function(t){t.Debug="debug",t.Silent="silent"})(_r||(_r={}));var ji=class{constructor(){this.logLevel=_r.Silent}setLogLevel(e){this.logLevel=e}log(e){this.info(e)}info(e){this.logLevel!==_r.Silent&&console.info(e)}error(e){this.logLevel!==_r.Silent&&console.error(e)}},lh=new ji;typeof window<"u"&&(window.web5logger=lh);var $x=c(f(),1);var Kx=c(f(),1);var Sx=c(f(),1);var bx=c(f(),1);var Le={};Ed(Le,{decode:()=>Wt,encodeTo:()=>dt,encodingLength:()=>ht});var wx=c(f(),1);var px=c(f(),1),dh=Fa,Na=128,hh=127,ph=~hh,yh=Math.pow(2,31);function Fa(t,e,r){e=e||[],r=r||0;for(var n=r;t>=yh;)e[r++]=t&255|Na,t/=128;for(;t&ph;)e[r++]=t&255|Na,t>>>=7;return e[r]=t|0,Fa.bytes=r-n+1,e}var wh=$i,gh=128,Ka=127;function $i(t,n){var r=0,n=n||0,i=0,o=n,s,a=t.length;do{if(o>=a)throw $i.bytes=0,new RangeError("Could not decode varint");s=t[o++],r+=i<28?(s&Ka)<<i:(s&Ka)*Math.pow(2,i),i+=7}while(s>=gh);return $i.bytes=o-n,r}var bh=Math.pow(2,7),mh=Math.pow(2,14),xh=Math.pow(2,21),Eh=Math.pow(2,28),_h=Math.pow(2,35),vh=Math.pow(2,42),Sh=Math.pow(2,49),Ah=Math.pow(2,56),Th=Math.pow(2,63),Bh=function(t){return t<bh?1:t<mh?2:t<xh?3:t<Eh?4:t<_h?5:t<vh?6:t<Sh?7:t<Ah?8:t<Th?9:10},Ih={encode:dh,decode:wh,encodingLength:Bh},kh=Ih,vr=kh;function Wt(t,e=0){return[vr.decode(t,e),vr.decode.bytes]}function dt(t,e,r=0){return vr.encode(t,e,r),e}function ht(t){return vr.encodingLength(t)}function Vi(t,e){let r=e.byteLength,n=ht(t),i=n+ht(r),o=new Uint8Array(i+r);return dt(t,o,0),dt(r,o,n),o.set(e,i),new Ht(t,r,e,o)}function qa(t){let e=Vt(t),[r,n]=Wt(e),[i,o]=Wt(e.subarray(n)),s=e.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new Ht(r,i,s,e)}function ja(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&Oa(t.bytes,r.bytes)}}var Ht=class{code;size;digest;bytes;constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}};var mx=c(f(),1);function $a(t,e){let{bytes:r,version:n}=t;switch(n){case 0:return Oh(r,Hi(t),e??Z.encoder);default:return Lh(r,Hi(t),e??xr.encoder)}}var Va=new WeakMap;function Hi(t){let e=Va.get(t);if(e==null){let r=new Map;return Va.set(t,r),r}return e}var Gi=class t{code;version;multihash;bytes;"/";constructor(e,r,n,i){this.code=r,this.version=e,this.multihash=n,this.bytes=i,this["/"]=i}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:r}=this;if(e!==Sr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Ch)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:r}=this.multihash,n=Vi(e,r);return t.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return t.equals(this,e)}static equals(e,r){let n=r;return n!=null&&e.code===n.code&&e.version===n.version&&ja(e.multihash,n.multihash)}toString(e){return $a(this,e)}toJSON(){return{"/":$a(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:i,multihash:o,bytes:s}=r;return new t(n,i,o,s??Wa(n,i,o.bytes))}else if(r[Dh]===!0){let{version:n,multihash:i,code:o}=r,s=qa(i);return t.create(n,o,s)}else return null}static create(e,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(r!==Sr)throw new Error(`Version 0 CID must use dag-pb (code: ${Sr}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let i=Wa(e,r,n.bytes);return new t(e,r,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,Sr,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,i=Vt(e.subarray(n,n+r.multihashSize));if(i.byteLength!==r.multihashSize)throw new Error("Incorrect length");let o=i.subarray(r.multihashSize-r.digestSize),s=new Ht(r.multihashCode,r.digestSize,o,i);return[r.version===0?t.createV0(s):t.createV1(r.codec,s),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[h,g]=Wt(e.subarray(r));return r+=g,h},i=n(),o=Sr;if(i===18?(i=0,r=0):o=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let s=r,a=n(),l=n(),u=r+l,d=u-s;return{version:i,codec:o,multihashCode:a,digestSize:l,multihashSize:d,size:u}}static parse(e,r){let[n,i]=Rh(e,r),o=t.decode(i);if(o.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Hi(o).set(n,e),o}};function Rh(t,e){switch(t[0]){case"Q":{let r=e??Z;return[Z.prefix,r.decode(`${Z.prefix}${t}`)]}case Z.prefix:{let r=e??Z;return[Z.prefix,r.decode(t)]}case xr.prefix:{let r=e??xr;return[xr.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}}function Oh(t,e,r){let{prefix:n}=r;if(n!==Z.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let i=e.get(n);if(i==null){let o=r.encode(t).slice(1);return e.set(n,o),o}else return i}function Lh(t,e,r){let{prefix:n}=r,i=e.get(n);if(i==null){let o=r.encode(t);return e.set(n,o),o}else return i}var Sr=112,Ch=18;function Wa(t,e,r){let n=ht(t),i=n+ht(e),o=new Uint8Array(i+r.byteLength);return dt(t,o,0),dt(e,o,n),o.set(r,i),o}var Dh=Symbol.for("@ipld/js-cid/CID");var Tx=c(f(),1);var Ox=c(f(),1);var Bx=c(f(),1);var Ix=c(f(),1);var kx=c(f(),1);var Rx=c(f(),1);var ee=class t{static addPrefix(e){var r;let{code:n,data:i,name:o}=e;if(!(o?!n:n))throw new Error("Either 'name' or 'code' must be defined, but not both.");if(n=t.codeToName.has(n)?n:t.nameToCode.get(o),n===void 0)throw new Error(`Unsupported multicodec: ${(r=e.name)!==null&&r!==void 0?r:e.code}`);let s=Le.encodingLength(n),a=new Uint8Array(s+i.byteLength);return a.set(i,s),Le.encodeTo(n,a),a}static getCodeFromData(e){let{prefixedData:r}=e,[n,i]=Le.decode(r);return n}static getCodeFromName(e){let{name:r}=e,n=t.nameToCode.get(r);if(n===void 0)throw new Error(`Unsupported multicodec: ${r}`);return n}static getNameFromCode(e){let{code:r}=e,n=t.codeToName.get(r);if(n===void 0)throw new Error(`Unsupported multicodec: ${r}`);return n}static registerCodec(e){t.codeToName.set(e.code,e.name),t.nameToCode.set(e.name,e.code)}static removePrefix(e){let{prefixedData:r}=e,[n,i]=Le.decode(r),o=t.codeToName.get(n);if(o===void 0)throw new Error(`Unsupported multicodec: ${n}`);return{code:n,data:r.slice(i),name:o}}};ee.codeToName=new Map;ee.nameToCode=new Map;ee.registerCodec({code:237,name:"ed25519-pub"});ee.registerCodec({code:4864,name:"ed25519-priv"});ee.registerCodec({code:236,name:"x25519-pub"});ee.registerCodec({code:4866,name:"x25519-priv"});ee.registerCodec({code:231,name:"secp256k1-pub"});ee.registerCodec({code:4865,name:"secp256k1-priv"});var Wx=c(f(),1);function Ji(t){Object.keys(t).forEach(e=>{t[e]===void 0?delete t[e]:typeof t[e]=="object"&&Ji(t[e])})}var e_=c(f(),1),qp=c(ic(),1);var n_=c(f(),1);var fv=c(f(),1),s0=c(ea(),1);var a0=c(ea(),1);var AA=c(f(),1);var MS=c(f(),1);var Wv=c(f(),1);var Kv=c(f(),1);var Uv=c(f(),1);var Lv=c(f(),1);var vv=c(f(),1);function u0(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function ta(t,...e){if(!u0(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function ra(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function id(t,e){ta(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var Iv=c(f(),1);var gi=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),ye=(t,e)=>t<<32-e|t>>>e;var Av=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function c0(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function na(t){return typeof t=="string"&&(t=c0(t)),ta(t),t}var wi=class{clone(){return this._cloneInto()}},Tv={}.toString;function od(t){let e=n=>t().update(na(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function f0(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),l=n?4:0,u=n?0:4;t.setUint32(e+l,s,n),t.setUint32(e+u,a,n)}var sd=(t,e,r)=>t&e^~t&r,ad=(t,e,r)=>t&e^t&r^e&r,bi=class extends wi{constructor(e,r,n,i){super(),this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=gi(this.buffer)}update(e){ra(this);let{view:r,buffer:n,blockLen:i}=this;e=na(e);let o=e.length;for(let s=0;s<o;){let a=Math.min(i-this.pos,o-s);if(a===i){let l=gi(e);for(;i<=o-s;s+=i)this.process(l,s);continue}n.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){ra(this),id(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:o}=this,{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let h=s;h<i;h++)r[h]=0;f0(n,i-8,BigInt(this.length*8),o),this.process(n,0);let a=gi(e),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=l/4,d=this.get();if(u>d.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<u;h++)a.setUint32(4*h,d[h],o)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:i,finished:o,destroyed:s,pos:a}=this;return e.length=i,e.pos=a,e.finished=o,e.destroyed=s,i%r&&e.buffer.set(n),e}};var l0=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]),at=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ut=new Uint32Array(64),ia=class extends bi{constructor(){super(64,32,8,!1),this.A=at[0]|0,this.B=at[1]|0,this.C=at[2]|0,this.D=at[3]|0,this.E=at[4]|0,this.F=at[5]|0,this.G=at[6]|0,this.H=at[7]|0}get(){let{A:e,B:r,C:n,D:i,E:o,F:s,G:a,H:l}=this;return[e,r,n,i,o,s,a,l]}set(e,r,n,i,o,s,a,l){this.A=e|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=a|0,this.H=l|0}process(e,r){for(let h=0;h<16;h++,r+=4)ut[h]=e.getUint32(r,!1);for(let h=16;h<64;h++){let g=ut[h-15],y=ut[h-2],b=ye(g,7)^ye(g,18)^g>>>3,w=ye(y,17)^ye(y,19)^y>>>10;ut[h]=w+ut[h-7]+b+ut[h-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:l,G:u,H:d}=this;for(let h=0;h<64;h++){let g=ye(a,6)^ye(a,11)^ye(a,25),y=d+g+sd(a,l,u)+l0[h]+ut[h]|0,w=(ye(n,2)^ye(n,13)^ye(n,22))+ad(n,i,o)|0;d=u,u=l,l=a,a=s+y|0,s=o,o=i,i=n,n=y+w|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,l=l+this.F|0,u=u+this.G|0,d=d+this.H|0,this.set(n,i,o,s,a,l,u,d)}roundClean(){ut.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var ud=od(()=>new ia);var d0=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(d){try{u(n.next(d))}catch(h){s(h)}}function l(d){try{u(n.throw(d))}catch(h){s(h)}}function u(d){d.done?o(d.value):i(d.value).then(a,l)}u((n=n.apply(t,e||[])).next())})},nn=class{static digest(e){return d0(this,arguments,void 0,function*({data:r}){return ud(r)})}};var qv=c(f(),1);var pS=c(f(),1);var rS=c(f(),1);var Zv=c(f(),1);var Gv=c(f(),1);function cd(t){let e=n=>{if(n!==null&&typeof n=="object"&&!Array.isArray(n)){let i=Object.keys(n).sort(),o={};for(let s of i)o[s]=e(n[s]);return o}return n},r=e(t);return JSON.stringify(r)}var h0=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(d){try{u(n.next(d))}catch(h){s(h)}}function l(d){try{u(n.throw(d))}catch(h){s(h)}}function u(d){d.done?o(d.value):i(d.value).then(a,l)}u((n=n.apply(t,e||[])).next())})};function ce(t){return h0(this,arguments,void 0,function*({jwk:e}){let r=e.kty,n;if(r==="EC")n={crv:e.crv,kty:e.kty,x:e.x,y:e.y};else if(r==="oct")n={k:e.k,kty:e.kty};else if(r==="OKP")n={crv:e.crv,kty:e.kty,x:e.x};else if(r==="RSA")n={e:e.e,kty:e.kty,n:e.n};else throw new Error(`Unsupported key type: ${r}`);Ji(n);let i=cd(n),o=P.string(i).toUint8Array(),s=yield nn.digest({data:o});return P.uint8Array(s).toBase64Url()})}var sS=c(f(),1);var SS=c(f(),1);var bS=c(f(),1);var KS=c(f(),1);var JS=c(f(),1);var $S=c(f(),1);var nA=c(f(),1);var ZS=c(f(),1);var iA=c(f(),1);var oA=c(f(),1);var sA=c(f(),1);var cA=c(f(),1);var lA=c(f(),1);var yA=c(f(),1);var mA=c(f(),1);var vA=c(f(),1);var XA=c(f(),1),xi=class t extends Error{constructor(r,n){super(`${r}: ${n}`);this.code=r;this.name="DidError",Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,t)}};var QA=c(f(),1),Ei=(o=>(o.authentication="authentication",o.assertionMethod="assertionMethod",o.keyAgreement="keyAgreement",o.capabilityInvocation="capabilityInvocation",o.capabilityDelegation="capabilityDelegation",o))(Ei||{});function sa(t){if(typeof t=="string"&&t.length!==0)return t.split("#").pop()}function uT({didDocument:t,id:e,type:r}){return t?.service?.filter(n=>!(e&&n.id!==e||r&&n.type!==r))??[]}async function cT({didDocument:t,publicKeyJwk:e,publicKeyMultibase:r}){let n=pd({didDocument:t});for(let i of n)if(e&&i.publicKeyJwk){if(await ce({jwk:e})===await ce({jwk:i.publicKeyJwk}))return i}else if(r&&i.publicKeyMultibase&&r===i.publicKeyMultibase)return i;return null}function pd({didDocument:t}){if(!t)throw new TypeError("Required parameter missing: 'didDocument'");let e=[];return e.push(...t.verificationMethod?.filter(aa)??[]),Object.keys(Ei).forEach(r=>{e.push(...t[r]?.filter(aa)??[])}),e}function fT({didDocument:t}){let r=pd({didDocument:t}).map(n=>n.type);return[...new Set(r)]}function lT({didDocument:t,methodId:e}){let r=[];return Object.keys(Ei).forEach(n=>{if(Array.isArray(t[n])){let i=t[n],o=sa(e);i.some(a=>{let l=sa(a)===o,u=aa(a)&&sa(a.id)===o;return l||u})&&r.push(n)}}),r}function p0(t){return!t||typeof t!="object"||t===null?!1:"id"in t&&"type"in t&&"serviceEndpoint"in t}function dT(t){if(!p0(t)||t.type!=="DecentralizedWebNode"||!("enc"in t&&"sig"in t))return!1;let e=r=>typeof r=="string"||Array.isArray(r)&&r.every(n=>typeof n=="string");return e(t.enc)&&e(t.sig)}function aa(t){return!(!t||typeof t!="object"||t===null||!("id"in t&&"type"in t&&"controller"in t)||typeof t.id!="string"||typeof t.type!="string"||typeof t.controller!="string")}function hT({keyBytes:t,multicodecCode:e,multicodecName:r}){let n=ee.addPrefix({code:e,data:t,name:r}),i=P.uint8Array(n).toBase58Btc();return P.base58Btc(i).toMultibase()}function pT({multibaseKeyId:t}){try{let e=P.multibase(t).toBase58Btc(),r=P.base58Btc(e).toUint8Array(),{code:n,data:i,name:o}=ee.removePrefix({prefixedData:r});return{keyBytes:i,multicodecCode:n,multicodecName:o}}catch{throw new xi("invalidDid",`Invalid multibase identifier: ${t}`)}}export{sa as extractDidFragment,uT as getServices,cT as getVerificationMethodByKey,fT as getVerificationMethodTypes,pd as getVerificationMethods,lT as getVerificationRelationshipsById,p0 as isDidService,aa as isDidVerificationMethod,dT as isDwnDidService,hT as keyBytesToMultibaseId,pT as multibaseIdToKeyBytes};
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};
3
2
  /*! Bundled license information:
4
3
 
5
4
  ieee754/index.js:
@@ -19,9 +18,6 @@ queue-microtask/index.js:
19
18
  run-parallel-limit/index.js:
20
19
  (*! run-parallel-limit. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
21
20
 
22
- safe-buffer/index.js:
23
- (*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
24
-
25
21
  @noble/hashes/esm/utils.js:
26
22
  (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
27
23
  */