@web5/common
Version:
1 lines • 191 kB
JavaScript
var $c=Object.create;var fi=Object.defineProperty;var jc=Object.getOwnPropertyDescriptor;var Vc=Object.getOwnPropertyNames;var Kc=Object.getPrototypeOf,Gc=Object.prototype.hasOwnProperty;var w=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Hc=(t,e)=>{for(var r in e)fi(t,r,{get:e[r],enumerable:!0})},zc=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Vc(e))!Gc.call(t,i)&&i!==r&&fi(t,i,{get:()=>e[i],enumerable:!(n=jc(e,i))||n.enumerable});return t};var Jr=(t,e,r)=>(r=t!=null?$c(Kc(t)):{},zc(e||!t||!t.__esModule?fi(r,"default",{value:t,enumerable:!0}):r,t));var js=w((Dm,$s)=>{var Yc=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Xr=()=>Yc.now(),Jc=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),ci=t=>t===1/0||Jc(t),di=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&&!ci(r))throw new TypeError("ttl must be positive integer or Infinity if set");if(!ci(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-Xr());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(Xr()+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(!ci(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-Xr())):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(Xr());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()}};$s.exports=di});var oa=w(ia=>{"use strict";ia.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 ae=w((ME,sa)=>{"use strict";sa.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 la=w(Qr=>{"use strict";Qr.byteLength=kd;Qr.toByteArray=Dd;Qr.fromByteArray=Fd;var he=[],ee=[],Nd=typeof Uint8Array<"u"?Uint8Array:Array,Ri="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(at=0,aa=Ri.length;at<aa;++at)he[at]=Ri[at],ee[Ri.charCodeAt(at)]=at;var at,aa;ee[45]=62;ee[95]=63;function ua(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 kd(t){var e=ua(t),r=e[0],n=e[1];return(r+n)*3/4-n}function Md(t,e,r){return(e+r)*3/4-r}function Dd(t){var e,r=ua(t),n=r[0],i=r[1],o=new Nd(Md(t,n,i)),s=0,a=i>0?n-4:n,l;for(l=0;l<a;l+=4)e=ee[t.charCodeAt(l)]<<18|ee[t.charCodeAt(l+1)]<<12|ee[t.charCodeAt(l+2)]<<6|ee[t.charCodeAt(l+3)],o[s++]=e>>16&255,o[s++]=e>>8&255,o[s++]=e&255;return i===2&&(e=ee[t.charCodeAt(l)]<<2|ee[t.charCodeAt(l+1)]>>4,o[s++]=e&255),i===1&&(e=ee[t.charCodeAt(l)]<<10|ee[t.charCodeAt(l+1)]<<4|ee[t.charCodeAt(l+2)]>>2,o[s++]=e>>8&255,o[s++]=e&255),o}function Ud(t){return he[t>>18&63]+he[t>>12&63]+he[t>>6&63]+he[t&63]}function Pd(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(Ud(n));return i.join("")}function Fd(t){for(var e,r=t.length,n=r%3,i=[],o=16383,s=0,a=r-n;s<a;s+=o)i.push(Pd(t,s,s+o>a?a:s+o));return n===1?(e=t[r-1],i.push(he[e>>2]+he[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(he[e>>10]+he[e>>4&63]+he[e<<2&63]+"=")),i.join("")}});var fa=w(vi=>{vi.read=function(t,e,r,n,i){var o,s,a=i*8-n-1,l=(1<<a)-1,u=l>>1,f=-7,c=r?i-1:0,y=r?-1:1,h=t[e+c];for(c+=y,o=h&(1<<-f)-1,h>>=-f,f+=a;f>0;o=o*256+t[e+c],c+=y,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=s*256+t[e+c],c+=y,f-=8);if(o===0)o=1-u;else{if(o===l)return s?NaN:(h?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-u}return(h?-1:1)*s*Math.pow(2,o-n)};vi.write=function(t,e,r,n,i,o){var s,a,l,u=o*8-i-1,f=(1<<u)-1,c=f>>1,y=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,h=n?0:o-1,b=n?1:-1,p=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=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-s))<1&&(s--,l*=2),s+c>=1?e+=y/l:e+=y*Math.pow(2,1-c),e*l>=2&&(s++,l/=2),s+c>=f?(a=0,s=f):s+c>=1?(a=(e*l-1)*Math.pow(2,i),s=s+c):(a=e*Math.pow(2,c-1)*Math.pow(2,i),s=0));i>=8;t[r+h]=a&255,h+=b,a/=256,i-=8);for(s=s<<i|a,u+=i;u>0;t[r+h]=s&255,h+=b,s/=256,u-=8);t[r+h-b]|=p*128}});var te=w(Wt=>{"use strict";var Ii=la(),Ft=fa(),ca=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Wt.Buffer=d;Wt.SlowBuffer=Kd;Wt.INSPECT_MAX_BYTES=50;var en=2147483647;Wt.kMaxLength=en;d.TYPED_ARRAY_SUPPORT=qd();!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 qd(){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(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 Ie(t){if(t>en)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,d.prototype),e}function d(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 Ci(t)}return ya(t,e,r)}d.poolSize=8192;function ya(t,e,r){if(typeof t=="string")return $d(t,e);if(ArrayBuffer.isView(t))return jd(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(pe(t,ArrayBuffer)||t&&pe(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(pe(t,SharedArrayBuffer)||t&&pe(t.buffer,SharedArrayBuffer)))return Bi(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 d.from(n,e,r);let i=Vd(t);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return d.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)}d.from=function(t,e,r){return ya(t,e,r)};Object.setPrototypeOf(d.prototype,Uint8Array.prototype);Object.setPrototypeOf(d,Uint8Array);function ba(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 Wd(t,e,r){return ba(t),t<=0?Ie(t):e!==void 0?typeof r=="string"?Ie(t).fill(e,r):Ie(t).fill(e):Ie(t)}d.alloc=function(t,e,r){return Wd(t,e,r)};function Ci(t){return ba(t),Ie(t<0?0:Ni(t)|0)}d.allocUnsafe=function(t){return Ci(t)};d.allocUnsafeSlow=function(t){return Ci(t)};function $d(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!d.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=wa(t,e)|0,n=Ie(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function Li(t){let e=t.length<0?0:Ni(t.length)|0,r=Ie(e);for(let n=0;n<e;n+=1)r[n]=t[n]&255;return r}function jd(t){if(pe(t,Uint8Array)){let e=new Uint8Array(t);return Bi(e.buffer,e.byteOffset,e.byteLength)}return Li(t)}function Bi(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,d.prototype),n}function Vd(t){if(d.isBuffer(t)){let e=Ni(t.length)|0,r=Ie(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||Mi(t.length)?Ie(0):Li(t);if(t.type==="Buffer"&&Array.isArray(t.data))return Li(t.data)}function Ni(t){if(t>=en)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+en.toString(16)+" bytes");return t|0}function Kd(t){return+t!=t&&(t=0),d.alloc(+t)}d.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==d.prototype};d.compare=function(e,r){if(pe(e,Uint8Array)&&(e=d.from(e,e.offset,e.byteLength)),pe(r,Uint8Array)&&(r=d.from(r,r.offset,r.byteLength)),!d.isBuffer(e)||!d.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};d.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}};d.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return d.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;let i=d.allocUnsafe(r),o=0;for(n=0;n<e.length;++n){let s=e[n];if(pe(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 wa(t,e){if(d.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||pe(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 Oi(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Ra(t).length;default:if(i)return n?-1:Oi(t).length;e=(""+e).toLowerCase(),i=!0}}d.byteLength=wa;function Gd(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 rh(this,e,r);case"utf8":case"utf-8":return ma(this,e,r);case"ascii":return eh(this,e,r);case"latin1":case"binary":return th(this,e,r);case"base64":return Zd(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return nh(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}d.prototype._isBuffer=!0;function ut(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}d.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)ut(this,r,r+1);return this};d.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)ut(this,r,r+3),ut(this,r+1,r+2);return this};d.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)ut(this,r,r+7),ut(this,r+1,r+6),ut(this,r+2,r+5),ut(this,r+3,r+4);return this};d.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?ma(this,0,e):Gd.apply(this,arguments)};d.prototype.toLocaleString=d.prototype.toString;d.prototype.equals=function(e){if(!d.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:d.compare(this,e)===0};d.prototype.inspect=function(){let e="",r=Wt.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};ca&&(d.prototype[ca]=d.prototype.inspect);d.prototype.compare=function(e,r,n,i,o){if(pe(e,Uint8Array)&&(e=d.from(e,e.offset,e.byteLength)),!d.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),f=e.slice(r,n);for(let c=0;c<l;++c)if(u[c]!==f[c]){s=u[c],a=f[c];break}return s<a?-1:a<s?1:0};function ga(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,Mi(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=d.from(e,n)),d.isBuffer(e))return e.length===0?-1:da(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):da(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function da(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(f,c){return o===1?f[c]:f.readUInt16BE(c*o)}let u;if(i){let f=-1;for(u=r;u<s;u++)if(l(t,u)===l(e,f===-1?0:u-f)){if(f===-1&&(f=u),u-f+1===a)return f*o}else f!==-1&&(u-=u-f),f=-1}else for(r+a>s&&(r=s-a),u=r;u>=0;u--){let f=!0;for(let c=0;c<a;c++)if(l(t,u+c)!==l(e,c)){f=!1;break}if(f)return u}return-1}d.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};d.prototype.indexOf=function(e,r,n){return ga(this,e,r,n,!0)};d.prototype.lastIndexOf=function(e,r,n){return ga(this,e,r,n,!1)};function Hd(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(Mi(a))return s;t[r+s]=a}return s}function zd(t,e,r,n){return tn(Oi(e,t.length-r),t,r,n)}function Yd(t,e,r,n){return tn(ah(e),t,r,n)}function Jd(t,e,r,n){return tn(Ra(e),t,r,n)}function Xd(t,e,r,n){return tn(uh(e,t.length-r),t,r,n)}d.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 Hd(this,e,r,n);case"utf8":case"utf-8":return zd(this,e,r,n);case"ascii":case"latin1":case"binary":return Yd(this,e,r,n);case"base64":return Jd(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Xd(this,e,r,n);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 Zd(t,e,r){return e===0&&r===t.length?Ii.fromByteArray(t):Ii.fromByteArray(t.slice(e,r))}function ma(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,f,c;switch(a){case 1:o<128&&(s=o);break;case 2:l=t[i+1],(l&192)===128&&(c=(o&31)<<6|l&63,c>127&&(s=c));break;case 3:l=t[i+1],u=t[i+2],(l&192)===128&&(u&192)===128&&(c=(o&15)<<12|(l&63)<<6|u&63,c>2047&&(c<55296||c>57343)&&(s=c));break;case 4:l=t[i+1],u=t[i+2],f=t[i+3],(l&192)===128&&(u&192)===128&&(f&192)===128&&(c=(o&15)<<18|(l&63)<<12|(u&63)<<6|f&63,c>65535&&c<1114112&&(s=c))}}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 Qd(n)}var ha=4096;function Qd(t){let e=t.length;if(e<=ha)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=ha));return r}function eh(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 th(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 rh(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+=lh[t[o]];return i}function nh(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}d.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,d.prototype),i};function P(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")}d.prototype.readUintLE=d.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||P(e,r,this.length);let i=this[e],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[e+s]*o;return i};d.prototype.readUintBE=d.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||P(e,r,this.length);let i=this[e+--r],o=1;for(;r>0&&(o*=256);)i+=this[e+--r]*o;return i};d.prototype.readUint8=d.prototype.readUInt8=function(e,r){return e=e>>>0,r||P(e,1,this.length),this[e]};d.prototype.readUint16LE=d.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||P(e,2,this.length),this[e]|this[e+1]<<8};d.prototype.readUint16BE=d.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||P(e,2,this.length),this[e]<<8|this[e+1]};d.prototype.readUint32LE=d.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||P(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};d.prototype.readUint32BE=d.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||P(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};d.prototype.readBigUInt64LE=Ve(function(e){e=e>>>0,qt(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&wr(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))});d.prototype.readBigUInt64BE=Ve(function(e){e=e>>>0,qt(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&wr(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)});d.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||P(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};d.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||P(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};d.prototype.readInt8=function(e,r){return e=e>>>0,r||P(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};d.prototype.readInt16LE=function(e,r){e=e>>>0,r||P(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};d.prototype.readInt16BE=function(e,r){e=e>>>0,r||P(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};d.prototype.readInt32LE=function(e,r){return e=e>>>0,r||P(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};d.prototype.readInt32BE=function(e,r){return e=e>>>0,r||P(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};d.prototype.readBigInt64LE=Ve(function(e){e=e>>>0,qt(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&wr(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)});d.prototype.readBigInt64BE=Ve(function(e){e=e>>>0,qt(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&wr(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)});d.prototype.readFloatLE=function(e,r){return e=e>>>0,r||P(e,4,this.length),Ft.read(this,e,!0,23,4)};d.prototype.readFloatBE=function(e,r){return e=e>>>0,r||P(e,4,this.length),Ft.read(this,e,!1,23,4)};d.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||P(e,8,this.length),Ft.read(this,e,!0,52,8)};d.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||P(e,8,this.length),Ft.read(this,e,!1,52,8)};function Y(t,e,r,n,i,o){if(!d.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")}d.prototype.writeUintLE=d.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};d.prototype.writeUintBE=d.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};d.prototype.writeUint8=d.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};d.prototype.writeUint16LE=d.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};d.prototype.writeUint16BE=d.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};d.prototype.writeUint32LE=d.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};d.prototype.writeUint32BE=d.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}d.prototype.writeBigUInt64LE=Ve(function(e,r=0){return Ea(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});d.prototype.writeBigUInt64BE=Ve(function(e,r=0){return _a(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});d.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};d.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};d.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};d.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};d.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};d.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};d.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};d.prototype.writeBigInt64LE=Ve(function(e,r=0){return Ea(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});d.prototype.writeBigInt64BE=Ve(function(e,r=0){return _a(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function xa(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||xa(t,e,r,4,34028234663852886e22,-34028234663852886e22),Ft.write(t,e,r,n,23,4),r+4}d.prototype.writeFloatLE=function(e,r,n){return Sa(this,e,r,!0,n)};d.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||xa(t,e,r,8,17976931348623157e292,-17976931348623157e292),Ft.write(t,e,r,n,52,8),r+8}d.prototype.writeDoubleLE=function(e,r,n){return Aa(this,e,r,!0,n)};d.prototype.writeDoubleBE=function(e,r,n){return Aa(this,e,r,!1,n)};d.prototype.copy=function(e,r,n,i){if(!d.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};d.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"&&!d.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=d.isBuffer(e)?e:d.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 Pt={};function ki(t,e,r){Pt[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}`}}}ki("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);ki("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);ki("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=pa(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=pa(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function pa(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 ih(t,e,r){qt(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&wr(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 Pt.ERR_OUT_OF_RANGE("value",a,t)}ih(n,i,o)}function qt(t,e){if(typeof t!="number")throw new Pt.ERR_INVALID_ARG_TYPE(e,"number",t)}function wr(t,e,r){throw Math.floor(t)!==t?(qt(t,r),new Pt.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new Pt.ERR_BUFFER_OUT_OF_BOUNDS:new Pt.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var oh=/[^+/0-9A-Za-z-_]/g;function sh(t){if(t=t.split("=")[0],t=t.trim().replace(oh,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function Oi(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 ah(t){let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function uh(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 Ra(t){return Ii.toByteArray(sh(t))}function tn(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 pe(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function Mi(t){return t!==t}var lh=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 Ve(t){return typeof BigInt>"u"?fh:t}function fh(){throw new Error("BigInt not supported")}});var Ui=w((qE,va)=>{"use strict";var Di=null;va.exports=function(){return Di===null&&(Di={textEncoder:new TextEncoder,textDecoder:new TextDecoder}),Di}});var qi=w(Ia=>{"use strict";var Pi=ae(),ch=new Set(["buffer","view","utf8"]),Fi=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"||!ch.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 Pi(`Encoding '${this.name}' cannot be transcoded to 'buffer'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createViewTranscoder(){throw new Pi(`Encoding '${this.name}' cannot be transcoded to 'view'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createUTF8Transcoder(){throw new Pi(`Encoding '${this.name}' cannot be transcoded to 'utf8'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}};Ia.Encoding=Fi});var Vi=w(rn=>{"use strict";var{Buffer:$i}=te()||{},{Encoding:ji}=qi(),dh=Ui(),gr=class extends ji{constructor(e){super({...e,format:"buffer"})}createViewTranscoder(){return new mr({encode:this.encode,decode:e=>this.decode($i.from(e.buffer,e.byteOffset,e.byteLength)),name:`${this.name}+view`})}createBufferTranscoder(){return this}},mr=class extends ji{constructor(e){super({...e,format:"view"})}createBufferTranscoder(){return new gr({encode:e=>{let r=this.encode(e);return $i.from(r.buffer,r.byteOffset,r.byteLength)},decode:this.decode,name:`${this.name}+buffer`})}createViewTranscoder(){return this}},Wi=class extends ji{constructor(e){super({...e,format:"utf8"})}createBufferTranscoder(){return new gr({encode:e=>$i.from(this.encode(e),"utf8"),decode:e=>this.decode(e.toString("utf8")),name:`${this.name}+buffer`})}createViewTranscoder(){let{textEncoder:e,textDecoder:r}=dh();return new mr({encode:n=>e.encode(this.encode(n)),decode:n=>this.decode(r.decode(n)),name:`${this.name}+view`})}createUTF8Transcoder(){return this}};rn.BufferFormat=gr;rn.ViewFormat=mr;rn.UTF8Format=Wi});var Ca=w(lt=>{"use strict";var{Buffer:$}=te()||{Buffer:{isBuffer:()=>!1}},{textEncoder:Ba,textDecoder:La}=Ui()(),{BufferFormat:Er,ViewFormat:Ki,UTF8Format:Oa}=Vi(),nn=t=>t;lt.utf8=new Oa({encode:function(t){return $.isBuffer(t)?t.toString("utf8"):ArrayBuffer.isView(t)?La.decode(t):String(t)},decode:nn,name:"utf8",createViewTranscoder(){return new Ki({encode:function(t){return ArrayBuffer.isView(t)?t:Ba.encode(t)},decode:function(t){return La.decode(t)},name:`${this.name}+view`})},createBufferTranscoder(){return new Er({encode:function(t){return $.isBuffer(t)?t:ArrayBuffer.isView(t)?$.from(t.buffer,t.byteOffset,t.byteLength):$.from(String(t),"utf8")},decode:function(t){return t.toString("utf8")},name:`${this.name}+buffer`})}});lt.json=new Oa({encode:JSON.stringify,decode:JSON.parse,name:"json"});lt.buffer=new Er({encode:function(t){return $.isBuffer(t)?t:ArrayBuffer.isView(t)?$.from(t.buffer,t.byteOffset,t.byteLength):$.from(String(t),"utf8")},decode:nn,name:"buffer",createViewTranscoder(){return new Ki({encode:function(t){return ArrayBuffer.isView(t)?t:$.from(String(t),"utf8")},decode:function(t){return $.from(t.buffer,t.byteOffset,t.byteLength)},name:`${this.name}+view`})}});lt.view=new Ki({encode:function(t){return ArrayBuffer.isView(t)?t:Ba.encode(t)},decode:nn,name:"view",createBufferTranscoder(){return new Er({encode:function(t){return $.isBuffer(t)?t:ArrayBuffer.isView(t)?$.from(t.buffer,t.byteOffset,t.byteLength):$.from(String(t),"utf8")},decode:nn,name:`${this.name}+buffer`})}});lt.hex=new Er({encode:function(t){return $.isBuffer(t)?t:$.from(String(t),"hex")},decode:function(t){return t.toString("hex")},name:"hex"});lt.base64=new Er({encode:function(t){return $.isBuffer(t)?t:$.from(String(t),"base64")},decode:function(t){return t.toString("base64")},name:"base64"})});var Ma=w(ka=>{"use strict";var Na=ae(),sn=Ca(),{Encoding:hh}=qi(),{BufferFormat:ph,ViewFormat:yh,UTF8Format:bh}=Vi(),_r=Symbol("formats"),on=Symbol("encodings"),wh=new Set(["buffer","view","utf8"]),Gi=class{constructor(e){if(Array.isArray(e)){if(!e.every(r=>wh.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[on]=new Map,this[_r]=new Set(e);for(let r in sn)try{this.encoding(r)}catch(n){if(n.code!=="LEVEL_ENCODING_NOT_SUPPORTED")throw n}}encodings(){return Array.from(new Set(this[on].values()))}encoding(e){let r=this[on].get(e);if(r===void 0){if(typeof e=="string"&&e!==""){if(r=_h[e],!r)throw new Na(`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=gh(e)}let{name:n,format:i}=r;if(!this[_r].has(i))if(this[_r].has("view"))r=r.createViewTranscoder();else if(this[_r].has("buffer"))r=r.createBufferTranscoder();else if(this[_r].has("utf8"))r=r.createUTF8Transcoder();else throw new Na(`Encoding '${n}' cannot be transcoded`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"});for(let o of[e,n,r.name,r.commonName])this[on].set(o,r)}return r}};ka.Transcoder=Gi;function gh(t){if(t instanceof hh)return t;let e="type"in t&&typeof t.type=="string"?t.type:void 0,r=t.name||e||`anonymous-${xh++}`;switch(mh(t)){case"view":return new yh({...t,name:r});case"utf8":return new bh({...t,name:r});case"buffer":return new ph({...t,name:r});default:throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'")}}function mh(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 Eh={binary:sn.buffer,"utf-8":sn.utf8},_h={...sn,...Eh},xh=0});var jt=w((KE,Hi)=>{"use strict";var $t=typeof Reflect=="object"?Reflect:null,Da=$t&&typeof $t.apply=="function"?$t.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},an;$t&&typeof $t.ownKeys=="function"?an=$t.ownKeys:Object.getOwnPropertySymbols?an=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:an=function(e){return Object.getOwnPropertyNames(e)};function Sh(t){console&&console.warn&&console.warn(t)}var Pa=Number.isNaN||function(e){return e!==e};function I(){I.init.call(this)}Hi.exports=I;Hi.exports.once=vh;I.EventEmitter=I;I.prototype._events=void 0;I.prototype._eventsCount=0;I.prototype._maxListeners=void 0;var Ua=10;function un(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(I,"defaultMaxListeners",{enumerable:!0,get:function(){return Ua},set:function(t){if(typeof t!="number"||t<0||Pa(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Ua=t}});I.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};I.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Pa(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 Fa(t){return t._maxListeners===void 0?I.defaultMaxListeners:t._maxListeners}I.prototype.getMaxListeners=function(){return Fa(this)};I.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")Da(l,this,r);else for(var u=l.length,f=Va(l,u),n=0;n<u;++n)Da(f[n],this,r);return!0};function qa(t,e,r,n){var i,o,s;if(un(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=Fa(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,Sh(a)}return t}I.prototype.addListener=function(e,r){return qa(this,e,r,!1)};I.prototype.on=I.prototype.addListener;I.prototype.prependListener=function(e,r){return qa(this,e,r,!0)};function Ah(){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 Wa(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=Ah.bind(n);return i.listener=r,n.wrapFn=i,i}I.prototype.once=function(e,r){return un(r),this.on(e,Wa(this,e,r)),this};I.prototype.prependOnceListener=function(e,r){return un(r),this.prependListener(e,Wa(this,e,r)),this};I.prototype.removeListener=function(e,r){var n,i,o,s,a;if(un(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():Th(n,o),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this};I.prototype.off=I.prototype.removeListener;I.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 $a(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?Rh(i):Va(i,i.length)}I.prototype.listeners=function(e){return $a(this,e,!0)};I.prototype.rawListeners=function(e){return $a(this,e,!1)};I.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):ja.call(t,e)};I.prototype.listenerCount=ja;function ja(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}I.prototype.eventNames=function(){return this._eventsCount>0?an(this._events):[]};function Va(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function Th(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function Rh(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function vh(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))}Ka(t,e,o,{once:!0}),e!=="error"&&Ih(t,i,{once:!0})})}function Ih(t,e,r){typeof t.on=="function"&&Ka(t,"error",e,r)}function Ka(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 Ha=w((GE,Ga)=>{Ga.exports=typeof queueMicrotask=="function"?queueMicrotask:t=>Promise.resolve().then(t)});var xr=w(zi=>{"use strict";var za=Ha();zi.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};zi.fromPromise=function(t,e){if(e===void 0)return t;t.then(function(r){za(()=>e(null,r))}).catch(function(r){za(()=>e(r))})}});var ln=w(Yi=>{"use strict";Yi.getCallback=function(t,e){return typeof t=="function"?t:e};Yi.getOptions=function(t,e){return typeof t=="object"&&t!==null?t:e!==void 0?e:{}}});var Je=w(hn=>{"use strict";var{fromCallback:Ji}=xr(),X=ae(),{getOptions:Xi,getCallback:Ya}=ln(),ft=Symbol("promise"),Vt=Symbol("callback"),ye=Symbol("working"),ct=Symbol("handleOne"),Le=Symbol("handleMany"),Zi=Symbol("autoClose"),ze=Symbol("finishWork"),be=Symbol("returnMany"),Ke=Symbol("closing"),Sr=Symbol("handleClose"),fn=Symbol("closed"),Ar=Symbol("closeCallbacks"),He=Symbol("keyEncoding"),dt=Symbol("valueEncoding"),Qi=Symbol("abortOnClose"),cn=Symbol("legacy"),eo=Symbol("keys"),to=Symbol("values"),Ge=Symbol("limit"),re=Symbol("count"),dn=Object.freeze({}),Lh=()=>{},Ja=!1,Tr=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[fn]=!1,this[Ar]=[],this[ye]=!1,this[Ke]=!1,this[Zi]=!1,this[Vt]=null,this[ct]=this[ct].bind(this),this[Le]=this[Le].bind(this),this[Sr]=this[Sr].bind(this),this[He]=r[He],this[dt]=r[dt],this[cn]=n,this[Ge]=Number.isInteger(r.limit)&&r.limit>=0?r.limit:1/0,this[re]=0,this[Qi]=!!r.abortOnClose,this.db=e,this.db.attachResource(this),this.nextTick=e.nextTick}get count(){return this[re]}get limit(){return this[Ge]}next(e){let r;if(e===void 0)r=new Promise((n,i)=>{e=(o,s,a)=>{o?i(o):this[cn]?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[Ke]?this.nextTick(e,new X("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[ye]?this.nextTick(e,new X("Iterator is busy: cannot call next() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[ye]=!0,this[Vt]=e,this[re]>=this[Ge]?this.nextTick(this[ct],null):this._next(this[ct])),r}_next(e){this.nextTick(e)}nextv(e,r,n){return n=Ya(r,n),n=Ji(n,ft),r=Xi(r,dn),Number.isInteger(e)?(this[Ke]?this.nextTick(n,new X("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[ye]?this.nextTick(n,new X("Iterator is busy: cannot call nextv() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(e<1&&(e=1),this[Ge]<1/0&&(e=Math.min(e,this[Ge]-this[re])),this[ye]=!0,this[Vt]=n,e<=0?this.nextTick(this[Le],null,[]):this._nextv(e,r,this[Le])),n[ft]):(this.nextTick(n,new TypeError("The first argument 'size' must be an integer")),n[ft])}_nextv(e,r,n){let i=[],o=(s,a,l)=>{if(s)return n(s);if(this[cn]?a===void 0&&l===void 0:a===void 0)return n(null,i);i.push(this[cn]?[a,l]:a),i.length===e?n(null,i):this._next(o)};this._next(o)}all(e,r){return r=Ya(e,r),r=Ji(r,ft),e=Xi(e,dn),this[Ke]?this.nextTick(r,new X("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[ye]?this.nextTick(r,new X("Iterator is busy: cannot call all() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[ye]=!0,this[Vt]=r,this[Zi]=!0,this[re]>=this[Ge]?this.nextTick(this[Le],null,[]):this._all(e,this[Le])),r[ft]}_all(e,r){let n=this[re],i=[],o=()=>{let a=this[Ge]<1/0?Math.min(1e3,this[Ge]-n):1e3;a<=0?this.nextTick(r,null,i):this._nextv(a,dn,s)},s=(a,l)=>{a?r(a):l.length===0?r(null,i):(i.push.apply(i,l),n+=l.length,o())};o()}[ze](){let e=this[Vt];return this[Qi]&&e===null?Lh:(this[ye]=!1,this[Vt]=nul