diff --git a/public/scripts/web5.js b/public/scripts/web5.js index adac21c..e9ecc50 100644 --- a/public/scripts/web5.js +++ b/public/scripts/web5.js @@ -1,22 +1,22 @@ -var Web5=(()=>{var K1e=Object.create;var $5=Object.defineProperty;var F1e=Object.getOwnPropertyDescriptor;var z1e=Object.getOwnPropertyNames;var W1e=Object.getPrototypeOf,H1e=Object.prototype.hasOwnProperty;var V1e=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var G1e=(t,e)=>()=>(t&&(e=t(t=0)),e);var V=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Pr=(t,e)=>{for(var r in e)$5(t,r,{get:e[r],enumerable:!0})},Lz=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of z1e(e))!H1e.call(t,i)&&i!==r&&$5(t,i,{get:()=>e[i],enumerable:!(n=F1e(e,i))||n.enumerable});return t};var gt=(t,e,r)=>(r=t!=null?K1e(W1e(t)):{},Lz(e||!t||!t.__esModule?$5(r,"default",{value:t,enumerable:!0}):r,t)),J1e=t=>Lz($5({},"__esModule",{value:!0}),t);var BD=V(j5=>{"use strict";f();j5.byteLength=Y1e;j5.toByteArray=Q1e;j5.fromByteArray=r2e;var vl=[],yd=[],Z1e=typeof Uint8Array<"u"?Uint8Array:Array,DD="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(w0=0,Kz=DD.length;w00)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 Y1e(t){var e=Fz(t),r=e[0],n=e[1];return(r+n)*3/4-n}function X1e(t,e,r){return(e+r)*3/4-r}function Q1e(t){var e,r=Fz(t),n=r[0],i=r[1],o=new Z1e(X1e(t,n,i)),s=0,a=i>0?n-4:n,d;for(d=0;d>16&255,o[s++]=e>>8&255,o[s++]=e&255;return i===2&&(e=yd[t.charCodeAt(d)]<<2|yd[t.charCodeAt(d+1)]>>4,o[s++]=e&255),i===1&&(e=yd[t.charCodeAt(d)]<<10|yd[t.charCodeAt(d+1)]<<4|yd[t.charCodeAt(d+2)]>>2,o[s++]=e>>8&255,o[s++]=e&255),o}function e2e(t){return vl[t>>18&63]+vl[t>>12&63]+vl[t>>6&63]+vl[t&63]}function t2e(t,e,r){for(var n,i=[],o=e;oa?a:s+o));return n===1?(e=t[r-1],i.push(vl[e>>2]+vl[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(vl[e>>10]+vl[e>>4&63]+vl[e<<2&63]+"=")),i.join("")}});var OD=V(MD=>{f();MD.read=function(t,e,r,n,i){var o,s,a=i*8-n-1,d=(1<>1,c=-7,l=r?i-1:0,p=r?-1:1,m=t[e+l];for(l+=p,o=m&(1<<-c)-1,m>>=-c,c+=a;c>0;o=o*256+t[e+l],l+=p,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=n;c>0;s=s*256+t[e+l],l+=p,c-=8);if(o===0)o=1-u;else{if(o===d)return s?NaN:(m?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-u}return(m?-1:1)*s*Math.pow(2,o-n)};MD.write=function(t,e,r,n,i,o){var s,a,d,u=o*8-i-1,c=(1<>1,p=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,m=n?0:o-1,g=n?1:-1,v=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=c):(s=Math.floor(Math.log(e)/Math.LN2),e*(d=Math.pow(2,-s))<1&&(s--,d*=2),s+l>=1?e+=p/d:e+=p*Math.pow(2,1-l),e*d>=2&&(s++,d/=2),s+l>=c?(a=0,s=c):s+l>=1?(a=(e*d-1)*Math.pow(2,i),s=s+l):(a=e*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;t[r+m]=a&255,m+=g,a/=256,i-=8);for(s=s<0;t[r+m]=s&255,m+=g,s/=256,u-=8);t[r+m-g]|=v*128}});var rW=V(Nb=>{"use strict";f();var CD=BD(),jb=OD(),zz=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Nb.Buffer=be;Nb.SlowBuffer=c2e;Nb.INSPECT_MAX_BYTES=50;var N5=2147483647;Nb.kMaxLength=N5;be.TYPED_ARRAY_SUPPORT=n2e();!be.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 n2e(){try{var 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(be.prototype,"parent",{enumerable:!0,get:function(){if(be.isBuffer(this))return this.buffer}});Object.defineProperty(be.prototype,"offset",{enumerable:!0,get:function(){if(be.isBuffer(this))return this.byteOffset}});function Hf(t){if(t>N5)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return Object.setPrototypeOf(e,be.prototype),e}function be(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 UD(t)}return Vz(t,e,r)}be.poolSize=8192;function Vz(t,e,r){if(typeof t=="string")return o2e(t,e);if(ArrayBuffer.isView(t))return s2e(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(bl(t,ArrayBuffer)||t&&bl(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(bl(t,SharedArrayBuffer)||t&&bl(t.buffer,SharedArrayBuffer)))return jD(t,e,r);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var n=t.valueOf&&t.valueOf();if(n!=null&&n!==t)return be.from(n,e,r);var i=a2e(t);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return be.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)}be.from=function(t,e,r){return Vz(t,e,r)};Object.setPrototypeOf(be.prototype,Uint8Array.prototype);Object.setPrototypeOf(be,Uint8Array);function Gz(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 i2e(t,e,r){return Gz(t),t<=0?Hf(t):e!==void 0?typeof r=="string"?Hf(t).fill(e,r):Hf(t).fill(e):Hf(t)}be.alloc=function(t,e,r){return i2e(t,e,r)};function UD(t){return Gz(t),Hf(t<0?0:qD(t)|0)}be.allocUnsafe=function(t){return UD(t)};be.allocUnsafeSlow=function(t){return UD(t)};function o2e(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!be.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=Jz(t,e)|0,n=Hf(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function $D(t){for(var e=t.length<0?0:qD(t.length)|0,r=Hf(e),n=0;n=N5)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+N5.toString(16)+" bytes");return t|0}function c2e(t){return+t!=t&&(t=0),be.alloc(+t)}be.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==be.prototype};be.compare=function(e,r){if(bl(e,Uint8Array)&&(e=be.from(e,e.offset,e.byteLength)),bl(r,Uint8Array)&&(r=be.from(r,r.offset,r.byteLength)),!be.isBuffer(e)||!be.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===r)return 0;for(var n=e.length,i=r.length,o=0,s=Math.min(n,i);oi.length?be.from(s).copy(i,o):Uint8Array.prototype.set.call(i,s,o);else if(be.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function Jz(t,e){if(be.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||bl(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);var r=t.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return ND(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return tW(t).length;default:if(i)return n?-1:ND(t).length;e=(""+e).toLowerCase(),i=!0}}be.byteLength=Jz;function d2e(t,e,r){var 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 b2e(this,e,r);case"utf8":case"utf-8":return Yz(this,e,r);case"ascii":return g2e(this,e,r);case"latin1":case"binary":return v2e(this,e,r);case"base64":return m2e(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return w2e(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}be.prototype._isBuffer=!0;function _0(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}be.prototype.swap16=function(){var e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var r=0;rr&&(e+=" ... "),""};zz&&(be.prototype[zz]=be.prototype.inspect);be.prototype.compare=function(e,r,n,i,o){if(bl(e,Uint8Array)&&(e=be.from(e,e.offset,e.byteLength)),!be.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;for(var s=o-i,a=n-r,d=Math.min(s,a),u=this.slice(i,o),c=e.slice(r,n),l=0;l2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,LD(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=be.from(e,n)),be.isBuffer(e))return e.length===0?-1:Wz(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):Wz(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Wz(t,e,r,n,i){var 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 d(m,g){return o===1?m[g]:m.readUInt16BE(g*o)}var u;if(i){var c=-1;for(u=r;us&&(r=s-a),u=r;u>=0;u--){for(var l=!0,p=0;pi&&(n=i)):n=i;var o=e.length;n>o/2&&(n=o/2);for(var s=0;s>>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");var 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");for(var s=!1;;)switch(i){case"hex":return u2e(this,e,r,n);case"utf8":case"utf-8":return l2e(this,e,r,n);case"ascii":case"latin1":case"binary":return f2e(this,e,r,n);case"base64":return h2e(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return p2e(this,e,r,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};be.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function m2e(t,e,r){return e===0&&r===t.length?CD.fromByteArray(t):CD.fromByteArray(t.slice(e,r))}function Yz(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:o>223?3:o>191?2:1;if(i+a<=r){var d,u,c,l;switch(a){case 1:o<128&&(s=o);break;case 2:d=t[i+1],(d&192)===128&&(l=(o&31)<<6|d&63,l>127&&(s=l));break;case 3:d=t[i+1],u=t[i+2],(d&192)===128&&(u&192)===128&&(l=(o&15)<<12|(d&63)<<6|u&63,l>2047&&(l<55296||l>57343)&&(s=l));break;case 4:d=t[i+1],u=t[i+2],c=t[i+3],(d&192)===128&&(u&192)===128&&(c&192)===128&&(l=(o&15)<<18|(d&63)<<12|(u&63)<<6|c&63,l>65535&&l<1114112&&(s=l))}}s===null?(s=65533,a=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),i+=a}return y2e(n)}var Hz=4096;function y2e(t){var e=t.length;if(e<=Hz)return String.fromCharCode.apply(String,t);for(var r="",n=0;nn)&&(r=n);for(var i="",o=e;on&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),rr)throw new RangeError("Trying to access beyond buffer length")}be.prototype.readUintLE=be.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||Eo(e,r,this.length);for(var i=this[e],o=1,s=0;++s>>0,r=r>>>0,n||Eo(e,r,this.length);for(var i=this[e+--r],o=1;r>0&&(o*=256);)i+=this[e+--r]*o;return i};be.prototype.readUint8=be.prototype.readUInt8=function(e,r){return e=e>>>0,r||Eo(e,1,this.length),this[e]};be.prototype.readUint16LE=be.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||Eo(e,2,this.length),this[e]|this[e+1]<<8};be.prototype.readUint16BE=be.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||Eo(e,2,this.length),this[e]<<8|this[e+1]};be.prototype.readUint32LE=be.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||Eo(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};be.prototype.readUint32BE=be.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||Eo(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};be.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||Eo(e,r,this.length);for(var i=this[e],o=1,s=0;++s=o&&(i-=Math.pow(2,8*r)),i};be.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||Eo(e,r,this.length);for(var i=r,o=1,s=this[e+--i];i>0&&(o*=256);)s+=this[e+--i]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*r)),s};be.prototype.readInt8=function(e,r){return e=e>>>0,r||Eo(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};be.prototype.readInt16LE=function(e,r){e=e>>>0,r||Eo(e,2,this.length);var n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};be.prototype.readInt16BE=function(e,r){e=e>>>0,r||Eo(e,2,this.length);var n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};be.prototype.readInt32LE=function(e,r){return e=e>>>0,r||Eo(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};be.prototype.readInt32BE=function(e,r){return e=e>>>0,r||Eo(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};be.prototype.readFloatLE=function(e,r){return e=e>>>0,r||Eo(e,4,this.length),jb.read(this,e,!0,23,4)};be.prototype.readFloatBE=function(e,r){return e=e>>>0,r||Eo(e,4,this.length),jb.read(this,e,!1,23,4)};be.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||Eo(e,8,this.length),jb.read(this,e,!0,52,8)};be.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||Eo(e,8,this.length),jb.read(this,e,!1,52,8)};function Va(t,e,r,n,i,o){if(!be.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}be.prototype.writeUintLE=be.prototype.writeUIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){var o=Math.pow(2,8*n)-1;Va(this,e,r,n,o,0)}var s=1,a=0;for(this[r]=e&255;++a>>0,n=n>>>0,!i){var o=Math.pow(2,8*n)-1;Va(this,e,r,n,o,0)}var s=n-1,a=1;for(this[r+s]=e&255;--s>=0&&(a*=256);)this[r+s]=e/a&255;return r+n};be.prototype.writeUint8=be.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||Va(this,e,r,1,255,0),this[r]=e&255,r+1};be.prototype.writeUint16LE=be.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||Va(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};be.prototype.writeUint16BE=be.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||Va(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};be.prototype.writeUint32LE=be.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||Va(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};be.prototype.writeUint32BE=be.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||Va(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};be.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){var o=Math.pow(2,8*n-1);Va(this,e,r,n,o-1,-o)}var s=0,a=1,d=0;for(this[r]=e&255;++s>0)-d&255;return r+n};be.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){var o=Math.pow(2,8*n-1);Va(this,e,r,n,o-1,-o)}var s=n-1,a=1,d=0;for(this[r+s]=e&255;--s>=0&&(a*=256);)e<0&&d===0&&this[r+s+1]!==0&&(d=1),this[r+s]=(e/a>>0)-d&255;return r+n};be.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||Va(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};be.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||Va(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};be.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||Va(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};be.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||Va(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};be.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||Va(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};function Xz(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 Qz(t,e,r,n,i){return e=+e,r=r>>>0,i||Xz(t,e,r,4,34028234663852886e22,-34028234663852886e22),jb.write(t,e,r,n,23,4),r+4}be.prototype.writeFloatLE=function(e,r,n){return Qz(this,e,r,!0,n)};be.prototype.writeFloatBE=function(e,r,n){return Qz(this,e,r,!1,n)};function eW(t,e,r,n,i){return e=+e,r=r>>>0,i||Xz(t,e,r,8,17976931348623157e292,-17976931348623157e292),jb.write(t,e,r,n,52,8),r+8}be.prototype.writeDoubleLE=function(e,r,n){return eW(this,e,r,!0,n)};be.prototype.writeDoubleBE=function(e,r,n){return eW(this,e,r,!1,n)};be.prototype.copy=function(e,r,n,i){if(!be.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=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>>0,n=n===void 0?this.length:n>>>0,e||(e=0);var s;if(typeof e=="number")for(s=r;s55295&&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 E2e(t){for(var e=[],r=0;r>8,i=r%256,o.push(i),o.push(n);return o}function tW(t){return CD.toByteArray(x2e(t))}function U5(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function bl(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function LD(t){return t!==t}var A2e=function(){for(var t="0123456789abcdef",e=new Array(256),r=0;r<16;++r)for(var n=r*16,i=0;i<16;++i)e[n+i]=t[r]+t[i];return e}()});var $s=V((bit,sW)=>{f();var Ti=sW.exports={},wl,_l;function KD(){throw new Error("setTimeout has not been defined")}function FD(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?wl=setTimeout:wl=KD}catch{wl=KD}try{typeof clearTimeout=="function"?_l=clearTimeout:_l=FD}catch{_l=FD}})();function nW(t){if(wl===setTimeout)return setTimeout(t,0);if((wl===KD||!wl)&&setTimeout)return wl=setTimeout,setTimeout(t,0);try{return wl(t,0)}catch{try{return wl.call(null,t,0)}catch{return wl.call(this,t,0)}}}function T2e(t){if(_l===clearTimeout)return clearTimeout(t);if((_l===FD||!_l)&&clearTimeout)return _l=clearTimeout,clearTimeout(t);try{return _l(t)}catch{try{return _l.call(null,t)}catch{return _l.call(this,t)}}}var Vf=[],Ub=!1,x0,q5=-1;function P2e(){!Ub||!x0||(Ub=!1,x0.length?Vf=x0.concat(Vf):q5=-1,Vf.length&&iW())}function iW(){if(!Ub){var t=nW(P2e);Ub=!0;for(var e=Vf.length;e;){for(x0=Vf,Vf=[];++q51)for(var r=1;r{O=gt(rW()),k=gt($s()),_it=function(t){function e(){var n=this||self;return delete t.prototype.__magic__,n}if(typeof globalThis=="object")return globalThis;if(this)return e();t.defineProperty(t.prototype,"__magic__",{configurable:!0,get:e});var r=__magic__;return r}(Object)});var cW=V((Eit,aW)=>{f();var I2e=typeof globalThis=="object"&&globalThis&&globalThis.Object===Object&&globalThis;aW.exports=I2e});var uW=V((Ait,dW)=>{f();var k2e=cW(),R2e=typeof self=="object"&&self&&self.Object===Object&&self,D2e=k2e||R2e||Function("return this")();dW.exports=D2e});var zD=V((Pit,lW)=>{f();var B2e=uW(),M2e=B2e.Symbol;lW.exports=M2e});var mW=V((kit,pW)=>{f();var fW=zD(),hW=Object.prototype,O2e=hW.hasOwnProperty,C2e=hW.toString,L_=fW?fW.toStringTag:void 0;function $2e(t){var e=O2e.call(t,L_),r=t[L_];try{t[L_]=void 0;var n=!0}catch{}var i=C2e.call(t);return n&&(e?t[L_]=r:delete t[L_]),i}pW.exports=$2e});var gW=V((Dit,yW)=>{f();var j2e=Object.prototype,N2e=j2e.toString;function U2e(t){return N2e.call(t)}yW.exports=U2e});var _W=V((Mit,wW)=>{f();var vW=zD(),q2e=mW(),L2e=gW(),K2e="[object Null]",F2e="[object Undefined]",bW=vW?vW.toStringTag:void 0;function z2e(t){return t==null?t===void 0?F2e:K2e:bW&&bW in Object(t)?q2e(t):L2e(t)}wW.exports=z2e});var EW=V((Cit,xW)=>{f();function W2e(t,e){return function(r){return t(e(r))}}xW.exports=W2e});var AW=V((jit,SW)=>{f();var H2e=EW(),V2e=H2e(Object.getPrototypeOf,Object);SW.exports=V2e});var PW=V((Uit,TW)=>{f();function G2e(t){return t!=null&&typeof t=="object"}TW.exports=G2e});var RW=V((Lit,kW)=>{f();var J2e=_W(),Z2e=AW(),Y2e=PW(),X2e="[object Object]",Q2e=Function.prototype,e_e=Object.prototype,IW=Q2e.toString,t_e=e_e.hasOwnProperty,r_e=IW.call(Object);function n_e(t){if(!Y2e(t)||J2e(t)!=X2e)return!1;var e=Z2e(t);if(e===null)return!0;var r=t_e.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&IW.call(r)==r_e}kW.exports=n_e});var Dc=V((Plt,YG)=>{"use strict";f();function ZG(t,e){for(let r in e)Object.defineProperty(t,r,{value:e[r],enumerable:!0,configurable:!0});return t}function GSe(t,e,r){if(!t||typeof t=="string")throw new TypeError("Please pass an Error to err-code");r||(r={}),typeof e=="object"&&(r=e,e=""),e&&(r.code=e);try{return ZG(t,r)}catch{r.message=t.message,r.stack=t.stack;let i=function(){};return i.prototype=Object.create(Object.getPrototypeOf(t)),ZG(new i,r)}}YG.exports=GSe});var HJ=V((Cx,M8)=>{f();(function(t,e){"use strict";var r={version:"3.0.0",x86:{},x64:{},inputValidation:!0};function n(m){if(!Array.isArray(m)&&!ArrayBuffer.isView(m))return!1;for(var g=0;g255)return!1;return!0}function i(m,g){return(m&65535)*g+(((m>>>16)*g&65535)<<16)}function o(m,g){return m<>>32-g}function s(m){return m^=m>>>16,m=i(m,2246822507),m^=m>>>13,m=i(m,3266489909),m^=m>>>16,m}function a(m,g){m=[m[0]>>>16,m[0]&65535,m[1]>>>16,m[1]&65535],g=[g[0]>>>16,g[0]&65535,g[1]>>>16,g[1]&65535];var v=[0,0,0,0];return v[3]+=m[3]+g[3],v[2]+=v[3]>>>16,v[3]&=65535,v[2]+=m[2]+g[2],v[1]+=v[2]>>>16,v[2]&=65535,v[1]+=m[1]+g[1],v[0]+=v[1]>>>16,v[1]&=65535,v[0]+=m[0]+g[0],v[0]&=65535,[v[0]<<16|v[1],v[2]<<16|v[3]]}function d(m,g){m=[m[0]>>>16,m[0]&65535,m[1]>>>16,m[1]&65535],g=[g[0]>>>16,g[0]&65535,g[1]>>>16,g[1]&65535];var v=[0,0,0,0];return v[3]+=m[3]*g[3],v[2]+=v[3]>>>16,v[3]&=65535,v[2]+=m[2]*g[3],v[1]+=v[2]>>>16,v[2]&=65535,v[2]+=m[3]*g[2],v[1]+=v[2]>>>16,v[2]&=65535,v[1]+=m[1]*g[3],v[0]+=v[1]>>>16,v[1]&=65535,v[1]+=m[2]*g[2],v[0]+=v[1]>>>16,v[1]&=65535,v[1]+=m[3]*g[1],v[0]+=v[1]>>>16,v[1]&=65535,v[0]+=m[0]*g[3]+m[1]*g[2]+m[2]*g[1]+m[3]*g[0],v[0]&=65535,[v[0]<<16|v[1],v[2]<<16|v[3]]}function u(m,g){return g%=64,g===32?[m[1],m[0]]:g<32?[m[0]<>>32-g,m[1]<>>32-g]:(g-=32,[m[1]<>>32-g,m[0]<>>32-g])}function c(m,g){return g%=64,g===0?m:g<32?[m[0]<>>32-g,m[1]<>>1]),m=d(m,[4283543511,3981806797]),m=l(m,[0,m[0]>>>1]),m=d(m,[3301882366,444984403]),m=l(m,[0,m[0]>>>1]),m}r.x86.hash32=function(m,g){if(r.inputValidation&&!n(m))return e;g=g||0;for(var v=m.length%4,x=m.length-v,S=g,P=0,A=3432918353,$=461845907,j=0;j>>0},r.x86.hash128=function(m,g){if(r.inputValidation&&!n(m))return e;g=g||0;for(var v=m.length%16,x=m.length-v,S=g,P=g,A=g,$=g,j=0,L=0,F=0,K=0,W=597399067,q=2869860233,I=951274213,T=2716044179,B=0;B>>0).toString(16)).slice(-8)+("00000000"+(P>>>0).toString(16)).slice(-8)+("00000000"+(A>>>0).toString(16)).slice(-8)+("00000000"+($>>>0).toString(16)).slice(-8)},r.x64.hash128=function(m,g){if(r.inputValidation&&!n(m))return e;g=g||0;for(var v=m.length%16,x=m.length-v,S=[0,g],P=[0,g],A=[0,0],$=[0,0],j=[2277735313,289559509],L=[1291169091,658871167],F=0;F>>0).toString(16)).slice(-8)+("00000000"+(S[1]>>>0).toString(16)).slice(-8)+("00000000"+(P[0]>>>0).toString(16)).slice(-8)+("00000000"+(P[1]>>>0).toString(16)).slice(-8)},typeof Cx<"u"?(typeof M8<"u"&&M8.exports&&(Cx=M8.exports=r),Cx.murmurHash3=r):typeof define=="function"&&define.amd?define([],function(){return r}):(r._murmurHash3=t.murmurHash3,r.noConflict=function(){return t.murmurHash3=r._murmurHash3,r._murmurHash3=e,r.noConflict=e,r},t.murmurHash3=r)})(Cx)});var GJ=V((nmt,VJ)=>{f();VJ.exports=HJ()});var YJ=V((fmt,ZJ)=>{"use strict";f();ZJ.exports=class{constructor(){this._bitArrays=[],this._data=[],this._length=0,this._changedLength=!1,this._changedData=!1}set(e,r){let n=this._internalPositionFor(e,!1);if(r===void 0)n!==-1&&(this._unsetInternalPos(n),this._unsetBit(e),this._changedLength=!0,this._changedData=!0);else{let i=!1;n===-1?(n=this._data.length,this._setBit(e),this._changedData=!0):i=!0,this._setInternalPos(n,e,r,i),this._changedLength=!0}}unset(e){this.set(e,void 0)}get(e){this._sortData();let r=this._internalPositionFor(e,!0);if(r!==-1)return this._data[r][1]}push(e){return this.set(this.length,e),this.length}get length(){if(this._sortData(),this._changedLength){let e=this._data[this._data.length-1];this._length=e?e[0]+1:0,this._changedLength=!1}return this._length}forEach(e){let r=0;for(;r=this._bitArrays.length)return-1;let i=this._bitArrays[n],o=e-n*7;if(!((i&1<0))return-1;let a=this._bitArrays.slice(0,n).reduce(t5e,0),d=~(4294967295<=r)o.push(s);else if(o[0][0]<=r)o.unshift(s);else{let a=Math.round(o.length/2);this._data=o.slice(0,a).concat(s).concat(o.slice(a))}else this._data.push(s);this._changedData=!0,this._changedLength=!0}}_unsetInternalPos(e){this._data.splice(e,1)}_sortData(){this._changedData&&this._data.sort(r5e),this._changedData=!1}bitField(){let e=[],r=8,n=0,i=0,o,s=this._bitArrays.slice();for(;s.length||n;){n===0&&(o=s.shift(),n=7);let d=Math.min(n,r),u=~(255<>>d,n-=d,r-=d,(!r||!n&&!s.length)&&(e.push(i),i=0,r=8)}for(var a=e.length-1;a>0&&e[a]===0;a--)e.pop();return e}compactArray(){return this._sortData(),this._data.map(n5e)}};function t5e(t,e){return t+JJ(e)}function JJ(t){let e=t;return e=e-(e>>1&1431655765),e=(e&858993459)+(e>>2&858993459),(e+(e>>4)&252645135)*16843009>>24}function r5e(t,e){return t[0]-e[0]}function n5e(t){return t[1]}});var hn=V(Tw=>{"use strict";f();var d7=BD(),Sw=OD(),lZ=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Tw.Buffer=ge;Tw.SlowBuffer=_5e;Tw.INSPECT_MAX_BYTES=50;var U8=2147483647;Tw.kMaxLength=U8;ge.TYPED_ARRAY_SUPPORT=y5e();!ge.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 y5e(){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(ge.prototype,"parent",{enumerable:!0,get:function(){if(ge.isBuffer(this))return this.buffer}});Object.defineProperty(ge.prototype,"offset",{enumerable:!0,get:function(){if(ge.isBuffer(this))return this.byteOffset}});function ch(t){if(t>U8)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,ge.prototype),e}function ge(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 h7(t)}return mZ(t,e,r)}ge.poolSize=8192;function mZ(t,e,r){if(typeof t=="string")return v5e(t,e);if(ArrayBuffer.isView(t))return b5e(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(Dl(t,ArrayBuffer)||t&&Dl(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Dl(t,SharedArrayBuffer)||t&&Dl(t.buffer,SharedArrayBuffer)))return l7(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 ge.from(n,e,r);let i=w5e(t);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return ge.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)}ge.from=function(t,e,r){return mZ(t,e,r)};Object.setPrototypeOf(ge.prototype,Uint8Array.prototype);Object.setPrototypeOf(ge,Uint8Array);function yZ(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 g5e(t,e,r){return yZ(t),t<=0?ch(t):e!==void 0?typeof r=="string"?ch(t).fill(e,r):ch(t).fill(e):ch(t)}ge.alloc=function(t,e,r){return g5e(t,e,r)};function h7(t){return yZ(t),ch(t<0?0:p7(t)|0)}ge.allocUnsafe=function(t){return h7(t)};ge.allocUnsafeSlow=function(t){return h7(t)};function v5e(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!ge.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=gZ(t,e)|0,n=ch(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function u7(t){let e=t.length<0?0:p7(t.length)|0,r=ch(e);for(let n=0;n=U8)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+U8.toString(16)+" bytes");return t|0}function _5e(t){return+t!=t&&(t=0),ge.alloc(+t)}ge.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==ge.prototype};ge.compare=function(e,r){if(Dl(e,Uint8Array)&&(e=ge.from(e,e.offset,e.byteLength)),Dl(r,Uint8Array)&&(r=ge.from(r,r.offset,r.byteLength)),!ge.isBuffer(e)||!ge.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);oi.length?(ge.isBuffer(s)||(s=ge.from(s)),s.copy(i,o)):Uint8Array.prototype.set.call(i,s,o);else if(ge.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function gZ(t,e){if(ge.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Dl(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 f7(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return TZ(t).length;default:if(i)return n?-1:f7(t).length;e=(""+e).toLowerCase(),i=!0}}ge.byteLength=gZ;function x5e(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 B5e(this,e,r);case"utf8":case"utf-8":return bZ(this,e,r);case"ascii":return R5e(this,e,r);case"latin1":case"binary":return D5e(this,e,r);case"base64":return I5e(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return M5e(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}ge.prototype._isBuffer=!0;function X0(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}ge.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;rr&&(e+=" ... "),""};lZ&&(ge.prototype[lZ]=ge.prototype.inspect);ge.prototype.compare=function(e,r,n,i,o){if(Dl(e,Uint8Array)&&(e=ge.from(e,e.offset,e.byteLength)),!ge.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,d=Math.min(s,a),u=this.slice(i,o),c=e.slice(r,n);for(let l=0;l2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,y7(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=ge.from(e,n)),ge.isBuffer(e))return e.length===0?-1:fZ(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):fZ(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function fZ(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 d(c,l){return o===1?c[l]:c.readUInt16BE(l*o)}let u;if(i){let c=-1;for(u=r;us&&(r=s-a),u=r;u>=0;u--){let c=!0;for(let l=0;li&&(n=i)):n=i;let o=e.length;n>o/2&&(n=o/2);let s;for(s=0;s>>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 E5e(this,e,r,n);case"utf8":case"utf-8":return S5e(this,e,r,n);case"ascii":case"latin1":case"binary":return A5e(this,e,r,n);case"base64":return T5e(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P5e(this,e,r,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};ge.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function I5e(t,e,r){return e===0&&r===t.length?d7.fromByteArray(t):d7.fromByteArray(t.slice(e,r))}function bZ(t,e,r){r=Math.min(t.length,r);let n=[],i=e;for(;i239?4:o>223?3:o>191?2:1;if(i+a<=r){let d,u,c,l;switch(a){case 1:o<128&&(s=o);break;case 2:d=t[i+1],(d&192)===128&&(l=(o&31)<<6|d&63,l>127&&(s=l));break;case 3:d=t[i+1],u=t[i+2],(d&192)===128&&(u&192)===128&&(l=(o&15)<<12|(d&63)<<6|u&63,l>2047&&(l<55296||l>57343)&&(s=l));break;case 4:d=t[i+1],u=t[i+2],c=t[i+3],(d&192)===128&&(u&192)===128&&(c&192)===128&&(l=(o&15)<<18|(d&63)<<12|(u&63)<<6|c&63,l>65535&&l<1114112&&(s=l))}}s===null?(s=65533,a=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),i+=a}return k5e(n)}var hZ=4096;function k5e(t){let e=t.length;if(e<=hZ)return String.fromCharCode.apply(String,t);let r="",n=0;for(;nn)&&(r=n);let i="";for(let o=e;on&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),rr)throw new RangeError("Trying to access beyond buffer length")}ge.prototype.readUintLE=ge.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||Do(e,r,this.length);let i=this[e],o=1,s=0;for(;++s>>0,r=r>>>0,n||Do(e,r,this.length);let i=this[e+--r],o=1;for(;r>0&&(o*=256);)i+=this[e+--r]*o;return i};ge.prototype.readUint8=ge.prototype.readUInt8=function(e,r){return e=e>>>0,r||Do(e,1,this.length),this[e]};ge.prototype.readUint16LE=ge.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||Do(e,2,this.length),this[e]|this[e+1]<<8};ge.prototype.readUint16BE=ge.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||Do(e,2,this.length),this[e]<<8|this[e+1]};ge.prototype.readUint32LE=ge.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||Do(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};ge.prototype.readUint32BE=ge.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||Do(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};ge.prototype.readBigUInt64LE=um(function(e){e=e>>>0,Aw(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&jx(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)<>>0,Aw(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&jx(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)<>>0,r=r>>>0,n||Do(e,r,this.length);let i=this[e],o=1,s=0;for(;++s=o&&(i-=Math.pow(2,8*r)),i};ge.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||Do(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};ge.prototype.readInt8=function(e,r){return e=e>>>0,r||Do(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};ge.prototype.readInt16LE=function(e,r){e=e>>>0,r||Do(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};ge.prototype.readInt16BE=function(e,r){e=e>>>0,r||Do(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};ge.prototype.readInt32LE=function(e,r){return e=e>>>0,r||Do(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};ge.prototype.readInt32BE=function(e,r){return e=e>>>0,r||Do(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};ge.prototype.readBigInt64LE=um(function(e){e=e>>>0,Aw(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&jx(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<>>0,Aw(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&jx(e,this.length-8);let i=(r<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(i)<>>0,r||Do(e,4,this.length),Sw.read(this,e,!0,23,4)};ge.prototype.readFloatBE=function(e,r){return e=e>>>0,r||Do(e,4,this.length),Sw.read(this,e,!1,23,4)};ge.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||Do(e,8,this.length),Sw.read(this,e,!0,52,8)};ge.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||Do(e,8,this.length),Sw.read(this,e,!1,52,8)};function Za(t,e,r,n,i,o){if(!ge.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}ge.prototype.writeUintLE=ge.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;Za(this,e,r,n,a,0)}let o=1,s=0;for(this[r]=e&255;++s>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;Za(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};ge.prototype.writeUint8=ge.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||Za(this,e,r,1,255,0),this[r]=e&255,r+1};ge.prototype.writeUint16LE=ge.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||Za(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};ge.prototype.writeUint16BE=ge.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||Za(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};ge.prototype.writeUint32LE=ge.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||Za(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};ge.prototype.writeUint32BE=ge.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||Za(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 wZ(t,e,r,n,i){AZ(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 _Z(t,e,r,n,i){AZ(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}ge.prototype.writeBigUInt64LE=um(function(e,r=0){return wZ(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});ge.prototype.writeBigUInt64BE=um(function(e,r=0){return _Z(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});ge.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let d=Math.pow(2,8*n-1);Za(this,e,r,n,d-1,-d)}let o=0,s=1,a=0;for(this[r]=e&255;++o>0)-a&255;return r+n};ge.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let d=Math.pow(2,8*n-1);Za(this,e,r,n,d-1,-d)}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};ge.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||Za(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};ge.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||Za(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};ge.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||Za(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};ge.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||Za(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};ge.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||Za(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};ge.prototype.writeBigInt64LE=um(function(e,r=0){return wZ(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});ge.prototype.writeBigInt64BE=um(function(e,r=0){return _Z(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function xZ(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 EZ(t,e,r,n,i){return e=+e,r=r>>>0,i||xZ(t,e,r,4,34028234663852886e22,-34028234663852886e22),Sw.write(t,e,r,n,23,4),r+4}ge.prototype.writeFloatLE=function(e,r,n){return EZ(this,e,r,!0,n)};ge.prototype.writeFloatBE=function(e,r,n){return EZ(this,e,r,!1,n)};function SZ(t,e,r,n,i){return e=+e,r=r>>>0,i||xZ(t,e,r,8,17976931348623157e292,-17976931348623157e292),Sw.write(t,e,r,n,52,8),r+8}ge.prototype.writeDoubleLE=function(e,r,n){return SZ(this,e,r,!0,n)};ge.prototype.writeDoubleBE=function(e,r,n){return SZ(this,e,r,!1,n)};ge.prototype.copy=function(e,r,n,i){if(!ge.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=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>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let o;if(typeof e=="number")for(o=r;o2**32?i=pZ(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=pZ(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function pZ(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 O5e(t,e,r){Aw(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&jx(e,t.length-(r+1))}function AZ(t,e,r,n,i,o){if(t>r||t3?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 Ew.ERR_OUT_OF_RANGE("value",a,t)}O5e(n,i,o)}function Aw(t,e){if(typeof t!="number")throw new Ew.ERR_INVALID_ARG_TYPE(e,"number",t)}function jx(t,e,r){throw Math.floor(t)!==t?(Aw(t,r),new Ew.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new Ew.ERR_BUFFER_OUT_OF_BOUNDS:new Ew.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var C5e=/[^+/0-9A-Za-z-_]/g;function $5e(t){if(t=t.split("=")[0],t=t.trim().replace(C5e,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function f7(t,e){e=e||1/0;let r,n=t.length,i=null,o=[];for(let s=0;s55295&&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 j5e(t){let e=[];for(let r=0;r>8,i=r%256,o.push(i),o.push(n);return o}function TZ(t){return d7.toByteArray($5e(t))}function q8(t,e,r,n){let i;for(i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function Dl(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function y7(t){return t!==t}var U5e=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 um(t){return typeof BigInt>"u"?q5e:t}function q5e(){throw new Error("BigInt not supported")}});var cr=V((g7,IZ)=>{f();var L8=hn(),Bl=L8.Buffer;function PZ(t,e){for(var r in t)e[r]=t[r]}Bl.from&&Bl.alloc&&Bl.allocUnsafe&&Bl.allocUnsafeSlow?IZ.exports=L8:(PZ(L8,g7),g7.Buffer=Q0);function Q0(t,e,r){return Bl(t,e,r)}Q0.prototype=Object.create(Bl.prototype);PZ(Bl,Q0);Q0.from=function(t,e,r){if(typeof t=="number")throw new TypeError("Argument must not be a number");return Bl(t,e,r)};Q0.alloc=function(t,e,r){if(typeof t!="number")throw new TypeError("Argument must be a number");var n=Bl(t);return e!==void 0?typeof r=="string"?n.fill(e,r):n.fill(e):n.fill(0),n};Q0.allocUnsafe=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return Bl(t)};Q0.allocUnsafeSlow=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return L8.SlowBuffer(t)}});var eg=V((myt,b7)=>{"use strict";f();var v7=65536,L5e=4294967295;function K5e(){throw new Error(`Secure random number generation is not supported by this browser. -Use Chrome, Firefox or Internet Explorer 11`)}var F5e=cr().Buffer,K8=globalThis.crypto||globalThis.msCrypto;K8&&K8.getRandomValues?b7.exports=z5e:b7.exports=K5e;function z5e(t,e){if(t>L5e)throw new RangeError("requested too many random bytes");var r=F5e.allocUnsafe(t);if(t>0)if(t>v7)for(var n=0;n{f();typeof Object.create=="function"?w7.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:w7.exports=function(e,r){if(r){e.super_=r;var n=function(){};n.prototype=r.prototype,e.prototype=new n,e.prototype.constructor=e}}});var Sa=V((byt,_7)=>{"use strict";f();var Pw=typeof Reflect=="object"?Reflect:null,kZ=Pw&&typeof Pw.apply=="function"?Pw.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},F8;Pw&&typeof Pw.ownKeys=="function"?F8=Pw.ownKeys:Object.getOwnPropertySymbols?F8=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:F8=function(e){return Object.getOwnPropertyNames(e)};function W5e(t){console&&console.warn&&console.warn(t)}var DZ=Number.isNaN||function(e){return e!==e};function pn(){pn.init.call(this)}_7.exports=pn;_7.exports.once=J5e;pn.EventEmitter=pn;pn.prototype._events=void 0;pn.prototype._eventsCount=0;pn.prototype._maxListeners=void 0;var RZ=10;function z8(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(pn,"defaultMaxListeners",{enumerable:!0,get:function(){return RZ},set:function(t){if(typeof t!="number"||t<0||DZ(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");RZ=t}});pn.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};pn.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||DZ(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 BZ(t){return t._maxListeners===void 0?pn.defaultMaxListeners:t._maxListeners}pn.prototype.getMaxListeners=function(){return BZ(this)};pn.prototype.emit=function(e){for(var r=[],n=1;n0&&(s=r[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var d=o[e];if(d===void 0)return!1;if(typeof d=="function")kZ(d,this,r);else for(var u=d.length,c=jZ(d,u),n=0;n0&&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,W5e(a)}return t}pn.prototype.addListener=function(e,r){return MZ(this,e,r,!1)};pn.prototype.on=pn.prototype.addListener;pn.prototype.prependListener=function(e,r){return MZ(this,e,r,!0)};function H5e(){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 OZ(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=H5e.bind(n);return i.listener=r,n.wrapFn=i,i}pn.prototype.once=function(e,r){return z8(r),this.on(e,OZ(this,e,r)),this};pn.prototype.prependOnceListener=function(e,r){return z8(r),this.prependListener(e,OZ(this,e,r)),this};pn.prototype.removeListener=function(e,r){var n,i,o,s,a;if(z8(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():V5e(n,o),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this};pn.prototype.off=pn.prototype.removeListener;pn.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=0;i--)this.removeListener(e,r[i]);return this};function CZ(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?G5e(i):jZ(i,i.length)}pn.prototype.listeners=function(e){return CZ(this,e,!0)};pn.prototype.rawListeners=function(e){return CZ(this,e,!1)};pn.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):$Z.call(t,e)};pn.prototype.listenerCount=$Z;function $Z(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}pn.prototype.eventNames=function(){return this._eventsCount>0?F8(this._events):[]};function jZ(t,e){for(var r=new Array(e),n=0;n{f();UZ.exports=Sa().EventEmitter});var Nx=V(()=>{f()});var WZ=V((Tyt,zZ)=>{"use strict";f();function qZ(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),r.push.apply(r,n)}return r}function LZ(t){for(var e=1;e0?this.tail.next=n:this.head=n,this.tail=n,++this.length}},{key:"unshift",value:function(r){var n={data:r,next:this.head};this.length===0&&(this.tail=n),this.head=n,++this.length}},{key:"shift",value:function(){if(this.length!==0){var r=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,r}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(r){if(this.length===0)return"";for(var n=this.head,i=""+n.data;n=n.next;)i+=r+n.data;return i}},{key:"concat",value:function(r){if(this.length===0)return W8.alloc(0);for(var n=W8.allocUnsafe(r>>>0),i=this.head,o=0;i;)i8e(i.data,n,o),o+=i.data.length,i=i.next;return n}},{key:"consume",value:function(r,n){var i;return rs.length?s.length:r;if(a===s.length?o+=s:o+=s.slice(0,r),r-=a,r===0){a===s.length?(++i,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=s.slice(a));break}++i}return this.length-=i,o}},{key:"_getBuffer",value:function(r){var n=W8.allocUnsafe(r),i=this.head,o=1;for(i.data.copy(n),r-=i.data.length;i=i.next;){var s=i.data,a=r>s.length?s.length:r;if(s.copy(n,n.length-r,0,a),r-=a,r===0){a===s.length?(++o,i.next?this.head=i.next:this.head=this.tail=null):(this.head=i,i.data=s.slice(a));break}++o}return this.length-=o,n}},{key:n8e,value:function(r,n){return E7(this,LZ(LZ({},n),{},{depth:0,customInspect:!1}))}}]),t}()});var A7=V((Iyt,VZ)=>{"use strict";f();function o8e(t,e){var r=this,n=this._readableState&&this._readableState.destroyed,i=this._writableState&&this._writableState.destroyed;return n||i?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,k.default.nextTick(S7,this,t)):k.default.nextTick(S7,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(o){!e&&o?r._writableState?r._writableState.errorEmitted?k.default.nextTick(H8,r):(r._writableState.errorEmitted=!0,k.default.nextTick(HZ,r,o)):k.default.nextTick(HZ,r,o):e?(k.default.nextTick(H8,r),e(o)):k.default.nextTick(H8,r)}),this)}function HZ(t,e){S7(t,e),H8(t)}function H8(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function s8e(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function S7(t,e){t.emit("error",e)}function a8e(t,e){var r=t._readableState,n=t._writableState;r&&r.autoDestroy||n&&n.autoDestroy?t.destroy(e):t.emit("error",e)}VZ.exports={destroy:o8e,undestroy:s8e,errorOrDestroy:a8e}});var tg=V((Ryt,ZZ)=>{"use strict";f();function c8e(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}var JZ={};function _d(t,e,r){r||(r=Error);function n(o,s,a){return typeof e=="string"?e:e(o,s,a)}var i=function(o){c8e(s,o);function s(a,d,u){return o.call(this,n(a,d,u))||this}return s}(r);i.prototype.name=r.name,i.prototype.code=t,JZ[t]=i}function GZ(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map(function(n){return String(n)}),r>2?"one of ".concat(e," ").concat(t.slice(0,r-1).join(", "),", or ")+t[r-1]:r===2?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}else return"of ".concat(e," ").concat(String(t))}function d8e(t,e,r){return t.substr(!r||r<0?0:+r,e.length)===e}function u8e(t,e,r){return(r===void 0||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}function l8e(t,e,r){return typeof r!="number"&&(r=0),r+e.length>t.length?!1:t.indexOf(e,r)!==-1}_d("ERR_INVALID_OPT_VALUE",function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'},TypeError);_d("ERR_INVALID_ARG_TYPE",function(t,e,r){var n;typeof e=="string"&&d8e(e,"not ")?(n="must not be",e=e.replace(/^not /,"")):n="must be";var i;if(u8e(t," argument"))i="The ".concat(t," ").concat(n," ").concat(GZ(e,"type"));else{var o=l8e(t,".")?"property":"argument";i='The "'.concat(t,'" ').concat(o," ").concat(n," ").concat(GZ(e,"type"))}return i+=". Received type ".concat(typeof r),i},TypeError);_d("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF");_d("ERR_METHOD_NOT_IMPLEMENTED",function(t){return"The "+t+" method is not implemented"});_d("ERR_STREAM_PREMATURE_CLOSE","Premature close");_d("ERR_STREAM_DESTROYED",function(t){return"Cannot call "+t+" after a stream was destroyed"});_d("ERR_MULTIPLE_CALLBACK","Callback called multiple times");_d("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable");_d("ERR_STREAM_WRITE_AFTER_END","write after end");_d("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);_d("ERR_UNKNOWN_ENCODING",function(t){return"Unknown encoding: "+t},TypeError);_d("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event");ZZ.exports.codes=JZ});var T7=V((Byt,YZ)=>{"use strict";f();var f8e=tg().codes.ERR_INVALID_OPT_VALUE;function h8e(t,e,r){return t.highWaterMark!=null?t.highWaterMark:e?t[r]:null}function p8e(t,e,r,n){var i=h8e(e,n,r);if(i!=null){if(!(isFinite(i)&&Math.floor(i)===i)||i<0){var o=n?r:"highWaterMark";throw new f8e(o,i)}return Math.floor(i)}return t.objectMode?16:16*1024}YZ.exports={getHighWaterMark:p8e}});var I7=V((Oyt,XZ)=>{f();XZ.exports=m8e;function m8e(t,e){if(P7("noDeprecation"))return t;var r=!1;function n(){if(!r){if(P7("throwDeprecation"))throw new Error(e);P7("traceDeprecation")?console.trace(e):console.warn(e),r=!0}return t.apply(this,arguments)}return n}function P7(t){try{if(!globalThis.localStorage)return!1}catch{return!1}var e=globalThis.localStorage[t];return e==null?!1:String(e).toLowerCase()==="true"}});var J8=V(($yt,iY)=>{"use strict";f();iY.exports=gi;function eY(t){var e=this;this.next=null,this.entry=null,this.finish=function(){K8e(e,t)}}var Iw;gi.WritableState=qx;var y8e={deprecate:I7()},tY=x7(),G8=hn().Buffer,g8e=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function v8e(t){return G8.from(t)}function b8e(t){return G8.isBuffer(t)||t instanceof g8e}var R7=A7(),w8e=T7(),_8e=w8e.getHighWaterMark,lm=tg().codes,x8e=lm.ERR_INVALID_ARG_TYPE,E8e=lm.ERR_METHOD_NOT_IMPLEMENTED,S8e=lm.ERR_MULTIPLE_CALLBACK,A8e=lm.ERR_STREAM_CANNOT_PIPE,T8e=lm.ERR_STREAM_DESTROYED,P8e=lm.ERR_STREAM_NULL_VALUES,I8e=lm.ERR_STREAM_WRITE_AFTER_END,k8e=lm.ERR_UNKNOWN_ENCODING,kw=R7.errorOrDestroy;Ft()(gi,tY);function R8e(){}function qx(t,e,r){Iw=Iw||fm(),t=t||{},typeof r!="boolean"&&(r=e instanceof Iw),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=_8e(this,t,"writableHighWaterMark",r),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var n=t.decodeStrings===!1;this.decodeStrings=!n,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(i){j8e(e,i)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=t.emitClose!==!1,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new eY(this)}qx.prototype.getBuffer=function(){for(var e=this.bufferedRequest,r=[];e;)r.push(e),e=e.next;return r};(function(){try{Object.defineProperty(qx.prototype,"buffer",{get:y8e.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var V8;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(V8=Function.prototype[Symbol.hasInstance],Object.defineProperty(gi,Symbol.hasInstance,{value:function(e){return V8.call(this,e)?!0:this!==gi?!1:e&&e._writableState instanceof qx}})):V8=function(e){return e instanceof this};function gi(t){Iw=Iw||fm();var e=this instanceof Iw;if(!e&&!V8.call(gi,this))return new gi(t);this._writableState=new qx(t,this,e),this.writable=!0,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)),tY.call(this)}gi.prototype.pipe=function(){kw(this,new A8e)};function D8e(t,e){var r=new I8e;kw(t,r),k.default.nextTick(e,r)}function B8e(t,e,r,n){var i;return r===null?i=new P8e:typeof r!="string"&&!e.objectMode&&(i=new x8e("chunk",["string","Buffer"],r)),i?(kw(t,i),k.default.nextTick(n,i),!1):!0}gi.prototype.write=function(t,e,r){var n=this._writableState,i=!1,o=!n.objectMode&&b8e(t);return o&&!G8.isBuffer(t)&&(t=v8e(t)),typeof e=="function"&&(r=e,e=null),o?e="buffer":e||(e=n.defaultEncoding),typeof r!="function"&&(r=R8e),n.ending?D8e(this,r):(o||B8e(this,n,t,r))&&(n.pendingcb++,i=O8e(this,n,o,t,e,r)),i};gi.prototype.cork=function(){this._writableState.corked++};gi.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,!t.writing&&!t.corked&&!t.bufferProcessing&&t.bufferedRequest&&rY(this,t))};gi.prototype.setDefaultEncoding=function(e){if(typeof e=="string"&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new k8e(e);return this._writableState.defaultEncoding=e,this};Object.defineProperty(gi.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function M8e(t,e,r){return!t.objectMode&&t.decodeStrings!==!1&&typeof e=="string"&&(e=G8.from(e,r)),e}Object.defineProperty(gi.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function O8e(t,e,r,n,i,o){if(!r){var s=M8e(e,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=e.objectMode?1:n.length;e.length+=a;var d=e.length{"use strict";f();var F8e=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};sY.exports=Ml;var oY=X8(),B7=J8();Ft()(Ml,oY);for(D7=F8e(B7.prototype),Z8=0;Z8{"use strict";f();var O7=cr().Buffer,aY=O7.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 H8e(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 V8e(t){var e=H8e(t);if(typeof e!="string"&&(O7.isEncoding===aY||!aY(t)))throw new Error("Unknown encoding: "+t);return e||t}cY.StringDecoder=Lx;function Lx(t){this.encoding=V8e(t);var e;switch(this.encoding){case"utf16le":this.text=Q8e,this.end=e4e,e=4;break;case"utf8":this.fillLast=Z8e,e=4;break;case"base64":this.text=t4e,this.end=r4e,e=3;break;default:this.write=n4e,this.end=i4e;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=O7.allocUnsafe(e)}Lx.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>5===6?2:t>>4===14?3:t>>3===30?4:t>>6===2?-1:-2}function G8e(t,e,r){var n=e.length-1;if(n=0?(i>0&&(t.lastNeed=i-1),i):--n=0?(i>0&&(t.lastNeed=i-2),i):--n=0?(i>0&&(i===2?i=0:t.lastNeed=i-3),i):0))}function J8e(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 Z8e(t){var e=this.lastTotal-this.lastNeed,r=J8e(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 Y8e(t,e){var r=G8e(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 X8e(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"\uFFFD":e}function Q8e(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 e4e(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 t4e(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 r4e(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function n4e(t){return t.toString(this.encoding)}function i4e(t){return t&&t.length?this.write(t):""}});var Kx=V((Kyt,lY)=>{"use strict";f();var dY=tg().codes.ERR_STREAM_PREMATURE_CLOSE;function o4e(t){var e=!1;return function(){if(!e){e=!0;for(var r=arguments.length,n=new Array(r),i=0;i{"use strict";f();var Q8;function hm(t,e,r){return e=c4e(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function c4e(t){var e=d4e(t,"string");return typeof e=="symbol"?e:String(e)}function d4e(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var u4e=Kx(),pm=Symbol("lastResolve"),rg=Symbol("lastReject"),Fx=Symbol("error"),e4=Symbol("ended"),ng=Symbol("lastPromise"),C7=Symbol("handlePromise"),ig=Symbol("stream");function mm(t,e){return{value:t,done:e}}function l4e(t){var e=t[pm];if(e!==null){var r=t[ig].read();r!==null&&(t[ng]=null,t[pm]=null,t[rg]=null,e(mm(r,!1)))}}function f4e(t){k.default.nextTick(l4e,t)}function h4e(t,e){return function(r,n){t.then(function(){if(e[e4]){r(mm(void 0,!0));return}e[C7](r,n)},n)}}var p4e=Object.getPrototypeOf(function(){}),m4e=Object.setPrototypeOf((Q8={get stream(){return this[ig]},next:function(){var e=this,r=this[Fx];if(r!==null)return Promise.reject(r);if(this[e4])return Promise.resolve(mm(void 0,!0));if(this[ig].destroyed)return new Promise(function(s,a){k.default.nextTick(function(){e[Fx]?a(e[Fx]):s(mm(void 0,!0))})});var n=this[ng],i;if(n)i=new Promise(h4e(n,this));else{var o=this[ig].read();if(o!==null)return Promise.resolve(mm(o,!1));i=new Promise(this[C7])}return this[ng]=i,i}},hm(Q8,Symbol.asyncIterator,function(){return this}),hm(Q8,"return",function(){var e=this;return new Promise(function(r,n){e[ig].destroy(null,function(i){if(i){n(i);return}r(mm(void 0,!0))})})}),Q8),p4e),y4e=function(e){var r,n=Object.create(m4e,(r={},hm(r,ig,{value:e,writable:!0}),hm(r,pm,{value:null,writable:!0}),hm(r,rg,{value:null,writable:!0}),hm(r,Fx,{value:null,writable:!0}),hm(r,e4,{value:e._readableState.endEmitted,writable:!0}),hm(r,C7,{value:function(o,s){var a=n[ig].read();a?(n[ng]=null,n[pm]=null,n[rg]=null,o(mm(a,!1))):(n[pm]=o,n[rg]=s)},writable:!0}),r));return n[ng]=null,u4e(e,function(i){if(i&&i.code!=="ERR_STREAM_PREMATURE_CLOSE"){var o=n[rg];o!==null&&(n[ng]=null,n[pm]=null,n[rg]=null,o(i)),n[Fx]=i;return}var s=n[pm];s!==null&&(n[ng]=null,n[pm]=null,n[rg]=null,s(mm(void 0,!0))),n[e4]=!0}),e.on("readable",f4e.bind(null,n)),n};fY.exports=y4e});var mY=V((Hyt,pY)=>{f();pY.exports=function(){throw new Error("Readable.from is not available in the browser")}});var X8=V((Jyt,AY)=>{"use strict";f();AY.exports=zr;var Dw;zr.ReadableState=bY;var Gyt=Sa().EventEmitter,vY=function(e,r){return e.listeners(r).length},Wx=x7(),t4=hn().Buffer,g4e=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function v4e(t){return t4.from(t)}function b4e(t){return t4.isBuffer(t)||t instanceof g4e}var $7=Nx(),Er;$7&&$7.debuglog?Er=$7.debuglog("stream"):Er=function(){};var w4e=WZ(),F7=A7(),_4e=T7(),x4e=_4e.getHighWaterMark,r4=tg().codes,E4e=r4.ERR_INVALID_ARG_TYPE,S4e=r4.ERR_STREAM_PUSH_AFTER_EOF,A4e=r4.ERR_METHOD_NOT_IMPLEMENTED,T4e=r4.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,Bw,j7,N7;Ft()(zr,Wx);var zx=F7.errorOrDestroy,U7=["error","close","destroy","pause","resume"];function P4e(t,e,r){if(typeof t.prependListener=="function")return t.prependListener(e,r);!t._events||!t._events[e]?t.on(e,r):Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]}function bY(t,e,r){Dw=Dw||fm(),t=t||{},typeof r!="boolean"&&(r=e instanceof Dw),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=x4e(this,t,"readableHighWaterMark",r),this.buffer=new w4e,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=t.emitClose!==!1,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(Bw||(Bw=Rw().StringDecoder),this.decoder=new Bw(t.encoding),this.encoding=t.encoding)}function zr(t){if(Dw=Dw||fm(),!(this instanceof zr))return new zr(t);var e=this instanceof Dw;this._readableState=new bY(t,this,e),this.readable=!0,t&&(typeof t.read=="function"&&(this._read=t.read),typeof t.destroy=="function"&&(this._destroy=t.destroy)),Wx.call(this)}Object.defineProperty(zr.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}});zr.prototype.destroy=F7.destroy;zr.prototype._undestroy=F7.undestroy;zr.prototype._destroy=function(t,e){e(t)};zr.prototype.push=function(t,e){var r=this._readableState,n;return r.objectMode?n=!0:typeof t=="string"&&(e=e||r.defaultEncoding,e!==r.encoding&&(t=t4.from(t,e),e=""),n=!0),wY(this,t,e,!1,n)};zr.prototype.unshift=function(t){return wY(this,t,null,!0,!1)};function wY(t,e,r,n,i){Er("readableAddChunk",e);var o=t._readableState;if(e===null)o.reading=!1,R4e(t,o);else{var s;if(i||(s=I4e(o,e)),s)zx(t,s);else if(o.objectMode||e&&e.length>0)if(typeof e!="string"&&!o.objectMode&&Object.getPrototypeOf(e)!==t4.prototype&&(e=v4e(e)),n)o.endEmitted?zx(t,new T4e):q7(t,o,e,!0);else if(o.ended)zx(t,new S4e);else{if(o.destroyed)return!1;o.reading=!1,o.decoder&&!r?(e=o.decoder.write(e),o.objectMode||e.length!==0?q7(t,o,e,!1):K7(t,o)):q7(t,o,e,!1)}else n||(o.reading=!1,K7(t,o))}return!o.ended&&(o.length=yY?t=yY:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}function gY(t,e){return t<=0||e.length===0&&e.ended?0:e.objectMode?1:t!==t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=k4e(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}zr.prototype.read=function(t){Er("read",t),t=parseInt(t,10);var e=this._readableState,r=t;if(t!==0&&(e.emittedReadable=!1),t===0&&e.needReadable&&((e.highWaterMark!==0?e.length>=e.highWaterMark:e.length>0)||e.ended))return Er("read: emitReadable",e.length,e.ended),e.length===0&&e.ended?L7(this):n4(this),null;if(t=gY(t,e),t===0&&e.ended)return e.length===0&&L7(this),null;var n=e.needReadable;Er("need readable",n),(e.length===0||e.length-t0?i=EY(t,e):i=null,i===null?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),e.length===0&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&L7(this)),i!==null&&this.emit("data",i),i};function R4e(t,e){if(Er("onEofChunk"),!e.ended){if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.sync?n4(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,_Y(t)))}}function n4(t){var e=t._readableState;Er("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(Er("emitReadable",e.flowing),e.emittedReadable=!0,k.default.nextTick(_Y,t))}function _Y(t){var e=t._readableState;Er("emitReadable_",e.destroyed,e.length,e.ended),!e.destroyed&&(e.length||e.ended)&&(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,z7(t)}function K7(t,e){e.readingMore||(e.readingMore=!0,k.default.nextTick(D4e,t,e))}function D4e(t,e){for(;!e.reading&&!e.ended&&(e.length1&&SY(n.pipes,t)!==-1)&&!u&&(Er("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause())}function p(x){Er("onerror",x),v(),t.removeListener("error",p),vY(t,"error")===0&&zx(t,x)}P4e(t,"error",p);function m(){t.removeListener("finish",g),v()}t.once("close",m);function g(){Er("onfinish"),t.removeListener("close",m),v()}t.once("finish",g);function v(){Er("unpipe"),r.unpipe(t)}return t.emit("pipe",r),n.flowing||(Er("pipe resume"),r.resume()),t};function B4e(t){return function(){var r=t._readableState;Er("pipeOnDrain",r.awaitDrain),r.awaitDrain&&r.awaitDrain--,r.awaitDrain===0&&vY(t,"data")&&(r.flowing=!0,z7(t))}}zr.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(e.pipesCount===0)return this;if(e.pipesCount===1)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r),this);if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o0,n.flowing!==!1&&this.resume()):t==="readable"&&!n.endEmitted&&!n.readableListening&&(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,Er("on readable",n.length,n.reading),n.length?n4(this):n.reading||k.default.nextTick(M4e,this)),r};zr.prototype.addListener=zr.prototype.on;zr.prototype.removeListener=function(t,e){var r=Wx.prototype.removeListener.call(this,t,e);return t==="readable"&&k.default.nextTick(xY,this),r};zr.prototype.removeAllListeners=function(t){var e=Wx.prototype.removeAllListeners.apply(this,arguments);return(t==="readable"||t===void 0)&&k.default.nextTick(xY,this),e};function xY(t){var e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function M4e(t){Er("readable nexttick read 0"),t.read(0)}zr.prototype.resume=function(){var t=this._readableState;return t.flowing||(Er("resume"),t.flowing=!t.readableListening,O4e(this,t)),t.paused=!1,this};function O4e(t,e){e.resumeScheduled||(e.resumeScheduled=!0,k.default.nextTick(C4e,t,e))}function C4e(t,e){Er("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),z7(t),e.flowing&&!e.reading&&t.read(0)}zr.prototype.pause=function(){return Er("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(Er("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function z7(t){var e=t._readableState;for(Er("flow",e.flowing);e.flowing&&t.read()!==null;);}zr.prototype.wrap=function(t){var e=this,r=this._readableState,n=!1;t.on("end",function(){if(Er("wrapped end"),r.decoder&&!r.ended){var s=r.decoder.end();s&&s.length&&e.push(s)}e.push(null)}),t.on("data",function(s){if(Er("wrapped data"),r.decoder&&(s=r.decoder.write(s)),!(r.objectMode&&s==null)&&!(!r.objectMode&&(!s||!s.length))){var a=e.push(s);a||(n=!0,t.pause())}});for(var i in t)this[i]===void 0&&typeof t[i]=="function"&&(this[i]=function(a){return function(){return t[a].apply(t,arguments)}}(i));for(var o=0;o=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 L7(t){var e=t._readableState;Er("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,k.default.nextTick($4e,e,t))}function $4e(t,e){if(Er("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&t.length===0&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}typeof Symbol=="function"&&(zr.from=function(t,e){return N7===void 0&&(N7=mY()),N7(zr,t,e)});function SY(t,e){for(var r=0,n=t.length;r{"use strict";f();PY.exports=dh;var i4=tg().codes,j4e=i4.ERR_METHOD_NOT_IMPLEMENTED,N4e=i4.ERR_MULTIPLE_CALLBACK,U4e=i4.ERR_TRANSFORM_ALREADY_TRANSFORMING,q4e=i4.ERR_TRANSFORM_WITH_LENGTH_0,o4=fm();Ft()(dh,o4);function L4e(t,e){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(n===null)return this.emit("error",new N4e);r.writechunk=null,r.writecb=null,e!=null&&this.push(e),n(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length{"use strict";f();kY.exports=Hx;var IY=s4();Ft()(Hx,IY);function Hx(t){if(!(this instanceof Hx))return new Hx(t);IY.call(this,t)}Hx.prototype._transform=function(t,e,r){r(null,t)}});var V7=V((t0t,MY)=>{"use strict";f();var H7;function F4e(t){var e=!1;return function(){e||(e=!0,t.apply(void 0,arguments))}}var BY=tg().codes,z4e=BY.ERR_MISSING_ARGS,W4e=BY.ERR_STREAM_DESTROYED;function RY(t){if(t)throw t}function H4e(t){return t.setHeader&&typeof t.abort=="function"}function V4e(t,e,r,n){n=F4e(n);var i=!1;t.on("close",function(){i=!0}),H7===void 0&&(H7=Kx()),H7(t,{readable:e,writable:r},function(s){if(s)return n(s);i=!0,n()});var o=!1;return function(s){if(!i&&!o){if(o=!0,H4e(t))return t.abort();if(typeof t.destroy=="function")return t.destroy();n(s||new W4e("pipe"))}}}function DY(t){t()}function G4e(t,e){return t.pipe(e)}function J4e(t){return!t.length||typeof t[t.length-1]!="function"?RY:t.pop()}function Z4e(){for(var t=arguments.length,e=new Array(t),r=0;r0;return V4e(s,d,u,function(c){i||(i=c),c&&o.forEach(DY),!d&&(o.forEach(DY),n(i))})});return e.reduce(G4e)}MY.exports=Z4e});var G7=V((xd,OY)=>{f();xd=OY.exports=X8();xd.Stream=xd;xd.Readable=xd;xd.Writable=J8();xd.Duplex=fm();xd.Transform=s4();xd.PassThrough=W7();xd.finished=Kx();xd.pipeline=V7()});var J7=V((i0t,$Y)=>{"use strict";f();var a4=cr().Buffer,CY=G7().Transform,Y4e=Ft();function X4e(t,e){if(!a4.isBuffer(t)&&typeof t!="string")throw new TypeError(e+" must be a string or a buffer")}function ym(t){CY.call(this),this._block=a4.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}Y4e(ym,CY);ym.prototype._transform=function(t,e,r){var n=null;try{this.update(t,e)}catch(i){n=i}r(n)};ym.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(r){e=r}t(e)};ym.prototype.update=function(t,e){if(X4e(t,"Data"),this._finalized)throw new Error("Digest already called");a4.isBuffer(t)||(t=a4.from(t,e));for(var r=this._block,n=0;this._blockOffset+t.length-n>=this._blockSize;){for(var i=this._blockOffset;i0;++o)this._length[o]+=s,s=this._length[o]/4294967296|0,s>0&&(this._length[o]-=4294967296*s);return this};ym.prototype._update=function(){throw new Error("_update is not implemented")};ym.prototype.digest=function(t){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var e=this._digest();t!==void 0&&(e=e.toString(t)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return e};ym.prototype._digest=function(){throw new Error("_digest is not implemented")};$Y.exports=ym});var u4=V((s0t,NY)=>{"use strict";f();var Q4e=Ft(),jY=J7(),eAe=cr().Buffer,tAe=new Array(16);function c4(){jY.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}Q4e(c4,jY);c4.prototype._update=function(){for(var t=tAe,e=0;e<16;++e)t[e]=this._block.readInt32LE(e*4);var r=this._a,n=this._b,i=this._c,o=this._d;r=Ws(r,n,i,o,t[0],3614090360,7),o=Ws(o,r,n,i,t[1],3905402710,12),i=Ws(i,o,r,n,t[2],606105819,17),n=Ws(n,i,o,r,t[3],3250441966,22),r=Ws(r,n,i,o,t[4],4118548399,7),o=Ws(o,r,n,i,t[5],1200080426,12),i=Ws(i,o,r,n,t[6],2821735955,17),n=Ws(n,i,o,r,t[7],4249261313,22),r=Ws(r,n,i,o,t[8],1770035416,7),o=Ws(o,r,n,i,t[9],2336552879,12),i=Ws(i,o,r,n,t[10],4294925233,17),n=Ws(n,i,o,r,t[11],2304563134,22),r=Ws(r,n,i,o,t[12],1804603682,7),o=Ws(o,r,n,i,t[13],4254626195,12),i=Ws(i,o,r,n,t[14],2792965006,17),n=Ws(n,i,o,r,t[15],1236535329,22),r=Hs(r,n,i,o,t[1],4129170786,5),o=Hs(o,r,n,i,t[6],3225465664,9),i=Hs(i,o,r,n,t[11],643717713,14),n=Hs(n,i,o,r,t[0],3921069994,20),r=Hs(r,n,i,o,t[5],3593408605,5),o=Hs(o,r,n,i,t[10],38016083,9),i=Hs(i,o,r,n,t[15],3634488961,14),n=Hs(n,i,o,r,t[4],3889429448,20),r=Hs(r,n,i,o,t[9],568446438,5),o=Hs(o,r,n,i,t[14],3275163606,9),i=Hs(i,o,r,n,t[3],4107603335,14),n=Hs(n,i,o,r,t[8],1163531501,20),r=Hs(r,n,i,o,t[13],2850285829,5),o=Hs(o,r,n,i,t[2],4243563512,9),i=Hs(i,o,r,n,t[7],1735328473,14),n=Hs(n,i,o,r,t[12],2368359562,20),r=Vs(r,n,i,o,t[5],4294588738,4),o=Vs(o,r,n,i,t[8],2272392833,11),i=Vs(i,o,r,n,t[11],1839030562,16),n=Vs(n,i,o,r,t[14],4259657740,23),r=Vs(r,n,i,o,t[1],2763975236,4),o=Vs(o,r,n,i,t[4],1272893353,11),i=Vs(i,o,r,n,t[7],4139469664,16),n=Vs(n,i,o,r,t[10],3200236656,23),r=Vs(r,n,i,o,t[13],681279174,4),o=Vs(o,r,n,i,t[0],3936430074,11),i=Vs(i,o,r,n,t[3],3572445317,16),n=Vs(n,i,o,r,t[6],76029189,23),r=Vs(r,n,i,o,t[9],3654602809,4),o=Vs(o,r,n,i,t[12],3873151461,11),i=Vs(i,o,r,n,t[15],530742520,16),n=Vs(n,i,o,r,t[2],3299628645,23),r=Gs(r,n,i,o,t[0],4096336452,6),o=Gs(o,r,n,i,t[7],1126891415,10),i=Gs(i,o,r,n,t[14],2878612391,15),n=Gs(n,i,o,r,t[5],4237533241,21),r=Gs(r,n,i,o,t[12],1700485571,6),o=Gs(o,r,n,i,t[3],2399980690,10),i=Gs(i,o,r,n,t[10],4293915773,15),n=Gs(n,i,o,r,t[1],2240044497,21),r=Gs(r,n,i,o,t[8],1873313359,6),o=Gs(o,r,n,i,t[15],4264355552,10),i=Gs(i,o,r,n,t[6],2734768916,15),n=Gs(n,i,o,r,t[13],1309151649,21),r=Gs(r,n,i,o,t[4],4149444226,6),o=Gs(o,r,n,i,t[11],3174756917,10),i=Gs(i,o,r,n,t[2],718787259,15),n=Gs(n,i,o,r,t[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+o|0};c4.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=eAe.allocUnsafe(16);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t};function d4(t,e){return t<>>32-e}function Ws(t,e,r,n,i,o,s){return d4(t+(e&r|~e&n)+i+o|0,s)+e|0}function Hs(t,e,r,n,i,o,s){return d4(t+(e&n|r&~n)+i+o|0,s)+e|0}function Vs(t,e,r,n,i,o,s){return d4(t+(e^r^n)+i+o|0,s)+e|0}function Gs(t,e,r,n,i,o,s){return d4(t+(r^(e|~n))+i+o|0,s)+e|0}NY.exports=c4});var f4=V((c0t,WY)=>{"use strict";f();var Z7=hn().Buffer,rAe=Ft(),zY=J7(),nAe=new Array(16),Vx=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],Gx=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],Jx=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],Zx=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],Yx=[0,1518500249,1859775393,2400959708,2840853838],Xx=[1352829926,1548603684,1836072691,2053994217,0];function l4(){zY.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}rAe(l4,zY);l4.prototype._update=function(){for(var t=nAe,e=0;e<16;++e)t[e]=this._block.readInt32LE(e*4);for(var r=this._a|0,n=this._b|0,i=this._c|0,o=this._d|0,s=this._e|0,a=this._a|0,d=this._b|0,u=this._c|0,c=this._d|0,l=this._e|0,p=0;p<80;p+=1){var m,g;p<16?(m=UY(r,n,i,o,s,t[Vx[p]],Yx[0],Jx[p]),g=FY(a,d,u,c,l,t[Gx[p]],Xx[0],Zx[p])):p<32?(m=qY(r,n,i,o,s,t[Vx[p]],Yx[1],Jx[p]),g=KY(a,d,u,c,l,t[Gx[p]],Xx[1],Zx[p])):p<48?(m=LY(r,n,i,o,s,t[Vx[p]],Yx[2],Jx[p]),g=LY(a,d,u,c,l,t[Gx[p]],Xx[2],Zx[p])):p<64?(m=KY(r,n,i,o,s,t[Vx[p]],Yx[3],Jx[p]),g=qY(a,d,u,c,l,t[Gx[p]],Xx[3],Zx[p])):(m=FY(r,n,i,o,s,t[Vx[p]],Yx[4],Jx[p]),g=UY(a,d,u,c,l,t[Gx[p]],Xx[4],Zx[p])),r=s,s=o,o=og(i,10),i=n,n=m,a=l,l=c,c=og(u,10),u=d,d=g}var v=this._b+i+c|0;this._b=this._c+o+l|0,this._c=this._d+s+a|0,this._d=this._e+r+d|0,this._e=this._a+n+u|0,this._a=v};l4.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=Z7.alloc?Z7.alloc(20):new Z7(20);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t.writeInt32LE(this._e,16),t};function og(t,e){return t<>>32-e}function UY(t,e,r,n,i,o,s,a){return og(t+(e^r^n)+o+s|0,a)+i|0}function qY(t,e,r,n,i,o,s,a){return og(t+(e&r|~e&n)+o+s|0,a)+i|0}function LY(t,e,r,n,i,o,s,a){return og(t+((e|~r)^n)+o+s|0,a)+i|0}function KY(t,e,r,n,i,o,s,a){return og(t+(e&n|r&~n)+o+s|0,a)+i|0}function FY(t,e,r,n,i,o,s,a){return og(t+(e^(r|~n))+o+s|0,a)+i|0}WY.exports=l4});var sg=V((u0t,VY)=>{f();var HY=cr().Buffer;function h4(t,e){this._block=HY.alloc(t),this._finalSize=e,this._blockSize=t,this._len=0}h4.prototype.update=function(t,e){typeof t=="string"&&(e=e||"utf8",t=HY.from(t,e));for(var r=this._block,n=this._blockSize,i=t.length,o=this._len,s=0;s=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=this._len*8;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(r&4294967295)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return t?o.toString(t):o};h4.prototype._update=function(){throw new Error("_update must be implemented by subclass")};VY.exports=h4});var ZY=V((f0t,JY)=>{f();var iAe=Ft(),GY=sg(),oAe=cr().Buffer,sAe=[1518500249,1859775393,-1894007588,-899497514],aAe=new Array(80);function Qx(){this.init(),this._w=aAe,GY.call(this,64,56)}iAe(Qx,GY);Qx.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function cAe(t){return t<<5|t>>>27}function dAe(t){return t<<30|t>>>2}function uAe(t,e,r,n){return t===0?e&r|~e&n:t===2?e&r|e&n|r&n:e^r^n}Qx.prototype._update=function(t){for(var e=this._w,r=this._a|0,n=this._b|0,i=this._c|0,o=this._d|0,s=this._e|0,a=0;a<16;++a)e[a]=t.readInt32BE(a*4);for(;a<80;++a)e[a]=e[a-3]^e[a-8]^e[a-14]^e[a-16];for(var d=0;d<80;++d){var u=~~(d/20),c=cAe(r)+uAe(u,n,i,o)+s+e[d]+sAe[u]|0;s=o,o=i,i=dAe(n),n=r,r=c}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=o+this._d|0,this._e=s+this._e|0};Qx.prototype._hash=function(){var t=oAe.allocUnsafe(20);return t.writeInt32BE(this._a|0,0),t.writeInt32BE(this._b|0,4),t.writeInt32BE(this._c|0,8),t.writeInt32BE(this._d|0,12),t.writeInt32BE(this._e|0,16),t};JY.exports=Qx});var QY=V((p0t,XY)=>{f();var lAe=Ft(),YY=sg(),fAe=cr().Buffer,hAe=[1518500249,1859775393,-1894007588,-899497514],pAe=new Array(80);function eE(){this.init(),this._w=pAe,YY.call(this,64,56)}lAe(eE,YY);eE.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function mAe(t){return t<<1|t>>>31}function yAe(t){return t<<5|t>>>27}function gAe(t){return t<<30|t>>>2}function vAe(t,e,r,n){return t===0?e&r|~e&n:t===2?e&r|e&n|r&n:e^r^n}eE.prototype._update=function(t){for(var e=this._w,r=this._a|0,n=this._b|0,i=this._c|0,o=this._d|0,s=this._e|0,a=0;a<16;++a)e[a]=t.readInt32BE(a*4);for(;a<80;++a)e[a]=mAe(e[a-3]^e[a-8]^e[a-14]^e[a-16]);for(var d=0;d<80;++d){var u=~~(d/20),c=yAe(r)+vAe(u,n,i,o)+s+e[d]+hAe[u]|0;s=o,o=i,i=gAe(n),n=r,r=c}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=o+this._d|0,this._e=s+this._e|0};eE.prototype._hash=function(){var t=fAe.allocUnsafe(20);return t.writeInt32BE(this._a|0,0),t.writeInt32BE(this._b|0,4),t.writeInt32BE(this._c|0,8),t.writeInt32BE(this._d|0,12),t.writeInt32BE(this._e|0,16),t};XY.exports=eE});var Y7=V((y0t,tX)=>{f();var bAe=Ft(),eX=sg(),wAe=cr().Buffer,_Ae=[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],xAe=new Array(64);function tE(){this.init(),this._w=xAe,eX.call(this,64,56)}bAe(tE,eX);tE.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this};function EAe(t,e,r){return r^t&(e^r)}function SAe(t,e,r){return t&e|r&(t|e)}function AAe(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function TAe(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function PAe(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}function IAe(t){return(t>>>17|t<<15)^(t>>>19|t<<13)^t>>>10}tE.prototype._update=function(t){for(var e=this._w,r=this._a|0,n=this._b|0,i=this._c|0,o=this._d|0,s=this._e|0,a=this._f|0,d=this._g|0,u=this._h|0,c=0;c<16;++c)e[c]=t.readInt32BE(c*4);for(;c<64;++c)e[c]=IAe(e[c-2])+e[c-7]+PAe(e[c-15])+e[c-16]|0;for(var l=0;l<64;++l){var p=u+TAe(s)+EAe(s,a,d)+_Ae[l]+e[l]|0,m=AAe(r)+SAe(r,n,i)|0;u=d,d=a,a=s,s=o+p|0,o=i,i=n,n=r,r=p+m|0}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=o+this._d|0,this._e=s+this._e|0,this._f=a+this._f|0,this._g=d+this._g|0,this._h=u+this._h|0};tE.prototype._hash=function(){var t=wAe.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t};tX.exports=tE});var nX=V((v0t,rX)=>{f();var kAe=Ft(),RAe=Y7(),DAe=sg(),BAe=cr().Buffer,MAe=new Array(64);function p4(){this.init(),this._w=MAe,DAe.call(this,64,56)}kAe(p4,RAe);p4.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this};p4.prototype._hash=function(){var t=BAe.allocUnsafe(28);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t};rX.exports=p4});var X7=V((w0t,uX)=>{f();var OAe=Ft(),dX=sg(),CAe=cr().Buffer,iX=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],$Ae=new Array(160);function rE(){this.init(),this._w=$Ae,dX.call(this,128,112)}OAe(rE,dX);rE.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this};function oX(t,e,r){return r^t&(e^r)}function sX(t,e,r){return t&e|r&(t|e)}function aX(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function cX(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function jAe(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function NAe(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function UAe(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function qAe(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function Bo(t,e){return t>>>0>>0?1:0}rE.prototype._update=function(t){for(var e=this._w,r=this._ah|0,n=this._bh|0,i=this._ch|0,o=this._dh|0,s=this._eh|0,a=this._fh|0,d=this._gh|0,u=this._hh|0,c=this._al|0,l=this._bl|0,p=this._cl|0,m=this._dl|0,g=this._el|0,v=this._fl|0,x=this._gl|0,S=this._hl|0,P=0;P<32;P+=2)e[P]=t.readInt32BE(P*4),e[P+1]=t.readInt32BE(P*4+4);for(;P<160;P+=2){var A=e[P-30],$=e[P-15*2+1],j=jAe(A,$),L=NAe($,A);A=e[P-2*2],$=e[P-2*2+1];var F=UAe(A,$),K=qAe($,A),W=e[P-7*2],q=e[P-7*2+1],I=e[P-16*2],T=e[P-16*2+1],B=L+q|0,h=j+W+Bo(B,L)|0;B=B+K|0,h=h+F+Bo(B,K)|0,B=B+T|0,h=h+I+Bo(B,T)|0,e[P]=h,e[P+1]=B}for(var y=0;y<160;y+=2){h=e[y],B=e[y+1];var w=sX(r,n,i),E=sX(c,l,p),_=aX(r,c),b=aX(c,r),C=cX(s,g),N=cX(g,s),M=iX[y],U=iX[y+1],G=oX(s,a,d),Z=oX(g,v,x),J=S+N|0,H=u+C+Bo(J,S)|0;J=J+Z|0,H=H+G+Bo(J,Z)|0,J=J+U|0,H=H+M+Bo(J,U)|0,J=J+B|0,H=H+h+Bo(J,B)|0;var X=b+E|0,te=_+w+Bo(X,b)|0;u=d,S=x,d=a,x=v,a=s,v=g,g=m+J|0,s=o+H+Bo(g,m)|0,o=i,m=p,i=n,p=l,n=r,l=c,c=J+X|0,r=H+te+Bo(c,J)|0}this._al=this._al+c|0,this._bl=this._bl+l|0,this._cl=this._cl+p|0,this._dl=this._dl+m|0,this._el=this._el+g|0,this._fl=this._fl+v|0,this._gl=this._gl+x|0,this._hl=this._hl+S|0,this._ah=this._ah+r+Bo(this._al,c)|0,this._bh=this._bh+n+Bo(this._bl,l)|0,this._ch=this._ch+i+Bo(this._cl,p)|0,this._dh=this._dh+o+Bo(this._dl,m)|0,this._eh=this._eh+s+Bo(this._el,g)|0,this._fh=this._fh+a+Bo(this._fl,v)|0,this._gh=this._gh+d+Bo(this._gl,x)|0,this._hh=this._hh+u+Bo(this._hl,S)|0};rE.prototype._hash=function(){var t=CAe.allocUnsafe(64);function e(r,n,i){t.writeInt32BE(r,i),t.writeInt32BE(n,i+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),t};uX.exports=rE});var fX=V((x0t,lX)=>{f();var LAe=Ft(),KAe=X7(),FAe=sg(),zAe=cr().Buffer,WAe=new Array(160);function m4(){this.init(),this._w=WAe,FAe.call(this,128,112)}LAe(m4,KAe);m4.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this};m4.prototype._hash=function(){var t=zAe.allocUnsafe(48);function e(r,n,i){t.writeInt32BE(r,i),t.writeInt32BE(n,i+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),t};lX.exports=m4});var y4=V((uh,hX)=>{f();var uh=hX.exports=function(e){e=e.toLowerCase();var r=uh[e];if(!r)throw new Error(e+" is not supported (we accept pull requests)");return new r};uh.sha=ZY();uh.sha1=QY();uh.sha224=nX();uh.sha256=Y7();uh.sha384=fX();uh.sha512=X7()});var mX=V((A0t,pX)=>{f();pX.exports=Ed;var Q7=Sa().EventEmitter,HAe=Ft();HAe(Ed,Q7);Ed.Readable=X8();Ed.Writable=J8();Ed.Duplex=fm();Ed.Transform=s4();Ed.PassThrough=W7();Ed.finished=Kx();Ed.pipeline=V7();Ed.Stream=Ed;function Ed(){Q7.call(this)}Ed.prototype.pipe=function(t,e){var r=this;function n(c){t.writable&&t.write(c)===!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));var o=!1;function s(){o||(o=!0,t.end())}function a(){o||(o=!0,typeof t.destroy=="function"&&t.destroy())}function d(c){if(u(),Q7.listenerCount(this,"error")===0)throw c}r.on("error",d),t.on("error",d);function u(){r.removeListener("data",n),t.removeListener("drain",i),r.removeListener("end",s),r.removeListener("close",a),r.removeListener("error",d),t.removeListener("error",d),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}});var lh=V((P0t,vX)=>{f();var yX=cr().Buffer,gX=mX().Transform,VAe=Rw().StringDecoder,GAe=Ft();function Eu(t){gX.call(this),this.hashMode=typeof t=="string",this.hashMode?this[t]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}GAe(Eu,gX);Eu.prototype.update=function(t,e,r){typeof t=="string"&&(t=yX.from(t,e));var n=this._update(t);return this.hashMode?this:(r&&(n=this._toString(n,r)),n)};Eu.prototype.setAutoPadding=function(){};Eu.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")};Eu.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")};Eu.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")};Eu.prototype._transform=function(t,e,r){var n;try{this.hashMode?this._update(t):this.push(this._update(t))}catch(i){n=i}finally{r(n)}};Eu.prototype._flush=function(t){var e;try{this.push(this.__final())}catch(r){e=r}t(e)};Eu.prototype._finalOrDigest=function(t){var e=this.__final()||yX.alloc(0);return t&&(e=this._toString(e,t,!0)),e};Eu.prototype._toString=function(t,e,r){if(this._decoder||(this._decoder=new VAe(e),this._encoding=e),this._encoding!==e)throw new Error("can't switch encodings");var n=this._decoder.write(t);return r&&(n+=this._decoder.end()),n};vX.exports=Eu});var Mw=V((k0t,wX)=>{"use strict";f();var JAe=Ft(),ZAe=u4(),YAe=f4(),XAe=y4(),bX=lh();function g4(t){bX.call(this,"digest"),this._hash=t}JAe(g4,bX);g4.prototype._update=function(t){this._hash.update(t)};g4.prototype._final=function(){return this._hash.digest()};wX.exports=function(e){return e=e.toLowerCase(),e==="md5"?new ZAe:e==="rmd160"||e==="ripemd160"?new YAe:new g4(XAe(e))}});var EX=V((D0t,xX)=>{"use strict";f();var QAe=Ft(),ag=cr().Buffer,_X=lh(),eTe=ag.alloc(128),Ow=64;function v4(t,e){_X.call(this,"digest"),typeof e=="string"&&(e=ag.from(e)),this._alg=t,this._key=e,e.length>Ow?e=t(e):e.length{f();var tTe=u4();SX.exports=function(t){return new tTe().update(t).digest()}});var nM=V((C0t,TX)=>{"use strict";f();var rTe=Ft(),nTe=EX(),AX=lh(),nE=cr().Buffer,iTe=eM(),tM=f4(),rM=y4(),oTe=nE.alloc(128);function iE(t,e){AX.call(this,"digest"),typeof e=="string"&&(e=nE.from(e));var r=t==="sha512"||t==="sha384"?128:64;if(this._alg=t,this._key=e,e.length>r){var n=t==="rmd160"?new tM:rM(t);e=n.update(e).digest()}else e.length{sTe.exports={sha224WithRSAEncryption:{sign:"rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},"RSA-SHA224":{sign:"ecdsa/rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},sha256WithRSAEncryption:{sign:"rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},"RSA-SHA256":{sign:"ecdsa/rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},sha384WithRSAEncryption:{sign:"rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},"RSA-SHA384":{sign:"ecdsa/rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},sha512WithRSAEncryption:{sign:"rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA512":{sign:"ecdsa/rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA1":{sign:"rsa",hash:"sha1",id:"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{sign:"ecdsa",hash:"sha1",id:""},sha256:{sign:"ecdsa",hash:"sha256",id:""},sha224:{sign:"ecdsa",hash:"sha224",id:""},sha384:{sign:"ecdsa",hash:"sha384",id:""},sha512:{sign:"ecdsa",hash:"sha512",id:""},"DSA-SHA":{sign:"dsa",hash:"sha1",id:""},"DSA-SHA1":{sign:"dsa",hash:"sha1",id:""},DSA:{sign:"dsa",hash:"sha1",id:""},"DSA-WITH-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-WITH-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-WITH-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-WITH-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-RIPEMD160":{sign:"dsa",hash:"rmd160",id:""},ripemd160WithRSA:{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},"RSA-RIPEMD160":{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},md5WithRSAEncryption:{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"},"RSA-MD5":{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"}}});var IX=V((N0t,PX)=>{"use strict";f();PX.exports=iM()});var oM=V((q0t,kX)=>{f();var aTe=Math.pow(2,30)-1;kX.exports=function(t,e){if(typeof t!="number")throw new TypeError("Iterations not a number");if(t<0)throw new TypeError("Bad iterations");if(typeof e!="number")throw new TypeError("Key length not a number");if(e<0||e>aTe||e!==e)throw new TypeError("Bad key length")}});var sM=V((K0t,DX)=>{f();var b4;globalThis.process&&globalThis.process.browser?b4="utf-8":globalThis.process&&globalThis.process.version?(RX=parseInt(k.default.version.split(".")[0].slice(1),10),b4=RX>=6?"utf-8":"binary"):b4="utf-8";var RX;DX.exports=b4});var cM=V((z0t,BX)=>{f();var aM=cr().Buffer;BX.exports=function(t,e,r){if(aM.isBuffer(t))return t;if(typeof t=="string")return aM.from(t,e);if(ArrayBuffer.isView(t))return aM.from(t.buffer);throw new TypeError(r+" must be a string, a Buffer, a typed array or a DataView")}});var dM=V((H0t,$X)=>{f();var cTe=eM(),dTe=f4(),uTe=y4(),cg=cr().Buffer,lTe=oM(),MX=sM(),OX=cM(),fTe=cg.alloc(128),w4={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function CX(t,e,r){var n=hTe(t),i=t==="sha512"||t==="sha384"?128:64;e.length>i?e=n(e):e.length{f();var qX=cr().Buffer,mTe=oM(),jX=sM(),NX=dM(),UX=cM(),_4,oE=globalThis.crypto&&globalThis.crypto.subtle,yTe={sha:"SHA-1","sha-1":"SHA-1",sha1:"SHA-1",sha256:"SHA-256","sha-256":"SHA-256",sha384:"SHA-384","sha-384":"SHA-384","sha-512":"SHA-512",sha512:"SHA-512"},uM=[];function gTe(t){if(globalThis.process&&!globalThis.process.browser||!oE||!oE.importKey||!oE.deriveBits)return Promise.resolve(!1);if(uM[t]!==void 0)return uM[t];_4=_4||qX.alloc(8);var e=LX(_4,_4,10,128,t).then(function(){return!0}).catch(function(){return!1});return uM[t]=e,e}var dg;function lM(){return dg||(globalThis.process&&globalThis.process.nextTick?dg=globalThis.process.nextTick:globalThis.queueMicrotask?dg=globalThis.queueMicrotask:globalThis.setImmediate?dg=globalThis.setImmediate:dg=globalThis.setTimeout,dg)}function LX(t,e,r,n,i){return oE.importKey("raw",t,{name:"PBKDF2"},!1,["deriveBits"]).then(function(o){return oE.deriveBits({name:"PBKDF2",salt:e,iterations:r,hash:{name:i}},o,n<<3)}).then(function(o){return qX.from(o)})}function vTe(t,e){t.then(function(r){lM()(function(){e(null,r)})},function(r){lM()(function(){e(r)})})}KX.exports=function(t,e,r,n,i,o){typeof i=="function"&&(o=i,i=void 0),i=i||"sha1";var s=yTe[i.toLowerCase()];if(!s||typeof globalThis.Promise!="function"){lM()(function(){var a;try{a=NX(t,e,r,n,i)}catch(d){return o(d)}o(null,a)});return}if(mTe(r,n),t=UX(t,jX,"Password"),e=UX(e,jX,"Salt"),typeof o!="function")throw new Error("No callback provided to pbkdf2");vTe(gTe(s).then(function(a){return a?LX(t,e,r,n,s):NX(t,e,r,n,i)}),o)}});var hM=V(fM=>{f();fM.pbkdf2=FX();fM.pbkdf2Sync=dM()});var pM=V(Sd=>{"use strict";f();Sd.readUInt32BE=function(e,r){var n=e[0+r]<<24|e[1+r]<<16|e[2+r]<<8|e[3+r];return n>>>0};Sd.writeUInt32BE=function(e,r,n){e[0+n]=r>>>24,e[1+n]=r>>>16&255,e[2+n]=r>>>8&255,e[3+n]=r&255};Sd.ip=function(e,r,n,i){for(var o=0,s=0,a=6;a>=0;a-=2){for(var d=0;d<=24;d+=8)o<<=1,o|=r>>>d+a&1;for(var d=0;d<=24;d+=8)o<<=1,o|=e>>>d+a&1}for(var a=6;a>=0;a-=2){for(var d=1;d<=25;d+=8)s<<=1,s|=r>>>d+a&1;for(var d=1;d<=25;d+=8)s<<=1,s|=e>>>d+a&1}n[i+0]=o>>>0,n[i+1]=s>>>0};Sd.rip=function(e,r,n,i){for(var o=0,s=0,a=0;a<4;a++)for(var d=24;d>=0;d-=8)o<<=1,o|=r>>>d+a&1,o<<=1,o|=e>>>d+a&1;for(var a=4;a<8;a++)for(var d=24;d>=0;d-=8)s<<=1,s|=r>>>d+a&1,s<<=1,s|=e>>>d+a&1;n[i+0]=o>>>0,n[i+1]=s>>>0};Sd.pc1=function(e,r,n,i){for(var o=0,s=0,a=7;a>=5;a--){for(var d=0;d<=24;d+=8)o<<=1,o|=r>>d+a&1;for(var d=0;d<=24;d+=8)o<<=1,o|=e>>d+a&1}for(var d=0;d<=24;d+=8)o<<=1,o|=r>>d+a&1;for(var a=1;a<=3;a++){for(var d=0;d<=24;d+=8)s<<=1,s|=r>>d+a&1;for(var d=0;d<=24;d+=8)s<<=1,s|=e>>d+a&1}for(var d=0;d<=24;d+=8)s<<=1,s|=e>>d+a&1;n[i+0]=o>>>0,n[i+1]=s>>>0};Sd.r28shl=function(e,r){return e<>>28-r};var x4=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];Sd.pc2=function(e,r,n,i){for(var o=0,s=0,a=x4.length>>>1,d=0;d>>x4[d]&1;for(var d=a;d>>x4[d]&1;n[i+0]=o>>>0,n[i+1]=s>>>0};Sd.expand=function(e,r,n){var i=0,o=0;i=(e&1)<<5|e>>>27;for(var s=23;s>=15;s-=4)i<<=6,i|=e>>>s&63;for(var s=11;s>=3;s-=4)o|=e>>>s&63,o<<=6;o|=(e&31)<<1|e>>>31,r[n+0]=i>>>0,r[n+1]=o>>>0};var zX=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];Sd.substitute=function(e,r){for(var n=0,i=0;i<4;i++){var o=e>>>18-i*6&63,s=zX[i*64+o];n<<=4,n|=s}for(var i=0;i<4;i++){var o=r>>>18-i*6&63,s=zX[4*64+i*64+o];n<<=4,n|=s}return n>>>0};var WX=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];Sd.permute=function(e){for(var r=0,n=0;n>>WX[n]&1;return r>>>0};Sd.padSplit=function(e,r,n){for(var i=e.toString(2);i.length{f();VX.exports=HX;function HX(t,e){if(!t)throw new Error(e||"Assertion failed")}HX.equal=function(e,r,n){if(e!=r)throw new Error(n||"Assertion failed: "+e+" != "+r)}});var E4=V((rgt,GX)=>{"use strict";f();var bTe=Cc();function Ad(t){this.options=t,this.type=this.options.type,this.blockSize=8,this._init(),this.buffer=new Array(this.blockSize),this.bufferOff=0,this.padding=t.padding!==!1}GX.exports=Ad;Ad.prototype._init=function(){};Ad.prototype.update=function(e){return e.length===0?[]:this.type==="decrypt"?this._updateDecrypt(e):this._updateEncrypt(e)};Ad.prototype._buffer=function(e,r){for(var n=Math.min(this.buffer.length-this.bufferOff,e.length-r),i=0;i0;i--)r+=this._buffer(e,r),n+=this._flushBuffer(o,n);return r+=this._buffer(e,r),o};Ad.prototype.final=function(e){var r;e&&(r=this.update(e));var n;return this.type==="encrypt"?n=this._finalEncrypt():n=this._finalDecrypt(),r?r.concat(n):n};Ad.prototype._pad=function(e,r){if(r===0)return!1;for(;r{"use strict";f();var JX=Cc(),wTe=Ft(),ro=pM(),ZX=E4();function _Te(){this.tmp=new Array(2),this.keys=null}function Ol(t){ZX.call(this,t);var e=new _Te;this._desState=e,this.deriveKeys(e,t.key)}wTe(Ol,ZX);YX.exports=Ol;Ol.create=function(e){return new Ol(e)};var xTe=[1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1];Ol.prototype.deriveKeys=function(e,r){e.keys=new Array(16*2),JX.equal(r.length,this.blockSize,"Invalid key length");var n=ro.readUInt32BE(r,0),i=ro.readUInt32BE(r,4);ro.pc1(n,i,e.tmp,0),n=e.tmp[0],i=e.tmp[1];for(var o=0;o>>1];n=ro.r28shl(n,s),i=ro.r28shl(i,s),ro.pc2(n,i,e.keys,o)}};Ol.prototype._update=function(e,r,n,i){var o=this._desState,s=ro.readUInt32BE(e,r),a=ro.readUInt32BE(e,r+4);ro.ip(s,a,o.tmp,0),s=o.tmp[0],a=o.tmp[1],this.type==="encrypt"?this._encrypt(o,s,a,o.tmp,0):this._decrypt(o,s,a,o.tmp,0),s=o.tmp[0],a=o.tmp[1],ro.writeUInt32BE(n,s,i),ro.writeUInt32BE(n,a,i+4)};Ol.prototype._pad=function(e,r){if(this.padding===!1)return!1;for(var n=e.length-r,i=r;i>>0,s=m}ro.rip(a,s,i,o)};Ol.prototype._decrypt=function(e,r,n,i,o){for(var s=n,a=r,d=e.keys.length-2;d>=0;d-=2){var u=e.keys[d],c=e.keys[d+1];ro.expand(s,e.tmp,0),u^=e.tmp[0],c^=e.tmp[1];var l=ro.substitute(u,c),p=ro.permute(l),m=s;s=(a^p)>>>0,a=m}ro.rip(s,a,i,o)}});var QX=V(XX=>{"use strict";f();var ETe=Cc(),STe=Ft(),S4={};function ATe(t){ETe.equal(t.length,8,"Invalid IV length"),this.iv=new Array(8);for(var e=0;e{"use strict";f();var PTe=Cc(),ITe=Ft(),eQ=E4(),gm=mM();function kTe(t,e){PTe.equal(e.length,24,"Invalid key length");var r=e.slice(0,8),n=e.slice(8,16),i=e.slice(16,24);t==="encrypt"?this.ciphers=[gm.create({type:"encrypt",key:r}),gm.create({type:"decrypt",key:n}),gm.create({type:"encrypt",key:i})]:this.ciphers=[gm.create({type:"decrypt",key:i}),gm.create({type:"encrypt",key:n}),gm.create({type:"decrypt",key:r})]}function ug(t){eQ.call(this,t);var e=new kTe(this.type,this.options.key);this._edeState=e}ITe(ug,eQ);tQ.exports=ug;ug.create=function(e){return new ug(e)};ug.prototype._update=function(e,r,n,i){var o=this._edeState;o.ciphers[0]._update(e,r,n,i),o.ciphers[1]._update(n,i,n,i),o.ciphers[2]._update(n,i,n,i)};ug.prototype._pad=gm.prototype._pad;ug.prototype._unpad=gm.prototype._unpad});var nQ=V(Cw=>{"use strict";f();Cw.utils=pM();Cw.Cipher=E4();Cw.DES=mM();Cw.CBC=QX();Cw.EDE=rQ()});var sQ=V((fgt,oQ)=>{f();var iQ=lh(),fh=nQ(),RTe=Ft(),lg=cr().Buffer,sE={"des-ede3-cbc":fh.CBC.instantiate(fh.EDE),"des-ede3":fh.EDE,"des-ede-cbc":fh.CBC.instantiate(fh.EDE),"des-ede":fh.EDE,"des-cbc":fh.CBC.instantiate(fh.DES),"des-ecb":fh.DES};sE.des=sE["des-cbc"];sE.des3=sE["des-ede3-cbc"];oQ.exports=A4;RTe(A4,iQ);function A4(t){iQ.call(this);var e=t.mode.toLowerCase(),r=sE[e],n;t.decrypt?n="decrypt":n="encrypt";var i=t.key;lg.isBuffer(i)||(i=lg.from(i)),(e==="des-ede"||e==="des-ede-cbc")&&(i=lg.concat([i,i.slice(0,8)]));var o=t.iv;lg.isBuffer(o)||(o=lg.from(o)),this._des=r.create({key:i,iv:o,type:n})}A4.prototype._update=function(t){return lg.from(this._des.update(t))};A4.prototype._final=function(){return lg.from(this._des.final())}});var aQ=V(yM=>{f();yM.encrypt=function(t,e){return t._cipher.encryptBlock(e)};yM.decrypt=function(t,e){return t._cipher.decryptBlock(e)}});var $w=V((ygt,cQ)=>{f();cQ.exports=function(e,r){for(var n=Math.min(e.length,r.length),i=new O.Buffer(n),o=0;o{f();var dQ=$w();gM.encrypt=function(t,e){var r=dQ(e,t._prev);return t._prev=t._cipher.encryptBlock(r),t._prev};gM.decrypt=function(t,e){var r=t._prev;t._prev=e;var n=t._cipher.decryptBlock(e);return dQ(n,r)}});var hQ=V(fQ=>{f();var aE=cr().Buffer,DTe=$w();function lQ(t,e,r){var n=e.length,i=DTe(e,t._cache);return t._cache=t._cache.slice(n),t._prev=aE.concat([t._prev,r?e:i]),i}fQ.encrypt=function(t,e,r){for(var n=aE.allocUnsafe(0),i;e.length;)if(t._cache.length===0&&(t._cache=t._cipher.encryptBlock(t._prev),t._prev=aE.allocUnsafe(0)),t._cache.length<=e.length)i=t._cache.length,n=aE.concat([n,lQ(t,e.slice(0,i),r)]),e=e.slice(i);else{n=aE.concat([n,lQ(t,e,r)]);break}return n}});var mQ=V(pQ=>{f();var vM=cr().Buffer;function BTe(t,e,r){var n=t._cipher.encryptBlock(t._prev),i=n[0]^e;return t._prev=vM.concat([t._prev.slice(1),vM.from([r?e:i])]),i}pQ.encrypt=function(t,e,r){for(var n=e.length,i=vM.allocUnsafe(n),o=-1;++o{f();var T4=cr().Buffer;function MTe(t,e,r){for(var n,i=-1,o=8,s=0,a,d;++i>i%8,t._prev=OTe(t._prev,r?a:d);return s}function OTe(t,e){var r=t.length,n=-1,i=T4.allocUnsafe(t.length);for(t=T4.concat([t,T4.from([e])]);++n>7;return i}yQ.encrypt=function(t,e,r){for(var n=e.length,i=T4.allocUnsafe(n),o=-1;++o{f();var CTe=$w();function $Te(t){return t._prev=t._cipher.encryptBlock(t._prev),t._prev}vQ.encrypt=function(t,e){for(;t._cache.length{f();function jTe(t){for(var e=t.length,r;e--;)if(r=t.readUInt8(e),r===255)t.writeUInt8(0,e);else{r++,t.writeUInt8(r,e);break}}wQ.exports=jTe});var _M=V(xQ=>{f();var NTe=$w(),_Q=cr().Buffer,UTe=bM();function qTe(t){var e=t._cipher.encryptBlockRaw(t._prev);return UTe(t._prev),e}var wM=16;xQ.encrypt=function(t,e){var r=Math.ceil(e.length/wM),n=t._cache.length;t._cache=_Q.concat([t._cache,_Q.allocUnsafe(r*wM)]);for(var i=0;i{LTe.exports={"aes-128-ecb":{cipher:"AES",key:128,iv:0,mode:"ECB",type:"block"},"aes-192-ecb":{cipher:"AES",key:192,iv:0,mode:"ECB",type:"block"},"aes-256-ecb":{cipher:"AES",key:256,iv:0,mode:"ECB",type:"block"},"aes-128-cbc":{cipher:"AES",key:128,iv:16,mode:"CBC",type:"block"},"aes-192-cbc":{cipher:"AES",key:192,iv:16,mode:"CBC",type:"block"},"aes-256-cbc":{cipher:"AES",key:256,iv:16,mode:"CBC",type:"block"},aes128:{cipher:"AES",key:128,iv:16,mode:"CBC",type:"block"},aes192:{cipher:"AES",key:192,iv:16,mode:"CBC",type:"block"},aes256:{cipher:"AES",key:256,iv:16,mode:"CBC",type:"block"},"aes-128-cfb":{cipher:"AES",key:128,iv:16,mode:"CFB",type:"stream"},"aes-192-cfb":{cipher:"AES",key:192,iv:16,mode:"CFB",type:"stream"},"aes-256-cfb":{cipher:"AES",key:256,iv:16,mode:"CFB",type:"stream"},"aes-128-cfb8":{cipher:"AES",key:128,iv:16,mode:"CFB8",type:"stream"},"aes-192-cfb8":{cipher:"AES",key:192,iv:16,mode:"CFB8",type:"stream"},"aes-256-cfb8":{cipher:"AES",key:256,iv:16,mode:"CFB8",type:"stream"},"aes-128-cfb1":{cipher:"AES",key:128,iv:16,mode:"CFB1",type:"stream"},"aes-192-cfb1":{cipher:"AES",key:192,iv:16,mode:"CFB1",type:"stream"},"aes-256-cfb1":{cipher:"AES",key:256,iv:16,mode:"CFB1",type:"stream"},"aes-128-ofb":{cipher:"AES",key:128,iv:16,mode:"OFB",type:"stream"},"aes-192-ofb":{cipher:"AES",key:192,iv:16,mode:"OFB",type:"stream"},"aes-256-ofb":{cipher:"AES",key:256,iv:16,mode:"OFB",type:"stream"},"aes-128-ctr":{cipher:"AES",key:128,iv:16,mode:"CTR",type:"stream"},"aes-192-ctr":{cipher:"AES",key:192,iv:16,mode:"CTR",type:"stream"},"aes-256-ctr":{cipher:"AES",key:256,iv:16,mode:"CTR",type:"stream"},"aes-128-gcm":{cipher:"AES",key:128,iv:12,mode:"GCM",type:"auth"},"aes-192-gcm":{cipher:"AES",key:192,iv:12,mode:"GCM",type:"auth"},"aes-256-gcm":{cipher:"AES",key:256,iv:12,mode:"GCM",type:"auth"}}});var I4=V((Mgt,EQ)=>{f();var KTe={ECB:aQ(),CBC:uQ(),CFB:hQ(),CFB8:mQ(),CFB1:gQ(),OFB:bQ(),CTR:_M(),GCM:_M()},P4=xM();for(EM in P4)P4[EM].module=KTe[P4[EM].mode];var EM;EQ.exports=P4});var cE=V((Cgt,AQ)=>{f();var k4=cr().Buffer;function AM(t){k4.isBuffer(t)||(t=k4.from(t));for(var e=t.length/4|0,r=new Array(e),n=0;n>>24]^s[c>>>16&255]^a[l>>>8&255]^d[p&255]^e[S++],g=o[c>>>24]^s[l>>>16&255]^a[p>>>8&255]^d[u&255]^e[S++],v=o[l>>>24]^s[p>>>16&255]^a[u>>>8&255]^d[c&255]^e[S++],x=o[p>>>24]^s[u>>>16&255]^a[c>>>8&255]^d[l&255]^e[S++],u=m,c=g,l=v,p=x;return m=(n[u>>>24]<<24|n[c>>>16&255]<<16|n[l>>>8&255]<<8|n[p&255])^e[S++],g=(n[c>>>24]<<24|n[l>>>16&255]<<16|n[p>>>8&255]<<8|n[u&255])^e[S++],v=(n[l>>>24]<<24|n[p>>>16&255]<<16|n[u>>>8&255]<<8|n[c&255])^e[S++],x=(n[p>>>24]<<24|n[u>>>16&255]<<16|n[c>>>8&255]<<8|n[l&255])^e[S++],m=m>>>0,g=g>>>0,v=v>>>0,x=x>>>0,[m,g,v,x]}var FTe=[0,1,2,4,8,16,32,64,128,27,54],Wi=function(){for(var t=new Array(256),e=0;e<256;e++)e<128?t[e]=e<<1:t[e]=e<<1^283;for(var r=[],n=[],i=[[],[],[],[]],o=[[],[],[],[]],s=0,a=0,d=0;d<256;++d){var u=a^a<<1^a<<2^a<<3^a<<4;u=u>>>8^u&255^99,r[s]=u,n[u]=s;var c=t[s],l=t[c],p=t[l],m=t[u]*257^u*16843008;i[0][s]=m<<24|m>>>8,i[1][s]=m<<16|m>>>16,i[2][s]=m<<8|m>>>24,i[3][s]=m,m=p*16843009^l*65537^c*257^s*16843008,o[0][u]=m<<24|m>>>8,o[1][u]=m<<16|m>>>16,o[2][u]=m<<8|m>>>24,o[3][u]=m,s===0?s=a=1:(s=c^t[t[t[p^c]]],a^=t[t[a]])}return{SBOX:r,INV_SBOX:n,SUB_MIX:i,INV_SUB_MIX:o}}();function Td(t){this._key=AM(t),this._reset()}Td.blockSize=4*4;Td.keySize=256/8;Td.prototype.blockSize=Td.blockSize;Td.prototype.keySize=Td.keySize;Td.prototype._reset=function(){for(var t=this._key,e=t.length,r=e+6,n=(r+1)*4,i=[],o=0;o>>24,s=Wi.SBOX[s>>>24]<<24|Wi.SBOX[s>>>16&255]<<16|Wi.SBOX[s>>>8&255]<<8|Wi.SBOX[s&255],s^=FTe[o/e|0]<<24):e>6&&o%e===4&&(s=Wi.SBOX[s>>>24]<<24|Wi.SBOX[s>>>16&255]<<16|Wi.SBOX[s>>>8&255]<<8|Wi.SBOX[s&255]),i[o]=i[o-e]^s}for(var a=[],d=0;d>>24]]^Wi.INV_SUB_MIX[1][Wi.SBOX[c>>>16&255]]^Wi.INV_SUB_MIX[2][Wi.SBOX[c>>>8&255]]^Wi.INV_SUB_MIX[3][Wi.SBOX[c&255]]}this._nRounds=r,this._keySchedule=i,this._invKeySchedule=a};Td.prototype.encryptBlockRaw=function(t){return t=AM(t),SQ(t,this._keySchedule,Wi.SUB_MIX,Wi.SBOX,this._nRounds)};Td.prototype.encryptBlock=function(t){var e=this.encryptBlockRaw(t),r=k4.allocUnsafe(16);return r.writeUInt32BE(e[0],0),r.writeUInt32BE(e[1],4),r.writeUInt32BE(e[2],8),r.writeUInt32BE(e[3],12),r};Td.prototype.decryptBlock=function(t){t=AM(t);var e=t[1];t[1]=t[3],t[3]=e;var r=SQ(t,this._invKeySchedule,Wi.INV_SUB_MIX,Wi.INV_SBOX,this._nRounds),n=k4.allocUnsafe(16);return n.writeUInt32BE(r[0],0),n.writeUInt32BE(r[3],4),n.writeUInt32BE(r[2],8),n.writeUInt32BE(r[1],12),n};Td.prototype.scrub=function(){SM(this._keySchedule),SM(this._invKeySchedule),SM(this._key)};AQ.exports.AES=Td});var IQ=V((jgt,PQ)=>{f();var jw=cr().Buffer,zTe=jw.alloc(16,0);function WTe(t){return[t.readUInt32BE(0),t.readUInt32BE(4),t.readUInt32BE(8),t.readUInt32BE(12)]}function TQ(t){var e=jw.allocUnsafe(16);return e.writeUInt32BE(t[0]>>>0,0),e.writeUInt32BE(t[1]>>>0,4),e.writeUInt32BE(t[2]>>>0,8),e.writeUInt32BE(t[3]>>>0,12),e}function dE(t){this.h=t,this.state=jw.alloc(16,0),this.cache=jw.allocUnsafe(0)}dE.prototype.ghash=function(t){for(var e=-1;++e0;r--)t[r]=t[r]>>>1|(t[r-1]&1)<<31;t[0]=t[0]>>>1,i&&(t[0]=t[0]^225<<24)}this.state=TQ(e)};dE.prototype.update=function(t){this.cache=jw.concat([this.cache,t]);for(var e;this.cache.length>=16;)e=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(e)};dE.prototype.final=function(t,e){return this.cache.length&&this.ghash(jw.concat([this.cache,zTe],16)),this.ghash(TQ([0,t,0,e])),this.state};PQ.exports=dE});var TM=V((Ugt,DQ)=>{f();var HTe=cE(),Ya=cr().Buffer,kQ=lh(),VTe=Ft(),RQ=IQ(),GTe=$w(),JTe=bM();function ZTe(t,e){var r=0;t.length!==e.length&&r++;for(var n=Math.min(t.length,e.length),i=0;i{f();var XTe=cE(),PM=cr().Buffer,BQ=lh(),QTe=Ft();function R4(t,e,r,n){BQ.call(this),this._cipher=new XTe.AES(e),this._prev=PM.from(r),this._cache=PM.allocUnsafe(0),this._secCache=PM.allocUnsafe(0),this._decrypt=n,this._mode=t}QTe(R4,BQ);R4.prototype._update=function(t){return this._mode.encrypt(this,t,this._decrypt)};R4.prototype._final=function(){this._cipher.scrub()};MQ.exports=R4});var uE=V((Fgt,OQ)=>{f();var hg=cr().Buffer,ePe=u4();function tPe(t,e,r,n){if(hg.isBuffer(t)||(t=hg.from(t,"binary")),e&&(hg.isBuffer(e)||(e=hg.from(e,"binary")),e.length!==8))throw new RangeError("salt should be Buffer with 8 byte length");for(var i=r/8,o=hg.alloc(i),s=hg.alloc(n||0),a=hg.alloc(0);i>0||n>0;){var d=new ePe;d.update(a),d.update(t),e&&d.update(e),a=d.digest();var u=0;if(i>0){var c=o.length-i;u=Math.min(i,a.length),a.copy(o,c,0,u),i-=u}if(u0){var l=s.length-n,p=Math.min(n,a.length-u);a.copy(s,l,u,u+p),n-=p}}return a.fill(0),{key:o,iv:s}}OQ.exports=tPe});var NQ=V(kM=>{f();var CQ=I4(),rPe=TM(),hh=cr().Buffer,nPe=IM(),$Q=lh(),iPe=cE(),oPe=uE(),sPe=Ft();function lE(t,e,r){$Q.call(this),this._cache=new D4,this._cipher=new iPe.AES(e),this._prev=hh.from(r),this._mode=t,this._autopadding=!0}sPe(lE,$Q);lE.prototype._update=function(t){this._cache.add(t);for(var e,r,n=[];e=this._cache.get();)r=this._mode.encrypt(this,e),n.push(r);return hh.concat(n)};var aPe=hh.alloc(16,16);lE.prototype._final=function(){var t=this._cache.flush();if(this._autopadding)return t=this._mode.encrypt(this,t),this._cipher.scrub(),t;if(!t.equals(aPe))throw this._cipher.scrub(),new Error("data not multiple of block length")};lE.prototype.setAutoPadding=function(t){return this._autopadding=!!t,this};function D4(){this.cache=hh.allocUnsafe(0)}D4.prototype.add=function(t){this.cache=hh.concat([this.cache,t])};D4.prototype.get=function(){if(this.cache.length>15){var t=this.cache.slice(0,16);return this.cache=this.cache.slice(16),t}return null};D4.prototype.flush=function(){for(var t=16-this.cache.length,e=hh.allocUnsafe(t),r=-1;++r{f();var dPe=TM(),Nw=cr().Buffer,UQ=I4(),uPe=IM(),qQ=lh(),lPe=cE(),fPe=uE(),hPe=Ft();function fE(t,e,r){qQ.call(this),this._cache=new B4,this._last=void 0,this._cipher=new lPe.AES(e),this._prev=Nw.from(r),this._mode=t,this._autopadding=!0}hPe(fE,qQ);fE.prototype._update=function(t){this._cache.add(t);for(var e,r,n=[];e=this._cache.get(this._autopadding);)r=this._mode.decrypt(this,e),n.push(r);return Nw.concat(n)};fE.prototype._final=function(){var t=this._cache.flush();if(this._autopadding)return pPe(this._mode.decrypt(this,t));if(t)throw new Error("data not multiple of block length")};fE.prototype.setAutoPadding=function(t){return this._autopadding=!!t,this};function B4(){this.cache=Nw.allocUnsafe(0)}B4.prototype.add=function(t){this.cache=Nw.concat([this.cache,t])};B4.prototype.get=function(t){var e;if(t){if(this.cache.length>16)return e=this.cache.slice(0,16),this.cache=this.cache.slice(16),e}else if(this.cache.length>=16)return e=this.cache.slice(0,16),this.cache=this.cache.slice(16),e;return null};B4.prototype.flush=function(){if(this.cache.length)return this.cache};function pPe(t){var e=t[15];if(e<1||e>16)throw new Error("unable to decrypt data");for(var r=-1;++r{f();var FQ=NQ(),zQ=KQ(),yPe=xM();function gPe(){return Object.keys(yPe)}Su.createCipher=Su.Cipher=FQ.createCipher;Su.createCipheriv=Su.Cipheriv=FQ.createCipheriv;Su.createDecipher=Su.Decipher=zQ.createDecipher;Su.createDecipheriv=Su.Decipheriv=zQ.createDecipheriv;Su.listCiphers=Su.getCiphers=gPe});var WQ=V(ph=>{f();ph["des-ecb"]={key:8,iv:0};ph["des-cbc"]=ph.des={key:8,iv:8};ph["des-ede3-cbc"]=ph.des3={key:24,iv:8};ph["des-ede3"]={key:24,iv:0};ph["des-ede-cbc"]={key:16,iv:8};ph["des-ede"]={key:16,iv:0}});var ZQ=V(Au=>{f();var HQ=sQ(),DM=M4(),vm=I4(),mh=WQ(),VQ=uE();function vPe(t,e){t=t.toLowerCase();var r,n;if(vm[t])r=vm[t].key,n=vm[t].iv;else if(mh[t])r=mh[t].key*8,n=mh[t].iv;else throw new TypeError("invalid suite type");var i=VQ(e,!1,r,n);return GQ(t,i.key,i.iv)}function bPe(t,e){t=t.toLowerCase();var r,n;if(vm[t])r=vm[t].key,n=vm[t].iv;else if(mh[t])r=mh[t].key*8,n=mh[t].iv;else throw new TypeError("invalid suite type");var i=VQ(e,!1,r,n);return JQ(t,i.key,i.iv)}function GQ(t,e,r){if(t=t.toLowerCase(),vm[t])return DM.createCipheriv(t,e,r);if(mh[t])return new HQ({key:e,iv:r,mode:t});throw new TypeError("invalid suite type")}function JQ(t,e,r){if(t=t.toLowerCase(),vm[t])return DM.createDecipheriv(t,e,r);if(mh[t])return new HQ({key:e,iv:r,mode:t,decrypt:!0});throw new TypeError("invalid suite type")}function wPe(){return Object.keys(mh).concat(DM.getCiphers())}Au.createCipher=Au.Cipher=vPe;Au.createCipheriv=Au.Cipheriv=GQ;Au.createDecipher=Au.Decipher=bPe;Au.createDecipheriv=Au.Decipheriv=JQ;Au.listCiphers=Au.getCiphers=wPe});var BM=V(()=>{f()});var Mo=V((YQ,MM)=>{f();(function(t,e){"use strict";function r(q,I){if(!q)throw new Error(I||"Assertion failed")}function n(q,I){q.super_=I;var T=function(){};T.prototype=I.prototype,q.prototype=new T,q.prototype.constructor=q}function i(q,I,T){if(i.isBN(q))return q;this.negative=0,this.words=null,this.length=0,this.red=null,q!==null&&((I==="le"||I==="be")&&(T=I,I=10),this._init(q||0,I||10,T||"be"))}typeof t=="object"?t.exports=i:e.BN=i,i.BN=i,i.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=BM().Buffer}catch{}i.isBN=function(I){return I instanceof i?!0:I!==null&&typeof I=="object"&&I.constructor.wordSize===i.wordSize&&Array.isArray(I.words)},i.max=function(I,T){return I.cmp(T)>0?I:T},i.min=function(I,T){return I.cmp(T)<0?I:T},i.prototype._init=function(I,T,B){if(typeof I=="number")return this._initNumber(I,T,B);if(typeof I=="object")return this._initArray(I,T,B);T==="hex"&&(T=16),r(T===(T|0)&&T>=2&&T<=36),I=I.toString().replace(/\s+/g,"");var h=0;I[0]==="-"&&(h++,this.negative=1),h=0;h-=3)w=I[h]|I[h-1]<<8|I[h-2]<<16,this.words[y]|=w<>>26-E&67108863,E+=24,E>=26&&(E-=26,y++);else if(B==="le")for(h=0,y=0;h>>26-E&67108863,E+=24,E>=26&&(E-=26,y++);return this.strip()};function s(q,I){var T=q.charCodeAt(I);return T>=65&&T<=70?T-55:T>=97&&T<=102?T-87:T-48&15}function a(q,I,T){var B=s(q,T);return T-1>=I&&(B|=s(q,T-1)<<4),B}i.prototype._parseHex=function(I,T,B){this.length=Math.ceil((I.length-T)/6),this.words=new Array(this.length);for(var h=0;h=T;h-=2)E=a(I,T,h)<=18?(y-=18,w+=1,this.words[w]|=E>>>26):y+=8;else{var _=I.length-T;for(h=_%2===0?T+1:T;h=18?(y-=18,w+=1,this.words[w]|=E>>>26):y+=8}this.strip()};function d(q,I,T,B){for(var h=0,y=Math.min(q.length,T),w=I;w=49?h+=E-49+10:E>=17?h+=E-17+10:h+=E}return h}i.prototype._parseBase=function(I,T,B){this.words=[0],this.length=1;for(var h=0,y=1;y<=67108863;y*=T)h++;h--,y=y/T|0;for(var w=I.length-B,E=w%h,_=Math.min(w,w-E)+B,b=0,C=B;C<_;C+=h)b=d(I,C,C+h,T),this.imuln(y),this.words[0]+b<67108864?this.words[0]+=b:this._iaddn(b);if(E!==0){var N=1;for(b=d(I,C,I.length,T),C=0;C1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},i.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},i.prototype.inspect=function(){return(this.red?""};var u=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],c=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],l=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];i.prototype.toString=function(I,T){I=I||10,T=T|0||1;var B;if(I===16||I==="hex"){B="";for(var h=0,y=0,w=0;w>>24-h&16777215,y!==0||w!==this.length-1?B=u[6-_.length]+_+B:B=_+B,h+=2,h>=26&&(h-=26,w--)}for(y!==0&&(B=y.toString(16)+B);B.length%T!==0;)B="0"+B;return this.negative!==0&&(B="-"+B),B}if(I===(I|0)&&I>=2&&I<=36){var b=c[I],C=l[I];B="";var N=this.clone();for(N.negative=0;!N.isZero();){var M=N.modn(C).toString(I);N=N.idivn(C),N.isZero()?B=M+B:B=u[b-M.length]+M+B}for(this.isZero()&&(B="0"+B);B.length%T!==0;)B="0"+B;return this.negative!==0&&(B="-"+B),B}r(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var I=this.words[0];return this.length===2?I+=this.words[1]*67108864:this.length===3&&this.words[2]===1?I+=4503599627370496+this.words[1]*67108864:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-I:I},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toBuffer=function(I,T){return r(typeof o<"u"),this.toArrayLike(o,I,T)},i.prototype.toArray=function(I,T){return this.toArrayLike(Array,I,T)},i.prototype.toArrayLike=function(I,T,B){var h=this.byteLength(),y=B||Math.max(1,h);r(h<=y,"byte array longer than desired length"),r(y>0,"Requested array length <= 0"),this.strip();var w=T==="le",E=new I(y),_,b,C=this.clone();if(w){for(b=0;!C.isZero();b++)_=C.andln(255),C.iushrn(8),E[b]=_;for(;b=4096&&(B+=13,T>>>=13),T>=64&&(B+=7,T>>>=7),T>=8&&(B+=4,T>>>=4),T>=2&&(B+=2,T>>>=2),B+T},i.prototype._zeroBits=function(I){if(I===0)return 26;var T=I,B=0;return T&8191||(B+=13,T>>>=13),T&127||(B+=7,T>>>=7),T&15||(B+=4,T>>>=4),T&3||(B+=2,T>>>=2),T&1||B++,B},i.prototype.bitLength=function(){var I=this.words[this.length-1],T=this._countBits(I);return(this.length-1)*26+T};function p(q){for(var I=new Array(q.bitLength()),T=0;T>>h}return I}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var I=0,T=0;TI.length?this.clone().ior(I):I.clone().ior(this)},i.prototype.uor=function(I){return this.length>I.length?this.clone().iuor(I):I.clone().iuor(this)},i.prototype.iuand=function(I){var T;this.length>I.length?T=I:T=this;for(var B=0;BI.length?this.clone().iand(I):I.clone().iand(this)},i.prototype.uand=function(I){return this.length>I.length?this.clone().iuand(I):I.clone().iuand(this)},i.prototype.iuxor=function(I){var T,B;this.length>I.length?(T=this,B=I):(T=I,B=this);for(var h=0;hI.length?this.clone().ixor(I):I.clone().ixor(this)},i.prototype.uxor=function(I){return this.length>I.length?this.clone().iuxor(I):I.clone().iuxor(this)},i.prototype.inotn=function(I){r(typeof I=="number"&&I>=0);var T=Math.ceil(I/26)|0,B=I%26;this._expand(T),B>0&&T--;for(var h=0;h0&&(this.words[h]=~this.words[h]&67108863>>26-B),this.strip()},i.prototype.notn=function(I){return this.clone().inotn(I)},i.prototype.setn=function(I,T){r(typeof I=="number"&&I>=0);var B=I/26|0,h=I%26;return this._expand(B+1),T?this.words[B]=this.words[B]|1<I.length?(B=this,h=I):(B=I,h=this);for(var y=0,w=0;w>>26;for(;y!==0&&w>>26;if(this.length=B.length,y!==0)this.words[this.length]=y,this.length++;else if(B!==this)for(;wI.length?this.clone().iadd(I):I.clone().iadd(this)},i.prototype.isub=function(I){if(I.negative!==0){I.negative=0;var T=this.iadd(I);return I.negative=1,T._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(I),this.negative=1,this._normSign();var B=this.cmp(I);if(B===0)return this.negative=0,this.length=1,this.words[0]=0,this;var h,y;B>0?(h=this,y=I):(h=I,y=this);for(var w=0,E=0;E>26,this.words[E]=T&67108863;for(;w!==0&&E>26,this.words[E]=T&67108863;if(w===0&&E>>26,N=_&67108863,M=Math.min(b,I.length-1),U=Math.max(0,b-q.length+1);U<=M;U++){var G=b-U|0;h=q.words[G]|0,y=I.words[U]|0,w=h*y+N,C+=w/67108864|0,N=w&67108863}T.words[b]=N|0,_=C|0}return _!==0?T.words[b]=_|0:T.length--,T.strip()}var g=function(I,T,B){var h=I.words,y=T.words,w=B.words,E=0,_,b,C,N=h[0]|0,M=N&8191,U=N>>>13,G=h[1]|0,Z=G&8191,J=G>>>13,H=h[2]|0,X=H&8191,te=H>>>13,ne=h[3]|0,Q=ne&8191,re=ne>>>13,ce=h[4]|0,pe=ce&8191,ye=ce>>>13,ie=h[5]|0,he=ie&8191,me=ie>>>13,Re=h[6]|0,xe=Re&8191,it=Re>>>13,Et=h[7]|0,Fe=Et&8191,mt=Et>>>13,En=h[8]|0,ke=En&8191,Pe=En>>>13,Wt=h[9]|0,Be=Wt&8191,Ee=Wt>>>13,Cr=y[0]|0,Ve=Cr&8191,Ze=Cr>>>13,en=y[1]|0,Rt=en&8191,Ye=en>>>13,pd=y[2]|0,Dt=pd&8191,Ut=pd>>>13,y0=y[3]|0,$t=y0&8191,Zt=y0>>>13,md=y[4]|0,Yt=md&8191,Ht=md>>>13,g0=y[5]|0,qt=g0&8191,Vt=g0>>>13,v0=y[6]|0,Gt=v0&8191,Xt=v0>>>13,qp=y[7]|0,ee=qp&8191,Y=qp>>>13,oe=y[8]|0,ue=oe&8191,le=oe>>>13,Ne=y[9]|0,Me=Ne&8191,Ue=Ne>>>13;B.negative=I.negative^T.negative,B.length=19,_=Math.imul(M,Ve),b=Math.imul(M,Ze),b=b+Math.imul(U,Ve)|0,C=Math.imul(U,Ze);var Tr=(E+_|0)+((b&8191)<<13)|0;E=(C+(b>>>13)|0)+(Tr>>>26)|0,Tr&=67108863,_=Math.imul(Z,Ve),b=Math.imul(Z,Ze),b=b+Math.imul(J,Ve)|0,C=Math.imul(J,Ze),_=_+Math.imul(M,Rt)|0,b=b+Math.imul(M,Ye)|0,b=b+Math.imul(U,Rt)|0,C=C+Math.imul(U,Ye)|0;var Lt=(E+_|0)+((b&8191)<<13)|0;E=(C+(b>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,_=Math.imul(X,Ve),b=Math.imul(X,Ze),b=b+Math.imul(te,Ve)|0,C=Math.imul(te,Ze),_=_+Math.imul(Z,Rt)|0,b=b+Math.imul(Z,Ye)|0,b=b+Math.imul(J,Rt)|0,C=C+Math.imul(J,Ye)|0,_=_+Math.imul(M,Dt)|0,b=b+Math.imul(M,Ut)|0,b=b+Math.imul(U,Dt)|0,C=C+Math.imul(U,Ut)|0;var ft=(E+_|0)+((b&8191)<<13)|0;E=(C+(b>>>13)|0)+(ft>>>26)|0,ft&=67108863,_=Math.imul(Q,Ve),b=Math.imul(Q,Ze),b=b+Math.imul(re,Ve)|0,C=Math.imul(re,Ze),_=_+Math.imul(X,Rt)|0,b=b+Math.imul(X,Ye)|0,b=b+Math.imul(te,Rt)|0,C=C+Math.imul(te,Ye)|0,_=_+Math.imul(Z,Dt)|0,b=b+Math.imul(Z,Ut)|0,b=b+Math.imul(J,Dt)|0,C=C+Math.imul(J,Ut)|0,_=_+Math.imul(M,$t)|0,b=b+Math.imul(M,Zt)|0,b=b+Math.imul(U,$t)|0,C=C+Math.imul(U,Zt)|0;var Jr=(E+_|0)+((b&8191)<<13)|0;E=(C+(b>>>13)|0)+(Jr>>>26)|0,Jr&=67108863,_=Math.imul(pe,Ve),b=Math.imul(pe,Ze),b=b+Math.imul(ye,Ve)|0,C=Math.imul(ye,Ze),_=_+Math.imul(Q,Rt)|0,b=b+Math.imul(Q,Ye)|0,b=b+Math.imul(re,Rt)|0,C=C+Math.imul(re,Ye)|0,_=_+Math.imul(X,Dt)|0,b=b+Math.imul(X,Ut)|0,b=b+Math.imul(te,Dt)|0,C=C+Math.imul(te,Ut)|0,_=_+Math.imul(Z,$t)|0,b=b+Math.imul(Z,Zt)|0,b=b+Math.imul(J,$t)|0,C=C+Math.imul(J,Zt)|0,_=_+Math.imul(M,Yt)|0,b=b+Math.imul(M,Ht)|0,b=b+Math.imul(U,Yt)|0,C=C+Math.imul(U,Ht)|0;var dn=(E+_|0)+((b&8191)<<13)|0;E=(C+(b>>>13)|0)+(dn>>>26)|0,dn&=67108863,_=Math.imul(he,Ve),b=Math.imul(he,Ze),b=b+Math.imul(me,Ve)|0,C=Math.imul(me,Ze),_=_+Math.imul(pe,Rt)|0,b=b+Math.imul(pe,Ye)|0,b=b+Math.imul(ye,Rt)|0,C=C+Math.imul(ye,Ye)|0,_=_+Math.imul(Q,Dt)|0,b=b+Math.imul(Q,Ut)|0,b=b+Math.imul(re,Dt)|0,C=C+Math.imul(re,Ut)|0,_=_+Math.imul(X,$t)|0,b=b+Math.imul(X,Zt)|0,b=b+Math.imul(te,$t)|0,C=C+Math.imul(te,Zt)|0,_=_+Math.imul(Z,Yt)|0,b=b+Math.imul(Z,Ht)|0,b=b+Math.imul(J,Yt)|0,C=C+Math.imul(J,Ht)|0,_=_+Math.imul(M,qt)|0,b=b+Math.imul(M,Vt)|0,b=b+Math.imul(U,qt)|0,C=C+Math.imul(U,Vt)|0;var Hr=(E+_|0)+((b&8191)<<13)|0;E=(C+(b>>>13)|0)+(Hr>>>26)|0,Hr&=67108863,_=Math.imul(xe,Ve),b=Math.imul(xe,Ze),b=b+Math.imul(it,Ve)|0,C=Math.imul(it,Ze),_=_+Math.imul(he,Rt)|0,b=b+Math.imul(he,Ye)|0,b=b+Math.imul(me,Rt)|0,C=C+Math.imul(me,Ye)|0,_=_+Math.imul(pe,Dt)|0,b=b+Math.imul(pe,Ut)|0,b=b+Math.imul(ye,Dt)|0,C=C+Math.imul(ye,Ut)|0,_=_+Math.imul(Q,$t)|0,b=b+Math.imul(Q,Zt)|0,b=b+Math.imul(re,$t)|0,C=C+Math.imul(re,Zt)|0,_=_+Math.imul(X,Yt)|0,b=b+Math.imul(X,Ht)|0,b=b+Math.imul(te,Yt)|0,C=C+Math.imul(te,Ht)|0,_=_+Math.imul(Z,qt)|0,b=b+Math.imul(Z,Vt)|0,b=b+Math.imul(J,qt)|0,C=C+Math.imul(J,Vt)|0,_=_+Math.imul(M,Gt)|0,b=b+Math.imul(M,Xt)|0,b=b+Math.imul(U,Gt)|0,C=C+Math.imul(U,Xt)|0;var ar=(E+_|0)+((b&8191)<<13)|0;E=(C+(b>>>13)|0)+(ar>>>26)|0,ar&=67108863,_=Math.imul(Fe,Ve),b=Math.imul(Fe,Ze),b=b+Math.imul(mt,Ve)|0,C=Math.imul(mt,Ze),_=_+Math.imul(xe,Rt)|0,b=b+Math.imul(xe,Ye)|0,b=b+Math.imul(it,Rt)|0,C=C+Math.imul(it,Ye)|0,_=_+Math.imul(he,Dt)|0,b=b+Math.imul(he,Ut)|0,b=b+Math.imul(me,Dt)|0,C=C+Math.imul(me,Ut)|0,_=_+Math.imul(pe,$t)|0,b=b+Math.imul(pe,Zt)|0,b=b+Math.imul(ye,$t)|0,C=C+Math.imul(ye,Zt)|0,_=_+Math.imul(Q,Yt)|0,b=b+Math.imul(Q,Ht)|0,b=b+Math.imul(re,Yt)|0,C=C+Math.imul(re,Ht)|0,_=_+Math.imul(X,qt)|0,b=b+Math.imul(X,Vt)|0,b=b+Math.imul(te,qt)|0,C=C+Math.imul(te,Vt)|0,_=_+Math.imul(Z,Gt)|0,b=b+Math.imul(Z,Xt)|0,b=b+Math.imul(J,Gt)|0,C=C+Math.imul(J,Xt)|0,_=_+Math.imul(M,ee)|0,b=b+Math.imul(M,Y)|0,b=b+Math.imul(U,ee)|0,C=C+Math.imul(U,Y)|0;var Zr=(E+_|0)+((b&8191)<<13)|0;E=(C+(b>>>13)|0)+(Zr>>>26)|0,Zr&=67108863,_=Math.imul(ke,Ve),b=Math.imul(ke,Ze),b=b+Math.imul(Pe,Ve)|0,C=Math.imul(Pe,Ze),_=_+Math.imul(Fe,Rt)|0,b=b+Math.imul(Fe,Ye)|0,b=b+Math.imul(mt,Rt)|0,C=C+Math.imul(mt,Ye)|0,_=_+Math.imul(xe,Dt)|0,b=b+Math.imul(xe,Ut)|0,b=b+Math.imul(it,Dt)|0,C=C+Math.imul(it,Ut)|0,_=_+Math.imul(he,$t)|0,b=b+Math.imul(he,Zt)|0,b=b+Math.imul(me,$t)|0,C=C+Math.imul(me,Zt)|0,_=_+Math.imul(pe,Yt)|0,b=b+Math.imul(pe,Ht)|0,b=b+Math.imul(ye,Yt)|0,C=C+Math.imul(ye,Ht)|0,_=_+Math.imul(Q,qt)|0,b=b+Math.imul(Q,Vt)|0,b=b+Math.imul(re,qt)|0,C=C+Math.imul(re,Vt)|0,_=_+Math.imul(X,Gt)|0,b=b+Math.imul(X,Xt)|0,b=b+Math.imul(te,Gt)|0,C=C+Math.imul(te,Xt)|0,_=_+Math.imul(Z,ee)|0,b=b+Math.imul(Z,Y)|0,b=b+Math.imul(J,ee)|0,C=C+Math.imul(J,Y)|0,_=_+Math.imul(M,ue)|0,b=b+Math.imul(M,le)|0,b=b+Math.imul(U,ue)|0,C=C+Math.imul(U,le)|0;var Br=(E+_|0)+((b&8191)<<13)|0;E=(C+(b>>>13)|0)+(Br>>>26)|0,Br&=67108863,_=Math.imul(Be,Ve),b=Math.imul(Be,Ze),b=b+Math.imul(Ee,Ve)|0,C=Math.imul(Ee,Ze),_=_+Math.imul(ke,Rt)|0,b=b+Math.imul(ke,Ye)|0,b=b+Math.imul(Pe,Rt)|0,C=C+Math.imul(Pe,Ye)|0,_=_+Math.imul(Fe,Dt)|0,b=b+Math.imul(Fe,Ut)|0,b=b+Math.imul(mt,Dt)|0,C=C+Math.imul(mt,Ut)|0,_=_+Math.imul(xe,$t)|0,b=b+Math.imul(xe,Zt)|0,b=b+Math.imul(it,$t)|0,C=C+Math.imul(it,Zt)|0,_=_+Math.imul(he,Yt)|0,b=b+Math.imul(he,Ht)|0,b=b+Math.imul(me,Yt)|0,C=C+Math.imul(me,Ht)|0,_=_+Math.imul(pe,qt)|0,b=b+Math.imul(pe,Vt)|0,b=b+Math.imul(ye,qt)|0,C=C+Math.imul(ye,Vt)|0,_=_+Math.imul(Q,Gt)|0,b=b+Math.imul(Q,Xt)|0,b=b+Math.imul(re,Gt)|0,C=C+Math.imul(re,Xt)|0,_=_+Math.imul(X,ee)|0,b=b+Math.imul(X,Y)|0,b=b+Math.imul(te,ee)|0,C=C+Math.imul(te,Y)|0,_=_+Math.imul(Z,ue)|0,b=b+Math.imul(Z,le)|0,b=b+Math.imul(J,ue)|0,C=C+Math.imul(J,le)|0,_=_+Math.imul(M,Me)|0,b=b+Math.imul(M,Ue)|0,b=b+Math.imul(U,Me)|0,C=C+Math.imul(U,Ue)|0;var ha=(E+_|0)+((b&8191)<<13)|0;E=(C+(b>>>13)|0)+(ha>>>26)|0,ha&=67108863,_=Math.imul(Be,Rt),b=Math.imul(Be,Ye),b=b+Math.imul(Ee,Rt)|0,C=Math.imul(Ee,Ye),_=_+Math.imul(ke,Dt)|0,b=b+Math.imul(ke,Ut)|0,b=b+Math.imul(Pe,Dt)|0,C=C+Math.imul(Pe,Ut)|0,_=_+Math.imul(Fe,$t)|0,b=b+Math.imul(Fe,Zt)|0,b=b+Math.imul(mt,$t)|0,C=C+Math.imul(mt,Zt)|0,_=_+Math.imul(xe,Yt)|0,b=b+Math.imul(xe,Ht)|0,b=b+Math.imul(it,Yt)|0,C=C+Math.imul(it,Ht)|0,_=_+Math.imul(he,qt)|0,b=b+Math.imul(he,Vt)|0,b=b+Math.imul(me,qt)|0,C=C+Math.imul(me,Vt)|0,_=_+Math.imul(pe,Gt)|0,b=b+Math.imul(pe,Xt)|0,b=b+Math.imul(ye,Gt)|0,C=C+Math.imul(ye,Xt)|0,_=_+Math.imul(Q,ee)|0,b=b+Math.imul(Q,Y)|0,b=b+Math.imul(re,ee)|0,C=C+Math.imul(re,Y)|0,_=_+Math.imul(X,ue)|0,b=b+Math.imul(X,le)|0,b=b+Math.imul(te,ue)|0,C=C+Math.imul(te,le)|0,_=_+Math.imul(Z,Me)|0,b=b+Math.imul(Z,Ue)|0,b=b+Math.imul(J,Me)|0,C=C+Math.imul(J,Ue)|0;var Si=(E+_|0)+((b&8191)<<13)|0;E=(C+(b>>>13)|0)+(Si>>>26)|0,Si&=67108863,_=Math.imul(Be,Dt),b=Math.imul(Be,Ut),b=b+Math.imul(Ee,Dt)|0,C=Math.imul(Ee,Ut),_=_+Math.imul(ke,$t)|0,b=b+Math.imul(ke,Zt)|0,b=b+Math.imul(Pe,$t)|0,C=C+Math.imul(Pe,Zt)|0,_=_+Math.imul(Fe,Yt)|0,b=b+Math.imul(Fe,Ht)|0,b=b+Math.imul(mt,Yt)|0,C=C+Math.imul(mt,Ht)|0,_=_+Math.imul(xe,qt)|0,b=b+Math.imul(xe,Vt)|0,b=b+Math.imul(it,qt)|0,C=C+Math.imul(it,Vt)|0,_=_+Math.imul(he,Gt)|0,b=b+Math.imul(he,Xt)|0,b=b+Math.imul(me,Gt)|0,C=C+Math.imul(me,Xt)|0,_=_+Math.imul(pe,ee)|0,b=b+Math.imul(pe,Y)|0,b=b+Math.imul(ye,ee)|0,C=C+Math.imul(ye,Y)|0,_=_+Math.imul(Q,ue)|0,b=b+Math.imul(Q,le)|0,b=b+Math.imul(re,ue)|0,C=C+Math.imul(re,le)|0,_=_+Math.imul(X,Me)|0,b=b+Math.imul(X,Ue)|0,b=b+Math.imul(te,Me)|0,C=C+Math.imul(te,Ue)|0;var Ui=(E+_|0)+((b&8191)<<13)|0;E=(C+(b>>>13)|0)+(Ui>>>26)|0,Ui&=67108863,_=Math.imul(Be,$t),b=Math.imul(Be,Zt),b=b+Math.imul(Ee,$t)|0,C=Math.imul(Ee,Zt),_=_+Math.imul(ke,Yt)|0,b=b+Math.imul(ke,Ht)|0,b=b+Math.imul(Pe,Yt)|0,C=C+Math.imul(Pe,Ht)|0,_=_+Math.imul(Fe,qt)|0,b=b+Math.imul(Fe,Vt)|0,b=b+Math.imul(mt,qt)|0,C=C+Math.imul(mt,Vt)|0,_=_+Math.imul(xe,Gt)|0,b=b+Math.imul(xe,Xt)|0,b=b+Math.imul(it,Gt)|0,C=C+Math.imul(it,Xt)|0,_=_+Math.imul(he,ee)|0,b=b+Math.imul(he,Y)|0,b=b+Math.imul(me,ee)|0,C=C+Math.imul(me,Y)|0,_=_+Math.imul(pe,ue)|0,b=b+Math.imul(pe,le)|0,b=b+Math.imul(ye,ue)|0,C=C+Math.imul(ye,le)|0,_=_+Math.imul(Q,Me)|0,b=b+Math.imul(Q,Ue)|0,b=b+Math.imul(re,Me)|0,C=C+Math.imul(re,Ue)|0;var $r=(E+_|0)+((b&8191)<<13)|0;E=(C+(b>>>13)|0)+($r>>>26)|0,$r&=67108863,_=Math.imul(Be,Yt),b=Math.imul(Be,Ht),b=b+Math.imul(Ee,Yt)|0,C=Math.imul(Ee,Ht),_=_+Math.imul(ke,qt)|0,b=b+Math.imul(ke,Vt)|0,b=b+Math.imul(Pe,qt)|0,C=C+Math.imul(Pe,Vt)|0,_=_+Math.imul(Fe,Gt)|0,b=b+Math.imul(Fe,Xt)|0,b=b+Math.imul(mt,Gt)|0,C=C+Math.imul(mt,Xt)|0,_=_+Math.imul(xe,ee)|0,b=b+Math.imul(xe,Y)|0,b=b+Math.imul(it,ee)|0,C=C+Math.imul(it,Y)|0,_=_+Math.imul(he,ue)|0,b=b+Math.imul(he,le)|0,b=b+Math.imul(me,ue)|0,C=C+Math.imul(me,le)|0,_=_+Math.imul(pe,Me)|0,b=b+Math.imul(pe,Ue)|0,b=b+Math.imul(ye,Me)|0,C=C+Math.imul(ye,Ue)|0;var Ai=(E+_|0)+((b&8191)<<13)|0;E=(C+(b>>>13)|0)+(Ai>>>26)|0,Ai&=67108863,_=Math.imul(Be,qt),b=Math.imul(Be,Vt),b=b+Math.imul(Ee,qt)|0,C=Math.imul(Ee,Vt),_=_+Math.imul(ke,Gt)|0,b=b+Math.imul(ke,Xt)|0,b=b+Math.imul(Pe,Gt)|0,C=C+Math.imul(Pe,Xt)|0,_=_+Math.imul(Fe,ee)|0,b=b+Math.imul(Fe,Y)|0,b=b+Math.imul(mt,ee)|0,C=C+Math.imul(mt,Y)|0,_=_+Math.imul(xe,ue)|0,b=b+Math.imul(xe,le)|0,b=b+Math.imul(it,ue)|0,C=C+Math.imul(it,le)|0,_=_+Math.imul(he,Me)|0,b=b+Math.imul(he,Ue)|0,b=b+Math.imul(me,Me)|0,C=C+Math.imul(me,Ue)|0;var qi=(E+_|0)+((b&8191)<<13)|0;E=(C+(b>>>13)|0)+(qi>>>26)|0,qi&=67108863,_=Math.imul(Be,Gt),b=Math.imul(Be,Xt),b=b+Math.imul(Ee,Gt)|0,C=Math.imul(Ee,Xt),_=_+Math.imul(ke,ee)|0,b=b+Math.imul(ke,Y)|0,b=b+Math.imul(Pe,ee)|0,C=C+Math.imul(Pe,Y)|0,_=_+Math.imul(Fe,ue)|0,b=b+Math.imul(Fe,le)|0,b=b+Math.imul(mt,ue)|0,C=C+Math.imul(mt,le)|0,_=_+Math.imul(xe,Me)|0,b=b+Math.imul(xe,Ue)|0,b=b+Math.imul(it,Me)|0,C=C+Math.imul(it,Ue)|0;var xo=(E+_|0)+((b&8191)<<13)|0;E=(C+(b>>>13)|0)+(xo>>>26)|0,xo&=67108863,_=Math.imul(Be,ee),b=Math.imul(Be,Y),b=b+Math.imul(Ee,ee)|0,C=Math.imul(Ee,Y),_=_+Math.imul(ke,ue)|0,b=b+Math.imul(ke,le)|0,b=b+Math.imul(Pe,ue)|0,C=C+Math.imul(Pe,le)|0,_=_+Math.imul(Fe,Me)|0,b=b+Math.imul(Fe,Ue)|0,b=b+Math.imul(mt,Me)|0,C=C+Math.imul(mt,Ue)|0;var pa=(E+_|0)+((b&8191)<<13)|0;E=(C+(b>>>13)|0)+(pa>>>26)|0,pa&=67108863,_=Math.imul(Be,ue),b=Math.imul(Be,le),b=b+Math.imul(Ee,ue)|0,C=Math.imul(Ee,le),_=_+Math.imul(ke,Me)|0,b=b+Math.imul(ke,Ue)|0,b=b+Math.imul(Pe,Me)|0,C=C+Math.imul(Pe,Ue)|0;var Xo=(E+_|0)+((b&8191)<<13)|0;E=(C+(b>>>13)|0)+(Xo>>>26)|0,Xo&=67108863,_=Math.imul(Be,Me),b=Math.imul(Be,Ue),b=b+Math.imul(Ee,Me)|0,C=Math.imul(Ee,Ue);var xc=(E+_|0)+((b&8191)<<13)|0;return E=(C+(b>>>13)|0)+(xc>>>26)|0,xc&=67108863,w[0]=Tr,w[1]=Lt,w[2]=ft,w[3]=Jr,w[4]=dn,w[5]=Hr,w[6]=ar,w[7]=Zr,w[8]=Br,w[9]=ha,w[10]=Si,w[11]=Ui,w[12]=$r,w[13]=Ai,w[14]=qi,w[15]=xo,w[16]=pa,w[17]=Xo,w[18]=xc,E!==0&&(w[19]=E,B.length++),B};Math.imul||(g=m);function v(q,I,T){T.negative=I.negative^q.negative,T.length=q.length+I.length;for(var B=0,h=0,y=0;y>>26)|0,h+=w>>>26,w&=67108863}T.words[y]=E,B=w,w=h}return B!==0?T.words[y]=B:T.length--,T.strip()}function x(q,I,T){var B=new S;return B.mulp(q,I,T)}i.prototype.mulTo=function(I,T){var B,h=this.length+I.length;return this.length===10&&I.length===10?B=g(this,I,T):h<63?B=m(this,I,T):h<1024?B=v(this,I,T):B=x(this,I,T),B};function S(q,I){this.x=q,this.y=I}S.prototype.makeRBT=function(I){for(var T=new Array(I),B=i.prototype._countBits(I)-1,h=0;h>=1;return h},S.prototype.permute=function(I,T,B,h,y,w){for(var E=0;E>>1)y++;return 1<>>13,B[2*w+1]=y&8191,y=y>>>13;for(w=2*T;w>=26,T+=h/67108864|0,T+=y>>>26,this.words[B]=y&67108863}return T!==0&&(this.words[B]=T,this.length++),this},i.prototype.muln=function(I){return this.clone().imuln(I)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(I){var T=p(I);if(T.length===0)return new i(1);for(var B=this,h=0;h=0);var T=I%26,B=(I-T)/26,h=67108863>>>26-T<<26-T,y;if(T!==0){var w=0;for(y=0;y>>26-T}w&&(this.words[y]=w,this.length++)}if(B!==0){for(y=this.length-1;y>=0;y--)this.words[y+B]=this.words[y];for(y=0;y=0);var h;T?h=(T-T%26)/26:h=0;var y=I%26,w=Math.min((I-y)/26,this.length),E=67108863^67108863>>>y<w)for(this.length-=w,b=0;b=0&&(C!==0||b>=h);b--){var N=this.words[b]|0;this.words[b]=C<<26-y|N>>>y,C=N&E}return _&&C!==0&&(_.words[_.length++]=C),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.ishrn=function(I,T,B){return r(this.negative===0),this.iushrn(I,T,B)},i.prototype.shln=function(I){return this.clone().ishln(I)},i.prototype.ushln=function(I){return this.clone().iushln(I)},i.prototype.shrn=function(I){return this.clone().ishrn(I)},i.prototype.ushrn=function(I){return this.clone().iushrn(I)},i.prototype.testn=function(I){r(typeof I=="number"&&I>=0);var T=I%26,B=(I-T)/26,h=1<=0);var T=I%26,B=(I-T)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=B)return this;if(T!==0&&B++,this.length=Math.min(B,this.length),T!==0){var h=67108863^67108863>>>T<=67108864;T++)this.words[T]-=67108864,T===this.length-1?this.words[T+1]=1:this.words[T+1]++;return this.length=Math.max(this.length,T+1),this},i.prototype.isubn=function(I){if(r(typeof I=="number"),r(I<67108864),I<0)return this.iaddn(-I);if(this.negative!==0)return this.negative=0,this.iaddn(I),this.negative=1,this;if(this.words[0]-=I,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var T=0;T>26)-(_/67108864|0),this.words[y+B]=w&67108863}for(;y>26,this.words[y+B]=w&67108863;if(E===0)return this.strip();for(r(E===-1),E=0,y=0;y>26,this.words[y]=w&67108863;return this.negative=1,this.strip()},i.prototype._wordDiv=function(I,T){var B=this.length-I.length,h=this.clone(),y=I,w=y.words[y.length-1]|0,E=this._countBits(w);B=26-E,B!==0&&(y=y.ushln(B),h.iushln(B),w=y.words[y.length-1]|0);var _=h.length-y.length,b;if(T!=="mod"){b=new i(null),b.length=_+1,b.words=new Array(b.length);for(var C=0;C=0;M--){var U=(h.words[y.length+M]|0)*67108864+(h.words[y.length+M-1]|0);for(U=Math.min(U/w|0,67108863),h._ishlnsubmul(y,U,M);h.negative!==0;)U--,h.negative=0,h._ishlnsubmul(y,1,M),h.isZero()||(h.negative^=1);b&&(b.words[M]=U)}return b&&b.strip(),h.strip(),T!=="div"&&B!==0&&h.iushrn(B),{div:b||null,mod:h}},i.prototype.divmod=function(I,T,B){if(r(!I.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var h,y,w;return this.negative!==0&&I.negative===0?(w=this.neg().divmod(I,T),T!=="mod"&&(h=w.div.neg()),T!=="div"&&(y=w.mod.neg(),B&&y.negative!==0&&y.iadd(I)),{div:h,mod:y}):this.negative===0&&I.negative!==0?(w=this.divmod(I.neg(),T),T!=="mod"&&(h=w.div.neg()),{div:h,mod:w.mod}):this.negative&I.negative?(w=this.neg().divmod(I.neg(),T),T!=="div"&&(y=w.mod.neg(),B&&y.negative!==0&&y.isub(I)),{div:w.div,mod:y}):I.length>this.length||this.cmp(I)<0?{div:new i(0),mod:this}:I.length===1?T==="div"?{div:this.divn(I.words[0]),mod:null}:T==="mod"?{div:null,mod:new i(this.modn(I.words[0]))}:{div:this.divn(I.words[0]),mod:new i(this.modn(I.words[0]))}:this._wordDiv(I,T)},i.prototype.div=function(I){return this.divmod(I,"div",!1).div},i.prototype.mod=function(I){return this.divmod(I,"mod",!1).mod},i.prototype.umod=function(I){return this.divmod(I,"mod",!0).mod},i.prototype.divRound=function(I){var T=this.divmod(I);if(T.mod.isZero())return T.div;var B=T.div.negative!==0?T.mod.isub(I):T.mod,h=I.ushrn(1),y=I.andln(1),w=B.cmp(h);return w<0||y===1&&w===0?T.div:T.div.negative!==0?T.div.isubn(1):T.div.iaddn(1)},i.prototype.modn=function(I){r(I<=67108863);for(var T=(1<<26)%I,B=0,h=this.length-1;h>=0;h--)B=(T*B+(this.words[h]|0))%I;return B},i.prototype.idivn=function(I){r(I<=67108863);for(var T=0,B=this.length-1;B>=0;B--){var h=(this.words[B]|0)+T*67108864;this.words[B]=h/I|0,T=h%I}return this.strip()},i.prototype.divn=function(I){return this.clone().idivn(I)},i.prototype.egcd=function(I){r(I.negative===0),r(!I.isZero());var T=this,B=I.clone();T.negative!==0?T=T.umod(I):T=T.clone();for(var h=new i(1),y=new i(0),w=new i(0),E=new i(1),_=0;T.isEven()&&B.isEven();)T.iushrn(1),B.iushrn(1),++_;for(var b=B.clone(),C=T.clone();!T.isZero();){for(var N=0,M=1;!(T.words[0]&M)&&N<26;++N,M<<=1);if(N>0)for(T.iushrn(N);N-- >0;)(h.isOdd()||y.isOdd())&&(h.iadd(b),y.isub(C)),h.iushrn(1),y.iushrn(1);for(var U=0,G=1;!(B.words[0]&G)&&U<26;++U,G<<=1);if(U>0)for(B.iushrn(U);U-- >0;)(w.isOdd()||E.isOdd())&&(w.iadd(b),E.isub(C)),w.iushrn(1),E.iushrn(1);T.cmp(B)>=0?(T.isub(B),h.isub(w),y.isub(E)):(B.isub(T),w.isub(h),E.isub(y))}return{a:w,b:E,gcd:B.iushln(_)}},i.prototype._invmp=function(I){r(I.negative===0),r(!I.isZero());var T=this,B=I.clone();T.negative!==0?T=T.umod(I):T=T.clone();for(var h=new i(1),y=new i(0),w=B.clone();T.cmpn(1)>0&&B.cmpn(1)>0;){for(var E=0,_=1;!(T.words[0]&_)&&E<26;++E,_<<=1);if(E>0)for(T.iushrn(E);E-- >0;)h.isOdd()&&h.iadd(w),h.iushrn(1);for(var b=0,C=1;!(B.words[0]&C)&&b<26;++b,C<<=1);if(b>0)for(B.iushrn(b);b-- >0;)y.isOdd()&&y.iadd(w),y.iushrn(1);T.cmp(B)>=0?(T.isub(B),h.isub(y)):(B.isub(T),y.isub(h))}var N;return T.cmpn(1)===0?N=h:N=y,N.cmpn(0)<0&&N.iadd(I),N},i.prototype.gcd=function(I){if(this.isZero())return I.abs();if(I.isZero())return this.abs();var T=this.clone(),B=I.clone();T.negative=0,B.negative=0;for(var h=0;T.isEven()&&B.isEven();h++)T.iushrn(1),B.iushrn(1);do{for(;T.isEven();)T.iushrn(1);for(;B.isEven();)B.iushrn(1);var y=T.cmp(B);if(y<0){var w=T;T=B,B=w}else if(y===0||B.cmpn(1)===0)break;T.isub(B)}while(!0);return B.iushln(h)},i.prototype.invm=function(I){return this.egcd(I).a.umod(I)},i.prototype.isEven=function(){return(this.words[0]&1)===0},i.prototype.isOdd=function(){return(this.words[0]&1)===1},i.prototype.andln=function(I){return this.words[0]&I},i.prototype.bincn=function(I){r(typeof I=="number");var T=I%26,B=(I-T)/26,h=1<>>26,E&=67108863,this.words[w]=E}return y!==0&&(this.words[w]=y,this.length++),this},i.prototype.isZero=function(){return this.length===1&&this.words[0]===0},i.prototype.cmpn=function(I){var T=I<0;if(this.negative!==0&&!T)return-1;if(this.negative===0&&T)return 1;this.strip();var B;if(this.length>1)B=1;else{T&&(I=-I),r(I<=67108863,"Number is too big");var h=this.words[0]|0;B=h===I?0:hI.length)return 1;if(this.length=0;B--){var h=this.words[B]|0,y=I.words[B]|0;if(h!==y){hy&&(T=1);break}}return T},i.prototype.gtn=function(I){return this.cmpn(I)===1},i.prototype.gt=function(I){return this.cmp(I)===1},i.prototype.gten=function(I){return this.cmpn(I)>=0},i.prototype.gte=function(I){return this.cmp(I)>=0},i.prototype.ltn=function(I){return this.cmpn(I)===-1},i.prototype.lt=function(I){return this.cmp(I)===-1},i.prototype.lten=function(I){return this.cmpn(I)<=0},i.prototype.lte=function(I){return this.cmp(I)<=0},i.prototype.eqn=function(I){return this.cmpn(I)===0},i.prototype.eq=function(I){return this.cmp(I)===0},i.red=function(I){return new K(I)},i.prototype.toRed=function(I){return r(!this.red,"Already a number in reduction context"),r(this.negative===0,"red works only with positives"),I.convertTo(this)._forceRed(I)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(I){return this.red=I,this},i.prototype.forceRed=function(I){return r(!this.red,"Already a number in reduction context"),this._forceRed(I)},i.prototype.redAdd=function(I){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,I)},i.prototype.redIAdd=function(I){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,I)},i.prototype.redSub=function(I){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,I)},i.prototype.redISub=function(I){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,I)},i.prototype.redShl=function(I){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,I)},i.prototype.redMul=function(I){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,I),this.red.mul(this,I)},i.prototype.redIMul=function(I){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,I),this.red.imul(this,I)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(I){return r(this.red&&!I.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,I)};var P={k256:null,p224:null,p192:null,p25519:null};function A(q,I){this.name=q,this.p=new i(I,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}A.prototype._tmp=function(){var I=new i(null);return I.words=new Array(Math.ceil(this.n/13)),I},A.prototype.ireduce=function(I){var T=I,B;do this.split(T,this.tmp),T=this.imulK(T),T=T.iadd(this.tmp),B=T.bitLength();while(B>this.n);var h=B0?T.isub(this.p):T.strip!==void 0?T.strip():T._strip(),T},A.prototype.split=function(I,T){I.iushrn(this.n,0,T)},A.prototype.imulK=function(I){return I.imul(this.k)};function $(){A.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n($,A),$.prototype.split=function(I,T){for(var B=4194303,h=Math.min(I.length,9),y=0;y>>22,w=E}w>>>=22,I.words[y-10]=w,w===0&&I.length>10?I.length-=10:I.length-=9},$.prototype.imulK=function(I){I.words[I.length]=0,I.words[I.length+1]=0,I.length+=2;for(var T=0,B=0;B>>=26,I.words[B]=y,T=h}return T!==0&&(I.words[I.length++]=T),I},i._prime=function(I){if(P[I])return P[I];var T;if(I==="k256")T=new $;else if(I==="p224")T=new j;else if(I==="p192")T=new L;else if(I==="p25519")T=new F;else throw new Error("Unknown prime "+I);return P[I]=T,T};function K(q){if(typeof q=="string"){var I=i._prime(q);this.m=I.p,this.prime=I}else r(q.gtn(1),"modulus must be greater than 1"),this.m=q,this.prime=null}K.prototype._verify1=function(I){r(I.negative===0,"red works only with positives"),r(I.red,"red works only with red numbers")},K.prototype._verify2=function(I,T){r((I.negative|T.negative)===0,"red works only with positives"),r(I.red&&I.red===T.red,"red works only with red numbers")},K.prototype.imod=function(I){return this.prime?this.prime.ireduce(I)._forceRed(this):I.umod(this.m)._forceRed(this)},K.prototype.neg=function(I){return I.isZero()?I.clone():this.m.sub(I)._forceRed(this)},K.prototype.add=function(I,T){this._verify2(I,T);var B=I.add(T);return B.cmp(this.m)>=0&&B.isub(this.m),B._forceRed(this)},K.prototype.iadd=function(I,T){this._verify2(I,T);var B=I.iadd(T);return B.cmp(this.m)>=0&&B.isub(this.m),B},K.prototype.sub=function(I,T){this._verify2(I,T);var B=I.sub(T);return B.cmpn(0)<0&&B.iadd(this.m),B._forceRed(this)},K.prototype.isub=function(I,T){this._verify2(I,T);var B=I.isub(T);return B.cmpn(0)<0&&B.iadd(this.m),B},K.prototype.shl=function(I,T){return this._verify1(I),this.imod(I.ushln(T))},K.prototype.imul=function(I,T){return this._verify2(I,T),this.imod(I.imul(T))},K.prototype.mul=function(I,T){return this._verify2(I,T),this.imod(I.mul(T))},K.prototype.isqr=function(I){return this.imul(I,I.clone())},K.prototype.sqr=function(I){return this.mul(I,I)},K.prototype.sqrt=function(I){if(I.isZero())return I.clone();var T=this.m.andln(3);if(r(T%2===1),T===3){var B=this.m.add(new i(1)).iushrn(2);return this.pow(I,B)}for(var h=this.m.subn(1),y=0;!h.isZero()&&h.andln(1)===0;)y++,h.iushrn(1);r(!h.isZero());var w=new i(1).toRed(this),E=w.redNeg(),_=this.m.subn(1).iushrn(1),b=this.m.bitLength();for(b=new i(2*b*b).toRed(this);this.pow(b,_).cmp(E)!==0;)b.redIAdd(E);for(var C=this.pow(b,h),N=this.pow(I,h.addn(1).iushrn(1)),M=this.pow(I,h),U=y;M.cmp(w)!==0;){for(var G=M,Z=0;G.cmp(w)!==0;Z++)G=G.redSqr();r(Z=0;y--){for(var C=T.words[y],N=b-1;N>=0;N--){var M=C>>N&1;if(w!==h[0]&&(w=this.sqr(w)),M===0&&E===0){_=0;continue}E<<=1,E|=M,_++,!(_!==B&&(y!==0||N!==0))&&(w=this.mul(w,h[E]),_=0,E=0)}b=26}return w},K.prototype.convertTo=function(I){var T=I.umod(this.m);return T===I?T.clone():T},K.prototype.convertFrom=function(I){var T=I.clone();return T.red=null,T},i.mont=function(I){return new W(I)};function W(q){K.call(this,q),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}n(W,K),W.prototype.convertTo=function(I){return this.imod(I.ushln(this.shift))},W.prototype.convertFrom=function(I){var T=this.imod(I.mul(this.rinv));return T.red=null,T},W.prototype.imul=function(I,T){if(I.isZero()||T.isZero())return I.words[0]=0,I.length=1,I;var B=I.imul(T),h=B.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),y=B.isub(h).iushrn(this.shift),w=y;return y.cmp(this.m)>=0?w=y.isub(this.m):y.cmpn(0)<0&&(w=y.iadd(this.m)),w._forceRed(this)},W.prototype.mul=function(I,T){if(I.isZero()||T.isZero())return new i(0)._forceRed(this);var B=I.mul(T),h=B.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),y=B.isub(h).iushrn(this.shift),w=y;return y.cmp(this.m)>=0?w=y.isub(this.m):y.cmpn(0)<0&&(w=y.iadd(this.m)),w._forceRed(this)},W.prototype.invm=function(I){var T=this.imod(I._invmp(this.m).mul(this.r2));return T._forceRed(this)}})(typeof MM>"u"||MM,YQ)});var O4=V((ovt,$M)=>{f();var OM;$M.exports=function(e){return OM||(OM=new bm(null)),OM.generate(e)};function bm(t){this.rand=t}$M.exports.Rand=bm;bm.prototype.generate=function(e){return this._rand(e)};bm.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var r=new Uint8Array(e),n=0;n{f();var pg=Mo(),_Pe=O4();function mg(t){this.rand=t||new _Pe.Rand}XQ.exports=mg;mg.create=function(e){return new mg(e)};mg.prototype._randbelow=function(e){var r=e.bitLength(),n=Math.ceil(r/8);do var i=new pg(this.rand.generate(n));while(i.cmp(e)>=0);return i};mg.prototype._randrange=function(e,r){var n=r.sub(e);return e.add(this._randbelow(n))};mg.prototype.test=function(e,r,n){var i=e.bitLength(),o=pg.mont(e),s=new pg(1).toRed(o);r||(r=Math.max(1,i/48|0));for(var a=e.subn(1),d=0;!a.testn(d);d++);for(var u=e.shrn(d),c=a.toRed(o),l=!0;r>0;r--){var p=this._randrange(new pg(2),a);n&&n(p);var m=p.toRed(o).redPow(u);if(!(m.cmp(s)===0||m.cmp(c)===0)){for(var g=1;g0;r--){var c=this._randrange(new pg(2),s),l=e.gcd(c);if(l.cmpn(1)!==0)return l;var p=c.toRed(i).redPow(d);if(!(p.cmp(o)===0||p.cmp(u)===0)){for(var m=1;m{f();var xPe=eg();tee.exports=KM;KM.simpleSieve=qM;KM.fermatTest=LM;var ns=Mo(),EPe=new ns(24),SPe=jM(),QQ=new SPe,APe=new ns(1),UM=new ns(2),TPe=new ns(5),dvt=new ns(16),uvt=new ns(8),PPe=new ns(10),IPe=new ns(3),lvt=new ns(7),kPe=new ns(11),eee=new ns(4),fvt=new ns(12),NM=null;function RPe(){if(NM!==null)return NM;var t=1048576,e=[];e[0]=2;for(var r=1,n=3;nt;)r.ishrn(1);if(r.isEven()&&r.iadd(APe),r.testn(1)||r.iadd(UM),e.cmp(UM)){if(!e.cmp(TPe))for(;r.mod(PPe).cmp(IPe);)r.iadd(eee)}else for(;r.mod(EPe).cmp(kPe);)r.iadd(eee);if(n=r.shrn(1),qM(n)&&qM(r)&&LM(n)&&LM(r)&&QQ.test(n)&&QQ.test(r))return r}}});var ree=V((mvt,DPe)=>{DPe.exports={modp1:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},modp2:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},modp5:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},modp14:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},modp15:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},modp16:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},modp17:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},modp18:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}});var see=V((yvt,oee)=>{f();var Pd=Mo(),BPe=jM(),nee=new BPe,MPe=new Pd(24),OPe=new Pd(11),CPe=new Pd(10),$Pe=new Pd(3),jPe=new Pd(7),iee=FM(),NPe=eg();oee.exports=yh;function UPe(t,e){return e=e||"utf8",O.Buffer.isBuffer(t)||(t=new O.Buffer(t,e)),this._pub=new Pd(t),this}function qPe(t,e){return e=e||"utf8",O.Buffer.isBuffer(t)||(t=new O.Buffer(t,e)),this._priv=new Pd(t),this}var $4={};function LPe(t,e){var r=e.toString("hex"),n=[r,t.toString(16)].join("_");if(n in $4)return $4[n];var i=0;if(t.isEven()||!iee.simpleSieve||!iee.fermatTest(t)||!nee.test(t))return i+=1,r==="02"||r==="05"?i+=8:i+=4,$4[n]=i,i;nee.test(t.shrn(1))||(i+=2);var o;switch(r){case"02":t.mod(MPe).cmp(OPe)&&(i+=8);break;case"05":o=t.mod(CPe),o.cmp($Pe)&&o.cmp(jPe)&&(i+=8);break;default:i+=4}return $4[n]=i,i}function yh(t,e,r){this.setGenerator(e),this.__prime=new Pd(t),this._prime=Pd.mont(this.__prime),this._primeLen=t.length,this._pub=void 0,this._priv=void 0,this._primeCode=void 0,r?(this.setPublicKey=UPe,this.setPrivateKey=qPe):this._primeCode=8}Object.defineProperty(yh.prototype,"verifyError",{enumerable:!0,get:function(){return typeof this._primeCode!="number"&&(this._primeCode=LPe(this.__prime,this.__gen)),this._primeCode}});yh.prototype.generateKeys=function(){return this._priv||(this._priv=new Pd(NPe(this._primeLen))),this._pub=this._gen.toRed(this._prime).redPow(this._priv).fromRed(),this.getPublicKey()};yh.prototype.computeSecret=function(t){t=new Pd(t),t=t.toRed(this._prime);var e=t.redPow(this._priv).fromRed(),r=new O.Buffer(e.toArray()),n=this.getPrime();if(r.length{f();var KPe=FM(),aee=ree(),zM=see();function FPe(t){var e=new O.Buffer(aee[t].prime,"hex"),r=new O.Buffer(aee[t].gen,"hex");return new zM(e,r)}var zPe={binary:!0,hex:!0,base64:!0};function cee(t,e,r,n){return O.Buffer.isBuffer(e)||zPe[e]===void 0?cee(t,"binary",e,r):(e=e||"binary",n=n||"binary",r=r||new O.Buffer([2]),O.Buffer.isBuffer(r)||(r=new O.Buffer(r,n)),typeof t=="number"?new zM(KPe(t,r),r,!0):(O.Buffer.isBuffer(t)||(t=new O.Buffer(t,e)),new zM(t,r,!0)))}Uw.DiffieHellmanGroup=Uw.createDiffieHellmanGroup=Uw.getDiffieHellman=FPe;Uw.createDiffieHellman=Uw.DiffieHellman=cee});var hE=V((wvt,WM)=>{"use strict";f();typeof k.default>"u"||!k.default.version||k.default.version.indexOf("v0.")===0||k.default.version.indexOf("v1.")===0&&k.default.version.indexOf("v1.8.")!==0?WM.exports={nextTick:WPe}:WM.exports=k.default;function WPe(t,e,r,n){if(typeof t!="function")throw new TypeError('"callback" argument must be a function');var i=arguments.length,o,s;switch(i){case 0:case 1:return k.default.nextTick(t);case 2:return k.default.nextTick(function(){t.call(null,e)});case 3:return k.default.nextTick(function(){t.call(null,e,r)});case 4:return k.default.nextTick(function(){t.call(null,e,r,n)});default:for(o=new Array(i-1),s=0;s{f();var HPe={}.toString;uee.exports=Array.isArray||function(t){return HPe.call(t)=="[object Array]"}});var HM=V((Svt,fee)=>{f();fee.exports=Sa().EventEmitter});var pE=V((VM,pee)=>{f();var N4=hn(),gh=N4.Buffer;function hee(t,e){for(var r in t)e[r]=t[r]}gh.from&&gh.alloc&&gh.allocUnsafe&&gh.allocUnsafeSlow?pee.exports=N4:(hee(N4,VM),VM.Buffer=qw);function qw(t,e,r){return gh(t,e,r)}hee(gh,qw);qw.from=function(t,e,r){if(typeof t=="number")throw new TypeError("Argument must not be a number");return gh(t,e,r)};qw.alloc=function(t,e,r){if(typeof t!="number")throw new TypeError("Argument must be a number");var n=gh(t);return e!==void 0?typeof r=="string"?n.fill(e,r):n.fill(e):n.fill(0),n};qw.allocUnsafe=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return gh(t)};qw.allocUnsafeSlow=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return N4.SlowBuffer(t)}});var Lw=V(Js=>{f();function VPe(t){return Array.isArray?Array.isArray(t):U4(t)==="[object Array]"}Js.isArray=VPe;function GPe(t){return typeof t=="boolean"}Js.isBoolean=GPe;function JPe(t){return t===null}Js.isNull=JPe;function ZPe(t){return t==null}Js.isNullOrUndefined=ZPe;function YPe(t){return typeof t=="number"}Js.isNumber=YPe;function XPe(t){return typeof t=="string"}Js.isString=XPe;function QPe(t){return typeof t=="symbol"}Js.isSymbol=QPe;function eIe(t){return t===void 0}Js.isUndefined=eIe;function tIe(t){return U4(t)==="[object RegExp]"}Js.isRegExp=tIe;function rIe(t){return typeof t=="object"&&t!==null}Js.isObject=rIe;function nIe(t){return U4(t)==="[object Date]"}Js.isDate=nIe;function iIe(t){return U4(t)==="[object Error]"||t instanceof Error}Js.isError=iIe;function oIe(t){return typeof t=="function"}Js.isFunction=oIe;function sIe(t){return t===null||typeof t=="boolean"||typeof t=="number"||typeof t=="string"||typeof t=="symbol"||typeof t>"u"}Js.isPrimitive=sIe;Js.isBuffer=hn().Buffer.isBuffer;function U4(t){return Object.prototype.toString.call(t)}});var yee=V((kvt,GM)=>{"use strict";f();function aIe(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var mee=pE().Buffer,mE=Nx();function cIe(t,e,r){t.copy(e,r)}GM.exports=function(){function t(){aIe(this,t),this.head=null,this.tail=null,this.length=0}return t.prototype.push=function(r){var n={data:r,next:null};this.length>0?this.tail.next=n:this.head=n,this.tail=n,++this.length},t.prototype.unshift=function(r){var n={data:r,next:this.head};this.length===0&&(this.tail=n),this.head=n,++this.length},t.prototype.shift=function(){if(this.length!==0){var r=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,r}},t.prototype.clear=function(){this.head=this.tail=null,this.length=0},t.prototype.join=function(r){if(this.length===0)return"";for(var n=this.head,i=""+n.data;n=n.next;)i+=r+n.data;return i},t.prototype.concat=function(r){if(this.length===0)return mee.alloc(0);for(var n=mee.allocUnsafe(r>>>0),i=this.head,o=0;i;)cIe(i.data,n,o),o+=i.data.length,i=i.next;return n},t}();mE&&mE.inspect&&mE.inspect.custom&&(GM.exports.prototype[mE.inspect.custom]=function(){var t=mE.inspect({length:this.length});return this.constructor.name+" "+t})});var JM=V((Dvt,gee)=>{"use strict";f();var q4=hE();function dIe(t,e){var r=this,n=this._readableState&&this._readableState.destroyed,i=this._writableState&&this._writableState.destroyed;return n||i?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,q4.nextTick(L4,this,t)):q4.nextTick(L4,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(o){!e&&o?r._writableState?r._writableState.errorEmitted||(r._writableState.errorEmitted=!0,q4.nextTick(L4,r,o)):q4.nextTick(L4,r,o):e&&e(o)}),this)}function uIe(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function L4(t,e){t.emit("error",e)}gee.exports={destroy:dIe,undestroy:uIe}});var YM=V((Mvt,Aee)=>{"use strict";f();var yg=hE();Aee.exports=Hi;function bee(t){var e=this;this.next=null,this.entry=null,this.finish=function(){IIe(e,t)}}var lIe=!k.default.browser&&["v0.10","v0.9."].indexOf(k.default.version.slice(0,5))>-1?setImmediate:yg.nextTick,Kw;Hi.WritableState=gE;var wee=Object.create(Lw());wee.inherits=Ft();var fIe={deprecate:I7()},_ee=HM(),F4=pE().Buffer,hIe=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function pIe(t){return F4.from(t)}function mIe(t){return F4.isBuffer(t)||t instanceof hIe}var xee=JM();wee.inherits(Hi,_ee);function yIe(){}function gE(t,e){Kw=Kw||gg(),t=t||{};var r=e instanceof Kw;this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.writableObjectMode);var n=t.highWaterMark,i=t.writableHighWaterMark,o=this.objectMode?16:16*1024;n||n===0?this.highWaterMark=n:r&&(i||i===0)?this.highWaterMark=i:this.highWaterMark=o,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=t.decodeStrings===!1;this.decodeStrings=!s,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(a){EIe(e,a)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new bee(this)}gE.prototype.getBuffer=function(){for(var e=this.bufferedRequest,r=[];e;)r.push(e),e=e.next;return r};(function(){try{Object.defineProperty(gE.prototype,"buffer",{get:fIe.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var K4;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(K4=Function.prototype[Symbol.hasInstance],Object.defineProperty(Hi,Symbol.hasInstance,{value:function(t){return K4.call(this,t)?!0:this!==Hi?!1:t&&t._writableState instanceof gE}})):K4=function(t){return t instanceof this};function Hi(t){if(Kw=Kw||gg(),!K4.call(Hi,this)&&!(this instanceof Kw))return new Hi(t);this._writableState=new gE(t,this),this.writable=!0,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)),_ee.call(this)}Hi.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))};function gIe(t,e){var r=new Error("write after end");t.emit("error",r),yg.nextTick(e,r)}function vIe(t,e,r,n){var i=!0,o=!1;return r===null?o=new TypeError("May not write null values to stream"):typeof r!="string"&&r!==void 0&&!e.objectMode&&(o=new TypeError("Invalid non-string/buffer chunk")),o&&(t.emit("error",o),yg.nextTick(n,o),i=!1),i}Hi.prototype.write=function(t,e,r){var n=this._writableState,i=!1,o=!n.objectMode&&mIe(t);return o&&!F4.isBuffer(t)&&(t=pIe(t)),typeof e=="function"&&(r=e,e=null),o?e="buffer":e||(e=n.defaultEncoding),typeof r!="function"&&(r=yIe),n.ended?gIe(this,r):(o||vIe(this,n,t,r))&&(n.pendingcb++,i=wIe(this,n,o,t,e,r)),i};Hi.prototype.cork=function(){var t=this._writableState;t.corked++};Hi.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,!t.writing&&!t.corked&&!t.bufferProcessing&&t.bufferedRequest&&Eee(this,t))};Hi.prototype.setDefaultEncoding=function(e){if(typeof e=="string"&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this};function bIe(t,e,r){return!t.objectMode&&t.decodeStrings!==!1&&typeof e=="string"&&(e=F4.from(e,r)),e}Object.defineProperty(Hi.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function wIe(t,e,r,n,i,o){if(!r){var s=bIe(e,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=e.objectMode?1:n.length;e.length+=a;var d=e.length{"use strict";f();var Tee=hE(),kIe=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};kee.exports=vh;var Pee=Object.create(Lw());Pee.inherits=Ft();var Iee=eO(),QM=YM();Pee.inherits(vh,Iee);for(XM=kIe(QM.prototype),z4=0;z4{"use strict";f();var rO=pE().Buffer,Ree=rO.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 BIe(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 MIe(t){var e=BIe(t);if(typeof e!="string"&&(rO.isEncoding===Ree||!Ree(t)))throw new Error("Unknown encoding: "+t);return e||t}Dee.StringDecoder=vE;function vE(t){this.encoding=MIe(t);var e;switch(this.encoding){case"utf16le":this.text=UIe,this.end=qIe,e=4;break;case"utf8":this.fillLast=$Ie,e=4;break;case"base64":this.text=LIe,this.end=KIe,e=3;break;default:this.write=FIe,this.end=zIe;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=rO.allocUnsafe(e)}vE.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>5===6?2:t>>4===14?3:t>>3===30?4:t>>6===2?-1:-2}function OIe(t,e,r){var n=e.length-1;if(n=0?(i>0&&(t.lastNeed=i-1),i):--n=0?(i>0&&(t.lastNeed=i-2),i):--n=0?(i>0&&(i===2?i=0:t.lastNeed=i-3),i):0))}function CIe(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 $Ie(t){var e=this.lastTotal-this.lastNeed,r=CIe(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 jIe(t,e){var r=OIe(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 NIe(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"\uFFFD":e}function UIe(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 qIe(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 LIe(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 KIe(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function FIe(t){return t.toString(this.encoding)}function zIe(t){return t&&t.length?this.write(t):""}});var eO=V((qvt,Fee)=>{"use strict";f();var zw=hE();Fee.exports=Ln;var WIe=lee(),bE;Ln.ReadableState=Nee;var Uvt=Sa().EventEmitter,Cee=function(t,e){return t.listeners(e).length},cO=HM(),wE=pE().Buffer,HIe=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function VIe(t){return wE.from(t)}function GIe(t){return wE.isBuffer(t)||t instanceof HIe}var $ee=Object.create(Lw());$ee.inherits=Ft();var iO=Nx(),Yr=void 0;iO&&iO.debuglog?Yr=iO.debuglog("stream"):Yr=function(){};var JIe=yee(),jee=JM(),Fw;$ee.inherits(Ln,cO);var oO=["error","close","destroy","pause","resume"];function ZIe(t,e,r){if(typeof t.prependListener=="function")return t.prependListener(e,r);!t._events||!t._events[e]?t.on(e,r):WIe(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]}function Nee(t,e){bE=bE||gg(),t=t||{};var r=e instanceof bE;this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode);var n=t.highWaterMark,i=t.readableHighWaterMark,o=this.objectMode?16:16*1024;n||n===0?this.highWaterMark=n:r&&(i||i===0)?this.highWaterMark=i:this.highWaterMark=o,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new JIe,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(Fw||(Fw=nO().StringDecoder),this.decoder=new Fw(t.encoding),this.encoding=t.encoding)}function Ln(t){if(bE=bE||gg(),!(this instanceof Ln))return new Ln(t);this._readableState=new Nee(t,this),this.readable=!0,t&&(typeof t.read=="function"&&(this._read=t.read),typeof t.destroy=="function"&&(this._destroy=t.destroy)),cO.call(this)}Object.defineProperty(Ln.prototype,"destroyed",{get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}});Ln.prototype.destroy=jee.destroy;Ln.prototype._undestroy=jee.undestroy;Ln.prototype._destroy=function(t,e){this.push(null),e(t)};Ln.prototype.push=function(t,e){var r=this._readableState,n;return r.objectMode?n=!0:typeof t=="string"&&(e=e||r.defaultEncoding,e!==r.encoding&&(t=wE.from(t,e),e=""),n=!0),Uee(this,t,e,!1,n)};Ln.prototype.unshift=function(t){return Uee(this,t,null,!0,!1)};function Uee(t,e,r,n,i){var o=t._readableState;if(e===null)o.reading=!1,eke(t,o);else{var s;i||(s=YIe(o,e)),s?t.emit("error",s):o.objectMode||e&&e.length>0?(typeof e!="string"&&!o.objectMode&&Object.getPrototypeOf(e)!==wE.prototype&&(e=VIe(e)),n?o.endEmitted?t.emit("error",new Error("stream.unshift() after end event")):sO(t,o,e,!0):o.ended?t.emit("error",new Error("stream.push() after EOF")):(o.reading=!1,o.decoder&&!r?(e=o.decoder.write(e),o.objectMode||e.length!==0?sO(t,o,e,!1):qee(t,o)):sO(t,o,e,!1))):n||(o.reading=!1)}return XIe(o)}function sO(t,e,r,n){e.flowing&&e.length===0&&!e.sync?(t.emit("data",r),t.read(0)):(e.length+=e.objectMode?1:r.length,n?e.buffer.unshift(r):e.buffer.push(r),e.needReadable&&H4(t)),qee(t,e)}function YIe(t,e){var r;return!GIe(e)&&typeof e!="string"&&e!==void 0&&!t.objectMode&&(r=new TypeError("Invalid non-string/buffer chunk")),r}function XIe(t){return!t.ended&&(t.needReadable||t.length=Bee?t=Bee:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}function Mee(t,e){return t<=0||e.length===0&&e.ended?0:e.objectMode?1:t!==t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=QIe(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}Ln.prototype.read=function(t){Yr("read",t),t=parseInt(t,10);var e=this._readableState,r=t;if(t!==0&&(e.emittedReadable=!1),t===0&&e.needReadable&&(e.length>=e.highWaterMark||e.ended))return Yr("read: emitReadable",e.length,e.ended),e.length===0&&e.ended?aO(this):H4(this),null;if(t=Mee(t,e),t===0&&e.ended)return e.length===0&&aO(this),null;var n=e.needReadable;Yr("need readable",n),(e.length===0||e.length-t0?i=Lee(t,e):i=null,i===null?(e.needReadable=!0,t=0):e.length-=t,e.length===0&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&aO(this)),i!==null&&this.emit("data",i),i};function eke(t,e){if(!e.ended){if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,H4(t)}}function H4(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(Yr("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?zw.nextTick(Oee,t):Oee(t))}function Oee(t){Yr("emit readable"),t.emit("readable"),dO(t)}function qee(t,e){e.readingMore||(e.readingMore=!0,zw.nextTick(tke,t,e))}function tke(t,e){for(var r=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length1&&Kee(n.pipes,t)!==-1)&&!u&&(Yr("false write response, pause",n.awaitDrain),n.awaitDrain++,l=!0),r.pause())}function m(S){Yr("onerror",S),x(),t.removeListener("error",m),Cee(t,"error")===0&&t.emit("error",S)}ZIe(t,"error",m);function g(){t.removeListener("finish",v),x()}t.once("close",g);function v(){Yr("onfinish"),t.removeListener("close",g),x()}t.once("finish",v);function x(){Yr("unpipe"),r.unpipe(t)}return t.emit("pipe",r),n.flowing||(Yr("pipe resume"),r.resume()),t};function rke(t){return function(){var e=t._readableState;Yr("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,e.awaitDrain===0&&Cee(t,"data")&&(e.flowing=!0,dO(t))}}Ln.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(e.pipesCount===0)return this;if(e.pipesCount===1)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r),this);if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o=e.length?(e.decoder?r=e.buffer.join(""):e.buffer.length===1?r=e.buffer.head.data:r=e.buffer.concat(e.length),e.buffer.clear()):r=ske(t,e.buffer,e.decoder),r}function ske(t,e,r){var n;return to.length?o.length:t;if(s===o.length?i+=o:i+=o.slice(0,t),t-=s,t===0){s===o.length?(++n,r.next?e.head=r.next:e.head=e.tail=null):(e.head=r,r.data=o.slice(s));break}++n}return e.length-=n,i}function cke(t,e){var r=wE.allocUnsafe(t),n=e.head,i=1;for(n.data.copy(r),t-=n.data.length;n=n.next;){var o=n.data,s=t>o.length?o.length:t;if(o.copy(r,r.length-t,0,s),t-=s,t===0){s===o.length?(++i,n.next?e.head=n.next:e.head=e.tail=null):(e.head=n,n.data=o.slice(s));break}++i}return e.length-=i,r}function aO(t){var e=t._readableState;if(e.length>0)throw new Error('"endReadable()" called on non-empty stream');e.endEmitted||(e.ended=!0,zw.nextTick(dke,e,t))}function dke(t,e){!t.endEmitted&&t.length===0&&(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function Kee(t,e){for(var r=0,n=t.length;r{"use strict";f();Hee.exports=bh;var V4=gg(),Wee=Object.create(Lw());Wee.inherits=Ft();Wee.inherits(bh,V4);function uke(t,e){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(!n)return this.emit("error",new Error("write callback called multiple times"));r.writechunk=null,r.writecb=null,e!=null&&this.push(e),n(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length{"use strict";f();Jee.exports=_E;var Vee=uO(),Gee=Object.create(Lw());Gee.inherits=Ft();Gee.inherits(_E,Vee);function _E(t){if(!(this instanceof _E))return new _E(t);Vee.call(this,t)}_E.prototype._transform=function(t,e,r){r(null,t)}});var Xee=V((Cl,Yee)=>{f();Cl=Yee.exports=eO();Cl.Stream=Cl;Cl.Readable=Cl;Cl.Writable=YM();Cl.Duplex=gg();Cl.Transform=uO();Cl.PassThrough=Zee()});var G4=V((Qee,lO)=>{f();(function(t,e){"use strict";function r(B,h){if(!B)throw new Error(h||"Assertion failed")}function n(B,h){B.super_=h;var y=function(){};y.prototype=h.prototype,B.prototype=new y,B.prototype.constructor=B}function i(B,h,y){if(i.isBN(B))return B;this.negative=0,this.words=null,this.length=0,this.red=null,B!==null&&((h==="le"||h==="be")&&(y=h,h=10),this._init(B||0,h||10,y||"be"))}typeof t=="object"?t.exports=i:e.BN=i,i.BN=i,i.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=BM().Buffer}catch{}i.isBN=function(h){return h instanceof i?!0:h!==null&&typeof h=="object"&&h.constructor.wordSize===i.wordSize&&Array.isArray(h.words)},i.max=function(h,y){return h.cmp(y)>0?h:y},i.min=function(h,y){return h.cmp(y)<0?h:y},i.prototype._init=function(h,y,w){if(typeof h=="number")return this._initNumber(h,y,w);if(typeof h=="object")return this._initArray(h,y,w);y==="hex"&&(y=16),r(y===(y|0)&&y>=2&&y<=36),h=h.toString().replace(/\s+/g,"");var E=0;h[0]==="-"&&(E++,this.negative=1),E=0;E-=3)b=h[E]|h[E-1]<<8|h[E-2]<<16,this.words[_]|=b<>>26-C&67108863,C+=24,C>=26&&(C-=26,_++);else if(w==="le")for(E=0,_=0;E>>26-C&67108863,C+=24,C>=26&&(C-=26,_++);return this._strip()};function s(B,h){var y=B.charCodeAt(h);if(y>=48&&y<=57)return y-48;if(y>=65&&y<=70)return y-55;if(y>=97&&y<=102)return y-87;r(!1,"Invalid character in "+B)}function a(B,h,y){var w=s(B,y);return y-1>=h&&(w|=s(B,y-1)<<4),w}i.prototype._parseHex=function(h,y,w){this.length=Math.ceil((h.length-y)/6),this.words=new Array(this.length);for(var E=0;E=y;E-=2)C=a(h,y,E)<<_,this.words[b]|=C&67108863,_>=18?(_-=18,b+=1,this.words[b]|=C>>>26):_+=8;else{var N=h.length-y;for(E=N%2===0?y+1:y;E=18?(_-=18,b+=1,this.words[b]|=C>>>26):_+=8}this._strip()};function d(B,h,y,w){for(var E=0,_=0,b=Math.min(B.length,y),C=h;C=49?_=N-49+10:N>=17?_=N-17+10:_=N,r(N>=0&&_1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},i.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{i.prototype[Symbol.for("nodejs.util.inspect.custom")]=c}catch{i.prototype.inspect=c}else i.prototype.inspect=c;function c(){return(this.red?""}var l=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],p=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],m=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];i.prototype.toString=function(h,y){h=h||10,y=y|0||1;var w;if(h===16||h==="hex"){w="";for(var E=0,_=0,b=0;b>>24-E&16777215,E+=2,E>=26&&(E-=26,b--),_!==0||b!==this.length-1?w=l[6-N.length]+N+w:w=N+w}for(_!==0&&(w=_.toString(16)+w);w.length%y!==0;)w="0"+w;return this.negative!==0&&(w="-"+w),w}if(h===(h|0)&&h>=2&&h<=36){var M=p[h],U=m[h];w="";var G=this.clone();for(G.negative=0;!G.isZero();){var Z=G.modrn(U).toString(h);G=G.idivn(U),G.isZero()?w=Z+w:w=l[M-Z.length]+Z+w}for(this.isZero()&&(w="0"+w);w.length%y!==0;)w="0"+w;return this.negative!==0&&(w="-"+w),w}r(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var h=this.words[0];return this.length===2?h+=this.words[1]*67108864:this.length===3&&this.words[2]===1?h+=4503599627370496+this.words[1]*67108864:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-h:h},i.prototype.toJSON=function(){return this.toString(16,2)},o&&(i.prototype.toBuffer=function(h,y){return this.toArrayLike(o,h,y)}),i.prototype.toArray=function(h,y){return this.toArrayLike(Array,h,y)};var g=function(h,y){return h.allocUnsafe?h.allocUnsafe(y):new h(y)};i.prototype.toArrayLike=function(h,y,w){this._strip();var E=this.byteLength(),_=w||Math.max(1,E);r(E<=_,"byte array longer than desired length"),r(_>0,"Requested array length <= 0");var b=g(h,_),C=y==="le"?"LE":"BE";return this["_toArrayLike"+C](b,E),b},i.prototype._toArrayLikeLE=function(h,y){for(var w=0,E=0,_=0,b=0;_>8&255),w>16&255),b===6?(w>24&255),E=0,b=0):(E=C>>>24,b+=2)}if(w=0&&(h[w--]=C>>8&255),w>=0&&(h[w--]=C>>16&255),b===6?(w>=0&&(h[w--]=C>>24&255),E=0,b=0):(E=C>>>24,b+=2)}if(w>=0)for(h[w--]=E;w>=0;)h[w--]=0},Math.clz32?i.prototype._countBits=function(h){return 32-Math.clz32(h)}:i.prototype._countBits=function(h){var y=h,w=0;return y>=4096&&(w+=13,y>>>=13),y>=64&&(w+=7,y>>>=7),y>=8&&(w+=4,y>>>=4),y>=2&&(w+=2,y>>>=2),w+y},i.prototype._zeroBits=function(h){if(h===0)return 26;var y=h,w=0;return y&8191||(w+=13,y>>>=13),y&127||(w+=7,y>>>=7),y&15||(w+=4,y>>>=4),y&3||(w+=2,y>>>=2),y&1||w++,w},i.prototype.bitLength=function(){var h=this.words[this.length-1],y=this._countBits(h);return(this.length-1)*26+y};function v(B){for(var h=new Array(B.bitLength()),y=0;y>>E&1}return h}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var h=0,y=0;yh.length?this.clone().ior(h):h.clone().ior(this)},i.prototype.uor=function(h){return this.length>h.length?this.clone().iuor(h):h.clone().iuor(this)},i.prototype.iuand=function(h){var y;this.length>h.length?y=h:y=this;for(var w=0;wh.length?this.clone().iand(h):h.clone().iand(this)},i.prototype.uand=function(h){return this.length>h.length?this.clone().iuand(h):h.clone().iuand(this)},i.prototype.iuxor=function(h){var y,w;this.length>h.length?(y=this,w=h):(y=h,w=this);for(var E=0;Eh.length?this.clone().ixor(h):h.clone().ixor(this)},i.prototype.uxor=function(h){return this.length>h.length?this.clone().iuxor(h):h.clone().iuxor(this)},i.prototype.inotn=function(h){r(typeof h=="number"&&h>=0);var y=Math.ceil(h/26)|0,w=h%26;this._expand(y),w>0&&y--;for(var E=0;E0&&(this.words[E]=~this.words[E]&67108863>>26-w),this._strip()},i.prototype.notn=function(h){return this.clone().inotn(h)},i.prototype.setn=function(h,y){r(typeof h=="number"&&h>=0);var w=h/26|0,E=h%26;return this._expand(w+1),y?this.words[w]=this.words[w]|1<h.length?(w=this,E=h):(w=h,E=this);for(var _=0,b=0;b>>26;for(;_!==0&&b>>26;if(this.length=w.length,_!==0)this.words[this.length]=_,this.length++;else if(w!==this)for(;bh.length?this.clone().iadd(h):h.clone().iadd(this)},i.prototype.isub=function(h){if(h.negative!==0){h.negative=0;var y=this.iadd(h);return h.negative=1,y._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(h),this.negative=1,this._normSign();var w=this.cmp(h);if(w===0)return this.negative=0,this.length=1,this.words[0]=0,this;var E,_;w>0?(E=this,_=h):(E=h,_=this);for(var b=0,C=0;C<_.length;C++)y=(E.words[C]|0)-(_.words[C]|0)+b,b=y>>26,this.words[C]=y&67108863;for(;b!==0&&C>26,this.words[C]=y&67108863;if(b===0&&C>>26,G=N&67108863,Z=Math.min(M,h.length-1),J=Math.max(0,M-B.length+1);J<=Z;J++){var H=M-J|0;E=B.words[H]|0,_=h.words[J]|0,b=E*_+G,U+=b/67108864|0,G=b&67108863}y.words[M]=G|0,N=U|0}return N!==0?y.words[M]=N|0:y.length--,y._strip()}var S=function(h,y,w){var E=h.words,_=y.words,b=w.words,C=0,N,M,U,G=E[0]|0,Z=G&8191,J=G>>>13,H=E[1]|0,X=H&8191,te=H>>>13,ne=E[2]|0,Q=ne&8191,re=ne>>>13,ce=E[3]|0,pe=ce&8191,ye=ce>>>13,ie=E[4]|0,he=ie&8191,me=ie>>>13,Re=E[5]|0,xe=Re&8191,it=Re>>>13,Et=E[6]|0,Fe=Et&8191,mt=Et>>>13,En=E[7]|0,ke=En&8191,Pe=En>>>13,Wt=E[8]|0,Be=Wt&8191,Ee=Wt>>>13,Cr=E[9]|0,Ve=Cr&8191,Ze=Cr>>>13,en=_[0]|0,Rt=en&8191,Ye=en>>>13,pd=_[1]|0,Dt=pd&8191,Ut=pd>>>13,y0=_[2]|0,$t=y0&8191,Zt=y0>>>13,md=_[3]|0,Yt=md&8191,Ht=md>>>13,g0=_[4]|0,qt=g0&8191,Vt=g0>>>13,v0=_[5]|0,Gt=v0&8191,Xt=v0>>>13,qp=_[6]|0,ee=qp&8191,Y=qp>>>13,oe=_[7]|0,ue=oe&8191,le=oe>>>13,Ne=_[8]|0,Me=Ne&8191,Ue=Ne>>>13,Tr=_[9]|0,Lt=Tr&8191,ft=Tr>>>13;w.negative=h.negative^y.negative,w.length=19,N=Math.imul(Z,Rt),M=Math.imul(Z,Ye),M=M+Math.imul(J,Rt)|0,U=Math.imul(J,Ye);var Jr=(C+N|0)+((M&8191)<<13)|0;C=(U+(M>>>13)|0)+(Jr>>>26)|0,Jr&=67108863,N=Math.imul(X,Rt),M=Math.imul(X,Ye),M=M+Math.imul(te,Rt)|0,U=Math.imul(te,Ye),N=N+Math.imul(Z,Dt)|0,M=M+Math.imul(Z,Ut)|0,M=M+Math.imul(J,Dt)|0,U=U+Math.imul(J,Ut)|0;var dn=(C+N|0)+((M&8191)<<13)|0;C=(U+(M>>>13)|0)+(dn>>>26)|0,dn&=67108863,N=Math.imul(Q,Rt),M=Math.imul(Q,Ye),M=M+Math.imul(re,Rt)|0,U=Math.imul(re,Ye),N=N+Math.imul(X,Dt)|0,M=M+Math.imul(X,Ut)|0,M=M+Math.imul(te,Dt)|0,U=U+Math.imul(te,Ut)|0,N=N+Math.imul(Z,$t)|0,M=M+Math.imul(Z,Zt)|0,M=M+Math.imul(J,$t)|0,U=U+Math.imul(J,Zt)|0;var Hr=(C+N|0)+((M&8191)<<13)|0;C=(U+(M>>>13)|0)+(Hr>>>26)|0,Hr&=67108863,N=Math.imul(pe,Rt),M=Math.imul(pe,Ye),M=M+Math.imul(ye,Rt)|0,U=Math.imul(ye,Ye),N=N+Math.imul(Q,Dt)|0,M=M+Math.imul(Q,Ut)|0,M=M+Math.imul(re,Dt)|0,U=U+Math.imul(re,Ut)|0,N=N+Math.imul(X,$t)|0,M=M+Math.imul(X,Zt)|0,M=M+Math.imul(te,$t)|0,U=U+Math.imul(te,Zt)|0,N=N+Math.imul(Z,Yt)|0,M=M+Math.imul(Z,Ht)|0,M=M+Math.imul(J,Yt)|0,U=U+Math.imul(J,Ht)|0;var ar=(C+N|0)+((M&8191)<<13)|0;C=(U+(M>>>13)|0)+(ar>>>26)|0,ar&=67108863,N=Math.imul(he,Rt),M=Math.imul(he,Ye),M=M+Math.imul(me,Rt)|0,U=Math.imul(me,Ye),N=N+Math.imul(pe,Dt)|0,M=M+Math.imul(pe,Ut)|0,M=M+Math.imul(ye,Dt)|0,U=U+Math.imul(ye,Ut)|0,N=N+Math.imul(Q,$t)|0,M=M+Math.imul(Q,Zt)|0,M=M+Math.imul(re,$t)|0,U=U+Math.imul(re,Zt)|0,N=N+Math.imul(X,Yt)|0,M=M+Math.imul(X,Ht)|0,M=M+Math.imul(te,Yt)|0,U=U+Math.imul(te,Ht)|0,N=N+Math.imul(Z,qt)|0,M=M+Math.imul(Z,Vt)|0,M=M+Math.imul(J,qt)|0,U=U+Math.imul(J,Vt)|0;var Zr=(C+N|0)+((M&8191)<<13)|0;C=(U+(M>>>13)|0)+(Zr>>>26)|0,Zr&=67108863,N=Math.imul(xe,Rt),M=Math.imul(xe,Ye),M=M+Math.imul(it,Rt)|0,U=Math.imul(it,Ye),N=N+Math.imul(he,Dt)|0,M=M+Math.imul(he,Ut)|0,M=M+Math.imul(me,Dt)|0,U=U+Math.imul(me,Ut)|0,N=N+Math.imul(pe,$t)|0,M=M+Math.imul(pe,Zt)|0,M=M+Math.imul(ye,$t)|0,U=U+Math.imul(ye,Zt)|0,N=N+Math.imul(Q,Yt)|0,M=M+Math.imul(Q,Ht)|0,M=M+Math.imul(re,Yt)|0,U=U+Math.imul(re,Ht)|0,N=N+Math.imul(X,qt)|0,M=M+Math.imul(X,Vt)|0,M=M+Math.imul(te,qt)|0,U=U+Math.imul(te,Vt)|0,N=N+Math.imul(Z,Gt)|0,M=M+Math.imul(Z,Xt)|0,M=M+Math.imul(J,Gt)|0,U=U+Math.imul(J,Xt)|0;var Br=(C+N|0)+((M&8191)<<13)|0;C=(U+(M>>>13)|0)+(Br>>>26)|0,Br&=67108863,N=Math.imul(Fe,Rt),M=Math.imul(Fe,Ye),M=M+Math.imul(mt,Rt)|0,U=Math.imul(mt,Ye),N=N+Math.imul(xe,Dt)|0,M=M+Math.imul(xe,Ut)|0,M=M+Math.imul(it,Dt)|0,U=U+Math.imul(it,Ut)|0,N=N+Math.imul(he,$t)|0,M=M+Math.imul(he,Zt)|0,M=M+Math.imul(me,$t)|0,U=U+Math.imul(me,Zt)|0,N=N+Math.imul(pe,Yt)|0,M=M+Math.imul(pe,Ht)|0,M=M+Math.imul(ye,Yt)|0,U=U+Math.imul(ye,Ht)|0,N=N+Math.imul(Q,qt)|0,M=M+Math.imul(Q,Vt)|0,M=M+Math.imul(re,qt)|0,U=U+Math.imul(re,Vt)|0,N=N+Math.imul(X,Gt)|0,M=M+Math.imul(X,Xt)|0,M=M+Math.imul(te,Gt)|0,U=U+Math.imul(te,Xt)|0,N=N+Math.imul(Z,ee)|0,M=M+Math.imul(Z,Y)|0,M=M+Math.imul(J,ee)|0,U=U+Math.imul(J,Y)|0;var ha=(C+N|0)+((M&8191)<<13)|0;C=(U+(M>>>13)|0)+(ha>>>26)|0,ha&=67108863,N=Math.imul(ke,Rt),M=Math.imul(ke,Ye),M=M+Math.imul(Pe,Rt)|0,U=Math.imul(Pe,Ye),N=N+Math.imul(Fe,Dt)|0,M=M+Math.imul(Fe,Ut)|0,M=M+Math.imul(mt,Dt)|0,U=U+Math.imul(mt,Ut)|0,N=N+Math.imul(xe,$t)|0,M=M+Math.imul(xe,Zt)|0,M=M+Math.imul(it,$t)|0,U=U+Math.imul(it,Zt)|0,N=N+Math.imul(he,Yt)|0,M=M+Math.imul(he,Ht)|0,M=M+Math.imul(me,Yt)|0,U=U+Math.imul(me,Ht)|0,N=N+Math.imul(pe,qt)|0,M=M+Math.imul(pe,Vt)|0,M=M+Math.imul(ye,qt)|0,U=U+Math.imul(ye,Vt)|0,N=N+Math.imul(Q,Gt)|0,M=M+Math.imul(Q,Xt)|0,M=M+Math.imul(re,Gt)|0,U=U+Math.imul(re,Xt)|0,N=N+Math.imul(X,ee)|0,M=M+Math.imul(X,Y)|0,M=M+Math.imul(te,ee)|0,U=U+Math.imul(te,Y)|0,N=N+Math.imul(Z,ue)|0,M=M+Math.imul(Z,le)|0,M=M+Math.imul(J,ue)|0,U=U+Math.imul(J,le)|0;var Si=(C+N|0)+((M&8191)<<13)|0;C=(U+(M>>>13)|0)+(Si>>>26)|0,Si&=67108863,N=Math.imul(Be,Rt),M=Math.imul(Be,Ye),M=M+Math.imul(Ee,Rt)|0,U=Math.imul(Ee,Ye),N=N+Math.imul(ke,Dt)|0,M=M+Math.imul(ke,Ut)|0,M=M+Math.imul(Pe,Dt)|0,U=U+Math.imul(Pe,Ut)|0,N=N+Math.imul(Fe,$t)|0,M=M+Math.imul(Fe,Zt)|0,M=M+Math.imul(mt,$t)|0,U=U+Math.imul(mt,Zt)|0,N=N+Math.imul(xe,Yt)|0,M=M+Math.imul(xe,Ht)|0,M=M+Math.imul(it,Yt)|0,U=U+Math.imul(it,Ht)|0,N=N+Math.imul(he,qt)|0,M=M+Math.imul(he,Vt)|0,M=M+Math.imul(me,qt)|0,U=U+Math.imul(me,Vt)|0,N=N+Math.imul(pe,Gt)|0,M=M+Math.imul(pe,Xt)|0,M=M+Math.imul(ye,Gt)|0,U=U+Math.imul(ye,Xt)|0,N=N+Math.imul(Q,ee)|0,M=M+Math.imul(Q,Y)|0,M=M+Math.imul(re,ee)|0,U=U+Math.imul(re,Y)|0,N=N+Math.imul(X,ue)|0,M=M+Math.imul(X,le)|0,M=M+Math.imul(te,ue)|0,U=U+Math.imul(te,le)|0,N=N+Math.imul(Z,Me)|0,M=M+Math.imul(Z,Ue)|0,M=M+Math.imul(J,Me)|0,U=U+Math.imul(J,Ue)|0;var Ui=(C+N|0)+((M&8191)<<13)|0;C=(U+(M>>>13)|0)+(Ui>>>26)|0,Ui&=67108863,N=Math.imul(Ve,Rt),M=Math.imul(Ve,Ye),M=M+Math.imul(Ze,Rt)|0,U=Math.imul(Ze,Ye),N=N+Math.imul(Be,Dt)|0,M=M+Math.imul(Be,Ut)|0,M=M+Math.imul(Ee,Dt)|0,U=U+Math.imul(Ee,Ut)|0,N=N+Math.imul(ke,$t)|0,M=M+Math.imul(ke,Zt)|0,M=M+Math.imul(Pe,$t)|0,U=U+Math.imul(Pe,Zt)|0,N=N+Math.imul(Fe,Yt)|0,M=M+Math.imul(Fe,Ht)|0,M=M+Math.imul(mt,Yt)|0,U=U+Math.imul(mt,Ht)|0,N=N+Math.imul(xe,qt)|0,M=M+Math.imul(xe,Vt)|0,M=M+Math.imul(it,qt)|0,U=U+Math.imul(it,Vt)|0,N=N+Math.imul(he,Gt)|0,M=M+Math.imul(he,Xt)|0,M=M+Math.imul(me,Gt)|0,U=U+Math.imul(me,Xt)|0,N=N+Math.imul(pe,ee)|0,M=M+Math.imul(pe,Y)|0,M=M+Math.imul(ye,ee)|0,U=U+Math.imul(ye,Y)|0,N=N+Math.imul(Q,ue)|0,M=M+Math.imul(Q,le)|0,M=M+Math.imul(re,ue)|0,U=U+Math.imul(re,le)|0,N=N+Math.imul(X,Me)|0,M=M+Math.imul(X,Ue)|0,M=M+Math.imul(te,Me)|0,U=U+Math.imul(te,Ue)|0,N=N+Math.imul(Z,Lt)|0,M=M+Math.imul(Z,ft)|0,M=M+Math.imul(J,Lt)|0,U=U+Math.imul(J,ft)|0;var $r=(C+N|0)+((M&8191)<<13)|0;C=(U+(M>>>13)|0)+($r>>>26)|0,$r&=67108863,N=Math.imul(Ve,Dt),M=Math.imul(Ve,Ut),M=M+Math.imul(Ze,Dt)|0,U=Math.imul(Ze,Ut),N=N+Math.imul(Be,$t)|0,M=M+Math.imul(Be,Zt)|0,M=M+Math.imul(Ee,$t)|0,U=U+Math.imul(Ee,Zt)|0,N=N+Math.imul(ke,Yt)|0,M=M+Math.imul(ke,Ht)|0,M=M+Math.imul(Pe,Yt)|0,U=U+Math.imul(Pe,Ht)|0,N=N+Math.imul(Fe,qt)|0,M=M+Math.imul(Fe,Vt)|0,M=M+Math.imul(mt,qt)|0,U=U+Math.imul(mt,Vt)|0,N=N+Math.imul(xe,Gt)|0,M=M+Math.imul(xe,Xt)|0,M=M+Math.imul(it,Gt)|0,U=U+Math.imul(it,Xt)|0,N=N+Math.imul(he,ee)|0,M=M+Math.imul(he,Y)|0,M=M+Math.imul(me,ee)|0,U=U+Math.imul(me,Y)|0,N=N+Math.imul(pe,ue)|0,M=M+Math.imul(pe,le)|0,M=M+Math.imul(ye,ue)|0,U=U+Math.imul(ye,le)|0,N=N+Math.imul(Q,Me)|0,M=M+Math.imul(Q,Ue)|0,M=M+Math.imul(re,Me)|0,U=U+Math.imul(re,Ue)|0,N=N+Math.imul(X,Lt)|0,M=M+Math.imul(X,ft)|0,M=M+Math.imul(te,Lt)|0,U=U+Math.imul(te,ft)|0;var Ai=(C+N|0)+((M&8191)<<13)|0;C=(U+(M>>>13)|0)+(Ai>>>26)|0,Ai&=67108863,N=Math.imul(Ve,$t),M=Math.imul(Ve,Zt),M=M+Math.imul(Ze,$t)|0,U=Math.imul(Ze,Zt),N=N+Math.imul(Be,Yt)|0,M=M+Math.imul(Be,Ht)|0,M=M+Math.imul(Ee,Yt)|0,U=U+Math.imul(Ee,Ht)|0,N=N+Math.imul(ke,qt)|0,M=M+Math.imul(ke,Vt)|0,M=M+Math.imul(Pe,qt)|0,U=U+Math.imul(Pe,Vt)|0,N=N+Math.imul(Fe,Gt)|0,M=M+Math.imul(Fe,Xt)|0,M=M+Math.imul(mt,Gt)|0,U=U+Math.imul(mt,Xt)|0,N=N+Math.imul(xe,ee)|0,M=M+Math.imul(xe,Y)|0,M=M+Math.imul(it,ee)|0,U=U+Math.imul(it,Y)|0,N=N+Math.imul(he,ue)|0,M=M+Math.imul(he,le)|0,M=M+Math.imul(me,ue)|0,U=U+Math.imul(me,le)|0,N=N+Math.imul(pe,Me)|0,M=M+Math.imul(pe,Ue)|0,M=M+Math.imul(ye,Me)|0,U=U+Math.imul(ye,Ue)|0,N=N+Math.imul(Q,Lt)|0,M=M+Math.imul(Q,ft)|0,M=M+Math.imul(re,Lt)|0,U=U+Math.imul(re,ft)|0;var qi=(C+N|0)+((M&8191)<<13)|0;C=(U+(M>>>13)|0)+(qi>>>26)|0,qi&=67108863,N=Math.imul(Ve,Yt),M=Math.imul(Ve,Ht),M=M+Math.imul(Ze,Yt)|0,U=Math.imul(Ze,Ht),N=N+Math.imul(Be,qt)|0,M=M+Math.imul(Be,Vt)|0,M=M+Math.imul(Ee,qt)|0,U=U+Math.imul(Ee,Vt)|0,N=N+Math.imul(ke,Gt)|0,M=M+Math.imul(ke,Xt)|0,M=M+Math.imul(Pe,Gt)|0,U=U+Math.imul(Pe,Xt)|0,N=N+Math.imul(Fe,ee)|0,M=M+Math.imul(Fe,Y)|0,M=M+Math.imul(mt,ee)|0,U=U+Math.imul(mt,Y)|0,N=N+Math.imul(xe,ue)|0,M=M+Math.imul(xe,le)|0,M=M+Math.imul(it,ue)|0,U=U+Math.imul(it,le)|0,N=N+Math.imul(he,Me)|0,M=M+Math.imul(he,Ue)|0,M=M+Math.imul(me,Me)|0,U=U+Math.imul(me,Ue)|0,N=N+Math.imul(pe,Lt)|0,M=M+Math.imul(pe,ft)|0,M=M+Math.imul(ye,Lt)|0,U=U+Math.imul(ye,ft)|0;var xo=(C+N|0)+((M&8191)<<13)|0;C=(U+(M>>>13)|0)+(xo>>>26)|0,xo&=67108863,N=Math.imul(Ve,qt),M=Math.imul(Ve,Vt),M=M+Math.imul(Ze,qt)|0,U=Math.imul(Ze,Vt),N=N+Math.imul(Be,Gt)|0,M=M+Math.imul(Be,Xt)|0,M=M+Math.imul(Ee,Gt)|0,U=U+Math.imul(Ee,Xt)|0,N=N+Math.imul(ke,ee)|0,M=M+Math.imul(ke,Y)|0,M=M+Math.imul(Pe,ee)|0,U=U+Math.imul(Pe,Y)|0,N=N+Math.imul(Fe,ue)|0,M=M+Math.imul(Fe,le)|0,M=M+Math.imul(mt,ue)|0,U=U+Math.imul(mt,le)|0,N=N+Math.imul(xe,Me)|0,M=M+Math.imul(xe,Ue)|0,M=M+Math.imul(it,Me)|0,U=U+Math.imul(it,Ue)|0,N=N+Math.imul(he,Lt)|0,M=M+Math.imul(he,ft)|0,M=M+Math.imul(me,Lt)|0,U=U+Math.imul(me,ft)|0;var pa=(C+N|0)+((M&8191)<<13)|0;C=(U+(M>>>13)|0)+(pa>>>26)|0,pa&=67108863,N=Math.imul(Ve,Gt),M=Math.imul(Ve,Xt),M=M+Math.imul(Ze,Gt)|0,U=Math.imul(Ze,Xt),N=N+Math.imul(Be,ee)|0,M=M+Math.imul(Be,Y)|0,M=M+Math.imul(Ee,ee)|0,U=U+Math.imul(Ee,Y)|0,N=N+Math.imul(ke,ue)|0,M=M+Math.imul(ke,le)|0,M=M+Math.imul(Pe,ue)|0,U=U+Math.imul(Pe,le)|0,N=N+Math.imul(Fe,Me)|0,M=M+Math.imul(Fe,Ue)|0,M=M+Math.imul(mt,Me)|0,U=U+Math.imul(mt,Ue)|0,N=N+Math.imul(xe,Lt)|0,M=M+Math.imul(xe,ft)|0,M=M+Math.imul(it,Lt)|0,U=U+Math.imul(it,ft)|0;var Xo=(C+N|0)+((M&8191)<<13)|0;C=(U+(M>>>13)|0)+(Xo>>>26)|0,Xo&=67108863,N=Math.imul(Ve,ee),M=Math.imul(Ve,Y),M=M+Math.imul(Ze,ee)|0,U=Math.imul(Ze,Y),N=N+Math.imul(Be,ue)|0,M=M+Math.imul(Be,le)|0,M=M+Math.imul(Ee,ue)|0,U=U+Math.imul(Ee,le)|0,N=N+Math.imul(ke,Me)|0,M=M+Math.imul(ke,Ue)|0,M=M+Math.imul(Pe,Me)|0,U=U+Math.imul(Pe,Ue)|0,N=N+Math.imul(Fe,Lt)|0,M=M+Math.imul(Fe,ft)|0,M=M+Math.imul(mt,Lt)|0,U=U+Math.imul(mt,ft)|0;var xc=(C+N|0)+((M&8191)<<13)|0;C=(U+(M>>>13)|0)+(xc>>>26)|0,xc&=67108863,N=Math.imul(Ve,ue),M=Math.imul(Ve,le),M=M+Math.imul(Ze,ue)|0,U=Math.imul(Ze,le),N=N+Math.imul(Be,Me)|0,M=M+Math.imul(Be,Ue)|0,M=M+Math.imul(Ee,Me)|0,U=U+Math.imul(Ee,Ue)|0,N=N+Math.imul(ke,Lt)|0,M=M+Math.imul(ke,ft)|0,M=M+Math.imul(Pe,Lt)|0,U=U+Math.imul(Pe,ft)|0;var Lp=(C+N|0)+((M&8191)<<13)|0;C=(U+(M>>>13)|0)+(Lp>>>26)|0,Lp&=67108863,N=Math.imul(Ve,Me),M=Math.imul(Ve,Ue),M=M+Math.imul(Ze,Me)|0,U=Math.imul(Ze,Ue),N=N+Math.imul(Be,Lt)|0,M=M+Math.imul(Be,ft)|0,M=M+Math.imul(Ee,Lt)|0,U=U+Math.imul(Ee,ft)|0;var Kp=(C+N|0)+((M&8191)<<13)|0;C=(U+(M>>>13)|0)+(Kp>>>26)|0,Kp&=67108863,N=Math.imul(Ve,Lt),M=Math.imul(Ve,ft),M=M+Math.imul(Ze,Lt)|0,U=Math.imul(Ze,ft);var gl=(C+N|0)+((M&8191)<<13)|0;return C=(U+(M>>>13)|0)+(gl>>>26)|0,gl&=67108863,b[0]=Jr,b[1]=dn,b[2]=Hr,b[3]=ar,b[4]=Zr,b[5]=Br,b[6]=ha,b[7]=Si,b[8]=Ui,b[9]=$r,b[10]=Ai,b[11]=qi,b[12]=xo,b[13]=pa,b[14]=Xo,b[15]=xc,b[16]=Lp,b[17]=Kp,b[18]=gl,C!==0&&(b[19]=C,w.length++),w};Math.imul||(S=x);function P(B,h,y){y.negative=h.negative^B.negative,y.length=B.length+h.length;for(var w=0,E=0,_=0;_>>26)|0,E+=b>>>26,b&=67108863}y.words[_]=C,w=b,b=E}return w!==0?y.words[_]=w:y.length--,y._strip()}function A(B,h,y){return P(B,h,y)}i.prototype.mulTo=function(h,y){var w,E=this.length+h.length;return this.length===10&&h.length===10?w=S(this,h,y):E<63?w=x(this,h,y):E<1024?w=P(this,h,y):w=A(this,h,y),w};function $(B,h){this.x=B,this.y=h}$.prototype.makeRBT=function(h){for(var y=new Array(h),w=i.prototype._countBits(h)-1,E=0;E>=1;return E},$.prototype.permute=function(h,y,w,E,_,b){for(var C=0;C>>1)_++;return 1<<_+1+E},$.prototype.conjugate=function(h,y,w){if(!(w<=1))for(var E=0;E>>13,w[2*b+1]=_&8191,_=_>>>13;for(b=2*y;b>=26,w+=_/67108864|0,w+=b>>>26,this.words[E]=b&67108863}return w!==0&&(this.words[E]=w,this.length++),y?this.ineg():this},i.prototype.muln=function(h){return this.clone().imuln(h)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(h){var y=v(h);if(y.length===0)return new i(1);for(var w=this,E=0;E=0);var y=h%26,w=(h-y)/26,E=67108863>>>26-y<<26-y,_;if(y!==0){var b=0;for(_=0;_>>26-y}b&&(this.words[_]=b,this.length++)}if(w!==0){for(_=this.length-1;_>=0;_--)this.words[_+w]=this.words[_];for(_=0;_=0);var E;y?E=(y-y%26)/26:E=0;var _=h%26,b=Math.min((h-_)/26,this.length),C=67108863^67108863>>>_<<_,N=w;if(E-=b,E=Math.max(0,E),N){for(var M=0;Mb)for(this.length-=b,M=0;M=0&&(U!==0||M>=E);M--){var G=this.words[M]|0;this.words[M]=U<<26-_|G>>>_,U=G&C}return N&&U!==0&&(N.words[N.length++]=U),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.ishrn=function(h,y,w){return r(this.negative===0),this.iushrn(h,y,w)},i.prototype.shln=function(h){return this.clone().ishln(h)},i.prototype.ushln=function(h){return this.clone().iushln(h)},i.prototype.shrn=function(h){return this.clone().ishrn(h)},i.prototype.ushrn=function(h){return this.clone().iushrn(h)},i.prototype.testn=function(h){r(typeof h=="number"&&h>=0);var y=h%26,w=(h-y)/26,E=1<=0);var y=h%26,w=(h-y)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=w)return this;if(y!==0&&w++,this.length=Math.min(w,this.length),y!==0){var E=67108863^67108863>>>y<=67108864;y++)this.words[y]-=67108864,y===this.length-1?this.words[y+1]=1:this.words[y+1]++;return this.length=Math.max(this.length,y+1),this},i.prototype.isubn=function(h){if(r(typeof h=="number"),r(h<67108864),h<0)return this.iaddn(-h);if(this.negative!==0)return this.negative=0,this.iaddn(h),this.negative=1,this;if(this.words[0]-=h,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var y=0;y>26)-(N/67108864|0),this.words[_+w]=b&67108863}for(;_>26,this.words[_+w]=b&67108863;if(C===0)return this._strip();for(r(C===-1),C=0,_=0;_>26,this.words[_]=b&67108863;return this.negative=1,this._strip()},i.prototype._wordDiv=function(h,y){var w=this.length-h.length,E=this.clone(),_=h,b=_.words[_.length-1]|0,C=this._countBits(b);w=26-C,w!==0&&(_=_.ushln(w),E.iushln(w),b=_.words[_.length-1]|0);var N=E.length-_.length,M;if(y!=="mod"){M=new i(null),M.length=N+1,M.words=new Array(M.length);for(var U=0;U=0;Z--){var J=(E.words[_.length+Z]|0)*67108864+(E.words[_.length+Z-1]|0);for(J=Math.min(J/b|0,67108863),E._ishlnsubmul(_,J,Z);E.negative!==0;)J--,E.negative=0,E._ishlnsubmul(_,1,Z),E.isZero()||(E.negative^=1);M&&(M.words[Z]=J)}return M&&M._strip(),E._strip(),y!=="div"&&w!==0&&E.iushrn(w),{div:M||null,mod:E}},i.prototype.divmod=function(h,y,w){if(r(!h.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var E,_,b;return this.negative!==0&&h.negative===0?(b=this.neg().divmod(h,y),y!=="mod"&&(E=b.div.neg()),y!=="div"&&(_=b.mod.neg(),w&&_.negative!==0&&_.iadd(h)),{div:E,mod:_}):this.negative===0&&h.negative!==0?(b=this.divmod(h.neg(),y),y!=="mod"&&(E=b.div.neg()),{div:E,mod:b.mod}):this.negative&h.negative?(b=this.neg().divmod(h.neg(),y),y!=="div"&&(_=b.mod.neg(),w&&_.negative!==0&&_.isub(h)),{div:b.div,mod:_}):h.length>this.length||this.cmp(h)<0?{div:new i(0),mod:this}:h.length===1?y==="div"?{div:this.divn(h.words[0]),mod:null}:y==="mod"?{div:null,mod:new i(this.modrn(h.words[0]))}:{div:this.divn(h.words[0]),mod:new i(this.modrn(h.words[0]))}:this._wordDiv(h,y)},i.prototype.div=function(h){return this.divmod(h,"div",!1).div},i.prototype.mod=function(h){return this.divmod(h,"mod",!1).mod},i.prototype.umod=function(h){return this.divmod(h,"mod",!0).mod},i.prototype.divRound=function(h){var y=this.divmod(h);if(y.mod.isZero())return y.div;var w=y.div.negative!==0?y.mod.isub(h):y.mod,E=h.ushrn(1),_=h.andln(1),b=w.cmp(E);return b<0||_===1&&b===0?y.div:y.div.negative!==0?y.div.isubn(1):y.div.iaddn(1)},i.prototype.modrn=function(h){var y=h<0;y&&(h=-h),r(h<=67108863);for(var w=(1<<26)%h,E=0,_=this.length-1;_>=0;_--)E=(w*E+(this.words[_]|0))%h;return y?-E:E},i.prototype.modn=function(h){return this.modrn(h)},i.prototype.idivn=function(h){var y=h<0;y&&(h=-h),r(h<=67108863);for(var w=0,E=this.length-1;E>=0;E--){var _=(this.words[E]|0)+w*67108864;this.words[E]=_/h|0,w=_%h}return this._strip(),y?this.ineg():this},i.prototype.divn=function(h){return this.clone().idivn(h)},i.prototype.egcd=function(h){r(h.negative===0),r(!h.isZero());var y=this,w=h.clone();y.negative!==0?y=y.umod(h):y=y.clone();for(var E=new i(1),_=new i(0),b=new i(0),C=new i(1),N=0;y.isEven()&&w.isEven();)y.iushrn(1),w.iushrn(1),++N;for(var M=w.clone(),U=y.clone();!y.isZero();){for(var G=0,Z=1;!(y.words[0]&Z)&&G<26;++G,Z<<=1);if(G>0)for(y.iushrn(G);G-- >0;)(E.isOdd()||_.isOdd())&&(E.iadd(M),_.isub(U)),E.iushrn(1),_.iushrn(1);for(var J=0,H=1;!(w.words[0]&H)&&J<26;++J,H<<=1);if(J>0)for(w.iushrn(J);J-- >0;)(b.isOdd()||C.isOdd())&&(b.iadd(M),C.isub(U)),b.iushrn(1),C.iushrn(1);y.cmp(w)>=0?(y.isub(w),E.isub(b),_.isub(C)):(w.isub(y),b.isub(E),C.isub(_))}return{a:b,b:C,gcd:w.iushln(N)}},i.prototype._invmp=function(h){r(h.negative===0),r(!h.isZero());var y=this,w=h.clone();y.negative!==0?y=y.umod(h):y=y.clone();for(var E=new i(1),_=new i(0),b=w.clone();y.cmpn(1)>0&&w.cmpn(1)>0;){for(var C=0,N=1;!(y.words[0]&N)&&C<26;++C,N<<=1);if(C>0)for(y.iushrn(C);C-- >0;)E.isOdd()&&E.iadd(b),E.iushrn(1);for(var M=0,U=1;!(w.words[0]&U)&&M<26;++M,U<<=1);if(M>0)for(w.iushrn(M);M-- >0;)_.isOdd()&&_.iadd(b),_.iushrn(1);y.cmp(w)>=0?(y.isub(w),E.isub(_)):(w.isub(y),_.isub(E))}var G;return y.cmpn(1)===0?G=E:G=_,G.cmpn(0)<0&&G.iadd(h),G},i.prototype.gcd=function(h){if(this.isZero())return h.abs();if(h.isZero())return this.abs();var y=this.clone(),w=h.clone();y.negative=0,w.negative=0;for(var E=0;y.isEven()&&w.isEven();E++)y.iushrn(1),w.iushrn(1);do{for(;y.isEven();)y.iushrn(1);for(;w.isEven();)w.iushrn(1);var _=y.cmp(w);if(_<0){var b=y;y=w,w=b}else if(_===0||w.cmpn(1)===0)break;y.isub(w)}while(!0);return w.iushln(E)},i.prototype.invm=function(h){return this.egcd(h).a.umod(h)},i.prototype.isEven=function(){return(this.words[0]&1)===0},i.prototype.isOdd=function(){return(this.words[0]&1)===1},i.prototype.andln=function(h){return this.words[0]&h},i.prototype.bincn=function(h){r(typeof h=="number");var y=h%26,w=(h-y)/26,E=1<>>26,C&=67108863,this.words[b]=C}return _!==0&&(this.words[b]=_,this.length++),this},i.prototype.isZero=function(){return this.length===1&&this.words[0]===0},i.prototype.cmpn=function(h){var y=h<0;if(this.negative!==0&&!y)return-1;if(this.negative===0&&y)return 1;this._strip();var w;if(this.length>1)w=1;else{y&&(h=-h),r(h<=67108863,"Number is too big");var E=this.words[0]|0;w=E===h?0:Eh.length)return 1;if(this.length=0;w--){var E=this.words[w]|0,_=h.words[w]|0;if(E!==_){E<_?y=-1:E>_&&(y=1);break}}return y},i.prototype.gtn=function(h){return this.cmpn(h)===1},i.prototype.gt=function(h){return this.cmp(h)===1},i.prototype.gten=function(h){return this.cmpn(h)>=0},i.prototype.gte=function(h){return this.cmp(h)>=0},i.prototype.ltn=function(h){return this.cmpn(h)===-1},i.prototype.lt=function(h){return this.cmp(h)===-1},i.prototype.lten=function(h){return this.cmpn(h)<=0},i.prototype.lte=function(h){return this.cmp(h)<=0},i.prototype.eqn=function(h){return this.cmpn(h)===0},i.prototype.eq=function(h){return this.cmp(h)===0},i.red=function(h){return new I(h)},i.prototype.toRed=function(h){return r(!this.red,"Already a number in reduction context"),r(this.negative===0,"red works only with positives"),h.convertTo(this)._forceRed(h)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(h){return this.red=h,this},i.prototype.forceRed=function(h){return r(!this.red,"Already a number in reduction context"),this._forceRed(h)},i.prototype.redAdd=function(h){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,h)},i.prototype.redIAdd=function(h){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,h)},i.prototype.redSub=function(h){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,h)},i.prototype.redISub=function(h){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,h)},i.prototype.redShl=function(h){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,h)},i.prototype.redMul=function(h){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,h),this.red.mul(this,h)},i.prototype.redIMul=function(h){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,h),this.red.imul(this,h)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(h){return r(this.red&&!h.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,h)};var j={k256:null,p224:null,p192:null,p25519:null};function L(B,h){this.name=B,this.p=new i(h,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}L.prototype._tmp=function(){var h=new i(null);return h.words=new Array(Math.ceil(this.n/13)),h},L.prototype.ireduce=function(h){var y=h,w;do this.split(y,this.tmp),y=this.imulK(y),y=y.iadd(this.tmp),w=y.bitLength();while(w>this.n);var E=w0?y.isub(this.p):y.strip!==void 0?y.strip():y._strip(),y},L.prototype.split=function(h,y){h.iushrn(this.n,0,y)},L.prototype.imulK=function(h){return h.imul(this.k)};function F(){L.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(F,L),F.prototype.split=function(h,y){for(var w=4194303,E=Math.min(h.length,9),_=0;_>>22,b=C}b>>>=22,h.words[_-10]=b,b===0&&h.length>10?h.length-=10:h.length-=9},F.prototype.imulK=function(h){h.words[h.length]=0,h.words[h.length+1]=0,h.length+=2;for(var y=0,w=0;w>>=26,h.words[w]=_,y=E}return y!==0&&(h.words[h.length++]=y),h},i._prime=function(h){if(j[h])return j[h];var y;if(h==="k256")y=new F;else if(h==="p224")y=new K;else if(h==="p192")y=new W;else if(h==="p25519")y=new q;else throw new Error("Unknown prime "+h);return j[h]=y,y};function I(B){if(typeof B=="string"){var h=i._prime(B);this.m=h.p,this.prime=h}else r(B.gtn(1),"modulus must be greater than 1"),this.m=B,this.prime=null}I.prototype._verify1=function(h){r(h.negative===0,"red works only with positives"),r(h.red,"red works only with red numbers")},I.prototype._verify2=function(h,y){r((h.negative|y.negative)===0,"red works only with positives"),r(h.red&&h.red===y.red,"red works only with red numbers")},I.prototype.imod=function(h){return this.prime?this.prime.ireduce(h)._forceRed(this):(u(h,h.umod(this.m)._forceRed(this)),h)},I.prototype.neg=function(h){return h.isZero()?h.clone():this.m.sub(h)._forceRed(this)},I.prototype.add=function(h,y){this._verify2(h,y);var w=h.add(y);return w.cmp(this.m)>=0&&w.isub(this.m),w._forceRed(this)},I.prototype.iadd=function(h,y){this._verify2(h,y);var w=h.iadd(y);return w.cmp(this.m)>=0&&w.isub(this.m),w},I.prototype.sub=function(h,y){this._verify2(h,y);var w=h.sub(y);return w.cmpn(0)<0&&w.iadd(this.m),w._forceRed(this)},I.prototype.isub=function(h,y){this._verify2(h,y);var w=h.isub(y);return w.cmpn(0)<0&&w.iadd(this.m),w},I.prototype.shl=function(h,y){return this._verify1(h),this.imod(h.ushln(y))},I.prototype.imul=function(h,y){return this._verify2(h,y),this.imod(h.imul(y))},I.prototype.mul=function(h,y){return this._verify2(h,y),this.imod(h.mul(y))},I.prototype.isqr=function(h){return this.imul(h,h.clone())},I.prototype.sqr=function(h){return this.mul(h,h)},I.prototype.sqrt=function(h){if(h.isZero())return h.clone();var y=this.m.andln(3);if(r(y%2===1),y===3){var w=this.m.add(new i(1)).iushrn(2);return this.pow(h,w)}for(var E=this.m.subn(1),_=0;!E.isZero()&&E.andln(1)===0;)_++,E.iushrn(1);r(!E.isZero());var b=new i(1).toRed(this),C=b.redNeg(),N=this.m.subn(1).iushrn(1),M=this.m.bitLength();for(M=new i(2*M*M).toRed(this);this.pow(M,N).cmp(C)!==0;)M.redIAdd(C);for(var U=this.pow(M,E),G=this.pow(h,E.addn(1).iushrn(1)),Z=this.pow(h,E),J=_;Z.cmp(b)!==0;){for(var H=Z,X=0;H.cmp(b)!==0;X++)H=H.redSqr();r(X=0;_--){for(var U=y.words[_],G=M-1;G>=0;G--){var Z=U>>G&1;if(b!==E[0]&&(b=this.sqr(b)),Z===0&&C===0){N=0;continue}C<<=1,C|=Z,N++,!(N!==w&&(_!==0||G!==0))&&(b=this.mul(b,E[C]),N=0,C=0)}M=26}return b},I.prototype.convertTo=function(h){var y=h.umod(this.m);return y===h?y.clone():y},I.prototype.convertFrom=function(h){var y=h.clone();return y.red=null,y},i.mont=function(h){return new T(h)};function T(B){I.call(this,B),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}n(T,I),T.prototype.convertTo=function(h){return this.imod(h.ushln(this.shift))},T.prototype.convertFrom=function(h){var y=this.imod(h.mul(this.rinv));return y.red=null,y},T.prototype.imul=function(h,y){if(h.isZero()||y.isZero())return h.words[0]=0,h.length=1,h;var w=h.imul(y),E=w.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),_=w.isub(E).iushrn(this.shift),b=_;return _.cmp(this.m)>=0?b=_.isub(this.m):_.cmpn(0)<0&&(b=_.iadd(this.m)),b._forceRed(this)},T.prototype.mul=function(h,y){if(h.isZero()||y.isZero())return new i(0)._forceRed(this);var w=h.mul(y),E=w.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),_=w.isub(E).iushrn(this.shift),b=_;return _.cmp(this.m)>=0?b=_.isub(this.m):_.cmpn(0)<0&&(b=_.iadd(this.m)),b._forceRed(this)},T.prototype.invm=function(h){var y=this.imod(h._invmp(this.m).mul(this.r2));return y._forceRed(this)}})(typeof lO>"u"||lO,Qee)});var J4=V((Gvt,rte)=>{f();var Ww=G4(),fke=eg();function hke(t){var e=ete(t),r=e.toRed(Ww.mont(t.modulus)).redPow(new Ww(t.publicExponent)).fromRed();return{blinder:r,unblinder:e.invm(t.modulus)}}function ete(t){var e=t.modulus.byteLength(),r;do r=new Ww(fke(e));while(r.cmp(t.modulus)>=0||!r.umod(t.prime1)||!r.umod(t.prime2));return r}function tte(t,e){var r=hke(e),n=e.modulus.byteLength(),i=new Ww(t).mul(r.blinder).umod(e.modulus),o=i.toRed(Ww.mont(e.prime1)),s=i.toRed(Ww.mont(e.prime2)),a=e.coefficient,d=e.prime1,u=e.prime2,c=o.redPow(e.exponent1).fromRed(),l=s.redPow(e.exponent2).fromRed(),p=c.isub(l).imul(a).umod(d).imul(u);return l.iadd(p).imul(r.unblinder).umod(e.modulus).toArrayLike(O.Buffer,"be",n)}tte.getr=ete;rte.exports=tte});var nte=V((Zvt,pke)=>{pke.exports={name:"elliptic",version:"6.5.7",description:"EC cryptography",main:"lib/elliptic.js",files:["lib"],scripts:{lint:"eslint lib test","lint:fix":"npm run lint -- --fix",unit:"istanbul test _mocha --reporter=spec test/index.js",test:"npm run lint && npm run unit",version:"grunt dist && git add dist/"},repository:{type:"git",url:"git@github.com:indutny/elliptic"},keywords:["EC","Elliptic","curve","Cryptography"],author:"Fedor Indutny ",license:"MIT",bugs:{url:"https://github.com/indutny/elliptic/issues"},homepage:"https://github.com/indutny/elliptic",devDependencies:{brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},dependencies:{"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"}}});var fO=V(ste=>{"use strict";f();var Z4=ste;function mke(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if(typeof t!="string"){for(var n=0;n>8,s=i&255;o?r.push(o,s):r.push(s)}return r}Z4.toArray=mke;function ite(t){return t.length===1?"0"+t:t}Z4.zero2=ite;function ote(t){for(var e="",r=0;r{"use strict";f();var Tu=ate,yke=Mo(),gke=Cc(),Y4=fO();Tu.assert=gke;Tu.toArray=Y4.toArray;Tu.zero2=Y4.zero2;Tu.toHex=Y4.toHex;Tu.encode=Y4.encode;function vke(t,e,r){var n=new Array(Math.max(t.bitLength(),r)+1),i;for(i=0;i(o>>1)-1?a=(o>>1)-d:a=d,s.isubn(a)):a=0,n[i]=a,s.iushrn(1)}return n}Tu.getNAF=vke;function bke(t,e){var r=[[],[]];t=t.clone(),e=e.clone();for(var n=0,i=0,o;t.cmpn(-n)>0||e.cmpn(-i)>0;){var s=t.andln(3)+n&3,a=e.andln(3)+i&3;s===3&&(s=-1),a===3&&(a=-1);var d;s&1?(o=t.andln(7)+n&7,(o===3||o===5)&&a===2?d=-s:d=s):d=0,r[0].push(d);var u;a&1?(o=e.andln(7)+i&7,(o===3||o===5)&&s===2?u=-a:u=a):u=0,r[1].push(u),2*n===d+1&&(n=1-n),2*i===u+1&&(i=1-i),t.iushrn(1),e.iushrn(1)}return r}Tu.getJSF=bke;function wke(t,e,r){var n="_"+e;t.prototype[e]=function(){return this[n]!==void 0?this[n]:this[n]=r.call(this)}}Tu.cachedProperty=wke;function _ke(t){return typeof t=="string"?Tu.toArray(t,"hex"):t}Tu.parseBytes=_ke;function xke(t){return new yke(t,"hex","le")}Tu.intFromLE=xke});var EE=V((tbt,cte)=>{"use strict";f();var vg=Mo(),xE=$c(),X4=xE.getNAF,Eke=xE.getJSF,Q4=xE.assert;function wm(t,e){this.type=t,this.p=new vg(e.p,16),this.red=e.prime?vg.red(e.prime):vg.mont(this.p),this.zero=new vg(0).toRed(this.red),this.one=new vg(1).toRed(this.red),this.two=new vg(2).toRed(this.red),this.n=e.n&&new vg(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}cte.exports=wm;wm.prototype.point=function(){throw new Error("Not implemented")};wm.prototype.validate=function(){throw new Error("Not implemented")};wm.prototype._fixedNafMul=function(e,r){Q4(e.precomputed);var n=e._getDoubles(),i=X4(r,1,this._bitLength),o=(1<=a;u--)d=(d<<1)+i[u];s.push(d)}for(var c=this.jpoint(null,null,null),l=this.jpoint(null,null,null),p=o;p>0;p--){for(a=0;a=0;d--){for(var u=0;d>=0&&s[d]===0;d--)u++;if(d>=0&&u++,a=a.dblp(u),d<0)break;var c=s[d];Q4(c!==0),e.type==="affine"?c>0?a=a.mixedAdd(o[c-1>>1]):a=a.mixedAdd(o[-c-1>>1].neg()):c>0?a=a.add(o[c-1>>1]):a=a.add(o[-c-1>>1].neg())}return e.type==="affine"?a.toP():a};wm.prototype._wnafMulAdd=function(e,r,n,i,o){var s=this._wnafT1,a=this._wnafT2,d=this._wnafT3,u=0,c,l,p;for(c=0;c=1;c-=2){var g=c-1,v=c;if(s[g]!==1||s[v]!==1){d[g]=X4(n[g],s[g],this._bitLength),d[v]=X4(n[v],s[v],this._bitLength),u=Math.max(d[g].length,u),u=Math.max(d[v].length,u);continue}var x=[r[g],null,null,r[v]];r[g].y.cmp(r[v].y)===0?(x[1]=r[g].add(r[v]),x[2]=r[g].toJ().mixedAdd(r[v].neg())):r[g].y.cmp(r[v].y.redNeg())===0?(x[1]=r[g].toJ().mixedAdd(r[v]),x[2]=r[g].add(r[v].neg())):(x[1]=r[g].toJ().mixedAdd(r[v]),x[2]=r[g].toJ().mixedAdd(r[v].neg()));var S=[-3,-1,-5,-7,0,7,5,1,3],P=Eke(n[g],n[v]);for(u=Math.max(P[0].length,u),d[g]=new Array(u),d[v]=new Array(u),l=0;l=0;c--){for(var F=0;c>=0;){var K=!0;for(l=0;l=0&&F++,j=j.dblp(F),c<0)break;for(l=0;l0?p=a[l][W-1>>1]:W<0&&(p=a[l][-W-1>>1].neg()),p.type==="affine"?j=j.mixedAdd(p):j=j.add(p))}}for(c=0;c=Math.ceil((e.bitLength()+1)/r.step):!1};Id.prototype._getDoubles=function(e,r){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var n=[this],i=this,o=0;o{"use strict";f();var Ske=$c(),vi=Mo(),hO=Ft(),Hw=EE(),Ake=Ske.assert;function kd(t){Hw.call(this,"short",t),this.a=new vi(t.a,16).toRed(this.red),this.b=new vi(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}hO(kd,Hw);dte.exports=kd;kd.prototype._getEndomorphism=function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var r,n;if(e.beta)r=new vi(e.beta,16).toRed(this.red);else{var i=this._getEndoRoots(this.p);r=i[0].cmp(i[1])<0?i[0]:i[1],r=r.toRed(this.red)}if(e.lambda)n=new vi(e.lambda,16);else{var o=this._getEndoRoots(this.n);this.g.mul(o[0]).x.cmp(this.g.x.redMul(r))===0?n=o[0]:(n=o[1],Ake(this.g.mul(n).x.cmp(this.g.x.redMul(r))===0))}var s;return e.basis?s=e.basis.map(function(a){return{a:new vi(a.a,16),b:new vi(a.b,16)}}):s=this._getEndoBasis(n),{beta:r,lambda:n,basis:s}}};kd.prototype._getEndoRoots=function(e){var r=e===this.p?this.red:vi.mont(e),n=new vi(2).toRed(r).redInvm(),i=n.redNeg(),o=new vi(3).toRed(r).redNeg().redSqrt().redMul(n),s=i.redAdd(o).fromRed(),a=i.redSub(o).fromRed();return[s,a]};kd.prototype._getEndoBasis=function(e){for(var r=this.n.ushrn(Math.floor(this.n.bitLength()/2)),n=e,i=this.n.clone(),o=new vi(1),s=new vi(0),a=new vi(0),d=new vi(1),u,c,l,p,m,g,v,x=0,S,P;n.cmpn(0)!==0;){var A=i.div(n);S=i.sub(A.mul(n)),P=a.sub(A.mul(o));var $=d.sub(A.mul(s));if(!l&&S.cmp(r)<0)u=v.neg(),c=o,l=S.neg(),p=P;else if(l&&++x===2)break;v=S,i=n,n=S,a=o,o=P,d=s,s=$}m=S.neg(),g=P;var j=l.sqr().add(p.sqr()),L=m.sqr().add(g.sqr());return L.cmp(j)>=0&&(m=u,g=c),l.negative&&(l=l.neg(),p=p.neg()),m.negative&&(m=m.neg(),g=g.neg()),[{a:l,b:p},{a:m,b:g}]};kd.prototype._endoSplit=function(e){var r=this.endo.basis,n=r[0],i=r[1],o=i.b.mul(e).divRound(this.n),s=n.b.neg().mul(e).divRound(this.n),a=o.mul(n.a),d=s.mul(i.a),u=o.mul(n.b),c=s.mul(i.b),l=e.sub(a).sub(d),p=u.add(c).neg();return{k1:l,k2:p}};kd.prototype.pointFromX=function(e,r){e=new vi(e,16),e.red||(e=e.toRed(this.red));var n=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),i=n.redSqrt();if(i.redSqr().redSub(n).cmp(this.zero)!==0)throw new Error("invalid point");var o=i.fromRed().isOdd();return(r&&!o||!r&&o)&&(i=i.redNeg()),this.point(e,i)};kd.prototype.validate=function(e){if(e.inf)return!0;var r=e.x,n=e.y,i=this.a.redMul(r),o=r.redSqr().redMul(r).redIAdd(i).redIAdd(this.b);return n.redSqr().redISub(o).cmpn(0)===0};kd.prototype._endoWnafMulAdd=function(e,r,n){for(var i=this._endoWnafT1,o=this._endoWnafT2,s=0;s":""};Oo.prototype.isInfinity=function(){return this.inf};Oo.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var r=this.y.redSub(e.y);r.cmpn(0)!==0&&(r=r.redMul(this.x.redSub(e.x).redInvm()));var n=r.redSqr().redISub(this.x).redISub(e.x),i=r.redMul(this.x.redSub(n)).redISub(this.y);return this.curve.point(n,i)};Oo.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var r=this.curve.a,n=this.x.redSqr(),i=e.redInvm(),o=n.redAdd(n).redIAdd(n).redIAdd(r).redMul(i),s=o.redSqr().redISub(this.x.redAdd(this.x)),a=o.redMul(this.x.redSub(s)).redISub(this.y);return this.curve.point(s,a)};Oo.prototype.getX=function(){return this.x.fromRed()};Oo.prototype.getY=function(){return this.y.fromRed()};Oo.prototype.mul=function(e){return e=new vi(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)};Oo.prototype.mulAdd=function(e,r,n){var i=[this,r],o=[e,n];return this.curve.endo?this.curve._endoWnafMulAdd(i,o):this.curve._wnafMulAdd(1,i,o,2)};Oo.prototype.jmulAdd=function(e,r,n){var i=[this,r],o=[e,n];return this.curve.endo?this.curve._endoWnafMulAdd(i,o,!0):this.curve._wnafMulAdd(1,i,o,2,!0)};Oo.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)};Oo.prototype.neg=function(e){if(this.inf)return this;var r=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var n=this.precomputed,i=function(o){return o.neg()};r.precomputed={naf:n.naf&&{wnd:n.naf.wnd,points:n.naf.points.map(i)},doubles:n.doubles&&{step:n.doubles.step,points:n.doubles.points.map(i)}}}return r};Oo.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function is(t,e,r,n){Hw.BasePoint.call(this,t,"jacobian"),e===null&&r===null&&n===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new vi(0)):(this.x=new vi(e,16),this.y=new vi(r,16),this.z=new vi(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}hO(is,Hw.BasePoint);kd.prototype.jpoint=function(e,r,n){return new is(this,e,r,n)};is.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),r=e.redSqr(),n=this.x.redMul(r),i=this.y.redMul(r).redMul(e);return this.curve.point(n,i)};is.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};is.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var r=e.z.redSqr(),n=this.z.redSqr(),i=this.x.redMul(r),o=e.x.redMul(n),s=this.y.redMul(r.redMul(e.z)),a=e.y.redMul(n.redMul(this.z)),d=i.redSub(o),u=s.redSub(a);if(d.cmpn(0)===0)return u.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var c=d.redSqr(),l=c.redMul(d),p=i.redMul(c),m=u.redSqr().redIAdd(l).redISub(p).redISub(p),g=u.redMul(p.redISub(m)).redISub(s.redMul(l)),v=this.z.redMul(e.z).redMul(d);return this.curve.jpoint(m,g,v)};is.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var r=this.z.redSqr(),n=this.x,i=e.x.redMul(r),o=this.y,s=e.y.redMul(r).redMul(this.z),a=n.redSub(i),d=o.redSub(s);if(a.cmpn(0)===0)return d.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),c=u.redMul(a),l=n.redMul(u),p=d.redSqr().redIAdd(c).redISub(l).redISub(l),m=d.redMul(l.redISub(p)).redISub(o.redMul(c)),g=this.z.redMul(a);return this.curve.jpoint(p,m,g)};is.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var r;if(this.curve.zeroA||this.curve.threeA){var n=this;for(r=0;r=0)return!1;if(n.redIAdd(o),this.x.cmp(n)===0)return!0}};is.prototype.inspect=function(){return this.isInfinity()?"":""};is.prototype.isInfinity=function(){return this.z.cmpn(0)===0}});var hte=V((obt,fte)=>{"use strict";f();var Vw=Mo(),lte=Ft(),eA=EE(),Tke=$c();function Gw(t){eA.call(this,"mont",t),this.a=new Vw(t.a,16).toRed(this.red),this.b=new Vw(t.b,16).toRed(this.red),this.i4=new Vw(4).toRed(this.red).redInvm(),this.two=new Vw(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}lte(Gw,eA);fte.exports=Gw;Gw.prototype.validate=function(e){var r=e.normalize().x,n=r.redSqr(),i=n.redMul(r).redAdd(n.redMul(this.a)).redAdd(r),o=i.redSqrt();return o.redSqr().cmp(i)===0};function Co(t,e,r){eA.BasePoint.call(this,t,"projective"),e===null&&r===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new Vw(e,16),this.z=new Vw(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}lte(Co,eA.BasePoint);Gw.prototype.decodePoint=function(e,r){return this.point(Tke.toArray(e,r),1)};Gw.prototype.point=function(e,r){return new Co(this,e,r)};Gw.prototype.pointFromJSON=function(e){return Co.fromJSON(this,e)};Co.prototype.precompute=function(){};Co.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())};Co.fromJSON=function(e,r){return new Co(e,r[0],r[1]||e.one)};Co.prototype.inspect=function(){return this.isInfinity()?"":""};Co.prototype.isInfinity=function(){return this.z.cmpn(0)===0};Co.prototype.dbl=function(){var e=this.x.redAdd(this.z),r=e.redSqr(),n=this.x.redSub(this.z),i=n.redSqr(),o=r.redSub(i),s=r.redMul(i),a=o.redMul(i.redAdd(this.curve.a24.redMul(o)));return this.curve.point(s,a)};Co.prototype.add=function(){throw new Error("Not supported on Montgomery curve")};Co.prototype.diffAdd=function(e,r){var n=this.x.redAdd(this.z),i=this.x.redSub(this.z),o=e.x.redAdd(e.z),s=e.x.redSub(e.z),a=s.redMul(n),d=o.redMul(i),u=r.z.redMul(a.redAdd(d).redSqr()),c=r.x.redMul(a.redISub(d).redSqr());return this.curve.point(u,c)};Co.prototype.mul=function(e){for(var r=e.clone(),n=this,i=this.curve.point(null,null),o=this,s=[];r.cmpn(0)!==0;r.iushrn(1))s.push(r.andln(1));for(var a=s.length-1;a>=0;a--)s[a]===0?(n=n.diffAdd(i,o),i=i.dbl()):(i=n.diffAdd(i,o),n=n.dbl());return i};Co.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")};Co.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")};Co.prototype.eq=function(e){return this.getX().cmp(e.getX())===0};Co.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this};Co.prototype.getX=function(){return this.normalize(),this.x.fromRed()}});var yte=V((abt,mte)=>{"use strict";f();var Pke=$c(),wh=Mo(),pte=Ft(),tA=EE(),Ike=Pke.assert;function $l(t){this.twisted=(t.a|0)!==1,this.mOneA=this.twisted&&(t.a|0)===-1,this.extended=this.mOneA,tA.call(this,"edwards",t),this.a=new wh(t.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new wh(t.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new wh(t.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),Ike(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(t.c|0)===1}pte($l,tA);mte.exports=$l;$l.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)};$l.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)};$l.prototype.jpoint=function(e,r,n,i){return this.point(e,r,n,i)};$l.prototype.pointFromX=function(e,r){e=new wh(e,16),e.red||(e=e.toRed(this.red));var n=e.redSqr(),i=this.c2.redSub(this.a.redMul(n)),o=this.one.redSub(this.c2.redMul(this.d).redMul(n)),s=i.redMul(o.redInvm()),a=s.redSqrt();if(a.redSqr().redSub(s).cmp(this.zero)!==0)throw new Error("invalid point");var d=a.fromRed().isOdd();return(r&&!d||!r&&d)&&(a=a.redNeg()),this.point(e,a)};$l.prototype.pointFromY=function(e,r){e=new wh(e,16),e.red||(e=e.toRed(this.red));var n=e.redSqr(),i=n.redSub(this.c2),o=n.redMul(this.d).redMul(this.c2).redSub(this.a),s=i.redMul(o.redInvm());if(s.cmp(this.zero)===0){if(r)throw new Error("invalid point");return this.point(this.zero,e)}var a=s.redSqrt();if(a.redSqr().redSub(s).cmp(this.zero)!==0)throw new Error("invalid point");return a.fromRed().isOdd()!==r&&(a=a.redNeg()),this.point(a,e)};$l.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var r=e.x.redSqr(),n=e.y.redSqr(),i=r.redMul(this.a).redAdd(n),o=this.c2.redMul(this.one.redAdd(this.d.redMul(r).redMul(n)));return i.cmp(o)===0};function On(t,e,r,n,i){tA.BasePoint.call(this,t,"projective"),e===null&&r===null&&n===null?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new wh(e,16),this.y=new wh(r,16),this.z=n?new wh(n,16):this.curve.one,this.t=i&&new wh(i,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}pte(On,tA.BasePoint);$l.prototype.pointFromJSON=function(e){return On.fromJSON(this,e)};$l.prototype.point=function(e,r,n,i){return new On(this,e,r,n,i)};On.fromJSON=function(e,r){return new On(e,r[0],r[1],r[2])};On.prototype.inspect=function(){return this.isInfinity()?"":""};On.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)};On.prototype._extDbl=function(){var e=this.x.redSqr(),r=this.y.redSqr(),n=this.z.redSqr();n=n.redIAdd(n);var i=this.curve._mulA(e),o=this.x.redAdd(this.y).redSqr().redISub(e).redISub(r),s=i.redAdd(r),a=s.redSub(n),d=i.redSub(r),u=o.redMul(a),c=s.redMul(d),l=o.redMul(d),p=a.redMul(s);return this.curve.point(u,c,p,l)};On.prototype._projDbl=function(){var e=this.x.redAdd(this.y).redSqr(),r=this.x.redSqr(),n=this.y.redSqr(),i,o,s,a,d,u;if(this.curve.twisted){a=this.curve._mulA(r);var c=a.redAdd(n);this.zOne?(i=e.redSub(r).redSub(n).redMul(c.redSub(this.curve.two)),o=c.redMul(a.redSub(n)),s=c.redSqr().redSub(c).redSub(c)):(d=this.z.redSqr(),u=c.redSub(d).redISub(d),i=e.redSub(r).redISub(n).redMul(u),o=c.redMul(a.redSub(n)),s=c.redMul(u))}else a=r.redAdd(n),d=this.curve._mulC(this.z).redSqr(),u=a.redSub(d).redSub(d),i=this.curve._mulC(e.redISub(a)).redMul(u),o=this.curve._mulC(a).redMul(r.redISub(n)),s=a.redMul(u);return this.curve.point(i,o,s)};On.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()};On.prototype._extAdd=function(e){var r=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),n=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),i=this.t.redMul(this.curve.dd).redMul(e.t),o=this.z.redMul(e.z.redAdd(e.z)),s=n.redSub(r),a=o.redSub(i),d=o.redAdd(i),u=n.redAdd(r),c=s.redMul(a),l=d.redMul(u),p=s.redMul(u),m=a.redMul(d);return this.curve.point(c,l,m,p)};On.prototype._projAdd=function(e){var r=this.z.redMul(e.z),n=r.redSqr(),i=this.x.redMul(e.x),o=this.y.redMul(e.y),s=this.curve.d.redMul(i).redMul(o),a=n.redSub(s),d=n.redAdd(s),u=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(i).redISub(o),c=r.redMul(a).redMul(u),l,p;return this.curve.twisted?(l=r.redMul(d).redMul(o.redSub(this.curve._mulA(i))),p=a.redMul(d)):(l=r.redMul(d).redMul(o.redSub(i)),p=this.curve._mulC(a).redMul(d)),this.curve.point(c,l,p)};On.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)};On.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)};On.prototype.mulAdd=function(e,r,n){return this.curve._wnafMulAdd(1,[this,r],[e,n],2,!1)};On.prototype.jmulAdd=function(e,r,n){return this.curve._wnafMulAdd(1,[this,r],[e,n],2,!0)};On.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this};On.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())};On.prototype.getX=function(){return this.normalize(),this.x.fromRed()};On.prototype.getY=function(){return this.normalize(),this.y.fromRed()};On.prototype.eq=function(e){return this===e||this.getX().cmp(e.getX())===0&&this.getY().cmp(e.getY())===0};On.prototype.eqXToP=function(e){var r=e.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(r)===0)return!0;for(var n=e.clone(),i=this.curve.redN.redMul(this.z);;){if(n.iadd(this.curve.n),n.cmp(this.curve.p)>=0)return!1;if(r.redIAdd(i),this.x.cmp(r)===0)return!0}};On.prototype.toP=On.prototype.normalize;On.prototype.mixedAdd=On.prototype.add});var pO=V(gte=>{"use strict";f();var rA=gte;rA.base=EE();rA.short=ute();rA.mont=hte();rA.edwards=yte()});var Pu=V(Sn=>{"use strict";f();var kke=Cc(),Rke=Ft();Sn.inherits=Rke;function Dke(t,e){return(t.charCodeAt(e)&64512)!==55296||e<0||e+1>=t.length?!1:(t.charCodeAt(e+1)&64512)===56320}function Bke(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if(typeof t=="string")if(e){if(e==="hex")for(t=t.replace(/[^a-z0-9]+/ig,""),t.length%2!==0&&(t="0"+t),i=0;i>6|192,r[n++]=o&63|128):Dke(t,i)?(o=65536+((o&1023)<<10)+(t.charCodeAt(++i)&1023),r[n++]=o>>18|240,r[n++]=o>>12&63|128,r[n++]=o>>6&63|128,r[n++]=o&63|128):(r[n++]=o>>12|224,r[n++]=o>>6&63|128,r[n++]=o&63|128)}else for(i=0;i>>24|t>>>8&65280|t<<8&16711680|(t&255)<<24;return e>>>0}Sn.htonl=vte;function Oke(t,e){for(var r="",n=0;n>>0}return o}Sn.join32=Cke;function $ke(t,e){for(var r=new Array(t.length*4),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=o&255):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=o&255)}return r}Sn.split32=$ke;function jke(t,e){return t>>>e|t<<32-e}Sn.rotr32=jke;function Nke(t,e){return t<>>32-e}Sn.rotl32=Nke;function Uke(t,e){return t+e>>>0}Sn.sum32=Uke;function qke(t,e,r){return t+e+r>>>0}Sn.sum32_3=qke;function Lke(t,e,r,n){return t+e+r+n>>>0}Sn.sum32_4=Lke;function Kke(t,e,r,n,i){return t+e+r+n+i>>>0}Sn.sum32_5=Kke;function Fke(t,e,r,n){var i=t[e],o=t[e+1],s=n+o>>>0,a=(s>>0,t[e+1]=s}Sn.sum64=Fke;function zke(t,e,r,n){var i=e+n>>>0,o=(i>>0}Sn.sum64_hi=zke;function Wke(t,e,r,n){var i=e+n;return i>>>0}Sn.sum64_lo=Wke;function Hke(t,e,r,n,i,o,s,a){var d=0,u=e;u=u+n>>>0,d+=u>>0,d+=u>>0,d+=u>>0}Sn.sum64_4_hi=Hke;function Vke(t,e,r,n,i,o,s,a){var d=e+n+o+a;return d>>>0}Sn.sum64_4_lo=Vke;function Gke(t,e,r,n,i,o,s,a,d,u){var c=0,l=e;l=l+n>>>0,c+=l>>0,c+=l>>0,c+=l>>0,c+=l>>0}Sn.sum64_5_hi=Gke;function Jke(t,e,r,n,i,o,s,a,d,u){var c=e+n+o+a+u;return c>>>0}Sn.sum64_5_lo=Jke;function Zke(t,e,r){var n=e<<32-r|t>>>r;return n>>>0}Sn.rotr64_hi=Zke;function Yke(t,e,r){var n=t<<32-r|e>>>r;return n>>>0}Sn.rotr64_lo=Yke;function Xke(t,e,r){return t>>>r}Sn.shr64_hi=Xke;function Qke(t,e,r){var n=t<<32-r|e>>>r;return n>>>0}Sn.shr64_lo=Qke});var Jw=V(xte=>{"use strict";f();var _te=Pu(),eRe=Cc();function nA(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}xte.BlockHash=nA;nA.prototype.update=function(e,r){if(e=_te.toArray(e,r),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){e=this.pending;var n=e.length%this._delta8;this.pending=e.slice(e.length-n,e.length),this.pending.length===0&&(this.pending=null),e=_te.join32(e,0,e.length-n,this.endian);for(var i=0;i>>24&255,i[o++]=e>>>16&255,i[o++]=e>>>8&255,i[o++]=e&255}else for(i[o++]=e&255,i[o++]=e>>>8&255,i[o++]=e>>>16&255,i[o++]=e>>>24&255,i[o++]=0,i[o++]=0,i[o++]=0,i[o++]=0,s=8;s{"use strict";f();var tRe=Pu(),jl=tRe.rotr32;function rRe(t,e,r,n){if(t===0)return Ete(e,r,n);if(t===1||t===3)return Ate(e,r,n);if(t===2)return Ste(e,r,n)}_h.ft_1=rRe;function Ete(t,e,r){return t&e^~t&r}_h.ch32=Ete;function Ste(t,e,r){return t&e^t&r^e&r}_h.maj32=Ste;function Ate(t,e,r){return t^e^r}_h.p32=Ate;function nRe(t){return jl(t,2)^jl(t,13)^jl(t,22)}_h.s0_256=nRe;function iRe(t){return jl(t,6)^jl(t,11)^jl(t,25)}_h.s1_256=iRe;function oRe(t){return jl(t,7)^jl(t,18)^t>>>3}_h.g0_256=oRe;function sRe(t){return jl(t,17)^jl(t,19)^t>>>10}_h.g1_256=sRe});var Ite=V((gbt,Pte)=>{"use strict";f();var Zw=Pu(),aRe=Jw(),cRe=mO(),yO=Zw.rotl32,SE=Zw.sum32,dRe=Zw.sum32_5,uRe=cRe.ft_1,Tte=aRe.BlockHash,lRe=[1518500249,1859775393,2400959708,3395469782];function Nl(){if(!(this instanceof Nl))return new Nl;Tte.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}Zw.inherits(Nl,Tte);Pte.exports=Nl;Nl.blockSize=512;Nl.outSize=160;Nl.hmacStrength=80;Nl.padLength=64;Nl.prototype._update=function(e,r){for(var n=this.W,i=0;i<16;i++)n[i]=e[r+i];for(;i{"use strict";f();var Yw=Pu(),fRe=Jw(),Xw=mO(),hRe=Cc(),Iu=Yw.sum32,pRe=Yw.sum32_4,mRe=Yw.sum32_5,yRe=Xw.ch32,gRe=Xw.maj32,vRe=Xw.s0_256,bRe=Xw.s1_256,wRe=Xw.g0_256,_Re=Xw.g1_256,kte=fRe.BlockHash,xRe=[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];function Ul(){if(!(this instanceof Ul))return new Ul;kte.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=xRe,this.W=new Array(64)}Yw.inherits(Ul,kte);Rte.exports=Ul;Ul.blockSize=512;Ul.outSize=256;Ul.hmacStrength=192;Ul.padLength=64;Ul.prototype._update=function(e,r){for(var n=this.W,i=0;i<16;i++)n[i]=e[r+i];for(;i{"use strict";f();var vO=Pu(),Dte=gO();function xh(){if(!(this instanceof xh))return new xh;Dte.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}vO.inherits(xh,Dte);Bte.exports=xh;xh.blockSize=512;xh.outSize=224;xh.hmacStrength=192;xh.padLength=64;xh.prototype._digest=function(e){return e==="hex"?vO.toHex32(this.h.slice(0,7),"big"):vO.split32(this.h.slice(0,7),"big")}});var _O=V((Ebt,jte)=>{"use strict";f();var Xa=Pu(),ERe=Jw(),SRe=Cc(),ql=Xa.rotr64_hi,Ll=Xa.rotr64_lo,Ote=Xa.shr64_hi,Cte=Xa.shr64_lo,_m=Xa.sum64,bO=Xa.sum64_hi,wO=Xa.sum64_lo,ARe=Xa.sum64_4_hi,TRe=Xa.sum64_4_lo,PRe=Xa.sum64_5_hi,IRe=Xa.sum64_5_lo,$te=ERe.BlockHash,kRe=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function ku(){if(!(this instanceof ku))return new ku;$te.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=kRe,this.W=new Array(160)}Xa.inherits(ku,$te);jte.exports=ku;ku.blockSize=1024;ku.outSize=512;ku.hmacStrength=192;ku.padLength=128;ku.prototype._prepareBlock=function(e,r){for(var n=this.W,i=0;i<32;i++)n[i]=e[r+i];for(;i{"use strict";f();var xO=Pu(),Nte=_O();function Eh(){if(!(this instanceof Eh))return new Eh;Nte.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}xO.inherits(Eh,Nte);Ute.exports=Eh;Eh.blockSize=1024;Eh.outSize=384;Eh.hmacStrength=192;Eh.padLength=128;Eh.prototype._digest=function(e){return e==="hex"?xO.toHex32(this.h.slice(0,12),"big"):xO.split32(this.h.slice(0,12),"big")}});var Lte=V(Qw=>{"use strict";f();Qw.sha1=Ite();Qw.sha224=Mte();Qw.sha256=gO();Qw.sha384=qte();Qw.sha512=_O()});var Vte=V(Hte=>{"use strict";f();var bg=Pu(),KRe=Jw(),iA=bg.rotl32,Kte=bg.sum32,AE=bg.sum32_3,Fte=bg.sum32_4,Wte=KRe.BlockHash;function Kl(){if(!(this instanceof Kl))return new Kl;Wte.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}bg.inherits(Kl,Wte);Hte.ripemd160=Kl;Kl.blockSize=512;Kl.outSize=160;Kl.hmacStrength=192;Kl.padLength=64;Kl.prototype._update=function(e,r){for(var n=this.h[0],i=this.h[1],o=this.h[2],s=this.h[3],a=this.h[4],d=n,u=i,c=o,l=s,p=a,m=0;m<80;m++){var g=Kte(iA(Fte(n,zte(m,i,o,s),e[WRe[m]+r],FRe(m)),VRe[m]),a);n=a,a=s,s=iA(o,10),o=i,i=g,g=Kte(iA(Fte(d,zte(79-m,u,c,l),e[HRe[m]+r],zRe(m)),GRe[m]),p),d=p,p=l,l=iA(c,10),c=u,u=g}g=AE(this.h[1],o,l),this.h[1]=AE(this.h[2],s,p),this.h[2]=AE(this.h[3],a,d),this.h[3]=AE(this.h[4],n,u),this.h[4]=AE(this.h[0],i,c),this.h[0]=g};Kl.prototype._digest=function(e){return e==="hex"?bg.toHex32(this.h,"little"):bg.split32(this.h,"little")};function zte(t,e,r,n){return t<=15?e^r^n:t<=31?e&r|~e&n:t<=47?(e|~r)^n:t<=63?e&n|r&~n:e^(r|~n)}function FRe(t){return t<=15?0:t<=31?1518500249:t<=47?1859775393:t<=63?2400959708:2840853838}function zRe(t){return t<=15?1352829926:t<=31?1548603684:t<=47?1836072691:t<=63?2053994217:0}var WRe=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],HRe=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],VRe=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],GRe=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]});var Jte=V((Dbt,Gte)=>{"use strict";f();var JRe=Pu(),ZRe=Cc();function e1(t,e,r){if(!(this instanceof e1))return new e1(t,e,r);this.Hash=t,this.blockSize=t.blockSize/8,this.outSize=t.outSize/8,this.inner=null,this.outer=null,this._init(JRe.toArray(e,r))}Gte.exports=e1;e1.prototype._init=function(e){e.length>this.blockSize&&(e=new this.Hash().update(e).digest()),ZRe(e.length<=this.blockSize);for(var r=e.length;r{f();var os=Zte;os.utils=Pu();os.common=Jw();os.sha=Lte();os.ripemd=Vte();os.hmac=Jte();os.sha1=os.sha.sha1;os.sha256=os.sha.sha256;os.sha224=os.sha.sha224;os.sha384=os.sha.sha384;os.sha512=os.sha.sha512;os.ripemd160=os.ripemd.ripemd160});var Xte=V((Cbt,Yte)=>{f();Yte.exports={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}});var sA=V(tre=>{"use strict";f();var SO=tre,xm=oA(),EO=pO(),YRe=$c(),Qte=YRe.assert;function ere(t){t.type==="short"?this.curve=new EO.short(t):t.type==="edwards"?this.curve=new EO.edwards(t):this.curve=new EO.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,Qte(this.g.validate(),"Invalid curve"),Qte(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}SO.PresetCurve=ere;function Em(t,e){Object.defineProperty(SO,t,{configurable:!0,enumerable:!0,get:function(){var r=new ere(e);return Object.defineProperty(SO,t,{configurable:!0,enumerable:!0,value:r}),r}})}Em("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:xm.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]});Em("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:xm.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]});Em("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:xm.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]});Em("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:xm.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]});Em("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:xm.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]});Em("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:xm.sha256,gRed:!1,g:["9"]});Em("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:xm.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var AO;try{AO=Xte()}catch{AO=void 0}Em("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:xm.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",AO]})});var ire=V((Ubt,nre)=>{"use strict";f();var XRe=oA(),wg=fO(),rre=Cc();function Sm(t){if(!(this instanceof Sm))return new Sm(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=wg.toArray(t.entropy,t.entropyEnc||"hex"),r=wg.toArray(t.nonce,t.nonceEnc||"hex"),n=wg.toArray(t.pers,t.persEnc||"hex");rre(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,n)}nre.exports=Sm;Sm.prototype._init=function(e,r,n){var i=e.concat(r).concat(n);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var o=0;o=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(n||[])),this._reseed=1};Sm.prototype.generate=function(e,r,n,i){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof r!="string"&&(i=n,n=r,r=null),n&&(n=wg.toArray(n,i||"hex"),this._update(n));for(var o=[];o.length{"use strict";f();var QRe=Mo(),eDe=$c(),TO=eDe.assert;function Zs(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}ore.exports=Zs;Zs.fromPublic=function(e,r,n){return r instanceof Zs?r:new Zs(e,{pub:r,pubEnc:n})};Zs.fromPrivate=function(e,r,n){return r instanceof Zs?r:new Zs(e,{priv:r,privEnc:n})};Zs.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}};Zs.prototype.getPublic=function(e,r){return typeof e=="string"&&(r=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),r?this.pub.encode(r,e):this.pub};Zs.prototype.getPrivate=function(e){return e==="hex"?this.priv.toString(16,2):this.priv};Zs.prototype._importPrivate=function(e,r){this.priv=new QRe(e,r||16),this.priv=this.priv.umod(this.ec.curve.n)};Zs.prototype._importPublic=function(e,r){if(e.x||e.y){this.ec.curve.type==="mont"?TO(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&TO(e.x&&e.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(e.x,e.y);return}this.pub=this.ec.curve.decodePoint(e,r)};Zs.prototype.derive=function(e){return e.validate()||TO(e.validate(),"public point not validated"),e.mul(this.priv).getX()};Zs.prototype.sign=function(e,r,n){return this.ec.sign(e,this,r,n)};Zs.prototype.verify=function(e,r){return this.ec.verify(e,r,this)};Zs.prototype.inspect=function(){return""}});var dre=V((Fbt,cre)=>{"use strict";f();var aA=Mo(),kO=$c(),tDe=kO.assert;function cA(t,e){if(t instanceof cA)return t;this._importDER(t,e)||(tDe(t.r&&t.s,"Signature without r or s"),this.r=new aA(t.r,16),this.s=new aA(t.s,16),t.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}cre.exports=cA;function rDe(){this.place=0}function PO(t,e){var r=t[e.place++];if(!(r&128))return r;var n=r&15;if(n===0||n>4||t[e.place]===0)return!1;for(var i=0,o=0,s=e.place;o>>=0;return i<=127?!1:(e.place=s,i)}function are(t){for(var e=0,r=t.length-1;!t[e]&&!(t[e+1]&128)&&e>>3);for(t.push(r|128);--r;)t.push(e>>>(r<<3)&255);t.push(e)}cA.prototype.toDER=function(e){var r=this.r.toArray(),n=this.s.toArray();for(r[0]&128&&(r=[0].concat(r)),n[0]&128&&(n=[0].concat(n)),r=are(r),n=are(n);!n[0]&&!(n[1]&128);)n=n.slice(1);var i=[2];IO(i,r.length),i=i.concat(r),i.push(2),IO(i,n.length);var o=i.concat(n),s=[48];return IO(s,o.length),s=s.concat(o),kO.encode(s,e)}});var hre=V((Wbt,fre)=>{"use strict";f();var _g=Mo(),ure=ire(),nDe=$c(),RO=sA(),iDe=O4(),lre=nDe.assert,DO=sre(),dA=dre();function Rd(t){if(!(this instanceof Rd))return new Rd(t);typeof t=="string"&&(lre(Object.prototype.hasOwnProperty.call(RO,t),"Unknown curve "+t),t=RO[t]),t instanceof RO.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}fre.exports=Rd;Rd.prototype.keyPair=function(e){return new DO(this,e)};Rd.prototype.keyFromPrivate=function(e,r){return DO.fromPrivate(this,e,r)};Rd.prototype.keyFromPublic=function(e,r){return DO.fromPublic(this,e,r)};Rd.prototype.genKeyPair=function(e){e||(e={});for(var r=new ure({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||iDe(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),n=this.n.byteLength(),i=this.n.sub(new _g(2));;){var o=new _g(r.generate(n));if(!(o.cmp(i)>0))return o.iaddn(1),this.keyFromPrivate(o)}};Rd.prototype._truncateToN=function(e,r){var n=e.byteLength()*8-this.n.bitLength();return n>0&&(e=e.ushrn(n)),!r&&e.cmp(this.n)>=0?e.sub(this.n):e};Rd.prototype.sign=function(e,r,n,i){typeof n=="object"&&(i=n,n=null),i||(i={}),r=this.keyFromPrivate(r,n),e=this._truncateToN(new _g(e,16));for(var o=this.n.byteLength(),s=r.getPrivate().toArray("be",o),a=e.toArray("be",o),d=new ure({hash:this.hash,entropy:s,nonce:a,pers:i.pers,persEnc:i.persEnc||"utf8"}),u=this.n.sub(new _g(1)),c=0;;c++){var l=i.k?i.k(c):new _g(d.generate(this.n.byteLength()));if(l=this._truncateToN(l,!0),!(l.cmpn(1)<=0||l.cmp(u)>=0)){var p=this.g.mul(l);if(!p.isInfinity()){var m=p.getX(),g=m.umod(this.n);if(g.cmpn(0)!==0){var v=l.invm(this.n).mul(g.mul(r.getPrivate()).iadd(e));if(v=v.umod(this.n),v.cmpn(0)!==0){var x=(p.getY().isOdd()?1:0)|(m.cmp(g)!==0?2:0);return i.canonical&&v.cmp(this.nh)>0&&(v=this.n.sub(v),x^=1),new dA({r:g,s:v,recoveryParam:x})}}}}}};Rd.prototype.verify=function(e,r,n,i){e=this._truncateToN(new _g(e,16)),n=this.keyFromPublic(n,i),r=new dA(r,"hex");var o=r.r,s=r.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0||s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var a=s.invm(this.n),d=a.mul(e).umod(this.n),u=a.mul(o).umod(this.n),c;return this.curve._maxwellTrick?(c=this.g.jmulAdd(d,n.getPublic(),u),c.isInfinity()?!1:c.eqXToP(o)):(c=this.g.mulAdd(d,n.getPublic(),u),c.isInfinity()?!1:c.getX().umod(this.n).cmp(o)===0)};Rd.prototype.recoverPubKey=function(t,e,r,n){lre((3&r)===r,"The recovery param is more than two bits"),e=new dA(e,n);var i=this.n,o=new _g(t),s=e.r,a=e.s,d=r&1,u=r>>1;if(s.cmp(this.curve.p.umod(this.curve.n))>=0&&u)throw new Error("Unable to find sencond key candinate");u?s=this.curve.pointFromX(s.add(this.curve.n),d):s=this.curve.pointFromX(s,d);var c=e.r.invm(i),l=i.sub(o).mul(c).umod(i),p=a.mul(c).umod(i);return this.g.mulAdd(l,s,p)};Rd.prototype.getKeyRecoveryParam=function(t,e,r,n){if(e=new dA(e,n),e.recoveryParam!==null)return e.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(t,e,i)}catch{continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")}});var gre=V((Vbt,yre)=>{"use strict";f();var TE=$c(),mre=TE.assert,pre=TE.parseBytes,t1=TE.cachedProperty;function $o(t,e){this.eddsa=t,this._secret=pre(e.secret),t.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=pre(e.pub)}$o.fromPublic=function(e,r){return r instanceof $o?r:new $o(e,{pub:r})};$o.fromSecret=function(e,r){return r instanceof $o?r:new $o(e,{secret:r})};$o.prototype.secret=function(){return this._secret};t1($o,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())});t1($o,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())});t1($o,"privBytes",function(){var e=this.eddsa,r=this.hash(),n=e.encodingLength-1,i=r.slice(0,e.encodingLength);return i[0]&=248,i[n]&=127,i[n]|=64,i});t1($o,"priv",function(){return this.eddsa.decodeInt(this.privBytes())});t1($o,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()});t1($o,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)});$o.prototype.sign=function(e){return mre(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)};$o.prototype.verify=function(e,r){return this.eddsa.verify(e,r,this)};$o.prototype.getSecret=function(e){return mre(this._secret,"KeyPair is public only"),TE.encode(this.secret(),e)};$o.prototype.getPublic=function(e){return TE.encode(this.pubBytes(),e)};yre.exports=$o});var wre=V((Jbt,bre)=>{"use strict";f();var oDe=Mo(),uA=$c(),vre=uA.assert,lA=uA.cachedProperty,sDe=uA.parseBytes;function xg(t,e){this.eddsa=t,typeof e!="object"&&(e=sDe(e)),Array.isArray(e)&&(vre(e.length===t.encodingLength*2,"Signature has invalid size"),e={R:e.slice(0,t.encodingLength),S:e.slice(t.encodingLength)}),vre(e.R&&e.S,"Signature without R or S"),t.isPoint(e.R)&&(this._R=e.R),e.S instanceof oDe&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}lA(xg,"S",function(){return this.eddsa.decodeInt(this.Sencoded())});lA(xg,"R",function(){return this.eddsa.decodePoint(this.Rencoded())});lA(xg,"Rencoded",function(){return this.eddsa.encodePoint(this.R())});lA(xg,"Sencoded",function(){return this.eddsa.encodeInt(this.S())});xg.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())};xg.prototype.toHex=function(){return uA.encode(this.toBytes(),"hex").toUpperCase()};bre.exports=xg});var Are=V((Ybt,Sre)=>{"use strict";f();var aDe=oA(),cDe=sA(),r1=$c(),dDe=r1.assert,xre=r1.parseBytes,Ere=gre(),_re=wre();function Qa(t){if(dDe(t==="ed25519","only tested with ed25519 so far"),!(this instanceof Qa))return new Qa(t);t=cDe[t].curve,this.curve=t,this.g=t.g,this.g.precompute(t.n.bitLength()+1),this.pointClass=t.point().constructor,this.encodingLength=Math.ceil(t.n.bitLength()/8),this.hash=aDe.sha512}Sre.exports=Qa;Qa.prototype.sign=function(e,r){e=xre(e);var n=this.keyFromSecret(r),i=this.hashInt(n.messagePrefix(),e),o=this.g.mul(i),s=this.encodePoint(o),a=this.hashInt(s,n.pubBytes(),e).mul(n.priv()),d=i.add(a).umod(this.curve.n);return this.makeSignature({R:o,S:d,Rencoded:s})};Qa.prototype.verify=function(e,r,n){if(e=xre(e),r=this.makeSignature(r),r.S().gte(r.eddsa.curve.n)||r.S().isNeg())return!1;var i=this.keyFromPublic(n),o=this.hashInt(r.Rencoded(),i.pubBytes(),e),s=this.g.mul(r.S()),a=r.R().add(i.pub().mul(o));return a.eq(s)};Qa.prototype.hashInt=function(){for(var e=this.hash(),r=0;r{"use strict";f();var Eg=Tre;Eg.version=nte().version;Eg.utils=$c();Eg.rand=O4();Eg.curve=pO();Eg.curves=sA();Eg.ec=hre();Eg.eddsa=Are()});var kre=V(Ire=>{f();var Pre=i1(),uDe=Ft(),lDe=Ire;lDe.define=function(e,r){return new n1(e,r)};function n1(t,e){this.name=t,this.body=e,this.decoders={},this.encoders={}}n1.prototype._createNamed=function(e){var r;try{r=V1e("vm").runInThisContext("(function "+this.name+`(entity) { +var Web5=(()=>{var J1e=Object.create;var L5=Object.defineProperty;var Z1e=Object.getOwnPropertyDescriptor;var Y1e=Object.getOwnPropertyNames;var X1e=Object.getPrototypeOf,Q1e=Object.prototype.hasOwnProperty;var e2e=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var t2e=(t,e)=>()=>(t&&(e=t(t=0)),e);var V=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Pr=(t,e)=>{for(var r in e)L5(t,r,{get:e[r],enumerable:!0})},Vz=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Y1e(e))!Q1e.call(t,i)&&i!==r&&L5(t,i,{get:()=>e[i],enumerable:!(n=Z1e(e,i))||n.enumerable});return t};var gt=(t,e,r)=>(r=t!=null?J1e(X1e(t)):{},Vz(e||!t||!t.__esModule?L5(r,"default",{value:t,enumerable:!0}):r,t)),r2e=t=>Vz(L5({},"__esModule",{value:!0}),t);var jD=V(K5=>{"use strict";f();K5.byteLength=i2e;K5.toByteArray=s2e;K5.fromByteArray=d2e;var bl=[],vd=[],n2e=typeof Uint8Array<"u"?Uint8Array:Array,$D="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(_0=0,Gz=$D.length;_00)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 i2e(t){var e=Jz(t),r=e[0],n=e[1];return(r+n)*3/4-n}function o2e(t,e,r){return(e+r)*3/4-r}function s2e(t){var e,r=Jz(t),n=r[0],i=r[1],o=new n2e(o2e(t,n,i)),s=0,a=i>0?n-4:n,d;for(d=0;d>16&255,o[s++]=e>>8&255,o[s++]=e&255;return i===2&&(e=vd[t.charCodeAt(d)]<<2|vd[t.charCodeAt(d+1)]>>4,o[s++]=e&255),i===1&&(e=vd[t.charCodeAt(d)]<<10|vd[t.charCodeAt(d+1)]<<4|vd[t.charCodeAt(d+2)]>>2,o[s++]=e>>8&255,o[s++]=e&255),o}function a2e(t){return bl[t>>18&63]+bl[t>>12&63]+bl[t>>6&63]+bl[t&63]}function c2e(t,e,r){for(var n,i=[],o=e;oa?a:s+o));return n===1?(e=t[r-1],i.push(bl[e>>2]+bl[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(bl[e>>10]+bl[e>>4&63]+bl[e<<2&63]+"=")),i.join("")}});var UD=V(ND=>{f();ND.read=function(t,e,r,n,i){var o,s,a=i*8-n-1,d=(1<>1,c=-7,l=r?i-1:0,p=r?-1:1,m=t[e+l];for(l+=p,o=m&(1<<-c)-1,m>>=-c,c+=a;c>0;o=o*256+t[e+l],l+=p,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=n;c>0;s=s*256+t[e+l],l+=p,c-=8);if(o===0)o=1-u;else{if(o===d)return s?NaN:(m?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-u}return(m?-1:1)*s*Math.pow(2,o-n)};ND.write=function(t,e,r,n,i,o){var s,a,d,u=o*8-i-1,c=(1<>1,p=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,m=n?0:o-1,g=n?1:-1,v=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=c):(s=Math.floor(Math.log(e)/Math.LN2),e*(d=Math.pow(2,-s))<1&&(s--,d*=2),s+l>=1?e+=p/d:e+=p*Math.pow(2,1-l),e*d>=2&&(s++,d/=2),s+l>=c?(a=0,s=c):s+l>=1?(a=(e*d-1)*Math.pow(2,i),s=s+l):(a=e*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;t[r+m]=a&255,m+=g,a/=256,i-=8);for(s=s<0;t[r+m]=s&255,m+=g,s/=256,u-=8);t[r+m-g]|=v*128}});var cW=V(Nb=>{"use strict";f();var qD=jD(),jb=UD(),Zz=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Nb.Buffer=be;Nb.SlowBuffer=m2e;Nb.INSPECT_MAX_BYTES=50;var F5=2147483647;Nb.kMaxLength=F5;be.TYPED_ARRAY_SUPPORT=u2e();!be.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 u2e(){try{var 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(be.prototype,"parent",{enumerable:!0,get:function(){if(be.isBuffer(this))return this.buffer}});Object.defineProperty(be.prototype,"offset",{enumerable:!0,get:function(){if(be.isBuffer(this))return this.byteOffset}});function Vf(t){if(t>F5)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return Object.setPrototypeOf(e,be.prototype),e}function be(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 zD(t)}return Qz(t,e,r)}be.poolSize=8192;function Qz(t,e,r){if(typeof t=="string")return f2e(t,e);if(ArrayBuffer.isView(t))return h2e(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(wl(t,ArrayBuffer)||t&&wl(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(wl(t,SharedArrayBuffer)||t&&wl(t.buffer,SharedArrayBuffer)))return KD(t,e,r);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var n=t.valueOf&&t.valueOf();if(n!=null&&n!==t)return be.from(n,e,r);var i=p2e(t);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return be.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)}be.from=function(t,e,r){return Qz(t,e,r)};Object.setPrototypeOf(be.prototype,Uint8Array.prototype);Object.setPrototypeOf(be,Uint8Array);function eW(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 l2e(t,e,r){return eW(t),t<=0?Vf(t):e!==void 0?typeof r=="string"?Vf(t).fill(e,r):Vf(t).fill(e):Vf(t)}be.alloc=function(t,e,r){return l2e(t,e,r)};function zD(t){return eW(t),Vf(t<0?0:WD(t)|0)}be.allocUnsafe=function(t){return zD(t)};be.allocUnsafeSlow=function(t){return zD(t)};function f2e(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!be.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=tW(t,e)|0,n=Vf(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function LD(t){for(var e=t.length<0?0:WD(t.length)|0,r=Vf(e),n=0;n=F5)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+F5.toString(16)+" bytes");return t|0}function m2e(t){return+t!=t&&(t=0),be.alloc(+t)}be.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==be.prototype};be.compare=function(e,r){if(wl(e,Uint8Array)&&(e=be.from(e,e.offset,e.byteLength)),wl(r,Uint8Array)&&(r=be.from(r,r.offset,r.byteLength)),!be.isBuffer(e)||!be.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===r)return 0;for(var n=e.length,i=r.length,o=0,s=Math.min(n,i);oi.length?be.from(s).copy(i,o):Uint8Array.prototype.set.call(i,s,o);else if(be.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function tW(t,e){if(be.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||wl(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);var r=t.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return FD(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return aW(t).length;default:if(i)return n?-1:FD(t).length;e=(""+e).toLowerCase(),i=!0}}be.byteLength=tW;function y2e(t,e,r){var 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 T2e(this,e,r);case"utf8":case"utf-8":return nW(this,e,r);case"ascii":return S2e(this,e,r);case"latin1":case"binary":return A2e(this,e,r);case"base64":return x2e(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P2e(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}be.prototype._isBuffer=!0;function x0(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}be.prototype.swap16=function(){var e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var r=0;rr&&(e+=" ... "),""};Zz&&(be.prototype[Zz]=be.prototype.inspect);be.prototype.compare=function(e,r,n,i,o){if(wl(e,Uint8Array)&&(e=be.from(e,e.offset,e.byteLength)),!be.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;for(var s=o-i,a=n-r,d=Math.min(s,a),u=this.slice(i,o),c=e.slice(r,n),l=0;l2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,HD(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=be.from(e,n)),be.isBuffer(e))return e.length===0?-1:Yz(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):Yz(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Yz(t,e,r,n,i){var 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 d(m,g){return o===1?m[g]:m.readUInt16BE(g*o)}var u;if(i){var c=-1;for(u=r;us&&(r=s-a),u=r;u>=0;u--){for(var l=!0,p=0;pi&&(n=i)):n=i;var o=e.length;n>o/2&&(n=o/2);for(var s=0;s>>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");var 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");for(var s=!1;;)switch(i){case"hex":return g2e(this,e,r,n);case"utf8":case"utf-8":return v2e(this,e,r,n);case"ascii":case"latin1":case"binary":return b2e(this,e,r,n);case"base64":return w2e(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _2e(this,e,r,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};be.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function x2e(t,e,r){return e===0&&r===t.length?qD.fromByteArray(t):qD.fromByteArray(t.slice(e,r))}function nW(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:o>223?3:o>191?2:1;if(i+a<=r){var d,u,c,l;switch(a){case 1:o<128&&(s=o);break;case 2:d=t[i+1],(d&192)===128&&(l=(o&31)<<6|d&63,l>127&&(s=l));break;case 3:d=t[i+1],u=t[i+2],(d&192)===128&&(u&192)===128&&(l=(o&15)<<12|(d&63)<<6|u&63,l>2047&&(l<55296||l>57343)&&(s=l));break;case 4:d=t[i+1],u=t[i+2],c=t[i+3],(d&192)===128&&(u&192)===128&&(c&192)===128&&(l=(o&15)<<18|(d&63)<<12|(u&63)<<6|c&63,l>65535&&l<1114112&&(s=l))}}s===null?(s=65533,a=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),i+=a}return E2e(n)}var Xz=4096;function E2e(t){var e=t.length;if(e<=Xz)return String.fromCharCode.apply(String,t);for(var r="",n=0;nn)&&(r=n);for(var i="",o=e;on&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),rr)throw new RangeError("Trying to access beyond buffer length")}be.prototype.readUintLE=be.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||Eo(e,r,this.length);for(var i=this[e],o=1,s=0;++s>>0,r=r>>>0,n||Eo(e,r,this.length);for(var i=this[e+--r],o=1;r>0&&(o*=256);)i+=this[e+--r]*o;return i};be.prototype.readUint8=be.prototype.readUInt8=function(e,r){return e=e>>>0,r||Eo(e,1,this.length),this[e]};be.prototype.readUint16LE=be.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||Eo(e,2,this.length),this[e]|this[e+1]<<8};be.prototype.readUint16BE=be.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||Eo(e,2,this.length),this[e]<<8|this[e+1]};be.prototype.readUint32LE=be.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||Eo(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};be.prototype.readUint32BE=be.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||Eo(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};be.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||Eo(e,r,this.length);for(var i=this[e],o=1,s=0;++s=o&&(i-=Math.pow(2,8*r)),i};be.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||Eo(e,r,this.length);for(var i=r,o=1,s=this[e+--i];i>0&&(o*=256);)s+=this[e+--i]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*r)),s};be.prototype.readInt8=function(e,r){return e=e>>>0,r||Eo(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};be.prototype.readInt16LE=function(e,r){e=e>>>0,r||Eo(e,2,this.length);var n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};be.prototype.readInt16BE=function(e,r){e=e>>>0,r||Eo(e,2,this.length);var n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};be.prototype.readInt32LE=function(e,r){return e=e>>>0,r||Eo(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};be.prototype.readInt32BE=function(e,r){return e=e>>>0,r||Eo(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};be.prototype.readFloatLE=function(e,r){return e=e>>>0,r||Eo(e,4,this.length),jb.read(this,e,!0,23,4)};be.prototype.readFloatBE=function(e,r){return e=e>>>0,r||Eo(e,4,this.length),jb.read(this,e,!1,23,4)};be.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||Eo(e,8,this.length),jb.read(this,e,!0,52,8)};be.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||Eo(e,8,this.length),jb.read(this,e,!1,52,8)};function Ga(t,e,r,n,i,o){if(!be.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}be.prototype.writeUintLE=be.prototype.writeUIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){var o=Math.pow(2,8*n)-1;Ga(this,e,r,n,o,0)}var s=1,a=0;for(this[r]=e&255;++a>>0,n=n>>>0,!i){var o=Math.pow(2,8*n)-1;Ga(this,e,r,n,o,0)}var s=n-1,a=1;for(this[r+s]=e&255;--s>=0&&(a*=256);)this[r+s]=e/a&255;return r+n};be.prototype.writeUint8=be.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||Ga(this,e,r,1,255,0),this[r]=e&255,r+1};be.prototype.writeUint16LE=be.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||Ga(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};be.prototype.writeUint16BE=be.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||Ga(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};be.prototype.writeUint32LE=be.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||Ga(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};be.prototype.writeUint32BE=be.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||Ga(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};be.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){var o=Math.pow(2,8*n-1);Ga(this,e,r,n,o-1,-o)}var s=0,a=1,d=0;for(this[r]=e&255;++s>0)-d&255;return r+n};be.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){var o=Math.pow(2,8*n-1);Ga(this,e,r,n,o-1,-o)}var s=n-1,a=1,d=0;for(this[r+s]=e&255;--s>=0&&(a*=256);)e<0&&d===0&&this[r+s+1]!==0&&(d=1),this[r+s]=(e/a>>0)-d&255;return r+n};be.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||Ga(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};be.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||Ga(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};be.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||Ga(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};be.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||Ga(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};be.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||Ga(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};function iW(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 oW(t,e,r,n,i){return e=+e,r=r>>>0,i||iW(t,e,r,4,34028234663852886e22,-34028234663852886e22),jb.write(t,e,r,n,23,4),r+4}be.prototype.writeFloatLE=function(e,r,n){return oW(this,e,r,!0,n)};be.prototype.writeFloatBE=function(e,r,n){return oW(this,e,r,!1,n)};function sW(t,e,r,n,i){return e=+e,r=r>>>0,i||iW(t,e,r,8,17976931348623157e292,-17976931348623157e292),jb.write(t,e,r,n,52,8),r+8}be.prototype.writeDoubleLE=function(e,r,n){return sW(this,e,r,!0,n)};be.prototype.writeDoubleBE=function(e,r,n){return sW(this,e,r,!1,n)};be.prototype.copy=function(e,r,n,i){if(!be.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=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>>0,n=n===void 0?this.length:n>>>0,e||(e=0);var s;if(typeof e=="number")for(s=r;s55295&&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 R2e(t){for(var e=[],r=0;r>8,i=r%256,o.push(i),o.push(n);return o}function aW(t){return qD.toByteArray(k2e(t))}function z5(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function wl(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function HD(t){return t!==t}var B2e=function(){for(var t="0123456789abcdef",e=new Array(256),r=0;r<16;++r)for(var n=r*16,i=0;i<16;++i)e[n+i]=t[r]+t[i];return e}()});var js=V((_it,fW)=>{f();var Ti=fW.exports={},_l,xl;function VD(){throw new Error("setTimeout has not been defined")}function GD(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?_l=setTimeout:_l=VD}catch{_l=VD}try{typeof clearTimeout=="function"?xl=clearTimeout:xl=GD}catch{xl=GD}})();function dW(t){if(_l===setTimeout)return setTimeout(t,0);if((_l===VD||!_l)&&setTimeout)return _l=setTimeout,setTimeout(t,0);try{return _l(t,0)}catch{try{return _l.call(null,t,0)}catch{return _l.call(this,t,0)}}}function M2e(t){if(xl===clearTimeout)return clearTimeout(t);if((xl===GD||!xl)&&clearTimeout)return xl=clearTimeout,clearTimeout(t);try{return xl(t)}catch{try{return xl.call(null,t)}catch{return xl.call(this,t)}}}var Gf=[],Ub=!1,E0,W5=-1;function O2e(){!Ub||!E0||(Ub=!1,E0.length?Gf=E0.concat(Gf):W5=-1,Gf.length&&uW())}function uW(){if(!Ub){var t=dW(O2e);Ub=!0;for(var e=Gf.length;e;){for(E0=Gf,Gf=[];++W51)for(var r=1;r{O=gt(cW()),k=gt(js()),Eit=function(t){function e(){var n=this||self;return delete t.prototype.__magic__,n}if(typeof globalThis=="object")return globalThis;if(this)return e();t.defineProperty(t.prototype,"__magic__",{configurable:!0,get:e});var r=__magic__;return r}(Object)});var pW=V((Ait,hW)=>{f();var C2e=typeof globalThis=="object"&&globalThis&&globalThis.Object===Object&&globalThis;hW.exports=C2e});var yW=V((Pit,mW)=>{f();var $2e=pW(),j2e=typeof self=="object"&&self&&self.Object===Object&&self,N2e=$2e||j2e||Function("return this")();mW.exports=N2e});var JD=V((kit,gW)=>{f();var U2e=yW(),q2e=U2e.Symbol;gW.exports=q2e});var _W=V((Dit,wW)=>{f();var vW=JD(),bW=Object.prototype,L2e=bW.hasOwnProperty,K2e=bW.toString,z_=vW?vW.toStringTag:void 0;function F2e(t){var e=L2e.call(t,z_),r=t[z_];try{t[z_]=void 0;var n=!0}catch{}var i=K2e.call(t);return n&&(e?t[z_]=r:delete t[z_]),i}wW.exports=F2e});var EW=V((Mit,xW)=>{f();var z2e=Object.prototype,W2e=z2e.toString;function H2e(t){return W2e.call(t)}xW.exports=H2e});var PW=V((Cit,TW)=>{f();var SW=JD(),V2e=_W(),G2e=EW(),J2e="[object Null]",Z2e="[object Undefined]",AW=SW?SW.toStringTag:void 0;function Y2e(t){return t==null?t===void 0?Z2e:J2e:AW&&AW in Object(t)?V2e(t):G2e(t)}TW.exports=Y2e});var kW=V((jit,IW)=>{f();function X2e(t,e){return function(r){return t(e(r))}}IW.exports=X2e});var DW=V((Uit,RW)=>{f();var Q2e=kW(),e_e=Q2e(Object.getPrototypeOf,Object);RW.exports=e_e});var MW=V((Lit,BW)=>{f();function t_e(t){return t!=null&&typeof t=="object"}BW.exports=t_e});var $W=V((Fit,CW)=>{f();var r_e=PW(),n_e=DW(),i_e=MW(),o_e="[object Object]",s_e=Function.prototype,a_e=Object.prototype,OW=s_e.toString,c_e=a_e.hasOwnProperty,d_e=OW.call(Object);function u_e(t){if(!i_e(t)||r_e(t)!=o_e)return!1;var e=n_e(t);if(e===null)return!0;var r=c_e.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&OW.call(r)==d_e}CW.exports=u_e});var Oc=V((klt,nJ)=>{"use strict";f();function rJ(t,e){for(let r in e)Object.defineProperty(t,r,{value:e[r],enumerable:!0,configurable:!0});return t}function t3e(t,e,r){if(!t||typeof t=="string")throw new TypeError("Please pass an Error to err-code");r||(r={}),typeof e=="object"&&(r=e,e=""),e&&(r.code=e);try{return rJ(t,r)}catch{r.message=t.message,r.stack=t.stack;let i=function(){};return i.prototype=Object.create(Object.getPrototypeOf(t)),rJ(new i,r)}}nJ.exports=t3e});var XJ=V((Nx,N8)=>{f();(function(t,e){"use strict";var r={version:"3.0.0",x86:{},x64:{},inputValidation:!0};function n(m){if(!Array.isArray(m)&&!ArrayBuffer.isView(m))return!1;for(var g=0;g255)return!1;return!0}function i(m,g){return(m&65535)*g+(((m>>>16)*g&65535)<<16)}function o(m,g){return m<>>32-g}function s(m){return m^=m>>>16,m=i(m,2246822507),m^=m>>>13,m=i(m,3266489909),m^=m>>>16,m}function a(m,g){m=[m[0]>>>16,m[0]&65535,m[1]>>>16,m[1]&65535],g=[g[0]>>>16,g[0]&65535,g[1]>>>16,g[1]&65535];var v=[0,0,0,0];return v[3]+=m[3]+g[3],v[2]+=v[3]>>>16,v[3]&=65535,v[2]+=m[2]+g[2],v[1]+=v[2]>>>16,v[2]&=65535,v[1]+=m[1]+g[1],v[0]+=v[1]>>>16,v[1]&=65535,v[0]+=m[0]+g[0],v[0]&=65535,[v[0]<<16|v[1],v[2]<<16|v[3]]}function d(m,g){m=[m[0]>>>16,m[0]&65535,m[1]>>>16,m[1]&65535],g=[g[0]>>>16,g[0]&65535,g[1]>>>16,g[1]&65535];var v=[0,0,0,0];return v[3]+=m[3]*g[3],v[2]+=v[3]>>>16,v[3]&=65535,v[2]+=m[2]*g[3],v[1]+=v[2]>>>16,v[2]&=65535,v[2]+=m[3]*g[2],v[1]+=v[2]>>>16,v[2]&=65535,v[1]+=m[1]*g[3],v[0]+=v[1]>>>16,v[1]&=65535,v[1]+=m[2]*g[2],v[0]+=v[1]>>>16,v[1]&=65535,v[1]+=m[3]*g[1],v[0]+=v[1]>>>16,v[1]&=65535,v[0]+=m[0]*g[3]+m[1]*g[2]+m[2]*g[1]+m[3]*g[0],v[0]&=65535,[v[0]<<16|v[1],v[2]<<16|v[3]]}function u(m,g){return g%=64,g===32?[m[1],m[0]]:g<32?[m[0]<>>32-g,m[1]<>>32-g]:(g-=32,[m[1]<>>32-g,m[0]<>>32-g])}function c(m,g){return g%=64,g===0?m:g<32?[m[0]<>>32-g,m[1]<>>1]),m=d(m,[4283543511,3981806797]),m=l(m,[0,m[0]>>>1]),m=d(m,[3301882366,444984403]),m=l(m,[0,m[0]>>>1]),m}r.x86.hash32=function(m,g){if(r.inputValidation&&!n(m))return e;g=g||0;for(var v=m.length%4,x=m.length-v,S=g,P=0,A=3432918353,$=461845907,j=0;j>>0},r.x86.hash128=function(m,g){if(r.inputValidation&&!n(m))return e;g=g||0;for(var v=m.length%16,x=m.length-v,S=g,P=g,A=g,$=g,j=0,q=0,F=0,K=0,W=597399067,L=2869860233,I=951274213,T=2716044179,B=0;B>>0).toString(16)).slice(-8)+("00000000"+(P>>>0).toString(16)).slice(-8)+("00000000"+(A>>>0).toString(16)).slice(-8)+("00000000"+($>>>0).toString(16)).slice(-8)},r.x64.hash128=function(m,g){if(r.inputValidation&&!n(m))return e;g=g||0;for(var v=m.length%16,x=m.length-v,S=[0,g],P=[0,g],A=[0,0],$=[0,0],j=[2277735313,289559509],q=[1291169091,658871167],F=0;F>>0).toString(16)).slice(-8)+("00000000"+(S[1]>>>0).toString(16)).slice(-8)+("00000000"+(P[0]>>>0).toString(16)).slice(-8)+("00000000"+(P[1]>>>0).toString(16)).slice(-8)},typeof Nx<"u"?(typeof N8<"u"&&N8.exports&&(Nx=N8.exports=r),Nx.murmurHash3=r):typeof define=="function"&&define.amd?define([],function(){return r}):(r._murmurHash3=t.murmurHash3,r.noConflict=function(){return t.murmurHash3=r._murmurHash3,r._murmurHash3=e,r.noConflict=e,r},t.murmurHash3=r)})(Nx)});var eZ=V((omt,QJ)=>{f();QJ.exports=XJ()});var nZ=V((pmt,rZ)=>{"use strict";f();rZ.exports=class{constructor(){this._bitArrays=[],this._data=[],this._length=0,this._changedLength=!1,this._changedData=!1}set(e,r){let n=this._internalPositionFor(e,!1);if(r===void 0)n!==-1&&(this._unsetInternalPos(n),this._unsetBit(e),this._changedLength=!0,this._changedData=!0);else{let i=!1;n===-1?(n=this._data.length,this._setBit(e),this._changedData=!0):i=!0,this._setInternalPos(n,e,r,i),this._changedLength=!0}}unset(e){this.set(e,void 0)}get(e){this._sortData();let r=this._internalPositionFor(e,!0);if(r!==-1)return this._data[r][1]}push(e){return this.set(this.length,e),this.length}get length(){if(this._sortData(),this._changedLength){let e=this._data[this._data.length-1];this._length=e?e[0]+1:0,this._changedLength=!1}return this._length}forEach(e){let r=0;for(;r=this._bitArrays.length)return-1;let i=this._bitArrays[n],o=e-n*7;if(!((i&1<0))return-1;let a=this._bitArrays.slice(0,n).reduce(c5e,0),d=~(4294967295<=r)o.push(s);else if(o[0][0]<=r)o.unshift(s);else{let a=Math.round(o.length/2);this._data=o.slice(0,a).concat(s).concat(o.slice(a))}else this._data.push(s);this._changedData=!0,this._changedLength=!0}}_unsetInternalPos(e){this._data.splice(e,1)}_sortData(){this._changedData&&this._data.sort(d5e),this._changedData=!1}bitField(){let e=[],r=8,n=0,i=0,o,s=this._bitArrays.slice();for(;s.length||n;){n===0&&(o=s.shift(),n=7);let d=Math.min(n,r),u=~(255<>>d,n-=d,r-=d,(!r||!n&&!s.length)&&(e.push(i),i=0,r=8)}for(var a=e.length-1;a>0&&e[a]===0;a--)e.pop();return e}compactArray(){return this._sortData(),this._data.map(u5e)}};function c5e(t,e){return t+tZ(e)}function tZ(t){let e=t;return e=e-(e>>1&1431655765),e=(e&858993459)+(e>>2&858993459),(e+(e>>4)&252645135)*16843009>>24}function d5e(t,e){return t[0]-e[0]}function u5e(t){return t[1]}});var pn=V(Tw=>{"use strict";f();var p7=jD(),Sw=UD(),gZ=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Tw.Buffer=ge;Tw.SlowBuffer=I5e;Tw.INSPECT_MAX_BYTES=50;var z8=2147483647;Tw.kMaxLength=z8;ge.TYPED_ARRAY_SUPPORT=E5e();!ge.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 E5e(){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(ge.prototype,"parent",{enumerable:!0,get:function(){if(ge.isBuffer(this))return this.buffer}});Object.defineProperty(ge.prototype,"offset",{enumerable:!0,get:function(){if(ge.isBuffer(this))return this.byteOffset}});function dh(t){if(t>z8)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,ge.prototype),e}function ge(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 v7(t)}return _Z(t,e,r)}ge.poolSize=8192;function _Z(t,e,r){if(typeof t=="string")return A5e(t,e);if(ArrayBuffer.isView(t))return T5e(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(Bl(t,ArrayBuffer)||t&&Bl(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Bl(t,SharedArrayBuffer)||t&&Bl(t.buffer,SharedArrayBuffer)))return y7(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 ge.from(n,e,r);let i=P5e(t);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return ge.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)}ge.from=function(t,e,r){return _Z(t,e,r)};Object.setPrototypeOf(ge.prototype,Uint8Array.prototype);Object.setPrototypeOf(ge,Uint8Array);function xZ(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 S5e(t,e,r){return xZ(t),t<=0?dh(t):e!==void 0?typeof r=="string"?dh(t).fill(e,r):dh(t).fill(e):dh(t)}ge.alloc=function(t,e,r){return S5e(t,e,r)};function v7(t){return xZ(t),dh(t<0?0:b7(t)|0)}ge.allocUnsafe=function(t){return v7(t)};ge.allocUnsafeSlow=function(t){return v7(t)};function A5e(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!ge.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=EZ(t,e)|0,n=dh(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function m7(t){let e=t.length<0?0:b7(t.length)|0,r=dh(e);for(let n=0;n=z8)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+z8.toString(16)+" bytes");return t|0}function I5e(t){return+t!=t&&(t=0),ge.alloc(+t)}ge.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==ge.prototype};ge.compare=function(e,r){if(Bl(e,Uint8Array)&&(e=ge.from(e,e.offset,e.byteLength)),Bl(r,Uint8Array)&&(r=ge.from(r,r.offset,r.byteLength)),!ge.isBuffer(e)||!ge.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);oi.length?(ge.isBuffer(s)||(s=ge.from(s)),s.copy(i,o)):Uint8Array.prototype.set.call(i,s,o);else if(ge.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function EZ(t,e){if(ge.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Bl(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 g7(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return BZ(t).length;default:if(i)return n?-1:g7(t).length;e=(""+e).toLowerCase(),i=!0}}ge.byteLength=EZ;function k5e(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 U5e(this,e,r);case"utf8":case"utf-8":return AZ(this,e,r);case"ascii":return j5e(this,e,r);case"latin1":case"binary":return N5e(this,e,r);case"base64":return C5e(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return q5e(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}ge.prototype._isBuffer=!0;function Q0(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}ge.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;rr&&(e+=" ... "),""};gZ&&(ge.prototype[gZ]=ge.prototype.inspect);ge.prototype.compare=function(e,r,n,i,o){if(Bl(e,Uint8Array)&&(e=ge.from(e,e.offset,e.byteLength)),!ge.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,d=Math.min(s,a),u=this.slice(i,o),c=e.slice(r,n);for(let l=0;l2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,_7(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=ge.from(e,n)),ge.isBuffer(e))return e.length===0?-1:vZ(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):vZ(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function vZ(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 d(c,l){return o===1?c[l]:c.readUInt16BE(l*o)}let u;if(i){let c=-1;for(u=r;us&&(r=s-a),u=r;u>=0;u--){let c=!0;for(let l=0;li&&(n=i)):n=i;let o=e.length;n>o/2&&(n=o/2);let s;for(s=0;s>>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 R5e(this,e,r,n);case"utf8":case"utf-8":return D5e(this,e,r,n);case"ascii":case"latin1":case"binary":return B5e(this,e,r,n);case"base64":return M5e(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O5e(this,e,r,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};ge.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function C5e(t,e,r){return e===0&&r===t.length?p7.fromByteArray(t):p7.fromByteArray(t.slice(e,r))}function AZ(t,e,r){r=Math.min(t.length,r);let n=[],i=e;for(;i239?4:o>223?3:o>191?2:1;if(i+a<=r){let d,u,c,l;switch(a){case 1:o<128&&(s=o);break;case 2:d=t[i+1],(d&192)===128&&(l=(o&31)<<6|d&63,l>127&&(s=l));break;case 3:d=t[i+1],u=t[i+2],(d&192)===128&&(u&192)===128&&(l=(o&15)<<12|(d&63)<<6|u&63,l>2047&&(l<55296||l>57343)&&(s=l));break;case 4:d=t[i+1],u=t[i+2],c=t[i+3],(d&192)===128&&(u&192)===128&&(c&192)===128&&(l=(o&15)<<18|(d&63)<<12|(u&63)<<6|c&63,l>65535&&l<1114112&&(s=l))}}s===null?(s=65533,a=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),i+=a}return $5e(n)}var bZ=4096;function $5e(t){let e=t.length;if(e<=bZ)return String.fromCharCode.apply(String,t);let r="",n=0;for(;nn)&&(r=n);let i="";for(let o=e;on&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),rr)throw new RangeError("Trying to access beyond buffer length")}ge.prototype.readUintLE=ge.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||Do(e,r,this.length);let i=this[e],o=1,s=0;for(;++s>>0,r=r>>>0,n||Do(e,r,this.length);let i=this[e+--r],o=1;for(;r>0&&(o*=256);)i+=this[e+--r]*o;return i};ge.prototype.readUint8=ge.prototype.readUInt8=function(e,r){return e=e>>>0,r||Do(e,1,this.length),this[e]};ge.prototype.readUint16LE=ge.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||Do(e,2,this.length),this[e]|this[e+1]<<8};ge.prototype.readUint16BE=ge.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||Do(e,2,this.length),this[e]<<8|this[e+1]};ge.prototype.readUint32LE=ge.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||Do(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};ge.prototype.readUint32BE=ge.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||Do(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};ge.prototype.readBigUInt64LE=fm(function(e){e=e>>>0,Aw(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&qx(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)<>>0,Aw(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&qx(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)<>>0,r=r>>>0,n||Do(e,r,this.length);let i=this[e],o=1,s=0;for(;++s=o&&(i-=Math.pow(2,8*r)),i};ge.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||Do(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};ge.prototype.readInt8=function(e,r){return e=e>>>0,r||Do(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};ge.prototype.readInt16LE=function(e,r){e=e>>>0,r||Do(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};ge.prototype.readInt16BE=function(e,r){e=e>>>0,r||Do(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};ge.prototype.readInt32LE=function(e,r){return e=e>>>0,r||Do(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};ge.prototype.readInt32BE=function(e,r){return e=e>>>0,r||Do(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};ge.prototype.readBigInt64LE=fm(function(e){e=e>>>0,Aw(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&qx(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<>>0,Aw(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&qx(e,this.length-8);let i=(r<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(i)<>>0,r||Do(e,4,this.length),Sw.read(this,e,!0,23,4)};ge.prototype.readFloatBE=function(e,r){return e=e>>>0,r||Do(e,4,this.length),Sw.read(this,e,!1,23,4)};ge.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||Do(e,8,this.length),Sw.read(this,e,!0,52,8)};ge.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||Do(e,8,this.length),Sw.read(this,e,!1,52,8)};function Ya(t,e,r,n,i,o){if(!ge.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}ge.prototype.writeUintLE=ge.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;Ya(this,e,r,n,a,0)}let o=1,s=0;for(this[r]=e&255;++s>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;Ya(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};ge.prototype.writeUint8=ge.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||Ya(this,e,r,1,255,0),this[r]=e&255,r+1};ge.prototype.writeUint16LE=ge.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||Ya(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};ge.prototype.writeUint16BE=ge.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||Ya(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};ge.prototype.writeUint32LE=ge.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||Ya(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};ge.prototype.writeUint32BE=ge.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||Ya(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 TZ(t,e,r,n,i){DZ(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 PZ(t,e,r,n,i){DZ(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}ge.prototype.writeBigUInt64LE=fm(function(e,r=0){return TZ(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});ge.prototype.writeBigUInt64BE=fm(function(e,r=0){return PZ(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});ge.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let d=Math.pow(2,8*n-1);Ya(this,e,r,n,d-1,-d)}let o=0,s=1,a=0;for(this[r]=e&255;++o>0)-a&255;return r+n};ge.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let d=Math.pow(2,8*n-1);Ya(this,e,r,n,d-1,-d)}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};ge.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||Ya(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};ge.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||Ya(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};ge.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||Ya(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};ge.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||Ya(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};ge.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||Ya(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};ge.prototype.writeBigInt64LE=fm(function(e,r=0){return TZ(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});ge.prototype.writeBigInt64BE=fm(function(e,r=0){return PZ(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function IZ(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 kZ(t,e,r,n,i){return e=+e,r=r>>>0,i||IZ(t,e,r,4,34028234663852886e22,-34028234663852886e22),Sw.write(t,e,r,n,23,4),r+4}ge.prototype.writeFloatLE=function(e,r,n){return kZ(this,e,r,!0,n)};ge.prototype.writeFloatBE=function(e,r,n){return kZ(this,e,r,!1,n)};function RZ(t,e,r,n,i){return e=+e,r=r>>>0,i||IZ(t,e,r,8,17976931348623157e292,-17976931348623157e292),Sw.write(t,e,r,n,52,8),r+8}ge.prototype.writeDoubleLE=function(e,r,n){return RZ(this,e,r,!0,n)};ge.prototype.writeDoubleBE=function(e,r,n){return RZ(this,e,r,!1,n)};ge.prototype.copy=function(e,r,n,i){if(!ge.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=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>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let o;if(typeof e=="number")for(o=r;o2**32?i=wZ(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=wZ(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function wZ(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 L5e(t,e,r){Aw(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&qx(e,t.length-(r+1))}function DZ(t,e,r,n,i,o){if(t>r||t3?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 Ew.ERR_OUT_OF_RANGE("value",a,t)}L5e(n,i,o)}function Aw(t,e){if(typeof t!="number")throw new Ew.ERR_INVALID_ARG_TYPE(e,"number",t)}function qx(t,e,r){throw Math.floor(t)!==t?(Aw(t,r),new Ew.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new Ew.ERR_BUFFER_OUT_OF_BOUNDS:new Ew.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var K5e=/[^+/0-9A-Za-z-_]/g;function F5e(t){if(t=t.split("=")[0],t=t.trim().replace(K5e,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function g7(t,e){e=e||1/0;let r,n=t.length,i=null,o=[];for(let s=0;s55295&&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 z5e(t){let e=[];for(let r=0;r>8,i=r%256,o.push(i),o.push(n);return o}function BZ(t){return p7.toByteArray(F5e(t))}function W8(t,e,r,n){let i;for(i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function Bl(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function _7(t){return t!==t}var H5e=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 fm(t){return typeof BigInt>"u"?V5e:t}function V5e(){throw new Error("BigInt not supported")}});var cr=V((x7,OZ)=>{f();var H8=pn(),Ml=H8.Buffer;function MZ(t,e){for(var r in t)e[r]=t[r]}Ml.from&&Ml.alloc&&Ml.allocUnsafe&&Ml.allocUnsafeSlow?OZ.exports=H8:(MZ(H8,x7),x7.Buffer=eg);function eg(t,e,r){return Ml(t,e,r)}eg.prototype=Object.create(Ml.prototype);MZ(Ml,eg);eg.from=function(t,e,r){if(typeof t=="number")throw new TypeError("Argument must not be a number");return Ml(t,e,r)};eg.alloc=function(t,e,r){if(typeof t!="number")throw new TypeError("Argument must be a number");var n=Ml(t);return e!==void 0?typeof r=="string"?n.fill(e,r):n.fill(e):n.fill(0),n};eg.allocUnsafe=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return Ml(t)};eg.allocUnsafeSlow=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return H8.SlowBuffer(t)}});var tg=V((gyt,S7)=>{"use strict";f();var E7=65536,G5e=4294967295;function J5e(){throw new Error(`Secure random number generation is not supported by this browser. +Use Chrome, Firefox or Internet Explorer 11`)}var Z5e=cr().Buffer,V8=globalThis.crypto||globalThis.msCrypto;V8&&V8.getRandomValues?S7.exports=Y5e:S7.exports=J5e;function Y5e(t,e){if(t>G5e)throw new RangeError("requested too many random bytes");var r=Z5e.allocUnsafe(t);if(t>0)if(t>E7)for(var n=0;n{f();typeof Object.create=="function"?A7.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:A7.exports=function(e,r){if(r){e.super_=r;var n=function(){};n.prototype=r.prototype,e.prototype=new n,e.prototype.constructor=e}}});var Aa=V((_yt,T7)=>{"use strict";f();var Pw=typeof Reflect=="object"?Reflect:null,CZ=Pw&&typeof Pw.apply=="function"?Pw.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},G8;Pw&&typeof Pw.ownKeys=="function"?G8=Pw.ownKeys:Object.getOwnPropertySymbols?G8=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:G8=function(e){return Object.getOwnPropertyNames(e)};function X5e(t){console&&console.warn&&console.warn(t)}var jZ=Number.isNaN||function(e){return e!==e};function mn(){mn.init.call(this)}T7.exports=mn;T7.exports.once=r8e;mn.EventEmitter=mn;mn.prototype._events=void 0;mn.prototype._eventsCount=0;mn.prototype._maxListeners=void 0;var $Z=10;function J8(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(mn,"defaultMaxListeners",{enumerable:!0,get:function(){return $Z},set:function(t){if(typeof t!="number"||t<0||jZ(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");$Z=t}});mn.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};mn.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||jZ(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 NZ(t){return t._maxListeners===void 0?mn.defaultMaxListeners:t._maxListeners}mn.prototype.getMaxListeners=function(){return NZ(this)};mn.prototype.emit=function(e){for(var r=[],n=1;n0&&(s=r[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var d=o[e];if(d===void 0)return!1;if(typeof d=="function")CZ(d,this,r);else for(var u=d.length,c=FZ(d,u),n=0;n0&&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,X5e(a)}return t}mn.prototype.addListener=function(e,r){return UZ(this,e,r,!1)};mn.prototype.on=mn.prototype.addListener;mn.prototype.prependListener=function(e,r){return UZ(this,e,r,!0)};function Q5e(){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 qZ(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=Q5e.bind(n);return i.listener=r,n.wrapFn=i,i}mn.prototype.once=function(e,r){return J8(r),this.on(e,qZ(this,e,r)),this};mn.prototype.prependOnceListener=function(e,r){return J8(r),this.prependListener(e,qZ(this,e,r)),this};mn.prototype.removeListener=function(e,r){var n,i,o,s,a;if(J8(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():e8e(n,o),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this};mn.prototype.off=mn.prototype.removeListener;mn.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=0;i--)this.removeListener(e,r[i]);return this};function LZ(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?t8e(i):FZ(i,i.length)}mn.prototype.listeners=function(e){return LZ(this,e,!0)};mn.prototype.rawListeners=function(e){return LZ(this,e,!1)};mn.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):KZ.call(t,e)};mn.prototype.listenerCount=KZ;function KZ(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}mn.prototype.eventNames=function(){return this._eventsCount>0?G8(this._events):[]};function FZ(t,e){for(var r=new Array(e),n=0;n{f();WZ.exports=Aa().EventEmitter});var Lx=V(()=>{f()});var YZ=V((Iyt,ZZ)=>{"use strict";f();function HZ(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),r.push.apply(r,n)}return r}function VZ(t){for(var e=1;e0?this.tail.next=n:this.head=n,this.tail=n,++this.length}},{key:"unshift",value:function(r){var n={data:r,next:this.head};this.length===0&&(this.tail=n),this.head=n,++this.length}},{key:"shift",value:function(){if(this.length!==0){var r=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,r}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(r){if(this.length===0)return"";for(var n=this.head,i=""+n.data;n=n.next;)i+=r+n.data;return i}},{key:"concat",value:function(r){if(this.length===0)return Z8.alloc(0);for(var n=Z8.allocUnsafe(r>>>0),i=this.head,o=0;i;)l8e(i.data,n,o),o+=i.data.length,i=i.next;return n}},{key:"consume",value:function(r,n){var i;return rs.length?s.length:r;if(a===s.length?o+=s:o+=s.slice(0,r),r-=a,r===0){a===s.length?(++i,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=s.slice(a));break}++i}return this.length-=i,o}},{key:"_getBuffer",value:function(r){var n=Z8.allocUnsafe(r),i=this.head,o=1;for(i.data.copy(n),r-=i.data.length;i=i.next;){var s=i.data,a=r>s.length?s.length:r;if(s.copy(n,n.length-r,0,a),r-=a,r===0){a===s.length?(++o,i.next?this.head=i.next:this.head=this.tail=null):(this.head=i,i.data=s.slice(a));break}++o}return this.length-=o,n}},{key:u8e,value:function(r,n){return I7(this,VZ(VZ({},n),{},{depth:0,customInspect:!1}))}}]),t}()});var R7=V((Ryt,QZ)=>{"use strict";f();function f8e(t,e){var r=this,n=this._readableState&&this._readableState.destroyed,i=this._writableState&&this._writableState.destroyed;return n||i?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,k.default.nextTick(k7,this,t)):k.default.nextTick(k7,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(o){!e&&o?r._writableState?r._writableState.errorEmitted?k.default.nextTick(Y8,r):(r._writableState.errorEmitted=!0,k.default.nextTick(XZ,r,o)):k.default.nextTick(XZ,r,o):e?(k.default.nextTick(Y8,r),e(o)):k.default.nextTick(Y8,r)}),this)}function XZ(t,e){k7(t,e),Y8(t)}function Y8(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function h8e(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function k7(t,e){t.emit("error",e)}function p8e(t,e){var r=t._readableState,n=t._writableState;r&&r.autoDestroy||n&&n.autoDestroy?t.destroy(e):t.emit("error",e)}QZ.exports={destroy:f8e,undestroy:h8e,errorOrDestroy:p8e}});var rg=V((Byt,rY)=>{"use strict";f();function m8e(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}var tY={};function Ed(t,e,r){r||(r=Error);function n(o,s,a){return typeof e=="string"?e:e(o,s,a)}var i=function(o){m8e(s,o);function s(a,d,u){return o.call(this,n(a,d,u))||this}return s}(r);i.prototype.name=r.name,i.prototype.code=t,tY[t]=i}function eY(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map(function(n){return String(n)}),r>2?"one of ".concat(e," ").concat(t.slice(0,r-1).join(", "),", or ")+t[r-1]:r===2?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}else return"of ".concat(e," ").concat(String(t))}function y8e(t,e,r){return t.substr(!r||r<0?0:+r,e.length)===e}function g8e(t,e,r){return(r===void 0||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}function v8e(t,e,r){return typeof r!="number"&&(r=0),r+e.length>t.length?!1:t.indexOf(e,r)!==-1}Ed("ERR_INVALID_OPT_VALUE",function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'},TypeError);Ed("ERR_INVALID_ARG_TYPE",function(t,e,r){var n;typeof e=="string"&&y8e(e,"not ")?(n="must not be",e=e.replace(/^not /,"")):n="must be";var i;if(g8e(t," argument"))i="The ".concat(t," ").concat(n," ").concat(eY(e,"type"));else{var o=v8e(t,".")?"property":"argument";i='The "'.concat(t,'" ').concat(o," ").concat(n," ").concat(eY(e,"type"))}return i+=". Received type ".concat(typeof r),i},TypeError);Ed("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF");Ed("ERR_METHOD_NOT_IMPLEMENTED",function(t){return"The "+t+" method is not implemented"});Ed("ERR_STREAM_PREMATURE_CLOSE","Premature close");Ed("ERR_STREAM_DESTROYED",function(t){return"Cannot call "+t+" after a stream was destroyed"});Ed("ERR_MULTIPLE_CALLBACK","Callback called multiple times");Ed("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable");Ed("ERR_STREAM_WRITE_AFTER_END","write after end");Ed("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);Ed("ERR_UNKNOWN_ENCODING",function(t){return"Unknown encoding: "+t},TypeError);Ed("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event");rY.exports.codes=tY});var D7=V((Oyt,nY)=>{"use strict";f();var b8e=rg().codes.ERR_INVALID_OPT_VALUE;function w8e(t,e,r){return t.highWaterMark!=null?t.highWaterMark:e?t[r]:null}function _8e(t,e,r,n){var i=w8e(e,n,r);if(i!=null){if(!(isFinite(i)&&Math.floor(i)===i)||i<0){var o=n?r:"highWaterMark";throw new b8e(o,i)}return Math.floor(i)}return t.objectMode?16:16*1024}nY.exports={getHighWaterMark:_8e}});var M7=V(($yt,iY)=>{f();iY.exports=x8e;function x8e(t,e){if(B7("noDeprecation"))return t;var r=!1;function n(){if(!r){if(B7("throwDeprecation"))throw new Error(e);B7("traceDeprecation")?console.trace(e):console.warn(e),r=!0}return t.apply(this,arguments)}return n}function B7(t){try{if(!globalThis.localStorage)return!1}catch{return!1}var e=globalThis.localStorage[t];return e==null?!1:String(e).toLowerCase()==="true"}});var eA=V((Nyt,uY)=>{"use strict";f();uY.exports=bi;function sY(t){var e=this;this.next=null,this.entry=null,this.finish=function(){J8e(e,t)}}var Iw;bi.WritableState=Fx;var E8e={deprecate:M7()},aY=P7(),Q8=pn().Buffer,S8e=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function A8e(t){return Q8.from(t)}function T8e(t){return Q8.isBuffer(t)||t instanceof S8e}var C7=R7(),P8e=D7(),I8e=P8e.getHighWaterMark,hm=rg().codes,k8e=hm.ERR_INVALID_ARG_TYPE,R8e=hm.ERR_METHOD_NOT_IMPLEMENTED,D8e=hm.ERR_MULTIPLE_CALLBACK,B8e=hm.ERR_STREAM_CANNOT_PIPE,M8e=hm.ERR_STREAM_DESTROYED,O8e=hm.ERR_STREAM_NULL_VALUES,C8e=hm.ERR_STREAM_WRITE_AFTER_END,$8e=hm.ERR_UNKNOWN_ENCODING,kw=C7.errorOrDestroy;Ft()(bi,aY);function j8e(){}function Fx(t,e,r){Iw=Iw||pm(),t=t||{},typeof r!="boolean"&&(r=e instanceof Iw),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=I8e(this,t,"writableHighWaterMark",r),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var n=t.decodeStrings===!1;this.decodeStrings=!n,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(i){z8e(e,i)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=t.emitClose!==!1,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new sY(this)}Fx.prototype.getBuffer=function(){for(var e=this.bufferedRequest,r=[];e;)r.push(e),e=e.next;return r};(function(){try{Object.defineProperty(Fx.prototype,"buffer",{get:E8e.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var X8;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(X8=Function.prototype[Symbol.hasInstance],Object.defineProperty(bi,Symbol.hasInstance,{value:function(e){return X8.call(this,e)?!0:this!==bi?!1:e&&e._writableState instanceof Fx}})):X8=function(e){return e instanceof this};function bi(t){Iw=Iw||pm();var e=this instanceof Iw;if(!e&&!X8.call(bi,this))return new bi(t);this._writableState=new Fx(t,this,e),this.writable=!0,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)),aY.call(this)}bi.prototype.pipe=function(){kw(this,new B8e)};function N8e(t,e){var r=new C8e;kw(t,r),k.default.nextTick(e,r)}function U8e(t,e,r,n){var i;return r===null?i=new O8e:typeof r!="string"&&!e.objectMode&&(i=new k8e("chunk",["string","Buffer"],r)),i?(kw(t,i),k.default.nextTick(n,i),!1):!0}bi.prototype.write=function(t,e,r){var n=this._writableState,i=!1,o=!n.objectMode&&T8e(t);return o&&!Q8.isBuffer(t)&&(t=A8e(t)),typeof e=="function"&&(r=e,e=null),o?e="buffer":e||(e=n.defaultEncoding),typeof r!="function"&&(r=j8e),n.ending?N8e(this,r):(o||U8e(this,n,t,r))&&(n.pendingcb++,i=L8e(this,n,o,t,e,r)),i};bi.prototype.cork=function(){this._writableState.corked++};bi.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,!t.writing&&!t.corked&&!t.bufferProcessing&&t.bufferedRequest&&cY(this,t))};bi.prototype.setDefaultEncoding=function(e){if(typeof e=="string"&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new $8e(e);return this._writableState.defaultEncoding=e,this};Object.defineProperty(bi.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function q8e(t,e,r){return!t.objectMode&&t.decodeStrings!==!1&&typeof e=="string"&&(e=Q8.from(e,r)),e}Object.defineProperty(bi.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function L8e(t,e,r,n,i,o){if(!r){var s=q8e(e,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=e.objectMode?1:n.length;e.length+=a;var d=e.length{"use strict";f();var Z8e=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};fY.exports=Ol;var lY=nA(),j7=eA();Ft()(Ol,lY);for($7=Z8e(j7.prototype),tA=0;tA<$7.length;tA++)rA=$7[tA],Ol.prototype[rA]||(Ol.prototype[rA]=j7.prototype[rA]);var $7,rA,tA;function Ol(t){if(!(this instanceof Ol))return new Ol(t);lY.call(this,t),j7.call(this,t),this.allowHalfOpen=!0,t&&(t.readable===!1&&(this.readable=!1),t.writable===!1&&(this.writable=!1),t.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",Y8e)))}Object.defineProperty(Ol.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});Object.defineProperty(Ol.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});Object.defineProperty(Ol.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function Y8e(){this._writableState.ended||k.default.nextTick(X8e,this)}function X8e(t){t.end()}Object.defineProperty(Ol.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(e){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=e,this._writableState.destroyed=e)}})});var Rw=V(pY=>{"use strict";f();var U7=cr().Buffer,hY=U7.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 Q8e(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 eAe(t){var e=Q8e(t);if(typeof e!="string"&&(U7.isEncoding===hY||!hY(t)))throw new Error("Unknown encoding: "+t);return e||t}pY.StringDecoder=zx;function zx(t){this.encoding=eAe(t);var e;switch(this.encoding){case"utf16le":this.text=sAe,this.end=aAe,e=4;break;case"utf8":this.fillLast=nAe,e=4;break;case"base64":this.text=cAe,this.end=dAe,e=3;break;default:this.write=uAe,this.end=lAe;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=U7.allocUnsafe(e)}zx.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>5===6?2:t>>4===14?3:t>>3===30?4:t>>6===2?-1:-2}function tAe(t,e,r){var n=e.length-1;if(n=0?(i>0&&(t.lastNeed=i-1),i):--n=0?(i>0&&(t.lastNeed=i-2),i):--n=0?(i>0&&(i===2?i=0:t.lastNeed=i-3),i):0))}function rAe(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 nAe(t){var e=this.lastTotal-this.lastNeed,r=rAe(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 iAe(t,e){var r=tAe(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 oAe(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"\uFFFD":e}function sAe(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 aAe(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 cAe(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 dAe(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function uAe(t){return t.toString(this.encoding)}function lAe(t){return t&&t.length?this.write(t):""}});var Wx=V((zyt,gY)=>{"use strict";f();var mY=rg().codes.ERR_STREAM_PREMATURE_CLOSE;function fAe(t){var e=!1;return function(){if(!e){e=!0;for(var r=arguments.length,n=new Array(r),i=0;i{"use strict";f();var iA;function mm(t,e,r){return e=mAe(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function mAe(t){var e=yAe(t,"string");return typeof e=="symbol"?e:String(e)}function yAe(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var gAe=Wx(),ym=Symbol("lastResolve"),ng=Symbol("lastReject"),Hx=Symbol("error"),oA=Symbol("ended"),ig=Symbol("lastPromise"),q7=Symbol("handlePromise"),og=Symbol("stream");function gm(t,e){return{value:t,done:e}}function vAe(t){var e=t[ym];if(e!==null){var r=t[og].read();r!==null&&(t[ig]=null,t[ym]=null,t[ng]=null,e(gm(r,!1)))}}function bAe(t){k.default.nextTick(vAe,t)}function wAe(t,e){return function(r,n){t.then(function(){if(e[oA]){r(gm(void 0,!0));return}e[q7](r,n)},n)}}var _Ae=Object.getPrototypeOf(function(){}),xAe=Object.setPrototypeOf((iA={get stream(){return this[og]},next:function(){var e=this,r=this[Hx];if(r!==null)return Promise.reject(r);if(this[oA])return Promise.resolve(gm(void 0,!0));if(this[og].destroyed)return new Promise(function(s,a){k.default.nextTick(function(){e[Hx]?a(e[Hx]):s(gm(void 0,!0))})});var n=this[ig],i;if(n)i=new Promise(wAe(n,this));else{var o=this[og].read();if(o!==null)return Promise.resolve(gm(o,!1));i=new Promise(this[q7])}return this[ig]=i,i}},mm(iA,Symbol.asyncIterator,function(){return this}),mm(iA,"return",function(){var e=this;return new Promise(function(r,n){e[og].destroy(null,function(i){if(i){n(i);return}r(gm(void 0,!0))})})}),iA),_Ae),EAe=function(e){var r,n=Object.create(xAe,(r={},mm(r,og,{value:e,writable:!0}),mm(r,ym,{value:null,writable:!0}),mm(r,ng,{value:null,writable:!0}),mm(r,Hx,{value:null,writable:!0}),mm(r,oA,{value:e._readableState.endEmitted,writable:!0}),mm(r,q7,{value:function(o,s){var a=n[og].read();a?(n[ig]=null,n[ym]=null,n[ng]=null,o(gm(a,!1))):(n[ym]=o,n[ng]=s)},writable:!0}),r));return n[ig]=null,gAe(e,function(i){if(i&&i.code!=="ERR_STREAM_PREMATURE_CLOSE"){var o=n[ng];o!==null&&(n[ig]=null,n[ym]=null,n[ng]=null,o(i)),n[Hx]=i;return}var s=n[ym];s!==null&&(n[ig]=null,n[ym]=null,n[ng]=null,s(gm(void 0,!0))),n[oA]=!0}),e.on("readable",bAe.bind(null,n)),n};vY.exports=EAe});var _Y=V((Gyt,wY)=>{f();wY.exports=function(){throw new Error("Readable.from is not available in the browser")}});var nA=V((Yyt,DY)=>{"use strict";f();DY.exports=zr;var Dw;zr.ReadableState=AY;var Zyt=Aa().EventEmitter,SY=function(e,r){return e.listeners(r).length},Gx=P7(),sA=pn().Buffer,SAe=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function AAe(t){return sA.from(t)}function TAe(t){return sA.isBuffer(t)||t instanceof SAe}var L7=Lx(),Er;L7&&L7.debuglog?Er=L7.debuglog("stream"):Er=function(){};var PAe=YZ(),G7=R7(),IAe=D7(),kAe=IAe.getHighWaterMark,aA=rg().codes,RAe=aA.ERR_INVALID_ARG_TYPE,DAe=aA.ERR_STREAM_PUSH_AFTER_EOF,BAe=aA.ERR_METHOD_NOT_IMPLEMENTED,MAe=aA.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,Bw,K7,F7;Ft()(zr,Gx);var Vx=G7.errorOrDestroy,z7=["error","close","destroy","pause","resume"];function OAe(t,e,r){if(typeof t.prependListener=="function")return t.prependListener(e,r);!t._events||!t._events[e]?t.on(e,r):Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]}function AY(t,e,r){Dw=Dw||pm(),t=t||{},typeof r!="boolean"&&(r=e instanceof Dw),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=kAe(this,t,"readableHighWaterMark",r),this.buffer=new PAe,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=t.emitClose!==!1,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(Bw||(Bw=Rw().StringDecoder),this.decoder=new Bw(t.encoding),this.encoding=t.encoding)}function zr(t){if(Dw=Dw||pm(),!(this instanceof zr))return new zr(t);var e=this instanceof Dw;this._readableState=new AY(t,this,e),this.readable=!0,t&&(typeof t.read=="function"&&(this._read=t.read),typeof t.destroy=="function"&&(this._destroy=t.destroy)),Gx.call(this)}Object.defineProperty(zr.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}});zr.prototype.destroy=G7.destroy;zr.prototype._undestroy=G7.undestroy;zr.prototype._destroy=function(t,e){e(t)};zr.prototype.push=function(t,e){var r=this._readableState,n;return r.objectMode?n=!0:typeof t=="string"&&(e=e||r.defaultEncoding,e!==r.encoding&&(t=sA.from(t,e),e=""),n=!0),TY(this,t,e,!1,n)};zr.prototype.unshift=function(t){return TY(this,t,null,!0,!1)};function TY(t,e,r,n,i){Er("readableAddChunk",e);var o=t._readableState;if(e===null)o.reading=!1,jAe(t,o);else{var s;if(i||(s=CAe(o,e)),s)Vx(t,s);else if(o.objectMode||e&&e.length>0)if(typeof e!="string"&&!o.objectMode&&Object.getPrototypeOf(e)!==sA.prototype&&(e=AAe(e)),n)o.endEmitted?Vx(t,new MAe):W7(t,o,e,!0);else if(o.ended)Vx(t,new DAe);else{if(o.destroyed)return!1;o.reading=!1,o.decoder&&!r?(e=o.decoder.write(e),o.objectMode||e.length!==0?W7(t,o,e,!1):V7(t,o)):W7(t,o,e,!1)}else n||(o.reading=!1,V7(t,o))}return!o.ended&&(o.length=xY?t=xY:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}function EY(t,e){return t<=0||e.length===0&&e.ended?0:e.objectMode?1:t!==t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=$Ae(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}zr.prototype.read=function(t){Er("read",t),t=parseInt(t,10);var e=this._readableState,r=t;if(t!==0&&(e.emittedReadable=!1),t===0&&e.needReadable&&((e.highWaterMark!==0?e.length>=e.highWaterMark:e.length>0)||e.ended))return Er("read: emitReadable",e.length,e.ended),e.length===0&&e.ended?H7(this):cA(this),null;if(t=EY(t,e),t===0&&e.ended)return e.length===0&&H7(this),null;var n=e.needReadable;Er("need readable",n),(e.length===0||e.length-t0?i=kY(t,e):i=null,i===null?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),e.length===0&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&H7(this)),i!==null&&this.emit("data",i),i};function jAe(t,e){if(Er("onEofChunk"),!e.ended){if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.sync?cA(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,PY(t)))}}function cA(t){var e=t._readableState;Er("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(Er("emitReadable",e.flowing),e.emittedReadable=!0,k.default.nextTick(PY,t))}function PY(t){var e=t._readableState;Er("emitReadable_",e.destroyed,e.length,e.ended),!e.destroyed&&(e.length||e.ended)&&(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,J7(t)}function V7(t,e){e.readingMore||(e.readingMore=!0,k.default.nextTick(NAe,t,e))}function NAe(t,e){for(;!e.reading&&!e.ended&&(e.length1&&RY(n.pipes,t)!==-1)&&!u&&(Er("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause())}function p(x){Er("onerror",x),v(),t.removeListener("error",p),SY(t,"error")===0&&Vx(t,x)}OAe(t,"error",p);function m(){t.removeListener("finish",g),v()}t.once("close",m);function g(){Er("onfinish"),t.removeListener("close",m),v()}t.once("finish",g);function v(){Er("unpipe"),r.unpipe(t)}return t.emit("pipe",r),n.flowing||(Er("pipe resume"),r.resume()),t};function UAe(t){return function(){var r=t._readableState;Er("pipeOnDrain",r.awaitDrain),r.awaitDrain&&r.awaitDrain--,r.awaitDrain===0&&SY(t,"data")&&(r.flowing=!0,J7(t))}}zr.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(e.pipesCount===0)return this;if(e.pipesCount===1)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r),this);if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o0,n.flowing!==!1&&this.resume()):t==="readable"&&!n.endEmitted&&!n.readableListening&&(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,Er("on readable",n.length,n.reading),n.length?cA(this):n.reading||k.default.nextTick(qAe,this)),r};zr.prototype.addListener=zr.prototype.on;zr.prototype.removeListener=function(t,e){var r=Gx.prototype.removeListener.call(this,t,e);return t==="readable"&&k.default.nextTick(IY,this),r};zr.prototype.removeAllListeners=function(t){var e=Gx.prototype.removeAllListeners.apply(this,arguments);return(t==="readable"||t===void 0)&&k.default.nextTick(IY,this),e};function IY(t){var e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function qAe(t){Er("readable nexttick read 0"),t.read(0)}zr.prototype.resume=function(){var t=this._readableState;return t.flowing||(Er("resume"),t.flowing=!t.readableListening,LAe(this,t)),t.paused=!1,this};function LAe(t,e){e.resumeScheduled||(e.resumeScheduled=!0,k.default.nextTick(KAe,t,e))}function KAe(t,e){Er("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),J7(t),e.flowing&&!e.reading&&t.read(0)}zr.prototype.pause=function(){return Er("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(Er("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function J7(t){var e=t._readableState;for(Er("flow",e.flowing);e.flowing&&t.read()!==null;);}zr.prototype.wrap=function(t){var e=this,r=this._readableState,n=!1;t.on("end",function(){if(Er("wrapped end"),r.decoder&&!r.ended){var s=r.decoder.end();s&&s.length&&e.push(s)}e.push(null)}),t.on("data",function(s){if(Er("wrapped data"),r.decoder&&(s=r.decoder.write(s)),!(r.objectMode&&s==null)&&!(!r.objectMode&&(!s||!s.length))){var a=e.push(s);a||(n=!0,t.pause())}});for(var i in t)this[i]===void 0&&typeof t[i]=="function"&&(this[i]=function(a){return function(){return t[a].apply(t,arguments)}}(i));for(var o=0;o=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 H7(t){var e=t._readableState;Er("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,k.default.nextTick(FAe,e,t))}function FAe(t,e){if(Er("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&t.length===0&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}typeof Symbol=="function"&&(zr.from=function(t,e){return F7===void 0&&(F7=_Y()),F7(zr,t,e)});function RY(t,e){for(var r=0,n=t.length;r{"use strict";f();MY.exports=uh;var dA=rg().codes,zAe=dA.ERR_METHOD_NOT_IMPLEMENTED,WAe=dA.ERR_MULTIPLE_CALLBACK,HAe=dA.ERR_TRANSFORM_ALREADY_TRANSFORMING,VAe=dA.ERR_TRANSFORM_WITH_LENGTH_0,uA=pm();Ft()(uh,uA);function GAe(t,e){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(n===null)return this.emit("error",new WAe);r.writechunk=null,r.writecb=null,e!=null&&this.push(e),n(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length{"use strict";f();CY.exports=Jx;var OY=lA();Ft()(Jx,OY);function Jx(t){if(!(this instanceof Jx))return new Jx(t);OY.call(this,t)}Jx.prototype._transform=function(t,e,r){r(null,t)}});var X7=V((n0t,UY)=>{"use strict";f();var Y7;function ZAe(t){var e=!1;return function(){e||(e=!0,t.apply(void 0,arguments))}}var NY=rg().codes,YAe=NY.ERR_MISSING_ARGS,XAe=NY.ERR_STREAM_DESTROYED;function $Y(t){if(t)throw t}function QAe(t){return t.setHeader&&typeof t.abort=="function"}function e4e(t,e,r,n){n=ZAe(n);var i=!1;t.on("close",function(){i=!0}),Y7===void 0&&(Y7=Wx()),Y7(t,{readable:e,writable:r},function(s){if(s)return n(s);i=!0,n()});var o=!1;return function(s){if(!i&&!o){if(o=!0,QAe(t))return t.abort();if(typeof t.destroy=="function")return t.destroy();n(s||new XAe("pipe"))}}}function jY(t){t()}function t4e(t,e){return t.pipe(e)}function r4e(t){return!t.length||typeof t[t.length-1]!="function"?$Y:t.pop()}function n4e(){for(var t=arguments.length,e=new Array(t),r=0;r0;return e4e(s,d,u,function(c){i||(i=c),c&&o.forEach(jY),!d&&(o.forEach(jY),n(i))})});return e.reduce(t4e)}UY.exports=n4e});var Q7=V((Sd,qY)=>{f();Sd=qY.exports=nA();Sd.Stream=Sd;Sd.Readable=Sd;Sd.Writable=eA();Sd.Duplex=pm();Sd.Transform=lA();Sd.PassThrough=Z7();Sd.finished=Wx();Sd.pipeline=X7()});var eM=V((s0t,KY)=>{"use strict";f();var fA=cr().Buffer,LY=Q7().Transform,i4e=Ft();function o4e(t,e){if(!fA.isBuffer(t)&&typeof t!="string")throw new TypeError(e+" must be a string or a buffer")}function vm(t){LY.call(this),this._block=fA.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}i4e(vm,LY);vm.prototype._transform=function(t,e,r){var n=null;try{this.update(t,e)}catch(i){n=i}r(n)};vm.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(r){e=r}t(e)};vm.prototype.update=function(t,e){if(o4e(t,"Data"),this._finalized)throw new Error("Digest already called");fA.isBuffer(t)||(t=fA.from(t,e));for(var r=this._block,n=0;this._blockOffset+t.length-n>=this._blockSize;){for(var i=this._blockOffset;i0;++o)this._length[o]+=s,s=this._length[o]/4294967296|0,s>0&&(this._length[o]-=4294967296*s);return this};vm.prototype._update=function(){throw new Error("_update is not implemented")};vm.prototype.digest=function(t){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var e=this._digest();t!==void 0&&(e=e.toString(t)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return e};vm.prototype._digest=function(){throw new Error("_digest is not implemented")};KY.exports=vm});var mA=V((c0t,zY)=>{"use strict";f();var s4e=Ft(),FY=eM(),a4e=cr().Buffer,c4e=new Array(16);function hA(){FY.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}s4e(hA,FY);hA.prototype._update=function(){for(var t=c4e,e=0;e<16;++e)t[e]=this._block.readInt32LE(e*4);var r=this._a,n=this._b,i=this._c,o=this._d;r=Hs(r,n,i,o,t[0],3614090360,7),o=Hs(o,r,n,i,t[1],3905402710,12),i=Hs(i,o,r,n,t[2],606105819,17),n=Hs(n,i,o,r,t[3],3250441966,22),r=Hs(r,n,i,o,t[4],4118548399,7),o=Hs(o,r,n,i,t[5],1200080426,12),i=Hs(i,o,r,n,t[6],2821735955,17),n=Hs(n,i,o,r,t[7],4249261313,22),r=Hs(r,n,i,o,t[8],1770035416,7),o=Hs(o,r,n,i,t[9],2336552879,12),i=Hs(i,o,r,n,t[10],4294925233,17),n=Hs(n,i,o,r,t[11],2304563134,22),r=Hs(r,n,i,o,t[12],1804603682,7),o=Hs(o,r,n,i,t[13],4254626195,12),i=Hs(i,o,r,n,t[14],2792965006,17),n=Hs(n,i,o,r,t[15],1236535329,22),r=Vs(r,n,i,o,t[1],4129170786,5),o=Vs(o,r,n,i,t[6],3225465664,9),i=Vs(i,o,r,n,t[11],643717713,14),n=Vs(n,i,o,r,t[0],3921069994,20),r=Vs(r,n,i,o,t[5],3593408605,5),o=Vs(o,r,n,i,t[10],38016083,9),i=Vs(i,o,r,n,t[15],3634488961,14),n=Vs(n,i,o,r,t[4],3889429448,20),r=Vs(r,n,i,o,t[9],568446438,5),o=Vs(o,r,n,i,t[14],3275163606,9),i=Vs(i,o,r,n,t[3],4107603335,14),n=Vs(n,i,o,r,t[8],1163531501,20),r=Vs(r,n,i,o,t[13],2850285829,5),o=Vs(o,r,n,i,t[2],4243563512,9),i=Vs(i,o,r,n,t[7],1735328473,14),n=Vs(n,i,o,r,t[12],2368359562,20),r=Gs(r,n,i,o,t[5],4294588738,4),o=Gs(o,r,n,i,t[8],2272392833,11),i=Gs(i,o,r,n,t[11],1839030562,16),n=Gs(n,i,o,r,t[14],4259657740,23),r=Gs(r,n,i,o,t[1],2763975236,4),o=Gs(o,r,n,i,t[4],1272893353,11),i=Gs(i,o,r,n,t[7],4139469664,16),n=Gs(n,i,o,r,t[10],3200236656,23),r=Gs(r,n,i,o,t[13],681279174,4),o=Gs(o,r,n,i,t[0],3936430074,11),i=Gs(i,o,r,n,t[3],3572445317,16),n=Gs(n,i,o,r,t[6],76029189,23),r=Gs(r,n,i,o,t[9],3654602809,4),o=Gs(o,r,n,i,t[12],3873151461,11),i=Gs(i,o,r,n,t[15],530742520,16),n=Gs(n,i,o,r,t[2],3299628645,23),r=Js(r,n,i,o,t[0],4096336452,6),o=Js(o,r,n,i,t[7],1126891415,10),i=Js(i,o,r,n,t[14],2878612391,15),n=Js(n,i,o,r,t[5],4237533241,21),r=Js(r,n,i,o,t[12],1700485571,6),o=Js(o,r,n,i,t[3],2399980690,10),i=Js(i,o,r,n,t[10],4293915773,15),n=Js(n,i,o,r,t[1],2240044497,21),r=Js(r,n,i,o,t[8],1873313359,6),o=Js(o,r,n,i,t[15],4264355552,10),i=Js(i,o,r,n,t[6],2734768916,15),n=Js(n,i,o,r,t[13],1309151649,21),r=Js(r,n,i,o,t[4],4149444226,6),o=Js(o,r,n,i,t[11],3174756917,10),i=Js(i,o,r,n,t[2],718787259,15),n=Js(n,i,o,r,t[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+o|0};hA.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=a4e.allocUnsafe(16);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t};function pA(t,e){return t<>>32-e}function Hs(t,e,r,n,i,o,s){return pA(t+(e&r|~e&n)+i+o|0,s)+e|0}function Vs(t,e,r,n,i,o,s){return pA(t+(e&n|r&~n)+i+o|0,s)+e|0}function Gs(t,e,r,n,i,o,s){return pA(t+(e^r^n)+i+o|0,s)+e|0}function Js(t,e,r,n,i,o,s){return pA(t+(r^(e|~n))+i+o|0,s)+e|0}zY.exports=hA});var gA=V((u0t,YY)=>{"use strict";f();var tM=pn().Buffer,d4e=Ft(),ZY=eM(),u4e=new Array(16),Zx=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],Yx=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],Xx=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],Qx=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],eE=[0,1518500249,1859775393,2400959708,2840853838],tE=[1352829926,1548603684,1836072691,2053994217,0];function yA(){ZY.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}d4e(yA,ZY);yA.prototype._update=function(){for(var t=u4e,e=0;e<16;++e)t[e]=this._block.readInt32LE(e*4);for(var r=this._a|0,n=this._b|0,i=this._c|0,o=this._d|0,s=this._e|0,a=this._a|0,d=this._b|0,u=this._c|0,c=this._d|0,l=this._e|0,p=0;p<80;p+=1){var m,g;p<16?(m=WY(r,n,i,o,s,t[Zx[p]],eE[0],Xx[p]),g=JY(a,d,u,c,l,t[Yx[p]],tE[0],Qx[p])):p<32?(m=HY(r,n,i,o,s,t[Zx[p]],eE[1],Xx[p]),g=GY(a,d,u,c,l,t[Yx[p]],tE[1],Qx[p])):p<48?(m=VY(r,n,i,o,s,t[Zx[p]],eE[2],Xx[p]),g=VY(a,d,u,c,l,t[Yx[p]],tE[2],Qx[p])):p<64?(m=GY(r,n,i,o,s,t[Zx[p]],eE[3],Xx[p]),g=HY(a,d,u,c,l,t[Yx[p]],tE[3],Qx[p])):(m=JY(r,n,i,o,s,t[Zx[p]],eE[4],Xx[p]),g=WY(a,d,u,c,l,t[Yx[p]],tE[4],Qx[p])),r=s,s=o,o=sg(i,10),i=n,n=m,a=l,l=c,c=sg(u,10),u=d,d=g}var v=this._b+i+c|0;this._b=this._c+o+l|0,this._c=this._d+s+a|0,this._d=this._e+r+d|0,this._e=this._a+n+u|0,this._a=v};yA.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=tM.alloc?tM.alloc(20):new tM(20);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t.writeInt32LE(this._e,16),t};function sg(t,e){return t<>>32-e}function WY(t,e,r,n,i,o,s,a){return sg(t+(e^r^n)+o+s|0,a)+i|0}function HY(t,e,r,n,i,o,s,a){return sg(t+(e&r|~e&n)+o+s|0,a)+i|0}function VY(t,e,r,n,i,o,s,a){return sg(t+((e|~r)^n)+o+s|0,a)+i|0}function GY(t,e,r,n,i,o,s,a){return sg(t+(e&n|r&~n)+o+s|0,a)+i|0}function JY(t,e,r,n,i,o,s,a){return sg(t+(e^(r|~n))+o+s|0,a)+i|0}YY.exports=yA});var ag=V((f0t,QY)=>{f();var XY=cr().Buffer;function vA(t,e){this._block=XY.alloc(t),this._finalSize=e,this._blockSize=t,this._len=0}vA.prototype.update=function(t,e){typeof t=="string"&&(e=e||"utf8",t=XY.from(t,e));for(var r=this._block,n=this._blockSize,i=t.length,o=this._len,s=0;s=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=this._len*8;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(r&4294967295)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return t?o.toString(t):o};vA.prototype._update=function(){throw new Error("_update must be implemented by subclass")};QY.exports=vA});var rX=V((p0t,tX)=>{f();var l4e=Ft(),eX=ag(),f4e=cr().Buffer,h4e=[1518500249,1859775393,-1894007588,-899497514],p4e=new Array(80);function rE(){this.init(),this._w=p4e,eX.call(this,64,56)}l4e(rE,eX);rE.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function m4e(t){return t<<5|t>>>27}function y4e(t){return t<<30|t>>>2}function g4e(t,e,r,n){return t===0?e&r|~e&n:t===2?e&r|e&n|r&n:e^r^n}rE.prototype._update=function(t){for(var e=this._w,r=this._a|0,n=this._b|0,i=this._c|0,o=this._d|0,s=this._e|0,a=0;a<16;++a)e[a]=t.readInt32BE(a*4);for(;a<80;++a)e[a]=e[a-3]^e[a-8]^e[a-14]^e[a-16];for(var d=0;d<80;++d){var u=~~(d/20),c=m4e(r)+g4e(u,n,i,o)+s+e[d]+h4e[u]|0;s=o,o=i,i=y4e(n),n=r,r=c}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=o+this._d|0,this._e=s+this._e|0};rE.prototype._hash=function(){var t=f4e.allocUnsafe(20);return t.writeInt32BE(this._a|0,0),t.writeInt32BE(this._b|0,4),t.writeInt32BE(this._c|0,8),t.writeInt32BE(this._d|0,12),t.writeInt32BE(this._e|0,16),t};tX.exports=rE});var oX=V((y0t,iX)=>{f();var v4e=Ft(),nX=ag(),b4e=cr().Buffer,w4e=[1518500249,1859775393,-1894007588,-899497514],_4e=new Array(80);function nE(){this.init(),this._w=_4e,nX.call(this,64,56)}v4e(nE,nX);nE.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function x4e(t){return t<<1|t>>>31}function E4e(t){return t<<5|t>>>27}function S4e(t){return t<<30|t>>>2}function A4e(t,e,r,n){return t===0?e&r|~e&n:t===2?e&r|e&n|r&n:e^r^n}nE.prototype._update=function(t){for(var e=this._w,r=this._a|0,n=this._b|0,i=this._c|0,o=this._d|0,s=this._e|0,a=0;a<16;++a)e[a]=t.readInt32BE(a*4);for(;a<80;++a)e[a]=x4e(e[a-3]^e[a-8]^e[a-14]^e[a-16]);for(var d=0;d<80;++d){var u=~~(d/20),c=E4e(r)+A4e(u,n,i,o)+s+e[d]+w4e[u]|0;s=o,o=i,i=S4e(n),n=r,r=c}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=o+this._d|0,this._e=s+this._e|0};nE.prototype._hash=function(){var t=b4e.allocUnsafe(20);return t.writeInt32BE(this._a|0,0),t.writeInt32BE(this._b|0,4),t.writeInt32BE(this._c|0,8),t.writeInt32BE(this._d|0,12),t.writeInt32BE(this._e|0,16),t};iX.exports=nE});var rM=V((v0t,aX)=>{f();var T4e=Ft(),sX=ag(),P4e=cr().Buffer,I4e=[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],k4e=new Array(64);function iE(){this.init(),this._w=k4e,sX.call(this,64,56)}T4e(iE,sX);iE.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this};function R4e(t,e,r){return r^t&(e^r)}function D4e(t,e,r){return t&e|r&(t|e)}function B4e(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function M4e(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function O4e(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}function C4e(t){return(t>>>17|t<<15)^(t>>>19|t<<13)^t>>>10}iE.prototype._update=function(t){for(var e=this._w,r=this._a|0,n=this._b|0,i=this._c|0,o=this._d|0,s=this._e|0,a=this._f|0,d=this._g|0,u=this._h|0,c=0;c<16;++c)e[c]=t.readInt32BE(c*4);for(;c<64;++c)e[c]=C4e(e[c-2])+e[c-7]+O4e(e[c-15])+e[c-16]|0;for(var l=0;l<64;++l){var p=u+M4e(s)+R4e(s,a,d)+I4e[l]+e[l]|0,m=B4e(r)+D4e(r,n,i)|0;u=d,d=a,a=s,s=o+p|0,o=i,i=n,n=r,r=p+m|0}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=o+this._d|0,this._e=s+this._e|0,this._f=a+this._f|0,this._g=d+this._g|0,this._h=u+this._h|0};iE.prototype._hash=function(){var t=P4e.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t};aX.exports=iE});var dX=V((w0t,cX)=>{f();var $4e=Ft(),j4e=rM(),N4e=ag(),U4e=cr().Buffer,q4e=new Array(64);function bA(){this.init(),this._w=q4e,N4e.call(this,64,56)}$4e(bA,j4e);bA.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this};bA.prototype._hash=function(){var t=U4e.allocUnsafe(28);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t};cX.exports=bA});var nM=V((x0t,yX)=>{f();var L4e=Ft(),mX=ag(),K4e=cr().Buffer,uX=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],F4e=new Array(160);function oE(){this.init(),this._w=F4e,mX.call(this,128,112)}L4e(oE,mX);oE.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this};function lX(t,e,r){return r^t&(e^r)}function fX(t,e,r){return t&e|r&(t|e)}function hX(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function pX(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function z4e(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function W4e(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function H4e(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function V4e(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function Bo(t,e){return t>>>0>>0?1:0}oE.prototype._update=function(t){for(var e=this._w,r=this._ah|0,n=this._bh|0,i=this._ch|0,o=this._dh|0,s=this._eh|0,a=this._fh|0,d=this._gh|0,u=this._hh|0,c=this._al|0,l=this._bl|0,p=this._cl|0,m=this._dl|0,g=this._el|0,v=this._fl|0,x=this._gl|0,S=this._hl|0,P=0;P<32;P+=2)e[P]=t.readInt32BE(P*4),e[P+1]=t.readInt32BE(P*4+4);for(;P<160;P+=2){var A=e[P-30],$=e[P-15*2+1],j=z4e(A,$),q=W4e($,A);A=e[P-2*2],$=e[P-2*2+1];var F=H4e(A,$),K=V4e($,A),W=e[P-7*2],L=e[P-7*2+1],I=e[P-16*2],T=e[P-16*2+1],B=q+L|0,h=j+W+Bo(B,q)|0;B=B+K|0,h=h+F+Bo(B,K)|0,B=B+T|0,h=h+I+Bo(B,T)|0,e[P]=h,e[P+1]=B}for(var y=0;y<160;y+=2){h=e[y],B=e[y+1];var w=fX(r,n,i),E=fX(c,l,p),_=hX(r,c),b=hX(c,r),C=pX(s,g),N=pX(g,s),M=uX[y],U=uX[y+1],G=lX(s,a,d),Z=lX(g,v,x),J=S+N|0,H=u+C+Bo(J,S)|0;J=J+Z|0,H=H+G+Bo(J,Z)|0,J=J+U|0,H=H+M+Bo(J,U)|0,J=J+B|0,H=H+h+Bo(J,B)|0;var X=b+E|0,te=_+w+Bo(X,b)|0;u=d,S=x,d=a,x=v,a=s,v=g,g=m+J|0,s=o+H+Bo(g,m)|0,o=i,m=p,i=n,p=l,n=r,l=c,c=J+X|0,r=H+te+Bo(c,J)|0}this._al=this._al+c|0,this._bl=this._bl+l|0,this._cl=this._cl+p|0,this._dl=this._dl+m|0,this._el=this._el+g|0,this._fl=this._fl+v|0,this._gl=this._gl+x|0,this._hl=this._hl+S|0,this._ah=this._ah+r+Bo(this._al,c)|0,this._bh=this._bh+n+Bo(this._bl,l)|0,this._ch=this._ch+i+Bo(this._cl,p)|0,this._dh=this._dh+o+Bo(this._dl,m)|0,this._eh=this._eh+s+Bo(this._el,g)|0,this._fh=this._fh+a+Bo(this._fl,v)|0,this._gh=this._gh+d+Bo(this._gl,x)|0,this._hh=this._hh+u+Bo(this._hl,S)|0};oE.prototype._hash=function(){var t=K4e.allocUnsafe(64);function e(r,n,i){t.writeInt32BE(r,i),t.writeInt32BE(n,i+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),t};yX.exports=oE});var vX=V((S0t,gX)=>{f();var G4e=Ft(),J4e=nM(),Z4e=ag(),Y4e=cr().Buffer,X4e=new Array(160);function wA(){this.init(),this._w=X4e,Z4e.call(this,128,112)}G4e(wA,J4e);wA.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this};wA.prototype._hash=function(){var t=Y4e.allocUnsafe(48);function e(r,n,i){t.writeInt32BE(r,i),t.writeInt32BE(n,i+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),t};gX.exports=wA});var _A=V((lh,bX)=>{f();var lh=bX.exports=function(e){e=e.toLowerCase();var r=lh[e];if(!r)throw new Error(e+" is not supported (we accept pull requests)");return new r};lh.sha=rX();lh.sha1=oX();lh.sha224=dX();lh.sha256=rM();lh.sha384=vX();lh.sha512=nM()});var _X=V((P0t,wX)=>{f();wX.exports=Ad;var iM=Aa().EventEmitter,Q4e=Ft();Q4e(Ad,iM);Ad.Readable=nA();Ad.Writable=eA();Ad.Duplex=pm();Ad.Transform=lA();Ad.PassThrough=Z7();Ad.finished=Wx();Ad.pipeline=X7();Ad.Stream=Ad;function Ad(){iM.call(this)}Ad.prototype.pipe=function(t,e){var r=this;function n(c){t.writable&&t.write(c)===!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));var o=!1;function s(){o||(o=!0,t.end())}function a(){o||(o=!0,typeof t.destroy=="function"&&t.destroy())}function d(c){if(u(),iM.listenerCount(this,"error")===0)throw c}r.on("error",d),t.on("error",d);function u(){r.removeListener("data",n),t.removeListener("drain",i),r.removeListener("end",s),r.removeListener("close",a),r.removeListener("error",d),t.removeListener("error",d),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}});var fh=V((k0t,SX)=>{f();var xX=cr().Buffer,EX=_X().Transform,eTe=Rw().StringDecoder,tTe=Ft();function Su(t){EX.call(this),this.hashMode=typeof t=="string",this.hashMode?this[t]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}tTe(Su,EX);Su.prototype.update=function(t,e,r){typeof t=="string"&&(t=xX.from(t,e));var n=this._update(t);return this.hashMode?this:(r&&(n=this._toString(n,r)),n)};Su.prototype.setAutoPadding=function(){};Su.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")};Su.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")};Su.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")};Su.prototype._transform=function(t,e,r){var n;try{this.hashMode?this._update(t):this.push(this._update(t))}catch(i){n=i}finally{r(n)}};Su.prototype._flush=function(t){var e;try{this.push(this.__final())}catch(r){e=r}t(e)};Su.prototype._finalOrDigest=function(t){var e=this.__final()||xX.alloc(0);return t&&(e=this._toString(e,t,!0)),e};Su.prototype._toString=function(t,e,r){if(this._decoder||(this._decoder=new eTe(e),this._encoding=e),this._encoding!==e)throw new Error("can't switch encodings");var n=this._decoder.write(t);return r&&(n+=this._decoder.end()),n};SX.exports=Su});var Mw=V((D0t,TX)=>{"use strict";f();var rTe=Ft(),nTe=mA(),iTe=gA(),oTe=_A(),AX=fh();function xA(t){AX.call(this,"digest"),this._hash=t}rTe(xA,AX);xA.prototype._update=function(t){this._hash.update(t)};xA.prototype._final=function(){return this._hash.digest()};TX.exports=function(e){return e=e.toLowerCase(),e==="md5"?new nTe:e==="rmd160"||e==="ripemd160"?new iTe:new xA(oTe(e))}});var kX=V((M0t,IX)=>{"use strict";f();var sTe=Ft(),cg=cr().Buffer,PX=fh(),aTe=cg.alloc(128),Ow=64;function EA(t,e){PX.call(this,"digest"),typeof e=="string"&&(e=cg.from(e)),this._alg=t,this._key=e,e.length>Ow?e=t(e):e.length{f();var cTe=mA();RX.exports=function(t){return new cTe().update(t).digest()}});var cM=V((j0t,BX)=>{"use strict";f();var dTe=Ft(),uTe=kX(),DX=fh(),sE=cr().Buffer,lTe=oM(),sM=gA(),aM=_A(),fTe=sE.alloc(128);function aE(t,e){DX.call(this,"digest"),typeof e=="string"&&(e=sE.from(e));var r=t==="sha512"||t==="sha384"?128:64;if(this._alg=t,this._key=e,e.length>r){var n=t==="rmd160"?new sM:aM(t);e=n.update(e).digest()}else e.length{hTe.exports={sha224WithRSAEncryption:{sign:"rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},"RSA-SHA224":{sign:"ecdsa/rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},sha256WithRSAEncryption:{sign:"rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},"RSA-SHA256":{sign:"ecdsa/rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},sha384WithRSAEncryption:{sign:"rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},"RSA-SHA384":{sign:"ecdsa/rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},sha512WithRSAEncryption:{sign:"rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA512":{sign:"ecdsa/rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA1":{sign:"rsa",hash:"sha1",id:"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{sign:"ecdsa",hash:"sha1",id:""},sha256:{sign:"ecdsa",hash:"sha256",id:""},sha224:{sign:"ecdsa",hash:"sha224",id:""},sha384:{sign:"ecdsa",hash:"sha384",id:""},sha512:{sign:"ecdsa",hash:"sha512",id:""},"DSA-SHA":{sign:"dsa",hash:"sha1",id:""},"DSA-SHA1":{sign:"dsa",hash:"sha1",id:""},DSA:{sign:"dsa",hash:"sha1",id:""},"DSA-WITH-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-WITH-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-WITH-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-WITH-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-RIPEMD160":{sign:"dsa",hash:"rmd160",id:""},ripemd160WithRSA:{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},"RSA-RIPEMD160":{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},md5WithRSAEncryption:{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"},"RSA-MD5":{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"}}});var OX=V((q0t,MX)=>{"use strict";f();MX.exports=dM()});var uM=V((K0t,CX)=>{f();var pTe=Math.pow(2,30)-1;CX.exports=function(t,e){if(typeof t!="number")throw new TypeError("Iterations not a number");if(t<0)throw new TypeError("Bad iterations");if(typeof e!="number")throw new TypeError("Key length not a number");if(e<0||e>pTe||e!==e)throw new TypeError("Bad key length")}});var lM=V((z0t,jX)=>{f();var SA;globalThis.process&&globalThis.process.browser?SA="utf-8":globalThis.process&&globalThis.process.version?($X=parseInt(k.default.version.split(".")[0].slice(1),10),SA=$X>=6?"utf-8":"binary"):SA="utf-8";var $X;jX.exports=SA});var hM=V((H0t,NX)=>{f();var fM=cr().Buffer;NX.exports=function(t,e,r){if(fM.isBuffer(t))return t;if(typeof t=="string")return fM.from(t,e);if(ArrayBuffer.isView(t))return fM.from(t.buffer);throw new TypeError(r+" must be a string, a Buffer, a typed array or a DataView")}});var pM=V((G0t,KX)=>{f();var mTe=oM(),yTe=gA(),gTe=_A(),dg=cr().Buffer,vTe=uM(),UX=lM(),qX=hM(),bTe=dg.alloc(128),AA={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function LX(t,e,r){var n=wTe(t),i=t==="sha512"||t==="sha384"?128:64;e.length>i?e=n(e):e.length{f();var HX=cr().Buffer,xTe=uM(),FX=lM(),zX=pM(),WX=hM(),TA,cE=globalThis.crypto&&globalThis.crypto.subtle,ETe={sha:"SHA-1","sha-1":"SHA-1",sha1:"SHA-1",sha256:"SHA-256","sha-256":"SHA-256",sha384:"SHA-384","sha-384":"SHA-384","sha-512":"SHA-512",sha512:"SHA-512"},mM=[];function STe(t){if(globalThis.process&&!globalThis.process.browser||!cE||!cE.importKey||!cE.deriveBits)return Promise.resolve(!1);if(mM[t]!==void 0)return mM[t];TA=TA||HX.alloc(8);var e=VX(TA,TA,10,128,t).then(function(){return!0}).catch(function(){return!1});return mM[t]=e,e}var ug;function yM(){return ug||(globalThis.process&&globalThis.process.nextTick?ug=globalThis.process.nextTick:globalThis.queueMicrotask?ug=globalThis.queueMicrotask:globalThis.setImmediate?ug=globalThis.setImmediate:ug=globalThis.setTimeout,ug)}function VX(t,e,r,n,i){return cE.importKey("raw",t,{name:"PBKDF2"},!1,["deriveBits"]).then(function(o){return cE.deriveBits({name:"PBKDF2",salt:e,iterations:r,hash:{name:i}},o,n<<3)}).then(function(o){return HX.from(o)})}function ATe(t,e){t.then(function(r){yM()(function(){e(null,r)})},function(r){yM()(function(){e(r)})})}GX.exports=function(t,e,r,n,i,o){typeof i=="function"&&(o=i,i=void 0),i=i||"sha1";var s=ETe[i.toLowerCase()];if(!s||typeof globalThis.Promise!="function"){yM()(function(){var a;try{a=zX(t,e,r,n,i)}catch(d){return o(d)}o(null,a)});return}if(xTe(r,n),t=WX(t,FX,"Password"),e=WX(e,FX,"Salt"),typeof o!="function")throw new Error("No callback provided to pbkdf2");ATe(STe(s).then(function(a){return a?VX(t,e,r,n,s):zX(t,e,r,n,i)}),o)}});var vM=V(gM=>{f();gM.pbkdf2=JX();gM.pbkdf2Sync=pM()});var bM=V(Td=>{"use strict";f();Td.readUInt32BE=function(e,r){var n=e[0+r]<<24|e[1+r]<<16|e[2+r]<<8|e[3+r];return n>>>0};Td.writeUInt32BE=function(e,r,n){e[0+n]=r>>>24,e[1+n]=r>>>16&255,e[2+n]=r>>>8&255,e[3+n]=r&255};Td.ip=function(e,r,n,i){for(var o=0,s=0,a=6;a>=0;a-=2){for(var d=0;d<=24;d+=8)o<<=1,o|=r>>>d+a&1;for(var d=0;d<=24;d+=8)o<<=1,o|=e>>>d+a&1}for(var a=6;a>=0;a-=2){for(var d=1;d<=25;d+=8)s<<=1,s|=r>>>d+a&1;for(var d=1;d<=25;d+=8)s<<=1,s|=e>>>d+a&1}n[i+0]=o>>>0,n[i+1]=s>>>0};Td.rip=function(e,r,n,i){for(var o=0,s=0,a=0;a<4;a++)for(var d=24;d>=0;d-=8)o<<=1,o|=r>>>d+a&1,o<<=1,o|=e>>>d+a&1;for(var a=4;a<8;a++)for(var d=24;d>=0;d-=8)s<<=1,s|=r>>>d+a&1,s<<=1,s|=e>>>d+a&1;n[i+0]=o>>>0,n[i+1]=s>>>0};Td.pc1=function(e,r,n,i){for(var o=0,s=0,a=7;a>=5;a--){for(var d=0;d<=24;d+=8)o<<=1,o|=r>>d+a&1;for(var d=0;d<=24;d+=8)o<<=1,o|=e>>d+a&1}for(var d=0;d<=24;d+=8)o<<=1,o|=r>>d+a&1;for(var a=1;a<=3;a++){for(var d=0;d<=24;d+=8)s<<=1,s|=r>>d+a&1;for(var d=0;d<=24;d+=8)s<<=1,s|=e>>d+a&1}for(var d=0;d<=24;d+=8)s<<=1,s|=e>>d+a&1;n[i+0]=o>>>0,n[i+1]=s>>>0};Td.r28shl=function(e,r){return e<>>28-r};var PA=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];Td.pc2=function(e,r,n,i){for(var o=0,s=0,a=PA.length>>>1,d=0;d>>PA[d]&1;for(var d=a;d>>PA[d]&1;n[i+0]=o>>>0,n[i+1]=s>>>0};Td.expand=function(e,r,n){var i=0,o=0;i=(e&1)<<5|e>>>27;for(var s=23;s>=15;s-=4)i<<=6,i|=e>>>s&63;for(var s=11;s>=3;s-=4)o|=e>>>s&63,o<<=6;o|=(e&31)<<1|e>>>31,r[n+0]=i>>>0,r[n+1]=o>>>0};var ZX=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];Td.substitute=function(e,r){for(var n=0,i=0;i<4;i++){var o=e>>>18-i*6&63,s=ZX[i*64+o];n<<=4,n|=s}for(var i=0;i<4;i++){var o=r>>>18-i*6&63,s=ZX[4*64+i*64+o];n<<=4,n|=s}return n>>>0};var YX=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];Td.permute=function(e){for(var r=0,n=0;n>>YX[n]&1;return r>>>0};Td.padSplit=function(e,r,n){for(var i=e.toString(2);i.length{f();QX.exports=XX;function XX(t,e){if(!t)throw new Error(e||"Assertion failed")}XX.equal=function(e,r,n){if(e!=r)throw new Error(n||"Assertion failed: "+e+" != "+r)}});var IA=V((igt,eQ)=>{"use strict";f();var TTe=Nc();function Pd(t){this.options=t,this.type=this.options.type,this.blockSize=8,this._init(),this.buffer=new Array(this.blockSize),this.bufferOff=0,this.padding=t.padding!==!1}eQ.exports=Pd;Pd.prototype._init=function(){};Pd.prototype.update=function(e){return e.length===0?[]:this.type==="decrypt"?this._updateDecrypt(e):this._updateEncrypt(e)};Pd.prototype._buffer=function(e,r){for(var n=Math.min(this.buffer.length-this.bufferOff,e.length-r),i=0;i0;i--)r+=this._buffer(e,r),n+=this._flushBuffer(o,n);return r+=this._buffer(e,r),o};Pd.prototype.final=function(e){var r;e&&(r=this.update(e));var n;return this.type==="encrypt"?n=this._finalEncrypt():n=this._finalDecrypt(),r?r.concat(n):n};Pd.prototype._pad=function(e,r){if(r===0)return!1;for(;r{"use strict";f();var tQ=Nc(),PTe=Ft(),ro=bM(),rQ=IA();function ITe(){this.tmp=new Array(2),this.keys=null}function Cl(t){rQ.call(this,t);var e=new ITe;this._desState=e,this.deriveKeys(e,t.key)}PTe(Cl,rQ);nQ.exports=Cl;Cl.create=function(e){return new Cl(e)};var kTe=[1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1];Cl.prototype.deriveKeys=function(e,r){e.keys=new Array(16*2),tQ.equal(r.length,this.blockSize,"Invalid key length");var n=ro.readUInt32BE(r,0),i=ro.readUInt32BE(r,4);ro.pc1(n,i,e.tmp,0),n=e.tmp[0],i=e.tmp[1];for(var o=0;o>>1];n=ro.r28shl(n,s),i=ro.r28shl(i,s),ro.pc2(n,i,e.keys,o)}};Cl.prototype._update=function(e,r,n,i){var o=this._desState,s=ro.readUInt32BE(e,r),a=ro.readUInt32BE(e,r+4);ro.ip(s,a,o.tmp,0),s=o.tmp[0],a=o.tmp[1],this.type==="encrypt"?this._encrypt(o,s,a,o.tmp,0):this._decrypt(o,s,a,o.tmp,0),s=o.tmp[0],a=o.tmp[1],ro.writeUInt32BE(n,s,i),ro.writeUInt32BE(n,a,i+4)};Cl.prototype._pad=function(e,r){if(this.padding===!1)return!1;for(var n=e.length-r,i=r;i>>0,s=m}ro.rip(a,s,i,o)};Cl.prototype._decrypt=function(e,r,n,i,o){for(var s=n,a=r,d=e.keys.length-2;d>=0;d-=2){var u=e.keys[d],c=e.keys[d+1];ro.expand(s,e.tmp,0),u^=e.tmp[0],c^=e.tmp[1];var l=ro.substitute(u,c),p=ro.permute(l),m=s;s=(a^p)>>>0,a=m}ro.rip(s,a,i,o)}});var oQ=V(iQ=>{"use strict";f();var RTe=Nc(),DTe=Ft(),kA={};function BTe(t){RTe.equal(t.length,8,"Invalid IV length"),this.iv=new Array(8);for(var e=0;e{"use strict";f();var OTe=Nc(),CTe=Ft(),sQ=IA(),bm=wM();function $Te(t,e){OTe.equal(e.length,24,"Invalid key length");var r=e.slice(0,8),n=e.slice(8,16),i=e.slice(16,24);t==="encrypt"?this.ciphers=[bm.create({type:"encrypt",key:r}),bm.create({type:"decrypt",key:n}),bm.create({type:"encrypt",key:i})]:this.ciphers=[bm.create({type:"decrypt",key:i}),bm.create({type:"encrypt",key:n}),bm.create({type:"decrypt",key:r})]}function lg(t){sQ.call(this,t);var e=new $Te(this.type,this.options.key);this._edeState=e}CTe(lg,sQ);aQ.exports=lg;lg.create=function(e){return new lg(e)};lg.prototype._update=function(e,r,n,i){var o=this._edeState;o.ciphers[0]._update(e,r,n,i),o.ciphers[1]._update(n,i,n,i),o.ciphers[2]._update(n,i,n,i)};lg.prototype._pad=bm.prototype._pad;lg.prototype._unpad=bm.prototype._unpad});var dQ=V(Cw=>{"use strict";f();Cw.utils=bM();Cw.Cipher=IA();Cw.DES=wM();Cw.CBC=oQ();Cw.EDE=cQ()});var fQ=V((pgt,lQ)=>{f();var uQ=fh(),hh=dQ(),jTe=Ft(),fg=cr().Buffer,dE={"des-ede3-cbc":hh.CBC.instantiate(hh.EDE),"des-ede3":hh.EDE,"des-ede-cbc":hh.CBC.instantiate(hh.EDE),"des-ede":hh.EDE,"des-cbc":hh.CBC.instantiate(hh.DES),"des-ecb":hh.DES};dE.des=dE["des-cbc"];dE.des3=dE["des-ede3-cbc"];lQ.exports=RA;jTe(RA,uQ);function RA(t){uQ.call(this);var e=t.mode.toLowerCase(),r=dE[e],n;t.decrypt?n="decrypt":n="encrypt";var i=t.key;fg.isBuffer(i)||(i=fg.from(i)),(e==="des-ede"||e==="des-ede-cbc")&&(i=fg.concat([i,i.slice(0,8)]));var o=t.iv;fg.isBuffer(o)||(o=fg.from(o)),this._des=r.create({key:i,iv:o,type:n})}RA.prototype._update=function(t){return fg.from(this._des.update(t))};RA.prototype._final=function(){return fg.from(this._des.final())}});var hQ=V(_M=>{f();_M.encrypt=function(t,e){return t._cipher.encryptBlock(e)};_M.decrypt=function(t,e){return t._cipher.decryptBlock(e)}});var $w=V((vgt,pQ)=>{f();pQ.exports=function(e,r){for(var n=Math.min(e.length,r.length),i=new O.Buffer(n),o=0;o{f();var mQ=$w();xM.encrypt=function(t,e){var r=mQ(e,t._prev);return t._prev=t._cipher.encryptBlock(r),t._prev};xM.decrypt=function(t,e){var r=t._prev;t._prev=e;var n=t._cipher.decryptBlock(e);return mQ(n,r)}});var bQ=V(vQ=>{f();var uE=cr().Buffer,NTe=$w();function gQ(t,e,r){var n=e.length,i=NTe(e,t._cache);return t._cache=t._cache.slice(n),t._prev=uE.concat([t._prev,r?e:i]),i}vQ.encrypt=function(t,e,r){for(var n=uE.allocUnsafe(0),i;e.length;)if(t._cache.length===0&&(t._cache=t._cipher.encryptBlock(t._prev),t._prev=uE.allocUnsafe(0)),t._cache.length<=e.length)i=t._cache.length,n=uE.concat([n,gQ(t,e.slice(0,i),r)]),e=e.slice(i);else{n=uE.concat([n,gQ(t,e,r)]);break}return n}});var _Q=V(wQ=>{f();var EM=cr().Buffer;function UTe(t,e,r){var n=t._cipher.encryptBlock(t._prev),i=n[0]^e;return t._prev=EM.concat([t._prev.slice(1),EM.from([r?e:i])]),i}wQ.encrypt=function(t,e,r){for(var n=e.length,i=EM.allocUnsafe(n),o=-1;++o{f();var DA=cr().Buffer;function qTe(t,e,r){for(var n,i=-1,o=8,s=0,a,d;++i>i%8,t._prev=LTe(t._prev,r?a:d);return s}function LTe(t,e){var r=t.length,n=-1,i=DA.allocUnsafe(t.length);for(t=DA.concat([t,DA.from([e])]);++n>7;return i}xQ.encrypt=function(t,e,r){for(var n=e.length,i=DA.allocUnsafe(n),o=-1;++o{f();var KTe=$w();function FTe(t){return t._prev=t._cipher.encryptBlock(t._prev),t._prev}SQ.encrypt=function(t,e){for(;t._cache.length{f();function zTe(t){for(var e=t.length,r;e--;)if(r=t.readUInt8(e),r===255)t.writeUInt8(0,e);else{r++,t.writeUInt8(r,e);break}}TQ.exports=zTe});var TM=V(IQ=>{f();var WTe=$w(),PQ=cr().Buffer,HTe=SM();function VTe(t){var e=t._cipher.encryptBlockRaw(t._prev);return HTe(t._prev),e}var AM=16;IQ.encrypt=function(t,e){var r=Math.ceil(e.length/AM),n=t._cache.length;t._cache=PQ.concat([t._cache,PQ.allocUnsafe(r*AM)]);for(var i=0;i{GTe.exports={"aes-128-ecb":{cipher:"AES",key:128,iv:0,mode:"ECB",type:"block"},"aes-192-ecb":{cipher:"AES",key:192,iv:0,mode:"ECB",type:"block"},"aes-256-ecb":{cipher:"AES",key:256,iv:0,mode:"ECB",type:"block"},"aes-128-cbc":{cipher:"AES",key:128,iv:16,mode:"CBC",type:"block"},"aes-192-cbc":{cipher:"AES",key:192,iv:16,mode:"CBC",type:"block"},"aes-256-cbc":{cipher:"AES",key:256,iv:16,mode:"CBC",type:"block"},aes128:{cipher:"AES",key:128,iv:16,mode:"CBC",type:"block"},aes192:{cipher:"AES",key:192,iv:16,mode:"CBC",type:"block"},aes256:{cipher:"AES",key:256,iv:16,mode:"CBC",type:"block"},"aes-128-cfb":{cipher:"AES",key:128,iv:16,mode:"CFB",type:"stream"},"aes-192-cfb":{cipher:"AES",key:192,iv:16,mode:"CFB",type:"stream"},"aes-256-cfb":{cipher:"AES",key:256,iv:16,mode:"CFB",type:"stream"},"aes-128-cfb8":{cipher:"AES",key:128,iv:16,mode:"CFB8",type:"stream"},"aes-192-cfb8":{cipher:"AES",key:192,iv:16,mode:"CFB8",type:"stream"},"aes-256-cfb8":{cipher:"AES",key:256,iv:16,mode:"CFB8",type:"stream"},"aes-128-cfb1":{cipher:"AES",key:128,iv:16,mode:"CFB1",type:"stream"},"aes-192-cfb1":{cipher:"AES",key:192,iv:16,mode:"CFB1",type:"stream"},"aes-256-cfb1":{cipher:"AES",key:256,iv:16,mode:"CFB1",type:"stream"},"aes-128-ofb":{cipher:"AES",key:128,iv:16,mode:"OFB",type:"stream"},"aes-192-ofb":{cipher:"AES",key:192,iv:16,mode:"OFB",type:"stream"},"aes-256-ofb":{cipher:"AES",key:256,iv:16,mode:"OFB",type:"stream"},"aes-128-ctr":{cipher:"AES",key:128,iv:16,mode:"CTR",type:"stream"},"aes-192-ctr":{cipher:"AES",key:192,iv:16,mode:"CTR",type:"stream"},"aes-256-ctr":{cipher:"AES",key:256,iv:16,mode:"CTR",type:"stream"},"aes-128-gcm":{cipher:"AES",key:128,iv:12,mode:"GCM",type:"auth"},"aes-192-gcm":{cipher:"AES",key:192,iv:12,mode:"GCM",type:"auth"},"aes-256-gcm":{cipher:"AES",key:256,iv:12,mode:"GCM",type:"auth"}}});var MA=V((Cgt,kQ)=>{f();var JTe={ECB:hQ(),CBC:yQ(),CFB:bQ(),CFB8:_Q(),CFB1:EQ(),OFB:AQ(),CTR:TM(),GCM:TM()},BA=PM();for(IM in BA)BA[IM].module=JTe[BA[IM].mode];var IM;kQ.exports=BA});var lE=V((jgt,DQ)=>{f();var OA=cr().Buffer;function RM(t){OA.isBuffer(t)||(t=OA.from(t));for(var e=t.length/4|0,r=new Array(e),n=0;n>>24]^s[c>>>16&255]^a[l>>>8&255]^d[p&255]^e[S++],g=o[c>>>24]^s[l>>>16&255]^a[p>>>8&255]^d[u&255]^e[S++],v=o[l>>>24]^s[p>>>16&255]^a[u>>>8&255]^d[c&255]^e[S++],x=o[p>>>24]^s[u>>>16&255]^a[c>>>8&255]^d[l&255]^e[S++],u=m,c=g,l=v,p=x;return m=(n[u>>>24]<<24|n[c>>>16&255]<<16|n[l>>>8&255]<<8|n[p&255])^e[S++],g=(n[c>>>24]<<24|n[l>>>16&255]<<16|n[p>>>8&255]<<8|n[u&255])^e[S++],v=(n[l>>>24]<<24|n[p>>>16&255]<<16|n[u>>>8&255]<<8|n[c&255])^e[S++],x=(n[p>>>24]<<24|n[u>>>16&255]<<16|n[c>>>8&255]<<8|n[l&255])^e[S++],m=m>>>0,g=g>>>0,v=v>>>0,x=x>>>0,[m,g,v,x]}var ZTe=[0,1,2,4,8,16,32,64,128,27,54],Hi=function(){for(var t=new Array(256),e=0;e<256;e++)e<128?t[e]=e<<1:t[e]=e<<1^283;for(var r=[],n=[],i=[[],[],[],[]],o=[[],[],[],[]],s=0,a=0,d=0;d<256;++d){var u=a^a<<1^a<<2^a<<3^a<<4;u=u>>>8^u&255^99,r[s]=u,n[u]=s;var c=t[s],l=t[c],p=t[l],m=t[u]*257^u*16843008;i[0][s]=m<<24|m>>>8,i[1][s]=m<<16|m>>>16,i[2][s]=m<<8|m>>>24,i[3][s]=m,m=p*16843009^l*65537^c*257^s*16843008,o[0][u]=m<<24|m>>>8,o[1][u]=m<<16|m>>>16,o[2][u]=m<<8|m>>>24,o[3][u]=m,s===0?s=a=1:(s=c^t[t[t[p^c]]],a^=t[t[a]])}return{SBOX:r,INV_SBOX:n,SUB_MIX:i,INV_SUB_MIX:o}}();function Id(t){this._key=RM(t),this._reset()}Id.blockSize=4*4;Id.keySize=256/8;Id.prototype.blockSize=Id.blockSize;Id.prototype.keySize=Id.keySize;Id.prototype._reset=function(){for(var t=this._key,e=t.length,r=e+6,n=(r+1)*4,i=[],o=0;o>>24,s=Hi.SBOX[s>>>24]<<24|Hi.SBOX[s>>>16&255]<<16|Hi.SBOX[s>>>8&255]<<8|Hi.SBOX[s&255],s^=ZTe[o/e|0]<<24):e>6&&o%e===4&&(s=Hi.SBOX[s>>>24]<<24|Hi.SBOX[s>>>16&255]<<16|Hi.SBOX[s>>>8&255]<<8|Hi.SBOX[s&255]),i[o]=i[o-e]^s}for(var a=[],d=0;d>>24]]^Hi.INV_SUB_MIX[1][Hi.SBOX[c>>>16&255]]^Hi.INV_SUB_MIX[2][Hi.SBOX[c>>>8&255]]^Hi.INV_SUB_MIX[3][Hi.SBOX[c&255]]}this._nRounds=r,this._keySchedule=i,this._invKeySchedule=a};Id.prototype.encryptBlockRaw=function(t){return t=RM(t),RQ(t,this._keySchedule,Hi.SUB_MIX,Hi.SBOX,this._nRounds)};Id.prototype.encryptBlock=function(t){var e=this.encryptBlockRaw(t),r=OA.allocUnsafe(16);return r.writeUInt32BE(e[0],0),r.writeUInt32BE(e[1],4),r.writeUInt32BE(e[2],8),r.writeUInt32BE(e[3],12),r};Id.prototype.decryptBlock=function(t){t=RM(t);var e=t[1];t[1]=t[3],t[3]=e;var r=RQ(t,this._invKeySchedule,Hi.INV_SUB_MIX,Hi.INV_SBOX,this._nRounds),n=OA.allocUnsafe(16);return n.writeUInt32BE(r[0],0),n.writeUInt32BE(r[3],4),n.writeUInt32BE(r[2],8),n.writeUInt32BE(r[1],12),n};Id.prototype.scrub=function(){kM(this._keySchedule),kM(this._invKeySchedule),kM(this._key)};DQ.exports.AES=Id});var OQ=V((Ugt,MQ)=>{f();var jw=cr().Buffer,YTe=jw.alloc(16,0);function XTe(t){return[t.readUInt32BE(0),t.readUInt32BE(4),t.readUInt32BE(8),t.readUInt32BE(12)]}function BQ(t){var e=jw.allocUnsafe(16);return e.writeUInt32BE(t[0]>>>0,0),e.writeUInt32BE(t[1]>>>0,4),e.writeUInt32BE(t[2]>>>0,8),e.writeUInt32BE(t[3]>>>0,12),e}function fE(t){this.h=t,this.state=jw.alloc(16,0),this.cache=jw.allocUnsafe(0)}fE.prototype.ghash=function(t){for(var e=-1;++e0;r--)t[r]=t[r]>>>1|(t[r-1]&1)<<31;t[0]=t[0]>>>1,i&&(t[0]=t[0]^225<<24)}this.state=BQ(e)};fE.prototype.update=function(t){this.cache=jw.concat([this.cache,t]);for(var e;this.cache.length>=16;)e=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(e)};fE.prototype.final=function(t,e){return this.cache.length&&this.ghash(jw.concat([this.cache,YTe],16)),this.ghash(BQ([0,t,0,e])),this.state};MQ.exports=fE});var DM=V((Lgt,jQ)=>{f();var QTe=lE(),Xa=cr().Buffer,CQ=fh(),ePe=Ft(),$Q=OQ(),tPe=$w(),rPe=SM();function nPe(t,e){var r=0;t.length!==e.length&&r++;for(var n=Math.min(t.length,e.length),i=0;i{f();var oPe=lE(),BM=cr().Buffer,NQ=fh(),sPe=Ft();function CA(t,e,r,n){NQ.call(this),this._cipher=new oPe.AES(e),this._prev=BM.from(r),this._cache=BM.allocUnsafe(0),this._secCache=BM.allocUnsafe(0),this._decrypt=n,this._mode=t}sPe(CA,NQ);CA.prototype._update=function(t){return this._mode.encrypt(this,t,this._decrypt)};CA.prototype._final=function(){this._cipher.scrub()};UQ.exports=CA});var hE=V((Wgt,qQ)=>{f();var pg=cr().Buffer,aPe=mA();function cPe(t,e,r,n){if(pg.isBuffer(t)||(t=pg.from(t,"binary")),e&&(pg.isBuffer(e)||(e=pg.from(e,"binary")),e.length!==8))throw new RangeError("salt should be Buffer with 8 byte length");for(var i=r/8,o=pg.alloc(i),s=pg.alloc(n||0),a=pg.alloc(0);i>0||n>0;){var d=new aPe;d.update(a),d.update(t),e&&d.update(e),a=d.digest();var u=0;if(i>0){var c=o.length-i;u=Math.min(i,a.length),a.copy(o,c,0,u),i-=u}if(u0){var l=s.length-n,p=Math.min(n,a.length-u);a.copy(s,l,u,u+p),n-=p}}return a.fill(0),{key:o,iv:s}}qQ.exports=cPe});var zQ=V(OM=>{f();var LQ=MA(),dPe=DM(),ph=cr().Buffer,uPe=MM(),KQ=fh(),lPe=lE(),fPe=hE(),hPe=Ft();function pE(t,e,r){KQ.call(this),this._cache=new $A,this._cipher=new lPe.AES(e),this._prev=ph.from(r),this._mode=t,this._autopadding=!0}hPe(pE,KQ);pE.prototype._update=function(t){this._cache.add(t);for(var e,r,n=[];e=this._cache.get();)r=this._mode.encrypt(this,e),n.push(r);return ph.concat(n)};var pPe=ph.alloc(16,16);pE.prototype._final=function(){var t=this._cache.flush();if(this._autopadding)return t=this._mode.encrypt(this,t),this._cipher.scrub(),t;if(!t.equals(pPe))throw this._cipher.scrub(),new Error("data not multiple of block length")};pE.prototype.setAutoPadding=function(t){return this._autopadding=!!t,this};function $A(){this.cache=ph.allocUnsafe(0)}$A.prototype.add=function(t){this.cache=ph.concat([this.cache,t])};$A.prototype.get=function(){if(this.cache.length>15){var t=this.cache.slice(0,16);return this.cache=this.cache.slice(16),t}return null};$A.prototype.flush=function(){for(var t=16-this.cache.length,e=ph.allocUnsafe(t),r=-1;++r{f();var yPe=DM(),Nw=cr().Buffer,WQ=MA(),gPe=MM(),HQ=fh(),vPe=lE(),bPe=hE(),wPe=Ft();function mE(t,e,r){HQ.call(this),this._cache=new jA,this._last=void 0,this._cipher=new vPe.AES(e),this._prev=Nw.from(r),this._mode=t,this._autopadding=!0}wPe(mE,HQ);mE.prototype._update=function(t){this._cache.add(t);for(var e,r,n=[];e=this._cache.get(this._autopadding);)r=this._mode.decrypt(this,e),n.push(r);return Nw.concat(n)};mE.prototype._final=function(){var t=this._cache.flush();if(this._autopadding)return _Pe(this._mode.decrypt(this,t));if(t)throw new Error("data not multiple of block length")};mE.prototype.setAutoPadding=function(t){return this._autopadding=!!t,this};function jA(){this.cache=Nw.allocUnsafe(0)}jA.prototype.add=function(t){this.cache=Nw.concat([this.cache,t])};jA.prototype.get=function(t){var e;if(t){if(this.cache.length>16)return e=this.cache.slice(0,16),this.cache=this.cache.slice(16),e}else if(this.cache.length>=16)return e=this.cache.slice(0,16),this.cache=this.cache.slice(16),e;return null};jA.prototype.flush=function(){if(this.cache.length)return this.cache};function _Pe(t){var e=t[15];if(e<1||e>16)throw new Error("unable to decrypt data");for(var r=-1;++r{f();var JQ=zQ(),ZQ=GQ(),EPe=PM();function SPe(){return Object.keys(EPe)}Au.createCipher=Au.Cipher=JQ.createCipher;Au.createCipheriv=Au.Cipheriv=JQ.createCipheriv;Au.createDecipher=Au.Decipher=ZQ.createDecipher;Au.createDecipheriv=Au.Decipheriv=ZQ.createDecipheriv;Au.listCiphers=Au.getCiphers=SPe});var YQ=V(mh=>{f();mh["des-ecb"]={key:8,iv:0};mh["des-cbc"]=mh.des={key:8,iv:8};mh["des-ede3-cbc"]=mh.des3={key:24,iv:8};mh["des-ede3"]={key:24,iv:0};mh["des-ede-cbc"]={key:16,iv:8};mh["des-ede"]={key:16,iv:0}});var ree=V(Tu=>{f();var XQ=fQ(),$M=NA(),wm=MA(),yh=YQ(),QQ=hE();function APe(t,e){t=t.toLowerCase();var r,n;if(wm[t])r=wm[t].key,n=wm[t].iv;else if(yh[t])r=yh[t].key*8,n=yh[t].iv;else throw new TypeError("invalid suite type");var i=QQ(e,!1,r,n);return eee(t,i.key,i.iv)}function TPe(t,e){t=t.toLowerCase();var r,n;if(wm[t])r=wm[t].key,n=wm[t].iv;else if(yh[t])r=yh[t].key*8,n=yh[t].iv;else throw new TypeError("invalid suite type");var i=QQ(e,!1,r,n);return tee(t,i.key,i.iv)}function eee(t,e,r){if(t=t.toLowerCase(),wm[t])return $M.createCipheriv(t,e,r);if(yh[t])return new XQ({key:e,iv:r,mode:t});throw new TypeError("invalid suite type")}function tee(t,e,r){if(t=t.toLowerCase(),wm[t])return $M.createDecipheriv(t,e,r);if(yh[t])return new XQ({key:e,iv:r,mode:t,decrypt:!0});throw new TypeError("invalid suite type")}function PPe(){return Object.keys(yh).concat($M.getCiphers())}Tu.createCipher=Tu.Cipher=APe;Tu.createCipheriv=Tu.Cipheriv=eee;Tu.createDecipher=Tu.Decipher=TPe;Tu.createDecipheriv=Tu.Decipheriv=tee;Tu.listCiphers=Tu.getCiphers=PPe});var jM=V(()=>{f()});var Mo=V((nee,NM)=>{f();(function(t,e){"use strict";function r(L,I){if(!L)throw new Error(I||"Assertion failed")}function n(L,I){L.super_=I;var T=function(){};T.prototype=I.prototype,L.prototype=new T,L.prototype.constructor=L}function i(L,I,T){if(i.isBN(L))return L;this.negative=0,this.words=null,this.length=0,this.red=null,L!==null&&((I==="le"||I==="be")&&(T=I,I=10),this._init(L||0,I||10,T||"be"))}typeof t=="object"?t.exports=i:e.BN=i,i.BN=i,i.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=jM().Buffer}catch{}i.isBN=function(I){return I instanceof i?!0:I!==null&&typeof I=="object"&&I.constructor.wordSize===i.wordSize&&Array.isArray(I.words)},i.max=function(I,T){return I.cmp(T)>0?I:T},i.min=function(I,T){return I.cmp(T)<0?I:T},i.prototype._init=function(I,T,B){if(typeof I=="number")return this._initNumber(I,T,B);if(typeof I=="object")return this._initArray(I,T,B);T==="hex"&&(T=16),r(T===(T|0)&&T>=2&&T<=36),I=I.toString().replace(/\s+/g,"");var h=0;I[0]==="-"&&(h++,this.negative=1),h=0;h-=3)w=I[h]|I[h-1]<<8|I[h-2]<<16,this.words[y]|=w<>>26-E&67108863,E+=24,E>=26&&(E-=26,y++);else if(B==="le")for(h=0,y=0;h>>26-E&67108863,E+=24,E>=26&&(E-=26,y++);return this.strip()};function s(L,I){var T=L.charCodeAt(I);return T>=65&&T<=70?T-55:T>=97&&T<=102?T-87:T-48&15}function a(L,I,T){var B=s(L,T);return T-1>=I&&(B|=s(L,T-1)<<4),B}i.prototype._parseHex=function(I,T,B){this.length=Math.ceil((I.length-T)/6),this.words=new Array(this.length);for(var h=0;h=T;h-=2)E=a(I,T,h)<=18?(y-=18,w+=1,this.words[w]|=E>>>26):y+=8;else{var _=I.length-T;for(h=_%2===0?T+1:T;h=18?(y-=18,w+=1,this.words[w]|=E>>>26):y+=8}this.strip()};function d(L,I,T,B){for(var h=0,y=Math.min(L.length,T),w=I;w=49?h+=E-49+10:E>=17?h+=E-17+10:h+=E}return h}i.prototype._parseBase=function(I,T,B){this.words=[0],this.length=1;for(var h=0,y=1;y<=67108863;y*=T)h++;h--,y=y/T|0;for(var w=I.length-B,E=w%h,_=Math.min(w,w-E)+B,b=0,C=B;C<_;C+=h)b=d(I,C,C+h,T),this.imuln(y),this.words[0]+b<67108864?this.words[0]+=b:this._iaddn(b);if(E!==0){var N=1;for(b=d(I,C,I.length,T),C=0;C1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},i.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},i.prototype.inspect=function(){return(this.red?""};var u=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],c=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],l=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];i.prototype.toString=function(I,T){I=I||10,T=T|0||1;var B;if(I===16||I==="hex"){B="";for(var h=0,y=0,w=0;w>>24-h&16777215,y!==0||w!==this.length-1?B=u[6-_.length]+_+B:B=_+B,h+=2,h>=26&&(h-=26,w--)}for(y!==0&&(B=y.toString(16)+B);B.length%T!==0;)B="0"+B;return this.negative!==0&&(B="-"+B),B}if(I===(I|0)&&I>=2&&I<=36){var b=c[I],C=l[I];B="";var N=this.clone();for(N.negative=0;!N.isZero();){var M=N.modn(C).toString(I);N=N.idivn(C),N.isZero()?B=M+B:B=u[b-M.length]+M+B}for(this.isZero()&&(B="0"+B);B.length%T!==0;)B="0"+B;return this.negative!==0&&(B="-"+B),B}r(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var I=this.words[0];return this.length===2?I+=this.words[1]*67108864:this.length===3&&this.words[2]===1?I+=4503599627370496+this.words[1]*67108864:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-I:I},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toBuffer=function(I,T){return r(typeof o<"u"),this.toArrayLike(o,I,T)},i.prototype.toArray=function(I,T){return this.toArrayLike(Array,I,T)},i.prototype.toArrayLike=function(I,T,B){var h=this.byteLength(),y=B||Math.max(1,h);r(h<=y,"byte array longer than desired length"),r(y>0,"Requested array length <= 0"),this.strip();var w=T==="le",E=new I(y),_,b,C=this.clone();if(w){for(b=0;!C.isZero();b++)_=C.andln(255),C.iushrn(8),E[b]=_;for(;b=4096&&(B+=13,T>>>=13),T>=64&&(B+=7,T>>>=7),T>=8&&(B+=4,T>>>=4),T>=2&&(B+=2,T>>>=2),B+T},i.prototype._zeroBits=function(I){if(I===0)return 26;var T=I,B=0;return T&8191||(B+=13,T>>>=13),T&127||(B+=7,T>>>=7),T&15||(B+=4,T>>>=4),T&3||(B+=2,T>>>=2),T&1||B++,B},i.prototype.bitLength=function(){var I=this.words[this.length-1],T=this._countBits(I);return(this.length-1)*26+T};function p(L){for(var I=new Array(L.bitLength()),T=0;T>>h}return I}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var I=0,T=0;TI.length?this.clone().ior(I):I.clone().ior(this)},i.prototype.uor=function(I){return this.length>I.length?this.clone().iuor(I):I.clone().iuor(this)},i.prototype.iuand=function(I){var T;this.length>I.length?T=I:T=this;for(var B=0;BI.length?this.clone().iand(I):I.clone().iand(this)},i.prototype.uand=function(I){return this.length>I.length?this.clone().iuand(I):I.clone().iuand(this)},i.prototype.iuxor=function(I){var T,B;this.length>I.length?(T=this,B=I):(T=I,B=this);for(var h=0;hI.length?this.clone().ixor(I):I.clone().ixor(this)},i.prototype.uxor=function(I){return this.length>I.length?this.clone().iuxor(I):I.clone().iuxor(this)},i.prototype.inotn=function(I){r(typeof I=="number"&&I>=0);var T=Math.ceil(I/26)|0,B=I%26;this._expand(T),B>0&&T--;for(var h=0;h0&&(this.words[h]=~this.words[h]&67108863>>26-B),this.strip()},i.prototype.notn=function(I){return this.clone().inotn(I)},i.prototype.setn=function(I,T){r(typeof I=="number"&&I>=0);var B=I/26|0,h=I%26;return this._expand(B+1),T?this.words[B]=this.words[B]|1<I.length?(B=this,h=I):(B=I,h=this);for(var y=0,w=0;w>>26;for(;y!==0&&w>>26;if(this.length=B.length,y!==0)this.words[this.length]=y,this.length++;else if(B!==this)for(;wI.length?this.clone().iadd(I):I.clone().iadd(this)},i.prototype.isub=function(I){if(I.negative!==0){I.negative=0;var T=this.iadd(I);return I.negative=1,T._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(I),this.negative=1,this._normSign();var B=this.cmp(I);if(B===0)return this.negative=0,this.length=1,this.words[0]=0,this;var h,y;B>0?(h=this,y=I):(h=I,y=this);for(var w=0,E=0;E>26,this.words[E]=T&67108863;for(;w!==0&&E>26,this.words[E]=T&67108863;if(w===0&&E>>26,N=_&67108863,M=Math.min(b,I.length-1),U=Math.max(0,b-L.length+1);U<=M;U++){var G=b-U|0;h=L.words[G]|0,y=I.words[U]|0,w=h*y+N,C+=w/67108864|0,N=w&67108863}T.words[b]=N|0,_=C|0}return _!==0?T.words[b]=_|0:T.length--,T.strip()}var g=function(I,T,B){var h=I.words,y=T.words,w=B.words,E=0,_,b,C,N=h[0]|0,M=N&8191,U=N>>>13,G=h[1]|0,Z=G&8191,J=G>>>13,H=h[2]|0,X=H&8191,te=H>>>13,ne=h[3]|0,Q=ne&8191,re=ne>>>13,ce=h[4]|0,pe=ce&8191,ye=ce>>>13,ie=h[5]|0,he=ie&8191,me=ie>>>13,Re=h[6]|0,xe=Re&8191,it=Re>>>13,Et=h[7]|0,Fe=Et&8191,mt=Et>>>13,Sn=h[8]|0,ke=Sn&8191,Pe=Sn>>>13,Wt=h[9]|0,Be=Wt&8191,Ee=Wt>>>13,$r=y[0]|0,Ve=$r&8191,Ze=$r>>>13,tn=y[1]|0,Rt=tn&8191,Ye=tn>>>13,yd=y[2]|0,Dt=yd&8191,Ut=yd>>>13,g0=y[3]|0,$t=g0&8191,Zt=g0>>>13,gd=y[4]|0,Yt=gd&8191,Ht=gd>>>13,v0=y[5]|0,qt=v0&8191,Vt=v0>>>13,b0=y[6]|0,Gt=b0&8191,Xt=b0>>>13,Kp=y[7]|0,ee=Kp&8191,Y=Kp>>>13,se=y[8]|0,ue=se&8191,le=se>>>13,Ne=y[9]|0,Me=Ne&8191,Ue=Ne>>>13;B.negative=I.negative^T.negative,B.length=19,_=Math.imul(M,Ve),b=Math.imul(M,Ze),b=b+Math.imul(U,Ve)|0,C=Math.imul(U,Ze);var Tr=(E+_|0)+((b&8191)<<13)|0;E=(C+(b>>>13)|0)+(Tr>>>26)|0,Tr&=67108863,_=Math.imul(Z,Ve),b=Math.imul(Z,Ze),b=b+Math.imul(J,Ve)|0,C=Math.imul(J,Ze),_=_+Math.imul(M,Rt)|0,b=b+Math.imul(M,Ye)|0,b=b+Math.imul(U,Rt)|0,C=C+Math.imul(U,Ye)|0;var Lt=(E+_|0)+((b&8191)<<13)|0;E=(C+(b>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,_=Math.imul(X,Ve),b=Math.imul(X,Ze),b=b+Math.imul(te,Ve)|0,C=Math.imul(te,Ze),_=_+Math.imul(Z,Rt)|0,b=b+Math.imul(Z,Ye)|0,b=b+Math.imul(J,Rt)|0,C=C+Math.imul(J,Ye)|0,_=_+Math.imul(M,Dt)|0,b=b+Math.imul(M,Ut)|0,b=b+Math.imul(U,Dt)|0,C=C+Math.imul(U,Ut)|0;var ft=(E+_|0)+((b&8191)<<13)|0;E=(C+(b>>>13)|0)+(ft>>>26)|0,ft&=67108863,_=Math.imul(Q,Ve),b=Math.imul(Q,Ze),b=b+Math.imul(re,Ve)|0,C=Math.imul(re,Ze),_=_+Math.imul(X,Rt)|0,b=b+Math.imul(X,Ye)|0,b=b+Math.imul(te,Rt)|0,C=C+Math.imul(te,Ye)|0,_=_+Math.imul(Z,Dt)|0,b=b+Math.imul(Z,Ut)|0,b=b+Math.imul(J,Dt)|0,C=C+Math.imul(J,Ut)|0,_=_+Math.imul(M,$t)|0,b=b+Math.imul(M,Zt)|0,b=b+Math.imul(U,$t)|0,C=C+Math.imul(U,Zt)|0;var Zr=(E+_|0)+((b&8191)<<13)|0;E=(C+(b>>>13)|0)+(Zr>>>26)|0,Zr&=67108863,_=Math.imul(pe,Ve),b=Math.imul(pe,Ze),b=b+Math.imul(ye,Ve)|0,C=Math.imul(ye,Ze),_=_+Math.imul(Q,Rt)|0,b=b+Math.imul(Q,Ye)|0,b=b+Math.imul(re,Rt)|0,C=C+Math.imul(re,Ye)|0,_=_+Math.imul(X,Dt)|0,b=b+Math.imul(X,Ut)|0,b=b+Math.imul(te,Dt)|0,C=C+Math.imul(te,Ut)|0,_=_+Math.imul(Z,$t)|0,b=b+Math.imul(Z,Zt)|0,b=b+Math.imul(J,$t)|0,C=C+Math.imul(J,Zt)|0,_=_+Math.imul(M,Yt)|0,b=b+Math.imul(M,Ht)|0,b=b+Math.imul(U,Yt)|0,C=C+Math.imul(U,Ht)|0;var un=(E+_|0)+((b&8191)<<13)|0;E=(C+(b>>>13)|0)+(un>>>26)|0,un&=67108863,_=Math.imul(he,Ve),b=Math.imul(he,Ze),b=b+Math.imul(me,Ve)|0,C=Math.imul(me,Ze),_=_+Math.imul(pe,Rt)|0,b=b+Math.imul(pe,Ye)|0,b=b+Math.imul(ye,Rt)|0,C=C+Math.imul(ye,Ye)|0,_=_+Math.imul(Q,Dt)|0,b=b+Math.imul(Q,Ut)|0,b=b+Math.imul(re,Dt)|0,C=C+Math.imul(re,Ut)|0,_=_+Math.imul(X,$t)|0,b=b+Math.imul(X,Zt)|0,b=b+Math.imul(te,$t)|0,C=C+Math.imul(te,Zt)|0,_=_+Math.imul(Z,Yt)|0,b=b+Math.imul(Z,Ht)|0,b=b+Math.imul(J,Yt)|0,C=C+Math.imul(J,Ht)|0,_=_+Math.imul(M,qt)|0,b=b+Math.imul(M,Vt)|0,b=b+Math.imul(U,qt)|0,C=C+Math.imul(U,Vt)|0;var Hr=(E+_|0)+((b&8191)<<13)|0;E=(C+(b>>>13)|0)+(Hr>>>26)|0,Hr&=67108863,_=Math.imul(xe,Ve),b=Math.imul(xe,Ze),b=b+Math.imul(it,Ve)|0,C=Math.imul(it,Ze),_=_+Math.imul(he,Rt)|0,b=b+Math.imul(he,Ye)|0,b=b+Math.imul(me,Rt)|0,C=C+Math.imul(me,Ye)|0,_=_+Math.imul(pe,Dt)|0,b=b+Math.imul(pe,Ut)|0,b=b+Math.imul(ye,Dt)|0,C=C+Math.imul(ye,Ut)|0,_=_+Math.imul(Q,$t)|0,b=b+Math.imul(Q,Zt)|0,b=b+Math.imul(re,$t)|0,C=C+Math.imul(re,Zt)|0,_=_+Math.imul(X,Yt)|0,b=b+Math.imul(X,Ht)|0,b=b+Math.imul(te,Yt)|0,C=C+Math.imul(te,Ht)|0,_=_+Math.imul(Z,qt)|0,b=b+Math.imul(Z,Vt)|0,b=b+Math.imul(J,qt)|0,C=C+Math.imul(J,Vt)|0,_=_+Math.imul(M,Gt)|0,b=b+Math.imul(M,Xt)|0,b=b+Math.imul(U,Gt)|0,C=C+Math.imul(U,Xt)|0;var ar=(E+_|0)+((b&8191)<<13)|0;E=(C+(b>>>13)|0)+(ar>>>26)|0,ar&=67108863,_=Math.imul(Fe,Ve),b=Math.imul(Fe,Ze),b=b+Math.imul(mt,Ve)|0,C=Math.imul(mt,Ze),_=_+Math.imul(xe,Rt)|0,b=b+Math.imul(xe,Ye)|0,b=b+Math.imul(it,Rt)|0,C=C+Math.imul(it,Ye)|0,_=_+Math.imul(he,Dt)|0,b=b+Math.imul(he,Ut)|0,b=b+Math.imul(me,Dt)|0,C=C+Math.imul(me,Ut)|0,_=_+Math.imul(pe,$t)|0,b=b+Math.imul(pe,Zt)|0,b=b+Math.imul(ye,$t)|0,C=C+Math.imul(ye,Zt)|0,_=_+Math.imul(Q,Yt)|0,b=b+Math.imul(Q,Ht)|0,b=b+Math.imul(re,Yt)|0,C=C+Math.imul(re,Ht)|0,_=_+Math.imul(X,qt)|0,b=b+Math.imul(X,Vt)|0,b=b+Math.imul(te,qt)|0,C=C+Math.imul(te,Vt)|0,_=_+Math.imul(Z,Gt)|0,b=b+Math.imul(Z,Xt)|0,b=b+Math.imul(J,Gt)|0,C=C+Math.imul(J,Xt)|0,_=_+Math.imul(M,ee)|0,b=b+Math.imul(M,Y)|0,b=b+Math.imul(U,ee)|0,C=C+Math.imul(U,Y)|0;var Yr=(E+_|0)+((b&8191)<<13)|0;E=(C+(b>>>13)|0)+(Yr>>>26)|0,Yr&=67108863,_=Math.imul(ke,Ve),b=Math.imul(ke,Ze),b=b+Math.imul(Pe,Ve)|0,C=Math.imul(Pe,Ze),_=_+Math.imul(Fe,Rt)|0,b=b+Math.imul(Fe,Ye)|0,b=b+Math.imul(mt,Rt)|0,C=C+Math.imul(mt,Ye)|0,_=_+Math.imul(xe,Dt)|0,b=b+Math.imul(xe,Ut)|0,b=b+Math.imul(it,Dt)|0,C=C+Math.imul(it,Ut)|0,_=_+Math.imul(he,$t)|0,b=b+Math.imul(he,Zt)|0,b=b+Math.imul(me,$t)|0,C=C+Math.imul(me,Zt)|0,_=_+Math.imul(pe,Yt)|0,b=b+Math.imul(pe,Ht)|0,b=b+Math.imul(ye,Yt)|0,C=C+Math.imul(ye,Ht)|0,_=_+Math.imul(Q,qt)|0,b=b+Math.imul(Q,Vt)|0,b=b+Math.imul(re,qt)|0,C=C+Math.imul(re,Vt)|0,_=_+Math.imul(X,Gt)|0,b=b+Math.imul(X,Xt)|0,b=b+Math.imul(te,Gt)|0,C=C+Math.imul(te,Xt)|0,_=_+Math.imul(Z,ee)|0,b=b+Math.imul(Z,Y)|0,b=b+Math.imul(J,ee)|0,C=C+Math.imul(J,Y)|0,_=_+Math.imul(M,ue)|0,b=b+Math.imul(M,le)|0,b=b+Math.imul(U,ue)|0,C=C+Math.imul(U,le)|0;var Br=(E+_|0)+((b&8191)<<13)|0;E=(C+(b>>>13)|0)+(Br>>>26)|0,Br&=67108863,_=Math.imul(Be,Ve),b=Math.imul(Be,Ze),b=b+Math.imul(Ee,Ve)|0,C=Math.imul(Ee,Ze),_=_+Math.imul(ke,Rt)|0,b=b+Math.imul(ke,Ye)|0,b=b+Math.imul(Pe,Rt)|0,C=C+Math.imul(Pe,Ye)|0,_=_+Math.imul(Fe,Dt)|0,b=b+Math.imul(Fe,Ut)|0,b=b+Math.imul(mt,Dt)|0,C=C+Math.imul(mt,Ut)|0,_=_+Math.imul(xe,$t)|0,b=b+Math.imul(xe,Zt)|0,b=b+Math.imul(it,$t)|0,C=C+Math.imul(it,Zt)|0,_=_+Math.imul(he,Yt)|0,b=b+Math.imul(he,Ht)|0,b=b+Math.imul(me,Yt)|0,C=C+Math.imul(me,Ht)|0,_=_+Math.imul(pe,qt)|0,b=b+Math.imul(pe,Vt)|0,b=b+Math.imul(ye,qt)|0,C=C+Math.imul(ye,Vt)|0,_=_+Math.imul(Q,Gt)|0,b=b+Math.imul(Q,Xt)|0,b=b+Math.imul(re,Gt)|0,C=C+Math.imul(re,Xt)|0,_=_+Math.imul(X,ee)|0,b=b+Math.imul(X,Y)|0,b=b+Math.imul(te,ee)|0,C=C+Math.imul(te,Y)|0,_=_+Math.imul(Z,ue)|0,b=b+Math.imul(Z,le)|0,b=b+Math.imul(J,ue)|0,C=C+Math.imul(J,le)|0,_=_+Math.imul(M,Me)|0,b=b+Math.imul(M,Ue)|0,b=b+Math.imul(U,Me)|0,C=C+Math.imul(U,Ue)|0;var pa=(E+_|0)+((b&8191)<<13)|0;E=(C+(b>>>13)|0)+(pa>>>26)|0,pa&=67108863,_=Math.imul(Be,Rt),b=Math.imul(Be,Ye),b=b+Math.imul(Ee,Rt)|0,C=Math.imul(Ee,Ye),_=_+Math.imul(ke,Dt)|0,b=b+Math.imul(ke,Ut)|0,b=b+Math.imul(Pe,Dt)|0,C=C+Math.imul(Pe,Ut)|0,_=_+Math.imul(Fe,$t)|0,b=b+Math.imul(Fe,Zt)|0,b=b+Math.imul(mt,$t)|0,C=C+Math.imul(mt,Zt)|0,_=_+Math.imul(xe,Yt)|0,b=b+Math.imul(xe,Ht)|0,b=b+Math.imul(it,Yt)|0,C=C+Math.imul(it,Ht)|0,_=_+Math.imul(he,qt)|0,b=b+Math.imul(he,Vt)|0,b=b+Math.imul(me,qt)|0,C=C+Math.imul(me,Vt)|0,_=_+Math.imul(pe,Gt)|0,b=b+Math.imul(pe,Xt)|0,b=b+Math.imul(ye,Gt)|0,C=C+Math.imul(ye,Xt)|0,_=_+Math.imul(Q,ee)|0,b=b+Math.imul(Q,Y)|0,b=b+Math.imul(re,ee)|0,C=C+Math.imul(re,Y)|0,_=_+Math.imul(X,ue)|0,b=b+Math.imul(X,le)|0,b=b+Math.imul(te,ue)|0,C=C+Math.imul(te,le)|0,_=_+Math.imul(Z,Me)|0,b=b+Math.imul(Z,Ue)|0,b=b+Math.imul(J,Me)|0,C=C+Math.imul(J,Ue)|0;var Si=(E+_|0)+((b&8191)<<13)|0;E=(C+(b>>>13)|0)+(Si>>>26)|0,Si&=67108863,_=Math.imul(Be,Dt),b=Math.imul(Be,Ut),b=b+Math.imul(Ee,Dt)|0,C=Math.imul(Ee,Ut),_=_+Math.imul(ke,$t)|0,b=b+Math.imul(ke,Zt)|0,b=b+Math.imul(Pe,$t)|0,C=C+Math.imul(Pe,Zt)|0,_=_+Math.imul(Fe,Yt)|0,b=b+Math.imul(Fe,Ht)|0,b=b+Math.imul(mt,Yt)|0,C=C+Math.imul(mt,Ht)|0,_=_+Math.imul(xe,qt)|0,b=b+Math.imul(xe,Vt)|0,b=b+Math.imul(it,qt)|0,C=C+Math.imul(it,Vt)|0,_=_+Math.imul(he,Gt)|0,b=b+Math.imul(he,Xt)|0,b=b+Math.imul(me,Gt)|0,C=C+Math.imul(me,Xt)|0,_=_+Math.imul(pe,ee)|0,b=b+Math.imul(pe,Y)|0,b=b+Math.imul(ye,ee)|0,C=C+Math.imul(ye,Y)|0,_=_+Math.imul(Q,ue)|0,b=b+Math.imul(Q,le)|0,b=b+Math.imul(re,ue)|0,C=C+Math.imul(re,le)|0,_=_+Math.imul(X,Me)|0,b=b+Math.imul(X,Ue)|0,b=b+Math.imul(te,Me)|0,C=C+Math.imul(te,Ue)|0;var qi=(E+_|0)+((b&8191)<<13)|0;E=(C+(b>>>13)|0)+(qi>>>26)|0,qi&=67108863,_=Math.imul(Be,$t),b=Math.imul(Be,Zt),b=b+Math.imul(Ee,$t)|0,C=Math.imul(Ee,Zt),_=_+Math.imul(ke,Yt)|0,b=b+Math.imul(ke,Ht)|0,b=b+Math.imul(Pe,Yt)|0,C=C+Math.imul(Pe,Ht)|0,_=_+Math.imul(Fe,qt)|0,b=b+Math.imul(Fe,Vt)|0,b=b+Math.imul(mt,qt)|0,C=C+Math.imul(mt,Vt)|0,_=_+Math.imul(xe,Gt)|0,b=b+Math.imul(xe,Xt)|0,b=b+Math.imul(it,Gt)|0,C=C+Math.imul(it,Xt)|0,_=_+Math.imul(he,ee)|0,b=b+Math.imul(he,Y)|0,b=b+Math.imul(me,ee)|0,C=C+Math.imul(me,Y)|0,_=_+Math.imul(pe,ue)|0,b=b+Math.imul(pe,le)|0,b=b+Math.imul(ye,ue)|0,C=C+Math.imul(ye,le)|0,_=_+Math.imul(Q,Me)|0,b=b+Math.imul(Q,Ue)|0,b=b+Math.imul(re,Me)|0,C=C+Math.imul(re,Ue)|0;var jr=(E+_|0)+((b&8191)<<13)|0;E=(C+(b>>>13)|0)+(jr>>>26)|0,jr&=67108863,_=Math.imul(Be,Yt),b=Math.imul(Be,Ht),b=b+Math.imul(Ee,Yt)|0,C=Math.imul(Ee,Ht),_=_+Math.imul(ke,qt)|0,b=b+Math.imul(ke,Vt)|0,b=b+Math.imul(Pe,qt)|0,C=C+Math.imul(Pe,Vt)|0,_=_+Math.imul(Fe,Gt)|0,b=b+Math.imul(Fe,Xt)|0,b=b+Math.imul(mt,Gt)|0,C=C+Math.imul(mt,Xt)|0,_=_+Math.imul(xe,ee)|0,b=b+Math.imul(xe,Y)|0,b=b+Math.imul(it,ee)|0,C=C+Math.imul(it,Y)|0,_=_+Math.imul(he,ue)|0,b=b+Math.imul(he,le)|0,b=b+Math.imul(me,ue)|0,C=C+Math.imul(me,le)|0,_=_+Math.imul(pe,Me)|0,b=b+Math.imul(pe,Ue)|0,b=b+Math.imul(ye,Me)|0,C=C+Math.imul(ye,Ue)|0;var Ai=(E+_|0)+((b&8191)<<13)|0;E=(C+(b>>>13)|0)+(Ai>>>26)|0,Ai&=67108863,_=Math.imul(Be,qt),b=Math.imul(Be,Vt),b=b+Math.imul(Ee,qt)|0,C=Math.imul(Ee,Vt),_=_+Math.imul(ke,Gt)|0,b=b+Math.imul(ke,Xt)|0,b=b+Math.imul(Pe,Gt)|0,C=C+Math.imul(Pe,Xt)|0,_=_+Math.imul(Fe,ee)|0,b=b+Math.imul(Fe,Y)|0,b=b+Math.imul(mt,ee)|0,C=C+Math.imul(mt,Y)|0,_=_+Math.imul(xe,ue)|0,b=b+Math.imul(xe,le)|0,b=b+Math.imul(it,ue)|0,C=C+Math.imul(it,le)|0,_=_+Math.imul(he,Me)|0,b=b+Math.imul(he,Ue)|0,b=b+Math.imul(me,Me)|0,C=C+Math.imul(me,Ue)|0;var Li=(E+_|0)+((b&8191)<<13)|0;E=(C+(b>>>13)|0)+(Li>>>26)|0,Li&=67108863,_=Math.imul(Be,Gt),b=Math.imul(Be,Xt),b=b+Math.imul(Ee,Gt)|0,C=Math.imul(Ee,Xt),_=_+Math.imul(ke,ee)|0,b=b+Math.imul(ke,Y)|0,b=b+Math.imul(Pe,ee)|0,C=C+Math.imul(Pe,Y)|0,_=_+Math.imul(Fe,ue)|0,b=b+Math.imul(Fe,le)|0,b=b+Math.imul(mt,ue)|0,C=C+Math.imul(mt,le)|0,_=_+Math.imul(xe,Me)|0,b=b+Math.imul(xe,Ue)|0,b=b+Math.imul(it,Me)|0,C=C+Math.imul(it,Ue)|0;var xo=(E+_|0)+((b&8191)<<13)|0;E=(C+(b>>>13)|0)+(xo>>>26)|0,xo&=67108863,_=Math.imul(Be,ee),b=Math.imul(Be,Y),b=b+Math.imul(Ee,ee)|0,C=Math.imul(Ee,Y),_=_+Math.imul(ke,ue)|0,b=b+Math.imul(ke,le)|0,b=b+Math.imul(Pe,ue)|0,C=C+Math.imul(Pe,le)|0,_=_+Math.imul(Fe,Me)|0,b=b+Math.imul(Fe,Ue)|0,b=b+Math.imul(mt,Me)|0,C=C+Math.imul(mt,Ue)|0;var ma=(E+_|0)+((b&8191)<<13)|0;E=(C+(b>>>13)|0)+(ma>>>26)|0,ma&=67108863,_=Math.imul(Be,ue),b=Math.imul(Be,le),b=b+Math.imul(Ee,ue)|0,C=Math.imul(Ee,le),_=_+Math.imul(ke,Me)|0,b=b+Math.imul(ke,Ue)|0,b=b+Math.imul(Pe,Me)|0,C=C+Math.imul(Pe,Ue)|0;var Qo=(E+_|0)+((b&8191)<<13)|0;E=(C+(b>>>13)|0)+(Qo>>>26)|0,Qo&=67108863,_=Math.imul(Be,Me),b=Math.imul(Be,Ue),b=b+Math.imul(Ee,Me)|0,C=Math.imul(Ee,Ue);var Ac=(E+_|0)+((b&8191)<<13)|0;return E=(C+(b>>>13)|0)+(Ac>>>26)|0,Ac&=67108863,w[0]=Tr,w[1]=Lt,w[2]=ft,w[3]=Zr,w[4]=un,w[5]=Hr,w[6]=ar,w[7]=Yr,w[8]=Br,w[9]=pa,w[10]=Si,w[11]=qi,w[12]=jr,w[13]=Ai,w[14]=Li,w[15]=xo,w[16]=ma,w[17]=Qo,w[18]=Ac,E!==0&&(w[19]=E,B.length++),B};Math.imul||(g=m);function v(L,I,T){T.negative=I.negative^L.negative,T.length=L.length+I.length;for(var B=0,h=0,y=0;y>>26)|0,h+=w>>>26,w&=67108863}T.words[y]=E,B=w,w=h}return B!==0?T.words[y]=B:T.length--,T.strip()}function x(L,I,T){var B=new S;return B.mulp(L,I,T)}i.prototype.mulTo=function(I,T){var B,h=this.length+I.length;return this.length===10&&I.length===10?B=g(this,I,T):h<63?B=m(this,I,T):h<1024?B=v(this,I,T):B=x(this,I,T),B};function S(L,I){this.x=L,this.y=I}S.prototype.makeRBT=function(I){for(var T=new Array(I),B=i.prototype._countBits(I)-1,h=0;h>=1;return h},S.prototype.permute=function(I,T,B,h,y,w){for(var E=0;E>>1)y++;return 1<>>13,B[2*w+1]=y&8191,y=y>>>13;for(w=2*T;w>=26,T+=h/67108864|0,T+=y>>>26,this.words[B]=y&67108863}return T!==0&&(this.words[B]=T,this.length++),this},i.prototype.muln=function(I){return this.clone().imuln(I)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(I){var T=p(I);if(T.length===0)return new i(1);for(var B=this,h=0;h=0);var T=I%26,B=(I-T)/26,h=67108863>>>26-T<<26-T,y;if(T!==0){var w=0;for(y=0;y>>26-T}w&&(this.words[y]=w,this.length++)}if(B!==0){for(y=this.length-1;y>=0;y--)this.words[y+B]=this.words[y];for(y=0;y=0);var h;T?h=(T-T%26)/26:h=0;var y=I%26,w=Math.min((I-y)/26,this.length),E=67108863^67108863>>>y<w)for(this.length-=w,b=0;b=0&&(C!==0||b>=h);b--){var N=this.words[b]|0;this.words[b]=C<<26-y|N>>>y,C=N&E}return _&&C!==0&&(_.words[_.length++]=C),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.ishrn=function(I,T,B){return r(this.negative===0),this.iushrn(I,T,B)},i.prototype.shln=function(I){return this.clone().ishln(I)},i.prototype.ushln=function(I){return this.clone().iushln(I)},i.prototype.shrn=function(I){return this.clone().ishrn(I)},i.prototype.ushrn=function(I){return this.clone().iushrn(I)},i.prototype.testn=function(I){r(typeof I=="number"&&I>=0);var T=I%26,B=(I-T)/26,h=1<=0);var T=I%26,B=(I-T)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=B)return this;if(T!==0&&B++,this.length=Math.min(B,this.length),T!==0){var h=67108863^67108863>>>T<=67108864;T++)this.words[T]-=67108864,T===this.length-1?this.words[T+1]=1:this.words[T+1]++;return this.length=Math.max(this.length,T+1),this},i.prototype.isubn=function(I){if(r(typeof I=="number"),r(I<67108864),I<0)return this.iaddn(-I);if(this.negative!==0)return this.negative=0,this.iaddn(I),this.negative=1,this;if(this.words[0]-=I,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var T=0;T>26)-(_/67108864|0),this.words[y+B]=w&67108863}for(;y>26,this.words[y+B]=w&67108863;if(E===0)return this.strip();for(r(E===-1),E=0,y=0;y>26,this.words[y]=w&67108863;return this.negative=1,this.strip()},i.prototype._wordDiv=function(I,T){var B=this.length-I.length,h=this.clone(),y=I,w=y.words[y.length-1]|0,E=this._countBits(w);B=26-E,B!==0&&(y=y.ushln(B),h.iushln(B),w=y.words[y.length-1]|0);var _=h.length-y.length,b;if(T!=="mod"){b=new i(null),b.length=_+1,b.words=new Array(b.length);for(var C=0;C=0;M--){var U=(h.words[y.length+M]|0)*67108864+(h.words[y.length+M-1]|0);for(U=Math.min(U/w|0,67108863),h._ishlnsubmul(y,U,M);h.negative!==0;)U--,h.negative=0,h._ishlnsubmul(y,1,M),h.isZero()||(h.negative^=1);b&&(b.words[M]=U)}return b&&b.strip(),h.strip(),T!=="div"&&B!==0&&h.iushrn(B),{div:b||null,mod:h}},i.prototype.divmod=function(I,T,B){if(r(!I.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var h,y,w;return this.negative!==0&&I.negative===0?(w=this.neg().divmod(I,T),T!=="mod"&&(h=w.div.neg()),T!=="div"&&(y=w.mod.neg(),B&&y.negative!==0&&y.iadd(I)),{div:h,mod:y}):this.negative===0&&I.negative!==0?(w=this.divmod(I.neg(),T),T!=="mod"&&(h=w.div.neg()),{div:h,mod:w.mod}):this.negative&I.negative?(w=this.neg().divmod(I.neg(),T),T!=="div"&&(y=w.mod.neg(),B&&y.negative!==0&&y.isub(I)),{div:w.div,mod:y}):I.length>this.length||this.cmp(I)<0?{div:new i(0),mod:this}:I.length===1?T==="div"?{div:this.divn(I.words[0]),mod:null}:T==="mod"?{div:null,mod:new i(this.modn(I.words[0]))}:{div:this.divn(I.words[0]),mod:new i(this.modn(I.words[0]))}:this._wordDiv(I,T)},i.prototype.div=function(I){return this.divmod(I,"div",!1).div},i.prototype.mod=function(I){return this.divmod(I,"mod",!1).mod},i.prototype.umod=function(I){return this.divmod(I,"mod",!0).mod},i.prototype.divRound=function(I){var T=this.divmod(I);if(T.mod.isZero())return T.div;var B=T.div.negative!==0?T.mod.isub(I):T.mod,h=I.ushrn(1),y=I.andln(1),w=B.cmp(h);return w<0||y===1&&w===0?T.div:T.div.negative!==0?T.div.isubn(1):T.div.iaddn(1)},i.prototype.modn=function(I){r(I<=67108863);for(var T=(1<<26)%I,B=0,h=this.length-1;h>=0;h--)B=(T*B+(this.words[h]|0))%I;return B},i.prototype.idivn=function(I){r(I<=67108863);for(var T=0,B=this.length-1;B>=0;B--){var h=(this.words[B]|0)+T*67108864;this.words[B]=h/I|0,T=h%I}return this.strip()},i.prototype.divn=function(I){return this.clone().idivn(I)},i.prototype.egcd=function(I){r(I.negative===0),r(!I.isZero());var T=this,B=I.clone();T.negative!==0?T=T.umod(I):T=T.clone();for(var h=new i(1),y=new i(0),w=new i(0),E=new i(1),_=0;T.isEven()&&B.isEven();)T.iushrn(1),B.iushrn(1),++_;for(var b=B.clone(),C=T.clone();!T.isZero();){for(var N=0,M=1;!(T.words[0]&M)&&N<26;++N,M<<=1);if(N>0)for(T.iushrn(N);N-- >0;)(h.isOdd()||y.isOdd())&&(h.iadd(b),y.isub(C)),h.iushrn(1),y.iushrn(1);for(var U=0,G=1;!(B.words[0]&G)&&U<26;++U,G<<=1);if(U>0)for(B.iushrn(U);U-- >0;)(w.isOdd()||E.isOdd())&&(w.iadd(b),E.isub(C)),w.iushrn(1),E.iushrn(1);T.cmp(B)>=0?(T.isub(B),h.isub(w),y.isub(E)):(B.isub(T),w.isub(h),E.isub(y))}return{a:w,b:E,gcd:B.iushln(_)}},i.prototype._invmp=function(I){r(I.negative===0),r(!I.isZero());var T=this,B=I.clone();T.negative!==0?T=T.umod(I):T=T.clone();for(var h=new i(1),y=new i(0),w=B.clone();T.cmpn(1)>0&&B.cmpn(1)>0;){for(var E=0,_=1;!(T.words[0]&_)&&E<26;++E,_<<=1);if(E>0)for(T.iushrn(E);E-- >0;)h.isOdd()&&h.iadd(w),h.iushrn(1);for(var b=0,C=1;!(B.words[0]&C)&&b<26;++b,C<<=1);if(b>0)for(B.iushrn(b);b-- >0;)y.isOdd()&&y.iadd(w),y.iushrn(1);T.cmp(B)>=0?(T.isub(B),h.isub(y)):(B.isub(T),y.isub(h))}var N;return T.cmpn(1)===0?N=h:N=y,N.cmpn(0)<0&&N.iadd(I),N},i.prototype.gcd=function(I){if(this.isZero())return I.abs();if(I.isZero())return this.abs();var T=this.clone(),B=I.clone();T.negative=0,B.negative=0;for(var h=0;T.isEven()&&B.isEven();h++)T.iushrn(1),B.iushrn(1);do{for(;T.isEven();)T.iushrn(1);for(;B.isEven();)B.iushrn(1);var y=T.cmp(B);if(y<0){var w=T;T=B,B=w}else if(y===0||B.cmpn(1)===0)break;T.isub(B)}while(!0);return B.iushln(h)},i.prototype.invm=function(I){return this.egcd(I).a.umod(I)},i.prototype.isEven=function(){return(this.words[0]&1)===0},i.prototype.isOdd=function(){return(this.words[0]&1)===1},i.prototype.andln=function(I){return this.words[0]&I},i.prototype.bincn=function(I){r(typeof I=="number");var T=I%26,B=(I-T)/26,h=1<>>26,E&=67108863,this.words[w]=E}return y!==0&&(this.words[w]=y,this.length++),this},i.prototype.isZero=function(){return this.length===1&&this.words[0]===0},i.prototype.cmpn=function(I){var T=I<0;if(this.negative!==0&&!T)return-1;if(this.negative===0&&T)return 1;this.strip();var B;if(this.length>1)B=1;else{T&&(I=-I),r(I<=67108863,"Number is too big");var h=this.words[0]|0;B=h===I?0:hI.length)return 1;if(this.length=0;B--){var h=this.words[B]|0,y=I.words[B]|0;if(h!==y){hy&&(T=1);break}}return T},i.prototype.gtn=function(I){return this.cmpn(I)===1},i.prototype.gt=function(I){return this.cmp(I)===1},i.prototype.gten=function(I){return this.cmpn(I)>=0},i.prototype.gte=function(I){return this.cmp(I)>=0},i.prototype.ltn=function(I){return this.cmpn(I)===-1},i.prototype.lt=function(I){return this.cmp(I)===-1},i.prototype.lten=function(I){return this.cmpn(I)<=0},i.prototype.lte=function(I){return this.cmp(I)<=0},i.prototype.eqn=function(I){return this.cmpn(I)===0},i.prototype.eq=function(I){return this.cmp(I)===0},i.red=function(I){return new K(I)},i.prototype.toRed=function(I){return r(!this.red,"Already a number in reduction context"),r(this.negative===0,"red works only with positives"),I.convertTo(this)._forceRed(I)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(I){return this.red=I,this},i.prototype.forceRed=function(I){return r(!this.red,"Already a number in reduction context"),this._forceRed(I)},i.prototype.redAdd=function(I){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,I)},i.prototype.redIAdd=function(I){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,I)},i.prototype.redSub=function(I){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,I)},i.prototype.redISub=function(I){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,I)},i.prototype.redShl=function(I){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,I)},i.prototype.redMul=function(I){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,I),this.red.mul(this,I)},i.prototype.redIMul=function(I){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,I),this.red.imul(this,I)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(I){return r(this.red&&!I.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,I)};var P={k256:null,p224:null,p192:null,p25519:null};function A(L,I){this.name=L,this.p=new i(I,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}A.prototype._tmp=function(){var I=new i(null);return I.words=new Array(Math.ceil(this.n/13)),I},A.prototype.ireduce=function(I){var T=I,B;do this.split(T,this.tmp),T=this.imulK(T),T=T.iadd(this.tmp),B=T.bitLength();while(B>this.n);var h=B0?T.isub(this.p):T.strip!==void 0?T.strip():T._strip(),T},A.prototype.split=function(I,T){I.iushrn(this.n,0,T)},A.prototype.imulK=function(I){return I.imul(this.k)};function $(){A.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n($,A),$.prototype.split=function(I,T){for(var B=4194303,h=Math.min(I.length,9),y=0;y>>22,w=E}w>>>=22,I.words[y-10]=w,w===0&&I.length>10?I.length-=10:I.length-=9},$.prototype.imulK=function(I){I.words[I.length]=0,I.words[I.length+1]=0,I.length+=2;for(var T=0,B=0;B>>=26,I.words[B]=y,T=h}return T!==0&&(I.words[I.length++]=T),I},i._prime=function(I){if(P[I])return P[I];var T;if(I==="k256")T=new $;else if(I==="p224")T=new j;else if(I==="p192")T=new q;else if(I==="p25519")T=new F;else throw new Error("Unknown prime "+I);return P[I]=T,T};function K(L){if(typeof L=="string"){var I=i._prime(L);this.m=I.p,this.prime=I}else r(L.gtn(1),"modulus must be greater than 1"),this.m=L,this.prime=null}K.prototype._verify1=function(I){r(I.negative===0,"red works only with positives"),r(I.red,"red works only with red numbers")},K.prototype._verify2=function(I,T){r((I.negative|T.negative)===0,"red works only with positives"),r(I.red&&I.red===T.red,"red works only with red numbers")},K.prototype.imod=function(I){return this.prime?this.prime.ireduce(I)._forceRed(this):I.umod(this.m)._forceRed(this)},K.prototype.neg=function(I){return I.isZero()?I.clone():this.m.sub(I)._forceRed(this)},K.prototype.add=function(I,T){this._verify2(I,T);var B=I.add(T);return B.cmp(this.m)>=0&&B.isub(this.m),B._forceRed(this)},K.prototype.iadd=function(I,T){this._verify2(I,T);var B=I.iadd(T);return B.cmp(this.m)>=0&&B.isub(this.m),B},K.prototype.sub=function(I,T){this._verify2(I,T);var B=I.sub(T);return B.cmpn(0)<0&&B.iadd(this.m),B._forceRed(this)},K.prototype.isub=function(I,T){this._verify2(I,T);var B=I.isub(T);return B.cmpn(0)<0&&B.iadd(this.m),B},K.prototype.shl=function(I,T){return this._verify1(I),this.imod(I.ushln(T))},K.prototype.imul=function(I,T){return this._verify2(I,T),this.imod(I.imul(T))},K.prototype.mul=function(I,T){return this._verify2(I,T),this.imod(I.mul(T))},K.prototype.isqr=function(I){return this.imul(I,I.clone())},K.prototype.sqr=function(I){return this.mul(I,I)},K.prototype.sqrt=function(I){if(I.isZero())return I.clone();var T=this.m.andln(3);if(r(T%2===1),T===3){var B=this.m.add(new i(1)).iushrn(2);return this.pow(I,B)}for(var h=this.m.subn(1),y=0;!h.isZero()&&h.andln(1)===0;)y++,h.iushrn(1);r(!h.isZero());var w=new i(1).toRed(this),E=w.redNeg(),_=this.m.subn(1).iushrn(1),b=this.m.bitLength();for(b=new i(2*b*b).toRed(this);this.pow(b,_).cmp(E)!==0;)b.redIAdd(E);for(var C=this.pow(b,h),N=this.pow(I,h.addn(1).iushrn(1)),M=this.pow(I,h),U=y;M.cmp(w)!==0;){for(var G=M,Z=0;G.cmp(w)!==0;Z++)G=G.redSqr();r(Z=0;y--){for(var C=T.words[y],N=b-1;N>=0;N--){var M=C>>N&1;if(w!==h[0]&&(w=this.sqr(w)),M===0&&E===0){_=0;continue}E<<=1,E|=M,_++,!(_!==B&&(y!==0||N!==0))&&(w=this.mul(w,h[E]),_=0,E=0)}b=26}return w},K.prototype.convertTo=function(I){var T=I.umod(this.m);return T===I?T.clone():T},K.prototype.convertFrom=function(I){var T=I.clone();return T.red=null,T},i.mont=function(I){return new W(I)};function W(L){K.call(this,L),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}n(W,K),W.prototype.convertTo=function(I){return this.imod(I.ushln(this.shift))},W.prototype.convertFrom=function(I){var T=this.imod(I.mul(this.rinv));return T.red=null,T},W.prototype.imul=function(I,T){if(I.isZero()||T.isZero())return I.words[0]=0,I.length=1,I;var B=I.imul(T),h=B.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),y=B.isub(h).iushrn(this.shift),w=y;return y.cmp(this.m)>=0?w=y.isub(this.m):y.cmpn(0)<0&&(w=y.iadd(this.m)),w._forceRed(this)},W.prototype.mul=function(I,T){if(I.isZero()||T.isZero())return new i(0)._forceRed(this);var B=I.mul(T),h=B.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),y=B.isub(h).iushrn(this.shift),w=y;return y.cmp(this.m)>=0?w=y.isub(this.m):y.cmpn(0)<0&&(w=y.iadd(this.m)),w._forceRed(this)},W.prototype.invm=function(I){var T=this.imod(I._invmp(this.m).mul(this.r2));return T._forceRed(this)}})(typeof NM>"u"||NM,nee)});var UA=V((avt,LM)=>{f();var UM;LM.exports=function(e){return UM||(UM=new _m(null)),UM.generate(e)};function _m(t){this.rand=t}LM.exports.Rand=_m;_m.prototype.generate=function(e){return this._rand(e)};_m.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var r=new Uint8Array(e),n=0;n{f();var mg=Mo(),IPe=UA();function yg(t){this.rand=t||new IPe.Rand}iee.exports=yg;yg.create=function(e){return new yg(e)};yg.prototype._randbelow=function(e){var r=e.bitLength(),n=Math.ceil(r/8);do var i=new mg(this.rand.generate(n));while(i.cmp(e)>=0);return i};yg.prototype._randrange=function(e,r){var n=r.sub(e);return e.add(this._randbelow(n))};yg.prototype.test=function(e,r,n){var i=e.bitLength(),o=mg.mont(e),s=new mg(1).toRed(o);r||(r=Math.max(1,i/48|0));for(var a=e.subn(1),d=0;!a.testn(d);d++);for(var u=e.shrn(d),c=a.toRed(o),l=!0;r>0;r--){var p=this._randrange(new mg(2),a);n&&n(p);var m=p.toRed(o).redPow(u);if(!(m.cmp(s)===0||m.cmp(c)===0)){for(var g=1;g0;r--){var c=this._randrange(new mg(2),s),l=e.gcd(c);if(l.cmpn(1)!==0)return l;var p=c.toRed(i).redPow(d);if(!(p.cmp(o)===0||p.cmp(u)===0)){for(var m=1;m{f();var kPe=tg();aee.exports=VM;VM.simpleSieve=WM;VM.fermatTest=HM;var is=Mo(),RPe=new is(24),DPe=KM(),oee=new DPe,BPe=new is(1),zM=new is(2),MPe=new is(5),lvt=new is(16),fvt=new is(8),OPe=new is(10),CPe=new is(3),hvt=new is(7),$Pe=new is(11),see=new is(4),pvt=new is(12),FM=null;function jPe(){if(FM!==null)return FM;var t=1048576,e=[];e[0]=2;for(var r=1,n=3;nt;)r.ishrn(1);if(r.isEven()&&r.iadd(BPe),r.testn(1)||r.iadd(zM),e.cmp(zM)){if(!e.cmp(MPe))for(;r.mod(OPe).cmp(CPe);)r.iadd(see)}else for(;r.mod(RPe).cmp($Pe);)r.iadd(see);if(n=r.shrn(1),WM(n)&&WM(r)&&HM(n)&&HM(r)&&oee.test(n)&&oee.test(r))return r}}});var cee=V((gvt,NPe)=>{NPe.exports={modp1:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},modp2:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},modp5:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},modp14:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},modp15:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},modp16:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},modp17:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},modp18:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}});var fee=V((vvt,lee)=>{f();var kd=Mo(),UPe=KM(),dee=new UPe,qPe=new kd(24),LPe=new kd(11),KPe=new kd(10),FPe=new kd(3),zPe=new kd(7),uee=GM(),WPe=tg();lee.exports=gh;function HPe(t,e){return e=e||"utf8",O.Buffer.isBuffer(t)||(t=new O.Buffer(t,e)),this._pub=new kd(t),this}function VPe(t,e){return e=e||"utf8",O.Buffer.isBuffer(t)||(t=new O.Buffer(t,e)),this._priv=new kd(t),this}var LA={};function GPe(t,e){var r=e.toString("hex"),n=[r,t.toString(16)].join("_");if(n in LA)return LA[n];var i=0;if(t.isEven()||!uee.simpleSieve||!uee.fermatTest(t)||!dee.test(t))return i+=1,r==="02"||r==="05"?i+=8:i+=4,LA[n]=i,i;dee.test(t.shrn(1))||(i+=2);var o;switch(r){case"02":t.mod(qPe).cmp(LPe)&&(i+=8);break;case"05":o=t.mod(KPe),o.cmp(FPe)&&o.cmp(zPe)&&(i+=8);break;default:i+=4}return LA[n]=i,i}function gh(t,e,r){this.setGenerator(e),this.__prime=new kd(t),this._prime=kd.mont(this.__prime),this._primeLen=t.length,this._pub=void 0,this._priv=void 0,this._primeCode=void 0,r?(this.setPublicKey=HPe,this.setPrivateKey=VPe):this._primeCode=8}Object.defineProperty(gh.prototype,"verifyError",{enumerable:!0,get:function(){return typeof this._primeCode!="number"&&(this._primeCode=GPe(this.__prime,this.__gen)),this._primeCode}});gh.prototype.generateKeys=function(){return this._priv||(this._priv=new kd(WPe(this._primeLen))),this._pub=this._gen.toRed(this._prime).redPow(this._priv).fromRed(),this.getPublicKey()};gh.prototype.computeSecret=function(t){t=new kd(t),t=t.toRed(this._prime);var e=t.redPow(this._priv).fromRed(),r=new O.Buffer(e.toArray()),n=this.getPrime();if(r.length{f();var JPe=GM(),hee=cee(),JM=fee();function ZPe(t){var e=new O.Buffer(hee[t].prime,"hex"),r=new O.Buffer(hee[t].gen,"hex");return new JM(e,r)}var YPe={binary:!0,hex:!0,base64:!0};function pee(t,e,r,n){return O.Buffer.isBuffer(e)||YPe[e]===void 0?pee(t,"binary",e,r):(e=e||"binary",n=n||"binary",r=r||new O.Buffer([2]),O.Buffer.isBuffer(r)||(r=new O.Buffer(r,n)),typeof t=="number"?new JM(JPe(t,r),r,!0):(O.Buffer.isBuffer(t)||(t=new O.Buffer(t,e)),new JM(t,r,!0)))}Uw.DiffieHellmanGroup=Uw.createDiffieHellmanGroup=Uw.getDiffieHellman=ZPe;Uw.createDiffieHellman=Uw.DiffieHellman=pee});var yE=V((xvt,ZM)=>{"use strict";f();typeof k.default>"u"||!k.default.version||k.default.version.indexOf("v0.")===0||k.default.version.indexOf("v1.")===0&&k.default.version.indexOf("v1.8.")!==0?ZM.exports={nextTick:XPe}:ZM.exports=k.default;function XPe(t,e,r,n){if(typeof t!="function")throw new TypeError('"callback" argument must be a function');var i=arguments.length,o,s;switch(i){case 0:case 1:return k.default.nextTick(t);case 2:return k.default.nextTick(function(){t.call(null,e)});case 3:return k.default.nextTick(function(){t.call(null,e,r)});case 4:return k.default.nextTick(function(){t.call(null,e,r,n)});default:for(o=new Array(i-1),s=0;s{f();var QPe={}.toString;yee.exports=Array.isArray||function(t){return QPe.call(t)=="[object Array]"}});var YM=V((Tvt,vee)=>{f();vee.exports=Aa().EventEmitter});var gE=V((XM,wee)=>{f();var FA=pn(),vh=FA.Buffer;function bee(t,e){for(var r in t)e[r]=t[r]}vh.from&&vh.alloc&&vh.allocUnsafe&&vh.allocUnsafeSlow?wee.exports=FA:(bee(FA,XM),XM.Buffer=qw);function qw(t,e,r){return vh(t,e,r)}bee(vh,qw);qw.from=function(t,e,r){if(typeof t=="number")throw new TypeError("Argument must not be a number");return vh(t,e,r)};qw.alloc=function(t,e,r){if(typeof t!="number")throw new TypeError("Argument must be a number");var n=vh(t);return e!==void 0?typeof r=="string"?n.fill(e,r):n.fill(e):n.fill(0),n};qw.allocUnsafe=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return vh(t)};qw.allocUnsafeSlow=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return FA.SlowBuffer(t)}});var Lw=V(Zs=>{f();function eIe(t){return Array.isArray?Array.isArray(t):zA(t)==="[object Array]"}Zs.isArray=eIe;function tIe(t){return typeof t=="boolean"}Zs.isBoolean=tIe;function rIe(t){return t===null}Zs.isNull=rIe;function nIe(t){return t==null}Zs.isNullOrUndefined=nIe;function iIe(t){return typeof t=="number"}Zs.isNumber=iIe;function oIe(t){return typeof t=="string"}Zs.isString=oIe;function sIe(t){return typeof t=="symbol"}Zs.isSymbol=sIe;function aIe(t){return t===void 0}Zs.isUndefined=aIe;function cIe(t){return zA(t)==="[object RegExp]"}Zs.isRegExp=cIe;function dIe(t){return typeof t=="object"&&t!==null}Zs.isObject=dIe;function uIe(t){return zA(t)==="[object Date]"}Zs.isDate=uIe;function lIe(t){return zA(t)==="[object Error]"||t instanceof Error}Zs.isError=lIe;function fIe(t){return typeof t=="function"}Zs.isFunction=fIe;function hIe(t){return t===null||typeof t=="boolean"||typeof t=="number"||typeof t=="string"||typeof t=="symbol"||typeof t>"u"}Zs.isPrimitive=hIe;Zs.isBuffer=pn().Buffer.isBuffer;function zA(t){return Object.prototype.toString.call(t)}});var xee=V((Dvt,QM)=>{"use strict";f();function pIe(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var _ee=gE().Buffer,vE=Lx();function mIe(t,e,r){t.copy(e,r)}QM.exports=function(){function t(){pIe(this,t),this.head=null,this.tail=null,this.length=0}return t.prototype.push=function(r){var n={data:r,next:null};this.length>0?this.tail.next=n:this.head=n,this.tail=n,++this.length},t.prototype.unshift=function(r){var n={data:r,next:this.head};this.length===0&&(this.tail=n),this.head=n,++this.length},t.prototype.shift=function(){if(this.length!==0){var r=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,r}},t.prototype.clear=function(){this.head=this.tail=null,this.length=0},t.prototype.join=function(r){if(this.length===0)return"";for(var n=this.head,i=""+n.data;n=n.next;)i+=r+n.data;return i},t.prototype.concat=function(r){if(this.length===0)return _ee.alloc(0);for(var n=_ee.allocUnsafe(r>>>0),i=this.head,o=0;i;)mIe(i.data,n,o),o+=i.data.length,i=i.next;return n},t}();vE&&vE.inspect&&vE.inspect.custom&&(QM.exports.prototype[vE.inspect.custom]=function(){var t=vE.inspect({length:this.length});return this.constructor.name+" "+t})});var eO=V((Mvt,Eee)=>{"use strict";f();var WA=yE();function yIe(t,e){var r=this,n=this._readableState&&this._readableState.destroyed,i=this._writableState&&this._writableState.destroyed;return n||i?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,WA.nextTick(HA,this,t)):WA.nextTick(HA,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(o){!e&&o?r._writableState?r._writableState.errorEmitted||(r._writableState.errorEmitted=!0,WA.nextTick(HA,r,o)):WA.nextTick(HA,r,o):e&&e(o)}),this)}function gIe(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function HA(t,e){t.emit("error",e)}Eee.exports={destroy:yIe,undestroy:gIe}});var rO=V((Cvt,Dee)=>{"use strict";f();var gg=yE();Dee.exports=Vi;function Aee(t){var e=this;this.next=null,this.entry=null,this.finish=function(){CIe(e,t)}}var vIe=!k.default.browser&&["v0.10","v0.9."].indexOf(k.default.version.slice(0,5))>-1?setImmediate:gg.nextTick,Kw;Vi.WritableState=wE;var Tee=Object.create(Lw());Tee.inherits=Ft();var bIe={deprecate:M7()},Pee=YM(),GA=gE().Buffer,wIe=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function _Ie(t){return GA.from(t)}function xIe(t){return GA.isBuffer(t)||t instanceof wIe}var Iee=eO();Tee.inherits(Vi,Pee);function EIe(){}function wE(t,e){Kw=Kw||vg(),t=t||{};var r=e instanceof Kw;this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.writableObjectMode);var n=t.highWaterMark,i=t.writableHighWaterMark,o=this.objectMode?16:16*1024;n||n===0?this.highWaterMark=n:r&&(i||i===0)?this.highWaterMark=i:this.highWaterMark=o,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=t.decodeStrings===!1;this.decodeStrings=!s,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(a){RIe(e,a)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new Aee(this)}wE.prototype.getBuffer=function(){for(var e=this.bufferedRequest,r=[];e;)r.push(e),e=e.next;return r};(function(){try{Object.defineProperty(wE.prototype,"buffer",{get:bIe.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var VA;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(VA=Function.prototype[Symbol.hasInstance],Object.defineProperty(Vi,Symbol.hasInstance,{value:function(t){return VA.call(this,t)?!0:this!==Vi?!1:t&&t._writableState instanceof wE}})):VA=function(t){return t instanceof this};function Vi(t){if(Kw=Kw||vg(),!VA.call(Vi,this)&&!(this instanceof Kw))return new Vi(t);this._writableState=new wE(t,this),this.writable=!0,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)),Pee.call(this)}Vi.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))};function SIe(t,e){var r=new Error("write after end");t.emit("error",r),gg.nextTick(e,r)}function AIe(t,e,r,n){var i=!0,o=!1;return r===null?o=new TypeError("May not write null values to stream"):typeof r!="string"&&r!==void 0&&!e.objectMode&&(o=new TypeError("Invalid non-string/buffer chunk")),o&&(t.emit("error",o),gg.nextTick(n,o),i=!1),i}Vi.prototype.write=function(t,e,r){var n=this._writableState,i=!1,o=!n.objectMode&&xIe(t);return o&&!GA.isBuffer(t)&&(t=_Ie(t)),typeof e=="function"&&(r=e,e=null),o?e="buffer":e||(e=n.defaultEncoding),typeof r!="function"&&(r=EIe),n.ended?SIe(this,r):(o||AIe(this,n,t,r))&&(n.pendingcb++,i=PIe(this,n,o,t,e,r)),i};Vi.prototype.cork=function(){var t=this._writableState;t.corked++};Vi.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,!t.writing&&!t.corked&&!t.bufferProcessing&&t.bufferedRequest&&kee(this,t))};Vi.prototype.setDefaultEncoding=function(e){if(typeof e=="string"&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this};function TIe(t,e,r){return!t.objectMode&&t.decodeStrings!==!1&&typeof e=="string"&&(e=GA.from(e,r)),e}Object.defineProperty(Vi.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function PIe(t,e,r,n,i,o){if(!r){var s=TIe(e,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=e.objectMode?1:n.length;e.length+=a;var d=e.length{"use strict";f();var Bee=yE(),$Ie=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};Cee.exports=bh;var Mee=Object.create(Lw());Mee.inherits=Ft();var Oee=oO(),iO=rO();Mee.inherits(bh,Oee);for(nO=$Ie(iO.prototype),JA=0;JA{"use strict";f();var aO=gE().Buffer,$ee=aO.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 UIe(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 qIe(t){var e=UIe(t);if(typeof e!="string"&&(aO.isEncoding===$ee||!$ee(t)))throw new Error("Unknown encoding: "+t);return e||t}jee.StringDecoder=_E;function _E(t){this.encoding=qIe(t);var e;switch(this.encoding){case"utf16le":this.text=HIe,this.end=VIe,e=4;break;case"utf8":this.fillLast=FIe,e=4;break;case"base64":this.text=GIe,this.end=JIe,e=3;break;default:this.write=ZIe,this.end=YIe;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=aO.allocUnsafe(e)}_E.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>5===6?2:t>>4===14?3:t>>3===30?4:t>>6===2?-1:-2}function LIe(t,e,r){var n=e.length-1;if(n=0?(i>0&&(t.lastNeed=i-1),i):--n=0?(i>0&&(t.lastNeed=i-2),i):--n=0?(i>0&&(i===2?i=0:t.lastNeed=i-3),i):0))}function KIe(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 FIe(t){var e=this.lastTotal-this.lastNeed,r=KIe(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 zIe(t,e){var r=LIe(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 WIe(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"\uFFFD":e}function HIe(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 VIe(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 GIe(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 JIe(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function ZIe(t){return t.toString(this.encoding)}function YIe(t){return t&&t.length?this.write(t):""}});var oO=V((Kvt,Jee)=>{"use strict";f();var zw=yE();Jee.exports=Ln;var XIe=gee(),xE;Ln.ReadableState=zee;var Lvt=Aa().EventEmitter,Lee=function(t,e){return t.listeners(e).length},hO=YM(),EE=gE().Buffer,QIe=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function eke(t){return EE.from(t)}function tke(t){return EE.isBuffer(t)||t instanceof QIe}var Kee=Object.create(Lw());Kee.inherits=Ft();var dO=Lx(),Xr=void 0;dO&&dO.debuglog?Xr=dO.debuglog("stream"):Xr=function(){};var rke=xee(),Fee=eO(),Fw;Kee.inherits(Ln,hO);var uO=["error","close","destroy","pause","resume"];function nke(t,e,r){if(typeof t.prependListener=="function")return t.prependListener(e,r);!t._events||!t._events[e]?t.on(e,r):XIe(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]}function zee(t,e){xE=xE||vg(),t=t||{};var r=e instanceof xE;this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode);var n=t.highWaterMark,i=t.readableHighWaterMark,o=this.objectMode?16:16*1024;n||n===0?this.highWaterMark=n:r&&(i||i===0)?this.highWaterMark=i:this.highWaterMark=o,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new rke,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(Fw||(Fw=cO().StringDecoder),this.decoder=new Fw(t.encoding),this.encoding=t.encoding)}function Ln(t){if(xE=xE||vg(),!(this instanceof Ln))return new Ln(t);this._readableState=new zee(t,this),this.readable=!0,t&&(typeof t.read=="function"&&(this._read=t.read),typeof t.destroy=="function"&&(this._destroy=t.destroy)),hO.call(this)}Object.defineProperty(Ln.prototype,"destroyed",{get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}});Ln.prototype.destroy=Fee.destroy;Ln.prototype._undestroy=Fee.undestroy;Ln.prototype._destroy=function(t,e){this.push(null),e(t)};Ln.prototype.push=function(t,e){var r=this._readableState,n;return r.objectMode?n=!0:typeof t=="string"&&(e=e||r.defaultEncoding,e!==r.encoding&&(t=EE.from(t,e),e=""),n=!0),Wee(this,t,e,!1,n)};Ln.prototype.unshift=function(t){return Wee(this,t,null,!0,!1)};function Wee(t,e,r,n,i){var o=t._readableState;if(e===null)o.reading=!1,ake(t,o);else{var s;i||(s=ike(o,e)),s?t.emit("error",s):o.objectMode||e&&e.length>0?(typeof e!="string"&&!o.objectMode&&Object.getPrototypeOf(e)!==EE.prototype&&(e=eke(e)),n?o.endEmitted?t.emit("error",new Error("stream.unshift() after end event")):lO(t,o,e,!0):o.ended?t.emit("error",new Error("stream.push() after EOF")):(o.reading=!1,o.decoder&&!r?(e=o.decoder.write(e),o.objectMode||e.length!==0?lO(t,o,e,!1):Hee(t,o)):lO(t,o,e,!1))):n||(o.reading=!1)}return oke(o)}function lO(t,e,r,n){e.flowing&&e.length===0&&!e.sync?(t.emit("data",r),t.read(0)):(e.length+=e.objectMode?1:r.length,n?e.buffer.unshift(r):e.buffer.push(r),e.needReadable&&YA(t)),Hee(t,e)}function ike(t,e){var r;return!tke(e)&&typeof e!="string"&&e!==void 0&&!t.objectMode&&(r=new TypeError("Invalid non-string/buffer chunk")),r}function oke(t){return!t.ended&&(t.needReadable||t.length=Nee?t=Nee:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}function Uee(t,e){return t<=0||e.length===0&&e.ended?0:e.objectMode?1:t!==t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=ske(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}Ln.prototype.read=function(t){Xr("read",t),t=parseInt(t,10);var e=this._readableState,r=t;if(t!==0&&(e.emittedReadable=!1),t===0&&e.needReadable&&(e.length>=e.highWaterMark||e.ended))return Xr("read: emitReadable",e.length,e.ended),e.length===0&&e.ended?fO(this):YA(this),null;if(t=Uee(t,e),t===0&&e.ended)return e.length===0&&fO(this),null;var n=e.needReadable;Xr("need readable",n),(e.length===0||e.length-t0?i=Vee(t,e):i=null,i===null?(e.needReadable=!0,t=0):e.length-=t,e.length===0&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&fO(this)),i!==null&&this.emit("data",i),i};function ake(t,e){if(!e.ended){if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,YA(t)}}function YA(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(Xr("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?zw.nextTick(qee,t):qee(t))}function qee(t){Xr("emit readable"),t.emit("readable"),pO(t)}function Hee(t,e){e.readingMore||(e.readingMore=!0,zw.nextTick(cke,t,e))}function cke(t,e){for(var r=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length1&&Gee(n.pipes,t)!==-1)&&!u&&(Xr("false write response, pause",n.awaitDrain),n.awaitDrain++,l=!0),r.pause())}function m(S){Xr("onerror",S),x(),t.removeListener("error",m),Lee(t,"error")===0&&t.emit("error",S)}nke(t,"error",m);function g(){t.removeListener("finish",v),x()}t.once("close",g);function v(){Xr("onfinish"),t.removeListener("close",g),x()}t.once("finish",v);function x(){Xr("unpipe"),r.unpipe(t)}return t.emit("pipe",r),n.flowing||(Xr("pipe resume"),r.resume()),t};function dke(t){return function(){var e=t._readableState;Xr("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,e.awaitDrain===0&&Lee(t,"data")&&(e.flowing=!0,pO(t))}}Ln.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(e.pipesCount===0)return this;if(e.pipesCount===1)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r),this);if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o=e.length?(e.decoder?r=e.buffer.join(""):e.buffer.length===1?r=e.buffer.head.data:r=e.buffer.concat(e.length),e.buffer.clear()):r=hke(t,e.buffer,e.decoder),r}function hke(t,e,r){var n;return to.length?o.length:t;if(s===o.length?i+=o:i+=o.slice(0,t),t-=s,t===0){s===o.length?(++n,r.next?e.head=r.next:e.head=e.tail=null):(e.head=r,r.data=o.slice(s));break}++n}return e.length-=n,i}function mke(t,e){var r=EE.allocUnsafe(t),n=e.head,i=1;for(n.data.copy(r),t-=n.data.length;n=n.next;){var o=n.data,s=t>o.length?o.length:t;if(o.copy(r,r.length-t,0,s),t-=s,t===0){s===o.length?(++i,n.next?e.head=n.next:e.head=e.tail=null):(e.head=n,n.data=o.slice(s));break}++i}return e.length-=i,r}function fO(t){var e=t._readableState;if(e.length>0)throw new Error('"endReadable()" called on non-empty stream');e.endEmitted||(e.ended=!0,zw.nextTick(yke,e,t))}function yke(t,e){!t.endEmitted&&t.length===0&&(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function Gee(t,e){for(var r=0,n=t.length;r{"use strict";f();Xee.exports=wh;var XA=vg(),Yee=Object.create(Lw());Yee.inherits=Ft();Yee.inherits(wh,XA);function gke(t,e){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(!n)return this.emit("error",new Error("write callback called multiple times"));r.writechunk=null,r.writecb=null,e!=null&&this.push(e),n(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length{"use strict";f();tte.exports=SE;var Qee=mO(),ete=Object.create(Lw());ete.inherits=Ft();ete.inherits(SE,Qee);function SE(t){if(!(this instanceof SE))return new SE(t);Qee.call(this,t)}SE.prototype._transform=function(t,e,r){r(null,t)}});var ite=V(($l,nte)=>{f();$l=nte.exports=oO();$l.Stream=$l;$l.Readable=$l;$l.Writable=rO();$l.Duplex=vg();$l.Transform=mO();$l.PassThrough=rte()});var QA=V((ote,yO)=>{f();(function(t,e){"use strict";function r(B,h){if(!B)throw new Error(h||"Assertion failed")}function n(B,h){B.super_=h;var y=function(){};y.prototype=h.prototype,B.prototype=new y,B.prototype.constructor=B}function i(B,h,y){if(i.isBN(B))return B;this.negative=0,this.words=null,this.length=0,this.red=null,B!==null&&((h==="le"||h==="be")&&(y=h,h=10),this._init(B||0,h||10,y||"be"))}typeof t=="object"?t.exports=i:e.BN=i,i.BN=i,i.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=jM().Buffer}catch{}i.isBN=function(h){return h instanceof i?!0:h!==null&&typeof h=="object"&&h.constructor.wordSize===i.wordSize&&Array.isArray(h.words)},i.max=function(h,y){return h.cmp(y)>0?h:y},i.min=function(h,y){return h.cmp(y)<0?h:y},i.prototype._init=function(h,y,w){if(typeof h=="number")return this._initNumber(h,y,w);if(typeof h=="object")return this._initArray(h,y,w);y==="hex"&&(y=16),r(y===(y|0)&&y>=2&&y<=36),h=h.toString().replace(/\s+/g,"");var E=0;h[0]==="-"&&(E++,this.negative=1),E=0;E-=3)b=h[E]|h[E-1]<<8|h[E-2]<<16,this.words[_]|=b<>>26-C&67108863,C+=24,C>=26&&(C-=26,_++);else if(w==="le")for(E=0,_=0;E>>26-C&67108863,C+=24,C>=26&&(C-=26,_++);return this._strip()};function s(B,h){var y=B.charCodeAt(h);if(y>=48&&y<=57)return y-48;if(y>=65&&y<=70)return y-55;if(y>=97&&y<=102)return y-87;r(!1,"Invalid character in "+B)}function a(B,h,y){var w=s(B,y);return y-1>=h&&(w|=s(B,y-1)<<4),w}i.prototype._parseHex=function(h,y,w){this.length=Math.ceil((h.length-y)/6),this.words=new Array(this.length);for(var E=0;E=y;E-=2)C=a(h,y,E)<<_,this.words[b]|=C&67108863,_>=18?(_-=18,b+=1,this.words[b]|=C>>>26):_+=8;else{var N=h.length-y;for(E=N%2===0?y+1:y;E=18?(_-=18,b+=1,this.words[b]|=C>>>26):_+=8}this._strip()};function d(B,h,y,w){for(var E=0,_=0,b=Math.min(B.length,y),C=h;C=49?_=N-49+10:N>=17?_=N-17+10:_=N,r(N>=0&&_1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},i.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{i.prototype[Symbol.for("nodejs.util.inspect.custom")]=c}catch{i.prototype.inspect=c}else i.prototype.inspect=c;function c(){return(this.red?""}var l=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],p=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],m=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];i.prototype.toString=function(h,y){h=h||10,y=y|0||1;var w;if(h===16||h==="hex"){w="";for(var E=0,_=0,b=0;b>>24-E&16777215,E+=2,E>=26&&(E-=26,b--),_!==0||b!==this.length-1?w=l[6-N.length]+N+w:w=N+w}for(_!==0&&(w=_.toString(16)+w);w.length%y!==0;)w="0"+w;return this.negative!==0&&(w="-"+w),w}if(h===(h|0)&&h>=2&&h<=36){var M=p[h],U=m[h];w="";var G=this.clone();for(G.negative=0;!G.isZero();){var Z=G.modrn(U).toString(h);G=G.idivn(U),G.isZero()?w=Z+w:w=l[M-Z.length]+Z+w}for(this.isZero()&&(w="0"+w);w.length%y!==0;)w="0"+w;return this.negative!==0&&(w="-"+w),w}r(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var h=this.words[0];return this.length===2?h+=this.words[1]*67108864:this.length===3&&this.words[2]===1?h+=4503599627370496+this.words[1]*67108864:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-h:h},i.prototype.toJSON=function(){return this.toString(16,2)},o&&(i.prototype.toBuffer=function(h,y){return this.toArrayLike(o,h,y)}),i.prototype.toArray=function(h,y){return this.toArrayLike(Array,h,y)};var g=function(h,y){return h.allocUnsafe?h.allocUnsafe(y):new h(y)};i.prototype.toArrayLike=function(h,y,w){this._strip();var E=this.byteLength(),_=w||Math.max(1,E);r(E<=_,"byte array longer than desired length"),r(_>0,"Requested array length <= 0");var b=g(h,_),C=y==="le"?"LE":"BE";return this["_toArrayLike"+C](b,E),b},i.prototype._toArrayLikeLE=function(h,y){for(var w=0,E=0,_=0,b=0;_>8&255),w>16&255),b===6?(w>24&255),E=0,b=0):(E=C>>>24,b+=2)}if(w=0&&(h[w--]=C>>8&255),w>=0&&(h[w--]=C>>16&255),b===6?(w>=0&&(h[w--]=C>>24&255),E=0,b=0):(E=C>>>24,b+=2)}if(w>=0)for(h[w--]=E;w>=0;)h[w--]=0},Math.clz32?i.prototype._countBits=function(h){return 32-Math.clz32(h)}:i.prototype._countBits=function(h){var y=h,w=0;return y>=4096&&(w+=13,y>>>=13),y>=64&&(w+=7,y>>>=7),y>=8&&(w+=4,y>>>=4),y>=2&&(w+=2,y>>>=2),w+y},i.prototype._zeroBits=function(h){if(h===0)return 26;var y=h,w=0;return y&8191||(w+=13,y>>>=13),y&127||(w+=7,y>>>=7),y&15||(w+=4,y>>>=4),y&3||(w+=2,y>>>=2),y&1||w++,w},i.prototype.bitLength=function(){var h=this.words[this.length-1],y=this._countBits(h);return(this.length-1)*26+y};function v(B){for(var h=new Array(B.bitLength()),y=0;y>>E&1}return h}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var h=0,y=0;yh.length?this.clone().ior(h):h.clone().ior(this)},i.prototype.uor=function(h){return this.length>h.length?this.clone().iuor(h):h.clone().iuor(this)},i.prototype.iuand=function(h){var y;this.length>h.length?y=h:y=this;for(var w=0;wh.length?this.clone().iand(h):h.clone().iand(this)},i.prototype.uand=function(h){return this.length>h.length?this.clone().iuand(h):h.clone().iuand(this)},i.prototype.iuxor=function(h){var y,w;this.length>h.length?(y=this,w=h):(y=h,w=this);for(var E=0;Eh.length?this.clone().ixor(h):h.clone().ixor(this)},i.prototype.uxor=function(h){return this.length>h.length?this.clone().iuxor(h):h.clone().iuxor(this)},i.prototype.inotn=function(h){r(typeof h=="number"&&h>=0);var y=Math.ceil(h/26)|0,w=h%26;this._expand(y),w>0&&y--;for(var E=0;E0&&(this.words[E]=~this.words[E]&67108863>>26-w),this._strip()},i.prototype.notn=function(h){return this.clone().inotn(h)},i.prototype.setn=function(h,y){r(typeof h=="number"&&h>=0);var w=h/26|0,E=h%26;return this._expand(w+1),y?this.words[w]=this.words[w]|1<h.length?(w=this,E=h):(w=h,E=this);for(var _=0,b=0;b>>26;for(;_!==0&&b>>26;if(this.length=w.length,_!==0)this.words[this.length]=_,this.length++;else if(w!==this)for(;bh.length?this.clone().iadd(h):h.clone().iadd(this)},i.prototype.isub=function(h){if(h.negative!==0){h.negative=0;var y=this.iadd(h);return h.negative=1,y._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(h),this.negative=1,this._normSign();var w=this.cmp(h);if(w===0)return this.negative=0,this.length=1,this.words[0]=0,this;var E,_;w>0?(E=this,_=h):(E=h,_=this);for(var b=0,C=0;C<_.length;C++)y=(E.words[C]|0)-(_.words[C]|0)+b,b=y>>26,this.words[C]=y&67108863;for(;b!==0&&C>26,this.words[C]=y&67108863;if(b===0&&C>>26,G=N&67108863,Z=Math.min(M,h.length-1),J=Math.max(0,M-B.length+1);J<=Z;J++){var H=M-J|0;E=B.words[H]|0,_=h.words[J]|0,b=E*_+G,U+=b/67108864|0,G=b&67108863}y.words[M]=G|0,N=U|0}return N!==0?y.words[M]=N|0:y.length--,y._strip()}var S=function(h,y,w){var E=h.words,_=y.words,b=w.words,C=0,N,M,U,G=E[0]|0,Z=G&8191,J=G>>>13,H=E[1]|0,X=H&8191,te=H>>>13,ne=E[2]|0,Q=ne&8191,re=ne>>>13,ce=E[3]|0,pe=ce&8191,ye=ce>>>13,ie=E[4]|0,he=ie&8191,me=ie>>>13,Re=E[5]|0,xe=Re&8191,it=Re>>>13,Et=E[6]|0,Fe=Et&8191,mt=Et>>>13,Sn=E[7]|0,ke=Sn&8191,Pe=Sn>>>13,Wt=E[8]|0,Be=Wt&8191,Ee=Wt>>>13,$r=E[9]|0,Ve=$r&8191,Ze=$r>>>13,tn=_[0]|0,Rt=tn&8191,Ye=tn>>>13,yd=_[1]|0,Dt=yd&8191,Ut=yd>>>13,g0=_[2]|0,$t=g0&8191,Zt=g0>>>13,gd=_[3]|0,Yt=gd&8191,Ht=gd>>>13,v0=_[4]|0,qt=v0&8191,Vt=v0>>>13,b0=_[5]|0,Gt=b0&8191,Xt=b0>>>13,Kp=_[6]|0,ee=Kp&8191,Y=Kp>>>13,se=_[7]|0,ue=se&8191,le=se>>>13,Ne=_[8]|0,Me=Ne&8191,Ue=Ne>>>13,Tr=_[9]|0,Lt=Tr&8191,ft=Tr>>>13;w.negative=h.negative^y.negative,w.length=19,N=Math.imul(Z,Rt),M=Math.imul(Z,Ye),M=M+Math.imul(J,Rt)|0,U=Math.imul(J,Ye);var Zr=(C+N|0)+((M&8191)<<13)|0;C=(U+(M>>>13)|0)+(Zr>>>26)|0,Zr&=67108863,N=Math.imul(X,Rt),M=Math.imul(X,Ye),M=M+Math.imul(te,Rt)|0,U=Math.imul(te,Ye),N=N+Math.imul(Z,Dt)|0,M=M+Math.imul(Z,Ut)|0,M=M+Math.imul(J,Dt)|0,U=U+Math.imul(J,Ut)|0;var un=(C+N|0)+((M&8191)<<13)|0;C=(U+(M>>>13)|0)+(un>>>26)|0,un&=67108863,N=Math.imul(Q,Rt),M=Math.imul(Q,Ye),M=M+Math.imul(re,Rt)|0,U=Math.imul(re,Ye),N=N+Math.imul(X,Dt)|0,M=M+Math.imul(X,Ut)|0,M=M+Math.imul(te,Dt)|0,U=U+Math.imul(te,Ut)|0,N=N+Math.imul(Z,$t)|0,M=M+Math.imul(Z,Zt)|0,M=M+Math.imul(J,$t)|0,U=U+Math.imul(J,Zt)|0;var Hr=(C+N|0)+((M&8191)<<13)|0;C=(U+(M>>>13)|0)+(Hr>>>26)|0,Hr&=67108863,N=Math.imul(pe,Rt),M=Math.imul(pe,Ye),M=M+Math.imul(ye,Rt)|0,U=Math.imul(ye,Ye),N=N+Math.imul(Q,Dt)|0,M=M+Math.imul(Q,Ut)|0,M=M+Math.imul(re,Dt)|0,U=U+Math.imul(re,Ut)|0,N=N+Math.imul(X,$t)|0,M=M+Math.imul(X,Zt)|0,M=M+Math.imul(te,$t)|0,U=U+Math.imul(te,Zt)|0,N=N+Math.imul(Z,Yt)|0,M=M+Math.imul(Z,Ht)|0,M=M+Math.imul(J,Yt)|0,U=U+Math.imul(J,Ht)|0;var ar=(C+N|0)+((M&8191)<<13)|0;C=(U+(M>>>13)|0)+(ar>>>26)|0,ar&=67108863,N=Math.imul(he,Rt),M=Math.imul(he,Ye),M=M+Math.imul(me,Rt)|0,U=Math.imul(me,Ye),N=N+Math.imul(pe,Dt)|0,M=M+Math.imul(pe,Ut)|0,M=M+Math.imul(ye,Dt)|0,U=U+Math.imul(ye,Ut)|0,N=N+Math.imul(Q,$t)|0,M=M+Math.imul(Q,Zt)|0,M=M+Math.imul(re,$t)|0,U=U+Math.imul(re,Zt)|0,N=N+Math.imul(X,Yt)|0,M=M+Math.imul(X,Ht)|0,M=M+Math.imul(te,Yt)|0,U=U+Math.imul(te,Ht)|0,N=N+Math.imul(Z,qt)|0,M=M+Math.imul(Z,Vt)|0,M=M+Math.imul(J,qt)|0,U=U+Math.imul(J,Vt)|0;var Yr=(C+N|0)+((M&8191)<<13)|0;C=(U+(M>>>13)|0)+(Yr>>>26)|0,Yr&=67108863,N=Math.imul(xe,Rt),M=Math.imul(xe,Ye),M=M+Math.imul(it,Rt)|0,U=Math.imul(it,Ye),N=N+Math.imul(he,Dt)|0,M=M+Math.imul(he,Ut)|0,M=M+Math.imul(me,Dt)|0,U=U+Math.imul(me,Ut)|0,N=N+Math.imul(pe,$t)|0,M=M+Math.imul(pe,Zt)|0,M=M+Math.imul(ye,$t)|0,U=U+Math.imul(ye,Zt)|0,N=N+Math.imul(Q,Yt)|0,M=M+Math.imul(Q,Ht)|0,M=M+Math.imul(re,Yt)|0,U=U+Math.imul(re,Ht)|0,N=N+Math.imul(X,qt)|0,M=M+Math.imul(X,Vt)|0,M=M+Math.imul(te,qt)|0,U=U+Math.imul(te,Vt)|0,N=N+Math.imul(Z,Gt)|0,M=M+Math.imul(Z,Xt)|0,M=M+Math.imul(J,Gt)|0,U=U+Math.imul(J,Xt)|0;var Br=(C+N|0)+((M&8191)<<13)|0;C=(U+(M>>>13)|0)+(Br>>>26)|0,Br&=67108863,N=Math.imul(Fe,Rt),M=Math.imul(Fe,Ye),M=M+Math.imul(mt,Rt)|0,U=Math.imul(mt,Ye),N=N+Math.imul(xe,Dt)|0,M=M+Math.imul(xe,Ut)|0,M=M+Math.imul(it,Dt)|0,U=U+Math.imul(it,Ut)|0,N=N+Math.imul(he,$t)|0,M=M+Math.imul(he,Zt)|0,M=M+Math.imul(me,$t)|0,U=U+Math.imul(me,Zt)|0,N=N+Math.imul(pe,Yt)|0,M=M+Math.imul(pe,Ht)|0,M=M+Math.imul(ye,Yt)|0,U=U+Math.imul(ye,Ht)|0,N=N+Math.imul(Q,qt)|0,M=M+Math.imul(Q,Vt)|0,M=M+Math.imul(re,qt)|0,U=U+Math.imul(re,Vt)|0,N=N+Math.imul(X,Gt)|0,M=M+Math.imul(X,Xt)|0,M=M+Math.imul(te,Gt)|0,U=U+Math.imul(te,Xt)|0,N=N+Math.imul(Z,ee)|0,M=M+Math.imul(Z,Y)|0,M=M+Math.imul(J,ee)|0,U=U+Math.imul(J,Y)|0;var pa=(C+N|0)+((M&8191)<<13)|0;C=(U+(M>>>13)|0)+(pa>>>26)|0,pa&=67108863,N=Math.imul(ke,Rt),M=Math.imul(ke,Ye),M=M+Math.imul(Pe,Rt)|0,U=Math.imul(Pe,Ye),N=N+Math.imul(Fe,Dt)|0,M=M+Math.imul(Fe,Ut)|0,M=M+Math.imul(mt,Dt)|0,U=U+Math.imul(mt,Ut)|0,N=N+Math.imul(xe,$t)|0,M=M+Math.imul(xe,Zt)|0,M=M+Math.imul(it,$t)|0,U=U+Math.imul(it,Zt)|0,N=N+Math.imul(he,Yt)|0,M=M+Math.imul(he,Ht)|0,M=M+Math.imul(me,Yt)|0,U=U+Math.imul(me,Ht)|0,N=N+Math.imul(pe,qt)|0,M=M+Math.imul(pe,Vt)|0,M=M+Math.imul(ye,qt)|0,U=U+Math.imul(ye,Vt)|0,N=N+Math.imul(Q,Gt)|0,M=M+Math.imul(Q,Xt)|0,M=M+Math.imul(re,Gt)|0,U=U+Math.imul(re,Xt)|0,N=N+Math.imul(X,ee)|0,M=M+Math.imul(X,Y)|0,M=M+Math.imul(te,ee)|0,U=U+Math.imul(te,Y)|0,N=N+Math.imul(Z,ue)|0,M=M+Math.imul(Z,le)|0,M=M+Math.imul(J,ue)|0,U=U+Math.imul(J,le)|0;var Si=(C+N|0)+((M&8191)<<13)|0;C=(U+(M>>>13)|0)+(Si>>>26)|0,Si&=67108863,N=Math.imul(Be,Rt),M=Math.imul(Be,Ye),M=M+Math.imul(Ee,Rt)|0,U=Math.imul(Ee,Ye),N=N+Math.imul(ke,Dt)|0,M=M+Math.imul(ke,Ut)|0,M=M+Math.imul(Pe,Dt)|0,U=U+Math.imul(Pe,Ut)|0,N=N+Math.imul(Fe,$t)|0,M=M+Math.imul(Fe,Zt)|0,M=M+Math.imul(mt,$t)|0,U=U+Math.imul(mt,Zt)|0,N=N+Math.imul(xe,Yt)|0,M=M+Math.imul(xe,Ht)|0,M=M+Math.imul(it,Yt)|0,U=U+Math.imul(it,Ht)|0,N=N+Math.imul(he,qt)|0,M=M+Math.imul(he,Vt)|0,M=M+Math.imul(me,qt)|0,U=U+Math.imul(me,Vt)|0,N=N+Math.imul(pe,Gt)|0,M=M+Math.imul(pe,Xt)|0,M=M+Math.imul(ye,Gt)|0,U=U+Math.imul(ye,Xt)|0,N=N+Math.imul(Q,ee)|0,M=M+Math.imul(Q,Y)|0,M=M+Math.imul(re,ee)|0,U=U+Math.imul(re,Y)|0,N=N+Math.imul(X,ue)|0,M=M+Math.imul(X,le)|0,M=M+Math.imul(te,ue)|0,U=U+Math.imul(te,le)|0,N=N+Math.imul(Z,Me)|0,M=M+Math.imul(Z,Ue)|0,M=M+Math.imul(J,Me)|0,U=U+Math.imul(J,Ue)|0;var qi=(C+N|0)+((M&8191)<<13)|0;C=(U+(M>>>13)|0)+(qi>>>26)|0,qi&=67108863,N=Math.imul(Ve,Rt),M=Math.imul(Ve,Ye),M=M+Math.imul(Ze,Rt)|0,U=Math.imul(Ze,Ye),N=N+Math.imul(Be,Dt)|0,M=M+Math.imul(Be,Ut)|0,M=M+Math.imul(Ee,Dt)|0,U=U+Math.imul(Ee,Ut)|0,N=N+Math.imul(ke,$t)|0,M=M+Math.imul(ke,Zt)|0,M=M+Math.imul(Pe,$t)|0,U=U+Math.imul(Pe,Zt)|0,N=N+Math.imul(Fe,Yt)|0,M=M+Math.imul(Fe,Ht)|0,M=M+Math.imul(mt,Yt)|0,U=U+Math.imul(mt,Ht)|0,N=N+Math.imul(xe,qt)|0,M=M+Math.imul(xe,Vt)|0,M=M+Math.imul(it,qt)|0,U=U+Math.imul(it,Vt)|0,N=N+Math.imul(he,Gt)|0,M=M+Math.imul(he,Xt)|0,M=M+Math.imul(me,Gt)|0,U=U+Math.imul(me,Xt)|0,N=N+Math.imul(pe,ee)|0,M=M+Math.imul(pe,Y)|0,M=M+Math.imul(ye,ee)|0,U=U+Math.imul(ye,Y)|0,N=N+Math.imul(Q,ue)|0,M=M+Math.imul(Q,le)|0,M=M+Math.imul(re,ue)|0,U=U+Math.imul(re,le)|0,N=N+Math.imul(X,Me)|0,M=M+Math.imul(X,Ue)|0,M=M+Math.imul(te,Me)|0,U=U+Math.imul(te,Ue)|0,N=N+Math.imul(Z,Lt)|0,M=M+Math.imul(Z,ft)|0,M=M+Math.imul(J,Lt)|0,U=U+Math.imul(J,ft)|0;var jr=(C+N|0)+((M&8191)<<13)|0;C=(U+(M>>>13)|0)+(jr>>>26)|0,jr&=67108863,N=Math.imul(Ve,Dt),M=Math.imul(Ve,Ut),M=M+Math.imul(Ze,Dt)|0,U=Math.imul(Ze,Ut),N=N+Math.imul(Be,$t)|0,M=M+Math.imul(Be,Zt)|0,M=M+Math.imul(Ee,$t)|0,U=U+Math.imul(Ee,Zt)|0,N=N+Math.imul(ke,Yt)|0,M=M+Math.imul(ke,Ht)|0,M=M+Math.imul(Pe,Yt)|0,U=U+Math.imul(Pe,Ht)|0,N=N+Math.imul(Fe,qt)|0,M=M+Math.imul(Fe,Vt)|0,M=M+Math.imul(mt,qt)|0,U=U+Math.imul(mt,Vt)|0,N=N+Math.imul(xe,Gt)|0,M=M+Math.imul(xe,Xt)|0,M=M+Math.imul(it,Gt)|0,U=U+Math.imul(it,Xt)|0,N=N+Math.imul(he,ee)|0,M=M+Math.imul(he,Y)|0,M=M+Math.imul(me,ee)|0,U=U+Math.imul(me,Y)|0,N=N+Math.imul(pe,ue)|0,M=M+Math.imul(pe,le)|0,M=M+Math.imul(ye,ue)|0,U=U+Math.imul(ye,le)|0,N=N+Math.imul(Q,Me)|0,M=M+Math.imul(Q,Ue)|0,M=M+Math.imul(re,Me)|0,U=U+Math.imul(re,Ue)|0,N=N+Math.imul(X,Lt)|0,M=M+Math.imul(X,ft)|0,M=M+Math.imul(te,Lt)|0,U=U+Math.imul(te,ft)|0;var Ai=(C+N|0)+((M&8191)<<13)|0;C=(U+(M>>>13)|0)+(Ai>>>26)|0,Ai&=67108863,N=Math.imul(Ve,$t),M=Math.imul(Ve,Zt),M=M+Math.imul(Ze,$t)|0,U=Math.imul(Ze,Zt),N=N+Math.imul(Be,Yt)|0,M=M+Math.imul(Be,Ht)|0,M=M+Math.imul(Ee,Yt)|0,U=U+Math.imul(Ee,Ht)|0,N=N+Math.imul(ke,qt)|0,M=M+Math.imul(ke,Vt)|0,M=M+Math.imul(Pe,qt)|0,U=U+Math.imul(Pe,Vt)|0,N=N+Math.imul(Fe,Gt)|0,M=M+Math.imul(Fe,Xt)|0,M=M+Math.imul(mt,Gt)|0,U=U+Math.imul(mt,Xt)|0,N=N+Math.imul(xe,ee)|0,M=M+Math.imul(xe,Y)|0,M=M+Math.imul(it,ee)|0,U=U+Math.imul(it,Y)|0,N=N+Math.imul(he,ue)|0,M=M+Math.imul(he,le)|0,M=M+Math.imul(me,ue)|0,U=U+Math.imul(me,le)|0,N=N+Math.imul(pe,Me)|0,M=M+Math.imul(pe,Ue)|0,M=M+Math.imul(ye,Me)|0,U=U+Math.imul(ye,Ue)|0,N=N+Math.imul(Q,Lt)|0,M=M+Math.imul(Q,ft)|0,M=M+Math.imul(re,Lt)|0,U=U+Math.imul(re,ft)|0;var Li=(C+N|0)+((M&8191)<<13)|0;C=(U+(M>>>13)|0)+(Li>>>26)|0,Li&=67108863,N=Math.imul(Ve,Yt),M=Math.imul(Ve,Ht),M=M+Math.imul(Ze,Yt)|0,U=Math.imul(Ze,Ht),N=N+Math.imul(Be,qt)|0,M=M+Math.imul(Be,Vt)|0,M=M+Math.imul(Ee,qt)|0,U=U+Math.imul(Ee,Vt)|0,N=N+Math.imul(ke,Gt)|0,M=M+Math.imul(ke,Xt)|0,M=M+Math.imul(Pe,Gt)|0,U=U+Math.imul(Pe,Xt)|0,N=N+Math.imul(Fe,ee)|0,M=M+Math.imul(Fe,Y)|0,M=M+Math.imul(mt,ee)|0,U=U+Math.imul(mt,Y)|0,N=N+Math.imul(xe,ue)|0,M=M+Math.imul(xe,le)|0,M=M+Math.imul(it,ue)|0,U=U+Math.imul(it,le)|0,N=N+Math.imul(he,Me)|0,M=M+Math.imul(he,Ue)|0,M=M+Math.imul(me,Me)|0,U=U+Math.imul(me,Ue)|0,N=N+Math.imul(pe,Lt)|0,M=M+Math.imul(pe,ft)|0,M=M+Math.imul(ye,Lt)|0,U=U+Math.imul(ye,ft)|0;var xo=(C+N|0)+((M&8191)<<13)|0;C=(U+(M>>>13)|0)+(xo>>>26)|0,xo&=67108863,N=Math.imul(Ve,qt),M=Math.imul(Ve,Vt),M=M+Math.imul(Ze,qt)|0,U=Math.imul(Ze,Vt),N=N+Math.imul(Be,Gt)|0,M=M+Math.imul(Be,Xt)|0,M=M+Math.imul(Ee,Gt)|0,U=U+Math.imul(Ee,Xt)|0,N=N+Math.imul(ke,ee)|0,M=M+Math.imul(ke,Y)|0,M=M+Math.imul(Pe,ee)|0,U=U+Math.imul(Pe,Y)|0,N=N+Math.imul(Fe,ue)|0,M=M+Math.imul(Fe,le)|0,M=M+Math.imul(mt,ue)|0,U=U+Math.imul(mt,le)|0,N=N+Math.imul(xe,Me)|0,M=M+Math.imul(xe,Ue)|0,M=M+Math.imul(it,Me)|0,U=U+Math.imul(it,Ue)|0,N=N+Math.imul(he,Lt)|0,M=M+Math.imul(he,ft)|0,M=M+Math.imul(me,Lt)|0,U=U+Math.imul(me,ft)|0;var ma=(C+N|0)+((M&8191)<<13)|0;C=(U+(M>>>13)|0)+(ma>>>26)|0,ma&=67108863,N=Math.imul(Ve,Gt),M=Math.imul(Ve,Xt),M=M+Math.imul(Ze,Gt)|0,U=Math.imul(Ze,Xt),N=N+Math.imul(Be,ee)|0,M=M+Math.imul(Be,Y)|0,M=M+Math.imul(Ee,ee)|0,U=U+Math.imul(Ee,Y)|0,N=N+Math.imul(ke,ue)|0,M=M+Math.imul(ke,le)|0,M=M+Math.imul(Pe,ue)|0,U=U+Math.imul(Pe,le)|0,N=N+Math.imul(Fe,Me)|0,M=M+Math.imul(Fe,Ue)|0,M=M+Math.imul(mt,Me)|0,U=U+Math.imul(mt,Ue)|0,N=N+Math.imul(xe,Lt)|0,M=M+Math.imul(xe,ft)|0,M=M+Math.imul(it,Lt)|0,U=U+Math.imul(it,ft)|0;var Qo=(C+N|0)+((M&8191)<<13)|0;C=(U+(M>>>13)|0)+(Qo>>>26)|0,Qo&=67108863,N=Math.imul(Ve,ee),M=Math.imul(Ve,Y),M=M+Math.imul(Ze,ee)|0,U=Math.imul(Ze,Y),N=N+Math.imul(Be,ue)|0,M=M+Math.imul(Be,le)|0,M=M+Math.imul(Ee,ue)|0,U=U+Math.imul(Ee,le)|0,N=N+Math.imul(ke,Me)|0,M=M+Math.imul(ke,Ue)|0,M=M+Math.imul(Pe,Me)|0,U=U+Math.imul(Pe,Ue)|0,N=N+Math.imul(Fe,Lt)|0,M=M+Math.imul(Fe,ft)|0,M=M+Math.imul(mt,Lt)|0,U=U+Math.imul(mt,ft)|0;var Ac=(C+N|0)+((M&8191)<<13)|0;C=(U+(M>>>13)|0)+(Ac>>>26)|0,Ac&=67108863,N=Math.imul(Ve,ue),M=Math.imul(Ve,le),M=M+Math.imul(Ze,ue)|0,U=Math.imul(Ze,le),N=N+Math.imul(Be,Me)|0,M=M+Math.imul(Be,Ue)|0,M=M+Math.imul(Ee,Me)|0,U=U+Math.imul(Ee,Ue)|0,N=N+Math.imul(ke,Lt)|0,M=M+Math.imul(ke,ft)|0,M=M+Math.imul(Pe,Lt)|0,U=U+Math.imul(Pe,ft)|0;var Fp=(C+N|0)+((M&8191)<<13)|0;C=(U+(M>>>13)|0)+(Fp>>>26)|0,Fp&=67108863,N=Math.imul(Ve,Me),M=Math.imul(Ve,Ue),M=M+Math.imul(Ze,Me)|0,U=Math.imul(Ze,Ue),N=N+Math.imul(Be,Lt)|0,M=M+Math.imul(Be,ft)|0,M=M+Math.imul(Ee,Lt)|0,U=U+Math.imul(Ee,ft)|0;var zp=(C+N|0)+((M&8191)<<13)|0;C=(U+(M>>>13)|0)+(zp>>>26)|0,zp&=67108863,N=Math.imul(Ve,Lt),M=Math.imul(Ve,ft),M=M+Math.imul(Ze,Lt)|0,U=Math.imul(Ze,ft);var vl=(C+N|0)+((M&8191)<<13)|0;return C=(U+(M>>>13)|0)+(vl>>>26)|0,vl&=67108863,b[0]=Zr,b[1]=un,b[2]=Hr,b[3]=ar,b[4]=Yr,b[5]=Br,b[6]=pa,b[7]=Si,b[8]=qi,b[9]=jr,b[10]=Ai,b[11]=Li,b[12]=xo,b[13]=ma,b[14]=Qo,b[15]=Ac,b[16]=Fp,b[17]=zp,b[18]=vl,C!==0&&(b[19]=C,w.length++),w};Math.imul||(S=x);function P(B,h,y){y.negative=h.negative^B.negative,y.length=B.length+h.length;for(var w=0,E=0,_=0;_>>26)|0,E+=b>>>26,b&=67108863}y.words[_]=C,w=b,b=E}return w!==0?y.words[_]=w:y.length--,y._strip()}function A(B,h,y){return P(B,h,y)}i.prototype.mulTo=function(h,y){var w,E=this.length+h.length;return this.length===10&&h.length===10?w=S(this,h,y):E<63?w=x(this,h,y):E<1024?w=P(this,h,y):w=A(this,h,y),w};function $(B,h){this.x=B,this.y=h}$.prototype.makeRBT=function(h){for(var y=new Array(h),w=i.prototype._countBits(h)-1,E=0;E>=1;return E},$.prototype.permute=function(h,y,w,E,_,b){for(var C=0;C>>1)_++;return 1<<_+1+E},$.prototype.conjugate=function(h,y,w){if(!(w<=1))for(var E=0;E>>13,w[2*b+1]=_&8191,_=_>>>13;for(b=2*y;b>=26,w+=_/67108864|0,w+=b>>>26,this.words[E]=b&67108863}return w!==0&&(this.words[E]=w,this.length++),y?this.ineg():this},i.prototype.muln=function(h){return this.clone().imuln(h)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(h){var y=v(h);if(y.length===0)return new i(1);for(var w=this,E=0;E=0);var y=h%26,w=(h-y)/26,E=67108863>>>26-y<<26-y,_;if(y!==0){var b=0;for(_=0;_>>26-y}b&&(this.words[_]=b,this.length++)}if(w!==0){for(_=this.length-1;_>=0;_--)this.words[_+w]=this.words[_];for(_=0;_=0);var E;y?E=(y-y%26)/26:E=0;var _=h%26,b=Math.min((h-_)/26,this.length),C=67108863^67108863>>>_<<_,N=w;if(E-=b,E=Math.max(0,E),N){for(var M=0;Mb)for(this.length-=b,M=0;M=0&&(U!==0||M>=E);M--){var G=this.words[M]|0;this.words[M]=U<<26-_|G>>>_,U=G&C}return N&&U!==0&&(N.words[N.length++]=U),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.ishrn=function(h,y,w){return r(this.negative===0),this.iushrn(h,y,w)},i.prototype.shln=function(h){return this.clone().ishln(h)},i.prototype.ushln=function(h){return this.clone().iushln(h)},i.prototype.shrn=function(h){return this.clone().ishrn(h)},i.prototype.ushrn=function(h){return this.clone().iushrn(h)},i.prototype.testn=function(h){r(typeof h=="number"&&h>=0);var y=h%26,w=(h-y)/26,E=1<=0);var y=h%26,w=(h-y)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=w)return this;if(y!==0&&w++,this.length=Math.min(w,this.length),y!==0){var E=67108863^67108863>>>y<=67108864;y++)this.words[y]-=67108864,y===this.length-1?this.words[y+1]=1:this.words[y+1]++;return this.length=Math.max(this.length,y+1),this},i.prototype.isubn=function(h){if(r(typeof h=="number"),r(h<67108864),h<0)return this.iaddn(-h);if(this.negative!==0)return this.negative=0,this.iaddn(h),this.negative=1,this;if(this.words[0]-=h,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var y=0;y>26)-(N/67108864|0),this.words[_+w]=b&67108863}for(;_>26,this.words[_+w]=b&67108863;if(C===0)return this._strip();for(r(C===-1),C=0,_=0;_>26,this.words[_]=b&67108863;return this.negative=1,this._strip()},i.prototype._wordDiv=function(h,y){var w=this.length-h.length,E=this.clone(),_=h,b=_.words[_.length-1]|0,C=this._countBits(b);w=26-C,w!==0&&(_=_.ushln(w),E.iushln(w),b=_.words[_.length-1]|0);var N=E.length-_.length,M;if(y!=="mod"){M=new i(null),M.length=N+1,M.words=new Array(M.length);for(var U=0;U=0;Z--){var J=(E.words[_.length+Z]|0)*67108864+(E.words[_.length+Z-1]|0);for(J=Math.min(J/b|0,67108863),E._ishlnsubmul(_,J,Z);E.negative!==0;)J--,E.negative=0,E._ishlnsubmul(_,1,Z),E.isZero()||(E.negative^=1);M&&(M.words[Z]=J)}return M&&M._strip(),E._strip(),y!=="div"&&w!==0&&E.iushrn(w),{div:M||null,mod:E}},i.prototype.divmod=function(h,y,w){if(r(!h.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var E,_,b;return this.negative!==0&&h.negative===0?(b=this.neg().divmod(h,y),y!=="mod"&&(E=b.div.neg()),y!=="div"&&(_=b.mod.neg(),w&&_.negative!==0&&_.iadd(h)),{div:E,mod:_}):this.negative===0&&h.negative!==0?(b=this.divmod(h.neg(),y),y!=="mod"&&(E=b.div.neg()),{div:E,mod:b.mod}):this.negative&h.negative?(b=this.neg().divmod(h.neg(),y),y!=="div"&&(_=b.mod.neg(),w&&_.negative!==0&&_.isub(h)),{div:b.div,mod:_}):h.length>this.length||this.cmp(h)<0?{div:new i(0),mod:this}:h.length===1?y==="div"?{div:this.divn(h.words[0]),mod:null}:y==="mod"?{div:null,mod:new i(this.modrn(h.words[0]))}:{div:this.divn(h.words[0]),mod:new i(this.modrn(h.words[0]))}:this._wordDiv(h,y)},i.prototype.div=function(h){return this.divmod(h,"div",!1).div},i.prototype.mod=function(h){return this.divmod(h,"mod",!1).mod},i.prototype.umod=function(h){return this.divmod(h,"mod",!0).mod},i.prototype.divRound=function(h){var y=this.divmod(h);if(y.mod.isZero())return y.div;var w=y.div.negative!==0?y.mod.isub(h):y.mod,E=h.ushrn(1),_=h.andln(1),b=w.cmp(E);return b<0||_===1&&b===0?y.div:y.div.negative!==0?y.div.isubn(1):y.div.iaddn(1)},i.prototype.modrn=function(h){var y=h<0;y&&(h=-h),r(h<=67108863);for(var w=(1<<26)%h,E=0,_=this.length-1;_>=0;_--)E=(w*E+(this.words[_]|0))%h;return y?-E:E},i.prototype.modn=function(h){return this.modrn(h)},i.prototype.idivn=function(h){var y=h<0;y&&(h=-h),r(h<=67108863);for(var w=0,E=this.length-1;E>=0;E--){var _=(this.words[E]|0)+w*67108864;this.words[E]=_/h|0,w=_%h}return this._strip(),y?this.ineg():this},i.prototype.divn=function(h){return this.clone().idivn(h)},i.prototype.egcd=function(h){r(h.negative===0),r(!h.isZero());var y=this,w=h.clone();y.negative!==0?y=y.umod(h):y=y.clone();for(var E=new i(1),_=new i(0),b=new i(0),C=new i(1),N=0;y.isEven()&&w.isEven();)y.iushrn(1),w.iushrn(1),++N;for(var M=w.clone(),U=y.clone();!y.isZero();){for(var G=0,Z=1;!(y.words[0]&Z)&&G<26;++G,Z<<=1);if(G>0)for(y.iushrn(G);G-- >0;)(E.isOdd()||_.isOdd())&&(E.iadd(M),_.isub(U)),E.iushrn(1),_.iushrn(1);for(var J=0,H=1;!(w.words[0]&H)&&J<26;++J,H<<=1);if(J>0)for(w.iushrn(J);J-- >0;)(b.isOdd()||C.isOdd())&&(b.iadd(M),C.isub(U)),b.iushrn(1),C.iushrn(1);y.cmp(w)>=0?(y.isub(w),E.isub(b),_.isub(C)):(w.isub(y),b.isub(E),C.isub(_))}return{a:b,b:C,gcd:w.iushln(N)}},i.prototype._invmp=function(h){r(h.negative===0),r(!h.isZero());var y=this,w=h.clone();y.negative!==0?y=y.umod(h):y=y.clone();for(var E=new i(1),_=new i(0),b=w.clone();y.cmpn(1)>0&&w.cmpn(1)>0;){for(var C=0,N=1;!(y.words[0]&N)&&C<26;++C,N<<=1);if(C>0)for(y.iushrn(C);C-- >0;)E.isOdd()&&E.iadd(b),E.iushrn(1);for(var M=0,U=1;!(w.words[0]&U)&&M<26;++M,U<<=1);if(M>0)for(w.iushrn(M);M-- >0;)_.isOdd()&&_.iadd(b),_.iushrn(1);y.cmp(w)>=0?(y.isub(w),E.isub(_)):(w.isub(y),_.isub(E))}var G;return y.cmpn(1)===0?G=E:G=_,G.cmpn(0)<0&&G.iadd(h),G},i.prototype.gcd=function(h){if(this.isZero())return h.abs();if(h.isZero())return this.abs();var y=this.clone(),w=h.clone();y.negative=0,w.negative=0;for(var E=0;y.isEven()&&w.isEven();E++)y.iushrn(1),w.iushrn(1);do{for(;y.isEven();)y.iushrn(1);for(;w.isEven();)w.iushrn(1);var _=y.cmp(w);if(_<0){var b=y;y=w,w=b}else if(_===0||w.cmpn(1)===0)break;y.isub(w)}while(!0);return w.iushln(E)},i.prototype.invm=function(h){return this.egcd(h).a.umod(h)},i.prototype.isEven=function(){return(this.words[0]&1)===0},i.prototype.isOdd=function(){return(this.words[0]&1)===1},i.prototype.andln=function(h){return this.words[0]&h},i.prototype.bincn=function(h){r(typeof h=="number");var y=h%26,w=(h-y)/26,E=1<>>26,C&=67108863,this.words[b]=C}return _!==0&&(this.words[b]=_,this.length++),this},i.prototype.isZero=function(){return this.length===1&&this.words[0]===0},i.prototype.cmpn=function(h){var y=h<0;if(this.negative!==0&&!y)return-1;if(this.negative===0&&y)return 1;this._strip();var w;if(this.length>1)w=1;else{y&&(h=-h),r(h<=67108863,"Number is too big");var E=this.words[0]|0;w=E===h?0:Eh.length)return 1;if(this.length=0;w--){var E=this.words[w]|0,_=h.words[w]|0;if(E!==_){E<_?y=-1:E>_&&(y=1);break}}return y},i.prototype.gtn=function(h){return this.cmpn(h)===1},i.prototype.gt=function(h){return this.cmp(h)===1},i.prototype.gten=function(h){return this.cmpn(h)>=0},i.prototype.gte=function(h){return this.cmp(h)>=0},i.prototype.ltn=function(h){return this.cmpn(h)===-1},i.prototype.lt=function(h){return this.cmp(h)===-1},i.prototype.lten=function(h){return this.cmpn(h)<=0},i.prototype.lte=function(h){return this.cmp(h)<=0},i.prototype.eqn=function(h){return this.cmpn(h)===0},i.prototype.eq=function(h){return this.cmp(h)===0},i.red=function(h){return new I(h)},i.prototype.toRed=function(h){return r(!this.red,"Already a number in reduction context"),r(this.negative===0,"red works only with positives"),h.convertTo(this)._forceRed(h)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(h){return this.red=h,this},i.prototype.forceRed=function(h){return r(!this.red,"Already a number in reduction context"),this._forceRed(h)},i.prototype.redAdd=function(h){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,h)},i.prototype.redIAdd=function(h){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,h)},i.prototype.redSub=function(h){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,h)},i.prototype.redISub=function(h){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,h)},i.prototype.redShl=function(h){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,h)},i.prototype.redMul=function(h){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,h),this.red.mul(this,h)},i.prototype.redIMul=function(h){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,h),this.red.imul(this,h)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(h){return r(this.red&&!h.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,h)};var j={k256:null,p224:null,p192:null,p25519:null};function q(B,h){this.name=B,this.p=new i(h,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}q.prototype._tmp=function(){var h=new i(null);return h.words=new Array(Math.ceil(this.n/13)),h},q.prototype.ireduce=function(h){var y=h,w;do this.split(y,this.tmp),y=this.imulK(y),y=y.iadd(this.tmp),w=y.bitLength();while(w>this.n);var E=w0?y.isub(this.p):y.strip!==void 0?y.strip():y._strip(),y},q.prototype.split=function(h,y){h.iushrn(this.n,0,y)},q.prototype.imulK=function(h){return h.imul(this.k)};function F(){q.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(F,q),F.prototype.split=function(h,y){for(var w=4194303,E=Math.min(h.length,9),_=0;_>>22,b=C}b>>>=22,h.words[_-10]=b,b===0&&h.length>10?h.length-=10:h.length-=9},F.prototype.imulK=function(h){h.words[h.length]=0,h.words[h.length+1]=0,h.length+=2;for(var y=0,w=0;w>>=26,h.words[w]=_,y=E}return y!==0&&(h.words[h.length++]=y),h},i._prime=function(h){if(j[h])return j[h];var y;if(h==="k256")y=new F;else if(h==="p224")y=new K;else if(h==="p192")y=new W;else if(h==="p25519")y=new L;else throw new Error("Unknown prime "+h);return j[h]=y,y};function I(B){if(typeof B=="string"){var h=i._prime(B);this.m=h.p,this.prime=h}else r(B.gtn(1),"modulus must be greater than 1"),this.m=B,this.prime=null}I.prototype._verify1=function(h){r(h.negative===0,"red works only with positives"),r(h.red,"red works only with red numbers")},I.prototype._verify2=function(h,y){r((h.negative|y.negative)===0,"red works only with positives"),r(h.red&&h.red===y.red,"red works only with red numbers")},I.prototype.imod=function(h){return this.prime?this.prime.ireduce(h)._forceRed(this):(u(h,h.umod(this.m)._forceRed(this)),h)},I.prototype.neg=function(h){return h.isZero()?h.clone():this.m.sub(h)._forceRed(this)},I.prototype.add=function(h,y){this._verify2(h,y);var w=h.add(y);return w.cmp(this.m)>=0&&w.isub(this.m),w._forceRed(this)},I.prototype.iadd=function(h,y){this._verify2(h,y);var w=h.iadd(y);return w.cmp(this.m)>=0&&w.isub(this.m),w},I.prototype.sub=function(h,y){this._verify2(h,y);var w=h.sub(y);return w.cmpn(0)<0&&w.iadd(this.m),w._forceRed(this)},I.prototype.isub=function(h,y){this._verify2(h,y);var w=h.isub(y);return w.cmpn(0)<0&&w.iadd(this.m),w},I.prototype.shl=function(h,y){return this._verify1(h),this.imod(h.ushln(y))},I.prototype.imul=function(h,y){return this._verify2(h,y),this.imod(h.imul(y))},I.prototype.mul=function(h,y){return this._verify2(h,y),this.imod(h.mul(y))},I.prototype.isqr=function(h){return this.imul(h,h.clone())},I.prototype.sqr=function(h){return this.mul(h,h)},I.prototype.sqrt=function(h){if(h.isZero())return h.clone();var y=this.m.andln(3);if(r(y%2===1),y===3){var w=this.m.add(new i(1)).iushrn(2);return this.pow(h,w)}for(var E=this.m.subn(1),_=0;!E.isZero()&&E.andln(1)===0;)_++,E.iushrn(1);r(!E.isZero());var b=new i(1).toRed(this),C=b.redNeg(),N=this.m.subn(1).iushrn(1),M=this.m.bitLength();for(M=new i(2*M*M).toRed(this);this.pow(M,N).cmp(C)!==0;)M.redIAdd(C);for(var U=this.pow(M,E),G=this.pow(h,E.addn(1).iushrn(1)),Z=this.pow(h,E),J=_;Z.cmp(b)!==0;){for(var H=Z,X=0;H.cmp(b)!==0;X++)H=H.redSqr();r(X=0;_--){for(var U=y.words[_],G=M-1;G>=0;G--){var Z=U>>G&1;if(b!==E[0]&&(b=this.sqr(b)),Z===0&&C===0){N=0;continue}C<<=1,C|=Z,N++,!(N!==w&&(_!==0||G!==0))&&(b=this.mul(b,E[C]),N=0,C=0)}M=26}return b},I.prototype.convertTo=function(h){var y=h.umod(this.m);return y===h?y.clone():y},I.prototype.convertFrom=function(h){var y=h.clone();return y.red=null,y},i.mont=function(h){return new T(h)};function T(B){I.call(this,B),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}n(T,I),T.prototype.convertTo=function(h){return this.imod(h.ushln(this.shift))},T.prototype.convertFrom=function(h){var y=this.imod(h.mul(this.rinv));return y.red=null,y},T.prototype.imul=function(h,y){if(h.isZero()||y.isZero())return h.words[0]=0,h.length=1,h;var w=h.imul(y),E=w.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),_=w.isub(E).iushrn(this.shift),b=_;return _.cmp(this.m)>=0?b=_.isub(this.m):_.cmpn(0)<0&&(b=_.iadd(this.m)),b._forceRed(this)},T.prototype.mul=function(h,y){if(h.isZero()||y.isZero())return new i(0)._forceRed(this);var w=h.mul(y),E=w.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),_=w.isub(E).iushrn(this.shift),b=_;return _.cmp(this.m)>=0?b=_.isub(this.m):_.cmpn(0)<0&&(b=_.iadd(this.m)),b._forceRed(this)},T.prototype.invm=function(h){var y=this.imod(h._invmp(this.m).mul(this.r2));return y._forceRed(this)}})(typeof yO>"u"||yO,ote)});var e4=V((Zvt,cte)=>{f();var Ww=QA(),bke=tg();function wke(t){var e=ste(t),r=e.toRed(Ww.mont(t.modulus)).redPow(new Ww(t.publicExponent)).fromRed();return{blinder:r,unblinder:e.invm(t.modulus)}}function ste(t){var e=t.modulus.byteLength(),r;do r=new Ww(bke(e));while(r.cmp(t.modulus)>=0||!r.umod(t.prime1)||!r.umod(t.prime2));return r}function ate(t,e){var r=wke(e),n=e.modulus.byteLength(),i=new Ww(t).mul(r.blinder).umod(e.modulus),o=i.toRed(Ww.mont(e.prime1)),s=i.toRed(Ww.mont(e.prime2)),a=e.coefficient,d=e.prime1,u=e.prime2,c=o.redPow(e.exponent1).fromRed(),l=s.redPow(e.exponent2).fromRed(),p=c.isub(l).imul(a).umod(d).imul(u);return l.iadd(p).imul(r.unblinder).umod(e.modulus).toArrayLike(O.Buffer,"be",n)}ate.getr=ste;cte.exports=ate});var dte=V((Xvt,_ke)=>{_ke.exports={name:"elliptic",version:"6.5.7",description:"EC cryptography",main:"lib/elliptic.js",files:["lib"],scripts:{lint:"eslint lib test","lint:fix":"npm run lint -- --fix",unit:"istanbul test _mocha --reporter=spec test/index.js",test:"npm run lint && npm run unit",version:"grunt dist && git add dist/"},repository:{type:"git",url:"git@github.com:indutny/elliptic"},keywords:["EC","Elliptic","curve","Cryptography"],author:"Fedor Indutny ",license:"MIT",bugs:{url:"https://github.com/indutny/elliptic/issues"},homepage:"https://github.com/indutny/elliptic",devDependencies:{brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},dependencies:{"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"}}});var gO=V(fte=>{"use strict";f();var t4=fte;function xke(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if(typeof t!="string"){for(var n=0;n>8,s=i&255;o?r.push(o,s):r.push(s)}return r}t4.toArray=xke;function ute(t){return t.length===1?"0"+t:t}t4.zero2=ute;function lte(t){for(var e="",r=0;r{"use strict";f();var Pu=hte,Eke=Mo(),Ske=Nc(),r4=gO();Pu.assert=Ske;Pu.toArray=r4.toArray;Pu.zero2=r4.zero2;Pu.toHex=r4.toHex;Pu.encode=r4.encode;function Ake(t,e,r){var n=new Array(Math.max(t.bitLength(),r)+1),i;for(i=0;i(o>>1)-1?a=(o>>1)-d:a=d,s.isubn(a)):a=0,n[i]=a,s.iushrn(1)}return n}Pu.getNAF=Ake;function Tke(t,e){var r=[[],[]];t=t.clone(),e=e.clone();for(var n=0,i=0,o;t.cmpn(-n)>0||e.cmpn(-i)>0;){var s=t.andln(3)+n&3,a=e.andln(3)+i&3;s===3&&(s=-1),a===3&&(a=-1);var d;s&1?(o=t.andln(7)+n&7,(o===3||o===5)&&a===2?d=-s:d=s):d=0,r[0].push(d);var u;a&1?(o=e.andln(7)+i&7,(o===3||o===5)&&s===2?u=-a:u=a):u=0,r[1].push(u),2*n===d+1&&(n=1-n),2*i===u+1&&(i=1-i),t.iushrn(1),e.iushrn(1)}return r}Pu.getJSF=Tke;function Pke(t,e,r){var n="_"+e;t.prototype[e]=function(){return this[n]!==void 0?this[n]:this[n]=r.call(this)}}Pu.cachedProperty=Pke;function Ike(t){return typeof t=="string"?Pu.toArray(t,"hex"):t}Pu.parseBytes=Ike;function kke(t){return new Eke(t,"hex","le")}Pu.intFromLE=kke});var TE=V((nbt,pte)=>{"use strict";f();var bg=Mo(),AE=Uc(),n4=AE.getNAF,Rke=AE.getJSF,i4=AE.assert;function xm(t,e){this.type=t,this.p=new bg(e.p,16),this.red=e.prime?bg.red(e.prime):bg.mont(this.p),this.zero=new bg(0).toRed(this.red),this.one=new bg(1).toRed(this.red),this.two=new bg(2).toRed(this.red),this.n=e.n&&new bg(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}pte.exports=xm;xm.prototype.point=function(){throw new Error("Not implemented")};xm.prototype.validate=function(){throw new Error("Not implemented")};xm.prototype._fixedNafMul=function(e,r){i4(e.precomputed);var n=e._getDoubles(),i=n4(r,1,this._bitLength),o=(1<=a;u--)d=(d<<1)+i[u];s.push(d)}for(var c=this.jpoint(null,null,null),l=this.jpoint(null,null,null),p=o;p>0;p--){for(a=0;a=0;d--){for(var u=0;d>=0&&s[d]===0;d--)u++;if(d>=0&&u++,a=a.dblp(u),d<0)break;var c=s[d];i4(c!==0),e.type==="affine"?c>0?a=a.mixedAdd(o[c-1>>1]):a=a.mixedAdd(o[-c-1>>1].neg()):c>0?a=a.add(o[c-1>>1]):a=a.add(o[-c-1>>1].neg())}return e.type==="affine"?a.toP():a};xm.prototype._wnafMulAdd=function(e,r,n,i,o){var s=this._wnafT1,a=this._wnafT2,d=this._wnafT3,u=0,c,l,p;for(c=0;c=1;c-=2){var g=c-1,v=c;if(s[g]!==1||s[v]!==1){d[g]=n4(n[g],s[g],this._bitLength),d[v]=n4(n[v],s[v],this._bitLength),u=Math.max(d[g].length,u),u=Math.max(d[v].length,u);continue}var x=[r[g],null,null,r[v]];r[g].y.cmp(r[v].y)===0?(x[1]=r[g].add(r[v]),x[2]=r[g].toJ().mixedAdd(r[v].neg())):r[g].y.cmp(r[v].y.redNeg())===0?(x[1]=r[g].toJ().mixedAdd(r[v]),x[2]=r[g].add(r[v].neg())):(x[1]=r[g].toJ().mixedAdd(r[v]),x[2]=r[g].toJ().mixedAdd(r[v].neg()));var S=[-3,-1,-5,-7,0,7,5,1,3],P=Rke(n[g],n[v]);for(u=Math.max(P[0].length,u),d[g]=new Array(u),d[v]=new Array(u),l=0;l=0;c--){for(var F=0;c>=0;){var K=!0;for(l=0;l=0&&F++,j=j.dblp(F),c<0)break;for(l=0;l0?p=a[l][W-1>>1]:W<0&&(p=a[l][-W-1>>1].neg()),p.type==="affine"?j=j.mixedAdd(p):j=j.add(p))}}for(c=0;c=Math.ceil((e.bitLength()+1)/r.step):!1};Rd.prototype._getDoubles=function(e,r){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var n=[this],i=this,o=0;o{"use strict";f();var Dke=Uc(),wi=Mo(),vO=Ft(),Hw=TE(),Bke=Dke.assert;function Dd(t){Hw.call(this,"short",t),this.a=new wi(t.a,16).toRed(this.red),this.b=new wi(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}vO(Dd,Hw);mte.exports=Dd;Dd.prototype._getEndomorphism=function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var r,n;if(e.beta)r=new wi(e.beta,16).toRed(this.red);else{var i=this._getEndoRoots(this.p);r=i[0].cmp(i[1])<0?i[0]:i[1],r=r.toRed(this.red)}if(e.lambda)n=new wi(e.lambda,16);else{var o=this._getEndoRoots(this.n);this.g.mul(o[0]).x.cmp(this.g.x.redMul(r))===0?n=o[0]:(n=o[1],Bke(this.g.mul(n).x.cmp(this.g.x.redMul(r))===0))}var s;return e.basis?s=e.basis.map(function(a){return{a:new wi(a.a,16),b:new wi(a.b,16)}}):s=this._getEndoBasis(n),{beta:r,lambda:n,basis:s}}};Dd.prototype._getEndoRoots=function(e){var r=e===this.p?this.red:wi.mont(e),n=new wi(2).toRed(r).redInvm(),i=n.redNeg(),o=new wi(3).toRed(r).redNeg().redSqrt().redMul(n),s=i.redAdd(o).fromRed(),a=i.redSub(o).fromRed();return[s,a]};Dd.prototype._getEndoBasis=function(e){for(var r=this.n.ushrn(Math.floor(this.n.bitLength()/2)),n=e,i=this.n.clone(),o=new wi(1),s=new wi(0),a=new wi(0),d=new wi(1),u,c,l,p,m,g,v,x=0,S,P;n.cmpn(0)!==0;){var A=i.div(n);S=i.sub(A.mul(n)),P=a.sub(A.mul(o));var $=d.sub(A.mul(s));if(!l&&S.cmp(r)<0)u=v.neg(),c=o,l=S.neg(),p=P;else if(l&&++x===2)break;v=S,i=n,n=S,a=o,o=P,d=s,s=$}m=S.neg(),g=P;var j=l.sqr().add(p.sqr()),q=m.sqr().add(g.sqr());return q.cmp(j)>=0&&(m=u,g=c),l.negative&&(l=l.neg(),p=p.neg()),m.negative&&(m=m.neg(),g=g.neg()),[{a:l,b:p},{a:m,b:g}]};Dd.prototype._endoSplit=function(e){var r=this.endo.basis,n=r[0],i=r[1],o=i.b.mul(e).divRound(this.n),s=n.b.neg().mul(e).divRound(this.n),a=o.mul(n.a),d=s.mul(i.a),u=o.mul(n.b),c=s.mul(i.b),l=e.sub(a).sub(d),p=u.add(c).neg();return{k1:l,k2:p}};Dd.prototype.pointFromX=function(e,r){e=new wi(e,16),e.red||(e=e.toRed(this.red));var n=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),i=n.redSqrt();if(i.redSqr().redSub(n).cmp(this.zero)!==0)throw new Error("invalid point");var o=i.fromRed().isOdd();return(r&&!o||!r&&o)&&(i=i.redNeg()),this.point(e,i)};Dd.prototype.validate=function(e){if(e.inf)return!0;var r=e.x,n=e.y,i=this.a.redMul(r),o=r.redSqr().redMul(r).redIAdd(i).redIAdd(this.b);return n.redSqr().redISub(o).cmpn(0)===0};Dd.prototype._endoWnafMulAdd=function(e,r,n){for(var i=this._endoWnafT1,o=this._endoWnafT2,s=0;s":""};Oo.prototype.isInfinity=function(){return this.inf};Oo.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var r=this.y.redSub(e.y);r.cmpn(0)!==0&&(r=r.redMul(this.x.redSub(e.x).redInvm()));var n=r.redSqr().redISub(this.x).redISub(e.x),i=r.redMul(this.x.redSub(n)).redISub(this.y);return this.curve.point(n,i)};Oo.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var r=this.curve.a,n=this.x.redSqr(),i=e.redInvm(),o=n.redAdd(n).redIAdd(n).redIAdd(r).redMul(i),s=o.redSqr().redISub(this.x.redAdd(this.x)),a=o.redMul(this.x.redSub(s)).redISub(this.y);return this.curve.point(s,a)};Oo.prototype.getX=function(){return this.x.fromRed()};Oo.prototype.getY=function(){return this.y.fromRed()};Oo.prototype.mul=function(e){return e=new wi(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)};Oo.prototype.mulAdd=function(e,r,n){var i=[this,r],o=[e,n];return this.curve.endo?this.curve._endoWnafMulAdd(i,o):this.curve._wnafMulAdd(1,i,o,2)};Oo.prototype.jmulAdd=function(e,r,n){var i=[this,r],o=[e,n];return this.curve.endo?this.curve._endoWnafMulAdd(i,o,!0):this.curve._wnafMulAdd(1,i,o,2,!0)};Oo.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)};Oo.prototype.neg=function(e){if(this.inf)return this;var r=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var n=this.precomputed,i=function(o){return o.neg()};r.precomputed={naf:n.naf&&{wnd:n.naf.wnd,points:n.naf.points.map(i)},doubles:n.doubles&&{step:n.doubles.step,points:n.doubles.points.map(i)}}}return r};Oo.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function os(t,e,r,n){Hw.BasePoint.call(this,t,"jacobian"),e===null&&r===null&&n===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new wi(0)):(this.x=new wi(e,16),this.y=new wi(r,16),this.z=new wi(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}vO(os,Hw.BasePoint);Dd.prototype.jpoint=function(e,r,n){return new os(this,e,r,n)};os.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),r=e.redSqr(),n=this.x.redMul(r),i=this.y.redMul(r).redMul(e);return this.curve.point(n,i)};os.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};os.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var r=e.z.redSqr(),n=this.z.redSqr(),i=this.x.redMul(r),o=e.x.redMul(n),s=this.y.redMul(r.redMul(e.z)),a=e.y.redMul(n.redMul(this.z)),d=i.redSub(o),u=s.redSub(a);if(d.cmpn(0)===0)return u.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var c=d.redSqr(),l=c.redMul(d),p=i.redMul(c),m=u.redSqr().redIAdd(l).redISub(p).redISub(p),g=u.redMul(p.redISub(m)).redISub(s.redMul(l)),v=this.z.redMul(e.z).redMul(d);return this.curve.jpoint(m,g,v)};os.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var r=this.z.redSqr(),n=this.x,i=e.x.redMul(r),o=this.y,s=e.y.redMul(r).redMul(this.z),a=n.redSub(i),d=o.redSub(s);if(a.cmpn(0)===0)return d.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),c=u.redMul(a),l=n.redMul(u),p=d.redSqr().redIAdd(c).redISub(l).redISub(l),m=d.redMul(l.redISub(p)).redISub(o.redMul(c)),g=this.z.redMul(a);return this.curve.jpoint(p,m,g)};os.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var r;if(this.curve.zeroA||this.curve.threeA){var n=this;for(r=0;r=0)return!1;if(n.redIAdd(o),this.x.cmp(n)===0)return!0}};os.prototype.inspect=function(){return this.isInfinity()?"":""};os.prototype.isInfinity=function(){return this.z.cmpn(0)===0}});var bte=V((abt,vte)=>{"use strict";f();var Vw=Mo(),gte=Ft(),o4=TE(),Mke=Uc();function Gw(t){o4.call(this,"mont",t),this.a=new Vw(t.a,16).toRed(this.red),this.b=new Vw(t.b,16).toRed(this.red),this.i4=new Vw(4).toRed(this.red).redInvm(),this.two=new Vw(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}gte(Gw,o4);vte.exports=Gw;Gw.prototype.validate=function(e){var r=e.normalize().x,n=r.redSqr(),i=n.redMul(r).redAdd(n.redMul(this.a)).redAdd(r),o=i.redSqrt();return o.redSqr().cmp(i)===0};function Co(t,e,r){o4.BasePoint.call(this,t,"projective"),e===null&&r===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new Vw(e,16),this.z=new Vw(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}gte(Co,o4.BasePoint);Gw.prototype.decodePoint=function(e,r){return this.point(Mke.toArray(e,r),1)};Gw.prototype.point=function(e,r){return new Co(this,e,r)};Gw.prototype.pointFromJSON=function(e){return Co.fromJSON(this,e)};Co.prototype.precompute=function(){};Co.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())};Co.fromJSON=function(e,r){return new Co(e,r[0],r[1]||e.one)};Co.prototype.inspect=function(){return this.isInfinity()?"":""};Co.prototype.isInfinity=function(){return this.z.cmpn(0)===0};Co.prototype.dbl=function(){var e=this.x.redAdd(this.z),r=e.redSqr(),n=this.x.redSub(this.z),i=n.redSqr(),o=r.redSub(i),s=r.redMul(i),a=o.redMul(i.redAdd(this.curve.a24.redMul(o)));return this.curve.point(s,a)};Co.prototype.add=function(){throw new Error("Not supported on Montgomery curve")};Co.prototype.diffAdd=function(e,r){var n=this.x.redAdd(this.z),i=this.x.redSub(this.z),o=e.x.redAdd(e.z),s=e.x.redSub(e.z),a=s.redMul(n),d=o.redMul(i),u=r.z.redMul(a.redAdd(d).redSqr()),c=r.x.redMul(a.redISub(d).redSqr());return this.curve.point(u,c)};Co.prototype.mul=function(e){for(var r=e.clone(),n=this,i=this.curve.point(null,null),o=this,s=[];r.cmpn(0)!==0;r.iushrn(1))s.push(r.andln(1));for(var a=s.length-1;a>=0;a--)s[a]===0?(n=n.diffAdd(i,o),i=i.dbl()):(i=n.diffAdd(i,o),n=n.dbl());return i};Co.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")};Co.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")};Co.prototype.eq=function(e){return this.getX().cmp(e.getX())===0};Co.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this};Co.prototype.getX=function(){return this.normalize(),this.x.fromRed()}});var xte=V((dbt,_te)=>{"use strict";f();var Oke=Uc(),_h=Mo(),wte=Ft(),s4=TE(),Cke=Oke.assert;function jl(t){this.twisted=(t.a|0)!==1,this.mOneA=this.twisted&&(t.a|0)===-1,this.extended=this.mOneA,s4.call(this,"edwards",t),this.a=new _h(t.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new _h(t.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new _h(t.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),Cke(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(t.c|0)===1}wte(jl,s4);_te.exports=jl;jl.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)};jl.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)};jl.prototype.jpoint=function(e,r,n,i){return this.point(e,r,n,i)};jl.prototype.pointFromX=function(e,r){e=new _h(e,16),e.red||(e=e.toRed(this.red));var n=e.redSqr(),i=this.c2.redSub(this.a.redMul(n)),o=this.one.redSub(this.c2.redMul(this.d).redMul(n)),s=i.redMul(o.redInvm()),a=s.redSqrt();if(a.redSqr().redSub(s).cmp(this.zero)!==0)throw new Error("invalid point");var d=a.fromRed().isOdd();return(r&&!d||!r&&d)&&(a=a.redNeg()),this.point(e,a)};jl.prototype.pointFromY=function(e,r){e=new _h(e,16),e.red||(e=e.toRed(this.red));var n=e.redSqr(),i=n.redSub(this.c2),o=n.redMul(this.d).redMul(this.c2).redSub(this.a),s=i.redMul(o.redInvm());if(s.cmp(this.zero)===0){if(r)throw new Error("invalid point");return this.point(this.zero,e)}var a=s.redSqrt();if(a.redSqr().redSub(s).cmp(this.zero)!==0)throw new Error("invalid point");return a.fromRed().isOdd()!==r&&(a=a.redNeg()),this.point(a,e)};jl.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var r=e.x.redSqr(),n=e.y.redSqr(),i=r.redMul(this.a).redAdd(n),o=this.c2.redMul(this.one.redAdd(this.d.redMul(r).redMul(n)));return i.cmp(o)===0};function On(t,e,r,n,i){s4.BasePoint.call(this,t,"projective"),e===null&&r===null&&n===null?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new _h(e,16),this.y=new _h(r,16),this.z=n?new _h(n,16):this.curve.one,this.t=i&&new _h(i,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}wte(On,s4.BasePoint);jl.prototype.pointFromJSON=function(e){return On.fromJSON(this,e)};jl.prototype.point=function(e,r,n,i){return new On(this,e,r,n,i)};On.fromJSON=function(e,r){return new On(e,r[0],r[1],r[2])};On.prototype.inspect=function(){return this.isInfinity()?"":""};On.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)};On.prototype._extDbl=function(){var e=this.x.redSqr(),r=this.y.redSqr(),n=this.z.redSqr();n=n.redIAdd(n);var i=this.curve._mulA(e),o=this.x.redAdd(this.y).redSqr().redISub(e).redISub(r),s=i.redAdd(r),a=s.redSub(n),d=i.redSub(r),u=o.redMul(a),c=s.redMul(d),l=o.redMul(d),p=a.redMul(s);return this.curve.point(u,c,p,l)};On.prototype._projDbl=function(){var e=this.x.redAdd(this.y).redSqr(),r=this.x.redSqr(),n=this.y.redSqr(),i,o,s,a,d,u;if(this.curve.twisted){a=this.curve._mulA(r);var c=a.redAdd(n);this.zOne?(i=e.redSub(r).redSub(n).redMul(c.redSub(this.curve.two)),o=c.redMul(a.redSub(n)),s=c.redSqr().redSub(c).redSub(c)):(d=this.z.redSqr(),u=c.redSub(d).redISub(d),i=e.redSub(r).redISub(n).redMul(u),o=c.redMul(a.redSub(n)),s=c.redMul(u))}else a=r.redAdd(n),d=this.curve._mulC(this.z).redSqr(),u=a.redSub(d).redSub(d),i=this.curve._mulC(e.redISub(a)).redMul(u),o=this.curve._mulC(a).redMul(r.redISub(n)),s=a.redMul(u);return this.curve.point(i,o,s)};On.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()};On.prototype._extAdd=function(e){var r=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),n=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),i=this.t.redMul(this.curve.dd).redMul(e.t),o=this.z.redMul(e.z.redAdd(e.z)),s=n.redSub(r),a=o.redSub(i),d=o.redAdd(i),u=n.redAdd(r),c=s.redMul(a),l=d.redMul(u),p=s.redMul(u),m=a.redMul(d);return this.curve.point(c,l,m,p)};On.prototype._projAdd=function(e){var r=this.z.redMul(e.z),n=r.redSqr(),i=this.x.redMul(e.x),o=this.y.redMul(e.y),s=this.curve.d.redMul(i).redMul(o),a=n.redSub(s),d=n.redAdd(s),u=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(i).redISub(o),c=r.redMul(a).redMul(u),l,p;return this.curve.twisted?(l=r.redMul(d).redMul(o.redSub(this.curve._mulA(i))),p=a.redMul(d)):(l=r.redMul(d).redMul(o.redSub(i)),p=this.curve._mulC(a).redMul(d)),this.curve.point(c,l,p)};On.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)};On.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)};On.prototype.mulAdd=function(e,r,n){return this.curve._wnafMulAdd(1,[this,r],[e,n],2,!1)};On.prototype.jmulAdd=function(e,r,n){return this.curve._wnafMulAdd(1,[this,r],[e,n],2,!0)};On.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this};On.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())};On.prototype.getX=function(){return this.normalize(),this.x.fromRed()};On.prototype.getY=function(){return this.normalize(),this.y.fromRed()};On.prototype.eq=function(e){return this===e||this.getX().cmp(e.getX())===0&&this.getY().cmp(e.getY())===0};On.prototype.eqXToP=function(e){var r=e.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(r)===0)return!0;for(var n=e.clone(),i=this.curve.redN.redMul(this.z);;){if(n.iadd(this.curve.n),n.cmp(this.curve.p)>=0)return!1;if(r.redIAdd(i),this.x.cmp(r)===0)return!0}};On.prototype.toP=On.prototype.normalize;On.prototype.mixedAdd=On.prototype.add});var bO=V(Ete=>{"use strict";f();var a4=Ete;a4.base=TE();a4.short=yte();a4.mont=bte();a4.edwards=xte()});var Iu=V(An=>{"use strict";f();var $ke=Nc(),jke=Ft();An.inherits=jke;function Nke(t,e){return(t.charCodeAt(e)&64512)!==55296||e<0||e+1>=t.length?!1:(t.charCodeAt(e+1)&64512)===56320}function Uke(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if(typeof t=="string")if(e){if(e==="hex")for(t=t.replace(/[^a-z0-9]+/ig,""),t.length%2!==0&&(t="0"+t),i=0;i>6|192,r[n++]=o&63|128):Nke(t,i)?(o=65536+((o&1023)<<10)+(t.charCodeAt(++i)&1023),r[n++]=o>>18|240,r[n++]=o>>12&63|128,r[n++]=o>>6&63|128,r[n++]=o&63|128):(r[n++]=o>>12|224,r[n++]=o>>6&63|128,r[n++]=o&63|128)}else for(i=0;i>>24|t>>>8&65280|t<<8&16711680|(t&255)<<24;return e>>>0}An.htonl=Ste;function Lke(t,e){for(var r="",n=0;n>>0}return o}An.join32=Kke;function Fke(t,e){for(var r=new Array(t.length*4),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=o&255):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=o&255)}return r}An.split32=Fke;function zke(t,e){return t>>>e|t<<32-e}An.rotr32=zke;function Wke(t,e){return t<>>32-e}An.rotl32=Wke;function Hke(t,e){return t+e>>>0}An.sum32=Hke;function Vke(t,e,r){return t+e+r>>>0}An.sum32_3=Vke;function Gke(t,e,r,n){return t+e+r+n>>>0}An.sum32_4=Gke;function Jke(t,e,r,n,i){return t+e+r+n+i>>>0}An.sum32_5=Jke;function Zke(t,e,r,n){var i=t[e],o=t[e+1],s=n+o>>>0,a=(s>>0,t[e+1]=s}An.sum64=Zke;function Yke(t,e,r,n){var i=e+n>>>0,o=(i>>0}An.sum64_hi=Yke;function Xke(t,e,r,n){var i=e+n;return i>>>0}An.sum64_lo=Xke;function Qke(t,e,r,n,i,o,s,a){var d=0,u=e;u=u+n>>>0,d+=u>>0,d+=u>>0,d+=u>>0}An.sum64_4_hi=Qke;function eRe(t,e,r,n,i,o,s,a){var d=e+n+o+a;return d>>>0}An.sum64_4_lo=eRe;function tRe(t,e,r,n,i,o,s,a,d,u){var c=0,l=e;l=l+n>>>0,c+=l>>0,c+=l>>0,c+=l>>0,c+=l>>0}An.sum64_5_hi=tRe;function rRe(t,e,r,n,i,o,s,a,d,u){var c=e+n+o+a+u;return c>>>0}An.sum64_5_lo=rRe;function nRe(t,e,r){var n=e<<32-r|t>>>r;return n>>>0}An.rotr64_hi=nRe;function iRe(t,e,r){var n=t<<32-r|e>>>r;return n>>>0}An.rotr64_lo=iRe;function oRe(t,e,r){return t>>>r}An.shr64_hi=oRe;function sRe(t,e,r){var n=t<<32-r|e>>>r;return n>>>0}An.shr64_lo=sRe});var Jw=V(Ite=>{"use strict";f();var Pte=Iu(),aRe=Nc();function c4(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}Ite.BlockHash=c4;c4.prototype.update=function(e,r){if(e=Pte.toArray(e,r),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){e=this.pending;var n=e.length%this._delta8;this.pending=e.slice(e.length-n,e.length),this.pending.length===0&&(this.pending=null),e=Pte.join32(e,0,e.length-n,this.endian);for(var i=0;i>>24&255,i[o++]=e>>>16&255,i[o++]=e>>>8&255,i[o++]=e&255}else for(i[o++]=e&255,i[o++]=e>>>8&255,i[o++]=e>>>16&255,i[o++]=e>>>24&255,i[o++]=0,i[o++]=0,i[o++]=0,i[o++]=0,s=8;s{"use strict";f();var cRe=Iu(),Nl=cRe.rotr32;function dRe(t,e,r,n){if(t===0)return kte(e,r,n);if(t===1||t===3)return Dte(e,r,n);if(t===2)return Rte(e,r,n)}xh.ft_1=dRe;function kte(t,e,r){return t&e^~t&r}xh.ch32=kte;function Rte(t,e,r){return t&e^t&r^e&r}xh.maj32=Rte;function Dte(t,e,r){return t^e^r}xh.p32=Dte;function uRe(t){return Nl(t,2)^Nl(t,13)^Nl(t,22)}xh.s0_256=uRe;function lRe(t){return Nl(t,6)^Nl(t,11)^Nl(t,25)}xh.s1_256=lRe;function fRe(t){return Nl(t,7)^Nl(t,18)^t>>>3}xh.g0_256=fRe;function hRe(t){return Nl(t,17)^Nl(t,19)^t>>>10}xh.g1_256=hRe});var Ote=V((bbt,Mte)=>{"use strict";f();var Zw=Iu(),pRe=Jw(),mRe=wO(),_O=Zw.rotl32,PE=Zw.sum32,yRe=Zw.sum32_5,gRe=mRe.ft_1,Bte=pRe.BlockHash,vRe=[1518500249,1859775393,2400959708,3395469782];function Ul(){if(!(this instanceof Ul))return new Ul;Bte.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}Zw.inherits(Ul,Bte);Mte.exports=Ul;Ul.blockSize=512;Ul.outSize=160;Ul.hmacStrength=80;Ul.padLength=64;Ul.prototype._update=function(e,r){for(var n=this.W,i=0;i<16;i++)n[i]=e[r+i];for(;i{"use strict";f();var Yw=Iu(),bRe=Jw(),Xw=wO(),wRe=Nc(),ku=Yw.sum32,_Re=Yw.sum32_4,xRe=Yw.sum32_5,ERe=Xw.ch32,SRe=Xw.maj32,ARe=Xw.s0_256,TRe=Xw.s1_256,PRe=Xw.g0_256,IRe=Xw.g1_256,Cte=bRe.BlockHash,kRe=[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];function ql(){if(!(this instanceof ql))return new ql;Cte.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=kRe,this.W=new Array(64)}Yw.inherits(ql,Cte);$te.exports=ql;ql.blockSize=512;ql.outSize=256;ql.hmacStrength=192;ql.padLength=64;ql.prototype._update=function(e,r){for(var n=this.W,i=0;i<16;i++)n[i]=e[r+i];for(;i{"use strict";f();var EO=Iu(),jte=xO();function Eh(){if(!(this instanceof Eh))return new Eh;jte.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}EO.inherits(Eh,jte);Nte.exports=Eh;Eh.blockSize=512;Eh.outSize=224;Eh.hmacStrength=192;Eh.padLength=64;Eh.prototype._digest=function(e){return e==="hex"?EO.toHex32(this.h.slice(0,7),"big"):EO.split32(this.h.slice(0,7),"big")}});var TO=V((Abt,Fte)=>{"use strict";f();var Qa=Iu(),RRe=Jw(),DRe=Nc(),Ll=Qa.rotr64_hi,Kl=Qa.rotr64_lo,qte=Qa.shr64_hi,Lte=Qa.shr64_lo,Em=Qa.sum64,SO=Qa.sum64_hi,AO=Qa.sum64_lo,BRe=Qa.sum64_4_hi,MRe=Qa.sum64_4_lo,ORe=Qa.sum64_5_hi,CRe=Qa.sum64_5_lo,Kte=RRe.BlockHash,$Re=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function Ru(){if(!(this instanceof Ru))return new Ru;Kte.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=$Re,this.W=new Array(160)}Qa.inherits(Ru,Kte);Fte.exports=Ru;Ru.blockSize=1024;Ru.outSize=512;Ru.hmacStrength=192;Ru.padLength=128;Ru.prototype._prepareBlock=function(e,r){for(var n=this.W,i=0;i<32;i++)n[i]=e[r+i];for(;i{"use strict";f();var PO=Iu(),zte=TO();function Sh(){if(!(this instanceof Sh))return new Sh;zte.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}PO.inherits(Sh,zte);Wte.exports=Sh;Sh.blockSize=1024;Sh.outSize=384;Sh.hmacStrength=192;Sh.padLength=128;Sh.prototype._digest=function(e){return e==="hex"?PO.toHex32(this.h.slice(0,12),"big"):PO.split32(this.h.slice(0,12),"big")}});var Vte=V(Qw=>{"use strict";f();Qw.sha1=Ote();Qw.sha224=Ute();Qw.sha256=xO();Qw.sha384=Hte();Qw.sha512=TO()});var Qte=V(Xte=>{"use strict";f();var wg=Iu(),JRe=Jw(),d4=wg.rotl32,Gte=wg.sum32,IE=wg.sum32_3,Jte=wg.sum32_4,Yte=JRe.BlockHash;function Fl(){if(!(this instanceof Fl))return new Fl;Yte.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}wg.inherits(Fl,Yte);Xte.ripemd160=Fl;Fl.blockSize=512;Fl.outSize=160;Fl.hmacStrength=192;Fl.padLength=64;Fl.prototype._update=function(e,r){for(var n=this.h[0],i=this.h[1],o=this.h[2],s=this.h[3],a=this.h[4],d=n,u=i,c=o,l=s,p=a,m=0;m<80;m++){var g=Gte(d4(Jte(n,Zte(m,i,o,s),e[XRe[m]+r],ZRe(m)),eDe[m]),a);n=a,a=s,s=d4(o,10),o=i,i=g,g=Gte(d4(Jte(d,Zte(79-m,u,c,l),e[QRe[m]+r],YRe(m)),tDe[m]),p),d=p,p=l,l=d4(c,10),c=u,u=g}g=IE(this.h[1],o,l),this.h[1]=IE(this.h[2],s,p),this.h[2]=IE(this.h[3],a,d),this.h[3]=IE(this.h[4],n,u),this.h[4]=IE(this.h[0],i,c),this.h[0]=g};Fl.prototype._digest=function(e){return e==="hex"?wg.toHex32(this.h,"little"):wg.split32(this.h,"little")};function Zte(t,e,r,n){return t<=15?e^r^n:t<=31?e&r|~e&n:t<=47?(e|~r)^n:t<=63?e&n|r&~n:e^(r|~n)}function ZRe(t){return t<=15?0:t<=31?1518500249:t<=47?1859775393:t<=63?2400959708:2840853838}function YRe(t){return t<=15?1352829926:t<=31?1548603684:t<=47?1836072691:t<=63?2053994217:0}var XRe=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],QRe=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],eDe=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],tDe=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]});var tre=V((Mbt,ere)=>{"use strict";f();var rDe=Iu(),nDe=Nc();function e1(t,e,r){if(!(this instanceof e1))return new e1(t,e,r);this.Hash=t,this.blockSize=t.blockSize/8,this.outSize=t.outSize/8,this.inner=null,this.outer=null,this._init(rDe.toArray(e,r))}ere.exports=e1;e1.prototype._init=function(e){e.length>this.blockSize&&(e=new this.Hash().update(e).digest()),nDe(e.length<=this.blockSize);for(var r=e.length;r{f();var ss=rre;ss.utils=Iu();ss.common=Jw();ss.sha=Vte();ss.ripemd=Qte();ss.hmac=tre();ss.sha1=ss.sha.sha1;ss.sha256=ss.sha.sha256;ss.sha224=ss.sha.sha224;ss.sha384=ss.sha.sha384;ss.sha512=ss.sha.sha512;ss.ripemd160=ss.ripemd.ripemd160});var ire=V((jbt,nre)=>{f();nre.exports={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}});var l4=V(are=>{"use strict";f();var kO=are,Sm=u4(),IO=bO(),iDe=Uc(),ore=iDe.assert;function sre(t){t.type==="short"?this.curve=new IO.short(t):t.type==="edwards"?this.curve=new IO.edwards(t):this.curve=new IO.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,ore(this.g.validate(),"Invalid curve"),ore(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}kO.PresetCurve=sre;function Am(t,e){Object.defineProperty(kO,t,{configurable:!0,enumerable:!0,get:function(){var r=new sre(e);return Object.defineProperty(kO,t,{configurable:!0,enumerable:!0,value:r}),r}})}Am("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:Sm.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]});Am("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:Sm.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]});Am("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:Sm.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]});Am("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:Sm.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]});Am("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:Sm.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]});Am("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Sm.sha256,gRed:!1,g:["9"]});Am("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Sm.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var RO;try{RO=ire()}catch{RO=void 0}Am("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:Sm.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",RO]})});var ure=V((Lbt,dre)=>{"use strict";f();var oDe=u4(),_g=gO(),cre=Nc();function Tm(t){if(!(this instanceof Tm))return new Tm(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=_g.toArray(t.entropy,t.entropyEnc||"hex"),r=_g.toArray(t.nonce,t.nonceEnc||"hex"),n=_g.toArray(t.pers,t.persEnc||"hex");cre(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,n)}dre.exports=Tm;Tm.prototype._init=function(e,r,n){var i=e.concat(r).concat(n);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var o=0;o=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(n||[])),this._reseed=1};Tm.prototype.generate=function(e,r,n,i){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof r!="string"&&(i=n,n=r,r=null),n&&(n=_g.toArray(n,i||"hex"),this._update(n));for(var o=[];o.length{"use strict";f();var sDe=Mo(),aDe=Uc(),DO=aDe.assert;function Ys(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}lre.exports=Ys;Ys.fromPublic=function(e,r,n){return r instanceof Ys?r:new Ys(e,{pub:r,pubEnc:n})};Ys.fromPrivate=function(e,r,n){return r instanceof Ys?r:new Ys(e,{priv:r,privEnc:n})};Ys.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}};Ys.prototype.getPublic=function(e,r){return typeof e=="string"&&(r=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),r?this.pub.encode(r,e):this.pub};Ys.prototype.getPrivate=function(e){return e==="hex"?this.priv.toString(16,2):this.priv};Ys.prototype._importPrivate=function(e,r){this.priv=new sDe(e,r||16),this.priv=this.priv.umod(this.ec.curve.n)};Ys.prototype._importPublic=function(e,r){if(e.x||e.y){this.ec.curve.type==="mont"?DO(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&DO(e.x&&e.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(e.x,e.y);return}this.pub=this.ec.curve.decodePoint(e,r)};Ys.prototype.derive=function(e){return e.validate()||DO(e.validate(),"public point not validated"),e.mul(this.priv).getX()};Ys.prototype.sign=function(e,r,n){return this.ec.sign(e,this,r,n)};Ys.prototype.verify=function(e,r){return this.ec.verify(e,r,this)};Ys.prototype.inspect=function(){return""}});var mre=V((Wbt,pre)=>{"use strict";f();var f4=Mo(),OO=Uc(),cDe=OO.assert;function h4(t,e){if(t instanceof h4)return t;this._importDER(t,e)||(cDe(t.r&&t.s,"Signature without r or s"),this.r=new f4(t.r,16),this.s=new f4(t.s,16),t.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}pre.exports=h4;function dDe(){this.place=0}function BO(t,e){var r=t[e.place++];if(!(r&128))return r;var n=r&15;if(n===0||n>4||t[e.place]===0)return!1;for(var i=0,o=0,s=e.place;o>>=0;return i<=127?!1:(e.place=s,i)}function hre(t){for(var e=0,r=t.length-1;!t[e]&&!(t[e+1]&128)&&e>>3);for(t.push(r|128);--r;)t.push(e>>>(r<<3)&255);t.push(e)}h4.prototype.toDER=function(e){var r=this.r.toArray(),n=this.s.toArray();for(r[0]&128&&(r=[0].concat(r)),n[0]&128&&(n=[0].concat(n)),r=hre(r),n=hre(n);!n[0]&&!(n[1]&128);)n=n.slice(1);var i=[2];MO(i,r.length),i=i.concat(r),i.push(2),MO(i,n.length);var o=i.concat(n),s=[48];return MO(s,o.length),s=s.concat(o),OO.encode(s,e)}});var bre=V((Vbt,vre)=>{"use strict";f();var xg=Mo(),yre=ure(),uDe=Uc(),CO=l4(),lDe=UA(),gre=uDe.assert,$O=fre(),p4=mre();function Bd(t){if(!(this instanceof Bd))return new Bd(t);typeof t=="string"&&(gre(Object.prototype.hasOwnProperty.call(CO,t),"Unknown curve "+t),t=CO[t]),t instanceof CO.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}vre.exports=Bd;Bd.prototype.keyPair=function(e){return new $O(this,e)};Bd.prototype.keyFromPrivate=function(e,r){return $O.fromPrivate(this,e,r)};Bd.prototype.keyFromPublic=function(e,r){return $O.fromPublic(this,e,r)};Bd.prototype.genKeyPair=function(e){e||(e={});for(var r=new yre({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||lDe(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),n=this.n.byteLength(),i=this.n.sub(new xg(2));;){var o=new xg(r.generate(n));if(!(o.cmp(i)>0))return o.iaddn(1),this.keyFromPrivate(o)}};Bd.prototype._truncateToN=function(e,r){var n=e.byteLength()*8-this.n.bitLength();return n>0&&(e=e.ushrn(n)),!r&&e.cmp(this.n)>=0?e.sub(this.n):e};Bd.prototype.sign=function(e,r,n,i){typeof n=="object"&&(i=n,n=null),i||(i={}),r=this.keyFromPrivate(r,n),e=this._truncateToN(new xg(e,16));for(var o=this.n.byteLength(),s=r.getPrivate().toArray("be",o),a=e.toArray("be",o),d=new yre({hash:this.hash,entropy:s,nonce:a,pers:i.pers,persEnc:i.persEnc||"utf8"}),u=this.n.sub(new xg(1)),c=0;;c++){var l=i.k?i.k(c):new xg(d.generate(this.n.byteLength()));if(l=this._truncateToN(l,!0),!(l.cmpn(1)<=0||l.cmp(u)>=0)){var p=this.g.mul(l);if(!p.isInfinity()){var m=p.getX(),g=m.umod(this.n);if(g.cmpn(0)!==0){var v=l.invm(this.n).mul(g.mul(r.getPrivate()).iadd(e));if(v=v.umod(this.n),v.cmpn(0)!==0){var x=(p.getY().isOdd()?1:0)|(m.cmp(g)!==0?2:0);return i.canonical&&v.cmp(this.nh)>0&&(v=this.n.sub(v),x^=1),new p4({r:g,s:v,recoveryParam:x})}}}}}};Bd.prototype.verify=function(e,r,n,i){e=this._truncateToN(new xg(e,16)),n=this.keyFromPublic(n,i),r=new p4(r,"hex");var o=r.r,s=r.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0||s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var a=s.invm(this.n),d=a.mul(e).umod(this.n),u=a.mul(o).umod(this.n),c;return this.curve._maxwellTrick?(c=this.g.jmulAdd(d,n.getPublic(),u),c.isInfinity()?!1:c.eqXToP(o)):(c=this.g.mulAdd(d,n.getPublic(),u),c.isInfinity()?!1:c.getX().umod(this.n).cmp(o)===0)};Bd.prototype.recoverPubKey=function(t,e,r,n){gre((3&r)===r,"The recovery param is more than two bits"),e=new p4(e,n);var i=this.n,o=new xg(t),s=e.r,a=e.s,d=r&1,u=r>>1;if(s.cmp(this.curve.p.umod(this.curve.n))>=0&&u)throw new Error("Unable to find sencond key candinate");u?s=this.curve.pointFromX(s.add(this.curve.n),d):s=this.curve.pointFromX(s,d);var c=e.r.invm(i),l=i.sub(o).mul(c).umod(i),p=a.mul(c).umod(i);return this.g.mulAdd(l,s,p)};Bd.prototype.getKeyRecoveryParam=function(t,e,r,n){if(e=new p4(e,n),e.recoveryParam!==null)return e.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(t,e,i)}catch{continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")}});var Ere=V((Jbt,xre)=>{"use strict";f();var kE=Uc(),_re=kE.assert,wre=kE.parseBytes,t1=kE.cachedProperty;function $o(t,e){this.eddsa=t,this._secret=wre(e.secret),t.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=wre(e.pub)}$o.fromPublic=function(e,r){return r instanceof $o?r:new $o(e,{pub:r})};$o.fromSecret=function(e,r){return r instanceof $o?r:new $o(e,{secret:r})};$o.prototype.secret=function(){return this._secret};t1($o,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())});t1($o,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())});t1($o,"privBytes",function(){var e=this.eddsa,r=this.hash(),n=e.encodingLength-1,i=r.slice(0,e.encodingLength);return i[0]&=248,i[n]&=127,i[n]|=64,i});t1($o,"priv",function(){return this.eddsa.decodeInt(this.privBytes())});t1($o,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()});t1($o,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)});$o.prototype.sign=function(e){return _re(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)};$o.prototype.verify=function(e,r){return this.eddsa.verify(e,r,this)};$o.prototype.getSecret=function(e){return _re(this._secret,"KeyPair is public only"),kE.encode(this.secret(),e)};$o.prototype.getPublic=function(e){return kE.encode(this.pubBytes(),e)};xre.exports=$o});var Tre=V((Ybt,Are)=>{"use strict";f();var fDe=Mo(),m4=Uc(),Sre=m4.assert,y4=m4.cachedProperty,hDe=m4.parseBytes;function Eg(t,e){this.eddsa=t,typeof e!="object"&&(e=hDe(e)),Array.isArray(e)&&(Sre(e.length===t.encodingLength*2,"Signature has invalid size"),e={R:e.slice(0,t.encodingLength),S:e.slice(t.encodingLength)}),Sre(e.R&&e.S,"Signature without R or S"),t.isPoint(e.R)&&(this._R=e.R),e.S instanceof fDe&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}y4(Eg,"S",function(){return this.eddsa.decodeInt(this.Sencoded())});y4(Eg,"R",function(){return this.eddsa.decodePoint(this.Rencoded())});y4(Eg,"Rencoded",function(){return this.eddsa.encodePoint(this.R())});y4(Eg,"Sencoded",function(){return this.eddsa.encodeInt(this.S())});Eg.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())};Eg.prototype.toHex=function(){return m4.encode(this.toBytes(),"hex").toUpperCase()};Are.exports=Eg});var Dre=V((Qbt,Rre)=>{"use strict";f();var pDe=u4(),mDe=l4(),r1=Uc(),yDe=r1.assert,Ire=r1.parseBytes,kre=Ere(),Pre=Tre();function ec(t){if(yDe(t==="ed25519","only tested with ed25519 so far"),!(this instanceof ec))return new ec(t);t=mDe[t].curve,this.curve=t,this.g=t.g,this.g.precompute(t.n.bitLength()+1),this.pointClass=t.point().constructor,this.encodingLength=Math.ceil(t.n.bitLength()/8),this.hash=pDe.sha512}Rre.exports=ec;ec.prototype.sign=function(e,r){e=Ire(e);var n=this.keyFromSecret(r),i=this.hashInt(n.messagePrefix(),e),o=this.g.mul(i),s=this.encodePoint(o),a=this.hashInt(s,n.pubBytes(),e).mul(n.priv()),d=i.add(a).umod(this.curve.n);return this.makeSignature({R:o,S:d,Rencoded:s})};ec.prototype.verify=function(e,r,n){if(e=Ire(e),r=this.makeSignature(r),r.S().gte(r.eddsa.curve.n)||r.S().isNeg())return!1;var i=this.keyFromPublic(n),o=this.hashInt(r.Rencoded(),i.pubBytes(),e),s=this.g.mul(r.S()),a=r.R().add(i.pub().mul(o));return a.eq(s)};ec.prototype.hashInt=function(){for(var e=this.hash(),r=0;r{"use strict";f();var Sg=Bre;Sg.version=dte().version;Sg.utils=Uc();Sg.rand=UA();Sg.curve=bO();Sg.curves=l4();Sg.ec=bre();Sg.eddsa=Dre()});var Cre=V(Ore=>{f();var Mre=i1(),gDe=Ft(),vDe=Ore;vDe.define=function(e,r){return new n1(e,r)};function n1(t,e){this.name=t,this.body=e,this.decoders={},this.encoders={}}n1.prototype._createNamed=function(e){var r;try{r=e2e("vm").runInThisContext("(function "+this.name+`(entity) { this._initNamed(entity); -})`)}catch{r=function(i){this._initNamed(i)}}return uDe(r,e),r.prototype._initNamed=function(i){e.call(this,i)},new r(this)};n1.prototype._getDecoder=function(e){return e=e||"der",this.decoders.hasOwnProperty(e)||(this.decoders[e]=this._createNamed(Pre.decoders[e])),this.decoders[e]};n1.prototype.decode=function(e,r,n){return this._getDecoder(r).decode(e,n)};n1.prototype._getEncoder=function(e){return e=e||"der",this.encoders.hasOwnProperty(e)||(this.encoders[e]=this._createNamed(Pre.encoders[e])),this.encoders[e]};n1.prototype.encode=function(e,r,n){return this._getEncoder(r).encode(e,n)}});var Dre=V(Rre=>{f();var fDe=Ft();function Dd(t){this._reporterState={obj:null,path:[],options:t||{},errors:[]}}Rre.Reporter=Dd;Dd.prototype.isError=function(e){return e instanceof o1};Dd.prototype.save=function(){var e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}};Dd.prototype.restore=function(e){var r=this._reporterState;r.obj=e.obj,r.path=r.path.slice(0,e.pathLen)};Dd.prototype.enterKey=function(e){return this._reporterState.path.push(e)};Dd.prototype.exitKey=function(e){var r=this._reporterState;r.path=r.path.slice(0,e-1)};Dd.prototype.leaveKey=function(e,r,n){var i=this._reporterState;this.exitKey(e),i.obj!==null&&(i.obj[r]=n)};Dd.prototype.path=function(){return this._reporterState.path.join("/")};Dd.prototype.enterObject=function(){var e=this._reporterState,r=e.obj;return e.obj={},r};Dd.prototype.leaveObject=function(e){var r=this._reporterState,n=r.obj;return r.obj=e,n};Dd.prototype.error=function(e){var r,n=this._reporterState,i=e instanceof o1;if(i?r=e:r=new o1(n.path.map(function(o){return"["+JSON.stringify(o)+"]"}).join(""),e.message||e,e.stack),!n.options.partial)throw r;return i||n.errors.push(r),r};Dd.prototype.wrapResult=function(e){var r=this._reporterState;return r.options.partial?{result:this.isError(e)?null:e,errors:r.errors}:e};function o1(t,e){this.path=t,this.rethrow(e)}fDe(o1,Error);o1.prototype.rethrow=function(e){if(this.message=e+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,o1),!this.stack)try{throw new Error(this.message)}catch(r){this.stack=r.stack}return this}});var MO=V(BO=>{f();var hDe=Ft(),pA=s1().Reporter,PE=hn().Buffer;function Fl(t,e){if(pA.call(this,e),!PE.isBuffer(t)){this.error("Input not Buffer");return}this.base=t,this.offset=0,this.length=t.length}hDe(Fl,pA);BO.DecoderBuffer=Fl;Fl.prototype.save=function(){return{offset:this.offset,reporter:pA.prototype.save.call(this)}};Fl.prototype.restore=function(e){var r=new Fl(this.base);return r.offset=e.offset,r.length=this.offset,this.offset=e.offset,pA.prototype.restore.call(this,e.reporter),r};Fl.prototype.isEmpty=function(){return this.offset===this.length};Fl.prototype.readUInt8=function(e){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(e||"DecoderBuffer overrun")};Fl.prototype.skip=function(e,r){if(!(this.offset+e<=this.length))return this.error(r||"DecoderBuffer overrun");var n=new Fl(this.base);return n._reporterState=this._reporterState,n.offset=this.offset,n.length=this.offset+e,this.offset+=e,n};Fl.prototype.raw=function(e){return this.base.slice(e?e.offset:this.offset,this.length)};function hA(t,e){if(Array.isArray(t))this.length=0,this.value=t.map(function(r){return r instanceof hA||(r=new hA(r,e)),this.length+=r.length,r},this);else if(typeof t=="number"){if(!(0<=t&&t<=255))return e.error("non-byte EncoderBuffer value");this.value=t,this.length=1}else if(typeof t=="string")this.value=t,this.length=PE.byteLength(t);else if(PE.isBuffer(t))this.value=t,this.length=t.length;else return e.error("Unsupported type: "+typeof t)}BO.EncoderBuffer=hA;hA.prototype.join=function(e,r){return e||(e=new PE(this.length)),r||(r=0),this.length===0||(Array.isArray(this.value)?this.value.forEach(function(n){n.join(e,r),r+=n.length}):(typeof this.value=="number"?e[r]=this.value:typeof this.value=="string"?e.write(this.value,r):PE.isBuffer(this.value)&&this.value.copy(e,r),r+=this.length)),e}});var Ore=V((awt,Mre)=>{f();var pDe=s1().Reporter,mDe=s1().EncoderBuffer,yDe=s1().DecoderBuffer,Aa=Cc(),Bre=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],gDe=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(Bre),vDe=["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"];function mn(t,e){var r={};this._baseState=r,r.enc=t,r.parent=e||null,r.children=null,r.tag=null,r.args=null,r.reverseArgs=null,r.choice=null,r.optional=!1,r.any=!1,r.obj=!1,r.use=null,r.useDecoder=null,r.key=null,r.default=null,r.explicit=null,r.implicit=null,r.contains=null,r.parent||(r.children=[],this._wrap())}Mre.exports=mn;var bDe=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];mn.prototype.clone=function(){var e=this._baseState,r={};bDe.forEach(function(i){r[i]=e[i]});var n=new this.constructor(r.parent);return n._baseState=r,n};mn.prototype._wrap=function(){var e=this._baseState;gDe.forEach(function(r){this[r]=function(){var i=new this.constructor(this);return e.children.push(i),i[r].apply(i,arguments)}},this)};mn.prototype._init=function(e){var r=this._baseState;Aa(r.parent===null),e.call(this),r.children=r.children.filter(function(n){return n._baseState.parent===this},this),Aa.equal(r.children.length,1,"Root node can have only one child")};mn.prototype._useArgs=function(e){var r=this._baseState,n=e.filter(function(i){return i instanceof this.constructor},this);e=e.filter(function(i){return!(i instanceof this.constructor)},this),n.length!==0&&(Aa(r.children===null),r.children=n,n.forEach(function(i){i._baseState.parent=this},this)),e.length!==0&&(Aa(r.args===null),r.args=e,r.reverseArgs=e.map(function(i){if(typeof i!="object"||i.constructor!==Object)return i;var o={};return Object.keys(i).forEach(function(s){s==(s|0)&&(s|=0);var a=i[s];o[a]=s}),o}))};vDe.forEach(function(t){mn.prototype[t]=function(){var r=this._baseState;throw new Error(t+" not implemented for encoding: "+r.enc)}});Bre.forEach(function(t){mn.prototype[t]=function(){var r=this._baseState,n=Array.prototype.slice.call(arguments);return Aa(r.tag===null),r.tag=t,this._useArgs(n),this}});mn.prototype.use=function(e){Aa(e);var r=this._baseState;return Aa(r.use===null),r.use=e,this};mn.prototype.optional=function(){var e=this._baseState;return e.optional=!0,this};mn.prototype.def=function(e){var r=this._baseState;return Aa(r.default===null),r.default=e,r.optional=!0,this};mn.prototype.explicit=function(e){var r=this._baseState;return Aa(r.explicit===null&&r.implicit===null),r.explicit=e,this};mn.prototype.implicit=function(e){var r=this._baseState;return Aa(r.explicit===null&&r.implicit===null),r.implicit=e,this};mn.prototype.obj=function(){var e=this._baseState,r=Array.prototype.slice.call(arguments);return e.obj=!0,r.length!==0&&this._useArgs(r),this};mn.prototype.key=function(e){var r=this._baseState;return Aa(r.key===null),r.key=e,this};mn.prototype.any=function(){var e=this._baseState;return e.any=!0,this};mn.prototype.choice=function(e){var r=this._baseState;return Aa(r.choice===null),r.choice=e,this._useArgs(Object.keys(e).map(function(n){return e[n]})),this};mn.prototype.contains=function(e){var r=this._baseState;return Aa(r.use===null),r.contains=e,this};mn.prototype._decode=function(e,r){var n=this._baseState;if(n.parent===null)return e.wrapResult(n.children[0]._decode(e,r));var i=n.default,o=!0,s=null;if(n.key!==null&&(s=e.enterKey(n.key)),n.optional){var a=null;if(n.explicit!==null?a=n.explicit:n.implicit!==null?a=n.implicit:n.tag!==null&&(a=n.tag),a===null&&!n.any){var d=e.save();try{n.choice===null?this._decodeGeneric(n.tag,e,r):this._decodeChoice(e,r),o=!0}catch{o=!1}e.restore(d)}else if(o=this._peekTag(e,a,n.any),e.isError(o))return o}var u;if(n.obj&&o&&(u=e.enterObject()),o){if(n.explicit!==null){var c=this._decodeTag(e,n.explicit);if(e.isError(c))return c;e=c}var l=e.offset;if(n.use===null&&n.choice===null){if(n.any)var d=e.save();var p=this._decodeTag(e,n.implicit!==null?n.implicit:n.tag,n.any);if(e.isError(p))return p;n.any?i=e.raw(d):e=p}if(r&&r.track&&n.tag!==null&&r.track(e.path(),l,e.length,"tagged"),r&&r.track&&n.tag!==null&&r.track(e.path(),e.offset,e.length,"content"),n.any?i=i:n.choice===null?i=this._decodeGeneric(n.tag,e,r):i=this._decodeChoice(e,r),e.isError(i))return i;if(!n.any&&n.choice===null&&n.children!==null&&n.children.forEach(function(v){v._decode(e,r)}),n.contains&&(n.tag==="octstr"||n.tag==="bitstr")){var m=new yDe(i);i=this._getUse(n.contains,e._reporterState.obj)._decode(m,r)}}return n.obj&&o&&(i=e.leaveObject(u)),n.key!==null&&(i!==null||o===!0)?e.leaveKey(s,n.key,i):s!==null&&e.exitKey(s),i};mn.prototype._decodeGeneric=function(e,r,n){var i=this._baseState;return e==="seq"||e==="set"?null:e==="seqof"||e==="setof"?this._decodeList(r,e,i.args[0],n):/str$/.test(e)?this._decodeStr(r,e,n):e==="objid"&&i.args?this._decodeObjid(r,i.args[0],i.args[1],n):e==="objid"?this._decodeObjid(r,null,null,n):e==="gentime"||e==="utctime"?this._decodeTime(r,e,n):e==="null_"?this._decodeNull(r,n):e==="bool"?this._decodeBool(r,n):e==="objDesc"?this._decodeStr(r,e,n):e==="int"||e==="enum"?this._decodeInt(r,i.args&&i.args[0],n):i.use!==null?this._getUse(i.use,r._reporterState.obj)._decode(r,n):r.error("unknown tag: "+e)};mn.prototype._getUse=function(e,r){var n=this._baseState;return n.useDecoder=this._use(e,r),Aa(n.useDecoder._baseState.parent===null),n.useDecoder=n.useDecoder._baseState.children[0],n.implicit!==n.useDecoder._baseState.implicit&&(n.useDecoder=n.useDecoder.clone(),n.useDecoder._baseState.implicit=n.implicit),n.useDecoder};mn.prototype._decodeChoice=function(e,r){var n=this._baseState,i=null,o=!1;return Object.keys(n.choice).some(function(s){var a=e.save(),d=n.choice[s];try{var u=d._decode(e,r);if(e.isError(u))return!1;i={type:s,value:u},o=!0}catch{return e.restore(a),!1}return!0},this),o?i:e.error("Choice not matched")};mn.prototype._createEncoderBuffer=function(e){return new mDe(e,this.reporter)};mn.prototype._encode=function(e,r,n){var i=this._baseState;if(!(i.default!==null&&i.default===e)){var o=this._encodeValue(e,r,n);if(o!==void 0&&!this._skipDefault(o,r,n))return o}};mn.prototype._encodeValue=function(e,r,n){var i=this._baseState;if(i.parent===null)return i.children[0]._encode(e,r||new pDe);var d=null;if(this.reporter=r,i.optional&&e===void 0)if(i.default!==null)e=i.default;else return;var o=null,s=!1;if(i.any)d=this._createEncoderBuffer(e);else if(i.choice)d=this._encodeChoice(e,r);else if(i.contains)o=this._getUse(i.contains,n)._encode(e,r),s=!0;else if(i.children)o=i.children.map(function(l){if(l._baseState.tag==="null_")return l._encode(null,r,e);if(l._baseState.key===null)return r.error("Child should have a key");var p=r.enterKey(l._baseState.key);if(typeof e!="object")return r.error("Child expected, but input is not object");var m=l._encode(e[l._baseState.key],r,e);return r.leaveKey(p),m},this).filter(function(l){return l}),o=this._createEncoderBuffer(o);else if(i.tag==="seqof"||i.tag==="setof"){if(!(i.args&&i.args.length===1))return r.error("Too many args for : "+i.tag);if(!Array.isArray(e))return r.error("seqof/setof, but data is not Array");var a=this.clone();a._baseState.implicit=null,o=this._createEncoderBuffer(e.map(function(l){var p=this._baseState;return this._getUse(p.args[0],e)._encode(l,r)},a))}else i.use!==null?d=this._getUse(i.use,n)._encode(e,r):(o=this._encodePrimitive(i.tag,e),s=!0);var d;if(!i.any&&i.choice===null){var u=i.implicit!==null?i.implicit:i.tag,c=i.implicit===null?"universal":"context";u===null?i.use===null&&r.error("Tag could be omitted only for .use()"):i.use===null&&(d=this._encodeComposite(u,s,c,o))}return i.explicit!==null&&(d=this._encodeComposite(i.explicit,!1,"context",d)),d};mn.prototype._encodeChoice=function(e,r){var n=this._baseState,i=n.choice[e.type];return i||Aa(!1,e.type+" not found in "+JSON.stringify(Object.keys(n.choice))),i._encode(e.value,r)};mn.prototype._encodePrimitive=function(e,r){var n=this._baseState;if(/str$/.test(e))return this._encodeStr(r,e);if(e==="objid"&&n.args)return this._encodeObjid(r,n.reverseArgs[0],n.args[1]);if(e==="objid")return this._encodeObjid(r,null,null);if(e==="gentime"||e==="utctime")return this._encodeTime(r,e);if(e==="null_")return this._encodeNull();if(e==="int"||e==="enum")return this._encodeInt(r,n.args&&n.reverseArgs[0]);if(e==="bool")return this._encodeBool(r);if(e==="objDesc")return this._encodeStr(r,e);throw new Error("Unsupported tag: "+e)};mn.prototype._isNumstr=function(e){return/^[0-9 ]*$/.test(e)};mn.prototype._isPrintstr=function(e){return/^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(e)}});var s1=V(Cre=>{f();var mA=Cre;mA.Reporter=Dre().Reporter;mA.DecoderBuffer=MO().DecoderBuffer;mA.EncoderBuffer=MO().EncoderBuffer;mA.Node=Ore()});var jre=V(Sg=>{f();var $re=OO();Sg.tagClass={0:"universal",1:"application",2:"context",3:"private"};Sg.tagClassByName=$re._reverse(Sg.tagClass);Sg.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"};Sg.tagByName=$re._reverse(Sg.tag)});var OO=V(Ure=>{f();var Nre=Ure;Nre._reverse=function(e){var r={};return Object.keys(e).forEach(function(n){(n|0)==n&&(n=n|0);var i=e[n];r[i]=n}),r};Nre.der=jre()});var jO=V((mwt,Fre)=>{f();var wDe=Ft(),CO=i1(),yA=CO.base,_De=CO.bignum,qre=CO.constants.der;function Lre(t){this.enc="der",this.name=t.name,this.entity=t,this.tree=new jc,this.tree._init(t.body)}Fre.exports=Lre;Lre.prototype.decode=function(e,r){return e instanceof yA.DecoderBuffer||(e=new yA.DecoderBuffer(e,r)),this.tree._decode(e,r)};function jc(t){yA.Node.call(this,"der",t)}wDe(jc,yA.Node);jc.prototype._peekTag=function(e,r,n){if(e.isEmpty())return!1;var i=e.save(),o=$O(e,'Failed to peek tag: "'+r+'"');return e.isError(o)?o:(e.restore(i),o.tag===r||o.tagStr===r||o.tagStr+"of"===r||n)};jc.prototype._decodeTag=function(e,r,n){var i=$O(e,'Failed to decode tag of "'+r+'"');if(e.isError(i))return i;var o=Kre(e,i.primitive,'Failed to get length of "'+r+'"');if(e.isError(o))return o;if(!n&&i.tag!==r&&i.tagStr!==r&&i.tagStr+"of"!==r)return e.error('Failed to match tag: "'+r+'"');if(i.primitive||o!==null)return e.skip(o,'Failed to match body of: "'+r+'"');var s=e.save(),a=this._skipUntilEnd(e,'Failed to skip indefinite length body: "'+this.tag+'"');return e.isError(a)?a:(o=e.offset-s.offset,e.restore(s),e.skip(o,'Failed to match body of: "'+r+'"'))};jc.prototype._skipUntilEnd=function(e,r){for(;;){var n=$O(e,r);if(e.isError(n))return n;var i=Kre(e,n.primitive,r);if(e.isError(i))return i;var o;if(n.primitive||i!==null?o=e.skip(i):o=this._skipUntilEnd(e,r),e.isError(o))return o;if(n.tagStr==="end")break}};jc.prototype._decodeList=function(e,r,n,i){for(var o=[];!e.isEmpty();){var s=this._peekTag(e,"end");if(e.isError(s))return s;var a=n.decode(e,"der",i);if(e.isError(a)&&s)break;o.push(a)}return o};jc.prototype._decodeStr=function(e,r){if(r==="bitstr"){var n=e.readUInt8();return e.isError(n)?n:{unused:n,data:e.raw()}}else if(r==="bmpstr"){var i=e.raw();if(i.length%2===1)return e.error("Decoding of string type: bmpstr length mismatch");for(var o="",s=0;s>6],i=(r&32)===0;if((r&31)===31){var o=r;for(r=0;(o&128)===128;){if(o=t.readUInt8(e),t.isError(o))return o;r<<=7,r|=o&127}}else r&=31;var s=qre.tag[r];return{cls:n,primitive:i,tag:r,tagStr:s}}function Kre(t,e,r){var n=t.readUInt8(r);if(t.isError(n))return n;if(!e&&n===128)return null;if(!(n&128))return n;var i=n&127;if(i>4)return t.error("length octect is too long");n=0;for(var o=0;o{f();var xDe=Ft(),EDe=hn().Buffer,NO=jO();function UO(t){NO.call(this,t),this.enc="pem"}xDe(UO,NO);zre.exports=UO;UO.prototype.decode=function(e,r){for(var n=e.toString().split(/[\r\n]+/g),i=r.label.toUpperCase(),o=/^-----(BEGIN|END) ([^-]+)-----$/,s=-1,a=-1,d=0;d{f();var Hre=Vre;Hre.der=jO();Hre.pem=Wre()});var LO=V((_wt,Xre)=>{f();var SDe=Ft(),Sh=hn().Buffer,Jre=i1(),Zre=Jre.base,qO=Jre.constants.der;function Yre(t){this.enc="der",this.name=t.name,this.entity=t,this.tree=new Ru,this.tree._init(t.body)}Xre.exports=Yre;Yre.prototype.encode=function(e,r){return this.tree._encode(e,r).join()};function Ru(t){Zre.Node.call(this,"der",t)}SDe(Ru,Zre.Node);Ru.prototype._encodeComposite=function(e,r,n,i){var o=ADe(e,r,n,this.reporter);if(i.length<128){var d=new Sh(2);return d[0]=o,d[1]=i.length,this._createEncoderBuffer([d,i])}for(var s=1,a=i.length;a>=256;a>>=8)s++;var d=new Sh(2+s);d[0]=o,d[1]=128|s;for(var a=1+s,u=i.length;u>0;a--,u>>=8)d[a]=u&255;return this._createEncoderBuffer([d,i])};Ru.prototype._encodeStr=function(e,r){if(r==="bitstr")return this._createEncoderBuffer([e.unused|0,e.data]);if(r==="bmpstr"){for(var n=new Sh(e.length*2),i=0;i=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,e[0]*40+e[1])}for(var o=0,i=0;i=128;s>>=7)o++}for(var a=new Sh(o),d=a.length-1,i=e.length-1;i>=0;i--){var s=e[i];for(a[d--]=s&127;(s>>=7)>0;)a[d--]=128|s&127}return this._createEncoderBuffer(a)};function Bd(t){return t<10?"0"+t:t}Ru.prototype._encodeTime=function(e,r){var n,i=new Date(e);return r==="gentime"?n=[Bd(i.getFullYear()),Bd(i.getUTCMonth()+1),Bd(i.getUTCDate()),Bd(i.getUTCHours()),Bd(i.getUTCMinutes()),Bd(i.getUTCSeconds()),"Z"].join(""):r==="utctime"?n=[Bd(i.getFullYear()%100),Bd(i.getUTCMonth()+1),Bd(i.getUTCDate()),Bd(i.getUTCHours()),Bd(i.getUTCMinutes()),Bd(i.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+r+" time is not supported yet"),this._encodeStr(n,"octstr")};Ru.prototype._encodeNull=function(){return this._createEncoderBuffer("")};Ru.prototype._encodeInt=function(e,r){if(typeof e=="string"){if(!r)return this.reporter.error("String int or enum given, but no values map");if(!r.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=r[e]}if(typeof e!="number"&&!Sh.isBuffer(e)){var n=e.toArray();!e.sign&&n[0]&128&&n.unshift(0),e=new Sh(n)}if(Sh.isBuffer(e)){var i=e.length;e.length===0&&i++;var s=new Sh(i);return e.copy(s),e.length===0&&(s[0]=0),this._createEncoderBuffer(s)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);for(var i=1,o=e;o>=256;o>>=8)i++;for(var s=new Array(i),o=s.length-1;o>=0;o--)s[o]=e&255,e>>=8;return s[0]&128&&s.unshift(0),this._createEncoderBuffer(new Sh(s))};Ru.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)};Ru.prototype._use=function(e,r){return typeof e=="function"&&(e=e(r)),e._getEncoder("der").tree};Ru.prototype._skipDefault=function(e,r,n){var i=this._baseState,o;if(i.default===null)return!1;var s=e.join();if(i.defaultBuffer===void 0&&(i.defaultBuffer=this._encodeValue(i.default,r,n).join()),s.length!==i.defaultBuffer.length)return!1;for(o=0;o=31?n.error("Multi-octet tag encoding unsupported"):(e||(i|=32),i|=qO.tagClassByName[r||"universal"]<<6,i)}});var ene=V((Ewt,Qre)=>{f();var TDe=Ft(),KO=LO();function FO(t){KO.call(this,t),this.enc="pem"}TDe(FO,KO);Qre.exports=FO;FO.prototype.encode=function(e,r){for(var n=KO.prototype.encode.call(this,e),i=n.toString("base64"),o=["-----BEGIN "+r.label+"-----"],s=0;s{f();var tne=rne;tne.der=LO();tne.pem=ene()});var i1=V(ine=>{f();var a1=ine;a1.bignum=Mo();a1.define=kre().define;a1.base=s1();a1.constants=OO();a1.decoders=Gre();a1.encoders=nne()});var cne=V((kwt,ane)=>{"use strict";f();var Du=i1(),one=Du.define("Time",function(){this.choice({utcTime:this.utctime(),generalTime:this.gentime()})}),PDe=Du.define("AttributeTypeValue",function(){this.seq().obj(this.key("type").objid(),this.key("value").any())}),zO=Du.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional(),this.key("curve").objid().optional())}),IDe=Du.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(zO),this.key("subjectPublicKey").bitstr())}),kDe=Du.define("RelativeDistinguishedName",function(){this.setof(PDe)}),RDe=Du.define("RDNSequence",function(){this.seqof(kDe)}),sne=Du.define("Name",function(){this.choice({rdnSequence:this.use(RDe)})}),DDe=Du.define("Validity",function(){this.seq().obj(this.key("notBefore").use(one),this.key("notAfter").use(one))}),BDe=Du.define("Extension",function(){this.seq().obj(this.key("extnID").objid(),this.key("critical").bool().def(!1),this.key("extnValue").octstr())}),MDe=Du.define("TBSCertificate",function(){this.seq().obj(this.key("version").explicit(0).int().optional(),this.key("serialNumber").int(),this.key("signature").use(zO),this.key("issuer").use(sne),this.key("validity").use(DDe),this.key("subject").use(sne),this.key("subjectPublicKeyInfo").use(IDe),this.key("issuerUniqueID").implicit(1).bitstr().optional(),this.key("subjectUniqueID").implicit(2).bitstr().optional(),this.key("extensions").explicit(3).seqof(BDe).optional())}),ODe=Du.define("X509Certificate",function(){this.seq().obj(this.key("tbsCertificate").use(MDe),this.key("signatureAlgorithm").use(zO),this.key("signatureValue").bitstr())});ane.exports=ODe});var une=V(Mu=>{"use strict";f();var Bu=i1();Mu.certificate=cne();var CDe=Bu.define("RSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("modulus").int(),this.key("publicExponent").int(),this.key("privateExponent").int(),this.key("prime1").int(),this.key("prime2").int(),this.key("exponent1").int(),this.key("exponent2").int(),this.key("coefficient").int())});Mu.RSAPrivateKey=CDe;var $De=Bu.define("RSAPublicKey",function(){this.seq().obj(this.key("modulus").int(),this.key("publicExponent").int())});Mu.RSAPublicKey=$De;var dne=Bu.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("none").null_().optional(),this.key("curve").objid().optional(),this.key("params").seq().obj(this.key("p").int(),this.key("q").int(),this.key("g").int()).optional())}),jDe=Bu.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(dne),this.key("subjectPublicKey").bitstr())});Mu.PublicKey=jDe;var NDe=Bu.define("PrivateKeyInfo",function(){this.seq().obj(this.key("version").int(),this.key("algorithm").use(dne),this.key("subjectPrivateKey").octstr())});Mu.PrivateKey=NDe;var UDe=Bu.define("EncryptedPrivateKeyInfo",function(){this.seq().obj(this.key("algorithm").seq().obj(this.key("id").objid(),this.key("decrypt").seq().obj(this.key("kde").seq().obj(this.key("id").objid(),this.key("kdeparams").seq().obj(this.key("salt").octstr(),this.key("iters").int())),this.key("cipher").seq().obj(this.key("algo").objid(),this.key("iv").octstr()))),this.key("subjectPrivateKey").octstr())});Mu.EncryptedPrivateKey=UDe;var qDe=Bu.define("DSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("p").int(),this.key("q").int(),this.key("g").int(),this.key("pub_key").int(),this.key("priv_key").int())});Mu.DSAPrivateKey=qDe;Mu.DSAparam=Bu.define("DSAparam",function(){this.int()});var LDe=Bu.define("ECParameters",function(){this.choice({namedCurve:this.objid()})}),KDe=Bu.define("ECPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").optional().explicit(0).use(LDe),this.key("publicKey").optional().explicit(1).bitstr())});Mu.ECPrivateKey=KDe;Mu.signature=Bu.define("signature",function(){this.seq().obj(this.key("r").int(),this.key("s").int())})});var lne=V((Mwt,FDe)=>{FDe.exports={"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"}});var hne=V((Owt,fne)=>{"use strict";f();var zDe=/Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r+/=]+)[\n\r]+/m,WDe=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m,HDe=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m,VDe=uE(),GDe=M4(),gA=cr().Buffer;fne.exports=function(t,e){var r=t.toString(),n=r.match(zDe),i;if(n){var s="aes"+n[1],a=gA.from(n[2],"hex"),d=gA.from(n[3].replace(/[\r\n]/g,""),"base64"),u=VDe(e,a.slice(0,8),parseInt(n[1],10)).key,c=[],l=GDe.createDecipheriv(s,u,a);c.push(l.update(d)),c.push(l.final()),i=gA.concat(c)}else{var o=r.match(HDe);i=gA.from(o[2].replace(/[\r\n]/g,""),"base64")}var p=r.match(WDe)[1];return{tag:p,data:i}}});var IE=V(($wt,mne)=>{"use strict";f();var ec=une(),JDe=lne(),ZDe=hne(),YDe=M4(),XDe=hM(),WO=cr().Buffer;function QDe(t,e){var r=t.algorithm.decrypt.kde.kdeparams.salt,n=parseInt(t.algorithm.decrypt.kde.kdeparams.iters.toString(),10),i=JDe[t.algorithm.decrypt.cipher.algo.join(".")],o=t.algorithm.decrypt.cipher.iv,s=t.subjectPrivateKey,a=parseInt(i.split("-")[1],10)/8,d=XDe.pbkdf2Sync(e,r,n,a,"sha1"),u=YDe.createDecipheriv(i,d,o),c=[];return c.push(u.update(s)),c.push(u.final()),WO.concat(c)}function pne(t){var e;typeof t=="object"&&!WO.isBuffer(t)&&(e=t.passphrase,t=t.key),typeof t=="string"&&(t=WO.from(t));var r=ZDe(t,e),n=r.tag,i=r.data,o,s;switch(n){case"CERTIFICATE":s=ec.certificate.decode(i,"der").tbsCertificate.subjectPublicKeyInfo;case"PUBLIC KEY":switch(s||(s=ec.PublicKey.decode(i,"der")),o=s.algorithm.algorithm.join("."),o){case"1.2.840.113549.1.1.1":return ec.RSAPublicKey.decode(s.subjectPublicKey.data,"der");case"1.2.840.10045.2.1":return s.subjectPrivateKey=s.subjectPublicKey,{type:"ec",data:s};case"1.2.840.10040.4.1":return s.algorithm.params.pub_key=ec.DSAparam.decode(s.subjectPublicKey.data,"der"),{type:"dsa",data:s.algorithm.params};default:throw new Error("unknown key id "+o)}case"ENCRYPTED PRIVATE KEY":i=ec.EncryptedPrivateKey.decode(i,"der"),i=QDe(i,e);case"PRIVATE KEY":switch(s=ec.PrivateKey.decode(i,"der"),o=s.algorithm.algorithm.join("."),o){case"1.2.840.113549.1.1.1":return ec.RSAPrivateKey.decode(s.subjectPrivateKey,"der");case"1.2.840.10045.2.1":return{curve:s.algorithm.curve,privateKey:ec.ECPrivateKey.decode(s.subjectPrivateKey,"der").privateKey};case"1.2.840.10040.4.1":return s.algorithm.params.priv_key=ec.DSAparam.decode(s.subjectPrivateKey,"der"),{type:"dsa",params:s.algorithm.params};default:throw new Error("unknown key id "+o)}case"RSA PUBLIC KEY":return ec.RSAPublicKey.decode(i,"der");case"RSA PRIVATE KEY":return ec.RSAPrivateKey.decode(i,"der");case"DSA PRIVATE KEY":return{type:"dsa",params:ec.DSAPrivateKey.decode(i,"der")};case"EC PRIVATE KEY":return i=ec.ECPrivateKey.decode(i,"der"),{curve:i.parameters.value,privateKey:i.privateKey};default:throw new Error("unknown key type "+n)}}pne.signature=ec.signature;mne.exports=pne});var HO=V((Nwt,e9e)=>{e9e.exports={"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"}});var vne=V((Uwt,bA)=>{"use strict";f();var Ys=cr().Buffer,Ag=nM(),t9e=J4(),r9e=fA().ec,vA=G4(),n9e=IE(),i9e=HO(),o9e=1;function s9e(t,e,r,n,i){var o=n9e(e);if(o.curve){if(n!=="ecdsa"&&n!=="ecdsa/rsa")throw new Error("wrong private key type");return a9e(t,o)}else if(o.type==="dsa"){if(n!=="dsa")throw new Error("wrong private key type");return c9e(t,o,r)}if(n!=="rsa"&&n!=="ecdsa/rsa")throw new Error("wrong private key type");if(e.padding!==void 0&&e.padding!==o9e)throw new Error("illegal or unsupported padding mode");t=Ys.concat([i,t]);for(var s=o.modulus.byteLength(),a=[0,1];t.length+a.length+10&&r.ishrn(n),r}function u9e(t,e){t=VO(t,e),t=t.mod(e);var r=Ys.from(t.toArray());if(r.length{"use strict";f();var GO=cr().Buffer,kE=G4(),f9e=fA().ec,wne=IE(),h9e=HO();function p9e(t,e,r,n,i){var o=wne(r);if(o.type==="ec"){if(n!=="ecdsa"&&n!=="ecdsa/rsa")throw new Error("wrong public key type");return m9e(t,e,o)}else if(o.type==="dsa"){if(n!=="dsa")throw new Error("wrong public key type");return y9e(t,e,o)}if(n!=="rsa"&&n!=="ecdsa/rsa")throw new Error("wrong public key type");e=GO.concat([i,e]);for(var s=o.modulus.byteLength(),a=[1],d=0;e.length+a.length+2=0)throw new Error("invalid sig")}_ne.exports=p9e});var Ine=V((Fwt,Pne)=>{"use strict";f();var wA=cr().Buffer,Ane=Mw(),_A=Xee(),Tne=Ft(),g9e=vne(),v9e=xne(),Tg=iM();Object.keys(Tg).forEach(function(t){Tg[t].id=wA.from(Tg[t].id,"hex"),Tg[t.toLowerCase()]=Tg[t]});function RE(t){_A.Writable.call(this);var e=Tg[t];if(!e)throw new Error("Unknown message digest");this._hashType=e.hash,this._hash=Ane(e.hash),this._tag=e.id,this._signType=e.sign}Tne(RE,_A.Writable);RE.prototype._write=function(e,r,n){this._hash.update(e),n()};RE.prototype.update=function(e,r){return this._hash.update(typeof e=="string"?wA.from(e,r):e),this};RE.prototype.sign=function(e,r){this.end();var n=this._hash.digest(),i=g9e(n,e,this._hashType,this._signType,this._tag);return r?i.toString(r):i};function DE(t){_A.Writable.call(this);var e=Tg[t];if(!e)throw new Error("Unknown message digest");this._hash=Ane(e.hash),this._tag=e.id,this._signType=e.sign}Tne(DE,_A.Writable);DE.prototype._write=function(e,r,n){this._hash.update(e),n()};DE.prototype.update=function(e,r){return this._hash.update(typeof e=="string"?wA.from(e,r):e),this};DE.prototype.verify=function(e,r,n){var i=typeof r=="string"?wA.from(r,n):r;this.end();var o=this._hash.digest();return v9e(i,o,e,this._signType,this._tag)};function Ene(t){return new RE(t)}function Sne(t){return new DE(t)}Pne.exports={Sign:Ene,Verify:Sne,createSign:Ene,createVerify:Sne}});var Rne=V((Wwt,kne)=>{f();var b9e=fA(),w9e=Mo();kne.exports=function(e){return new Pg(e)};var Nc={secp256k1:{name:"secp256k1",byteLength:32},secp224r1:{name:"p224",byteLength:28},prime256v1:{name:"p256",byteLength:32},prime192v1:{name:"p192",byteLength:24},ed25519:{name:"ed25519",byteLength:32},secp384r1:{name:"p384",byteLength:48},secp521r1:{name:"p521",byteLength:66}};Nc.p224=Nc.secp224r1;Nc.p256=Nc.secp256r1=Nc.prime256v1;Nc.p192=Nc.secp192r1=Nc.prime192v1;Nc.p384=Nc.secp384r1;Nc.p521=Nc.secp521r1;function Pg(t){this.curveType=Nc[t],this.curveType||(this.curveType={name:t}),this.curve=new b9e.ec(this.curveType.name),this.keys=void 0}Pg.prototype.generateKeys=function(t,e){return this.keys=this.curve.genKeyPair(),this.getPublicKey(t,e)};Pg.prototype.computeSecret=function(t,e,r){e=e||"utf8",O.Buffer.isBuffer(t)||(t=new O.Buffer(t,e));var n=this.curve.keyFromPublic(t).getPublic(),i=n.mul(this.keys.getPrivate()).getX();return JO(i,r,this.curveType.byteLength)};Pg.prototype.getPublicKey=function(t,e){var r=this.keys.getPublic(e==="compressed",!0);return e==="hybrid"&&(r[r.length-1]%2?r[0]=7:r[0]=6),JO(r,t)};Pg.prototype.getPrivateKey=function(t){return JO(this.keys.getPrivate(),t)};Pg.prototype.setPublicKey=function(t,e){return e=e||"utf8",O.Buffer.isBuffer(t)||(t=new O.Buffer(t,e)),this.keys._importPublic(t),this};Pg.prototype.setPrivateKey=function(t,e){e=e||"utf8",O.Buffer.isBuffer(t)||(t=new O.Buffer(t,e));var r=new w9e(t);return r=r.toString(16),this.keys=this.curve.genKeyPair(),this.keys._importPrivate(r),this};function JO(t,e,r){Array.isArray(t)||(t=t.toArray());var n=new O.Buffer(t);if(r&&n.length{f();var _9e=Mw(),ZO=cr().Buffer;Dne.exports=function(t,e){for(var r=ZO.alloc(0),n=0,i;r.length{f();Bne.exports=function(e,r){for(var n=e.length,i=-1;++i{f();var Mne=Mo(),E9e=cr().Buffer;function S9e(t,e){return E9e.from(t.toRed(Mne.mont(e.modulus)).redPow(new Mne(e.publicExponent)).fromRed().toArray())}One.exports=S9e});var Nne=V((Qwt,jne)=>{f();var A9e=IE(),eC=eg(),T9e=Mw(),Cne=YO(),$ne=XO(),tC=Mo(),P9e=QO(),I9e=J4(),Ou=cr().Buffer;jne.exports=function(e,r,n){var i;e.padding?i=e.padding:n?i=1:i=4;var o=A9e(e),s;if(i===4)s=k9e(o,r);else if(i===1)s=R9e(o,r,n);else if(i===3){if(s=new tC(r),s.cmp(o.modulus)>=0)throw new Error("data too long for modulus")}else throw new Error("unknown padding");return n?I9e(s,o):P9e(s,o)};function k9e(t,e){var r=t.modulus.byteLength(),n=e.length,i=T9e("sha1").update(Ou.alloc(0)).digest(),o=i.length,s=2*o;if(n>r-s-2)throw new Error("message too long");var a=Ou.alloc(r-n-s-2),d=r-o-1,u=eC(o),c=$ne(Ou.concat([i,a,Ou.alloc(1,1),e],d),Cne(u,d)),l=$ne(u,Cne(c,o));return new tC(Ou.concat([Ou.alloc(1),l,c],r))}function R9e(t,e,r){var n=e.length,i=t.modulus.byteLength();if(n>i-11)throw new Error("message too long");var o;return r?o=Ou.alloc(i-n-3,255):o=D9e(i-n-3),new tC(Ou.concat([Ou.from([0,r?1:2]),o,Ou.alloc(1),e],i))}function D9e(t){for(var e=Ou.allocUnsafe(t),r=0,n=eC(t*2),i=0,o;r{f();var B9e=IE(),Une=YO(),qne=XO(),Lne=Mo(),M9e=J4(),O9e=Mw(),C9e=QO(),BE=cr().Buffer;Kne.exports=function(e,r,n){var i;e.padding?i=e.padding:n?i=1:i=4;var o=B9e(e),s=o.modulus.byteLength();if(r.length>s||new Lne(r).cmp(o.modulus)>=0)throw new Error("decryption error");var a;n?a=C9e(new Lne(r),o):a=M9e(r,o);var d=BE.alloc(s-a.length);if(a=BE.concat([d,a],s),i===4)return $9e(o,a);if(i===1)return j9e(o,a,n);if(i===3)return a;throw new Error("unknown padding")};function $9e(t,e){var r=t.modulus.byteLength(),n=O9e("sha1").update(BE.alloc(0)).digest(),i=n.length;if(e[0]!==0)throw new Error("decryption error");var o=e.slice(1,i+1),s=e.slice(i+1),a=qne(o,Une(s,i)),d=qne(s,Une(a,r-i-1));if(N9e(n,d.slice(0,i)))throw new Error("decryption error");for(var u=i;d[u]===0;)u++;if(d[u++]!==1)throw new Error("decryption error");return d.slice(u)}function j9e(t,e,r){for(var n=e.slice(0,2),i=2,o=0;e[i++]!==0;)if(i>=e.length){o++;break}var s=e.slice(2,i-1);if((n.toString("hex")!=="0002"&&!r||n.toString("hex")!=="0001"&&r)&&o++,s.length<8&&o++,o)throw new Error("decryption error");return e.slice(i)}function N9e(t,e){t=BE.from(t),e=BE.from(e);var r=0,n=t.length;t.length!==e.length&&(r++,n=Math.min(t.length,e.length));for(var i=-1;++i{f();Ig.publicEncrypt=Nne();Ig.privateDecrypt=Fne();Ig.privateEncrypt=function(e,r){return Ig.publicEncrypt(e,r,!0)};Ig.publicDecrypt=function(e,r){return Ig.privateDecrypt(e,r,!0)}});var eie=V(ME=>{"use strict";f();function Wne(){throw new Error(`secure random number generation not supported by this browser -use chrome, FireFox or Internet Explorer 11`)}var Vne=cr(),Hne=eg(),Gne=Vne.Buffer,Jne=Vne.kMaxLength,rC=globalThis.crypto||globalThis.msCrypto,Zne=Math.pow(2,32)-1;function Yne(t,e){if(typeof t!="number"||t!==t)throw new TypeError("offset must be a number");if(t>Zne||t<0)throw new TypeError("offset must be a uint32");if(t>Jne||t>e)throw new RangeError("offset out of range")}function Xne(t,e,r){if(typeof t!="number"||t!==t)throw new TypeError("size must be a number");if(t>Zne||t<0)throw new TypeError("size must be a uint32");if(t+e>r||t>Jne)throw new RangeError("buffer too small")}rC&&rC.getRandomValues||!k.default.browser?(ME.randomFill=U9e,ME.randomFillSync=q9e):(ME.randomFill=Wne,ME.randomFillSync=Wne);function U9e(t,e,r,n){if(!Gne.isBuffer(t)&&!(t instanceof globalThis.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if(typeof e=="function")n=e,e=0,r=t.length;else if(typeof r=="function")n=r,r=t.length-e;else if(typeof n!="function")throw new TypeError('"cb" argument must be a function');return Yne(e,t.length),Xne(r,e,t.length),Qne(t,e,r,n)}function Qne(t,e,r,n){if(k.default.browser){var i=t.buffer,o=new Uint8Array(i,e,r);if(rC.getRandomValues(o),n){k.default.nextTick(function(){n(null,t)});return}return t}if(n){Hne(r,function(a,d){if(a)return n(a);d.copy(t,e),n(null,t)});return}var s=Hne(r);return s.copy(t,e),t}function q9e(t,e,r){if(typeof e>"u"&&(e=0),!Gne.isBuffer(t)&&!(t instanceof globalThis.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');return Yne(e,t.length),r===void 0&&(r=t.length-e),Xne(r,e,t.length),Qne(t,e,r)}});var C4=V(dr=>{"use strict";f();dr.randomBytes=dr.rng=dr.pseudoRandomBytes=dr.prng=eg();dr.createHash=dr.Hash=Mw();dr.createHmac=dr.Hmac=nM();var L9e=IX(),K9e=Object.keys(L9e),F9e=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(K9e);dr.getHashes=function(){return F9e};var tie=hM();dr.pbkdf2=tie.pbkdf2;dr.pbkdf2Sync=tie.pbkdf2Sync;var zl=ZQ();dr.Cipher=zl.Cipher;dr.createCipher=zl.createCipher;dr.Cipheriv=zl.Cipheriv;dr.createCipheriv=zl.createCipheriv;dr.Decipher=zl.Decipher;dr.createDecipher=zl.createDecipher;dr.Decipheriv=zl.Decipheriv;dr.createDecipheriv=zl.createDecipheriv;dr.getCiphers=zl.getCiphers;dr.listCiphers=zl.listCiphers;var OE=dee();dr.DiffieHellmanGroup=OE.DiffieHellmanGroup;dr.createDiffieHellmanGroup=OE.createDiffieHellmanGroup;dr.getDiffieHellman=OE.getDiffieHellman;dr.createDiffieHellman=OE.createDiffieHellman;dr.DiffieHellman=OE.DiffieHellman;var xA=Ine();dr.createSign=xA.createSign;dr.Sign=xA.Sign;dr.createVerify=xA.createVerify;dr.Verify=xA.Verify;dr.createECDH=Rne();var EA=zne();dr.publicEncrypt=EA.publicEncrypt;dr.privateEncrypt=EA.privateEncrypt;dr.publicDecrypt=EA.publicDecrypt;dr.privateDecrypt=EA.privateDecrypt;var rie=eie();dr.randomFill=rie.randomFill;dr.randomFillSync=rie.randomFillSync;dr.createCredentials=function(){throw new Error(["sorry, createCredentials is not implemented yet","we accept pull requests","https://github.com/crypto-browserify/crypto-browserify"].join(` -`))};dr.constants={DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8,NPN_ENABLED:1,ALPN_ENABLED:1,RSA_PKCS1_PADDING:1,RSA_SSLV23_PADDING:2,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_X931_PADDING:5,RSA_PKCS1_PSS_PADDING:6,POINT_CONVERSION_COMPRESSED:2,POINT_CONVERSION_UNCOMPRESSED:4,POINT_CONVERSION_HYBRID:6}});var Cu=V(ur=>{"use strict";f();Object.defineProperty(ur,"__esModule",{value:!0});ur.setBigUint64=ur.Hash=ur.equalBytes=ur.ensureBytes=ur.checkOpts=ur.concatBytes=ur.toBytes=ur.bytesToUtf8=ur.utf8ToBytes=ur.asyncLoop=ur.nextTick=ur.hexToBytes=ur.bytesToHex=ur.isLE=ur.createView=ur.u32=ur.u16=ur.u8=void 0;var iC=t=>t instanceof Uint8Array,z9e=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);ur.u8=z9e;var W9e=t=>new Uint16Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/2));ur.u16=W9e;var H9e=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));ur.u32=H9e;var V9e=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);ur.createView=V9e;ur.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!ur.isLE)throw new Error("Non little-endian hardware is not supported");var G9e=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function J9e(t){if(!iC(t))throw new Error("Uint8Array expected");let e="";for(let r=0;r{};ur.nextTick=Y9e;async function X9e(t,e,r){let n=Date.now();for(let i=0;i=0&&on+i.length,0)),r=0;return t.forEach(n=>{if(!iC(n))throw new Error("Uint8Array expected");e.set(n,r),r+=n.length}),e}ur.concatBytes=tBe;var rBe=t=>Object.prototype.toString.call(t)==="[object Object]"&&t.constructor===Object;function nBe(t,e){if(e!==void 0&&(typeof e!="object"||!rBe(e)))throw new Error("options must be object or undefined");return Object.assign(t,e)}ur.checkOpts=nBe;function iBe(t,e){if(!(t instanceof Uint8Array))throw new Error("Uint8Array expected");if(typeof e=="number"&&t.length!==e)throw new Error(`Uint8Array length ${e} expected`)}ur.ensureBytes=iBe;function oBe(t,e){if(t.length!==e.length)throw new Error("equalBytes: Different size of Uint8Arrays");let r=!0;for(let n=0;n>i&o),a=Number(r&o),d=n?4:0,u=n?0:4;t.setUint32(e+d,s,n),t.setUint32(e+u,a,n)}ur.setBigUint64=sBe});var CE=V(Xs=>{"use strict";f();Object.defineProperty(Xs,"__esModule",{value:!0});Xs.AEAD_TAG_LENGTH=Xs.XCHACHA20_NONCE_LENGTH=Xs.CURVE25519_PUBLIC_KEY_SIZE=Xs.ETH_PUBLIC_KEY_SIZE=Xs.UNCOMPRESSED_PUBLIC_KEY_SIZE=Xs.COMPRESSED_PUBLIC_KEY_SIZE=Xs.SECRET_KEY_LENGTH=void 0;Xs.SECRET_KEY_LENGTH=32;Xs.COMPRESSED_PUBLIC_KEY_SIZE=33;Xs.UNCOMPRESSED_PUBLIC_KEY_SIZE=65;Xs.ETH_PUBLIC_KEY_SIZE=64;Xs.CURVE25519_PUBLIC_KEY_SIZE=32;Xs.XCHACHA20_NONCE_LENGTH=24;Xs.AEAD_TAG_LENGTH=16});var kg=V(Vn=>{"use strict";f();Object.defineProperty(Vn,"__esModule",{value:!0});Vn.ephemeralKeySize=Vn.symmetricNonceLength=Vn.symmetricAlgorithm=Vn.isHkdfKeyCompressed=Vn.isEphemeralKeyCompressed=Vn.ellipticCurve=Vn.ECIES_CONFIG=void 0;var SA=CE(),aBe=function(){function t(){this.ellipticCurve="secp256k1",this.isEphemeralKeyCompressed=!1,this.isHkdfKeyCompressed=!1,this.symmetricAlgorithm="aes-256-gcm",this.symmetricNonceLength=16}return t}();Vn.ECIES_CONFIG=new aBe;var cBe=function(){return Vn.ECIES_CONFIG.ellipticCurve};Vn.ellipticCurve=cBe;var dBe=function(){return Vn.ECIES_CONFIG.isEphemeralKeyCompressed};Vn.isEphemeralKeyCompressed=dBe;var uBe=function(){return Vn.ECIES_CONFIG.isHkdfKeyCompressed};Vn.isHkdfKeyCompressed=uBe;var lBe=function(){return Vn.ECIES_CONFIG.symmetricAlgorithm};Vn.symmetricAlgorithm=lBe;var fBe=function(){return Vn.ECIES_CONFIG.symmetricNonceLength};Vn.symmetricNonceLength=fBe;var hBe=function(){var t={secp256k1:Vn.ECIES_CONFIG.isEphemeralKeyCompressed?SA.COMPRESSED_PUBLIC_KEY_SIZE:SA.UNCOMPRESSED_PUBLIC_KEY_SIZE,x25519:SA.CURVE25519_PUBLIC_KEY_SIZE,ed25519:SA.CURVE25519_PUBLIC_KEY_SIZE};if(Vn.ECIES_CONFIG.ellipticCurve in t)return t[Vn.ECIES_CONFIG.ellipticCurve];throw new Error("Not implemented")};Vn.ephemeralKeySize=hBe});var iie=V(AA=>{"use strict";f();Object.defineProperty(AA,"__esModule",{value:!0});AA.crypto=void 0;AA.crypto=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0});var oC=V(c1=>{"use strict";f();Object.defineProperty(c1,"__esModule",{value:!0});c1.getWebcryptoSubtle=c1.randomBytes=void 0;var Rg=iie();function pBe(t=32){if(Rg.crypto&&typeof Rg.crypto.getRandomValues=="function")return Rg.crypto.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}c1.randomBytes=pBe;function mBe(){if(Rg.crypto&&typeof Rg.crypto.subtle=="object"&&Rg.crypto.subtle!=null)return Rg.crypto.subtle;throw new Error("crypto.subtle must be defined")}c1.getWebcryptoSubtle=mBe});var aC=V(Ta=>{"use strict";f();Object.defineProperty(Ta,"__esModule",{value:!0});Ta.output=Ta.exists=Ta.hash=Ta.bytes=Ta.bool=Ta.number=void 0;function TA(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}Ta.number=TA;function oie(t){if(typeof t!="boolean")throw new Error(`Expected boolean, not ${t}`)}Ta.bool=oie;function yBe(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function sC(t,...e){if(!yBe(t))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}Ta.bytes=sC;function sie(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");TA(t.outputLen),TA(t.blockLen)}Ta.hash=sie;function aie(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")}Ta.exists=aie;function cie(t,e){sC(t);let r=e.outputLen;if(t.length{"use strict";f();Object.defineProperty(PA,"__esModule",{value:!0});PA.crypto=void 0;PA.crypto=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0});var Am=V(lr=>{"use strict";f();Object.defineProperty(lr,"__esModule",{value:!0});lr.randomBytes=lr.wrapXOFConstructorWithOpts=lr.wrapConstructorWithOpts=lr.wrapConstructor=lr.checkOpts=lr.Hash=lr.concatBytes=lr.toBytes=lr.utf8ToBytes=lr.asyncLoop=lr.nextTick=lr.hexToBytes=lr.bytesToHex=lr.isLE=lr.rotr=lr.createView=lr.u32=lr.u8=void 0;var cC=die(),vBe=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);lr.u8=vBe;var bBe=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));lr.u32=bBe;function uC(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}var wBe=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);lr.createView=wBe;var _Be=(t,e)=>t<<32-e|t>>>e;lr.rotr=_Be;lr.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!lr.isLE)throw new Error("Non little-endian hardware is not supported");var xBe=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function EBe(t){if(!uC(t))throw new Error("Uint8Array expected");let e="";for(let r=0;r=Ah._0&&t<=Ah._9)return t-Ah._0;if(t>=Ah._A&&t<=Ah._F)return t-(Ah._A-10);if(t>=Ah._a&&t<=Ah._f)return t-(Ah._a-10)}function SBe(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let i=0,o=0;i{};lr.nextTick=ABe;async function TBe(t,e,r){let n=Date.now();for(let i=0;i=0&&ot().update(IA(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}lr.wrapConstructor=RBe;function DBe(t){let e=(n,i)=>t(i).update(IA(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}lr.wrapConstructorWithOpts=DBe;function BBe(t){let e=(n,i)=>t(i).update(IA(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}lr.wrapXOFConstructorWithOpts=BBe;function MBe(t=32){if(cC.crypto&&typeof cC.crypto.getRandomValues=="function")return cC.crypto.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}lr.randomBytes=MBe});var hC=V(kA=>{"use strict";f();Object.defineProperty(kA,"__esModule",{value:!0});kA.SHA2=void 0;var lC=aC(),$E=Am();function OBe(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),d=n?4:0,u=n?0:4;t.setUint32(e+d,s,n),t.setUint32(e+u,a,n)}var fC=class extends $E.Hash{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=(0,$E.createView)(this.buffer)}update(e){(0,lC.exists)(this);let{view:r,buffer:n,blockLen:i}=this;e=(0,$E.toBytes)(e);let o=e.length;for(let s=0;si-s&&(this.process(n,0),s=0);for(let l=s;lc.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l{"use strict";f();Object.defineProperty(Ot,"__esModule",{value:!0});Ot.add5L=Ot.add5H=Ot.add4H=Ot.add4L=Ot.add3H=Ot.add3L=Ot.add=Ot.rotlBL=Ot.rotlBH=Ot.rotlSL=Ot.rotlSH=Ot.rotr32L=Ot.rotr32H=Ot.rotrBL=Ot.rotrBH=Ot.rotrSL=Ot.rotrSH=Ot.shrSL=Ot.shrSH=Ot.toBig=Ot.split=Ot.fromBig=void 0;var RA=BigInt(2**32-1),pC=BigInt(32);function mC(t,e=!1){return e?{h:Number(t&RA),l:Number(t>>pC&RA)}:{h:Number(t>>pC&RA)|0,l:Number(t&RA)|0}}Ot.fromBig=mC;function fie(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;iBigInt(t>>>0)<>>0);Ot.toBig=hie;var pie=(t,e,r)=>t>>>r;Ot.shrSH=pie;var mie=(t,e,r)=>t<<32-r|e>>>r;Ot.shrSL=mie;var yie=(t,e,r)=>t>>>r|e<<32-r;Ot.rotrSH=yie;var gie=(t,e,r)=>t<<32-r|e>>>r;Ot.rotrSL=gie;var vie=(t,e,r)=>t<<64-r|e>>>r-32;Ot.rotrBH=vie;var bie=(t,e,r)=>t>>>r-32|e<<64-r;Ot.rotrBL=bie;var wie=(t,e)=>e;Ot.rotr32H=wie;var _ie=(t,e)=>t;Ot.rotr32L=_ie;var xie=(t,e,r)=>t<>>32-r;Ot.rotlSH=xie;var Eie=(t,e,r)=>e<>>32-r;Ot.rotlSL=Eie;var Sie=(t,e,r)=>e<>>64-r;Ot.rotlBH=Sie;var Aie=(t,e,r)=>t<>>64-r;Ot.rotlBL=Aie;function Tie(t,e,r,n){let i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}Ot.add=Tie;var Pie=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0);Ot.add3L=Pie;var Iie=(t,e,r,n)=>e+r+n+(t/2**32|0)|0;Ot.add3H=Iie;var kie=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0);Ot.add4L=kie;var Rie=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0;Ot.add4H=Rie;var Die=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0);Ot.add5L=Die;var Bie=(t,e,r,n,i,o)=>e+r+n+i+o+(t/2**32|0)|0;Ot.add5H=Bie;var CBe={fromBig:mC,split:fie,toBig:hie,shrSH:pie,shrSL:mie,rotrSH:yie,rotrSL:gie,rotrBH:vie,rotrBL:bie,rotr32H:wie,rotr32L:_ie,rotlSH:xie,rotlSL:Eie,rotlBH:Sie,rotlBL:Aie,add:Tie,add3L:Pie,add3H:Iie,add4L:kie,add4H:Rie,add5H:Bie,add5L:Die};Ot.default=CBe});var Oie=V(Md=>{"use strict";f();Object.defineProperty(Md,"__esModule",{value:!0});Md.sha384=Md.sha512_256=Md.sha512_224=Md.sha512=Md.SHA512=void 0;var $Be=hC(),fr=Mie(),DA=Am(),[jBe,NBe]=fr.default.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),Tm=new Uint32Array(80),Pm=new Uint32Array(80),Dg=class extends $Be.SHA2{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:r,Bh:n,Bl:i,Ch:o,Cl:s,Dh:a,Dl:d,Eh:u,El:c,Fh:l,Fl:p,Gh:m,Gl:g,Hh:v,Hl:x}=this;return[e,r,n,i,o,s,a,d,u,c,l,p,m,g,v,x]}set(e,r,n,i,o,s,a,d,u,c,l,p,m,g,v,x){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=o|0,this.Cl=s|0,this.Dh=a|0,this.Dl=d|0,this.Eh=u|0,this.El=c|0,this.Fh=l|0,this.Fl=p|0,this.Gh=m|0,this.Gl=g|0,this.Hh=v|0,this.Hl=x|0}process(e,r){for(let A=0;A<16;A++,r+=4)Tm[A]=e.getUint32(r),Pm[A]=e.getUint32(r+=4);for(let A=16;A<80;A++){let $=Tm[A-15]|0,j=Pm[A-15]|0,L=fr.default.rotrSH($,j,1)^fr.default.rotrSH($,j,8)^fr.default.shrSH($,j,7),F=fr.default.rotrSL($,j,1)^fr.default.rotrSL($,j,8)^fr.default.shrSL($,j,7),K=Tm[A-2]|0,W=Pm[A-2]|0,q=fr.default.rotrSH(K,W,19)^fr.default.rotrBH(K,W,61)^fr.default.shrSH(K,W,6),I=fr.default.rotrSL(K,W,19)^fr.default.rotrBL(K,W,61)^fr.default.shrSL(K,W,6),T=fr.default.add4L(F,I,Pm[A-7],Pm[A-16]),B=fr.default.add4H(T,L,q,Tm[A-7],Tm[A-16]);Tm[A]=B|0,Pm[A]=T|0}let{Ah:n,Al:i,Bh:o,Bl:s,Ch:a,Cl:d,Dh:u,Dl:c,Eh:l,El:p,Fh:m,Fl:g,Gh:v,Gl:x,Hh:S,Hl:P}=this;for(let A=0;A<80;A++){let $=fr.default.rotrSH(l,p,14)^fr.default.rotrSH(l,p,18)^fr.default.rotrBH(l,p,41),j=fr.default.rotrSL(l,p,14)^fr.default.rotrSL(l,p,18)^fr.default.rotrBL(l,p,41),L=l&m^~l&v,F=p&g^~p&x,K=fr.default.add5L(P,j,F,NBe[A],Pm[A]),W=fr.default.add5H(K,S,$,L,jBe[A],Tm[A]),q=K|0,I=fr.default.rotrSH(n,i,28)^fr.default.rotrBH(n,i,34)^fr.default.rotrBH(n,i,39),T=fr.default.rotrSL(n,i,28)^fr.default.rotrBL(n,i,34)^fr.default.rotrBL(n,i,39),B=n&o^n&a^o&a,h=i&s^i&d^s&d;S=v|0,P=x|0,v=m|0,x=g|0,m=l|0,g=p|0,{h:l,l:p}=fr.default.add(u|0,c|0,W|0,q|0),u=a|0,c=d|0,a=o|0,d=s|0,o=n|0,s=i|0;let y=fr.default.add3L(q,T,h);n=fr.default.add3H(y,W,I,B),i=y|0}({h:n,l:i}=fr.default.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:o,l:s}=fr.default.add(this.Bh|0,this.Bl|0,o|0,s|0),{h:a,l:d}=fr.default.add(this.Ch|0,this.Cl|0,a|0,d|0),{h:u,l:c}=fr.default.add(this.Dh|0,this.Dl|0,u|0,c|0),{h:l,l:p}=fr.default.add(this.Eh|0,this.El|0,l|0,p|0),{h:m,l:g}=fr.default.add(this.Fh|0,this.Fl|0,m|0,g|0),{h:v,l:x}=fr.default.add(this.Gh|0,this.Gl|0,v|0,x|0),{h:S,l:P}=fr.default.add(this.Hh|0,this.Hl|0,S|0,P|0),this.set(n,i,o,s,a,d,u,c,l,p,m,g,v,x,S,P)}roundClean(){Tm.fill(0),Pm.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};Md.SHA512=Dg;var yC=class extends Dg{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}},gC=class extends Dg{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}},vC=class extends Dg{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}};Md.sha512=(0,DA.wrapConstructor)(()=>new Dg);Md.sha512_224=(0,DA.wrapConstructor)(()=>new yC);Md.sha512_256=(0,DA.wrapConstructor)(()=>new gC);Md.sha384=(0,DA.wrapConstructor)(()=>new vC)});var $u=V(Qt=>{"use strict";f();Object.defineProperty(Qt,"__esModule",{value:!0});Qt.validateObject=Qt.createHmacDrbg=Qt.bitMask=Qt.bitSet=Qt.bitGet=Qt.bitLen=Qt.utf8ToBytes=Qt.equalBytes=Qt.concatBytes=Qt.ensureBytes=Qt.numberToVarBytesBE=Qt.numberToBytesLE=Qt.numberToBytesBE=Qt.bytesToNumberLE=Qt.bytesToNumberBE=Qt.hexToBytes=Qt.hexToNumber=Qt.numberToHexUnpadded=Qt.bytesToHex=Qt.isBytes=void 0;var jie=BigInt(0),BA=BigInt(1),UBe=BigInt(2);function d1(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}Qt.isBytes=d1;var qBe=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function wC(t){if(!d1(t))throw new Error("Uint8Array expected");let e="";for(let r=0;r=Th._0&&t<=Th._9)return t-Th._0;if(t>=Th._A&&t<=Th._F)return t-(Th._A-10);if(t>=Th._a&&t<=Th._f)return t-(Th._a-10)}function MA(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let i=0,o=0;ijie;t>>=BA,e+=1);return e}Qt.bitLen=GBe;function JBe(t,e){return t>>BigInt(e)&BA}Qt.bitGet=JBe;var ZBe=(t,e,r)=>t|(r?BA:jie)<(UBe<new Uint8Array(t),$ie=t=>Uint8Array.from(t);function XBe(t,e,r){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=bC(t),i=bC(t),o=0,s=()=>{n.fill(1),i.fill(0),o=0},a=(...l)=>r(i,n,...l),d=(l=bC())=>{i=a($ie([0]),l),n=a(),l.length!==0&&(i=a($ie([1]),l),n=a())},u=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,p=[];for(;l{s(),d(l);let m;for(;!(m=p(u()));)d();return s(),m}}Qt.createHmacDrbg=XBe;var QBe={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||d1(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function e7e(t,e,r={}){let n=(i,o,s)=>{let a=QBe[o];if(typeof a!="function")throw new Error(`Invalid validator "${o}", expected function`);let d=t[i];if(!(s&&d===void 0)&&!a(d,t))throw new Error(`Invalid param ${String(i)}=${d} (${typeof d}), expected ${o}`)};for(let[i,o]of Object.entries(e))n(i,o,!1);for(let[i,o]of Object.entries(r))n(i,o,!0);return t}Qt.validateObject=e7e});var km=V(er=>{"use strict";f();Object.defineProperty(er,"__esModule",{value:!0});er.mapHashToField=er.getMinHashLength=er.getFieldBytesLength=er.hashToPrivateScalar=er.FpSqrtEven=er.FpSqrtOdd=er.Field=er.nLength=er.FpIsSquare=er.FpDiv=er.FpInvertBatch=er.FpPow=er.validateField=er.isNegativeLE=er.FpSqrt=er.tonelliShanks=er.invert=er.pow2=er.pow=er.mod=void 0;var qc=$u(),no=BigInt(0),An=BigInt(1),Im=BigInt(2),t7e=BigInt(3),xC=BigInt(4),Lie=BigInt(5),Kie=BigInt(8),r7e=BigInt(9),n7e=BigInt(16);function Uc(t,e){let r=t%e;return r>=no?r:e+r}er.mod=Uc;function Fie(t,e,r){if(r<=no||e 0");if(r===An)return no;let n=An;for(;e>no;)e&An&&(n=n*t%r),t=t*t%r,e>>=An;return n}er.pow=Fie;function i7e(t,e,r){let n=t;for(;e-- >no;)n*=n,n%=r;return n}er.pow2=i7e;function OA(t,e){if(t===no||e<=no)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=Uc(t,e),n=e,i=no,o=An,s=An,a=no;for(;r!==no;){let u=n/r,c=n%r,l=i-s*u,p=o-a*u;n=r,r=c,i=s,o=a,s=l,a=p}if(n!==An)throw new Error("invert: does not exist");return Uc(i,e)}er.invert=OA;function zie(t){let e=(t-An)/Im,r,n,i;for(r=t-An,n=0;r%Im===no;r/=Im,n++);for(i=Im;i(Uc(t,e)&An)===An;er.isNegativeLE=o7e;var s7e=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function a7e(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=s7e.reduce((n,i)=>(n[i]="function",n),e);return(0,qc.validateObject)(t,r)}er.validateField=a7e;function Hie(t,e,r){if(r 0");if(r===no)return t.ONE;if(r===An)return e;let n=t.ONE,i=e;for(;r>no;)r&An&&(n=t.mul(n,i)),i=t.sqr(i),r>>=An;return n}er.FpPow=Hie;function Vie(t,e){let r=new Array(e.length),n=e.reduce((o,s,a)=>t.is0(s)?o:(r[a]=o,t.mul(o,s)),t.ONE),i=t.inv(n);return e.reduceRight((o,s,a)=>t.is0(s)?o:(r[a]=t.mul(o,r[a]),t.mul(o,s)),i),r}er.FpInvertBatch=Vie;function c7e(t,e,r){return t.mul(e,typeof r=="bigint"?OA(r,t.ORDER):t.inv(r))}er.FpDiv=c7e;function d7e(t){let e=(t.ORDER-An)/Im;return r=>{let n=t.pow(r,e);return t.eql(n,t.ZERO)||t.eql(n,t.ONE)}}er.FpIsSquare=d7e;function EC(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}er.nLength=EC;function u7e(t,e,r=!1,n={}){if(t<=no)throw new Error(`Expected Field ORDER > 0, got ${t}`);let{nBitLength:i,nByteLength:o}=EC(t,e);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=Wie(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:o,MASK:(0,qc.bitMask)(i),ZERO:no,ONE:An,create:d=>Uc(d,t),isValid:d=>{if(typeof d!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof d}`);return no<=d&&dd===no,isOdd:d=>(d&An)===An,neg:d=>Uc(-d,t),eql:(d,u)=>d===u,sqr:d=>Uc(d*d,t),add:(d,u)=>Uc(d+u,t),sub:(d,u)=>Uc(d-u,t),mul:(d,u)=>Uc(d*u,t),pow:(d,u)=>Hie(a,d,u),div:(d,u)=>Uc(d*OA(u,t),t),sqrN:d=>d*d,addN:(d,u)=>d+u,subN:(d,u)=>d-u,mulN:(d,u)=>d*u,inv:d=>OA(d,t),sqrt:n.sqrt||(d=>s(a,d)),invertBatch:d=>Vie(a,d),cmov:(d,u,c)=>c?u:d,toBytes:d=>r?(0,qc.numberToBytesLE)(d,o):(0,qc.numberToBytesBE)(d,o),fromBytes:d=>{if(d.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${d.length}`);return r?(0,qc.bytesToNumberLE)(d):(0,qc.bytesToNumberBE)(d)}});return Object.freeze(a)}er.Field=u7e;function l7e(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");let r=t.sqrt(e);return t.isOdd(r)?r:t.neg(r)}er.FpSqrtOdd=l7e;function f7e(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");let r=t.sqrt(e);return t.isOdd(r)?t.neg(r):r}er.FpSqrtEven=f7e;function h7e(t,e,r=!1){t=(0,qc.ensureBytes)("privateHash",t);let n=t.length,i=EC(e).nByteLength+8;if(i<24||n1024)throw new Error(`hashToPrivateScalar: expected ${i}-1024 bytes of input, got ${n}`);let o=r?(0,qc.bytesToNumberLE)(t):(0,qc.bytesToNumberBE)(t);return Uc(o,e-An)+An}er.hashToPrivateScalar=h7e;function SC(t){if(typeof t!="bigint")throw new Error("field order must be bigint");let e=t.toString(2).length;return Math.ceil(e/8)}er.getFieldBytesLength=SC;function Gie(t){let e=SC(t);return e+Math.ceil(e/2)}er.getMinHashLength=Gie;function p7e(t,e,r=!1){let n=t.length,i=SC(e),o=Gie(e);if(n<16||n1024)throw new Error(`expected ${o}-1024 bytes of input, got ${n}`);let s=r?(0,qc.bytesToNumberBE)(t):(0,qc.bytesToNumberLE)(t),a=Uc(s,e-An)+An;return r?(0,qc.numberToBytesLE)(a,i):(0,qc.numberToBytesBE)(a,i)}er.mapHashToField=p7e});var TC=V(u1=>{"use strict";f();Object.defineProperty(u1,"__esModule",{value:!0});u1.validateBasic=u1.wNAF=void 0;var Jie=km(),m7e=$u(),y7e=BigInt(0),AC=BigInt(1);function g7e(t,e){let r=(i,o)=>{let s=o.negate();return i?s:o},n=i=>{let o=Math.ceil(e/i)+1,s=2**(i-1);return{windows:o,windowSize:s}};return{constTimeNegate:r,unsafeLadder(i,o){let s=t.ZERO,a=i;for(;o>y7e;)o&AC&&(s=s.add(a)),a=a.double(),o>>=AC;return s},precomputeWindow(i,o){let{windows:s,windowSize:a}=n(o),d=[],u=i,c=u;for(let l=0;l>=m,x>d&&(x-=p,s+=AC);let S=v,P=v+Math.abs(x)-1,A=g%2!==0,$=x<0;x===0?c=c.add(r(A,o[S])):u=u.add(r($,o[P]))}return{p:u,f:c}},wNAFCached(i,o,s,a){let d=i._WINDOW_SIZE||1,u=o.get(i);return u||(u=this.precomputeWindow(i,d),d!==1&&o.set(i,a(u))),this.wNAF(d,u,s)}}}u1.wNAF=g7e;function v7e(t){return(0,Jie.validateField)(t.Fp),(0,m7e.validateObject)(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,Jie.nLength)(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}u1.validateBasic=v7e});var Yie=V($A=>{"use strict";f();Object.defineProperty($A,"__esModule",{value:!0});$A.twistedEdwards=void 0;var b7e=km(),Ph=$u(),Rm=$u(),Zie=TC(),ju=BigInt(0),Lc=BigInt(1),CA=BigInt(2),w7e=BigInt(8),_7e={zip215:!0};function x7e(t){let e=(0,Zie.validateBasic)(t);return Ph.validateObject(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function E7e(t){let e=x7e(t),{Fp:r,n,prehash:i,hash:o,randomBytes:s,nByteLength:a,h:d}=e,u=CA<{try{return{isValid:!0,value:r.sqrt(_*r.inv(b))}}catch{return{isValid:!1,value:ju}}}),p=e.adjustScalarBytes||(_=>_),m=e.domain||((_,b,C)=>{if(b.length||C)throw new Error("Contexts/pre-hash are not supported");return _}),g=_=>typeof _=="bigint"&&ju<_,v=(_,b)=>g(_)&&g(b)&&__===ju||v(_,u);function S(_,b){if(v(_,b))return _;throw new Error(`Expected valid scalar < ${b}, got ${typeof _} ${_}`)}function P(_){return _===ju?_:S(_,n)}let A=new Map;function $(_){if(!(_ instanceof j))throw new Error("ExtendedPoint expected")}class j{constructor(b,C,N,M){if(this.ex=b,this.ey=C,this.ez=N,this.et=M,!x(b))throw new Error("x required");if(!x(C))throw new Error("y required");if(!x(N))throw new Error("z required");if(!x(M))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(b){if(b instanceof j)throw new Error("extended point not allowed");let{x:C,y:N}=b||{};if(!x(C)||!x(N))throw new Error("invalid affine point");return new j(C,N,Lc,c(C*N))}static normalizeZ(b){let C=r.invertBatch(b.map(N=>N.ez));return b.map((N,M)=>N.toAffine(C[M])).map(j.fromAffine)}_setWindowSize(b){this._WINDOW_SIZE=b,A.delete(this)}assertValidity(){let{a:b,d:C}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:N,ey:M,ez:U,et:G}=this,Z=c(N*N),J=c(M*M),H=c(U*U),X=c(H*H),te=c(Z*b),ne=c(H*c(te+J)),Q=c(X+c(C*c(Z*J)));if(ne!==Q)throw new Error("bad point: equation left != right (1)");let re=c(N*M),ce=c(U*G);if(re!==ce)throw new Error("bad point: equation left != right (2)")}equals(b){$(b);let{ex:C,ey:N,ez:M}=this,{ex:U,ey:G,ez:Z}=b,J=c(C*Z),H=c(U*M),X=c(N*Z),te=c(G*M);return J===H&&X===te}is0(){return this.equals(j.ZERO)}negate(){return new j(c(-this.ex),this.ey,this.ez,c(-this.et))}double(){let{a:b}=e,{ex:C,ey:N,ez:M}=this,U=c(C*C),G=c(N*N),Z=c(CA*c(M*M)),J=c(b*U),H=C+N,X=c(c(H*H)-U-G),te=J+G,ne=te-Z,Q=J-G,re=c(X*ne),ce=c(te*Q),pe=c(X*Q),ye=c(ne*te);return new j(re,ce,ye,pe)}add(b){$(b);let{a:C,d:N}=e,{ex:M,ey:U,ez:G,et:Z}=this,{ex:J,ey:H,ez:X,et:te}=b;if(C===BigInt(-1)){let Et=c((U-M)*(H+J)),Fe=c((U+M)*(H-J)),mt=c(Fe-Et);if(mt===ju)return this.double();let En=c(G*CA*te),ke=c(Z*CA*X),Pe=ke+En,Wt=Fe+Et,Be=ke-En,Ee=c(Pe*mt),Cr=c(Wt*Be),Ve=c(Pe*Be),Ze=c(mt*Wt);return new j(Ee,Cr,Ze,Ve)}let ne=c(M*J),Q=c(U*H),re=c(Z*N*te),ce=c(G*X),pe=c((M+U)*(J+H)-ne-Q),ye=ce-re,ie=ce+re,he=c(Q-C*ne),me=c(pe*ye),Re=c(ie*he),xe=c(pe*he),it=c(ye*ie);return new j(me,Re,it,xe)}subtract(b){return this.add(b.negate())}wNAF(b){return K.wNAFCached(this,A,b,j.normalizeZ)}multiply(b){let{p:C,f:N}=this.wNAF(S(b,n));return j.normalizeZ([C,N])[0]}multiplyUnsafe(b){let C=P(b);return C===ju?F:this.equals(F)||C===Lc?this:this.equals(L)?this.wNAF(C).p:K.unsafeLadder(this,C)}isSmallOrder(){return this.multiplyUnsafe(d).is0()}isTorsionFree(){return K.unsafeLadder(this,n).is0()}toAffine(b){let{ex:C,ey:N,ez:M}=this,U=this.is0();b==null&&(b=U?w7e:r.inv(M));let G=c(C*b),Z=c(N*b),J=c(M*b);if(U)return{x:ju,y:Lc};if(J!==Lc)throw new Error("invZ was invalid");return{x:G,y:Z}}clearCofactor(){let{h:b}=e;return b===Lc?this:this.multiplyUnsafe(b)}static fromHex(b,C=!1){let{d:N,a:M}=e,U=r.BYTES;b=(0,Rm.ensureBytes)("pointHex",b,U);let G=b.slice(),Z=b[U-1];G[U-1]=Z&-129;let J=Ph.bytesToNumberLE(G);J===ju||(C?S(J,u):S(J,r.ORDER));let H=c(J*J),X=c(H-Lc),te=c(N*H-M),{isValid:ne,value:Q}=l(X,te);if(!ne)throw new Error("Point.fromHex: invalid y coordinate");let re=(Q&Lc)===Lc,ce=(Z&128)!==0;if(!C&&Q===ju&&ce)throw new Error("Point.fromHex: x=0 and x_0=1");return ce!==re&&(Q=c(-Q)),j.fromAffine({x:Q,y:J})}static fromPrivateKey(b){return I(b).point}toRawBytes(){let{x:b,y:C}=this.toAffine(),N=Ph.numberToBytesLE(C,r.BYTES);return N[N.length-1]|=b&Lc?128:0,N}toHex(){return Ph.bytesToHex(this.toRawBytes())}}j.BASE=new j(e.Gx,e.Gy,Lc,c(e.Gx*e.Gy)),j.ZERO=new j(ju,Lc,Lc,ju);let{BASE:L,ZERO:F}=j,K=(0,Zie.wNAF)(j,a*8);function W(_){return(0,b7e.mod)(_,n)}function q(_){return W(Ph.bytesToNumberLE(_))}function I(_){let b=a;_=(0,Rm.ensureBytes)("private key",_,b);let C=(0,Rm.ensureBytes)("hashed private key",o(_),2*b),N=p(C.slice(0,b)),M=C.slice(b,2*b),U=q(N),G=L.multiply(U),Z=G.toRawBytes();return{head:N,prefix:M,scalar:U,point:G,pointBytes:Z}}function T(_){return I(_).pointBytes}function B(_=new Uint8Array,...b){let C=Ph.concatBytes(...b);return q(o(m(C,(0,Rm.ensureBytes)("context",_),!!i)))}function h(_,b,C={}){_=(0,Rm.ensureBytes)("message",_),i&&(_=i(_));let{prefix:N,scalar:M,pointBytes:U}=I(b),G=B(C.context,N,_),Z=L.multiply(G).toRawBytes(),J=B(C.context,Z,U,_),H=W(G+J*M);P(H);let X=Ph.concatBytes(Z,Ph.numberToBytesLE(H,r.BYTES));return(0,Rm.ensureBytes)("result",X,a*2)}let y=_7e;function w(_,b,C,N=y){let{context:M,zip215:U}=N,G=r.BYTES;_=(0,Rm.ensureBytes)("signature",_,2*G),b=(0,Rm.ensureBytes)("message",b),i&&(b=i(b));let Z=Ph.bytesToNumberLE(_.slice(G,2*G)),J,H,X;try{J=j.fromHex(C,U),H=j.fromHex(_.slice(0,G),U),X=L.multiplyUnsafe(Z)}catch{return!1}if(!U&&J.isSmallOrder())return!1;let te=B(M,H.toRawBytes(),J.toRawBytes(),b);return H.add(J.multiplyUnsafe(te)).subtract(X).clearCofactor().equals(j.ZERO)}return L._setWindowSize(8),{CURVE:e,getPublicKey:T,sign:h,verify:w,ExtendedPoint:j,utils:{getExtendedPublicKey:I,randomPrivateKey:()=>s(r.BYTES),precompute(_=8,b=j.BASE){return b._setWindowSize(_),b.multiply(BigInt(3)),b}}}}$A.twistedEdwards=E7e});var Qie=V(jA=>{"use strict";f();Object.defineProperty(jA,"__esModule",{value:!0});jA.montgomery=void 0;var Xie=km(),l1=$u(),jE=BigInt(0),PC=BigInt(1);function S7e(t){return(0,l1.validateObject)(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function A7e(t){let e=S7e(t),{P:r}=e,n=A=>(0,Xie.mod)(A,r),i=e.montgomeryBits,o=Math.ceil(i/8),s=e.nByteLength,a=e.adjustScalarBytes||(A=>A),d=e.powPminus2||(A=>(0,Xie.pow)(A,r-BigInt(2),r));function u(A,$,j){let L=n(A*($-j));return $=n($-L),j=n(j+L),[$,j]}function c(A){if(typeof A=="bigint"&&jE<=A&&A=jE;y--){let w=L>>y&PC;T^=w,B=u(T,K,q),K=B[0],q=B[1],B=u(T,W,I),W=B[0],I=B[1],T=w;let E=K+W,_=n(E*E),b=K-W,C=n(b*b),N=_-C,M=q+I,U=q-I,G=n(U*E),Z=n(M*b),J=G+Z,H=G-Z;q=n(J*J),I=n(F*n(H*H)),K=n(_*C),W=n(N*(_+n(l*N)))}B=u(T,K,q),K=B[0],q=B[1],B=u(T,W,I),W=B[0],I=B[1];let h=d(W);return n(K*h)}function m(A){return(0,l1.numberToBytesLE)(n(A),o)}function g(A){let $=(0,l1.ensureBytes)("u coordinate",A,o);return s===32&&($[31]&=127),(0,l1.bytesToNumberLE)($)}function v(A){let $=(0,l1.ensureBytes)("scalar",A),j=$.length;if(j!==o&&j!==s)throw new Error(`Expected ${o} or ${s} bytes, got ${j}`);return(0,l1.bytesToNumberLE)(a($))}function x(A,$){let j=g($),L=v(A),F=p(j,L);if(F===jE)throw new Error("Invalid private or public key received");return m(F)}let S=m(e.Gu);function P(A){return x(A,S)}return{scalarMult:x,scalarMultBase:P,getSharedSecret:(A,$)=>x(A,$),getPublicKey:A=>P(A),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:S}}jA.montgomery=A7e});var RC=V(Od=>{"use strict";f();Object.defineProperty(Od,"__esModule",{value:!0});Od.createHasher=Od.isogenyMap=Od.hash_to_field=Od.expand_message_xof=Od.expand_message_xmd=void 0;var T7e=km(),Kc=$u();function P7e(t){if((0,Kc.isBytes)(t))return t;if(typeof t=="string")return(0,Kc.utf8ToBytes)(t);throw new Error("DST must be Uint8Array or string")}var I7e=Kc.bytesToNumberBE;function Dm(t,e){if(t<0||t>=1<<8*e)throw new Error(`bad I2OSP call: value=${t} length=${e}`);let r=Array.from({length:e}).fill(0);for(let n=e-1;n>=0;n--)r[n]=t&255,t>>>=8;return new Uint8Array(r)}function k7e(t,e){let r=new Uint8Array(t.length);for(let n=0;n255&&(e=n((0,Kc.concatBytes)((0,Kc.utf8ToBytes)("H2C-OVERSIZE-DST-"),e)));let{outputLen:i,blockLen:o}=n,s=Math.ceil(r/i);if(s>255)throw new Error("Invalid xmd length");let a=(0,Kc.concatBytes)(e,Dm(e.length,1)),d=Dm(0,o),u=Dm(r,2),c=new Array(s),l=n((0,Kc.concatBytes)(d,t,u,Dm(0,1),a));c[0]=n((0,Kc.concatBytes)(l,Dm(1,1),a));for(let m=1;m<=s;m++){let g=[k7e(l,c[m-1]),Dm(m+1,1),a];c[m]=n((0,Kc.concatBytes)(...g))}return(0,Kc.concatBytes)(...c).slice(0,r)}Od.expand_message_xmd=eoe;function toe(t,e,r,n,i){if(NE(t),NE(e),kC(r),e.length>255){let o=Math.ceil(2*n/8);e=i.create({dkLen:o}).update((0,Kc.utf8ToBytes)("H2C-OVERSIZE-DST-")).update(e).digest()}if(r>65535||e.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return i.create({dkLen:r}).update(t).update(Dm(r,2)).update(e).update(Dm(e.length,1)).digest()}Od.expand_message_xof=toe;function IC(t,e,r){(0,Kc.validateObject)(r,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});let{p:n,k:i,m:o,hash:s,expand:a,DST:d}=r;NE(t),kC(e);let u=P7e(d),c=n.toString(2).length,l=Math.ceil((c+i)/8),p=e*o*l,m;if(a==="xmd")m=eoe(t,u,p,s);else if(a==="xof")m=toe(t,u,p,i,s);else if(a==="_internal_pass")m=t;else throw new Error('expand must be "xmd" or "xof"');let g=new Array(e);for(let v=0;vArray.from(n).reverse());return(n,i)=>{let[o,s,a,d]=r.map(u=>u.reduce((c,l)=>t.add(t.mul(c,n),l)));return n=t.div(o,s),i=t.mul(i,t.div(a,d)),{x:n,y:i}}}Od.isogenyMap=R7e;function D7e(t,e,r){if(typeof e!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(n,i){let o=IC(n,2,{...r,DST:r.DST,...i}),s=t.fromAffine(e(o[0])),a=t.fromAffine(e(o[1])),d=s.add(a).clearCofactor();return d.assertValidity(),d},encodeToCurve(n,i){let o=IC(n,1,{...r,DST:r.encodeDST,...i}),s=t.fromAffine(e(o[0])).clearCofactor();return s.assertValidity(),s}}}Od.createHasher=D7e});var poe=V(jt=>{"use strict";f();Object.defineProperty(jt,"__esModule",{value:!0});jt.hash_to_ristretto255=jt.hashToRistretto255=jt.RistrettoPoint=jt.encodeToCurve=jt.hashToCurve=jt.edwardsToMontgomeryPriv=jt.edwardsToMontgomery=jt.edwardsToMontgomeryPub=jt.x25519=jt.ed25519ph=jt.ed25519ctx=jt.ed25519=jt.ED25519_TORSION_SUBGROUP=void 0;var UA=Oie(),UE=Am(),CC=Yie(),B7e=Qie(),on=km(),Bg=$u(),coe=RC(),qE=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),MC=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),M7e=BigInt(0),Wl=BigInt(1),NA=BigInt(2),O7e=BigInt(5),roe=BigInt(10),C7e=BigInt(20),$7e=BigInt(40),noe=BigInt(80);function doe(t){let e=qE,n=t*t%e*t%e,i=(0,on.pow2)(n,NA,e)*n%e,o=(0,on.pow2)(i,Wl,e)*t%e,s=(0,on.pow2)(o,O7e,e)*o%e,a=(0,on.pow2)(s,roe,e)*s%e,d=(0,on.pow2)(a,C7e,e)*a%e,u=(0,on.pow2)(d,$7e,e)*d%e,c=(0,on.pow2)(u,noe,e)*u%e,l=(0,on.pow2)(c,noe,e)*u%e,p=(0,on.pow2)(l,roe,e)*s%e;return{pow_p_5_8:(0,on.pow2)(p,NA,e)*t%e,b2:n}}function uoe(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function $C(t,e){let r=qE,n=(0,on.mod)(e*e*e,r),i=(0,on.mod)(n*n*e,r),o=doe(t*i).pow_p_5_8,s=(0,on.mod)(t*n*o,r),a=(0,on.mod)(e*s*s,r),d=s,u=(0,on.mod)(s*MC,r),c=a===t,l=a===(0,on.mod)(-t,r),p=a===(0,on.mod)(-t*MC,r);return c&&(s=d),(l||p)&&(s=u),(0,on.isNegativeLE)(s,r)&&(s=(0,on.mod)(-s,r)),{isValid:c||l,value:s}}jt.ED25519_TORSION_SUBGROUP=["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"];var Le=(0,on.Field)(qE,void 0,!0),LE={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Le,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:UA.sha512,randomBytes:UE.randomBytes,adjustScalarBytes:uoe,uvRatio:$C};jt.ed25519=(0,CC.twistedEdwards)(LE);function loe(t,e,r){if(e.length>255)throw new Error("Context is too big");return(0,UE.concatBytes)((0,UE.utf8ToBytes)("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,e.length]),e,t)}jt.ed25519ctx=(0,CC.twistedEdwards)({...LE,domain:loe});jt.ed25519ph=(0,CC.twistedEdwards)({...LE,domain:loe,prehash:UA.sha512});jt.x25519=(0,B7e.montgomery)({P:qE,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{let e=qE,{pow_p_5_8:r,b2:n}=doe(t);return(0,on.mod)((0,on.pow2)(r,BigInt(3),e)*n,e)},adjustScalarBytes:uoe,randomBytes:UE.randomBytes});function foe(t){let{y:e}=jt.ed25519.ExtendedPoint.fromHex(t),r=BigInt(1);return Le.toBytes(Le.create((r+e)*Le.inv(r-e)))}jt.edwardsToMontgomeryPub=foe;jt.edwardsToMontgomery=foe;function j7e(t){let e=LE.hash(t.subarray(0,32));return LE.adjustScalarBytes(e).subarray(0,32)}jt.edwardsToMontgomeryPriv=j7e;var N7e=(Le.ORDER+BigInt(3))/BigInt(8),U7e=Le.pow(NA,N7e),ioe=Le.sqrt(Le.neg(Le.ONE)),q7e=(Le.ORDER-BigInt(5))/BigInt(8),ooe=BigInt(486662);function L7e(t){let e=Le.sqr(t);e=Le.mul(e,NA);let r=Le.add(e,Le.ONE),n=Le.neg(ooe),i=Le.sqr(r),o=Le.mul(i,r),s=Le.mul(e,ooe);s=Le.mul(s,n),s=Le.add(s,i),s=Le.mul(s,n);let a=Le.sqr(o);i=Le.sqr(a),a=Le.mul(a,o),a=Le.mul(a,s),i=Le.mul(i,a);let d=Le.pow(i,q7e);d=Le.mul(d,a);let u=Le.mul(d,ioe);i=Le.sqr(d),i=Le.mul(i,o);let c=Le.eql(i,s),l=Le.cmov(u,d,c),p=Le.mul(n,e),m=Le.mul(d,t);m=Le.mul(m,U7e);let g=Le.mul(m,ioe),v=Le.mul(s,e);i=Le.sqr(m),i=Le.mul(i,o);let x=Le.eql(i,v),S=Le.cmov(g,m,x);i=Le.sqr(l),i=Le.mul(i,o);let P=Le.eql(i,s),A=Le.cmov(p,n,P),$=Le.cmov(S,l,P),j=Le.isOdd($);return $=Le.cmov($,Le.neg($),P!==j),{xMn:A,xMd:r,yMn:$,yMd:Wl}}var K7e=(0,on.FpSqrtEven)(Le,Le.neg(BigInt(486664)));function F7e(t){let{xMn:e,xMd:r,yMn:n,yMd:i}=L7e(t),o=Le.mul(e,i);o=Le.mul(o,K7e);let s=Le.mul(r,n),a=Le.sub(e,r),d=Le.add(e,r),u=Le.mul(s,d),c=Le.eql(u,Le.ZERO);o=Le.cmov(o,Le.ZERO,c),s=Le.cmov(s,Le.ONE,c),a=Le.cmov(a,Le.ONE,c),d=Le.cmov(d,Le.ONE,c);let l=Le.invertBatch([s,d]);return{x:Le.mul(o,l[0]),y:Le.mul(a,l[1])}}var hoe=(0,coe.createHasher)(jt.ed25519.ExtendedPoint,t=>F7e(t[0]),{DST:"edwards25519_XMD:SHA-512_ELL2_RO_",encodeDST:"edwards25519_XMD:SHA-512_ELL2_NU_",p:Le.ORDER,m:1,k:128,expand:"xmd",hash:UA.sha512});jt.hashToCurve=hoe.hashToCurve;jt.encodeToCurve=hoe.encodeToCurve;function DC(t){if(!(t instanceof Nu))throw new Error("RistrettoPoint expected")}var OC=MC,z7e=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),W7e=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),H7e=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),V7e=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),soe=t=>$C(Wl,t),G7e=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),BC=t=>jt.ed25519.CURVE.Fp.create((0,Bg.bytesToNumberLE)(t)&G7e);function aoe(t){let{d:e}=jt.ed25519.CURVE,r=jt.ed25519.CURVE.Fp.ORDER,n=jt.ed25519.CURVE.Fp.create,i=n(OC*t*t),o=n((i+Wl)*H7e),s=BigInt(-1),a=n((s-e*i)*n(i+e)),{isValid:d,value:u}=$C(o,a),c=n(u*t);(0,on.isNegativeLE)(c,r)||(c=n(-c)),d||(u=c),d||(s=i);let l=n(s*(i-Wl)*V7e-a),p=u*u,m=n((u+u)*a),g=n(l*z7e),v=n(Wl-p),x=n(Wl+p);return new jt.ed25519.ExtendedPoint(n(m*x),n(v*g),n(g*x),n(m*v))}var Nu=class t{constructor(e){this.ep=e}static fromAffine(e){return new t(jt.ed25519.ExtendedPoint.fromAffine(e))}static hashToCurve(e){e=(0,Bg.ensureBytes)("ristrettoHash",e,64);let r=BC(e.slice(0,32)),n=aoe(r),i=BC(e.slice(32,64)),o=aoe(i);return new t(n.add(o))}static fromHex(e){e=(0,Bg.ensureBytes)("ristrettoHex",e,32);let{a:r,d:n}=jt.ed25519.CURVE,i=jt.ed25519.CURVE.Fp.ORDER,o=jt.ed25519.CURVE.Fp.create,s="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",a=BC(e);if(!(0,Bg.equalBytes)((0,Bg.numberToBytesLE)(a,32),e)||(0,on.isNegativeLE)(a,i))throw new Error(s);let d=o(a*a),u=o(Wl+r*d),c=o(Wl-r*d),l=o(u*u),p=o(c*c),m=o(r*n*l-p),{isValid:g,value:v}=soe(o(m*p)),x=o(v*c),S=o(v*x*m),P=o((a+a)*x);(0,on.isNegativeLE)(P,i)&&(P=o(-P));let A=o(u*S),$=o(P*A);if(!g||(0,on.isNegativeLE)($,i)||A===M7e)throw new Error(s);return new t(new jt.ed25519.ExtendedPoint(P,A,Wl,$))}toRawBytes(){let{ex:e,ey:r,ez:n,et:i}=this.ep,o=jt.ed25519.CURVE.Fp.ORDER,s=jt.ed25519.CURVE.Fp.create,a=s(s(n+r)*s(n-r)),d=s(e*r),u=s(d*d),{value:c}=soe(s(a*u)),l=s(c*a),p=s(c*d),m=s(l*p*i),g;if((0,on.isNegativeLE)(i*m,o)){let x=s(r*OC),S=s(e*OC);e=x,r=S,g=s(l*W7e)}else g=p;(0,on.isNegativeLE)(e*m,o)&&(r=s(-r));let v=s((n-r)*g);return(0,on.isNegativeLE)(v,o)&&(v=s(-v)),(0,Bg.numberToBytesLE)(v,32)}toHex(){return(0,Bg.bytesToHex)(this.toRawBytes())}toString(){return this.toHex()}equals(e){DC(e);let{ex:r,ey:n}=this.ep,{ex:i,ey:o}=e.ep,s=jt.ed25519.CURVE.Fp.create,a=s(r*o)===s(n*i),d=s(n*o)===s(r*i);return a||d}add(e){return DC(e),new t(this.ep.add(e.ep))}subtract(e){return DC(e),new t(this.ep.subtract(e.ep))}multiply(e){return new t(this.ep.multiply(e))}multiplyUnsafe(e){return new t(this.ep.multiplyUnsafe(e))}double(){return new t(this.ep.double())}negate(){return new t(this.ep.negate())}};jt.RistrettoPoint=(Nu.BASE||(Nu.BASE=new Nu(jt.ed25519.ExtendedPoint.BASE)),Nu.ZERO||(Nu.ZERO=new Nu(jt.ed25519.ExtendedPoint.ZERO)),Nu);var J7e=(t,e)=>{let r=e.DST,n=typeof r=="string"?(0,UE.utf8ToBytes)(r):r,i=(0,coe.expand_message_xmd)(t,n,64,UA.sha512);return Nu.hashToCurve(i)};jt.hashToRistretto255=J7e;jt.hash_to_ristretto255=jt.hashToRistretto255});var moe=V(f1=>{"use strict";f();Object.defineProperty(f1,"__esModule",{value:!0});f1.sha224=f1.sha256=void 0;var Z7e=hC(),Cd=Am(),Y7e=(t,e,r)=>t&e^~t&r,X7e=(t,e,r)=>t&e^t&r^e&r,Q7e=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]),Bm=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Mm=new Uint32Array(64),qA=class extends Z7e.SHA2{constructor(){super(64,32,8,!1),this.A=Bm[0]|0,this.B=Bm[1]|0,this.C=Bm[2]|0,this.D=Bm[3]|0,this.E=Bm[4]|0,this.F=Bm[5]|0,this.G=Bm[6]|0,this.H=Bm[7]|0}get(){let{A:e,B:r,C:n,D:i,E:o,F:s,G:a,H:d}=this;return[e,r,n,i,o,s,a,d]}set(e,r,n,i,o,s,a,d){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=d|0}process(e,r){for(let l=0;l<16;l++,r+=4)Mm[l]=e.getUint32(r,!1);for(let l=16;l<64;l++){let p=Mm[l-15],m=Mm[l-2],g=(0,Cd.rotr)(p,7)^(0,Cd.rotr)(p,18)^p>>>3,v=(0,Cd.rotr)(m,17)^(0,Cd.rotr)(m,19)^m>>>10;Mm[l]=v+Mm[l-7]+g+Mm[l-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:d,G:u,H:c}=this;for(let l=0;l<64;l++){let p=(0,Cd.rotr)(a,6)^(0,Cd.rotr)(a,11)^(0,Cd.rotr)(a,25),m=c+p+Y7e(a,d,u)+Q7e[l]+Mm[l]|0,v=((0,Cd.rotr)(n,2)^(0,Cd.rotr)(n,13)^(0,Cd.rotr)(n,22))+X7e(n,i,o)|0;c=u,u=d,d=a,a=s+m|0,s=o,o=i,i=n,n=m+v|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,d=d+this.F|0,u=u+this.G|0,c=c+this.H|0,this.set(n,i,o,s,a,d,u,c)}roundClean(){Mm.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},jC=class extends qA{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}};f1.sha256=(0,Cd.wrapConstructor)(()=>new qA);f1.sha224=(0,Cd.wrapConstructor)(()=>new jC)});var UC=V(io=>{"use strict";f();Object.defineProperty(io,"__esModule",{value:!0});io.mapToCurveSimpleSWU=io.SWUFpSqrtRatio=io.weierstrass=io.weierstrassPoints=io.DER=void 0;var h1=km(),ti=$u(),Hl=$u(),NC=TC();function eMe(t){let e=(0,NC.validateBasic)(t);ti.validateObject(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:r,Fp:n,a:i}=e;if(r){if(!n.eql(i,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:tMe,hexToBytes:rMe}=ti;io.DER={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(t){let{Err:e}=io.DER;if(t.length<2||t[0]!==2)throw new e("Invalid signature integer tag");let r=t[1],n=t.subarray(2,r+2);if(!r||n.length!==r)throw new e("Invalid signature integer: wrong length");if(n[0]&128)throw new e("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:tMe(n),l:t.subarray(r+2)}},toSig(t){let{Err:e}=io.DER,r=typeof t=="string"?rMe(t):t;if(!ti.isBytes(r))throw new Error("ui8a expected");let n=r.length;if(n<2||r[0]!=48)throw new e("Invalid signature tag");if(r[1]!==n-2)throw new e("Invalid signature: incorrect length");let{d:i,l:o}=io.DER._parseInt(r.subarray(2)),{d:s,l:a}=io.DER._parseInt(o);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:i,s}},hexFromSig(t){let e=u=>Number.parseInt(u[0],16)&8?"00"+u:u,r=u=>{let c=u.toString(16);return c.length&1?`0${c}`:c},n=e(r(t.s)),i=e(r(t.r)),o=n.length/2,s=i.length/2,a=r(o),d=r(s);return`30${r(s+o+4)}02${d}${i}02${a}${n}`}};var Uu=BigInt(0),bi=BigInt(1),Om=BigInt(2),LA=BigInt(3),yoe=BigInt(4);function goe(t){let e=eMe(t),{Fp:r}=e,n=e.toBytes||((g,v,x)=>{let S=v.toAffine();return ti.concatBytes(Uint8Array.from([4]),r.toBytes(S.x),r.toBytes(S.y))}),i=e.fromBytes||(g=>{let v=g.subarray(1),x=r.fromBytes(v.subarray(0,r.BYTES)),S=r.fromBytes(v.subarray(r.BYTES,2*r.BYTES));return{x,y:S}});function o(g){let{a:v,b:x}=e,S=r.sqr(g),P=r.mul(S,g);return r.add(r.add(P,r.mul(g,v)),x)}if(!r.eql(r.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function s(g){return typeof g=="bigint"&&Uur.eql(A,r.ZERO);return P(x)&&P(S)?l.ZERO:new l(x,S,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(v){let x=r.invertBatch(v.map(S=>S.pz));return v.map((S,P)=>S.toAffine(x[P])).map(l.fromAffine)}static fromHex(v){let x=l.fromAffine(i((0,Hl.ensureBytes)("pointHex",v)));return x.assertValidity(),x}static fromPrivateKey(v){return l.BASE.multiply(d(v))}_setWindowSize(v){this._WINDOW_SIZE=v,u.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}let{x:v,y:x}=this.toAffine();if(!r.isValid(v)||!r.isValid(x))throw new Error("bad point: x or y not FE");let S=r.sqr(x),P=o(v);if(!r.eql(S,P))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:v}=this.toAffine();if(r.isOdd)return!r.isOdd(v);throw new Error("Field doesn't support isOdd")}equals(v){c(v);let{px:x,py:S,pz:P}=this,{px:A,py:$,pz:j}=v,L=r.eql(r.mul(x,j),r.mul(A,P)),F=r.eql(r.mul(S,j),r.mul($,P));return L&&F}negate(){return new l(this.px,r.neg(this.py),this.pz)}double(){let{a:v,b:x}=e,S=r.mul(x,LA),{px:P,py:A,pz:$}=this,j=r.ZERO,L=r.ZERO,F=r.ZERO,K=r.mul(P,P),W=r.mul(A,A),q=r.mul($,$),I=r.mul(P,A);return I=r.add(I,I),F=r.mul(P,$),F=r.add(F,F),j=r.mul(v,F),L=r.mul(S,q),L=r.add(j,L),j=r.sub(W,L),L=r.add(W,L),L=r.mul(j,L),j=r.mul(I,j),F=r.mul(S,F),q=r.mul(v,q),I=r.sub(K,q),I=r.mul(v,I),I=r.add(I,F),F=r.add(K,K),K=r.add(F,K),K=r.add(K,q),K=r.mul(K,I),L=r.add(L,K),q=r.mul(A,$),q=r.add(q,q),K=r.mul(q,I),j=r.sub(j,K),F=r.mul(q,W),F=r.add(F,F),F=r.add(F,F),new l(j,L,F)}add(v){c(v);let{px:x,py:S,pz:P}=this,{px:A,py:$,pz:j}=v,L=r.ZERO,F=r.ZERO,K=r.ZERO,W=e.a,q=r.mul(e.b,LA),I=r.mul(x,A),T=r.mul(S,$),B=r.mul(P,j),h=r.add(x,S),y=r.add(A,$);h=r.mul(h,y),y=r.add(I,T),h=r.sub(h,y),y=r.add(x,P);let w=r.add(A,j);return y=r.mul(y,w),w=r.add(I,B),y=r.sub(y,w),w=r.add(S,P),L=r.add($,j),w=r.mul(w,L),L=r.add(T,B),w=r.sub(w,L),K=r.mul(W,y),L=r.mul(q,B),K=r.add(L,K),L=r.sub(T,K),K=r.add(T,K),F=r.mul(L,K),T=r.add(I,I),T=r.add(T,I),B=r.mul(W,B),y=r.mul(q,y),T=r.add(T,B),B=r.sub(I,B),B=r.mul(W,B),y=r.add(y,B),I=r.mul(T,y),F=r.add(F,I),I=r.mul(w,y),L=r.mul(h,L),L=r.sub(L,I),I=r.mul(h,T),K=r.mul(w,K),K=r.add(K,I),new l(L,F,K)}subtract(v){return this.add(v.negate())}is0(){return this.equals(l.ZERO)}wNAF(v){return m.wNAFCached(this,u,v,x=>{let S=r.invertBatch(x.map(P=>P.pz));return x.map((P,A)=>P.toAffine(S[A])).map(l.fromAffine)})}multiplyUnsafe(v){let x=l.ZERO;if(v===Uu)return x;if(a(v),v===bi)return this;let{endo:S}=e;if(!S)return m.unsafeLadder(this,v);let{k1neg:P,k1:A,k2neg:$,k2:j}=S.splitScalar(v),L=x,F=x,K=this;for(;A>Uu||j>Uu;)A&bi&&(L=L.add(K)),j&bi&&(F=F.add(K)),K=K.double(),A>>=bi,j>>=bi;return P&&(L=L.negate()),$&&(F=F.negate()),F=new l(r.mul(F.px,S.beta),F.py,F.pz),L.add(F)}multiply(v){a(v);let x=v,S,P,{endo:A}=e;if(A){let{k1neg:$,k1:j,k2neg:L,k2:F}=A.splitScalar(x),{p:K,f:W}=this.wNAF(j),{p:q,f:I}=this.wNAF(F);K=m.constTimeNegate($,K),q=m.constTimeNegate(L,q),q=new l(r.mul(q.px,A.beta),q.py,q.pz),S=K.add(q),P=W.add(I)}else{let{p:$,f:j}=this.wNAF(x);S=$,P=j}return l.normalizeZ([S,P])[0]}multiplyAndAddUnsafe(v,x,S){let P=l.BASE,A=(j,L)=>L===Uu||L===bi||!j.equals(P)?j.multiplyUnsafe(L):j.multiply(L),$=A(this,x).add(A(v,S));return $.is0()?void 0:$}toAffine(v){let{px:x,py:S,pz:P}=this,A=this.is0();v==null&&(v=A?r.ONE:r.inv(P));let $=r.mul(x,v),j=r.mul(S,v),L=r.mul(P,v);if(A)return{x:r.ZERO,y:r.ZERO};if(!r.eql(L,r.ONE))throw new Error("invZ was invalid");return{x:$,y:j}}isTorsionFree(){let{h:v,isTorsionFree:x}=e;if(v===bi)return!0;if(x)return x(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:v,clearCofactor:x}=e;return v===bi?this:x?x(l,this):this.multiplyUnsafe(e.h)}toRawBytes(v=!0){return this.assertValidity(),n(l,this,v)}toHex(v=!0){return ti.bytesToHex(this.toRawBytes(v))}}l.BASE=new l(e.Gx,e.Gy,r.ONE),l.ZERO=new l(r.ZERO,r.ONE,r.ZERO);let p=e.nBitLength,m=(0,NC.wNAF)(l,e.endo?Math.ceil(p/2):p);return{CURVE:e,ProjectivePoint:l,normPrivateKeyToScalar:d,weierstrassEquation:o,isWithinCurveOrder:s}}io.weierstrassPoints=goe;function nMe(t){let e=(0,NC.validateBasic)(t);return ti.validateObject(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function iMe(t){let e=nMe(t),{Fp:r,n}=e,i=r.BYTES+1,o=2*r.BYTES+1;function s(y){return Uuti.bytesToHex(ti.numberToBytesBE(y,e.nByteLength));function g(y){let w=n>>bi;return y>w}function v(y){return g(y)?a(-y):y}let x=(y,w,E)=>ti.bytesToNumberBE(y.slice(w,E));class S{constructor(w,E,_){this.r=w,this.s=E,this.recovery=_,this.assertValidity()}static fromCompact(w){let E=e.nByteLength;return w=(0,Hl.ensureBytes)("compactSignature",w,E*2),new S(x(w,0,E),x(w,E,2*E))}static fromDER(w){let{r:E,s:_}=io.DER.toSig((0,Hl.ensureBytes)("DER",w));return new S(E,_)}assertValidity(){if(!p(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!p(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(w){return new S(this.r,this.s,w)}recoverPublicKey(w){let{r:E,s:_,recovery:b}=this,C=F((0,Hl.ensureBytes)("msgHash",w));if(b==null||![0,1,2,3].includes(b))throw new Error("recovery id invalid");let N=b===2||b===3?E+e.n:E;if(N>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let M=b&1?"03":"02",U=u.fromHex(M+m(N)),G=d(N),Z=a(-C*G),J=a(_*G),H=u.BASE.multiplyAndAddUnsafe(U,Z,J);if(!H)throw new Error("point at infinify");return H.assertValidity(),H}hasHighS(){return g(this.s)}normalizeS(){return this.hasHighS()?new S(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return ti.hexToBytes(this.toDERHex())}toDERHex(){return io.DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return ti.hexToBytes(this.toCompactHex())}toCompactHex(){return m(this.r)+m(this.s)}}let P={isValidPrivateKey(y){try{return c(y),!0}catch{return!1}},normPrivateKeyToScalar:c,randomPrivateKey:()=>{let y=h1.getMinHashLength(e.n);return h1.mapHashToField(e.randomBytes(y),e.n)},precompute(y=8,w=u.BASE){return w._setWindowSize(y),w.multiply(BigInt(3)),w}};function A(y,w=!0){return u.fromPrivateKey(y).toRawBytes(w)}function $(y){let w=ti.isBytes(y),E=typeof y=="string",_=(w||E)&&y.length;return w?_===i||_===o:E?_===2*i||_===2*o:y instanceof u}function j(y,w,E=!0){if($(y))throw new Error("first arg must be private key");if(!$(w))throw new Error("second arg must be public key");return u.fromHex(w).multiply(c(y)).toRawBytes(E)}let L=e.bits2int||function(y){let w=ti.bytesToNumberBE(y),E=y.length*8-e.nBitLength;return E>0?w>>BigInt(E):w},F=e.bits2int_modN||function(y){return a(L(y))},K=ti.bitMask(e.nBitLength);function W(y){if(typeof y!="bigint")throw new Error("bigint expected");if(!(Uu<=y&&yte in E))throw new Error("sign() legacy options not supported");let{hash:_,randomBytes:b}=e,{lowS:C,prehash:N,extraEntropy:M}=E;C==null&&(C=!0),y=(0,Hl.ensureBytes)("msgHash",y),N&&(y=(0,Hl.ensureBytes)("prehashed msgHash",_(y)));let U=F(y),G=c(w),Z=[W(G),W(U)];if(M!=null){let te=M===!0?b(r.BYTES):M;Z.push((0,Hl.ensureBytes)("extraEntropy",te))}let J=ti.concatBytes(...Z),H=U;function X(te){let ne=L(te);if(!p(ne))return;let Q=d(ne),re=u.BASE.multiply(ne).toAffine(),ce=a(re.x);if(ce===Uu)return;let pe=a(Q*a(H+ce*G));if(pe===Uu)return;let ye=(re.x===ce?0:2)|Number(re.y&bi),ie=pe;return C&&g(pe)&&(ie=v(pe),ye^=1),new S(ce,ie,ye)}return{seed:J,k2sig:X}}let I={lowS:e.lowS,prehash:!1},T={lowS:e.lowS,prehash:!1};function B(y,w,E=I){let{seed:_,k2sig:b}=q(y,w,E),C=e;return ti.createHmacDrbg(C.hash.outputLen,C.nByteLength,C.hmac)(_,b)}u.BASE._setWindowSize(8);function h(y,w,E,_=T){let b=y;if(w=(0,Hl.ensureBytes)("msgHash",w),E=(0,Hl.ensureBytes)("publicKey",E),"strict"in _)throw new Error("options.strict was renamed to lowS");let{lowS:C,prehash:N}=_,M,U;try{if(typeof b=="string"||ti.isBytes(b))try{M=S.fromDER(b)}catch(re){if(!(re instanceof io.DER.Err))throw re;M=S.fromCompact(b)}else if(typeof b=="object"&&typeof b.r=="bigint"&&typeof b.s=="bigint"){let{r:re,s:ce}=b;M=new S(re,ce)}else throw new Error("PARSE");U=u.fromHex(E)}catch(re){if(re.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(C&&M.hasHighS())return!1;N&&(w=e.hash(w));let{r:G,s:Z}=M,J=F(w),H=d(Z),X=a(J*H),te=a(G*H),ne=u.BASE.multiplyAndAddUnsafe(U,X,te)?.toAffine();return ne?a(ne.x)===G:!1}return{CURVE:e,getPublicKey:A,getSharedSecret:j,sign:B,verify:h,ProjectivePoint:u,Signature:S,utils:P}}io.weierstrass=iMe;function voe(t,e){let r=t.ORDER,n=Uu;for(let g=r-bi;g%Om===Uu;g/=Om)n+=bi;let i=n,o=Om<{let x=l,S=t.pow(v,u),P=t.sqr(S);P=t.mul(P,v);let A=t.mul(g,P);A=t.pow(A,d),A=t.mul(A,S),S=t.mul(A,v),P=t.mul(A,g);let $=t.mul(P,S);A=t.pow($,c);let j=t.eql(A,t.ONE);S=t.mul(P,p),A=t.mul($,x),P=t.cmov(S,P,j),$=t.cmov(A,$,j);for(let L=i;L>bi;L--){let F=L-Om;F=Om<{let P=t.sqr(S),A=t.mul(x,S);P=t.mul(P,A);let $=t.pow(P,g);$=t.mul($,A);let j=t.mul($,v),L=t.mul(t.sqr($),S),F=t.eql(L,x),K=t.cmov(j,$,F);return{isValid:F,value:K}}}return m}io.SWUFpSqrtRatio=voe;function oMe(t,e){if(h1.validateField(t),!t.isValid(e.A)||!t.isValid(e.B)||!t.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");let r=voe(t,e.Z);if(!t.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let i,o,s,a,d,u,c,l;i=t.sqr(n),i=t.mul(i,e.Z),o=t.sqr(i),o=t.add(o,i),s=t.add(o,t.ONE),s=t.mul(s,e.B),a=t.cmov(e.Z,t.neg(o),!t.eql(o,t.ZERO)),a=t.mul(a,e.A),o=t.sqr(s),u=t.sqr(a),d=t.mul(u,e.A),o=t.add(o,d),o=t.mul(o,s),u=t.mul(u,a),d=t.mul(u,e.B),o=t.add(o,d),c=t.mul(i,s);let{isValid:p,value:m}=r(o,u);l=t.mul(i,n),l=t.mul(l,m),c=t.cmov(c,s,p),l=t.cmov(l,m,p);let g=t.isOdd(n)===t.isOdd(l);return l=t.cmov(t.neg(l),l,g),c=t.div(c,a),{x:c,y:l}}}io.mapToCurveSimpleSWU=oMe});var woe=V(Mg=>{"use strict";f();Object.defineProperty(Mg,"__esModule",{value:!0});Mg.hmac=Mg.HMAC=void 0;var KA=aC(),boe=Am(),KE=class extends boe.Hash{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,(0,KA.hash)(e);let n=(0,boe.toBytes)(r);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let i=this.blockLen,o=new Uint8Array(i);o.set(n.length>i?e.create().update(n).digest():n);for(let s=0;snew KE(t,e).update(r).digest();Mg.hmac=sMe;Mg.hmac.create=(t,e)=>new KE(t,e)});var Eoe=V(p1=>{"use strict";f();Object.defineProperty(p1,"__esModule",{value:!0});p1.createCurve=p1.getHash=void 0;var aMe=woe(),_oe=Am(),cMe=UC();function xoe(t){return{hash:t,hmac:(e,...r)=>(0,aMe.hmac)(t,e,(0,_oe.concatBytes)(...r)),randomBytes:_oe.randomBytes}}p1.getHash=xoe;function dMe(t,e){let r=n=>(0,cMe.weierstrass)({...t,...xoe(n)});return Object.freeze({...r(e),create:r})}p1.createCurve=dMe});var Ooe=V(tc=>{"use strict";f();Object.defineProperty(tc,"__esModule",{value:!0});tc.encodeToCurve=tc.hashToCurve=tc.schnorr=tc.secp256k1=void 0;var FA=moe(),uMe=Am(),jo=km(),lMe=UC(),Qs=$u(),Toe=RC(),fMe=Eoe(),VA=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),zA=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Poe=BigInt(1),WA=BigInt(2),Soe=(t,e)=>(t+e/WA)/e;function Ioe(t){let e=VA,r=BigInt(3),n=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),d=BigInt(88),u=t*t*t%e,c=u*u*t%e,l=(0,jo.pow2)(c,r,e)*c%e,p=(0,jo.pow2)(l,r,e)*c%e,m=(0,jo.pow2)(p,WA,e)*u%e,g=(0,jo.pow2)(m,i,e)*m%e,v=(0,jo.pow2)(g,o,e)*g%e,x=(0,jo.pow2)(v,a,e)*v%e,S=(0,jo.pow2)(x,d,e)*x%e,P=(0,jo.pow2)(S,a,e)*v%e,A=(0,jo.pow2)(P,r,e)*c%e,$=(0,jo.pow2)(A,s,e)*g%e,j=(0,jo.pow2)($,n,e)*u%e,L=(0,jo.pow2)(j,WA,e);if(!Cm.eql(Cm.sqr(L),t))throw new Error("Cannot find square root");return L}var Cm=(0,jo.Field)(VA,void 0,void 0,{sqrt:Ioe});tc.secp256k1=(0,fMe.createCurve)({a:BigInt(0),b:BigInt(7),Fp:Cm,n:zA,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{let e=zA,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Poe*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=r,s=BigInt("0x100000000000000000000000000000000"),a=Soe(o*t,e),d=Soe(-n*t,e),u=(0,jo.mod)(t-a*r-d*i,e),c=(0,jo.mod)(-a*n-d*o,e),l=u>s,p=c>s;if(l&&(u=e-u),p&&(c=e-c),u>s||c>s)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:l,k1:u,k2neg:p,k2:c}}}},FA.sha256);var GA=BigInt(0),koe=t=>typeof t=="bigint"&&GAtypeof t=="bigint"&&GAi.charCodeAt(0)));r=(0,Qs.concatBytes)(n,n),Aoe[t]=r}return(0,FA.sha256)((0,Qs.concatBytes)(r,...e))}var FC=t=>t.toRawBytes(!0).slice(1),LC=t=>(0,Qs.numberToBytesBE)(t,32),qC=t=>(0,jo.mod)(t,VA),FE=t=>(0,jo.mod)(t,zA),zC=tc.secp256k1.ProjectivePoint,pMe=(t,e,r)=>zC.BASE.multiplyAndAddUnsafe(t,e,r);function KC(t){let e=tc.secp256k1.utils.normPrivateKeyToScalar(t),r=zC.fromPrivateKey(e);return{scalar:r.hasEvenY()?e:FE(-e),bytes:FC(r)}}function Roe(t){if(!koe(t))throw new Error("bad x: need 0 < x < p");let e=qC(t*t),r=qC(e*t+BigInt(7)),n=Ioe(r);n%WA!==GA&&(n=qC(-n));let i=new zC(t,n,Poe);return i.assertValidity(),i}function Doe(...t){return FE((0,Qs.bytesToNumberBE)(HA("BIP0340/challenge",...t)))}function mMe(t){return KC(t).bytes}function yMe(t,e,r=(0,uMe.randomBytes)(32)){let n=(0,Qs.ensureBytes)("message",t),{bytes:i,scalar:o}=KC(e),s=(0,Qs.ensureBytes)("auxRand",r,32),a=LC(o^(0,Qs.bytesToNumberBE)(HA("BIP0340/aux",s))),d=HA("BIP0340/nonce",a,i,n),u=FE((0,Qs.bytesToNumberBE)(d));if(u===GA)throw new Error("sign failed: k is zero");let{bytes:c,scalar:l}=KC(u),p=Doe(c,i,n),m=new Uint8Array(64);if(m.set(c,0),m.set(LC(FE(l+p*o)),32),!Boe(m,n,i))throw new Error("sign: Invalid signature produced");return m}function Boe(t,e,r){let n=(0,Qs.ensureBytes)("signature",t,64),i=(0,Qs.ensureBytes)("message",e),o=(0,Qs.ensureBytes)("publicKey",r,32);try{let s=Roe((0,Qs.bytesToNumberBE)(o)),a=(0,Qs.bytesToNumberBE)(n.subarray(0,32));if(!koe(a))return!1;let d=(0,Qs.bytesToNumberBE)(n.subarray(32,64));if(!hMe(d))return!1;let u=Doe(LC(a),FC(s),i),c=pMe(s,d,FE(-u));return!(!c||!c.hasEvenY()||c.toAffine().x!==a)}catch{return!1}}tc.schnorr={getPublicKey:mMe,sign:yMe,verify:Boe,utils:{randomPrivateKey:tc.secp256k1.utils.randomPrivateKey,lift_x:Roe,pointToBytes:FC,numberToBytesBE:Qs.numberToBytesBE,bytesToNumberBE:Qs.bytesToNumberBE,taggedHash:HA,mod:jo.mod}};var gMe=(0,Toe.isogenyMap)(Cm,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map(t=>t.map(e=>BigInt(e)))),vMe=(0,lMe.mapToCurveSimpleSWU)(Cm,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:Cm.create(BigInt("-11"))}),Moe=(0,Toe.createHasher)(tc.secp256k1.ProjectivePoint,t=>{let{x:e,y:r}=vMe(Cm.create(t[0]));return gMe(e,r)},{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:Cm.ORDER,m:1,k:128,expand:"xmd",hash:FA.sha256});tc.hashToCurve=Moe.hashToCurve;tc.encodeToCurve=Moe.encodeToCurve});var WC=V(m1=>{"use strict";f();Object.defineProperty(m1,"__esModule",{value:!0});m1.decodeHex=m1.remove0x=void 0;var bMe=Cu();function Coe(t){return t.startsWith("0x")||t.startsWith("0X")?t.slice(2):t}m1.remove0x=Coe;function wMe(t){return(0,bMe.hexToBytes)(Coe(t))}m1.decodeHex=wMe});var VC=V(Pa=>{"use strict";f();Object.defineProperty(Pa,"__esModule",{value:!0});Pa.output=Pa.exists=Pa.hash=Pa.bytes=Pa.bool=Pa.number=void 0;function JA(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}Pa.number=JA;function $oe(t){if(typeof t!="boolean")throw new Error(`Expected boolean, not ${t}`)}Pa.bool=$oe;function HC(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}Pa.bytes=HC;function joe(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("hash must be wrapped by utils.wrapConstructor");JA(t.outputLen),JA(t.blockLen)}Pa.hash=joe;function Noe(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")}Pa.exists=Noe;function Uoe(t,e){HC(t);let r=e.outputLen;if(t.length{"use strict";f();Object.defineProperty(y1,"__esModule",{value:!0});y1.poly1305=y1.wrapConstructorWithKey=void 0;var ZA=Cu(),GC=VC(),ss=(t,e)=>t[e++]&255|(t[e++]&255)<<8,JC=class{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,e=(0,ZA.toBytes)(e),(0,ZA.ensureBytes)(e,32);let r=ss(e,0),n=ss(e,2),i=ss(e,4),o=ss(e,6),s=ss(e,8),a=ss(e,10),d=ss(e,12),u=ss(e,14);this.r[0]=r&8191,this.r[1]=(r>>>13|n<<3)&8191,this.r[2]=(n>>>10|i<<6)&7939,this.r[3]=(i>>>7|o<<9)&8191,this.r[4]=(o>>>4|s<<12)&255,this.r[5]=s>>>1&8190,this.r[6]=(s>>>14|a<<2)&8191,this.r[7]=(a>>>11|d<<5)&8065,this.r[8]=(d>>>8|u<<8)&8191,this.r[9]=u>>>5&127;for(let c=0;c<8;c++)this.pad[c]=ss(e,16+2*c)}process(e,r,n=!1){let i=n?0:2048,{h:o,r:s}=this,a=s[0],d=s[1],u=s[2],c=s[3],l=s[4],p=s[5],m=s[6],g=s[7],v=s[8],x=s[9],S=ss(e,r+0),P=ss(e,r+2),A=ss(e,r+4),$=ss(e,r+6),j=ss(e,r+8),L=ss(e,r+10),F=ss(e,r+12),K=ss(e,r+14),W=o[0]+(S&8191),q=o[1]+((S>>>13|P<<3)&8191),I=o[2]+((P>>>10|A<<6)&8191),T=o[3]+((A>>>7|$<<9)&8191),B=o[4]+(($>>>4|j<<12)&8191),h=o[5]+(j>>>1&8191),y=o[6]+((j>>>14|L<<2)&8191),w=o[7]+((L>>>11|F<<5)&8191),E=o[8]+((F>>>8|K<<8)&8191),_=o[9]+(K>>>5|i),b=0,C=b+W*a+q*(5*x)+I*(5*v)+T*(5*g)+B*(5*m);b=C>>>13,C&=8191,C+=h*(5*p)+y*(5*l)+w*(5*c)+E*(5*u)+_*(5*d),b+=C>>>13,C&=8191;let N=b+W*d+q*a+I*(5*x)+T*(5*v)+B*(5*g);b=N>>>13,N&=8191,N+=h*(5*m)+y*(5*p)+w*(5*l)+E*(5*c)+_*(5*u),b+=N>>>13,N&=8191;let M=b+W*u+q*d+I*a+T*(5*x)+B*(5*v);b=M>>>13,M&=8191,M+=h*(5*g)+y*(5*m)+w*(5*p)+E*(5*l)+_*(5*c),b+=M>>>13,M&=8191;let U=b+W*c+q*u+I*d+T*a+B*(5*x);b=U>>>13,U&=8191,U+=h*(5*v)+y*(5*g)+w*(5*m)+E*(5*p)+_*(5*l),b+=U>>>13,U&=8191;let G=b+W*l+q*c+I*u+T*d+B*a;b=G>>>13,G&=8191,G+=h*(5*x)+y*(5*v)+w*(5*g)+E*(5*m)+_*(5*p),b+=G>>>13,G&=8191;let Z=b+W*p+q*l+I*c+T*u+B*d;b=Z>>>13,Z&=8191,Z+=h*a+y*(5*x)+w*(5*v)+E*(5*g)+_*(5*m),b+=Z>>>13,Z&=8191;let J=b+W*m+q*p+I*l+T*c+B*u;b=J>>>13,J&=8191,J+=h*d+y*a+w*(5*x)+E*(5*v)+_*(5*g),b+=J>>>13,J&=8191;let H=b+W*g+q*m+I*p+T*l+B*c;b=H>>>13,H&=8191,H+=h*u+y*d+w*a+E*(5*x)+_*(5*v),b+=H>>>13,H&=8191;let X=b+W*v+q*g+I*m+T*p+B*l;b=X>>>13,X&=8191,X+=h*c+y*u+w*d+E*a+_*(5*x),b+=X>>>13,X&=8191;let te=b+W*x+q*v+I*g+T*m+B*p;b=te>>>13,te&=8191,te+=h*l+y*c+w*u+E*d+_*a,b+=te>>>13,te&=8191,b=(b<<2)+b|0,b=b+C|0,C=b&8191,b=b>>>13,N+=b,o[0]=C,o[1]=N,o[2]=M,o[3]=U,o[4]=G,o[5]=Z,o[6]=J,o[7]=H,o[8]=X,o[9]=te}finalize(){let{h:e,pad:r}=this,n=new Uint16Array(10),i=e[1]>>>13;e[1]&=8191;for(let a=2;a<10;a++)e[a]+=i,i=e[a]>>>13,e[a]&=8191;e[0]+=i*5,i=e[0]>>>13,e[0]&=8191,e[1]+=i,i=e[1]>>>13,e[1]&=8191,e[2]+=i,n[0]=e[0]+5,i=n[0]>>>13,n[0]&=8191;for(let a=1;a<10;a++)n[a]=e[a]+i,i=n[a]>>>13,n[a]&=8191;n[9]-=8192;let o=(i^1)-1;for(let a=0;a<10;a++)n[a]&=o;o=~o;for(let a=0;a<10;a++)e[a]=e[a]&o|n[a];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let s=e[0]+r[0];e[0]=s&65535;for(let a=1;a<8;a++)s=(e[a]+r[a]|0)+(s>>>16)|0,e[a]=s&65535}update(e){GC.default.exists(this);let{buffer:r,blockLen:n}=this;e=(0,ZA.toBytes)(e);let i=e.length;for(let o=0;o>>0,e[o++]=n[s]>>>8;return e}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}};function qoe(t){let e=(n,i)=>t(i).update((0,ZA.toBytes)(n)).digest(),r=t(new Uint8Array(32));return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}y1.wrapConstructorWithKey=qoe;y1.poly1305=qoe(t=>new JC(t))});var Koe=V(XA=>{"use strict";f();Object.defineProperty(XA,"__esModule",{value:!0});XA.salsaBasic=void 0;var Vl=VC(),Gl=Cu(),xMe=(0,Gl.utf8ToBytes)("expand 16-byte k"),EMe=(0,Gl.utf8ToBytes)("expand 32-byte k"),SMe=(0,Gl.u32)(xMe),AMe=(0,Gl.u32)(EMe),YA=t=>!(t.byteOffset%4),TMe=t=>{let{core:e,rounds:r,counterRight:n,counterLen:i,allow128bitKeys:o,extendNonceFn:s,blockLen:a}=(0,Gl.checkOpts)({rounds:20,counterRight:!1,counterLen:8,allow128bitKeys:!0,blockLen:64},t);Vl.default.number(i),Vl.default.number(r),Vl.default.number(a),Vl.default.bool(n),Vl.default.bool(o);let d=a/4;if(a%4!==0)throw new Error("Salsa/ChaCha: blockLen must be aligned to 4 bytes");return(u,c,l,p,m=0)=>{if(Vl.default.bytes(u),Vl.default.bytes(c),Vl.default.bytes(l),p||(p=new Uint8Array(l.length)),Vl.default.bytes(p),Vl.default.number(m),m<0||m>=2**32-1)throw new Error("Salsa/ChaCha: counter overflow");if(p.length=2**32-1)throw new Error("Salsa/ChaCha: counter overflow");let I=Math.min(a,K-W);if(I===a&&F&&L){let T=W/4;if(W%4!==0)throw new Error("Salsa/ChaCha: invalid block position");for(let B=0;B{"use strict";f();Object.defineProperty(Gn,"__esModule",{value:!0});Gn.xchacha20poly1305=Gn.chacha20poly1305=Gn._poly1305_aead=Gn.chacha12=Gn.chacha8=Gn.xchacha20=Gn.chacha20=Gn.chacha20orig=Gn.hchacha=void 0;var qu=Cu(),PMe=Loe(),zE=Koe(),et=(t,e)=>t<>>32-e;function WE(t,e,r,n,i,o=20){let s=t[0],a=t[1],d=t[2],u=t[3],c=e[0],l=e[1],p=e[2],m=e[3],g=e[4],v=e[5],x=e[6],S=e[7],P=i,A=r[0],$=r[1],j=r[2],L=s,F=a,K=d,W=u,q=c,I=l,T=p,B=m,h=g,y=v,w=x,E=S,_=P,b=A,C=$,N=j;for(let U=0;U{t.update(e);let r=e.length%16;r&&t.update(IMe.subarray(r))},zoe=(t,e,r,n,i)=>{let o=t(e,r,new Uint8Array(32)),s=PMe.poly1305.create(o);i&&Foe(s,i),Foe(s,n);let a=new Uint8Array(16),d=(0,qu.createView)(a);(0,qu.setBigUint64)(d,0,BigInt(i?i.length:0),!0),(0,qu.setBigUint64)(d,8,BigInt(n.length),!0),s.update(a);let u=s.digest();return o.fill(0),u},kMe=t=>(e,r,n)=>((0,qu.ensureBytes)(e,32),(0,qu.ensureBytes)(r),{tagLength:16,encrypt:(o,s)=>{let a=o.length,d=a+16;s?(0,qu.ensureBytes)(s,d):s=new Uint8Array(d),t(e,r,o,s,1);let u=zoe(t,e,r,s.subarray(0,-16),n);return s.set(u,a),s},decrypt:(o,s)=>{let a=o.length,d=a-16;if(a<16)throw new Error("encrypted data must be at least 16 bytes");s?(0,qu.ensureBytes)(s,d):s=new Uint8Array(d);let u=o.subarray(0,-16),c=o.subarray(-16),l=zoe(t,e,r,u,n);if(!(0,qu.equalBytes)(c,l))throw new Error("invalid tag");return t(e,r,u,s,1),s}});Gn._poly1305_aead=kMe;Gn.chacha20poly1305=(0,Gn._poly1305_aead)(Gn.chacha20);Gn.xchacha20poly1305=(0,Gn._poly1305_aead)(Gn.xchacha20)});var HE=V(as=>{"use strict";f();Object.defineProperty(as,"__esModule",{value:!0});as.output=as.exists=as.hash=as.bytes=as.bool=as.number=as.isBytes=void 0;function QA(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}as.number=QA;function Voe(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}as.bool=Voe;function Goe(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}as.isBytes=Goe;function ZC(t,...e){if(!Goe(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}`)}as.bytes=ZC;function Joe(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");QA(t.outputLen),QA(t.blockLen)}as.hash=Joe;function Zoe(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")}as.exists=Zoe;function Yoe(t,e){ZC(t);let r=e.outputLen;if(t.length{"use strict";f();Object.defineProperty(eT,"__esModule",{value:!0});eT.crypto=void 0;eT.crypto=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0});var VE=V(wt=>{"use strict";f();Object.defineProperty(wt,"__esModule",{value:!0});wt.randomBytes=wt.wrapXOFConstructorWithOpts=wt.wrapConstructorWithOpts=wt.wrapConstructor=wt.checkOpts=wt.Hash=wt.concatBytes=wt.toBytes=wt.utf8ToBytes=wt.asyncLoop=wt.nextTick=wt.hexToBytes=wt.bytesToHex=wt.byteSwap32=wt.byteSwapIfBE=wt.byteSwap=wt.isLE=wt.rotl=wt.rotr=wt.createView=wt.u32=wt.u8=wt.isBytes=void 0;var YC=Xoe(),QC=HE();function DMe(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}wt.isBytes=DMe;var BMe=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);wt.u8=BMe;var MMe=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));wt.u32=MMe;var OMe=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);wt.createView=OMe;var CMe=(t,e)=>t<<32-e|t>>>e;wt.rotr=CMe;var $Me=(t,e)=>t<>>32-e>>>0;wt.rotl=$Me;wt.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;var jMe=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255;wt.byteSwap=jMe;wt.byteSwapIfBE=wt.isLE?t=>t:t=>(0,wt.byteSwap)(t);function NMe(t){for(let e=0;ee.toString(16).padStart(2,"0"));function qMe(t){(0,QC.bytes)(t);let e="";for(let r=0;r=Ih._0&&t<=Ih._9)return t-Ih._0;if(t>=Ih._A&&t<=Ih._F)return t-(Ih._A-10);if(t>=Ih._a&&t<=Ih._f)return t-(Ih._a-10)}function LMe(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let i=0,o=0;i{};wt.nextTick=KMe;async function FMe(t,e,r){let n=Date.now();for(let i=0;i=0&&ot().update(tT(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}wt.wrapConstructor=VMe;function GMe(t){let e=(n,i)=>t(i).update(tT(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}wt.wrapConstructorWithOpts=GMe;function JMe(t){let e=(n,i)=>t(i).update(tT(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}wt.wrapXOFConstructorWithOpts=JMe;function ZMe(t=32){if(YC.crypto&&typeof YC.crypto.getRandomValues=="function")return YC.crypto.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}wt.randomBytes=ZMe});var rse=V(Og=>{"use strict";f();Object.defineProperty(Og,"__esModule",{value:!0});Og.hmac=Og.HMAC=void 0;var rT=HE(),tse=VE(),GE=class extends tse.Hash{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,(0,rT.hash)(e);let n=(0,tse.toBytes)(r);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let i=this.blockLen,o=new Uint8Array(i);o.set(n.length>i?e.create().update(n).digest():n);for(let s=0;snew GE(t,e).update(r).digest();Og.hmac=YMe;Og.hmac.create=(t,e)=>new GE(t,e)});var cse=V($m=>{"use strict";f();Object.defineProperty($m,"__esModule",{value:!0});$m.hkdf=$m.expand=$m.extract=void 0;var t$=HE(),nse=VE(),ose=rse();function sse(t,e,r){return(0,t$.hash)(t),r===void 0&&(r=new Uint8Array(t.outputLen)),(0,ose.hmac)(t,(0,nse.toBytes)(r),(0,nse.toBytes)(e))}$m.extract=sse;var e$=new Uint8Array([0]),ise=new Uint8Array;function ase(t,e,r,n=32){if((0,t$.hash)(t),(0,t$.number)(n),n>255*t.outputLen)throw new Error("Length should be <= 255*HashLen");let i=Math.ceil(n/t.outputLen);r===void 0&&(r=ise);let o=new Uint8Array(i*t.outputLen),s=ose.hmac.create(t,e),a=s._cloneInto(),d=new Uint8Array(s.outputLen);for(let u=0;uase(t,sse(t,e,r),n,i);$m.hkdf=XMe});var dse=V(jm=>{"use strict";f();Object.defineProperty(jm,"__esModule",{value:!0});jm.HashMD=jm.Maj=jm.Chi=void 0;var r$=HE(),JE=VE();function QMe(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),d=n?4:0,u=n?0:4;t.setUint32(e+d,s,n),t.setUint32(e+u,a,n)}var eOe=(t,e,r)=>t&e^~t&r;jm.Chi=eOe;var tOe=(t,e,r)=>t&e^t&r^e&r;jm.Maj=tOe;var n$=class extends JE.Hash{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=(0,JE.createView)(this.buffer)}update(e){(0,r$.exists)(this);let{view:r,buffer:n,blockLen:i}=this;e=(0,JE.toBytes)(e);let o=e.length;for(let s=0;si-s&&(this.process(n,0),s=0);for(let l=s;lc.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l{"use strict";f();Object.defineProperty(g1,"__esModule",{value:!0});g1.sha224=g1.sha256=void 0;var i$=dse(),$d=VE(),rOe=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]),Nm=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Um=new Uint32Array(64),nT=class extends i$.HashMD{constructor(){super(64,32,8,!1),this.A=Nm[0]|0,this.B=Nm[1]|0,this.C=Nm[2]|0,this.D=Nm[3]|0,this.E=Nm[4]|0,this.F=Nm[5]|0,this.G=Nm[6]|0,this.H=Nm[7]|0}get(){let{A:e,B:r,C:n,D:i,E:o,F:s,G:a,H:d}=this;return[e,r,n,i,o,s,a,d]}set(e,r,n,i,o,s,a,d){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=d|0}process(e,r){for(let l=0;l<16;l++,r+=4)Um[l]=e.getUint32(r,!1);for(let l=16;l<64;l++){let p=Um[l-15],m=Um[l-2],g=(0,$d.rotr)(p,7)^(0,$d.rotr)(p,18)^p>>>3,v=(0,$d.rotr)(m,17)^(0,$d.rotr)(m,19)^m>>>10;Um[l]=v+Um[l-7]+g+Um[l-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:d,G:u,H:c}=this;for(let l=0;l<64;l++){let p=(0,$d.rotr)(a,6)^(0,$d.rotr)(a,11)^(0,$d.rotr)(a,25),m=c+p+(0,i$.Chi)(a,d,u)+rOe[l]+Um[l]|0,v=((0,$d.rotr)(n,2)^(0,$d.rotr)(n,13)^(0,$d.rotr)(n,22))+(0,i$.Maj)(n,i,o)|0;c=u,u=d,d=a,a=s+m|0,s=o,o=i,i=n,n=m+v|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,d=d+this.F|0,u=u+this.G|0,c=c+this.H|0,this.set(n,i,o,s,a,d,u,c)}roundClean(){Um.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},o$=class extends nT{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}};g1.sha256=(0,$d.wrapConstructor)(()=>new nT);g1.sha224=(0,$d.wrapConstructor)(()=>new o$)});var hse=V(iT=>{"use strict";f();Object.defineProperty(iT,"__esModule",{value:!0});iT.aes256gcm=void 0;var lse=Cu(),fse=C4(),s$=CE();function nOe(t,e,r){var n=function(o){var s=(0,fse.createCipheriv)("aes-256-gcm",t,e);r&&s.setAAD(r);var a=s.update(o),d=s.final();return(0,lse.concatBytes)(a,d,s.getAuthTag())},i=function(o){var s=o.subarray(0,o.length-s$.AEAD_TAG_LENGTH),a=o.subarray(-s$.AEAD_TAG_LENGTH),d=(0,fse.createDecipheriv)("aes-256-gcm",t,e);r&&d.setAAD(r),d.setAuthTag(a);var u=d.update(s),c=d.final();return(0,lse.concatBytes)(u,c)};return{tagLength:s$.AEAD_TAG_LENGTH,encrypt:n,decrypt:i}}iT.aes256gcm=nOe});var a$=V(qm=>{"use strict";f();Object.defineProperty(qm,"__esModule",{value:!0});qm.deriveKey=qm.aesDecrypt=qm.aesEncrypt=void 0;var iOe=Hoe(),mse=Cu(),oOe=oC(),sOe=cse(),aOe=use(),pse=kg(),oT=CE(),cOe=hse();function dOe(t,e){return yse(!0,t,e)}qm.aesEncrypt=dOe;function uOe(t,e){return yse(!1,t,e)}qm.aesDecrypt=uOe;function lOe(t){return(0,sOe.hkdf)(aOe.sha256,t,void 0,void 0,32)}qm.deriveKey=lOe;function yse(t,e,r){var n=(0,pse.symmetricAlgorithm)(),i=t?fOe:hOe;if(n==="aes-256-gcm")return i(cOe.aes256gcm,e,r,(0,pse.symmetricNonceLength)());if(n==="xchacha20")return i(iOe.xchacha20poly1305,e,r,oT.XCHACHA20_NONCE_LENGTH);throw new Error("Not implemented")}function fOe(t,e,r,n){var i=(0,oOe.randomBytes)(n),o=t(e,i),s=o.encrypt(r),a=s.subarray(0,s.length-oT.AEAD_TAG_LENGTH),d=s.subarray(-oT.AEAD_TAG_LENGTH);return(0,mse.concatBytes)(i,d,a)}function hOe(t,e,r,n){var i=n+oT.AEAD_TAG_LENGTH,o=r.subarray(0,n),s=r.subarray(n,i),a=r.subarray(i),d=t(e,Uint8Array.from(o)),u=(0,mse.concatBytes)(a,s);return d.decrypt(u)}});var wse=V(ea=>{"use strict";f();Object.defineProperty(ea,"__esModule",{value:!0});ea.hexToPublicKey=ea.convertPublicKeyFormat=ea.getSharedPoint=ea.getSharedKey=ea.getPublicKey=ea.isValidPrivateKey=ea.getValidSecret=void 0;var pOe=Cu(),mOe=oC(),gse=poe(),yOe=Ooe(),c$=kg(),vse=CE(),gOe=WC(),vOe=a$();function bOe(){var t;do t=(0,mOe.randomBytes)(vse.SECRET_KEY_LENGTH);while(!bse(t));return t}ea.getValidSecret=bOe;function bse(t){return ZE(function(e){return e.utils.isValidPrivateKey(t)},function(){return!0},function(){return!0})}ea.isValidPrivateKey=bse;function wOe(t){return ZE(function(e){return e.getPublicKey(t)},function(e){return e.getPublicKey(t)},function(e){return e.getPublicKey(t)})}ea.getPublicKey=wOe;function _Oe(t,e){return(0,vOe.deriveKey)((0,pOe.concatBytes)(t,e))}ea.getSharedKey=_Oe;function xOe(t,e,r){return ZE(function(n){return n.getSharedSecret(t,e,r)},function(n){return n.getSharedSecret(t,e)},function(n){var i=n.utils.getExtendedPublicKey(t).scalar,o=n.ExtendedPoint.fromHex(e).multiply(i);return o.toRawBytes()})}ea.getSharedPoint=xOe;function EOe(t,e){return ZE(function(r){return r.getSharedSecret(BigInt(1),t,e)},function(){return t},function(){return t})}ea.convertPublicKeyFormat=EOe;function SOe(t){var e=(0,gOe.decodeHex)(t);return ZE(function(){if(e.length===vse.ETH_PUBLIC_KEY_SIZE){var r=new Uint8Array(1+e.length);return r.set([4]),r.set(e,1),r}return e},function(){return e},function(){return e})}ea.hexToPublicKey=SOe;function ZE(t,e,r){if((0,c$.ellipticCurve)()==="secp256k1")return t(yOe.secp256k1);if((0,c$.ellipticCurve)()==="x25519")return e(gse.x25519);if((0,c$.ellipticCurve)()==="ed25519")return r(gse.ed25519);throw new Error("Not implemented")}});var sT=V(kh=>{"use strict";f();var AOe=kh&&kh.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),d$=kh&&kh.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&AOe(e,t,r)};Object.defineProperty(kh,"__esModule",{value:!0});d$(wse(),kh);d$(WC(),kh);d$(a$(),kh)});var l$=V(cT=>{"use strict";f();Object.defineProperty(cT,"__esModule",{value:!0});cT.PublicKey=void 0;var u$=Cu(),TOe=kg(),aT=sT(),POe=function(){function t(e){this.data=(0,aT.convertPublicKeyFormat)(e,!0)}return t.fromHex=function(e){return new t((0,aT.hexToPublicKey)(e))},Object.defineProperty(t.prototype,"uncompressed",{get:function(){return O.Buffer.from((0,aT.convertPublicKeyFormat)(this.data,!1))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"compressed",{get:function(){return O.Buffer.from(this.data)},enumerable:!1,configurable:!0}),t.prototype.toHex=function(e){return e===void 0&&(e=!0),e?(0,u$.bytesToHex)(this.data):(0,u$.bytesToHex)(this.uncompressed)},t.prototype.decapsulate=function(e){var r,n;return(0,TOe.isHkdfKeyCompressed)()?(r=this.data,n=e.multiply(this,!0)):(r=this.uncompressed,n=e.multiply(this,!1)),(0,aT.getSharedKey)(r,n)},t.prototype.equals=function(e){return(0,u$.equalBytes)(this.data,e.data)},t}();cT.PublicKey=POe});var xse=V(dT=>{"use strict";f();Object.defineProperty(dT,"__esModule",{value:!0});dT.PrivateKey=void 0;var _se=Cu(),IOe=kg(),v1=sT(),kOe=l$(),ROe=function(){function t(e){var r=e===void 0?(0,v1.getValidSecret)():e;if(!(0,v1.isValidPrivateKey)(r))throw new Error("Invalid private key");this.data=r,this.publicKey=new kOe.PublicKey((0,v1.getPublicKey)(r))}return t.fromHex=function(e){return new t((0,v1.decodeHex)(e))},Object.defineProperty(t.prototype,"secret",{get:function(){return O.Buffer.from(this.data)},enumerable:!1,configurable:!0}),t.prototype.toHex=function(){return(0,_se.bytesToHex)(this.data)},t.prototype.encapsulate=function(e){var r,n;return(0,IOe.isHkdfKeyCompressed)()?(r=this.publicKey.compressed,n=this.multiply(e,!0)):(r=this.publicKey.uncompressed,n=this.multiply(e,!1)),(0,v1.getSharedKey)(r,n)},t.prototype.multiply=function(e,r){return r===void 0&&(r=!1),(0,v1.getSharedPoint)(this.data,e.compressed,r)},t.prototype.equals=function(e){return(0,_se.equalBytes)(this.data,e.data)},t}();dT.PrivateKey=ROe});var f$=V(b1=>{"use strict";f();Object.defineProperty(b1,"__esModule",{value:!0});b1.PublicKey=b1.PrivateKey=void 0;var DOe=xse();Object.defineProperty(b1,"PrivateKey",{enumerable:!0,get:function(){return DOe.PrivateKey}});var BOe=l$();Object.defineProperty(b1,"PublicKey",{enumerable:!0,get:function(){return BOe.PublicKey}})});var Ase=V(rc=>{"use strict";f();Object.defineProperty(rc,"__esModule",{value:!0});rc.utils=rc.PublicKey=rc.PrivateKey=rc.ECIES_CONFIG=rc.decrypt=rc.encrypt=void 0;var MOe=Cu(),Ese=kg(),w1=f$(),Cg=sT();function OOe(t,e){var r=new w1.PrivateKey,n=t instanceof Uint8Array?new w1.PublicKey(t):w1.PublicKey.fromHex(t),i=r.encapsulate(n),o=(0,Cg.aesEncrypt)(i,e),s;return(0,Ese.isEphemeralKeyCompressed)()?s=r.publicKey.compressed:s=r.publicKey.uncompressed,O.Buffer.from((0,MOe.concatBytes)(s,o))}rc.encrypt=OOe;function COe(t,e){var r=t instanceof Uint8Array?new w1.PrivateKey(t):w1.PrivateKey.fromHex(t),n=(0,Ese.ephemeralKeySize)(),i=new w1.PublicKey(e.subarray(0,n)),o=e.subarray(n),s=i.decapsulate(r);return O.Buffer.from((0,Cg.aesDecrypt)(s,o))}rc.decrypt=COe;var $Oe=kg();Object.defineProperty(rc,"ECIES_CONFIG",{enumerable:!0,get:function(){return $Oe.ECIES_CONFIG}});var Sse=f$();Object.defineProperty(rc,"PrivateKey",{enumerable:!0,get:function(){return Sse.PrivateKey}});Object.defineProperty(rc,"PublicKey",{enumerable:!0,get:function(){return Sse.PublicKey}});rc.utils={aesDecrypt:Cg.aesDecrypt,aesEncrypt:Cg.aesEncrypt,decodeHex:Cg.decodeHex,getValidSecret:Cg.getValidSecret,remove0x:Cg.remove0x}});var ri=V((K2t,Tse)=>{"use strict";f();Tse.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 Rh=V((z2t,uT)=>{"use strict";f();var{AbortController:Pse,AbortSignal:jOe}=typeof self<"u"?self:typeof window<"u"?window:void 0;uT.exports=Pse;uT.exports.AbortSignal=jOe;uT.exports.default=Pse});var ta=V((H2t,p$)=>{"use strict";f();var NOe=hn(),{kResistStopPropagation:UOe,SymbolDispose:qOe}=ri(),LOe=globalThis.AbortSignal||Rh().AbortSignal,KOe=globalThis.AbortController||Rh().AbortController,FOe=Object.getPrototypeOf(async function(){}).constructor,Ise=globalThis.Blob||NOe.Blob,zOe=typeof Ise<"u"?function(e){return e instanceof Ise}:function(e){return!1},kse=(t,e)=>{if(t!==void 0&&(t===null||typeof t!="object"||!("aborted"in t)))throw new ERR_INVALID_ARG_TYPE(e,"AbortSignal",t)},WOe=(t,e)=>{if(typeof t!="function")throw new ERR_INVALID_ARG_TYPE(e,"Function",t)},h$=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{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 FOe},isArrayBufferView(t){return ArrayBuffer.isView(t)}},isBlob:zOe,deprecate(t,e){return t},addAbortListener:Sa().addAbortListener||function(e,r){if(e===void 0)throw new ERR_INVALID_ARG_TYPE("signal","AbortSignal",e);kse(e,"signal"),WOe(r,"listener");let n;return e.aborted?queueMicrotask(()=>r()):(e.addEventListener("abort",r,{__proto__:null,once:!0,[UOe]:!0}),n=()=>{e.removeEventListener("abort",r)}),{__proto__:null,[qOe](){var i;(i=n)===null||i===void 0||i()}}},AbortSignalAny:LOe.any||function(e){if(e.length===1)return e[0];let r=new KOe,n=()=>r.abort();return e.forEach(i=>{kse(i,"signals"),i.addEventListener("abort",n,{once:!0})}),r.signal.addEventListener("abort",()=>{e.forEach(i=>i.removeEventListener("abort",n))},{once:!0}),r.signal}};p$.exports.promisify.custom=Symbol.for("nodejs.util.promisify.custom")});var Ia=V((G2t,Bse)=>{"use strict";f();var{format:HOe,inspect:lT,AggregateError:VOe}=ta(),GOe=globalThis.AggregateError||VOe,JOe=Symbol("kIsNodeError"),ZOe=["string","function","number","object","Function","Object","boolean","bigint","symbol"],YOe=/^([A-Z][a-z0-9]*)+$/,XOe="__node_internal_",fT={};function $g(t,e){if(!t)throw new fT.ERR_INTERNAL_ASSERTION(e)}function Rse(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 QOe(t,e,r){if(typeof e=="function")return $g(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 $g(n===r.length,`Code: ${t}; The provided arguments length (${r.length}) does not match the required ones (${n}).`),r.length===0?e:HOe(e,...r)}function cs(t,e,r){r||(r=Error);class n extends r{constructor(...o){super(QOe(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[JOe]=!0,fT[t]=n}function Dse(t){let e=XOe+t.name;return Object.defineProperty(t,"name",{value:e}),t}function eCe(t,e){if(t&&e&&t!==e){if(Array.isArray(e.errors))return e.errors.push(t),e;let r=new GOe([e,t],e.message);return r.code=e.code,r}return t||e}var m$=class extends Error{constructor(e="The operation was aborted",r=void 0){if(r!==void 0&&typeof r!="object")throw new fT.ERR_INVALID_ARG_TYPE("options","Object",r);super(e,r),this.code="ABORT_ERR",this.name="AbortError"}};cs("ERR_ASSERTION","%s",Error);cs("ERR_INVALID_ARG_TYPE",(t,e,r)=>{$g(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 d of e)$g(typeof d=="string","All expected entries have to be of type string"),ZOe.includes(d)?i.push(d.toLowerCase()):YOe.test(d)?o.push(d):($g(d!=="object",'The value "object" should be written as "Object"'),s.push(d));if(o.length>0){let d=i.indexOf("object");d!==-1&&(i.splice(i,d,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 d=i.pop();n+=`one of type ${i.join(", ")}, or ${d}`}}(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 d=o.pop();n+=`an instance of ${o.join(", ")}, or ${d}`}}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 d=s.pop();n+=`one of ${s.join(", ")}, or ${d}`}}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 d=lT(r,{depth:-1});n+=`. Received ${d}`}}else{let d=lT(r,{colors:!1});d.length>25&&(d=`${d.slice(0,25)}...`),n+=`. Received type ${typeof r} (${d})`}return n},TypeError);cs("ERR_INVALID_ARG_VALUE",(t,e,r="is invalid")=>{let n=lT(e);return n.length>128&&(n=n.slice(0,128)+"..."),`The ${t.includes(".")?"property":"argument"} '${t}' ${r}. Received ${n}`},TypeError);cs("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);cs("ERR_MISSING_ARGS",(...t)=>{$g(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);cs("ERR_OUT_OF_RANGE",(t,e,r)=>{$g(e,'Missing "range" argument');let n;return Number.isInteger(r)&&Math.abs(r)>2**32?n=Rse(String(r)):typeof r=="bigint"?(n=String(r),(r>2n**32n||r<-(2n**32n))&&(n=Rse(n)),n+="n"):n=lT(r),`The value of "${t}" is out of range. It must be ${e}. Received ${n}`},RangeError);cs("ERR_MULTIPLE_CALLBACK","Callback called multiple times",Error);cs("ERR_METHOD_NOT_IMPLEMENTED","The %s method is not implemented",Error);cs("ERR_STREAM_ALREADY_FINISHED","Cannot call %s after a stream was finished",Error);cs("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable",Error);cs("ERR_STREAM_DESTROYED","Cannot call %s after a stream was destroyed",Error);cs("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);cs("ERR_STREAM_PREMATURE_CLOSE","Premature close",Error);cs("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF",Error);cs("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event",Error);cs("ERR_STREAM_WRITE_AFTER_END","write after end",Error);cs("ERR_UNKNOWN_ENCODING","Unknown encoding: %s",TypeError);Bse.exports={AbortError:m$,aggregateTwoErrors:Dse(eCe),hideStackFrames:Dse,codes:fT}});var x1=V((Z2t,Kse)=>{"use strict";f();var{ArrayIsArray:g$,ArrayPrototypeIncludes:$se,ArrayPrototypeJoin:jse,ArrayPrototypeMap:tCe,NumberIsInteger:v$,NumberIsNaN:rCe,NumberMAX_SAFE_INTEGER:nCe,NumberMIN_SAFE_INTEGER:iCe,NumberParseInt:oCe,ObjectPrototypeHasOwnProperty:sCe,RegExpPrototypeExec:Nse,String:aCe,StringPrototypeToUpperCase:cCe,StringPrototypeTrim:dCe}=ri(),{hideStackFrames:jd,codes:{ERR_SOCKET_BAD_PORT:uCe,ERR_INVALID_ARG_TYPE:ra,ERR_INVALID_ARG_VALUE:_1,ERR_OUT_OF_RANGE:jg,ERR_UNKNOWN_SIGNAL:Mse}}=Ia(),{normalizeEncoding:lCe}=ta(),{isAsyncFunction:fCe,isArrayBufferView:hCe}=ta().types,Ose={};function pCe(t){return t===(t|0)}function mCe(t){return t===t>>>0}var yCe=/^[0-7]+$/,gCe="must be a 32-bit unsigned integer or an octal string";function vCe(t,e,r){if(typeof t>"u"&&(t=r),typeof t=="string"){if(Nse(yCe,t)===null)throw new _1(e,t,gCe);t=oCe(t,8)}return Use(t,e),t}var bCe=jd((t,e,r=iCe,n=nCe)=>{if(typeof t!="number")throw new ra(e,"number",t);if(!v$(t))throw new jg(e,"an integer",t);if(tn)throw new jg(e,`>= ${r} && <= ${n}`,t)}),wCe=jd((t,e,r=-2147483648,n=2147483647)=>{if(typeof t!="number")throw new ra(e,"number",t);if(!v$(t))throw new jg(e,"an integer",t);if(tn)throw new jg(e,`>= ${r} && <= ${n}`,t)}),Use=jd((t,e,r=!1)=>{if(typeof t!="number")throw new ra(e,"number",t);if(!v$(t))throw new jg(e,"an integer",t);let n=r?1:0,i=4294967295;if(ti)throw new jg(e,`>= ${n} && <= ${i}`,t)});function b$(t,e){if(typeof t!="string")throw new ra(e,"string",t)}function _Ce(t,e,r=void 0,n){if(typeof t!="number")throw new ra(e,"number",t);if(r!=null&&tn||(r!=null||n!=null)&&rCe(t))throw new jg(e,`${r!=null?`>= ${r}`:""}${r!=null&&n!=null?" && ":""}${n!=null?`<= ${n}`:""}`,t)}var xCe=jd((t,e,r)=>{if(!$se(r,t)){let i="must be one of: "+jse(tCe(r,o=>typeof o=="string"?`'${o}'`:aCe(o)),", ");throw new _1(e,t,i)}});function qse(t,e){if(typeof t!="boolean")throw new ra(e,"boolean",t)}function y$(t,e,r){return t==null||!sCe(t,e)?r:t[e]}var ECe=jd((t,e,r=null)=>{let n=y$(r,"allowArray",!1),i=y$(r,"allowFunction",!1);if(!y$(r,"nullable",!1)&&t===null||!n&&g$(t)||typeof t!="object"&&(!i||typeof t!="function"))throw new ra(e,"Object",t)}),SCe=jd((t,e)=>{if(t!=null&&typeof t!="object"&&typeof t!="function")throw new ra(e,"a dictionary",t)}),hT=jd((t,e,r=0)=>{if(!g$(t))throw new ra(e,"Array",t);if(t.length{if(!hCe(t))throw new ra(e,["Buffer","TypedArray","DataView"],t)});function RCe(t,e){let r=lCe(e),n=t.length;if(r==="hex"&&n%2!==0)throw new _1("encoding",e,`is invalid for data of length ${n}`)}function DCe(t,e="Port",r=!0){if(typeof t!="number"&&typeof t!="string"||typeof t=="string"&&dCe(t).length===0||+t!==+t>>>0||t>65535||t===0&&!r)throw new uCe(e,t,r);return t|0}var Lse=jd((t,e)=>{if(t!==void 0&&(t===null||typeof t!="object"||!("aborted"in t)))throw new ra(e,"AbortSignal",t)}),BCe=jd((t,e)=>{if(typeof t!="function")throw new ra(e,"Function",t)}),MCe=jd((t,e)=>{if(typeof t!="function"||fCe(t))throw new ra(e,"Function",t)}),OCe=jd((t,e)=>{if(t!==void 0)throw new ra(e,"undefined",t)});function CCe(t,e,r){if(!$se(r,t))throw new ra(e,`('${jse(r,"|")}')`,t)}var $Ce=/^(?:<[^>]*>)(?:\s*;\s*[^;"\s]+(?:=(")?[^;"\s]*\1)?)*$/;function Cse(t,e){if(typeof t>"u"||!Nse($Ce,t))throw new _1(e,t,'must be an array or string of format "; rel=preload; as=style"')}function jCe(t){if(typeof t=="string")return Cse(t,"hints"),t;if(g$(t)){let e=t.length,r="";if(e===0)return r;for(let n=0;n; rel=preload; as=style"')}Kse.exports={isInt32:pCe,isUint32:mCe,parseFileMode:vCe,validateArray:hT,validateStringArray:ACe,validateBooleanArray:TCe,validateAbortSignalArray:PCe,validateBoolean:qse,validateBuffer:kCe,validateDictionary:SCe,validateEncoding:RCe,validateFunction:BCe,validateInt32:wCe,validateInteger:bCe,validateNumber:_Ce,validateObject:ECe,validateOneOf:xCe,validatePlainFunction:MCe,validatePort:DCe,validateSignalName:ICe,validateString:b$,validateUint32:Use,validateUndefined:OCe,validateUnion:CCe,validateAbortSignal:Lse,validateLinkHeaderValue:jCe}});var Zl=V((X2t,nae)=>{"use strict";f();var{SymbolAsyncIterator:Fse,SymbolIterator:zse,SymbolFor:Ng}=ri(),Wse=Ng("nodejs.stream.destroyed"),Hse=Ng("nodejs.stream.errored"),w$=Ng("nodejs.stream.readable"),_$=Ng("nodejs.stream.writable"),Vse=Ng("nodejs.stream.disturbed"),NCe=Ng("nodejs.webstream.isClosedPromise"),UCe=Ng("nodejs.webstream.controllerErrorFunction");function pT(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 mT(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 qCe(t){return!!(t&&typeof t.pipe=="function"&&t._readableState&&typeof t.on=="function"&&typeof t.write=="function")}function Jl(t){return t&&(t._readableState||t._writableState||typeof t.write=="function"&&typeof t.on=="function"||typeof t.pipe=="function"&&typeof t.on=="function")}function Gse(t){return!!(t&&!Jl(t)&&typeof t.pipeThrough=="function"&&typeof t.getReader=="function"&&typeof t.cancel=="function")}function Jse(t){return!!(t&&!Jl(t)&&typeof t.getWriter=="function"&&typeof t.abort=="function")}function Zse(t){return!!(t&&!Jl(t)&&typeof t.readable=="object"&&typeof t.writable=="object")}function LCe(t){return Gse(t)||Jse(t)||Zse(t)}function KCe(t,e){return t==null?!1:e===!0?typeof t[Fse]=="function":e===!1?typeof t[zse]=="function":typeof t[Fse]=="function"||typeof t[zse]=="function"}function yT(t){if(!Jl(t))return null;let e=t._writableState,r=t._readableState,n=e||r;return!!(t.destroyed||t[Wse]||n!=null&&n.destroyed)}function Yse(t){if(!mT(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 FCe(t,e){if(!mT(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 zCe(t){if(!pT(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 Xse(t,e){if(!pT(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 Qse(t){return t&&t[w$]!=null?t[w$]:typeof t?.readable!="boolean"?null:yT(t)?!1:pT(t)&&t.readable&&!Xse(t)}function eae(t){return t&&t[_$]!=null?t[_$]:typeof t?.writable!="boolean"?null:yT(t)?!1:mT(t)&&t.writable&&!Yse(t)}function WCe(t,e){return Jl(t)?yT(t)?!0:!(e?.readable!==!1&&Qse(t)||e?.writable!==!1&&eae(t)):null}function HCe(t){var e,r;return Jl(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 VCe(t){var e,r;return Jl(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 GCe(t){if(!Jl(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"&&tae(t)?t._closed:null}function tae(t){return typeof t._closed=="boolean"&&typeof t._defaultKeepAlive=="boolean"&&typeof t._removedConnection=="boolean"&&typeof t._removedContLen=="boolean"}function rae(t){return typeof t._sent100=="boolean"&&tae(t)}function JCe(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 ZCe(t){if(!Jl(t))return null;let e=t._writableState,r=t._readableState,n=e||r;return!n&&rae(t)||!!(n&&n.autoDestroy&&n.emitClose&&n.closed===!1)}function YCe(t){var e;return!!(t&&((e=t[Vse])!==null&&e!==void 0?e:t.readableDidRead||t.readableAborted))}function XCe(t){var e,r,n,i,o,s,a,d,u,c;return!!(t&&((e=(r=(n=(i=(o=(s=t[Hse])!==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:(d=t._writableState)===null||d===void 0?void 0:d.errorEmitted)!==null&&r!==void 0?r:(u=t._readableState)===null||u===void 0?void 0:u.errored)!==null&&e!==void 0?e:!((c=t._writableState)===null||c===void 0)&&c.errored))}nae.exports={isDestroyed:yT,kIsDestroyed:Wse,isDisturbed:YCe,kIsDisturbed:Vse,isErrored:XCe,kIsErrored:Hse,isReadable:Qse,kIsReadable:w$,kIsClosedPromise:NCe,kControllerErrorFunction:UCe,kIsWritable:_$,isClosed:GCe,isDuplexNodeStream:qCe,isFinished:WCe,isIterable:KCe,isReadableNodeStream:pT,isReadableStream:Gse,isReadableEnded:zCe,isReadableFinished:Xse,isReadableErrored:VCe,isNodeStream:Jl,isWebStream:LCe,isWritable:eae,isWritableNodeStream:mT,isWritableStream:Jse,isWritableEnded:Yse,isWritableFinished:FCe,isWritableErrored:HCe,isServerRequest:JCe,isServerResponse:rae,willEmitClose:ZCe,isTransformStream:Zse}});var Dh=V((e_t,T$)=>{f();var Lm=$s(),{AbortError:fae,codes:QCe}=Ia(),{ERR_INVALID_ARG_TYPE:e$e,ERR_STREAM_PREMATURE_CLOSE:iae}=QCe,{kEmptyObject:E$,once:S$}=ta(),{validateAbortSignal:t$e,validateFunction:r$e,validateObject:n$e,validateBoolean:i$e}=x1(),{Promise:o$e,PromisePrototypeThen:s$e,SymbolDispose:hae}=ri(),{isClosed:a$e,isReadable:oae,isReadableNodeStream:x$,isReadableStream:c$e,isReadableFinished:sae,isReadableErrored:aae,isWritable:cae,isWritableNodeStream:dae,isWritableStream:d$e,isWritableFinished:uae,isWritableErrored:lae,isNodeStream:u$e,willEmitClose:l$e,kIsClosedPromise:f$e}=Zl(),E1;function h$e(t){return t.setHeader&&typeof t.abort=="function"}var A$=()=>{};function pae(t,e,r){var n,i;if(arguments.length===2?(r=e,e=E$):e==null?e=E$:n$e(e,"options"),r$e(r,"callback"),t$e(e.signal,"options.signal"),r=S$(r),c$e(t)||d$e(t))return p$e(t,e,r);if(!u$e(t))throw new e$e("stream",["ReadableStream","WritableStream","Stream"],t);let o=(n=e.readable)!==null&&n!==void 0?n:x$(t),s=(i=e.writable)!==null&&i!==void 0?i:dae(t),a=t._writableState,d=t._readableState,u=()=>{t.writable||p()},c=l$e(t)&&x$(t)===o&&dae(t)===s,l=uae(t,!1),p=()=>{l=!0,t.destroyed&&(c=!1),!(c&&(!t.readable||o))&&(!o||m)&&r.call(t)},m=sae(t,!1),g=()=>{m=!0,t.destroyed&&(c=!1),!(c&&(!t.writable||s))&&(!s||l)&&r.call(t)},v=j=>{r.call(t,j)},x=a$e(t),S=()=>{x=!0;let j=lae(t)||aae(t);if(j&&typeof j!="boolean")return r.call(t,j);if(o&&!m&&x$(t,!0)&&!sae(t,!1))return r.call(t,new iae);if(s&&!l&&!uae(t,!1))return r.call(t,new iae);r.call(t)},P=()=>{x=!0;let j=lae(t)||aae(t);if(j&&typeof j!="boolean")return r.call(t,j);r.call(t)},A=()=>{t.req.on("finish",p)};h$e(t)?(t.on("complete",p),c||t.on("abort",S),t.req?A():t.on("request",A)):s&&!a&&(t.on("end",u),t.on("close",u)),!c&&typeof t.aborted=="boolean"&&t.on("aborted",S),t.on("end",g),t.on("finish",p),e.error!==!1&&t.on("error",v),t.on("close",S),x?Lm.nextTick(S):a!=null&&a.errorEmitted||d!=null&&d.errorEmitted?c||Lm.nextTick(P):(!o&&(!c||oae(t))&&(l||cae(t)===!1)||!s&&(!c||cae(t))&&(m||oae(t)===!1)||d&&t.req&&t.aborted)&&Lm.nextTick(P);let $=()=>{r=A$,t.removeListener("aborted",S),t.removeListener("complete",p),t.removeListener("abort",S),t.removeListener("request",A),t.req&&t.req.removeListener("finish",p),t.removeListener("end",u),t.removeListener("close",u),t.removeListener("finish",p),t.removeListener("end",g),t.removeListener("error",v),t.removeListener("close",S)};if(e.signal&&!x){let j=()=>{let L=r;$(),L.call(t,new fae(void 0,{cause:e.signal.reason}))};if(e.signal.aborted)Lm.nextTick(j);else{E1=E1||ta().addAbortListener;let L=E1(e.signal,j),F=r;r=S$((...K)=>{L[hae](),F.apply(t,K)})}}return $}function p$e(t,e,r){let n=!1,i=A$;if(e.signal)if(i=()=>{n=!0,r.call(t,new fae(void 0,{cause:e.signal.reason}))},e.signal.aborted)Lm.nextTick(i);else{E1=E1||ta().addAbortListener;let s=E1(e.signal,i),a=r;r=S$((...d)=>{s[hae](),a.apply(t,d)})}let o=(...s)=>{n||Lm.nextTick(()=>r.apply(t,s))};return s$e(t[f$e].promise,o,o),A$}function m$e(t,e){var r;let n=!1;return e===null&&(e=E$),(r=e)!==null&&r!==void 0&&r.cleanup&&(i$e(e.cleanup,"cleanup"),n=e.cleanup),new o$e((i,o)=>{let s=pae(t,e,a=>{n&&s(),a?o(a):i()})})}T$.exports=pae;T$.exports.finished=m$e});var Ug=V((r_t,xae)=>{"use strict";f();var Yl=$s(),{aggregateTwoErrors:y$e,codes:{ERR_MULTIPLE_CALLBACK:g$e},AbortError:v$e}=Ia(),{Symbol:gae}=ri(),{kIsDestroyed:b$e,isDestroyed:w$e,isFinished:_$e,isServerRequest:x$e}=Zl(),vae=gae("kDestroy"),P$=gae("kConstruct");function bae(t,e,r){t&&(t.stack,e&&!e.errored&&(e.errored=t),r&&!r.errored&&(r.errored=t))}function E$e(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):(bae(t,n,r),n&&(n.destroyed=!0),r&&(r.destroyed=!0),i.constructed?mae(this,t,e):this.once(vae,function(o){mae(this,y$e(o,t),e)}),this)}function mae(t,e,r){let n=!1;function i(o){if(n)return;n=!0;let s=t._readableState,a=t._writableState;bae(o,a,s),a&&(a.closed=!0),s&&(s.closed=!0),typeof r=="function"&&r(o),o?Yl.nextTick(S$e,t,o):Yl.nextTick(wae,t)}try{t._destroy(e||null,i)}catch(o){i(o)}}function S$e(t,e){I$(t,e),wae(t)}function wae(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 I$(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 A$e(){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 k$(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?Yl.nextTick(I$,t,e):I$(t,e))}function T$e(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(P$,e),!(t.listenerCount(P$)>1)&&Yl.nextTick(P$e,t)}function P$e(t){let e=!1;function r(n){if(e){k$(t,n??new g$e);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(vae,n):n?k$(t,n,!0):Yl.nextTick(I$e,t)}try{t._construct(n=>{Yl.nextTick(r,n)})}catch(n){Yl.nextTick(r,n)}}function I$e(t){t.emit(P$)}function yae(t){return t?.setHeader&&typeof t.abort=="function"}function _ae(t){t.emit("close")}function k$e(t,e){t.emit("error",e),Yl.nextTick(_ae,t)}function R$e(t,e){!t||w$e(t)||(!e&&!_$e(t)&&(e=new v$e),x$e(t)?(t.socket=null,t.destroy(e)):yae(t)?t.abort():yae(t.req)?t.req.abort():typeof t.destroy=="function"?t.destroy(e):typeof t.close=="function"?t.close():e?Yl.nextTick(k$e,t,e):Yl.nextTick(_ae,t),t.destroyed||(t[b$e]=!0))}xae.exports={construct:T$e,destroyer:R$e,destroy:E$e,undestroy:A$e,errorOrDestroy:k$}});var bT=V((i_t,Sae)=>{"use strict";f();var{ArrayIsArray:D$e,ObjectSetPrototypeOf:Eae}=ri(),{EventEmitter:gT}=Sa();function vT(t){gT.call(this,t)}Eae(vT.prototype,gT.prototype);Eae(vT,gT);vT.prototype.pipe=function(t,e){let r=this;function n(c){t.writable&&t.write(c)===!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 d(c){u(),gT.listenerCount(this,"error")===0&&this.emit("error",c)}R$(r,"error",d),R$(t,"error",d);function u(){r.removeListener("data",n),t.removeListener("drain",i),r.removeListener("end",s),r.removeListener("close",a),r.removeListener("error",d),t.removeListener("error",d),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 R$(t,e,r){if(typeof t.prependListener=="function")return t.prependListener(e,r);!t._events||!t._events[e]?t.on(e,r):D$e(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]}Sae.exports={Stream:vT,prependListener:R$}});var YE=V((s_t,wT)=>{"use strict";f();var{SymbolDispose:B$e}=ri(),{AbortError:Aae,codes:M$e}=Ia(),{isNodeStream:Tae,isWebStream:O$e,kControllerErrorFunction:C$e}=Zl(),$$e=Dh(),{ERR_INVALID_ARG_TYPE:Pae}=M$e,D$,j$e=(t,e)=>{if(typeof t!="object"||!("aborted"in t))throw new Pae(e,"AbortSignal",t)};wT.exports.addAbortSignal=function(e,r){if(j$e(e,"signal"),!Tae(r)&&!O$e(r))throw new Pae("stream",["ReadableStream","WritableStream","Stream"],r);return wT.exports.addAbortSignalNoValidate(e,r)};wT.exports.addAbortSignalNoValidate=function(t,e){if(typeof t!="object"||!("aborted"in t))return e;let r=Tae(e)?()=>{e.destroy(new Aae(void 0,{cause:t.reason}))}:()=>{e[C$e](new Aae(void 0,{cause:t.reason}))};if(t.aborted)r();else{D$=D$||ta().addAbortListener;let n=D$(t,r);$$e(e,n[B$e])}return e}});var Rae=V((d_t,kae)=>{"use strict";f();var{StringPrototypeSlice:Iae,SymbolIterator:N$e,TypedArrayPrototypeSet:_T,Uint8Array:U$e}=ri(),{Buffer:B$}=hn(),{inspect:q$e}=ta();kae.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 B$.alloc(0);let r=B$.allocUnsafe(e>>>0),n=this.head,i=0;for(;n;)_T(r,n.data,i),i+=n.data.length,n=n.next;return r}consume(e,r){let n=this.head.data;if(eo.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+=Iae(o,0,e),this.head=n,n.data=Iae(o,e));break}++i}while((n=n.next)!==null);return this.length-=i,r}_getBuffer(e){let r=B$.allocUnsafe(e),n=e,i=this.head,o=0;do{let s=i.data;if(e>s.length)_T(r,s,n-e),e-=s.length;else{e===s.length?(_T(r,s,n-e),++o,i.next?this.head=i.next:this.head=this.tail=null):(_T(r,new U$e(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 q$e(this,{...r,depth:0,customInspect:!1})}}});var XE=V((l_t,Oae)=>{"use strict";f();var{MathFloor:L$e,NumberIsInteger:K$e}=ri(),{validateInteger:F$e}=x1(),{ERR_INVALID_ARG_VALUE:z$e}=Ia().codes,Dae=16*1024,Bae=16;function W$e(t,e,r){return t.highWaterMark!=null?t.highWaterMark:e?t[r]:null}function Mae(t){return t?Bae:Dae}function H$e(t,e){F$e(e,"value",0),t?Bae=e:Dae=e}function V$e(t,e,r,n){let i=W$e(e,n,r);if(i!=null){if(!K$e(i)||i<0){let o=n?`options.${r}`:"options.highWaterMark";throw new z$e(o,i)}return L$e(i)}return Mae(t.objectMode)}Oae.exports={getHighWaterMark:V$e,getDefaultHighWaterMark:Mae,setDefaultHighWaterMark:H$e}});var M$=V((h_t,Nae)=>{"use strict";f();var Cae=$s(),{PromisePrototypeThen:G$e,SymbolAsyncIterator:$ae,SymbolIterator:jae}=ri(),{Buffer:J$e}=hn(),{ERR_INVALID_ARG_TYPE:Z$e,ERR_STREAM_NULL_VALUES:Y$e}=Ia().codes;function X$e(t,e,r){let n;if(typeof e=="string"||e instanceof J$e)return new t({objectMode:!0,...r,read(){this.push(e),this.push(null)}});let i;if(e&&e[$ae])i=!0,n=e[$ae]();else if(e&&e[jae])i=!1,n=e[jae]();else throw new Z$e("iterable",["Iterable"],e);let o=new t({objectMode:!0,highWaterMark:1,...r}),s=!1;o._read=function(){s||(s=!0,d())},o._destroy=function(u,c){G$e(a(u),()=>Cae.nextTick(c,u),l=>Cae.nextTick(c,l||u))};async function a(u){let c=u!=null,l=typeof n.throw=="function";if(c&&l){let{value:p,done:m}=await n.throw(u);if(await p,m)return}if(typeof n.return=="function"){let{value:p}=await n.return();await p}}async function d(){for(;;){try{let{value:u,done:c}=i?await n.next():n.next();if(c)o.push(null);else{let l=u&&typeof u.then=="function"?await u:u;if(l===null)throw s=!1,new Y$e;if(o.push(l))continue;s=!1}}catch(u){o.destroy(u)}break}}return o}Nae.exports=X$e});var e6=V((m_t,rce)=>{f();var Lu=$s(),{ArrayPrototypeIndexOf:Q$e,NumberIsInteger:eje,NumberIsNaN:tje,NumberParseInt:rje,ObjectDefineProperties:L$,ObjectKeys:nje,ObjectSetPrototypeOf:Lae,Promise:Kae,SafeSet:ije,SymbolAsyncDispose:oje,SymbolAsyncIterator:sje,Symbol:aje}=ri();rce.exports=hr;hr.ReadableState=AT;var{EventEmitter:cje}=Sa(),{Stream:Km,prependListener:dje}=bT(),{Buffer:O$}=hn(),{addAbortSignal:uje}=YE(),Fae=Dh(),Mr=ta().debuglog("stream",t=>{Mr=t}),lje=Rae(),T1=Ug(),{getHighWaterMark:fje,getDefaultHighWaterMark:hje}=XE(),{aggregateTwoErrors:Uae,codes:{ERR_INVALID_ARG_TYPE:pje,ERR_METHOD_NOT_IMPLEMENTED:mje,ERR_OUT_OF_RANGE:yje,ERR_STREAM_PUSH_AFTER_EOF:gje,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:vje},AbortError:bje}=Ia(),{validateObject:wje}=x1(),qg=aje("kPaused"),{StringDecoder:zae}=Rw(),_je=M$();Lae(hr.prototype,Km.prototype);Lae(hr,Km);var C$=()=>{},{errorOrDestroy:S1}=T1,A1=1,xje=2,Wae=4,QE=8,Hae=16,xT=32,ET=64,Vae=128,Eje=256,Sje=512,Aje=1024,U$=2048,q$=4096,Tje=8192,Pje=16384,Ije=32768,Gae=65536,kje=1<<17,Rje=1<<18;function oo(t){return{enumerable:!1,get(){return(this.state&t)!==0},set(e){e?this.state|=t:this.state&=~t}}}L$(AT.prototype,{objectMode:oo(A1),ended:oo(xje),endEmitted:oo(Wae),reading:oo(QE),constructed:oo(Hae),sync:oo(xT),needReadable:oo(ET),emittedReadable:oo(Vae),readableListening:oo(Eje),resumeScheduled:oo(Sje),errorEmitted:oo(Aje),emitClose:oo(U$),autoDestroy:oo(q$),destroyed:oo(Tje),closed:oo(Pje),closeEmitted:oo(Ije),multiAwaitDrain:oo(Gae),readingMore:oo(kje),dataEmitted:oo(Rje)});function AT(t,e,r){typeof r!="boolean"&&(r=e instanceof Xl()),this.state=U$|q$|Hae|xT,t&&t.objectMode&&(this.state|=A1),r&&t&&t.readableObjectMode&&(this.state|=A1),this.highWaterMark=t?fje(this,t,"readableHighWaterMark",r):hje(!1),this.buffer=new lje,this.length=0,this.pipes=[],this.flowing=null,this[qg]=null,t&&t.emitClose===!1&&(this.state&=~U$),t&&t.autoDestroy===!1&&(this.state&=~q$),this.errored=null,this.defaultEncoding=t&&t.defaultEncoding||"utf8",this.awaitDrainWriters=null,this.decoder=null,this.encoding=null,t&&t.encoding&&(this.decoder=new zae(t.encoding),this.encoding=t.encoding)}function hr(t){if(!(this instanceof hr))return new hr(t);let e=this instanceof Xl();this._readableState=new AT(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&&uje(t.signal,this)),Km.call(this,t),T1.construct(this,()=>{this._readableState.needReadable&&ST(this,this._readableState)})}hr.prototype.destroy=T1.destroy;hr.prototype._undestroy=T1.undestroy;hr.prototype._destroy=function(t,e){e(t)};hr.prototype[cje.captureRejectionSymbol]=function(t){this.destroy(t)};hr.prototype[oje]=function(){let t;return this.destroyed||(t=this.readableEnded?null:new bje,this.destroy(t)),new Kae((e,r)=>Fae(this,n=>n&&n!==t?r(n):e(null)))};hr.prototype.push=function(t,e){return Jae(this,t,e,!1)};hr.prototype.unshift=function(t,e){return Jae(this,t,e,!0)};function Jae(t,e,r,n){Mr("readableAddChunk",e);let i=t._readableState,o;if(i.state&A1||(typeof e=="string"?(r=r||i.defaultEncoding,i.encoding!==r&&(n&&i.encoding?e=O$.from(e,r).toString(i.encoding):(e=O$.from(e,r),r=""))):e instanceof O$?r="":Km._isUint8Array(e)?(e=Km._uint8ArrayToBuffer(e),r=""):e!=null&&(o=new pje("chunk",["string","Buffer","Uint8Array"],e))),o)S1(t,o);else if(e===null)i.state&=~QE,Mje(t,i);else if(i.state&A1||e&&e.length>0)if(n)if(i.state&Wae)S1(t,new vje);else{if(i.destroyed||i.errored)return!1;$$(t,i,e,!0)}else if(i.ended)S1(t,new gje);else{if(i.destroyed||i.errored)return!1;i.state&=~QE,i.decoder&&!r?(e=i.decoder.write(e),i.objectMode||e.length!==0?$$(t,i,e,!1):ST(t,i)):$$(t,i,e,!1)}else n||(i.state&=~QE,ST(t,i));return!i.ended&&(i.length0?(e.state&Gae?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&ET&&TT(t)),ST(t,e)}hr.prototype.isPaused=function(){let t=this._readableState;return t[qg]===!0||t.flowing===!1};hr.prototype.setEncoding=function(t){let e=new zae(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 Dje=1073741824;function Bje(t){if(t>Dje)throw new yje("size","<= 1GiB",t);return t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++,t}function qae(t,e){return t<=0||e.length===0&&e.ended?0:e.state&A1?1:tje(t)?e.flowing&&e.length?e.buffer.first().length:e.length:t<=e.length?t:e.ended?e.length:0}hr.prototype.read=function(t){Mr("read",t),t===void 0?t=NaN:eje(t)||(t=rje(t,10));let e=this._readableState,r=t;if(t>e.highWaterMark&&(e.highWaterMark=Bje(t)),t!==0&&(e.state&=~Vae),t===0&&e.needReadable&&((e.highWaterMark!==0?e.length>=e.highWaterMark:e.length>0)||e.ended))return Mr("read: emitReadable",e.length,e.ended),e.length===0&&e.ended?j$(this):TT(this),null;if(t=qae(t,e),t===0&&e.ended)return e.length===0&&j$(this),null;let n=(e.state&ET)!==0;if(Mr("need readable",n),(e.length===0||e.length-t0?i=ece(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&&j$(this)),i!==null&&!e.errorEmitted&&!e.closeEmitted&&(e.dataEmitted=!0,this.emit("data",i)),i};function Mje(t,e){if(Mr("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?TT(t):(e.needReadable=!1,e.emittedReadable=!0,Zae(t))}}function TT(t){let e=t._readableState;Mr("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(Mr("emitReadable",e.flowing),e.emittedReadable=!0,Lu.nextTick(Zae,t))}function Zae(t){let e=t._readableState;Mr("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,Xae(t)}function ST(t,e){!e.readingMore&&e.constructed&&(e.readingMore=!0,Lu.nextTick(Oje,t,e))}function Oje(t,e){for(;!e.reading&&!e.ended&&(e.length1&&n.pipes.includes(t)&&(Mr("false write response, pause",n.awaitDrainWriters.size),n.awaitDrainWriters.add(t)),r.pause()),d||(d=Cje(r,t),t.on("drain",d))}r.on("data",p);function p(S){Mr("ondata");let P=t.write(S);Mr("dest.write",P),P===!1&&l()}function m(S){if(Mr("onerror",S),x(),t.removeListener("error",m),t.listenerCount("error")===0){let P=t._writableState||t._readableState;P&&!P.errorEmitted?S1(t,S):t.emit("error",S)}}dje(t,"error",m);function g(){t.removeListener("finish",v),x()}t.once("close",g);function v(){Mr("onfinish"),t.removeListener("close",g),x()}t.once("finish",v);function x(){Mr("unpipe"),r.unpipe(t)}return t.emit("pipe",r),t.writableNeedDrain===!0?l():n.flowing||(Mr("pipe resume"),r.resume()),t};function Cje(t,e){return function(){let n=t._readableState;n.awaitDrainWriters===e?(Mr("pipeOnDrain",1),n.awaitDrainWriters=null):n.multiAwaitDrain&&(Mr("pipeOnDrain",n.awaitDrainWriters.size),n.awaitDrainWriters.delete(e)),(!n.awaitDrainWriters||n.awaitDrainWriters.size===0)&&t.listenerCount("data")&&t.resume()}}hr.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;o0,n.flowing!==!1&&this.resume()):t==="readable"&&!n.endEmitted&&!n.readableListening&&(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,Mr("on readable",n.length,n.reading),n.length?TT(this):n.reading||Lu.nextTick($je,this)),r};hr.prototype.addListener=hr.prototype.on;hr.prototype.removeListener=function(t,e){let r=Km.prototype.removeListener.call(this,t,e);return t==="readable"&&Lu.nextTick(Yae,this),r};hr.prototype.off=hr.prototype.removeListener;hr.prototype.removeAllListeners=function(t){let e=Km.prototype.removeAllListeners.apply(this,arguments);return(t==="readable"||t===void 0)&&Lu.nextTick(Yae,this),e};function Yae(t){let e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&e[qg]===!1?e.flowing=!0:t.listenerCount("data")>0?t.resume():e.readableListening||(e.flowing=null)}function $je(t){Mr("readable nexttick read 0"),t.read(0)}hr.prototype.resume=function(){let t=this._readableState;return t.flowing||(Mr("resume"),t.flowing=!t.readableListening,jje(this,t)),t[qg]=!1,this};function jje(t,e){e.resumeScheduled||(e.resumeScheduled=!0,Lu.nextTick(Nje,t,e))}function Nje(t,e){Mr("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),Xae(t),e.flowing&&!e.reading&&t.read(0)}hr.prototype.pause=function(){return Mr("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(Mr("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState[qg]=!0,this};function Xae(t){let e=t._readableState;for(Mr("flow",e.flowing);e.flowing&&t.read()!==null;);}hr.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=>{S1(this,n)}),t.on("close",()=>{this.destroy()}),t.on("destroy",()=>{this.destroy()}),this._read=()=>{e&&t.resume&&(e=!1,t.resume())};let r=nje(t);for(let n=1;n{i=s?Uae(i,s):null,r(),r=C$});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 Kae(n)}}}catch(s){throw i=Uae(i,s),i}finally{(i||e?.destroyOnReturn!==!1)&&(i===void 0||t._readableState.autoDestroy)?T1.destroyer(t,null):(t.off("readable",n),o())}}L$(hr.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}}});L$(AT.prototype,{pipesCount:{__proto__:null,get(){return this.pipes.length}},paused:{__proto__:null,get(){return this[qg]!==!1},set(t){this[qg]=!!t}}});hr._fromList=ece;function ece(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 j$(t){let e=t._readableState;Mr("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,Lu.nextTick(qje,e,t))}function qje(t,e){if(Mr("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)Lu.nextTick(Lje,e);else if(t.autoDestroy){let r=e._writableState;(!r||r.autoDestroy&&(r.finished||r.writable===!1))&&e.destroy()}}}function Lje(t){t.writable&&!t.writableEnded&&!t.destroyed&&t.end()}hr.from=function(t,e){return _je(hr,t,e)};var N$;function tce(){return N$===void 0&&(N$={}),N$}hr.fromWeb=function(t,e){return tce().newStreamReadableFromReadableStream(t,e)};hr.toWeb=function(t,e){return tce().newReadableStreamFromStreamReadable(t,e)};hr.wrap=function(t,e){var r,n;return new hr({objectMode:(r=(n=t.readableObjectMode)!==null&&n!==void 0?n:t.objectMode)!==null&&r!==void 0?r:!0,...e,destroy(i,o){T1.destroyer(t,i),o(i)}}).wrap(t)}});var DT=V((g_t,pce)=>{f();var Lg=$s(),{ArrayPrototypeSlice:oce,Error:Kje,FunctionPrototypeSymbolHasInstance:sce,ObjectDefineProperty:ace,ObjectDefineProperties:Fje,ObjectSetPrototypeOf:cce,StringPrototypeToLowerCase:zje,Symbol:Wje,SymbolHasInstance:Hje}=ri();pce.exports=ni;ni.WritableState=n6;var{EventEmitter:Vje}=Sa(),t6=bT().Stream,{Buffer:PT}=hn(),RT=Ug(),{addAbortSignal:Gje}=YE(),{getHighWaterMark:Jje,getDefaultHighWaterMark:Zje}=XE(),{ERR_INVALID_ARG_TYPE:Yje,ERR_METHOD_NOT_IMPLEMENTED:Xje,ERR_MULTIPLE_CALLBACK:dce,ERR_STREAM_CANNOT_PIPE:Qje,ERR_STREAM_DESTROYED:r6,ERR_STREAM_ALREADY_FINISHED:eNe,ERR_STREAM_NULL_VALUES:tNe,ERR_STREAM_WRITE_AFTER_END:rNe,ERR_UNKNOWN_ENCODING:uce}=Ia().codes,{errorOrDestroy:P1}=RT;cce(ni.prototype,t6.prototype);cce(ni,t6);function z$(){}var I1=Wje("kOnFinished");function n6(t,e,r){typeof r!="boolean"&&(r=e instanceof Xl()),this.objectMode=!!(t&&t.objectMode),r&&(this.objectMode=this.objectMode||!!(t&&t.writableObjectMode)),this.highWaterMark=t?Jje(this,t,"writableHighWaterMark",r):Zje(!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=iNe.bind(void 0,e),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,kT(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[I1]=[]}function kT(t){t.buffered=[],t.bufferedIndex=0,t.allBuffers=!0,t.allNoop=!0}n6.prototype.getBuffer=function(){return oce(this.buffered,this.bufferedIndex)};ace(n6.prototype,"bufferedRequestCount",{__proto__:null,get(){return this.buffered.length-this.bufferedIndex}});function ni(t){let e=this instanceof Xl();if(!e&&!sce(ni,this))return new ni(t);this._writableState=new n6(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&&Gje(t.signal,this)),t6.call(this,t),RT.construct(this,()=>{let r=this._writableState;r.writing||H$(this,r),V$(this,r)})}ace(ni,Hje,{__proto__:null,value:function(t){return sce(this,t)?!0:this!==ni?!1:t&&t._writableState instanceof n6}});ni.prototype.pipe=function(){P1(this,new Qje)};function lce(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"&&!PT.isEncoding(r))throw new uce(r);typeof n!="function"&&(n=z$)}if(e===null)throw new tNe;if(!i.objectMode)if(typeof e=="string")i.decodeStrings!==!1&&(e=PT.from(e,r),r="buffer");else if(e instanceof PT)r="buffer";else if(t6._isUint8Array(e))e=t6._uint8ArrayToBuffer(e),r="buffer";else throw new Yje("chunk",["string","Buffer","Uint8Array"],e);let o;return i.ending?o=new rNe:i.destroyed&&(o=new r6("write")),o?(Lg.nextTick(n,o),P1(t,o,!0),o):(i.pendingcb++,nNe(t,i,e,r,n))}ni.prototype.write=function(t,e,r){return lce(this,t,e,r)===!0};ni.prototype.cork=function(){this._writableState.corked++};ni.prototype.uncork=function(){let t=this._writableState;t.corked&&(t.corked--,t.writing||H$(this,t))};ni.prototype.setDefaultEncoding=function(e){if(typeof e=="string"&&(e=zje(e)),!PT.isEncoding(e))throw new uce(e);return this._writableState.defaultEncoding=e,this};function nNe(t,e,r,n,i){let o=e.objectMode?1:r.length;e.length+=o;let s=e.lengthr.bufferedIndex&&H$(t,r),n?r.afterWriteTickInfo!==null&&r.afterWriteTickInfo.cb===i?r.afterWriteTickInfo.count++:(r.afterWriteTickInfo={count:1,cb:i,stream:t,state:r},Lg.nextTick(oNe,r.afterWriteTickInfo)):fce(t,r,1,i))}function oNe({stream:t,state:e,count:r,cb:n}){return e.afterWriteTickInfo=null,fce(t,e,r,n)}function fce(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&&W$(e),V$(t,e)}function W$(t){if(t.writing)return;for(let i=t.bufferedIndex;i1&&t._writev){e.pendingcb-=o-1;let a=e.allNoop?z$:u=>{for(let c=s;c256?(r.splice(0,s),e.bufferedIndex=0):e.bufferedIndex=s}e.bufferProcessing=!1}ni.prototype._write=function(t,e,r){if(this._writev)this._writev([{chunk:t,encoding:e}],r);else throw new Xje("_write()")};ni.prototype._writev=null;ni.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=lce(this,t,e);o instanceof Kje&&(i=o)}return n.corked&&(n.corked=1,this.uncork()),i||(!n.errored&&!n.ending?(n.ending=!0,V$(this,n,!0),n.ended=!0):n.finished?i=new eNe("end"):n.destroyed&&(i=new r6("end"))),typeof r=="function"&&(i||n.finished?Lg.nextTick(r,i):n[I1].push(r)),this};function IT(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 sNe(t,e){let r=!1;function n(i){if(r){P1(t,i??dce());return}if(r=!0,e.pendingcb--,i){let o=e[I1].splice(0);for(let s=0;s{IT(i)?F$(n,i):i.pendingcb--},t,e)):IT(e)&&(e.pendingcb++,F$(t,e))))}function F$(t,e){e.pendingcb--,e.finished=!0;let r=e[I1].splice(0);for(let n=0;n{f();var G$=$s(),dNe=hn(),{isReadable:uNe,isWritable:lNe,isIterable:mce,isNodeStream:fNe,isReadableNodeStream:yce,isWritableNodeStream:gce,isDuplexNodeStream:hNe,isReadableStream:vce,isWritableStream:bce}=Zl(),wce=Dh(),{AbortError:Tce,codes:{ERR_INVALID_ARG_TYPE:pNe,ERR_INVALID_RETURN_VALUE:_ce}}=Ia(),{destroyer:R1}=Ug(),mNe=Xl(),Pce=e6(),yNe=DT(),{createDeferredPromise:xce}=ta(),Ece=M$(),Sce=globalThis.Blob||dNe.Blob,gNe=typeof Sce<"u"?function(e){return e instanceof Sce}:function(e){return!1},vNe=globalThis.AbortController||Rh().AbortController,{FunctionPrototypeCall:Ace}=ri(),Fm=class extends mNe{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)}};Ice.exports=function t(e,r){if(hNe(e))return e;if(yce(e))return k1({readable:e});if(gce(e))return k1({writable:e});if(fNe(e))return k1({writable:!1,readable:!1});if(vce(e))return k1({readable:Pce.fromWeb(e)});if(bce(e))return k1({writable:yNe.fromWeb(e)});if(typeof e=="function"){let{value:i,write:o,final:s,destroy:a}=bNe(e);if(mce(i))return Ece(Fm,i,{objectMode:!0,write:o,final:s,destroy:a});let d=i?.then;if(typeof d=="function"){let u,c=Ace(d,i,l=>{if(l!=null)throw new _ce("nully","body",l)},l=>{R1(u,l)});return u=new Fm({objectMode:!0,readable:!1,write:o,final(l){s(async()=>{try{await c,G$.nextTick(l,null)}catch(p){G$.nextTick(l,p)}})},destroy:a})}throw new _ce("Iterable, AsyncIterable or AsyncFunction",r,i)}if(gNe(e))return t(e.arrayBuffer());if(mce(e))return Ece(Fm,e,{objectMode:!0,writable:!1});if(vce(e?.readable)&&bce(e?.writable))return Fm.fromWeb(e);if(typeof e?.writable=="object"||typeof e?.readable=="object"){let i=e!=null&&e.readable?yce(e?.readable)?e?.readable:t(e.readable):void 0,o=e!=null&&e.writable?gce(e?.writable)?e?.writable:t(e.writable):void 0;return k1({readable:i,writable:o})}let n=e?.then;if(typeof n=="function"){let i;return Ace(n,e,o=>{o!=null&&i.push(o),i.push(null)},o=>{R1(i,o)}),i=new Fm({objectMode:!0,writable:!1,read(){}})}throw new pNe(r,["Blob","ReadableStream","WritableStream","Stream","Iterable","AsyncIterable","Function","{ readable, writable } pair","Promise"],e)};function bNe(t){let{promise:e,resolve:r}=xce(),n=new vNe,i=n.signal;return{value:t(async function*(){for(;;){let s=e;e=null;let{chunk:a,done:d,cb:u}=await s;if(G$.nextTick(u),d)return;if(i.aborted)throw new Tce(void 0,{cause:i.reason});({promise:e,resolve:r}=xce()),yield a}}(),{signal:i}),write(s,a,d){let u=r;r=null,u({chunk:s,done:!1,cb:d})},final(s){let a=r;r=null,a({done:!0,cb:s})},destroy(s,a){n.abort(),a(s)}}}function k1(t){let e=t.readable&&typeof t.readable.read!="function"?Pce.wrap(t.readable):t.readable,r=t.writable,n=!!uNe(e),i=!!lNe(r),o,s,a,d,u;function c(l){let p=d;d=null,p?p(l):l&&u.destroy(l)}return u=new Fm({readableObjectMode:!!(e!=null&&e.readableObjectMode),writableObjectMode:!!(r!=null&&r.writableObjectMode),readable:n,writable:i}),i&&(wce(r,l=>{i=!1,l&&R1(e,l),c(l)}),u._write=function(l,p,m){r.write(l,p)?m():o=m},u._final=function(l){r.end(),s=l},r.on("drain",function(){if(o){let l=o;o=null,l()}}),r.on("finish",function(){if(s){let l=s;s=null,l()}})),n&&(wce(e,l=>{n=!1,l&&R1(e,l),c(l)}),e.on("readable",function(){if(a){let l=a;a=null,l()}}),e.on("end",function(){u.push(null)}),u._read=function(){for(;;){let l=e.read();if(l===null){a=u._read;return}if(!u.push(l))return}}),u._destroy=function(l,p){!l&&d!==null&&(l=new Tce),a=null,o=null,s=null,d===null?p(l):(d=p,R1(r,l),R1(e,l))},u}});var Xl=V((__t,Bce)=>{"use strict";f();var{ObjectDefineProperties:wNe,ObjectGetOwnPropertyDescriptor:Bh,ObjectKeys:_Ne,ObjectSetPrototypeOf:Rce}=ri();Bce.exports=Ku;var Y$=e6(),Nd=DT();Rce(Ku.prototype,Y$.prototype);Rce(Ku,Y$);{let t=_Ne(Nd.prototype);for(let e=0;e{"use strict";f();var{ObjectSetPrototypeOf:Mce,Symbol:xNe}=ri();Oce.exports=Mh;var{ERR_METHOD_NOT_IMPLEMENTED:ENe}=Ia().codes,Q$=Xl(),{getHighWaterMark:SNe}=XE();Mce(Mh.prototype,Q$.prototype);Mce(Mh,Q$);var i6=xNe("kCallback");function Mh(t){if(!(this instanceof Mh))return new Mh(t);let e=t?SNe(this,t,"readableHighWaterMark",!0):null;e===0&&(t={...t,highWaterMark:null,readableHighWaterMark:e,writableHighWaterMark:t.writableHighWaterMark||0}),Q$.call(this,t),this._readableState.sync=!1,this[i6]=null,t&&(typeof t.transform=="function"&&(this._transform=t.transform),typeof t.flush=="function"&&(this._flush=t.flush)),this.on("prefinish",ANe)}function X$(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 ANe(){this._final!==X$&&X$.call(this)}Mh.prototype._final=X$;Mh.prototype._transform=function(t,e,r){throw new ENe("_transform()")};Mh.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{"use strict";f();var{ObjectSetPrototypeOf:Cce}=ri();$ce.exports=D1;var tj=ej();Cce(D1.prototype,tj.prototype);Cce(D1,tj);function D1(t){if(!(this instanceof D1))return new D1(t);tj.call(this,t)}D1.prototype._transform=function(t,e,r){r(null,t)}});var CT=V((P_t,Lce)=>{f();var o6=$s(),{ArrayIsArray:TNe,Promise:PNe,SymbolAsyncIterator:INe,SymbolDispose:kNe}=ri(),OT=Dh(),{once:RNe}=ta(),DNe=Ug(),jce=Xl(),{aggregateTwoErrors:BNe,codes:{ERR_INVALID_ARG_TYPE:lj,ERR_INVALID_RETURN_VALUE:nj,ERR_MISSING_ARGS:MNe,ERR_STREAM_DESTROYED:ONe,ERR_STREAM_PREMATURE_CLOSE:CNe},AbortError:$Ne}=Ia(),{validateFunction:jNe,validateAbortSignal:NNe}=x1(),{isIterable:Kg,isReadable:ij,isReadableNodeStream:MT,isNodeStream:Nce,isTransformStream:B1,isWebStream:UNe,isReadableStream:oj,isReadableFinished:qNe}=Zl(),LNe=globalThis.AbortController||Rh().AbortController,sj,aj,cj;function Uce(t,e,r){let n=!1;t.on("close",()=>{n=!0});let i=OT(t,{readable:e,writable:r},o=>{n=!o});return{destroy:o=>{n||(n=!0,DNe.destroyer(t,o||new ONe("pipe")))},cleanup:i}}function KNe(t){return jNe(t[t.length-1],"streams[stream.length - 1]"),t.pop()}function dj(t){if(Kg(t))return t;if(MT(t))return FNe(t);throw new lj("val",["Readable","Iterable","AsyncIterable"],t)}async function*FNe(t){aj||(aj=e6()),yield*aj.prototype[INe].call(t)}async function BT(t,e,r,{end:n}){let i,o=null,s=u=>{if(u&&(i=u),o){let c=o;o=null,c()}},a=()=>new PNe((u,c)=>{i?c(i):o=()=>{i?c(i):u()}});e.on("drain",s);let d=OT(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?BNe(i,u):u)}finally{d(),e.off("drain",s)}}async function uj(t,e,r,{end:n}){B1(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 zNe(...t){return qce(t,RNe(KNe(t)))}function qce(t,e,r){if(t.length===1&&TNe(t[0])&&(t=t[0]),t.length<2)throw new MNe("streams");let n=new LNe,i=n.signal,o=r?.signal,s=[];NNe(o,"options.signal");function a(){g(new $Ne)}cj=cj||ta().addAbortListener;let d;o&&(d=cj(o,a));let u,c,l=[],p=0;function m(A){g(A,--p===0)}function g(A,$){var j;if(A&&(!u||u.code==="ERR_STREAM_PREMATURE_CLOSE")&&(u=A),!(!u&&!$)){for(;l.length;)l.shift()(u);(j=d)===null||j===void 0||j[kNe](),n.abort(),$&&(u||s.forEach(L=>L()),o6.nextTick(e,u,c))}}let v;for(let A=0;A0,F=j||r?.end!==!1,K=A===t.length-1;if(Nce($)){let W=function(q){q&&q.name!=="AbortError"&&q.code!=="ERR_STREAM_PREMATURE_CLOSE"&&m(q)};var P=W;if(F){let{destroy:q,cleanup:I}=Uce($,j,L);l.push(q),ij($)&&K&&s.push(I)}$.on("error",W),ij($)&&K&&s.push(()=>{$.removeListener("error",W)})}if(A===0)if(typeof $=="function"){if(v=$({signal:i}),!Kg(v))throw new nj("Iterable, AsyncIterable or Stream","source",v)}else Kg($)||MT($)||B1($)?v=$:v=jce.from($);else if(typeof $=="function"){if(B1(v)){var x;v=dj((x=v)===null||x===void 0?void 0:x.readable)}else v=dj(v);if(v=$(v,{signal:i}),j){if(!Kg(v,!0))throw new nj("AsyncIterable",`transform[${A-1}]`,v)}else{var S;sj||(sj=rj());let W=new sj({objectMode:!0}),q=(S=v)===null||S===void 0?void 0:S.then;if(typeof q=="function")p++,q.call(v,B=>{c=B,B!=null&&W.write(B),F&&W.end(),o6.nextTick(m)},B=>{W.destroy(B),o6.nextTick(m,B)});else if(Kg(v,!0))p++,BT(v,W,m,{end:F});else if(oj(v)||B1(v)){let B=v.readable||v;p++,BT(B,W,m,{end:F})}else throw new nj("AsyncIterable or Promise","destination",v);v=W;let{destroy:I,cleanup:T}=Uce(v,!1,!0);l.push(I),K&&s.push(T)}}else if(Nce($)){if(MT(v)){p+=2;let W=WNe(v,$,m,{end:F});ij($)&&K&&s.push(W)}else if(B1(v)||oj(v)){let W=v.readable||v;p++,BT(W,$,m,{end:F})}else if(Kg(v))p++,BT(v,$,m,{end:F});else throw new lj("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],v);v=$}else if(UNe($)){if(MT(v))p++,uj(dj(v),$,m,{end:F});else if(oj(v)||Kg(v))p++,uj(v,$,m,{end:F});else if(B1(v))p++,uj(v.readable,$,m,{end:F});else throw new lj("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],v);v=$}else v=jce.from($)}return(i!=null&&i.aborted||o!=null&&o.aborted)&&o6.nextTick(a),v}function WNe(t,e,r,{end:n}){let i=!1;if(e.on("close",()=>{i||r(new CNe)}),t.pipe(e,{end:!1}),n){let s=function(){i=!0,e.end()};var o=s;qNe(t)?o6.nextTick(s):t.once("end",s)}else r();return OT(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)}),OT(e,{readable:!1,writable:!0},r)}Lce.exports={pipelineImpl:qce,pipeline:zNe}});var hj=V((k_t,Vce)=>{"use strict";f();var{pipeline:HNe}=CT(),$T=Xl(),{destroyer:VNe}=Ug(),{isNodeStream:jT,isReadable:Kce,isWritable:Fce,isWebStream:fj,isTransformStream:Fg,isWritableStream:zce,isReadableStream:Wce}=Zl(),{AbortError:GNe,codes:{ERR_INVALID_ARG_VALUE:Hce,ERR_MISSING_ARGS:JNe}}=Ia(),ZNe=Dh();Vce.exports=function(...e){if(e.length===0)throw new JNe("streams");if(e.length===1)return $T.from(e[0]);let r=[...e];if(typeof e[0]=="function"&&(e[0]=$T.from(e[0])),typeof e[e.length-1]=="function"){let m=e.length-1;e[m]=$T.from(e[m])}for(let m=0;m0&&!(Fce(e[m])||zce(e[m])||Fg(e[m])))throw new Hce(`streams[${m}]`,r[m],"must be writable")}let n,i,o,s,a;function d(m){let g=s;s=null,g?g(m):m?a.destroy(m):!p&&!l&&a.destroy()}let u=e[0],c=HNe(e,d),l=!!(Fce(u)||zce(u)||Fg(u)),p=!!(Kce(c)||Wce(c)||Fg(c));if(a=new $T({writableObjectMode:!!(u!=null&&u.writableObjectMode),readableObjectMode:!!(c!=null&&c.readableObjectMode),writable:l,readable:p}),l){if(jT(u))a._write=function(g,v,x){u.write(g,v)?x():n=x},a._final=function(g){u.end(),i=g},u.on("drain",function(){if(n){let g=n;n=null,g()}});else if(fj(u)){let v=(Fg(u)?u.writable:u).getWriter();a._write=async function(x,S,P){try{await v.ready,v.write(x).catch(()=>{}),P()}catch(A){P(A)}},a._final=async function(x){try{await v.ready,v.close().catch(()=>{}),i=x}catch(S){x(S)}}}let m=Fg(c)?c.readable:c;ZNe(m,()=>{if(i){let g=i;i=null,g()}})}if(p){if(jT(c))c.on("readable",function(){if(o){let m=o;o=null,m()}}),c.on("end",function(){a.push(null)}),a._read=function(){for(;;){let m=c.read();if(m===null){o=a._read;return}if(!a.push(m))return}};else if(fj(c)){let g=(Fg(c)?c.readable:c).getReader();a._read=async function(){for(;;)try{let{value:v,done:x}=await g.read();if(!a.push(v))return;if(x){a.push(null);return}}catch{return}}}}return a._destroy=function(m,g){!m&&s!==null&&(m=new GNe),o=null,n=null,i=null,s===null?g(m):(s=g,jT(c)&&VNe(c,m))},a}});var nde=V((D_t,yj)=>{"use strict";f();var YNe=globalThis.AbortController||Rh().AbortController,{codes:{ERR_INVALID_ARG_VALUE:XNe,ERR_INVALID_ARG_TYPE:s6,ERR_MISSING_ARGS:QNe,ERR_OUT_OF_RANGE:eUe},AbortError:Ql}=Ia(),{validateAbortSignal:zg,validateInteger:Gce,validateObject:Wg}=x1(),tUe=ri().Symbol("kWeak"),rUe=ri().Symbol("kResistStopPropagation"),{finished:nUe}=Dh(),iUe=hj(),{addAbortSignalNoValidate:oUe}=YE(),{isWritable:sUe,isNodeStream:aUe}=Zl(),{deprecate:cUe}=ta(),{ArrayPrototypePush:dUe,Boolean:uUe,MathFloor:Jce,Number:lUe,NumberIsNaN:fUe,Promise:Zce,PromiseReject:Yce,PromiseResolve:hUe,PromisePrototypeThen:Xce,Symbol:ede}=ri(),NT=ede("kEmpty"),Qce=ede("kEof");function pUe(t,e){if(e!=null&&Wg(e,"options"),e?.signal!=null&&zg(e.signal,"options.signal"),aUe(t)&&!sUe(t))throw new XNe("stream",t,"must be writable");let r=iUe(this,t);return e!=null&&e.signal&&oUe(e.signal,r),r}function UT(t,e){if(typeof t!="function")throw new s6("fn",["Function","AsyncFunction"],t);e!=null&&Wg(e,"options"),e?.signal!=null&&zg(e.signal,"options.signal");let r=1;e?.concurrency!=null&&(r=Jce(e.concurrency));let n=r-1;return e?.highWaterMark!=null&&(n=Jce(e.highWaterMark)),Gce(r,"options.concurrency",1),Gce(n,"options.highWaterMark",0),n+=r,(async function*(){let o=ta().AbortSignalAny([e?.signal].filter(uUe)),s=this,a=[],d={signal:o},u,c,l=!1,p=0;function m(){l=!0,g()}function g(){p-=1,v()}function v(){c&&!l&&p=n||p>=r)&&await new Zce(P=>{c=P})}a.push(Qce)}catch(S){let P=Yce(S);Xce(P,g,m),a.push(P)}finally{l=!0,u&&(u(),u=null)}}x();try{for(;;){for(;a.length>0;){let S=await a[0];if(S===Qce)return;if(o.aborted)throw new Ql;S!==NT&&(yield S),a.shift(),v()}await new Zce(S=>{u=S})}}finally{l=!0,c&&(c(),c=null)}}).call(this)}function mUe(t=void 0){return t!=null&&Wg(t,"options"),t?.signal!=null&&zg(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 Ql({cause:t.signal.reason});yield[r++,i]}}).call(this)}async function tde(t,e=void 0){for await(let r of mj.call(this,t,e))return!0;return!1}async function yUe(t,e=void 0){if(typeof t!="function")throw new s6("fn",["Function","AsyncFunction"],t);return!await tde.call(this,async(...r)=>!await t(...r),e)}async function gUe(t,e){for await(let r of mj.call(this,t,e))return r}async function vUe(t,e){if(typeof t!="function")throw new s6("fn",["Function","AsyncFunction"],t);async function r(n,i){return await t(n,i),NT}for await(let n of UT.call(this,r,e));}function mj(t,e){if(typeof t!="function")throw new s6("fn",["Function","AsyncFunction"],t);async function r(n,i){return await t(n,i)?n:NT}return UT.call(this,r,e)}var pj=class extends QNe{constructor(){super("reduce"),this.message="Reduce of an empty stream requires an initial value"}};async function bUe(t,e,r){var n;if(typeof t!="function")throw new s6("reducer",["Function","AsyncFunction"],t);r!=null&&Wg(r,"options"),r?.signal!=null&&zg(r.signal,"options.signal");let i=arguments.length>1;if(r!=null&&(n=r.signal)!==null&&n!==void 0&&n.aborted){let u=new Ql(void 0,{cause:r.signal.reason});throw this.once("error",()=>{}),await nUe(this.destroy(u)),u}let o=new YNe,s=o.signal;if(r!=null&&r.signal){let u={once:!0,[tUe]:this,[rUe]:!0};r.signal.addEventListener("abort",()=>o.abort(),u)}let a=!1;try{for await(let u of this){var d;if(a=!0,r!=null&&(d=r.signal)!==null&&d!==void 0&&d.aborted)throw new Ql;i?e=await t(e,u,{signal:s}):(e=u,i=!0)}if(!a&&!i)throw new pj}finally{o.abort()}return e}async function wUe(t){t!=null&&Wg(t,"options"),t?.signal!=null&&zg(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 Ql(void 0,{cause:t.signal.reason});dUe(e,n)}return e}function _Ue(t,e){let r=UT.call(this,t,e);return(async function*(){for await(let i of r)yield*i}).call(this)}function rde(t){if(t=lUe(t),fUe(t))return 0;if(t<0)throw new eUe("number",">= 0",t);return t}function xUe(t,e=void 0){return e!=null&&Wg(e,"options"),e?.signal!=null&&zg(e.signal,"options.signal"),t=rde(t),(async function*(){var n;if(e!=null&&(n=e.signal)!==null&&n!==void 0&&n.aborted)throw new Ql;for await(let o of this){var i;if(e!=null&&(i=e.signal)!==null&&i!==void 0&&i.aborted)throw new Ql;t--<=0&&(yield o)}}).call(this)}function EUe(t,e=void 0){return e!=null&&Wg(e,"options"),e?.signal!=null&&zg(e.signal,"options.signal"),t=rde(t),(async function*(){var n;if(e!=null&&(n=e.signal)!==null&&n!==void 0&&n.aborted)throw new Ql;for await(let o of this){var i;if(e!=null&&(i=e.signal)!==null&&i!==void 0&&i.aborted)throw new Ql;if(t-- >0&&(yield o),t<=0)return}}).call(this)}yj.exports.streamReturningOperators={asIndexedPairs:cUe(mUe,"readable.asIndexedPairs will be removed in a future version."),drop:xUe,filter:mj,flatMap:_Ue,map:UT,take:EUe,compose:pUe};yj.exports.promiseReturningOperators={every:yUe,forEach:vUe,reduce:bUe,toArray:wUe,some:tde,find:gUe}});var gj=V((M_t,ide)=>{"use strict";f();var{ArrayPrototypePop:SUe,Promise:AUe}=ri(),{isIterable:TUe,isNodeStream:PUe,isWebStream:IUe}=Zl(),{pipelineImpl:kUe}=CT(),{finished:RUe}=Dh();vj();function DUe(...t){return new AUe((e,r)=>{let n,i,o=t[t.length-1];if(o&&typeof o=="object"&&!PUe(o)&&!TUe(o)&&!IUe(o)){let s=SUe(t);n=s.signal,i=s.end}kUe(t,(s,a)=>{s?r(s):e(a)},{signal:n,end:i})})}ide.exports={finished:RUe,pipeline:DUe}});var vj=V((C_t,hde)=>{f();var{Buffer:BUe}=hn(),{ObjectDefineProperty:Oh,ObjectKeys:ade,ReflectApply:cde}=ri(),{promisify:{custom:dde}}=ta(),{streamReturningOperators:ode,promiseReturningOperators:sde}=nde(),{codes:{ERR_ILLEGAL_CONSTRUCTOR:ude}}=Ia(),MUe=hj(),{setDefaultHighWaterMark:OUe,getDefaultHighWaterMark:CUe}=XE(),{pipeline:lde}=CT(),{destroyer:$Ue}=Ug(),fde=Dh(),bj=gj(),a6=Zl(),Kn=hde.exports=bT().Stream;Kn.isDestroyed=a6.isDestroyed;Kn.isDisturbed=a6.isDisturbed;Kn.isErrored=a6.isErrored;Kn.isReadable=a6.isReadable;Kn.isWritable=a6.isWritable;Kn.Readable=e6();for(let t of ade(ode)){let r=function(...n){if(new.target)throw ude();return Kn.Readable.from(cde(e,this,n))};wj=r;let e=ode[t];Oh(r,"name",{__proto__:null,value:e.name}),Oh(r,"length",{__proto__:null,value:e.length}),Oh(Kn.Readable.prototype,t,{__proto__:null,value:r,enumerable:!1,configurable:!0,writable:!0})}var wj;for(let t of ade(sde)){let r=function(...i){if(new.target)throw ude();return cde(e,this,i)};wj=r;let e=sde[t];Oh(r,"name",{__proto__:null,value:e.name}),Oh(r,"length",{__proto__:null,value:e.length}),Oh(Kn.Readable.prototype,t,{__proto__:null,value:r,enumerable:!1,configurable:!0,writable:!0})}var wj;Kn.Writable=DT();Kn.Duplex=Xl();Kn.Transform=ej();Kn.PassThrough=rj();Kn.pipeline=lde;var{addAbortSignal:jUe}=YE();Kn.addAbortSignal=jUe;Kn.finished=fde;Kn.destroy=$Ue;Kn.compose=MUe;Kn.setDefaultHighWaterMark=OUe;Kn.getDefaultHighWaterMark=CUe;Oh(Kn,"promises",{__proto__:null,configurable:!0,enumerable:!0,get(){return bj}});Oh(lde,dde,{__proto__:null,enumerable:!0,get(){return bj.pipeline}});Oh(fde,dde,{__proto__:null,enumerable:!0,get(){return bj.finished}});Kn.Stream=Kn;Kn._isUint8Array=function(e){return e instanceof Uint8Array};Kn._uint8ArrayToBuffer=function(e){return BUe.from(e.buffer,e.byteOffset,e.byteLength)}});var M1=V((j_t,ki)=>{"use strict";f();var so=vj(),NUe=gj(),UUe=so.Readable.destroy;ki.exports=so.Readable;ki.exports._uint8ArrayToBuffer=so._uint8ArrayToBuffer;ki.exports._isUint8Array=so._isUint8Array;ki.exports.isDisturbed=so.isDisturbed;ki.exports.isErrored=so.isErrored;ki.exports.isReadable=so.isReadable;ki.exports.Readable=so.Readable;ki.exports.Writable=so.Writable;ki.exports.Duplex=so.Duplex;ki.exports.Transform=so.Transform;ki.exports.PassThrough=so.PassThrough;ki.exports.addAbortSignal=so.addAbortSignal;ki.exports.finished=so.finished;ki.exports.destroy=so.destroy;ki.exports.destroy=UUe;ki.exports.pipeline=so.pipeline;ki.exports.compose=so.compose;Object.defineProperty(so,"promises",{configurable:!0,enumerable:!0,get(){return NUe}});ki.exports.Stream=so.Stream;ki.exports.default=ki.exports});var _de=V((Rj,Dj)=>{f();(function(t,e){typeof Rj=="object"&&typeof Dj<"u"?Dj.exports=e():typeof define=="function"&&define.amd?define(e):(t=t||self,t.JSBI=e())})(Rj,function(){"use strict";var t=Math.imul,e=Math.clz32;function r(K){"@babel/helpers - typeof";return r=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(W){return typeof W}:function(W){return W&&typeof Symbol=="function"&&W.constructor===Symbol&&W!==Symbol.prototype?"symbol":typeof W},r(K)}function n(K,W){if(!(K instanceof W))throw new TypeError("Cannot call a class as a function")}function i(K,W){for(var q,I=0;I"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function c(){return c=u()?Reflect.construct:function(K,W,q){var I=[null];I.push.apply(I,W);var T=Function.bind.apply(K,I),B=new T;return q&&d(B,q.prototype),B},c.apply(null,arguments)}function l(K){return Function.toString.call(K).indexOf("[native code]")!==-1}function p(K){var W=typeof Map=="function"?new Map:void 0;return p=function(q){function I(){return c(q,arguments,a(this).constructor)}if(q===null||!l(q))return q;if(typeof q!="function")throw new TypeError("Super expression must either be null or a function");if(typeof W<"u"){if(W.has(q))return W.get(q);W.set(q,I)}return I.prototype=Object.create(q.prototype,{constructor:{value:I,enumerable:!1,writable:!0,configurable:!0}}),d(I,q)},p(K)}function m(K){if(K===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return K}function g(K,W){if(W&&(typeof W=="object"||typeof W=="function"))return W;if(W!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return m(K)}function v(K){var W=u();return function(){var q,I=a(K);if(W){var T=a(this).constructor;q=Reflect.construct(I,arguments,T)}else q=I.apply(this,arguments);return g(this,q)}}function x(K,W){return S(K)||P(K,W)||A(K,W)||j()}function S(K){if(Array.isArray(K))return K}function P(K,W){var q=K==null?null:typeof Symbol<"u"&&K[Symbol.iterator]||K["@@iterator"];if(q!=null){var I,T,B=[],h=!0,y=!1;try{for(q=q.call(K);!(h=(I=q.next()).done)&&(B.push(I.value),!(W&&B.length===W));h=!0);}catch(w){y=!0,T=w}finally{try{h||q.return==null||q.return()}finally{if(y)throw T}}return B}}function A(K,W){if(K){if(typeof K=="string")return $(K,W);var q=Object.prototype.toString.call(K).slice(8,-1);return q==="Object"&&K.constructor&&(q=K.constructor.name),q==="Map"||q==="Set"?Array.from(K):q==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(q)?$(K,W):void 0}}function $(K,W){(W==null||W>K.length)&&(W=K.length);for(var q=0,I=Array(W);q=K.length?{done:!0}:{done:!1,value:K[I++]}},e:function(w){throw w},f:T}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var B,h=!0,y=!1;return{s:function(){q=q.call(K)},n:function(){var w=q.next();return h=w.done,w},e:function(w){y=!0,B=w},f:function(){try{h||q.return==null||q.return()}finally{if(y)throw B}}}}var F=function(K){var W=Math.abs,q=Math.max,I=Math.floor;function T(h,y){var w;if(n(this,T),w=B.call(this,h),w.sign=y,Object.setPrototypeOf(m(w),T.prototype),h>T.__kMaxLength)throw new RangeError("Maximum BigInt size exceeded");return w}s(T,K);var B=v(T);return o(T,[{key:"toDebugString",value:function(){var h,y=["BigInt["],w=L(this);try{for(w.s();!(h=w.n()).done;){var E=h.value;y.push((E&&(E>>>0).toString(16))+", ")}}catch(_){w.e(_)}finally{w.f()}return y.push("]"),y.join("")}},{key:"toString",value:function(){var h=0h||36this.length&&(w=this.length);for(var E=32767&h,_=h>>>15,b=0,C=y,N=0;N>>15,Z=T.__imul(U,E),J=T.__imul(U,_),H=T.__imul(G,E),X=T.__imul(G,_),te=C+Z+b;b=te>>>30,te&=1073741823,te+=((32767&J)<<15)+((32767&H)<<15),b+=te>>>30,C=X+(J>>>15)+(H>>>15),this.__setDigit(N,1073741823&te)}if(b!==0||C!==0)throw new Error("implementation bug")}},{key:"__inplaceAdd",value:function(h,y,w){for(var E,_=0,b=0;b>>15,this.__setHalfDigit(y+b,32767&E);return _}},{key:"__inplaceSub",value:function(h,y,w){var E=0;if(1&y){y>>=1;for(var _=this.__digit(y),b=32767&_,C=0;C>>1;C++){var N=h.__digit(C),M=(_>>>15)-(32767&N)-E;E=1&M>>>15,this.__setDigit(y+C,(32767&M)<<15|32767&b),_=this.__digit(y+C+1),b=(32767&_)-(N>>>15)-E,E=1&b>>>15}var U=h.__digit(C),G=(_>>>15)-(32767&U)-E;if(E=1&G>>>15,this.__setDigit(y+C,(32767&G)<<15|32767&b),y+C+1>=this.length)throw new RangeError("out of bounds");!(1&w)&&(_=this.__digit(y+C+1),b=(32767&_)-(U>>>15)-E,E=1&b>>>15,this.__setDigit(y+h.length,1073709056&_|32767&b))}else{y>>=1;for(var Z=0;Z>>15;var te=(J>>>15)-(H>>>15)-E;E=1&te>>>15,this.__setDigit(y+Z,(32767&te)<<15|32767&X)}var ne=this.__digit(y+Z),Q=h.__digit(Z),re=(32767&ne)-(32767&Q)-E;E=1&re>>>15;var ce=0;!(1&w)&&(ce=(ne>>>15)-(Q>>>15)-E,E=1&ce>>>15),this.__setDigit(y+Z,(32767&ce)<<15|32767&re)}return E}},{key:"__inplaceRightShift",value:function(h){if(h!==0){for(var y,w=this.__digit(0)>>>h,E=this.length-1,_=0;_>>h;this.__setDigit(E,w)}}},{key:"__digit",value:function(h){return this[h]}},{key:"__unsignedDigit",value:function(h){return this[h]>>>0}},{key:"__setDigit",value:function(h,y){this[h]=0|y}},{key:"__setDigitGrow",value:function(h,y){this[h]=0|y}},{key:"__halfDigitLength",value:function(){var h=this.length;return 32767>=this.__unsignedDigit(h-1)?2*h-1:2*h}},{key:"__halfDigit",value:function(h){return 32767&this[h>>>1]>>>15*(1&h)}},{key:"__setHalfDigit",value:function(h,y){var w=h>>>1,E=this.__digit(w),_=1&h?32767&E|y<<15:1073709056&E|32767&y;this.__setDigit(w,_)}}],[{key:"BigInt",value:function(h){var y=Number.isFinite;if(typeof h=="number"){if(h===0)return T.__zero();if(T.__isOneDigitInt(h))return 0>h?T.__oneDigit(-h,!0):T.__oneDigit(h,!1);if(!y(h)||I(h)!==h)throw new RangeError("The number "+h+" cannot be converted to BigInt because it is not an integer");return T.__fromDouble(h)}if(typeof h=="string"){var w=T.__fromString(h);if(w===null)throw new SyntaxError("Cannot convert "+h+" to a BigInt");return w}if(typeof h=="boolean")return h===!0?T.__oneDigit(1,!1):T.__zero();if(r(h)==="object"){if(h.constructor===T)return h;var E=T.__toPrimitive(h);return T.BigInt(E)}throw new TypeError("Cannot convert "+h+" to a BigInt")}},{key:"toNumber",value:function(h){var y=h.length;if(y===0)return 0;if(y===1){var w=h.__unsignedDigit(0);return h.sign?-w:w}var E=h.__digit(y-1),_=T.__clz30(E),b=30*y-_;if(1024>>=12;var Z=U-12,J=12<=U?0:N<<20+U,H=20+U;for(0>>30-Z,J=N<>>30-H,H-=30;var X=T.__decideRounding(h,H,M,N);if((X===1||X===0&&(1&J)==1)&&(J=J+1>>>0,J===0&&(G++,G>>>20!=0&&(G=0,C++,1023=T.__kMaxLengthBits)throw new RangeError("BigInt too big");if(h.length===1&&h.__digit(0)===2){var E=1+(0|w/30),_=h.sign&&(1&w)!=0,b=new T(E,_);b.__initializeDigits();var C=1<>=1;w!==0;w>>=1)M=T.multiply(M,M),1&w&&(N===null?N=M:N=T.multiply(N,M));return N}},{key:"multiply",value:function(h,y){if(h.length===0)return h;if(y.length===0)return y;var w=h.length+y.length;30<=h.__clzmsd()+y.__clzmsd()&&w--;var E=new T(w,h.sign!==y.sign);E.__initializeDigits();for(var _=0;_T.__absoluteCompare(h,y))return T.__zero();var w,E=h.sign!==y.sign,_=y.__unsignedDigit(0);if(y.length===1&&32767>=_){if(_===1)return E===h.sign?h:T.unaryMinus(h);w=T.__absoluteDivSmall(h,_,null)}else w=T.__absoluteDivLarge(h,y,!0,!1);return w.sign=E,w.__trim()}},{key:"remainder",value:function(y,w){if(w.length===0)throw new RangeError("Division by zero");if(0>T.__absoluteCompare(y,w))return y;var E=w.__unsignedDigit(0);if(w.length===1&&32767>=E){if(E===1)return T.__zero();var _=T.__absoluteModSmall(y,E);return _===0?T.__zero():T.__oneDigit(_,y.sign)}var b=T.__absoluteDivLarge(y,w,!1,!0);return b.sign=y.sign,b.__trim()}},{key:"add",value:function(h,y){var w=h.sign;return w===y.sign?T.__absoluteAdd(h,y,w):0<=T.__absoluteCompare(h,y)?T.__absoluteSub(h,y,w):T.__absoluteSub(y,h,!w)}},{key:"subtract",value:function(h,y){var w=h.sign;return w===y.sign?0<=T.__absoluteCompare(h,y)?T.__absoluteSub(h,y,w):T.__absoluteSub(y,h,!w):T.__absoluteAdd(h,y,w)}},{key:"leftShift",value:function(h,y){return y.length===0||h.length===0?h:y.sign?T.__rightShiftByAbsolute(h,y):T.__leftShiftByAbsolute(h,y)}},{key:"signedRightShift",value:function(h,y){return y.length===0||h.length===0?h:y.sign?T.__leftShiftByAbsolute(h,y):T.__rightShiftByAbsolute(h,y)}},{key:"unsignedRightShift",value:function(){throw new TypeError("BigInts have no unsigned right shift; use >> instead")}},{key:"lessThan",value:function(h,y){return 0>T.__compareToBigInt(h,y)}},{key:"lessThanOrEqual",value:function(h,y){return 0>=T.__compareToBigInt(h,y)}},{key:"greaterThan",value:function(h,y){return 0h)throw new RangeError("Invalid value: not (convertible to) a safe integer");if(h===0)return T.__zero();if(h>=T.__kMaxLengthBits)return y;var w=0|(h+29)/30;if(y.lengthh)throw new RangeError("Invalid value: not (convertible to) a safe integer");if(h===0)return T.__zero();if(y.sign){if(h>T.__kMaxLengthBits)throw new RangeError("BigInt too big");return T.__truncateAndSubFromPowerOfTwo(h,y,!1)}if(h>=T.__kMaxLengthBits)return y;var w=0|(h+29)/30;if(y.length>>E))return y}return T.__truncateToNBits(h,y)}},{key:"ADD",value:function(h,y){if(h=T.__toPrimitive(h),y=T.__toPrimitive(y),typeof h=="string")return typeof y!="string"&&(y=y.toString()),h+y;if(typeof y=="string")return h.toString()+y;if(h=T.__toNumeric(h),y=T.__toNumeric(y),T.__isBigInt(h)&&T.__isBigInt(y))return T.add(h,y);if(typeof h=="number"&&typeof y=="number")return h+y;throw new TypeError("Cannot mix BigInt and other types, use explicit conversions")}},{key:"LT",value:function(h,y){return T.__compare(h,y,0)}},{key:"LE",value:function(h,y){return T.__compare(h,y,1)}},{key:"GT",value:function(h,y){return T.__compare(h,y,2)}},{key:"GE",value:function(h,y){return T.__compare(h,y,3)}},{key:"EQ",value:function(h,y){for(;;){if(T.__isBigInt(h))return T.__isBigInt(y)?T.equal(h,y):T.EQ(y,h);if(typeof h=="number"){if(T.__isBigInt(y))return T.__equalToNumber(y,h);if(r(y)!=="object")return h==y;y=T.__toPrimitive(y)}else if(typeof h=="string"){if(T.__isBigInt(y))return h=T.__fromString(h),h!==null&&T.equal(h,y);if(r(y)!=="object")return h==y;y=T.__toPrimitive(y)}else if(typeof h=="boolean"){if(T.__isBigInt(y))return T.__equalToNumber(y,+h);if(r(y)!=="object")return h==y;y=T.__toPrimitive(y)}else if(r(h)==="symbol"){if(T.__isBigInt(y))return!1;if(r(y)!=="object")return h==y;y=T.__toPrimitive(y)}else if(r(h)==="object"){if(r(y)==="object"&&y.constructor!==T)return h==y;h=T.__toPrimitive(h)}else return h==y}}},{key:"NE",value:function(h,y){return!T.EQ(h,y)}},{key:"DataViewGetBigInt64",value:function(h,y){var w=2>>30),U.__setDigit(2,N>>>28),U.__trim()}},{key:"DataViewSetBigInt64",value:function(h,y,w){var E=3>>2,2y)_=-y-1;else{if(w===0)return-1;w--,E=h.__digit(w),_=29}var b=1<<_;if(!(E&b))return-1;if(b-=1,(E&b)!=0)return 1;for(;0>>20,E=w-1023,_=(0|E/30)+1,b=new T(_,0>h),C=1048575&T.__kBitConversionInts[1]|1048576,N=T.__kBitConversionInts[0],M=20,U=E%30,G=0;if(U>>Z,C=C<<32-Z|N>>>Z,N<<=32-Z}else if(U===M)G=32,y=C,C=N,N=0;else{var J=U-M;G=32-J,y=C<>>32-J,C=N<>>2,C=C<<30|N>>>2,N<<=30):y=0,b.__setDigit(H,y);return b.__trim()}},{key:"__isWhitespace",value:function(h){return 13>=h&&9<=h||(159>=h?h==32:131071>=h?h==160||h==5760:196607>=h?(h&=131071,10>=h||h==40||h==41||h==47||h==95||h==4096):h==65279)}},{key:"__fromString",value:function(h){var y=11073741824/N)return null;var U=N*C+M>>>T.__kBitsPerCharTableShift,G=new T(0|(U+29)/30,!1),Z=10>y?y:10,J=10>>0>>0>>T.__kBitsPerCharTableShift)/30;G.__inplaceMultiplyAdd(he,ie,Re)}while(!ce)}else{N>>=T.__kBitsPerCharTableShift;var H=[],X=[],te=!1;do{for(var ne,Q=0,re=0;;){if(ne=void 0,b-48>>>0>>0>>M-b)}if(_!==0){if(E>=h.length)throw new Error("implementation bug");h.__setDigit(E++,_)}for(;E>>1)+(85&E),E=(51&E>>>2)+(51&E),E=(15&E>>>4)+(15&E);var _=E,b=y-1,C=h.__digit(w-1),N=T.__clz30(C),M=0|(30*w-N+_-1)/_;if(h.sign&&M++,268435456>>ne,J=30-ne;J>=_;)U[G--]=T.__kConversionChars[Z&b],Z>>>=_,J-=_}var Q=(Z|C<>>_-J;Z!==0;)U[G--]=T.__kConversionChars[Z&b],Z>>>=_;if(h.sign&&(U[G--]="-"),G!==-1)throw new Error("implementation bug");return U.join("")}},{key:"__toStringGeneric",value:function(h,y,w){var E=h.length;if(E===0)return"";if(E===1){var _=h.__unsignedDigit(0).toString(y);return w===!1&&h.sign&&(_="-"+_),_}var b=30*E-T.__clz30(h.__digit(E-1)),C=T.__kMaxBitsPerChar[y],N=C-1,M=b*T.__kBitsPerCharTableMultiplier;M+=N-1,M=0|M/N;var U,G,Z=M+1>>1,J=T.exponentiate(T.__oneDigit(y,!1),T.__oneDigit(Z,!1)),H=J.__unsignedDigit(0);if(J.length===1&&32767>=H){U=new T(h.length,!1),U.__initializeDigits();for(var X,te=0,ne=2*h.length-1;0<=ne;ne--)X=te<<15|h.__halfDigit(ne),U.__setHalfDigit(ne,0|X/H),te=0|X%H;G=te.toString(y)}else{var Q=T.__absoluteDivLarge(h,J,!0,!0);U=Q.quotient;var re=Q.remainder.__trim();G=T.__toStringGeneric(re,y,!0)}U.__trim();for(var ce=T.__toStringGeneric(U,y,!0);G.lengthE?T.__absoluteLess(w):0}},{key:"__compareToNumber",value:function(h,y){if(T.__isOneDigitInt(y)){var w=h.sign,E=0>y;if(w!==E)return T.__unequalSign(w);if(h.length===0){if(E)throw new Error("implementation bug");return y===0?0:-1}if(1_?T.__absoluteGreater(w):b<_?T.__absoluteLess(w):0}return T.__compareToDouble(h,y)}},{key:"__compareToDouble",value:function(h,y){if(y!==y)return y;if(y===1/0)return-1;if(y===-1/0)return 1;var w=h.sign;if(w!==0>y)return T.__unequalSign(w);if(y===0)throw new Error("implementation bug: should be handled elsewhere");if(h.length===0)return-1;T.__kBitConversionDouble[0]=y;var E=2047&T.__kBitConversionInts[1]>>>20;if(E==2047)throw new Error("implementation bug: handled elsewhere");var _=E-1023;if(0>_)return T.__absoluteGreater(w);var b=h.length,C=h.__digit(b-1),N=T.__clz30(C),M=30*b-N,U=_+1;if(MU)return T.__absoluteGreater(w);var G=1048576|1048575&T.__kBitConversionInts[1],Z=T.__kBitConversionInts[0],J=20,H=29-N;if(H!==(0|(M-1)%30))throw new Error("implementation bug");var X,te=0;if(H>>ne,G=G<<32-ne|Z>>>ne,Z<<=32-ne}else if(H===J)te=32,X=G,G=Z,Z=0;else{var Q=H-J;te=32-Q,X=G<>>32-Q,G=Z<>>=0,X>>>=0,C>X)return T.__absoluteGreater(w);if(C>>2,G=G<<30|Z>>>2,Z<<=30):X=0;var ce=h.__unsignedDigit(re);if(ce>X)return T.__absoluteGreater(w);if(cey&&h.__unsignedDigit(0)===W(y):T.__compareToDouble(h,y)===0}},{key:"__comparisonResultToBool",value:function(h,y){return y===0?0>h:y===1?0>=h:y===2?0y;case 3:return h>=y}if(T.__isBigInt(h)&&typeof y=="string")return y=T.__fromString(y),y!==null&&T.__comparisonResultToBool(T.__compareToBigInt(h,y),w);if(typeof h=="string"&&T.__isBigInt(y))return h=T.__fromString(h),h!==null&&T.__comparisonResultToBool(T.__compareToBigInt(h,y),w);if(h=T.__toNumeric(h),y=T.__toNumeric(y),T.__isBigInt(h)){if(T.__isBigInt(y))return T.__comparisonResultToBool(T.__compareToBigInt(h,y),w);if(typeof y!="number")throw new Error("implementation bug");return T.__comparisonResultToBool(T.__compareToNumber(h,y),w)}if(typeof h!="number")throw new Error("implementation bug");if(T.__isBigInt(y))return T.__comparisonResultToBool(T.__compareToNumber(y,h),2^w);if(typeof y!="number")throw new Error("implementation bug");return w===0?hy:w===3?h>=y:void 0}},{key:"__absoluteAdd",value:function(h,y,w){if(h.length>>30,b.__setDigit(N,1073741823&_);for(;N>>30,b.__setDigit(N,1073741823&M)}return N>>30,_.__setDigit(C,1073741823&E);for(;C>>30,_.__setDigit(C,1073741823&N)}return _.__trim()}},{key:"__absoluteAddOne",value:function(h,y){var w=2>>30,w.__setDigit(C,1073741823&_);return b!==0&&w.__setDigitGrow(E,1),w}},{key:"__absoluteSubOne",value:function(h,y){var w=h.length;y=y||w;for(var E,_=new T(y,!1),b=1,C=0;C>>30,_.__setDigit(C,1073741823&E);if(b!==0)throw new Error("implementation bug");for(var N=w;NE?0:h.__unsignedDigit(E)>y.__unsignedDigit(E)?1:-1}},{key:"__multiplyAccumulate",value:function(h,y,w,E){if(y!==0){for(var _=32767&y,b=y>>>15,C=0,N=0,M=0;M>>15,H=T.__imul(Z,_),X=T.__imul(Z,b),te=T.__imul(J,_),ne=T.__imul(J,b);U+=N+H+C,C=U>>>30,U&=1073741823,U+=((32767&X)<<15)+((32767&te)<<15),C+=U>>>30,N=ne+(X>>>15)+(te>>>15),w.__setDigit(E,1073741823&U)}for(;C!==0||N!==0;E++){var Q=w.__digit(E);Q+=C+N,N=0,C=Q>>>30,w.__setDigit(E,1073741823&Q)}}}},{key:"__internalMultiplyAdd",value:function(h,y,w,E,_){for(var b=w,C=0,N=0;N>>15,y),Z=U+((32767&G)<<15)+C+b;b=Z>>>30,C=G>>>15,_.__setDigit(N,1073741823&Z)}if(_.length>E)for(_.__setDigit(E++,b+C);E<_.length;)_.__setDigit(E++,0);else if(b+C!==0)throw new Error("implementation bug")}},{key:"__absoluteDivSmall",value:function(h,y){var w=2>>0,C=0|b/y;E=0|b%y,b=(E<<15|h.__halfDigit(_-1))>>>0;var N=0|b/y;E=0|b%y,w.__setDigit(_>>>1,C<<15|N)}return w}},{key:"__absoluteModSmall",value:function(h,y){for(var w,E=0,_=2*h.length-1;0<=_;_--)w=(E<<15|h.__halfDigit(_))>>>0,E=0|w%y;return E}},{key:"__absoluteDivLarge",value:function(h,y,w,E){var _=y.__halfDigitLength(),b=y.length,C=h.__halfDigitLength()-_,N=null;w&&(N=new T(C+2>>>1,!1),N.__initializeDigits());var M=new T(_+2>>>1,!1);M.__initializeDigits();var U=T.__clz15(y.__halfDigit(_-1));0>>0;X=0|ne/Z;for(var Q=0|ne%Z,re=y.__halfDigit(_-2),ce=G.__halfDigit(H+_-2);T.__imul(X,re)>>>0>(Q<<16|ce)>>>0&&(X--,Q+=Z,!(32767>>1,J|X))}if(E)return G.__inplaceRightShift(U),w?{quotient:N,remainder:G}:G;if(w)return N;throw new Error("unreachable")}},{key:"__clz15",value:function(h){return T.__clz30(h)-15}},{key:"__specialLeftShift",value:function(h,y,w){var E=h.length,_=new T(E+w,!1);if(y===0){for(var b=0;b>>30-y;return 0w)throw new RangeError("BigInt too big");var E=0|w/30,_=w%30,b=h.length,C=_!==0&&h.__digit(b-1)>>>30-_!=0,N=b+E+(C?1:0),M=new T(N,h.sign);if(_===0){for(var U=0;U>>30-_;if(C)M.__setDigit(b+E,G);else if(G!==0)throw new Error("implementation bug")}return M.__trim()}},{key:"__rightShiftByAbsolute",value:function(h,y){var w=h.length,E=h.sign,_=T.__toShiftAmount(y);if(0>_)return T.__rightShiftByMaximum(E);var b=0|_/30,C=_%30,N=w-b;if(0>=N)return T.__rightShiftByMaximum(E);var M=!1;if(E){if(h.__digit(b)&(1<>>C,te=w-b-1,ne=0;ne>>C;Z.__setDigit(te,X)}return M&&(Z=T.__absoluteAddOne(Z,!0,Z)),Z.__trim()}},{key:"__rightShiftByMaximum",value:function(h){return h?T.__oneDigit(1,!0):T.__zero()}},{key:"__toShiftAmount",value:function(h){if(1T.__kMaxLengthBits?-1:y}},{key:"__toPrimitive",value:function(h){var y=1>>N}return E.__setDigit(_,C),E.__trim()}},{key:"__truncateAndSubFromPowerOfTwo",value:function(h,y,w){for(var E=Math.min,_,b=0|(h+29)/30,C=new T(b,w),N=0,M=b-1,U=0,G=E(M,y.length);N>>30,C.__setDigit(N,1073741823&_);for(;N>>X;var te=1<<32-X;Z=te-J-U,Z&=te-1}return C.__setDigit(M,Z),C.__trim()}},{key:"__digitPow",value:function(h,y){for(var w=1;0>>=1,h*=h;return w}},{key:"__isOneDigitInt",value:function(h){return(1073741823&h)===h}}]),T}(p(Array));return F.__kMaxLength=33554432,F.__kMaxLengthBits=F.__kMaxLength<<5,F.__kMaxBitsPerChar=[0,0,32,51,64,75,83,90,96,102,107,111,115,119,122,126,128,131,134,136,139,141,143,145,147,149,151,153,154,156,158,159,160,162,163,165,166],F.__kBitsPerCharTableShift=5,F.__kBitsPerCharTableMultiplier=1<>>0)/W)},F.__imul=t||function(K,W){return 0|K*W},F})});var W6=V(Wr=>{"use strict";f();Object.defineProperty(Wr,"__esModule",{value:!0});Wr.regexpCode=Wr.getEsmExportName=Wr.getProperty=Wr.safeStringify=Wr.stringify=Wr.strConcat=Wr.addCodeArg=Wr.str=Wr._=Wr.nil=Wr._Code=Wr.Name=Wr.IDENTIFIER=Wr._CodeOrName=void 0;var F6=class{};Wr._CodeOrName=F6;Wr.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var fv=class extends F6{constructor(e){if(super(),!Wr.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};Wr.Name=fv;var Ld=class extends F6{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((r,n)=>(n instanceof fv&&(r[n.str]=(r[n.str]||0)+1),r),{})}};Wr._Code=Ld;Wr.nil=new Ld("");function yle(t,...e){let r=[t[0]],n=0;for(;n{"use strict";f();Object.defineProperty(Oa,"__esModule",{value:!0});Oa.ValueScope=Oa.ValueScopeName=Oa.Scope=Oa.varKinds=Oa.UsedValueState=void 0;var ac=W6(),FN=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},zN;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(zN=Oa.UsedValueState||(Oa.UsedValueState={}));Oa.varKinds={const:new ac.Name("const"),let:new ac.Name("let"),var:new ac.Name("var")};var OP=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof ac.Name?e:this.name(e)}name(e){return new ac.Name(this._newName(e))}_newName(e){let r=this._names[e]||this._nameGroup(e);return`${e}${r.index++}`}_nameGroup(e){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};Oa.Scope=OP;var CP=class extends ac.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=(0,ac._)`.${new ac.Name(r)}[${n}]`}};Oa.ValueScopeName=CP;var Wqe=(0,ac._)`\n`,WN=class extends OP{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?Wqe:ac.nil}}get(){return this._scope}name(e){return new CP(e,this._newName(e))}value(e,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let i=this.toName(e),{prefix:o}=i,s=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[o];if(a){let c=a.get(s);if(c)return c}else a=this._values[o]=new Map;a.set(s,i);let d=this._scope[o]||(this._scope[o]=[]),u=d.length;return d[u]=r.ref,i.setValue(r,{property:o,itemIndex:u}),i}getValue(e,r){let n=this._values[e];if(n)return n.get(r)}scopeRefs(e,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,ac._)`${e}${n.scopePath}`})}scopeCode(e=this._values,r,n){return this._reduceValues(e,i=>{if(i.value===void 0)throw new Error(`CodeGen: name "${i}" has no value`);return i.value.code},r,n)}_reduceValues(e,r,n={},i){let o=ac.nil;for(let s in e){let a=e[s];if(!a)continue;let d=n[s]=n[s]||new Map;a.forEach(u=>{if(d.has(u))return;d.set(u,zN.Started);let c=r(u);if(c){let l=this.opts.es5?Oa.varKinds.var:Oa.varKinds.const;o=(0,ac._)`${o}${l} ${u} = ${c};${this.opts._n}`}else if(c=i?.(u))o=(0,ac._)`${o}${c}${this.opts._n}`;else throw new FN(u);d.set(u,zN.Completed)})}return o}};Oa.ValueScope=WN});var rr=V(br=>{"use strict";f();Object.defineProperty(br,"__esModule",{value:!0});br.or=br.and=br.not=br.CodeGen=br.operators=br.varKinds=br.ValueScopeName=br.ValueScope=br.Scope=br.Name=br.regexpCode=br.stringify=br.getProperty=br.nil=br.strConcat=br.str=br._=void 0;var qr=W6(),Ju=HN(),dy=W6();Object.defineProperty(br,"_",{enumerable:!0,get:function(){return dy._}});Object.defineProperty(br,"str",{enumerable:!0,get:function(){return dy.str}});Object.defineProperty(br,"strConcat",{enumerable:!0,get:function(){return dy.strConcat}});Object.defineProperty(br,"nil",{enumerable:!0,get:function(){return dy.nil}});Object.defineProperty(br,"getProperty",{enumerable:!0,get:function(){return dy.getProperty}});Object.defineProperty(br,"stringify",{enumerable:!0,get:function(){return dy.stringify}});Object.defineProperty(br,"regexpCode",{enumerable:!0,get:function(){return dy.regexpCode}});Object.defineProperty(br,"Name",{enumerable:!0,get:function(){return dy.Name}});var UP=HN();Object.defineProperty(br,"Scope",{enumerable:!0,get:function(){return UP.Scope}});Object.defineProperty(br,"ValueScope",{enumerable:!0,get:function(){return UP.ValueScope}});Object.defineProperty(br,"ValueScopeName",{enumerable:!0,get:function(){return UP.ValueScopeName}});Object.defineProperty(br,"varKinds",{enumerable:!0,get:function(){return UP.varKinds}});br.operators={GT:new qr._Code(">"),GTE:new qr._Code(">="),LT:new qr._Code("<"),LTE:new qr._Code("<="),EQ:new qr._Code("==="),NEQ:new qr._Code("!=="),NOT:new qr._Code("!"),OR:new qr._Code("||"),AND:new qr._Code("&&"),ADD:new qr._Code("+")};var Vh=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},VN=class extends Vh{constructor(e,r,n){super(),this.varKind=e,this.name=r,this.rhs=n}render({es5:e,_n:r}){let n=e?Ju.varKinds.var:this.varKind,i=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${i};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=s2(this.rhs,e,r)),this}get names(){return this.rhs instanceof qr._CodeOrName?this.rhs.names:{}}},$P=class extends Vh{constructor(e,r,n){super(),this.lhs=e,this.rhs=r,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof qr.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=s2(this.rhs,e,r),this}get names(){let e=this.lhs instanceof qr.Name?{}:{...this.lhs.names};return NP(e,this.rhs)}},GN=class extends $P{constructor(e,r,n,i){super(e,n,i),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},JN=class extends Vh{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},ZN=class extends Vh{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},YN=class extends Vh{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},XN=class extends Vh{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,r){return this.code=s2(this.code,e,r),this}get names(){return this.code instanceof qr._CodeOrName?this.code.names:{}}},H6=class extends Vh{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((r,n)=>r+n.render(e),"")}optimizeNodes(){let{nodes:e}=this,r=e.length;for(;r--;){let n=e[r].optimizeNodes();Array.isArray(n)?e.splice(r,1,...n):n?e[r]=n:e.splice(r,1)}return e.length>0?this:void 0}optimizeNames(e,r){let{nodes:n}=this,i=n.length;for(;i--;){let o=n[i];o.optimizeNames(e,r)||(Hqe(e,o.names),n.splice(i,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>mv(e,r.names),{})}},Gh=class extends H6{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},QN=class extends H6{},o2=class extends Gh{};o2.kind="else";var hv=class t extends Gh{constructor(e,r){super(r),this.condition=e}render(e){let r=`if(${this.condition})`+super.render(e);return this.else&&(r+="else "+this.else.render(e)),r}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new o2(n):n}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(vle(e),r instanceof t?[r]:r.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(e,r),!!(super.optimizeNames(e,r)||this.else))return this.condition=s2(this.condition,e,r),this}get names(){let e=super.names;return NP(e,this.condition),this.else&&mv(e,this.else.names),e}};hv.kind="if";var pv=class extends Gh{};pv.kind="for";var eU=class extends pv{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iteration=s2(this.iteration,e,r),this}get names(){return mv(super.names,this.iteration.names)}},tU=class extends pv{constructor(e,r,n,i){super(),this.varKind=e,this.name=r,this.from=n,this.to=i}render(e){let r=e.es5?Ju.varKinds.var:this.varKind,{name:n,from:i,to:o}=this;return`for(${r} ${n}=${i}; ${n}<${o}; ${n}++)`+super.render(e)}get names(){let e=NP(super.names,this.from);return NP(e,this.to)}},jP=class extends pv{constructor(e,r,n,i){super(),this.loop=e,this.varKind=r,this.name=n,this.iterable=i}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iterable=s2(this.iterable,e,r),this}get names(){return mv(super.names,this.iterable.names)}},V6=class extends Gh{constructor(e,r,n){super(),this.name=e,this.args=r,this.async=n}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};V6.kind="func";var G6=class extends H6{render(e){return"return "+super.render(e)}};G6.kind="return";var rU=class extends Gh{render(e){let r="try"+super.render(e);return this.catch&&(r+=this.catch.render(e)),this.finally&&(r+=this.finally.render(e)),r}optimizeNodes(){var e,r;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(e,r){var n,i;return super.optimizeNames(e,r),(n=this.catch)===null||n===void 0||n.optimizeNames(e,r),(i=this.finally)===null||i===void 0||i.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&mv(e,this.catch.names),this.finally&&mv(e,this.finally.names),e}},J6=class extends Gh{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};J6.kind="catch";var Z6=class extends Gh{render(e){return"finally"+super.render(e)}};Z6.kind="finally";var nU=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?` -`:""},this._extScope=e,this._scope=new Ju.Scope({parent:e}),this._nodes=[new QN]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,r){let n=this._extScope.value(e,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,r){return this._extScope.getValue(e,r)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,r,n,i){let o=this._scope.toName(r);return n!==void 0&&i&&(this._constants[o.str]=n),this._leafNode(new VN(e,o,n)),o}const(e,r,n){return this._def(Ju.varKinds.const,e,r,n)}let(e,r,n){return this._def(Ju.varKinds.let,e,r,n)}var(e,r,n){return this._def(Ju.varKinds.var,e,r,n)}assign(e,r,n){return this._leafNode(new $P(e,r,n))}add(e,r){return this._leafNode(new GN(e,br.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==qr.nil&&this._leafNode(new XN(e)),this}object(...e){let r=["{"];for(let[n,i]of e)r.length>1&&r.push(","),r.push(n),(n!==i||this.opts.es5)&&(r.push(":"),(0,qr.addCodeArg)(r,i));return r.push("}"),new qr._Code(r)}if(e,r,n){if(this._blockNode(new hv(e)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new hv(e))}else(){return this._elseNode(new o2)}endIf(){return this._endBlockNode(hv,o2)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new eU(e),r)}forRange(e,r,n,i,o=this.opts.es5?Ju.varKinds.var:Ju.varKinds.let){let s=this._scope.toName(e);return this._for(new tU(o,s,r,n),()=>i(s))}forOf(e,r,n,i=Ju.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let s=r instanceof qr.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,qr._)`${s}.length`,a=>{this.var(o,(0,qr._)`${s}[${a}]`),n(o)})}return this._for(new jP("of",i,o,r),()=>n(o))}forIn(e,r,n,i=this.opts.es5?Ju.varKinds.var:Ju.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,qr._)`Object.keys(${r})`,n);let o=this._scope.toName(e);return this._for(new jP("in",i,o,r),()=>n(o))}endFor(){return this._endBlockNode(pv)}label(e){return this._leafNode(new JN(e))}break(e){return this._leafNode(new ZN(e))}return(e){let r=new G6;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(G6)}try(e,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let i=new rU;if(this._blockNode(i),this.code(e),r){let o=this.name("e");this._currNode=i.catch=new J6(o),r(o)}return n&&(this._currNode=i.finally=new Z6,this.code(n)),this._endBlockNode(J6,Z6)}throw(e){return this._leafNode(new YN(e))}block(e,r){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(r),this}endBlock(e){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||e!==void 0&&n!==e)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=r,this}func(e,r=qr.nil,n,i){return this._blockNode(new V6(e,r,n)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(V6)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,r){let n=this._currNode;if(n instanceof e||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${e.kind}/${r.kind}`:e.kind}"`)}_elseNode(e){let r=this._currNode;if(!(r instanceof hv))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let r=this._nodes;r[r.length-1]=e}};br.CodeGen=nU;function mv(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function NP(t,e){return e instanceof qr._CodeOrName?mv(t,e.names):t}function s2(t,e,r){if(t instanceof qr.Name)return n(t);if(!i(t))return t;return new qr._Code(t._items.reduce((o,s)=>(s instanceof qr.Name&&(s=n(s)),s instanceof qr._Code?o.push(...s._items):o.push(s),o),[]));function n(o){let s=r[o.str];return s===void 0||e[o.str]!==1?o:(delete e[o.str],s)}function i(o){return o instanceof qr._Code&&o._items.some(s=>s instanceof qr.Name&&e[s.str]===1&&r[s.str]!==void 0)}}function Hqe(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function vle(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,qr._)`!${iU(t)}`}br.not=vle;var Vqe=ble(br.operators.AND);function Gqe(...t){return t.reduce(Vqe)}br.and=Gqe;var Jqe=ble(br.operators.OR);function Zqe(...t){return t.reduce(Jqe)}br.or=Zqe;function ble(t){return(e,r)=>e===qr.nil?r:r===qr.nil?e:(0,qr._)`${iU(e)} ${t} ${iU(r)}`}function iU(t){return t instanceof qr.Name?t:(0,qr._)`(${t})`}});var Rr=V(wr=>{"use strict";f();Object.defineProperty(wr,"__esModule",{value:!0});wr.checkStrictMode=wr.getErrorPath=wr.Type=wr.useFunc=wr.setEvaluated=wr.evaluatedPropsToName=wr.mergeEvaluated=wr.eachItem=wr.unescapeJsonPointer=wr.escapeJsonPointer=wr.escapeFragment=wr.unescapeFragment=wr.schemaRefOrVal=wr.schemaHasRulesButRef=wr.schemaHasRules=wr.checkUnknownRules=wr.alwaysValidSchema=wr.toHash=void 0;var kn=rr(),Yqe=W6();function Xqe(t){let e={};for(let r of t)e[r]=!0;return e}wr.toHash=Xqe;function Qqe(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(xle(t,e),!Ele(e,t.self.RULES.all))}wr.alwaysValidSchema=Qqe;function xle(t,e=t.schema){let{opts:r,self:n}=t;if(!r.strictSchema||typeof e=="boolean")return;let i=n.RULES.keywords;for(let o in e)i[o]||Ple(t,`unknown keyword: "${o}"`)}wr.checkUnknownRules=xle;function Ele(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}wr.schemaHasRules=Ele;function eLe(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}wr.schemaHasRulesButRef=eLe;function tLe({topSchemaRef:t,schemaPath:e},r,n,i){if(!i){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,kn._)`${r}`}return(0,kn._)`${t}${e}${(0,kn.getProperty)(n)}`}wr.schemaRefOrVal=tLe;function rLe(t){return Sle(decodeURIComponent(t))}wr.unescapeFragment=rLe;function nLe(t){return encodeURIComponent(oU(t))}wr.escapeFragment=nLe;function oU(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}wr.escapeJsonPointer=oU;function Sle(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}wr.unescapeJsonPointer=Sle;function iLe(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}wr.eachItem=iLe;function wle({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:n}){return(i,o,s,a)=>{let d=s===void 0?o:s instanceof kn.Name?(o instanceof kn.Name?t(i,o,s):e(i,o,s),s):o instanceof kn.Name?(e(i,s,o),o):r(o,s);return a===kn.Name&&!(d instanceof kn.Name)?n(i,d):d}}wr.mergeEvaluated={props:wle({mergeNames:(t,e,r)=>t.if((0,kn._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,kn._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,kn._)`${r} || {}`).code((0,kn._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,kn._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,kn._)`${r} || {}`),sU(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:Ale}),items:wle({mergeNames:(t,e,r)=>t.if((0,kn._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,kn._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,kn._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,kn._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function Ale(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,kn._)`{}`);return e!==void 0&&sU(t,r,e),r}wr.evaluatedPropsToName=Ale;function sU(t,e,r){Object.keys(r).forEach(n=>t.assign((0,kn._)`${e}${(0,kn.getProperty)(n)}`,!0))}wr.setEvaluated=sU;var _le={};function oLe(t,e){return t.scopeValue("func",{ref:e,code:_le[e.code]||(_le[e.code]=new Yqe._Code(e.code))})}wr.useFunc=oLe;var Tle;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(Tle=wr.Type||(wr.Type={}));function sLe(t,e,r){if(t instanceof kn.Name){let n=e===Tle.Num;return r?n?(0,kn._)`"[" + ${t} + "]"`:(0,kn._)`"['" + ${t} + "']"`:n?(0,kn._)`"/" + ${t}`:(0,kn._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,kn.getProperty)(t).toString():"/"+oU(t)}wr.getErrorPath=sLe;function Ple(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}wr.checkStrictMode=Ple});var Kd=V(aU=>{"use strict";f();Object.defineProperty(aU,"__esModule",{value:!0});var oa=rr(),aLe={data:new oa.Name("data"),valCxt:new oa.Name("valCxt"),instancePath:new oa.Name("instancePath"),parentData:new oa.Name("parentData"),parentDataProperty:new oa.Name("parentDataProperty"),rootData:new oa.Name("rootData"),dynamicAnchors:new oa.Name("dynamicAnchors"),vErrors:new oa.Name("vErrors"),errors:new oa.Name("errors"),this:new oa.Name("this"),self:new oa.Name("self"),scope:new oa.Name("scope"),json:new oa.Name("json"),jsonPos:new oa.Name("jsonPos"),jsonLen:new oa.Name("jsonLen"),jsonPart:new oa.Name("jsonPart")};aU.default=aLe});var Y6=V(sa=>{"use strict";f();Object.defineProperty(sa,"__esModule",{value:!0});sa.extendErrors=sa.resetErrorsCount=sa.reportExtraError=sa.reportError=sa.keyword$DataError=sa.keywordError=void 0;var Kr=rr(),qP=Rr(),Ca=Kd();sa.keywordError={message:({keyword:t})=>(0,Kr.str)`must pass "${t}" keyword validation`};sa.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,Kr.str)`"${t}" keyword must be ${e} ($data)`:(0,Kr.str)`"${t}" keyword is invalid ($data)`};function cLe(t,e=sa.keywordError,r,n){let{it:i}=t,{gen:o,compositeRule:s,allErrors:a}=i,d=Rle(t,e,r);n??(s||a)?Ile(o,d):kle(i,(0,Kr._)`[${d}]`)}sa.reportError=cLe;function dLe(t,e=sa.keywordError,r){let{it:n}=t,{gen:i,compositeRule:o,allErrors:s}=n,a=Rle(t,e,r);Ile(i,a),o||s||kle(n,Ca.default.vErrors)}sa.reportExtraError=dLe;function uLe(t,e){t.assign(Ca.default.errors,e),t.if((0,Kr._)`${Ca.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,Kr._)`${Ca.default.vErrors}.length`,e),()=>t.assign(Ca.default.vErrors,null)))}sa.resetErrorsCount=uLe;function lLe({gen:t,keyword:e,schemaValue:r,data:n,errsCount:i,it:o}){if(i===void 0)throw new Error("ajv implementation error");let s=t.name("err");t.forRange("i",i,Ca.default.errors,a=>{t.const(s,(0,Kr._)`${Ca.default.vErrors}[${a}]`),t.if((0,Kr._)`${s}.instancePath === undefined`,()=>t.assign((0,Kr._)`${s}.instancePath`,(0,Kr.strConcat)(Ca.default.instancePath,o.errorPath))),t.assign((0,Kr._)`${s}.schemaPath`,(0,Kr.str)`${o.errSchemaPath}/${e}`),o.opts.verbose&&(t.assign((0,Kr._)`${s}.schema`,r),t.assign((0,Kr._)`${s}.data`,n))})}sa.extendErrors=lLe;function Ile(t,e){let r=t.const("err",e);t.if((0,Kr._)`${Ca.default.vErrors} === null`,()=>t.assign(Ca.default.vErrors,(0,Kr._)`[${r}]`),(0,Kr._)`${Ca.default.vErrors}.push(${r})`),t.code((0,Kr._)`${Ca.default.errors}++`)}function kle(t,e){let{gen:r,validateName:n,schemaEnv:i}=t;i.$async?r.throw((0,Kr._)`new ${t.ValidationError}(${e})`):(r.assign((0,Kr._)`${n}.errors`,e),r.return(!1))}var yv={keyword:new Kr.Name("keyword"),schemaPath:new Kr.Name("schemaPath"),params:new Kr.Name("params"),propertyName:new Kr.Name("propertyName"),message:new Kr.Name("message"),schema:new Kr.Name("schema"),parentSchema:new Kr.Name("parentSchema")};function Rle(t,e,r){let{createErrors:n}=t.it;return n===!1?(0,Kr._)`{}`:fLe(t,e,r)}function fLe(t,e,r={}){let{gen:n,it:i}=t,o=[hLe(i,r),pLe(t,r)];return mLe(t,e,o),n.object(...o)}function hLe({errorPath:t},{instancePath:e}){let r=e?(0,Kr.str)`${t}${(0,qP.getErrorPath)(e,qP.Type.Str)}`:t;return[Ca.default.instancePath,(0,Kr.strConcat)(Ca.default.instancePath,r)]}function pLe({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:n}){let i=n?e:(0,Kr.str)`${e}/${t}`;return r&&(i=(0,Kr.str)`${i}${(0,qP.getErrorPath)(r,qP.Type.Str)}`),[yv.schemaPath,i]}function mLe(t,{params:e,message:r},n){let{keyword:i,data:o,schemaValue:s,it:a}=t,{opts:d,propertyName:u,topSchemaRef:c,schemaPath:l}=a;n.push([yv.keyword,i],[yv.params,typeof e=="function"?e(t):e||(0,Kr._)`{}`]),d.messages&&n.push([yv.message,typeof r=="function"?r(t):r]),d.verbose&&n.push([yv.schema,s],[yv.parentSchema,(0,Kr._)`${c}${l}`],[Ca.default.data,o]),u&&n.push([yv.propertyName,u])}});var Ble=V(a2=>{"use strict";f();Object.defineProperty(a2,"__esModule",{value:!0});a2.boolOrEmptySchema=a2.topBoolOrEmptySchema=void 0;var yLe=Y6(),gLe=rr(),vLe=Kd(),bLe={message:"boolean schema is false"};function wLe(t){let{gen:e,schema:r,validateName:n}=t;r===!1?Dle(t,!1):typeof r=="object"&&r.$async===!0?e.return(vLe.default.data):(e.assign((0,gLe._)`${n}.errors`,null),e.return(!0))}a2.topBoolOrEmptySchema=wLe;function _Le(t,e){let{gen:r,schema:n}=t;n===!1?(r.var(e,!1),Dle(t)):r.var(e,!0)}a2.boolOrEmptySchema=_Le;function Dle(t,e){let{gen:r,data:n}=t,i={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,yLe.reportError)(i,bLe,void 0,e)}});var cU=V(c2=>{"use strict";f();Object.defineProperty(c2,"__esModule",{value:!0});c2.getRules=c2.isJSONType=void 0;var xLe=["string","number","integer","boolean","null","object","array"],ELe=new Set(xLe);function SLe(t){return typeof t=="string"&&ELe.has(t)}c2.isJSONType=SLe;function ALe(){let t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}c2.getRules=ALe});var dU=V(uy=>{"use strict";f();Object.defineProperty(uy,"__esModule",{value:!0});uy.shouldUseRule=uy.shouldUseGroup=uy.schemaHasRulesForType=void 0;function TLe({schema:t,self:e},r){let n=e.RULES.types[r];return n&&n!==!0&&Mle(t,n)}uy.schemaHasRulesForType=TLe;function Mle(t,e){return e.rules.some(r=>Ole(t,r))}uy.shouldUseGroup=Mle;function Ole(t,e){var r;return t[e.keyword]!==void 0||((r=e.definition.implements)===null||r===void 0?void 0:r.some(n=>t[n]!==void 0))}uy.shouldUseRule=Ole});var Q6=V(xs=>{"use strict";f();Object.defineProperty(xs,"__esModule",{value:!0});xs.reportTypeError=xs.checkDataTypes=xs.checkDataType=xs.coerceAndCheckDataType=xs.getJSONTypes=xs.getSchemaTypes=xs.DataType=void 0;var PLe=cU(),ILe=dU(),kLe=Y6(),nr=rr(),Cle=Rr(),X6;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(X6=xs.DataType||(xs.DataType={}));function RLe(t){let e=$le(t.type);if(e.includes("null")){if(t.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&t.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');t.nullable===!0&&e.push("null")}return e}xs.getSchemaTypes=RLe;function $le(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(PLe.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}xs.getJSONTypes=$le;function DLe(t,e){let{gen:r,data:n,opts:i}=t,o=BLe(e,i.coerceTypes),s=e.length>0&&!(o.length===0&&e.length===1&&(0,ILe.schemaHasRulesForType)(t,e[0]));if(s){let a=lU(e,n,i.strictNumbers,X6.Wrong);r.if(a,()=>{o.length?MLe(t,e,o):fU(t)})}return s}xs.coerceAndCheckDataType=DLe;var jle=new Set(["string","number","integer","boolean","null"]);function BLe(t,e){return e?t.filter(r=>jle.has(r)||e==="array"&&r==="array"):[]}function MLe(t,e,r){let{gen:n,data:i,opts:o}=t,s=n.let("dataType",(0,nr._)`typeof ${i}`),a=n.let("coerced",(0,nr._)`undefined`);o.coerceTypes==="array"&&n.if((0,nr._)`${s} == 'object' && Array.isArray(${i}) && ${i}.length == 1`,()=>n.assign(i,(0,nr._)`${i}[0]`).assign(s,(0,nr._)`typeof ${i}`).if(lU(e,i,o.strictNumbers),()=>n.assign(a,i))),n.if((0,nr._)`${a} !== undefined`);for(let u of r)(jle.has(u)||u==="array"&&o.coerceTypes==="array")&&d(u);n.else(),fU(t),n.endIf(),n.if((0,nr._)`${a} !== undefined`,()=>{n.assign(i,a),OLe(t,a)});function d(u){switch(u){case"string":n.elseIf((0,nr._)`${s} == "number" || ${s} == "boolean"`).assign(a,(0,nr._)`"" + ${i}`).elseIf((0,nr._)`${i} === null`).assign(a,(0,nr._)`""`);return;case"number":n.elseIf((0,nr._)`${s} == "boolean" || ${i} === null - || (${s} == "string" && ${i} && ${i} == +${i})`).assign(a,(0,nr._)`+${i}`);return;case"integer":n.elseIf((0,nr._)`${s} === "boolean" || ${i} === null - || (${s} === "string" && ${i} && ${i} == +${i} && !(${i} % 1))`).assign(a,(0,nr._)`+${i}`);return;case"boolean":n.elseIf((0,nr._)`${i} === "false" || ${i} === 0 || ${i} === null`).assign(a,!1).elseIf((0,nr._)`${i} === "true" || ${i} === 1`).assign(a,!0);return;case"null":n.elseIf((0,nr._)`${i} === "" || ${i} === 0 || ${i} === false`),n.assign(a,null);return;case"array":n.elseIf((0,nr._)`${s} === "string" || ${s} === "number" - || ${s} === "boolean" || ${i} === null`).assign(a,(0,nr._)`[${i}]`)}}}function OLe({gen:t,parentData:e,parentDataProperty:r},n){t.if((0,nr._)`${e} !== undefined`,()=>t.assign((0,nr._)`${e}[${r}]`,n))}function uU(t,e,r,n=X6.Correct){let i=n===X6.Correct?nr.operators.EQ:nr.operators.NEQ,o;switch(t){case"null":return(0,nr._)`${e} ${i} null`;case"array":o=(0,nr._)`Array.isArray(${e})`;break;case"object":o=(0,nr._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":o=s((0,nr._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":o=s();break;default:return(0,nr._)`typeof ${e} ${i} ${t}`}return n===X6.Correct?o:(0,nr.not)(o);function s(a=nr.nil){return(0,nr.and)((0,nr._)`typeof ${e} == "number"`,a,r?(0,nr._)`isFinite(${e})`:nr.nil)}}xs.checkDataType=uU;function lU(t,e,r,n){if(t.length===1)return uU(t[0],e,r,n);let i,o=(0,Cle.toHash)(t);if(o.array&&o.object){let s=(0,nr._)`typeof ${e} != "object"`;i=o.null?s:(0,nr._)`!${e} || ${s}`,delete o.null,delete o.array,delete o.object}else i=nr.nil;o.number&&delete o.integer;for(let s in o)i=(0,nr.and)(i,uU(s,e,r,n));return i}xs.checkDataTypes=lU;var CLe={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,nr._)`{type: ${t}}`:(0,nr._)`{type: ${e}}`};function fU(t){let e=$Le(t);(0,kLe.reportError)(e,CLe)}xs.reportTypeError=fU;function $Le(t){let{gen:e,data:r,schema:n}=t,i=(0,Cle.schemaRefOrVal)(t,n,"type");return{gen:e,keyword:"type",data:r,schema:n.type,schemaCode:i,schemaValue:i,parentSchema:n,params:{},it:t}}});var Ule=V(LP=>{"use strict";f();Object.defineProperty(LP,"__esModule",{value:!0});LP.assignDefaults=void 0;var d2=rr(),jLe=Rr();function NLe(t,e){let{properties:r,items:n}=t.schema;if(e==="object"&&r)for(let i in r)Nle(t,i,r[i].default);else e==="array"&&Array.isArray(n)&&n.forEach((i,o)=>Nle(t,o,i.default))}LP.assignDefaults=NLe;function Nle(t,e,r){let{gen:n,compositeRule:i,data:o,opts:s}=t;if(r===void 0)return;let a=(0,d2._)`${o}${(0,d2.getProperty)(e)}`;if(i){(0,jLe.checkStrictMode)(t,`default is ignored for: ${a}`);return}let d=(0,d2._)`${a} === undefined`;s.useDefaults==="empty"&&(d=(0,d2._)`${d} || ${a} === null || ${a} === ""`),n.if(d,(0,d2._)`${a} = ${(0,d2.stringify)(r)}`)}});var Fd=V(wn=>{"use strict";f();Object.defineProperty(wn,"__esModule",{value:!0});wn.validateUnion=wn.validateArray=wn.usePattern=wn.callValidateCode=wn.schemaProperties=wn.allSchemaProperties=wn.noPropertyInData=wn.propertyInData=wn.isOwnProperty=wn.hasPropFunc=wn.reportMissingProp=wn.checkMissingProp=wn.checkReportMissingProp=void 0;var Fn=rr(),hU=Rr(),ly=Kd(),ULe=Rr();function qLe(t,e){let{gen:r,data:n,it:i}=t;r.if(mU(r,n,e,i.opts.ownProperties),()=>{t.setParams({missingProperty:(0,Fn._)`${e}`},!0),t.error()})}wn.checkReportMissingProp=qLe;function LLe({gen:t,data:e,it:{opts:r}},n,i){return(0,Fn.or)(...n.map(o=>(0,Fn.and)(mU(t,e,o,r.ownProperties),(0,Fn._)`${i} = ${o}`)))}wn.checkMissingProp=LLe;function KLe(t,e){t.setParams({missingProperty:e},!0),t.error()}wn.reportMissingProp=KLe;function qle(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Fn._)`Object.prototype.hasOwnProperty`})}wn.hasPropFunc=qle;function pU(t,e,r){return(0,Fn._)`${qle(t)}.call(${e}, ${r})`}wn.isOwnProperty=pU;function FLe(t,e,r,n){let i=(0,Fn._)`${e}${(0,Fn.getProperty)(r)} !== undefined`;return n?(0,Fn._)`${i} && ${pU(t,e,r)}`:i}wn.propertyInData=FLe;function mU(t,e,r,n){let i=(0,Fn._)`${e}${(0,Fn.getProperty)(r)} === undefined`;return n?(0,Fn.or)(i,(0,Fn.not)(pU(t,e,r))):i}wn.noPropertyInData=mU;function Lle(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}wn.allSchemaProperties=Lle;function zLe(t,e){return Lle(e).filter(r=>!(0,hU.alwaysValidSchema)(t,e[r]))}wn.schemaProperties=zLe;function WLe({schemaCode:t,data:e,it:{gen:r,topSchemaRef:n,schemaPath:i,errorPath:o},it:s},a,d,u){let c=u?(0,Fn._)`${t}, ${e}, ${n}${i}`:e,l=[[ly.default.instancePath,(0,Fn.strConcat)(ly.default.instancePath,o)],[ly.default.parentData,s.parentData],[ly.default.parentDataProperty,s.parentDataProperty],[ly.default.rootData,ly.default.rootData]];s.opts.dynamicRef&&l.push([ly.default.dynamicAnchors,ly.default.dynamicAnchors]);let p=(0,Fn._)`${c}, ${r.object(...l)}`;return d!==Fn.nil?(0,Fn._)`${a}.call(${d}, ${p})`:(0,Fn._)`${a}(${p})`}wn.callValidateCode=WLe;var HLe=(0,Fn._)`new RegExp`;function VLe({gen:t,it:{opts:e}},r){let n=e.unicodeRegExp?"u":"",{regExp:i}=e.code,o=i(r,n);return t.scopeValue("pattern",{key:o.toString(),ref:o,code:(0,Fn._)`${i.code==="new RegExp"?HLe:(0,ULe.useFunc)(t,i)}(${r}, ${n})`})}wn.usePattern=VLe;function GLe(t){let{gen:e,data:r,keyword:n,it:i}=t,o=e.name("valid");if(i.allErrors){let a=e.let("valid",!0);return s(()=>e.assign(a,!1)),a}return e.var(o,!0),s(()=>e.break()),o;function s(a){let d=e.const("len",(0,Fn._)`${r}.length`);e.forRange("i",0,d,u=>{t.subschema({keyword:n,dataProp:u,dataPropType:hU.Type.Num},o),e.if((0,Fn.not)(o),a)})}}wn.validateArray=GLe;function JLe(t){let{gen:e,schema:r,keyword:n,it:i}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(d=>(0,hU.alwaysValidSchema)(i,d))&&!i.opts.unevaluated)return;let s=e.let("valid",!1),a=e.name("_valid");e.block(()=>r.forEach((d,u)=>{let c=t.subschema({keyword:n,schemaProp:u,compositeRule:!0},a);e.assign(s,(0,Fn._)`${s} || ${a}`),t.mergeValidEvaluated(c,a)||e.if((0,Fn.not)(s))})),t.result(s,()=>t.reset(),()=>t.error(!0))}wn.validateUnion=JLe});var zle=V(pf=>{"use strict";f();Object.defineProperty(pf,"__esModule",{value:!0});pf.validateKeywordUsage=pf.validSchemaType=pf.funcKeywordCode=pf.macroKeywordCode=void 0;var $a=rr(),gv=Kd(),ZLe=Fd(),YLe=Y6();function XLe(t,e){let{gen:r,keyword:n,schema:i,parentSchema:o,it:s}=t,a=e.macro.call(s.self,i,o,s),d=Fle(r,n,a);s.opts.validateSchema!==!1&&s.self.validateSchema(a,!0);let u=r.name("valid");t.subschema({schema:a,schemaPath:$a.nil,errSchemaPath:`${s.errSchemaPath}/${n}`,topSchemaRef:d,compositeRule:!0},u),t.pass(u,()=>t.error(!0))}pf.macroKeywordCode=XLe;function QLe(t,e){var r;let{gen:n,keyword:i,schema:o,parentSchema:s,$data:a,it:d}=t;tKe(d,e);let u=!a&&e.compile?e.compile.call(d.self,o,s,d):e.validate,c=Fle(n,i,u),l=n.let("valid");t.block$data(l,p),t.ok((r=e.valid)!==null&&r!==void 0?r:l);function p(){if(e.errors===!1)v(),e.modifying&&Kle(t),x(()=>t.error());else{let S=e.async?m():g();e.modifying&&Kle(t),x(()=>eKe(t,S))}}function m(){let S=n.let("ruleErrs",null);return n.try(()=>v((0,$a._)`await `),P=>n.assign(l,!1).if((0,$a._)`${P} instanceof ${d.ValidationError}`,()=>n.assign(S,(0,$a._)`${P}.errors`),()=>n.throw(P))),S}function g(){let S=(0,$a._)`${c}.errors`;return n.assign(S,null),v($a.nil),S}function v(S=e.async?(0,$a._)`await `:$a.nil){let P=d.opts.passContext?gv.default.this:gv.default.self,A=!("compile"in e&&!a||e.schema===!1);n.assign(l,(0,$a._)`${S}${(0,ZLe.callValidateCode)(t,c,P,A)}`,e.modifying)}function x(S){var P;n.if((0,$a.not)((P=e.valid)!==null&&P!==void 0?P:l),S)}}pf.funcKeywordCode=QLe;function Kle(t){let{gen:e,data:r,it:n}=t;e.if(n.parentData,()=>e.assign(r,(0,$a._)`${n.parentData}[${n.parentDataProperty}]`))}function eKe(t,e){let{gen:r}=t;r.if((0,$a._)`Array.isArray(${e})`,()=>{r.assign(gv.default.vErrors,(0,$a._)`${gv.default.vErrors} === null ? ${e} : ${gv.default.vErrors}.concat(${e})`).assign(gv.default.errors,(0,$a._)`${gv.default.vErrors}.length`),(0,YLe.extendErrors)(t)},()=>t.error())}function tKe({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function Fle(t,e,r){if(r===void 0)throw new Error(`keyword "${e}" failed to compile`);return t.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,$a.stringify)(r)})}function rKe(t,e,r=!1){return!e.length||e.some(n=>n==="array"?Array.isArray(t):n==="object"?t&&typeof t=="object"&&!Array.isArray(t):typeof t==n||r&&typeof t>"u")}pf.validSchemaType=rKe;function nKe({schema:t,opts:e,self:r,errSchemaPath:n},i,o){if(Array.isArray(i.keyword)?!i.keyword.includes(o):i.keyword!==o)throw new Error("ajv implementation error");let s=i.dependencies;if(s?.some(a=>!Object.prototype.hasOwnProperty.call(t,a)))throw new Error(`parent schema must have dependencies of ${o}: ${s.join(",")}`);if(i.validateSchema&&!i.validateSchema(t[o])){let d=`keyword "${o}" value is invalid at path "${n}": `+r.errorsText(i.validateSchema.errors);if(e.validateSchema==="log")r.logger.error(d);else throw new Error(d)}}pf.validateKeywordUsage=nKe});var Hle=V(fy=>{"use strict";f();Object.defineProperty(fy,"__esModule",{value:!0});fy.extendSubschemaMode=fy.extendSubschemaData=fy.getSubschema=void 0;var mf=rr(),Wle=Rr();function iKe(t,{keyword:e,schemaProp:r,schema:n,schemaPath:i,errSchemaPath:o,topSchemaRef:s}){if(e!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){let a=t.schema[e];return r===void 0?{schema:a,schemaPath:(0,mf._)`${t.schemaPath}${(0,mf.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[r],schemaPath:(0,mf._)`${t.schemaPath}${(0,mf.getProperty)(e)}${(0,mf.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,Wle.escapeFragment)(r)}`}}if(n!==void 0){if(i===void 0||o===void 0||s===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:i,topSchemaRef:s,errSchemaPath:o}}throw new Error('either "keyword" or "schema" must be passed')}fy.getSubschema=iKe;function oKe(t,e,{dataProp:r,dataPropType:n,data:i,dataTypes:o,propertyName:s}){if(i!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=e;if(r!==void 0){let{errorPath:u,dataPathArr:c,opts:l}=e,p=a.let("data",(0,mf._)`${e.data}${(0,mf.getProperty)(r)}`,!0);d(p),t.errorPath=(0,mf.str)`${u}${(0,Wle.getErrorPath)(r,n,l.jsPropertySyntax)}`,t.parentDataProperty=(0,mf._)`${r}`,t.dataPathArr=[...c,t.parentDataProperty]}if(i!==void 0){let u=i instanceof mf.Name?i:a.let("data",i,!0);d(u),s!==void 0&&(t.propertyName=s)}o&&(t.dataTypes=o);function d(u){t.data=u,t.dataLevel=e.dataLevel+1,t.dataTypes=[],e.definedProperties=new Set,t.parentData=e.data,t.dataNames=[...e.dataNames,u]}}fy.extendSubschemaData=oKe;function sKe(t,{jtdDiscriminator:e,jtdMetadata:r,compositeRule:n,createErrors:i,allErrors:o}){n!==void 0&&(t.compositeRule=n),i!==void 0&&(t.createErrors=i),o!==void 0&&(t.allErrors=o),t.jtdDiscriminator=e,t.jtdMetadata=r}fy.extendSubschemaMode=sKe});var yU=V((v3t,Vle)=>{"use strict";f();Vle.exports=function t(e,r){if(e===r)return!0;if(e&&r&&typeof e=="object"&&typeof r=="object"){if(e.constructor!==r.constructor)return!1;var n,i,o;if(Array.isArray(e)){if(n=e.length,n!=r.length)return!1;for(i=n;i--!==0;)if(!t(e[i],r[i]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if(o=Object.keys(e),n=o.length,n!==Object.keys(r).length)return!1;for(i=n;i--!==0;)if(!Object.prototype.hasOwnProperty.call(r,o[i]))return!1;for(i=n;i--!==0;){var s=o[i];if(!t(e[s],r[s]))return!1}return!0}return e!==e&&r!==r}});var Jle=V((w3t,Gle)=>{"use strict";f();var hy=Gle.exports=function(t,e,r){typeof e=="function"&&(r=e,e={}),r=e.cb||r;var n=typeof r=="function"?r:r.pre||function(){},i=r.post||function(){};KP(e,n,i,t,"",t)};hy.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};hy.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};hy.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};hy.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function KP(t,e,r,n,i,o,s,a,d,u){if(n&&typeof n=="object"&&!Array.isArray(n)){e(n,i,o,s,a,d,u);for(var c in n){var l=n[c];if(Array.isArray(l)){if(c in hy.arrayKeywords)for(var p=0;p{"use strict";f();Object.defineProperty(cc,"__esModule",{value:!0});cc.getSchemaRefs=cc.resolveUrl=cc.normalizeId=cc._getFullPath=cc.getFullPath=cc.inlineRef=void 0;var cKe=Rr(),dKe=yU(),uKe=Jle(),lKe=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function fKe(t,e=!0){return typeof t=="boolean"?!0:e===!0?!gU(t):e?Zle(t)<=e:!1}cc.inlineRef=fKe;var hKe=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function gU(t){for(let e in t){if(hKe.has(e))return!0;let r=t[e];if(Array.isArray(r)&&r.some(gU)||typeof r=="object"&&gU(r))return!0}return!1}function Zle(t){let e=0;for(let r in t){if(r==="$ref")return 1/0;if(e++,!lKe.has(r)&&(typeof t[r]=="object"&&(0,cKe.eachItem)(t[r],n=>e+=Zle(n)),e===1/0))return 1/0}return e}function Yle(t,e="",r){r!==!1&&(e=u2(e));let n=t.parse(e);return Xle(t,n)}cc.getFullPath=Yle;function Xle(t,e){return t.serialize(e).split("#")[0]+"#"}cc._getFullPath=Xle;var pKe=/#\/?$/;function u2(t){return t?t.replace(pKe,""):""}cc.normalizeId=u2;function mKe(t,e,r){return r=u2(r),t.resolve(e,r)}cc.resolveUrl=mKe;var yKe=/^[a-z_][-a-z0-9._]*$/i;function gKe(t,e){if(typeof t=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,i=u2(t[r]||e),o={"":i},s=Yle(n,i,!1),a={},d=new Set;return uKe(t,{allKeys:!0},(l,p,m,g)=>{if(g===void 0)return;let v=s+p,x=o[g];typeof l[r]=="string"&&(x=S.call(this,l[r])),P.call(this,l.$anchor),P.call(this,l.$dynamicAnchor),o[p]=x;function S(A){let $=this.opts.uriResolver.resolve;if(A=u2(x?$(x,A):A),d.has(A))throw c(A);d.add(A);let j=this.refs[A];return typeof j=="string"&&(j=this.refs[j]),typeof j=="object"?u(l,j.schema,A):A!==u2(v)&&(A[0]==="#"?(u(l,a[A],A),a[A]=l):this.refs[A]=v),A}function P(A){if(typeof A=="string"){if(!yKe.test(A))throw new Error(`invalid anchor "${A}"`);S.call(this,`#${A}`)}}}),a;function u(l,p,m){if(p!==void 0&&!dKe(l,p))throw c(m)}function c(l){return new Error(`reference "${l}" resolves to more than one schema`)}}cc.getSchemaRefs=gKe});var nS=V(py=>{"use strict";f();Object.defineProperty(py,"__esModule",{value:!0});py.getData=py.KeywordCxt=py.validateFunctionCode=void 0;var nfe=Ble(),Qle=Q6(),bU=dU(),FP=Q6(),vKe=Ule(),rS=zle(),vU=Hle(),pt=rr(),Nt=Kd(),bKe=eS(),Jh=Rr(),tS=Y6();function wKe(t){if(sfe(t)&&(afe(t),ofe(t))){EKe(t);return}ife(t,()=>(0,nfe.topBoolOrEmptySchema)(t))}py.validateFunctionCode=wKe;function ife({gen:t,validateName:e,schema:r,schemaEnv:n,opts:i},o){i.code.es5?t.func(e,(0,pt._)`${Nt.default.data}, ${Nt.default.valCxt}`,n.$async,()=>{t.code((0,pt._)`"use strict"; ${efe(r,i)}`),xKe(t,i),t.code(o)}):t.func(e,(0,pt._)`${Nt.default.data}, ${_Ke(i)}`,n.$async,()=>t.code(efe(r,i)).code(o))}function _Ke(t){return(0,pt._)`{${Nt.default.instancePath}="", ${Nt.default.parentData}, ${Nt.default.parentDataProperty}, ${Nt.default.rootData}=${Nt.default.data}${t.dynamicRef?(0,pt._)`, ${Nt.default.dynamicAnchors}={}`:pt.nil}}={}`}function xKe(t,e){t.if(Nt.default.valCxt,()=>{t.var(Nt.default.instancePath,(0,pt._)`${Nt.default.valCxt}.${Nt.default.instancePath}`),t.var(Nt.default.parentData,(0,pt._)`${Nt.default.valCxt}.${Nt.default.parentData}`),t.var(Nt.default.parentDataProperty,(0,pt._)`${Nt.default.valCxt}.${Nt.default.parentDataProperty}`),t.var(Nt.default.rootData,(0,pt._)`${Nt.default.valCxt}.${Nt.default.rootData}`),e.dynamicRef&&t.var(Nt.default.dynamicAnchors,(0,pt._)`${Nt.default.valCxt}.${Nt.default.dynamicAnchors}`)},()=>{t.var(Nt.default.instancePath,(0,pt._)`""`),t.var(Nt.default.parentData,(0,pt._)`undefined`),t.var(Nt.default.parentDataProperty,(0,pt._)`undefined`),t.var(Nt.default.rootData,Nt.default.data),e.dynamicRef&&t.var(Nt.default.dynamicAnchors,(0,pt._)`{}`)})}function EKe(t){let{schema:e,opts:r,gen:n}=t;ife(t,()=>{r.$comment&&e.$comment&&dfe(t),IKe(t),n.let(Nt.default.vErrors,null),n.let(Nt.default.errors,0),r.unevaluated&&SKe(t),cfe(t),DKe(t)})}function SKe(t){let{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",(0,pt._)`${r}.evaluated`),e.if((0,pt._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,pt._)`${t.evaluated}.props`,(0,pt._)`undefined`)),e.if((0,pt._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,pt._)`${t.evaluated}.items`,(0,pt._)`undefined`))}function efe(t,e){let r=typeof t=="object"&&t[e.schemaId];return r&&(e.code.source||e.code.process)?(0,pt._)`/*# sourceURL=${r} */`:pt.nil}function AKe(t,e){if(sfe(t)&&(afe(t),ofe(t))){TKe(t,e);return}(0,nfe.boolOrEmptySchema)(t,e)}function ofe({schema:t,self:e}){if(typeof t=="boolean")return!t;for(let r in t)if(e.RULES.all[r])return!0;return!1}function sfe(t){return typeof t.schema!="boolean"}function TKe(t,e){let{schema:r,gen:n,opts:i}=t;i.$comment&&r.$comment&&dfe(t),kKe(t),RKe(t);let o=n.const("_errs",Nt.default.errors);cfe(t,o),n.var(e,(0,pt._)`${o} === ${Nt.default.errors}`)}function afe(t){(0,Jh.checkUnknownRules)(t),PKe(t)}function cfe(t,e){if(t.opts.jtd)return tfe(t,[],!1,e);let r=(0,Qle.getSchemaTypes)(t.schema),n=(0,Qle.coerceAndCheckDataType)(t,r);tfe(t,r,!n,e)}function PKe(t){let{schema:e,errSchemaPath:r,opts:n,self:i}=t;e.$ref&&n.ignoreKeywordsWithRef&&(0,Jh.schemaHasRulesButRef)(e,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function IKe(t){let{schema:e,opts:r}=t;e.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Jh.checkStrictMode)(t,"default is ignored in the schema root")}function kKe(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,bKe.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function RKe(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function dfe({gen:t,schemaEnv:e,schema:r,errSchemaPath:n,opts:i}){let o=r.$comment;if(i.$comment===!0)t.code((0,pt._)`${Nt.default.self}.logger.log(${o})`);else if(typeof i.$comment=="function"){let s=(0,pt.str)`${n}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,pt._)`${Nt.default.self}.opts.$comment(${o}, ${s}, ${a}.schema)`)}}function DKe(t){let{gen:e,schemaEnv:r,validateName:n,ValidationError:i,opts:o}=t;r.$async?e.if((0,pt._)`${Nt.default.errors} === 0`,()=>e.return(Nt.default.data),()=>e.throw((0,pt._)`new ${i}(${Nt.default.vErrors})`)):(e.assign((0,pt._)`${n}.errors`,Nt.default.vErrors),o.unevaluated&&BKe(t),e.return((0,pt._)`${Nt.default.errors} === 0`))}function BKe({gen:t,evaluated:e,props:r,items:n}){r instanceof pt.Name&&t.assign((0,pt._)`${e}.props`,r),n instanceof pt.Name&&t.assign((0,pt._)`${e}.items`,n)}function tfe(t,e,r,n){let{gen:i,schema:o,data:s,allErrors:a,opts:d,self:u}=t,{RULES:c}=u;if(o.$ref&&(d.ignoreKeywordsWithRef||!(0,Jh.schemaHasRulesButRef)(o,c))){i.block(()=>lfe(t,"$ref",c.all.$ref.definition));return}d.jtd||MKe(t,e),i.block(()=>{for(let p of c.rules)l(p);l(c.post)});function l(p){(0,bU.shouldUseGroup)(o,p)&&(p.type?(i.if((0,FP.checkDataType)(p.type,s,d.strictNumbers)),rfe(t,p),e.length===1&&e[0]===p.type&&r&&(i.else(),(0,FP.reportTypeError)(t)),i.endIf()):rfe(t,p),a||i.if((0,pt._)`${Nt.default.errors} === ${n||0}`))}}function rfe(t,e){let{gen:r,schema:n,opts:{useDefaults:i}}=t;i&&(0,vKe.assignDefaults)(t,e.type),r.block(()=>{for(let o of e.rules)(0,bU.shouldUseRule)(n,o)&&lfe(t,o.keyword,o.definition,e.type)})}function MKe(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(OKe(t,e),t.opts.allowUnionTypes||CKe(t,e),$Ke(t,t.dataTypes))}function OKe(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{ufe(t.dataTypes,r)||wU(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),NKe(t,e)}}function CKe(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&wU(t,"use allowUnionTypes to allow union type keyword")}function $Ke(t,e){let r=t.self.RULES.all;for(let n in r){let i=r[n];if(typeof i=="object"&&(0,bU.shouldUseRule)(t.schema,i)){let{type:o}=i.definition;o.length&&!o.some(s=>jKe(e,s))&&wU(t,`missing type "${o.join(",")}" for keyword "${n}"`)}}}function jKe(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function ufe(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function NKe(t,e){let r=[];for(let n of t.dataTypes)ufe(e,n)?r.push(n):e.includes("integer")&&n==="number"&&r.push("integer");t.dataTypes=r}function wU(t,e){let r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0,Jh.checkStrictMode)(t,e,t.opts.strictTypes)}var zP=class{constructor(e,r,n){if((0,rS.validateKeywordUsage)(e,r,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=r.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Jh.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=r,this.$data)this.schemaCode=e.gen.const("vSchema",ffe(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,rS.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=e.gen.const("_errs",Nt.default.errors))}result(e,r,n){this.failResult((0,pt.not)(e),r,n)}failResult(e,r,n){this.gen.if(e),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,r){this.failResult((0,pt.not)(e),void 0,r)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:r}=this;this.fail((0,pt._)`${r} !== undefined && (${(0,pt.or)(this.invalid$data(),e)})`)}error(e,r,n){if(r){this.setParams(r),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,r){(e?tS.reportExtraError:tS.reportError)(this,this.def.error,r)}$dataError(){(0,tS.reportError)(this,this.def.$dataError||tS.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,tS.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,r){r?Object.assign(this.params,e):this.params=e}block$data(e,r,n=pt.nil){this.gen.block(()=>{this.check$data(e,n),r()})}check$data(e=pt.nil,r=pt.nil){if(!this.$data)return;let{gen:n,schemaCode:i,schemaType:o,def:s}=this;n.if((0,pt.or)((0,pt._)`${i} === undefined`,r)),e!==pt.nil&&n.assign(e,!0),(o.length||s.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==pt.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:r,schemaType:n,def:i,it:o}=this;return(0,pt.or)(s(),a());function s(){if(n.length){if(!(r instanceof pt.Name))throw new Error("ajv implementation error");let d=Array.isArray(n)?n:[n];return(0,pt._)`${(0,FP.checkDataTypes)(d,r,o.opts.strictNumbers,FP.DataType.Wrong)}`}return pt.nil}function a(){if(i.validateSchema){let d=e.scopeValue("validate$data",{ref:i.validateSchema});return(0,pt._)`!${d}(${r})`}return pt.nil}}subschema(e,r){let n=(0,vU.getSubschema)(this.it,e);(0,vU.extendSubschemaData)(n,this.it,e),(0,vU.extendSubschemaMode)(n,e);let i={...this.it,...n,items:void 0,props:void 0};return AKe(i,r),i}mergeEvaluated(e,r){let{it:n,gen:i}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=Jh.mergeEvaluated.props(i,e.props,n.props,r)),n.items!==!0&&e.items!==void 0&&(n.items=Jh.mergeEvaluated.items(i,e.items,n.items,r)))}mergeValidEvaluated(e,r){let{it:n,gen:i}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return i.if(r,()=>this.mergeEvaluated(e,pt.Name)),!0}};py.KeywordCxt=zP;function lfe(t,e,r,n){let i=new zP(t,r,e);"code"in r?r.code(i,n):i.$data&&r.validate?(0,rS.funcKeywordCode)(i,r):"macro"in r?(0,rS.macroKeywordCode)(i,r):(r.compile||r.validate)&&(0,rS.funcKeywordCode)(i,r)}var UKe=/^\/(?:[^~]|~0|~1)*$/,qKe=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function ffe(t,{dataLevel:e,dataNames:r,dataPathArr:n}){let i,o;if(t==="")return Nt.default.rootData;if(t[0]==="/"){if(!UKe.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);i=t,o=Nt.default.rootData}else{let u=qKe.exec(t);if(!u)throw new Error(`Invalid JSON-pointer: ${t}`);let c=+u[1];if(i=u[2],i==="#"){if(c>=e)throw new Error(d("property/index",c));return n[e-c]}if(c>e)throw new Error(d("data",c));if(o=r[e-c],!i)return o}let s=o,a=i.split("/");for(let u of a)u&&(o=(0,pt._)`${o}${(0,pt.getProperty)((0,Jh.unescapeJsonPointer)(u))}`,s=(0,pt._)`${s} && ${o}`);return s;function d(u,c){return`Cannot access ${u} ${c} levels up, current level is ${e}`}}py.getData=ffe});var WP=V(xU=>{"use strict";f();Object.defineProperty(xU,"__esModule",{value:!0});var _U=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};xU.default=_U});var HP=V(AU=>{"use strict";f();Object.defineProperty(AU,"__esModule",{value:!0});var EU=eS(),SU=class extends Error{constructor(e,r,n,i){super(i||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,EU.resolveUrl)(e,r,n),this.missingSchema=(0,EU.normalizeId)((0,EU.getFullPath)(e,this.missingRef))}};AU.default=SU});var iS=V(zd=>{"use strict";f();Object.defineProperty(zd,"__esModule",{value:!0});zd.resolveSchema=zd.getCompilingSchema=zd.resolveRef=zd.compileSchema=zd.SchemaEnv=void 0;var Zu=rr(),LKe=WP(),vv=Kd(),Yu=eS(),hfe=Rr(),KKe=nS(),l2=class{constructor(e){var r;this.refs={},this.dynamicAnchors={};let n;typeof e.schema=="object"&&(n=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(r=e.baseId)!==null&&r!==void 0?r:(0,Yu.normalizeId)(n?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=n?.$async,this.refs={}}};zd.SchemaEnv=l2;function PU(t){let e=pfe.call(this,t);if(e)return e;let r=(0,Yu.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:n,lines:i}=this.opts.code,{ownProperties:o}=this.opts,s=new Zu.CodeGen(this.scope,{es5:n,lines:i,ownProperties:o}),a;t.$async&&(a=s.scopeValue("Error",{ref:LKe.default,code:(0,Zu._)`require("ajv/dist/runtime/validation_error").default`}));let d=s.scopeName("validate");t.validateName=d;let u={gen:s,allErrors:this.opts.allErrors,data:vv.default.data,parentData:vv.default.parentData,parentDataProperty:vv.default.parentDataProperty,dataNames:[vv.default.data],dataPathArr:[Zu.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:s.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,Zu.stringify)(t.schema)}:{ref:t.schema}),validateName:d,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:Zu.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,Zu._)`""`,opts:this.opts,self:this},c;try{this._compilations.add(t),(0,KKe.validateFunctionCode)(u),s.optimize(this.opts.code.optimize);let l=s.toString();c=`${s.scopeRefs(vv.default.scope)}return ${l}`,this.opts.code.process&&(c=this.opts.code.process(c,t));let m=new Function(`${vv.default.self}`,`${vv.default.scope}`,c)(this,this.scope.get());if(this.scope.value(d,{ref:m}),m.errors=null,m.schema=t.schema,m.schemaEnv=t,t.$async&&(m.$async=!0),this.opts.code.source===!0&&(m.source={validateName:d,validateCode:l,scopeValues:s._values}),this.opts.unevaluated){let{props:g,items:v}=u;m.evaluated={props:g instanceof Zu.Name?void 0:g,items:v instanceof Zu.Name?void 0:v,dynamicProps:g instanceof Zu.Name,dynamicItems:v instanceof Zu.Name},m.source&&(m.source.evaluated=(0,Zu.stringify)(m.evaluated))}return t.validate=m,t}catch(l){throw delete t.validate,delete t.validateName,c&&this.logger.error("Error compiling schema, function code:",c),l}finally{this._compilations.delete(t)}}zd.compileSchema=PU;function FKe(t,e,r){var n;r=(0,Yu.resolveUrl)(this.opts.uriResolver,e,r);let i=t.refs[r];if(i)return i;let o=HKe.call(this,t,r);if(o===void 0){let s=(n=t.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;s&&(o=new l2({schema:s,schemaId:a,root:t,baseId:e}))}if(o!==void 0)return t.refs[r]=zKe.call(this,o)}zd.resolveRef=FKe;function zKe(t){return(0,Yu.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:PU.call(this,t)}function pfe(t){for(let e of this._compilations)if(WKe(e,t))return e}zd.getCompilingSchema=pfe;function WKe(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function HKe(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||VP.call(this,t,e)}function VP(t,e){let r=this.opts.uriResolver.parse(e),n=(0,Yu._getFullPath)(this.opts.uriResolver,r),i=(0,Yu.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&n===i)return TU.call(this,r,t);let o=(0,Yu.normalizeId)(n),s=this.refs[o]||this.schemas[o];if(typeof s=="string"){let a=VP.call(this,t,s);return typeof a?.schema!="object"?void 0:TU.call(this,r,a)}if(typeof s?.schema=="object"){if(s.validate||PU.call(this,s),o===(0,Yu.normalizeId)(e)){let{schema:a}=s,{schemaId:d}=this.opts,u=a[d];return u&&(i=(0,Yu.resolveUrl)(this.opts.uriResolver,i,u)),new l2({schema:a,schemaId:d,root:t,baseId:i})}return TU.call(this,r,s)}}zd.resolveSchema=VP;var VKe=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function TU(t,{baseId:e,schema:r,root:n}){var i;if(((i=t.fragment)===null||i===void 0?void 0:i[0])!=="/")return;for(let a of t.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let d=r[(0,hfe.unescapeFragment)(a)];if(d===void 0)return;r=d;let u=typeof r=="object"&&r[this.opts.schemaId];!VKe.has(a)&&u&&(e=(0,Yu.resolveUrl)(this.opts.uriResolver,e,u))}let o;if(typeof r!="boolean"&&r.$ref&&!(0,hfe.schemaHasRulesButRef)(r,this.RULES)){let a=(0,Yu.resolveUrl)(this.opts.uriResolver,e,r.$ref);o=VP.call(this,n,a)}let{schemaId:s}=this.opts;if(o=o||new l2({schema:r,schemaId:s,root:n,baseId:e}),o.schema!==o.root.schema)return o}});var mfe=V((B3t,GKe)=>{GKe.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var IU=V((GP,yfe)=>{f();(function(t,e){typeof GP=="object"&&typeof yfe<"u"?e(GP):typeof define=="function"&&define.amd?define(["exports"],e):e(t.URI=t.URI||{})})(GP,function(t){"use strict";function e(){for(var ee=arguments.length,Y=Array(ee),oe=0;oe1){Y[0]=Y[0].slice(0,-1);for(var ue=Y.length-1,le=1;le= 0x80 (not a basic code point)","invalid-input":"Invalid input"},W=m-g,q=Math.floor,I=String.fromCharCode;function T(ee){throw new RangeError(K[ee])}function B(ee,Y){for(var oe=[],ue=ee.length;ue--;)oe[ue]=Y(ee[ue]);return oe}function h(ee,Y){var oe=ee.split("@"),ue="";oe.length>1&&(ue=oe[0]+"@",ee=oe[1]),ee=ee.replace(F,".");var le=ee.split("."),Ne=B(le,Y).join(".");return ue+Ne}function y(ee){for(var Y=[],oe=0,ue=ee.length;oe=55296&&le<=56319&&oe>1,Y+=q(Y/oe);Y>W*v>>1;le+=m)Y=q(Y/W);return q(le+(W+1)*Y/(Y+x))},C=function(Y){var oe=[],ue=Y.length,le=0,Ne=A,Me=P,Ue=Y.lastIndexOf($);Ue<0&&(Ue=0);for(var Tr=0;Tr=128&&T("not-basic"),oe.push(Y.charCodeAt(Tr));for(var Lt=Ue>0?Ue+1:0;Lt=ue&&T("invalid-input");var Hr=E(Y.charCodeAt(Lt++));(Hr>=m||Hr>q((p-le)/Jr))&&T("overflow"),le+=Hr*Jr;var ar=dn<=Me?g:dn>=Me+v?v:dn-Me;if(Hrq(p/Zr)&&T("overflow"),Jr*=Zr}var Br=oe.length+1;Me=b(le-ft,Br,ft==0),q(le/Br)>p-Ne&&T("overflow"),Ne+=q(le/Br),le%=Br,oe.splice(le++,0,Ne)}return String.fromCodePoint.apply(String,oe)},N=function(Y){var oe=[];Y=y(Y);var ue=Y.length,le=A,Ne=0,Me=P,Ue=!0,Tr=!1,Lt=void 0;try{for(var ft=Y[Symbol.iterator](),Jr;!(Ue=(Jr=ft.next()).done);Ue=!0){var dn=Jr.value;dn<128&&oe.push(I(dn))}}catch(b0){Tr=!0,Lt=b0}finally{try{!Ue&&ft.return&&ft.return()}finally{if(Tr)throw Lt}}var Hr=oe.length,ar=Hr;for(Hr&&oe.push($);ar=le&&Aiq((p-Ne)/qi)&&T("overflow"),Ne+=(Zr-le)*qi,le=Zr;var xo=!0,pa=!1,Xo=void 0;try{for(var xc=Y[Symbol.iterator](),Lp;!(xo=(Lp=xc.next()).done);xo=!0){var Kp=Lp.value;if(Kpp&&T("overflow"),Kp==le){for(var gl=Ne,Bb=m;;Bb+=m){var zf=Bb<=Me?g:Bb>=Me+v?v:Bb-Me;if(gl>6|192).toString(16).toUpperCase()+"%"+(Y&63|128).toString(16).toUpperCase():oe="%"+(Y>>12|224).toString(16).toUpperCase()+"%"+(Y>>6&63|128).toString(16).toUpperCase()+"%"+(Y&63|128).toString(16).toUpperCase(),oe}function H(ee){for(var Y="",oe=0,ue=ee.length;oe=194&&le<224){if(ue-oe>=6){var Ne=parseInt(ee.substr(oe+4,2),16);Y+=String.fromCharCode((le&31)<<6|Ne&63)}else Y+=ee.substr(oe,6);oe+=6}else if(le>=224){if(ue-oe>=9){var Me=parseInt(ee.substr(oe+4,2),16),Ue=parseInt(ee.substr(oe+7,2),16);Y+=String.fromCharCode((le&15)<<12|(Me&63)<<6|Ue&63)}else Y+=ee.substr(oe,9);oe+=9}else Y+=ee.substr(oe,3),oe+=3}return Y}function X(ee,Y){function oe(ue){var le=H(ue);return le.match(Y.UNRESERVED)?le:ue}return ee.scheme&&(ee.scheme=String(ee.scheme).replace(Y.PCT_ENCODED,oe).toLowerCase().replace(Y.NOT_SCHEME,"")),ee.userinfo!==void 0&&(ee.userinfo=String(ee.userinfo).replace(Y.PCT_ENCODED,oe).replace(Y.NOT_USERINFO,J).replace(Y.PCT_ENCODED,i)),ee.host!==void 0&&(ee.host=String(ee.host).replace(Y.PCT_ENCODED,oe).toLowerCase().replace(Y.NOT_HOST,J).replace(Y.PCT_ENCODED,i)),ee.path!==void 0&&(ee.path=String(ee.path).replace(Y.PCT_ENCODED,oe).replace(ee.scheme?Y.NOT_PATH:Y.NOT_PATH_NOSCHEME,J).replace(Y.PCT_ENCODED,i)),ee.query!==void 0&&(ee.query=String(ee.query).replace(Y.PCT_ENCODED,oe).replace(Y.NOT_QUERY,J).replace(Y.PCT_ENCODED,i)),ee.fragment!==void 0&&(ee.fragment=String(ee.fragment).replace(Y.PCT_ENCODED,oe).replace(Y.NOT_FRAGMENT,J).replace(Y.PCT_ENCODED,i)),ee}function te(ee){return ee.replace(/^0*(.*)/,"$1")||"0"}function ne(ee,Y){var oe=ee.match(Y.IPV4ADDRESS)||[],ue=c(oe,2),le=ue[1];return le?le.split(".").map(te).join("."):ee}function Q(ee,Y){var oe=ee.match(Y.IPV6ADDRESS)||[],ue=c(oe,3),le=ue[1],Ne=ue[2];if(le){for(var Me=le.toLowerCase().split("::").reverse(),Ue=c(Me,2),Tr=Ue[0],Lt=Ue[1],ft=Lt?Lt.split(":").map(te):[],Jr=Tr.split(":").map(te),dn=Y.IPV4ADDRESS.test(Jr[Jr.length-1]),Hr=dn?7:8,ar=Jr.length-Hr,Zr=Array(Hr),Br=0;Br1){var $r=Zr.slice(0,Si.index),Ai=Zr.slice(Si.index+Si.length);Ui=$r.join(":")+"::"+Ai.join(":")}else Ui=Zr.join(":");return Ne&&(Ui+="%"+Ne),Ui}else return ee}var re=/^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i,ce="".match(/(){0}/)[1]===void 0;function pe(ee){var Y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},oe={},ue=Y.iri!==!1?u:d;Y.reference==="suffix"&&(ee=(Y.scheme?Y.scheme+":":"")+"//"+ee);var le=ee.match(re);if(le){ce?(oe.scheme=le[1],oe.userinfo=le[3],oe.host=le[4],oe.port=parseInt(le[5],10),oe.path=le[6]||"",oe.query=le[7],oe.fragment=le[8],isNaN(oe.port)&&(oe.port=le[5])):(oe.scheme=le[1]||void 0,oe.userinfo=ee.indexOf("@")!==-1?le[3]:void 0,oe.host=ee.indexOf("//")!==-1?le[4]:void 0,oe.port=parseInt(le[5],10),oe.path=le[6]||"",oe.query=ee.indexOf("?")!==-1?le[7]:void 0,oe.fragment=ee.indexOf("#")!==-1?le[8]:void 0,isNaN(oe.port)&&(oe.port=ee.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/)?le[4]:void 0)),oe.host&&(oe.host=Q(ne(oe.host,ue),ue)),oe.scheme===void 0&&oe.userinfo===void 0&&oe.host===void 0&&oe.port===void 0&&!oe.path&&oe.query===void 0?oe.reference="same-document":oe.scheme===void 0?oe.reference="relative":oe.fragment===void 0?oe.reference="absolute":oe.reference="uri",Y.reference&&Y.reference!=="suffix"&&Y.reference!==oe.reference&&(oe.error=oe.error||"URI is not a "+Y.reference+" reference.");var Ne=Z[(Y.scheme||oe.scheme||"").toLowerCase()];if(!Y.unicodeSupport&&(!Ne||!Ne.unicodeSupport)){if(oe.host&&(Y.domainHost||Ne&&Ne.domainHost))try{oe.host=G.toASCII(oe.host.replace(ue.PCT_ENCODED,H).toLowerCase())}catch(Me){oe.error=oe.error||"Host's domain name can not be converted to ASCII via punycode: "+Me}X(oe,d)}else X(oe,ue);Ne&&Ne.parse&&Ne.parse(oe,Y)}else oe.error=oe.error||"URI can not be parsed.";return oe}function ye(ee,Y){var oe=Y.iri!==!1?u:d,ue=[];return ee.userinfo!==void 0&&(ue.push(ee.userinfo),ue.push("@")),ee.host!==void 0&&ue.push(Q(ne(String(ee.host),oe),oe).replace(oe.IPV6ADDRESS,function(le,Ne,Me){return"["+Ne+(Me?"%25"+Me:"")+"]"})),(typeof ee.port=="number"||typeof ee.port=="string")&&(ue.push(":"),ue.push(String(ee.port))),ue.length?ue.join(""):void 0}var ie=/^\.\.?\//,he=/^\/\.(\/|$)/,me=/^\/\.\.(\/|$)/,Re=/^\/?(?:.|\n)*?(?=\/|$)/;function xe(ee){for(var Y=[];ee.length;)if(ee.match(ie))ee=ee.replace(ie,"");else if(ee.match(he))ee=ee.replace(he,"/");else if(ee.match(me))ee=ee.replace(me,"/"),Y.pop();else if(ee==="."||ee==="..")ee="";else{var oe=ee.match(Re);if(oe){var ue=oe[0];ee=ee.slice(ue.length),Y.push(ue)}else throw new Error("Unexpected dot segment condition")}return Y.join("")}function it(ee){var Y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},oe=Y.iri?u:d,ue=[],le=Z[(Y.scheme||ee.scheme||"").toLowerCase()];if(le&&le.serialize&&le.serialize(ee,Y),ee.host&&!oe.IPV6ADDRESS.test(ee.host)){if(Y.domainHost||le&&le.domainHost)try{ee.host=Y.iri?G.toUnicode(ee.host):G.toASCII(ee.host.replace(oe.PCT_ENCODED,H).toLowerCase())}catch(Ue){ee.error=ee.error||"Host's domain name can not be converted to "+(Y.iri?"Unicode":"ASCII")+" via punycode: "+Ue}}X(ee,oe),Y.reference!=="suffix"&&ee.scheme&&(ue.push(ee.scheme),ue.push(":"));var Ne=ye(ee,Y);if(Ne!==void 0&&(Y.reference!=="suffix"&&ue.push("//"),ue.push(Ne),ee.path&&ee.path.charAt(0)!=="/"&&ue.push("/")),ee.path!==void 0){var Me=ee.path;!Y.absolutePath&&(!le||!le.absolutePath)&&(Me=xe(Me)),Ne===void 0&&(Me=Me.replace(/^\/\//,"/%2F")),ue.push(Me)}return ee.query!==void 0&&(ue.push("?"),ue.push(ee.query)),ee.fragment!==void 0&&(ue.push("#"),ue.push(ee.fragment)),ue.join("")}function Et(ee,Y){var oe=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},ue=arguments[3],le={};return ue||(ee=pe(it(ee,oe),oe),Y=pe(it(Y,oe),oe)),oe=oe||{},!oe.tolerant&&Y.scheme?(le.scheme=Y.scheme,le.userinfo=Y.userinfo,le.host=Y.host,le.port=Y.port,le.path=xe(Y.path||""),le.query=Y.query):(Y.userinfo!==void 0||Y.host!==void 0||Y.port!==void 0?(le.userinfo=Y.userinfo,le.host=Y.host,le.port=Y.port,le.path=xe(Y.path||""),le.query=Y.query):(Y.path?(Y.path.charAt(0)==="/"?le.path=xe(Y.path):((ee.userinfo!==void 0||ee.host!==void 0||ee.port!==void 0)&&!ee.path?le.path="/"+Y.path:ee.path?le.path=ee.path.slice(0,ee.path.lastIndexOf("/")+1)+Y.path:le.path=Y.path,le.path=xe(le.path)),le.query=Y.query):(le.path=ee.path,Y.query!==void 0?le.query=Y.query:le.query=ee.query),le.userinfo=ee.userinfo,le.host=ee.host,le.port=ee.port),le.scheme=ee.scheme),le.fragment=Y.fragment,le}function Fe(ee,Y,oe){var ue=s({scheme:"null"},oe);return it(Et(pe(ee,ue),pe(Y,ue),ue,!0),ue)}function mt(ee,Y){return typeof ee=="string"?ee=it(pe(ee,Y),Y):n(ee)==="object"&&(ee=pe(it(ee,Y),Y)),ee}function En(ee,Y,oe){return typeof ee=="string"?ee=it(pe(ee,oe),oe):n(ee)==="object"&&(ee=it(ee,oe)),typeof Y=="string"?Y=it(pe(Y,oe),oe):n(Y)==="object"&&(Y=it(Y,oe)),ee===Y}function ke(ee,Y){return ee&&ee.toString().replace(!Y||!Y.iri?d.ESCAPE:u.ESCAPE,J)}function Pe(ee,Y){return ee&&ee.toString().replace(!Y||!Y.iri?d.PCT_ENCODED:u.PCT_ENCODED,H)}var Wt={scheme:"http",domainHost:!0,parse:function(Y,oe){return Y.host||(Y.error=Y.error||"HTTP URIs must have a host."),Y},serialize:function(Y,oe){var ue=String(Y.scheme).toLowerCase()==="https";return(Y.port===(ue?443:80)||Y.port==="")&&(Y.port=void 0),Y.path||(Y.path="/"),Y}},Be={scheme:"https",domainHost:Wt.domainHost,parse:Wt.parse,serialize:Wt.serialize};function Ee(ee){return typeof ee.secure=="boolean"?ee.secure:String(ee.scheme).toLowerCase()==="wss"}var Cr={scheme:"ws",domainHost:!0,parse:function(Y,oe){var ue=Y;return ue.secure=Ee(ue),ue.resourceName=(ue.path||"/")+(ue.query?"?"+ue.query:""),ue.path=void 0,ue.query=void 0,ue},serialize:function(Y,oe){if((Y.port===(Ee(Y)?443:80)||Y.port==="")&&(Y.port=void 0),typeof Y.secure=="boolean"&&(Y.scheme=Y.secure?"wss":"ws",Y.secure=void 0),Y.resourceName){var ue=Y.resourceName.split("?"),le=c(ue,2),Ne=le[0],Me=le[1];Y.path=Ne&&Ne!=="/"?Ne:void 0,Y.query=Me,Y.resourceName=void 0}return Y.fragment=void 0,Y}},Ve={scheme:"wss",domainHost:Cr.domainHost,parse:Cr.parse,serialize:Cr.serialize},Ze={},en=!0,Rt="[A-Za-z0-9\\-\\.\\_\\~"+(en?"\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF":"")+"]",Ye="[0-9A-Fa-f]",pd=r(r("%[EFef]"+Ye+"%"+Ye+Ye+"%"+Ye+Ye)+"|"+r("%[89A-Fa-f]"+Ye+"%"+Ye+Ye)+"|"+r("%"+Ye+Ye)),Dt="[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]",Ut="[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]",y0=e(Ut,'[\\"\\\\]'),$t="[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]",Zt=new RegExp(Rt,"g"),md=new RegExp(pd,"g"),Yt=new RegExp(e("[^]",Dt,"[\\.]",'[\\"]',y0),"g"),Ht=new RegExp(e("[^]",Rt,$t),"g"),g0=Ht;function qt(ee){var Y=H(ee);return Y.match(Zt)?Y:ee}var Vt={scheme:"mailto",parse:function(Y,oe){var ue=Y,le=ue.to=ue.path?ue.path.split(","):[];if(ue.path=void 0,ue.query){for(var Ne=!1,Me={},Ue=ue.query.split("&"),Tr=0,Lt=Ue.length;Tr{"use strict";f();Object.defineProperty(kU,"__esModule",{value:!0});var gfe=IU();gfe.code='require("ajv/dist/runtime/uri").default';kU.default=gfe});var Tfe=V(Es=>{"use strict";f();Object.defineProperty(Es,"__esModule",{value:!0});Es.CodeGen=Es.Name=Es.nil=Es.stringify=Es.str=Es._=Es.KeywordCxt=void 0;var JKe=nS();Object.defineProperty(Es,"KeywordCxt",{enumerable:!0,get:function(){return JKe.KeywordCxt}});var f2=rr();Object.defineProperty(Es,"_",{enumerable:!0,get:function(){return f2._}});Object.defineProperty(Es,"str",{enumerable:!0,get:function(){return f2.str}});Object.defineProperty(Es,"stringify",{enumerable:!0,get:function(){return f2.stringify}});Object.defineProperty(Es,"nil",{enumerable:!0,get:function(){return f2.nil}});Object.defineProperty(Es,"Name",{enumerable:!0,get:function(){return f2.Name}});Object.defineProperty(Es,"CodeGen",{enumerable:!0,get:function(){return f2.CodeGen}});var ZKe=WP(),Efe=HP(),YKe=cU(),oS=iS(),XKe=rr(),sS=eS(),JP=Q6(),DU=Rr(),bfe=mfe(),QKe=vfe(),Sfe=(t,e)=>new RegExp(t,e);Sfe.code="new RegExp";var eFe=["removeAdditional","useDefaults","coerceTypes"],tFe=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),rFe={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},nFe={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},wfe=200;function iFe(t){var e,r,n,i,o,s,a,d,u,c,l,p,m,g,v,x,S,P,A,$,j,L,F,K,W;let q=t.strict,I=(e=t.code)===null||e===void 0?void 0:e.optimize,T=I===!0||I===void 0?1:I||0,B=(n=(r=t.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:Sfe,h=(i=t.uriResolver)!==null&&i!==void 0?i:QKe.default;return{strictSchema:(s=(o=t.strictSchema)!==null&&o!==void 0?o:q)!==null&&s!==void 0?s:!0,strictNumbers:(d=(a=t.strictNumbers)!==null&&a!==void 0?a:q)!==null&&d!==void 0?d:!0,strictTypes:(c=(u=t.strictTypes)!==null&&u!==void 0?u:q)!==null&&c!==void 0?c:"log",strictTuples:(p=(l=t.strictTuples)!==null&&l!==void 0?l:q)!==null&&p!==void 0?p:"log",strictRequired:(g=(m=t.strictRequired)!==null&&m!==void 0?m:q)!==null&&g!==void 0?g:!1,code:t.code?{...t.code,optimize:T,regExp:B}:{optimize:T,regExp:B},loopRequired:(v=t.loopRequired)!==null&&v!==void 0?v:wfe,loopEnum:(x=t.loopEnum)!==null&&x!==void 0?x:wfe,meta:(S=t.meta)!==null&&S!==void 0?S:!0,messages:(P=t.messages)!==null&&P!==void 0?P:!0,inlineRefs:(A=t.inlineRefs)!==null&&A!==void 0?A:!0,schemaId:($=t.schemaId)!==null&&$!==void 0?$:"$id",addUsedSchema:(j=t.addUsedSchema)!==null&&j!==void 0?j:!0,validateSchema:(L=t.validateSchema)!==null&&L!==void 0?L:!0,validateFormats:(F=t.validateFormats)!==null&&F!==void 0?F:!0,unicodeRegExp:(K=t.unicodeRegExp)!==null&&K!==void 0?K:!0,int32range:(W=t.int32range)!==null&&W!==void 0?W:!0,uriResolver:h}}var aS=class{constructor(e={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...iFe(e)};let{es5:r,lines:n}=this.opts.code;this.scope=new XKe.ValueScope({scope:{},prefixes:tFe,es5:r,lines:n}),this.logger=uFe(e.logger);let i=e.validateFormats;e.validateFormats=!1,this.RULES=(0,YKe.getRules)(),_fe.call(this,rFe,e,"NOT SUPPORTED"),_fe.call(this,nFe,e,"DEPRECATED","warn"),this._metaOpts=cFe.call(this),e.formats&&sFe.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&aFe.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),oFe.call(this),e.validateFormats=i}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:r,schemaId:n}=this.opts,i=bfe;n==="id"&&(i={...bfe},i.id=i.$id,delete i.$id),r&&e&&this.addMetaSchema(i,i[n],!1)}defaultMeta(){let{meta:e,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof e=="object"?e[r]||e:void 0}validate(e,r){let n;if(typeof e=="string"){if(n=this.getSchema(e),!n)throw new Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let i=n(r);return"$async"in n||(this.errors=n.errors),i}compile(e,r){let n=this._addSchema(e,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return i.call(this,e,r);async function i(c,l){await o.call(this,c.$schema);let p=this._addSchema(c,l);return p.validate||s.call(this,p)}async function o(c){c&&!this.getSchema(c)&&await i.call(this,{$ref:c},!0)}async function s(c){try{return this._compileSchemaEnv(c)}catch(l){if(!(l instanceof Efe.default))throw l;return a.call(this,l),await d.call(this,l.missingSchema),s.call(this,c)}}function a({missingSchema:c,missingRef:l}){if(this.refs[c])throw new Error(`AnySchema ${c} is loaded but ${l} cannot be resolved`)}async function d(c){let l=await u.call(this,c);this.refs[c]||await o.call(this,l.$schema),this.refs[c]||this.addSchema(l,c,r)}async function u(c){let l=this._loading[c];if(l)return l;try{return await(this._loading[c]=n(c))}finally{delete this._loading[c]}}}addSchema(e,r,n,i=this.opts.validateSchema){if(Array.isArray(e)){for(let s of e)this.addSchema(s,void 0,n,i);return this}let o;if(typeof e=="object"){let{schemaId:s}=this.opts;if(o=e[s],o!==void 0&&typeof o!="string")throw new Error(`schema ${s} must be string`)}return r=(0,sS.normalizeId)(r||o),this._checkUnique(r),this.schemas[r]=this._addSchema(e,n,r,i,!0),this}addMetaSchema(e,r,n=this.opts.validateSchema){return this.addSchema(e,r,!0,n),this}validateSchema(e,r){if(typeof e=="boolean")return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let i=this.validate(n,e);if(!i&&r){let o="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(o);else throw new Error(o)}return i}getSchema(e){let r;for(;typeof(r=xfe.call(this,e))=="string";)e=r;if(r===void 0){let{schemaId:n}=this.opts,i=new oS.SchemaEnv({schema:{},schemaId:n});if(r=oS.resolveSchema.call(this,i,e),!r)return;this.refs[e]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=xfe.call(this,e);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{let r=e;this._cache.delete(r);let n=e[this.opts.schemaId];return n&&(n=(0,sS.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(let r of e)this.addKeyword(r);return this}addKeyword(e,r){let n;if(typeof e=="string")n=e,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof e=="object"&&r===void 0){if(r=e,n=r.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(fFe.call(this,n,r),!r)return(0,DU.eachItem)(n,o=>RU.call(this,o)),this;pFe.call(this,r);let i={...r,type:(0,JP.getJSONTypes)(r.type),schemaType:(0,JP.getJSONTypes)(r.schemaType)};return(0,DU.eachItem)(n,i.type.length===0?o=>RU.call(this,o,i):o=>i.type.forEach(s=>RU.call(this,o,i,s))),this}getKeyword(e){let r=this.RULES.all[e];return typeof r=="object"?r.definition:!!r}removeKeyword(e){let{RULES:r}=this;delete r.keywords[e],delete r.all[e];for(let n of r.rules){let i=n.rules.findIndex(o=>o.keyword===e);i>=0&&n.rules.splice(i,1)}return this}addFormat(e,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[e]=r,this}errorsText(e=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!e||e.length===0?"No errors":e.map(i=>`${n}${i.instancePath} ${i.message}`).reduce((i,o)=>i+r+o)}$dataMetaSchema(e,r){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let i of r){let o=i.split("/").slice(1),s=e;for(let a of o)s=s[a];for(let a in n){let d=n[a];if(typeof d!="object")continue;let{$data:u}=d.definition,c=s[a];u&&c&&(s[a]=Afe(c))}}return e}_removeAllSchemas(e,r){for(let n in e){let i=e[n];(!r||r.test(n))&&(typeof i=="string"?delete e[n]:i&&!i.meta&&(this._cache.delete(i.schema),delete e[n]))}}_addSchema(e,r,n,i=this.opts.validateSchema,o=this.opts.addUsedSchema){let s,{schemaId:a}=this.opts;if(typeof e=="object")s=e[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof e!="boolean")throw new Error("schema must be object or boolean")}let d=this._cache.get(e);if(d!==void 0)return d;n=(0,sS.normalizeId)(s||n);let u=sS.getSchemaRefs.call(this,e,n);return d=new oS.SchemaEnv({schema:e,schemaId:a,meta:r,baseId:n,localRefs:u}),this._cache.set(d.schema,d),o&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=d),i&&this.validateSchema(e,!0),d}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):oS.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){let r=this.opts;this.opts=this._metaOpts;try{oS.compileSchema.call(this,e)}finally{this.opts=r}}};Es.default=aS;aS.ValidationError=ZKe.default;aS.MissingRefError=Efe.default;function _fe(t,e,r,n="error"){for(let i in t){let o=i;o in e&&this.logger[n](`${r}: option ${i}. ${t[o]}`)}}function xfe(t){return t=(0,sS.normalizeId)(t),this.schemas[t]||this.refs[t]}function oFe(){let t=this.opts.schemas;if(t)if(Array.isArray(t))this.addSchema(t);else for(let e in t)this.addSchema(t[e],e)}function sFe(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function aFe(t){if(Array.isArray(t)){this.addVocabulary(t);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let e in t){let r=t[e];r.keyword||(r.keyword=e),this.addKeyword(r)}}function cFe(){let t={...this.opts};for(let e of eFe)delete t[e];return t}var dFe={log(){},warn(){},error(){}};function uFe(t){if(t===!1)return dFe;if(t===void 0)return console;if(t.log&&t.warn&&t.error)return t;throw new Error("logger must implement log, warn and error methods")}var lFe=/^[a-z_$][a-z0-9_$:-]*$/i;function fFe(t,e){let{RULES:r}=this;if((0,DU.eachItem)(t,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!lFe.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!e&&e.$data&&!("code"in e||"validate"in e))throw new Error('$data keyword must have "code" or "validate" function')}function RU(t,e,r){var n;let i=e?.post;if(r&&i)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:o}=this,s=i?o.post:o.rules.find(({type:d})=>d===r);if(s||(s={type:r,rules:[]},o.rules.push(s)),o.keywords[t]=!0,!e)return;let a={keyword:t,definition:{...e,type:(0,JP.getJSONTypes)(e.type),schemaType:(0,JP.getJSONTypes)(e.schemaType)}};e.before?hFe.call(this,s,a,e.before):s.rules.push(a),o.all[t]=a,(n=e.implements)===null||n===void 0||n.forEach(d=>this.addKeyword(d))}function hFe(t,e,r){let n=t.rules.findIndex(i=>i.keyword===r);n>=0?t.rules.splice(n,0,e):(t.rules.push(e),this.logger.warn(`rule ${r} is not defined`))}function pFe(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=Afe(e)),t.validateSchema=this.compile(e,!0))}var mFe={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Afe(t){return{anyOf:[t,mFe]}}});var Pfe=V(BU=>{"use strict";f();Object.defineProperty(BU,"__esModule",{value:!0});var yFe={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};BU.default=yFe});var XP=V(bv=>{"use strict";f();Object.defineProperty(bv,"__esModule",{value:!0});bv.callRef=bv.getValidate=void 0;var gFe=HP(),Ife=Fd(),dc=rr(),h2=Kd(),kfe=iS(),ZP=Rr(),vFe={keyword:"$ref",schemaType:"string",code(t){let{gen:e,schema:r,it:n}=t,{baseId:i,schemaEnv:o,validateName:s,opts:a,self:d}=n,{root:u}=o;if((r==="#"||r==="#/")&&i===u.baseId)return l();let c=kfe.resolveRef.call(d,u,i,r);if(c===void 0)throw new gFe.default(n.opts.uriResolver,i,r);if(c instanceof kfe.SchemaEnv)return p(c);return m(c);function l(){if(o===u)return YP(t,s,o,o.$async);let g=e.scopeValue("root",{ref:u});return YP(t,(0,dc._)`${g}.validate`,u,u.$async)}function p(g){let v=Rfe(t,g);YP(t,v,g,g.$async)}function m(g){let v=e.scopeValue("schema",a.code.source===!0?{ref:g,code:(0,dc.stringify)(g)}:{ref:g}),x=e.name("valid"),S=t.subschema({schema:g,dataTypes:[],schemaPath:dc.nil,topSchemaRef:v,errSchemaPath:r},x);t.mergeEvaluated(S),t.ok(x)}}};function Rfe(t,e){let{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0,dc._)`${r.scopeValue("wrapper",{ref:e})}.validate`}bv.getValidate=Rfe;function YP(t,e,r,n){let{gen:i,it:o}=t,{allErrors:s,schemaEnv:a,opts:d}=o,u=d.passContext?h2.default.this:dc.nil;n?c():l();function c(){if(!a.$async)throw new Error("async schema referenced by sync schema");let g=i.let("valid");i.try(()=>{i.code((0,dc._)`await ${(0,Ife.callValidateCode)(t,e,u)}`),m(e),s||i.assign(g,!0)},v=>{i.if((0,dc._)`!(${v} instanceof ${o.ValidationError})`,()=>i.throw(v)),p(v),s||i.assign(g,!1)}),t.ok(g)}function l(){t.result((0,Ife.callValidateCode)(t,e,u),()=>m(e),()=>p(e))}function p(g){let v=(0,dc._)`${g}.errors`;i.assign(h2.default.vErrors,(0,dc._)`${h2.default.vErrors} === null ? ${v} : ${h2.default.vErrors}.concat(${v})`),i.assign(h2.default.errors,(0,dc._)`${h2.default.vErrors}.length`)}function m(g){var v;if(!o.opts.unevaluated)return;let x=(v=r?.validate)===null||v===void 0?void 0:v.evaluated;if(o.props!==!0)if(x&&!x.dynamicProps)x.props!==void 0&&(o.props=ZP.mergeEvaluated.props(i,x.props,o.props));else{let S=i.var("props",(0,dc._)`${g}.evaluated.props`);o.props=ZP.mergeEvaluated.props(i,S,o.props,dc.Name)}if(o.items!==!0)if(x&&!x.dynamicItems)x.items!==void 0&&(o.items=ZP.mergeEvaluated.items(i,x.items,o.items));else{let S=i.var("items",(0,dc._)`${g}.evaluated.items`);o.items=ZP.mergeEvaluated.items(i,S,o.items,dc.Name)}}}bv.callRef=YP;bv.default=vFe});var Dfe=V(MU=>{"use strict";f();Object.defineProperty(MU,"__esModule",{value:!0});var bFe=Pfe(),wFe=XP(),_Fe=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",bFe.default,wFe.default];MU.default=_Fe});var Bfe=V(OU=>{"use strict";f();Object.defineProperty(OU,"__esModule",{value:!0});var QP=rr(),my=QP.operators,eI={maximum:{okStr:"<=",ok:my.LTE,fail:my.GT},minimum:{okStr:">=",ok:my.GTE,fail:my.LT},exclusiveMaximum:{okStr:"<",ok:my.LT,fail:my.GTE},exclusiveMinimum:{okStr:">",ok:my.GT,fail:my.LTE}},xFe={message:({keyword:t,schemaCode:e})=>(0,QP.str)`must be ${eI[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,QP._)`{comparison: ${eI[t].okStr}, limit: ${e}}`},EFe={keyword:Object.keys(eI),type:"number",schemaType:"number",$data:!0,error:xFe,code(t){let{keyword:e,data:r,schemaCode:n}=t;t.fail$data((0,QP._)`${r} ${eI[e].fail} ${n} || isNaN(${r})`)}};OU.default=EFe});var Mfe=V(CU=>{"use strict";f();Object.defineProperty(CU,"__esModule",{value:!0});var cS=rr(),SFe={message:({schemaCode:t})=>(0,cS.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,cS._)`{multipleOf: ${t}}`},AFe={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:SFe,code(t){let{gen:e,data:r,schemaCode:n,it:i}=t,o=i.opts.multipleOfPrecision,s=e.let("res"),a=o?(0,cS._)`Math.abs(Math.round(${s}) - ${s}) > 1e-${o}`:(0,cS._)`${s} !== parseInt(${s})`;t.fail$data((0,cS._)`(${n} === 0 || (${s} = ${r}/${n}, ${a}))`)}};CU.default=AFe});var Cfe=V($U=>{"use strict";f();Object.defineProperty($U,"__esModule",{value:!0});function Ofe(t){let e=t.length,r=0,n=0,i;for(;n=55296&&i<=56319&&n{"use strict";f();Object.defineProperty(jU,"__esModule",{value:!0});var wv=rr(),TFe=Rr(),PFe=Cfe(),IFe={message({keyword:t,schemaCode:e}){let r=t==="maxLength"?"more":"fewer";return(0,wv.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0,wv._)`{limit: ${t}}`},kFe={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:IFe,code(t){let{keyword:e,data:r,schemaCode:n,it:i}=t,o=e==="maxLength"?wv.operators.GT:wv.operators.LT,s=i.opts.unicode===!1?(0,wv._)`${r}.length`:(0,wv._)`${(0,TFe.useFunc)(t.gen,PFe.default)}(${r})`;t.fail$data((0,wv._)`${s} ${o} ${n}`)}};jU.default=kFe});var jfe=V(NU=>{"use strict";f();Object.defineProperty(NU,"__esModule",{value:!0});var RFe=Fd(),tI=rr(),DFe={message:({schemaCode:t})=>(0,tI.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,tI._)`{pattern: ${t}}`},BFe={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:DFe,code(t){let{data:e,$data:r,schema:n,schemaCode:i,it:o}=t,s=o.opts.unicodeRegExp?"u":"",a=r?(0,tI._)`(new RegExp(${i}, ${s}))`:(0,RFe.usePattern)(t,n);t.fail$data((0,tI._)`!${a}.test(${e})`)}};NU.default=BFe});var Nfe=V(UU=>{"use strict";f();Object.defineProperty(UU,"__esModule",{value:!0});var dS=rr(),MFe={message({keyword:t,schemaCode:e}){let r=t==="maxProperties"?"more":"fewer";return(0,dS.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0,dS._)`{limit: ${t}}`},OFe={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:MFe,code(t){let{keyword:e,data:r,schemaCode:n}=t,i=e==="maxProperties"?dS.operators.GT:dS.operators.LT;t.fail$data((0,dS._)`Object.keys(${r}).length ${i} ${n}`)}};UU.default=OFe});var Ufe=V(qU=>{"use strict";f();Object.defineProperty(qU,"__esModule",{value:!0});var uS=Fd(),lS=rr(),CFe=Rr(),$Fe={message:({params:{missingProperty:t}})=>(0,lS.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,lS._)`{missingProperty: ${t}}`},jFe={keyword:"required",type:"object",schemaType:"array",$data:!0,error:$Fe,code(t){let{gen:e,schema:r,schemaCode:n,data:i,$data:o,it:s}=t,{opts:a}=s;if(!o&&r.length===0)return;let d=r.length>=a.loopRequired;if(s.allErrors?u():c(),a.strictRequired){let m=t.parentSchema.properties,{definedProperties:g}=t.it;for(let v of r)if(m?.[v]===void 0&&!g.has(v)){let x=s.schemaEnv.baseId+s.errSchemaPath,S=`required property "${v}" is not defined at "${x}" (strictRequired)`;(0,CFe.checkStrictMode)(s,S,s.opts.strictRequired)}}function u(){if(d||o)t.block$data(lS.nil,l);else for(let m of r)(0,uS.checkReportMissingProp)(t,m)}function c(){let m=e.let("missing");if(d||o){let g=e.let("valid",!0);t.block$data(g,()=>p(m,g)),t.ok(g)}else e.if((0,uS.checkMissingProp)(t,r,m)),(0,uS.reportMissingProp)(t,m),e.else()}function l(){e.forOf("prop",n,m=>{t.setParams({missingProperty:m}),e.if((0,uS.noPropertyInData)(e,i,m,a.ownProperties),()=>t.error())})}function p(m,g){t.setParams({missingProperty:m}),e.forOf(m,n,()=>{e.assign(g,(0,uS.propertyInData)(e,i,m,a.ownProperties)),e.if((0,lS.not)(g),()=>{t.error(),e.break()})},lS.nil)}}};qU.default=jFe});var qfe=V(LU=>{"use strict";f();Object.defineProperty(LU,"__esModule",{value:!0});var fS=rr(),NFe={message({keyword:t,schemaCode:e}){let r=t==="maxItems"?"more":"fewer";return(0,fS.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0,fS._)`{limit: ${t}}`},UFe={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:NFe,code(t){let{keyword:e,data:r,schemaCode:n}=t,i=e==="maxItems"?fS.operators.GT:fS.operators.LT;t.fail$data((0,fS._)`${r}.length ${i} ${n}`)}};LU.default=UFe});var rI=V(KU=>{"use strict";f();Object.defineProperty(KU,"__esModule",{value:!0});var Lfe=yU();Lfe.code='require("ajv/dist/runtime/equal").default';KU.default=Lfe});var Kfe=V(zU=>{"use strict";f();Object.defineProperty(zU,"__esModule",{value:!0});var FU=Q6(),Ss=rr(),qFe=Rr(),LFe=rI(),KFe={message:({params:{i:t,j:e}})=>(0,Ss.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,Ss._)`{i: ${t}, j: ${e}}`},FFe={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:KFe,code(t){let{gen:e,data:r,$data:n,schema:i,parentSchema:o,schemaCode:s,it:a}=t;if(!n&&!i)return;let d=e.let("valid"),u=o.items?(0,FU.getSchemaTypes)(o.items):[];t.block$data(d,c,(0,Ss._)`${s} === false`),t.ok(d);function c(){let g=e.let("i",(0,Ss._)`${r}.length`),v=e.let("j");t.setParams({i:g,j:v}),e.assign(d,!0),e.if((0,Ss._)`${g} > 1`,()=>(l()?p:m)(g,v))}function l(){return u.length>0&&!u.some(g=>g==="object"||g==="array")}function p(g,v){let x=e.name("item"),S=(0,FU.checkDataTypes)(u,x,a.opts.strictNumbers,FU.DataType.Wrong),P=e.const("indices",(0,Ss._)`{}`);e.for((0,Ss._)`;${g}--;`,()=>{e.let(x,(0,Ss._)`${r}[${g}]`),e.if(S,(0,Ss._)`continue`),u.length>1&&e.if((0,Ss._)`typeof ${x} == "string"`,(0,Ss._)`${x} += "_"`),e.if((0,Ss._)`typeof ${P}[${x}] == "number"`,()=>{e.assign(v,(0,Ss._)`${P}[${x}]`),t.error(),e.assign(d,!1).break()}).code((0,Ss._)`${P}[${x}] = ${g}`)})}function m(g,v){let x=(0,qFe.useFunc)(e,LFe.default),S=e.name("outer");e.label(S).for((0,Ss._)`;${g}--;`,()=>e.for((0,Ss._)`${v} = ${g}; ${v}--;`,()=>e.if((0,Ss._)`${x}(${r}[${g}], ${r}[${v}])`,()=>{t.error(),e.assign(d,!1).break(S)})))}}};zU.default=FFe});var Ffe=V(HU=>{"use strict";f();Object.defineProperty(HU,"__esModule",{value:!0});var WU=rr(),zFe=Rr(),WFe=rI(),HFe={message:"must be equal to constant",params:({schemaCode:t})=>(0,WU._)`{allowedValue: ${t}}`},VFe={keyword:"const",$data:!0,error:HFe,code(t){let{gen:e,data:r,$data:n,schemaCode:i,schema:o}=t;n||o&&typeof o=="object"?t.fail$data((0,WU._)`!${(0,zFe.useFunc)(e,WFe.default)}(${r}, ${i})`):t.fail((0,WU._)`${o} !== ${r}`)}};HU.default=VFe});var zfe=V(VU=>{"use strict";f();Object.defineProperty(VU,"__esModule",{value:!0});var hS=rr(),GFe=Rr(),JFe=rI(),ZFe={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,hS._)`{allowedValues: ${t}}`},YFe={keyword:"enum",schemaType:"array",$data:!0,error:ZFe,code(t){let{gen:e,data:r,$data:n,schema:i,schemaCode:o,it:s}=t;if(!n&&i.length===0)throw new Error("enum must have non-empty array");let a=i.length>=s.opts.loopEnum,d,u=()=>d??(d=(0,GFe.useFunc)(e,JFe.default)),c;if(a||n)c=e.let("valid"),t.block$data(c,l);else{if(!Array.isArray(i))throw new Error("ajv implementation error");let m=e.const("vSchema",o);c=(0,hS.or)(...i.map((g,v)=>p(m,v)))}t.pass(c);function l(){e.assign(c,!1),e.forOf("v",o,m=>e.if((0,hS._)`${u()}(${r}, ${m})`,()=>e.assign(c,!0).break()))}function p(m,g){let v=i[g];return typeof v=="object"&&v!==null?(0,hS._)`${u()}(${r}, ${m}[${g}])`:(0,hS._)`${r} === ${v}`}}};VU.default=YFe});var Wfe=V(GU=>{"use strict";f();Object.defineProperty(GU,"__esModule",{value:!0});var XFe=Bfe(),QFe=Mfe(),eze=$fe(),tze=jfe(),rze=Nfe(),nze=Ufe(),ize=qfe(),oze=Kfe(),sze=Ffe(),aze=zfe(),cze=[XFe.default,QFe.default,eze.default,tze.default,rze.default,nze.default,ize.default,oze.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},sze.default,aze.default];GU.default=cze});var ZU=V(pS=>{"use strict";f();Object.defineProperty(pS,"__esModule",{value:!0});pS.validateAdditionalItems=void 0;var _v=rr(),JU=Rr(),dze={message:({params:{len:t}})=>(0,_v.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,_v._)`{limit: ${t}}`},uze={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:dze,code(t){let{parentSchema:e,it:r}=t,{items:n}=e;if(!Array.isArray(n)){(0,JU.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}Hfe(t,n)}};function Hfe(t,e){let{gen:r,schema:n,data:i,keyword:o,it:s}=t;s.items=!0;let a=r.const("len",(0,_v._)`${i}.length`);if(n===!1)t.setParams({len:e.length}),t.pass((0,_v._)`${a} <= ${e.length}`);else if(typeof n=="object"&&!(0,JU.alwaysValidSchema)(s,n)){let u=r.var("valid",(0,_v._)`${a} <= ${e.length}`);r.if((0,_v.not)(u),()=>d(u)),t.ok(u)}function d(u){r.forRange("i",e.length,a,c=>{t.subschema({keyword:o,dataProp:c,dataPropType:JU.Type.Num},u),s.allErrors||r.if((0,_v.not)(u),()=>r.break())})}}pS.validateAdditionalItems=Hfe;pS.default=uze});var YU=V(mS=>{"use strict";f();Object.defineProperty(mS,"__esModule",{value:!0});mS.validateTuple=void 0;var Vfe=rr(),nI=Rr(),lze=Fd(),fze={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:r}=t;if(Array.isArray(e))return Gfe(t,"additionalItems",e);r.items=!0,!(0,nI.alwaysValidSchema)(r,e)&&t.ok((0,lze.validateArray)(t))}};function Gfe(t,e,r=t.schema){let{gen:n,parentSchema:i,data:o,keyword:s,it:a}=t;c(i),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=nI.mergeEvaluated.items(n,r.length,a.items));let d=n.name("valid"),u=n.const("len",(0,Vfe._)`${o}.length`);r.forEach((l,p)=>{(0,nI.alwaysValidSchema)(a,l)||(n.if((0,Vfe._)`${u} > ${p}`,()=>t.subschema({keyword:s,schemaProp:p,dataProp:p},d)),t.ok(d))});function c(l){let{opts:p,errSchemaPath:m}=a,g=r.length,v=g===l.minItems&&(g===l.maxItems||l[e]===!1);if(p.strictTuples&&!v){let x=`"${s}" is ${g}-tuple, but minItems or maxItems/${e} are not specified or different at path "${m}"`;(0,nI.checkStrictMode)(a,x,p.strictTuples)}}}mS.validateTuple=Gfe;mS.default=fze});var Jfe=V(XU=>{"use strict";f();Object.defineProperty(XU,"__esModule",{value:!0});var hze=YU(),pze={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,hze.validateTuple)(t,"items")};XU.default=pze});var Yfe=V(QU=>{"use strict";f();Object.defineProperty(QU,"__esModule",{value:!0});var Zfe=rr(),mze=Rr(),yze=Fd(),gze=ZU(),vze={message:({params:{len:t}})=>(0,Zfe.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,Zfe._)`{limit: ${t}}`},bze={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:vze,code(t){let{schema:e,parentSchema:r,it:n}=t,{prefixItems:i}=r;n.items=!0,!(0,mze.alwaysValidSchema)(n,e)&&(i?(0,gze.validateAdditionalItems)(t,i):t.ok((0,yze.validateArray)(t)))}};QU.default=bze});var Xfe=V(eq=>{"use strict";f();Object.defineProperty(eq,"__esModule",{value:!0});var Wd=rr(),iI=Rr(),wze={message:({params:{min:t,max:e}})=>e===void 0?(0,Wd.str)`must contain at least ${t} valid item(s)`:(0,Wd.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,Wd._)`{minContains: ${t}}`:(0,Wd._)`{minContains: ${t}, maxContains: ${e}}`},_ze={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:wze,code(t){let{gen:e,schema:r,parentSchema:n,data:i,it:o}=t,s,a,{minContains:d,maxContains:u}=n;o.opts.next?(s=d===void 0?1:d,a=u):s=1;let c=e.const("len",(0,Wd._)`${i}.length`);if(t.setParams({min:s,max:a}),a===void 0&&s===0){(0,iI.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&s>a){(0,iI.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,iI.alwaysValidSchema)(o,r)){let v=(0,Wd._)`${c} >= ${s}`;a!==void 0&&(v=(0,Wd._)`${v} && ${c} <= ${a}`),t.pass(v);return}o.items=!0;let l=e.name("valid");a===void 0&&s===1?m(l,()=>e.if(l,()=>e.break())):s===0?(e.let(l,!0),a!==void 0&&e.if((0,Wd._)`${i}.length > 0`,p)):(e.let(l,!1),p()),t.result(l,()=>t.reset());function p(){let v=e.name("_valid"),x=e.let("count",0);m(v,()=>e.if(v,()=>g(x)))}function m(v,x){e.forRange("i",0,c,S=>{t.subschema({keyword:"contains",dataProp:S,dataPropType:iI.Type.Num,compositeRule:!0},v),x()})}function g(v){e.code((0,Wd._)`${v}++`),a===void 0?e.if((0,Wd._)`${v} >= ${s}`,()=>e.assign(l,!0).break()):(e.if((0,Wd._)`${v} > ${a}`,()=>e.assign(l,!1).break()),s===1?e.assign(l,!0):e.if((0,Wd._)`${v} >= ${s}`,()=>e.assign(l,!0)))}}};eq.default=_ze});var oI=V(yf=>{"use strict";f();Object.defineProperty(yf,"__esModule",{value:!0});yf.validateSchemaDeps=yf.validatePropertyDeps=yf.error=void 0;var tq=rr(),xze=Rr(),yS=Fd();yf.error={message:({params:{property:t,depsCount:e,deps:r}})=>{let n=e===1?"property":"properties";return(0,tq.str)`must have ${n} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:n}})=>(0,tq._)`{property: ${t}, +})`)}catch{r=function(i){this._initNamed(i)}}return gDe(r,e),r.prototype._initNamed=function(i){e.call(this,i)},new r(this)};n1.prototype._getDecoder=function(e){return e=e||"der",this.decoders.hasOwnProperty(e)||(this.decoders[e]=this._createNamed(Mre.decoders[e])),this.decoders[e]};n1.prototype.decode=function(e,r,n){return this._getDecoder(r).decode(e,n)};n1.prototype._getEncoder=function(e){return e=e||"der",this.encoders.hasOwnProperty(e)||(this.encoders[e]=this._createNamed(Mre.encoders[e])),this.encoders[e]};n1.prototype.encode=function(e,r,n){return this._getEncoder(r).encode(e,n)}});var jre=V($re=>{f();var bDe=Ft();function Md(t){this._reporterState={obj:null,path:[],options:t||{},errors:[]}}$re.Reporter=Md;Md.prototype.isError=function(e){return e instanceof o1};Md.prototype.save=function(){var e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}};Md.prototype.restore=function(e){var r=this._reporterState;r.obj=e.obj,r.path=r.path.slice(0,e.pathLen)};Md.prototype.enterKey=function(e){return this._reporterState.path.push(e)};Md.prototype.exitKey=function(e){var r=this._reporterState;r.path=r.path.slice(0,e-1)};Md.prototype.leaveKey=function(e,r,n){var i=this._reporterState;this.exitKey(e),i.obj!==null&&(i.obj[r]=n)};Md.prototype.path=function(){return this._reporterState.path.join("/")};Md.prototype.enterObject=function(){var e=this._reporterState,r=e.obj;return e.obj={},r};Md.prototype.leaveObject=function(e){var r=this._reporterState,n=r.obj;return r.obj=e,n};Md.prototype.error=function(e){var r,n=this._reporterState,i=e instanceof o1;if(i?r=e:r=new o1(n.path.map(function(o){return"["+JSON.stringify(o)+"]"}).join(""),e.message||e,e.stack),!n.options.partial)throw r;return i||n.errors.push(r),r};Md.prototype.wrapResult=function(e){var r=this._reporterState;return r.options.partial?{result:this.isError(e)?null:e,errors:r.errors}:e};function o1(t,e){this.path=t,this.rethrow(e)}bDe(o1,Error);o1.prototype.rethrow=function(e){if(this.message=e+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,o1),!this.stack)try{throw new Error(this.message)}catch(r){this.stack=r.stack}return this}});var NO=V(jO=>{f();var wDe=Ft(),b4=s1().Reporter,RE=pn().Buffer;function zl(t,e){if(b4.call(this,e),!RE.isBuffer(t)){this.error("Input not Buffer");return}this.base=t,this.offset=0,this.length=t.length}wDe(zl,b4);jO.DecoderBuffer=zl;zl.prototype.save=function(){return{offset:this.offset,reporter:b4.prototype.save.call(this)}};zl.prototype.restore=function(e){var r=new zl(this.base);return r.offset=e.offset,r.length=this.offset,this.offset=e.offset,b4.prototype.restore.call(this,e.reporter),r};zl.prototype.isEmpty=function(){return this.offset===this.length};zl.prototype.readUInt8=function(e){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(e||"DecoderBuffer overrun")};zl.prototype.skip=function(e,r){if(!(this.offset+e<=this.length))return this.error(r||"DecoderBuffer overrun");var n=new zl(this.base);return n._reporterState=this._reporterState,n.offset=this.offset,n.length=this.offset+e,this.offset+=e,n};zl.prototype.raw=function(e){return this.base.slice(e?e.offset:this.offset,this.length)};function v4(t,e){if(Array.isArray(t))this.length=0,this.value=t.map(function(r){return r instanceof v4||(r=new v4(r,e)),this.length+=r.length,r},this);else if(typeof t=="number"){if(!(0<=t&&t<=255))return e.error("non-byte EncoderBuffer value");this.value=t,this.length=1}else if(typeof t=="string")this.value=t,this.length=RE.byteLength(t);else if(RE.isBuffer(t))this.value=t,this.length=t.length;else return e.error("Unsupported type: "+typeof t)}jO.EncoderBuffer=v4;v4.prototype.join=function(e,r){return e||(e=new RE(this.length)),r||(r=0),this.length===0||(Array.isArray(this.value)?this.value.forEach(function(n){n.join(e,r),r+=n.length}):(typeof this.value=="number"?e[r]=this.value:typeof this.value=="string"?e.write(this.value,r):RE.isBuffer(this.value)&&this.value.copy(e,r),r+=this.length)),e}});var qre=V((dwt,Ure)=>{f();var _De=s1().Reporter,xDe=s1().EncoderBuffer,EDe=s1().DecoderBuffer,Ta=Nc(),Nre=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],SDe=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(Nre),ADe=["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"];function yn(t,e){var r={};this._baseState=r,r.enc=t,r.parent=e||null,r.children=null,r.tag=null,r.args=null,r.reverseArgs=null,r.choice=null,r.optional=!1,r.any=!1,r.obj=!1,r.use=null,r.useDecoder=null,r.key=null,r.default=null,r.explicit=null,r.implicit=null,r.contains=null,r.parent||(r.children=[],this._wrap())}Ure.exports=yn;var TDe=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];yn.prototype.clone=function(){var e=this._baseState,r={};TDe.forEach(function(i){r[i]=e[i]});var n=new this.constructor(r.parent);return n._baseState=r,n};yn.prototype._wrap=function(){var e=this._baseState;SDe.forEach(function(r){this[r]=function(){var i=new this.constructor(this);return e.children.push(i),i[r].apply(i,arguments)}},this)};yn.prototype._init=function(e){var r=this._baseState;Ta(r.parent===null),e.call(this),r.children=r.children.filter(function(n){return n._baseState.parent===this},this),Ta.equal(r.children.length,1,"Root node can have only one child")};yn.prototype._useArgs=function(e){var r=this._baseState,n=e.filter(function(i){return i instanceof this.constructor},this);e=e.filter(function(i){return!(i instanceof this.constructor)},this),n.length!==0&&(Ta(r.children===null),r.children=n,n.forEach(function(i){i._baseState.parent=this},this)),e.length!==0&&(Ta(r.args===null),r.args=e,r.reverseArgs=e.map(function(i){if(typeof i!="object"||i.constructor!==Object)return i;var o={};return Object.keys(i).forEach(function(s){s==(s|0)&&(s|=0);var a=i[s];o[a]=s}),o}))};ADe.forEach(function(t){yn.prototype[t]=function(){var r=this._baseState;throw new Error(t+" not implemented for encoding: "+r.enc)}});Nre.forEach(function(t){yn.prototype[t]=function(){var r=this._baseState,n=Array.prototype.slice.call(arguments);return Ta(r.tag===null),r.tag=t,this._useArgs(n),this}});yn.prototype.use=function(e){Ta(e);var r=this._baseState;return Ta(r.use===null),r.use=e,this};yn.prototype.optional=function(){var e=this._baseState;return e.optional=!0,this};yn.prototype.def=function(e){var r=this._baseState;return Ta(r.default===null),r.default=e,r.optional=!0,this};yn.prototype.explicit=function(e){var r=this._baseState;return Ta(r.explicit===null&&r.implicit===null),r.explicit=e,this};yn.prototype.implicit=function(e){var r=this._baseState;return Ta(r.explicit===null&&r.implicit===null),r.implicit=e,this};yn.prototype.obj=function(){var e=this._baseState,r=Array.prototype.slice.call(arguments);return e.obj=!0,r.length!==0&&this._useArgs(r),this};yn.prototype.key=function(e){var r=this._baseState;return Ta(r.key===null),r.key=e,this};yn.prototype.any=function(){var e=this._baseState;return e.any=!0,this};yn.prototype.choice=function(e){var r=this._baseState;return Ta(r.choice===null),r.choice=e,this._useArgs(Object.keys(e).map(function(n){return e[n]})),this};yn.prototype.contains=function(e){var r=this._baseState;return Ta(r.use===null),r.contains=e,this};yn.prototype._decode=function(e,r){var n=this._baseState;if(n.parent===null)return e.wrapResult(n.children[0]._decode(e,r));var i=n.default,o=!0,s=null;if(n.key!==null&&(s=e.enterKey(n.key)),n.optional){var a=null;if(n.explicit!==null?a=n.explicit:n.implicit!==null?a=n.implicit:n.tag!==null&&(a=n.tag),a===null&&!n.any){var d=e.save();try{n.choice===null?this._decodeGeneric(n.tag,e,r):this._decodeChoice(e,r),o=!0}catch{o=!1}e.restore(d)}else if(o=this._peekTag(e,a,n.any),e.isError(o))return o}var u;if(n.obj&&o&&(u=e.enterObject()),o){if(n.explicit!==null){var c=this._decodeTag(e,n.explicit);if(e.isError(c))return c;e=c}var l=e.offset;if(n.use===null&&n.choice===null){if(n.any)var d=e.save();var p=this._decodeTag(e,n.implicit!==null?n.implicit:n.tag,n.any);if(e.isError(p))return p;n.any?i=e.raw(d):e=p}if(r&&r.track&&n.tag!==null&&r.track(e.path(),l,e.length,"tagged"),r&&r.track&&n.tag!==null&&r.track(e.path(),e.offset,e.length,"content"),n.any?i=i:n.choice===null?i=this._decodeGeneric(n.tag,e,r):i=this._decodeChoice(e,r),e.isError(i))return i;if(!n.any&&n.choice===null&&n.children!==null&&n.children.forEach(function(v){v._decode(e,r)}),n.contains&&(n.tag==="octstr"||n.tag==="bitstr")){var m=new EDe(i);i=this._getUse(n.contains,e._reporterState.obj)._decode(m,r)}}return n.obj&&o&&(i=e.leaveObject(u)),n.key!==null&&(i!==null||o===!0)?e.leaveKey(s,n.key,i):s!==null&&e.exitKey(s),i};yn.prototype._decodeGeneric=function(e,r,n){var i=this._baseState;return e==="seq"||e==="set"?null:e==="seqof"||e==="setof"?this._decodeList(r,e,i.args[0],n):/str$/.test(e)?this._decodeStr(r,e,n):e==="objid"&&i.args?this._decodeObjid(r,i.args[0],i.args[1],n):e==="objid"?this._decodeObjid(r,null,null,n):e==="gentime"||e==="utctime"?this._decodeTime(r,e,n):e==="null_"?this._decodeNull(r,n):e==="bool"?this._decodeBool(r,n):e==="objDesc"?this._decodeStr(r,e,n):e==="int"||e==="enum"?this._decodeInt(r,i.args&&i.args[0],n):i.use!==null?this._getUse(i.use,r._reporterState.obj)._decode(r,n):r.error("unknown tag: "+e)};yn.prototype._getUse=function(e,r){var n=this._baseState;return n.useDecoder=this._use(e,r),Ta(n.useDecoder._baseState.parent===null),n.useDecoder=n.useDecoder._baseState.children[0],n.implicit!==n.useDecoder._baseState.implicit&&(n.useDecoder=n.useDecoder.clone(),n.useDecoder._baseState.implicit=n.implicit),n.useDecoder};yn.prototype._decodeChoice=function(e,r){var n=this._baseState,i=null,o=!1;return Object.keys(n.choice).some(function(s){var a=e.save(),d=n.choice[s];try{var u=d._decode(e,r);if(e.isError(u))return!1;i={type:s,value:u},o=!0}catch{return e.restore(a),!1}return!0},this),o?i:e.error("Choice not matched")};yn.prototype._createEncoderBuffer=function(e){return new xDe(e,this.reporter)};yn.prototype._encode=function(e,r,n){var i=this._baseState;if(!(i.default!==null&&i.default===e)){var o=this._encodeValue(e,r,n);if(o!==void 0&&!this._skipDefault(o,r,n))return o}};yn.prototype._encodeValue=function(e,r,n){var i=this._baseState;if(i.parent===null)return i.children[0]._encode(e,r||new _De);var d=null;if(this.reporter=r,i.optional&&e===void 0)if(i.default!==null)e=i.default;else return;var o=null,s=!1;if(i.any)d=this._createEncoderBuffer(e);else if(i.choice)d=this._encodeChoice(e,r);else if(i.contains)o=this._getUse(i.contains,n)._encode(e,r),s=!0;else if(i.children)o=i.children.map(function(l){if(l._baseState.tag==="null_")return l._encode(null,r,e);if(l._baseState.key===null)return r.error("Child should have a key");var p=r.enterKey(l._baseState.key);if(typeof e!="object")return r.error("Child expected, but input is not object");var m=l._encode(e[l._baseState.key],r,e);return r.leaveKey(p),m},this).filter(function(l){return l}),o=this._createEncoderBuffer(o);else if(i.tag==="seqof"||i.tag==="setof"){if(!(i.args&&i.args.length===1))return r.error("Too many args for : "+i.tag);if(!Array.isArray(e))return r.error("seqof/setof, but data is not Array");var a=this.clone();a._baseState.implicit=null,o=this._createEncoderBuffer(e.map(function(l){var p=this._baseState;return this._getUse(p.args[0],e)._encode(l,r)},a))}else i.use!==null?d=this._getUse(i.use,n)._encode(e,r):(o=this._encodePrimitive(i.tag,e),s=!0);var d;if(!i.any&&i.choice===null){var u=i.implicit!==null?i.implicit:i.tag,c=i.implicit===null?"universal":"context";u===null?i.use===null&&r.error("Tag could be omitted only for .use()"):i.use===null&&(d=this._encodeComposite(u,s,c,o))}return i.explicit!==null&&(d=this._encodeComposite(i.explicit,!1,"context",d)),d};yn.prototype._encodeChoice=function(e,r){var n=this._baseState,i=n.choice[e.type];return i||Ta(!1,e.type+" not found in "+JSON.stringify(Object.keys(n.choice))),i._encode(e.value,r)};yn.prototype._encodePrimitive=function(e,r){var n=this._baseState;if(/str$/.test(e))return this._encodeStr(r,e);if(e==="objid"&&n.args)return this._encodeObjid(r,n.reverseArgs[0],n.args[1]);if(e==="objid")return this._encodeObjid(r,null,null);if(e==="gentime"||e==="utctime")return this._encodeTime(r,e);if(e==="null_")return this._encodeNull();if(e==="int"||e==="enum")return this._encodeInt(r,n.args&&n.reverseArgs[0]);if(e==="bool")return this._encodeBool(r);if(e==="objDesc")return this._encodeStr(r,e);throw new Error("Unsupported tag: "+e)};yn.prototype._isNumstr=function(e){return/^[0-9 ]*$/.test(e)};yn.prototype._isPrintstr=function(e){return/^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(e)}});var s1=V(Lre=>{f();var w4=Lre;w4.Reporter=jre().Reporter;w4.DecoderBuffer=NO().DecoderBuffer;w4.EncoderBuffer=NO().EncoderBuffer;w4.Node=qre()});var Fre=V(Ag=>{f();var Kre=UO();Ag.tagClass={0:"universal",1:"application",2:"context",3:"private"};Ag.tagClassByName=Kre._reverse(Ag.tagClass);Ag.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"};Ag.tagByName=Kre._reverse(Ag.tag)});var UO=V(Wre=>{f();var zre=Wre;zre._reverse=function(e){var r={};return Object.keys(e).forEach(function(n){(n|0)==n&&(n=n|0);var i=e[n];r[i]=n}),r};zre.der=Fre()});var KO=V((gwt,Jre)=>{f();var PDe=Ft(),qO=i1(),_4=qO.base,IDe=qO.bignum,Hre=qO.constants.der;function Vre(t){this.enc="der",this.name=t.name,this.entity=t,this.tree=new qc,this.tree._init(t.body)}Jre.exports=Vre;Vre.prototype.decode=function(e,r){return e instanceof _4.DecoderBuffer||(e=new _4.DecoderBuffer(e,r)),this.tree._decode(e,r)};function qc(t){_4.Node.call(this,"der",t)}PDe(qc,_4.Node);qc.prototype._peekTag=function(e,r,n){if(e.isEmpty())return!1;var i=e.save(),o=LO(e,'Failed to peek tag: "'+r+'"');return e.isError(o)?o:(e.restore(i),o.tag===r||o.tagStr===r||o.tagStr+"of"===r||n)};qc.prototype._decodeTag=function(e,r,n){var i=LO(e,'Failed to decode tag of "'+r+'"');if(e.isError(i))return i;var o=Gre(e,i.primitive,'Failed to get length of "'+r+'"');if(e.isError(o))return o;if(!n&&i.tag!==r&&i.tagStr!==r&&i.tagStr+"of"!==r)return e.error('Failed to match tag: "'+r+'"');if(i.primitive||o!==null)return e.skip(o,'Failed to match body of: "'+r+'"');var s=e.save(),a=this._skipUntilEnd(e,'Failed to skip indefinite length body: "'+this.tag+'"');return e.isError(a)?a:(o=e.offset-s.offset,e.restore(s),e.skip(o,'Failed to match body of: "'+r+'"'))};qc.prototype._skipUntilEnd=function(e,r){for(;;){var n=LO(e,r);if(e.isError(n))return n;var i=Gre(e,n.primitive,r);if(e.isError(i))return i;var o;if(n.primitive||i!==null?o=e.skip(i):o=this._skipUntilEnd(e,r),e.isError(o))return o;if(n.tagStr==="end")break}};qc.prototype._decodeList=function(e,r,n,i){for(var o=[];!e.isEmpty();){var s=this._peekTag(e,"end");if(e.isError(s))return s;var a=n.decode(e,"der",i);if(e.isError(a)&&s)break;o.push(a)}return o};qc.prototype._decodeStr=function(e,r){if(r==="bitstr"){var n=e.readUInt8();return e.isError(n)?n:{unused:n,data:e.raw()}}else if(r==="bmpstr"){var i=e.raw();if(i.length%2===1)return e.error("Decoding of string type: bmpstr length mismatch");for(var o="",s=0;s>6],i=(r&32)===0;if((r&31)===31){var o=r;for(r=0;(o&128)===128;){if(o=t.readUInt8(e),t.isError(o))return o;r<<=7,r|=o&127}}else r&=31;var s=Hre.tag[r];return{cls:n,primitive:i,tag:r,tagStr:s}}function Gre(t,e,r){var n=t.readUInt8(r);if(t.isError(n))return n;if(!e&&n===128)return null;if(!(n&128))return n;var i=n&127;if(i>4)return t.error("length octect is too long");n=0;for(var o=0;o{f();var kDe=Ft(),RDe=pn().Buffer,FO=KO();function zO(t){FO.call(this,t),this.enc="pem"}kDe(zO,FO);Zre.exports=zO;zO.prototype.decode=function(e,r){for(var n=e.toString().split(/[\r\n]+/g),i=r.label.toUpperCase(),o=/^-----(BEGIN|END) ([^-]+)-----$/,s=-1,a=-1,d=0;d{f();var Xre=Qre;Xre.der=KO();Xre.pem=Yre()});var HO=V((Ewt,ine)=>{f();var DDe=Ft(),Ah=pn().Buffer,tne=i1(),rne=tne.base,WO=tne.constants.der;function nne(t){this.enc="der",this.name=t.name,this.entity=t,this.tree=new Du,this.tree._init(t.body)}ine.exports=nne;nne.prototype.encode=function(e,r){return this.tree._encode(e,r).join()};function Du(t){rne.Node.call(this,"der",t)}DDe(Du,rne.Node);Du.prototype._encodeComposite=function(e,r,n,i){var o=BDe(e,r,n,this.reporter);if(i.length<128){var d=new Ah(2);return d[0]=o,d[1]=i.length,this._createEncoderBuffer([d,i])}for(var s=1,a=i.length;a>=256;a>>=8)s++;var d=new Ah(2+s);d[0]=o,d[1]=128|s;for(var a=1+s,u=i.length;u>0;a--,u>>=8)d[a]=u&255;return this._createEncoderBuffer([d,i])};Du.prototype._encodeStr=function(e,r){if(r==="bitstr")return this._createEncoderBuffer([e.unused|0,e.data]);if(r==="bmpstr"){for(var n=new Ah(e.length*2),i=0;i=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,e[0]*40+e[1])}for(var o=0,i=0;i=128;s>>=7)o++}for(var a=new Ah(o),d=a.length-1,i=e.length-1;i>=0;i--){var s=e[i];for(a[d--]=s&127;(s>>=7)>0;)a[d--]=128|s&127}return this._createEncoderBuffer(a)};function Od(t){return t<10?"0"+t:t}Du.prototype._encodeTime=function(e,r){var n,i=new Date(e);return r==="gentime"?n=[Od(i.getFullYear()),Od(i.getUTCMonth()+1),Od(i.getUTCDate()),Od(i.getUTCHours()),Od(i.getUTCMinutes()),Od(i.getUTCSeconds()),"Z"].join(""):r==="utctime"?n=[Od(i.getFullYear()%100),Od(i.getUTCMonth()+1),Od(i.getUTCDate()),Od(i.getUTCHours()),Od(i.getUTCMinutes()),Od(i.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+r+" time is not supported yet"),this._encodeStr(n,"octstr")};Du.prototype._encodeNull=function(){return this._createEncoderBuffer("")};Du.prototype._encodeInt=function(e,r){if(typeof e=="string"){if(!r)return this.reporter.error("String int or enum given, but no values map");if(!r.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=r[e]}if(typeof e!="number"&&!Ah.isBuffer(e)){var n=e.toArray();!e.sign&&n[0]&128&&n.unshift(0),e=new Ah(n)}if(Ah.isBuffer(e)){var i=e.length;e.length===0&&i++;var s=new Ah(i);return e.copy(s),e.length===0&&(s[0]=0),this._createEncoderBuffer(s)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);for(var i=1,o=e;o>=256;o>>=8)i++;for(var s=new Array(i),o=s.length-1;o>=0;o--)s[o]=e&255,e>>=8;return s[0]&128&&s.unshift(0),this._createEncoderBuffer(new Ah(s))};Du.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)};Du.prototype._use=function(e,r){return typeof e=="function"&&(e=e(r)),e._getEncoder("der").tree};Du.prototype._skipDefault=function(e,r,n){var i=this._baseState,o;if(i.default===null)return!1;var s=e.join();if(i.defaultBuffer===void 0&&(i.defaultBuffer=this._encodeValue(i.default,r,n).join()),s.length!==i.defaultBuffer.length)return!1;for(o=0;o=31?n.error("Multi-octet tag encoding unsupported"):(e||(i|=32),i|=WO.tagClassByName[r||"universal"]<<6,i)}});var sne=V((Awt,one)=>{f();var MDe=Ft(),VO=HO();function GO(t){VO.call(this,t),this.enc="pem"}MDe(GO,VO);one.exports=GO;GO.prototype.encode=function(e,r){for(var n=VO.prototype.encode.call(this,e),i=n.toString("base64"),o=["-----BEGIN "+r.label+"-----"],s=0;s{f();var ane=cne;ane.der=HO();ane.pem=sne()});var i1=V(une=>{f();var a1=une;a1.bignum=Mo();a1.define=Cre().define;a1.base=s1();a1.constants=UO();a1.decoders=ene();a1.encoders=dne()});var pne=V((Dwt,hne)=>{"use strict";f();var Bu=i1(),lne=Bu.define("Time",function(){this.choice({utcTime:this.utctime(),generalTime:this.gentime()})}),ODe=Bu.define("AttributeTypeValue",function(){this.seq().obj(this.key("type").objid(),this.key("value").any())}),JO=Bu.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional(),this.key("curve").objid().optional())}),CDe=Bu.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(JO),this.key("subjectPublicKey").bitstr())}),$De=Bu.define("RelativeDistinguishedName",function(){this.setof(ODe)}),jDe=Bu.define("RDNSequence",function(){this.seqof($De)}),fne=Bu.define("Name",function(){this.choice({rdnSequence:this.use(jDe)})}),NDe=Bu.define("Validity",function(){this.seq().obj(this.key("notBefore").use(lne),this.key("notAfter").use(lne))}),UDe=Bu.define("Extension",function(){this.seq().obj(this.key("extnID").objid(),this.key("critical").bool().def(!1),this.key("extnValue").octstr())}),qDe=Bu.define("TBSCertificate",function(){this.seq().obj(this.key("version").explicit(0).int().optional(),this.key("serialNumber").int(),this.key("signature").use(JO),this.key("issuer").use(fne),this.key("validity").use(NDe),this.key("subject").use(fne),this.key("subjectPublicKeyInfo").use(CDe),this.key("issuerUniqueID").implicit(1).bitstr().optional(),this.key("subjectUniqueID").implicit(2).bitstr().optional(),this.key("extensions").explicit(3).seqof(UDe).optional())}),LDe=Bu.define("X509Certificate",function(){this.seq().obj(this.key("tbsCertificate").use(qDe),this.key("signatureAlgorithm").use(JO),this.key("signatureValue").bitstr())});hne.exports=LDe});var yne=V(Ou=>{"use strict";f();var Mu=i1();Ou.certificate=pne();var KDe=Mu.define("RSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("modulus").int(),this.key("publicExponent").int(),this.key("privateExponent").int(),this.key("prime1").int(),this.key("prime2").int(),this.key("exponent1").int(),this.key("exponent2").int(),this.key("coefficient").int())});Ou.RSAPrivateKey=KDe;var FDe=Mu.define("RSAPublicKey",function(){this.seq().obj(this.key("modulus").int(),this.key("publicExponent").int())});Ou.RSAPublicKey=FDe;var mne=Mu.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("none").null_().optional(),this.key("curve").objid().optional(),this.key("params").seq().obj(this.key("p").int(),this.key("q").int(),this.key("g").int()).optional())}),zDe=Mu.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(mne),this.key("subjectPublicKey").bitstr())});Ou.PublicKey=zDe;var WDe=Mu.define("PrivateKeyInfo",function(){this.seq().obj(this.key("version").int(),this.key("algorithm").use(mne),this.key("subjectPrivateKey").octstr())});Ou.PrivateKey=WDe;var HDe=Mu.define("EncryptedPrivateKeyInfo",function(){this.seq().obj(this.key("algorithm").seq().obj(this.key("id").objid(),this.key("decrypt").seq().obj(this.key("kde").seq().obj(this.key("id").objid(),this.key("kdeparams").seq().obj(this.key("salt").octstr(),this.key("iters").int())),this.key("cipher").seq().obj(this.key("algo").objid(),this.key("iv").octstr()))),this.key("subjectPrivateKey").octstr())});Ou.EncryptedPrivateKey=HDe;var VDe=Mu.define("DSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("p").int(),this.key("q").int(),this.key("g").int(),this.key("pub_key").int(),this.key("priv_key").int())});Ou.DSAPrivateKey=VDe;Ou.DSAparam=Mu.define("DSAparam",function(){this.int()});var GDe=Mu.define("ECParameters",function(){this.choice({namedCurve:this.objid()})}),JDe=Mu.define("ECPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").optional().explicit(0).use(GDe),this.key("publicKey").optional().explicit(1).bitstr())});Ou.ECPrivateKey=JDe;Ou.signature=Mu.define("signature",function(){this.seq().obj(this.key("r").int(),this.key("s").int())})});var gne=V((Cwt,ZDe)=>{ZDe.exports={"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"}});var bne=V(($wt,vne)=>{"use strict";f();var YDe=/Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r+/=]+)[\n\r]+/m,XDe=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m,QDe=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m,e9e=hE(),t9e=NA(),x4=cr().Buffer;vne.exports=function(t,e){var r=t.toString(),n=r.match(YDe),i;if(n){var s="aes"+n[1],a=x4.from(n[2],"hex"),d=x4.from(n[3].replace(/[\r\n]/g,""),"base64"),u=e9e(e,a.slice(0,8),parseInt(n[1],10)).key,c=[],l=t9e.createDecipheriv(s,u,a);c.push(l.update(d)),c.push(l.final()),i=x4.concat(c)}else{var o=r.match(QDe);i=x4.from(o[2].replace(/[\r\n]/g,""),"base64")}var p=r.match(XDe)[1];return{tag:p,data:i}}});var DE=V((Nwt,_ne)=>{"use strict";f();var tc=yne(),r9e=gne(),n9e=bne(),i9e=NA(),o9e=vM(),ZO=cr().Buffer;function s9e(t,e){var r=t.algorithm.decrypt.kde.kdeparams.salt,n=parseInt(t.algorithm.decrypt.kde.kdeparams.iters.toString(),10),i=r9e[t.algorithm.decrypt.cipher.algo.join(".")],o=t.algorithm.decrypt.cipher.iv,s=t.subjectPrivateKey,a=parseInt(i.split("-")[1],10)/8,d=o9e.pbkdf2Sync(e,r,n,a,"sha1"),u=i9e.createDecipheriv(i,d,o),c=[];return c.push(u.update(s)),c.push(u.final()),ZO.concat(c)}function wne(t){var e;typeof t=="object"&&!ZO.isBuffer(t)&&(e=t.passphrase,t=t.key),typeof t=="string"&&(t=ZO.from(t));var r=n9e(t,e),n=r.tag,i=r.data,o,s;switch(n){case"CERTIFICATE":s=tc.certificate.decode(i,"der").tbsCertificate.subjectPublicKeyInfo;case"PUBLIC KEY":switch(s||(s=tc.PublicKey.decode(i,"der")),o=s.algorithm.algorithm.join("."),o){case"1.2.840.113549.1.1.1":return tc.RSAPublicKey.decode(s.subjectPublicKey.data,"der");case"1.2.840.10045.2.1":return s.subjectPrivateKey=s.subjectPublicKey,{type:"ec",data:s};case"1.2.840.10040.4.1":return s.algorithm.params.pub_key=tc.DSAparam.decode(s.subjectPublicKey.data,"der"),{type:"dsa",data:s.algorithm.params};default:throw new Error("unknown key id "+o)}case"ENCRYPTED PRIVATE KEY":i=tc.EncryptedPrivateKey.decode(i,"der"),i=s9e(i,e);case"PRIVATE KEY":switch(s=tc.PrivateKey.decode(i,"der"),o=s.algorithm.algorithm.join("."),o){case"1.2.840.113549.1.1.1":return tc.RSAPrivateKey.decode(s.subjectPrivateKey,"der");case"1.2.840.10045.2.1":return{curve:s.algorithm.curve,privateKey:tc.ECPrivateKey.decode(s.subjectPrivateKey,"der").privateKey};case"1.2.840.10040.4.1":return s.algorithm.params.priv_key=tc.DSAparam.decode(s.subjectPrivateKey,"der"),{type:"dsa",params:s.algorithm.params};default:throw new Error("unknown key id "+o)}case"RSA PUBLIC KEY":return tc.RSAPublicKey.decode(i,"der");case"RSA PRIVATE KEY":return tc.RSAPrivateKey.decode(i,"der");case"DSA PRIVATE KEY":return{type:"dsa",params:tc.DSAPrivateKey.decode(i,"der")};case"EC PRIVATE KEY":return i=tc.ECPrivateKey.decode(i,"der"),{curve:i.parameters.value,privateKey:i.privateKey};default:throw new Error("unknown key type "+n)}}wne.signature=tc.signature;_ne.exports=wne});var YO=V((qwt,a9e)=>{a9e.exports={"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"}});var Sne=V((Lwt,S4)=>{"use strict";f();var Xs=cr().Buffer,Tg=cM(),c9e=e4(),d9e=g4().ec,E4=QA(),u9e=DE(),l9e=YO(),f9e=1;function h9e(t,e,r,n,i){var o=u9e(e);if(o.curve){if(n!=="ecdsa"&&n!=="ecdsa/rsa")throw new Error("wrong private key type");return p9e(t,o)}else if(o.type==="dsa"){if(n!=="dsa")throw new Error("wrong private key type");return m9e(t,o,r)}if(n!=="rsa"&&n!=="ecdsa/rsa")throw new Error("wrong private key type");if(e.padding!==void 0&&e.padding!==f9e)throw new Error("illegal or unsupported padding mode");t=Xs.concat([i,t]);for(var s=o.modulus.byteLength(),a=[0,1];t.length+a.length+10&&r.ishrn(n),r}function g9e(t,e){t=XO(t,e),t=t.mod(e);var r=Xs.from(t.toArray());if(r.length{"use strict";f();var QO=cr().Buffer,BE=QA(),b9e=g4().ec,Tne=DE(),w9e=YO();function _9e(t,e,r,n,i){var o=Tne(r);if(o.type==="ec"){if(n!=="ecdsa"&&n!=="ecdsa/rsa")throw new Error("wrong public key type");return x9e(t,e,o)}else if(o.type==="dsa"){if(n!=="dsa")throw new Error("wrong public key type");return E9e(t,e,o)}if(n!=="rsa"&&n!=="ecdsa/rsa")throw new Error("wrong public key type");e=QO.concat([i,e]);for(var s=o.modulus.byteLength(),a=[1],d=0;e.length+a.length+2=0)throw new Error("invalid sig")}Pne.exports=_9e});var One=V((Wwt,Mne)=>{"use strict";f();var A4=cr().Buffer,Dne=Mw(),T4=ite(),Bne=Ft(),S9e=Sne(),A9e=Ine(),Pg=dM();Object.keys(Pg).forEach(function(t){Pg[t].id=A4.from(Pg[t].id,"hex"),Pg[t.toLowerCase()]=Pg[t]});function ME(t){T4.Writable.call(this);var e=Pg[t];if(!e)throw new Error("Unknown message digest");this._hashType=e.hash,this._hash=Dne(e.hash),this._tag=e.id,this._signType=e.sign}Bne(ME,T4.Writable);ME.prototype._write=function(e,r,n){this._hash.update(e),n()};ME.prototype.update=function(e,r){return this._hash.update(typeof e=="string"?A4.from(e,r):e),this};ME.prototype.sign=function(e,r){this.end();var n=this._hash.digest(),i=S9e(n,e,this._hashType,this._signType,this._tag);return r?i.toString(r):i};function OE(t){T4.Writable.call(this);var e=Pg[t];if(!e)throw new Error("Unknown message digest");this._hash=Dne(e.hash),this._tag=e.id,this._signType=e.sign}Bne(OE,T4.Writable);OE.prototype._write=function(e,r,n){this._hash.update(e),n()};OE.prototype.update=function(e,r){return this._hash.update(typeof e=="string"?A4.from(e,r):e),this};OE.prototype.verify=function(e,r,n){var i=typeof r=="string"?A4.from(r,n):r;this.end();var o=this._hash.digest();return A9e(i,o,e,this._signType,this._tag)};function kne(t){return new ME(t)}function Rne(t){return new OE(t)}Mne.exports={Sign:kne,Verify:Rne,createSign:kne,createVerify:Rne}});var $ne=V((Vwt,Cne)=>{f();var T9e=g4(),P9e=Mo();Cne.exports=function(e){return new Ig(e)};var Lc={secp256k1:{name:"secp256k1",byteLength:32},secp224r1:{name:"p224",byteLength:28},prime256v1:{name:"p256",byteLength:32},prime192v1:{name:"p192",byteLength:24},ed25519:{name:"ed25519",byteLength:32},secp384r1:{name:"p384",byteLength:48},secp521r1:{name:"p521",byteLength:66}};Lc.p224=Lc.secp224r1;Lc.p256=Lc.secp256r1=Lc.prime256v1;Lc.p192=Lc.secp192r1=Lc.prime192v1;Lc.p384=Lc.secp384r1;Lc.p521=Lc.secp521r1;function Ig(t){this.curveType=Lc[t],this.curveType||(this.curveType={name:t}),this.curve=new T9e.ec(this.curveType.name),this.keys=void 0}Ig.prototype.generateKeys=function(t,e){return this.keys=this.curve.genKeyPair(),this.getPublicKey(t,e)};Ig.prototype.computeSecret=function(t,e,r){e=e||"utf8",O.Buffer.isBuffer(t)||(t=new O.Buffer(t,e));var n=this.curve.keyFromPublic(t).getPublic(),i=n.mul(this.keys.getPrivate()).getX();return eC(i,r,this.curveType.byteLength)};Ig.prototype.getPublicKey=function(t,e){var r=this.keys.getPublic(e==="compressed",!0);return e==="hybrid"&&(r[r.length-1]%2?r[0]=7:r[0]=6),eC(r,t)};Ig.prototype.getPrivateKey=function(t){return eC(this.keys.getPrivate(),t)};Ig.prototype.setPublicKey=function(t,e){return e=e||"utf8",O.Buffer.isBuffer(t)||(t=new O.Buffer(t,e)),this.keys._importPublic(t),this};Ig.prototype.setPrivateKey=function(t,e){e=e||"utf8",O.Buffer.isBuffer(t)||(t=new O.Buffer(t,e));var r=new P9e(t);return r=r.toString(16),this.keys=this.curve.genKeyPair(),this.keys._importPrivate(r),this};function eC(t,e,r){Array.isArray(t)||(t=t.toArray());var n=new O.Buffer(t);if(r&&n.length{f();var I9e=Mw(),tC=cr().Buffer;jne.exports=function(t,e){for(var r=tC.alloc(0),n=0,i;r.length{f();Nne.exports=function(e,r){for(var n=e.length,i=-1;++i{f();var Une=Mo(),R9e=cr().Buffer;function D9e(t,e){return R9e.from(t.toRed(Une.mont(e.modulus)).redPow(new Une(e.publicExponent)).fromRed().toArray())}qne.exports=D9e});var zne=V((t1t,Fne)=>{f();var B9e=DE(),oC=tg(),M9e=Mw(),Lne=rC(),Kne=nC(),sC=Mo(),O9e=iC(),C9e=e4(),Cu=cr().Buffer;Fne.exports=function(e,r,n){var i;e.padding?i=e.padding:n?i=1:i=4;var o=B9e(e),s;if(i===4)s=$9e(o,r);else if(i===1)s=j9e(o,r,n);else if(i===3){if(s=new sC(r),s.cmp(o.modulus)>=0)throw new Error("data too long for modulus")}else throw new Error("unknown padding");return n?C9e(s,o):O9e(s,o)};function $9e(t,e){var r=t.modulus.byteLength(),n=e.length,i=M9e("sha1").update(Cu.alloc(0)).digest(),o=i.length,s=2*o;if(n>r-s-2)throw new Error("message too long");var a=Cu.alloc(r-n-s-2),d=r-o-1,u=oC(o),c=Kne(Cu.concat([i,a,Cu.alloc(1,1),e],d),Lne(u,d)),l=Kne(u,Lne(c,o));return new sC(Cu.concat([Cu.alloc(1),l,c],r))}function j9e(t,e,r){var n=e.length,i=t.modulus.byteLength();if(n>i-11)throw new Error("message too long");var o;return r?o=Cu.alloc(i-n-3,255):o=N9e(i-n-3),new sC(Cu.concat([Cu.from([0,r?1:2]),o,Cu.alloc(1),e],i))}function N9e(t){for(var e=Cu.allocUnsafe(t),r=0,n=oC(t*2),i=0,o;r{f();var U9e=DE(),Wne=rC(),Hne=nC(),Vne=Mo(),q9e=e4(),L9e=Mw(),K9e=iC(),CE=cr().Buffer;Gne.exports=function(e,r,n){var i;e.padding?i=e.padding:n?i=1:i=4;var o=U9e(e),s=o.modulus.byteLength();if(r.length>s||new Vne(r).cmp(o.modulus)>=0)throw new Error("decryption error");var a;n?a=K9e(new Vne(r),o):a=q9e(r,o);var d=CE.alloc(s-a.length);if(a=CE.concat([d,a],s),i===4)return F9e(o,a);if(i===1)return z9e(o,a,n);if(i===3)return a;throw new Error("unknown padding")};function F9e(t,e){var r=t.modulus.byteLength(),n=L9e("sha1").update(CE.alloc(0)).digest(),i=n.length;if(e[0]!==0)throw new Error("decryption error");var o=e.slice(1,i+1),s=e.slice(i+1),a=Hne(o,Wne(s,i)),d=Hne(s,Wne(a,r-i-1));if(W9e(n,d.slice(0,i)))throw new Error("decryption error");for(var u=i;d[u]===0;)u++;if(d[u++]!==1)throw new Error("decryption error");return d.slice(u)}function z9e(t,e,r){for(var n=e.slice(0,2),i=2,o=0;e[i++]!==0;)if(i>=e.length){o++;break}var s=e.slice(2,i-1);if((n.toString("hex")!=="0002"&&!r||n.toString("hex")!=="0001"&&r)&&o++,s.length<8&&o++,o)throw new Error("decryption error");return e.slice(i)}function W9e(t,e){t=CE.from(t),e=CE.from(e);var r=0,n=t.length;t.length!==e.length&&(r++,n=Math.min(t.length,e.length));for(var i=-1;++i{f();kg.publicEncrypt=zne();kg.privateDecrypt=Jne();kg.privateEncrypt=function(e,r){return kg.publicEncrypt(e,r,!0)};kg.publicDecrypt=function(e,r){return kg.privateDecrypt(e,r,!0)}});var sie=V($E=>{"use strict";f();function Yne(){throw new Error(`secure random number generation not supported by this browser +use chrome, FireFox or Internet Explorer 11`)}var Qne=cr(),Xne=tg(),eie=Qne.Buffer,tie=Qne.kMaxLength,aC=globalThis.crypto||globalThis.msCrypto,rie=Math.pow(2,32)-1;function nie(t,e){if(typeof t!="number"||t!==t)throw new TypeError("offset must be a number");if(t>rie||t<0)throw new TypeError("offset must be a uint32");if(t>tie||t>e)throw new RangeError("offset out of range")}function iie(t,e,r){if(typeof t!="number"||t!==t)throw new TypeError("size must be a number");if(t>rie||t<0)throw new TypeError("size must be a uint32");if(t+e>r||t>tie)throw new RangeError("buffer too small")}aC&&aC.getRandomValues||!k.default.browser?($E.randomFill=H9e,$E.randomFillSync=V9e):($E.randomFill=Yne,$E.randomFillSync=Yne);function H9e(t,e,r,n){if(!eie.isBuffer(t)&&!(t instanceof globalThis.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if(typeof e=="function")n=e,e=0,r=t.length;else if(typeof r=="function")n=r,r=t.length-e;else if(typeof n!="function")throw new TypeError('"cb" argument must be a function');return nie(e,t.length),iie(r,e,t.length),oie(t,e,r,n)}function oie(t,e,r,n){if(k.default.browser){var i=t.buffer,o=new Uint8Array(i,e,r);if(aC.getRandomValues(o),n){k.default.nextTick(function(){n(null,t)});return}return t}if(n){Xne(r,function(a,d){if(a)return n(a);d.copy(t,e),n(null,t)});return}var s=Xne(r);return s.copy(t,e),t}function V9e(t,e,r){if(typeof e>"u"&&(e=0),!eie.isBuffer(t)&&!(t instanceof globalThis.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');return nie(e,t.length),r===void 0&&(r=t.length-e),iie(r,e,t.length),oie(t,e,r)}});var qA=V(dr=>{"use strict";f();dr.randomBytes=dr.rng=dr.pseudoRandomBytes=dr.prng=tg();dr.createHash=dr.Hash=Mw();dr.createHmac=dr.Hmac=cM();var G9e=OX(),J9e=Object.keys(G9e),Z9e=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(J9e);dr.getHashes=function(){return Z9e};var aie=vM();dr.pbkdf2=aie.pbkdf2;dr.pbkdf2Sync=aie.pbkdf2Sync;var Wl=ree();dr.Cipher=Wl.Cipher;dr.createCipher=Wl.createCipher;dr.Cipheriv=Wl.Cipheriv;dr.createCipheriv=Wl.createCipheriv;dr.Decipher=Wl.Decipher;dr.createDecipher=Wl.createDecipher;dr.Decipheriv=Wl.Decipheriv;dr.createDecipheriv=Wl.createDecipheriv;dr.getCiphers=Wl.getCiphers;dr.listCiphers=Wl.listCiphers;var jE=mee();dr.DiffieHellmanGroup=jE.DiffieHellmanGroup;dr.createDiffieHellmanGroup=jE.createDiffieHellmanGroup;dr.getDiffieHellman=jE.getDiffieHellman;dr.createDiffieHellman=jE.createDiffieHellman;dr.DiffieHellman=jE.DiffieHellman;var P4=One();dr.createSign=P4.createSign;dr.Sign=P4.Sign;dr.createVerify=P4.createVerify;dr.Verify=P4.Verify;dr.createECDH=$ne();var I4=Zne();dr.publicEncrypt=I4.publicEncrypt;dr.privateEncrypt=I4.privateEncrypt;dr.publicDecrypt=I4.publicDecrypt;dr.privateDecrypt=I4.privateDecrypt;var cie=sie();dr.randomFill=cie.randomFill;dr.randomFillSync=cie.randomFillSync;dr.createCredentials=function(){throw new Error(["sorry, createCredentials is not implemented yet","we accept pull requests","https://github.com/crypto-browserify/crypto-browserify"].join(` +`))};dr.constants={DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8,NPN_ENABLED:1,ALPN_ENABLED:1,RSA_PKCS1_PADDING:1,RSA_SSLV23_PADDING:2,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_X931_PADDING:5,RSA_PKCS1_PSS_PADDING:6,POINT_CONVERSION_COMPRESSED:2,POINT_CONVERSION_UNCOMPRESSED:4,POINT_CONVERSION_HYBRID:6}});var $u=V(ur=>{"use strict";f();Object.defineProperty(ur,"__esModule",{value:!0});ur.setBigUint64=ur.Hash=ur.equalBytes=ur.ensureBytes=ur.checkOpts=ur.concatBytes=ur.toBytes=ur.bytesToUtf8=ur.utf8ToBytes=ur.asyncLoop=ur.nextTick=ur.hexToBytes=ur.bytesToHex=ur.isLE=ur.createView=ur.u32=ur.u16=ur.u8=void 0;var dC=t=>t instanceof Uint8Array,Y9e=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);ur.u8=Y9e;var X9e=t=>new Uint16Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/2));ur.u16=X9e;var Q9e=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));ur.u32=Q9e;var eBe=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);ur.createView=eBe;ur.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!ur.isLE)throw new Error("Non little-endian hardware is not supported");var tBe=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function rBe(t){if(!dC(t))throw new Error("Uint8Array expected");let e="";for(let r=0;r{};ur.nextTick=iBe;async function oBe(t,e,r){let n=Date.now();for(let i=0;i=0&&on+i.length,0)),r=0;return t.forEach(n=>{if(!dC(n))throw new Error("Uint8Array expected");e.set(n,r),r+=n.length}),e}ur.concatBytes=cBe;var dBe=t=>Object.prototype.toString.call(t)==="[object Object]"&&t.constructor===Object;function uBe(t,e){if(e!==void 0&&(typeof e!="object"||!dBe(e)))throw new Error("options must be object or undefined");return Object.assign(t,e)}ur.checkOpts=uBe;function lBe(t,e){if(!(t instanceof Uint8Array))throw new Error("Uint8Array expected");if(typeof e=="number"&&t.length!==e)throw new Error(`Uint8Array length ${e} expected`)}ur.ensureBytes=lBe;function fBe(t,e){if(t.length!==e.length)throw new Error("equalBytes: Different size of Uint8Arrays");let r=!0;for(let n=0;n>i&o),a=Number(r&o),d=n?4:0,u=n?0:4;t.setUint32(e+d,s,n),t.setUint32(e+u,a,n)}ur.setBigUint64=hBe});var NE=V(Qs=>{"use strict";f();Object.defineProperty(Qs,"__esModule",{value:!0});Qs.AEAD_TAG_LENGTH=Qs.XCHACHA20_NONCE_LENGTH=Qs.CURVE25519_PUBLIC_KEY_SIZE=Qs.ETH_PUBLIC_KEY_SIZE=Qs.UNCOMPRESSED_PUBLIC_KEY_SIZE=Qs.COMPRESSED_PUBLIC_KEY_SIZE=Qs.SECRET_KEY_LENGTH=void 0;Qs.SECRET_KEY_LENGTH=32;Qs.COMPRESSED_PUBLIC_KEY_SIZE=33;Qs.UNCOMPRESSED_PUBLIC_KEY_SIZE=65;Qs.ETH_PUBLIC_KEY_SIZE=64;Qs.CURVE25519_PUBLIC_KEY_SIZE=32;Qs.XCHACHA20_NONCE_LENGTH=24;Qs.AEAD_TAG_LENGTH=16});var Rg=V(Gn=>{"use strict";f();Object.defineProperty(Gn,"__esModule",{value:!0});Gn.ephemeralKeySize=Gn.symmetricNonceLength=Gn.symmetricAlgorithm=Gn.isHkdfKeyCompressed=Gn.isEphemeralKeyCompressed=Gn.ellipticCurve=Gn.ECIES_CONFIG=void 0;var k4=NE(),pBe=function(){function t(){this.ellipticCurve="secp256k1",this.isEphemeralKeyCompressed=!1,this.isHkdfKeyCompressed=!1,this.symmetricAlgorithm="aes-256-gcm",this.symmetricNonceLength=16}return t}();Gn.ECIES_CONFIG=new pBe;var mBe=function(){return Gn.ECIES_CONFIG.ellipticCurve};Gn.ellipticCurve=mBe;var yBe=function(){return Gn.ECIES_CONFIG.isEphemeralKeyCompressed};Gn.isEphemeralKeyCompressed=yBe;var gBe=function(){return Gn.ECIES_CONFIG.isHkdfKeyCompressed};Gn.isHkdfKeyCompressed=gBe;var vBe=function(){return Gn.ECIES_CONFIG.symmetricAlgorithm};Gn.symmetricAlgorithm=vBe;var bBe=function(){return Gn.ECIES_CONFIG.symmetricNonceLength};Gn.symmetricNonceLength=bBe;var wBe=function(){var t={secp256k1:Gn.ECIES_CONFIG.isEphemeralKeyCompressed?k4.COMPRESSED_PUBLIC_KEY_SIZE:k4.UNCOMPRESSED_PUBLIC_KEY_SIZE,x25519:k4.CURVE25519_PUBLIC_KEY_SIZE,ed25519:k4.CURVE25519_PUBLIC_KEY_SIZE};if(Gn.ECIES_CONFIG.ellipticCurve in t)return t[Gn.ECIES_CONFIG.ellipticCurve];throw new Error("Not implemented")};Gn.ephemeralKeySize=wBe});var uie=V(R4=>{"use strict";f();Object.defineProperty(R4,"__esModule",{value:!0});R4.crypto=void 0;R4.crypto=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0});var uC=V(c1=>{"use strict";f();Object.defineProperty(c1,"__esModule",{value:!0});c1.getWebcryptoSubtle=c1.randomBytes=void 0;var Dg=uie();function _Be(t=32){if(Dg.crypto&&typeof Dg.crypto.getRandomValues=="function")return Dg.crypto.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}c1.randomBytes=_Be;function xBe(){if(Dg.crypto&&typeof Dg.crypto.subtle=="object"&&Dg.crypto.subtle!=null)return Dg.crypto.subtle;throw new Error("crypto.subtle must be defined")}c1.getWebcryptoSubtle=xBe});var fC=V(Pa=>{"use strict";f();Object.defineProperty(Pa,"__esModule",{value:!0});Pa.output=Pa.exists=Pa.hash=Pa.bytes=Pa.bool=Pa.number=void 0;function D4(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}Pa.number=D4;function lie(t){if(typeof t!="boolean")throw new Error(`Expected boolean, not ${t}`)}Pa.bool=lie;function EBe(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function lC(t,...e){if(!EBe(t))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}Pa.bytes=lC;function fie(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");D4(t.outputLen),D4(t.blockLen)}Pa.hash=fie;function hie(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")}Pa.exists=hie;function pie(t,e){lC(t);let r=e.outputLen;if(t.length{"use strict";f();Object.defineProperty(B4,"__esModule",{value:!0});B4.crypto=void 0;B4.crypto=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0});var Pm=V(lr=>{"use strict";f();Object.defineProperty(lr,"__esModule",{value:!0});lr.randomBytes=lr.wrapXOFConstructorWithOpts=lr.wrapConstructorWithOpts=lr.wrapConstructor=lr.checkOpts=lr.Hash=lr.concatBytes=lr.toBytes=lr.utf8ToBytes=lr.asyncLoop=lr.nextTick=lr.hexToBytes=lr.bytesToHex=lr.isLE=lr.rotr=lr.createView=lr.u32=lr.u8=void 0;var hC=mie(),ABe=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);lr.u8=ABe;var TBe=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));lr.u32=TBe;function mC(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}var PBe=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);lr.createView=PBe;var IBe=(t,e)=>t<<32-e|t>>>e;lr.rotr=IBe;lr.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!lr.isLE)throw new Error("Non little-endian hardware is not supported");var kBe=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function RBe(t){if(!mC(t))throw new Error("Uint8Array expected");let e="";for(let r=0;r=Th._0&&t<=Th._9)return t-Th._0;if(t>=Th._A&&t<=Th._F)return t-(Th._A-10);if(t>=Th._a&&t<=Th._f)return t-(Th._a-10)}function DBe(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let i=0,o=0;i{};lr.nextTick=BBe;async function MBe(t,e,r){let n=Date.now();for(let i=0;i=0&&ot().update(M4(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}lr.wrapConstructor=jBe;function NBe(t){let e=(n,i)=>t(i).update(M4(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}lr.wrapConstructorWithOpts=NBe;function UBe(t){let e=(n,i)=>t(i).update(M4(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}lr.wrapXOFConstructorWithOpts=UBe;function qBe(t=32){if(hC.crypto&&typeof hC.crypto.getRandomValues=="function")return hC.crypto.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}lr.randomBytes=qBe});var vC=V(O4=>{"use strict";f();Object.defineProperty(O4,"__esModule",{value:!0});O4.SHA2=void 0;var yC=fC(),UE=Pm();function LBe(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),d=n?4:0,u=n?0:4;t.setUint32(e+d,s,n),t.setUint32(e+u,a,n)}var gC=class extends UE.Hash{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=(0,UE.createView)(this.buffer)}update(e){(0,yC.exists)(this);let{view:r,buffer:n,blockLen:i}=this;e=(0,UE.toBytes)(e);let o=e.length;for(let s=0;si-s&&(this.process(n,0),s=0);for(let l=s;lc.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l{"use strict";f();Object.defineProperty(Ot,"__esModule",{value:!0});Ot.add5L=Ot.add5H=Ot.add4H=Ot.add4L=Ot.add3H=Ot.add3L=Ot.add=Ot.rotlBL=Ot.rotlBH=Ot.rotlSL=Ot.rotlSH=Ot.rotr32L=Ot.rotr32H=Ot.rotrBL=Ot.rotrBH=Ot.rotrSL=Ot.rotrSH=Ot.shrSL=Ot.shrSH=Ot.toBig=Ot.split=Ot.fromBig=void 0;var C4=BigInt(2**32-1),bC=BigInt(32);function wC(t,e=!1){return e?{h:Number(t&C4),l:Number(t>>bC&C4)}:{h:Number(t>>bC&C4)|0,l:Number(t&C4)|0}}Ot.fromBig=wC;function vie(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;iBigInt(t>>>0)<>>0);Ot.toBig=bie;var wie=(t,e,r)=>t>>>r;Ot.shrSH=wie;var _ie=(t,e,r)=>t<<32-r|e>>>r;Ot.shrSL=_ie;var xie=(t,e,r)=>t>>>r|e<<32-r;Ot.rotrSH=xie;var Eie=(t,e,r)=>t<<32-r|e>>>r;Ot.rotrSL=Eie;var Sie=(t,e,r)=>t<<64-r|e>>>r-32;Ot.rotrBH=Sie;var Aie=(t,e,r)=>t>>>r-32|e<<64-r;Ot.rotrBL=Aie;var Tie=(t,e)=>e;Ot.rotr32H=Tie;var Pie=(t,e)=>t;Ot.rotr32L=Pie;var Iie=(t,e,r)=>t<>>32-r;Ot.rotlSH=Iie;var kie=(t,e,r)=>e<>>32-r;Ot.rotlSL=kie;var Rie=(t,e,r)=>e<>>64-r;Ot.rotlBH=Rie;var Die=(t,e,r)=>t<>>64-r;Ot.rotlBL=Die;function Bie(t,e,r,n){let i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}Ot.add=Bie;var Mie=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0);Ot.add3L=Mie;var Oie=(t,e,r,n)=>e+r+n+(t/2**32|0)|0;Ot.add3H=Oie;var Cie=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0);Ot.add4L=Cie;var $ie=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0;Ot.add4H=$ie;var jie=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0);Ot.add5L=jie;var Nie=(t,e,r,n,i,o)=>e+r+n+i+o+(t/2**32|0)|0;Ot.add5H=Nie;var KBe={fromBig:wC,split:vie,toBig:bie,shrSH:wie,shrSL:_ie,rotrSH:xie,rotrSL:Eie,rotrBH:Sie,rotrBL:Aie,rotr32H:Tie,rotr32L:Pie,rotlSH:Iie,rotlSL:kie,rotlBH:Rie,rotlBL:Die,add:Bie,add3L:Mie,add3H:Oie,add4L:Cie,add4H:$ie,add5H:Nie,add5L:jie};Ot.default=KBe});var qie=V(Cd=>{"use strict";f();Object.defineProperty(Cd,"__esModule",{value:!0});Cd.sha384=Cd.sha512_256=Cd.sha512_224=Cd.sha512=Cd.SHA512=void 0;var FBe=vC(),fr=Uie(),$4=Pm(),[zBe,WBe]=fr.default.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),Im=new Uint32Array(80),km=new Uint32Array(80),Bg=class extends FBe.SHA2{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:r,Bh:n,Bl:i,Ch:o,Cl:s,Dh:a,Dl:d,Eh:u,El:c,Fh:l,Fl:p,Gh:m,Gl:g,Hh:v,Hl:x}=this;return[e,r,n,i,o,s,a,d,u,c,l,p,m,g,v,x]}set(e,r,n,i,o,s,a,d,u,c,l,p,m,g,v,x){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=o|0,this.Cl=s|0,this.Dh=a|0,this.Dl=d|0,this.Eh=u|0,this.El=c|0,this.Fh=l|0,this.Fl=p|0,this.Gh=m|0,this.Gl=g|0,this.Hh=v|0,this.Hl=x|0}process(e,r){for(let A=0;A<16;A++,r+=4)Im[A]=e.getUint32(r),km[A]=e.getUint32(r+=4);for(let A=16;A<80;A++){let $=Im[A-15]|0,j=km[A-15]|0,q=fr.default.rotrSH($,j,1)^fr.default.rotrSH($,j,8)^fr.default.shrSH($,j,7),F=fr.default.rotrSL($,j,1)^fr.default.rotrSL($,j,8)^fr.default.shrSL($,j,7),K=Im[A-2]|0,W=km[A-2]|0,L=fr.default.rotrSH(K,W,19)^fr.default.rotrBH(K,W,61)^fr.default.shrSH(K,W,6),I=fr.default.rotrSL(K,W,19)^fr.default.rotrBL(K,W,61)^fr.default.shrSL(K,W,6),T=fr.default.add4L(F,I,km[A-7],km[A-16]),B=fr.default.add4H(T,q,L,Im[A-7],Im[A-16]);Im[A]=B|0,km[A]=T|0}let{Ah:n,Al:i,Bh:o,Bl:s,Ch:a,Cl:d,Dh:u,Dl:c,Eh:l,El:p,Fh:m,Fl:g,Gh:v,Gl:x,Hh:S,Hl:P}=this;for(let A=0;A<80;A++){let $=fr.default.rotrSH(l,p,14)^fr.default.rotrSH(l,p,18)^fr.default.rotrBH(l,p,41),j=fr.default.rotrSL(l,p,14)^fr.default.rotrSL(l,p,18)^fr.default.rotrBL(l,p,41),q=l&m^~l&v,F=p&g^~p&x,K=fr.default.add5L(P,j,F,WBe[A],km[A]),W=fr.default.add5H(K,S,$,q,zBe[A],Im[A]),L=K|0,I=fr.default.rotrSH(n,i,28)^fr.default.rotrBH(n,i,34)^fr.default.rotrBH(n,i,39),T=fr.default.rotrSL(n,i,28)^fr.default.rotrBL(n,i,34)^fr.default.rotrBL(n,i,39),B=n&o^n&a^o&a,h=i&s^i&d^s&d;S=v|0,P=x|0,v=m|0,x=g|0,m=l|0,g=p|0,{h:l,l:p}=fr.default.add(u|0,c|0,W|0,L|0),u=a|0,c=d|0,a=o|0,d=s|0,o=n|0,s=i|0;let y=fr.default.add3L(L,T,h);n=fr.default.add3H(y,W,I,B),i=y|0}({h:n,l:i}=fr.default.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:o,l:s}=fr.default.add(this.Bh|0,this.Bl|0,o|0,s|0),{h:a,l:d}=fr.default.add(this.Ch|0,this.Cl|0,a|0,d|0),{h:u,l:c}=fr.default.add(this.Dh|0,this.Dl|0,u|0,c|0),{h:l,l:p}=fr.default.add(this.Eh|0,this.El|0,l|0,p|0),{h:m,l:g}=fr.default.add(this.Fh|0,this.Fl|0,m|0,g|0),{h:v,l:x}=fr.default.add(this.Gh|0,this.Gl|0,v|0,x|0),{h:S,l:P}=fr.default.add(this.Hh|0,this.Hl|0,S|0,P|0),this.set(n,i,o,s,a,d,u,c,l,p,m,g,v,x,S,P)}roundClean(){Im.fill(0),km.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};Cd.SHA512=Bg;var _C=class extends Bg{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}},xC=class extends Bg{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}},EC=class extends Bg{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}};Cd.sha512=(0,$4.wrapConstructor)(()=>new Bg);Cd.sha512_224=(0,$4.wrapConstructor)(()=>new _C);Cd.sha512_256=(0,$4.wrapConstructor)(()=>new xC);Cd.sha384=(0,$4.wrapConstructor)(()=>new EC)});var ju=V(Qt=>{"use strict";f();Object.defineProperty(Qt,"__esModule",{value:!0});Qt.validateObject=Qt.createHmacDrbg=Qt.bitMask=Qt.bitSet=Qt.bitGet=Qt.bitLen=Qt.utf8ToBytes=Qt.equalBytes=Qt.concatBytes=Qt.ensureBytes=Qt.numberToVarBytesBE=Qt.numberToBytesLE=Qt.numberToBytesBE=Qt.bytesToNumberLE=Qt.bytesToNumberBE=Qt.hexToBytes=Qt.hexToNumber=Qt.numberToHexUnpadded=Qt.bytesToHex=Qt.isBytes=void 0;var Fie=BigInt(0),j4=BigInt(1),HBe=BigInt(2);function d1(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}Qt.isBytes=d1;var VBe=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function AC(t){if(!d1(t))throw new Error("Uint8Array expected");let e="";for(let r=0;r=Ph._0&&t<=Ph._9)return t-Ph._0;if(t>=Ph._A&&t<=Ph._F)return t-(Ph._A-10);if(t>=Ph._a&&t<=Ph._f)return t-(Ph._a-10)}function N4(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let i=0,o=0;iFie;t>>=j4,e+=1);return e}Qt.bitLen=t7e;function r7e(t,e){return t>>BigInt(e)&j4}Qt.bitGet=r7e;var n7e=(t,e,r)=>t|(r?j4:Fie)<(HBe<new Uint8Array(t),Kie=t=>Uint8Array.from(t);function o7e(t,e,r){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=SC(t),i=SC(t),o=0,s=()=>{n.fill(1),i.fill(0),o=0},a=(...l)=>r(i,n,...l),d=(l=SC())=>{i=a(Kie([0]),l),n=a(),l.length!==0&&(i=a(Kie([1]),l),n=a())},u=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,p=[];for(;l{s(),d(l);let m;for(;!(m=p(u()));)d();return s(),m}}Qt.createHmacDrbg=o7e;var s7e={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||d1(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function a7e(t,e,r={}){let n=(i,o,s)=>{let a=s7e[o];if(typeof a!="function")throw new Error(`Invalid validator "${o}", expected function`);let d=t[i];if(!(s&&d===void 0)&&!a(d,t))throw new Error(`Invalid param ${String(i)}=${d} (${typeof d}), expected ${o}`)};for(let[i,o]of Object.entries(e))n(i,o,!1);for(let[i,o]of Object.entries(r))n(i,o,!0);return t}Qt.validateObject=a7e});var Dm=V(er=>{"use strict";f();Object.defineProperty(er,"__esModule",{value:!0});er.mapHashToField=er.getMinHashLength=er.getFieldBytesLength=er.hashToPrivateScalar=er.FpSqrtEven=er.FpSqrtOdd=er.Field=er.nLength=er.FpIsSquare=er.FpDiv=er.FpInvertBatch=er.FpPow=er.validateField=er.isNegativeLE=er.FpSqrt=er.tonelliShanks=er.invert=er.pow2=er.pow=er.mod=void 0;var Fc=ju(),no=BigInt(0),Tn=BigInt(1),Rm=BigInt(2),c7e=BigInt(3),PC=BigInt(4),Vie=BigInt(5),Gie=BigInt(8),d7e=BigInt(9),u7e=BigInt(16);function Kc(t,e){let r=t%e;return r>=no?r:e+r}er.mod=Kc;function Jie(t,e,r){if(r<=no||e 0");if(r===Tn)return no;let n=Tn;for(;e>no;)e&Tn&&(n=n*t%r),t=t*t%r,e>>=Tn;return n}er.pow=Jie;function l7e(t,e,r){let n=t;for(;e-- >no;)n*=n,n%=r;return n}er.pow2=l7e;function U4(t,e){if(t===no||e<=no)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=Kc(t,e),n=e,i=no,o=Tn,s=Tn,a=no;for(;r!==no;){let u=n/r,c=n%r,l=i-s*u,p=o-a*u;n=r,r=c,i=s,o=a,s=l,a=p}if(n!==Tn)throw new Error("invert: does not exist");return Kc(i,e)}er.invert=U4;function Zie(t){let e=(t-Tn)/Rm,r,n,i;for(r=t-Tn,n=0;r%Rm===no;r/=Rm,n++);for(i=Rm;i(Kc(t,e)&Tn)===Tn;er.isNegativeLE=f7e;var h7e=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function p7e(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=h7e.reduce((n,i)=>(n[i]="function",n),e);return(0,Fc.validateObject)(t,r)}er.validateField=p7e;function Xie(t,e,r){if(r 0");if(r===no)return t.ONE;if(r===Tn)return e;let n=t.ONE,i=e;for(;r>no;)r&Tn&&(n=t.mul(n,i)),i=t.sqr(i),r>>=Tn;return n}er.FpPow=Xie;function Qie(t,e){let r=new Array(e.length),n=e.reduce((o,s,a)=>t.is0(s)?o:(r[a]=o,t.mul(o,s)),t.ONE),i=t.inv(n);return e.reduceRight((o,s,a)=>t.is0(s)?o:(r[a]=t.mul(o,r[a]),t.mul(o,s)),i),r}er.FpInvertBatch=Qie;function m7e(t,e,r){return t.mul(e,typeof r=="bigint"?U4(r,t.ORDER):t.inv(r))}er.FpDiv=m7e;function y7e(t){let e=(t.ORDER-Tn)/Rm;return r=>{let n=t.pow(r,e);return t.eql(n,t.ZERO)||t.eql(n,t.ONE)}}er.FpIsSquare=y7e;function IC(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}er.nLength=IC;function g7e(t,e,r=!1,n={}){if(t<=no)throw new Error(`Expected Field ORDER > 0, got ${t}`);let{nBitLength:i,nByteLength:o}=IC(t,e);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=Yie(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:o,MASK:(0,Fc.bitMask)(i),ZERO:no,ONE:Tn,create:d=>Kc(d,t),isValid:d=>{if(typeof d!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof d}`);return no<=d&&dd===no,isOdd:d=>(d&Tn)===Tn,neg:d=>Kc(-d,t),eql:(d,u)=>d===u,sqr:d=>Kc(d*d,t),add:(d,u)=>Kc(d+u,t),sub:(d,u)=>Kc(d-u,t),mul:(d,u)=>Kc(d*u,t),pow:(d,u)=>Xie(a,d,u),div:(d,u)=>Kc(d*U4(u,t),t),sqrN:d=>d*d,addN:(d,u)=>d+u,subN:(d,u)=>d-u,mulN:(d,u)=>d*u,inv:d=>U4(d,t),sqrt:n.sqrt||(d=>s(a,d)),invertBatch:d=>Qie(a,d),cmov:(d,u,c)=>c?u:d,toBytes:d=>r?(0,Fc.numberToBytesLE)(d,o):(0,Fc.numberToBytesBE)(d,o),fromBytes:d=>{if(d.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${d.length}`);return r?(0,Fc.bytesToNumberLE)(d):(0,Fc.bytesToNumberBE)(d)}});return Object.freeze(a)}er.Field=g7e;function v7e(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");let r=t.sqrt(e);return t.isOdd(r)?r:t.neg(r)}er.FpSqrtOdd=v7e;function b7e(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");let r=t.sqrt(e);return t.isOdd(r)?t.neg(r):r}er.FpSqrtEven=b7e;function w7e(t,e,r=!1){t=(0,Fc.ensureBytes)("privateHash",t);let n=t.length,i=IC(e).nByteLength+8;if(i<24||n1024)throw new Error(`hashToPrivateScalar: expected ${i}-1024 bytes of input, got ${n}`);let o=r?(0,Fc.bytesToNumberLE)(t):(0,Fc.bytesToNumberBE)(t);return Kc(o,e-Tn)+Tn}er.hashToPrivateScalar=w7e;function kC(t){if(typeof t!="bigint")throw new Error("field order must be bigint");let e=t.toString(2).length;return Math.ceil(e/8)}er.getFieldBytesLength=kC;function eoe(t){let e=kC(t);return e+Math.ceil(e/2)}er.getMinHashLength=eoe;function _7e(t,e,r=!1){let n=t.length,i=kC(e),o=eoe(e);if(n<16||n1024)throw new Error(`expected ${o}-1024 bytes of input, got ${n}`);let s=r?(0,Fc.bytesToNumberBE)(t):(0,Fc.bytesToNumberLE)(t),a=Kc(s,e-Tn)+Tn;return r?(0,Fc.numberToBytesLE)(a,i):(0,Fc.numberToBytesBE)(a,i)}er.mapHashToField=_7e});var DC=V(u1=>{"use strict";f();Object.defineProperty(u1,"__esModule",{value:!0});u1.validateBasic=u1.wNAF=void 0;var toe=Dm(),x7e=ju(),E7e=BigInt(0),RC=BigInt(1);function S7e(t,e){let r=(i,o)=>{let s=o.negate();return i?s:o},n=i=>{let o=Math.ceil(e/i)+1,s=2**(i-1);return{windows:o,windowSize:s}};return{constTimeNegate:r,unsafeLadder(i,o){let s=t.ZERO,a=i;for(;o>E7e;)o&RC&&(s=s.add(a)),a=a.double(),o>>=RC;return s},precomputeWindow(i,o){let{windows:s,windowSize:a}=n(o),d=[],u=i,c=u;for(let l=0;l>=m,x>d&&(x-=p,s+=RC);let S=v,P=v+Math.abs(x)-1,A=g%2!==0,$=x<0;x===0?c=c.add(r(A,o[S])):u=u.add(r($,o[P]))}return{p:u,f:c}},wNAFCached(i,o,s,a){let d=i._WINDOW_SIZE||1,u=o.get(i);return u||(u=this.precomputeWindow(i,d),d!==1&&o.set(i,a(u))),this.wNAF(d,u,s)}}}u1.wNAF=S7e;function A7e(t){return(0,toe.validateField)(t.Fp),(0,x7e.validateObject)(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,toe.nLength)(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}u1.validateBasic=A7e});var noe=V(L4=>{"use strict";f();Object.defineProperty(L4,"__esModule",{value:!0});L4.twistedEdwards=void 0;var T7e=Dm(),Ih=ju(),Bm=ju(),roe=DC(),Nu=BigInt(0),zc=BigInt(1),q4=BigInt(2),P7e=BigInt(8),I7e={zip215:!0};function k7e(t){let e=(0,roe.validateBasic)(t);return Ih.validateObject(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function R7e(t){let e=k7e(t),{Fp:r,n,prehash:i,hash:o,randomBytes:s,nByteLength:a,h:d}=e,u=q4<{try{return{isValid:!0,value:r.sqrt(_*r.inv(b))}}catch{return{isValid:!1,value:Nu}}}),p=e.adjustScalarBytes||(_=>_),m=e.domain||((_,b,C)=>{if(b.length||C)throw new Error("Contexts/pre-hash are not supported");return _}),g=_=>typeof _=="bigint"&&Nu<_,v=(_,b)=>g(_)&&g(b)&&__===Nu||v(_,u);function S(_,b){if(v(_,b))return _;throw new Error(`Expected valid scalar < ${b}, got ${typeof _} ${_}`)}function P(_){return _===Nu?_:S(_,n)}let A=new Map;function $(_){if(!(_ instanceof j))throw new Error("ExtendedPoint expected")}class j{constructor(b,C,N,M){if(this.ex=b,this.ey=C,this.ez=N,this.et=M,!x(b))throw new Error("x required");if(!x(C))throw new Error("y required");if(!x(N))throw new Error("z required");if(!x(M))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(b){if(b instanceof j)throw new Error("extended point not allowed");let{x:C,y:N}=b||{};if(!x(C)||!x(N))throw new Error("invalid affine point");return new j(C,N,zc,c(C*N))}static normalizeZ(b){let C=r.invertBatch(b.map(N=>N.ez));return b.map((N,M)=>N.toAffine(C[M])).map(j.fromAffine)}_setWindowSize(b){this._WINDOW_SIZE=b,A.delete(this)}assertValidity(){let{a:b,d:C}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:N,ey:M,ez:U,et:G}=this,Z=c(N*N),J=c(M*M),H=c(U*U),X=c(H*H),te=c(Z*b),ne=c(H*c(te+J)),Q=c(X+c(C*c(Z*J)));if(ne!==Q)throw new Error("bad point: equation left != right (1)");let re=c(N*M),ce=c(U*G);if(re!==ce)throw new Error("bad point: equation left != right (2)")}equals(b){$(b);let{ex:C,ey:N,ez:M}=this,{ex:U,ey:G,ez:Z}=b,J=c(C*Z),H=c(U*M),X=c(N*Z),te=c(G*M);return J===H&&X===te}is0(){return this.equals(j.ZERO)}negate(){return new j(c(-this.ex),this.ey,this.ez,c(-this.et))}double(){let{a:b}=e,{ex:C,ey:N,ez:M}=this,U=c(C*C),G=c(N*N),Z=c(q4*c(M*M)),J=c(b*U),H=C+N,X=c(c(H*H)-U-G),te=J+G,ne=te-Z,Q=J-G,re=c(X*ne),ce=c(te*Q),pe=c(X*Q),ye=c(ne*te);return new j(re,ce,ye,pe)}add(b){$(b);let{a:C,d:N}=e,{ex:M,ey:U,ez:G,et:Z}=this,{ex:J,ey:H,ez:X,et:te}=b;if(C===BigInt(-1)){let Et=c((U-M)*(H+J)),Fe=c((U+M)*(H-J)),mt=c(Fe-Et);if(mt===Nu)return this.double();let Sn=c(G*q4*te),ke=c(Z*q4*X),Pe=ke+Sn,Wt=Fe+Et,Be=ke-Sn,Ee=c(Pe*mt),$r=c(Wt*Be),Ve=c(Pe*Be),Ze=c(mt*Wt);return new j(Ee,$r,Ze,Ve)}let ne=c(M*J),Q=c(U*H),re=c(Z*N*te),ce=c(G*X),pe=c((M+U)*(J+H)-ne-Q),ye=ce-re,ie=ce+re,he=c(Q-C*ne),me=c(pe*ye),Re=c(ie*he),xe=c(pe*he),it=c(ye*ie);return new j(me,Re,it,xe)}subtract(b){return this.add(b.negate())}wNAF(b){return K.wNAFCached(this,A,b,j.normalizeZ)}multiply(b){let{p:C,f:N}=this.wNAF(S(b,n));return j.normalizeZ([C,N])[0]}multiplyUnsafe(b){let C=P(b);return C===Nu?F:this.equals(F)||C===zc?this:this.equals(q)?this.wNAF(C).p:K.unsafeLadder(this,C)}isSmallOrder(){return this.multiplyUnsafe(d).is0()}isTorsionFree(){return K.unsafeLadder(this,n).is0()}toAffine(b){let{ex:C,ey:N,ez:M}=this,U=this.is0();b==null&&(b=U?P7e:r.inv(M));let G=c(C*b),Z=c(N*b),J=c(M*b);if(U)return{x:Nu,y:zc};if(J!==zc)throw new Error("invZ was invalid");return{x:G,y:Z}}clearCofactor(){let{h:b}=e;return b===zc?this:this.multiplyUnsafe(b)}static fromHex(b,C=!1){let{d:N,a:M}=e,U=r.BYTES;b=(0,Bm.ensureBytes)("pointHex",b,U);let G=b.slice(),Z=b[U-1];G[U-1]=Z&-129;let J=Ih.bytesToNumberLE(G);J===Nu||(C?S(J,u):S(J,r.ORDER));let H=c(J*J),X=c(H-zc),te=c(N*H-M),{isValid:ne,value:Q}=l(X,te);if(!ne)throw new Error("Point.fromHex: invalid y coordinate");let re=(Q&zc)===zc,ce=(Z&128)!==0;if(!C&&Q===Nu&&ce)throw new Error("Point.fromHex: x=0 and x_0=1");return ce!==re&&(Q=c(-Q)),j.fromAffine({x:Q,y:J})}static fromPrivateKey(b){return I(b).point}toRawBytes(){let{x:b,y:C}=this.toAffine(),N=Ih.numberToBytesLE(C,r.BYTES);return N[N.length-1]|=b&zc?128:0,N}toHex(){return Ih.bytesToHex(this.toRawBytes())}}j.BASE=new j(e.Gx,e.Gy,zc,c(e.Gx*e.Gy)),j.ZERO=new j(Nu,zc,zc,Nu);let{BASE:q,ZERO:F}=j,K=(0,roe.wNAF)(j,a*8);function W(_){return(0,T7e.mod)(_,n)}function L(_){return W(Ih.bytesToNumberLE(_))}function I(_){let b=a;_=(0,Bm.ensureBytes)("private key",_,b);let C=(0,Bm.ensureBytes)("hashed private key",o(_),2*b),N=p(C.slice(0,b)),M=C.slice(b,2*b),U=L(N),G=q.multiply(U),Z=G.toRawBytes();return{head:N,prefix:M,scalar:U,point:G,pointBytes:Z}}function T(_){return I(_).pointBytes}function B(_=new Uint8Array,...b){let C=Ih.concatBytes(...b);return L(o(m(C,(0,Bm.ensureBytes)("context",_),!!i)))}function h(_,b,C={}){_=(0,Bm.ensureBytes)("message",_),i&&(_=i(_));let{prefix:N,scalar:M,pointBytes:U}=I(b),G=B(C.context,N,_),Z=q.multiply(G).toRawBytes(),J=B(C.context,Z,U,_),H=W(G+J*M);P(H);let X=Ih.concatBytes(Z,Ih.numberToBytesLE(H,r.BYTES));return(0,Bm.ensureBytes)("result",X,a*2)}let y=I7e;function w(_,b,C,N=y){let{context:M,zip215:U}=N,G=r.BYTES;_=(0,Bm.ensureBytes)("signature",_,2*G),b=(0,Bm.ensureBytes)("message",b),i&&(b=i(b));let Z=Ih.bytesToNumberLE(_.slice(G,2*G)),J,H,X;try{J=j.fromHex(C,U),H=j.fromHex(_.slice(0,G),U),X=q.multiplyUnsafe(Z)}catch{return!1}if(!U&&J.isSmallOrder())return!1;let te=B(M,H.toRawBytes(),J.toRawBytes(),b);return H.add(J.multiplyUnsafe(te)).subtract(X).clearCofactor().equals(j.ZERO)}return q._setWindowSize(8),{CURVE:e,getPublicKey:T,sign:h,verify:w,ExtendedPoint:j,utils:{getExtendedPublicKey:I,randomPrivateKey:()=>s(r.BYTES),precompute(_=8,b=j.BASE){return b._setWindowSize(_),b.multiply(BigInt(3)),b}}}}L4.twistedEdwards=R7e});var ooe=V(K4=>{"use strict";f();Object.defineProperty(K4,"__esModule",{value:!0});K4.montgomery=void 0;var ioe=Dm(),l1=ju(),qE=BigInt(0),BC=BigInt(1);function D7e(t){return(0,l1.validateObject)(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function B7e(t){let e=D7e(t),{P:r}=e,n=A=>(0,ioe.mod)(A,r),i=e.montgomeryBits,o=Math.ceil(i/8),s=e.nByteLength,a=e.adjustScalarBytes||(A=>A),d=e.powPminus2||(A=>(0,ioe.pow)(A,r-BigInt(2),r));function u(A,$,j){let q=n(A*($-j));return $=n($-q),j=n(j+q),[$,j]}function c(A){if(typeof A=="bigint"&&qE<=A&&A=qE;y--){let w=q>>y&BC;T^=w,B=u(T,K,L),K=B[0],L=B[1],B=u(T,W,I),W=B[0],I=B[1],T=w;let E=K+W,_=n(E*E),b=K-W,C=n(b*b),N=_-C,M=L+I,U=L-I,G=n(U*E),Z=n(M*b),J=G+Z,H=G-Z;L=n(J*J),I=n(F*n(H*H)),K=n(_*C),W=n(N*(_+n(l*N)))}B=u(T,K,L),K=B[0],L=B[1],B=u(T,W,I),W=B[0],I=B[1];let h=d(W);return n(K*h)}function m(A){return(0,l1.numberToBytesLE)(n(A),o)}function g(A){let $=(0,l1.ensureBytes)("u coordinate",A,o);return s===32&&($[31]&=127),(0,l1.bytesToNumberLE)($)}function v(A){let $=(0,l1.ensureBytes)("scalar",A),j=$.length;if(j!==o&&j!==s)throw new Error(`Expected ${o} or ${s} bytes, got ${j}`);return(0,l1.bytesToNumberLE)(a($))}function x(A,$){let j=g($),q=v(A),F=p(j,q);if(F===qE)throw new Error("Invalid private or public key received");return m(F)}let S=m(e.Gu);function P(A){return x(A,S)}return{scalarMult:x,scalarMultBase:P,getSharedSecret:(A,$)=>x(A,$),getPublicKey:A=>P(A),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:S}}K4.montgomery=B7e});var CC=V($d=>{"use strict";f();Object.defineProperty($d,"__esModule",{value:!0});$d.createHasher=$d.isogenyMap=$d.hash_to_field=$d.expand_message_xof=$d.expand_message_xmd=void 0;var M7e=Dm(),Wc=ju();function O7e(t){if((0,Wc.isBytes)(t))return t;if(typeof t=="string")return(0,Wc.utf8ToBytes)(t);throw new Error("DST must be Uint8Array or string")}var C7e=Wc.bytesToNumberBE;function Mm(t,e){if(t<0||t>=1<<8*e)throw new Error(`bad I2OSP call: value=${t} length=${e}`);let r=Array.from({length:e}).fill(0);for(let n=e-1;n>=0;n--)r[n]=t&255,t>>>=8;return new Uint8Array(r)}function $7e(t,e){let r=new Uint8Array(t.length);for(let n=0;n255&&(e=n((0,Wc.concatBytes)((0,Wc.utf8ToBytes)("H2C-OVERSIZE-DST-"),e)));let{outputLen:i,blockLen:o}=n,s=Math.ceil(r/i);if(s>255)throw new Error("Invalid xmd length");let a=(0,Wc.concatBytes)(e,Mm(e.length,1)),d=Mm(0,o),u=Mm(r,2),c=new Array(s),l=n((0,Wc.concatBytes)(d,t,u,Mm(0,1),a));c[0]=n((0,Wc.concatBytes)(l,Mm(1,1),a));for(let m=1;m<=s;m++){let g=[$7e(l,c[m-1]),Mm(m+1,1),a];c[m]=n((0,Wc.concatBytes)(...g))}return(0,Wc.concatBytes)(...c).slice(0,r)}$d.expand_message_xmd=soe;function aoe(t,e,r,n,i){if(LE(t),LE(e),OC(r),e.length>255){let o=Math.ceil(2*n/8);e=i.create({dkLen:o}).update((0,Wc.utf8ToBytes)("H2C-OVERSIZE-DST-")).update(e).digest()}if(r>65535||e.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return i.create({dkLen:r}).update(t).update(Mm(r,2)).update(e).update(Mm(e.length,1)).digest()}$d.expand_message_xof=aoe;function MC(t,e,r){(0,Wc.validateObject)(r,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});let{p:n,k:i,m:o,hash:s,expand:a,DST:d}=r;LE(t),OC(e);let u=O7e(d),c=n.toString(2).length,l=Math.ceil((c+i)/8),p=e*o*l,m;if(a==="xmd")m=soe(t,u,p,s);else if(a==="xof")m=aoe(t,u,p,i,s);else if(a==="_internal_pass")m=t;else throw new Error('expand must be "xmd" or "xof"');let g=new Array(e);for(let v=0;vArray.from(n).reverse());return(n,i)=>{let[o,s,a,d]=r.map(u=>u.reduce((c,l)=>t.add(t.mul(c,n),l)));return n=t.div(o,s),i=t.mul(i,t.div(a,d)),{x:n,y:i}}}$d.isogenyMap=j7e;function N7e(t,e,r){if(typeof e!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(n,i){let o=MC(n,2,{...r,DST:r.DST,...i}),s=t.fromAffine(e(o[0])),a=t.fromAffine(e(o[1])),d=s.add(a).clearCofactor();return d.assertValidity(),d},encodeToCurve(n,i){let o=MC(n,1,{...r,DST:r.encodeDST,...i}),s=t.fromAffine(e(o[0])).clearCofactor();return s.assertValidity(),s}}}$d.createHasher=N7e});var woe=V(jt=>{"use strict";f();Object.defineProperty(jt,"__esModule",{value:!0});jt.hash_to_ristretto255=jt.hashToRistretto255=jt.RistrettoPoint=jt.encodeToCurve=jt.hashToCurve=jt.edwardsToMontgomeryPriv=jt.edwardsToMontgomery=jt.edwardsToMontgomeryPub=jt.x25519=jt.ed25519ph=jt.ed25519ctx=jt.ed25519=jt.ED25519_TORSION_SUBGROUP=void 0;var z4=qie(),KE=Pm(),qC=noe(),U7e=ooe(),on=Dm(),Mg=ju(),poe=CC(),FE=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),NC=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),q7e=BigInt(0),Hl=BigInt(1),F4=BigInt(2),L7e=BigInt(5),coe=BigInt(10),K7e=BigInt(20),F7e=BigInt(40),doe=BigInt(80);function moe(t){let e=FE,n=t*t%e*t%e,i=(0,on.pow2)(n,F4,e)*n%e,o=(0,on.pow2)(i,Hl,e)*t%e,s=(0,on.pow2)(o,L7e,e)*o%e,a=(0,on.pow2)(s,coe,e)*s%e,d=(0,on.pow2)(a,K7e,e)*a%e,u=(0,on.pow2)(d,F7e,e)*d%e,c=(0,on.pow2)(u,doe,e)*u%e,l=(0,on.pow2)(c,doe,e)*u%e,p=(0,on.pow2)(l,coe,e)*s%e;return{pow_p_5_8:(0,on.pow2)(p,F4,e)*t%e,b2:n}}function yoe(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function LC(t,e){let r=FE,n=(0,on.mod)(e*e*e,r),i=(0,on.mod)(n*n*e,r),o=moe(t*i).pow_p_5_8,s=(0,on.mod)(t*n*o,r),a=(0,on.mod)(e*s*s,r),d=s,u=(0,on.mod)(s*NC,r),c=a===t,l=a===(0,on.mod)(-t,r),p=a===(0,on.mod)(-t*NC,r);return c&&(s=d),(l||p)&&(s=u),(0,on.isNegativeLE)(s,r)&&(s=(0,on.mod)(-s,r)),{isValid:c||l,value:s}}jt.ED25519_TORSION_SUBGROUP=["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"];var Le=(0,on.Field)(FE,void 0,!0),zE={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Le,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:z4.sha512,randomBytes:KE.randomBytes,adjustScalarBytes:yoe,uvRatio:LC};jt.ed25519=(0,qC.twistedEdwards)(zE);function goe(t,e,r){if(e.length>255)throw new Error("Context is too big");return(0,KE.concatBytes)((0,KE.utf8ToBytes)("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,e.length]),e,t)}jt.ed25519ctx=(0,qC.twistedEdwards)({...zE,domain:goe});jt.ed25519ph=(0,qC.twistedEdwards)({...zE,domain:goe,prehash:z4.sha512});jt.x25519=(0,U7e.montgomery)({P:FE,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{let e=FE,{pow_p_5_8:r,b2:n}=moe(t);return(0,on.mod)((0,on.pow2)(r,BigInt(3),e)*n,e)},adjustScalarBytes:yoe,randomBytes:KE.randomBytes});function voe(t){let{y:e}=jt.ed25519.ExtendedPoint.fromHex(t),r=BigInt(1);return Le.toBytes(Le.create((r+e)*Le.inv(r-e)))}jt.edwardsToMontgomeryPub=voe;jt.edwardsToMontgomery=voe;function z7e(t){let e=zE.hash(t.subarray(0,32));return zE.adjustScalarBytes(e).subarray(0,32)}jt.edwardsToMontgomeryPriv=z7e;var W7e=(Le.ORDER+BigInt(3))/BigInt(8),H7e=Le.pow(F4,W7e),uoe=Le.sqrt(Le.neg(Le.ONE)),V7e=(Le.ORDER-BigInt(5))/BigInt(8),loe=BigInt(486662);function G7e(t){let e=Le.sqr(t);e=Le.mul(e,F4);let r=Le.add(e,Le.ONE),n=Le.neg(loe),i=Le.sqr(r),o=Le.mul(i,r),s=Le.mul(e,loe);s=Le.mul(s,n),s=Le.add(s,i),s=Le.mul(s,n);let a=Le.sqr(o);i=Le.sqr(a),a=Le.mul(a,o),a=Le.mul(a,s),i=Le.mul(i,a);let d=Le.pow(i,V7e);d=Le.mul(d,a);let u=Le.mul(d,uoe);i=Le.sqr(d),i=Le.mul(i,o);let c=Le.eql(i,s),l=Le.cmov(u,d,c),p=Le.mul(n,e),m=Le.mul(d,t);m=Le.mul(m,H7e);let g=Le.mul(m,uoe),v=Le.mul(s,e);i=Le.sqr(m),i=Le.mul(i,o);let x=Le.eql(i,v),S=Le.cmov(g,m,x);i=Le.sqr(l),i=Le.mul(i,o);let P=Le.eql(i,s),A=Le.cmov(p,n,P),$=Le.cmov(S,l,P),j=Le.isOdd($);return $=Le.cmov($,Le.neg($),P!==j),{xMn:A,xMd:r,yMn:$,yMd:Hl}}var J7e=(0,on.FpSqrtEven)(Le,Le.neg(BigInt(486664)));function Z7e(t){let{xMn:e,xMd:r,yMn:n,yMd:i}=G7e(t),o=Le.mul(e,i);o=Le.mul(o,J7e);let s=Le.mul(r,n),a=Le.sub(e,r),d=Le.add(e,r),u=Le.mul(s,d),c=Le.eql(u,Le.ZERO);o=Le.cmov(o,Le.ZERO,c),s=Le.cmov(s,Le.ONE,c),a=Le.cmov(a,Le.ONE,c),d=Le.cmov(d,Le.ONE,c);let l=Le.invertBatch([s,d]);return{x:Le.mul(o,l[0]),y:Le.mul(a,l[1])}}var boe=(0,poe.createHasher)(jt.ed25519.ExtendedPoint,t=>Z7e(t[0]),{DST:"edwards25519_XMD:SHA-512_ELL2_RO_",encodeDST:"edwards25519_XMD:SHA-512_ELL2_NU_",p:Le.ORDER,m:1,k:128,expand:"xmd",hash:z4.sha512});jt.hashToCurve=boe.hashToCurve;jt.encodeToCurve=boe.encodeToCurve;function $C(t){if(!(t instanceof Uu))throw new Error("RistrettoPoint expected")}var UC=NC,Y7e=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),X7e=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),Q7e=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),eMe=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),foe=t=>LC(Hl,t),tMe=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),jC=t=>jt.ed25519.CURVE.Fp.create((0,Mg.bytesToNumberLE)(t)&tMe);function hoe(t){let{d:e}=jt.ed25519.CURVE,r=jt.ed25519.CURVE.Fp.ORDER,n=jt.ed25519.CURVE.Fp.create,i=n(UC*t*t),o=n((i+Hl)*Q7e),s=BigInt(-1),a=n((s-e*i)*n(i+e)),{isValid:d,value:u}=LC(o,a),c=n(u*t);(0,on.isNegativeLE)(c,r)||(c=n(-c)),d||(u=c),d||(s=i);let l=n(s*(i-Hl)*eMe-a),p=u*u,m=n((u+u)*a),g=n(l*Y7e),v=n(Hl-p),x=n(Hl+p);return new jt.ed25519.ExtendedPoint(n(m*x),n(v*g),n(g*x),n(m*v))}var Uu=class t{constructor(e){this.ep=e}static fromAffine(e){return new t(jt.ed25519.ExtendedPoint.fromAffine(e))}static hashToCurve(e){e=(0,Mg.ensureBytes)("ristrettoHash",e,64);let r=jC(e.slice(0,32)),n=hoe(r),i=jC(e.slice(32,64)),o=hoe(i);return new t(n.add(o))}static fromHex(e){e=(0,Mg.ensureBytes)("ristrettoHex",e,32);let{a:r,d:n}=jt.ed25519.CURVE,i=jt.ed25519.CURVE.Fp.ORDER,o=jt.ed25519.CURVE.Fp.create,s="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",a=jC(e);if(!(0,Mg.equalBytes)((0,Mg.numberToBytesLE)(a,32),e)||(0,on.isNegativeLE)(a,i))throw new Error(s);let d=o(a*a),u=o(Hl+r*d),c=o(Hl-r*d),l=o(u*u),p=o(c*c),m=o(r*n*l-p),{isValid:g,value:v}=foe(o(m*p)),x=o(v*c),S=o(v*x*m),P=o((a+a)*x);(0,on.isNegativeLE)(P,i)&&(P=o(-P));let A=o(u*S),$=o(P*A);if(!g||(0,on.isNegativeLE)($,i)||A===q7e)throw new Error(s);return new t(new jt.ed25519.ExtendedPoint(P,A,Hl,$))}toRawBytes(){let{ex:e,ey:r,ez:n,et:i}=this.ep,o=jt.ed25519.CURVE.Fp.ORDER,s=jt.ed25519.CURVE.Fp.create,a=s(s(n+r)*s(n-r)),d=s(e*r),u=s(d*d),{value:c}=foe(s(a*u)),l=s(c*a),p=s(c*d),m=s(l*p*i),g;if((0,on.isNegativeLE)(i*m,o)){let x=s(r*UC),S=s(e*UC);e=x,r=S,g=s(l*X7e)}else g=p;(0,on.isNegativeLE)(e*m,o)&&(r=s(-r));let v=s((n-r)*g);return(0,on.isNegativeLE)(v,o)&&(v=s(-v)),(0,Mg.numberToBytesLE)(v,32)}toHex(){return(0,Mg.bytesToHex)(this.toRawBytes())}toString(){return this.toHex()}equals(e){$C(e);let{ex:r,ey:n}=this.ep,{ex:i,ey:o}=e.ep,s=jt.ed25519.CURVE.Fp.create,a=s(r*o)===s(n*i),d=s(n*o)===s(r*i);return a||d}add(e){return $C(e),new t(this.ep.add(e.ep))}subtract(e){return $C(e),new t(this.ep.subtract(e.ep))}multiply(e){return new t(this.ep.multiply(e))}multiplyUnsafe(e){return new t(this.ep.multiplyUnsafe(e))}double(){return new t(this.ep.double())}negate(){return new t(this.ep.negate())}};jt.RistrettoPoint=(Uu.BASE||(Uu.BASE=new Uu(jt.ed25519.ExtendedPoint.BASE)),Uu.ZERO||(Uu.ZERO=new Uu(jt.ed25519.ExtendedPoint.ZERO)),Uu);var rMe=(t,e)=>{let r=e.DST,n=typeof r=="string"?(0,KE.utf8ToBytes)(r):r,i=(0,poe.expand_message_xmd)(t,n,64,z4.sha512);return Uu.hashToCurve(i)};jt.hashToRistretto255=rMe;jt.hash_to_ristretto255=jt.hashToRistretto255});var _oe=V(f1=>{"use strict";f();Object.defineProperty(f1,"__esModule",{value:!0});f1.sha224=f1.sha256=void 0;var nMe=vC(),jd=Pm(),iMe=(t,e,r)=>t&e^~t&r,oMe=(t,e,r)=>t&e^t&r^e&r,sMe=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]),Om=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Cm=new Uint32Array(64),W4=class extends nMe.SHA2{constructor(){super(64,32,8,!1),this.A=Om[0]|0,this.B=Om[1]|0,this.C=Om[2]|0,this.D=Om[3]|0,this.E=Om[4]|0,this.F=Om[5]|0,this.G=Om[6]|0,this.H=Om[7]|0}get(){let{A:e,B:r,C:n,D:i,E:o,F:s,G:a,H:d}=this;return[e,r,n,i,o,s,a,d]}set(e,r,n,i,o,s,a,d){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=d|0}process(e,r){for(let l=0;l<16;l++,r+=4)Cm[l]=e.getUint32(r,!1);for(let l=16;l<64;l++){let p=Cm[l-15],m=Cm[l-2],g=(0,jd.rotr)(p,7)^(0,jd.rotr)(p,18)^p>>>3,v=(0,jd.rotr)(m,17)^(0,jd.rotr)(m,19)^m>>>10;Cm[l]=v+Cm[l-7]+g+Cm[l-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:d,G:u,H:c}=this;for(let l=0;l<64;l++){let p=(0,jd.rotr)(a,6)^(0,jd.rotr)(a,11)^(0,jd.rotr)(a,25),m=c+p+iMe(a,d,u)+sMe[l]+Cm[l]|0,v=((0,jd.rotr)(n,2)^(0,jd.rotr)(n,13)^(0,jd.rotr)(n,22))+oMe(n,i,o)|0;c=u,u=d,d=a,a=s+m|0,s=o,o=i,i=n,n=m+v|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,d=d+this.F|0,u=u+this.G|0,c=c+this.H|0,this.set(n,i,o,s,a,d,u,c)}roundClean(){Cm.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},KC=class extends W4{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}};f1.sha256=(0,jd.wrapConstructor)(()=>new W4);f1.sha224=(0,jd.wrapConstructor)(()=>new KC)});var zC=V(io=>{"use strict";f();Object.defineProperty(io,"__esModule",{value:!0});io.mapToCurveSimpleSWU=io.SWUFpSqrtRatio=io.weierstrass=io.weierstrassPoints=io.DER=void 0;var h1=Dm(),ri=ju(),Vl=ju(),FC=DC();function aMe(t){let e=(0,FC.validateBasic)(t);ri.validateObject(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:r,Fp:n,a:i}=e;if(r){if(!n.eql(i,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:cMe,hexToBytes:dMe}=ri;io.DER={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(t){let{Err:e}=io.DER;if(t.length<2||t[0]!==2)throw new e("Invalid signature integer tag");let r=t[1],n=t.subarray(2,r+2);if(!r||n.length!==r)throw new e("Invalid signature integer: wrong length");if(n[0]&128)throw new e("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:cMe(n),l:t.subarray(r+2)}},toSig(t){let{Err:e}=io.DER,r=typeof t=="string"?dMe(t):t;if(!ri.isBytes(r))throw new Error("ui8a expected");let n=r.length;if(n<2||r[0]!=48)throw new e("Invalid signature tag");if(r[1]!==n-2)throw new e("Invalid signature: incorrect length");let{d:i,l:o}=io.DER._parseInt(r.subarray(2)),{d:s,l:a}=io.DER._parseInt(o);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:i,s}},hexFromSig(t){let e=u=>Number.parseInt(u[0],16)&8?"00"+u:u,r=u=>{let c=u.toString(16);return c.length&1?`0${c}`:c},n=e(r(t.s)),i=e(r(t.r)),o=n.length/2,s=i.length/2,a=r(o),d=r(s);return`30${r(s+o+4)}02${d}${i}02${a}${n}`}};var qu=BigInt(0),_i=BigInt(1),$m=BigInt(2),H4=BigInt(3),xoe=BigInt(4);function Eoe(t){let e=aMe(t),{Fp:r}=e,n=e.toBytes||((g,v,x)=>{let S=v.toAffine();return ri.concatBytes(Uint8Array.from([4]),r.toBytes(S.x),r.toBytes(S.y))}),i=e.fromBytes||(g=>{let v=g.subarray(1),x=r.fromBytes(v.subarray(0,r.BYTES)),S=r.fromBytes(v.subarray(r.BYTES,2*r.BYTES));return{x,y:S}});function o(g){let{a:v,b:x}=e,S=r.sqr(g),P=r.mul(S,g);return r.add(r.add(P,r.mul(g,v)),x)}if(!r.eql(r.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function s(g){return typeof g=="bigint"&&qur.eql(A,r.ZERO);return P(x)&&P(S)?l.ZERO:new l(x,S,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(v){let x=r.invertBatch(v.map(S=>S.pz));return v.map((S,P)=>S.toAffine(x[P])).map(l.fromAffine)}static fromHex(v){let x=l.fromAffine(i((0,Vl.ensureBytes)("pointHex",v)));return x.assertValidity(),x}static fromPrivateKey(v){return l.BASE.multiply(d(v))}_setWindowSize(v){this._WINDOW_SIZE=v,u.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}let{x:v,y:x}=this.toAffine();if(!r.isValid(v)||!r.isValid(x))throw new Error("bad point: x or y not FE");let S=r.sqr(x),P=o(v);if(!r.eql(S,P))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:v}=this.toAffine();if(r.isOdd)return!r.isOdd(v);throw new Error("Field doesn't support isOdd")}equals(v){c(v);let{px:x,py:S,pz:P}=this,{px:A,py:$,pz:j}=v,q=r.eql(r.mul(x,j),r.mul(A,P)),F=r.eql(r.mul(S,j),r.mul($,P));return q&&F}negate(){return new l(this.px,r.neg(this.py),this.pz)}double(){let{a:v,b:x}=e,S=r.mul(x,H4),{px:P,py:A,pz:$}=this,j=r.ZERO,q=r.ZERO,F=r.ZERO,K=r.mul(P,P),W=r.mul(A,A),L=r.mul($,$),I=r.mul(P,A);return I=r.add(I,I),F=r.mul(P,$),F=r.add(F,F),j=r.mul(v,F),q=r.mul(S,L),q=r.add(j,q),j=r.sub(W,q),q=r.add(W,q),q=r.mul(j,q),j=r.mul(I,j),F=r.mul(S,F),L=r.mul(v,L),I=r.sub(K,L),I=r.mul(v,I),I=r.add(I,F),F=r.add(K,K),K=r.add(F,K),K=r.add(K,L),K=r.mul(K,I),q=r.add(q,K),L=r.mul(A,$),L=r.add(L,L),K=r.mul(L,I),j=r.sub(j,K),F=r.mul(L,W),F=r.add(F,F),F=r.add(F,F),new l(j,q,F)}add(v){c(v);let{px:x,py:S,pz:P}=this,{px:A,py:$,pz:j}=v,q=r.ZERO,F=r.ZERO,K=r.ZERO,W=e.a,L=r.mul(e.b,H4),I=r.mul(x,A),T=r.mul(S,$),B=r.mul(P,j),h=r.add(x,S),y=r.add(A,$);h=r.mul(h,y),y=r.add(I,T),h=r.sub(h,y),y=r.add(x,P);let w=r.add(A,j);return y=r.mul(y,w),w=r.add(I,B),y=r.sub(y,w),w=r.add(S,P),q=r.add($,j),w=r.mul(w,q),q=r.add(T,B),w=r.sub(w,q),K=r.mul(W,y),q=r.mul(L,B),K=r.add(q,K),q=r.sub(T,K),K=r.add(T,K),F=r.mul(q,K),T=r.add(I,I),T=r.add(T,I),B=r.mul(W,B),y=r.mul(L,y),T=r.add(T,B),B=r.sub(I,B),B=r.mul(W,B),y=r.add(y,B),I=r.mul(T,y),F=r.add(F,I),I=r.mul(w,y),q=r.mul(h,q),q=r.sub(q,I),I=r.mul(h,T),K=r.mul(w,K),K=r.add(K,I),new l(q,F,K)}subtract(v){return this.add(v.negate())}is0(){return this.equals(l.ZERO)}wNAF(v){return m.wNAFCached(this,u,v,x=>{let S=r.invertBatch(x.map(P=>P.pz));return x.map((P,A)=>P.toAffine(S[A])).map(l.fromAffine)})}multiplyUnsafe(v){let x=l.ZERO;if(v===qu)return x;if(a(v),v===_i)return this;let{endo:S}=e;if(!S)return m.unsafeLadder(this,v);let{k1neg:P,k1:A,k2neg:$,k2:j}=S.splitScalar(v),q=x,F=x,K=this;for(;A>qu||j>qu;)A&_i&&(q=q.add(K)),j&_i&&(F=F.add(K)),K=K.double(),A>>=_i,j>>=_i;return P&&(q=q.negate()),$&&(F=F.negate()),F=new l(r.mul(F.px,S.beta),F.py,F.pz),q.add(F)}multiply(v){a(v);let x=v,S,P,{endo:A}=e;if(A){let{k1neg:$,k1:j,k2neg:q,k2:F}=A.splitScalar(x),{p:K,f:W}=this.wNAF(j),{p:L,f:I}=this.wNAF(F);K=m.constTimeNegate($,K),L=m.constTimeNegate(q,L),L=new l(r.mul(L.px,A.beta),L.py,L.pz),S=K.add(L),P=W.add(I)}else{let{p:$,f:j}=this.wNAF(x);S=$,P=j}return l.normalizeZ([S,P])[0]}multiplyAndAddUnsafe(v,x,S){let P=l.BASE,A=(j,q)=>q===qu||q===_i||!j.equals(P)?j.multiplyUnsafe(q):j.multiply(q),$=A(this,x).add(A(v,S));return $.is0()?void 0:$}toAffine(v){let{px:x,py:S,pz:P}=this,A=this.is0();v==null&&(v=A?r.ONE:r.inv(P));let $=r.mul(x,v),j=r.mul(S,v),q=r.mul(P,v);if(A)return{x:r.ZERO,y:r.ZERO};if(!r.eql(q,r.ONE))throw new Error("invZ was invalid");return{x:$,y:j}}isTorsionFree(){let{h:v,isTorsionFree:x}=e;if(v===_i)return!0;if(x)return x(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:v,clearCofactor:x}=e;return v===_i?this:x?x(l,this):this.multiplyUnsafe(e.h)}toRawBytes(v=!0){return this.assertValidity(),n(l,this,v)}toHex(v=!0){return ri.bytesToHex(this.toRawBytes(v))}}l.BASE=new l(e.Gx,e.Gy,r.ONE),l.ZERO=new l(r.ZERO,r.ONE,r.ZERO);let p=e.nBitLength,m=(0,FC.wNAF)(l,e.endo?Math.ceil(p/2):p);return{CURVE:e,ProjectivePoint:l,normPrivateKeyToScalar:d,weierstrassEquation:o,isWithinCurveOrder:s}}io.weierstrassPoints=Eoe;function uMe(t){let e=(0,FC.validateBasic)(t);return ri.validateObject(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function lMe(t){let e=uMe(t),{Fp:r,n}=e,i=r.BYTES+1,o=2*r.BYTES+1;function s(y){return quri.bytesToHex(ri.numberToBytesBE(y,e.nByteLength));function g(y){let w=n>>_i;return y>w}function v(y){return g(y)?a(-y):y}let x=(y,w,E)=>ri.bytesToNumberBE(y.slice(w,E));class S{constructor(w,E,_){this.r=w,this.s=E,this.recovery=_,this.assertValidity()}static fromCompact(w){let E=e.nByteLength;return w=(0,Vl.ensureBytes)("compactSignature",w,E*2),new S(x(w,0,E),x(w,E,2*E))}static fromDER(w){let{r:E,s:_}=io.DER.toSig((0,Vl.ensureBytes)("DER",w));return new S(E,_)}assertValidity(){if(!p(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!p(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(w){return new S(this.r,this.s,w)}recoverPublicKey(w){let{r:E,s:_,recovery:b}=this,C=F((0,Vl.ensureBytes)("msgHash",w));if(b==null||![0,1,2,3].includes(b))throw new Error("recovery id invalid");let N=b===2||b===3?E+e.n:E;if(N>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let M=b&1?"03":"02",U=u.fromHex(M+m(N)),G=d(N),Z=a(-C*G),J=a(_*G),H=u.BASE.multiplyAndAddUnsafe(U,Z,J);if(!H)throw new Error("point at infinify");return H.assertValidity(),H}hasHighS(){return g(this.s)}normalizeS(){return this.hasHighS()?new S(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return ri.hexToBytes(this.toDERHex())}toDERHex(){return io.DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return ri.hexToBytes(this.toCompactHex())}toCompactHex(){return m(this.r)+m(this.s)}}let P={isValidPrivateKey(y){try{return c(y),!0}catch{return!1}},normPrivateKeyToScalar:c,randomPrivateKey:()=>{let y=h1.getMinHashLength(e.n);return h1.mapHashToField(e.randomBytes(y),e.n)},precompute(y=8,w=u.BASE){return w._setWindowSize(y),w.multiply(BigInt(3)),w}};function A(y,w=!0){return u.fromPrivateKey(y).toRawBytes(w)}function $(y){let w=ri.isBytes(y),E=typeof y=="string",_=(w||E)&&y.length;return w?_===i||_===o:E?_===2*i||_===2*o:y instanceof u}function j(y,w,E=!0){if($(y))throw new Error("first arg must be private key");if(!$(w))throw new Error("second arg must be public key");return u.fromHex(w).multiply(c(y)).toRawBytes(E)}let q=e.bits2int||function(y){let w=ri.bytesToNumberBE(y),E=y.length*8-e.nBitLength;return E>0?w>>BigInt(E):w},F=e.bits2int_modN||function(y){return a(q(y))},K=ri.bitMask(e.nBitLength);function W(y){if(typeof y!="bigint")throw new Error("bigint expected");if(!(qu<=y&&yte in E))throw new Error("sign() legacy options not supported");let{hash:_,randomBytes:b}=e,{lowS:C,prehash:N,extraEntropy:M}=E;C==null&&(C=!0),y=(0,Vl.ensureBytes)("msgHash",y),N&&(y=(0,Vl.ensureBytes)("prehashed msgHash",_(y)));let U=F(y),G=c(w),Z=[W(G),W(U)];if(M!=null){let te=M===!0?b(r.BYTES):M;Z.push((0,Vl.ensureBytes)("extraEntropy",te))}let J=ri.concatBytes(...Z),H=U;function X(te){let ne=q(te);if(!p(ne))return;let Q=d(ne),re=u.BASE.multiply(ne).toAffine(),ce=a(re.x);if(ce===qu)return;let pe=a(Q*a(H+ce*G));if(pe===qu)return;let ye=(re.x===ce?0:2)|Number(re.y&_i),ie=pe;return C&&g(pe)&&(ie=v(pe),ye^=1),new S(ce,ie,ye)}return{seed:J,k2sig:X}}let I={lowS:e.lowS,prehash:!1},T={lowS:e.lowS,prehash:!1};function B(y,w,E=I){let{seed:_,k2sig:b}=L(y,w,E),C=e;return ri.createHmacDrbg(C.hash.outputLen,C.nByteLength,C.hmac)(_,b)}u.BASE._setWindowSize(8);function h(y,w,E,_=T){let b=y;if(w=(0,Vl.ensureBytes)("msgHash",w),E=(0,Vl.ensureBytes)("publicKey",E),"strict"in _)throw new Error("options.strict was renamed to lowS");let{lowS:C,prehash:N}=_,M,U;try{if(typeof b=="string"||ri.isBytes(b))try{M=S.fromDER(b)}catch(re){if(!(re instanceof io.DER.Err))throw re;M=S.fromCompact(b)}else if(typeof b=="object"&&typeof b.r=="bigint"&&typeof b.s=="bigint"){let{r:re,s:ce}=b;M=new S(re,ce)}else throw new Error("PARSE");U=u.fromHex(E)}catch(re){if(re.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(C&&M.hasHighS())return!1;N&&(w=e.hash(w));let{r:G,s:Z}=M,J=F(w),H=d(Z),X=a(J*H),te=a(G*H),ne=u.BASE.multiplyAndAddUnsafe(U,X,te)?.toAffine();return ne?a(ne.x)===G:!1}return{CURVE:e,getPublicKey:A,getSharedSecret:j,sign:B,verify:h,ProjectivePoint:u,Signature:S,utils:P}}io.weierstrass=lMe;function Soe(t,e){let r=t.ORDER,n=qu;for(let g=r-_i;g%$m===qu;g/=$m)n+=_i;let i=n,o=$m<{let x=l,S=t.pow(v,u),P=t.sqr(S);P=t.mul(P,v);let A=t.mul(g,P);A=t.pow(A,d),A=t.mul(A,S),S=t.mul(A,v),P=t.mul(A,g);let $=t.mul(P,S);A=t.pow($,c);let j=t.eql(A,t.ONE);S=t.mul(P,p),A=t.mul($,x),P=t.cmov(S,P,j),$=t.cmov(A,$,j);for(let q=i;q>_i;q--){let F=q-$m;F=$m<{let P=t.sqr(S),A=t.mul(x,S);P=t.mul(P,A);let $=t.pow(P,g);$=t.mul($,A);let j=t.mul($,v),q=t.mul(t.sqr($),S),F=t.eql(q,x),K=t.cmov(j,$,F);return{isValid:F,value:K}}}return m}io.SWUFpSqrtRatio=Soe;function fMe(t,e){if(h1.validateField(t),!t.isValid(e.A)||!t.isValid(e.B)||!t.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");let r=Soe(t,e.Z);if(!t.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let i,o,s,a,d,u,c,l;i=t.sqr(n),i=t.mul(i,e.Z),o=t.sqr(i),o=t.add(o,i),s=t.add(o,t.ONE),s=t.mul(s,e.B),a=t.cmov(e.Z,t.neg(o),!t.eql(o,t.ZERO)),a=t.mul(a,e.A),o=t.sqr(s),u=t.sqr(a),d=t.mul(u,e.A),o=t.add(o,d),o=t.mul(o,s),u=t.mul(u,a),d=t.mul(u,e.B),o=t.add(o,d),c=t.mul(i,s);let{isValid:p,value:m}=r(o,u);l=t.mul(i,n),l=t.mul(l,m),c=t.cmov(c,s,p),l=t.cmov(l,m,p);let g=t.isOdd(n)===t.isOdd(l);return l=t.cmov(t.neg(l),l,g),c=t.div(c,a),{x:c,y:l}}}io.mapToCurveSimpleSWU=fMe});var Toe=V(Og=>{"use strict";f();Object.defineProperty(Og,"__esModule",{value:!0});Og.hmac=Og.HMAC=void 0;var V4=fC(),Aoe=Pm(),WE=class extends Aoe.Hash{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,(0,V4.hash)(e);let n=(0,Aoe.toBytes)(r);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let i=this.blockLen,o=new Uint8Array(i);o.set(n.length>i?e.create().update(n).digest():n);for(let s=0;snew WE(t,e).update(r).digest();Og.hmac=hMe;Og.hmac.create=(t,e)=>new WE(t,e)});var koe=V(p1=>{"use strict";f();Object.defineProperty(p1,"__esModule",{value:!0});p1.createCurve=p1.getHash=void 0;var pMe=Toe(),Poe=Pm(),mMe=zC();function Ioe(t){return{hash:t,hmac:(e,...r)=>(0,pMe.hmac)(t,e,(0,Poe.concatBytes)(...r)),randomBytes:Poe.randomBytes}}p1.getHash=Ioe;function yMe(t,e){let r=n=>(0,mMe.weierstrass)({...t,...Ioe(n)});return Object.freeze({...r(e),create:r})}p1.createCurve=yMe});var qoe=V(rc=>{"use strict";f();Object.defineProperty(rc,"__esModule",{value:!0});rc.encodeToCurve=rc.hashToCurve=rc.schnorr=rc.secp256k1=void 0;var G4=_oe(),gMe=Pm(),jo=Dm(),vMe=zC(),ea=ju(),Boe=CC(),bMe=koe(),X4=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),J4=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Moe=BigInt(1),Z4=BigInt(2),Roe=(t,e)=>(t+e/Z4)/e;function Ooe(t){let e=X4,r=BigInt(3),n=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),d=BigInt(88),u=t*t*t%e,c=u*u*t%e,l=(0,jo.pow2)(c,r,e)*c%e,p=(0,jo.pow2)(l,r,e)*c%e,m=(0,jo.pow2)(p,Z4,e)*u%e,g=(0,jo.pow2)(m,i,e)*m%e,v=(0,jo.pow2)(g,o,e)*g%e,x=(0,jo.pow2)(v,a,e)*v%e,S=(0,jo.pow2)(x,d,e)*x%e,P=(0,jo.pow2)(S,a,e)*v%e,A=(0,jo.pow2)(P,r,e)*c%e,$=(0,jo.pow2)(A,s,e)*g%e,j=(0,jo.pow2)($,n,e)*u%e,q=(0,jo.pow2)(j,Z4,e);if(!jm.eql(jm.sqr(q),t))throw new Error("Cannot find square root");return q}var jm=(0,jo.Field)(X4,void 0,void 0,{sqrt:Ooe});rc.secp256k1=(0,bMe.createCurve)({a:BigInt(0),b:BigInt(7),Fp:jm,n:J4,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{let e=J4,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Moe*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=r,s=BigInt("0x100000000000000000000000000000000"),a=Roe(o*t,e),d=Roe(-n*t,e),u=(0,jo.mod)(t-a*r-d*i,e),c=(0,jo.mod)(-a*n-d*o,e),l=u>s,p=c>s;if(l&&(u=e-u),p&&(c=e-c),u>s||c>s)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:l,k1:u,k2neg:p,k2:c}}}},G4.sha256);var Q4=BigInt(0),Coe=t=>typeof t=="bigint"&&Q4typeof t=="bigint"&&Q4i.charCodeAt(0)));r=(0,ea.concatBytes)(n,n),Doe[t]=r}return(0,G4.sha256)((0,ea.concatBytes)(r,...e))}var GC=t=>t.toRawBytes(!0).slice(1),HC=t=>(0,ea.numberToBytesBE)(t,32),WC=t=>(0,jo.mod)(t,X4),HE=t=>(0,jo.mod)(t,J4),JC=rc.secp256k1.ProjectivePoint,_Me=(t,e,r)=>JC.BASE.multiplyAndAddUnsafe(t,e,r);function VC(t){let e=rc.secp256k1.utils.normPrivateKeyToScalar(t),r=JC.fromPrivateKey(e);return{scalar:r.hasEvenY()?e:HE(-e),bytes:GC(r)}}function $oe(t){if(!Coe(t))throw new Error("bad x: need 0 < x < p");let e=WC(t*t),r=WC(e*t+BigInt(7)),n=Ooe(r);n%Z4!==Q4&&(n=WC(-n));let i=new JC(t,n,Moe);return i.assertValidity(),i}function joe(...t){return HE((0,ea.bytesToNumberBE)(Y4("BIP0340/challenge",...t)))}function xMe(t){return VC(t).bytes}function EMe(t,e,r=(0,gMe.randomBytes)(32)){let n=(0,ea.ensureBytes)("message",t),{bytes:i,scalar:o}=VC(e),s=(0,ea.ensureBytes)("auxRand",r,32),a=HC(o^(0,ea.bytesToNumberBE)(Y4("BIP0340/aux",s))),d=Y4("BIP0340/nonce",a,i,n),u=HE((0,ea.bytesToNumberBE)(d));if(u===Q4)throw new Error("sign failed: k is zero");let{bytes:c,scalar:l}=VC(u),p=joe(c,i,n),m=new Uint8Array(64);if(m.set(c,0),m.set(HC(HE(l+p*o)),32),!Noe(m,n,i))throw new Error("sign: Invalid signature produced");return m}function Noe(t,e,r){let n=(0,ea.ensureBytes)("signature",t,64),i=(0,ea.ensureBytes)("message",e),o=(0,ea.ensureBytes)("publicKey",r,32);try{let s=$oe((0,ea.bytesToNumberBE)(o)),a=(0,ea.bytesToNumberBE)(n.subarray(0,32));if(!Coe(a))return!1;let d=(0,ea.bytesToNumberBE)(n.subarray(32,64));if(!wMe(d))return!1;let u=joe(HC(a),GC(s),i),c=_Me(s,d,HE(-u));return!(!c||!c.hasEvenY()||c.toAffine().x!==a)}catch{return!1}}rc.schnorr={getPublicKey:xMe,sign:EMe,verify:Noe,utils:{randomPrivateKey:rc.secp256k1.utils.randomPrivateKey,lift_x:$oe,pointToBytes:GC,numberToBytesBE:ea.numberToBytesBE,bytesToNumberBE:ea.bytesToNumberBE,taggedHash:Y4,mod:jo.mod}};var SMe=(0,Boe.isogenyMap)(jm,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map(t=>t.map(e=>BigInt(e)))),AMe=(0,vMe.mapToCurveSimpleSWU)(jm,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:jm.create(BigInt("-11"))}),Uoe=(0,Boe.createHasher)(rc.secp256k1.ProjectivePoint,t=>{let{x:e,y:r}=AMe(jm.create(t[0]));return SMe(e,r)},{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:jm.ORDER,m:1,k:128,expand:"xmd",hash:G4.sha256});rc.hashToCurve=Uoe.hashToCurve;rc.encodeToCurve=Uoe.encodeToCurve});var ZC=V(m1=>{"use strict";f();Object.defineProperty(m1,"__esModule",{value:!0});m1.decodeHex=m1.remove0x=void 0;var TMe=$u();function Loe(t){return t.startsWith("0x")||t.startsWith("0X")?t.slice(2):t}m1.remove0x=Loe;function PMe(t){return(0,TMe.hexToBytes)(Loe(t))}m1.decodeHex=PMe});var XC=V(Ia=>{"use strict";f();Object.defineProperty(Ia,"__esModule",{value:!0});Ia.output=Ia.exists=Ia.hash=Ia.bytes=Ia.bool=Ia.number=void 0;function eT(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}Ia.number=eT;function Koe(t){if(typeof t!="boolean")throw new Error(`Expected boolean, not ${t}`)}Ia.bool=Koe;function YC(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}Ia.bytes=YC;function Foe(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("hash must be wrapped by utils.wrapConstructor");eT(t.outputLen),eT(t.blockLen)}Ia.hash=Foe;function zoe(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")}Ia.exists=zoe;function Woe(t,e){YC(t);let r=e.outputLen;if(t.length{"use strict";f();Object.defineProperty(y1,"__esModule",{value:!0});y1.poly1305=y1.wrapConstructorWithKey=void 0;var tT=$u(),QC=XC(),as=(t,e)=>t[e++]&255|(t[e++]&255)<<8,e$=class{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,e=(0,tT.toBytes)(e),(0,tT.ensureBytes)(e,32);let r=as(e,0),n=as(e,2),i=as(e,4),o=as(e,6),s=as(e,8),a=as(e,10),d=as(e,12),u=as(e,14);this.r[0]=r&8191,this.r[1]=(r>>>13|n<<3)&8191,this.r[2]=(n>>>10|i<<6)&7939,this.r[3]=(i>>>7|o<<9)&8191,this.r[4]=(o>>>4|s<<12)&255,this.r[5]=s>>>1&8190,this.r[6]=(s>>>14|a<<2)&8191,this.r[7]=(a>>>11|d<<5)&8065,this.r[8]=(d>>>8|u<<8)&8191,this.r[9]=u>>>5&127;for(let c=0;c<8;c++)this.pad[c]=as(e,16+2*c)}process(e,r,n=!1){let i=n?0:2048,{h:o,r:s}=this,a=s[0],d=s[1],u=s[2],c=s[3],l=s[4],p=s[5],m=s[6],g=s[7],v=s[8],x=s[9],S=as(e,r+0),P=as(e,r+2),A=as(e,r+4),$=as(e,r+6),j=as(e,r+8),q=as(e,r+10),F=as(e,r+12),K=as(e,r+14),W=o[0]+(S&8191),L=o[1]+((S>>>13|P<<3)&8191),I=o[2]+((P>>>10|A<<6)&8191),T=o[3]+((A>>>7|$<<9)&8191),B=o[4]+(($>>>4|j<<12)&8191),h=o[5]+(j>>>1&8191),y=o[6]+((j>>>14|q<<2)&8191),w=o[7]+((q>>>11|F<<5)&8191),E=o[8]+((F>>>8|K<<8)&8191),_=o[9]+(K>>>5|i),b=0,C=b+W*a+L*(5*x)+I*(5*v)+T*(5*g)+B*(5*m);b=C>>>13,C&=8191,C+=h*(5*p)+y*(5*l)+w*(5*c)+E*(5*u)+_*(5*d),b+=C>>>13,C&=8191;let N=b+W*d+L*a+I*(5*x)+T*(5*v)+B*(5*g);b=N>>>13,N&=8191,N+=h*(5*m)+y*(5*p)+w*(5*l)+E*(5*c)+_*(5*u),b+=N>>>13,N&=8191;let M=b+W*u+L*d+I*a+T*(5*x)+B*(5*v);b=M>>>13,M&=8191,M+=h*(5*g)+y*(5*m)+w*(5*p)+E*(5*l)+_*(5*c),b+=M>>>13,M&=8191;let U=b+W*c+L*u+I*d+T*a+B*(5*x);b=U>>>13,U&=8191,U+=h*(5*v)+y*(5*g)+w*(5*m)+E*(5*p)+_*(5*l),b+=U>>>13,U&=8191;let G=b+W*l+L*c+I*u+T*d+B*a;b=G>>>13,G&=8191,G+=h*(5*x)+y*(5*v)+w*(5*g)+E*(5*m)+_*(5*p),b+=G>>>13,G&=8191;let Z=b+W*p+L*l+I*c+T*u+B*d;b=Z>>>13,Z&=8191,Z+=h*a+y*(5*x)+w*(5*v)+E*(5*g)+_*(5*m),b+=Z>>>13,Z&=8191;let J=b+W*m+L*p+I*l+T*c+B*u;b=J>>>13,J&=8191,J+=h*d+y*a+w*(5*x)+E*(5*v)+_*(5*g),b+=J>>>13,J&=8191;let H=b+W*g+L*m+I*p+T*l+B*c;b=H>>>13,H&=8191,H+=h*u+y*d+w*a+E*(5*x)+_*(5*v),b+=H>>>13,H&=8191;let X=b+W*v+L*g+I*m+T*p+B*l;b=X>>>13,X&=8191,X+=h*c+y*u+w*d+E*a+_*(5*x),b+=X>>>13,X&=8191;let te=b+W*x+L*v+I*g+T*m+B*p;b=te>>>13,te&=8191,te+=h*l+y*c+w*u+E*d+_*a,b+=te>>>13,te&=8191,b=(b<<2)+b|0,b=b+C|0,C=b&8191,b=b>>>13,N+=b,o[0]=C,o[1]=N,o[2]=M,o[3]=U,o[4]=G,o[5]=Z,o[6]=J,o[7]=H,o[8]=X,o[9]=te}finalize(){let{h:e,pad:r}=this,n=new Uint16Array(10),i=e[1]>>>13;e[1]&=8191;for(let a=2;a<10;a++)e[a]+=i,i=e[a]>>>13,e[a]&=8191;e[0]+=i*5,i=e[0]>>>13,e[0]&=8191,e[1]+=i,i=e[1]>>>13,e[1]&=8191,e[2]+=i,n[0]=e[0]+5,i=n[0]>>>13,n[0]&=8191;for(let a=1;a<10;a++)n[a]=e[a]+i,i=n[a]>>>13,n[a]&=8191;n[9]-=8192;let o=(i^1)-1;for(let a=0;a<10;a++)n[a]&=o;o=~o;for(let a=0;a<10;a++)e[a]=e[a]&o|n[a];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let s=e[0]+r[0];e[0]=s&65535;for(let a=1;a<8;a++)s=(e[a]+r[a]|0)+(s>>>16)|0,e[a]=s&65535}update(e){QC.default.exists(this);let{buffer:r,blockLen:n}=this;e=(0,tT.toBytes)(e);let i=e.length;for(let o=0;o>>0,e[o++]=n[s]>>>8;return e}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}};function Hoe(t){let e=(n,i)=>t(i).update((0,tT.toBytes)(n)).digest(),r=t(new Uint8Array(32));return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}y1.wrapConstructorWithKey=Hoe;y1.poly1305=Hoe(t=>new e$(t))});var Goe=V(nT=>{"use strict";f();Object.defineProperty(nT,"__esModule",{value:!0});nT.salsaBasic=void 0;var Gl=XC(),Jl=$u(),kMe=(0,Jl.utf8ToBytes)("expand 16-byte k"),RMe=(0,Jl.utf8ToBytes)("expand 32-byte k"),DMe=(0,Jl.u32)(kMe),BMe=(0,Jl.u32)(RMe),rT=t=>!(t.byteOffset%4),MMe=t=>{let{core:e,rounds:r,counterRight:n,counterLen:i,allow128bitKeys:o,extendNonceFn:s,blockLen:a}=(0,Jl.checkOpts)({rounds:20,counterRight:!1,counterLen:8,allow128bitKeys:!0,blockLen:64},t);Gl.default.number(i),Gl.default.number(r),Gl.default.number(a),Gl.default.bool(n),Gl.default.bool(o);let d=a/4;if(a%4!==0)throw new Error("Salsa/ChaCha: blockLen must be aligned to 4 bytes");return(u,c,l,p,m=0)=>{if(Gl.default.bytes(u),Gl.default.bytes(c),Gl.default.bytes(l),p||(p=new Uint8Array(l.length)),Gl.default.bytes(p),Gl.default.number(m),m<0||m>=2**32-1)throw new Error("Salsa/ChaCha: counter overflow");if(p.length=2**32-1)throw new Error("Salsa/ChaCha: counter overflow");let I=Math.min(a,K-W);if(I===a&&F&&q){let T=W/4;if(W%4!==0)throw new Error("Salsa/ChaCha: invalid block position");for(let B=0;B{"use strict";f();Object.defineProperty(Jn,"__esModule",{value:!0});Jn.xchacha20poly1305=Jn.chacha20poly1305=Jn._poly1305_aead=Jn.chacha12=Jn.chacha8=Jn.xchacha20=Jn.chacha20=Jn.chacha20orig=Jn.hchacha=void 0;var Lu=$u(),OMe=Voe(),VE=Goe(),et=(t,e)=>t<>>32-e;function GE(t,e,r,n,i,o=20){let s=t[0],a=t[1],d=t[2],u=t[3],c=e[0],l=e[1],p=e[2],m=e[3],g=e[4],v=e[5],x=e[6],S=e[7],P=i,A=r[0],$=r[1],j=r[2],q=s,F=a,K=d,W=u,L=c,I=l,T=p,B=m,h=g,y=v,w=x,E=S,_=P,b=A,C=$,N=j;for(let U=0;U{t.update(e);let r=e.length%16;r&&t.update(CMe.subarray(r))},Zoe=(t,e,r,n,i)=>{let o=t(e,r,new Uint8Array(32)),s=OMe.poly1305.create(o);i&&Joe(s,i),Joe(s,n);let a=new Uint8Array(16),d=(0,Lu.createView)(a);(0,Lu.setBigUint64)(d,0,BigInt(i?i.length:0),!0),(0,Lu.setBigUint64)(d,8,BigInt(n.length),!0),s.update(a);let u=s.digest();return o.fill(0),u},$Me=t=>(e,r,n)=>((0,Lu.ensureBytes)(e,32),(0,Lu.ensureBytes)(r),{tagLength:16,encrypt:(o,s)=>{let a=o.length,d=a+16;s?(0,Lu.ensureBytes)(s,d):s=new Uint8Array(d),t(e,r,o,s,1);let u=Zoe(t,e,r,s.subarray(0,-16),n);return s.set(u,a),s},decrypt:(o,s)=>{let a=o.length,d=a-16;if(a<16)throw new Error("encrypted data must be at least 16 bytes");s?(0,Lu.ensureBytes)(s,d):s=new Uint8Array(d);let u=o.subarray(0,-16),c=o.subarray(-16),l=Zoe(t,e,r,u,n);if(!(0,Lu.equalBytes)(c,l))throw new Error("invalid tag");return t(e,r,u,s,1),s}});Jn._poly1305_aead=$Me;Jn.chacha20poly1305=(0,Jn._poly1305_aead)(Jn.chacha20);Jn.xchacha20poly1305=(0,Jn._poly1305_aead)(Jn.xchacha20)});var JE=V(cs=>{"use strict";f();Object.defineProperty(cs,"__esModule",{value:!0});cs.output=cs.exists=cs.hash=cs.bytes=cs.bool=cs.number=cs.isBytes=void 0;function iT(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}cs.number=iT;function Qoe(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}cs.bool=Qoe;function ese(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}cs.isBytes=ese;function t$(t,...e){if(!ese(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}`)}cs.bytes=t$;function tse(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");iT(t.outputLen),iT(t.blockLen)}cs.hash=tse;function rse(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")}cs.exists=rse;function nse(t,e){t$(t);let r=e.outputLen;if(t.length{"use strict";f();Object.defineProperty(oT,"__esModule",{value:!0});oT.crypto=void 0;oT.crypto=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0});var ZE=V(wt=>{"use strict";f();Object.defineProperty(wt,"__esModule",{value:!0});wt.randomBytes=wt.wrapXOFConstructorWithOpts=wt.wrapConstructorWithOpts=wt.wrapConstructor=wt.checkOpts=wt.Hash=wt.concatBytes=wt.toBytes=wt.utf8ToBytes=wt.asyncLoop=wt.nextTick=wt.hexToBytes=wt.bytesToHex=wt.byteSwap32=wt.byteSwapIfBE=wt.byteSwap=wt.isLE=wt.rotl=wt.rotr=wt.createView=wt.u32=wt.u8=wt.isBytes=void 0;var r$=ise(),i$=JE();function NMe(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}wt.isBytes=NMe;var UMe=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);wt.u8=UMe;var qMe=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));wt.u32=qMe;var LMe=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);wt.createView=LMe;var KMe=(t,e)=>t<<32-e|t>>>e;wt.rotr=KMe;var FMe=(t,e)=>t<>>32-e>>>0;wt.rotl=FMe;wt.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;var zMe=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255;wt.byteSwap=zMe;wt.byteSwapIfBE=wt.isLE?t=>t:t=>(0,wt.byteSwap)(t);function WMe(t){for(let e=0;ee.toString(16).padStart(2,"0"));function VMe(t){(0,i$.bytes)(t);let e="";for(let r=0;r=kh._0&&t<=kh._9)return t-kh._0;if(t>=kh._A&&t<=kh._F)return t-(kh._A-10);if(t>=kh._a&&t<=kh._f)return t-(kh._a-10)}function GMe(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let i=0,o=0;i{};wt.nextTick=JMe;async function ZMe(t,e,r){let n=Date.now();for(let i=0;i=0&&ot().update(sT(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}wt.wrapConstructor=eOe;function tOe(t){let e=(n,i)=>t(i).update(sT(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}wt.wrapConstructorWithOpts=tOe;function rOe(t){let e=(n,i)=>t(i).update(sT(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}wt.wrapXOFConstructorWithOpts=rOe;function nOe(t=32){if(r$.crypto&&typeof r$.crypto.getRandomValues=="function")return r$.crypto.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}wt.randomBytes=nOe});var cse=V(Cg=>{"use strict";f();Object.defineProperty(Cg,"__esModule",{value:!0});Cg.hmac=Cg.HMAC=void 0;var aT=JE(),ase=ZE(),YE=class extends ase.Hash{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,(0,aT.hash)(e);let n=(0,ase.toBytes)(r);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let i=this.blockLen,o=new Uint8Array(i);o.set(n.length>i?e.create().update(n).digest():n);for(let s=0;snew YE(t,e).update(r).digest();Cg.hmac=iOe;Cg.hmac.create=(t,e)=>new YE(t,e)});var pse=V(Nm=>{"use strict";f();Object.defineProperty(Nm,"__esModule",{value:!0});Nm.hkdf=Nm.expand=Nm.extract=void 0;var s$=JE(),dse=ZE(),lse=cse();function fse(t,e,r){return(0,s$.hash)(t),r===void 0&&(r=new Uint8Array(t.outputLen)),(0,lse.hmac)(t,(0,dse.toBytes)(r),(0,dse.toBytes)(e))}Nm.extract=fse;var o$=new Uint8Array([0]),use=new Uint8Array;function hse(t,e,r,n=32){if((0,s$.hash)(t),(0,s$.number)(n),n>255*t.outputLen)throw new Error("Length should be <= 255*HashLen");let i=Math.ceil(n/t.outputLen);r===void 0&&(r=use);let o=new Uint8Array(i*t.outputLen),s=lse.hmac.create(t,e),a=s._cloneInto(),d=new Uint8Array(s.outputLen);for(let u=0;uhse(t,fse(t,e,r),n,i);Nm.hkdf=oOe});var mse=V(Um=>{"use strict";f();Object.defineProperty(Um,"__esModule",{value:!0});Um.HashMD=Um.Maj=Um.Chi=void 0;var a$=JE(),XE=ZE();function sOe(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),d=n?4:0,u=n?0:4;t.setUint32(e+d,s,n),t.setUint32(e+u,a,n)}var aOe=(t,e,r)=>t&e^~t&r;Um.Chi=aOe;var cOe=(t,e,r)=>t&e^t&r^e&r;Um.Maj=cOe;var c$=class extends XE.Hash{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=(0,XE.createView)(this.buffer)}update(e){(0,a$.exists)(this);let{view:r,buffer:n,blockLen:i}=this;e=(0,XE.toBytes)(e);let o=e.length;for(let s=0;si-s&&(this.process(n,0),s=0);for(let l=s;lc.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l{"use strict";f();Object.defineProperty(g1,"__esModule",{value:!0});g1.sha224=g1.sha256=void 0;var d$=mse(),Nd=ZE(),dOe=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]),qm=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Lm=new Uint32Array(64),cT=class extends d$.HashMD{constructor(){super(64,32,8,!1),this.A=qm[0]|0,this.B=qm[1]|0,this.C=qm[2]|0,this.D=qm[3]|0,this.E=qm[4]|0,this.F=qm[5]|0,this.G=qm[6]|0,this.H=qm[7]|0}get(){let{A:e,B:r,C:n,D:i,E:o,F:s,G:a,H:d}=this;return[e,r,n,i,o,s,a,d]}set(e,r,n,i,o,s,a,d){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=d|0}process(e,r){for(let l=0;l<16;l++,r+=4)Lm[l]=e.getUint32(r,!1);for(let l=16;l<64;l++){let p=Lm[l-15],m=Lm[l-2],g=(0,Nd.rotr)(p,7)^(0,Nd.rotr)(p,18)^p>>>3,v=(0,Nd.rotr)(m,17)^(0,Nd.rotr)(m,19)^m>>>10;Lm[l]=v+Lm[l-7]+g+Lm[l-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:d,G:u,H:c}=this;for(let l=0;l<64;l++){let p=(0,Nd.rotr)(a,6)^(0,Nd.rotr)(a,11)^(0,Nd.rotr)(a,25),m=c+p+(0,d$.Chi)(a,d,u)+dOe[l]+Lm[l]|0,v=((0,Nd.rotr)(n,2)^(0,Nd.rotr)(n,13)^(0,Nd.rotr)(n,22))+(0,d$.Maj)(n,i,o)|0;c=u,u=d,d=a,a=s+m|0,s=o,o=i,i=n,n=m+v|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,d=d+this.F|0,u=u+this.G|0,c=c+this.H|0,this.set(n,i,o,s,a,d,u,c)}roundClean(){Lm.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},u$=class extends cT{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}};g1.sha256=(0,Nd.wrapConstructor)(()=>new cT);g1.sha224=(0,Nd.wrapConstructor)(()=>new u$)});var bse=V(dT=>{"use strict";f();Object.defineProperty(dT,"__esModule",{value:!0});dT.aes256gcm=void 0;var gse=$u(),vse=qA(),l$=NE();function uOe(t,e,r){var n=function(o){var s=(0,vse.createCipheriv)("aes-256-gcm",t,e);r&&s.setAAD(r);var a=s.update(o),d=s.final();return(0,gse.concatBytes)(a,d,s.getAuthTag())},i=function(o){var s=o.subarray(0,o.length-l$.AEAD_TAG_LENGTH),a=o.subarray(-l$.AEAD_TAG_LENGTH),d=(0,vse.createDecipheriv)("aes-256-gcm",t,e);r&&d.setAAD(r),d.setAuthTag(a);var u=d.update(s),c=d.final();return(0,gse.concatBytes)(u,c)};return{tagLength:l$.AEAD_TAG_LENGTH,encrypt:n,decrypt:i}}dT.aes256gcm=uOe});var f$=V(Km=>{"use strict";f();Object.defineProperty(Km,"__esModule",{value:!0});Km.deriveKey=Km.aesDecrypt=Km.aesEncrypt=void 0;var lOe=Xoe(),_se=$u(),fOe=uC(),hOe=pse(),pOe=yse(),wse=Rg(),uT=NE(),mOe=bse();function yOe(t,e){return xse(!0,t,e)}Km.aesEncrypt=yOe;function gOe(t,e){return xse(!1,t,e)}Km.aesDecrypt=gOe;function vOe(t){return(0,hOe.hkdf)(pOe.sha256,t,void 0,void 0,32)}Km.deriveKey=vOe;function xse(t,e,r){var n=(0,wse.symmetricAlgorithm)(),i=t?bOe:wOe;if(n==="aes-256-gcm")return i(mOe.aes256gcm,e,r,(0,wse.symmetricNonceLength)());if(n==="xchacha20")return i(lOe.xchacha20poly1305,e,r,uT.XCHACHA20_NONCE_LENGTH);throw new Error("Not implemented")}function bOe(t,e,r,n){var i=(0,fOe.randomBytes)(n),o=t(e,i),s=o.encrypt(r),a=s.subarray(0,s.length-uT.AEAD_TAG_LENGTH),d=s.subarray(-uT.AEAD_TAG_LENGTH);return(0,_se.concatBytes)(i,d,a)}function wOe(t,e,r,n){var i=n+uT.AEAD_TAG_LENGTH,o=r.subarray(0,n),s=r.subarray(n,i),a=r.subarray(i),d=t(e,Uint8Array.from(o)),u=(0,_se.concatBytes)(a,s);return d.decrypt(u)}});var Tse=V(ta=>{"use strict";f();Object.defineProperty(ta,"__esModule",{value:!0});ta.hexToPublicKey=ta.convertPublicKeyFormat=ta.getSharedPoint=ta.getSharedKey=ta.getPublicKey=ta.isValidPrivateKey=ta.getValidSecret=void 0;var _Oe=$u(),xOe=uC(),Ese=woe(),EOe=qoe(),h$=Rg(),Sse=NE(),SOe=ZC(),AOe=f$();function TOe(){var t;do t=(0,xOe.randomBytes)(Sse.SECRET_KEY_LENGTH);while(!Ase(t));return t}ta.getValidSecret=TOe;function Ase(t){return QE(function(e){return e.utils.isValidPrivateKey(t)},function(){return!0},function(){return!0})}ta.isValidPrivateKey=Ase;function POe(t){return QE(function(e){return e.getPublicKey(t)},function(e){return e.getPublicKey(t)},function(e){return e.getPublicKey(t)})}ta.getPublicKey=POe;function IOe(t,e){return(0,AOe.deriveKey)((0,_Oe.concatBytes)(t,e))}ta.getSharedKey=IOe;function kOe(t,e,r){return QE(function(n){return n.getSharedSecret(t,e,r)},function(n){return n.getSharedSecret(t,e)},function(n){var i=n.utils.getExtendedPublicKey(t).scalar,o=n.ExtendedPoint.fromHex(e).multiply(i);return o.toRawBytes()})}ta.getSharedPoint=kOe;function ROe(t,e){return QE(function(r){return r.getSharedSecret(BigInt(1),t,e)},function(){return t},function(){return t})}ta.convertPublicKeyFormat=ROe;function DOe(t){var e=(0,SOe.decodeHex)(t);return QE(function(){if(e.length===Sse.ETH_PUBLIC_KEY_SIZE){var r=new Uint8Array(1+e.length);return r.set([4]),r.set(e,1),r}return e},function(){return e},function(){return e})}ta.hexToPublicKey=DOe;function QE(t,e,r){if((0,h$.ellipticCurve)()==="secp256k1")return t(EOe.secp256k1);if((0,h$.ellipticCurve)()==="x25519")return e(Ese.x25519);if((0,h$.ellipticCurve)()==="ed25519")return r(Ese.ed25519);throw new Error("Not implemented")}});var lT=V(Rh=>{"use strict";f();var BOe=Rh&&Rh.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),p$=Rh&&Rh.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&BOe(e,t,r)};Object.defineProperty(Rh,"__esModule",{value:!0});p$(Tse(),Rh);p$(ZC(),Rh);p$(f$(),Rh)});var y$=V(hT=>{"use strict";f();Object.defineProperty(hT,"__esModule",{value:!0});hT.PublicKey=void 0;var m$=$u(),MOe=Rg(),fT=lT(),OOe=function(){function t(e){this.data=(0,fT.convertPublicKeyFormat)(e,!0)}return t.fromHex=function(e){return new t((0,fT.hexToPublicKey)(e))},Object.defineProperty(t.prototype,"uncompressed",{get:function(){return O.Buffer.from((0,fT.convertPublicKeyFormat)(this.data,!1))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"compressed",{get:function(){return O.Buffer.from(this.data)},enumerable:!1,configurable:!0}),t.prototype.toHex=function(e){return e===void 0&&(e=!0),e?(0,m$.bytesToHex)(this.data):(0,m$.bytesToHex)(this.uncompressed)},t.prototype.decapsulate=function(e){var r,n;return(0,MOe.isHkdfKeyCompressed)()?(r=this.data,n=e.multiply(this,!0)):(r=this.uncompressed,n=e.multiply(this,!1)),(0,fT.getSharedKey)(r,n)},t.prototype.equals=function(e){return(0,m$.equalBytes)(this.data,e.data)},t}();hT.PublicKey=OOe});var Ise=V(pT=>{"use strict";f();Object.defineProperty(pT,"__esModule",{value:!0});pT.PrivateKey=void 0;var Pse=$u(),COe=Rg(),v1=lT(),$Oe=y$(),jOe=function(){function t(e){var r=e===void 0?(0,v1.getValidSecret)():e;if(!(0,v1.isValidPrivateKey)(r))throw new Error("Invalid private key");this.data=r,this.publicKey=new $Oe.PublicKey((0,v1.getPublicKey)(r))}return t.fromHex=function(e){return new t((0,v1.decodeHex)(e))},Object.defineProperty(t.prototype,"secret",{get:function(){return O.Buffer.from(this.data)},enumerable:!1,configurable:!0}),t.prototype.toHex=function(){return(0,Pse.bytesToHex)(this.data)},t.prototype.encapsulate=function(e){var r,n;return(0,COe.isHkdfKeyCompressed)()?(r=this.publicKey.compressed,n=this.multiply(e,!0)):(r=this.publicKey.uncompressed,n=this.multiply(e,!1)),(0,v1.getSharedKey)(r,n)},t.prototype.multiply=function(e,r){return r===void 0&&(r=!1),(0,v1.getSharedPoint)(this.data,e.compressed,r)},t.prototype.equals=function(e){return(0,Pse.equalBytes)(this.data,e.data)},t}();pT.PrivateKey=jOe});var g$=V(b1=>{"use strict";f();Object.defineProperty(b1,"__esModule",{value:!0});b1.PublicKey=b1.PrivateKey=void 0;var NOe=Ise();Object.defineProperty(b1,"PrivateKey",{enumerable:!0,get:function(){return NOe.PrivateKey}});var UOe=y$();Object.defineProperty(b1,"PublicKey",{enumerable:!0,get:function(){return UOe.PublicKey}})});var Dse=V(nc=>{"use strict";f();Object.defineProperty(nc,"__esModule",{value:!0});nc.utils=nc.PublicKey=nc.PrivateKey=nc.ECIES_CONFIG=nc.decrypt=nc.encrypt=void 0;var qOe=$u(),kse=Rg(),w1=g$(),$g=lT();function LOe(t,e){var r=new w1.PrivateKey,n=t instanceof Uint8Array?new w1.PublicKey(t):w1.PublicKey.fromHex(t),i=r.encapsulate(n),o=(0,$g.aesEncrypt)(i,e),s;return(0,kse.isEphemeralKeyCompressed)()?s=r.publicKey.compressed:s=r.publicKey.uncompressed,O.Buffer.from((0,qOe.concatBytes)(s,o))}nc.encrypt=LOe;function KOe(t,e){var r=t instanceof Uint8Array?new w1.PrivateKey(t):w1.PrivateKey.fromHex(t),n=(0,kse.ephemeralKeySize)(),i=new w1.PublicKey(e.subarray(0,n)),o=e.subarray(n),s=i.decapsulate(r);return O.Buffer.from((0,$g.aesDecrypt)(s,o))}nc.decrypt=KOe;var FOe=Rg();Object.defineProperty(nc,"ECIES_CONFIG",{enumerable:!0,get:function(){return FOe.ECIES_CONFIG}});var Rse=g$();Object.defineProperty(nc,"PrivateKey",{enumerable:!0,get:function(){return Rse.PrivateKey}});Object.defineProperty(nc,"PublicKey",{enumerable:!0,get:function(){return Rse.PublicKey}});nc.utils={aesDecrypt:$g.aesDecrypt,aesEncrypt:$g.aesEncrypt,decodeHex:$g.decodeHex,getValidSecret:$g.getValidSecret,remove0x:$g.remove0x}});var ni=V((z2t,Bse)=>{"use strict";f();Bse.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 Dh=V((H2t,mT)=>{"use strict";f();var{AbortController:Mse,AbortSignal:zOe}=typeof self<"u"?self:typeof window<"u"?window:void 0;mT.exports=Mse;mT.exports.AbortSignal=zOe;mT.exports.default=Mse});var ra=V((G2t,b$)=>{"use strict";f();var WOe=pn(),{kResistStopPropagation:HOe,SymbolDispose:VOe}=ni(),GOe=globalThis.AbortSignal||Dh().AbortSignal,JOe=globalThis.AbortController||Dh().AbortController,ZOe=Object.getPrototypeOf(async function(){}).constructor,Ose=globalThis.Blob||WOe.Blob,YOe=typeof Ose<"u"?function(e){return e instanceof Ose}:function(e){return!1},Cse=(t,e)=>{if(t!==void 0&&(t===null||typeof t!="object"||!("aborted"in t)))throw new ERR_INVALID_ARG_TYPE(e,"AbortSignal",t)},XOe=(t,e)=>{if(typeof t!="function")throw new ERR_INVALID_ARG_TYPE(e,"Function",t)},v$=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{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 ZOe},isArrayBufferView(t){return ArrayBuffer.isView(t)}},isBlob:YOe,deprecate(t,e){return t},addAbortListener:Aa().addAbortListener||function(e,r){if(e===void 0)throw new ERR_INVALID_ARG_TYPE("signal","AbortSignal",e);Cse(e,"signal"),XOe(r,"listener");let n;return e.aborted?queueMicrotask(()=>r()):(e.addEventListener("abort",r,{__proto__:null,once:!0,[HOe]:!0}),n=()=>{e.removeEventListener("abort",r)}),{__proto__:null,[VOe](){var i;(i=n)===null||i===void 0||i()}}},AbortSignalAny:GOe.any||function(e){if(e.length===1)return e[0];let r=new JOe,n=()=>r.abort();return e.forEach(i=>{Cse(i,"signals"),i.addEventListener("abort",n,{once:!0})}),r.signal.addEventListener("abort",()=>{e.forEach(i=>i.removeEventListener("abort",n))},{once:!0}),r.signal}};b$.exports.promisify.custom=Symbol.for("nodejs.util.promisify.custom")});var ka=V((Z2t,Nse)=>{"use strict";f();var{format:QOe,inspect:yT,AggregateError:eCe}=ra(),tCe=globalThis.AggregateError||eCe,rCe=Symbol("kIsNodeError"),nCe=["string","function","number","object","Function","Object","boolean","bigint","symbol"],iCe=/^([A-Z][a-z0-9]*)+$/,oCe="__node_internal_",gT={};function jg(t,e){if(!t)throw new gT.ERR_INTERNAL_ASSERTION(e)}function $se(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 sCe(t,e,r){if(typeof e=="function")return jg(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 jg(n===r.length,`Code: ${t}; The provided arguments length (${r.length}) does not match the required ones (${n}).`),r.length===0?e:QOe(e,...r)}function ds(t,e,r){r||(r=Error);class n extends r{constructor(...o){super(sCe(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[rCe]=!0,gT[t]=n}function jse(t){let e=oCe+t.name;return Object.defineProperty(t,"name",{value:e}),t}function aCe(t,e){if(t&&e&&t!==e){if(Array.isArray(e.errors))return e.errors.push(t),e;let r=new tCe([e,t],e.message);return r.code=e.code,r}return t||e}var w$=class extends Error{constructor(e="The operation was aborted",r=void 0){if(r!==void 0&&typeof r!="object")throw new gT.ERR_INVALID_ARG_TYPE("options","Object",r);super(e,r),this.code="ABORT_ERR",this.name="AbortError"}};ds("ERR_ASSERTION","%s",Error);ds("ERR_INVALID_ARG_TYPE",(t,e,r)=>{jg(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 d of e)jg(typeof d=="string","All expected entries have to be of type string"),nCe.includes(d)?i.push(d.toLowerCase()):iCe.test(d)?o.push(d):(jg(d!=="object",'The value "object" should be written as "Object"'),s.push(d));if(o.length>0){let d=i.indexOf("object");d!==-1&&(i.splice(i,d,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 d=i.pop();n+=`one of type ${i.join(", ")}, or ${d}`}}(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 d=o.pop();n+=`an instance of ${o.join(", ")}, or ${d}`}}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 d=s.pop();n+=`one of ${s.join(", ")}, or ${d}`}}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 d=yT(r,{depth:-1});n+=`. Received ${d}`}}else{let d=yT(r,{colors:!1});d.length>25&&(d=`${d.slice(0,25)}...`),n+=`. Received type ${typeof r} (${d})`}return n},TypeError);ds("ERR_INVALID_ARG_VALUE",(t,e,r="is invalid")=>{let n=yT(e);return n.length>128&&(n=n.slice(0,128)+"..."),`The ${t.includes(".")?"property":"argument"} '${t}' ${r}. Received ${n}`},TypeError);ds("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);ds("ERR_MISSING_ARGS",(...t)=>{jg(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);ds("ERR_OUT_OF_RANGE",(t,e,r)=>{jg(e,'Missing "range" argument');let n;return Number.isInteger(r)&&Math.abs(r)>2**32?n=$se(String(r)):typeof r=="bigint"?(n=String(r),(r>2n**32n||r<-(2n**32n))&&(n=$se(n)),n+="n"):n=yT(r),`The value of "${t}" is out of range. It must be ${e}. Received ${n}`},RangeError);ds("ERR_MULTIPLE_CALLBACK","Callback called multiple times",Error);ds("ERR_METHOD_NOT_IMPLEMENTED","The %s method is not implemented",Error);ds("ERR_STREAM_ALREADY_FINISHED","Cannot call %s after a stream was finished",Error);ds("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable",Error);ds("ERR_STREAM_DESTROYED","Cannot call %s after a stream was destroyed",Error);ds("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);ds("ERR_STREAM_PREMATURE_CLOSE","Premature close",Error);ds("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF",Error);ds("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event",Error);ds("ERR_STREAM_WRITE_AFTER_END","write after end",Error);ds("ERR_UNKNOWN_ENCODING","Unknown encoding: %s",TypeError);Nse.exports={AbortError:w$,aggregateTwoErrors:jse(aCe),hideStackFrames:jse,codes:gT}});var x1=V((X2t,Gse)=>{"use strict";f();var{ArrayIsArray:x$,ArrayPrototypeIncludes:Kse,ArrayPrototypeJoin:Fse,ArrayPrototypeMap:cCe,NumberIsInteger:E$,NumberIsNaN:dCe,NumberMAX_SAFE_INTEGER:uCe,NumberMIN_SAFE_INTEGER:lCe,NumberParseInt:fCe,ObjectPrototypeHasOwnProperty:hCe,RegExpPrototypeExec:zse,String:pCe,StringPrototypeToUpperCase:mCe,StringPrototypeTrim:yCe}=ni(),{hideStackFrames:Ud,codes:{ERR_SOCKET_BAD_PORT:gCe,ERR_INVALID_ARG_TYPE:na,ERR_INVALID_ARG_VALUE:_1,ERR_OUT_OF_RANGE:Ng,ERR_UNKNOWN_SIGNAL:Use}}=ka(),{normalizeEncoding:vCe}=ra(),{isAsyncFunction:bCe,isArrayBufferView:wCe}=ra().types,qse={};function _Ce(t){return t===(t|0)}function xCe(t){return t===t>>>0}var ECe=/^[0-7]+$/,SCe="must be a 32-bit unsigned integer or an octal string";function ACe(t,e,r){if(typeof t>"u"&&(t=r),typeof t=="string"){if(zse(ECe,t)===null)throw new _1(e,t,SCe);t=fCe(t,8)}return Wse(t,e),t}var TCe=Ud((t,e,r=lCe,n=uCe)=>{if(typeof t!="number")throw new na(e,"number",t);if(!E$(t))throw new Ng(e,"an integer",t);if(tn)throw new Ng(e,`>= ${r} && <= ${n}`,t)}),PCe=Ud((t,e,r=-2147483648,n=2147483647)=>{if(typeof t!="number")throw new na(e,"number",t);if(!E$(t))throw new Ng(e,"an integer",t);if(tn)throw new Ng(e,`>= ${r} && <= ${n}`,t)}),Wse=Ud((t,e,r=!1)=>{if(typeof t!="number")throw new na(e,"number",t);if(!E$(t))throw new Ng(e,"an integer",t);let n=r?1:0,i=4294967295;if(ti)throw new Ng(e,`>= ${n} && <= ${i}`,t)});function S$(t,e){if(typeof t!="string")throw new na(e,"string",t)}function ICe(t,e,r=void 0,n){if(typeof t!="number")throw new na(e,"number",t);if(r!=null&&tn||(r!=null||n!=null)&&dCe(t))throw new Ng(e,`${r!=null?`>= ${r}`:""}${r!=null&&n!=null?" && ":""}${n!=null?`<= ${n}`:""}`,t)}var kCe=Ud((t,e,r)=>{if(!Kse(r,t)){let i="must be one of: "+Fse(cCe(r,o=>typeof o=="string"?`'${o}'`:pCe(o)),", ");throw new _1(e,t,i)}});function Hse(t,e){if(typeof t!="boolean")throw new na(e,"boolean",t)}function _$(t,e,r){return t==null||!hCe(t,e)?r:t[e]}var RCe=Ud((t,e,r=null)=>{let n=_$(r,"allowArray",!1),i=_$(r,"allowFunction",!1);if(!_$(r,"nullable",!1)&&t===null||!n&&x$(t)||typeof t!="object"&&(!i||typeof t!="function"))throw new na(e,"Object",t)}),DCe=Ud((t,e)=>{if(t!=null&&typeof t!="object"&&typeof t!="function")throw new na(e,"a dictionary",t)}),vT=Ud((t,e,r=0)=>{if(!x$(t))throw new na(e,"Array",t);if(t.length{if(!wCe(t))throw new na(e,["Buffer","TypedArray","DataView"],t)});function jCe(t,e){let r=vCe(e),n=t.length;if(r==="hex"&&n%2!==0)throw new _1("encoding",e,`is invalid for data of length ${n}`)}function NCe(t,e="Port",r=!0){if(typeof t!="number"&&typeof t!="string"||typeof t=="string"&&yCe(t).length===0||+t!==+t>>>0||t>65535||t===0&&!r)throw new gCe(e,t,r);return t|0}var Vse=Ud((t,e)=>{if(t!==void 0&&(t===null||typeof t!="object"||!("aborted"in t)))throw new na(e,"AbortSignal",t)}),UCe=Ud((t,e)=>{if(typeof t!="function")throw new na(e,"Function",t)}),qCe=Ud((t,e)=>{if(typeof t!="function"||bCe(t))throw new na(e,"Function",t)}),LCe=Ud((t,e)=>{if(t!==void 0)throw new na(e,"undefined",t)});function KCe(t,e,r){if(!Kse(r,t))throw new na(e,`('${Fse(r,"|")}')`,t)}var FCe=/^(?:<[^>]*>)(?:\s*;\s*[^;"\s]+(?:=(")?[^;"\s]*\1)?)*$/;function Lse(t,e){if(typeof t>"u"||!zse(FCe,t))throw new _1(e,t,'must be an array or string of format "; rel=preload; as=style"')}function zCe(t){if(typeof t=="string")return Lse(t,"hints"),t;if(x$(t)){let e=t.length,r="";if(e===0)return r;for(let n=0;n; rel=preload; as=style"')}Gse.exports={isInt32:_Ce,isUint32:xCe,parseFileMode:ACe,validateArray:vT,validateStringArray:BCe,validateBooleanArray:MCe,validateAbortSignalArray:OCe,validateBoolean:Hse,validateBuffer:$Ce,validateDictionary:DCe,validateEncoding:jCe,validateFunction:UCe,validateInt32:PCe,validateInteger:TCe,validateNumber:ICe,validateObject:RCe,validateOneOf:kCe,validatePlainFunction:qCe,validatePort:NCe,validateSignalName:CCe,validateString:S$,validateUint32:Wse,validateUndefined:LCe,validateUnion:KCe,validateAbortSignal:Vse,validateLinkHeaderValue:zCe}});var Yl=V((e_t,dae)=>{"use strict";f();var{SymbolAsyncIterator:Jse,SymbolIterator:Zse,SymbolFor:Ug}=ni(),Yse=Ug("nodejs.stream.destroyed"),Xse=Ug("nodejs.stream.errored"),A$=Ug("nodejs.stream.readable"),T$=Ug("nodejs.stream.writable"),Qse=Ug("nodejs.stream.disturbed"),WCe=Ug("nodejs.webstream.isClosedPromise"),HCe=Ug("nodejs.webstream.controllerErrorFunction");function bT(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 wT(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 VCe(t){return!!(t&&typeof t.pipe=="function"&&t._readableState&&typeof t.on=="function"&&typeof t.write=="function")}function Zl(t){return t&&(t._readableState||t._writableState||typeof t.write=="function"&&typeof t.on=="function"||typeof t.pipe=="function"&&typeof t.on=="function")}function eae(t){return!!(t&&!Zl(t)&&typeof t.pipeThrough=="function"&&typeof t.getReader=="function"&&typeof t.cancel=="function")}function tae(t){return!!(t&&!Zl(t)&&typeof t.getWriter=="function"&&typeof t.abort=="function")}function rae(t){return!!(t&&!Zl(t)&&typeof t.readable=="object"&&typeof t.writable=="object")}function GCe(t){return eae(t)||tae(t)||rae(t)}function JCe(t,e){return t==null?!1:e===!0?typeof t[Jse]=="function":e===!1?typeof t[Zse]=="function":typeof t[Jse]=="function"||typeof t[Zse]=="function"}function _T(t){if(!Zl(t))return null;let e=t._writableState,r=t._readableState,n=e||r;return!!(t.destroyed||t[Yse]||n!=null&&n.destroyed)}function nae(t){if(!wT(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 ZCe(t,e){if(!wT(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 YCe(t){if(!bT(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 iae(t,e){if(!bT(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 oae(t){return t&&t[A$]!=null?t[A$]:typeof t?.readable!="boolean"?null:_T(t)?!1:bT(t)&&t.readable&&!iae(t)}function sae(t){return t&&t[T$]!=null?t[T$]:typeof t?.writable!="boolean"?null:_T(t)?!1:wT(t)&&t.writable&&!nae(t)}function XCe(t,e){return Zl(t)?_T(t)?!0:!(e?.readable!==!1&&oae(t)||e?.writable!==!1&&sae(t)):null}function QCe(t){var e,r;return Zl(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 e$e(t){var e,r;return Zl(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 t$e(t){if(!Zl(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"&&aae(t)?t._closed:null}function aae(t){return typeof t._closed=="boolean"&&typeof t._defaultKeepAlive=="boolean"&&typeof t._removedConnection=="boolean"&&typeof t._removedContLen=="boolean"}function cae(t){return typeof t._sent100=="boolean"&&aae(t)}function r$e(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 n$e(t){if(!Zl(t))return null;let e=t._writableState,r=t._readableState,n=e||r;return!n&&cae(t)||!!(n&&n.autoDestroy&&n.emitClose&&n.closed===!1)}function i$e(t){var e;return!!(t&&((e=t[Qse])!==null&&e!==void 0?e:t.readableDidRead||t.readableAborted))}function o$e(t){var e,r,n,i,o,s,a,d,u,c;return!!(t&&((e=(r=(n=(i=(o=(s=t[Xse])!==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:(d=t._writableState)===null||d===void 0?void 0:d.errorEmitted)!==null&&r!==void 0?r:(u=t._readableState)===null||u===void 0?void 0:u.errored)!==null&&e!==void 0?e:!((c=t._writableState)===null||c===void 0)&&c.errored))}dae.exports={isDestroyed:_T,kIsDestroyed:Yse,isDisturbed:i$e,kIsDisturbed:Qse,isErrored:o$e,kIsErrored:Xse,isReadable:oae,kIsReadable:A$,kIsClosedPromise:WCe,kControllerErrorFunction:HCe,kIsWritable:T$,isClosed:t$e,isDuplexNodeStream:VCe,isFinished:XCe,isIterable:JCe,isReadableNodeStream:bT,isReadableStream:eae,isReadableEnded:YCe,isReadableFinished:iae,isReadableErrored:e$e,isNodeStream:Zl,isWebStream:GCe,isWritable:sae,isWritableNodeStream:wT,isWritableStream:tae,isWritableEnded:nae,isWritableFinished:ZCe,isWritableErrored:QCe,isServerRequest:r$e,isServerResponse:cae,willEmitClose:n$e,isTransformStream:rae}});var Bh=V((r_t,D$)=>{f();var Fm=js(),{AbortError:vae,codes:s$e}=ka(),{ERR_INVALID_ARG_TYPE:a$e,ERR_STREAM_PREMATURE_CLOSE:uae}=s$e,{kEmptyObject:I$,once:k$}=ra(),{validateAbortSignal:c$e,validateFunction:d$e,validateObject:u$e,validateBoolean:l$e}=x1(),{Promise:f$e,PromisePrototypeThen:h$e,SymbolDispose:bae}=ni(),{isClosed:p$e,isReadable:lae,isReadableNodeStream:P$,isReadableStream:m$e,isReadableFinished:fae,isReadableErrored:hae,isWritable:pae,isWritableNodeStream:mae,isWritableStream:y$e,isWritableFinished:yae,isWritableErrored:gae,isNodeStream:g$e,willEmitClose:v$e,kIsClosedPromise:b$e}=Yl(),E1;function w$e(t){return t.setHeader&&typeof t.abort=="function"}var R$=()=>{};function wae(t,e,r){var n,i;if(arguments.length===2?(r=e,e=I$):e==null?e=I$:u$e(e,"options"),d$e(r,"callback"),c$e(e.signal,"options.signal"),r=k$(r),m$e(t)||y$e(t))return _$e(t,e,r);if(!g$e(t))throw new a$e("stream",["ReadableStream","WritableStream","Stream"],t);let o=(n=e.readable)!==null&&n!==void 0?n:P$(t),s=(i=e.writable)!==null&&i!==void 0?i:mae(t),a=t._writableState,d=t._readableState,u=()=>{t.writable||p()},c=v$e(t)&&P$(t)===o&&mae(t)===s,l=yae(t,!1),p=()=>{l=!0,t.destroyed&&(c=!1),!(c&&(!t.readable||o))&&(!o||m)&&r.call(t)},m=fae(t,!1),g=()=>{m=!0,t.destroyed&&(c=!1),!(c&&(!t.writable||s))&&(!s||l)&&r.call(t)},v=j=>{r.call(t,j)},x=p$e(t),S=()=>{x=!0;let j=gae(t)||hae(t);if(j&&typeof j!="boolean")return r.call(t,j);if(o&&!m&&P$(t,!0)&&!fae(t,!1))return r.call(t,new uae);if(s&&!l&&!yae(t,!1))return r.call(t,new uae);r.call(t)},P=()=>{x=!0;let j=gae(t)||hae(t);if(j&&typeof j!="boolean")return r.call(t,j);r.call(t)},A=()=>{t.req.on("finish",p)};w$e(t)?(t.on("complete",p),c||t.on("abort",S),t.req?A():t.on("request",A)):s&&!a&&(t.on("end",u),t.on("close",u)),!c&&typeof t.aborted=="boolean"&&t.on("aborted",S),t.on("end",g),t.on("finish",p),e.error!==!1&&t.on("error",v),t.on("close",S),x?Fm.nextTick(S):a!=null&&a.errorEmitted||d!=null&&d.errorEmitted?c||Fm.nextTick(P):(!o&&(!c||lae(t))&&(l||pae(t)===!1)||!s&&(!c||pae(t))&&(m||lae(t)===!1)||d&&t.req&&t.aborted)&&Fm.nextTick(P);let $=()=>{r=R$,t.removeListener("aborted",S),t.removeListener("complete",p),t.removeListener("abort",S),t.removeListener("request",A),t.req&&t.req.removeListener("finish",p),t.removeListener("end",u),t.removeListener("close",u),t.removeListener("finish",p),t.removeListener("end",g),t.removeListener("error",v),t.removeListener("close",S)};if(e.signal&&!x){let j=()=>{let q=r;$(),q.call(t,new vae(void 0,{cause:e.signal.reason}))};if(e.signal.aborted)Fm.nextTick(j);else{E1=E1||ra().addAbortListener;let q=E1(e.signal,j),F=r;r=k$((...K)=>{q[bae](),F.apply(t,K)})}}return $}function _$e(t,e,r){let n=!1,i=R$;if(e.signal)if(i=()=>{n=!0,r.call(t,new vae(void 0,{cause:e.signal.reason}))},e.signal.aborted)Fm.nextTick(i);else{E1=E1||ra().addAbortListener;let s=E1(e.signal,i),a=r;r=k$((...d)=>{s[bae](),a.apply(t,d)})}let o=(...s)=>{n||Fm.nextTick(()=>r.apply(t,s))};return h$e(t[b$e].promise,o,o),R$}function x$e(t,e){var r;let n=!1;return e===null&&(e=I$),(r=e)!==null&&r!==void 0&&r.cleanup&&(l$e(e.cleanup,"cleanup"),n=e.cleanup),new f$e((i,o)=>{let s=wae(t,e,a=>{n&&s(),a?o(a):i()})})}D$.exports=wae;D$.exports.finished=x$e});var qg=V((i_t,Iae)=>{"use strict";f();var Xl=js(),{aggregateTwoErrors:E$e,codes:{ERR_MULTIPLE_CALLBACK:S$e},AbortError:A$e}=ka(),{Symbol:Eae}=ni(),{kIsDestroyed:T$e,isDestroyed:P$e,isFinished:I$e,isServerRequest:k$e}=Yl(),Sae=Eae("kDestroy"),B$=Eae("kConstruct");function Aae(t,e,r){t&&(t.stack,e&&!e.errored&&(e.errored=t),r&&!r.errored&&(r.errored=t))}function R$e(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):(Aae(t,n,r),n&&(n.destroyed=!0),r&&(r.destroyed=!0),i.constructed?_ae(this,t,e):this.once(Sae,function(o){_ae(this,E$e(o,t),e)}),this)}function _ae(t,e,r){let n=!1;function i(o){if(n)return;n=!0;let s=t._readableState,a=t._writableState;Aae(o,a,s),a&&(a.closed=!0),s&&(s.closed=!0),typeof r=="function"&&r(o),o?Xl.nextTick(D$e,t,o):Xl.nextTick(Tae,t)}try{t._destroy(e||null,i)}catch(o){i(o)}}function D$e(t,e){M$(t,e),Tae(t)}function Tae(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 M$(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 B$e(){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 O$(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?Xl.nextTick(M$,t,e):M$(t,e))}function M$e(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(B$,e),!(t.listenerCount(B$)>1)&&Xl.nextTick(O$e,t)}function O$e(t){let e=!1;function r(n){if(e){O$(t,n??new S$e);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(Sae,n):n?O$(t,n,!0):Xl.nextTick(C$e,t)}try{t._construct(n=>{Xl.nextTick(r,n)})}catch(n){Xl.nextTick(r,n)}}function C$e(t){t.emit(B$)}function xae(t){return t?.setHeader&&typeof t.abort=="function"}function Pae(t){t.emit("close")}function $$e(t,e){t.emit("error",e),Xl.nextTick(Pae,t)}function j$e(t,e){!t||P$e(t)||(!e&&!I$e(t)&&(e=new A$e),k$e(t)?(t.socket=null,t.destroy(e)):xae(t)?t.abort():xae(t.req)?t.req.abort():typeof t.destroy=="function"?t.destroy(e):typeof t.close=="function"?t.close():e?Xl.nextTick($$e,t,e):Xl.nextTick(Pae,t),t.destroyed||(t[T$e]=!0))}Iae.exports={construct:M$e,destroyer:j$e,destroy:R$e,undestroy:B$e,errorOrDestroy:O$}});var ST=V((s_t,Rae)=>{"use strict";f();var{ArrayIsArray:N$e,ObjectSetPrototypeOf:kae}=ni(),{EventEmitter:xT}=Aa();function ET(t){xT.call(this,t)}kae(ET.prototype,xT.prototype);kae(ET,xT);ET.prototype.pipe=function(t,e){let r=this;function n(c){t.writable&&t.write(c)===!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 d(c){u(),xT.listenerCount(this,"error")===0&&this.emit("error",c)}C$(r,"error",d),C$(t,"error",d);function u(){r.removeListener("data",n),t.removeListener("drain",i),r.removeListener("end",s),r.removeListener("close",a),r.removeListener("error",d),t.removeListener("error",d),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 C$(t,e,r){if(typeof t.prependListener=="function")return t.prependListener(e,r);!t._events||!t._events[e]?t.on(e,r):N$e(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]}Rae.exports={Stream:ET,prependListener:C$}});var e6=V((c_t,AT)=>{"use strict";f();var{SymbolDispose:U$e}=ni(),{AbortError:Dae,codes:q$e}=ka(),{isNodeStream:Bae,isWebStream:L$e,kControllerErrorFunction:K$e}=Yl(),F$e=Bh(),{ERR_INVALID_ARG_TYPE:Mae}=q$e,$$,z$e=(t,e)=>{if(typeof t!="object"||!("aborted"in t))throw new Mae(e,"AbortSignal",t)};AT.exports.addAbortSignal=function(e,r){if(z$e(e,"signal"),!Bae(r)&&!L$e(r))throw new Mae("stream",["ReadableStream","WritableStream","Stream"],r);return AT.exports.addAbortSignalNoValidate(e,r)};AT.exports.addAbortSignalNoValidate=function(t,e){if(typeof t!="object"||!("aborted"in t))return e;let r=Bae(e)?()=>{e.destroy(new Dae(void 0,{cause:t.reason}))}:()=>{e[K$e](new Dae(void 0,{cause:t.reason}))};if(t.aborted)r();else{$$=$$||ra().addAbortListener;let n=$$(t,r);F$e(e,n[U$e])}return e}});var $ae=V((l_t,Cae)=>{"use strict";f();var{StringPrototypeSlice:Oae,SymbolIterator:W$e,TypedArrayPrototypeSet:TT,Uint8Array:H$e}=ni(),{Buffer:j$}=pn(),{inspect:V$e}=ra();Cae.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 j$.alloc(0);let r=j$.allocUnsafe(e>>>0),n=this.head,i=0;for(;n;)TT(r,n.data,i),i+=n.data.length,n=n.next;return r}consume(e,r){let n=this.head.data;if(eo.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+=Oae(o,0,e),this.head=n,n.data=Oae(o,e));break}++i}while((n=n.next)!==null);return this.length-=i,r}_getBuffer(e){let r=j$.allocUnsafe(e),n=e,i=this.head,o=0;do{let s=i.data;if(e>s.length)TT(r,s,n-e),e-=s.length;else{e===s.length?(TT(r,s,n-e),++o,i.next?this.head=i.next:this.head=this.tail=null):(TT(r,new H$e(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 V$e(this,{...r,depth:0,customInspect:!1})}}});var t6=V((h_t,qae)=>{"use strict";f();var{MathFloor:G$e,NumberIsInteger:J$e}=ni(),{validateInteger:Z$e}=x1(),{ERR_INVALID_ARG_VALUE:Y$e}=ka().codes,jae=16*1024,Nae=16;function X$e(t,e,r){return t.highWaterMark!=null?t.highWaterMark:e?t[r]:null}function Uae(t){return t?Nae:jae}function Q$e(t,e){Z$e(e,"value",0),t?Nae=e:jae=e}function eje(t,e,r,n){let i=X$e(e,n,r);if(i!=null){if(!J$e(i)||i<0){let o=n?`options.${r}`:"options.highWaterMark";throw new Y$e(o,i)}return G$e(i)}return Uae(t.objectMode)}qae.exports={getHighWaterMark:eje,getDefaultHighWaterMark:Uae,setDefaultHighWaterMark:Q$e}});var N$=V((m_t,zae)=>{"use strict";f();var Lae=js(),{PromisePrototypeThen:tje,SymbolAsyncIterator:Kae,SymbolIterator:Fae}=ni(),{Buffer:rje}=pn(),{ERR_INVALID_ARG_TYPE:nje,ERR_STREAM_NULL_VALUES:ije}=ka().codes;function oje(t,e,r){let n;if(typeof e=="string"||e instanceof rje)return new t({objectMode:!0,...r,read(){this.push(e),this.push(null)}});let i;if(e&&e[Kae])i=!0,n=e[Kae]();else if(e&&e[Fae])i=!1,n=e[Fae]();else throw new nje("iterable",["Iterable"],e);let o=new t({objectMode:!0,highWaterMark:1,...r}),s=!1;o._read=function(){s||(s=!0,d())},o._destroy=function(u,c){tje(a(u),()=>Lae.nextTick(c,u),l=>Lae.nextTick(c,l||u))};async function a(u){let c=u!=null,l=typeof n.throw=="function";if(c&&l){let{value:p,done:m}=await n.throw(u);if(await p,m)return}if(typeof n.return=="function"){let{value:p}=await n.return();await p}}async function d(){for(;;){try{let{value:u,done:c}=i?await n.next():n.next();if(c)o.push(null);else{let l=u&&typeof u.then=="function"?await u:u;if(l===null)throw s=!1,new ije;if(o.push(l))continue;s=!1}}catch(u){o.destroy(u)}break}}return o}zae.exports=oje});var n6=V((g_t,cce)=>{f();var Ku=js(),{ArrayPrototypeIndexOf:sje,NumberIsInteger:aje,NumberIsNaN:cje,NumberParseInt:dje,ObjectDefineProperties:H$,ObjectKeys:uje,ObjectSetPrototypeOf:Vae,Promise:Gae,SafeSet:lje,SymbolAsyncDispose:fje,SymbolAsyncIterator:hje,Symbol:pje}=ni();cce.exports=hr;hr.ReadableState=RT;var{EventEmitter:mje}=Aa(),{Stream:zm,prependListener:yje}=ST(),{Buffer:U$}=pn(),{addAbortSignal:gje}=e6(),Jae=Bh(),Mr=ra().debuglog("stream",t=>{Mr=t}),vje=$ae(),T1=qg(),{getHighWaterMark:bje,getDefaultHighWaterMark:wje}=t6(),{aggregateTwoErrors:Wae,codes:{ERR_INVALID_ARG_TYPE:_je,ERR_METHOD_NOT_IMPLEMENTED:xje,ERR_OUT_OF_RANGE:Eje,ERR_STREAM_PUSH_AFTER_EOF:Sje,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:Aje},AbortError:Tje}=ka(),{validateObject:Pje}=x1(),Lg=pje("kPaused"),{StringDecoder:Zae}=Rw(),Ije=N$();Vae(hr.prototype,zm.prototype);Vae(hr,zm);var q$=()=>{},{errorOrDestroy:S1}=T1,A1=1,kje=2,Yae=4,r6=8,Xae=16,PT=32,IT=64,Qae=128,Rje=256,Dje=512,Bje=1024,z$=2048,W$=4096,Mje=8192,Oje=16384,Cje=32768,ece=65536,$je=1<<17,jje=1<<18;function oo(t){return{enumerable:!1,get(){return(this.state&t)!==0},set(e){e?this.state|=t:this.state&=~t}}}H$(RT.prototype,{objectMode:oo(A1),ended:oo(kje),endEmitted:oo(Yae),reading:oo(r6),constructed:oo(Xae),sync:oo(PT),needReadable:oo(IT),emittedReadable:oo(Qae),readableListening:oo(Rje),resumeScheduled:oo(Dje),errorEmitted:oo(Bje),emitClose:oo(z$),autoDestroy:oo(W$),destroyed:oo(Mje),closed:oo(Oje),closeEmitted:oo(Cje),multiAwaitDrain:oo(ece),readingMore:oo($je),dataEmitted:oo(jje)});function RT(t,e,r){typeof r!="boolean"&&(r=e instanceof Ql()),this.state=z$|W$|Xae|PT,t&&t.objectMode&&(this.state|=A1),r&&t&&t.readableObjectMode&&(this.state|=A1),this.highWaterMark=t?bje(this,t,"readableHighWaterMark",r):wje(!1),this.buffer=new vje,this.length=0,this.pipes=[],this.flowing=null,this[Lg]=null,t&&t.emitClose===!1&&(this.state&=~z$),t&&t.autoDestroy===!1&&(this.state&=~W$),this.errored=null,this.defaultEncoding=t&&t.defaultEncoding||"utf8",this.awaitDrainWriters=null,this.decoder=null,this.encoding=null,t&&t.encoding&&(this.decoder=new Zae(t.encoding),this.encoding=t.encoding)}function hr(t){if(!(this instanceof hr))return new hr(t);let e=this instanceof Ql();this._readableState=new RT(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&&gje(t.signal,this)),zm.call(this,t),T1.construct(this,()=>{this._readableState.needReadable&&kT(this,this._readableState)})}hr.prototype.destroy=T1.destroy;hr.prototype._undestroy=T1.undestroy;hr.prototype._destroy=function(t,e){e(t)};hr.prototype[mje.captureRejectionSymbol]=function(t){this.destroy(t)};hr.prototype[fje]=function(){let t;return this.destroyed||(t=this.readableEnded?null:new Tje,this.destroy(t)),new Gae((e,r)=>Jae(this,n=>n&&n!==t?r(n):e(null)))};hr.prototype.push=function(t,e){return tce(this,t,e,!1)};hr.prototype.unshift=function(t,e){return tce(this,t,e,!0)};function tce(t,e,r,n){Mr("readableAddChunk",e);let i=t._readableState,o;if(i.state&A1||(typeof e=="string"?(r=r||i.defaultEncoding,i.encoding!==r&&(n&&i.encoding?e=U$.from(e,r).toString(i.encoding):(e=U$.from(e,r),r=""))):e instanceof U$?r="":zm._isUint8Array(e)?(e=zm._uint8ArrayToBuffer(e),r=""):e!=null&&(o=new _je("chunk",["string","Buffer","Uint8Array"],e))),o)S1(t,o);else if(e===null)i.state&=~r6,qje(t,i);else if(i.state&A1||e&&e.length>0)if(n)if(i.state&Yae)S1(t,new Aje);else{if(i.destroyed||i.errored)return!1;L$(t,i,e,!0)}else if(i.ended)S1(t,new Sje);else{if(i.destroyed||i.errored)return!1;i.state&=~r6,i.decoder&&!r?(e=i.decoder.write(e),i.objectMode||e.length!==0?L$(t,i,e,!1):kT(t,i)):L$(t,i,e,!1)}else n||(i.state&=~r6,kT(t,i));return!i.ended&&(i.length0?(e.state&ece?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&IT&&DT(t)),kT(t,e)}hr.prototype.isPaused=function(){let t=this._readableState;return t[Lg]===!0||t.flowing===!1};hr.prototype.setEncoding=function(t){let e=new Zae(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 Nje=1073741824;function Uje(t){if(t>Nje)throw new Eje("size","<= 1GiB",t);return t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++,t}function Hae(t,e){return t<=0||e.length===0&&e.ended?0:e.state&A1?1:cje(t)?e.flowing&&e.length?e.buffer.first().length:e.length:t<=e.length?t:e.ended?e.length:0}hr.prototype.read=function(t){Mr("read",t),t===void 0?t=NaN:aje(t)||(t=dje(t,10));let e=this._readableState,r=t;if(t>e.highWaterMark&&(e.highWaterMark=Uje(t)),t!==0&&(e.state&=~Qae),t===0&&e.needReadable&&((e.highWaterMark!==0?e.length>=e.highWaterMark:e.length>0)||e.ended))return Mr("read: emitReadable",e.length,e.ended),e.length===0&&e.ended?K$(this):DT(this),null;if(t=Hae(t,e),t===0&&e.ended)return e.length===0&&K$(this),null;let n=(e.state&IT)!==0;if(Mr("need readable",n),(e.length===0||e.length-t0?i=sce(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&&K$(this)),i!==null&&!e.errorEmitted&&!e.closeEmitted&&(e.dataEmitted=!0,this.emit("data",i)),i};function qje(t,e){if(Mr("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?DT(t):(e.needReadable=!1,e.emittedReadable=!0,rce(t))}}function DT(t){let e=t._readableState;Mr("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(Mr("emitReadable",e.flowing),e.emittedReadable=!0,Ku.nextTick(rce,t))}function rce(t){let e=t._readableState;Mr("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,ice(t)}function kT(t,e){!e.readingMore&&e.constructed&&(e.readingMore=!0,Ku.nextTick(Lje,t,e))}function Lje(t,e){for(;!e.reading&&!e.ended&&(e.length1&&n.pipes.includes(t)&&(Mr("false write response, pause",n.awaitDrainWriters.size),n.awaitDrainWriters.add(t)),r.pause()),d||(d=Kje(r,t),t.on("drain",d))}r.on("data",p);function p(S){Mr("ondata");let P=t.write(S);Mr("dest.write",P),P===!1&&l()}function m(S){if(Mr("onerror",S),x(),t.removeListener("error",m),t.listenerCount("error")===0){let P=t._writableState||t._readableState;P&&!P.errorEmitted?S1(t,S):t.emit("error",S)}}yje(t,"error",m);function g(){t.removeListener("finish",v),x()}t.once("close",g);function v(){Mr("onfinish"),t.removeListener("close",g),x()}t.once("finish",v);function x(){Mr("unpipe"),r.unpipe(t)}return t.emit("pipe",r),t.writableNeedDrain===!0?l():n.flowing||(Mr("pipe resume"),r.resume()),t};function Kje(t,e){return function(){let n=t._readableState;n.awaitDrainWriters===e?(Mr("pipeOnDrain",1),n.awaitDrainWriters=null):n.multiAwaitDrain&&(Mr("pipeOnDrain",n.awaitDrainWriters.size),n.awaitDrainWriters.delete(e)),(!n.awaitDrainWriters||n.awaitDrainWriters.size===0)&&t.listenerCount("data")&&t.resume()}}hr.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;o0,n.flowing!==!1&&this.resume()):t==="readable"&&!n.endEmitted&&!n.readableListening&&(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,Mr("on readable",n.length,n.reading),n.length?DT(this):n.reading||Ku.nextTick(Fje,this)),r};hr.prototype.addListener=hr.prototype.on;hr.prototype.removeListener=function(t,e){let r=zm.prototype.removeListener.call(this,t,e);return t==="readable"&&Ku.nextTick(nce,this),r};hr.prototype.off=hr.prototype.removeListener;hr.prototype.removeAllListeners=function(t){let e=zm.prototype.removeAllListeners.apply(this,arguments);return(t==="readable"||t===void 0)&&Ku.nextTick(nce,this),e};function nce(t){let e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&e[Lg]===!1?e.flowing=!0:t.listenerCount("data")>0?t.resume():e.readableListening||(e.flowing=null)}function Fje(t){Mr("readable nexttick read 0"),t.read(0)}hr.prototype.resume=function(){let t=this._readableState;return t.flowing||(Mr("resume"),t.flowing=!t.readableListening,zje(this,t)),t[Lg]=!1,this};function zje(t,e){e.resumeScheduled||(e.resumeScheduled=!0,Ku.nextTick(Wje,t,e))}function Wje(t,e){Mr("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),ice(t),e.flowing&&!e.reading&&t.read(0)}hr.prototype.pause=function(){return Mr("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(Mr("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState[Lg]=!0,this};function ice(t){let e=t._readableState;for(Mr("flow",e.flowing);e.flowing&&t.read()!==null;);}hr.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=>{S1(this,n)}),t.on("close",()=>{this.destroy()}),t.on("destroy",()=>{this.destroy()}),this._read=()=>{e&&t.resume&&(e=!1,t.resume())};let r=uje(t);for(let n=1;n{i=s?Wae(i,s):null,r(),r=q$});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 Gae(n)}}}catch(s){throw i=Wae(i,s),i}finally{(i||e?.destroyOnReturn!==!1)&&(i===void 0||t._readableState.autoDestroy)?T1.destroyer(t,null):(t.off("readable",n),o())}}H$(hr.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}}});H$(RT.prototype,{pipesCount:{__proto__:null,get(){return this.pipes.length}},paused:{__proto__:null,get(){return this[Lg]!==!1},set(t){this[Lg]=!!t}}});hr._fromList=sce;function sce(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 K$(t){let e=t._readableState;Mr("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,Ku.nextTick(Vje,e,t))}function Vje(t,e){if(Mr("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)Ku.nextTick(Gje,e);else if(t.autoDestroy){let r=e._writableState;(!r||r.autoDestroy&&(r.finished||r.writable===!1))&&e.destroy()}}}function Gje(t){t.writable&&!t.writableEnded&&!t.destroyed&&t.end()}hr.from=function(t,e){return Ije(hr,t,e)};var F$;function ace(){return F$===void 0&&(F$={}),F$}hr.fromWeb=function(t,e){return ace().newStreamReadableFromReadableStream(t,e)};hr.toWeb=function(t,e){return ace().newReadableStreamFromStreamReadable(t,e)};hr.wrap=function(t,e){var r,n;return new hr({objectMode:(r=(n=t.readableObjectMode)!==null&&n!==void 0?n:t.objectMode)!==null&&r!==void 0?r:!0,...e,destroy(i,o){T1.destroyer(t,i),o(i)}}).wrap(t)}});var $T=V((b_t,wce)=>{f();var Kg=js(),{ArrayPrototypeSlice:lce,Error:Jje,FunctionPrototypeSymbolHasInstance:fce,ObjectDefineProperty:hce,ObjectDefineProperties:Zje,ObjectSetPrototypeOf:pce,StringPrototypeToLowerCase:Yje,Symbol:Xje,SymbolHasInstance:Qje}=ni();wce.exports=ii;ii.WritableState=s6;var{EventEmitter:eNe}=Aa(),i6=ST().Stream,{Buffer:BT}=pn(),CT=qg(),{addAbortSignal:tNe}=e6(),{getHighWaterMark:rNe,getDefaultHighWaterMark:nNe}=t6(),{ERR_INVALID_ARG_TYPE:iNe,ERR_METHOD_NOT_IMPLEMENTED:oNe,ERR_MULTIPLE_CALLBACK:mce,ERR_STREAM_CANNOT_PIPE:sNe,ERR_STREAM_DESTROYED:o6,ERR_STREAM_ALREADY_FINISHED:aNe,ERR_STREAM_NULL_VALUES:cNe,ERR_STREAM_WRITE_AFTER_END:dNe,ERR_UNKNOWN_ENCODING:yce}=ka().codes,{errorOrDestroy:P1}=CT;pce(ii.prototype,i6.prototype);pce(ii,i6);function J$(){}var I1=Xje("kOnFinished");function s6(t,e,r){typeof r!="boolean"&&(r=e instanceof Ql()),this.objectMode=!!(t&&t.objectMode),r&&(this.objectMode=this.objectMode||!!(t&&t.writableObjectMode)),this.highWaterMark=t?rNe(this,t,"writableHighWaterMark",r):nNe(!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=lNe.bind(void 0,e),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,OT(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[I1]=[]}function OT(t){t.buffered=[],t.bufferedIndex=0,t.allBuffers=!0,t.allNoop=!0}s6.prototype.getBuffer=function(){return lce(this.buffered,this.bufferedIndex)};hce(s6.prototype,"bufferedRequestCount",{__proto__:null,get(){return this.buffered.length-this.bufferedIndex}});function ii(t){let e=this instanceof Ql();if(!e&&!fce(ii,this))return new ii(t);this._writableState=new s6(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&&tNe(t.signal,this)),i6.call(this,t),CT.construct(this,()=>{let r=this._writableState;r.writing||Y$(this,r),X$(this,r)})}hce(ii,Qje,{__proto__:null,value:function(t){return fce(this,t)?!0:this!==ii?!1:t&&t._writableState instanceof s6}});ii.prototype.pipe=function(){P1(this,new sNe)};function gce(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"&&!BT.isEncoding(r))throw new yce(r);typeof n!="function"&&(n=J$)}if(e===null)throw new cNe;if(!i.objectMode)if(typeof e=="string")i.decodeStrings!==!1&&(e=BT.from(e,r),r="buffer");else if(e instanceof BT)r="buffer";else if(i6._isUint8Array(e))e=i6._uint8ArrayToBuffer(e),r="buffer";else throw new iNe("chunk",["string","Buffer","Uint8Array"],e);let o;return i.ending?o=new dNe:i.destroyed&&(o=new o6("write")),o?(Kg.nextTick(n,o),P1(t,o,!0),o):(i.pendingcb++,uNe(t,i,e,r,n))}ii.prototype.write=function(t,e,r){return gce(this,t,e,r)===!0};ii.prototype.cork=function(){this._writableState.corked++};ii.prototype.uncork=function(){let t=this._writableState;t.corked&&(t.corked--,t.writing||Y$(this,t))};ii.prototype.setDefaultEncoding=function(e){if(typeof e=="string"&&(e=Yje(e)),!BT.isEncoding(e))throw new yce(e);return this._writableState.defaultEncoding=e,this};function uNe(t,e,r,n,i){let o=e.objectMode?1:r.length;e.length+=o;let s=e.lengthr.bufferedIndex&&Y$(t,r),n?r.afterWriteTickInfo!==null&&r.afterWriteTickInfo.cb===i?r.afterWriteTickInfo.count++:(r.afterWriteTickInfo={count:1,cb:i,stream:t,state:r},Kg.nextTick(fNe,r.afterWriteTickInfo)):vce(t,r,1,i))}function fNe({stream:t,state:e,count:r,cb:n}){return e.afterWriteTickInfo=null,vce(t,e,r,n)}function vce(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&&Z$(e),X$(t,e)}function Z$(t){if(t.writing)return;for(let i=t.bufferedIndex;i1&&t._writev){e.pendingcb-=o-1;let a=e.allNoop?J$:u=>{for(let c=s;c256?(r.splice(0,s),e.bufferedIndex=0):e.bufferedIndex=s}e.bufferProcessing=!1}ii.prototype._write=function(t,e,r){if(this._writev)this._writev([{chunk:t,encoding:e}],r);else throw new oNe("_write()")};ii.prototype._writev=null;ii.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=gce(this,t,e);o instanceof Jje&&(i=o)}return n.corked&&(n.corked=1,this.uncork()),i||(!n.errored&&!n.ending?(n.ending=!0,X$(this,n,!0),n.ended=!0):n.finished?i=new aNe("end"):n.destroyed&&(i=new o6("end"))),typeof r=="function"&&(i||n.finished?Kg.nextTick(r,i):n[I1].push(r)),this};function MT(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 hNe(t,e){let r=!1;function n(i){if(r){P1(t,i??mce());return}if(r=!0,e.pendingcb--,i){let o=e[I1].splice(0);for(let s=0;s{MT(i)?G$(n,i):i.pendingcb--},t,e)):MT(e)&&(e.pendingcb++,G$(t,e))))}function G$(t,e){e.pendingcb--,e.finished=!0;let r=e[I1].splice(0);for(let n=0;n{f();var Q$=js(),yNe=pn(),{isReadable:gNe,isWritable:vNe,isIterable:_ce,isNodeStream:bNe,isReadableNodeStream:xce,isWritableNodeStream:Ece,isDuplexNodeStream:wNe,isReadableStream:Sce,isWritableStream:Ace}=Yl(),Tce=Bh(),{AbortError:Bce,codes:{ERR_INVALID_ARG_TYPE:_Ne,ERR_INVALID_RETURN_VALUE:Pce}}=ka(),{destroyer:R1}=qg(),xNe=Ql(),Mce=n6(),ENe=$T(),{createDeferredPromise:Ice}=ra(),kce=N$(),Rce=globalThis.Blob||yNe.Blob,SNe=typeof Rce<"u"?function(e){return e instanceof Rce}:function(e){return!1},ANe=globalThis.AbortController||Dh().AbortController,{FunctionPrototypeCall:Dce}=ni(),Wm=class extends xNe{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)}};Oce.exports=function t(e,r){if(wNe(e))return e;if(xce(e))return k1({readable:e});if(Ece(e))return k1({writable:e});if(bNe(e))return k1({writable:!1,readable:!1});if(Sce(e))return k1({readable:Mce.fromWeb(e)});if(Ace(e))return k1({writable:ENe.fromWeb(e)});if(typeof e=="function"){let{value:i,write:o,final:s,destroy:a}=TNe(e);if(_ce(i))return kce(Wm,i,{objectMode:!0,write:o,final:s,destroy:a});let d=i?.then;if(typeof d=="function"){let u,c=Dce(d,i,l=>{if(l!=null)throw new Pce("nully","body",l)},l=>{R1(u,l)});return u=new Wm({objectMode:!0,readable:!1,write:o,final(l){s(async()=>{try{await c,Q$.nextTick(l,null)}catch(p){Q$.nextTick(l,p)}})},destroy:a})}throw new Pce("Iterable, AsyncIterable or AsyncFunction",r,i)}if(SNe(e))return t(e.arrayBuffer());if(_ce(e))return kce(Wm,e,{objectMode:!0,writable:!1});if(Sce(e?.readable)&&Ace(e?.writable))return Wm.fromWeb(e);if(typeof e?.writable=="object"||typeof e?.readable=="object"){let i=e!=null&&e.readable?xce(e?.readable)?e?.readable:t(e.readable):void 0,o=e!=null&&e.writable?Ece(e?.writable)?e?.writable:t(e.writable):void 0;return k1({readable:i,writable:o})}let n=e?.then;if(typeof n=="function"){let i;return Dce(n,e,o=>{o!=null&&i.push(o),i.push(null)},o=>{R1(i,o)}),i=new Wm({objectMode:!0,writable:!1,read(){}})}throw new _Ne(r,["Blob","ReadableStream","WritableStream","Stream","Iterable","AsyncIterable","Function","{ readable, writable } pair","Promise"],e)};function TNe(t){let{promise:e,resolve:r}=Ice(),n=new ANe,i=n.signal;return{value:t(async function*(){for(;;){let s=e;e=null;let{chunk:a,done:d,cb:u}=await s;if(Q$.nextTick(u),d)return;if(i.aborted)throw new Bce(void 0,{cause:i.reason});({promise:e,resolve:r}=Ice()),yield a}}(),{signal:i}),write(s,a,d){let u=r;r=null,u({chunk:s,done:!1,cb:d})},final(s){let a=r;r=null,a({done:!0,cb:s})},destroy(s,a){n.abort(),a(s)}}}function k1(t){let e=t.readable&&typeof t.readable.read!="function"?Mce.wrap(t.readable):t.readable,r=t.writable,n=!!gNe(e),i=!!vNe(r),o,s,a,d,u;function c(l){let p=d;d=null,p?p(l):l&&u.destroy(l)}return u=new Wm({readableObjectMode:!!(e!=null&&e.readableObjectMode),writableObjectMode:!!(r!=null&&r.writableObjectMode),readable:n,writable:i}),i&&(Tce(r,l=>{i=!1,l&&R1(e,l),c(l)}),u._write=function(l,p,m){r.write(l,p)?m():o=m},u._final=function(l){r.end(),s=l},r.on("drain",function(){if(o){let l=o;o=null,l()}}),r.on("finish",function(){if(s){let l=s;s=null,l()}})),n&&(Tce(e,l=>{n=!1,l&&R1(e,l),c(l)}),e.on("readable",function(){if(a){let l=a;a=null,l()}}),e.on("end",function(){u.push(null)}),u._read=function(){for(;;){let l=e.read();if(l===null){a=u._read;return}if(!u.push(l))return}}),u._destroy=function(l,p){!l&&d!==null&&(l=new Bce),a=null,o=null,s=null,d===null?p(l):(d=p,R1(r,l),R1(e,l))},u}});var Ql=V((E_t,Nce)=>{"use strict";f();var{ObjectDefineProperties:PNe,ObjectGetOwnPropertyDescriptor:Mh,ObjectKeys:INe,ObjectSetPrototypeOf:$ce}=ni();Nce.exports=Fu;var rj=n6(),qd=$T();$ce(Fu.prototype,rj.prototype);$ce(Fu,rj);{let t=INe(qd.prototype);for(let e=0;e{"use strict";f();var{ObjectSetPrototypeOf:Uce,Symbol:kNe}=ni();qce.exports=Oh;var{ERR_METHOD_NOT_IMPLEMENTED:RNe}=ka().codes,ij=Ql(),{getHighWaterMark:DNe}=t6();Uce(Oh.prototype,ij.prototype);Uce(Oh,ij);var a6=kNe("kCallback");function Oh(t){if(!(this instanceof Oh))return new Oh(t);let e=t?DNe(this,t,"readableHighWaterMark",!0):null;e===0&&(t={...t,highWaterMark:null,readableHighWaterMark:e,writableHighWaterMark:t.writableHighWaterMark||0}),ij.call(this,t),this._readableState.sync=!1,this[a6]=null,t&&(typeof t.transform=="function"&&(this._transform=t.transform),typeof t.flush=="function"&&(this._flush=t.flush)),this.on("prefinish",BNe)}function nj(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 BNe(){this._final!==nj&&nj.call(this)}Oh.prototype._final=nj;Oh.prototype._transform=function(t,e,r){throw new RNe("_transform()")};Oh.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{"use strict";f();var{ObjectSetPrototypeOf:Lce}=ni();Kce.exports=D1;var sj=oj();Lce(D1.prototype,sj.prototype);Lce(D1,sj);function D1(t){if(!(this instanceof D1))return new D1(t);sj.call(this,t)}D1.prototype._transform=function(t,e,r){r(null,t)}});var qT=V((k_t,Vce)=>{f();var c6=js(),{ArrayIsArray:MNe,Promise:ONe,SymbolAsyncIterator:CNe,SymbolDispose:$Ne}=ni(),UT=Bh(),{once:jNe}=ra(),NNe=qg(),Fce=Ql(),{aggregateTwoErrors:UNe,codes:{ERR_INVALID_ARG_TYPE:yj,ERR_INVALID_RETURN_VALUE:cj,ERR_MISSING_ARGS:qNe,ERR_STREAM_DESTROYED:LNe,ERR_STREAM_PREMATURE_CLOSE:KNe},AbortError:FNe}=ka(),{validateFunction:zNe,validateAbortSignal:WNe}=x1(),{isIterable:Fg,isReadable:dj,isReadableNodeStream:NT,isNodeStream:zce,isTransformStream:B1,isWebStream:HNe,isReadableStream:uj,isReadableFinished:VNe}=Yl(),GNe=globalThis.AbortController||Dh().AbortController,lj,fj,hj;function Wce(t,e,r){let n=!1;t.on("close",()=>{n=!0});let i=UT(t,{readable:e,writable:r},o=>{n=!o});return{destroy:o=>{n||(n=!0,NNe.destroyer(t,o||new LNe("pipe")))},cleanup:i}}function JNe(t){return zNe(t[t.length-1],"streams[stream.length - 1]"),t.pop()}function pj(t){if(Fg(t))return t;if(NT(t))return ZNe(t);throw new yj("val",["Readable","Iterable","AsyncIterable"],t)}async function*ZNe(t){fj||(fj=n6()),yield*fj.prototype[CNe].call(t)}async function jT(t,e,r,{end:n}){let i,o=null,s=u=>{if(u&&(i=u),o){let c=o;o=null,c()}},a=()=>new ONe((u,c)=>{i?c(i):o=()=>{i?c(i):u()}});e.on("drain",s);let d=UT(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?UNe(i,u):u)}finally{d(),e.off("drain",s)}}async function mj(t,e,r,{end:n}){B1(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 YNe(...t){return Hce(t,jNe(JNe(t)))}function Hce(t,e,r){if(t.length===1&&MNe(t[0])&&(t=t[0]),t.length<2)throw new qNe("streams");let n=new GNe,i=n.signal,o=r?.signal,s=[];WNe(o,"options.signal");function a(){g(new FNe)}hj=hj||ra().addAbortListener;let d;o&&(d=hj(o,a));let u,c,l=[],p=0;function m(A){g(A,--p===0)}function g(A,$){var j;if(A&&(!u||u.code==="ERR_STREAM_PREMATURE_CLOSE")&&(u=A),!(!u&&!$)){for(;l.length;)l.shift()(u);(j=d)===null||j===void 0||j[$Ne](),n.abort(),$&&(u||s.forEach(q=>q()),c6.nextTick(e,u,c))}}let v;for(let A=0;A0,F=j||r?.end!==!1,K=A===t.length-1;if(zce($)){let W=function(L){L&&L.name!=="AbortError"&&L.code!=="ERR_STREAM_PREMATURE_CLOSE"&&m(L)};var P=W;if(F){let{destroy:L,cleanup:I}=Wce($,j,q);l.push(L),dj($)&&K&&s.push(I)}$.on("error",W),dj($)&&K&&s.push(()=>{$.removeListener("error",W)})}if(A===0)if(typeof $=="function"){if(v=$({signal:i}),!Fg(v))throw new cj("Iterable, AsyncIterable or Stream","source",v)}else Fg($)||NT($)||B1($)?v=$:v=Fce.from($);else if(typeof $=="function"){if(B1(v)){var x;v=pj((x=v)===null||x===void 0?void 0:x.readable)}else v=pj(v);if(v=$(v,{signal:i}),j){if(!Fg(v,!0))throw new cj("AsyncIterable",`transform[${A-1}]`,v)}else{var S;lj||(lj=aj());let W=new lj({objectMode:!0}),L=(S=v)===null||S===void 0?void 0:S.then;if(typeof L=="function")p++,L.call(v,B=>{c=B,B!=null&&W.write(B),F&&W.end(),c6.nextTick(m)},B=>{W.destroy(B),c6.nextTick(m,B)});else if(Fg(v,!0))p++,jT(v,W,m,{end:F});else if(uj(v)||B1(v)){let B=v.readable||v;p++,jT(B,W,m,{end:F})}else throw new cj("AsyncIterable or Promise","destination",v);v=W;let{destroy:I,cleanup:T}=Wce(v,!1,!0);l.push(I),K&&s.push(T)}}else if(zce($)){if(NT(v)){p+=2;let W=XNe(v,$,m,{end:F});dj($)&&K&&s.push(W)}else if(B1(v)||uj(v)){let W=v.readable||v;p++,jT(W,$,m,{end:F})}else if(Fg(v))p++,jT(v,$,m,{end:F});else throw new yj("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],v);v=$}else if(HNe($)){if(NT(v))p++,mj(pj(v),$,m,{end:F});else if(uj(v)||Fg(v))p++,mj(v,$,m,{end:F});else if(B1(v))p++,mj(v.readable,$,m,{end:F});else throw new yj("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],v);v=$}else v=Fce.from($)}return(i!=null&&i.aborted||o!=null&&o.aborted)&&c6.nextTick(a),v}function XNe(t,e,r,{end:n}){let i=!1;if(e.on("close",()=>{i||r(new KNe)}),t.pipe(e,{end:!1}),n){let s=function(){i=!0,e.end()};var o=s;VNe(t)?c6.nextTick(s):t.once("end",s)}else r();return UT(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)}),UT(e,{readable:!1,writable:!0},r)}Vce.exports={pipelineImpl:Hce,pipeline:YNe}});var vj=V((D_t,Qce)=>{"use strict";f();var{pipeline:QNe}=qT(),LT=Ql(),{destroyer:eUe}=qg(),{isNodeStream:KT,isReadable:Gce,isWritable:Jce,isWebStream:gj,isTransformStream:zg,isWritableStream:Zce,isReadableStream:Yce}=Yl(),{AbortError:tUe,codes:{ERR_INVALID_ARG_VALUE:Xce,ERR_MISSING_ARGS:rUe}}=ka(),nUe=Bh();Qce.exports=function(...e){if(e.length===0)throw new rUe("streams");if(e.length===1)return LT.from(e[0]);let r=[...e];if(typeof e[0]=="function"&&(e[0]=LT.from(e[0])),typeof e[e.length-1]=="function"){let m=e.length-1;e[m]=LT.from(e[m])}for(let m=0;m0&&!(Jce(e[m])||Zce(e[m])||zg(e[m])))throw new Xce(`streams[${m}]`,r[m],"must be writable")}let n,i,o,s,a;function d(m){let g=s;s=null,g?g(m):m?a.destroy(m):!p&&!l&&a.destroy()}let u=e[0],c=QNe(e,d),l=!!(Jce(u)||Zce(u)||zg(u)),p=!!(Gce(c)||Yce(c)||zg(c));if(a=new LT({writableObjectMode:!!(u!=null&&u.writableObjectMode),readableObjectMode:!!(c!=null&&c.readableObjectMode),writable:l,readable:p}),l){if(KT(u))a._write=function(g,v,x){u.write(g,v)?x():n=x},a._final=function(g){u.end(),i=g},u.on("drain",function(){if(n){let g=n;n=null,g()}});else if(gj(u)){let v=(zg(u)?u.writable:u).getWriter();a._write=async function(x,S,P){try{await v.ready,v.write(x).catch(()=>{}),P()}catch(A){P(A)}},a._final=async function(x){try{await v.ready,v.close().catch(()=>{}),i=x}catch(S){x(S)}}}let m=zg(c)?c.readable:c;nUe(m,()=>{if(i){let g=i;i=null,g()}})}if(p){if(KT(c))c.on("readable",function(){if(o){let m=o;o=null,m()}}),c.on("end",function(){a.push(null)}),a._read=function(){for(;;){let m=c.read();if(m===null){o=a._read;return}if(!a.push(m))return}};else if(gj(c)){let g=(zg(c)?c.readable:c).getReader();a._read=async function(){for(;;)try{let{value:v,done:x}=await g.read();if(!a.push(v))return;if(x){a.push(null);return}}catch{return}}}}return a._destroy=function(m,g){!m&&s!==null&&(m=new tUe),o=null,n=null,i=null,s===null?g(m):(s=g,KT(c)&&eUe(c,m))},a}});var dde=V((M_t,_j)=>{"use strict";f();var iUe=globalThis.AbortController||Dh().AbortController,{codes:{ERR_INVALID_ARG_VALUE:oUe,ERR_INVALID_ARG_TYPE:d6,ERR_MISSING_ARGS:sUe,ERR_OUT_OF_RANGE:aUe},AbortError:ef}=ka(),{validateAbortSignal:Wg,validateInteger:ede,validateObject:Hg}=x1(),cUe=ni().Symbol("kWeak"),dUe=ni().Symbol("kResistStopPropagation"),{finished:uUe}=Bh(),lUe=vj(),{addAbortSignalNoValidate:fUe}=e6(),{isWritable:hUe,isNodeStream:pUe}=Yl(),{deprecate:mUe}=ra(),{ArrayPrototypePush:yUe,Boolean:gUe,MathFloor:tde,Number:vUe,NumberIsNaN:bUe,Promise:rde,PromiseReject:nde,PromiseResolve:wUe,PromisePrototypeThen:ide,Symbol:sde}=ni(),FT=sde("kEmpty"),ode=sde("kEof");function _Ue(t,e){if(e!=null&&Hg(e,"options"),e?.signal!=null&&Wg(e.signal,"options.signal"),pUe(t)&&!hUe(t))throw new oUe("stream",t,"must be writable");let r=lUe(this,t);return e!=null&&e.signal&&fUe(e.signal,r),r}function zT(t,e){if(typeof t!="function")throw new d6("fn",["Function","AsyncFunction"],t);e!=null&&Hg(e,"options"),e?.signal!=null&&Wg(e.signal,"options.signal");let r=1;e?.concurrency!=null&&(r=tde(e.concurrency));let n=r-1;return e?.highWaterMark!=null&&(n=tde(e.highWaterMark)),ede(r,"options.concurrency",1),ede(n,"options.highWaterMark",0),n+=r,(async function*(){let o=ra().AbortSignalAny([e?.signal].filter(gUe)),s=this,a=[],d={signal:o},u,c,l=!1,p=0;function m(){l=!0,g()}function g(){p-=1,v()}function v(){c&&!l&&p=n||p>=r)&&await new rde(P=>{c=P})}a.push(ode)}catch(S){let P=nde(S);ide(P,g,m),a.push(P)}finally{l=!0,u&&(u(),u=null)}}x();try{for(;;){for(;a.length>0;){let S=await a[0];if(S===ode)return;if(o.aborted)throw new ef;S!==FT&&(yield S),a.shift(),v()}await new rde(S=>{u=S})}}finally{l=!0,c&&(c(),c=null)}}).call(this)}function xUe(t=void 0){return t!=null&&Hg(t,"options"),t?.signal!=null&&Wg(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 ef({cause:t.signal.reason});yield[r++,i]}}).call(this)}async function ade(t,e=void 0){for await(let r of wj.call(this,t,e))return!0;return!1}async function EUe(t,e=void 0){if(typeof t!="function")throw new d6("fn",["Function","AsyncFunction"],t);return!await ade.call(this,async(...r)=>!await t(...r),e)}async function SUe(t,e){for await(let r of wj.call(this,t,e))return r}async function AUe(t,e){if(typeof t!="function")throw new d6("fn",["Function","AsyncFunction"],t);async function r(n,i){return await t(n,i),FT}for await(let n of zT.call(this,r,e));}function wj(t,e){if(typeof t!="function")throw new d6("fn",["Function","AsyncFunction"],t);async function r(n,i){return await t(n,i)?n:FT}return zT.call(this,r,e)}var bj=class extends sUe{constructor(){super("reduce"),this.message="Reduce of an empty stream requires an initial value"}};async function TUe(t,e,r){var n;if(typeof t!="function")throw new d6("reducer",["Function","AsyncFunction"],t);r!=null&&Hg(r,"options"),r?.signal!=null&&Wg(r.signal,"options.signal");let i=arguments.length>1;if(r!=null&&(n=r.signal)!==null&&n!==void 0&&n.aborted){let u=new ef(void 0,{cause:r.signal.reason});throw this.once("error",()=>{}),await uUe(this.destroy(u)),u}let o=new iUe,s=o.signal;if(r!=null&&r.signal){let u={once:!0,[cUe]:this,[dUe]:!0};r.signal.addEventListener("abort",()=>o.abort(),u)}let a=!1;try{for await(let u of this){var d;if(a=!0,r!=null&&(d=r.signal)!==null&&d!==void 0&&d.aborted)throw new ef;i?e=await t(e,u,{signal:s}):(e=u,i=!0)}if(!a&&!i)throw new bj}finally{o.abort()}return e}async function PUe(t){t!=null&&Hg(t,"options"),t?.signal!=null&&Wg(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 ef(void 0,{cause:t.signal.reason});yUe(e,n)}return e}function IUe(t,e){let r=zT.call(this,t,e);return(async function*(){for await(let i of r)yield*i}).call(this)}function cde(t){if(t=vUe(t),bUe(t))return 0;if(t<0)throw new aUe("number",">= 0",t);return t}function kUe(t,e=void 0){return e!=null&&Hg(e,"options"),e?.signal!=null&&Wg(e.signal,"options.signal"),t=cde(t),(async function*(){var n;if(e!=null&&(n=e.signal)!==null&&n!==void 0&&n.aborted)throw new ef;for await(let o of this){var i;if(e!=null&&(i=e.signal)!==null&&i!==void 0&&i.aborted)throw new ef;t--<=0&&(yield o)}}).call(this)}function RUe(t,e=void 0){return e!=null&&Hg(e,"options"),e?.signal!=null&&Wg(e.signal,"options.signal"),t=cde(t),(async function*(){var n;if(e!=null&&(n=e.signal)!==null&&n!==void 0&&n.aborted)throw new ef;for await(let o of this){var i;if(e!=null&&(i=e.signal)!==null&&i!==void 0&&i.aborted)throw new ef;if(t-- >0&&(yield o),t<=0)return}}).call(this)}_j.exports.streamReturningOperators={asIndexedPairs:mUe(xUe,"readable.asIndexedPairs will be removed in a future version."),drop:kUe,filter:wj,flatMap:IUe,map:zT,take:RUe,compose:_Ue};_j.exports.promiseReturningOperators={every:EUe,forEach:AUe,reduce:TUe,toArray:PUe,some:ade,find:SUe}});var xj=V((C_t,ude)=>{"use strict";f();var{ArrayPrototypePop:DUe,Promise:BUe}=ni(),{isIterable:MUe,isNodeStream:OUe,isWebStream:CUe}=Yl(),{pipelineImpl:$Ue}=qT(),{finished:jUe}=Bh();Ej();function NUe(...t){return new BUe((e,r)=>{let n,i,o=t[t.length-1];if(o&&typeof o=="object"&&!OUe(o)&&!MUe(o)&&!CUe(o)){let s=DUe(t);n=s.signal,i=s.end}$Ue(t,(s,a)=>{s?r(s):e(a)},{signal:n,end:i})})}ude.exports={finished:jUe,pipeline:NUe}});var Ej=V((j_t,bde)=>{f();var{Buffer:UUe}=pn(),{ObjectDefineProperty:Ch,ObjectKeys:hde,ReflectApply:pde}=ni(),{promisify:{custom:mde}}=ra(),{streamReturningOperators:lde,promiseReturningOperators:fde}=dde(),{codes:{ERR_ILLEGAL_CONSTRUCTOR:yde}}=ka(),qUe=vj(),{setDefaultHighWaterMark:LUe,getDefaultHighWaterMark:KUe}=t6(),{pipeline:gde}=qT(),{destroyer:FUe}=qg(),vde=Bh(),Sj=xj(),u6=Yl(),Kn=bde.exports=ST().Stream;Kn.isDestroyed=u6.isDestroyed;Kn.isDisturbed=u6.isDisturbed;Kn.isErrored=u6.isErrored;Kn.isReadable=u6.isReadable;Kn.isWritable=u6.isWritable;Kn.Readable=n6();for(let t of hde(lde)){let r=function(...n){if(new.target)throw yde();return Kn.Readable.from(pde(e,this,n))};Aj=r;let e=lde[t];Ch(r,"name",{__proto__:null,value:e.name}),Ch(r,"length",{__proto__:null,value:e.length}),Ch(Kn.Readable.prototype,t,{__proto__:null,value:r,enumerable:!1,configurable:!0,writable:!0})}var Aj;for(let t of hde(fde)){let r=function(...i){if(new.target)throw yde();return pde(e,this,i)};Aj=r;let e=fde[t];Ch(r,"name",{__proto__:null,value:e.name}),Ch(r,"length",{__proto__:null,value:e.length}),Ch(Kn.Readable.prototype,t,{__proto__:null,value:r,enumerable:!1,configurable:!0,writable:!0})}var Aj;Kn.Writable=$T();Kn.Duplex=Ql();Kn.Transform=oj();Kn.PassThrough=aj();Kn.pipeline=gde;var{addAbortSignal:zUe}=e6();Kn.addAbortSignal=zUe;Kn.finished=vde;Kn.destroy=FUe;Kn.compose=qUe;Kn.setDefaultHighWaterMark=LUe;Kn.getDefaultHighWaterMark=KUe;Ch(Kn,"promises",{__proto__:null,configurable:!0,enumerable:!0,get(){return Sj}});Ch(gde,mde,{__proto__:null,enumerable:!0,get(){return Sj.pipeline}});Ch(vde,mde,{__proto__:null,enumerable:!0,get(){return Sj.finished}});Kn.Stream=Kn;Kn._isUint8Array=function(e){return e instanceof Uint8Array};Kn._uint8ArrayToBuffer=function(e){return UUe.from(e.buffer,e.byteOffset,e.byteLength)}});var M1=V((U_t,ki)=>{"use strict";f();var so=Ej(),WUe=xj(),HUe=so.Readable.destroy;ki.exports=so.Readable;ki.exports._uint8ArrayToBuffer=so._uint8ArrayToBuffer;ki.exports._isUint8Array=so._isUint8Array;ki.exports.isDisturbed=so.isDisturbed;ki.exports.isErrored=so.isErrored;ki.exports.isReadable=so.isReadable;ki.exports.Readable=so.Readable;ki.exports.Writable=so.Writable;ki.exports.Duplex=so.Duplex;ki.exports.Transform=so.Transform;ki.exports.PassThrough=so.PassThrough;ki.exports.addAbortSignal=so.addAbortSignal;ki.exports.finished=so.finished;ki.exports.destroy=so.destroy;ki.exports.destroy=HUe;ki.exports.pipeline=so.pipeline;ki.exports.compose=so.compose;Object.defineProperty(so,"promises",{configurable:!0,enumerable:!0,get(){return WUe}});ki.exports.Stream=so.Stream;ki.exports.default=ki.exports});var Pde=V((Cj,$j)=>{f();(function(t,e){typeof Cj=="object"&&typeof $j<"u"?$j.exports=e():typeof define=="function"&&define.amd?define(e):(t=t||self,t.JSBI=e())})(Cj,function(){"use strict";var t=Math.imul,e=Math.clz32;function r(K){"@babel/helpers - typeof";return r=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(W){return typeof W}:function(W){return W&&typeof Symbol=="function"&&W.constructor===Symbol&&W!==Symbol.prototype?"symbol":typeof W},r(K)}function n(K,W){if(!(K instanceof W))throw new TypeError("Cannot call a class as a function")}function i(K,W){for(var L,I=0;I"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function c(){return c=u()?Reflect.construct:function(K,W,L){var I=[null];I.push.apply(I,W);var T=Function.bind.apply(K,I),B=new T;return L&&d(B,L.prototype),B},c.apply(null,arguments)}function l(K){return Function.toString.call(K).indexOf("[native code]")!==-1}function p(K){var W=typeof Map=="function"?new Map:void 0;return p=function(L){function I(){return c(L,arguments,a(this).constructor)}if(L===null||!l(L))return L;if(typeof L!="function")throw new TypeError("Super expression must either be null or a function");if(typeof W<"u"){if(W.has(L))return W.get(L);W.set(L,I)}return I.prototype=Object.create(L.prototype,{constructor:{value:I,enumerable:!1,writable:!0,configurable:!0}}),d(I,L)},p(K)}function m(K){if(K===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return K}function g(K,W){if(W&&(typeof W=="object"||typeof W=="function"))return W;if(W!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return m(K)}function v(K){var W=u();return function(){var L,I=a(K);if(W){var T=a(this).constructor;L=Reflect.construct(I,arguments,T)}else L=I.apply(this,arguments);return g(this,L)}}function x(K,W){return S(K)||P(K,W)||A(K,W)||j()}function S(K){if(Array.isArray(K))return K}function P(K,W){var L=K==null?null:typeof Symbol<"u"&&K[Symbol.iterator]||K["@@iterator"];if(L!=null){var I,T,B=[],h=!0,y=!1;try{for(L=L.call(K);!(h=(I=L.next()).done)&&(B.push(I.value),!(W&&B.length===W));h=!0);}catch(w){y=!0,T=w}finally{try{h||L.return==null||L.return()}finally{if(y)throw T}}return B}}function A(K,W){if(K){if(typeof K=="string")return $(K,W);var L=Object.prototype.toString.call(K).slice(8,-1);return L==="Object"&&K.constructor&&(L=K.constructor.name),L==="Map"||L==="Set"?Array.from(K):L==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(L)?$(K,W):void 0}}function $(K,W){(W==null||W>K.length)&&(W=K.length);for(var L=0,I=Array(W);L=K.length?{done:!0}:{done:!1,value:K[I++]}},e:function(w){throw w},f:T}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var B,h=!0,y=!1;return{s:function(){L=L.call(K)},n:function(){var w=L.next();return h=w.done,w},e:function(w){y=!0,B=w},f:function(){try{h||L.return==null||L.return()}finally{if(y)throw B}}}}var F=function(K){var W=Math.abs,L=Math.max,I=Math.floor;function T(h,y){var w;if(n(this,T),w=B.call(this,h),w.sign=y,Object.setPrototypeOf(m(w),T.prototype),h>T.__kMaxLength)throw new RangeError("Maximum BigInt size exceeded");return w}s(T,K);var B=v(T);return o(T,[{key:"toDebugString",value:function(){var h,y=["BigInt["],w=q(this);try{for(w.s();!(h=w.n()).done;){var E=h.value;y.push((E&&(E>>>0).toString(16))+", ")}}catch(_){w.e(_)}finally{w.f()}return y.push("]"),y.join("")}},{key:"toString",value:function(){var h=0h||36this.length&&(w=this.length);for(var E=32767&h,_=h>>>15,b=0,C=y,N=0;N>>15,Z=T.__imul(U,E),J=T.__imul(U,_),H=T.__imul(G,E),X=T.__imul(G,_),te=C+Z+b;b=te>>>30,te&=1073741823,te+=((32767&J)<<15)+((32767&H)<<15),b+=te>>>30,C=X+(J>>>15)+(H>>>15),this.__setDigit(N,1073741823&te)}if(b!==0||C!==0)throw new Error("implementation bug")}},{key:"__inplaceAdd",value:function(h,y,w){for(var E,_=0,b=0;b>>15,this.__setHalfDigit(y+b,32767&E);return _}},{key:"__inplaceSub",value:function(h,y,w){var E=0;if(1&y){y>>=1;for(var _=this.__digit(y),b=32767&_,C=0;C>>1;C++){var N=h.__digit(C),M=(_>>>15)-(32767&N)-E;E=1&M>>>15,this.__setDigit(y+C,(32767&M)<<15|32767&b),_=this.__digit(y+C+1),b=(32767&_)-(N>>>15)-E,E=1&b>>>15}var U=h.__digit(C),G=(_>>>15)-(32767&U)-E;if(E=1&G>>>15,this.__setDigit(y+C,(32767&G)<<15|32767&b),y+C+1>=this.length)throw new RangeError("out of bounds");!(1&w)&&(_=this.__digit(y+C+1),b=(32767&_)-(U>>>15)-E,E=1&b>>>15,this.__setDigit(y+h.length,1073709056&_|32767&b))}else{y>>=1;for(var Z=0;Z>>15;var te=(J>>>15)-(H>>>15)-E;E=1&te>>>15,this.__setDigit(y+Z,(32767&te)<<15|32767&X)}var ne=this.__digit(y+Z),Q=h.__digit(Z),re=(32767&ne)-(32767&Q)-E;E=1&re>>>15;var ce=0;!(1&w)&&(ce=(ne>>>15)-(Q>>>15)-E,E=1&ce>>>15),this.__setDigit(y+Z,(32767&ce)<<15|32767&re)}return E}},{key:"__inplaceRightShift",value:function(h){if(h!==0){for(var y,w=this.__digit(0)>>>h,E=this.length-1,_=0;_>>h;this.__setDigit(E,w)}}},{key:"__digit",value:function(h){return this[h]}},{key:"__unsignedDigit",value:function(h){return this[h]>>>0}},{key:"__setDigit",value:function(h,y){this[h]=0|y}},{key:"__setDigitGrow",value:function(h,y){this[h]=0|y}},{key:"__halfDigitLength",value:function(){var h=this.length;return 32767>=this.__unsignedDigit(h-1)?2*h-1:2*h}},{key:"__halfDigit",value:function(h){return 32767&this[h>>>1]>>>15*(1&h)}},{key:"__setHalfDigit",value:function(h,y){var w=h>>>1,E=this.__digit(w),_=1&h?32767&E|y<<15:1073709056&E|32767&y;this.__setDigit(w,_)}}],[{key:"BigInt",value:function(h){var y=Number.isFinite;if(typeof h=="number"){if(h===0)return T.__zero();if(T.__isOneDigitInt(h))return 0>h?T.__oneDigit(-h,!0):T.__oneDigit(h,!1);if(!y(h)||I(h)!==h)throw new RangeError("The number "+h+" cannot be converted to BigInt because it is not an integer");return T.__fromDouble(h)}if(typeof h=="string"){var w=T.__fromString(h);if(w===null)throw new SyntaxError("Cannot convert "+h+" to a BigInt");return w}if(typeof h=="boolean")return h===!0?T.__oneDigit(1,!1):T.__zero();if(r(h)==="object"){if(h.constructor===T)return h;var E=T.__toPrimitive(h);return T.BigInt(E)}throw new TypeError("Cannot convert "+h+" to a BigInt")}},{key:"toNumber",value:function(h){var y=h.length;if(y===0)return 0;if(y===1){var w=h.__unsignedDigit(0);return h.sign?-w:w}var E=h.__digit(y-1),_=T.__clz30(E),b=30*y-_;if(1024>>=12;var Z=U-12,J=12<=U?0:N<<20+U,H=20+U;for(0>>30-Z,J=N<>>30-H,H-=30;var X=T.__decideRounding(h,H,M,N);if((X===1||X===0&&(1&J)==1)&&(J=J+1>>>0,J===0&&(G++,G>>>20!=0&&(G=0,C++,1023=T.__kMaxLengthBits)throw new RangeError("BigInt too big");if(h.length===1&&h.__digit(0)===2){var E=1+(0|w/30),_=h.sign&&(1&w)!=0,b=new T(E,_);b.__initializeDigits();var C=1<>=1;w!==0;w>>=1)M=T.multiply(M,M),1&w&&(N===null?N=M:N=T.multiply(N,M));return N}},{key:"multiply",value:function(h,y){if(h.length===0)return h;if(y.length===0)return y;var w=h.length+y.length;30<=h.__clzmsd()+y.__clzmsd()&&w--;var E=new T(w,h.sign!==y.sign);E.__initializeDigits();for(var _=0;_T.__absoluteCompare(h,y))return T.__zero();var w,E=h.sign!==y.sign,_=y.__unsignedDigit(0);if(y.length===1&&32767>=_){if(_===1)return E===h.sign?h:T.unaryMinus(h);w=T.__absoluteDivSmall(h,_,null)}else w=T.__absoluteDivLarge(h,y,!0,!1);return w.sign=E,w.__trim()}},{key:"remainder",value:function(y,w){if(w.length===0)throw new RangeError("Division by zero");if(0>T.__absoluteCompare(y,w))return y;var E=w.__unsignedDigit(0);if(w.length===1&&32767>=E){if(E===1)return T.__zero();var _=T.__absoluteModSmall(y,E);return _===0?T.__zero():T.__oneDigit(_,y.sign)}var b=T.__absoluteDivLarge(y,w,!1,!0);return b.sign=y.sign,b.__trim()}},{key:"add",value:function(h,y){var w=h.sign;return w===y.sign?T.__absoluteAdd(h,y,w):0<=T.__absoluteCompare(h,y)?T.__absoluteSub(h,y,w):T.__absoluteSub(y,h,!w)}},{key:"subtract",value:function(h,y){var w=h.sign;return w===y.sign?0<=T.__absoluteCompare(h,y)?T.__absoluteSub(h,y,w):T.__absoluteSub(y,h,!w):T.__absoluteAdd(h,y,w)}},{key:"leftShift",value:function(h,y){return y.length===0||h.length===0?h:y.sign?T.__rightShiftByAbsolute(h,y):T.__leftShiftByAbsolute(h,y)}},{key:"signedRightShift",value:function(h,y){return y.length===0||h.length===0?h:y.sign?T.__leftShiftByAbsolute(h,y):T.__rightShiftByAbsolute(h,y)}},{key:"unsignedRightShift",value:function(){throw new TypeError("BigInts have no unsigned right shift; use >> instead")}},{key:"lessThan",value:function(h,y){return 0>T.__compareToBigInt(h,y)}},{key:"lessThanOrEqual",value:function(h,y){return 0>=T.__compareToBigInt(h,y)}},{key:"greaterThan",value:function(h,y){return 0h)throw new RangeError("Invalid value: not (convertible to) a safe integer");if(h===0)return T.__zero();if(h>=T.__kMaxLengthBits)return y;var w=0|(h+29)/30;if(y.lengthh)throw new RangeError("Invalid value: not (convertible to) a safe integer");if(h===0)return T.__zero();if(y.sign){if(h>T.__kMaxLengthBits)throw new RangeError("BigInt too big");return T.__truncateAndSubFromPowerOfTwo(h,y,!1)}if(h>=T.__kMaxLengthBits)return y;var w=0|(h+29)/30;if(y.length>>E))return y}return T.__truncateToNBits(h,y)}},{key:"ADD",value:function(h,y){if(h=T.__toPrimitive(h),y=T.__toPrimitive(y),typeof h=="string")return typeof y!="string"&&(y=y.toString()),h+y;if(typeof y=="string")return h.toString()+y;if(h=T.__toNumeric(h),y=T.__toNumeric(y),T.__isBigInt(h)&&T.__isBigInt(y))return T.add(h,y);if(typeof h=="number"&&typeof y=="number")return h+y;throw new TypeError("Cannot mix BigInt and other types, use explicit conversions")}},{key:"LT",value:function(h,y){return T.__compare(h,y,0)}},{key:"LE",value:function(h,y){return T.__compare(h,y,1)}},{key:"GT",value:function(h,y){return T.__compare(h,y,2)}},{key:"GE",value:function(h,y){return T.__compare(h,y,3)}},{key:"EQ",value:function(h,y){for(;;){if(T.__isBigInt(h))return T.__isBigInt(y)?T.equal(h,y):T.EQ(y,h);if(typeof h=="number"){if(T.__isBigInt(y))return T.__equalToNumber(y,h);if(r(y)!=="object")return h==y;y=T.__toPrimitive(y)}else if(typeof h=="string"){if(T.__isBigInt(y))return h=T.__fromString(h),h!==null&&T.equal(h,y);if(r(y)!=="object")return h==y;y=T.__toPrimitive(y)}else if(typeof h=="boolean"){if(T.__isBigInt(y))return T.__equalToNumber(y,+h);if(r(y)!=="object")return h==y;y=T.__toPrimitive(y)}else if(r(h)==="symbol"){if(T.__isBigInt(y))return!1;if(r(y)!=="object")return h==y;y=T.__toPrimitive(y)}else if(r(h)==="object"){if(r(y)==="object"&&y.constructor!==T)return h==y;h=T.__toPrimitive(h)}else return h==y}}},{key:"NE",value:function(h,y){return!T.EQ(h,y)}},{key:"DataViewGetBigInt64",value:function(h,y){var w=2>>30),U.__setDigit(2,N>>>28),U.__trim()}},{key:"DataViewSetBigInt64",value:function(h,y,w){var E=3>>2,2y)_=-y-1;else{if(w===0)return-1;w--,E=h.__digit(w),_=29}var b=1<<_;if(!(E&b))return-1;if(b-=1,(E&b)!=0)return 1;for(;0>>20,E=w-1023,_=(0|E/30)+1,b=new T(_,0>h),C=1048575&T.__kBitConversionInts[1]|1048576,N=T.__kBitConversionInts[0],M=20,U=E%30,G=0;if(U>>Z,C=C<<32-Z|N>>>Z,N<<=32-Z}else if(U===M)G=32,y=C,C=N,N=0;else{var J=U-M;G=32-J,y=C<>>32-J,C=N<>>2,C=C<<30|N>>>2,N<<=30):y=0,b.__setDigit(H,y);return b.__trim()}},{key:"__isWhitespace",value:function(h){return 13>=h&&9<=h||(159>=h?h==32:131071>=h?h==160||h==5760:196607>=h?(h&=131071,10>=h||h==40||h==41||h==47||h==95||h==4096):h==65279)}},{key:"__fromString",value:function(h){var y=11073741824/N)return null;var U=N*C+M>>>T.__kBitsPerCharTableShift,G=new T(0|(U+29)/30,!1),Z=10>y?y:10,J=10>>0>>0>>T.__kBitsPerCharTableShift)/30;G.__inplaceMultiplyAdd(he,ie,Re)}while(!ce)}else{N>>=T.__kBitsPerCharTableShift;var H=[],X=[],te=!1;do{for(var ne,Q=0,re=0;;){if(ne=void 0,b-48>>>0>>0>>M-b)}if(_!==0){if(E>=h.length)throw new Error("implementation bug");h.__setDigit(E++,_)}for(;E>>1)+(85&E),E=(51&E>>>2)+(51&E),E=(15&E>>>4)+(15&E);var _=E,b=y-1,C=h.__digit(w-1),N=T.__clz30(C),M=0|(30*w-N+_-1)/_;if(h.sign&&M++,268435456>>ne,J=30-ne;J>=_;)U[G--]=T.__kConversionChars[Z&b],Z>>>=_,J-=_}var Q=(Z|C<>>_-J;Z!==0;)U[G--]=T.__kConversionChars[Z&b],Z>>>=_;if(h.sign&&(U[G--]="-"),G!==-1)throw new Error("implementation bug");return U.join("")}},{key:"__toStringGeneric",value:function(h,y,w){var E=h.length;if(E===0)return"";if(E===1){var _=h.__unsignedDigit(0).toString(y);return w===!1&&h.sign&&(_="-"+_),_}var b=30*E-T.__clz30(h.__digit(E-1)),C=T.__kMaxBitsPerChar[y],N=C-1,M=b*T.__kBitsPerCharTableMultiplier;M+=N-1,M=0|M/N;var U,G,Z=M+1>>1,J=T.exponentiate(T.__oneDigit(y,!1),T.__oneDigit(Z,!1)),H=J.__unsignedDigit(0);if(J.length===1&&32767>=H){U=new T(h.length,!1),U.__initializeDigits();for(var X,te=0,ne=2*h.length-1;0<=ne;ne--)X=te<<15|h.__halfDigit(ne),U.__setHalfDigit(ne,0|X/H),te=0|X%H;G=te.toString(y)}else{var Q=T.__absoluteDivLarge(h,J,!0,!0);U=Q.quotient;var re=Q.remainder.__trim();G=T.__toStringGeneric(re,y,!0)}U.__trim();for(var ce=T.__toStringGeneric(U,y,!0);G.lengthE?T.__absoluteLess(w):0}},{key:"__compareToNumber",value:function(h,y){if(T.__isOneDigitInt(y)){var w=h.sign,E=0>y;if(w!==E)return T.__unequalSign(w);if(h.length===0){if(E)throw new Error("implementation bug");return y===0?0:-1}if(1_?T.__absoluteGreater(w):b<_?T.__absoluteLess(w):0}return T.__compareToDouble(h,y)}},{key:"__compareToDouble",value:function(h,y){if(y!==y)return y;if(y===1/0)return-1;if(y===-1/0)return 1;var w=h.sign;if(w!==0>y)return T.__unequalSign(w);if(y===0)throw new Error("implementation bug: should be handled elsewhere");if(h.length===0)return-1;T.__kBitConversionDouble[0]=y;var E=2047&T.__kBitConversionInts[1]>>>20;if(E==2047)throw new Error("implementation bug: handled elsewhere");var _=E-1023;if(0>_)return T.__absoluteGreater(w);var b=h.length,C=h.__digit(b-1),N=T.__clz30(C),M=30*b-N,U=_+1;if(MU)return T.__absoluteGreater(w);var G=1048576|1048575&T.__kBitConversionInts[1],Z=T.__kBitConversionInts[0],J=20,H=29-N;if(H!==(0|(M-1)%30))throw new Error("implementation bug");var X,te=0;if(H>>ne,G=G<<32-ne|Z>>>ne,Z<<=32-ne}else if(H===J)te=32,X=G,G=Z,Z=0;else{var Q=H-J;te=32-Q,X=G<>>32-Q,G=Z<>>=0,X>>>=0,C>X)return T.__absoluteGreater(w);if(C>>2,G=G<<30|Z>>>2,Z<<=30):X=0;var ce=h.__unsignedDigit(re);if(ce>X)return T.__absoluteGreater(w);if(cey&&h.__unsignedDigit(0)===W(y):T.__compareToDouble(h,y)===0}},{key:"__comparisonResultToBool",value:function(h,y){return y===0?0>h:y===1?0>=h:y===2?0y;case 3:return h>=y}if(T.__isBigInt(h)&&typeof y=="string")return y=T.__fromString(y),y!==null&&T.__comparisonResultToBool(T.__compareToBigInt(h,y),w);if(typeof h=="string"&&T.__isBigInt(y))return h=T.__fromString(h),h!==null&&T.__comparisonResultToBool(T.__compareToBigInt(h,y),w);if(h=T.__toNumeric(h),y=T.__toNumeric(y),T.__isBigInt(h)){if(T.__isBigInt(y))return T.__comparisonResultToBool(T.__compareToBigInt(h,y),w);if(typeof y!="number")throw new Error("implementation bug");return T.__comparisonResultToBool(T.__compareToNumber(h,y),w)}if(typeof h!="number")throw new Error("implementation bug");if(T.__isBigInt(y))return T.__comparisonResultToBool(T.__compareToNumber(y,h),2^w);if(typeof y!="number")throw new Error("implementation bug");return w===0?hy:w===3?h>=y:void 0}},{key:"__absoluteAdd",value:function(h,y,w){if(h.length>>30,b.__setDigit(N,1073741823&_);for(;N>>30,b.__setDigit(N,1073741823&M)}return N>>30,_.__setDigit(C,1073741823&E);for(;C>>30,_.__setDigit(C,1073741823&N)}return _.__trim()}},{key:"__absoluteAddOne",value:function(h,y){var w=2>>30,w.__setDigit(C,1073741823&_);return b!==0&&w.__setDigitGrow(E,1),w}},{key:"__absoluteSubOne",value:function(h,y){var w=h.length;y=y||w;for(var E,_=new T(y,!1),b=1,C=0;C>>30,_.__setDigit(C,1073741823&E);if(b!==0)throw new Error("implementation bug");for(var N=w;NE?0:h.__unsignedDigit(E)>y.__unsignedDigit(E)?1:-1}},{key:"__multiplyAccumulate",value:function(h,y,w,E){if(y!==0){for(var _=32767&y,b=y>>>15,C=0,N=0,M=0;M>>15,H=T.__imul(Z,_),X=T.__imul(Z,b),te=T.__imul(J,_),ne=T.__imul(J,b);U+=N+H+C,C=U>>>30,U&=1073741823,U+=((32767&X)<<15)+((32767&te)<<15),C+=U>>>30,N=ne+(X>>>15)+(te>>>15),w.__setDigit(E,1073741823&U)}for(;C!==0||N!==0;E++){var Q=w.__digit(E);Q+=C+N,N=0,C=Q>>>30,w.__setDigit(E,1073741823&Q)}}}},{key:"__internalMultiplyAdd",value:function(h,y,w,E,_){for(var b=w,C=0,N=0;N>>15,y),Z=U+((32767&G)<<15)+C+b;b=Z>>>30,C=G>>>15,_.__setDigit(N,1073741823&Z)}if(_.length>E)for(_.__setDigit(E++,b+C);E<_.length;)_.__setDigit(E++,0);else if(b+C!==0)throw new Error("implementation bug")}},{key:"__absoluteDivSmall",value:function(h,y){var w=2>>0,C=0|b/y;E=0|b%y,b=(E<<15|h.__halfDigit(_-1))>>>0;var N=0|b/y;E=0|b%y,w.__setDigit(_>>>1,C<<15|N)}return w}},{key:"__absoluteModSmall",value:function(h,y){for(var w,E=0,_=2*h.length-1;0<=_;_--)w=(E<<15|h.__halfDigit(_))>>>0,E=0|w%y;return E}},{key:"__absoluteDivLarge",value:function(h,y,w,E){var _=y.__halfDigitLength(),b=y.length,C=h.__halfDigitLength()-_,N=null;w&&(N=new T(C+2>>>1,!1),N.__initializeDigits());var M=new T(_+2>>>1,!1);M.__initializeDigits();var U=T.__clz15(y.__halfDigit(_-1));0>>0;X=0|ne/Z;for(var Q=0|ne%Z,re=y.__halfDigit(_-2),ce=G.__halfDigit(H+_-2);T.__imul(X,re)>>>0>(Q<<16|ce)>>>0&&(X--,Q+=Z,!(32767>>1,J|X))}if(E)return G.__inplaceRightShift(U),w?{quotient:N,remainder:G}:G;if(w)return N;throw new Error("unreachable")}},{key:"__clz15",value:function(h){return T.__clz30(h)-15}},{key:"__specialLeftShift",value:function(h,y,w){var E=h.length,_=new T(E+w,!1);if(y===0){for(var b=0;b>>30-y;return 0w)throw new RangeError("BigInt too big");var E=0|w/30,_=w%30,b=h.length,C=_!==0&&h.__digit(b-1)>>>30-_!=0,N=b+E+(C?1:0),M=new T(N,h.sign);if(_===0){for(var U=0;U>>30-_;if(C)M.__setDigit(b+E,G);else if(G!==0)throw new Error("implementation bug")}return M.__trim()}},{key:"__rightShiftByAbsolute",value:function(h,y){var w=h.length,E=h.sign,_=T.__toShiftAmount(y);if(0>_)return T.__rightShiftByMaximum(E);var b=0|_/30,C=_%30,N=w-b;if(0>=N)return T.__rightShiftByMaximum(E);var M=!1;if(E){if(h.__digit(b)&(1<>>C,te=w-b-1,ne=0;ne>>C;Z.__setDigit(te,X)}return M&&(Z=T.__absoluteAddOne(Z,!0,Z)),Z.__trim()}},{key:"__rightShiftByMaximum",value:function(h){return h?T.__oneDigit(1,!0):T.__zero()}},{key:"__toShiftAmount",value:function(h){if(1T.__kMaxLengthBits?-1:y}},{key:"__toPrimitive",value:function(h){var y=1>>N}return E.__setDigit(_,C),E.__trim()}},{key:"__truncateAndSubFromPowerOfTwo",value:function(h,y,w){for(var E=Math.min,_,b=0|(h+29)/30,C=new T(b,w),N=0,M=b-1,U=0,G=E(M,y.length);N>>30,C.__setDigit(N,1073741823&_);for(;N>>X;var te=1<<32-X;Z=te-J-U,Z&=te-1}return C.__setDigit(M,Z),C.__trim()}},{key:"__digitPow",value:function(h,y){for(var w=1;0>>=1,h*=h;return w}},{key:"__isOneDigitInt",value:function(h){return(1073741823&h)===h}}]),T}(p(Array));return F.__kMaxLength=33554432,F.__kMaxLengthBits=F.__kMaxLength<<5,F.__kMaxBitsPerChar=[0,0,32,51,64,75,83,90,96,102,107,111,115,119,122,126,128,131,134,136,139,141,143,145,147,149,151,153,154,156,158,159,160,162,163,165,166],F.__kBitsPerCharTableShift=5,F.__kBitsPerCharTableMultiplier=1<>>0)/W)},F.__imul=t||function(K,W){return 0|K*W},F})});var G6=V(Wr=>{"use strict";f();Object.defineProperty(Wr,"__esModule",{value:!0});Wr.regexpCode=Wr.getEsmExportName=Wr.getProperty=Wr.safeStringify=Wr.stringify=Wr.strConcat=Wr.addCodeArg=Wr.str=Wr._=Wr.nil=Wr._Code=Wr.Name=Wr.IDENTIFIER=Wr._CodeOrName=void 0;var H6=class{};Wr._CodeOrName=H6;Wr.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var hv=class extends H6{constructor(e){if(super(),!Wr.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};Wr.Name=hv;var Fd=class extends H6{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((r,n)=>(n instanceof hv&&(r[n.str]=(r[n.str]||0)+1),r),{})}};Wr._Code=Fd;Wr.nil=new Fd("");function xle(t,...e){let r=[t[0]],n=0;for(;n{"use strict";f();Object.defineProperty(Ca,"__esModule",{value:!0});Ca.ValueScope=Ca.ValueScopeName=Ca.Scope=Ca.varKinds=Ca.UsedValueState=void 0;var cc=G6(),GN=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},JN;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(JN=Ca.UsedValueState||(Ca.UsedValueState={}));Ca.varKinds={const:new cc.Name("const"),let:new cc.Name("let"),var:new cc.Name("var")};var UP=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof cc.Name?e:this.name(e)}name(e){return new cc.Name(this._newName(e))}_newName(e){let r=this._names[e]||this._nameGroup(e);return`${e}${r.index++}`}_nameGroup(e){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};Ca.Scope=UP;var qP=class extends cc.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=(0,cc._)`.${new cc.Name(r)}[${n}]`}};Ca.ValueScopeName=qP;var Xqe=(0,cc._)`\n`,ZN=class extends UP{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?Xqe:cc.nil}}get(){return this._scope}name(e){return new qP(e,this._newName(e))}value(e,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let i=this.toName(e),{prefix:o}=i,s=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[o];if(a){let c=a.get(s);if(c)return c}else a=this._values[o]=new Map;a.set(s,i);let d=this._scope[o]||(this._scope[o]=[]),u=d.length;return d[u]=r.ref,i.setValue(r,{property:o,itemIndex:u}),i}getValue(e,r){let n=this._values[e];if(n)return n.get(r)}scopeRefs(e,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,cc._)`${e}${n.scopePath}`})}scopeCode(e=this._values,r,n){return this._reduceValues(e,i=>{if(i.value===void 0)throw new Error(`CodeGen: name "${i}" has no value`);return i.value.code},r,n)}_reduceValues(e,r,n={},i){let o=cc.nil;for(let s in e){let a=e[s];if(!a)continue;let d=n[s]=n[s]||new Map;a.forEach(u=>{if(d.has(u))return;d.set(u,JN.Started);let c=r(u);if(c){let l=this.opts.es5?Ca.varKinds.var:Ca.varKinds.const;o=(0,cc._)`${o}${l} ${u} = ${c};${this.opts._n}`}else if(c=i?.(u))o=(0,cc._)`${o}${c}${this.opts._n}`;else throw new GN(u);d.set(u,JN.Completed)})}return o}};Ca.ValueScope=ZN});var rr=V(br=>{"use strict";f();Object.defineProperty(br,"__esModule",{value:!0});br.or=br.and=br.not=br.CodeGen=br.operators=br.varKinds=br.ValueScopeName=br.ValueScope=br.Scope=br.Name=br.regexpCode=br.stringify=br.getProperty=br.nil=br.strConcat=br.str=br._=void 0;var qr=G6(),Zu=YN(),ly=G6();Object.defineProperty(br,"_",{enumerable:!0,get:function(){return ly._}});Object.defineProperty(br,"str",{enumerable:!0,get:function(){return ly.str}});Object.defineProperty(br,"strConcat",{enumerable:!0,get:function(){return ly.strConcat}});Object.defineProperty(br,"nil",{enumerable:!0,get:function(){return ly.nil}});Object.defineProperty(br,"getProperty",{enumerable:!0,get:function(){return ly.getProperty}});Object.defineProperty(br,"stringify",{enumerable:!0,get:function(){return ly.stringify}});Object.defineProperty(br,"regexpCode",{enumerable:!0,get:function(){return ly.regexpCode}});Object.defineProperty(br,"Name",{enumerable:!0,get:function(){return ly.Name}});var zP=YN();Object.defineProperty(br,"Scope",{enumerable:!0,get:function(){return zP.Scope}});Object.defineProperty(br,"ValueScope",{enumerable:!0,get:function(){return zP.ValueScope}});Object.defineProperty(br,"ValueScopeName",{enumerable:!0,get:function(){return zP.ValueScopeName}});Object.defineProperty(br,"varKinds",{enumerable:!0,get:function(){return zP.varKinds}});br.operators={GT:new qr._Code(">"),GTE:new qr._Code(">="),LT:new qr._Code("<"),LTE:new qr._Code("<="),EQ:new qr._Code("==="),NEQ:new qr._Code("!=="),NOT:new qr._Code("!"),OR:new qr._Code("||"),AND:new qr._Code("&&"),ADD:new qr._Code("+")};var Gh=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},XN=class extends Gh{constructor(e,r,n){super(),this.varKind=e,this.name=r,this.rhs=n}render({es5:e,_n:r}){let n=e?Zu.varKinds.var:this.varKind,i=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${i};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=s2(this.rhs,e,r)),this}get names(){return this.rhs instanceof qr._CodeOrName?this.rhs.names:{}}},LP=class extends Gh{constructor(e,r,n){super(),this.lhs=e,this.rhs=r,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof qr.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=s2(this.rhs,e,r),this}get names(){let e=this.lhs instanceof qr.Name?{}:{...this.lhs.names};return FP(e,this.rhs)}},QN=class extends LP{constructor(e,r,n,i){super(e,n,i),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},eU=class extends Gh{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},tU=class extends Gh{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},rU=class extends Gh{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},nU=class extends Gh{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,r){return this.code=s2(this.code,e,r),this}get names(){return this.code instanceof qr._CodeOrName?this.code.names:{}}},J6=class extends Gh{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((r,n)=>r+n.render(e),"")}optimizeNodes(){let{nodes:e}=this,r=e.length;for(;r--;){let n=e[r].optimizeNodes();Array.isArray(n)?e.splice(r,1,...n):n?e[r]=n:e.splice(r,1)}return e.length>0?this:void 0}optimizeNames(e,r){let{nodes:n}=this,i=n.length;for(;i--;){let o=n[i];o.optimizeNames(e,r)||(Qqe(e,o.names),n.splice(i,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>yv(e,r.names),{})}},Jh=class extends J6{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},iU=class extends J6{},o2=class extends Jh{};o2.kind="else";var pv=class t extends Jh{constructor(e,r){super(r),this.condition=e}render(e){let r=`if(${this.condition})`+super.render(e);return this.else&&(r+="else "+this.else.render(e)),r}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new o2(n):n}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(Sle(e),r instanceof t?[r]:r.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(e,r),!!(super.optimizeNames(e,r)||this.else))return this.condition=s2(this.condition,e,r),this}get names(){let e=super.names;return FP(e,this.condition),this.else&&yv(e,this.else.names),e}};pv.kind="if";var mv=class extends Jh{};mv.kind="for";var oU=class extends mv{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iteration=s2(this.iteration,e,r),this}get names(){return yv(super.names,this.iteration.names)}},sU=class extends mv{constructor(e,r,n,i){super(),this.varKind=e,this.name=r,this.from=n,this.to=i}render(e){let r=e.es5?Zu.varKinds.var:this.varKind,{name:n,from:i,to:o}=this;return`for(${r} ${n}=${i}; ${n}<${o}; ${n}++)`+super.render(e)}get names(){let e=FP(super.names,this.from);return FP(e,this.to)}},KP=class extends mv{constructor(e,r,n,i){super(),this.loop=e,this.varKind=r,this.name=n,this.iterable=i}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iterable=s2(this.iterable,e,r),this}get names(){return yv(super.names,this.iterable.names)}},Z6=class extends Jh{constructor(e,r,n){super(),this.name=e,this.args=r,this.async=n}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};Z6.kind="func";var Y6=class extends J6{render(e){return"return "+super.render(e)}};Y6.kind="return";var aU=class extends Jh{render(e){let r="try"+super.render(e);return this.catch&&(r+=this.catch.render(e)),this.finally&&(r+=this.finally.render(e)),r}optimizeNodes(){var e,r;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(e,r){var n,i;return super.optimizeNames(e,r),(n=this.catch)===null||n===void 0||n.optimizeNames(e,r),(i=this.finally)===null||i===void 0||i.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&yv(e,this.catch.names),this.finally&&yv(e,this.finally.names),e}},X6=class extends Jh{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};X6.kind="catch";var Q6=class extends Jh{render(e){return"finally"+super.render(e)}};Q6.kind="finally";var cU=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?` +`:""},this._extScope=e,this._scope=new Zu.Scope({parent:e}),this._nodes=[new iU]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,r){let n=this._extScope.value(e,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,r){return this._extScope.getValue(e,r)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,r,n,i){let o=this._scope.toName(r);return n!==void 0&&i&&(this._constants[o.str]=n),this._leafNode(new XN(e,o,n)),o}const(e,r,n){return this._def(Zu.varKinds.const,e,r,n)}let(e,r,n){return this._def(Zu.varKinds.let,e,r,n)}var(e,r,n){return this._def(Zu.varKinds.var,e,r,n)}assign(e,r,n){return this._leafNode(new LP(e,r,n))}add(e,r){return this._leafNode(new QN(e,br.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==qr.nil&&this._leafNode(new nU(e)),this}object(...e){let r=["{"];for(let[n,i]of e)r.length>1&&r.push(","),r.push(n),(n!==i||this.opts.es5)&&(r.push(":"),(0,qr.addCodeArg)(r,i));return r.push("}"),new qr._Code(r)}if(e,r,n){if(this._blockNode(new pv(e)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new pv(e))}else(){return this._elseNode(new o2)}endIf(){return this._endBlockNode(pv,o2)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new oU(e),r)}forRange(e,r,n,i,o=this.opts.es5?Zu.varKinds.var:Zu.varKinds.let){let s=this._scope.toName(e);return this._for(new sU(o,s,r,n),()=>i(s))}forOf(e,r,n,i=Zu.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let s=r instanceof qr.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,qr._)`${s}.length`,a=>{this.var(o,(0,qr._)`${s}[${a}]`),n(o)})}return this._for(new KP("of",i,o,r),()=>n(o))}forIn(e,r,n,i=this.opts.es5?Zu.varKinds.var:Zu.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,qr._)`Object.keys(${r})`,n);let o=this._scope.toName(e);return this._for(new KP("in",i,o,r),()=>n(o))}endFor(){return this._endBlockNode(mv)}label(e){return this._leafNode(new eU(e))}break(e){return this._leafNode(new tU(e))}return(e){let r=new Y6;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(Y6)}try(e,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let i=new aU;if(this._blockNode(i),this.code(e),r){let o=this.name("e");this._currNode=i.catch=new X6(o),r(o)}return n&&(this._currNode=i.finally=new Q6,this.code(n)),this._endBlockNode(X6,Q6)}throw(e){return this._leafNode(new rU(e))}block(e,r){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(r),this}endBlock(e){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||e!==void 0&&n!==e)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=r,this}func(e,r=qr.nil,n,i){return this._blockNode(new Z6(e,r,n)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(Z6)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,r){let n=this._currNode;if(n instanceof e||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${e.kind}/${r.kind}`:e.kind}"`)}_elseNode(e){let r=this._currNode;if(!(r instanceof pv))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let r=this._nodes;r[r.length-1]=e}};br.CodeGen=cU;function yv(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function FP(t,e){return e instanceof qr._CodeOrName?yv(t,e.names):t}function s2(t,e,r){if(t instanceof qr.Name)return n(t);if(!i(t))return t;return new qr._Code(t._items.reduce((o,s)=>(s instanceof qr.Name&&(s=n(s)),s instanceof qr._Code?o.push(...s._items):o.push(s),o),[]));function n(o){let s=r[o.str];return s===void 0||e[o.str]!==1?o:(delete e[o.str],s)}function i(o){return o instanceof qr._Code&&o._items.some(s=>s instanceof qr.Name&&e[s.str]===1&&r[s.str]!==void 0)}}function Qqe(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function Sle(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,qr._)`!${dU(t)}`}br.not=Sle;var eLe=Ale(br.operators.AND);function tLe(...t){return t.reduce(eLe)}br.and=tLe;var rLe=Ale(br.operators.OR);function nLe(...t){return t.reduce(rLe)}br.or=nLe;function Ale(t){return(e,r)=>e===qr.nil?r:r===qr.nil?e:(0,qr._)`${dU(e)} ${t} ${dU(r)}`}function dU(t){return t instanceof qr.Name?t:(0,qr._)`(${t})`}});var Rr=V(wr=>{"use strict";f();Object.defineProperty(wr,"__esModule",{value:!0});wr.checkStrictMode=wr.getErrorPath=wr.Type=wr.useFunc=wr.setEvaluated=wr.evaluatedPropsToName=wr.mergeEvaluated=wr.eachItem=wr.unescapeJsonPointer=wr.escapeJsonPointer=wr.escapeFragment=wr.unescapeFragment=wr.schemaRefOrVal=wr.schemaHasRulesButRef=wr.schemaHasRules=wr.checkUnknownRules=wr.alwaysValidSchema=wr.toHash=void 0;var Rn=rr(),iLe=G6();function oLe(t){let e={};for(let r of t)e[r]=!0;return e}wr.toHash=oLe;function sLe(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(Ile(t,e),!kle(e,t.self.RULES.all))}wr.alwaysValidSchema=sLe;function Ile(t,e=t.schema){let{opts:r,self:n}=t;if(!r.strictSchema||typeof e=="boolean")return;let i=n.RULES.keywords;for(let o in e)i[o]||Mle(t,`unknown keyword: "${o}"`)}wr.checkUnknownRules=Ile;function kle(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}wr.schemaHasRules=kle;function aLe(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}wr.schemaHasRulesButRef=aLe;function cLe({topSchemaRef:t,schemaPath:e},r,n,i){if(!i){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,Rn._)`${r}`}return(0,Rn._)`${t}${e}${(0,Rn.getProperty)(n)}`}wr.schemaRefOrVal=cLe;function dLe(t){return Rle(decodeURIComponent(t))}wr.unescapeFragment=dLe;function uLe(t){return encodeURIComponent(uU(t))}wr.escapeFragment=uLe;function uU(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}wr.escapeJsonPointer=uU;function Rle(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}wr.unescapeJsonPointer=Rle;function lLe(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}wr.eachItem=lLe;function Tle({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:n}){return(i,o,s,a)=>{let d=s===void 0?o:s instanceof Rn.Name?(o instanceof Rn.Name?t(i,o,s):e(i,o,s),s):o instanceof Rn.Name?(e(i,s,o),o):r(o,s);return a===Rn.Name&&!(d instanceof Rn.Name)?n(i,d):d}}wr.mergeEvaluated={props:Tle({mergeNames:(t,e,r)=>t.if((0,Rn._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,Rn._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,Rn._)`${r} || {}`).code((0,Rn._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,Rn._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,Rn._)`${r} || {}`),lU(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:Dle}),items:Tle({mergeNames:(t,e,r)=>t.if((0,Rn._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,Rn._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,Rn._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,Rn._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function Dle(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,Rn._)`{}`);return e!==void 0&&lU(t,r,e),r}wr.evaluatedPropsToName=Dle;function lU(t,e,r){Object.keys(r).forEach(n=>t.assign((0,Rn._)`${e}${(0,Rn.getProperty)(n)}`,!0))}wr.setEvaluated=lU;var Ple={};function fLe(t,e){return t.scopeValue("func",{ref:e,code:Ple[e.code]||(Ple[e.code]=new iLe._Code(e.code))})}wr.useFunc=fLe;var Ble;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(Ble=wr.Type||(wr.Type={}));function hLe(t,e,r){if(t instanceof Rn.Name){let n=e===Ble.Num;return r?n?(0,Rn._)`"[" + ${t} + "]"`:(0,Rn._)`"['" + ${t} + "']"`:n?(0,Rn._)`"/" + ${t}`:(0,Rn._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,Rn.getProperty)(t).toString():"/"+uU(t)}wr.getErrorPath=hLe;function Mle(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}wr.checkStrictMode=Mle});var zd=V(fU=>{"use strict";f();Object.defineProperty(fU,"__esModule",{value:!0});var sa=rr(),pLe={data:new sa.Name("data"),valCxt:new sa.Name("valCxt"),instancePath:new sa.Name("instancePath"),parentData:new sa.Name("parentData"),parentDataProperty:new sa.Name("parentDataProperty"),rootData:new sa.Name("rootData"),dynamicAnchors:new sa.Name("dynamicAnchors"),vErrors:new sa.Name("vErrors"),errors:new sa.Name("errors"),this:new sa.Name("this"),self:new sa.Name("self"),scope:new sa.Name("scope"),json:new sa.Name("json"),jsonPos:new sa.Name("jsonPos"),jsonLen:new sa.Name("jsonLen"),jsonPart:new sa.Name("jsonPart")};fU.default=pLe});var eS=V(aa=>{"use strict";f();Object.defineProperty(aa,"__esModule",{value:!0});aa.extendErrors=aa.resetErrorsCount=aa.reportExtraError=aa.reportError=aa.keyword$DataError=aa.keywordError=void 0;var Kr=rr(),WP=Rr(),$a=zd();aa.keywordError={message:({keyword:t})=>(0,Kr.str)`must pass "${t}" keyword validation`};aa.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,Kr.str)`"${t}" keyword must be ${e} ($data)`:(0,Kr.str)`"${t}" keyword is invalid ($data)`};function mLe(t,e=aa.keywordError,r,n){let{it:i}=t,{gen:o,compositeRule:s,allErrors:a}=i,d=$le(t,e,r);n??(s||a)?Ole(o,d):Cle(i,(0,Kr._)`[${d}]`)}aa.reportError=mLe;function yLe(t,e=aa.keywordError,r){let{it:n}=t,{gen:i,compositeRule:o,allErrors:s}=n,a=$le(t,e,r);Ole(i,a),o||s||Cle(n,$a.default.vErrors)}aa.reportExtraError=yLe;function gLe(t,e){t.assign($a.default.errors,e),t.if((0,Kr._)`${$a.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,Kr._)`${$a.default.vErrors}.length`,e),()=>t.assign($a.default.vErrors,null)))}aa.resetErrorsCount=gLe;function vLe({gen:t,keyword:e,schemaValue:r,data:n,errsCount:i,it:o}){if(i===void 0)throw new Error("ajv implementation error");let s=t.name("err");t.forRange("i",i,$a.default.errors,a=>{t.const(s,(0,Kr._)`${$a.default.vErrors}[${a}]`),t.if((0,Kr._)`${s}.instancePath === undefined`,()=>t.assign((0,Kr._)`${s}.instancePath`,(0,Kr.strConcat)($a.default.instancePath,o.errorPath))),t.assign((0,Kr._)`${s}.schemaPath`,(0,Kr.str)`${o.errSchemaPath}/${e}`),o.opts.verbose&&(t.assign((0,Kr._)`${s}.schema`,r),t.assign((0,Kr._)`${s}.data`,n))})}aa.extendErrors=vLe;function Ole(t,e){let r=t.const("err",e);t.if((0,Kr._)`${$a.default.vErrors} === null`,()=>t.assign($a.default.vErrors,(0,Kr._)`[${r}]`),(0,Kr._)`${$a.default.vErrors}.push(${r})`),t.code((0,Kr._)`${$a.default.errors}++`)}function Cle(t,e){let{gen:r,validateName:n,schemaEnv:i}=t;i.$async?r.throw((0,Kr._)`new ${t.ValidationError}(${e})`):(r.assign((0,Kr._)`${n}.errors`,e),r.return(!1))}var gv={keyword:new Kr.Name("keyword"),schemaPath:new Kr.Name("schemaPath"),params:new Kr.Name("params"),propertyName:new Kr.Name("propertyName"),message:new Kr.Name("message"),schema:new Kr.Name("schema"),parentSchema:new Kr.Name("parentSchema")};function $le(t,e,r){let{createErrors:n}=t.it;return n===!1?(0,Kr._)`{}`:bLe(t,e,r)}function bLe(t,e,r={}){let{gen:n,it:i}=t,o=[wLe(i,r),_Le(t,r)];return xLe(t,e,o),n.object(...o)}function wLe({errorPath:t},{instancePath:e}){let r=e?(0,Kr.str)`${t}${(0,WP.getErrorPath)(e,WP.Type.Str)}`:t;return[$a.default.instancePath,(0,Kr.strConcat)($a.default.instancePath,r)]}function _Le({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:n}){let i=n?e:(0,Kr.str)`${e}/${t}`;return r&&(i=(0,Kr.str)`${i}${(0,WP.getErrorPath)(r,WP.Type.Str)}`),[gv.schemaPath,i]}function xLe(t,{params:e,message:r},n){let{keyword:i,data:o,schemaValue:s,it:a}=t,{opts:d,propertyName:u,topSchemaRef:c,schemaPath:l}=a;n.push([gv.keyword,i],[gv.params,typeof e=="function"?e(t):e||(0,Kr._)`{}`]),d.messages&&n.push([gv.message,typeof r=="function"?r(t):r]),d.verbose&&n.push([gv.schema,s],[gv.parentSchema,(0,Kr._)`${c}${l}`],[$a.default.data,o]),u&&n.push([gv.propertyName,u])}});var Nle=V(a2=>{"use strict";f();Object.defineProperty(a2,"__esModule",{value:!0});a2.boolOrEmptySchema=a2.topBoolOrEmptySchema=void 0;var ELe=eS(),SLe=rr(),ALe=zd(),TLe={message:"boolean schema is false"};function PLe(t){let{gen:e,schema:r,validateName:n}=t;r===!1?jle(t,!1):typeof r=="object"&&r.$async===!0?e.return(ALe.default.data):(e.assign((0,SLe._)`${n}.errors`,null),e.return(!0))}a2.topBoolOrEmptySchema=PLe;function ILe(t,e){let{gen:r,schema:n}=t;n===!1?(r.var(e,!1),jle(t)):r.var(e,!0)}a2.boolOrEmptySchema=ILe;function jle(t,e){let{gen:r,data:n}=t,i={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,ELe.reportError)(i,TLe,void 0,e)}});var hU=V(c2=>{"use strict";f();Object.defineProperty(c2,"__esModule",{value:!0});c2.getRules=c2.isJSONType=void 0;var kLe=["string","number","integer","boolean","null","object","array"],RLe=new Set(kLe);function DLe(t){return typeof t=="string"&&RLe.has(t)}c2.isJSONType=DLe;function BLe(){let t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}c2.getRules=BLe});var pU=V(fy=>{"use strict";f();Object.defineProperty(fy,"__esModule",{value:!0});fy.shouldUseRule=fy.shouldUseGroup=fy.schemaHasRulesForType=void 0;function MLe({schema:t,self:e},r){let n=e.RULES.types[r];return n&&n!==!0&&Ule(t,n)}fy.schemaHasRulesForType=MLe;function Ule(t,e){return e.rules.some(r=>qle(t,r))}fy.shouldUseGroup=Ule;function qle(t,e){var r;return t[e.keyword]!==void 0||((r=e.definition.implements)===null||r===void 0?void 0:r.some(n=>t[n]!==void 0))}fy.shouldUseRule=qle});var rS=V(Es=>{"use strict";f();Object.defineProperty(Es,"__esModule",{value:!0});Es.reportTypeError=Es.checkDataTypes=Es.checkDataType=Es.coerceAndCheckDataType=Es.getJSONTypes=Es.getSchemaTypes=Es.DataType=void 0;var OLe=hU(),CLe=pU(),$Le=eS(),ir=rr(),Lle=Rr(),tS;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(tS=Es.DataType||(Es.DataType={}));function jLe(t){let e=Kle(t.type);if(e.includes("null")){if(t.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&t.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');t.nullable===!0&&e.push("null")}return e}Es.getSchemaTypes=jLe;function Kle(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(OLe.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}Es.getJSONTypes=Kle;function NLe(t,e){let{gen:r,data:n,opts:i}=t,o=ULe(e,i.coerceTypes),s=e.length>0&&!(o.length===0&&e.length===1&&(0,CLe.schemaHasRulesForType)(t,e[0]));if(s){let a=yU(e,n,i.strictNumbers,tS.Wrong);r.if(a,()=>{o.length?qLe(t,e,o):gU(t)})}return s}Es.coerceAndCheckDataType=NLe;var Fle=new Set(["string","number","integer","boolean","null"]);function ULe(t,e){return e?t.filter(r=>Fle.has(r)||e==="array"&&r==="array"):[]}function qLe(t,e,r){let{gen:n,data:i,opts:o}=t,s=n.let("dataType",(0,ir._)`typeof ${i}`),a=n.let("coerced",(0,ir._)`undefined`);o.coerceTypes==="array"&&n.if((0,ir._)`${s} == 'object' && Array.isArray(${i}) && ${i}.length == 1`,()=>n.assign(i,(0,ir._)`${i}[0]`).assign(s,(0,ir._)`typeof ${i}`).if(yU(e,i,o.strictNumbers),()=>n.assign(a,i))),n.if((0,ir._)`${a} !== undefined`);for(let u of r)(Fle.has(u)||u==="array"&&o.coerceTypes==="array")&&d(u);n.else(),gU(t),n.endIf(),n.if((0,ir._)`${a} !== undefined`,()=>{n.assign(i,a),LLe(t,a)});function d(u){switch(u){case"string":n.elseIf((0,ir._)`${s} == "number" || ${s} == "boolean"`).assign(a,(0,ir._)`"" + ${i}`).elseIf((0,ir._)`${i} === null`).assign(a,(0,ir._)`""`);return;case"number":n.elseIf((0,ir._)`${s} == "boolean" || ${i} === null + || (${s} == "string" && ${i} && ${i} == +${i})`).assign(a,(0,ir._)`+${i}`);return;case"integer":n.elseIf((0,ir._)`${s} === "boolean" || ${i} === null + || (${s} === "string" && ${i} && ${i} == +${i} && !(${i} % 1))`).assign(a,(0,ir._)`+${i}`);return;case"boolean":n.elseIf((0,ir._)`${i} === "false" || ${i} === 0 || ${i} === null`).assign(a,!1).elseIf((0,ir._)`${i} === "true" || ${i} === 1`).assign(a,!0);return;case"null":n.elseIf((0,ir._)`${i} === "" || ${i} === 0 || ${i} === false`),n.assign(a,null);return;case"array":n.elseIf((0,ir._)`${s} === "string" || ${s} === "number" + || ${s} === "boolean" || ${i} === null`).assign(a,(0,ir._)`[${i}]`)}}}function LLe({gen:t,parentData:e,parentDataProperty:r},n){t.if((0,ir._)`${e} !== undefined`,()=>t.assign((0,ir._)`${e}[${r}]`,n))}function mU(t,e,r,n=tS.Correct){let i=n===tS.Correct?ir.operators.EQ:ir.operators.NEQ,o;switch(t){case"null":return(0,ir._)`${e} ${i} null`;case"array":o=(0,ir._)`Array.isArray(${e})`;break;case"object":o=(0,ir._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":o=s((0,ir._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":o=s();break;default:return(0,ir._)`typeof ${e} ${i} ${t}`}return n===tS.Correct?o:(0,ir.not)(o);function s(a=ir.nil){return(0,ir.and)((0,ir._)`typeof ${e} == "number"`,a,r?(0,ir._)`isFinite(${e})`:ir.nil)}}Es.checkDataType=mU;function yU(t,e,r,n){if(t.length===1)return mU(t[0],e,r,n);let i,o=(0,Lle.toHash)(t);if(o.array&&o.object){let s=(0,ir._)`typeof ${e} != "object"`;i=o.null?s:(0,ir._)`!${e} || ${s}`,delete o.null,delete o.array,delete o.object}else i=ir.nil;o.number&&delete o.integer;for(let s in o)i=(0,ir.and)(i,mU(s,e,r,n));return i}Es.checkDataTypes=yU;var KLe={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,ir._)`{type: ${t}}`:(0,ir._)`{type: ${e}}`};function gU(t){let e=FLe(t);(0,$Le.reportError)(e,KLe)}Es.reportTypeError=gU;function FLe(t){let{gen:e,data:r,schema:n}=t,i=(0,Lle.schemaRefOrVal)(t,n,"type");return{gen:e,keyword:"type",data:r,schema:n.type,schemaCode:i,schemaValue:i,parentSchema:n,params:{},it:t}}});var Wle=V(HP=>{"use strict";f();Object.defineProperty(HP,"__esModule",{value:!0});HP.assignDefaults=void 0;var d2=rr(),zLe=Rr();function WLe(t,e){let{properties:r,items:n}=t.schema;if(e==="object"&&r)for(let i in r)zle(t,i,r[i].default);else e==="array"&&Array.isArray(n)&&n.forEach((i,o)=>zle(t,o,i.default))}HP.assignDefaults=WLe;function zle(t,e,r){let{gen:n,compositeRule:i,data:o,opts:s}=t;if(r===void 0)return;let a=(0,d2._)`${o}${(0,d2.getProperty)(e)}`;if(i){(0,zLe.checkStrictMode)(t,`default is ignored for: ${a}`);return}let d=(0,d2._)`${a} === undefined`;s.useDefaults==="empty"&&(d=(0,d2._)`${d} || ${a} === null || ${a} === ""`),n.if(d,(0,d2._)`${a} = ${(0,d2.stringify)(r)}`)}});var Wd=V(_n=>{"use strict";f();Object.defineProperty(_n,"__esModule",{value:!0});_n.validateUnion=_n.validateArray=_n.usePattern=_n.callValidateCode=_n.schemaProperties=_n.allSchemaProperties=_n.noPropertyInData=_n.propertyInData=_n.isOwnProperty=_n.hasPropFunc=_n.reportMissingProp=_n.checkMissingProp=_n.checkReportMissingProp=void 0;var Fn=rr(),vU=Rr(),hy=zd(),HLe=Rr();function VLe(t,e){let{gen:r,data:n,it:i}=t;r.if(wU(r,n,e,i.opts.ownProperties),()=>{t.setParams({missingProperty:(0,Fn._)`${e}`},!0),t.error()})}_n.checkReportMissingProp=VLe;function GLe({gen:t,data:e,it:{opts:r}},n,i){return(0,Fn.or)(...n.map(o=>(0,Fn.and)(wU(t,e,o,r.ownProperties),(0,Fn._)`${i} = ${o}`)))}_n.checkMissingProp=GLe;function JLe(t,e){t.setParams({missingProperty:e},!0),t.error()}_n.reportMissingProp=JLe;function Hle(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Fn._)`Object.prototype.hasOwnProperty`})}_n.hasPropFunc=Hle;function bU(t,e,r){return(0,Fn._)`${Hle(t)}.call(${e}, ${r})`}_n.isOwnProperty=bU;function ZLe(t,e,r,n){let i=(0,Fn._)`${e}${(0,Fn.getProperty)(r)} !== undefined`;return n?(0,Fn._)`${i} && ${bU(t,e,r)}`:i}_n.propertyInData=ZLe;function wU(t,e,r,n){let i=(0,Fn._)`${e}${(0,Fn.getProperty)(r)} === undefined`;return n?(0,Fn.or)(i,(0,Fn.not)(bU(t,e,r))):i}_n.noPropertyInData=wU;function Vle(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}_n.allSchemaProperties=Vle;function YLe(t,e){return Vle(e).filter(r=>!(0,vU.alwaysValidSchema)(t,e[r]))}_n.schemaProperties=YLe;function XLe({schemaCode:t,data:e,it:{gen:r,topSchemaRef:n,schemaPath:i,errorPath:o},it:s},a,d,u){let c=u?(0,Fn._)`${t}, ${e}, ${n}${i}`:e,l=[[hy.default.instancePath,(0,Fn.strConcat)(hy.default.instancePath,o)],[hy.default.parentData,s.parentData],[hy.default.parentDataProperty,s.parentDataProperty],[hy.default.rootData,hy.default.rootData]];s.opts.dynamicRef&&l.push([hy.default.dynamicAnchors,hy.default.dynamicAnchors]);let p=(0,Fn._)`${c}, ${r.object(...l)}`;return d!==Fn.nil?(0,Fn._)`${a}.call(${d}, ${p})`:(0,Fn._)`${a}(${p})`}_n.callValidateCode=XLe;var QLe=(0,Fn._)`new RegExp`;function eKe({gen:t,it:{opts:e}},r){let n=e.unicodeRegExp?"u":"",{regExp:i}=e.code,o=i(r,n);return t.scopeValue("pattern",{key:o.toString(),ref:o,code:(0,Fn._)`${i.code==="new RegExp"?QLe:(0,HLe.useFunc)(t,i)}(${r}, ${n})`})}_n.usePattern=eKe;function tKe(t){let{gen:e,data:r,keyword:n,it:i}=t,o=e.name("valid");if(i.allErrors){let a=e.let("valid",!0);return s(()=>e.assign(a,!1)),a}return e.var(o,!0),s(()=>e.break()),o;function s(a){let d=e.const("len",(0,Fn._)`${r}.length`);e.forRange("i",0,d,u=>{t.subschema({keyword:n,dataProp:u,dataPropType:vU.Type.Num},o),e.if((0,Fn.not)(o),a)})}}_n.validateArray=tKe;function rKe(t){let{gen:e,schema:r,keyword:n,it:i}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(d=>(0,vU.alwaysValidSchema)(i,d))&&!i.opts.unevaluated)return;let s=e.let("valid",!1),a=e.name("_valid");e.block(()=>r.forEach((d,u)=>{let c=t.subschema({keyword:n,schemaProp:u,compositeRule:!0},a);e.assign(s,(0,Fn._)`${s} || ${a}`),t.mergeValidEvaluated(c,a)||e.if((0,Fn.not)(s))})),t.result(s,()=>t.reset(),()=>t.error(!0))}_n.validateUnion=rKe});var Zle=V(mf=>{"use strict";f();Object.defineProperty(mf,"__esModule",{value:!0});mf.validateKeywordUsage=mf.validSchemaType=mf.funcKeywordCode=mf.macroKeywordCode=void 0;var ja=rr(),vv=zd(),nKe=Wd(),iKe=eS();function oKe(t,e){let{gen:r,keyword:n,schema:i,parentSchema:o,it:s}=t,a=e.macro.call(s.self,i,o,s),d=Jle(r,n,a);s.opts.validateSchema!==!1&&s.self.validateSchema(a,!0);let u=r.name("valid");t.subschema({schema:a,schemaPath:ja.nil,errSchemaPath:`${s.errSchemaPath}/${n}`,topSchemaRef:d,compositeRule:!0},u),t.pass(u,()=>t.error(!0))}mf.macroKeywordCode=oKe;function sKe(t,e){var r;let{gen:n,keyword:i,schema:o,parentSchema:s,$data:a,it:d}=t;cKe(d,e);let u=!a&&e.compile?e.compile.call(d.self,o,s,d):e.validate,c=Jle(n,i,u),l=n.let("valid");t.block$data(l,p),t.ok((r=e.valid)!==null&&r!==void 0?r:l);function p(){if(e.errors===!1)v(),e.modifying&&Gle(t),x(()=>t.error());else{let S=e.async?m():g();e.modifying&&Gle(t),x(()=>aKe(t,S))}}function m(){let S=n.let("ruleErrs",null);return n.try(()=>v((0,ja._)`await `),P=>n.assign(l,!1).if((0,ja._)`${P} instanceof ${d.ValidationError}`,()=>n.assign(S,(0,ja._)`${P}.errors`),()=>n.throw(P))),S}function g(){let S=(0,ja._)`${c}.errors`;return n.assign(S,null),v(ja.nil),S}function v(S=e.async?(0,ja._)`await `:ja.nil){let P=d.opts.passContext?vv.default.this:vv.default.self,A=!("compile"in e&&!a||e.schema===!1);n.assign(l,(0,ja._)`${S}${(0,nKe.callValidateCode)(t,c,P,A)}`,e.modifying)}function x(S){var P;n.if((0,ja.not)((P=e.valid)!==null&&P!==void 0?P:l),S)}}mf.funcKeywordCode=sKe;function Gle(t){let{gen:e,data:r,it:n}=t;e.if(n.parentData,()=>e.assign(r,(0,ja._)`${n.parentData}[${n.parentDataProperty}]`))}function aKe(t,e){let{gen:r}=t;r.if((0,ja._)`Array.isArray(${e})`,()=>{r.assign(vv.default.vErrors,(0,ja._)`${vv.default.vErrors} === null ? ${e} : ${vv.default.vErrors}.concat(${e})`).assign(vv.default.errors,(0,ja._)`${vv.default.vErrors}.length`),(0,iKe.extendErrors)(t)},()=>t.error())}function cKe({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function Jle(t,e,r){if(r===void 0)throw new Error(`keyword "${e}" failed to compile`);return t.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,ja.stringify)(r)})}function dKe(t,e,r=!1){return!e.length||e.some(n=>n==="array"?Array.isArray(t):n==="object"?t&&typeof t=="object"&&!Array.isArray(t):typeof t==n||r&&typeof t>"u")}mf.validSchemaType=dKe;function uKe({schema:t,opts:e,self:r,errSchemaPath:n},i,o){if(Array.isArray(i.keyword)?!i.keyword.includes(o):i.keyword!==o)throw new Error("ajv implementation error");let s=i.dependencies;if(s?.some(a=>!Object.prototype.hasOwnProperty.call(t,a)))throw new Error(`parent schema must have dependencies of ${o}: ${s.join(",")}`);if(i.validateSchema&&!i.validateSchema(t[o])){let d=`keyword "${o}" value is invalid at path "${n}": `+r.errorsText(i.validateSchema.errors);if(e.validateSchema==="log")r.logger.error(d);else throw new Error(d)}}mf.validateKeywordUsage=uKe});var Xle=V(py=>{"use strict";f();Object.defineProperty(py,"__esModule",{value:!0});py.extendSubschemaMode=py.extendSubschemaData=py.getSubschema=void 0;var yf=rr(),Yle=Rr();function lKe(t,{keyword:e,schemaProp:r,schema:n,schemaPath:i,errSchemaPath:o,topSchemaRef:s}){if(e!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){let a=t.schema[e];return r===void 0?{schema:a,schemaPath:(0,yf._)`${t.schemaPath}${(0,yf.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[r],schemaPath:(0,yf._)`${t.schemaPath}${(0,yf.getProperty)(e)}${(0,yf.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,Yle.escapeFragment)(r)}`}}if(n!==void 0){if(i===void 0||o===void 0||s===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:i,topSchemaRef:s,errSchemaPath:o}}throw new Error('either "keyword" or "schema" must be passed')}py.getSubschema=lKe;function fKe(t,e,{dataProp:r,dataPropType:n,data:i,dataTypes:o,propertyName:s}){if(i!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=e;if(r!==void 0){let{errorPath:u,dataPathArr:c,opts:l}=e,p=a.let("data",(0,yf._)`${e.data}${(0,yf.getProperty)(r)}`,!0);d(p),t.errorPath=(0,yf.str)`${u}${(0,Yle.getErrorPath)(r,n,l.jsPropertySyntax)}`,t.parentDataProperty=(0,yf._)`${r}`,t.dataPathArr=[...c,t.parentDataProperty]}if(i!==void 0){let u=i instanceof yf.Name?i:a.let("data",i,!0);d(u),s!==void 0&&(t.propertyName=s)}o&&(t.dataTypes=o);function d(u){t.data=u,t.dataLevel=e.dataLevel+1,t.dataTypes=[],e.definedProperties=new Set,t.parentData=e.data,t.dataNames=[...e.dataNames,u]}}py.extendSubschemaData=fKe;function hKe(t,{jtdDiscriminator:e,jtdMetadata:r,compositeRule:n,createErrors:i,allErrors:o}){n!==void 0&&(t.compositeRule=n),i!==void 0&&(t.createErrors=i),o!==void 0&&(t.allErrors=o),t.jtdDiscriminator=e,t.jtdMetadata=r}py.extendSubschemaMode=hKe});var _U=V((w3t,Qle)=>{"use strict";f();Qle.exports=function t(e,r){if(e===r)return!0;if(e&&r&&typeof e=="object"&&typeof r=="object"){if(e.constructor!==r.constructor)return!1;var n,i,o;if(Array.isArray(e)){if(n=e.length,n!=r.length)return!1;for(i=n;i--!==0;)if(!t(e[i],r[i]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if(o=Object.keys(e),n=o.length,n!==Object.keys(r).length)return!1;for(i=n;i--!==0;)if(!Object.prototype.hasOwnProperty.call(r,o[i]))return!1;for(i=n;i--!==0;){var s=o[i];if(!t(e[s],r[s]))return!1}return!0}return e!==e&&r!==r}});var tfe=V((x3t,efe)=>{"use strict";f();var my=efe.exports=function(t,e,r){typeof e=="function"&&(r=e,e={}),r=e.cb||r;var n=typeof r=="function"?r:r.pre||function(){},i=r.post||function(){};VP(e,n,i,t,"",t)};my.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};my.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};my.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};my.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function VP(t,e,r,n,i,o,s,a,d,u){if(n&&typeof n=="object"&&!Array.isArray(n)){e(n,i,o,s,a,d,u);for(var c in n){var l=n[c];if(Array.isArray(l)){if(c in my.arrayKeywords)for(var p=0;p{"use strict";f();Object.defineProperty(dc,"__esModule",{value:!0});dc.getSchemaRefs=dc.resolveUrl=dc.normalizeId=dc._getFullPath=dc.getFullPath=dc.inlineRef=void 0;var mKe=Rr(),yKe=_U(),gKe=tfe(),vKe=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function bKe(t,e=!0){return typeof t=="boolean"?!0:e===!0?!xU(t):e?rfe(t)<=e:!1}dc.inlineRef=bKe;var wKe=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function xU(t){for(let e in t){if(wKe.has(e))return!0;let r=t[e];if(Array.isArray(r)&&r.some(xU)||typeof r=="object"&&xU(r))return!0}return!1}function rfe(t){let e=0;for(let r in t){if(r==="$ref")return 1/0;if(e++,!vKe.has(r)&&(typeof t[r]=="object"&&(0,mKe.eachItem)(t[r],n=>e+=rfe(n)),e===1/0))return 1/0}return e}function nfe(t,e="",r){r!==!1&&(e=u2(e));let n=t.parse(e);return ife(t,n)}dc.getFullPath=nfe;function ife(t,e){return t.serialize(e).split("#")[0]+"#"}dc._getFullPath=ife;var _Ke=/#\/?$/;function u2(t){return t?t.replace(_Ke,""):""}dc.normalizeId=u2;function xKe(t,e,r){return r=u2(r),t.resolve(e,r)}dc.resolveUrl=xKe;var EKe=/^[a-z_][-a-z0-9._]*$/i;function SKe(t,e){if(typeof t=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,i=u2(t[r]||e),o={"":i},s=nfe(n,i,!1),a={},d=new Set;return gKe(t,{allKeys:!0},(l,p,m,g)=>{if(g===void 0)return;let v=s+p,x=o[g];typeof l[r]=="string"&&(x=S.call(this,l[r])),P.call(this,l.$anchor),P.call(this,l.$dynamicAnchor),o[p]=x;function S(A){let $=this.opts.uriResolver.resolve;if(A=u2(x?$(x,A):A),d.has(A))throw c(A);d.add(A);let j=this.refs[A];return typeof j=="string"&&(j=this.refs[j]),typeof j=="object"?u(l,j.schema,A):A!==u2(v)&&(A[0]==="#"?(u(l,a[A],A),a[A]=l):this.refs[A]=v),A}function P(A){if(typeof A=="string"){if(!EKe.test(A))throw new Error(`invalid anchor "${A}"`);S.call(this,`#${A}`)}}}),a;function u(l,p,m){if(p!==void 0&&!yKe(l,p))throw c(m)}function c(l){return new Error(`reference "${l}" resolves to more than one schema`)}}dc.getSchemaRefs=SKe});var sS=V(yy=>{"use strict";f();Object.defineProperty(yy,"__esModule",{value:!0});yy.getData=yy.KeywordCxt=yy.validateFunctionCode=void 0;var dfe=Nle(),ofe=rS(),SU=pU(),GP=rS(),AKe=Wle(),oS=Zle(),EU=Xle(),pt=rr(),Nt=zd(),TKe=nS(),Zh=Rr(),iS=eS();function PKe(t){if(ffe(t)&&(hfe(t),lfe(t))){RKe(t);return}ufe(t,()=>(0,dfe.topBoolOrEmptySchema)(t))}yy.validateFunctionCode=PKe;function ufe({gen:t,validateName:e,schema:r,schemaEnv:n,opts:i},o){i.code.es5?t.func(e,(0,pt._)`${Nt.default.data}, ${Nt.default.valCxt}`,n.$async,()=>{t.code((0,pt._)`"use strict"; ${sfe(r,i)}`),kKe(t,i),t.code(o)}):t.func(e,(0,pt._)`${Nt.default.data}, ${IKe(i)}`,n.$async,()=>t.code(sfe(r,i)).code(o))}function IKe(t){return(0,pt._)`{${Nt.default.instancePath}="", ${Nt.default.parentData}, ${Nt.default.parentDataProperty}, ${Nt.default.rootData}=${Nt.default.data}${t.dynamicRef?(0,pt._)`, ${Nt.default.dynamicAnchors}={}`:pt.nil}}={}`}function kKe(t,e){t.if(Nt.default.valCxt,()=>{t.var(Nt.default.instancePath,(0,pt._)`${Nt.default.valCxt}.${Nt.default.instancePath}`),t.var(Nt.default.parentData,(0,pt._)`${Nt.default.valCxt}.${Nt.default.parentData}`),t.var(Nt.default.parentDataProperty,(0,pt._)`${Nt.default.valCxt}.${Nt.default.parentDataProperty}`),t.var(Nt.default.rootData,(0,pt._)`${Nt.default.valCxt}.${Nt.default.rootData}`),e.dynamicRef&&t.var(Nt.default.dynamicAnchors,(0,pt._)`${Nt.default.valCxt}.${Nt.default.dynamicAnchors}`)},()=>{t.var(Nt.default.instancePath,(0,pt._)`""`),t.var(Nt.default.parentData,(0,pt._)`undefined`),t.var(Nt.default.parentDataProperty,(0,pt._)`undefined`),t.var(Nt.default.rootData,Nt.default.data),e.dynamicRef&&t.var(Nt.default.dynamicAnchors,(0,pt._)`{}`)})}function RKe(t){let{schema:e,opts:r,gen:n}=t;ufe(t,()=>{r.$comment&&e.$comment&&mfe(t),CKe(t),n.let(Nt.default.vErrors,null),n.let(Nt.default.errors,0),r.unevaluated&&DKe(t),pfe(t),NKe(t)})}function DKe(t){let{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",(0,pt._)`${r}.evaluated`),e.if((0,pt._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,pt._)`${t.evaluated}.props`,(0,pt._)`undefined`)),e.if((0,pt._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,pt._)`${t.evaluated}.items`,(0,pt._)`undefined`))}function sfe(t,e){let r=typeof t=="object"&&t[e.schemaId];return r&&(e.code.source||e.code.process)?(0,pt._)`/*# sourceURL=${r} */`:pt.nil}function BKe(t,e){if(ffe(t)&&(hfe(t),lfe(t))){MKe(t,e);return}(0,dfe.boolOrEmptySchema)(t,e)}function lfe({schema:t,self:e}){if(typeof t=="boolean")return!t;for(let r in t)if(e.RULES.all[r])return!0;return!1}function ffe(t){return typeof t.schema!="boolean"}function MKe(t,e){let{schema:r,gen:n,opts:i}=t;i.$comment&&r.$comment&&mfe(t),$Ke(t),jKe(t);let o=n.const("_errs",Nt.default.errors);pfe(t,o),n.var(e,(0,pt._)`${o} === ${Nt.default.errors}`)}function hfe(t){(0,Zh.checkUnknownRules)(t),OKe(t)}function pfe(t,e){if(t.opts.jtd)return afe(t,[],!1,e);let r=(0,ofe.getSchemaTypes)(t.schema),n=(0,ofe.coerceAndCheckDataType)(t,r);afe(t,r,!n,e)}function OKe(t){let{schema:e,errSchemaPath:r,opts:n,self:i}=t;e.$ref&&n.ignoreKeywordsWithRef&&(0,Zh.schemaHasRulesButRef)(e,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function CKe(t){let{schema:e,opts:r}=t;e.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Zh.checkStrictMode)(t,"default is ignored in the schema root")}function $Ke(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,TKe.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function jKe(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function mfe({gen:t,schemaEnv:e,schema:r,errSchemaPath:n,opts:i}){let o=r.$comment;if(i.$comment===!0)t.code((0,pt._)`${Nt.default.self}.logger.log(${o})`);else if(typeof i.$comment=="function"){let s=(0,pt.str)`${n}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,pt._)`${Nt.default.self}.opts.$comment(${o}, ${s}, ${a}.schema)`)}}function NKe(t){let{gen:e,schemaEnv:r,validateName:n,ValidationError:i,opts:o}=t;r.$async?e.if((0,pt._)`${Nt.default.errors} === 0`,()=>e.return(Nt.default.data),()=>e.throw((0,pt._)`new ${i}(${Nt.default.vErrors})`)):(e.assign((0,pt._)`${n}.errors`,Nt.default.vErrors),o.unevaluated&&UKe(t),e.return((0,pt._)`${Nt.default.errors} === 0`))}function UKe({gen:t,evaluated:e,props:r,items:n}){r instanceof pt.Name&&t.assign((0,pt._)`${e}.props`,r),n instanceof pt.Name&&t.assign((0,pt._)`${e}.items`,n)}function afe(t,e,r,n){let{gen:i,schema:o,data:s,allErrors:a,opts:d,self:u}=t,{RULES:c}=u;if(o.$ref&&(d.ignoreKeywordsWithRef||!(0,Zh.schemaHasRulesButRef)(o,c))){i.block(()=>gfe(t,"$ref",c.all.$ref.definition));return}d.jtd||qKe(t,e),i.block(()=>{for(let p of c.rules)l(p);l(c.post)});function l(p){(0,SU.shouldUseGroup)(o,p)&&(p.type?(i.if((0,GP.checkDataType)(p.type,s,d.strictNumbers)),cfe(t,p),e.length===1&&e[0]===p.type&&r&&(i.else(),(0,GP.reportTypeError)(t)),i.endIf()):cfe(t,p),a||i.if((0,pt._)`${Nt.default.errors} === ${n||0}`))}}function cfe(t,e){let{gen:r,schema:n,opts:{useDefaults:i}}=t;i&&(0,AKe.assignDefaults)(t,e.type),r.block(()=>{for(let o of e.rules)(0,SU.shouldUseRule)(n,o)&&gfe(t,o.keyword,o.definition,e.type)})}function qKe(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(LKe(t,e),t.opts.allowUnionTypes||KKe(t,e),FKe(t,t.dataTypes))}function LKe(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{yfe(t.dataTypes,r)||AU(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),WKe(t,e)}}function KKe(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&AU(t,"use allowUnionTypes to allow union type keyword")}function FKe(t,e){let r=t.self.RULES.all;for(let n in r){let i=r[n];if(typeof i=="object"&&(0,SU.shouldUseRule)(t.schema,i)){let{type:o}=i.definition;o.length&&!o.some(s=>zKe(e,s))&&AU(t,`missing type "${o.join(",")}" for keyword "${n}"`)}}}function zKe(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function yfe(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function WKe(t,e){let r=[];for(let n of t.dataTypes)yfe(e,n)?r.push(n):e.includes("integer")&&n==="number"&&r.push("integer");t.dataTypes=r}function AU(t,e){let r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0,Zh.checkStrictMode)(t,e,t.opts.strictTypes)}var JP=class{constructor(e,r,n){if((0,oS.validateKeywordUsage)(e,r,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=r.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Zh.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=r,this.$data)this.schemaCode=e.gen.const("vSchema",vfe(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,oS.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=e.gen.const("_errs",Nt.default.errors))}result(e,r,n){this.failResult((0,pt.not)(e),r,n)}failResult(e,r,n){this.gen.if(e),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,r){this.failResult((0,pt.not)(e),void 0,r)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:r}=this;this.fail((0,pt._)`${r} !== undefined && (${(0,pt.or)(this.invalid$data(),e)})`)}error(e,r,n){if(r){this.setParams(r),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,r){(e?iS.reportExtraError:iS.reportError)(this,this.def.error,r)}$dataError(){(0,iS.reportError)(this,this.def.$dataError||iS.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,iS.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,r){r?Object.assign(this.params,e):this.params=e}block$data(e,r,n=pt.nil){this.gen.block(()=>{this.check$data(e,n),r()})}check$data(e=pt.nil,r=pt.nil){if(!this.$data)return;let{gen:n,schemaCode:i,schemaType:o,def:s}=this;n.if((0,pt.or)((0,pt._)`${i} === undefined`,r)),e!==pt.nil&&n.assign(e,!0),(o.length||s.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==pt.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:r,schemaType:n,def:i,it:o}=this;return(0,pt.or)(s(),a());function s(){if(n.length){if(!(r instanceof pt.Name))throw new Error("ajv implementation error");let d=Array.isArray(n)?n:[n];return(0,pt._)`${(0,GP.checkDataTypes)(d,r,o.opts.strictNumbers,GP.DataType.Wrong)}`}return pt.nil}function a(){if(i.validateSchema){let d=e.scopeValue("validate$data",{ref:i.validateSchema});return(0,pt._)`!${d}(${r})`}return pt.nil}}subschema(e,r){let n=(0,EU.getSubschema)(this.it,e);(0,EU.extendSubschemaData)(n,this.it,e),(0,EU.extendSubschemaMode)(n,e);let i={...this.it,...n,items:void 0,props:void 0};return BKe(i,r),i}mergeEvaluated(e,r){let{it:n,gen:i}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=Zh.mergeEvaluated.props(i,e.props,n.props,r)),n.items!==!0&&e.items!==void 0&&(n.items=Zh.mergeEvaluated.items(i,e.items,n.items,r)))}mergeValidEvaluated(e,r){let{it:n,gen:i}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return i.if(r,()=>this.mergeEvaluated(e,pt.Name)),!0}};yy.KeywordCxt=JP;function gfe(t,e,r,n){let i=new JP(t,r,e);"code"in r?r.code(i,n):i.$data&&r.validate?(0,oS.funcKeywordCode)(i,r):"macro"in r?(0,oS.macroKeywordCode)(i,r):(r.compile||r.validate)&&(0,oS.funcKeywordCode)(i,r)}var HKe=/^\/(?:[^~]|~0|~1)*$/,VKe=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function vfe(t,{dataLevel:e,dataNames:r,dataPathArr:n}){let i,o;if(t==="")return Nt.default.rootData;if(t[0]==="/"){if(!HKe.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);i=t,o=Nt.default.rootData}else{let u=VKe.exec(t);if(!u)throw new Error(`Invalid JSON-pointer: ${t}`);let c=+u[1];if(i=u[2],i==="#"){if(c>=e)throw new Error(d("property/index",c));return n[e-c]}if(c>e)throw new Error(d("data",c));if(o=r[e-c],!i)return o}let s=o,a=i.split("/");for(let u of a)u&&(o=(0,pt._)`${o}${(0,pt.getProperty)((0,Zh.unescapeJsonPointer)(u))}`,s=(0,pt._)`${s} && ${o}`);return s;function d(u,c){return`Cannot access ${u} ${c} levels up, current level is ${e}`}}yy.getData=vfe});var ZP=V(PU=>{"use strict";f();Object.defineProperty(PU,"__esModule",{value:!0});var TU=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};PU.default=TU});var YP=V(RU=>{"use strict";f();Object.defineProperty(RU,"__esModule",{value:!0});var IU=nS(),kU=class extends Error{constructor(e,r,n,i){super(i||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,IU.resolveUrl)(e,r,n),this.missingSchema=(0,IU.normalizeId)((0,IU.getFullPath)(e,this.missingRef))}};RU.default=kU});var aS=V(Hd=>{"use strict";f();Object.defineProperty(Hd,"__esModule",{value:!0});Hd.resolveSchema=Hd.getCompilingSchema=Hd.resolveRef=Hd.compileSchema=Hd.SchemaEnv=void 0;var Yu=rr(),GKe=ZP(),bv=zd(),Xu=nS(),bfe=Rr(),JKe=sS(),l2=class{constructor(e){var r;this.refs={},this.dynamicAnchors={};let n;typeof e.schema=="object"&&(n=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(r=e.baseId)!==null&&r!==void 0?r:(0,Xu.normalizeId)(n?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=n?.$async,this.refs={}}};Hd.SchemaEnv=l2;function BU(t){let e=wfe.call(this,t);if(e)return e;let r=(0,Xu.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:n,lines:i}=this.opts.code,{ownProperties:o}=this.opts,s=new Yu.CodeGen(this.scope,{es5:n,lines:i,ownProperties:o}),a;t.$async&&(a=s.scopeValue("Error",{ref:GKe.default,code:(0,Yu._)`require("ajv/dist/runtime/validation_error").default`}));let d=s.scopeName("validate");t.validateName=d;let u={gen:s,allErrors:this.opts.allErrors,data:bv.default.data,parentData:bv.default.parentData,parentDataProperty:bv.default.parentDataProperty,dataNames:[bv.default.data],dataPathArr:[Yu.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:s.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,Yu.stringify)(t.schema)}:{ref:t.schema}),validateName:d,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:Yu.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,Yu._)`""`,opts:this.opts,self:this},c;try{this._compilations.add(t),(0,JKe.validateFunctionCode)(u),s.optimize(this.opts.code.optimize);let l=s.toString();c=`${s.scopeRefs(bv.default.scope)}return ${l}`,this.opts.code.process&&(c=this.opts.code.process(c,t));let m=new Function(`${bv.default.self}`,`${bv.default.scope}`,c)(this,this.scope.get());if(this.scope.value(d,{ref:m}),m.errors=null,m.schema=t.schema,m.schemaEnv=t,t.$async&&(m.$async=!0),this.opts.code.source===!0&&(m.source={validateName:d,validateCode:l,scopeValues:s._values}),this.opts.unevaluated){let{props:g,items:v}=u;m.evaluated={props:g instanceof Yu.Name?void 0:g,items:v instanceof Yu.Name?void 0:v,dynamicProps:g instanceof Yu.Name,dynamicItems:v instanceof Yu.Name},m.source&&(m.source.evaluated=(0,Yu.stringify)(m.evaluated))}return t.validate=m,t}catch(l){throw delete t.validate,delete t.validateName,c&&this.logger.error("Error compiling schema, function code:",c),l}finally{this._compilations.delete(t)}}Hd.compileSchema=BU;function ZKe(t,e,r){var n;r=(0,Xu.resolveUrl)(this.opts.uriResolver,e,r);let i=t.refs[r];if(i)return i;let o=QKe.call(this,t,r);if(o===void 0){let s=(n=t.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;s&&(o=new l2({schema:s,schemaId:a,root:t,baseId:e}))}if(o!==void 0)return t.refs[r]=YKe.call(this,o)}Hd.resolveRef=ZKe;function YKe(t){return(0,Xu.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:BU.call(this,t)}function wfe(t){for(let e of this._compilations)if(XKe(e,t))return e}Hd.getCompilingSchema=wfe;function XKe(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function QKe(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||XP.call(this,t,e)}function XP(t,e){let r=this.opts.uriResolver.parse(e),n=(0,Xu._getFullPath)(this.opts.uriResolver,r),i=(0,Xu.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&n===i)return DU.call(this,r,t);let o=(0,Xu.normalizeId)(n),s=this.refs[o]||this.schemas[o];if(typeof s=="string"){let a=XP.call(this,t,s);return typeof a?.schema!="object"?void 0:DU.call(this,r,a)}if(typeof s?.schema=="object"){if(s.validate||BU.call(this,s),o===(0,Xu.normalizeId)(e)){let{schema:a}=s,{schemaId:d}=this.opts,u=a[d];return u&&(i=(0,Xu.resolveUrl)(this.opts.uriResolver,i,u)),new l2({schema:a,schemaId:d,root:t,baseId:i})}return DU.call(this,r,s)}}Hd.resolveSchema=XP;var eFe=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function DU(t,{baseId:e,schema:r,root:n}){var i;if(((i=t.fragment)===null||i===void 0?void 0:i[0])!=="/")return;for(let a of t.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let d=r[(0,bfe.unescapeFragment)(a)];if(d===void 0)return;r=d;let u=typeof r=="object"&&r[this.opts.schemaId];!eFe.has(a)&&u&&(e=(0,Xu.resolveUrl)(this.opts.uriResolver,e,u))}let o;if(typeof r!="boolean"&&r.$ref&&!(0,bfe.schemaHasRulesButRef)(r,this.RULES)){let a=(0,Xu.resolveUrl)(this.opts.uriResolver,e,r.$ref);o=XP.call(this,n,a)}let{schemaId:s}=this.opts;if(o=o||new l2({schema:r,schemaId:s,root:n,baseId:e}),o.schema!==o.root.schema)return o}});var _fe=V((O3t,tFe)=>{tFe.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var MU=V((QP,xfe)=>{f();(function(t,e){typeof QP=="object"&&typeof xfe<"u"?e(QP):typeof define=="function"&&define.amd?define(["exports"],e):e(t.URI=t.URI||{})})(QP,function(t){"use strict";function e(){for(var ee=arguments.length,Y=Array(ee),se=0;se1){Y[0]=Y[0].slice(0,-1);for(var ue=Y.length-1,le=1;le= 0x80 (not a basic code point)","invalid-input":"Invalid input"},W=m-g,L=Math.floor,I=String.fromCharCode;function T(ee){throw new RangeError(K[ee])}function B(ee,Y){for(var se=[],ue=ee.length;ue--;)se[ue]=Y(ee[ue]);return se}function h(ee,Y){var se=ee.split("@"),ue="";se.length>1&&(ue=se[0]+"@",ee=se[1]),ee=ee.replace(F,".");var le=ee.split("."),Ne=B(le,Y).join(".");return ue+Ne}function y(ee){for(var Y=[],se=0,ue=ee.length;se=55296&&le<=56319&&se>1,Y+=L(Y/se);Y>W*v>>1;le+=m)Y=L(Y/W);return L(le+(W+1)*Y/(Y+x))},C=function(Y){var se=[],ue=Y.length,le=0,Ne=A,Me=P,Ue=Y.lastIndexOf($);Ue<0&&(Ue=0);for(var Tr=0;Tr=128&&T("not-basic"),se.push(Y.charCodeAt(Tr));for(var Lt=Ue>0?Ue+1:0;Lt=ue&&T("invalid-input");var Hr=E(Y.charCodeAt(Lt++));(Hr>=m||Hr>L((p-le)/Zr))&&T("overflow"),le+=Hr*Zr;var ar=un<=Me?g:un>=Me+v?v:un-Me;if(HrL(p/Yr)&&T("overflow"),Zr*=Yr}var Br=se.length+1;Me=b(le-ft,Br,ft==0),L(le/Br)>p-Ne&&T("overflow"),Ne+=L(le/Br),le%=Br,se.splice(le++,0,Ne)}return String.fromCodePoint.apply(String,se)},N=function(Y){var se=[];Y=y(Y);var ue=Y.length,le=A,Ne=0,Me=P,Ue=!0,Tr=!1,Lt=void 0;try{for(var ft=Y[Symbol.iterator](),Zr;!(Ue=(Zr=ft.next()).done);Ue=!0){var un=Zr.value;un<128&&se.push(I(un))}}catch(w0){Tr=!0,Lt=w0}finally{try{!Ue&&ft.return&&ft.return()}finally{if(Tr)throw Lt}}var Hr=se.length,ar=Hr;for(Hr&&se.push($);ar=le&&AiL((p-Ne)/Li)&&T("overflow"),Ne+=(Yr-le)*Li,le=Yr;var xo=!0,ma=!1,Qo=void 0;try{for(var Ac=Y[Symbol.iterator](),Fp;!(xo=(Fp=Ac.next()).done);xo=!0){var zp=Fp.value;if(zpp&&T("overflow"),zp==le){for(var vl=Ne,Bb=m;;Bb+=m){var Wf=Bb<=Me?g:Bb>=Me+v?v:Bb-Me;if(vl>6|192).toString(16).toUpperCase()+"%"+(Y&63|128).toString(16).toUpperCase():se="%"+(Y>>12|224).toString(16).toUpperCase()+"%"+(Y>>6&63|128).toString(16).toUpperCase()+"%"+(Y&63|128).toString(16).toUpperCase(),se}function H(ee){for(var Y="",se=0,ue=ee.length;se=194&&le<224){if(ue-se>=6){var Ne=parseInt(ee.substr(se+4,2),16);Y+=String.fromCharCode((le&31)<<6|Ne&63)}else Y+=ee.substr(se,6);se+=6}else if(le>=224){if(ue-se>=9){var Me=parseInt(ee.substr(se+4,2),16),Ue=parseInt(ee.substr(se+7,2),16);Y+=String.fromCharCode((le&15)<<12|(Me&63)<<6|Ue&63)}else Y+=ee.substr(se,9);se+=9}else Y+=ee.substr(se,3),se+=3}return Y}function X(ee,Y){function se(ue){var le=H(ue);return le.match(Y.UNRESERVED)?le:ue}return ee.scheme&&(ee.scheme=String(ee.scheme).replace(Y.PCT_ENCODED,se).toLowerCase().replace(Y.NOT_SCHEME,"")),ee.userinfo!==void 0&&(ee.userinfo=String(ee.userinfo).replace(Y.PCT_ENCODED,se).replace(Y.NOT_USERINFO,J).replace(Y.PCT_ENCODED,i)),ee.host!==void 0&&(ee.host=String(ee.host).replace(Y.PCT_ENCODED,se).toLowerCase().replace(Y.NOT_HOST,J).replace(Y.PCT_ENCODED,i)),ee.path!==void 0&&(ee.path=String(ee.path).replace(Y.PCT_ENCODED,se).replace(ee.scheme?Y.NOT_PATH:Y.NOT_PATH_NOSCHEME,J).replace(Y.PCT_ENCODED,i)),ee.query!==void 0&&(ee.query=String(ee.query).replace(Y.PCT_ENCODED,se).replace(Y.NOT_QUERY,J).replace(Y.PCT_ENCODED,i)),ee.fragment!==void 0&&(ee.fragment=String(ee.fragment).replace(Y.PCT_ENCODED,se).replace(Y.NOT_FRAGMENT,J).replace(Y.PCT_ENCODED,i)),ee}function te(ee){return ee.replace(/^0*(.*)/,"$1")||"0"}function ne(ee,Y){var se=ee.match(Y.IPV4ADDRESS)||[],ue=c(se,2),le=ue[1];return le?le.split(".").map(te).join("."):ee}function Q(ee,Y){var se=ee.match(Y.IPV6ADDRESS)||[],ue=c(se,3),le=ue[1],Ne=ue[2];if(le){for(var Me=le.toLowerCase().split("::").reverse(),Ue=c(Me,2),Tr=Ue[0],Lt=Ue[1],ft=Lt?Lt.split(":").map(te):[],Zr=Tr.split(":").map(te),un=Y.IPV4ADDRESS.test(Zr[Zr.length-1]),Hr=un?7:8,ar=Zr.length-Hr,Yr=Array(Hr),Br=0;Br1){var jr=Yr.slice(0,Si.index),Ai=Yr.slice(Si.index+Si.length);qi=jr.join(":")+"::"+Ai.join(":")}else qi=Yr.join(":");return Ne&&(qi+="%"+Ne),qi}else return ee}var re=/^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i,ce="".match(/(){0}/)[1]===void 0;function pe(ee){var Y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},se={},ue=Y.iri!==!1?u:d;Y.reference==="suffix"&&(ee=(Y.scheme?Y.scheme+":":"")+"//"+ee);var le=ee.match(re);if(le){ce?(se.scheme=le[1],se.userinfo=le[3],se.host=le[4],se.port=parseInt(le[5],10),se.path=le[6]||"",se.query=le[7],se.fragment=le[8],isNaN(se.port)&&(se.port=le[5])):(se.scheme=le[1]||void 0,se.userinfo=ee.indexOf("@")!==-1?le[3]:void 0,se.host=ee.indexOf("//")!==-1?le[4]:void 0,se.port=parseInt(le[5],10),se.path=le[6]||"",se.query=ee.indexOf("?")!==-1?le[7]:void 0,se.fragment=ee.indexOf("#")!==-1?le[8]:void 0,isNaN(se.port)&&(se.port=ee.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/)?le[4]:void 0)),se.host&&(se.host=Q(ne(se.host,ue),ue)),se.scheme===void 0&&se.userinfo===void 0&&se.host===void 0&&se.port===void 0&&!se.path&&se.query===void 0?se.reference="same-document":se.scheme===void 0?se.reference="relative":se.fragment===void 0?se.reference="absolute":se.reference="uri",Y.reference&&Y.reference!=="suffix"&&Y.reference!==se.reference&&(se.error=se.error||"URI is not a "+Y.reference+" reference.");var Ne=Z[(Y.scheme||se.scheme||"").toLowerCase()];if(!Y.unicodeSupport&&(!Ne||!Ne.unicodeSupport)){if(se.host&&(Y.domainHost||Ne&&Ne.domainHost))try{se.host=G.toASCII(se.host.replace(ue.PCT_ENCODED,H).toLowerCase())}catch(Me){se.error=se.error||"Host's domain name can not be converted to ASCII via punycode: "+Me}X(se,d)}else X(se,ue);Ne&&Ne.parse&&Ne.parse(se,Y)}else se.error=se.error||"URI can not be parsed.";return se}function ye(ee,Y){var se=Y.iri!==!1?u:d,ue=[];return ee.userinfo!==void 0&&(ue.push(ee.userinfo),ue.push("@")),ee.host!==void 0&&ue.push(Q(ne(String(ee.host),se),se).replace(se.IPV6ADDRESS,function(le,Ne,Me){return"["+Ne+(Me?"%25"+Me:"")+"]"})),(typeof ee.port=="number"||typeof ee.port=="string")&&(ue.push(":"),ue.push(String(ee.port))),ue.length?ue.join(""):void 0}var ie=/^\.\.?\//,he=/^\/\.(\/|$)/,me=/^\/\.\.(\/|$)/,Re=/^\/?(?:.|\n)*?(?=\/|$)/;function xe(ee){for(var Y=[];ee.length;)if(ee.match(ie))ee=ee.replace(ie,"");else if(ee.match(he))ee=ee.replace(he,"/");else if(ee.match(me))ee=ee.replace(me,"/"),Y.pop();else if(ee==="."||ee==="..")ee="";else{var se=ee.match(Re);if(se){var ue=se[0];ee=ee.slice(ue.length),Y.push(ue)}else throw new Error("Unexpected dot segment condition")}return Y.join("")}function it(ee){var Y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},se=Y.iri?u:d,ue=[],le=Z[(Y.scheme||ee.scheme||"").toLowerCase()];if(le&&le.serialize&&le.serialize(ee,Y),ee.host&&!se.IPV6ADDRESS.test(ee.host)){if(Y.domainHost||le&&le.domainHost)try{ee.host=Y.iri?G.toUnicode(ee.host):G.toASCII(ee.host.replace(se.PCT_ENCODED,H).toLowerCase())}catch(Ue){ee.error=ee.error||"Host's domain name can not be converted to "+(Y.iri?"Unicode":"ASCII")+" via punycode: "+Ue}}X(ee,se),Y.reference!=="suffix"&&ee.scheme&&(ue.push(ee.scheme),ue.push(":"));var Ne=ye(ee,Y);if(Ne!==void 0&&(Y.reference!=="suffix"&&ue.push("//"),ue.push(Ne),ee.path&&ee.path.charAt(0)!=="/"&&ue.push("/")),ee.path!==void 0){var Me=ee.path;!Y.absolutePath&&(!le||!le.absolutePath)&&(Me=xe(Me)),Ne===void 0&&(Me=Me.replace(/^\/\//,"/%2F")),ue.push(Me)}return ee.query!==void 0&&(ue.push("?"),ue.push(ee.query)),ee.fragment!==void 0&&(ue.push("#"),ue.push(ee.fragment)),ue.join("")}function Et(ee,Y){var se=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},ue=arguments[3],le={};return ue||(ee=pe(it(ee,se),se),Y=pe(it(Y,se),se)),se=se||{},!se.tolerant&&Y.scheme?(le.scheme=Y.scheme,le.userinfo=Y.userinfo,le.host=Y.host,le.port=Y.port,le.path=xe(Y.path||""),le.query=Y.query):(Y.userinfo!==void 0||Y.host!==void 0||Y.port!==void 0?(le.userinfo=Y.userinfo,le.host=Y.host,le.port=Y.port,le.path=xe(Y.path||""),le.query=Y.query):(Y.path?(Y.path.charAt(0)==="/"?le.path=xe(Y.path):((ee.userinfo!==void 0||ee.host!==void 0||ee.port!==void 0)&&!ee.path?le.path="/"+Y.path:ee.path?le.path=ee.path.slice(0,ee.path.lastIndexOf("/")+1)+Y.path:le.path=Y.path,le.path=xe(le.path)),le.query=Y.query):(le.path=ee.path,Y.query!==void 0?le.query=Y.query:le.query=ee.query),le.userinfo=ee.userinfo,le.host=ee.host,le.port=ee.port),le.scheme=ee.scheme),le.fragment=Y.fragment,le}function Fe(ee,Y,se){var ue=s({scheme:"null"},se);return it(Et(pe(ee,ue),pe(Y,ue),ue,!0),ue)}function mt(ee,Y){return typeof ee=="string"?ee=it(pe(ee,Y),Y):n(ee)==="object"&&(ee=pe(it(ee,Y),Y)),ee}function Sn(ee,Y,se){return typeof ee=="string"?ee=it(pe(ee,se),se):n(ee)==="object"&&(ee=it(ee,se)),typeof Y=="string"?Y=it(pe(Y,se),se):n(Y)==="object"&&(Y=it(Y,se)),ee===Y}function ke(ee,Y){return ee&&ee.toString().replace(!Y||!Y.iri?d.ESCAPE:u.ESCAPE,J)}function Pe(ee,Y){return ee&&ee.toString().replace(!Y||!Y.iri?d.PCT_ENCODED:u.PCT_ENCODED,H)}var Wt={scheme:"http",domainHost:!0,parse:function(Y,se){return Y.host||(Y.error=Y.error||"HTTP URIs must have a host."),Y},serialize:function(Y,se){var ue=String(Y.scheme).toLowerCase()==="https";return(Y.port===(ue?443:80)||Y.port==="")&&(Y.port=void 0),Y.path||(Y.path="/"),Y}},Be={scheme:"https",domainHost:Wt.domainHost,parse:Wt.parse,serialize:Wt.serialize};function Ee(ee){return typeof ee.secure=="boolean"?ee.secure:String(ee.scheme).toLowerCase()==="wss"}var $r={scheme:"ws",domainHost:!0,parse:function(Y,se){var ue=Y;return ue.secure=Ee(ue),ue.resourceName=(ue.path||"/")+(ue.query?"?"+ue.query:""),ue.path=void 0,ue.query=void 0,ue},serialize:function(Y,se){if((Y.port===(Ee(Y)?443:80)||Y.port==="")&&(Y.port=void 0),typeof Y.secure=="boolean"&&(Y.scheme=Y.secure?"wss":"ws",Y.secure=void 0),Y.resourceName){var ue=Y.resourceName.split("?"),le=c(ue,2),Ne=le[0],Me=le[1];Y.path=Ne&&Ne!=="/"?Ne:void 0,Y.query=Me,Y.resourceName=void 0}return Y.fragment=void 0,Y}},Ve={scheme:"wss",domainHost:$r.domainHost,parse:$r.parse,serialize:$r.serialize},Ze={},tn=!0,Rt="[A-Za-z0-9\\-\\.\\_\\~"+(tn?"\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF":"")+"]",Ye="[0-9A-Fa-f]",yd=r(r("%[EFef]"+Ye+"%"+Ye+Ye+"%"+Ye+Ye)+"|"+r("%[89A-Fa-f]"+Ye+"%"+Ye+Ye)+"|"+r("%"+Ye+Ye)),Dt="[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]",Ut="[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]",g0=e(Ut,'[\\"\\\\]'),$t="[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]",Zt=new RegExp(Rt,"g"),gd=new RegExp(yd,"g"),Yt=new RegExp(e("[^]",Dt,"[\\.]",'[\\"]',g0),"g"),Ht=new RegExp(e("[^]",Rt,$t),"g"),v0=Ht;function qt(ee){var Y=H(ee);return Y.match(Zt)?Y:ee}var Vt={scheme:"mailto",parse:function(Y,se){var ue=Y,le=ue.to=ue.path?ue.path.split(","):[];if(ue.path=void 0,ue.query){for(var Ne=!1,Me={},Ue=ue.query.split("&"),Tr=0,Lt=Ue.length;Tr{"use strict";f();Object.defineProperty(OU,"__esModule",{value:!0});var Efe=MU();Efe.code='require("ajv/dist/runtime/uri").default';OU.default=Efe});var Bfe=V(Ss=>{"use strict";f();Object.defineProperty(Ss,"__esModule",{value:!0});Ss.CodeGen=Ss.Name=Ss.nil=Ss.stringify=Ss.str=Ss._=Ss.KeywordCxt=void 0;var rFe=sS();Object.defineProperty(Ss,"KeywordCxt",{enumerable:!0,get:function(){return rFe.KeywordCxt}});var f2=rr();Object.defineProperty(Ss,"_",{enumerable:!0,get:function(){return f2._}});Object.defineProperty(Ss,"str",{enumerable:!0,get:function(){return f2.str}});Object.defineProperty(Ss,"stringify",{enumerable:!0,get:function(){return f2.stringify}});Object.defineProperty(Ss,"nil",{enumerable:!0,get:function(){return f2.nil}});Object.defineProperty(Ss,"Name",{enumerable:!0,get:function(){return f2.Name}});Object.defineProperty(Ss,"CodeGen",{enumerable:!0,get:function(){return f2.CodeGen}});var nFe=ZP(),kfe=YP(),iFe=hU(),cS=aS(),oFe=rr(),dS=nS(),eI=rS(),$U=Rr(),Afe=_fe(),sFe=Sfe(),Rfe=(t,e)=>new RegExp(t,e);Rfe.code="new RegExp";var aFe=["removeAdditional","useDefaults","coerceTypes"],cFe=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),dFe={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},uFe={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},Tfe=200;function lFe(t){var e,r,n,i,o,s,a,d,u,c,l,p,m,g,v,x,S,P,A,$,j,q,F,K,W;let L=t.strict,I=(e=t.code)===null||e===void 0?void 0:e.optimize,T=I===!0||I===void 0?1:I||0,B=(n=(r=t.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:Rfe,h=(i=t.uriResolver)!==null&&i!==void 0?i:sFe.default;return{strictSchema:(s=(o=t.strictSchema)!==null&&o!==void 0?o:L)!==null&&s!==void 0?s:!0,strictNumbers:(d=(a=t.strictNumbers)!==null&&a!==void 0?a:L)!==null&&d!==void 0?d:!0,strictTypes:(c=(u=t.strictTypes)!==null&&u!==void 0?u:L)!==null&&c!==void 0?c:"log",strictTuples:(p=(l=t.strictTuples)!==null&&l!==void 0?l:L)!==null&&p!==void 0?p:"log",strictRequired:(g=(m=t.strictRequired)!==null&&m!==void 0?m:L)!==null&&g!==void 0?g:!1,code:t.code?{...t.code,optimize:T,regExp:B}:{optimize:T,regExp:B},loopRequired:(v=t.loopRequired)!==null&&v!==void 0?v:Tfe,loopEnum:(x=t.loopEnum)!==null&&x!==void 0?x:Tfe,meta:(S=t.meta)!==null&&S!==void 0?S:!0,messages:(P=t.messages)!==null&&P!==void 0?P:!0,inlineRefs:(A=t.inlineRefs)!==null&&A!==void 0?A:!0,schemaId:($=t.schemaId)!==null&&$!==void 0?$:"$id",addUsedSchema:(j=t.addUsedSchema)!==null&&j!==void 0?j:!0,validateSchema:(q=t.validateSchema)!==null&&q!==void 0?q:!0,validateFormats:(F=t.validateFormats)!==null&&F!==void 0?F:!0,unicodeRegExp:(K=t.unicodeRegExp)!==null&&K!==void 0?K:!0,int32range:(W=t.int32range)!==null&&W!==void 0?W:!0,uriResolver:h}}var uS=class{constructor(e={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...lFe(e)};let{es5:r,lines:n}=this.opts.code;this.scope=new oFe.ValueScope({scope:{},prefixes:cFe,es5:r,lines:n}),this.logger=gFe(e.logger);let i=e.validateFormats;e.validateFormats=!1,this.RULES=(0,iFe.getRules)(),Pfe.call(this,dFe,e,"NOT SUPPORTED"),Pfe.call(this,uFe,e,"DEPRECATED","warn"),this._metaOpts=mFe.call(this),e.formats&&hFe.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&pFe.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),fFe.call(this),e.validateFormats=i}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:r,schemaId:n}=this.opts,i=Afe;n==="id"&&(i={...Afe},i.id=i.$id,delete i.$id),r&&e&&this.addMetaSchema(i,i[n],!1)}defaultMeta(){let{meta:e,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof e=="object"?e[r]||e:void 0}validate(e,r){let n;if(typeof e=="string"){if(n=this.getSchema(e),!n)throw new Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let i=n(r);return"$async"in n||(this.errors=n.errors),i}compile(e,r){let n=this._addSchema(e,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return i.call(this,e,r);async function i(c,l){await o.call(this,c.$schema);let p=this._addSchema(c,l);return p.validate||s.call(this,p)}async function o(c){c&&!this.getSchema(c)&&await i.call(this,{$ref:c},!0)}async function s(c){try{return this._compileSchemaEnv(c)}catch(l){if(!(l instanceof kfe.default))throw l;return a.call(this,l),await d.call(this,l.missingSchema),s.call(this,c)}}function a({missingSchema:c,missingRef:l}){if(this.refs[c])throw new Error(`AnySchema ${c} is loaded but ${l} cannot be resolved`)}async function d(c){let l=await u.call(this,c);this.refs[c]||await o.call(this,l.$schema),this.refs[c]||this.addSchema(l,c,r)}async function u(c){let l=this._loading[c];if(l)return l;try{return await(this._loading[c]=n(c))}finally{delete this._loading[c]}}}addSchema(e,r,n,i=this.opts.validateSchema){if(Array.isArray(e)){for(let s of e)this.addSchema(s,void 0,n,i);return this}let o;if(typeof e=="object"){let{schemaId:s}=this.opts;if(o=e[s],o!==void 0&&typeof o!="string")throw new Error(`schema ${s} must be string`)}return r=(0,dS.normalizeId)(r||o),this._checkUnique(r),this.schemas[r]=this._addSchema(e,n,r,i,!0),this}addMetaSchema(e,r,n=this.opts.validateSchema){return this.addSchema(e,r,!0,n),this}validateSchema(e,r){if(typeof e=="boolean")return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let i=this.validate(n,e);if(!i&&r){let o="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(o);else throw new Error(o)}return i}getSchema(e){let r;for(;typeof(r=Ife.call(this,e))=="string";)e=r;if(r===void 0){let{schemaId:n}=this.opts,i=new cS.SchemaEnv({schema:{},schemaId:n});if(r=cS.resolveSchema.call(this,i,e),!r)return;this.refs[e]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=Ife.call(this,e);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{let r=e;this._cache.delete(r);let n=e[this.opts.schemaId];return n&&(n=(0,dS.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(let r of e)this.addKeyword(r);return this}addKeyword(e,r){let n;if(typeof e=="string")n=e,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof e=="object"&&r===void 0){if(r=e,n=r.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(bFe.call(this,n,r),!r)return(0,$U.eachItem)(n,o=>CU.call(this,o)),this;_Fe.call(this,r);let i={...r,type:(0,eI.getJSONTypes)(r.type),schemaType:(0,eI.getJSONTypes)(r.schemaType)};return(0,$U.eachItem)(n,i.type.length===0?o=>CU.call(this,o,i):o=>i.type.forEach(s=>CU.call(this,o,i,s))),this}getKeyword(e){let r=this.RULES.all[e];return typeof r=="object"?r.definition:!!r}removeKeyword(e){let{RULES:r}=this;delete r.keywords[e],delete r.all[e];for(let n of r.rules){let i=n.rules.findIndex(o=>o.keyword===e);i>=0&&n.rules.splice(i,1)}return this}addFormat(e,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[e]=r,this}errorsText(e=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!e||e.length===0?"No errors":e.map(i=>`${n}${i.instancePath} ${i.message}`).reduce((i,o)=>i+r+o)}$dataMetaSchema(e,r){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let i of r){let o=i.split("/").slice(1),s=e;for(let a of o)s=s[a];for(let a in n){let d=n[a];if(typeof d!="object")continue;let{$data:u}=d.definition,c=s[a];u&&c&&(s[a]=Dfe(c))}}return e}_removeAllSchemas(e,r){for(let n in e){let i=e[n];(!r||r.test(n))&&(typeof i=="string"?delete e[n]:i&&!i.meta&&(this._cache.delete(i.schema),delete e[n]))}}_addSchema(e,r,n,i=this.opts.validateSchema,o=this.opts.addUsedSchema){let s,{schemaId:a}=this.opts;if(typeof e=="object")s=e[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof e!="boolean")throw new Error("schema must be object or boolean")}let d=this._cache.get(e);if(d!==void 0)return d;n=(0,dS.normalizeId)(s||n);let u=dS.getSchemaRefs.call(this,e,n);return d=new cS.SchemaEnv({schema:e,schemaId:a,meta:r,baseId:n,localRefs:u}),this._cache.set(d.schema,d),o&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=d),i&&this.validateSchema(e,!0),d}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):cS.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){let r=this.opts;this.opts=this._metaOpts;try{cS.compileSchema.call(this,e)}finally{this.opts=r}}};Ss.default=uS;uS.ValidationError=nFe.default;uS.MissingRefError=kfe.default;function Pfe(t,e,r,n="error"){for(let i in t){let o=i;o in e&&this.logger[n](`${r}: option ${i}. ${t[o]}`)}}function Ife(t){return t=(0,dS.normalizeId)(t),this.schemas[t]||this.refs[t]}function fFe(){let t=this.opts.schemas;if(t)if(Array.isArray(t))this.addSchema(t);else for(let e in t)this.addSchema(t[e],e)}function hFe(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function pFe(t){if(Array.isArray(t)){this.addVocabulary(t);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let e in t){let r=t[e];r.keyword||(r.keyword=e),this.addKeyword(r)}}function mFe(){let t={...this.opts};for(let e of aFe)delete t[e];return t}var yFe={log(){},warn(){},error(){}};function gFe(t){if(t===!1)return yFe;if(t===void 0)return console;if(t.log&&t.warn&&t.error)return t;throw new Error("logger must implement log, warn and error methods")}var vFe=/^[a-z_$][a-z0-9_$:-]*$/i;function bFe(t,e){let{RULES:r}=this;if((0,$U.eachItem)(t,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!vFe.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!e&&e.$data&&!("code"in e||"validate"in e))throw new Error('$data keyword must have "code" or "validate" function')}function CU(t,e,r){var n;let i=e?.post;if(r&&i)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:o}=this,s=i?o.post:o.rules.find(({type:d})=>d===r);if(s||(s={type:r,rules:[]},o.rules.push(s)),o.keywords[t]=!0,!e)return;let a={keyword:t,definition:{...e,type:(0,eI.getJSONTypes)(e.type),schemaType:(0,eI.getJSONTypes)(e.schemaType)}};e.before?wFe.call(this,s,a,e.before):s.rules.push(a),o.all[t]=a,(n=e.implements)===null||n===void 0||n.forEach(d=>this.addKeyword(d))}function wFe(t,e,r){let n=t.rules.findIndex(i=>i.keyword===r);n>=0?t.rules.splice(n,0,e):(t.rules.push(e),this.logger.warn(`rule ${r} is not defined`))}function _Fe(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=Dfe(e)),t.validateSchema=this.compile(e,!0))}var xFe={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Dfe(t){return{anyOf:[t,xFe]}}});var Mfe=V(jU=>{"use strict";f();Object.defineProperty(jU,"__esModule",{value:!0});var EFe={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};jU.default=EFe});var nI=V(wv=>{"use strict";f();Object.defineProperty(wv,"__esModule",{value:!0});wv.callRef=wv.getValidate=void 0;var SFe=YP(),Ofe=Wd(),uc=rr(),h2=zd(),Cfe=aS(),tI=Rr(),AFe={keyword:"$ref",schemaType:"string",code(t){let{gen:e,schema:r,it:n}=t,{baseId:i,schemaEnv:o,validateName:s,opts:a,self:d}=n,{root:u}=o;if((r==="#"||r==="#/")&&i===u.baseId)return l();let c=Cfe.resolveRef.call(d,u,i,r);if(c===void 0)throw new SFe.default(n.opts.uriResolver,i,r);if(c instanceof Cfe.SchemaEnv)return p(c);return m(c);function l(){if(o===u)return rI(t,s,o,o.$async);let g=e.scopeValue("root",{ref:u});return rI(t,(0,uc._)`${g}.validate`,u,u.$async)}function p(g){let v=$fe(t,g);rI(t,v,g,g.$async)}function m(g){let v=e.scopeValue("schema",a.code.source===!0?{ref:g,code:(0,uc.stringify)(g)}:{ref:g}),x=e.name("valid"),S=t.subschema({schema:g,dataTypes:[],schemaPath:uc.nil,topSchemaRef:v,errSchemaPath:r},x);t.mergeEvaluated(S),t.ok(x)}}};function $fe(t,e){let{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0,uc._)`${r.scopeValue("wrapper",{ref:e})}.validate`}wv.getValidate=$fe;function rI(t,e,r,n){let{gen:i,it:o}=t,{allErrors:s,schemaEnv:a,opts:d}=o,u=d.passContext?h2.default.this:uc.nil;n?c():l();function c(){if(!a.$async)throw new Error("async schema referenced by sync schema");let g=i.let("valid");i.try(()=>{i.code((0,uc._)`await ${(0,Ofe.callValidateCode)(t,e,u)}`),m(e),s||i.assign(g,!0)},v=>{i.if((0,uc._)`!(${v} instanceof ${o.ValidationError})`,()=>i.throw(v)),p(v),s||i.assign(g,!1)}),t.ok(g)}function l(){t.result((0,Ofe.callValidateCode)(t,e,u),()=>m(e),()=>p(e))}function p(g){let v=(0,uc._)`${g}.errors`;i.assign(h2.default.vErrors,(0,uc._)`${h2.default.vErrors} === null ? ${v} : ${h2.default.vErrors}.concat(${v})`),i.assign(h2.default.errors,(0,uc._)`${h2.default.vErrors}.length`)}function m(g){var v;if(!o.opts.unevaluated)return;let x=(v=r?.validate)===null||v===void 0?void 0:v.evaluated;if(o.props!==!0)if(x&&!x.dynamicProps)x.props!==void 0&&(o.props=tI.mergeEvaluated.props(i,x.props,o.props));else{let S=i.var("props",(0,uc._)`${g}.evaluated.props`);o.props=tI.mergeEvaluated.props(i,S,o.props,uc.Name)}if(o.items!==!0)if(x&&!x.dynamicItems)x.items!==void 0&&(o.items=tI.mergeEvaluated.items(i,x.items,o.items));else{let S=i.var("items",(0,uc._)`${g}.evaluated.items`);o.items=tI.mergeEvaluated.items(i,S,o.items,uc.Name)}}}wv.callRef=rI;wv.default=AFe});var jfe=V(NU=>{"use strict";f();Object.defineProperty(NU,"__esModule",{value:!0});var TFe=Mfe(),PFe=nI(),IFe=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",TFe.default,PFe.default];NU.default=IFe});var Nfe=V(UU=>{"use strict";f();Object.defineProperty(UU,"__esModule",{value:!0});var iI=rr(),gy=iI.operators,oI={maximum:{okStr:"<=",ok:gy.LTE,fail:gy.GT},minimum:{okStr:">=",ok:gy.GTE,fail:gy.LT},exclusiveMaximum:{okStr:"<",ok:gy.LT,fail:gy.GTE},exclusiveMinimum:{okStr:">",ok:gy.GT,fail:gy.LTE}},kFe={message:({keyword:t,schemaCode:e})=>(0,iI.str)`must be ${oI[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,iI._)`{comparison: ${oI[t].okStr}, limit: ${e}}`},RFe={keyword:Object.keys(oI),type:"number",schemaType:"number",$data:!0,error:kFe,code(t){let{keyword:e,data:r,schemaCode:n}=t;t.fail$data((0,iI._)`${r} ${oI[e].fail} ${n} || isNaN(${r})`)}};UU.default=RFe});var Ufe=V(qU=>{"use strict";f();Object.defineProperty(qU,"__esModule",{value:!0});var lS=rr(),DFe={message:({schemaCode:t})=>(0,lS.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,lS._)`{multipleOf: ${t}}`},BFe={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:DFe,code(t){let{gen:e,data:r,schemaCode:n,it:i}=t,o=i.opts.multipleOfPrecision,s=e.let("res"),a=o?(0,lS._)`Math.abs(Math.round(${s}) - ${s}) > 1e-${o}`:(0,lS._)`${s} !== parseInt(${s})`;t.fail$data((0,lS._)`(${n} === 0 || (${s} = ${r}/${n}, ${a}))`)}};qU.default=BFe});var Lfe=V(LU=>{"use strict";f();Object.defineProperty(LU,"__esModule",{value:!0});function qfe(t){let e=t.length,r=0,n=0,i;for(;n=55296&&i<=56319&&n{"use strict";f();Object.defineProperty(KU,"__esModule",{value:!0});var _v=rr(),MFe=Rr(),OFe=Lfe(),CFe={message({keyword:t,schemaCode:e}){let r=t==="maxLength"?"more":"fewer";return(0,_v.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0,_v._)`{limit: ${t}}`},$Fe={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:CFe,code(t){let{keyword:e,data:r,schemaCode:n,it:i}=t,o=e==="maxLength"?_v.operators.GT:_v.operators.LT,s=i.opts.unicode===!1?(0,_v._)`${r}.length`:(0,_v._)`${(0,MFe.useFunc)(t.gen,OFe.default)}(${r})`;t.fail$data((0,_v._)`${s} ${o} ${n}`)}};KU.default=$Fe});var Ffe=V(FU=>{"use strict";f();Object.defineProperty(FU,"__esModule",{value:!0});var jFe=Wd(),sI=rr(),NFe={message:({schemaCode:t})=>(0,sI.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,sI._)`{pattern: ${t}}`},UFe={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:NFe,code(t){let{data:e,$data:r,schema:n,schemaCode:i,it:o}=t,s=o.opts.unicodeRegExp?"u":"",a=r?(0,sI._)`(new RegExp(${i}, ${s}))`:(0,jFe.usePattern)(t,n);t.fail$data((0,sI._)`!${a}.test(${e})`)}};FU.default=UFe});var zfe=V(zU=>{"use strict";f();Object.defineProperty(zU,"__esModule",{value:!0});var fS=rr(),qFe={message({keyword:t,schemaCode:e}){let r=t==="maxProperties"?"more":"fewer";return(0,fS.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0,fS._)`{limit: ${t}}`},LFe={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:qFe,code(t){let{keyword:e,data:r,schemaCode:n}=t,i=e==="maxProperties"?fS.operators.GT:fS.operators.LT;t.fail$data((0,fS._)`Object.keys(${r}).length ${i} ${n}`)}};zU.default=LFe});var Wfe=V(WU=>{"use strict";f();Object.defineProperty(WU,"__esModule",{value:!0});var hS=Wd(),pS=rr(),KFe=Rr(),FFe={message:({params:{missingProperty:t}})=>(0,pS.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,pS._)`{missingProperty: ${t}}`},zFe={keyword:"required",type:"object",schemaType:"array",$data:!0,error:FFe,code(t){let{gen:e,schema:r,schemaCode:n,data:i,$data:o,it:s}=t,{opts:a}=s;if(!o&&r.length===0)return;let d=r.length>=a.loopRequired;if(s.allErrors?u():c(),a.strictRequired){let m=t.parentSchema.properties,{definedProperties:g}=t.it;for(let v of r)if(m?.[v]===void 0&&!g.has(v)){let x=s.schemaEnv.baseId+s.errSchemaPath,S=`required property "${v}" is not defined at "${x}" (strictRequired)`;(0,KFe.checkStrictMode)(s,S,s.opts.strictRequired)}}function u(){if(d||o)t.block$data(pS.nil,l);else for(let m of r)(0,hS.checkReportMissingProp)(t,m)}function c(){let m=e.let("missing");if(d||o){let g=e.let("valid",!0);t.block$data(g,()=>p(m,g)),t.ok(g)}else e.if((0,hS.checkMissingProp)(t,r,m)),(0,hS.reportMissingProp)(t,m),e.else()}function l(){e.forOf("prop",n,m=>{t.setParams({missingProperty:m}),e.if((0,hS.noPropertyInData)(e,i,m,a.ownProperties),()=>t.error())})}function p(m,g){t.setParams({missingProperty:m}),e.forOf(m,n,()=>{e.assign(g,(0,hS.propertyInData)(e,i,m,a.ownProperties)),e.if((0,pS.not)(g),()=>{t.error(),e.break()})},pS.nil)}}};WU.default=zFe});var Hfe=V(HU=>{"use strict";f();Object.defineProperty(HU,"__esModule",{value:!0});var mS=rr(),WFe={message({keyword:t,schemaCode:e}){let r=t==="maxItems"?"more":"fewer";return(0,mS.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0,mS._)`{limit: ${t}}`},HFe={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:WFe,code(t){let{keyword:e,data:r,schemaCode:n}=t,i=e==="maxItems"?mS.operators.GT:mS.operators.LT;t.fail$data((0,mS._)`${r}.length ${i} ${n}`)}};HU.default=HFe});var aI=V(VU=>{"use strict";f();Object.defineProperty(VU,"__esModule",{value:!0});var Vfe=_U();Vfe.code='require("ajv/dist/runtime/equal").default';VU.default=Vfe});var Gfe=V(JU=>{"use strict";f();Object.defineProperty(JU,"__esModule",{value:!0});var GU=rS(),As=rr(),VFe=Rr(),GFe=aI(),JFe={message:({params:{i:t,j:e}})=>(0,As.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,As._)`{i: ${t}, j: ${e}}`},ZFe={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:JFe,code(t){let{gen:e,data:r,$data:n,schema:i,parentSchema:o,schemaCode:s,it:a}=t;if(!n&&!i)return;let d=e.let("valid"),u=o.items?(0,GU.getSchemaTypes)(o.items):[];t.block$data(d,c,(0,As._)`${s} === false`),t.ok(d);function c(){let g=e.let("i",(0,As._)`${r}.length`),v=e.let("j");t.setParams({i:g,j:v}),e.assign(d,!0),e.if((0,As._)`${g} > 1`,()=>(l()?p:m)(g,v))}function l(){return u.length>0&&!u.some(g=>g==="object"||g==="array")}function p(g,v){let x=e.name("item"),S=(0,GU.checkDataTypes)(u,x,a.opts.strictNumbers,GU.DataType.Wrong),P=e.const("indices",(0,As._)`{}`);e.for((0,As._)`;${g}--;`,()=>{e.let(x,(0,As._)`${r}[${g}]`),e.if(S,(0,As._)`continue`),u.length>1&&e.if((0,As._)`typeof ${x} == "string"`,(0,As._)`${x} += "_"`),e.if((0,As._)`typeof ${P}[${x}] == "number"`,()=>{e.assign(v,(0,As._)`${P}[${x}]`),t.error(),e.assign(d,!1).break()}).code((0,As._)`${P}[${x}] = ${g}`)})}function m(g,v){let x=(0,VFe.useFunc)(e,GFe.default),S=e.name("outer");e.label(S).for((0,As._)`;${g}--;`,()=>e.for((0,As._)`${v} = ${g}; ${v}--;`,()=>e.if((0,As._)`${x}(${r}[${g}], ${r}[${v}])`,()=>{t.error(),e.assign(d,!1).break(S)})))}}};JU.default=ZFe});var Jfe=V(YU=>{"use strict";f();Object.defineProperty(YU,"__esModule",{value:!0});var ZU=rr(),YFe=Rr(),XFe=aI(),QFe={message:"must be equal to constant",params:({schemaCode:t})=>(0,ZU._)`{allowedValue: ${t}}`},eze={keyword:"const",$data:!0,error:QFe,code(t){let{gen:e,data:r,$data:n,schemaCode:i,schema:o}=t;n||o&&typeof o=="object"?t.fail$data((0,ZU._)`!${(0,YFe.useFunc)(e,XFe.default)}(${r}, ${i})`):t.fail((0,ZU._)`${o} !== ${r}`)}};YU.default=eze});var Zfe=V(XU=>{"use strict";f();Object.defineProperty(XU,"__esModule",{value:!0});var yS=rr(),tze=Rr(),rze=aI(),nze={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,yS._)`{allowedValues: ${t}}`},ize={keyword:"enum",schemaType:"array",$data:!0,error:nze,code(t){let{gen:e,data:r,$data:n,schema:i,schemaCode:o,it:s}=t;if(!n&&i.length===0)throw new Error("enum must have non-empty array");let a=i.length>=s.opts.loopEnum,d,u=()=>d??(d=(0,tze.useFunc)(e,rze.default)),c;if(a||n)c=e.let("valid"),t.block$data(c,l);else{if(!Array.isArray(i))throw new Error("ajv implementation error");let m=e.const("vSchema",o);c=(0,yS.or)(...i.map((g,v)=>p(m,v)))}t.pass(c);function l(){e.assign(c,!1),e.forOf("v",o,m=>e.if((0,yS._)`${u()}(${r}, ${m})`,()=>e.assign(c,!0).break()))}function p(m,g){let v=i[g];return typeof v=="object"&&v!==null?(0,yS._)`${u()}(${r}, ${m}[${g}])`:(0,yS._)`${r} === ${v}`}}};XU.default=ize});var Yfe=V(QU=>{"use strict";f();Object.defineProperty(QU,"__esModule",{value:!0});var oze=Nfe(),sze=Ufe(),aze=Kfe(),cze=Ffe(),dze=zfe(),uze=Wfe(),lze=Hfe(),fze=Gfe(),hze=Jfe(),pze=Zfe(),mze=[oze.default,sze.default,aze.default,cze.default,dze.default,uze.default,lze.default,fze.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},hze.default,pze.default];QU.default=mze});var tq=V(gS=>{"use strict";f();Object.defineProperty(gS,"__esModule",{value:!0});gS.validateAdditionalItems=void 0;var xv=rr(),eq=Rr(),yze={message:({params:{len:t}})=>(0,xv.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,xv._)`{limit: ${t}}`},gze={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:yze,code(t){let{parentSchema:e,it:r}=t,{items:n}=e;if(!Array.isArray(n)){(0,eq.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}Xfe(t,n)}};function Xfe(t,e){let{gen:r,schema:n,data:i,keyword:o,it:s}=t;s.items=!0;let a=r.const("len",(0,xv._)`${i}.length`);if(n===!1)t.setParams({len:e.length}),t.pass((0,xv._)`${a} <= ${e.length}`);else if(typeof n=="object"&&!(0,eq.alwaysValidSchema)(s,n)){let u=r.var("valid",(0,xv._)`${a} <= ${e.length}`);r.if((0,xv.not)(u),()=>d(u)),t.ok(u)}function d(u){r.forRange("i",e.length,a,c=>{t.subschema({keyword:o,dataProp:c,dataPropType:eq.Type.Num},u),s.allErrors||r.if((0,xv.not)(u),()=>r.break())})}}gS.validateAdditionalItems=Xfe;gS.default=gze});var rq=V(vS=>{"use strict";f();Object.defineProperty(vS,"__esModule",{value:!0});vS.validateTuple=void 0;var Qfe=rr(),cI=Rr(),vze=Wd(),bze={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:r}=t;if(Array.isArray(e))return ehe(t,"additionalItems",e);r.items=!0,!(0,cI.alwaysValidSchema)(r,e)&&t.ok((0,vze.validateArray)(t))}};function ehe(t,e,r=t.schema){let{gen:n,parentSchema:i,data:o,keyword:s,it:a}=t;c(i),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=cI.mergeEvaluated.items(n,r.length,a.items));let d=n.name("valid"),u=n.const("len",(0,Qfe._)`${o}.length`);r.forEach((l,p)=>{(0,cI.alwaysValidSchema)(a,l)||(n.if((0,Qfe._)`${u} > ${p}`,()=>t.subschema({keyword:s,schemaProp:p,dataProp:p},d)),t.ok(d))});function c(l){let{opts:p,errSchemaPath:m}=a,g=r.length,v=g===l.minItems&&(g===l.maxItems||l[e]===!1);if(p.strictTuples&&!v){let x=`"${s}" is ${g}-tuple, but minItems or maxItems/${e} are not specified or different at path "${m}"`;(0,cI.checkStrictMode)(a,x,p.strictTuples)}}}vS.validateTuple=ehe;vS.default=bze});var the=V(nq=>{"use strict";f();Object.defineProperty(nq,"__esModule",{value:!0});var wze=rq(),_ze={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,wze.validateTuple)(t,"items")};nq.default=_ze});var nhe=V(iq=>{"use strict";f();Object.defineProperty(iq,"__esModule",{value:!0});var rhe=rr(),xze=Rr(),Eze=Wd(),Sze=tq(),Aze={message:({params:{len:t}})=>(0,rhe.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,rhe._)`{limit: ${t}}`},Tze={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:Aze,code(t){let{schema:e,parentSchema:r,it:n}=t,{prefixItems:i}=r;n.items=!0,!(0,xze.alwaysValidSchema)(n,e)&&(i?(0,Sze.validateAdditionalItems)(t,i):t.ok((0,Eze.validateArray)(t)))}};iq.default=Tze});var ihe=V(oq=>{"use strict";f();Object.defineProperty(oq,"__esModule",{value:!0});var Vd=rr(),dI=Rr(),Pze={message:({params:{min:t,max:e}})=>e===void 0?(0,Vd.str)`must contain at least ${t} valid item(s)`:(0,Vd.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,Vd._)`{minContains: ${t}}`:(0,Vd._)`{minContains: ${t}, maxContains: ${e}}`},Ize={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:Pze,code(t){let{gen:e,schema:r,parentSchema:n,data:i,it:o}=t,s,a,{minContains:d,maxContains:u}=n;o.opts.next?(s=d===void 0?1:d,a=u):s=1;let c=e.const("len",(0,Vd._)`${i}.length`);if(t.setParams({min:s,max:a}),a===void 0&&s===0){(0,dI.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&s>a){(0,dI.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,dI.alwaysValidSchema)(o,r)){let v=(0,Vd._)`${c} >= ${s}`;a!==void 0&&(v=(0,Vd._)`${v} && ${c} <= ${a}`),t.pass(v);return}o.items=!0;let l=e.name("valid");a===void 0&&s===1?m(l,()=>e.if(l,()=>e.break())):s===0?(e.let(l,!0),a!==void 0&&e.if((0,Vd._)`${i}.length > 0`,p)):(e.let(l,!1),p()),t.result(l,()=>t.reset());function p(){let v=e.name("_valid"),x=e.let("count",0);m(v,()=>e.if(v,()=>g(x)))}function m(v,x){e.forRange("i",0,c,S=>{t.subschema({keyword:"contains",dataProp:S,dataPropType:dI.Type.Num,compositeRule:!0},v),x()})}function g(v){e.code((0,Vd._)`${v}++`),a===void 0?e.if((0,Vd._)`${v} >= ${s}`,()=>e.assign(l,!0).break()):(e.if((0,Vd._)`${v} > ${a}`,()=>e.assign(l,!1).break()),s===1?e.assign(l,!0):e.if((0,Vd._)`${v} >= ${s}`,()=>e.assign(l,!0)))}}};oq.default=Ize});var uI=V(gf=>{"use strict";f();Object.defineProperty(gf,"__esModule",{value:!0});gf.validateSchemaDeps=gf.validatePropertyDeps=gf.error=void 0;var sq=rr(),kze=Rr(),bS=Wd();gf.error={message:({params:{property:t,depsCount:e,deps:r}})=>{let n=e===1?"property":"properties";return(0,sq.str)`must have ${n} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:n}})=>(0,sq._)`{property: ${t}, missingProperty: ${n}, depsCount: ${e}, - deps: ${r}}`};var Eze={keyword:"dependencies",type:"object",schemaType:"object",error:yf.error,code(t){let[e,r]=Sze(t);Qfe(t,e),ehe(t,r)}};function Sze({schema:t}){let e={},r={};for(let n in t){if(n==="__proto__")continue;let i=Array.isArray(t[n])?e:r;i[n]=t[n]}return[e,r]}function Qfe(t,e=t.schema){let{gen:r,data:n,it:i}=t;if(Object.keys(e).length===0)return;let o=r.let("missing");for(let s in e){let a=e[s];if(a.length===0)continue;let d=(0,yS.propertyInData)(r,n,s,i.opts.ownProperties);t.setParams({property:s,depsCount:a.length,deps:a.join(", ")}),i.allErrors?r.if(d,()=>{for(let u of a)(0,yS.checkReportMissingProp)(t,u)}):(r.if((0,tq._)`${d} && (${(0,yS.checkMissingProp)(t,a,o)})`),(0,yS.reportMissingProp)(t,o),r.else())}}yf.validatePropertyDeps=Qfe;function ehe(t,e=t.schema){let{gen:r,data:n,keyword:i,it:o}=t,s=r.name("valid");for(let a in e)(0,xze.alwaysValidSchema)(o,e[a])||(r.if((0,yS.propertyInData)(r,n,a,o.opts.ownProperties),()=>{let d=t.subschema({keyword:i,schemaProp:a},s);t.mergeValidEvaluated(d,s)},()=>r.var(s,!0)),t.ok(s))}yf.validateSchemaDeps=ehe;yf.default=Eze});var rhe=V(rq=>{"use strict";f();Object.defineProperty(rq,"__esModule",{value:!0});var the=rr(),Aze=Rr(),Tze={message:"property name must be valid",params:({params:t})=>(0,the._)`{propertyName: ${t.propertyName}}`},Pze={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:Tze,code(t){let{gen:e,schema:r,data:n,it:i}=t;if((0,Aze.alwaysValidSchema)(i,r))return;let o=e.name("valid");e.forIn("key",n,s=>{t.setParams({propertyName:s}),t.subschema({keyword:"propertyNames",data:s,dataTypes:["string"],propertyName:s,compositeRule:!0},o),e.if((0,the.not)(o),()=>{t.error(!0),i.allErrors||e.break()})}),t.ok(o)}};rq.default=Pze});var iq=V(nq=>{"use strict";f();Object.defineProperty(nq,"__esModule",{value:!0});var sI=Fd(),Xu=rr(),Ize=Kd(),aI=Rr(),kze={message:"must NOT have additional properties",params:({params:t})=>(0,Xu._)`{additionalProperty: ${t.additionalProperty}}`},Rze={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:kze,code(t){let{gen:e,schema:r,parentSchema:n,data:i,errsCount:o,it:s}=t;if(!o)throw new Error("ajv implementation error");let{allErrors:a,opts:d}=s;if(s.props=!0,d.removeAdditional!=="all"&&(0,aI.alwaysValidSchema)(s,r))return;let u=(0,sI.allSchemaProperties)(n.properties),c=(0,sI.allSchemaProperties)(n.patternProperties);l(),t.ok((0,Xu._)`${o} === ${Ize.default.errors}`);function l(){e.forIn("key",i,x=>{!u.length&&!c.length?g(x):e.if(p(x),()=>g(x))})}function p(x){let S;if(u.length>8){let P=(0,aI.schemaRefOrVal)(s,n.properties,"properties");S=(0,sI.isOwnProperty)(e,P,x)}else u.length?S=(0,Xu.or)(...u.map(P=>(0,Xu._)`${x} === ${P}`)):S=Xu.nil;return c.length&&(S=(0,Xu.or)(S,...c.map(P=>(0,Xu._)`${(0,sI.usePattern)(t,P)}.test(${x})`))),(0,Xu.not)(S)}function m(x){e.code((0,Xu._)`delete ${i}[${x}]`)}function g(x){if(d.removeAdditional==="all"||d.removeAdditional&&r===!1){m(x);return}if(r===!1){t.setParams({additionalProperty:x}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,aI.alwaysValidSchema)(s,r)){let S=e.name("valid");d.removeAdditional==="failing"?(v(x,S,!1),e.if((0,Xu.not)(S),()=>{t.reset(),m(x)})):(v(x,S),a||e.if((0,Xu.not)(S),()=>e.break()))}}function v(x,S,P){let A={keyword:"additionalProperties",dataProp:x,dataPropType:aI.Type.Str};P===!1&&Object.assign(A,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(A,S)}}};nq.default=Rze});var ohe=V(sq=>{"use strict";f();Object.defineProperty(sq,"__esModule",{value:!0});var Dze=nS(),nhe=Fd(),oq=Rr(),ihe=iq(),Bze={keyword:"properties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,parentSchema:n,data:i,it:o}=t;o.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&ihe.default.code(new Dze.KeywordCxt(o,ihe.default,"additionalProperties"));let s=(0,nhe.allSchemaProperties)(r);for(let l of s)o.definedProperties.add(l);o.opts.unevaluated&&s.length&&o.props!==!0&&(o.props=oq.mergeEvaluated.props(e,(0,oq.toHash)(s),o.props));let a=s.filter(l=>!(0,oq.alwaysValidSchema)(o,r[l]));if(a.length===0)return;let d=e.name("valid");for(let l of a)u(l)?c(l):(e.if((0,nhe.propertyInData)(e,i,l,o.opts.ownProperties)),c(l),o.allErrors||e.else().var(d,!0),e.endIf()),t.it.definedProperties.add(l),t.ok(d);function u(l){return o.opts.useDefaults&&!o.compositeRule&&r[l].default!==void 0}function c(l){t.subschema({keyword:"properties",schemaProp:l,dataProp:l},d)}}};sq.default=Bze});var dhe=V(aq=>{"use strict";f();Object.defineProperty(aq,"__esModule",{value:!0});var she=Fd(),cI=rr(),ahe=Rr(),che=Rr(),Mze={keyword:"patternProperties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,data:n,parentSchema:i,it:o}=t,{opts:s}=o,a=(0,she.allSchemaProperties)(r),d=a.filter(v=>(0,ahe.alwaysValidSchema)(o,r[v]));if(a.length===0||d.length===a.length&&(!o.opts.unevaluated||o.props===!0))return;let u=s.strictSchema&&!s.allowMatchingProperties&&i.properties,c=e.name("valid");o.props!==!0&&!(o.props instanceof cI.Name)&&(o.props=(0,che.evaluatedPropsToName)(e,o.props));let{props:l}=o;p();function p(){for(let v of a)u&&m(v),o.allErrors?g(v):(e.var(c,!0),g(v),e.if(c))}function m(v){for(let x in u)new RegExp(v).test(x)&&(0,ahe.checkStrictMode)(o,`property ${x} matches pattern ${v} (use allowMatchingProperties)`)}function g(v){e.forIn("key",n,x=>{e.if((0,cI._)`${(0,she.usePattern)(t,v)}.test(${x})`,()=>{let S=d.includes(v);S||t.subschema({keyword:"patternProperties",schemaProp:v,dataProp:x,dataPropType:che.Type.Str},c),o.opts.unevaluated&&l!==!0?e.assign((0,cI._)`${l}[${x}]`,!0):!S&&!o.allErrors&&e.if((0,cI.not)(c),()=>e.break())})})}}};aq.default=Mze});var uhe=V(cq=>{"use strict";f();Object.defineProperty(cq,"__esModule",{value:!0});var Oze=Rr(),Cze={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:n}=t;if((0,Oze.alwaysValidSchema)(n,r)){t.fail();return}let i=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},i),t.failResult(i,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};cq.default=Cze});var lhe=V(dq=>{"use strict";f();Object.defineProperty(dq,"__esModule",{value:!0});var $ze=Fd(),jze={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:$ze.validateUnion,error:{message:"must match a schema in anyOf"}};dq.default=jze});var fhe=V(uq=>{"use strict";f();Object.defineProperty(uq,"__esModule",{value:!0});var dI=rr(),Nze=Rr(),Uze={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,dI._)`{passingSchemas: ${t.passing}}`},qze={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:Uze,code(t){let{gen:e,schema:r,parentSchema:n,it:i}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(i.opts.discriminator&&n.discriminator)return;let o=r,s=e.let("valid",!1),a=e.let("passing",null),d=e.name("_valid");t.setParams({passing:a}),e.block(u),t.result(s,()=>t.reset(),()=>t.error(!0));function u(){o.forEach((c,l)=>{let p;(0,Nze.alwaysValidSchema)(i,c)?e.var(d,!0):p=t.subschema({keyword:"oneOf",schemaProp:l,compositeRule:!0},d),l>0&&e.if((0,dI._)`${d} && ${s}`).assign(s,!1).assign(a,(0,dI._)`[${a}, ${l}]`).else(),e.if(d,()=>{e.assign(s,!0),e.assign(a,l),p&&t.mergeEvaluated(p,dI.Name)})})}}};uq.default=qze});var hhe=V(lq=>{"use strict";f();Object.defineProperty(lq,"__esModule",{value:!0});var Lze=Rr(),Kze={keyword:"allOf",schemaType:"array",code(t){let{gen:e,schema:r,it:n}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");let i=e.name("valid");r.forEach((o,s)=>{if((0,Lze.alwaysValidSchema)(n,o))return;let a=t.subschema({keyword:"allOf",schemaProp:s},i);t.ok(i),t.mergeEvaluated(a)})}};lq.default=Kze});var yhe=V(fq=>{"use strict";f();Object.defineProperty(fq,"__esModule",{value:!0});var uI=rr(),mhe=Rr(),Fze={message:({params:t})=>(0,uI.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,uI._)`{failingKeyword: ${t.ifClause}}`},zze={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:Fze,code(t){let{gen:e,parentSchema:r,it:n}=t;r.then===void 0&&r.else===void 0&&(0,mhe.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let i=phe(n,"then"),o=phe(n,"else");if(!i&&!o)return;let s=e.let("valid",!0),a=e.name("_valid");if(d(),t.reset(),i&&o){let c=e.let("ifClause");t.setParams({ifClause:c}),e.if(a,u("then",c),u("else",c))}else i?e.if(a,u("then")):e.if((0,uI.not)(a),u("else"));t.pass(s,()=>t.error(!0));function d(){let c=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);t.mergeEvaluated(c)}function u(c,l){return()=>{let p=t.subschema({keyword:c},a);e.assign(s,a),t.mergeValidEvaluated(p,s),l?e.assign(l,(0,uI._)`${c}`):t.setParams({ifClause:c})}}}};function phe(t,e){let r=t.schema[e];return r!==void 0&&!(0,mhe.alwaysValidSchema)(t,r)}fq.default=zze});var ghe=V(hq=>{"use strict";f();Object.defineProperty(hq,"__esModule",{value:!0});var Wze=Rr(),Hze={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,Wze.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};hq.default=Hze});var vhe=V(pq=>{"use strict";f();Object.defineProperty(pq,"__esModule",{value:!0});var Vze=ZU(),Gze=Jfe(),Jze=YU(),Zze=Yfe(),Yze=Xfe(),Xze=oI(),Qze=rhe(),eWe=iq(),tWe=ohe(),rWe=dhe(),nWe=uhe(),iWe=lhe(),oWe=fhe(),sWe=hhe(),aWe=yhe(),cWe=ghe();function dWe(t=!1){let e=[nWe.default,iWe.default,oWe.default,sWe.default,aWe.default,cWe.default,Qze.default,eWe.default,Xze.default,tWe.default,rWe.default];return t?e.push(Gze.default,Zze.default):e.push(Vze.default,Jze.default),e.push(Yze.default),e}pq.default=dWe});var yq=V(gS=>{"use strict";f();Object.defineProperty(gS,"__esModule",{value:!0});gS.dynamicAnchor=void 0;var mq=rr(),uWe=Kd(),bhe=iS(),lWe=XP(),fWe={keyword:"$dynamicAnchor",schemaType:"string",code:t=>whe(t,t.schema)};function whe(t,e){let{gen:r,it:n}=t;n.schemaEnv.root.dynamicAnchors[e]=!0;let i=(0,mq._)`${uWe.default.dynamicAnchors}${(0,mq.getProperty)(e)}`,o=n.errSchemaPath==="#"?n.validateName:hWe(t);r.if((0,mq._)`!${i}`,()=>r.assign(i,o))}gS.dynamicAnchor=whe;function hWe(t){let{schemaEnv:e,schema:r,self:n}=t.it,{root:i,baseId:o,localRefs:s,meta:a}=e.root,{schemaId:d}=n.opts,u=new bhe.SchemaEnv({schema:r,schemaId:d,root:i,baseId:o,localRefs:s,meta:a});return bhe.compileSchema.call(n,u),(0,lWe.getValidate)(t,u)}gS.default=fWe});var gq=V(vS=>{"use strict";f();Object.defineProperty(vS,"__esModule",{value:!0});vS.dynamicRef=void 0;var _he=rr(),pWe=Kd(),xhe=XP(),mWe={keyword:"$dynamicRef",schemaType:"string",code:t=>Ehe(t,t.schema)};function Ehe(t,e){let{gen:r,keyword:n,it:i}=t;if(e[0]!=="#")throw new Error(`"${n}" only supports hash fragment reference`);let o=e.slice(1);if(i.allErrors)s();else{let d=r.let("valid",!1);s(d),t.ok(d)}function s(d){if(i.schemaEnv.root.dynamicAnchors[o]){let u=r.let("_v",(0,_he._)`${pWe.default.dynamicAnchors}${(0,_he.getProperty)(o)}`);r.if(u,a(u,d),a(i.validateName,d))}else a(i.validateName,d)()}function a(d,u){return u?()=>r.block(()=>{(0,xhe.callRef)(t,d),r.let(u,!0)}):()=>(0,xhe.callRef)(t,d)}}vS.dynamicRef=Ehe;vS.default=mWe});var She=V(vq=>{"use strict";f();Object.defineProperty(vq,"__esModule",{value:!0});var yWe=yq(),gWe=Rr(),vWe={keyword:"$recursiveAnchor",schemaType:"boolean",code(t){t.schema?(0,yWe.dynamicAnchor)(t,""):(0,gWe.checkStrictMode)(t.it,"$recursiveAnchor: false is ignored")}};vq.default=vWe});var Ahe=V(bq=>{"use strict";f();Object.defineProperty(bq,"__esModule",{value:!0});var bWe=gq(),wWe={keyword:"$recursiveRef",schemaType:"string",code:t=>(0,bWe.dynamicRef)(t,t.schema)};bq.default=wWe});var The=V(wq=>{"use strict";f();Object.defineProperty(wq,"__esModule",{value:!0});var _We=yq(),xWe=gq(),EWe=She(),SWe=Ahe(),AWe=[_We.default,xWe.default,EWe.default,SWe.default];wq.default=AWe});var Ihe=V(_q=>{"use strict";f();Object.defineProperty(_q,"__esModule",{value:!0});var Phe=oI(),TWe={keyword:"dependentRequired",type:"object",schemaType:"object",error:Phe.error,code:t=>(0,Phe.validatePropertyDeps)(t)};_q.default=TWe});var khe=V(xq=>{"use strict";f();Object.defineProperty(xq,"__esModule",{value:!0});var PWe=oI(),IWe={keyword:"dependentSchemas",type:"object",schemaType:"object",code:t=>(0,PWe.validateSchemaDeps)(t)};xq.default=IWe});var Rhe=V(Eq=>{"use strict";f();Object.defineProperty(Eq,"__esModule",{value:!0});var kWe=Rr(),RWe={keyword:["maxContains","minContains"],type:"array",schemaType:"number",code({keyword:t,parentSchema:e,it:r}){e.contains===void 0&&(0,kWe.checkStrictMode)(r,`"${t}" without "contains" is ignored`)}};Eq.default=RWe});var Dhe=V(Sq=>{"use strict";f();Object.defineProperty(Sq,"__esModule",{value:!0});var DWe=Ihe(),BWe=khe(),MWe=Rhe(),OWe=[DWe.default,BWe.default,MWe.default];Sq.default=OWe});var Mhe=V(Aq=>{"use strict";f();Object.defineProperty(Aq,"__esModule",{value:!0});var yy=rr(),Bhe=Rr(),CWe=Kd(),$We={message:"must NOT have unevaluated properties",params:({params:t})=>(0,yy._)`{unevaluatedProperty: ${t.unevaluatedProperty}}`},jWe={keyword:"unevaluatedProperties",type:"object",schemaType:["boolean","object"],trackErrors:!0,error:$We,code(t){let{gen:e,schema:r,data:n,errsCount:i,it:o}=t;if(!i)throw new Error("ajv implementation error");let{allErrors:s,props:a}=o;a instanceof yy.Name?e.if((0,yy._)`${a} !== true`,()=>e.forIn("key",n,l=>e.if(u(a,l),()=>d(l)))):a!==!0&&e.forIn("key",n,l=>a===void 0?d(l):e.if(c(a,l),()=>d(l))),o.props=!0,t.ok((0,yy._)`${i} === ${CWe.default.errors}`);function d(l){if(r===!1){t.setParams({unevaluatedProperty:l}),t.error(),s||e.break();return}if(!(0,Bhe.alwaysValidSchema)(o,r)){let p=e.name("valid");t.subschema({keyword:"unevaluatedProperties",dataProp:l,dataPropType:Bhe.Type.Str},p),s||e.if((0,yy.not)(p),()=>e.break())}}function u(l,p){return(0,yy._)`!${l} || !${l}[${p}]`}function c(l,p){let m=[];for(let g in l)l[g]===!0&&m.push((0,yy._)`${p} !== ${g}`);return(0,yy.and)(...m)}}};Aq.default=jWe});var Che=V(Tq=>{"use strict";f();Object.defineProperty(Tq,"__esModule",{value:!0});var xv=rr(),Ohe=Rr(),NWe={message:({params:{len:t}})=>(0,xv.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,xv._)`{limit: ${t}}`},UWe={keyword:"unevaluatedItems",type:"array",schemaType:["boolean","object"],error:NWe,code(t){let{gen:e,schema:r,data:n,it:i}=t,o=i.items||0;if(o===!0)return;let s=e.const("len",(0,xv._)`${n}.length`);if(r===!1)t.setParams({len:o}),t.fail((0,xv._)`${s} > ${o}`);else if(typeof r=="object"&&!(0,Ohe.alwaysValidSchema)(i,r)){let d=e.var("valid",(0,xv._)`${s} <= ${o}`);e.if((0,xv.not)(d),()=>a(d,o)),t.ok(d)}i.items=!0;function a(d,u){e.forRange("i",u,s,c=>{t.subschema({keyword:"unevaluatedItems",dataProp:c,dataPropType:Ohe.Type.Num},d),i.allErrors||e.if((0,xv.not)(d),()=>e.break())})}}};Tq.default=UWe});var $he=V(Pq=>{"use strict";f();Object.defineProperty(Pq,"__esModule",{value:!0});var qWe=Mhe(),LWe=Che(),KWe=[qWe.default,LWe.default];Pq.default=KWe});var jhe=V(Iq=>{"use strict";f();Object.defineProperty(Iq,"__esModule",{value:!0});var Oi=rr(),FWe={message:({schemaCode:t})=>(0,Oi.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,Oi._)`{format: ${t}}`},zWe={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:FWe,code(t,e){let{gen:r,data:n,$data:i,schema:o,schemaCode:s,it:a}=t,{opts:d,errSchemaPath:u,schemaEnv:c,self:l}=a;if(!d.validateFormats)return;i?p():m();function p(){let g=r.scopeValue("formats",{ref:l.formats,code:d.code.formats}),v=r.const("fDef",(0,Oi._)`${g}[${s}]`),x=r.let("fType"),S=r.let("format");r.if((0,Oi._)`typeof ${v} == "object" && !(${v} instanceof RegExp)`,()=>r.assign(x,(0,Oi._)`${v}.type || "string"`).assign(S,(0,Oi._)`${v}.validate`),()=>r.assign(x,(0,Oi._)`"string"`).assign(S,v)),t.fail$data((0,Oi.or)(P(),A()));function P(){return d.strictSchema===!1?Oi.nil:(0,Oi._)`${s} && !${S}`}function A(){let $=c.$async?(0,Oi._)`(${v}.async ? await ${S}(${n}) : ${S}(${n}))`:(0,Oi._)`${S}(${n})`,j=(0,Oi._)`(typeof ${S} == "function" ? ${$} : ${S}.test(${n}))`;return(0,Oi._)`${S} && ${S} !== true && ${x} === ${e} && !${j}`}}function m(){let g=l.formats[o];if(!g){P();return}if(g===!0)return;let[v,x,S]=A(g);v===e&&t.pass($());function P(){if(d.strictSchema===!1){l.logger.warn(j());return}throw new Error(j());function j(){return`unknown format "${o}" ignored in schema at path "${u}"`}}function A(j){let L=j instanceof RegExp?(0,Oi.regexpCode)(j):d.code.formats?(0,Oi._)`${d.code.formats}${(0,Oi.getProperty)(o)}`:void 0,F=r.scopeValue("formats",{key:o,ref:j,code:L});return typeof j=="object"&&!(j instanceof RegExp)?[j.type||"string",j.validate,(0,Oi._)`${F}.validate`]:["string",j,F]}function $(){if(typeof g=="object"&&!(g instanceof RegExp)&&g.async){if(!c.$async)throw new Error("async format in sync schema");return(0,Oi._)`await ${S}(${n})`}return typeof x=="function"?(0,Oi._)`${S}(${n})`:(0,Oi._)`${S}.test(${n})`}}}};Iq.default=zWe});var Nhe=V(kq=>{"use strict";f();Object.defineProperty(kq,"__esModule",{value:!0});var WWe=jhe(),HWe=[WWe.default];kq.default=HWe});var Uhe=V(p2=>{"use strict";f();Object.defineProperty(p2,"__esModule",{value:!0});p2.contentVocabulary=p2.metadataVocabulary=void 0;p2.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];p2.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var Lhe=V(Rq=>{"use strict";f();Object.defineProperty(Rq,"__esModule",{value:!0});var VWe=Dfe(),GWe=Wfe(),JWe=vhe(),ZWe=The(),YWe=Dhe(),XWe=$he(),QWe=Nhe(),qhe=Uhe(),eHe=[ZWe.default,VWe.default,GWe.default,(0,JWe.default)(!0),QWe.default,qhe.metadataVocabulary,qhe.contentVocabulary,YWe.default,XWe.default];Rq.default=eHe});var Khe=V(bS=>{"use strict";f();Object.defineProperty(bS,"__esModule",{value:!0});bS.DiscrError=void 0;var tHe;(function(t){t.Tag="tag",t.Mapping="mapping"})(tHe=bS.DiscrError||(bS.DiscrError={}))});var zhe=V(Bq=>{"use strict";f();Object.defineProperty(Bq,"__esModule",{value:!0});var m2=rr(),Dq=Khe(),Fhe=iS(),rHe=Rr(),nHe={message:({params:{discrError:t,tagName:e}})=>t===Dq.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0,m2._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},iHe={keyword:"discriminator",type:"object",schemaType:"object",error:nHe,code(t){let{gen:e,data:r,schema:n,parentSchema:i,it:o}=t,{oneOf:s}=i;if(!o.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=n.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!s)throw new Error("discriminator: requires oneOf keyword");let d=e.let("valid",!1),u=e.const("tag",(0,m2._)`${r}${(0,m2.getProperty)(a)}`);e.if((0,m2._)`typeof ${u} == "string"`,()=>c(),()=>t.error(!1,{discrError:Dq.DiscrError.Tag,tag:u,tagName:a})),t.ok(d);function c(){let m=p();e.if(!1);for(let g in m)e.elseIf((0,m2._)`${u} === ${g}`),e.assign(d,l(m[g]));e.else(),t.error(!1,{discrError:Dq.DiscrError.Mapping,tag:u,tagName:a}),e.endIf()}function l(m){let g=e.name("valid"),v=t.subschema({keyword:"oneOf",schemaProp:m},g);return t.mergeEvaluated(v,m2.Name),g}function p(){var m;let g={},v=S(i),x=!0;for(let $=0;${oHe.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/schema",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/core":!0,"https://json-schema.org/draft/2020-12/vocab/applicator":!0,"https://json-schema.org/draft/2020-12/vocab/unevaluated":!0,"https://json-schema.org/draft/2020-12/vocab/validation":!0,"https://json-schema.org/draft/2020-12/vocab/meta-data":!0,"https://json-schema.org/draft/2020-12/vocab/format-annotation":!0,"https://json-schema.org/draft/2020-12/vocab/content":!0},$dynamicAnchor:"meta",title:"Core and Validation specifications meta-schema",allOf:[{$ref:"meta/core"},{$ref:"meta/applicator"},{$ref:"meta/unevaluated"},{$ref:"meta/validation"},{$ref:"meta/meta-data"},{$ref:"meta/format-annotation"},{$ref:"meta/content"}],type:["object","boolean"],$comment:"This meta-schema also defines keywords that have appeared in previous drafts in order to prevent incompatible extensions as they remain in common use.",properties:{definitions:{$comment:'"definitions" has been replaced by "$defs".',type:"object",additionalProperties:{$dynamicRef:"#meta"},deprecated:!0,default:{}},dependencies:{$comment:'"dependencies" has been split and replaced by "dependentSchemas" and "dependentRequired" in order to serve their differing semantics.',type:"object",additionalProperties:{anyOf:[{$dynamicRef:"#meta"},{$ref:"meta/validation#/$defs/stringArray"}]},deprecated:!0,default:{}},$recursiveAnchor:{$comment:'"$recursiveAnchor" has been replaced by "$dynamicAnchor".',$ref:"meta/core#/$defs/anchorString",deprecated:!0},$recursiveRef:{$comment:'"$recursiveRef" has been replaced by "$dynamicRef".',$ref:"meta/core#/$defs/uriReferenceString",deprecated:!0}}}});var Hhe=V((M8t,sHe)=>{sHe.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/applicator",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/applicator":!0},$dynamicAnchor:"meta",title:"Applicator vocabulary meta-schema",type:["object","boolean"],properties:{prefixItems:{$ref:"#/$defs/schemaArray"},items:{$dynamicRef:"#meta"},contains:{$dynamicRef:"#meta"},additionalProperties:{$dynamicRef:"#meta"},properties:{type:"object",additionalProperties:{$dynamicRef:"#meta"},default:{}},patternProperties:{type:"object",additionalProperties:{$dynamicRef:"#meta"},propertyNames:{format:"regex"},default:{}},dependentSchemas:{type:"object",additionalProperties:{$dynamicRef:"#meta"},default:{}},propertyNames:{$dynamicRef:"#meta"},if:{$dynamicRef:"#meta"},then:{$dynamicRef:"#meta"},else:{$dynamicRef:"#meta"},allOf:{$ref:"#/$defs/schemaArray"},anyOf:{$ref:"#/$defs/schemaArray"},oneOf:{$ref:"#/$defs/schemaArray"},not:{$dynamicRef:"#meta"}},$defs:{schemaArray:{type:"array",minItems:1,items:{$dynamicRef:"#meta"}}}}});var Vhe=V((O8t,aHe)=>{aHe.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/unevaluated",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/unevaluated":!0},$dynamicAnchor:"meta",title:"Unevaluated applicator vocabulary meta-schema",type:["object","boolean"],properties:{unevaluatedItems:{$dynamicRef:"#meta"},unevaluatedProperties:{$dynamicRef:"#meta"}}}});var Ghe=V((C8t,cHe)=>{cHe.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/content",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/content":!0},$dynamicAnchor:"meta",title:"Content vocabulary meta-schema",type:["object","boolean"],properties:{contentEncoding:{type:"string"},contentMediaType:{type:"string"},contentSchema:{$dynamicRef:"#meta"}}}});var Jhe=V(($8t,dHe)=>{dHe.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/core",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/core":!0},$dynamicAnchor:"meta",title:"Core vocabulary meta-schema",type:["object","boolean"],properties:{$id:{$ref:"#/$defs/uriReferenceString",$comment:"Non-empty fragments not allowed.",pattern:"^[^#]*#?$"},$schema:{$ref:"#/$defs/uriString"},$ref:{$ref:"#/$defs/uriReferenceString"},$anchor:{$ref:"#/$defs/anchorString"},$dynamicRef:{$ref:"#/$defs/uriReferenceString"},$dynamicAnchor:{$ref:"#/$defs/anchorString"},$vocabulary:{type:"object",propertyNames:{$ref:"#/$defs/uriString"},additionalProperties:{type:"boolean"}},$comment:{type:"string"},$defs:{type:"object",additionalProperties:{$dynamicRef:"#meta"}}},$defs:{anchorString:{type:"string",pattern:"^[A-Za-z_][-A-Za-z0-9._]*$"},uriString:{type:"string",format:"uri"},uriReferenceString:{type:"string",format:"uri-reference"}}}});var Zhe=V((j8t,uHe)=>{uHe.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/format-annotation",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/format-annotation":!0},$dynamicAnchor:"meta",title:"Format vocabulary meta-schema for annotation results",type:["object","boolean"],properties:{format:{type:"string"}}}});var Yhe=V((N8t,lHe)=>{lHe.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/meta-data",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/meta-data":!0},$dynamicAnchor:"meta",title:"Meta-data vocabulary meta-schema",type:["object","boolean"],properties:{title:{type:"string"},description:{type:"string"},default:!0,deprecated:{type:"boolean",default:!1},readOnly:{type:"boolean",default:!1},writeOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0}}}});var Xhe=V((U8t,fHe)=>{fHe.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/validation",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/validation":!0},$dynamicAnchor:"meta",title:"Validation vocabulary meta-schema",type:["object","boolean"],properties:{type:{anyOf:[{$ref:"#/$defs/simpleTypes"},{type:"array",items:{$ref:"#/$defs/simpleTypes"},minItems:1,uniqueItems:!0}]},const:!0,enum:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/$defs/nonNegativeInteger"},minLength:{$ref:"#/$defs/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},maxItems:{$ref:"#/$defs/nonNegativeInteger"},minItems:{$ref:"#/$defs/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},maxContains:{$ref:"#/$defs/nonNegativeInteger"},minContains:{$ref:"#/$defs/nonNegativeInteger",default:1},maxProperties:{$ref:"#/$defs/nonNegativeInteger"},minProperties:{$ref:"#/$defs/nonNegativeIntegerDefault0"},required:{$ref:"#/$defs/stringArray"},dependentRequired:{type:"object",additionalProperties:{$ref:"#/$defs/stringArray"}}},$defs:{nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{$ref:"#/$defs/nonNegativeInteger",default:0},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}}}});var Qhe=V(Mq=>{"use strict";f();Object.defineProperty(Mq,"__esModule",{value:!0});var hHe=Whe(),pHe=Hhe(),mHe=Vhe(),yHe=Ghe(),gHe=Jhe(),vHe=Zhe(),bHe=Yhe(),wHe=Xhe(),_He=["/properties"];function xHe(t){return[hHe,pHe,mHe,yHe,gHe,e(this,vHe),bHe,e(this,wHe)].forEach(r=>this.addMetaSchema(r,void 0,!1)),this;function e(r,n){return t?r.$dataMetaSchema(n,_He):n}}Mq.default=xHe});var Cq=V((si,epe)=>{"use strict";f();Object.defineProperty(si,"__esModule",{value:!0});si.MissingRefError=si.ValidationError=si.CodeGen=si.Name=si.nil=si.stringify=si.str=si._=si.KeywordCxt=void 0;var EHe=Tfe(),SHe=Lhe(),AHe=zhe(),THe=Qhe(),Oq="https://json-schema.org/draft/2020-12/schema",lI=class extends EHe.default{constructor(e={}){super({...e,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){super._addVocabularies(),SHe.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(AHe.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:e,meta:r}=this.opts;r&&(THe.default.call(this,e),this.refs["http://json-schema.org/schema"]=Oq)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(Oq)?Oq:void 0)}};epe.exports=si=lI;Object.defineProperty(si,"__esModule",{value:!0});si.default=lI;var PHe=nS();Object.defineProperty(si,"KeywordCxt",{enumerable:!0,get:function(){return PHe.KeywordCxt}});var y2=rr();Object.defineProperty(si,"_",{enumerable:!0,get:function(){return y2._}});Object.defineProperty(si,"str",{enumerable:!0,get:function(){return y2.str}});Object.defineProperty(si,"stringify",{enumerable:!0,get:function(){return y2.stringify}});Object.defineProperty(si,"nil",{enumerable:!0,get:function(){return y2.nil}});Object.defineProperty(si,"Name",{enumerable:!0,get:function(){return y2.Name}});Object.defineProperty(si,"CodeGen",{enumerable:!0,get:function(){return y2.CodeGen}});var IHe=WP();Object.defineProperty(si,"ValidationError",{enumerable:!0,get:function(){return IHe.default}});var kHe=HP();Object.defineProperty(si,"MissingRefError",{enumerable:!0,get:function(){return kHe.default}})});var _I=V((rPt,cpe)=>{f();var MHe=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,wI=()=>MHe.now(),OHe=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),Lq=t=>t===1/0||OHe(t),Kq=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&&!Lq(r))throw new TypeError("ttl must be positive integer or Infinity if set");if(!Lq(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{this.timer=void 0,this.timerExpiration=void 0,this.purgeStale();for(let i in this.expirations){this.setTimer(i,i-wI());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 k.default.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(wI()+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(!Lq(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-wI())):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(wI());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()}};cpe.exports=Kq});var hpe=V(fpe=>{"use strict";f();fpe.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 Qu=V((xPt,ppe)=>{"use strict";f();ppe.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 Wq=V((SPt,mpe)=>{"use strict";f();var zq=null;mpe.exports=function(){return zq===null&&(zq={textEncoder:new TextEncoder,textDecoder:new TextDecoder}),zq}});var Gq=V(ype=>{"use strict";f();var Hq=Qu(),$He=new Set(["buffer","view","utf8"]),Vq=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"||!$He.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 Hq(`Encoding '${this.name}' cannot be transcoded to 'buffer'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createViewTranscoder(){throw new Hq(`Encoding '${this.name}' cannot be transcoded to 'view'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createUTF8Transcoder(){throw new Hq(`Encoding '${this.name}' cannot be transcoded to 'utf8'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}};ype.Encoding=Vq});var Xq=V(SI=>{"use strict";f();var{Buffer:Zq}=hn()||{},{Encoding:Yq}=Gq(),jHe=Wq(),AS=class extends Yq{constructor(e){super({...e,format:"buffer"})}createViewTranscoder(){return new TS({encode:this.encode,decode:e=>this.decode(Zq.from(e.buffer,e.byteOffset,e.byteLength)),name:`${this.name}+view`})}createBufferTranscoder(){return this}},TS=class extends Yq{constructor(e){super({...e,format:"view"})}createBufferTranscoder(){return new AS({encode:e=>{let r=this.encode(e);return Zq.from(r.buffer,r.byteOffset,r.byteLength)},decode:this.decode,name:`${this.name}+buffer`})}createViewTranscoder(){return this}},Jq=class extends Yq{constructor(e){super({...e,format:"utf8"})}createBufferTranscoder(){return new AS({encode:e=>Zq.from(this.encode(e),"utf8"),decode:e=>this.decode(e.toString("utf8")),name:`${this.name}+buffer`})}createViewTranscoder(){let{textEncoder:e,textDecoder:r}=jHe();return new TS({encode:n=>e.encode(this.encode(n)),decode:n=>this.decode(r.decode(n)),name:`${this.name}+view`})}createUTF8Transcoder(){return this}};SI.BufferFormat=AS;SI.ViewFormat=TS;SI.UTF8Format=Jq});var wpe=V(Pv=>{"use strict";f();var{Buffer:aa}=hn()||{Buffer:{isBuffer:()=>!1}},{textEncoder:vpe,textDecoder:gpe}=Wq()(),{BufferFormat:PS,ViewFormat:Qq,UTF8Format:bpe}=Xq(),AI=t=>t;Pv.utf8=new bpe({encode:function(t){return aa.isBuffer(t)?t.toString("utf8"):ArrayBuffer.isView(t)?gpe.decode(t):String(t)},decode:AI,name:"utf8",createViewTranscoder(){return new Qq({encode:function(t){return ArrayBuffer.isView(t)?t:vpe.encode(t)},decode:function(t){return gpe.decode(t)},name:`${this.name}+view`})},createBufferTranscoder(){return new PS({encode:function(t){return aa.isBuffer(t)?t:ArrayBuffer.isView(t)?aa.from(t.buffer,t.byteOffset,t.byteLength):aa.from(String(t),"utf8")},decode:function(t){return t.toString("utf8")},name:`${this.name}+buffer`})}});Pv.json=new bpe({encode:JSON.stringify,decode:JSON.parse,name:"json"});Pv.buffer=new PS({encode:function(t){return aa.isBuffer(t)?t:ArrayBuffer.isView(t)?aa.from(t.buffer,t.byteOffset,t.byteLength):aa.from(String(t),"utf8")},decode:AI,name:"buffer",createViewTranscoder(){return new Qq({encode:function(t){return ArrayBuffer.isView(t)?t:aa.from(String(t),"utf8")},decode:function(t){return aa.from(t.buffer,t.byteOffset,t.byteLength)},name:`${this.name}+view`})}});Pv.view=new Qq({encode:function(t){return ArrayBuffer.isView(t)?t:vpe.encode(t)},decode:AI,name:"view",createBufferTranscoder(){return new PS({encode:function(t){return aa.isBuffer(t)?t:ArrayBuffer.isView(t)?aa.from(t.buffer,t.byteOffset,t.byteLength):aa.from(String(t),"utf8")},decode:AI,name:`${this.name}+buffer`})}});Pv.hex=new PS({encode:function(t){return aa.isBuffer(t)?t:aa.from(String(t),"hex")},decode:function(t){return t.toString("hex")},name:"hex"});Pv.base64=new PS({encode:function(t){return aa.isBuffer(t)?t:aa.from(String(t),"base64")},decode:function(t){return t.toString("base64")},name:"base64"})});var Epe=V(xpe=>{"use strict";f();var _pe=Qu(),PI=wpe(),{Encoding:NHe}=Gq(),{BufferFormat:UHe,ViewFormat:qHe,UTF8Format:LHe}=Xq(),IS=Symbol("formats"),TI=Symbol("encodings"),KHe=new Set(["buffer","view","utf8"]),eL=class{constructor(e){if(Array.isArray(e)){if(!e.every(r=>KHe.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[TI]=new Map,this[IS]=new Set(e);for(let r in PI)try{this.encoding(r)}catch(n){if(n.code!=="LEVEL_ENCODING_NOT_SUPPORTED")throw n}}encodings(){return Array.from(new Set(this[TI].values()))}encoding(e){let r=this[TI].get(e);if(r===void 0){if(typeof e=="string"&&e!==""){if(r=HHe[e],!r)throw new _pe(`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=FHe(e)}let{name:n,format:i}=r;if(!this[IS].has(i))if(this[IS].has("view"))r=r.createViewTranscoder();else if(this[IS].has("buffer"))r=r.createBufferTranscoder();else if(this[IS].has("utf8"))r=r.createUTF8Transcoder();else throw new _pe(`Encoding '${n}' cannot be transcoded`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"});for(let o of[e,n,r.name,r.commonName])this[TI].set(o,r)}return r}};xpe.Transcoder=eL;function FHe(t){if(t instanceof NHe)return t;let e="type"in t&&typeof t.type=="string"?t.type:void 0,r=t.name||e||`anonymous-${VHe++}`;switch(zHe(t)){case"view":return new qHe({...t,name:r});case"utf8":return new LHe({...t,name:r});case"buffer":return new UHe({...t,name:r});default:throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'")}}function zHe(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 WHe={binary:PI.buffer,"utf-8":PI.utf8},HHe={...PI,...WHe},VHe=0});var Ape=V((OPt,Spe)=>{f();Spe.exports=typeof queueMicrotask=="function"?queueMicrotask:t=>Promise.resolve().then(t)});var kS=V(tL=>{"use strict";f();var Tpe=Ape();tL.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};tL.fromPromise=function(t,e){if(e===void 0)return t;t.then(function(r){Tpe(()=>e(null,r))}).catch(function(r){Tpe(()=>e(r))})}});var II=V(rL=>{"use strict";f();rL.getCallback=function(t,e){return typeof t=="function"?t:e};rL.getOptions=function(t,e){return typeof t=="object"&&t!==null?t:e!==void 0?e:{}}});var Ty=V(BI=>{"use strict";f();var{fromCallback:nL}=kS(),Zc=Qu(),{getOptions:iL,getCallback:Ppe}=II(),Iv=Symbol("promise"),b2=Symbol("callback"),wf=Symbol("working"),kv=Symbol("handleOne"),Yh=Symbol("handleMany"),oL=Symbol("autoClose"),Sy=Symbol("finishWork"),_f=Symbol("returnMany"),_y=Symbol("closing"),RS=Symbol("handleClose"),kI=Symbol("closed"),DS=Symbol("closeCallbacks"),Ey=Symbol("keyEncoding"),Rv=Symbol("valueEncoding"),sL=Symbol("abortOnClose"),RI=Symbol("legacy"),aL=Symbol("keys"),cL=Symbol("values"),xy=Symbol("limit"),Hd=Symbol("count"),DI=Object.freeze({}),GHe=()=>{},Ipe=!1,BS=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[kI]=!1,this[DS]=[],this[wf]=!1,this[_y]=!1,this[oL]=!1,this[b2]=null,this[kv]=this[kv].bind(this),this[Yh]=this[Yh].bind(this),this[RS]=this[RS].bind(this),this[Ey]=r[Ey],this[Rv]=r[Rv],this[RI]=n,this[xy]=Number.isInteger(r.limit)&&r.limit>=0?r.limit:1/0,this[Hd]=0,this[sL]=!!r.abortOnClose,this.db=e,this.db.attachResource(this),this.nextTick=e.nextTick}get count(){return this[Hd]}get limit(){return this[xy]}next(e){let r;if(e===void 0)r=new Promise((n,i)=>{e=(o,s,a)=>{o?i(o):this[RI]?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[_y]?this.nextTick(e,new Zc("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[wf]?this.nextTick(e,new Zc("Iterator is busy: cannot call next() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[wf]=!0,this[b2]=e,this[Hd]>=this[xy]?this.nextTick(this[kv],null):this._next(this[kv])),r}_next(e){this.nextTick(e)}nextv(e,r,n){return n=Ppe(r,n),n=nL(n,Iv),r=iL(r,DI),Number.isInteger(e)?(this[_y]?this.nextTick(n,new Zc("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[wf]?this.nextTick(n,new Zc("Iterator is busy: cannot call nextv() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(e<1&&(e=1),this[xy]<1/0&&(e=Math.min(e,this[xy]-this[Hd])),this[wf]=!0,this[b2]=n,e<=0?this.nextTick(this[Yh],null,[]):this._nextv(e,r,this[Yh])),n[Iv]):(this.nextTick(n,new TypeError("The first argument 'size' must be an integer")),n[Iv])}_nextv(e,r,n){let i=[],o=(s,a,d)=>{if(s)return n(s);if(this[RI]?a===void 0&&d===void 0:a===void 0)return n(null,i);i.push(this[RI]?[a,d]:a),i.length===e?n(null,i):this._next(o)};this._next(o)}all(e,r){return r=Ppe(e,r),r=nL(r,Iv),e=iL(e,DI),this[_y]?this.nextTick(r,new Zc("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[wf]?this.nextTick(r,new Zc("Iterator is busy: cannot call all() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[wf]=!0,this[b2]=r,this[oL]=!0,this[Hd]>=this[xy]?this.nextTick(this[Yh],null,[]):this._all(e,this[Yh])),r[Iv]}_all(e,r){let n=this[Hd],i=[],o=()=>{let a=this[xy]<1/0?Math.min(1e3,this[xy]-n):1e3;a<=0?this.nextTick(r,null,i):this._nextv(a,DI,s)},s=(a,d)=>{a?r(a):d.length===0?r(null,i):(i.push.apply(i,d),n+=d.length,o())};o()}[Sy](){let e=this[b2];return this[sL]&&e===null?GHe:(this[wf]=!1,this[b2]=null,this[_y]&&this._close(this[RS]),e)}[_f](e,r,n){this[oL]?this.close(e.bind(null,r,n)):e(r,n)}seek(e,r){if(r=iL(r,DI),!this[_y]){if(this[wf])throw new Zc("Iterator is busy: cannot call seek() until next() has completed",{code:"LEVEL_ITERATOR_BUSY"});{let n=this.db.keyEncoding(r.keyEncoding||this[Ey]),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 Zc("Iterator does not support seek()",{code:"LEVEL_NOT_SUPPORTED"})}close(e){return e=nL(e,Iv),this[kI]?this.nextTick(e):this[_y]?this[DS].push(e):(this[_y]=!0,this[DS].push(e),this[wf]?this[sL]&&this[Sy]()(new Zc("Aborted on iterator close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this._close(this[RS])),e[Iv]}_close(e){this.nextTick(e)}[RS](){this[kI]=!0,this.db.detachResource(this);let e=this[DS];this[DS]=[];for(let r of e)r()}async*[Symbol.asyncIterator](){try{let e;for(;(e=await this.next())!==void 0;)yield e}finally{this[kI]||await this.close()}}},w2=class extends BS{constructor(e,r){super(e,r,!0),this[aL]=r.keys!==!1,this[cL]=r.values!==!1}[kv](e,r,n){let i=this[Sy]();if(e)return i(e);try{r=this[aL]&&r!==void 0?this[Ey].decode(r):void 0,n=this[cL]&&n!==void 0?this[Rv].decode(n):void 0}catch(o){return i(new Ay("entry",o))}r===void 0&&n===void 0||this[Hd]++,i(null,r,n)}[Yh](e,r){let n=this[Sy]();if(e)return this[_f](n,e);try{for(let i of r){let o=i[0],s=i[1];i[0]=this[aL]&&o!==void 0?this[Ey].decode(o):void 0,i[1]=this[cL]&&s!==void 0?this[Rv].decode(s):void 0}}catch(i){return this[_f](n,new Ay("entries",i))}this[Hd]+=r.length,this[_f](n,null,r)}end(e){return!Ipe&&typeof console<"u"&&(Ipe=!0,console.warn(new Zc("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)}},dL=class extends BS{constructor(e,r){super(e,r,!1)}[kv](e,r){let n=this[Sy]();if(e)return n(e);try{r=r!==void 0?this[Ey].decode(r):void 0}catch(i){return n(new Ay("key",i))}r!==void 0&&this[Hd]++,n(null,r)}[Yh](e,r){let n=this[Sy]();if(e)return this[_f](n,e);try{for(let i=0;i{"use strict";f();var{AbstractKeyIterator:JHe,AbstractValueIterator:ZHe}=Ty(),Dv=Symbol("iterator"),MS=Symbol("callback"),_2=Symbol("handleOne"),Bv=Symbol("handleMany"),OS=class extends JHe{constructor(e,r){super(e,r),this[Dv]=e.iterator({...r,keys:!0,values:!1}),this[_2]=this[_2].bind(this),this[Bv]=this[Bv].bind(this)}},MI=class extends ZHe{constructor(e,r){super(e,r),this[Dv]=e.iterator({...r,keys:!1,values:!0}),this[_2]=this[_2].bind(this),this[Bv]=this[Bv].bind(this)}};for(let t of[OS,MI]){let e=t===OS,r=e?n=>n[0]:n=>n[1];t.prototype._next=function(n){this[MS]=n,this[Dv].next(this[_2])},t.prototype[_2]=function(n,i,o){let s=this[MS];n?s(n):s(null,e?i:o)},t.prototype._nextv=function(n,i,o){this[MS]=o,this[Dv].nextv(n,i,this[Bv])},t.prototype._all=function(n,i){this[MS]=i,this[Dv].all(n,this[Bv])},t.prototype[Bv]=function(n,i){let o=this[MS];n?o(n):o(null,i.map(r))},t.prototype._seek=function(n,i){this[Dv].seek(n,i)},t.prototype._close=function(n){this[Dv].close(n)}}lL.DefaultKeyIterator=OS;lL.DefaultValueIterator=MI});var Rpe=V(UI=>{"use strict";f();var{AbstractIterator:YHe,AbstractKeyIterator:XHe,AbstractValueIterator:QHe}=Ty(),fL=Qu(),lc=Symbol("nut"),jI=Symbol("undefer"),NI=Symbol("factory"),OI=class extends YHe{constructor(e,r){super(e,r),this[lc]=null,this[NI]=()=>e.iterator(r),this.db.defer(()=>this[jI]())}},CI=class extends XHe{constructor(e,r){super(e,r),this[lc]=null,this[NI]=()=>e.keys(r),this.db.defer(()=>this[jI]())}},$I=class extends QHe{constructor(e,r){super(e,r),this[lc]=null,this[NI]=()=>e.values(r),this.db.defer(()=>this[jI]())}};for(let t of[OI,CI,$I])t.prototype[jI]=function(){this.db.status==="open"&&(this[lc]=this[NI]())},t.prototype._next=function(e){this[lc]!==null?this[lc].next(e):this.db.status==="opening"?this.db.defer(()=>this._next(e)):this.nextTick(e,new fL("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},t.prototype._nextv=function(e,r,n){this[lc]!==null?this[lc].nextv(e,r,n):this.db.status==="opening"?this.db.defer(()=>this._nextv(e,r,n)):this.nextTick(n,new fL("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},t.prototype._all=function(e,r){this[lc]!==null?this[lc].all(r):this.db.status==="opening"?this.db.defer(()=>this._all(e,r)):this.nextTick(r,new fL("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},t.prototype._seek=function(e,r){this[lc]!==null?this[lc]._seek(e,r):this.db.status==="opening"&&this.db.defer(()=>this._seek(e,r))},t.prototype._close=function(e){this[lc]!==null?this[lc].close(e):this.db.status==="opening"?this.db.defer(()=>this._close(e)):this.nextTick(e)};UI.DeferredIterator=OI;UI.DeferredKeyIterator=CI;UI.DeferredValueIterator=$I});var pL=V(Bpe=>{"use strict";f();var{fromCallback:Dpe}=kS(),qI=Qu(),{getCallback:eVe,getOptions:tVe}=II(),LI=Symbol("promise"),Vd=Symbol("status"),x2=Symbol("operations"),CS=Symbol("finishClose"),E2=Symbol("closeCallbacks"),hL=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[x2]=[],this[E2]=[],this[Vd]="open",this[CS]=this[CS].bind(this),this.db=e,this.db.attachResource(this),this.nextTick=e.nextTick}get length(){return this[x2].length}put(e,r,n){if(this[Vd]!=="open")throw new qI("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),d=o.valueEncoding(n&&n.valueEncoding),u=a.format;n={...n,keyEncoding:u,valueEncoding:d.format},o!==this.db&&(n.sublevel=null);let c=o.prefixKey(a.encode(e),u),l=d.encode(r);return this._put(c,l,n),this[x2].push({...s,type:"put",key:e,value:r}),this}_put(e,r,n){}del(e,r){if(this[Vd]!=="open")throw new qI("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[x2].push({...o,type:"del",key:e}),this}_del(e,r){}clear(){if(this[Vd]!=="open")throw new qI("Batch is not open: cannot call clear() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});return this._clear(),this[x2]=[],this}_clear(){}write(e,r){return r=eVe(e,r),r=Dpe(r,LI),e=tVe(e),this[Vd]!=="open"?this.nextTick(r,new qI("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"})):this.length===0?this.close(r):(this[Vd]="writing",this._write(e,n=>{this[Vd]="closing",this[E2].push(()=>r(n)),n||this.db.emit("batch",this[x2]),this._close(this[CS])})),r[LI]}_write(e,r){}close(e){return e=Dpe(e,LI),this[Vd]==="closing"?this[E2].push(e):this[Vd]==="closed"?this.nextTick(e):(this[E2].push(e),this[Vd]!=="writing"&&(this[Vd]="closing",this._close(this[CS]))),e[LI]}_close(e){this.nextTick(e)}[CS](){this[Vd]="closed",this.db.detachResource(this);let e=this[E2];this[E2]=[];for(let r of e)r()}};Bpe.AbstractChainedBatch=hL});var Ope=V(Mpe=>{"use strict";f();var{AbstractChainedBatch:rVe}=pL(),nVe=Qu(),S2=Symbol("encoded"),mL=class extends rVe{constructor(e){super(e),this[S2]=[]}_put(e,r,n){this[S2].push({...n,type:"put",key:e,value:r})}_del(e,r){this[S2].push({...r,type:"del",key:e})}_clear(){this[S2]=[]}_write(e,r){this.db.status==="opening"?this.db.defer(()=>this._write(e,r)):this.db.status==="open"?this[S2].length===0?this.nextTick(r):this.db._batch(this[S2],e,r):this.nextTick(r,new nVe("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"}))}};Mpe.DefaultChainedBatch=mL});var jpe=V((ZPt,$pe)=>{"use strict";f();var Cpe=Qu(),iVe=Object.prototype.hasOwnProperty,oVe=new Set(["lt","lte","gt","gte"]);$pe.exports=function(t,e){let r={};for(let n in t)if(iVe.call(t,n)&&!(n==="keyEncoding"||n==="valueEncoding")){if(n==="start"||n==="end")throw new Cpe(`The legacy range option '${n}' has been removed`,{code:"LEVEL_LEGACY"});if(n==="encoding")throw new Cpe("The levelup-style 'encoding' alias has been removed, use 'valueEncoding' instead",{code:"LEVEL_LEGACY"});oVe.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 yL=V((XPt,Upe)=>{f();var Npe;Upe.exports=typeof queueMicrotask=="function"?queueMicrotask.bind(typeof window<"u"?window:globalThis):t=>(Npe||(Npe=Promise.resolve())).then(t).catch(e=>setTimeout(()=>{throw e},0))});var Kpe=V((eIt,Lpe)=>{"use strict";f();var qpe=yL();Lpe.exports=function(t,...e){e.length===0?qpe(t):qpe(()=>t(...e))}});var Fpe=V(KI=>{"use strict";f();var{AbstractIterator:sVe,AbstractKeyIterator:aVe,AbstractValueIterator:cVe}=Ty(),A2=Symbol("unfix"),el=Symbol("iterator"),Mv=Symbol("handleOne"),Py=Symbol("handleMany"),Xh=Symbol("callback"),$S=class extends sVe{constructor(e,r,n,i){super(e,r),this[el]=n,this[A2]=i,this[Mv]=this[Mv].bind(this),this[Py]=this[Py].bind(this),this[Xh]=null}[Mv](e,r,n){let i=this[Xh];if(e)return i(e);r!==void 0&&(r=this[A2](r)),i(e,r,n)}[Py](e,r){let n=this[Xh];if(e)return n(e);for(let i of r){let o=i[0];o!==void 0&&(i[0]=this[A2](o))}n(e,r)}},jS=class extends aVe{constructor(e,r,n,i){super(e,r),this[el]=n,this[A2]=i,this[Mv]=this[Mv].bind(this),this[Py]=this[Py].bind(this),this[Xh]=null}[Mv](e,r){let n=this[Xh];if(e)return n(e);r!==void 0&&(r=this[A2](r)),n(e,r)}[Py](e,r){let n=this[Xh];if(e)return n(e);for(let i=0;i{"use strict";f();var gL=Qu(),{Buffer:wL}=hn()||{},{AbstractSublevelIterator:dVe,AbstractSublevelKeyIterator:uVe,AbstractSublevelValueIterator:lVe}=Fpe(),Qh=Symbol("prefix"),zpe=Symbol("upperBound"),US=Symbol("prefixRange"),Yc=Symbol("parent"),vL=Symbol("unfix"),Wpe=new TextEncoder,fVe={separator:"!"};Hpe.exports=function({AbstractLevel:t}){class e extends t{static defaults(n){if(typeof n=="string")throw new gL("The subleveldown string shorthand for { separator } has been removed",{code:"LEVEL_LEGACY"});if(n&&n.open)throw new gL("The subleveldown open option has been removed",{code:"LEVEL_LEGACY"});return n==null?fVe:n.separator?n:{...n,separator:"!"}}constructor(n,i,o){let{separator:s,manifest:a,...d}=e.defaults(o);i=pVe(i,s);let u=s.charCodeAt(0)+1,c=n[Yc]||n;if(!Wpe.encode(i).every(m=>m>u&&m<127))throw new gL(`Prefix must use bytes > ${u} < 127`,{code:"LEVEL_INVALID_PREFIX"});super(hVe(c,a),d);let l=(n.prefix||"")+s+i+s,p=l.slice(0,-1)+String.fromCharCode(u);this[Yc]=c,this[Qh]=new FI(l),this[zpe]=new FI(p),this[vL]=new _L,this.nextTick=c.nextTick}prefixKey(n,i){if(i==="utf8")return this[Qh].utf8+n;if(n.byteLength===0)return this[Qh][i];if(i==="view"){let o=this[Qh].view,s=new Uint8Array(o.byteLength+n.byteLength);return s.set(o,0),s.set(n,o.byteLength),s}else{let o=this[Qh].buffer;return wL.concat([o,n],o.byteLength+n.byteLength)}}[US](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[Qh][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[zpe][i]}get prefix(){return this[Qh].utf8}get db(){return this[Yc]}_open(n,i){this[Yc].open({passive:!0},i)}_put(n,i,o,s){this[Yc].put(n,i,o,s)}_get(n,i,o){this[Yc].get(n,i,o)}_getMany(n,i,o){this[Yc].getMany(n,i,o)}_del(n,i,o){this[Yc].del(n,i,o)}_batch(n,i,o){this[Yc].batch(n,i,o)}_clear(n,i){this[US](n,n.keyEncoding),this[Yc].clear(n,i)}_iterator(n){this[US](n,n.keyEncoding);let i=this[Yc].iterator(n),o=this[vL].get(this[Qh].utf8.length,n.keyEncoding);return new dVe(this,n,i,o)}_keys(n){this[US](n,n.keyEncoding);let i=this[Yc].keys(n),o=this[vL].get(this[Qh].utf8.length,n.keyEncoding);return new uVe(this,n,i,o)}_values(n){this[US](n,n.keyEncoding);let i=this[Yc].values(n);return new lVe(this,n,i)}}return{AbstractSublevel:e}};var hVe=function(t,e){return{...t.supports,createIfMissing:!1,errorIfExists:!1,events:{},additionalMethods:{},...e,encodings:{utf8:bL(t,"utf8"),buffer:bL(t,"buffer"),view:bL(t,"view")}}},bL=function(t,e){return t.supports.encodings[e]?t.keyEncoding(e).name===e:!1},FI=class{constructor(e){this.utf8=e,this.view=Wpe.encode(e),this.buffer=wL?wL.from(this.view.buffer,0,this.view.byteLength):{}}},_L=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}},pVe=function(t,e){let r=0,n=t.length;for(;rr&&t[n-1]===e;)n--;return t.slice(r,n)}});var TL=V(AL=>{"use strict";f();var{supports:mVe}=hpe(),{Transcoder:yVe}=Epe(),{EventEmitter:gVe}=Sa(),{fromCallback:Iy}=kS(),tl=Qu(),{AbstractIterator:Ov}=Ty(),{DefaultKeyIterator:vVe,DefaultValueIterator:bVe}=kpe(),{DeferredIterator:wVe,DeferredKeyIterator:_Ve,DeferredValueIterator:xVe}=Rpe(),{DefaultChainedBatch:Gpe}=Ope(),{getCallback:Cv,getOptions:ky}=II(),zI=jpe(),yr=Symbol("promise"),ep=Symbol("landed"),$v=Symbol("resources"),xL=Symbol("closeResources"),qS=Symbol("operations"),LS=Symbol("undefer"),WI=Symbol("deferOpen"),Jpe=Symbol("options"),Dr=Symbol("status"),jv=Symbol("defaultOptions"),T2=Symbol("transcoder"),HI=Symbol("keyEncoding"),EL=Symbol("valueEncoding"),EVe=()=>{},KS=class extends gVe{constructor(e,r){if(super(),typeof e!="object"||e===null)throw new TypeError("The first argument 'manifest' must be an object");r=ky(r);let{keyEncoding:n,valueEncoding:i,passive:o,...s}=r;this[$v]=new Set,this[qS]=[],this[WI]=!0,this[Jpe]=s,this[Dr]="opening",this.supports=mVe(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[T2]=new yVe(SVe(this)),this[HI]=this[T2].encoding(n||"utf8"),this[EL]=this[T2].encoding(i||"utf8");for(let a of this[T2].encodings())this.supports.encodings[a.commonName]||(this.supports.encodings[a.commonName]=!0);this[jv]={empty:Object.freeze({}),entry:Object.freeze({keyEncoding:this[HI].commonName,valueEncoding:this[EL].commonName}),key:Object.freeze({keyEncoding:this[HI].commonName})},this.nextTick(()=>{this[WI]&&this.open({passive:!1},EVe)})}get status(){return this[Dr]}keyEncoding(e){return this[T2].encoding(e??this[HI])}valueEncoding(e){return this[T2].encoding(e??this[EL])}open(e,r){r=Cv(e,r),r=Iy(r,yr),e={...this[Jpe],...ky(e)},e.createIfMissing=e.createIfMissing!==!1,e.errorIfExists=!!e.errorIfExists;let n=i=>{this[Dr]==="closing"||this[Dr]==="opening"?this.once(ep,i?()=>n(i):n):this[Dr]!=="open"?r(new tl("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN",cause:i})):r()};return e.passive?this[Dr]==="opening"?this.once(ep,n):this.nextTick(n):this[Dr]==="closed"||this[WI]?(this[WI]=!1,this[Dr]="opening",this.emit("opening"),this._open(e,i=>{if(i){this[Dr]="closed",this[xL](()=>{this.emit(ep),n(i)}),this[LS]();return}this[Dr]="open",this[LS](),this.emit(ep),this[Dr]==="open"&&this.emit("open"),this[Dr]==="open"&&this.emit("ready"),n()})):this[Dr]==="open"?this.nextTick(n):this.once(ep,()=>this.open(e,r)),r[yr]}_open(e,r){this.nextTick(r)}close(e){e=Iy(e,yr);let r=n=>{this[Dr]==="opening"||this[Dr]==="closing"?this.once(ep,n?r(n):r):this[Dr]!=="closed"?e(new tl("Database is not closed",{code:"LEVEL_DATABASE_NOT_CLOSED",cause:n})):e()};if(this[Dr]==="open"){this[Dr]="closing",this.emit("closing");let n=i=>{this[Dr]="open",this[LS](),this.emit(ep),r(i)};this[xL](()=>{this._close(i=>{if(i)return n(i);this[Dr]="closed",this[LS](),this.emit(ep),this[Dr]==="closed"&&this.emit("closed"),r()})})}else this[Dr]==="closed"?this.nextTick(r):this.once(ep,()=>this.close(e));return e[yr]}[xL](e){if(this[$v].size===0)return this.nextTick(e);let r=this[$v].size,n=!0,i=()=>{--r===0&&(n?this.nextTick(e):e())};for(let o of this[$v])o.close(i);n=!1,this[$v].clear()}_close(e){this.nextTick(e)}get(e,r,n){if(n=Cv(r,n),n=Iy(n,yr),r=ky(r,this[jv].entry),this[Dr]==="opening")return this.defer(()=>this.get(e,r,n)),n[yr];if(P2(this,n))return n[yr];let i=this._checkKey(e);if(i)return this.nextTick(n,i),n[yr];let o=this.keyEncoding(r.keyEncoding),s=this.valueEncoding(r.valueEncoding),a=o.format,d=s.format;return(r.keyEncoding!==a||r.valueEncoding!==d)&&(r=Object.assign({},r,{keyEncoding:a,valueEncoding:d})),this._get(this.prefixKey(o.encode(e),a),r,(u,c)=>{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{c=s.decode(c)}catch(l){return n(new tl("Could not decode value",{code:"LEVEL_DECODE_ERROR",cause:l}))}n(null,c)}),n[yr]}_get(e,r,n){this.nextTick(n,new Error("NotFound"))}getMany(e,r,n){if(n=Cv(r,n),n=Iy(n,yr),r=ky(r,this[jv].entry),this[Dr]==="opening")return this.defer(()=>this.getMany(e,r,n)),n[yr];if(P2(this,n))return n[yr];if(!Array.isArray(e))return this.nextTick(n,new TypeError("The first argument 'keys' must be an array")),n[yr];if(e.length===0)return this.nextTick(n,null,[]),n[yr];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 d=new Array(e.length);for(let u=0;u{if(u)return n(u);try{for(let l=0;lthis.put(e,r,n,i)),i[yr];if(P2(this,i))return i[yr];let o=this._checkKey(e)||this._checkValue(r);if(o)return this.nextTick(i,o),i[yr];let s=this.keyEncoding(n.keyEncoding),a=this.valueEncoding(n.valueEncoding),d=s.format,u=a.format;(n.keyEncoding!==d||n.valueEncoding!==u)&&(n=Object.assign({},n,{keyEncoding:d,valueEncoding:u}));let c=this.prefixKey(s.encode(e),d),l=a.encode(r);return this._put(c,l,n,p=>{if(p)return i(p);this.emit("put",e,r),i()}),i[yr]}_put(e,r,n,i){this.nextTick(i)}del(e,r,n){if(n=Cv(r,n),n=Iy(n,yr),r=ky(r,this[jv].key),this[Dr]==="opening")return this.defer(()=>this.del(e,r,n)),n[yr];if(P2(this,n))return n[yr];let i=this._checkKey(e);if(i)return this.nextTick(n,i),n[yr];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[yr]}_del(e,r,n){this.nextTick(n)}batch(e,r,n){if(!arguments.length){if(this[Dr]==="opening")return new Gpe(this);if(this[Dr]!=="open")throw new tl("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._chainedBatch()}if(typeof e=="function"?n=e:n=Cv(r,n),n=Iy(n,yr),r=ky(r,this[jv].empty),this[Dr]==="opening")return this.defer(()=>this.batch(e,r,n)),n[yr];if(P2(this,n))return n[yr];if(!Array.isArray(e))return this.nextTick(n,new TypeError("The first argument 'operations' must be an array")),n[yr];if(e.length===0)return this.nextTick(n),n[yr];let i=new Array(e.length),{keyEncoding:o,valueEncoding:s,...a}=r;for(let d=0;d{if(d)return n(d);this.emit("batch",e),n()}),n[yr]}_batch(e,r,n){this.nextTick(n)}sublevel(e,r){return this._sublevel(e,SL.defaults(r))}_sublevel(e,r){return new SL(this,e,r)}prefixKey(e,r){return e}clear(e,r){if(r=Cv(e,r),r=Iy(r,yr),e=ky(e,this[jv].empty),this[Dr]==="opening")return this.defer(()=>this.clear(e,r)),r[yr];if(P2(this,r))return r[yr];let n=e,i=this.keyEncoding(e.keyEncoding);return e=zI(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[yr]}_clear(e,r){this.nextTick(r)}iterator(e){let r=this.keyEncoding(e&&e.keyEncoding),n=this.valueEncoding(e&&e.valueEncoding);if(e=zI(e,r),e.keys=e.keys!==!1,e.values=e.values!==!1,e[Ov.keyEncoding]=r,e[Ov.valueEncoding]=n,e.keyEncoding=r.format,e.valueEncoding=n.format,this[Dr]==="opening")return new wVe(this,e);if(this[Dr]!=="open")throw new tl("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._iterator(e)}_iterator(e){return new Ov(this,e)}keys(e){let r=this.keyEncoding(e&&e.keyEncoding),n=this.valueEncoding(e&&e.valueEncoding);if(e=zI(e,r),e[Ov.keyEncoding]=r,e[Ov.valueEncoding]=n,e.keyEncoding=r.format,e.valueEncoding=n.format,this[Dr]==="opening")return new _Ve(this,e);if(this[Dr]!=="open")throw new tl("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._keys(e)}_keys(e){return new vVe(this,e)}values(e){let r=this.keyEncoding(e&&e.keyEncoding),n=this.valueEncoding(e&&e.valueEncoding);if(e=zI(e,r),e[Ov.keyEncoding]=r,e[Ov.valueEncoding]=n,e.keyEncoding=r.format,e.valueEncoding=n.format,this[Dr]==="opening")return new xVe(this,e);if(this[Dr]!=="open")throw new tl("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._values(e)}_values(e){return new bVe(this,e)}defer(e){if(typeof e!="function")throw new TypeError("The first argument must be a function");this[qS].push(e)}[LS](){if(this[qS].length===0)return;let e=this[qS];this[qS]=[];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[$v].add(e)}detachResource(e){this[$v].delete(e)}_chainedBatch(){return new Gpe(this)}_checkKey(e){if(e==null)return new tl("Key cannot be null or undefined",{code:"LEVEL_INVALID_KEY"})}_checkValue(e){if(e==null)return new tl("Value cannot be null or undefined",{code:"LEVEL_INVALID_VALUE"})}};KS.prototype.nextTick=Kpe();var{AbstractSublevel:SL}=Vpe()({AbstractLevel:KS});AL.AbstractLevel=KS;AL.AbstractSublevel=SL;var P2=function(t,e){return t[Dr]!=="open"?(t.nextTick(e,new tl("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"})),!0):!1},SVe=function(t){return Object.keys(t.supports.encodings).filter(e=>!!t.supports.encodings[e])}});var PL=V(Nv=>{"use strict";f();Nv.AbstractLevel=TL().AbstractLevel;Nv.AbstractSublevel=TL().AbstractSublevel;Nv.AbstractIterator=Ty().AbstractIterator;Nv.AbstractKeyIterator=Ty().AbstractKeyIterator;Nv.AbstractValueIterator=Ty().AbstractValueIterator;Nv.AbstractChainedBatch=pL().AbstractChainedBatch});var Ype=V((uIt,Zpe)=>{f();Zpe.exports=TVe;var AVe=yL();function TVe(t,e,r){if(typeof e!="number")throw new Error("second argument must be a Number");let n,i,o,s,a,d=!0,u;Array.isArray(t)?(n=[],o=i=t.length):(s=Object.keys(t),n={},o=i=s.length);function c(p){function m(){r&&r(p,n),r=null}d?AVe(m):m()}function l(p,m,g){if(n[p]=g,m&&(a=!0),--o===0||m)c(m);else if(!a&&u{"use strict";f();Xpe.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 kL=V((pIt,Qpe)=>{"use strict";f();var PVe=new TextEncoder;Qpe.exports=function(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):PVe.encode(t)}});var ime=V(nme=>{"use strict";f();var{AbstractIterator:IVe}=PL(),eme=IL(),VI=kL(),xf=Symbol("cache"),tp=Symbol("finished"),Xc=Symbol("options"),rp=Symbol("currentOptions"),Uv=Symbol("position"),RL=Symbol("location"),I2=Symbol("first"),tme={},DL=class extends IVe{constructor(e,r,n){super(e,n),this[xf]=[],this[tp]=this.limit===0,this[Xc]=n,this[rp]={...n},this[Uv]=void 0,this[RL]=r,this[I2]=!0}_nextv(e,r,n){if(this[I2]=!1,this[tp])return this.nextTick(n,null,[]);if(this[xf].length>0)return e=Math.min(e,this[xf].length),this.nextTick(n,null,this[xf].splice(0,e));this[Uv]!==void 0&&(this[Xc].reverse?(this[rp].lt=this[Uv],this[rp].lte=void 0):(this[rp].gt=this[Uv],this[rp].gte=void 0));let i;try{i=eme(this[rp])}catch{return this[tp]=!0,this.nextTick(n,null,[])}let o=this.db.db.transaction([this[RL]],"readonly"),s=o.objectStore(this[RL]),a=[];if(this[Xc].reverse){let d=!this[Xc].values&&s.openKeyCursor?"openKeyCursor":"openCursor";s[d](i,"prev").onsuccess=u=>{let c=u.target.result;if(c){let{key:l,value:p}=c;this[Uv]=l,a.push([this[Xc].keys&&l!==void 0?VI(l):void 0,this[Xc].values&&p!==void 0?VI(p):void 0]),a.length{if(d===void 0||u===void 0)return;let l=Math.max(d.length,u.length);l===0||e===1/0?this[tp]=!0:this[Uv]=d[l-1],a.length=l;for(let p=0;p{d=l.target.result,c()}:(d=[],this.nextTick(c)),this[Xc].values?s.getAll(i,e<1/0?e:void 0).onsuccess=l=>{u=l.target.result,c()}:(u=[],this.nextTick(c))}o.onabort=()=>{n(o.error||new Error("aborted by user")),n=null},o.oncomplete=()=>{n(null,a),n=null}}_next(e){if(this[xf].length>0){let[r,n]=this[xf].shift();this.nextTick(e,null,r,n)}else if(this[tp])this.nextTick(e);else{let r=Math.min(100,this.limit-this.count);this[I2]&&(this[I2]=!1,r=1),this._nextv(r,tme,(n,i)=>{if(n)return e(n);this[xf]=i,this._next(e)})}}_all(e,r){this[I2]=!1;let n=this[xf].splice(0,this[xf].length),i=this.limit-this.count-n.length;if(i<=0)return this.nextTick(r,null,n);this._nextv(i,tme,(o,s)=>{if(o)return r(o);n.length>0&&(s=n.concat(s)),r(null,s)})}_seek(e,r){this[I2]=!0,this[xf]=[],this[tp]=!1,this[Uv]=void 0,this[rp]={...this[Xc]};let n;try{n=eme(this[Xc])}catch{this[tp]=!0;return}n!==null&&!n.includes(e)?this[tp]=!0:this[Xc].reverse?this[rp].lte=e:this[rp].gte=e}};nme.Iterator=DL;function rme(t){typeof t.commit=="function"&&t.commit()}});var sme=V((vIt,ome)=>{"use strict";f();ome.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),d=0;s.oncomplete=function(){o()},s.onabort=function(){o(s.error||new Error("aborted by user"))};let u=a.openKeyCursor?"openKeyCursor":"openCursor",c=i.reverse?"prev":"next";a[u](n,c).onsuccess=function(l){let p=l.target.result;p&&(a.delete(p.key).onsuccess=function(){(i.limit<=0||++d{"use strict";f();var{AbstractLevel:kVe}=PL(),ame=Qu(),RVe=Ype(),{fromCallback:DVe}=kS(),{Iterator:BVe}=ime(),cme=kL(),MVe=sme(),OVe=IL(),ume="level-js-",FS=Symbol("idb"),BL=Symbol("namePrefix"),np=Symbol("location"),ML=Symbol("version"),qv=Symbol("store"),zS=Symbol("onComplete"),dme=Symbol("promise"),GI=class extends kVe{constructor(e,r,n){if(typeof r=="function"||typeof n=="function")throw new ame("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[np]=e,this[BL]=i??ume,this[ML]=parseInt(o||1,10),this[FS]=null}get location(){return this[np]}get namePrefix(){return this[BL]}get version(){return this[ML]}get db(){return this[FS]}get type(){return"browser-level"}_open(e,r){let n=indexedDB.open(this[BL]+this[np],this[ML]);n.onerror=function(){r(n.error||new Error("unknown error"))},n.onsuccess=()=>{this[FS]=n.result,r()},n.onupgradeneeded=i=>{let o=i.target.result;o.objectStoreNames.contains(this[np])||o.createObjectStore(this[np])}}[qv](e){return this[FS].transaction([this[np]],e).objectStore(this[np])}[zS](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[qv]("readonly"),o;try{o=i.get(e)}catch(s){return this.nextTick(n,s)}this[zS](o,function(s,a){if(s)return n(s);if(a===void 0)return n(new ame("Entry not found",{code:"LEVEL_NOT_FOUND"}));n(null,cme(a))})}_getMany(e,r,n){let i=this[qv]("readonly"),o=e.map(s=>a=>{let d;try{d=i.get(s)}catch(u){return a(u)}d.onsuccess=()=>{let u=d.result;a(null,u===void 0?u:cme(u))},d.onerror=u=>{u.stopPropagation(),a(d.error)}});RVe(o,16,n)}_del(e,r,n){let i=this[qv]("readwrite"),o;try{o=i.delete(e)}catch(s){return this.nextTick(n,s)}this[zS](o,n)}_put(e,r,n,i){let o=this[qv]("readwrite"),s;try{s=o.put(r,e)}catch(a){return this.nextTick(i,a)}this[zS](s,i)}_iterator(e){return new BVe(this,this[np],e)}_batch(e,r,n){let i=this[qv]("readwrite"),o=i.transaction,s=0,a;o.onabort=function(){n(a||o.error||new Error("aborted by user"))},o.oncomplete=function(){n()};function d(){let u=e[s++],c=u.key,l;try{l=u.type==="del"?i.delete(c):i.put(u.value,c)}catch(p){a=p,o.abort();return}s=0)return MVe(this,this[np],n,e,r);try{let o=this[qv]("readwrite");i=n?o.delete(n):o.clear()}catch(o){return this.nextTick(r,o)}this[zS](i,r)}_close(e){this[FS].close(),this.nextTick(e)}};GI.destroy=function(t,e,r){typeof e=="function"&&(r=e,e=ume),r=DVe(r,dme);let n=indexedDB.deleteDatabase(e+t);return n.onsuccess=function(){r()},n.onerror=function(i){r(i)},r[dme]};lme.BrowserLevel=GI});var WS=V(fme=>{f();fme.Level=OL().BrowserLevel});var Zi=V((kIt,hme)=>{"use strict";f();hme.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)},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,TypedArrayPrototypeSet(t,e,r){return t.set(e,r)},Uint8Array}});var Ef=V((DIt,$L)=>{"use strict";f();var $Ve=hn(),jVe=Object.getPrototypeOf(async function(){}).constructor,pme=globalThis.Blob||$Ve.Blob,NVe=typeof pme<"u"?function(e){return e instanceof pme}:function(e){return!1},CL=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{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 jVe},isArrayBufferView(t){return ArrayBuffer.isView(t)}},isBlob:NVe};$L.exports.promisify.custom=Symbol.for("nodejs.util.promisify.custom")});var ja=V((MIt,gme)=>{"use strict";f();var{format:UVe,inspect:ZI,AggregateError:qVe}=Ef(),LVe=globalThis.AggregateError||qVe,KVe=Symbol("kIsNodeError"),FVe=["string","function","number","object","Function","Object","boolean","bigint","symbol"],zVe=/^([A-Z][a-z0-9]*)+$/,WVe="__node_internal_",YI={};function Kv(t,e){if(!t)throw new YI.ERR_INTERNAL_ASSERTION(e)}function mme(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 HVe(t,e,r){if(typeof e=="function")return Kv(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 Kv(n===r.length,`Code: ${t}; The provided arguments length (${r.length}) does not match the required ones (${n}).`),r.length===0?e:UVe(e,...r)}function Ts(t,e,r){r||(r=Error);class n extends r{constructor(...o){super(HVe(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[KVe]=!0,YI[t]=n}function yme(t){let e=WVe+t.name;return Object.defineProperty(t,"name",{value:e}),t}function VVe(t,e){if(t&&e&&t!==e){if(Array.isArray(e.errors))return e.errors.push(t),e;let r=new LVe([e,t],e.message);return r.code=e.code,r}return t||e}var jL=class extends Error{constructor(e="The operation was aborted",r=void 0){if(r!==void 0&&typeof r!="object")throw new YI.ERR_INVALID_ARG_TYPE("options","Object",r);super(e,r),this.code="ABORT_ERR",this.name="AbortError"}};Ts("ERR_ASSERTION","%s",Error);Ts("ERR_INVALID_ARG_TYPE",(t,e,r)=>{Kv(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 d of e)Kv(typeof d=="string","All expected entries have to be of type string"),FVe.includes(d)?i.push(d.toLowerCase()):zVe.test(d)?o.push(d):(Kv(d!=="object",'The value "object" should be written as "Object"'),s.push(d));if(o.length>0){let d=i.indexOf("object");d!==-1&&(i.splice(i,d,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 d=i.pop();n+=`one of type ${i.join(", ")}, or ${d}`}}(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 d=o.pop();n+=`an instance of ${o.join(", ")}, or ${d}`}}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 d=s.pop();n+=`one of ${s.join(", ")}, or ${d}`}}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 d=ZI(r,{depth:-1});n+=`. Received ${d}`}}else{let d=ZI(r,{colors:!1});d.length>25&&(d=`${d.slice(0,25)}...`),n+=`. Received type ${typeof r} (${d})`}return n},TypeError);Ts("ERR_INVALID_ARG_VALUE",(t,e,r="is invalid")=>{let n=ZI(e);return n.length>128&&(n=n.slice(0,128)+"..."),`The ${t.includes(".")?"property":"argument"} '${t}' ${r}. Received ${n}`},TypeError);Ts("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);Ts("ERR_MISSING_ARGS",(...t)=>{Kv(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);Ts("ERR_OUT_OF_RANGE",(t,e,r)=>{Kv(e,'Missing "range" argument');let n;return Number.isInteger(r)&&Math.abs(r)>2**32?n=mme(String(r)):typeof r=="bigint"?(n=String(r),(r>2n**32n||r<-(2n**32n))&&(n=mme(n)),n+="n"):n=ZI(r),`The value of "${t}" is out of range. It must be ${e}. Received ${n}`},RangeError);Ts("ERR_MULTIPLE_CALLBACK","Callback called multiple times",Error);Ts("ERR_METHOD_NOT_IMPLEMENTED","The %s method is not implemented",Error);Ts("ERR_STREAM_ALREADY_FINISHED","Cannot call %s after a stream was finished",Error);Ts("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable",Error);Ts("ERR_STREAM_DESTROYED","Cannot call %s after a stream was destroyed",Error);Ts("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);Ts("ERR_STREAM_PREMATURE_CLOSE","Premature close",Error);Ts("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF",Error);Ts("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event",Error);Ts("ERR_STREAM_WRITE_AFTER_END","write after end",Error);Ts("ERR_UNKNOWN_ENCODING","Unknown encoding: %s",TypeError);gme.exports={AbortError:jL,aggregateTwoErrors:yme(VVe),hideStackFrames:yme,codes:YI}});var HS=V((CIt,Tme)=>{"use strict";f();var{ArrayIsArray:UL,ArrayPrototypeIncludes:_me,ArrayPrototypeJoin:xme,ArrayPrototypeMap:GVe,NumberIsInteger:qL,NumberIsNaN:JVe,NumberMAX_SAFE_INTEGER:ZVe,NumberMIN_SAFE_INTEGER:YVe,NumberParseInt:XVe,ObjectPrototypeHasOwnProperty:QVe,RegExpPrototypeExec:Eme,String:eGe,StringPrototypeToUpperCase:tGe,StringPrototypeTrim:rGe}=Zi(),{hideStackFrames:Gd,codes:{ERR_SOCKET_BAD_PORT:nGe,ERR_INVALID_ARG_TYPE:Na,ERR_INVALID_ARG_VALUE:k2,ERR_OUT_OF_RANGE:Fv,ERR_UNKNOWN_SIGNAL:vme}}=ja(),{normalizeEncoding:iGe}=Ef(),{isAsyncFunction:oGe,isArrayBufferView:sGe}=Ef().types,bme={};function aGe(t){return t===(t|0)}function cGe(t){return t===t>>>0}var dGe=/^[0-7]+$/,uGe="must be a 32-bit unsigned integer or an octal string";function lGe(t,e,r){if(typeof t>"u"&&(t=r),typeof t=="string"){if(Eme(dGe,t)===null)throw new k2(e,t,uGe);t=XVe(t,8)}return Sme(t,e),t}var fGe=Gd((t,e,r=YVe,n=ZVe)=>{if(typeof t!="number")throw new Na(e,"number",t);if(!qL(t))throw new Fv(e,"an integer",t);if(tn)throw new Fv(e,`>= ${r} && <= ${n}`,t)}),hGe=Gd((t,e,r=-2147483648,n=2147483647)=>{if(typeof t!="number")throw new Na(e,"number",t);if(!qL(t))throw new Fv(e,"an integer",t);if(tn)throw new Fv(e,`>= ${r} && <= ${n}`,t)}),Sme=Gd((t,e,r=!1)=>{if(typeof t!="number")throw new Na(e,"number",t);if(!qL(t))throw new Fv(e,"an integer",t);let n=r?1:0,i=4294967295;if(ti)throw new Fv(e,`>= ${n} && <= ${i}`,t)});function LL(t,e){if(typeof t!="string")throw new Na(e,"string",t)}function pGe(t,e,r=void 0,n){if(typeof t!="number")throw new Na(e,"number",t);if(r!=null&&tn||(r!=null||n!=null)&&JVe(t))throw new Fv(e,`${r!=null?`>= ${r}`:""}${r!=null&&n!=null?" && ":""}${n!=null?`<= ${n}`:""}`,t)}var mGe=Gd((t,e,r)=>{if(!_me(r,t)){let i="must be one of: "+xme(GVe(r,o=>typeof o=="string"?`'${o}'`:eGe(o)),", ");throw new k2(e,t,i)}});function Ame(t,e){if(typeof t!="boolean")throw new Na(e,"boolean",t)}function NL(t,e,r){return t==null||!QVe(t,e)?r:t[e]}var yGe=Gd((t,e,r=null)=>{let n=NL(r,"allowArray",!1),i=NL(r,"allowFunction",!1);if(!NL(r,"nullable",!1)&&t===null||!n&&UL(t)||typeof t!="object"&&(!i||typeof t!="function"))throw new Na(e,"Object",t)}),gGe=Gd((t,e)=>{if(t!=null&&typeof t!="object"&&typeof t!="function")throw new Na(e,"a dictionary",t)}),KL=Gd((t,e,r=0)=>{if(!UL(t))throw new Na(e,"Array",t);if(t.length{if(!sGe(t))throw new Na(e,["Buffer","TypedArray","DataView"],t)});function xGe(t,e){let r=iGe(e),n=t.length;if(r==="hex"&&n%2!==0)throw new k2("encoding",e,`is invalid for data of length ${n}`)}function EGe(t,e="Port",r=!0){if(typeof t!="number"&&typeof t!="string"||typeof t=="string"&&rGe(t).length===0||+t!==+t>>>0||t>65535||t===0&&!r)throw new nGe(e,t,r);return t|0}var SGe=Gd((t,e)=>{if(t!==void 0&&(t===null||typeof t!="object"||!("aborted"in t)))throw new Na(e,"AbortSignal",t)}),AGe=Gd((t,e)=>{if(typeof t!="function")throw new Na(e,"Function",t)}),TGe=Gd((t,e)=>{if(typeof t!="function"||oGe(t))throw new Na(e,"Function",t)}),PGe=Gd((t,e)=>{if(t!==void 0)throw new Na(e,"undefined",t)});function IGe(t,e,r){if(!_me(r,t))throw new Na(e,`('${xme(r,"|")}')`,t)}var kGe=/^(?:<[^>]*>)(?:\s*;\s*[^;"\s]+(?:=(")?[^;"\s]*\1)?)*$/;function wme(t,e){if(typeof t>"u"||!Eme(kGe,t))throw new k2(e,t,'must be an array or string of format "; rel=preload; as=style"')}function RGe(t){if(typeof t=="string")return wme(t,"hints"),t;if(UL(t)){let e=t.length,r="";if(e===0)return r;for(let n=0;n; rel=preload; as=style"')}Tme.exports={isInt32:aGe,isUint32:cGe,parseFileMode:lGe,validateArray:KL,validateStringArray:vGe,validateBooleanArray:bGe,validateBoolean:Ame,validateBuffer:_Ge,validateDictionary:gGe,validateEncoding:xGe,validateFunction:AGe,validateInt32:hGe,validateInteger:fGe,validateNumber:pGe,validateObject:yGe,validateOneOf:mGe,validatePlainFunction:TGe,validatePort:EGe,validateSignalName:wGe,validateString:LL,validateUint32:Sme,validateUndefined:PGe,validateUnion:IGe,validateAbortSignal:SGe,validateLinkHeaderValue:RGe}});var Af=V((jIt,Kme)=>{"use strict";f();var{Symbol:XI,SymbolAsyncIterator:Pme,SymbolIterator:Ime,SymbolFor:kme}=Zi(),Rme=XI("kDestroyed"),Dme=XI("kIsErrored"),FL=XI("kIsReadable"),Bme=XI("kIsDisturbed"),DGe=kme("nodejs.webstream.isClosedPromise"),BGe=kme("nodejs.webstream.controllerErrorFunction");function QI(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 ek(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 MGe(t){return!!(t&&typeof t.pipe=="function"&&t._readableState&&typeof t.on=="function"&&typeof t.write=="function")}function Sf(t){return t&&(t._readableState||t._writableState||typeof t.write=="function"&&typeof t.on=="function"||typeof t.pipe=="function"&&typeof t.on=="function")}function Mme(t){return!!(t&&!Sf(t)&&typeof t.pipeThrough=="function"&&typeof t.getReader=="function"&&typeof t.cancel=="function")}function Ome(t){return!!(t&&!Sf(t)&&typeof t.getWriter=="function"&&typeof t.abort=="function")}function Cme(t){return!!(t&&!Sf(t)&&typeof t.readable=="object"&&typeof t.writable=="object")}function OGe(t){return Mme(t)||Ome(t)||Cme(t)}function CGe(t,e){return t==null?!1:e===!0?typeof t[Pme]=="function":e===!1?typeof t[Ime]=="function":typeof t[Pme]=="function"||typeof t[Ime]=="function"}function tk(t){if(!Sf(t))return null;let e=t._writableState,r=t._readableState,n=e||r;return!!(t.destroyed||t[Rme]||n!=null&&n.destroyed)}function $me(t){if(!ek(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 $Ge(t,e){if(!ek(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 jGe(t){if(!QI(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 jme(t,e){if(!QI(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 Nme(t){return t&&t[FL]!=null?t[FL]:typeof t?.readable!="boolean"?null:tk(t)?!1:QI(t)&&t.readable&&!jme(t)}function Ume(t){return typeof t?.writable!="boolean"?null:tk(t)?!1:ek(t)&&t.writable&&!$me(t)}function NGe(t,e){return Sf(t)?tk(t)?!0:!(e?.readable!==!1&&Nme(t)||e?.writable!==!1&&Ume(t)):null}function UGe(t){var e,r;return Sf(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 qGe(t){var e,r;return Sf(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 LGe(t){if(!Sf(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"&&qme(t)?t._closed:null}function qme(t){return typeof t._closed=="boolean"&&typeof t._defaultKeepAlive=="boolean"&&typeof t._removedConnection=="boolean"&&typeof t._removedContLen=="boolean"}function Lme(t){return typeof t._sent100=="boolean"&&qme(t)}function KGe(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 FGe(t){if(!Sf(t))return null;let e=t._writableState,r=t._readableState,n=e||r;return!n&&Lme(t)||!!(n&&n.autoDestroy&&n.emitClose&&n.closed===!1)}function zGe(t){var e;return!!(t&&((e=t[Bme])!==null&&e!==void 0?e:t.readableDidRead||t.readableAborted))}function WGe(t){var e,r,n,i,o,s,a,d,u,c;return!!(t&&((e=(r=(n=(i=(o=(s=t[Dme])!==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:(d=t._writableState)===null||d===void 0?void 0:d.errorEmitted)!==null&&r!==void 0?r:(u=t._readableState)===null||u===void 0?void 0:u.errored)!==null&&e!==void 0?e:!((c=t._writableState)===null||c===void 0)&&c.errored))}Kme.exports={kDestroyed:Rme,isDisturbed:zGe,kIsDisturbed:Bme,isErrored:WGe,kIsErrored:Dme,isReadable:Nme,kIsReadable:FL,kIsClosedPromise:DGe,kControllerErrorFunction:BGe,isClosed:LGe,isDestroyed:tk,isDuplexNodeStream:MGe,isFinished:NGe,isIterable:CGe,isReadableNodeStream:QI,isReadableStream:Mme,isReadableEnded:jGe,isReadableFinished:jme,isReadableErrored:qGe,isNodeStream:Sf,isWebStream:OGe,isWritable:Ume,isWritableNodeStream:ek,isWritableStream:Ome,isWritableEnded:$me,isWritableFinished:$Ge,isWritableErrored:UGe,isServerRequest:KGe,isServerResponse:Lme,willEmitClose:FGe,isTransformStream:Cme}});var ip=V((UIt,GL)=>{f();var Ry=$s(),{AbortError:Yme,codes:HGe}=ja(),{ERR_INVALID_ARG_TYPE:VGe,ERR_STREAM_PREMATURE_CLOSE:Fme}=HGe,{kEmptyObject:WL,once:HL}=Ef(),{validateAbortSignal:GGe,validateFunction:JGe,validateObject:ZGe,validateBoolean:YGe}=HS(),{Promise:XGe,PromisePrototypeThen:QGe}=Zi(),{isClosed:eJe,isReadable:zme,isReadableNodeStream:zL,isReadableStream:tJe,isReadableFinished:Wme,isReadableErrored:Hme,isWritable:Vme,isWritableNodeStream:Gme,isWritableStream:rJe,isWritableFinished:Jme,isWritableErrored:Zme,isNodeStream:nJe,willEmitClose:iJe,kIsClosedPromise:oJe}=Af();function sJe(t){return t.setHeader&&typeof t.abort=="function"}var VL=()=>{};function Xme(t,e,r){var n,i;if(arguments.length===2?(r=e,e=WL):e==null?e=WL:ZGe(e,"options"),JGe(r,"callback"),GGe(e.signal,"options.signal"),r=HL(r),tJe(t)||rJe(t))return aJe(t,e,r);if(!nJe(t))throw new VGe("stream",["ReadableStream","WritableStream","Stream"],t);let o=(n=e.readable)!==null&&n!==void 0?n:zL(t),s=(i=e.writable)!==null&&i!==void 0?i:Gme(t),a=t._writableState,d=t._readableState,u=()=>{t.writable||p()},c=iJe(t)&&zL(t)===o&&Gme(t)===s,l=Jme(t,!1),p=()=>{l=!0,t.destroyed&&(c=!1),!(c&&(!t.readable||o))&&(!o||m)&&r.call(t)},m=Wme(t,!1),g=()=>{m=!0,t.destroyed&&(c=!1),!(c&&(!t.writable||s))&&(!s||l)&&r.call(t)},v=j=>{r.call(t,j)},x=eJe(t),S=()=>{x=!0;let j=Zme(t)||Hme(t);if(j&&typeof j!="boolean")return r.call(t,j);if(o&&!m&&zL(t,!0)&&!Wme(t,!1))return r.call(t,new Fme);if(s&&!l&&!Jme(t,!1))return r.call(t,new Fme);r.call(t)},P=()=>{x=!0;let j=Zme(t)||Hme(t);if(j&&typeof j!="boolean")return r.call(t,j);r.call(t)},A=()=>{t.req.on("finish",p)};sJe(t)?(t.on("complete",p),c||t.on("abort",S),t.req?A():t.on("request",A)):s&&!a&&(t.on("end",u),t.on("close",u)),!c&&typeof t.aborted=="boolean"&&t.on("aborted",S),t.on("end",g),t.on("finish",p),e.error!==!1&&t.on("error",v),t.on("close",S),x?Ry.nextTick(S):a!=null&&a.errorEmitted||d!=null&&d.errorEmitted?c||Ry.nextTick(P):(!o&&(!c||zme(t))&&(l||Vme(t)===!1)||!s&&(!c||Vme(t))&&(m||zme(t)===!1)||d&&t.req&&t.aborted)&&Ry.nextTick(P);let $=()=>{r=VL,t.removeListener("aborted",S),t.removeListener("complete",p),t.removeListener("abort",S),t.removeListener("request",A),t.req&&t.req.removeListener("finish",p),t.removeListener("end",u),t.removeListener("close",u),t.removeListener("finish",p),t.removeListener("end",g),t.removeListener("error",v),t.removeListener("close",S)};if(e.signal&&!x){let j=()=>{let L=r;$(),L.call(t,new Yme(void 0,{cause:e.signal.reason}))};if(e.signal.aborted)Ry.nextTick(j);else{let L=r;r=HL((...F)=>{e.signal.removeEventListener("abort",j),L.apply(t,F)}),e.signal.addEventListener("abort",j)}}return $}function aJe(t,e,r){let n=!1,i=VL;if(e.signal)if(i=()=>{n=!0,r.call(t,new Yme(void 0,{cause:e.signal.reason}))},e.signal.aborted)Ry.nextTick(i);else{let s=r;r=HL((...a)=>{e.signal.removeEventListener("abort",i),s.apply(t,a)}),e.signal.addEventListener("abort",i)}let o=(...s)=>{n||Ry.nextTick(()=>r.apply(t,s))};return QGe(t[oJe].promise,o,o),VL}function cJe(t,e){var r;let n=!1;return e===null&&(e=WL),(r=e)!==null&&r!==void 0&&r.cleanup&&(YGe(e.cleanup,"cleanup"),n=e.cleanup),new XGe((i,o)=>{let s=Xme(t,e,a=>{n&&s(),a?o(a):i()})})}GL.exports=Xme;GL.exports.finished=cJe});var zv=V((LIt,sye)=>{"use strict";f();var Tf=$s(),{aggregateTwoErrors:dJe,codes:{ERR_MULTIPLE_CALLBACK:uJe},AbortError:lJe}=ja(),{Symbol:tye}=Zi(),{kDestroyed:fJe,isDestroyed:hJe,isFinished:pJe,isServerRequest:mJe}=Af(),rye=tye("kDestroy"),JL=tye("kConstruct");function nye(t,e,r){t&&(t.stack,e&&!e.errored&&(e.errored=t),r&&!r.errored&&(r.errored=t))}function yJe(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):(nye(t,n,r),n&&(n.destroyed=!0),r&&(r.destroyed=!0),i.constructed?Qme(this,t,e):this.once(rye,function(o){Qme(this,dJe(o,t),e)}),this)}function Qme(t,e,r){let n=!1;function i(o){if(n)return;n=!0;let s=t._readableState,a=t._writableState;nye(o,a,s),a&&(a.closed=!0),s&&(s.closed=!0),typeof r=="function"&&r(o),o?Tf.nextTick(gJe,t,o):Tf.nextTick(iye,t)}try{t._destroy(e||null,i)}catch(o){i(o)}}function gJe(t,e){ZL(t,e),iye(t)}function iye(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 ZL(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 vJe(){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 YL(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?Tf.nextTick(ZL,t,e):ZL(t,e))}function bJe(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(JL,e),!(t.listenerCount(JL)>1)&&Tf.nextTick(wJe,t)}function wJe(t){let e=!1;function r(n){if(e){YL(t,n??new uJe);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(rye,n):n?YL(t,n,!0):Tf.nextTick(_Je,t)}try{t._construct(n=>{Tf.nextTick(r,n)})}catch(n){Tf.nextTick(r,n)}}function _Je(t){t.emit(JL)}function eye(t){return t?.setHeader&&typeof t.abort=="function"}function oye(t){t.emit("close")}function xJe(t,e){t.emit("error",e),Tf.nextTick(oye,t)}function EJe(t,e){!t||hJe(t)||(!e&&!pJe(t)&&(e=new lJe),mJe(t)?(t.socket=null,t.destroy(e)):eye(t)?t.abort():eye(t.req)?t.req.abort():typeof t.destroy=="function"?t.destroy(e):typeof t.close=="function"?t.close():e?Tf.nextTick(xJe,t,e):Tf.nextTick(oye,t),t.destroyed||(t[fJe]=!0))}sye.exports={construct:bJe,destroyer:EJe,destroy:yJe,undestroy:vJe,errorOrDestroy:YL}});var ik=V((FIt,cye)=>{"use strict";f();var{ArrayIsArray:SJe,ObjectSetPrototypeOf:aye}=Zi(),{EventEmitter:rk}=Sa();function nk(t){rk.call(this,t)}aye(nk.prototype,rk.prototype);aye(nk,rk);nk.prototype.pipe=function(t,e){let r=this;function n(c){t.writable&&t.write(c)===!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 d(c){u(),rk.listenerCount(this,"error")===0&&this.emit("error",c)}XL(r,"error",d),XL(t,"error",d);function u(){r.removeListener("data",n),t.removeListener("drain",i),r.removeListener("end",s),r.removeListener("close",a),r.removeListener("error",d),t.removeListener("error",d),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 XL(t,e,r){if(typeof t.prependListener=="function")return t.prependListener(e,r);!t._events||!t._events[e]?t.on(e,r):SJe(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]}cye.exports={Stream:nk,prependListener:XL}});var VS=V((WIt,ok)=>{"use strict";f();var{AbortError:dye,codes:AJe}=ja(),{isNodeStream:uye,isWebStream:TJe,kControllerErrorFunction:PJe}=Af(),IJe=ip(),{ERR_INVALID_ARG_TYPE:lye}=AJe,kJe=(t,e)=>{if(typeof t!="object"||!("aborted"in t))throw new lye(e,"AbortSignal",t)};ok.exports.addAbortSignal=function(e,r){if(kJe(e,"signal"),!uye(r)&&!TJe(r))throw new lye("stream",["ReadableStream","WritableStream","Stream"],r);return ok.exports.addAbortSignalNoValidate(e,r)};ok.exports.addAbortSignalNoValidate=function(t,e){if(typeof t!="object"||!("aborted"in t))return e;let r=uye(e)?()=>{e.destroy(new dye(void 0,{cause:t.reason}))}:()=>{e[PJe](new dye(void 0,{cause:t.reason}))};return t.aborted?r():(t.addEventListener("abort",r),IJe(e,()=>t.removeEventListener("abort",r))),e}});var pye=V((GIt,hye)=>{"use strict";f();var{StringPrototypeSlice:fye,SymbolIterator:RJe,TypedArrayPrototypeSet:sk,Uint8Array:DJe}=Zi(),{Buffer:QL}=hn(),{inspect:BJe}=Ef();hye.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 QL.alloc(0);let r=QL.allocUnsafe(e>>>0),n=this.head,i=0;for(;n;)sk(r,n.data,i),i+=n.data.length,n=n.next;return r}consume(e,r){let n=this.head.data;if(eo.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+=fye(o,0,e),this.head=n,n.data=fye(o,e));break}++i}while((n=n.next)!==null);return this.length-=i,r}_getBuffer(e){let r=QL.allocUnsafe(e),n=e,i=this.head,o=0;do{let s=i.data;if(e>s.length)sk(r,s,n-e),e-=s.length;else{e===s.length?(sk(r,s,n-e),++o,i.next?this.head=i.next:this.head=this.tail=null):(sk(r,new DJe(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 BJe(this,{...r,depth:0,customInspect:!1})}}});var ak=V((ZIt,yye)=>{"use strict";f();var{MathFloor:MJe,NumberIsInteger:OJe}=Zi(),{ERR_INVALID_ARG_VALUE:CJe}=ja().codes;function $Je(t,e,r){return t.highWaterMark!=null?t.highWaterMark:e?t[r]:null}function mye(t){return t?16:16*1024}function jJe(t,e,r,n){let i=$Je(e,n,r);if(i!=null){if(!OJe(i)||i<0){let o=n?`options.${r}`:"options.highWaterMark";throw new CJe(o,i)}return MJe(i)}return mye(t.objectMode)}yye.exports={getHighWaterMark:jJe,getDefaultHighWaterMark:mye}});var eK=V((XIt,wye)=>{"use strict";f();var gye=$s(),{PromisePrototypeThen:NJe,SymbolAsyncIterator:vye,SymbolIterator:bye}=Zi(),{Buffer:UJe}=hn(),{ERR_INVALID_ARG_TYPE:qJe,ERR_STREAM_NULL_VALUES:LJe}=ja().codes;function KJe(t,e,r){let n;if(typeof e=="string"||e instanceof UJe)return new t({objectMode:!0,...r,read(){this.push(e),this.push(null)}});let i;if(e&&e[vye])i=!0,n=e[vye]();else if(e&&e[bye])i=!1,n=e[bye]();else throw new qJe("iterable",["Iterable"],e);let o=new t({objectMode:!0,highWaterMark:1,...r}),s=!1;o._read=function(){s||(s=!0,d())},o._destroy=function(u,c){NJe(a(u),()=>gye.nextTick(c,u),l=>gye.nextTick(c,l||u))};async function a(u){let c=u!=null,l=typeof n.throw=="function";if(c&&l){let{value:p,done:m}=await n.throw(u);if(await p,m)return}if(typeof n.return=="function"){let{value:p}=await n.return();await p}}async function d(){for(;;){try{let{value:u,done:c}=i?await n.next():n.next();if(c)o.push(null);else{let l=u&&typeof u.then=="function"?await u:u;if(l===null)throw s=!1,new LJe;if(o.push(l))continue;s=!1}}catch(u){o.destroy(u)}break}}return o}wye.exports=KJe});var GS=V((ekt,Mye)=>{f();var rl=$s(),{ArrayPrototypeIndexOf:FJe,NumberIsInteger:zJe,NumberIsNaN:WJe,NumberParseInt:HJe,ObjectDefineProperties:Eye,ObjectKeys:VJe,ObjectSetPrototypeOf:Sye,Promise:GJe,SafeSet:JJe,SymbolAsyncIterator:ZJe,Symbol:YJe}=Zi();Mye.exports=xr;xr.ReadableState=sK;var{EventEmitter:XJe}=Sa(),{Stream:Dy,prependListener:QJe}=ik(),{Buffer:tK}=hn(),{addAbortSignal:eZe}=VS(),tZe=ip(),Or=Ef().debuglog("stream",t=>{Or=t}),rZe=pye(),D2=zv(),{getHighWaterMark:nZe,getDefaultHighWaterMark:iZe}=ak(),{aggregateTwoErrors:_ye,codes:{ERR_INVALID_ARG_TYPE:oZe,ERR_METHOD_NOT_IMPLEMENTED:sZe,ERR_OUT_OF_RANGE:aZe,ERR_STREAM_PUSH_AFTER_EOF:cZe,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:dZe}}=ja(),{validateObject:uZe}=HS(),Wv=YJe("kPaused"),{StringDecoder:Aye}=Rw(),lZe=eK();Sye(xr.prototype,Dy.prototype);Sye(xr,Dy);var rK=()=>{},{errorOrDestroy:R2}=D2;function sK(t,e,r){typeof r!="boolean"&&(r=e instanceof Pf()),this.objectMode=!!(t&&t.objectMode),r&&(this.objectMode=this.objectMode||!!(t&&t.readableObjectMode)),this.highWaterMark=t?nZe(this,t,"readableHighWaterMark",r):iZe(!1),this.buffer=new rZe,this.length=0,this.pipes=[],this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.constructed=!0,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this[Wv]=null,this.errorEmitted=!1,this.emitClose=!t||t.emitClose!==!1,this.autoDestroy=!t||t.autoDestroy!==!1,this.destroyed=!1,this.errored=null,this.closed=!1,this.closeEmitted=!1,this.defaultEncoding=t&&t.defaultEncoding||"utf8",this.awaitDrainWriters=null,this.multiAwaitDrain=!1,this.readingMore=!1,this.dataEmitted=!1,this.decoder=null,this.encoding=null,t&&t.encoding&&(this.decoder=new Aye(t.encoding),this.encoding=t.encoding)}function xr(t){if(!(this instanceof xr))return new xr(t);let e=this instanceof Pf();this._readableState=new sK(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&&eZe(t.signal,this)),Dy.call(this,t),D2.construct(this,()=>{this._readableState.needReadable&&ck(this,this._readableState)})}xr.prototype.destroy=D2.destroy;xr.prototype._undestroy=D2.undestroy;xr.prototype._destroy=function(t,e){e(t)};xr.prototype[XJe.captureRejectionSymbol]=function(t){this.destroy(t)};xr.prototype.push=function(t,e){return Tye(this,t,e,!1)};xr.prototype.unshift=function(t,e){return Tye(this,t,e,!0)};function Tye(t,e,r,n){Or("readableAddChunk",e);let i=t._readableState,o;if(i.objectMode||(typeof e=="string"?(r=r||i.defaultEncoding,i.encoding!==r&&(n&&i.encoding?e=tK.from(e,r).toString(i.encoding):(e=tK.from(e,r),r=""))):e instanceof tK?r="":Dy._isUint8Array(e)?(e=Dy._uint8ArrayToBuffer(e),r=""):e!=null&&(o=new oZe("chunk",["string","Buffer","Uint8Array"],e))),o)R2(t,o);else if(e===null)i.reading=!1,pZe(t,i);else if(i.objectMode||e&&e.length>0)if(n)if(i.endEmitted)R2(t,new dZe);else{if(i.destroyed||i.errored)return!1;nK(t,i,e,!0)}else if(i.ended)R2(t,new cZe);else{if(i.destroyed||i.errored)return!1;i.reading=!1,i.decoder&&!r?(e=i.decoder.write(e),i.objectMode||e.length!==0?nK(t,i,e,!1):ck(t,i)):nK(t,i,e,!1)}else n||(i.reading=!1,ck(t,i));return!i.ended&&(i.length0?(e.multiAwaitDrain?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.needReadable&&dk(t)),ck(t,e)}xr.prototype.isPaused=function(){let t=this._readableState;return t[Wv]===!0||t.flowing===!1};xr.prototype.setEncoding=function(t){let e=new Aye(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 fZe=1073741824;function hZe(t){if(t>fZe)throw new aZe("size","<= 1GiB",t);return t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++,t}function xye(t,e){return t<=0||e.length===0&&e.ended?0:e.objectMode?1:WJe(t)?e.flowing&&e.length?e.buffer.first().length:e.length:t<=e.length?t:e.ended?e.length:0}xr.prototype.read=function(t){Or("read",t),t===void 0?t=NaN:zJe(t)||(t=HJe(t,10));let e=this._readableState,r=t;if(t>e.highWaterMark&&(e.highWaterMark=hZe(t)),t!==0&&(e.emittedReadable=!1),t===0&&e.needReadable&&((e.highWaterMark!==0?e.length>=e.highWaterMark:e.length>0)||e.ended))return Or("read: emitReadable",e.length,e.ended),e.length===0&&e.ended?iK(this):dk(this),null;if(t=xye(t,e),t===0&&e.ended)return e.length===0&&iK(this),null;let n=e.needReadable;if(Or("need readable",n),(e.length===0||e.length-t0?i=Dye(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&&iK(this)),i!==null&&!e.errorEmitted&&!e.closeEmitted&&(e.dataEmitted=!0,this.emit("data",i)),i};function pZe(t,e){if(Or("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?dk(t):(e.needReadable=!1,e.emittedReadable=!0,Pye(t))}}function dk(t){let e=t._readableState;Or("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(Or("emitReadable",e.flowing),e.emittedReadable=!0,rl.nextTick(Pye,t))}function Pye(t){let e=t._readableState;Or("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,kye(t)}function ck(t,e){!e.readingMore&&e.constructed&&(e.readingMore=!0,rl.nextTick(mZe,t,e))}function mZe(t,e){for(;!e.reading&&!e.ended&&(e.length1&&n.pipes.includes(t)&&(Or("false write response, pause",n.awaitDrainWriters.size),n.awaitDrainWriters.add(t)),r.pause()),d||(d=yZe(r,t),t.on("drain",d))}r.on("data",p);function p(S){Or("ondata");let P=t.write(S);Or("dest.write",P),P===!1&&l()}function m(S){if(Or("onerror",S),x(),t.removeListener("error",m),t.listenerCount("error")===0){let P=t._writableState||t._readableState;P&&!P.errorEmitted?R2(t,S):t.emit("error",S)}}QJe(t,"error",m);function g(){t.removeListener("finish",v),x()}t.once("close",g);function v(){Or("onfinish"),t.removeListener("close",g),x()}t.once("finish",v);function x(){Or("unpipe"),r.unpipe(t)}return t.emit("pipe",r),t.writableNeedDrain===!0?n.flowing&&l():n.flowing||(Or("pipe resume"),r.resume()),t};function yZe(t,e){return function(){let n=t._readableState;n.awaitDrainWriters===e?(Or("pipeOnDrain",1),n.awaitDrainWriters=null):n.multiAwaitDrain&&(Or("pipeOnDrain",n.awaitDrainWriters.size),n.awaitDrainWriters.delete(e)),(!n.awaitDrainWriters||n.awaitDrainWriters.size===0)&&t.listenerCount("data")&&t.resume()}}xr.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;o0,n.flowing!==!1&&this.resume()):t==="readable"&&!n.endEmitted&&!n.readableListening&&(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,Or("on readable",n.length,n.reading),n.length?dk(this):n.reading||rl.nextTick(gZe,this)),r};xr.prototype.addListener=xr.prototype.on;xr.prototype.removeListener=function(t,e){let r=Dy.prototype.removeListener.call(this,t,e);return t==="readable"&&rl.nextTick(Iye,this),r};xr.prototype.off=xr.prototype.removeListener;xr.prototype.removeAllListeners=function(t){let e=Dy.prototype.removeAllListeners.apply(this,arguments);return(t==="readable"||t===void 0)&&rl.nextTick(Iye,this),e};function Iye(t){let e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&e[Wv]===!1?e.flowing=!0:t.listenerCount("data")>0?t.resume():e.readableListening||(e.flowing=null)}function gZe(t){Or("readable nexttick read 0"),t.read(0)}xr.prototype.resume=function(){let t=this._readableState;return t.flowing||(Or("resume"),t.flowing=!t.readableListening,vZe(this,t)),t[Wv]=!1,this};function vZe(t,e){e.resumeScheduled||(e.resumeScheduled=!0,rl.nextTick(bZe,t,e))}function bZe(t,e){Or("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),kye(t),e.flowing&&!e.reading&&t.read(0)}xr.prototype.pause=function(){return Or("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(Or("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState[Wv]=!0,this};function kye(t){let e=t._readableState;for(Or("flow",e.flowing);e.flowing&&t.read()!==null;);}xr.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=>{R2(this,n)}),t.on("close",()=>{this.destroy()}),t.on("destroy",()=>{this.destroy()}),this._read=()=>{e&&t.resume&&(e=!1,t.resume())};let r=VJe(t);for(let n=1;n{i=s?_ye(i,s):null,r(),r=rK});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 GJe(n)}}}catch(s){throw i=_ye(i,s),i}finally{(i||e?.destroyOnReturn!==!1)&&(i===void 0||t._readableState.autoDestroy)?D2.destroyer(t,null):(t.off("readable",n),o())}}Eye(xr.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}}});Eye(sK.prototype,{pipesCount:{__proto__:null,get(){return this.pipes.length}},paused:{__proto__:null,get(){return this[Wv]!==!1},set(t){this[Wv]=!!t}}});xr._fromList=Dye;function Dye(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 iK(t){let e=t._readableState;Or("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,rl.nextTick(_Ze,e,t))}function _Ze(t,e){if(Or("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)rl.nextTick(xZe,e);else if(t.autoDestroy){let r=e._writableState;(!r||r.autoDestroy&&(r.finished||r.writable===!1))&&e.destroy()}}}function xZe(t){t.writable&&!t.writableEnded&&!t.destroyed&&t.end()}xr.from=function(t,e){return lZe(xr,t,e)};var oK;function Bye(){return oK===void 0&&(oK={}),oK}xr.fromWeb=function(t,e){return Bye().newStreamReadableFromReadableStream(t,e)};xr.toWeb=function(t,e){return Bye().newReadableStreamFromStreamReadable(t,e)};xr.wrap=function(t,e){var r,n;return new xr({objectMode:(r=(n=t.readableObjectMode)!==null&&n!==void 0?n:t.objectMode)!==null&&r!==void 0?r:!0,...e,destroy(i,o){D2.destroyer(t,i),o(i)}}).wrap(t)}});var hK=V((rkt,Wye)=>{f();var Hv=$s(),{ArrayPrototypeSlice:$ye,Error:EZe,FunctionPrototypeSymbolHasInstance:jye,ObjectDefineProperty:Nye,ObjectDefineProperties:SZe,ObjectSetPrototypeOf:Uye,StringPrototypeToLowerCase:AZe,Symbol:TZe,SymbolHasInstance:PZe}=Zi();Wye.exports=ci;ci.WritableState=YS;var{EventEmitter:IZe}=Sa(),JS=ik().Stream,{Buffer:uk}=hn(),hk=zv(),{addAbortSignal:kZe}=VS(),{getHighWaterMark:RZe,getDefaultHighWaterMark:DZe}=ak(),{ERR_INVALID_ARG_TYPE:BZe,ERR_METHOD_NOT_IMPLEMENTED:MZe,ERR_MULTIPLE_CALLBACK:qye,ERR_STREAM_CANNOT_PIPE:OZe,ERR_STREAM_DESTROYED:ZS,ERR_STREAM_ALREADY_FINISHED:CZe,ERR_STREAM_NULL_VALUES:$Ze,ERR_STREAM_WRITE_AFTER_END:jZe,ERR_UNKNOWN_ENCODING:Lye}=ja().codes,{errorOrDestroy:B2}=hk;Uye(ci.prototype,JS.prototype);Uye(ci,JS);function dK(){}var M2=TZe("kOnFinished");function YS(t,e,r){typeof r!="boolean"&&(r=e instanceof Pf()),this.objectMode=!!(t&&t.objectMode),r&&(this.objectMode=this.objectMode||!!(t&&t.writableObjectMode)),this.highWaterMark=t?RZe(this,t,"writableHighWaterMark",r):DZe(!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=UZe.bind(void 0,e),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,fk(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[M2]=[]}function fk(t){t.buffered=[],t.bufferedIndex=0,t.allBuffers=!0,t.allNoop=!0}YS.prototype.getBuffer=function(){return $ye(this.buffered,this.bufferedIndex)};Nye(YS.prototype,"bufferedRequestCount",{__proto__:null,get(){return this.buffered.length-this.bufferedIndex}});function ci(t){let e=this instanceof Pf();if(!e&&!jye(ci,this))return new ci(t);this._writableState=new YS(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&&kZe(t.signal,this)),JS.call(this,t),hk.construct(this,()=>{let r=this._writableState;r.writing||lK(this,r),fK(this,r)})}Nye(ci,PZe,{__proto__:null,value:function(t){return jye(this,t)?!0:this!==ci?!1:t&&t._writableState instanceof YS}});ci.prototype.pipe=function(){B2(this,new OZe)};function Kye(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"&&!uk.isEncoding(r))throw new Lye(r);typeof n!="function"&&(n=dK)}if(e===null)throw new $Ze;if(!i.objectMode)if(typeof e=="string")i.decodeStrings!==!1&&(e=uk.from(e,r),r="buffer");else if(e instanceof uk)r="buffer";else if(JS._isUint8Array(e))e=JS._uint8ArrayToBuffer(e),r="buffer";else throw new BZe("chunk",["string","Buffer","Uint8Array"],e);let o;return i.ending?o=new jZe:i.destroyed&&(o=new ZS("write")),o?(Hv.nextTick(n,o),B2(t,o,!0),o):(i.pendingcb++,NZe(t,i,e,r,n))}ci.prototype.write=function(t,e,r){return Kye(this,t,e,r)===!0};ci.prototype.cork=function(){this._writableState.corked++};ci.prototype.uncork=function(){let t=this._writableState;t.corked&&(t.corked--,t.writing||lK(this,t))};ci.prototype.setDefaultEncoding=function(e){if(typeof e=="string"&&(e=AZe(e)),!uk.isEncoding(e))throw new Lye(e);return this._writableState.defaultEncoding=e,this};function NZe(t,e,r,n,i){let o=e.objectMode?1:r.length;e.length+=o;let s=e.lengthr.bufferedIndex&&lK(t,r),n?r.afterWriteTickInfo!==null&&r.afterWriteTickInfo.cb===i?r.afterWriteTickInfo.count++:(r.afterWriteTickInfo={count:1,cb:i,stream:t,state:r},Hv.nextTick(qZe,r.afterWriteTickInfo)):Fye(t,r,1,i))}function qZe({stream:t,state:e,count:r,cb:n}){return e.afterWriteTickInfo=null,Fye(t,e,r,n)}function Fye(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&&uK(e),fK(t,e)}function uK(t){if(t.writing)return;for(let i=t.bufferedIndex;i1&&t._writev){e.pendingcb-=o-1;let a=e.allNoop?dK:u=>{for(let c=s;c256?(r.splice(0,s),e.bufferedIndex=0):e.bufferedIndex=s}e.bufferProcessing=!1}ci.prototype._write=function(t,e,r){if(this._writev)this._writev([{chunk:t,encoding:e}],r);else throw new MZe("_write()")};ci.prototype._writev=null;ci.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=Kye(this,t,e);o instanceof EZe&&(i=o)}return n.corked&&(n.corked=1,this.uncork()),i||(!n.errored&&!n.ending?(n.ending=!0,fK(this,n,!0),n.ended=!0):n.finished?i=new CZe("end"):n.destroyed&&(i=new ZS("end"))),typeof r=="function"&&(i||n.finished?Hv.nextTick(r,i):n[M2].push(r)),this};function lk(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 LZe(t,e){let r=!1;function n(i){if(r){B2(t,i??qye());return}if(r=!0,e.pendingcb--,i){let o=e[M2].splice(0);for(let s=0;s{lk(i)?cK(n,i):i.pendingcb--},t,e)):lk(e)&&(e.pendingcb++,cK(t,e))))}function cK(t,e){e.pendingcb--,e.finished=!0;let r=e[M2].splice(0);for(let n=0;n{f();var pK=$s(),zZe=hn(),{isReadable:WZe,isWritable:HZe,isIterable:Hye,isNodeStream:VZe,isReadableNodeStream:Vye,isWritableNodeStream:Gye,isDuplexNodeStream:GZe}=Af(),Jye=ip(),{AbortError:t0e,codes:{ERR_INVALID_ARG_TYPE:JZe,ERR_INVALID_RETURN_VALUE:Zye}}=ja(),{destroyer:O2}=zv(),ZZe=Pf(),YZe=GS(),{createDeferredPromise:Yye}=Ef(),Xye=eK(),Qye=globalThis.Blob||zZe.Blob,XZe=typeof Qye<"u"?function(e){return e instanceof Qye}:function(e){return!1},QZe=globalThis.AbortController||Rh().AbortController,{FunctionPrototypeCall:e0e}=Zi(),Vv=class extends ZZe{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)}};r0e.exports=function t(e,r){if(GZe(e))return e;if(Vye(e))return pk({readable:e});if(Gye(e))return pk({writable:e});if(VZe(e))return pk({writable:!1,readable:!1});if(typeof e=="function"){let{value:i,write:o,final:s,destroy:a}=eYe(e);if(Hye(i))return Xye(Vv,i,{objectMode:!0,write:o,final:s,destroy:a});let d=i?.then;if(typeof d=="function"){let u,c=e0e(d,i,l=>{if(l!=null)throw new Zye("nully","body",l)},l=>{O2(u,l)});return u=new Vv({objectMode:!0,readable:!1,write:o,final(l){s(async()=>{try{await c,pK.nextTick(l,null)}catch(p){pK.nextTick(l,p)}})},destroy:a})}throw new Zye("Iterable, AsyncIterable or AsyncFunction",r,i)}if(XZe(e))return t(e.arrayBuffer());if(Hye(e))return Xye(Vv,e,{objectMode:!0,writable:!1});if(typeof e?.writable=="object"||typeof e?.readable=="object"){let i=e!=null&&e.readable?Vye(e?.readable)?e?.readable:t(e.readable):void 0,o=e!=null&&e.writable?Gye(e?.writable)?e?.writable:t(e.writable):void 0;return pk({readable:i,writable:o})}let n=e?.then;if(typeof n=="function"){let i;return e0e(n,e,o=>{o!=null&&i.push(o),i.push(null)},o=>{O2(i,o)}),i=new Vv({objectMode:!0,writable:!1,read(){}})}throw new JZe(r,["Blob","ReadableStream","WritableStream","Stream","Iterable","AsyncIterable","Function","{ readable, writable } pair","Promise"],e)};function eYe(t){let{promise:e,resolve:r}=Yye(),n=new QZe,i=n.signal;return{value:t(async function*(){for(;;){let s=e;e=null;let{chunk:a,done:d,cb:u}=await s;if(pK.nextTick(u),d)return;if(i.aborted)throw new t0e(void 0,{cause:i.reason});({promise:e,resolve:r}=Yye()),yield a}}(),{signal:i}),write(s,a,d){let u=r;r=null,u({chunk:s,done:!1,cb:d})},final(s){let a=r;r=null,a({done:!0,cb:s})},destroy(s,a){n.abort(),a(s)}}}function pk(t){let e=t.readable&&typeof t.readable.read!="function"?YZe.wrap(t.readable):t.readable,r=t.writable,n=!!WZe(e),i=!!HZe(r),o,s,a,d,u;function c(l){let p=d;d=null,p?p(l):l&&u.destroy(l)}return u=new Vv({readableObjectMode:!!(e!=null&&e.readableObjectMode),writableObjectMode:!!(r!=null&&r.writableObjectMode),readable:n,writable:i}),i&&(Jye(r,l=>{i=!1,l&&O2(e,l),c(l)}),u._write=function(l,p,m){r.write(l,p)?m():o=m},u._final=function(l){r.end(),s=l},r.on("drain",function(){if(o){let l=o;o=null,l()}}),r.on("finish",function(){if(s){let l=s;s=null,l()}})),n&&(Jye(e,l=>{n=!1,l&&O2(e,l),c(l)}),e.on("readable",function(){if(a){let l=a;a=null,l()}}),e.on("end",function(){u.push(null)}),u._read=function(){for(;;){let l=e.read();if(l===null){a=u._read;return}if(!u.push(l))return}}),u._destroy=function(l,p){!l&&d!==null&&(l=new t0e),a=null,o=null,s=null,d===null?p(l):(d=p,O2(r,l),O2(e,l))},u}});var Pf=V((skt,s0e)=>{"use strict";f();var{ObjectDefineProperties:tYe,ObjectGetOwnPropertyDescriptor:op,ObjectKeys:rYe,ObjectSetPrototypeOf:i0e}=Zi();s0e.exports=nl;var gK=GS(),Jd=hK();i0e(nl.prototype,gK.prototype);i0e(nl,gK);{let t=rYe(Jd.prototype);for(let e=0;e{"use strict";f();var{ObjectSetPrototypeOf:a0e,Symbol:nYe}=Zi();c0e.exports=sp;var{ERR_METHOD_NOT_IMPLEMENTED:iYe}=ja().codes,bK=Pf(),{getHighWaterMark:oYe}=ak();a0e(sp.prototype,bK.prototype);a0e(sp,bK);var XS=nYe("kCallback");function sp(t){if(!(this instanceof sp))return new sp(t);let e=t?oYe(this,t,"readableHighWaterMark",!0):null;e===0&&(t={...t,highWaterMark:null,readableHighWaterMark:e,writableHighWaterMark:t.writableHighWaterMark||0}),bK.call(this,t),this._readableState.sync=!1,this[XS]=null,t&&(typeof t.transform=="function"&&(this._transform=t.transform),typeof t.flush=="function"&&(this._flush=t.flush)),this.on("prefinish",sYe)}function vK(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 sYe(){this._final!==vK&&vK.call(this)}sp.prototype._final=vK;sp.prototype._transform=function(t,e,r){throw new iYe("_transform()")};sp.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{"use strict";f();var{ObjectSetPrototypeOf:d0e}=Zi();u0e.exports=C2;var _K=wK();d0e(C2.prototype,_K.prototype);d0e(C2,_K);function C2(t){if(!(this instanceof C2))return new C2(t);_K.call(this,t)}C2.prototype._transform=function(t,e,r){r(null,t)}});var vk=V((fkt,m0e)=>{f();var QS=$s(),{ArrayIsArray:aYe,Promise:cYe,SymbolAsyncIterator:dYe}=Zi(),gk=ip(),{once:uYe}=Ef(),lYe=zv(),l0e=Pf(),{aggregateTwoErrors:fYe,codes:{ERR_INVALID_ARG_TYPE:RK,ERR_INVALID_RETURN_VALUE:EK,ERR_MISSING_ARGS:hYe,ERR_STREAM_DESTROYED:pYe,ERR_STREAM_PREMATURE_CLOSE:mYe},AbortError:yYe}=ja(),{validateFunction:gYe,validateAbortSignal:vYe}=HS(),{isIterable:Gv,isReadable:SK,isReadableNodeStream:yk,isNodeStream:f0e,isTransformStream:$2,isWebStream:bYe,isReadableStream:AK,isReadableEnded:wYe}=Af(),_Ye=globalThis.AbortController||Rh().AbortController,TK,PK;function h0e(t,e,r){let n=!1;t.on("close",()=>{n=!0});let i=gk(t,{readable:e,writable:r},o=>{n=!o});return{destroy:o=>{n||(n=!0,lYe.destroyer(t,o||new pYe("pipe")))},cleanup:i}}function xYe(t){return gYe(t[t.length-1],"streams[stream.length - 1]"),t.pop()}function IK(t){if(Gv(t))return t;if(yk(t))return EYe(t);throw new RK("val",["Readable","Iterable","AsyncIterable"],t)}async function*EYe(t){PK||(PK=GS()),yield*PK.prototype[dYe].call(t)}async function mk(t,e,r,{end:n}){let i,o=null,s=u=>{if(u&&(i=u),o){let c=o;o=null,c()}},a=()=>new cYe((u,c)=>{i?c(i):o=()=>{i?c(i):u()}});e.on("drain",s);let d=gk(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?fYe(i,u):u)}finally{d(),e.off("drain",s)}}async function kK(t,e,r,{end:n}){$2(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 SYe(...t){return p0e(t,uYe(xYe(t)))}function p0e(t,e,r){if(t.length===1&&aYe(t[0])&&(t=t[0]),t.length<2)throw new hYe("streams");let n=new _Ye,i=n.signal,o=r?.signal,s=[];vYe(o,"options.signal");function a(){m(new yYe)}o?.addEventListener("abort",a);let d,u,c=[],l=0;function p(P){m(P,--l===0)}function m(P,A){if(P&&(!d||d.code==="ERR_STREAM_PREMATURE_CLOSE")&&(d=P),!(!d&&!A)){for(;c.length;)c.shift()(d);o?.removeEventListener("abort",a),n.abort(),A&&(d||s.forEach($=>$()),QS.nextTick(e,d,u))}}let g;for(let P=0;P0,L=$||r?.end!==!1,F=P===t.length-1;if(f0e(A)){let K=function(W){W&&W.name!=="AbortError"&&W.code!=="ERR_STREAM_PREMATURE_CLOSE"&&p(W)};var S=K;if(L){let{destroy:W,cleanup:q}=h0e(A,$,j);c.push(W),SK(A)&&F&&s.push(q)}A.on("error",K),SK(A)&&F&&s.push(()=>{A.removeListener("error",K)})}if(P===0)if(typeof A=="function"){if(g=A({signal:i}),!Gv(g))throw new EK("Iterable, AsyncIterable or Stream","source",g)}else Gv(A)||yk(A)||$2(A)?g=A:g=l0e.from(A);else if(typeof A=="function"){if($2(g)){var v;g=IK((v=g)===null||v===void 0?void 0:v.readable)}else g=IK(g);if(g=A(g,{signal:i}),$){if(!Gv(g,!0))throw new EK("AsyncIterable",`transform[${P-1}]`,g)}else{var x;TK||(TK=xK());let K=new TK({objectMode:!0}),W=(x=g)===null||x===void 0?void 0:x.then;if(typeof W=="function")l++,W.call(g,T=>{u=T,T!=null&&K.write(T),L&&K.end(),QS.nextTick(p)},T=>{K.destroy(T),QS.nextTick(p,T)});else if(Gv(g,!0))l++,mk(g,K,p,{end:L});else if(AK(g)||$2(g)){let T=g.readable||g;l++,mk(T,K,p,{end:L})}else throw new EK("AsyncIterable or Promise","destination",g);g=K;let{destroy:q,cleanup:I}=h0e(g,!1,!0);c.push(q),F&&s.push(I)}}else if(f0e(A)){if(yk(g)){l+=2;let K=AYe(g,A,p,{end:L});SK(A)&&F&&s.push(K)}else if($2(g)||AK(g)){let K=g.readable||g;l++,mk(K,A,p,{end:L})}else if(Gv(g))l++,mk(g,A,p,{end:L});else throw new RK("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],g);g=A}else if(bYe(A)){if(yk(g))l++,kK(IK(g),A,p,{end:L});else if(AK(g)||Gv(g))l++,kK(g,A,p,{end:L});else if($2(g))l++,kK(g.readable,A,p,{end:L});else throw new RK("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],g);g=A}else g=l0e.from(A)}return(i!=null&&i.aborted||o!=null&&o.aborted)&&QS.nextTick(a),g}function AYe(t,e,r,{end:n}){let i=!1;if(e.on("close",()=>{i||r(new mYe)}),t.pipe(e,{end:!1}),n){let s=function(){i=!0,e.end()};var o=s;wYe(t)?QS.nextTick(s):t.once("end",s)}else r();return gk(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)}),gk(e,{readable:!1,writable:!0},r)}m0e.exports={pipelineImpl:p0e,pipeline:SYe}});var BK=V((pkt,_0e)=>{"use strict";f();var{pipeline:TYe}=vk(),bk=Pf(),{destroyer:PYe}=zv(),{isNodeStream:wk,isReadable:y0e,isWritable:g0e,isWebStream:DK,isTransformStream:Jv,isWritableStream:v0e,isReadableStream:b0e}=Af(),{AbortError:IYe,codes:{ERR_INVALID_ARG_VALUE:w0e,ERR_MISSING_ARGS:kYe}}=ja(),RYe=ip();_0e.exports=function(...e){if(e.length===0)throw new kYe("streams");if(e.length===1)return bk.from(e[0]);let r=[...e];if(typeof e[0]=="function"&&(e[0]=bk.from(e[0])),typeof e[e.length-1]=="function"){let m=e.length-1;e[m]=bk.from(e[m])}for(let m=0;m0&&!(g0e(e[m])||v0e(e[m])||Jv(e[m])))throw new w0e(`streams[${m}]`,r[m],"must be writable")}let n,i,o,s,a;function d(m){let g=s;s=null,g?g(m):m?a.destroy(m):!p&&!l&&a.destroy()}let u=e[0],c=TYe(e,d),l=!!(g0e(u)||v0e(u)||Jv(u)),p=!!(y0e(c)||b0e(c)||Jv(c));if(a=new bk({writableObjectMode:!!(u!=null&&u.writableObjectMode),readableObjectMode:!!(c!=null&&c.writableObjectMode),writable:l,readable:p}),l){if(wk(u))a._write=function(g,v,x){u.write(g,v)?x():n=x},a._final=function(g){u.end(),i=g},u.on("drain",function(){if(n){let g=n;n=null,g()}});else if(DK(u)){let v=(Jv(u)?u.writable:u).getWriter();a._write=async function(x,S,P){try{await v.ready,v.write(x).catch(()=>{}),P()}catch(A){P(A)}},a._final=async function(x){try{await v.ready,v.close().catch(()=>{}),i=x}catch(S){x(S)}}}let m=Jv(c)?c.readable:c;RYe(m,()=>{if(i){let g=i;i=null,g()}})}if(p){if(wk(c))c.on("readable",function(){if(o){let m=o;o=null,m()}}),c.on("end",function(){a.push(null)}),a._read=function(){for(;;){let m=c.read();if(m===null){o=a._read;return}if(!a.push(m))return}};else if(DK(c)){let g=(Jv(c)?c.readable:c).getReader();a._read=async function(){for(;;)try{let{value:v,done:x}=await g.read();if(!a.push(v))return;if(x){a.push(null);return}}catch{return}}}}return a._destroy=function(m,g){!m&&s!==null&&(m=new IYe),o=null,n=null,i=null,s===null?g(m):(s=g,wk(c)&&PYe(c,m))},a}});var k0e=V((ykt,CK)=>{"use strict";f();var A0e=globalThis.AbortController||Rh().AbortController,{codes:{ERR_INVALID_ARG_VALUE:DYe,ERR_INVALID_ARG_TYPE:e3,ERR_MISSING_ARGS:BYe,ERR_OUT_OF_RANGE:MYe},AbortError:If}=ja(),{validateAbortSignal:Zv,validateInteger:OYe,validateObject:Yv}=HS(),CYe=Zi().Symbol("kWeak"),{finished:$Ye}=ip(),jYe=BK(),{addAbortSignalNoValidate:NYe}=VS(),{isWritable:UYe,isNodeStream:qYe}=Af(),{ArrayPrototypePush:LYe,MathFloor:KYe,Number:FYe,NumberIsNaN:zYe,Promise:x0e,PromiseReject:E0e,PromisePrototypeThen:WYe,Symbol:T0e}=Zi(),_k=T0e("kEmpty"),S0e=T0e("kEof");function HYe(t,e){if(e!=null&&Yv(e,"options"),e?.signal!=null&&Zv(e.signal,"options.signal"),qYe(t)&&!UYe(t))throw new DYe("stream",t,"must be writable");let r=jYe(this,t);return e!=null&&e.signal&&NYe(e.signal,r),r}function xk(t,e){if(typeof t!="function")throw new e3("fn",["Function","AsyncFunction"],t);e!=null&&Yv(e,"options"),e?.signal!=null&&Zv(e.signal,"options.signal");let r=1;return e?.concurrency!=null&&(r=KYe(e.concurrency)),OYe(r,"concurrency",1),(async function*(){var i,o;let s=new A0e,a=this,d=[],u=s.signal,c={signal:u},l=()=>s.abort();e!=null&&(i=e.signal)!==null&&i!==void 0&&i.aborted&&l(),e==null||(o=e.signal)===null||o===void 0||o.addEventListener("abort",l);let p,m,g=!1;function v(){g=!0}async function x(){try{for await(let A of a){var S;if(g)return;if(u.aborted)throw new If;try{A=t(A,c)}catch($){A=E0e($)}A!==_k&&(typeof((S=A)===null||S===void 0?void 0:S.catch)=="function"&&A.catch(v),d.push(A),p&&(p(),p=null),!g&&d.length&&d.length>=r&&await new x0e($=>{m=$}))}d.push(S0e)}catch(A){let $=E0e(A);WYe($,void 0,v),d.push($)}finally{var P;g=!0,p&&(p(),p=null),e==null||(P=e.signal)===null||P===void 0||P.removeEventListener("abort",l)}}x();try{for(;;){for(;d.length>0;){let S=await d[0];if(S===S0e)return;if(u.aborted)throw new If;S!==_k&&(yield S),d.shift(),m&&(m(),m=null)}await new x0e(S=>{p=S})}}finally{s.abort(),g=!0,m&&(m(),m=null)}}).call(this)}function VYe(t=void 0){return t!=null&&Yv(t,"options"),t?.signal!=null&&Zv(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 If({cause:t.signal.reason});yield[r++,i]}}).call(this)}async function P0e(t,e=void 0){for await(let r of OK.call(this,t,e))return!0;return!1}async function GYe(t,e=void 0){if(typeof t!="function")throw new e3("fn",["Function","AsyncFunction"],t);return!await P0e.call(this,async(...r)=>!await t(...r),e)}async function JYe(t,e){for await(let r of OK.call(this,t,e))return r}async function ZYe(t,e){if(typeof t!="function")throw new e3("fn",["Function","AsyncFunction"],t);async function r(n,i){return await t(n,i),_k}for await(let n of xk.call(this,r,e));}function OK(t,e){if(typeof t!="function")throw new e3("fn",["Function","AsyncFunction"],t);async function r(n,i){return await t(n,i)?n:_k}return xk.call(this,r,e)}var MK=class extends BYe{constructor(){super("reduce"),this.message="Reduce of an empty stream requires an initial value"}};async function YYe(t,e,r){var n;if(typeof t!="function")throw new e3("reducer",["Function","AsyncFunction"],t);r!=null&&Yv(r,"options"),r?.signal!=null&&Zv(r.signal,"options.signal");let i=arguments.length>1;if(r!=null&&(n=r.signal)!==null&&n!==void 0&&n.aborted){let u=new If(void 0,{cause:r.signal.reason});throw this.once("error",()=>{}),await $Ye(this.destroy(u)),u}let o=new A0e,s=o.signal;if(r!=null&&r.signal){let u={once:!0,[CYe]:this};r.signal.addEventListener("abort",()=>o.abort(),u)}let a=!1;try{for await(let u of this){var d;if(a=!0,r!=null&&(d=r.signal)!==null&&d!==void 0&&d.aborted)throw new If;i?e=await t(e,u,{signal:s}):(e=u,i=!0)}if(!a&&!i)throw new MK}finally{o.abort()}return e}async function XYe(t){t!=null&&Yv(t,"options"),t?.signal!=null&&Zv(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 If(void 0,{cause:t.signal.reason});LYe(e,n)}return e}function QYe(t,e){let r=xk.call(this,t,e);return(async function*(){for await(let i of r)yield*i}).call(this)}function I0e(t){if(t=FYe(t),zYe(t))return 0;if(t<0)throw new MYe("number",">= 0",t);return t}function eXe(t,e=void 0){return e!=null&&Yv(e,"options"),e?.signal!=null&&Zv(e.signal,"options.signal"),t=I0e(t),(async function*(){var n;if(e!=null&&(n=e.signal)!==null&&n!==void 0&&n.aborted)throw new If;for await(let o of this){var i;if(e!=null&&(i=e.signal)!==null&&i!==void 0&&i.aborted)throw new If;t--<=0&&(yield o)}}).call(this)}function tXe(t,e=void 0){return e!=null&&Yv(e,"options"),e?.signal!=null&&Zv(e.signal,"options.signal"),t=I0e(t),(async function*(){var n;if(e!=null&&(n=e.signal)!==null&&n!==void 0&&n.aborted)throw new If;for await(let o of this){var i;if(e!=null&&(i=e.signal)!==null&&i!==void 0&&i.aborted)throw new If;if(t-- >0)yield o;else return}}).call(this)}CK.exports.streamReturningOperators={asIndexedPairs:VYe,drop:eXe,filter:OK,flatMap:QYe,map:xk,take:tXe,compose:HYe};CK.exports.promiseReturningOperators={every:GYe,forEach:ZYe,reduce:YYe,toArray:XYe,some:P0e,find:JYe}});var $K=V((vkt,R0e)=>{"use strict";f();var{ArrayPrototypePop:rXe,Promise:nXe}=Zi(),{isIterable:iXe,isNodeStream:oXe,isWebStream:sXe}=Af(),{pipelineImpl:aXe}=vk(),{finished:cXe}=ip();jK();function dXe(...t){return new nXe((e,r)=>{let n,i,o=t[t.length-1];if(o&&typeof o=="object"&&!oXe(o)&&!iXe(o)&&!sXe(o)){let s=rXe(t);n=s.signal,i=s.end}aXe(t,(s,a)=>{s?r(s):e(a)},{signal:n,end:i})})}R0e.exports={finished:cXe,pipeline:dXe}});var jK=V((wkt,U0e)=>{f();var{Buffer:uXe}=hn(),{ObjectDefineProperty:ap,ObjectKeys:M0e,ReflectApply:O0e}=Zi(),{promisify:{custom:C0e}}=Ef(),{streamReturningOperators:D0e,promiseReturningOperators:B0e}=k0e(),{codes:{ERR_ILLEGAL_CONSTRUCTOR:$0e}}=ja(),lXe=BK(),{pipeline:j0e}=vk(),{destroyer:fXe}=zv(),N0e=ip(),NK=$K(),UK=Af(),Ci=U0e.exports=ik().Stream;Ci.isDisturbed=UK.isDisturbed;Ci.isErrored=UK.isErrored;Ci.isReadable=UK.isReadable;Ci.Readable=GS();for(let t of M0e(D0e)){let r=function(...n){if(new.target)throw $0e();return Ci.Readable.from(O0e(e,this,n))};qK=r;let e=D0e[t];ap(r,"name",{__proto__:null,value:e.name}),ap(r,"length",{__proto__:null,value:e.length}),ap(Ci.Readable.prototype,t,{__proto__:null,value:r,enumerable:!1,configurable:!0,writable:!0})}var qK;for(let t of M0e(B0e)){let r=function(...i){if(new.target)throw $0e();return O0e(e,this,i)};qK=r;let e=B0e[t];ap(r,"name",{__proto__:null,value:e.name}),ap(r,"length",{__proto__:null,value:e.length}),ap(Ci.Readable.prototype,t,{__proto__:null,value:r,enumerable:!1,configurable:!0,writable:!0})}var qK;Ci.Writable=hK();Ci.Duplex=Pf();Ci.Transform=wK();Ci.PassThrough=xK();Ci.pipeline=j0e;var{addAbortSignal:hXe}=VS();Ci.addAbortSignal=hXe;Ci.finished=N0e;Ci.destroy=fXe;Ci.compose=lXe;ap(Ci,"promises",{__proto__:null,configurable:!0,enumerable:!0,get(){return NK}});ap(j0e,C0e,{__proto__:null,enumerable:!0,get(){return NK.pipeline}});ap(N0e,C0e,{__proto__:null,enumerable:!0,get(){return NK.finished}});Ci.Stream=Ci;Ci._isUint8Array=function(e){return e instanceof Uint8Array};Ci._uint8ArrayToBuffer=function(e){return uXe.from(e.buffer,e.byteOffset,e.byteLength)}});var t3=V((xkt,$i)=>{"use strict";f();var po=jK(),pXe=$K(),mXe=po.Readable.destroy;$i.exports=po.Readable;$i.exports._uint8ArrayToBuffer=po._uint8ArrayToBuffer;$i.exports._isUint8Array=po._isUint8Array;$i.exports.isDisturbed=po.isDisturbed;$i.exports.isErrored=po.isErrored;$i.exports.isReadable=po.isReadable;$i.exports.Readable=po.Readable;$i.exports.Writable=po.Writable;$i.exports.Duplex=po.Duplex;$i.exports.Transform=po.Transform;$i.exports.PassThrough=po.PassThrough;$i.exports.addAbortSignal=po.addAbortSignal;$i.exports.finished=po.finished;$i.exports.destroy=po.destroy;$i.exports.destroy=mXe;$i.exports.pipeline=po.pipeline;$i.exports.compose=po.compose;Object.defineProperty(po,"promises",{configurable:!0,enumerable:!0,get(){return pXe}});$i.exports.Stream=po.Stream;$i.exports.default=$i.exports});var p3=V(Cge=>{f();Cge.Level=OL().BrowserLevel});var gve=V((aOt,yve)=>{"use strict";f();yve.exports=function t(e){if(typeof e=="number"&&isNaN(e))throw new Error("NaN is not allowed");if(typeof e=="number"&&!isFinite(e))throw new Error("Infinity is not allowed");return e===null||typeof e!="object"?JSON.stringify(e):e.toJSON instanceof Function?t(e.toJSON()):Array.isArray(e)?`[${e.reduce((i,o,s)=>`${i}${s===0?"":","}${t(o===void 0||typeof o=="symbol"?null:o)}`,"")}]`:`{${Object.keys(e).sort().reduce((n,i)=>{if(e[i]===void 0||typeof e[i]=="symbol")return n;let o=n.length===0?"":",";return`${n}${o}${t(i)}:${t(e[i])}`},"")}}`}});var db=V((YCt,Sve)=>{f();var n_=1e3,i_=n_*60,o_=i_*60,cb=o_*24,zet=cb*7,Wet=cb*365.25;Sve.exports=function(t,e){e=e||{};var r=typeof t;if(r==="string"&&t.length>0)return Het(t);if(r==="number"&&isFinite(t))return e.long?Get(t):Vet(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))};function Het(t){if(t=String(t),!(t.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(e){var r=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*Wet;case"weeks":case"week":case"w":return r*zet;case"days":case"day":case"d":return r*cb;case"hours":case"hour":case"hrs":case"hr":case"h":return r*o_;case"minutes":case"minute":case"mins":case"min":case"m":return r*i_;case"seconds":case"second":case"secs":case"sec":case"s":return r*n_;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function Vet(t){var e=Math.abs(t);return e>=cb?Math.round(t/cb)+"d":e>=o_?Math.round(t/o_)+"h":e>=i_?Math.round(t/i_)+"m":e>=n_?Math.round(t/n_)+"s":t+"ms"}function Get(t){var e=Math.abs(t);return e>=cb?lR(t,e,cb,"day"):e>=o_?lR(t,e,o_,"hour"):e>=i_?lR(t,e,i_,"minute"):e>=n_?lR(t,e,n_,"second"):t+" ms"}function lR(t,e,r,n){var i=e>=r*1.5;return Math.round(t/r)+" "+n+(i?"s":"")}});var nwe=V((kUt,HF)=>{"use strict";f();var Qtt=Object.prototype.hasOwnProperty,Ka="~";function C3(){}Object.create&&(C3.prototype=Object.create(null),new C3().__proto__||(Ka=!1));function ert(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function rwe(t,e,r,n,i){if(typeof r!="function")throw new TypeError("The listener must be a function");var o=new ert(r,n||t,i),s=Ka?Ka+e:e;return t._events[s]?t._events[s].fn?t._events[s]=[t._events[s],o]:t._events[s].push(o):(t._events[s]=o,t._eventsCount++),t}function DR(t,e){--t._eventsCount===0?t._events=new C3:delete t._events[e]}function ua(){this._events=new C3,this._eventsCount=0}ua.prototype.eventNames=function(){var e=[],r,n;if(this._eventsCount===0)return e;for(n in r=this._events)Qtt.call(r,n)&&e.push(Ka?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(r)):e};ua.prototype.listeners=function(e){var r=Ka?Ka+e:e,n=this._events[r];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,o=n.length,s=new Array(o);i{"use strict";f();Object.defineProperty(lD,"__esModule",{value:!0});lD.ReadableWebToNodeStream=void 0;var ont=G7(),gz=class extends ont.Readable{constructor(e){super(),this.bytesRead=0,this.released=!1,this.reader=e.getReader()}async _read(){if(this.released){this.push(null);return}this.pendingRead=this.reader.read();let e=await this.pendingRead;delete this.pendingRead,e.done||this.released?this.push(null):(this.bytesRead+=e.value.length,this.push(e.value))}async waitForReadToComplete(){this.pendingRead&&await this.pendingRead}async close(){await this.syncAndRelease()}async syncAndRelease(){this.released=!0,await this.waitForReadToComplete(),await this.reader.releaseLock()}};lD.ReadableWebToNodeStream=gz});var nit={};Pr(nit,{DidApi:()=>k5,DwnApi:()=>M5,PermissionGrant:()=>Kf,PermissionGrantRevocation:()=>B5,PermissionRequest:()=>$_,Protocol:()=>C_,Record:()=>Up,VcApi:()=>O5,Web5:()=>$z,utils:()=>Cz});f();f();f();f();f();f();f();f();var sV=gt(RW(),1);f();f();f();f();function i_e(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n>>0,$=new Uint8Array(A);S!==P;){for(var j=g[S],L=0,F=A-1;(j!==0||L>>0,$[F]=j%a>>>0,j=j/a>>>0;if(j!==0)throw new Error("Non-zero carry");x=L,S++}for(var K=A-x;K!==A&&$[K]===0;)K++;for(var W=d.repeat(v);K>>0,A=new Uint8Array(P);g[v];){var $=r[g.charCodeAt(v)];if($===255)return;for(var j=0,L=P-1;($!==0||j>>0,A[L]=$%256>>>0,$=$/256>>>0;if($!==0)throw new Error("Non-zero carry");S=j,v++}if(g[v]!==" "){for(var F=P-S;F!==P&&A[F]===0;)F++;for(var K=new Uint8Array(x+(P-F)),W=x;F!==P;)K[W++]=A[F++];return K}}}function m(g){var v=p(g);if(v)return v;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:p,decode:m}}var o_e=i_e,s_e=o_e,DW=s_e;f();var Wit=new Uint8Array(0);var BW=(t,e)=>{if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r{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")};f();var WD=class{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")}},HD=class{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 OW(this,e)}},VD=class{constructor(e){this.decoders=e}or(e){return OW(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},OW=(t,e)=>new VD({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),GD=class{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new WD(e,r,n),this.decoder=new HD(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},CW=({name:t,prefix:e,encode:r,decode:n})=>new GD(t,e,r,n),JD=({prefix:t,name:e,alphabet:r})=>{let{encode:n,decode:i}=DW(r,e);return CW({prefix:t,name:e,encode:n,decode:o=>hu(i(o))})},a_e=(t,e,r,n)=>{let i={};for(let c=0;c=8&&(a-=8,s[u++]=255&d>>a)}if(a>=r||255&d<<8-a)throw new SyntaxError("Unexpected end of data");return s},c_e=(t,e,r)=>{let n=e[e.length-1]==="=",i=(1<r;)s-=r,o+=e[i&a>>s];if(s&&(o+=e[i&a<CW({prefix:e,name:t,encode(i){return c_e(i,n,r)},decode(i){return a_e(i,n,r,t)}});var eot=ma({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),tot=ma({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ya=ma({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),rot=ma({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var ZD=new TextEncoder,d_e=new TextDecoder,qe=class t{static base64UrlToBytes(e){return ya.baseDecode(e)}static base64UrlToObject(e){let r=ya.baseDecode(e);return t.bytesToObject(r)}static bytesToBase64Url(e){return ya.baseEncode(e)}static bytesToString(e){return d_e.decode(e)}static bytesToObject(e){let r=t.bytesToString(e);return JSON.parse(r)}static objectToBytes(e){let r=JSON.stringify(e);return ZD.encode(r)}static stringToBase64Url(e){let r=ZD.encode(e);return ya.baseEncode(r)}static stringToBytes(e){return ZD.encode(e)}};f();f();f();f();var Qo=2n**255n-19n,qb=2n**252n+27742317777372353535851937790883648493n,YD=0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,XD=0x6666666666666666666666666666666666666666666666666666666666666658n,L5={a:-1n,d:37095705934669439343138083508754565189542113879843219016388785533085940283555n,p:Qo,n:qb,h:8,Gx:YD,Gy:XD},ga=(t="")=>{throw new Error(t)},qW=t=>typeof t=="string",z5=(t,e)=>!(t instanceof Uint8Array)||typeof e=="number"&&e>0&&t.length!==e?ga("Uint8Array expected"):t,Lb=t=>new Uint8Array(t),Kb=(t,e)=>z5(qW(t)?e9(t):Lb(t),e),vt=(t,e=Qo)=>{let r=t%e;return r>=0n?r:e+r},$W=t=>t instanceof El?t:ga("Point expected"),jW,El=class t{constructor(e,r,n,i){this.ex=e,this.ey=r,this.ez=n,this.et=i}static fromAffine(e){return new t(e.x,e.y,1n,vt(e.x*e.y))}static fromHex(e,r=!0){let{d:n}=L5;e=Kb(e,32);let i=e.slice();i[31]=e[31]&-129;let o=t9(i);o===0n||(r&&!(0n0n;o=o.double(),e>>=1n)e&1n?n=n.add(o):r&&(i=i.add(o));return n}multiply(e){return this.mul(e)}clearCofactor(){return this.mul(BigInt(L5.h),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let e=this.mul(qb/2n,!1).double();return qb%2n&&(e=e.add(this)),e.is0()}toAffine(){let{ex:e,ey:r,ez:n}=this;if(this.is0())return{x:0n,y:0n};let i=FW(n);return vt(n*i)!==1n&&ga("invalid inverse"),{x:vt(e*i),y:vt(r*i)}}toRawBytes(){let{x:e,y:r}=this.toAffine(),n=KW(r);return n[31]|=e&1n?128:0,n}toHex(){return QD(this.toRawBytes())}};El.BASE=new El(YD,XD,1n,vt(YD*XD));El.ZERO=new El(0n,1n,1n,0n);var{BASE:Fp,ZERO:K5}=El,LW=(t,e)=>t.toString(16).padStart(e,"0"),QD=t=>Array.from(t).map(e=>LW(e,2)).join(""),e9=t=>{let e=t.length;(!qW(t)||e%2)&&ga("hex invalid 1");let r=Lb(e/2);for(let n=0;ne9(LW(t,32*2)).reverse(),t9=t=>BigInt("0x"+QD(Lb(z5(t)).reverse())),F_=(...t)=>{let e=Lb(t.reduce((n,i)=>n+z5(i).length,0)),r=0;return t.forEach(n=>{e.set(n,r),r+=n.length}),e},FW=(t,e=Qo)=>{(t===0n||e<=0n)&&ga("no inverse n="+t+" mod="+e);let r=vt(t,e),n=e,i=0n,o=1n,s=1n,a=0n;for(;r!==0n;){let d=n/r,u=n%r,c=i-s*d,l=o-a*d;n=r,r=u,i=s,o=a,s=c,a=l}return n===1n?vt(i,e):ga("no inverse")},xl=(t,e)=>{let r=t;for(;e-- >0n;)r*=r,r%=Qo;return r},u_e=t=>{let r=t*t%Qo*t%Qo,n=xl(r,2n)*r%Qo,i=xl(n,1n)*t%Qo,o=xl(i,5n)*i%Qo,s=xl(o,10n)*o%Qo,a=xl(s,20n)*s%Qo,d=xl(a,40n)*a%Qo,u=xl(d,80n)*d%Qo,c=xl(u,80n)*d%Qo,l=xl(c,10n)*o%Qo;return{pow_p_5_8:xl(l,2n)*t%Qo,b2:r}},NW=19681161376707505956807079304988542015446066515923890162744021073123829784752n,l_e=(t,e)=>{let r=vt(e*e*e),n=vt(r*r*e),i=u_e(t*n).pow_p_5_8,o=vt(t*r*i),s=vt(e*o*o),a=o,d=vt(o*NW),u=s===t,c=s===vt(-t),l=s===vt(-t*NW);return u&&(o=a),(c||l)&&(o=d),(vt(o)&1n)===1n&&(o=vt(-o)),{isValid:u||c,value:o}},F5=t=>vt(t9(t),qb),K_,r9=(...t)=>i9.sha512Async(...t),zW=(...t)=>typeof K_=="function"?K_(...t):ga("etc.sha512Sync not set"),WW=t=>{let e=t.slice(0,32);e[0]&=248,e[31]&=127,e[31]|=64;let r=t.slice(32,64),n=F5(e),i=Fp.mul(n),o=i.toRawBytes();return{head:e,prefix:r,scalar:n,point:i,pointBytes:o}},n9=t=>r9(Kb(t,32)).then(WW),f_e=t=>WW(zW(Kb(t,32))),HW=t=>n9(t).then(e=>e.pointBytes);function VW(t,e){return t?r9(e.hashable).then(e.finish):e.finish(zW(e.hashable))}var h_e=(t,e,r)=>{let{pointBytes:n,scalar:i}=t,o=F5(e),s=Fp.mul(o).toRawBytes();return{hashable:F_(s,n,r),finish:u=>{let c=vt(o+F5(u)*i,qb);return z5(F_(s,KW(c)),64)}}},GW=async(t,e)=>{let r=Kb(t),n=await n9(e),i=await r9(n.prefix,r);return VW(!0,h_e(n,i,r))};var p_e=(t,e,r)=>{e=Kb(e),t=Kb(t,64);let n=El.fromHex(r,!1),i=El.fromHex(t.slice(0,32),!1),o=t9(t.slice(32,64)),s=Fp.mul(o,!1);return{hashable:F_(i.toRawBytes(),n.toRawBytes(),e),finish:u=>{let c=F5(u);return i.add(n.mul(c,!1)).add(s.negate()).clearCofactor().is0()}}},JW=async(t,e,r)=>VW(!0,p_e(t,e,r));var UW=()=>typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0,i9={bytesToHex:QD,hexToBytes:e9,concatBytes:F_,mod:vt,invert:FW,randomBytes:t=>{let e=UW();return e||ga("crypto.getRandomValues must be defined"),e.getRandomValues(Lb(t))},sha512Async:async(...t)=>{let e=UW();e||ga("crypto.subtle or etc.sha512Async must be defined");let r=F_(...t);return Lb(await e.subtle.digest("SHA-512",r.buffer))},sha512Sync:void 0};Object.defineProperties(i9,{sha512Sync:{configurable:!1,get(){return K_},set(t){K_||(K_=t)}}});var ZW={getExtendedPublicKeyAsync:n9,getExtendedPublicKey:f_e,randomPrivateKey:()=>i9.randomBytes(32),precompute(t=8,e=Fp){return e.multiply(3n),e}},E0=8,m_e=()=>{let t=[],e=256/E0+1,r=Fp,n=r;for(let i=0;i{let e=jW||(jW=m_e()),r=(c,l)=>{let p=l.negate();return c?p:l},n=K5,i=Fp,o=1+256/E0,s=2**(E0-1),a=BigInt(2**E0-1),d=2**E0,u=BigInt(E0);for(let c=0;c>=u,p>s&&(p-=d,t+=1n);let m=l,g=l+Math.abs(p)-1,v=c%2!==0,x=p<0;p===0?i=i.add(r(v,e[m])):n=n.add(r(x,e[g]))}return{p:n,f:i}};f();var de=class extends Error{constructor(e,r){super(`${e}: ${r}`),this.code=e,this.name="DwnError"}},se;(function(t){t.AuthenticateJwsMissing="AuthenticateJwsMissing",t.AuthenticateDescriptorCidMismatch="AuthenticateDescriptorCidMismatch",t.AuthenticationMoreThanOneSignatureNotSupported="AuthenticationMoreThanOneSignatureNotSupported",t.AuthorizationNotGrantedToAuthor="AuthorizationNotGrantedToAuthor",t.ComputeCidCodecNotSupported="ComputeCidCodecNotSupported",t.ComputeCidMultihashNotSupported="ComputeCidMultihashNotSupported",t.Ed25519InvalidJwk="Ed25519InvalidJwk",t.EventEmitterStreamNotOpenError="EventEmitterStreamNotOpenError",t.MessagesGrantAuthorizationMismatchedProtocol="EventsGrantAuthorizationMismatchedProtocol",t.MessagesSubscribeAuthorizationFailed="MessagesSubscribeAuthorizationFailed",t.MessagesSubscribeEventStreamUnimplemented="MessagesSubscribeEventStreamUnimplemented",t.GeneralJwsVerifierGetPublicKeyNotFound="GeneralJwsVerifierGetPublicKeyNotFound",t.GeneralJwsVerifierInvalidSignature="GeneralJwsVerifierInvalidSignature",t.GrantAuthorizationGrantExpired="GrantAuthorizationGrantExpired",t.GrantAuthorizationGrantMissing="GrantAuthorizationGrantMissing",t.GrantAuthorizationGrantRevoked="GrantAuthorizationGrantRevoked",t.GrantAuthorizationInterfaceMismatch="GrantAuthorizationInterfaceMismatch",t.GrantAuthorizationMethodMismatch="GrantAuthorizationMethodMismatch",t.GrantAuthorizationNotGrantedForTenant="GrantAuthorizationNotGrantedForTenant",t.GrantAuthorizationNotGrantedToAuthor="GrantAuthorizationNotGrantedToAuthor",t.GrantAuthorizationGrantNotYetActive="GrantAuthorizationGrantNotYetActive",t.HdKeyDerivationPathInvalid="HdKeyDerivationPathInvalid",t.JwsVerifySignatureUnsupportedCrv="JwsVerifySignatureUnsupportedCrv",t.IndexInvalidCursorValueType="IndexInvalidCursorValueType",t.IndexInvalidCursorSortProperty="IndexInvalidCursorSortProperty",t.IndexInvalidSortPropertyInMemory="IndexInvalidSortPropertyInMemory",t.IndexMissingIndexableProperty="IndexMissingIndexableProperty",t.JwsDecodePlainObjectPayloadInvalid="JwsDecodePlainObjectPayloadInvalid",t.MessagesReadInvalidCid="MessagesReadInvalidCid",t.MessagesReadAuthorizationFailed="MessagesReadAuthorizationFailed",t.MessageGetInvalidCid="MessageGetInvalidCid",t.MessagesQueryAuthorizationFailed="MessagesQueryAuthorizationFailed",t.MessagesReadVerifyScopeFailed="MessagesReadVerifyScopeFailed",t.ParseCidCodecNotSupported="ParseCidCodecNotSupported",t.ParseCidMultihashNotSupported="ParseCidMultihashNotSupported",t.PermissionsProtocolCreateGrantRecordsScopeMissingProtocol="PermissionsProtocolCreateGrantRecordsScopeMissingProtocol",t.PermissionsProtocolCreateRequestRecordsScopeMissingProtocol="PermissionsProtocolCreateRequestRecordsScopeMissingProtocol",t.PermissionsProtocolGetScopeInvalidProtocol="PermissionsProtocolGetScopeInvalidProtocol",t.PermissionsProtocolValidateSchemaUnexpectedRecord="PermissionsProtocolValidateSchemaUnexpectedRecord",t.PermissionsProtocolValidateScopeContextIdProhibitedProperties="PermissionsProtocolValidateScopeContextIdProhibitedProperties",t.PermissionsProtocolValidateScopeProtocolMismatch="PermissionsProtocolValidateScopeProtocolMismatch",t.PermissionsProtocolValidateScopeMissingProtocolTag="PermissionsProtocolValidateScopeMissingProtocolTag",t.PermissionsProtocolValidateRevocationProtocolTagMismatch="PermissionsProtocolValidateRevocationProtocolTagMismatch",t.PrivateKeySignerUnableToDeduceAlgorithm="PrivateKeySignerUnableToDeduceAlgorithm",t.PrivateKeySignerUnableToDeduceKeyId="PrivateKeySignerUnableToDeduceKeyId",t.PrivateKeySignerUnsupportedCurve="PrivateKeySignerUnsupportedCurve",t.ProtocolAuthorizationActionNotAllowed="ProtocolAuthorizationActionNotAllowed",t.ProtocolAuthorizationActionRulesNotFound="ProtocolAuthorizationActionRulesNotFound",t.ProtocolAuthorizationIncorrectDataFormat="ProtocolAuthorizationIncorrectDataFormat",t.ProtocolAuthorizationIncorrectContextId="ProtocolAuthorizationIncorrectContextId",t.ProtocolAuthorizationIncorrectProtocolPath="ProtocolAuthorizationIncorrectProtocolPath",t.ProtocolAuthorizationDuplicateRoleRecipient="ProtocolAuthorizationDuplicateRoleRecipient",t.ProtocolAuthorizationInvalidSchema="ProtocolAuthorizationInvalidSchema",t.ProtocolAuthorizationInvalidType="ProtocolAuthorizationInvalidType",t.ProtocolAuthorizationMatchingRoleRecordNotFound="ProtocolAuthorizationMatchingRoleRecordNotFound",t.ProtocolAuthorizationMaxSizeInvalid="ProtocolAuthorizationMaxSizeInvalid",t.ProtocolAuthorizationMinSizeInvalid="ProtocolAuthorizationMinSizeInvalid",t.ProtocolAuthorizationMissingContextId="ProtocolAuthorizationMissingContextId",t.ProtocolAuthorizationMissingRuleSet="ProtocolAuthorizationMissingRuleSet",t.ProtocolAuthorizationParentlessIncorrectProtocolPath="ProtocolAuthorizationParentlessIncorrectProtocolPath",t.ProtocolAuthorizationNotARole="ProtocolAuthorizationNotARole",t.ProtocolAuthorizationParentNotFoundConstructingRecordChain="ProtocolAuthorizationParentNotFoundConstructingRecordChain",t.ProtocolAuthorizationProtocolNotFound="ProtocolAuthorizationProtocolNotFound",t.ProtocolAuthorizationRoleMissingRecipient="ProtocolAuthorizationRoleMissingRecipient",t.ProtocolAuthorizationTagsInvalidSchema="ProtocolAuthorizationTagsInvalidSchema",t.ProtocolsConfigureAuthorizationFailed="ProtocolsConfigureAuthorizationFailed",t.ProtocolsConfigureDuplicateActorInRuleSet="ProtocolsConfigureDuplicateActorInRuleSet",t.ProtocolsConfigureDuplicateRoleInRuleSet="ProtocolsConfigureDuplicateRoleInRuleSet",t.ProtocolsConfigureInvalidSize="ProtocolsConfigureInvalidSize",t.ProtocolsConfigureInvalidActionMissingOf="ProtocolsConfigureInvalidActionMissingOf",t.ProtocolsConfigureInvalidActionOfNotAllowed="ProtocolsConfigureInvalidActionOfNotAllowed",t.ProtocolsConfigureInvalidActionDeleteWithoutCreate="ProtocolsConfigureInvalidActionDeleteWithoutCreate",t.ProtocolsConfigureInvalidActionUpdateWithoutCreate="ProtocolsConfigureInvalidActionUpdateWithoutCreate",t.ProtocolsConfigureInvalidRecipientOfAction="ProtocolsConfigureInvalidRecipientOfAction",t.ProtocolsConfigureInvalidRuleSetRecordType="ProtocolsConfigureInvalidRuleSetRecordType",t.ProtocolsConfigureInvalidTagSchema="ProtocolsConfigureInvalidTagSchema",t.ProtocolsConfigureRecordNestingDepthExceeded="ProtocolsConfigureRecordNestingDepthExceeded",t.ProtocolsConfigureRoleDoesNotExistAtGivenPath="ProtocolsConfigureRoleDoesNotExistAtGivenPath",t.ProtocolsGrantAuthorizationQueryProtocolScopeMismatch="ProtocolsGrantAuthorizationQueryProtocolScopeMismatch",t.ProtocolsGrantAuthorizationScopeProtocolMismatch="ProtocolsGrantAuthorizationScopeProtocolMismatch",t.ProtocolsQueryUnauthorized="ProtocolsQueryUnauthorized",t.RecordsAuthorDelegatedGrantAndIdExistenceMismatch="RecordsAuthorDelegatedGrantAndIdExistenceMismatch",t.RecordsAuthorDelegatedGrantCidMismatch="RecordsAuthorDelegatedGrantCidMismatch",t.RecordsAuthorDelegatedGrantGrantedToAndOwnerSignatureMismatch="RecordsAuthorDelegatedGrantGrantedToAndOwnerSignatureMismatch",t.RecordsAuthorDelegatedGrantNotADelegatedGrant="RecordsAuthorDelegatedGrantNotADelegatedGrant",t.RecordsDecryptNoMatchingKeyEncryptedFound="RecordsDecryptNoMatchingKeyEncryptedFound",t.RecordsDeleteAuthorizationFailed="RecordsDeleteAuthorizationFailed",t.RecordsQueryCreateFilterPublishedSortInvalid="RecordsQueryCreateFilterPublishedSortInvalid",t.RecordsQueryParseFilterPublishedSortInvalid="RecordsQueryParseFilterPublishedSortInvalid",t.RecordsGrantAuthorizationConditionPublicationProhibited="RecordsGrantAuthorizationConditionPublicationProhibited",t.RecordsGrantAuthorizationConditionPublicationRequired="RecordsGrantAuthorizationConditionPublicationRequired",t.RecordsGrantAuthorizationDeleteProtocolScopeMismatch="RecordsGrantAuthorizationDeleteProtocolScopeMismatch",t.RecordsGrantAuthorizationQueryOrSubscribeProtocolScopeMismatch="RecordsGrantAuthorizationQueryOrSubscribeProtocolScopeMismatch",t.RecordsGrantAuthorizationScopeContextIdMismatch="RecordsGrantAuthorizationScopeContextIdMismatch",t.RecordsGrantAuthorizationScopeProtocolMismatch="RecordsGrantAuthorizationScopeProtocolMismatch",t.RecordsGrantAuthorizationScopeProtocolPathMismatch="RecordsGrantAuthorizationScopeProtocolPathMismatch",t.RecordsDerivePrivateKeyUnSupportedCurve="RecordsDerivePrivateKeyUnSupportedCurve",t.RecordsInvalidAncestorKeyDerivationSegment="RecordsInvalidAncestorKeyDerivationSegment",t.RecordsOwnerDelegatedGrantAndIdExistenceMismatch="RecordsOwnerDelegatedGrantAndIdExistenceMismatch",t.RecordsOwnerDelegatedGrantCidMismatch="RecordsOwnerDelegatedGrantCidMismatch",t.RecordsOwnerDelegatedGrantGrantedToAndOwnerSignatureMismatch="RecordsOwnerDelegatedGrantGrantedToAndOwnerSignatureMismatch",t.RecordsOwnerDelegatedGrantNotADelegatedGrant="RecordsOwnerDelegatedGrantNotADelegatedGrant",t.RecordsProtocolContextDerivationSchemeMissingContextId="RecordsProtocolContextDerivationSchemeMissingContextId",t.RecordsProtocolPathDerivationSchemeMissingProtocol="RecordsProtocolPathDerivationSchemeMissingProtocol",t.RecordsQueryFilterMissingRequiredProperties="RecordsQueryFilterMissingRequiredProperties",t.RecordsReadReturnedMultiple="RecordsReadReturnedMultiple",t.RecordsReadAuthorizationFailed="RecordsReadAuthorizationFailed",t.RecordsSubscribeEventStreamUnimplemented="RecordsSubscribeEventStreamUnimplemented",t.RecordsSubscribeFilterMissingRequiredProperties="RecordsSubscribeFilterMissingRequiredProperties",t.RecordsSchemasDerivationSchemeMissingSchema="RecordsSchemasDerivationSchemeMissingSchema",t.RecordsWriteAttestationIntegrityMoreThanOneSignature="RecordsWriteAttestationIntegrityMoreThanOneSignature",t.RecordsWriteAttestationIntegrityDescriptorCidMismatch="RecordsWriteAttestationIntegrityDescriptorCidMismatch",t.RecordsWriteAttestationIntegrityInvalidPayloadProperty="RecordsWriteAttestationIntegrityInvalidPayloadProperty",t.RecordsWriteAuthorizationFailed="RecordsWriteAuthorizationFailed",t.RecordsWriteCreateMissingSigner="RecordsWriteCreateMissingSigner",t.RecordsWriteCreateDataAndDataCidMutuallyExclusive="RecordsWriteCreateDataAndDataCidMutuallyExclusive",t.RecordsWriteCreateDataCidAndDataSizeMutuallyInclusive="RecordsWriteCreateDataCidAndDataSizeMutuallyInclusive",t.RecordsWriteCreateProtocolAndProtocolPathMutuallyInclusive="RecordsWriteCreateProtocolAndProtocolPathMutuallyInclusive",t.RecordsWriteDataCidMismatch="RecordsWriteDataCidMismatch",t.RecordsWriteDataSizeMismatch="RecordsWriteDataSizeMismatch",t.RecordsWriteGetEntryIdUndefinedAuthor="RecordsWriteGetEntryIdUndefinedAuthor",t.RecordsWriteGetNewestWriteRecordNotFound="RecordsWriteGetNewestWriteRecordNotFound",t.RecordsWriteGetInitialWriteNotFound="RecordsWriteGetInitialWriteNotFound",t.RecordsWriteImmutablePropertyChanged="RecordsWriteImmutablePropertyChanged",t.RecordsWriteMissingSigner="RecordsWriteMissingSigner",t.RecordsWriteMissingDataInPrevious="RecordsWriteMissingDataInPrevious",t.RecordsWriteMissingEncodedDataInPrevious="RecordsWriteMissingEncodedDataInPrevious",t.RecordsWriteMissingProtocol="RecordsWriteMissingProtocol",t.RecordsWriteMissingSchema="RecordsWriteMissingSchema",t.RecordsWriteNotAllowedAfterDelete="RecordsWriteNotAllowedAfterDelete",t.RecordsWriteOwnerAndTenantMismatch="RecordsWriteOwnerAndTenantMismatch",t.RecordsWriteSignAsOwnerDelegateUnknownAuthor="RecordsWriteSignAsOwnerDelegateUnknownAuthor",t.RecordsWriteSignAsOwnerUnknownAuthor="RecordsWriteSignAsOwnerUnknownAuthor",t.RecordsWriteValidateIntegrityAttestationMismatch="RecordsWriteValidateIntegrityAttestationMismatch",t.RecordsWriteValidateIntegrityContextIdMismatch="RecordsWriteValidateIntegrityContextIdMismatch",t.RecordsWriteValidateIntegrityContextIdNotInSignerSignaturePayload="RecordsWriteValidateIntegrityContextIdNotInSignerSignaturePayload",t.RecordsWriteValidateIntegrityDateCreatedMismatch="RecordsWriteValidateIntegrityDateCreatedMismatch",t.RecordsWriteValidateIntegrityEncryptionCidMismatch="RecordsWriteValidateIntegrityEncryptionCidMismatch",t.RecordsWriteValidateIntegrityRecordIdUnauthorized="RecordsWriteValidateIntegrityRecordIdUnauthorized",t.SchemaValidatorAdditionalPropertyNotAllowed="SchemaValidatorAdditionalPropertyNotAllowed",t.SchemaValidatorFailure="SchemaValidatorFailure",t.SchemaValidatorSchemaNotFound="SchemaValidatorSchemaNotFound",t.SchemaValidatorUnevaluatedPropertyNotAllowed="SchemaValidatorUnevaluatedPropertyNotAllowed",t.Secp256k1KeyNotValid="Secp256k1KeyNotValid",t.Secp256r1KeyNotValid="Secp256r1KeyNotValid",t.TimestampInvalid="TimestampInvalid",t.UrlProtocolNotNormalized="UrlProtocolNotNormalized",t.UrlProtocolNotNormalizable="UrlProtocolNotNormalizable",t.UrlSchemaNotNormalized="UrlSchemaNotNormalized"})(se||(se={}));var W5=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})};function YW(t){if(t.kty!=="OKP"||t.crv!=="Ed25519")throw new de(se.Ed25519InvalidJwk,"invalid jwk. kty MUST be OKP. crv MUST be Ed25519")}function XW(t){return{alg:"EdDSA",kty:"OKP",crv:"Ed25519",x:qe.bytesToBase64Url(t)}}var o9={sign:(t,e)=>W5(void 0,void 0,void 0,function*(){YW(e);let r=qe.base64UrlToBytes(e.d);return GW(t,r)}),verify:(t,e,r)=>W5(void 0,void 0,void 0,function*(){YW(r);let n=qe.base64UrlToBytes(r.x);return JW(e,t,n)}),generateKeyPair:()=>W5(void 0,void 0,void 0,function*(){let t=ZW.randomPrivateKey(),e=yield HW(t),r=qe.bytesToBase64Url(t),n=XW(e),i=Object.assign(Object.assign({},n),{d:r});return{publicJwk:n,privateJwk:i}}),publicKeyToJwk:t=>W5(void 0,void 0,void 0,function*(){return XW(t)})};f();f();var c9=2n**256n,zp=c9-0x1000003d1n,to=c9-0x14551231950b75fc4402da1732fc9bebfn,iH=0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,oH=0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n,sH={p:zp,n:to,a:0n,b:7n,Gx:iH,Gy:oH},js=32,QW=t=>He(He(t*t)*t+sH.b),un=(t="")=>{throw new Error(t)},J5=t=>typeof t=="bigint",aH=t=>typeof t=="string",s9=t=>J5(t)&&0nJ5(t)&&0n!(t instanceof Uint8Array)||typeof e=="number"&&e>0&&t.length!==e?un("Uint8Array expected"):t,Ec=t=>new Uint8Array(t),Zf=(t,e)=>cH(aH(t)?G_(t):Ec(t),e),He=(t,e=zp)=>{let r=t%e;return r>=0n?r:e+r},eH=t=>t instanceof va?t:un("Point expected"),tH,va=class t{constructor(e,r,n){this.px=e,this.py=r,this.pz=n}static fromAffine(e){return new t(e.x,e.y,1n)}static fromHex(e){e=Zf(e);let r,n=e[0],i=e.subarray(1),o=V5(i,0,js),s=e.length;if(s===33&&[2,3].includes(n)){s9(o)||un("Point hex invalid: x not FE");let a=v_e(QW(o)),d=(a&1n)===1n;(n&1)===1!==d&&(a=He(-a)),r=new t(o,a,1n)}return s===65&&n===4&&(r=new t(o,V5(i,js,2*js),1n)),r?r.ok():un("Point is not on curve")}static fromPrivateKey(e){return Jf.mul(G5(e))}get x(){return this.aff().x}get y(){return this.aff().y}equals(e){let{px:r,py:n,pz:i}=this,{px:o,py:s,pz:a}=eH(e),d=He(r*a),u=He(o*i),c=He(n*a),l=He(s*i);return d===u&&c===l}negate(){return new t(this.px,He(-this.py),this.pz)}double(){return this.add(this)}add(e){let{px:r,py:n,pz:i}=this,{px:o,py:s,pz:a}=eH(e),{a:d,b:u}=sH,c=0n,l=0n,p=0n,m=He(u*3n),g=He(r*o),v=He(n*s),x=He(i*a),S=He(r+n),P=He(o+s);S=He(S*P),P=He(g+v),S=He(S-P),P=He(r+i);let A=He(o+a);return P=He(P*A),A=He(g+x),P=He(P-A),A=He(n+i),c=He(s+a),A=He(A*c),c=He(v+x),A=He(A-c),p=He(d*P),c=He(m*x),p=He(c+p),c=He(v-p),p=He(v+p),l=He(c*p),v=He(g+g),v=He(v+g),x=He(d*x),P=He(m*P),v=He(v+x),x=He(g-x),x=He(d*x),P=He(P+x),g=He(v*P),l=He(l+g),g=He(A*P),c=He(S*c),c=He(c-g),g=He(S*v),p=He(A*p),p=He(p+g),new t(c,l,p)}mul(e,r=!0){if(!r&&e===0n)return H5;if(H_(e)||un("invalid scalar"),this.equals(Jf))return E_e(e).p;let n=H5,i=Jf;for(let o=this;e>0n;o=o.double(),e>>=1n)e&1n?n=n.add(o):r&&(i=i.add(o));return n}mulAddQUns(e,r,n){return this.mul(r,!1).add(e.mul(n,!1)).ok()}toAffine(){let{px:e,py:r,pz:n}=this;if(this.equals(H5))return{x:0n,y:0n};if(n===1n)return{x:e,y:r};let i=Z_(n);return He(n*i)!==1n&&un("invalid inverse"),{x:He(e*i),y:He(r*i)}}assertValidity(){let{x:e,y:r}=this.aff();return(!s9(e)||!s9(r))&&un("Point invalid: x or y"),He(r*r)===QW(e)?this:un("Point invalid: not on curve")}multiply(e){return this.mul(e)}aff(){return this.toAffine()}ok(){return this.assertValidity()}toHex(e=!0){let{x:r,y:n}=this.aff();return(e?(n&1n)===0n?"02":"03":"04")+z_(r)+(e?"":z_(n))}toRawBytes(e=!0){return G_(this.toHex(e))}};va.BASE=new va(iH,oH,1n);va.ZERO=new va(0n,1n,0n);var{BASE:Jf,ZERO:H5}=va,dH=(t,e)=>t.toString(16).padStart(e,"0"),d9=t=>Array.from(t).map(e=>dH(e,2)).join(""),G_=t=>{let e=t.length;(!aH(t)||e%2)&&un("hex invalid 1");let r=Ec(e/2);for(let n=0;nBigInt("0x"+(d9(t)||"0")),V5=(t,e,r)=>J_(t.slice(e,r)),Z5=t=>J5(t)&&t>=0n&&td9(Z5(t)),a9=(...t)=>{let e=Ec(t.reduce((n,i)=>n+cH(i).length,0)),r=0;return t.forEach(n=>{e.set(n,r),r+=n.length}),e},Z_=(t,e=zp)=>{(t===0n||e<=0n)&&un("no inverse n="+t+" mod="+e);let r=He(t,e),n=e,i=0n,o=1n,s=1n,a=0n;for(;r!==0n;){let d=n/r,u=n%r,c=i-s*d,l=o-a*d;n=r,r=u,i=s,o=a,s=c,a=l}return n===1n?He(i,e):un("no inverse")},v_e=t=>{let e=1n;for(let r=t,n=(zp+1n)/4n;n>0n;n>>=1n)n&1n&&(e=e*r%zp),r=r*r%zp;return He(e*e)===t?e:un("sqrt invalid")},G5=t=>(J5(t)||(t=J_(Zf(t,js))),H_(t)?t:un("private key out of range")),u9=t=>t>to>>1n;function Y5(t,e=!0){return va.fromPrivateKey(t).toRawBytes(e)}var V_=class t{constructor(e,r,n){this.r=e,this.s=r,this.recovery=n,this.assertValidity()}static fromCompact(e){return e=Zf(e,64),new t(V5(e,0,js),V5(e,js,2*js))}assertValidity(){return H_(this.r)&&H_(this.s)?this:un()}addRecoveryBit(e){return new t(this.r,this.s,e)}hasHighS(){return u9(this.s)}recoverPublicKey(e){let{r,s:n,recovery:i}=this;[0,1,2,3].includes(i)||un("recovery id invalid");let o=l9(Zf(e,32)),s=i===2||i===3?r+to:r;s>=zp&&un("q.x invalid");let a=i&1?"03":"02",d=va.fromHex(a+z_(s)),u=Z_(s,to),c=He(-o*u,to),l=He(n*u,to);return Jf.mulAddQUns(d,c,l)}toCompactRawBytes(){return G_(this.toCompactHex())}toCompactHex(){return z_(this.r)+z_(this.s)}},uH=t=>{let e=t.length*8-256,r=J_(t);return e>0?r>>BigInt(e):r},l9=t=>He(uH(t),to),rH=t=>Z5(t),nH=()=>typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0,W_,lH={lowS:!0},b_e={lowS:!0};function w_e(t,e,r=lH){["der","recovered","canonical"].some(l=>l in r)&&un("sign() legacy options not supported");let{lowS:n}=r;n==null&&(n=!0);let i=l9(Zf(t)),o=rH(i),s=G5(e),a=[rH(s),o],d=r.extraEntropy;if(d){d===!0&&(d=A0.randomBytes(js));let l=Zf(d);l.length!==js&&un(),a.push(l)}let u=i,c=l=>{let p=uH(l);if(!H_(p))return;let m=Z_(p,to),g=Jf.mul(p).aff(),v=He(g.x,to);if(v===0n)return;let x=He(m*He(u+He(s*v,to),to),to);if(x===0n)return;let S=x,P=(g.x===v?0:2)|Number(g.y&1n);return n&&u9(x)&&(S=He(-x,to),P^=1),new V_(v,S,P)};return{seed:a9(...a),k2sig:c}}function __e(t){let e=Ec(js),r=Ec(js),n=0,i=()=>{e.fill(1),r.fill(0),n=0},o="drbg: tried 1000 values";if(t){let s=(...u)=>A0.hmacSha256Async(r,e,...u),a=async(u=Ec())=>{r=await s(Ec([0]),u),e=await s(),u.length!==0&&(r=await s(Ec([1]),u),e=await s())},d=async()=>(n++>=1e3&&un(o),e=await s(),e);return async(u,c)=>{i(),await a(u);let l;for(;!(l=c(await d()));)await a();return i(),l}}else{let s=(...u)=>{let c=W_;return c||un("etc.hmacSha256Sync not set"),c(r,e,...u)},a=(u=Ec())=>{r=s(Ec([0]),u),e=s(),u.length!==0&&(r=s(Ec([1]),u),e=s())},d=()=>(n++>=1e3&&un(o),e=s(),e);return(u,c)=>{i(),a(u);let l;for(;!(l=c(d()));)a();return i(),l}}}async function fH(t,e,r=lH){let{seed:n,k2sig:i}=w_e(t,e,r);return __e(!0)(n,i)}function hH(t,e,r,n=b_e){let{lowS:i}=n;i==null&&(i=!0),"strict"in n&&un("verify() legacy options not supported");let o,s,a,d=t&&typeof t=="object"&&"r"in t;!d&&Zf(t).length!==2*js&&un("signature must be 64 bytes");try{o=d?new V_(t.r,t.s).assertValidity():V_.fromCompact(t),s=l9(Zf(e,js)),a=r instanceof va?r.ok():va.fromHex(r)}catch{return!1}if(!o)return!1;let{r:u,s:c}=o;if(i&&u9(c))return!1;let l;try{let m=Z_(c,to),g=He(s*m,to),v=He(u*m,to);l=Jf.mulAddQUns(a,g,v).aff()}catch{return!1}return l?He(l.x,to)===u:!1}function pH(t){t=Zf(t);let e=js+8;(t.length1024)&&un("expected proper params");let r=He(J_(t),to-1n)+1n;return Z5(r)}var A0={hexToBytes:G_,bytesToHex:d9,concatBytes:a9,bytesToNumberBE:J_,numberToBytesBE:Z5,mod:He,invert:Z_,hmacSha256Async:async(t,...e)=>{let r=nH();if(!r)return un("etc.hmacSha256Async not set");let n=r.subtle,i=await n.importKey("raw",t,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);return Ec(await n.sign("HMAC",i,a9(...e)))},hmacSha256Sync:W_,hashToPrivateKey:pH,randomBytes:t=>{let e=nH();return e||un("crypto.getRandomValues must be defined"),e.getRandomValues(Ec(t))}},f9={normPrivateKeyToScalar:G5,isValidPrivateKey:t=>{try{return!!G5(t)}catch{return!1}},randomPrivateKey:()=>pH(A0.randomBytes(js+8)),precompute(t=8,e=Jf){return e.multiply(3n),e}};Object.defineProperties(A0,{hmacSha256Sync:{configurable:!1,get(){return W_},set(t){W_||(W_=t)}}});var S0=8,x_e=()=>{let t=[],e=256/S0+1,r=Jf,n=r;for(let i=0;i{let e=tH||(tH=x_e()),r=(c,l)=>{let p=l.negate();return c?p:l},n=H5,i=Jf,o=1+256/S0,s=2**(S0-1),a=BigInt(2**S0-1),d=2**S0,u=BigInt(S0);for(let c=0;c>=u,p>s&&(p-=d,t+=1n);let m=l,g=l+Math.abs(p)-1,v=c%2!==0,x=p<0;p===0?i=i.add(r(v,e[m])):n=n.add(r(x,e[g]))}return{p:n,f:i}};f();f();f();var Yf={};Pr(Yf,{decode:()=>Fb,encodeTo:()=>T0,encodingLength:()=>P0});f();f();var A_e=gH,mH=128,T_e=127,P_e=~T_e,I_e=Math.pow(2,31);function gH(t,e,r){e=e||[],r=r||0;for(var n=r;t>=I_e;)e[r++]=t&255|mH,t/=128;for(;t&P_e;)e[r++]=t&255|mH,t>>>=7;return e[r]=t|0,gH.bytes=r-n+1,e}var k_e=h9,R_e=128,yH=127;function h9(t,n){var r=0,n=n||0,i=0,o=n,s,a=t.length;do{if(o>=a)throw h9.bytes=0,new RangeError("Could not decode varint");s=t[o++],r+=i<28?(s&yH)<=R_e);return h9.bytes=o-n,r}var D_e=Math.pow(2,7),B_e=Math.pow(2,14),M_e=Math.pow(2,21),O_e=Math.pow(2,28),C_e=Math.pow(2,35),$_e=Math.pow(2,42),j_e=Math.pow(2,49),N_e=Math.pow(2,56),U_e=Math.pow(2,63),q_e=function(t){return t[Y_.decode(t,e),Y_.decode.bytes],T0=(t,e,r=0)=>(Y_.encode(t,e,r),e),P0=t=>Y_.encodingLength(t);var I0=(t,e)=>{let r=e.byteLength,n=P0(t),i=n+P0(r),o=new Uint8Array(i+r);return T0(t,o,0),T0(r,o,n),o.set(e,i),new zb(t,r,e,o)},X5=t=>{let e=hu(t),[r,n]=Fb(e),[i,o]=Fb(e.subarray(n)),s=e.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new zb(r,i,s,e)},vH=(t,e)=>{if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&BW(t.bytes,r.bytes)}},zb=class{constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}};var m9=({name:t,code:e,encode:r})=>new p9(t,e,r),p9=class{constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?I0(this.code,r):r.then(n=>I0(this.code,n))}else throw Error("Unknown type, must be binary type")}};var bH=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),Ns=m9({name:"sha2-256",code:18,encode:bH("SHA-256")}),Sot=m9({name:"sha2-512",code:19,encode:bH("SHA-512")});var Wp=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},z_e=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function _H(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");wH(t.outputLen),wH(t.blockLen)}function Hb(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 xH(t,e){Wb(t);let r=e.outputLen;if(t.lengthnew DataView(t.buffer,t.byteOffset,t.byteLength),pu=(t,e)=>t<<32-e|t>>>e;var Not=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function H_e(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function Q_(t){return typeof t=="string"&&(t=H_e(t)),Wb(t),t}function EH(...t){let e=0;for(let n=0;nt().update(Q_(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Gb(t=32){if(Hp&&typeof Hp.getRandomValues=="function")return Hp.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function V_e(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),d=n?4:0,u=n?0:4;t.setUint32(e+d,s,n),t.setUint32(e+u,a,n)}var AH=(t,e,r)=>t&e^~t&r,TH=(t,e,r)=>t&e^t&r^e&r,e8=class extends Vb{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=Q5(this.buffer)}update(e){Hb(this);let{view:r,buffer:n,blockLen:i}=this;e=Q_(e);let o=e.length;for(let s=0;si-s&&(this.process(n,0),s=0);for(let l=s;lc.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l>>3,v=pu(m,17)^pu(m,19)^m>>>10;Gp[l]=v+Gp[l-7]+g+Gp[l-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:d,G:u,H:c}=this;for(let l=0;l<64;l++){let p=pu(a,6)^pu(a,11)^pu(a,25),m=c+p+AH(a,d,u)+G_e[l]+Gp[l]|0,v=(pu(n,2)^pu(n,13)^pu(n,22))+TH(n,i,o)|0;c=u,u=d,d=a,a=s+m|0,s=o,o=i,i=n,n=m+v|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,d=d+this.F|0,u=u+this.G|0,c=c+this.H|0,this.set(n,i,o,s,a,d,u,c)}roundClean(){Gp.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var So=SH(()=>new y9);f();f();var t8=class extends Vb{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,_H(e);let n=Q_(r);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let i=this.blockLen,o=new Uint8Array(i);o.set(n.length>i?e.create().update(n).digest():n);for(let s=0;snew t8(t,e).update(r).digest();g9.create=(t,e)=>new t8(t,e);f();f();f();var _9={};Pr(_9,{abytes:()=>Jb,bitGet:()=>txe,bitLen:()=>exe,bitMask:()=>ex,bitSet:()=>rxe,bytesToHex:()=>k0,bytesToNumberBE:()=>Qf,bytesToNumberLE:()=>n8,concatBytes:()=>Zb,createHmacDrbg:()=>w9,ensureBytes:()=>Sc,equalBytes:()=>X_e,hexToBytes:()=>R0,hexToNumber:()=>b9,isBytes:()=>Jp,numberToBytesBE:()=>Zp,numberToBytesLE:()=>i8,numberToHexUnpadded:()=>RH,numberToVarBytesBE:()=>Y_e,utf8ToBytes:()=>Q_e,validateObject:()=>Yp});f();var kH=BigInt(0),r8=BigInt(1),J_e=BigInt(2);function Jp(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function Jb(t){if(!Jp(t))throw new Error("Uint8Array expected")}var Z_e=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function k0(t){Jb(t);let e="";for(let r=0;r=Xf._0&&t<=Xf._9)return t-Xf._0;if(t>=Xf._A&&t<=Xf._F)return t-(Xf._A-10);if(t>=Xf._a&&t<=Xf._f)return t-(Xf._a-10)}function R0(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let i=0,o=0;ikH;t>>=r8,e+=1);return e}function txe(t,e){return t>>BigInt(e)&r8}function rxe(t,e,r){return t|(r?r8:kH)<(J_e<new Uint8Array(t),IH=t=>Uint8Array.from(t);function w9(t,e,r){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=v9(t),i=v9(t),o=0,s=()=>{n.fill(1),i.fill(0),o=0},a=(...l)=>r(i,n,...l),d=(l=v9())=>{i=a(IH([0]),l),n=a(),l.length!==0&&(i=a(IH([1]),l),n=a())},u=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,p=[];for(;l{s(),d(l);let m;for(;!(m=p(u()));)d();return s(),m}}var nxe={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||Jp(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function Yp(t,e,r={}){let n=(i,o,s)=>{let a=nxe[o];if(typeof a!="function")throw new Error(`Invalid validator "${o}", expected function`);let d=t[i];if(!(s&&d===void 0)&&!a(d,t))throw new Error(`Invalid param ${String(i)}=${d} (${typeof d}), expected ${o}`)};for(let[i,o]of Object.entries(e))n(i,o,!1);for(let[i,o]of Object.entries(r))n(i,o,!0);return t}var Ao=BigInt(0),fi=BigInt(1),D0=BigInt(2),ixe=BigInt(3),x9=BigInt(4),DH=BigInt(5),BH=BigInt(8),oxe=BigInt(9),sxe=BigInt(16);function Ac(t,e){let r=t%e;return r>=Ao?r:e+r}function axe(t,e,r){if(r<=Ao||e 0");if(r===fi)return Ao;let n=fi;for(;e>Ao;)e&fi&&(n=n*t%r),t=t*t%r,e>>=fi;return n}function o8(t,e){if(t===Ao||e<=Ao)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=Ac(t,e),n=e,i=Ao,o=fi,s=fi,a=Ao;for(;r!==Ao;){let u=n/r,c=n%r,l=i-s*u,p=o-a*u;n=r,r=c,i=s,o=a,s=l,a=p}if(n!==fi)throw new Error("invert: does not exist");return Ac(i,e)}function cxe(t){let e=(t-fi)/D0,r,n,i;for(r=t-fi,n=0;r%D0===Ao;r/=D0,n++);for(i=D0;i(n[i]="function",n),e);return Yp(t,r)}function lxe(t,e,r){if(r 0");if(r===Ao)return t.ONE;if(r===fi)return e;let n=t.ONE,i=e;for(;r>Ao;)r&fi&&(n=t.mul(n,i)),i=t.sqr(i),r>>=fi;return n}function fxe(t,e){let r=new Array(e.length),n=e.reduce((o,s,a)=>t.is0(s)?o:(r[a]=o,t.mul(o,s)),t.ONE),i=t.inv(n);return e.reduceRight((o,s,a)=>t.is0(s)?o:(r[a]=t.mul(o,r[a]),t.mul(o,s)),i),r}function S9(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function MH(t,e,r=!1,n={}){if(t<=Ao)throw new Error(`Expected Field ORDER > 0, got ${t}`);let{nBitLength:i,nByteLength:o}=S9(t,e);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=dxe(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:o,MASK:ex(i),ZERO:Ao,ONE:fi,create:d=>Ac(d,t),isValid:d=>{if(typeof d!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof d}`);return Ao<=d&&dd===Ao,isOdd:d=>(d&fi)===fi,neg:d=>Ac(-d,t),eql:(d,u)=>d===u,sqr:d=>Ac(d*d,t),add:(d,u)=>Ac(d+u,t),sub:(d,u)=>Ac(d-u,t),mul:(d,u)=>Ac(d*u,t),pow:(d,u)=>lxe(a,d,u),div:(d,u)=>Ac(d*o8(u,t),t),sqrN:d=>d*d,addN:(d,u)=>d+u,subN:(d,u)=>d-u,mulN:(d,u)=>d*u,inv:d=>o8(d,t),sqrt:n.sqrt||(d=>s(a,d)),invertBatch:d=>fxe(a,d),cmov:(d,u,c)=>c?u:d,toBytes:d=>r?i8(d,o):Zp(d,o),fromBytes:d=>{if(d.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${d.length}`);return r?n8(d):Qf(d)}});return Object.freeze(a)}function OH(t){if(typeof t!="bigint")throw new Error("field order must be bigint");let e=t.toString(2).length;return Math.ceil(e/8)}function A9(t){let e=OH(t);return e+Math.ceil(e/2)}function CH(t,e,r=!1){let n=t.length,i=OH(e),o=A9(e);if(n<16||n1024)throw new Error(`expected ${o}-1024 bytes of input, got ${n}`);let s=r?Qf(t):n8(t),a=Ac(s,e-fi)+fi;return r?i8(a,i):Zp(a,i)}var pxe=BigInt(0),T9=BigInt(1);function $H(t,e){let r=(i,o)=>{let s=o.negate();return i?s:o},n=i=>{let o=Math.ceil(e/i)+1,s=2**(i-1);return{windows:o,windowSize:s}};return{constTimeNegate:r,unsafeLadder(i,o){let s=t.ZERO,a=i;for(;o>pxe;)o&T9&&(s=s.add(a)),a=a.double(),o>>=T9;return s},precomputeWindow(i,o){let{windows:s,windowSize:a}=n(o),d=[],u=i,c=u;for(let l=0;l>=m,x>d&&(x-=p,s+=T9);let S=v,P=v+Math.abs(x)-1,A=g%2!==0,$=x<0;x===0?c=c.add(r(A,o[S])):u=u.add(r($,o[P]))}return{p:u,f:c}},wNAFCached(i,o,s,a){let d=i._WINDOW_SIZE||1,u=o.get(i);return u||(u=this.precomputeWindow(i,d),d!==1&&o.set(i,a(u))),this.wNAF(d,u,s)}}}function P9(t){return E9(t.Fp),Yp(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...S9(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}function mxe(t){let e=P9(t);Yp(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:r,Fp:n,a:i}=e;if(r){if(!n.eql(i,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:yxe,hexToBytes:gxe}=_9,B0={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(t){let{Err:e}=B0;if(t.length<2||t[0]!==2)throw new e("Invalid signature integer tag");let r=t[1],n=t.subarray(2,r+2);if(!r||n.length!==r)throw new e("Invalid signature integer: wrong length");if(n[0]&128)throw new e("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:yxe(n),l:t.subarray(r+2)}},toSig(t){let{Err:e}=B0,r=typeof t=="string"?gxe(t):t;Jb(r);let n=r.length;if(n<2||r[0]!=48)throw new e("Invalid signature tag");if(r[1]!==n-2)throw new e("Invalid signature: incorrect length");let{d:i,l:o}=B0._parseInt(r.subarray(2)),{d:s,l:a}=B0._parseInt(o);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:i,s}},hexFromSig(t){let e=u=>Number.parseInt(u[0],16)&8?"00"+u:u,r=u=>{let c=u.toString(16);return c.length&1?`0${c}`:c},n=e(r(t.s)),i=e(r(t.r)),o=n.length/2,s=i.length/2,a=r(o),d=r(s);return`30${r(s+o+4)}02${d}${i}02${a}${n}`}},eh=BigInt(0),gd=BigInt(1),ust=BigInt(2),jH=BigInt(3),lst=BigInt(4);function vxe(t){let e=mxe(t),{Fp:r}=e,n=e.toBytes||((g,v,x)=>{let S=v.toAffine();return Zb(Uint8Array.from([4]),r.toBytes(S.x),r.toBytes(S.y))}),i=e.fromBytes||(g=>{let v=g.subarray(1),x=r.fromBytes(v.subarray(0,r.BYTES)),S=r.fromBytes(v.subarray(r.BYTES,2*r.BYTES));return{x,y:S}});function o(g){let{a:v,b:x}=e,S=r.sqr(g),P=r.mul(S,g);return r.add(r.add(P,r.mul(g,v)),x)}if(!r.eql(r.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function s(g){return typeof g=="bigint"&&ehr.eql(A,r.ZERO);return P(x)&&P(S)?l.ZERO:new l(x,S,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(v){let x=r.invertBatch(v.map(S=>S.pz));return v.map((S,P)=>S.toAffine(x[P])).map(l.fromAffine)}static fromHex(v){let x=l.fromAffine(i(Sc("pointHex",v)));return x.assertValidity(),x}static fromPrivateKey(v){return l.BASE.multiply(d(v))}_setWindowSize(v){this._WINDOW_SIZE=v,u.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}let{x:v,y:x}=this.toAffine();if(!r.isValid(v)||!r.isValid(x))throw new Error("bad point: x or y not FE");let S=r.sqr(x),P=o(v);if(!r.eql(S,P))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:v}=this.toAffine();if(r.isOdd)return!r.isOdd(v);throw new Error("Field doesn't support isOdd")}equals(v){c(v);let{px:x,py:S,pz:P}=this,{px:A,py:$,pz:j}=v,L=r.eql(r.mul(x,j),r.mul(A,P)),F=r.eql(r.mul(S,j),r.mul($,P));return L&&F}negate(){return new l(this.px,r.neg(this.py),this.pz)}double(){let{a:v,b:x}=e,S=r.mul(x,jH),{px:P,py:A,pz:$}=this,j=r.ZERO,L=r.ZERO,F=r.ZERO,K=r.mul(P,P),W=r.mul(A,A),q=r.mul($,$),I=r.mul(P,A);return I=r.add(I,I),F=r.mul(P,$),F=r.add(F,F),j=r.mul(v,F),L=r.mul(S,q),L=r.add(j,L),j=r.sub(W,L),L=r.add(W,L),L=r.mul(j,L),j=r.mul(I,j),F=r.mul(S,F),q=r.mul(v,q),I=r.sub(K,q),I=r.mul(v,I),I=r.add(I,F),F=r.add(K,K),K=r.add(F,K),K=r.add(K,q),K=r.mul(K,I),L=r.add(L,K),q=r.mul(A,$),q=r.add(q,q),K=r.mul(q,I),j=r.sub(j,K),F=r.mul(q,W),F=r.add(F,F),F=r.add(F,F),new l(j,L,F)}add(v){c(v);let{px:x,py:S,pz:P}=this,{px:A,py:$,pz:j}=v,L=r.ZERO,F=r.ZERO,K=r.ZERO,W=e.a,q=r.mul(e.b,jH),I=r.mul(x,A),T=r.mul(S,$),B=r.mul(P,j),h=r.add(x,S),y=r.add(A,$);h=r.mul(h,y),y=r.add(I,T),h=r.sub(h,y),y=r.add(x,P);let w=r.add(A,j);return y=r.mul(y,w),w=r.add(I,B),y=r.sub(y,w),w=r.add(S,P),L=r.add($,j),w=r.mul(w,L),L=r.add(T,B),w=r.sub(w,L),K=r.mul(W,y),L=r.mul(q,B),K=r.add(L,K),L=r.sub(T,K),K=r.add(T,K),F=r.mul(L,K),T=r.add(I,I),T=r.add(T,I),B=r.mul(W,B),y=r.mul(q,y),T=r.add(T,B),B=r.sub(I,B),B=r.mul(W,B),y=r.add(y,B),I=r.mul(T,y),F=r.add(F,I),I=r.mul(w,y),L=r.mul(h,L),L=r.sub(L,I),I=r.mul(h,T),K=r.mul(w,K),K=r.add(K,I),new l(L,F,K)}subtract(v){return this.add(v.negate())}is0(){return this.equals(l.ZERO)}wNAF(v){return m.wNAFCached(this,u,v,x=>{let S=r.invertBatch(x.map(P=>P.pz));return x.map((P,A)=>P.toAffine(S[A])).map(l.fromAffine)})}multiplyUnsafe(v){let x=l.ZERO;if(v===eh)return x;if(a(v),v===gd)return this;let{endo:S}=e;if(!S)return m.unsafeLadder(this,v);let{k1neg:P,k1:A,k2neg:$,k2:j}=S.splitScalar(v),L=x,F=x,K=this;for(;A>eh||j>eh;)A&gd&&(L=L.add(K)),j&gd&&(F=F.add(K)),K=K.double(),A>>=gd,j>>=gd;return P&&(L=L.negate()),$&&(F=F.negate()),F=new l(r.mul(F.px,S.beta),F.py,F.pz),L.add(F)}multiply(v){a(v);let x=v,S,P,{endo:A}=e;if(A){let{k1neg:$,k1:j,k2neg:L,k2:F}=A.splitScalar(x),{p:K,f:W}=this.wNAF(j),{p:q,f:I}=this.wNAF(F);K=m.constTimeNegate($,K),q=m.constTimeNegate(L,q),q=new l(r.mul(q.px,A.beta),q.py,q.pz),S=K.add(q),P=W.add(I)}else{let{p:$,f:j}=this.wNAF(x);S=$,P=j}return l.normalizeZ([S,P])[0]}multiplyAndAddUnsafe(v,x,S){let P=l.BASE,A=(j,L)=>L===eh||L===gd||!j.equals(P)?j.multiplyUnsafe(L):j.multiply(L),$=A(this,x).add(A(v,S));return $.is0()?void 0:$}toAffine(v){let{px:x,py:S,pz:P}=this,A=this.is0();v==null&&(v=A?r.ONE:r.inv(P));let $=r.mul(x,v),j=r.mul(S,v),L=r.mul(P,v);if(A)return{x:r.ZERO,y:r.ZERO};if(!r.eql(L,r.ONE))throw new Error("invZ was invalid");return{x:$,y:j}}isTorsionFree(){let{h:v,isTorsionFree:x}=e;if(v===gd)return!0;if(x)return x(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:v,clearCofactor:x}=e;return v===gd?this:x?x(l,this):this.multiplyUnsafe(e.h)}toRawBytes(v=!0){return this.assertValidity(),n(l,this,v)}toHex(v=!0){return k0(this.toRawBytes(v))}}l.BASE=new l(e.Gx,e.Gy,r.ONE),l.ZERO=new l(r.ZERO,r.ONE,r.ZERO);let p=e.nBitLength,m=$H(l,e.endo?Math.ceil(p/2):p);return{CURVE:e,ProjectivePoint:l,normPrivateKeyToScalar:d,weierstrassEquation:o,isWithinCurveOrder:s}}function bxe(t){let e=P9(t);return Yp(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function NH(t){let e=bxe(t),{Fp:r,n}=e,i=r.BYTES+1,o=2*r.BYTES+1;function s(y){return ehk0(Zp(y,e.nByteLength));function g(y){let w=n>>gd;return y>w}function v(y){return g(y)?a(-y):y}let x=(y,w,E)=>Qf(y.slice(w,E));class S{constructor(w,E,_){this.r=w,this.s=E,this.recovery=_,this.assertValidity()}static fromCompact(w){let E=e.nByteLength;return w=Sc("compactSignature",w,E*2),new S(x(w,0,E),x(w,E,2*E))}static fromDER(w){let{r:E,s:_}=B0.toSig(Sc("DER",w));return new S(E,_)}assertValidity(){if(!p(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!p(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(w){return new S(this.r,this.s,w)}recoverPublicKey(w){let{r:E,s:_,recovery:b}=this,C=F(Sc("msgHash",w));if(b==null||![0,1,2,3].includes(b))throw new Error("recovery id invalid");let N=b===2||b===3?E+e.n:E;if(N>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let M=b&1?"03":"02",U=u.fromHex(M+m(N)),G=d(N),Z=a(-C*G),J=a(_*G),H=u.BASE.multiplyAndAddUnsafe(U,Z,J);if(!H)throw new Error("point at infinify");return H.assertValidity(),H}hasHighS(){return g(this.s)}normalizeS(){return this.hasHighS()?new S(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return R0(this.toDERHex())}toDERHex(){return B0.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return R0(this.toCompactHex())}toCompactHex(){return m(this.r)+m(this.s)}}let P={isValidPrivateKey(y){try{return c(y),!0}catch{return!1}},normPrivateKeyToScalar:c,randomPrivateKey:()=>{let y=A9(e.n);return CH(e.randomBytes(y),e.n)},precompute(y=8,w=u.BASE){return w._setWindowSize(y),w.multiply(BigInt(3)),w}};function A(y,w=!0){return u.fromPrivateKey(y).toRawBytes(w)}function $(y){let w=Jp(y),E=typeof y=="string",_=(w||E)&&y.length;return w?_===i||_===o:E?_===2*i||_===2*o:y instanceof u}function j(y,w,E=!0){if($(y))throw new Error("first arg must be private key");if(!$(w))throw new Error("second arg must be public key");return u.fromHex(w).multiply(c(y)).toRawBytes(E)}let L=e.bits2int||function(y){let w=Qf(y),E=y.length*8-e.nBitLength;return E>0?w>>BigInt(E):w},F=e.bits2int_modN||function(y){return a(L(y))},K=ex(e.nBitLength);function W(y){if(typeof y!="bigint")throw new Error("bigint expected");if(!(eh<=y&&yte in E))throw new Error("sign() legacy options not supported");let{hash:_,randomBytes:b}=e,{lowS:C,prehash:N,extraEntropy:M}=E;C==null&&(C=!0),y=Sc("msgHash",y),N&&(y=Sc("prehashed msgHash",_(y)));let U=F(y),G=c(w),Z=[W(G),W(U)];if(M!=null&&M!==!1){let te=M===!0?b(r.BYTES):M;Z.push(Sc("extraEntropy",te))}let J=Zb(...Z),H=U;function X(te){let ne=L(te);if(!p(ne))return;let Q=d(ne),re=u.BASE.multiply(ne).toAffine(),ce=a(re.x);if(ce===eh)return;let pe=a(Q*a(H+ce*G));if(pe===eh)return;let ye=(re.x===ce?0:2)|Number(re.y&gd),ie=pe;return C&&g(pe)&&(ie=v(pe),ye^=1),new S(ce,ie,ye)}return{seed:J,k2sig:X}}let I={lowS:e.lowS,prehash:!1},T={lowS:e.lowS,prehash:!1};function B(y,w,E=I){let{seed:_,k2sig:b}=q(y,w,E),C=e;return w9(C.hash.outputLen,C.nByteLength,C.hmac)(_,b)}u.BASE._setWindowSize(8);function h(y,w,E,_=T){let b=y;if(w=Sc("msgHash",w),E=Sc("publicKey",E),"strict"in _)throw new Error("options.strict was renamed to lowS");let{lowS:C,prehash:N}=_,M,U;try{if(typeof b=="string"||Jp(b))try{M=S.fromDER(b)}catch(re){if(!(re instanceof B0.Err))throw re;M=S.fromCompact(b)}else if(typeof b=="object"&&typeof b.r=="bigint"&&typeof b.s=="bigint"){let{r:re,s:ce}=b;M=new S(re,ce)}else throw new Error("PARSE");U=u.fromHex(E)}catch(re){if(re.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(C&&M.hasHighS())return!1;N&&(w=e.hash(w));let{r:G,s:Z}=M,J=F(w),H=d(Z),X=a(J*H),te=a(G*H),ne=u.BASE.multiplyAndAddUnsafe(U,X,te)?.toAffine();return ne?a(ne.x)===G:!1}return{CURVE:e,getPublicKey:A,getSharedSecret:j,sign:B,verify:h,ProjectivePoint:u,Signature:S,utils:P}}function wxe(t){return{hash:t,hmac:(e,...r)=>g9(t,e,EH(...r)),randomBytes:Gb}}function UH(t,e){let r=n=>NH({...t,...wxe(n)});return Object.freeze({...r(e),create:r})}var qH=MH(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),_xe=qH.create(BigInt("-3")),xxe=BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),th=UH({a:_xe,b:xxe,Fp:qH,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},So),LH=th;f();f();function I9(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;ri+o.length,0));let r=Ga(e),n=0;for(let i of t)r.set(i,n),n+=i.length;return r}f();f();f();var $9={};Pr($9,{base10:()=>Bxe});f();f();var Xb={};Pr(Xb,{coerce:()=>Sl,empty:()=>KH,equals:()=>k9,fromHex:()=>Axe,fromString:()=>R9,isBinary:()=>Txe,toHex:()=>Sxe,toString:()=>D9});f();var KH=new Uint8Array(0);function Sxe(t){return t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")}function Axe(t){let e=t.match(/../g);return e!=null?new Uint8Array(e.map(r=>parseInt(r,16))):KH}function k9(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n>>0,$=new Uint8Array(A);S!==P;){for(var j=g[S],L=0,F=A-1;(j!==0||L>>0,$[F]=j%a>>>0,j=j/a>>>0;if(j!==0)throw new Error("Non-zero carry");x=L,S++}for(var K=A-x;K!==A&&$[K]===0;)K++;for(var W=d.repeat(v);K>>0,A=new Uint8Array(P);g[v];){var $=r[g.charCodeAt(v)];if($===255)return;for(var j=0,L=P-1;($!==0||j>>0,A[L]=$%256>>>0,$=$/256>>>0;if($!==0)throw new Error("Non-zero carry");S=j,v++}if(g[v]!==" "){for(var F=P-S;F!==P&&A[F]===0;)F++;for(var K=new Uint8Array(x+(P-F)),W=x;F!==P;)K[W++]=A[F++];return K}}}function m(g){var v=p(g);if(v)return v;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:p,decode:m}}var Ixe=Pxe,kxe=Ixe,FH=kxe;var B9=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")}},M9=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 zH(this,e)}},O9=class{decoders;constructor(e){this.decoders=e}or(e){return zH(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 zH(t,e){return new O9({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var C9=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 B9(e,r,n),this.decoder=new M9(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Qb({name:t,prefix:e,encode:r,decode:n}){return new C9(t,e,r,n)}function Xp({name:t,prefix:e,alphabet:r}){let{encode:n,decode:i}=FH(r,t);return Qb({prefix:e,name:t,encode:n,decode:o=>Sl(i(o))})}function Rxe(t,e,r,n){let i={};for(let c=0;c=8&&(a-=8,s[u++]=255&d>>a)}if(a>=r||255&d<<8-a)throw new SyntaxError("Unexpected end of data");return s}function Dxe(t,e,r){let n=e[e.length-1]==="=",i=(1<r;)s-=r,o+=e[i&a>>s];if(s!==0&&(o+=e[i&a<Mxe,base16upper:()=>Oxe});f();var Mxe=hi({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Oxe=hi({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var N9={};Pr(N9,{base2:()=>Cxe});f();var Cxe=hi({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var U9={};Pr(U9,{base256emoji:()=>qxe});f();var WH=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),$xe=WH.reduce((t,e,r)=>(t[r]=e,t),[]),jxe=WH.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function Nxe(t){return t.reduce((e,r)=>(e+=$xe[r],e),"")}function Uxe(t){let e=[];for(let r of t){let n=jxe[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}var qxe=Qb({prefix:"\u{1F680}",name:"base256emoji",encode:Nxe,decode:Uxe});var q9={};Pr(q9,{base32:()=>ew,base32hex:()=>zxe,base32hexpad:()=>Hxe,base32hexpadupper:()=>Vxe,base32hexupper:()=>Wxe,base32pad:()=>Kxe,base32padupper:()=>Fxe,base32upper:()=>Lxe,base32z:()=>M0});f();var ew=hi({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Lxe=hi({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Kxe=hi({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Fxe=hi({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),zxe=hi({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Wxe=hi({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Hxe=hi({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Vxe=hi({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),M0=hi({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var L9={};Pr(L9,{base36:()=>Gxe,base36upper:()=>Jxe});f();var Gxe=Xp({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Jxe=Xp({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var K9={};Pr(K9,{base58btc:()=>Ki,base58flickr:()=>Zxe});f();var Ki=Xp({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Zxe=Xp({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var F9={};Pr(F9,{base64:()=>Yxe,base64pad:()=>Xxe,base64url:()=>Pi,base64urlpad:()=>Qxe});f();var Yxe=hi({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Xxe=hi({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Pi=hi({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Qxe=hi({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var z9={};Pr(z9,{base8:()=>eEe});f();var eEe=hi({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var W9={};Pr(W9,{identity:()=>tEe});f();var tEe=Qb({prefix:"\0",name:"identity",encode:t=>D9(t),decode:t=>R9(t)});f();var pat=new TextEncoder,mat=new TextDecoder;f();var V9={};Pr(V9,{identity:()=>SEe});f();f();var ba={};Pr(ba,{decode:()=>tw,encodeTo:()=>O0,encodingLength:()=>C0});f();f();var iEe=GH,HH=128,oEe=127,sEe=~oEe,aEe=Math.pow(2,31);function GH(t,e,r){e=e||[],r=r||0;for(var n=r;t>=aEe;)e[r++]=t&255|HH,t/=128;for(;t&sEe;)e[r++]=t&255|HH,t>>>=7;return e[r]=t|0,GH.bytes=r-n+1,e}var cEe=H9,dEe=128,VH=127;function H9(t,n){var r=0,n=n||0,i=0,o=n,s,a=t.length;do{if(o>=a)throw H9.bytes=0,new RangeError("Could not decode varint");s=t[o++],r+=i<28?(s&VH)<=dEe);return H9.bytes=o-n,r}var uEe=Math.pow(2,7),lEe=Math.pow(2,14),fEe=Math.pow(2,21),hEe=Math.pow(2,28),pEe=Math.pow(2,35),mEe=Math.pow(2,42),yEe=Math.pow(2,49),gEe=Math.pow(2,56),vEe=Math.pow(2,63),bEe=function(t){return tAEe,sha512:()=>TEe});f();f();function j0({name:t,code:e,encode:r}){return new G9(t,e,r)}var G9=class{name;code;encode;constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?$0(this.code,r):r.then(n=>$0(this.code,n))}else throw Error("Unknown type, must be binary type")}};function eV(t){return async e=>new Uint8Array(await crypto.subtle.digest(t,e))}var AEe=j0({name:"sha2-256",code:18,encode:eV("SHA-256")}),TEe=j0({name:"sha2-512",code:19,encode:eV("SHA-512")});f();f();f();function tV(t,e){let{bytes:r,version:n}=t;switch(n){case 0:return IEe(r,Z9(t),e??Ki.encoder);default:return kEe(r,Z9(t),e??ew.encoder)}}var rV=new WeakMap;function Z9(t){let e=rV.get(t);if(e==null){let r=new Map;return rV.set(t,r),r}return e}var mu=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!==nx)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==REe)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=$0(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&&ZH(e.multihash,n.multihash)}toString(e){return tV(this,e)}toJSON(){return{"/":tV(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??nV(n,i,o.bytes))}else if(r[DEe]===!0){let{version:n,multihash:i,code:o}=r,s=JH(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!==nx)throw new Error(`Version 0 CID must use dag-pb (code: ${nx}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let i=nV(e,r,n.bytes);return new t(e,r,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,nx,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=Sl(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 rw(r.multihashCode,r.digestSize,o,i);return[r.version===0?t.createV0(s):t.createV1(r.codec,s),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[l,p]=tw(e.subarray(r));return r+=p,l},i=n(),o=nx;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(),d=n(),u=r+d,c=u-s;return{version:i,codec:o,multihashCode:a,digestSize:d,multihashSize:c,size:u}}static parse(e,r){let[n,i]=PEe(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 Z9(o).set(n,e),o}};function PEe(t,e){switch(t[0]){case"Q":{let r=e??Ki;return[Ki.prefix,r.decode(`${Ki.prefix}${t}`)]}case Ki.prefix:{let r=e??Ki;return[Ki.prefix,r.decode(t)]}case ew.prefix:{let r=e??ew;return[ew.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 IEe(t,e,r){let{prefix:n}=r;if(n!==Ki.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 kEe(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 nx=112,REe=18;function nV(t,e,r){let n=C0(t),i=n+C0(e),o=new Uint8Array(i+r.byteLength);return O0(t,o,0),O0(e,o,n),o.set(r,i),o}var DEe=Symbol.for("@ipld/js-cid/CID");f();f();f();f();f();var Y9={...W9,...N9,...z9,...$9,...j9,...q9,...L9,...K9,...F9,...U9},Xat={...J9,...V9};function oV(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var iV=oV("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),X9=oV("ascii","a",t=>{let e="a";for(let r=0;r{t=t.substring(1);let e=Ga(t.length);for(let r=0;rt.createSigner(n))}static createSigner(e){let r=e.keyPair.privateJwk,n=e.keyId;return new iw({privateJwk:r,keyId:n})}};f();f();var ix=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,cV=new Set,eB=typeof k.default=="object"&&k.default?k.default:{},dV=(t,e,r,n)=>{typeof eB.emitWarning=="function"?eB.emitWarning(t,e,r,n):console.error(`[${r}] ${e}: ${t}`)},c8=globalThis.AbortController,aV=globalThis.AbortSignal;if(typeof c8>"u"){aV=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(n,i){this._onabort.push(i)}},c8=class{constructor(){e()}signal=new aV;abort(n){if(!this.signal.aborted){this.signal.reason=n,this.signal.aborted=!0;for(let i of this.signal._onabort)i(n);this.signal.onabort?.(n)}}};let t=eB.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{t&&(t=!1,dV("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e))}}var $Ee=t=>!cV.has(t),Wct=Symbol("type"),em=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),uV=t=>em(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?ow:null:null,ow=class extends Array{constructor(e){super(e),this.fill(0)}},tB=class t{heap;length;static#c=!1;static create(e){let r=uV(e);if(!r)return[];t.#c=!0;let n=new t(e,r);return t.#c=!1,n}constructor(e,r){if(!t.#c)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new r(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},d8=class t{#c;#l;#v;#p;#k;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#n;#m;#i;#r;#e;#d;#f;#a;#o;#y;#s;#x;#E;#g;#b;#A;#u;static unsafeExposeInternals(e){return{starts:e.#E,ttls:e.#g,sizes:e.#x,keyMap:e.#i,keyList:e.#r,valList:e.#e,next:e.#d,prev:e.#f,get head(){return e.#a},get tail(){return e.#o},free:e.#y,isBackgroundFetch:r=>e.#t(r),backgroundFetch:(r,n,i,o)=>e.#B(r,n,i,o),moveToTail:r=>e.#I(r),indexes:r=>e.#w(r),rindexes:r=>e.#_(r),isStale:r=>e.#h(r)}}get max(){return this.#c}get maxSize(){return this.#l}get calculatedSize(){return this.#m}get size(){return this.#n}get fetchMethod(){return this.#k}get dispose(){return this.#v}get disposeAfter(){return this.#p}constructor(e){let{max:r=0,ttl:n,ttlResolution:i=1,ttlAutopurge:o,updateAgeOnGet:s,updateAgeOnHas:a,allowStale:d,dispose:u,disposeAfter:c,noDisposeOnSet:l,noUpdateTTL:p,maxSize:m=0,maxEntrySize:g=0,sizeCalculation:v,fetchMethod:x,noDeleteOnFetchRejection:S,noDeleteOnStaleGet:P,allowStaleOnFetchRejection:A,allowStaleOnFetchAbort:$,ignoreFetchAbort:j}=e;if(r!==0&&!em(r))throw new TypeError("max option must be a nonnegative integer");let L=r?uV(r):Array;if(!L)throw new Error("invalid max value: "+r);if(this.#c=r,this.#l=m,this.maxEntrySize=g||this.#l,this.sizeCalculation=v,this.sizeCalculation){if(!this.#l&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(x!==void 0&&typeof x!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#k=x,this.#A=!!x,this.#i=new Map,this.#r=new Array(r).fill(void 0),this.#e=new Array(r).fill(void 0),this.#d=new L(r),this.#f=new L(r),this.#a=0,this.#o=0,this.#y=tB.create(r),this.#n=0,this.#m=0,typeof u=="function"&&(this.#v=u),typeof c=="function"?(this.#p=c,this.#s=[]):(this.#p=void 0,this.#s=void 0),this.#b=!!this.#v,this.#u=!!this.#p,this.noDisposeOnSet=!!l,this.noUpdateTTL=!!p,this.noDeleteOnFetchRejection=!!S,this.allowStaleOnFetchRejection=!!A,this.allowStaleOnFetchAbort=!!$,this.ignoreFetchAbort=!!j,this.maxEntrySize!==0){if(this.#l!==0&&!em(this.#l))throw new TypeError("maxSize must be a positive integer if specified");if(!em(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#N()}if(this.allowStale=!!d,this.noDeleteOnStaleGet=!!P,this.updateAgeOnGet=!!s,this.updateAgeOnHas=!!a,this.ttlResolution=em(i)||i===0?i:1,this.ttlAutopurge=!!o,this.ttl=n||0,this.ttl){if(!em(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#M()}if(this.#c===0&&this.ttl===0&&this.#l===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#c&&!this.#l){let F="LRU_CACHE_UNBOUNDED";$Ee(F)&&(cV.add(F),dV("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",F,t))}}getRemainingTTL(e){return this.#i.has(e)?1/0:0}#M(){let e=new ow(this.#c),r=new ow(this.#c);this.#g=e,this.#E=r,this.#O=(o,s,a=ix.now())=>{if(r[o]=s!==0?a:0,e[o]=s,s!==0&&this.ttlAutopurge){let d=setTimeout(()=>{this.#h(o)&&this.delete(this.#r[o])},s+1);d.unref&&d.unref()}},this.#T=o=>{r[o]=e[o]!==0?ix.now():0},this.#S=(o,s)=>{if(e[s]){let a=e[s],d=r[s];o.ttl=a,o.start=d,o.now=n||i();let u=o.now-d;o.remainingTTL=a-u}};let n=0,i=()=>{let o=ix.now();if(this.ttlResolution>0){n=o;let s=setTimeout(()=>n=0,this.ttlResolution);s.unref&&s.unref()}return o};this.getRemainingTTL=o=>{let s=this.#i.get(o);if(s===void 0)return 0;let a=e[s],d=r[s];if(a===0||d===0)return 1/0;let u=(n||i())-d;return a-u},this.#h=o=>e[o]!==0&&r[o]!==0&&(n||i())-r[o]>e[o]}#T=()=>{};#S=()=>{};#O=()=>{};#h=()=>!1;#N(){let e=new ow(this.#c);this.#m=0,this.#x=e,this.#P=r=>{this.#m-=e[r],e[r]=0},this.#C=(r,n,i,o)=>{if(this.#t(n))return 0;if(!em(i))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(i=o(n,r),!em(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return i},this.#R=(r,n,i)=>{if(e[r]=n,this.#l){let o=this.#l-e[r];for(;this.#m>o;)this.#D(!0)}this.#m+=e[r],i&&(i.entrySize=n,i.totalCalculatedSize=this.#m)}}#P=e=>{};#R=(e,r,n)=>{};#C=(e,r,n,i)=>{if(n||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#w({allowStale:e=this.allowStale}={}){if(this.#n)for(let r=this.#o;!(!this.#$(r)||((e||!this.#h(r))&&(yield r),r===this.#a));)r=this.#f[r]}*#_({allowStale:e=this.allowStale}={}){if(this.#n)for(let r=this.#a;!(!this.#$(r)||((e||!this.#h(r))&&(yield r),r===this.#o));)r=this.#d[r]}#$(e){return e!==void 0&&this.#i.get(this.#r[e])===e}*entries(){for(let e of this.#w())this.#e[e]!==void 0&&this.#r[e]!==void 0&&!this.#t(this.#e[e])&&(yield[this.#r[e],this.#e[e]])}*rentries(){for(let e of this.#_())this.#e[e]!==void 0&&this.#r[e]!==void 0&&!this.#t(this.#e[e])&&(yield[this.#r[e],this.#e[e]])}*keys(){for(let e of this.#w()){let r=this.#r[e];r!==void 0&&!this.#t(this.#e[e])&&(yield r)}}*rkeys(){for(let e of this.#_()){let r=this.#r[e];r!==void 0&&!this.#t(this.#e[e])&&(yield r)}}*values(){for(let e of this.#w())this.#e[e]!==void 0&&!this.#t(this.#e[e])&&(yield this.#e[e])}*rvalues(){for(let e of this.#_())this.#e[e]!==void 0&&!this.#t(this.#e[e])&&(yield this.#e[e])}[Symbol.iterator](){return this.entries()}find(e,r={}){for(let n of this.#w()){let i=this.#e[n],o=this.#t(i)?i.__staleWhileFetching:i;if(o!==void 0&&e(o,this.#r[n],this))return this.get(this.#r[n],r)}}forEach(e,r=this){for(let n of this.#w()){let i=this.#e[n],o=this.#t(i)?i.__staleWhileFetching:i;o!==void 0&&e.call(r,o,this.#r[n],this)}}rforEach(e,r=this){for(let n of this.#_()){let i=this.#e[n],o=this.#t(i)?i.__staleWhileFetching:i;o!==void 0&&e.call(r,o,this.#r[n],this)}}purgeStale(){let e=!1;for(let r of this.#_({allowStale:!0}))this.#h(r)&&(this.delete(this.#r[r]),e=!0);return e}dump(){let e=[];for(let r of this.#w({allowStale:!0})){let n=this.#r[r],i=this.#e[r],o=this.#t(i)?i.__staleWhileFetching:i;if(o===void 0||n===void 0)continue;let s={value:o};if(this.#g&&this.#E){s.ttl=this.#g[r];let a=ix.now()-this.#E[r];s.start=Math.floor(Date.now()-a)}this.#x&&(s.size=this.#x[r]),e.unshift([n,s])}return e}load(e){this.clear();for(let[r,n]of e){if(n.start){let i=Date.now()-n.start;n.start=ix.now()-i}this.set(r,n.value,n)}}set(e,r,n={}){if(r===void 0)return this.delete(e),this;let{ttl:i=this.ttl,start:o,noDisposeOnSet:s=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:d}=n,{noUpdateTTL:u=this.noUpdateTTL}=n,c=this.#C(e,r,n.size||0,a);if(this.maxEntrySize&&c>this.maxEntrySize)return d&&(d.set="miss",d.maxEntrySizeExceeded=!0),this.delete(e),this;let l=this.#n===0?void 0:this.#i.get(e);if(l===void 0)l=this.#n===0?this.#o:this.#y.length!==0?this.#y.pop():this.#n===this.#c?this.#D(!1):this.#n,this.#r[l]=e,this.#e[l]=r,this.#i.set(e,l),this.#d[this.#o]=l,this.#f[l]=this.#o,this.#o=l,this.#n++,this.#R(l,c,d),d&&(d.set="add"),u=!1;else{this.#I(l);let p=this.#e[l];if(r!==p){if(this.#A&&this.#t(p)?p.__abortController.abort(new Error("replaced")):s||(this.#b&&this.#v?.(p,e,"set"),this.#u&&this.#s?.push([p,e,"set"])),this.#P(l),this.#R(l,c,d),this.#e[l]=r,d){d.set="replace";let m=p&&this.#t(p)?p.__staleWhileFetching:p;m!==void 0&&(d.oldValue=m)}}else d&&(d.set="update")}if(i!==0&&!this.#g&&this.#M(),this.#g&&(u||this.#O(l,i,o),d&&this.#S(d,l)),!s&&this.#u&&this.#s){let p=this.#s,m;for(;m=p?.shift();)this.#p?.(...m)}return this}pop(){try{for(;this.#n;){let e=this.#e[this.#a];if(this.#D(!0),this.#t(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(this.#u&&this.#s){let e=this.#s,r;for(;r=e?.shift();)this.#p?.(...r)}}}#D(e){let r=this.#a,n=this.#r[r],i=this.#e[r];return this.#A&&this.#t(i)?i.__abortController.abort(new Error("evicted")):(this.#b||this.#u)&&(this.#b&&this.#v?.(i,n,"evict"),this.#u&&this.#s?.push([i,n,"evict"])),this.#P(r),e&&(this.#r[r]=void 0,this.#e[r]=void 0,this.#y.push(r)),this.#n===1?(this.#a=this.#o=0,this.#y.length=0):this.#a=this.#d[r],this.#i.delete(n),this.#n--,r}has(e,r={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:i}=r,o=this.#i.get(e);if(o!==void 0){let s=this.#e[o];if(this.#t(s)&&s.__staleWhileFetching===void 0)return!1;if(this.#h(o))i&&(i.has="stale",this.#S(i,o));else return n&&this.#T(o),i&&(i.has="hit",this.#S(i,o)),!0}else i&&(i.has="miss");return!1}peek(e,r={}){let{allowStale:n=this.allowStale}=r,i=this.#i.get(e);if(i!==void 0&&(n||!this.#h(i))){let o=this.#e[i];return this.#t(o)?o.__staleWhileFetching:o}}#B(e,r,n,i){let o=r===void 0?void 0:this.#e[r];if(this.#t(o))return o;let s=new c8,{signal:a}=n;a?.addEventListener("abort",()=>s.abort(a.reason),{signal:s.signal});let d={signal:s.signal,options:n,context:i},u=(v,x=!1)=>{let{aborted:S}=s.signal,P=n.ignoreFetchAbort&&v!==void 0;if(n.status&&(S&&!x?(n.status.fetchAborted=!0,n.status.fetchError=s.signal.reason,P&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),S&&!P&&!x)return l(s.signal.reason);let A=m;return this.#e[r]===m&&(v===void 0?A.__staleWhileFetching?this.#e[r]=A.__staleWhileFetching:this.delete(e):(n.status&&(n.status.fetchUpdated=!0),this.set(e,v,d.options))),v},c=v=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=v),l(v)),l=v=>{let{aborted:x}=s.signal,S=x&&n.allowStaleOnFetchAbort,P=S||n.allowStaleOnFetchRejection,A=P||n.noDeleteOnFetchRejection,$=m;if(this.#e[r]===m&&(!A||$.__staleWhileFetching===void 0?this.delete(e):S||(this.#e[r]=$.__staleWhileFetching)),P)return n.status&&$.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),$.__staleWhileFetching;if($.__returned===$)throw v},p=(v,x)=>{let S=this.#k?.(e,o,d);S&&S instanceof Promise&&S.then(P=>v(P),x),s.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(v(),n.allowStaleOnFetchAbort&&(v=P=>u(P,!0)))})};n.status&&(n.status.fetchDispatched=!0);let m=new Promise(p).then(u,c),g=Object.assign(m,{__abortController:s,__staleWhileFetching:o,__returned:void 0});return r===void 0?(this.set(e,g,{...d.options,status:void 0}),r=this.#i.get(e)):this.#e[r]=g,g}#t(e){if(!this.#A)return!1;let r=e;return!!r&&r instanceof Promise&&r.hasOwnProperty("__staleWhileFetching")&&r.__abortController instanceof c8}async fetch(e,r={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:s=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:d=0,sizeCalculation:u=this.sizeCalculation,noUpdateTTL:c=this.noUpdateTTL,noDeleteOnFetchRejection:l=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:p=this.allowStaleOnFetchRejection,ignoreFetchAbort:m=this.ignoreFetchAbort,allowStaleOnFetchAbort:g=this.allowStaleOnFetchAbort,context:v,forceRefresh:x=!1,status:S,signal:P}=r;if(!this.#A)return S&&(S.fetch="get"),this.get(e,{allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:o,status:S});let A={allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:o,ttl:s,noDisposeOnSet:a,size:d,sizeCalculation:u,noUpdateTTL:c,noDeleteOnFetchRejection:l,allowStaleOnFetchRejection:p,allowStaleOnFetchAbort:g,ignoreFetchAbort:m,status:S,signal:P},$=this.#i.get(e);if($===void 0){S&&(S.fetch="miss");let j=this.#B(e,$,A,v);return j.__returned=j}else{let j=this.#e[$];if(this.#t(j)){let q=n&&j.__staleWhileFetching!==void 0;return S&&(S.fetch="inflight",q&&(S.returnedStale=!0)),q?j.__staleWhileFetching:j.__returned=j}let L=this.#h($);if(!x&&!L)return S&&(S.fetch="hit"),this.#I($),i&&this.#T($),S&&this.#S(S,$),j;let F=this.#B(e,$,A,v),W=F.__staleWhileFetching!==void 0&&n;return S&&(S.fetch=L?"stale":"refresh",W&&L&&(S.returnedStale=!0)),W?F.__staleWhileFetching:F.__returned=F}}get(e,r={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:s}=r,a=this.#i.get(e);if(a!==void 0){let d=this.#e[a],u=this.#t(d);return s&&this.#S(s,a),this.#h(a)?(s&&(s.get="stale"),u?(s&&n&&d.__staleWhileFetching!==void 0&&(s.returnedStale=!0),n?d.__staleWhileFetching:void 0):(o||this.delete(e),s&&n&&(s.returnedStale=!0),n?d:void 0)):(s&&(s.get="hit"),u?d.__staleWhileFetching:(this.#I(a),i&&this.#T(a),d))}else s&&(s.get="miss")}#j(e,r){this.#f[r]=e,this.#d[e]=r}#I(e){e!==this.#o&&(e===this.#a?this.#a=this.#d[e]:this.#j(this.#f[e],this.#d[e]),this.#j(this.#o,e),this.#o=e)}delete(e){let r=!1;if(this.#n!==0){let n=this.#i.get(e);if(n!==void 0)if(r=!0,this.#n===1)this.clear();else{this.#P(n);let i=this.#e[n];this.#t(i)?i.__abortController.abort(new Error("deleted")):(this.#b||this.#u)&&(this.#b&&this.#v?.(i,e,"delete"),this.#u&&this.#s?.push([i,e,"delete"])),this.#i.delete(e),this.#r[n]=void 0,this.#e[n]=void 0,n===this.#o?this.#o=this.#f[n]:n===this.#a?this.#a=this.#d[n]:(this.#d[this.#f[n]]=this.#d[n],this.#f[this.#d[n]]=this.#f[n]),this.#n--,this.#y.push(n)}}if(this.#u&&this.#s?.length){let n=this.#s,i;for(;i=n?.shift();)this.#p?.(...i)}return r}clear(){for(let e of this.#_({allowStale:!0})){let r=this.#e[e];if(this.#t(r))r.__abortController.abort(new Error("deleted"));else{let n=this.#r[e];this.#b&&this.#v?.(r,n,"delete"),this.#u&&this.#s?.push([r,n,"delete"])}}if(this.#i.clear(),this.#e.fill(void 0),this.#r.fill(void 0),this.#g&&this.#E&&(this.#g.fill(0),this.#E.fill(0)),this.#x&&this.#x.fill(0),this.#a=0,this.#o=0,this.#y.length=0,this.#m=0,this.#n=0,this.#u&&this.#s){let e=this.#s,r;for(;r=e?.shift();)this.#p?.(...r)}}};var lV=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},u8=class{constructor(e){this.timeToLiveInSeconds=e,this.cache=new d8({max:1e5,ttl:e*1e3})}set(e,r){return lV(this,void 0,void 0,function*(){try{this.cache.set(e,r)}catch{}})}get(e){return lV(this,void 0,void 0,function*(){return this.cache.get(e)})}};f();var oB={};Pr(oB,{Authorization:()=>jEe,AuthorizationDelegatedGrant:()=>NEe,AuthorizationOwner:()=>LEe,Definitions:()=>GEe,GeneralJwk:()=>JEe,GeneralJws:()=>ZEe,GenericSignaturePayload:()=>b6e,JwkVerificationMethod:()=>YEe,MessagesFilter:()=>QEe,MessagesQuery:()=>e6e,MessagesRead:()=>t6e,MessagesSubscribe:()=>r6e,NumberRangeFilter:()=>n6e,PaginationCursor:()=>i6e,PermissionGrantData:()=>o6e,PermissionRequestData:()=>s6e,PermissionRevocationData:()=>a6e,PermissionsDefinitions:()=>c6e,PermissionsScopes:()=>d6e,ProtocolDefinition:()=>u6e,ProtocolRuleSet:()=>h6e,ProtocolsConfigure:()=>p6e,ProtocolsQuery:()=>m6e,PublicJwk:()=>v6e,RecordsDelete:()=>KEe,RecordsFilter:()=>g6e,RecordsQuery:()=>FEe,RecordsRead:()=>y6e,RecordsSubscribe:()=>zEe,RecordsWrite:()=>WEe,RecordsWriteDataEncoded:()=>HEe,RecordsWriteSignaturePayload:()=>w6e,RecordsWriteUnidentified:()=>VEe,StringRangeFilter:()=>_6e});f();var jEe=Po;var L0=new RegExp("^[A-Za-z0-9_-]+$","u");function nn(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=nn.evaluated;if(d.dynamicProps&&(d.props=void 0),d.dynamicItems&&(d.items=void 0),a===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let p=a;for(let m in t)if(!(m==="payload"||m==="signatures")){return nn.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:m},message:"must NOT have additional properties"}],!1;break}if(p===a){if(t.payload!==void 0){let m=t.payload,g=a;if(a===a)if(typeof m=="string"){if(!L0.test(m))return nn.errors=[{instancePath:e+"/payload",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/base64url/pattern",keyword:"pattern",params:{pattern:"^[A-Za-z0-9_-]+$"},message:'must match pattern "^[A-Za-z0-9_-]+$"'}],!1}else return nn.errors=[{instancePath:e+"/payload",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/base64url/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=g===a}else var u=!0;if(u)if(t.signatures!==void 0){let m=t.signatures,g=a;if(a===g)if(Array.isArray(m)){if(m.length<1)return nn.errors=[{instancePath:e+"/signatures",schemaPath:"#/properties/signatures/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"}],!1;{var c=!0;let x=m.length;for(let S=0;S10)return ze.errors=[{instancePath:e+"/descriptor/tags",schemaPath:"#/properties/descriptor/properties/tags/maxProperties",keyword:"maxProperties",params:{limit:10},message:"must NOT have more than 10 properties"}],!1;if(Object.keys(Re).length<1)return ze.errors=[{instancePath:e+"/descriptor/tags",schemaPath:"#/properties/descriptor/properties/tags/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;for(let Et in Re){let Fe=Re[Et],mt=a,En=a,ke=!1,Pe=null,Wt=a;if(typeof Fe!="string"){let Ee={instancePath:e+"/descriptor/tags/"+Et.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/descriptor/properties/tags/additionalProperties/oneOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[Ee]:s.push(Ee),a++}var E=Wt===a;E&&(ke=!0,Pe=0);let Be=a;if(!(typeof Fe=="number"&&isFinite(Fe))){let Ee={instancePath:e+"/descriptor/tags/"+Et.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/descriptor/properties/tags/additionalProperties/oneOf/1/type",keyword:"type",params:{type:"number"},message:"must be number"};s===null?s=[Ee]:s.push(Ee),a++}var E=Be===a;if(E&&ke)ke=!1,Pe=[Pe,1];else{E&&(ke=!0,Pe=1);let Ee=a;if(typeof Fe!="boolean"){let Ve={instancePath:e+"/descriptor/tags/"+Et.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/descriptor/properties/tags/additionalProperties/oneOf/2/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};s===null?s=[Ve]:s.push(Ve),a++}var E=Ee===a;if(E&&ke)ke=!1,Pe=[Pe,2];else{E&&(ke=!0,Pe=2);let Ve=a;if(a===Ve)if(Array.isArray(Fe))if(Fe.length>10){let en={instancePath:e+"/descriptor/tags/"+Et.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/descriptor/properties/tags/additionalProperties/oneOf/3/maxItems",keyword:"maxItems",params:{limit:10},message:"must NOT have more than 10 items"};s===null?s=[en]:s.push(en),a++}else if(Fe.length<1){let en={instancePath:e+"/descriptor/tags/"+Et.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/descriptor/properties/tags/additionalProperties/oneOf/3/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};s===null?s=[en]:s.push(en),a++}else{var _=!0;let en=Fe.length;for(let Rt=0;Rt10){let Ye={instancePath:e+"/descriptor/tags/"+Et.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/descriptor/properties/tags/additionalProperties/oneOf/4/maxItems",keyword:"maxItems",params:{limit:10},message:"must NOT have more than 10 items"};s===null?s=[Ye]:s.push(Ye),a++}else if(Fe.length<1){let Ye={instancePath:e+"/descriptor/tags/"+Et.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/descriptor/properties/tags/additionalProperties/oneOf/4/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};s===null?s=[Ye]:s.push(Ye),a++}else{var C=!0;let Ye=Fe.length;for(let pd=0;pd=",limit:1},message:"must be >= 1"}],!1}else return ln.errors=[{instancePath:e+"/descriptor/pagination/limit",schemaPath:"#/properties/descriptor/properties/pagination/properties/limit/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var l=W===a}else var l=!0;if(l)if($.cursor!==void 0){let K=$.cursor,W=a;if(a===a)if(K&&typeof K=="object"&&!Array.isArray(K)){if(Object.keys(K).length<1)return ln.errors=[{instancePath:e+"/descriptor/pagination/cursor",schemaPath:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;{let T;if(K.messageCid===void 0&&(T="messageCid")||K.value===void 0&&(T="value"))return ln.errors=[{instancePath:e+"/descriptor/pagination/cursor",schemaPath:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json/required",keyword:"required",params:{missingProperty:T},message:"must have required property '"+T+"'"}],!1;{let B=a;for(let h in K)if(!(h==="messageCid"||h==="value")){return ln.errors=[{instancePath:e+"/descriptor/pagination/cursor",schemaPath:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:h},message:"must NOT have additional properties"}],!1;break}if(B===a){if(K.messageCid!==void 0){let h=a;if(typeof K.messageCid!="string")return ln.errors=[{instancePath:e+"/descriptor/pagination/cursor/messageCid",schemaPath:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json/properties/messageCid/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var p=h===a}else var p=!0;if(p)if(K.value!==void 0){let h=K.value,y=a;if(typeof h!="string"&&!(typeof h=="number"&&isFinite(h)))return ln.errors=[{instancePath:e+"/descriptor/pagination/cursor/value",schemaPath:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json/properties/value/type",keyword:"type",params:{type:iB.properties.value.type},message:"must be string,number"}],!1;var p=y===a}else var p=!0}}}}else return ln.errors=[{instancePath:e+"/descriptor/pagination/cursor",schemaPath:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var l=W===a}else var l=!0}}else return ln.errors=[{instancePath:e+"/descriptor/pagination",schemaPath:"#/properties/descriptor/properties/pagination/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var c=j===a}else var c=!0;if(c)if(v.dateSort!==void 0){let $=v.dateSort,j=a;if(typeof $!="string")return ln.errors=[{instancePath:e+"/descriptor/dateSort",schemaPath:"#/properties/descriptor/properties/dateSort/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(!($==="createdAscending"||$==="createdDescending"||$==="publishedAscending"||$==="publishedDescending"))return ln.errors=[{instancePath:e+"/descriptor/dateSort",schemaPath:"#/properties/descriptor/properties/dateSort/enum",keyword:"enum",params:{allowedValues:rB.properties.descriptor.properties.dateSort.enum},message:"must be equal to one of the allowed values"}],!1;var c=j===a}else var c=!0}}}}}}}else return ln.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var u=x===a}else var u=!0}}}else return ln.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return ln.errors=s,a===0}ln.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var zEe=Us,pV={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://identity.foundation/dwn/json-schemas/records-subscribe.json",type:"object",additionalProperties:!1,required:["descriptor"],properties:{authorization:{$ref:"https://identity.foundation/dwn/json-schemas/authorization-delegated-grant.json"},descriptor:{type:"object",additionalProperties:!1,required:["interface","method","messageTimestamp","filter"],properties:{interface:{enum:["Records"],type:"string"},method:{enum:["Subscribe"],type:"string"},messageTimestamp:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time"},filter:{$ref:"https://identity.foundation/dwn/json-schemas/records-filter.json"}}}}};function Us(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=Us.evaluated;if(d.dynamicProps&&(d.props=void 0),d.dynamicItems&&(d.items=void 0),a===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let l;if(t.descriptor===void 0&&(l="descriptor"))return Us.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:l},message:"must have required property '"+l+"'"}],!1;{let p=a;for(let m in t)if(!(m==="authorization"||m==="descriptor")){return Us.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:m},message:"must NOT have additional properties"}],!1;break}if(p===a){if(t.authorization!==void 0){let m=a;Ii(t.authorization,{instancePath:e+"/authorization",parentData:t,parentDataProperty:"authorization",rootData:i,dynamicAnchors:o})||(s=s===null?Ii.errors:s.concat(Ii.errors),a=s.length);var u=m===a}else var u=!0;if(u)if(t.descriptor!==void 0){let m=t.descriptor,g=a;if(a===g)if(m&&typeof m=="object"&&!Array.isArray(m)){let x;if(m.interface===void 0&&(x="interface")||m.method===void 0&&(x="method")||m.messageTimestamp===void 0&&(x="messageTimestamp")||m.filter===void 0&&(x="filter"))return Us.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/required",keyword:"required",params:{missingProperty:x},message:"must have required property '"+x+"'"}],!1;{let S=a;for(let P in m)if(!(P==="interface"||P==="method"||P==="messageTimestamp"||P==="filter")){return Us.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:P},message:"must NOT have additional properties"}],!1;break}if(S===a){if(m.interface!==void 0){let P=m.interface,A=a;if(typeof P!="string")return Us.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(P!=="Records")return Us.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/enum",keyword:"enum",params:{allowedValues:pV.properties.descriptor.properties.interface.enum},message:"must be equal to one of the allowed values"}],!1;var c=A===a}else var c=!0;if(c){if(m.method!==void 0){let P=m.method,A=a;if(typeof P!="string")return Us.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(P!=="Subscribe")return Us.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/enum",keyword:"enum",params:{allowedValues:pV.properties.descriptor.properties.method.enum},message:"must be equal to one of the allowed values"}],!1;var c=A===a}else var c=!0;if(c){if(m.messageTimestamp!==void 0){let P=m.messageTimestamp,A=a;if(a===a)if(typeof P=="string"){if(!zi.test(P))return Us.errors=[{instancePath:e+"/descriptor/messageTimestamp",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/pattern",keyword:"pattern",params:{pattern:"^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"},message:'must match pattern "^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"'}],!1}else return Us.errors=[{instancePath:e+"/descriptor/messageTimestamp",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var c=A===a}else var c=!0;if(c)if(m.filter!==void 0){let P=a;Xe(m.filter,{instancePath:e+"/descriptor/filter",parentData:m,parentDataProperty:"filter",rootData:i,dynamicAnchors:o})||(s=s===null?Xe.errors:s.concat(Xe.errors),a=s.length);var c=P===a}else var c=!0}}}}}else return Us.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var u=g===a}else var u=!0}}}else return Us.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return Us.errors=s,a===0}Us.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var WEe=U0;function U0(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=U0.evaluated;if(d.dynamicProps&&(d.props=void 0),d.dynamicItems&&(d.items=void 0),!ze(t,{instancePath:e,parentData:r,parentDataProperty:n,rootData:i,dynamicAnchors:o}))s=s===null?ze.errors:s.concat(ze.errors),a=s.length;else var u=ze.evaluated.props;if(a===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let c;if(t.recordId===void 0&&(c="recordId")||t.authorization===void 0&&(c="authorization"))return U0.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:c},message:"must have required property '"+c+"'"}],!1;if(u!==!0){for(let l in t)if(!u||!u[l]){return U0.errors=[{instancePath:e,schemaPath:"#/unevaluatedProperties",keyword:"unevaluatedProperties",params:{unevaluatedProperty:l},message:"must NOT have unevaluated properties"}],!1;break}}}else return U0.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return U0.errors=s,a===0}U0.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var HEe=vd,VEe=ze,GEe=ox;function ox(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=ox.evaluated;return d.dynamicProps&&(d.props=void 0),d.dynamicItems&&(d.items=void 0),t&&typeof t=="object"&&!Array.isArray(t)?(ox.errors=s,a===0):(ox.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1)}ox.evaluated={dynamicProps:!1,dynamicItems:!1};var JEe=es;function es(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=es.evaluated;d.dynamicProps&&(d.props=void 0),d.dynamicItems&&(d.items=void 0);let u=a,c=!1,l=null,p=a;if(t&&typeof t=="object"&&!Array.isArray(t)){let j;if(t.crv===void 0&&(j="crv")||t.x===void 0&&(j="x")){let L={instancePath:e,schemaPath:"#/oneOf/0/required",keyword:"required",params:{missingProperty:j},message:"must have required property '"+j+"'"};s===null?s=[L]:s.push(L),a++}else{if(t.kty!==void 0){let L=a;if(t.kty!=="EC"){let F={instancePath:e+"/kty",schemaPath:"#/oneOf/0/properties/kty/const",keyword:"const",params:{allowedValue:"EC"},message:"must be equal to constant"};s===null?s=[F]:s.push(F),a++}var m=L===a}else var m=!0;if(m){if(t.crv!==void 0){let L=a;if(typeof t.crv!="string"){let K={instancePath:e+"/crv",schemaPath:"#/oneOf/0/properties/crv/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[K]:s.push(K),a++}var m=L===a}else var m=!0;if(m){if(t.x!==void 0){let L=a;if(typeof t.x!="string"){let K={instancePath:e+"/x",schemaPath:"#/oneOf/0/properties/x/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[K]:s.push(K),a++}var m=L===a}else var m=!0;if(m){if(t.y!==void 0){let L=a;if(typeof t.y!="string"){let K={instancePath:e+"/y",schemaPath:"#/oneOf/0/properties/y/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[K]:s.push(K),a++}var m=L===a}else var m=!0;if(m)if(t.d!==void 0){let L=a;if(typeof t.d!="string"){let K={instancePath:e+"/d",schemaPath:"#/oneOf/0/properties/d/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[K]:s.push(K),a++}var m=L===a}else var m=!0}}}}}var S=p===a;if(S){c=!0,l=0;var g={};g.kty=!0,g.crv=!0,g.x=!0,g.y=!0,g.d=!0}let v=a;if(t&&typeof t=="object"&&!Array.isArray(t)){let j;if(t.crv===void 0&&(j="crv")||t.x===void 0&&(j="x")){let L={instancePath:e,schemaPath:"#/oneOf/1/required",keyword:"required",params:{missingProperty:j},message:"must have required property '"+j+"'"};s===null?s=[L]:s.push(L),a++}else{if(t.kty!==void 0){let L=a;if(t.kty!=="OKP"){let F={instancePath:e+"/kty",schemaPath:"#/oneOf/1/properties/kty/const",keyword:"const",params:{allowedValue:"OKP"},message:"must be equal to constant"};s===null?s=[F]:s.push(F),a++}var x=L===a}else var x=!0;if(x){if(t.crv!==void 0){let L=a;if(typeof t.crv!="string"){let K={instancePath:e+"/crv",schemaPath:"#/oneOf/1/properties/crv/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[K]:s.push(K),a++}var x=L===a}else var x=!0;if(x){if(t.x!==void 0){let L=a;if(typeof t.x!="string"){let K={instancePath:e+"/x",schemaPath:"#/oneOf/1/properties/x/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[K]:s.push(K),a++}var x=L===a}else var x=!0;if(x)if(t.d!==void 0){let L=a;if(typeof t.d!="string"){let K={instancePath:e+"/d",schemaPath:"#/oneOf/1/properties/d/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[K]:s.push(K),a++}var x=L===a}else var x=!0}}}}var S=v===a;if(S&&c)c=!1,l=[l,1];else{S&&(c=!0,l=1,g!==!0&&(g=g||{},g.kty=!0,g.crv=!0,g.x=!0,g.d=!0));let j=a;if(t&&typeof t=="object"&&!Array.isArray(t)){let F;if(t.n===void 0&&(F="n")||t.e===void 0&&(F="e")){let K={instancePath:e,schemaPath:"#/oneOf/2/required",keyword:"required",params:{missingProperty:F},message:"must have required property '"+F+"'"};s===null?s=[K]:s.push(K),a++}else{if(t.kty!==void 0){let K=a;if(t.kty!=="RSA"){let W={instancePath:e+"/kty",schemaPath:"#/oneOf/2/properties/kty/const",keyword:"const",params:{allowedValue:"RSA"},message:"must be equal to constant"};s===null?s=[W]:s.push(W),a++}var P=K===a}else var P=!0;if(P){if(t.n!==void 0){let K=a;if(typeof t.n!="string"){let q={instancePath:e+"/n",schemaPath:"#/oneOf/2/properties/n/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[q]:s.push(q),a++}var P=K===a}else var P=!0;if(P){if(t.e!==void 0){let K=a;if(typeof t.e!="string"){let q={instancePath:e+"/e",schemaPath:"#/oneOf/2/properties/e/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[q]:s.push(q),a++}var P=K===a}else var P=!0;if(P){if(t.d!==void 0){let K=a;if(typeof t.d!="string"){let q={instancePath:e+"/d",schemaPath:"#/oneOf/2/properties/d/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[q]:s.push(q),a++}var P=K===a}else var P=!0;if(P){if(t.p!==void 0){let K=a;if(typeof t.p!="string"){let q={instancePath:e+"/p",schemaPath:"#/oneOf/2/properties/p/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[q]:s.push(q),a++}var P=K===a}else var P=!0;if(P){if(t.q!==void 0){let K=a;if(typeof t.q!="string"){let q={instancePath:e+"/q",schemaPath:"#/oneOf/2/properties/q/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[q]:s.push(q),a++}var P=K===a}else var P=!0;if(P){if(t.dp!==void 0){let K=a;if(typeof t.dp!="string"){let q={instancePath:e+"/dp",schemaPath:"#/oneOf/2/properties/dp/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[q]:s.push(q),a++}var P=K===a}else var P=!0;if(P){if(t.dq!==void 0){let K=a;if(typeof t.dq!="string"){let q={instancePath:e+"/dq",schemaPath:"#/oneOf/2/properties/dq/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[q]:s.push(q),a++}var P=K===a}else var P=!0;if(P){if(t.qi!==void 0){let K=a;if(typeof t.qi!="string"){let q={instancePath:e+"/qi",schemaPath:"#/oneOf/2/properties/qi/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[q]:s.push(q),a++}var P=K===a}else var P=!0;if(P)if(t.oth!==void 0){let K=t.oth,W=a;if(!(K&&typeof K=="object"&&!Array.isArray(K))){let I={instancePath:e+"/oth",schemaPath:"#/oneOf/2/properties/oth/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[I]:s.push(I),a++}var P=W===a}else var P=!0}}}}}}}}}}var S=j===a;if(S&&c)c=!1,l=[l,2];else{S&&(c=!0,l=2,g!==!0&&(g=g||{},g.kty=!0,g.n=!0,g.e=!0,g.d=!0,g.p=!0,g.q=!0,g.dp=!0,g.dq=!0,g.qi=!0,g.oth=!0));let F=a;if(t&&typeof t=="object"&&!Array.isArray(t)){let W;if(t.k===void 0&&(W="k")){let q={instancePath:e,schemaPath:"#/oneOf/3/required",keyword:"required",params:{missingProperty:W},message:"must have required property '"+W+"'"};s===null?s=[q]:s.push(q),a++}else{if(t.kty!==void 0){let q=a;if(t.kty!=="oct"){let I={instancePath:e+"/kty",schemaPath:"#/oneOf/3/properties/kty/const",keyword:"const",params:{allowedValue:"oct"},message:"must be equal to constant"};s===null?s=[I]:s.push(I),a++}var A=q===a}else var A=!0;if(A)if(t.k!==void 0){let q=a;if(typeof t.k!="string"){let T={instancePath:e+"/k",schemaPath:"#/oneOf/3/properties/k/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[T]:s.push(T),a++}var A=q===a}else var A=!0}}var S=F===a;S&&c?(c=!1,l=[l,3]):S&&(c=!0,l=3,g!==!0&&(g=g||{},g.kty=!0,g.k=!0))}}if(c)a=u,s!==null&&(u?s.length=u:s=null);else{let j={instancePath:e,schemaPath:"#/oneOf",keyword:"oneOf",params:{passingSchemas:l},message:"must match exactly one schema in oneOf"};return s===null?s=[j]:s.push(j),a++,es.errors=s,!1}if(a===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let j;if(t.kty===void 0&&(j="kty"))return es.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:j},message:"must have required property '"+j+"'"}],!1;if(g!==!0&&(g=g||{},g.alg=!0,g.kid=!0,g.kty=!0,g.crv=!0,g.use=!0,g.key_ops=!0,g.x5u=!0,g.x5c=!0,g.x5t=!0,g["x5t#S256"]=!0),t.alg!==void 0){let L=a;if(typeof t.alg!="string")return es.errors=[{instancePath:e+"/alg",schemaPath:"#/properties/alg/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var $=L===a}else var $=!0;if($){if(t.kid!==void 0){let L=a;if(typeof t.kid!="string")return es.errors=[{instancePath:e+"/kid",schemaPath:"#/properties/kid/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var $=L===a}else var $=!0;if($){if(t.kty!==void 0){let L=t.kty,F=a;if(!(L==="EC"||L==="RSA"||L==="oct"||L==="OKP"))return es.errors=[{instancePath:e+"/kty",schemaPath:"#/properties/kty/enum",keyword:"enum",params:{allowedValues:AV.properties.kty.enum},message:"must be equal to one of the allowed values"}],!1;var $=F===a}else var $=!0;if($){if(t.crv!==void 0){let L=a;if(typeof t.crv!="string")return es.errors=[{instancePath:e+"/crv",schemaPath:"#/properties/crv/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var $=L===a}else var $=!0;if($){if(t.use!==void 0){let L=a;if(typeof t.use!="string")return es.errors=[{instancePath:e+"/use",schemaPath:"#/properties/use/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var $=L===a}else var $=!0;if($){if(t.key_ops!==void 0){let L=a;if(typeof t.key_ops!="string")return es.errors=[{instancePath:e+"/key_ops",schemaPath:"#/properties/key_ops/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var $=L===a}else var $=!0;if($){if(t.x5u!==void 0){let L=a;if(typeof t.x5u!="string")return es.errors=[{instancePath:e+"/x5u",schemaPath:"#/properties/x5u/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var $=L===a}else var $=!0;if($){if(t.x5c!==void 0){let L=a;if(typeof t.x5c!="string")return es.errors=[{instancePath:e+"/x5c",schemaPath:"#/properties/x5c/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var $=L===a}else var $=!0;if($){if(t.x5t!==void 0){let L=a;if(typeof t.x5t!="string")return es.errors=[{instancePath:e+"/x5t",schemaPath:"#/properties/x5t/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var $=L===a}else var $=!0;if($)if(t["x5t#S256"]!==void 0){let L=a;if(typeof t["x5t#S256"]!="string")return es.errors=[{instancePath:e+"/x5t#S256",schemaPath:"#/properties/x5t%23S256/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var $=L===a}else var $=!0}}}}}}}}}else return es.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return es.errors=s,d.props=g,a===0}es.evaluated={dynamicProps:!0,dynamicItems:!1};var ZEe=nn,YEe=yu,XEe={$id:"https://identity.foundation/dwn/json-schemas/jwk-verification-method.json",$schema:"https://json-schema.org/draft/2020-12/schema",type:"object",additionalProperties:!1,required:["id","type","controller","publicKeyJwk"],properties:{id:{type:"string"},type:{enum:["JsonWebKey","JsonWebKey2020"]},controller:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did"},publicKeyJwk:{$ref:"https://identity.foundation/dwn/json-schemas/public-jwk.json"}}};function yu(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=yu.evaluated;if(d.dynamicProps&&(d.props=void 0),d.dynamicItems&&(d.items=void 0),a===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let c;if(t.id===void 0&&(c="id")||t.type===void 0&&(c="type")||t.controller===void 0&&(c="controller")||t.publicKeyJwk===void 0&&(c="publicKeyJwk"))return yu.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:c},message:"must have required property '"+c+"'"}],!1;{let l=a;for(let p in t)if(!(p==="id"||p==="type"||p==="controller"||p==="publicKeyJwk")){return yu.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:p},message:"must NOT have additional properties"}],!1;break}if(l===a){if(t.id!==void 0){let p=a;if(typeof t.id!="string")return yu.errors=[{instancePath:e+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=p===a}else var u=!0;if(u){if(t.type!==void 0){let p=t.type,m=a;if(!(p==="JsonWebKey"||p==="JsonWebKey2020"))return yu.errors=[{instancePath:e+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:XEe.properties.type.enum},message:"must be equal to one of the allowed values"}],!1;var u=m===a}else var u=!0;if(u){if(t.controller!==void 0){let p=t.controller,m=a;if(a===a)if(typeof p=="string"){if(!rm.test(p))return yu.errors=[{instancePath:e+"/controller",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did/pattern",keyword:"pattern",params:{pattern:"^did:([a-z0-9]+):((?:(?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))*:)*((?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))+))((;[a-zA-Z0-9_.:%-]+=[a-zA-Z0-9_.:%-]*)*)(/[^#?]*)?([?][^#]*)?(#.*)?$"},message:'must match pattern "^did:([a-z0-9]+):((?:(?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))*:)*((?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))+))((;[a-zA-Z0-9_.:%-]+=[a-zA-Z0-9_.:%-]*)*)(/[^#?]*)?([?][^#]*)?(#.*)?$"'}],!1}else return yu.errors=[{instancePath:e+"/controller",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=m===a}else var u=!0;if(u)if(t.publicKeyJwk!==void 0){let p=a;rn(t.publicKeyJwk,{instancePath:e+"/publicKeyJwk",parentData:t,parentDataProperty:"publicKeyJwk",rootData:i,dynamicAnchors:o})||(s=s===null?rn.errors:s.concat(rn.errors),a=s.length);var u=p===a}else var u=!0}}}}}else return yu.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return yu.errors=s,a===0}yu.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var QEe=qn,mV={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://identity.foundation/dwn/json-schemas/messages-filter.json",type:"object",additionalProperties:!1,minProperties:1,properties:{interface:{enum:["Protocols","Records"],type:"string"},method:{enum:["Configure","Delete","Write"],type:"string"},protocol:{type:"string"},messageTimestamp:{type:"object",minProperties:1,additionalProperties:!1,properties:{from:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time"},to:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time"}}}}};function qn(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=qn.evaluated;if(d.dynamicProps&&(d.props=void 0),d.dynamicItems&&(d.items=void 0),a===0)if(t&&typeof t=="object"&&!Array.isArray(t)){if(Object.keys(t).length<1)return qn.errors=[{instancePath:e,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;{let l=a;for(let p in t)if(!(p==="interface"||p==="method"||p==="protocol"||p==="messageTimestamp")){return qn.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:p},message:"must NOT have additional properties"}],!1;break}if(l===a){if(t.interface!==void 0){let p=t.interface,m=a;if(typeof p!="string")return qn.errors=[{instancePath:e+"/interface",schemaPath:"#/properties/interface/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(!(p==="Protocols"||p==="Records"))return qn.errors=[{instancePath:e+"/interface",schemaPath:"#/properties/interface/enum",keyword:"enum",params:{allowedValues:mV.properties.interface.enum},message:"must be equal to one of the allowed values"}],!1;var u=m===a}else var u=!0;if(u){if(t.method!==void 0){let p=t.method,m=a;if(typeof p!="string")return qn.errors=[{instancePath:e+"/method",schemaPath:"#/properties/method/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(!(p==="Configure"||p==="Delete"||p==="Write"))return qn.errors=[{instancePath:e+"/method",schemaPath:"#/properties/method/enum",keyword:"enum",params:{allowedValues:mV.properties.method.enum},message:"must be equal to one of the allowed values"}],!1;var u=m===a}else var u=!0;if(u){if(t.protocol!==void 0){let p=a;if(typeof t.protocol!="string")return qn.errors=[{instancePath:e+"/protocol",schemaPath:"#/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=p===a}else var u=!0;if(u)if(t.messageTimestamp!==void 0){let p=t.messageTimestamp,m=a;if(a===m)if(p&&typeof p=="object"&&!Array.isArray(p)){if(Object.keys(p).length<1)return qn.errors=[{instancePath:e+"/messageTimestamp",schemaPath:"#/properties/messageTimestamp/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;{let v=a;for(let x in p)if(!(x==="from"||x==="to")){return qn.errors=[{instancePath:e+"/messageTimestamp",schemaPath:"#/properties/messageTimestamp/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:x},message:"must NOT have additional properties"}],!1;break}if(v===a){if(p.from!==void 0){let x=p.from,S=a;if(a===a)if(typeof x=="string"){if(!zi.test(x))return qn.errors=[{instancePath:e+"/messageTimestamp/from",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/pattern",keyword:"pattern",params:{pattern:"^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"},message:'must match pattern "^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"'}],!1}else return qn.errors=[{instancePath:e+"/messageTimestamp/from",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var c=S===a}else var c=!0;if(c)if(p.to!==void 0){let x=p.to,S=a;if(a===a)if(typeof x=="string"){if(!zi.test(x))return qn.errors=[{instancePath:e+"/messageTimestamp/to",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/pattern",keyword:"pattern",params:{pattern:"^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"},message:'must match pattern "^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"'}],!1}else return qn.errors=[{instancePath:e+"/messageTimestamp/to",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var c=S===a}else var c=!0}}}else return qn.errors=[{instancePath:e+"/messageTimestamp",schemaPath:"#/properties/messageTimestamp/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var u=m===a}else var u=!0}}}}}else return qn.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return qn.errors=s,a===0}qn.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var e6e=ei,yV={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://identity.foundation/dwn/json-schemas/messages-query.json",type:"object",additionalProperties:!1,required:["authorization","descriptor"],properties:{authorization:{$ref:"https://identity.foundation/dwn/json-schemas/authorization.json"},descriptor:{type:"object",additionalProperties:!1,required:["interface","method","messageTimestamp","filters"],properties:{interface:{enum:["Messages"],type:"string"},method:{enum:["Query"],type:"string"},messageTimestamp:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time"},filters:{type:"array",items:{$ref:"https://identity.foundation/dwn/json-schemas/messages-filter.json"}},cursor:{$ref:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json"}}}}};function ei(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=ei.evaluated;if(d.dynamicProps&&(d.props=void 0),d.dynamicItems&&(d.items=void 0),a===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let m;if(t.authorization===void 0&&(m="authorization")||t.descriptor===void 0&&(m="descriptor"))return ei.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:m},message:"must have required property '"+m+"'"}],!1;{let g=a;for(let v in t)if(!(v==="authorization"||v==="descriptor")){return ei.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:v},message:"must NOT have additional properties"}],!1;break}if(g===a){if(t.authorization!==void 0){let v=a;Po(t.authorization,{instancePath:e+"/authorization",parentData:t,parentDataProperty:"authorization",rootData:i,dynamicAnchors:o})||(s=s===null?Po.errors:s.concat(Po.errors),a=s.length);var u=v===a}else var u=!0;if(u)if(t.descriptor!==void 0){let v=t.descriptor,x=a;if(a===x)if(v&&typeof v=="object"&&!Array.isArray(v)){let P;if(v.interface===void 0&&(P="interface")||v.method===void 0&&(P="method")||v.messageTimestamp===void 0&&(P="messageTimestamp")||v.filters===void 0&&(P="filters"))return ei.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/required",keyword:"required",params:{missingProperty:P},message:"must have required property '"+P+"'"}],!1;{let A=a;for(let $ in v)if(!($==="interface"||$==="method"||$==="messageTimestamp"||$==="filters"||$==="cursor")){return ei.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:$},message:"must NOT have additional properties"}],!1;break}if(A===a){if(v.interface!==void 0){let $=v.interface,j=a;if(typeof $!="string")return ei.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if($!=="Messages")return ei.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/enum",keyword:"enum",params:{allowedValues:yV.properties.descriptor.properties.interface.enum},message:"must be equal to one of the allowed values"}],!1;var c=j===a}else var c=!0;if(c){if(v.method!==void 0){let $=v.method,j=a;if(typeof $!="string")return ei.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if($!=="Query")return ei.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/enum",keyword:"enum",params:{allowedValues:yV.properties.descriptor.properties.method.enum},message:"must be equal to one of the allowed values"}],!1;var c=j===a}else var c=!0;if(c){if(v.messageTimestamp!==void 0){let $=v.messageTimestamp,j=a;if(a===a)if(typeof $=="string"){if(!zi.test($))return ei.errors=[{instancePath:e+"/descriptor/messageTimestamp",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/pattern",keyword:"pattern",params:{pattern:"^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"},message:'must match pattern "^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"'}],!1}else return ei.errors=[{instancePath:e+"/descriptor/messageTimestamp",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var c=j===a}else var c=!0;if(c){if(v.filters!==void 0){let $=v.filters,j=a;if(a===j)if(Array.isArray($)){var l=!0;let F=$.length;for(let K=0;K=",limit:0},message:"must be >= 0"}],!1}else return Ir.errors=[{instancePath:e+"/$size/min",schemaPath:"#/properties/%24size/properties/min/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var P=_===a}else var P=!0;if(P)if(B.max!==void 0){let E=B.max,_=a;if(a===_)if(typeof E=="number"&&isFinite(E)){if(E<0||isNaN(E))return Ir.errors=[{instancePath:e+"/$size/max",schemaPath:"#/properties/%24size/properties/max/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"}],!1}else return Ir.errors=[{instancePath:e+"/$size/max",schemaPath:"#/properties/%24size/properties/max/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var P=_===a}else var P=!0}}else return Ir.errors=[{instancePath:e+"/$size",schemaPath:"#/properties/%24size/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var c=h===a}else var c=!0;if(c){if(t.$tags!==void 0){let B=t.$tags,h=a;if(a===h)if(B&&typeof B=="object"&&!Array.isArray(B)){if(Object.keys(B).length<1)return Ir.errors=[{instancePath:e+"/$tags",schemaPath:"#/properties/%24tags/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;if(B.$requiredTags!==void 0){let w=B.$requiredTags,E=a;if(a===E)if(Array.isArray(w)){var A=!0;let _=w.length;for(let b=0;b<_;b++){let C=a;if(typeof w[b]!="string")return Ir.errors=[{instancePath:e+"/$tags/$requiredTags/"+b,schemaPath:"#/properties/%24tags/properties/%24requiredTags/items/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var A=C===a;if(!A)break}}else return Ir.errors=[{instancePath:e+"/$tags/$requiredTags",schemaPath:"#/properties/%24tags/properties/%24requiredTags/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;var $=E===a}else var $=!0;if($){if(B.$allowUndefinedTags!==void 0){let w=a;if(typeof B.$allowUndefinedTags!="boolean")return Ir.errors=[{instancePath:e+"/$tags/$allowUndefinedTags",schemaPath:"#/properties/%24tags/properties/%24allowUndefinedTags/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;var $=w===a}else var $=!0;if($){var j={};j.$requiredTags=!0,j.$allowUndefinedTags=!0;for(let w in B)if(l6e.test(w)){let E=B[w];if(a===a)if(E&&typeof E=="object"&&!Array.isArray(E)){let b=a;for(let C in E)if(!(C==="type"||C==="items"||C==="contains"||f6e.test(C))){return Ir.errors=[{instancePath:e+"/$tags/"+w.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/%24tags/patternProperties/%5E(%3F!%5C%24requiredTags%24%7C%5C%24allowUndefinedTags%24).*%24/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:C},message:"must NOT have additional properties"}],!1;break}if(b===a){if(E.type!==void 0){let C=E.type,N=a;if(!(C==="string"||C==="number"||C==="integer"||C==="boolean"||C==="array"))return Ir.errors=[{instancePath:e+"/$tags/"+w.replace(/~/g,"~0").replace(/\//g,"~1")+"/type",schemaPath:"#/properties/%24tags/patternProperties/%5E(%3F!%5C%24requiredTags%24%7C%5C%24allowUndefinedTags%24).*%24/properties/type/enum",keyword:"enum",params:{allowedValues:aw.properties.$tags.patternProperties["^(?!\\$requiredTags$|\\$allowUndefinedTags$).*$"].properties.type.enum},message:"must be equal to one of the allowed values"}],!1;var L=N===a}else var L=!0;if(L){if(E.items!==void 0){let C=E.items,N=a;if(a===N)if(C&&typeof C=="object"&&!Array.isArray(C)){if(C.type!==void 0){let U=C.type,G=a;if(!(U==="string"||U==="number"||U==="integer"))return Ir.errors=[{instancePath:e+"/$tags/"+w.replace(/~/g,"~0").replace(/\//g,"~1")+"/items/type",schemaPath:"#/properties/%24tags/patternProperties/%5E(%3F!%5C%24requiredTags%24%7C%5C%24allowUndefinedTags%24).*%24/properties/items/properties/type/enum",keyword:"enum",params:{allowedValues:aw.properties.$tags.patternProperties["^(?!\\$requiredTags$|\\$allowUndefinedTags$).*$"].properties.items.properties.type.enum},message:"must be equal to one of the allowed values"}],!1;var F=G===a}else var F=!0;if(F){var K={};K.type=!0;for(let U in C)_V.test(U)&&(K[U]=!0)}}else return Ir.errors=[{instancePath:e+"/$tags/"+w.replace(/~/g,"~0").replace(/\//g,"~1")+"/items",schemaPath:"#/properties/%24tags/patternProperties/%5E(%3F!%5C%24requiredTags%24%7C%5C%24allowUndefinedTags%24).*%24/properties/items/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var L=N===a}else var L=!0;if(L)if(E.contains!==void 0){let C=E.contains,N=a;if(a===N)if(C&&typeof C=="object"&&!Array.isArray(C)){if(C.type!==void 0){let U=C.type,G=a;if(!(U==="string"||U==="number"||U==="integer"))return Ir.errors=[{instancePath:e+"/$tags/"+w.replace(/~/g,"~0").replace(/\//g,"~1")+"/contains/type",schemaPath:"#/properties/%24tags/patternProperties/%5E(%3F!%5C%24requiredTags%24%7C%5C%24allowUndefinedTags%24).*%24/properties/contains/properties/type/enum",keyword:"enum",params:{allowedValues:aw.properties.$tags.patternProperties["^(?!\\$requiredTags$|\\$allowUndefinedTags$).*$"].properties.contains.properties.type.enum},message:"must be equal to one of the allowed values"}],!1;var W=G===a}else var W=!0;if(W){var q={};q.type=!0;for(let U in C)_V.test(U)&&(q[U]=!0)}}else return Ir.errors=[{instancePath:e+"/$tags/"+w.replace(/~/g,"~0").replace(/\//g,"~1")+"/contains",schemaPath:"#/properties/%24tags/patternProperties/%5E(%3F!%5C%24requiredTags%24%7C%5C%24allowUndefinedTags%24).*%24/properties/contains/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var L=N===a}else var L=!0}}}else return Ir.errors=[{instancePath:e+"/$tags/"+w.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/%24tags/patternProperties/%5E(%3F!%5C%24requiredTags%24%7C%5C%24allowUndefinedTags%24).*%24/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;j[w]=!0}}}}else return Ir.errors=[{instancePath:e+"/$tags",schemaPath:"#/properties/%24tags/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var c=h===a}else var c=!0;if(c){var I=!0;for(let B in t)if(wV.test(B)){let h=a;nB.validate(t[B],{instancePath:e+"/"+B.replace(/~/g,"~0").replace(/\//g,"~1"),parentData:t,parentDataProperty:B,rootData:i,dynamicAnchors:o})||(s=s===null?nB.validate.errors:s.concat(nB.validate.errors),a=s.length);var I=h===a;if(!I)break}}}}}}}}else return Ir.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return Ir.errors=s,a===0}Ir.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};function Fi(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=Fi.evaluated;if(d.dynamicProps&&(d.props=void 0),d.dynamicItems&&(d.items=void 0),a===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let g;if(t.protocol===void 0&&(g="protocol")||t.published===void 0&&(g="published")||t.types===void 0&&(g="types")||t.structure===void 0&&(g="structure"))return Fi.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:g},message:"must have required property '"+g+"'"}],!1;{let v=a;for(let x in t)if(!(x==="protocol"||x==="published"||x==="types"||x==="structure")){return Fi.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:x},message:"must NOT have additional properties"}],!1;break}if(v===a){if(t.protocol!==void 0){let x=a;if(typeof t.protocol!="string")return Fi.errors=[{instancePath:e+"/protocol",schemaPath:"#/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=x===a}else var u=!0;if(u){if(t.published!==void 0){let x=a;if(typeof t.published!="boolean")return Fi.errors=[{instancePath:e+"/published",schemaPath:"#/properties/published/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;var u=x===a}else var u=!0;if(u){if(t.types!==void 0){let x=t.types,S=a;if(a===S)if(x&&typeof x=="object"&&!Array.isArray(x)){var c={};for(let A in x)if(bV.test(A)){let $=x[A];if(a===a)if($&&typeof $=="object"&&!Array.isArray($)){let L=a;for(let F in $)if(!(F==="schema"||F==="dataFormats")){return Fi.errors=[{instancePath:e+"/types/"+A.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/types/patternProperties/.*/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:F},message:"must NOT have additional properties"}],!1;break}if(L===a){if($.schema!==void 0){let F=a;if(typeof $.schema!="string")return Fi.errors=[{instancePath:e+"/types/"+A.replace(/~/g,"~0").replace(/\//g,"~1")+"/schema",schemaPath:"#/properties/types/patternProperties/.*/properties/schema/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var l=F===a}else var l=!0;if(l)if($.dataFormats!==void 0){let F=$.dataFormats,K=a;if(a===K)if(Array.isArray(F)){if(F.length<1)return Fi.errors=[{instancePath:e+"/types/"+A.replace(/~/g,"~0").replace(/\//g,"~1")+"/dataFormats",schemaPath:"#/properties/types/patternProperties/.*/properties/dataFormats/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"}],!1;{var p=!0;let q=F.length;for(let I=0;Ivx,decode:()=>KSe,encode:()=>LSe,name:()=>qSe});f();f();f();f();var x6e=["string","number","bigint","symbol"],E6e=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function IV(t){if(t===null)return"null";if(t===void 0)return"undefined";if(t===!0||t===!1)return"boolean";let e=typeof t;if(x6e.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(t))return"Array";if(S6e(t))return"Buffer";let r=A6e(t);return r||"Object"}function S6e(t){return t&&t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer.call(null,t)}function A6e(t){let e=Object.prototype.toString.call(t).slice(8,-1);if(E6e.includes(e))return e}f();var ve=class{constructor(e,r,n){this.major=e,this.majorEncoded=e<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.majore.major?1:0}};ve.uint=new ve(0,"uint",!0);ve.negint=new ve(1,"negint",!0);ve.bytes=new ve(2,"bytes",!0);ve.string=new ve(3,"string",!0);ve.array=new ve(4,"array",!1);ve.map=new ve(5,"map",!1);ve.tag=new ve(6,"tag",!1);ve.float=new ve(7,"float",!0);ve.false=new ve(7,"false",!0);ve.true=new ve(7,"true",!0);ve.null=new ve(7,"null",!0);ve.undefined=new ve(7,"undefined",!0);ve.break=new ve(7,"break",!0);var We=class{constructor(e,r,n){this.type=e,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};f();f();var cw=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",T6e=new TextDecoder,P6e=new TextEncoder;function l8(t){return cw&&globalThis.Buffer.isBuffer(t)}function aB(t){return t instanceof Uint8Array?l8(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t:Uint8Array.from(t)}var BV=cw?(t,e,r)=>r-e>64?globalThis.Buffer.from(t.subarray(e,r)).toString("utf8"):RV(t,e,r):(t,e,r)=>r-e>64?T6e.decode(t.subarray(e,r)):RV(t,e,r),MV=cw?t=>t.length>64?globalThis.Buffer.from(t):kV(t):t=>t.length>64?P6e.encode(t):kV(t),Pl=t=>Uint8Array.from(t),dw=cw?(t,e,r)=>l8(t)?new Uint8Array(t.subarray(e,r)):t.slice(e,r):(t,e,r)=>t.slice(e,r),OV=cw?(t,e)=>(t=t.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),aB(globalThis.Buffer.concat(t,e))):(t,e)=>{let r=new Uint8Array(e),n=0;for(let i of t)n+i.length>r.length&&(i=i.subarray(0,r.length-n)),r.set(i,n),n+=i.length;return r},CV=cw?t=>globalThis.Buffer.allocUnsafe(t):t=>new Uint8Array(t);function $V(t,e){if(l8(t)&&l8(e))return t.compare(e);for(let r=0;r55295&&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 RV(t,e,r){let n=[];for(;e239?4:i>223?3:i>191?2:1;if(e+s<=r){let a,d,u,c;switch(s){case 1:i<128&&(o=i);break;case 2:a=t[e+1],(a&192)===128&&(c=(i&31)<<6|a&63,c>127&&(o=c));break;case 3:a=t[e+1],d=t[e+2],(a&192)===128&&(d&192)===128&&(c=(i&15)<<12|(a&63)<<6|d&63,c>2047&&(c<55296||c>57343)&&(o=c));break;case 4:a=t[e+1],d=t[e+2],u=t[e+3],(a&192)===128&&(d&192)===128&&(u&192)===128&&(c=(i&15)<<18|(a&63)<<12|(d&63)<<6|u&63,c>65535&&c<1114112&&(o=c))}}o===null?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),e+=s}return I6e(n)}var DV=4096;function I6e(t){let e=t.length;if(e<=DV)return String.fromCharCode.apply(String,t);let r="",n=0;for(;nn.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=dw(n,0,this.cursor)}else r=OV(this.chunks,this.cursor);return e&&this.reset(),r}};f();var Kt="CBOR decode error:",cB="CBOR encode error:",dx=[];dx[23]=1;dx[24]=2;dx[25]=3;dx[26]=5;dx[27]=9;function ih(t,e,r){if(t.length-e>>8,n&255])}else if(r>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n>BigInt(32)&BigInt(4294967295));i[8]=o&255,o=o>>8,i[7]=o&255,o=o>>8,i[6]=o&255,o=o>>8,i[5]=o&255,i[4]=s&255,s=s>>8,i[3]=s&255,s=s>>8,i[2]=s&255,s=s>>8,i[1]=s&255,t.push(i)}else throw new Error(`${Kt} encountered BigInt larger than allowable range`)}}bd.encodedSize=function(e){return rs.encodedSize(e.value)};rs.encodedSize=function(e){return er.value?1:0};f();function LV(t,e,r,n){return new We(ve.negint,-1-Pc(t,e+1,n),2)}function KV(t,e,r,n){return new We(ve.negint,-1-Ic(t,e+1,n),3)}function FV(t,e,r,n){return new We(ve.negint,-1-kc(t,e+1,n),5)}var dB=BigInt(-1),zV=BigInt(1);function WV(t,e,r,n){let i=Rc(t,e+1,n);if(typeof i!="bigint"){let o=-1-i;if(o>=Number.MIN_SAFE_INTEGER)return new We(ve.negint,o,9)}if(n.allowBigInt!==!0)throw new Error(`${Kt} integers outside of the safe integer range are not supported`);return new We(ve.negint,dB-BigInt(i),9)}function f8(t,e){let r=e.value,n=typeof r=="bigint"?r*dB-zV:r*-1-1;rs(t,e.type.majorEncoded,n)}f8.encodedSize=function(e){let r=e.value,n=typeof r=="bigint"?r*dB-zV:r*-1-1;return nr.value?-1:0};f();function ux(t,e,r,n){ih(t,e,r+n);let i=dw(t,e+r,e+r+n);return new We(ve.bytes,i,r+n)}function HV(t,e,r,n){return ux(t,e,1,r)}function VV(t,e,r,n){return ux(t,e,2,Pc(t,e+1,n))}function GV(t,e,r,n){return ux(t,e,3,Ic(t,e+1,n))}function JV(t,e,r,n){return ux(t,e,5,kc(t,e+1,n))}function ZV(t,e,r,n){let i=Rc(t,e+1,n);if(typeof i=="bigint")throw new Error(`${Kt} 64-bit integer bytes lengths not supported`);return ux(t,e,9,i)}function h8(t){return t.encodedBytes===void 0&&(t.encodedBytes=t.type===ve.string?MV(t.value):t.value),t.encodedBytes}function uw(t,e){let r=h8(e);rs(t,e.type.majorEncoded,r.length),t.push(r)}uw.encodedSize=function(e){let r=h8(e);return rs.encodedSize(r.length)+r.length};uw.compareTokens=function(e,r){return D6e(h8(e),h8(r))};function D6e(t,e){return t.lengthe.length?1:$V(t,e)}f();function lx(t,e,r,n,i){let o=r+n;ih(t,e,o);let s=new We(ve.string,BV(t,e+r,e+o),o);return i.retainStringBytes===!0&&(s.byteValue=dw(t,e+r,e+o)),s}function YV(t,e,r,n){return lx(t,e,1,r,n)}function XV(t,e,r,n){return lx(t,e,2,Pc(t,e+1,n),n)}function QV(t,e,r,n){return lx(t,e,3,Ic(t,e+1,n),n)}function eG(t,e,r,n){return lx(t,e,5,kc(t,e+1,n),n)}function tG(t,e,r,n){let i=Rc(t,e+1,n);if(typeof i=="bigint")throw new Error(`${Kt} 64-bit integer string lengths not supported`);return lx(t,e,9,i,n)}var rG=uw;f();function lw(t,e,r,n){return new We(ve.array,n,r)}function nG(t,e,r,n){return lw(t,e,1,r)}function iG(t,e,r,n){return lw(t,e,2,Pc(t,e+1,n))}function oG(t,e,r,n){return lw(t,e,3,Ic(t,e+1,n))}function sG(t,e,r,n){return lw(t,e,5,kc(t,e+1,n))}function aG(t,e,r,n){let i=Rc(t,e+1,n);if(typeof i=="bigint")throw new Error(`${Kt} 64-bit integer array lengths not supported`);return lw(t,e,9,i)}function cG(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${Kt} indefinite length items not allowed`);return lw(t,e,1,1/0)}function p8(t,e){rs(t,ve.array.majorEncoded,e.value)}p8.compareTokens=bd.compareTokens;p8.encodedSize=function(e){return rs.encodedSize(e.value)};f();function fw(t,e,r,n){return new We(ve.map,n,r)}function dG(t,e,r,n){return fw(t,e,1,r)}function uG(t,e,r,n){return fw(t,e,2,Pc(t,e+1,n))}function lG(t,e,r,n){return fw(t,e,3,Ic(t,e+1,n))}function fG(t,e,r,n){return fw(t,e,5,kc(t,e+1,n))}function hG(t,e,r,n){let i=Rc(t,e+1,n);if(typeof i=="bigint")throw new Error(`${Kt} 64-bit integer map lengths not supported`);return fw(t,e,9,i)}function pG(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${Kt} indefinite length items not allowed`);return fw(t,e,1,1/0)}function m8(t,e){rs(t,ve.map.majorEncoded,e.value)}m8.compareTokens=bd.compareTokens;m8.encodedSize=function(e){return rs.encodedSize(e.value)};f();function mG(t,e,r,n){return new We(ve.tag,r,1)}function yG(t,e,r,n){return new We(ve.tag,Pc(t,e+1,n),2)}function gG(t,e,r,n){return new We(ve.tag,Ic(t,e+1,n),3)}function vG(t,e,r,n){return new We(ve.tag,kc(t,e+1,n),5)}function bG(t,e,r,n){return new We(ve.tag,Rc(t,e+1,n),9)}function y8(t,e){rs(t,ve.tag.majorEncoded,e.value)}y8.compareTokens=bd.compareTokens;y8.encodedSize=function(e){return rs.encodedSize(e.value)};f();var j6e=20,N6e=21,U6e=22,q6e=23;function wG(t,e,r,n){if(n.allowUndefined===!1)throw new Error(`${Kt} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new We(ve.null,null,1):new We(ve.undefined,void 0,1)}function _G(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${Kt} indefinite length items not allowed`);return new We(ve.break,void 0,1)}function uB(t,e,r){if(r){if(r.allowNaN===!1&&Number.isNaN(t))throw new Error(`${Kt} NaN values are not supported`);if(r.allowInfinity===!1&&(t===1/0||t===-1/0))throw new Error(`${Kt} Infinity values are not supported`)}return new We(ve.float,t,e)}function xG(t,e,r,n){return uB(lB(t,e+1),3,n)}function EG(t,e,r,n){return uB(fB(t,e+1),5,n)}function SG(t,e,r,n){return uB(IG(t,e+1),9,n)}function g8(t,e,r){let n=e.value;if(n===!1)t.push([ve.float.majorEncoded|j6e]);else if(n===!0)t.push([ve.float.majorEncoded|N6e]);else if(n===null)t.push([ve.float.majorEncoded|U6e]);else if(n===void 0)t.push([ve.float.majorEncoded|q6e]);else{let i,o=!1;(!r||r.float64!==!0)&&(TG(n),i=lB(vu,1),n===i||Number.isNaN(n)?(vu[0]=249,t.push(vu.slice(0,3)),o=!0):(PG(n),i=fB(vu,1),n===i&&(vu[0]=250,t.push(vu.slice(0,5)),o=!0))),o||(L6e(n),i=IG(vu,1),vu[0]=251,t.push(vu.slice(0,9)))}}g8.encodedSize=function(e,r){let n=e.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){TG(n);let i=lB(vu,1);if(n===i||Number.isNaN(n))return 3;if(PG(n),i=fB(vu,1),n===i)return 5}return 9};var AG=new ArrayBuffer(9),wd=new DataView(AG,1),vu=new Uint8Array(AG,0);function TG(t){if(t===1/0)wd.setUint16(0,31744,!1);else if(t===-1/0)wd.setUint16(0,64512,!1);else if(Number.isNaN(t))wd.setUint16(0,32256,!1);else{wd.setFloat32(0,t);let e=wd.getUint32(0),r=(e&2139095040)>>23,n=e&8388607;if(r===255)wd.setUint16(0,31744,!1);else if(r===0)wd.setUint16(0,(t&2147483648)>>16|n>>13,!1);else{let i=r-127;i<-24?wd.setUint16(0,0):i<-14?wd.setUint16(0,(e&2147483648)>>16|1<<24+i,!1):wd.setUint16(0,(e&2147483648)>>16|i+15<<10|n>>13,!1)}}}function lB(t,e){if(t.length-e<2)throw new Error(`${Kt} not enough data for float16`);let r=(t[e]<<8)+t[e+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,i=r&1023,o;return n===0?o=i*2**-24:n!==31?o=(i+1024)*2**(n-25):o=i===0?1/0:NaN,r&32768?-o:o}function PG(t){wd.setFloat32(0,t,!1)}function fB(t,e){if(t.length-e<4)throw new Error(`${Kt} not enough data for float32`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,4).getFloat32(0,!1)}function L6e(t){wd.setFloat64(0,t,!1)}function IG(t,e){if(t.length-e<8)throw new Error(`${Kt} not enough data for float64`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,8).getFloat64(0,!1)}g8.compareTokens=bd.compareTokens;function Vr(t,e,r){throw new Error(`${Kt} encountered invalid minor (${r}) for major ${t[e]>>>5}`)}function v8(t){return()=>{throw new Error(`${Kt} ${t}`)}}var Ce=[];for(let t=0;t<=23;t++)Ce[t]=Vr;Ce[24]=jV;Ce[25]=NV;Ce[26]=UV;Ce[27]=qV;Ce[28]=Vr;Ce[29]=Vr;Ce[30]=Vr;Ce[31]=Vr;for(let t=32;t<=55;t++)Ce[t]=Vr;Ce[56]=LV;Ce[57]=KV;Ce[58]=FV;Ce[59]=WV;Ce[60]=Vr;Ce[61]=Vr;Ce[62]=Vr;Ce[63]=Vr;for(let t=64;t<=87;t++)Ce[t]=HV;Ce[88]=VV;Ce[89]=GV;Ce[90]=JV;Ce[91]=ZV;Ce[92]=Vr;Ce[93]=Vr;Ce[94]=Vr;Ce[95]=v8("indefinite length bytes/strings are not supported");for(let t=96;t<=119;t++)Ce[t]=YV;Ce[120]=XV;Ce[121]=QV;Ce[122]=eG;Ce[123]=tG;Ce[124]=Vr;Ce[125]=Vr;Ce[126]=Vr;Ce[127]=v8("indefinite length bytes/strings are not supported");for(let t=128;t<=151;t++)Ce[t]=nG;Ce[152]=iG;Ce[153]=oG;Ce[154]=sG;Ce[155]=aG;Ce[156]=Vr;Ce[157]=Vr;Ce[158]=Vr;Ce[159]=cG;for(let t=160;t<=183;t++)Ce[t]=dG;Ce[184]=uG;Ce[185]=lG;Ce[186]=fG;Ce[187]=hG;Ce[188]=Vr;Ce[189]=Vr;Ce[190]=Vr;Ce[191]=pG;for(let t=192;t<=215;t++)Ce[t]=mG;Ce[216]=yG;Ce[217]=gG;Ce[218]=vG;Ce[219]=bG;Ce[220]=Vr;Ce[221]=Vr;Ce[222]=Vr;Ce[223]=Vr;for(let t=224;t<=243;t++)Ce[t]=v8("simple values are not supported");Ce[244]=Vr;Ce[245]=Vr;Ce[246]=Vr;Ce[247]=wG;Ce[248]=v8("simple values are not supported");Ce[249]=xG;Ce[250]=EG;Ce[251]=SG;Ce[252]=Vr;Ce[253]=Vr;Ce[254]=Vr;Ce[255]=_G;var bu=[];for(let t=0;t<24;t++)bu[t]=new We(ve.uint,t,1);for(let t=-1;t>=-24;t--)bu[31-t]=new We(ve.negint,t,1);bu[64]=new We(ve.bytes,new Uint8Array(0),1);bu[96]=new We(ve.string,"",1);bu[128]=new We(ve.array,0,1);bu[160]=new We(ve.map,0,1);bu[244]=new We(ve.false,!1,1);bu[245]=new We(ve.true,!0,1);bu[246]=new We(ve.null,null,1);function kG(t){switch(t.type){case ve.false:return Pl([244]);case ve.true:return Pl([245]);case ve.null:return Pl([246]);case ve.bytes:return t.value.length?void 0:Pl([64]);case ve.string:return t.value===""?Pl([96]):void 0;case ve.array:return t.value===0?Pl([128]):void 0;case ve.map:return t.value===0?Pl([160]):void 0;case ve.uint:return t.value<24?Pl([Number(t.value)]):void 0;case ve.negint:if(t.value>=-24)return Pl([31-Number(t.value)])}}var F6e={float64:!1,mapSorter:H6e,quickEncodeToken:kG};function z6e(){let t=[];return t[ve.uint.major]=bd,t[ve.negint.major]=f8,t[ve.bytes.major]=uw,t[ve.string.major]=rG,t[ve.array.major]=p8,t[ve.map.major]=m8,t[ve.tag.major]=y8,t[ve.float.major]=g8,t}var RG=z6e(),hB=new cx,w8=class t{constructor(e,r){this.obj=e,this.parent=r}includes(e){let r=this;do if(r.obj===e)return!0;while(r=r.parent);return!1}static createCheck(e,r){if(e&&e.includes(r))throw new Error(`${cB} object contains circular references`);return new t(r,e)}},nm={null:new We(ve.null,null),undefined:new We(ve.undefined,void 0),true:new We(ve.true,!0),false:new We(ve.false,!1),emptyArray:new We(ve.array,0),emptyMap:new We(ve.map,0)},im={number(t,e,r,n){return!Number.isInteger(t)||!Number.isSafeInteger(t)?new We(ve.float,t):t>=0?new We(ve.uint,t):new We(ve.negint,t)},bigint(t,e,r,n){return t>=BigInt(0)?new We(ve.uint,t):new We(ve.negint,t)},Uint8Array(t,e,r,n){return new We(ve.bytes,t)},string(t,e,r,n){return new We(ve.string,t)},boolean(t,e,r,n){return t?nm.true:nm.false},null(t,e,r,n){return nm.null},undefined(t,e,r,n){return nm.undefined},ArrayBuffer(t,e,r,n){return new We(ve.bytes,new Uint8Array(t))},DataView(t,e,r,n){return new We(ve.bytes,new Uint8Array(t.buffer,t.byteOffset,t.byteLength))},Array(t,e,r,n){if(!t.length)return r.addBreakTokens===!0?[nm.emptyArray,new We(ve.break)]:nm.emptyArray;n=w8.createCheck(n,t);let i=[],o=0;for(let s of t)i[o++]=b8(s,r,n);return r.addBreakTokens?[new We(ve.array,t.length),i,new We(ve.break)]:[new We(ve.array,t.length),i]},Object(t,e,r,n){let i=e!=="Object",o=i?t.keys():Object.keys(t),s=i?t.size:o.length;if(!s)return r.addBreakTokens===!0?[nm.emptyMap,new We(ve.break)]:nm.emptyMap;n=w8.createCheck(n,t);let a=[],d=0;for(let u of o)a[d++]=[b8(u,r,n),b8(i?t.get(u):t[u],r,n)];return W6e(a,r),r.addBreakTokens?[new We(ve.map,s),a,new We(ve.break)]:[new We(ve.map,s),a]}};im.Map=im.Object;im.Buffer=im.Uint8Array;for(let t of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))im[`${t}Array`]=im.DataView;function b8(t,e={},r){let n=IV(t),i=e&&e.typeEncoders&&e.typeEncoders[n]||im[n];if(typeof i=="function"){let s=i(t,n,e,r);if(s!=null)return s}let o=im[n];if(!o)throw new Error(`${cB} unsupported type: ${n}`);return o(t,n,e,r)}function W6e(t,e){e.mapSorter&&t.sort(e.mapSorter)}function H6e(t,e){let r=Array.isArray(t[0])?t[0][0]:t[0],n=Array.isArray(e[0])?e[0][0]:e[0];if(r.type!==n.type)return r.type.compare(n.type);let i=r.type.major,o=RG[i].compareTokens(r,n);return o===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),o}function DG(t,e,r,n){if(Array.isArray(e))for(let i of e)DG(t,i,r,n);else r[e.type.major](t,e,n)}function V6e(t,e,r){let n=b8(t,r);if(!Array.isArray(n)&&r.quickEncodeToken){let i=r.quickEncodeToken(n);if(i)return i;let o=e[n.type.major];if(o.encodedSize){let s=o.encodedSize(n,r),a=new cx(s);if(o(a,n,r),a.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return aB(a.chunks[0])}}return hB.reset(),DG(hB,n,e,r),hB.toBytes(!0)}function pB(t,e){return e=Object.assign({},F6e,e),V6e(t,RG,e)}f();var G6e={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},mB=class{constructor(e,r={}){this.pos=0,this.data=e,this.options=r}done(){return this.pos>=this.data.length}next(){let e=this.data[this.pos],r=bu[e];if(r===void 0){let n=Ce[e];if(!n)throw new Error(`${Kt} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);let i=e&31;r=n(this.data,this.pos,i,this.options)}return this.pos+=r.encodedLength,r}},fx=Symbol.for("DONE"),_8=Symbol.for("BREAK");function J6e(t,e,r){let n=[];for(let i=0;ipw,base32hex:()=>sSe,base32hexpad:()=>cSe,base32hexpadupper:()=>dSe,base32hexupper:()=>aSe,base32pad:()=>iSe,base32padupper:()=>oSe,base32upper:()=>nSe,base32z:()=>uSe});f();f();f();function X6e(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n>>0,$=new Uint8Array(A);S!==P;){for(var j=g[S],L=0,F=A-1;(j!==0||L>>0,$[F]=j%a>>>0,j=j/a>>>0;if(j!==0)throw new Error("Non-zero carry");x=L,S++}for(var K=A-x;K!==A&&$[K]===0;)K++;for(var W=d.repeat(v);K>>0,A=new Uint8Array(P);g[v];){var $=r[g.charCodeAt(v)];if($===255)return;for(var j=0,L=P-1;($!==0||j>>0,A[L]=$%256>>>0,$=$/256>>>0;if($!==0)throw new Error("Non-zero carry");S=j,v++}if(g[v]!==" "){for(var F=P-S;F!==P&&A[F]===0;)F++;for(var K=new Uint8Array(x+(P-F)),W=x;F!==P;)K[W++]=A[F++];return K}}}function m(g){var v=p(g);if(v)return v;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:p,decode:m}}var Q6e=X6e,eSe=Q6e,BG=eSe;f();var Eut=new Uint8Array(0);var MG=(t,e)=>{if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r{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 OG=t=>new TextEncoder().encode(t),CG=t=>new TextDecoder().decode(t);f();var gB=class{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")}},vB=class{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 jG(this,e)}},bB=class{constructor(e){this.decoders=e}or(e){return jG(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},jG=(t,e)=>new bB({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),wB=class{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new gB(e,r,n),this.decoder=new vB(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},hw=({name:t,prefix:e,encode:r,decode:n})=>new wB(t,e,r,n),om=({prefix:t,name:e,alphabet:r})=>{let{encode:n,decode:i}=BG(r,e);return hw({prefix:t,name:e,encode:n,decode:o=>oh(i(o))})},tSe=(t,e,r,n)=>{let i={};for(let c=0;c=8&&(a-=8,s[u++]=255&d>>a)}if(a>=r||255&d<<8-a)throw new SyntaxError("Unexpected end of data");return s},rSe=(t,e,r)=>{let n=e[e.length-1]==="=",i=(1<r;)s-=r,o+=e[i&a>>s];if(s&&(o+=e[i&a<hw({prefix:e,name:t,encode(i){return rSe(i,n,r)},decode(i){return tSe(i,n,r,t)}});var pw=mi({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),nSe=mi({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),iSe=mi({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),oSe=mi({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),sSe=mi({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),aSe=mi({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),cSe=mi({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),dSe=mi({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),uSe=mi({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var xB={};Pr(xB,{base58btc:()=>Il,base58flickr:()=>lSe});f();var Il=om({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),lSe=om({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});f();f();f();var fSe=qG,NG=128,hSe=127,pSe=~hSe,mSe=Math.pow(2,31);function qG(t,e,r){e=e||[],r=r||0;for(var n=r;t>=mSe;)e[r++]=t&255|NG,t/=128;for(;t&pSe;)e[r++]=t&255|NG,t>>>=7;return e[r]=t|0,qG.bytes=r-n+1,e}var ySe=EB,gSe=128,UG=127;function EB(t,n){var r=0,n=n||0,i=0,o=n,s,a=t.length;do{if(o>=a)throw EB.bytes=0,new RangeError("Could not decode varint");s=t[o++],r+=i<28?(s&UG)<=gSe);return EB.bytes=o-n,r}var vSe=Math.pow(2,7),bSe=Math.pow(2,14),wSe=Math.pow(2,21),_Se=Math.pow(2,28),xSe=Math.pow(2,35),ESe=Math.pow(2,42),SSe=Math.pow(2,49),ASe=Math.pow(2,56),TSe=Math.pow(2,63),PSe=function(t){return t[px.decode(t,e),px.decode.bytes],mw=(t,e,r=0)=>(px.encode(t,e,r),e),yw=t=>px.encodingLength(t);var H0=(t,e)=>{let r=e.byteLength,n=yw(t),i=n+yw(r),o=new Uint8Array(i+r);return mw(t,o,0),mw(r,o,n),o.set(e,i),new gw(t,r,e,o)},E8=t=>{let e=oh(t),[r,n]=mx(e),[i,o]=mx(e.subarray(n)),s=e.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new gw(r,i,s,e)},LG=(t,e)=>{if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&MG(t.bytes,r.bytes)}},gw=class{constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}};f();var KG=(t,e)=>{let{bytes:r,version:n}=t;switch(n){case 0:return DSe(r,SB(t),e||Il.encoder);default:return BSe(r,SB(t),e||pw.encoder)}};var FG=new WeakMap,SB=t=>{let e=FG.get(t);if(e==null){let r=new Map;return FG.set(t,r),r}return e},sh=class t{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!==gx)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==MSe)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=H0(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&&e.code===n.code&&e.version===n.version&&LG(e.multihash,n.multihash)}toString(e){return KG(this,e)}toJSON(){return{"/":KG(this)}}link(){return this}get[Symbol.toStringTag](){return"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||zG(n,i,o.bytes))}else if(r[OSe]===!0){let{version:n,multihash:i,code:o}=r,s=E8(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!==gx)throw new Error(`Version 0 CID must use dag-pb (code: ${gx}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let i=zG(e,r,n.bytes);return new t(e,r,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,gx,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,i=oh(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 gw(r.multihashCode,r.digestSize,o,i);return[r.version===0?t.createV0(s):t.createV1(r.codec,s),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[l,p]=mx(e.subarray(r));return r+=p,l},i=n(),o=gx;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(),d=n(),u=r+d,c=u-s;return{version:i,codec:o,multihashCode:a,digestSize:d,multihashSize:c,size:u}}static parse(e,r){let[n,i]=RSe(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 SB(o).set(n,e),o}},RSe=(t,e)=>{switch(t[0]){case"Q":{let r=e||Il;return[Il.prefix,r.decode(`${Il.prefix}${t}`)]}case Il.prefix:{let r=e||Il;return[Il.prefix,r.decode(t)]}case pw.prefix:{let r=e||pw;return[pw.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)]}}},DSe=(t,e,r)=>{let{prefix:n}=r;if(n!==Il.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},BSe=(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},gx=112,MSe=18,zG=(t,e,r)=>{let n=yw(t),i=n+yw(e),o=new Uint8Array(i+r.byteLength);return mw(t,o,0),mw(e,o,n),o.set(r,i),o},OSe=Symbol.for("@ipld/js-cid/CID");var WG=42;function CSe(t){if(t.asCID!==t&&t["/"]!==t.bytes)return null;let e=sh.asCID(t);if(!e)return null;let r=new Uint8Array(e.bytes.byteLength+1);return r.set(e.bytes,1),[new We(ve.tag,WG),new We(ve.bytes,r)]}function $Se(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function jSe(t){if(Number.isNaN(t))throw new Error("`NaN` is not supported by the IPLD Data Model and cannot be encoded");if(t===1/0||t===-1/0)throw new Error("`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded");return null}var NSe={float64:!0,typeEncoders:{Object:CSe,undefined:$Se,number:jSe}};function USe(t){if(t[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return sh.decode(t.subarray(1))}var HG={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:[]};HG.tags[WG]=USe;var qSe="dag-cbor",vx=113,LSe=t=>pB(t,NSe),KSe=t=>yB(t,HG);f();f();f();f();var Ja=JD({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Xut=JD({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});f();var bx=ma({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),rlt=ma({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),nlt=ma({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ilt=ma({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),olt=ma({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),slt=ma({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),alt=ma({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),clt=ma({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),AB=ma({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});f();var VG=(t,e)=>{let{bytes:r,version:n}=t;switch(n){case 0:return zSe(r,TB(t),e||Ja.encoder);default:return WSe(r,TB(t),e||bx.encoder)}};var GG=new WeakMap,TB=t=>{let e=GG.get(t);if(e==null){let r=new Map;return GG.set(t,r),r}return e},jr=class t{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!==wx)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==HSe)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=I0(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&&e.code===n.code&&e.version===n.version&&vH(e.multihash,n.multihash)}toString(e){return VG(this,e)}toJSON(){return{"/":VG(this)}}link(){return this}get[Symbol.toStringTag](){return"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||JG(n,i,o.bytes))}else if(r[VSe]===!0){let{version:n,multihash:i,code:o}=r,s=X5(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!==wx)throw new Error(`Version 0 CID must use dag-pb (code: ${wx}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let i=JG(e,r,n.bytes);return new t(e,r,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,wx,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,i=hu(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 zb(r.multihashCode,r.digestSize,o,i);return[r.version===0?t.createV0(s):t.createV1(r.codec,s),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[l,p]=Fb(e.subarray(r));return r+=p,l},i=n(),o=wx;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(),d=n(),u=r+d,c=u-s;return{version:i,codec:o,multihashCode:a,digestSize:d,multihashSize:c,size:u}}static parse(e,r){let[n,i]=FSe(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 TB(o).set(n,e),o}},FSe=(t,e)=>{switch(t[0]){case"Q":{let r=e||Ja;return[Ja.prefix,r.decode(`${Ja.prefix}${t}`)]}case Ja.prefix:{let r=e||Ja;return[Ja.prefix,r.decode(t)]}case bx.prefix:{let r=e||bx;return[bx.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)]}}},zSe=(t,e,r)=>{let{prefix:n}=r;if(n!==Ja.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},WSe=(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},wx=112,HSe=18,JG=(t,e,r)=>{let n=P0(t),i=n+P0(e),o=new Uint8Array(i+r.byteLength);return T0(t,o,0),T0(e,o,n),o.set(r,i),o},VSe=Symbol.for("@ipld/js-cid/CID");f();var sm=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},S8=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,d){s=t[o](s),i(a,d,s.done,s.value)})}}function i(o,s,a,d){Promise.resolve(d).then(function(u){o({value:u,done:a})},s)}},ko=function(t){return this instanceof ko?(this.v=t,this):new ko(t)},A8=function(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),i,o=[];return i={},s("next"),s("throw"),s("return"),i[Symbol.asyncIterator]=function(){return this},i;function s(p){n[p]&&(i[p]=function(m){return new Promise(function(g,v){o.push([p,m,g,v])>1||a(p,m)})})}function a(p,m){try{d(n[p](m))}catch(g){l(o[0][3],g)}}function d(p){p.value instanceof ko?Promise.resolve(p.value.v).then(u,c):l(o[0][2],p)}function u(p){a("next",p)}function c(p){a("throw",p)}function l(p,m){p(m),o.shift(),o.length&&a(o[0][0],o[0][1])}},_x=class{open(){return sm(this,void 0,void 0,function*(){})}close(){return sm(this,void 0,void 0,function*(){})}put(e,r,n){return sm(this,void 0,void 0,function*(){return e})}get(e,r){return sm(this,void 0,void 0,function*(){return new Uint8Array})}has(e,r){return sm(this,void 0,void 0,function*(){return!1})}delete(e,r){return sm(this,void 0,void 0,function*(){})}isEmpty(e){return sm(this,void 0,void 0,function*(){return!0})}putMany(e,r){return A8(this,arguments,function*(){var i,o,s,a;try{for(var d=!0,u=S8(e),c;c=yield ko(u.next()),i=c.done,!i;d=!0){a=c.value,d=!1;let l=a;yield ko(this.put(l.cid,l.block,r)),yield yield ko(l.cid)}}catch(l){o={error:l}}finally{try{!d&&!i&&(s=u.return)&&(yield ko(s.call(u)))}finally{if(o)throw o.error}}})}getMany(e,r){return A8(this,arguments,function*(){var i,o,s,a;try{for(var d=!0,u=S8(e),c;c=yield ko(u.next()),i=c.done,!i;d=!0){a=c.value,d=!1;let l=a;yield yield ko({cid:l,block:yield ko(this.get(l,r))})}}catch(l){o={error:l}}finally{try{!d&&!i&&(s=u.return)&&(yield ko(s.call(u)))}finally{if(o)throw o.error}}})}getAll(e){return A8(this,arguments,function*(){var n,i,o,s;let a=this.db.iterator({keys:!0,keyEncoding:"buffer"},e);try{for(var d=!0,u=S8(a),c;c=yield ko(u.next()),n=c.done,!n;d=!0){s=c.value,d=!1;let[l,p]=s;yield yield ko({cid:jr.decode(l),block:p})}}catch(l){i={error:l}}finally{try{!d&&!n&&(o=u.return)&&(yield ko(o.call(u)))}finally{if(i)throw i.error}}})}deleteMany(e,r){return A8(this,arguments,function*(){var i,o,s,a;try{for(var d=!0,u=S8(e),c;c=yield ko(u.next()),i=c.done,!i;d=!0){a=c.value,d=!1;let l=a;yield ko(this.delete(l,r)),yield yield ko(l)}}catch(l){o={error:l}}finally{try{!d&&!i&&(s=u.return)&&(yield ko(s.call(u)))}finally{if(o)throw o.error}}})}clear(){return sm(this,void 0,void 0,function*(){})}};f();var m5e=gt(Dc(),1);f();f();f();function JSe(t){return t[Symbol.asyncIterator]!=null}function ZSe(t,e=1){return e=Number(e),JSe(t)?async function*(){let r=[];if(e<1&&(e=1),e!==Math.round(e))throw new Error("Batch size must be an integer");for await(let n of t)for(r.push(n);r.length>=e;)yield r.slice(0,e),r=r.slice(e);for(;r.length>0;)yield r.slice(0,e),r=r.slice(e)}():function*(){let r=[];if(e<1&&(e=1),e!==Math.round(e))throw new Error("Batch size must be an integer");for(let n of t)for(r.push(n);r.length>=e;)yield r.slice(0,e),r=r.slice(e);for(;r.length>0;)yield r.slice(0,e),r=r.slice(e)}()}var xx=ZSe;async function*Ex(t,e=1){for await(let r of xx(t,e)){let n=r.map(async i=>i().then(o=>({ok:!0,value:o}),o=>({ok:!1,err:o})));for(let i=0;i0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let r=0;for(let n of e)if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.push(n);else if(T8(n))r+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}prepend(...e){this.prependAll(e)}prependAll(e){let r=0;for(let n of e.reverse())if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.unshift(n);else if(T8(n))r+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}get(e){let r=XG(this.bufs,e);return r.buf[r.index]}set(e,r){let n=XG(this.bufs,e);n.buf[n.index]=r}write(e,r=0){if(e instanceof Uint8Array)for(let n=0;n0;)if(e>=this.bufs[0].byteLength)e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}}}slice(e,r){let{bufs:n,length:i}=this._subList(e,r);return Yb(n,i)}subarray(e,r){let{bufs:n,length:i}=this._subList(e,r);return n.length===1?n[0]:Yb(n,i)}sublist(e,r){let{bufs:n,length:i}=this._subList(e,r),o=new t;return o.length=i,o.bufs=[...n],o}_subList(e,r){if(e=e??0,r=r??this.length,e<0&&(e=this.length+e),r<0&&(r=this.length+r),e<0||r>this.length)throw new RangeError("index is out of bounds");if(e===r)return{bufs:[],length:0};if(e===0&&r===this.length)return{bufs:this.bufs,length:this.length};let n=[],i=0;for(let o=0;o=d)continue;let u=e>=a&&ea&&r<=d;if(u&&c){if(e===a&&r===d){n.push(s);break}let l=e-a;n.push(s.subarray(l,l+(r-e)));break}if(u){if(e===0){n.push(s);continue}n.push(s.subarray(e-a));continue}if(c){if(r===d){n.push(s);break}n.push(s.subarray(0,r-a));break}n.push(s)}return{bufs:n,length:r-e}}indexOf(e,r=0){if(!T8(e)&&!(e instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=e instanceof Uint8Array?e:e.subarray();if(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),e.length===0)return r>this.length?this.length:r;let i=n.byteLength;if(i===0)throw new TypeError("search must be at least 1 byte long");let o=256,s=new Int32Array(o);for(let l=0;l=0;p--){let m=this.get(l+p);if(n[p]!==m){c=Math.max(1,p-a[m]);break}}if(c===0)return l}return-1}getInt8(e){let r=this.subarray(e,e+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(e,r){let n=Ga(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,e)}getInt16(e,r){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(e,r,n){let i=rh(2);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt16(0,r,n),this.write(i,e)}getInt32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,r)}setInt32(e,r,n){let i=rh(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt32(0,r,n),this.write(i,e)}getBigInt64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,r)}setBigInt64(e,r,n){let i=rh(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setBigInt64(0,r,n),this.write(i,e)}getUint8(e){let r=this.subarray(e,e+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(e,r){let n=Ga(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,e)}getUint16(e,r){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(e,r,n){let i=rh(2);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint16(0,r,n),this.write(i,e)}getUint32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,r)}setUint32(e,r,n){let i=rh(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint32(0,r,n),this.write(i,e)}getBigUint64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,r)}setBigUint64(e,r,n){let i=rh(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setBigUint64(0,r,n),this.write(i,e)}getFloat32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,r)}setFloat32(e,r,n){let i=rh(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat32(0,r,n),this.write(i,e)}getFloat64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,r)}setFloat64(e,r,n){let i=rh(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat64(0,r,n),this.write(i,e)}equals(e){if(e==null||!(e instanceof t)||e.bufs.length!==this.bufs.length)return!1;for(let r=0;ri+o.byteLength,0)),n.length=r,n}};var YSe=262144,eJ=(t={})=>{let e=t.chunkSize??YSe;return async function*(n){let i=new vw,o=0,s=!1;for await(let a of n)for(i.append(a),o+=a.length;o>=e;)if(yield i.slice(0,e),s=!0,e===i.length)i=new vw,o=0;else{let d=new vw;d.append(i.sublist(e)),i=d,o-=e}(!s||o>0)&&(yield i.subarray(0,o))}};f();var G0={};Pr(G0,{code:()=>Ax,createLink:()=>uJ,createNode:()=>dJ,decode:()=>ah,encode:()=>Mc,name:()=>c3e,prepare:()=>Bc,validate:()=>kB});f();f();var XSe=new TextDecoder;function PB(t,e){let r=0;for(let n=0;;n+=7){if(n>=64)throw new Error("protobuf: varint overflow");if(e>=t.length)throw new Error("protobuf: unexpected end of data");let i=t[e++];if(r+=n<28?(i&127)<t.length)throw new Error("protobuf: unexpected end of data");return[t.subarray(e,n),n]}function tJ(t,e){let r;return[r,e]=PB(t,e),[r&7,r>>3,e]}function QSe(t){let e={},r=t.length,n=0;for(;nr)throw new Error("protobuf: (PBLink) unexpected end of data");return e}function rJ(t){let e=t.length,r=0,n,i=!1,o;for(;re)throw new Error("protobuf: (PBNode) unexpected end of data");let s={};return o&&(s.Data=o),s.Links=n||[],s}f();var iJ=new TextEncoder,nJ=2**32,e3e=2**31;function t3e(t,e){let r=e.length;if(typeof t.Tsize=="number"){if(t.Tsize<0)throw new Error("Tsize cannot be negative");if(!Number.isSafeInteger(t.Tsize))throw new Error("Tsize too large for encoding");r=Sx(e,r,t.Tsize)-1,e[r]=24}if(typeof t.Name=="string"){let n=iJ.encode(t.Name);r-=n.length,e.set(n,r),r=Sx(e,r,n.length)-1,e[r]=18}return t.Hash&&(r-=t.Hash.length,e.set(t.Hash,r),r=Sx(e,r,t.Hash.length)-1,e[r]=10),e.length-r}function oJ(t){let e=n3e(t),r=new Uint8Array(e),n=e;if(t.Data&&(n-=t.Data.length,r.set(t.Data,n),n=Sx(r,n,t.Data.length)-1,r[n]=10),t.Links)for(let i=t.Links.length-1;i>=0;i--){let o=t3e(t.Links[i],r.subarray(0,n));n-=o,n=Sx(r,n,o)-1,r[n]=18}return r}function r3e(t){let e=0;if(t.Hash){let r=t.Hash.length;e+=1+r+bw(r)}if(typeof t.Name=="string"){let r=iJ.encode(t.Name).length;e+=1+r+bw(r)}return typeof t.Tsize=="number"&&(e+=1+bw(t.Tsize)),e}function n3e(t){let e=0;if(t.Data){let r=t.Data.length;e+=1+r+bw(r)}if(t.Links)for(let r of t.Links){let n=r3e(r);e+=1+n+bw(n)}return e}function Sx(t,e,r){e-=bw(r);let n=e;for(;r>=e3e;)t[e++]=r&127|128,r/=128;for(;r>=128;)t[e++]=r&127|128,r>>>=7;return t[e]=r,n}function bw(t){return t%2===0&&t++,Math.floor((i3e(t)+6)/7)}function i3e(t){let e=0;return t>=nJ&&(t=Math.floor(t/nJ),e=32),t>=65536&&(t>>>=16,e+=16),t>=256&&(t>>>=8,e+=8),e+o3e[t]}var o3e=[0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8];f();var s3e=["Data","Links"],a3e=["Hash","Name","Tsize"],IB=new TextEncoder;function aJ(t,e){if(t===e)return 0;let r=t.Name?IB.encode(t.Name):[],n=e.Name?IB.encode(e.Name):[],i=r.length,o=n.length;for(let s=0,a=Math.min(i,o);s!e.includes(r))}function cJ(t){if(typeof t.asCID=="object"){let r=mu.asCID(t);if(!r)throw new TypeError("Invalid DAG-PB form");return{Hash:r}}if(typeof t!="object"||Array.isArray(t))throw new TypeError("Invalid DAG-PB form");let e={};if(t.Hash){let r=mu.asCID(t.Hash);try{r||(typeof t.Hash=="string"?r=mu.parse(t.Hash):t.Hash instanceof Uint8Array&&(r=mu.decode(t.Hash)))}catch(n){throw new TypeError(`Invalid DAG-PB form: ${n.message}`)}r&&(e.Hash=r)}if(!e.Hash)throw new TypeError("Invalid DAG-PB form");return typeof t.Name=="string"&&(e.Name=t.Name),typeof t.Tsize=="number"&&(e.Tsize=t.Tsize),e}function Bc(t){if((t instanceof Uint8Array||typeof t=="string")&&(t={Data:t}),typeof t!="object"||Array.isArray(t))throw new TypeError("Invalid DAG-PB form");let e={};if(t.Data!==void 0)if(typeof t.Data=="string")e.Data=IB.encode(t.Data);else if(t.Data instanceof Uint8Array)e.Data=t.Data;else throw new TypeError("Invalid DAG-PB form");if(t.Links!==void 0)if(Array.isArray(t.Links))e.Links=t.Links.map(cJ),e.Links.sort(aJ);else throw new TypeError("Invalid DAG-PB form");else e.Links=[];return e}function kB(t){if(!t||typeof t!="object"||Array.isArray(t)||t instanceof Uint8Array||t["/"]&&t["/"]===t.bytes)throw new TypeError("Invalid DAG-PB form");if(!sJ(t,s3e))throw new TypeError("Invalid DAG-PB form (extraneous properties)");if(t.Data!==void 0&&!(t.Data instanceof Uint8Array))throw new TypeError("Invalid DAG-PB form (Data must be bytes)");if(!Array.isArray(t.Links))throw new TypeError("Invalid DAG-PB form (Links must be a list)");for(let e=0;e0&&aJ(r,t.Links[e-1])===-1)throw new TypeError("Invalid DAG-PB form (links must be sorted by Name bytes)")}}function dJ(t,e=[]){return Bc({Data:t,Links:e})}function uJ(t,e,r){return cJ({Hash:r,Name:t,Tsize:e})}function lJ(t){return t instanceof ArrayBuffer?new Uint8Array(t,0,t.byteLength):t}var c3e="dag-pb",Ax=112;function Mc(t){kB(t);let e={};return t.Links&&(e.Links=t.Links.map(r=>{let n={};return r.Hash&&(n.Hash=r.Hash.bytes),r.Name!==void 0&&(n.Name=r.Name),r.Tsize!==void 0&&(n.Tsize=r.Tsize),n})),t.Data&&(e.Data=t.Data),oJ(e)}function ah(t){let e=lJ(t),r=rJ(e),n={};return r.Data&&(n.Data=r.Data),r.Links&&(n.Links=r.Links.map(i=>{let o={};try{o.Hash=mu.decode(i.Hash)}catch{}if(!o.Hash)throw new Error("Invalid Hash field found in link, expected CID");return i.Name!==void 0&&(o.Name=i.Name),i.Tsize!==void 0&&(o.Tsize=i.Tsize),o})),n}f();var KB=gt(Dc(),1);f();f();f();f();f();var d3e=Math.pow(2,7),u3e=Math.pow(2,14),l3e=Math.pow(2,21),fJ=Math.pow(2,28),hJ=Math.pow(2,35),pJ=Math.pow(2,42),mJ=Math.pow(2,49),Ea=128,am=127;function Tx(t){if(tNumber.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function yJ(t,e,r=0){switch(Tx(t)){case 8:e[r++]=t&255|Ea,t/=128;case 7:e[r++]=t&255|Ea,t/=128;case 6:e[r++]=t&255|Ea,t/=128;case 5:e[r++]=t&255|Ea,t/=128;case 4:e[r++]=t&255|Ea,t>>>=7;case 3:e[r++]=t&255|Ea,t>>>=7;case 2:e[r++]=t&255|Ea,t>>>=7;case 1:{e[r++]=t&255,t>>>=7;break}default:throw new Error("unreachable")}return e}function gJ(t,e){let r=t[e],n=0;if(n+=r&am,r>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?e<16384?e<128?1:2:e<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return J0;if(eh3e)return this.fromNumber(Number(e));let r=e<0n;r&&(e=-e);let n=e>>32n,i=e-(n<<32n);return r&&(n=~n|0n,i=~i|0n,++i>xJ&&(i=0n,++n>xJ&&(n=0n))),new t(Number(i),Number(n))}static fromNumber(e){if(e===0)return J0;let r=e<0;r&&(e=-e);let n=e>>>0,i=(e-n)/4294967296>>>0;return r&&(i=~i>>>0,n=~n>>>0,++n>4294967295&&(n=0,++i>4294967295&&(i=0))),new t(n,i)}static from(e){return typeof e=="number"?t.fromNumber(e):typeof e=="bigint"?t.fromBigInt(e):typeof e=="string"?t.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new t(e.low>>>0,e.high>>>0):J0}},J0=new Oc(0,0);J0.toBigInt=function(){return 0n};J0.zzEncode=J0.zzDecode=function(){return this};J0.length=function(){return 1};var xJ=4294967296n;f();function EJ(t){let e=0,r=0;for(let n=0;n191&&a<224?o[s++]=(a&31)<<6|t[e++]&63:a>239&&a<365?(a=((a&7)<<18|(t[e++]&63)<<12|(t[e++]&63)<<6|t[e++]&63)-65536,o[s++]=55296+(a>>10),o[s++]=56320+(a&1023)):o[s++]=(a&15)<<12|(t[e++]&63)<<6|t[e++]&63,s>8191&&((i??(i=[])).push(String.fromCharCode.apply(String,o)),s=0);return i!=null?(s>0&&i.push(String.fromCharCode.apply(String,o.slice(0,s))),i.join("")):String.fromCharCode.apply(String,o.slice(0,s))}function BB(t,e,r){let n=r,i,o;for(let s=0;s>6|192,e[r++]=i&63|128):(i&64512)===55296&&((o=t.charCodeAt(s+1))&64512)===56320?(i=65536+((i&1023)<<10)+(o&1023),++s,e[r++]=i>>18|240,e[r++]=i>>12&63|128,e[r++]=i>>6&63|128,e[r++]=i&63|128):(e[r++]=i>>12|224,e[r++]=i>>6&63|128,e[r++]=i&63|128);return r-n}function wu(t,e){return RangeError(`index out of range: ${t.pos} + ${e??1} > ${t.len}`)}function I8(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}var MB=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,wu(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw wu(this,4);return I8(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw wu(this,4);return I8(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw wu(this,4);let e=bJ(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw wu(this,4);let e=_J(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),r=this.pos,n=this.pos+e;if(n>this.len)throw wu(this,e);return this.pos+=e,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let e=this.bytes();return SJ(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw wu(this,e);this.pos+=e}else do if(this.pos>=this.len)throw wu(this);while(this.buf[this.pos++]&128);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new Oc(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(e.lo=(e.lo|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw wu(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<>>0,e}if(this.len-this.pos>4){for(;r<5;++r)if(e.hi=(e.hi|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return e}else for(;r<5;++r){if(this.pos>=this.len)throw wu(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw wu(this,8);let e=I8(this.buf,this.pos+=4),r=I8(this.buf,this.pos+=4);return new Oc(e,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=gJ(this.buf,this.pos);return this.pos+=Tx(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function OB(t){return new MB(t instanceof Uint8Array?t:t.subarray())}function Px(t,e,r){let n=OB(t);return e.decode(n,void 0,r)}f();f();f();function CB(t){let e=t??8192,r=e>>>1,n,i=e;return function(s){if(s<1||s>r)return Ga(s);i+s>e&&(n=Ga(e),i=0);let a=n.subarray(i,i+=s);return i&7&&(i=(i|7)+1),a}}var Z0=class{fn;len;next;val;constructor(e,r,n){this.fn=e,this.len=r,this.next=void 0,this.val=n}};function $B(){}var NB=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},p3e=CB();function m3e(t){return globalThis.Buffer!=null?Ga(t):p3e(t)}var kx=class{len;head;tail;states;constructor(){this.len=0,this.head=new Z0($B,0,0),this.tail=this.head,this.states=null}_push(e,r,n){return this.tail=this.tail.next=new Z0(e,r,n),this.len+=r,this}uint32(e){return this.len+=(this.tail=this.tail.next=new UB((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(k8,10,Oc.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let r=Oc.fromBigInt(e);return this._push(k8,r.length(),r)}uint64Number(e){return this._push(yJ,Tx(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let r=Oc.fromBigInt(e).zzEncode();return this._push(k8,r.length(),r)}sint64Number(e){let r=Oc.fromNumber(e).zzEncode();return this._push(k8,r.length(),r)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(jB,1,e?1:0)}fixed32(e){return this._push(Ix,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let r=Oc.fromBigInt(e);return this._push(Ix,4,r.lo)._push(Ix,4,r.hi)}fixed64Number(e){let r=Oc.fromNumber(e);return this._push(Ix,4,r.lo)._push(Ix,4,r.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(vJ,4,e)}double(e){return this._push(wJ,8,e)}bytes(e){let r=e.length>>>0;return r===0?this._push(jB,1,0):this.uint32(r)._push(g3e,r,e)}string(e){let r=EJ(e);return r!==0?this.uint32(r)._push(BB,r,e):this._push(jB,1,0)}fork(){return this.states=new NB(this),this.head=this.tail=new Z0($B,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new Z0($B,0,0),this.len=0),this}ldelim(){let e=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=r,this.len+=n),this}finish(){let e=this.head.next,r=m3e(this.len),n=0;for(;e!=null;)e.fn(e.val,r,n),n+=e.len,e=e.next;return r}};function jB(t,e,r){e[r]=t&255}function y3e(t,e,r){for(;t>127;)e[r++]=t&127|128,t>>>=7;e[r]=t}var UB=class extends Z0{next;constructor(e,r){super(y3e,e,r),this.next=void 0}};function k8(t,e,r){for(;t.hi!==0;)e[r++]=t.lo&127|128,t.lo=(t.lo>>>7|t.hi<<25)>>>0,t.hi>>>=7;for(;t.lo>127;)e[r++]=t.lo&127|128,t.lo=t.lo>>>7;e[r++]=t.lo}function Ix(t,e,r){e[r]=t&255,e[r+1]=t>>>8&255,e[r+2]=t>>>16&255,e[r+3]=t>>>24}function g3e(t,e,r){e.set(t,r)}globalThis.Buffer!=null&&(kx.prototype.bytes=function(t){let e=t.length>>>0;return this.uint32(e),e>0&&this._push(v3e,e,t),this},kx.prototype.string=function(t){let e=globalThis.Buffer.byteLength(t);return this.uint32(e),e>0&&this._push(b3e,e,t),this});function v3e(t,e,r){e.set(t,r)}function b3e(t,e,r){t.length<40?BB(t,e,r):e.utf8Write!=null?e.utf8Write(t,r):e.set(N0(t),r)}function qB(){return new kx}function Rx(t,e){let r=qB();return e.encode(t,r,{lengthDelimited:!1}),r.finish()}f();f();var ww;(function(t){t[t.VARINT=0]="VARINT",t[t.BIT64=1]="BIT64",t[t.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",t[t.START_GROUP=3]="START_GROUP",t[t.END_GROUP=4]="END_GROUP",t[t.BIT32=5]="BIT32"})(ww||(ww={}));function R8(t,e,r,n){return{name:t,type:e,encode:r,decode:n}}function LB(t){function e(i){if(t[i.toString()]==null)throw new Error("Invalid enum value");return t[i]}let r=function(o,s){let a=e(o);s.int32(a)},n=function(o){let s=o.int32();return e(s)};return R8("enum",ww.VARINT,r,n)}f();function Dx(t,e){return R8("message",ww.LENGTH_DELIMITED,t,e)}var _u;(function(t){let e;(function(i){i.Raw="Raw",i.Directory="Directory",i.File="File",i.Metadata="Metadata",i.Symlink="Symlink",i.HAMTShard="HAMTShard"})(e=t.DataType||(t.DataType={}));let r;(function(i){i[i.Raw=0]="Raw",i[i.Directory=1]="Directory",i[i.File=2]="File",i[i.Metadata=3]="Metadata",i[i.Symlink=4]="Symlink",i[i.HAMTShard=5]="HAMTShard"})(r||(r={})),function(i){i.codec=()=>LB(r)}(e=t.DataType||(t.DataType={}));let n;t.codec=()=>(n==null&&(n=Dx((i,o,s={})=>{if(s.lengthDelimited!==!1&&o.fork(),i.Type!=null&&(o.uint32(8),t.DataType.codec().encode(i.Type,o)),i.Data!=null&&(o.uint32(18),o.bytes(i.Data)),i.filesize!=null&&(o.uint32(24),o.uint64(i.filesize)),i.blocksizes!=null)for(let a of i.blocksizes)o.uint32(32),o.uint64(a);i.hashType!=null&&(o.uint32(40),o.uint64(i.hashType)),i.fanout!=null&&(o.uint32(48),o.uint64(i.fanout)),i.mode!=null&&(o.uint32(56),o.uint32(i.mode)),i.mtime!=null&&(o.uint32(66),D8.codec().encode(i.mtime,o)),s.lengthDelimited!==!1&&o.ldelim()},(i,o)=>{let s={blocksizes:[]},a=o==null?i.len:i.pos+o;for(;i.pos>>3){case 1:s.Type=t.DataType.codec().decode(i);break;case 2:s.Data=i.bytes();break;case 3:s.filesize=i.uint64();break;case 4:s.blocksizes.push(i.uint64());break;case 5:s.hashType=i.uint64();break;case 6:s.fanout=i.uint64();break;case 7:s.mode=i.uint32();break;case 8:s.mtime=D8.codec().decode(i,i.uint32());break;default:i.skipType(d&7);break}}return s})),n),t.encode=i=>Rx(i,t.codec()),t.decode=i=>Px(i,t.codec())})(_u||(_u={}));var D8;(function(t){let e;t.codec=()=>(e==null&&(e=Dx((r,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),r.Seconds!=null&&(n.uint32(8),n.int64(r.Seconds)),r.FractionalNanoseconds!=null&&(n.uint32(21),n.fixed32(r.FractionalNanoseconds)),i.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{let i={},o=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:i.Seconds=r.int64();break;case 2:i.FractionalNanoseconds=r.fixed32();break;default:r.skipType(s&7);break}}return i})),e),t.encode=r=>Rx(r,t.codec()),t.decode=r=>Px(r,t.codec())})(D8||(D8={}));var TJ;(function(t){let e;t.codec=()=>(e==null&&(e=Dx((r,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),r.MimeType!=null&&(n.uint32(10),n.string(r.MimeType)),i.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{let i={},o=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:i.MimeType=r.string();break;default:r.skipType(s&7);break}}return i})),e),t.encode=r=>Rx(r,t.codec()),t.decode=r=>Px(r,t.codec())})(TJ||(TJ={}));var PJ={Raw:"raw",Directory:"directory",File:"file",Metadata:"metadata",Symlink:"symlink",HAMTShard:"hamt-sharded-directory"},w3e=["directory","hamt-sharded-directory"],IJ=parseInt("0644",8),kJ=parseInt("0755",8),Ro=class t{static unmarshal(e){let r=_u.decode(e),n=new t({type:PJ[r.Type!=null?r.Type.toString():"File"],data:r.Data,blockSizes:r.blocksizes,mode:r.mode,mtime:r.mtime!=null?{secs:r.mtime.Seconds??0n,nsecs:r.mtime.FractionalNanoseconds}:void 0,fanout:r.fanout});return n._originalMode=r.mode??0,n}type;data;blockSizes;hashType;fanout;mtime;_mode;_originalMode;constructor(e={type:"file"}){let{type:r,data:n,blockSizes:i,hashType:o,fanout:s,mtime:a,mode:d}=e;if(r!=null&&!Object.values(PJ).includes(r))throw(0,KB.default)(new Error("Type: "+r+" is not valid"),"ERR_INVALID_TYPE");this.type=r??"file",this.data=n,this.hashType=o,this.fanout=s,this.blockSizes=i??[],this._originalMode=0,this.mode=d,this.mtime=a}set mode(e){e==null?this._mode=this.isDirectory()?kJ:IJ:this._mode=e&4095}get mode(){return this._mode}isDirectory(){return w3e.includes(this.type)}addBlockSize(e){this.blockSizes.push(e)}removeBlockSize(e){this.blockSizes.splice(e,1)}fileSize(){if(this.isDirectory())return 0n;let e=0n;return this.blockSizes.forEach(r=>{e+=r}),this.data!=null&&(e+=BigInt(this.data.length)),e}marshal(){let e;switch(this.type){case"raw":e=_u.DataType.Raw;break;case"directory":e=_u.DataType.Directory;break;case"file":e=_u.DataType.File;break;case"metadata":e=_u.DataType.Metadata;break;case"symlink":e=_u.DataType.Symlink;break;case"hamt-sharded-directory":e=_u.DataType.HAMTShard;break;default:throw(0,KB.default)(new Error(`Type: ${e} is not valid`),"ERR_INVALID_TYPE")}let r=this.data;(this.data==null||this.data.length===0)&&(r=void 0);let n;this.mode!=null&&(n=this._originalMode&4294963200|(this.mode??0),n===IJ&&!this.isDirectory()&&(n=void 0),n===kJ&&this.isDirectory()&&(n=void 0));let i;return this.mtime!=null&&(i={Seconds:this.mtime.secs,FractionalNanoseconds:this.mtime.nsecs}),_u.encode({Type:e,Data:r,filesize:this.isDirectory()?void 0:this.fileSize(),blocksizes:this.blockSizes,hashType:this.hashType,fanout:this.fanout,mode:n,mtime:i})}};var _w={};Pr(_w,{code:()=>dm,decode:()=>E3e,encode:()=>x3e,name:()=>_3e});f();var _3e="raw",dm=85,x3e=t=>hu(t),E3e=t=>hu(t);f();var yi=class extends Event{type;detail;constructor(e,r){super(e),this.type=e,this.detail=r}};f();var xu=async(t,e,r)=>{r.codec==null&&(r.codec=G0);let n=await Ns.digest(t),i=jr.create(r.cidVersion,r.codec.code,n);return await e.put(i,t,r),i};function RJ(t){return async function*(r,n){let i=0n;for await(let o of r.content)yield async()=>{let s,a={codec:G0,cidVersion:t.cidVersion,onProgress:t.onProgress};t.rawLeaves?(a.codec=_w,a.cidVersion=1):(s=new Ro({type:t.leafType,data:o}),o=Mc({Data:s.marshal(),Links:[]}));let d=await xu(o,n,a);return i+=BigInt(o.byteLength),t.onProgress?.(new yi("unixfs:importer:progress:file:write",{bytesWritten:i,cid:d,path:r.path})),{cid:d,unixfs:s,size:BigInt(o.length),block:o}}}}f();var FB=gt(Dc(),1);f();var DJ=async(t,e,r)=>{let n=new Ro({type:"directory",mtime:t.mtime,mode:t.mode}),i=Mc(Bc({Data:n.marshal()})),o=await xu(i,e,r),s=t.path;return{cid:o,path:s,unixfs:n,size:BigInt(i.length),originalPath:t.originalPath,block:i}};f();async function*S3e(t,e,r){let n=-1,i;for await(let o of Ex(r.bufferImporter(t,e),r.blockWriteConcurrency)){if(n++,n===0){i={...o,single:!0};continue}else n===1&&i!=null&&(yield{...i,block:void 0,single:void 0},i=void 0);yield{...o,block:void 0}}i!=null&&(yield i)}function BJ(t){return t.single===!0}var A3e=(t,e,r)=>async function(i){if(i.length===1&&BJ(i[0])&&r.reduceSingleLeafToSelf){let c=i[0],l=c.block;return BJ(c)&&(t.mtime!==void 0||t.mode!==void 0)&&(c.unixfs=new Ro({type:"file",mtime:t.mtime,mode:t.mode,data:c.block}),l={Data:c.unixfs.marshal(),Links:[]},c.block=Mc(Bc(l)),c.cid=await xu(c.block,e,{...r,cidVersion:r.cidVersion}),c.size=BigInt(c.block.length)),r.onProgress?.(new yi("unixfs:importer:progress:file:layout",{cid:c.cid,path:c.originalPath})),{cid:c.cid,path:t.path,unixfs:c.unixfs,size:c.size,originalPath:c.originalPath}}let o=new Ro({type:"file",mtime:t.mtime,mode:t.mode}),s=i.filter(c=>c.cid.code===dm&&c.size>0||c.unixfs!=null&&c.unixfs.data==null&&c.unixfs.fileSize()>0n?!0:!!c.unixfs?.data?.length).map(c=>c.cid.code===dm?(o.addBlockSize(c.size),{Name:"",Tsize:Number(c.size),Hash:c.cid}):(c.unixfs==null||c.unixfs.data==null?o.addBlockSize(c.unixfs?.fileSize()??0n):o.addBlockSize(BigInt(c.unixfs.data.length)),{Name:"",Tsize:Number(c.size),Hash:c.cid})),a={Data:o.marshal(),Links:s},d=Mc(Bc(a)),u=await xu(d,e,r);return r.onProgress?.(new yi("unixfs:importer:progress:file:layout",{cid:u,path:t.originalPath})),{cid:u,path:t.path,unixfs:o,size:BigInt(d.length+a.Links.reduce((c,l)=>c+(l.Tsize??0),0)),originalPath:t.originalPath,block:d}},MJ=async(t,e,r)=>r.layout(S3e(t,e,r),A3e(t,e,r));function T3e(t){return Symbol.iterator in t}function P3e(t){return Symbol.asyncIterator in t}function I3e(t){try{if(t instanceof Uint8Array)return async function*(){yield t}();if(T3e(t))return async function*(){yield*t}();if(P3e(t))return t}catch{throw(0,FB.default)(new Error("Content was invalid"),"ERR_INVALID_CONTENT")}throw(0,FB.default)(new Error("Content was invalid"),"ERR_INVALID_CONTENT")}function OJ(t){return async function*(r,n){for await(let i of r){let o;if(i.path!=null&&(o=i.path,i.path=i.path.split("/").filter(s=>s!=null&&s!==".").join("/")),k3e(i)){let s={path:i.path,mtime:i.mtime,mode:i.mode,content:async function*(){let a=0n;for await(let d of t.chunker(t.chunkValidator(I3e(i.content)))){let u=BigInt(d.byteLength);a+=u,t.onProgress?.(new yi("unixfs:importer:progress:file:read",{bytesRead:a,chunkSize:u,path:i.path})),yield d}}(),originalPath:o};yield async()=>MJ(s,n,t)}else if(i.path!=null){let s={path:i.path,mtime:i.mtime,mode:i.mode,originalPath:o};yield async()=>DJ(s,n,t)}else throw new Error("Import candidate must have content or path or both")}}}function k3e(t){return t.content!=null}f();var i7=gt(Dc(),1);f();f();function B8(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}f();f();var zB={};Pr(zB,{base10:()=>R3e});f();var R3e=om({prefix:"9",name:"base10",alphabet:"0123456789"});var WB={};Pr(WB,{base16:()=>D3e,base16upper:()=>B3e});f();var D3e=mi({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),B3e=mi({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var HB={};Pr(HB,{base2:()=>M3e});f();var M3e=mi({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var VB={};Pr(VB,{base256emoji:()=>N3e});f();var CJ=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),O3e=CJ.reduce((t,e,r)=>(t[r]=e,t),[]),C3e=CJ.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function $3e(t){return t.reduce((e,r)=>(e+=O3e[r],e),"")}function j3e(t){let e=[];for(let r of t){let n=C3e[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}var N3e=hw({prefix:"\u{1F680}",name:"base256emoji",encode:$3e,decode:j3e});var GB={};Pr(GB,{base36:()=>U3e,base36upper:()=>q3e});f();var U3e=om({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),q3e=om({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var JB={};Pr(JB,{base64:()=>L3e,base64pad:()=>K3e,base64url:()=>xw,base64urlpad:()=>F3e});f();var L3e=mi({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),K3e=mi({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),xw=mi({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),F3e=mi({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var ZB={};Pr(ZB,{base8:()=>z3e});f();var z3e=mi({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var YB={};Pr(YB,{identity:()=>W3e});f();var W3e=hw({prefix:"\0",name:"identity",encode:t=>CG(t),decode:t=>OG(t)});f();var Jht=new TextEncoder,Zht=new TextDecoder;f();var XB={};Pr(XB,{identity:()=>Z3e});f();var $J=0,G3e="identity",jJ=oh,J3e=t=>H0($J,jJ(t)),Z3e={code:$J,name:G3e,encode:jJ,digest:J3e};var t7={};Pr(t7,{sha256:()=>Bx,sha512:()=>Y3e});f();f();var e7=({name:t,code:e,encode:r})=>new QB(t,e,r),QB=class{constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?H0(this.code,r):r.then(n=>H0(this.code,n))}else throw Error("Unknown type, must be binary type")}};var UJ=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),Bx=e7({name:"sha2-256",code:18,encode:UJ("SHA-256")}),Y3e=e7({name:"sha2-512",code:19,encode:UJ("SHA-512")});f();f();var r7={...YB,...HB,...ZB,...zB,...WB,..._B,...GB,...xB,...JB,...VB},lpt={...t7,...XB};f();function qJ(t=0){return globalThis.Buffer?.allocUnsafe!=null?B8(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function KJ(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var LJ=KJ("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),n7=KJ("ascii","a",t=>{let e="a";for(let r=0;r{t=t.substring(1);let e=qJ(t.length);for(let r=0;rasync function*(e){for await(let r of e){if(r.length===void 0)throw(0,i7.default)(new Error("Content was invalid"),"ERR_INVALID_CONTENT");if(typeof r=="string"||r instanceof String)yield zJ(r.toString());else if(Array.isArray(r))yield Uint8Array.from(r);else if(r instanceof Uint8Array)yield r;else throw(0,i7.default)(new Error("Content was invalid"),"ERR_INVALID_CONTENT")}};f();f();var Q3e=174;function o7(t){let e=t?.maxChildrenPerNode??Q3e;return async function r(n,i){let o=[];for await(let s of xx(n,e))o.push(await i(s));return o.length>1?r(o,i):o[0]}}f();f();f();f();f();f();var kl=class{options;root;dir;path;dirty;flat;parent;parentKey;unixfs;mode;mtime;cid;size;nodeSize;constructor(e,r){this.options=r??{},this.root=e.root,this.dir=e.dir,this.path=e.path,this.dirty=e.dirty,this.flat=e.flat,this.parent=e.parent,this.parentKey=e.parentKey,this.unixfs=e.unixfs,this.mode=e.mode,this.mtime=e.mtime}},Mx=jr.parse("QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn"),Ox=jr.parse("zdj7WbTaiJT1fgatdet9Ei9iDB5hdCxkbVyhyh8YTUnXMiwYi");var Y0=class extends kl{_children;constructor(e,r){super(e,r),this._children=new Map}async put(e,r){this.cid=void 0,this.size=void 0,this.nodeSize=void 0,this._children.set(e,r)}async get(e){return Promise.resolve(this._children.get(e))}childCount(){return this._children.size}directChildrenCount(){return this.childCount()}onlyChild(){return this._children.values().next().value}async*eachChildSeries(){for(let[e,r]of this._children.entries())yield{key:e,child:r}}estimateNodeSize(){if(this.nodeSize!==void 0)return this.nodeSize;this.nodeSize=0;for(let[e,r]of this._children.entries())r.size!=null&&r.cid!=null&&(this.nodeSize+=e.length+(this.options.cidVersion===1?Ox.bytes.byteLength:Mx.bytes.byteLength));return this.nodeSize}async*flush(e){let r=[];for(let[d,u]of this._children.entries()){let c=u;if(u instanceof kl)for await(let l of u.flush(e))c=l,yield l;c.size!=null&&c.cid!=null&&r.push({Name:d,Tsize:Number(c.size),Hash:c.cid})}let n=new Ro({type:"directory",mtime:this.mtime,mode:this.mode}),i={Data:n.marshal(),Links:r},o=Mc(Bc(i)),s=await xu(o,e,this.options),a=o.length+i.Links.reduce((d,u)=>d+(u.Tsize==null?0:u.Tsize),0);this.cid=s,this.size=a,yield{cid:s,unixfs:n,path:this.path,size:BigInt(a)}}};f();f();f();var O8=gt(GJ(),1);function e5e(t){let e=new Array(4);for(let r=0;r<4;r++)e[r]=t&255,t=t>>8;return new Uint8Array(e)}var amt=j0({name:"murmur3-32",code:35,encode:t=>e5e(O8.default.x86.hash32(t))}),C8=j0({name:"murmur3-128",code:34,encode:t=>Xb.fromHex(O8.default.x64.hash128(t))}),cmt=j0({name:"murmur3-x64-64",code:34,encode:t=>Xb.fromHex(O8.default.x64.hash128(t)).subarray(0,8)});f();f();var XJ=gt(YJ(),1);var Rl=class t{_options;_popCount;_parent;_posAtParent;_children;key;constructor(e,r,n=0){this._options=e,this._popCount=0,this._parent=r,this._posAtParent=n,this._children=new XJ.default,this.key=null}async put(e,r){let n=await this._findNewBucketAndPos(e);n.bucket._putAt(n,e,r)}async get(e){let r=await this._findChild(e);if(r!=null)return r.value}async del(e){let r=await this._findPlace(e),n=r.bucket._at(r.pos);n!=null&&n.key===e&&r.bucket._delAt(r.pos)}leafCount(){return this._children.compactArray().reduce((r,n)=>n instanceof t?r+n.leafCount():r+1,0)}childrenCount(){return this._children.length}onlyChild(){return this._children.get(0)}*eachLeafSeries(){let e=this._children.compactArray();for(let r of e)r instanceof t?yield*r.eachLeafSeries():yield r}serialize(e,r){let n=[];return r(this._children.reduce((i,o,s)=>(o!=null&&(o instanceof t?i.push(o.serialize(e,r)):i.push(e(o,s))),i),n))}async asyncTransform(e,r){return QJ(this,e,r)}toJSON(){return this.serialize(o5e,s5e)}prettyPrint(){return JSON.stringify(this.toJSON(),null," ")}tableSize(){return Math.pow(2,this._options.bits)}async _findChild(e){let r=await this._findPlace(e),n=r.bucket._at(r.pos);if(!(n instanceof t)&&n!=null&&n.key===e)return n}async _findPlace(e){let r=this._options.hash(typeof e=="string"?N0(e):e),n=await r.take(this._options.bits),i=this._children.get(n);return i instanceof t?i._findPlace(r):{bucket:this,pos:n,hash:r,existingChild:i}}async _findNewBucketAndPos(e){let r=await this._findPlace(e);if(r.existingChild!=null&&r.existingChild.key!==e){let n=new t(this._options,r.bucket,r.pos);r.bucket._putObjectAt(r.pos,n);let i=await n._findPlace(r.existingChild.hash);return i.bucket._putAt(i,r.existingChild.key,r.existingChild.value),n._findNewBucketAndPos(r.hash)}return r}_putAt(e,r,n){this._putObjectAt(e.pos,{key:r,value:n,hash:e.hash})}_putObjectAt(e,r){this._children.get(e)==null&&this._popCount++,this._children.set(e,r)}_delAt(e){if(e===-1)throw new Error("Invalid position");this._children.get(e)!=null&&this._popCount--,this._children.unset(e),this._level()}_level(){if(this._parent!=null&&this._popCount<=1)if(this._popCount===1){let e=this._children.find(i5e);if(e!=null&&!(e instanceof t)){let r=e.hash;r.untake(this._options.bits);let n={pos:this._posAtParent,hash:r,bucket:this._parent};this._parent._putAt(n,e.key,e.value)}}else this._parent._delAt(this._posAtParent)}_at(e){return this._children.get(e)}};function i5e(t){return!!t}function o5e(t,e){return t.key}function s5e(t){return t}async function QJ(t,e,r){let n=[];for(let i of t._children.compactArray())if(i instanceof Rl)await QJ(i,e,r);else{let o=await e(i);n.push({bitField:t._children.bitField(),children:o})}return r(n)}f();f();var a5e=[255,254,252,248,240,224,192,128],c5e=[1,3,7,15,31,63,127,255],$8=class{_value;_currentBytePos;_currentBitPos;constructor(e){this._value=e,this._currentBytePos=e.length-1,this._currentBitPos=7}availableBits(){return this._currentBitPos+1+this._currentBytePos*8}totalBits(){return this._value.length*8}take(e){let r=e,n=0;for(;r>0&&this._haveBits();){let i=this._value[this._currentBytePos],o=this._currentBitPos+1,s=Math.min(o,r),a=d5e(i,o-s,s);n=(n<7;)this._currentBitPos-=8,this._currentBytePos+=1}_haveBits(){return this._currentBytePos>=0}};function d5e(t,e,r){let n=u5e(e,r);return(t&n)>>>e}function u5e(t,e){return a5e[t]&c5e[Math.min(e+t-1,7)]}function eZ(t){function e(r){return r instanceof j8?r:new j8(r,t)}return e}var j8=class{_value;_hashFn;_depth;_availableBits;_currentBufferIndex;_buffers;constructor(e,r){if(!(e instanceof Uint8Array))throw new Error("can only hash Uint8Arrays");this._value=e,this._hashFn=r,this._depth=-1,this._availableBits=0,this._currentBufferIndex=0,this._buffers=[]}async take(e){let r=e;for(;this._availableBits0;){let i=this._buffers[this._currentBufferIndex],o=Math.min(i.availableBits(),r),s=i.take(o);n=(n<0;){let n=this._buffers[this._currentBufferIndex],i=Math.min(n.totalBits()-n.availableBits(),r);n.untake(i),r-=i,this._availableBits+=i,this._currentBufferIndex>0&&n.totalBits()===n.availableBits()&&(this._depth--,this._currentBufferIndex--)}}async _produceMoreBits(){this._depth++;let e=this._depth>0?Yb([this._value,Uint8Array.from([this._depth])]):this._value,r=await this._hashFn(e),n=new $8(r);this._buffers.push(n),this._availableBits+=n.availableBits()}};function N8(t){if(t==null||t.hashFn==null)throw new Error("please define an options.hashFn");let e={bits:t.bits??8,hash:eZ(t.hashFn)};return new Rl(e)}async function l5e(t){return(await C8.encode(t)).slice(0,8).reverse()}var tZ=BigInt(34),s7=class extends kl{_bucket;constructor(e,r){super(e,r),this._bucket=N8({hashFn:l5e,bits:8})}async put(e,r){this.cid=void 0,this.size=void 0,this.nodeSize=void 0,await this._bucket.put(e,r)}async get(e){return this._bucket.get(e)}childCount(){return this._bucket.leafCount()}directChildrenCount(){return this._bucket.childrenCount()}onlyChild(){return this._bucket.onlyChild()}async*eachChildSeries(){for await(let{key:e,value:r}of this._bucket.eachLeafSeries())yield{key:e,child:r}}estimateNodeSize(){return this.nodeSize!==void 0?this.nodeSize:(this.nodeSize=iZ(this._bucket,this,this.options),this.nodeSize)}async*flush(e){for await(let r of nZ(this._bucket,e,this,this.options))yield{...r,path:this.path}}},rZ=s7;async function*nZ(t,e,r,n){let i=t._children,o=[],s=0n;for(let m=0;mr&&(i=await h5e(e,n));let o=i.parent;if(o!=null){if(i!==e){if(t!=null&&(t.parent=i),i.parentKey==null)throw new Error("No parent key found");await o.put(i.parentKey,i)}return a7(i,o,r,n)}return i}async function h5e(t,e){let r=new rZ({root:t.root,dir:!0,parent:t.parent,parentKey:t.parentKey,path:t.path,dirty:t.dirty,flat:!1,mtime:t.mtime,mode:t.mode},e);for await(let{key:n,child:i}of t.eachChildSeries())await r.put(n,i);return r}f();var oZ=(t="")=>(t.trim().match(/([^\\/]|\\\/)+/g)??[]).filter(Boolean);async function p5e(t,e,r){let n=oZ(t.path??""),i=n.length-1,o=e,s="";for(let a=0;a1)yield*sZ(i,n);else for await(let a of i.eachChildSeries())a!=null&&(yield*sZ(a.child,n))}}async function*$x(t,e,r={}){let n;Symbol.asyncIterator in t||Symbol.iterator in t?n=t:n=[t];let i=r.wrapWithDirectory??!1,o=r.shardSplitThresholdBytes??262144,s=r.cidVersion??1,a=r.rawLeaves??!0,d=r.leafType??"file",u=r.fileImportConcurrency??50,c=r.blockWriteConcurrency??10,l=r.reduceSingleLeafToSelf??!0,p=r.chunker??eJ(),m=r.chunkValidator??WJ(),g=r.dagBuilder??OJ({chunker:p,chunkValidator:m,wrapWithDirectory:i,layout:r.layout??o7(),bufferImporter:r.bufferImporter??RJ({cidVersion:s,rawLeaves:a,leafType:d,onProgress:r.onProgress}),blockWriteConcurrency:c,reduceSingleLeafToSelf:l,cidVersion:s,onProgress:r.onProgress}),v=r.treeBuilder??aZ({wrapWithDirectory:i,shardSplitThresholdBytes:o,cidVersion:s,onProgress:r.onProgress});for await(let x of v(Ex(g(n,e),u),e))yield{cid:x.cid,path:x.path,unixfs:x.unixfs,size:x.size}}var c7=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},cZ=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,d){s=t[o](s),i(a,d,s.done,s.value)})}}function i(o,s,a,d){Promise.resolve(d).then(function(u){o({value:u,done:a})},s)}},dZ={[Ns.code]:Ns},uZ={[vx]:V0},fn=class{static computeCid(e,r=vx,n=Ns.code){return c7(this,void 0,void 0,function*(){let i=uZ[r];if(!i)throw new de(se.ComputeCidCodecNotSupported,`codec [${r}] not supported`);let o=dZ[n];if(!o)throw new de(se.ComputeCidMultihashNotSupported,`multihash code [${n}] not supported`);let s=i.encode(e),a=yield o.digest(s);return(yield jr.createV1(i.code,a)).toString()})}static parseCid(e){let r=jr.parse(e).toV1();if(!uZ[r.code])throw new de(se.ParseCidCodecNotSupported,`codec [${r.code}] not supported`);if(!dZ[r.multihash.code])throw new de(se.ParseCidMultihashNotSupported,`multihash code [${r.multihash.code}] not supported`);return r}static computeDagPbCidFromBytes(e){var r,n,i,o;return c7(this,void 0,void 0,function*(){let s=$x([{content:e}],new _x,{cidVersion:1}),a;try{for(var d=!0,u=cZ(s),c;c=yield u.next(),r=c.done,!r;d=!0)o=c.value,d=!1,a=o}catch(l){n={error:l}}finally{try{!d&&!r&&(i=u.return)&&(yield i.call(u))}finally{if(n)throw n.error}}return a?a.cid.toString():""})}static computeDagPbCidFromStream(e){var r,n,i,o;return c7(this,void 0,void 0,function*(){let s=$x([{content:e}],new _x,{cidVersion:1}),a;try{for(var d=!0,u=cZ(s),c;c=yield u.next(),r=c.done,!r;d=!0)o=c.value,d=!1,a=o}catch(l){n={error:l}}finally{try{!d&&!r&&(i=u.return)&&(yield i.call(u))}finally{if(n)throw n.error}}return a?a.cid.toString():""})}};f();var LT=gt(C4(),1),zm=gt(Ase(),1),_j=gt(M1(),1),qT=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})};zm.ECIES_CONFIG.isEphemeralKeyCompressed=!0;var Ch=class t{static aes256CtrEncrypt(e,r,n){return qT(this,void 0,void 0,function*(){let i=LT.createCipheriv("aes-256-ctr",e,r),o=new _j.Readable({read(){}});return n.on("data",s=>{let a=i.update(s);o.push(a)}),n.on("end",()=>{let s=i.final();o.push(s),o.push(null)}),n.on("error",s=>{o.emit("error",s)}),o})}static aes256CtrDecrypt(e,r,n){return qT(this,void 0,void 0,function*(){let i=LT.createDecipheriv("aes-256-ctr",e,r),o=new _j.Readable({read(){}});return n.on("data",s=>{let a=i.update(s);o.push(a)}),n.on("end",()=>{let s=i.final();o.push(s),o.push(null)}),n.on("error",s=>{o.emit("error",s)}),o})}static eciesSecp256k1Encrypt(e,r){return qT(this,void 0,void 0,function*(){let n=O.Buffer.from(e),i=O.Buffer.from(r),o=zm.encrypt(n,i),s=0,a=t.isEphemeralKeyCompressed?33:65,d=o.subarray(s,a);s=a,a+=zm.ECIES_CONFIG.symmetricNonceLength;let u=o.subarray(s,a);s=a,a+=16;let c=o.subarray(s,a);return{ciphertext:o.subarray(a),ephemeralPublicKey:d,initializationVector:u,messageAuthenticationCode:c}})}static eciesSecp256k1Decrypt(e){return qT(this,void 0,void 0,function*(){let r=O.Buffer.from(e.privateKey),n=O.Buffer.concat([e.ephemeralPublicKey,e.initializationVector,e.messageAuthenticationCode,e.ciphertext]);return zm.decrypt(r,n)})}static get isEphemeralKeyCompressed(){return zm.ECIES_CONFIG.isEphemeralKeyCompressed}},Hg;(function(t){t.Aes256Ctr="A256CTR",t.EciesSecp256k1="ECIES-ES256K"})(Hg||(Hg={}));f();var pde=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Vg=class t{constructor(e){this.jws=e}static create(e,r=[]){return pde(this,void 0,void 0,function*(){let n={payload:qe.bytesToBase64Url(e),signatures:[]},i=new t(n);for(let o of r)yield i.addSignature(o);return i})}addSignature(e){return pde(this,void 0,void 0,function*(){let r={kid:e.keyId,alg:e.algorithm},n=JSON.stringify(r),i=qe.stringToBase64Url(n),o=`${i}.${this.jws.payload}`,s=qe.stringToBytes(o),a=yield e.sign(s),d=qe.bytesToBase64Url(a);this.jws.signatures.push({protected:i,signature:d})})}getJws(){return this.jws}};f();f();f();var KT=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function ds(){if(KT&&typeof KT.subtle=="object"&&KT.subtle!=null)return KT.subtle;throw new Error("crypto.subtle must be defined")}f();f();function c6(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function xj(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}function Ej(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function ao(t,...e){if(!Ej(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 Sj(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 mde(t,e){ao(t);let r=e.outputLen;if(t.lengthnew Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),yde=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),qUe=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!qUe)throw new Error("Non little-endian hardware is not supported");function LUe(t){if(typeof t!="string")throw new Error(`string expected, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function FT(t){if(typeof t=="string")t=LUe(t);else if(Ej(t))t=t.slice();else throw new Error(`Uint8Array expected, got ${typeof t}`);return t}function gde(t,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(t,e)}function vde(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n(Object.assign(e,t),e);function Tj(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),d=n?4:0,u=n?0:4;t.setUint32(e+d,s,n),t.setUint32(e+u,a,n)}var bde={async encrypt(t,e,r,n){let i=ds(),o=await i.importKey("raw",t,e,!0,["encrypt"]),s=await i.encrypt(r,o,n);return new Uint8Array(s)},async decrypt(t,e,r,n){let i=ds(),o=await i.importKey("raw",t,e,!0,["decrypt"]),s=await i.decrypt(r,o,n);return new Uint8Array(s)}},ef={CBC:"AES-CBC",CTR:"AES-CTR",GCM:"AES-GCM"};function KUe(t,e,r){if(t===ef.CBC)return{name:ef.CBC,iv:e};if(t===ef.CTR)return{name:ef.CTR,counter:e,length:64};if(t===ef.GCM)return r?{name:ef.GCM,iv:e,additionalData:r}:{name:ef.GCM,iv:e};throw new Error("unknown aes block mode")}function Pj(t){return(e,r,n)=>{ao(e),ao(r);let i={name:t,length:e.length*8},o=KUe(t,r,n);return{encrypt(s){return ao(s),bde.encrypt(e,i,o,s)},decrypt(s){return ao(s),bde.decrypt(e,i,o,s)}}}}var ext=Pj(ef.CBC),txt=Pj(ef.CTR),rxt=Pj(ef.GCM);var zT=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},co;(function(t){t.DataFormats="dataFormats",t.ProtocolContext="protocolContext",t.ProtocolPath="protocolPath",t.Schemas="schemas"})(co||(co={}));var Gg=class t{static derivePrivateKey(e,r){var n;return zT(this,void 0,void 0,function*(){let i=Li.privateJwkToBytes(e.derivedPrivateKey),o=(n=e.derivationPath)!==null&&n!==void 0?n:[],s=yield t.derivePrivateKeyBytes(i,r),a=yield Li.privateKeyToJwk(s);return{rootKeyId:e.rootKeyId,derivationScheme:e.derivationScheme,derivationPath:[...o,...r],derivedPrivateKey:a}})}static derivePublicKey(e,r){return zT(this,void 0,void 0,function*(){let n=yield t.derivePrivateKey(e,r);return yield Li.getPublicJwk(n.derivedPrivateKey)})}static derivePrivateKeyBytes(e,r){return zT(this,void 0,void 0,function*(){t.validateKeyDerivationPath(r);let n=e;for(let i of r){let o=qe.stringToBytes(i);n=yield t.deriveKeyUsingHkdf({hashAlgorithm:"SHA-256",initialKeyMaterial:n,info:o,keyLengthInBytes:32})}return n})}static deriveKeyUsingHkdf(e){return zT(this,void 0,void 0,function*(){let{hashAlgorithm:r,initialKeyMaterial:n,info:i,keyLengthInBytes:o}=e,a=yield ds().importKey("raw",n,{name:"HKDF"},!1,["deriveBits"]),d=yield crypto.subtle.deriveBits({name:"HKDF",hash:r,salt:new Uint8Array(0),info:i},a,o*8);return new Uint8Array(d)})}static validateKeyDerivationPath(e){if(e.includes(""))throw new de(se.HdKeyDerivationPathInvalid,`Invalid key derivation path: ${e}`)}};f();f();function d6(t,e){return t>e?1:t{t[e]===void 0?delete t[e]:typeof t[e]=="object"&&Tn(t[e])})}var tf=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},_e=class t{static getAuthor(e){if(e.authorization===void 0)return;let r;return e.authorization.authorDelegatedGrant!==void 0?r=t.getSigner(e.authorization.authorDelegatedGrant):r=t.getSigner(e),r}static validateJsonSchema(e){let r=e.descriptor.interface,n=e.descriptor.method,i=r+n;nh(i,e)}static getSigner(e){return e.authorization===void 0?void 0:tn.getSignerDid(e.authorization.signature.signatures[0])}static getCid(e){return tf(this,void 0,void 0,function*(){let r=Object.assign({},e);return r.encodedData&&delete r.encodedData,yield fn.computeCid(r)})}static compareCid(e,r){return tf(this,void 0,void 0,function*(){let n=yield t.getCid(e),i=yield t.getCid(r);return d6(n,i)})}static createAuthorization(e){return tf(this,void 0,void 0,function*(){let{descriptor:r,signer:n,delegatedGrant:i,permissionGrantId:o,protocolRole:s}=e,a;i!==void 0&&(a=yield t.getCid(i));let u={signature:yield t.createSignature(r,n,{delegatedGrantId:a,permissionGrantId:o,protocolRole:s})};return i!==void 0&&(u.authorDelegatedGrant=i),u})}static createSignature(e,r,n){return tf(this,void 0,void 0,function*(){let i=yield fn.computeCid(e),o=Object.assign({descriptorCid:i},n);Tn(o);let s=qe.objectToBytes(o);return(yield Vg.create(s,[r])).getJws()})}static getNewestMessage(e){return tf(this,void 0,void 0,function*(){let r;for(let n of e)(r===void 0||(yield t.isNewer(n,r)))&&(r=n);return r})}static getOldestMessage(e){return tf(this,void 0,void 0,function*(){let r;for(let n of e)(r===void 0||(yield t.isOlder(n,r)))&&(r=n);return r})}static isNewer(e,r){return tf(this,void 0,void 0,function*(){return(yield t.compareMessageTimestamp(e,r))>0})}static isOlder(e,r){return tf(this,void 0,void 0,function*(){return(yield t.compareMessageTimestamp(e,r))<0})}static isSignedByAuthorDelegate(e){var r;return((r=e.authorization)===null||r===void 0?void 0:r.authorDelegatedGrant)!==void 0}static isSignedByOwnerDelegate(e){var r;return((r=e.authorization)===null||r===void 0?void 0:r.ownerDelegatedGrant)!==void 0}static compareMessageTimestamp(e,r){return tf(this,void 0,void 0,function*(){return e.descriptor.messageTimestamp>r.descriptor.messageTimestamp?1:e.descriptor.messageTimestamp=e.lt||e.lte!==void 0&&r>e.lte||e.gt!==void 0&&r<=e.gt||e.gte!==void 0&&rv.rootKeyId===r.rootKeyId&&v.derivationScheme===r.derivationScheme);if(o===void 0)throw new de(se.RecordsDecryptNoMatchingKeyEncryptedFound,`Unable to find a symmetric key encrypted using key with ID '${r.rootKeyId}' and '${r.derivationScheme}' derivation scheme.`);let s=t.constructKeyDerivationPath(o.derivationScheme,e),a=yield t.derivePrivateKey(r,s),d=qe.base64UrlToBytes(o.encryptedKey),u=Li.publicJwkToBytes(o.ephemeralPublicKey),c=qe.base64UrlToBytes(o.initializationVector),l=qe.base64UrlToBytes(o.messageAuthenticationCode),p=yield Ch.eciesSecp256k1Decrypt({ciphertext:d,ephemeralPublicKey:u,initializationVector:c,messageAuthenticationCode:l,privateKey:a}),m=qe.base64UrlToBytes(i.initializationVector);return yield Ch.aes256CtrDecrypt(p,m,n)})}static constructKeyDerivationPath(e,r){let n=r.descriptor,i=r.contextId,o;return e===co.DataFormats?o=t.constructKeyDerivationPathUsingDataFormatsScheme(n.schema,n.dataFormat):e===co.ProtocolPath?o=t.constructKeyDerivationPathUsingProtocolPathScheme(n):e===co.ProtocolContext?o=t.constructKeyDerivationPathUsingProtocolContextScheme(i):o=t.constructKeyDerivationPathUsingSchemasScheme(n.schema),o}static constructKeyDerivationPathUsingDataFormatsScheme(e,r){return e!==void 0?[co.DataFormats,e,r]:[co.DataFormats,r]}static constructKeyDerivationPathUsingProtocolPathScheme(e){if(e.protocol===void 0)throw new de(se.RecordsProtocolPathDerivationSchemeMissingProtocol,"Unable to construct key derivation path using `protocols` scheme because `protocol` is missing.");let r=e.protocolPath.split("/");return[co.ProtocolPath,e.protocol,...r]}static constructKeyDerivationPathUsingProtocolContextScheme(e){if(e===void 0)throw new de(se.RecordsProtocolContextDerivationSchemeMissingContextId,"Unable to construct key derivation path using `protocolContext` scheme because `contextId` is missing.");let r=e.split("/")[0];return[co.ProtocolContext,r]}static constructKeyDerivationPathUsingSchemasScheme(e){if(e===void 0)throw new de(se.RecordsSchemasDerivationSchemeMissingSchema,"Unable to construct key derivation path using `schemas` scheme because `schema` is missing.");return[co.Schemas,e]}static derivePrivateKey(e,r){var n;return Ij(this,void 0,void 0,function*(){if(e.derivedPrivateKey.crv!=="secp256k1")throw new de(se.RecordsDerivePrivateKeyUnSupportedCurve,`Curve ${e.derivedPrivateKey.crv} is not supported.`);let i=(n=e.derivationPath)!==null&&n!==void 0?n:[];t.validateAncestorKeyAndDescentKeyDerivationPathsMatch(i,r);let o=r.slice(i.length),s=Li.privateJwkToBytes(e.derivedPrivateKey);return yield Gg.derivePrivateKeyBytes(s,o)})}static validateAncestorKeyAndDescentKeyDerivationPathsMatch(e,r){for(let n=0;n=n.dateExpires)throw new de(se.GrantAuthorizationGrantExpired,"The message has timestamp after the expiry of the associated permission grant");let o={parentId:n.id,protocolPath:"grant/revocation",isLatestBaseState:!0},{messages:s}=yield i.query(e,[o]),a=yield _e.getOldestMessage(s);if(a!==void 0&&a.descriptor.messageTimestamp<=r)throw new de(se.GrantAuthorizationGrantRevoked,`Permission grant with CID ${n.id} has been revoked`)})}static verifyGrantScopeInterfaceAndMethod(e,r,n){return kj(this,void 0,void 0,function*(){if(e!==n.scope.interface)throw new de(se.GrantAuthorizationInterfaceMismatch,`DWN Interface of incoming message is outside the scope of permission grant with ID ${n.id}`);if(r!==n.scope.method)throw new de(se.GrantAuthorizationMethodMismatch,`DWN Method of incoming message is outside the scope of permission grant with ID ${n.id}`)})}};f();var l6;(function(t){t.Required="Required",t.Prohibited="Prohibited"})(l6||(l6={}));var HT=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},us=class t{static authorizeWrite(e){return HT(this,void 0,void 0,function*(){let{recordsWriteMessage:r,expectedGrantor:n,expectedGrantee:i,permissionGrant:o,messageStore:s}=e;yield Fc.performBaseValidation({incomingMessage:r,expectedGrantor:n,expectedGrantee:i,permissionGrant:o,messageStore:s}),t.verifyScope(r,o.scope),t.verifyConditions(r,o.conditions)})}static authorizeRead(e){return HT(this,void 0,void 0,function*(){let{recordsReadMessage:r,recordsWriteMessageToBeRead:n,expectedGrantor:i,expectedGrantee:o,permissionGrant:s,messageStore:a}=e;yield Fc.performBaseValidation({incomingMessage:r,expectedGrantor:i,expectedGrantee:o,permissionGrant:s,messageStore:a}),t.verifyScope(n,s.scope)})}static authorizeQueryOrSubscribe(e){return HT(this,void 0,void 0,function*(){let{incomingMessage:r,expectedGrantor:n,expectedGrantee:i,permissionGrant:o,messageStore:s}=e;yield Fc.performBaseValidation({incomingMessage:r,expectedGrantor:n,expectedGrantee:i,permissionGrant:o,messageStore:s});let d=o.scope.protocol,u=r.descriptor.filter.protocol;if(d!==void 0&&u!==d)throw new de(se.RecordsGrantAuthorizationQueryOrSubscribeProtocolScopeMismatch,`Grant protocol scope ${d} does not match protocol in message ${u}`)})}static authorizeDelete(e){return HT(this,void 0,void 0,function*(){let{recordsDeleteMessage:r,recordsWriteToDelete:n,expectedGrantor:i,expectedGrantee:o,permissionGrant:s,messageStore:a}=e;yield Fc.performBaseValidation({incomingMessage:r,expectedGrantor:i,expectedGrantee:o,permissionGrant:s,messageStore:a});let u=s.scope.protocol,c=n.descriptor.protocol;if(u!==void 0&&c!==u)throw new de(se.RecordsGrantAuthorizationDeleteProtocolScopeMismatch,`Grant protocol scope ${u} does not match protocol in record to delete ${c}`)})}static verifyScope(e,r){if(r.protocol!==e.descriptor.protocol)throw new de(se.RecordsGrantAuthorizationScopeProtocolMismatch,"Grant scope specifies different protocol than what appears in the record");if(r.contextId!==void 0&&(e.contextId===void 0||!e.contextId.startsWith(r.contextId)))throw new de(se.RecordsGrantAuthorizationScopeContextIdMismatch,"Grant scope specifies different contextId than what appears in the record");if(r.protocolPath!==void 0&&r.protocolPath!==e.descriptor.protocolPath)throw new de(se.RecordsGrantAuthorizationScopeProtocolPathMismatch,"Grant scope specifies different protocolPath than what appears in the record")}static verifyConditions(e,r){if(r?.publication===l6.Required&&!e.descriptor.published)throw new de(se.RecordsGrantAuthorizationConditionPublicationRequired,"Permission grant requires message to be published");if(r?.publication===l6.Prohibited&&e.descriptor.published)throw new de(se.RecordsGrantAuthorizationConditionPublicationProhibited,"Permission grant prohibits message from being published")}};f();f();var z=gt(_de(),1),Nj={};function lf(t,e){Object.defineProperty(t.prototype,Symbol.toStringTag,{value:e,writable:!1,enumerable:!1,configurable:!0});for(let r of Object.getOwnPropertyNames(t)){let n=Object.getOwnPropertyDescriptor(t,r);n.configurable&&n.enumerable&&(n.enumerable=!1,Object.defineProperty(t,r,n))}for(let r of Object.getOwnPropertyNames(t.prototype)){let n=Object.getOwnPropertyDescriptor(t.prototype,r);n.configurable&&n.enumerable&&(n.enumerable=!1,Object.defineProperty(t.prototype,r,n))}In(e,t),In(`${e}.prototype`,t.prototype)}function In(t,e){let r=`%${t}%`;if(Nj[r]!==void 0)throw new Error(`intrinsic ${t} already exists`);Nj[r]=e}function Ae(t){return Nj[t]}var xde,Ede,ut="slot-epochNanoSeconds",nf="slot-timezone-identifier",De="slot-year",Oe="slot-month",je="slot-day",St="slot-hour",At="slot-minute",Tt="slot-second",Pt="slot-millisecond",It="slot-microsecond",kt="slot-nanosecond",fe="slot-calendar",iue="slot-date-brand",oue="slot-year-month-brand",sue="slot-month-day-brand",qo="slot-cached-instant",Nr="slot-time-zone",ls="slot-years",Gi="slot-months",ia="slot-weeks",fs="slot-days",hs="slot-hours",ps="slot-minutes",ms="slot-seconds",ys="slot-milliseconds",gs="slot-microseconds",vs="slot-nanoseconds",Pn="slot-calendar-identifier",aue=new WeakMap,Uj=Symbol.for("@@Temporal__GetSlots");(xde=globalThis)[Uj]||(xde[Uj]=function(e){return aue.get(e)});var pN=globalThis[Uj],qj=Symbol.for("@@Temporal__CreateSlots");(Ede=globalThis)[qj]||(Ede[qj]=function(e){aue.set(e,Object.create(null))});var ff=globalThis[qj];function Bi(t,...e){if(!t||typeof t!="object")return!1;let r=pN(t);return!!r&&e.every(n=>n in r)}function R(t,e){let r=pN(t)?.[e];if(r===void 0)throw new TypeError(`Missing internal slot ${e}`);return r}function Mt(t,e,r){let n=pN(t);if(n===void 0)throw new TypeError("Missing slots for the given container");if(n[e])throw new TypeError(`${e} already has set`);n[e]=r}var Sde=/\.[-A-Za-z_]|\.\.[-A-Za-z._]{1,12}|\.[-A-Za-z_][-A-Za-z._]{0,12}|[A-Za-z_][-A-Za-z._]{0,13}/,k6=new RegExp("(?:"+[`(?:${Sde.source})(?:\\/(?:${Sde.source}))*`,"Etc/GMT(?:0|[-+]\\d{1,2})","GMT[-+]?0","EST5EDT","CST6CDT","MST7MDT","PST8PDT",/(?:[+\u2212-][0-2][0-9](?::?[0-5][0-9](?::?[0-5][0-9](?:[.,]\d{1,9})?)?)?)/.source].join("|")+")"),cue=/(?:[+\u2212-]\d{6}|\d{4})/,XT=/(?:0[1-9]|1[0-2])/,Lj=/(?:0[1-9]|[12]\d|3[01])/,VUe=new RegExp(`(${cue.source})(?:-(${XT.source})-(${Lj.source})|(${XT.source})(${Lj.source}))`),due=/(\d{2})(?::(\d{2})(?::(\d{2})(?:[.,](\d{1,9}))?)?|(\d{2})(?:(\d{2})(?:[.,](\d{1,9}))?)?)?/,uue=/([+\u2212-])([01][0-9]|2[0-3])(?::?([0-5][0-9])(?::?([0-5][0-9])(?:[.,](\d{1,9}))?)?)?/,lue=new RegExp(`([zZ])|${uue.source}?`),ty=/\[(!)?([a-z_][a-z0-9_-]*)=([A-Za-z0-9]+(?:-[A-Za-z0-9]+)*)\]/g,GUe=new RegExp([`^${VUe.source}`,`(?:(?:T|\\s+)${due.source}(?:${lue.source})?)?`,`(?:\\[!?(${k6.source})\\])?`,`((?:${ty.source})*)$`].join(""),"i"),JUe=new RegExp([`^T?${due.source}`,`(?:${lue.source})?`,`(?:\\[!?${k6.source}\\])?`,`((?:${ty.source})*)$`].join(""),"i"),ZUe=new RegExp(`^(${cue.source})-?(${XT.source})(?:\\[!?${k6.source}\\])?((?:${ty.source})*)$`),YUe=new RegExp(`^(?:--)?(${XT.source})-?(${Lj.source})(?:\\[!?${k6.source}\\])?((?:${ty.source})*)$`),Bj=/(\d+)(?:[.,](\d{1,9}))?/,XUe=new RegExp(`(?:${Bj.source}H)?(?:${Bj.source}M)?(?:${Bj.source}S)?`),QUe=new RegExp(`^([+\u2212-])?P${/(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?/.source}(?:T(?!$)${XUe.source})?$`,"i"),eqe=Array.prototype.includes,fue=Array.prototype.push,hue=globalThis.Intl.DateTimeFormat,tqe=Math.min,rqe=Math.max,an=Math.abs,Da=Math.floor,z1=Math.sign,Xg=Math.trunc,pP=Number.isNaN,bs=Number.isFinite,nqe=Number,R6=String,iqe=Number.MAX_SAFE_INTEGER,Ko=Object.create,oqe=Object.getOwnPropertyDescriptor,mP=Reflect.apply,sqe=Reflect.ownKeys,Nn=z.default.BigInt(0),Q1=z.default.BigInt(1),of=z.default.BigInt(60),pue=z.default.BigInt(24),Ar=z.default.BigInt(1e3),Hc=z.default.BigInt(1e6),sf=z.default.BigInt(1e9),aqe=z.default.BigInt(-1),mue=z.default.multiply(z.default.BigInt(3600),sf),yue=z.default.multiply(of,sf),cf=z.default.multiply(mue,pue),y6=z.default.multiply(z.default.BigInt(-86400),z.default.BigInt(1e17)),W1=z.default.multiply(z.default.BigInt(86400),z.default.BigInt(1e17)),QT=-271821,eP=275760,j1=z.default.multiply(z.default.BigInt(-388152),z.default.BigInt(1e13)),cqe=z.default.multiply(cf,z.default.BigInt(3660)),gue=z.default.multiply(cf,z.default.BigInt(366)),vue=z.default.multiply(cf,z.default.BigInt(14)),dqe=["iso8601","hebrew","islamic","islamic-umalqura","islamic-tbla","islamic-civil","islamic-rgsa","islamicc","persian","ethiopic","ethioaa","coptic","chinese","dangi","roc","indian","buddhist","japanese","gregory"];function Wc(t){return z.default.equal(t,Nn)}function kr(t,e){let r=t[e];if(r!==void 0)return r}function Ge(t,e,r){let n=arguments.length>2?r:[];return mP(t,e,n)}function cn(t){return typeof t=="object"&&t!==null||typeof t=="function"}function H1(t){if(typeof t=="bigint")throw new TypeError("Cannot convert BigInt to number");return nqe(t)}function ii(t){let e=H1(t);if(pP(e)||e===0)return 0;if(!bs(e))return e;let r=Da(an(e));return r===0?0:z1(e)*r}function sc(t){if(typeof t!="number"||pP(t)||!bs(t))return!1;let e=an(t);return Da(e)===e}function _s(t){if(typeof t=="symbol")throw new TypeError("Cannot convert a Symbol value to a String");return R6(t)}function vr(t){let e=H1(t);if(e===0)return 0;if(pP(e)||!bs(e))throw new RangeError("invalid number value");let r=Xg(e);return r===0?0:r}function Ade(t,e){let r=vr(t);if(r<=0)throw e!==void 0?new RangeError(`property '${e}' cannot be a a number less than one`):new RangeError("Cannot convert a number less than one to a positive integer");return r}function Di(t){let e=H1(t);if(!bs(e))throw new RangeError("infinity is out of range");if(!sc(e))throw new RangeError(`unsupported fractional value ${t}`);return e===0?0:e}function Zn(t,e){return{quotient:z.default.divide(t,e),remainder:z.default.remainder(t,e)}}function tP(t){return z.default.lessThan(t,Nn)}function Tde(t){return Wc(t)?0:tP(t)?-1:1}function Fu(t){return z.default.lessThan(t,Nn)?z.default.multiply(t,aqe):t}var Pde=new Map([["year",vr],["month",Ade],["monthCode",_s],["day",Ade],["hour",vr],["minute",vr],["second",vr],["millisecond",vr],["microsecond",vr],["nanosecond",vr],["years",Di],["months",Di],["weeks",Di],["days",Di],["hours",Di],["minutes",Di],["seconds",Di],["milliseconds",Di],["microseconds",Di],["nanoseconds",Di],["era",_s],["eraYear",ii],["offset",_s]]),uqe=new Map([["hour",0],["minute",0],["second",0],["millisecond",0],["microsecond",0],["nanosecond",0]]),D6=[["years","year","date"],["months","month","date"],["weeks","week","date"],["days","day","date"],["hours","hour","time"],["minutes","minute","time"],["seconds","second","time"],["milliseconds","millisecond","time"],["microseconds","microsecond","time"],["nanoseconds","nanosecond","time"]],rP=new Map(D6.map(t=>[t[0],t[1]])),lqe=new Map(D6.map(([t,e])=>[e,t])),Ide=D6.map(([,t])=>t),kde=Array.from(rP.keys()).sort(),Rde=new Map;function bue(t){let e=Rde.get(t);return e===void 0&&(e=new hue("en-us",{timeZone:R6(t),hour12:!1,era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}),Rde.set(t,e)),e}function Dde(t){if(t==null)throw new TypeError(`Expected object not ${t}`);return Object(t)}function N1(t,e,r,n){if(e==null)return;let i=sqe(e);for(let o of i)if(!r.some(s=>Object.is(s,o))&&Object.prototype.propertyIsEnumerable.call(e,o)){let s=e[o];if(n&&n.some(a=>Object.is(a,s)))continue;t[o]=s}}function _i(t){return Bi(t,ut)&&!Bi(t,Nr,fe)}function zc(t){return Bi(t,nf)}function Cn(t){return Bi(t,Pn)}function $n(t){return Bi(t,ls,Gi,fs,hs,ps,ms,ys,gs,vs)}function Jt(t){return Bi(t,iue)}function jn(t){return Bi(t,St,At,Tt,Pt,It,kt)&&!Bi(t,De,Oe,je)}function _t(t){return Bi(t,De,Oe,je,St,At,Tt,Pt,It,kt)}function Sr(t){return Bi(t,oue)}function Ri(t){return Bi(t,sue)}function Ke(t){return Bi(t,ut,Nr,fe)}function e2(t){if(Bi(t,fe)||Bi(t,Nr))throw new TypeError("with() does not support a calendar or timeZone property");if(jn(t))throw new TypeError("with() does not accept Temporal.PlainTime, use withPlainTime() instead");if(t.calendar!==void 0)throw new TypeError("with() does not support a calendar property");if(t.timeZone!==void 0)throw new TypeError("with() does not support a timeZone property")}function fqe(t){let{ianaName:e,offset:r,z:n}=function(o){if(new RegExp(`^${k6.source}$`,"i").test(o))return{ianaName:o};try{let s=hf(o);if(s.z||s.offset||s.ianaName)return s}catch{}throw new RangeError(`Invalid time zone: ${o}`)}(t);return e?AN(e):n?"UTC":PP(Jm(r))}function mN(t,e){return e==="never"?"":yN(ho(t),e)}function yN(t,e){return e==="never"||e==="auto"&&t==="iso8601"?"":`[${e==="critical"?"!":""}u-ca=${t}]`}function hf(t){let e=GUe.exec(t);if(!e)throw new RangeError(`invalid ISO 8601 string: ${t}`);let r=e[1];if(r[0]==="\u2212"&&(r=`-${r.slice(1)}`),r==="-000000")throw new RangeError(`invalid ISO 8601 string: ${t}`);let n=ii(r),i=ii(e[2]||e[4]),o=ii(e[3]||e[5]),s=ii(e[6]),a=e[6]!==void 0,d=ii(e[7]||e[10]),u=ii(e[8]||e[11]);u===60&&(u=59);let c=(e[9]||e[12])+"000000000",l=ii(c.slice(0,3)),p=ii(c.slice(3,6)),m=ii(c.slice(6,9)),g,v=!1;if(e[13])g=void 0,v=!0;else if(e[14]&&e[15]){let A=e[14]==="-"||e[14]==="\u2212"?"-":"+",$=e[15]||"00",j=e[16]||"00",L=e[17]||"00",F=e[18]||"0";if(g=`${A}${$}:${j}`,+F){for(;F.endsWith("0");)F=F.slice(0,-1);g+=`:${L}.${F}`}else+L&&(g+=`:${L}`);g==="-00:00"&&(g="+00:00")}let x=e[19],S=e[20],P;for(let[,A,$,j]of S.matchAll(ty))if($==="u-ca")P===void 0&&(P=j);else if(A==="!")throw new RangeError(`Unrecognized annotation: !${$}=${j}`);return IN(n,i,o,s,d,u,l,p,m),{year:n,month:i,day:o,hasTime:a,hour:s,minute:d,second:u,millisecond:l,microsecond:p,nanosecond:m,ianaName:x,offset:g,z:v,calendar:P}}function gN(t){let e=ZUe.exec(t),r,n,i,o;if(e){let s=e[1];if(s[0]==="\u2212"&&(s=`-${s.slice(1)}`),s==="-000000")throw new RangeError(`invalid ISO 8601 string: ${t}`);r=ii(s),n=ii(e[2]);let a=e[3];for(let[,d,u,c]of a.matchAll(ty))if(u==="u-ca")i===void 0&&(i=c);else if(d==="!")throw new RangeError(`Unrecognized annotation: !${u}=${c}`);if(i!==void 0&&i!=="iso8601")throw new RangeError("YYYY-MM format is only valid with iso8601 calendar")}else{let s;if({year:r,month:n,calendar:i,day:o,z:s}=hf(t),s)throw new RangeError("Z designator not supported for PlainYearMonth")}return{year:r,month:n,calendar:i,referenceISODay:o}}function vN(t){let e=YUe.exec(t),r,n,i,o;if(e){r=ii(e[1]),n=ii(e[2]);let s=e[3];for(let[,a,d,u]of s.matchAll(ty))if(d==="u-ca")i===void 0&&(i=u);else if(a==="!")throw new RangeError(`Unrecognized annotation: !${d}=${u}`);if(i!==void 0&&i!=="iso8601")throw new RangeError("MM-DD format is only valid with iso8601 calendar")}else{let s;if({month:r,day:n,calendar:i,year:o,z:s}=hf(t),s)throw new RangeError("Z designator not supported for PlainMonthDay")}return{month:r,day:n,calendar:i,referenceISOYear:o}}function hqe(t){let{year:e,month:r,day:n,hour:i,minute:o,second:s,millisecond:a,microsecond:d,nanosecond:u,offset:c,z:l}=function(v){let x=hf(v);if(!x.z&&!x.offset)throw new RangeError("Temporal.Instant requires a time zone offset");return x}(t);if(!l&&!c)throw new RangeError("Temporal.Instant requires a time zone offset");let p=l?0:Jm(c);({year:e,month:r,day:n,hour:i,minute:o,second:s,millisecond:a,microsecond:d,nanosecond:u}=TN(e,r,n,i,o,s,a,d,u-p));let m=Zm(e,r,n,i,o,s,a,d,u);if(m===null)throw new RangeError("DateTime outside of supported range");return m}function nP(t,e,r,n){let i=t,o=e,s=r;switch(n){case"reject":df(i,o,s);break;case"constrain":({year:i,month:o,day:s}=$ue(i,o,s))}return{year:i,month:o,day:s}}function yP(t,e,r,n,i,o,s){let a=t,d=e,u=r,c=n,l=i,p=o;switch(s){case"reject":kP(a,d,u,c,l,p);break;case"constrain":({hour:a,minute:d,second:u,millisecond:c,microsecond:l,nanosecond:p}=function(g,v,x,S,P,A){let $=Ra(g,0,23),j=Ra(v,0,59),L=Ra(x,0,59),F=Ra(S,0,999),K=Ra(P,0,999),W=Ra(A,0,999);return{hour:$,minute:j,second:L,millisecond:F,microsecond:K,nanosecond:W}}(a,d,u,c,l,p))}return{hour:a,minute:d,second:u,millisecond:c,microsecond:l,nanosecond:p}}function dv(t){if(!cn(t))return function(g){let v=QUe.exec(g);if(!v)throw new RangeError(`invalid duration: ${g}`);if(v.slice(2).every(E=>E===void 0))throw new RangeError(`invalid duration: ${g}`);let x=v[1]==="-"||v[1]==="\u2212"?-1:1,S=v[2]===void 0?0:vr(v[2])*x,P=v[3]===void 0?0:vr(v[3])*x,A=v[4]===void 0?0:vr(v[4])*x,$=v[5]===void 0?0:vr(v[5])*x,j=v[6]===void 0?0:vr(v[6])*x,L=v[7],F=v[8],K=v[9],W=v[10],q=v[11],I=0,T=0,B=0;if(L!==void 0){if(F??K??W??q)throw new RangeError("only the smallest unit can be fractional");B=3600*ii((L+"000000000").slice(0,9))*x}else if(I=F===void 0?0:vr(F)*x,K!==void 0){if(W??q)throw new RangeError("only the smallest unit can be fractional");B=60*ii((K+"000000000").slice(0,9))*x}else T=W===void 0?0:vr(W)*x,q!==void 0&&(B=ii((q+"000000000").slice(0,9))*x);let h=B%1e3,y=Xg(B/1e3)%1e3,w=Xg(B/1e6)%1e3;return T+=Xg(B/1e9)%60,I+=Xg(B/6e10),dP(S,P,A,$,j,I,T,w,y,h),{years:S,months:P,weeks:A,days:$,hours:j,minutes:I,seconds:T,milliseconds:w,microseconds:y,nanoseconds:h}}(_s(t));if($n(t))return{years:R(t,ls),months:R(t,Gi),weeks:R(t,ia),days:R(t,fs),hours:R(t,hs),minutes:R(t,ps),seconds:R(t,ms),milliseconds:R(t,ys),microseconds:R(t,gs),nanoseconds:R(t,vs)};let e={years:0,months:0,weeks:0,days:0,hours:0,minutes:0,seconds:0,milliseconds:0,microseconds:0,nanoseconds:0},r=function(g){if(!cn(g))throw new TypeError("invalid duration-like");let v={years:void 0,months:void 0,weeks:void 0,days:void 0,hours:void 0,minutes:void 0,seconds:void 0,milliseconds:void 0,microseconds:void 0,nanoseconds:void 0},x=!1;for(let S of kde){let P=g[S];P!==void 0&&(x=!0,v[S]=Di(P))}if(!x)throw new TypeError("invalid duration-like");return v}(t);for(let m of kde){let g=r[m];g!==void 0&&(e[m]=g)}let{years:n,months:i,weeks:o,days:s,hours:a,minutes:d,seconds:u,milliseconds:c,microseconds:l,nanoseconds:p}=e;return dP(n,i,o,s,a,d,u,c,l,p),{years:n,months:i,weeks:o,days:s,hours:a,minutes:d,seconds:u,milliseconds:c,microseconds:l,nanoseconds:p}}function Yn(t){return t===void 0?"constrain":Xm(t,"overflow",["constrain","reject"],"constrain")}function V1(t){return t===void 0?"compatible":Xm(t,"disambiguation",["compatible","earlier","later","reject"],"compatible")}function Wu(t,e){return Xm(t,"roundingMode",["ceil","floor","expand","trunc","halfCeil","halfFloor","halfExpand","halfTrunc","halfEven"],e)}function iP(t,e){return t===void 0?e:Xm(t,"offset",["prefer","use","ignore","reject"],e)}function B6(t){return Xm(t,"calendarName",["auto","always","never","critical"],"auto")}function t2(t){let e=t.roundingIncrement;if(e===void 0)return 1;if(e=H1(e),!bs(e))throw new RangeError("roundingIncrement must be finite");let r=Xg(e);if(r<1||r>1e9)throw new RangeError(`roundingIncrement must be at least 1 and at most 1e9, not ${e}`);return r}function r2(t,e,r){let n=r?e:e-1;if(t>n)throw new RangeError(`roundingIncrement must be at least 1 and less than ${n}, not ${t}`);if(e%t!=0)throw new RangeError(`Rounding increment must divide evenly into ${e}`)}function M6(t){let e=t.fractionalSecondDigits;if(e===void 0)return"auto";if(typeof e!="number"){if(_s(e)!=="auto")throw new RangeError(`fractionalSecondDigits must be 'auto' or 0 through 9, not ${e}`);return"auto"}let r=Da(e);if(!bs(r)||r<0||r>9)throw new RangeError(`fractionalSecondDigits must be 'auto' or 0 through 9, not ${e}`);return r}function O6(t,e){switch(t){case"minute":return{precision:"minute",unit:"minute",increment:1};case"second":return{precision:0,unit:"second",increment:1};case"millisecond":return{precision:3,unit:"millisecond",increment:1};case"microsecond":return{precision:6,unit:"microsecond",increment:1};case"nanosecond":return{precision:9,unit:"nanosecond",increment:1}}switch(e){case"auto":return{precision:e,unit:"nanosecond",increment:1};case 0:return{precision:e,unit:"second",increment:1};case 1:case 2:case 3:return{precision:e,unit:"millisecond",increment:10**(3-e)};case 4:case 5:case 6:return{precision:e,unit:"microsecond",increment:10**(6-e)};case 7:case 8:case 9:return{precision:e,unit:"nanosecond",increment:10**(9-e)};default:throw new RangeError(`fractionalSecondDigits must be 'auto' or 0 through 9, not ${e}`)}}var nv=Symbol("~required~");function Ba(t,e,r,n,i=[]){let o=[];for(let[,u,c]of D6)r!=="datetime"&&r!==c||o.push(u);o.push(...i);let s=n;s===nv?s=void 0:s!==void 0&&o.push(s);let a=[...o];for(let u of o){let c=lqe.get(u);c!==void 0&&a.push(c)}let d=Xm(t,e,a,s);if(d===void 0&&n===nv)throw new RangeError(`${e} is required`);return rP.has(d)?rP.get(d):d}function GT(t){let e=t.relativeTo;if(e===void 0)return e;let r,n,i,o,s,a,d,u,c,l,p,m,g="option",v=!1;if(cn(e)){if(Ke(e)||Jt(e))return e;if(_t(e))return J1(e);l=N6(e);let x=oi(l,["day","hour","microsecond","millisecond","minute","month","monthCode","nanosecond","second","year"]);x.push("timeZone","offset");let S=Ct(e,x,[]),P=Ko(null);P.overflow="constrain",{year:r,month:n,day:i,hour:o,minute:s,second:a,millisecond:d,microsecond:u,nanosecond:c}=C6(l,S,P),m=S.offset,m===void 0&&(g="wall"),p=S.timeZone,p!==void 0&&(p=Lo(p))}else{let x,S;if({year:r,month:n,day:i,hour:o,minute:s,second:a,millisecond:d,microsecond:u,nanosecond:c,calendar:l,ianaName:x,offset:m,z:S}=hf(_s(e)),x)p=Lo(x),S?g="exact":m||(g="wall"),v=!0;else if(S)throw new RangeError("Z designator not supported for PlainDate relativeTo; either remove the Z or add a bracketed time zone");if(l||(l="iso8601"),!zh(l))throw new RangeError(`invalid calendar identifier ${l}`);l=uf(l)}return p===void 0?Gc(r,n,i,l):uo(sP(r,n,i,o,s,a,d,u,c,g,g==="option"?Jm(m):0,p,"compatible","reject",v),p,l)}function Kj(t,e,r,n,i,o,s,a,d,u){for(let[c,l]of[["years",t],["months",e],["weeks",r],["days",n],["hours",i],["minutes",o],["seconds",s],["milliseconds",a],["microseconds",d],["nanoseconds",u]])if(l!==0)return rP.get(c);return"nanosecond"}function iv(t,e){return Ide.indexOf(t)>Ide.indexOf(e)?e:t}function Ct(t,e,r,{emptySourceErrorMessage:n}={emptySourceErrorMessage:"no supported properties found"}){let i=Ko(null),o=!1;e.sort();for(let s of e){let a=t[s];if(a!==void 0)o=!0,Pde.has(s)&&(a=Pde.get(s)(a)),i[s]=a;else if(r!=="partial"){if(eqe.call(r,s))throw new TypeError(`required property '${s}' missing or undefined`);a=uqe.get(s),i[s]=a}}if(r==="partial"&&!o)throw new TypeError(n);return i}function oP(t,e="complete"){let r=["hour","microsecond","millisecond","minute","nanosecond","second"],n=Ct(t,r,"partial",{emptySourceErrorMessage:"invalid time-like"}),i={};for(let o of r){let s=oqe(n,o);s!==void 0?i[o]=s.value:e==="complete"&&(i[o]=0)}return i}function Lr(t,e){let r=t;if(cn(r)){if(Jt(r))return r;if(Ke(r)&&(Yn(e),r=oc(R(r,Nr),R(r,qo),R(r,fe))),_t(r))return Yn(e),Gc(R(r,De),R(r,Oe),R(r,je),R(r,fe));let d=N6(r);return Kh(d,Ct(r,oi(d,["day","month","monthCode","year"]),[]),e)}Yn(e);let{year:n,month:i,day:o,calendar:s,z:a}=function(u){return hf(u)}(_s(r));if(a)throw new RangeError("Z designator not supported for PlainDate");if(s||(s="iso8601"),!zh(s))throw new RangeError(`invalid calendar identifier ${s}`);return s=uf(s),Gc(n,i,o,s)}function C6(t,e,r){let{hour:n,minute:i,second:o,millisecond:s,microsecond:a,nanosecond:d}=oP(e),u=Yn(r),c=Kh(t,e,r),l=R(c,De),p=R(c,Oe),m=R(c,je);return{hour:n,minute:i,second:o,millisecond:s,microsecond:a,nanosecond:d}=yP(n,i,o,s,a,d,u),{year:l,month:p,day:m,hour:n,minute:i,second:o,millisecond:s,microsecond:a,nanosecond:d}}function Qg(t,e){let r,n,i,o,s,a,d,u,c,l;if(cn(t)){if(_t(t))return t;if(Ke(t))return Yn(e),oc(R(t,Nr),R(t,qo),R(t,fe));if(Jt(t))return Yn(e),ka(R(t,De),R(t,Oe),R(t,je),0,0,0,0,0,0,R(t,fe));l=N6(t);let p=Ct(t,oi(l,["day","hour","microsecond","millisecond","minute","month","monthCode","nanosecond","second","year"]),[]);({year:r,month:n,day:i,hour:o,minute:s,second:a,millisecond:d,microsecond:u,nanosecond:c}=C6(l,p,e))}else{let p;if(Yn(e),{year:r,month:n,day:i,hour:o,minute:s,second:a,millisecond:d,microsecond:u,nanosecond:c,calendar:l,z:p}=function(g){return hf(g)}(_s(t)),p)throw new RangeError("Z designator not supported for PlainDateTime");if(IN(r,n,i,o,s,a,d,u,c),l||(l="iso8601"),!zh(l))throw new RangeError(`invalid calendar identifier ${l}`);l=uf(l)}return ka(r,n,i,o,s,a,d,u,c,l)}function U1(t){if($n(t))return t;let{years:e,months:r,weeks:n,days:i,hours:o,minutes:s,seconds:a,milliseconds:d,microseconds:u,nanoseconds:c}=dv(t);return new(Ae("%Temporal.Duration%"))(e,r,n,i,o,s,a,d,u,c)}function zu(t){if(_i(t))return t;if(Ke(t))return new(Ae("%Temporal.Instant%"))(R(t,ut));let e=hqe(_s(t));return new(Ae("%Temporal.Instant%"))(e)}function Bde(t,e){let r=t;if(cn(r)){if(Ri(r))return r;let a,d;if(Bi(r,fe))a=R(r,fe),d=!1;else{let c=r.calendar;d=c===void 0,c===void 0&&(c="iso8601"),a=Ma(c)}let u=Ct(r,oi(a,["day","month","monthCode","year"]),[]);return d&&u.month!==void 0&&u.monthCode===void 0&&u.year===void 0&&(u.year=1972),G1(a,u,e)}Yn(e);let{month:n,day:i,referenceISOYear:o,calendar:s}=vN(_s(r));if(s===void 0&&(s="iso8601"),!zh(s))throw new RangeError(`invalid calendar identifier ${s}`);return s=uf(s),o===void 0?(df(1972,n,i),g6(n,i,s)):G1(s,g6(n,i,s,o))}function Nh(t,e="constrain"){let r,n,i,o,s,a,d=t;if(cn(d)){if(jn(d))return d;if(Ke(d)&&(d=oc(R(d,Nr),R(d,qo),R(d,fe))),_t(d))return new(Ae("%Temporal.PlainTime%"))(R(d,St),R(d,At),R(d,Tt),R(d,Pt),R(d,It),R(d,kt));({hour:r,minute:n,second:i,millisecond:o,microsecond:s,nanosecond:a}=oP(d)),{hour:r,minute:n,second:i,millisecond:o,microsecond:s,nanosecond:a}=yP(r,n,i,o,s,a,e)}else({hour:r,minute:n,second:i,millisecond:o,microsecond:s,nanosecond:a}=function(c){let l=JUe.exec(c),p,m,g,v,x,S,P;if(l){p=ii(l[1]),m=ii(l[2]||l[5]),g=ii(l[3]||l[6]),g===60&&(g=59);let A=(l[4]||l[7])+"000000000";v=ii(A.slice(0,3)),x=ii(A.slice(3,6)),S=ii(A.slice(6,9)),P=l[14];for(let[,$,j,L]of P.matchAll(ty))if(j!=="u-ca"&&$==="!")throw new RangeError(`Unrecognized annotation: !${j}=${L}`);if(l[8])throw new RangeError("Z designator not supported for PlainTime")}else{let A,$;if({hasTime:$,hour:p,minute:m,second:g,millisecond:v,microsecond:x,nanosecond:S,z:A}=hf(c),!$)throw new RangeError(`time is missing in string: ${c}`);if(A)throw new RangeError("Z designator not supported for PlainTime")}if(/[tT ][0-9][0-9]/.test(c))return{hour:p,minute:m,second:g,millisecond:v,microsecond:x,nanosecond:S};try{let{month:A,day:$}=vN(c);df(1972,A,$)}catch{try{let{year:A,month:$}=gN(c);df(A,$,1)}catch{return{hour:p,minute:m,second:g,millisecond:v,microsecond:x,nanosecond:S}}}throw new RangeError(`invalid ISO 8601 time-only string ${c}; may need a T prefix`)}(_s(d))),kP(r,n,i,o,s,a);return new(Ae("%Temporal.PlainTime%"))(r,n,i,o,s,a)}function f6(t,e){if(cn(t)){if(Sr(t))return t;let s=N6(t);return sv(s,Ct(t,oi(s,["month","monthCode","year"]),[]),e)}Yn(e);let{year:r,month:n,referenceISODay:i,calendar:o}=gN(_s(t));if(o===void 0&&(o="iso8601"),!zh(o))throw new RangeError(`invalid calendar identifier ${o}`);return o=uf(o),i===void 0?(df(r,n,1),v6(r,n,o)):sv(o,v6(r,n,o,i))}function sP(t,e,r,n,i,o,s,a,d,u,c,l,p,m,g){let v=new(Ae("%Temporal.PlainDateTime%"))(t,e,r,n,i,o,s,a,d);if(u==="wall"||m==="ignore")return R(ws(l,v,p),ut);if(u==="exact"||m==="use"){let S=Zm(t,e,r,n,i,o,s,a,d);if(S===null)throw new RangeError("ZonedDateTime outside of supported range");return z.default.subtract(S,z.default.BigInt(c))}let x=aP(l,v);for(let S of x){let P=Hu(l,S),A=z.default.toNumber(ic(z.default.BigInt(P),yue,"halfExpand"));if(P===c||g&&A===c)return R(S,ut)}if(m==="reject"){let S=PP(c),P=zc(l)?R(l,nf):"time zone";throw new RangeError(`Offset ${S} is invalid for ${v.toString()} in ${P}`)}return R(Iue(x,l,v,p),ut)}function h6(t,e){let r,n,i,o,s,a,d,u,c,l,p,m,g,v,x=!1,S="option";if(cn(t)){if(Ke(t))return t;m=N6(t);let A=oi(m,["day","hour","microsecond","millisecond","minute","month","monthCode","nanosecond","second","year"]);A.push("timeZone","offset");let $=Ct(t,A,["timeZone"]);l=Lo($.timeZone),p=$.offset,p===void 0&&(S="wall"),g=V1(e),v=iP(e,"reject"),{year:r,month:n,day:i,hour:o,minute:s,second:a,millisecond:d,microsecond:u,nanosecond:c}=C6(m,$,e)}else{let A,$;if({year:r,month:n,day:i,hour:o,minute:s,second:a,millisecond:d,microsecond:u,nanosecond:c,ianaName:A,offset:p,z:$,calendar:m}=function(L){let F=hf(L);if(!F.ianaName)throw new RangeError("Temporal.ZonedDateTime requires a time zone ID in brackets");return F}(_s(t)),l=Lo(A),$?S="exact":p||(S="wall"),m||(m="iso8601"),!zh(m))throw new RangeError(`invalid calendar identifier ${m}`);m=uf(m),x=!0,g=V1(e),v=iP(e,"reject"),Yn(e)}let P=0;return S==="option"&&(P=Jm(p)),uo(sP(r,n,i,o,s,a,d,u,c,S,P,l,g,v,x),l,m)}function wue(t,e,r,n,i){df(e,r,n),jue(e,r,n),ff(t),Mt(t,De,e),Mt(t,Oe,r),Mt(t,je,n),Mt(t,fe,i),Mt(t,iue,!0)}function Gc(t,e,r,n="iso8601"){let i=Ae("%Temporal.PlainDate%"),o=Ko(i.prototype);return wue(o,t,e,r,n),o}function _ue(t,e,r,n,i,o,s,a,d,u,c){IN(e,r,n,i,o,s,a,d,u),Nue(e,r,n,i,o,s,a,d,u),ff(t),Mt(t,De,e),Mt(t,Oe,r),Mt(t,je,n),Mt(t,St,i),Mt(t,At,o),Mt(t,Tt,s),Mt(t,Pt,a),Mt(t,It,d),Mt(t,kt,u),Mt(t,fe,c)}function ka(t,e,r,n,i,o,s,a,d,u="iso8601"){let c=Ae("%Temporal.PlainDateTime%"),l=Ko(c.prototype);return _ue(l,t,e,r,n,i,o,s,a,d,u),l}function xue(t,e,r,n,i){df(i,e,r),jue(i,e,r),ff(t),Mt(t,Oe,e),Mt(t,je,r),Mt(t,De,i),Mt(t,fe,n),Mt(t,sue,!0)}function g6(t,e,r="iso8601",n=1972){let i=Ae("%Temporal.PlainMonthDay%"),o=Ko(i.prototype);return xue(o,t,e,r,n),o}function Eue(t,e,r,n,i){df(e,r,i),function(s,a){fo(s,QT,eP),s===QT?fo(a,4,12):s===eP&&fo(a,1,9)}(e,r),ff(t),Mt(t,De,e),Mt(t,Oe,r),Mt(t,je,i),Mt(t,fe,n),Mt(t,oue,!0)}function v6(t,e,r="iso8601",n=1){let i=Ae("%Temporal.PlainYearMonth%"),o=Ko(i.prototype);return Eue(o,t,e,r,n),o}function Sue(t,e,r,n){Yg(e),ff(t),Mt(t,ut,e),Mt(t,Nr,r),Mt(t,fe,n);let i=new(Ae("%Temporal.Instant%"))(R(t,ut));Mt(t,qo,i)}function uo(t,e,r="iso8601"){let n=Ae("%Temporal.ZonedDateTime%"),i=Ko(n.prototype);return Sue(i,t,e,r),i}function oi(t,e){if(typeof t=="string"){let i=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.fields%"),i,[e])}let r=Ge(kr(t,"fields"),t,[e]),n=[];for(let i of r){if(typeof i!="string")throw new TypeError("bad return from calendar.fields()");fue.call(n,i)}return n}function ov(t,e,r){if(typeof t=="string"){let i=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.mergeFields%"),i,[e,r])}let n=Ge(kr(t,"mergeFields"),t,[e,r]);if(!cn(n))throw new TypeError("bad return from calendar.mergeFields()");return n}function lo(t,e,r,n,i){let o=i;if(typeof t=="string"){let a=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.dateAdd%"),a,[e,r,n])}o===void 0&&(o=kr(t,"dateAdd"));let s=mP(o,t,[e,r,n]);if(!Jt(s))throw new TypeError("invalid result");return s}function Gm(t,e,r,n,i){let o=i;if(typeof t=="string"){let a=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.dateUntil%"),a,[e,r,n])}o===void 0&&(o=kr(t,"dateUntil"));let s=mP(o,t,[e,r,n]);if(!$n(s))throw new TypeError("invalid result");return s}function gP(t,e){if(typeof t=="string"){let n=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.year%"),n,[e])}let r=Ge(kr(t,"year"),t,[e]);if(typeof r!="number")throw new TypeError("calendar year result must be an integer");if(!sc(r))throw new RangeError("calendar year result must be an integer");return r}function vP(t,e){if(typeof t=="string"){let n=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.month%"),n,[e])}let r=Ge(kr(t,"month"),t,[e]);if(typeof r!="number")throw new TypeError("calendar month result must be a positive integer");if(!sc(r)||r<1)throw new RangeError("calendar month result must be a positive integer");return r}function $6(t,e){if(typeof t=="string"){let n=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.monthCode%"),n,[e])}let r=Ge(kr(t,"monthCode"),t,[e]);if(typeof r!="string")throw new TypeError("calendar monthCode result must be a string");return r}function j6(t,e){if(typeof t=="string"){let n=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.day%"),n,[e])}let r=Ge(kr(t,"day"),t,[e]);if(typeof r!="number")throw new TypeError("calendar day result must be a positive integer");if(!sc(r)||r<1)throw new RangeError("calendar day result must be a positive integer");return r}function bP(t,e){if(typeof t=="string"){let n=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.era%"),n,[e])}let r=Ge(kr(t,"era"),t,[e]);if(r===void 0)return r;if(typeof r!="string")throw new TypeError("calendar era result must be a string or undefined");return r}function wP(t,e){if(typeof t=="string"){let n=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.eraYear%"),n,[e])}let r=Ge(kr(t,"eraYear"),t,[e]);if(r===void 0)return r;if(typeof r!="number")throw new TypeError("calendar eraYear result must be an integer or undefined");if(!sc(r))throw new RangeError("calendar eraYear result must be an integer or undefined");return r}function bN(t,e){if(typeof t=="string"){let n=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.dayOfWeek%"),n,[e])}let r=Ge(kr(t,"dayOfWeek"),t,[e]);if(typeof r!="number")throw new TypeError("calendar dayOfWeek result must be a positive integer");if(!sc(r)||r<1)throw new RangeError("calendar dayOfWeek result must be a positive integer");return r}function wN(t,e){if(typeof t=="string"){let n=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.dayOfYear%"),n,[e])}let r=Ge(kr(t,"dayOfYear"),t,[e]);if(typeof r!="number")throw new TypeError("calendar dayOfYear result must be a positive integer");if(!sc(r)||r<1)throw new RangeError("calendar dayOfYear result must be a positive integer");return r}function _N(t,e){if(typeof t=="string"){let n=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.weekOfYear%"),n,[e])}let r=Ge(kr(t,"weekOfYear"),t,[e]);if(typeof r!="number")throw new TypeError("calendar weekOfYear result must be a positive integer");if(!sc(r)||r<1)throw new RangeError("calendar weekOfYear result must be a positive integer");return r}function xN(t,e){if(typeof t=="string"){let n=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.yearOfWeek%"),n,[e])}let r=Ge(kr(t,"yearOfWeek"),t,[e]);if(typeof r!="number")throw new TypeError("calendar yearOfWeek result must be an integer");if(!sc(r))throw new RangeError("calendar yearOfWeek result must be an integer");return r}function EN(t,e){if(typeof t=="string"){let n=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.daysInWeek%"),n,[e])}let r=Ge(kr(t,"daysInWeek"),t,[e]);if(typeof r!="number")throw new TypeError("calendar daysInWeek result must be a positive integer");if(!sc(r)||r<1)throw new RangeError("calendar daysInWeek result must be a positive integer");return r}function _P(t,e){if(typeof t=="string"){let n=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.daysInMonth%"),n,[e])}let r=Ge(kr(t,"daysInMonth"),t,[e]);if(typeof r!="number")throw new TypeError("calendar daysInMonth result must be a positive integer");if(!sc(r)||r<1)throw new RangeError("calendar daysInMonth result must be a positive integer");return r}function xP(t,e){if(typeof t=="string"){let n=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.daysInYear%"),n,[e])}let r=Ge(kr(t,"daysInYear"),t,[e]);if(typeof r!="number")throw new TypeError("calendar daysInYear result must be a positive integer");if(!sc(r)||r<1)throw new RangeError("calendar daysInYear result must be a positive integer");return r}function EP(t,e){if(typeof t=="string"){let n=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.monthsInYear%"),n,[e])}let r=Ge(kr(t,"monthsInYear"),t,[e]);if(typeof r!="number")throw new TypeError("calendar monthsInYear result must be a positive integer");if(!sc(r)||r<1)throw new RangeError("calendar monthsInYear result must be a positive integer");return r}function SP(t,e){if(typeof t=="string"){let n=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.inLeapYear%"),n,[e])}let r=Ge(kr(t,"inLeapYear"),t,[e]);if(typeof r!="boolean")throw new TypeError("calendar inLeapYear result must be a boolean");return r}function Ma(t){if(cn(t)){if(Bi(t,fe))return R(t,fe);if(!function(i){return!!Cn(i)||"dateAdd"in i&&"dateFromFields"in i&&"dateUntil"in i&&"day"in i&&"dayOfWeek"in i&&"dayOfYear"in i&&"daysInMonth"in i&&"daysInWeek"in i&&"daysInYear"in i&&"fields"in i&&"id"in i&&"inLeapYear"in i&&"mergeFields"in i&&"month"in i&&"monthCode"in i&&"monthDayFromFields"in i&&"monthsInYear"in i&&"weekOfYear"in i&&"year"in i&&"yearMonthFromFields"in i&&"yearOfWeek"in i}(t))throw new TypeError("expected a Temporal.Calendar or object implementing the Temporal.Calendar protocol");return t}let e=_s(t);if(zh(e))return uf(e);let r;try{({calendar:r}=hf(e))}catch{try{({calendar:r}=gN(e))}catch{({calendar:r}=vN(e))}}if(r||(r="iso8601"),!zh(r))throw new RangeError(`invalid calendar identifier ${r}`);return uf(r)}function N6(t){if(Bi(t,fe))return R(t,fe);let{calendar:e}=t;return e===void 0?"iso8601":Ma(e)}function ho(t){if(typeof t=="string")return t;let e=t.id;if(typeof e!="string")throw new TypeError("calendar.id should be a string");return e}function n2(t){return cn(t)?t:new(Ae("%Temporal.Calendar%"))(t)}function U6(t,e){return t===e?!0:ho(t)===ho(e)}function AP(t,e,r){if(t===e)return;let n=ho(t),i=ho(e);if(n!==i)throw new RangeError(`cannot ${r} of ${n} and ${i} calendars`)}function Aue(t,e){if(t===e)return e;let r=ho(t),n=ho(e);if(r===n||r==="iso8601")return e;if(n==="iso8601")return t;throw new RangeError("irreconcilable calendars")}function Kh(t,e,r,n){if(typeof t=="string"){let o=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.dateFromFields%"),o,[e,r])}let i=Ge(n??kr(t,"dateFromFields"),t,[e,r]);if(!Jt(i))throw new TypeError("invalid result");return i}function sv(t,e,r){if(typeof t=="string"){let i=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.yearMonthFromFields%"),i,[e,r])}let n=Ge(kr(t,"yearMonthFromFields"),t,[e,r]);if(!Sr(n))throw new TypeError("invalid result");return n}function G1(t,e,r){if(typeof t=="string"){let i=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.monthDayFromFields%"),i,[e,r])}let n=Ge(kr(t,"monthDayFromFields"),t,[e,r]);if(!Ri(n))throw new TypeError("invalid result");return n}function Lo(t){if(cn(t)){if(Ke(t))return R(t,Nr);if(!function(r){return!!zc(r)||"getOffsetNanosecondsFor"in r&&"getPossibleInstantsFor"in r&&"id"in r}(t))throw new TypeError("expected a Temporal.TimeZone or object implementing the Temporal.TimeZone protocol");return t}return fqe(_s(t))}function b6(t){if(typeof t=="string")return t;let e=t.id;if(typeof e!="string")throw new TypeError("timeZone.id should be a string");return e}function Tue(t){return cn(t)?t:new(Ae("%Temporal.TimeZone%"))(t)}function Pue(t,e){return t===e?!0:b6(t)===b6(e)}function J1(t){return Gc(R(t,De),R(t,Oe),R(t,je),R(t,fe))}function SN(t){return new(Ae("%Temporal.PlainTime%"))(R(t,St),R(t,At),R(t,Tt),R(t,Pt),R(t,It),R(t,kt))}function Hu(t,e,r){if(typeof t=="string"){let i=new(Ae("%Temporal.TimeZone%"))(t);return Ge(Ae("%Temporal.TimeZone.prototype.getOffsetNanosecondsFor%"),i,[e])}let n=Ge(r??kr(t,"getOffsetNanosecondsFor"),t,[e]);if(typeof n!="number")throw new TypeError("bad return from getOffsetNanosecondsFor");if(!sc(n)||an(n)>=864e11)throw new RangeError("out-of-range return from getOffsetNanosecondsFor");return n}function Fj(t,e){return PP(Hu(t,e))}function oc(t,e,r){let n=R(e,ut),i=Hu(t,e),{year:o,month:s,day:a,hour:d,minute:u,second:c,millisecond:l,microsecond:p,nanosecond:m}=Rue(n);return{year:o,month:s,day:a,hour:d,minute:u,second:c,millisecond:l,microsecond:p,nanosecond:m}=TN(o,s,a,d,u,c,l,p,m+i),ka(o,s,a,d,u,c,l,p,m,r)}function ws(t,e,r){return Iue(aP(t,e),t,e,r)}function Iue(t,e,r,n){let i=Ae("%Temporal.Instant%"),o=t.length;if(o===1)return t[0];if(o)switch(n){case"compatible":case"earlier":return t[0];case"later":return t[o-1];case"reject":throw new RangeError("multiple instants found")}let s=R(r,De),a=R(r,Oe),d=R(r,je),u=R(r,St),c=R(r,At),l=R(r,Tt),p=R(r,Pt),m=R(r,It),g=R(r,kt),v=Zm(s,a,d,u,c,l,p,m,g);if(v===null)throw new RangeError("DateTime outside of supported range");let x=new i(z.default.subtract(v,cf)),S=new i(z.default.add(v,cf)),P=Hu(e,x),A=Hu(e,S)-P;switch(n){case"earlier":{let $=R(r,fe),j=Ae("%Temporal.PlainDateTime%"),L=Vj(s,a,d,u,c,l,p,m,g,$,0,0,0,0,0,0,0,0,0,-A,void 0);return aP(e,new j(L.year,L.month,L.day,L.hour,L.minute,L.second,L.millisecond,L.microsecond,L.nanosecond,$))[0]}case"compatible":case"later":{let $=R(r,fe),j=Ae("%Temporal.PlainDateTime%"),L=Vj(s,a,d,u,c,l,p,m,g,$,0,0,0,0,0,0,0,0,0,A,void 0),F=aP(e,new j(L.year,L.month,L.day,L.hour,L.minute,L.second,L.millisecond,L.microsecond,L.nanosecond,$));return F[F.length-1]}case"reject":throw new RangeError("no such instant found")}}function aP(t,e,r){if(typeof t=="string"){let o=new(Ae("%Temporal.TimeZone%"))(t);return Ge(Ae("%Temporal.TimeZone.prototype.getPossibleInstantsFor%"),o,[e])}let n=Ge(r??kr(t,"getPossibleInstantsFor"),t,[e]),i=[];for(let o of n){if(!_i(o))throw new TypeError("bad return from getPossibleInstantsFor");fue.call(i,o)}return i}function uv(t){let e;return t<0||t>9999?e=(t<0?"-":"+")+`000000${an(t)}`.slice(-6):e=`0000${t}`.slice(-4),e}function bn(t){return`00${t}`.slice(-2)}function TP(t,e,r,n,i){if(i==="minute")return"";let o=`:${bn(t)}`,s,a=1e6*e+1e3*r+n;if(i==="auto"){if(a===0)return o;for(s=`${a}`.padStart(9,"0");s[s.length-1]==="0";)s=s.slice(0,-1)}else{if(i===0)return o;s=`${a}`.padStart(9,"0").slice(0,i)}return`${o}.${s}`}function Mde(t,e,r){let n=e;n===void 0&&(n="UTC");let i=oc(n,t,"iso8601"),o=uv(R(i,De)),s=bn(R(i,Oe)),a=bn(R(i,je)),d=bn(R(i,St)),u=bn(R(i,At)),c=TP(R(i,Tt),R(i,Pt),R(i,It),R(i,kt),r),l="Z";return e!==void 0&&(l=kue(Hu(n,t))),`${o}-${s}-${a}T${d}:${u}${c}${l}`}function Mj(t,e="auto",r){function n(W){return W<=iqe?W.toString(10):z.default.BigInt(W).toString(10)}let i=R(t,ls),o=R(t,Gi),s=R(t,ia),a=R(t,fs),d=R(t,hs),u=R(t,ps),c=R(t,ms),l=R(t,ys),p=R(t,gs),m=R(t,vs),g=af(i,o,s,a,d,u,c,l,p,m);if(r){let{unit:W,increment:q,roundingMode:I}=r;({seconds:c,milliseconds:l,microseconds:p,nanoseconds:m}=Fh(0,0,0,0,0,0,c,l,p,m,q,W,I))}let v=[];i&&v.push(`${n(an(i))}Y`),o&&v.push(`${n(an(o))}M`),s&&v.push(`${n(an(s))}W`),a&&v.push(`${n(an(a))}D`);let x=[];d&&x.push(`${n(an(d))}H`),u&&x.push(`${n(an(u))}M`);let S=[],P,A,$,j,L=Z1(0,0,0,c,l,p,m,0);({quotient:L,remainder:P}=Zn(L,Ar)),{quotient:L,remainder:A}=Zn(L,Ar),{quotient:j,remainder:$}=Zn(L,Ar);let F=1e6*an(z.default.toNumber($))+1e3*an(z.default.toNumber(A))+an(z.default.toNumber(P)),K;if(e==="auto"){if(F!==0)for(K=`${F}`.padStart(9,"0");K[K.length-1]==="0";)K=K.slice(0,-1)}else e!==0&&(K=`${F}`.padStart(9,"0").slice(0,e));return K&&S.unshift(".",K),z.default.equal(j,Nn)&&!S.length&&e==="auto"||S.unshift(Fu(j).toString()),S.length&&x.push(`${S.join("")}S`),x.length&&x.unshift("T"),v.length||x.length?`${g<0?"-":""}P${v.join("")}${x.join("")}`:"PT0S"}function Ode(t,e="auto"){return`${uv(R(t,De))}-${bn(R(t,Oe))}-${bn(R(t,je))}${mN(R(t,fe),e)}`}function Cde(t,e,r="auto",n){let i=R(t,De),o=R(t,Oe),s=R(t,je),a=R(t,St),d=R(t,At),u=R(t,Tt),c=R(t,Pt),l=R(t,It),p=R(t,kt);if(n){let{unit:m,increment:g,roundingMode:v}=n;({year:i,month:o,day:s,hour:a,minute:d,second:u,millisecond:c,microsecond:l,nanosecond:p}=BN(i,o,s,a,d,u,c,l,p,g,m,v))}return`${uv(i)}-${bn(o)}-${bn(s)}T${bn(a)}:${bn(d)}${TP(u,c,l,p,e)}${mN(R(t,fe),r)}`}function $de(t,e="auto"){let r=`${bn(R(t,Oe))}-${bn(R(t,je))}`,n=ho(R(t,fe));(e==="always"||e==="critical"||n!=="iso8601")&&(r=`${uv(R(t,De))}-${r}`);let i=yN(n,e);return i&&(r+=i),r}function jde(t,e="auto"){let r=`${uv(R(t,De))}-${bn(R(t,Oe))}`,n=ho(R(t,fe));(e==="always"||e==="critical"||n!=="iso8601")&&(r+=`-${bn(R(t,je))}`);let i=yN(n,e);return i&&(r+=i),r}function Nde(t,e,r="auto",n="auto",i="auto",o){let s=R(t,qo);if(o){let{unit:c,increment:l,roundingMode:p}=o,m=uP(R(t,ut),l,c,p);s=new(Ae("%Temporal.Instant%"))(m)}let a=R(t,Nr),d=oc(a,s,"iso8601"),u=`${uv(R(d,De))}-${bn(R(d,Oe))}-${bn(R(d,je))}T${bn(R(d,St))}:${bn(R(d,At))}${TP(R(d,Tt),R(d,Pt),R(d,It),R(d,kt),e)}`;return i!=="never"&&(u+=kue(Hu(a,s))),n!=="never"&&(u+=`[${n==="critical"?"!":""}${b6(a)}]`),u+=mN(R(t,fe),r),u}function $1(t){return Wue.test(R6(t))}function Jm(t){let e=Wue.exec(R6(t));if(!e)throw new RangeError(`invalid time zone offset: ${t}`);return(e[1]==="-"||e[1]==="\u2212"?-1:1)*(1e9*(60*(60*+e[2]+ +(e[3]||0))+ +(e[4]||0))+ +((e[5]||0)+"000000000").slice(0,9))}function AN(t){return $1(t)?PP(Jm(t)):bue(R6(t)).resolvedOptions().timeZone}function Uh(t,e){let{year:r,month:n,day:i,hour:o,minute:s,second:a,millisecond:d,microsecond:u,nanosecond:c}=Due(t,e),l=r%400,p=(r-l)/400,m=z.default.multiply(z.default.BigInt(146097),cf),g=Zm(l,n,i,o,s,a,d,u,c),v=z.default.add(g,z.default.multiply(m,z.default.BigInt(p)));return z.default.toNumber(z.default.subtract(v,e))}function PP(t){let e=t<0?"-":"+",r=an(t),n=r%1e9,i=Da(r/1e9)%60,o=Da(r/6e10)%60,s=bn(Da(r/36e11)),a=bn(o),d=bn(i),u="";if(n){let c=`${n}`.padStart(9,"0");for(;c[c.length-1]==="0";)c=c.slice(0,-1);u=`:${d}.${c}`}else i&&(u=`:${d}`);return`${e}${s}:${a}${u}`}function kue(t){let e=z.default.toNumber(ic(z.default.BigInt(t),yue,"halfExpand")),r=e<0?"-":"+";e=an(e);let n=e/6e10%60;return`${r}${bn(Da(e/36e11))}:${bn(n)}`}function Zm(t,e,r,n,i,o,s,a,d){let u=new Date;u.setUTCHours(n,i,o,s),u.setUTCFullYear(t,e-1,r);let c=u.getTime();if(pP(c))return null;let l=z.default.multiply(z.default.BigInt(c),Hc);return l=z.default.add(l,z.default.multiply(z.default.BigInt(a),Ar)),l=z.default.add(l,z.default.BigInt(d)),z.default.lessThan(l,y6)||z.default.greaterThan(l,W1)?null:l}function Rue(t){let{quotient:e,remainder:r}=Zn(t,Hc),n=z.default.toNumber(e),i=z.default.toNumber(r);i<0&&(i+=1e6,n-=1);let o=Da(i/1e3)%1e3,s=i%1e3,a=new Date(n);return{epochMilliseconds:n,year:a.getUTCFullYear(),month:a.getUTCMonth()+1,day:a.getUTCDate(),hour:a.getUTCHours(),minute:a.getUTCMinutes(),second:a.getUTCSeconds(),millisecond:a.getUTCMilliseconds(),microsecond:o,nanosecond:s}}function Due(t,e){let{epochMilliseconds:r,millisecond:n,microsecond:i,nanosecond:o}=Rue(e),{year:s,month:a,day:d,hour:u,minute:c,second:l}=function(m,g){let v=bue(m).format(new Date(g));return function(S){let P=S.split(/[^\w]+/);if(P.length!==7)throw new RangeError(`expected 7 parts in "${S}`);let A=+P[0],$=+P[1],j=+P[2],L=P[3].toUpperCase();if(L==="B"||L==="BC")j=1-j;else if(L!=="A"&&L!=="AD")throw new RangeError(`Unknown era ${L} in "${S}`);let F=+P[4];F===24&&(F=0);let K=+P[5],W=+P[6];if(!(bs(j)&&bs(A)&&bs($)&&bs(F)&&bs(K)&&bs(W)))throw new RangeError(`Invalid number in "${S}`);return{year:j,month:A,day:$,hour:F,minute:K,second:W}}(v)}(t,r);return TN(s,a,d,u,c,l,n,i,o)}function Ude(t,e){return z.default.lessThan(t,e)?e:t}function Bue(){return z.default.add(ON(),cqe)}function Mue(t,e){if(z.default.lessThan(e,j1))return Mue(t,j1);let r=z.default.add(e,gue),n=Ude(Bue(),r),i=Ude(j1,e),o=Uh(t,i),s=i,a=o;for(;o===a&&z.default.lessThan(z.default.BigInt(i),n);){if(s=z.default.add(i,vue),z.default.greaterThan(s,W1))return null;a=Uh(t,s),o===a&&(i=s)}return o===a?null:Hue(d=>Uh(t,d),i,s,o,a)}function zj(t,e){let r=Bue(),n=z.default.greaterThan(e,r),i=n?z.default.subtract(e,gue):j1;if(t==="Africa/Casablanca"||t==="Africa/El_Aaiun"){let u=R(zu("2088-01-01T00Z"),ut);if(z.default.lessThan(u,e))return zj(t,u)}let o=z.default.subtract(e,Q1);if(z.default.lessThan(o,j1))return null;let s=Uh(t,o),a=o,d=s;for(;s===d&&z.default.greaterThan(o,i);){if(a=z.default.subtract(o,vue),z.default.lessThan(a,j1))return null;d=Uh(t,a),s===d&&(o=a)}if(s===d){if(n){let u=z.default.subtract(r,cf);return zj(t,u)}return null}return Hue(u=>Uh(t,u),a,o,d,s)}function Ym(t){return t===void 0?!1:t%4==0&&(t%100!=0||t%400==0)}function qh(t,e){return{standard:[31,28,31,30,31,30,31,31,30,31,30,31],leapyear:[31,29,31,30,31,30,31,31,30,31,30,31]}[Ym(t)?"leapyear":"standard"][e-1]}function Wj(t,e,r){let n=e+(e<3?10:-2),i=t-(e<3?1:0),o=Da(i/100),s=i-100*o,a=(r+Da(2.6*n-.2)+(s+Da(s/4))+(Da(o/4)-2*o))%7;return a+(a<=0?7:0)}function cP(t,e,r){let n=r;for(let i=e-1;i>0;i--)n+=qh(t,i);return n}function qde(t,e,r){let n=cP(t,e,r),i=Wj(t,e,r)||7,o=Wj(t,1,1),s=Da((n-i+10)/7);return s<1?o===5||o===6&&Ym(t-1)?{week:53,year:t-1}:{week:52,year:t-1}:s===53&&(Ym(t)?366:365)-n<4-i?{week:1,year:t+1}:{week:s,year:t}}function af(t,e,r,n,i,o,s,a,d,u){for(let c of[t,e,r,n,i,o,s,a,d,u])if(c!==0)return c<0?-1:1;return 0}function JT(t,e){let r=t,n=e;if(!bs(r)||!bs(n))throw new RangeError("infinity is out of range");return n-=1,r+=Da(n/12),n%=12,n<0&&(n+=12),n+=1,{year:r,month:n}}function IP(t,e,r){let n=t,i=e,o=r;if(!bs(o))throw new RangeError("infinity is out of range");({year:n,month:i}=JT(n,i));let s=146097;if(an(o)>s){let u=Xg(o/s);n+=400*u,o-=u*s}let a=0,d=i>2?n:n-1;for(;a=Ym(d)?366:365,o<-a;)n-=1,d-=1,o+=a;for(d+=1;a=Ym(d)?366:365,o>a;)n+=1,d+=1,o-=a;for(;o<1;)({year:n,month:i}=JT(n,i-1)),o+=qh(n,i);for(;o>qh(n,i);)o-=qh(n,i),{year:n,month:i}=JT(n,i+1);return{year:n,month:i,day:o}}function TN(t,e,r,n,i,o,s,a,d){let{deltaDays:u,hour:c,minute:l,second:p,millisecond:m,microsecond:g,nanosecond:v}=jh(n,i,o,s,a,d),{year:x,month:S,day:P}=IP(t,e,r+u);return{year:x,month:S,day:P,hour:c,minute:l,second:p,millisecond:m,microsecond:g,nanosecond:v}}function jh(t,e,r,n,i,o){let s,a=z.default.BigInt(t),d=z.default.BigInt(e),u=z.default.BigInt(r),c=z.default.BigInt(n),l=z.default.BigInt(i),p=z.default.BigInt(o);return{quotient:s,remainder:p}=Zg(p,Ar),l=z.default.add(l,s),{quotient:s,remainder:l}=Zg(l,Ar),c=z.default.add(c,s),{quotient:s,remainder:c}=Zg(c,Ar),u=z.default.add(u,s),{quotient:s,remainder:u}=Zg(u,of),d=z.default.add(d,s),{quotient:s,remainder:d}=Zg(d,of),a=z.default.add(a,s),{quotient:s,remainder:a}=Zg(a,pue),{deltaDays:z.default.toNumber(s),hour:z.default.toNumber(a),minute:z.default.toNumber(d),second:z.default.toNumber(u),millisecond:z.default.toNumber(c),microsecond:z.default.toNumber(l),nanosecond:z.default.toNumber(p)}}function Z1(t,e,r,n,i,o,s,a){let d=z.default.BigInt(t),u=z.default.BigInt(s);t!==0&&(u=z.default.subtract(z.default.BigInt(s),z.default.BigInt(a)));let c=z.default.add(z.default.BigInt(e),z.default.multiply(d,z.default.BigInt(24))),l=z.default.add(z.default.BigInt(r),z.default.multiply(c,of)),p=z.default.add(z.default.BigInt(n),z.default.multiply(l,of)),m=z.default.add(z.default.BigInt(i),z.default.multiply(p,Ar)),g=z.default.add(z.default.BigInt(o),z.default.multiply(m,Ar));return z.default.add(z.default.BigInt(u),z.default.multiply(g,Ar))}function PN(t,e){let r=Ae("%Temporal.Instant%"),n=z1(z.default.toNumber(t)),i=z.default.BigInt(t),o=864e11;if(n===0)return{days:0,nanoseconds:Nn,dayLengthNs:o};if(!Ke(e)){let A;return{quotient:A,remainder:i}=Zn(i,z.default.BigInt(o)),{days:z.default.toNumber(A),nanoseconds:i,dayLengthNs:o}}let s=R(e,ut),a=R(e,qo),d=z.default.add(s,i),u=new r(d),c=R(e,Nr),l=R(e,fe),p=oc(c,a,l),m=oc(c,u,l),{days:g}=DN(R(p,De),R(p,Oe),R(p,je),R(p,St),R(p,At),R(p,Tt),R(p,Pt),R(p,It),R(p,kt),R(m,De),R(m,Oe),R(m,je),R(m,St),R(m,At),R(m,Tt),R(m,Pt),R(m,It),R(m,kt),l,"day",Ko(null)),v=Vc(a,c,l,0,0,0,g,0,0,0,0,0,0),x=z.default.BigInt(g);if(n===1)for(;z.default.greaterThan(x,Nn)&&z.default.greaterThan(v,d);)x=z.default.subtract(x,Q1),v=Vc(a,c,l,0,0,0,z.default.toNumber(x),0,0,0,0,0,0);i=z.default.subtract(d,v);let S=!1,P=new r(v);do{let A=Vc(P,c,l,0,0,0,n,0,0,0,0,0,0),$=R(P,ut);o=z.default.toNumber(z.default.subtract(A,$)),S=z.default.greaterThanOrEqual(z.default.multiply(z.default.subtract(i,z.default.BigInt(o)),z.default.BigInt(n)),Nn),S&&(i=z.default.subtract(i,z.default.BigInt(o)),P=new r(A),x=z.default.add(x,z.default.BigInt(n)))}while(S);if(!Wc(x)&&Tde(x)!==n)throw new RangeError("Time zone or calendar converted nanoseconds into a number of days with the opposite sign");if(!Wc(i)&&Tde(i)!==n)throw tP(i)&&n===1?new Error("assert not reached"):new RangeError("Time zone or calendar ended up with a remainder of nanoseconds with the opposite sign");if(z.default.greaterThanOrEqual(Fu(i),Fu(z.default.BigInt(o))))throw new Error("assert not reached");return{days:z.default.toNumber(x),nanoseconds:i,dayLengthNs:an(o)}}function qd(t,e,r,n,i,o,s,a,d){let u=Oue(t,e,r,n,i,o,s,a,d);if(u==="positive overflow"||u==="negative overflow")throw new RangeError("Duration out of range");return u}function Oue(t,e,r,n,i,o,s,a,d){let u,c,l,p,m,g,v=t;if(Ke(d)){let F=Vc(R(d,qo),R(d,Nr),R(d,fe),0,0,0,v,e,r,n,i,o,s),K=R(d,ut);u=z.default.subtract(F,K)}else u=Z1(v,e,r,n,i,o,s,0);a==="year"||a==="month"||a==="week"||a==="day"?{days:v,nanoseconds:u}=PN(u,d):v=0;let x=z.default.lessThan(u,Nn)?-1:1;switch(u=Fu(u),c=l=p=m=g=Nn,a){case"year":case"month":case"week":case"day":case"hour":({quotient:c,remainder:u}=Zn(u,Ar)),{quotient:l,remainder:c}=Zn(c,Ar),{quotient:p,remainder:l}=Zn(l,Ar),{quotient:m,remainder:p}=Zn(p,of),{quotient:g,remainder:m}=Zn(m,of);break;case"minute":({quotient:c,remainder:u}=Zn(u,Ar)),{quotient:l,remainder:c}=Zn(c,Ar),{quotient:p,remainder:l}=Zn(l,Ar),{quotient:m,remainder:p}=Zn(p,of);break;case"second":({quotient:c,remainder:u}=Zn(u,Ar)),{quotient:l,remainder:c}=Zn(c,Ar),{quotient:p,remainder:l}=Zn(l,Ar);break;case"millisecond":({quotient:c,remainder:u}=Zn(u,Ar)),{quotient:l,remainder:c}=Zn(c,Ar);break;case"microsecond":({quotient:c,remainder:u}=Zn(u,Ar));break;case"nanosecond":break;default:throw new Error("assert not reached")}let S=z.default.toNumber(g)*x,P=z.default.toNumber(m)*x,A=z.default.toNumber(p)*x,$=z.default.toNumber(l)*x,j=z.default.toNumber(c)*x,L=z.default.toNumber(u)*x;for(let F of[v,S,P,A,$,j,L])if(!bs(F))return x===1?"positive overflow":"negative overflow";return{days:v,hours:S,minutes:P,seconds:A,milliseconds:$,microseconds:j,nanoseconds:L}}function VT(t,e,r,n,i,o){let s=Ae("%Temporal.Duration%"),a=af(t,e,r,n,0,0,0,0,0,0);if(a===0)return{years:t,months:e,weeks:r,days:n};let d=z.default.BigInt(a),u,c,l=z.default.BigInt(t),p=z.default.BigInt(e),m=z.default.BigInt(r),g=z.default.BigInt(n);o&&(c=Lr(o),u=R(c,fe));let v=new s(a),x=new s(0,a),S=new s(0,0,a);switch(i){case"year":break;case"month":{if(!u)throw new RangeError("a starting point is required for months balancing");let P,A;for(typeof u!="string"&&(P=kr(u,"dateAdd"),A=kr(u,"dateUntil"));!Wc(l);){let $=lo(u,c,v,void 0,P),j=Ko(null);j.largestUnit="month";let L=Gm(u,c,$,j,A),F=z.default.BigInt(R(L,Gi));c=$,p=z.default.add(p,F),l=z.default.subtract(l,d)}}break;case"week":{if(!u)throw new RangeError("a starting point is required for weeks balancing");let P=typeof u!="string"?kr(u,"dateAdd"):void 0;for(;!Wc(l);){let A;({relativeTo:c,days:A}=Uo(u,c,v,P)),g=z.default.add(g,z.default.BigInt(A)),l=z.default.subtract(l,d)}for(;!Wc(p);){let A;({relativeTo:c,days:A}=Uo(u,c,x,P)),g=z.default.add(g,z.default.BigInt(A)),p=z.default.subtract(p,d)}break}default:{if(Wc(l)&&Wc(p)&&Wc(m))break;if(!u)throw new RangeError("a starting point is required for balancing calendar units");let P=typeof u!="string"?kr(u,"dateAdd"):void 0;for(;!Wc(l);){let A;({relativeTo:c,days:A}=Uo(u,c,v,P)),g=z.default.add(g,z.default.BigInt(A)),l=z.default.subtract(l,d)}for(;!Wc(p);){let A;({relativeTo:c,days:A}=Uo(u,c,x,P)),g=z.default.add(g,z.default.BigInt(A)),p=z.default.subtract(p,d)}for(;!Wc(m);){let A;({relativeTo:c,days:A}=Uo(u,c,S,P)),g=z.default.add(g,z.default.BigInt(A)),m=z.default.subtract(m,d)}break}}return{years:z.default.toNumber(l),months:z.default.toNumber(p),weeks:z.default.toNumber(m),days:z.default.toNumber(g)}}function Lde(t,e,r,n,i){if(Ke(t)){let o=R(t,qo),s=R(t,Nr),a=R(t,fe),d=Hu(s,o),u=Vc(o,s,a,e,r,n,i,0,0,0,0,0,0);return Hu(s,new(Ae("%Temporal.Instant%"))(u))-d}return 0}function Cue(t){return new(Ae("%Temporal.Duration%"))(-R(t,ls),-R(t,Gi),-R(t,ia),-R(t,fs),-R(t,hs),-R(t,ps),-R(t,ms),-R(t,ys),-R(t,gs),-R(t,vs))}function Ra(t,e,r){return tqe(r,rqe(e,t))}function $ue(t,e,r){let n=Ra(e,1,12);return{year:t,month:n,day:Ra(r,1,qh(t,n))}}function fo(t,e,r){if(tr)throw new RangeError(`value out of range: ${e} <= ${t} <= ${r}`)}function df(t,e,r){fo(e,1,12),fo(r,1,qh(t,e))}function jue(t,e,r){Nue(t,e,r,12,0,0,0,0,0)}function kP(t,e,r,n,i,o){fo(t,0,23),fo(e,0,59),fo(r,0,59),fo(n,0,999),fo(i,0,999),fo(o,0,999)}function IN(t,e,r,n,i,o,s,a,d){df(t,e,r),kP(n,i,o,s,a,d)}function Nue(t,e,r,n,i,o,s,a,d){if(fo(t,QT,eP),t===QT&&Zm(t,e,r+1,n,i,o,s,a,d-1)==null||t===eP&&Zm(t,e,r-1,n,i,o,s,a,d+1)==null)throw new RangeError("DateTime outside of supported range")}function Yg(t){if(z.default.lessThan(t,y6)||z.default.greaterThan(t,W1))throw new RangeError("Instant outside of supported range")}function dP(t,e,r,n,i,o,s,a,d,u){let c=af(t,e,r,n,i,o,s,a,d,u);for(let l of[t,e,r,n,i,o,s,a,d,u]){if(!bs(l))throw new RangeError("infinite values not allowed as duration fields");let p=z1(l);if(p!==0&&p!==c)throw new RangeError("mixed-sign values not allowed as duration fields")}}function kN(t,e,r,n,i,o,s){switch(s){case"year":case"month":{let a=-Vm(t,e,r,n,i,o);if(a===0)return{years:0,months:0,weeks:0,days:0};let d={year:t,month:e,day:r},u={year:n,month:i,day:o},c=u.year-d.year,l=ev(t,e,r,c,0,0,0,"constrain"),p=-Vm(l.year,l.month,l.day,n,i,o);if(p===0)return s==="year"?{years:c,months:0,weeks:0,days:0}:{years:0,months:12*c,weeks:0,days:0};let m=u.month-d.month;if(p!==a&&(c-=a,m+=12*a),l=ev(t,e,r,c,m,0,0,"constrain"),p=-Vm(l.year,l.month,l.day,n,i,o),p===0)return s==="year"?{years:c,months:m,weeks:0,days:0}:{years:0,months:m+12*c,weeks:0,days:0};p!==a&&(m-=a,m===-a&&(c-=a,m=11*a),l=ev(t,e,r,c,m,0,0,"constrain"));let g=0;return g=l.month===u.month?u.day-l.day:a<0?-l.day-(qh(u.year,u.month)-u.day):u.day+(qh(l.year,l.month)-l.day),s==="month"&&(m+=12*c,c=0),{years:c,months:m,weeks:0,days:g}}case"week":case"day":{let a,d,u;Vm(t,e,r,n,i,o)<0?(d={year:t,month:e,day:r},a={year:n,month:i,day:o},u=1):(d={year:n,month:i,day:o},a={year:t,month:e,day:r},u=-1);let c=cP(a.year,a.month,a.day)-cP(d.year,d.month,d.day);for(let p=d.year;p{let v=g[0],x=g[1],S=g[2];return r!=="datetime"&&S!==r||n.includes(x)||m.push(x,v),m},[]),a=Ba(e,"largestUnit",r,"auto");if(n.includes(a))throw new RangeError(`largestUnit must be one of ${s.join(", ")}, not ${a}`);let d=t2(e),u=Wu(e,"trunc");t==="since"&&(u=function(g){switch(g){case"ceil":return"floor";case"floor":return"ceil";case"halfCeil":return"halfFloor";case"halfFloor":return"halfCeil";default:return g}}(u));let c=Ba(e,"smallestUnit",r,i);if(n.includes(c))throw new RangeError(`smallestUnit must be one of ${s.join(", ")}, not ${c}`);let l=iv(o,c);if(a==="auto"&&(a=l),iv(a,c)!==a)throw new RangeError(`largestUnit ${a} cannot be smaller than smallestUnit ${c}`);let p={hour:24,minute:60,second:60,millisecond:1e3,microsecond:1e3,nanosecond:1e3}[c];return p!==void 0&&r2(d,p,!1),{largestUnit:a,roundingIncrement:d,roundingMode:u,smallestUnit:c}}function Kde(t,e,r,n){let i=t==="since"?-1:1,o=zu(r),s=i2(t,ry(n),"time",[],"nanosecond","second"),a=R(e,ut),d=R(o,ut),{hours:u,minutes:c,seconds:l,milliseconds:p,microseconds:m,nanoseconds:g}=RN(a,d,s.roundingIncrement,s.smallestUnit,s.largestUnit,s.roundingMode);return new(Ae("%Temporal.Duration%"))(0,0,0,0,i*u,i*c,i*l,i*p,i*m,i*g)}function Fde(t,e,r,n){let i=t==="since"?-1:1,o=Lr(r),s=R(e,fe);AP(s,R(o,fe),"compute difference between dates");let a=ry(n),d=i2(t,a,"date",[],"day","day");a.largestUnit=d.largestUnit;let{years:u,months:c,weeks:l,days:p}=Gm(s,e,o,a);return d.smallestUnit==="day"&&d.roundingIncrement===1||({years:u,months:c,weeks:l,days:p}=Fh(u,c,l,p,0,0,0,0,0,0,d.roundingIncrement,d.smallestUnit,d.roundingMode,e)),new(Ae("%Temporal.Duration%"))(i*u,i*c,i*l,i*p,0,0,0,0,0,0)}function zde(t,e,r,n){let i=t==="since"?-1:1,o=Qg(r),s=R(e,fe);AP(s,R(o,fe),"compute difference between dates");let a=ry(n),d=i2(t,a,"datetime",[],"nanosecond","day"),{years:u,months:c,weeks:l,days:p,hours:m,minutes:g,seconds:v,milliseconds:x,microseconds:S,nanoseconds:P}=DN(R(e,De),R(e,Oe),R(e,je),R(e,St),R(e,At),R(e,Tt),R(e,Pt),R(e,It),R(e,kt),R(o,De),R(o,Oe),R(o,je),R(o,St),R(o,At),R(o,Tt),R(o,Pt),R(o,It),R(o,kt),s,d.largestUnit,a),A=J1(e);return{years:u,months:c,weeks:l,days:p,hours:m,minutes:g,seconds:v,milliseconds:x,microseconds:S,nanoseconds:P}=Fh(u,c,l,p,m,g,v,x,S,P,d.roundingIncrement,d.smallestUnit,d.roundingMode,A),{days:p,hours:m,minutes:g,seconds:v,milliseconds:x,microseconds:S,nanoseconds:P}=qd(p,m,g,v,x,S,P,d.largestUnit),new(Ae("%Temporal.Duration%"))(i*u,i*c,i*l,i*p,i*m,i*g,i*v,i*x,i*S,i*P)}function Wde(t,e,r,n){let i=t==="since"?-1:1,o=Nh(r),s=i2(t,ry(n),"time",[],"nanosecond","hour"),{hours:a,minutes:d,seconds:u,milliseconds:c,microseconds:l,nanoseconds:p}=Uue(R(e,St),R(e,At),R(e,Tt),R(e,Pt),R(e,It),R(e,kt),R(o,St),R(o,At),R(o,Tt),R(o,Pt),R(o,It),R(o,kt));return{hours:a,minutes:d,seconds:u,milliseconds:c,microseconds:l,nanoseconds:p}=Fh(0,0,0,0,a,d,u,c,l,p,s.roundingIncrement,s.smallestUnit,s.roundingMode),{hours:a,minutes:d,seconds:u,milliseconds:c,microseconds:l,nanoseconds:p}=qd(0,a,d,u,c,l,p,s.largestUnit),new(Ae("%Temporal.Duration%"))(0,0,0,0,i*a,i*d,i*u,i*c,i*l,i*p)}function Hde(t,e,r,n){let i=t==="since"?-1:1,o=f6(r),s=R(e,fe);AP(s,R(o,fe),"compute difference between months");let a=ry(n),d=i2(t,a,"date",["week","day"],"month","year");a.largestUnit=d.largestUnit;let u=oi(s,["monthCode","year"]),c=Ct(e,u,[]);c.day=1;let l=Kh(s,c),p=Ct(o,u,[]);p.day=1;let m=Kh(s,p),{years:g,months:v}=Gm(s,l,m,a);return d.smallestUnit==="month"&&d.roundingIncrement===1||({years:g,months:v}=Fh(g,v,0,0,0,0,0,0,0,0,d.roundingIncrement,d.smallestUnit,d.roundingMode,l)),new(Ae("%Temporal.Duration%"))(i*g,i*v,0,0,0,0,0,0,0,0)}function Vde(t,e,r,n){let i=t==="since"?-1:1,o=h6(r),s=R(e,fe);AP(s,R(o,fe),"compute difference between dates");let a=ry(n),d=i2(t,a,"datetime",[],"nanosecond","hour");a.largestUnit=d.largestUnit;let u=R(e,ut),c=R(o,ut),l,p,m,g,v,x,S,P,A,$;if(d.largestUnit!=="year"&&d.largestUnit!=="month"&&d.largestUnit!=="week"&&d.largestUnit!=="day")l=0,p=0,m=0,g=0,{hours:v,minutes:x,seconds:S,milliseconds:P,microseconds:A,nanoseconds:$}=RN(u,c,d.roundingIncrement,d.smallestUnit,d.largestUnit,d.roundingMode);else{let j=R(e,Nr);if(!Pue(j,R(o,Nr)))throw new RangeError("When calculating difference between time zones, largestUnit must be 'hours' or smaller because day lengths can vary between time zones due to DST or time zone offset changes.");({years:l,months:p,weeks:m,days:g,hours:v,minutes:x,seconds:S,milliseconds:P,microseconds:A,nanoseconds:$}=que(u,c,j,s,d.largestUnit,a)),{years:l,months:p,weeks:m,days:g,hours:v,minutes:x,seconds:S,milliseconds:P,microseconds:A,nanoseconds:$}=Fh(l,p,m,g,v,x,S,P,A,$,d.roundingIncrement,d.smallestUnit,d.roundingMode,e),{years:l,months:p,weeks:m,days:g,hours:v,minutes:x,seconds:S,milliseconds:P,microseconds:A,nanoseconds:$}=zue(l,p,m,g,v,x,S,P,A,$,d.roundingIncrement,d.smallestUnit,d.roundingMode,e)}return new(Ae("%Temporal.Duration%"))(i*l,i*p,i*m,i*g,i*v,i*x,i*S,i*P,i*A,i*$)}function ev(t,e,r,n,i,o,s,a){let d=t,u=e,c=r,l=o,p=s;return d+=n,u+=i,{year:d,month:u}=JT(d,u),{year:d,month:u,day:c}=nP(d,u,c,a),p+=7*l,c+=p,{year:d,month:u,day:c}=IP(d,u,c),{year:d,month:u,day:c}}function Lue(t,e,r,n,i,o,s,a,d,u,c,l){let p=t,m=e,g=r,v=n,x=i,S=o;p+=s,m+=a,g+=d,v+=u,x+=c,S+=l;let P=0;return{deltaDays:P,hour:p,minute:m,second:g,millisecond:v,microsecond:x,nanosecond:S}=jh(p,m,g,v,x,S),{deltaDays:P,hour:p,minute:m,second:g,millisecond:v,microsecond:x,nanosecond:S}}function Kue(t,e,r,n,i,o,s,a,d,u,c,l,p,m,g,v,x,S,P,A,$){let j=iv(Kj(t,e,r,n,i,o,s,a,d,u),Kj(c,l,p,m,g,v,x,S,P,A)),L,F,K,W,q,I,T,B,h,y;if($)if(Jt($)){let w=Ae("%Temporal.Duration%"),E=R($,fe),_=new w(t,e,r,n,0,0,0,0,0,0),b=new w(c,l,p,m,0,0,0,0,0,0),C=typeof E!="string"?kr(E,"dateAdd"):void 0,N=lo(E,$,_,void 0,C),M=lo(E,N,b,void 0,C),U=iv("day",j),G=Ko(null);G.largestUnit=U,{years:L,months:F,weeks:K,days:W}=Gm(E,$,M,G),{days:W,hours:q,minutes:I,seconds:T,milliseconds:B,microseconds:h,nanoseconds:y}=qd(W,z.default.add(z.default.BigInt(i),z.default.BigInt(g)),z.default.add(z.default.BigInt(o),z.default.BigInt(v)),z.default.add(z.default.BigInt(s),z.default.BigInt(x)),z.default.add(z.default.BigInt(a),z.default.BigInt(S)),z.default.add(z.default.BigInt(d),z.default.BigInt(P)),z.default.add(z.default.BigInt(u),z.default.BigInt(A)),j)}else{let w=Ae("%Temporal.Instant%"),E=R($,Nr),_=R($,fe),b=Vc(R($,qo),E,_,t,e,r,n,i,o,s,a,d,u),C=Vc(new w(b),E,_,c,l,p,m,g,v,x,S,P,A);j!=="year"&&j!=="month"&&j!=="week"&&j!=="day"?(L=0,F=0,K=0,W=0,{hours:q,minutes:I,seconds:T,milliseconds:B,microseconds:h,nanoseconds:y}=RN(R($,ut),C,1,"nanosecond",j,"halfExpand")):{years:L,months:F,weeks:K,days:W,hours:q,minutes:I,seconds:T,milliseconds:B,microseconds:h,nanoseconds:y}=que(R($,ut),C,E,_,j,Ko(null))}else{if(j==="year"||j==="month"||j==="week")throw new RangeError("relativeTo is required for years, months, or weeks arithmetic");L=F=K=0,{days:W,hours:q,minutes:I,seconds:T,milliseconds:B,microseconds:h,nanoseconds:y}=qd(n+m,z.default.add(z.default.BigInt(i),z.default.BigInt(g)),z.default.add(z.default.BigInt(o),z.default.BigInt(v)),z.default.add(z.default.BigInt(s),z.default.BigInt(x)),z.default.add(z.default.BigInt(a),z.default.BigInt(S)),z.default.add(z.default.BigInt(d),z.default.BigInt(P)),z.default.add(z.default.BigInt(u),z.default.BigInt(A)),j)}return dP(L,F,K,W,q,I,T,B,h,y),{years:L,months:F,weeks:K,days:W,hours:q,minutes:I,seconds:T,milliseconds:B,microseconds:h,nanoseconds:y}}function Hj(t,e,r,n,i,o,s){let a=Nn;a=z.default.add(a,z.default.BigInt(s)),a=z.default.add(a,z.default.multiply(z.default.BigInt(o),Ar)),a=z.default.add(a,z.default.multiply(z.default.BigInt(i),Hc)),a=z.default.add(a,z.default.multiply(z.default.BigInt(n),sf)),a=z.default.add(a,z.default.multiply(z.default.BigInt(r),z.default.BigInt(6e10))),a=z.default.add(a,z.default.multiply(z.default.BigInt(e),z.default.BigInt(36e11)));let d=z.default.add(t,a);return Yg(d),d}function Vj(t,e,r,n,i,o,s,a,d,u,c,l,p,m,g,v,x,S,P,A,$){let j=m,{deltaDays:L,hour:F,minute:K,second:W,millisecond:q,microsecond:I,nanosecond:T}=Lue(n,i,o,s,a,d,g,v,x,S,P,A);j+=L;let B=Ae("%Temporal.Duration%"),h=lo(u,Gc(t,e,r,u),new B(c,l,p,j,0,0,0,0,0,0),$);return{year:R(h,De),month:R(h,Oe),day:R(h,je),hour:F,minute:K,second:W,millisecond:q,microsecond:I,nanosecond:T}}function Vc(t,e,r,n,i,o,s,a,d,u,c,l,p,m){let g=Ae("%Temporal.Duration%");if(af(n,i,o,s,0,0,0,0,0,0)===0)return Hj(R(t,ut),a,d,u,c,l,p);let v=oc(e,t,r),x=lo(r,Gc(R(v,De),R(v,Oe),R(v,je),r),new g(n,i,o,s,0,0,0,0,0,0),m),S=ka(R(x,De),R(x,Oe),R(x,je),R(v,St),R(v,At),R(v,Tt),R(v,Pt),R(v,It),R(v,kt),r);return Hj(R(ws(e,S,"compatible"),ut),a,d,u,c,l,p)}function Gde(t,e,r,n){let i=t==="subtract"?-1:1,{years:o,months:s,weeks:a,days:d,hours:u,minutes:c,seconds:l,milliseconds:p,microseconds:m,nanoseconds:g}=dv(r),v=GT(tr(n));return{years:o,months:s,weeks:a,days:d,hours:u,minutes:c,seconds:l,milliseconds:p,microseconds:m,nanoseconds:g}=Kue(R(e,ls),R(e,Gi),R(e,ia),R(e,fs),R(e,hs),R(e,ps),R(e,ms),R(e,ys),R(e,gs),R(e,vs),i*o,i*s,i*a,i*d,i*u,i*c,i*l,i*p,i*m,i*g,v),new(Ae("%Temporal.Duration%"))(o,s,a,d,u,c,l,p,m,g)}function Jde(t,e,r){let n=t==="subtract"?-1:1,{hours:i,minutes:o,seconds:s,milliseconds:a,microseconds:d,nanoseconds:u}=function(p,m){let g=dv(p);for(let v of m)if(g[v]!==0)throw new RangeError(`Duration field ${v} not supported by Temporal.Instant. Try Temporal.ZonedDateTime instead.`);return g}(r,["years","months","weeks","days"]),c=Hj(R(e,ut),n*i,n*o,n*s,n*a,n*d,n*u);return new(Ae("%Temporal.Instant%"))(c)}function Zde(t,e,r,n){let i=t==="subtract"?-1:1,{years:o,months:s,weeks:a,days:d,hours:u,minutes:c,seconds:l,milliseconds:p,microseconds:m,nanoseconds:g}=dv(r),v=tr(n),x=R(e,fe),{year:S,month:P,day:A,hour:$,minute:j,second:L,millisecond:F,microsecond:K,nanosecond:W}=Vj(R(e,De),R(e,Oe),R(e,je),R(e,St),R(e,At),R(e,Tt),R(e,Pt),R(e,It),R(e,kt),x,i*o,i*s,i*a,i*d,i*u,i*c,i*l,i*p,i*m,i*g,v);return ka(S,P,A,$,j,L,F,K,W,x)}function Yde(t,e,r){let n=t==="subtract"?-1:1,{hours:i,minutes:o,seconds:s,milliseconds:a,microseconds:d,nanoseconds:u}=dv(r),{hour:c,minute:l,second:p,millisecond:m,microsecond:g,nanosecond:v}=Lue(R(e,St),R(e,At),R(e,Tt),R(e,Pt),R(e,It),R(e,kt),n*i,n*o,n*s,n*a,n*d,n*u);return{hour:c,minute:l,second:p,millisecond:m,microsecond:g,nanosecond:v}=yP(c,l,p,m,g,v,"reject"),new(Ae("%Temporal.PlainTime%"))(c,l,p,m,g,v)}function Xde(t,e,r,n){let i=dv(r);t==="subtract"&&(i={years:-i.years,months:-i.months,weeks:-i.weeks,days:-i.days,hours:-i.hours,minutes:-i.minutes,seconds:-i.seconds,milliseconds:-i.milliseconds,microseconds:-i.microseconds,nanoseconds:-i.nanoseconds});let{years:o,months:s,weeks:a,days:d,hours:u,minutes:c,seconds:l,milliseconds:p,microseconds:m,nanoseconds:g}=i;({days:d}=qd(d,u,c,l,p,m,g,"day"));let v=tr(n),x=R(e,fe),S=oi(x,["monthCode","year"]),P=Ct(e,S,[]),A=Ko(null);N1(A,P,[]),P.day=1;let $=Kh(x,P),j=af(o,s,a,d,0,0,0,0,0,0),L=kr(x,"dateAdd"),F=Ae("%Temporal.Duration%");if(j<0){let q=lo(x,$,new F(0,1,0,0,0,0,0,0,0,0),void 0,L),I=lo(x,q,new F(0,0,0,-1,0,0,0,0,0,0),void 0,L);A.day=j6(x,I),$=Kh(x,A)}let K=new F(o,s,a,d,0,0,0,0,0,0),W=ry(v);return sv(x,Ct(lo(x,$,K,v,L),S,[]),W)}function Qde(t,e,r,n){let i=t==="subtract"?-1:1,{years:o,months:s,weeks:a,days:d,hours:u,minutes:c,seconds:l,milliseconds:p,microseconds:m,nanoseconds:g}=dv(r),v=tr(n),x=R(e,Nr),S=R(e,fe);return uo(Vc(R(e,qo),x,S,i*o,i*s,i*a,i*d,i*u,i*c,i*l,i*p,i*m,i*g,v),x,S)}function ic(t,e,r){if(z.default.equal(e,Q1))return t;let{quotient:n,remainder:i}=Zn(t,e);if(z.default.equal(i,Nn))return t;let o=z.default.lessThan(i,Nn)?-1:1,s=Fu(z.default.multiply(i,z.default.BigInt(2))),a=z.default.equal(s,e),d=z.default.greaterThan(s,e);switch(r){case"ceil":o>0&&(n=z.default.add(n,z.default.BigInt(o)));break;case"floor":o<0&&(n=z.default.add(n,z.default.BigInt(o)));break;case"expand":n=z.default.add(n,z.default.BigInt(o));break;case"trunc":break;case"halfCeil":(d||a&&o>0)&&(n=z.default.add(n,z.default.BigInt(o)));break;case"halfFloor":(d||a&&o<0)&&(n=z.default.add(n,z.default.BigInt(o)));break;case"halfExpand":(d||a)&&(n=z.default.add(n,z.default.BigInt(o)));break;case"halfTrunc":d&&(n=z.default.add(n,z.default.BigInt(o)));break;case"halfEven":(d||a&&z.default.toNumber(z.default.remainder(Fu(n),z.default.BigInt(2)))===1)&&(n=z.default.add(n,z.default.BigInt(o)))}return z.default.multiply(n,e)}function uP(t,e,r,n){let{remainder:i}=Zg(t,cf),o=z.default.subtract(t,i),s=ic(i,z.default.BigInt(Vue[r]*e),n);return z.default.add(o,s)}function BN(t,e,r,n,i,o,s,a,d,u,c,l,p=864e11){let{deltaDays:m,hour:g,minute:v,second:x,millisecond:S,microsecond:P,nanosecond:A}=MN(n,i,o,s,a,d,u,c,l,p),{year:$,month:j,day:L}=IP(t,e,r+m);return{year:$,month:j,day:L,hour:g,minute:v,second:x,millisecond:S,microsecond:P,nanosecond:A}}function MN(t,e,r,n,i,o,s,a,d,u=864e11){let c=Nn;switch(a){case"day":case"hour":c=z.default.BigInt(t);case"minute":c=z.default.add(z.default.multiply(c,of),z.default.BigInt(e));case"second":c=z.default.add(z.default.multiply(c,of),z.default.BigInt(r));case"millisecond":c=z.default.add(z.default.multiply(c,Ar),z.default.BigInt(n));case"microsecond":c=z.default.add(z.default.multiply(c,Ar),z.default.BigInt(i));case"nanosecond":c=z.default.add(z.default.multiply(c,Ar),z.default.BigInt(o))}let l=a==="day"?u:Vue[a],p=ic(c,z.default.BigInt(l*s),d),m=z.default.toNumber(z.default.divide(p,z.default.BigInt(l)));switch(a){case"day":return{deltaDays:m,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0};case"hour":return jh(m,0,0,0,0,0);case"minute":return jh(t,m,0,0,0,0);case"second":return jh(t,e,m,0,0,0);case"millisecond":return jh(t,e,r,m,0,0);case"microsecond":return jh(t,e,r,n,m,0);case"nanosecond":return jh(t,e,r,n,i,m);default:throw new Error(`Invalid unit ${a}`)}}function ZT(t,e){return kN(R(t,De),R(t,Oe),R(t,je),R(e,De),R(e,Oe),R(e,je),"day").days}function Uo(t,e,r,n){let i=lo(t,e,r,void 0,n);return{relativeTo:i,days:ZT(e,i)}}function Fue(t,e,r,n,i){let o=R(t,Nr),s=R(t,fe);return uo(Vc(R(t,qo),o,s,e,r,n,i,0,0,0,0,0,0),o,s)}function zue(t,e,r,n,i,o,s,a,d,u,c,l,p,m){let g=t,v=e,x=r,S=n,P=i,A=o,$=s,j=a,L=d,F=u;if(!Ke(m)||l==="year"||l==="month"||l==="week"||l==="day"||l==="nanosecond"&&c===1)return{years:g,months:v,weeks:x,days:S,hours:P,minutes:A,seconds:$,milliseconds:j,microseconds:L,nanoseconds:F};let K=Z1(0,P,A,$,j,L,F,0),W=z1(z.default.toNumber(K)),q=R(m,Nr),I=R(m,fe),T=Vc(R(m,qo),q,I,g,v,x,S,0,0,0,0,0,0),B=Vc(new(Ae("%Temporal.Instant%"))(T),q,I,0,0,0,W,0,0,0,0,0,0),h=z.default.subtract(B,T);return z.default.greaterThanOrEqual(z.default.multiply(z.default.subtract(K,h),z.default.BigInt(W)),Nn)&&({years:g,months:v,weeks:x,days:S}=Kue(g,v,x,S,0,0,0,0,0,0,0,0,0,W,0,0,0,0,0,0,m),K=uP(z.default.subtract(K,h),c,l,p),{hours:P,minutes:A,seconds:$,milliseconds:j,microseconds:L,nanoseconds:F}=qd(0,0,0,0,0,0,z.default.toNumber(K),"hour")),{years:g,months:v,weeks:x,days:S,hours:P,minutes:A,seconds:$,milliseconds:j,microseconds:L,nanoseconds:F}}function Fh(t,e,r,n,i,o,s,a,d,u,c,l,p,m){let g=t,v=e,x=r,S=n,P=i,A=o,$=s,j=a,L=d,F=z.default.BigInt(u),K=Ae("%Temporal.Duration%"),W,q,I,T,B=m;if(B){if(Ke(B))q=B,B=Lr(B);else if(!Jt(B))throw new TypeError("starting point must be PlainDate or ZonedDateTime");W=R(B,fe)}if(l==="year"||l==="month"||l==="week"||l==="day"){let h,y,w;F=Z1(0,P,A,$,j,L,u,0),q&&(h=Fue(q,g,v,x,S)),{days:y,nanoseconds:F,dayLengthNs:w}=PN(F,h),I=z.default.BigInt(w),S+=y,P=A=$=j=L=0}switch(l){case"year":{if(!W)throw new RangeError("A starting point is required for years rounding");let h=new K(g),y=typeof W!="string"?kr(W,"dateAdd"):void 0,w=lo(W,B,h,void 0,y),E=lo(W,B,new K(g,v,x),void 0,y);B=w,S+=ZT(w,E);let _=lo(W,B,new K(0,0,0,S),void 0,y),b=Ko(null);b.largestUnit="year";let C=Gm(W,B,_,b).years;g+=C;let N=B;B=lo(W,B,new K(C),void 0,y),S-=ZT(N,B);let M=new K(S<0?-1:1),{days:U}=Uo(W,B,M,y);U=an(U);let G=z.default.multiply(z.default.BigInt(U),I);F=z.default.add(z.default.add(z.default.multiply(G,z.default.BigInt(g)),z.default.multiply(z.default.BigInt(S),I)),F);let Z=ic(F,z.default.multiply(G,z.default.BigInt(c)),p);T=rf(F,G),g=z.default.toNumber(z.default.divide(Z,G)),F=Nn,v=x=S=0;break}case"month":{if(!W)throw new RangeError("A starting point is required for months rounding");let h=new K(g,v),y=typeof W!="string"?kr(W,"dateAdd"):void 0,w=lo(W,B,h,void 0,y),E=lo(W,B,new K(g,v,x),void 0,y);B=w,S+=ZT(w,E);let _=z1(S),b=new K(0,S<0?-1:1),C;for({relativeTo:B,days:C}=Uo(W,B,b,y);an(S)>=an(C);)v+=_,S-=C,{relativeTo:B,days:C}=Uo(W,B,b,y);C=an(C);let N=z.default.multiply(z.default.BigInt(C),I);F=z.default.add(z.default.add(z.default.multiply(N,z.default.BigInt(v)),z.default.multiply(z.default.BigInt(S),I)),F);let M=ic(F,z.default.multiply(N,z.default.BigInt(c)),p);T=rf(F,N),v=z.default.toNumber(z.default.divide(M,N)),F=Nn,x=S=0;break}case"week":{if(!W)throw new RangeError("A starting point is required for weeks rounding");let h=z1(S),y=new K(0,0,S<0?-1:1),w=typeof W!="string"?kr(W,"dateAdd"):void 0,E;for({relativeTo:B,days:E}=Uo(W,B,y,w);an(S)>=an(E);)x+=h,S-=E,{relativeTo:B,days:E}=Uo(W,B,y,w);E=an(E);let _=z.default.multiply(z.default.BigInt(E),I);F=z.default.add(z.default.add(z.default.multiply(_,z.default.BigInt(x)),z.default.multiply(z.default.BigInt(S),I)),F);let b=ic(F,z.default.multiply(_,z.default.BigInt(c)),p);T=rf(F,_),x=z.default.toNumber(z.default.divide(b,_)),F=Nn,S=0;break}case"day":{let h=I;F=z.default.add(z.default.multiply(h,z.default.BigInt(S)),F);let y=ic(F,z.default.multiply(h,z.default.BigInt(c)),p);T=rf(F,h),S=z.default.toNumber(z.default.divide(y,h)),F=Nn;break}case"hour":{let y=z.default.multiply(z.default.BigInt(P),z.default.BigInt(36e11));y=z.default.add(y,z.default.multiply(z.default.BigInt(A),z.default.BigInt(6e10))),y=z.default.add(y,z.default.multiply(z.default.BigInt($),sf)),y=z.default.add(y,z.default.multiply(z.default.BigInt(j),Hc)),y=z.default.add(y,z.default.multiply(z.default.BigInt(L),Ar)),y=z.default.add(y,F),T=rf(y,z.default.BigInt(36e11));let w=ic(y,z.default.BigInt(36e11*c),p);P=z.default.toNumber(z.default.divide(w,z.default.BigInt(36e11))),F=Nn,A=$=j=L=0;break}case"minute":{let y=z.default.multiply(z.default.BigInt(A),z.default.BigInt(6e10));y=z.default.add(y,z.default.multiply(z.default.BigInt($),sf)),y=z.default.add(y,z.default.multiply(z.default.BigInt(j),Hc)),y=z.default.add(y,z.default.multiply(z.default.BigInt(L),Ar)),y=z.default.add(y,F),T=rf(y,z.default.BigInt(6e10));let w=ic(y,z.default.BigInt(6e10*c),p);A=z.default.toNumber(z.default.divide(w,z.default.BigInt(6e10))),F=Nn,$=j=L=0;break}case"second":{let y=z.default.multiply(z.default.BigInt($),sf);y=z.default.add(y,z.default.multiply(z.default.BigInt(j),Hc)),y=z.default.add(y,z.default.multiply(z.default.BigInt(L),Ar)),y=z.default.add(y,F),T=rf(y,z.default.BigInt(1e9));let w=ic(y,z.default.BigInt(1e9*c),p);$=z.default.toNumber(z.default.divide(w,z.default.BigInt(1e9))),F=Nn,j=L=0;break}case"millisecond":{let y=z.default.multiply(z.default.BigInt(j),Hc);y=z.default.add(y,z.default.multiply(z.default.BigInt(L),Ar)),y=z.default.add(y,F),T=rf(y,z.default.BigInt(1e6));let w=ic(y,z.default.BigInt(1e6*c),p);j=z.default.toNumber(z.default.divide(w,z.default.BigInt(1e6))),F=Nn,L=0;break}case"microsecond":{let y=z.default.multiply(z.default.BigInt(L),Ar);y=z.default.add(y,F),T=rf(y,z.default.BigInt(1e3));let w=ic(y,z.default.BigInt(1e3*c),p);L=z.default.toNumber(z.default.divide(w,z.default.BigInt(1e3))),F=Nn;break}case"nanosecond":T=z.default.toNumber(F),F=ic(z.default.BigInt(F),z.default.BigInt(c),p)}return{years:g,months:v,weeks:x,days:S,hours:P,minutes:A,seconds:$,milliseconds:j,microseconds:L,nanoseconds:z.default.toNumber(F),total:T}}function Vm(t,e,r,n,i,o){for(let[s,a]of[[t,n],[e,i],[r,o]])if(s!==a)return tv(s-a);return 0}function Zg(t,e){let{quotient:r,remainder:n}=Zn(t,e);return z.default.lessThan(n,Nn)&&(r=z.default.subtract(r,Q1),n=z.default.add(n,e)),{quotient:r,remainder:n}}function q1(t,e){let{quotient:r,remainder:n}=Zn(t,e);return Wc(n)||!tP(t)==!tP(e)?r:z.default.subtract(r,Q1)}function rf(t,e){let{quotient:r,remainder:n}=Zn(t,e);return z.default.toNumber(r)+z.default.toNumber(n)/z.default.toNumber(e)}function lP(t){let e=p6(t);return globalThis.BigInt!==void 0?globalThis.BigInt(e.toString(10)):e}function p6(t){let e=t;if(typeof t=="object"){let r=t[Symbol.toPrimitive];r&&typeof r=="function"&&(e=mP(r,t,["number"]))}if(typeof e=="number")throw new TypeError("cannot convert number to bigint");return typeof e=="bigint"?z.default.BigInt(e.toString(10)):z.default.BigInt(e)}var ON=(()=>{let t=z.default.BigInt(Date.now()%1e6);return()=>{let e=z.default.BigInt(Date.now()),r=z.default.add(z.default.multiply(e,Hc),t);return t=z.default.remainder(e,Hc),z.default.greaterThan(r,W1)?W1:z.default.lessThan(r,y6)?y6:r}})();function Hm(){return new hue().resolvedOptions().timeZone}function tv(t){return t<0?-1:t>0?1:t}function tr(t){if(t===void 0)return Ko(null);if(cn(t)&&t!==null)return t;throw new TypeError("Options parameter must be an object, not "+(t===null?"null":typeof t))}function Y1(t,e){let r=Ko(null);return r[t]=e,r}function ry(t){let e=Ko(null);return N1(e,tr(t),[]),e}function Xm(t,e,r,n){let i=t[e];if(i!==void 0){if(i=_s(i),!r.includes(i))throw new RangeError(`${e} must be one of ${r.join(", ")}, not ${i}`);return i}return n}function zh(t){return dqe.includes(uf(t))}function uf(t){return t.replace(/[A-Z]/g,e=>{let r=e.charCodeAt(0);return String.fromCharCode(r+32)})}var Wue=new RegExp(`^${uue.source}$`);function Hue(t,e,r,n=t(e),i=t(r)){let o=z.default.BigInt(e),s=z.default.BigInt(r),a=n,d=i;for(;z.default.greaterThan(z.default.subtract(s,o),Q1);){let u=z.default.divide(z.default.add(o,s),z.default.BigInt(2)),c=t(u);if(c===a)o=u,a=c;else{if(c!==d)throw new Error(`invalid state in bisection ${a} - ${c} - ${d}`);s=u,d=c}}return s}var Vue={hour:36e11,minute:6e10,second:1e9,millisecond:1e6,microsecond:1e3,nanosecond:1},Gue=Symbol("date"),Jue=Symbol("ym"),Zue=Symbol("md"),Yue=Symbol("time"),Xue=Symbol("datetime"),Que=Symbol("instant"),L1=Symbol("original"),C1=Symbol("timezone"),Ud=Symbol("calendar-id"),ele=Symbol("locale"),Gj=Symbol("options"),m6=t=>({value:t,enumerable:!0,writable:!1,configurable:!0}),K1=globalThis.Intl.DateTimeFormat,Wh=Object.assign,pqe=Object.prototype.hasOwnProperty,mqe=Reflect.apply;function O1(t,e){let r=t[e];return typeof r=="function"&&(r=new K1(t[ele],r(t[Gj])),t[e]=r),r}function av(t,e={}){if(!(this instanceof av))return new av(t,e);let r=e!==void 0,n=r?Wh({},e):{},i=new K1(t,n),o=i.resolvedOptions();if(r){let s=Wh({},o);for(let a in s)mqe(pqe,n,[a])||delete s[a];this[Gj]=s}else this[Gj]=n;this[ele]=o.locale,this[L1]=i,this[C1]=o.timeZone,this[Ud]=o.calendar,this[Gue]=bqe,this[Jue]=gqe,this[Zue]=vqe,this[Yue]=yqe,this[Xue]=wqe,this[Que]=_qe}Object.defineProperty(av,"name",{writable:!0,value:"DateTimeFormat"}),av.supportedLocalesOf=function(t,e){return K1.supportedLocalesOf(t,e)};var Oj={resolvedOptions:m6(function(){return this[L1].resolvedOptions()}),format:m6(function(e,...r){let{instant:n,formatter:i}=F1(e,this);return n&&i?i.format(n.epochMilliseconds):this[L1].format(e,...r)}),formatRange:m6(function(e,r){if(X1(e)||X1(r)){if(!tle(e,r))throw new TypeError("Intl.DateTimeFormat.formatRange accepts two values of the same type");let{instant:n,formatter:i}=F1(e,this),{instant:o,formatter:s}=F1(r,this);if(n&&o&&i&&s&&i===s)return i.formatRange(n.epochMilliseconds,o.epochMilliseconds)}return this[L1].formatRange(e,r)})};"formatToParts"in K1.prototype&&(Oj.formatToParts=m6(function(e,...r){let{instant:n,formatter:i}=F1(e,this);return n&&i?i.formatToParts(n.epochMilliseconds):this[L1].formatToParts(e,...r)})),"formatRangeToParts"in K1.prototype&&(Oj.formatRangeToParts=m6(function(e,r){if(X1(e)||X1(r)){if(!tle(e,r))throw new TypeError("Intl.DateTimeFormat.formatRangeToParts accepts two values of the same type");let{instant:n,formatter:i}=F1(e,this),{instant:o,formatter:s}=F1(r,this);if(n&&o&&i&&s&&i===s)return i.formatRangeToParts(n.epochMilliseconds,o.epochMilliseconds)}return this[L1].formatRangeToParts(e,r)})),av.prototype=Object.create(K1.prototype,Oj),Object.defineProperty(av,"prototype",{writable:!1,enumerable:!1,configurable:!1});var Hh=av;function q6(t={},e={}){let r=Wh({},t);for(let n of["year","month","day","hour","minute","second","weekday","dayPeriod","timeZoneName","dateStyle","timeStyle"])r[n]=n in e?e[n]:r[n],r[n]!==!1&&r[n]!==void 0||delete r[n];return r}function yqe(t){let e=q6(t,{year:!1,month:!1,day:!1,weekday:!1,timeZoneName:!1,dateStyle:!1});return $N(e)||(e=Wh({},e,{hour:"numeric",minute:"numeric",second:"numeric"})),e}function gqe(t){let e=q6(t,{day:!1,hour:!1,minute:!1,second:!1,weekday:!1,dayPeriod:!1,timeZoneName:!1,dateStyle:!1,timeStyle:!1});return"year"in e||"month"in e||(e=Wh(e,{year:"numeric",month:"numeric"})),e}function vqe(t){let e=q6(t,{year:!1,hour:!1,minute:!1,second:!1,weekday:!1,dayPeriod:!1,timeZoneName:!1,dateStyle:!1,timeStyle:!1});return"month"in e||"day"in e||(e=Wh({},e,{month:"numeric",day:"numeric"})),e}function bqe(t){let e=q6(t,{hour:!1,minute:!1,second:!1,dayPeriod:!1,timeZoneName:!1,timeStyle:!1});return CN(e)||(e=Wh({},e,{year:"numeric",month:"numeric",day:"numeric"})),e}function wqe(t){let e=q6(t,{timeZoneName:!1});return $N(e)||CN(e)||(e=Wh({},e,{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})),e}function _qe(t){let e=t;return $N(e)||CN(e)||(e=Wh({},e,{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})),e}function CN(t){return"year"in t||"month"in t||"day"in t||"weekday"in t||"dateStyle"in t}function $N(t){return"hour"in t||"minute"in t||"second"in t||"timeStyle"in t||"dayPeriod"in t}function X1(t){return Jt(t)||jn(t)||_t(t)||Ke(t)||Sr(t)||Ri(t)||_i(t)}function tle(t,e){return!(!X1(t)||!X1(e))&&!(jn(t)&&!jn(e))&&!(Jt(t)&&!Jt(e))&&!(_t(t)&&!_t(e))&&!(Ke(t)&&!Ke(e))&&!(Sr(t)&&!Sr(e))&&!(Ri(t)&&!Ri(e))&&!(_i(t)&&!_i(e))}function F1(t,e){let r=Ae("%Temporal.PlainDateTime%");if(jn(t)){let n=new r(1970,1,1,R(t,St),R(t,At),R(t,Tt),R(t,Pt),R(t,It),R(t,kt),e[Ud]);return{instant:ws(e[C1],n,"compatible"),formatter:O1(e,Yue)}}if(Sr(t)){let n=R(t,De),i=R(t,Oe),o=R(t,je),s=ho(R(t,fe));if(s!==e[Ud])throw new RangeError(`cannot format PlainYearMonth with calendar ${s} in locale with calendar ${e[Ud]}`);let a=new r(n,i,o,12,0,0,0,0,0,s);return{instant:ws(e[C1],a,"compatible"),formatter:O1(e,Jue)}}if(Ri(t)){let n=R(t,De),i=R(t,Oe),o=R(t,je),s=ho(R(t,fe));if(s!==e[Ud])throw new RangeError(`cannot format PlainMonthDay with calendar ${s} in locale with calendar ${e[Ud]}`);let a=new r(n,i,o,12,0,0,0,0,0,s);return{instant:ws(e[C1],a,"compatible"),formatter:O1(e,Zue)}}if(Jt(t)){let n=R(t,De),i=R(t,Oe),o=R(t,je),s=ho(R(t,fe));if(s!=="iso8601"&&s!==e[Ud])throw new RangeError(`cannot format PlainDate with calendar ${s} in locale with calendar ${e[Ud]}`);let a=new r(n,i,o,12,0,0,0,0,0,e[Ud]);return{instant:ws(e[C1],a,"compatible"),formatter:O1(e,Gue)}}if(_t(t)){let n=R(t,De),i=R(t,Oe),o=R(t,je),s=R(t,St),a=R(t,At),d=R(t,Tt),u=R(t,Pt),c=R(t,It),l=R(t,kt),p=ho(R(t,fe));if(p!=="iso8601"&&p!==e[Ud])throw new RangeError(`cannot format PlainDateTime with calendar ${p} in locale with calendar ${e[Ud]}`);let m=t;return p==="iso8601"&&(m=new r(n,i,o,s,a,d,u,c,l,e[Ud])),{instant:ws(e[C1],m,"compatible"),formatter:O1(e,Xue)}}if(Ke(t))throw new TypeError("Temporal.ZonedDateTime not supported in DateTimeFormat methods. Use toLocaleString() instead.");return _i(t)?{instant:t,formatter:O1(e,Que)}:{}}var lEt=Object.freeze({__proto__:null,DateTimeFormat:Hh}),w6=class t{constructor(e){if(arguments.length<1)throw new TypeError("missing argument: epochNanoseconds is required");let r=p6(e);Yg(r),ff(this),Mt(this,ut,r)}get epochSeconds(){if(!_i(this))throw new TypeError("invalid receiver");let e=R(this,ut);return z.default.toNumber(q1(e,sf))}get epochMilliseconds(){if(!_i(this))throw new TypeError("invalid receiver");let e=z.default.BigInt(R(this,ut));return z.default.toNumber(q1(e,Hc))}get epochMicroseconds(){if(!_i(this))throw new TypeError("invalid receiver");return lP(q1(z.default.BigInt(R(this,ut)),Ar))}get epochNanoseconds(){if(!_i(this))throw new TypeError("invalid receiver");return lP(z.default.BigInt(R(this,ut)))}add(e){if(!_i(this))throw new TypeError("invalid receiver");return Jde("add",this,e)}subtract(e){if(!_i(this))throw new TypeError("invalid receiver");return Jde("subtract",this,e)}until(e,r){if(!_i(this))throw new TypeError("invalid receiver");return Kde("until",this,e,r)}since(e,r){if(!_i(this))throw new TypeError("invalid receiver");return Kde("since",this,e,r)}round(e){if(!_i(this))throw new TypeError("invalid receiver");if(e===void 0)throw new TypeError("options parameter is required");let r=typeof e=="string"?Y1("smallestUnit",e):tr(e),n=t2(r),i=Wu(r,"halfExpand"),o=Ba(r,"smallestUnit","time",nv);r2(n,{hour:24,minute:1440,second:86400,millisecond:864e5,microsecond:864e8,nanosecond:864e11}[o],!0);let s=uP(R(this,ut),n,o,i);return new t(s)}equals(e){if(!_i(this))throw new TypeError("invalid receiver");let r=zu(e),n=R(this,ut),i=R(r,ut);return z.default.equal(z.default.BigInt(n),z.default.BigInt(i))}toString(e){if(!_i(this))throw new TypeError("invalid receiver");let r=tr(e),n=M6(r),i=Wu(r,"trunc"),o=Ba(r,"smallestUnit","time",void 0);if(o==="hour")throw new RangeError('smallestUnit must be a time unit other than "hour"');let s=r.timeZone;s!==void 0&&(s=Lo(s));let{precision:a,unit:d,increment:u}=O6(o,n),c=uP(R(this,ut),u,d,i);return Mde(new t(c),s,a)}toJSON(){if(!_i(this))throw new TypeError("invalid receiver");return Mde(this,void 0,"auto")}toLocaleString(e,r){if(!_i(this))throw new TypeError("invalid receiver");return new Hh(e,r).format(this)}valueOf(){throw new TypeError("use compare() or equals() to compare Temporal.Instant")}toZonedDateTime(e){if(!_i(this))throw new TypeError("invalid receiver");if(!cn(e))throw new TypeError("invalid argument in toZonedDateTime");let r=e.calendar;if(r===void 0)throw new TypeError("missing calendar property in toZonedDateTime");let n=Ma(r),i=e.timeZone;if(i===void 0)throw new TypeError("missing timeZone property in toZonedDateTime");let o=Lo(i);return uo(R(this,ut),o,n)}toZonedDateTimeISO(e){if(!_i(this))throw new TypeError("invalid receiver");let r=Lo(e);return uo(R(this,ut),r,"iso8601")}static fromEpochSeconds(e){let r=H1(e),n=z.default.multiply(z.default.BigInt(r),sf);return Yg(n),new t(n)}static fromEpochMilliseconds(e){let r=H1(e),n=z.default.multiply(z.default.BigInt(r),Hc);return Yg(n),new t(n)}static fromEpochMicroseconds(e){let r=p6(e),n=z.default.multiply(r,Ar);return Yg(n),new t(n)}static fromEpochNanoseconds(e){let r=p6(e);return Yg(r),new t(r)}static from(e){return _i(e)?new t(R(e,ut)):zu(e)}static compare(e,r){let n=zu(e),i=zu(r),o=R(n,ut),s=R(i,ut);return z.default.lessThan(o,s)?-1:z.default.greaterThan(o,s)?1:0}};lf(w6,"Temporal.Instant");var rle=Array.prototype.includes,xqe=Array.prototype.push,Eqe=globalThis.Intl.DateTimeFormat,Sqe=Array.prototype.sort,Aqe=Math.abs,Tqe=Math.floor,Cj=Object.create,Jj=Object.entries,nle=Set,eue=Reflect.ownKeys,No=Set.prototype.add,ile=Set.prototype.values,vn={},gn=class{constructor(e){if(arguments.length<1)throw new RangeError("missing argument: id is required");let r=_s(e);if(!zh(r))throw new RangeError(`invalid calendar identifier ${r}`);ff(this),Mt(this,Pn,uf(r))}get id(){if(!Cn(this))throw new TypeError("invalid receiver");return R(this,Pn)}dateFromFields(e,r){if(!Cn(this))throw new TypeError("invalid receiver");if(!cn(e))throw new TypeError("invalid fields");let n=tr(r),i=R(this,Pn);return vn[i].dateFromFields(e,n,i)}yearMonthFromFields(e,r){if(!Cn(this))throw new TypeError("invalid receiver");if(!cn(e))throw new TypeError("invalid fields");let n=tr(r),i=R(this,Pn);return vn[i].yearMonthFromFields(e,n,i)}monthDayFromFields(e,r){if(!Cn(this))throw new TypeError("invalid receiver");if(!cn(e))throw new TypeError("invalid fields");let n=tr(r),i=R(this,Pn);return vn[i].monthDayFromFields(e,n,i)}fields(e){if(!Cn(this))throw new TypeError("invalid receiver");let r=[],n=new Set(["year","month","monthCode","day","hour","minute","second","millisecond","microsecond","nanosecond"]);for(let i of e){if(typeof i!="string")throw new TypeError("invalid fields");if(!n.has(i))throw new RangeError(`invalid field name ${i}`);n.delete(i),xqe.call(r,i)}return vn[R(this,Pn)].fields(r)}mergeFields(e,r){if(!Cn(this))throw new TypeError("invalid receiver");let n=Dde(e),i=Cj(null);N1(i,n,[],[void 0]);let o=Dde(r),s=Cj(null);N1(s,o,[],[void 0]);let a=eue(s),d=vn[R(this,Pn)].fieldKeysToIgnore(a),u=Cj(null),c=eue(i);for(let l of c){let p;p=Ge(rle,d,[l])?s[l]:i[l],p!==void 0&&(u[l]=p)}return N1(u,s,[]),u}dateAdd(e,r,n){if(!Cn(this))throw new TypeError("invalid receiver");let i=Lr(e),o=U1(r),s=Yn(tr(n)),{days:a}=qd(R(o,fs),R(o,hs),R(o,ps),R(o,ms),R(o,ys),R(o,gs),R(o,vs),"day"),d=R(this,Pn);return vn[d].dateAdd(i,R(o,ls),R(o,Gi),R(o,ia),a,s,d)}dateUntil(e,r,n){if(!Cn(this))throw new TypeError("invalid receiver");let i=Lr(e),o=Lr(r),s=Ba(tr(n),"largestUnit","date","auto");s==="auto"&&(s="day");let{years:a,months:d,weeks:u,days:c}=vn[R(this,Pn)].dateUntil(i,o,s);return new(Ae("%Temporal.Duration%"))(a,d,u,c,0,0,0,0,0,0)}year(e){let r=e;if(!Cn(this))throw new TypeError("invalid receiver");return Sr(r)||(r=Lr(r)),vn[R(this,Pn)].year(r)}month(e){let r=e;if(!Cn(this))throw new TypeError("invalid receiver");if(Ri(r))throw new TypeError("use monthCode on PlainMonthDay instead");return Sr(r)||(r=Lr(r)),vn[R(this,Pn)].month(r)}monthCode(e){let r=e;if(!Cn(this))throw new TypeError("invalid receiver");return Sr(r)||Ri(r)||(r=Lr(r)),vn[R(this,Pn)].monthCode(r)}day(e){let r=e;if(!Cn(this))throw new TypeError("invalid receiver");return Ri(r)||(r=Lr(r)),vn[R(this,Pn)].day(r)}era(e){let r=e;if(!Cn(this))throw new TypeError("invalid receiver");return Sr(r)||(r=Lr(r)),vn[R(this,Pn)].era(r)}eraYear(e){let r=e;if(!Cn(this))throw new TypeError("invalid receiver");return Sr(r)||(r=Lr(r)),vn[R(this,Pn)].eraYear(r)}dayOfWeek(e){if(!Cn(this))throw new TypeError("invalid receiver");let r=Lr(e);return vn[R(this,Pn)].dayOfWeek(r)}dayOfYear(e){if(!Cn(this))throw new TypeError("invalid receiver");let r=Lr(e);return vn[R(this,Pn)].dayOfYear(r)}weekOfYear(e){if(!Cn(this))throw new TypeError("invalid receiver");let r=Lr(e);return vn[R(this,Pn)].weekOfYear(r)}yearOfWeek(e){if(!Cn(this))throw new TypeError("invalid receiver");let r=Lr(e);return vn[R(this,Pn)].yearOfWeek(r)}daysInWeek(e){if(!Cn(this))throw new TypeError("invalid receiver");let r=Lr(e);return vn[R(this,Pn)].daysInWeek(r)}daysInMonth(e){let r=e;if(!Cn(this))throw new TypeError("invalid receiver");return Sr(r)||(r=Lr(r)),vn[R(this,Pn)].daysInMonth(r)}daysInYear(e){let r=e;if(!Cn(this))throw new TypeError("invalid receiver");return Sr(r)||(r=Lr(r)),vn[R(this,Pn)].daysInYear(r)}monthsInYear(e){let r=e;if(!Cn(this))throw new TypeError("invalid receiver");return Sr(r)||(r=Lr(r)),vn[R(this,Pn)].monthsInYear(r)}inLeapYear(e){let r=e;if(!Cn(this))throw new TypeError("invalid receiver");return Sr(r)||(r=Lr(r)),vn[R(this,Pn)].inLeapYear(r)}toString(){if(!Cn(this))throw new TypeError("invalid receiver");return R(this,Pn)}toJSON(){if(!Cn(this))throw new TypeError("invalid receiver");return R(this,Pn)}static from(e){return n2(Ma(e))}};function jN(t){if(!t.startsWith("M"))throw new RangeError(`Invalid month code: ${t}. Month codes must start with M.`);let e=+t.slice(1);if(isNaN(e))throw new RangeError(`Invalid month code: ${t}`);return e}function Lh(t,e=!1){return`M${t.toString().padStart(2,"0")}${e?"L":""}`}function YT(t,e,r=12){let{month:n,monthCode:i}=t;if(i===void 0){if(n===void 0)throw new TypeError("Either month or monthCode are required");e==="reject"&&fo(n,1,r),e==="constrain"&&(n=Ra(n,1,r)),i=Lh(n)}else{let o=jN(i);if(n!==void 0&&n!==o)throw new RangeError(`monthCode ${i} and month ${n} must match if both are present`);if(i!==Lh(o))throw new RangeError(`Invalid month code: ${i}`);if(n=o,n<1||n>r)throw new RangeError(`Invalid monthCode: ${i}`)}return{...t,month:n,monthCode:i}}lf(gn,"Temporal.Calendar"),In("Temporal.Calendar.from",gn.from),In("Temporal.Calendar.prototype.dateAdd",gn.prototype.dateAdd),In("Temporal.Calendar.prototype.dateFromFields",gn.prototype.dateFromFields),In("Temporal.Calendar.prototype.dateUntil",gn.prototype.dateUntil),In("Temporal.Calendar.prototype.day",gn.prototype.day),In("Temporal.Calendar.prototype.dayOfWeek",gn.prototype.dayOfWeek),In("Temporal.Calendar.prototype.dayOfYear",gn.prototype.dayOfYear),In("Temporal.Calendar.prototype.daysInMonth",gn.prototype.daysInMonth),In("Temporal.Calendar.prototype.daysInWeek",gn.prototype.daysInWeek),In("Temporal.Calendar.prototype.daysInYear",gn.prototype.daysInYear),In("Temporal.Calendar.prototype.era",gn.prototype.era),In("Temporal.Calendar.prototype.eraYear",gn.prototype.eraYear),In("Temporal.Calendar.prototype.fields",gn.prototype.fields),In("Temporal.Calendar.prototype.inLeapYear",gn.prototype.inLeapYear),In("Temporal.Calendar.prototype.mergeFields",gn.prototype.mergeFields),In("Temporal.Calendar.prototype.month",gn.prototype.month),In("Temporal.Calendar.prototype.monthCode",gn.prototype.monthCode),In("Temporal.Calendar.prototype.monthDayFromFields",gn.prototype.monthDayFromFields),In("Temporal.Calendar.prototype.monthsInYear",gn.prototype.monthsInYear),In("Temporal.Calendar.prototype.weekOfYear",gn.prototype.weekOfYear),In("Temporal.Calendar.prototype.year",gn.prototype.year),In("Temporal.Calendar.prototype.yearMonthFromFields",gn.prototype.yearMonthFromFields),In("Temporal.Calendar.prototype.yearOfWeek",gn.prototype.yearOfWeek),vn.iso8601={dateFromFields(t,e,r){let n=Ct(t,["day","month","monthCode","year"],["year","day"]),i=Yn(e);n=YT(n);let{year:o,month:s,day:a}=n;return{year:o,month:s,day:a}=nP(o,s,a,i),Gc(o,s,a,r)},yearMonthFromFields(t,e,r){let n=Ct(t,["month","monthCode","year"],["year"]),i=Yn(e);n=YT(n);let{year:o,month:s}=n;return{year:o,month:s}=function(d,u,c){let l=d,p=u;switch(c){case"reject":df(l,p,1);break;case"constrain":({year:l,month:p}=$ue(l,p))}return{year:l,month:p}}(o,s,i),v6(o,s,r,1)},monthDayFromFields(t,e,r){let n=Ct(t,["day","month","monthCode","year"],["day"]),i=Yn(e);if(n.month!==void 0&&n.year===void 0&&n.monthCode===void 0)throw new TypeError("either year or monthCode required with month");let o=n.monthCode===void 0;n=YT(n);let{month:s,day:a,year:d}=n;return{month:s,day:a}=nP(o?d:1972,s,a,i),g6(s,a,r,1972)},fields:t=>t,fieldKeysToIgnore(t){let e=new nle;for(let r=0;rkN(R(t,De),R(t,Oe),R(t,je),R(e,De),R(e,Oe),R(e,je),r),year:t=>R(t,De),era(){},eraYear(){},month:t=>R(t,Oe),monthCode:t=>Lh(R(t,Oe)),day:t=>R(t,je),dayOfWeek:t=>Wj(R(t,De),R(t,Oe),R(t,je)),dayOfYear:t=>cP(R(t,De),R(t,Oe),R(t,je)),weekOfYear:t=>qde(R(t,De),R(t,Oe),R(t,je)).week,yearOfWeek:t=>qde(R(t,De),R(t,Oe),R(t,je)).year,daysInWeek:()=>7,daysInMonth:t=>qh(R(t,De),R(t,Oe)),daysInYear(t){let e=t;return Bi(e,De)||(e=Lr(e)),Ym(R(e,De))?366:365},monthsInYear:()=>12,inLeapYear(t){let e=t;return Bi(e,De)||(e=Lr(e)),Ym(R(e,De))}};var wi=class t{constructor(e){if(this.map=new Map,this.calls=0,this.hits=0,this.misses=0,this.now=globalThis.performance?globalThis.performance.now():Date.now(),e!==void 0){let r=0;for(let n of e.map.entries()){if(++r>t.MAX_CACHE_ENTRIES)break;this.map.set(...n)}}}get(e){let r=this.map.get(e);return r&&(this.hits++,this.report()),this.calls++,r}set(e,r){this.map.set(e,r),this.misses++,this.report()}report(){}setObject(e){if(t.objectMap.get(e))throw new RangeError("object already cached");t.objectMap.set(e,this),this.report()}static getCacheForObject(e){let r=t.objectMap.get(e);return r||(r=new t,t.objectMap.set(e,r)),r}};function ole({isoYear:t,isoMonth:e,isoDay:r}){return`${uv(t)}-${bn(e)}-${bn(r)}T00:00Z`}function $j(t,e){return{years:t.year-e.year,months:t.month-e.month,days:t.day-e.day}}wi.objectMap=new WeakMap,wi.MAX_CACHE_ENTRIES=1e3;var Qm=class{constructor(){this.eraLength="short",this.hasEra=!0,this.erasBeginMidYear=!1}getFormatter(){return this.formatter===void 0&&(this.formatter=new Eqe(`en-US-u-ca-${this.id}`,{day:"numeric",month:"numeric",year:"numeric",era:this.eraLength,timeZone:"UTC"})),this.formatter}isoToCalendarDate(e,r){let{year:n,month:i,day:o}=e,s=JSON.stringify({func:"isoToCalendarDate",isoYear:n,isoMonth:i,isoDay:o,id:this.id}),a=r.get(s);if(a)return a;let d=this.getFormatter(),u,c;try{c=ole({isoYear:n,isoMonth:i,isoDay:o}),u=d.formatToParts(new Date(c))}catch{throw new RangeError(`Invalid ISO date: ${JSON.stringify({isoYear:n,isoMonth:i,isoDay:o})}`)}let l={};for(let{type:m,value:g}of u){if(m==="year"&&(l.eraYear=+g),m==="relatedYear"&&(l.eraYear=+g),m==="month"){let v=/^([0-9]*)(.*?)$/.exec(g);if(!v||v.length!=3||!v[1]&&!v[2])throw new RangeError(`Unexpected month: ${g}`);if(l.month=v[1]?+v[1]:1,l.month<1)throw new RangeError(`Invalid month ${g} from ${c}[u-ca-${this.id}] (probably due to https://bugs.chromium.org/p/v8/issues/detail?id=10527)`);if(l.month>13)throw new RangeError(`Invalid month ${g} from ${c}[u-ca-${this.id}] (probably due to https://bugs.chromium.org/p/v8/issues/detail?id=10529)`);v[2]&&(l.monthExtra=v[2])}m==="day"&&(l.day=+g),this.hasEra&&m==="era"&&g!=null&&g!==""&&(g=g.split(" (")[0],l.era=g.normalize("NFD").replace(/[^-0-9 \p{L}]/gu,"").replace(" ","-").toLowerCase())}if(l.eraYear===void 0)throw new RangeError(`Intl.DateTimeFormat.formatToParts lacks relatedYear in ${this.id} calendar. Try Node 14+ or modern browsers.`);if(this.reviseIntlEra){let{era:m,eraYear:g}=this.reviseIntlEra(l,e);l.era=m,l.eraYear=g}this.checkIcuBugs&&this.checkIcuBugs(e);let p=this.adjustCalendarDate(l,r,"constrain",!0);if(p.year===void 0)throw new RangeError(`Missing year converting ${JSON.stringify(e)}`);if(p.month===void 0)throw new RangeError(`Missing month converting ${JSON.stringify(e)}`);if(p.day===void 0)throw new RangeError(`Missing day converting ${JSON.stringify(e)}`);return r.set(s,p),["constrain","reject"].forEach(m=>{let g=JSON.stringify({func:"calendarToIsoDate",year:p.year,month:p.month,day:p.day,overflow:m,id:this.id});r.set(g,e)}),p}validateCalendarDate(e){let{era:r,month:n,year:i,day:o,eraYear:s,monthCode:a,monthExtra:d}=e;if(d!==void 0)throw new RangeError("Unexpected `monthExtra` value");if(i===void 0&&s===void 0)throw new TypeError("year or eraYear is required");if(n===void 0&&a===void 0)throw new TypeError("month or monthCode is required");if(o===void 0)throw new RangeError("Missing day");if(a!==void 0){if(typeof a!="string")throw new RangeError("monthCode must be a string, not "+typeof a);if(!/^M([01]?\d)(L?)$/.test(a))throw new RangeError(`Invalid monthCode: ${a}`)}if(this.constantEra){if(r!==void 0&&r!==this.constantEra)throw new RangeError(`era must be ${this.constantEra}, not ${r}`);if(s!==void 0&&i!==void 0&&s!==i)throw new RangeError(`eraYear ${s} does not match year ${i}`)}if(this.hasEra&&e.era===void 0!=(e.eraYear===void 0))throw new RangeError("properties 'era' and 'eraYear' must be provided together")}adjustCalendarDate(e,r,n="constrain",i=!1){if(this.calendarType==="lunisolar")throw new RangeError("Override required for lunisolar calendars");let o=e;if(this.validateCalendarDate(o),this.constantEra){let{year:u,eraYear:c}=o;o={...o,era:this.constantEra,year:u!==void 0?u:c,eraYear:c!==void 0?c:u}}let s=this.monthsInYear(o,r),{month:a,monthCode:d}=o;return{month:a,monthCode:d}=YT(o,n,s),{...o,month:a,monthCode:d}}regulateMonthDayNaive(e,r,n){let i=this.monthsInYear(e,n),{month:o,day:s}=e;return r==="reject"?(fo(o,1,i),fo(s,1,this.maximumMonthLength(e))):(o=Ra(o,1,i),s=Ra(s,1,this.maximumMonthLength({...e,month:o}))),{...e,month:o,day:s}}calendarToIsoDate(e,r="constrain",n){let i=e,o=this.adjustCalendarDate(e,n,r,!1);o=this.regulateMonthDayNaive(o,r,n);let{year:s,month:a,day:d}=o,u=JSON.stringify({func:"calendarToIsoDate",year:s,month:a,day:d,overflow:r,id:this.id}),c,l=n.get(u);if(l||i.year!==void 0&&i.month!==void 0&&i.day!==void 0&&(i.year!==o.year||i.month!==o.month||i.day!==o.day)&&(c=JSON.stringify({func:"calendarToIsoDate",year:i.year,month:i.month,day:i.day,overflow:r,id:this.id}),l=n.get(c),l))return l;let p=this.estimateIsoDate({year:s,month:a,day:d}),m=P=>{let A=this.addDaysIso(p,P);if(o.day>this.minimumMonthLength(o)){let $=this.isoToCalendarDate(A,n);for(;$.month!==a||$.year!==s;){if(r==="reject")throw new RangeError(`day ${d} does not exist in month ${a} of year ${s}`);A=this.addDaysIso(A,-1),$=this.isoToCalendarDate(A,n)}}return A},g=0,v=this.isoToCalendarDate(p,n),x=$j(o,v);if(x.years!==0||x.months!==0||x.days!==0){let P=365*x.years+30*x.months+x.days;p=this.addDaysIso(p,P),v=this.isoToCalendarDate(p,n),x=$j(o,v),x.years===0&&x.months===0?p=m(x.days):g=this.compareCalendarDates(o,v)}let S=8;for(;g;){p=this.addDaysIso(p,g*S);let P=v;v=this.isoToCalendarDate(p,n);let A=g;if(g=this.compareCalendarDates(o,v),g){if(x=$j(o,v),x.years===0&&x.months===0)p=m(x.days),g=0;else if(A&&g!==A)if(S>1)S/=2;else{if(r==="reject")throw new RangeError(`Can't find ISO date from calendar date: ${JSON.stringify({...i})}`);this.compareCalendarDates(v,P)>0&&(p=this.addDaysIso(p,-1)),g=0}}}if(n.set(u,p),c&&n.set(c,p),o.year===void 0||o.month===void 0||o.day===void 0||o.monthCode===void 0||this.hasEra&&(o.era===void 0||o.eraYear===void 0))throw new RangeError("Unexpected missing property");return p}temporalToCalendarDate(e,r){let n={year:R(e,De),month:R(e,Oe),day:R(e,je)};return this.isoToCalendarDate(n,r)}compareCalendarDates(e,r){let n=Ct(e,["day","month","year"],["day","month","year"]),i=Ct(r,["day","month","year"],["day","month","year"]);return n.year!==i.year?tv(n.year-i.year):n.month!==i.month?tv(n.month-i.month):n.day!==i.day?tv(n.day-i.day):0}regulateDate(e,r="constrain",n){let i=this.calendarToIsoDate(e,r,n);return this.isoToCalendarDate(i,n)}addDaysIso(e,r){return ev(e.year,e.month,e.day,0,0,0,r,"constrain")}addDaysCalendar(e,r,n){let i=this.calendarToIsoDate(e,"constrain",n),o=this.addDaysIso(i,r);return this.isoToCalendarDate(o,n)}addMonthsCalendar(e,r,n,i){let o=e,{day:s}=o;for(let a=0,d=Aqe(r);a0){let g=this.monthsInYear(c,i);for(;o.month-1!=u%g;)m=this.addDaysIso(m,-1),o=this.isoToCalendarDate(m,i)}o.day!==s&&(o=this.regulateDate({...o,day:s},"constrain",i))}if(n==="reject"&&o.day!==s)throw new RangeError(`Day ${s} does not exist in resulting calendar month`);return o}addCalendar(e,{years:r=0,months:n=0,weeks:i=0,days:o=0},s,a){let{year:d,day:u,monthCode:c}=e,l=this.adjustCalendarDate({year:d+r,monthCode:c,day:u},a),p=this.addMonthsCalendar(l,n,s,a),m=o+7*i;return this.addDaysCalendar(p,m,a)}untilCalendar(e,r,n,i){let o=0,s=0,a=0,d=0;switch(n){case"day":o=this.calendarDaysUntil(e,r,i);break;case"week":{let u=this.calendarDaysUntil(e,r,i);o=u%7,s=(u-o)/7;break}case"month":case"year":{let u=this.compareCalendarDates(r,e);if(!u)return{years:0,months:0,weeks:0,days:0};let c=r.year-e.year,l=r.day-e.day;if(n==="year"&&c){let g=0;r.monthCode>e.monthCode&&(g=1),r.monthCode=0);a-=u,o=this.calendarDaysUntil(p,r,i);break}}return{years:d,months:a,weeks:s,days:o}}daysInMonth(e,r){let{day:n}=e,i=this.maximumMonthLength(e),o=this.minimumMonthLength(e);if(o===i)return o;let s=n<=i-o?i:o,a=this.calendarToIsoDate(e,"constrain",r),d=this.addDaysIso(a,s),u=this.isoToCalendarDate(d,r),c=this.addDaysIso(d,-u.day);return this.isoToCalendarDate(c,r).day}daysInPreviousMonth(e,r){let{day:n,month:i,year:o}=e,s={year:i>1?o:o-1,month:i,day:1},a=i>1?i-1:this.monthsInYear(s,r);s={...s,month:a};let d=this.minimumMonthLength(s),u=this.maximumMonthLength(s);if(d===u)return u;let c=this.calendarToIsoDate(e,"constrain",r),l=this.addDaysIso(c,-n);return this.isoToCalendarDate(l,r).day}startOfCalendarYear(e){return{year:e.year,month:1,monthCode:"M01",day:1}}startOfCalendarMonth(e){return{year:e.year,month:e.month,day:1}}calendarDaysUntil(e,r,n){let i=this.calendarToIsoDate(e,"constrain",n),o=this.calendarToIsoDate(r,"constrain",n);return this.isoDaysUntil(i,o)}isoDaysUntil(e,r){return kN(e.year,e.month,e.day,r.year,r.month,r.day,"day").days}monthDayFromFields(e,r,n){let i,o,s,a,d,{monthCode:u,day:c}=e;if(u===void 0){let{year:m,era:g,eraYear:v}=e;if(m===void 0&&(g===void 0||v===void 0))throw new TypeError("when `monthCode` is omitted, `year` (or `era` and `eraYear`) and `month` are required");({monthCode:u,day:c}=this.isoToCalendarDate(this.calendarToIsoDate(e,r,n),n))}let l=this.isoToCalendarDate({year:1972,month:12,day:31},n),p=l.monthCode>u||l.monthCode===u&&l.day>=c?l.year:l.year-1;for(let m=0;m<100;m++){let g=this.adjustCalendarDate({day:c,monthCode:u,year:p-m},n),v=this.calendarToIsoDate(g,"constrain",n),x=this.isoToCalendarDate(v,n);if({year:i,month:o,day:s}=v,x.monthCode===u&&x.day===c)return{month:o,day:s,year:i};r==="constrain"&&(a===void 0||x.monthCode===a.monthCode&&x.day>a.day)&&(a=x,d=v)}if(r==="constrain"&&d!==void 0)return d;throw new RangeError(`No recent ${this.id} year with monthCode ${u} and day ${c}`)}},Zj=class extends Qm{constructor(){super(...arguments),this.id="hebrew",this.calendarType="lunisolar",this.months={Tishri:{leap:1,regular:1,monthCode:"M01",days:30},Heshvan:{leap:2,regular:2,monthCode:"M02",days:{min:29,max:30}},Kislev:{leap:3,regular:3,monthCode:"M03",days:{min:29,max:30}},Tevet:{leap:4,regular:4,monthCode:"M04",days:29},Shevat:{leap:5,regular:5,monthCode:"M05",days:30},Adar:{leap:void 0,regular:6,monthCode:"M06",days:29},"Adar I":{leap:6,regular:void 0,monthCode:"M05L",days:30},"Adar II":{leap:7,regular:void 0,monthCode:"M06",days:29},Nisan:{leap:8,regular:7,monthCode:"M07",days:30},Iyar:{leap:9,regular:8,monthCode:"M08",days:29},Sivan:{leap:10,regular:9,monthCode:"M09",days:30},Tamuz:{leap:11,regular:10,monthCode:"M10",days:29},Av:{leap:12,regular:11,monthCode:"M11",days:30},Elul:{leap:13,regular:12,monthCode:"M12",days:29}},this.hasEra=!1}inLeapYear(e){let{year:r}=e;return(7*r+1)%19<7}monthsInYear(e){return this.inLeapYear(e)?13:12}minimumMonthLength(e){return this.minMaxMonthLength(e,"min")}maximumMonthLength(e){return this.minMaxMonthLength(e,"max")}minMaxMonthLength(e,r){let{month:n,year:i}=e,o=this.getMonthCode(i,n),s=Jj(this.months).find(d=>d[1].monthCode===o);if(s===void 0)throw new RangeError(`unmatched Hebrew month: ${n}`);let a=s[1].days;return typeof a=="number"?a:a[r]}estimateIsoDate(e){let{year:r}=e;return{year:r-3760,month:1,day:1}}getMonthCode(e,r){return this.inLeapYear({year:e})?r===6?Lh(5,!0):Lh(r<6?r:r-1):Lh(r)}adjustCalendarDate(e,r,n="constrain",i=!1){let{year:o,eraYear:s,month:a,monthCode:d,day:u,monthExtra:c}=e;if(o===void 0&&s!==void 0&&(o=s),s===void 0&&o!==void 0&&(s=o),i){if(c){let l=this.months[c];if(!l)throw new RangeError(`Unrecognized month from formatToParts: ${c}`);a=this.inLeapYear({year:o})?l.leap:l.regular}return d=this.getMonthCode(o,a),{year:o,month:a,day:u,era:void 0,eraYear:s,monthCode:d}}if(this.validateCalendarDate(e),a===void 0)if(d.endsWith("L")){if(d!=="M05L")throw new RangeError(`Hebrew leap month must have monthCode M05L, not ${d}`);if(a=6,!this.inLeapYear({year:o})){if(n==="reject")throw new RangeError(`Hebrew monthCode M05L is invalid in year ${o} which is not a leap year`);a=6,d="M06"}}else{a=jN(d),this.inLeapYear({year:o})&&a>=6&&a++;let l=this.monthsInYear({year:o});if(a<1||a>l)throw new RangeError(`Invalid monthCode: ${d}`)}else if(n==="reject"?(fo(a,1,this.monthsInYear({year:o})),fo(u,1,this.maximumMonthLength({year:o,month:a}))):(a=Ra(a,1,this.monthsInYear({year:o})),u=Ra(u,1,this.maximumMonthLength({year:o,month:a}))),d===void 0)d=this.getMonthCode(o,a);else if(this.getMonthCode(o,a)!==d)throw new RangeError(`monthCode ${d} doesn't correspond to month ${a} in Hebrew year ${o}`);return{...e,day:u,month:a,monthCode:d,year:o,eraYear:s}}},ey=class extends Qm{constructor(){super(...arguments),this.calendarType="lunar",this.DAYS_PER_ISLAMIC_YEAR=354+11/30,this.DAYS_PER_ISO_YEAR=365.2425,this.constantEra="ah"}inLeapYear(e,r){return this.daysInMonth({year:e.year,month:12,day:1},r)===30}monthsInYear(){return 12}minimumMonthLength(){return 29}maximumMonthLength(){return 30}estimateIsoDate(e){let{year:r}=this.adjustCalendarDate(e);return{year:Tqe(r*this.DAYS_PER_ISLAMIC_YEAR/this.DAYS_PER_ISO_YEAR)+622,month:1,day:1}}},fP=class extends ey{constructor(){super(...arguments),this.id="islamic"}},Yj=class extends ey{constructor(){super(...arguments),this.id="islamic-umalqura"}},Xj=class extends ey{constructor(){super(...arguments),this.id="islamic-tbla"}},Qj=class extends ey{constructor(){super(...arguments),this.id="islamic-civil"}},eN=class extends ey{constructor(){super(...arguments),this.id="islamic-rgsa"}},tN=class extends ey{constructor(){super(...arguments),this.id="islamicc"}},rN=class extends Qm{constructor(){super(...arguments),this.id="persian",this.calendarType="solar",this.constantEra="ap"}inLeapYear(e,r){return fP.prototype.inLeapYear.call(this,e,r)}monthsInYear(){return 12}minimumMonthLength(e){let{month:r}=e;return r===12?29:r<=6?31:30}maximumMonthLength(e){let{month:r}=e;return r===12?30:r<=6?31:30}estimateIsoDate(e){let{year:r}=this.adjustCalendarDate(e);return{year:r+621,month:1,day:1}}},nN=class extends Qm{constructor(){super(...arguments),this.id="indian",this.calendarType="solar",this.constantEra="saka",this.months={1:{length:30,month:3,day:22,leap:{length:31,month:3,day:21}},2:{length:31,month:4,day:21},3:{length:31,month:5,day:22},4:{length:31,month:6,day:22},5:{length:31,month:7,day:23},6:{length:31,month:8,day:23},7:{length:30,month:9,day:23},8:{length:30,month:10,day:23},9:{length:30,month:11,day:22},10:{length:30,month:12,day:22},11:{length:30,month:1,nextYear:!0,day:21},12:{length:30,month:2,nextYear:!0,day:20}},this.vulnerableToBceBug=new Date("0000-01-01T00:00Z").toLocaleDateString("en-US-u-ca-indian",{timeZone:"UTC"})!=="10/11/-79 Saka"}inLeapYear(e){return sle(e.year+78)}monthsInYear(){return 12}minimumMonthLength(e){return this.getMonthInfo(e).length}maximumMonthLength(e){return this.getMonthInfo(e).length}getMonthInfo(e){let{month:r}=e,n=this.months[r];if(n===void 0)throw new RangeError(`Invalid month: ${r}`);return this.inLeapYear(e)&&n.leap&&(n=n.leap),n}estimateIsoDate(e){let r=this.adjustCalendarDate(e),n=this.getMonthInfo(r);return ev(r.year+78+(n.nextYear?1:0),n.month,n.day,0,0,0,r.day-1,"constrain")}checkIcuBugs(e){if(this.vulnerableToBceBug&&e.year<1)throw new RangeError(`calendar '${this.id}' is broken for ISO dates before 0001-01-01 (see https://bugs.chromium.org/p/v8/issues/detail?id=10529)`)}};function sle(t){return t%4==0&&(t%100!=0||t%400==0)}var cv=class extends Qm{constructor(e,r){super(),this.calendarType="solar",this.v8IsVulnerableToJulianBug=new Date("+001001-01-01T00:00Z").toLocaleDateString("en-US-u-ca-japanese",{timeZone:"UTC"}).startsWith("12"),this.calendarIsVulnerableToJulianBug=!1,this.id=e;let{eras:n,anchorEra:i}=function(s){let a,d=s;if(d.length===0)throw new RangeError("Invalid era data: eras are required");if(d.length===1&&d[0].reverseOf)throw new RangeError("Invalid era data: anchor era cannot count years backwards");if(d.length===1&&!d[0].name)throw new RangeError("Invalid era data: at least one named era is required");if(d.filter(c=>c.reverseOf!=null).length>1)throw new RangeError("Invalid era data: only one era can count years backwards");d.forEach(c=>{if(c.isAnchor||!c.anchorEpoch&&!c.reverseOf){if(a)throw new RangeError("Invalid era data: cannot have multiple anchor eras");a=c,c.anchorEpoch={year:c.hasYearZero?0:1}}else if(!c.name)throw new RangeError("If era name is blank, it must be the anchor era")}),d=d.filter(c=>c.name),d.forEach(c=>{let{reverseOf:l}=c;if(l){let p=d.find(m=>m.name===l);if(p===void 0)throw new RangeError(`Invalid era data: unmatched reverseOf era: ${l}`);c.reverseOf=p,c.anchorEpoch=p.anchorEpoch,c.isoEpoch=p.isoEpoch}c.anchorEpoch.month===void 0&&(c.anchorEpoch.month=1),c.anchorEpoch.day===void 0&&(c.anchorEpoch.day=1)}),Sqe.call(d,(c,l)=>{if(c.reverseOf)return 1;if(l.reverseOf)return-1;if(!c.isoEpoch||!l.isoEpoch)throw new RangeError("Invalid era data: missing ISO epoch");return l.isoEpoch.year-c.isoEpoch.year});let u=d[d.length-1].reverseOf;if(u&&u!==d[d.length-2])throw new RangeError("Invalid era data: invalid reverse-sign era");return d.forEach((c,l)=>{c.genericName="era"+(d.length-1-l)}),{eras:d,anchorEra:a||d[0]}}(r);this.anchorEra=i,this.eras=n}inLeapYear(e){let{year:r}=this.estimateIsoDate({month:1,day:1,year:e.year});return sle(r)}monthsInYear(){return 12}minimumMonthLength(e){let{month:r}=e;return r===2?this.inLeapYear(e)?29:28:[4,6,9,11].indexOf(r)>=0?30:31}maximumMonthLength(e){return this.minimumMonthLength(e)}completeEraYear(e){let r=(a,d)=>{let u=e[a];if(u!=null&&u!=d)throw new RangeError(`Input ${a} ${u} doesn't match calculated value ${d}`)},n=a=>{let d,u={...e,year:a},c=this.eras.find((l,p)=>{if(p===this.eras.length-1){if(l.reverseOf){if(a>0)throw new RangeError(`Signed year ${a} is invalid for era ${l.name}`);return d=l.anchorEpoch.year-a,!0}return d=a-l.anchorEpoch.year+(l.hasYearZero?0:1),!0}return this.compareCalendarDates(u,l.anchorEpoch)>=0&&(d=a-l.anchorEpoch.year+(l.hasYearZero?0:1),!0)});if(!c)throw new RangeError(`Year ${a} was not matched by any era`);return{eraYear:d,era:c.name}},{year:i,eraYear:o,era:s}=e;if(i!=null)({eraYear:o,era:s}=n(i)),r("era",s),r("eraYear",o);else{if(o==null)throw new RangeError("Either `year` or `eraYear` and `era` are required");{let a=s===void 0?void 0:this.eras.find(d=>d.name===s||d.genericName===s);if(!a)throw new RangeError(`Era ${s} (ISO year ${o}) was not matched by any era`);if(o<1&&a.reverseOf)throw new RangeError(`Years in ${s} era must be positive, not ${i}`);i=a.reverseOf?a.anchorEpoch.year-o:o+a.anchorEpoch.year-(a.hasYearZero?0:1),r("year",i),{eraYear:o,era:s}=n(i)}}return{...e,year:i,eraYear:o,era:s}}adjustCalendarDate(e,r,n="constrain"){let i=e,{month:o,monthCode:s}=i;return o===void 0&&(i={...i,month:jN(s)}),this.validateCalendarDate(i),i=this.completeEraYear(i),super.adjustCalendarDate(i,r,n)}estimateIsoDate(e){let r=this.adjustCalendarDate(e),{year:n,month:i,day:o}=r,{anchorEra:s}=this;return nP(n+s.isoEpoch.year-(s.hasYearZero?0:1),i,o,"constrain")}checkIcuBugs(e){if(this.calendarIsVulnerableToJulianBug&&this.v8IsVulnerableToJulianBug&&Vm(e.year,e.month,e.day,1582,10,15)<0)throw new RangeError(`calendar '${this.id}' is broken for ISO dates before 1582-10-15 (see https://bugs.chromium.org/p/chromium/issues/detail?id=1173158)`)}},_6=class extends cv{constructor(e,r){super(e,r)}inLeapYear(e){let{year:r}=e;return(r+1)%4==0}monthsInYear(){return 13}minimumMonthLength(e){let{month:r}=e;return r===13?this.inLeapYear(e)?6:5:30}maximumMonthLength(e){return this.minimumMonthLength(e)}},iN=class extends _6{constructor(){super("ethioaa",[{name:"era0",isoEpoch:{year:-5492,month:7,day:17}}])}},oN=class extends _6{constructor(){super("coptic",[{name:"era1",isoEpoch:{year:284,month:8,day:29}},{name:"era0",reverseOf:"era1"}])}},sN=class extends _6{constructor(){super("ethiopic",[{name:"era0",isoEpoch:{year:-5492,month:7,day:17}},{name:"era1",isoEpoch:{year:8,month:8,day:27},anchorEpoch:{year:5501}}])}},aN=class extends cv{constructor(){super("roc",[{name:"minguo",isoEpoch:{year:1912,month:1,day:1}},{name:"before-roc",reverseOf:"minguo"}]),this.calendarIsVulnerableToJulianBug=!0}},cN=class extends cv{constructor(){super("buddhist",[{name:"be",hasYearZero:!0,isoEpoch:{year:-543,month:1,day:1}}]),this.calendarIsVulnerableToJulianBug=!0}},dN=class extends cv{constructor(){super("gregory",[{name:"ce",isoEpoch:{year:1,month:1,day:1}},{name:"bce",reverseOf:"ce"}])}reviseIntlEra(e){let{era:r,eraYear:n}=e;return r!=="bc"&&r!=="b"||(r="bce"),r!=="ad"&&r!=="a"||(r="ce"),{era:r,eraYear:n}}},uN=class extends cv{constructor(){super("japanese",[{name:"reiwa",isoEpoch:{year:2019,month:5,day:1},anchorEpoch:{year:2019,month:5,day:1}},{name:"heisei",isoEpoch:{year:1989,month:1,day:8},anchorEpoch:{year:1989,month:1,day:8}},{name:"showa",isoEpoch:{year:1926,month:12,day:25},anchorEpoch:{year:1926,month:12,day:25}},{name:"taisho",isoEpoch:{year:1912,month:7,day:30},anchorEpoch:{year:1912,month:7,day:30}},{name:"meiji",isoEpoch:{year:1868,month:9,day:8},anchorEpoch:{year:1868,month:9,day:8}},{name:"ce",isoEpoch:{year:1,month:1,day:1}},{name:"bce",reverseOf:"ce"}]),this.calendarIsVulnerableToJulianBug=!0,this.eraLength="long",this.erasBeginMidYear=!0}reviseIntlEra(e,r){let{era:n,eraYear:i}=e,{year:o}=r;return this.eras.find(s=>s.name===n)?{era:n,eraYear:i}:o<1?{era:"bce",eraYear:1-o}:{era:"ce",eraYear:o}}},hP=class extends Qm{constructor(){super(...arguments),this.calendarType="lunisolar",this.hasEra=!1}inLeapYear(e,r){let n=this.getMonthList(e.year,r);return Jj(n).length===13}monthsInYear(e,r){return this.inLeapYear(e,r)?13:12}minimumMonthLength(){return 29}maximumMonthLength(){return 30}getMonthList(e,r){if(e===void 0)throw new TypeError("Missing year");let n=JSON.stringify({func:"getMonthList",calendarYear:e,id:this.id}),i=r.get(n);if(i)return i;let o=this.getFormatter(),s=(x,S)=>{let P=ole({isoYear:x,isoMonth:2,isoDay:1}),A=new Date(P);A.setUTCDate(S+1);let $=o.formatToParts(A),j=$.find(K=>K.type==="month").value,L=+$.find(K=>K.type==="day").value,F=$.find(K=>K.type==="relatedYear");if(F===void 0)throw new RangeError(`Intl.DateTimeFormat.formatToParts lacks relatedYear in ${this.id} calendar. Try Node 14+ or modern browsers.`);return F=+F.value,{calendarMonthString:j,calendarDay:L,calendarYearToVerify:F}},a=17,{calendarMonthString:d,calendarDay:u,calendarYearToVerify:c}=s(e,a);d!=="1"&&(a+=29,{calendarMonthString:d,calendarDay:u}=s(e,a)),a-=u-5;let l={},p,m,g=1,v=!1;do({calendarMonthString:d,calendarDay:u,calendarYearToVerify:c}=s(e,a)),p&&(l[m].daysInMonth=p+30-u),c!==e?v=!0:(l[d]={monthIndex:g++},a+=30),p=u,m=d;while(!v);return l[m].daysInMonth=p+30-u,r.set(n,l),l}estimateIsoDate(e){let{year:r,month:n}=e;return{year:r,month:n>=12?12:n+1,day:1}}adjustCalendarDate(e,r,n="constrain",i=!1){let{year:o,month:s,monthExtra:a,day:d,monthCode:u,eraYear:c}=e;if(i){if(o=c,a&&a!=="bis")throw new RangeError(`Unexpected leap month suffix: ${a}`);let l=Lh(s,a!==void 0),p=`${s}${a||""}`,m=this.getMonthList(o,r)[p];if(m===void 0)throw new RangeError(`Unmatched month ${p} in Chinese year ${o}`);return s=m.monthIndex,{year:o,month:s,day:d,era:void 0,eraYear:c,monthCode:l}}if(this.validateCalendarDate(e),o===void 0&&(o=c),c===void 0&&(c=o),s===void 0){let l=this.getMonthList(o,r),p=u.replace("L","bis").slice(1);p[0]==="0"&&(p=p.slice(1));let m=l[p];if(s=m&&m.monthIndex,s===void 0&&u.endsWith("L")&&u!="M13L"&&n==="constrain"){let g=u.slice(1,-1);g[0]==="0"&&(g=g.slice(1)),m=l[g],m&&(s=m.monthIndex,u=Lh(g))}if(s===void 0)throw new RangeError(`Unmatched month ${u} in Chinese year ${o}`)}else if(u===void 0){let l=this.getMonthList(o,r),p=Jj(l),m=p.length;n==="reject"?(fo(s,1,m),fo(d,1,this.maximumMonthLength())):(s=Ra(s,1,m),d=Ra(d,1,this.maximumMonthLength()));let g=p.find(([,v])=>v.monthIndex===s);if(g===void 0)throw new RangeError(`Invalid month ${s} in Chinese year ${o}`);u=Lh(g[0].replace("bis",""),g[0].indexOf("bis")!==-1)}else{let l=this.getMonthList(o,r),p=u.replace("L","bis").slice(1);p[0]==="0"&&(p=p.slice(1));let m=l[p];if(!m)throw new RangeError(`Unmatched monthCode ${u} in Chinese year ${o}`);if(s!==m.monthIndex)throw new RangeError(`monthCode ${u} doesn't correspond to month ${s} in Chinese year ${o}`)}return{...e,year:o,eraYear:c,month:s,monthCode:u,day:d}}},lN=class extends hP{constructor(){super(...arguments),this.id="chinese"}},fN=class extends hP{constructor(){super(...arguments),this.id="dangi"}},hN=class{constructor(e){this.helper=e}dateFromFields(e,r,n){let i=new wi,o=Ct(e,this.fields(["day","month","monthCode","year"]),[]),s=Yn(r),{year:a,month:d,day:u}=this.helper.calendarToIsoDate(o,s,i),c=Gc(a,d,u,n);return i.setObject(c),c}yearMonthFromFields(e,r,n){let i=new wi,o=Ct(e,this.fields(["month","monthCode","year"]),[]),s=Yn(r),{year:a,month:d,day:u}=this.helper.calendarToIsoDate({...o,day:1},s,i),c=v6(a,d,n,u);return i.setObject(c),c}monthDayFromFields(e,r,n){let i=new wi,o=Ct(e,this.fields(["day","month","monthCode","year"]),[]),s=Yn(r),{year:a,month:d,day:u}=this.helper.monthDayFromFields(o,s,i),c=g6(d,u,n,a);return i.setObject(c),c}fields(e){let r=e;return rle.call(r,"year")&&(r=[...r,"era","eraYear"]),r}fieldKeysToIgnore(e){let r=new nle;for(let n=0;nnew(Ae("%Temporal.Instant%"))(ON()),tue=(t,e=Hm())=>{let r=Lo(e),n=Ma(t);return oc(r,NN(),n)},jj=(t=Hm())=>oc(Lo(t),NN(),"iso8601"),rue=(t,e=Hm())=>{let r=Lo(e),n=Ma(t);return uo(ON(),r,n)},ale={instant:NN,plainDateTime:tue,plainDateTimeISO:jj,plainDate:(t,e=Hm())=>J1(tue(t,e)),plainDateISO:(t=Hm())=>J1(jj(t)),plainTimeISO:(t=Hm())=>SN(jj(t)),timeZoneId:()=>Hm(),zonedDateTime:rue,zonedDateTimeISO:(t=Hm())=>rue("iso8601",t),[Symbol.toStringTag]:"Temporal.Now"};Object.defineProperty(ale,Symbol.toStringTag,{value:"Temporal.Now",writable:!1,enumerable:!1,configurable:!0});var Iqe=Object.assign;function nue(t,e,r){let n=R(t,St),i=R(t,At),o=R(t,Tt),s=R(t,Pt),a=R(t,It),d=R(t,kt);if(r){let{unit:u,increment:c,roundingMode:l}=r;({hour:n,minute:i,second:o,millisecond:s,microsecond:a,nanosecond:d}=MN(n,i,o,s,a,d,c,u,l))}return`${bn(n)}:${bn(i)}${TP(o,s,a,d,e)}`}var T6=class t{constructor(e=0,r=0,n=0,i=0,o=0,s=0){let a=e===void 0?0:vr(e),d=r===void 0?0:vr(r),u=n===void 0?0:vr(n),c=i===void 0?0:vr(i),l=o===void 0?0:vr(o),p=s===void 0?0:vr(s);kP(a,d,u,c,l,p),ff(this),Mt(this,St,a),Mt(this,At,d),Mt(this,Tt,u),Mt(this,Pt,c),Mt(this,It,l),Mt(this,kt,p)}get hour(){if(!jn(this))throw new TypeError("invalid receiver");return R(this,St)}get minute(){if(!jn(this))throw new TypeError("invalid receiver");return R(this,At)}get second(){if(!jn(this))throw new TypeError("invalid receiver");return R(this,Tt)}get millisecond(){if(!jn(this))throw new TypeError("invalid receiver");return R(this,Pt)}get microsecond(){if(!jn(this))throw new TypeError("invalid receiver");return R(this,It)}get nanosecond(){if(!jn(this))throw new TypeError("invalid receiver");return R(this,kt)}with(e,r){if(!jn(this))throw new TypeError("invalid receiver");if(!cn(e))throw new TypeError("invalid argument");e2(e);let n=Yn(tr(r)),i=oP(e,"partial"),o=oP(this),{hour:s,minute:a,second:d,millisecond:u,microsecond:c,nanosecond:l}=Iqe(o,i);return{hour:s,minute:a,second:d,millisecond:u,microsecond:c,nanosecond:l}=yP(s,a,d,u,c,l,n),new t(s,a,d,u,c,l)}add(e){if(!jn(this))throw new TypeError("invalid receiver");return Yde("add",this,e)}subtract(e){if(!jn(this))throw new TypeError("invalid receiver");return Yde("subtract",this,e)}until(e,r){if(!jn(this))throw new TypeError("invalid receiver");return Wde("until",this,e,r)}since(e,r){if(!jn(this))throw new TypeError("invalid receiver");return Wde("since",this,e,r)}round(e){if(!jn(this))throw new TypeError("invalid receiver");if(e===void 0)throw new TypeError("options parameter is required");let r=typeof e=="string"?Y1("smallestUnit",e):tr(e),n=t2(r),i=Wu(r,"halfExpand"),o=Ba(r,"smallestUnit","time",nv);r2(n,{hour:24,minute:60,second:60,millisecond:1e3,microsecond:1e3,nanosecond:1e3}[o],!1);let s=R(this,St),a=R(this,At),d=R(this,Tt),u=R(this,Pt),c=R(this,It),l=R(this,kt);return{hour:s,minute:a,second:d,millisecond:u,microsecond:c,nanosecond:l}=MN(s,a,d,u,c,l,n,o,i),new t(s,a,d,u,c,l)}equals(e){if(!jn(this))throw new TypeError("invalid receiver");let r=Nh(e);for(let n of[St,At,Tt,Pt,It,kt])if(R(this,n)!==R(r,n))return!1;return!0}toString(e){if(!jn(this))throw new TypeError("invalid receiver");let r=tr(e),n=M6(r),i=Wu(r,"trunc"),o=Ba(r,"smallestUnit","time",void 0);if(o==="hour")throw new RangeError('smallestUnit must be a time unit other than "hour"');let{precision:s,unit:a,increment:d}=O6(o,n);return nue(this,s,{unit:a,increment:d,roundingMode:i})}toJSON(){if(!jn(this))throw new TypeError("invalid receiver");return nue(this,"auto")}toLocaleString(e,r){if(!jn(this))throw new TypeError("invalid receiver");return new Hh(e,r).format(this)}valueOf(){throw new TypeError("use compare() or equals() to compare Temporal.PlainTime")}toPlainDateTime(e){if(!jn(this))throw new TypeError("invalid receiver");let r=Lr(e),n=R(r,De),i=R(r,Oe),o=R(r,je),s=R(r,fe);return ka(n,i,o,R(this,St),R(this,At),R(this,Tt),R(this,Pt),R(this,It),R(this,kt),s)}toZonedDateTime(e){if(!jn(this))throw new TypeError("invalid receiver");if(!cn(e))throw new TypeError("invalid argument");let r=e.plainDate;if(r===void 0)throw new TypeError("missing date property");let n=Lr(r),i=e.timeZone;if(i===void 0)throw new TypeError("missing timeZone property");let o=Lo(i),s=R(n,De),a=R(n,Oe),d=R(n,je),u=R(n,fe),c=R(this,St),l=R(this,At),p=R(this,Tt),m=R(this,Pt),g=R(this,It),v=R(this,kt);return uo(R(ws(o,new(Ae("%Temporal.PlainDateTime%"))(s,a,d,c,l,p,m,g,v,u),"compatible"),ut),o,u)}getISOFields(){if(!jn(this))throw new TypeError("invalid receiver");return{isoHour:R(this,St),isoMicrosecond:R(this,It),isoMillisecond:R(this,Pt),isoMinute:R(this,At),isoNanosecond:R(this,kt),isoSecond:R(this,Tt)}}static from(e,r){let n=Yn(tr(r));return jn(e)?new t(R(e,St),R(e,At),R(e,Tt),R(e,Pt),R(e,It),R(e,kt)):Nh(e,n)}static compare(e,r){let n=Nh(e),i=Nh(r);for(let o of[St,At,Tt,Pt,It,kt]){let s=R(n,o),a=R(i,o);if(s!==a)return tv(s-a)}return 0}};lf(T6,"Temporal.PlainTime");var rv=class{constructor(e){if(arguments.length<1)throw new RangeError("missing argument: identifier is required");let r=AN(e);ff(this),Mt(this,nf,r)}get id(){if(!zc(this))throw new TypeError("invalid receiver");return R(this,nf)}getOffsetNanosecondsFor(e){if(!zc(this))throw new TypeError("invalid receiver");let r=zu(e),n=R(this,nf);return $1(n)?Jm(n):Uh(n,R(r,ut))}getOffsetStringFor(e){if(!zc(this))throw new TypeError("invalid receiver");return Fj(this,zu(e))}getPlainDateTimeFor(e,r="iso8601"){if(!zc(this))throw new TypeError("invalid receiver");return oc(this,zu(e),Ma(r))}getInstantFor(e,r){if(!zc(this))throw new TypeError("invalid receiver");return ws(this,Qg(e),V1(tr(r)))}getPossibleInstantsFor(e){if(!zc(this))throw new TypeError("invalid receiver");let r=Qg(e),n=Ae("%Temporal.Instant%"),i=R(this,nf);if($1(i)){let s=Zm(R(r,De),R(r,Oe),R(r,je),R(r,St),R(r,At),R(r,Tt),R(r,Pt),R(r,It),R(r,kt));if(s===null)throw new RangeError("DateTime outside of supported range");let a=Jm(i);return[new n(z.default.subtract(s,z.default.BigInt(a)))]}return function(a,d,u,c,l,p,m,g,v,x){let S=Zm(d,u,c,l,p,m,g,v,x);if(S===null)throw new RangeError("DateTime outside of supported range");let P=z.default.subtract(S,cf);z.default.lessThan(P,y6)&&(P=S);let A=z.default.add(S,cf);z.default.greaterThan(A,W1)&&(A=S);let $=Uh(a,P),j=Uh(a,A);return($===j?[$]:[$,j]).map(L=>{let F=z.default.subtract(S,z.default.BigInt(L)),K=Due(a,F);if(d===K.year&&u===K.month&&c===K.day&&l===K.hour&&p===K.minute&&m===K.second&&g===K.millisecond&&v===K.microsecond&&x===K.nanosecond)return F}).filter(L=>L!==void 0)}(i,R(r,De),R(r,Oe),R(r,je),R(r,St),R(r,At),R(r,Tt),R(r,Pt),R(r,It),R(r,kt)).map(s=>new n(s))}getNextTransition(e){if(!zc(this))throw new TypeError("invalid receiver");let r=zu(e),n=R(this,nf);if($1(n)||n==="UTC")return null;let i=R(r,ut),o=Ae("%Temporal.Instant%");return i=Mue(n,i),i===null?null:new o(i)}getPreviousTransition(e){if(!zc(this))throw new TypeError("invalid receiver");let r=zu(e),n=R(this,nf);if($1(n)||n==="UTC")return null;let i=R(r,ut),o=Ae("%Temporal.Instant%");return i=zj(n,i),i===null?null:new o(i)}toString(){if(!zc(this))throw new TypeError("invalid receiver");return R(this,nf)}toJSON(){if(!zc(this))throw new TypeError("invalid receiver");return R(this,nf)}static from(e){return Tue(Lo(e))}};lf(rv,"Temporal.TimeZone"),In("Temporal.TimeZone.prototype.getOffsetNanosecondsFor",rv.prototype.getOffsetNanosecondsFor),In("Temporal.TimeZone.prototype.getPossibleInstantsFor",rv.prototype.getPossibleInstantsFor);var kqe=Object.create,P6=class{constructor(e,r,n="iso8601",i=1){Eue(this,vr(e),vr(r),Ma(n),vr(i))}get year(){if(!Sr(this))throw new TypeError("invalid receiver");return gP(R(this,fe),this)}get month(){if(!Sr(this))throw new TypeError("invalid receiver");return vP(R(this,fe),this)}get monthCode(){if(!Sr(this))throw new TypeError("invalid receiver");return $6(R(this,fe),this)}get calendarId(){if(!Sr(this))throw new TypeError("invalid receiver");return ho(R(this,fe))}get era(){if(!Sr(this))throw new TypeError("invalid receiver");return bP(R(this,fe),this)}get eraYear(){if(!Sr(this))throw new TypeError("invalid receiver");return wP(R(this,fe),this)}get daysInMonth(){if(!Sr(this))throw new TypeError("invalid receiver");return _P(R(this,fe),this)}get daysInYear(){if(!Sr(this))throw new TypeError("invalid receiver");return xP(R(this,fe),this)}get monthsInYear(){if(!Sr(this))throw new TypeError("invalid receiver");return EP(R(this,fe),this)}get inLeapYear(){if(!Sr(this))throw new TypeError("invalid receiver");return SP(R(this,fe),this)}with(e,r){if(!Sr(this))throw new TypeError("invalid receiver");if(!cn(e))throw new TypeError("invalid argument");e2(e);let n=tr(r),i=R(this,fe),o=oi(i,["month","monthCode","year"]),s=Ct(this,o,[]);return s=ov(i,s,Ct(e,o,"partial")),s=Ct(s,o,[]),sv(i,s,n)}add(e,r){if(!Sr(this))throw new TypeError("invalid receiver");return Xde("add",this,e,r)}subtract(e,r){if(!Sr(this))throw new TypeError("invalid receiver");return Xde("subtract",this,e,r)}until(e,r){if(!Sr(this))throw new TypeError("invalid receiver");return Hde("until",this,e,r)}since(e,r){if(!Sr(this))throw new TypeError("invalid receiver");return Hde("since",this,e,r)}equals(e){if(!Sr(this))throw new TypeError("invalid receiver");let r=f6(e);for(let n of[De,Oe,je])if(R(this,n)!==R(r,n))return!1;return U6(R(this,fe),R(r,fe))}toString(e){if(!Sr(this))throw new TypeError("invalid receiver");return jde(this,B6(tr(e)))}toJSON(){if(!Sr(this))throw new TypeError("invalid receiver");return jde(this)}toLocaleString(e,r){if(!Sr(this))throw new TypeError("invalid receiver");return new Hh(e,r).format(this)}valueOf(){throw new TypeError("use compare() or equals() to compare Temporal.PlainYearMonth")}toPlainDate(e){if(!Sr(this))throw new TypeError("invalid receiver");if(!cn(e))throw new TypeError("argument should be an object");let r=R(this,fe),n=oi(r,["monthCode","year"]),i=Ct(this,n,[]),o=oi(r,["day"]),s=ov(r,i,Ct(e,o,[]));s=Ct(s,[...new Set([...n,...o])],[]);let a=kqe(null);return a.overflow="reject",Kh(r,s,a)}getISOFields(){if(!Sr(this))throw new TypeError("invalid receiver");return{calendar:R(this,fe),isoDay:R(this,je),isoMonth:R(this,Oe),isoYear:R(this,De)}}getCalendar(){if(!Sr(this))throw new TypeError("invalid receiver");return n2(R(this,fe))}static from(e,r){let n=tr(r);return Sr(e)?(Yn(n),v6(R(e,De),R(e,Oe),R(e,fe),R(e,je))):f6(e,n)}static compare(e,r){let n=f6(e),i=f6(r);return Vm(R(n,De),R(n,Oe),R(n,je),R(i,De),R(i,Oe),R(i,je))}};lf(P6,"Temporal.PlainYearMonth");var Rqe=Hh.prototype.resolvedOptions,Dqe=Object.create,I6=class{constructor(e,r,n="iso8601"){if(arguments.length<1)throw new TypeError("missing argument: epochNanoseconds is required");Sue(this,p6(e),Lo(r),Ma(n))}get calendarId(){if(!Ke(this))throw new TypeError("invalid receiver");return ho(R(this,fe))}get timeZoneId(){if(!Ke(this))throw new TypeError("invalid receiver");return b6(R(this,Nr))}get year(){if(!Ke(this))throw new TypeError("invalid receiver");return gP(R(this,fe),sn(this))}get month(){if(!Ke(this))throw new TypeError("invalid receiver");return vP(R(this,fe),sn(this))}get monthCode(){if(!Ke(this))throw new TypeError("invalid receiver");return $6(R(this,fe),sn(this))}get day(){if(!Ke(this))throw new TypeError("invalid receiver");return j6(R(this,fe),sn(this))}get hour(){if(!Ke(this))throw new TypeError("invalid receiver");return R(sn(this),St)}get minute(){if(!Ke(this))throw new TypeError("invalid receiver");return R(sn(this),At)}get second(){if(!Ke(this))throw new TypeError("invalid receiver");return R(sn(this),Tt)}get millisecond(){if(!Ke(this))throw new TypeError("invalid receiver");return R(sn(this),Pt)}get microsecond(){if(!Ke(this))throw new TypeError("invalid receiver");return R(sn(this),It)}get nanosecond(){if(!Ke(this))throw new TypeError("invalid receiver");return R(sn(this),kt)}get era(){if(!Ke(this))throw new TypeError("invalid receiver");return bP(R(this,fe),sn(this))}get eraYear(){if(!Ke(this))throw new TypeError("invalid receiver");return wP(R(this,fe),sn(this))}get epochSeconds(){if(!Ke(this))throw new TypeError("invalid receiver");let e=R(this,ut);return z.default.toNumber(q1(e,sf))}get epochMilliseconds(){if(!Ke(this))throw new TypeError("invalid receiver");let e=R(this,ut);return z.default.toNumber(q1(e,Hc))}get epochMicroseconds(){if(!Ke(this))throw new TypeError("invalid receiver");return lP(q1(R(this,ut),Ar))}get epochNanoseconds(){if(!Ke(this))throw new TypeError("invalid receiver");return lP(R(this,ut))}get dayOfWeek(){if(!Ke(this))throw new TypeError("invalid receiver");return bN(R(this,fe),sn(this))}get dayOfYear(){if(!Ke(this))throw new TypeError("invalid receiver");return wN(R(this,fe),sn(this))}get weekOfYear(){if(!Ke(this))throw new TypeError("invalid receiver");return _N(R(this,fe),sn(this))}get yearOfWeek(){if(!Ke(this))throw new TypeError("invalid receiver");return xN(R(this,fe),sn(this))}get hoursInDay(){if(!Ke(this))throw new TypeError("invalid receiver");let e=sn(this),r=Ae("%Temporal.PlainDateTime%"),n=R(e,De),i=R(e,Oe),o=R(e,je),s=new r(n,i,o,0,0,0,0,0,0),a=ev(n,i,o,0,0,0,1,"reject"),d=new r(a.year,a.month,a.day,0,0,0,0,0,0),u=R(this,Nr),c=R(ws(u,s,"compatible"),ut),l=R(ws(u,d,"compatible"),ut);return rf(z.default.subtract(l,c),mue)}get daysInWeek(){if(!Ke(this))throw new TypeError("invalid receiver");return EN(R(this,fe),sn(this))}get daysInMonth(){if(!Ke(this))throw new TypeError("invalid receiver");return _P(R(this,fe),sn(this))}get daysInYear(){if(!Ke(this))throw new TypeError("invalid receiver");return xP(R(this,fe),sn(this))}get monthsInYear(){if(!Ke(this))throw new TypeError("invalid receiver");return EP(R(this,fe),sn(this))}get inLeapYear(){if(!Ke(this))throw new TypeError("invalid receiver");return SP(R(this,fe),sn(this))}get offset(){if(!Ke(this))throw new TypeError("invalid receiver");return Fj(R(this,Nr),R(this,qo))}get offsetNanoseconds(){if(!Ke(this))throw new TypeError("invalid receiver");return Hu(R(this,Nr),R(this,qo))}with(e,r){if(!Ke(this))throw new TypeError("invalid receiver");if(!cn(e))throw new TypeError("invalid zoned-date-time-like");e2(e);let n=tr(r),i=R(this,fe),o=oi(i,["day","hour","microsecond","millisecond","minute","month","monthCode","nanosecond","second","year"]);o.push("offset");let s=Ct(this,o,["offset"]);s=ov(i,s,Ct(e,o,"partial")),s=Ct(s,o,["offset"]);let a=V1(n),d=iP(n,"prefer"),{year:u,month:c,day:l,hour:p,minute:m,second:g,millisecond:v,microsecond:x,nanosecond:S}=C6(i,s,n),P=Jm(s.offset),A=R(this,Nr);return uo(sP(u,c,l,p,m,g,v,x,S,"option",P,A,a,d,!1),A,i)}withPlainDate(e){if(!Ke(this))throw new TypeError("invalid receiver");let r=Lr(e),n=R(r,De),i=R(r,Oe),o=R(r,je),s=R(r,fe),a=sn(this),d=R(a,St),u=R(a,At),c=R(a,Tt),l=R(a,Pt),p=R(a,It),m=R(a,kt);s=Aue(R(this,fe),s);let g=R(this,Nr);return uo(R(ws(g,new(Ae("%Temporal.PlainDateTime%"))(n,i,o,d,u,c,l,p,m,s),"compatible"),ut),g,s)}withPlainTime(e){if(!Ke(this))throw new TypeError("invalid receiver");let r=Ae("%Temporal.PlainTime%"),n=e===void 0?new r:Nh(e),i=sn(this),o=R(i,De),s=R(i,Oe),a=R(i,je),d=R(this,fe),u=R(n,St),c=R(n,At),l=R(n,Tt),p=R(n,Pt),m=R(n,It),g=R(n,kt),v=R(this,Nr);return uo(R(ws(v,new(Ae("%Temporal.PlainDateTime%"))(o,s,a,u,c,l,p,m,g,d),"compatible"),ut),v,d)}withTimeZone(e){if(!Ke(this))throw new TypeError("invalid receiver");let r=Lo(e);return uo(R(this,ut),r,R(this,fe))}withCalendar(e){if(!Ke(this))throw new TypeError("invalid receiver");let r=Ma(e);return uo(R(this,ut),R(this,Nr),r)}add(e,r){if(!Ke(this))throw new TypeError("invalid receiver");return Qde("add",this,e,r)}subtract(e,r){if(!Ke(this))throw new TypeError("invalid receiver");return Qde("subtract",this,e,r)}until(e,r){if(!Ke(this))throw new TypeError("invalid receiver");return Vde("until",this,e,r)}since(e,r){if(!Ke(this))throw new TypeError("invalid receiver");return Vde("since",this,e,r)}round(e){if(!Ke(this))throw new TypeError("invalid receiver");if(e===void 0)throw new TypeError("options parameter is required");let r=typeof e=="string"?Y1("smallestUnit",e):tr(e),n=t2(r),i=Wu(r,"halfExpand"),o=Ba(r,"smallestUnit","time",nv,["day"]),s={day:1,hour:24,minute:60,second:60,millisecond:1e3,microsecond:1e3,nanosecond:1e3}[o];r2(n,s,s===1);let a=sn(this),d=R(a,De),u=R(a,Oe),c=R(a,je),l=R(a,St),p=R(a,At),m=R(a,Tt),g=R(a,Pt),v=R(a,It),x=R(a,kt),S=Ae("%Temporal.PlainDateTime%"),P=R(this,Nr),A=R(this,fe),$=ws(P,new S(R(a,De),R(a,Oe),R(a,je),0,0,0,0,0,0),"compatible"),j=Vc($,P,A,0,0,0,1,0,0,0,0,0,0),L=z.default.subtract(j,z.default.BigInt(R($,ut)));if(z.default.lessThanOrEqual(L,Nn))throw new RangeError("cannot round a ZonedDateTime in a calendar with zero or negative length days");return{year:d,month:u,day:c,hour:l,minute:p,second:m,millisecond:g,microsecond:v,nanosecond:x}=BN(d,u,c,l,p,m,g,v,x,n,o,i,z.default.toNumber(L)),uo(sP(d,u,c,l,p,m,g,v,x,"option",Hu(P,R(this,qo)),P,"compatible","prefer",!1),P,R(this,fe))}equals(e){if(!Ke(this))throw new TypeError("invalid receiver");let r=h6(e),n=R(this,ut),i=R(r,ut);return!!z.default.equal(z.default.BigInt(n),z.default.BigInt(i))&&!!Pue(R(this,Nr),R(r,Nr))&&U6(R(this,fe),R(r,fe))}toString(e){if(!Ke(this))throw new TypeError("invalid receiver");let r=tr(e),n=B6(r),i=M6(r),o=function(m){return Xm(m,"offset",["auto","never"],"auto")}(r),s=Wu(r,"trunc"),a=Ba(r,"smallestUnit","time",void 0);if(a==="hour")throw new RangeError('smallestUnit must be a time unit other than "hour"');let d=function(m){return Xm(m,"timeZoneName",["auto","never","critical"],"auto")}(r),{precision:u,unit:c,increment:l}=O6(a,i);return Nde(this,u,n,d,o,{unit:c,increment:l,roundingMode:s})}toLocaleString(e,r){if(!Ke(this))throw new TypeError("invalid receiver");let n=tr(r),i=Dqe(null);if(N1(i,n,["timeZone"]),n.timeZone!==void 0)throw new TypeError("ZonedDateTime toLocaleString does not accept a timeZone option");i.year===void 0&&i.month===void 0&&i.day===void 0&&i.weekday===void 0&&i.dateStyle===void 0&&i.hour===void 0&&i.minute===void 0&&i.second===void 0&&i.timeStyle===void 0&&i.dayPeriod===void 0&&i.timeZoneName===void 0&&(i.timeZoneName="short");let o=b6(R(this,Nr));if($1(o))throw new RangeError("toLocaleString does not support offset string time zones");o=AN(o),i.timeZone=o;let s=new Hh(e,i),a=Ge(Rqe,s,[]).calendar,d=ho(R(this,fe));if(d!=="iso8601"&&a!=="iso8601"&&a!==d)throw new RangeError(`cannot format ZonedDateTime with calendar ${d} in locale with calendar ${a}`);return s.format(R(this,qo))}toJSON(){if(!Ke(this))throw new TypeError("invalid receiver");return Nde(this,"auto")}valueOf(){throw new TypeError("use compare() or equals() to compare Temporal.ZonedDateTime")}startOfDay(){if(!Ke(this))throw new TypeError("invalid receiver");let e=sn(this),r=Ae("%Temporal.PlainDateTime%"),n=R(this,fe),i=new r(R(e,De),R(e,Oe),R(e,je),0,0,0,0,0,0,n),o=R(this,Nr);return uo(R(ws(o,i,"compatible"),ut),o,n)}toInstant(){if(!Ke(this))throw new TypeError("invalid receiver");return new(Ae("%Temporal.Instant%"))(R(this,ut))}toPlainDate(){if(!Ke(this))throw new TypeError("invalid receiver");return J1(sn(this))}toPlainTime(){if(!Ke(this))throw new TypeError("invalid receiver");return SN(sn(this))}toPlainDateTime(){if(!Ke(this))throw new TypeError("invalid receiver");return sn(this)}toPlainYearMonth(){if(!Ke(this))throw new TypeError("invalid receiver");let e=R(this,fe);return sv(e,Ct(this,oi(e,["monthCode","year"]),[]))}toPlainMonthDay(){if(!Ke(this))throw new TypeError("invalid receiver");let e=R(this,fe);return G1(e,Ct(this,oi(e,["day","monthCode"]),[]))}getISOFields(){if(!Ke(this))throw new TypeError("invalid receiver");let e=sn(this),r=R(this,Nr);return{calendar:R(this,fe),isoDay:R(e,je),isoHour:R(e,St),isoMicrosecond:R(e,It),isoMillisecond:R(e,Pt),isoMinute:R(e,At),isoMonth:R(e,Oe),isoNanosecond:R(e,kt),isoSecond:R(e,Tt),isoYear:R(e,De),offset:Fj(r,R(this,qo)),timeZone:r}}getCalendar(){if(!Ke(this))throw new TypeError("invalid receiver");return n2(R(this,fe))}getTimeZone(){if(!Ke(this))throw new TypeError("invalid receiver");return Tue(R(this,Nr))}static from(e,r){let n=tr(r);return Ke(e)?(V1(n),iP(n,"reject"),Yn(n),uo(R(e,ut),R(e,Nr),R(e,fe))):h6(e,n)}static compare(e,r){let n=h6(e),i=h6(r),o=R(n,ut),s=R(i,ut);return z.default.lessThan(z.default.BigInt(o),z.default.BigInt(s))?-1:z.default.greaterThan(z.default.BigInt(o),z.default.BigInt(s))?1:0}};function sn(t){return oc(R(t,Nr),R(t,qo),R(t,fe))}lf(I6,"Temporal.ZonedDateTime");var lv=Object.freeze({__proto__:null,Calendar:gn,Duration:S6,Instant:w6,Now:ale,PlainDate:x6,PlainDateTime:E6,PlainMonthDay:A6,PlainTime:T6,PlainYearMonth:P6,TimeZone:rv,ZonedDateTime:I6});var Bqe=[w6,gn,x6,E6,S6,A6,T6,rv,P6,I6];for(let t of Bqe){let e=Object.getOwnPropertyDescriptor(t,"prototype");(e.configurable||e.enumerable||e.writable)&&(e.configurable=!1,e.enumerable=!1,e.writable=!1,Object.defineProperty(t,"prototype",e))}var cle=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},pr=class t{static sleep(e){return cle(this,void 0,void 0,function*(){return new Promise(r=>setTimeout(r,e))})}static minimalSleep(){return cle(this,void 0,void 0,function*(){yield t.sleep(2)})}static getCurrentTimestamp(){return lv.Now.instant().toString({smallestUnit:"microseconds"})}static createTimestamp(e){let{year:r,month:n,day:i,hour:o,minute:s,second:a,millisecond:d,microsecond:u}=e;return lv.ZonedDateTime.from({timeZone:"UTC",year:r,month:n,day:i,hour:o,minute:s,second:a,millisecond:d,microsecond:u}).toInstant().toString({smallestUnit:"microseconds"})}static createOffsetTimestamp(e,r){let n=r?lv.Instant.from(r):lv.Now.instant(),i=lv.Duration.from(e);return n.add(i).toString({smallestUnit:"microseconds"})}static validateTimestamp(e){try{lv.Instant.from(e)}catch{throw new de(se.TimestampInvalid,`Invalid timestamp: ${e}`)}}};var xi=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Mqe=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);ir!=="").pop()}static createFrom(e){var r,n,i,o;return xi(this,void 0,void 0,function*(){let s=e.recordsWriteMessage,a=yield t.parse(s),d=pr.getCurrentTimestamp(),u=(r=e.published)!==null&&r!==void 0?r:e.datePublished?!0:s.descriptor.published,c;e.datePublished?c=e.datePublished:u&&(s.descriptor.published?c=s.descriptor.datePublished:c=d);let l={recipient:s.descriptor.recipient,recordId:s.recordId,dateCreated:s.descriptor.dateCreated,protocol:s.descriptor.protocol,protocolPath:s.descriptor.protocolPath,schema:s.descriptor.schema,parentContextId:lt.getParentContextFromOfContextId(s.contextId),messageTimestamp:(n=e.messageTimestamp)!==null&&n!==void 0?n:d,published:u,datePublished:c,tags:e.tags,data:e.data,dataCid:e.data?void 0:s.descriptor.dataCid,dataSize:e.data?void 0:s.descriptor.dataSize,dataFormat:(i=e.dataFormat)!==null&&i!==void 0?i:s.descriptor.dataFormat,protocolRole:(o=e.protocolRole)!==null&&o!==void 0?o:a.signaturePayload.protocolRole,delegatedGrant:e.delegatedGrant,signer:e.signer,attestationSigners:e.attestationSigners};return yield t.create(l)})}toJSON(){return this.message}encryptSymmetricEncryptionKey(e){return xi(this,void 0,void 0,function*(){this._message.encryption=yield t.createEncryptionProperty(this._message.descriptor,e),delete this._message.authorization,this._signaturePayload=void 0,this._author=void 0})}sign(e){var r;return xi(this,void 0,void 0,function*(){let{signer:n,delegatedGrant:i,permissionGrantId:o,protocolRole:s}=e,a,d;i!==void 0?(a=yield _e.getCid(i),d=tn.getSignerDid(i.authorization.signature.signatures[0])):d=tn.extractDid(n.keyId);let u=this._message.descriptor,c=yield fn.computeCid(u);this._message.recordId=(r=this._message.recordId)!==null&&r!==void 0?r:yield t.getEntryId(d,u),this._message.descriptor.protocol!==void 0&&(this.parentContextId===void 0||this.parentContextId===""?this._message.contextId=this._message.recordId:this._message.contextId=this.parentContextId+"/"+this._message.recordId);let l=yield t.createSignerSignature({recordId:this._message.recordId,contextId:this._message.contextId,descriptorCid:c,attestation:this._message.attestation,encryption:this._message.encryption,signer:n,delegatedGrantId:a,permissionGrantId:o,protocolRole:s});this._message.authorization={signature:l},i!==void 0&&(this._message.authorization.authorDelegatedGrant=i),this._signaturePayload=tn.decodePlainObjectPayload(l),this._author=d})}signAsOwner(e){return xi(this,void 0,void 0,function*(){if(this._author===void 0)throw new de(se.RecordsWriteSignAsOwnerUnknownAuthor,"Unable to sign as owner without message signature because owner needs to sign over `recordId` which depends on author DID.");let r=this._message.descriptor,n=yield _e.createSignature(r,e);this._message.authorization.ownerSignature=n,this._ownerSignaturePayload=tn.decodePlainObjectPayload(n),this._owner=tn.extractDid(e.keyId)})}signAsOwnerDelegate(e,r){return xi(this,void 0,void 0,function*(){if(this._author===void 0)throw new de(se.RecordsWriteSignAsOwnerDelegateUnknownAuthor,"Unable to sign as owner delegate without message signature because owner delegate needs to sign over `recordId` which depends on author DID.");let n=yield _e.getCid(r),i=this._message.descriptor,o=yield _e.createSignature(i,e,{delegatedGrantId:n});this._message.authorization.ownerSignature=o,this._message.authorization.ownerDelegatedGrant=r,this._ownerSignaturePayload=tn.decodePlainObjectPayload(o),this._owner=tn.getSignerDid(r.authorization.signature.signatures[0])})}validateIntegrity(){return xi(this,void 0,void 0,function*(){if(yield this.isInitialWrite()){let n=this.message.descriptor.dateCreated,i=this.message.descriptor.messageTimestamp;if(i!==n)throw new de(se.RecordsWriteValidateIntegrityDateCreatedMismatch,`messageTimestamp ${i} must match dateCreated ${n} for the initial write`);if(this.message.descriptor.protocol!==void 0&&this.message.descriptor.parentId===void 0){let o=yield this.getEntryId();if(this.message.contextId!==o)throw new de(se.RecordsWriteValidateIntegrityContextIdMismatch,`contextId in message: ${this.message.contextId} does not match deterministic contextId: ${o}`)}}let r=this.signaturePayload;if(this.message.recordId!==r.recordId)throw new de(se.RecordsWriteValidateIntegrityRecordIdUnauthorized,`recordId in message ${this.message.recordId} does not match recordId in authorization: ${r.recordId}`);if(this.message.contextId!==r.contextId)throw new de(se.RecordsWriteValidateIntegrityContextIdNotInSignerSignaturePayload,`contextId in message ${this.message.contextId} does not match contextId in authorization: ${r.contextId}`);if(yield lt.validateDelegatedGrantReferentialIntegrity(this.message,r,this.ownerSignaturePayload),r.attestationCid!==void 0){let n=yield fn.computeCid(this.message.attestation),i=r.attestationCid;if(i!==n)throw new de(se.RecordsWriteValidateIntegrityAttestationMismatch,`CID ${n} of attestation property in message does not match attestationCid in authorization: ${i}`)}if(r.encryptionCid!==void 0){let n=yield fn.computeCid(this.message.encryption),i=r.encryptionCid;if(i!==n)throw new de(se.RecordsWriteValidateIntegrityEncryptionCidMismatch,`CID ${n} of encryption property in message does not match encryptionCid in authorization: ${i}`)}this.message.descriptor.protocol!==void 0&&na(this.message.descriptor.protocol),this.message.descriptor.schema!==void 0&&Wm(this.message.descriptor.schema),pr.validateTimestamp(this.message.descriptor.messageTimestamp),pr.validateTimestamp(this.message.descriptor.dateCreated),this.message.descriptor.datePublished&&pr.validateTimestamp(this.message.descriptor.datePublished)})}static validateAttestationIntegrity(e){return xi(this,void 0,void 0,function*(){if(e.attestation===void 0)return;if(e.attestation.signatures.length!==1)throw new de(se.RecordsWriteAttestationIntegrityMoreThanOneSignature,`Currently implementation only supports 1 attester, but got ${e.attestation.signatures.length}`);let r=tn.decodePlainObjectPayload(e.attestation),{descriptorCid:n}=r,i=yield fn.computeCid(e.descriptor);if(n!==i)throw new de(se.RecordsWriteAttestationIntegrityDescriptorCidMismatch,`descriptorCid ${n} does not match expected descriptorCid ${i}`);let o=Object.keys(r).length;if(o>1)throw new de(se.RecordsWriteAttestationIntegrityInvalidPayloadProperty,`Only 'descriptorCid' is allowed in attestation payload, but got ${o} properties.`)})}getEntryId(){return xi(this,void 0,void 0,function*(){return yield t.getEntryId(this.author,this.message.descriptor)})}static getEntryId(e,r){return xi(this,void 0,void 0,function*(){if(e===void 0)throw new de(se.RecordsWriteGetEntryIdUndefinedAuthor,"Property `author` is needed to compute entry ID.");let n=Object.assign({},r);return n.author=e,yield fn.computeCid(n)})}isInitialWrite(){return xi(this,void 0,void 0,function*(){return(yield this.getEntryId())===this.message.recordId})}constructIndexes(e){return xi(this,void 0,void 0,function*(){let r=this.message,n=r.descriptor,{tags:i}=n,o=Mqe(n,["tags"]);delete o.published;let s=Object.assign(Object.assign({},o),{isLatestBaseState:e,published:!!r.descriptor.published,author:this.author,recordId:r.recordId,entryId:yield t.getEntryId(this.author,this.message.descriptor)});if(i!==void 0&&e===!0){let a=lt.buildTagIndexes(Object.assign({},i));s=Object.assign(Object.assign({},s),a)}return this.attesters.length>0&&(s.attester=this.attesters[0]),r.contextId!==void 0&&(s.contextId=r.contextId),s})}authorizeAuthorDelegate(e){return xi(this,void 0,void 0,function*(){let r=yield yn.parse(this.message.authorization.authorDelegatedGrant);yield us.authorizeWrite({recordsWriteMessage:this.message,expectedGrantor:this.author,expectedGrantee:this.signer,permissionGrant:r,messageStore:e})})}authorizeOwnerDelegate(e){return xi(this,void 0,void 0,function*(){let r=yield yn.parse(this.message.authorization.ownerDelegatedGrant);yield us.authorizeWrite({recordsWriteMessage:this.message,expectedGrantor:this.owner,expectedGrantee:this.ownerSignatureSigner,permissionGrant:r,messageStore:e})})}static isInitialWrite(e){return xi(this,void 0,void 0,function*(){if(e.descriptor.interface!==Te.Records||e.descriptor.method!==Se.Write)return!1;let r=e,n=_e.getAuthor(r);return(yield t.getEntryId(n,r.descriptor))===r.recordId})}static createEncryptionProperty(e,r){var n,i;return xi(this,void 0,void 0,function*(){if(r===void 0)return;let o=[];for(let a of r.keyEncryptionInputs){if(a.derivationScheme===co.ProtocolPath&&e.protocol===void 0)throw new de(se.RecordsWriteMissingProtocol,"`protocols` encryption scheme cannot be applied to record without the `protocol` property.");if(a.derivationScheme===co.Schemas&&e.schema===void 0)throw new de(se.RecordsWriteMissingSchema,"`schemas` encryption scheme cannot be applied to record without the `schema` property.");let d=Li.publicJwkToBytes(a.publicKey),u=yield Ch.eciesSecp256k1Encrypt(d,r.key),c=qe.bytesToBase64Url(u.ciphertext),l=yield Li.publicKeyToJwk(u.ephemeralPublicKey),p=qe.bytesToBase64Url(u.initializationVector),m=qe.bytesToBase64Url(u.messageAuthenticationCode),g={rootKeyId:a.publicKeyId,algorithm:(n=a.algorithm)!==null&&n!==void 0?n:Hg.EciesSecp256k1,derivationScheme:a.derivationScheme,ephemeralPublicKey:l,initializationVector:p,messageAuthenticationCode:m,encryptedKey:c};a.derivationScheme===co.ProtocolContext&&(g.derivedPublicKey=a.publicKey),o.push(g)}return{algorithm:(i=r.algorithm)!==null&&i!==void 0?i:Hg.Aes256Ctr,initializationVector:qe.bytesToBase64Url(r.initializationVector),keyEncryption:o}})}static createAttestation(e,r){return xi(this,void 0,void 0,function*(){if(r===void 0||r.length===0)return;let n={descriptorCid:e},i=qe.objectToBytes(n);return(yield Vg.create(i,r)).getJws()})}static createSignerSignature(e){return xi(this,void 0,void 0,function*(){let{recordId:r,contextId:n,descriptorCid:i,attestation:o,encryption:s,signer:a,delegatedGrantId:d,permissionGrantId:u,protocolRole:c}=e,l=o?yield fn.computeCid(o):void 0,p=s?yield fn.computeCid(s):void 0,m={recordId:r,descriptorCid:i,contextId:n,attestationCid:l,encryptionCid:p,delegatedGrantId:d,permissionGrantId:u,protocolRole:c};Tn(m);let g=qe.objectToBytes(m);return(yield Vg.create(g,[a])).getJws()})}static getInitialWrite(e){return xi(this,void 0,void 0,function*(){for(let r of e)if(yield t.isInitialWrite(r))return r;throw new de(se.RecordsWriteGetInitialWriteNotFound,"Initial write is not found.")})}static verifyEqualityOfImmutableProperties(e,r){let n=["dataCid","dataSize","dataFormat","datePublished","published","messageTimestamp","tags"],i=[];i.push(...Object.keys(e.descriptor)),i.push(...Object.keys(r.descriptor)),i=[...new Set(i)];for(let o of i)if(n.indexOf(o)===-1){let s=e.descriptor[o],a=r.descriptor[o];if(a!==s)throw new de(se.RecordsWriteImmutablePropertyChanged,`${o} is an immutable property: cannot change '${s}' to '${a}'`)}return!0}static getAttesters(e){var r,n;return((n=(r=e.attestation)===null||r===void 0?void 0:r.signatures)!==null&&n!==void 0?n:[]).map(s=>tn.getSignerDid(s))}static fetchNewestRecordsWrite(e,r,n){return xi(this,void 0,void 0,function*(){let i={interface:Te.Records,method:Se.Write,recordId:n},{messages:o}=yield e.query(r,[i]),s=yield _e.getNewestMessage(o);if(s!==void 0)return s;throw new de(se.RecordsWriteGetNewestWriteRecordNotFound,"record not found")})}static fetchInitialRecordsWrite(e,r,n){return xi(this,void 0,void 0,function*(){let i={entryId:n},{messages:o}=yield e.query(r,[i]);return o.length===0?void 0:yield t.parse(o[0])})}};var Oqe=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})};function Mi(t,e){return Oqe(this,void 0,void 0,function*(){if(t===void 0)throw new de(se.AuthenticateJwsMissing,"Missing JWS.");if(yield z0.verifySignatures(t.signature,e),t.ownerSignature!==void 0&&(yield z0.verifySignatures(t.ownerSignature,e)),t.authorDelegatedGrant!==void 0){let r=yield Ur.parse(t.authorDelegatedGrant);yield z0.verifySignatures(r.message.authorization.signature,e)}if(t.ownerDelegatedGrant!==void 0){let r=yield Ur.parse(t.ownerDelegatedGrant);yield z0.verifySignatures(r.message.authorization.signature,e)}})}f();var Cqe=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},L6=class{isActiveTenant(e){return Cqe(this,void 0,void 0,function*(){return{isActiveTenant:!0}})}};f();f();var Ji=class{get message(){return this._message}get signer(){return this._signer}get author(){return this._author}get signaturePayload(){return this._signaturePayload}get isSignedByAuthorDelegate(){return _e.isSignedByAuthorDelegate(this._message)}constructor(e){this._message=e,e.authorization!==void 0&&(this._signer=_e.getSigner(e),e.authorization.authorDelegatedGrant!==void 0?this._author=_e.getSigner(e.authorization.authorDelegatedGrant):this._author=this._signer,this._signaturePayload=tn.decodePlainObjectPayload(e.authorization.signature))}toJSON(){return this.message}};var UN=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},ny=class t extends Ji{static parse(e){return UN(this,void 0,void 0,function*(){if(e.descriptor.filter.published===!1&&(e.descriptor.dateSort===Vi.PublishedAscending||e.descriptor.dateSort===Vi.PublishedDescending))throw new de(se.RecordsQueryParseFilterPublishedSortInvalid,`queries must not filter for \`published:false\` and sort by ${e.descriptor.dateSort}`);let r;if(e.authorization!==void 0&&(r=yield _e.validateSignatureStructure(e.authorization.signature,e.descriptor)),yield lt.validateDelegatedGrantReferentialIntegrity(e,r),r?.protocolRole!==void 0&&e.descriptor.filter.protocolPath===void 0)throw new de(se.RecordsQueryFilterMissingRequiredProperties,"Role-authorized queries must include `protocolPath` in the filter");return e.descriptor.filter.protocol!==void 0&&na(e.descriptor.filter.protocol),e.descriptor.filter.schema!==void 0&&Wm(e.descriptor.filter.schema),pr.validateTimestamp(e.descriptor.messageTimestamp),new t(e)})}static create(e){var r;return UN(this,void 0,void 0,function*(){let n={interface:Te.Records,method:Se.Query,messageTimestamp:(r=e.messageTimestamp)!==null&&r!==void 0?r:pr.getCurrentTimestamp(),filter:lt.normalizeFilter(e.filter),dateSort:e.dateSort,pagination:e.pagination};if(e.filter.published===!1&&(e.dateSort===Vi.PublishedAscending||e.dateSort===Vi.PublishedDescending))throw new de(se.RecordsQueryCreateFilterPublishedSortInvalid,`queries must not filter for \`published:false\` and sort by ${e.dateSort}`);Tn(n);let i=e.signer,o;i&&(o=yield _e.createAuthorization({descriptor:n,signer:i,protocolRole:e.protocolRole,delegatedGrant:e.delegatedGrant}));let s={descriptor:n,authorization:o};return _e.validateJsonSchema(s),new t(s)})}authorizeDelegate(e){return UN(this,void 0,void 0,function*(){let r=yield yn.parse(this.message.authorization.authorDelegatedGrant);yield us.authorizeQueryOrSubscribe({incomingMessage:this.message,expectedGrantee:this.signer,expectedGrantor:this.author,permissionGrant:r,messageStore:e})})}};f();var RP=gt(M1(),1),dle=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Vu=class t{static toBytes(e){return dle(this,void 0,void 0,function*(){return new Promise((r,n)=>{let i=[];e.on("data",o=>{i.push(o)}),e.on("end",()=>{let o=t.concatenateArrayOfBytes(i);r(o)}),e.on("error",n)})})}static toObject(e){return dle(this,void 0,void 0,function*(){let r=yield t.toBytes(e);return qe.bytesToObject(r)})}static concatenateArrayOfBytes(e){let r=e.reduce((o,s)=>o+s.length,0),n=new Uint8Array(r),i=0;for(let o of e)n.set(o,i),i+=o.length;return n}static fromBytes(e){let n=0;return new RP.Readable({read(o){n+1e5>e.length?(this.push(e.subarray(n)),this.push(null)):(this.push(e.subarray(n,n+1e5)),n=n+1e5)}})}static fromObject(e){let r=qe.objectToBytes(e);return t.fromBytes(r)}static duplicateDataStream(e,r){let n=[];for(let i=0;i{e===c&&Jn.matchAnyFilter(p,s)&&n(l)},u=yield this.eventStream.subscribe(e,a,d);return{status:{code:200,detail:"OK"},subscription:u}})}static authorizeMessagesSubscribe(e,r,n){return mle(this,void 0,void 0,function*(){if(r.author!==e)if(r.author!==void 0&&r.signaturePayload.permissionGrantId!==void 0){let i=yield ht.fetchGrant(e,n,r.signaturePayload.permissionGrantId);yield oy.authorizeQueryOrSubscribe({incomingMessage:r.message,expectedGrantor:e,expectedGrantee:r.author,permissionGrant:i,messageStore:n})}else throw new de(se.MessagesSubscribeAuthorizationFailed,"message failed authorization")})}};f();f();var rpe=gt(Cq(),1);f();var tpe=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},gy=class t{static authorizeConfigure(e){return tpe(this,void 0,void 0,function*(){let{protocolsConfigureMessage:r,expectedGrantor:n,expectedGrantee:i,permissionGrant:o,messageStore:s}=e;yield Fc.performBaseValidation({incomingMessage:r,expectedGrantor:n,expectedGrantee:i,permissionGrant:o,messageStore:s}),t.verifyScope(r,o.scope)})}static authorizeQuery(e){var r;return tpe(this,void 0,void 0,function*(){let{expectedGrantee:n,expectedGrantor:i,incomingMessage:o,permissionGrant:s,messageStore:a}=e;yield Fc.performBaseValidation({incomingMessage:o,expectedGrantor:i,expectedGrantee:n,permissionGrant:s,messageStore:a});let u=s.scope.protocol,c=(r=o.descriptor.filter)===null||r===void 0?void 0:r.protocol;if(u!==void 0&&c!==u)throw new de(se.ProtocolsGrantAuthorizationQueryProtocolScopeMismatch,`Grant protocol scope ${u} does not match protocol in message ${c}`)})}static verifyScope(e,r){if(r.protocol!==void 0&&r.protocol!==e.descriptor.definition.protocol)throw new de(se.ProtocolsGrantAuthorizationScopeProtocolMismatch,"Grant scope specifies different protocol than what appears in the configure message.")}};f();var Zh;(function(t){t.Anyone="anyone",t.Author="author",t.Recipient="recipient"})(Zh||(Zh={}));var Ei;(function(t){t.CoDelete="co-delete",t.CoPrune="co-prune",t.CoUpdate="co-update",t.Create="create",t.Delete="delete",t.Prune="prune",t.Query="query",t.Read="read",t.Subscribe="subscribe",t.Update="update"})(Ei||(Ei={}));var $q=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},RHe=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i10)throw new de(se.ProtocolsConfigureRecordNestingDepthExceeded,"Record nesting depth exceeded 10 levels.");for(let i in r){if(i.startsWith("$"))continue;let o=r[i],s;e===""?s=i:s=`${e}/${i}`,o.$role?n.push(s):t.fetchAllRolePathsRecursively(s,o,n)}return n}static validateRuleSetRecursively(e){var r;let{ruleSet:n,ruleSetProtocolPath:i,recordTypes:o,roles:s}=e;if(n.$size!==void 0){let{min:d=0,max:u}=n.$size;if(u!==void 0&&u![Ei.CoUpdate,Ei.CoDelete,Ei.CoPrune].includes(l)))throw new de(se.ProtocolsConfigureInvalidRecipientOfAction,"Rules for `recipient` without `of` property must have `can` containing only `co-update`, `co-delete`, and `co-prune`.");if(u.who===Zh.Author&&!u.of)throw new de(se.ProtocolsConfigureInvalidActionMissingOf,"'of' is required when 'author' is specified as 'who'");if(u.can!==void 0){if(u.can.includes(Ei.Update)&&!u.can.includes(Ei.Create))throw new de(se.ProtocolsConfigureInvalidActionUpdateWithoutCreate,`Action rule ${JSON.stringify(u)} contains 'update' action but missing the required 'create' action.`);if(u.can.includes(Ei.Delete)&&!u.can.includes(Ei.Create))throw new de(se.ProtocolsConfigureInvalidActionDeleteWithoutCreate,`Action rule ${JSON.stringify(u)} contains 'delete' action but missing the required 'create' action.`)}for(let c=d+1;c0)throw new de(se.ProtocolAuthorizationMissingContextId,"Could not verify role because contextId is missing.");if(l>0){let g=i.split("/").slice(0,l).join("/"),v=Jn.constructPrefixFilterAsRangeFilter(g);c.contextId=v}let{messages:p}=yield s.query(e,[c]);if(p.length===0)throw new de(se.ProtocolAuthorizationMatchingRoleRecordNotFound,`No matching role record found for protocol path ${d}`)})}static getActionsSeekingARuleMatch(e,r,n){return uc(this,void 0,void 0,function*(){switch(r.message.descriptor.method){case Se.Delete:let i=r,o=i.message.descriptor.recordId,s=yield Ur.fetchInitialRecordsWrite(n,e,o);if(s===void 0)return[];let a=[];return i.message.descriptor.prune?(a.push(Ei.CoPrune),r.author===s.author&&a.push(Ei.Prune)):(a.push(Ei.CoDelete),r.author===s.author&&a.push(Ei.Delete)),a;case Se.Query:return[Ei.Query];case Se.Read:return[Ei.Read];case Se.Subscribe:return[Ei.Subscribe];case Se.Write:if(yield r.isInitialWrite())return[Ei.Create];{let c=r.message.recordId,l=yield Ur.fetchInitialRecordsWrite(n,e,c);return l===void 0?[]:r.author===l.author?[Ei.CoUpdate,Ei.Update]:[Ei.CoUpdate]}}return[]})}static authorizeAgainstAllowedActions(e,r,n,i,o){var s;return uc(this,void 0,void 0,function*(){let a=r.message.descriptor.method,d=yield t.getActionsSeekingARuleMatch(e,r,o),u=r.author,c=n.$actions;if(c===void 0)throw new de(se.ProtocolAuthorizationActionRulesNotFound,`no action rule defined for Records${a}, ${u} is unauthorized`);let l=(s=r.signaturePayload)===null||s===void 0?void 0:s.protocolRole;for(let p of c){if(!p.can.some(v=>d.includes(v)))continue;if(p.who===Zh.Anyone)return;if(u===void 0)continue;if(l!==void 0){if(p.role===l)return;continue}if(p.who===Zh.Recipient&&p.of===void 0){let v;if(r.message.descriptor.method===Se.Write?v=r.message:v=i[i.length-1],v.descriptor.recipient===u)return;continue}if(yield t.checkActor(u,p,i))return}throw new de(se.ProtocolAuthorizationActionNotAllowed,`Inbound message action Records${a} by author ${r.author} not allowed.`)})}static verifySizeLimit(e,r){let{min:n=0,max:i}=r.$size||{},o=e.message.descriptor.dataSize;if(oi)throw new de(se.ProtocolAuthorizationMaxSizeInvalid,`data size ${o} is more than allowed ${i}`)}static verifyTagsIfNeeded(e,r){if(r.$tags!==void 0){let{tags:n={},protocol:i,protocolPath:o}=e.message.descriptor,s=r.$tags,{$allowUndefinedTags:a,$requiredTags:d}=s,u=BHe(s,["$allowUndefinedTags","$requiredTags"]),c=a||!1,l=d||[],p=new ope.default.default,m=p.compile({type:"object",properties:u,required:l,additionalProperties:c});if(!m(n)){let v=p.errorsText(m.errors,{dataVar:`${i}/${o}/$tags`});throw new de(se.ProtocolAuthorizationTagsInvalidSchema,`tags schema validation error: ${v}`)}}}static verifyAsRoleRecordIfNeeded(e,r,n,i){return uc(this,void 0,void 0,function*(){if(!n.$role)return;let o=r,s=o.message.descriptor.recipient;if(s===void 0)throw new de(se.ProtocolAuthorizationRoleMissingRecipient,"Role records must have a recipient");let a=o.message.descriptor.protocolPath,d={interface:Te.Records,method:Se.Write,isLatestBaseState:!0,protocol:o.message.descriptor.protocol,protocolPath:a,recipient:s},u=lt.getParentContextFromOfContextId(o.message.contextId);if(u!==""){let m=Jn.constructPrefixFilterAsRangeFilter(u);d.contextId=m}let{messages:c}=yield i.query(e,[d]);if(c.filter(m=>m.recordId!==o.message.recordId).length>0)throw new de(se.ProtocolAuthorizationDuplicateRoleRecipient,`DID '${s}' is already recipient of a role record at protocol path '${a} under the parent context ${u}.`)})}static getRuleSetAtProtocolPath(e,r){let n=e.split("/"),i=r.structure,o=0;for(;oo.descriptor.protocolPath===r.of);if(i===void 0)return!1;if(r.who===Zh.Recipient)return e===i.descriptor.recipient;{let o=(yield Ur.parse(i)).author;return e===o}})}static getTypeName(e){return e.split("/").slice(-1)[0]}};f();var Nq=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},gf=class t extends Ji{static parse(e){return Nq(this,void 0,void 0,function*(){let r;return e.authorization!==void 0&&(r=yield _e.validateSignatureStructure(e.authorization.signature,e.descriptor)),yield lt.validateDelegatedGrantReferentialIntegrity(e,r),pr.validateTimestamp(e.descriptor.messageTimestamp),new t(e)})}static create(e){var r,n;return Nq(this,void 0,void 0,function*(){let i=e.recordId,o=pr.getCurrentTimestamp(),s={interface:Te.Records,method:Se.Delete,messageTimestamp:(r=e.messageTimestamp)!==null&&r!==void 0?r:o,recordId:i,prune:(n=e.prune)!==null&&n!==void 0?n:!1},a=yield _e.createAuthorization({descriptor:s,signer:e.signer,protocolRole:e.protocolRole,delegatedGrant:e.delegatedGrant}),d={descriptor:s,authorization:a};return _e.validateJsonSchema(d),new t(d)})}constructIndexes(e){let r=this.message,n=Object.assign({},r.descriptor),{protocol:i,protocolPath:o,recipient:s,schema:a,parentId:d,dateCreated:u}=e.descriptor,c=Object.assign({protocol:i,protocolPath:o,recipient:s,schema:a,parentId:d,dateCreated:u,contextId:e.contextId,author:this.author},n);return Tn(c),c}authorizeDelegate(e,r){return Nq(this,void 0,void 0,function*(){let n=yield yn.parse(this.message.authorization.authorDelegatedGrant);yield us.authorizeDelete({recordsDeleteMessage:this.message,recordsWriteToDelete:e,expectedGrantor:this.author,expectedGrantee:this.signer,permissionGrant:n,messageStore:r})})}};f();var g2=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},wS;(function(t){t.RecordsDelete="RecordsDelete"})(wS||(wS={}));var _S=class t{constructor(e,r){this.resumableTaskStore=e,this.resumableTaskBatchSize=100,this.resumableTaskHandlers={[wS.RecordsDelete]:n=>g2(this,void 0,void 0,function*(){return yield r.performRecordsDelete(n)})}}run(e){return g2(this,void 0,void 0,function*(){let r=t.timeoutExtensionFrequencyInSeconds*2,n=yield this.resumableTaskStore.register(e,r);yield this.runWithAutomaticTimeoutExtension(n)})}runWithAutomaticTimeoutExtension(e){return g2(this,void 0,void 0,function*(){let r=t.timeoutExtensionFrequencyInSeconds*2,n;try{n=setInterval(()=>{this.resumableTaskStore.extend(e.id,r)},t.timeoutExtensionFrequencyInSeconds*1e3);let i=this.resumableTaskHandlers[e.task.name];yield i(e.task.data),yield this.resumableTaskStore.delete(e.id)}finally{t.clearTimeoutExtensionTimer(n)}})}static clearTimeoutExtensionTimer(e){clearInterval(e)}resumeTasksAndWaitForCompletion(){return g2(this,void 0,void 0,function*(){for(;;){let e=yield this.resumableTaskStore.grab(this.resumableTaskBatchSize);if(e===void 0||e.length===0)break;yield this.retryTasksUntilCompletion(e)}})}retryTasksUntilCompletion(e){return g2(this,void 0,void 0,function*(){let r=e;for(;r.length>0;){let n=r;r=[];let i=n.map(o=>g2(this,void 0,void 0,function*(){try{yield this.runWithAutomaticTimeoutExtension(o)}catch(s){console.error("Error while running resumable task:",s),console.error("Resumable task:",e),r.push(o)}}));yield Promise.all(i)}})}};_S.timeoutExtensionFrequencyInSeconds=30;var spe=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},pI=class t{constructor(e,r,n){this.didResolver=e,this.messageStore=r,this.resumableTaskManager=n}handle({tenant:e,message:r}){return spe(this,void 0,void 0,function*(){let n;try{n=yield gf.parse(r)}catch(u){return mr(u,400)}try{yield Mi(r.authorization,this.didResolver)}catch(u){return mr(u,401)}let i={interface:Te.Records,recordId:r.descriptor.recordId},{messages:o}=yield this.messageStore.query(e,[i]),s=yield _e.getNewestMessage(o);if(!lt.canPerformDeleteAgainstRecord(r,s))return{status:{code:404,detail:"Not Found"}};if(!(yield _e.isNewer(r,s)))return{status:{code:409,detail:"Conflict"}};try{let u=yield Ur.fetchInitialRecordsWrite(this.messageStore,e,r.descriptor.recordId);yield t.authorizeRecordsDelete(e,n,u,this.messageStore)}catch(u){return mr(u,401)}return yield this.resumableTaskManager.run({name:wS.RecordsDelete,data:{tenant:e,message:r}}),{status:{code:202,detail:"Accepted"}}})}static authorizeRecordsDelete(e,r,n,i){return spe(this,void 0,void 0,function*(){if(_e.isSignedByAuthorDelegate(r.message)&&(yield r.authorizeDelegate(n.message,i)),r.author!==e)if(n.message.descriptor.protocol!==void 0)yield Jc.authorizeDelete(e,r,n,i);else throw new de(se.RecordsDeleteAuthorizationFailed,"RecordsDelete message failed authorization")})}};f();f();var As;(function(t){t[t.Descending=-1]="Descending",t[t.Ascending=1]="Ascending"})(As||(As={}));var xS=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},mI=class t{constructor(e,r,n){this.didResolver=e,this.messageStore=r,this.dataStore=n}handle({tenant:e,message:r}){return xS(this,void 0,void 0,function*(){let n;try{n=yield ny.parse(r)}catch(s){return mr(s,400)}let i,o;if(lt.filterIncludesPublishedRecords(n.message.descriptor.filter)&&n.author===void 0){let s=yield this.fetchPublishedRecords(e,n);i=s.messages,o=s.cursor}else{try{yield Mi(r.authorization,this.didResolver),yield t.authorizeRecordsQuery(e,n,this.messageStore)}catch(s){return mr(s,401)}if(n.author===e){let s=yield this.fetchRecordsAsOwner(e,n);i=s.messages,o=s.cursor}else{let s=yield this.fetchRecordsAsNonOwner(e,n);i=s.messages,o=s.cursor}}for(let s of i)if(!(yield Ur.isInitialWrite(s))){let d=(yield this.messageStore.query(e,[{recordId:s.recordId,isLatestBaseState:!1,method:Se.Write}])).messages[0];delete d.encodedData,s.initialWrite=d}return{status:{code:200,detail:"OK"},entries:i,cursor:o}})}convertDateSort(e){switch(e){case Vi.CreatedAscending:return{dateCreated:As.Ascending};case Vi.CreatedDescending:return{dateCreated:As.Descending};case Vi.PublishedAscending:return{datePublished:As.Ascending};case Vi.PublishedDescending:return{datePublished:As.Descending};default:return{dateCreated:As.Ascending}}}fetchRecordsAsOwner(e,r){return xS(this,void 0,void 0,function*(){let{dateSort:n,filter:i,pagination:o}=r.message.descriptor,s=Object.assign(Object.assign({},lt.convertFilter(i,n)),{interface:Te.Records,method:Se.Write,isLatestBaseState:!0}),a=this.convertDateSort(n);return this.messageStore.query(e,[s],a,o)})}fetchRecordsAsNonOwner(e,r){return xS(this,void 0,void 0,function*(){let{dateSort:n,pagination:i,filter:o}=r.message.descriptor,s=[];lt.filterIncludesPublishedRecords(o)&&s.push(t.buildPublishedRecordsFilter(r)),lt.filterIncludesUnpublishedRecords(o)&&(lt.shouldBuildUnpublishedAuthorFilter(o,r.author)&&s.push(t.buildUnpublishedRecordsByQueryAuthorFilter(r)),lt.shouldProtocolAuthorize(r.signaturePayload)&&s.push(t.buildUnpublishedProtocolAuthorizedRecordsFilter(r)),lt.shouldBuildUnpublishedRecipientFilter(o,r.author)&&s.push(t.buildUnpublishedRecordsForQueryAuthorFilter(r)));let a=this.convertDateSort(n);return this.messageStore.query(e,s,a,i)})}fetchPublishedRecords(e,r){return xS(this,void 0,void 0,function*(){let{dateSort:n,pagination:i}=r.message.descriptor,o=t.buildPublishedRecordsFilter(r),s=this.convertDateSort(n);return this.messageStore.query(e,[o],s,i)})}static buildPublishedRecordsFilter(e){let{dateSort:r,filter:n}=e.message.descriptor;return Object.assign(Object.assign({},lt.convertFilter(n,r)),{interface:Te.Records,method:Se.Write,published:!0,isLatestBaseState:!0})}static buildUnpublishedRecordsForQueryAuthorFilter(e){let{dateSort:r,filter:n}=e.message.descriptor;return Object.assign(Object.assign({},lt.convertFilter(n,r)),{interface:Te.Records,method:Se.Write,recipient:e.author,isLatestBaseState:!0,published:!1})}static buildUnpublishedProtocolAuthorizedRecordsFilter(e){let{dateSort:r,filter:n}=e.message.descriptor;return Object.assign(Object.assign({},lt.convertFilter(n,r)),{interface:Te.Records,method:Se.Write,isLatestBaseState:!0,published:!1})}static buildUnpublishedRecordsByQueryAuthorFilter(e){let{dateSort:r,filter:n}=e.message.descriptor;return Object.assign(Object.assign({},lt.convertFilter(n,r)),{author:e.author,interface:Te.Records,method:Se.Write,isLatestBaseState:!0,published:!1})}static authorizeRecordsQuery(e,r,n){return xS(this,void 0,void 0,function*(){_e.isSignedByAuthorDelegate(r.message)&&(yield r.authorizeDelegate(n)),lt.shouldProtocolAuthorize(r.signaturePayload)&&(yield Jc.authorizeQueryOrSubscribe(e,r,n))})}};f();f();var Uq=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Ev=class t extends Ji{static parse(e){return Uq(this,void 0,void 0,function*(){let r;return e.authorization!==void 0&&(r=yield _e.validateSignatureStructure(e.authorization.signature,e.descriptor)),yield lt.validateDelegatedGrantReferentialIntegrity(e,r),pr.validateTimestamp(e.descriptor.messageTimestamp),new t(e)})}static create(e){var r;return Uq(this,void 0,void 0,function*(){let{filter:n,signer:i,permissionGrantId:o,protocolRole:s}=e,a=pr.getCurrentTimestamp(),d={interface:Te.Records,method:Se.Read,filter:lt.normalizeFilter(n),messageTimestamp:(r=e.messageTimestamp)!==null&&r!==void 0?r:a};Tn(d);let u;i!==void 0&&(u=yield _e.createAuthorization({descriptor:d,signer:i,permissionGrantId:o,protocolRole:s,delegatedGrant:e.delegatedGrant}));let c={descriptor:d,authorization:u};return _e.validateJsonSchema(c),new t(c)})}authorizeDelegate(e,r){return Uq(this,void 0,void 0,function*(){let n=yield yn.parse(this.message.authorization.authorDelegatedGrant);yield us.authorizeRead({recordsReadMessage:this.message,recordsWriteMessageToBeRead:e,expectedGrantor:this.author,expectedGrantee:this.signer,permissionGrant:n,messageStore:r})})}};var ape=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},yI=class t{constructor(e,r,n){this.didResolver=e,this.messageStore=r,this.dataStore=n}handle({tenant:e,message:r}){return ape(this,void 0,void 0,function*(){let n;try{n=yield Ev.parse(r)}catch(c){return mr(c,400)}try{n.author!==void 0&&(yield Mi(r.authorization,this.didResolver))}catch(c){return mr(c,401)}let i=Object.assign({interface:Te.Records,isLatestBaseState:!0},lt.convertFilter(r.descriptor.filter)),{messages:o}=yield this.messageStore.query(e,[i]);if(o.length===0)return{status:{code:404,detail:"Not Found"}};if(o.length>1)return mr(new de(se.RecordsReadReturnedMultiple,"Multiple records exist for the RecordsRead filter"),400);let s=o[0];try{yield t.authorizeRecordsRead(e,n,yield Ur.parse(s),this.messageStore)}catch(c){return mr(c,401)}let a;if(s.encodedData!==void 0){let c=qe.base64UrlToBytes(s.encodedData);a=Vu.fromBytes(c),delete s.encodedData}else{let c=yield this.dataStore.get(e,s.recordId,s.descriptor.dataCid);if(c?.dataStream===void 0)return{status:{code:404,detail:"Not Found"}};a=c.dataStream}let d=Object.assign(Object.assign({},s),{data:a});if(!(yield Ur.isInitialWrite(d))){let l=(yield this.messageStore.query(e,[{recordId:d.recordId,isLatestBaseState:!1,method:Se.Write}])).messages[0];delete l.encodedData,d.initialWrite=l}return{status:{code:200,detail:"OK"},record:d}})}static authorizeRecordsRead(e,r,n,i){return ape(this,void 0,void 0,function*(){_e.isSignedByAuthorDelegate(r.message)&&(yield r.authorizeDelegate(n.message,i));let{descriptor:o}=n.message;if(r.author!==e){if(o.published===!0)return;if(r.author!==void 0&&r.author===o.recipient)return;if(r.author!==void 0&&r.signaturePayload.permissionGrantId!==void 0){let s=yield ht.fetchGrant(e,i,r.signaturePayload.permissionGrantId);yield us.authorizeRead({recordsReadMessage:r.message,recordsWriteMessageToBeRead:n.message,expectedGrantor:e,expectedGrantee:r.author,permissionGrant:s,messageStore:i})}else if(o.protocol!==void 0)yield Jc.authorizeRead(e,r,n,i);else throw new de(se.RecordsReadAuthorizationFailed,"message failed authorization")}})}};f();f();var qq=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},wy=class t extends Ji{static parse(e){return qq(this,void 0,void 0,function*(){let r;if(e.authorization!==void 0&&(r=yield _e.validateSignatureStructure(e.authorization.signature,e.descriptor)),yield lt.validateDelegatedGrantReferentialIntegrity(e,r),r?.protocolRole!==void 0&&e.descriptor.filter.protocolPath===void 0)throw new de(se.RecordsSubscribeFilterMissingRequiredProperties,"Role-authorized subscriptions must include `protocolPath` in the filter");return e.descriptor.filter.protocol!==void 0&&na(e.descriptor.filter.protocol),e.descriptor.filter.schema!==void 0&&Wm(e.descriptor.filter.schema),pr.validateTimestamp(e.descriptor.messageTimestamp),new t(e)})}static create(e){var r;return qq(this,void 0,void 0,function*(){let n={interface:Te.Records,method:Se.Subscribe,messageTimestamp:(r=e.messageTimestamp)!==null&&r!==void 0?r:pr.getCurrentTimestamp(),filter:lt.normalizeFilter(e.filter)};Tn(n);let i=e.signer,o;i&&(o=yield _e.createAuthorization({descriptor:n,signer:i,protocolRole:e.protocolRole,delegatedGrant:e.delegatedGrant}));let s={descriptor:n,authorization:o};return _e.validateJsonSchema(s),new t(s)})}authorizeDelegate(e){return qq(this,void 0,void 0,function*(){let r=yield yn.parse(this.message.authorization.authorDelegatedGrant);yield us.authorizeQueryOrSubscribe({incomingMessage:this.message,expectedGrantor:this.author,expectedGrantee:this.signer,permissionGrant:r,messageStore:e})})}};var gI=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},vI=class t{constructor(e,r,n){this.didResolver=e,this.messageStore=r,this.eventStream=n}handle({tenant:e,message:r,subscriptionHandler:n}){return gI(this,void 0,void 0,function*(){if(this.eventStream===void 0)return mr(new de(se.RecordsSubscribeEventStreamUnimplemented,"Subscriptions are not supported"),501);let i;try{i=yield wy.parse(r)}catch(u){return mr(u,400)}let o=[];if(lt.filterIncludesPublishedRecords(i.message.descriptor.filter)&&i.author===void 0)o=[t.buildPublishedRecordsFilter(i)],delete r.authorization;else{try{yield Mi(r.authorization,this.didResolver),yield t.authorizeRecordsSubscribe(e,i,this.messageStore)}catch(u){return mr(u,401)}i.author===e?o=yield t.filterAsOwner(i):o=yield t.filterAsNonOwner(i)}let s=(u,c,l)=>{e===u&&Jn.matchAnyFilter(l,o)&&n(c)},a=yield _e.getCid(r),d=yield this.eventStream.subscribe(e,a,s);return{status:{code:200,detail:"OK"},subscription:d}})}static filterAsOwner(e){return gI(this,void 0,void 0,function*(){let{filter:r}=e.message.descriptor;return[Object.assign(Object.assign({},lt.convertFilter(r)),{interface:Te.Records,method:[Se.Write,Se.Delete]})]})}static filterAsNonOwner(e){return gI(this,void 0,void 0,function*(){let r=[],{filter:n}=e.message.descriptor;return lt.filterIncludesPublishedRecords(n)&&r.push(t.buildPublishedRecordsFilter(e)),lt.filterIncludesUnpublishedRecords(n)&&(lt.shouldBuildUnpublishedAuthorFilter(n,e.author)&&r.push(t.buildUnpublishedRecordsBySubscribeAuthorFilter(e)),lt.shouldProtocolAuthorize(e.signaturePayload)&&r.push(t.buildUnpublishedProtocolAuthorizedRecordsFilter(e)),lt.shouldBuildUnpublishedRecipientFilter(n,e.author)&&r.push(t.buildUnpublishedRecordsForSubscribeAuthorFilter(e))),r})}static buildPublishedRecordsFilter(e){return Object.assign(Object.assign({},lt.convertFilter(e.message.descriptor.filter)),{interface:Te.Records,method:[Se.Write,Se.Delete],published:!0})}static buildUnpublishedRecordsForSubscribeAuthorFilter(e){return Object.assign(Object.assign({},lt.convertFilter(e.message.descriptor.filter)),{interface:Te.Records,method:[Se.Write,Se.Delete],recipient:e.author,published:!1})}static buildUnpublishedProtocolAuthorizedRecordsFilter(e){return Object.assign(Object.assign({},lt.convertFilter(e.message.descriptor.filter)),{interface:Te.Records,method:[Se.Write,Se.Delete],published:!1})}static buildUnpublishedRecordsBySubscribeAuthorFilter(e){return Object.assign(Object.assign({},lt.convertFilter(e.message.descriptor.filter)),{author:e.author,interface:Te.Records,method:[Se.Write,Se.Delete],published:!1})}static authorizeRecordsSubscribe(e,r,n){return gI(this,void 0,void 0,function*(){_e.isSignedByAuthorDelegate(r.message)&&(yield r.authorizeDelegate(n)),lt.shouldProtocolAuthorize(r.signaturePayload)&&(yield Jc.authorizeQueryOrSubscribe(e,r,n))})}};f();f();var vf=class{};vf.maxDataSizeAllowedToBeEncoded=3e4;f();var ES=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},v2=class t{constructor({messageStore:e,dataStore:r,eventLog:n,eventStream:i}){this.messageStore=e,this.dataStore=r,this.eventLog=n,this.eventStream=i}performRecordsDelete({tenant:e,message:r}){return ES(this,void 0,void 0,function*(){let n={interface:Te.Records,recordId:r.descriptor.recordId},{messages:i}=yield this.messageStore.query(e,[n]),o=yield _e.getNewestMessage(i);if(!lt.canPerformDeleteAgainstRecord(r,o))return;let s=yield gf.parse(r),a=yield Ur.getInitialWrite(i),d=s.constructIndexes(a),u=yield _e.getCid(r);yield this.messageStore.put(e,r,d),yield this.eventLog.append(e,u,d),this.eventStream!==void 0&&this.eventStream.emit(e,{message:r,initialWrite:a},d),r.descriptor.prune&&(yield t.purgeRecordDescendants(e,r.descriptor.recordId,this.messageStore,this.dataStore,this.eventLog)),yield t.deleteAllOlderMessagesButKeepInitialWrite(e,i,r,this.messageStore,this.dataStore,this.eventLog)})}static deleteFromDataStoreIfNeeded(e,r,n,i){return ES(this,void 0,void 0,function*(){if(n.descriptor.method!==Se.Write)return;let o=n;o.descriptor.dataSize<=vf.maxDataSizeAllowedToBeEncoded||o.descriptor.dataCid!==i.descriptor.dataCid&&(yield e.delete(r,o.recordId,o.descriptor.dataCid))})}static purgeRecordDescendants(e,r,n,i,o){return ES(this,void 0,void 0,function*(){let s={interface:Te.Records,parentId:r},{messages:a}=yield n.query(e,[s]),d=new Map;for(let u of a){let c;lt.isRecordsWrite(u)?c=u.recordId:c=u.descriptor.recordId,d.has(c)||d.set(c,[]),d.get(c).push(u)}for(let u of d.keys())yield t.purgeRecordDescendants(e,u,n,i,o);for(let u of d.keys())yield t.purgeRecordMessages(e,d.get(u),n,i,o)})}static purgeRecordMessages(e,r,n,i,o){return ES(this,void 0,void 0,function*(){let s=r.filter(u=>u.descriptor.method===Se.Write),a=yield _e.getNewestMessage(s);yield i.delete(e,a.recordId,a.descriptor.dataCid);let d=yield Promise.all(r.map(u=>_e.getCid(u)));yield o.deleteEventsByCid(e,d),yield Promise.all(d.map(u=>n.delete(e,u)))})}static deleteAllOlderMessagesButKeepInitialWrite(e,r,n,i,o,s){return ES(this,void 0,void 0,function*(){let a=[];for(let d of r){if(yield _e.isOlder(d,n)){yield t.deleteFromDataStoreIfNeeded(o,e,d,n);let c=yield _e.getCid(d);if(yield i.delete(e,c),yield Ur.isInitialWrite(d)){let p=yield Ur.parse(d),m=!1,g=yield p.constructIndexes(m),v=d;delete v.encodedData,yield i.put(e,v,g)}else{let p=yield _e.getCid(d);a.push(p)}}yield s.deleteEventsByCid(e,a)}})}};var Sv=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},bI=class t{constructor(e,r,n,i,o){this.didResolver=e,this.messageStore=r,this.dataStore=n,this.eventLog=i,this.eventStream=o}handle({tenant:e,message:r,dataStream:n}){return Sv(this,void 0,void 0,function*(){let i;try{i=yield Ur.parse(r),r.descriptor.protocol!==void 0&&(yield Jc.validateReferentialIntegrity(e,i,this.messageStore))}catch(m){return mr(m,400)}try{yield Mi(r.authorization,this.didResolver),yield t.authorizeRecordsWrite(e,i,this.messageStore)}catch(m){return mr(m,401)}let o={interface:Te.Records,recordId:r.recordId},{messages:s}=yield this.messageStore.query(e,[o]),a=yield i.isInitialWrite(),d;if(!a)try{d=yield Ur.getInitialWrite(s),Ur.verifyEqualityOfImmutableProperties(d,r)}catch(m){return mr(m,400)}let u=yield _e.getNewestMessage(s),c=!1,l;if(u===void 0||(yield _e.isNewer(r,u))?(c=!0,l=r):l=u,!c)return{status:{code:409,detail:"Conflict"}};try{if(u?.descriptor.method===Se.Delete)throw new de(se.RecordsWriteNotAllowedAfterDelete,"RecordsWrite is not allowed after a RecordsDelete.");yield this.preProcessingForCoreRecordsWrite(e,r);let m=!1,g=r;if(n!==void 0)g=yield this.processMessageWithDataStream(e,r,n),m=!0;else if(!a){let x=u;g=yield this.processMessageWithoutDataStream(e,r,x),m=!0}let v=yield i.constructIndexes(m);yield this.messageStore.put(e,g,v),yield this.eventLog.append(e,yield _e.getCid(r),v),this.eventStream!==void 0&&m&&this.eventStream.emit(e,{message:r,initialWrite:d},v)}catch(m){let g=m;if(g.code!==void 0&&(g.code===se.RecordsWriteMissingEncodedDataInPrevious||g.code===se.RecordsWriteMissingDataInPrevious||g.code===se.RecordsWriteNotAllowedAfterDelete||g.code===se.RecordsWriteDataCidMismatch||g.code===se.RecordsWriteDataSizeMismatch||g.code.startsWith("PermissionsProtocolValidate")||g.code.startsWith("SchemaValidator")))return mr(m,400);throw m}let p={status:a&&n===void 0?{code:204,detail:"No Content"}:{code:202,detail:"Accepted"}};return yield v2.deleteAllOlderMessagesButKeepInitialWrite(e,s,l,this.messageStore,this.dataStore,this.eventLog),yield this.postProcessingForCoreRecordsWrite(e,i),p})}preProcessingForCoreRecordsWrite(e,r){var n;return Sv(this,void 0,void 0,function*(){if(r.descriptor.protocol===ht.uri&&r.descriptor.protocolPath===ht.revocationPath){let i=r.descriptor.parentId,o=yield ht.fetchGrant(e,this.messageStore,i),s=(n=r.descriptor.tags)===null||n===void 0?void 0:n.protocol,a="protocol"in o.scope?o.scope.protocol:void 0;if(a!==s)throw new de(se.PermissionsProtocolValidateRevocationProtocolTagMismatch,`Revocation protocol ${s} does not match grant protocol ${a}`)}})}static validateSchemaForCoreRecordsWrite(e,r){e.descriptor.protocol===ht.uri&&ht.validateSchema(e,r)}postProcessingForCoreRecordsWrite(e,r){return Sv(this,void 0,void 0,function*(){if(r.message.descriptor.protocol===ht.uri&&r.message.descriptor.protocolPath===ht.revocationPath){let i={permissionGrantId:r.message.descriptor.parentId,dateCreated:{gte:r.message.descriptor.messageTimestamp}},{messages:o}=yield this.messageStore.query(e,[i]),s=[];for(let a of o){let d=yield _e.getCid(a);yield this.messageStore.delete(e,d)}this.eventLog.deleteEventsByCid(e,s)}})}cloneAndAddEncodedData(e,r){return Sv(this,void 0,void 0,function*(){let n=Object.assign({},e);return n.encodedData=qe.bytesToBase64Url(r),n})}processMessageWithDataStream(e,r,n){return Sv(this,void 0,void 0,function*(){let i=r;if(r.descriptor.dataSize<=vf.maxDataSizeAllowedToBeEncoded){let o=yield Vu.toBytes(n),s=yield fn.computeDagPbCidFromBytes(o);t.validateDataIntegrity(r.descriptor.dataCid,r.descriptor.dataSize,s,o.length),t.validateSchemaForCoreRecordsWrite(r,o),i=yield this.cloneAndAddEncodedData(r,o)}else{let[o,s]=Vu.duplicateDataStream(n,2);try{let[a,d]=yield Promise.all([fn.computeDagPbCidFromStream(o),this.dataStore.put(e,r.recordId,r.descriptor.dataCid,s)]);t.validateDataIntegrity(r.descriptor.dataCid,r.descriptor.dataSize,a,d.dataSize)}catch(a){throw yield this.dataStore.delete(e,r.recordId,r.descriptor.dataCid),a}}return i})}processMessageWithoutDataStream(e,r,n){return Sv(this,void 0,void 0,function*(){let i=Object.assign({},r),{dataCid:o,dataSize:s}=r.descriptor;if(t.validateDataIntegrity(o,s,n.descriptor.dataCid,n.descriptor.dataSize),s<=vf.maxDataSizeAllowedToBeEncoded)if(n.encodedData!==void 0)i.encodedData=n.encodedData;else throw new de(se.RecordsWriteMissingEncodedDataInPrevious,"No dataStream was provided and unable to get data from previous message");else if((yield this.dataStore.get(e,n.recordId,r.descriptor.dataCid))===void 0)throw new de(se.RecordsWriteMissingDataInPrevious,"No dataStream was provided and unable to get data from previous message");return i})}static validateDataIntegrity(e,r,n,i){if(e!==n)throw new de(se.RecordsWriteDataCidMismatch,`actual data CID ${n} does not match dataCid in descriptor: ${e}`);if(r!==i)throw new de(se.RecordsWriteDataSizeMismatch,`actual data size ${i} bytes does not match dataSize in descriptor: ${r}`)}static authorizeRecordsWrite(e,r,n){return Sv(this,void 0,void 0,function*(){if(r.owner!==void 0&&r.owner!==e)throw new de(se.RecordsWriteOwnerAndTenantMismatch,`Owner ${r.owner} must be the same as tenant ${e} when specified.`);if(r.isSignedByAuthorDelegate&&(yield r.authorizeAuthorDelegate(n)),r.isSignedByOwnerDelegate&&(yield r.authorizeOwnerDelegate(n)),r.owner===void 0){if(r.author===e)return;if(r.author!==void 0&&r.signaturePayload.permissionGrantId!==void 0){let i=yield ht.fetchGrant(e,n,r.signaturePayload.permissionGrantId);yield us.authorizeWrite({recordsWriteMessage:r.message,expectedGrantor:e,expectedGrantee:r.author,permissionGrant:i,messageStore:n})}else if(r.message.descriptor.protocol!==void 0)yield Jc.authorizeWrite(e,r,n);else throw new de(se.RecordsWriteAuthorizationFailed,"message failed authorization")}})}};f();f();var Av;(function(t){t.authentication="authentication",t.assertionMethod="assertionMethod",t.keyAgreement="keyAgreement",t.capabilityInvocation="capabilityInvocation",t.capabilityDelegation="capabilityDelegation"})(Av||(Av={}));f();var ai={"@context":"https://w3id.org/did-resolution/v1",didResolutionMetadata:{},didDocument:null,didDocumentMetadata:{}};f();var _r=class t{constructor({method:e,id:r,path:n,query:i,fragment:o,params:s}){this.uri=`did:${e}:${r}`,this.method=e,this.id=r,this.path=n,this.query=i,this.fragment=o,this.params=s}static parse(e){if(!e)return null;let r=t.DID_URI_PATTERN.exec(e);if(!r||!r.groups)return null;let{method:n,id:i,path:o,query:s,fragment:a}=r.groups,d={uri:`did:${n}:${i}`,method:n,id:i};if(o&&(d.path=o),s&&(d.query=s.slice(1)),a&&(d.fragment=a.slice(1)),s){let u={},c=s.slice(1).split("&");for(let l of c){let[p,m]=l.split("=");u[p]=m}d.params=u}return d}};_r.METHOD_PATTERN="([a-z0-9]+)";_r.PCT_ENCODED_PATTERN="(?:%[0-9a-fA-F]{2})";_r.ID_CHAR_PATTERN=`(?:[a-zA-Z0-9._-]|${_r.PCT_ENCODED_PATTERN})`;_r.METHOD_ID_PATTERN=`((?:${_r.ID_CHAR_PATTERN}*:)*(${_r.ID_CHAR_PATTERN}+))`;_r.PATH_PATTERN="(/[^#?]*)?";_r.QUERY_PATTERN="([?][^#]*)?";_r.FRAGMENT_PATTERN="(#.*)?";_r.DID_URI_PATTERN=new RegExp(`^did:(?${_r.METHOD_PATTERN}):(?${_r.METHOD_ID_PATTERN})(?${_r.PATH_PATTERN})(?${_r.QUERY_PATTERN})(?${_r.FRAGMENT_PATTERN})$`);f();var at=class t 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,t)}},tt;(function(t){t.InvalidDid="invalidDid",t.MethodNotSupported="methodNotSupported",t.InternalError="internalError",t.InvalidDidDocument="invalidDidDocument",t.InvalidDidDocumentLength="invalidDidDocumentLength",t.InvalidDidUrl="invalidDidUrl",t.InvalidPreviousDidProof="invalidPreviousDidProof",t.InvalidPublicKey="invalidPublicKey",t.InvalidPublicKeyLength="invalidPublicKeyLength",t.InvalidPublicKeyType="invalidPublicKeyType",t.InvalidSignature="invalidSignature",t.NotFound="notFound",t.RepresentationNotSupported="representationNotSupported",t.UnsupportedPublicKeyType="unsupportedPublicKeyType"})(tt||(tt={}));f();f();f();f();f();var CHe=gt(_I(),1);f();f();function dpe(t){return t.byteOffset!==0||t.byteLength!==t.buffer.byteLength}function upe(t){return typeof t!="object"||t===null?!1:typeof t[Symbol.asyncIterator]=="function"}function xI(t){let r=Object.prototype.toString.call(t).match(/\s([a-zA-Z0-9]+)/),[n,i]=r;return i}var SS=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},lpe=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,d){s=t[o](s),i(a,d,s.done,s.value)})}}function i(o,s,a,d){Promise.resolve(d).then(function(u){o({value:u,done:a})},s)}},EI=new TextEncoder,Tv=new TextDecoder,xt=class t{constructor(e,r){this.data=e,this.format=r}static arrayBuffer(e){return new t(e,"ArrayBuffer")}static asyncIterable(e){if(!upe(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 Ki.baseDecode(this.data).buffer;case"Base64Url":return Pi.baseDecode(this.data).buffer;case"BufferSource":{if(xI(this.data)==="ArrayBuffer")return this.data;if(ArrayBuffer.isView(this.data))return dpe(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 SS(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 M0.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 Ki.baseEncode(e)}case"Multibase":return this.data.substring(1);case"Uint8Array":return Ki.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 Pi.baseEncode(e)}case"BufferSource":{let e=this.toUint8Array();return Pi.baseEncode(e)}case"Object":{let e=JSON.stringify(this.data),r=EI.encode(e);return Pi.baseEncode(r)}case"String":{let e=EI.encode(this.data);return Pi.baseEncode(e)}case"Uint8Array":return Pi.baseEncode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Base64Url is not supported.`)}}toBlobAsync(){return SS(this,void 0,void 0,function*(){var e,r,n,i;switch(this.format){case"AsyncIterable":{let d=[];try{for(var o=!0,s=lpe(this.data),a;a=yield s.next(),e=a.done,!e;o=!0){i=a.value,o=!1;let c=i;d.push(c)}}catch(c){r={error:c}}finally{try{!o&&!e&&(n=s.return)&&(yield n.call(s))}finally{if(r)throw r.error}}return new Blob(d)}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{t[e]===void 0?delete t[e]:typeof t[e]=="object"&&Fq(t[e])})}f();var CVe=gt(WS(),1),Lv=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})};var JI=class{constructor(){this.store=new Map}clear(){return Lv(this,void 0,void 0,function*(){this.store.clear()})}close(){return Lv(this,void 0,void 0,function*(){})}delete(e){return Lv(this,void 0,void 0,function*(){return this.store.delete(e)})}get(e){return Lv(this,void 0,void 0,function*(){return this.store.get(e)})}has(e){return Lv(this,void 0,void 0,function*(){return this.store.has(e)})}list(){return Lv(this,void 0,void 0,function*(){return Array.from(this.store.values())})}set(e,r){return Lv(this,void 0,void 0,function*(){this.store.set(e,r)})}};f();f();var yXe=gt(t3(),1);var gXe=gt(t3(),1);f();f();var vXe=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},j2=class{static digest(e){return vXe(this,arguments,void 0,function*({data:r}){return So(r)})}};f();var kf=class{};var bXe=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Ek=class extends kf{digest(e){return bXe(this,arguments,void 0,function*({algorithm:r,data:n}){switch(r){case"SHA-256":return yield j2.digest({data:n})}})}};f();f();f();f();f();f();function By(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function wXe(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function cp(t,...e){if(!wXe(t))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function Sk(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");By(t.outputLen),By(t.blockLen)}function N2(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 q0e(t,e){cp(t);let r=e.outputLen;if(t.lengthnew DataView(t.buffer,t.byteOffset,t.byteLength),il=(t,e)=>t<<32-e|t>>>e,_Xe=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!_Xe)throw new Error("Non little-endian hardware is not supported");var xXe=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function KK(t){if(!LK(t))throw new Error("Uint8Array expected");let e="";for(let r=0;r=dp._0&&t<=dp._9)return t-dp._0;if(t>=dp._A&&t<=dp._F)return t-(dp._A-10);if(t>=dp._a&&t<=dp._f)return t-(dp._a-10)}function K0e(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let i=0,o=0;i{};async function F0e(t,e,r){let n=Date.now();for(let i=0;i=0&&ot().update(My(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Qv(t=32){if(Ak&&typeof Ak.getRandomValues=="function")return Ak.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function AXe(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),d=n?4:0,u=n?0:4;t.setUint32(e+d,s,n),t.setUint32(e+u,a,n)}var Oy=class extends U2{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=up(this.buffer)}update(e){N2(this);let{view:r,buffer:n,blockLen:i}=this;e=My(e);let o=e.length;for(let s=0;si-s&&(this.process(n,0),s=0);for(let l=s;lc.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;lt&e^~t&r,PXe=(t,e,r)=>t&e^t&r^e&r,IXe=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]),Cy=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),$y=new Uint32Array(64),FK=class extends Oy{constructor(){super(64,32,8,!1),this.A=Cy[0]|0,this.B=Cy[1]|0,this.C=Cy[2]|0,this.D=Cy[3]|0,this.E=Cy[4]|0,this.F=Cy[5]|0,this.G=Cy[6]|0,this.H=Cy[7]|0}get(){let{A:e,B:r,C:n,D:i,E:o,F:s,G:a,H:d}=this;return[e,r,n,i,o,s,a,d]}set(e,r,n,i,o,s,a,d){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=d|0}process(e,r){for(let l=0;l<16;l++,r+=4)$y[l]=e.getUint32(r,!1);for(let l=16;l<64;l++){let p=$y[l-15],m=$y[l-2],g=il(p,7)^il(p,18)^p>>>3,v=il(m,17)^il(m,19)^m>>>10;$y[l]=v+$y[l-7]+g+$y[l-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:d,G:u,H:c}=this;for(let l=0;l<64;l++){let p=il(a,6)^il(a,11)^il(a,25),m=c+p+TXe(a,d,u)+IXe[l]+$y[l]|0,v=(il(n,2)^il(n,13)^il(n,22))+PXe(n,i,o)|0;c=u,u=d,d=a,a=s+m|0,s=o,o=i,i=n,n=m+v|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,d=d+this.F|0,u=u+this.G|0,c=c+this.H|0,this.set(n,i,o,s,a,d,u,c)}roundClean(){$y.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var jy=q2(()=>new FK);f();var Pk={};Pr(Pk,{bitGet:()=>CXe,bitLen:()=>OXe,bitMask:()=>n3,bitSet:()=>$Xe,bytesToHex:()=>fp,bytesToNumberBE:()=>hp,bytesToNumberLE:()=>sl,concatBytes:()=>mp,createHmacDrbg:()=>HK,ensureBytes:()=>zn,equalBytes:()=>BXe,hexToBytes:()=>eb,hexToNumber:()=>WK,isBytes:()=>ol,numberToBytesBE:()=>Yi,numberToBytesLE:()=>pp,numberToHexUnpadded:()=>G0e,numberToVarBytesBE:()=>DXe,utf8ToBytes:()=>MXe,validateObject:()=>Zd});f();var V0e=BigInt(0),Tk=BigInt(1),kXe=BigInt(2);function ol(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}var RXe=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function fp(t){if(!ol(t))throw new Error("Uint8Array expected");let e="";for(let r=0;r=lp._0&&t<=lp._9)return t-lp._0;if(t>=lp._A&&t<=lp._F)return t-(lp._A-10);if(t>=lp._a&&t<=lp._f)return t-(lp._a-10)}function eb(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let i=0,o=0;iV0e;t>>=Tk,e+=1);return e}function CXe(t,e){return t>>BigInt(e)&Tk}var $Xe=(t,e,r)=>t|(r?Tk:V0e)<(kXe<new Uint8Array(t),H0e=t=>Uint8Array.from(t);function HK(t,e,r){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=zK(t),i=zK(t),o=0,s=()=>{n.fill(1),i.fill(0),o=0},a=(...l)=>r(i,n,...l),d=(l=zK())=>{i=a(H0e([0]),l),n=a(),l.length!==0&&(i=a(H0e([1]),l),n=a())},u=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,p=[];for(;l{s(),d(l);let m;for(;!(m=p(u()));)d();return s(),m}}var jXe={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||ol(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function Zd(t,e,r={}){let n=(i,o,s)=>{let a=jXe[o];if(typeof a!="function")throw new Error(`Invalid validator "${o}", expected function`);let d=t[i];if(!(s&&d===void 0)&&!a(d,t))throw new Error(`Invalid param ${String(i)}=${d} (${typeof d}), expected ${o}`)};for(let[i,o]of Object.entries(e))n(i,o,!1);for(let[i,o]of Object.entries(r))n(i,o,!0);return t}var mo=BigInt(0),Xn=BigInt(1),tb=BigInt(2),NXe=BigInt(3),VK=BigInt(4),J0e=BigInt(5),Z0e=BigInt(8),UXe=BigInt(9),qXe=BigInt(16);function Xr(t,e){let r=t%e;return r>=mo?r:e+r}function GK(t,e,r){if(r<=mo||e 0");if(r===Xn)return mo;let n=Xn;for(;e>mo;)e&Xn&&(n=n*t%r),t=t*t%r,e>>=Xn;return n}function Wn(t,e,r){let n=t;for(;e-- >mo;)n*=n,n%=r;return n}function Ik(t,e){if(t===mo||e<=mo)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=Xr(t,e),n=e,i=mo,o=Xn,s=Xn,a=mo;for(;r!==mo;){let u=n/r,c=n%r,l=i-s*u,p=o-a*u;n=r,r=c,i=s,o=a,s=l,a=p}if(n!==Xn)throw new Error("invert: does not exist");return Xr(i,e)}function LXe(t){let e=(t-Xn)/tb,r,n,i;for(r=t-Xn,n=0;r%tb===mo;r/=tb,n++);for(i=tb;i(Xr(t,e)&Xn)===Xn,FXe=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function JK(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=FXe.reduce((n,i)=>(n[i]="function",n),e);return Zd(t,r)}function zXe(t,e,r){if(r 0");if(r===mo)return t.ONE;if(r===Xn)return e;let n=t.ONE,i=e;for(;r>mo;)r&Xn&&(n=t.mul(n,i)),i=t.sqr(i),r>>=Xn;return n}function WXe(t,e){let r=new Array(e.length),n=e.reduce((o,s,a)=>t.is0(s)?o:(r[a]=o,t.mul(o,s)),t.ONE),i=t.inv(n);return e.reduceRight((o,s,a)=>t.is0(s)?o:(r[a]=t.mul(o,r[a]),t.mul(o,s)),i),r}function ZK(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function L2(t,e,r=!1,n={}){if(t<=mo)throw new Error(`Expected Field ORDER > 0, got ${t}`);let{nBitLength:i,nByteLength:o}=ZK(t,e);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=KXe(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:o,MASK:n3(i),ZERO:mo,ONE:Xn,create:d=>Xr(d,t),isValid:d=>{if(typeof d!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof d}`);return mo<=d&&dd===mo,isOdd:d=>(d&Xn)===Xn,neg:d=>Xr(-d,t),eql:(d,u)=>d===u,sqr:d=>Xr(d*d,t),add:(d,u)=>Xr(d+u,t),sub:(d,u)=>Xr(d-u,t),mul:(d,u)=>Xr(d*u,t),pow:(d,u)=>zXe(a,d,u),div:(d,u)=>Xr(d*Ik(u,t),t),sqrN:d=>d*d,addN:(d,u)=>d+u,subN:(d,u)=>d-u,mulN:(d,u)=>d*u,inv:d=>Ik(d,t),sqrt:n.sqrt||(d=>s(a,d)),invertBatch:d=>WXe(a,d),cmov:(d,u,c)=>c?u:d,toBytes:d=>r?pp(d,o):Yi(d,o),fromBytes:d=>{if(d.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${d.length}`);return r?sl(d):hp(d)}});return Object.freeze(a)}function X0e(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");let r=t.sqrt(e);return t.isOdd(r)?t.neg(r):r}function Q0e(t){if(typeof t!="bigint")throw new Error("field order must be bigint");let e=t.toString(2).length;return Math.ceil(e/8)}function YK(t){let e=Q0e(t);return e+Math.ceil(e/2)}function ege(t,e,r=!1){let n=t.length,i=Q0e(e),o=YK(e);if(n<16||n1024)throw new Error(`expected ${o}-1024 bytes of input, got ${n}`);let s=r?hp(t):sl(t),a=Xr(s,e-Xn)+Xn;return r?pp(a,i):Yi(a,i)}f();f();var VXe=BigInt(0),XK=BigInt(1);function kk(t,e){let r=(i,o)=>{let s=o.negate();return i?s:o},n=i=>{let o=Math.ceil(e/i)+1,s=2**(i-1);return{windows:o,windowSize:s}};return{constTimeNegate:r,unsafeLadder(i,o){let s=t.ZERO,a=i;for(;o>VXe;)o&XK&&(s=s.add(a)),a=a.double(),o>>=XK;return s},precomputeWindow(i,o){let{windows:s,windowSize:a}=n(o),d=[],u=i,c=u;for(let l=0;l>=m,x>d&&(x-=p,s+=XK);let S=v,P=v+Math.abs(x)-1,A=g%2!==0,$=x<0;x===0?c=c.add(r(A,o[S])):u=u.add(r($,o[P]))}return{p:u,f:c}},wNAFCached(i,o,s,a){let d=i._WINDOW_SIZE||1,u=o.get(i);return u||(u=this.precomputeWindow(i,d),d!==1&&o.set(i,a(u))),this.wNAF(d,u,s)}}}function i3(t){return JK(t.Fp),Zd(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...ZK(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}function GXe(t){let e=i3(t);Zd(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:r,Fp:n,a:i}=e;if(r){if(!n.eql(i,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:JXe,hexToBytes:ZXe}=Pk,rb={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(t){let{Err:e}=rb;if(t.length<2||t[0]!==2)throw new e("Invalid signature integer tag");let r=t[1],n=t.subarray(2,r+2);if(!r||n.length!==r)throw new e("Invalid signature integer: wrong length");if(n[0]&128)throw new e("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:JXe(n),l:t.subarray(r+2)}},toSig(t){let{Err:e}=rb,r=typeof t=="string"?ZXe(t):t;if(!ol(r))throw new Error("ui8a expected");let n=r.length;if(n<2||r[0]!=48)throw new e("Invalid signature tag");if(r[1]!==n-2)throw new e("Invalid signature: incorrect length");let{d:i,l:o}=rb._parseInt(r.subarray(2)),{d:s,l:a}=rb._parseInt(o);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:i,s}},hexFromSig(t){let e=u=>Number.parseInt(u[0],16)&8?"00"+u:u,r=u=>{let c=u.toString(16);return c.length&1?`0${c}`:c},n=e(r(t.s)),i=e(r(t.r)),o=n.length/2,s=i.length/2,a=r(o),d=r(s);return`30${r(s+o+4)}02${d}${i}02${a}${n}`}},yp=BigInt(0),Yd=BigInt(1),bRt=BigInt(2),tge=BigInt(3),wRt=BigInt(4);function YXe(t){let e=GXe(t),{Fp:r}=e,n=e.toBytes||((g,v,x)=>{let S=v.toAffine();return mp(Uint8Array.from([4]),r.toBytes(S.x),r.toBytes(S.y))}),i=e.fromBytes||(g=>{let v=g.subarray(1),x=r.fromBytes(v.subarray(0,r.BYTES)),S=r.fromBytes(v.subarray(r.BYTES,2*r.BYTES));return{x,y:S}});function o(g){let{a:v,b:x}=e,S=r.sqr(g),P=r.mul(S,g);return r.add(r.add(P,r.mul(g,v)),x)}if(!r.eql(r.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function s(g){return typeof g=="bigint"&&ypr.eql(A,r.ZERO);return P(x)&&P(S)?l.ZERO:new l(x,S,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(v){let x=r.invertBatch(v.map(S=>S.pz));return v.map((S,P)=>S.toAffine(x[P])).map(l.fromAffine)}static fromHex(v){let x=l.fromAffine(i(zn("pointHex",v)));return x.assertValidity(),x}static fromPrivateKey(v){return l.BASE.multiply(d(v))}_setWindowSize(v){this._WINDOW_SIZE=v,u.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}let{x:v,y:x}=this.toAffine();if(!r.isValid(v)||!r.isValid(x))throw new Error("bad point: x or y not FE");let S=r.sqr(x),P=o(v);if(!r.eql(S,P))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:v}=this.toAffine();if(r.isOdd)return!r.isOdd(v);throw new Error("Field doesn't support isOdd")}equals(v){c(v);let{px:x,py:S,pz:P}=this,{px:A,py:$,pz:j}=v,L=r.eql(r.mul(x,j),r.mul(A,P)),F=r.eql(r.mul(S,j),r.mul($,P));return L&&F}negate(){return new l(this.px,r.neg(this.py),this.pz)}double(){let{a:v,b:x}=e,S=r.mul(x,tge),{px:P,py:A,pz:$}=this,j=r.ZERO,L=r.ZERO,F=r.ZERO,K=r.mul(P,P),W=r.mul(A,A),q=r.mul($,$),I=r.mul(P,A);return I=r.add(I,I),F=r.mul(P,$),F=r.add(F,F),j=r.mul(v,F),L=r.mul(S,q),L=r.add(j,L),j=r.sub(W,L),L=r.add(W,L),L=r.mul(j,L),j=r.mul(I,j),F=r.mul(S,F),q=r.mul(v,q),I=r.sub(K,q),I=r.mul(v,I),I=r.add(I,F),F=r.add(K,K),K=r.add(F,K),K=r.add(K,q),K=r.mul(K,I),L=r.add(L,K),q=r.mul(A,$),q=r.add(q,q),K=r.mul(q,I),j=r.sub(j,K),F=r.mul(q,W),F=r.add(F,F),F=r.add(F,F),new l(j,L,F)}add(v){c(v);let{px:x,py:S,pz:P}=this,{px:A,py:$,pz:j}=v,L=r.ZERO,F=r.ZERO,K=r.ZERO,W=e.a,q=r.mul(e.b,tge),I=r.mul(x,A),T=r.mul(S,$),B=r.mul(P,j),h=r.add(x,S),y=r.add(A,$);h=r.mul(h,y),y=r.add(I,T),h=r.sub(h,y),y=r.add(x,P);let w=r.add(A,j);return y=r.mul(y,w),w=r.add(I,B),y=r.sub(y,w),w=r.add(S,P),L=r.add($,j),w=r.mul(w,L),L=r.add(T,B),w=r.sub(w,L),K=r.mul(W,y),L=r.mul(q,B),K=r.add(L,K),L=r.sub(T,K),K=r.add(T,K),F=r.mul(L,K),T=r.add(I,I),T=r.add(T,I),B=r.mul(W,B),y=r.mul(q,y),T=r.add(T,B),B=r.sub(I,B),B=r.mul(W,B),y=r.add(y,B),I=r.mul(T,y),F=r.add(F,I),I=r.mul(w,y),L=r.mul(h,L),L=r.sub(L,I),I=r.mul(h,T),K=r.mul(w,K),K=r.add(K,I),new l(L,F,K)}subtract(v){return this.add(v.negate())}is0(){return this.equals(l.ZERO)}wNAF(v){return m.wNAFCached(this,u,v,x=>{let S=r.invertBatch(x.map(P=>P.pz));return x.map((P,A)=>P.toAffine(S[A])).map(l.fromAffine)})}multiplyUnsafe(v){let x=l.ZERO;if(v===yp)return x;if(a(v),v===Yd)return this;let{endo:S}=e;if(!S)return m.unsafeLadder(this,v);let{k1neg:P,k1:A,k2neg:$,k2:j}=S.splitScalar(v),L=x,F=x,K=this;for(;A>yp||j>yp;)A&Yd&&(L=L.add(K)),j&Yd&&(F=F.add(K)),K=K.double(),A>>=Yd,j>>=Yd;return P&&(L=L.negate()),$&&(F=F.negate()),F=new l(r.mul(F.px,S.beta),F.py,F.pz),L.add(F)}multiply(v){a(v);let x=v,S,P,{endo:A}=e;if(A){let{k1neg:$,k1:j,k2neg:L,k2:F}=A.splitScalar(x),{p:K,f:W}=this.wNAF(j),{p:q,f:I}=this.wNAF(F);K=m.constTimeNegate($,K),q=m.constTimeNegate(L,q),q=new l(r.mul(q.px,A.beta),q.py,q.pz),S=K.add(q),P=W.add(I)}else{let{p:$,f:j}=this.wNAF(x);S=$,P=j}return l.normalizeZ([S,P])[0]}multiplyAndAddUnsafe(v,x,S){let P=l.BASE,A=(j,L)=>L===yp||L===Yd||!j.equals(P)?j.multiplyUnsafe(L):j.multiply(L),$=A(this,x).add(A(v,S));return $.is0()?void 0:$}toAffine(v){let{px:x,py:S,pz:P}=this,A=this.is0();v==null&&(v=A?r.ONE:r.inv(P));let $=r.mul(x,v),j=r.mul(S,v),L=r.mul(P,v);if(A)return{x:r.ZERO,y:r.ZERO};if(!r.eql(L,r.ONE))throw new Error("invZ was invalid");return{x:$,y:j}}isTorsionFree(){let{h:v,isTorsionFree:x}=e;if(v===Yd)return!0;if(x)return x(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:v,clearCofactor:x}=e;return v===Yd?this:x?x(l,this):this.multiplyUnsafe(e.h)}toRawBytes(v=!0){return this.assertValidity(),n(l,this,v)}toHex(v=!0){return fp(this.toRawBytes(v))}}l.BASE=new l(e.Gx,e.Gy,r.ONE),l.ZERO=new l(r.ZERO,r.ONE,r.ZERO);let p=e.nBitLength,m=kk(l,e.endo?Math.ceil(p/2):p);return{CURVE:e,ProjectivePoint:l,normPrivateKeyToScalar:d,weierstrassEquation:o,isWithinCurveOrder:s}}function XXe(t){let e=i3(t);return Zd(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function rge(t){let e=XXe(t),{Fp:r,n}=e,i=r.BYTES+1,o=2*r.BYTES+1;function s(y){return ypfp(Yi(y,e.nByteLength));function g(y){let w=n>>Yd;return y>w}function v(y){return g(y)?a(-y):y}let x=(y,w,E)=>hp(y.slice(w,E));class S{constructor(w,E,_){this.r=w,this.s=E,this.recovery=_,this.assertValidity()}static fromCompact(w){let E=e.nByteLength;return w=zn("compactSignature",w,E*2),new S(x(w,0,E),x(w,E,2*E))}static fromDER(w){let{r:E,s:_}=rb.toSig(zn("DER",w));return new S(E,_)}assertValidity(){if(!p(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!p(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(w){return new S(this.r,this.s,w)}recoverPublicKey(w){let{r:E,s:_,recovery:b}=this,C=F(zn("msgHash",w));if(b==null||![0,1,2,3].includes(b))throw new Error("recovery id invalid");let N=b===2||b===3?E+e.n:E;if(N>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let M=b&1?"03":"02",U=u.fromHex(M+m(N)),G=d(N),Z=a(-C*G),J=a(_*G),H=u.BASE.multiplyAndAddUnsafe(U,Z,J);if(!H)throw new Error("point at infinify");return H.assertValidity(),H}hasHighS(){return g(this.s)}normalizeS(){return this.hasHighS()?new S(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return eb(this.toDERHex())}toDERHex(){return rb.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return eb(this.toCompactHex())}toCompactHex(){return m(this.r)+m(this.s)}}let P={isValidPrivateKey(y){try{return c(y),!0}catch{return!1}},normPrivateKeyToScalar:c,randomPrivateKey:()=>{let y=YK(e.n);return ege(e.randomBytes(y),e.n)},precompute(y=8,w=u.BASE){return w._setWindowSize(y),w.multiply(BigInt(3)),w}};function A(y,w=!0){return u.fromPrivateKey(y).toRawBytes(w)}function $(y){let w=ol(y),E=typeof y=="string",_=(w||E)&&y.length;return w?_===i||_===o:E?_===2*i||_===2*o:y instanceof u}function j(y,w,E=!0){if($(y))throw new Error("first arg must be private key");if(!$(w))throw new Error("second arg must be public key");return u.fromHex(w).multiply(c(y)).toRawBytes(E)}let L=e.bits2int||function(y){let w=hp(y),E=y.length*8-e.nBitLength;return E>0?w>>BigInt(E):w},F=e.bits2int_modN||function(y){return a(L(y))},K=n3(e.nBitLength);function W(y){if(typeof y!="bigint")throw new Error("bigint expected");if(!(yp<=y&&yte in E))throw new Error("sign() legacy options not supported");let{hash:_,randomBytes:b}=e,{lowS:C,prehash:N,extraEntropy:M}=E;C==null&&(C=!0),y=zn("msgHash",y),N&&(y=zn("prehashed msgHash",_(y)));let U=F(y),G=c(w),Z=[W(G),W(U)];if(M!=null){let te=M===!0?b(r.BYTES):M;Z.push(zn("extraEntropy",te))}let J=mp(...Z),H=U;function X(te){let ne=L(te);if(!p(ne))return;let Q=d(ne),re=u.BASE.multiply(ne).toAffine(),ce=a(re.x);if(ce===yp)return;let pe=a(Q*a(H+ce*G));if(pe===yp)return;let ye=(re.x===ce?0:2)|Number(re.y&Yd),ie=pe;return C&&g(pe)&&(ie=v(pe),ye^=1),new S(ce,ie,ye)}return{seed:J,k2sig:X}}let I={lowS:e.lowS,prehash:!1},T={lowS:e.lowS,prehash:!1};function B(y,w,E=I){let{seed:_,k2sig:b}=q(y,w,E),C=e;return HK(C.hash.outputLen,C.nByteLength,C.hmac)(_,b)}u.BASE._setWindowSize(8);function h(y,w,E,_=T){let b=y;if(w=zn("msgHash",w),E=zn("publicKey",E),"strict"in _)throw new Error("options.strict was renamed to lowS");let{lowS:C,prehash:N}=_,M,U;try{if(typeof b=="string"||ol(b))try{M=S.fromDER(b)}catch(re){if(!(re instanceof rb.Err))throw re;M=S.fromCompact(b)}else if(typeof b=="object"&&typeof b.r=="bigint"&&typeof b.s=="bigint"){let{r:re,s:ce}=b;M=new S(re,ce)}else throw new Error("PARSE");U=u.fromHex(E)}catch(re){if(re.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(C&&M.hasHighS())return!1;N&&(w=e.hash(w));let{r:G,s:Z}=M,J=F(w),H=d(Z),X=a(J*H),te=a(G*H),ne=u.BASE.multiplyAndAddUnsafe(U,X,te)?.toAffine();return ne?a(ne.x)===G:!1}return{CURVE:e,getPublicKey:A,getSharedSecret:j,sign:B,verify:h,ProjectivePoint:u,Signature:S,utils:P}}f();f();var Rk=class extends U2{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,Sk(e);let n=My(r);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let i=this.blockLen,o=new Uint8Array(i);o.set(n.length>i?e.create().update(n).digest():n);for(let s=0;snew Rk(t,e).update(r).digest();Ny.create=(t,e)=>new Rk(t,e);function QXe(t){return{hash:t,hmac:(e,...r)=>Ny(t,e,Xv(...r)),randomBytes:Qv}}function Dk(t,e){let r=n=>rge({...t,...QXe(n)});return Object.freeze({...r(e),create:r})}var oge=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),nge=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),eQe=BigInt(1),QK=BigInt(2),ige=(t,e)=>(t+e/QK)/e;function tQe(t){let e=oge,r=BigInt(3),n=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),d=BigInt(88),u=t*t*t%e,c=u*u*t%e,l=Wn(c,r,e)*c%e,p=Wn(l,r,e)*c%e,m=Wn(p,QK,e)*u%e,g=Wn(m,i,e)*m%e,v=Wn(g,o,e)*g%e,x=Wn(v,a,e)*v%e,S=Wn(x,d,e)*x%e,P=Wn(S,a,e)*v%e,A=Wn(P,r,e)*c%e,$=Wn(A,s,e)*g%e,j=Wn($,n,e)*u%e,L=Wn(j,QK,e);if(!eF.eql(eF.sqr(L),t))throw new Error("Cannot find square root");return L}var eF=L2(oge,void 0,void 0,{sqrt:tQe}),Rn=Dk({a:BigInt(0),b:BigInt(7),Fp:eF,n:nge,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{let e=nge,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-eQe*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=r,s=BigInt("0x100000000000000000000000000000000"),a=ige(o*t,e),d=ige(-n*t,e),u=Xr(t-a*r-d*i,e),c=Xr(-a*n-d*o,e),l=u>s,p=c>s;if(l&&(u=e-u),p&&(c=e-c),u>s||c>s)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:l,k1:u,k2neg:p,k2:c}}}},jy),CRt=BigInt(0);var $Rt=Rn.ProjectivePoint;f();f();function sge(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 rQe=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},tF="urn:jwk:";function gr(t){return rQe(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}`);Fq(n);let i=sge(n),o=xt.string(i).toUint8Array(),s=yield j2.digest({data:o});return xt.uint8Array(s).toBase64Url()})}function Rf(t){return!(!t||typeof t!="object"||!("kty"in t&&"crv"in t&&"x"in t&&"d"in t)||t.kty!=="EC"||typeof t.d!="string"||typeof t.x!="string")}function K2(t){return!(!t||typeof t!="object"||!("kty"in t&&"crv"in t&&"x"in t)||"d"in t||t.kty!=="EC"||typeof t.x!="string")}function Df(t){return!(!t||typeof t!="object"||!("kty"in t&&"crv"in t&&"x"in t&&"d"in t)||t.kty!=="OKP"||typeof t.d!="string"||typeof t.x!="string")}function F2(t){return!(!t||typeof t!="object"||"d"in t||!("kty"in t&&"crv"in t&&"x"in t)||t.kty!=="OKP"||typeof t.x!="string")}function age(t){if(!t||typeof t!="object")return!1;switch(t.kty){case"EC":case"OKP":case"RSA":return"d"in t;case"oct":return"k"in t;default:return!1}}var Ps=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},nQe=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i>rF&Bk)}:{h:Number(t>>rF&Bk)|0,l:Number(t&Bk)|0}}function cQe(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;iBigInt(t>>>0)<>>0),uQe=(t,e,r)=>t>>>r,lQe=(t,e,r)=>t<<32-r|e>>>r,fQe=(t,e,r)=>t>>>r|e<<32-r,hQe=(t,e,r)=>t<<32-r|e>>>r,pQe=(t,e,r)=>t<<64-r|e>>>r-32,mQe=(t,e,r)=>t>>>r-32|e<<64-r,yQe=(t,e)=>e,gQe=(t,e)=>t,vQe=(t,e,r)=>t<>>32-r,bQe=(t,e,r)=>e<>>32-r,wQe=(t,e,r)=>e<>>64-r,_Qe=(t,e,r)=>t<>>64-r;function xQe(t,e,r,n){let i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}var EQe=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),SQe=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,AQe=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),TQe=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0,PQe=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0),IQe=(t,e,r,n,i,o)=>e+r+n+i+o+(t/2**32|0)|0;var kQe={fromBig:dge,split:cQe,toBig:dQe,shrSH:uQe,shrSL:lQe,rotrSH:fQe,rotrSL:hQe,rotrBH:pQe,rotrBL:mQe,rotr32H:yQe,rotr32L:gQe,rotlSH:vQe,rotlSL:bQe,rotlBH:wQe,rotlBL:_Qe,add:xQe,add3L:EQe,add3H:SQe,add4L:AQe,add4H:TQe,add5H:IQe,add5L:PQe},ir=kQe;var[RQe,DQe]=ir.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),Uy=new Uint32Array(80),qy=new Uint32Array(80),nF=class extends Oy{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:r,Bh:n,Bl:i,Ch:o,Cl:s,Dh:a,Dl:d,Eh:u,El:c,Fh:l,Fl:p,Gh:m,Gl:g,Hh:v,Hl:x}=this;return[e,r,n,i,o,s,a,d,u,c,l,p,m,g,v,x]}set(e,r,n,i,o,s,a,d,u,c,l,p,m,g,v,x){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=o|0,this.Cl=s|0,this.Dh=a|0,this.Dl=d|0,this.Eh=u|0,this.El=c|0,this.Fh=l|0,this.Fl=p|0,this.Gh=m|0,this.Gl=g|0,this.Hh=v|0,this.Hl=x|0}process(e,r){for(let A=0;A<16;A++,r+=4)Uy[A]=e.getUint32(r),qy[A]=e.getUint32(r+=4);for(let A=16;A<80;A++){let $=Uy[A-15]|0,j=qy[A-15]|0,L=ir.rotrSH($,j,1)^ir.rotrSH($,j,8)^ir.shrSH($,j,7),F=ir.rotrSL($,j,1)^ir.rotrSL($,j,8)^ir.shrSL($,j,7),K=Uy[A-2]|0,W=qy[A-2]|0,q=ir.rotrSH(K,W,19)^ir.rotrBH(K,W,61)^ir.shrSH(K,W,6),I=ir.rotrSL(K,W,19)^ir.rotrBL(K,W,61)^ir.shrSL(K,W,6),T=ir.add4L(F,I,qy[A-7],qy[A-16]),B=ir.add4H(T,L,q,Uy[A-7],Uy[A-16]);Uy[A]=B|0,qy[A]=T|0}let{Ah:n,Al:i,Bh:o,Bl:s,Ch:a,Cl:d,Dh:u,Dl:c,Eh:l,El:p,Fh:m,Fl:g,Gh:v,Gl:x,Hh:S,Hl:P}=this;for(let A=0;A<80;A++){let $=ir.rotrSH(l,p,14)^ir.rotrSH(l,p,18)^ir.rotrBH(l,p,41),j=ir.rotrSL(l,p,14)^ir.rotrSL(l,p,18)^ir.rotrBL(l,p,41),L=l&m^~l&v,F=p&g^~p&x,K=ir.add5L(P,j,F,DQe[A],qy[A]),W=ir.add5H(K,S,$,L,RQe[A],Uy[A]),q=K|0,I=ir.rotrSH(n,i,28)^ir.rotrBH(n,i,34)^ir.rotrBH(n,i,39),T=ir.rotrSL(n,i,28)^ir.rotrBL(n,i,34)^ir.rotrBL(n,i,39),B=n&o^n&a^o&a,h=i&s^i&d^s&d;S=v|0,P=x|0,v=m|0,x=g|0,m=l|0,g=p|0,{h:l,l:p}=ir.add(u|0,c|0,W|0,q|0),u=a|0,c=d|0,a=o|0,d=s|0,o=n|0,s=i|0;let y=ir.add3L(q,T,h);n=ir.add3H(y,W,I,B),i=y|0}({h:n,l:i}=ir.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:o,l:s}=ir.add(this.Bh|0,this.Bl|0,o|0,s|0),{h:a,l:d}=ir.add(this.Ch|0,this.Cl|0,a|0,d|0),{h:u,l:c}=ir.add(this.Dh|0,this.Dl|0,u|0,c|0),{h:l,l:p}=ir.add(this.Eh|0,this.El|0,l|0,p|0),{h:m,l:g}=ir.add(this.Fh|0,this.Fl|0,m|0,g|0),{h:v,l:x}=ir.add(this.Gh|0,this.Gl|0,v|0,x|0),{h:S,l:P}=ir.add(this.Hh|0,this.Hl|0,S|0,P|0),this.set(n,i,o,s,a,d,u,c,l,p,m,g,v,x,S,P)}roundClean(){Uy.fill(0),qy.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var Ly=q2(()=>new nF);f();var al=BigInt(0),Qc=BigInt(1),Mk=BigInt(2),BQe=BigInt(8),MQe={zip215:!0};function OQe(t){let e=i3(t);return Zd(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function Ok(t){let e=OQe(t),{Fp:r,n,prehash:i,hash:o,randomBytes:s,nByteLength:a,h:d}=e,u=Mk<{try{return{isValid:!0,value:r.sqrt(_*r.inv(b))}}catch{return{isValid:!1,value:al}}}),p=e.adjustScalarBytes||(_=>_),m=e.domain||((_,b,C)=>{if(b.length||C)throw new Error("Contexts/pre-hash are not supported");return _}),g=_=>typeof _=="bigint"&&al<_,v=(_,b)=>g(_)&&g(b)&&__===al||v(_,u);function S(_,b){if(v(_,b))return _;throw new Error(`Expected valid scalar < ${b}, got ${typeof _} ${_}`)}function P(_){return _===al?_:S(_,n)}let A=new Map;function $(_){if(!(_ instanceof j))throw new Error("ExtendedPoint expected")}class j{constructor(b,C,N,M){if(this.ex=b,this.ey=C,this.ez=N,this.et=M,!x(b))throw new Error("x required");if(!x(C))throw new Error("y required");if(!x(N))throw new Error("z required");if(!x(M))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(b){if(b instanceof j)throw new Error("extended point not allowed");let{x:C,y:N}=b||{};if(!x(C)||!x(N))throw new Error("invalid affine point");return new j(C,N,Qc,c(C*N))}static normalizeZ(b){let C=r.invertBatch(b.map(N=>N.ez));return b.map((N,M)=>N.toAffine(C[M])).map(j.fromAffine)}_setWindowSize(b){this._WINDOW_SIZE=b,A.delete(this)}assertValidity(){let{a:b,d:C}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:N,ey:M,ez:U,et:G}=this,Z=c(N*N),J=c(M*M),H=c(U*U),X=c(H*H),te=c(Z*b),ne=c(H*c(te+J)),Q=c(X+c(C*c(Z*J)));if(ne!==Q)throw new Error("bad point: equation left != right (1)");let re=c(N*M),ce=c(U*G);if(re!==ce)throw new Error("bad point: equation left != right (2)")}equals(b){$(b);let{ex:C,ey:N,ez:M}=this,{ex:U,ey:G,ez:Z}=b,J=c(C*Z),H=c(U*M),X=c(N*Z),te=c(G*M);return J===H&&X===te}is0(){return this.equals(j.ZERO)}negate(){return new j(c(-this.ex),this.ey,this.ez,c(-this.et))}double(){let{a:b}=e,{ex:C,ey:N,ez:M}=this,U=c(C*C),G=c(N*N),Z=c(Mk*c(M*M)),J=c(b*U),H=C+N,X=c(c(H*H)-U-G),te=J+G,ne=te-Z,Q=J-G,re=c(X*ne),ce=c(te*Q),pe=c(X*Q),ye=c(ne*te);return new j(re,ce,ye,pe)}add(b){$(b);let{a:C,d:N}=e,{ex:M,ey:U,ez:G,et:Z}=this,{ex:J,ey:H,ez:X,et:te}=b;if(C===BigInt(-1)){let Et=c((U-M)*(H+J)),Fe=c((U+M)*(H-J)),mt=c(Fe-Et);if(mt===al)return this.double();let En=c(G*Mk*te),ke=c(Z*Mk*X),Pe=ke+En,Wt=Fe+Et,Be=ke-En,Ee=c(Pe*mt),Cr=c(Wt*Be),Ve=c(Pe*Be),Ze=c(mt*Wt);return new j(Ee,Cr,Ze,Ve)}let ne=c(M*J),Q=c(U*H),re=c(Z*N*te),ce=c(G*X),pe=c((M+U)*(J+H)-ne-Q),ye=ce-re,ie=ce+re,he=c(Q-C*ne),me=c(pe*ye),Re=c(ie*he),xe=c(pe*he),it=c(ye*ie);return new j(me,Re,it,xe)}subtract(b){return this.add(b.negate())}wNAF(b){return K.wNAFCached(this,A,b,j.normalizeZ)}multiply(b){let{p:C,f:N}=this.wNAF(S(b,n));return j.normalizeZ([C,N])[0]}multiplyUnsafe(b){let C=P(b);return C===al?F:this.equals(F)||C===Qc?this:this.equals(L)?this.wNAF(C).p:K.unsafeLadder(this,C)}isSmallOrder(){return this.multiplyUnsafe(d).is0()}isTorsionFree(){return K.unsafeLadder(this,n).is0()}toAffine(b){let{ex:C,ey:N,ez:M}=this,U=this.is0();b==null&&(b=U?BQe:r.inv(M));let G=c(C*b),Z=c(N*b),J=c(M*b);if(U)return{x:al,y:Qc};if(J!==Qc)throw new Error("invZ was invalid");return{x:G,y:Z}}clearCofactor(){let{h:b}=e;return b===Qc?this:this.multiplyUnsafe(b)}static fromHex(b,C=!1){let{d:N,a:M}=e,U=r.BYTES;b=zn("pointHex",b,U);let G=b.slice(),Z=b[U-1];G[U-1]=Z&-129;let J=sl(G);J===al||(C?S(J,u):S(J,r.ORDER));let H=c(J*J),X=c(H-Qc),te=c(N*H-M),{isValid:ne,value:Q}=l(X,te);if(!ne)throw new Error("Point.fromHex: invalid y coordinate");let re=(Q&Qc)===Qc,ce=(Z&128)!==0;if(!C&&Q===al&&ce)throw new Error("Point.fromHex: x=0 and x_0=1");return ce!==re&&(Q=c(-Q)),j.fromAffine({x:Q,y:J})}static fromPrivateKey(b){return I(b).point}toRawBytes(){let{x:b,y:C}=this.toAffine(),N=pp(C,r.BYTES);return N[N.length-1]|=b&Qc?128:0,N}toHex(){return fp(this.toRawBytes())}}j.BASE=new j(e.Gx,e.Gy,Qc,c(e.Gx*e.Gy)),j.ZERO=new j(al,Qc,Qc,al);let{BASE:L,ZERO:F}=j,K=kk(j,a*8);function W(_){return Xr(_,n)}function q(_){return W(sl(_))}function I(_){let b=a;_=zn("private key",_,b);let C=zn("hashed private key",o(_),2*b),N=p(C.slice(0,b)),M=C.slice(b,2*b),U=q(N),G=L.multiply(U),Z=G.toRawBytes();return{head:N,prefix:M,scalar:U,point:G,pointBytes:Z}}function T(_){return I(_).pointBytes}function B(_=new Uint8Array,...b){let C=mp(...b);return q(o(m(C,zn("context",_),!!i)))}function h(_,b,C={}){_=zn("message",_),i&&(_=i(_));let{prefix:N,scalar:M,pointBytes:U}=I(b),G=B(C.context,N,_),Z=L.multiply(G).toRawBytes(),J=B(C.context,Z,U,_),H=W(G+J*M);P(H);let X=mp(Z,pp(H,r.BYTES));return zn("result",X,a*2)}let y=MQe;function w(_,b,C,N=y){let{context:M,zip215:U}=N,G=r.BYTES;_=zn("signature",_,2*G),b=zn("message",b),i&&(b=i(b));let Z=sl(_.slice(G,2*G)),J,H,X;try{J=j.fromHex(C,U),H=j.fromHex(_.slice(0,G),U),X=L.multiplyUnsafe(Z)}catch{return!1}if(!U&&J.isSmallOrder())return!1;let te=B(M,H.toRawBytes(),J.toRawBytes(),b);return H.add(J.multiplyUnsafe(te)).subtract(X).clearCofactor().equals(j.ZERO)}return L._setWindowSize(8),{CURVE:e,getPublicKey:T,sign:h,verify:w,ExtendedPoint:j,utils:{getExtendedPublicKey:I,randomPrivateKey:()=>s(r.BYTES),precompute(_=8,b=j.BASE){return b._setWindowSize(_),b.multiply(BigInt(3)),b}}}}f();var a3=BigInt(0),iF=BigInt(1);function CQe(t){return Zd(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function uge(t){let e=CQe(t),{P:r}=e,n=A=>Xr(A,r),i=e.montgomeryBits,o=Math.ceil(i/8),s=e.nByteLength,a=e.adjustScalarBytes||(A=>A),d=e.powPminus2||(A=>GK(A,r-BigInt(2),r));function u(A,$,j){let L=n(A*($-j));return $=n($-L),j=n(j+L),[$,j]}function c(A){if(typeof A=="bigint"&&a3<=A&&A=a3;y--){let w=L>>y&iF;T^=w,B=u(T,K,q),K=B[0],q=B[1],B=u(T,W,I),W=B[0],I=B[1],T=w;let E=K+W,_=n(E*E),b=K-W,C=n(b*b),N=_-C,M=q+I,U=q-I,G=n(U*E),Z=n(M*b),J=G+Z,H=G-Z;q=n(J*J),I=n(F*n(H*H)),K=n(_*C),W=n(N*(_+n(l*N)))}B=u(T,K,q),K=B[0],q=B[1],B=u(T,W,I),W=B[0],I=B[1];let h=d(W);return n(K*h)}function m(A){return pp(n(A),o)}function g(A){let $=zn("u coordinate",A,o);return s===32&&($[31]&=127),sl($)}function v(A){let $=zn("scalar",A),j=$.length;if(j!==o&&j!==s)throw new Error(`Expected ${o} or ${s} bytes, got ${j}`);return sl(a($))}function x(A,$){let j=g($),L=v(A),F=p(j,L);if(F===a3)throw new Error("Invalid private or public key received");return m(F)}let S=m(e.Gu);function P(A){return x(A,S)}return{scalarMult:x,scalarMultBase:P,getSharedSecret:(A,$)=>x(A,$),getPublicKey:A=>P(A),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:S}}var c3=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),lge=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),NDt=BigInt(0),$Qe=BigInt(1),oF=BigInt(2),jQe=BigInt(5),fge=BigInt(10),NQe=BigInt(20),UQe=BigInt(40),hge=BigInt(80);function pge(t){let e=c3,n=t*t%e*t%e,i=Wn(n,oF,e)*n%e,o=Wn(i,$Qe,e)*t%e,s=Wn(o,jQe,e)*o%e,a=Wn(s,fge,e)*s%e,d=Wn(a,NQe,e)*a%e,u=Wn(d,UQe,e)*d%e,c=Wn(u,hge,e)*u%e,l=Wn(c,hge,e)*u%e,p=Wn(l,fge,e)*s%e;return{pow_p_5_8:Wn(p,oF,e)*t%e,b2:n}}function mge(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function qQe(t,e){let r=c3,n=Xr(e*e*e,r),i=Xr(n*n*e,r),o=pge(t*i).pow_p_5_8,s=Xr(t*n*o,r),a=Xr(e*s*s,r),d=s,u=Xr(s*lge,r),c=a===t,l=a===Xr(-t,r),p=a===Xr(-t*lge,r);return c&&(s=d),(l||p)&&(s=u),Y0e(s,r)&&(s=Xr(-s,r)),{isValid:c||l,value:s}}var Xd=L2(c3,void 0,!0),d3={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Xd,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Ly,randomBytes:Qv,adjustScalarBytes:mge,uvRatio:qQe},yo=Ok(d3);function yge(t,e,r){if(e.length>255)throw new Error("Context is too big");return Xv(r3("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,e.length]),e,t)}var UDt=Ok({...d3,domain:yge}),qDt=Ok({...d3,domain:yge,prehash:Ly}),fc=uge({P:c3,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{let e=c3,{pow_p_5_8:r,b2:n}=pge(t);return Xr(Wn(r,BigInt(3),e)*n,e)},adjustScalarBytes:mge,randomBytes:Qv});function Ck(t){let{y:e}=yo.ExtendedPoint.fromHex(t),r=BigInt(1);return Xd.toBytes(Xd.create((r+e)*Xd.inv(r-e)))}function $k(t){let e=d3.hash(t.subarray(0,32));return d3.adjustScalarBytes(e).subarray(0,32)}var LQe=(Xd.ORDER+BigInt(3))/BigInt(8),LDt=Xd.pow(oF,LQe),KDt=Xd.sqrt(Xd.neg(Xd.ONE)),FDt=(Xd.ORDER-BigInt(5))/BigInt(8),zDt=BigInt(486662);var WDt=X0e(Xd,Xd.neg(BigInt(486664)));var HDt=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),VDt=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),GDt=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),JDt=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");var ZDt=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var Qd=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},KQe=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);iFQe,checkRequiredProperty:()=>gge,checkValidProperty:()=>vge,getJoseSignatureAlgorithmFromPublicKey:()=>bge,isWebCryptoSupported:()=>wge,randomBytes:()=>Nk,randomPin:()=>xge,randomUuid:()=>_ge});f();function gge(t){if(!t||t.property===void 0||t.inObject===void 0)throw new TypeError("One or more required parameters missing: 'property, properties'");let{property:e,inObject:r}=t;if(!(e in r))throw new TypeError(`Required parameter missing: '${e}'`)}function vge(t){if(!t||t.property===void 0||t.allowedProperties===void 0)throw new TypeError("One or more required parameters missing: 'property, allowedProperties'");let{property:e,allowedProperties:r}=t;if(Array.isArray(r)&&!r.includes(e)||r instanceof Set&&!r.has(e)||r instanceof Map&&!r.has(e)){let n=Array.from(r instanceof Map?r.keys():r).join(", ");throw new TypeError(`Out of range: '${e}'. Must be one of '${n}'`)}}function bge(t){let e={Ed25519:"EdDSA","P-256":"ES256","P-384":"ES384","P-521":"ES512",secp256k1:"ES256K"};if(t.alg&&Object.values(e).includes(t.alg))return t.alg;if(t.crv&&Object.keys(e).includes(t.crv))return e[t.crv];throw new Error(`Unable to determine algorithm based on provided input: alg=${t.alg}, crv=${t.crv}. Supported 'alg' values: ${Object.values(e).join(", ")}. Supported 'crv' values: ${Object.keys(e).join(", ")}.`)}function wge(){return!!(globalThis.crypto&&globalThis.crypto.subtle)}function Nk(t){return Gb(t)}function _ge(){return Hp.randomUUID()}function xge({length:t}){if(3>t||t>10)throw new Error("randomPin() can securely generate a PIN between 3 to 10 digits.");let e=Math.pow(10,t)-1,r;if(t<=6){let n=Math.pow(10,t);do{let i=Nk(Math.ceil(t/2));r=new DataView(i.buffer).getUint16(0,!1)%n}while(r>e)}else{let n=Math.pow(10,10);do{let i=Nk(4);r=new DataView(i.buffer).getUint32(0,!1)%n}while(r>e)}return r.toString().padStart(t,"0")}var FQe={randomPin:xge,randomUuid:_ge,randomBytes:Nk,isWebCryptoSupported:wge,getJoseSignatureAlgorithmFromPublicKey:bge,checkValidProperty:vge,checkRequiredProperty:gge};f();f();f();f();f();f();f();f();f();f();var Ky=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},zQe=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);it[e++]&255|(t[e++]&255)<<8,cF=class{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,e=FT(e),ao(e,32);let r=Rs(e,0),n=Rs(e,2),i=Rs(e,4),o=Rs(e,6),s=Rs(e,8),a=Rs(e,10),d=Rs(e,12),u=Rs(e,14);this.r[0]=r&8191,this.r[1]=(r>>>13|n<<3)&8191,this.r[2]=(n>>>10|i<<6)&7939,this.r[3]=(i>>>7|o<<9)&8191,this.r[4]=(o>>>4|s<<12)&255,this.r[5]=s>>>1&8190,this.r[6]=(s>>>14|a<<2)&8191,this.r[7]=(a>>>11|d<<5)&8065,this.r[8]=(d>>>8|u<<8)&8191,this.r[9]=u>>>5&127;for(let c=0;c<8;c++)this.pad[c]=Rs(e,16+2*c)}process(e,r,n=!1){let i=n?0:2048,{h:o,r:s}=this,a=s[0],d=s[1],u=s[2],c=s[3],l=s[4],p=s[5],m=s[6],g=s[7],v=s[8],x=s[9],S=Rs(e,r+0),P=Rs(e,r+2),A=Rs(e,r+4),$=Rs(e,r+6),j=Rs(e,r+8),L=Rs(e,r+10),F=Rs(e,r+12),K=Rs(e,r+14),W=o[0]+(S&8191),q=o[1]+((S>>>13|P<<3)&8191),I=o[2]+((P>>>10|A<<6)&8191),T=o[3]+((A>>>7|$<<9)&8191),B=o[4]+(($>>>4|j<<12)&8191),h=o[5]+(j>>>1&8191),y=o[6]+((j>>>14|L<<2)&8191),w=o[7]+((L>>>11|F<<5)&8191),E=o[8]+((F>>>8|K<<8)&8191),_=o[9]+(K>>>5|i),b=0,C=b+W*a+q*(5*x)+I*(5*v)+T*(5*g)+B*(5*m);b=C>>>13,C&=8191,C+=h*(5*p)+y*(5*l)+w*(5*c)+E*(5*u)+_*(5*d),b+=C>>>13,C&=8191;let N=b+W*d+q*a+I*(5*x)+T*(5*v)+B*(5*g);b=N>>>13,N&=8191,N+=h*(5*m)+y*(5*p)+w*(5*l)+E*(5*c)+_*(5*u),b+=N>>>13,N&=8191;let M=b+W*u+q*d+I*a+T*(5*x)+B*(5*v);b=M>>>13,M&=8191,M+=h*(5*g)+y*(5*m)+w*(5*p)+E*(5*l)+_*(5*c),b+=M>>>13,M&=8191;let U=b+W*c+q*u+I*d+T*a+B*(5*x);b=U>>>13,U&=8191,U+=h*(5*v)+y*(5*g)+w*(5*m)+E*(5*p)+_*(5*l),b+=U>>>13,U&=8191;let G=b+W*l+q*c+I*u+T*d+B*a;b=G>>>13,G&=8191,G+=h*(5*x)+y*(5*v)+w*(5*g)+E*(5*m)+_*(5*p),b+=G>>>13,G&=8191;let Z=b+W*p+q*l+I*c+T*u+B*d;b=Z>>>13,Z&=8191,Z+=h*a+y*(5*x)+w*(5*v)+E*(5*g)+_*(5*m),b+=Z>>>13,Z&=8191;let J=b+W*m+q*p+I*l+T*c+B*u;b=J>>>13,J&=8191,J+=h*d+y*a+w*(5*x)+E*(5*v)+_*(5*g),b+=J>>>13,J&=8191;let H=b+W*g+q*m+I*p+T*l+B*c;b=H>>>13,H&=8191,H+=h*u+y*d+w*a+E*(5*x)+_*(5*v),b+=H>>>13,H&=8191;let X=b+W*v+q*g+I*m+T*p+B*l;b=X>>>13,X&=8191,X+=h*c+y*u+w*d+E*a+_*(5*x),b+=X>>>13,X&=8191;let te=b+W*x+q*v+I*g+T*m+B*p;b=te>>>13,te&=8191,te+=h*l+y*c+w*u+E*d+_*a,b+=te>>>13,te&=8191,b=(b<<2)+b|0,b=b+C|0,C=b&8191,b=b>>>13,N+=b,o[0]=C,o[1]=N,o[2]=M,o[3]=U,o[4]=G,o[5]=Z,o[6]=J,o[7]=H,o[8]=X,o[9]=te}finalize(){let{h:e,pad:r}=this,n=new Uint16Array(10),i=e[1]>>>13;e[1]&=8191;for(let a=2;a<10;a++)e[a]+=i,i=e[a]>>>13,e[a]&=8191;e[0]+=i*5,i=e[0]>>>13,e[0]&=8191,e[1]+=i,i=e[1]>>>13,e[1]&=8191,e[2]+=i,n[0]=e[0]+5,i=n[0]>>>13,n[0]&=8191;for(let a=1;a<10;a++)n[a]=e[a]+i,i=n[a]>>>13,n[a]&=8191;n[9]-=8192;let o=(i^1)-1;for(let a=0;a<10;a++)n[a]&=o;o=~o;for(let a=0;a<10;a++)e[a]=e[a]&o|n[a];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let s=e[0]+r[0];e[0]=s&65535;for(let a=1;a<8;a++)s=(e[a]+r[a]|0)+(s>>>16)|0,e[a]=s&65535}update(e){Sj(this);let{buffer:r,blockLen:n}=this;e=FT(e);let i=e.length;for(let o=0;o>>0,e[o++]=n[s]>>>8;return e}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}};function WQe(t){let e=(n,i)=>t(i).update(FT(n)).digest(),r=t(new Uint8Array(32));return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}var Ege=WQe(t=>new cF(t));f();var Age=t=>Uint8Array.from(t.split("").map(e=>e.charCodeAt(0))),HQe=Age("expand 16-byte k"),VQe=Age("expand 32-byte k"),GQe=$h(HQe),Tge=$h(VQe),rBt=Tge.slice();function Qe(t,e){return t<>>32-e}function dF(t){return t.byteOffset%4===0}var qk=64,JQe=16,Pge=2**32-1,Sge=new Uint32Array;function ZQe(t,e,r,n,i,o,s,a){let d=i.length,u=new Uint8Array(qk),c=$h(u),l=dF(i)&&dF(o),p=l?$h(i):Sge,m=l?$h(o):Sge;for(let g=0;g=Pge)throw new Error("arx: counter overflow");let v=Math.min(qk,d-g);if(l&&v===qk){let x=g/4;if(g%4!==0)throw new Error("arx: invalid block position");for(let S=0,P;S{ao(a),ao(d),ao(u);let p=u.length;if(c||(c=new Uint8Array(p)),ao(c),c6(l),l<0||l>=Pge)throw new Error("arx: counter overflow");if(c.length0;)m.pop().fill(0);return c}}function Rge(t,e,r,n,i,o=20){let s=t[0],a=t[1],d=t[2],u=t[3],c=e[0],l=e[1],p=e[2],m=e[3],g=e[4],v=e[5],x=e[6],S=e[7],P=i,A=r[0],$=r[1],j=r[2],L=s,F=a,K=d,W=u,q=c,I=l,T=p,B=m,h=g,y=v,w=x,E=S,_=P,b=A,C=$,N=j;for(let U=0;U{t.update(e);let r=e.length%16;r&&t.update(eet.subarray(r))},tet=new Uint8Array(32);function kge(t,e,r,n,i){let o=t(e,r,tet),s=Ege.create(o);i&&Ige(s,i),Ige(s,n);let a=new Uint8Array(16),d=yde(a);Tj(d,0,BigInt(i?i.length:0),!0),Tj(d,8,BigInt(n.length),!0),s.update(a);let u=s.digest();return o.fill(0),u}var Dge=t=>(e,r,n)=>(ao(e,32),ao(r),{encrypt:(o,s)=>{let a=o.length,d=a+16;s?ao(s,d):s=new Uint8Array(d),t(e,r,o,s,1);let u=kge(t,e,r,s.subarray(0,-16),n);return s.set(u,a),s},decrypt:(o,s)=>{let a=o.length,d=a-16;if(a<16)throw new Error("encrypted data must be at least 16 bytes");s?ao(s,d):s=new Uint8Array(d);let u=o.subarray(0,-16),c=o.subarray(-16),l=kge(t,e,r,u,n);if(!vde(c,l))throw new Error("invalid tag");return t(e,r,u,s,1),s}}),dBt=Aj({blockSize:64,nonceLength:12,tagLength:16},Dge(XQe)),l3=Aj({blockSize:64,nonceLength:24,tagLength:16},Dge(QQe));f();f();f();f();var ret=gt(_I(),1);f();f();function Bge(t){return t.byteOffset!==0||t.byteLength!==t.buffer.byteLength}function Mge(t){return typeof t!="object"||t===null?!1:typeof t[Symbol.asyncIterator]=="function"}function f3(t){let r=Object.prototype.toString.call(t).match(/\s([a-zA-Z0-9]+)/),[n,i]=r;return i}var h3=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Oge=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,d){s=t[o](s),i(a,d,s.done,s.value)})}}function i(o,s,a,d){Promise.resolve(d).then(function(u){o({value:u,done:a})},s)}},Lk=new TextEncoder,nb=new TextDecoder,ji=class t{constructor(e,r){this.data=e,this.format=r}static arrayBuffer(e){return new t(e,"ArrayBuffer")}static asyncIterable(e){if(!Mge(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 Ja.baseDecode(this.data).buffer;case"Base64Url":return ya.baseDecode(this.data).buffer;case"BufferSource":{if(f3(this.data)==="ArrayBuffer")return this.data;if(ArrayBuffer.isView(this.data))return Bge(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 h3(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 AB.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 Ja.baseEncode(e)}case"Multibase":return this.data.substring(1);case"Uint8Array":return Ja.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 ya.baseEncode(e)}case"BufferSource":{let e=this.toUint8Array();return ya.baseEncode(e)}case"Object":{let e=JSON.stringify(this.data),r=Lk.encode(e);return ya.baseEncode(r)}case"String":{let e=Lk.encode(this.data);return ya.baseEncode(e)}case"Uint8Array":return ya.baseEncode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Base64Url is not supported.`)}}toBlobAsync(){var e,r,n,i;return h3(this,void 0,void 0,function*(){switch(this.format){case"AsyncIterable":{let d=[];try{for(var o=!0,s=Oge(this.data),a;a=yield s.next(),e=a.done,!e;o=!0){i=a.value,o=!1;let c=i;d.push(c)}}catch(c){r={error:c}}finally{try{!o&&!e&&(n=s.return)&&(yield n.call(s))}finally{if(r)throw r.error}}return new Blob(d)}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{var o,s;n.push(...(s=(o=t[i])===null||o===void 0?void 0:o.filter(lF))!==null&&s!==void 0?s:[])}),n}function $ge({didDocument:t}){let r=fF({didDocument:t}).map(n=>n.type);return[...new Set(r)]}function jge({didDocument:t,methodId:e}){let r=[];return Object.keys(Av).forEach(n=>{if(Array.isArray(t[n])){let i=t[n],o=ed(e);i.some(a=>{let d=ed(a)===o,u=lF(a)&&ed(a.id)===o;return d||u})&&r.push(n)}}),r}function lF(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 hF({keyBytes:t,multicodecCode:e,multicodecName:r}){let n=da.addPrefix({code:e,data:t,name:r}),i=ji.uint8Array(n).toBase58Btc();return ji.base58Btc(i).toMultibase()}function pF({multibaseKeyId:t}){try{let e=ji.multibase(t).toBase58Btc(),r=ji.base58Btc(e).toUint8Array(),{code:n,data:i,name:o}=da.removePrefix({prefixedData:r});return{keyBytes:i,multicodecCode:n,multicodecName:o}}catch{throw new at(tt.InvalidDid,`Invalid multibase identifier: ${t}`)}}var m3=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},hc=class t{constructor({uri:e,document:r,metadata:n,keyManager:i}){this.uri=e,this.document=r,this.metadata=n,this.keyManager=i}export(){return m3(this,void 0,void 0,function*(){if(!(Array.isArray(this.document.verificationMethod)&&this.document.verificationMethod.length>0))throw new Error(`DID document for '${this.uri}' is missing verification methods`);let e={uri:this.uri,document:this.document,metadata:this.metadata};if("exportKey"in this.keyManager&&typeof this.keyManager.exportKey=="function"){let r=[];for(let n of this.document.verificationMethod){if(!n.publicKeyJwk)throw new Error(`Verification method '${n.id}' does not contain a public key in JWK format`);let i=yield this.keyManager.getKeyUri({key:n.publicKeyJwk}),o=yield this.keyManager.exportKey({keyUri:i});r.push(Object.assign({},o))}e.privateKeys=r}return e})}getSigner(e){return m3(this,void 0,void 0,function*(){var r;let n=(r=this.document.verificationMethod)===null||r===void 0?void 0:r.find(d=>{var u,c;return ed(d.id)===((u=ed(e?.methodId))!==null&&u!==void 0?u:ed((c=this.document.assertionMethod)===null||c===void 0?void 0:c[0]))});if(!(n&&n.publicKeyJwk))throw new at(tt.InternalError,"A verification method intended for signing could not be determined from the DID Document");let i=yield this.keyManager.getKeyUri({key:n.publicKeyJwk}),o=yield this.keyManager.getPublicKey({keyUri:i}),s=this.keyManager;return{algorithm:Uk.getJoseSignatureAlgorithmFromPublicKey(o),keyId:n.id,sign(d){return m3(this,arguments,void 0,function*({data:u}){return yield s.sign({data:u,keyUri:i})})},verify(d){return m3(this,arguments,void 0,function*({data:u,signature:c}){return yield s.verify({data:u,key:o,signature:c})})}}})}static import(e){return m3(this,arguments,void 0,function*({portableDid:r,keyManager:n=new ca}){var i;let o=fF({didDocument:r.document});if(o.length===0)throw new at(tt.InvalidDidDocument,"At least one verification method is required but 0 were given");for(let a of(i=r.privateKeys)!==null&&i!==void 0?i:[])yield n.importKey({key:a});for(let a of o){if(!a.publicKeyJwk)throw new Error(`Verification method '${a.id}' does not contain a public key in JWK format`);let d=yield n.getKeyUri({key:a.publicKeyJwk});yield n.getPublicKey({keyUri:d})}return new t({uri:r.uri,document:r.document,metadata:r.metadata,keyManager:n})})}};f();f();f();f();f();var mF="0123456789abcdef",Uge=[],Nge=[];for(let t=0;t<256;t++)Uge[t]=mF[t>>4&15]+mF[t&15],t<16&&(t<10?Nge[48+t]=t:Nge[87+t]=t);var yF=t=>{let e=t.length,r="",n=0;for(;n{let r=t.length||0;if(!e){let s=r;for(;s--;)e+=t[s].length}let n=new Uint8Array(e),i=e,o=r;for(;o--;)i-=t[o].length,n.set(t[o],i);return n};f();var Lge="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",aet=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(y3=0;y3e?new TextDecoder(e).decode(t):cet.decode(t),det=new TextEncoder,eu=t=>det.encode(t);var Kge=typeof window<"u"?window:self,Fge=Kge.crypto||Kge.msCrypto||{},G7t=Fge.subtle||Fge.webkitSubtle;f();function W2(t){let e=t<0?1:0;return t=Math.abs(Number(t||1)),Math.floor(Math.log10(t))+1+e}function Kk(t){return ArrayBuffer.isView(t)?"arraybufferview":Array.isArray(t)?"array":t instanceof Number?"number":t instanceof Boolean?"boolean":t instanceof Set?"set":t instanceof Map?"map":t instanceof String?"string":t instanceof ArrayBuffer?"arraybuffer":typeof t}function Qr(t,e,r){let n=[],i=null;return Qr._encode(n,t),i=qge(n),Qr.bytes=i.length,ArrayBuffer.isView(e)?(e.set(i,r),e):i}Qr.bytes=-1;Qr._floatConversionDetected=!1;Qr._encode=function(t,e){if(e!=null)switch(Kk(e)){case"object":Qr.dict(t,e);break;case"map":Qr.dictMap(t,e);break;case"array":Qr.list(t,e);break;case"set":Qr.listSet(t,e);break;case"string":Qr.string(t,e);break;case"number":Qr.number(t,e);break;case"boolean":Qr.number(t,e);break;case"arraybufferview":Qr.buffer(t,new Uint8Array(e.buffer,e.byteOffset,e.byteLength));break;case"arraybuffer":Qr.buffer(t,new Uint8Array(e));break}};var Fk=new Uint8Array([101]),zge=new Uint8Array([100]),Wge=new Uint8Array([108]);Qr.buffer=function(t,e){t.push(eu(e.length+":"),e)};Qr.string=function(t,e){t.push(eu(eu(e).byteLength+":"+e))};Qr.number=function(t,e){if(Number.isInteger(e))return t.push(eu("i"+BigInt(e)+"e"));let r=2147483648,n=e/r<<0,i=e%r<<0,o=n*r+i;t.push(eu("i"+o+"e")),o!==e&&!Qr._floatConversionDetected&&(Qr._floatConversionDetected=!0,console.warn('WARNING: Possible data corruption detected with value "'+e+'":','Bencoding only defines support for integers, value was converted to "'+o+'"'),console.trace())};Qr.dict=function(t,e){t.push(zge);let r=0,n,i=Object.keys(e).sort(),o=i.length;for(;r=48){n=n*10+(s-48);continue}if(!(o===e&&s===43)){if(o===e&&s===45){i=-1;continue}if(s===46)break;throw new Error("not a number: buffer["+o+"] = "+s)}}return n*i}function Bt(t,e,r,n){return t==null||t.length===0?null:(typeof e!="number"&&n==null&&(n=e,e=void 0),typeof r!="number"&&n==null&&(n=r,r=void 0),Bt.position=0,Bt.encoding=n||null,Bt.data=ArrayBuffer.isView(t)?new Uint8Array(t.slice(e,r)):eu(t),Bt.bytes=Bt.data.length,Bt.next())}Bt.bytes=0;Bt.position=0;Bt.data=null;Bt.encoding=null;Bt.next=function(){switch(Bt.data[Bt.position]){case het:return Bt.dictionary();case pet:return Bt.list();case uet:return Bt.integer();default:return Bt.buffer()}};Bt.find=function(t){let e=Bt.position,r=Bt.data.length,n=Bt.data;for(;e_et.test(t),encode(t,e,r){r=~~r,e=e||new Uint8Array(r+4);let n=t.length,i=0;for(let o=0;ot.length>0&&xet.test(t),encode(t,e,r){r=~~r;let n=r+16,i=-1,o=0,s=0,a=!0,d=!1;e=e||new Uint8Array(r+16);for(let u=0;u>8),r=97?c-=87:c>=65?c-=55:(c-=48,s=s*10+c),o=(o<<4)+c)}if(a===!1)d===!0?(r>8),r=i+2;u--)e[u]=e[u-2];e[i]=0,e[i+1]=0,i=r}if(i!==r&&i!==-1)for(r>n-2&&(r=n-2);n>i;)e[--n]=ri?e[--r]:0;else for(;r=56320||(t.charCodeAt(o)&64512)!==56320?e+=3:(n=o,e+=4)}}return e}function G2(t,e,r){let n=t.length;r==null&&(r=0),e===void 0&&(e=new Uint8Array(EF(t)+r));let i=r;for(let o=0;o>6,e[i++]=128|s&63;else if((s&63488)!==55296)e[i++]=224|(s&61440)>>12,e[i++]=128|(s&4032)>>6,e[i++]=128|s&63;else{let a=o+1;if(a===n||s>=56320)e[i++]=239,e[i++]=191,e[i++]=189;else{let d=t.charCodeAt(a);(d&64512)!==56320?(e[i++]=239,e[i++]=191,e[i++]=189):(o=a,s=65536|(s&1023)<<10|d&1023,e[i++]=240|(s&1835008)>>18,e[i++]=128|(s&258048)>>12,e[i++]=128|(s&4032)>>6,e[i++]=128|s&63)}}}return G2.bytes=i-r,e}G2.bytes=0;function J2(t,e,r){let n="";e==null&&(e=0),r==null&&(r=t.length);for(let i=e;i191&&o<224)s=(o&31)<<6|t[i++]&63;else if(o>239&&o<365){s=((o&7)<<18|(t[i++]&63)<<12|(t[i++]&63)<<6|t[i++]&63)-65536;let a=55296|s>>10&1023;n+=String.fromCharCode(a),s=56320|s&1023}else s=(o&15)<<12|(t[i++]&63)<<6|t[i++]&63;n+=String.fromCharCode(s)}return J2.bytes=r-e,n}J2.bytes=0;var Fy=t=>t instanceof Uint8Array;function bp(t){return typeof t=="string"?EF(t):t.byteLength}function Wk(t){return t instanceof Uint8Array?t:Array.isArray(t)?new Uint8Array(t):G2(t)}function Hk(t,e,r){if(typeof e!="string")throw new Error("unknown input type");return G2(e,t,r),G2.bytes}var v3={},rve=new Array(255);for(let t=0;t<=15;t+=1){let e=t.toString(16),r=e.toUpperCase();for(let n=0;n<=15;n+=1){let i=n.toString(16),o=i.toUpperCase(),s=t<<4|n,a=`${e}${i}`;rve[s]=a,v3[a]=s,v3[`${r}${i}`]=s,v3[`${e}${o}`]=s,v3[`${r}${o}`]=s}}function nve(t,e,r){let n="";for(let i=e;i>>1}function ive(t,e,r,n){let i=0;for(;rt[e]*Det+t[e+1]*Bet+t[e+2]*Met+t[e+3],or=(t,e)=>t[e]<<8|t[e+1],Mf=(t,e,r)=>(e=+e,t[r+3]=e,e=e>>>8,t[r+2]=e,e=e>>>8,t[r+1]=e,e=e>>>8,t[r]=e,r+4),bt=(t,e,r)=>(t[r]=e>>8,t[r+1]=e&255,r+2);function pc(t,e,r,n,i){return r<0&&(n-=r,r=0),n<0&&(n=0),i<0?new Uint8Array(0):r>=e.length||n>=i?0:Oet(t,e,r,n,i)}function Oet(t,e,r,n,i){i-n>e.length-r&&(i=n+e.length-r);let o=i-n,s=t.length-n;return o>s&&(o=s),(n!==0||it)}}var ot=Dn({encode(t,e,r){e||(e=new Uint8Array(ot.encodingLength(t))),r||(r=0);let n=r,i=t.replace(/^\.|\.$/gm,"");if(i.length){let o=i.split(".");for(let s=0;s=t.length)throw new Error("Cannot decode name (buffer overflow)");let a=t[e++];if(o+=s?0:1,a===0)break;if(a&192)if((a&192)===192){if(e+1>t.length)throw new Error("Cannot decode name (buffer overflow)");let d=or(t,e-1)-49152;if(d>=n)throw new Error("Cannot decode name (bad pointer)");e=d,n=d,o+=s?0:1,s=!0}else throw new Error("Cannot decode name (bad label)");else{if(e+a>t.length)throw new Error("Cannot decode name (buffer overflow)");if(i+=a+1,i>254)throw new Error("Cannot decode name (name too long)");r.push(J2(t,e,e+a)),e+=a,o+=s?0:a}}return ot.decode.bytes=o,r.length===0?".":r.join(".")},encodingLength(t){return t==="."||t===".."?1:bp(t.replace(/^\.|\.$/gm,""))+2}}),vo=Dn({encode(t,e,r){e||(e=new Uint8Array(vo.encodingLength(t))),r||(r=0);let n=Hk(e,t,r+1);return e[r]=n,vo.encode.bytes=n+1,e},decode(t,e){e||(e=0);let r=t[e],n=J2(t,e+1,e+1+r);return vo.decode.bytes=r+1,n},encodingLength(t){return bp(t)+1}}),Z2=Dn({bytes:12,encode(t,e,r){e||(e=new Uint8Array(Z2.encodingLength(t))),r||(r=0);let n=(t.flags||0)&32767,i=t.type==="response"?ove:$et;return bt(e,t.id||0,r),bt(e,n|i,r+2),bt(e,t.questions.length,r+4),bt(e,t.answers.length,r+6),bt(e,t.authorities.length,r+8),bt(e,t.additionals.length,r+10),e},decode(t,e){if(e||(e=0),t.length<12)throw new Error("Header must be 12 bytes");let r=or(t,e+2);return{id:or(t,e),type:r&ove?"response":"query",flags:r&32767,flag_qr:(r>>15&1)===1,opcode:eve(r>>11&15),flag_aa:(r>>10&1)===1,flag_tc:(r>>9&1)===1,flag_rd:(r>>8&1)===1,flag_ra:(r>>7&1)===1,flag_z:(r>>6&1)===1,flag_ad:(r>>5&1)===1,flag_cd:(r>>4&1)===1,rcode:Qge(r&15),questions:new Array(or(t,e+4)),answers:new Array(or(t,e+6)),authorities:new Array(or(t,e+8)),additionals:new Array(or(t,e+10))}},encodingLength(){return 12}}),Gk=Dn({encode(t,e,r){e||(e=new Uint8Array(Gk.encodingLength(t))),r||(r=0);let n=t.length;return bt(e,n,r),pc(t,e,r+2,0,n),Gk.encode.bytes=n+2,e},decode(t,e){e||(e=0);let r=or(t,e),n=t.slice(e+2,e+2+r);return Gk.decode.bytes=r+2,n},encodingLength(t){return t.length+2}}),Jk=Dn({encode(t,e,r){return e||(e=new Uint8Array(Jk.encodingLength(t))),r||(r=0),ot.encode(t,e,r+2),bt(e,ot.encode.bytes,r),Jk.encode.bytes=ot.encode.bytes+2,e},decode(t,e){e||(e=0);let r=or(t,e),n=ot.decode(t,e+2);return Jk.decode.bytes=r+2,n},encodingLength(t){return ot.encodingLength(t)+2}}),Zk=Dn({encode(t,e,r){e||(e=new Uint8Array(Zk.encodingLength(t))),r||(r=0);let n=r;return r+=2,ot.encode(t.mname,e,r),r+=ot.encode.bytes,ot.encode(t.rname,e,r),r+=ot.encode.bytes,Mf(e,t.serial||0,r),r+=4,Mf(e,t.refresh||0,r),r+=4,Mf(e,t.retry||0,r),r+=4,Mf(e,t.expire||0,r),r+=4,Mf(e,t.minimum||0,r),r+=4,bt(e,r-n-2,n),Zk.encode.bytes=r-n,e},decode(t,e){e||(e=0);let r=e,n={};return e+=2,n.mname=ot.decode(t,e),e+=ot.decode.bytes,n.rname=ot.decode(t,e),e+=ot.decode.bytes,n.serial=Bf(t,e),e+=4,n.refresh=Bf(t,e),e+=4,n.retry=Bf(t,e),e+=4,n.expire=Bf(t,e),e+=4,n.minimum=Bf(t,e),e+=4,Zk.decode.bytes=e-r,n},encodingLength(t){return 22+ot.encodingLength(t.mname)+ot.encodingLength(t.rname)}}),Yk=Dn({encode(t,e,r){Array.isArray(t)||(t=[t]);for(let i=0;i0;){let o=t[e++];if(--n,nnew Uint8Array(t),wp=Dn({encode(t,e,r){e||(e=new Uint8Array(wp.encodingLength(t))),r||(r=0);let n=r,i=xF(t.code);if(bt(e,i,r),r+=2,t.data)bt(e,t.data.length,r),r+=2,pc(t.data,e,r),r+=t.data.length;else switch(i){case 8:{let o=t.sourcePrefixLength||0,s=t.family||Zge(t.ip,sve),a=Yge(t.ip,sve),d=Math.ceil(o/8);bt(e,d+4,r),r+=2,bt(e,s,r),r+=2,e[r++]=o,e[r++]=t.scopePrefixLength||0,pc(a,e,r,0,d),r+=d}break;case 11:t.timeout?(bt(e,2,r),r+=2,bt(e,t.timeout,r),r+=2):(bt(e,0,r),r+=2);break;case 12:{let o=t.length||0;bt(e,o,r),r+=2,e.fill(0,r,r+o),r+=o}break;case 14:{let o=t.tags.length*2;bt(e,o,r),r+=2;for(let s of t.tags)bt(e,s,r),r+=2}break;default:throw new Error(`Unknown roption code: ${t.code}`)}return wp.encode.bytes=r-n,e},decode(t,e){e||(e=0);let r={};r.code=or(t,e),r.type=tve(r.code),e+=2;let n=or(t,e);switch(e+=2,r.data=t.slice(e,e+n),r.code){case 8:r.family=or(t,e),e+=2,r.sourcePrefixLength=t[e++],r.scopePrefixLength=t[e++];{let i=new Uint8Array(r.family===1?4:16);pc(t,i,0,e,e+n-4),r.ip=Xge(i)}break;case 11:n>0&&(r.timeout=or(t,e),e+=2);break;case 14:r.tags=[];for(let i=0;i0;)n[o++]=wp.decode(t,e),e+=wp.decode.bytes,i-=wp.decode.bytes;return Wy.decode.bytes=e-r,n},encodingLength(t){return 2+X2(t||[],wp)}}),Of=Dn({encode(t,e,r){e||(e=new Uint8Array(Of.encodingLength(t))),r||(r=0);let n=r,i=t.key;if(!Fy(i))throw new Error("Key must be a Buffer");return r+=2,bt(e,t.flags,r),r+=2,e[r]=Of.PROTOCOL_DNSSEC,r+=1,e[r]=t.algorithm,r+=1,pc(i,e,r,0,i.length),r+=i.length,Of.encode.bytes=r-n,bt(e,Of.encode.bytes-2,n),e},decode(t,e){e||(e=0);let r=e,n={},i=or(t,e);if(e+=2,n.flags=or(t,e),e+=2,t[e]!==Of.PROTOCOL_DNSSEC)throw new Error("Protocol must be 3");return e+=1,n.algorithm=t[e],e+=1,n.key=t.slice(e,r+i+2),e+=n.key.length,Of.decode.bytes=e-r,n},encodingLength(t){return 6+bp(t.key)}});Of.PROTOCOL_DNSSEC=3;Of.ZONE_KEY=128;Of.SECURE_ENTRYPOINT=32768;var b3=Dn({encode(t,e,r){e||(e=new Uint8Array(b3.encodingLength(t))),r||(r=0);let n=r,i=t.signature;if(!Fy(i))throw new Error("Signature must be a Buffer");return r+=2,bt(e,V2(t.typeCovered),r),r+=2,e[r]=t.algorithm,r+=1,e[r]=t.labels,r+=1,Mf(e,t.originalTTL,r),r+=4,Mf(e,t.expiration,r),r+=4,Mf(e,t.inception,r),r+=4,bt(e,t.keyTag,r),r+=2,ot.encode(t.signersName,e,r),r+=ot.encode.bytes,pc(i,e,r,0,i.length),r+=i.length,b3.encode.bytes=r-n,bt(e,b3.encode.bytes-2,n),e},decode(t,e){e||(e=0);let r=e,n={},i=or(t,e);return e+=2,n.typeCovered=g3(or(t,e)),e+=2,n.algorithm=t[e],e+=1,n.labels=t[e],e+=1,n.originalTTL=Bf(t,e),e+=4,n.expiration=Bf(t,e),e+=4,n.inception=Bf(t,e),e+=4,n.keyTag=or(t,e),e+=2,n.signersName=ot.decode(t,e),e+=ot.decode.bytes,n.signature=t.slice(e,r+i+2),e+=n.signature.length,b3.decode.bytes=e-r,n},encodingLength(t){return 20+ot.encodingLength(t.signersName)+bp(t.signature)}}),w3=Dn({encode(t,e,r){e||(e=new Uint8Array(w3.encodingLength(t))),r||(r=0);let n=r;return r+=2,ot.encode(t.mbox||".",e,r),r+=ot.encode.bytes,ot.encode(t.txt||".",e,r),r+=ot.encode.bytes,w3.encode.bytes=r-n,bt(e,w3.encode.bytes-2,n),e},decode(t,e){e||(e=0);let r=e,n={};return e+=2,n.mbox=ot.decode(t,e)||".",e+=ot.decode.bytes,n.txt=ot.decode(t,e)||".",e+=ot.decode.bytes,w3.decode.bytes=e-r,n},encodingLength(t){return 2+ot.encodingLength(t.mbox||".")+ot.encodingLength(t.txt||".")}}),td=Dn({encode(t,e,r){e||(e=new Uint8Array(td.encodingLength(t))),r||(r=0);let n=r,i=[];for(let o=0;o>8]===void 0&&(i[s>>8]=[]),i[s>>8][s>>3&31]|=1<<7-(s&7)}for(let o=0;o>8]=Math.max(e[i>>8]||0,i&255)}let r=0;for(let n=0;n>15&1)===1,r.options=Wy.decode(t,e+8),e+=8+Wy.decode.bytes;else{let i=or(t,e+2);r.ttl=Bf(t,e+4),r.class=wF(i&jet),r.flush=!!(i&TF);let o=AF(r.type);r.data=o.decode(t,e+8),e+=8+o.decode.bytes}return tu.decode.bytes=e-n,r},encodingLength(t){let e=t.data!==null&&t.data!==void 0?t.data:t.options;return ot.encodingLength(t.name)+8+AF(t.type).encodingLength(e)}}),e_=Dn({encode(t,e,r){e||(e=new Uint8Array(e_.encodingLength(t))),r||(r=0);let n=r;return ot.encode(t.name,e,r),r+=ot.encode.bytes,bt(e,V2(t.type),r),r+=2,bt(e,_F(t.class===void 0?"IN":t.class),r),r+=2,e_.encode.bytes=r-n,t},decode(t,e){e||(e=0);let r=e,n={};return n.name=ot.decode(t,e),e+=ot.decode.bytes,n.type=g3(or(t,e)),e+=2,n.class=wF(or(t,e)),e+=2,!!(n.class&ave)&&(n.class&=Net),e_.decode.bytes=e-r,n},encodingLength(t){return ot.encodingLength(t.name)+4}});var sR=1024;var Ds={encode:function(t,e,r){let n=!e;n&&(e=new Uint8Array(Uet(t))),r||(r=0);let i=r;return t.questions||(t.questions=[]),t.answers||(t.answers=[]),t.authorities||(t.authorities=[]),t.additionals||(t.additionals=[]),Z2.encode(t,e,r),r+=Z2.encode.bytes,r=S3(t.questions,e_,e,r),r=S3(t.answers,tu,e,r),r=S3(t.authorities,tu,e,r),r=S3(t.additionals,tu,e,r),Ds.encode.bytes=r-i,n&&ib.bytes!==e.length?e.slice(0,ib.bytes):e},decode:function(t,e){e||(e=0);let r=e,n=Z2.decode(t,e);return e+=Z2.decode.bytes,e=Vk(n.questions,e_,t,e),e=Vk(n.answers,tu,t,e),e=Vk(n.authorities,tu,t,e),e=Vk(n.additionals,tu,t,e),Ds.decode.bytes=e-r,n},encodingLength:function(t){return Z2.encodingLength(t)+X2(t.questions||[],e_)+X2(t.answers||[],tu)+X2(t.authorities||[],tu)+X2(t.additionals||[],tu)}};Ds.encode.bytes=0;Ds.decode.bytes=0;function nR(t,e){if(t.questions)throw new Error("Only one .question object expected instead of a .questions array!");let r=Object.assign({type:e},t);return r.question&&(r.questions=[r.question],delete r.question),r}var iR={encode:function(t,e,r){return e=Ds.encode(nR(t,"query"),e,r),iR.encode.bytes=Ds.encode.bytes,e},decode:function(t,e){let r=Ds.decode(t,e);return iR.decode.bytes=Ds.decode.bytes,r.questions&&(r.question=r.questions[0],delete r.questions),r},encodingLength:function(t){return Ds.encodingLength(nR(t,"query"))}};iR.encode.bytes=0;iR.decode.bytes=0;var oR={encode:function(t,e,r){return e=Ds.encode(nR(t,"response"),e,r),oR.encode.bytes=Ds.encode.bytes,e},decode:function(t,e){let r=Ds.decode(t,e);return oR.decode.bytes=Ds.decode.bytes,r.questions&&(r.question=r.questions[0],delete r.questions),r},encodingLength:function(t){return Ds.encodingLength(nR(t,"response"))}};oR.encode.bytes=0;oR.decode.bytes=0;var ib=Ds.encode,t_=Ds.decode,Uet=Ds.encodingLength;function dve(t){let e=ib(t),r=new Uint8Array(2+e.byteLength);return bt(r,e.byteLength),pc(e,r,2,0,e.length),dve.bytes=r.byteLength,r}dve.bytes=0;function uve(t){let e=or(t,0);if(t.byteLength!(j.algorithm in mve)))throw new Error("One or more verification method algorithms are not supported");let g=(i=r.verificationMethods)===null||i===void 0?void 0:i.filter(j=>"id"in j).map(j=>j.id);if(g&&g.length!==new Set(g).size)throw new Error("One or more verification method IDs are not unique");if(!((o=r.services)===null||o===void 0)&&o.some(j=>!j.id||!j.type||!j.serviceEndpoint))throw new Error("One or more services are missing required properties");let v=yield e.generateKey({algorithm:"Ed25519"}),x=yield e.getPublicKey({keyUri:v}),S=yield zo.identityKeyToIdentifier({identityKey:x}),P=Object.assign(Object.assign({id:S},r.alsoKnownAs&&{alsoKnownAs:r.alsoKnownAs}),r.controllers&&{controller:r.controllers}),A=[...(s=r.verificationMethods)!==null&&s!==void 0?s:[]];A?.some(j=>{var L;return((L=j.id)===null||L===void 0?void 0:L.split("#").pop())==="0"})||A.unshift({algorithm:"Ed25519",id:"0",purposes:["authentication","assertionMethod","capabilityDelegation","capabilityInvocation"]});for(let j of A){let L=j.id&&j.id.split("#").pop()==="0"?v:yield e.generateKey({algorithm:j.algorithm}),F=yield e.getPublicKey({keyUri:L}),K=(d=(a=j.id)!==null&&a!==void 0?a:F.kid)!==null&&d!==void 0?d:yield gr({jwk:F});K=`${S}#${ed(K)}`,(u=P.verificationMethod)!==null&&u!==void 0||(P.verificationMethod=[]),P.verificationMethod.push({id:K,type:"JsonWebKey",controller:(c=j.controller)!==null&&c!==void 0?c:S,publicKeyJwk:F});for(let W of(l=j.purposes)!==null&&l!==void 0?l:[])P[W]||(P[W]=[]),P[W].push(K)}(p=r.services)===null||p===void 0||p.forEach(j=>{var L;(L=P.service)!==null&&L!==void 0||(P.service=[]),j.id=`${S}#${j.id.split("#").pop()}`,P.service.push(j)});let $=new hc({uri:S,document:P,metadata:Object.assign({published:!1},r.types&&{types:r.types}),keyManager:e});if(!((m=r.publish)!==null&&m!==void 0)||m){let j=yield t.publish({did:$,gatewayUri:r.gatewayUri});$.metadata=j.didDocumentMetadata}return $})}static import(e){return Wo(this,arguments,void 0,function*({portableDid:r,keyManager:n=new ca}){var i;let o=_r.parse(r.uri);if(o?.method!==t.methodName)throw new at(tt.MethodNotSupported,"Method not supported");let s=yield hc.import({portableDid:r,keyManager:n});if(!(!((i=s.document.verificationMethod)===null||i===void 0)&&i.some(a=>{var d;return((d=a.id)===null||d===void 0?void 0:d.split("#").pop())==="0"})))throw new at(tt.InvalidDidDocument,"DID document must contain an Identity Key");return s})}static getSigningMethod(e){return Wo(this,arguments,void 0,function*({didDocument:r,methodId:n="#0"}){var i;let o=_r.parse(r.id);if(o&&o.method!==this.methodName)throw new at(tt.MethodNotSupported,`Method not supported: ${o.method}`);let s=(i=r.verificationMethod)===null||i===void 0?void 0:i.find(a=>{var d,u;return ed(a.id)===((d=ed(n))!==null&&d!==void 0?d:ed((u=r.assertionMethod)===null||u===void 0?void 0:u[0]))});if(!(s&&s.publicKeyJwk))throw new at(tt.InternalError,"A verification method intended for signing could not be determined from the DID Document");return s})}static publish(e){return Wo(this,arguments,void 0,function*({did:r,gatewayUri:n=hve}){return yield cR.put({did:r,gatewayUri:n})})}static resolve(e){return Wo(this,arguments,void 0,function*(r,n={}){var i;let o=(i=n?.gatewayUri)!==null&&i!==void 0?i:hve;try{yield zo.identifierToIdentityKey({didUri:r});let{didDocument:s,didDocumentMetadata:a}=yield cR.get({didUri:r,gatewayUri:o});return Object.assign(Object.assign({},ai),{didDocument:s,didDocumentMetadata:a})}catch(s){if(!(s instanceof at))throw new Error(s);return Object.assign(Object.assign({},ai),{didResolutionMetadata:Object.assign({error:s.code},s.message&&{errorMessage:s.message})})}})}};ob.methodName="dht";var cR=class t{static get(e){return Wo(this,arguments,void 0,function*({didUri:r,gatewayUri:n}){let i=zo.identifierToIdentityKeyBytes({didUri:r}),o=yield t.pkarrGet({gatewayUri:n,publicKeyBytes:i}),s=yield zo.parseBep44GetMessage({bep44Message:o}),a=yield t.fromDnsPacket({didUri:r,dnsPacket:s});return a.didDocumentMetadata.versionId=o.seq.toString(),a})}static put(e){return Wo(this,arguments,void 0,function*({did:r,gatewayUri:n}){let i=yield t.toDnsPacket({didDocument:r.document,didMetadata:r.metadata,authoritativeGatewayUris:[n]}),o=yield zo.createBep44PutMessage({dnsPacket:i,publicKeyBytes:zo.identifierToIdentityKeyBytes({didUri:r.uri}),signer:yield r.getSigner({methodId:"0"})}),s=yield t.pkarrPut({gatewayUri:n,bep44Message:o});return{didDocument:r.document,didDocumentMetadata:Object.assign(Object.assign({},r.metadata),{published:s,versionId:o.seq.toString()}),didRegistrationMetadata:{}}})}static pkarrGet(e){return Wo(this,arguments,void 0,function*({gatewayUri:r,publicKeyBytes:n}){let i=ji.uint8Array(n).toBase32Z(),o=new URL(i,r).href,s;try{if(s=yield fetch(o,{method:"GET"}),!s.ok)throw new at(tt.NotFound,`Pkarr record not found for: ${i}`)}catch(u){throw u instanceof at?u:new at(tt.InternalError,`Failed to fetch Pkarr record: ${u.message}`)}let a=yield s.arrayBuffer();if(!a)throw new at(tt.NotFound,`Pkarr record not found for: ${i}`);if(a.byteLength<72)throw new at(tt.InvalidDidDocumentLength,`Pkarr response must be at least 72 bytes but got: ${a.byteLength}`);if(a.byteLength>1072)throw new at(tt.InvalidDidDocumentLength,`Pkarr response exceeds 1000 byte limit: ${a.byteLength}`);return{k:n,seq:Number(new DataView(a).getBigUint64(64)),sig:new Uint8Array(a,0,64),v:new Uint8Array(a,72)}})}static pkarrPut(e){return Wo(this,arguments,void 0,function*({gatewayUri:r,bep44Message:n}){let i=ji.uint8Array(n.k).toBase32Z(),o=new URL(i,r).href,s=new Uint8Array(n.v.length+72);s.set(n.sig,0),new DataView(s.buffer).setBigUint64(n.sig.length,BigInt(n.seq)),s.set(n.v,n.sig.length+8);let a;try{a=yield fetch(o,{method:"PUT",headers:{"Content-Type":"application/octet-stream"},body:s})}catch(d){throw new at(tt.InternalError,`Failed to put Pkarr record for identifier ${i}: ${d.message}`)}return a.ok})}static fromDnsPacket(e){return Wo(this,arguments,void 0,function*({didUri:r,dnsPacket:n}){var i,o,s;let a={id:r},d={published:!0},u=new Map;for(let c of(i=n?.answers)!==null&&i!==void 0?i:[]){if(c.type!=="TXT")continue;let l=c.name.split(".")[0].substring(1);switch(!0){case l.startsWith("aka"):{let p=zo.parseTxtDataToString(c.data);a.alsoKnownAs=p.split(Ua);break}case l.startsWith("cnt"):{let p=zo.parseTxtDataToString(c.data);a.controller=p.includes(Ua)?p.split(Ua):p;break}case l.startsWith("k"):{let{id:p,t:m,k:g,c:v,a:x}=zo.parseTxtDataToObject(c.data),S=ji.base64Url(g).toUint8Array(),P=qa[Number(m)],A=yield zo.keyConverter(P).bytesToPublicKey({publicKeyBytes:S});A.alg=x||pve[Number(m)];let $=l==="k0"?"0":p!==void 0?p:yield gr({jwk:A});(o=a.verificationMethod)!==null&&o!==void 0||(a.verificationMethod=[]);let j=`${r}#${$}`;a.verificationMethod.push({id:j,type:"JsonWebKey",controller:v??r,publicKeyJwk:A}),u.set(l,j);break}case l.startsWith("s"):{let p=zo.parseTxtDataToObject(c.data),{id:m,t:g,se:v}=p,x=fve(p,["id","t","se"]),S=v.includes(Ua)?v.split(Ua):[v],P=Object.fromEntries(Object.entries(x).map(([A,$])=>[A,$.includes(Ua)?$.split(Ua):$]));(s=a.service)!==null&&s!==void 0||(a.service=[]),a.service.push(Object.assign(Object.assign({},P),{id:`${r}#${m}`,type:g,serviceEndpoint:S}));break}case l.startsWith("typ"):{let{id:p}=zo.parseTxtDataToObject(c.data);d.types=p.split(Ua).map(m=>Number(m));break}case l.startsWith("did"):{let p=P=>P.split(Ua).map(A=>u.get(A)).filter(A=>typeof A=="string"),{auth:m,asm:g,del:v,inv:x,agm:S}=zo.parseTxtDataToObject(c.data);m&&(a.authentication=p(m)),g&&(a.assertionMethod=p(g)),v&&(a.capabilityDelegation=p(v)),x&&(a.capabilityInvocation=p(x)),S&&(a.keyAgreement=p(S));break}}}return{didDocument:a,didDocumentMetadata:d,didResolutionMetadata:{}}})}static toDnsPacket(e){return Wo(this,arguments,void 0,function*({didDocument:r,didMetadata:n,authoritativeGatewayUris:i,previousDidProof:o}){var s,a,d,u,c;let l=[],p=[],m=new Map,g=[],v=[];if(o!==void 0){let{signature:P,previousDid:A}=o;yield zo.validatePreviousDidProof({newDid:r.id,previousDidProof:o}),l.push({type:"TXT",name:"_prv._did.",ttl:Hy,data:`id=${A};s=${P}`})}if(r.alsoKnownAs&&l.push({type:"TXT",name:"_aka._did.",ttl:Hy,data:r.alsoKnownAs.join(Ua)}),r.controller){let P=Array.isArray(r.controller)?r.controller.join(Ua):r.controller;l.push({type:"TXT",name:"_cnt._did.",ttl:Hy,data:P})}for(let[P,A]of(a=(s=r.verificationMethod)===null||s===void 0?void 0:s.entries())!==null&&a!==void 0?a:[]){let $=`k${P}`;v.push($);let j=A.id.split("#").pop();m.set(j,$);let L=A.publicKeyJwk;if(!(L?.crv&&L.crv in mve))throw new at(tt.InvalidPublicKeyType,`Verification method '${A.id}' contains an unsupported key type: ${(d=L?.crv)!==null&&d!==void 0?d:"undefined"}`);let F=qa[L.crv],K=yield zo.keyConverter(L.crv).publicKeyToBytes({publicKey:L}),W=ji.uint8Array(K).toBase64Url(),q=[`t=${F}`,`k=${W}`];j!=="0"&&(yield gr({jwk:L}))!==j&&q.unshift(`id=${j}`),L.alg!==pve[F]&&q.push(`a=${L.alg}`),A.controller!==r.id&&q.push(`c=${A.controller}`),l.push({type:"TXT",name:`_${$}._did.`,ttl:Hy,data:q.join(aR)})}(u=r.service)===null||u===void 0||u.forEach((P,A)=>{let $=`s${A}`;g.push($);let{id:j,type:L,serviceEndpoint:F}=P,K=fve(P,["id","type","serviceEndpoint"]);j=ed(j),F=Array.isArray(F)?F.join(","):F;let q=Object.entries(Object.assign({id:j,t:L,se:F},K)).map(([T,B])=>`${T}=${B}`).join(aR),I=zo.chunkDataIfNeeded(q);l.push({type:"TXT",name:`_${$}._did.`,ttl:Hy,data:I})});let x=[`v=${qet}`];if(v.length&&x.push(`vm=${v.join(Ua)}`),Object.keys(Av).forEach(P=>{var A;let $=(A=r[P])===null||A===void 0?void 0:A.map(j=>m.get(j.split("#").pop()));if($){let j=kF[P];x.push(`${j}=${$.join(Ua)}`)}}),g.length&&x.push(`svc=${g.join(Ua)}`),!((c=n.types)===null||c===void 0)&&c.length){let A=n.types.map($=>typeof $=="string"?IF[$]:$);l.push({type:"TXT",name:"_typ._did.",ttl:Hy,data:`id=${A.join(Ua)}`})}l.push({type:"TXT",name:"_did."+t.getUniqueDidSuffix(r.id)+".",ttl:Hy,data:x.join(aR)});for(let P of i||[])p.push({type:"NS",name:"_did."+t.getUniqueDidSuffix(r.id)+".",ttl:Hy,data:P+"."});return{id:0,type:"response",flags:sR,answers:[...l,...p]}})}static getUniqueDidSuffix(e){return e.split(":")[2]}},zo=class t{static createBep44PutMessage(e){return Wo(this,arguments,void 0,function*({dnsPacket:r,publicKeyBytes:n,signer:i}){let o=Math.ceil(Date.now()/1e3),s=ib(r),a=H2.encode({seq:o,v:s}).subarray(1,-1);if(a.length>1e3)throw new at(tt.InvalidDidDocumentLength,`DNS packet exceeds the 1000 byte maximum size: ${a.length} bytes`);let d=yield i.sign({data:a});return{k:n,seq:o,sig:d,v:s}})}static identifierToIdentityKey(e){return Wo(this,arguments,void 0,function*({didUri:r}){let n=t.identifierToIdentityKeyBytes({didUri:r});return yield go.bytesToPublicKey({publicKeyBytes:n})})}static identifierToIdentityKeyBytes({didUri:e}){let r=_r.parse(e);if(!r)throw new at(tt.InvalidDid,`Invalid DID URI: ${e}`);if(r.method!==ob.methodName)throw new at(tt.MethodNotSupported,`Method not supported: ${r.method}`);let n;try{n=ji.base32Z(r.id).toUint8Array()}catch{throw new at(tt.InvalidPublicKey,"Failed to decode method-specific identifier")}if(n.length!==32)throw new at(tt.InvalidPublicKeyLength,`Invalid public key length: ${n.length}`);return n}static identityKeyToIdentifier(e){return Wo(this,arguments,void 0,function*({identityKey:r}){let n=yield go.publicKeyToBytes({publicKey:r}),i=ji.uint8Array(n).toBase32Z();return`did:${ob.methodName}:${i}`})}static keyConverter(e){let n={Ed25519:go,"P-256":{publicKeyToBytes:i=>Wo(this,[i],void 0,function*({publicKey:o}){let s=yield ks.publicKeyToBytes({publicKey:o});return yield ks.compressPublicKey({publicKeyBytes:s})}),bytesToPublicKey:ks.bytesToPublicKey,privateKeyToBytes:ks.privateKeyToBytes,bytesToPrivateKey:ks.bytesToPrivateKey},secp256k1:{publicKeyToBytes:i=>Wo(this,[i],void 0,function*({publicKey:o}){let s=yield Fo.publicKeyToBytes({publicKey:o});return yield Fo.compressPublicKey({publicKeyBytes:s})}),bytesToPublicKey:Fo.bytesToPublicKey,privateKeyToBytes:Fo.privateKeyToBytes,bytesToPrivateKey:Fo.bytesToPrivateKey},X25519:z2}[e];if(!n)throw new at(tt.InvalidPublicKeyType,`Unsupported curve: ${e}`);return n}static parseBep44GetMessage(e){return Wo(this,arguments,void 0,function*({bep44Message:r}){let n=yield go.bytesToPublicKey({publicKeyBytes:r.k}),i=H2.encode({seq:r.seq,v:r.v}).subarray(1,-1);if(!(yield go.verify({key:n,signature:r.sig,data:i})))throw new at(tt.InvalidSignature,"Invalid signature for DHT BEP44 message");return t_(r.v)})}static parseTxtDataToObject(e){return this.parseTxtDataToString(e).split(aR).reduce((r,n)=>{let[i,o]=n.split("=");return r[i]=o,r},{})}static parseTxtDataToString(e){if(typeof e=="string")return e;if(e instanceof Uint8Array)return ji.uint8Array(e).toString();if(Array.isArray(e))return e.map(r=>this.parseTxtDataToString(r)).join("");throw new at(tt.InternalError,"Pkarr returned DNS TXT record with invalid data type")}static validatePreviousDidProof(e){return Wo(this,arguments,void 0,function*({newDid:r,previousDidProof:n}){let i=yield t.identifierToIdentityKey({didUri:n.previousDid}),o=t.identifierToIdentityKeyBytes({didUri:r}),s=ji.base64Url(n.signature).toUint8Array();if(!(yield go.verify({key:i,data:o,signature:s})))throw new at(tt.InvalidPreviousDidProof,"The previous DID proof is invalid.")})}static chunkDataIfNeeded(e){if(e.length<=255)return e;let r=[];for(let n=0;n50)throw new _n(Hn.IdTooLong,`Key ID length ${e.length} exceed max allowed length of 50.`);if(!mc.isBase64UrlString(e))throw new _n(Hn.IdNotUsingBase64UrlCharacterSet,`Key ID '${e}' is not a Base64URL string.`)}static validatePublicKeyPurposes(e){if(e===void 0)return;let r=new Set;for(let n of e){if(r.has(n))throw new _n(Hn.PublicKeyPurposeDuplicated,`Public key purpose '${n}' already specified.`);r.add(n)}}};f();var A3=class{};A3.hashAlgorithmInMultihashCode=18;A3.maxCanonicalizedDeltaSizeInBytes=1e3;var La=A3;f();var vve=gt(gve(),1);var dl=class t{static canonicalizeAsBytes(e){let r=t.removeAllUndefinedProperties(e),n=vve.default(r);return mc.stringToBytes(n)}static removeAllUndefinedProperties(e){for(let r in e)typeof e[r]=="object"?t.removeAllUndefinedProperties(e[r]):e[r]===void 0&&delete e[r];return e}};f();var T3=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Ho=class t{static hash(e,r){return T3(this,void 0,void 0,function*(){let n;switch(r){case 18:n=(yield Bx.digest(e)).bytes;break;default:throw new _n(Hn.MultihashUnsupportedHashAlgorithm,`Hash algorithm defined in multihash code ${r} is not supported.`)}return n})}static hashAsNonMultihashBytes(e,r){return T3(this,void 0,void 0,function*(){let n;switch(r){case 18:n=yield Bx.encode(e);break;default:throw new _n(Hn.MultihashUnsupportedHashAlgorithm,`Hash algorithm defined in multihash code ${r} is not supported.`)}return n})}static canonicalizeThenHashThenEncode(e,r){return T3(this,void 0,void 0,function*(){let n=dl.canonicalizeAsBytes(e);return yield t.hashThenEncode(n,r)})}static canonicalizeThenDoubleHashThenEncode(e,r){return T3(this,void 0,void 0,function*(){let n=dl.canonicalizeAsBytes(e),i=yield t.hashAsNonMultihashBytes(n,r);return yield t.hashThenEncode(i,r)})}static hashThenEncode(e,r){return T3(this,void 0,void 0,function*(){let n=yield t.hash(e,r);return mc.encode(n)})}static validateEncodedHashComputedUsingSupportedHashAlgorithm(e,r){let n,i=mc.decodeAsBytes(e,r);try{n=E8(i)}catch{throw new _n(Hn.MultihashStringNotAMultihash,`Given ${r} string '${e}' is not a multihash after decoding.`)}let o=La.hashAlgorithmInMultihashCode;if(o!==n.code)throw new _n(Hn.MultihashUnsupportedHashAlgorithm,`Given ${r} uses unsupported multihash algorithm with code ${n.code}, should use ${o} or change IonSdkConfig to desired hashing algorithm.`)}};f();var DF;(function(t){t.Create="create",t.Update="update",t.Deactivate="deactivate",t.Recover="recover"})(DF||(DF={}));var P3=DF;f();var BF;(function(t){t.Replace="replace",t.AddPublicKeys="add-public-keys",t.RemovePublicKeys="remove-public-keys",t.AddServices="add-services",t.RemoveServices="remove-services"})(BF||(BF={}));var sb=BF;var dR=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Cf=class t{static createCreateRequest(e){return dR(this,void 0,void 0,function*(){let r=e.recoveryKey,n=e.updateKey,i=e.document.publicKeys,o=e.document.services;bo.validateEs256kOperationKey(r,rd.Public),bo.validateEs256kOperationKey(n,rd.Public),t.validateDidDocumentKeys(i),t.validateServices(o);let s=La.hashAlgorithmInMultihashCode,a=[{action:sb.Replace,document:e.document}],d={updateCommitment:yield Ho.canonicalizeThenDoubleHashThenEncode(n,s),patches:a};t.validateDeltaSize(d);let c={deltaHash:yield Ho.canonicalizeThenHashThenEncode(d,s),recoveryCommitment:yield Ho.canonicalizeThenDoubleHashThenEncode(r,s)};return{type:P3.Create,suffixData:c,delta:d}})}static createDeactivateRequest(e){return dR(this,void 0,void 0,function*(){t.validateDidSuffix(e.didSuffix),bo.validateEs256kOperationKey(e.recoveryPublicKey,rd.Public);let r=La.hashAlgorithmInMultihashCode,n=yield Ho.canonicalizeThenHashThenEncode(e.recoveryPublicKey,r),i={didSuffix:e.didSuffix,recoveryKey:e.recoveryPublicKey},o=yield e.signer.sign({alg:"ES256K"},i);return{type:P3.Deactivate,didSuffix:e.didSuffix,revealValue:n,signedData:o}})}static createRecoverRequest(e){return dR(this,void 0,void 0,function*(){t.validateDidSuffix(e.didSuffix),bo.validateEs256kOperationKey(e.recoveryPublicKey,rd.Public),bo.validateEs256kOperationKey(e.nextRecoveryPublicKey,rd.Public),bo.validateEs256kOperationKey(e.nextUpdatePublicKey,rd.Public),t.validateDidDocumentKeys(e.document.publicKeys),t.validateServices(e.document.services);let r=La.hashAlgorithmInMultihashCode,n=yield Ho.canonicalizeThenHashThenEncode(e.recoveryPublicKey,r),i=[{action:sb.Replace,document:e.document}],o=yield Ho.canonicalizeThenDoubleHashThenEncode(e.nextUpdatePublicKey,r),s={patches:i,updateCommitment:o},a=yield Ho.canonicalizeThenHashThenEncode(s,r),u={recoveryCommitment:yield Ho.canonicalizeThenDoubleHashThenEncode(e.nextRecoveryPublicKey,r),recoveryKey:e.recoveryPublicKey,deltaHash:a},c=yield e.signer.sign({alg:"ES256K"},u);return{type:P3.Recover,didSuffix:e.didSuffix,revealValue:n,delta:s,signedData:c}})}static createUpdateRequest(e){return dR(this,void 0,void 0,function*(){if(t.validateDidSuffix(e.didSuffix),bo.validateEs256kOperationKey(e.updatePublicKey,rd.Public),bo.validateEs256kOperationKey(e.nextUpdatePublicKey,rd.Public),t.validateServices(e.servicesToAdd),t.validateDidDocumentKeys(e.publicKeysToAdd),e.idsOfServicesToRemove!==void 0)for(let g of e.idsOfServicesToRemove)bo.validateId(g);if(e.idsOfPublicKeysToRemove!==void 0)for(let g of e.idsOfPublicKeysToRemove)bo.validateId(g);let r=[],n=e.servicesToAdd;if(n!==void 0&&n.length>0){let g={action:sb.AddServices,services:n};r.push(g)}let i=e.idsOfServicesToRemove;if(i!==void 0&&i.length>0){let g={action:sb.RemoveServices,ids:i};r.push(g)}let o=e.publicKeysToAdd;if(o!==void 0&&o.length>0){let g={action:sb.AddPublicKeys,publicKeys:o};r.push(g)}let s=e.idsOfPublicKeysToRemove;if(s!==void 0&&s.length>0){let g={action:sb.RemovePublicKeys,ids:s};r.push(g)}let a=La.hashAlgorithmInMultihashCode,d=yield Ho.canonicalizeThenHashThenEncode(e.updatePublicKey,a),u=yield Ho.canonicalizeThenDoubleHashThenEncode(e.nextUpdatePublicKey,a),c={patches:r,updateCommitment:u},l=yield Ho.canonicalizeThenHashThenEncode(c,a),p={updateKey:e.updatePublicKey,deltaHash:l},m=yield e.signer.sign({alg:"ES256K"},p);return{type:P3.Update,didSuffix:e.didSuffix,revealValue:d,delta:c,signedData:m}})}static validateDidSuffix(e){Ho.validateEncodedHashComputedUsingSupportedHashAlgorithm(e,"didSuffix")}static validateDidDocumentKeys(e){if(e===void 0)return;let r=new Set;for(let n of e){if(Array.isArray(n.publicKeyJwk))throw new _n(Hn.DidDocumentPublicKeyMissingOrIncorrectType,"DID Document key 'publicKeyJwk' property is not a non-array object.");if(bo.validateId(n.id),r.has(n.id))throw new _n(Hn.DidDocumentPublicKeyIdDuplicated,`DID Document key with ID '${n.id}' already exists.`);r.add(n.id),bo.validatePublicKeyPurposes(n.purposes)}}static validateServices(e){if(e!==void 0&&e.length!==0){let r=new Set;for(let n of e){if(t.validateService(n),r.has(n.id))throw new _n(Hn.DidDocumentServiceIdDuplicated,"Service id has to be unique");r.add(n.id)}}}static validateService(e){bo.validateId(e.id);let r=30;if(e.type.length>r){let n=`Service endpoint type length ${e.type.length} exceeds max allowed length of ${r}.`;throw new _n(Hn.ServiceTypeTooLong,n)}if(Array.isArray(e.serviceEndpoint)){let n="Service endpoint value cannot be an array.";throw new _n(Hn.ServiceEndpointCannotBeAnArray,n)}if(typeof e.serviceEndpoint=="string"&&bve.parse(e.serviceEndpoint).error!==void 0)throw new _n(Hn.ServiceEndpointStringNotValidUri,`Service endpoint string '${e.serviceEndpoint}' is not a URI.`)}static validateDeltaSize(e){let r=dl.canonicalizeAsBytes(e);if(r.length>La.maxCanonicalizedDeltaSizeInBytes){let n=`Delta of ${r.length} bytes exceeded limit of ${La.maxCanonicalizedDeltaSizeInBytes} bytes.`;throw new _n(Hn.DeltaExceedsMaximumSize,n)}}};var wve=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Vy=class t{static createLongFormDid(e){return wve(this,void 0,void 0,function*(){let r=yield Cf.createCreateRequest(e),n=yield t.computeDidUniqueSuffix(r.suffixData),i;La.network===void 0||La.network==="mainnet"?i=`did:ion:${n}`:i=`did:ion:${La.network}:${n}`;let o={suffixData:r.suffixData,delta:r.delta},s=dl.canonicalizeAsBytes(o),a=mc.encode(s);return`${i}:${a}`})}static computeDidUniqueSuffix(e){return wve(this,void 0,void 0,function*(){let r=dl.canonicalizeAsBytes(e),n=yield Ho.hash(r,La.hashAlgorithmInMultihashCode);return mc.encode(n)})}};f();f();var _ve;(function(t){t.Mainnet="mainnet",t.Testnet="test"})(_ve||(_ve={}));f();var xve;(function(t){t.Authentication="authentication",t.AssertionMethod="assertionMethod",t.CapabilityInvocation="capabilityInvocation",t.CapabilityDelegation="capabilityDelegation",t.KeyAgreement="keyAgreement"})(xve||(xve={}));f();var Gy=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},$f;(function(t){t.Ed25519="Ed25519",t.secp256k1="secp256k1",t.secp256r1="secp256r1",t.X25519="X25519"})($f||($f={}));var Let={Ed25519:$f.Ed25519,ES256K:$f.secp256k1,ES256:$f.secp256r1,"P-256":$f.secp256r1,secp256k1:$f.secp256k1,secp256r1:$f.secp256r1},Eve="https://ion.tbd.engineering",MF=class t extends ru{static create(){return Gy(this,arguments,void 0,function*({keyManager:e=new ca,options:r={}}={}){var n,i,o,s,a,d,u;if(!((n=r.verificationMethods)===null||n===void 0)&&n.some(j=>!(j.algorithm in Let)))throw new Error("One or more verification method algorithms are not supported");let c=(i=r.verificationMethods)===null||i===void 0?void 0:i.filter(j=>"id"in j).map(j=>j.id);if(c&&c.length!==new Set(c).size)throw new Error("One or more verification method IDs are not unique");if(!((o=r.services)===null||o===void 0)&&o.some(j=>!j.id||!j.type||!j.serviceEndpoint))throw new Error("One or more services are missing required properties");let l={algorithm:"Ed25519",purposes:["authentication","assertionMethod","capabilityDelegation","capabilityInvocation"]},p=[];for(let j of(s=r.verificationMethods)!==null&&s!==void 0?s:[l]){let L=yield e.generateKey({algorithm:j.algorithm}),F=yield e.getPublicKey({keyUri:L});p.push({id:j.id,publicKeyJwk:F,purposes:(a=j.purposes)!==null&&a!==void 0?a:["authentication","assertionMethod","capabilityDelegation","capabilityInvocation"]})}let m=yield e.generateKey({algorithm:$f.secp256k1}),g=yield e.getPublicKey({keyUri:m}),v=yield e.generateKey({algorithm:$f.secp256k1}),x=yield e.getPublicKey({keyUri:v}),S=yield ab.computeLongFormDidUri({recoveryKey:g,updateKey:x,services:(d=r.services)!==null&&d!==void 0?d:[],verificationMethods:p}),{didDocument:P,didResolutionMetadata:A}=yield t.resolve(S,{gatewayUri:r.gatewayUri});if(P===null)throw new Error(`Unable to resolve DID during creation: ${A?.error}`);let $=new hc({uri:S,document:P,metadata:{published:!1,canonicalId:S.split(":",3).join(":"),recoveryKey:g,updateKey:x},keyManager:e});if(!((u=r.publish)!==null&&u!==void 0)||u){let j=yield t.publish({did:$,gatewayUri:r.gatewayUri});$.metadata=j.didDocumentMetadata}return $})}static getSigningMethod(e){return Gy(this,arguments,void 0,function*({didDocument:r,methodId:n}){var i;let o=_r.parse(r.id);if(o&&o.method!==this.methodName)throw new at(tt.MethodNotSupported,`Method not supported: ${o.method}`);let s=(i=r.verificationMethod)===null||i===void 0?void 0:i.find(a=>{var d;return a.id===(n??((d=r.assertionMethod)===null||d===void 0?void 0:d[0]))});if(!(s&&s.publicKeyJwk))throw new at(tt.InternalError,"A verification method intended for signing could not be determined from the DID Document");return s})}static import(e){return Gy(this,arguments,void 0,function*({portableDid:r,keyManager:n=new ca}){let i=_r.parse(r.uri);if(i?.method!==t.methodName)throw new at(tt.MethodNotSupported,"Method not supported");return yield hc.import({portableDid:r,keyManager:n})})}static publish(e){return Gy(this,arguments,void 0,function*({did:r,gatewayUri:n=Eve}){var i,o,s;let a=(o=(i=r.document.verificationMethod)===null||i===void 0?void 0:i.map(c=>({id:c.id,publicKeyJwk:c.publicKeyJwk,purposes:jge({didDocument:r.document,methodId:c.id})})))!==null&&o!==void 0?o:[],d=yield ab.createIonDocument({services:(s=r.document.service)!==null&&s!==void 0?s:[],verificationMethods:a}),u=yield ab.constructCreateRequest({ionDocument:d,recoveryKey:r.metadata.recoveryKey,updateKey:r.metadata.updateKey});try{let c=ab.appendPathToUrl({baseUrl:n,path:"/operations"}),l=yield fetch(c,{method:"POST",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)});return{didDocument:r.document,didDocumentMetadata:Object.assign(Object.assign({},r.metadata),{published:l.ok}),didRegistrationMetadata:{}}}catch{return{didDocument:null,didDocumentMetadata:{published:!1},didRegistrationMetadata:{error:tt.InternalError,errorMessage:`Failed to publish DID document for: ${r.uri}`}}}})}static resolve(e){return Gy(this,arguments,void 0,function*(r,n={}){var i,o;let s=_r.parse(r);if(!s)return Object.assign(Object.assign({},ai),{didResolutionMetadata:{error:"invalidDid"}});if(s.method!==t.methodName)return Object.assign(Object.assign({},ai),{didResolutionMetadata:{error:"methodNotSupported"}});let a=(i=n?.gatewayUri)!==null&&i!==void 0?i:Eve;try{let d=ab.appendPathToUrl({baseUrl:a,path:`/identifiers/${r}`}),u=yield fetch(d);if(!u.ok)throw new at(tt.NotFound,`Unable to find DID document for: ${r}`);let{didDocument:c,didDocumentMetadata:l}=yield u.json();return Object.assign(Object.assign(Object.assign({},ai),c&&{didDocument:c}),{didDocumentMetadata:Object.assign({published:(o=l?.method)===null||o===void 0?void 0:o.published},l)})}catch(d){if(!(d instanceof at))throw new Error(d);return Object.assign(Object.assign({},ai),{didResolutionMetadata:Object.assign({error:d.code},d.message&&{errorMessage:d.message})})}})}};MF.methodName="ion";var ab=class t{static appendPathToUrl({baseUrl:e,path:r}){let n=new URL(e);return n.pathname=n.pathname.endsWith("/")?n.pathname:n.pathname+"/",n.pathname+=r.startsWith("/")?r.substring(1):r,n.toString()}static computeLongFormDidUri(e){return Gy(this,arguments,void 0,function*({recoveryKey:r,updateKey:n,services:i,verificationMethods:o}){let s=yield t.createIonDocument({services:i,verificationMethods:o}),a=t.normalizeJwk(r),d=t.normalizeJwk(n);return yield Vy.createLongFormDid({document:s,recoveryKey:a,updateKey:d})})}static constructCreateRequest(e){return Gy(this,arguments,void 0,function*({ionDocument:r,recoveryKey:n,updateKey:i}){return yield Cf.createCreateRequest({document:r,recoveryKey:t.normalizeJwk(n),updateKey:t.normalizeJwk(i)})})}static createIonDocument(e){return Gy(this,arguments,void 0,function*({services:r,verificationMethods:n}){var i,o;let s=[];for(let u of n){let c=(o=(i=u.id)!==null&&i!==void 0?i:u.publicKeyJwk.kid)!==null&&o!==void 0?o:yield gr({jwk:u.publicKeyJwk});c=`${c.split("#").pop()}`;let l={id:c,publicKeyJwk:t.normalizeJwk(u.publicKeyJwk),purposes:u.purposes,type:"JsonWebKey2020"};s.push(l)}let a=r.map(u=>Object.assign(Object.assign({},u),{id:`${u.id.split("#").pop()}`}));return{publicKeys:s,services:a}})}static normalizeJwk(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}`);return n}};f();var uR=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},I3=class t extends ru{static create(){return uR(this,arguments,void 0,function*({keyManager:e=new ca,options:r={}}={}){var n,i,o,s;if(r.algorithm&&r.verificationMethods)throw new Error("The 'algorithm' and 'verificationMethods' options are mutually exclusive");if(r.verificationMethods&&r.verificationMethods.length!==1)throw new Error("The 'verificationMethods' option must contain exactly one entry");let a=(s=(n=r.algorithm)!==null&&n!==void 0?n:(o=(i=r.verificationMethods)===null||i===void 0?void 0:i[0])===null||o===void 0?void 0:o.algorithm)!==null&&s!==void 0?s:"Ed25519",d=yield e.generateKey({algorithm:a}),u=yield e.getPublicKey({keyUri:d}),c=ji.object(u).toBase64Url(),l=`did:${t.methodName}:${c}`,m=(yield t.resolve(l)).didDocument;return new hc({uri:l,document:m,metadata:{},keyManager:e})})}static getSigningMethod(e){return uR(this,arguments,void 0,function*({didDocument:r}){var n;let i=_r.parse(r.id);if(i&&i.method!==this.methodName)throw new at(tt.MethodNotSupported,`Method not supported: ${i.method}`);let[o]=(n=r.verificationMethod)!==null&&n!==void 0?n:[];if(!(o&&o.publicKeyJwk))throw new at(tt.InternalError,"A verification method intended for signing could not be determined from the DID Document");return o})}static import(e){return uR(this,arguments,void 0,function*({portableDid:r,keyManager:n=new ca}){let i=_r.parse(r.uri);if(i?.method!==t.methodName)throw new at(tt.MethodNotSupported,"Method not supported");let o=yield hc.import({portableDid:r,keyManager:n});if(o.document.verificationMethod.length!==1)throw new at(tt.InvalidDidDocument,"DID document must contain exactly one verification method");return o})}static resolve(e,r){return uR(this,void 0,void 0,function*(){let n=_r.parse(e),i;try{i=ji.base64Url(n.id).toObject()}catch{}if(!n||!i)return Object.assign(Object.assign({},ai),{didResolutionMetadata:{error:"invalidDid"}});if(n.method!==t.methodName)return Object.assign(Object.assign({},ai),{didResolutionMetadata:{error:"methodNotSupported"}});let o={"@context":["https://www.w3.org/ns/did/v1"],id:n.uri},s=`${o.id}#0`;switch(o.verificationMethod=[{id:s,type:"JsonWebKey",controller:o.id,publicKeyJwk:i}],o.authentication=[s],o.assertionMethod=[s],o.capabilityInvocation=[s],o.capabilityDelegation=[s],o.keyAgreement=[s],i.use){case"sig":{delete o.keyAgreement;break}case"enc":{delete o.authentication,delete o.assertionMethod,delete o.capabilityInvocation,delete o.capabilityDelegation;break}}return Object.assign(Object.assign({},ai),{didDocument:o})})}};I3.methodName="jwk";f();var ul=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},_p;(function(t){t.Ed25519="Ed25519",t.secp256k1="secp256k1",t.secp256r1="secp256r1",t.X25519="X25519"})(_p||(_p={}));var OF={Ed25519VerificationKey2020:"https://w3id.org/security/suites/ed25519-2020/v1",JsonWebKey2020:"https://w3id.org/security/suites/jws-2020/v1",X25519KeyAgreementKey2020:"https://w3id.org/security/suites/x25519-2020/v1"},Ket={Ed25519:_p.Ed25519,ES256K:_p.secp256k1,ES256:_p.secp256r1,"P-256":_p.secp256r1,secp256k1:_p.secp256k1,secp256r1:_p.secp256r1,X25519:_p.X25519},r_=class t extends ru{static create(){return ul(this,arguments,void 0,function*({keyManager:e=new ca,options:r={}}={}){var n,i,o,s;if(r.algorithm&&r.verificationMethods)throw new Error("The 'algorithm' and 'verificationMethods' options are mutually exclusive");if(r.verificationMethods&&r.verificationMethods.length!==1)throw new Error("The 'verificationMethods' option must contain exactly one entry");let a=(s=(n=r.algorithm)!==null&&n!==void 0?n:(o=(i=r.verificationMethods)===null||i===void 0?void 0:i[0])===null||o===void 0?void 0:o.algorithm)!==null&&s!==void 0?s:"Ed25519",d=yield e.generateKey({algorithm:a}),u=yield e.getPublicKey({keyUri:d}),c=yield yc.publicKeyToMultibaseId({publicKey:u}),l=`did:${t.methodName}:${c}`,m=(yield t.resolve(l,r)).didDocument;return new hc({uri:l,document:m,metadata:{},keyManager:e})})}static getSigningMethod(e){return ul(this,arguments,void 0,function*({didDocument:r}){var n;let i=_r.parse(r.id);if(i&&i.method!==this.methodName)throw new at(tt.MethodNotSupported,`Method not supported: ${i.method}`);let[o]=r.assertionMethod||[],s=(n=r.verificationMethod)===null||n===void 0?void 0:n.find(a=>a.id===o);if(!(s&&s.publicKeyJwk))throw new at(tt.InternalError,"A verification method intended for signing could not be determined from the DID Document");return s})}static import(e){return ul(this,arguments,void 0,function*({portableDid:r,keyManager:n=new ca}){let i=_r.parse(r.uri);if(i?.method!==t.methodName)throw new at(tt.MethodNotSupported,"Method not supported");let o=yield hc.import({portableDid:r,keyManager:n});if(o.document.verificationMethod.length!==1)throw new at(tt.InvalidDidDocument,"DID document must contain exactly one verification method");return o})}static resolve(e,r){return ul(this,void 0,void 0,function*(){try{let n=yield t.createDocument({didUri:e,options:r});return Object.assign(Object.assign({},ai),{didDocument:n})}catch(n){if(!(n instanceof at))throw new Error(n);return Object.assign(Object.assign({},ai),{didResolutionMetadata:Object.assign({error:n.code},n.message&&{errorMessage:n.message})})}})}static createDocument(e){return ul(this,arguments,void 0,function*({didUri:r,options:n={}}){let{defaultContext:i="https://www.w3.org/ns/did/v1",enableEncryptionKeyDerivation:o=!1,enableExperimentalPublicKeyTypes:s=!1,publicKeyFormat:a="JsonWebKey2020"}=n,d={id:""},u=_r.parse(r);if(!u)throw new at(tt.InvalidDid,`Invalid DID URI: ${r}`);let c=u.id;if(u.method!==t.methodName)throw new at(tt.MethodNotSupported,`Method not supported: ${u.method}`);if(!t.validateIdentifier(u))throw new at(tt.InvalidDid,`Invalid DID URI: ${r}`);let l=yield t.createSignatureMethod({didUri:r,multibaseValue:c,options:{enableExperimentalPublicKeyTypes:s,publicKeyFormat:a}});if(d.id=u.uri,d.verificationMethod=[l],d.authentication=[l.id],d.assertionMethod=[l.id],d.capabilityInvocation=[l.id],d.capabilityDelegation=[l.id],o===!0){let g=a==="Ed25519VerificationKey2020"?"X25519KeyAgreementKey2020":"JsonWebKey2020",v=yield this.createEncryptionMethod({didUri:r,multibaseValue:c,options:{enableExperimentalPublicKeyTypes:s,publicKeyFormat:g}});d.verificationMethod.push(v),d.keyAgreement=[v.id]}let p=[i];return $ge({didDocument:d}).forEach(g=>{let v=OF[g];p.push(v)}),d["@context"]=p,d})}static createEncryptionMethod(e){return ul(this,arguments,void 0,function*({didUri:r,multibaseValue:n,options:i}){let{enableExperimentalPublicKeyTypes:o,publicKeyFormat:s}=i,a={id:"",type:"",controller:""},{keyBytes:d,multicodecCode:u}=yield t.deriveEncryptionKey({multibaseValue:n}),c=d.byteLength,l=yc.MULTICODEC_PUBLIC_KEY_LENGTH[u];if(c!==l)throw new at(tt.InvalidPublicKeyLength,`Expected ${c} bytes. Actual: ${l}`);let p=hF({keyBytes:d,multicodecCode:u});a.id=`${r}#${p}`;try{new URL(a.id)}catch{throw new at(tt.InvalidDidUrl,"Verification Method ID is not a valid DID URL.")}if(!(s in OF))throw new at(tt.UnsupportedPublicKeyType,`Unsupported format: ${s}`);if(o===!1&&!["Multikey","JsonWebKey2020","X25519KeyAgreementKey2020"].includes(s))throw new at(tt.InvalidPublicKeyType,`Specified '${s}' without setting enableExperimentalPublicKeyTypes to true.`);if(a.type=s,a.controller=r,s==="X25519KeyAgreementKey2020"&&(a.publicKeyMultibase=p),s==="JsonWebKey2020"){let{crv:g}=yield yc.multicodecToJwk({code:u});a.publicKeyJwk=yield yc.keyConverter(g).bytesToPublicKey({publicKeyBytes:d})}return a})}static createSignatureMethod(e){return ul(this,arguments,void 0,function*({didUri:r,multibaseValue:n,options:i}){let{enableExperimentalPublicKeyTypes:o,publicKeyFormat:s}=i,a={id:"",type:"",controller:""},{keyBytes:d,multicodecCode:u,multicodecName:c}=pF({multibaseKeyId:n}),l=d.byteLength,p=yc.MULTICODEC_PUBLIC_KEY_LENGTH[u];if(l!==p)throw new at(tt.InvalidPublicKeyLength,`Expected ${l} bytes. Actual: ${p}`);let m=!1;switch(c){case"secp256k1-pub":m=yield Fo.validatePublicKey({publicKeyBytes:d});break;case"ed25519-pub":m=yield go.validatePublicKey({publicKeyBytes:d});break;case"x25519-pub":m=!0;break}if(!m)throw new at(tt.InvalidPublicKey,"Invalid public key detected.");a.id=`${r}#${n}`;try{new URL(a.id)}catch{throw new at(tt.InvalidDidUrl,"Verification Method ID is not a valid DID URL.")}if(!(s in OF))throw new at(tt.UnsupportedPublicKeyType,`Unsupported format: ${s}`);if(o===!1&&!["Multikey","JsonWebKey2020","Ed25519VerificationKey2020"].includes(s))throw new at(tt.InvalidPublicKeyType,`Specified '${s}' without setting enableExperimentalPublicKeyTypes to true.`);if(a.type=s,a.controller=r,s==="Ed25519VerificationKey2020"&&(a.publicKeyMultibase=n),s==="JsonWebKey2020"){let{crv:v}=yield yc.multicodecToJwk({code:u});a.publicKeyJwk=yield yc.keyConverter(v).bytesToPublicKey({publicKeyBytes:d})}return a})}static deriveEncryptionKey(e){return ul(this,arguments,void 0,function*({multibaseValue:r}){let n={keyBytes:new Uint8Array,multicodecCode:0},{keyBytes:i,multicodecCode:o}=pF({multibaseKeyId:r});if(o===237){let s=yield yc.keyConverter("Ed25519").bytesToPublicKey({publicKeyBytes:i}),a=yield go.convertPublicKeyToX25519({publicKey:s});n={keyBytes:yield yc.keyConverter("Ed25519").publicKeyToBytes({publicKey:a}),multicodecCode:236}}return n})}static validateIdentifier(e){let{method:r,id:n}=e,[i]=e.uri.split(":",1);return i==="did"&&r==="key"&&Number("1")>0&&f3(n)==="String"&&n.startsWith("z")}};r_.methodName="key";var yc=class t{static jwkToMulticodec(e){return ul(this,arguments,void 0,function*({jwk:r}){let n=[];r.crv&&(n.push(r.crv),r.d?n.push("private"):n.push("public"));let i=n.join(":"),o=t.JWK_TO_MULTICODEC[i];if(o===void 0)throw new Error(`Unsupported JWK to Multicodec conversion: '${i}'`);return{code:da.getCodeFromName({name:o}),name:o}})}static keyCompressor(e){let n={"P-256":ks.compressPublicKey,secp256k1:Fo.compressPublicKey}[e];if(!n)throw new at(tt.InvalidPublicKeyType,`Unsupported curve: ${e}`);return n}static keyConverter(e){let n={Ed25519:go,"P-256":ks,secp256k1:Fo,X25519:z2}[e];if(!n)throw new at(tt.InvalidPublicKeyType,`Unsupported curve: ${e}`);return n}static multicodecToJwk(e){return ul(this,arguments,void 0,function*({code:r,name:n}){if(!(n?!r:r))throw new Error("Either 'name' or 'code' must be defined, but not both.");n=n===void 0?da.getNameFromCode({code:r}):n;let i=n,o=t.MULTICODEC_TO_JWK[i];if(o===void 0)throw new Error("Unsupported Multicodec to JWK conversion");return Object.assign({},o)})}static publicKeyToMultibaseId(e){return ul(this,arguments,void 0,function*({publicKey:r}){var n;if(!(r?.crv&&r.crv in Ket))throw new at(tt.InvalidPublicKeyType,`Public key contains an unsupported key type: ${(n=r?.crv)!==null&&n!==void 0?n:"undefined"}`);let i=yield t.keyConverter(r.crv).publicKeyToBytes({publicKey:r});/^(secp256k1|P-256|P-384|P-521)$/.test(r.crv)&&(i=yield t.keyCompressor(r.crv)({publicKeyBytes:i}));let{name:o}=yield t.jwkToMulticodec({jwk:r});return hF({keyBytes:i,multicodecName:o})})}};yc.JWK_TO_MULTICODEC={"Ed25519:public":"ed25519-pub","Ed25519:private":"ed25519-priv","secp256k1:public":"secp256k1-pub","secp256k1:private":"secp256k1-priv","X25519:public":"x25519-pub","X25519:private":"x25519-priv"};yc.MULTICODEC_PUBLIC_KEY_LENGTH={231:33,236:32,237:32};yc.MULTICODEC_TO_JWK={"ed25519-pub":{crv:"Ed25519",kty:"OKP",x:""},"ed25519-priv":{crv:"Ed25519",kty:"OKP",x:"",d:""},"secp256k1-pub":{crv:"secp256k1",kty:"EC",x:"",y:""},"secp256k1-priv":{crv:"secp256k1",kty:"EC",x:"",y:"",d:""},"x25519-pub":{crv:"X25519",kty:"OKP",x:""},"x25519-priv":{crv:"X25519",kty:"OKP",x:"",d:""}};f();var Fet=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},CF=class t extends ru{static resolve(e,r){return Fet(this,void 0,void 0,function*(){let n=_r.parse(e);if(!n)return Object.assign(Object.assign({},ai),{didResolutionMetadata:{error:"invalidDid"}});if(n.method!==t.methodName)return Object.assign(Object.assign({},ai),{didResolutionMetadata:{error:"methodNotSupported"}});let i=`https://${n.id.replace(/:/g,"/")}`;i=decodeURIComponent(i);let o=n.id.includes(":")?`${i}/did.json`:`${i}/.well-known/did.json`;try{let s=yield fetch(o);if(!s.ok)throw new Error("HTTP error status code returned");let a=yield s.json();return Object.assign(Object.assign({},ai),{didDocument:a})}catch{return Object.assign(Object.assign({},ai),{didResolutionMetadata:{error:"notFound"}})}})}};CF.methodName="web";f();var Ave=gt(db(),1),Tve=gt(WS(),1),Jet=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},fR=class{constructor({db:e,location:r="DATA/DID_RESOLVERCACHE",ttl:n="15m"}={}){this.cache=e??new Tve.Level(r),this.ttl=(0,Ave.default)(n)}get(e){return Jet(this,void 0,void 0,function*(){try{let r=yield this.cache.get(e),n=JSON.parse(r);if(Date.now()>=n.ttlMillis){this.cache.nextTick(()=>this.cache.del(e));return}else return n.value}catch(r){if(r.notFound)return;throw r}})}set(e,r){let n={ttlMillis:Date.now()+this.ttl,value:r},i=JSON.stringify(n);return this.cache.put(e,i)}delete(e){return this.cache.del(e)}clear(){return this.cache.clear()}close(){return this.cache.close()}};f();var Pve={get:function(t){return null},set:function(t,e){return null},delete:function(t){return null},clear:function(){return null},close:function(){return null}};f();var Ive=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},hR=class{constructor({cache:e,didResolvers:r}){this.didResolvers=new Map,this.cache=e||Pve;for(let n of r)this.didResolvers.set(n.methodName,n)}resolve(e,r){return Ive(this,void 0,void 0,function*(){let n=_r.parse(e);if(!n)return Object.assign(Object.assign({},ai),{didResolutionMetadata:{error:tt.InvalidDid,errorMessage:`Invalid DID URI: ${e}`}});let i=this.didResolvers.get(n.method);if(!i)return Object.assign(Object.assign({},ai),{didResolutionMetadata:{error:tt.MethodNotSupported,errorMessage:`Method not supported: ${n.method}`}});let o=yield this.cache.get(n.uri);if(o)return o;{let s=yield i.resolve(n.uri,r);return s.didResolutionMetadata.error||(yield this.cache.set(n.uri,s)),s}})}dereference(e,r){return Ive(this,void 0,void 0,function*(){let n=_r.parse(e);if(!n)return{dereferencingMetadata:{error:tt.InvalidDidUrl},contentStream:null,contentMetadata:{}};let{didDocument:i,didResolutionMetadata:o,didDocumentMetadata:s}=yield this.resolve(n.uri);if(!i)return{dereferencingMetadata:{error:o.error},contentStream:null,contentMetadata:{}};if(!n.fragment||n.query)return{dereferencingMetadata:{contentType:"application/did+json"},contentStream:i,contentMetadata:s};let{service:a=[],verificationMethod:d=[]}=i,u=new Set([e,n.fragment,`#${n.fragment}`]),c;for(let l of d)if(u.has(l.id)){c=l;break}for(let l of a)if(u.has(l.id)){c=l;break}return c?{dereferencingMetadata:{contentType:"application/did+json"},contentStream:c,contentMetadata:o}:{dereferencingMetadata:{error:tt.NotFound},contentStream:null,contentMetadata:{}}})}};var s_=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},k3=class t{constructor(e){this.didResolver=e.didResolver,this.tenantGate=e.tenantGate,this.eventStream=e.eventStream,this.messageStore=e.messageStore,this.dataStore=e.dataStore,this.resumableTaskStore=e.resumableTaskStore,this.eventLog=e.eventLog,this.eventStream=e.eventStream,this.storageController=new v2({messageStore:this.messageStore,dataStore:this.dataStore,eventLog:this.eventLog,eventStream:this.eventStream}),this.resumableTaskManager=new _S(e.resumableTaskStore,this.storageController),this.methodHandlers={[Te.Messages+Se.Query]:new DP(this.didResolver,this.messageStore,this.eventLog),[Te.Messages+Se.Read]:new BP(this.didResolver,this.messageStore,this.dataStore),[Te.Messages+Se.Subscribe]:new MP(this.didResolver,this.messageStore,this.eventStream),[Te.Protocols+Se.Configure]:new fI(this.didResolver,this.messageStore,this.eventLog,this.eventStream),[Te.Protocols+Se.Query]:new hI(this.didResolver,this.messageStore,this.dataStore),[Te.Records+Se.Delete]:new pI(this.didResolver,this.messageStore,this.resumableTaskManager),[Te.Records+Se.Query]:new mI(this.didResolver,this.messageStore,this.dataStore),[Te.Records+Se.Read]:new yI(this.didResolver,this.messageStore,this.dataStore),[Te.Records+Se.Subscribe]:new vI(this.didResolver,this.messageStore,this.eventStream),[Te.Records+Se.Write]:new bI(this.didResolver,this.messageStore,this.dataStore,this.eventLog,this.eventStream)}}static create(e){var r,n;return s_(this,void 0,void 0,function*(){(r=e.didResolver)!==null&&r!==void 0||(e.didResolver=new hR({didResolvers:[ob,I3,r_],cache:new fR({location:"RESOLVERCACHE"})})),(n=e.tenantGate)!==null&&n!==void 0||(e.tenantGate=new L6);let i=new t(e);return yield i.open(),i})}open(){var e;return s_(this,void 0,void 0,function*(){yield this.messageStore.open(),yield this.dataStore.open(),yield this.resumableTaskStore.open(),yield this.eventLog.open(),yield(e=this.eventStream)===null||e===void 0?void 0:e.open(),yield this.resumableTaskManager.resumeTasksAndWaitForCompletion()})}close(){var e;return s_(this,void 0,void 0,function*(){yield(e=this.eventStream)===null||e===void 0?void 0:e.close(),yield this.messageStore.close(),yield this.dataStore.close(),yield this.resumableTaskStore.close(),yield this.eventLog.close()})}processMessage(e,r,n={}){var i;return s_(this,void 0,void 0,function*(){let o=(i=yield this.validateTenant(e))!==null&&i!==void 0?i:yield this.validateMessageIntegrity(r);if(o!==void 0)return o;let{dataStream:s,subscriptionHandler:a}=n,d=r.descriptor.interface+r.descriptor.method;return yield this.methodHandlers[d].handle({tenant:e,message:r,dataStream:s,subscriptionHandler:a})})}validateTenant(e){var r;return s_(this,void 0,void 0,function*(){let n=yield this.tenantGate.isActiveTenant(e);if(!n.isActiveTenant)return{status:{code:401,detail:(r=n.detail)!==null&&r!==void 0?r:`DID ${e} is not an active tenant.`}}})}validateMessageIntegrity(e){var r,n;return s_(this,void 0,void 0,function*(){let i=(r=e?.descriptor)===null||r===void 0?void 0:r.interface,o=(n=e?.descriptor)===null||n===void 0?void 0:n.method;if(i===void 0||o===void 0)return{status:{code:400,detail:`Both interface and method must be present, interface: ${i}, method: ${o}`}};try{_e.validateJsonSchema(e)}catch(s){return mr(s,400)}})}};f();var Zet=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})};function Yet(t){return new Promise((e,r)=>{if(t.aborted){r(t.reason);return}t.addEventListener("abort",()=>{r(t.reason)})})}function Xi(t,e){return Zet(this,void 0,void 0,function*(){return e?Promise.race([t,Yet(e)]):t})}f();f();f();f();var Rve=gt(p3(),1),nd=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},ll=function(t){return this instanceof ll?(this.v=t,this):new ll(t)},$F=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,d){s=t[o](s),i(a,d,s.done,s.value)})}}function i(o,s,a,d){Promise.resolve(d).then(function(u){o({value:u,done:a})},s)}},kve=function(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),i,o=[];return i={},s("next"),s("throw"),s("return"),i[Symbol.asyncIterator]=function(){return this},i;function s(p){n[p]&&(i[p]=function(m){return new Promise(function(g,v){o.push([p,m,g,v])>1||a(p,m)})})}function a(p,m){try{d(n[p](m))}catch(g){l(o[0][3],g)}}function d(p){p.value instanceof ll?Promise.resolve(p.value.v).then(u,c):l(o[0][2],p)}function u(p){a("next",p)}function c(p){a("throw",p)}function l(p,m){p(m),o.shift(),o.length&&a(o[0][0],o[0][1])}};function id(t,e){return nd(this,void 0,void 0,function*(){return new Rve.Level(t,Object.assign(Object.assign({},e),{keyEncoding:"utf8"}))})}var Jy=class t{constructor(e,r){this.config=Object.assign({createLevelDatabase:id},e),this.db=r}open(){return nd(this,void 0,void 0,function*(){switch(yield this.createLevelDatabase(),this.db.status){case"open":return;case"opening":return new Promise(e=>{this.db.once("open",e)});case"closing":return new Promise((e,r)=>{let n=()=>{this.db.open().then(e).catch(r)};this.db.once("closed",n)});case"closed":return this.db.open()}})}close(){return nd(this,void 0,void 0,function*(){if(this.db)switch(this.db.status){case"open":return this.db.close();case"opening":return new Promise((e,r)=>{let n=()=>{this.db.close().then(e).catch(r)};this.db.once("open",n)});case"closing":return new Promise(e=>{this.db.once("closed",e)});case"closed":return}})}partition(e){return nd(this,void 0,void 0,function*(){return yield this.createLevelDatabase(),new t(this.config,this.db.sublevel(e,{keyEncoding:"utf8",valueEncoding:this.config.valueEncoding}))})}get(e,r){var n;return nd(this,void 0,void 0,function*(){(n=r?.signal)===null||n===void 0||n.throwIfAborted(),yield Xi(this.createLevelDatabase(),r?.signal);try{return yield Xi(this.db.get(String(e)),r?.signal)}catch(i){if(i.code==="LEVEL_NOT_FOUND")return;throw i}})}has(e,r){return nd(this,void 0,void 0,function*(){return!!(yield this.get(e,r))})}keys(e){var r,n;return kve(this,arguments,function*(){var o,s,a,d;(r=e?.signal)===null||r===void 0||r.throwIfAborted(),yield ll(Xi(this.createLevelDatabase(),e?.signal));try{for(var u=!0,c=$F(this.db.keys()),l;l=yield ll(c.next()),o=l.done,!o;u=!0){d=l.value,u=!1;let p=d;(n=e?.signal)===null||n===void 0||n.throwIfAborted(),yield yield ll(p)}}catch(p){s={error:p}}finally{try{!u&&!o&&(a=c.return)&&(yield ll(a.call(c)))}finally{if(s)throw s.error}}})}iterator(e,r){var n,i;return kve(this,arguments,function*(){var s,a,d,u;(n=r?.signal)===null||n===void 0||n.throwIfAborted(),yield ll(Xi(this.createLevelDatabase(),r?.signal));try{for(var c=!0,l=$F(this.db.iterator(e)),p;p=yield ll(l.next()),s=p.done,!s;c=!0){u=p.value,c=!1;let m=u;(i=r?.signal)===null||i===void 0||i.throwIfAborted(),yield yield ll(m)}}catch(m){a={error:m}}finally{try{!c&&!s&&(d=l.return)&&(yield ll(d.call(l)))}finally{if(a)throw a.error}}})}put(e,r,n){var i;return nd(this,void 0,void 0,function*(){return(i=n?.signal)===null||i===void 0||i.throwIfAborted(),yield Xi(this.createLevelDatabase(),n?.signal),Xi(this.db.put(String(e),r),n?.signal)})}delete(e,r){var n;return nd(this,void 0,void 0,function*(){return(n=r?.signal)===null||n===void 0||n.throwIfAborted(),yield Xi(this.createLevelDatabase(),r?.signal),Xi(this.db.del(String(e)),r?.signal)})}isEmpty(e){var r,n,i,o;return nd(this,void 0,void 0,function*(){try{for(var s=!0,a=$F(this.keys(e)),d;d=yield a.next(),r=d.done,!r;s=!0){o=d.value,s=!1;let u=o;return!1}}catch(u){n={error:u}}finally{try{!s&&!r&&(i=a.return)&&(yield i.call(a))}finally{if(n)throw n.error}}return!0})}clear(){return nd(this,void 0,void 0,function*(){yield this.createLevelDatabase(),yield this.db.clear(),yield this.compactUnderlyingStorage()})}batch(e,r){var n;return nd(this,void 0,void 0,function*(){return(n=r?.signal)===null||n===void 0||n.throwIfAborted(),yield Xi(this.createLevelDatabase(),r?.signal),Xi(this.db.batch(e),r?.signal)})}createPartitionOperation(e,r){return Object.assign(Object.assign({},r),{sublevel:this.db.sublevel(e,{keyEncoding:"utf8",valueEncoding:this.config.valueEncoding})})}compactUnderlyingStorage(e){var r,n,i;return nd(this,void 0,void 0,function*(){(r=e?.signal)===null||r===void 0||r.throwIfAborted(),yield Xi(this.createLevelDatabase(),e?.signal);let o=this.sublevelRange;if(!o)return;let s=this.root;if(s.db.supports.additionalMethods.compactRange)return Xi((i=(n=s.db).compactRange)===null||i===void 0?void 0:i.call(n,...o),e?.signal)})}get sublevelRange(){let e=this.db.prefix;if(!e)return;let r=e.slice(0,-1)+String.fromCharCode(e.charCodeAt(e.length-1)+1);return[e,r]}get root(){let e=this.db;for(let r=e.db;r&&r!==e;)e=r;return new t(this.config,e)}createLevelDatabase(){var e;return nd(this,void 0,void 0,function*(){(e=this.db)!==null&&e!==void 0||(this.db=yield this.config.createLevelDatabase(this.config.location,{keyEncoding:"utf8",valueEncoding:this.config.valueEncoding}))})}};var xp=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},pR=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,d){s=t[o](s),i(a,d,s.done,s.value)})}}function i(o,s,a,d){Promise.resolve(d).then(function(u){o({value:u,done:a})},s)}},Vo=function(t){return this instanceof Vo?(this.v=t,this):new Vo(t)},mR=function(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),i,o=[];return i={},s("next"),s("throw"),s("return"),i[Symbol.asyncIterator]=function(){return this},i;function s(p){n[p]&&(i[p]=function(m){return new Promise(function(g,v){o.push([p,m,g,v])>1||a(p,m)})})}function a(p,m){try{d(n[p](m))}catch(g){l(o[0][3],g)}}function d(p){p.value instanceof Vo?Promise.resolve(p.value.v).then(u,c):l(o[0][2],p)}function u(p){a("next",p)}function c(p){a("throw",p)}function l(p,m){p(m),o.shift(),o.length&&a(o[0][0],o[0][1])}},a_=class t{constructor(e,r){this.config=Object.assign({createLevelDatabase:id},e),this.db=r??new Jy(Object.assign(Object.assign({},this.config),{valueEncoding:"binary"}))}open(){return xp(this,void 0,void 0,function*(){return this.db.open()})}close(){return xp(this,void 0,void 0,function*(){return this.db.close()})}partition(e){return xp(this,void 0,void 0,function*(){let r=yield this.db.partition(e);return new t(Object.assign(Object.assign({},this.config),{location:""}),r)})}put(e,r,n){return xp(this,void 0,void 0,function*(){return yield this.db.put(String(e),r,n),jr.parse(e.toString())})}get(e,r){return xp(this,void 0,void 0,function*(){return yield this.db.get(String(e),r)})}has(e,r){return xp(this,void 0,void 0,function*(){return this.db.has(String(e),r)})}delete(e,r){return xp(this,void 0,void 0,function*(){return this.db.delete(String(e),r)})}isEmpty(e){return xp(this,void 0,void 0,function*(){return this.db.isEmpty(e)})}putMany(e,r){return mR(this,arguments,function*(){var i,o,s,a;try{for(var d=!0,u=pR(e),c;c=yield Vo(u.next()),i=c.done,!i;d=!0){a=c.value,d=!1;let l=a;yield Vo(this.put(l.cid,l.block,r)),yield yield Vo(l.cid)}}catch(l){o={error:l}}finally{try{!d&&!i&&(s=u.return)&&(yield Vo(s.call(u)))}finally{if(o)throw o.error}}})}getMany(e,r){return mR(this,arguments,function*(){var i,o,s,a;try{for(var d=!0,u=pR(e),c;c=yield Vo(u.next()),i=c.done,!i;d=!0){a=c.value,d=!1;let l=a;yield yield Vo({cid:l,block:yield Vo(this.get(l,r))})}}catch(l){o={error:l}}finally{try{!d&&!i&&(s=u.return)&&(yield Vo(s.call(u)))}finally{if(o)throw o.error}}})}getAll(e){return mR(this,arguments,function*(){var n,i,o,s;let a=this.db.iterator({keys:!0,keyEncoding:"buffer"},e);try{for(var d=!0,u=pR(a),c;c=yield Vo(u.next()),n=c.done,!n;d=!0){s=c.value,d=!1;let[l,p]=s;yield yield Vo({cid:jr.decode(l),block:p})}}catch(l){i={error:l}}finally{try{!d&&!n&&(o=u.return)&&(yield Vo(o.call(u)))}finally{if(i)throw i.error}}})}deleteMany(e,r){return mR(this,arguments,function*(){var i,o,s,a;try{for(var d=!0,u=pR(e),c;c=yield Vo(u.next()),i=c.done,!i;d=!0){a=c.value,d=!1;let l=a;yield Vo(this.delete(l,r)),yield yield Vo(l)}}catch(l){o={error:l}}finally{try{!d&&!i&&(s=u.return)&&(yield Vo(s.call(u)))}finally{if(o)throw o.error}}})}clear(){return xp(this,void 0,void 0,function*(){return this.db.clear()})}};f();var qR=gt(Dc(),1);f();function Xet(t){return t[Symbol.asyncIterator]!=null}function Qet(t){if(Xet(t))return(async()=>{let r;for await(let n of t)r=n;return r})();let e;for(let r of t)e=r;return e}var Dve=Qet;f();f();f();f();f();var ett=["string","number","bigint","symbol"],ttt=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function Bve(t){if(t===null)return"null";if(t===void 0)return"undefined";if(t===!0||t===!1)return"boolean";let e=typeof t;if(ett.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(t))return"Array";if(rtt(t))return"Buffer";let r=ntt(t);return r||"Object"}function rtt(t){return t&&t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer.call(null,t)}function ntt(t){let e=Object.prototype.toString.call(t).slice(8,-1);if(ttt.includes(e))return e}f();var we=class{constructor(e,r,n){this.major=e,this.majorEncoded=e<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.majore.major?1:0}};we.uint=new we(0,"uint",!0);we.negint=new we(1,"negint",!0);we.bytes=new we(2,"bytes",!0);we.string=new we(3,"string",!0);we.array=new we(4,"array",!1);we.map=new we(5,"map",!1);we.tag=new we(6,"tag",!1);we.float=new we(7,"float",!0);we.false=new we(7,"false",!0);we.true=new we(7,"true",!0);we.null=new we(7,"null",!0);we.undefined=new we(7,"undefined",!0);we.break=new we(7,"break",!0);var Je=class{constructor(e,r,n){this.type=e,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};f();f();var c_=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",itt=new TextDecoder,ott=new TextEncoder;function yR(t){return c_&&globalThis.Buffer.isBuffer(t)}function $ve(t){return t instanceof Uint8Array?yR(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t:Uint8Array.from(t)}var jve=c_?(t,e,r)=>r-e>64?globalThis.Buffer.from(t.subarray(e,r)).toString("utf8"):Ove(t,e,r):(t,e,r)=>r-e>64?itt.decode(t.subarray(e,r)):Ove(t,e,r),Nve=c_?t=>t.length>64?globalThis.Buffer.from(t):Mve(t):t=>t.length>64?ott.encode(t):Mve(t);var d_=c_?(t,e,r)=>yR(t)?new Uint8Array(t.subarray(e,r)):t.slice(e,r):(t,e,r)=>t.slice(e,r),Uve=c_?(t,e)=>(t=t.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),$ve(globalThis.Buffer.concat(t,e))):(t,e)=>{let r=new Uint8Array(e),n=0;for(let i of t)n+i.length>r.length&&(i=i.subarray(0,r.length-n)),r.set(i,n),n+=i.length;return r},qve=c_?t=>globalThis.Buffer.allocUnsafe(t):t=>new Uint8Array(t);function Lve(t,e){if(yR(t)&&yR(e))return t.compare(e);for(let r=0;r>6|192,e[r++]=i&63|128):(i&64512)===55296&&n+1>18|240,e[r++]=i>>12&63|128,e[r++]=i>>6&63|128,e[r++]=i&63|128):(e[r++]=i>>12|224,e[r++]=i>>6&63|128,e[r++]=i&63|128)}return e}function Ove(t,e,r){let n=[];for(;e239?4:i>223?3:i>191?2:1;if(e+s<=r){let a,d,u,c;switch(s){case 1:i<128&&(o=i);break;case 2:a=t[e+1],(a&192)===128&&(c=(i&31)<<6|a&63,c>127&&(o=c));break;case 3:a=t[e+1],d=t[e+2],(a&192)===128&&(d&192)===128&&(c=(i&15)<<12|(a&63)<<6|d&63,c>2047&&(c<55296||c>57343)&&(o=c));break;case 4:a=t[e+1],d=t[e+2],u=t[e+3],(a&192)===128&&(d&192)===128&&(u&192)===128&&(c=(i&15)<<18|(a&63)<<12|(d&63)<<6|u&63,c>65535&&c<1114112&&(o=c))}}o===null?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),e+=s}return stt(n)}var Cve=4096;function stt(t){let e=t.length;if(e<=Cve)return String.fromCharCode.apply(String,t);let r="",n=0;for(;nn.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=d_(n,0,this.cursor)}else r=Uve(this.chunks,this.cursor);return e&&this.reset(),r}};f();var zt="CBOR decode error:",jF="CBOR encode error:",R3=[];R3[23]=1;R3[24]=2;R3[25]=3;R3[26]=5;R3[27]=9;function Ep(t,e,r){if(t.length-e>>8,n&255])}else if(r>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n>BigInt(32)&BigInt(4294967295));i[8]=o&255,o=o>>8,i[7]=o&255,o=o>>8,i[6]=o&255,o=o>>8,i[5]=o&255,i[4]=s&255,s=s>>8,i[3]=s&255,s=s>>8,i[2]=s&255,s=s>>8,i[1]=s&255,t.push(i)}else throw new Error(`${zt} encountered BigInt larger than allowable range`)}}nu.encodedSize=function(e){return Bs.encodedSize(e.value)};Bs.encodedSize=function(e){return er.value?1:0};f();function Hve(t,e,r,n){return new Je(we.negint,-1-od(t,e+1,n),2)}function Vve(t,e,r,n){return new Je(we.negint,-1-sd(t,e+1,n),3)}function Gve(t,e,r,n){return new Je(we.negint,-1-ad(t,e+1,n),5)}var NF=BigInt(-1),Jve=BigInt(1);function Zve(t,e,r,n){let i=cd(t,e+1,n);if(typeof i!="bigint"){let o=-1-i;if(o>=Number.MIN_SAFE_INTEGER)return new Je(we.negint,o,9)}if(n.allowBigInt!==!0)throw new Error(`${zt} integers outside of the safe integer range are not supported`);return new Je(we.negint,NF-BigInt(i),9)}function vR(t,e){let r=e.value,n=typeof r=="bigint"?r*NF-Jve:r*-1-1;Bs(t,e.type.majorEncoded,n)}vR.encodedSize=function(e){let r=e.value,n=typeof r=="bigint"?r*NF-Jve:r*-1-1;return nr.value?-1:0};f();function D3(t,e,r,n){Ep(t,e,r+n);let i=d_(t,e+r,e+r+n);return new Je(we.bytes,i,r+n)}function Yve(t,e,r,n){return D3(t,e,1,r)}function Xve(t,e,r,n){return D3(t,e,2,od(t,e+1,n))}function Qve(t,e,r,n){return D3(t,e,3,sd(t,e+1,n))}function ebe(t,e,r,n){return D3(t,e,5,ad(t,e+1,n))}function tbe(t,e,r,n){let i=cd(t,e+1,n);if(typeof i=="bigint")throw new Error(`${zt} 64-bit integer bytes lengths not supported`);return D3(t,e,9,i)}function bR(t){return t.encodedBytes===void 0&&(t.encodedBytes=t.type===we.string?Nve(t.value):t.value),t.encodedBytes}function u_(t,e){let r=bR(e);Bs(t,e.type.majorEncoded,r.length),t.push(r)}u_.encodedSize=function(e){let r=bR(e);return Bs.encodedSize(r.length)+r.length};u_.compareTokens=function(e,r){return dtt(bR(e),bR(r))};function dtt(t,e){return t.lengthe.length?1:Lve(t,e)}f();function B3(t,e,r,n,i){let o=r+n;Ep(t,e,o);let s=new Je(we.string,jve(t,e+r,e+o),o);return i.retainStringBytes===!0&&(s.byteValue=d_(t,e+r,e+o)),s}function rbe(t,e,r,n){return B3(t,e,1,r,n)}function nbe(t,e,r,n){return B3(t,e,2,od(t,e+1,n),n)}function ibe(t,e,r,n){return B3(t,e,3,sd(t,e+1,n),n)}function obe(t,e,r,n){return B3(t,e,5,ad(t,e+1,n),n)}function sbe(t,e,r,n){let i=cd(t,e+1,n);if(typeof i=="bigint")throw new Error(`${zt} 64-bit integer string lengths not supported`);return B3(t,e,9,i,n)}var abe=u_;f();function l_(t,e,r,n){return new Je(we.array,n,r)}function cbe(t,e,r,n){return l_(t,e,1,r)}function dbe(t,e,r,n){return l_(t,e,2,od(t,e+1,n))}function ube(t,e,r,n){return l_(t,e,3,sd(t,e+1,n))}function lbe(t,e,r,n){return l_(t,e,5,ad(t,e+1,n))}function fbe(t,e,r,n){let i=cd(t,e+1,n);if(typeof i=="bigint")throw new Error(`${zt} 64-bit integer array lengths not supported`);return l_(t,e,9,i)}function hbe(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${zt} indefinite length items not allowed`);return l_(t,e,1,1/0)}function wR(t,e){Bs(t,we.array.majorEncoded,e.value)}wR.compareTokens=nu.compareTokens;wR.encodedSize=function(e){return Bs.encodedSize(e.value)};f();function f_(t,e,r,n){return new Je(we.map,n,r)}function pbe(t,e,r,n){return f_(t,e,1,r)}function mbe(t,e,r,n){return f_(t,e,2,od(t,e+1,n))}function ybe(t,e,r,n){return f_(t,e,3,sd(t,e+1,n))}function gbe(t,e,r,n){return f_(t,e,5,ad(t,e+1,n))}function vbe(t,e,r,n){let i=cd(t,e+1,n);if(typeof i=="bigint")throw new Error(`${zt} 64-bit integer map lengths not supported`);return f_(t,e,9,i)}function bbe(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${zt} indefinite length items not allowed`);return f_(t,e,1,1/0)}function _R(t,e){Bs(t,we.map.majorEncoded,e.value)}_R.compareTokens=nu.compareTokens;_R.encodedSize=function(e){return Bs.encodedSize(e.value)};f();function wbe(t,e,r,n){return new Je(we.tag,r,1)}function _be(t,e,r,n){return new Je(we.tag,od(t,e+1,n),2)}function xbe(t,e,r,n){return new Je(we.tag,sd(t,e+1,n),3)}function Ebe(t,e,r,n){return new Je(we.tag,ad(t,e+1,n),5)}function Sbe(t,e,r,n){return new Je(we.tag,cd(t,e+1,n),9)}function xR(t,e){Bs(t,we.tag.majorEncoded,e.value)}xR.compareTokens=nu.compareTokens;xR.encodedSize=function(e){return Bs.encodedSize(e.value)};f();var mtt=20,ytt=21,gtt=22,vtt=23;function Abe(t,e,r,n){if(n.allowUndefined===!1)throw new Error(`${zt} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new Je(we.null,null,1):new Je(we.undefined,void 0,1)}function Tbe(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${zt} indefinite length items not allowed`);return new Je(we.break,void 0,1)}function UF(t,e,r){if(r){if(r.allowNaN===!1&&Number.isNaN(t))throw new Error(`${zt} NaN values are not supported`);if(r.allowInfinity===!1&&(t===1/0||t===-1/0))throw new Error(`${zt} Infinity values are not supported`)}return new Je(we.float,t,e)}function Pbe(t,e,r,n){return UF(qF(t,e+1),3,n)}function Ibe(t,e,r,n){return UF(LF(t,e+1),5,n)}function kbe(t,e,r,n){return UF(Mbe(t,e+1),9,n)}function ER(t,e,r){let n=e.value;if(n===!1)t.push([we.float.majorEncoded|mtt]);else if(n===!0)t.push([we.float.majorEncoded|ytt]);else if(n===null)t.push([we.float.majorEncoded|gtt]);else if(n===void 0)t.push([we.float.majorEncoded|vtt]);else{let i,o=!1;(!r||r.float64!==!0)&&(Dbe(n),i=qF(fl,1),n===i||Number.isNaN(n)?(fl[0]=249,t.push(fl.slice(0,3)),o=!0):(Bbe(n),i=LF(fl,1),n===i&&(fl[0]=250,t.push(fl.slice(0,5)),o=!0))),o||(btt(n),i=Mbe(fl,1),fl[0]=251,t.push(fl.slice(0,9)))}}ER.encodedSize=function(e,r){let n=e.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){Dbe(n);let i=qF(fl,1);if(n===i||Number.isNaN(n))return 3;if(Bbe(n),i=LF(fl,1),n===i)return 5}return 9};var Rbe=new ArrayBuffer(9),iu=new DataView(Rbe,1),fl=new Uint8Array(Rbe,0);function Dbe(t){if(t===1/0)iu.setUint16(0,31744,!1);else if(t===-1/0)iu.setUint16(0,64512,!1);else if(Number.isNaN(t))iu.setUint16(0,32256,!1);else{iu.setFloat32(0,t);let e=iu.getUint32(0),r=(e&2139095040)>>23,n=e&8388607;if(r===255)iu.setUint16(0,31744,!1);else if(r===0)iu.setUint16(0,(t&2147483648)>>16|n>>13,!1);else{let i=r-127;i<-24?iu.setUint16(0,0):i<-14?iu.setUint16(0,(e&2147483648)>>16|1<<24+i,!1):iu.setUint16(0,(e&2147483648)>>16|i+15<<10|n>>13,!1)}}}function qF(t,e){if(t.length-e<2)throw new Error(`${zt} not enough data for float16`);let r=(t[e]<<8)+t[e+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,i=r&1023,o;return n===0?o=i*2**-24:n!==31?o=(i+1024)*2**(n-25):o=i===0?1/0:NaN,r&32768?-o:o}function Bbe(t){iu.setFloat32(0,t,!1)}function LF(t,e){if(t.length-e<4)throw new Error(`${zt} not enough data for float32`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,4).getFloat32(0,!1)}function btt(t){iu.setFloat64(0,t,!1)}function Mbe(t,e){if(t.length-e<8)throw new Error(`${zt} not enough data for float64`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,8).getFloat64(0,!1)}ER.compareTokens=nu.compareTokens;function Gr(t,e,r){throw new Error(`${zt} encountered invalid minor (${r}) for major ${t[e]>>>5}`)}function SR(t){return()=>{throw new Error(`${zt} ${t}`)}}var $e=[];for(let t=0;t<=23;t++)$e[t]=Gr;$e[24]=Kve;$e[25]=Fve;$e[26]=zve;$e[27]=Wve;$e[28]=Gr;$e[29]=Gr;$e[30]=Gr;$e[31]=Gr;for(let t=32;t<=55;t++)$e[t]=Gr;$e[56]=Hve;$e[57]=Vve;$e[58]=Gve;$e[59]=Zve;$e[60]=Gr;$e[61]=Gr;$e[62]=Gr;$e[63]=Gr;for(let t=64;t<=87;t++)$e[t]=Yve;$e[88]=Xve;$e[89]=Qve;$e[90]=ebe;$e[91]=tbe;$e[92]=Gr;$e[93]=Gr;$e[94]=Gr;$e[95]=SR("indefinite length bytes/strings are not supported");for(let t=96;t<=119;t++)$e[t]=rbe;$e[120]=nbe;$e[121]=ibe;$e[122]=obe;$e[123]=sbe;$e[124]=Gr;$e[125]=Gr;$e[126]=Gr;$e[127]=SR("indefinite length bytes/strings are not supported");for(let t=128;t<=151;t++)$e[t]=cbe;$e[152]=dbe;$e[153]=ube;$e[154]=lbe;$e[155]=fbe;$e[156]=Gr;$e[157]=Gr;$e[158]=Gr;$e[159]=hbe;for(let t=160;t<=183;t++)$e[t]=pbe;$e[184]=mbe;$e[185]=ybe;$e[186]=gbe;$e[187]=vbe;$e[188]=Gr;$e[189]=Gr;$e[190]=Gr;$e[191]=bbe;for(let t=192;t<=215;t++)$e[t]=wbe;$e[216]=_be;$e[217]=xbe;$e[218]=Ebe;$e[219]=Sbe;$e[220]=Gr;$e[221]=Gr;$e[222]=Gr;$e[223]=Gr;for(let t=224;t<=243;t++)$e[t]=SR("simple values are not supported");$e[244]=Gr;$e[245]=Gr;$e[246]=Gr;$e[247]=Abe;$e[248]=SR("simple values are not supported");$e[249]=Pbe;$e[250]=Ibe;$e[251]=kbe;$e[252]=Gr;$e[253]=Gr;$e[254]=Gr;$e[255]=Tbe;var hl=[];for(let t=0;t<24;t++)hl[t]=new Je(we.uint,t,1);for(let t=-1;t>=-24;t--)hl[31-t]=new Je(we.negint,t,1);hl[64]=new Je(we.bytes,new Uint8Array(0),1);hl[96]=new Je(we.string,"",1);hl[128]=new Je(we.array,0,1);hl[160]=new Je(we.map,0,1);hl[244]=new Je(we.false,!1,1);hl[245]=new Je(we.true,!0,1);hl[246]=new Je(we.null,null,1);function _tt(){let t=[];return t[we.uint.major]=nu,t[we.negint.major]=vR,t[we.bytes.major]=u_,t[we.string.major]=abe,t[we.array.major]=wR,t[we.map.major]=_R,t[we.tag.major]=xR,t[we.float.major]=ER,t}var uNt=_tt(),lNt=new gR,AR=class t{constructor(e,r){this.obj=e,this.parent=r}includes(e){let r=this;do if(r.obj===e)return!0;while(r=r.parent);return!1}static createCheck(e,r){if(e&&e.includes(r))throw new Error(`${jF} object contains circular references`);return new t(r,e)}},Zy={null:new Je(we.null,null),undefined:new Je(we.undefined,void 0),true:new Je(we.true,!0),false:new Je(we.false,!1),emptyArray:new Je(we.array,0),emptyMap:new Je(we.map,0)},Yy={number(t,e,r,n){return!Number.isInteger(t)||!Number.isSafeInteger(t)?new Je(we.float,t):t>=0?new Je(we.uint,t):new Je(we.negint,t)},bigint(t,e,r,n){return t>=BigInt(0)?new Je(we.uint,t):new Je(we.negint,t)},Uint8Array(t,e,r,n){return new Je(we.bytes,t)},string(t,e,r,n){return new Je(we.string,t)},boolean(t,e,r,n){return t?Zy.true:Zy.false},null(t,e,r,n){return Zy.null},undefined(t,e,r,n){return Zy.undefined},ArrayBuffer(t,e,r,n){return new Je(we.bytes,new Uint8Array(t))},DataView(t,e,r,n){return new Je(we.bytes,new Uint8Array(t.buffer,t.byteOffset,t.byteLength))},Array(t,e,r,n){if(!t.length)return r.addBreakTokens===!0?[Zy.emptyArray,new Je(we.break)]:Zy.emptyArray;n=AR.createCheck(n,t);let i=[],o=0;for(let s of t)i[o++]=KF(s,r,n);return r.addBreakTokens?[new Je(we.array,t.length),i,new Je(we.break)]:[new Je(we.array,t.length),i]},Object(t,e,r,n){let i=e!=="Object",o=i?t.keys():Object.keys(t),s=i?t.size:o.length;if(!s)return r.addBreakTokens===!0?[Zy.emptyMap,new Je(we.break)]:Zy.emptyMap;n=AR.createCheck(n,t);let a=[],d=0;for(let u of o)a[d++]=[KF(u,r,n),KF(i?t.get(u):t[u],r,n)];return xtt(a,r),r.addBreakTokens?[new Je(we.map,s),a,new Je(we.break)]:[new Je(we.map,s),a]}};Yy.Map=Yy.Object;Yy.Buffer=Yy.Uint8Array;for(let t of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Yy[`${t}Array`]=Yy.DataView;function KF(t,e={},r){let n=Bve(t),i=e&&e.typeEncoders&&e.typeEncoders[n]||Yy[n];if(typeof i=="function"){let s=i(t,n,e,r);if(s!=null)return s}let o=Yy[n];if(!o)throw new Error(`${jF} unsupported type: ${n}`);return o(t,n,e,r)}function xtt(t,e){e.mapSorter&&t.sort(e.mapSorter)}f();var Ett={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},TR=class{constructor(e,r={}){this._pos=0,this.data=e,this.options=r}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let e=this.data[this._pos],r=hl[e];if(r===void 0){let n=$e[e];if(!n)throw new Error(`${zt} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);let i=e&31;r=n(this.data,this._pos,i,this.options)}return this._pos+=r.encodedLength,r}},M3=Symbol.for("DONE"),PR=Symbol.for("BREAK");function Stt(t,e,r){let n=[];for(let i=0;i0)throw new Error(`${zt} too many terminals, data makes no sense`);return r}var Itt=42;function ktt(t){if(t[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return sh.decode(t.subarray(1))}var Cbe={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:[]};Cbe.tags[Itt]=ktt;var $be=113;var jbe=t=>FF(t,Cbe);var vwe=gt(Dc(),1);f();var Ube=0,Rtt="identity",qbe=hu,Dtt=t=>I0(Ube,qbe(t)),Lbe={code:Ube,name:Rtt,encode:qbe,digest:Dtt};f();var Kbe=gt(Dc(),1);var Btt=async(t,e,r,n,i,o,s,a)=>{let d=await s.get(t,a),u=jbe(d),c=u,l=r;for(;n.length>0;){let p=n[0];if(p in c){n.shift(),l=`${l}/${p}`;let m=jr.asCID(c[p]);if(m!=null)return{entry:{type:"object",name:e,path:r,cid:t,node:d,depth:o,size:BigInt(d.length),content:async function*(){yield u}},next:{cid:m,name:p,path:l,toResolve:n}};c=c[p]}else throw(0,Kbe.default)(new Error(`No property named ${p} found in cbor node ${t}`),"ERR_NO_PROP")}return{entry:{type:"object",name:e,path:r,cid:t,node:d,depth:o,size:BigInt(d.length),content:async function*(){yield u}}}},Fbe=Btt;f();var zbe=gt(Dc(),1);f();function Mtt(t,e,r,n){let i=BigInt(t.length),o=BigInt(e+i);return r>=o||n=e&&n=e&&r{let n=BigInt(t),i=BigInt(e??0),o=BigInt(r);if(o!==n&&(o=i+o),o>n&&(o=n),i<0n)throw(0,O3.default)(new Error("Offset must be greater than or equal to 0"),"ERR_INVALID_PARAMS");if(i>n)throw(0,O3.default)(new Error("Offset must be less than the file size"),"ERR_INVALID_PARAMS");if(o<0n)throw(0,O3.default)(new Error("Length must be greater than or equal to 0"),"ERR_INVALID_PARAMS");if(o>n)throw(0,O3.default)(new Error("Length must be less than the file size"),"ERR_INVALID_PARAMS");return{start:i,end:o}},p_=Ott;var Ctt=t=>{async function*e(r={}){let{start:n,end:i}=p_(t.length,r.offset,r.length),o=lb(t,0n,n,i);r.onProgress?.(new yi("unixfs:exporter:progress:identity",{bytesRead:BigInt(o.byteLength),totalBytes:i-n,fileSize:BigInt(t.byteLength)})),yield o}return e},$tt=async(t,e,r,n,i,o,s,a)=>{if(n.length>0)throw(0,zbe.default)(new Error(`No link named ${r} found in raw node ${t}`),"ERR_NOT_FOUND");let d=X5(t.multihash.bytes);return{entry:{type:"identity",name:e,path:r,cid:t,content:Ctt(d.digest),depth:o,size:BigInt(d.digest.length),node:d.digest}}},Wbe=$tt;f();var Hbe=gt(Dc(),1);var jtt=t=>{async function*e(r={}){let{start:n,end:i}=p_(t.length,r.offset,r.length),o=lb(t,0n,n,i);r.onProgress?.(new yi("unixfs:exporter:progress:raw",{bytesRead:BigInt(o.byteLength),totalBytes:i-n,fileSize:BigInt(t.byteLength)})),yield o}return e},Ntt=async(t,e,r,n,i,o,s,a)=>{if(n.length>0)throw(0,Hbe.default)(new Error(`No link named ${r} found in raw node ${t}`),"ERR_NOT_FOUND");let d=await s.get(t,a);return{entry:{type:"raw",name:e,path:r,cid:t,content:jtt(d),depth:o,size:BigInt(d.length),node:d}}},Vbe=Ntt;f();var K3=gt(Dc(),1);f();var Utt=async function(t){return(await C8.encode(t)).slice(0,8).reverse()},qtt=async(t,e,r)=>{await Promise.all(t.map(async n=>{if(n.Name==null)throw new Error("Unexpected Link without a Name");if(n.Name.length===2){let i=parseInt(n.Name,16);e._putObjectAt(i,new Rl({hash:r._options.hash,bits:r._options.bits},e,i));return}await r.put(n.Name.substring(2),!0)}))},Gbe=t=>t.toString(16).toUpperCase().padStart(2,"0").substring(0,2),Ltt=t=>{let e=t.bucket,r=[];for(;e._parent!=null;)r.push(e),e=e._parent;return r.push(e),r.reverse()},Jbe=async(t,e,r,n,i)=>{if(n==null){let c=N8({hashFn:Utt});n={rootBucket:c,hamtDepth:1,lastBucket:c}}await qtt(t.Links,n.lastBucket,n.rootBucket);let o=await n.rootBucket._findNewBucketAndPos(e),s=Gbe(o.pos),a=Ltt(o);a.length>n.hamtDepth&&(n.lastBucket=a[n.hamtDepth],s=Gbe(n.lastBucket._posAtParent));let d=t.Links.find(c=>{if(c.Name==null)return!1;let l=c.Name.substring(0,2),p=c.Name.substring(2);return!(l!==s||p!==""&&p!==e)});if(d==null)return;if(d.Name!=null&&d.Name.substring(2)===e)return d.Hash;n.hamtDepth++;let u=await r.get(d.Hash,i);return t=ah(u),Jbe(t,e,r,n,i)},Zbe=Jbe;f();f();f();function Ktt(t){let[e,r]=t[Symbol.asyncIterator]!=null?[t[Symbol.asyncIterator](),Symbol.asyncIterator]:[t[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>e.next(),push:i=>{n.push(i)},next:()=>n.length>0?{done:!1,value:n.shift()}:e.next(),[r](){return this}}}var IR=Ktt;function Ftt(t){return t[Symbol.asyncIterator]!=null}function ztt(t,e){let r=0;if(Ftt(t))return async function*(){for await(let d of t)await e(d,r++)&&(yield d)}();let n=IR(t),{value:i,done:o}=n.next();if(o===!0)return function*(){}();let s=e(i,r++);if(typeof s.then=="function")return async function*(){await s&&(yield i);for await(let d of n)await e(d,r++)&&(yield d)}();let a=e;return function*(){s===!0&&(yield i);for(let d of n)a(d,r++)&&(yield d)}()}var Ybe=ztt;f();function Wtt(t){return t[Symbol.asyncIterator]!=null}function Htt(t,e){let r=0;if(Wtt(t))return async function*(){for await(let d of t)yield e(d,r++)}();let n=IR(t),{value:i,done:o}=n.next();if(o===!0)return function*(){}();let s=e(i,r++);if(typeof s.then=="function")return async function*(){yield await s;for await(let d of n)yield e(d,r++)}();let a=e;return function*(){yield s;for(let d of n)yield a(d,r++)}()}var m_=Htt;f();f();function Sp(){let t={};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t}var kR=globalThis.CustomEvent??Event;async function*fb(t,e={}){let r=e.concurrency??1/0;r<1&&(r=1/0);let n=e.ordered==null?!1:e.ordered,i=new EventTarget,o=[],s=Sp(),a=Sp(),d=!1,u,c=!1;i.addEventListener("task-complete",()=>{a.resolve()}),Promise.resolve().then(async()=>{try{for await(let g of t){if(o.length===r&&(s=Sp(),await s.promise),c)break;let v={done:!1};o.push(v),g().then(x=>{v.done=!0,v.ok=!0,v.value=x,i.dispatchEvent(new kR("task-complete"))},x=>{v.done=!0,v.err=x,i.dispatchEvent(new kR("task-complete"))})}d=!0,i.dispatchEvent(new kR("task-complete"))}catch(g){u=g,i.dispatchEvent(new kR("task-complete"))}});function l(){return n?o[0]?.done:!!o.find(g=>g.done)}function*p(){for(;o.length>0&&o[0].done;){let g=o[0];if(o.shift(),g.ok)yield g.value;else throw c=!0,s.resolve(),g.err;s.resolve()}}function*m(){for(;l();)for(let g=0;g0)||e-1&e)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return this.buffer[this.btm]===void 0}},y_=class{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new RR(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return e?.byteLength!=null?e.byteLength:1}push(e){if(e?.value!=null&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){let r=this.head;this.head=r.next=new RR(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next!=null){let r=this.tail.next;this.tail.next=null,this.tail=r,e=this.tail.shift()}return e?.value!=null&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}};var zF=class extends Error{type;code;constructor(e,r){super(e??"The operation was aborted"),this.type="aborted",this.code=r??"ABORT_ERR"}};function g_(t={}){return Vtt(r=>{let n=r.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},t)}function Vtt(t,e){e=e??{};let r=e.onEnd,n=new y_,i,o,s,a=Sp(),d=async()=>{try{return n.isEmpty()?s?{done:!0}:await new Promise((x,S)=>{o=P=>{o=null,n.push(P);try{x(t(n))}catch(A){S(A)}return i}}):t(n)}finally{n.isEmpty()&&queueMicrotask(()=>{a.resolve(),a=Sp()})}},u=x=>o!=null?o(x):(n.push(x),i),c=x=>(n=new y_,o!=null?o({error:x}):(n.push({error:x}),i)),l=x=>{if(s)return i;if(e?.objectMode!==!0&&x?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return u({done:!1,value:x})},p=x=>s?i:(s=!0,x!=null?c(x):u({done:!0})),m=()=>(n=new y_,p(),{done:!0}),g=x=>(p(x),{done:!0});if(i={[Symbol.asyncIterator](){return this},next:d,return:m,throw:g,push:l,end:p,get readableLength(){return n.size},onEmpty:async x=>{let S=x?.signal;if(S?.throwIfAborted(),n.isEmpty())return;let P,A;S!=null&&(P=new Promise(($,j)=>{A=()=>{j(new zF)},S.addEventListener("abort",A)}));try{await Promise.race([a.promise,P])}finally{A!=null&&S!=null&&S?.removeEventListener("abort",A)}}},r==null)return i;let v=i;return i={[Symbol.asyncIterator](){return this},next(){return v.next()},throw(x){return v.throw(x),r!=null&&(r(x),r=void 0),{done:!0}},return(){return v.return(),r!=null&&(r(),r=void 0),{done:!0}},push:l,end(x){return v.end(x),r!=null&&(r(x),r=void 0),i},get readableLength(){return v.readableLength},onEmpty:x=>v.onEmpty(x)},i}f();function Gtt(t){return t[Symbol.asyncIterator]!=null}function Jtt(...t){let e=[];for(let r of t)Gtt(r)||e.push(r);return e.length===t.length?function*(){for(let r of e)yield*r}():async function*(){let r=g_({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(t.map(async n=>{for await(let i of n)r.push(i)})),r.end()}catch(n){r.end(n)}}),yield*r}()}var Xbe=Jtt;function v_(t,...e){if(t==null)throw new Error("Empty pipeline");if(WF(t)){let n=t;t=()=>n.source}else if(ewe(t)||Qbe(t)){let n=t;t=()=>n}let r=[t,...e];if(r.length>1&&WF(r[r.length-1])&&(r[r.length-1]=r[r.length-1].sink),r.length>2)for(let n=1;n{let e;for(;t.length>0;)e=t.shift()(e);return e},Qbe=t=>t?.[Symbol.asyncIterator]!=null,ewe=t=>t?.[Symbol.iterator]!=null,WF=t=>t==null?!1:t.sink!=null&&t.source!=null,Ytt=t=>e=>{let r=t.sink(e);if(r?.then!=null){let n=g_({objectMode:!0});r.then(()=>{n.end()},s=>{n.end(s)});let i,o=t.source;if(Qbe(o))i=async function*(){yield*o,n.end()};else if(ewe(o))i=function*(){yield*o,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return Xbe(n,i())}return t.source};var Xtt=(t,e,r,n,i,o,s)=>{async function*a(d={}){let u=d.offset??0,c=d.length??e.Links.length,l=e.Links.slice(u,c);d.onProgress?.(new yi("unixfs:exporter:walk:directory",{cid:t})),yield*v_(l,p=>m_(p,m=>async()=>{let g=m.Name??"",v=`${n}/${g}`;return(await i(m.Hash,g,v,[],o+1,s,d)).entry}),p=>fb(p,{ordered:!0}),p=>Ybe(p,m=>m!=null))}return a},twe=Xtt;f();var pb=gt(Dc(),1);f();f();var VF=gt(nwe(),1);f();var $3=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},GF=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},iwe=t=>globalThis.DOMException===void 0?new GF(t):new DOMException(t),owe=t=>{let e=t.reason===void 0?iwe("This operation was aborted."):t.reason;return e instanceof Error?e:iwe(e)};function JF(t,e,r,n){let i,o=new Promise((s,a)=>{if(typeof e!="number"||Math.sign(e)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${e}\``);if(e===Number.POSITIVE_INFINITY){s(t);return}if(n={customTimers:{setTimeout,clearTimeout},...n},n.signal){let{signal:d}=n;d.aborted&&a(owe(d)),d.addEventListener("abort",()=>{a(owe(d))})}i=n.customTimers.setTimeout.call(void 0,()=>{if(typeof r=="function"){try{s(r())}catch(c){a(c)}return}let d=typeof r=="string"?r:`Promise timed out after ${e} milliseconds`,u=r instanceof Error?r:new $3(d);typeof t.cancel=="function"&&t.cancel(),a(u)},e),(async()=>{try{s(await t)}catch(d){a(d)}finally{n.customTimers.clearTimeout.call(void 0,i)}})()});return o.clear=()=>{clearTimeout(i),i=void 0},o}f();f();function ZF(t,e,r){let n=0,i=t.length;for(;i>0;){let o=Math.trunc(i/2),s=n+o;r(t[s],e)<=0?(n=++s,i-=o+1):i=o}return n}var hb=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Ap,YF=class{constructor(){Ap.set(this,[])}enqueue(e,r){r={priority:0,...r};let n={priority:r.priority,run:e};if(this.size&&hb(this,Ap,"f")[this.size-1].priority>=r.priority){hb(this,Ap,"f").push(n);return}let i=ZF(hb(this,Ap,"f"),n,(o,s)=>s.priority-o.priority);hb(this,Ap,"f").splice(i,0,n)}dequeue(){let e=hb(this,Ap,"f").shift();return e?.run}filter(e){return hb(this,Ap,"f").filter(r=>r.priority===e.priority).map(r=>r.run)}get size(){return hb(this,Ap,"f").length}};Ap=new WeakMap;var swe=YF;var di=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},ct=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Ni,N3,U3,Qy,jR,q3,BR,pl,j3,dd,MR,ud,L3,Xy,OR,awe,cwe,lwe,dwe,uwe,CR,XF,QF,NR,fwe,$R,UR=class extends Error{},ez=class extends VF.default{constructor(e){var r,n,i,o;if(super(),Ni.add(this),N3.set(this,void 0),U3.set(this,void 0),Qy.set(this,0),jR.set(this,void 0),q3.set(this,void 0),BR.set(this,0),pl.set(this,void 0),j3.set(this,void 0),dd.set(this,void 0),MR.set(this,void 0),ud.set(this,0),L3.set(this,void 0),Xy.set(this,void 0),OR.set(this,void 0),Object.defineProperty(this,"timeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:swe,...e},!(typeof e.intervalCap=="number"&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(n=(r=e.intervalCap)===null||r===void 0?void 0:r.toString())!==null&&n!==void 0?n:""}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${(o=(i=e.interval)===null||i===void 0?void 0:i.toString())!==null&&o!==void 0?o:""}\` (${typeof e.interval})`);di(this,N3,e.carryoverConcurrencyCount,"f"),di(this,U3,e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,"f"),di(this,jR,e.intervalCap,"f"),di(this,q3,e.interval,"f"),di(this,dd,new e.queueClass,"f"),di(this,MR,e.queueClass,"f"),this.concurrency=e.concurrency,this.timeout=e.timeout,di(this,OR,e.throwOnTimeout===!0,"f"),di(this,Xy,e.autoStart===!1,"f")}get concurrency(){return ct(this,L3,"f")}set concurrency(e){if(!(typeof e=="number"&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);di(this,L3,e,"f"),ct(this,Ni,"m",NR).call(this)}async add(e,r={}){return r={timeout:this.timeout,throwOnTimeout:ct(this,OR,"f"),...r},new Promise((n,i)=>{ct(this,dd,"f").enqueue(async()=>{var o,s,a;di(this,ud,(s=ct(this,ud,"f"),s++,s),"f"),di(this,Qy,(a=ct(this,Qy,"f"),a++,a),"f");try{if(!((o=r.signal)===null||o===void 0)&&o.aborted)throw new UR("The task was aborted.");let d=e({signal:r.signal});r.timeout&&(d=JF(Promise.resolve(d),r.timeout)),r.signal&&(d=Promise.race([d,ct(this,Ni,"m",fwe).call(this,r.signal)]));let u=await d;n(u),this.emit("completed",u)}catch(d){if(d instanceof $3&&!r.throwOnTimeout){n();return}i(d),this.emit("error",d)}finally{ct(this,Ni,"m",lwe).call(this)}},r),this.emit("add"),ct(this,Ni,"m",CR).call(this)})}async addAll(e,r){return Promise.all(e.map(async n=>this.add(n,r)))}start(){return ct(this,Xy,"f")?(di(this,Xy,!1,"f"),ct(this,Ni,"m",NR).call(this),this):this}pause(){di(this,Xy,!0,"f")}clear(){di(this,dd,new(ct(this,MR,"f")),"f")}async onEmpty(){ct(this,dd,"f").size!==0&&await ct(this,Ni,"m",$R).call(this,"empty")}async onSizeLessThan(e){ct(this,dd,"f").sizect(this,dd,"f").size{ct(this,Ni,"m",dwe).call(this)},r),"f"),!0}return!1},CR=function(){if(ct(this,dd,"f").size===0)return ct(this,pl,"f")&&clearInterval(ct(this,pl,"f")),di(this,pl,void 0,"f"),this.emit("empty"),ct(this,ud,"f")===0&&this.emit("idle"),!1;if(!ct(this,Xy,"f")){let e=!ct(this,Ni,"a",uwe);if(ct(this,Ni,"a",awe)&&ct(this,Ni,"a",cwe)){let r=ct(this,dd,"f").dequeue();return r?(this.emit("active"),r(),e&&ct(this,Ni,"m",XF).call(this),!0):!1}}return!1},XF=function(){ct(this,U3,"f")||ct(this,pl,"f")!==void 0||(di(this,pl,setInterval(()=>{ct(this,Ni,"m",QF).call(this)},ct(this,q3,"f")),"f"),di(this,BR,Date.now()+ct(this,q3,"f"),"f"))},QF=function(){ct(this,Qy,"f")===0&&ct(this,ud,"f")===0&&ct(this,pl,"f")&&(clearInterval(ct(this,pl,"f")),di(this,pl,void 0,"f")),di(this,Qy,ct(this,N3,"f")?ct(this,ud,"f"):0,"f"),ct(this,Ni,"m",NR).call(this)},NR=function(){for(;ct(this,Ni,"m",CR).call(this););},fwe=async function(e){return new Promise((r,n)=>{e.addEventListener("abort",()=>{n(new UR("The task was aborted."))},{once:!0})})},$R=async function(e,r){return new Promise(n=>{let i=()=>{r&&!r()||(this.off(e,i),n())};this.on(e,i)})};var hwe=ez;async function pwe(t,e,r,n,i,o,s){if(e instanceof Uint8Array){let u=lb(e,n,i,o);r.push(u);return}if(e.Data==null)throw(0,pb.default)(new Error("no data in PBNode"),"ERR_NOT_UNIXFS");let a;try{a=Ro.unmarshal(e.Data)}catch(u){throw(0,pb.default)(u,"ERR_NOT_UNIXFS")}if(a.data!=null){let u=a.data,c=lb(u,n,i,o);r.push(c),n+=BigInt(c.byteLength)}let d=[];if(e.Links.length!==a.blockSizes.length)throw(0,pb.default)(new Error("Inconsistent block sizes and dag links"),"ERR_NOT_UNIXFS");for(let u=0;u=l&&i=l&&o<=p||ip)&&d.push({link:c,blockStart:n}),n=p,n>o)break}await v_(d,u=>m_(u,c=>async()=>{let l=await t.get(c.link.Hash,s);return{...c,block:l}}),u=>fb(u,{ordered:!0}),async u=>{for await(let{link:c,block:l,blockStart:p}of u){let m;switch(c.Hash.code){case Ax:m=ah(l);break;case dm:m=l;break;default:r.end((0,pb.default)(new Error(`Unsupported codec: ${c.Hash.code}`),"ERR_NOT_UNIXFS"));return}let g=new hwe({concurrency:1});g.on("error",v=>{r.end(v)}),g.add(async()=>{s.onProgress?.(new yi("unixfs:exporter:walk:file",{cid:c.Hash})),await pwe(t,m,r,p,i,o,s)}),await g.onIdle()}}),n>=o&&r.end()}var trt=(t,e,r,n,i,o,s)=>{async function*a(d={}){let u=r.fileSize();if(u===void 0)throw new Error("File was a directory");let{start:c,end:l}=p_(u,d.offset,d.length);if(l===0n)return;let p=0n,m=l-c,g=g_();d.onProgress?.(new yi("unixfs:exporter:walk:file",{cid:t})),pwe(s,e,g,0n,c,l,d).catch(v=>{g.end(v)});for await(let v of g)if(v!=null){if(p+=BigInt(v.byteLength),p>m)throw g.end(),(0,pb.default)(new Error("Read too many bytes - the file size reported by the UnixFS data in the root node may be incorrect"),"ERR_OVER_READ");p===m&&g.end(),d.onProgress?.(new yi("unixfs:exporter:progress:unixfs:file",{bytesRead:p,totalBytes:m,fileSize:u})),yield v}if(p{function a(d={}){return d.onProgress?.(new yi("unixfs:exporter:walk:hamt-sharded-directory",{cid:t})),mwe(e,n,i,o,s,d)}return a};async function*mwe(t,e,r,n,i,o){let s=t.Links,a=v_(s,d=>m_(d,u=>async()=>{let c=u.Name!=null?u.Name.substring(2):null;if(c!=null&&c!==""){let l=await r(u.Hash,c,`${e}/${c}`,[],n+1,i,o);return{entries:l.entry==null?[]:[l.entry]}}else{let l=await i.get(u.Hash,o);return t=ah(l),o.onProgress?.(new yi("unixfs:exporter:walk:hamt-sharded-directory",{cid:u.Hash})),{entries:mwe(t,e,r,n,i,o)}}}),d=>fb(d,{ordered:!0}));for await(let{entries:d}of a)yield*d}var ywe=rrt;var nrt=(t,e)=>t.Links.find(n=>n.Name===e)?.Hash,irt={raw:tz,file:tz,directory:twe,"hamt-sharded-directory":ywe,metadata:(t,e,r,n,i,o,s)=>()=>[],symlink:(t,e,r,n,i,o,s)=>()=>[]},ort=async(t,e,r,n,i,o,s,a)=>{let d=await s.get(t,a),u=ah(d),c,l;if(e==null&&(e=t.toString()),u.Data==null)throw(0,K3.default)(new Error("no data in PBNode"),"ERR_NOT_UNIXFS");try{c=Ro.unmarshal(u.Data)}catch(m){throw(0,K3.default)(m,"ERR_NOT_UNIXFS")}if(r==null&&(r=e),n.length>0){let m;if(c?.type==="hamt-sharded-directory"?m=await Zbe(u,n[0],s):m=nrt(u,n[0]),m==null)throw(0,K3.default)(new Error("file does not exist"),"ERR_NOT_FOUND");let g=n.shift(),v=`${r}/${g}`;l={cid:m,toResolve:n,name:g??"",path:v}}let p=irt[c.type](t,u,c,r,i,o,s);if(p==null)throw(0,K3.default)(new Error("could not find content exporter"),"ERR_NOT_FOUND");return c.isDirectory()?{entry:{type:"directory",name:e,path:r,cid:t,content:p,unixfs:c,depth:o,node:u,size:c.fileSize()},next:l}:{entry:{type:"file",name:e,path:r,cid:t,content:p,unixfs:c,depth:o,node:u,size:c.fileSize()},next:l}},gwe=ort;var srt={[Ax]:gwe,[dm]:Vbe,[$be]:Fbe,[Lbe.code]:Wbe},bwe=async(t,e,r,n,i,o,s)=>{let a=srt[t.code];if(a==null)throw(0,vwe.default)(new Error(`No resolver for code ${t.code}`),"ERR_NO_RESOLVER");return a(t,e,r,n,bwe,i,o,s)},wwe=bwe;var art=(t="")=>(t.trim().match(/([^\\^/]|\\\/)+/g)??[]).filter(Boolean),crt=t=>{if(t instanceof Uint8Array)return{cid:jr.decode(t),toResolve:[]};let e=jr.asCID(t);if(e!=null)return{cid:e,toResolve:[]};if(typeof t=="string"){t.indexOf("/ipfs/")===0&&(t=t.substring(6));let r=art(t);return{cid:jr.parse(r[0]),toResolve:r.slice(1)}}throw(0,qR.default)(new Error(`Unknown path type ${t}`),"ERR_BAD_PATH")};async function*drt(t,e,r={}){let{cid:n,toResolve:i}=crt(t),o=n.toString(),s=o,a=i.length;for(;;){let d=await wwe(n,o,s,i,a,e,r);if(d.entry==null&&d.next==null)throw(0,qR.default)(new Error(`Could not resolve ${t}`),"ERR_NOT_FOUND");if(d.entry!=null&&(yield d.entry),d.next==null)return;i=d.next.toResolve,n=d.next.cid,o=d.next.name,s=d.next.path}}async function _we(t,e,r={}){let n=await Dve(drt(t,e,r));if(n==null)throw(0,qR.default)(new Error(`Could not resolve ${t}`),"ERR_NOT_FOUND");return n}var xwe=gt(M1(),1),e0=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},urt=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,d){s=t[o](s),i(a,d,s.done,s.value)})}}function i(o,s,a,d){Promise.resolve(d).then(function(u){o({value:u,done:a})},s)}},b_=class{constructor(e={}){this.config=Object.assign({blockstoreLocation:"DATASTORE",createLevelDatabase:id},e),this.blockstore=new a_({location:this.config.blockstoreLocation,createLevelDatabase:this.config.createLevelDatabase})}open(){return e0(this,void 0,void 0,function*(){yield this.blockstore.open()})}close(){return e0(this,void 0,void 0,function*(){yield this.blockstore.close()})}put(e,r,n,i){var o,s,a,d,u,c;return e0(this,void 0,void 0,function*(){let l=yield this.getBlockstoreForStoringData(e,r,n),p=$x([{content:i}],l,{cidVersion:1}),m;try{for(var g=!0,v=urt(p),x;x=yield v.next(),o=x.done,!o;g=!0)d=x.value,g=!1,m=d}catch(S){s={error:S}}finally{try{!g&&!o&&(a=v.return)&&(yield a.call(v))}finally{if(s)throw s.error}}return{dataSize:Number((c=(u=m.unixfs)===null||u===void 0?void 0:u.fileSize())!==null&&c!==void 0?c:m.size)}})}get(e,r,n){return e0(this,void 0,void 0,function*(){let i=yield this.getBlockstoreForStoringData(e,r,n);if(!(yield i.has(n)))return;let s=yield _we(n,i),a=s.content(),d=new xwe.Readable({read(){return e0(this,void 0,void 0,function*(){let c=yield a.next();c.done?this.push(null):this.push(c.value)})}}),u=s.size;return(s.type==="file"||s.type==="directory")&&(u=s.unixfs.fileSize()),{dataSize:Number(u),dataStream:d}})}delete(e,r,n){return e0(this,void 0,void 0,function*(){yield(yield this.getBlockstoreForStoringData(e,r,n)).clear()})}clear(){return e0(this,void 0,void 0,function*(){yield this.blockstore.clear()})}getBlockstoreForStoringData(e,r,n){return e0(this,void 0,void 0,function*(){let i="data";return yield(yield(yield(yield this.blockstore.partition(i)).partition(e)).partition(r)).partition(n)})}};f();f();var wo=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},F3=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,d){s=t[o](s),i(a,d,s.done,s.value)})}}function i(o,s,a,d){Promise.resolve(d).then(function(u){o({value:u,done:a})},s)}},mb=function(t){return this instanceof mb?(this.v=t,this):new mb(t)},lrt=function(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),i,o=[];return i={},s("next"),s("throw"),s("return"),i[Symbol.asyncIterator]=function(){return this},i;function s(p){n[p]&&(i[p]=function(m){return new Promise(function(g,v){o.push([p,m,g,v])>1||a(p,m)})})}function a(p,m){try{d(n[p](m))}catch(g){l(o[0][3],g)}}function d(p){p.value instanceof mb?Promise.resolve(p.value.v).then(u,c):l(o[0][2],p)}function u(p){a("next",p)}function c(p){a("throw",p)}function l(p,m){p(m),o.shift(),o.length&&a(o[0][0],o[0][1])}},Ewe="index",Tp=class t{constructor(e){this.config=Object.assign({createLevelDatabase:id},e),this.db=new Jy({location:this.config.location,createLevelDatabase:this.config.createLevelDatabase,keyEncoding:"utf8"})}open(){return wo(this,void 0,void 0,function*(){yield this.db.open()})}close(){return wo(this,void 0,void 0,function*(){yield this.db.close()})}clear(){return wo(this,void 0,void 0,function*(){yield this.db.clear()})}put(e,r,n,i){return wo(this,void 0,void 0,function*(){if(u6(n))throw new de(se.IndexMissingIndexableProperty,"Index must include at least one valid indexable property");let o={messageCid:r,indexes:n},s=[];for(let c in n){let l=n[c];if(Array.isArray(l))for(let p of l){let m=this.createPutIndexedItemOperation(e,o,c,p);s.push(m)}else{let p=this.createPutIndexedItemOperation(e,o,c,l);s.push(p)}}let a=this.createOperationForIndexesLookupPartition(e,{type:"put",key:r,value:JSON.stringify(n)});s.push(a);let d=yield Promise.all(s);yield(yield this.db.partition(e)).batch(d,i)})}delete(e,r,n){return wo(this,void 0,void 0,function*(){let i=[],o=yield this.getIndexes(e,r);if(o===void 0)return;let s=this.createOperationForIndexesLookupPartition(e,{type:"del",key:r});i.push(s);for(let u in o){let c=o[u];if(Array.isArray(c))for(let l of c){let p=this.createDeleteIndexedItemOperation(e,r,u,l);i.push(p)}else{let l=this.createDeleteIndexedItemOperation(e,r,u,c);i.push(l)}}let a=yield Promise.all(i);yield(yield this.db.partition(e)).batch(a,n)})}createPutIndexedItemOperation(e,r,n,i){return wo(this,void 0,void 0,function*(){let{messageCid:o}=r,s=t.keySegmentJoin(t.encodeValue(i),o);return this.createOperationForIndexPartition(e,n,{type:"put",key:s,value:JSON.stringify(r)})})}createDeleteIndexedItemOperation(e,r,n,i){return wo(this,void 0,void 0,function*(){let o=t.keySegmentJoin(t.encodeValue(i),r);return this.createOperationForIndexPartition(e,n,{type:"del",key:o})})}createOperationForIndexPartition(e,r,n){return wo(this,void 0,void 0,function*(){let i=yield this.db.partition(e),o=t.getIndexPartitionName(r);return i.createPartitionOperation(o,n)})}createOperationForIndexesLookupPartition(e,r){return wo(this,void 0,void 0,function*(){return(yield this.db.partition(e)).createPartitionOperation(Ewe,r)})}static getIndexPartitionName(e){return`__${e}__`}getIndexPartition(e,r){return wo(this,void 0,void 0,function*(){let n=t.getIndexPartitionName(r);return(yield this.db.partition(e)).partition(n)})}getIndexesLookupPartition(e){return wo(this,void 0,void 0,function*(){return(yield this.db.partition(e)).partition(Ewe)})}query(e,r,n,i){return wo(this,void 0,void 0,function*(){return t.shouldQueryWithInMemoryPaging(r,n)?this.queryWithInMemoryPaging(e,r,n,i):this.queryWithIteratorPaging(e,r,n,i)})}queryWithIteratorPaging(e,r,n,i){var o,s,a,d;return wo(this,void 0,void 0,function*(){let{cursor:u,limit:c}=n,l=u?this.createStartingKeyFromCursor(u):"",p=[];try{for(var m=!0,g=F3(this.getIndexIterator(e,l,n,i)),v;v=yield g.next(),o=v.done,!o;m=!0){d=v.value,m=!1;let x=d;if(c!==void 0&&c===p.length)break;let{indexes:S}=x;Jn.matchAnyFilter(S,r)&&p.push(x)}}catch(x){s={error:x}}finally{try{!m&&!o&&(a=g.return)&&(yield a.call(g))}finally{if(s)throw s.error}}return p})}getIndexIterator(e,r,n,i){return lrt(this,arguments,function*(){var s,a,d,u;let{sortProperty:c,sortDirection:l=As.Ascending,cursor:p}=n,m={gt:r};l===As.Descending&&(m.reverse=!0,p!==void 0&&(m.lt=r,delete m.gt));let g=yield mb(this.getIndexPartition(e,c));try{for(var v=!0,x=F3(g.iterator(m,i)),S;S=yield mb(x.next()),s=S.done,!s;v=!0){u=S.value,v=!1;let[P,A]=u,{indexes:$,messageCid:j}=JSON.parse(A);yield yield mb({indexes:$,messageCid:j})}}catch(P){a={error:P}}finally{try{!v&&!s&&(d=x.return)&&(yield mb(d.call(x)))}finally{if(a)throw a.error}}})}createStartingKeyFromCursor(e){let{messageCid:r,value:n}=e;return t.keySegmentJoin(t.encodeValue(n),r)}static createCursorFromLastArrayItem(e,r){if(e.length>0)return this.createCursorFromItem(e.at(-1),r)}static createCursorFromItem(e,r){let{messageCid:n,indexes:i}=e,o=i[r];if(o===void 0)throw new de(se.IndexInvalidCursorSortProperty,`the sort property '${r}' is not defined within the given item.`);if(typeof o=="boolean"||Array.isArray(o))throw new de(se.IndexInvalidCursorValueType,`only string or number values are supported for cursors, a(n) ${typeof o} was given.`);return{messageCid:n,value:o}}queryWithInMemoryPaging(e,r,n,i){return wo(this,void 0,void 0,function*(){let{sortProperty:o,sortDirection:s=As.Ascending,cursor:a,limit:d}=n,u=a?this.createStartingKeyFromCursor(a):void 0,c=new Map;r.length===0&&(r=[{}]);try{yield Promise.all(r.map(g=>this.executeSingleFilterQuery(e,g,o,c,i)))}catch(g){if(g.code===se.IndexInvalidSortPropertyInMemory)return[]}let l=[...c.values()].sort((g,v)=>this.sortItems(g,v,o,s)),p=u!==void 0?this.findCursorStartingIndex(l,s,o,u):0;if(p<0)return[];let m=d!==void 0?p+d:void 0;return l.slice(p,m)})}executeSingleFilterQuery(e,r,n,i,o){return wo(this,void 0,void 0,function*(){let s=[];if(u6(r)){let d=this.getAllItems(e,n);s.push(d)}let a=WT.reduceFilter(r);for(let d in a){let u=a[d];if(Jn.isEqualFilter(u)){let c=this.filterExactMatches(e,d,u,o);s.push(c)}else if(Jn.isOneOfFilter(u))for(let c of new Set(u)){let l=this.filterExactMatches(e,d,c,o);s.push(l)}else if(Jn.isRangeFilter(u)){let c=this.filterRangeMatches(e,d,u,o);s.push(c)}}for(let d of s){let u=yield d;for(let c of u)if(!(i.has(c.messageCid)||!Jn.matchFilter(c.indexes,r))){if(c.indexes[n]===void 0)throw new de(se.IndexInvalidSortPropertyInMemory,`invalid sort property ${n}`);i.set(c.messageCid,c)}}})}getAllItems(e,r){var n,i,o,s;return wo(this,void 0,void 0,function*(){let a=yield this.getIndexPartition(e,r),d=[];try{for(var u=!0,c=F3(a.iterator()),l;l=yield c.next(),n=l.done,!n;u=!0){s=l.value,u=!1;let[p,m]=s;d.push(JSON.parse(m))}}catch(p){i={error:p}}finally{try{!u&&!n&&(o=c.return)&&(yield o.call(c))}finally{if(i)throw i.error}}return d})}filterExactMatches(e,r,n,i){var o,s,a,d;return wo(this,void 0,void 0,function*(){let u=t.keySegmentJoin(t.encodeValue(n)),c={gt:u},l=yield this.getIndexPartition(e,r),p=[];try{for(var m=!0,g=F3(l.iterator(c,i)),v;v=yield g.next(),o=v.done,!o;m=!0){d=v.value,m=!1;let[x,S]=d;if(!x.startsWith(u))break;p.push(JSON.parse(S))}}catch(x){s={error:x}}finally{try{!m&&!o&&(a=g.return)&&(yield a.call(g))}finally{if(s)throw s.error}}return p})}filterRangeMatches(e,r,n,i){var o,s,a,d;return wo(this,void 0,void 0,function*(){let u={};for(let v in n){let x=v;u[x]=t.encodeValue(n[x])}u.gt===void 0&&u.gte===void 0&&(u.reverse=!0);let c=[],l=yield this.getIndexPartition(e,r);try{for(var p=!0,m=F3(l.iterator(u,i)),g;g=yield m.next(),o=g.done,!o;p=!0){d=g.value,p=!1;let[v,x]=d;"gt"in n&&this.extractIndexValueFromKey(v)===t.encodeValue(n.gt)||c.push(JSON.parse(x))}}catch(v){s={error:v}}finally{try{!p&&!o&&(a=m.return)&&(yield a.call(m))}finally{if(s)throw s.error}}if("lte"in n)for(let v of yield this.filterExactMatches(e,r,n.lte,i))c.push(v);return c})}sortItems(e,r,n,i){let o=e.indexes[n],s=r.indexes[n],a=t.encodeValue(o)+e.messageCid,d=t.encodeValue(s)+r.messageCid;return i===As.Ascending?d6(a,d):d6(d,a)}findCursorStartingIndex(e,r,n,i){let o=s=>{let{messageCid:a,indexes:d}=s,u=d[n],c=t.keySegmentJoin(t.encodeValue(u),a);return r===As.Ascending?c>i:c{let n=new Uint8Array(1);return r.getRandomValues(n),n[0]/255};if(typeof r?.randomBytes=="function")return()=>r.randomBytes(1).readUInt8()/255;throw new ml({info:{code:"PRNG_DETECT",...yb}},"Failed to find a reliable PRNG")}function mrt(){return vrt()?self:typeof window<"u"?window:typeof globalThis<"u"||typeof globalThis<"u"?globalThis:null}function yrt(t,e){let r="";for(;t>0;t--)r=brt(e)+r;return r}function Pwe(t,e){if(isNaN(t))throw new ml({info:{code:"ENC_TIME_NAN",...yb}},`Time must be a number: ${t}`);if(t>Awe)throw new ml({info:{code:"ENC_TIME_SIZE_EXCEED",...yb}},`Cannot encode a time larger than ${Awe}: ${t}`);if(t<0)throw new ml({info:{code:"ENC_TIME_NEG",...yb}},`Time must be positive: ${t}`);if(Number.isInteger(t)===!1)throw new ml({info:{code:"ENC_TIME_TYPE",...yb}},`Time must be an integer: ${t}`);let r,n="";for(let i=e;i>0;i--)r=t%__,n=W3.charAt(r)+n,t=(t-r)/__;return n}function grt(t){let e,r=t.length,n,i,o=t,s=__-1;for(;!e&&r-->=0;){if(n=o[r],i=W3.indexOf(n),i===-1)throw new ml({info:{code:"B32_INC_ENC",...yb}},"Incorrectly encoded string");if(i===s){o=Iwe(o,r,W3[0]);continue}e=Iwe(o,r,W3[i+1])}if(typeof e=="string")return e;throw new ml({info:{code:"B32_INC_INVALID",...yb}},"Failed incrementing string")}function vrt(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function LR(t){let e=t||prt(),r=0,n;return function(o){let s=isNaN(o)?Date.now():o;if(s<=r){let d=n=grt(n);return Pwe(r,Twe)+d}r=s;let a=n=yrt(hrt,e);return Pwe(s,Twe)+a}}function brt(t){let e=Math.floor(t()*__);return e===__&&(e=__-1),W3.charAt(e)}function Iwe(t,e,r){return e>t.length-1?t:t.substr(0,e)+r+t.substr(e+1)}var gb=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},x_=class{constructor(e){this.index=new Tp(Object.assign({location:"EVENTLOG",createLevelDatabase:id},e)),this.ulidFactory=LR()}open(){return gb(this,void 0,void 0,function*(){return this.index.open()})}close(){return gb(this,void 0,void 0,function*(){return this.index.close()})}clear(){return gb(this,void 0,void 0,function*(){return this.index.clear()})}append(e,r,n){return gb(this,void 0,void 0,function*(){let i=this.ulidFactory();yield this.index.put(e,r,Object.assign(Object.assign({},n),{watermark:i}))})}queryEvents(e,r,n){return gb(this,void 0,void 0,function*(){let i=yield this.index.query(e,r,{sortProperty:"watermark",cursor:n});return{events:i.map(({messageCid:o})=>o),cursor:Tp.createCursorFromLastArrayItem(i,"watermark")}})}getEvents(e,r){return gb(this,void 0,void 0,function*(){return this.queryEvents(e,[],r)})}deleteEventsByCid(e,r){return gb(this,void 0,void 0,function*(){let n=[];for(let i of r)n.push(this.index.delete(e,i));yield Promise.all(n)})}};f();f();function KR({enumerable:t=!0,configurable:e=!1}={}){return{enumerable:t,configurable:e,writable:!1}}function*wrt(t,e){if(e!=null&&typeof e=="object")if(Array.isArray(e))for(let[r,n]of e.entries()){let i=[...t,r],o=jr.asCID(n);o?yield[i.join("/"),o]:typeof n=="object"&&(yield*rz(n,i))}else{let r=jr.asCID(e);r?yield[t.join("/"),r]:yield*rz(e,t)}}function*rz(t,e){if(t==null||t instanceof Uint8Array)return;let r=jr.asCID(t);r&&(yield[e.join("/"),r]);for(let[n,i]of Object.entries(t)){let o=[...e,n];yield*wrt(o,i)}}function*_rt(t,e){if(Array.isArray(e))for(let[r,n]of e.entries()){let i=[...t,r];yield i.join("/"),typeof n=="object"&&!jr.asCID(n)&&(yield*nz(n,i))}else yield*nz(e,t)}function*nz(t,e){if(!(t==null||typeof t!="object"))for(let[r,n]of Object.entries(t)){let i=[...e,r];yield i.join("/"),n!=null&&!(n instanceof Uint8Array)&&typeof n=="object"&&!jr.asCID(n)&&(yield*_rt(i,n))}}function xrt(t,e){let r=t;for(let[n,i]of e.entries()){if(r=r[i],r==null)throw new Error(`Object has no property at ${e.slice(0,n+1).map(s=>`[${JSON.stringify(s)}]`).join("")}`);let o=jr.asCID(r);if(o)return{value:o,remaining:e.slice(n+1).join("/")}}return{value:r}}var FR=class{constructor({cid:e,bytes:r,value:n}){if(!e||!r||typeof n>"u")throw new Error("Missing required argument");this.cid=e,this.bytes=r,this.value=n,this.asBlock=this,Object.defineProperties(this,{cid:KR(),bytes:KR(),value:KR(),asBlock:KR()})}links(){return rz(this.value,[])}tree(){return nz(this.value,[])}get(e="/"){return xrt(this.value,e.split("/").filter(Boolean))}};async function kwe({value:t,codec:e,hasher:r}){if(typeof t>"u")throw new Error('Missing required argument "value"');if(!e||!r)throw new Error("Missing required argument: codec or hasher");let n=e.encode(t),i=await r.digest(n),o=jr.create(1,e.code,i);return new FR({value:t,bytes:n,cid:o})}async function Rwe({bytes:t,codec:e,hasher:r}){if(!t)throw new Error('Missing required argument "bytes"');if(!e||!r)throw new Error("Missing required argument: codec or hasher");let n=e.decode(t),i=await r.digest(t),o=jr.create(1,e.code,i);return new FR({value:n,bytes:t,cid:o})}var vb=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},E_=class t{constructor(e={}){this.config=Object.assign({blockstoreLocation:"MESSAGESTORE",indexLocation:"INDEX",createLevelDatabase:id},e),this.blockstore=new a_({location:this.config.blockstoreLocation,createLevelDatabase:this.config.createLevelDatabase}),this.index=new Tp({location:this.config.indexLocation,createLevelDatabase:this.config.createLevelDatabase})}open(){return vb(this,void 0,void 0,function*(){yield this.blockstore.open(),yield this.index.open()})}close(){return vb(this,void 0,void 0,function*(){yield this.blockstore.close(),yield this.index.close()})}get(e,r,n){var i;return vb(this,void 0,void 0,function*(){(i=n?.signal)===null||i===void 0||i.throwIfAborted();let o=yield Xi(this.blockstore.partition(e),n?.signal),s=jr.parse(r),a=yield o.get(s,n);return a?(yield Xi(Rwe({bytes:a,codec:V0,hasher:Ns}),n?.signal)).value:void 0})}query(e,r,n,i,o){var s;return vb(this,void 0,void 0,function*(){(s=o?.signal)===null||s===void 0||s.throwIfAborted();let a=t.buildQueryOptions(n,i),d=yield this.index.query(e,r,a,o),u;i?.limit!==void 0&&i.limit0&&(n=n+1),{sortDirection:d,sortProperty:u,limit:n,cursor:i}}delete(e,r,n){var i;return vb(this,void 0,void 0,function*(){(i=n?.signal)===null||i===void 0||i.throwIfAborted();let o=yield Xi(this.blockstore.partition(e),n?.signal),s=jr.parse(r);yield o.delete(s,n),yield this.index.delete(e,r,n)})}put(e,r,n,i){var o;return vb(this,void 0,void 0,function*(){(o=i?.signal)===null||o===void 0||o.throwIfAborted();let s=yield Xi(this.blockstore.partition(e),i?.signal),a=yield Xi(kwe({value:r,codec:V0,hasher:Ns}),i?.signal),d=fn.parseCid(yield _e.getCid(r));yield s.put(d,a.bytes,i);let u=d.toString();yield this.index.put(e,u,n,i)})}clear(){return vb(this,void 0,void 0,function*(){yield this.blockstore.clear(),yield this.index.clear()})}};f();var t0=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Srt=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,d){s=t[o](s),i(a,d,s.done,s.value)})}}function i(o,s,a,d){Promise.resolve(d).then(function(u){o({value:u,done:a})},s)}},bb=class t{constructor(e){this.config=Object.assign({location:"RESUMABLE-TASK-STORE",createLevelDatabase:id},e),this.db=new Jy({location:this.config.location,createLevelDatabase:this.config.createLevelDatabase,keyEncoding:"utf8"})}open(){return t0(this,void 0,void 0,function*(){yield this.db.open()})}close(){return t0(this,void 0,void 0,function*(){yield this.db.close()})}register(e,r){return t0(this,void 0,void 0,function*(){let n=yield fn.computeCid(e),i={id:n,timeout:Date.now()+r*1e3,retryCount:0,task:e};return yield this.db.put(n,JSON.stringify(i)),i})}grab(e){var r,n,i,o;return t0(this,void 0,void 0,function*(){let s=[];try{for(var a=!0,d=Srt(this.db.iterator()),u;u=yield d.next(),r=u.done,!r;a=!0){o=u.value,a=!1;let[c,l]=o,p=JSON.parse(l);if(Date.now()>=p.timeout&&(p.timeout=Date.now()+t.taskTimeoutInSeconds*1e3,p.retryCount++,yield this.db.put(p.id,JSON.stringify(p)),s.push(p)),s.length>=e)break}}catch(c){n={error:c}}finally{try{!a&&!r&&(i=d.return)&&(yield i.call(d))}finally{if(n)throw n.error}}return s})}read(e){return t0(this,void 0,void 0,function*(){let r=yield this.db.get(e);if(r)return JSON.parse(r)})}extend(e,r){return t0(this,void 0,void 0,function*(){let n=yield this.db.get(e);if(n){let i=JSON.parse(n);i.timeout=Date.now()+r*1e3,yield this.db.put(i.id,JSON.stringify(i))}})}delete(e){return t0(this,void 0,void 0,function*(){return this.db.delete(e)})}clear(){return t0(this,void 0,void 0,function*(){yield this.db.clear()})}};bb.taskTimeoutInSeconds=60;f();var Art=gt(Sa(),1);f();f();var Trt=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},H3=class t{static pollUntilSuccessOrTimeout(e,r=t.pollRetrySleep,n=t.pollTimeout){return Trt(this,void 0,void 0,function*(){let i=Date.now();for(;;)try{return yield e()}catch{if(Date.now()-i>=n)throw new Error("Operation timed out");yield pr.sleep(r)}})}};H3.pollRetrySleep=20;H3.pollTimeout=2e3;var Ie;(function(t){t.MessagesQuery="MessagesQuery",t.MessagesRead="MessagesRead",t.MessagesSubscribe="MessagesSubscribe",t.ProtocolsConfigure="ProtocolsConfigure",t.ProtocolsQuery="ProtocolsQuery",t.RecordsDelete="RecordsDelete",t.RecordsQuery="RecordsQuery",t.RecordsRead="RecordsRead",t.RecordsSubscribe="RecordsSubscribe",t.RecordsWrite="RecordsWrite"})(Ie||(Ie={}));var iz={[Ie.MessagesQuery]:sy,[Ie.MessagesRead]:ay,[Ie.MessagesSubscribe]:cy,[Ie.ProtocolsConfigure]:vy,[Ie.ProtocolsQuery]:by,[Ie.RecordsDelete]:gf,[Ie.RecordsQuery]:ny,[Ie.RecordsRead]:Ev,[Ie.RecordsSubscribe]:wy,[Ie.RecordsWrite]:Ur};f();f();f();var wb;(function(t){t.authentication="authentication",t.assertionMethod="assertionMethod",t.keyAgreement="keyAgreement",t.capabilityInvocation="capabilityInvocation",t.capabilityDelegation="capabilityDelegation"})(wb||(wb={}));f();var ui={"@context":"https://w3id.org/did-resolution/v1",didResolutionMetadata:{},didDocument:null,didDocumentMetadata:{}};f();var sr=class t{constructor({method:e,id:r,path:n,query:i,fragment:o,params:s}){this.uri=`did:${e}:${r}`,this.method=e,this.id=r,this.path=n,this.query=i,this.fragment=o,this.params=s}static parse(e){if(!e)return null;let r=t.DID_URI_PATTERN.exec(e);if(!r||!r.groups)return null;let{method:n,id:i,path:o,query:s,fragment:a}=r.groups,d={uri:`did:${n}:${i}`,method:n,id:i};if(o&&(d.path=o),s&&(d.query=s.slice(1)),a&&(d.fragment=a.slice(1)),s){let u={},c=s.slice(1).split("&");for(let l of c){let[p,m]=l.split("=");u[p]=m}d.params=u}return d}};sr.METHOD_PATTERN="([a-z0-9]+)";sr.PCT_ENCODED_PATTERN="(?:%[0-9a-fA-F]{2})";sr.ID_CHAR_PATTERN=`(?:[a-zA-Z0-9._-]|${sr.PCT_ENCODED_PATTERN})`;sr.METHOD_ID_PATTERN=`((?:${sr.ID_CHAR_PATTERN}*:)*(${sr.ID_CHAR_PATTERN}+))`;sr.PATH_PATTERN="(/[^#?]*)?";sr.QUERY_PATTERN="([?][^#]*)?";sr.FRAGMENT_PATTERN="(#.*)?";sr.DID_URI_PATTERN=new RegExp(`^did:(?${sr.METHOD_PATTERN}):(?${sr.METHOD_ID_PATTERN})(?${sr.PATH_PATTERN})(?${sr.QUERY_PATTERN})(?${sr.FRAGMENT_PATTERN})$`);f();var dt=class t 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,t)}},rt;(function(t){t.InvalidDid="invalidDid",t.MethodNotSupported="methodNotSupported",t.InternalError="internalError",t.InvalidDidDocument="invalidDidDocument",t.InvalidDidDocumentLength="invalidDidDocumentLength",t.InvalidDidUrl="invalidDidUrl",t.InvalidPreviousDidProof="invalidPreviousDidProof",t.InvalidPublicKey="invalidPublicKey",t.InvalidPublicKeyLength="invalidPublicKeyLength",t.InvalidPublicKeyType="invalidPublicKeyType",t.InvalidSignature="invalidSignature",t.NotFound="notFound",t.RepresentationNotSupported="representationNotSupported",t.UnsupportedPublicKeyType="unsupportedPublicKeyType"})(rt||(rt={}));f();f();f();f();f();var jf=gt(_I(),1);f();f();function Dwe(t){return t.byteOffset!==0||t.byteLength!==t.buffer.byteLength}function Bwe(t){return typeof t!="object"||t===null?!1:typeof t[Symbol.asyncIterator]=="function"}function r0(t){let r=Object.prototype.toString.call(t).match(/\s([a-zA-Z0-9]+)/),[n,i]=r;return i}var V3=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Mwe=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,d){s=t[o](s),i(a,d,s.done,s.value)})}}function i(o,s,a,d){Promise.resolve(d).then(function(u){o({value:u,done:a})},s)}},zR=new TextEncoder,_b=new TextDecoder,ae=class t{constructor(e,r){this.data=e,this.format=r}static arrayBuffer(e){return new t(e,"ArrayBuffer")}static asyncIterable(e){if(!Bwe(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 Ki.baseDecode(this.data).buffer;case"Base64Url":return Pi.baseDecode(this.data).buffer;case"BufferSource":{if(r0(this.data)==="ArrayBuffer")return this.data;if(ArrayBuffer.isView(this.data))return Dwe(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 V3(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 M0.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 Ki.baseEncode(e)}case"Multibase":return this.data.substring(1);case"Uint8Array":return Ki.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 Pi.baseEncode(e)}case"BufferSource":{let e=this.toUint8Array();return Pi.baseEncode(e)}case"Object":{let e=JSON.stringify(this.data),r=zR.encode(e);return Pi.baseEncode(r)}case"String":{let e=zR.encode(this.data);return Pi.baseEncode(e)}case"Uint8Array":return Pi.baseEncode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Base64Url is not supported.`)}}toBlobAsync(){return V3(this,void 0,void 0,function*(){var e,r,n,i;switch(this.format){case"AsyncIterable":{let d=[];try{for(var o=!0,s=Mwe(this.data),a;a=yield s.next(),e=a.done,!e;o=!0){i=a.value,o=!1;let c=i;d.push(c)}}catch(c){r={error:c}}finally{try{!o&&!e&&(n=s.return)&&(yield n.call(s))}finally{if(r)throw r.error}}return new Blob(d)}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;n0?!1:Object.keys(t).length===0}function S_(t){Object.keys(t).forEach(e=>{t[e]===void 0?delete t[e]:typeof t[e]=="object"&&S_(t[e])})}f();var Owe=gt(WS(),1),ou=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},G3=class{constructor({db:e,location:r="DATASTORE"}={}){this.store=e??new Owe.Level(r)}clear(){return ou(this,void 0,void 0,function*(){yield this.store.clear()})}close(){return ou(this,void 0,void 0,function*(){yield this.store.close()})}delete(e){return ou(this,void 0,void 0,function*(){yield this.store.del(e)})}get(e){return ou(this,void 0,void 0,function*(){try{return yield this.store.get(e)}catch(r){if(r.notFound)return;throw r}})}set(e,r){return ou(this,void 0,void 0,function*(){yield this.store.put(e,r)})}},xb=class{constructor(){this.store=new Map}clear(){return ou(this,void 0,void 0,function*(){this.store.clear()})}close(){return ou(this,void 0,void 0,function*(){})}delete(e){return ou(this,void 0,void 0,function*(){return this.store.delete(e)})}get(e){return ou(this,void 0,void 0,function*(){return this.store.get(e)})}has(e){return ou(this,void 0,void 0,function*(){return this.store.has(e)})}list(){return ou(this,void 0,void 0,function*(){return Array.from(this.store.values())})}set(e,r){return ou(this,void 0,void 0,function*(){this.store.set(e,r)})}};f();var J3=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Z3=function(t){return this instanceof Z3?(this.v=t,this):new Z3(t)},Irt=function(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),i,o=[];return i={},a("next"),a("throw"),a("return",s),i[Symbol.asyncIterator]=function(){return this},i;function s(m){return function(g){return Promise.resolve(g).then(m,l)}}function a(m,g){n[m]&&(i[m]=function(v){return new Promise(function(x,S){o.push([m,v,x,S])>1||d(m,v)})},g&&(i[m]=g(i[m])))}function d(m,g){try{u(n[m](g))}catch(v){p(o[0][3],v)}}function u(m){m.value instanceof Z3?Promise.resolve(m.value.v).then(c,l):p(o[0][2],m)}function c(m){d("next",m)}function l(m){d("throw",m)}function p(m,g){m(g),o.shift(),o.length&&d(o[0][0],o[0][1])}},Eb=class t{static asAsyncIterator(e){return Irt(this,arguments,function*(){let n=e.getReader();try{for(;;){let{done:i,value:o}=yield Z3(n.read());if(i)break;yield yield Z3(o)}}finally{n.releaseLock()}})}static consumeToArrayBuffer(e){return J3(this,arguments,void 0,function*({readableStream:r}){let n=t.asAsyncIterator(r);return yield ae.asyncIterable(n).toArrayBufferAsync()})}static consumeToBlob(e){return J3(this,arguments,void 0,function*({readableStream:r}){let n=t.asAsyncIterator(r);return yield ae.asyncIterable(n).toBlobAsync()})}static consumeToBytes(e){return J3(this,arguments,void 0,function*({readableStream:r}){let n=t.asAsyncIterator(r);return yield ae.asyncIterable(n).toUint8ArrayAsync()})}static consumeToJson(e){return J3(this,arguments,void 0,function*({readableStream:r}){let n=t.asAsyncIterator(r);return yield ae.asyncIterable(n).toObjectAsync()})}static consumeToText(e){return J3(this,arguments,void 0,function*({readableStream:r}){let n=t.asAsyncIterator(r);return yield ae.asyncIterable(n).toStringAsync()})}static generateByteStream({streamLength:e,chunkLength:r,fillValue:n}){let i=e??1/0,o;function s(){let a=Math.min(i,r??1/0);i-=a;let d;if(typeof n=="number")d=new Uint8Array(a).fill(n);else if(Array.isArray(n)){d=new Uint8Array(a);let[u,c]=n,l=c-u+1;for(let p=0;p{if(s)this.push(null);else if(!this.push(a))return}).catch(s=>{this.destroy(s)})},destroy:function(s,a){function d(){a(s)}if(!i){n.cancel(s).then(d).catch(d);return}d()}}));return n.closed.then(()=>{i=!0}).catch(s=>{i=!0,o.destroy(s)}),o}static isDestroyed({stream:e}){if(!t.isStream(e))throw new TypeError("NodeStream.isDestroyed: 'stream' is not a Node stream.");let r="_writableState"in e?e._writableState:void 0,n=e._readableState,i=r||n;return!!(e.destroyed||i.destroyed)}static isReadable({readable:e}){return t.isReadableStream(e)?e.readable&&typeof e._readableState.ended=="boolean"&&!e._readableState.ended&&typeof e._readableState.endEmitted=="boolean"&&!e._readableState.endEmitted&&!e.destroyed&&!e.isPaused():!1}static isReadableStream(e){return typeof e=="object"&&e!==null&&"pipe"in e&&typeof e.pipe=="function"&&"on"in e&&typeof e.on=="function"&&!("_writableState"in e)&&"_readableState"in e}static isStream(e){return typeof e=="object"&&e!==null&&("_readableState"in e||"_writableState"in e)}static toWebReadable({readable:e}){if(!t.isReadableStream(e))throw new TypeError("NodeStream.toWebReadable: 'readable' is not a Node Readable stream.");if(t.isDestroyed({stream:e})){let r=new ReadableStream;return r.cancel(),r}return new ReadableStream({start(r){e.on("data",n=>{r.enqueue(n)}),e.on("end",()=>{r.close()}),e.on("error",n=>{r.error(n)})},cancel(){e.destroy()}})}};f();f();var Rrt=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Nf=class{static digest(e){return Rrt(this,arguments,void 0,function*({data:r}){return So(r)})}};f();var li=class{};var Drt=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},n0=class extends li{digest(e){return Drt(this,arguments,void 0,function*({algorithm:r,data:n}){switch(r){case"SHA-256":return yield Nf.digest({data:n})}})}};f();f();f();f();function $we(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 Brt=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Sb="urn:jwk:";function yt(t){return Brt(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}`);S_(n);let i=$we(n),o=ae.string(i).toUint8Array(),s=yield Nf.digest({data:o});return ae.uint8Array(s).toBase64Url()})}function gc(t){return!(!t||typeof t!="object"||!("kty"in t&&"crv"in t&&"x"in t&&"d"in t)||t.kty!=="EC"||typeof t.d!="string"||typeof t.x!="string")}function i0(t){return!(!t||typeof t!="object"||!("kty"in t&&"crv"in t&&"x"in t)||"d"in t||t.kty!=="EC"||typeof t.x!="string")}function Ab(t){return!(!t||typeof t!="object"||!("kty"in t&&"k"in t)||t.kty!=="oct"||typeof t.k!="string")}function vc(t){return!(!t||typeof t!="object"||!("kty"in t&&"crv"in t&&"x"in t&&"d"in t)||t.kty!=="OKP"||typeof t.d!="string"||typeof t.x!="string")}function o0(t){return!(!t||typeof t!="object"||"d"in t||!("kty"in t&&"crv"in t&&"x"in t)||t.kty!=="OKP"||typeof t.x!="string")}function A_(t){if(!t||typeof t!="object")return!1;switch(t.kty){case"EC":case"OKP":case"RSA":return"d"in t;case"oct":return"k"in t;default:return!1}}var Ms=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Mrt=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);it||t>10)throw new Error("randomPin() can securely generate a PIN between 3 to 10 digits.");let e=Math.pow(10,t)-1,r;if(t<=6){let n=Math.pow(10,t);do{let i=sz(Math.ceil(t/2));r=new DataView(i.buffer).getUint16(0,!1)%n}while(r>e)}else{let n=Math.pow(10,10);do{let i=sz(4);r=new DataView(i.buffer).getUint32(0,!1)%n}while(r>e)}return r.toString().padStart(t,"0")}var Mn={randomPin:Nrt,randomUuid:jrt,randomBytes:sz,getJoseSignatureAlgorithmFromPublicKey:$rt};f();f();f();f();var e5=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Urt=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);ibc,getServices:()=>Krt,getVerificationMethodByKey:()=>Frt,getVerificationMethodTypes:()=>cz,getVerificationMethods:()=>t5,getVerificationRelationshipsById:()=>dz,isDidService:()=>Nwe,isDidVerificationMethod:()=>JR,isDwnDidService:()=>zrt,keyBytesToMultibaseId:()=>ZR,multibaseIdToKeyBytes:()=>YR});f();var Lrt=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})};function bc(t){if(typeof t=="string"&&t.length!==0)return t.split("#").pop()}function Krt({didDocument:t,id:e,type:r}){var n,i;return(i=(n=t?.service)===null||n===void 0?void 0:n.filter(o=>!(e&&o.id!==e||r&&o.type!==r)))!==null&&i!==void 0?i:[]}function Frt(t){return Lrt(this,arguments,void 0,function*({didDocument:e,publicKeyJwk:r,publicKeyMultibase:n}){let i=t5({didDocument:e});for(let o of i)if(r&&o.publicKeyJwk){if((yield yt({jwk:r}))===(yield yt({jwk:o.publicKeyJwk})))return o}else if(n&&o.publicKeyMultibase&&n===o.publicKeyMultibase)return o;return null})}function t5({didDocument:t}){var e,r;if(!t)throw new TypeError("Required parameter missing: 'didDocument'");let n=[];return n.push(...(r=(e=t.verificationMethod)===null||e===void 0?void 0:e.filter(JR))!==null&&r!==void 0?r:[]),Object.keys(wb).forEach(i=>{var o,s;n.push(...(s=(o=t[i])===null||o===void 0?void 0:o.filter(JR))!==null&&s!==void 0?s:[])}),n}function cz({didDocument:t}){let r=t5({didDocument:t}).map(n=>n.type);return[...new Set(r)]}function dz({didDocument:t,methodId:e}){let r=[];return Object.keys(wb).forEach(n=>{if(Array.isArray(t[n])){let i=t[n],o=bc(e);i.some(a=>{let d=bc(a)===o,u=JR(a)&&bc(a.id)===o;return d||u})&&r.push(n)}}),r}function Nwe(t){return!t||typeof t!="object"||t===null?!1:"id"in t&&"type"in t&&"serviceEndpoint"in t}function zrt(t){if(!Nwe(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 JR(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 ZR({keyBytes:t,multicodecCode:e,multicodecName:r}){let n=la.addPrefix({code:e,data:t,name:r}),i=ae.uint8Array(n).toBase58Btc();return ae.base58Btc(i).toMultibase()}function YR({multibaseKeyId:t}){try{let e=ae.multibase(t).toBase58Btc(),r=ae.base58Btc(e).toUint8Array(),{code:n,data:i,name:o}=la.removePrefix({prefixedData:r});return{keyBytes:i,multicodecCode:n,multicodecName:o}}catch{throw new dt(rt.InvalidDid,`Invalid multibase identifier: ${t}`)}}var r5=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},_o=class t{constructor({uri:e,document:r,metadata:n,keyManager:i}){this.uri=e,this.document=r,this.metadata=n,this.keyManager=i}export(){return r5(this,void 0,void 0,function*(){if(!(Array.isArray(this.document.verificationMethod)&&this.document.verificationMethod.length>0))throw new Error(`DID document for '${this.uri}' is missing verification methods`);let e={uri:this.uri,document:this.document,metadata:this.metadata};if("exportKey"in this.keyManager&&typeof this.keyManager.exportKey=="function"){let r=[];for(let n of this.document.verificationMethod){if(!n.publicKeyJwk)throw new Error(`Verification method '${n.id}' does not contain a public key in JWK format`);let i=yield this.keyManager.getKeyUri({key:n.publicKeyJwk}),o=yield this.keyManager.exportKey({keyUri:i});r.push(Object.assign({},o))}e.privateKeys=r}return e})}getSigner(e){return r5(this,void 0,void 0,function*(){var r;let n=(r=this.document.verificationMethod)===null||r===void 0?void 0:r.find(d=>{var u,c;return bc(d.id)===((u=bc(e?.methodId))!==null&&u!==void 0?u:bc((c=this.document.assertionMethod)===null||c===void 0?void 0:c[0]))});if(!(n&&n.publicKeyJwk))throw new dt(rt.InternalError,"A verification method intended for signing could not be determined from the DID Document");let i=yield this.keyManager.getKeyUri({key:n.publicKeyJwk}),o=yield this.keyManager.getPublicKey({keyUri:i}),s=this.keyManager;return{algorithm:Mn.getJoseSignatureAlgorithmFromPublicKey(o),keyId:n.id,sign(d){return r5(this,arguments,void 0,function*({data:u}){return yield s.sign({data:u,keyUri:i})})},verify(d){return r5(this,arguments,void 0,function*({data:u,signature:c}){return yield s.verify({data:u,key:o,signature:c})})}}})}static import(e){return r5(this,arguments,void 0,function*({portableDid:r,keyManager:n=new Qn}){var i;let o=t5({didDocument:r.document});if(o.length===0)throw new dt(rt.InvalidDidDocument,"At least one verification method is required but 0 were given");for(let a of(i=r.privateKeys)!==null&&i!==void 0?i:[])yield n.importKey({key:a});for(let a of o){if(!a.publicKeyJwk)throw new Error(`Verification method '${a.id}' does not contain a public key in JWK format`);let d=yield n.getKeyUri({key:a.publicKeyJwk});yield n.getPublicKey({keyUri:d})}return new t({uri:r.uri,document:r.document,metadata:r.metadata,keyManager:n})})}};f();f();var Uwe=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},cu=class{static getSigningMethod(e){return Uwe(this,void 0,void 0,function*(){throw new Error("Not implemented: Classes extending DidMethod must implement getSigningMethod()")})}static resolve(e,r){return Uwe(this,void 0,void 0,function*(){throw new Error("Not implemented: Classes extending DidMethod must implement resolve()")})}};var Yo=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},qwe=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i!(j.algorithm in Fwe)))throw new Error("One or more verification method algorithms are not supported");let g=(i=r.verificationMethods)===null||i===void 0?void 0:i.filter(j=>"id"in j).map(j=>j.id);if(g&&g.length!==new Set(g).size)throw new Error("One or more verification method IDs are not unique");if(!((o=r.services)===null||o===void 0)&&o.some(j=>!j.id||!j.type||!j.serviceEndpoint))throw new Error("One or more services are missing required properties");let v=yield e.generateKey({algorithm:"Ed25519"}),x=yield e.getPublicKey({keyUri:v}),S=yield Zo.identityKeyToIdentifier({identityKey:x}),P=Object.assign(Object.assign({id:S},r.alsoKnownAs&&{alsoKnownAs:r.alsoKnownAs}),r.controllers&&{controller:r.controllers}),A=[...(s=r.verificationMethods)!==null&&s!==void 0?s:[]];A?.some(j=>{var L;return((L=j.id)===null||L===void 0?void 0:L.split("#").pop())==="0"})||A.unshift({algorithm:"Ed25519",id:"0",purposes:["authentication","assertionMethod","capabilityDelegation","capabilityInvocation"]});for(let j of A){let L=j.id&&j.id.split("#").pop()==="0"?v:yield e.generateKey({algorithm:j.algorithm}),F=yield e.getPublicKey({keyUri:L}),K=(d=(a=j.id)!==null&&a!==void 0?a:F.kid)!==null&&d!==void 0?d:yield yt({jwk:F});K=`${S}#${bc(K)}`,(u=P.verificationMethod)!==null&&u!==void 0||(P.verificationMethod=[]),P.verificationMethod.push({id:K,type:"JsonWebKey",controller:(c=j.controller)!==null&&c!==void 0?c:S,publicKeyJwk:F});for(let W of(l=j.purposes)!==null&&l!==void 0?l:[])P[W]||(P[W]=[]),P[W].push(K)}(p=r.services)===null||p===void 0||p.forEach(j=>{var L;(L=P.service)!==null&&L!==void 0||(P.service=[]),j.id=`${S}#${j.id.split("#").pop()}`,P.service.push(j)});let $=new _o({uri:S,document:P,metadata:Object.assign({published:!1},r.types&&{types:r.types}),keyManager:e});if(!((m=r.publish)!==null&&m!==void 0)||m){let j=yield t.publish({did:$,gatewayUri:r.gatewayUri});$.metadata=j.didDocumentMetadata}return $})}static import(e){return Yo(this,arguments,void 0,function*({portableDid:r,keyManager:n=new Qn}){var i;let o=sr.parse(r.uri);if(o?.method!==t.methodName)throw new dt(rt.MethodNotSupported,"Method not supported");let s=yield _o.import({portableDid:r,keyManager:n});if(!(!((i=s.document.verificationMethod)===null||i===void 0)&&i.some(a=>{var d;return((d=a.id)===null||d===void 0?void 0:d.split("#").pop())==="0"})))throw new dt(rt.InvalidDidDocument,"DID document must contain an Identity Key");return s})}static getSigningMethod(e){return Yo(this,arguments,void 0,function*({didDocument:r,methodId:n="#0"}){var i;let o=sr.parse(r.id);if(o&&o.method!==this.methodName)throw new dt(rt.MethodNotSupported,`Method not supported: ${o.method}`);let s=(i=r.verificationMethod)===null||i===void 0?void 0:i.find(a=>{var d,u;return bc(a.id)===((d=bc(n))!==null&&d!==void 0?d:bc((u=r.assertionMethod)===null||u===void 0?void 0:u[0]))});if(!(s&&s.publicKeyJwk))throw new dt(rt.InternalError,"A verification method intended for signing could not be determined from the DID Document");return s})}static publish(e){return Yo(this,arguments,void 0,function*({did:r,gatewayUri:n=Lwe}){return yield eD.put({did:r,gatewayUri:n})})}static resolve(e){return Yo(this,arguments,void 0,function*(r,n={}){var i;let o=(i=n?.gatewayUri)!==null&&i!==void 0?i:Lwe;try{yield Zo.identifierToIdentityKey({didUri:r});let{didDocument:s,didDocumentMetadata:a}=yield eD.get({didUri:r,gatewayUri:o});return Object.assign(Object.assign({},ui),{didDocument:s,didDocumentMetadata:a})}catch(s){if(!(s instanceof dt))throw new Error(s);return Object.assign(Object.assign({},ui),{didResolutionMetadata:Object.assign({error:s.code},s.message&&{errorMessage:s.message})})}})}};du.methodName="dht";var eD=class t{static get(e){return Yo(this,arguments,void 0,function*({didUri:r,gatewayUri:n}){let i=Zo.identifierToIdentityKeyBytes({didUri:r}),o=yield t.pkarrGet({gatewayUri:n,publicKeyBytes:i}),s=yield Zo.parseBep44GetMessage({bep44Message:o}),a=yield t.fromDnsPacket({didUri:r,dnsPacket:s});return a.didDocumentMetadata.versionId=o.seq.toString(),a})}static put(e){return Yo(this,arguments,void 0,function*({did:r,gatewayUri:n}){let i=yield t.toDnsPacket({didDocument:r.document,didMetadata:r.metadata,authoritativeGatewayUris:[n]}),o=yield Zo.createBep44PutMessage({dnsPacket:i,publicKeyBytes:Zo.identifierToIdentityKeyBytes({didUri:r.uri}),signer:yield r.getSigner({methodId:"0"})}),s=yield t.pkarrPut({gatewayUri:n,bep44Message:o});return{didDocument:r.document,didDocumentMetadata:Object.assign(Object.assign({},r.metadata),{published:s,versionId:o.seq.toString()}),didRegistrationMetadata:{}}})}static pkarrGet(e){return Yo(this,arguments,void 0,function*({gatewayUri:r,publicKeyBytes:n}){let i=ae.uint8Array(n).toBase32Z(),o=new URL(i,r).href,s;try{if(s=yield fetch(o,{method:"GET"}),!s.ok)throw new dt(rt.NotFound,`Pkarr record not found for: ${i}`)}catch(u){throw u instanceof dt?u:new dt(rt.InternalError,`Failed to fetch Pkarr record: ${u.message}`)}let a=yield s.arrayBuffer();if(!a)throw new dt(rt.NotFound,`Pkarr record not found for: ${i}`);if(a.byteLength<72)throw new dt(rt.InvalidDidDocumentLength,`Pkarr response must be at least 72 bytes but got: ${a.byteLength}`);if(a.byteLength>1072)throw new dt(rt.InvalidDidDocumentLength,`Pkarr response exceeds 1000 byte limit: ${a.byteLength}`);return{k:n,seq:Number(new DataView(a).getBigUint64(64)),sig:new Uint8Array(a,0,64),v:new Uint8Array(a,72)}})}static pkarrPut(e){return Yo(this,arguments,void 0,function*({gatewayUri:r,bep44Message:n}){let i=ae.uint8Array(n.k).toBase32Z(),o=new URL(i,r).href,s=new Uint8Array(n.v.length+72);s.set(n.sig,0),new DataView(s.buffer).setBigUint64(n.sig.length,BigInt(n.seq)),s.set(n.v,n.sig.length+8);let a;try{a=yield fetch(o,{method:"PUT",headers:{"Content-Type":"application/octet-stream"},body:s})}catch(d){throw new dt(rt.InternalError,`Failed to put Pkarr record for identifier ${i}: ${d.message}`)}return a.ok})}static fromDnsPacket(e){return Yo(this,arguments,void 0,function*({didUri:r,dnsPacket:n}){var i,o,s;let a={id:r},d={published:!0},u=new Map;for(let c of(i=n?.answers)!==null&&i!==void 0?i:[]){if(c.type!=="TXT")continue;let l=c.name.split(".")[0].substring(1);switch(!0){case l.startsWith("aka"):{let p=Zo.parseTxtDataToString(c.data);a.alsoKnownAs=p.split(Fa);break}case l.startsWith("cnt"):{let p=Zo.parseTxtDataToString(c.data);a.controller=p.includes(Fa)?p.split(Fa):p;break}case l.startsWith("k"):{let{id:p,t:m,k:g,c:v,a:x}=Zo.parseTxtDataToObject(c.data),S=ae.base64Url(g).toUint8Array(),P=za[Number(m)],A=yield Zo.keyConverter(P).bytesToPublicKey({publicKeyBytes:S});A.alg=x||Kwe[Number(m)];let $=l==="k0"?"0":p!==void 0?p:yield yt({jwk:A});(o=a.verificationMethod)!==null&&o!==void 0||(a.verificationMethod=[]);let j=`${r}#${$}`;a.verificationMethod.push({id:j,type:"JsonWebKey",controller:v??r,publicKeyJwk:A}),u.set(l,j);break}case l.startsWith("s"):{let p=Zo.parseTxtDataToObject(c.data),{id:m,t:g,se:v}=p,x=qwe(p,["id","t","se"]),S=v.includes(Fa)?v.split(Fa):[v],P=Object.fromEntries(Object.entries(x).map(([A,$])=>[A,$.includes(Fa)?$.split(Fa):$]));(s=a.service)!==null&&s!==void 0||(a.service=[]),a.service.push(Object.assign(Object.assign({},P),{id:`${r}#${m}`,type:g,serviceEndpoint:S}));break}case l.startsWith("typ"):{let{id:p}=Zo.parseTxtDataToObject(c.data);d.types=p.split(Fa).map(m=>Number(m));break}case l.startsWith("did"):{let p=P=>P.split(Fa).map(A=>u.get(A)).filter(A=>typeof A=="string"),{auth:m,asm:g,del:v,inv:x,agm:S}=Zo.parseTxtDataToObject(c.data);m&&(a.authentication=p(m)),g&&(a.assertionMethod=p(g)),v&&(a.capabilityDelegation=p(v)),x&&(a.capabilityInvocation=p(x)),S&&(a.keyAgreement=p(S));break}}}return{didDocument:a,didDocumentMetadata:d,didResolutionMetadata:{}}})}static toDnsPacket(e){return Yo(this,arguments,void 0,function*({didDocument:r,didMetadata:n,authoritativeGatewayUris:i,previousDidProof:o}){var s,a,d,u,c;let l=[],p=[],m=new Map,g=[],v=[];if(o!==void 0){let{signature:P,previousDid:A}=o;yield Zo.validatePreviousDidProof({newDid:r.id,previousDidProof:o}),l.push({type:"TXT",name:"_prv._did.",ttl:u0,data:`id=${A};s=${P}`})}if(r.alsoKnownAs&&l.push({type:"TXT",name:"_aka._did.",ttl:u0,data:r.alsoKnownAs.join(Fa)}),r.controller){let P=Array.isArray(r.controller)?r.controller.join(Fa):r.controller;l.push({type:"TXT",name:"_cnt._did.",ttl:u0,data:P})}for(let[P,A]of(a=(s=r.verificationMethod)===null||s===void 0?void 0:s.entries())!==null&&a!==void 0?a:[]){let $=`k${P}`;v.push($);let j=A.id.split("#").pop();m.set(j,$);let L=A.publicKeyJwk;if(!(L?.crv&&L.crv in Fwe))throw new dt(rt.InvalidPublicKeyType,`Verification method '${A.id}' contains an unsupported key type: ${(d=L?.crv)!==null&&d!==void 0?d:"undefined"}`);let F=za[L.crv],K=yield Zo.keyConverter(L.crv).publicKeyToBytes({publicKey:L}),W=ae.uint8Array(K).toBase64Url(),q=[`t=${F}`,`k=${W}`];j!=="0"&&(yield yt({jwk:L}))!==j&&q.unshift(`id=${j}`),L.alg!==Kwe[F]&&q.push(`a=${L.alg}`),A.controller!==r.id&&q.push(`c=${A.controller}`),l.push({type:"TXT",name:`_${$}._did.`,ttl:u0,data:q.join(QR)})}(u=r.service)===null||u===void 0||u.forEach((P,A)=>{let $=`s${A}`;g.push($);let{id:j,type:L,serviceEndpoint:F}=P,K=qwe(P,["id","type","serviceEndpoint"]);j=bc(j),F=Array.isArray(F)?F.join(","):F;let q=Object.entries(Object.assign({id:j,t:L,se:F},K)).map(([T,B])=>`${T}=${B}`).join(QR),I=Zo.chunkDataIfNeeded(q);l.push({type:"TXT",name:`_${$}._did.`,ttl:u0,data:I})});let x=[`v=${Wrt}`];if(v.length&&x.push(`vm=${v.join(Fa)}`),Object.keys(wb).forEach(P=>{var A;let $=(A=r[P])===null||A===void 0?void 0:A.map(j=>m.get(j.split("#").pop()));if($){let j=lz[P];x.push(`${j}=${$.join(Fa)}`)}}),g.length&&x.push(`svc=${g.join(Fa)}`),!((c=n.types)===null||c===void 0)&&c.length){let A=n.types.map($=>typeof $=="string"?uz[$]:$);l.push({type:"TXT",name:"_typ._did.",ttl:u0,data:`id=${A.join(Fa)}`})}l.push({type:"TXT",name:"_did."+t.getUniqueDidSuffix(r.id)+".",ttl:u0,data:x.join(QR)});for(let P of i||[])p.push({type:"NS",name:"_did."+t.getUniqueDidSuffix(r.id)+".",ttl:u0,data:P+"."});return{id:0,type:"response",flags:sR,answers:[...l,...p]}})}static getUniqueDidSuffix(e){return e.split(":")[2]}},Zo=class t{static createBep44PutMessage(e){return Yo(this,arguments,void 0,function*({dnsPacket:r,publicKeyBytes:n,signer:i}){let o=Math.ceil(Date.now()/1e3),s=ib(r),a=H2.encode({seq:o,v:s}).subarray(1,-1);if(a.length>1e3)throw new dt(rt.InvalidDidDocumentLength,`DNS packet exceeds the 1000 byte maximum size: ${a.length} bytes`);let d=yield i.sign({data:a});return{k:n,seq:o,sig:d,v:s}})}static identifierToIdentityKey(e){return Yo(this,arguments,void 0,function*({didUri:r}){let n=t.identifierToIdentityKeyBytes({didUri:r});return yield Fr.bytesToPublicKey({publicKeyBytes:n})})}static identifierToIdentityKeyBytes({didUri:e}){let r=sr.parse(e);if(!r)throw new dt(rt.InvalidDid,`Invalid DID URI: ${e}`);if(r.method!==du.methodName)throw new dt(rt.MethodNotSupported,`Method not supported: ${r.method}`);let n;try{n=ae.base32Z(r.id).toUint8Array()}catch{throw new dt(rt.InvalidPublicKey,"Failed to decode method-specific identifier")}if(n.length!==32)throw new dt(rt.InvalidPublicKeyLength,`Invalid public key length: ${n.length}`);return n}static identityKeyToIdentifier(e){return Yo(this,arguments,void 0,function*({identityKey:r}){let n=yield Fr.publicKeyToBytes({publicKey:r}),i=ae.uint8Array(n).toBase32Z();return`did:${du.methodName}:${i}`})}static keyConverter(e){let n={Ed25519:Fr,"P-256":{publicKeyToBytes:i=>Yo(this,[i],void 0,function*({publicKey:o}){let s=yield Bn.publicKeyToBytes({publicKey:o});return yield Bn.compressPublicKey({publicKeyBytes:s})}),bytesToPublicKey:Bn.bytesToPublicKey,privateKeyToBytes:Bn.privateKeyToBytes,bytesToPrivateKey:Bn.bytesToPrivateKey},secp256k1:{publicKeyToBytes:i=>Yo(this,[i],void 0,function*({publicKey:o}){let s=yield xn.publicKeyToBytes({publicKey:o});return yield xn.compressPublicKey({publicKeyBytes:s})}),bytesToPublicKey:xn.bytesToPublicKey,privateKeyToBytes:xn.privateKeyToBytes,bytesToPrivateKey:xn.bytesToPrivateKey},X25519:d0}[e];if(!n)throw new dt(rt.InvalidPublicKeyType,`Unsupported curve: ${e}`);return n}static parseBep44GetMessage(e){return Yo(this,arguments,void 0,function*({bep44Message:r}){let n=yield Fr.bytesToPublicKey({publicKeyBytes:r.k}),i=H2.encode({seq:r.seq,v:r.v}).subarray(1,-1);if(!(yield Fr.verify({key:n,signature:r.sig,data:i})))throw new dt(rt.InvalidSignature,"Invalid signature for DHT BEP44 message");return t_(r.v)})}static parseTxtDataToObject(e){return this.parseTxtDataToString(e).split(QR).reduce((r,n)=>{let[i,o]=n.split("=");return r[i]=o,r},{})}static parseTxtDataToString(e){if(typeof e=="string")return e;if(e instanceof Uint8Array)return ae.uint8Array(e).toString();if(Array.isArray(e))return e.map(r=>this.parseTxtDataToString(r)).join("");throw new dt(rt.InternalError,"Pkarr returned DNS TXT record with invalid data type")}static validatePreviousDidProof(e){return Yo(this,arguments,void 0,function*({newDid:r,previousDidProof:n}){let i=yield t.identifierToIdentityKey({didUri:n.previousDid}),o=t.identifierToIdentityKeyBytes({didUri:r}),s=ae.base64Url(n.signature).toUint8Array();if(!(yield Fr.verify({key:i,data:o,signature:s})))throw new dt(rt.InvalidPreviousDidProof,"The previous DID proof is invalid.")})}static chunkDataIfNeeded(e){if(e.length<=255)return e;let r=[];for(let n=0;n!(j.algorithm in Hrt)))throw new Error("One or more verification method algorithms are not supported");let c=(i=r.verificationMethods)===null||i===void 0?void 0:i.filter(j=>"id"in j).map(j=>j.id);if(c&&c.length!==new Set(c).size)throw new Error("One or more verification method IDs are not unique");if(!((o=r.services)===null||o===void 0)&&o.some(j=>!j.id||!j.type||!j.serviceEndpoint))throw new Error("One or more services are missing required properties");let l={algorithm:"Ed25519",purposes:["authentication","assertionMethod","capabilityDelegation","capabilityInvocation"]},p=[];for(let j of(s=r.verificationMethods)!==null&&s!==void 0?s:[l]){let L=yield e.generateKey({algorithm:j.algorithm}),F=yield e.getPublicKey({keyUri:L});p.push({id:j.id,publicKeyJwk:F,purposes:(a=j.purposes)!==null&&a!==void 0?a:["authentication","assertionMethod","capabilityDelegation","capabilityInvocation"]})}let m=yield e.generateKey({algorithm:Uf.secp256k1}),g=yield e.getPublicKey({keyUri:m}),v=yield e.generateKey({algorithm:Uf.secp256k1}),x=yield e.getPublicKey({keyUri:v}),S=yield Tb.computeLongFormDidUri({recoveryKey:g,updateKey:x,services:(d=r.services)!==null&&d!==void 0?d:[],verificationMethods:p}),{didDocument:P,didResolutionMetadata:A}=yield t.resolve(S,{gatewayUri:r.gatewayUri});if(P===null)throw new Error(`Unable to resolve DID during creation: ${A?.error}`);let $=new _o({uri:S,document:P,metadata:{published:!1,canonicalId:S.split(":",3).join(":"),recoveryKey:g,updateKey:x},keyManager:e});if(!((u=r.publish)!==null&&u!==void 0)||u){let j=yield t.publish({did:$,gatewayUri:r.gatewayUri});$.metadata=j.didDocumentMetadata}return $})}static getSigningMethod(e){return l0(this,arguments,void 0,function*({didDocument:r,methodId:n}){var i;let o=sr.parse(r.id);if(o&&o.method!==this.methodName)throw new dt(rt.MethodNotSupported,`Method not supported: ${o.method}`);let s=(i=r.verificationMethod)===null||i===void 0?void 0:i.find(a=>{var d;return a.id===(n??((d=r.assertionMethod)===null||d===void 0?void 0:d[0]))});if(!(s&&s.publicKeyJwk))throw new dt(rt.InternalError,"A verification method intended for signing could not be determined from the DID Document");return s})}static import(e){return l0(this,arguments,void 0,function*({portableDid:r,keyManager:n=new Qn}){let i=sr.parse(r.uri);if(i?.method!==t.methodName)throw new dt(rt.MethodNotSupported,"Method not supported");return yield _o.import({portableDid:r,keyManager:n})})}static publish(e){return l0(this,arguments,void 0,function*({did:r,gatewayUri:n=zwe}){var i,o,s;let a=(o=(i=r.document.verificationMethod)===null||i===void 0?void 0:i.map(c=>({id:c.id,publicKeyJwk:c.publicKeyJwk,purposes:dz({didDocument:r.document,methodId:c.id})})))!==null&&o!==void 0?o:[],d=yield Tb.createIonDocument({services:(s=r.document.service)!==null&&s!==void 0?s:[],verificationMethods:a}),u=yield Tb.constructCreateRequest({ionDocument:d,recoveryKey:r.metadata.recoveryKey,updateKey:r.metadata.updateKey});try{let c=Tb.appendPathToUrl({baseUrl:n,path:"/operations"}),l=yield fetch(c,{method:"POST",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)});return{didDocument:r.document,didDocumentMetadata:Object.assign(Object.assign({},r.metadata),{published:l.ok}),didRegistrationMetadata:{}}}catch{return{didDocument:null,didDocumentMetadata:{published:!1},didRegistrationMetadata:{error:rt.InternalError,errorMessage:`Failed to publish DID document for: ${r.uri}`}}}})}static resolve(e){return l0(this,arguments,void 0,function*(r,n={}){var i,o;let s=sr.parse(r);if(!s)return Object.assign(Object.assign({},ui),{didResolutionMetadata:{error:"invalidDid"}});if(s.method!==t.methodName)return Object.assign(Object.assign({},ui),{didResolutionMetadata:{error:"methodNotSupported"}});let a=(i=n?.gatewayUri)!==null&&i!==void 0?i:zwe;try{let d=Tb.appendPathToUrl({baseUrl:a,path:`/identifiers/${r}`}),u=yield fetch(d);if(!u.ok)throw new dt(rt.NotFound,`Unable to find DID document for: ${r}`);let{didDocument:c,didDocumentMetadata:l}=yield u.json();return Object.assign(Object.assign(Object.assign({},ui),c&&{didDocument:c}),{didDocumentMetadata:Object.assign({published:(o=l?.method)===null||o===void 0?void 0:o.published},l)})}catch(d){if(!(d instanceof dt))throw new Error(d);return Object.assign(Object.assign({},ui),{didResolutionMetadata:Object.assign({error:d.code},d.message&&{errorMessage:d.message})})}})}};fz.methodName="ion";var Tb=class t{static appendPathToUrl({baseUrl:e,path:r}){let n=new URL(e);return n.pathname=n.pathname.endsWith("/")?n.pathname:n.pathname+"/",n.pathname+=r.startsWith("/")?r.substring(1):r,n.toString()}static computeLongFormDidUri(e){return l0(this,arguments,void 0,function*({recoveryKey:r,updateKey:n,services:i,verificationMethods:o}){let s=yield t.createIonDocument({services:i,verificationMethods:o}),a=t.normalizeJwk(r),d=t.normalizeJwk(n);return yield Vy.createLongFormDid({document:s,recoveryKey:a,updateKey:d})})}static constructCreateRequest(e){return l0(this,arguments,void 0,function*({ionDocument:r,recoveryKey:n,updateKey:i}){return yield Cf.createCreateRequest({document:r,recoveryKey:t.normalizeJwk(n),updateKey:t.normalizeJwk(i)})})}static createIonDocument(e){return l0(this,arguments,void 0,function*({services:r,verificationMethods:n}){var i,o;let s=[];for(let u of n){let c=(o=(i=u.id)!==null&&i!==void 0?i:u.publicKeyJwk.kid)!==null&&o!==void 0?o:yield yt({jwk:u.publicKeyJwk});c=`${c.split("#").pop()}`;let l={id:c,publicKeyJwk:t.normalizeJwk(u.publicKeyJwk),purposes:u.purposes,type:"JsonWebKey2020"};s.push(l)}let a=r.map(u=>Object.assign(Object.assign({},u),{id:`${u.id.split("#").pop()}`}));return{publicKeys:s,services:a}})}static normalizeJwk(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}`);return n}};f();var tD=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Wa=class t extends cu{static create(){return tD(this,arguments,void 0,function*({keyManager:e=new Qn,options:r={}}={}){var n,i,o,s;if(r.algorithm&&r.verificationMethods)throw new Error("The 'algorithm' and 'verificationMethods' options are mutually exclusive");if(r.verificationMethods&&r.verificationMethods.length!==1)throw new Error("The 'verificationMethods' option must contain exactly one entry");let a=(s=(n=r.algorithm)!==null&&n!==void 0?n:(o=(i=r.verificationMethods)===null||i===void 0?void 0:i[0])===null||o===void 0?void 0:o.algorithm)!==null&&s!==void 0?s:"Ed25519",d=yield e.generateKey({algorithm:a}),u=yield e.getPublicKey({keyUri:d}),c=ae.object(u).toBase64Url(),l=`did:${t.methodName}:${c}`,m=(yield t.resolve(l)).didDocument;return new _o({uri:l,document:m,metadata:{},keyManager:e})})}static getSigningMethod(e){return tD(this,arguments,void 0,function*({didDocument:r}){var n;let i=sr.parse(r.id);if(i&&i.method!==this.methodName)throw new dt(rt.MethodNotSupported,`Method not supported: ${i.method}`);let[o]=(n=r.verificationMethod)!==null&&n!==void 0?n:[];if(!(o&&o.publicKeyJwk))throw new dt(rt.InternalError,"A verification method intended for signing could not be determined from the DID Document");return o})}static import(e){return tD(this,arguments,void 0,function*({portableDid:r,keyManager:n=new Qn}){let i=sr.parse(r.uri);if(i?.method!==t.methodName)throw new dt(rt.MethodNotSupported,"Method not supported");let o=yield _o.import({portableDid:r,keyManager:n});if(o.document.verificationMethod.length!==1)throw new dt(rt.InvalidDidDocument,"DID document must contain exactly one verification method");return o})}static resolve(e,r){return tD(this,void 0,void 0,function*(){let n=sr.parse(e),i;try{i=ae.base64Url(n.id).toObject()}catch{}if(!n||!i)return Object.assign(Object.assign({},ui),{didResolutionMetadata:{error:"invalidDid"}});if(n.method!==t.methodName)return Object.assign(Object.assign({},ui),{didResolutionMetadata:{error:"methodNotSupported"}});let o={"@context":["https://www.w3.org/ns/did/v1"],id:n.uri},s=`${o.id}#0`;switch(o.verificationMethod=[{id:s,type:"JsonWebKey",controller:o.id,publicKeyJwk:i}],o.authentication=[s],o.assertionMethod=[s],o.capabilityInvocation=[s],o.capabilityDelegation=[s],o.keyAgreement=[s],i.use){case"sig":{delete o.keyAgreement;break}case"enc":{delete o.authentication,delete o.assertionMethod,delete o.capabilityInvocation,delete o.capabilityDelegation;break}}return Object.assign(Object.assign({},ui),{didDocument:o})})}};Wa.methodName="jwk";f();var yl=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Ip;(function(t){t.Ed25519="Ed25519",t.secp256k1="secp256k1",t.secp256r1="secp256r1",t.X25519="X25519"})(Ip||(Ip={}));var hz={Ed25519VerificationKey2020:"https://w3id.org/security/suites/ed25519-2020/v1",JsonWebKey2020:"https://w3id.org/security/suites/jws-2020/v1",X25519KeyAgreementKey2020:"https://w3id.org/security/suites/x25519-2020/v1"},Vrt={Ed25519:Ip.Ed25519,ES256K:Ip.secp256k1,ES256:Ip.secp256r1,"P-256":Ip.secp256r1,secp256k1:Ip.secp256k1,secp256r1:Ip.secp256r1,X25519:Ip.X25519},pz=class t extends cu{static create(){return yl(this,arguments,void 0,function*({keyManager:e=new Qn,options:r={}}={}){var n,i,o,s;if(r.algorithm&&r.verificationMethods)throw new Error("The 'algorithm' and 'verificationMethods' options are mutually exclusive");if(r.verificationMethods&&r.verificationMethods.length!==1)throw new Error("The 'verificationMethods' option must contain exactly one entry");let a=(s=(n=r.algorithm)!==null&&n!==void 0?n:(o=(i=r.verificationMethods)===null||i===void 0?void 0:i[0])===null||o===void 0?void 0:o.algorithm)!==null&&s!==void 0?s:"Ed25519",d=yield e.generateKey({algorithm:a}),u=yield e.getPublicKey({keyUri:d}),c=yield wc.publicKeyToMultibaseId({publicKey:u}),l=`did:${t.methodName}:${c}`,m=(yield t.resolve(l,r)).didDocument;return new _o({uri:l,document:m,metadata:{},keyManager:e})})}static getSigningMethod(e){return yl(this,arguments,void 0,function*({didDocument:r}){var n;let i=sr.parse(r.id);if(i&&i.method!==this.methodName)throw new dt(rt.MethodNotSupported,`Method not supported: ${i.method}`);let[o]=r.assertionMethod||[],s=(n=r.verificationMethod)===null||n===void 0?void 0:n.find(a=>a.id===o);if(!(s&&s.publicKeyJwk))throw new dt(rt.InternalError,"A verification method intended for signing could not be determined from the DID Document");return s})}static import(e){return yl(this,arguments,void 0,function*({portableDid:r,keyManager:n=new Qn}){let i=sr.parse(r.uri);if(i?.method!==t.methodName)throw new dt(rt.MethodNotSupported,"Method not supported");let o=yield _o.import({portableDid:r,keyManager:n});if(o.document.verificationMethod.length!==1)throw new dt(rt.InvalidDidDocument,"DID document must contain exactly one verification method");return o})}static resolve(e,r){return yl(this,void 0,void 0,function*(){try{let n=yield t.createDocument({didUri:e,options:r});return Object.assign(Object.assign({},ui),{didDocument:n})}catch(n){if(!(n instanceof dt))throw new Error(n);return Object.assign(Object.assign({},ui),{didResolutionMetadata:Object.assign({error:n.code},n.message&&{errorMessage:n.message})})}})}static createDocument(e){return yl(this,arguments,void 0,function*({didUri:r,options:n={}}){let{defaultContext:i="https://www.w3.org/ns/did/v1",enableEncryptionKeyDerivation:o=!1,enableExperimentalPublicKeyTypes:s=!1,publicKeyFormat:a="JsonWebKey2020"}=n,d={id:""},u=sr.parse(r);if(!u)throw new dt(rt.InvalidDid,`Invalid DID URI: ${r}`);let c=u.id;if(u.method!==t.methodName)throw new dt(rt.MethodNotSupported,`Method not supported: ${u.method}`);if(!t.validateIdentifier(u))throw new dt(rt.InvalidDid,`Invalid DID URI: ${r}`);let l=yield t.createSignatureMethod({didUri:r,multibaseValue:c,options:{enableExperimentalPublicKeyTypes:s,publicKeyFormat:a}});if(d.id=u.uri,d.verificationMethod=[l],d.authentication=[l.id],d.assertionMethod=[l.id],d.capabilityInvocation=[l.id],d.capabilityDelegation=[l.id],o===!0){let g=a==="Ed25519VerificationKey2020"?"X25519KeyAgreementKey2020":"JsonWebKey2020",v=yield this.createEncryptionMethod({didUri:r,multibaseValue:c,options:{enableExperimentalPublicKeyTypes:s,publicKeyFormat:g}});d.verificationMethod.push(v),d.keyAgreement=[v.id]}let p=[i];return cz({didDocument:d}).forEach(g=>{let v=hz[g];p.push(v)}),d["@context"]=p,d})}static createEncryptionMethod(e){return yl(this,arguments,void 0,function*({didUri:r,multibaseValue:n,options:i}){let{enableExperimentalPublicKeyTypes:o,publicKeyFormat:s}=i,a={id:"",type:"",controller:""},{keyBytes:d,multicodecCode:u}=yield t.deriveEncryptionKey({multibaseValue:n}),c=d.byteLength,l=wc.MULTICODEC_PUBLIC_KEY_LENGTH[u];if(c!==l)throw new dt(rt.InvalidPublicKeyLength,`Expected ${c} bytes. Actual: ${l}`);let p=ZR({keyBytes:d,multicodecCode:u});a.id=`${r}#${p}`;try{new URL(a.id)}catch{throw new dt(rt.InvalidDidUrl,"Verification Method ID is not a valid DID URL.")}if(!(s in hz))throw new dt(rt.UnsupportedPublicKeyType,`Unsupported format: ${s}`);if(o===!1&&!["Multikey","JsonWebKey2020","X25519KeyAgreementKey2020"].includes(s))throw new dt(rt.InvalidPublicKeyType,`Specified '${s}' without setting enableExperimentalPublicKeyTypes to true.`);if(a.type=s,a.controller=r,s==="X25519KeyAgreementKey2020"&&(a.publicKeyMultibase=p),s==="JsonWebKey2020"){let{crv:g}=yield wc.multicodecToJwk({code:u});a.publicKeyJwk=yield wc.keyConverter(g).bytesToPublicKey({publicKeyBytes:d})}return a})}static createSignatureMethod(e){return yl(this,arguments,void 0,function*({didUri:r,multibaseValue:n,options:i}){let{enableExperimentalPublicKeyTypes:o,publicKeyFormat:s}=i,a={id:"",type:"",controller:""},{keyBytes:d,multicodecCode:u,multicodecName:c}=YR({multibaseKeyId:n}),l=d.byteLength,p=wc.MULTICODEC_PUBLIC_KEY_LENGTH[u];if(l!==p)throw new dt(rt.InvalidPublicKeyLength,`Expected ${l} bytes. Actual: ${p}`);let m=!1;switch(c){case"secp256k1-pub":m=yield xn.validatePublicKey({publicKeyBytes:d});break;case"ed25519-pub":m=yield Fr.validatePublicKey({publicKeyBytes:d});break;case"x25519-pub":m=!0;break}if(!m)throw new dt(rt.InvalidPublicKey,"Invalid public key detected.");a.id=`${r}#${n}`;try{new URL(a.id)}catch{throw new dt(rt.InvalidDidUrl,"Verification Method ID is not a valid DID URL.")}if(!(s in hz))throw new dt(rt.UnsupportedPublicKeyType,`Unsupported format: ${s}`);if(o===!1&&!["Multikey","JsonWebKey2020","Ed25519VerificationKey2020"].includes(s))throw new dt(rt.InvalidPublicKeyType,`Specified '${s}' without setting enableExperimentalPublicKeyTypes to true.`);if(a.type=s,a.controller=r,s==="Ed25519VerificationKey2020"&&(a.publicKeyMultibase=n),s==="JsonWebKey2020"){let{crv:v}=yield wc.multicodecToJwk({code:u});a.publicKeyJwk=yield wc.keyConverter(v).bytesToPublicKey({publicKeyBytes:d})}return a})}static deriveEncryptionKey(e){return yl(this,arguments,void 0,function*({multibaseValue:r}){let n={keyBytes:new Uint8Array,multicodecCode:0},{keyBytes:i,multicodecCode:o}=YR({multibaseKeyId:r});if(o===237){let s=yield wc.keyConverter("Ed25519").bytesToPublicKey({publicKeyBytes:i}),a=yield Fr.convertPublicKeyToX25519({publicKey:s});n={keyBytes:yield wc.keyConverter("Ed25519").publicKeyToBytes({publicKey:a}),multicodecCode:236}}return n})}static validateIdentifier(e){let{method:r,id:n}=e,[i]=e.uri.split(":",1);return i==="did"&&r==="key"&&Number("1")>0&&r0(n)==="String"&&n.startsWith("z")}};pz.methodName="key";var wc=class t{static jwkToMulticodec(e){return yl(this,arguments,void 0,function*({jwk:r}){let n=[];r.crv&&(n.push(r.crv),r.d?n.push("private"):n.push("public"));let i=n.join(":"),o=t.JWK_TO_MULTICODEC[i];if(o===void 0)throw new Error(`Unsupported JWK to Multicodec conversion: '${i}'`);return{code:la.getCodeFromName({name:o}),name:o}})}static keyCompressor(e){let n={"P-256":Bn.compressPublicKey,secp256k1:xn.compressPublicKey}[e];if(!n)throw new dt(rt.InvalidPublicKeyType,`Unsupported curve: ${e}`);return n}static keyConverter(e){let n={Ed25519:Fr,"P-256":Bn,secp256k1:xn,X25519:d0}[e];if(!n)throw new dt(rt.InvalidPublicKeyType,`Unsupported curve: ${e}`);return n}static multicodecToJwk(e){return yl(this,arguments,void 0,function*({code:r,name:n}){if(!(n?!r:r))throw new Error("Either 'name' or 'code' must be defined, but not both.");n=n===void 0?la.getNameFromCode({code:r}):n;let i=n,o=t.MULTICODEC_TO_JWK[i];if(o===void 0)throw new Error("Unsupported Multicodec to JWK conversion");return Object.assign({},o)})}static publicKeyToMultibaseId(e){return yl(this,arguments,void 0,function*({publicKey:r}){var n;if(!(r?.crv&&r.crv in Vrt))throw new dt(rt.InvalidPublicKeyType,`Public key contains an unsupported key type: ${(n=r?.crv)!==null&&n!==void 0?n:"undefined"}`);let i=yield t.keyConverter(r.crv).publicKeyToBytes({publicKey:r});/^(secp256k1|P-256|P-384|P-521)$/.test(r.crv)&&(i=yield t.keyCompressor(r.crv)({publicKeyBytes:i}));let{name:o}=yield t.jwkToMulticodec({jwk:r});return ZR({keyBytes:i,multicodecName:o})})}};wc.JWK_TO_MULTICODEC={"Ed25519:public":"ed25519-pub","Ed25519:private":"ed25519-priv","secp256k1:public":"secp256k1-pub","secp256k1:private":"secp256k1-priv","X25519:public":"x25519-pub","X25519:private":"x25519-priv"};wc.MULTICODEC_PUBLIC_KEY_LENGTH={231:33,236:32,237:32};wc.MULTICODEC_TO_JWK={"ed25519-pub":{crv:"Ed25519",kty:"OKP",x:""},"ed25519-priv":{crv:"Ed25519",kty:"OKP",x:"",d:""},"secp256k1-pub":{crv:"secp256k1",kty:"EC",x:"",y:""},"secp256k1-priv":{crv:"secp256k1",kty:"EC",x:"",y:"",d:""},"x25519-pub":{crv:"X25519",kty:"OKP",x:""},"x25519-priv":{crv:"X25519",kty:"OKP",x:"",d:""}};f();var Grt=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},mz=class t extends cu{static resolve(e,r){return Grt(this,void 0,void 0,function*(){let n=sr.parse(e);if(!n)return Object.assign(Object.assign({},ui),{didResolutionMetadata:{error:"invalidDid"}});if(n.method!==t.methodName)return Object.assign(Object.assign({},ui),{didResolutionMetadata:{error:"methodNotSupported"}});let i=`https://${n.id.replace(/:/g,"/")}`;i=decodeURIComponent(i);let o=n.id.includes(":")?`${i}/did.json`:`${i}/.well-known/did.json`;try{let s=yield fetch(o);if(!s.ok)throw new Error("HTTP error status code returned");let a=yield s.json();return Object.assign(Object.assign({},ui),{didDocument:a})}catch{return Object.assign(Object.assign({},ui),{didResolutionMetadata:{error:"notFound"}})}})}};mz.methodName="web";f();var Wwe=gt(db(),1),Hwe=gt(WS(),1),Jrt=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},T_=class{constructor({db:e,location:r="DATA/DID_RESOLVERCACHE",ttl:n="15m"}={}){this.cache=e??new Hwe.Level(r),this.ttl=(0,Wwe.default)(n)}get(e){return Jrt(this,void 0,void 0,function*(){try{let r=yield this.cache.get(e),n=JSON.parse(r);if(Date.now()>=n.ttlMillis){this.cache.nextTick(()=>this.cache.del(e));return}else return n.value}catch(r){if(r.notFound)return;throw r}})}set(e,r){let n={ttlMillis:Date.now()+this.ttl,value:r},i=JSON.stringify(n);return this.cache.put(e,i)}delete(e){return this.cache.del(e)}clear(){return this.cache.clear()}close(){return this.cache.close()}};f();var Vwe={get:function(t){return null},set:function(t,e){return null},delete:function(t){return null},clear:function(){return null},close:function(){return null}};f();var Gwe=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},P_=class{constructor({cache:e,didResolvers:r}){this.didResolvers=new Map,this.cache=e||Vwe;for(let n of r)this.didResolvers.set(n.methodName,n)}resolve(e,r){return Gwe(this,void 0,void 0,function*(){let n=sr.parse(e);if(!n)return Object.assign(Object.assign({},ui),{didResolutionMetadata:{error:rt.InvalidDid,errorMessage:`Invalid DID URI: ${e}`}});let i=this.didResolvers.get(n.method);if(!i)return Object.assign(Object.assign({},ui),{didResolutionMetadata:{error:rt.MethodNotSupported,errorMessage:`Method not supported: ${n.method}`}});let o=yield this.cache.get(n.uri);if(o)return o;{let s=yield i.resolve(n.uri,r);return s.didResolutionMetadata.error||(yield this.cache.set(n.uri,s)),s}})}dereference(e,r){return Gwe(this,void 0,void 0,function*(){let n=sr.parse(e);if(!n)return{dereferencingMetadata:{error:rt.InvalidDidUrl},contentStream:null,contentMetadata:{}};let{didDocument:i,didResolutionMetadata:o,didDocumentMetadata:s}=yield this.resolve(n.uri);if(!i)return{dereferencingMetadata:{error:o.error},contentStream:null,contentMetadata:{}};if(!n.fragment||n.query)return{dereferencingMetadata:{contentType:"application/did+json"},contentStream:i,contentMetadata:s};let{service:a=[],verificationMethod:d=[]}=i,u=new Set([e,n.fragment,`#${n.fragment}`]),c;for(let l of d)if(u.has(l.id)){c=l;break}for(let l of a)if(u.has(l.id)){c=l;break}return c?{dereferencingMetadata:{contentType:"application/did+json"},contentStream:c,contentMetadata:o}:{dereferencingMetadata:{error:rt.NotFound},contentStream:null,contentMetadata:{}}})}};var Zrt=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Pb=class extends T_{constructor({agent:e,db:r,location:n,ttl:i}){super({db:r,location:n,ttl:i}),this._resolving=new Map,this._agent=e}get agent(){if(!this._agent)throw new Error("Agent not initialized");return this._agent}set agent(e){this._agent=e}get(e){return Zrt(this,void 0,void 0,function*(){try{let r=yield this.cache.get(e),n=JSON.parse(r);if(!this._resolving.has(e)&&Date.now()>=n.ttlMillis)if(this._resolving.set(e,!0),this.agent.agentDid.uri===e||typeof(yield this.agent.identity.get({didUri:e}))<"u")try{let i=yield this.agent.did.resolve(e);i.didResolutionMetadata.error||this.set(e,i)}finally{this._resolving.delete(e)}else this._resolving.delete(e),this.cache.nextTick(()=>this.cache.del(e));return n.value}catch(r){if(r.notFound)return;throw r}})}};f();var Yrt=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Ib=class{constructor({did:e,metadata:r}){this.did=e,this.metadata=r}export(){return Yrt(this,void 0,void 0,function*(){return{portableDid:yield this.did.export(),metadata:this.metadata}})}};f();f();f();var Xrt=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},rD=class{static deriveKeyBytes({baseKeyBytes:e,length:r,hash:n,salt:i,info:o=new Uint8Array}){return Xrt(this,void 0,void 0,function*(){let a=yield ds().importKey("raw",e,{name:"HKDF"},!1,["deriveBits"]);i=typeof i=="string"?ae.string(i).toUint8Array():i,o=typeof o=="string"?ae.string(o).toUint8Array():o;let d=yield crypto.subtle.deriveBits({name:"HKDF",hash:n,salt:i,info:o},a,r);return new Uint8Array(d)})}};var Qrt=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},ent=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);isuper.delete}});return Dp(this,void 0,void 0,function*(){return yield r.delete.call(this,e)})}get(e){let r=Object.create(null,{get:{get:()=>super.get}});return Dp(this,void 0,void 0,function*(){return yield r.get.call(this,e)})}list(e){let r=Object.create(null,{list:{get:()=>super.list}});return Dp(this,void 0,void 0,function*(){return yield r.list.call(this,e)})}set(e){let r=Object.create(null,{set:{get:()=>super.set}});return Dp(this,void 0,void 0,function*(){return yield r.set.call(this,e)})}getAllRecords({agent:e,tenantDid:r}){var n;return Dp(this,void 0,void 0,function*(){this._index.clear();let{reply:i}=yield e.dwn.processRequest({author:r,target:r,messageType:Ie.RecordsQuery,messageParams:{filter:Object.assign({},this._recordProperties)}}),o=[];for(let s of(n=i.entries)!==null&&n!==void 0?n:[]){if(!s.encodedData)throw new Error(`${this.name}: Expected 'encodedData' to be present in the DWN query result entry`);let a=ae.base64Url(s.encodedData).toObject();if(a5(a)){let d=`${r}${Cs}${a.uri}`;this._index.set(d,s.recordId),this._cache.set(s.recordId,a),o.push(a)}}return o})}},d5=class extends p0{constructor(){super(...arguments),this.name="InMemoryDidStore"}delete(e){let r=Object.create(null,{delete:{get:()=>super.delete}});return Dp(this,void 0,void 0,function*(){return yield r.delete.call(this,e)})}get(e){let r=Object.create(null,{get:{get:()=>super.get}});return Dp(this,void 0,void 0,function*(){return yield r.get.call(this,e)})}list(e){let r=Object.create(null,{list:{get:()=>super.list}});return Dp(this,void 0,void 0,function*(){return yield r.list.call(this,e)})}set(e){let r=Object.create(null,{set:{get:()=>super.set}});return Dp(this,void 0,void 0,function*(){return yield r.set.call(this,e)})}};var m0=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},kb;(function(t){t.Create="Create",t.Resolve="Resolve"})(kb||(kb={}));function Xwe(t,e){return t.messageType===e}var u5=class extends P_{constructor({agent:e,didMethods:r,resolverCache:n,store:i}){if(!r)throw new TypeError("AgentDidApi: Required parameter missing: 'didMethods'");super({didResolvers:r,cache:n??new Pb({agent:e,location:"DATA/AGENT/DID_CACHE"})}),this._didMethods=new Map,this._agent=e,this._store=i??new d5;for(let o of r)this._didMethods.set(o.methodName,o)}get agent(){if(this._agent===void 0)throw new Error("AgentDidApi: Unable to determine agent execution context.");return this._agent}set agent(e){this._agent=e,"agent"in this.cache&&(this.cache.agent=e)}create({method:e,tenant:r,options:n,store:i}){return m0(this,void 0,void 0,function*(){let s=yield this.getMethod(e).create({keyManager:this.agent.keyManager,options:n});if(i??!0){let{uri:a,document:d,metadata:u}=s,c={uri:a,document:d,metadata:u};yield this._store.set({id:c.uri,data:c,agent:this.agent,tenant:r??c.uri,preventDuplicates:!1,useCache:!0})}return s})}export({didUri:e,tenant:r}){return m0(this,void 0,void 0,function*(){let n=yield this.get({didUri:e,tenant:r});if(!n)throw new Error(`AgentDidApi: Failed to export due to DID not found: ${e}`);return yield n.export()})}get({didUri:e,tenant:r}){return m0(this,void 0,void 0,function*(){let n=yield this._store.get({id:e,agent:this.agent,tenant:r,useCache:!0});return n?yield _o.import({portableDid:n,keyManager:this.agent.keyManager}):void 0})}getSigningMethod({didUri:e,methodId:r}){return m0(this,void 0,void 0,function*(){let n=sr.parse(e);if(!n)throw new Error(`Invalid DID URI: ${e}`);let i=this.getMethod(n.method),{didDocument:o,didResolutionMetadata:s}=yield this.resolve(e);if(!o)throw new Error(`DID resolution failed for '${e}': ${JSON.stringify(s)}`);return yield i.getSigningMethod({didDocument:o,methodId:r})})}import({portableDid:e,tenant:r}){return m0(this,void 0,void 0,function*(){let n=yield _o.import({keyManager:this.agent.keyManager,portableDid:e}),{uri:i,document:o,metadata:s}=n,a={uri:i,document:o,metadata:s};return yield this._store.set({id:a.uri,data:a,agent:this.agent,tenant:r??a.uri,preventDuplicates:!0,useCache:!0}),n})}delete({didUri:e,tenant:r,deleteKey:n=!0}){return m0(this,void 0,void 0,function*(){let i=yield this._store.get({id:e,agent:this.agent,tenant:r,useCache:!1});if(!i)throw new Error("AgentDidApi: Could not delete, DID not found");yield this._store.delete({id:e,agent:this.agent,tenant:r}),n&&(yield this.deleteKeys({portableDid:i}))})}deleteKeys({portableDid:e}){return m0(this,void 0,void 0,function*(){for(let r of e.document.verificationMethod||[]){if(!r.publicKeyJwk)continue;let n=yield this.agent.keyManager.getKeyUri({key:r.publicKeyJwk});yield this.agent.keyManager.deleteKey({keyUri:n})}})}processRequest(e){var r;return m0(this,void 0,void 0,function*(){if(Xwe(e,kb.Create))try{let n=yield this.create(Object.assign({},e.messageParams));return{result:{uri:n.uri,document:n.document,metadata:n.metadata},ok:!0,status:{code:201,message:"Created"}}}catch(n){return{ok:!1,status:{code:500,message:(r=n.message)!==null&&r!==void 0?r:"Unknown error occurred"}}}if(Xwe(e,kb.Resolve)){let{didUri:n,options:i}=e.messageParams;return{result:yield this.resolve(n,i),ok:!0,status:{code:200,message:"OK"}}}throw new Error(`AgentDidApi: Unsupported request type: ${e.messageType}`)})}getMethod(e){let r=this._didMethods.get(e);if(r===void 0)throw new Error(`DID Method not supported: ${e}`);return r}};f();f();var e1e=gt(Qwe(),1);var vz=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})};function bz(t){return hD(t.stream())}function fD(t,e){return vz(this,void 0,void 0,function*(){let r=yield e.dereference(`${t}#dwn`);if(r.dereferencingMetadata.error)throw new Error(`Failed to dereference '${t}#dwn': ${r.dereferencingMetadata.error}`);if(XR.isDwnDidService(r.contentStream)){let{serviceEndpoint:n}=r.contentStream,i=typeof n=="string"?[n]:Array.isArray(n)&&n.every(o=>typeof o=="string")?n:[];if(i.length>0)return i}return[]})}function Lf(t){return _e.getAuthor(t)}function Rb(t){return!t||typeof t!="object"||t===null?!1:"message"in t&&typeof t.message=="object"&&t.message!==null&&"descriptor"in t.message&&typeof t.message.descriptor=="object"&&t.message.descriptor!==null&&"interface"in t.message.descriptor&&t.message.descriptor.interface===Te.Records&&"method"in t.message.descriptor&&t.message.descriptor.method===Se.Write}function snt(t){return _e.getCid(t)}function t1e(t,e){return vz(this,void 0,void 0,function*(){let r=e===Vi.CreatedAscending||e===Vi.CreatedDescending?t.descriptor.dateCreated:t.descriptor.datePublished;if(r===void 0)throw new Error("The dateCreated or datePublished property is missing from the record descriptor.");return{messageCid:yield snt(t),value:r}})}function hD(t){return new e1e.ReadableWebToNodeStream(t)}function r1e(t,e=3e3,r=3e5,n){let i=Date.now()+r,o=null,s=!0;return new Promise((a,d)=>{n&&n.addEventListener("abort",()=>{s=!1,o!==null&&clearTimeout(o),console.log("Polling aborted by user"),a(null)});function u(){return vz(this,void 0,void 0,function*(){if(!s)return;let c=i-Date.now();if(c<=0){s=!1,console.log("Polling stopped: TTL reached"),a(null);return}console.log(`Polling... (Remaining time: ${Math.ceil(c/1e3)}s)`);try{let l=yield t();if(l.ok){s=!1,o!==null&&clearTimeout(o),console.log("Polling stopped: Success condition met"),a(l);return}}catch(l){console.error("Error fetching data:",l),d(l)}s&&(o=setTimeout(u,e))})}u()})}function Bp(t,e){return t.endsWith("/")&&(t=t.slice(0,-1)),e.startsWith("/")&&(e=e.slice(1)),`${t}/${e}`}var Mp=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})};function ant(t,e){return t.messageType===e}function pD(t,e){return e.descriptor.interface+e.descriptor.method===t}function n1e(t){return t===Ie.RecordsDelete||t===Ie.RecordsQuery||t===Ie.RecordsRead||t===Ie.RecordsSubscribe||t===Ie.RecordsWrite}function i1e(t){return t.interface===Te.Records}var R_=class{constructor({agent:e,dwn:r}){this._agent=e,this._dwn=r}get agent(){if(this._agent===void 0)throw new Error("AgentDwnApi: Unable to determine agent execution context.");return this._agent}set agent(e){this._agent=e}get node(){return this._dwn}static createDwn({dataPath:e,dataStore:r,didResolver:n,eventLog:i,eventStream:o,messageStore:s,tenantGate:a,resumableTaskStore:d}){return Mp(this,void 0,void 0,function*(){return r??(r=new b_({blockstoreLocation:`${e}/DWN_DATASTORE`})),n??(n=new P_({didResolvers:[du,Wa],cache:new T_({location:`${e}/DID_RESOLVERCACHE`})})),i??(i=new x_({location:`${e}/DWN_EVENTLOG`})),s??(s=new E_({blockstoreLocation:`${e}/DWN_MESSAGESTORE`,indexLocation:`${e}/DWN_MESSAGEINDEX`})),d??(d=new bb({location:`${e}/DWN_RESUMABLETASKSTORE`})),yield k3.create({dataStore:r,didResolver:n,eventLog:i,eventStream:o,messageStore:s,tenantGate:a,resumableTaskStore:d})})}processRequest(e){return Mp(this,void 0,void 0,function*(){let{message:r,dataStream:n}=yield this.constructDwnMessage({request:e}),{subscriptionHandler:i}=e;return{reply:e.store!==!1?yield this._dwn.processMessage(e.target,r,{dataStream:n,subscriptionHandler:i}):{status:{code:202,detail:"Accepted"}},message:r,messageCid:yield _e.getCid(r)}})}sendRequest(e){return Mp(this,void 0,void 0,function*(){let r=yield fD(e.target,this.agent.did);if(r.length===0)throw new Error(`AgentDwnApi: DID Service is missing or malformed: ${e.target}#dwn`);let n,i,o,s;if("messageCid"in e)({message:i,data:o}=yield this.getDwnMessage({author:e.author,messageCid:e.messageCid,messageType:e.messageType})),n=e.messageCid;else{if({message:i}=yield this.constructDwnMessage({request:e}),e.dataStream&&!(e.dataStream instanceof Blob))throw new Error("AgentDwnApi: DataStream must be provided as a Blob");o=e.dataStream,s=e.subscriptionHandler}let a=yield this.sendDwnRpcRequest({targetDid:e.target,dwnEndpointUrls:r,message:i,data:o,subscriptionHandler:s});return n??(n=yield _e.getCid(i)),{reply:a,message:i,messageCid:n}})}sendDwnRpcRequest({targetDid:e,dwnEndpointUrls:r,message:n,data:i,subscriptionHandler:o}){return Mp(this,void 0,void 0,function*(){let s=[];if(n.descriptor.method===Se.Subscribe&&o===void 0)throw new Error("AgentDwnApi: Subscription handler is required for subscription requests.");for(let a of r)try{if(o!==void 0){if(!(yield this.agent.rpc.getServerInfo(a)).webSocketSupport){s.push({url:a,message:"WebSocket support is not enabled on the server."});continue}let c=new URL(a);c.protocol=c.protocol==="http:"?"ws:":"wss:",a=c.toString()}return yield this.agent.rpc.sendDwnRequest({dwnUrl:a,targetDid:e,message:n,data:i,subscriptionHandler:o})}catch(d){s.push({url:a,message:d instanceof Error?d.message:"Unknown error"})}throw new Error(`Failed to send DWN RPC request: ${JSON.stringify(s)}`)})}constructDwnMessage({request:e}){var r;return Mp(this,void 0,void 0,function*(){if(e.granteeDid&&!this.hasGrantParams(e.messageParams))throw new Error("AgentDwnApi: Requested to sign with a permission but no grant messageParams were provided in the request");let n=e.rawMessage,i;if(ant(e,Ie.RecordsWrite)){let a=e.messageParams;if(e.dataStream&&!a?.data){let{dataStream:d}=e,u;if(d instanceof Blob)u=bz(d),i=bz(d);else if(d instanceof ReadableStream){let[c,l]=d.tee();u=hD(c),i=hD(l)}n||(a.dataCid=yield fn.computeDagPbCidFromStream(u),(r=a.dataSize)!==null&&r!==void 0||(a.dataSize=u.bytesRead))}}let o,s=iz[e.messageType];if(n){if(o=yield s.parse(n),Rb(o)&&e.signAsOwner){let a=yield this.getSigner(e.author);yield o.signAsOwner(a)}else if(e.granteeDid&&Rb(o)&&e.signAsOwnerDelegate){let a=yield this.getSigner(e.granteeDid),d=e.messageParams;yield o.signAsOwnerDelegate(a,d.delegatedGrant)}}else{let a=e.granteeDid?yield this.getSigner(e.granteeDid):yield this.getSigner(e.author);o=yield s.create(Object.assign(Object.assign({},e.messageParams),{signer:a}))}return{message:o.message,dataStream:i}})}hasGrantParams(e){return e!==void 0&&("permissionGrantId"in e&&e.permissionGrantId!==void 0||"delegatedGrant"in e&&e.delegatedGrant!==void 0)}getSigner(e){return Mp(this,void 0,void 0,function*(){if(e===this.agent.agentDid.uri){let r=yield this.agent.agentDid.getSigner();return{algorithm:r.algorithm,keyId:r.keyId,sign:n=>Mp(this,void 0,void 0,function*(){return yield r.sign({data:n})})}}else try{let r=yield this.agent.did.getSigningMethod({didUri:e});if(!r.publicKeyJwk)throw new Error(`Verification method '${r.id}' does not contain a public key in JWK format`);let n=yield this.agent.keyManager.getKeyUri({key:r.publicKeyJwk}),i=yield this.agent.keyManager.getPublicKey({keyUri:n}),o=this.agent.keyManager;return{algorithm:Mn.getJoseSignatureAlgorithmFromPublicKey(i),keyId:r.id,sign:s=>Mp(this,void 0,void 0,function*(){return yield o.sign({data:s,keyUri:n})})}}catch(r){throw new Error(`AgentDwnApi: Unable to get signer for author '${e}': ${r.message}`)}})}getDwnMessage({author:e,messageCid:r}){return Mp(this,void 0,void 0,function*(){let n=yield this.getSigner(e),i=yield iz[Ie.MessagesRead].create({messageCid:r,signer:n}),o=yield this._dwn.processMessage(e,i.message);if(o.status.code!==200)throw new Error(`AgentDwnApi: Failed to read message, response status: ${o.status.code} - ${o.status.detail}`);let s=o.entry,d={message:s.message};if(Rb(s)&&s.data){let u=yield Jo.consumeToBytes({readable:s.data});d.data=new Blob([u],{type:s.message.descriptor.dataFormat})}return d})}};f();var mD=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},l5=class t{static registerTenant(e,r){return mD(this,void 0,void 0,function*(){let n=Bp(e,"registration"),i=Bp(n,"terms-of-service"),o=Bp(n,"proof-of-work"),s=yield fetch(i,{method:"GET"});if(s.status!==200){let v=s.status,x=s.statusText,S=yield s.text();throw new Error(`Failed fetching terms-of-service: ${v} ${x}: ${S}`)}let a=yield s.text(),d=yield fetch(o,{method:"GET"}),{challengeNonce:u,maximumAllowedHashValue:c}=yield d.json(),l={did:r,termsOfServiceHash:yield t.hashAsHexString(a)},p=yield t.findQualifiedResponseNonce({challengeNonce:u,maximumAllowedHashValue:c,requestData:JSON.stringify(l)}),g=yield fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({registrationData:l,proofOfWork:{challengeNonce:u,responseNonce:p}})});if(g.status!==200){let v=g.status,x=g.statusText,S=yield g.text();throw new Error(`Registration failed: ${v} ${x}: ${S}`)}})}static hashAsHexString(e){return mD(this,void 0,void 0,function*(){let r=yield Nf.digest({data:ae.string(e).toUint8Array()});return ae.uint8Array(r).toHex()})}static findQualifiedResponseNonce(e){return mD(this,void 0,void 0,function*(){let r=Date.now(),{maximumAllowedHashValue:n,challengeNonce:i,requestData:o}=e,s=BigInt(`0x${n}`),a=1,d,u=!1;do{d=yield this.generateNonce();let c=yield t.hashAsHexString(i+d+o);u=BigInt(`0x${c}`)<=s,a++}while(!u);return console.log(`iterations: ${a}, time lapsed: ${Date.now()-r} ms`),d})}static generateNonce(){return mD(this,void 0,void 0,function*(){let e=Mn.randomBytes(32);return ae.uint8Array(e).toHex().toUpperCase()})}};f();f();f();var cnt=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),s1e=Uint8Array.from({length:16},(t,e)=>e),dnt=s1e.map(t=>(9*t+5)%16),_z=[s1e],xz=[dnt];for(let t=0;t<4;t++)for(let e of[_z,xz])e.push(e[t].map(r=>cnt[r]));var a1e=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(t=>new Uint8Array(t)),unt=_z.map((t,e)=>t.map(r=>a1e[e][r])),lnt=xz.map((t,e)=>t.map(r=>a1e[e][r])),fnt=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),hnt=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]),yD=(t,e)=>t<>>32-e;function o1e(t,e,r,n){return t===0?e^r^n:t===1?e&r|~e&n:t===2?(e|~r)^n:t===3?e&n|r&~n:e^(r|~n)}var gD=new Uint32Array(16),wz=class extends Oy{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){let{h0:e,h1:r,h2:n,h3:i,h4:o}=this;return[e,r,n,i,o]}set(e,r,n,i,o){this.h0=e|0,this.h1=r|0,this.h2=n|0,this.h3=i|0,this.h4=o|0}process(e,r){for(let m=0;m<16;m++,r+=4)gD[m]=e.getUint32(r,!0);let n=this.h0|0,i=n,o=this.h1|0,s=o,a=this.h2|0,d=a,u=this.h3|0,c=u,l=this.h4|0,p=l;for(let m=0;m<5;m++){let g=4-m,v=fnt[m],x=hnt[m],S=_z[m],P=xz[m],A=unt[m],$=lnt[m];for(let j=0;j<16;j++){let L=yD(n+o1e(m,o,a,u)+gD[S[j]]+v,A[j])+l|0;n=l,l=u,u=yD(a,10)|0,a=o,o=L}for(let j=0;j<16;j++){let L=yD(i+o1e(g,s,d,c)+gD[P[j]]+x,$[j])+p|0;i=p,p=c,c=yD(d,10)|0,d=s,s=L}}this.set(this.h1+a+c|0,this.h2+u+p|0,this.h3+l+i|0,this.h4+n+s|0,this.h0+o+d|0)}roundClean(){gD.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}},c1e=q2(()=>new wz);var pnt=r3("ed25519 seed"),Ez=2147483648,d1e=new Uint8Array([0]);function u1e(t,...e){return typeof t=="string"&&(t=K0e(t)),cp(t,...e),t}var mnt=t=>c1e(jy(t)),ynt=t=>up(t).getUint32(0,!1),Sz=t=>{if(!Number.isSafeInteger(t)||t<0||t>2**32-1)throw new Error(`Invalid number=${t}. Should be from 0 to 2 ** 32 - 1`);let e=new Uint8Array(4);return up(e).setUint32(0,t,!1),e},vD=class t{get publicKeyRaw(){return yo.getPublicKey(this.privateKey)}get publicKey(){return Xv(d1e,this.publicKeyRaw)}get pubHash(){return mnt(this.publicKey)}get fingerprint(){return ynt(this.pubHash)}get fingerprintHex(){return KK(Sz(this.fingerprint))}get parentFingerprintHex(){return KK(Sz(this.parentFingerprint))}static fromMasterSeed(e){if(e=u1e(e),8*e.length<128||8*e.length>512)throw new Error(`HDKey: wrong seed length=${e.length}. Should be between 128 and 512 bits; 256 bits is advised)`);let r=Ny(Ly,pnt,e);return new t({privateKey:r.slice(0,32),chainCode:r.slice(32)})}constructor(e){if(this.depth=0,this.index=0,this.parentFingerprint=0,!e||typeof e!="object")throw new Error("HDKey.constructor must not be called directly");if(cp(e.privateKey,32),cp(e.chainCode,32),this.depth=e.depth||0,this.index=e.index||0,this.parentFingerprint=e.parentFingerprint||0,!this.depth&&(this.parentFingerprint||this.index))throw new Error("HDKey: zero depth with non-zero index/parent fingerprint");this.chainCode=e.chainCode,this.privateKey=e.privateKey}derive(e,r=!1){if(!/^[mM]'?/.test(e))throw new Error('Path must start with "m" or "M"');if(/^[mM]'?$/.test(e))return this;let n=e.replace(/^[mM]'?\//,"").split("/"),i=this;for(let o of n){let s=/^(\d+)('?)$/.exec(o);if(!s||s.length!==3)throw new Error(`Invalid child index: ${o}`);let a=+s[1];if(!Number.isSafeInteger(a)||a>=Ez)throw new Error("Invalid index");(r||s[2]==="'")&&(a+=Ez),i=i.deriveChild(a)}return i}deriveChild(e){if(e{for(let u of a)(0,bS.checkReportMissingProp)(t,u)}):(r.if((0,sq._)`${d} && (${(0,bS.checkMissingProp)(t,a,o)})`),(0,bS.reportMissingProp)(t,o),r.else())}}gf.validatePropertyDeps=ohe;function she(t,e=t.schema){let{gen:r,data:n,keyword:i,it:o}=t,s=r.name("valid");for(let a in e)(0,kze.alwaysValidSchema)(o,e[a])||(r.if((0,bS.propertyInData)(r,n,a,o.opts.ownProperties),()=>{let d=t.subschema({keyword:i,schemaProp:a},s);t.mergeValidEvaluated(d,s)},()=>r.var(s,!0)),t.ok(s))}gf.validateSchemaDeps=she;gf.default=Rze});var che=V(aq=>{"use strict";f();Object.defineProperty(aq,"__esModule",{value:!0});var ahe=rr(),Bze=Rr(),Mze={message:"property name must be valid",params:({params:t})=>(0,ahe._)`{propertyName: ${t.propertyName}}`},Oze={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:Mze,code(t){let{gen:e,schema:r,data:n,it:i}=t;if((0,Bze.alwaysValidSchema)(i,r))return;let o=e.name("valid");e.forIn("key",n,s=>{t.setParams({propertyName:s}),t.subschema({keyword:"propertyNames",data:s,dataTypes:["string"],propertyName:s,compositeRule:!0},o),e.if((0,ahe.not)(o),()=>{t.error(!0),i.allErrors||e.break()})}),t.ok(o)}};aq.default=Oze});var dq=V(cq=>{"use strict";f();Object.defineProperty(cq,"__esModule",{value:!0});var lI=Wd(),Qu=rr(),Cze=zd(),fI=Rr(),$ze={message:"must NOT have additional properties",params:({params:t})=>(0,Qu._)`{additionalProperty: ${t.additionalProperty}}`},jze={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:$ze,code(t){let{gen:e,schema:r,parentSchema:n,data:i,errsCount:o,it:s}=t;if(!o)throw new Error("ajv implementation error");let{allErrors:a,opts:d}=s;if(s.props=!0,d.removeAdditional!=="all"&&(0,fI.alwaysValidSchema)(s,r))return;let u=(0,lI.allSchemaProperties)(n.properties),c=(0,lI.allSchemaProperties)(n.patternProperties);l(),t.ok((0,Qu._)`${o} === ${Cze.default.errors}`);function l(){e.forIn("key",i,x=>{!u.length&&!c.length?g(x):e.if(p(x),()=>g(x))})}function p(x){let S;if(u.length>8){let P=(0,fI.schemaRefOrVal)(s,n.properties,"properties");S=(0,lI.isOwnProperty)(e,P,x)}else u.length?S=(0,Qu.or)(...u.map(P=>(0,Qu._)`${x} === ${P}`)):S=Qu.nil;return c.length&&(S=(0,Qu.or)(S,...c.map(P=>(0,Qu._)`${(0,lI.usePattern)(t,P)}.test(${x})`))),(0,Qu.not)(S)}function m(x){e.code((0,Qu._)`delete ${i}[${x}]`)}function g(x){if(d.removeAdditional==="all"||d.removeAdditional&&r===!1){m(x);return}if(r===!1){t.setParams({additionalProperty:x}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,fI.alwaysValidSchema)(s,r)){let S=e.name("valid");d.removeAdditional==="failing"?(v(x,S,!1),e.if((0,Qu.not)(S),()=>{t.reset(),m(x)})):(v(x,S),a||e.if((0,Qu.not)(S),()=>e.break()))}}function v(x,S,P){let A={keyword:"additionalProperties",dataProp:x,dataPropType:fI.Type.Str};P===!1&&Object.assign(A,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(A,S)}}};cq.default=jze});var lhe=V(lq=>{"use strict";f();Object.defineProperty(lq,"__esModule",{value:!0});var Nze=sS(),dhe=Wd(),uq=Rr(),uhe=dq(),Uze={keyword:"properties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,parentSchema:n,data:i,it:o}=t;o.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&uhe.default.code(new Nze.KeywordCxt(o,uhe.default,"additionalProperties"));let s=(0,dhe.allSchemaProperties)(r);for(let l of s)o.definedProperties.add(l);o.opts.unevaluated&&s.length&&o.props!==!0&&(o.props=uq.mergeEvaluated.props(e,(0,uq.toHash)(s),o.props));let a=s.filter(l=>!(0,uq.alwaysValidSchema)(o,r[l]));if(a.length===0)return;let d=e.name("valid");for(let l of a)u(l)?c(l):(e.if((0,dhe.propertyInData)(e,i,l,o.opts.ownProperties)),c(l),o.allErrors||e.else().var(d,!0),e.endIf()),t.it.definedProperties.add(l),t.ok(d);function u(l){return o.opts.useDefaults&&!o.compositeRule&&r[l].default!==void 0}function c(l){t.subschema({keyword:"properties",schemaProp:l,dataProp:l},d)}}};lq.default=Uze});var mhe=V(fq=>{"use strict";f();Object.defineProperty(fq,"__esModule",{value:!0});var fhe=Wd(),hI=rr(),hhe=Rr(),phe=Rr(),qze={keyword:"patternProperties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,data:n,parentSchema:i,it:o}=t,{opts:s}=o,a=(0,fhe.allSchemaProperties)(r),d=a.filter(v=>(0,hhe.alwaysValidSchema)(o,r[v]));if(a.length===0||d.length===a.length&&(!o.opts.unevaluated||o.props===!0))return;let u=s.strictSchema&&!s.allowMatchingProperties&&i.properties,c=e.name("valid");o.props!==!0&&!(o.props instanceof hI.Name)&&(o.props=(0,phe.evaluatedPropsToName)(e,o.props));let{props:l}=o;p();function p(){for(let v of a)u&&m(v),o.allErrors?g(v):(e.var(c,!0),g(v),e.if(c))}function m(v){for(let x in u)new RegExp(v).test(x)&&(0,hhe.checkStrictMode)(o,`property ${x} matches pattern ${v} (use allowMatchingProperties)`)}function g(v){e.forIn("key",n,x=>{e.if((0,hI._)`${(0,fhe.usePattern)(t,v)}.test(${x})`,()=>{let S=d.includes(v);S||t.subschema({keyword:"patternProperties",schemaProp:v,dataProp:x,dataPropType:phe.Type.Str},c),o.opts.unevaluated&&l!==!0?e.assign((0,hI._)`${l}[${x}]`,!0):!S&&!o.allErrors&&e.if((0,hI.not)(c),()=>e.break())})})}}};fq.default=qze});var yhe=V(hq=>{"use strict";f();Object.defineProperty(hq,"__esModule",{value:!0});var Lze=Rr(),Kze={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:n}=t;if((0,Lze.alwaysValidSchema)(n,r)){t.fail();return}let i=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},i),t.failResult(i,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};hq.default=Kze});var ghe=V(pq=>{"use strict";f();Object.defineProperty(pq,"__esModule",{value:!0});var Fze=Wd(),zze={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:Fze.validateUnion,error:{message:"must match a schema in anyOf"}};pq.default=zze});var vhe=V(mq=>{"use strict";f();Object.defineProperty(mq,"__esModule",{value:!0});var pI=rr(),Wze=Rr(),Hze={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,pI._)`{passingSchemas: ${t.passing}}`},Vze={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:Hze,code(t){let{gen:e,schema:r,parentSchema:n,it:i}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(i.opts.discriminator&&n.discriminator)return;let o=r,s=e.let("valid",!1),a=e.let("passing",null),d=e.name("_valid");t.setParams({passing:a}),e.block(u),t.result(s,()=>t.reset(),()=>t.error(!0));function u(){o.forEach((c,l)=>{let p;(0,Wze.alwaysValidSchema)(i,c)?e.var(d,!0):p=t.subschema({keyword:"oneOf",schemaProp:l,compositeRule:!0},d),l>0&&e.if((0,pI._)`${d} && ${s}`).assign(s,!1).assign(a,(0,pI._)`[${a}, ${l}]`).else(),e.if(d,()=>{e.assign(s,!0),e.assign(a,l),p&&t.mergeEvaluated(p,pI.Name)})})}}};mq.default=Vze});var bhe=V(yq=>{"use strict";f();Object.defineProperty(yq,"__esModule",{value:!0});var Gze=Rr(),Jze={keyword:"allOf",schemaType:"array",code(t){let{gen:e,schema:r,it:n}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");let i=e.name("valid");r.forEach((o,s)=>{if((0,Gze.alwaysValidSchema)(n,o))return;let a=t.subschema({keyword:"allOf",schemaProp:s},i);t.ok(i),t.mergeEvaluated(a)})}};yq.default=Jze});var xhe=V(gq=>{"use strict";f();Object.defineProperty(gq,"__esModule",{value:!0});var mI=rr(),_he=Rr(),Zze={message:({params:t})=>(0,mI.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,mI._)`{failingKeyword: ${t.ifClause}}`},Yze={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:Zze,code(t){let{gen:e,parentSchema:r,it:n}=t;r.then===void 0&&r.else===void 0&&(0,_he.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let i=whe(n,"then"),o=whe(n,"else");if(!i&&!o)return;let s=e.let("valid",!0),a=e.name("_valid");if(d(),t.reset(),i&&o){let c=e.let("ifClause");t.setParams({ifClause:c}),e.if(a,u("then",c),u("else",c))}else i?e.if(a,u("then")):e.if((0,mI.not)(a),u("else"));t.pass(s,()=>t.error(!0));function d(){let c=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);t.mergeEvaluated(c)}function u(c,l){return()=>{let p=t.subschema({keyword:c},a);e.assign(s,a),t.mergeValidEvaluated(p,s),l?e.assign(l,(0,mI._)`${c}`):t.setParams({ifClause:c})}}}};function whe(t,e){let r=t.schema[e];return r!==void 0&&!(0,_he.alwaysValidSchema)(t,r)}gq.default=Yze});var Ehe=V(vq=>{"use strict";f();Object.defineProperty(vq,"__esModule",{value:!0});var Xze=Rr(),Qze={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,Xze.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};vq.default=Qze});var She=V(bq=>{"use strict";f();Object.defineProperty(bq,"__esModule",{value:!0});var eWe=tq(),tWe=the(),rWe=rq(),nWe=nhe(),iWe=ihe(),oWe=uI(),sWe=che(),aWe=dq(),cWe=lhe(),dWe=mhe(),uWe=yhe(),lWe=ghe(),fWe=vhe(),hWe=bhe(),pWe=xhe(),mWe=Ehe();function yWe(t=!1){let e=[uWe.default,lWe.default,fWe.default,hWe.default,pWe.default,mWe.default,sWe.default,aWe.default,oWe.default,cWe.default,dWe.default];return t?e.push(tWe.default,nWe.default):e.push(eWe.default,rWe.default),e.push(iWe.default),e}bq.default=yWe});var _q=V(wS=>{"use strict";f();Object.defineProperty(wS,"__esModule",{value:!0});wS.dynamicAnchor=void 0;var wq=rr(),gWe=zd(),Ahe=aS(),vWe=nI(),bWe={keyword:"$dynamicAnchor",schemaType:"string",code:t=>The(t,t.schema)};function The(t,e){let{gen:r,it:n}=t;n.schemaEnv.root.dynamicAnchors[e]=!0;let i=(0,wq._)`${gWe.default.dynamicAnchors}${(0,wq.getProperty)(e)}`,o=n.errSchemaPath==="#"?n.validateName:wWe(t);r.if((0,wq._)`!${i}`,()=>r.assign(i,o))}wS.dynamicAnchor=The;function wWe(t){let{schemaEnv:e,schema:r,self:n}=t.it,{root:i,baseId:o,localRefs:s,meta:a}=e.root,{schemaId:d}=n.opts,u=new Ahe.SchemaEnv({schema:r,schemaId:d,root:i,baseId:o,localRefs:s,meta:a});return Ahe.compileSchema.call(n,u),(0,vWe.getValidate)(t,u)}wS.default=bWe});var xq=V(_S=>{"use strict";f();Object.defineProperty(_S,"__esModule",{value:!0});_S.dynamicRef=void 0;var Phe=rr(),_We=zd(),Ihe=nI(),xWe={keyword:"$dynamicRef",schemaType:"string",code:t=>khe(t,t.schema)};function khe(t,e){let{gen:r,keyword:n,it:i}=t;if(e[0]!=="#")throw new Error(`"${n}" only supports hash fragment reference`);let o=e.slice(1);if(i.allErrors)s();else{let d=r.let("valid",!1);s(d),t.ok(d)}function s(d){if(i.schemaEnv.root.dynamicAnchors[o]){let u=r.let("_v",(0,Phe._)`${_We.default.dynamicAnchors}${(0,Phe.getProperty)(o)}`);r.if(u,a(u,d),a(i.validateName,d))}else a(i.validateName,d)()}function a(d,u){return u?()=>r.block(()=>{(0,Ihe.callRef)(t,d),r.let(u,!0)}):()=>(0,Ihe.callRef)(t,d)}}_S.dynamicRef=khe;_S.default=xWe});var Rhe=V(Eq=>{"use strict";f();Object.defineProperty(Eq,"__esModule",{value:!0});var EWe=_q(),SWe=Rr(),AWe={keyword:"$recursiveAnchor",schemaType:"boolean",code(t){t.schema?(0,EWe.dynamicAnchor)(t,""):(0,SWe.checkStrictMode)(t.it,"$recursiveAnchor: false is ignored")}};Eq.default=AWe});var Dhe=V(Sq=>{"use strict";f();Object.defineProperty(Sq,"__esModule",{value:!0});var TWe=xq(),PWe={keyword:"$recursiveRef",schemaType:"string",code:t=>(0,TWe.dynamicRef)(t,t.schema)};Sq.default=PWe});var Bhe=V(Aq=>{"use strict";f();Object.defineProperty(Aq,"__esModule",{value:!0});var IWe=_q(),kWe=xq(),RWe=Rhe(),DWe=Dhe(),BWe=[IWe.default,kWe.default,RWe.default,DWe.default];Aq.default=BWe});var Ohe=V(Tq=>{"use strict";f();Object.defineProperty(Tq,"__esModule",{value:!0});var Mhe=uI(),MWe={keyword:"dependentRequired",type:"object",schemaType:"object",error:Mhe.error,code:t=>(0,Mhe.validatePropertyDeps)(t)};Tq.default=MWe});var Che=V(Pq=>{"use strict";f();Object.defineProperty(Pq,"__esModule",{value:!0});var OWe=uI(),CWe={keyword:"dependentSchemas",type:"object",schemaType:"object",code:t=>(0,OWe.validateSchemaDeps)(t)};Pq.default=CWe});var $he=V(Iq=>{"use strict";f();Object.defineProperty(Iq,"__esModule",{value:!0});var $We=Rr(),jWe={keyword:["maxContains","minContains"],type:"array",schemaType:"number",code({keyword:t,parentSchema:e,it:r}){e.contains===void 0&&(0,$We.checkStrictMode)(r,`"${t}" without "contains" is ignored`)}};Iq.default=jWe});var jhe=V(kq=>{"use strict";f();Object.defineProperty(kq,"__esModule",{value:!0});var NWe=Ohe(),UWe=Che(),qWe=$he(),LWe=[NWe.default,UWe.default,qWe.default];kq.default=LWe});var Uhe=V(Rq=>{"use strict";f();Object.defineProperty(Rq,"__esModule",{value:!0});var vy=rr(),Nhe=Rr(),KWe=zd(),FWe={message:"must NOT have unevaluated properties",params:({params:t})=>(0,vy._)`{unevaluatedProperty: ${t.unevaluatedProperty}}`},zWe={keyword:"unevaluatedProperties",type:"object",schemaType:["boolean","object"],trackErrors:!0,error:FWe,code(t){let{gen:e,schema:r,data:n,errsCount:i,it:o}=t;if(!i)throw new Error("ajv implementation error");let{allErrors:s,props:a}=o;a instanceof vy.Name?e.if((0,vy._)`${a} !== true`,()=>e.forIn("key",n,l=>e.if(u(a,l),()=>d(l)))):a!==!0&&e.forIn("key",n,l=>a===void 0?d(l):e.if(c(a,l),()=>d(l))),o.props=!0,t.ok((0,vy._)`${i} === ${KWe.default.errors}`);function d(l){if(r===!1){t.setParams({unevaluatedProperty:l}),t.error(),s||e.break();return}if(!(0,Nhe.alwaysValidSchema)(o,r)){let p=e.name("valid");t.subschema({keyword:"unevaluatedProperties",dataProp:l,dataPropType:Nhe.Type.Str},p),s||e.if((0,vy.not)(p),()=>e.break())}}function u(l,p){return(0,vy._)`!${l} || !${l}[${p}]`}function c(l,p){let m=[];for(let g in l)l[g]===!0&&m.push((0,vy._)`${p} !== ${g}`);return(0,vy.and)(...m)}}};Rq.default=zWe});var Lhe=V(Dq=>{"use strict";f();Object.defineProperty(Dq,"__esModule",{value:!0});var Ev=rr(),qhe=Rr(),WWe={message:({params:{len:t}})=>(0,Ev.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,Ev._)`{limit: ${t}}`},HWe={keyword:"unevaluatedItems",type:"array",schemaType:["boolean","object"],error:WWe,code(t){let{gen:e,schema:r,data:n,it:i}=t,o=i.items||0;if(o===!0)return;let s=e.const("len",(0,Ev._)`${n}.length`);if(r===!1)t.setParams({len:o}),t.fail((0,Ev._)`${s} > ${o}`);else if(typeof r=="object"&&!(0,qhe.alwaysValidSchema)(i,r)){let d=e.var("valid",(0,Ev._)`${s} <= ${o}`);e.if((0,Ev.not)(d),()=>a(d,o)),t.ok(d)}i.items=!0;function a(d,u){e.forRange("i",u,s,c=>{t.subschema({keyword:"unevaluatedItems",dataProp:c,dataPropType:qhe.Type.Num},d),i.allErrors||e.if((0,Ev.not)(d),()=>e.break())})}}};Dq.default=HWe});var Khe=V(Bq=>{"use strict";f();Object.defineProperty(Bq,"__esModule",{value:!0});var VWe=Uhe(),GWe=Lhe(),JWe=[VWe.default,GWe.default];Bq.default=JWe});var Fhe=V(Mq=>{"use strict";f();Object.defineProperty(Mq,"__esModule",{value:!0});var Oi=rr(),ZWe={message:({schemaCode:t})=>(0,Oi.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,Oi._)`{format: ${t}}`},YWe={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:ZWe,code(t,e){let{gen:r,data:n,$data:i,schema:o,schemaCode:s,it:a}=t,{opts:d,errSchemaPath:u,schemaEnv:c,self:l}=a;if(!d.validateFormats)return;i?p():m();function p(){let g=r.scopeValue("formats",{ref:l.formats,code:d.code.formats}),v=r.const("fDef",(0,Oi._)`${g}[${s}]`),x=r.let("fType"),S=r.let("format");r.if((0,Oi._)`typeof ${v} == "object" && !(${v} instanceof RegExp)`,()=>r.assign(x,(0,Oi._)`${v}.type || "string"`).assign(S,(0,Oi._)`${v}.validate`),()=>r.assign(x,(0,Oi._)`"string"`).assign(S,v)),t.fail$data((0,Oi.or)(P(),A()));function P(){return d.strictSchema===!1?Oi.nil:(0,Oi._)`${s} && !${S}`}function A(){let $=c.$async?(0,Oi._)`(${v}.async ? await ${S}(${n}) : ${S}(${n}))`:(0,Oi._)`${S}(${n})`,j=(0,Oi._)`(typeof ${S} == "function" ? ${$} : ${S}.test(${n}))`;return(0,Oi._)`${S} && ${S} !== true && ${x} === ${e} && !${j}`}}function m(){let g=l.formats[o];if(!g){P();return}if(g===!0)return;let[v,x,S]=A(g);v===e&&t.pass($());function P(){if(d.strictSchema===!1){l.logger.warn(j());return}throw new Error(j());function j(){return`unknown format "${o}" ignored in schema at path "${u}"`}}function A(j){let q=j instanceof RegExp?(0,Oi.regexpCode)(j):d.code.formats?(0,Oi._)`${d.code.formats}${(0,Oi.getProperty)(o)}`:void 0,F=r.scopeValue("formats",{key:o,ref:j,code:q});return typeof j=="object"&&!(j instanceof RegExp)?[j.type||"string",j.validate,(0,Oi._)`${F}.validate`]:["string",j,F]}function $(){if(typeof g=="object"&&!(g instanceof RegExp)&&g.async){if(!c.$async)throw new Error("async format in sync schema");return(0,Oi._)`await ${S}(${n})`}return typeof x=="function"?(0,Oi._)`${S}(${n})`:(0,Oi._)`${S}.test(${n})`}}}};Mq.default=YWe});var zhe=V(Oq=>{"use strict";f();Object.defineProperty(Oq,"__esModule",{value:!0});var XWe=Fhe(),QWe=[XWe.default];Oq.default=QWe});var Whe=V(p2=>{"use strict";f();Object.defineProperty(p2,"__esModule",{value:!0});p2.contentVocabulary=p2.metadataVocabulary=void 0;p2.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];p2.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var Vhe=V(Cq=>{"use strict";f();Object.defineProperty(Cq,"__esModule",{value:!0});var eHe=jfe(),tHe=Yfe(),rHe=She(),nHe=Bhe(),iHe=jhe(),oHe=Khe(),sHe=zhe(),Hhe=Whe(),aHe=[nHe.default,eHe.default,tHe.default,(0,rHe.default)(!0),sHe.default,Hhe.metadataVocabulary,Hhe.contentVocabulary,iHe.default,oHe.default];Cq.default=aHe});var Ghe=V(xS=>{"use strict";f();Object.defineProperty(xS,"__esModule",{value:!0});xS.DiscrError=void 0;var cHe;(function(t){t.Tag="tag",t.Mapping="mapping"})(cHe=xS.DiscrError||(xS.DiscrError={}))});var Zhe=V(jq=>{"use strict";f();Object.defineProperty(jq,"__esModule",{value:!0});var m2=rr(),$q=Ghe(),Jhe=aS(),dHe=Rr(),uHe={message:({params:{discrError:t,tagName:e}})=>t===$q.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0,m2._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},lHe={keyword:"discriminator",type:"object",schemaType:"object",error:uHe,code(t){let{gen:e,data:r,schema:n,parentSchema:i,it:o}=t,{oneOf:s}=i;if(!o.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=n.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!s)throw new Error("discriminator: requires oneOf keyword");let d=e.let("valid",!1),u=e.const("tag",(0,m2._)`${r}${(0,m2.getProperty)(a)}`);e.if((0,m2._)`typeof ${u} == "string"`,()=>c(),()=>t.error(!1,{discrError:$q.DiscrError.Tag,tag:u,tagName:a})),t.ok(d);function c(){let m=p();e.if(!1);for(let g in m)e.elseIf((0,m2._)`${u} === ${g}`),e.assign(d,l(m[g]));e.else(),t.error(!1,{discrError:$q.DiscrError.Mapping,tag:u,tagName:a}),e.endIf()}function l(m){let g=e.name("valid"),v=t.subschema({keyword:"oneOf",schemaProp:m},g);return t.mergeEvaluated(v,m2.Name),g}function p(){var m;let g={},v=S(i),x=!0;for(let $=0;${fHe.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/schema",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/core":!0,"https://json-schema.org/draft/2020-12/vocab/applicator":!0,"https://json-schema.org/draft/2020-12/vocab/unevaluated":!0,"https://json-schema.org/draft/2020-12/vocab/validation":!0,"https://json-schema.org/draft/2020-12/vocab/meta-data":!0,"https://json-schema.org/draft/2020-12/vocab/format-annotation":!0,"https://json-schema.org/draft/2020-12/vocab/content":!0},$dynamicAnchor:"meta",title:"Core and Validation specifications meta-schema",allOf:[{$ref:"meta/core"},{$ref:"meta/applicator"},{$ref:"meta/unevaluated"},{$ref:"meta/validation"},{$ref:"meta/meta-data"},{$ref:"meta/format-annotation"},{$ref:"meta/content"}],type:["object","boolean"],$comment:"This meta-schema also defines keywords that have appeared in previous drafts in order to prevent incompatible extensions as they remain in common use.",properties:{definitions:{$comment:'"definitions" has been replaced by "$defs".',type:"object",additionalProperties:{$dynamicRef:"#meta"},deprecated:!0,default:{}},dependencies:{$comment:'"dependencies" has been split and replaced by "dependentSchemas" and "dependentRequired" in order to serve their differing semantics.',type:"object",additionalProperties:{anyOf:[{$dynamicRef:"#meta"},{$ref:"meta/validation#/$defs/stringArray"}]},deprecated:!0,default:{}},$recursiveAnchor:{$comment:'"$recursiveAnchor" has been replaced by "$dynamicAnchor".',$ref:"meta/core#/$defs/anchorString",deprecated:!0},$recursiveRef:{$comment:'"$recursiveRef" has been replaced by "$dynamicRef".',$ref:"meta/core#/$defs/uriReferenceString",deprecated:!0}}}});var Xhe=V((C8t,hHe)=>{hHe.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/applicator",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/applicator":!0},$dynamicAnchor:"meta",title:"Applicator vocabulary meta-schema",type:["object","boolean"],properties:{prefixItems:{$ref:"#/$defs/schemaArray"},items:{$dynamicRef:"#meta"},contains:{$dynamicRef:"#meta"},additionalProperties:{$dynamicRef:"#meta"},properties:{type:"object",additionalProperties:{$dynamicRef:"#meta"},default:{}},patternProperties:{type:"object",additionalProperties:{$dynamicRef:"#meta"},propertyNames:{format:"regex"},default:{}},dependentSchemas:{type:"object",additionalProperties:{$dynamicRef:"#meta"},default:{}},propertyNames:{$dynamicRef:"#meta"},if:{$dynamicRef:"#meta"},then:{$dynamicRef:"#meta"},else:{$dynamicRef:"#meta"},allOf:{$ref:"#/$defs/schemaArray"},anyOf:{$ref:"#/$defs/schemaArray"},oneOf:{$ref:"#/$defs/schemaArray"},not:{$dynamicRef:"#meta"}},$defs:{schemaArray:{type:"array",minItems:1,items:{$dynamicRef:"#meta"}}}}});var Qhe=V(($8t,pHe)=>{pHe.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/unevaluated",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/unevaluated":!0},$dynamicAnchor:"meta",title:"Unevaluated applicator vocabulary meta-schema",type:["object","boolean"],properties:{unevaluatedItems:{$dynamicRef:"#meta"},unevaluatedProperties:{$dynamicRef:"#meta"}}}});var epe=V((j8t,mHe)=>{mHe.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/content",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/content":!0},$dynamicAnchor:"meta",title:"Content vocabulary meta-schema",type:["object","boolean"],properties:{contentEncoding:{type:"string"},contentMediaType:{type:"string"},contentSchema:{$dynamicRef:"#meta"}}}});var tpe=V((N8t,yHe)=>{yHe.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/core",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/core":!0},$dynamicAnchor:"meta",title:"Core vocabulary meta-schema",type:["object","boolean"],properties:{$id:{$ref:"#/$defs/uriReferenceString",$comment:"Non-empty fragments not allowed.",pattern:"^[^#]*#?$"},$schema:{$ref:"#/$defs/uriString"},$ref:{$ref:"#/$defs/uriReferenceString"},$anchor:{$ref:"#/$defs/anchorString"},$dynamicRef:{$ref:"#/$defs/uriReferenceString"},$dynamicAnchor:{$ref:"#/$defs/anchorString"},$vocabulary:{type:"object",propertyNames:{$ref:"#/$defs/uriString"},additionalProperties:{type:"boolean"}},$comment:{type:"string"},$defs:{type:"object",additionalProperties:{$dynamicRef:"#meta"}}},$defs:{anchorString:{type:"string",pattern:"^[A-Za-z_][-A-Za-z0-9._]*$"},uriString:{type:"string",format:"uri"},uriReferenceString:{type:"string",format:"uri-reference"}}}});var rpe=V((U8t,gHe)=>{gHe.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/format-annotation",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/format-annotation":!0},$dynamicAnchor:"meta",title:"Format vocabulary meta-schema for annotation results",type:["object","boolean"],properties:{format:{type:"string"}}}});var npe=V((q8t,vHe)=>{vHe.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/meta-data",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/meta-data":!0},$dynamicAnchor:"meta",title:"Meta-data vocabulary meta-schema",type:["object","boolean"],properties:{title:{type:"string"},description:{type:"string"},default:!0,deprecated:{type:"boolean",default:!1},readOnly:{type:"boolean",default:!1},writeOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0}}}});var ipe=V((L8t,bHe)=>{bHe.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/validation",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/validation":!0},$dynamicAnchor:"meta",title:"Validation vocabulary meta-schema",type:["object","boolean"],properties:{type:{anyOf:[{$ref:"#/$defs/simpleTypes"},{type:"array",items:{$ref:"#/$defs/simpleTypes"},minItems:1,uniqueItems:!0}]},const:!0,enum:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/$defs/nonNegativeInteger"},minLength:{$ref:"#/$defs/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},maxItems:{$ref:"#/$defs/nonNegativeInteger"},minItems:{$ref:"#/$defs/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},maxContains:{$ref:"#/$defs/nonNegativeInteger"},minContains:{$ref:"#/$defs/nonNegativeInteger",default:1},maxProperties:{$ref:"#/$defs/nonNegativeInteger"},minProperties:{$ref:"#/$defs/nonNegativeIntegerDefault0"},required:{$ref:"#/$defs/stringArray"},dependentRequired:{type:"object",additionalProperties:{$ref:"#/$defs/stringArray"}}},$defs:{nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{$ref:"#/$defs/nonNegativeInteger",default:0},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}}}});var ope=V(Nq=>{"use strict";f();Object.defineProperty(Nq,"__esModule",{value:!0});var wHe=Yhe(),_He=Xhe(),xHe=Qhe(),EHe=epe(),SHe=tpe(),AHe=rpe(),THe=npe(),PHe=ipe(),IHe=["/properties"];function kHe(t){return[wHe,_He,xHe,EHe,SHe,e(this,AHe),THe,e(this,PHe)].forEach(r=>this.addMetaSchema(r,void 0,!1)),this;function e(r,n){return t?r.$dataMetaSchema(n,IHe):n}}Nq.default=kHe});var qq=V((ci,spe)=>{"use strict";f();Object.defineProperty(ci,"__esModule",{value:!0});ci.MissingRefError=ci.ValidationError=ci.CodeGen=ci.Name=ci.nil=ci.stringify=ci.str=ci._=ci.KeywordCxt=void 0;var RHe=Bfe(),DHe=Vhe(),BHe=Zhe(),MHe=ope(),Uq="https://json-schema.org/draft/2020-12/schema",yI=class extends RHe.default{constructor(e={}){super({...e,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){super._addVocabularies(),DHe.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(BHe.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:e,meta:r}=this.opts;r&&(MHe.default.call(this,e),this.refs["http://json-schema.org/schema"]=Uq)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(Uq)?Uq:void 0)}};spe.exports=ci=yI;Object.defineProperty(ci,"__esModule",{value:!0});ci.default=yI;var OHe=sS();Object.defineProperty(ci,"KeywordCxt",{enumerable:!0,get:function(){return OHe.KeywordCxt}});var y2=rr();Object.defineProperty(ci,"_",{enumerable:!0,get:function(){return y2._}});Object.defineProperty(ci,"str",{enumerable:!0,get:function(){return y2.str}});Object.defineProperty(ci,"stringify",{enumerable:!0,get:function(){return y2.stringify}});Object.defineProperty(ci,"nil",{enumerable:!0,get:function(){return y2.nil}});Object.defineProperty(ci,"Name",{enumerable:!0,get:function(){return y2.Name}});Object.defineProperty(ci,"CodeGen",{enumerable:!0,get:function(){return y2.CodeGen}});var CHe=ZP();Object.defineProperty(ci,"ValidationError",{enumerable:!0,get:function(){return CHe.default}});var $He=YP();Object.defineProperty(ci,"MissingRefError",{enumerable:!0,get:function(){return $He.default}})});var TI=V((iPt,ppe)=>{f();var qHe=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,AI=()=>qHe.now(),LHe=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),Hq=t=>t===1/0||LHe(t),Vq=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&&!Hq(r))throw new TypeError("ttl must be positive integer or Infinity if set");if(!Hq(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{this.timer=void 0,this.timerExpiration=void 0,this.purgeStale();for(let i in this.expirations){this.setTimer(i,i-AI());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 k.default.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(AI()+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(!Hq(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-AI())):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(AI());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()}};ppe.exports=Vq});var bpe=V(vpe=>{"use strict";f();vpe.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 el=V((SPt,wpe)=>{"use strict";f();wpe.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 Zq=V((TPt,_pe)=>{"use strict";f();var Jq=null;_pe.exports=function(){return Jq===null&&(Jq={textEncoder:new TextEncoder,textDecoder:new TextDecoder}),Jq}});var Qq=V(xpe=>{"use strict";f();var Yq=el(),FHe=new Set(["buffer","view","utf8"]),Xq=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"||!FHe.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 Yq(`Encoding '${this.name}' cannot be transcoded to 'buffer'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createViewTranscoder(){throw new Yq(`Encoding '${this.name}' cannot be transcoded to 'view'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createUTF8Transcoder(){throw new Yq(`Encoding '${this.name}' cannot be transcoded to 'utf8'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}};xpe.Encoding=Xq});var nL=V(kI=>{"use strict";f();var{Buffer:tL}=pn()||{},{Encoding:rL}=Qq(),zHe=Zq(),IS=class extends rL{constructor(e){super({...e,format:"buffer"})}createViewTranscoder(){return new kS({encode:this.encode,decode:e=>this.decode(tL.from(e.buffer,e.byteOffset,e.byteLength)),name:`${this.name}+view`})}createBufferTranscoder(){return this}},kS=class extends rL{constructor(e){super({...e,format:"view"})}createBufferTranscoder(){return new IS({encode:e=>{let r=this.encode(e);return tL.from(r.buffer,r.byteOffset,r.byteLength)},decode:this.decode,name:`${this.name}+buffer`})}createViewTranscoder(){return this}},eL=class extends rL{constructor(e){super({...e,format:"utf8"})}createBufferTranscoder(){return new IS({encode:e=>tL.from(this.encode(e),"utf8"),decode:e=>this.decode(e.toString("utf8")),name:`${this.name}+buffer`})}createViewTranscoder(){let{textEncoder:e,textDecoder:r}=zHe();return new kS({encode:n=>e.encode(this.encode(n)),decode:n=>this.decode(r.decode(n)),name:`${this.name}+view`})}createUTF8Transcoder(){return this}};kI.BufferFormat=IS;kI.ViewFormat=kS;kI.UTF8Format=eL});var Tpe=V(Iv=>{"use strict";f();var{Buffer:ca}=pn()||{Buffer:{isBuffer:()=>!1}},{textEncoder:Spe,textDecoder:Epe}=Zq()(),{BufferFormat:RS,ViewFormat:iL,UTF8Format:Ape}=nL(),RI=t=>t;Iv.utf8=new Ape({encode:function(t){return ca.isBuffer(t)?t.toString("utf8"):ArrayBuffer.isView(t)?Epe.decode(t):String(t)},decode:RI,name:"utf8",createViewTranscoder(){return new iL({encode:function(t){return ArrayBuffer.isView(t)?t:Spe.encode(t)},decode:function(t){return Epe.decode(t)},name:`${this.name}+view`})},createBufferTranscoder(){return new RS({encode:function(t){return ca.isBuffer(t)?t:ArrayBuffer.isView(t)?ca.from(t.buffer,t.byteOffset,t.byteLength):ca.from(String(t),"utf8")},decode:function(t){return t.toString("utf8")},name:`${this.name}+buffer`})}});Iv.json=new Ape({encode:JSON.stringify,decode:JSON.parse,name:"json"});Iv.buffer=new RS({encode:function(t){return ca.isBuffer(t)?t:ArrayBuffer.isView(t)?ca.from(t.buffer,t.byteOffset,t.byteLength):ca.from(String(t),"utf8")},decode:RI,name:"buffer",createViewTranscoder(){return new iL({encode:function(t){return ArrayBuffer.isView(t)?t:ca.from(String(t),"utf8")},decode:function(t){return ca.from(t.buffer,t.byteOffset,t.byteLength)},name:`${this.name}+view`})}});Iv.view=new iL({encode:function(t){return ArrayBuffer.isView(t)?t:Spe.encode(t)},decode:RI,name:"view",createBufferTranscoder(){return new RS({encode:function(t){return ca.isBuffer(t)?t:ArrayBuffer.isView(t)?ca.from(t.buffer,t.byteOffset,t.byteLength):ca.from(String(t),"utf8")},decode:RI,name:`${this.name}+buffer`})}});Iv.hex=new RS({encode:function(t){return ca.isBuffer(t)?t:ca.from(String(t),"hex")},decode:function(t){return t.toString("hex")},name:"hex"});Iv.base64=new RS({encode:function(t){return ca.isBuffer(t)?t:ca.from(String(t),"base64")},decode:function(t){return t.toString("base64")},name:"base64"})});var kpe=V(Ipe=>{"use strict";f();var Ppe=el(),BI=Tpe(),{Encoding:WHe}=Qq(),{BufferFormat:HHe,ViewFormat:VHe,UTF8Format:GHe}=nL(),DS=Symbol("formats"),DI=Symbol("encodings"),JHe=new Set(["buffer","view","utf8"]),oL=class{constructor(e){if(Array.isArray(e)){if(!e.every(r=>JHe.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[DI]=new Map,this[DS]=new Set(e);for(let r in BI)try{this.encoding(r)}catch(n){if(n.code!=="LEVEL_ENCODING_NOT_SUPPORTED")throw n}}encodings(){return Array.from(new Set(this[DI].values()))}encoding(e){let r=this[DI].get(e);if(r===void 0){if(typeof e=="string"&&e!==""){if(r=QHe[e],!r)throw new Ppe(`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=ZHe(e)}let{name:n,format:i}=r;if(!this[DS].has(i))if(this[DS].has("view"))r=r.createViewTranscoder();else if(this[DS].has("buffer"))r=r.createBufferTranscoder();else if(this[DS].has("utf8"))r=r.createUTF8Transcoder();else throw new Ppe(`Encoding '${n}' cannot be transcoded`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"});for(let o of[e,n,r.name,r.commonName])this[DI].set(o,r)}return r}};Ipe.Transcoder=oL;function ZHe(t){if(t instanceof WHe)return t;let e="type"in t&&typeof t.type=="string"?t.type:void 0,r=t.name||e||`anonymous-${eVe++}`;switch(YHe(t)){case"view":return new VHe({...t,name:r});case"utf8":return new GHe({...t,name:r});case"buffer":return new HHe({...t,name:r});default:throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'")}}function YHe(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 XHe={binary:BI.buffer,"utf-8":BI.utf8},QHe={...BI,...XHe},eVe=0});var Dpe=V(($Pt,Rpe)=>{f();Rpe.exports=typeof queueMicrotask=="function"?queueMicrotask:t=>Promise.resolve().then(t)});var BS=V(sL=>{"use strict";f();var Bpe=Dpe();sL.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};sL.fromPromise=function(t,e){if(e===void 0)return t;t.then(function(r){Bpe(()=>e(null,r))}).catch(function(r){Bpe(()=>e(r))})}});var MI=V(aL=>{"use strict";f();aL.getCallback=function(t,e){return typeof t=="function"?t:e};aL.getOptions=function(t,e){return typeof t=="object"&&t!==null?t:e!==void 0?e:{}}});var Iy=V(jI=>{"use strict";f();var{fromCallback:cL}=BS(),Qc=el(),{getOptions:dL,getCallback:Mpe}=MI(),kv=Symbol("promise"),b2=Symbol("callback"),_f=Symbol("working"),Rv=Symbol("handleOne"),Xh=Symbol("handleMany"),uL=Symbol("autoClose"),Ty=Symbol("finishWork"),xf=Symbol("returnMany"),Ey=Symbol("closing"),MS=Symbol("handleClose"),OI=Symbol("closed"),OS=Symbol("closeCallbacks"),Ay=Symbol("keyEncoding"),Dv=Symbol("valueEncoding"),lL=Symbol("abortOnClose"),CI=Symbol("legacy"),fL=Symbol("keys"),hL=Symbol("values"),Sy=Symbol("limit"),Gd=Symbol("count"),$I=Object.freeze({}),tVe=()=>{},Ope=!1,CS=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[OI]=!1,this[OS]=[],this[_f]=!1,this[Ey]=!1,this[uL]=!1,this[b2]=null,this[Rv]=this[Rv].bind(this),this[Xh]=this[Xh].bind(this),this[MS]=this[MS].bind(this),this[Ay]=r[Ay],this[Dv]=r[Dv],this[CI]=n,this[Sy]=Number.isInteger(r.limit)&&r.limit>=0?r.limit:1/0,this[Gd]=0,this[lL]=!!r.abortOnClose,this.db=e,this.db.attachResource(this),this.nextTick=e.nextTick}get count(){return this[Gd]}get limit(){return this[Sy]}next(e){let r;if(e===void 0)r=new Promise((n,i)=>{e=(o,s,a)=>{o?i(o):this[CI]?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[Ey]?this.nextTick(e,new Qc("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[_f]?this.nextTick(e,new Qc("Iterator is busy: cannot call next() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[_f]=!0,this[b2]=e,this[Gd]>=this[Sy]?this.nextTick(this[Rv],null):this._next(this[Rv])),r}_next(e){this.nextTick(e)}nextv(e,r,n){return n=Mpe(r,n),n=cL(n,kv),r=dL(r,$I),Number.isInteger(e)?(this[Ey]?this.nextTick(n,new Qc("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[_f]?this.nextTick(n,new Qc("Iterator is busy: cannot call nextv() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(e<1&&(e=1),this[Sy]<1/0&&(e=Math.min(e,this[Sy]-this[Gd])),this[_f]=!0,this[b2]=n,e<=0?this.nextTick(this[Xh],null,[]):this._nextv(e,r,this[Xh])),n[kv]):(this.nextTick(n,new TypeError("The first argument 'size' must be an integer")),n[kv])}_nextv(e,r,n){let i=[],o=(s,a,d)=>{if(s)return n(s);if(this[CI]?a===void 0&&d===void 0:a===void 0)return n(null,i);i.push(this[CI]?[a,d]:a),i.length===e?n(null,i):this._next(o)};this._next(o)}all(e,r){return r=Mpe(e,r),r=cL(r,kv),e=dL(e,$I),this[Ey]?this.nextTick(r,new Qc("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[_f]?this.nextTick(r,new Qc("Iterator is busy: cannot call all() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[_f]=!0,this[b2]=r,this[uL]=!0,this[Gd]>=this[Sy]?this.nextTick(this[Xh],null,[]):this._all(e,this[Xh])),r[kv]}_all(e,r){let n=this[Gd],i=[],o=()=>{let a=this[Sy]<1/0?Math.min(1e3,this[Sy]-n):1e3;a<=0?this.nextTick(r,null,i):this._nextv(a,$I,s)},s=(a,d)=>{a?r(a):d.length===0?r(null,i):(i.push.apply(i,d),n+=d.length,o())};o()}[Ty](){let e=this[b2];return this[lL]&&e===null?tVe:(this[_f]=!1,this[b2]=null,this[Ey]&&this._close(this[MS]),e)}[xf](e,r,n){this[uL]?this.close(e.bind(null,r,n)):e(r,n)}seek(e,r){if(r=dL(r,$I),!this[Ey]){if(this[_f])throw new Qc("Iterator is busy: cannot call seek() until next() has completed",{code:"LEVEL_ITERATOR_BUSY"});{let n=this.db.keyEncoding(r.keyEncoding||this[Ay]),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 Qc("Iterator does not support seek()",{code:"LEVEL_NOT_SUPPORTED"})}close(e){return e=cL(e,kv),this[OI]?this.nextTick(e):this[Ey]?this[OS].push(e):(this[Ey]=!0,this[OS].push(e),this[_f]?this[lL]&&this[Ty]()(new Qc("Aborted on iterator close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this._close(this[MS])),e[kv]}_close(e){this.nextTick(e)}[MS](){this[OI]=!0,this.db.detachResource(this);let e=this[OS];this[OS]=[];for(let r of e)r()}async*[Symbol.asyncIterator](){try{let e;for(;(e=await this.next())!==void 0;)yield e}finally{this[OI]||await this.close()}}},w2=class extends CS{constructor(e,r){super(e,r,!0),this[fL]=r.keys!==!1,this[hL]=r.values!==!1}[Rv](e,r,n){let i=this[Ty]();if(e)return i(e);try{r=this[fL]&&r!==void 0?this[Ay].decode(r):void 0,n=this[hL]&&n!==void 0?this[Dv].decode(n):void 0}catch(o){return i(new Py("entry",o))}r===void 0&&n===void 0||this[Gd]++,i(null,r,n)}[Xh](e,r){let n=this[Ty]();if(e)return this[xf](n,e);try{for(let i of r){let o=i[0],s=i[1];i[0]=this[fL]&&o!==void 0?this[Ay].decode(o):void 0,i[1]=this[hL]&&s!==void 0?this[Dv].decode(s):void 0}}catch(i){return this[xf](n,new Py("entries",i))}this[Gd]+=r.length,this[xf](n,null,r)}end(e){return!Ope&&typeof console<"u"&&(Ope=!0,console.warn(new Qc("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)}},pL=class extends CS{constructor(e,r){super(e,r,!1)}[Rv](e,r){let n=this[Ty]();if(e)return n(e);try{r=r!==void 0?this[Ay].decode(r):void 0}catch(i){return n(new Py("key",i))}r!==void 0&&this[Gd]++,n(null,r)}[Xh](e,r){let n=this[Ty]();if(e)return this[xf](n,e);try{for(let i=0;i{"use strict";f();var{AbstractKeyIterator:rVe,AbstractValueIterator:nVe}=Iy(),Bv=Symbol("iterator"),$S=Symbol("callback"),_2=Symbol("handleOne"),Mv=Symbol("handleMany"),jS=class extends rVe{constructor(e,r){super(e,r),this[Bv]=e.iterator({...r,keys:!0,values:!1}),this[_2]=this[_2].bind(this),this[Mv]=this[Mv].bind(this)}},NI=class extends nVe{constructor(e,r){super(e,r),this[Bv]=e.iterator({...r,keys:!1,values:!0}),this[_2]=this[_2].bind(this),this[Mv]=this[Mv].bind(this)}};for(let t of[jS,NI]){let e=t===jS,r=e?n=>n[0]:n=>n[1];t.prototype._next=function(n){this[$S]=n,this[Bv].next(this[_2])},t.prototype[_2]=function(n,i,o){let s=this[$S];n?s(n):s(null,e?i:o)},t.prototype._nextv=function(n,i,o){this[$S]=o,this[Bv].nextv(n,i,this[Mv])},t.prototype._all=function(n,i){this[$S]=i,this[Bv].all(n,this[Mv])},t.prototype[Mv]=function(n,i){let o=this[$S];n?o(n):o(null,i.map(r))},t.prototype._seek=function(n,i){this[Bv].seek(n,i)},t.prototype._close=function(n){this[Bv].close(n)}}yL.DefaultKeyIterator=jS;yL.DefaultValueIterator=NI});var $pe=V(zI=>{"use strict";f();var{AbstractIterator:iVe,AbstractKeyIterator:oVe,AbstractValueIterator:sVe}=Iy(),gL=el(),fc=Symbol("nut"),KI=Symbol("undefer"),FI=Symbol("factory"),UI=class extends iVe{constructor(e,r){super(e,r),this[fc]=null,this[FI]=()=>e.iterator(r),this.db.defer(()=>this[KI]())}},qI=class extends oVe{constructor(e,r){super(e,r),this[fc]=null,this[FI]=()=>e.keys(r),this.db.defer(()=>this[KI]())}},LI=class extends sVe{constructor(e,r){super(e,r),this[fc]=null,this[FI]=()=>e.values(r),this.db.defer(()=>this[KI]())}};for(let t of[UI,qI,LI])t.prototype[KI]=function(){this.db.status==="open"&&(this[fc]=this[FI]())},t.prototype._next=function(e){this[fc]!==null?this[fc].next(e):this.db.status==="opening"?this.db.defer(()=>this._next(e)):this.nextTick(e,new gL("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},t.prototype._nextv=function(e,r,n){this[fc]!==null?this[fc].nextv(e,r,n):this.db.status==="opening"?this.db.defer(()=>this._nextv(e,r,n)):this.nextTick(n,new gL("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},t.prototype._all=function(e,r){this[fc]!==null?this[fc].all(r):this.db.status==="opening"?this.db.defer(()=>this._all(e,r)):this.nextTick(r,new gL("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},t.prototype._seek=function(e,r){this[fc]!==null?this[fc]._seek(e,r):this.db.status==="opening"&&this.db.defer(()=>this._seek(e,r))},t.prototype._close=function(e){this[fc]!==null?this[fc].close(e):this.db.status==="opening"?this.db.defer(()=>this._close(e)):this.nextTick(e)};zI.DeferredIterator=UI;zI.DeferredKeyIterator=qI;zI.DeferredValueIterator=LI});var bL=V(Npe=>{"use strict";f();var{fromCallback:jpe}=BS(),WI=el(),{getCallback:aVe,getOptions:cVe}=MI(),HI=Symbol("promise"),Jd=Symbol("status"),x2=Symbol("operations"),NS=Symbol("finishClose"),E2=Symbol("closeCallbacks"),vL=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[x2]=[],this[E2]=[],this[Jd]="open",this[NS]=this[NS].bind(this),this.db=e,this.db.attachResource(this),this.nextTick=e.nextTick}get length(){return this[x2].length}put(e,r,n){if(this[Jd]!=="open")throw new WI("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),d=o.valueEncoding(n&&n.valueEncoding),u=a.format;n={...n,keyEncoding:u,valueEncoding:d.format},o!==this.db&&(n.sublevel=null);let c=o.prefixKey(a.encode(e),u),l=d.encode(r);return this._put(c,l,n),this[x2].push({...s,type:"put",key:e,value:r}),this}_put(e,r,n){}del(e,r){if(this[Jd]!=="open")throw new WI("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[x2].push({...o,type:"del",key:e}),this}_del(e,r){}clear(){if(this[Jd]!=="open")throw new WI("Batch is not open: cannot call clear() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});return this._clear(),this[x2]=[],this}_clear(){}write(e,r){return r=aVe(e,r),r=jpe(r,HI),e=cVe(e),this[Jd]!=="open"?this.nextTick(r,new WI("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"})):this.length===0?this.close(r):(this[Jd]="writing",this._write(e,n=>{this[Jd]="closing",this[E2].push(()=>r(n)),n||this.db.emit("batch",this[x2]),this._close(this[NS])})),r[HI]}_write(e,r){}close(e){return e=jpe(e,HI),this[Jd]==="closing"?this[E2].push(e):this[Jd]==="closed"?this.nextTick(e):(this[E2].push(e),this[Jd]!=="writing"&&(this[Jd]="closing",this._close(this[NS]))),e[HI]}_close(e){this.nextTick(e)}[NS](){this[Jd]="closed",this.db.detachResource(this);let e=this[E2];this[E2]=[];for(let r of e)r()}};Npe.AbstractChainedBatch=vL});var qpe=V(Upe=>{"use strict";f();var{AbstractChainedBatch:dVe}=bL(),uVe=el(),S2=Symbol("encoded"),wL=class extends dVe{constructor(e){super(e),this[S2]=[]}_put(e,r,n){this[S2].push({...n,type:"put",key:e,value:r})}_del(e,r){this[S2].push({...r,type:"del",key:e})}_clear(){this[S2]=[]}_write(e,r){this.db.status==="opening"?this.db.defer(()=>this._write(e,r)):this.db.status==="open"?this[S2].length===0?this.nextTick(r):this.db._batch(this[S2],e,r):this.nextTick(r,new uVe("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"}))}};Upe.DefaultChainedBatch=wL});var Fpe=V((XPt,Kpe)=>{"use strict";f();var Lpe=el(),lVe=Object.prototype.hasOwnProperty,fVe=new Set(["lt","lte","gt","gte"]);Kpe.exports=function(t,e){let r={};for(let n in t)if(lVe.call(t,n)&&!(n==="keyEncoding"||n==="valueEncoding")){if(n==="start"||n==="end")throw new Lpe(`The legacy range option '${n}' has been removed`,{code:"LEVEL_LEGACY"});if(n==="encoding")throw new Lpe("The levelup-style 'encoding' alias has been removed, use 'valueEncoding' instead",{code:"LEVEL_LEGACY"});fVe.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 _L=V((eIt,Wpe)=>{f();var zpe;Wpe.exports=typeof queueMicrotask=="function"?queueMicrotask.bind(typeof window<"u"?window:globalThis):t=>(zpe||(zpe=Promise.resolve())).then(t).catch(e=>setTimeout(()=>{throw e},0))});var Gpe=V((rIt,Vpe)=>{"use strict";f();var Hpe=_L();Vpe.exports=function(t,...e){e.length===0?Hpe(t):Hpe(()=>t(...e))}});var Jpe=V(VI=>{"use strict";f();var{AbstractIterator:hVe,AbstractKeyIterator:pVe,AbstractValueIterator:mVe}=Iy(),A2=Symbol("unfix"),tl=Symbol("iterator"),Ov=Symbol("handleOne"),ky=Symbol("handleMany"),Qh=Symbol("callback"),US=class extends hVe{constructor(e,r,n,i){super(e,r),this[tl]=n,this[A2]=i,this[Ov]=this[Ov].bind(this),this[ky]=this[ky].bind(this),this[Qh]=null}[Ov](e,r,n){let i=this[Qh];if(e)return i(e);r!==void 0&&(r=this[A2](r)),i(e,r,n)}[ky](e,r){let n=this[Qh];if(e)return n(e);for(let i of r){let o=i[0];o!==void 0&&(i[0]=this[A2](o))}n(e,r)}},qS=class extends pVe{constructor(e,r,n,i){super(e,r),this[tl]=n,this[A2]=i,this[Ov]=this[Ov].bind(this),this[ky]=this[ky].bind(this),this[Qh]=null}[Ov](e,r){let n=this[Qh];if(e)return n(e);r!==void 0&&(r=this[A2](r)),n(e,r)}[ky](e,r){let n=this[Qh];if(e)return n(e);for(let i=0;i{"use strict";f();var xL=el(),{Buffer:AL}=pn()||{},{AbstractSublevelIterator:yVe,AbstractSublevelKeyIterator:gVe,AbstractSublevelValueIterator:vVe}=Jpe(),ep=Symbol("prefix"),Zpe=Symbol("upperBound"),KS=Symbol("prefixRange"),ed=Symbol("parent"),EL=Symbol("unfix"),Ype=new TextEncoder,bVe={separator:"!"};Xpe.exports=function({AbstractLevel:t}){class e extends t{static defaults(n){if(typeof n=="string")throw new xL("The subleveldown string shorthand for { separator } has been removed",{code:"LEVEL_LEGACY"});if(n&&n.open)throw new xL("The subleveldown open option has been removed",{code:"LEVEL_LEGACY"});return n==null?bVe:n.separator?n:{...n,separator:"!"}}constructor(n,i,o){let{separator:s,manifest:a,...d}=e.defaults(o);i=_Ve(i,s);let u=s.charCodeAt(0)+1,c=n[ed]||n;if(!Ype.encode(i).every(m=>m>u&&m<127))throw new xL(`Prefix must use bytes > ${u} < 127`,{code:"LEVEL_INVALID_PREFIX"});super(wVe(c,a),d);let l=(n.prefix||"")+s+i+s,p=l.slice(0,-1)+String.fromCharCode(u);this[ed]=c,this[ep]=new GI(l),this[Zpe]=new GI(p),this[EL]=new TL,this.nextTick=c.nextTick}prefixKey(n,i){if(i==="utf8")return this[ep].utf8+n;if(n.byteLength===0)return this[ep][i];if(i==="view"){let o=this[ep].view,s=new Uint8Array(o.byteLength+n.byteLength);return s.set(o,0),s.set(n,o.byteLength),s}else{let o=this[ep].buffer;return AL.concat([o,n],o.byteLength+n.byteLength)}}[KS](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[ep][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[Zpe][i]}get prefix(){return this[ep].utf8}get db(){return this[ed]}_open(n,i){this[ed].open({passive:!0},i)}_put(n,i,o,s){this[ed].put(n,i,o,s)}_get(n,i,o){this[ed].get(n,i,o)}_getMany(n,i,o){this[ed].getMany(n,i,o)}_del(n,i,o){this[ed].del(n,i,o)}_batch(n,i,o){this[ed].batch(n,i,o)}_clear(n,i){this[KS](n,n.keyEncoding),this[ed].clear(n,i)}_iterator(n){this[KS](n,n.keyEncoding);let i=this[ed].iterator(n),o=this[EL].get(this[ep].utf8.length,n.keyEncoding);return new yVe(this,n,i,o)}_keys(n){this[KS](n,n.keyEncoding);let i=this[ed].keys(n),o=this[EL].get(this[ep].utf8.length,n.keyEncoding);return new gVe(this,n,i,o)}_values(n){this[KS](n,n.keyEncoding);let i=this[ed].values(n);return new vVe(this,n,i)}}return{AbstractSublevel:e}};var wVe=function(t,e){return{...t.supports,createIfMissing:!1,errorIfExists:!1,events:{},additionalMethods:{},...e,encodings:{utf8:SL(t,"utf8"),buffer:SL(t,"buffer"),view:SL(t,"view")}}},SL=function(t,e){return t.supports.encodings[e]?t.keyEncoding(e).name===e:!1},GI=class{constructor(e){this.utf8=e,this.view=Ype.encode(e),this.buffer=AL?AL.from(this.view.buffer,0,this.view.byteLength):{}}},TL=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}},_Ve=function(t,e){let r=0,n=t.length;for(;rr&&t[n-1]===e;)n--;return t.slice(r,n)}});var DL=V(RL=>{"use strict";f();var{supports:xVe}=bpe(),{Transcoder:EVe}=kpe(),{EventEmitter:SVe}=Aa(),{fromCallback:Ry}=BS(),rl=el(),{AbstractIterator:Cv}=Iy(),{DefaultKeyIterator:AVe,DefaultValueIterator:TVe}=Cpe(),{DeferredIterator:PVe,DeferredKeyIterator:IVe,DeferredValueIterator:kVe}=$pe(),{DefaultChainedBatch:eme}=qpe(),{getCallback:$v,getOptions:Dy}=MI(),JI=Fpe(),yr=Symbol("promise"),tp=Symbol("landed"),jv=Symbol("resources"),PL=Symbol("closeResources"),FS=Symbol("operations"),zS=Symbol("undefer"),ZI=Symbol("deferOpen"),tme=Symbol("options"),Dr=Symbol("status"),Nv=Symbol("defaultOptions"),T2=Symbol("transcoder"),YI=Symbol("keyEncoding"),IL=Symbol("valueEncoding"),RVe=()=>{},WS=class extends SVe{constructor(e,r){if(super(),typeof e!="object"||e===null)throw new TypeError("The first argument 'manifest' must be an object");r=Dy(r);let{keyEncoding:n,valueEncoding:i,passive:o,...s}=r;this[jv]=new Set,this[FS]=[],this[ZI]=!0,this[tme]=s,this[Dr]="opening",this.supports=xVe(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[T2]=new EVe(DVe(this)),this[YI]=this[T2].encoding(n||"utf8"),this[IL]=this[T2].encoding(i||"utf8");for(let a of this[T2].encodings())this.supports.encodings[a.commonName]||(this.supports.encodings[a.commonName]=!0);this[Nv]={empty:Object.freeze({}),entry:Object.freeze({keyEncoding:this[YI].commonName,valueEncoding:this[IL].commonName}),key:Object.freeze({keyEncoding:this[YI].commonName})},this.nextTick(()=>{this[ZI]&&this.open({passive:!1},RVe)})}get status(){return this[Dr]}keyEncoding(e){return this[T2].encoding(e??this[YI])}valueEncoding(e){return this[T2].encoding(e??this[IL])}open(e,r){r=$v(e,r),r=Ry(r,yr),e={...this[tme],...Dy(e)},e.createIfMissing=e.createIfMissing!==!1,e.errorIfExists=!!e.errorIfExists;let n=i=>{this[Dr]==="closing"||this[Dr]==="opening"?this.once(tp,i?()=>n(i):n):this[Dr]!=="open"?r(new rl("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN",cause:i})):r()};return e.passive?this[Dr]==="opening"?this.once(tp,n):this.nextTick(n):this[Dr]==="closed"||this[ZI]?(this[ZI]=!1,this[Dr]="opening",this.emit("opening"),this._open(e,i=>{if(i){this[Dr]="closed",this[PL](()=>{this.emit(tp),n(i)}),this[zS]();return}this[Dr]="open",this[zS](),this.emit(tp),this[Dr]==="open"&&this.emit("open"),this[Dr]==="open"&&this.emit("ready"),n()})):this[Dr]==="open"?this.nextTick(n):this.once(tp,()=>this.open(e,r)),r[yr]}_open(e,r){this.nextTick(r)}close(e){e=Ry(e,yr);let r=n=>{this[Dr]==="opening"||this[Dr]==="closing"?this.once(tp,n?r(n):r):this[Dr]!=="closed"?e(new rl("Database is not closed",{code:"LEVEL_DATABASE_NOT_CLOSED",cause:n})):e()};if(this[Dr]==="open"){this[Dr]="closing",this.emit("closing");let n=i=>{this[Dr]="open",this[zS](),this.emit(tp),r(i)};this[PL](()=>{this._close(i=>{if(i)return n(i);this[Dr]="closed",this[zS](),this.emit(tp),this[Dr]==="closed"&&this.emit("closed"),r()})})}else this[Dr]==="closed"?this.nextTick(r):this.once(tp,()=>this.close(e));return e[yr]}[PL](e){if(this[jv].size===0)return this.nextTick(e);let r=this[jv].size,n=!0,i=()=>{--r===0&&(n?this.nextTick(e):e())};for(let o of this[jv])o.close(i);n=!1,this[jv].clear()}_close(e){this.nextTick(e)}get(e,r,n){if(n=$v(r,n),n=Ry(n,yr),r=Dy(r,this[Nv].entry),this[Dr]==="opening")return this.defer(()=>this.get(e,r,n)),n[yr];if(P2(this,n))return n[yr];let i=this._checkKey(e);if(i)return this.nextTick(n,i),n[yr];let o=this.keyEncoding(r.keyEncoding),s=this.valueEncoding(r.valueEncoding),a=o.format,d=s.format;return(r.keyEncoding!==a||r.valueEncoding!==d)&&(r=Object.assign({},r,{keyEncoding:a,valueEncoding:d})),this._get(this.prefixKey(o.encode(e),a),r,(u,c)=>{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{c=s.decode(c)}catch(l){return n(new rl("Could not decode value",{code:"LEVEL_DECODE_ERROR",cause:l}))}n(null,c)}),n[yr]}_get(e,r,n){this.nextTick(n,new Error("NotFound"))}getMany(e,r,n){if(n=$v(r,n),n=Ry(n,yr),r=Dy(r,this[Nv].entry),this[Dr]==="opening")return this.defer(()=>this.getMany(e,r,n)),n[yr];if(P2(this,n))return n[yr];if(!Array.isArray(e))return this.nextTick(n,new TypeError("The first argument 'keys' must be an array")),n[yr];if(e.length===0)return this.nextTick(n,null,[]),n[yr];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 d=new Array(e.length);for(let u=0;u{if(u)return n(u);try{for(let l=0;lthis.put(e,r,n,i)),i[yr];if(P2(this,i))return i[yr];let o=this._checkKey(e)||this._checkValue(r);if(o)return this.nextTick(i,o),i[yr];let s=this.keyEncoding(n.keyEncoding),a=this.valueEncoding(n.valueEncoding),d=s.format,u=a.format;(n.keyEncoding!==d||n.valueEncoding!==u)&&(n=Object.assign({},n,{keyEncoding:d,valueEncoding:u}));let c=this.prefixKey(s.encode(e),d),l=a.encode(r);return this._put(c,l,n,p=>{if(p)return i(p);this.emit("put",e,r),i()}),i[yr]}_put(e,r,n,i){this.nextTick(i)}del(e,r,n){if(n=$v(r,n),n=Ry(n,yr),r=Dy(r,this[Nv].key),this[Dr]==="opening")return this.defer(()=>this.del(e,r,n)),n[yr];if(P2(this,n))return n[yr];let i=this._checkKey(e);if(i)return this.nextTick(n,i),n[yr];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[yr]}_del(e,r,n){this.nextTick(n)}batch(e,r,n){if(!arguments.length){if(this[Dr]==="opening")return new eme(this);if(this[Dr]!=="open")throw new rl("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._chainedBatch()}if(typeof e=="function"?n=e:n=$v(r,n),n=Ry(n,yr),r=Dy(r,this[Nv].empty),this[Dr]==="opening")return this.defer(()=>this.batch(e,r,n)),n[yr];if(P2(this,n))return n[yr];if(!Array.isArray(e))return this.nextTick(n,new TypeError("The first argument 'operations' must be an array")),n[yr];if(e.length===0)return this.nextTick(n),n[yr];let i=new Array(e.length),{keyEncoding:o,valueEncoding:s,...a}=r;for(let d=0;d{if(d)return n(d);this.emit("batch",e),n()}),n[yr]}_batch(e,r,n){this.nextTick(n)}sublevel(e,r){return this._sublevel(e,kL.defaults(r))}_sublevel(e,r){return new kL(this,e,r)}prefixKey(e,r){return e}clear(e,r){if(r=$v(e,r),r=Ry(r,yr),e=Dy(e,this[Nv].empty),this[Dr]==="opening")return this.defer(()=>this.clear(e,r)),r[yr];if(P2(this,r))return r[yr];let n=e,i=this.keyEncoding(e.keyEncoding);return e=JI(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[yr]}_clear(e,r){this.nextTick(r)}iterator(e){let r=this.keyEncoding(e&&e.keyEncoding),n=this.valueEncoding(e&&e.valueEncoding);if(e=JI(e,r),e.keys=e.keys!==!1,e.values=e.values!==!1,e[Cv.keyEncoding]=r,e[Cv.valueEncoding]=n,e.keyEncoding=r.format,e.valueEncoding=n.format,this[Dr]==="opening")return new PVe(this,e);if(this[Dr]!=="open")throw new rl("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._iterator(e)}_iterator(e){return new Cv(this,e)}keys(e){let r=this.keyEncoding(e&&e.keyEncoding),n=this.valueEncoding(e&&e.valueEncoding);if(e=JI(e,r),e[Cv.keyEncoding]=r,e[Cv.valueEncoding]=n,e.keyEncoding=r.format,e.valueEncoding=n.format,this[Dr]==="opening")return new IVe(this,e);if(this[Dr]!=="open")throw new rl("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._keys(e)}_keys(e){return new AVe(this,e)}values(e){let r=this.keyEncoding(e&&e.keyEncoding),n=this.valueEncoding(e&&e.valueEncoding);if(e=JI(e,r),e[Cv.keyEncoding]=r,e[Cv.valueEncoding]=n,e.keyEncoding=r.format,e.valueEncoding=n.format,this[Dr]==="opening")return new kVe(this,e);if(this[Dr]!=="open")throw new rl("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._values(e)}_values(e){return new TVe(this,e)}defer(e){if(typeof e!="function")throw new TypeError("The first argument must be a function");this[FS].push(e)}[zS](){if(this[FS].length===0)return;let e=this[FS];this[FS]=[];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[jv].add(e)}detachResource(e){this[jv].delete(e)}_chainedBatch(){return new eme(this)}_checkKey(e){if(e==null)return new rl("Key cannot be null or undefined",{code:"LEVEL_INVALID_KEY"})}_checkValue(e){if(e==null)return new rl("Value cannot be null or undefined",{code:"LEVEL_INVALID_VALUE"})}};WS.prototype.nextTick=Gpe();var{AbstractSublevel:kL}=Qpe()({AbstractLevel:WS});RL.AbstractLevel=WS;RL.AbstractSublevel=kL;var P2=function(t,e){return t[Dr]!=="open"?(t.nextTick(e,new rl("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"})),!0):!1},DVe=function(t){return Object.keys(t.supports.encodings).filter(e=>!!t.supports.encodings[e])}});var BL=V(Uv=>{"use strict";f();Uv.AbstractLevel=DL().AbstractLevel;Uv.AbstractSublevel=DL().AbstractSublevel;Uv.AbstractIterator=Iy().AbstractIterator;Uv.AbstractKeyIterator=Iy().AbstractKeyIterator;Uv.AbstractValueIterator=Iy().AbstractValueIterator;Uv.AbstractChainedBatch=bL().AbstractChainedBatch});var nme=V((fIt,rme)=>{f();rme.exports=MVe;var BVe=_L();function MVe(t,e,r){if(typeof e!="number")throw new Error("second argument must be a Number");let n,i,o,s,a,d=!0,u;Array.isArray(t)?(n=[],o=i=t.length):(s=Object.keys(t),n={},o=i=s.length);function c(p){function m(){r&&r(p,n),r=null}d?BVe(m):m()}function l(p,m,g){if(n[p]=g,m&&(a=!0),--o===0||m)c(m);else if(!a&&u{"use strict";f();ime.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 OL=V((yIt,ome)=>{"use strict";f();var OVe=new TextEncoder;ome.exports=function(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):OVe.encode(t)}});var ume=V(dme=>{"use strict";f();var{AbstractIterator:CVe}=BL(),sme=ML(),XI=OL(),Ef=Symbol("cache"),rp=Symbol("finished"),td=Symbol("options"),np=Symbol("currentOptions"),qv=Symbol("position"),CL=Symbol("location"),I2=Symbol("first"),ame={},$L=class extends CVe{constructor(e,r,n){super(e,n),this[Ef]=[],this[rp]=this.limit===0,this[td]=n,this[np]={...n},this[qv]=void 0,this[CL]=r,this[I2]=!0}_nextv(e,r,n){if(this[I2]=!1,this[rp])return this.nextTick(n,null,[]);if(this[Ef].length>0)return e=Math.min(e,this[Ef].length),this.nextTick(n,null,this[Ef].splice(0,e));this[qv]!==void 0&&(this[td].reverse?(this[np].lt=this[qv],this[np].lte=void 0):(this[np].gt=this[qv],this[np].gte=void 0));let i;try{i=sme(this[np])}catch{return this[rp]=!0,this.nextTick(n,null,[])}let o=this.db.db.transaction([this[CL]],"readonly"),s=o.objectStore(this[CL]),a=[];if(this[td].reverse){let d=!this[td].values&&s.openKeyCursor?"openKeyCursor":"openCursor";s[d](i,"prev").onsuccess=u=>{let c=u.target.result;if(c){let{key:l,value:p}=c;this[qv]=l,a.push([this[td].keys&&l!==void 0?XI(l):void 0,this[td].values&&p!==void 0?XI(p):void 0]),a.length{if(d===void 0||u===void 0)return;let l=Math.max(d.length,u.length);l===0||e===1/0?this[rp]=!0:this[qv]=d[l-1],a.length=l;for(let p=0;p{d=l.target.result,c()}:(d=[],this.nextTick(c)),this[td].values?s.getAll(i,e<1/0?e:void 0).onsuccess=l=>{u=l.target.result,c()}:(u=[],this.nextTick(c))}o.onabort=()=>{n(o.error||new Error("aborted by user")),n=null},o.oncomplete=()=>{n(null,a),n=null}}_next(e){if(this[Ef].length>0){let[r,n]=this[Ef].shift();this.nextTick(e,null,r,n)}else if(this[rp])this.nextTick(e);else{let r=Math.min(100,this.limit-this.count);this[I2]&&(this[I2]=!1,r=1),this._nextv(r,ame,(n,i)=>{if(n)return e(n);this[Ef]=i,this._next(e)})}}_all(e,r){this[I2]=!1;let n=this[Ef].splice(0,this[Ef].length),i=this.limit-this.count-n.length;if(i<=0)return this.nextTick(r,null,n);this._nextv(i,ame,(o,s)=>{if(o)return r(o);n.length>0&&(s=n.concat(s)),r(null,s)})}_seek(e,r){this[I2]=!0,this[Ef]=[],this[rp]=!1,this[qv]=void 0,this[np]={...this[td]};let n;try{n=sme(this[td])}catch{this[rp]=!0;return}n!==null&&!n.includes(e)?this[rp]=!0:this[td].reverse?this[np].lte=e:this[np].gte=e}};dme.Iterator=$L;function cme(t){typeof t.commit=="function"&&t.commit()}});var fme=V((wIt,lme)=>{"use strict";f();lme.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),d=0;s.oncomplete=function(){o()},s.onabort=function(){o(s.error||new Error("aborted by user"))};let u=a.openKeyCursor?"openKeyCursor":"openCursor",c=i.reverse?"prev":"next";a[u](n,c).onsuccess=function(l){let p=l.target.result;p&&(a.delete(p.key).onsuccess=function(){(i.limit<=0||++d{"use strict";f();var{AbstractLevel:$Ve}=BL(),hme=el(),jVe=nme(),{fromCallback:NVe}=BS(),{Iterator:UVe}=ume(),pme=OL(),qVe=fme(),LVe=ML(),yme="level-js-",HS=Symbol("idb"),jL=Symbol("namePrefix"),ip=Symbol("location"),NL=Symbol("version"),Lv=Symbol("store"),VS=Symbol("onComplete"),mme=Symbol("promise"),QI=class extends $Ve{constructor(e,r,n){if(typeof r=="function"||typeof n=="function")throw new hme("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[ip]=e,this[jL]=i??yme,this[NL]=parseInt(o||1,10),this[HS]=null}get location(){return this[ip]}get namePrefix(){return this[jL]}get version(){return this[NL]}get db(){return this[HS]}get type(){return"browser-level"}_open(e,r){let n=indexedDB.open(this[jL]+this[ip],this[NL]);n.onerror=function(){r(n.error||new Error("unknown error"))},n.onsuccess=()=>{this[HS]=n.result,r()},n.onupgradeneeded=i=>{let o=i.target.result;o.objectStoreNames.contains(this[ip])||o.createObjectStore(this[ip])}}[Lv](e){return this[HS].transaction([this[ip]],e).objectStore(this[ip])}[VS](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[Lv]("readonly"),o;try{o=i.get(e)}catch(s){return this.nextTick(n,s)}this[VS](o,function(s,a){if(s)return n(s);if(a===void 0)return n(new hme("Entry not found",{code:"LEVEL_NOT_FOUND"}));n(null,pme(a))})}_getMany(e,r,n){let i=this[Lv]("readonly"),o=e.map(s=>a=>{let d;try{d=i.get(s)}catch(u){return a(u)}d.onsuccess=()=>{let u=d.result;a(null,u===void 0?u:pme(u))},d.onerror=u=>{u.stopPropagation(),a(d.error)}});jVe(o,16,n)}_del(e,r,n){let i=this[Lv]("readwrite"),o;try{o=i.delete(e)}catch(s){return this.nextTick(n,s)}this[VS](o,n)}_put(e,r,n,i){let o=this[Lv]("readwrite"),s;try{s=o.put(r,e)}catch(a){return this.nextTick(i,a)}this[VS](s,i)}_iterator(e){return new UVe(this,this[ip],e)}_batch(e,r,n){let i=this[Lv]("readwrite"),o=i.transaction,s=0,a;o.onabort=function(){n(a||o.error||new Error("aborted by user"))},o.oncomplete=function(){n()};function d(){let u=e[s++],c=u.key,l;try{l=u.type==="del"?i.delete(c):i.put(u.value,c)}catch(p){a=p,o.abort();return}s=0)return qVe(this,this[ip],n,e,r);try{let o=this[Lv]("readwrite");i=n?o.delete(n):o.clear()}catch(o){return this.nextTick(r,o)}this[VS](i,r)}_close(e){this[HS].close(),this.nextTick(e)}};QI.destroy=function(t,e,r){typeof e=="function"&&(r=e,e=yme),r=NVe(r,mme);let n=indexedDB.deleteDatabase(e+t);return n.onsuccess=function(){r()},n.onerror=function(i){r(i)},r[mme]};gme.BrowserLevel=QI});var GS=V(vme=>{f();vme.Level=UL().BrowserLevel});var Zi=V((DIt,bme)=>{"use strict";f();bme.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)},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,TypedArrayPrototypeSet(t,e,r){return t.set(e,r)},Uint8Array}});var Sf=V((MIt,LL)=>{"use strict";f();var FVe=pn(),zVe=Object.getPrototypeOf(async function(){}).constructor,wme=globalThis.Blob||FVe.Blob,WVe=typeof wme<"u"?function(e){return e instanceof wme}:function(e){return!1},qL=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{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 zVe},isArrayBufferView(t){return ArrayBuffer.isView(t)}},isBlob:WVe};LL.exports.promisify.custom=Symbol.for("nodejs.util.promisify.custom")});var Na=V((CIt,Eme)=>{"use strict";f();var{format:HVe,inspect:tk,AggregateError:VVe}=Sf(),GVe=globalThis.AggregateError||VVe,JVe=Symbol("kIsNodeError"),ZVe=["string","function","number","object","Function","Object","boolean","bigint","symbol"],YVe=/^([A-Z][a-z0-9]*)+$/,XVe="__node_internal_",rk={};function Fv(t,e){if(!t)throw new rk.ERR_INTERNAL_ASSERTION(e)}function _me(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 QVe(t,e,r){if(typeof e=="function")return Fv(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 Fv(n===r.length,`Code: ${t}; The provided arguments length (${r.length}) does not match the required ones (${n}).`),r.length===0?e:HVe(e,...r)}function Ps(t,e,r){r||(r=Error);class n extends r{constructor(...o){super(QVe(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[JVe]=!0,rk[t]=n}function xme(t){let e=XVe+t.name;return Object.defineProperty(t,"name",{value:e}),t}function eGe(t,e){if(t&&e&&t!==e){if(Array.isArray(e.errors))return e.errors.push(t),e;let r=new GVe([e,t],e.message);return r.code=e.code,r}return t||e}var KL=class extends Error{constructor(e="The operation was aborted",r=void 0){if(r!==void 0&&typeof r!="object")throw new rk.ERR_INVALID_ARG_TYPE("options","Object",r);super(e,r),this.code="ABORT_ERR",this.name="AbortError"}};Ps("ERR_ASSERTION","%s",Error);Ps("ERR_INVALID_ARG_TYPE",(t,e,r)=>{Fv(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 d of e)Fv(typeof d=="string","All expected entries have to be of type string"),ZVe.includes(d)?i.push(d.toLowerCase()):YVe.test(d)?o.push(d):(Fv(d!=="object",'The value "object" should be written as "Object"'),s.push(d));if(o.length>0){let d=i.indexOf("object");d!==-1&&(i.splice(i,d,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 d=i.pop();n+=`one of type ${i.join(", ")}, or ${d}`}}(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 d=o.pop();n+=`an instance of ${o.join(", ")}, or ${d}`}}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 d=s.pop();n+=`one of ${s.join(", ")}, or ${d}`}}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 d=tk(r,{depth:-1});n+=`. Received ${d}`}}else{let d=tk(r,{colors:!1});d.length>25&&(d=`${d.slice(0,25)}...`),n+=`. Received type ${typeof r} (${d})`}return n},TypeError);Ps("ERR_INVALID_ARG_VALUE",(t,e,r="is invalid")=>{let n=tk(e);return n.length>128&&(n=n.slice(0,128)+"..."),`The ${t.includes(".")?"property":"argument"} '${t}' ${r}. Received ${n}`},TypeError);Ps("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);Ps("ERR_MISSING_ARGS",(...t)=>{Fv(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);Ps("ERR_OUT_OF_RANGE",(t,e,r)=>{Fv(e,'Missing "range" argument');let n;return Number.isInteger(r)&&Math.abs(r)>2**32?n=_me(String(r)):typeof r=="bigint"?(n=String(r),(r>2n**32n||r<-(2n**32n))&&(n=_me(n)),n+="n"):n=tk(r),`The value of "${t}" is out of range. It must be ${e}. Received ${n}`},RangeError);Ps("ERR_MULTIPLE_CALLBACK","Callback called multiple times",Error);Ps("ERR_METHOD_NOT_IMPLEMENTED","The %s method is not implemented",Error);Ps("ERR_STREAM_ALREADY_FINISHED","Cannot call %s after a stream was finished",Error);Ps("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable",Error);Ps("ERR_STREAM_DESTROYED","Cannot call %s after a stream was destroyed",Error);Ps("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);Ps("ERR_STREAM_PREMATURE_CLOSE","Premature close",Error);Ps("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF",Error);Ps("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event",Error);Ps("ERR_STREAM_WRITE_AFTER_END","write after end",Error);Ps("ERR_UNKNOWN_ENCODING","Unknown encoding: %s",TypeError);Eme.exports={AbortError:KL,aggregateTwoErrors:xme(eGe),hideStackFrames:xme,codes:rk}});var JS=V((jIt,Bme)=>{"use strict";f();var{ArrayIsArray:zL,ArrayPrototypeIncludes:Pme,ArrayPrototypeJoin:Ime,ArrayPrototypeMap:tGe,NumberIsInteger:WL,NumberIsNaN:rGe,NumberMAX_SAFE_INTEGER:nGe,NumberMIN_SAFE_INTEGER:iGe,NumberParseInt:oGe,ObjectPrototypeHasOwnProperty:sGe,RegExpPrototypeExec:kme,String:aGe,StringPrototypeToUpperCase:cGe,StringPrototypeTrim:dGe}=Zi(),{hideStackFrames:Zd,codes:{ERR_SOCKET_BAD_PORT:uGe,ERR_INVALID_ARG_TYPE:Ua,ERR_INVALID_ARG_VALUE:k2,ERR_OUT_OF_RANGE:zv,ERR_UNKNOWN_SIGNAL:Sme}}=Na(),{normalizeEncoding:lGe}=Sf(),{isAsyncFunction:fGe,isArrayBufferView:hGe}=Sf().types,Ame={};function pGe(t){return t===(t|0)}function mGe(t){return t===t>>>0}var yGe=/^[0-7]+$/,gGe="must be a 32-bit unsigned integer or an octal string";function vGe(t,e,r){if(typeof t>"u"&&(t=r),typeof t=="string"){if(kme(yGe,t)===null)throw new k2(e,t,gGe);t=oGe(t,8)}return Rme(t,e),t}var bGe=Zd((t,e,r=iGe,n=nGe)=>{if(typeof t!="number")throw new Ua(e,"number",t);if(!WL(t))throw new zv(e,"an integer",t);if(tn)throw new zv(e,`>= ${r} && <= ${n}`,t)}),wGe=Zd((t,e,r=-2147483648,n=2147483647)=>{if(typeof t!="number")throw new Ua(e,"number",t);if(!WL(t))throw new zv(e,"an integer",t);if(tn)throw new zv(e,`>= ${r} && <= ${n}`,t)}),Rme=Zd((t,e,r=!1)=>{if(typeof t!="number")throw new Ua(e,"number",t);if(!WL(t))throw new zv(e,"an integer",t);let n=r?1:0,i=4294967295;if(ti)throw new zv(e,`>= ${n} && <= ${i}`,t)});function HL(t,e){if(typeof t!="string")throw new Ua(e,"string",t)}function _Ge(t,e,r=void 0,n){if(typeof t!="number")throw new Ua(e,"number",t);if(r!=null&&tn||(r!=null||n!=null)&&rGe(t))throw new zv(e,`${r!=null?`>= ${r}`:""}${r!=null&&n!=null?" && ":""}${n!=null?`<= ${n}`:""}`,t)}var xGe=Zd((t,e,r)=>{if(!Pme(r,t)){let i="must be one of: "+Ime(tGe(r,o=>typeof o=="string"?`'${o}'`:aGe(o)),", ");throw new k2(e,t,i)}});function Dme(t,e){if(typeof t!="boolean")throw new Ua(e,"boolean",t)}function FL(t,e,r){return t==null||!sGe(t,e)?r:t[e]}var EGe=Zd((t,e,r=null)=>{let n=FL(r,"allowArray",!1),i=FL(r,"allowFunction",!1);if(!FL(r,"nullable",!1)&&t===null||!n&&zL(t)||typeof t!="object"&&(!i||typeof t!="function"))throw new Ua(e,"Object",t)}),SGe=Zd((t,e)=>{if(t!=null&&typeof t!="object"&&typeof t!="function")throw new Ua(e,"a dictionary",t)}),VL=Zd((t,e,r=0)=>{if(!zL(t))throw new Ua(e,"Array",t);if(t.length{if(!hGe(t))throw new Ua(e,["Buffer","TypedArray","DataView"],t)});function kGe(t,e){let r=lGe(e),n=t.length;if(r==="hex"&&n%2!==0)throw new k2("encoding",e,`is invalid for data of length ${n}`)}function RGe(t,e="Port",r=!0){if(typeof t!="number"&&typeof t!="string"||typeof t=="string"&&dGe(t).length===0||+t!==+t>>>0||t>65535||t===0&&!r)throw new uGe(e,t,r);return t|0}var DGe=Zd((t,e)=>{if(t!==void 0&&(t===null||typeof t!="object"||!("aborted"in t)))throw new Ua(e,"AbortSignal",t)}),BGe=Zd((t,e)=>{if(typeof t!="function")throw new Ua(e,"Function",t)}),MGe=Zd((t,e)=>{if(typeof t!="function"||fGe(t))throw new Ua(e,"Function",t)}),OGe=Zd((t,e)=>{if(t!==void 0)throw new Ua(e,"undefined",t)});function CGe(t,e,r){if(!Pme(r,t))throw new Ua(e,`('${Ime(r,"|")}')`,t)}var $Ge=/^(?:<[^>]*>)(?:\s*;\s*[^;"\s]+(?:=(")?[^;"\s]*\1)?)*$/;function Tme(t,e){if(typeof t>"u"||!kme($Ge,t))throw new k2(e,t,'must be an array or string of format "; rel=preload; as=style"')}function jGe(t){if(typeof t=="string")return Tme(t,"hints"),t;if(zL(t)){let e=t.length,r="";if(e===0)return r;for(let n=0;n; rel=preload; as=style"')}Bme.exports={isInt32:pGe,isUint32:mGe,parseFileMode:vGe,validateArray:VL,validateStringArray:AGe,validateBooleanArray:TGe,validateBoolean:Dme,validateBuffer:IGe,validateDictionary:SGe,validateEncoding:kGe,validateFunction:BGe,validateInt32:wGe,validateInteger:bGe,validateNumber:_Ge,validateObject:EGe,validateOneOf:xGe,validatePlainFunction:MGe,validatePort:RGe,validateSignalName:PGe,validateString:HL,validateUint32:Rme,validateUndefined:OGe,validateUnion:CGe,validateAbortSignal:DGe,validateLinkHeaderValue:jGe}});var Tf=V((UIt,Gme)=>{"use strict";f();var{Symbol:nk,SymbolAsyncIterator:Mme,SymbolIterator:Ome,SymbolFor:Cme}=Zi(),$me=nk("kDestroyed"),jme=nk("kIsErrored"),GL=nk("kIsReadable"),Nme=nk("kIsDisturbed"),NGe=Cme("nodejs.webstream.isClosedPromise"),UGe=Cme("nodejs.webstream.controllerErrorFunction");function ik(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 ok(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 qGe(t){return!!(t&&typeof t.pipe=="function"&&t._readableState&&typeof t.on=="function"&&typeof t.write=="function")}function Af(t){return t&&(t._readableState||t._writableState||typeof t.write=="function"&&typeof t.on=="function"||typeof t.pipe=="function"&&typeof t.on=="function")}function Ume(t){return!!(t&&!Af(t)&&typeof t.pipeThrough=="function"&&typeof t.getReader=="function"&&typeof t.cancel=="function")}function qme(t){return!!(t&&!Af(t)&&typeof t.getWriter=="function"&&typeof t.abort=="function")}function Lme(t){return!!(t&&!Af(t)&&typeof t.readable=="object"&&typeof t.writable=="object")}function LGe(t){return Ume(t)||qme(t)||Lme(t)}function KGe(t,e){return t==null?!1:e===!0?typeof t[Mme]=="function":e===!1?typeof t[Ome]=="function":typeof t[Mme]=="function"||typeof t[Ome]=="function"}function sk(t){if(!Af(t))return null;let e=t._writableState,r=t._readableState,n=e||r;return!!(t.destroyed||t[$me]||n!=null&&n.destroyed)}function Kme(t){if(!ok(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 FGe(t,e){if(!ok(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 zGe(t){if(!ik(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 Fme(t,e){if(!ik(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 zme(t){return t&&t[GL]!=null?t[GL]:typeof t?.readable!="boolean"?null:sk(t)?!1:ik(t)&&t.readable&&!Fme(t)}function Wme(t){return typeof t?.writable!="boolean"?null:sk(t)?!1:ok(t)&&t.writable&&!Kme(t)}function WGe(t,e){return Af(t)?sk(t)?!0:!(e?.readable!==!1&&zme(t)||e?.writable!==!1&&Wme(t)):null}function HGe(t){var e,r;return Af(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 VGe(t){var e,r;return Af(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 GGe(t){if(!Af(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"&&Hme(t)?t._closed:null}function Hme(t){return typeof t._closed=="boolean"&&typeof t._defaultKeepAlive=="boolean"&&typeof t._removedConnection=="boolean"&&typeof t._removedContLen=="boolean"}function Vme(t){return typeof t._sent100=="boolean"&&Hme(t)}function JGe(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 ZGe(t){if(!Af(t))return null;let e=t._writableState,r=t._readableState,n=e||r;return!n&&Vme(t)||!!(n&&n.autoDestroy&&n.emitClose&&n.closed===!1)}function YGe(t){var e;return!!(t&&((e=t[Nme])!==null&&e!==void 0?e:t.readableDidRead||t.readableAborted))}function XGe(t){var e,r,n,i,o,s,a,d,u,c;return!!(t&&((e=(r=(n=(i=(o=(s=t[jme])!==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:(d=t._writableState)===null||d===void 0?void 0:d.errorEmitted)!==null&&r!==void 0?r:(u=t._readableState)===null||u===void 0?void 0:u.errored)!==null&&e!==void 0?e:!((c=t._writableState)===null||c===void 0)&&c.errored))}Gme.exports={kDestroyed:$me,isDisturbed:YGe,kIsDisturbed:Nme,isErrored:XGe,kIsErrored:jme,isReadable:zme,kIsReadable:GL,kIsClosedPromise:NGe,kControllerErrorFunction:UGe,isClosed:GGe,isDestroyed:sk,isDuplexNodeStream:qGe,isFinished:WGe,isIterable:KGe,isReadableNodeStream:ik,isReadableStream:Ume,isReadableEnded:zGe,isReadableFinished:Fme,isReadableErrored:VGe,isNodeStream:Af,isWebStream:LGe,isWritable:Wme,isWritableNodeStream:ok,isWritableStream:qme,isWritableEnded:Kme,isWritableFinished:FGe,isWritableErrored:HGe,isServerRequest:JGe,isServerResponse:Vme,willEmitClose:ZGe,isTransformStream:Lme}});var op=V((LIt,QL)=>{f();var By=js(),{AbortError:nye,codes:QGe}=Na(),{ERR_INVALID_ARG_TYPE:eJe,ERR_STREAM_PREMATURE_CLOSE:Jme}=QGe,{kEmptyObject:ZL,once:YL}=Sf(),{validateAbortSignal:tJe,validateFunction:rJe,validateObject:nJe,validateBoolean:iJe}=JS(),{Promise:oJe,PromisePrototypeThen:sJe}=Zi(),{isClosed:aJe,isReadable:Zme,isReadableNodeStream:JL,isReadableStream:cJe,isReadableFinished:Yme,isReadableErrored:Xme,isWritable:Qme,isWritableNodeStream:eye,isWritableStream:dJe,isWritableFinished:tye,isWritableErrored:rye,isNodeStream:uJe,willEmitClose:lJe,kIsClosedPromise:fJe}=Tf();function hJe(t){return t.setHeader&&typeof t.abort=="function"}var XL=()=>{};function iye(t,e,r){var n,i;if(arguments.length===2?(r=e,e=ZL):e==null?e=ZL:nJe(e,"options"),rJe(r,"callback"),tJe(e.signal,"options.signal"),r=YL(r),cJe(t)||dJe(t))return pJe(t,e,r);if(!uJe(t))throw new eJe("stream",["ReadableStream","WritableStream","Stream"],t);let o=(n=e.readable)!==null&&n!==void 0?n:JL(t),s=(i=e.writable)!==null&&i!==void 0?i:eye(t),a=t._writableState,d=t._readableState,u=()=>{t.writable||p()},c=lJe(t)&&JL(t)===o&&eye(t)===s,l=tye(t,!1),p=()=>{l=!0,t.destroyed&&(c=!1),!(c&&(!t.readable||o))&&(!o||m)&&r.call(t)},m=Yme(t,!1),g=()=>{m=!0,t.destroyed&&(c=!1),!(c&&(!t.writable||s))&&(!s||l)&&r.call(t)},v=j=>{r.call(t,j)},x=aJe(t),S=()=>{x=!0;let j=rye(t)||Xme(t);if(j&&typeof j!="boolean")return r.call(t,j);if(o&&!m&&JL(t,!0)&&!Yme(t,!1))return r.call(t,new Jme);if(s&&!l&&!tye(t,!1))return r.call(t,new Jme);r.call(t)},P=()=>{x=!0;let j=rye(t)||Xme(t);if(j&&typeof j!="boolean")return r.call(t,j);r.call(t)},A=()=>{t.req.on("finish",p)};hJe(t)?(t.on("complete",p),c||t.on("abort",S),t.req?A():t.on("request",A)):s&&!a&&(t.on("end",u),t.on("close",u)),!c&&typeof t.aborted=="boolean"&&t.on("aborted",S),t.on("end",g),t.on("finish",p),e.error!==!1&&t.on("error",v),t.on("close",S),x?By.nextTick(S):a!=null&&a.errorEmitted||d!=null&&d.errorEmitted?c||By.nextTick(P):(!o&&(!c||Zme(t))&&(l||Qme(t)===!1)||!s&&(!c||Qme(t))&&(m||Zme(t)===!1)||d&&t.req&&t.aborted)&&By.nextTick(P);let $=()=>{r=XL,t.removeListener("aborted",S),t.removeListener("complete",p),t.removeListener("abort",S),t.removeListener("request",A),t.req&&t.req.removeListener("finish",p),t.removeListener("end",u),t.removeListener("close",u),t.removeListener("finish",p),t.removeListener("end",g),t.removeListener("error",v),t.removeListener("close",S)};if(e.signal&&!x){let j=()=>{let q=r;$(),q.call(t,new nye(void 0,{cause:e.signal.reason}))};if(e.signal.aborted)By.nextTick(j);else{let q=r;r=YL((...F)=>{e.signal.removeEventListener("abort",j),q.apply(t,F)}),e.signal.addEventListener("abort",j)}}return $}function pJe(t,e,r){let n=!1,i=XL;if(e.signal)if(i=()=>{n=!0,r.call(t,new nye(void 0,{cause:e.signal.reason}))},e.signal.aborted)By.nextTick(i);else{let s=r;r=YL((...a)=>{e.signal.removeEventListener("abort",i),s.apply(t,a)}),e.signal.addEventListener("abort",i)}let o=(...s)=>{n||By.nextTick(()=>r.apply(t,s))};return sJe(t[fJe].promise,o,o),XL}function mJe(t,e){var r;let n=!1;return e===null&&(e=ZL),(r=e)!==null&&r!==void 0&&r.cleanup&&(iJe(e.cleanup,"cleanup"),n=e.cleanup),new oJe((i,o)=>{let s=iye(t,e,a=>{n&&s(),a?o(a):i()})})}QL.exports=iye;QL.exports.finished=mJe});var Wv=V((FIt,fye)=>{"use strict";f();var Pf=js(),{aggregateTwoErrors:yJe,codes:{ERR_MULTIPLE_CALLBACK:gJe},AbortError:vJe}=Na(),{Symbol:aye}=Zi(),{kDestroyed:bJe,isDestroyed:wJe,isFinished:_Je,isServerRequest:xJe}=Tf(),cye=aye("kDestroy"),eK=aye("kConstruct");function dye(t,e,r){t&&(t.stack,e&&!e.errored&&(e.errored=t),r&&!r.errored&&(r.errored=t))}function EJe(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):(dye(t,n,r),n&&(n.destroyed=!0),r&&(r.destroyed=!0),i.constructed?oye(this,t,e):this.once(cye,function(o){oye(this,yJe(o,t),e)}),this)}function oye(t,e,r){let n=!1;function i(o){if(n)return;n=!0;let s=t._readableState,a=t._writableState;dye(o,a,s),a&&(a.closed=!0),s&&(s.closed=!0),typeof r=="function"&&r(o),o?Pf.nextTick(SJe,t,o):Pf.nextTick(uye,t)}try{t._destroy(e||null,i)}catch(o){i(o)}}function SJe(t,e){tK(t,e),uye(t)}function uye(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 tK(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 AJe(){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 rK(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?Pf.nextTick(tK,t,e):tK(t,e))}function TJe(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(eK,e),!(t.listenerCount(eK)>1)&&Pf.nextTick(PJe,t)}function PJe(t){let e=!1;function r(n){if(e){rK(t,n??new gJe);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(cye,n):n?rK(t,n,!0):Pf.nextTick(IJe,t)}try{t._construct(n=>{Pf.nextTick(r,n)})}catch(n){Pf.nextTick(r,n)}}function IJe(t){t.emit(eK)}function sye(t){return t?.setHeader&&typeof t.abort=="function"}function lye(t){t.emit("close")}function kJe(t,e){t.emit("error",e),Pf.nextTick(lye,t)}function RJe(t,e){!t||wJe(t)||(!e&&!_Je(t)&&(e=new vJe),xJe(t)?(t.socket=null,t.destroy(e)):sye(t)?t.abort():sye(t.req)?t.req.abort():typeof t.destroy=="function"?t.destroy(e):typeof t.close=="function"?t.close():e?Pf.nextTick(kJe,t,e):Pf.nextTick(lye,t),t.destroyed||(t[bJe]=!0))}fye.exports={construct:TJe,destroyer:RJe,destroy:EJe,undestroy:AJe,errorOrDestroy:rK}});var dk=V((WIt,pye)=>{"use strict";f();var{ArrayIsArray:DJe,ObjectSetPrototypeOf:hye}=Zi(),{EventEmitter:ak}=Aa();function ck(t){ak.call(this,t)}hye(ck.prototype,ak.prototype);hye(ck,ak);ck.prototype.pipe=function(t,e){let r=this;function n(c){t.writable&&t.write(c)===!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 d(c){u(),ak.listenerCount(this,"error")===0&&this.emit("error",c)}nK(r,"error",d),nK(t,"error",d);function u(){r.removeListener("data",n),t.removeListener("drain",i),r.removeListener("end",s),r.removeListener("close",a),r.removeListener("error",d),t.removeListener("error",d),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 nK(t,e,r){if(typeof t.prependListener=="function")return t.prependListener(e,r);!t._events||!t._events[e]?t.on(e,r):DJe(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]}pye.exports={Stream:ck,prependListener:nK}});var ZS=V((VIt,uk)=>{"use strict";f();var{AbortError:mye,codes:BJe}=Na(),{isNodeStream:yye,isWebStream:MJe,kControllerErrorFunction:OJe}=Tf(),CJe=op(),{ERR_INVALID_ARG_TYPE:gye}=BJe,$Je=(t,e)=>{if(typeof t!="object"||!("aborted"in t))throw new gye(e,"AbortSignal",t)};uk.exports.addAbortSignal=function(e,r){if($Je(e,"signal"),!yye(r)&&!MJe(r))throw new gye("stream",["ReadableStream","WritableStream","Stream"],r);return uk.exports.addAbortSignalNoValidate(e,r)};uk.exports.addAbortSignalNoValidate=function(t,e){if(typeof t!="object"||!("aborted"in t))return e;let r=yye(e)?()=>{e.destroy(new mye(void 0,{cause:t.reason}))}:()=>{e[OJe](new mye(void 0,{cause:t.reason}))};return t.aborted?r():(t.addEventListener("abort",r),CJe(e,()=>t.removeEventListener("abort",r))),e}});var wye=V((ZIt,bye)=>{"use strict";f();var{StringPrototypeSlice:vye,SymbolIterator:jJe,TypedArrayPrototypeSet:lk,Uint8Array:NJe}=Zi(),{Buffer:iK}=pn(),{inspect:UJe}=Sf();bye.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 iK.alloc(0);let r=iK.allocUnsafe(e>>>0),n=this.head,i=0;for(;n;)lk(r,n.data,i),i+=n.data.length,n=n.next;return r}consume(e,r){let n=this.head.data;if(eo.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+=vye(o,0,e),this.head=n,n.data=vye(o,e));break}++i}while((n=n.next)!==null);return this.length-=i,r}_getBuffer(e){let r=iK.allocUnsafe(e),n=e,i=this.head,o=0;do{let s=i.data;if(e>s.length)lk(r,s,n-e),e-=s.length;else{e===s.length?(lk(r,s,n-e),++o,i.next?this.head=i.next:this.head=this.tail=null):(lk(r,new NJe(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 UJe(this,{...r,depth:0,customInspect:!1})}}});var fk=V((XIt,xye)=>{"use strict";f();var{MathFloor:qJe,NumberIsInteger:LJe}=Zi(),{ERR_INVALID_ARG_VALUE:KJe}=Na().codes;function FJe(t,e,r){return t.highWaterMark!=null?t.highWaterMark:e?t[r]:null}function _ye(t){return t?16:16*1024}function zJe(t,e,r,n){let i=FJe(e,n,r);if(i!=null){if(!LJe(i)||i<0){let o=n?`options.${r}`:"options.highWaterMark";throw new KJe(o,i)}return qJe(i)}return _ye(t.objectMode)}xye.exports={getHighWaterMark:zJe,getDefaultHighWaterMark:_ye}});var oK=V((ekt,Tye)=>{"use strict";f();var Eye=js(),{PromisePrototypeThen:WJe,SymbolAsyncIterator:Sye,SymbolIterator:Aye}=Zi(),{Buffer:HJe}=pn(),{ERR_INVALID_ARG_TYPE:VJe,ERR_STREAM_NULL_VALUES:GJe}=Na().codes;function JJe(t,e,r){let n;if(typeof e=="string"||e instanceof HJe)return new t({objectMode:!0,...r,read(){this.push(e),this.push(null)}});let i;if(e&&e[Sye])i=!0,n=e[Sye]();else if(e&&e[Aye])i=!1,n=e[Aye]();else throw new VJe("iterable",["Iterable"],e);let o=new t({objectMode:!0,highWaterMark:1,...r}),s=!1;o._read=function(){s||(s=!0,d())},o._destroy=function(u,c){WJe(a(u),()=>Eye.nextTick(c,u),l=>Eye.nextTick(c,l||u))};async function a(u){let c=u!=null,l=typeof n.throw=="function";if(c&&l){let{value:p,done:m}=await n.throw(u);if(await p,m)return}if(typeof n.return=="function"){let{value:p}=await n.return();await p}}async function d(){for(;;){try{let{value:u,done:c}=i?await n.next():n.next();if(c)o.push(null);else{let l=u&&typeof u.then=="function"?await u:u;if(l===null)throw s=!1,new GJe;if(o.push(l))continue;s=!1}}catch(u){o.destroy(u)}break}}return o}Tye.exports=JJe});var YS=V((rkt,Uye)=>{f();var nl=js(),{ArrayPrototypeIndexOf:ZJe,NumberIsInteger:YJe,NumberIsNaN:XJe,NumberParseInt:QJe,ObjectDefineProperties:kye,ObjectKeys:eZe,ObjectSetPrototypeOf:Rye,Promise:tZe,SafeSet:rZe,SymbolAsyncIterator:nZe,Symbol:iZe}=Zi();Uye.exports=xr;xr.ReadableState=lK;var{EventEmitter:oZe}=Aa(),{Stream:My,prependListener:sZe}=dk(),{Buffer:sK}=pn(),{addAbortSignal:aZe}=ZS(),cZe=op(),Cr=Sf().debuglog("stream",t=>{Cr=t}),dZe=wye(),D2=Wv(),{getHighWaterMark:uZe,getDefaultHighWaterMark:lZe}=fk(),{aggregateTwoErrors:Pye,codes:{ERR_INVALID_ARG_TYPE:fZe,ERR_METHOD_NOT_IMPLEMENTED:hZe,ERR_OUT_OF_RANGE:pZe,ERR_STREAM_PUSH_AFTER_EOF:mZe,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:yZe}}=Na(),{validateObject:gZe}=JS(),Hv=iZe("kPaused"),{StringDecoder:Dye}=Rw(),vZe=oK();Rye(xr.prototype,My.prototype);Rye(xr,My);var aK=()=>{},{errorOrDestroy:R2}=D2;function lK(t,e,r){typeof r!="boolean"&&(r=e instanceof If()),this.objectMode=!!(t&&t.objectMode),r&&(this.objectMode=this.objectMode||!!(t&&t.readableObjectMode)),this.highWaterMark=t?uZe(this,t,"readableHighWaterMark",r):lZe(!1),this.buffer=new dZe,this.length=0,this.pipes=[],this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.constructed=!0,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this[Hv]=null,this.errorEmitted=!1,this.emitClose=!t||t.emitClose!==!1,this.autoDestroy=!t||t.autoDestroy!==!1,this.destroyed=!1,this.errored=null,this.closed=!1,this.closeEmitted=!1,this.defaultEncoding=t&&t.defaultEncoding||"utf8",this.awaitDrainWriters=null,this.multiAwaitDrain=!1,this.readingMore=!1,this.dataEmitted=!1,this.decoder=null,this.encoding=null,t&&t.encoding&&(this.decoder=new Dye(t.encoding),this.encoding=t.encoding)}function xr(t){if(!(this instanceof xr))return new xr(t);let e=this instanceof If();this._readableState=new lK(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&&aZe(t.signal,this)),My.call(this,t),D2.construct(this,()=>{this._readableState.needReadable&&hk(this,this._readableState)})}xr.prototype.destroy=D2.destroy;xr.prototype._undestroy=D2.undestroy;xr.prototype._destroy=function(t,e){e(t)};xr.prototype[oZe.captureRejectionSymbol]=function(t){this.destroy(t)};xr.prototype.push=function(t,e){return Bye(this,t,e,!1)};xr.prototype.unshift=function(t,e){return Bye(this,t,e,!0)};function Bye(t,e,r,n){Cr("readableAddChunk",e);let i=t._readableState,o;if(i.objectMode||(typeof e=="string"?(r=r||i.defaultEncoding,i.encoding!==r&&(n&&i.encoding?e=sK.from(e,r).toString(i.encoding):(e=sK.from(e,r),r=""))):e instanceof sK?r="":My._isUint8Array(e)?(e=My._uint8ArrayToBuffer(e),r=""):e!=null&&(o=new fZe("chunk",["string","Buffer","Uint8Array"],e))),o)R2(t,o);else if(e===null)i.reading=!1,_Ze(t,i);else if(i.objectMode||e&&e.length>0)if(n)if(i.endEmitted)R2(t,new yZe);else{if(i.destroyed||i.errored)return!1;cK(t,i,e,!0)}else if(i.ended)R2(t,new mZe);else{if(i.destroyed||i.errored)return!1;i.reading=!1,i.decoder&&!r?(e=i.decoder.write(e),i.objectMode||e.length!==0?cK(t,i,e,!1):hk(t,i)):cK(t,i,e,!1)}else n||(i.reading=!1,hk(t,i));return!i.ended&&(i.length0?(e.multiAwaitDrain?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.needReadable&&pk(t)),hk(t,e)}xr.prototype.isPaused=function(){let t=this._readableState;return t[Hv]===!0||t.flowing===!1};xr.prototype.setEncoding=function(t){let e=new Dye(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 bZe=1073741824;function wZe(t){if(t>bZe)throw new pZe("size","<= 1GiB",t);return t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++,t}function Iye(t,e){return t<=0||e.length===0&&e.ended?0:e.objectMode?1:XJe(t)?e.flowing&&e.length?e.buffer.first().length:e.length:t<=e.length?t:e.ended?e.length:0}xr.prototype.read=function(t){Cr("read",t),t===void 0?t=NaN:YJe(t)||(t=QJe(t,10));let e=this._readableState,r=t;if(t>e.highWaterMark&&(e.highWaterMark=wZe(t)),t!==0&&(e.emittedReadable=!1),t===0&&e.needReadable&&((e.highWaterMark!==0?e.length>=e.highWaterMark:e.length>0)||e.ended))return Cr("read: emitReadable",e.length,e.ended),e.length===0&&e.ended?dK(this):pk(this),null;if(t=Iye(t,e),t===0&&e.ended)return e.length===0&&dK(this),null;let n=e.needReadable;if(Cr("need readable",n),(e.length===0||e.length-t0?i=jye(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&&dK(this)),i!==null&&!e.errorEmitted&&!e.closeEmitted&&(e.dataEmitted=!0,this.emit("data",i)),i};function _Ze(t,e){if(Cr("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?pk(t):(e.needReadable=!1,e.emittedReadable=!0,Mye(t))}}function pk(t){let e=t._readableState;Cr("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(Cr("emitReadable",e.flowing),e.emittedReadable=!0,nl.nextTick(Mye,t))}function Mye(t){let e=t._readableState;Cr("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,Cye(t)}function hk(t,e){!e.readingMore&&e.constructed&&(e.readingMore=!0,nl.nextTick(xZe,t,e))}function xZe(t,e){for(;!e.reading&&!e.ended&&(e.length1&&n.pipes.includes(t)&&(Cr("false write response, pause",n.awaitDrainWriters.size),n.awaitDrainWriters.add(t)),r.pause()),d||(d=EZe(r,t),t.on("drain",d))}r.on("data",p);function p(S){Cr("ondata");let P=t.write(S);Cr("dest.write",P),P===!1&&l()}function m(S){if(Cr("onerror",S),x(),t.removeListener("error",m),t.listenerCount("error")===0){let P=t._writableState||t._readableState;P&&!P.errorEmitted?R2(t,S):t.emit("error",S)}}sZe(t,"error",m);function g(){t.removeListener("finish",v),x()}t.once("close",g);function v(){Cr("onfinish"),t.removeListener("close",g),x()}t.once("finish",v);function x(){Cr("unpipe"),r.unpipe(t)}return t.emit("pipe",r),t.writableNeedDrain===!0?n.flowing&&l():n.flowing||(Cr("pipe resume"),r.resume()),t};function EZe(t,e){return function(){let n=t._readableState;n.awaitDrainWriters===e?(Cr("pipeOnDrain",1),n.awaitDrainWriters=null):n.multiAwaitDrain&&(Cr("pipeOnDrain",n.awaitDrainWriters.size),n.awaitDrainWriters.delete(e)),(!n.awaitDrainWriters||n.awaitDrainWriters.size===0)&&t.listenerCount("data")&&t.resume()}}xr.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;o0,n.flowing!==!1&&this.resume()):t==="readable"&&!n.endEmitted&&!n.readableListening&&(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,Cr("on readable",n.length,n.reading),n.length?pk(this):n.reading||nl.nextTick(SZe,this)),r};xr.prototype.addListener=xr.prototype.on;xr.prototype.removeListener=function(t,e){let r=My.prototype.removeListener.call(this,t,e);return t==="readable"&&nl.nextTick(Oye,this),r};xr.prototype.off=xr.prototype.removeListener;xr.prototype.removeAllListeners=function(t){let e=My.prototype.removeAllListeners.apply(this,arguments);return(t==="readable"||t===void 0)&&nl.nextTick(Oye,this),e};function Oye(t){let e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&e[Hv]===!1?e.flowing=!0:t.listenerCount("data")>0?t.resume():e.readableListening||(e.flowing=null)}function SZe(t){Cr("readable nexttick read 0"),t.read(0)}xr.prototype.resume=function(){let t=this._readableState;return t.flowing||(Cr("resume"),t.flowing=!t.readableListening,AZe(this,t)),t[Hv]=!1,this};function AZe(t,e){e.resumeScheduled||(e.resumeScheduled=!0,nl.nextTick(TZe,t,e))}function TZe(t,e){Cr("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),Cye(t),e.flowing&&!e.reading&&t.read(0)}xr.prototype.pause=function(){return Cr("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(Cr("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState[Hv]=!0,this};function Cye(t){let e=t._readableState;for(Cr("flow",e.flowing);e.flowing&&t.read()!==null;);}xr.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=>{R2(this,n)}),t.on("close",()=>{this.destroy()}),t.on("destroy",()=>{this.destroy()}),this._read=()=>{e&&t.resume&&(e=!1,t.resume())};let r=eZe(t);for(let n=1;n{i=s?Pye(i,s):null,r(),r=aK});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 tZe(n)}}}catch(s){throw i=Pye(i,s),i}finally{(i||e?.destroyOnReturn!==!1)&&(i===void 0||t._readableState.autoDestroy)?D2.destroyer(t,null):(t.off("readable",n),o())}}kye(xr.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}}});kye(lK.prototype,{pipesCount:{__proto__:null,get(){return this.pipes.length}},paused:{__proto__:null,get(){return this[Hv]!==!1},set(t){this[Hv]=!!t}}});xr._fromList=jye;function jye(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 dK(t){let e=t._readableState;Cr("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,nl.nextTick(IZe,e,t))}function IZe(t,e){if(Cr("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)nl.nextTick(kZe,e);else if(t.autoDestroy){let r=e._writableState;(!r||r.autoDestroy&&(r.finished||r.writable===!1))&&e.destroy()}}}function kZe(t){t.writable&&!t.writableEnded&&!t.destroyed&&t.end()}xr.from=function(t,e){return vZe(xr,t,e)};var uK;function Nye(){return uK===void 0&&(uK={}),uK}xr.fromWeb=function(t,e){return Nye().newStreamReadableFromReadableStream(t,e)};xr.toWeb=function(t,e){return Nye().newReadableStreamFromStreamReadable(t,e)};xr.wrap=function(t,e){var r,n;return new xr({objectMode:(r=(n=t.readableObjectMode)!==null&&n!==void 0?n:t.objectMode)!==null&&r!==void 0?r:!0,...e,destroy(i,o){D2.destroyer(t,i),o(i)}}).wrap(t)}});var vK=V((ikt,Yye)=>{f();var Vv=js(),{ArrayPrototypeSlice:Kye,Error:RZe,FunctionPrototypeSymbolHasInstance:Fye,ObjectDefineProperty:zye,ObjectDefineProperties:DZe,ObjectSetPrototypeOf:Wye,StringPrototypeToLowerCase:BZe,Symbol:MZe,SymbolHasInstance:OZe}=Zi();Yye.exports=ui;ui.WritableState=e3;var{EventEmitter:CZe}=Aa(),XS=dk().Stream,{Buffer:mk}=pn(),vk=Wv(),{addAbortSignal:$Ze}=ZS(),{getHighWaterMark:jZe,getDefaultHighWaterMark:NZe}=fk(),{ERR_INVALID_ARG_TYPE:UZe,ERR_METHOD_NOT_IMPLEMENTED:qZe,ERR_MULTIPLE_CALLBACK:Hye,ERR_STREAM_CANNOT_PIPE:LZe,ERR_STREAM_DESTROYED:QS,ERR_STREAM_ALREADY_FINISHED:KZe,ERR_STREAM_NULL_VALUES:FZe,ERR_STREAM_WRITE_AFTER_END:zZe,ERR_UNKNOWN_ENCODING:Vye}=Na().codes,{errorOrDestroy:B2}=vk;Wye(ui.prototype,XS.prototype);Wye(ui,XS);function pK(){}var M2=MZe("kOnFinished");function e3(t,e,r){typeof r!="boolean"&&(r=e instanceof If()),this.objectMode=!!(t&&t.objectMode),r&&(this.objectMode=this.objectMode||!!(t&&t.writableObjectMode)),this.highWaterMark=t?jZe(this,t,"writableHighWaterMark",r):NZe(!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=HZe.bind(void 0,e),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,gk(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[M2]=[]}function gk(t){t.buffered=[],t.bufferedIndex=0,t.allBuffers=!0,t.allNoop=!0}e3.prototype.getBuffer=function(){return Kye(this.buffered,this.bufferedIndex)};zye(e3.prototype,"bufferedRequestCount",{__proto__:null,get(){return this.buffered.length-this.bufferedIndex}});function ui(t){let e=this instanceof If();if(!e&&!Fye(ui,this))return new ui(t);this._writableState=new e3(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&&$Ze(t.signal,this)),XS.call(this,t),vk.construct(this,()=>{let r=this._writableState;r.writing||yK(this,r),gK(this,r)})}zye(ui,OZe,{__proto__:null,value:function(t){return Fye(this,t)?!0:this!==ui?!1:t&&t._writableState instanceof e3}});ui.prototype.pipe=function(){B2(this,new LZe)};function Gye(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"&&!mk.isEncoding(r))throw new Vye(r);typeof n!="function"&&(n=pK)}if(e===null)throw new FZe;if(!i.objectMode)if(typeof e=="string")i.decodeStrings!==!1&&(e=mk.from(e,r),r="buffer");else if(e instanceof mk)r="buffer";else if(XS._isUint8Array(e))e=XS._uint8ArrayToBuffer(e),r="buffer";else throw new UZe("chunk",["string","Buffer","Uint8Array"],e);let o;return i.ending?o=new zZe:i.destroyed&&(o=new QS("write")),o?(Vv.nextTick(n,o),B2(t,o,!0),o):(i.pendingcb++,WZe(t,i,e,r,n))}ui.prototype.write=function(t,e,r){return Gye(this,t,e,r)===!0};ui.prototype.cork=function(){this._writableState.corked++};ui.prototype.uncork=function(){let t=this._writableState;t.corked&&(t.corked--,t.writing||yK(this,t))};ui.prototype.setDefaultEncoding=function(e){if(typeof e=="string"&&(e=BZe(e)),!mk.isEncoding(e))throw new Vye(e);return this._writableState.defaultEncoding=e,this};function WZe(t,e,r,n,i){let o=e.objectMode?1:r.length;e.length+=o;let s=e.lengthr.bufferedIndex&&yK(t,r),n?r.afterWriteTickInfo!==null&&r.afterWriteTickInfo.cb===i?r.afterWriteTickInfo.count++:(r.afterWriteTickInfo={count:1,cb:i,stream:t,state:r},Vv.nextTick(VZe,r.afterWriteTickInfo)):Jye(t,r,1,i))}function VZe({stream:t,state:e,count:r,cb:n}){return e.afterWriteTickInfo=null,Jye(t,e,r,n)}function Jye(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&&mK(e),gK(t,e)}function mK(t){if(t.writing)return;for(let i=t.bufferedIndex;i1&&t._writev){e.pendingcb-=o-1;let a=e.allNoop?pK:u=>{for(let c=s;c256?(r.splice(0,s),e.bufferedIndex=0):e.bufferedIndex=s}e.bufferProcessing=!1}ui.prototype._write=function(t,e,r){if(this._writev)this._writev([{chunk:t,encoding:e}],r);else throw new qZe("_write()")};ui.prototype._writev=null;ui.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=Gye(this,t,e);o instanceof RZe&&(i=o)}return n.corked&&(n.corked=1,this.uncork()),i||(!n.errored&&!n.ending?(n.ending=!0,gK(this,n,!0),n.ended=!0):n.finished?i=new KZe("end"):n.destroyed&&(i=new QS("end"))),typeof r=="function"&&(i||n.finished?Vv.nextTick(r,i):n[M2].push(r)),this};function yk(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 GZe(t,e){let r=!1;function n(i){if(r){B2(t,i??Hye());return}if(r=!0,e.pendingcb--,i){let o=e[M2].splice(0);for(let s=0;s{yk(i)?hK(n,i):i.pendingcb--},t,e)):yk(e)&&(e.pendingcb++,hK(t,e))))}function hK(t,e){e.pendingcb--,e.finished=!0;let r=e[M2].splice(0);for(let n=0;n{f();var bK=js(),YZe=pn(),{isReadable:XZe,isWritable:QZe,isIterable:Xye,isNodeStream:eYe,isReadableNodeStream:Qye,isWritableNodeStream:e0e,isDuplexNodeStream:tYe}=Tf(),t0e=op(),{AbortError:a0e,codes:{ERR_INVALID_ARG_TYPE:rYe,ERR_INVALID_RETURN_VALUE:r0e}}=Na(),{destroyer:O2}=Wv(),nYe=If(),iYe=YS(),{createDeferredPromise:n0e}=Sf(),i0e=oK(),o0e=globalThis.Blob||YZe.Blob,oYe=typeof o0e<"u"?function(e){return e instanceof o0e}:function(e){return!1},sYe=globalThis.AbortController||Dh().AbortController,{FunctionPrototypeCall:s0e}=Zi(),Gv=class extends nYe{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)}};c0e.exports=function t(e,r){if(tYe(e))return e;if(Qye(e))return bk({readable:e});if(e0e(e))return bk({writable:e});if(eYe(e))return bk({writable:!1,readable:!1});if(typeof e=="function"){let{value:i,write:o,final:s,destroy:a}=aYe(e);if(Xye(i))return i0e(Gv,i,{objectMode:!0,write:o,final:s,destroy:a});let d=i?.then;if(typeof d=="function"){let u,c=s0e(d,i,l=>{if(l!=null)throw new r0e("nully","body",l)},l=>{O2(u,l)});return u=new Gv({objectMode:!0,readable:!1,write:o,final(l){s(async()=>{try{await c,bK.nextTick(l,null)}catch(p){bK.nextTick(l,p)}})},destroy:a})}throw new r0e("Iterable, AsyncIterable or AsyncFunction",r,i)}if(oYe(e))return t(e.arrayBuffer());if(Xye(e))return i0e(Gv,e,{objectMode:!0,writable:!1});if(typeof e?.writable=="object"||typeof e?.readable=="object"){let i=e!=null&&e.readable?Qye(e?.readable)?e?.readable:t(e.readable):void 0,o=e!=null&&e.writable?e0e(e?.writable)?e?.writable:t(e.writable):void 0;return bk({readable:i,writable:o})}let n=e?.then;if(typeof n=="function"){let i;return s0e(n,e,o=>{o!=null&&i.push(o),i.push(null)},o=>{O2(i,o)}),i=new Gv({objectMode:!0,writable:!1,read(){}})}throw new rYe(r,["Blob","ReadableStream","WritableStream","Stream","Iterable","AsyncIterable","Function","{ readable, writable } pair","Promise"],e)};function aYe(t){let{promise:e,resolve:r}=n0e(),n=new sYe,i=n.signal;return{value:t(async function*(){for(;;){let s=e;e=null;let{chunk:a,done:d,cb:u}=await s;if(bK.nextTick(u),d)return;if(i.aborted)throw new a0e(void 0,{cause:i.reason});({promise:e,resolve:r}=n0e()),yield a}}(),{signal:i}),write(s,a,d){let u=r;r=null,u({chunk:s,done:!1,cb:d})},final(s){let a=r;r=null,a({done:!0,cb:s})},destroy(s,a){n.abort(),a(s)}}}function bk(t){let e=t.readable&&typeof t.readable.read!="function"?iYe.wrap(t.readable):t.readable,r=t.writable,n=!!XZe(e),i=!!QZe(r),o,s,a,d,u;function c(l){let p=d;d=null,p?p(l):l&&u.destroy(l)}return u=new Gv({readableObjectMode:!!(e!=null&&e.readableObjectMode),writableObjectMode:!!(r!=null&&r.writableObjectMode),readable:n,writable:i}),i&&(t0e(r,l=>{i=!1,l&&O2(e,l),c(l)}),u._write=function(l,p,m){r.write(l,p)?m():o=m},u._final=function(l){r.end(),s=l},r.on("drain",function(){if(o){let l=o;o=null,l()}}),r.on("finish",function(){if(s){let l=s;s=null,l()}})),n&&(t0e(e,l=>{n=!1,l&&O2(e,l),c(l)}),e.on("readable",function(){if(a){let l=a;a=null,l()}}),e.on("end",function(){u.push(null)}),u._read=function(){for(;;){let l=e.read();if(l===null){a=u._read;return}if(!u.push(l))return}}),u._destroy=function(l,p){!l&&d!==null&&(l=new a0e),a=null,o=null,s=null,d===null?p(l):(d=p,O2(r,l),O2(e,l))},u}});var If=V((ckt,f0e)=>{"use strict";f();var{ObjectDefineProperties:cYe,ObjectGetOwnPropertyDescriptor:sp,ObjectKeys:dYe,ObjectSetPrototypeOf:u0e}=Zi();f0e.exports=il;var xK=YS(),Yd=vK();u0e(il.prototype,xK.prototype);u0e(il,xK);{let t=dYe(Yd.prototype);for(let e=0;e{"use strict";f();var{ObjectSetPrototypeOf:h0e,Symbol:uYe}=Zi();p0e.exports=ap;var{ERR_METHOD_NOT_IMPLEMENTED:lYe}=Na().codes,SK=If(),{getHighWaterMark:fYe}=fk();h0e(ap.prototype,SK.prototype);h0e(ap,SK);var t3=uYe("kCallback");function ap(t){if(!(this instanceof ap))return new ap(t);let e=t?fYe(this,t,"readableHighWaterMark",!0):null;e===0&&(t={...t,highWaterMark:null,readableHighWaterMark:e,writableHighWaterMark:t.writableHighWaterMark||0}),SK.call(this,t),this._readableState.sync=!1,this[t3]=null,t&&(typeof t.transform=="function"&&(this._transform=t.transform),typeof t.flush=="function"&&(this._flush=t.flush)),this.on("prefinish",hYe)}function EK(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 hYe(){this._final!==EK&&EK.call(this)}ap.prototype._final=EK;ap.prototype._transform=function(t,e,r){throw new lYe("_transform()")};ap.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{"use strict";f();var{ObjectSetPrototypeOf:m0e}=Zi();y0e.exports=C2;var TK=AK();m0e(C2.prototype,TK.prototype);m0e(C2,TK);function C2(t){if(!(this instanceof C2))return new C2(t);TK.call(this,t)}C2.prototype._transform=function(t,e,r){r(null,t)}});var Ek=V((pkt,_0e)=>{f();var r3=js(),{ArrayIsArray:pYe,Promise:mYe,SymbolAsyncIterator:yYe}=Zi(),xk=op(),{once:gYe}=Sf(),vYe=Wv(),g0e=If(),{aggregateTwoErrors:bYe,codes:{ERR_INVALID_ARG_TYPE:CK,ERR_INVALID_RETURN_VALUE:IK,ERR_MISSING_ARGS:wYe,ERR_STREAM_DESTROYED:_Ye,ERR_STREAM_PREMATURE_CLOSE:xYe},AbortError:EYe}=Na(),{validateFunction:SYe,validateAbortSignal:AYe}=JS(),{isIterable:Jv,isReadable:kK,isReadableNodeStream:_k,isNodeStream:v0e,isTransformStream:$2,isWebStream:TYe,isReadableStream:RK,isReadableEnded:PYe}=Tf(),IYe=globalThis.AbortController||Dh().AbortController,DK,BK;function b0e(t,e,r){let n=!1;t.on("close",()=>{n=!0});let i=xk(t,{readable:e,writable:r},o=>{n=!o});return{destroy:o=>{n||(n=!0,vYe.destroyer(t,o||new _Ye("pipe")))},cleanup:i}}function kYe(t){return SYe(t[t.length-1],"streams[stream.length - 1]"),t.pop()}function MK(t){if(Jv(t))return t;if(_k(t))return RYe(t);throw new CK("val",["Readable","Iterable","AsyncIterable"],t)}async function*RYe(t){BK||(BK=YS()),yield*BK.prototype[yYe].call(t)}async function wk(t,e,r,{end:n}){let i,o=null,s=u=>{if(u&&(i=u),o){let c=o;o=null,c()}},a=()=>new mYe((u,c)=>{i?c(i):o=()=>{i?c(i):u()}});e.on("drain",s);let d=xk(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?bYe(i,u):u)}finally{d(),e.off("drain",s)}}async function OK(t,e,r,{end:n}){$2(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 DYe(...t){return w0e(t,gYe(kYe(t)))}function w0e(t,e,r){if(t.length===1&&pYe(t[0])&&(t=t[0]),t.length<2)throw new wYe("streams");let n=new IYe,i=n.signal,o=r?.signal,s=[];AYe(o,"options.signal");function a(){m(new EYe)}o?.addEventListener("abort",a);let d,u,c=[],l=0;function p(P){m(P,--l===0)}function m(P,A){if(P&&(!d||d.code==="ERR_STREAM_PREMATURE_CLOSE")&&(d=P),!(!d&&!A)){for(;c.length;)c.shift()(d);o?.removeEventListener("abort",a),n.abort(),A&&(d||s.forEach($=>$()),r3.nextTick(e,d,u))}}let g;for(let P=0;P0,q=$||r?.end!==!1,F=P===t.length-1;if(v0e(A)){let K=function(W){W&&W.name!=="AbortError"&&W.code!=="ERR_STREAM_PREMATURE_CLOSE"&&p(W)};var S=K;if(q){let{destroy:W,cleanup:L}=b0e(A,$,j);c.push(W),kK(A)&&F&&s.push(L)}A.on("error",K),kK(A)&&F&&s.push(()=>{A.removeListener("error",K)})}if(P===0)if(typeof A=="function"){if(g=A({signal:i}),!Jv(g))throw new IK("Iterable, AsyncIterable or Stream","source",g)}else Jv(A)||_k(A)||$2(A)?g=A:g=g0e.from(A);else if(typeof A=="function"){if($2(g)){var v;g=MK((v=g)===null||v===void 0?void 0:v.readable)}else g=MK(g);if(g=A(g,{signal:i}),$){if(!Jv(g,!0))throw new IK("AsyncIterable",`transform[${P-1}]`,g)}else{var x;DK||(DK=PK());let K=new DK({objectMode:!0}),W=(x=g)===null||x===void 0?void 0:x.then;if(typeof W=="function")l++,W.call(g,T=>{u=T,T!=null&&K.write(T),q&&K.end(),r3.nextTick(p)},T=>{K.destroy(T),r3.nextTick(p,T)});else if(Jv(g,!0))l++,wk(g,K,p,{end:q});else if(RK(g)||$2(g)){let T=g.readable||g;l++,wk(T,K,p,{end:q})}else throw new IK("AsyncIterable or Promise","destination",g);g=K;let{destroy:L,cleanup:I}=b0e(g,!1,!0);c.push(L),F&&s.push(I)}}else if(v0e(A)){if(_k(g)){l+=2;let K=BYe(g,A,p,{end:q});kK(A)&&F&&s.push(K)}else if($2(g)||RK(g)){let K=g.readable||g;l++,wk(K,A,p,{end:q})}else if(Jv(g))l++,wk(g,A,p,{end:q});else throw new CK("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],g);g=A}else if(TYe(A)){if(_k(g))l++,OK(MK(g),A,p,{end:q});else if(RK(g)||Jv(g))l++,OK(g,A,p,{end:q});else if($2(g))l++,OK(g.readable,A,p,{end:q});else throw new CK("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],g);g=A}else g=g0e.from(A)}return(i!=null&&i.aborted||o!=null&&o.aborted)&&r3.nextTick(a),g}function BYe(t,e,r,{end:n}){let i=!1;if(e.on("close",()=>{i||r(new xYe)}),t.pipe(e,{end:!1}),n){let s=function(){i=!0,e.end()};var o=s;PYe(t)?r3.nextTick(s):t.once("end",s)}else r();return xk(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)}),xk(e,{readable:!1,writable:!0},r)}_0e.exports={pipelineImpl:w0e,pipeline:DYe}});var jK=V((ykt,P0e)=>{"use strict";f();var{pipeline:MYe}=Ek(),Sk=If(),{destroyer:OYe}=Wv(),{isNodeStream:Ak,isReadable:x0e,isWritable:E0e,isWebStream:$K,isTransformStream:Zv,isWritableStream:S0e,isReadableStream:A0e}=Tf(),{AbortError:CYe,codes:{ERR_INVALID_ARG_VALUE:T0e,ERR_MISSING_ARGS:$Ye}}=Na(),jYe=op();P0e.exports=function(...e){if(e.length===0)throw new $Ye("streams");if(e.length===1)return Sk.from(e[0]);let r=[...e];if(typeof e[0]=="function"&&(e[0]=Sk.from(e[0])),typeof e[e.length-1]=="function"){let m=e.length-1;e[m]=Sk.from(e[m])}for(let m=0;m0&&!(E0e(e[m])||S0e(e[m])||Zv(e[m])))throw new T0e(`streams[${m}]`,r[m],"must be writable")}let n,i,o,s,a;function d(m){let g=s;s=null,g?g(m):m?a.destroy(m):!p&&!l&&a.destroy()}let u=e[0],c=MYe(e,d),l=!!(E0e(u)||S0e(u)||Zv(u)),p=!!(x0e(c)||A0e(c)||Zv(c));if(a=new Sk({writableObjectMode:!!(u!=null&&u.writableObjectMode),readableObjectMode:!!(c!=null&&c.writableObjectMode),writable:l,readable:p}),l){if(Ak(u))a._write=function(g,v,x){u.write(g,v)?x():n=x},a._final=function(g){u.end(),i=g},u.on("drain",function(){if(n){let g=n;n=null,g()}});else if($K(u)){let v=(Zv(u)?u.writable:u).getWriter();a._write=async function(x,S,P){try{await v.ready,v.write(x).catch(()=>{}),P()}catch(A){P(A)}},a._final=async function(x){try{await v.ready,v.close().catch(()=>{}),i=x}catch(S){x(S)}}}let m=Zv(c)?c.readable:c;jYe(m,()=>{if(i){let g=i;i=null,g()}})}if(p){if(Ak(c))c.on("readable",function(){if(o){let m=o;o=null,m()}}),c.on("end",function(){a.push(null)}),a._read=function(){for(;;){let m=c.read();if(m===null){o=a._read;return}if(!a.push(m))return}};else if($K(c)){let g=(Zv(c)?c.readable:c).getReader();a._read=async function(){for(;;)try{let{value:v,done:x}=await g.read();if(!a.push(v))return;if(x){a.push(null);return}}catch{return}}}}return a._destroy=function(m,g){!m&&s!==null&&(m=new CYe),o=null,n=null,i=null,s===null?g(m):(s=g,Ak(c)&&OYe(c,m))},a}});var C0e=V((vkt,qK)=>{"use strict";f();var D0e=globalThis.AbortController||Dh().AbortController,{codes:{ERR_INVALID_ARG_VALUE:NYe,ERR_INVALID_ARG_TYPE:n3,ERR_MISSING_ARGS:UYe,ERR_OUT_OF_RANGE:qYe},AbortError:kf}=Na(),{validateAbortSignal:Yv,validateInteger:LYe,validateObject:Xv}=JS(),KYe=Zi().Symbol("kWeak"),{finished:FYe}=op(),zYe=jK(),{addAbortSignalNoValidate:WYe}=ZS(),{isWritable:HYe,isNodeStream:VYe}=Tf(),{ArrayPrototypePush:GYe,MathFloor:JYe,Number:ZYe,NumberIsNaN:YYe,Promise:I0e,PromiseReject:k0e,PromisePrototypeThen:XYe,Symbol:B0e}=Zi(),Tk=B0e("kEmpty"),R0e=B0e("kEof");function QYe(t,e){if(e!=null&&Xv(e,"options"),e?.signal!=null&&Yv(e.signal,"options.signal"),VYe(t)&&!HYe(t))throw new NYe("stream",t,"must be writable");let r=zYe(this,t);return e!=null&&e.signal&&WYe(e.signal,r),r}function Pk(t,e){if(typeof t!="function")throw new n3("fn",["Function","AsyncFunction"],t);e!=null&&Xv(e,"options"),e?.signal!=null&&Yv(e.signal,"options.signal");let r=1;return e?.concurrency!=null&&(r=JYe(e.concurrency)),LYe(r,"concurrency",1),(async function*(){var i,o;let s=new D0e,a=this,d=[],u=s.signal,c={signal:u},l=()=>s.abort();e!=null&&(i=e.signal)!==null&&i!==void 0&&i.aborted&&l(),e==null||(o=e.signal)===null||o===void 0||o.addEventListener("abort",l);let p,m,g=!1;function v(){g=!0}async function x(){try{for await(let A of a){var S;if(g)return;if(u.aborted)throw new kf;try{A=t(A,c)}catch($){A=k0e($)}A!==Tk&&(typeof((S=A)===null||S===void 0?void 0:S.catch)=="function"&&A.catch(v),d.push(A),p&&(p(),p=null),!g&&d.length&&d.length>=r&&await new I0e($=>{m=$}))}d.push(R0e)}catch(A){let $=k0e(A);XYe($,void 0,v),d.push($)}finally{var P;g=!0,p&&(p(),p=null),e==null||(P=e.signal)===null||P===void 0||P.removeEventListener("abort",l)}}x();try{for(;;){for(;d.length>0;){let S=await d[0];if(S===R0e)return;if(u.aborted)throw new kf;S!==Tk&&(yield S),d.shift(),m&&(m(),m=null)}await new I0e(S=>{p=S})}}finally{s.abort(),g=!0,m&&(m(),m=null)}}).call(this)}function eXe(t=void 0){return t!=null&&Xv(t,"options"),t?.signal!=null&&Yv(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 kf({cause:t.signal.reason});yield[r++,i]}}).call(this)}async function M0e(t,e=void 0){for await(let r of UK.call(this,t,e))return!0;return!1}async function tXe(t,e=void 0){if(typeof t!="function")throw new n3("fn",["Function","AsyncFunction"],t);return!await M0e.call(this,async(...r)=>!await t(...r),e)}async function rXe(t,e){for await(let r of UK.call(this,t,e))return r}async function nXe(t,e){if(typeof t!="function")throw new n3("fn",["Function","AsyncFunction"],t);async function r(n,i){return await t(n,i),Tk}for await(let n of Pk.call(this,r,e));}function UK(t,e){if(typeof t!="function")throw new n3("fn",["Function","AsyncFunction"],t);async function r(n,i){return await t(n,i)?n:Tk}return Pk.call(this,r,e)}var NK=class extends UYe{constructor(){super("reduce"),this.message="Reduce of an empty stream requires an initial value"}};async function iXe(t,e,r){var n;if(typeof t!="function")throw new n3("reducer",["Function","AsyncFunction"],t);r!=null&&Xv(r,"options"),r?.signal!=null&&Yv(r.signal,"options.signal");let i=arguments.length>1;if(r!=null&&(n=r.signal)!==null&&n!==void 0&&n.aborted){let u=new kf(void 0,{cause:r.signal.reason});throw this.once("error",()=>{}),await FYe(this.destroy(u)),u}let o=new D0e,s=o.signal;if(r!=null&&r.signal){let u={once:!0,[KYe]:this};r.signal.addEventListener("abort",()=>o.abort(),u)}let a=!1;try{for await(let u of this){var d;if(a=!0,r!=null&&(d=r.signal)!==null&&d!==void 0&&d.aborted)throw new kf;i?e=await t(e,u,{signal:s}):(e=u,i=!0)}if(!a&&!i)throw new NK}finally{o.abort()}return e}async function oXe(t){t!=null&&Xv(t,"options"),t?.signal!=null&&Yv(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 kf(void 0,{cause:t.signal.reason});GYe(e,n)}return e}function sXe(t,e){let r=Pk.call(this,t,e);return(async function*(){for await(let i of r)yield*i}).call(this)}function O0e(t){if(t=ZYe(t),YYe(t))return 0;if(t<0)throw new qYe("number",">= 0",t);return t}function aXe(t,e=void 0){return e!=null&&Xv(e,"options"),e?.signal!=null&&Yv(e.signal,"options.signal"),t=O0e(t),(async function*(){var n;if(e!=null&&(n=e.signal)!==null&&n!==void 0&&n.aborted)throw new kf;for await(let o of this){var i;if(e!=null&&(i=e.signal)!==null&&i!==void 0&&i.aborted)throw new kf;t--<=0&&(yield o)}}).call(this)}function cXe(t,e=void 0){return e!=null&&Xv(e,"options"),e?.signal!=null&&Yv(e.signal,"options.signal"),t=O0e(t),(async function*(){var n;if(e!=null&&(n=e.signal)!==null&&n!==void 0&&n.aborted)throw new kf;for await(let o of this){var i;if(e!=null&&(i=e.signal)!==null&&i!==void 0&&i.aborted)throw new kf;if(t-- >0)yield o;else return}}).call(this)}qK.exports.streamReturningOperators={asIndexedPairs:eXe,drop:aXe,filter:UK,flatMap:sXe,map:Pk,take:cXe,compose:QYe};qK.exports.promiseReturningOperators={every:tXe,forEach:nXe,reduce:iXe,toArray:oXe,some:M0e,find:rXe}});var LK=V((wkt,$0e)=>{"use strict";f();var{ArrayPrototypePop:dXe,Promise:uXe}=Zi(),{isIterable:lXe,isNodeStream:fXe,isWebStream:hXe}=Tf(),{pipelineImpl:pXe}=Ek(),{finished:mXe}=op();KK();function yXe(...t){return new uXe((e,r)=>{let n,i,o=t[t.length-1];if(o&&typeof o=="object"&&!fXe(o)&&!lXe(o)&&!hXe(o)){let s=dXe(t);n=s.signal,i=s.end}pXe(t,(s,a)=>{s?r(s):e(a)},{signal:n,end:i})})}$0e.exports={finished:mXe,pipeline:yXe}});var KK=V((xkt,W0e)=>{f();var{Buffer:gXe}=pn(),{ObjectDefineProperty:cp,ObjectKeys:U0e,ReflectApply:q0e}=Zi(),{promisify:{custom:L0e}}=Sf(),{streamReturningOperators:j0e,promiseReturningOperators:N0e}=C0e(),{codes:{ERR_ILLEGAL_CONSTRUCTOR:K0e}}=Na(),vXe=jK(),{pipeline:F0e}=Ek(),{destroyer:bXe}=Wv(),z0e=op(),FK=LK(),zK=Tf(),Ci=W0e.exports=dk().Stream;Ci.isDisturbed=zK.isDisturbed;Ci.isErrored=zK.isErrored;Ci.isReadable=zK.isReadable;Ci.Readable=YS();for(let t of U0e(j0e)){let r=function(...n){if(new.target)throw K0e();return Ci.Readable.from(q0e(e,this,n))};WK=r;let e=j0e[t];cp(r,"name",{__proto__:null,value:e.name}),cp(r,"length",{__proto__:null,value:e.length}),cp(Ci.Readable.prototype,t,{__proto__:null,value:r,enumerable:!1,configurable:!0,writable:!0})}var WK;for(let t of U0e(N0e)){let r=function(...i){if(new.target)throw K0e();return q0e(e,this,i)};WK=r;let e=N0e[t];cp(r,"name",{__proto__:null,value:e.name}),cp(r,"length",{__proto__:null,value:e.length}),cp(Ci.Readable.prototype,t,{__proto__:null,value:r,enumerable:!1,configurable:!0,writable:!0})}var WK;Ci.Writable=vK();Ci.Duplex=If();Ci.Transform=AK();Ci.PassThrough=PK();Ci.pipeline=F0e;var{addAbortSignal:wXe}=ZS();Ci.addAbortSignal=wXe;Ci.finished=z0e;Ci.destroy=bXe;Ci.compose=vXe;cp(Ci,"promises",{__proto__:null,configurable:!0,enumerable:!0,get(){return FK}});cp(F0e,L0e,{__proto__:null,enumerable:!0,get(){return FK.pipeline}});cp(z0e,L0e,{__proto__:null,enumerable:!0,get(){return FK.finished}});Ci.Stream=Ci;Ci._isUint8Array=function(e){return e instanceof Uint8Array};Ci._uint8ArrayToBuffer=function(e){return gXe.from(e.buffer,e.byteOffset,e.byteLength)}});var i3=V((Skt,$i)=>{"use strict";f();var mo=KK(),_Xe=LK(),xXe=mo.Readable.destroy;$i.exports=mo.Readable;$i.exports._uint8ArrayToBuffer=mo._uint8ArrayToBuffer;$i.exports._isUint8Array=mo._isUint8Array;$i.exports.isDisturbed=mo.isDisturbed;$i.exports.isErrored=mo.isErrored;$i.exports.isReadable=mo.isReadable;$i.exports.Readable=mo.Readable;$i.exports.Writable=mo.Writable;$i.exports.Duplex=mo.Duplex;$i.exports.Transform=mo.Transform;$i.exports.PassThrough=mo.PassThrough;$i.exports.addAbortSignal=mo.addAbortSignal;$i.exports.finished=mo.finished;$i.exports.destroy=mo.destroy;$i.exports.destroy=xXe;$i.exports.pipeline=mo.pipeline;$i.exports.compose=mo.compose;Object.defineProperty(mo,"promises",{configurable:!0,enumerable:!0,get(){return _Xe}});$i.exports.Stream=mo.Stream;$i.exports.default=$i.exports});var g3=V(Lge=>{f();Lge.Level=UL().BrowserLevel});var Eve=V((dOt,xve)=>{"use strict";f();xve.exports=function t(e){if(typeof e=="number"&&isNaN(e))throw new Error("NaN is not allowed");if(typeof e=="number"&&!isFinite(e))throw new Error("Infinity is not allowed");return e===null||typeof e!="object"?JSON.stringify(e):e.toJSON instanceof Function?t(e.toJSON()):Array.isArray(e)?`[${e.reduce((i,o,s)=>`${i}${s===0?"":","}${t(o===void 0||typeof o=="symbol"?null:o)}`,"")}]`:`{${Object.keys(e).sort().reduce((n,i)=>{if(e[i]===void 0||typeof e[i]=="symbol")return n;let o=n.length===0?"":",";return`${n}${o}${t(i)}:${t(e[i])}`},"")}}`}});var ub=V((QCt,Rve)=>{f();var n_=1e3,i_=n_*60,o_=i_*60,db=o_*24,Yet=db*7,Xet=db*365.25;Rve.exports=function(t,e){e=e||{};var r=typeof t;if(r==="string"&&t.length>0)return Qet(t);if(r==="number"&&isFinite(t))return e.long?ttt(t):ett(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))};function Qet(t){if(t=String(t),!(t.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(e){var r=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*Xet;case"weeks":case"week":case"w":return r*Yet;case"days":case"day":case"d":return r*db;case"hours":case"hour":case"hrs":case"hr":case"h":return r*o_;case"minutes":case"minute":case"mins":case"min":case"m":return r*i_;case"seconds":case"second":case"secs":case"sec":case"s":return r*n_;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function ett(t){var e=Math.abs(t);return e>=db?Math.round(t/db)+"d":e>=o_?Math.round(t/o_)+"h":e>=i_?Math.round(t/i_)+"m":e>=n_?Math.round(t/n_)+"s":t+"ms"}function ttt(t){var e=Math.abs(t);return e>=db?yR(t,e,db,"day"):e>=o_?yR(t,e,o_,"hour"):e>=i_?yR(t,e,i_,"minute"):e>=n_?yR(t,e,n_,"second"):t+" ms"}function yR(t,e,r,n){var i=e>=r*1.5;return Math.round(t/r)+" "+n+(i?"s":"")}});var dwe=V((DUt,YF)=>{"use strict";f();var srt=Object.prototype.hasOwnProperty,Fa="~";function N3(){}Object.create&&(N3.prototype=Object.create(null),new N3().__proto__||(Fa=!1));function art(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function cwe(t,e,r,n,i){if(typeof r!="function")throw new TypeError("The listener must be a function");var o=new art(r,n||t,i),s=Fa?Fa+e:e;return t._events[s]?t._events[s].fn?t._events[s]=[t._events[s],o]:t._events[s].push(o):(t._events[s]=o,t._eventsCount++),t}function $R(t,e){--t._eventsCount===0?t._events=new N3:delete t._events[e]}function la(){this._events=new N3,this._eventsCount=0}la.prototype.eventNames=function(){var e=[],r,n;if(this._eventsCount===0)return e;for(n in r=this._events)srt.call(r,n)&&e.push(Fa?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(r)):e};la.prototype.listeners=function(e){var r=Fa?Fa+e:e,n=this._events[r];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,o=n.length,s=new Array(o);i{"use strict";f();Object.defineProperty(gD,"__esModule",{value:!0});gD.ReadableWebToNodeStream=void 0;var ant=Q7(),Ez=class extends ant.Readable{constructor(e){super(),this.bytesRead=0,this.released=!1,this.reader=e.getReader()}async _read(){if(this.released){this.push(null);return}this.pendingRead=this.reader.read();let e=await this.pendingRead;delete this.pendingRead,e.done||this.released?this.push(null):(this.bytesRead+=e.value.length,this.push(e.value))}async waitForReadToComplete(){this.pendingRead&&await this.pendingRead}async close(){await this.syncAndRelease()}async syncAndRelease(){this.released=!0,await this.waitForReadToComplete(),await this.reader.releaseLock()}};gD.ReadableWebToNodeStream=Ez});var oit={};Pr(oit,{DidApi:()=>O5,DwnApi:()=>N5,PermissionGrant:()=>Ff,PermissionGrantRevocation:()=>j5,PermissionRequest:()=>U_,Protocol:()=>N_,Record:()=>Lp,VcApi:()=>U5,Web5:()=>Kz,utils:()=>Lz});f();f();f();f();f();f();f();f();var fV=gt($W(),1);f();f();f();f();function l_e(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n>>0,$=new Uint8Array(A);S!==P;){for(var j=g[S],q=0,F=A-1;(j!==0||q>>0,$[F]=j%a>>>0,j=j/a>>>0;if(j!==0)throw new Error("Non-zero carry");x=q,S++}for(var K=A-x;K!==A&&$[K]===0;)K++;for(var W=d.repeat(v);K>>0,A=new Uint8Array(P);g[v];){var $=r[g.charCodeAt(v)];if($===255)return;for(var j=0,q=P-1;($!==0||j>>0,A[q]=$%256>>>0,$=$/256>>>0;if($!==0)throw new Error("Non-zero carry");S=j,v++}if(g[v]!==" "){for(var F=P-S;F!==P&&A[F]===0;)F++;for(var K=new Uint8Array(x+(P-F)),W=x;F!==P;)K[W++]=A[F++];return K}}}function m(g){var v=p(g);if(v)return v;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:p,decode:m}}var f_e=l_e,h_e=f_e,jW=h_e;f();var Vit=new Uint8Array(0);var NW=(t,e)=>{if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r{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")};f();var ZD=class{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")}},YD=class{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 qW(this,e)}},XD=class{constructor(e){this.decoders=e}or(e){return qW(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},qW=(t,e)=>new XD({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),QD=class{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new ZD(e,r,n),this.decoder=new YD(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},LW=({name:t,prefix:e,encode:r,decode:n})=>new QD(t,e,r,n),e9=({prefix:t,name:e,alphabet:r})=>{let{encode:n,decode:i}=jW(r,e);return LW({prefix:t,name:e,encode:n,decode:o=>pu(i(o))})},p_e=(t,e,r,n)=>{let i={};for(let c=0;c=8&&(a-=8,s[u++]=255&d>>a)}if(a>=r||255&d<<8-a)throw new SyntaxError("Unexpected end of data");return s},m_e=(t,e,r)=>{let n=e[e.length-1]==="=",i=(1<r;)s-=r,o+=e[i&a>>s];if(s&&(o+=e[i&a<LW({prefix:e,name:t,encode(i){return m_e(i,n,r)},decode(i){return p_e(i,n,r,t)}});var rot=ya({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),not=ya({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ga=ya({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),iot=ya({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var t9=new TextEncoder,y_e=new TextDecoder,qe=class t{static base64UrlToBytes(e){return ga.baseDecode(e)}static base64UrlToObject(e){let r=ga.baseDecode(e);return t.bytesToObject(r)}static bytesToBase64Url(e){return ga.baseEncode(e)}static bytesToString(e){return y_e.decode(e)}static bytesToObject(e){let r=t.bytesToString(e);return JSON.parse(r)}static objectToBytes(e){let r=JSON.stringify(e);return t9.encode(r)}static stringToBase64Url(e){let r=t9.encode(e);return ga.baseEncode(r)}static stringToBytes(e){return t9.encode(e)}};f();f();f();f();var es=2n**255n-19n,qb=2n**252n+27742317777372353535851937790883648493n,r9=0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,n9=0x6666666666666666666666666666666666666666666666666666666666666658n,H5={a:-1n,d:37095705934669439343138083508754565189542113879843219016388785533085940283555n,p:es,n:qb,h:8,Gx:r9,Gy:n9},va=(t="")=>{throw new Error(t)},HW=t=>typeof t=="string",J5=(t,e)=>!(t instanceof Uint8Array)||typeof e=="number"&&e>0&&t.length!==e?va("Uint8Array expected"):t,Lb=t=>new Uint8Array(t),Kb=(t,e)=>J5(HW(t)?o9(t):Lb(t),e),vt=(t,e=es)=>{let r=t%e;return r>=0n?r:e+r},KW=t=>t instanceof Sl?t:va("Point expected"),FW,Sl=class t{constructor(e,r,n,i){this.ex=e,this.ey=r,this.ez=n,this.et=i}static fromAffine(e){return new t(e.x,e.y,1n,vt(e.x*e.y))}static fromHex(e,r=!0){let{d:n}=H5;e=Kb(e,32);let i=e.slice();i[31]=e[31]&-129;let o=s9(i);o===0n||(r&&!(0n0n;o=o.double(),e>>=1n)e&1n?n=n.add(o):r&&(i=i.add(o));return n}multiply(e){return this.mul(e)}clearCofactor(){return this.mul(BigInt(H5.h),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let e=this.mul(qb/2n,!1).double();return qb%2n&&(e=e.add(this)),e.is0()}toAffine(){let{ex:e,ey:r,ez:n}=this;if(this.is0())return{x:0n,y:0n};let i=JW(n);return vt(n*i)!==1n&&va("invalid inverse"),{x:vt(e*i),y:vt(r*i)}}toRawBytes(){let{x:e,y:r}=this.toAffine(),n=GW(r);return n[31]|=e&1n?128:0,n}toHex(){return i9(this.toRawBytes())}};Sl.BASE=new Sl(r9,n9,1n,vt(r9*n9));Sl.ZERO=new Sl(0n,1n,1n,0n);var{BASE:Wp,ZERO:V5}=Sl,VW=(t,e)=>t.toString(16).padStart(e,"0"),i9=t=>Array.from(t).map(e=>VW(e,2)).join(""),o9=t=>{let e=t.length;(!HW(t)||e%2)&&va("hex invalid 1");let r=Lb(e/2);for(let n=0;no9(VW(t,32*2)).reverse(),s9=t=>BigInt("0x"+i9(Lb(J5(t)).reverse())),H_=(...t)=>{let e=Lb(t.reduce((n,i)=>n+J5(i).length,0)),r=0;return t.forEach(n=>{e.set(n,r),r+=n.length}),e},JW=(t,e=es)=>{(t===0n||e<=0n)&&va("no inverse n="+t+" mod="+e);let r=vt(t,e),n=e,i=0n,o=1n,s=1n,a=0n;for(;r!==0n;){let d=n/r,u=n%r,c=i-s*d,l=o-a*d;n=r,r=u,i=s,o=a,s=c,a=l}return n===1n?vt(i,e):va("no inverse")},El=(t,e)=>{let r=t;for(;e-- >0n;)r*=r,r%=es;return r},g_e=t=>{let r=t*t%es*t%es,n=El(r,2n)*r%es,i=El(n,1n)*t%es,o=El(i,5n)*i%es,s=El(o,10n)*o%es,a=El(s,20n)*s%es,d=El(a,40n)*a%es,u=El(d,80n)*d%es,c=El(u,80n)*d%es,l=El(c,10n)*o%es;return{pow_p_5_8:El(l,2n)*t%es,b2:r}},zW=19681161376707505956807079304988542015446066515923890162744021073123829784752n,v_e=(t,e)=>{let r=vt(e*e*e),n=vt(r*r*e),i=g_e(t*n).pow_p_5_8,o=vt(t*r*i),s=vt(e*o*o),a=o,d=vt(o*zW),u=s===t,c=s===vt(-t),l=s===vt(-t*zW);return u&&(o=a),(c||l)&&(o=d),(vt(o)&1n)===1n&&(o=vt(-o)),{isValid:u||c,value:o}},G5=t=>vt(s9(t),qb),W_,a9=(...t)=>d9.sha512Async(...t),ZW=(...t)=>typeof W_=="function"?W_(...t):va("etc.sha512Sync not set"),YW=t=>{let e=t.slice(0,32);e[0]&=248,e[31]&=127,e[31]|=64;let r=t.slice(32,64),n=G5(e),i=Wp.mul(n),o=i.toRawBytes();return{head:e,prefix:r,scalar:n,point:i,pointBytes:o}},c9=t=>a9(Kb(t,32)).then(YW),b_e=t=>YW(ZW(Kb(t,32))),XW=t=>c9(t).then(e=>e.pointBytes);function QW(t,e){return t?a9(e.hashable).then(e.finish):e.finish(ZW(e.hashable))}var w_e=(t,e,r)=>{let{pointBytes:n,scalar:i}=t,o=G5(e),s=Wp.mul(o).toRawBytes();return{hashable:H_(s,n,r),finish:u=>{let c=vt(o+G5(u)*i,qb);return J5(H_(s,GW(c)),64)}}},eH=async(t,e)=>{let r=Kb(t),n=await c9(e),i=await a9(n.prefix,r);return QW(!0,w_e(n,i,r))};var __e=(t,e,r)=>{e=Kb(e),t=Kb(t,64);let n=Sl.fromHex(r,!1),i=Sl.fromHex(t.slice(0,32),!1),o=s9(t.slice(32,64)),s=Wp.mul(o,!1);return{hashable:H_(i.toRawBytes(),n.toRawBytes(),e),finish:u=>{let c=G5(u);return i.add(n.mul(c,!1)).add(s.negate()).clearCofactor().is0()}}},tH=async(t,e,r)=>QW(!0,__e(t,e,r));var WW=()=>typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0,d9={bytesToHex:i9,hexToBytes:o9,concatBytes:H_,mod:vt,invert:JW,randomBytes:t=>{let e=WW();return e||va("crypto.getRandomValues must be defined"),e.getRandomValues(Lb(t))},sha512Async:async(...t)=>{let e=WW();e||va("crypto.subtle or etc.sha512Async must be defined");let r=H_(...t);return Lb(await e.subtle.digest("SHA-512",r.buffer))},sha512Sync:void 0};Object.defineProperties(d9,{sha512Sync:{configurable:!1,get(){return W_},set(t){W_||(W_=t)}}});var rH={getExtendedPublicKeyAsync:c9,getExtendedPublicKey:b_e,randomPrivateKey:()=>d9.randomBytes(32),precompute(t=8,e=Wp){return e.multiply(3n),e}},S0=8,x_e=()=>{let t=[],e=256/S0+1,r=Wp,n=r;for(let i=0;i{let e=FW||(FW=x_e()),r=(c,l)=>{let p=l.negate();return c?p:l},n=V5,i=Wp,o=1+256/S0,s=2**(S0-1),a=BigInt(2**S0-1),d=2**S0,u=BigInt(S0);for(let c=0;c>=u,p>s&&(p-=d,t+=1n);let m=l,g=l+Math.abs(p)-1,v=c%2!==0,x=p<0;p===0?i=i.add(r(v,e[m])):n=n.add(r(x,e[g]))}return{p:n,f:i}};f();var de=class extends Error{constructor(e,r){super(`${e}: ${r}`),this.code=e,this.name="DwnError"}},oe;(function(t){t.AuthenticateJwsMissing="AuthenticateJwsMissing",t.AuthenticateDescriptorCidMismatch="AuthenticateDescriptorCidMismatch",t.AuthenticationMoreThanOneSignatureNotSupported="AuthenticationMoreThanOneSignatureNotSupported",t.AuthorizationNotGrantedToAuthor="AuthorizationNotGrantedToAuthor",t.ComputeCidCodecNotSupported="ComputeCidCodecNotSupported",t.ComputeCidMultihashNotSupported="ComputeCidMultihashNotSupported",t.Ed25519InvalidJwk="Ed25519InvalidJwk",t.EventEmitterStreamNotOpenError="EventEmitterStreamNotOpenError",t.MessagesGrantAuthorizationMismatchedProtocol="EventsGrantAuthorizationMismatchedProtocol",t.MessagesSubscribeAuthorizationFailed="MessagesSubscribeAuthorizationFailed",t.MessagesSubscribeEventStreamUnimplemented="MessagesSubscribeEventStreamUnimplemented",t.GeneralJwsVerifierGetPublicKeyNotFound="GeneralJwsVerifierGetPublicKeyNotFound",t.GeneralJwsVerifierInvalidSignature="GeneralJwsVerifierInvalidSignature",t.GrantAuthorizationGrantExpired="GrantAuthorizationGrantExpired",t.GrantAuthorizationGrantMissing="GrantAuthorizationGrantMissing",t.GrantAuthorizationGrantRevoked="GrantAuthorizationGrantRevoked",t.GrantAuthorizationInterfaceMismatch="GrantAuthorizationInterfaceMismatch",t.GrantAuthorizationMethodMismatch="GrantAuthorizationMethodMismatch",t.GrantAuthorizationNotGrantedForTenant="GrantAuthorizationNotGrantedForTenant",t.GrantAuthorizationNotGrantedToAuthor="GrantAuthorizationNotGrantedToAuthor",t.GrantAuthorizationGrantNotYetActive="GrantAuthorizationGrantNotYetActive",t.HdKeyDerivationPathInvalid="HdKeyDerivationPathInvalid",t.JwsVerifySignatureUnsupportedCrv="JwsVerifySignatureUnsupportedCrv",t.IndexInvalidCursorValueType="IndexInvalidCursorValueType",t.IndexInvalidCursorSortProperty="IndexInvalidCursorSortProperty",t.IndexInvalidSortPropertyInMemory="IndexInvalidSortPropertyInMemory",t.IndexMissingIndexableProperty="IndexMissingIndexableProperty",t.JwsDecodePlainObjectPayloadInvalid="JwsDecodePlainObjectPayloadInvalid",t.MessagesReadInvalidCid="MessagesReadInvalidCid",t.MessagesReadAuthorizationFailed="MessagesReadAuthorizationFailed",t.MessageGetInvalidCid="MessageGetInvalidCid",t.MessagesQueryAuthorizationFailed="MessagesQueryAuthorizationFailed",t.MessagesReadVerifyScopeFailed="MessagesReadVerifyScopeFailed",t.ParseCidCodecNotSupported="ParseCidCodecNotSupported",t.ParseCidMultihashNotSupported="ParseCidMultihashNotSupported",t.PermissionsProtocolCreateGrantRecordsScopeMissingProtocol="PermissionsProtocolCreateGrantRecordsScopeMissingProtocol",t.PermissionsProtocolCreateRequestRecordsScopeMissingProtocol="PermissionsProtocolCreateRequestRecordsScopeMissingProtocol",t.PermissionsProtocolGetScopeInvalidProtocol="PermissionsProtocolGetScopeInvalidProtocol",t.PermissionsProtocolValidateSchemaUnexpectedRecord="PermissionsProtocolValidateSchemaUnexpectedRecord",t.PermissionsProtocolValidateScopeContextIdProhibitedProperties="PermissionsProtocolValidateScopeContextIdProhibitedProperties",t.PermissionsProtocolValidateScopeProtocolMismatch="PermissionsProtocolValidateScopeProtocolMismatch",t.PermissionsProtocolValidateScopeMissingProtocolTag="PermissionsProtocolValidateScopeMissingProtocolTag",t.PermissionsProtocolValidateRevocationProtocolTagMismatch="PermissionsProtocolValidateRevocationProtocolTagMismatch",t.PrivateKeySignerUnableToDeduceAlgorithm="PrivateKeySignerUnableToDeduceAlgorithm",t.PrivateKeySignerUnableToDeduceKeyId="PrivateKeySignerUnableToDeduceKeyId",t.PrivateKeySignerUnsupportedCurve="PrivateKeySignerUnsupportedCurve",t.ProtocolAuthorizationActionNotAllowed="ProtocolAuthorizationActionNotAllowed",t.ProtocolAuthorizationActionRulesNotFound="ProtocolAuthorizationActionRulesNotFound",t.ProtocolAuthorizationIncorrectDataFormat="ProtocolAuthorizationIncorrectDataFormat",t.ProtocolAuthorizationIncorrectContextId="ProtocolAuthorizationIncorrectContextId",t.ProtocolAuthorizationIncorrectProtocolPath="ProtocolAuthorizationIncorrectProtocolPath",t.ProtocolAuthorizationDuplicateRoleRecipient="ProtocolAuthorizationDuplicateRoleRecipient",t.ProtocolAuthorizationInvalidSchema="ProtocolAuthorizationInvalidSchema",t.ProtocolAuthorizationInvalidType="ProtocolAuthorizationInvalidType",t.ProtocolAuthorizationMatchingRoleRecordNotFound="ProtocolAuthorizationMatchingRoleRecordNotFound",t.ProtocolAuthorizationMaxSizeInvalid="ProtocolAuthorizationMaxSizeInvalid",t.ProtocolAuthorizationMinSizeInvalid="ProtocolAuthorizationMinSizeInvalid",t.ProtocolAuthorizationMissingContextId="ProtocolAuthorizationMissingContextId",t.ProtocolAuthorizationMissingRuleSet="ProtocolAuthorizationMissingRuleSet",t.ProtocolAuthorizationParentlessIncorrectProtocolPath="ProtocolAuthorizationParentlessIncorrectProtocolPath",t.ProtocolAuthorizationNotARole="ProtocolAuthorizationNotARole",t.ProtocolAuthorizationParentNotFoundConstructingRecordChain="ProtocolAuthorizationParentNotFoundConstructingRecordChain",t.ProtocolAuthorizationProtocolNotFound="ProtocolAuthorizationProtocolNotFound",t.ProtocolAuthorizationRoleMissingRecipient="ProtocolAuthorizationRoleMissingRecipient",t.ProtocolAuthorizationTagsInvalidSchema="ProtocolAuthorizationTagsInvalidSchema",t.ProtocolsConfigureAuthorizationFailed="ProtocolsConfigureAuthorizationFailed",t.ProtocolsConfigureDuplicateActorInRuleSet="ProtocolsConfigureDuplicateActorInRuleSet",t.ProtocolsConfigureDuplicateRoleInRuleSet="ProtocolsConfigureDuplicateRoleInRuleSet",t.ProtocolsConfigureInvalidSize="ProtocolsConfigureInvalidSize",t.ProtocolsConfigureInvalidActionMissingOf="ProtocolsConfigureInvalidActionMissingOf",t.ProtocolsConfigureInvalidActionOfNotAllowed="ProtocolsConfigureInvalidActionOfNotAllowed",t.ProtocolsConfigureInvalidActionDeleteWithoutCreate="ProtocolsConfigureInvalidActionDeleteWithoutCreate",t.ProtocolsConfigureInvalidActionUpdateWithoutCreate="ProtocolsConfigureInvalidActionUpdateWithoutCreate",t.ProtocolsConfigureInvalidRecipientOfAction="ProtocolsConfigureInvalidRecipientOfAction",t.ProtocolsConfigureInvalidRuleSetRecordType="ProtocolsConfigureInvalidRuleSetRecordType",t.ProtocolsConfigureInvalidTagSchema="ProtocolsConfigureInvalidTagSchema",t.ProtocolsConfigureRecordNestingDepthExceeded="ProtocolsConfigureRecordNestingDepthExceeded",t.ProtocolsConfigureRoleDoesNotExistAtGivenPath="ProtocolsConfigureRoleDoesNotExistAtGivenPath",t.ProtocolsConfigureRoleReadActionMissing="ProtocolsConfigureRoleReadActionMissing",t.ProtocolsGrantAuthorizationQueryProtocolScopeMismatch="ProtocolsGrantAuthorizationQueryProtocolScopeMismatch",t.ProtocolsGrantAuthorizationScopeProtocolMismatch="ProtocolsGrantAuthorizationScopeProtocolMismatch",t.ProtocolsQueryUnauthorized="ProtocolsQueryUnauthorized",t.RecordsAuthorDelegatedGrantAndIdExistenceMismatch="RecordsAuthorDelegatedGrantAndIdExistenceMismatch",t.RecordsAuthorDelegatedGrantCidMismatch="RecordsAuthorDelegatedGrantCidMismatch",t.RecordsAuthorDelegatedGrantGrantedToAndOwnerSignatureMismatch="RecordsAuthorDelegatedGrantGrantedToAndOwnerSignatureMismatch",t.RecordsAuthorDelegatedGrantNotADelegatedGrant="RecordsAuthorDelegatedGrantNotADelegatedGrant",t.RecordsDecryptNoMatchingKeyEncryptedFound="RecordsDecryptNoMatchingKeyEncryptedFound",t.RecordsDeleteAuthorizationFailed="RecordsDeleteAuthorizationFailed",t.RecordsQueryCreateFilterPublishedSortInvalid="RecordsQueryCreateFilterPublishedSortInvalid",t.RecordsQueryParseFilterPublishedSortInvalid="RecordsQueryParseFilterPublishedSortInvalid",t.RecordsGrantAuthorizationConditionPublicationProhibited="RecordsGrantAuthorizationConditionPublicationProhibited",t.RecordsGrantAuthorizationConditionPublicationRequired="RecordsGrantAuthorizationConditionPublicationRequired",t.RecordsGrantAuthorizationDeleteProtocolScopeMismatch="RecordsGrantAuthorizationDeleteProtocolScopeMismatch",t.RecordsGrantAuthorizationQueryOrSubscribeProtocolScopeMismatch="RecordsGrantAuthorizationQueryOrSubscribeProtocolScopeMismatch",t.RecordsGrantAuthorizationScopeContextIdMismatch="RecordsGrantAuthorizationScopeContextIdMismatch",t.RecordsGrantAuthorizationScopeProtocolMismatch="RecordsGrantAuthorizationScopeProtocolMismatch",t.RecordsGrantAuthorizationScopeProtocolPathMismatch="RecordsGrantAuthorizationScopeProtocolPathMismatch",t.RecordsDerivePrivateKeyUnSupportedCurve="RecordsDerivePrivateKeyUnSupportedCurve",t.RecordsInvalidAncestorKeyDerivationSegment="RecordsInvalidAncestorKeyDerivationSegment",t.RecordsOwnerDelegatedGrantAndIdExistenceMismatch="RecordsOwnerDelegatedGrantAndIdExistenceMismatch",t.RecordsOwnerDelegatedGrantCidMismatch="RecordsOwnerDelegatedGrantCidMismatch",t.RecordsOwnerDelegatedGrantGrantedToAndOwnerSignatureMismatch="RecordsOwnerDelegatedGrantGrantedToAndOwnerSignatureMismatch",t.RecordsOwnerDelegatedGrantNotADelegatedGrant="RecordsOwnerDelegatedGrantNotADelegatedGrant",t.RecordsProtocolContextDerivationSchemeMissingContextId="RecordsProtocolContextDerivationSchemeMissingContextId",t.RecordsProtocolPathDerivationSchemeMissingProtocol="RecordsProtocolPathDerivationSchemeMissingProtocol",t.RecordsQueryFilterMissingRequiredProperties="RecordsQueryFilterMissingRequiredProperties",t.RecordsReadReturnedMultiple="RecordsReadReturnedMultiple",t.RecordsReadAuthorizationFailed="RecordsReadAuthorizationFailed",t.RecordsSubscribeEventStreamUnimplemented="RecordsSubscribeEventStreamUnimplemented",t.RecordsSubscribeFilterMissingRequiredProperties="RecordsSubscribeFilterMissingRequiredProperties",t.RecordsSchemasDerivationSchemeMissingSchema="RecordsSchemasDerivationSchemeMissingSchema",t.RecordsWriteAttestationIntegrityMoreThanOneSignature="RecordsWriteAttestationIntegrityMoreThanOneSignature",t.RecordsWriteAttestationIntegrityDescriptorCidMismatch="RecordsWriteAttestationIntegrityDescriptorCidMismatch",t.RecordsWriteAttestationIntegrityInvalidPayloadProperty="RecordsWriteAttestationIntegrityInvalidPayloadProperty",t.RecordsWriteAuthorizationFailed="RecordsWriteAuthorizationFailed",t.RecordsWriteCreateMissingSigner="RecordsWriteCreateMissingSigner",t.RecordsWriteCreateDataAndDataCidMutuallyExclusive="RecordsWriteCreateDataAndDataCidMutuallyExclusive",t.RecordsWriteCreateDataCidAndDataSizeMutuallyInclusive="RecordsWriteCreateDataCidAndDataSizeMutuallyInclusive",t.RecordsWriteCreateProtocolAndProtocolPathMutuallyInclusive="RecordsWriteCreateProtocolAndProtocolPathMutuallyInclusive",t.RecordsWriteDataCidMismatch="RecordsWriteDataCidMismatch",t.RecordsWriteDataSizeMismatch="RecordsWriteDataSizeMismatch",t.RecordsWriteGetEntryIdUndefinedAuthor="RecordsWriteGetEntryIdUndefinedAuthor",t.RecordsWriteGetNewestWriteRecordNotFound="RecordsWriteGetNewestWriteRecordNotFound",t.RecordsWriteGetInitialWriteNotFound="RecordsWriteGetInitialWriteNotFound",t.RecordsWriteImmutablePropertyChanged="RecordsWriteImmutablePropertyChanged",t.RecordsWriteMissingSigner="RecordsWriteMissingSigner",t.RecordsWriteMissingDataInPrevious="RecordsWriteMissingDataInPrevious",t.RecordsWriteMissingEncodedDataInPrevious="RecordsWriteMissingEncodedDataInPrevious",t.RecordsWriteMissingProtocol="RecordsWriteMissingProtocol",t.RecordsWriteMissingSchema="RecordsWriteMissingSchema",t.RecordsWriteNotAllowedAfterDelete="RecordsWriteNotAllowedAfterDelete",t.RecordsWriteOwnerAndTenantMismatch="RecordsWriteOwnerAndTenantMismatch",t.RecordsWriteSignAsOwnerDelegateUnknownAuthor="RecordsWriteSignAsOwnerDelegateUnknownAuthor",t.RecordsWriteSignAsOwnerUnknownAuthor="RecordsWriteSignAsOwnerUnknownAuthor",t.RecordsWriteValidateIntegrityAttestationMismatch="RecordsWriteValidateIntegrityAttestationMismatch",t.RecordsWriteValidateIntegrityContextIdMismatch="RecordsWriteValidateIntegrityContextIdMismatch",t.RecordsWriteValidateIntegrityContextIdNotInSignerSignaturePayload="RecordsWriteValidateIntegrityContextIdNotInSignerSignaturePayload",t.RecordsWriteValidateIntegrityDateCreatedMismatch="RecordsWriteValidateIntegrityDateCreatedMismatch",t.RecordsWriteValidateIntegrityEncryptionCidMismatch="RecordsWriteValidateIntegrityEncryptionCidMismatch",t.RecordsWriteValidateIntegrityRecordIdUnauthorized="RecordsWriteValidateIntegrityRecordIdUnauthorized",t.SchemaValidatorAdditionalPropertyNotAllowed="SchemaValidatorAdditionalPropertyNotAllowed",t.SchemaValidatorFailure="SchemaValidatorFailure",t.SchemaValidatorSchemaNotFound="SchemaValidatorSchemaNotFound",t.SchemaValidatorUnevaluatedPropertyNotAllowed="SchemaValidatorUnevaluatedPropertyNotAllowed",t.Secp256k1KeyNotValid="Secp256k1KeyNotValid",t.Secp256r1KeyNotValid="Secp256r1KeyNotValid",t.TimestampInvalid="TimestampInvalid",t.UrlProtocolNotNormalized="UrlProtocolNotNormalized",t.UrlProtocolNotNormalizable="UrlProtocolNotNormalizable",t.UrlSchemaNotNormalized="UrlSchemaNotNormalized"})(oe||(oe={}));var Z5=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})};function nH(t){if(t.kty!=="OKP"||t.crv!=="Ed25519")throw new de(oe.Ed25519InvalidJwk,"invalid jwk. kty MUST be OKP. crv MUST be Ed25519")}function iH(t){return{alg:"EdDSA",kty:"OKP",crv:"Ed25519",x:qe.bytesToBase64Url(t)}}var u9={sign:(t,e)=>Z5(void 0,void 0,void 0,function*(){nH(e);let r=qe.base64UrlToBytes(e.d);return eH(t,r)}),verify:(t,e,r)=>Z5(void 0,void 0,void 0,function*(){nH(r);let n=qe.base64UrlToBytes(r.x);return tH(e,t,n)}),generateKeyPair:()=>Z5(void 0,void 0,void 0,function*(){let t=rH.randomPrivateKey(),e=yield XW(t),r=qe.bytesToBase64Url(t),n=iH(e),i=Object.assign(Object.assign({},n),{d:r});return{publicJwk:n,privateJwk:i}}),publicKeyToJwk:t=>Z5(void 0,void 0,void 0,function*(){return iH(t)})};f();f();var h9=2n**256n,Hp=h9-0x1000003d1n,to=h9-0x14551231950b75fc4402da1732fc9bebfn,uH=0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,lH=0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n,fH={p:Hp,n:to,a:0n,b:7n,Gx:uH,Gy:lH},Ns=32,oH=t=>He(He(t*t)*t+fH.b),ln=(t="")=>{throw new Error(t)},e8=t=>typeof t=="bigint",hH=t=>typeof t=="string",l9=t=>e8(t)&&0ne8(t)&&0n!(t instanceof Uint8Array)||typeof e=="number"&&e>0&&t.length!==e?ln("Uint8Array expected"):t,Tc=t=>new Uint8Array(t),Yf=(t,e)=>pH(hH(t)?Y_(t):Tc(t),e),He=(t,e=Hp)=>{let r=t%e;return r>=0n?r:e+r},sH=t=>t instanceof ba?t:ln("Point expected"),aH,ba=class t{constructor(e,r,n){this.px=e,this.py=r,this.pz=n}static fromAffine(e){return new t(e.x,e.y,1n)}static fromHex(e){e=Yf(e);let r,n=e[0],i=e.subarray(1),o=X5(i,0,Ns),s=e.length;if(s===33&&[2,3].includes(n)){l9(o)||ln("Point hex invalid: x not FE");let a=A_e(oH(o)),d=(a&1n)===1n;(n&1)===1!==d&&(a=He(-a)),r=new t(o,a,1n)}return s===65&&n===4&&(r=new t(o,X5(i,Ns,2*Ns),1n)),r?r.ok():ln("Point is not on curve")}static fromPrivateKey(e){return Zf.mul(Q5(e))}get x(){return this.aff().x}get y(){return this.aff().y}equals(e){let{px:r,py:n,pz:i}=this,{px:o,py:s,pz:a}=sH(e),d=He(r*a),u=He(o*i),c=He(n*a),l=He(s*i);return d===u&&c===l}negate(){return new t(this.px,He(-this.py),this.pz)}double(){return this.add(this)}add(e){let{px:r,py:n,pz:i}=this,{px:o,py:s,pz:a}=sH(e),{a:d,b:u}=fH,c=0n,l=0n,p=0n,m=He(u*3n),g=He(r*o),v=He(n*s),x=He(i*a),S=He(r+n),P=He(o+s);S=He(S*P),P=He(g+v),S=He(S-P),P=He(r+i);let A=He(o+a);return P=He(P*A),A=He(g+x),P=He(P-A),A=He(n+i),c=He(s+a),A=He(A*c),c=He(v+x),A=He(A-c),p=He(d*P),c=He(m*x),p=He(c+p),c=He(v-p),p=He(v+p),l=He(c*p),v=He(g+g),v=He(v+g),x=He(d*x),P=He(m*P),v=He(v+x),x=He(g-x),x=He(d*x),P=He(P+x),g=He(v*P),l=He(l+g),g=He(A*P),c=He(S*c),c=He(c-g),g=He(S*v),p=He(A*p),p=He(p+g),new t(c,l,p)}mul(e,r=!0){if(!r&&e===0n)return Y5;if(J_(e)||ln("invalid scalar"),this.equals(Zf))return R_e(e).p;let n=Y5,i=Zf;for(let o=this;e>0n;o=o.double(),e>>=1n)e&1n?n=n.add(o):r&&(i=i.add(o));return n}mulAddQUns(e,r,n){return this.mul(r,!1).add(e.mul(n,!1)).ok()}toAffine(){let{px:e,py:r,pz:n}=this;if(this.equals(Y5))return{x:0n,y:0n};if(n===1n)return{x:e,y:r};let i=Q_(n);return He(n*i)!==1n&&ln("invalid inverse"),{x:He(e*i),y:He(r*i)}}assertValidity(){let{x:e,y:r}=this.aff();return(!l9(e)||!l9(r))&&ln("Point invalid: x or y"),He(r*r)===oH(e)?this:ln("Point invalid: not on curve")}multiply(e){return this.mul(e)}aff(){return this.toAffine()}ok(){return this.assertValidity()}toHex(e=!0){let{x:r,y:n}=this.aff();return(e?(n&1n)===0n?"02":"03":"04")+V_(r)+(e?"":V_(n))}toRawBytes(e=!0){return Y_(this.toHex(e))}};ba.BASE=new ba(uH,lH,1n);ba.ZERO=new ba(0n,1n,0n);var{BASE:Zf,ZERO:Y5}=ba,mH=(t,e)=>t.toString(16).padStart(e,"0"),p9=t=>Array.from(t).map(e=>mH(e,2)).join(""),Y_=t=>{let e=t.length;(!hH(t)||e%2)&&ln("hex invalid 1");let r=Tc(e/2);for(let n=0;nBigInt("0x"+(p9(t)||"0")),X5=(t,e,r)=>X_(t.slice(e,r)),t8=t=>e8(t)&&t>=0n&&tp9(t8(t)),f9=(...t)=>{let e=Tc(t.reduce((n,i)=>n+pH(i).length,0)),r=0;return t.forEach(n=>{e.set(n,r),r+=n.length}),e},Q_=(t,e=Hp)=>{(t===0n||e<=0n)&&ln("no inverse n="+t+" mod="+e);let r=He(t,e),n=e,i=0n,o=1n,s=1n,a=0n;for(;r!==0n;){let d=n/r,u=n%r,c=i-s*d,l=o-a*d;n=r,r=u,i=s,o=a,s=c,a=l}return n===1n?He(i,e):ln("no inverse")},A_e=t=>{let e=1n;for(let r=t,n=(Hp+1n)/4n;n>0n;n>>=1n)n&1n&&(e=e*r%Hp),r=r*r%Hp;return He(e*e)===t?e:ln("sqrt invalid")},Q5=t=>(e8(t)||(t=X_(Yf(t,Ns))),J_(t)?t:ln("private key out of range")),m9=t=>t>to>>1n;function r8(t,e=!0){return ba.fromPrivateKey(t).toRawBytes(e)}var Z_=class t{constructor(e,r,n){this.r=e,this.s=r,this.recovery=n,this.assertValidity()}static fromCompact(e){return e=Yf(e,64),new t(X5(e,0,Ns),X5(e,Ns,2*Ns))}assertValidity(){return J_(this.r)&&J_(this.s)?this:ln()}addRecoveryBit(e){return new t(this.r,this.s,e)}hasHighS(){return m9(this.s)}recoverPublicKey(e){let{r,s:n,recovery:i}=this;[0,1,2,3].includes(i)||ln("recovery id invalid");let o=y9(Yf(e,32)),s=i===2||i===3?r+to:r;s>=Hp&&ln("q.x invalid");let a=i&1?"03":"02",d=ba.fromHex(a+V_(s)),u=Q_(s,to),c=He(-o*u,to),l=He(n*u,to);return Zf.mulAddQUns(d,c,l)}toCompactRawBytes(){return Y_(this.toCompactHex())}toCompactHex(){return V_(this.r)+V_(this.s)}},yH=t=>{let e=t.length*8-256,r=X_(t);return e>0?r>>BigInt(e):r},y9=t=>He(yH(t),to),cH=t=>t8(t),dH=()=>typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0,G_,gH={lowS:!0},T_e={lowS:!0};function P_e(t,e,r=gH){["der","recovered","canonical"].some(l=>l in r)&&ln("sign() legacy options not supported");let{lowS:n}=r;n==null&&(n=!0);let i=y9(Yf(t)),o=cH(i),s=Q5(e),a=[cH(s),o],d=r.extraEntropy;if(d){d===!0&&(d=T0.randomBytes(Ns));let l=Yf(d);l.length!==Ns&&ln(),a.push(l)}let u=i,c=l=>{let p=yH(l);if(!J_(p))return;let m=Q_(p,to),g=Zf.mul(p).aff(),v=He(g.x,to);if(v===0n)return;let x=He(m*He(u+He(s*v,to),to),to);if(x===0n)return;let S=x,P=(g.x===v?0:2)|Number(g.y&1n);return n&&m9(x)&&(S=He(-x,to),P^=1),new Z_(v,S,P)};return{seed:f9(...a),k2sig:c}}function I_e(t){let e=Tc(Ns),r=Tc(Ns),n=0,i=()=>{e.fill(1),r.fill(0),n=0},o="drbg: tried 1000 values";if(t){let s=(...u)=>T0.hmacSha256Async(r,e,...u),a=async(u=Tc())=>{r=await s(Tc([0]),u),e=await s(),u.length!==0&&(r=await s(Tc([1]),u),e=await s())},d=async()=>(n++>=1e3&&ln(o),e=await s(),e);return async(u,c)=>{i(),await a(u);let l;for(;!(l=c(await d()));)await a();return i(),l}}else{let s=(...u)=>{let c=G_;return c||ln("etc.hmacSha256Sync not set"),c(r,e,...u)},a=(u=Tc())=>{r=s(Tc([0]),u),e=s(),u.length!==0&&(r=s(Tc([1]),u),e=s())},d=()=>(n++>=1e3&&ln(o),e=s(),e);return(u,c)=>{i(),a(u);let l;for(;!(l=c(d()));)a();return i(),l}}}async function vH(t,e,r=gH){let{seed:n,k2sig:i}=P_e(t,e,r);return I_e(!0)(n,i)}function bH(t,e,r,n=T_e){let{lowS:i}=n;i==null&&(i=!0),"strict"in n&&ln("verify() legacy options not supported");let o,s,a,d=t&&typeof t=="object"&&"r"in t;!d&&Yf(t).length!==2*Ns&&ln("signature must be 64 bytes");try{o=d?new Z_(t.r,t.s).assertValidity():Z_.fromCompact(t),s=y9(Yf(e,Ns)),a=r instanceof ba?r.ok():ba.fromHex(r)}catch{return!1}if(!o)return!1;let{r:u,s:c}=o;if(i&&m9(c))return!1;let l;try{let m=Q_(c,to),g=He(s*m,to),v=He(u*m,to);l=Zf.mulAddQUns(a,g,v).aff()}catch{return!1}return l?He(l.x,to)===u:!1}function wH(t){t=Yf(t);let e=Ns+8;(t.length1024)&&ln("expected proper params");let r=He(X_(t),to-1n)+1n;return t8(r)}var T0={hexToBytes:Y_,bytesToHex:p9,concatBytes:f9,bytesToNumberBE:X_,numberToBytesBE:t8,mod:He,invert:Q_,hmacSha256Async:async(t,...e)=>{let r=dH();if(!r)return ln("etc.hmacSha256Async not set");let n=r.subtle,i=await n.importKey("raw",t,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);return Tc(await n.sign("HMAC",i,f9(...e)))},hmacSha256Sync:G_,hashToPrivateKey:wH,randomBytes:t=>{let e=dH();return e||ln("crypto.getRandomValues must be defined"),e.getRandomValues(Tc(t))}},g9={normPrivateKeyToScalar:Q5,isValidPrivateKey:t=>{try{return!!Q5(t)}catch{return!1}},randomPrivateKey:()=>wH(T0.randomBytes(Ns+8)),precompute(t=8,e=Zf){return e.multiply(3n),e}};Object.defineProperties(T0,{hmacSha256Sync:{configurable:!1,get(){return G_},set(t){G_||(G_=t)}}});var A0=8,k_e=()=>{let t=[],e=256/A0+1,r=Zf,n=r;for(let i=0;i{let e=aH||(aH=k_e()),r=(c,l)=>{let p=l.negate();return c?p:l},n=Y5,i=Zf,o=1+256/A0,s=2**(A0-1),a=BigInt(2**A0-1),d=2**A0,u=BigInt(A0);for(let c=0;c>=u,p>s&&(p-=d,t+=1n);let m=l,g=l+Math.abs(p)-1,v=c%2!==0,x=p<0;p===0?i=i.add(r(v,e[m])):n=n.add(r(x,e[g]))}return{p:n,f:i}};f();f();f();var Xf={};Pr(Xf,{decode:()=>Fb,encodeTo:()=>P0,encodingLength:()=>I0});f();f();var B_e=EH,_H=128,M_e=127,O_e=~M_e,C_e=Math.pow(2,31);function EH(t,e,r){e=e||[],r=r||0;for(var n=r;t>=C_e;)e[r++]=t&255|_H,t/=128;for(;t&O_e;)e[r++]=t&255|_H,t>>>=7;return e[r]=t|0,EH.bytes=r-n+1,e}var $_e=v9,j_e=128,xH=127;function v9(t,n){var r=0,n=n||0,i=0,o=n,s,a=t.length;do{if(o>=a)throw v9.bytes=0,new RangeError("Could not decode varint");s=t[o++],r+=i<28?(s&xH)<=j_e);return v9.bytes=o-n,r}var N_e=Math.pow(2,7),U_e=Math.pow(2,14),q_e=Math.pow(2,21),L_e=Math.pow(2,28),K_e=Math.pow(2,35),F_e=Math.pow(2,42),z_e=Math.pow(2,49),W_e=Math.pow(2,56),H_e=Math.pow(2,63),V_e=function(t){return t[ex.decode(t,e),ex.decode.bytes],P0=(t,e,r=0)=>(ex.encode(t,e,r),e),I0=t=>ex.encodingLength(t);var k0=(t,e)=>{let r=e.byteLength,n=I0(t),i=n+I0(r),o=new Uint8Array(i+r);return P0(t,o,0),P0(r,o,n),o.set(e,i),new zb(t,r,e,o)},n8=t=>{let e=pu(t),[r,n]=Fb(e),[i,o]=Fb(e.subarray(n)),s=e.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new zb(r,i,s,e)},SH=(t,e)=>{if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&NW(t.bytes,r.bytes)}},zb=class{constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}};var w9=({name:t,code:e,encode:r})=>new b9(t,e,r),b9=class{constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?k0(this.code,r):r.then(n=>k0(this.code,n))}else throw Error("Unknown type, must be binary type")}};var AH=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),Us=w9({name:"sha2-256",code:18,encode:AH("SHA-256")}),Tot=w9({name:"sha2-512",code:19,encode:AH("SHA-512")});var Vp=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Y_e=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function PH(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");TH(t.outputLen),TH(t.blockLen)}function Hb(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 IH(t,e){Wb(t);let r=e.outputLen;if(t.lengthnew DataView(t.buffer,t.byteOffset,t.byteLength),mu=(t,e)=>t<<32-e|t>>>e;var qot=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Q_e(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function rx(t){return typeof t=="string"&&(t=Q_e(t)),Wb(t),t}function kH(...t){let e=0;for(let n=0;nt().update(rx(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Gb(t=32){if(Gp&&typeof Gp.getRandomValues=="function")return Gp.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function exe(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),d=n?4:0,u=n?0:4;t.setUint32(e+d,s,n),t.setUint32(e+u,a,n)}var DH=(t,e,r)=>t&e^~t&r,BH=(t,e,r)=>t&e^t&r^e&r,o8=class extends Vb{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=i8(this.buffer)}update(e){Hb(this);let{view:r,buffer:n,blockLen:i}=this;e=rx(e);let o=e.length;for(let s=0;si-s&&(this.process(n,0),s=0);for(let l=s;lc.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l>>3,v=mu(m,17)^mu(m,19)^m>>>10;Zp[l]=v+Zp[l-7]+g+Zp[l-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:d,G:u,H:c}=this;for(let l=0;l<64;l++){let p=mu(a,6)^mu(a,11)^mu(a,25),m=c+p+DH(a,d,u)+txe[l]+Zp[l]|0,v=(mu(n,2)^mu(n,13)^mu(n,22))+BH(n,i,o)|0;c=u,u=d,d=a,a=s+m|0,s=o,o=i,i=n,n=m+v|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,d=d+this.F|0,u=u+this.G|0,c=c+this.H|0,this.set(n,i,o,s,a,d,u,c)}roundClean(){Zp.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var So=RH(()=>new _9);f();f();var s8=class extends Vb{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,PH(e);let n=rx(r);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let i=this.blockLen,o=new Uint8Array(i);o.set(n.length>i?e.create().update(n).digest():n);for(let s=0;snew s8(t,e).update(r).digest();x9.create=(t,e)=>new s8(t,e);f();f();f();var T9={};Pr(T9,{abytes:()=>Jb,bitGet:()=>cxe,bitLen:()=>axe,bitMask:()=>nx,bitSet:()=>dxe,bytesToHex:()=>R0,bytesToNumberBE:()=>eh,bytesToNumberLE:()=>c8,concatBytes:()=>Zb,createHmacDrbg:()=>A9,ensureBytes:()=>Pc,equalBytes:()=>oxe,hexToBytes:()=>D0,hexToNumber:()=>S9,isBytes:()=>Yp,numberToBytesBE:()=>Xp,numberToBytesLE:()=>d8,numberToHexUnpadded:()=>$H,numberToVarBytesBE:()=>ixe,utf8ToBytes:()=>sxe,validateObject:()=>Qp});f();var CH=BigInt(0),a8=BigInt(1),rxe=BigInt(2);function Yp(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function Jb(t){if(!Yp(t))throw new Error("Uint8Array expected")}var nxe=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function R0(t){Jb(t);let e="";for(let r=0;r=Qf._0&&t<=Qf._9)return t-Qf._0;if(t>=Qf._A&&t<=Qf._F)return t-(Qf._A-10);if(t>=Qf._a&&t<=Qf._f)return t-(Qf._a-10)}function D0(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let i=0,o=0;iCH;t>>=a8,e+=1);return e}function cxe(t,e){return t>>BigInt(e)&a8}function dxe(t,e,r){return t|(r?a8:CH)<(rxe<new Uint8Array(t),OH=t=>Uint8Array.from(t);function A9(t,e,r){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=E9(t),i=E9(t),o=0,s=()=>{n.fill(1),i.fill(0),o=0},a=(...l)=>r(i,n,...l),d=(l=E9())=>{i=a(OH([0]),l),n=a(),l.length!==0&&(i=a(OH([1]),l),n=a())},u=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,p=[];for(;l{s(),d(l);let m;for(;!(m=p(u()));)d();return s(),m}}var uxe={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||Yp(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function Qp(t,e,r={}){let n=(i,o,s)=>{let a=uxe[o];if(typeof a!="function")throw new Error(`Invalid validator "${o}", expected function`);let d=t[i];if(!(s&&d===void 0)&&!a(d,t))throw new Error(`Invalid param ${String(i)}=${d} (${typeof d}), expected ${o}`)};for(let[i,o]of Object.entries(e))n(i,o,!1);for(let[i,o]of Object.entries(r))n(i,o,!0);return t}var Ao=BigInt(0),pi=BigInt(1),B0=BigInt(2),lxe=BigInt(3),P9=BigInt(4),jH=BigInt(5),NH=BigInt(8),fxe=BigInt(9),hxe=BigInt(16);function Ic(t,e){let r=t%e;return r>=Ao?r:e+r}function pxe(t,e,r){if(r<=Ao||e 0");if(r===pi)return Ao;let n=pi;for(;e>Ao;)e&pi&&(n=n*t%r),t=t*t%r,e>>=pi;return n}function u8(t,e){if(t===Ao||e<=Ao)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=Ic(t,e),n=e,i=Ao,o=pi,s=pi,a=Ao;for(;r!==Ao;){let u=n/r,c=n%r,l=i-s*u,p=o-a*u;n=r,r=c,i=s,o=a,s=l,a=p}if(n!==pi)throw new Error("invert: does not exist");return Ic(i,e)}function mxe(t){let e=(t-pi)/B0,r,n,i;for(r=t-pi,n=0;r%B0===Ao;r/=B0,n++);for(i=B0;i(n[i]="function",n),e);return Qp(t,r)}function vxe(t,e,r){if(r 0");if(r===Ao)return t.ONE;if(r===pi)return e;let n=t.ONE,i=e;for(;r>Ao;)r&pi&&(n=t.mul(n,i)),i=t.sqr(i),r>>=pi;return n}function bxe(t,e){let r=new Array(e.length),n=e.reduce((o,s,a)=>t.is0(s)?o:(r[a]=o,t.mul(o,s)),t.ONE),i=t.inv(n);return e.reduceRight((o,s,a)=>t.is0(s)?o:(r[a]=t.mul(o,r[a]),t.mul(o,s)),i),r}function k9(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function UH(t,e,r=!1,n={}){if(t<=Ao)throw new Error(`Expected Field ORDER > 0, got ${t}`);let{nBitLength:i,nByteLength:o}=k9(t,e);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=yxe(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:o,MASK:nx(i),ZERO:Ao,ONE:pi,create:d=>Ic(d,t),isValid:d=>{if(typeof d!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof d}`);return Ao<=d&&dd===Ao,isOdd:d=>(d&pi)===pi,neg:d=>Ic(-d,t),eql:(d,u)=>d===u,sqr:d=>Ic(d*d,t),add:(d,u)=>Ic(d+u,t),sub:(d,u)=>Ic(d-u,t),mul:(d,u)=>Ic(d*u,t),pow:(d,u)=>vxe(a,d,u),div:(d,u)=>Ic(d*u8(u,t),t),sqrN:d=>d*d,addN:(d,u)=>d+u,subN:(d,u)=>d-u,mulN:(d,u)=>d*u,inv:d=>u8(d,t),sqrt:n.sqrt||(d=>s(a,d)),invertBatch:d=>bxe(a,d),cmov:(d,u,c)=>c?u:d,toBytes:d=>r?d8(d,o):Xp(d,o),fromBytes:d=>{if(d.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${d.length}`);return r?c8(d):eh(d)}});return Object.freeze(a)}function qH(t){if(typeof t!="bigint")throw new Error("field order must be bigint");let e=t.toString(2).length;return Math.ceil(e/8)}function R9(t){let e=qH(t);return e+Math.ceil(e/2)}function LH(t,e,r=!1){let n=t.length,i=qH(e),o=R9(e);if(n<16||n1024)throw new Error(`expected ${o}-1024 bytes of input, got ${n}`);let s=r?eh(t):c8(t),a=Ic(s,e-pi)+pi;return r?d8(a,i):Xp(a,i)}var _xe=BigInt(0),D9=BigInt(1);function KH(t,e){let r=(i,o)=>{let s=o.negate();return i?s:o},n=i=>{let o=Math.ceil(e/i)+1,s=2**(i-1);return{windows:o,windowSize:s}};return{constTimeNegate:r,unsafeLadder(i,o){let s=t.ZERO,a=i;for(;o>_xe;)o&D9&&(s=s.add(a)),a=a.double(),o>>=D9;return s},precomputeWindow(i,o){let{windows:s,windowSize:a}=n(o),d=[],u=i,c=u;for(let l=0;l>=m,x>d&&(x-=p,s+=D9);let S=v,P=v+Math.abs(x)-1,A=g%2!==0,$=x<0;x===0?c=c.add(r(A,o[S])):u=u.add(r($,o[P]))}return{p:u,f:c}},wNAFCached(i,o,s,a){let d=i._WINDOW_SIZE||1,u=o.get(i);return u||(u=this.precomputeWindow(i,d),d!==1&&o.set(i,a(u))),this.wNAF(d,u,s)}}}function B9(t){return I9(t.Fp),Qp(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...k9(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}function xxe(t){let e=B9(t);Qp(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:r,Fp:n,a:i}=e;if(r){if(!n.eql(i,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:Exe,hexToBytes:Sxe}=T9,M0={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(t){let{Err:e}=M0;if(t.length<2||t[0]!==2)throw new e("Invalid signature integer tag");let r=t[1],n=t.subarray(2,r+2);if(!r||n.length!==r)throw new e("Invalid signature integer: wrong length");if(n[0]&128)throw new e("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:Exe(n),l:t.subarray(r+2)}},toSig(t){let{Err:e}=M0,r=typeof t=="string"?Sxe(t):t;Jb(r);let n=r.length;if(n<2||r[0]!=48)throw new e("Invalid signature tag");if(r[1]!==n-2)throw new e("Invalid signature: incorrect length");let{d:i,l:o}=M0._parseInt(r.subarray(2)),{d:s,l:a}=M0._parseInt(o);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:i,s}},hexFromSig(t){let e=u=>Number.parseInt(u[0],16)&8?"00"+u:u,r=u=>{let c=u.toString(16);return c.length&1?`0${c}`:c},n=e(r(t.s)),i=e(r(t.r)),o=n.length/2,s=i.length/2,a=r(o),d=r(s);return`30${r(s+o+4)}02${d}${i}02${a}${n}`}},th=BigInt(0),bd=BigInt(1),fst=BigInt(2),FH=BigInt(3),hst=BigInt(4);function Axe(t){let e=xxe(t),{Fp:r}=e,n=e.toBytes||((g,v,x)=>{let S=v.toAffine();return Zb(Uint8Array.from([4]),r.toBytes(S.x),r.toBytes(S.y))}),i=e.fromBytes||(g=>{let v=g.subarray(1),x=r.fromBytes(v.subarray(0,r.BYTES)),S=r.fromBytes(v.subarray(r.BYTES,2*r.BYTES));return{x,y:S}});function o(g){let{a:v,b:x}=e,S=r.sqr(g),P=r.mul(S,g);return r.add(r.add(P,r.mul(g,v)),x)}if(!r.eql(r.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function s(g){return typeof g=="bigint"&&thr.eql(A,r.ZERO);return P(x)&&P(S)?l.ZERO:new l(x,S,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(v){let x=r.invertBatch(v.map(S=>S.pz));return v.map((S,P)=>S.toAffine(x[P])).map(l.fromAffine)}static fromHex(v){let x=l.fromAffine(i(Pc("pointHex",v)));return x.assertValidity(),x}static fromPrivateKey(v){return l.BASE.multiply(d(v))}_setWindowSize(v){this._WINDOW_SIZE=v,u.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}let{x:v,y:x}=this.toAffine();if(!r.isValid(v)||!r.isValid(x))throw new Error("bad point: x or y not FE");let S=r.sqr(x),P=o(v);if(!r.eql(S,P))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:v}=this.toAffine();if(r.isOdd)return!r.isOdd(v);throw new Error("Field doesn't support isOdd")}equals(v){c(v);let{px:x,py:S,pz:P}=this,{px:A,py:$,pz:j}=v,q=r.eql(r.mul(x,j),r.mul(A,P)),F=r.eql(r.mul(S,j),r.mul($,P));return q&&F}negate(){return new l(this.px,r.neg(this.py),this.pz)}double(){let{a:v,b:x}=e,S=r.mul(x,FH),{px:P,py:A,pz:$}=this,j=r.ZERO,q=r.ZERO,F=r.ZERO,K=r.mul(P,P),W=r.mul(A,A),L=r.mul($,$),I=r.mul(P,A);return I=r.add(I,I),F=r.mul(P,$),F=r.add(F,F),j=r.mul(v,F),q=r.mul(S,L),q=r.add(j,q),j=r.sub(W,q),q=r.add(W,q),q=r.mul(j,q),j=r.mul(I,j),F=r.mul(S,F),L=r.mul(v,L),I=r.sub(K,L),I=r.mul(v,I),I=r.add(I,F),F=r.add(K,K),K=r.add(F,K),K=r.add(K,L),K=r.mul(K,I),q=r.add(q,K),L=r.mul(A,$),L=r.add(L,L),K=r.mul(L,I),j=r.sub(j,K),F=r.mul(L,W),F=r.add(F,F),F=r.add(F,F),new l(j,q,F)}add(v){c(v);let{px:x,py:S,pz:P}=this,{px:A,py:$,pz:j}=v,q=r.ZERO,F=r.ZERO,K=r.ZERO,W=e.a,L=r.mul(e.b,FH),I=r.mul(x,A),T=r.mul(S,$),B=r.mul(P,j),h=r.add(x,S),y=r.add(A,$);h=r.mul(h,y),y=r.add(I,T),h=r.sub(h,y),y=r.add(x,P);let w=r.add(A,j);return y=r.mul(y,w),w=r.add(I,B),y=r.sub(y,w),w=r.add(S,P),q=r.add($,j),w=r.mul(w,q),q=r.add(T,B),w=r.sub(w,q),K=r.mul(W,y),q=r.mul(L,B),K=r.add(q,K),q=r.sub(T,K),K=r.add(T,K),F=r.mul(q,K),T=r.add(I,I),T=r.add(T,I),B=r.mul(W,B),y=r.mul(L,y),T=r.add(T,B),B=r.sub(I,B),B=r.mul(W,B),y=r.add(y,B),I=r.mul(T,y),F=r.add(F,I),I=r.mul(w,y),q=r.mul(h,q),q=r.sub(q,I),I=r.mul(h,T),K=r.mul(w,K),K=r.add(K,I),new l(q,F,K)}subtract(v){return this.add(v.negate())}is0(){return this.equals(l.ZERO)}wNAF(v){return m.wNAFCached(this,u,v,x=>{let S=r.invertBatch(x.map(P=>P.pz));return x.map((P,A)=>P.toAffine(S[A])).map(l.fromAffine)})}multiplyUnsafe(v){let x=l.ZERO;if(v===th)return x;if(a(v),v===bd)return this;let{endo:S}=e;if(!S)return m.unsafeLadder(this,v);let{k1neg:P,k1:A,k2neg:$,k2:j}=S.splitScalar(v),q=x,F=x,K=this;for(;A>th||j>th;)A&bd&&(q=q.add(K)),j&bd&&(F=F.add(K)),K=K.double(),A>>=bd,j>>=bd;return P&&(q=q.negate()),$&&(F=F.negate()),F=new l(r.mul(F.px,S.beta),F.py,F.pz),q.add(F)}multiply(v){a(v);let x=v,S,P,{endo:A}=e;if(A){let{k1neg:$,k1:j,k2neg:q,k2:F}=A.splitScalar(x),{p:K,f:W}=this.wNAF(j),{p:L,f:I}=this.wNAF(F);K=m.constTimeNegate($,K),L=m.constTimeNegate(q,L),L=new l(r.mul(L.px,A.beta),L.py,L.pz),S=K.add(L),P=W.add(I)}else{let{p:$,f:j}=this.wNAF(x);S=$,P=j}return l.normalizeZ([S,P])[0]}multiplyAndAddUnsafe(v,x,S){let P=l.BASE,A=(j,q)=>q===th||q===bd||!j.equals(P)?j.multiplyUnsafe(q):j.multiply(q),$=A(this,x).add(A(v,S));return $.is0()?void 0:$}toAffine(v){let{px:x,py:S,pz:P}=this,A=this.is0();v==null&&(v=A?r.ONE:r.inv(P));let $=r.mul(x,v),j=r.mul(S,v),q=r.mul(P,v);if(A)return{x:r.ZERO,y:r.ZERO};if(!r.eql(q,r.ONE))throw new Error("invZ was invalid");return{x:$,y:j}}isTorsionFree(){let{h:v,isTorsionFree:x}=e;if(v===bd)return!0;if(x)return x(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:v,clearCofactor:x}=e;return v===bd?this:x?x(l,this):this.multiplyUnsafe(e.h)}toRawBytes(v=!0){return this.assertValidity(),n(l,this,v)}toHex(v=!0){return R0(this.toRawBytes(v))}}l.BASE=new l(e.Gx,e.Gy,r.ONE),l.ZERO=new l(r.ZERO,r.ONE,r.ZERO);let p=e.nBitLength,m=KH(l,e.endo?Math.ceil(p/2):p);return{CURVE:e,ProjectivePoint:l,normPrivateKeyToScalar:d,weierstrassEquation:o,isWithinCurveOrder:s}}function Txe(t){let e=B9(t);return Qp(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function zH(t){let e=Txe(t),{Fp:r,n}=e,i=r.BYTES+1,o=2*r.BYTES+1;function s(y){return thR0(Xp(y,e.nByteLength));function g(y){let w=n>>bd;return y>w}function v(y){return g(y)?a(-y):y}let x=(y,w,E)=>eh(y.slice(w,E));class S{constructor(w,E,_){this.r=w,this.s=E,this.recovery=_,this.assertValidity()}static fromCompact(w){let E=e.nByteLength;return w=Pc("compactSignature",w,E*2),new S(x(w,0,E),x(w,E,2*E))}static fromDER(w){let{r:E,s:_}=M0.toSig(Pc("DER",w));return new S(E,_)}assertValidity(){if(!p(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!p(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(w){return new S(this.r,this.s,w)}recoverPublicKey(w){let{r:E,s:_,recovery:b}=this,C=F(Pc("msgHash",w));if(b==null||![0,1,2,3].includes(b))throw new Error("recovery id invalid");let N=b===2||b===3?E+e.n:E;if(N>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let M=b&1?"03":"02",U=u.fromHex(M+m(N)),G=d(N),Z=a(-C*G),J=a(_*G),H=u.BASE.multiplyAndAddUnsafe(U,Z,J);if(!H)throw new Error("point at infinify");return H.assertValidity(),H}hasHighS(){return g(this.s)}normalizeS(){return this.hasHighS()?new S(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return D0(this.toDERHex())}toDERHex(){return M0.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return D0(this.toCompactHex())}toCompactHex(){return m(this.r)+m(this.s)}}let P={isValidPrivateKey(y){try{return c(y),!0}catch{return!1}},normPrivateKeyToScalar:c,randomPrivateKey:()=>{let y=R9(e.n);return LH(e.randomBytes(y),e.n)},precompute(y=8,w=u.BASE){return w._setWindowSize(y),w.multiply(BigInt(3)),w}};function A(y,w=!0){return u.fromPrivateKey(y).toRawBytes(w)}function $(y){let w=Yp(y),E=typeof y=="string",_=(w||E)&&y.length;return w?_===i||_===o:E?_===2*i||_===2*o:y instanceof u}function j(y,w,E=!0){if($(y))throw new Error("first arg must be private key");if(!$(w))throw new Error("second arg must be public key");return u.fromHex(w).multiply(c(y)).toRawBytes(E)}let q=e.bits2int||function(y){let w=eh(y),E=y.length*8-e.nBitLength;return E>0?w>>BigInt(E):w},F=e.bits2int_modN||function(y){return a(q(y))},K=nx(e.nBitLength);function W(y){if(typeof y!="bigint")throw new Error("bigint expected");if(!(th<=y&&yte in E))throw new Error("sign() legacy options not supported");let{hash:_,randomBytes:b}=e,{lowS:C,prehash:N,extraEntropy:M}=E;C==null&&(C=!0),y=Pc("msgHash",y),N&&(y=Pc("prehashed msgHash",_(y)));let U=F(y),G=c(w),Z=[W(G),W(U)];if(M!=null&&M!==!1){let te=M===!0?b(r.BYTES):M;Z.push(Pc("extraEntropy",te))}let J=Zb(...Z),H=U;function X(te){let ne=q(te);if(!p(ne))return;let Q=d(ne),re=u.BASE.multiply(ne).toAffine(),ce=a(re.x);if(ce===th)return;let pe=a(Q*a(H+ce*G));if(pe===th)return;let ye=(re.x===ce?0:2)|Number(re.y&bd),ie=pe;return C&&g(pe)&&(ie=v(pe),ye^=1),new S(ce,ie,ye)}return{seed:J,k2sig:X}}let I={lowS:e.lowS,prehash:!1},T={lowS:e.lowS,prehash:!1};function B(y,w,E=I){let{seed:_,k2sig:b}=L(y,w,E),C=e;return A9(C.hash.outputLen,C.nByteLength,C.hmac)(_,b)}u.BASE._setWindowSize(8);function h(y,w,E,_=T){let b=y;if(w=Pc("msgHash",w),E=Pc("publicKey",E),"strict"in _)throw new Error("options.strict was renamed to lowS");let{lowS:C,prehash:N}=_,M,U;try{if(typeof b=="string"||Yp(b))try{M=S.fromDER(b)}catch(re){if(!(re instanceof M0.Err))throw re;M=S.fromCompact(b)}else if(typeof b=="object"&&typeof b.r=="bigint"&&typeof b.s=="bigint"){let{r:re,s:ce}=b;M=new S(re,ce)}else throw new Error("PARSE");U=u.fromHex(E)}catch(re){if(re.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(C&&M.hasHighS())return!1;N&&(w=e.hash(w));let{r:G,s:Z}=M,J=F(w),H=d(Z),X=a(J*H),te=a(G*H),ne=u.BASE.multiplyAndAddUnsafe(U,X,te)?.toAffine();return ne?a(ne.x)===G:!1}return{CURVE:e,getPublicKey:A,getSharedSecret:j,sign:B,verify:h,ProjectivePoint:u,Signature:S,utils:P}}function Pxe(t){return{hash:t,hmac:(e,...r)=>x9(t,e,kH(...r)),randomBytes:Gb}}function WH(t,e){let r=n=>zH({...t,...Pxe(n)});return Object.freeze({...r(e),create:r})}var HH=UH(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),Ixe=HH.create(BigInt("-3")),kxe=BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),rh=WH({a:Ixe,b:kxe,Fp:HH,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},So),VH=rh;f();f();function M9(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;ri+o.length,0));let r=Ja(e),n=0;for(let i of t)r.set(i,n),n+=i.length;return r}f();f();f();var L9={};Pr(L9,{base10:()=>Uxe});f();f();var Xb={};Pr(Xb,{coerce:()=>Al,empty:()=>GH,equals:()=>O9,fromHex:()=>Bxe,fromString:()=>C9,isBinary:()=>Mxe,toHex:()=>Dxe,toString:()=>$9});f();var GH=new Uint8Array(0);function Dxe(t){return t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")}function Bxe(t){let e=t.match(/../g);return e!=null?new Uint8Array(e.map(r=>parseInt(r,16))):GH}function O9(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n>>0,$=new Uint8Array(A);S!==P;){for(var j=g[S],q=0,F=A-1;(j!==0||q>>0,$[F]=j%a>>>0,j=j/a>>>0;if(j!==0)throw new Error("Non-zero carry");x=q,S++}for(var K=A-x;K!==A&&$[K]===0;)K++;for(var W=d.repeat(v);K>>0,A=new Uint8Array(P);g[v];){var $=r[g.charCodeAt(v)];if($===255)return;for(var j=0,q=P-1;($!==0||j>>0,A[q]=$%256>>>0,$=$/256>>>0;if($!==0)throw new Error("Non-zero carry");S=j,v++}if(g[v]!==" "){for(var F=P-S;F!==P&&A[F]===0;)F++;for(var K=new Uint8Array(x+(P-F)),W=x;F!==P;)K[W++]=A[F++];return K}}}function m(g){var v=p(g);if(v)return v;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:p,decode:m}}var Cxe=Oxe,$xe=Cxe,JH=$xe;var j9=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")}},N9=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 ZH(this,e)}},U9=class{decoders;constructor(e){this.decoders=e}or(e){return ZH(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 ZH(t,e){return new U9({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var q9=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 j9(e,r,n),this.decoder=new N9(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Qb({name:t,prefix:e,encode:r,decode:n}){return new q9(t,e,r,n)}function em({name:t,prefix:e,alphabet:r}){let{encode:n,decode:i}=JH(r,t);return Qb({prefix:e,name:t,encode:n,decode:o=>Al(i(o))})}function jxe(t,e,r,n){let i={};for(let c=0;c=8&&(a-=8,s[u++]=255&d>>a)}if(a>=r||255&d<<8-a)throw new SyntaxError("Unexpected end of data");return s}function Nxe(t,e,r){let n=e[e.length-1]==="=",i=(1<r;)s-=r,o+=e[i&a>>s];if(s!==0&&(o+=e[i&a<qxe,base16upper:()=>Lxe});f();var qxe=mi({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Lxe=mi({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var F9={};Pr(F9,{base2:()=>Kxe});f();var Kxe=mi({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var z9={};Pr(z9,{base256emoji:()=>Vxe});f();var YH=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),Fxe=YH.reduce((t,e,r)=>(t[r]=e,t),[]),zxe=YH.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function Wxe(t){return t.reduce((e,r)=>(e+=Fxe[r],e),"")}function Hxe(t){let e=[];for(let r of t){let n=zxe[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}var Vxe=Qb({prefix:"\u{1F680}",name:"base256emoji",encode:Wxe,decode:Hxe});var W9={};Pr(W9,{base32:()=>ew,base32hex:()=>Yxe,base32hexpad:()=>Qxe,base32hexpadupper:()=>eEe,base32hexupper:()=>Xxe,base32pad:()=>Jxe,base32padupper:()=>Zxe,base32upper:()=>Gxe,base32z:()=>O0});f();var ew=mi({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Gxe=mi({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Jxe=mi({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Zxe=mi({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Yxe=mi({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Xxe=mi({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Qxe=mi({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),eEe=mi({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),O0=mi({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var H9={};Pr(H9,{base36:()=>tEe,base36upper:()=>rEe});f();var tEe=em({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),rEe=em({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var V9={};Pr(V9,{base58btc:()=>Fi,base58flickr:()=>nEe});f();var Fi=em({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),nEe=em({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var G9={};Pr(G9,{base64:()=>iEe,base64pad:()=>oEe,base64url:()=>Pi,base64urlpad:()=>sEe});f();var iEe=mi({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),oEe=mi({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Pi=mi({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),sEe=mi({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var J9={};Pr(J9,{base8:()=>aEe});f();var aEe=mi({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Z9={};Pr(Z9,{identity:()=>cEe});f();var cEe=Qb({prefix:"\0",name:"identity",encode:t=>$9(t),decode:t=>C9(t)});f();var yat=new TextEncoder,gat=new TextDecoder;f();var X9={};Pr(X9,{identity:()=>DEe});f();f();var wa={};Pr(wa,{decode:()=>tw,encodeTo:()=>C0,encodingLength:()=>$0});f();f();var lEe=eV,XH=128,fEe=127,hEe=~fEe,pEe=Math.pow(2,31);function eV(t,e,r){e=e||[],r=r||0;for(var n=r;t>=pEe;)e[r++]=t&255|XH,t/=128;for(;t&hEe;)e[r++]=t&255|XH,t>>>=7;return e[r]=t|0,eV.bytes=r-n+1,e}var mEe=Y9,yEe=128,QH=127;function Y9(t,n){var r=0,n=n||0,i=0,o=n,s,a=t.length;do{if(o>=a)throw Y9.bytes=0,new RangeError("Could not decode varint");s=t[o++],r+=i<28?(s&QH)<=yEe);return Y9.bytes=o-n,r}var gEe=Math.pow(2,7),vEe=Math.pow(2,14),bEe=Math.pow(2,21),wEe=Math.pow(2,28),_Ee=Math.pow(2,35),xEe=Math.pow(2,42),EEe=Math.pow(2,49),SEe=Math.pow(2,56),AEe=Math.pow(2,63),TEe=function(t){return tBEe,sha512:()=>MEe});f();f();function N0({name:t,code:e,encode:r}){return new Q9(t,e,r)}var Q9=class{name;code;encode;constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?j0(this.code,r):r.then(n=>j0(this.code,n))}else throw Error("Unknown type, must be binary type")}};function sV(t){return async e=>new Uint8Array(await crypto.subtle.digest(t,e))}var BEe=N0({name:"sha2-256",code:18,encode:sV("SHA-256")}),MEe=N0({name:"sha2-512",code:19,encode:sV("SHA-512")});f();f();f();function aV(t,e){let{bytes:r,version:n}=t;switch(n){case 0:return CEe(r,tB(t),e??Fi.encoder);default:return $Ee(r,tB(t),e??ew.encoder)}}var cV=new WeakMap;function tB(t){let e=cV.get(t);if(e==null){let r=new Map;return cV.set(t,r),r}return e}var yu=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!==sx)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==jEe)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=j0(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&&rV(e.multihash,n.multihash)}toString(e){return aV(this,e)}toJSON(){return{"/":aV(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??dV(n,i,o.bytes))}else if(r[NEe]===!0){let{version:n,multihash:i,code:o}=r,s=tV(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!==sx)throw new Error(`Version 0 CID must use dag-pb (code: ${sx}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let i=dV(e,r,n.bytes);return new t(e,r,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,sx,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=Al(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 rw(r.multihashCode,r.digestSize,o,i);return[r.version===0?t.createV0(s):t.createV1(r.codec,s),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[l,p]=tw(e.subarray(r));return r+=p,l},i=n(),o=sx;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(),d=n(),u=r+d,c=u-s;return{version:i,codec:o,multihashCode:a,digestSize:d,multihashSize:c,size:u}}static parse(e,r){let[n,i]=OEe(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 tB(o).set(n,e),o}};function OEe(t,e){switch(t[0]){case"Q":{let r=e??Fi;return[Fi.prefix,r.decode(`${Fi.prefix}${t}`)]}case Fi.prefix:{let r=e??Fi;return[Fi.prefix,r.decode(t)]}case ew.prefix:{let r=e??ew;return[ew.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 CEe(t,e,r){let{prefix:n}=r;if(n!==Fi.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 $Ee(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 sx=112,jEe=18;function dV(t,e,r){let n=$0(t),i=n+$0(e),o=new Uint8Array(i+r.byteLength);return C0(t,o,0),C0(e,o,n),o.set(r,i),o}var NEe=Symbol.for("@ipld/js-cid/CID");f();f();f();f();f();var rB={...Z9,...F9,...J9,...L9,...K9,...W9,...H9,...V9,...G9,...z9},ect={...eB,...X9};function lV(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var uV=lV("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),nB=lV("ascii","a",t=>{let e="a";for(let r=0;r{t=t.substring(1);let e=Ja(t.length);for(let r=0;rt.createSigner(n))}static createSigner(e){let r=e.keyPair.privateJwk,n=e.keyId;return new iw({privateJwk:r,keyId:n})}};f();f();var ax=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,pV=new Set,oB=typeof k.default=="object"&&k.default?k.default:{},mV=(t,e,r,n)=>{typeof oB.emitWarning=="function"?oB.emitWarning(t,e,r,n):console.error(`[${r}] ${e}: ${t}`)},h8=globalThis.AbortController,hV=globalThis.AbortSignal;if(typeof h8>"u"){hV=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(n,i){this._onabort.push(i)}},h8=class{constructor(){e()}signal=new hV;abort(n){if(!this.signal.aborted){this.signal.reason=n,this.signal.aborted=!0;for(let i of this.signal._onabort)i(n);this.signal.onabort?.(n)}}};let t=oB.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{t&&(t=!1,mV("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e))}}var FEe=t=>!pV.has(t),Vct=Symbol("type"),rm=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),yV=t=>rm(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?ow:null:null,ow=class extends Array{constructor(e){super(e),this.fill(0)}},sB=class t{heap;length;static#c=!1;static create(e){let r=yV(e);if(!r)return[];t.#c=!0;let n=new t(e,r);return t.#c=!1,n}constructor(e,r){if(!t.#c)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new r(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},p8=class t{#c;#l;#v;#p;#k;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#n;#m;#i;#r;#e;#d;#f;#a;#o;#y;#s;#x;#E;#g;#b;#A;#u;static unsafeExposeInternals(e){return{starts:e.#E,ttls:e.#g,sizes:e.#x,keyMap:e.#i,keyList:e.#r,valList:e.#e,next:e.#d,prev:e.#f,get head(){return e.#a},get tail(){return e.#o},free:e.#y,isBackgroundFetch:r=>e.#t(r),backgroundFetch:(r,n,i,o)=>e.#B(r,n,i,o),moveToTail:r=>e.#I(r),indexes:r=>e.#w(r),rindexes:r=>e.#_(r),isStale:r=>e.#h(r)}}get max(){return this.#c}get maxSize(){return this.#l}get calculatedSize(){return this.#m}get size(){return this.#n}get fetchMethod(){return this.#k}get dispose(){return this.#v}get disposeAfter(){return this.#p}constructor(e){let{max:r=0,ttl:n,ttlResolution:i=1,ttlAutopurge:o,updateAgeOnGet:s,updateAgeOnHas:a,allowStale:d,dispose:u,disposeAfter:c,noDisposeOnSet:l,noUpdateTTL:p,maxSize:m=0,maxEntrySize:g=0,sizeCalculation:v,fetchMethod:x,noDeleteOnFetchRejection:S,noDeleteOnStaleGet:P,allowStaleOnFetchRejection:A,allowStaleOnFetchAbort:$,ignoreFetchAbort:j}=e;if(r!==0&&!rm(r))throw new TypeError("max option must be a nonnegative integer");let q=r?yV(r):Array;if(!q)throw new Error("invalid max value: "+r);if(this.#c=r,this.#l=m,this.maxEntrySize=g||this.#l,this.sizeCalculation=v,this.sizeCalculation){if(!this.#l&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(x!==void 0&&typeof x!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#k=x,this.#A=!!x,this.#i=new Map,this.#r=new Array(r).fill(void 0),this.#e=new Array(r).fill(void 0),this.#d=new q(r),this.#f=new q(r),this.#a=0,this.#o=0,this.#y=sB.create(r),this.#n=0,this.#m=0,typeof u=="function"&&(this.#v=u),typeof c=="function"?(this.#p=c,this.#s=[]):(this.#p=void 0,this.#s=void 0),this.#b=!!this.#v,this.#u=!!this.#p,this.noDisposeOnSet=!!l,this.noUpdateTTL=!!p,this.noDeleteOnFetchRejection=!!S,this.allowStaleOnFetchRejection=!!A,this.allowStaleOnFetchAbort=!!$,this.ignoreFetchAbort=!!j,this.maxEntrySize!==0){if(this.#l!==0&&!rm(this.#l))throw new TypeError("maxSize must be a positive integer if specified");if(!rm(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#N()}if(this.allowStale=!!d,this.noDeleteOnStaleGet=!!P,this.updateAgeOnGet=!!s,this.updateAgeOnHas=!!a,this.ttlResolution=rm(i)||i===0?i:1,this.ttlAutopurge=!!o,this.ttl=n||0,this.ttl){if(!rm(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#M()}if(this.#c===0&&this.ttl===0&&this.#l===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#c&&!this.#l){let F="LRU_CACHE_UNBOUNDED";FEe(F)&&(pV.add(F),mV("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",F,t))}}getRemainingTTL(e){return this.#i.has(e)?1/0:0}#M(){let e=new ow(this.#c),r=new ow(this.#c);this.#g=e,this.#E=r,this.#O=(o,s,a=ax.now())=>{if(r[o]=s!==0?a:0,e[o]=s,s!==0&&this.ttlAutopurge){let d=setTimeout(()=>{this.#h(o)&&this.delete(this.#r[o])},s+1);d.unref&&d.unref()}},this.#T=o=>{r[o]=e[o]!==0?ax.now():0},this.#S=(o,s)=>{if(e[s]){let a=e[s],d=r[s];o.ttl=a,o.start=d,o.now=n||i();let u=o.now-d;o.remainingTTL=a-u}};let n=0,i=()=>{let o=ax.now();if(this.ttlResolution>0){n=o;let s=setTimeout(()=>n=0,this.ttlResolution);s.unref&&s.unref()}return o};this.getRemainingTTL=o=>{let s=this.#i.get(o);if(s===void 0)return 0;let a=e[s],d=r[s];if(a===0||d===0)return 1/0;let u=(n||i())-d;return a-u},this.#h=o=>e[o]!==0&&r[o]!==0&&(n||i())-r[o]>e[o]}#T=()=>{};#S=()=>{};#O=()=>{};#h=()=>!1;#N(){let e=new ow(this.#c);this.#m=0,this.#x=e,this.#P=r=>{this.#m-=e[r],e[r]=0},this.#C=(r,n,i,o)=>{if(this.#t(n))return 0;if(!rm(i))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(i=o(n,r),!rm(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return i},this.#R=(r,n,i)=>{if(e[r]=n,this.#l){let o=this.#l-e[r];for(;this.#m>o;)this.#D(!0)}this.#m+=e[r],i&&(i.entrySize=n,i.totalCalculatedSize=this.#m)}}#P=e=>{};#R=(e,r,n)=>{};#C=(e,r,n,i)=>{if(n||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#w({allowStale:e=this.allowStale}={}){if(this.#n)for(let r=this.#o;!(!this.#$(r)||((e||!this.#h(r))&&(yield r),r===this.#a));)r=this.#f[r]}*#_({allowStale:e=this.allowStale}={}){if(this.#n)for(let r=this.#a;!(!this.#$(r)||((e||!this.#h(r))&&(yield r),r===this.#o));)r=this.#d[r]}#$(e){return e!==void 0&&this.#i.get(this.#r[e])===e}*entries(){for(let e of this.#w())this.#e[e]!==void 0&&this.#r[e]!==void 0&&!this.#t(this.#e[e])&&(yield[this.#r[e],this.#e[e]])}*rentries(){for(let e of this.#_())this.#e[e]!==void 0&&this.#r[e]!==void 0&&!this.#t(this.#e[e])&&(yield[this.#r[e],this.#e[e]])}*keys(){for(let e of this.#w()){let r=this.#r[e];r!==void 0&&!this.#t(this.#e[e])&&(yield r)}}*rkeys(){for(let e of this.#_()){let r=this.#r[e];r!==void 0&&!this.#t(this.#e[e])&&(yield r)}}*values(){for(let e of this.#w())this.#e[e]!==void 0&&!this.#t(this.#e[e])&&(yield this.#e[e])}*rvalues(){for(let e of this.#_())this.#e[e]!==void 0&&!this.#t(this.#e[e])&&(yield this.#e[e])}[Symbol.iterator](){return this.entries()}find(e,r={}){for(let n of this.#w()){let i=this.#e[n],o=this.#t(i)?i.__staleWhileFetching:i;if(o!==void 0&&e(o,this.#r[n],this))return this.get(this.#r[n],r)}}forEach(e,r=this){for(let n of this.#w()){let i=this.#e[n],o=this.#t(i)?i.__staleWhileFetching:i;o!==void 0&&e.call(r,o,this.#r[n],this)}}rforEach(e,r=this){for(let n of this.#_()){let i=this.#e[n],o=this.#t(i)?i.__staleWhileFetching:i;o!==void 0&&e.call(r,o,this.#r[n],this)}}purgeStale(){let e=!1;for(let r of this.#_({allowStale:!0}))this.#h(r)&&(this.delete(this.#r[r]),e=!0);return e}dump(){let e=[];for(let r of this.#w({allowStale:!0})){let n=this.#r[r],i=this.#e[r],o=this.#t(i)?i.__staleWhileFetching:i;if(o===void 0||n===void 0)continue;let s={value:o};if(this.#g&&this.#E){s.ttl=this.#g[r];let a=ax.now()-this.#E[r];s.start=Math.floor(Date.now()-a)}this.#x&&(s.size=this.#x[r]),e.unshift([n,s])}return e}load(e){this.clear();for(let[r,n]of e){if(n.start){let i=Date.now()-n.start;n.start=ax.now()-i}this.set(r,n.value,n)}}set(e,r,n={}){if(r===void 0)return this.delete(e),this;let{ttl:i=this.ttl,start:o,noDisposeOnSet:s=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:d}=n,{noUpdateTTL:u=this.noUpdateTTL}=n,c=this.#C(e,r,n.size||0,a);if(this.maxEntrySize&&c>this.maxEntrySize)return d&&(d.set="miss",d.maxEntrySizeExceeded=!0),this.delete(e),this;let l=this.#n===0?void 0:this.#i.get(e);if(l===void 0)l=this.#n===0?this.#o:this.#y.length!==0?this.#y.pop():this.#n===this.#c?this.#D(!1):this.#n,this.#r[l]=e,this.#e[l]=r,this.#i.set(e,l),this.#d[this.#o]=l,this.#f[l]=this.#o,this.#o=l,this.#n++,this.#R(l,c,d),d&&(d.set="add"),u=!1;else{this.#I(l);let p=this.#e[l];if(r!==p){if(this.#A&&this.#t(p)?p.__abortController.abort(new Error("replaced")):s||(this.#b&&this.#v?.(p,e,"set"),this.#u&&this.#s?.push([p,e,"set"])),this.#P(l),this.#R(l,c,d),this.#e[l]=r,d){d.set="replace";let m=p&&this.#t(p)?p.__staleWhileFetching:p;m!==void 0&&(d.oldValue=m)}}else d&&(d.set="update")}if(i!==0&&!this.#g&&this.#M(),this.#g&&(u||this.#O(l,i,o),d&&this.#S(d,l)),!s&&this.#u&&this.#s){let p=this.#s,m;for(;m=p?.shift();)this.#p?.(...m)}return this}pop(){try{for(;this.#n;){let e=this.#e[this.#a];if(this.#D(!0),this.#t(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(this.#u&&this.#s){let e=this.#s,r;for(;r=e?.shift();)this.#p?.(...r)}}}#D(e){let r=this.#a,n=this.#r[r],i=this.#e[r];return this.#A&&this.#t(i)?i.__abortController.abort(new Error("evicted")):(this.#b||this.#u)&&(this.#b&&this.#v?.(i,n,"evict"),this.#u&&this.#s?.push([i,n,"evict"])),this.#P(r),e&&(this.#r[r]=void 0,this.#e[r]=void 0,this.#y.push(r)),this.#n===1?(this.#a=this.#o=0,this.#y.length=0):this.#a=this.#d[r],this.#i.delete(n),this.#n--,r}has(e,r={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:i}=r,o=this.#i.get(e);if(o!==void 0){let s=this.#e[o];if(this.#t(s)&&s.__staleWhileFetching===void 0)return!1;if(this.#h(o))i&&(i.has="stale",this.#S(i,o));else return n&&this.#T(o),i&&(i.has="hit",this.#S(i,o)),!0}else i&&(i.has="miss");return!1}peek(e,r={}){let{allowStale:n=this.allowStale}=r,i=this.#i.get(e);if(i!==void 0&&(n||!this.#h(i))){let o=this.#e[i];return this.#t(o)?o.__staleWhileFetching:o}}#B(e,r,n,i){let o=r===void 0?void 0:this.#e[r];if(this.#t(o))return o;let s=new h8,{signal:a}=n;a?.addEventListener("abort",()=>s.abort(a.reason),{signal:s.signal});let d={signal:s.signal,options:n,context:i},u=(v,x=!1)=>{let{aborted:S}=s.signal,P=n.ignoreFetchAbort&&v!==void 0;if(n.status&&(S&&!x?(n.status.fetchAborted=!0,n.status.fetchError=s.signal.reason,P&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),S&&!P&&!x)return l(s.signal.reason);let A=m;return this.#e[r]===m&&(v===void 0?A.__staleWhileFetching?this.#e[r]=A.__staleWhileFetching:this.delete(e):(n.status&&(n.status.fetchUpdated=!0),this.set(e,v,d.options))),v},c=v=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=v),l(v)),l=v=>{let{aborted:x}=s.signal,S=x&&n.allowStaleOnFetchAbort,P=S||n.allowStaleOnFetchRejection,A=P||n.noDeleteOnFetchRejection,$=m;if(this.#e[r]===m&&(!A||$.__staleWhileFetching===void 0?this.delete(e):S||(this.#e[r]=$.__staleWhileFetching)),P)return n.status&&$.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),$.__staleWhileFetching;if($.__returned===$)throw v},p=(v,x)=>{let S=this.#k?.(e,o,d);S&&S instanceof Promise&&S.then(P=>v(P),x),s.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(v(),n.allowStaleOnFetchAbort&&(v=P=>u(P,!0)))})};n.status&&(n.status.fetchDispatched=!0);let m=new Promise(p).then(u,c),g=Object.assign(m,{__abortController:s,__staleWhileFetching:o,__returned:void 0});return r===void 0?(this.set(e,g,{...d.options,status:void 0}),r=this.#i.get(e)):this.#e[r]=g,g}#t(e){if(!this.#A)return!1;let r=e;return!!r&&r instanceof Promise&&r.hasOwnProperty("__staleWhileFetching")&&r.__abortController instanceof h8}async fetch(e,r={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:s=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:d=0,sizeCalculation:u=this.sizeCalculation,noUpdateTTL:c=this.noUpdateTTL,noDeleteOnFetchRejection:l=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:p=this.allowStaleOnFetchRejection,ignoreFetchAbort:m=this.ignoreFetchAbort,allowStaleOnFetchAbort:g=this.allowStaleOnFetchAbort,context:v,forceRefresh:x=!1,status:S,signal:P}=r;if(!this.#A)return S&&(S.fetch="get"),this.get(e,{allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:o,status:S});let A={allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:o,ttl:s,noDisposeOnSet:a,size:d,sizeCalculation:u,noUpdateTTL:c,noDeleteOnFetchRejection:l,allowStaleOnFetchRejection:p,allowStaleOnFetchAbort:g,ignoreFetchAbort:m,status:S,signal:P},$=this.#i.get(e);if($===void 0){S&&(S.fetch="miss");let j=this.#B(e,$,A,v);return j.__returned=j}else{let j=this.#e[$];if(this.#t(j)){let L=n&&j.__staleWhileFetching!==void 0;return S&&(S.fetch="inflight",L&&(S.returnedStale=!0)),L?j.__staleWhileFetching:j.__returned=j}let q=this.#h($);if(!x&&!q)return S&&(S.fetch="hit"),this.#I($),i&&this.#T($),S&&this.#S(S,$),j;let F=this.#B(e,$,A,v),W=F.__staleWhileFetching!==void 0&&n;return S&&(S.fetch=q?"stale":"refresh",W&&q&&(S.returnedStale=!0)),W?F.__staleWhileFetching:F.__returned=F}}get(e,r={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:s}=r,a=this.#i.get(e);if(a!==void 0){let d=this.#e[a],u=this.#t(d);return s&&this.#S(s,a),this.#h(a)?(s&&(s.get="stale"),u?(s&&n&&d.__staleWhileFetching!==void 0&&(s.returnedStale=!0),n?d.__staleWhileFetching:void 0):(o||this.delete(e),s&&n&&(s.returnedStale=!0),n?d:void 0)):(s&&(s.get="hit"),u?d.__staleWhileFetching:(this.#I(a),i&&this.#T(a),d))}else s&&(s.get="miss")}#j(e,r){this.#f[r]=e,this.#d[e]=r}#I(e){e!==this.#o&&(e===this.#a?this.#a=this.#d[e]:this.#j(this.#f[e],this.#d[e]),this.#j(this.#o,e),this.#o=e)}delete(e){let r=!1;if(this.#n!==0){let n=this.#i.get(e);if(n!==void 0)if(r=!0,this.#n===1)this.clear();else{this.#P(n);let i=this.#e[n];this.#t(i)?i.__abortController.abort(new Error("deleted")):(this.#b||this.#u)&&(this.#b&&this.#v?.(i,e,"delete"),this.#u&&this.#s?.push([i,e,"delete"])),this.#i.delete(e),this.#r[n]=void 0,this.#e[n]=void 0,n===this.#o?this.#o=this.#f[n]:n===this.#a?this.#a=this.#d[n]:(this.#d[this.#f[n]]=this.#d[n],this.#f[this.#d[n]]=this.#f[n]),this.#n--,this.#y.push(n)}}if(this.#u&&this.#s?.length){let n=this.#s,i;for(;i=n?.shift();)this.#p?.(...i)}return r}clear(){for(let e of this.#_({allowStale:!0})){let r=this.#e[e];if(this.#t(r))r.__abortController.abort(new Error("deleted"));else{let n=this.#r[e];this.#b&&this.#v?.(r,n,"delete"),this.#u&&this.#s?.push([r,n,"delete"])}}if(this.#i.clear(),this.#e.fill(void 0),this.#r.fill(void 0),this.#g&&this.#E&&(this.#g.fill(0),this.#E.fill(0)),this.#x&&this.#x.fill(0),this.#a=0,this.#o=0,this.#y.length=0,this.#m=0,this.#n=0,this.#u&&this.#s){let e=this.#s,r;for(;r=e?.shift();)this.#p?.(...r)}}};var gV=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},m8=class{constructor(e){this.timeToLiveInSeconds=e,this.cache=new p8({max:1e5,ttl:e*1e3})}set(e,r){return gV(this,void 0,void 0,function*(){try{this.cache.set(e,r)}catch{}})}get(e){return gV(this,void 0,void 0,function*(){return this.cache.get(e)})}};f();var uB={};Pr(uB,{Authorization:()=>zEe,AuthorizationDelegatedGrant:()=>WEe,AuthorizationOwner:()=>GEe,Definitions:()=>t6e,GeneralJwk:()=>r6e,GeneralJws:()=>n6e,GenericSignaturePayload:()=>T6e,JwkVerificationMethod:()=>i6e,MessagesFilter:()=>s6e,MessagesQuery:()=>a6e,MessagesRead:()=>c6e,MessagesSubscribe:()=>d6e,NumberRangeFilter:()=>u6e,PaginationCursor:()=>l6e,PermissionGrantData:()=>f6e,PermissionRequestData:()=>h6e,PermissionRevocationData:()=>p6e,PermissionsDefinitions:()=>m6e,PermissionsScopes:()=>y6e,ProtocolDefinition:()=>g6e,ProtocolRuleSet:()=>w6e,ProtocolsConfigure:()=>_6e,ProtocolsQuery:()=>x6e,PublicJwk:()=>A6e,RecordsDelete:()=>JEe,RecordsFilter:()=>S6e,RecordsQuery:()=>ZEe,RecordsRead:()=>E6e,RecordsSubscribe:()=>YEe,RecordsWrite:()=>XEe,RecordsWriteDataEncoded:()=>QEe,RecordsWriteSignaturePayload:()=>P6e,RecordsWriteUnidentified:()=>e6e,StringRangeFilter:()=>I6e});f();var zEe=Po;var K0=new RegExp("^[A-Za-z0-9_-]+$","u");function nn(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=nn.evaluated;if(d.dynamicProps&&(d.props=void 0),d.dynamicItems&&(d.items=void 0),a===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let p=a;for(let m in t)if(!(m==="payload"||m==="signatures")){return nn.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:m},message:"must NOT have additional properties"}],!1;break}if(p===a){if(t.payload!==void 0){let m=t.payload,g=a;if(a===a)if(typeof m=="string"){if(!K0.test(m))return nn.errors=[{instancePath:e+"/payload",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/base64url/pattern",keyword:"pattern",params:{pattern:"^[A-Za-z0-9_-]+$"},message:'must match pattern "^[A-Za-z0-9_-]+$"'}],!1}else return nn.errors=[{instancePath:e+"/payload",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/base64url/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=g===a}else var u=!0;if(u)if(t.signatures!==void 0){let m=t.signatures,g=a;if(a===g)if(Array.isArray(m)){if(m.length<1)return nn.errors=[{instancePath:e+"/signatures",schemaPath:"#/properties/signatures/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"}],!1;{var c=!0;let x=m.length;for(let S=0;S10)return ze.errors=[{instancePath:e+"/descriptor/tags",schemaPath:"#/properties/descriptor/properties/tags/maxProperties",keyword:"maxProperties",params:{limit:10},message:"must NOT have more than 10 properties"}],!1;if(Object.keys(Re).length<1)return ze.errors=[{instancePath:e+"/descriptor/tags",schemaPath:"#/properties/descriptor/properties/tags/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;for(let Et in Re){let Fe=Re[Et],mt=a,Sn=a,ke=!1,Pe=null,Wt=a;if(typeof Fe!="string"){let Ee={instancePath:e+"/descriptor/tags/"+Et.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/descriptor/properties/tags/additionalProperties/oneOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[Ee]:s.push(Ee),a++}var E=Wt===a;E&&(ke=!0,Pe=0);let Be=a;if(!(typeof Fe=="number"&&isFinite(Fe))){let Ee={instancePath:e+"/descriptor/tags/"+Et.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/descriptor/properties/tags/additionalProperties/oneOf/1/type",keyword:"type",params:{type:"number"},message:"must be number"};s===null?s=[Ee]:s.push(Ee),a++}var E=Be===a;if(E&&ke)ke=!1,Pe=[Pe,1];else{E&&(ke=!0,Pe=1);let Ee=a;if(typeof Fe!="boolean"){let Ve={instancePath:e+"/descriptor/tags/"+Et.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/descriptor/properties/tags/additionalProperties/oneOf/2/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};s===null?s=[Ve]:s.push(Ve),a++}var E=Ee===a;if(E&&ke)ke=!1,Pe=[Pe,2];else{E&&(ke=!0,Pe=2);let Ve=a;if(a===Ve)if(Array.isArray(Fe))if(Fe.length>10){let tn={instancePath:e+"/descriptor/tags/"+Et.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/descriptor/properties/tags/additionalProperties/oneOf/3/maxItems",keyword:"maxItems",params:{limit:10},message:"must NOT have more than 10 items"};s===null?s=[tn]:s.push(tn),a++}else if(Fe.length<1){let tn={instancePath:e+"/descriptor/tags/"+Et.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/descriptor/properties/tags/additionalProperties/oneOf/3/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};s===null?s=[tn]:s.push(tn),a++}else{var _=!0;let tn=Fe.length;for(let Rt=0;Rt10){let Ye={instancePath:e+"/descriptor/tags/"+Et.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/descriptor/properties/tags/additionalProperties/oneOf/4/maxItems",keyword:"maxItems",params:{limit:10},message:"must NOT have more than 10 items"};s===null?s=[Ye]:s.push(Ye),a++}else if(Fe.length<1){let Ye={instancePath:e+"/descriptor/tags/"+Et.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/descriptor/properties/tags/additionalProperties/oneOf/4/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};s===null?s=[Ye]:s.push(Ye),a++}else{var C=!0;let Ye=Fe.length;for(let yd=0;yd=",limit:1},message:"must be >= 1"}],!1}else return fn.errors=[{instancePath:e+"/descriptor/pagination/limit",schemaPath:"#/properties/descriptor/properties/pagination/properties/limit/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var l=W===a}else var l=!0;if(l)if($.cursor!==void 0){let K=$.cursor,W=a;if(a===a)if(K&&typeof K=="object"&&!Array.isArray(K)){if(Object.keys(K).length<1)return fn.errors=[{instancePath:e+"/descriptor/pagination/cursor",schemaPath:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;{let T;if(K.messageCid===void 0&&(T="messageCid")||K.value===void 0&&(T="value"))return fn.errors=[{instancePath:e+"/descriptor/pagination/cursor",schemaPath:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json/required",keyword:"required",params:{missingProperty:T},message:"must have required property '"+T+"'"}],!1;{let B=a;for(let h in K)if(!(h==="messageCid"||h==="value")){return fn.errors=[{instancePath:e+"/descriptor/pagination/cursor",schemaPath:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:h},message:"must NOT have additional properties"}],!1;break}if(B===a){if(K.messageCid!==void 0){let h=a;if(typeof K.messageCid!="string")return fn.errors=[{instancePath:e+"/descriptor/pagination/cursor/messageCid",schemaPath:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json/properties/messageCid/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var p=h===a}else var p=!0;if(p)if(K.value!==void 0){let h=K.value,y=a;if(typeof h!="string"&&!(typeof h=="number"&&isFinite(h)))return fn.errors=[{instancePath:e+"/descriptor/pagination/cursor/value",schemaPath:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json/properties/value/type",keyword:"type",params:{type:dB.properties.value.type},message:"must be string,number"}],!1;var p=y===a}else var p=!0}}}}else return fn.errors=[{instancePath:e+"/descriptor/pagination/cursor",schemaPath:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var l=W===a}else var l=!0}}else return fn.errors=[{instancePath:e+"/descriptor/pagination",schemaPath:"#/properties/descriptor/properties/pagination/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var c=j===a}else var c=!0;if(c)if(v.dateSort!==void 0){let $=v.dateSort,j=a;if(typeof $!="string")return fn.errors=[{instancePath:e+"/descriptor/dateSort",schemaPath:"#/properties/descriptor/properties/dateSort/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(!($==="createdAscending"||$==="createdDescending"||$==="publishedAscending"||$==="publishedDescending"))return fn.errors=[{instancePath:e+"/descriptor/dateSort",schemaPath:"#/properties/descriptor/properties/dateSort/enum",keyword:"enum",params:{allowedValues:aB.properties.descriptor.properties.dateSort.enum},message:"must be equal to one of the allowed values"}],!1;var c=j===a}else var c=!0}}}}}}}else return fn.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var u=x===a}else var u=!0}}}else return fn.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return fn.errors=s,a===0}fn.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var YEe=qs,wV={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://identity.foundation/dwn/json-schemas/records-subscribe.json",type:"object",additionalProperties:!1,required:["descriptor"],properties:{authorization:{$ref:"https://identity.foundation/dwn/json-schemas/authorization-delegated-grant.json"},descriptor:{type:"object",additionalProperties:!1,required:["interface","method","messageTimestamp","filter"],properties:{interface:{enum:["Records"],type:"string"},method:{enum:["Subscribe"],type:"string"},messageTimestamp:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time"},filter:{$ref:"https://identity.foundation/dwn/json-schemas/records-filter.json"}}}}};function qs(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=qs.evaluated;if(d.dynamicProps&&(d.props=void 0),d.dynamicItems&&(d.items=void 0),a===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let l;if(t.descriptor===void 0&&(l="descriptor"))return qs.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:l},message:"must have required property '"+l+"'"}],!1;{let p=a;for(let m in t)if(!(m==="authorization"||m==="descriptor")){return qs.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:m},message:"must NOT have additional properties"}],!1;break}if(p===a){if(t.authorization!==void 0){let m=a;Ii(t.authorization,{instancePath:e+"/authorization",parentData:t,parentDataProperty:"authorization",rootData:i,dynamicAnchors:o})||(s=s===null?Ii.errors:s.concat(Ii.errors),a=s.length);var u=m===a}else var u=!0;if(u)if(t.descriptor!==void 0){let m=t.descriptor,g=a;if(a===g)if(m&&typeof m=="object"&&!Array.isArray(m)){let x;if(m.interface===void 0&&(x="interface")||m.method===void 0&&(x="method")||m.messageTimestamp===void 0&&(x="messageTimestamp")||m.filter===void 0&&(x="filter"))return qs.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/required",keyword:"required",params:{missingProperty:x},message:"must have required property '"+x+"'"}],!1;{let S=a;for(let P in m)if(!(P==="interface"||P==="method"||P==="messageTimestamp"||P==="filter")){return qs.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:P},message:"must NOT have additional properties"}],!1;break}if(S===a){if(m.interface!==void 0){let P=m.interface,A=a;if(typeof P!="string")return qs.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(P!=="Records")return qs.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/enum",keyword:"enum",params:{allowedValues:wV.properties.descriptor.properties.interface.enum},message:"must be equal to one of the allowed values"}],!1;var c=A===a}else var c=!0;if(c){if(m.method!==void 0){let P=m.method,A=a;if(typeof P!="string")return qs.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(P!=="Subscribe")return qs.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/enum",keyword:"enum",params:{allowedValues:wV.properties.descriptor.properties.method.enum},message:"must be equal to one of the allowed values"}],!1;var c=A===a}else var c=!0;if(c){if(m.messageTimestamp!==void 0){let P=m.messageTimestamp,A=a;if(a===a)if(typeof P=="string"){if(!Wi.test(P))return qs.errors=[{instancePath:e+"/descriptor/messageTimestamp",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/pattern",keyword:"pattern",params:{pattern:"^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"},message:'must match pattern "^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"'}],!1}else return qs.errors=[{instancePath:e+"/descriptor/messageTimestamp",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var c=A===a}else var c=!0;if(c)if(m.filter!==void 0){let P=a;Xe(m.filter,{instancePath:e+"/descriptor/filter",parentData:m,parentDataProperty:"filter",rootData:i,dynamicAnchors:o})||(s=s===null?Xe.errors:s.concat(Xe.errors),a=s.length);var c=P===a}else var c=!0}}}}}else return qs.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var u=g===a}else var u=!0}}}else return qs.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return qs.errors=s,a===0}qs.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var XEe=q0;function q0(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=q0.evaluated;if(d.dynamicProps&&(d.props=void 0),d.dynamicItems&&(d.items=void 0),!ze(t,{instancePath:e,parentData:r,parentDataProperty:n,rootData:i,dynamicAnchors:o}))s=s===null?ze.errors:s.concat(ze.errors),a=s.length;else var u=ze.evaluated.props;if(a===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let c;if(t.recordId===void 0&&(c="recordId")||t.authorization===void 0&&(c="authorization"))return q0.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:c},message:"must have required property '"+c+"'"}],!1;if(u!==!0){for(let l in t)if(!u||!u[l]){return q0.errors=[{instancePath:e,schemaPath:"#/unevaluatedProperties",keyword:"unevaluatedProperties",params:{unevaluatedProperty:l},message:"must NOT have unevaluated properties"}],!1;break}}}else return q0.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return q0.errors=s,a===0}q0.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var QEe=wd,e6e=ze,t6e=cx;function cx(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=cx.evaluated;return d.dynamicProps&&(d.props=void 0),d.dynamicItems&&(d.items=void 0),t&&typeof t=="object"&&!Array.isArray(t)?(cx.errors=s,a===0):(cx.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1)}cx.evaluated={dynamicProps:!1,dynamicItems:!1};var r6e=ts;function ts(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=ts.evaluated;d.dynamicProps&&(d.props=void 0),d.dynamicItems&&(d.items=void 0);let u=a,c=!1,l=null,p=a;if(t&&typeof t=="object"&&!Array.isArray(t)){let j;if(t.crv===void 0&&(j="crv")||t.x===void 0&&(j="x")){let q={instancePath:e,schemaPath:"#/oneOf/0/required",keyword:"required",params:{missingProperty:j},message:"must have required property '"+j+"'"};s===null?s=[q]:s.push(q),a++}else{if(t.kty!==void 0){let q=a;if(t.kty!=="EC"){let F={instancePath:e+"/kty",schemaPath:"#/oneOf/0/properties/kty/const",keyword:"const",params:{allowedValue:"EC"},message:"must be equal to constant"};s===null?s=[F]:s.push(F),a++}var m=q===a}else var m=!0;if(m){if(t.crv!==void 0){let q=a;if(typeof t.crv!="string"){let K={instancePath:e+"/crv",schemaPath:"#/oneOf/0/properties/crv/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[K]:s.push(K),a++}var m=q===a}else var m=!0;if(m){if(t.x!==void 0){let q=a;if(typeof t.x!="string"){let K={instancePath:e+"/x",schemaPath:"#/oneOf/0/properties/x/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[K]:s.push(K),a++}var m=q===a}else var m=!0;if(m){if(t.y!==void 0){let q=a;if(typeof t.y!="string"){let K={instancePath:e+"/y",schemaPath:"#/oneOf/0/properties/y/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[K]:s.push(K),a++}var m=q===a}else var m=!0;if(m)if(t.d!==void 0){let q=a;if(typeof t.d!="string"){let K={instancePath:e+"/d",schemaPath:"#/oneOf/0/properties/d/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[K]:s.push(K),a++}var m=q===a}else var m=!0}}}}}var S=p===a;if(S){c=!0,l=0;var g={};g.kty=!0,g.crv=!0,g.x=!0,g.y=!0,g.d=!0}let v=a;if(t&&typeof t=="object"&&!Array.isArray(t)){let j;if(t.crv===void 0&&(j="crv")||t.x===void 0&&(j="x")){let q={instancePath:e,schemaPath:"#/oneOf/1/required",keyword:"required",params:{missingProperty:j},message:"must have required property '"+j+"'"};s===null?s=[q]:s.push(q),a++}else{if(t.kty!==void 0){let q=a;if(t.kty!=="OKP"){let F={instancePath:e+"/kty",schemaPath:"#/oneOf/1/properties/kty/const",keyword:"const",params:{allowedValue:"OKP"},message:"must be equal to constant"};s===null?s=[F]:s.push(F),a++}var x=q===a}else var x=!0;if(x){if(t.crv!==void 0){let q=a;if(typeof t.crv!="string"){let K={instancePath:e+"/crv",schemaPath:"#/oneOf/1/properties/crv/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[K]:s.push(K),a++}var x=q===a}else var x=!0;if(x){if(t.x!==void 0){let q=a;if(typeof t.x!="string"){let K={instancePath:e+"/x",schemaPath:"#/oneOf/1/properties/x/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[K]:s.push(K),a++}var x=q===a}else var x=!0;if(x)if(t.d!==void 0){let q=a;if(typeof t.d!="string"){let K={instancePath:e+"/d",schemaPath:"#/oneOf/1/properties/d/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[K]:s.push(K),a++}var x=q===a}else var x=!0}}}}var S=v===a;if(S&&c)c=!1,l=[l,1];else{S&&(c=!0,l=1,g!==!0&&(g=g||{},g.kty=!0,g.crv=!0,g.x=!0,g.d=!0));let j=a;if(t&&typeof t=="object"&&!Array.isArray(t)){let F;if(t.n===void 0&&(F="n")||t.e===void 0&&(F="e")){let K={instancePath:e,schemaPath:"#/oneOf/2/required",keyword:"required",params:{missingProperty:F},message:"must have required property '"+F+"'"};s===null?s=[K]:s.push(K),a++}else{if(t.kty!==void 0){let K=a;if(t.kty!=="RSA"){let W={instancePath:e+"/kty",schemaPath:"#/oneOf/2/properties/kty/const",keyword:"const",params:{allowedValue:"RSA"},message:"must be equal to constant"};s===null?s=[W]:s.push(W),a++}var P=K===a}else var P=!0;if(P){if(t.n!==void 0){let K=a;if(typeof t.n!="string"){let L={instancePath:e+"/n",schemaPath:"#/oneOf/2/properties/n/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[L]:s.push(L),a++}var P=K===a}else var P=!0;if(P){if(t.e!==void 0){let K=a;if(typeof t.e!="string"){let L={instancePath:e+"/e",schemaPath:"#/oneOf/2/properties/e/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[L]:s.push(L),a++}var P=K===a}else var P=!0;if(P){if(t.d!==void 0){let K=a;if(typeof t.d!="string"){let L={instancePath:e+"/d",schemaPath:"#/oneOf/2/properties/d/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[L]:s.push(L),a++}var P=K===a}else var P=!0;if(P){if(t.p!==void 0){let K=a;if(typeof t.p!="string"){let L={instancePath:e+"/p",schemaPath:"#/oneOf/2/properties/p/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[L]:s.push(L),a++}var P=K===a}else var P=!0;if(P){if(t.q!==void 0){let K=a;if(typeof t.q!="string"){let L={instancePath:e+"/q",schemaPath:"#/oneOf/2/properties/q/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[L]:s.push(L),a++}var P=K===a}else var P=!0;if(P){if(t.dp!==void 0){let K=a;if(typeof t.dp!="string"){let L={instancePath:e+"/dp",schemaPath:"#/oneOf/2/properties/dp/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[L]:s.push(L),a++}var P=K===a}else var P=!0;if(P){if(t.dq!==void 0){let K=a;if(typeof t.dq!="string"){let L={instancePath:e+"/dq",schemaPath:"#/oneOf/2/properties/dq/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[L]:s.push(L),a++}var P=K===a}else var P=!0;if(P){if(t.qi!==void 0){let K=a;if(typeof t.qi!="string"){let L={instancePath:e+"/qi",schemaPath:"#/oneOf/2/properties/qi/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[L]:s.push(L),a++}var P=K===a}else var P=!0;if(P)if(t.oth!==void 0){let K=t.oth,W=a;if(!(K&&typeof K=="object"&&!Array.isArray(K))){let I={instancePath:e+"/oth",schemaPath:"#/oneOf/2/properties/oth/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[I]:s.push(I),a++}var P=W===a}else var P=!0}}}}}}}}}}var S=j===a;if(S&&c)c=!1,l=[l,2];else{S&&(c=!0,l=2,g!==!0&&(g=g||{},g.kty=!0,g.n=!0,g.e=!0,g.d=!0,g.p=!0,g.q=!0,g.dp=!0,g.dq=!0,g.qi=!0,g.oth=!0));let F=a;if(t&&typeof t=="object"&&!Array.isArray(t)){let W;if(t.k===void 0&&(W="k")){let L={instancePath:e,schemaPath:"#/oneOf/3/required",keyword:"required",params:{missingProperty:W},message:"must have required property '"+W+"'"};s===null?s=[L]:s.push(L),a++}else{if(t.kty!==void 0){let L=a;if(t.kty!=="oct"){let I={instancePath:e+"/kty",schemaPath:"#/oneOf/3/properties/kty/const",keyword:"const",params:{allowedValue:"oct"},message:"must be equal to constant"};s===null?s=[I]:s.push(I),a++}var A=L===a}else var A=!0;if(A)if(t.k!==void 0){let L=a;if(typeof t.k!="string"){let T={instancePath:e+"/k",schemaPath:"#/oneOf/3/properties/k/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[T]:s.push(T),a++}var A=L===a}else var A=!0}}var S=F===a;S&&c?(c=!1,l=[l,3]):S&&(c=!0,l=3,g!==!0&&(g=g||{},g.kty=!0,g.k=!0))}}if(c)a=u,s!==null&&(u?s.length=u:s=null);else{let j={instancePath:e,schemaPath:"#/oneOf",keyword:"oneOf",params:{passingSchemas:l},message:"must match exactly one schema in oneOf"};return s===null?s=[j]:s.push(j),a++,ts.errors=s,!1}if(a===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let j;if(t.kty===void 0&&(j="kty"))return ts.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:j},message:"must have required property '"+j+"'"}],!1;if(g!==!0&&(g=g||{},g.alg=!0,g.kid=!0,g.kty=!0,g.crv=!0,g.use=!0,g.key_ops=!0,g.x5u=!0,g.x5c=!0,g.x5t=!0,g["x5t#S256"]=!0),t.alg!==void 0){let q=a;if(typeof t.alg!="string")return ts.errors=[{instancePath:e+"/alg",schemaPath:"#/properties/alg/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var $=q===a}else var $=!0;if($){if(t.kid!==void 0){let q=a;if(typeof t.kid!="string")return ts.errors=[{instancePath:e+"/kid",schemaPath:"#/properties/kid/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var $=q===a}else var $=!0;if($){if(t.kty!==void 0){let q=t.kty,F=a;if(!(q==="EC"||q==="RSA"||q==="oct"||q==="OKP"))return ts.errors=[{instancePath:e+"/kty",schemaPath:"#/properties/kty/enum",keyword:"enum",params:{allowedValues:DV.properties.kty.enum},message:"must be equal to one of the allowed values"}],!1;var $=F===a}else var $=!0;if($){if(t.crv!==void 0){let q=a;if(typeof t.crv!="string")return ts.errors=[{instancePath:e+"/crv",schemaPath:"#/properties/crv/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var $=q===a}else var $=!0;if($){if(t.use!==void 0){let q=a;if(typeof t.use!="string")return ts.errors=[{instancePath:e+"/use",schemaPath:"#/properties/use/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var $=q===a}else var $=!0;if($){if(t.key_ops!==void 0){let q=a;if(typeof t.key_ops!="string")return ts.errors=[{instancePath:e+"/key_ops",schemaPath:"#/properties/key_ops/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var $=q===a}else var $=!0;if($){if(t.x5u!==void 0){let q=a;if(typeof t.x5u!="string")return ts.errors=[{instancePath:e+"/x5u",schemaPath:"#/properties/x5u/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var $=q===a}else var $=!0;if($){if(t.x5c!==void 0){let q=a;if(typeof t.x5c!="string")return ts.errors=[{instancePath:e+"/x5c",schemaPath:"#/properties/x5c/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var $=q===a}else var $=!0;if($){if(t.x5t!==void 0){let q=a;if(typeof t.x5t!="string")return ts.errors=[{instancePath:e+"/x5t",schemaPath:"#/properties/x5t/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var $=q===a}else var $=!0;if($)if(t["x5t#S256"]!==void 0){let q=a;if(typeof t["x5t#S256"]!="string")return ts.errors=[{instancePath:e+"/x5t#S256",schemaPath:"#/properties/x5t%23S256/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var $=q===a}else var $=!0}}}}}}}}}else return ts.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return ts.errors=s,d.props=g,a===0}ts.evaluated={dynamicProps:!0,dynamicItems:!1};var n6e=nn,i6e=gu,o6e={$id:"https://identity.foundation/dwn/json-schemas/jwk-verification-method.json",$schema:"https://json-schema.org/draft/2020-12/schema",type:"object",additionalProperties:!1,required:["id","type","controller","publicKeyJwk"],properties:{id:{type:"string"},type:{enum:["JsonWebKey","JsonWebKey2020"]},controller:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did"},publicKeyJwk:{$ref:"https://identity.foundation/dwn/json-schemas/public-jwk.json"}}};function gu(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=gu.evaluated;if(d.dynamicProps&&(d.props=void 0),d.dynamicItems&&(d.items=void 0),a===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let c;if(t.id===void 0&&(c="id")||t.type===void 0&&(c="type")||t.controller===void 0&&(c="controller")||t.publicKeyJwk===void 0&&(c="publicKeyJwk"))return gu.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:c},message:"must have required property '"+c+"'"}],!1;{let l=a;for(let p in t)if(!(p==="id"||p==="type"||p==="controller"||p==="publicKeyJwk")){return gu.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:p},message:"must NOT have additional properties"}],!1;break}if(l===a){if(t.id!==void 0){let p=a;if(typeof t.id!="string")return gu.errors=[{instancePath:e+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=p===a}else var u=!0;if(u){if(t.type!==void 0){let p=t.type,m=a;if(!(p==="JsonWebKey"||p==="JsonWebKey2020"))return gu.errors=[{instancePath:e+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:o6e.properties.type.enum},message:"must be equal to one of the allowed values"}],!1;var u=m===a}else var u=!0;if(u){if(t.controller!==void 0){let p=t.controller,m=a;if(a===a)if(typeof p=="string"){if(!im.test(p))return gu.errors=[{instancePath:e+"/controller",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did/pattern",keyword:"pattern",params:{pattern:"^did:([a-z0-9]+):((?:(?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))*:)*((?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))+))((;[a-zA-Z0-9_.:%-]+=[a-zA-Z0-9_.:%-]*)*)(/[^#?]*)?([?][^#]*)?(#.*)?$"},message:'must match pattern "^did:([a-z0-9]+):((?:(?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))*:)*((?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))+))((;[a-zA-Z0-9_.:%-]+=[a-zA-Z0-9_.:%-]*)*)(/[^#?]*)?([?][^#]*)?(#.*)?$"'}],!1}else return gu.errors=[{instancePath:e+"/controller",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=m===a}else var u=!0;if(u)if(t.publicKeyJwk!==void 0){let p=a;rn(t.publicKeyJwk,{instancePath:e+"/publicKeyJwk",parentData:t,parentDataProperty:"publicKeyJwk",rootData:i,dynamicAnchors:o})||(s=s===null?rn.errors:s.concat(rn.errors),a=s.length);var u=p===a}else var u=!0}}}}}else return gu.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return gu.errors=s,a===0}gu.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var s6e=qn,_V={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://identity.foundation/dwn/json-schemas/messages-filter.json",type:"object",additionalProperties:!1,minProperties:1,properties:{interface:{enum:["Protocols","Records"],type:"string"},method:{enum:["Configure","Delete","Write"],type:"string"},protocol:{type:"string"},messageTimestamp:{type:"object",minProperties:1,additionalProperties:!1,properties:{from:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time"},to:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time"}}}}};function qn(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=qn.evaluated;if(d.dynamicProps&&(d.props=void 0),d.dynamicItems&&(d.items=void 0),a===0)if(t&&typeof t=="object"&&!Array.isArray(t)){if(Object.keys(t).length<1)return qn.errors=[{instancePath:e,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;{let l=a;for(let p in t)if(!(p==="interface"||p==="method"||p==="protocol"||p==="messageTimestamp")){return qn.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:p},message:"must NOT have additional properties"}],!1;break}if(l===a){if(t.interface!==void 0){let p=t.interface,m=a;if(typeof p!="string")return qn.errors=[{instancePath:e+"/interface",schemaPath:"#/properties/interface/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(!(p==="Protocols"||p==="Records"))return qn.errors=[{instancePath:e+"/interface",schemaPath:"#/properties/interface/enum",keyword:"enum",params:{allowedValues:_V.properties.interface.enum},message:"must be equal to one of the allowed values"}],!1;var u=m===a}else var u=!0;if(u){if(t.method!==void 0){let p=t.method,m=a;if(typeof p!="string")return qn.errors=[{instancePath:e+"/method",schemaPath:"#/properties/method/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(!(p==="Configure"||p==="Delete"||p==="Write"))return qn.errors=[{instancePath:e+"/method",schemaPath:"#/properties/method/enum",keyword:"enum",params:{allowedValues:_V.properties.method.enum},message:"must be equal to one of the allowed values"}],!1;var u=m===a}else var u=!0;if(u){if(t.protocol!==void 0){let p=a;if(typeof t.protocol!="string")return qn.errors=[{instancePath:e+"/protocol",schemaPath:"#/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=p===a}else var u=!0;if(u)if(t.messageTimestamp!==void 0){let p=t.messageTimestamp,m=a;if(a===m)if(p&&typeof p=="object"&&!Array.isArray(p)){if(Object.keys(p).length<1)return qn.errors=[{instancePath:e+"/messageTimestamp",schemaPath:"#/properties/messageTimestamp/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;{let v=a;for(let x in p)if(!(x==="from"||x==="to")){return qn.errors=[{instancePath:e+"/messageTimestamp",schemaPath:"#/properties/messageTimestamp/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:x},message:"must NOT have additional properties"}],!1;break}if(v===a){if(p.from!==void 0){let x=p.from,S=a;if(a===a)if(typeof x=="string"){if(!Wi.test(x))return qn.errors=[{instancePath:e+"/messageTimestamp/from",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/pattern",keyword:"pattern",params:{pattern:"^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"},message:'must match pattern "^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"'}],!1}else return qn.errors=[{instancePath:e+"/messageTimestamp/from",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var c=S===a}else var c=!0;if(c)if(p.to!==void 0){let x=p.to,S=a;if(a===a)if(typeof x=="string"){if(!Wi.test(x))return qn.errors=[{instancePath:e+"/messageTimestamp/to",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/pattern",keyword:"pattern",params:{pattern:"^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"},message:'must match pattern "^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"'}],!1}else return qn.errors=[{instancePath:e+"/messageTimestamp/to",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var c=S===a}else var c=!0}}}else return qn.errors=[{instancePath:e+"/messageTimestamp",schemaPath:"#/properties/messageTimestamp/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var u=m===a}else var u=!0}}}}}else return qn.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return qn.errors=s,a===0}qn.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var a6e=ti,xV={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://identity.foundation/dwn/json-schemas/messages-query.json",type:"object",additionalProperties:!1,required:["authorization","descriptor"],properties:{authorization:{$ref:"https://identity.foundation/dwn/json-schemas/authorization.json"},descriptor:{type:"object",additionalProperties:!1,required:["interface","method","messageTimestamp","filters"],properties:{interface:{enum:["Messages"],type:"string"},method:{enum:["Query"],type:"string"},messageTimestamp:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time"},filters:{type:"array",items:{$ref:"https://identity.foundation/dwn/json-schemas/messages-filter.json"}},cursor:{$ref:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json"}}}}};function ti(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=ti.evaluated;if(d.dynamicProps&&(d.props=void 0),d.dynamicItems&&(d.items=void 0),a===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let m;if(t.authorization===void 0&&(m="authorization")||t.descriptor===void 0&&(m="descriptor"))return ti.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:m},message:"must have required property '"+m+"'"}],!1;{let g=a;for(let v in t)if(!(v==="authorization"||v==="descriptor")){return ti.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:v},message:"must NOT have additional properties"}],!1;break}if(g===a){if(t.authorization!==void 0){let v=a;Po(t.authorization,{instancePath:e+"/authorization",parentData:t,parentDataProperty:"authorization",rootData:i,dynamicAnchors:o})||(s=s===null?Po.errors:s.concat(Po.errors),a=s.length);var u=v===a}else var u=!0;if(u)if(t.descriptor!==void 0){let v=t.descriptor,x=a;if(a===x)if(v&&typeof v=="object"&&!Array.isArray(v)){let P;if(v.interface===void 0&&(P="interface")||v.method===void 0&&(P="method")||v.messageTimestamp===void 0&&(P="messageTimestamp")||v.filters===void 0&&(P="filters"))return ti.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/required",keyword:"required",params:{missingProperty:P},message:"must have required property '"+P+"'"}],!1;{let A=a;for(let $ in v)if(!($==="interface"||$==="method"||$==="messageTimestamp"||$==="filters"||$==="cursor")){return ti.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:$},message:"must NOT have additional properties"}],!1;break}if(A===a){if(v.interface!==void 0){let $=v.interface,j=a;if(typeof $!="string")return ti.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if($!=="Messages")return ti.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/enum",keyword:"enum",params:{allowedValues:xV.properties.descriptor.properties.interface.enum},message:"must be equal to one of the allowed values"}],!1;var c=j===a}else var c=!0;if(c){if(v.method!==void 0){let $=v.method,j=a;if(typeof $!="string")return ti.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if($!=="Query")return ti.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/enum",keyword:"enum",params:{allowedValues:xV.properties.descriptor.properties.method.enum},message:"must be equal to one of the allowed values"}],!1;var c=j===a}else var c=!0;if(c){if(v.messageTimestamp!==void 0){let $=v.messageTimestamp,j=a;if(a===a)if(typeof $=="string"){if(!Wi.test($))return ti.errors=[{instancePath:e+"/descriptor/messageTimestamp",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/pattern",keyword:"pattern",params:{pattern:"^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"},message:'must match pattern "^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"'}],!1}else return ti.errors=[{instancePath:e+"/descriptor/messageTimestamp",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var c=j===a}else var c=!0;if(c){if(v.filters!==void 0){let $=v.filters,j=a;if(a===j)if(Array.isArray($)){var l=!0;let F=$.length;for(let K=0;K=",limit:0},message:"must be >= 0"}],!1}else return Ir.errors=[{instancePath:e+"/$size/min",schemaPath:"#/properties/%24size/properties/min/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var P=_===a}else var P=!0;if(P)if(B.max!==void 0){let E=B.max,_=a;if(a===_)if(typeof E=="number"&&isFinite(E)){if(E<0||isNaN(E))return Ir.errors=[{instancePath:e+"/$size/max",schemaPath:"#/properties/%24size/properties/max/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"}],!1}else return Ir.errors=[{instancePath:e+"/$size/max",schemaPath:"#/properties/%24size/properties/max/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var P=_===a}else var P=!0}}else return Ir.errors=[{instancePath:e+"/$size",schemaPath:"#/properties/%24size/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var c=h===a}else var c=!0;if(c){if(t.$tags!==void 0){let B=t.$tags,h=a;if(a===h)if(B&&typeof B=="object"&&!Array.isArray(B)){if(Object.keys(B).length<1)return Ir.errors=[{instancePath:e+"/$tags",schemaPath:"#/properties/%24tags/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;if(B.$requiredTags!==void 0){let w=B.$requiredTags,E=a;if(a===E)if(Array.isArray(w)){var A=!0;let _=w.length;for(let b=0;b<_;b++){let C=a;if(typeof w[b]!="string")return Ir.errors=[{instancePath:e+"/$tags/$requiredTags/"+b,schemaPath:"#/properties/%24tags/properties/%24requiredTags/items/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var A=C===a;if(!A)break}}else return Ir.errors=[{instancePath:e+"/$tags/$requiredTags",schemaPath:"#/properties/%24tags/properties/%24requiredTags/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;var $=E===a}else var $=!0;if($){if(B.$allowUndefinedTags!==void 0){let w=a;if(typeof B.$allowUndefinedTags!="boolean")return Ir.errors=[{instancePath:e+"/$tags/$allowUndefinedTags",schemaPath:"#/properties/%24tags/properties/%24allowUndefinedTags/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;var $=w===a}else var $=!0;if($){var j={};j.$requiredTags=!0,j.$allowUndefinedTags=!0;for(let w in B)if(v6e.test(w)){let E=B[w];if(a===a)if(E&&typeof E=="object"&&!Array.isArray(E)){let b=a;for(let C in E)if(!(C==="type"||C==="items"||C==="contains"||b6e.test(C))){return Ir.errors=[{instancePath:e+"/$tags/"+w.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/%24tags/patternProperties/%5E(%3F!%5C%24requiredTags%24%7C%5C%24allowUndefinedTags%24).*%24/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:C},message:"must NOT have additional properties"}],!1;break}if(b===a){if(E.type!==void 0){let C=E.type,N=a;if(!(C==="string"||C==="number"||C==="integer"||C==="boolean"||C==="array"))return Ir.errors=[{instancePath:e+"/$tags/"+w.replace(/~/g,"~0").replace(/\//g,"~1")+"/type",schemaPath:"#/properties/%24tags/patternProperties/%5E(%3F!%5C%24requiredTags%24%7C%5C%24allowUndefinedTags%24).*%24/properties/type/enum",keyword:"enum",params:{allowedValues:aw.properties.$tags.patternProperties["^(?!\\$requiredTags$|\\$allowUndefinedTags$).*$"].properties.type.enum},message:"must be equal to one of the allowed values"}],!1;var q=N===a}else var q=!0;if(q){if(E.items!==void 0){let C=E.items,N=a;if(a===N)if(C&&typeof C=="object"&&!Array.isArray(C)){if(C.type!==void 0){let U=C.type,G=a;if(!(U==="string"||U==="number"||U==="integer"))return Ir.errors=[{instancePath:e+"/$tags/"+w.replace(/~/g,"~0").replace(/\//g,"~1")+"/items/type",schemaPath:"#/properties/%24tags/patternProperties/%5E(%3F!%5C%24requiredTags%24%7C%5C%24allowUndefinedTags%24).*%24/properties/items/properties/type/enum",keyword:"enum",params:{allowedValues:aw.properties.$tags.patternProperties["^(?!\\$requiredTags$|\\$allowUndefinedTags$).*$"].properties.items.properties.type.enum},message:"must be equal to one of the allowed values"}],!1;var F=G===a}else var F=!0;if(F){var K={};K.type=!0;for(let U in C)PV.test(U)&&(K[U]=!0)}}else return Ir.errors=[{instancePath:e+"/$tags/"+w.replace(/~/g,"~0").replace(/\//g,"~1")+"/items",schemaPath:"#/properties/%24tags/patternProperties/%5E(%3F!%5C%24requiredTags%24%7C%5C%24allowUndefinedTags%24).*%24/properties/items/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var q=N===a}else var q=!0;if(q)if(E.contains!==void 0){let C=E.contains,N=a;if(a===N)if(C&&typeof C=="object"&&!Array.isArray(C)){if(C.type!==void 0){let U=C.type,G=a;if(!(U==="string"||U==="number"||U==="integer"))return Ir.errors=[{instancePath:e+"/$tags/"+w.replace(/~/g,"~0").replace(/\//g,"~1")+"/contains/type",schemaPath:"#/properties/%24tags/patternProperties/%5E(%3F!%5C%24requiredTags%24%7C%5C%24allowUndefinedTags%24).*%24/properties/contains/properties/type/enum",keyword:"enum",params:{allowedValues:aw.properties.$tags.patternProperties["^(?!\\$requiredTags$|\\$allowUndefinedTags$).*$"].properties.contains.properties.type.enum},message:"must be equal to one of the allowed values"}],!1;var W=G===a}else var W=!0;if(W){var L={};L.type=!0;for(let U in C)PV.test(U)&&(L[U]=!0)}}else return Ir.errors=[{instancePath:e+"/$tags/"+w.replace(/~/g,"~0").replace(/\//g,"~1")+"/contains",schemaPath:"#/properties/%24tags/patternProperties/%5E(%3F!%5C%24requiredTags%24%7C%5C%24allowUndefinedTags%24).*%24/properties/contains/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var q=N===a}else var q=!0}}}else return Ir.errors=[{instancePath:e+"/$tags/"+w.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/%24tags/patternProperties/%5E(%3F!%5C%24requiredTags%24%7C%5C%24allowUndefinedTags%24).*%24/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;j[w]=!0}}}}else return Ir.errors=[{instancePath:e+"/$tags",schemaPath:"#/properties/%24tags/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var c=h===a}else var c=!0;if(c){var I=!0;for(let B in t)if(TV.test(B)){let h=a;cB.validate(t[B],{instancePath:e+"/"+B.replace(/~/g,"~0").replace(/\//g,"~1"),parentData:t,parentDataProperty:B,rootData:i,dynamicAnchors:o})||(s=s===null?cB.validate.errors:s.concat(cB.validate.errors),a=s.length);var I=h===a;if(!I)break}}}}}}}}else return Ir.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return Ir.errors=s,a===0}Ir.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};function zi(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:o={}}={}){let s=null,a=0,d=zi.evaluated;if(d.dynamicProps&&(d.props=void 0),d.dynamicItems&&(d.items=void 0),a===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let g;if(t.protocol===void 0&&(g="protocol")||t.published===void 0&&(g="published")||t.types===void 0&&(g="types")||t.structure===void 0&&(g="structure"))return zi.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:g},message:"must have required property '"+g+"'"}],!1;{let v=a;for(let x in t)if(!(x==="protocol"||x==="published"||x==="types"||x==="structure")){return zi.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:x},message:"must NOT have additional properties"}],!1;break}if(v===a){if(t.protocol!==void 0){let x=a;if(typeof t.protocol!="string")return zi.errors=[{instancePath:e+"/protocol",schemaPath:"#/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=x===a}else var u=!0;if(u){if(t.published!==void 0){let x=a;if(typeof t.published!="boolean")return zi.errors=[{instancePath:e+"/published",schemaPath:"#/properties/published/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;var u=x===a}else var u=!0;if(u){if(t.types!==void 0){let x=t.types,S=a;if(a===S)if(x&&typeof x=="object"&&!Array.isArray(x)){var c={};for(let A in x)if(AV.test(A)){let $=x[A];if(a===a)if($&&typeof $=="object"&&!Array.isArray($)){let q=a;for(let F in $)if(!(F==="schema"||F==="dataFormats")){return zi.errors=[{instancePath:e+"/types/"+A.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/types/patternProperties/.*/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:F},message:"must NOT have additional properties"}],!1;break}if(q===a){if($.schema!==void 0){let F=a;if(typeof $.schema!="string")return zi.errors=[{instancePath:e+"/types/"+A.replace(/~/g,"~0").replace(/\//g,"~1")+"/schema",schemaPath:"#/properties/types/patternProperties/.*/properties/schema/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var l=F===a}else var l=!0;if(l)if($.dataFormats!==void 0){let F=$.dataFormats,K=a;if(a===K)if(Array.isArray(F)){if(F.length<1)return zi.errors=[{instancePath:e+"/types/"+A.replace(/~/g,"~0").replace(/\//g,"~1")+"/dataFormats",schemaPath:"#/properties/types/patternProperties/.*/properties/dataFormats/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"}],!1;{var p=!0;let L=F.length;for(let I=0;I_x,decode:()=>JSe,encode:()=>GSe,name:()=>VSe});f();f();f();f();var k6e=["string","number","bigint","symbol"],R6e=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function OV(t){if(t===null)return"null";if(t===void 0)return"undefined";if(t===!0||t===!1)return"boolean";let e=typeof t;if(k6e.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(t))return"Array";if(D6e(t))return"Buffer";let r=B6e(t);return r||"Object"}function D6e(t){return t&&t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer.call(null,t)}function B6e(t){let e=Object.prototype.toString.call(t).slice(8,-1);if(R6e.includes(e))return e}f();var ve=class{constructor(e,r,n){this.major=e,this.majorEncoded=e<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.majore.major?1:0}};ve.uint=new ve(0,"uint",!0);ve.negint=new ve(1,"negint",!0);ve.bytes=new ve(2,"bytes",!0);ve.string=new ve(3,"string",!0);ve.array=new ve(4,"array",!1);ve.map=new ve(5,"map",!1);ve.tag=new ve(6,"tag",!1);ve.float=new ve(7,"float",!0);ve.false=new ve(7,"false",!0);ve.true=new ve(7,"true",!0);ve.null=new ve(7,"null",!0);ve.undefined=new ve(7,"undefined",!0);ve.break=new ve(7,"break",!0);var We=class{constructor(e,r,n){this.type=e,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};f();f();var cw=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",M6e=new TextDecoder,O6e=new TextEncoder;function y8(t){return cw&&globalThis.Buffer.isBuffer(t)}function fB(t){return t instanceof Uint8Array?y8(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t:Uint8Array.from(t)}var NV=cw?(t,e,r)=>r-e>64?globalThis.Buffer.from(t.subarray(e,r)).toString("utf8"):$V(t,e,r):(t,e,r)=>r-e>64?M6e.decode(t.subarray(e,r)):$V(t,e,r),UV=cw?t=>t.length>64?globalThis.Buffer.from(t):CV(t):t=>t.length>64?O6e.encode(t):CV(t),Il=t=>Uint8Array.from(t),dw=cw?(t,e,r)=>y8(t)?new Uint8Array(t.subarray(e,r)):t.slice(e,r):(t,e,r)=>t.slice(e,r),qV=cw?(t,e)=>(t=t.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),fB(globalThis.Buffer.concat(t,e))):(t,e)=>{let r=new Uint8Array(e),n=0;for(let i of t)n+i.length>r.length&&(i=i.subarray(0,r.length-n)),r.set(i,n),n+=i.length;return r},LV=cw?t=>globalThis.Buffer.allocUnsafe(t):t=>new Uint8Array(t);function KV(t,e){if(y8(t)&&y8(e))return t.compare(e);for(let r=0;r55295&&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 $V(t,e,r){let n=[];for(;e239?4:i>223?3:i>191?2:1;if(e+s<=r){let a,d,u,c;switch(s){case 1:i<128&&(o=i);break;case 2:a=t[e+1],(a&192)===128&&(c=(i&31)<<6|a&63,c>127&&(o=c));break;case 3:a=t[e+1],d=t[e+2],(a&192)===128&&(d&192)===128&&(c=(i&15)<<12|(a&63)<<6|d&63,c>2047&&(c<55296||c>57343)&&(o=c));break;case 4:a=t[e+1],d=t[e+2],u=t[e+3],(a&192)===128&&(d&192)===128&&(u&192)===128&&(c=(i&15)<<18|(a&63)<<12|(d&63)<<6|u&63,c>65535&&c<1114112&&(o=c))}}o===null?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),e+=s}return C6e(n)}var jV=4096;function C6e(t){let e=t.length;if(e<=jV)return String.fromCharCode.apply(String,t);let r="",n=0;for(;nn.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=dw(n,0,this.cursor)}else r=qV(this.chunks,this.cursor);return e&&this.reset(),r}};f();var Kt="CBOR decode error:",hB="CBOR encode error:",fx=[];fx[23]=1;fx[24]=2;fx[25]=3;fx[26]=5;fx[27]=9;function oh(t,e,r){if(t.length-e>>8,n&255])}else if(r>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n>BigInt(32)&BigInt(4294967295));i[8]=o&255,o=o>>8,i[7]=o&255,o=o>>8,i[6]=o&255,o=o>>8,i[5]=o&255,i[4]=s&255,s=s>>8,i[3]=s&255,s=s>>8,i[2]=s&255,s=s>>8,i[1]=s&255,t.push(i)}else throw new Error(`${Kt} encountered BigInt larger than allowable range`)}}_d.encodedSize=function(e){return ns.encodedSize(e.value)};ns.encodedSize=function(e){return er.value?1:0};f();function VV(t,e,r,n){return new We(ve.negint,-1-Rc(t,e+1,n),2)}function GV(t,e,r,n){return new We(ve.negint,-1-Dc(t,e+1,n),3)}function JV(t,e,r,n){return new We(ve.negint,-1-Bc(t,e+1,n),5)}var pB=BigInt(-1),ZV=BigInt(1);function YV(t,e,r,n){let i=Mc(t,e+1,n);if(typeof i!="bigint"){let o=-1-i;if(o>=Number.MIN_SAFE_INTEGER)return new We(ve.negint,o,9)}if(n.allowBigInt!==!0)throw new Error(`${Kt} integers outside of the safe integer range are not supported`);return new We(ve.negint,pB-BigInt(i),9)}function g8(t,e){let r=e.value,n=typeof r=="bigint"?r*pB-ZV:r*-1-1;ns(t,e.type.majorEncoded,n)}g8.encodedSize=function(e){let r=e.value,n=typeof r=="bigint"?r*pB-ZV:r*-1-1;return nr.value?-1:0};f();function hx(t,e,r,n){oh(t,e,r+n);let i=dw(t,e+r,e+r+n);return new We(ve.bytes,i,r+n)}function XV(t,e,r,n){return hx(t,e,1,r)}function QV(t,e,r,n){return hx(t,e,2,Rc(t,e+1,n))}function eG(t,e,r,n){return hx(t,e,3,Dc(t,e+1,n))}function tG(t,e,r,n){return hx(t,e,5,Bc(t,e+1,n))}function rG(t,e,r,n){let i=Mc(t,e+1,n);if(typeof i=="bigint")throw new Error(`${Kt} 64-bit integer bytes lengths not supported`);return hx(t,e,9,i)}function v8(t){return t.encodedBytes===void 0&&(t.encodedBytes=t.type===ve.string?UV(t.value):t.value),t.encodedBytes}function uw(t,e){let r=v8(e);ns(t,e.type.majorEncoded,r.length),t.push(r)}uw.encodedSize=function(e){let r=v8(e);return ns.encodedSize(r.length)+r.length};uw.compareTokens=function(e,r){return N6e(v8(e),v8(r))};function N6e(t,e){return t.lengthe.length?1:KV(t,e)}f();function px(t,e,r,n,i){let o=r+n;oh(t,e,o);let s=new We(ve.string,NV(t,e+r,e+o),o);return i.retainStringBytes===!0&&(s.byteValue=dw(t,e+r,e+o)),s}function nG(t,e,r,n){return px(t,e,1,r,n)}function iG(t,e,r,n){return px(t,e,2,Rc(t,e+1,n),n)}function oG(t,e,r,n){return px(t,e,3,Dc(t,e+1,n),n)}function sG(t,e,r,n){return px(t,e,5,Bc(t,e+1,n),n)}function aG(t,e,r,n){let i=Mc(t,e+1,n);if(typeof i=="bigint")throw new Error(`${Kt} 64-bit integer string lengths not supported`);return px(t,e,9,i,n)}var cG=uw;f();function lw(t,e,r,n){return new We(ve.array,n,r)}function dG(t,e,r,n){return lw(t,e,1,r)}function uG(t,e,r,n){return lw(t,e,2,Rc(t,e+1,n))}function lG(t,e,r,n){return lw(t,e,3,Dc(t,e+1,n))}function fG(t,e,r,n){return lw(t,e,5,Bc(t,e+1,n))}function hG(t,e,r,n){let i=Mc(t,e+1,n);if(typeof i=="bigint")throw new Error(`${Kt} 64-bit integer array lengths not supported`);return lw(t,e,9,i)}function pG(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${Kt} indefinite length items not allowed`);return lw(t,e,1,1/0)}function b8(t,e){ns(t,ve.array.majorEncoded,e.value)}b8.compareTokens=_d.compareTokens;b8.encodedSize=function(e){return ns.encodedSize(e.value)};f();function fw(t,e,r,n){return new We(ve.map,n,r)}function mG(t,e,r,n){return fw(t,e,1,r)}function yG(t,e,r,n){return fw(t,e,2,Rc(t,e+1,n))}function gG(t,e,r,n){return fw(t,e,3,Dc(t,e+1,n))}function vG(t,e,r,n){return fw(t,e,5,Bc(t,e+1,n))}function bG(t,e,r,n){let i=Mc(t,e+1,n);if(typeof i=="bigint")throw new Error(`${Kt} 64-bit integer map lengths not supported`);return fw(t,e,9,i)}function wG(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${Kt} indefinite length items not allowed`);return fw(t,e,1,1/0)}function w8(t,e){ns(t,ve.map.majorEncoded,e.value)}w8.compareTokens=_d.compareTokens;w8.encodedSize=function(e){return ns.encodedSize(e.value)};f();function _G(t,e,r,n){return new We(ve.tag,r,1)}function xG(t,e,r,n){return new We(ve.tag,Rc(t,e+1,n),2)}function EG(t,e,r,n){return new We(ve.tag,Dc(t,e+1,n),3)}function SG(t,e,r,n){return new We(ve.tag,Bc(t,e+1,n),5)}function AG(t,e,r,n){return new We(ve.tag,Mc(t,e+1,n),9)}function _8(t,e){ns(t,ve.tag.majorEncoded,e.value)}_8.compareTokens=_d.compareTokens;_8.encodedSize=function(e){return ns.encodedSize(e.value)};f();var z6e=20,W6e=21,H6e=22,V6e=23;function TG(t,e,r,n){if(n.allowUndefined===!1)throw new Error(`${Kt} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new We(ve.null,null,1):new We(ve.undefined,void 0,1)}function PG(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${Kt} indefinite length items not allowed`);return new We(ve.break,void 0,1)}function mB(t,e,r){if(r){if(r.allowNaN===!1&&Number.isNaN(t))throw new Error(`${Kt} NaN values are not supported`);if(r.allowInfinity===!1&&(t===1/0||t===-1/0))throw new Error(`${Kt} Infinity values are not supported`)}return new We(ve.float,t,e)}function IG(t,e,r,n){return mB(yB(t,e+1),3,n)}function kG(t,e,r,n){return mB(gB(t,e+1),5,n)}function RG(t,e,r,n){return mB(OG(t,e+1),9,n)}function x8(t,e,r){let n=e.value;if(n===!1)t.push([ve.float.majorEncoded|z6e]);else if(n===!0)t.push([ve.float.majorEncoded|W6e]);else if(n===null)t.push([ve.float.majorEncoded|H6e]);else if(n===void 0)t.push([ve.float.majorEncoded|V6e]);else{let i,o=!1;(!r||r.float64!==!0)&&(BG(n),i=yB(bu,1),n===i||Number.isNaN(n)?(bu[0]=249,t.push(bu.slice(0,3)),o=!0):(MG(n),i=gB(bu,1),n===i&&(bu[0]=250,t.push(bu.slice(0,5)),o=!0))),o||(G6e(n),i=OG(bu,1),bu[0]=251,t.push(bu.slice(0,9)))}}x8.encodedSize=function(e,r){let n=e.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){BG(n);let i=yB(bu,1);if(n===i||Number.isNaN(n))return 3;if(MG(n),i=gB(bu,1),n===i)return 5}return 9};var DG=new ArrayBuffer(9),xd=new DataView(DG,1),bu=new Uint8Array(DG,0);function BG(t){if(t===1/0)xd.setUint16(0,31744,!1);else if(t===-1/0)xd.setUint16(0,64512,!1);else if(Number.isNaN(t))xd.setUint16(0,32256,!1);else{xd.setFloat32(0,t);let e=xd.getUint32(0),r=(e&2139095040)>>23,n=e&8388607;if(r===255)xd.setUint16(0,31744,!1);else if(r===0)xd.setUint16(0,(t&2147483648)>>16|n>>13,!1);else{let i=r-127;i<-24?xd.setUint16(0,0):i<-14?xd.setUint16(0,(e&2147483648)>>16|1<<24+i,!1):xd.setUint16(0,(e&2147483648)>>16|i+15<<10|n>>13,!1)}}}function yB(t,e){if(t.length-e<2)throw new Error(`${Kt} not enough data for float16`);let r=(t[e]<<8)+t[e+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,i=r&1023,o;return n===0?o=i*2**-24:n!==31?o=(i+1024)*2**(n-25):o=i===0?1/0:NaN,r&32768?-o:o}function MG(t){xd.setFloat32(0,t,!1)}function gB(t,e){if(t.length-e<4)throw new Error(`${Kt} not enough data for float32`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,4).getFloat32(0,!1)}function G6e(t){xd.setFloat64(0,t,!1)}function OG(t,e){if(t.length-e<8)throw new Error(`${Kt} not enough data for float64`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,8).getFloat64(0,!1)}x8.compareTokens=_d.compareTokens;function Gr(t,e,r){throw new Error(`${Kt} encountered invalid minor (${r}) for major ${t[e]>>>5}`)}function E8(t){return()=>{throw new Error(`${Kt} ${t}`)}}var Ce=[];for(let t=0;t<=23;t++)Ce[t]=Gr;Ce[24]=FV;Ce[25]=zV;Ce[26]=WV;Ce[27]=HV;Ce[28]=Gr;Ce[29]=Gr;Ce[30]=Gr;Ce[31]=Gr;for(let t=32;t<=55;t++)Ce[t]=Gr;Ce[56]=VV;Ce[57]=GV;Ce[58]=JV;Ce[59]=YV;Ce[60]=Gr;Ce[61]=Gr;Ce[62]=Gr;Ce[63]=Gr;for(let t=64;t<=87;t++)Ce[t]=XV;Ce[88]=QV;Ce[89]=eG;Ce[90]=tG;Ce[91]=rG;Ce[92]=Gr;Ce[93]=Gr;Ce[94]=Gr;Ce[95]=E8("indefinite length bytes/strings are not supported");for(let t=96;t<=119;t++)Ce[t]=nG;Ce[120]=iG;Ce[121]=oG;Ce[122]=sG;Ce[123]=aG;Ce[124]=Gr;Ce[125]=Gr;Ce[126]=Gr;Ce[127]=E8("indefinite length bytes/strings are not supported");for(let t=128;t<=151;t++)Ce[t]=dG;Ce[152]=uG;Ce[153]=lG;Ce[154]=fG;Ce[155]=hG;Ce[156]=Gr;Ce[157]=Gr;Ce[158]=Gr;Ce[159]=pG;for(let t=160;t<=183;t++)Ce[t]=mG;Ce[184]=yG;Ce[185]=gG;Ce[186]=vG;Ce[187]=bG;Ce[188]=Gr;Ce[189]=Gr;Ce[190]=Gr;Ce[191]=wG;for(let t=192;t<=215;t++)Ce[t]=_G;Ce[216]=xG;Ce[217]=EG;Ce[218]=SG;Ce[219]=AG;Ce[220]=Gr;Ce[221]=Gr;Ce[222]=Gr;Ce[223]=Gr;for(let t=224;t<=243;t++)Ce[t]=E8("simple values are not supported");Ce[244]=Gr;Ce[245]=Gr;Ce[246]=Gr;Ce[247]=TG;Ce[248]=E8("simple values are not supported");Ce[249]=IG;Ce[250]=kG;Ce[251]=RG;Ce[252]=Gr;Ce[253]=Gr;Ce[254]=Gr;Ce[255]=PG;var wu=[];for(let t=0;t<24;t++)wu[t]=new We(ve.uint,t,1);for(let t=-1;t>=-24;t--)wu[31-t]=new We(ve.negint,t,1);wu[64]=new We(ve.bytes,new Uint8Array(0),1);wu[96]=new We(ve.string,"",1);wu[128]=new We(ve.array,0,1);wu[160]=new We(ve.map,0,1);wu[244]=new We(ve.false,!1,1);wu[245]=new We(ve.true,!0,1);wu[246]=new We(ve.null,null,1);function CG(t){switch(t.type){case ve.false:return Il([244]);case ve.true:return Il([245]);case ve.null:return Il([246]);case ve.bytes:return t.value.length?void 0:Il([64]);case ve.string:return t.value===""?Il([96]):void 0;case ve.array:return t.value===0?Il([128]):void 0;case ve.map:return t.value===0?Il([160]):void 0;case ve.uint:return t.value<24?Il([Number(t.value)]):void 0;case ve.negint:if(t.value>=-24)return Il([31-Number(t.value)])}}var Z6e={float64:!1,mapSorter:Q6e,quickEncodeToken:CG};function Y6e(){let t=[];return t[ve.uint.major]=_d,t[ve.negint.major]=g8,t[ve.bytes.major]=uw,t[ve.string.major]=cG,t[ve.array.major]=b8,t[ve.map.major]=w8,t[ve.tag.major]=_8,t[ve.float.major]=x8,t}var $G=Y6e(),vB=new lx,A8=class t{constructor(e,r){this.obj=e,this.parent=r}includes(e){let r=this;do if(r.obj===e)return!0;while(r=r.parent);return!1}static createCheck(e,r){if(e&&e.includes(r))throw new Error(`${hB} object contains circular references`);return new t(r,e)}},om={null:new We(ve.null,null),undefined:new We(ve.undefined,void 0),true:new We(ve.true,!0),false:new We(ve.false,!1),emptyArray:new We(ve.array,0),emptyMap:new We(ve.map,0)},sm={number(t,e,r,n){return!Number.isInteger(t)||!Number.isSafeInteger(t)?new We(ve.float,t):t>=0?new We(ve.uint,t):new We(ve.negint,t)},bigint(t,e,r,n){return t>=BigInt(0)?new We(ve.uint,t):new We(ve.negint,t)},Uint8Array(t,e,r,n){return new We(ve.bytes,t)},string(t,e,r,n){return new We(ve.string,t)},boolean(t,e,r,n){return t?om.true:om.false},null(t,e,r,n){return om.null},undefined(t,e,r,n){return om.undefined},ArrayBuffer(t,e,r,n){return new We(ve.bytes,new Uint8Array(t))},DataView(t,e,r,n){return new We(ve.bytes,new Uint8Array(t.buffer,t.byteOffset,t.byteLength))},Array(t,e,r,n){if(!t.length)return r.addBreakTokens===!0?[om.emptyArray,new We(ve.break)]:om.emptyArray;n=A8.createCheck(n,t);let i=[],o=0;for(let s of t)i[o++]=S8(s,r,n);return r.addBreakTokens?[new We(ve.array,t.length),i,new We(ve.break)]:[new We(ve.array,t.length),i]},Object(t,e,r,n){let i=e!=="Object",o=i?t.keys():Object.keys(t),s=i?t.size:o.length;if(!s)return r.addBreakTokens===!0?[om.emptyMap,new We(ve.break)]:om.emptyMap;n=A8.createCheck(n,t);let a=[],d=0;for(let u of o)a[d++]=[S8(u,r,n),S8(i?t.get(u):t[u],r,n)];return X6e(a,r),r.addBreakTokens?[new We(ve.map,s),a,new We(ve.break)]:[new We(ve.map,s),a]}};sm.Map=sm.Object;sm.Buffer=sm.Uint8Array;for(let t of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))sm[`${t}Array`]=sm.DataView;function S8(t,e={},r){let n=OV(t),i=e&&e.typeEncoders&&e.typeEncoders[n]||sm[n];if(typeof i=="function"){let s=i(t,n,e,r);if(s!=null)return s}let o=sm[n];if(!o)throw new Error(`${hB} unsupported type: ${n}`);return o(t,n,e,r)}function X6e(t,e){e.mapSorter&&t.sort(e.mapSorter)}function Q6e(t,e){let r=Array.isArray(t[0])?t[0][0]:t[0],n=Array.isArray(e[0])?e[0][0]:e[0];if(r.type!==n.type)return r.type.compare(n.type);let i=r.type.major,o=$G[i].compareTokens(r,n);return o===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),o}function jG(t,e,r,n){if(Array.isArray(e))for(let i of e)jG(t,i,r,n);else r[e.type.major](t,e,n)}function eSe(t,e,r){let n=S8(t,r);if(!Array.isArray(n)&&r.quickEncodeToken){let i=r.quickEncodeToken(n);if(i)return i;let o=e[n.type.major];if(o.encodedSize){let s=o.encodedSize(n,r),a=new lx(s);if(o(a,n,r),a.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return fB(a.chunks[0])}}return vB.reset(),jG(vB,n,e,r),vB.toBytes(!0)}function bB(t,e){return e=Object.assign({},Z6e,e),eSe(t,$G,e)}f();var tSe={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},wB=class{constructor(e,r={}){this.pos=0,this.data=e,this.options=r}done(){return this.pos>=this.data.length}next(){let e=this.data[this.pos],r=wu[e];if(r===void 0){let n=Ce[e];if(!n)throw new Error(`${Kt} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);let i=e&31;r=n(this.data,this.pos,i,this.options)}return this.pos+=r.encodedLength,r}},mx=Symbol.for("DONE"),T8=Symbol.for("BREAK");function rSe(t,e,r){let n=[];for(let i=0;ipw,base32hex:()=>hSe,base32hexpad:()=>mSe,base32hexpadupper:()=>ySe,base32hexupper:()=>pSe,base32pad:()=>lSe,base32padupper:()=>fSe,base32upper:()=>uSe,base32z:()=>gSe});f();f();f();function oSe(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n>>0,$=new Uint8Array(A);S!==P;){for(var j=g[S],q=0,F=A-1;(j!==0||q>>0,$[F]=j%a>>>0,j=j/a>>>0;if(j!==0)throw new Error("Non-zero carry");x=q,S++}for(var K=A-x;K!==A&&$[K]===0;)K++;for(var W=d.repeat(v);K>>0,A=new Uint8Array(P);g[v];){var $=r[g.charCodeAt(v)];if($===255)return;for(var j=0,q=P-1;($!==0||j>>0,A[q]=$%256>>>0,$=$/256>>>0;if($!==0)throw new Error("Non-zero carry");S=j,v++}if(g[v]!==" "){for(var F=P-S;F!==P&&A[F]===0;)F++;for(var K=new Uint8Array(x+(P-F)),W=x;F!==P;)K[W++]=A[F++];return K}}}function m(g){var v=p(g);if(v)return v;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:p,decode:m}}var sSe=oSe,aSe=sSe,NG=aSe;f();var Aut=new Uint8Array(0);var UG=(t,e)=>{if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r{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 qG=t=>new TextEncoder().encode(t),LG=t=>new TextDecoder().decode(t);f();var xB=class{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")}},EB=class{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 FG(this,e)}},SB=class{constructor(e){this.decoders=e}or(e){return FG(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},FG=(t,e)=>new SB({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),AB=class{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new xB(e,r,n),this.decoder=new EB(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},hw=({name:t,prefix:e,encode:r,decode:n})=>new AB(t,e,r,n),am=({prefix:t,name:e,alphabet:r})=>{let{encode:n,decode:i}=NG(r,e);return hw({prefix:t,name:e,encode:n,decode:o=>sh(i(o))})},cSe=(t,e,r,n)=>{let i={};for(let c=0;c=8&&(a-=8,s[u++]=255&d>>a)}if(a>=r||255&d<<8-a)throw new SyntaxError("Unexpected end of data");return s},dSe=(t,e,r)=>{let n=e[e.length-1]==="=",i=(1<r;)s-=r,o+=e[i&a>>s];if(s&&(o+=e[i&a<hw({prefix:e,name:t,encode(i){return dSe(i,n,r)},decode(i){return cSe(i,n,r,t)}});var pw=gi({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),uSe=gi({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),lSe=gi({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),fSe=gi({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),hSe=gi({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),pSe=gi({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),mSe=gi({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),ySe=gi({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),gSe=gi({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var PB={};Pr(PB,{base58btc:()=>kl,base58flickr:()=>vSe});f();var kl=am({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),vSe=am({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});f();f();f();var bSe=HG,zG=128,wSe=127,_Se=~wSe,xSe=Math.pow(2,31);function HG(t,e,r){e=e||[],r=r||0;for(var n=r;t>=xSe;)e[r++]=t&255|zG,t/=128;for(;t&_Se;)e[r++]=t&255|zG,t>>>=7;return e[r]=t|0,HG.bytes=r-n+1,e}var ESe=IB,SSe=128,WG=127;function IB(t,n){var r=0,n=n||0,i=0,o=n,s,a=t.length;do{if(o>=a)throw IB.bytes=0,new RangeError("Could not decode varint");s=t[o++],r+=i<28?(s&WG)<=SSe);return IB.bytes=o-n,r}var ASe=Math.pow(2,7),TSe=Math.pow(2,14),PSe=Math.pow(2,21),ISe=Math.pow(2,28),kSe=Math.pow(2,35),RSe=Math.pow(2,42),DSe=Math.pow(2,49),BSe=Math.pow(2,56),MSe=Math.pow(2,63),OSe=function(t){return t[gx.decode(t,e),gx.decode.bytes],mw=(t,e,r=0)=>(gx.encode(t,e,r),e),yw=t=>gx.encodingLength(t);var V0=(t,e)=>{let r=e.byteLength,n=yw(t),i=n+yw(r),o=new Uint8Array(i+r);return mw(t,o,0),mw(r,o,n),o.set(e,i),new gw(t,r,e,o)},I8=t=>{let e=sh(t),[r,n]=vx(e),[i,o]=vx(e.subarray(n)),s=e.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new gw(r,i,s,e)},VG=(t,e)=>{if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&UG(t.bytes,r.bytes)}},gw=class{constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}};f();var GG=(t,e)=>{let{bytes:r,version:n}=t;switch(n){case 0:return NSe(r,kB(t),e||kl.encoder);default:return USe(r,kB(t),e||pw.encoder)}};var JG=new WeakMap,kB=t=>{let e=JG.get(t);if(e==null){let r=new Map;return JG.set(t,r),r}return e},ah=class t{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!==wx)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==qSe)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=V0(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&&e.code===n.code&&e.version===n.version&&VG(e.multihash,n.multihash)}toString(e){return GG(this,e)}toJSON(){return{"/":GG(this)}}link(){return this}get[Symbol.toStringTag](){return"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||ZG(n,i,o.bytes))}else if(r[LSe]===!0){let{version:n,multihash:i,code:o}=r,s=I8(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!==wx)throw new Error(`Version 0 CID must use dag-pb (code: ${wx}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let i=ZG(e,r,n.bytes);return new t(e,r,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,wx,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,i=sh(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 gw(r.multihashCode,r.digestSize,o,i);return[r.version===0?t.createV0(s):t.createV1(r.codec,s),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[l,p]=vx(e.subarray(r));return r+=p,l},i=n(),o=wx;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(),d=n(),u=r+d,c=u-s;return{version:i,codec:o,multihashCode:a,digestSize:d,multihashSize:c,size:u}}static parse(e,r){let[n,i]=jSe(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 kB(o).set(n,e),o}},jSe=(t,e)=>{switch(t[0]){case"Q":{let r=e||kl;return[kl.prefix,r.decode(`${kl.prefix}${t}`)]}case kl.prefix:{let r=e||kl;return[kl.prefix,r.decode(t)]}case pw.prefix:{let r=e||pw;return[pw.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)]}}},NSe=(t,e,r)=>{let{prefix:n}=r;if(n!==kl.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},USe=(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},wx=112,qSe=18,ZG=(t,e,r)=>{let n=yw(t),i=n+yw(e),o=new Uint8Array(i+r.byteLength);return mw(t,o,0),mw(e,o,n),o.set(r,i),o},LSe=Symbol.for("@ipld/js-cid/CID");var YG=42;function KSe(t){if(t.asCID!==t&&t["/"]!==t.bytes)return null;let e=ah.asCID(t);if(!e)return null;let r=new Uint8Array(e.bytes.byteLength+1);return r.set(e.bytes,1),[new We(ve.tag,YG),new We(ve.bytes,r)]}function FSe(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function zSe(t){if(Number.isNaN(t))throw new Error("`NaN` is not supported by the IPLD Data Model and cannot be encoded");if(t===1/0||t===-1/0)throw new Error("`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded");return null}var WSe={float64:!0,typeEncoders:{Object:KSe,undefined:FSe,number:zSe}};function HSe(t){if(t[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return ah.decode(t.subarray(1))}var XG={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:[]};XG.tags[YG]=HSe;var VSe="dag-cbor",_x=113,GSe=t=>bB(t,WSe),JSe=t=>_B(t,XG);f();f();f();f();var Za=e9({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),elt=e9({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});f();var xx=ya({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),ilt=ya({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),olt=ya({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),slt=ya({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),alt=ya({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),clt=ya({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),dlt=ya({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),ult=ya({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),RB=ya({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});f();var QG=(t,e)=>{let{bytes:r,version:n}=t;switch(n){case 0:return YSe(r,DB(t),e||Za.encoder);default:return XSe(r,DB(t),e||xx.encoder)}};var eJ=new WeakMap,DB=t=>{let e=eJ.get(t);if(e==null){let r=new Map;return eJ.set(t,r),r}return e},Nr=class t{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!==Ex)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==QSe)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=k0(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&&e.code===n.code&&e.version===n.version&&SH(e.multihash,n.multihash)}toString(e){return QG(this,e)}toJSON(){return{"/":QG(this)}}link(){return this}get[Symbol.toStringTag](){return"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||tJ(n,i,o.bytes))}else if(r[e3e]===!0){let{version:n,multihash:i,code:o}=r,s=n8(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!==Ex)throw new Error(`Version 0 CID must use dag-pb (code: ${Ex}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let i=tJ(e,r,n.bytes);return new t(e,r,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,Ex,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,i=pu(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 zb(r.multihashCode,r.digestSize,o,i);return[r.version===0?t.createV0(s):t.createV1(r.codec,s),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[l,p]=Fb(e.subarray(r));return r+=p,l},i=n(),o=Ex;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(),d=n(),u=r+d,c=u-s;return{version:i,codec:o,multihashCode:a,digestSize:d,multihashSize:c,size:u}}static parse(e,r){let[n,i]=ZSe(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 DB(o).set(n,e),o}},ZSe=(t,e)=>{switch(t[0]){case"Q":{let r=e||Za;return[Za.prefix,r.decode(`${Za.prefix}${t}`)]}case Za.prefix:{let r=e||Za;return[Za.prefix,r.decode(t)]}case xx.prefix:{let r=e||xx;return[xx.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)]}}},YSe=(t,e,r)=>{let{prefix:n}=r;if(n!==Za.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},XSe=(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},Ex=112,QSe=18,tJ=(t,e,r)=>{let n=I0(t),i=n+I0(e),o=new Uint8Array(i+r.byteLength);return P0(t,o,0),P0(e,o,n),o.set(r,i),o},e3e=Symbol.for("@ipld/js-cid/CID");f();var cm=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},k8=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,d){s=t[o](s),i(a,d,s.done,s.value)})}}function i(o,s,a,d){Promise.resolve(d).then(function(u){o({value:u,done:a})},s)}},ko=function(t){return this instanceof ko?(this.v=t,this):new ko(t)},R8=function(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),i,o=[];return i={},s("next"),s("throw"),s("return"),i[Symbol.asyncIterator]=function(){return this},i;function s(p){n[p]&&(i[p]=function(m){return new Promise(function(g,v){o.push([p,m,g,v])>1||a(p,m)})})}function a(p,m){try{d(n[p](m))}catch(g){l(o[0][3],g)}}function d(p){p.value instanceof ko?Promise.resolve(p.value.v).then(u,c):l(o[0][2],p)}function u(p){a("next",p)}function c(p){a("throw",p)}function l(p,m){p(m),o.shift(),o.length&&a(o[0][0],o[0][1])}},Sx=class{open(){return cm(this,void 0,void 0,function*(){})}close(){return cm(this,void 0,void 0,function*(){})}put(e,r,n){return cm(this,void 0,void 0,function*(){return e})}get(e,r){return cm(this,void 0,void 0,function*(){return new Uint8Array})}has(e,r){return cm(this,void 0,void 0,function*(){return!1})}delete(e,r){return cm(this,void 0,void 0,function*(){})}isEmpty(e){return cm(this,void 0,void 0,function*(){return!0})}putMany(e,r){return R8(this,arguments,function*(){var i,o,s,a;try{for(var d=!0,u=k8(e),c;c=yield ko(u.next()),i=c.done,!i;d=!0){a=c.value,d=!1;let l=a;yield ko(this.put(l.cid,l.block,r)),yield yield ko(l.cid)}}catch(l){o={error:l}}finally{try{!d&&!i&&(s=u.return)&&(yield ko(s.call(u)))}finally{if(o)throw o.error}}})}getMany(e,r){return R8(this,arguments,function*(){var i,o,s,a;try{for(var d=!0,u=k8(e),c;c=yield ko(u.next()),i=c.done,!i;d=!0){a=c.value,d=!1;let l=a;yield yield ko({cid:l,block:yield ko(this.get(l,r))})}}catch(l){o={error:l}}finally{try{!d&&!i&&(s=u.return)&&(yield ko(s.call(u)))}finally{if(o)throw o.error}}})}getAll(e){return R8(this,arguments,function*(){var n,i,o,s;let a=this.db.iterator({keys:!0,keyEncoding:"buffer"},e);try{for(var d=!0,u=k8(a),c;c=yield ko(u.next()),n=c.done,!n;d=!0){s=c.value,d=!1;let[l,p]=s;yield yield ko({cid:Nr.decode(l),block:p})}}catch(l){i={error:l}}finally{try{!d&&!n&&(o=u.return)&&(yield ko(o.call(u)))}finally{if(i)throw i.error}}})}deleteMany(e,r){return R8(this,arguments,function*(){var i,o,s,a;try{for(var d=!0,u=k8(e),c;c=yield ko(u.next()),i=c.done,!i;d=!0){a=c.value,d=!1;let l=a;yield ko(this.delete(l,r)),yield yield ko(l)}}catch(l){o={error:l}}finally{try{!d&&!i&&(s=u.return)&&(yield ko(s.call(u)))}finally{if(o)throw o.error}}})}clear(){return cm(this,void 0,void 0,function*(){})}};f();var x5e=gt(Oc(),1);f();f();f();function r3e(t){return t[Symbol.asyncIterator]!=null}function n3e(t,e=1){return e=Number(e),r3e(t)?async function*(){let r=[];if(e<1&&(e=1),e!==Math.round(e))throw new Error("Batch size must be an integer");for await(let n of t)for(r.push(n);r.length>=e;)yield r.slice(0,e),r=r.slice(e);for(;r.length>0;)yield r.slice(0,e),r=r.slice(e)}():function*(){let r=[];if(e<1&&(e=1),e!==Math.round(e))throw new Error("Batch size must be an integer");for(let n of t)for(r.push(n);r.length>=e;)yield r.slice(0,e),r=r.slice(e);for(;r.length>0;)yield r.slice(0,e),r=r.slice(e)}()}var Ax=n3e;async function*Tx(t,e=1){for await(let r of Ax(t,e)){let n=r.map(async i=>i().then(o=>({ok:!0,value:o}),o=>({ok:!1,err:o})));for(let i=0;i0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let r=0;for(let n of e)if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.push(n);else if(D8(n))r+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}prepend(...e){this.prependAll(e)}prependAll(e){let r=0;for(let n of e.reverse())if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.unshift(n);else if(D8(n))r+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}get(e){let r=iJ(this.bufs,e);return r.buf[r.index]}set(e,r){let n=iJ(this.bufs,e);n.buf[n.index]=r}write(e,r=0){if(e instanceof Uint8Array)for(let n=0;n0;)if(e>=this.bufs[0].byteLength)e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}}}slice(e,r){let{bufs:n,length:i}=this._subList(e,r);return Yb(n,i)}subarray(e,r){let{bufs:n,length:i}=this._subList(e,r);return n.length===1?n[0]:Yb(n,i)}sublist(e,r){let{bufs:n,length:i}=this._subList(e,r),o=new t;return o.length=i,o.bufs=[...n],o}_subList(e,r){if(e=e??0,r=r??this.length,e<0&&(e=this.length+e),r<0&&(r=this.length+r),e<0||r>this.length)throw new RangeError("index is out of bounds");if(e===r)return{bufs:[],length:0};if(e===0&&r===this.length)return{bufs:this.bufs,length:this.length};let n=[],i=0;for(let o=0;o=d)continue;let u=e>=a&&ea&&r<=d;if(u&&c){if(e===a&&r===d){n.push(s);break}let l=e-a;n.push(s.subarray(l,l+(r-e)));break}if(u){if(e===0){n.push(s);continue}n.push(s.subarray(e-a));continue}if(c){if(r===d){n.push(s);break}n.push(s.subarray(0,r-a));break}n.push(s)}return{bufs:n,length:r-e}}indexOf(e,r=0){if(!D8(e)&&!(e instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=e instanceof Uint8Array?e:e.subarray();if(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),e.length===0)return r>this.length?this.length:r;let i=n.byteLength;if(i===0)throw new TypeError("search must be at least 1 byte long");let o=256,s=new Int32Array(o);for(let l=0;l=0;p--){let m=this.get(l+p);if(n[p]!==m){c=Math.max(1,p-a[m]);break}}if(c===0)return l}return-1}getInt8(e){let r=this.subarray(e,e+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(e,r){let n=Ja(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,e)}getInt16(e,r){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(e,r,n){let i=nh(2);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt16(0,r,n),this.write(i,e)}getInt32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,r)}setInt32(e,r,n){let i=nh(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt32(0,r,n),this.write(i,e)}getBigInt64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,r)}setBigInt64(e,r,n){let i=nh(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setBigInt64(0,r,n),this.write(i,e)}getUint8(e){let r=this.subarray(e,e+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(e,r){let n=Ja(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,e)}getUint16(e,r){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(e,r,n){let i=nh(2);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint16(0,r,n),this.write(i,e)}getUint32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,r)}setUint32(e,r,n){let i=nh(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint32(0,r,n),this.write(i,e)}getBigUint64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,r)}setBigUint64(e,r,n){let i=nh(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setBigUint64(0,r,n),this.write(i,e)}getFloat32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,r)}setFloat32(e,r,n){let i=nh(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat32(0,r,n),this.write(i,e)}getFloat64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,r)}setFloat64(e,r,n){let i=nh(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat64(0,r,n),this.write(i,e)}equals(e){if(e==null||!(e instanceof t)||e.bufs.length!==this.bufs.length)return!1;for(let r=0;ri+o.byteLength,0)),n.length=r,n}};var i3e=262144,sJ=(t={})=>{let e=t.chunkSize??i3e;return async function*(n){let i=new vw,o=0,s=!1;for await(let a of n)for(i.append(a),o+=a.length;o>=e;)if(yield i.slice(0,e),s=!0,e===i.length)i=new vw,o=0;else{let d=new vw;d.append(i.sublist(e)),i=d,o-=e}(!s||o>0)&&(yield i.subarray(0,o))}};f();var J0={};Pr(J0,{code:()=>Ix,createLink:()=>yJ,createNode:()=>mJ,decode:()=>ch,encode:()=>$c,name:()=>m3e,prepare:()=>Cc,validate:()=>OB});f();f();var o3e=new TextDecoder;function BB(t,e){let r=0;for(let n=0;;n+=7){if(n>=64)throw new Error("protobuf: varint overflow");if(e>=t.length)throw new Error("protobuf: unexpected end of data");let i=t[e++];if(r+=n<28?(i&127)<t.length)throw new Error("protobuf: unexpected end of data");return[t.subarray(e,n),n]}function aJ(t,e){let r;return[r,e]=BB(t,e),[r&7,r>>3,e]}function s3e(t){let e={},r=t.length,n=0;for(;nr)throw new Error("protobuf: (PBLink) unexpected end of data");return e}function cJ(t){let e=t.length,r=0,n,i=!1,o;for(;re)throw new Error("protobuf: (PBNode) unexpected end of data");let s={};return o&&(s.Data=o),s.Links=n||[],s}f();var uJ=new TextEncoder,dJ=2**32,a3e=2**31;function c3e(t,e){let r=e.length;if(typeof t.Tsize=="number"){if(t.Tsize<0)throw new Error("Tsize cannot be negative");if(!Number.isSafeInteger(t.Tsize))throw new Error("Tsize too large for encoding");r=Px(e,r,t.Tsize)-1,e[r]=24}if(typeof t.Name=="string"){let n=uJ.encode(t.Name);r-=n.length,e.set(n,r),r=Px(e,r,n.length)-1,e[r]=18}return t.Hash&&(r-=t.Hash.length,e.set(t.Hash,r),r=Px(e,r,t.Hash.length)-1,e[r]=10),e.length-r}function lJ(t){let e=u3e(t),r=new Uint8Array(e),n=e;if(t.Data&&(n-=t.Data.length,r.set(t.Data,n),n=Px(r,n,t.Data.length)-1,r[n]=10),t.Links)for(let i=t.Links.length-1;i>=0;i--){let o=c3e(t.Links[i],r.subarray(0,n));n-=o,n=Px(r,n,o)-1,r[n]=18}return r}function d3e(t){let e=0;if(t.Hash){let r=t.Hash.length;e+=1+r+bw(r)}if(typeof t.Name=="string"){let r=uJ.encode(t.Name).length;e+=1+r+bw(r)}return typeof t.Tsize=="number"&&(e+=1+bw(t.Tsize)),e}function u3e(t){let e=0;if(t.Data){let r=t.Data.length;e+=1+r+bw(r)}if(t.Links)for(let r of t.Links){let n=d3e(r);e+=1+n+bw(n)}return e}function Px(t,e,r){e-=bw(r);let n=e;for(;r>=a3e;)t[e++]=r&127|128,r/=128;for(;r>=128;)t[e++]=r&127|128,r>>>=7;return t[e]=r,n}function bw(t){return t%2===0&&t++,Math.floor((l3e(t)+6)/7)}function l3e(t){let e=0;return t>=dJ&&(t=Math.floor(t/dJ),e=32),t>=65536&&(t>>>=16,e+=16),t>=256&&(t>>>=8,e+=8),e+f3e[t]}var f3e=[0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8];f();var h3e=["Data","Links"],p3e=["Hash","Name","Tsize"],MB=new TextEncoder;function hJ(t,e){if(t===e)return 0;let r=t.Name?MB.encode(t.Name):[],n=e.Name?MB.encode(e.Name):[],i=r.length,o=n.length;for(let s=0,a=Math.min(i,o);s!e.includes(r))}function pJ(t){if(typeof t.asCID=="object"){let r=yu.asCID(t);if(!r)throw new TypeError("Invalid DAG-PB form");return{Hash:r}}if(typeof t!="object"||Array.isArray(t))throw new TypeError("Invalid DAG-PB form");let e={};if(t.Hash){let r=yu.asCID(t.Hash);try{r||(typeof t.Hash=="string"?r=yu.parse(t.Hash):t.Hash instanceof Uint8Array&&(r=yu.decode(t.Hash)))}catch(n){throw new TypeError(`Invalid DAG-PB form: ${n.message}`)}r&&(e.Hash=r)}if(!e.Hash)throw new TypeError("Invalid DAG-PB form");return typeof t.Name=="string"&&(e.Name=t.Name),typeof t.Tsize=="number"&&(e.Tsize=t.Tsize),e}function Cc(t){if((t instanceof Uint8Array||typeof t=="string")&&(t={Data:t}),typeof t!="object"||Array.isArray(t))throw new TypeError("Invalid DAG-PB form");let e={};if(t.Data!==void 0)if(typeof t.Data=="string")e.Data=MB.encode(t.Data);else if(t.Data instanceof Uint8Array)e.Data=t.Data;else throw new TypeError("Invalid DAG-PB form");if(t.Links!==void 0)if(Array.isArray(t.Links))e.Links=t.Links.map(pJ),e.Links.sort(hJ);else throw new TypeError("Invalid DAG-PB form");else e.Links=[];return e}function OB(t){if(!t||typeof t!="object"||Array.isArray(t)||t instanceof Uint8Array||t["/"]&&t["/"]===t.bytes)throw new TypeError("Invalid DAG-PB form");if(!fJ(t,h3e))throw new TypeError("Invalid DAG-PB form (extraneous properties)");if(t.Data!==void 0&&!(t.Data instanceof Uint8Array))throw new TypeError("Invalid DAG-PB form (Data must be bytes)");if(!Array.isArray(t.Links))throw new TypeError("Invalid DAG-PB form (Links must be a list)");for(let e=0;e0&&hJ(r,t.Links[e-1])===-1)throw new TypeError("Invalid DAG-PB form (links must be sorted by Name bytes)")}}function mJ(t,e=[]){return Cc({Data:t,Links:e})}function yJ(t,e,r){return pJ({Hash:r,Name:t,Tsize:e})}function gJ(t){return t instanceof ArrayBuffer?new Uint8Array(t,0,t.byteLength):t}var m3e="dag-pb",Ix=112;function $c(t){OB(t);let e={};return t.Links&&(e.Links=t.Links.map(r=>{let n={};return r.Hash&&(n.Hash=r.Hash.bytes),r.Name!==void 0&&(n.Name=r.Name),r.Tsize!==void 0&&(n.Tsize=r.Tsize),n})),t.Data&&(e.Data=t.Data),lJ(e)}function ch(t){let e=gJ(t),r=cJ(e),n={};return r.Data&&(n.Data=r.Data),r.Links&&(n.Links=r.Links.map(i=>{let o={};try{o.Hash=yu.decode(i.Hash)}catch{}if(!o.Hash)throw new Error("Invalid Hash field found in link, expected CID");return i.Name!==void 0&&(o.Name=i.Name),i.Tsize!==void 0&&(o.Tsize=i.Tsize),o})),n}f();var VB=gt(Oc(),1);f();f();f();f();f();var y3e=Math.pow(2,7),g3e=Math.pow(2,14),v3e=Math.pow(2,21),vJ=Math.pow(2,28),bJ=Math.pow(2,35),wJ=Math.pow(2,42),_J=Math.pow(2,49),Sa=128,dm=127;function kx(t){if(tNumber.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function xJ(t,e,r=0){switch(kx(t)){case 8:e[r++]=t&255|Sa,t/=128;case 7:e[r++]=t&255|Sa,t/=128;case 6:e[r++]=t&255|Sa,t/=128;case 5:e[r++]=t&255|Sa,t/=128;case 4:e[r++]=t&255|Sa,t>>>=7;case 3:e[r++]=t&255|Sa,t>>>=7;case 2:e[r++]=t&255|Sa,t>>>=7;case 1:{e[r++]=t&255,t>>>=7;break}default:throw new Error("unreachable")}return e}function EJ(t,e){let r=t[e],n=0;if(n+=r&dm,r>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?e<16384?e<128?1:2:e<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return Z0;if(ew3e)return this.fromNumber(Number(e));let r=e<0n;r&&(e=-e);let n=e>>32n,i=e-(n<<32n);return r&&(n=~n|0n,i=~i|0n,++i>IJ&&(i=0n,++n>IJ&&(n=0n))),new t(Number(i),Number(n))}static fromNumber(e){if(e===0)return Z0;let r=e<0;r&&(e=-e);let n=e>>>0,i=(e-n)/4294967296>>>0;return r&&(i=~i>>>0,n=~n>>>0,++n>4294967295&&(n=0,++i>4294967295&&(i=0))),new t(n,i)}static from(e){return typeof e=="number"?t.fromNumber(e):typeof e=="bigint"?t.fromBigInt(e):typeof e=="string"?t.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new t(e.low>>>0,e.high>>>0):Z0}},Z0=new jc(0,0);Z0.toBigInt=function(){return 0n};Z0.zzEncode=Z0.zzDecode=function(){return this};Z0.length=function(){return 1};var IJ=4294967296n;f();function kJ(t){let e=0,r=0;for(let n=0;n191&&a<224?o[s++]=(a&31)<<6|t[e++]&63:a>239&&a<365?(a=((a&7)<<18|(t[e++]&63)<<12|(t[e++]&63)<<6|t[e++]&63)-65536,o[s++]=55296+(a>>10),o[s++]=56320+(a&1023)):o[s++]=(a&15)<<12|(t[e++]&63)<<6|t[e++]&63,s>8191&&((i??(i=[])).push(String.fromCharCode.apply(String,o)),s=0);return i!=null?(s>0&&i.push(String.fromCharCode.apply(String,o.slice(0,s))),i.join("")):String.fromCharCode.apply(String,o.slice(0,s))}function jB(t,e,r){let n=r,i,o;for(let s=0;s>6|192,e[r++]=i&63|128):(i&64512)===55296&&((o=t.charCodeAt(s+1))&64512)===56320?(i=65536+((i&1023)<<10)+(o&1023),++s,e[r++]=i>>18|240,e[r++]=i>>12&63|128,e[r++]=i>>6&63|128,e[r++]=i&63|128):(e[r++]=i>>12|224,e[r++]=i>>6&63|128,e[r++]=i&63|128);return r-n}function _u(t,e){return RangeError(`index out of range: ${t.pos} + ${e??1} > ${t.len}`)}function M8(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}var NB=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,_u(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw _u(this,4);return M8(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw _u(this,4);return M8(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw _u(this,4);let e=AJ(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw _u(this,4);let e=PJ(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),r=this.pos,n=this.pos+e;if(n>this.len)throw _u(this,e);return this.pos+=e,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let e=this.bytes();return RJ(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw _u(this,e);this.pos+=e}else do if(this.pos>=this.len)throw _u(this);while(this.buf[this.pos++]&128);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new jc(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(e.lo=(e.lo|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw _u(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<>>0,e}if(this.len-this.pos>4){for(;r<5;++r)if(e.hi=(e.hi|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return e}else for(;r<5;++r){if(this.pos>=this.len)throw _u(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw _u(this,8);let e=M8(this.buf,this.pos+=4),r=M8(this.buf,this.pos+=4);return new jc(e,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=EJ(this.buf,this.pos);return this.pos+=kx(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function UB(t){return new NB(t instanceof Uint8Array?t:t.subarray())}function Rx(t,e,r){let n=UB(t);return e.decode(n,void 0,r)}f();f();f();function qB(t){let e=t??8192,r=e>>>1,n,i=e;return function(s){if(s<1||s>r)return Ja(s);i+s>e&&(n=Ja(e),i=0);let a=n.subarray(i,i+=s);return i&7&&(i=(i|7)+1),a}}var Y0=class{fn;len;next;val;constructor(e,r,n){this.fn=e,this.len=r,this.next=void 0,this.val=n}};function LB(){}var FB=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},_3e=qB();function x3e(t){return globalThis.Buffer!=null?Ja(t):_3e(t)}var Bx=class{len;head;tail;states;constructor(){this.len=0,this.head=new Y0(LB,0,0),this.tail=this.head,this.states=null}_push(e,r,n){return this.tail=this.tail.next=new Y0(e,r,n),this.len+=r,this}uint32(e){return this.len+=(this.tail=this.tail.next=new zB((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(O8,10,jc.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let r=jc.fromBigInt(e);return this._push(O8,r.length(),r)}uint64Number(e){return this._push(xJ,kx(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let r=jc.fromBigInt(e).zzEncode();return this._push(O8,r.length(),r)}sint64Number(e){let r=jc.fromNumber(e).zzEncode();return this._push(O8,r.length(),r)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(KB,1,e?1:0)}fixed32(e){return this._push(Dx,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let r=jc.fromBigInt(e);return this._push(Dx,4,r.lo)._push(Dx,4,r.hi)}fixed64Number(e){let r=jc.fromNumber(e);return this._push(Dx,4,r.lo)._push(Dx,4,r.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(SJ,4,e)}double(e){return this._push(TJ,8,e)}bytes(e){let r=e.length>>>0;return r===0?this._push(KB,1,0):this.uint32(r)._push(S3e,r,e)}string(e){let r=kJ(e);return r!==0?this.uint32(r)._push(jB,r,e):this._push(KB,1,0)}fork(){return this.states=new FB(this),this.head=this.tail=new Y0(LB,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new Y0(LB,0,0),this.len=0),this}ldelim(){let e=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=r,this.len+=n),this}finish(){let e=this.head.next,r=x3e(this.len),n=0;for(;e!=null;)e.fn(e.val,r,n),n+=e.len,e=e.next;return r}};function KB(t,e,r){e[r]=t&255}function E3e(t,e,r){for(;t>127;)e[r++]=t&127|128,t>>>=7;e[r]=t}var zB=class extends Y0{next;constructor(e,r){super(E3e,e,r),this.next=void 0}};function O8(t,e,r){for(;t.hi!==0;)e[r++]=t.lo&127|128,t.lo=(t.lo>>>7|t.hi<<25)>>>0,t.hi>>>=7;for(;t.lo>127;)e[r++]=t.lo&127|128,t.lo=t.lo>>>7;e[r++]=t.lo}function Dx(t,e,r){e[r]=t&255,e[r+1]=t>>>8&255,e[r+2]=t>>>16&255,e[r+3]=t>>>24}function S3e(t,e,r){e.set(t,r)}globalThis.Buffer!=null&&(Bx.prototype.bytes=function(t){let e=t.length>>>0;return this.uint32(e),e>0&&this._push(A3e,e,t),this},Bx.prototype.string=function(t){let e=globalThis.Buffer.byteLength(t);return this.uint32(e),e>0&&this._push(T3e,e,t),this});function A3e(t,e,r){e.set(t,r)}function T3e(t,e,r){t.length<40?jB(t,e,r):e.utf8Write!=null?e.utf8Write(t,r):e.set(U0(t),r)}function WB(){return new Bx}function Mx(t,e){let r=WB();return e.encode(t,r,{lengthDelimited:!1}),r.finish()}f();f();var ww;(function(t){t[t.VARINT=0]="VARINT",t[t.BIT64=1]="BIT64",t[t.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",t[t.START_GROUP=3]="START_GROUP",t[t.END_GROUP=4]="END_GROUP",t[t.BIT32=5]="BIT32"})(ww||(ww={}));function C8(t,e,r,n){return{name:t,type:e,encode:r,decode:n}}function HB(t){function e(i){if(t[i.toString()]==null)throw new Error("Invalid enum value");return t[i]}let r=function(o,s){let a=e(o);s.int32(a)},n=function(o){let s=o.int32();return e(s)};return C8("enum",ww.VARINT,r,n)}f();function Ox(t,e){return C8("message",ww.LENGTH_DELIMITED,t,e)}var xu;(function(t){let e;(function(i){i.Raw="Raw",i.Directory="Directory",i.File="File",i.Metadata="Metadata",i.Symlink="Symlink",i.HAMTShard="HAMTShard"})(e=t.DataType||(t.DataType={}));let r;(function(i){i[i.Raw=0]="Raw",i[i.Directory=1]="Directory",i[i.File=2]="File",i[i.Metadata=3]="Metadata",i[i.Symlink=4]="Symlink",i[i.HAMTShard=5]="HAMTShard"})(r||(r={})),function(i){i.codec=()=>HB(r)}(e=t.DataType||(t.DataType={}));let n;t.codec=()=>(n==null&&(n=Ox((i,o,s={})=>{if(s.lengthDelimited!==!1&&o.fork(),i.Type!=null&&(o.uint32(8),t.DataType.codec().encode(i.Type,o)),i.Data!=null&&(o.uint32(18),o.bytes(i.Data)),i.filesize!=null&&(o.uint32(24),o.uint64(i.filesize)),i.blocksizes!=null)for(let a of i.blocksizes)o.uint32(32),o.uint64(a);i.hashType!=null&&(o.uint32(40),o.uint64(i.hashType)),i.fanout!=null&&(o.uint32(48),o.uint64(i.fanout)),i.mode!=null&&(o.uint32(56),o.uint32(i.mode)),i.mtime!=null&&(o.uint32(66),$8.codec().encode(i.mtime,o)),s.lengthDelimited!==!1&&o.ldelim()},(i,o)=>{let s={blocksizes:[]},a=o==null?i.len:i.pos+o;for(;i.pos>>3){case 1:s.Type=t.DataType.codec().decode(i);break;case 2:s.Data=i.bytes();break;case 3:s.filesize=i.uint64();break;case 4:s.blocksizes.push(i.uint64());break;case 5:s.hashType=i.uint64();break;case 6:s.fanout=i.uint64();break;case 7:s.mode=i.uint32();break;case 8:s.mtime=$8.codec().decode(i,i.uint32());break;default:i.skipType(d&7);break}}return s})),n),t.encode=i=>Mx(i,t.codec()),t.decode=i=>Rx(i,t.codec())})(xu||(xu={}));var $8;(function(t){let e;t.codec=()=>(e==null&&(e=Ox((r,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),r.Seconds!=null&&(n.uint32(8),n.int64(r.Seconds)),r.FractionalNanoseconds!=null&&(n.uint32(21),n.fixed32(r.FractionalNanoseconds)),i.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{let i={},o=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:i.Seconds=r.int64();break;case 2:i.FractionalNanoseconds=r.fixed32();break;default:r.skipType(s&7);break}}return i})),e),t.encode=r=>Mx(r,t.codec()),t.decode=r=>Rx(r,t.codec())})($8||($8={}));var BJ;(function(t){let e;t.codec=()=>(e==null&&(e=Ox((r,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),r.MimeType!=null&&(n.uint32(10),n.string(r.MimeType)),i.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{let i={},o=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:i.MimeType=r.string();break;default:r.skipType(s&7);break}}return i})),e),t.encode=r=>Mx(r,t.codec()),t.decode=r=>Rx(r,t.codec())})(BJ||(BJ={}));var MJ={Raw:"raw",Directory:"directory",File:"file",Metadata:"metadata",Symlink:"symlink",HAMTShard:"hamt-sharded-directory"},P3e=["directory","hamt-sharded-directory"],OJ=parseInt("0644",8),CJ=parseInt("0755",8),Ro=class t{static unmarshal(e){let r=xu.decode(e),n=new t({type:MJ[r.Type!=null?r.Type.toString():"File"],data:r.Data,blockSizes:r.blocksizes,mode:r.mode,mtime:r.mtime!=null?{secs:r.mtime.Seconds??0n,nsecs:r.mtime.FractionalNanoseconds}:void 0,fanout:r.fanout});return n._originalMode=r.mode??0,n}type;data;blockSizes;hashType;fanout;mtime;_mode;_originalMode;constructor(e={type:"file"}){let{type:r,data:n,blockSizes:i,hashType:o,fanout:s,mtime:a,mode:d}=e;if(r!=null&&!Object.values(MJ).includes(r))throw(0,VB.default)(new Error("Type: "+r+" is not valid"),"ERR_INVALID_TYPE");this.type=r??"file",this.data=n,this.hashType=o,this.fanout=s,this.blockSizes=i??[],this._originalMode=0,this.mode=d,this.mtime=a}set mode(e){e==null?this._mode=this.isDirectory()?CJ:OJ:this._mode=e&4095}get mode(){return this._mode}isDirectory(){return P3e.includes(this.type)}addBlockSize(e){this.blockSizes.push(e)}removeBlockSize(e){this.blockSizes.splice(e,1)}fileSize(){if(this.isDirectory())return 0n;let e=0n;return this.blockSizes.forEach(r=>{e+=r}),this.data!=null&&(e+=BigInt(this.data.length)),e}marshal(){let e;switch(this.type){case"raw":e=xu.DataType.Raw;break;case"directory":e=xu.DataType.Directory;break;case"file":e=xu.DataType.File;break;case"metadata":e=xu.DataType.Metadata;break;case"symlink":e=xu.DataType.Symlink;break;case"hamt-sharded-directory":e=xu.DataType.HAMTShard;break;default:throw(0,VB.default)(new Error(`Type: ${e} is not valid`),"ERR_INVALID_TYPE")}let r=this.data;(this.data==null||this.data.length===0)&&(r=void 0);let n;this.mode!=null&&(n=this._originalMode&4294963200|(this.mode??0),n===OJ&&!this.isDirectory()&&(n=void 0),n===CJ&&this.isDirectory()&&(n=void 0));let i;return this.mtime!=null&&(i={Seconds:this.mtime.secs,FractionalNanoseconds:this.mtime.nsecs}),xu.encode({Type:e,Data:r,filesize:this.isDirectory()?void 0:this.fileSize(),blocksizes:this.blockSizes,hashType:this.hashType,fanout:this.fanout,mode:n,mtime:i})}};var _w={};Pr(_w,{code:()=>lm,decode:()=>R3e,encode:()=>k3e,name:()=>I3e});f();var I3e="raw",lm=85,k3e=t=>pu(t),R3e=t=>pu(t);f();var vi=class extends Event{type;detail;constructor(e,r){super(e),this.type=e,this.detail=r}};f();var Eu=async(t,e,r)=>{r.codec==null&&(r.codec=J0);let n=await Us.digest(t),i=Nr.create(r.cidVersion,r.codec.code,n);return await e.put(i,t,r),i};function $J(t){return async function*(r,n){let i=0n;for await(let o of r.content)yield async()=>{let s,a={codec:J0,cidVersion:t.cidVersion,onProgress:t.onProgress};t.rawLeaves?(a.codec=_w,a.cidVersion=1):(s=new Ro({type:t.leafType,data:o}),o=$c({Data:s.marshal(),Links:[]}));let d=await Eu(o,n,a);return i+=BigInt(o.byteLength),t.onProgress?.(new vi("unixfs:importer:progress:file:write",{bytesWritten:i,cid:d,path:r.path})),{cid:d,unixfs:s,size:BigInt(o.length),block:o}}}}f();var GB=gt(Oc(),1);f();var jJ=async(t,e,r)=>{let n=new Ro({type:"directory",mtime:t.mtime,mode:t.mode}),i=$c(Cc({Data:n.marshal()})),o=await Eu(i,e,r),s=t.path;return{cid:o,path:s,unixfs:n,size:BigInt(i.length),originalPath:t.originalPath,block:i}};f();async function*D3e(t,e,r){let n=-1,i;for await(let o of Tx(r.bufferImporter(t,e),r.blockWriteConcurrency)){if(n++,n===0){i={...o,single:!0};continue}else n===1&&i!=null&&(yield{...i,block:void 0,single:void 0},i=void 0);yield{...o,block:void 0}}i!=null&&(yield i)}function NJ(t){return t.single===!0}var B3e=(t,e,r)=>async function(i){if(i.length===1&&NJ(i[0])&&r.reduceSingleLeafToSelf){let c=i[0],l=c.block;return NJ(c)&&(t.mtime!==void 0||t.mode!==void 0)&&(c.unixfs=new Ro({type:"file",mtime:t.mtime,mode:t.mode,data:c.block}),l={Data:c.unixfs.marshal(),Links:[]},c.block=$c(Cc(l)),c.cid=await Eu(c.block,e,{...r,cidVersion:r.cidVersion}),c.size=BigInt(c.block.length)),r.onProgress?.(new vi("unixfs:importer:progress:file:layout",{cid:c.cid,path:c.originalPath})),{cid:c.cid,path:t.path,unixfs:c.unixfs,size:c.size,originalPath:c.originalPath}}let o=new Ro({type:"file",mtime:t.mtime,mode:t.mode}),s=i.filter(c=>c.cid.code===lm&&c.size>0||c.unixfs!=null&&c.unixfs.data==null&&c.unixfs.fileSize()>0n?!0:!!c.unixfs?.data?.length).map(c=>c.cid.code===lm?(o.addBlockSize(c.size),{Name:"",Tsize:Number(c.size),Hash:c.cid}):(c.unixfs==null||c.unixfs.data==null?o.addBlockSize(c.unixfs?.fileSize()??0n):o.addBlockSize(BigInt(c.unixfs.data.length)),{Name:"",Tsize:Number(c.size),Hash:c.cid})),a={Data:o.marshal(),Links:s},d=$c(Cc(a)),u=await Eu(d,e,r);return r.onProgress?.(new vi("unixfs:importer:progress:file:layout",{cid:u,path:t.originalPath})),{cid:u,path:t.path,unixfs:o,size:BigInt(d.length+a.Links.reduce((c,l)=>c+(l.Tsize??0),0)),originalPath:t.originalPath,block:d}},UJ=async(t,e,r)=>r.layout(D3e(t,e,r),B3e(t,e,r));function M3e(t){return Symbol.iterator in t}function O3e(t){return Symbol.asyncIterator in t}function C3e(t){try{if(t instanceof Uint8Array)return async function*(){yield t}();if(M3e(t))return async function*(){yield*t}();if(O3e(t))return t}catch{throw(0,GB.default)(new Error("Content was invalid"),"ERR_INVALID_CONTENT")}throw(0,GB.default)(new Error("Content was invalid"),"ERR_INVALID_CONTENT")}function qJ(t){return async function*(r,n){for await(let i of r){let o;if(i.path!=null&&(o=i.path,i.path=i.path.split("/").filter(s=>s!=null&&s!==".").join("/")),$3e(i)){let s={path:i.path,mtime:i.mtime,mode:i.mode,content:async function*(){let a=0n;for await(let d of t.chunker(t.chunkValidator(C3e(i.content)))){let u=BigInt(d.byteLength);a+=u,t.onProgress?.(new vi("unixfs:importer:progress:file:read",{bytesRead:a,chunkSize:u,path:i.path})),yield d}}(),originalPath:o};yield async()=>UJ(s,n,t)}else if(i.path!=null){let s={path:i.path,mtime:i.mtime,mode:i.mode,originalPath:o};yield async()=>jJ(s,n,t)}else throw new Error("Import candidate must have content or path or both")}}}function $3e(t){return t.content!=null}f();var d7=gt(Oc(),1);f();f();function j8(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}f();f();var JB={};Pr(JB,{base10:()=>j3e});f();var j3e=am({prefix:"9",name:"base10",alphabet:"0123456789"});var ZB={};Pr(ZB,{base16:()=>N3e,base16upper:()=>U3e});f();var N3e=gi({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),U3e=gi({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var YB={};Pr(YB,{base2:()=>q3e});f();var q3e=gi({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var XB={};Pr(XB,{base256emoji:()=>W3e});f();var LJ=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),L3e=LJ.reduce((t,e,r)=>(t[r]=e,t),[]),K3e=LJ.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function F3e(t){return t.reduce((e,r)=>(e+=L3e[r],e),"")}function z3e(t){let e=[];for(let r of t){let n=K3e[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}var W3e=hw({prefix:"\u{1F680}",name:"base256emoji",encode:F3e,decode:z3e});var QB={};Pr(QB,{base36:()=>H3e,base36upper:()=>V3e});f();var H3e=am({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),V3e=am({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var e7={};Pr(e7,{base64:()=>G3e,base64pad:()=>J3e,base64url:()=>xw,base64urlpad:()=>Z3e});f();var G3e=gi({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),J3e=gi({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),xw=gi({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Z3e=gi({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var t7={};Pr(t7,{base8:()=>Y3e});f();var Y3e=gi({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var r7={};Pr(r7,{identity:()=>X3e});f();var X3e=hw({prefix:"\0",name:"identity",encode:t=>LG(t),decode:t=>qG(t)});f();var Yht=new TextEncoder,Xht=new TextDecoder;f();var n7={};Pr(n7,{identity:()=>n5e});f();var KJ=0,t5e="identity",FJ=sh,r5e=t=>V0(KJ,FJ(t)),n5e={code:KJ,name:t5e,encode:FJ,digest:r5e};var s7={};Pr(s7,{sha256:()=>Cx,sha512:()=>i5e});f();f();var o7=({name:t,code:e,encode:r})=>new i7(t,e,r),i7=class{constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?V0(this.code,r):r.then(n=>V0(this.code,n))}else throw Error("Unknown type, must be binary type")}};var WJ=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),Cx=o7({name:"sha2-256",code:18,encode:WJ("SHA-256")}),i5e=o7({name:"sha2-512",code:19,encode:WJ("SHA-512")});f();f();var a7={...r7,...YB,...t7,...JB,...ZB,...TB,...QB,...PB,...e7,...XB},hpt={...s7,...n7};f();function HJ(t=0){return globalThis.Buffer?.allocUnsafe!=null?j8(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function GJ(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var VJ=GJ("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),c7=GJ("ascii","a",t=>{let e="a";for(let r=0;r{t=t.substring(1);let e=HJ(t.length);for(let r=0;rasync function*(e){for await(let r of e){if(r.length===void 0)throw(0,d7.default)(new Error("Content was invalid"),"ERR_INVALID_CONTENT");if(typeof r=="string"||r instanceof String)yield ZJ(r.toString());else if(Array.isArray(r))yield Uint8Array.from(r);else if(r instanceof Uint8Array)yield r;else throw(0,d7.default)(new Error("Content was invalid"),"ERR_INVALID_CONTENT")}};f();f();var s5e=174;function u7(t){let e=t?.maxChildrenPerNode??s5e;return async function r(n,i){let o=[];for await(let s of Ax(n,e))o.push(await i(s));return o.length>1?r(o,i):o[0]}}f();f();f();f();f();f();var Rl=class{options;root;dir;path;dirty;flat;parent;parentKey;unixfs;mode;mtime;cid;size;nodeSize;constructor(e,r){this.options=r??{},this.root=e.root,this.dir=e.dir,this.path=e.path,this.dirty=e.dirty,this.flat=e.flat,this.parent=e.parent,this.parentKey=e.parentKey,this.unixfs=e.unixfs,this.mode=e.mode,this.mtime=e.mtime}},$x=Nr.parse("QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn"),jx=Nr.parse("zdj7WbTaiJT1fgatdet9Ei9iDB5hdCxkbVyhyh8YTUnXMiwYi");var X0=class extends Rl{_children;constructor(e,r){super(e,r),this._children=new Map}async put(e,r){this.cid=void 0,this.size=void 0,this.nodeSize=void 0,this._children.set(e,r)}async get(e){return Promise.resolve(this._children.get(e))}childCount(){return this._children.size}directChildrenCount(){return this.childCount()}onlyChild(){return this._children.values().next().value}async*eachChildSeries(){for(let[e,r]of this._children.entries())yield{key:e,child:r}}estimateNodeSize(){if(this.nodeSize!==void 0)return this.nodeSize;this.nodeSize=0;for(let[e,r]of this._children.entries())r.size!=null&&r.cid!=null&&(this.nodeSize+=e.length+(this.options.cidVersion===1?jx.bytes.byteLength:$x.bytes.byteLength));return this.nodeSize}async*flush(e){let r=[];for(let[d,u]of this._children.entries()){let c=u;if(u instanceof Rl)for await(let l of u.flush(e))c=l,yield l;c.size!=null&&c.cid!=null&&r.push({Name:d,Tsize:Number(c.size),Hash:c.cid})}let n=new Ro({type:"directory",mtime:this.mtime,mode:this.mode}),i={Data:n.marshal(),Links:r},o=$c(Cc(i)),s=await Eu(o,e,this.options),a=o.length+i.Links.reduce((d,u)=>d+(u.Tsize==null?0:u.Tsize),0);this.cid=s,this.size=a,yield{cid:s,unixfs:n,path:this.path,size:BigInt(a)}}};f();f();f();var U8=gt(eZ(),1);function a5e(t){let e=new Array(4);for(let r=0;r<4;r++)e[r]=t&255,t=t>>8;return new Uint8Array(e)}var dmt=N0({name:"murmur3-32",code:35,encode:t=>a5e(U8.default.x86.hash32(t))}),q8=N0({name:"murmur3-128",code:34,encode:t=>Xb.fromHex(U8.default.x64.hash128(t))}),umt=N0({name:"murmur3-x64-64",code:34,encode:t=>Xb.fromHex(U8.default.x64.hash128(t)).subarray(0,8)});f();f();var iZ=gt(nZ(),1);var Dl=class t{_options;_popCount;_parent;_posAtParent;_children;key;constructor(e,r,n=0){this._options=e,this._popCount=0,this._parent=r,this._posAtParent=n,this._children=new iZ.default,this.key=null}async put(e,r){let n=await this._findNewBucketAndPos(e);n.bucket._putAt(n,e,r)}async get(e){let r=await this._findChild(e);if(r!=null)return r.value}async del(e){let r=await this._findPlace(e),n=r.bucket._at(r.pos);n!=null&&n.key===e&&r.bucket._delAt(r.pos)}leafCount(){return this._children.compactArray().reduce((r,n)=>n instanceof t?r+n.leafCount():r+1,0)}childrenCount(){return this._children.length}onlyChild(){return this._children.get(0)}*eachLeafSeries(){let e=this._children.compactArray();for(let r of e)r instanceof t?yield*r.eachLeafSeries():yield r}serialize(e,r){let n=[];return r(this._children.reduce((i,o,s)=>(o!=null&&(o instanceof t?i.push(o.serialize(e,r)):i.push(e(o,s))),i),n))}async asyncTransform(e,r){return oZ(this,e,r)}toJSON(){return this.serialize(f5e,h5e)}prettyPrint(){return JSON.stringify(this.toJSON(),null," ")}tableSize(){return Math.pow(2,this._options.bits)}async _findChild(e){let r=await this._findPlace(e),n=r.bucket._at(r.pos);if(!(n instanceof t)&&n!=null&&n.key===e)return n}async _findPlace(e){let r=this._options.hash(typeof e=="string"?U0(e):e),n=await r.take(this._options.bits),i=this._children.get(n);return i instanceof t?i._findPlace(r):{bucket:this,pos:n,hash:r,existingChild:i}}async _findNewBucketAndPos(e){let r=await this._findPlace(e);if(r.existingChild!=null&&r.existingChild.key!==e){let n=new t(this._options,r.bucket,r.pos);r.bucket._putObjectAt(r.pos,n);let i=await n._findPlace(r.existingChild.hash);return i.bucket._putAt(i,r.existingChild.key,r.existingChild.value),n._findNewBucketAndPos(r.hash)}return r}_putAt(e,r,n){this._putObjectAt(e.pos,{key:r,value:n,hash:e.hash})}_putObjectAt(e,r){this._children.get(e)==null&&this._popCount++,this._children.set(e,r)}_delAt(e){if(e===-1)throw new Error("Invalid position");this._children.get(e)!=null&&this._popCount--,this._children.unset(e),this._level()}_level(){if(this._parent!=null&&this._popCount<=1)if(this._popCount===1){let e=this._children.find(l5e);if(e!=null&&!(e instanceof t)){let r=e.hash;r.untake(this._options.bits);let n={pos:this._posAtParent,hash:r,bucket:this._parent};this._parent._putAt(n,e.key,e.value)}}else this._parent._delAt(this._posAtParent)}_at(e){return this._children.get(e)}};function l5e(t){return!!t}function f5e(t,e){return t.key}function h5e(t){return t}async function oZ(t,e,r){let n=[];for(let i of t._children.compactArray())if(i instanceof Dl)await oZ(i,e,r);else{let o=await e(i);n.push({bitField:t._children.bitField(),children:o})}return r(n)}f();f();var p5e=[255,254,252,248,240,224,192,128],m5e=[1,3,7,15,31,63,127,255],L8=class{_value;_currentBytePos;_currentBitPos;constructor(e){this._value=e,this._currentBytePos=e.length-1,this._currentBitPos=7}availableBits(){return this._currentBitPos+1+this._currentBytePos*8}totalBits(){return this._value.length*8}take(e){let r=e,n=0;for(;r>0&&this._haveBits();){let i=this._value[this._currentBytePos],o=this._currentBitPos+1,s=Math.min(o,r),a=y5e(i,o-s,s);n=(n<7;)this._currentBitPos-=8,this._currentBytePos+=1}_haveBits(){return this._currentBytePos>=0}};function y5e(t,e,r){let n=g5e(e,r);return(t&n)>>>e}function g5e(t,e){return p5e[t]&m5e[Math.min(e+t-1,7)]}function sZ(t){function e(r){return r instanceof K8?r:new K8(r,t)}return e}var K8=class{_value;_hashFn;_depth;_availableBits;_currentBufferIndex;_buffers;constructor(e,r){if(!(e instanceof Uint8Array))throw new Error("can only hash Uint8Arrays");this._value=e,this._hashFn=r,this._depth=-1,this._availableBits=0,this._currentBufferIndex=0,this._buffers=[]}async take(e){let r=e;for(;this._availableBits0;){let i=this._buffers[this._currentBufferIndex],o=Math.min(i.availableBits(),r),s=i.take(o);n=(n<0;){let n=this._buffers[this._currentBufferIndex],i=Math.min(n.totalBits()-n.availableBits(),r);n.untake(i),r-=i,this._availableBits+=i,this._currentBufferIndex>0&&n.totalBits()===n.availableBits()&&(this._depth--,this._currentBufferIndex--)}}async _produceMoreBits(){this._depth++;let e=this._depth>0?Yb([this._value,Uint8Array.from([this._depth])]):this._value,r=await this._hashFn(e),n=new L8(r);this._buffers.push(n),this._availableBits+=n.availableBits()}};function F8(t){if(t==null||t.hashFn==null)throw new Error("please define an options.hashFn");let e={bits:t.bits??8,hash:sZ(t.hashFn)};return new Dl(e)}async function v5e(t){return(await q8.encode(t)).slice(0,8).reverse()}var aZ=BigInt(34),l7=class extends Rl{_bucket;constructor(e,r){super(e,r),this._bucket=F8({hashFn:v5e,bits:8})}async put(e,r){this.cid=void 0,this.size=void 0,this.nodeSize=void 0,await this._bucket.put(e,r)}async get(e){return this._bucket.get(e)}childCount(){return this._bucket.leafCount()}directChildrenCount(){return this._bucket.childrenCount()}onlyChild(){return this._bucket.onlyChild()}async*eachChildSeries(){for await(let{key:e,value:r}of this._bucket.eachLeafSeries())yield{key:e,child:r}}estimateNodeSize(){return this.nodeSize!==void 0?this.nodeSize:(this.nodeSize=uZ(this._bucket,this,this.options),this.nodeSize)}async*flush(e){for await(let r of dZ(this._bucket,e,this,this.options))yield{...r,path:this.path}}},cZ=l7;async function*dZ(t,e,r,n){let i=t._children,o=[],s=0n;for(let m=0;mr&&(i=await w5e(e,n));let o=i.parent;if(o!=null){if(i!==e){if(t!=null&&(t.parent=i),i.parentKey==null)throw new Error("No parent key found");await o.put(i.parentKey,i)}return f7(i,o,r,n)}return i}async function w5e(t,e){let r=new cZ({root:t.root,dir:!0,parent:t.parent,parentKey:t.parentKey,path:t.path,dirty:t.dirty,flat:!1,mtime:t.mtime,mode:t.mode},e);for await(let{key:n,child:i}of t.eachChildSeries())await r.put(n,i);return r}f();var lZ=(t="")=>(t.trim().match(/([^\\/]|\\\/)+/g)??[]).filter(Boolean);async function _5e(t,e,r){let n=lZ(t.path??""),i=n.length-1,o=e,s="";for(let a=0;a1)yield*fZ(i,n);else for await(let a of i.eachChildSeries())a!=null&&(yield*fZ(a.child,n))}}async function*Ux(t,e,r={}){let n;Symbol.asyncIterator in t||Symbol.iterator in t?n=t:n=[t];let i=r.wrapWithDirectory??!1,o=r.shardSplitThresholdBytes??262144,s=r.cidVersion??1,a=r.rawLeaves??!0,d=r.leafType??"file",u=r.fileImportConcurrency??50,c=r.blockWriteConcurrency??10,l=r.reduceSingleLeafToSelf??!0,p=r.chunker??sJ(),m=r.chunkValidator??YJ(),g=r.dagBuilder??qJ({chunker:p,chunkValidator:m,wrapWithDirectory:i,layout:r.layout??u7(),bufferImporter:r.bufferImporter??$J({cidVersion:s,rawLeaves:a,leafType:d,onProgress:r.onProgress}),blockWriteConcurrency:c,reduceSingleLeafToSelf:l,cidVersion:s,onProgress:r.onProgress}),v=r.treeBuilder??hZ({wrapWithDirectory:i,shardSplitThresholdBytes:o,cidVersion:s,onProgress:r.onProgress});for await(let x of v(Tx(g(n,e),u),e))yield{cid:x.cid,path:x.path,unixfs:x.unixfs,size:x.size}}var h7=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},pZ=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,d){s=t[o](s),i(a,d,s.done,s.value)})}}function i(o,s,a,d){Promise.resolve(d).then(function(u){o({value:u,done:a})},s)}},mZ={[Us.code]:Us},yZ={[_x]:G0},hn=class{static computeCid(e,r=_x,n=Us.code){return h7(this,void 0,void 0,function*(){let i=yZ[r];if(!i)throw new de(oe.ComputeCidCodecNotSupported,`codec [${r}] not supported`);let o=mZ[n];if(!o)throw new de(oe.ComputeCidMultihashNotSupported,`multihash code [${n}] not supported`);let s=i.encode(e),a=yield o.digest(s);return(yield Nr.createV1(i.code,a)).toString()})}static parseCid(e){let r=Nr.parse(e).toV1();if(!yZ[r.code])throw new de(oe.ParseCidCodecNotSupported,`codec [${r.code}] not supported`);if(!mZ[r.multihash.code])throw new de(oe.ParseCidMultihashNotSupported,`multihash code [${r.multihash.code}] not supported`);return r}static computeDagPbCidFromBytes(e){var r,n,i,o;return h7(this,void 0,void 0,function*(){let s=Ux([{content:e}],new Sx,{cidVersion:1}),a;try{for(var d=!0,u=pZ(s),c;c=yield u.next(),r=c.done,!r;d=!0)o=c.value,d=!1,a=o}catch(l){n={error:l}}finally{try{!d&&!r&&(i=u.return)&&(yield i.call(u))}finally{if(n)throw n.error}}return a?a.cid.toString():""})}static computeDagPbCidFromStream(e){var r,n,i,o;return h7(this,void 0,void 0,function*(){let s=Ux([{content:e}],new Sx,{cidVersion:1}),a;try{for(var d=!0,u=pZ(s),c;c=yield u.next(),r=c.done,!r;d=!0)o=c.value,d=!1,a=o}catch(l){n={error:l}}finally{try{!d&&!r&&(i=u.return)&&(yield i.call(u))}finally{if(n)throw n.error}}return a?a.cid.toString():""})}};f();var HT=gt(qA(),1),Hm=gt(Dse(),1),Tj=gt(M1(),1),WT=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})};Hm.ECIES_CONFIG.isEphemeralKeyCompressed=!0;var $h=class t{static aes256CtrEncrypt(e,r,n){return WT(this,void 0,void 0,function*(){let i=HT.createCipheriv("aes-256-ctr",e,r),o=new Tj.Readable({read(){}});return n.on("data",s=>{let a=i.update(s);o.push(a)}),n.on("end",()=>{let s=i.final();o.push(s),o.push(null)}),n.on("error",s=>{o.emit("error",s)}),o})}static aes256CtrDecrypt(e,r,n){return WT(this,void 0,void 0,function*(){let i=HT.createDecipheriv("aes-256-ctr",e,r),o=new Tj.Readable({read(){}});return n.on("data",s=>{let a=i.update(s);o.push(a)}),n.on("end",()=>{let s=i.final();o.push(s),o.push(null)}),n.on("error",s=>{o.emit("error",s)}),o})}static eciesSecp256k1Encrypt(e,r){return WT(this,void 0,void 0,function*(){let n=O.Buffer.from(e),i=O.Buffer.from(r),o=Hm.encrypt(n,i),s=0,a=t.isEphemeralKeyCompressed?33:65,d=o.subarray(s,a);s=a,a+=Hm.ECIES_CONFIG.symmetricNonceLength;let u=o.subarray(s,a);s=a,a+=16;let c=o.subarray(s,a);return{ciphertext:o.subarray(a),ephemeralPublicKey:d,initializationVector:u,messageAuthenticationCode:c}})}static eciesSecp256k1Decrypt(e){return WT(this,void 0,void 0,function*(){let r=O.Buffer.from(e.privateKey),n=O.Buffer.concat([e.ephemeralPublicKey,e.initializationVector,e.messageAuthenticationCode,e.ciphertext]);return Hm.decrypt(r,n)})}static get isEphemeralKeyCompressed(){return Hm.ECIES_CONFIG.isEphemeralKeyCompressed}},Vg;(function(t){t.Aes256Ctr="A256CTR",t.EciesSecp256k1="ECIES-ES256K"})(Vg||(Vg={}));f();var wde=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Gg=class t{constructor(e){this.jws=e}static create(e,r=[]){return wde(this,void 0,void 0,function*(){let n={payload:qe.bytesToBase64Url(e),signatures:[]},i=new t(n);for(let o of r)yield i.addSignature(o);return i})}addSignature(e){return wde(this,void 0,void 0,function*(){let r={kid:e.keyId,alg:e.algorithm},n=JSON.stringify(r),i=qe.stringToBase64Url(n),o=`${i}.${this.jws.payload}`,s=qe.stringToBytes(o),a=yield e.sign(s),d=qe.bytesToBase64Url(a);this.jws.signatures.push({protected:i,signature:d})})}getJws(){return this.jws}};f();f();f();var VT=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function us(){if(VT&&typeof VT.subtle=="object"&&VT.subtle!=null)return VT.subtle;throw new Error("crypto.subtle must be defined")}f();f();function l6(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function Pj(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}function Ij(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function ao(t,...e){if(!Ij(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 kj(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 _de(t,e){ao(t);let r=e.outputLen;if(t.lengthnew Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),xde=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),VUe=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!VUe)throw new Error("Non little-endian hardware is not supported");function GUe(t){if(typeof t!="string")throw new Error(`string expected, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function GT(t){if(typeof t=="string")t=GUe(t);else if(Ij(t))t=t.slice();else throw new Error(`Uint8Array expected, got ${typeof t}`);return t}function Ede(t,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(t,e)}function Sde(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n(Object.assign(e,t),e);function Dj(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),d=n?4:0,u=n?0:4;t.setUint32(e+d,s,n),t.setUint32(e+u,a,n)}var Ade={async encrypt(t,e,r,n){let i=us(),o=await i.importKey("raw",t,e,!0,["encrypt"]),s=await i.encrypt(r,o,n);return new Uint8Array(s)},async decrypt(t,e,r,n){let i=us(),o=await i.importKey("raw",t,e,!0,["decrypt"]),s=await i.decrypt(r,o,n);return new Uint8Array(s)}},tf={CBC:"AES-CBC",CTR:"AES-CTR",GCM:"AES-GCM"};function JUe(t,e,r){if(t===tf.CBC)return{name:tf.CBC,iv:e};if(t===tf.CTR)return{name:tf.CTR,counter:e,length:64};if(t===tf.GCM)return r?{name:tf.GCM,iv:e,additionalData:r}:{name:tf.GCM,iv:e};throw new Error("unknown aes block mode")}function Bj(t){return(e,r,n)=>{ao(e),ao(r);let i={name:t,length:e.length*8},o=JUe(t,r,n);return{encrypt(s){return ao(s),Ade.encrypt(e,i,o,s)},decrypt(s){return ao(s),Ade.decrypt(e,i,o,s)}}}}var rxt=Bj(tf.CBC),nxt=Bj(tf.CTR),ixt=Bj(tf.GCM);var JT=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},co;(function(t){t.DataFormats="dataFormats",t.ProtocolContext="protocolContext",t.ProtocolPath="protocolPath",t.Schemas="schemas"})(co||(co={}));var Jg=class t{static derivePrivateKey(e,r){var n;return JT(this,void 0,void 0,function*(){let i=Ki.privateJwkToBytes(e.derivedPrivateKey),o=(n=e.derivationPath)!==null&&n!==void 0?n:[],s=yield t.derivePrivateKeyBytes(i,r),a=yield Ki.privateKeyToJwk(s);return{rootKeyId:e.rootKeyId,derivationScheme:e.derivationScheme,derivationPath:[...o,...r],derivedPrivateKey:a}})}static derivePublicKey(e,r){return JT(this,void 0,void 0,function*(){let n=yield t.derivePrivateKey(e,r);return yield Ki.getPublicJwk(n.derivedPrivateKey)})}static derivePrivateKeyBytes(e,r){return JT(this,void 0,void 0,function*(){t.validateKeyDerivationPath(r);let n=e;for(let i of r){let o=qe.stringToBytes(i);n=yield t.deriveKeyUsingHkdf({hashAlgorithm:"SHA-256",initialKeyMaterial:n,info:o,keyLengthInBytes:32})}return n})}static deriveKeyUsingHkdf(e){return JT(this,void 0,void 0,function*(){let{hashAlgorithm:r,initialKeyMaterial:n,info:i,keyLengthInBytes:o}=e,a=yield us().importKey("raw",n,{name:"HKDF"},!1,["deriveBits"]),d=yield crypto.subtle.deriveBits({name:"HKDF",hash:r,salt:new Uint8Array(0),info:i},a,o*8);return new Uint8Array(d)})}static validateKeyDerivationPath(e){if(e.includes(""))throw new de(oe.HdKeyDerivationPathInvalid,`Invalid key derivation path: ${e}`)}};f();f();function f6(t,e){return t>e?1:t{t[e]===void 0?delete t[e]:typeof t[e]=="object"&&Pn(t[e])})}var rf=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},_e=class t{static getAuthor(e){if(e.authorization===void 0)return;let r;return e.authorization.authorDelegatedGrant!==void 0?r=t.getSigner(e.authorization.authorDelegatedGrant):r=t.getSigner(e),r}static validateJsonSchema(e){let r=e.descriptor.interface,n=e.descriptor.method,i=r+n;ih(i,e)}static getSigner(e){return e.authorization===void 0?void 0:Vr.getSignerDid(e.authorization.signature.signatures[0])}static getCid(e){return rf(this,void 0,void 0,function*(){let r=Object.assign({},e);return r.encodedData&&delete r.encodedData,yield hn.computeCid(r)})}static compareCid(e,r){return rf(this,void 0,void 0,function*(){let n=yield t.getCid(e),i=yield t.getCid(r);return f6(n,i)})}static createAuthorization(e){return rf(this,void 0,void 0,function*(){let{descriptor:r,signer:n,delegatedGrant:i,permissionGrantId:o,protocolRole:s}=e,a;i!==void 0&&(a=yield t.getCid(i));let u={signature:yield t.createSignature(r,n,{delegatedGrantId:a,permissionGrantId:o,protocolRole:s})};return i!==void 0&&(u.authorDelegatedGrant=i),u})}static createSignature(e,r,n){return rf(this,void 0,void 0,function*(){let i=yield hn.computeCid(e),o=Object.assign({descriptorCid:i},n);Pn(o);let s=qe.objectToBytes(o);return(yield Gg.create(s,[r])).getJws()})}static getNewestMessage(e){return rf(this,void 0,void 0,function*(){let r;for(let n of e)(r===void 0||(yield t.isNewer(n,r)))&&(r=n);return r})}static getOldestMessage(e){return rf(this,void 0,void 0,function*(){let r;for(let n of e)(r===void 0||(yield t.isOlder(n,r)))&&(r=n);return r})}static isNewer(e,r){return rf(this,void 0,void 0,function*(){return(yield t.compareMessageTimestamp(e,r))>0})}static isOlder(e,r){return rf(this,void 0,void 0,function*(){return(yield t.compareMessageTimestamp(e,r))<0})}static isSignedByAuthorDelegate(e){var r;return((r=e.authorization)===null||r===void 0?void 0:r.authorDelegatedGrant)!==void 0}static isSignedByOwnerDelegate(e){var r;return((r=e.authorization)===null||r===void 0?void 0:r.ownerDelegatedGrant)!==void 0}static compareMessageTimestamp(e,r){return rf(this,void 0,void 0,function*(){return e.descriptor.messageTimestamp>r.descriptor.messageTimestamp?1:e.descriptor.messageTimestamp=e.lt||e.lte!==void 0&&r>e.lte||e.gt!==void 0&&r<=e.gt||e.gte!==void 0&&rv.rootKeyId===r.rootKeyId&&v.derivationScheme===r.derivationScheme);if(o===void 0)throw new de(oe.RecordsDecryptNoMatchingKeyEncryptedFound,`Unable to find a symmetric key encrypted using key with ID '${r.rootKeyId}' and '${r.derivationScheme}' derivation scheme.`);let s=t.constructKeyDerivationPath(o.derivationScheme,e),a=yield t.derivePrivateKey(r,s),d=qe.base64UrlToBytes(o.encryptedKey),u=Ki.publicJwkToBytes(o.ephemeralPublicKey),c=qe.base64UrlToBytes(o.initializationVector),l=qe.base64UrlToBytes(o.messageAuthenticationCode),p=yield $h.eciesSecp256k1Decrypt({ciphertext:d,ephemeralPublicKey:u,initializationVector:c,messageAuthenticationCode:l,privateKey:a}),m=qe.base64UrlToBytes(i.initializationVector);return yield $h.aes256CtrDecrypt(p,m,n)})}static constructKeyDerivationPath(e,r){let n=r.descriptor,i=r.contextId,o;return e===co.DataFormats?o=t.constructKeyDerivationPathUsingDataFormatsScheme(n.schema,n.dataFormat):e===co.ProtocolPath?o=t.constructKeyDerivationPathUsingProtocolPathScheme(n):e===co.ProtocolContext?o=t.constructKeyDerivationPathUsingProtocolContextScheme(i):o=t.constructKeyDerivationPathUsingSchemasScheme(n.schema),o}static constructKeyDerivationPathUsingDataFormatsScheme(e,r){return e!==void 0?[co.DataFormats,e,r]:[co.DataFormats,r]}static constructKeyDerivationPathUsingProtocolPathScheme(e){if(e.protocol===void 0)throw new de(oe.RecordsProtocolPathDerivationSchemeMissingProtocol,"Unable to construct key derivation path using `protocols` scheme because `protocol` is missing.");let r=e.protocolPath.split("/");return[co.ProtocolPath,e.protocol,...r]}static constructKeyDerivationPathUsingProtocolContextScheme(e){if(e===void 0)throw new de(oe.RecordsProtocolContextDerivationSchemeMissingContextId,"Unable to construct key derivation path using `protocolContext` scheme because `contextId` is missing.");let r=e.split("/")[0];return[co.ProtocolContext,r]}static constructKeyDerivationPathUsingSchemasScheme(e){if(e===void 0)throw new de(oe.RecordsSchemasDerivationSchemeMissingSchema,"Unable to construct key derivation path using `schemas` scheme because `schema` is missing.");return[co.Schemas,e]}static derivePrivateKey(e,r){var n;return Mj(this,void 0,void 0,function*(){if(e.derivedPrivateKey.crv!=="secp256k1")throw new de(oe.RecordsDerivePrivateKeyUnSupportedCurve,`Curve ${e.derivedPrivateKey.crv} is not supported.`);let i=(n=e.derivationPath)!==null&&n!==void 0?n:[];t.validateAncestorKeyAndDescentKeyDerivationPathsMatch(i,r);let o=r.slice(i.length),s=Ki.privateJwkToBytes(e.derivedPrivateKey);return yield Jg.derivePrivateKeyBytes(s,o)})}static validateAncestorKeyAndDescentKeyDerivationPathsMatch(e,r){for(let n=0;n=n.dateExpires)throw new de(oe.GrantAuthorizationGrantExpired,"The message has timestamp after the expiry of the associated permission grant");let o={parentId:n.id,protocolPath:"grant/revocation",isLatestBaseState:!0},{messages:s}=yield i.query(e,[o]),a=yield _e.getOldestMessage(s);if(a!==void 0&&a.descriptor.messageTimestamp<=r)throw new de(oe.GrantAuthorizationGrantRevoked,`Permission grant with CID ${n.id} has been revoked`)})}static verifyGrantScopeInterfaceAndMethod(e,r,n){return Oj(this,void 0,void 0,function*(){if(e!==n.scope.interface)throw new de(oe.GrantAuthorizationInterfaceMismatch,`DWN Interface of incoming message is outside the scope of permission grant with ID ${n.id}`);if(r!==n.scope.method)throw new de(oe.GrantAuthorizationMethodMismatch,`DWN Method of incoming message is outside the scope of permission grant with ID ${n.id}`)})}};f();var p6;(function(t){t.Required="Required",t.Prohibited="Prohibited"})(p6||(p6={}));var YT=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},ls=class t{static authorizeWrite(e){return YT(this,void 0,void 0,function*(){let{recordsWriteMessage:r,expectedGrantor:n,expectedGrantee:i,permissionGrant:o,messageStore:s}=e;yield Hc.performBaseValidation({incomingMessage:r,expectedGrantor:n,expectedGrantee:i,permissionGrant:o,messageStore:s}),t.verifyScope(r,o.scope),t.verifyConditions(r,o.conditions)})}static authorizeRead(e){return YT(this,void 0,void 0,function*(){let{recordsReadMessage:r,recordsWriteMessageToBeRead:n,expectedGrantor:i,expectedGrantee:o,permissionGrant:s,messageStore:a}=e;yield Hc.performBaseValidation({incomingMessage:r,expectedGrantor:i,expectedGrantee:o,permissionGrant:s,messageStore:a}),t.verifyScope(n,s.scope)})}static authorizeQueryOrSubscribe(e){return YT(this,void 0,void 0,function*(){let{incomingMessage:r,expectedGrantor:n,expectedGrantee:i,permissionGrant:o,messageStore:s}=e;yield Hc.performBaseValidation({incomingMessage:r,expectedGrantor:n,expectedGrantee:i,permissionGrant:o,messageStore:s});let d=o.scope.protocol,u=r.descriptor.filter.protocol;if(d!==void 0&&u!==d)throw new de(oe.RecordsGrantAuthorizationQueryOrSubscribeProtocolScopeMismatch,`Grant protocol scope ${d} does not match protocol in message ${u}`)})}static authorizeDelete(e){return YT(this,void 0,void 0,function*(){let{recordsDeleteMessage:r,recordsWriteToDelete:n,expectedGrantor:i,expectedGrantee:o,permissionGrant:s,messageStore:a}=e;yield Hc.performBaseValidation({incomingMessage:r,expectedGrantor:i,expectedGrantee:o,permissionGrant:s,messageStore:a});let u=s.scope.protocol,c=n.descriptor.protocol;if(u!==void 0&&c!==u)throw new de(oe.RecordsGrantAuthorizationDeleteProtocolScopeMismatch,`Grant protocol scope ${u} does not match protocol in record to delete ${c}`)})}static verifyScope(e,r){if(r.protocol!==e.descriptor.protocol)throw new de(oe.RecordsGrantAuthorizationScopeProtocolMismatch,"Grant scope specifies different protocol than what appears in the record");if(r.contextId!==void 0&&(e.contextId===void 0||!e.contextId.startsWith(r.contextId)))throw new de(oe.RecordsGrantAuthorizationScopeContextIdMismatch,"Grant scope specifies different contextId than what appears in the record");if(r.protocolPath!==void 0&&r.protocolPath!==e.descriptor.protocolPath)throw new de(oe.RecordsGrantAuthorizationScopeProtocolPathMismatch,"Grant scope specifies different protocolPath than what appears in the record")}static verifyConditions(e,r){if(r?.publication===p6.Required&&!e.descriptor.published)throw new de(oe.RecordsGrantAuthorizationConditionPublicationRequired,"Permission grant requires message to be published");if(r?.publication===p6.Prohibited&&e.descriptor.published)throw new de(oe.RecordsGrantAuthorizationConditionPublicationProhibited,"Permission grant prohibits message from being published")}};f();f();var z=gt(Pde(),1),Fj={};function ff(t,e){Object.defineProperty(t.prototype,Symbol.toStringTag,{value:e,writable:!1,enumerable:!1,configurable:!0});for(let r of Object.getOwnPropertyNames(t)){let n=Object.getOwnPropertyDescriptor(t,r);n.configurable&&n.enumerable&&(n.enumerable=!1,Object.defineProperty(t,r,n))}for(let r of Object.getOwnPropertyNames(t.prototype)){let n=Object.getOwnPropertyDescriptor(t.prototype,r);n.configurable&&n.enumerable&&(n.enumerable=!1,Object.defineProperty(t.prototype,r,n))}kn(e,t),kn(`${e}.prototype`,t.prototype)}function kn(t,e){let r=`%${t}%`;if(Fj[r]!==void 0)throw new Error(`intrinsic ${t} already exists`);Fj[r]=e}function Ae(t){return Fj[t]}var Ide,kde,ut="slot-epochNanoSeconds",of="slot-timezone-identifier",De="slot-year",Oe="slot-month",je="slot-day",St="slot-hour",At="slot-minute",Tt="slot-second",Pt="slot-millisecond",It="slot-microsecond",kt="slot-nanosecond",fe="slot-calendar",uue="slot-date-brand",lue="slot-year-month-brand",fue="slot-month-day-brand",qo="slot-cached-instant",Ur="slot-time-zone",fs="slot-years",Gi="slot-months",oa="slot-weeks",hs="slot-days",ps="slot-hours",ms="slot-minutes",ys="slot-seconds",gs="slot-milliseconds",vs="slot-microseconds",bs="slot-nanoseconds",In="slot-calendar-identifier",hue=new WeakMap,zj=Symbol.for("@@Temporal__GetSlots");(Ide=globalThis)[zj]||(Ide[zj]=function(e){return hue.get(e)});var bN=globalThis[zj],Wj=Symbol.for("@@Temporal__CreateSlots");(kde=globalThis)[Wj]||(kde[Wj]=function(e){hue.set(e,Object.create(null))});var hf=globalThis[Wj];function Bi(t,...e){if(!t||typeof t!="object")return!1;let r=bN(t);return!!r&&e.every(n=>n in r)}function R(t,e){let r=bN(t)?.[e];if(r===void 0)throw new TypeError(`Missing internal slot ${e}`);return r}function Mt(t,e,r){let n=bN(t);if(n===void 0)throw new TypeError("Missing slots for the given container");if(n[e])throw new TypeError(`${e} already has set`);n[e]=r}var Rde=/\.[-A-Za-z_]|\.\.[-A-Za-z._]{1,12}|\.[-A-Za-z_][-A-Za-z._]{0,12}|[A-Za-z_][-A-Za-z._]{0,13}/,B6=new RegExp("(?:"+[`(?:${Rde.source})(?:\\/(?:${Rde.source}))*`,"Etc/GMT(?:0|[-+]\\d{1,2})","GMT[-+]?0","EST5EDT","CST6CDT","MST7MDT","PST8PDT",/(?:[+\u2212-][0-2][0-9](?::?[0-5][0-9](?::?[0-5][0-9](?:[.,]\d{1,9})?)?)?)/.source].join("|")+")"),pue=/(?:[+\u2212-]\d{6}|\d{4})/,nP=/(?:0[1-9]|1[0-2])/,Hj=/(?:0[1-9]|[12]\d|3[01])/,eqe=new RegExp(`(${pue.source})(?:-(${nP.source})-(${Hj.source})|(${nP.source})(${Hj.source}))`),mue=/(\d{2})(?::(\d{2})(?::(\d{2})(?:[.,](\d{1,9}))?)?|(\d{2})(?:(\d{2})(?:[.,](\d{1,9}))?)?)?/,yue=/([+\u2212-])([01][0-9]|2[0-3])(?::?([0-5][0-9])(?::?([0-5][0-9])(?:[.,](\d{1,9}))?)?)?/,gue=new RegExp(`([zZ])|${yue.source}?`),ny=/\[(!)?([a-z_][a-z0-9_-]*)=([A-Za-z0-9]+(?:-[A-Za-z0-9]+)*)\]/g,tqe=new RegExp([`^${eqe.source}`,`(?:(?:T|\\s+)${mue.source}(?:${gue.source})?)?`,`(?:\\[!?(${B6.source})\\])?`,`((?:${ny.source})*)$`].join(""),"i"),rqe=new RegExp([`^T?${mue.source}`,`(?:${gue.source})?`,`(?:\\[!?${B6.source}\\])?`,`((?:${ny.source})*)$`].join(""),"i"),nqe=new RegExp(`^(${pue.source})-?(${nP.source})(?:\\[!?${B6.source}\\])?((?:${ny.source})*)$`),iqe=new RegExp(`^(?:--)?(${nP.source})-?(${Hj.source})(?:\\[!?${B6.source}\\])?((?:${ny.source})*)$`),jj=/(\d+)(?:[.,](\d{1,9}))?/,oqe=new RegExp(`(?:${jj.source}H)?(?:${jj.source}M)?(?:${jj.source}S)?`),sqe=new RegExp(`^([+\u2212-])?P${/(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?/.source}(?:T(?!$)${oqe.source})?$`,"i"),aqe=Array.prototype.includes,vue=Array.prototype.push,bue=globalThis.Intl.DateTimeFormat,cqe=Math.min,dqe=Math.max,an=Math.abs,Ba=Math.floor,z1=Math.sign,Qg=Math.trunc,bP=Number.isNaN,ws=Number.isFinite,uqe=Number,M6=String,lqe=Number.MAX_SAFE_INTEGER,Ko=Object.create,fqe=Object.getOwnPropertyDescriptor,wP=Reflect.apply,hqe=Reflect.ownKeys,Nn=z.default.BigInt(0),Q1=z.default.BigInt(1),sf=z.default.BigInt(60),wue=z.default.BigInt(24),Ar=z.default.BigInt(1e3),Jc=z.default.BigInt(1e6),af=z.default.BigInt(1e9),pqe=z.default.BigInt(-1),_ue=z.default.multiply(z.default.BigInt(3600),af),xue=z.default.multiply(sf,af),df=z.default.multiply(_ue,wue),b6=z.default.multiply(z.default.BigInt(-86400),z.default.BigInt(1e17)),W1=z.default.multiply(z.default.BigInt(86400),z.default.BigInt(1e17)),iP=-271821,oP=275760,j1=z.default.multiply(z.default.BigInt(-388152),z.default.BigInt(1e13)),mqe=z.default.multiply(df,z.default.BigInt(3660)),Eue=z.default.multiply(df,z.default.BigInt(366)),Sue=z.default.multiply(df,z.default.BigInt(14)),yqe=["iso8601","hebrew","islamic","islamic-umalqura","islamic-tbla","islamic-civil","islamic-rgsa","islamicc","persian","ethiopic","ethioaa","coptic","chinese","dangi","roc","indian","buddhist","japanese","gregory"];function Gc(t){return z.default.equal(t,Nn)}function kr(t,e){let r=t[e];if(r!==void 0)return r}function Ge(t,e,r){let n=arguments.length>2?r:[];return wP(t,e,n)}function cn(t){return typeof t=="object"&&t!==null||typeof t=="function"}function H1(t){if(typeof t=="bigint")throw new TypeError("Cannot convert BigInt to number");return uqe(t)}function oi(t){let e=H1(t);if(bP(e)||e===0)return 0;if(!ws(e))return e;let r=Ba(an(e));return r===0?0:z1(e)*r}function ac(t){if(typeof t!="number"||bP(t)||!ws(t))return!1;let e=an(t);return Ba(e)===e}function xs(t){if(typeof t=="symbol")throw new TypeError("Cannot convert a Symbol value to a String");return M6(t)}function vr(t){let e=H1(t);if(e===0)return 0;if(bP(e)||!ws(e))throw new RangeError("invalid number value");let r=Qg(e);return r===0?0:r}function Dde(t,e){let r=vr(t);if(r<=0)throw e!==void 0?new RangeError(`property '${e}' cannot be a a number less than one`):new RangeError("Cannot convert a number less than one to a positive integer");return r}function Di(t){let e=H1(t);if(!ws(e))throw new RangeError("infinity is out of range");if(!ac(e))throw new RangeError(`unsupported fractional value ${t}`);return e===0?0:e}function Yn(t,e){return{quotient:z.default.divide(t,e),remainder:z.default.remainder(t,e)}}function sP(t){return z.default.lessThan(t,Nn)}function Bde(t){return Gc(t)?0:sP(t)?-1:1}function zu(t){return z.default.lessThan(t,Nn)?z.default.multiply(t,pqe):t}var Mde=new Map([["year",vr],["month",Dde],["monthCode",xs],["day",Dde],["hour",vr],["minute",vr],["second",vr],["millisecond",vr],["microsecond",vr],["nanosecond",vr],["years",Di],["months",Di],["weeks",Di],["days",Di],["hours",Di],["minutes",Di],["seconds",Di],["milliseconds",Di],["microseconds",Di],["nanoseconds",Di],["era",xs],["eraYear",oi],["offset",xs]]),gqe=new Map([["hour",0],["minute",0],["second",0],["millisecond",0],["microsecond",0],["nanosecond",0]]),O6=[["years","year","date"],["months","month","date"],["weeks","week","date"],["days","day","date"],["hours","hour","time"],["minutes","minute","time"],["seconds","second","time"],["milliseconds","millisecond","time"],["microseconds","microsecond","time"],["nanoseconds","nanosecond","time"]],aP=new Map(O6.map(t=>[t[0],t[1]])),vqe=new Map(O6.map(([t,e])=>[e,t])),Ode=O6.map(([,t])=>t),Cde=Array.from(aP.keys()).sort(),$de=new Map;function Aue(t){let e=$de.get(t);return e===void 0&&(e=new bue("en-us",{timeZone:M6(t),hour12:!1,era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}),$de.set(t,e)),e}function jde(t){if(t==null)throw new TypeError(`Expected object not ${t}`);return Object(t)}function N1(t,e,r,n){if(e==null)return;let i=hqe(e);for(let o of i)if(!r.some(s=>Object.is(s,o))&&Object.prototype.propertyIsEnumerable.call(e,o)){let s=e[o];if(n&&n.some(a=>Object.is(a,s)))continue;t[o]=s}}function Ei(t){return Bi(t,ut)&&!Bi(t,Ur,fe)}function Vc(t){return Bi(t,of)}function Cn(t){return Bi(t,In)}function $n(t){return Bi(t,fs,Gi,hs,ps,ms,ys,gs,vs,bs)}function Jt(t){return Bi(t,uue)}function jn(t){return Bi(t,St,At,Tt,Pt,It,kt)&&!Bi(t,De,Oe,je)}function _t(t){return Bi(t,De,Oe,je,St,At,Tt,Pt,It,kt)}function Sr(t){return Bi(t,lue)}function Ri(t){return Bi(t,fue)}function Ke(t){return Bi(t,ut,Ur,fe)}function e2(t){if(Bi(t,fe)||Bi(t,Ur))throw new TypeError("with() does not support a calendar or timeZone property");if(jn(t))throw new TypeError("with() does not accept Temporal.PlainTime, use withPlainTime() instead");if(t.calendar!==void 0)throw new TypeError("with() does not support a calendar property");if(t.timeZone!==void 0)throw new TypeError("with() does not support a timeZone property")}function bqe(t){let{ianaName:e,offset:r,z:n}=function(o){if(new RegExp(`^${B6.source}$`,"i").test(o))return{ianaName:o};try{let s=pf(o);if(s.z||s.offset||s.ianaName)return s}catch{}throw new RangeError(`Invalid time zone: ${o}`)}(t);return e?RN(e):n?"UTC":BP(Ym(r))}function wN(t,e){return e==="never"?"":_N(po(t),e)}function _N(t,e){return e==="never"||e==="auto"&&t==="iso8601"?"":`[${e==="critical"?"!":""}u-ca=${t}]`}function pf(t){let e=tqe.exec(t);if(!e)throw new RangeError(`invalid ISO 8601 string: ${t}`);let r=e[1];if(r[0]==="\u2212"&&(r=`-${r.slice(1)}`),r==="-000000")throw new RangeError(`invalid ISO 8601 string: ${t}`);let n=oi(r),i=oi(e[2]||e[4]),o=oi(e[3]||e[5]),s=oi(e[6]),a=e[6]!==void 0,d=oi(e[7]||e[10]),u=oi(e[8]||e[11]);u===60&&(u=59);let c=(e[9]||e[12])+"000000000",l=oi(c.slice(0,3)),p=oi(c.slice(3,6)),m=oi(c.slice(6,9)),g,v=!1;if(e[13])g=void 0,v=!0;else if(e[14]&&e[15]){let A=e[14]==="-"||e[14]==="\u2212"?"-":"+",$=e[15]||"00",j=e[16]||"00",q=e[17]||"00",F=e[18]||"0";if(g=`${A}${$}:${j}`,+F){for(;F.endsWith("0");)F=F.slice(0,-1);g+=`:${q}.${F}`}else+q&&(g+=`:${q}`);g==="-00:00"&&(g="+00:00")}let x=e[19],S=e[20],P;for(let[,A,$,j]of S.matchAll(ny))if($==="u-ca")P===void 0&&(P=j);else if(A==="!")throw new RangeError(`Unrecognized annotation: !${$}=${j}`);return MN(n,i,o,s,d,u,l,p,m),{year:n,month:i,day:o,hasTime:a,hour:s,minute:d,second:u,millisecond:l,microsecond:p,nanosecond:m,ianaName:x,offset:g,z:v,calendar:P}}function xN(t){let e=nqe.exec(t),r,n,i,o;if(e){let s=e[1];if(s[0]==="\u2212"&&(s=`-${s.slice(1)}`),s==="-000000")throw new RangeError(`invalid ISO 8601 string: ${t}`);r=oi(s),n=oi(e[2]);let a=e[3];for(let[,d,u,c]of a.matchAll(ny))if(u==="u-ca")i===void 0&&(i=c);else if(d==="!")throw new RangeError(`Unrecognized annotation: !${u}=${c}`);if(i!==void 0&&i!=="iso8601")throw new RangeError("YYYY-MM format is only valid with iso8601 calendar")}else{let s;if({year:r,month:n,calendar:i,day:o,z:s}=pf(t),s)throw new RangeError("Z designator not supported for PlainYearMonth")}return{year:r,month:n,calendar:i,referenceISODay:o}}function EN(t){let e=iqe.exec(t),r,n,i,o;if(e){r=oi(e[1]),n=oi(e[2]);let s=e[3];for(let[,a,d,u]of s.matchAll(ny))if(d==="u-ca")i===void 0&&(i=u);else if(a==="!")throw new RangeError(`Unrecognized annotation: !${d}=${u}`);if(i!==void 0&&i!=="iso8601")throw new RangeError("MM-DD format is only valid with iso8601 calendar")}else{let s;if({month:r,day:n,calendar:i,year:o,z:s}=pf(t),s)throw new RangeError("Z designator not supported for PlainMonthDay")}return{month:r,day:n,calendar:i,referenceISOYear:o}}function wqe(t){let{year:e,month:r,day:n,hour:i,minute:o,second:s,millisecond:a,microsecond:d,nanosecond:u,offset:c,z:l}=function(v){let x=pf(v);if(!x.z&&!x.offset)throw new RangeError("Temporal.Instant requires a time zone offset");return x}(t);if(!l&&!c)throw new RangeError("Temporal.Instant requires a time zone offset");let p=l?0:Ym(c);({year:e,month:r,day:n,hour:i,minute:o,second:s,millisecond:a,microsecond:d,nanosecond:u}=DN(e,r,n,i,o,s,a,d,u-p));let m=Xm(e,r,n,i,o,s,a,d,u);if(m===null)throw new RangeError("DateTime outside of supported range");return m}function cP(t,e,r,n){let i=t,o=e,s=r;switch(n){case"reject":uf(i,o,s);break;case"constrain":({year:i,month:o,day:s}=Kue(i,o,s))}return{year:i,month:o,day:s}}function _P(t,e,r,n,i,o,s){let a=t,d=e,u=r,c=n,l=i,p=o;switch(s){case"reject":OP(a,d,u,c,l,p);break;case"constrain":({hour:a,minute:d,second:u,millisecond:c,microsecond:l,nanosecond:p}=function(g,v,x,S,P,A){let $=Da(g,0,23),j=Da(v,0,59),q=Da(x,0,59),F=Da(S,0,999),K=Da(P,0,999),W=Da(A,0,999);return{hour:$,minute:j,second:q,millisecond:F,microsecond:K,nanosecond:W}}(a,d,u,c,l,p))}return{hour:a,minute:d,second:u,millisecond:c,microsecond:l,nanosecond:p}}function uv(t){if(!cn(t))return function(g){let v=sqe.exec(g);if(!v)throw new RangeError(`invalid duration: ${g}`);if(v.slice(2).every(E=>E===void 0))throw new RangeError(`invalid duration: ${g}`);let x=v[1]==="-"||v[1]==="\u2212"?-1:1,S=v[2]===void 0?0:vr(v[2])*x,P=v[3]===void 0?0:vr(v[3])*x,A=v[4]===void 0?0:vr(v[4])*x,$=v[5]===void 0?0:vr(v[5])*x,j=v[6]===void 0?0:vr(v[6])*x,q=v[7],F=v[8],K=v[9],W=v[10],L=v[11],I=0,T=0,B=0;if(q!==void 0){if(F??K??W??L)throw new RangeError("only the smallest unit can be fractional");B=3600*oi((q+"000000000").slice(0,9))*x}else if(I=F===void 0?0:vr(F)*x,K!==void 0){if(W??L)throw new RangeError("only the smallest unit can be fractional");B=60*oi((K+"000000000").slice(0,9))*x}else T=W===void 0?0:vr(W)*x,L!==void 0&&(B=oi((L+"000000000").slice(0,9))*x);let h=B%1e3,y=Qg(B/1e3)%1e3,w=Qg(B/1e6)%1e3;return T+=Qg(B/1e9)%60,I+=Qg(B/6e10),pP(S,P,A,$,j,I,T,w,y,h),{years:S,months:P,weeks:A,days:$,hours:j,minutes:I,seconds:T,milliseconds:w,microseconds:y,nanoseconds:h}}(xs(t));if($n(t))return{years:R(t,fs),months:R(t,Gi),weeks:R(t,oa),days:R(t,hs),hours:R(t,ps),minutes:R(t,ms),seconds:R(t,ys),milliseconds:R(t,gs),microseconds:R(t,vs),nanoseconds:R(t,bs)};let e={years:0,months:0,weeks:0,days:0,hours:0,minutes:0,seconds:0,milliseconds:0,microseconds:0,nanoseconds:0},r=function(g){if(!cn(g))throw new TypeError("invalid duration-like");let v={years:void 0,months:void 0,weeks:void 0,days:void 0,hours:void 0,minutes:void 0,seconds:void 0,milliseconds:void 0,microseconds:void 0,nanoseconds:void 0},x=!1;for(let S of Cde){let P=g[S];P!==void 0&&(x=!0,v[S]=Di(P))}if(!x)throw new TypeError("invalid duration-like");return v}(t);for(let m of Cde){let g=r[m];g!==void 0&&(e[m]=g)}let{years:n,months:i,weeks:o,days:s,hours:a,minutes:d,seconds:u,milliseconds:c,microseconds:l,nanoseconds:p}=e;return pP(n,i,o,s,a,d,u,c,l,p),{years:n,months:i,weeks:o,days:s,hours:a,minutes:d,seconds:u,milliseconds:c,microseconds:l,nanoseconds:p}}function Xn(t){return t===void 0?"constrain":ey(t,"overflow",["constrain","reject"],"constrain")}function V1(t){return t===void 0?"compatible":ey(t,"disambiguation",["compatible","earlier","later","reject"],"compatible")}function Hu(t,e){return ey(t,"roundingMode",["ceil","floor","expand","trunc","halfCeil","halfFloor","halfExpand","halfTrunc","halfEven"],e)}function dP(t,e){return t===void 0?e:ey(t,"offset",["prefer","use","ignore","reject"],e)}function C6(t){return ey(t,"calendarName",["auto","always","never","critical"],"auto")}function t2(t){let e=t.roundingIncrement;if(e===void 0)return 1;if(e=H1(e),!ws(e))throw new RangeError("roundingIncrement must be finite");let r=Qg(e);if(r<1||r>1e9)throw new RangeError(`roundingIncrement must be at least 1 and at most 1e9, not ${e}`);return r}function r2(t,e,r){let n=r?e:e-1;if(t>n)throw new RangeError(`roundingIncrement must be at least 1 and less than ${n}, not ${t}`);if(e%t!=0)throw new RangeError(`Rounding increment must divide evenly into ${e}`)}function $6(t){let e=t.fractionalSecondDigits;if(e===void 0)return"auto";if(typeof e!="number"){if(xs(e)!=="auto")throw new RangeError(`fractionalSecondDigits must be 'auto' or 0 through 9, not ${e}`);return"auto"}let r=Ba(e);if(!ws(r)||r<0||r>9)throw new RangeError(`fractionalSecondDigits must be 'auto' or 0 through 9, not ${e}`);return r}function j6(t,e){switch(t){case"minute":return{precision:"minute",unit:"minute",increment:1};case"second":return{precision:0,unit:"second",increment:1};case"millisecond":return{precision:3,unit:"millisecond",increment:1};case"microsecond":return{precision:6,unit:"microsecond",increment:1};case"nanosecond":return{precision:9,unit:"nanosecond",increment:1}}switch(e){case"auto":return{precision:e,unit:"nanosecond",increment:1};case 0:return{precision:e,unit:"second",increment:1};case 1:case 2:case 3:return{precision:e,unit:"millisecond",increment:10**(3-e)};case 4:case 5:case 6:return{precision:e,unit:"microsecond",increment:10**(6-e)};case 7:case 8:case 9:return{precision:e,unit:"nanosecond",increment:10**(9-e)};default:throw new RangeError(`fractionalSecondDigits must be 'auto' or 0 through 9, not ${e}`)}}var iv=Symbol("~required~");function Ma(t,e,r,n,i=[]){let o=[];for(let[,u,c]of O6)r!=="datetime"&&r!==c||o.push(u);o.push(...i);let s=n;s===iv?s=void 0:s!==void 0&&o.push(s);let a=[...o];for(let u of o){let c=vqe.get(u);c!==void 0&&a.push(c)}let d=ey(t,e,a,s);if(d===void 0&&n===iv)throw new RangeError(`${e} is required`);return aP.has(d)?aP.get(d):d}function QT(t){let e=t.relativeTo;if(e===void 0)return e;let r,n,i,o,s,a,d,u,c,l,p,m,g="option",v=!1;if(cn(e)){if(Ke(e)||Jt(e))return e;if(_t(e))return J1(e);l=L6(e);let x=si(l,["day","hour","microsecond","millisecond","minute","month","monthCode","nanosecond","second","year"]);x.push("timeZone","offset");let S=Ct(e,x,[]),P=Ko(null);P.overflow="constrain",{year:r,month:n,day:i,hour:o,minute:s,second:a,millisecond:d,microsecond:u,nanosecond:c}=N6(l,S,P),m=S.offset,m===void 0&&(g="wall"),p=S.timeZone,p!==void 0&&(p=Lo(p))}else{let x,S;if({year:r,month:n,day:i,hour:o,minute:s,second:a,millisecond:d,microsecond:u,nanosecond:c,calendar:l,ianaName:x,offset:m,z:S}=pf(xs(e)),x)p=Lo(x),S?g="exact":m||(g="wall"),v=!0;else if(S)throw new RangeError("Z designator not supported for PlainDate relativeTo; either remove the Z or add a bracketed time zone");if(l||(l="iso8601"),!Wh(l))throw new RangeError(`invalid calendar identifier ${l}`);l=lf(l)}return p===void 0?Yc(r,n,i,l):lo(lP(r,n,i,o,s,a,d,u,c,g,g==="option"?Ym(m):0,p,"compatible","reject",v),p,l)}function Vj(t,e,r,n,i,o,s,a,d,u){for(let[c,l]of[["years",t],["months",e],["weeks",r],["days",n],["hours",i],["minutes",o],["seconds",s],["milliseconds",a],["microseconds",d],["nanoseconds",u]])if(l!==0)return aP.get(c);return"nanosecond"}function ov(t,e){return Ode.indexOf(t)>Ode.indexOf(e)?e:t}function Ct(t,e,r,{emptySourceErrorMessage:n}={emptySourceErrorMessage:"no supported properties found"}){let i=Ko(null),o=!1;e.sort();for(let s of e){let a=t[s];if(a!==void 0)o=!0,Mde.has(s)&&(a=Mde.get(s)(a)),i[s]=a;else if(r!=="partial"){if(aqe.call(r,s))throw new TypeError(`required property '${s}' missing or undefined`);a=gqe.get(s),i[s]=a}}if(r==="partial"&&!o)throw new TypeError(n);return i}function uP(t,e="complete"){let r=["hour","microsecond","millisecond","minute","nanosecond","second"],n=Ct(t,r,"partial",{emptySourceErrorMessage:"invalid time-like"}),i={};for(let o of r){let s=fqe(n,o);s!==void 0?i[o]=s.value:e==="complete"&&(i[o]=0)}return i}function Lr(t,e){let r=t;if(cn(r)){if(Jt(r))return r;if(Ke(r)&&(Xn(e),r=sc(R(r,Ur),R(r,qo),R(r,fe))),_t(r))return Xn(e),Yc(R(r,De),R(r,Oe),R(r,je),R(r,fe));let d=L6(r);return Fh(d,Ct(r,si(d,["day","month","monthCode","year"]),[]),e)}Xn(e);let{year:n,month:i,day:o,calendar:s,z:a}=function(u){return pf(u)}(xs(r));if(a)throw new RangeError("Z designator not supported for PlainDate");if(s||(s="iso8601"),!Wh(s))throw new RangeError(`invalid calendar identifier ${s}`);return s=lf(s),Yc(n,i,o,s)}function N6(t,e,r){let{hour:n,minute:i,second:o,millisecond:s,microsecond:a,nanosecond:d}=uP(e),u=Xn(r),c=Fh(t,e,r),l=R(c,De),p=R(c,Oe),m=R(c,je);return{hour:n,minute:i,second:o,millisecond:s,microsecond:a,nanosecond:d}=_P(n,i,o,s,a,d,u),{year:l,month:p,day:m,hour:n,minute:i,second:o,millisecond:s,microsecond:a,nanosecond:d}}function ev(t,e){let r,n,i,o,s,a,d,u,c,l;if(cn(t)){if(_t(t))return t;if(Ke(t))return Xn(e),sc(R(t,Ur),R(t,qo),R(t,fe));if(Jt(t))return Xn(e),Ra(R(t,De),R(t,Oe),R(t,je),0,0,0,0,0,0,R(t,fe));l=L6(t);let p=Ct(t,si(l,["day","hour","microsecond","millisecond","minute","month","monthCode","nanosecond","second","year"]),[]);({year:r,month:n,day:i,hour:o,minute:s,second:a,millisecond:d,microsecond:u,nanosecond:c}=N6(l,p,e))}else{let p;if(Xn(e),{year:r,month:n,day:i,hour:o,minute:s,second:a,millisecond:d,microsecond:u,nanosecond:c,calendar:l,z:p}=function(g){return pf(g)}(xs(t)),p)throw new RangeError("Z designator not supported for PlainDateTime");if(MN(r,n,i,o,s,a,d,u,c),l||(l="iso8601"),!Wh(l))throw new RangeError(`invalid calendar identifier ${l}`);l=lf(l)}return Ra(r,n,i,o,s,a,d,u,c,l)}function U1(t){if($n(t))return t;let{years:e,months:r,weeks:n,days:i,hours:o,minutes:s,seconds:a,milliseconds:d,microseconds:u,nanoseconds:c}=uv(t);return new(Ae("%Temporal.Duration%"))(e,r,n,i,o,s,a,d,u,c)}function Wu(t){if(Ei(t))return t;if(Ke(t))return new(Ae("%Temporal.Instant%"))(R(t,ut));let e=wqe(xs(t));return new(Ae("%Temporal.Instant%"))(e)}function Nde(t,e){let r=t;if(cn(r)){if(Ri(r))return r;let a,d;if(Bi(r,fe))a=R(r,fe),d=!1;else{let c=r.calendar;d=c===void 0,c===void 0&&(c="iso8601"),a=Oa(c)}let u=Ct(r,si(a,["day","month","monthCode","year"]),[]);return d&&u.month!==void 0&&u.monthCode===void 0&&u.year===void 0&&(u.year=1972),G1(a,u,e)}Xn(e);let{month:n,day:i,referenceISOYear:o,calendar:s}=EN(xs(r));if(s===void 0&&(s="iso8601"),!Wh(s))throw new RangeError(`invalid calendar identifier ${s}`);return s=lf(s),o===void 0?(uf(1972,n,i),w6(n,i,s)):G1(s,w6(n,i,s,o))}function Uh(t,e="constrain"){let r,n,i,o,s,a,d=t;if(cn(d)){if(jn(d))return d;if(Ke(d)&&(d=sc(R(d,Ur),R(d,qo),R(d,fe))),_t(d))return new(Ae("%Temporal.PlainTime%"))(R(d,St),R(d,At),R(d,Tt),R(d,Pt),R(d,It),R(d,kt));({hour:r,minute:n,second:i,millisecond:o,microsecond:s,nanosecond:a}=uP(d)),{hour:r,minute:n,second:i,millisecond:o,microsecond:s,nanosecond:a}=_P(r,n,i,o,s,a,e)}else({hour:r,minute:n,second:i,millisecond:o,microsecond:s,nanosecond:a}=function(c){let l=rqe.exec(c),p,m,g,v,x,S,P;if(l){p=oi(l[1]),m=oi(l[2]||l[5]),g=oi(l[3]||l[6]),g===60&&(g=59);let A=(l[4]||l[7])+"000000000";v=oi(A.slice(0,3)),x=oi(A.slice(3,6)),S=oi(A.slice(6,9)),P=l[14];for(let[,$,j,q]of P.matchAll(ny))if(j!=="u-ca"&&$==="!")throw new RangeError(`Unrecognized annotation: !${j}=${q}`);if(l[8])throw new RangeError("Z designator not supported for PlainTime")}else{let A,$;if({hasTime:$,hour:p,minute:m,second:g,millisecond:v,microsecond:x,nanosecond:S,z:A}=pf(c),!$)throw new RangeError(`time is missing in string: ${c}`);if(A)throw new RangeError("Z designator not supported for PlainTime")}if(/[tT ][0-9][0-9]/.test(c))return{hour:p,minute:m,second:g,millisecond:v,microsecond:x,nanosecond:S};try{let{month:A,day:$}=EN(c);uf(1972,A,$)}catch{try{let{year:A,month:$}=xN(c);uf(A,$,1)}catch{return{hour:p,minute:m,second:g,millisecond:v,microsecond:x,nanosecond:S}}}throw new RangeError(`invalid ISO 8601 time-only string ${c}; may need a T prefix`)}(xs(d))),OP(r,n,i,o,s,a);return new(Ae("%Temporal.PlainTime%"))(r,n,i,o,s,a)}function m6(t,e){if(cn(t)){if(Sr(t))return t;let s=L6(t);return av(s,Ct(t,si(s,["month","monthCode","year"]),[]),e)}Xn(e);let{year:r,month:n,referenceISODay:i,calendar:o}=xN(xs(t));if(o===void 0&&(o="iso8601"),!Wh(o))throw new RangeError(`invalid calendar identifier ${o}`);return o=lf(o),i===void 0?(uf(r,n,1),_6(r,n,o)):av(o,_6(r,n,o,i))}function lP(t,e,r,n,i,o,s,a,d,u,c,l,p,m,g){let v=new(Ae("%Temporal.PlainDateTime%"))(t,e,r,n,i,o,s,a,d);if(u==="wall"||m==="ignore")return R(_s(l,v,p),ut);if(u==="exact"||m==="use"){let S=Xm(t,e,r,n,i,o,s,a,d);if(S===null)throw new RangeError("ZonedDateTime outside of supported range");return z.default.subtract(S,z.default.BigInt(c))}let x=fP(l,v);for(let S of x){let P=Vu(l,S),A=z.default.toNumber(oc(z.default.BigInt(P),xue,"halfExpand"));if(P===c||g&&A===c)return R(S,ut)}if(m==="reject"){let S=BP(c),P=Vc(l)?R(l,of):"time zone";throw new RangeError(`Offset ${S} is invalid for ${v.toString()} in ${P}`)}return R(Oue(x,l,v,p),ut)}function y6(t,e){let r,n,i,o,s,a,d,u,c,l,p,m,g,v,x=!1,S="option";if(cn(t)){if(Ke(t))return t;m=L6(t);let A=si(m,["day","hour","microsecond","millisecond","minute","month","monthCode","nanosecond","second","year"]);A.push("timeZone","offset");let $=Ct(t,A,["timeZone"]);l=Lo($.timeZone),p=$.offset,p===void 0&&(S="wall"),g=V1(e),v=dP(e,"reject"),{year:r,month:n,day:i,hour:o,minute:s,second:a,millisecond:d,microsecond:u,nanosecond:c}=N6(m,$,e)}else{let A,$;if({year:r,month:n,day:i,hour:o,minute:s,second:a,millisecond:d,microsecond:u,nanosecond:c,ianaName:A,offset:p,z:$,calendar:m}=function(q){let F=pf(q);if(!F.ianaName)throw new RangeError("Temporal.ZonedDateTime requires a time zone ID in brackets");return F}(xs(t)),l=Lo(A),$?S="exact":p||(S="wall"),m||(m="iso8601"),!Wh(m))throw new RangeError(`invalid calendar identifier ${m}`);m=lf(m),x=!0,g=V1(e),v=dP(e,"reject"),Xn(e)}let P=0;return S==="option"&&(P=Ym(p)),lo(lP(r,n,i,o,s,a,d,u,c,S,P,l,g,v,x),l,m)}function Tue(t,e,r,n,i){uf(e,r,n),Fue(e,r,n),hf(t),Mt(t,De,e),Mt(t,Oe,r),Mt(t,je,n),Mt(t,fe,i),Mt(t,uue,!0)}function Yc(t,e,r,n="iso8601"){let i=Ae("%Temporal.PlainDate%"),o=Ko(i.prototype);return Tue(o,t,e,r,n),o}function Pue(t,e,r,n,i,o,s,a,d,u,c){MN(e,r,n,i,o,s,a,d,u),zue(e,r,n,i,o,s,a,d,u),hf(t),Mt(t,De,e),Mt(t,Oe,r),Mt(t,je,n),Mt(t,St,i),Mt(t,At,o),Mt(t,Tt,s),Mt(t,Pt,a),Mt(t,It,d),Mt(t,kt,u),Mt(t,fe,c)}function Ra(t,e,r,n,i,o,s,a,d,u="iso8601"){let c=Ae("%Temporal.PlainDateTime%"),l=Ko(c.prototype);return Pue(l,t,e,r,n,i,o,s,a,d,u),l}function Iue(t,e,r,n,i){uf(i,e,r),Fue(i,e,r),hf(t),Mt(t,Oe,e),Mt(t,je,r),Mt(t,De,i),Mt(t,fe,n),Mt(t,fue,!0)}function w6(t,e,r="iso8601",n=1972){let i=Ae("%Temporal.PlainMonthDay%"),o=Ko(i.prototype);return Iue(o,t,e,r,n),o}function kue(t,e,r,n,i){uf(e,r,i),function(s,a){ho(s,iP,oP),s===iP?ho(a,4,12):s===oP&&ho(a,1,9)}(e,r),hf(t),Mt(t,De,e),Mt(t,Oe,r),Mt(t,je,i),Mt(t,fe,n),Mt(t,lue,!0)}function _6(t,e,r="iso8601",n=1){let i=Ae("%Temporal.PlainYearMonth%"),o=Ko(i.prototype);return kue(o,t,e,r,n),o}function Rue(t,e,r,n){Xg(e),hf(t),Mt(t,ut,e),Mt(t,Ur,r),Mt(t,fe,n);let i=new(Ae("%Temporal.Instant%"))(R(t,ut));Mt(t,qo,i)}function lo(t,e,r="iso8601"){let n=Ae("%Temporal.ZonedDateTime%"),i=Ko(n.prototype);return Rue(i,t,e,r),i}function si(t,e){if(typeof t=="string"){let i=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.fields%"),i,[e])}let r=Ge(kr(t,"fields"),t,[e]),n=[];for(let i of r){if(typeof i!="string")throw new TypeError("bad return from calendar.fields()");vue.call(n,i)}return n}function sv(t,e,r){if(typeof t=="string"){let i=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.mergeFields%"),i,[e,r])}let n=Ge(kr(t,"mergeFields"),t,[e,r]);if(!cn(n))throw new TypeError("bad return from calendar.mergeFields()");return n}function fo(t,e,r,n,i){let o=i;if(typeof t=="string"){let a=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.dateAdd%"),a,[e,r,n])}o===void 0&&(o=kr(t,"dateAdd"));let s=wP(o,t,[e,r,n]);if(!Jt(s))throw new TypeError("invalid result");return s}function Zm(t,e,r,n,i){let o=i;if(typeof t=="string"){let a=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.dateUntil%"),a,[e,r,n])}o===void 0&&(o=kr(t,"dateUntil"));let s=wP(o,t,[e,r,n]);if(!$n(s))throw new TypeError("invalid result");return s}function xP(t,e){if(typeof t=="string"){let n=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.year%"),n,[e])}let r=Ge(kr(t,"year"),t,[e]);if(typeof r!="number")throw new TypeError("calendar year result must be an integer");if(!ac(r))throw new RangeError("calendar year result must be an integer");return r}function EP(t,e){if(typeof t=="string"){let n=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.month%"),n,[e])}let r=Ge(kr(t,"month"),t,[e]);if(typeof r!="number")throw new TypeError("calendar month result must be a positive integer");if(!ac(r)||r<1)throw new RangeError("calendar month result must be a positive integer");return r}function U6(t,e){if(typeof t=="string"){let n=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.monthCode%"),n,[e])}let r=Ge(kr(t,"monthCode"),t,[e]);if(typeof r!="string")throw new TypeError("calendar monthCode result must be a string");return r}function q6(t,e){if(typeof t=="string"){let n=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.day%"),n,[e])}let r=Ge(kr(t,"day"),t,[e]);if(typeof r!="number")throw new TypeError("calendar day result must be a positive integer");if(!ac(r)||r<1)throw new RangeError("calendar day result must be a positive integer");return r}function SP(t,e){if(typeof t=="string"){let n=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.era%"),n,[e])}let r=Ge(kr(t,"era"),t,[e]);if(r===void 0)return r;if(typeof r!="string")throw new TypeError("calendar era result must be a string or undefined");return r}function AP(t,e){if(typeof t=="string"){let n=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.eraYear%"),n,[e])}let r=Ge(kr(t,"eraYear"),t,[e]);if(r===void 0)return r;if(typeof r!="number")throw new TypeError("calendar eraYear result must be an integer or undefined");if(!ac(r))throw new RangeError("calendar eraYear result must be an integer or undefined");return r}function SN(t,e){if(typeof t=="string"){let n=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.dayOfWeek%"),n,[e])}let r=Ge(kr(t,"dayOfWeek"),t,[e]);if(typeof r!="number")throw new TypeError("calendar dayOfWeek result must be a positive integer");if(!ac(r)||r<1)throw new RangeError("calendar dayOfWeek result must be a positive integer");return r}function AN(t,e){if(typeof t=="string"){let n=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.dayOfYear%"),n,[e])}let r=Ge(kr(t,"dayOfYear"),t,[e]);if(typeof r!="number")throw new TypeError("calendar dayOfYear result must be a positive integer");if(!ac(r)||r<1)throw new RangeError("calendar dayOfYear result must be a positive integer");return r}function TN(t,e){if(typeof t=="string"){let n=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.weekOfYear%"),n,[e])}let r=Ge(kr(t,"weekOfYear"),t,[e]);if(typeof r!="number")throw new TypeError("calendar weekOfYear result must be a positive integer");if(!ac(r)||r<1)throw new RangeError("calendar weekOfYear result must be a positive integer");return r}function PN(t,e){if(typeof t=="string"){let n=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.yearOfWeek%"),n,[e])}let r=Ge(kr(t,"yearOfWeek"),t,[e]);if(typeof r!="number")throw new TypeError("calendar yearOfWeek result must be an integer");if(!ac(r))throw new RangeError("calendar yearOfWeek result must be an integer");return r}function IN(t,e){if(typeof t=="string"){let n=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.daysInWeek%"),n,[e])}let r=Ge(kr(t,"daysInWeek"),t,[e]);if(typeof r!="number")throw new TypeError("calendar daysInWeek result must be a positive integer");if(!ac(r)||r<1)throw new RangeError("calendar daysInWeek result must be a positive integer");return r}function TP(t,e){if(typeof t=="string"){let n=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.daysInMonth%"),n,[e])}let r=Ge(kr(t,"daysInMonth"),t,[e]);if(typeof r!="number")throw new TypeError("calendar daysInMonth result must be a positive integer");if(!ac(r)||r<1)throw new RangeError("calendar daysInMonth result must be a positive integer");return r}function PP(t,e){if(typeof t=="string"){let n=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.daysInYear%"),n,[e])}let r=Ge(kr(t,"daysInYear"),t,[e]);if(typeof r!="number")throw new TypeError("calendar daysInYear result must be a positive integer");if(!ac(r)||r<1)throw new RangeError("calendar daysInYear result must be a positive integer");return r}function IP(t,e){if(typeof t=="string"){let n=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.monthsInYear%"),n,[e])}let r=Ge(kr(t,"monthsInYear"),t,[e]);if(typeof r!="number")throw new TypeError("calendar monthsInYear result must be a positive integer");if(!ac(r)||r<1)throw new RangeError("calendar monthsInYear result must be a positive integer");return r}function kP(t,e){if(typeof t=="string"){let n=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.inLeapYear%"),n,[e])}let r=Ge(kr(t,"inLeapYear"),t,[e]);if(typeof r!="boolean")throw new TypeError("calendar inLeapYear result must be a boolean");return r}function Oa(t){if(cn(t)){if(Bi(t,fe))return R(t,fe);if(!function(i){return!!Cn(i)||"dateAdd"in i&&"dateFromFields"in i&&"dateUntil"in i&&"day"in i&&"dayOfWeek"in i&&"dayOfYear"in i&&"daysInMonth"in i&&"daysInWeek"in i&&"daysInYear"in i&&"fields"in i&&"id"in i&&"inLeapYear"in i&&"mergeFields"in i&&"month"in i&&"monthCode"in i&&"monthDayFromFields"in i&&"monthsInYear"in i&&"weekOfYear"in i&&"year"in i&&"yearMonthFromFields"in i&&"yearOfWeek"in i}(t))throw new TypeError("expected a Temporal.Calendar or object implementing the Temporal.Calendar protocol");return t}let e=xs(t);if(Wh(e))return lf(e);let r;try{({calendar:r}=pf(e))}catch{try{({calendar:r}=xN(e))}catch{({calendar:r}=EN(e))}}if(r||(r="iso8601"),!Wh(r))throw new RangeError(`invalid calendar identifier ${r}`);return lf(r)}function L6(t){if(Bi(t,fe))return R(t,fe);let{calendar:e}=t;return e===void 0?"iso8601":Oa(e)}function po(t){if(typeof t=="string")return t;let e=t.id;if(typeof e!="string")throw new TypeError("calendar.id should be a string");return e}function n2(t){return cn(t)?t:new(Ae("%Temporal.Calendar%"))(t)}function K6(t,e){return t===e?!0:po(t)===po(e)}function RP(t,e,r){if(t===e)return;let n=po(t),i=po(e);if(n!==i)throw new RangeError(`cannot ${r} of ${n} and ${i} calendars`)}function Due(t,e){if(t===e)return e;let r=po(t),n=po(e);if(r===n||r==="iso8601")return e;if(n==="iso8601")return t;throw new RangeError("irreconcilable calendars")}function Fh(t,e,r,n){if(typeof t=="string"){let o=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.dateFromFields%"),o,[e,r])}let i=Ge(n??kr(t,"dateFromFields"),t,[e,r]);if(!Jt(i))throw new TypeError("invalid result");return i}function av(t,e,r){if(typeof t=="string"){let i=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.yearMonthFromFields%"),i,[e,r])}let n=Ge(kr(t,"yearMonthFromFields"),t,[e,r]);if(!Sr(n))throw new TypeError("invalid result");return n}function G1(t,e,r){if(typeof t=="string"){let i=new(Ae("%Temporal.Calendar%"))(t);return Ge(Ae("%Temporal.Calendar.prototype.monthDayFromFields%"),i,[e,r])}let n=Ge(kr(t,"monthDayFromFields"),t,[e,r]);if(!Ri(n))throw new TypeError("invalid result");return n}function Lo(t){if(cn(t)){if(Ke(t))return R(t,Ur);if(!function(r){return!!Vc(r)||"getOffsetNanosecondsFor"in r&&"getPossibleInstantsFor"in r&&"id"in r}(t))throw new TypeError("expected a Temporal.TimeZone or object implementing the Temporal.TimeZone protocol");return t}return bqe(xs(t))}function x6(t){if(typeof t=="string")return t;let e=t.id;if(typeof e!="string")throw new TypeError("timeZone.id should be a string");return e}function Bue(t){return cn(t)?t:new(Ae("%Temporal.TimeZone%"))(t)}function Mue(t,e){return t===e?!0:x6(t)===x6(e)}function J1(t){return Yc(R(t,De),R(t,Oe),R(t,je),R(t,fe))}function kN(t){return new(Ae("%Temporal.PlainTime%"))(R(t,St),R(t,At),R(t,Tt),R(t,Pt),R(t,It),R(t,kt))}function Vu(t,e,r){if(typeof t=="string"){let i=new(Ae("%Temporal.TimeZone%"))(t);return Ge(Ae("%Temporal.TimeZone.prototype.getOffsetNanosecondsFor%"),i,[e])}let n=Ge(r??kr(t,"getOffsetNanosecondsFor"),t,[e]);if(typeof n!="number")throw new TypeError("bad return from getOffsetNanosecondsFor");if(!ac(n)||an(n)>=864e11)throw new RangeError("out-of-range return from getOffsetNanosecondsFor");return n}function Gj(t,e){return BP(Vu(t,e))}function sc(t,e,r){let n=R(e,ut),i=Vu(t,e),{year:o,month:s,day:a,hour:d,minute:u,second:c,millisecond:l,microsecond:p,nanosecond:m}=$ue(n);return{year:o,month:s,day:a,hour:d,minute:u,second:c,millisecond:l,microsecond:p,nanosecond:m}=DN(o,s,a,d,u,c,l,p,m+i),Ra(o,s,a,d,u,c,l,p,m,r)}function _s(t,e,r){return Oue(fP(t,e),t,e,r)}function Oue(t,e,r,n){let i=Ae("%Temporal.Instant%"),o=t.length;if(o===1)return t[0];if(o)switch(n){case"compatible":case"earlier":return t[0];case"later":return t[o-1];case"reject":throw new RangeError("multiple instants found")}let s=R(r,De),a=R(r,Oe),d=R(r,je),u=R(r,St),c=R(r,At),l=R(r,Tt),p=R(r,Pt),m=R(r,It),g=R(r,kt),v=Xm(s,a,d,u,c,l,p,m,g);if(v===null)throw new RangeError("DateTime outside of supported range");let x=new i(z.default.subtract(v,df)),S=new i(z.default.add(v,df)),P=Vu(e,x),A=Vu(e,S)-P;switch(n){case"earlier":{let $=R(r,fe),j=Ae("%Temporal.PlainDateTime%"),q=Xj(s,a,d,u,c,l,p,m,g,$,0,0,0,0,0,0,0,0,0,-A,void 0);return fP(e,new j(q.year,q.month,q.day,q.hour,q.minute,q.second,q.millisecond,q.microsecond,q.nanosecond,$))[0]}case"compatible":case"later":{let $=R(r,fe),j=Ae("%Temporal.PlainDateTime%"),q=Xj(s,a,d,u,c,l,p,m,g,$,0,0,0,0,0,0,0,0,0,A,void 0),F=fP(e,new j(q.year,q.month,q.day,q.hour,q.minute,q.second,q.millisecond,q.microsecond,q.nanosecond,$));return F[F.length-1]}case"reject":throw new RangeError("no such instant found")}}function fP(t,e,r){if(typeof t=="string"){let o=new(Ae("%Temporal.TimeZone%"))(t);return Ge(Ae("%Temporal.TimeZone.prototype.getPossibleInstantsFor%"),o,[e])}let n=Ge(r??kr(t,"getPossibleInstantsFor"),t,[e]),i=[];for(let o of n){if(!Ei(o))throw new TypeError("bad return from getPossibleInstantsFor");vue.call(i,o)}return i}function lv(t){let e;return t<0||t>9999?e=(t<0?"-":"+")+`000000${an(t)}`.slice(-6):e=`0000${t}`.slice(-4),e}function wn(t){return`00${t}`.slice(-2)}function DP(t,e,r,n,i){if(i==="minute")return"";let o=`:${wn(t)}`,s,a=1e6*e+1e3*r+n;if(i==="auto"){if(a===0)return o;for(s=`${a}`.padStart(9,"0");s[s.length-1]==="0";)s=s.slice(0,-1)}else{if(i===0)return o;s=`${a}`.padStart(9,"0").slice(0,i)}return`${o}.${s}`}function Ude(t,e,r){let n=e;n===void 0&&(n="UTC");let i=sc(n,t,"iso8601"),o=lv(R(i,De)),s=wn(R(i,Oe)),a=wn(R(i,je)),d=wn(R(i,St)),u=wn(R(i,At)),c=DP(R(i,Tt),R(i,Pt),R(i,It),R(i,kt),r),l="Z";return e!==void 0&&(l=Cue(Vu(n,t))),`${o}-${s}-${a}T${d}:${u}${c}${l}`}function Nj(t,e="auto",r){function n(W){return W<=lqe?W.toString(10):z.default.BigInt(W).toString(10)}let i=R(t,fs),o=R(t,Gi),s=R(t,oa),a=R(t,hs),d=R(t,ps),u=R(t,ms),c=R(t,ys),l=R(t,gs),p=R(t,vs),m=R(t,bs),g=cf(i,o,s,a,d,u,c,l,p,m);if(r){let{unit:W,increment:L,roundingMode:I}=r;({seconds:c,milliseconds:l,microseconds:p,nanoseconds:m}=zh(0,0,0,0,0,0,c,l,p,m,L,W,I))}let v=[];i&&v.push(`${n(an(i))}Y`),o&&v.push(`${n(an(o))}M`),s&&v.push(`${n(an(s))}W`),a&&v.push(`${n(an(a))}D`);let x=[];d&&x.push(`${n(an(d))}H`),u&&x.push(`${n(an(u))}M`);let S=[],P,A,$,j,q=Z1(0,0,0,c,l,p,m,0);({quotient:q,remainder:P}=Yn(q,Ar)),{quotient:q,remainder:A}=Yn(q,Ar),{quotient:j,remainder:$}=Yn(q,Ar);let F=1e6*an(z.default.toNumber($))+1e3*an(z.default.toNumber(A))+an(z.default.toNumber(P)),K;if(e==="auto"){if(F!==0)for(K=`${F}`.padStart(9,"0");K[K.length-1]==="0";)K=K.slice(0,-1)}else e!==0&&(K=`${F}`.padStart(9,"0").slice(0,e));return K&&S.unshift(".",K),z.default.equal(j,Nn)&&!S.length&&e==="auto"||S.unshift(zu(j).toString()),S.length&&x.push(`${S.join("")}S`),x.length&&x.unshift("T"),v.length||x.length?`${g<0?"-":""}P${v.join("")}${x.join("")}`:"PT0S"}function qde(t,e="auto"){return`${lv(R(t,De))}-${wn(R(t,Oe))}-${wn(R(t,je))}${wN(R(t,fe),e)}`}function Lde(t,e,r="auto",n){let i=R(t,De),o=R(t,Oe),s=R(t,je),a=R(t,St),d=R(t,At),u=R(t,Tt),c=R(t,Pt),l=R(t,It),p=R(t,kt);if(n){let{unit:m,increment:g,roundingMode:v}=n;({year:i,month:o,day:s,hour:a,minute:d,second:u,millisecond:c,microsecond:l,nanosecond:p}=jN(i,o,s,a,d,u,c,l,p,g,m,v))}return`${lv(i)}-${wn(o)}-${wn(s)}T${wn(a)}:${wn(d)}${DP(u,c,l,p,e)}${wN(R(t,fe),r)}`}function Kde(t,e="auto"){let r=`${wn(R(t,Oe))}-${wn(R(t,je))}`,n=po(R(t,fe));(e==="always"||e==="critical"||n!=="iso8601")&&(r=`${lv(R(t,De))}-${r}`);let i=_N(n,e);return i&&(r+=i),r}function Fde(t,e="auto"){let r=`${lv(R(t,De))}-${wn(R(t,Oe))}`,n=po(R(t,fe));(e==="always"||e==="critical"||n!=="iso8601")&&(r+=`-${wn(R(t,je))}`);let i=_N(n,e);return i&&(r+=i),r}function zde(t,e,r="auto",n="auto",i="auto",o){let s=R(t,qo);if(o){let{unit:c,increment:l,roundingMode:p}=o,m=mP(R(t,ut),l,c,p);s=new(Ae("%Temporal.Instant%"))(m)}let a=R(t,Ur),d=sc(a,s,"iso8601"),u=`${lv(R(d,De))}-${wn(R(d,Oe))}-${wn(R(d,je))}T${wn(R(d,St))}:${wn(R(d,At))}${DP(R(d,Tt),R(d,Pt),R(d,It),R(d,kt),e)}`;return i!=="never"&&(u+=Cue(Vu(a,s))),n!=="never"&&(u+=`[${n==="critical"?"!":""}${x6(a)}]`),u+=wN(R(t,fe),r),u}function $1(t){return Yue.test(M6(t))}function Ym(t){let e=Yue.exec(M6(t));if(!e)throw new RangeError(`invalid time zone offset: ${t}`);return(e[1]==="-"||e[1]==="\u2212"?-1:1)*(1e9*(60*(60*+e[2]+ +(e[3]||0))+ +(e[4]||0))+ +((e[5]||0)+"000000000").slice(0,9))}function RN(t){return $1(t)?BP(Ym(t)):Aue(M6(t)).resolvedOptions().timeZone}function qh(t,e){let{year:r,month:n,day:i,hour:o,minute:s,second:a,millisecond:d,microsecond:u,nanosecond:c}=jue(t,e),l=r%400,p=(r-l)/400,m=z.default.multiply(z.default.BigInt(146097),df),g=Xm(l,n,i,o,s,a,d,u,c),v=z.default.add(g,z.default.multiply(m,z.default.BigInt(p)));return z.default.toNumber(z.default.subtract(v,e))}function BP(t){let e=t<0?"-":"+",r=an(t),n=r%1e9,i=Ba(r/1e9)%60,o=Ba(r/6e10)%60,s=wn(Ba(r/36e11)),a=wn(o),d=wn(i),u="";if(n){let c=`${n}`.padStart(9,"0");for(;c[c.length-1]==="0";)c=c.slice(0,-1);u=`:${d}.${c}`}else i&&(u=`:${d}`);return`${e}${s}:${a}${u}`}function Cue(t){let e=z.default.toNumber(oc(z.default.BigInt(t),xue,"halfExpand")),r=e<0?"-":"+";e=an(e);let n=e/6e10%60;return`${r}${wn(Ba(e/36e11))}:${wn(n)}`}function Xm(t,e,r,n,i,o,s,a,d){let u=new Date;u.setUTCHours(n,i,o,s),u.setUTCFullYear(t,e-1,r);let c=u.getTime();if(bP(c))return null;let l=z.default.multiply(z.default.BigInt(c),Jc);return l=z.default.add(l,z.default.multiply(z.default.BigInt(a),Ar)),l=z.default.add(l,z.default.BigInt(d)),z.default.lessThan(l,b6)||z.default.greaterThan(l,W1)?null:l}function $ue(t){let{quotient:e,remainder:r}=Yn(t,Jc),n=z.default.toNumber(e),i=z.default.toNumber(r);i<0&&(i+=1e6,n-=1);let o=Ba(i/1e3)%1e3,s=i%1e3,a=new Date(n);return{epochMilliseconds:n,year:a.getUTCFullYear(),month:a.getUTCMonth()+1,day:a.getUTCDate(),hour:a.getUTCHours(),minute:a.getUTCMinutes(),second:a.getUTCSeconds(),millisecond:a.getUTCMilliseconds(),microsecond:o,nanosecond:s}}function jue(t,e){let{epochMilliseconds:r,millisecond:n,microsecond:i,nanosecond:o}=$ue(e),{year:s,month:a,day:d,hour:u,minute:c,second:l}=function(m,g){let v=Aue(m).format(new Date(g));return function(S){let P=S.split(/[^\w]+/);if(P.length!==7)throw new RangeError(`expected 7 parts in "${S}`);let A=+P[0],$=+P[1],j=+P[2],q=P[3].toUpperCase();if(q==="B"||q==="BC")j=1-j;else if(q!=="A"&&q!=="AD")throw new RangeError(`Unknown era ${q} in "${S}`);let F=+P[4];F===24&&(F=0);let K=+P[5],W=+P[6];if(!(ws(j)&&ws(A)&&ws($)&&ws(F)&&ws(K)&&ws(W)))throw new RangeError(`Invalid number in "${S}`);return{year:j,month:A,day:$,hour:F,minute:K,second:W}}(v)}(t,r);return DN(s,a,d,u,c,l,n,i,o)}function Wde(t,e){return z.default.lessThan(t,e)?e:t}function Nue(){return z.default.add(UN(),mqe)}function Uue(t,e){if(z.default.lessThan(e,j1))return Uue(t,j1);let r=z.default.add(e,Eue),n=Wde(Nue(),r),i=Wde(j1,e),o=qh(t,i),s=i,a=o;for(;o===a&&z.default.lessThan(z.default.BigInt(i),n);){if(s=z.default.add(i,Sue),z.default.greaterThan(s,W1))return null;a=qh(t,s),o===a&&(i=s)}return o===a?null:Xue(d=>qh(t,d),i,s,o,a)}function Jj(t,e){let r=Nue(),n=z.default.greaterThan(e,r),i=n?z.default.subtract(e,Eue):j1;if(t==="Africa/Casablanca"||t==="Africa/El_Aaiun"){let u=R(Wu("2088-01-01T00Z"),ut);if(z.default.lessThan(u,e))return Jj(t,u)}let o=z.default.subtract(e,Q1);if(z.default.lessThan(o,j1))return null;let s=qh(t,o),a=o,d=s;for(;s===d&&z.default.greaterThan(o,i);){if(a=z.default.subtract(o,Sue),z.default.lessThan(a,j1))return null;d=qh(t,a),s===d&&(o=a)}if(s===d){if(n){let u=z.default.subtract(r,df);return Jj(t,u)}return null}return Xue(u=>qh(t,u),a,o,d,s)}function Qm(t){return t===void 0?!1:t%4==0&&(t%100!=0||t%400==0)}function Lh(t,e){return{standard:[31,28,31,30,31,30,31,31,30,31,30,31],leapyear:[31,29,31,30,31,30,31,31,30,31,30,31]}[Qm(t)?"leapyear":"standard"][e-1]}function Zj(t,e,r){let n=e+(e<3?10:-2),i=t-(e<3?1:0),o=Ba(i/100),s=i-100*o,a=(r+Ba(2.6*n-.2)+(s+Ba(s/4))+(Ba(o/4)-2*o))%7;return a+(a<=0?7:0)}function hP(t,e,r){let n=r;for(let i=e-1;i>0;i--)n+=Lh(t,i);return n}function Hde(t,e,r){let n=hP(t,e,r),i=Zj(t,e,r)||7,o=Zj(t,1,1),s=Ba((n-i+10)/7);return s<1?o===5||o===6&&Qm(t-1)?{week:53,year:t-1}:{week:52,year:t-1}:s===53&&(Qm(t)?366:365)-n<4-i?{week:1,year:t+1}:{week:s,year:t}}function cf(t,e,r,n,i,o,s,a,d,u){for(let c of[t,e,r,n,i,o,s,a,d,u])if(c!==0)return c<0?-1:1;return 0}function eP(t,e){let r=t,n=e;if(!ws(r)||!ws(n))throw new RangeError("infinity is out of range");return n-=1,r+=Ba(n/12),n%=12,n<0&&(n+=12),n+=1,{year:r,month:n}}function MP(t,e,r){let n=t,i=e,o=r;if(!ws(o))throw new RangeError("infinity is out of range");({year:n,month:i}=eP(n,i));let s=146097;if(an(o)>s){let u=Qg(o/s);n+=400*u,o-=u*s}let a=0,d=i>2?n:n-1;for(;a=Qm(d)?366:365,o<-a;)n-=1,d-=1,o+=a;for(d+=1;a=Qm(d)?366:365,o>a;)n+=1,d+=1,o-=a;for(;o<1;)({year:n,month:i}=eP(n,i-1)),o+=Lh(n,i);for(;o>Lh(n,i);)o-=Lh(n,i),{year:n,month:i}=eP(n,i+1);return{year:n,month:i,day:o}}function DN(t,e,r,n,i,o,s,a,d){let{deltaDays:u,hour:c,minute:l,second:p,millisecond:m,microsecond:g,nanosecond:v}=Nh(n,i,o,s,a,d),{year:x,month:S,day:P}=MP(t,e,r+u);return{year:x,month:S,day:P,hour:c,minute:l,second:p,millisecond:m,microsecond:g,nanosecond:v}}function Nh(t,e,r,n,i,o){let s,a=z.default.BigInt(t),d=z.default.BigInt(e),u=z.default.BigInt(r),c=z.default.BigInt(n),l=z.default.BigInt(i),p=z.default.BigInt(o);return{quotient:s,remainder:p}=Yg(p,Ar),l=z.default.add(l,s),{quotient:s,remainder:l}=Yg(l,Ar),c=z.default.add(c,s),{quotient:s,remainder:c}=Yg(c,Ar),u=z.default.add(u,s),{quotient:s,remainder:u}=Yg(u,sf),d=z.default.add(d,s),{quotient:s,remainder:d}=Yg(d,sf),a=z.default.add(a,s),{quotient:s,remainder:a}=Yg(a,wue),{deltaDays:z.default.toNumber(s),hour:z.default.toNumber(a),minute:z.default.toNumber(d),second:z.default.toNumber(u),millisecond:z.default.toNumber(c),microsecond:z.default.toNumber(l),nanosecond:z.default.toNumber(p)}}function Z1(t,e,r,n,i,o,s,a){let d=z.default.BigInt(t),u=z.default.BigInt(s);t!==0&&(u=z.default.subtract(z.default.BigInt(s),z.default.BigInt(a)));let c=z.default.add(z.default.BigInt(e),z.default.multiply(d,z.default.BigInt(24))),l=z.default.add(z.default.BigInt(r),z.default.multiply(c,sf)),p=z.default.add(z.default.BigInt(n),z.default.multiply(l,sf)),m=z.default.add(z.default.BigInt(i),z.default.multiply(p,Ar)),g=z.default.add(z.default.BigInt(o),z.default.multiply(m,Ar));return z.default.add(z.default.BigInt(u),z.default.multiply(g,Ar))}function BN(t,e){let r=Ae("%Temporal.Instant%"),n=z1(z.default.toNumber(t)),i=z.default.BigInt(t),o=864e11;if(n===0)return{days:0,nanoseconds:Nn,dayLengthNs:o};if(!Ke(e)){let A;return{quotient:A,remainder:i}=Yn(i,z.default.BigInt(o)),{days:z.default.toNumber(A),nanoseconds:i,dayLengthNs:o}}let s=R(e,ut),a=R(e,qo),d=z.default.add(s,i),u=new r(d),c=R(e,Ur),l=R(e,fe),p=sc(c,a,l),m=sc(c,u,l),{days:g}=$N(R(p,De),R(p,Oe),R(p,je),R(p,St),R(p,At),R(p,Tt),R(p,Pt),R(p,It),R(p,kt),R(m,De),R(m,Oe),R(m,je),R(m,St),R(m,At),R(m,Tt),R(m,Pt),R(m,It),R(m,kt),l,"day",Ko(null)),v=Zc(a,c,l,0,0,0,g,0,0,0,0,0,0),x=z.default.BigInt(g);if(n===1)for(;z.default.greaterThan(x,Nn)&&z.default.greaterThan(v,d);)x=z.default.subtract(x,Q1),v=Zc(a,c,l,0,0,0,z.default.toNumber(x),0,0,0,0,0,0);i=z.default.subtract(d,v);let S=!1,P=new r(v);do{let A=Zc(P,c,l,0,0,0,n,0,0,0,0,0,0),$=R(P,ut);o=z.default.toNumber(z.default.subtract(A,$)),S=z.default.greaterThanOrEqual(z.default.multiply(z.default.subtract(i,z.default.BigInt(o)),z.default.BigInt(n)),Nn),S&&(i=z.default.subtract(i,z.default.BigInt(o)),P=new r(A),x=z.default.add(x,z.default.BigInt(n)))}while(S);if(!Gc(x)&&Bde(x)!==n)throw new RangeError("Time zone or calendar converted nanoseconds into a number of days with the opposite sign");if(!Gc(i)&&Bde(i)!==n)throw sP(i)&&n===1?new Error("assert not reached"):new RangeError("Time zone or calendar ended up with a remainder of nanoseconds with the opposite sign");if(z.default.greaterThanOrEqual(zu(i),zu(z.default.BigInt(o))))throw new Error("assert not reached");return{days:z.default.toNumber(x),nanoseconds:i,dayLengthNs:an(o)}}function Kd(t,e,r,n,i,o,s,a,d){let u=que(t,e,r,n,i,o,s,a,d);if(u==="positive overflow"||u==="negative overflow")throw new RangeError("Duration out of range");return u}function que(t,e,r,n,i,o,s,a,d){let u,c,l,p,m,g,v=t;if(Ke(d)){let F=Zc(R(d,qo),R(d,Ur),R(d,fe),0,0,0,v,e,r,n,i,o,s),K=R(d,ut);u=z.default.subtract(F,K)}else u=Z1(v,e,r,n,i,o,s,0);a==="year"||a==="month"||a==="week"||a==="day"?{days:v,nanoseconds:u}=BN(u,d):v=0;let x=z.default.lessThan(u,Nn)?-1:1;switch(u=zu(u),c=l=p=m=g=Nn,a){case"year":case"month":case"week":case"day":case"hour":({quotient:c,remainder:u}=Yn(u,Ar)),{quotient:l,remainder:c}=Yn(c,Ar),{quotient:p,remainder:l}=Yn(l,Ar),{quotient:m,remainder:p}=Yn(p,sf),{quotient:g,remainder:m}=Yn(m,sf);break;case"minute":({quotient:c,remainder:u}=Yn(u,Ar)),{quotient:l,remainder:c}=Yn(c,Ar),{quotient:p,remainder:l}=Yn(l,Ar),{quotient:m,remainder:p}=Yn(p,sf);break;case"second":({quotient:c,remainder:u}=Yn(u,Ar)),{quotient:l,remainder:c}=Yn(c,Ar),{quotient:p,remainder:l}=Yn(l,Ar);break;case"millisecond":({quotient:c,remainder:u}=Yn(u,Ar)),{quotient:l,remainder:c}=Yn(c,Ar);break;case"microsecond":({quotient:c,remainder:u}=Yn(u,Ar));break;case"nanosecond":break;default:throw new Error("assert not reached")}let S=z.default.toNumber(g)*x,P=z.default.toNumber(m)*x,A=z.default.toNumber(p)*x,$=z.default.toNumber(l)*x,j=z.default.toNumber(c)*x,q=z.default.toNumber(u)*x;for(let F of[v,S,P,A,$,j,q])if(!ws(F))return x===1?"positive overflow":"negative overflow";return{days:v,hours:S,minutes:P,seconds:A,milliseconds:$,microseconds:j,nanoseconds:q}}function XT(t,e,r,n,i,o){let s=Ae("%Temporal.Duration%"),a=cf(t,e,r,n,0,0,0,0,0,0);if(a===0)return{years:t,months:e,weeks:r,days:n};let d=z.default.BigInt(a),u,c,l=z.default.BigInt(t),p=z.default.BigInt(e),m=z.default.BigInt(r),g=z.default.BigInt(n);o&&(c=Lr(o),u=R(c,fe));let v=new s(a),x=new s(0,a),S=new s(0,0,a);switch(i){case"year":break;case"month":{if(!u)throw new RangeError("a starting point is required for months balancing");let P,A;for(typeof u!="string"&&(P=kr(u,"dateAdd"),A=kr(u,"dateUntil"));!Gc(l);){let $=fo(u,c,v,void 0,P),j=Ko(null);j.largestUnit="month";let q=Zm(u,c,$,j,A),F=z.default.BigInt(R(q,Gi));c=$,p=z.default.add(p,F),l=z.default.subtract(l,d)}}break;case"week":{if(!u)throw new RangeError("a starting point is required for weeks balancing");let P=typeof u!="string"?kr(u,"dateAdd"):void 0;for(;!Gc(l);){let A;({relativeTo:c,days:A}=Uo(u,c,v,P)),g=z.default.add(g,z.default.BigInt(A)),l=z.default.subtract(l,d)}for(;!Gc(p);){let A;({relativeTo:c,days:A}=Uo(u,c,x,P)),g=z.default.add(g,z.default.BigInt(A)),p=z.default.subtract(p,d)}break}default:{if(Gc(l)&&Gc(p)&&Gc(m))break;if(!u)throw new RangeError("a starting point is required for balancing calendar units");let P=typeof u!="string"?kr(u,"dateAdd"):void 0;for(;!Gc(l);){let A;({relativeTo:c,days:A}=Uo(u,c,v,P)),g=z.default.add(g,z.default.BigInt(A)),l=z.default.subtract(l,d)}for(;!Gc(p);){let A;({relativeTo:c,days:A}=Uo(u,c,x,P)),g=z.default.add(g,z.default.BigInt(A)),p=z.default.subtract(p,d)}for(;!Gc(m);){let A;({relativeTo:c,days:A}=Uo(u,c,S,P)),g=z.default.add(g,z.default.BigInt(A)),m=z.default.subtract(m,d)}break}}return{years:z.default.toNumber(l),months:z.default.toNumber(p),weeks:z.default.toNumber(m),days:z.default.toNumber(g)}}function Vde(t,e,r,n,i){if(Ke(t)){let o=R(t,qo),s=R(t,Ur),a=R(t,fe),d=Vu(s,o),u=Zc(o,s,a,e,r,n,i,0,0,0,0,0,0);return Vu(s,new(Ae("%Temporal.Instant%"))(u))-d}return 0}function Lue(t){return new(Ae("%Temporal.Duration%"))(-R(t,fs),-R(t,Gi),-R(t,oa),-R(t,hs),-R(t,ps),-R(t,ms),-R(t,ys),-R(t,gs),-R(t,vs),-R(t,bs))}function Da(t,e,r){return cqe(r,dqe(e,t))}function Kue(t,e,r){let n=Da(e,1,12);return{year:t,month:n,day:Da(r,1,Lh(t,n))}}function ho(t,e,r){if(tr)throw new RangeError(`value out of range: ${e} <= ${t} <= ${r}`)}function uf(t,e,r){ho(e,1,12),ho(r,1,Lh(t,e))}function Fue(t,e,r){zue(t,e,r,12,0,0,0,0,0)}function OP(t,e,r,n,i,o){ho(t,0,23),ho(e,0,59),ho(r,0,59),ho(n,0,999),ho(i,0,999),ho(o,0,999)}function MN(t,e,r,n,i,o,s,a,d){uf(t,e,r),OP(n,i,o,s,a,d)}function zue(t,e,r,n,i,o,s,a,d){if(ho(t,iP,oP),t===iP&&Xm(t,e,r+1,n,i,o,s,a,d-1)==null||t===oP&&Xm(t,e,r-1,n,i,o,s,a,d+1)==null)throw new RangeError("DateTime outside of supported range")}function Xg(t){if(z.default.lessThan(t,b6)||z.default.greaterThan(t,W1))throw new RangeError("Instant outside of supported range")}function pP(t,e,r,n,i,o,s,a,d,u){let c=cf(t,e,r,n,i,o,s,a,d,u);for(let l of[t,e,r,n,i,o,s,a,d,u]){if(!ws(l))throw new RangeError("infinite values not allowed as duration fields");let p=z1(l);if(p!==0&&p!==c)throw new RangeError("mixed-sign values not allowed as duration fields")}}function ON(t,e,r,n,i,o,s){switch(s){case"year":case"month":{let a=-Jm(t,e,r,n,i,o);if(a===0)return{years:0,months:0,weeks:0,days:0};let d={year:t,month:e,day:r},u={year:n,month:i,day:o},c=u.year-d.year,l=tv(t,e,r,c,0,0,0,"constrain"),p=-Jm(l.year,l.month,l.day,n,i,o);if(p===0)return s==="year"?{years:c,months:0,weeks:0,days:0}:{years:0,months:12*c,weeks:0,days:0};let m=u.month-d.month;if(p!==a&&(c-=a,m+=12*a),l=tv(t,e,r,c,m,0,0,"constrain"),p=-Jm(l.year,l.month,l.day,n,i,o),p===0)return s==="year"?{years:c,months:m,weeks:0,days:0}:{years:0,months:m+12*c,weeks:0,days:0};p!==a&&(m-=a,m===-a&&(c-=a,m=11*a),l=tv(t,e,r,c,m,0,0,"constrain"));let g=0;return g=l.month===u.month?u.day-l.day:a<0?-l.day-(Lh(u.year,u.month)-u.day):u.day+(Lh(l.year,l.month)-l.day),s==="month"&&(m+=12*c,c=0),{years:c,months:m,weeks:0,days:g}}case"week":case"day":{let a,d,u;Jm(t,e,r,n,i,o)<0?(d={year:t,month:e,day:r},a={year:n,month:i,day:o},u=1):(d={year:n,month:i,day:o},a={year:t,month:e,day:r},u=-1);let c=hP(a.year,a.month,a.day)-hP(d.year,d.month,d.day);for(let p=d.year;p{let v=g[0],x=g[1],S=g[2];return r!=="datetime"&&S!==r||n.includes(x)||m.push(x,v),m},[]),a=Ma(e,"largestUnit",r,"auto");if(n.includes(a))throw new RangeError(`largestUnit must be one of ${s.join(", ")}, not ${a}`);let d=t2(e),u=Hu(e,"trunc");t==="since"&&(u=function(g){switch(g){case"ceil":return"floor";case"floor":return"ceil";case"halfCeil":return"halfFloor";case"halfFloor":return"halfCeil";default:return g}}(u));let c=Ma(e,"smallestUnit",r,i);if(n.includes(c))throw new RangeError(`smallestUnit must be one of ${s.join(", ")}, not ${c}`);let l=ov(o,c);if(a==="auto"&&(a=l),ov(a,c)!==a)throw new RangeError(`largestUnit ${a} cannot be smaller than smallestUnit ${c}`);let p={hour:24,minute:60,second:60,millisecond:1e3,microsecond:1e3,nanosecond:1e3}[c];return p!==void 0&&r2(d,p,!1),{largestUnit:a,roundingIncrement:d,roundingMode:u,smallestUnit:c}}function Gde(t,e,r,n){let i=t==="since"?-1:1,o=Wu(r),s=i2(t,iy(n),"time",[],"nanosecond","second"),a=R(e,ut),d=R(o,ut),{hours:u,minutes:c,seconds:l,milliseconds:p,microseconds:m,nanoseconds:g}=CN(a,d,s.roundingIncrement,s.smallestUnit,s.largestUnit,s.roundingMode);return new(Ae("%Temporal.Duration%"))(0,0,0,0,i*u,i*c,i*l,i*p,i*m,i*g)}function Jde(t,e,r,n){let i=t==="since"?-1:1,o=Lr(r),s=R(e,fe);RP(s,R(o,fe),"compute difference between dates");let a=iy(n),d=i2(t,a,"date",[],"day","day");a.largestUnit=d.largestUnit;let{years:u,months:c,weeks:l,days:p}=Zm(s,e,o,a);return d.smallestUnit==="day"&&d.roundingIncrement===1||({years:u,months:c,weeks:l,days:p}=zh(u,c,l,p,0,0,0,0,0,0,d.roundingIncrement,d.smallestUnit,d.roundingMode,e)),new(Ae("%Temporal.Duration%"))(i*u,i*c,i*l,i*p,0,0,0,0,0,0)}function Zde(t,e,r,n){let i=t==="since"?-1:1,o=ev(r),s=R(e,fe);RP(s,R(o,fe),"compute difference between dates");let a=iy(n),d=i2(t,a,"datetime",[],"nanosecond","day"),{years:u,months:c,weeks:l,days:p,hours:m,minutes:g,seconds:v,milliseconds:x,microseconds:S,nanoseconds:P}=$N(R(e,De),R(e,Oe),R(e,je),R(e,St),R(e,At),R(e,Tt),R(e,Pt),R(e,It),R(e,kt),R(o,De),R(o,Oe),R(o,je),R(o,St),R(o,At),R(o,Tt),R(o,Pt),R(o,It),R(o,kt),s,d.largestUnit,a),A=J1(e);return{years:u,months:c,weeks:l,days:p,hours:m,minutes:g,seconds:v,milliseconds:x,microseconds:S,nanoseconds:P}=zh(u,c,l,p,m,g,v,x,S,P,d.roundingIncrement,d.smallestUnit,d.roundingMode,A),{days:p,hours:m,minutes:g,seconds:v,milliseconds:x,microseconds:S,nanoseconds:P}=Kd(p,m,g,v,x,S,P,d.largestUnit),new(Ae("%Temporal.Duration%"))(i*u,i*c,i*l,i*p,i*m,i*g,i*v,i*x,i*S,i*P)}function Yde(t,e,r,n){let i=t==="since"?-1:1,o=Uh(r),s=i2(t,iy(n),"time",[],"nanosecond","hour"),{hours:a,minutes:d,seconds:u,milliseconds:c,microseconds:l,nanoseconds:p}=Wue(R(e,St),R(e,At),R(e,Tt),R(e,Pt),R(e,It),R(e,kt),R(o,St),R(o,At),R(o,Tt),R(o,Pt),R(o,It),R(o,kt));return{hours:a,minutes:d,seconds:u,milliseconds:c,microseconds:l,nanoseconds:p}=zh(0,0,0,0,a,d,u,c,l,p,s.roundingIncrement,s.smallestUnit,s.roundingMode),{hours:a,minutes:d,seconds:u,milliseconds:c,microseconds:l,nanoseconds:p}=Kd(0,a,d,u,c,l,p,s.largestUnit),new(Ae("%Temporal.Duration%"))(0,0,0,0,i*a,i*d,i*u,i*c,i*l,i*p)}function Xde(t,e,r,n){let i=t==="since"?-1:1,o=m6(r),s=R(e,fe);RP(s,R(o,fe),"compute difference between months");let a=iy(n),d=i2(t,a,"date",["week","day"],"month","year");a.largestUnit=d.largestUnit;let u=si(s,["monthCode","year"]),c=Ct(e,u,[]);c.day=1;let l=Fh(s,c),p=Ct(o,u,[]);p.day=1;let m=Fh(s,p),{years:g,months:v}=Zm(s,l,m,a);return d.smallestUnit==="month"&&d.roundingIncrement===1||({years:g,months:v}=zh(g,v,0,0,0,0,0,0,0,0,d.roundingIncrement,d.smallestUnit,d.roundingMode,l)),new(Ae("%Temporal.Duration%"))(i*g,i*v,0,0,0,0,0,0,0,0)}function Qde(t,e,r,n){let i=t==="since"?-1:1,o=y6(r),s=R(e,fe);RP(s,R(o,fe),"compute difference between dates");let a=iy(n),d=i2(t,a,"datetime",[],"nanosecond","hour");a.largestUnit=d.largestUnit;let u=R(e,ut),c=R(o,ut),l,p,m,g,v,x,S,P,A,$;if(d.largestUnit!=="year"&&d.largestUnit!=="month"&&d.largestUnit!=="week"&&d.largestUnit!=="day")l=0,p=0,m=0,g=0,{hours:v,minutes:x,seconds:S,milliseconds:P,microseconds:A,nanoseconds:$}=CN(u,c,d.roundingIncrement,d.smallestUnit,d.largestUnit,d.roundingMode);else{let j=R(e,Ur);if(!Mue(j,R(o,Ur)))throw new RangeError("When calculating difference between time zones, largestUnit must be 'hours' or smaller because day lengths can vary between time zones due to DST or time zone offset changes.");({years:l,months:p,weeks:m,days:g,hours:v,minutes:x,seconds:S,milliseconds:P,microseconds:A,nanoseconds:$}=Hue(u,c,j,s,d.largestUnit,a)),{years:l,months:p,weeks:m,days:g,hours:v,minutes:x,seconds:S,milliseconds:P,microseconds:A,nanoseconds:$}=zh(l,p,m,g,v,x,S,P,A,$,d.roundingIncrement,d.smallestUnit,d.roundingMode,e),{years:l,months:p,weeks:m,days:g,hours:v,minutes:x,seconds:S,milliseconds:P,microseconds:A,nanoseconds:$}=Zue(l,p,m,g,v,x,S,P,A,$,d.roundingIncrement,d.smallestUnit,d.roundingMode,e)}return new(Ae("%Temporal.Duration%"))(i*l,i*p,i*m,i*g,i*v,i*x,i*S,i*P,i*A,i*$)}function tv(t,e,r,n,i,o,s,a){let d=t,u=e,c=r,l=o,p=s;return d+=n,u+=i,{year:d,month:u}=eP(d,u),{year:d,month:u,day:c}=cP(d,u,c,a),p+=7*l,c+=p,{year:d,month:u,day:c}=MP(d,u,c),{year:d,month:u,day:c}}function Vue(t,e,r,n,i,o,s,a,d,u,c,l){let p=t,m=e,g=r,v=n,x=i,S=o;p+=s,m+=a,g+=d,v+=u,x+=c,S+=l;let P=0;return{deltaDays:P,hour:p,minute:m,second:g,millisecond:v,microsecond:x,nanosecond:S}=Nh(p,m,g,v,x,S),{deltaDays:P,hour:p,minute:m,second:g,millisecond:v,microsecond:x,nanosecond:S}}function Gue(t,e,r,n,i,o,s,a,d,u,c,l,p,m,g,v,x,S,P,A,$){let j=ov(Vj(t,e,r,n,i,o,s,a,d,u),Vj(c,l,p,m,g,v,x,S,P,A)),q,F,K,W,L,I,T,B,h,y;if($)if(Jt($)){let w=Ae("%Temporal.Duration%"),E=R($,fe),_=new w(t,e,r,n,0,0,0,0,0,0),b=new w(c,l,p,m,0,0,0,0,0,0),C=typeof E!="string"?kr(E,"dateAdd"):void 0,N=fo(E,$,_,void 0,C),M=fo(E,N,b,void 0,C),U=ov("day",j),G=Ko(null);G.largestUnit=U,{years:q,months:F,weeks:K,days:W}=Zm(E,$,M,G),{days:W,hours:L,minutes:I,seconds:T,milliseconds:B,microseconds:h,nanoseconds:y}=Kd(W,z.default.add(z.default.BigInt(i),z.default.BigInt(g)),z.default.add(z.default.BigInt(o),z.default.BigInt(v)),z.default.add(z.default.BigInt(s),z.default.BigInt(x)),z.default.add(z.default.BigInt(a),z.default.BigInt(S)),z.default.add(z.default.BigInt(d),z.default.BigInt(P)),z.default.add(z.default.BigInt(u),z.default.BigInt(A)),j)}else{let w=Ae("%Temporal.Instant%"),E=R($,Ur),_=R($,fe),b=Zc(R($,qo),E,_,t,e,r,n,i,o,s,a,d,u),C=Zc(new w(b),E,_,c,l,p,m,g,v,x,S,P,A);j!=="year"&&j!=="month"&&j!=="week"&&j!=="day"?(q=0,F=0,K=0,W=0,{hours:L,minutes:I,seconds:T,milliseconds:B,microseconds:h,nanoseconds:y}=CN(R($,ut),C,1,"nanosecond",j,"halfExpand")):{years:q,months:F,weeks:K,days:W,hours:L,minutes:I,seconds:T,milliseconds:B,microseconds:h,nanoseconds:y}=Hue(R($,ut),C,E,_,j,Ko(null))}else{if(j==="year"||j==="month"||j==="week")throw new RangeError("relativeTo is required for years, months, or weeks arithmetic");q=F=K=0,{days:W,hours:L,minutes:I,seconds:T,milliseconds:B,microseconds:h,nanoseconds:y}=Kd(n+m,z.default.add(z.default.BigInt(i),z.default.BigInt(g)),z.default.add(z.default.BigInt(o),z.default.BigInt(v)),z.default.add(z.default.BigInt(s),z.default.BigInt(x)),z.default.add(z.default.BigInt(a),z.default.BigInt(S)),z.default.add(z.default.BigInt(d),z.default.BigInt(P)),z.default.add(z.default.BigInt(u),z.default.BigInt(A)),j)}return pP(q,F,K,W,L,I,T,B,h,y),{years:q,months:F,weeks:K,days:W,hours:L,minutes:I,seconds:T,milliseconds:B,microseconds:h,nanoseconds:y}}function Yj(t,e,r,n,i,o,s){let a=Nn;a=z.default.add(a,z.default.BigInt(s)),a=z.default.add(a,z.default.multiply(z.default.BigInt(o),Ar)),a=z.default.add(a,z.default.multiply(z.default.BigInt(i),Jc)),a=z.default.add(a,z.default.multiply(z.default.BigInt(n),af)),a=z.default.add(a,z.default.multiply(z.default.BigInt(r),z.default.BigInt(6e10))),a=z.default.add(a,z.default.multiply(z.default.BigInt(e),z.default.BigInt(36e11)));let d=z.default.add(t,a);return Xg(d),d}function Xj(t,e,r,n,i,o,s,a,d,u,c,l,p,m,g,v,x,S,P,A,$){let j=m,{deltaDays:q,hour:F,minute:K,second:W,millisecond:L,microsecond:I,nanosecond:T}=Vue(n,i,o,s,a,d,g,v,x,S,P,A);j+=q;let B=Ae("%Temporal.Duration%"),h=fo(u,Yc(t,e,r,u),new B(c,l,p,j,0,0,0,0,0,0),$);return{year:R(h,De),month:R(h,Oe),day:R(h,je),hour:F,minute:K,second:W,millisecond:L,microsecond:I,nanosecond:T}}function Zc(t,e,r,n,i,o,s,a,d,u,c,l,p,m){let g=Ae("%Temporal.Duration%");if(cf(n,i,o,s,0,0,0,0,0,0)===0)return Yj(R(t,ut),a,d,u,c,l,p);let v=sc(e,t,r),x=fo(r,Yc(R(v,De),R(v,Oe),R(v,je),r),new g(n,i,o,s,0,0,0,0,0,0),m),S=Ra(R(x,De),R(x,Oe),R(x,je),R(v,St),R(v,At),R(v,Tt),R(v,Pt),R(v,It),R(v,kt),r);return Yj(R(_s(e,S,"compatible"),ut),a,d,u,c,l,p)}function eue(t,e,r,n){let i=t==="subtract"?-1:1,{years:o,months:s,weeks:a,days:d,hours:u,minutes:c,seconds:l,milliseconds:p,microseconds:m,nanoseconds:g}=uv(r),v=QT(tr(n));return{years:o,months:s,weeks:a,days:d,hours:u,minutes:c,seconds:l,milliseconds:p,microseconds:m,nanoseconds:g}=Gue(R(e,fs),R(e,Gi),R(e,oa),R(e,hs),R(e,ps),R(e,ms),R(e,ys),R(e,gs),R(e,vs),R(e,bs),i*o,i*s,i*a,i*d,i*u,i*c,i*l,i*p,i*m,i*g,v),new(Ae("%Temporal.Duration%"))(o,s,a,d,u,c,l,p,m,g)}function tue(t,e,r){let n=t==="subtract"?-1:1,{hours:i,minutes:o,seconds:s,milliseconds:a,microseconds:d,nanoseconds:u}=function(p,m){let g=uv(p);for(let v of m)if(g[v]!==0)throw new RangeError(`Duration field ${v} not supported by Temporal.Instant. Try Temporal.ZonedDateTime instead.`);return g}(r,["years","months","weeks","days"]),c=Yj(R(e,ut),n*i,n*o,n*s,n*a,n*d,n*u);return new(Ae("%Temporal.Instant%"))(c)}function rue(t,e,r,n){let i=t==="subtract"?-1:1,{years:o,months:s,weeks:a,days:d,hours:u,minutes:c,seconds:l,milliseconds:p,microseconds:m,nanoseconds:g}=uv(r),v=tr(n),x=R(e,fe),{year:S,month:P,day:A,hour:$,minute:j,second:q,millisecond:F,microsecond:K,nanosecond:W}=Xj(R(e,De),R(e,Oe),R(e,je),R(e,St),R(e,At),R(e,Tt),R(e,Pt),R(e,It),R(e,kt),x,i*o,i*s,i*a,i*d,i*u,i*c,i*l,i*p,i*m,i*g,v);return Ra(S,P,A,$,j,q,F,K,W,x)}function nue(t,e,r){let n=t==="subtract"?-1:1,{hours:i,minutes:o,seconds:s,milliseconds:a,microseconds:d,nanoseconds:u}=uv(r),{hour:c,minute:l,second:p,millisecond:m,microsecond:g,nanosecond:v}=Vue(R(e,St),R(e,At),R(e,Tt),R(e,Pt),R(e,It),R(e,kt),n*i,n*o,n*s,n*a,n*d,n*u);return{hour:c,minute:l,second:p,millisecond:m,microsecond:g,nanosecond:v}=_P(c,l,p,m,g,v,"reject"),new(Ae("%Temporal.PlainTime%"))(c,l,p,m,g,v)}function iue(t,e,r,n){let i=uv(r);t==="subtract"&&(i={years:-i.years,months:-i.months,weeks:-i.weeks,days:-i.days,hours:-i.hours,minutes:-i.minutes,seconds:-i.seconds,milliseconds:-i.milliseconds,microseconds:-i.microseconds,nanoseconds:-i.nanoseconds});let{years:o,months:s,weeks:a,days:d,hours:u,minutes:c,seconds:l,milliseconds:p,microseconds:m,nanoseconds:g}=i;({days:d}=Kd(d,u,c,l,p,m,g,"day"));let v=tr(n),x=R(e,fe),S=si(x,["monthCode","year"]),P=Ct(e,S,[]),A=Ko(null);N1(A,P,[]),P.day=1;let $=Fh(x,P),j=cf(o,s,a,d,0,0,0,0,0,0),q=kr(x,"dateAdd"),F=Ae("%Temporal.Duration%");if(j<0){let L=fo(x,$,new F(0,1,0,0,0,0,0,0,0,0),void 0,q),I=fo(x,L,new F(0,0,0,-1,0,0,0,0,0,0),void 0,q);A.day=q6(x,I),$=Fh(x,A)}let K=new F(o,s,a,d,0,0,0,0,0,0),W=iy(v);return av(x,Ct(fo(x,$,K,v,q),S,[]),W)}function oue(t,e,r,n){let i=t==="subtract"?-1:1,{years:o,months:s,weeks:a,days:d,hours:u,minutes:c,seconds:l,milliseconds:p,microseconds:m,nanoseconds:g}=uv(r),v=tr(n),x=R(e,Ur),S=R(e,fe);return lo(Zc(R(e,qo),x,S,i*o,i*s,i*a,i*d,i*u,i*c,i*l,i*p,i*m,i*g,v),x,S)}function oc(t,e,r){if(z.default.equal(e,Q1))return t;let{quotient:n,remainder:i}=Yn(t,e);if(z.default.equal(i,Nn))return t;let o=z.default.lessThan(i,Nn)?-1:1,s=zu(z.default.multiply(i,z.default.BigInt(2))),a=z.default.equal(s,e),d=z.default.greaterThan(s,e);switch(r){case"ceil":o>0&&(n=z.default.add(n,z.default.BigInt(o)));break;case"floor":o<0&&(n=z.default.add(n,z.default.BigInt(o)));break;case"expand":n=z.default.add(n,z.default.BigInt(o));break;case"trunc":break;case"halfCeil":(d||a&&o>0)&&(n=z.default.add(n,z.default.BigInt(o)));break;case"halfFloor":(d||a&&o<0)&&(n=z.default.add(n,z.default.BigInt(o)));break;case"halfExpand":(d||a)&&(n=z.default.add(n,z.default.BigInt(o)));break;case"halfTrunc":d&&(n=z.default.add(n,z.default.BigInt(o)));break;case"halfEven":(d||a&&z.default.toNumber(z.default.remainder(zu(n),z.default.BigInt(2)))===1)&&(n=z.default.add(n,z.default.BigInt(o)))}return z.default.multiply(n,e)}function mP(t,e,r,n){let{remainder:i}=Yg(t,df),o=z.default.subtract(t,i),s=oc(i,z.default.BigInt(Que[r]*e),n);return z.default.add(o,s)}function jN(t,e,r,n,i,o,s,a,d,u,c,l,p=864e11){let{deltaDays:m,hour:g,minute:v,second:x,millisecond:S,microsecond:P,nanosecond:A}=NN(n,i,o,s,a,d,u,c,l,p),{year:$,month:j,day:q}=MP(t,e,r+m);return{year:$,month:j,day:q,hour:g,minute:v,second:x,millisecond:S,microsecond:P,nanosecond:A}}function NN(t,e,r,n,i,o,s,a,d,u=864e11){let c=Nn;switch(a){case"day":case"hour":c=z.default.BigInt(t);case"minute":c=z.default.add(z.default.multiply(c,sf),z.default.BigInt(e));case"second":c=z.default.add(z.default.multiply(c,sf),z.default.BigInt(r));case"millisecond":c=z.default.add(z.default.multiply(c,Ar),z.default.BigInt(n));case"microsecond":c=z.default.add(z.default.multiply(c,Ar),z.default.BigInt(i));case"nanosecond":c=z.default.add(z.default.multiply(c,Ar),z.default.BigInt(o))}let l=a==="day"?u:Que[a],p=oc(c,z.default.BigInt(l*s),d),m=z.default.toNumber(z.default.divide(p,z.default.BigInt(l)));switch(a){case"day":return{deltaDays:m,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0};case"hour":return Nh(m,0,0,0,0,0);case"minute":return Nh(t,m,0,0,0,0);case"second":return Nh(t,e,m,0,0,0);case"millisecond":return Nh(t,e,r,m,0,0);case"microsecond":return Nh(t,e,r,n,m,0);case"nanosecond":return Nh(t,e,r,n,i,m);default:throw new Error(`Invalid unit ${a}`)}}function tP(t,e){return ON(R(t,De),R(t,Oe),R(t,je),R(e,De),R(e,Oe),R(e,je),"day").days}function Uo(t,e,r,n){let i=fo(t,e,r,void 0,n);return{relativeTo:i,days:tP(e,i)}}function Jue(t,e,r,n,i){let o=R(t,Ur),s=R(t,fe);return lo(Zc(R(t,qo),o,s,e,r,n,i,0,0,0,0,0,0),o,s)}function Zue(t,e,r,n,i,o,s,a,d,u,c,l,p,m){let g=t,v=e,x=r,S=n,P=i,A=o,$=s,j=a,q=d,F=u;if(!Ke(m)||l==="year"||l==="month"||l==="week"||l==="day"||l==="nanosecond"&&c===1)return{years:g,months:v,weeks:x,days:S,hours:P,minutes:A,seconds:$,milliseconds:j,microseconds:q,nanoseconds:F};let K=Z1(0,P,A,$,j,q,F,0),W=z1(z.default.toNumber(K)),L=R(m,Ur),I=R(m,fe),T=Zc(R(m,qo),L,I,g,v,x,S,0,0,0,0,0,0),B=Zc(new(Ae("%Temporal.Instant%"))(T),L,I,0,0,0,W,0,0,0,0,0,0),h=z.default.subtract(B,T);return z.default.greaterThanOrEqual(z.default.multiply(z.default.subtract(K,h),z.default.BigInt(W)),Nn)&&({years:g,months:v,weeks:x,days:S}=Gue(g,v,x,S,0,0,0,0,0,0,0,0,0,W,0,0,0,0,0,0,m),K=mP(z.default.subtract(K,h),c,l,p),{hours:P,minutes:A,seconds:$,milliseconds:j,microseconds:q,nanoseconds:F}=Kd(0,0,0,0,0,0,z.default.toNumber(K),"hour")),{years:g,months:v,weeks:x,days:S,hours:P,minutes:A,seconds:$,milliseconds:j,microseconds:q,nanoseconds:F}}function zh(t,e,r,n,i,o,s,a,d,u,c,l,p,m){let g=t,v=e,x=r,S=n,P=i,A=o,$=s,j=a,q=d,F=z.default.BigInt(u),K=Ae("%Temporal.Duration%"),W,L,I,T,B=m;if(B){if(Ke(B))L=B,B=Lr(B);else if(!Jt(B))throw new TypeError("starting point must be PlainDate or ZonedDateTime");W=R(B,fe)}if(l==="year"||l==="month"||l==="week"||l==="day"){let h,y,w;F=Z1(0,P,A,$,j,q,u,0),L&&(h=Jue(L,g,v,x,S)),{days:y,nanoseconds:F,dayLengthNs:w}=BN(F,h),I=z.default.BigInt(w),S+=y,P=A=$=j=q=0}switch(l){case"year":{if(!W)throw new RangeError("A starting point is required for years rounding");let h=new K(g),y=typeof W!="string"?kr(W,"dateAdd"):void 0,w=fo(W,B,h,void 0,y),E=fo(W,B,new K(g,v,x),void 0,y);B=w,S+=tP(w,E);let _=fo(W,B,new K(0,0,0,S),void 0,y),b=Ko(null);b.largestUnit="year";let C=Zm(W,B,_,b).years;g+=C;let N=B;B=fo(W,B,new K(C),void 0,y),S-=tP(N,B);let M=new K(S<0?-1:1),{days:U}=Uo(W,B,M,y);U=an(U);let G=z.default.multiply(z.default.BigInt(U),I);F=z.default.add(z.default.add(z.default.multiply(G,z.default.BigInt(g)),z.default.multiply(z.default.BigInt(S),I)),F);let Z=oc(F,z.default.multiply(G,z.default.BigInt(c)),p);T=nf(F,G),g=z.default.toNumber(z.default.divide(Z,G)),F=Nn,v=x=S=0;break}case"month":{if(!W)throw new RangeError("A starting point is required for months rounding");let h=new K(g,v),y=typeof W!="string"?kr(W,"dateAdd"):void 0,w=fo(W,B,h,void 0,y),E=fo(W,B,new K(g,v,x),void 0,y);B=w,S+=tP(w,E);let _=z1(S),b=new K(0,S<0?-1:1),C;for({relativeTo:B,days:C}=Uo(W,B,b,y);an(S)>=an(C);)v+=_,S-=C,{relativeTo:B,days:C}=Uo(W,B,b,y);C=an(C);let N=z.default.multiply(z.default.BigInt(C),I);F=z.default.add(z.default.add(z.default.multiply(N,z.default.BigInt(v)),z.default.multiply(z.default.BigInt(S),I)),F);let M=oc(F,z.default.multiply(N,z.default.BigInt(c)),p);T=nf(F,N),v=z.default.toNumber(z.default.divide(M,N)),F=Nn,x=S=0;break}case"week":{if(!W)throw new RangeError("A starting point is required for weeks rounding");let h=z1(S),y=new K(0,0,S<0?-1:1),w=typeof W!="string"?kr(W,"dateAdd"):void 0,E;for({relativeTo:B,days:E}=Uo(W,B,y,w);an(S)>=an(E);)x+=h,S-=E,{relativeTo:B,days:E}=Uo(W,B,y,w);E=an(E);let _=z.default.multiply(z.default.BigInt(E),I);F=z.default.add(z.default.add(z.default.multiply(_,z.default.BigInt(x)),z.default.multiply(z.default.BigInt(S),I)),F);let b=oc(F,z.default.multiply(_,z.default.BigInt(c)),p);T=nf(F,_),x=z.default.toNumber(z.default.divide(b,_)),F=Nn,S=0;break}case"day":{let h=I;F=z.default.add(z.default.multiply(h,z.default.BigInt(S)),F);let y=oc(F,z.default.multiply(h,z.default.BigInt(c)),p);T=nf(F,h),S=z.default.toNumber(z.default.divide(y,h)),F=Nn;break}case"hour":{let y=z.default.multiply(z.default.BigInt(P),z.default.BigInt(36e11));y=z.default.add(y,z.default.multiply(z.default.BigInt(A),z.default.BigInt(6e10))),y=z.default.add(y,z.default.multiply(z.default.BigInt($),af)),y=z.default.add(y,z.default.multiply(z.default.BigInt(j),Jc)),y=z.default.add(y,z.default.multiply(z.default.BigInt(q),Ar)),y=z.default.add(y,F),T=nf(y,z.default.BigInt(36e11));let w=oc(y,z.default.BigInt(36e11*c),p);P=z.default.toNumber(z.default.divide(w,z.default.BigInt(36e11))),F=Nn,A=$=j=q=0;break}case"minute":{let y=z.default.multiply(z.default.BigInt(A),z.default.BigInt(6e10));y=z.default.add(y,z.default.multiply(z.default.BigInt($),af)),y=z.default.add(y,z.default.multiply(z.default.BigInt(j),Jc)),y=z.default.add(y,z.default.multiply(z.default.BigInt(q),Ar)),y=z.default.add(y,F),T=nf(y,z.default.BigInt(6e10));let w=oc(y,z.default.BigInt(6e10*c),p);A=z.default.toNumber(z.default.divide(w,z.default.BigInt(6e10))),F=Nn,$=j=q=0;break}case"second":{let y=z.default.multiply(z.default.BigInt($),af);y=z.default.add(y,z.default.multiply(z.default.BigInt(j),Jc)),y=z.default.add(y,z.default.multiply(z.default.BigInt(q),Ar)),y=z.default.add(y,F),T=nf(y,z.default.BigInt(1e9));let w=oc(y,z.default.BigInt(1e9*c),p);$=z.default.toNumber(z.default.divide(w,z.default.BigInt(1e9))),F=Nn,j=q=0;break}case"millisecond":{let y=z.default.multiply(z.default.BigInt(j),Jc);y=z.default.add(y,z.default.multiply(z.default.BigInt(q),Ar)),y=z.default.add(y,F),T=nf(y,z.default.BigInt(1e6));let w=oc(y,z.default.BigInt(1e6*c),p);j=z.default.toNumber(z.default.divide(w,z.default.BigInt(1e6))),F=Nn,q=0;break}case"microsecond":{let y=z.default.multiply(z.default.BigInt(q),Ar);y=z.default.add(y,F),T=nf(y,z.default.BigInt(1e3));let w=oc(y,z.default.BigInt(1e3*c),p);q=z.default.toNumber(z.default.divide(w,z.default.BigInt(1e3))),F=Nn;break}case"nanosecond":T=z.default.toNumber(F),F=oc(z.default.BigInt(F),z.default.BigInt(c),p)}return{years:g,months:v,weeks:x,days:S,hours:P,minutes:A,seconds:$,milliseconds:j,microseconds:q,nanoseconds:z.default.toNumber(F),total:T}}function Jm(t,e,r,n,i,o){for(let[s,a]of[[t,n],[e,i],[r,o]])if(s!==a)return rv(s-a);return 0}function Yg(t,e){let{quotient:r,remainder:n}=Yn(t,e);return z.default.lessThan(n,Nn)&&(r=z.default.subtract(r,Q1),n=z.default.add(n,e)),{quotient:r,remainder:n}}function q1(t,e){let{quotient:r,remainder:n}=Yn(t,e);return Gc(n)||!sP(t)==!sP(e)?r:z.default.subtract(r,Q1)}function nf(t,e){let{quotient:r,remainder:n}=Yn(t,e);return z.default.toNumber(r)+z.default.toNumber(n)/z.default.toNumber(e)}function yP(t){let e=g6(t);return globalThis.BigInt!==void 0?globalThis.BigInt(e.toString(10)):e}function g6(t){let e=t;if(typeof t=="object"){let r=t[Symbol.toPrimitive];r&&typeof r=="function"&&(e=wP(r,t,["number"]))}if(typeof e=="number")throw new TypeError("cannot convert number to bigint");return typeof e=="bigint"?z.default.BigInt(e.toString(10)):z.default.BigInt(e)}var UN=(()=>{let t=z.default.BigInt(Date.now()%1e6);return()=>{let e=z.default.BigInt(Date.now()),r=z.default.add(z.default.multiply(e,Jc),t);return t=z.default.remainder(e,Jc),z.default.greaterThan(r,W1)?W1:z.default.lessThan(r,b6)?b6:r}})();function Gm(){return new bue().resolvedOptions().timeZone}function rv(t){return t<0?-1:t>0?1:t}function tr(t){if(t===void 0)return Ko(null);if(cn(t)&&t!==null)return t;throw new TypeError("Options parameter must be an object, not "+(t===null?"null":typeof t))}function Y1(t,e){let r=Ko(null);return r[t]=e,r}function iy(t){let e=Ko(null);return N1(e,tr(t),[]),e}function ey(t,e,r,n){let i=t[e];if(i!==void 0){if(i=xs(i),!r.includes(i))throw new RangeError(`${e} must be one of ${r.join(", ")}, not ${i}`);return i}return n}function Wh(t){return yqe.includes(lf(t))}function lf(t){return t.replace(/[A-Z]/g,e=>{let r=e.charCodeAt(0);return String.fromCharCode(r+32)})}var Yue=new RegExp(`^${yue.source}$`);function Xue(t,e,r,n=t(e),i=t(r)){let o=z.default.BigInt(e),s=z.default.BigInt(r),a=n,d=i;for(;z.default.greaterThan(z.default.subtract(s,o),Q1);){let u=z.default.divide(z.default.add(o,s),z.default.BigInt(2)),c=t(u);if(c===a)o=u,a=c;else{if(c!==d)throw new Error(`invalid state in bisection ${a} - ${c} - ${d}`);s=u,d=c}}return s}var Que={hour:36e11,minute:6e10,second:1e9,millisecond:1e6,microsecond:1e3,nanosecond:1},ele=Symbol("date"),tle=Symbol("ym"),rle=Symbol("md"),nle=Symbol("time"),ile=Symbol("datetime"),ole=Symbol("instant"),L1=Symbol("original"),C1=Symbol("timezone"),Ld=Symbol("calendar-id"),sle=Symbol("locale"),Qj=Symbol("options"),v6=t=>({value:t,enumerable:!0,writable:!1,configurable:!0}),K1=globalThis.Intl.DateTimeFormat,Hh=Object.assign,_qe=Object.prototype.hasOwnProperty,xqe=Reflect.apply;function O1(t,e){let r=t[e];return typeof r=="function"&&(r=new K1(t[sle],r(t[Qj])),t[e]=r),r}function cv(t,e={}){if(!(this instanceof cv))return new cv(t,e);let r=e!==void 0,n=r?Hh({},e):{},i=new K1(t,n),o=i.resolvedOptions();if(r){let s=Hh({},o);for(let a in s)xqe(_qe,n,[a])||delete s[a];this[Qj]=s}else this[Qj]=n;this[sle]=o.locale,this[L1]=i,this[C1]=o.timeZone,this[Ld]=o.calendar,this[ele]=Tqe,this[tle]=Sqe,this[rle]=Aqe,this[nle]=Eqe,this[ile]=Pqe,this[ole]=Iqe}Object.defineProperty(cv,"name",{writable:!0,value:"DateTimeFormat"}),cv.supportedLocalesOf=function(t,e){return K1.supportedLocalesOf(t,e)};var Uj={resolvedOptions:v6(function(){return this[L1].resolvedOptions()}),format:v6(function(e,...r){let{instant:n,formatter:i}=F1(e,this);return n&&i?i.format(n.epochMilliseconds):this[L1].format(e,...r)}),formatRange:v6(function(e,r){if(X1(e)||X1(r)){if(!ale(e,r))throw new TypeError("Intl.DateTimeFormat.formatRange accepts two values of the same type");let{instant:n,formatter:i}=F1(e,this),{instant:o,formatter:s}=F1(r,this);if(n&&o&&i&&s&&i===s)return i.formatRange(n.epochMilliseconds,o.epochMilliseconds)}return this[L1].formatRange(e,r)})};"formatToParts"in K1.prototype&&(Uj.formatToParts=v6(function(e,...r){let{instant:n,formatter:i}=F1(e,this);return n&&i?i.formatToParts(n.epochMilliseconds):this[L1].formatToParts(e,...r)})),"formatRangeToParts"in K1.prototype&&(Uj.formatRangeToParts=v6(function(e,r){if(X1(e)||X1(r)){if(!ale(e,r))throw new TypeError("Intl.DateTimeFormat.formatRangeToParts accepts two values of the same type");let{instant:n,formatter:i}=F1(e,this),{instant:o,formatter:s}=F1(r,this);if(n&&o&&i&&s&&i===s)return i.formatRangeToParts(n.epochMilliseconds,o.epochMilliseconds)}return this[L1].formatRangeToParts(e,r)})),cv.prototype=Object.create(K1.prototype,Uj),Object.defineProperty(cv,"prototype",{writable:!1,enumerable:!1,configurable:!1});var Vh=cv;function F6(t={},e={}){let r=Hh({},t);for(let n of["year","month","day","hour","minute","second","weekday","dayPeriod","timeZoneName","dateStyle","timeStyle"])r[n]=n in e?e[n]:r[n],r[n]!==!1&&r[n]!==void 0||delete r[n];return r}function Eqe(t){let e=F6(t,{year:!1,month:!1,day:!1,weekday:!1,timeZoneName:!1,dateStyle:!1});return LN(e)||(e=Hh({},e,{hour:"numeric",minute:"numeric",second:"numeric"})),e}function Sqe(t){let e=F6(t,{day:!1,hour:!1,minute:!1,second:!1,weekday:!1,dayPeriod:!1,timeZoneName:!1,dateStyle:!1,timeStyle:!1});return"year"in e||"month"in e||(e=Hh(e,{year:"numeric",month:"numeric"})),e}function Aqe(t){let e=F6(t,{year:!1,hour:!1,minute:!1,second:!1,weekday:!1,dayPeriod:!1,timeZoneName:!1,dateStyle:!1,timeStyle:!1});return"month"in e||"day"in e||(e=Hh({},e,{month:"numeric",day:"numeric"})),e}function Tqe(t){let e=F6(t,{hour:!1,minute:!1,second:!1,dayPeriod:!1,timeZoneName:!1,timeStyle:!1});return qN(e)||(e=Hh({},e,{year:"numeric",month:"numeric",day:"numeric"})),e}function Pqe(t){let e=F6(t,{timeZoneName:!1});return LN(e)||qN(e)||(e=Hh({},e,{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})),e}function Iqe(t){let e=t;return LN(e)||qN(e)||(e=Hh({},e,{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})),e}function qN(t){return"year"in t||"month"in t||"day"in t||"weekday"in t||"dateStyle"in t}function LN(t){return"hour"in t||"minute"in t||"second"in t||"timeStyle"in t||"dayPeriod"in t}function X1(t){return Jt(t)||jn(t)||_t(t)||Ke(t)||Sr(t)||Ri(t)||Ei(t)}function ale(t,e){return!(!X1(t)||!X1(e))&&!(jn(t)&&!jn(e))&&!(Jt(t)&&!Jt(e))&&!(_t(t)&&!_t(e))&&!(Ke(t)&&!Ke(e))&&!(Sr(t)&&!Sr(e))&&!(Ri(t)&&!Ri(e))&&!(Ei(t)&&!Ei(e))}function F1(t,e){let r=Ae("%Temporal.PlainDateTime%");if(jn(t)){let n=new r(1970,1,1,R(t,St),R(t,At),R(t,Tt),R(t,Pt),R(t,It),R(t,kt),e[Ld]);return{instant:_s(e[C1],n,"compatible"),formatter:O1(e,nle)}}if(Sr(t)){let n=R(t,De),i=R(t,Oe),o=R(t,je),s=po(R(t,fe));if(s!==e[Ld])throw new RangeError(`cannot format PlainYearMonth with calendar ${s} in locale with calendar ${e[Ld]}`);let a=new r(n,i,o,12,0,0,0,0,0,s);return{instant:_s(e[C1],a,"compatible"),formatter:O1(e,tle)}}if(Ri(t)){let n=R(t,De),i=R(t,Oe),o=R(t,je),s=po(R(t,fe));if(s!==e[Ld])throw new RangeError(`cannot format PlainMonthDay with calendar ${s} in locale with calendar ${e[Ld]}`);let a=new r(n,i,o,12,0,0,0,0,0,s);return{instant:_s(e[C1],a,"compatible"),formatter:O1(e,rle)}}if(Jt(t)){let n=R(t,De),i=R(t,Oe),o=R(t,je),s=po(R(t,fe));if(s!=="iso8601"&&s!==e[Ld])throw new RangeError(`cannot format PlainDate with calendar ${s} in locale with calendar ${e[Ld]}`);let a=new r(n,i,o,12,0,0,0,0,0,e[Ld]);return{instant:_s(e[C1],a,"compatible"),formatter:O1(e,ele)}}if(_t(t)){let n=R(t,De),i=R(t,Oe),o=R(t,je),s=R(t,St),a=R(t,At),d=R(t,Tt),u=R(t,Pt),c=R(t,It),l=R(t,kt),p=po(R(t,fe));if(p!=="iso8601"&&p!==e[Ld])throw new RangeError(`cannot format PlainDateTime with calendar ${p} in locale with calendar ${e[Ld]}`);let m=t;return p==="iso8601"&&(m=new r(n,i,o,s,a,d,u,c,l,e[Ld])),{instant:_s(e[C1],m,"compatible"),formatter:O1(e,ile)}}if(Ke(t))throw new TypeError("Temporal.ZonedDateTime not supported in DateTimeFormat methods. Use toLocaleString() instead.");return Ei(t)?{instant:t,formatter:O1(e,ole)}:{}}var hEt=Object.freeze({__proto__:null,DateTimeFormat:Vh}),E6=class t{constructor(e){if(arguments.length<1)throw new TypeError("missing argument: epochNanoseconds is required");let r=g6(e);Xg(r),hf(this),Mt(this,ut,r)}get epochSeconds(){if(!Ei(this))throw new TypeError("invalid receiver");let e=R(this,ut);return z.default.toNumber(q1(e,af))}get epochMilliseconds(){if(!Ei(this))throw new TypeError("invalid receiver");let e=z.default.BigInt(R(this,ut));return z.default.toNumber(q1(e,Jc))}get epochMicroseconds(){if(!Ei(this))throw new TypeError("invalid receiver");return yP(q1(z.default.BigInt(R(this,ut)),Ar))}get epochNanoseconds(){if(!Ei(this))throw new TypeError("invalid receiver");return yP(z.default.BigInt(R(this,ut)))}add(e){if(!Ei(this))throw new TypeError("invalid receiver");return tue("add",this,e)}subtract(e){if(!Ei(this))throw new TypeError("invalid receiver");return tue("subtract",this,e)}until(e,r){if(!Ei(this))throw new TypeError("invalid receiver");return Gde("until",this,e,r)}since(e,r){if(!Ei(this))throw new TypeError("invalid receiver");return Gde("since",this,e,r)}round(e){if(!Ei(this))throw new TypeError("invalid receiver");if(e===void 0)throw new TypeError("options parameter is required");let r=typeof e=="string"?Y1("smallestUnit",e):tr(e),n=t2(r),i=Hu(r,"halfExpand"),o=Ma(r,"smallestUnit","time",iv);r2(n,{hour:24,minute:1440,second:86400,millisecond:864e5,microsecond:864e8,nanosecond:864e11}[o],!0);let s=mP(R(this,ut),n,o,i);return new t(s)}equals(e){if(!Ei(this))throw new TypeError("invalid receiver");let r=Wu(e),n=R(this,ut),i=R(r,ut);return z.default.equal(z.default.BigInt(n),z.default.BigInt(i))}toString(e){if(!Ei(this))throw new TypeError("invalid receiver");let r=tr(e),n=$6(r),i=Hu(r,"trunc"),o=Ma(r,"smallestUnit","time",void 0);if(o==="hour")throw new RangeError('smallestUnit must be a time unit other than "hour"');let s=r.timeZone;s!==void 0&&(s=Lo(s));let{precision:a,unit:d,increment:u}=j6(o,n),c=mP(R(this,ut),u,d,i);return Ude(new t(c),s,a)}toJSON(){if(!Ei(this))throw new TypeError("invalid receiver");return Ude(this,void 0,"auto")}toLocaleString(e,r){if(!Ei(this))throw new TypeError("invalid receiver");return new Vh(e,r).format(this)}valueOf(){throw new TypeError("use compare() or equals() to compare Temporal.Instant")}toZonedDateTime(e){if(!Ei(this))throw new TypeError("invalid receiver");if(!cn(e))throw new TypeError("invalid argument in toZonedDateTime");let r=e.calendar;if(r===void 0)throw new TypeError("missing calendar property in toZonedDateTime");let n=Oa(r),i=e.timeZone;if(i===void 0)throw new TypeError("missing timeZone property in toZonedDateTime");let o=Lo(i);return lo(R(this,ut),o,n)}toZonedDateTimeISO(e){if(!Ei(this))throw new TypeError("invalid receiver");let r=Lo(e);return lo(R(this,ut),r,"iso8601")}static fromEpochSeconds(e){let r=H1(e),n=z.default.multiply(z.default.BigInt(r),af);return Xg(n),new t(n)}static fromEpochMilliseconds(e){let r=H1(e),n=z.default.multiply(z.default.BigInt(r),Jc);return Xg(n),new t(n)}static fromEpochMicroseconds(e){let r=g6(e),n=z.default.multiply(r,Ar);return Xg(n),new t(n)}static fromEpochNanoseconds(e){let r=g6(e);return Xg(r),new t(r)}static from(e){return Ei(e)?new t(R(e,ut)):Wu(e)}static compare(e,r){let n=Wu(e),i=Wu(r),o=R(n,ut),s=R(i,ut);return z.default.lessThan(o,s)?-1:z.default.greaterThan(o,s)?1:0}};ff(E6,"Temporal.Instant");var cle=Array.prototype.includes,kqe=Array.prototype.push,Rqe=globalThis.Intl.DateTimeFormat,Dqe=Array.prototype.sort,Bqe=Math.abs,Mqe=Math.floor,qj=Object.create,eN=Object.entries,dle=Set,sue=Reflect.ownKeys,No=Set.prototype.add,ule=Set.prototype.values,bn={},vn=class{constructor(e){if(arguments.length<1)throw new RangeError("missing argument: id is required");let r=xs(e);if(!Wh(r))throw new RangeError(`invalid calendar identifier ${r}`);hf(this),Mt(this,In,lf(r))}get id(){if(!Cn(this))throw new TypeError("invalid receiver");return R(this,In)}dateFromFields(e,r){if(!Cn(this))throw new TypeError("invalid receiver");if(!cn(e))throw new TypeError("invalid fields");let n=tr(r),i=R(this,In);return bn[i].dateFromFields(e,n,i)}yearMonthFromFields(e,r){if(!Cn(this))throw new TypeError("invalid receiver");if(!cn(e))throw new TypeError("invalid fields");let n=tr(r),i=R(this,In);return bn[i].yearMonthFromFields(e,n,i)}monthDayFromFields(e,r){if(!Cn(this))throw new TypeError("invalid receiver");if(!cn(e))throw new TypeError("invalid fields");let n=tr(r),i=R(this,In);return bn[i].monthDayFromFields(e,n,i)}fields(e){if(!Cn(this))throw new TypeError("invalid receiver");let r=[],n=new Set(["year","month","monthCode","day","hour","minute","second","millisecond","microsecond","nanosecond"]);for(let i of e){if(typeof i!="string")throw new TypeError("invalid fields");if(!n.has(i))throw new RangeError(`invalid field name ${i}`);n.delete(i),kqe.call(r,i)}return bn[R(this,In)].fields(r)}mergeFields(e,r){if(!Cn(this))throw new TypeError("invalid receiver");let n=jde(e),i=qj(null);N1(i,n,[],[void 0]);let o=jde(r),s=qj(null);N1(s,o,[],[void 0]);let a=sue(s),d=bn[R(this,In)].fieldKeysToIgnore(a),u=qj(null),c=sue(i);for(let l of c){let p;p=Ge(cle,d,[l])?s[l]:i[l],p!==void 0&&(u[l]=p)}return N1(u,s,[]),u}dateAdd(e,r,n){if(!Cn(this))throw new TypeError("invalid receiver");let i=Lr(e),o=U1(r),s=Xn(tr(n)),{days:a}=Kd(R(o,hs),R(o,ps),R(o,ms),R(o,ys),R(o,gs),R(o,vs),R(o,bs),"day"),d=R(this,In);return bn[d].dateAdd(i,R(o,fs),R(o,Gi),R(o,oa),a,s,d)}dateUntil(e,r,n){if(!Cn(this))throw new TypeError("invalid receiver");let i=Lr(e),o=Lr(r),s=Ma(tr(n),"largestUnit","date","auto");s==="auto"&&(s="day");let{years:a,months:d,weeks:u,days:c}=bn[R(this,In)].dateUntil(i,o,s);return new(Ae("%Temporal.Duration%"))(a,d,u,c,0,0,0,0,0,0)}year(e){let r=e;if(!Cn(this))throw new TypeError("invalid receiver");return Sr(r)||(r=Lr(r)),bn[R(this,In)].year(r)}month(e){let r=e;if(!Cn(this))throw new TypeError("invalid receiver");if(Ri(r))throw new TypeError("use monthCode on PlainMonthDay instead");return Sr(r)||(r=Lr(r)),bn[R(this,In)].month(r)}monthCode(e){let r=e;if(!Cn(this))throw new TypeError("invalid receiver");return Sr(r)||Ri(r)||(r=Lr(r)),bn[R(this,In)].monthCode(r)}day(e){let r=e;if(!Cn(this))throw new TypeError("invalid receiver");return Ri(r)||(r=Lr(r)),bn[R(this,In)].day(r)}era(e){let r=e;if(!Cn(this))throw new TypeError("invalid receiver");return Sr(r)||(r=Lr(r)),bn[R(this,In)].era(r)}eraYear(e){let r=e;if(!Cn(this))throw new TypeError("invalid receiver");return Sr(r)||(r=Lr(r)),bn[R(this,In)].eraYear(r)}dayOfWeek(e){if(!Cn(this))throw new TypeError("invalid receiver");let r=Lr(e);return bn[R(this,In)].dayOfWeek(r)}dayOfYear(e){if(!Cn(this))throw new TypeError("invalid receiver");let r=Lr(e);return bn[R(this,In)].dayOfYear(r)}weekOfYear(e){if(!Cn(this))throw new TypeError("invalid receiver");let r=Lr(e);return bn[R(this,In)].weekOfYear(r)}yearOfWeek(e){if(!Cn(this))throw new TypeError("invalid receiver");let r=Lr(e);return bn[R(this,In)].yearOfWeek(r)}daysInWeek(e){if(!Cn(this))throw new TypeError("invalid receiver");let r=Lr(e);return bn[R(this,In)].daysInWeek(r)}daysInMonth(e){let r=e;if(!Cn(this))throw new TypeError("invalid receiver");return Sr(r)||(r=Lr(r)),bn[R(this,In)].daysInMonth(r)}daysInYear(e){let r=e;if(!Cn(this))throw new TypeError("invalid receiver");return Sr(r)||(r=Lr(r)),bn[R(this,In)].daysInYear(r)}monthsInYear(e){let r=e;if(!Cn(this))throw new TypeError("invalid receiver");return Sr(r)||(r=Lr(r)),bn[R(this,In)].monthsInYear(r)}inLeapYear(e){let r=e;if(!Cn(this))throw new TypeError("invalid receiver");return Sr(r)||(r=Lr(r)),bn[R(this,In)].inLeapYear(r)}toString(){if(!Cn(this))throw new TypeError("invalid receiver");return R(this,In)}toJSON(){if(!Cn(this))throw new TypeError("invalid receiver");return R(this,In)}static from(e){return n2(Oa(e))}};function KN(t){if(!t.startsWith("M"))throw new RangeError(`Invalid month code: ${t}. Month codes must start with M.`);let e=+t.slice(1);if(isNaN(e))throw new RangeError(`Invalid month code: ${t}`);return e}function Kh(t,e=!1){return`M${t.toString().padStart(2,"0")}${e?"L":""}`}function rP(t,e,r=12){let{month:n,monthCode:i}=t;if(i===void 0){if(n===void 0)throw new TypeError("Either month or monthCode are required");e==="reject"&&ho(n,1,r),e==="constrain"&&(n=Da(n,1,r)),i=Kh(n)}else{let o=KN(i);if(n!==void 0&&n!==o)throw new RangeError(`monthCode ${i} and month ${n} must match if both are present`);if(i!==Kh(o))throw new RangeError(`Invalid month code: ${i}`);if(n=o,n<1||n>r)throw new RangeError(`Invalid monthCode: ${i}`)}return{...t,month:n,monthCode:i}}ff(vn,"Temporal.Calendar"),kn("Temporal.Calendar.from",vn.from),kn("Temporal.Calendar.prototype.dateAdd",vn.prototype.dateAdd),kn("Temporal.Calendar.prototype.dateFromFields",vn.prototype.dateFromFields),kn("Temporal.Calendar.prototype.dateUntil",vn.prototype.dateUntil),kn("Temporal.Calendar.prototype.day",vn.prototype.day),kn("Temporal.Calendar.prototype.dayOfWeek",vn.prototype.dayOfWeek),kn("Temporal.Calendar.prototype.dayOfYear",vn.prototype.dayOfYear),kn("Temporal.Calendar.prototype.daysInMonth",vn.prototype.daysInMonth),kn("Temporal.Calendar.prototype.daysInWeek",vn.prototype.daysInWeek),kn("Temporal.Calendar.prototype.daysInYear",vn.prototype.daysInYear),kn("Temporal.Calendar.prototype.era",vn.prototype.era),kn("Temporal.Calendar.prototype.eraYear",vn.prototype.eraYear),kn("Temporal.Calendar.prototype.fields",vn.prototype.fields),kn("Temporal.Calendar.prototype.inLeapYear",vn.prototype.inLeapYear),kn("Temporal.Calendar.prototype.mergeFields",vn.prototype.mergeFields),kn("Temporal.Calendar.prototype.month",vn.prototype.month),kn("Temporal.Calendar.prototype.monthCode",vn.prototype.monthCode),kn("Temporal.Calendar.prototype.monthDayFromFields",vn.prototype.monthDayFromFields),kn("Temporal.Calendar.prototype.monthsInYear",vn.prototype.monthsInYear),kn("Temporal.Calendar.prototype.weekOfYear",vn.prototype.weekOfYear),kn("Temporal.Calendar.prototype.year",vn.prototype.year),kn("Temporal.Calendar.prototype.yearMonthFromFields",vn.prototype.yearMonthFromFields),kn("Temporal.Calendar.prototype.yearOfWeek",vn.prototype.yearOfWeek),bn.iso8601={dateFromFields(t,e,r){let n=Ct(t,["day","month","monthCode","year"],["year","day"]),i=Xn(e);n=rP(n);let{year:o,month:s,day:a}=n;return{year:o,month:s,day:a}=cP(o,s,a,i),Yc(o,s,a,r)},yearMonthFromFields(t,e,r){let n=Ct(t,["month","monthCode","year"],["year"]),i=Xn(e);n=rP(n);let{year:o,month:s}=n;return{year:o,month:s}=function(d,u,c){let l=d,p=u;switch(c){case"reject":uf(l,p,1);break;case"constrain":({year:l,month:p}=Kue(l,p))}return{year:l,month:p}}(o,s,i),_6(o,s,r,1)},monthDayFromFields(t,e,r){let n=Ct(t,["day","month","monthCode","year"],["day"]),i=Xn(e);if(n.month!==void 0&&n.year===void 0&&n.monthCode===void 0)throw new TypeError("either year or monthCode required with month");let o=n.monthCode===void 0;n=rP(n);let{month:s,day:a,year:d}=n;return{month:s,day:a}=cP(o?d:1972,s,a,i),w6(s,a,r,1972)},fields:t=>t,fieldKeysToIgnore(t){let e=new dle;for(let r=0;rON(R(t,De),R(t,Oe),R(t,je),R(e,De),R(e,Oe),R(e,je),r),year:t=>R(t,De),era(){},eraYear(){},month:t=>R(t,Oe),monthCode:t=>Kh(R(t,Oe)),day:t=>R(t,je),dayOfWeek:t=>Zj(R(t,De),R(t,Oe),R(t,je)),dayOfYear:t=>hP(R(t,De),R(t,Oe),R(t,je)),weekOfYear:t=>Hde(R(t,De),R(t,Oe),R(t,je)).week,yearOfWeek:t=>Hde(R(t,De),R(t,Oe),R(t,je)).year,daysInWeek:()=>7,daysInMonth:t=>Lh(R(t,De),R(t,Oe)),daysInYear(t){let e=t;return Bi(e,De)||(e=Lr(e)),Qm(R(e,De))?366:365},monthsInYear:()=>12,inLeapYear(t){let e=t;return Bi(e,De)||(e=Lr(e)),Qm(R(e,De))}};var xi=class t{constructor(e){if(this.map=new Map,this.calls=0,this.hits=0,this.misses=0,this.now=globalThis.performance?globalThis.performance.now():Date.now(),e!==void 0){let r=0;for(let n of e.map.entries()){if(++r>t.MAX_CACHE_ENTRIES)break;this.map.set(...n)}}}get(e){let r=this.map.get(e);return r&&(this.hits++,this.report()),this.calls++,r}set(e,r){this.map.set(e,r),this.misses++,this.report()}report(){}setObject(e){if(t.objectMap.get(e))throw new RangeError("object already cached");t.objectMap.set(e,this),this.report()}static getCacheForObject(e){let r=t.objectMap.get(e);return r||(r=new t,t.objectMap.set(e,r)),r}};function lle({isoYear:t,isoMonth:e,isoDay:r}){return`${lv(t)}-${wn(e)}-${wn(r)}T00:00Z`}function Lj(t,e){return{years:t.year-e.year,months:t.month-e.month,days:t.day-e.day}}xi.objectMap=new WeakMap,xi.MAX_CACHE_ENTRIES=1e3;var ty=class{constructor(){this.eraLength="short",this.hasEra=!0,this.erasBeginMidYear=!1}getFormatter(){return this.formatter===void 0&&(this.formatter=new Rqe(`en-US-u-ca-${this.id}`,{day:"numeric",month:"numeric",year:"numeric",era:this.eraLength,timeZone:"UTC"})),this.formatter}isoToCalendarDate(e,r){let{year:n,month:i,day:o}=e,s=JSON.stringify({func:"isoToCalendarDate",isoYear:n,isoMonth:i,isoDay:o,id:this.id}),a=r.get(s);if(a)return a;let d=this.getFormatter(),u,c;try{c=lle({isoYear:n,isoMonth:i,isoDay:o}),u=d.formatToParts(new Date(c))}catch{throw new RangeError(`Invalid ISO date: ${JSON.stringify({isoYear:n,isoMonth:i,isoDay:o})}`)}let l={};for(let{type:m,value:g}of u){if(m==="year"&&(l.eraYear=+g),m==="relatedYear"&&(l.eraYear=+g),m==="month"){let v=/^([0-9]*)(.*?)$/.exec(g);if(!v||v.length!=3||!v[1]&&!v[2])throw new RangeError(`Unexpected month: ${g}`);if(l.month=v[1]?+v[1]:1,l.month<1)throw new RangeError(`Invalid month ${g} from ${c}[u-ca-${this.id}] (probably due to https://bugs.chromium.org/p/v8/issues/detail?id=10527)`);if(l.month>13)throw new RangeError(`Invalid month ${g} from ${c}[u-ca-${this.id}] (probably due to https://bugs.chromium.org/p/v8/issues/detail?id=10529)`);v[2]&&(l.monthExtra=v[2])}m==="day"&&(l.day=+g),this.hasEra&&m==="era"&&g!=null&&g!==""&&(g=g.split(" (")[0],l.era=g.normalize("NFD").replace(/[^-0-9 \p{L}]/gu,"").replace(" ","-").toLowerCase())}if(l.eraYear===void 0)throw new RangeError(`Intl.DateTimeFormat.formatToParts lacks relatedYear in ${this.id} calendar. Try Node 14+ or modern browsers.`);if(this.reviseIntlEra){let{era:m,eraYear:g}=this.reviseIntlEra(l,e);l.era=m,l.eraYear=g}this.checkIcuBugs&&this.checkIcuBugs(e);let p=this.adjustCalendarDate(l,r,"constrain",!0);if(p.year===void 0)throw new RangeError(`Missing year converting ${JSON.stringify(e)}`);if(p.month===void 0)throw new RangeError(`Missing month converting ${JSON.stringify(e)}`);if(p.day===void 0)throw new RangeError(`Missing day converting ${JSON.stringify(e)}`);return r.set(s,p),["constrain","reject"].forEach(m=>{let g=JSON.stringify({func:"calendarToIsoDate",year:p.year,month:p.month,day:p.day,overflow:m,id:this.id});r.set(g,e)}),p}validateCalendarDate(e){let{era:r,month:n,year:i,day:o,eraYear:s,monthCode:a,monthExtra:d}=e;if(d!==void 0)throw new RangeError("Unexpected `monthExtra` value");if(i===void 0&&s===void 0)throw new TypeError("year or eraYear is required");if(n===void 0&&a===void 0)throw new TypeError("month or monthCode is required");if(o===void 0)throw new RangeError("Missing day");if(a!==void 0){if(typeof a!="string")throw new RangeError("monthCode must be a string, not "+typeof a);if(!/^M([01]?\d)(L?)$/.test(a))throw new RangeError(`Invalid monthCode: ${a}`)}if(this.constantEra){if(r!==void 0&&r!==this.constantEra)throw new RangeError(`era must be ${this.constantEra}, not ${r}`);if(s!==void 0&&i!==void 0&&s!==i)throw new RangeError(`eraYear ${s} does not match year ${i}`)}if(this.hasEra&&e.era===void 0!=(e.eraYear===void 0))throw new RangeError("properties 'era' and 'eraYear' must be provided together")}adjustCalendarDate(e,r,n="constrain",i=!1){if(this.calendarType==="lunisolar")throw new RangeError("Override required for lunisolar calendars");let o=e;if(this.validateCalendarDate(o),this.constantEra){let{year:u,eraYear:c}=o;o={...o,era:this.constantEra,year:u!==void 0?u:c,eraYear:c!==void 0?c:u}}let s=this.monthsInYear(o,r),{month:a,monthCode:d}=o;return{month:a,monthCode:d}=rP(o,n,s),{...o,month:a,monthCode:d}}regulateMonthDayNaive(e,r,n){let i=this.monthsInYear(e,n),{month:o,day:s}=e;return r==="reject"?(ho(o,1,i),ho(s,1,this.maximumMonthLength(e))):(o=Da(o,1,i),s=Da(s,1,this.maximumMonthLength({...e,month:o}))),{...e,month:o,day:s}}calendarToIsoDate(e,r="constrain",n){let i=e,o=this.adjustCalendarDate(e,n,r,!1);o=this.regulateMonthDayNaive(o,r,n);let{year:s,month:a,day:d}=o,u=JSON.stringify({func:"calendarToIsoDate",year:s,month:a,day:d,overflow:r,id:this.id}),c,l=n.get(u);if(l||i.year!==void 0&&i.month!==void 0&&i.day!==void 0&&(i.year!==o.year||i.month!==o.month||i.day!==o.day)&&(c=JSON.stringify({func:"calendarToIsoDate",year:i.year,month:i.month,day:i.day,overflow:r,id:this.id}),l=n.get(c),l))return l;let p=this.estimateIsoDate({year:s,month:a,day:d}),m=P=>{let A=this.addDaysIso(p,P);if(o.day>this.minimumMonthLength(o)){let $=this.isoToCalendarDate(A,n);for(;$.month!==a||$.year!==s;){if(r==="reject")throw new RangeError(`day ${d} does not exist in month ${a} of year ${s}`);A=this.addDaysIso(A,-1),$=this.isoToCalendarDate(A,n)}}return A},g=0,v=this.isoToCalendarDate(p,n),x=Lj(o,v);if(x.years!==0||x.months!==0||x.days!==0){let P=365*x.years+30*x.months+x.days;p=this.addDaysIso(p,P),v=this.isoToCalendarDate(p,n),x=Lj(o,v),x.years===0&&x.months===0?p=m(x.days):g=this.compareCalendarDates(o,v)}let S=8;for(;g;){p=this.addDaysIso(p,g*S);let P=v;v=this.isoToCalendarDate(p,n);let A=g;if(g=this.compareCalendarDates(o,v),g){if(x=Lj(o,v),x.years===0&&x.months===0)p=m(x.days),g=0;else if(A&&g!==A)if(S>1)S/=2;else{if(r==="reject")throw new RangeError(`Can't find ISO date from calendar date: ${JSON.stringify({...i})}`);this.compareCalendarDates(v,P)>0&&(p=this.addDaysIso(p,-1)),g=0}}}if(n.set(u,p),c&&n.set(c,p),o.year===void 0||o.month===void 0||o.day===void 0||o.monthCode===void 0||this.hasEra&&(o.era===void 0||o.eraYear===void 0))throw new RangeError("Unexpected missing property");return p}temporalToCalendarDate(e,r){let n={year:R(e,De),month:R(e,Oe),day:R(e,je)};return this.isoToCalendarDate(n,r)}compareCalendarDates(e,r){let n=Ct(e,["day","month","year"],["day","month","year"]),i=Ct(r,["day","month","year"],["day","month","year"]);return n.year!==i.year?rv(n.year-i.year):n.month!==i.month?rv(n.month-i.month):n.day!==i.day?rv(n.day-i.day):0}regulateDate(e,r="constrain",n){let i=this.calendarToIsoDate(e,r,n);return this.isoToCalendarDate(i,n)}addDaysIso(e,r){return tv(e.year,e.month,e.day,0,0,0,r,"constrain")}addDaysCalendar(e,r,n){let i=this.calendarToIsoDate(e,"constrain",n),o=this.addDaysIso(i,r);return this.isoToCalendarDate(o,n)}addMonthsCalendar(e,r,n,i){let o=e,{day:s}=o;for(let a=0,d=Bqe(r);a0){let g=this.monthsInYear(c,i);for(;o.month-1!=u%g;)m=this.addDaysIso(m,-1),o=this.isoToCalendarDate(m,i)}o.day!==s&&(o=this.regulateDate({...o,day:s},"constrain",i))}if(n==="reject"&&o.day!==s)throw new RangeError(`Day ${s} does not exist in resulting calendar month`);return o}addCalendar(e,{years:r=0,months:n=0,weeks:i=0,days:o=0},s,a){let{year:d,day:u,monthCode:c}=e,l=this.adjustCalendarDate({year:d+r,monthCode:c,day:u},a),p=this.addMonthsCalendar(l,n,s,a),m=o+7*i;return this.addDaysCalendar(p,m,a)}untilCalendar(e,r,n,i){let o=0,s=0,a=0,d=0;switch(n){case"day":o=this.calendarDaysUntil(e,r,i);break;case"week":{let u=this.calendarDaysUntil(e,r,i);o=u%7,s=(u-o)/7;break}case"month":case"year":{let u=this.compareCalendarDates(r,e);if(!u)return{years:0,months:0,weeks:0,days:0};let c=r.year-e.year,l=r.day-e.day;if(n==="year"&&c){let g=0;r.monthCode>e.monthCode&&(g=1),r.monthCode=0);a-=u,o=this.calendarDaysUntil(p,r,i);break}}return{years:d,months:a,weeks:s,days:o}}daysInMonth(e,r){let{day:n}=e,i=this.maximumMonthLength(e),o=this.minimumMonthLength(e);if(o===i)return o;let s=n<=i-o?i:o,a=this.calendarToIsoDate(e,"constrain",r),d=this.addDaysIso(a,s),u=this.isoToCalendarDate(d,r),c=this.addDaysIso(d,-u.day);return this.isoToCalendarDate(c,r).day}daysInPreviousMonth(e,r){let{day:n,month:i,year:o}=e,s={year:i>1?o:o-1,month:i,day:1},a=i>1?i-1:this.monthsInYear(s,r);s={...s,month:a};let d=this.minimumMonthLength(s),u=this.maximumMonthLength(s);if(d===u)return u;let c=this.calendarToIsoDate(e,"constrain",r),l=this.addDaysIso(c,-n);return this.isoToCalendarDate(l,r).day}startOfCalendarYear(e){return{year:e.year,month:1,monthCode:"M01",day:1}}startOfCalendarMonth(e){return{year:e.year,month:e.month,day:1}}calendarDaysUntil(e,r,n){let i=this.calendarToIsoDate(e,"constrain",n),o=this.calendarToIsoDate(r,"constrain",n);return this.isoDaysUntil(i,o)}isoDaysUntil(e,r){return ON(e.year,e.month,e.day,r.year,r.month,r.day,"day").days}monthDayFromFields(e,r,n){let i,o,s,a,d,{monthCode:u,day:c}=e;if(u===void 0){let{year:m,era:g,eraYear:v}=e;if(m===void 0&&(g===void 0||v===void 0))throw new TypeError("when `monthCode` is omitted, `year` (or `era` and `eraYear`) and `month` are required");({monthCode:u,day:c}=this.isoToCalendarDate(this.calendarToIsoDate(e,r,n),n))}let l=this.isoToCalendarDate({year:1972,month:12,day:31},n),p=l.monthCode>u||l.monthCode===u&&l.day>=c?l.year:l.year-1;for(let m=0;m<100;m++){let g=this.adjustCalendarDate({day:c,monthCode:u,year:p-m},n),v=this.calendarToIsoDate(g,"constrain",n),x=this.isoToCalendarDate(v,n);if({year:i,month:o,day:s}=v,x.monthCode===u&&x.day===c)return{month:o,day:s,year:i};r==="constrain"&&(a===void 0||x.monthCode===a.monthCode&&x.day>a.day)&&(a=x,d=v)}if(r==="constrain"&&d!==void 0)return d;throw new RangeError(`No recent ${this.id} year with monthCode ${u} and day ${c}`)}},tN=class extends ty{constructor(){super(...arguments),this.id="hebrew",this.calendarType="lunisolar",this.months={Tishri:{leap:1,regular:1,monthCode:"M01",days:30},Heshvan:{leap:2,regular:2,monthCode:"M02",days:{min:29,max:30}},Kislev:{leap:3,regular:3,monthCode:"M03",days:{min:29,max:30}},Tevet:{leap:4,regular:4,monthCode:"M04",days:29},Shevat:{leap:5,regular:5,monthCode:"M05",days:30},Adar:{leap:void 0,regular:6,monthCode:"M06",days:29},"Adar I":{leap:6,regular:void 0,monthCode:"M05L",days:30},"Adar II":{leap:7,regular:void 0,monthCode:"M06",days:29},Nisan:{leap:8,regular:7,monthCode:"M07",days:30},Iyar:{leap:9,regular:8,monthCode:"M08",days:29},Sivan:{leap:10,regular:9,monthCode:"M09",days:30},Tamuz:{leap:11,regular:10,monthCode:"M10",days:29},Av:{leap:12,regular:11,monthCode:"M11",days:30},Elul:{leap:13,regular:12,monthCode:"M12",days:29}},this.hasEra=!1}inLeapYear(e){let{year:r}=e;return(7*r+1)%19<7}monthsInYear(e){return this.inLeapYear(e)?13:12}minimumMonthLength(e){return this.minMaxMonthLength(e,"min")}maximumMonthLength(e){return this.minMaxMonthLength(e,"max")}minMaxMonthLength(e,r){let{month:n,year:i}=e,o=this.getMonthCode(i,n),s=eN(this.months).find(d=>d[1].monthCode===o);if(s===void 0)throw new RangeError(`unmatched Hebrew month: ${n}`);let a=s[1].days;return typeof a=="number"?a:a[r]}estimateIsoDate(e){let{year:r}=e;return{year:r-3760,month:1,day:1}}getMonthCode(e,r){return this.inLeapYear({year:e})?r===6?Kh(5,!0):Kh(r<6?r:r-1):Kh(r)}adjustCalendarDate(e,r,n="constrain",i=!1){let{year:o,eraYear:s,month:a,monthCode:d,day:u,monthExtra:c}=e;if(o===void 0&&s!==void 0&&(o=s),s===void 0&&o!==void 0&&(s=o),i){if(c){let l=this.months[c];if(!l)throw new RangeError(`Unrecognized month from formatToParts: ${c}`);a=this.inLeapYear({year:o})?l.leap:l.regular}return d=this.getMonthCode(o,a),{year:o,month:a,day:u,era:void 0,eraYear:s,monthCode:d}}if(this.validateCalendarDate(e),a===void 0)if(d.endsWith("L")){if(d!=="M05L")throw new RangeError(`Hebrew leap month must have monthCode M05L, not ${d}`);if(a=6,!this.inLeapYear({year:o})){if(n==="reject")throw new RangeError(`Hebrew monthCode M05L is invalid in year ${o} which is not a leap year`);a=6,d="M06"}}else{a=KN(d),this.inLeapYear({year:o})&&a>=6&&a++;let l=this.monthsInYear({year:o});if(a<1||a>l)throw new RangeError(`Invalid monthCode: ${d}`)}else if(n==="reject"?(ho(a,1,this.monthsInYear({year:o})),ho(u,1,this.maximumMonthLength({year:o,month:a}))):(a=Da(a,1,this.monthsInYear({year:o})),u=Da(u,1,this.maximumMonthLength({year:o,month:a}))),d===void 0)d=this.getMonthCode(o,a);else if(this.getMonthCode(o,a)!==d)throw new RangeError(`monthCode ${d} doesn't correspond to month ${a} in Hebrew year ${o}`);return{...e,day:u,month:a,monthCode:d,year:o,eraYear:s}}},ry=class extends ty{constructor(){super(...arguments),this.calendarType="lunar",this.DAYS_PER_ISLAMIC_YEAR=354+11/30,this.DAYS_PER_ISO_YEAR=365.2425,this.constantEra="ah"}inLeapYear(e,r){return this.daysInMonth({year:e.year,month:12,day:1},r)===30}monthsInYear(){return 12}minimumMonthLength(){return 29}maximumMonthLength(){return 30}estimateIsoDate(e){let{year:r}=this.adjustCalendarDate(e);return{year:Mqe(r*this.DAYS_PER_ISLAMIC_YEAR/this.DAYS_PER_ISO_YEAR)+622,month:1,day:1}}},gP=class extends ry{constructor(){super(...arguments),this.id="islamic"}},rN=class extends ry{constructor(){super(...arguments),this.id="islamic-umalqura"}},nN=class extends ry{constructor(){super(...arguments),this.id="islamic-tbla"}},iN=class extends ry{constructor(){super(...arguments),this.id="islamic-civil"}},oN=class extends ry{constructor(){super(...arguments),this.id="islamic-rgsa"}},sN=class extends ry{constructor(){super(...arguments),this.id="islamicc"}},aN=class extends ty{constructor(){super(...arguments),this.id="persian",this.calendarType="solar",this.constantEra="ap"}inLeapYear(e,r){return gP.prototype.inLeapYear.call(this,e,r)}monthsInYear(){return 12}minimumMonthLength(e){let{month:r}=e;return r===12?29:r<=6?31:30}maximumMonthLength(e){let{month:r}=e;return r===12?30:r<=6?31:30}estimateIsoDate(e){let{year:r}=this.adjustCalendarDate(e);return{year:r+621,month:1,day:1}}},cN=class extends ty{constructor(){super(...arguments),this.id="indian",this.calendarType="solar",this.constantEra="saka",this.months={1:{length:30,month:3,day:22,leap:{length:31,month:3,day:21}},2:{length:31,month:4,day:21},3:{length:31,month:5,day:22},4:{length:31,month:6,day:22},5:{length:31,month:7,day:23},6:{length:31,month:8,day:23},7:{length:30,month:9,day:23},8:{length:30,month:10,day:23},9:{length:30,month:11,day:22},10:{length:30,month:12,day:22},11:{length:30,month:1,nextYear:!0,day:21},12:{length:30,month:2,nextYear:!0,day:20}},this.vulnerableToBceBug=new Date("0000-01-01T00:00Z").toLocaleDateString("en-US-u-ca-indian",{timeZone:"UTC"})!=="10/11/-79 Saka"}inLeapYear(e){return fle(e.year+78)}monthsInYear(){return 12}minimumMonthLength(e){return this.getMonthInfo(e).length}maximumMonthLength(e){return this.getMonthInfo(e).length}getMonthInfo(e){let{month:r}=e,n=this.months[r];if(n===void 0)throw new RangeError(`Invalid month: ${r}`);return this.inLeapYear(e)&&n.leap&&(n=n.leap),n}estimateIsoDate(e){let r=this.adjustCalendarDate(e),n=this.getMonthInfo(r);return tv(r.year+78+(n.nextYear?1:0),n.month,n.day,0,0,0,r.day-1,"constrain")}checkIcuBugs(e){if(this.vulnerableToBceBug&&e.year<1)throw new RangeError(`calendar '${this.id}' is broken for ISO dates before 0001-01-01 (see https://bugs.chromium.org/p/v8/issues/detail?id=10529)`)}};function fle(t){return t%4==0&&(t%100!=0||t%400==0)}var dv=class extends ty{constructor(e,r){super(),this.calendarType="solar",this.v8IsVulnerableToJulianBug=new Date("+001001-01-01T00:00Z").toLocaleDateString("en-US-u-ca-japanese",{timeZone:"UTC"}).startsWith("12"),this.calendarIsVulnerableToJulianBug=!1,this.id=e;let{eras:n,anchorEra:i}=function(s){let a,d=s;if(d.length===0)throw new RangeError("Invalid era data: eras are required");if(d.length===1&&d[0].reverseOf)throw new RangeError("Invalid era data: anchor era cannot count years backwards");if(d.length===1&&!d[0].name)throw new RangeError("Invalid era data: at least one named era is required");if(d.filter(c=>c.reverseOf!=null).length>1)throw new RangeError("Invalid era data: only one era can count years backwards");d.forEach(c=>{if(c.isAnchor||!c.anchorEpoch&&!c.reverseOf){if(a)throw new RangeError("Invalid era data: cannot have multiple anchor eras");a=c,c.anchorEpoch={year:c.hasYearZero?0:1}}else if(!c.name)throw new RangeError("If era name is blank, it must be the anchor era")}),d=d.filter(c=>c.name),d.forEach(c=>{let{reverseOf:l}=c;if(l){let p=d.find(m=>m.name===l);if(p===void 0)throw new RangeError(`Invalid era data: unmatched reverseOf era: ${l}`);c.reverseOf=p,c.anchorEpoch=p.anchorEpoch,c.isoEpoch=p.isoEpoch}c.anchorEpoch.month===void 0&&(c.anchorEpoch.month=1),c.anchorEpoch.day===void 0&&(c.anchorEpoch.day=1)}),Dqe.call(d,(c,l)=>{if(c.reverseOf)return 1;if(l.reverseOf)return-1;if(!c.isoEpoch||!l.isoEpoch)throw new RangeError("Invalid era data: missing ISO epoch");return l.isoEpoch.year-c.isoEpoch.year});let u=d[d.length-1].reverseOf;if(u&&u!==d[d.length-2])throw new RangeError("Invalid era data: invalid reverse-sign era");return d.forEach((c,l)=>{c.genericName="era"+(d.length-1-l)}),{eras:d,anchorEra:a||d[0]}}(r);this.anchorEra=i,this.eras=n}inLeapYear(e){let{year:r}=this.estimateIsoDate({month:1,day:1,year:e.year});return fle(r)}monthsInYear(){return 12}minimumMonthLength(e){let{month:r}=e;return r===2?this.inLeapYear(e)?29:28:[4,6,9,11].indexOf(r)>=0?30:31}maximumMonthLength(e){return this.minimumMonthLength(e)}completeEraYear(e){let r=(a,d)=>{let u=e[a];if(u!=null&&u!=d)throw new RangeError(`Input ${a} ${u} doesn't match calculated value ${d}`)},n=a=>{let d,u={...e,year:a},c=this.eras.find((l,p)=>{if(p===this.eras.length-1){if(l.reverseOf){if(a>0)throw new RangeError(`Signed year ${a} is invalid for era ${l.name}`);return d=l.anchorEpoch.year-a,!0}return d=a-l.anchorEpoch.year+(l.hasYearZero?0:1),!0}return this.compareCalendarDates(u,l.anchorEpoch)>=0&&(d=a-l.anchorEpoch.year+(l.hasYearZero?0:1),!0)});if(!c)throw new RangeError(`Year ${a} was not matched by any era`);return{eraYear:d,era:c.name}},{year:i,eraYear:o,era:s}=e;if(i!=null)({eraYear:o,era:s}=n(i)),r("era",s),r("eraYear",o);else{if(o==null)throw new RangeError("Either `year` or `eraYear` and `era` are required");{let a=s===void 0?void 0:this.eras.find(d=>d.name===s||d.genericName===s);if(!a)throw new RangeError(`Era ${s} (ISO year ${o}) was not matched by any era`);if(o<1&&a.reverseOf)throw new RangeError(`Years in ${s} era must be positive, not ${i}`);i=a.reverseOf?a.anchorEpoch.year-o:o+a.anchorEpoch.year-(a.hasYearZero?0:1),r("year",i),{eraYear:o,era:s}=n(i)}}return{...e,year:i,eraYear:o,era:s}}adjustCalendarDate(e,r,n="constrain"){let i=e,{month:o,monthCode:s}=i;return o===void 0&&(i={...i,month:KN(s)}),this.validateCalendarDate(i),i=this.completeEraYear(i),super.adjustCalendarDate(i,r,n)}estimateIsoDate(e){let r=this.adjustCalendarDate(e),{year:n,month:i,day:o}=r,{anchorEra:s}=this;return cP(n+s.isoEpoch.year-(s.hasYearZero?0:1),i,o,"constrain")}checkIcuBugs(e){if(this.calendarIsVulnerableToJulianBug&&this.v8IsVulnerableToJulianBug&&Jm(e.year,e.month,e.day,1582,10,15)<0)throw new RangeError(`calendar '${this.id}' is broken for ISO dates before 1582-10-15 (see https://bugs.chromium.org/p/chromium/issues/detail?id=1173158)`)}},S6=class extends dv{constructor(e,r){super(e,r)}inLeapYear(e){let{year:r}=e;return(r+1)%4==0}monthsInYear(){return 13}minimumMonthLength(e){let{month:r}=e;return r===13?this.inLeapYear(e)?6:5:30}maximumMonthLength(e){return this.minimumMonthLength(e)}},dN=class extends S6{constructor(){super("ethioaa",[{name:"era0",isoEpoch:{year:-5492,month:7,day:17}}])}},uN=class extends S6{constructor(){super("coptic",[{name:"era1",isoEpoch:{year:284,month:8,day:29}},{name:"era0",reverseOf:"era1"}])}},lN=class extends S6{constructor(){super("ethiopic",[{name:"era0",isoEpoch:{year:-5492,month:7,day:17}},{name:"era1",isoEpoch:{year:8,month:8,day:27},anchorEpoch:{year:5501}}])}},fN=class extends dv{constructor(){super("roc",[{name:"minguo",isoEpoch:{year:1912,month:1,day:1}},{name:"before-roc",reverseOf:"minguo"}]),this.calendarIsVulnerableToJulianBug=!0}},hN=class extends dv{constructor(){super("buddhist",[{name:"be",hasYearZero:!0,isoEpoch:{year:-543,month:1,day:1}}]),this.calendarIsVulnerableToJulianBug=!0}},pN=class extends dv{constructor(){super("gregory",[{name:"ce",isoEpoch:{year:1,month:1,day:1}},{name:"bce",reverseOf:"ce"}])}reviseIntlEra(e){let{era:r,eraYear:n}=e;return r!=="bc"&&r!=="b"||(r="bce"),r!=="ad"&&r!=="a"||(r="ce"),{era:r,eraYear:n}}},mN=class extends dv{constructor(){super("japanese",[{name:"reiwa",isoEpoch:{year:2019,month:5,day:1},anchorEpoch:{year:2019,month:5,day:1}},{name:"heisei",isoEpoch:{year:1989,month:1,day:8},anchorEpoch:{year:1989,month:1,day:8}},{name:"showa",isoEpoch:{year:1926,month:12,day:25},anchorEpoch:{year:1926,month:12,day:25}},{name:"taisho",isoEpoch:{year:1912,month:7,day:30},anchorEpoch:{year:1912,month:7,day:30}},{name:"meiji",isoEpoch:{year:1868,month:9,day:8},anchorEpoch:{year:1868,month:9,day:8}},{name:"ce",isoEpoch:{year:1,month:1,day:1}},{name:"bce",reverseOf:"ce"}]),this.calendarIsVulnerableToJulianBug=!0,this.eraLength="long",this.erasBeginMidYear=!0}reviseIntlEra(e,r){let{era:n,eraYear:i}=e,{year:o}=r;return this.eras.find(s=>s.name===n)?{era:n,eraYear:i}:o<1?{era:"bce",eraYear:1-o}:{era:"ce",eraYear:o}}},vP=class extends ty{constructor(){super(...arguments),this.calendarType="lunisolar",this.hasEra=!1}inLeapYear(e,r){let n=this.getMonthList(e.year,r);return eN(n).length===13}monthsInYear(e,r){return this.inLeapYear(e,r)?13:12}minimumMonthLength(){return 29}maximumMonthLength(){return 30}getMonthList(e,r){if(e===void 0)throw new TypeError("Missing year");let n=JSON.stringify({func:"getMonthList",calendarYear:e,id:this.id}),i=r.get(n);if(i)return i;let o=this.getFormatter(),s=(x,S)=>{let P=lle({isoYear:x,isoMonth:2,isoDay:1}),A=new Date(P);A.setUTCDate(S+1);let $=o.formatToParts(A),j=$.find(K=>K.type==="month").value,q=+$.find(K=>K.type==="day").value,F=$.find(K=>K.type==="relatedYear");if(F===void 0)throw new RangeError(`Intl.DateTimeFormat.formatToParts lacks relatedYear in ${this.id} calendar. Try Node 14+ or modern browsers.`);return F=+F.value,{calendarMonthString:j,calendarDay:q,calendarYearToVerify:F}},a=17,{calendarMonthString:d,calendarDay:u,calendarYearToVerify:c}=s(e,a);d!=="1"&&(a+=29,{calendarMonthString:d,calendarDay:u}=s(e,a)),a-=u-5;let l={},p,m,g=1,v=!1;do({calendarMonthString:d,calendarDay:u,calendarYearToVerify:c}=s(e,a)),p&&(l[m].daysInMonth=p+30-u),c!==e?v=!0:(l[d]={monthIndex:g++},a+=30),p=u,m=d;while(!v);return l[m].daysInMonth=p+30-u,r.set(n,l),l}estimateIsoDate(e){let{year:r,month:n}=e;return{year:r,month:n>=12?12:n+1,day:1}}adjustCalendarDate(e,r,n="constrain",i=!1){let{year:o,month:s,monthExtra:a,day:d,monthCode:u,eraYear:c}=e;if(i){if(o=c,a&&a!=="bis")throw new RangeError(`Unexpected leap month suffix: ${a}`);let l=Kh(s,a!==void 0),p=`${s}${a||""}`,m=this.getMonthList(o,r)[p];if(m===void 0)throw new RangeError(`Unmatched month ${p} in Chinese year ${o}`);return s=m.monthIndex,{year:o,month:s,day:d,era:void 0,eraYear:c,monthCode:l}}if(this.validateCalendarDate(e),o===void 0&&(o=c),c===void 0&&(c=o),s===void 0){let l=this.getMonthList(o,r),p=u.replace("L","bis").slice(1);p[0]==="0"&&(p=p.slice(1));let m=l[p];if(s=m&&m.monthIndex,s===void 0&&u.endsWith("L")&&u!="M13L"&&n==="constrain"){let g=u.slice(1,-1);g[0]==="0"&&(g=g.slice(1)),m=l[g],m&&(s=m.monthIndex,u=Kh(g))}if(s===void 0)throw new RangeError(`Unmatched month ${u} in Chinese year ${o}`)}else if(u===void 0){let l=this.getMonthList(o,r),p=eN(l),m=p.length;n==="reject"?(ho(s,1,m),ho(d,1,this.maximumMonthLength())):(s=Da(s,1,m),d=Da(d,1,this.maximumMonthLength()));let g=p.find(([,v])=>v.monthIndex===s);if(g===void 0)throw new RangeError(`Invalid month ${s} in Chinese year ${o}`);u=Kh(g[0].replace("bis",""),g[0].indexOf("bis")!==-1)}else{let l=this.getMonthList(o,r),p=u.replace("L","bis").slice(1);p[0]==="0"&&(p=p.slice(1));let m=l[p];if(!m)throw new RangeError(`Unmatched monthCode ${u} in Chinese year ${o}`);if(s!==m.monthIndex)throw new RangeError(`monthCode ${u} doesn't correspond to month ${s} in Chinese year ${o}`)}return{...e,year:o,eraYear:c,month:s,monthCode:u,day:d}}},yN=class extends vP{constructor(){super(...arguments),this.id="chinese"}},gN=class extends vP{constructor(){super(...arguments),this.id="dangi"}},vN=class{constructor(e){this.helper=e}dateFromFields(e,r,n){let i=new xi,o=Ct(e,this.fields(["day","month","monthCode","year"]),[]),s=Xn(r),{year:a,month:d,day:u}=this.helper.calendarToIsoDate(o,s,i),c=Yc(a,d,u,n);return i.setObject(c),c}yearMonthFromFields(e,r,n){let i=new xi,o=Ct(e,this.fields(["month","monthCode","year"]),[]),s=Xn(r),{year:a,month:d,day:u}=this.helper.calendarToIsoDate({...o,day:1},s,i),c=_6(a,d,n,u);return i.setObject(c),c}monthDayFromFields(e,r,n){let i=new xi,o=Ct(e,this.fields(["day","month","monthCode","year"]),[]),s=Xn(r),{year:a,month:d,day:u}=this.helper.monthDayFromFields(o,s,i),c=w6(d,u,n,a);return i.setObject(c),c}fields(e){let r=e;return cle.call(r,"year")&&(r=[...r,"era","eraYear"]),r}fieldKeysToIgnore(e){let r=new dle;for(let n=0;nnew(Ae("%Temporal.Instant%"))(UN()),aue=(t,e=Gm())=>{let r=Lo(e),n=Oa(t);return sc(r,FN(),n)},Kj=(t=Gm())=>sc(Lo(t),FN(),"iso8601"),cue=(t,e=Gm())=>{let r=Lo(e),n=Oa(t);return lo(UN(),r,n)},hle={instant:FN,plainDateTime:aue,plainDateTimeISO:Kj,plainDate:(t,e=Gm())=>J1(aue(t,e)),plainDateISO:(t=Gm())=>J1(Kj(t)),plainTimeISO:(t=Gm())=>kN(Kj(t)),timeZoneId:()=>Gm(),zonedDateTime:cue,zonedDateTimeISO:(t=Gm())=>cue("iso8601",t),[Symbol.toStringTag]:"Temporal.Now"};Object.defineProperty(hle,Symbol.toStringTag,{value:"Temporal.Now",writable:!1,enumerable:!1,configurable:!0});var Cqe=Object.assign;function due(t,e,r){let n=R(t,St),i=R(t,At),o=R(t,Tt),s=R(t,Pt),a=R(t,It),d=R(t,kt);if(r){let{unit:u,increment:c,roundingMode:l}=r;({hour:n,minute:i,second:o,millisecond:s,microsecond:a,nanosecond:d}=NN(n,i,o,s,a,d,c,u,l))}return`${wn(n)}:${wn(i)}${DP(o,s,a,d,e)}`}var k6=class t{constructor(e=0,r=0,n=0,i=0,o=0,s=0){let a=e===void 0?0:vr(e),d=r===void 0?0:vr(r),u=n===void 0?0:vr(n),c=i===void 0?0:vr(i),l=o===void 0?0:vr(o),p=s===void 0?0:vr(s);OP(a,d,u,c,l,p),hf(this),Mt(this,St,a),Mt(this,At,d),Mt(this,Tt,u),Mt(this,Pt,c),Mt(this,It,l),Mt(this,kt,p)}get hour(){if(!jn(this))throw new TypeError("invalid receiver");return R(this,St)}get minute(){if(!jn(this))throw new TypeError("invalid receiver");return R(this,At)}get second(){if(!jn(this))throw new TypeError("invalid receiver");return R(this,Tt)}get millisecond(){if(!jn(this))throw new TypeError("invalid receiver");return R(this,Pt)}get microsecond(){if(!jn(this))throw new TypeError("invalid receiver");return R(this,It)}get nanosecond(){if(!jn(this))throw new TypeError("invalid receiver");return R(this,kt)}with(e,r){if(!jn(this))throw new TypeError("invalid receiver");if(!cn(e))throw new TypeError("invalid argument");e2(e);let n=Xn(tr(r)),i=uP(e,"partial"),o=uP(this),{hour:s,minute:a,second:d,millisecond:u,microsecond:c,nanosecond:l}=Cqe(o,i);return{hour:s,minute:a,second:d,millisecond:u,microsecond:c,nanosecond:l}=_P(s,a,d,u,c,l,n),new t(s,a,d,u,c,l)}add(e){if(!jn(this))throw new TypeError("invalid receiver");return nue("add",this,e)}subtract(e){if(!jn(this))throw new TypeError("invalid receiver");return nue("subtract",this,e)}until(e,r){if(!jn(this))throw new TypeError("invalid receiver");return Yde("until",this,e,r)}since(e,r){if(!jn(this))throw new TypeError("invalid receiver");return Yde("since",this,e,r)}round(e){if(!jn(this))throw new TypeError("invalid receiver");if(e===void 0)throw new TypeError("options parameter is required");let r=typeof e=="string"?Y1("smallestUnit",e):tr(e),n=t2(r),i=Hu(r,"halfExpand"),o=Ma(r,"smallestUnit","time",iv);r2(n,{hour:24,minute:60,second:60,millisecond:1e3,microsecond:1e3,nanosecond:1e3}[o],!1);let s=R(this,St),a=R(this,At),d=R(this,Tt),u=R(this,Pt),c=R(this,It),l=R(this,kt);return{hour:s,minute:a,second:d,millisecond:u,microsecond:c,nanosecond:l}=NN(s,a,d,u,c,l,n,o,i),new t(s,a,d,u,c,l)}equals(e){if(!jn(this))throw new TypeError("invalid receiver");let r=Uh(e);for(let n of[St,At,Tt,Pt,It,kt])if(R(this,n)!==R(r,n))return!1;return!0}toString(e){if(!jn(this))throw new TypeError("invalid receiver");let r=tr(e),n=$6(r),i=Hu(r,"trunc"),o=Ma(r,"smallestUnit","time",void 0);if(o==="hour")throw new RangeError('smallestUnit must be a time unit other than "hour"');let{precision:s,unit:a,increment:d}=j6(o,n);return due(this,s,{unit:a,increment:d,roundingMode:i})}toJSON(){if(!jn(this))throw new TypeError("invalid receiver");return due(this,"auto")}toLocaleString(e,r){if(!jn(this))throw new TypeError("invalid receiver");return new Vh(e,r).format(this)}valueOf(){throw new TypeError("use compare() or equals() to compare Temporal.PlainTime")}toPlainDateTime(e){if(!jn(this))throw new TypeError("invalid receiver");let r=Lr(e),n=R(r,De),i=R(r,Oe),o=R(r,je),s=R(r,fe);return Ra(n,i,o,R(this,St),R(this,At),R(this,Tt),R(this,Pt),R(this,It),R(this,kt),s)}toZonedDateTime(e){if(!jn(this))throw new TypeError("invalid receiver");if(!cn(e))throw new TypeError("invalid argument");let r=e.plainDate;if(r===void 0)throw new TypeError("missing date property");let n=Lr(r),i=e.timeZone;if(i===void 0)throw new TypeError("missing timeZone property");let o=Lo(i),s=R(n,De),a=R(n,Oe),d=R(n,je),u=R(n,fe),c=R(this,St),l=R(this,At),p=R(this,Tt),m=R(this,Pt),g=R(this,It),v=R(this,kt);return lo(R(_s(o,new(Ae("%Temporal.PlainDateTime%"))(s,a,d,c,l,p,m,g,v,u),"compatible"),ut),o,u)}getISOFields(){if(!jn(this))throw new TypeError("invalid receiver");return{isoHour:R(this,St),isoMicrosecond:R(this,It),isoMillisecond:R(this,Pt),isoMinute:R(this,At),isoNanosecond:R(this,kt),isoSecond:R(this,Tt)}}static from(e,r){let n=Xn(tr(r));return jn(e)?new t(R(e,St),R(e,At),R(e,Tt),R(e,Pt),R(e,It),R(e,kt)):Uh(e,n)}static compare(e,r){let n=Uh(e),i=Uh(r);for(let o of[St,At,Tt,Pt,It,kt]){let s=R(n,o),a=R(i,o);if(s!==a)return rv(s-a)}return 0}};ff(k6,"Temporal.PlainTime");var nv=class{constructor(e){if(arguments.length<1)throw new RangeError("missing argument: identifier is required");let r=RN(e);hf(this),Mt(this,of,r)}get id(){if(!Vc(this))throw new TypeError("invalid receiver");return R(this,of)}getOffsetNanosecondsFor(e){if(!Vc(this))throw new TypeError("invalid receiver");let r=Wu(e),n=R(this,of);return $1(n)?Ym(n):qh(n,R(r,ut))}getOffsetStringFor(e){if(!Vc(this))throw new TypeError("invalid receiver");return Gj(this,Wu(e))}getPlainDateTimeFor(e,r="iso8601"){if(!Vc(this))throw new TypeError("invalid receiver");return sc(this,Wu(e),Oa(r))}getInstantFor(e,r){if(!Vc(this))throw new TypeError("invalid receiver");return _s(this,ev(e),V1(tr(r)))}getPossibleInstantsFor(e){if(!Vc(this))throw new TypeError("invalid receiver");let r=ev(e),n=Ae("%Temporal.Instant%"),i=R(this,of);if($1(i)){let s=Xm(R(r,De),R(r,Oe),R(r,je),R(r,St),R(r,At),R(r,Tt),R(r,Pt),R(r,It),R(r,kt));if(s===null)throw new RangeError("DateTime outside of supported range");let a=Ym(i);return[new n(z.default.subtract(s,z.default.BigInt(a)))]}return function(a,d,u,c,l,p,m,g,v,x){let S=Xm(d,u,c,l,p,m,g,v,x);if(S===null)throw new RangeError("DateTime outside of supported range");let P=z.default.subtract(S,df);z.default.lessThan(P,b6)&&(P=S);let A=z.default.add(S,df);z.default.greaterThan(A,W1)&&(A=S);let $=qh(a,P),j=qh(a,A);return($===j?[$]:[$,j]).map(q=>{let F=z.default.subtract(S,z.default.BigInt(q)),K=jue(a,F);if(d===K.year&&u===K.month&&c===K.day&&l===K.hour&&p===K.minute&&m===K.second&&g===K.millisecond&&v===K.microsecond&&x===K.nanosecond)return F}).filter(q=>q!==void 0)}(i,R(r,De),R(r,Oe),R(r,je),R(r,St),R(r,At),R(r,Tt),R(r,Pt),R(r,It),R(r,kt)).map(s=>new n(s))}getNextTransition(e){if(!Vc(this))throw new TypeError("invalid receiver");let r=Wu(e),n=R(this,of);if($1(n)||n==="UTC")return null;let i=R(r,ut),o=Ae("%Temporal.Instant%");return i=Uue(n,i),i===null?null:new o(i)}getPreviousTransition(e){if(!Vc(this))throw new TypeError("invalid receiver");let r=Wu(e),n=R(this,of);if($1(n)||n==="UTC")return null;let i=R(r,ut),o=Ae("%Temporal.Instant%");return i=Jj(n,i),i===null?null:new o(i)}toString(){if(!Vc(this))throw new TypeError("invalid receiver");return R(this,of)}toJSON(){if(!Vc(this))throw new TypeError("invalid receiver");return R(this,of)}static from(e){return Bue(Lo(e))}};ff(nv,"Temporal.TimeZone"),kn("Temporal.TimeZone.prototype.getOffsetNanosecondsFor",nv.prototype.getOffsetNanosecondsFor),kn("Temporal.TimeZone.prototype.getPossibleInstantsFor",nv.prototype.getPossibleInstantsFor);var $qe=Object.create,R6=class{constructor(e,r,n="iso8601",i=1){kue(this,vr(e),vr(r),Oa(n),vr(i))}get year(){if(!Sr(this))throw new TypeError("invalid receiver");return xP(R(this,fe),this)}get month(){if(!Sr(this))throw new TypeError("invalid receiver");return EP(R(this,fe),this)}get monthCode(){if(!Sr(this))throw new TypeError("invalid receiver");return U6(R(this,fe),this)}get calendarId(){if(!Sr(this))throw new TypeError("invalid receiver");return po(R(this,fe))}get era(){if(!Sr(this))throw new TypeError("invalid receiver");return SP(R(this,fe),this)}get eraYear(){if(!Sr(this))throw new TypeError("invalid receiver");return AP(R(this,fe),this)}get daysInMonth(){if(!Sr(this))throw new TypeError("invalid receiver");return TP(R(this,fe),this)}get daysInYear(){if(!Sr(this))throw new TypeError("invalid receiver");return PP(R(this,fe),this)}get monthsInYear(){if(!Sr(this))throw new TypeError("invalid receiver");return IP(R(this,fe),this)}get inLeapYear(){if(!Sr(this))throw new TypeError("invalid receiver");return kP(R(this,fe),this)}with(e,r){if(!Sr(this))throw new TypeError("invalid receiver");if(!cn(e))throw new TypeError("invalid argument");e2(e);let n=tr(r),i=R(this,fe),o=si(i,["month","monthCode","year"]),s=Ct(this,o,[]);return s=sv(i,s,Ct(e,o,"partial")),s=Ct(s,o,[]),av(i,s,n)}add(e,r){if(!Sr(this))throw new TypeError("invalid receiver");return iue("add",this,e,r)}subtract(e,r){if(!Sr(this))throw new TypeError("invalid receiver");return iue("subtract",this,e,r)}until(e,r){if(!Sr(this))throw new TypeError("invalid receiver");return Xde("until",this,e,r)}since(e,r){if(!Sr(this))throw new TypeError("invalid receiver");return Xde("since",this,e,r)}equals(e){if(!Sr(this))throw new TypeError("invalid receiver");let r=m6(e);for(let n of[De,Oe,je])if(R(this,n)!==R(r,n))return!1;return K6(R(this,fe),R(r,fe))}toString(e){if(!Sr(this))throw new TypeError("invalid receiver");return Fde(this,C6(tr(e)))}toJSON(){if(!Sr(this))throw new TypeError("invalid receiver");return Fde(this)}toLocaleString(e,r){if(!Sr(this))throw new TypeError("invalid receiver");return new Vh(e,r).format(this)}valueOf(){throw new TypeError("use compare() or equals() to compare Temporal.PlainYearMonth")}toPlainDate(e){if(!Sr(this))throw new TypeError("invalid receiver");if(!cn(e))throw new TypeError("argument should be an object");let r=R(this,fe),n=si(r,["monthCode","year"]),i=Ct(this,n,[]),o=si(r,["day"]),s=sv(r,i,Ct(e,o,[]));s=Ct(s,[...new Set([...n,...o])],[]);let a=$qe(null);return a.overflow="reject",Fh(r,s,a)}getISOFields(){if(!Sr(this))throw new TypeError("invalid receiver");return{calendar:R(this,fe),isoDay:R(this,je),isoMonth:R(this,Oe),isoYear:R(this,De)}}getCalendar(){if(!Sr(this))throw new TypeError("invalid receiver");return n2(R(this,fe))}static from(e,r){let n=tr(r);return Sr(e)?(Xn(n),_6(R(e,De),R(e,Oe),R(e,fe),R(e,je))):m6(e,n)}static compare(e,r){let n=m6(e),i=m6(r);return Jm(R(n,De),R(n,Oe),R(n,je),R(i,De),R(i,Oe),R(i,je))}};ff(R6,"Temporal.PlainYearMonth");var jqe=Vh.prototype.resolvedOptions,Nqe=Object.create,D6=class{constructor(e,r,n="iso8601"){if(arguments.length<1)throw new TypeError("missing argument: epochNanoseconds is required");Rue(this,g6(e),Lo(r),Oa(n))}get calendarId(){if(!Ke(this))throw new TypeError("invalid receiver");return po(R(this,fe))}get timeZoneId(){if(!Ke(this))throw new TypeError("invalid receiver");return x6(R(this,Ur))}get year(){if(!Ke(this))throw new TypeError("invalid receiver");return xP(R(this,fe),sn(this))}get month(){if(!Ke(this))throw new TypeError("invalid receiver");return EP(R(this,fe),sn(this))}get monthCode(){if(!Ke(this))throw new TypeError("invalid receiver");return U6(R(this,fe),sn(this))}get day(){if(!Ke(this))throw new TypeError("invalid receiver");return q6(R(this,fe),sn(this))}get hour(){if(!Ke(this))throw new TypeError("invalid receiver");return R(sn(this),St)}get minute(){if(!Ke(this))throw new TypeError("invalid receiver");return R(sn(this),At)}get second(){if(!Ke(this))throw new TypeError("invalid receiver");return R(sn(this),Tt)}get millisecond(){if(!Ke(this))throw new TypeError("invalid receiver");return R(sn(this),Pt)}get microsecond(){if(!Ke(this))throw new TypeError("invalid receiver");return R(sn(this),It)}get nanosecond(){if(!Ke(this))throw new TypeError("invalid receiver");return R(sn(this),kt)}get era(){if(!Ke(this))throw new TypeError("invalid receiver");return SP(R(this,fe),sn(this))}get eraYear(){if(!Ke(this))throw new TypeError("invalid receiver");return AP(R(this,fe),sn(this))}get epochSeconds(){if(!Ke(this))throw new TypeError("invalid receiver");let e=R(this,ut);return z.default.toNumber(q1(e,af))}get epochMilliseconds(){if(!Ke(this))throw new TypeError("invalid receiver");let e=R(this,ut);return z.default.toNumber(q1(e,Jc))}get epochMicroseconds(){if(!Ke(this))throw new TypeError("invalid receiver");return yP(q1(R(this,ut),Ar))}get epochNanoseconds(){if(!Ke(this))throw new TypeError("invalid receiver");return yP(R(this,ut))}get dayOfWeek(){if(!Ke(this))throw new TypeError("invalid receiver");return SN(R(this,fe),sn(this))}get dayOfYear(){if(!Ke(this))throw new TypeError("invalid receiver");return AN(R(this,fe),sn(this))}get weekOfYear(){if(!Ke(this))throw new TypeError("invalid receiver");return TN(R(this,fe),sn(this))}get yearOfWeek(){if(!Ke(this))throw new TypeError("invalid receiver");return PN(R(this,fe),sn(this))}get hoursInDay(){if(!Ke(this))throw new TypeError("invalid receiver");let e=sn(this),r=Ae("%Temporal.PlainDateTime%"),n=R(e,De),i=R(e,Oe),o=R(e,je),s=new r(n,i,o,0,0,0,0,0,0),a=tv(n,i,o,0,0,0,1,"reject"),d=new r(a.year,a.month,a.day,0,0,0,0,0,0),u=R(this,Ur),c=R(_s(u,s,"compatible"),ut),l=R(_s(u,d,"compatible"),ut);return nf(z.default.subtract(l,c),_ue)}get daysInWeek(){if(!Ke(this))throw new TypeError("invalid receiver");return IN(R(this,fe),sn(this))}get daysInMonth(){if(!Ke(this))throw new TypeError("invalid receiver");return TP(R(this,fe),sn(this))}get daysInYear(){if(!Ke(this))throw new TypeError("invalid receiver");return PP(R(this,fe),sn(this))}get monthsInYear(){if(!Ke(this))throw new TypeError("invalid receiver");return IP(R(this,fe),sn(this))}get inLeapYear(){if(!Ke(this))throw new TypeError("invalid receiver");return kP(R(this,fe),sn(this))}get offset(){if(!Ke(this))throw new TypeError("invalid receiver");return Gj(R(this,Ur),R(this,qo))}get offsetNanoseconds(){if(!Ke(this))throw new TypeError("invalid receiver");return Vu(R(this,Ur),R(this,qo))}with(e,r){if(!Ke(this))throw new TypeError("invalid receiver");if(!cn(e))throw new TypeError("invalid zoned-date-time-like");e2(e);let n=tr(r),i=R(this,fe),o=si(i,["day","hour","microsecond","millisecond","minute","month","monthCode","nanosecond","second","year"]);o.push("offset");let s=Ct(this,o,["offset"]);s=sv(i,s,Ct(e,o,"partial")),s=Ct(s,o,["offset"]);let a=V1(n),d=dP(n,"prefer"),{year:u,month:c,day:l,hour:p,minute:m,second:g,millisecond:v,microsecond:x,nanosecond:S}=N6(i,s,n),P=Ym(s.offset),A=R(this,Ur);return lo(lP(u,c,l,p,m,g,v,x,S,"option",P,A,a,d,!1),A,i)}withPlainDate(e){if(!Ke(this))throw new TypeError("invalid receiver");let r=Lr(e),n=R(r,De),i=R(r,Oe),o=R(r,je),s=R(r,fe),a=sn(this),d=R(a,St),u=R(a,At),c=R(a,Tt),l=R(a,Pt),p=R(a,It),m=R(a,kt);s=Due(R(this,fe),s);let g=R(this,Ur);return lo(R(_s(g,new(Ae("%Temporal.PlainDateTime%"))(n,i,o,d,u,c,l,p,m,s),"compatible"),ut),g,s)}withPlainTime(e){if(!Ke(this))throw new TypeError("invalid receiver");let r=Ae("%Temporal.PlainTime%"),n=e===void 0?new r:Uh(e),i=sn(this),o=R(i,De),s=R(i,Oe),a=R(i,je),d=R(this,fe),u=R(n,St),c=R(n,At),l=R(n,Tt),p=R(n,Pt),m=R(n,It),g=R(n,kt),v=R(this,Ur);return lo(R(_s(v,new(Ae("%Temporal.PlainDateTime%"))(o,s,a,u,c,l,p,m,g,d),"compatible"),ut),v,d)}withTimeZone(e){if(!Ke(this))throw new TypeError("invalid receiver");let r=Lo(e);return lo(R(this,ut),r,R(this,fe))}withCalendar(e){if(!Ke(this))throw new TypeError("invalid receiver");let r=Oa(e);return lo(R(this,ut),R(this,Ur),r)}add(e,r){if(!Ke(this))throw new TypeError("invalid receiver");return oue("add",this,e,r)}subtract(e,r){if(!Ke(this))throw new TypeError("invalid receiver");return oue("subtract",this,e,r)}until(e,r){if(!Ke(this))throw new TypeError("invalid receiver");return Qde("until",this,e,r)}since(e,r){if(!Ke(this))throw new TypeError("invalid receiver");return Qde("since",this,e,r)}round(e){if(!Ke(this))throw new TypeError("invalid receiver");if(e===void 0)throw new TypeError("options parameter is required");let r=typeof e=="string"?Y1("smallestUnit",e):tr(e),n=t2(r),i=Hu(r,"halfExpand"),o=Ma(r,"smallestUnit","time",iv,["day"]),s={day:1,hour:24,minute:60,second:60,millisecond:1e3,microsecond:1e3,nanosecond:1e3}[o];r2(n,s,s===1);let a=sn(this),d=R(a,De),u=R(a,Oe),c=R(a,je),l=R(a,St),p=R(a,At),m=R(a,Tt),g=R(a,Pt),v=R(a,It),x=R(a,kt),S=Ae("%Temporal.PlainDateTime%"),P=R(this,Ur),A=R(this,fe),$=_s(P,new S(R(a,De),R(a,Oe),R(a,je),0,0,0,0,0,0),"compatible"),j=Zc($,P,A,0,0,0,1,0,0,0,0,0,0),q=z.default.subtract(j,z.default.BigInt(R($,ut)));if(z.default.lessThanOrEqual(q,Nn))throw new RangeError("cannot round a ZonedDateTime in a calendar with zero or negative length days");return{year:d,month:u,day:c,hour:l,minute:p,second:m,millisecond:g,microsecond:v,nanosecond:x}=jN(d,u,c,l,p,m,g,v,x,n,o,i,z.default.toNumber(q)),lo(lP(d,u,c,l,p,m,g,v,x,"option",Vu(P,R(this,qo)),P,"compatible","prefer",!1),P,R(this,fe))}equals(e){if(!Ke(this))throw new TypeError("invalid receiver");let r=y6(e),n=R(this,ut),i=R(r,ut);return!!z.default.equal(z.default.BigInt(n),z.default.BigInt(i))&&!!Mue(R(this,Ur),R(r,Ur))&&K6(R(this,fe),R(r,fe))}toString(e){if(!Ke(this))throw new TypeError("invalid receiver");let r=tr(e),n=C6(r),i=$6(r),o=function(m){return ey(m,"offset",["auto","never"],"auto")}(r),s=Hu(r,"trunc"),a=Ma(r,"smallestUnit","time",void 0);if(a==="hour")throw new RangeError('smallestUnit must be a time unit other than "hour"');let d=function(m){return ey(m,"timeZoneName",["auto","never","critical"],"auto")}(r),{precision:u,unit:c,increment:l}=j6(a,i);return zde(this,u,n,d,o,{unit:c,increment:l,roundingMode:s})}toLocaleString(e,r){if(!Ke(this))throw new TypeError("invalid receiver");let n=tr(r),i=Nqe(null);if(N1(i,n,["timeZone"]),n.timeZone!==void 0)throw new TypeError("ZonedDateTime toLocaleString does not accept a timeZone option");i.year===void 0&&i.month===void 0&&i.day===void 0&&i.weekday===void 0&&i.dateStyle===void 0&&i.hour===void 0&&i.minute===void 0&&i.second===void 0&&i.timeStyle===void 0&&i.dayPeriod===void 0&&i.timeZoneName===void 0&&(i.timeZoneName="short");let o=x6(R(this,Ur));if($1(o))throw new RangeError("toLocaleString does not support offset string time zones");o=RN(o),i.timeZone=o;let s=new Vh(e,i),a=Ge(jqe,s,[]).calendar,d=po(R(this,fe));if(d!=="iso8601"&&a!=="iso8601"&&a!==d)throw new RangeError(`cannot format ZonedDateTime with calendar ${d} in locale with calendar ${a}`);return s.format(R(this,qo))}toJSON(){if(!Ke(this))throw new TypeError("invalid receiver");return zde(this,"auto")}valueOf(){throw new TypeError("use compare() or equals() to compare Temporal.ZonedDateTime")}startOfDay(){if(!Ke(this))throw new TypeError("invalid receiver");let e=sn(this),r=Ae("%Temporal.PlainDateTime%"),n=R(this,fe),i=new r(R(e,De),R(e,Oe),R(e,je),0,0,0,0,0,0,n),o=R(this,Ur);return lo(R(_s(o,i,"compatible"),ut),o,n)}toInstant(){if(!Ke(this))throw new TypeError("invalid receiver");return new(Ae("%Temporal.Instant%"))(R(this,ut))}toPlainDate(){if(!Ke(this))throw new TypeError("invalid receiver");return J1(sn(this))}toPlainTime(){if(!Ke(this))throw new TypeError("invalid receiver");return kN(sn(this))}toPlainDateTime(){if(!Ke(this))throw new TypeError("invalid receiver");return sn(this)}toPlainYearMonth(){if(!Ke(this))throw new TypeError("invalid receiver");let e=R(this,fe);return av(e,Ct(this,si(e,["monthCode","year"]),[]))}toPlainMonthDay(){if(!Ke(this))throw new TypeError("invalid receiver");let e=R(this,fe);return G1(e,Ct(this,si(e,["day","monthCode"]),[]))}getISOFields(){if(!Ke(this))throw new TypeError("invalid receiver");let e=sn(this),r=R(this,Ur);return{calendar:R(this,fe),isoDay:R(e,je),isoHour:R(e,St),isoMicrosecond:R(e,It),isoMillisecond:R(e,Pt),isoMinute:R(e,At),isoMonth:R(e,Oe),isoNanosecond:R(e,kt),isoSecond:R(e,Tt),isoYear:R(e,De),offset:Gj(r,R(this,qo)),timeZone:r}}getCalendar(){if(!Ke(this))throw new TypeError("invalid receiver");return n2(R(this,fe))}getTimeZone(){if(!Ke(this))throw new TypeError("invalid receiver");return Bue(R(this,Ur))}static from(e,r){let n=tr(r);return Ke(e)?(V1(n),dP(n,"reject"),Xn(n),lo(R(e,ut),R(e,Ur),R(e,fe))):y6(e,n)}static compare(e,r){let n=y6(e),i=y6(r),o=R(n,ut),s=R(i,ut);return z.default.lessThan(z.default.BigInt(o),z.default.BigInt(s))?-1:z.default.greaterThan(z.default.BigInt(o),z.default.BigInt(s))?1:0}};function sn(t){return sc(R(t,Ur),R(t,qo),R(t,fe))}ff(D6,"Temporal.ZonedDateTime");var fv=Object.freeze({__proto__:null,Calendar:vn,Duration:P6,Instant:E6,Now:hle,PlainDate:A6,PlainDateTime:T6,PlainMonthDay:I6,PlainTime:k6,PlainYearMonth:R6,TimeZone:nv,ZonedDateTime:D6});var Uqe=[E6,vn,A6,T6,P6,I6,k6,nv,R6,D6];for(let t of Uqe){let e=Object.getOwnPropertyDescriptor(t,"prototype");(e.configurable||e.enumerable||e.writable)&&(e.configurable=!1,e.enumerable=!1,e.writable=!1,Object.defineProperty(t,"prototype",e))}var ple=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},pr=class t{static sleep(e){return ple(this,void 0,void 0,function*(){return new Promise(r=>setTimeout(r,e))})}static minimalSleep(){return ple(this,void 0,void 0,function*(){yield t.sleep(2)})}static getCurrentTimestamp(){return fv.Now.instant().toString({smallestUnit:"microseconds"})}static createTimestamp(e){let{year:r,month:n,day:i,hour:o,minute:s,second:a,millisecond:d,microsecond:u}=e;return fv.ZonedDateTime.from({timeZone:"UTC",year:r,month:n,day:i,hour:o,minute:s,second:a,millisecond:d,microsecond:u}).toInstant().toString({smallestUnit:"microseconds"})}static createOffsetTimestamp(e,r){let n=r?fv.Instant.from(r):fv.Now.instant(),i=fv.Duration.from(e);return n.add(i).toString({smallestUnit:"microseconds"})}static validateTimestamp(e){try{fv.Instant.from(e)}catch{throw new de(oe.TimestampInvalid,`Invalid timestamp: ${e}`)}}};var ai=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},qqe=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);ir!=="").pop()}static createFrom(e){var r,n,i,o;return ai(this,void 0,void 0,function*(){let s=e.recordsWriteMessage,a=yield t.parse(s),d=pr.getCurrentTimestamp(),u=(r=e.published)!==null&&r!==void 0?r:e.datePublished?!0:s.descriptor.published,c;e.datePublished?c=e.datePublished:u&&(s.descriptor.published?c=s.descriptor.datePublished:c=d);let l={recipient:s.descriptor.recipient,recordId:s.recordId,dateCreated:s.descriptor.dateCreated,protocol:s.descriptor.protocol,protocolPath:s.descriptor.protocolPath,schema:s.descriptor.schema,parentContextId:lt.getParentContextFromOfContextId(s.contextId),messageTimestamp:(n=e.messageTimestamp)!==null&&n!==void 0?n:d,published:u,datePublished:c,tags:e.tags,data:e.data,dataCid:e.data?void 0:s.descriptor.dataCid,dataSize:e.data?void 0:s.descriptor.dataSize,dataFormat:(i=e.dataFormat)!==null&&i!==void 0?i:s.descriptor.dataFormat,protocolRole:(o=e.protocolRole)!==null&&o!==void 0?o:a.signaturePayload.protocolRole,delegatedGrant:e.delegatedGrant,signer:e.signer,attestationSigners:e.attestationSigners};return yield t.create(l)})}toJSON(){return this.message}encryptSymmetricEncryptionKey(e){return ai(this,void 0,void 0,function*(){this._message.encryption=yield t.createEncryptionProperty(this._message.descriptor,e),delete this._message.authorization,this._signaturePayload=void 0,this._author=void 0})}sign(e){var r;return ai(this,void 0,void 0,function*(){let{signer:n,delegatedGrant:i,permissionGrantId:o,protocolRole:s}=e,a,d;i!==void 0?(a=yield _e.getCid(i),d=Vr.getSignerDid(i.authorization.signature.signatures[0])):d=Vr.extractDid(n.keyId);let u=this._message.descriptor,c=yield hn.computeCid(u);this._message.recordId=(r=this._message.recordId)!==null&&r!==void 0?r:yield t.getEntryId(d,u),this._message.descriptor.protocol!==void 0&&(this.parentContextId===void 0||this.parentContextId===""?this._message.contextId=this._message.recordId:this._message.contextId=this.parentContextId+"/"+this._message.recordId);let l=yield t.createSignerSignature({recordId:this._message.recordId,contextId:this._message.contextId,descriptorCid:c,attestation:this._message.attestation,encryption:this._message.encryption,signer:n,delegatedGrantId:a,permissionGrantId:o,protocolRole:s});this._message.authorization={signature:l},i!==void 0&&(this._message.authorization.authorDelegatedGrant=i),this._signaturePayload=Vr.decodePlainObjectPayload(l),this._author=d})}signAsOwner(e){return ai(this,void 0,void 0,function*(){if(this._author===void 0)throw new de(oe.RecordsWriteSignAsOwnerUnknownAuthor,"Unable to sign as owner without message signature because owner needs to sign over `recordId` which depends on author DID.");let r=this._message.descriptor,n=yield _e.createSignature(r,e);this._message.authorization.ownerSignature=n,this._ownerSignaturePayload=Vr.decodePlainObjectPayload(n),this._owner=Vr.extractDid(e.keyId)})}signAsOwnerDelegate(e,r){return ai(this,void 0,void 0,function*(){if(this._author===void 0)throw new de(oe.RecordsWriteSignAsOwnerDelegateUnknownAuthor,"Unable to sign as owner delegate without message signature because owner delegate needs to sign over `recordId` which depends on author DID.");let n=yield _e.getCid(r),i=this._message.descriptor,o=yield _e.createSignature(i,e,{delegatedGrantId:n});this._message.authorization.ownerSignature=o,this._message.authorization.ownerDelegatedGrant=r,this._ownerSignaturePayload=Vr.decodePlainObjectPayload(o),this._owner=Vr.getSignerDid(r.authorization.signature.signatures[0])})}validateIntegrity(){return ai(this,void 0,void 0,function*(){if(yield this.isInitialWrite()){let n=this.message.descriptor.dateCreated,i=this.message.descriptor.messageTimestamp;if(i!==n)throw new de(oe.RecordsWriteValidateIntegrityDateCreatedMismatch,`messageTimestamp ${i} must match dateCreated ${n} for the initial write`);if(this.message.descriptor.protocol!==void 0&&this.message.descriptor.parentId===void 0){let o=yield this.getEntryId();if(this.message.contextId!==o)throw new de(oe.RecordsWriteValidateIntegrityContextIdMismatch,`contextId in message: ${this.message.contextId} does not match deterministic contextId: ${o}`)}}let r=this.signaturePayload;if(this.message.recordId!==r.recordId)throw new de(oe.RecordsWriteValidateIntegrityRecordIdUnauthorized,`recordId in message ${this.message.recordId} does not match recordId in authorization: ${r.recordId}`);if(this.message.contextId!==r.contextId)throw new de(oe.RecordsWriteValidateIntegrityContextIdNotInSignerSignaturePayload,`contextId in message ${this.message.contextId} does not match contextId in authorization: ${r.contextId}`);if(yield lt.validateDelegatedGrantReferentialIntegrity(this.message,r,this.ownerSignaturePayload),r.attestationCid!==void 0){let n=yield hn.computeCid(this.message.attestation),i=r.attestationCid;if(i!==n)throw new de(oe.RecordsWriteValidateIntegrityAttestationMismatch,`CID ${n} of attestation property in message does not match attestationCid in authorization: ${i}`)}if(r.encryptionCid!==void 0){let n=yield hn.computeCid(this.message.encryption),i=r.encryptionCid;if(i!==n)throw new de(oe.RecordsWriteValidateIntegrityEncryptionCidMismatch,`CID ${n} of encryption property in message does not match encryptionCid in authorization: ${i}`)}this.message.descriptor.protocol!==void 0&&ia(this.message.descriptor.protocol),this.message.descriptor.schema!==void 0&&Vm(this.message.descriptor.schema),pr.validateTimestamp(this.message.descriptor.messageTimestamp),pr.validateTimestamp(this.message.descriptor.dateCreated),this.message.descriptor.datePublished&&pr.validateTimestamp(this.message.descriptor.datePublished)})}static validateAttestationIntegrity(e){return ai(this,void 0,void 0,function*(){if(e.attestation===void 0)return;if(e.attestation.signatures.length!==1)throw new de(oe.RecordsWriteAttestationIntegrityMoreThanOneSignature,`Currently implementation only supports 1 attester, but got ${e.attestation.signatures.length}`);let r=Vr.decodePlainObjectPayload(e.attestation),{descriptorCid:n}=r,i=yield hn.computeCid(e.descriptor);if(n!==i)throw new de(oe.RecordsWriteAttestationIntegrityDescriptorCidMismatch,`descriptorCid ${n} does not match expected descriptorCid ${i}`);let o=Object.keys(r).length;if(o>1)throw new de(oe.RecordsWriteAttestationIntegrityInvalidPayloadProperty,`Only 'descriptorCid' is allowed in attestation payload, but got ${o} properties.`)})}getEntryId(){return ai(this,void 0,void 0,function*(){return yield t.getEntryId(this.author,this.message.descriptor)})}static getEntryId(e,r){return ai(this,void 0,void 0,function*(){if(e===void 0)throw new de(oe.RecordsWriteGetEntryIdUndefinedAuthor,"Property `author` is needed to compute entry ID.");let n=Object.assign({},r);return n.author=e,yield hn.computeCid(n)})}isInitialWrite(){return ai(this,void 0,void 0,function*(){return(yield this.getEntryId())===this.message.recordId})}constructIndexes(e){return ai(this,void 0,void 0,function*(){let r=this.message,n=r.descriptor,{tags:i}=n,o=qqe(n,["tags"]);delete o.published;let s=Object.assign(Object.assign({},o),{isLatestBaseState:e,published:!!r.descriptor.published,author:this.author,recordId:r.recordId,entryId:yield t.getEntryId(this.author,this.message.descriptor)});if(i!==void 0&&e===!0){let a=lt.buildTagIndexes(Object.assign({},i));s=Object.assign(Object.assign({},s),a)}return this.attesters.length>0&&(s.attester=this.attesters[0]),r.contextId!==void 0&&(s.contextId=r.contextId),s})}authorizeAuthorDelegate(e){return ai(this,void 0,void 0,function*(){let r=yield gn.parse(this.message.authorization.authorDelegatedGrant);yield ls.authorizeWrite({recordsWriteMessage:this.message,expectedGrantor:this.author,expectedGrantee:this.signer,permissionGrant:r,messageStore:e})})}authorizeOwnerDelegate(e){return ai(this,void 0,void 0,function*(){let r=yield gn.parse(this.message.authorization.ownerDelegatedGrant);yield ls.authorizeWrite({recordsWriteMessage:this.message,expectedGrantor:this.owner,expectedGrantee:this.ownerSignatureSigner,permissionGrant:r,messageStore:e})})}static isInitialWrite(e){return ai(this,void 0,void 0,function*(){if(e.descriptor.interface!==Te.Records||e.descriptor.method!==Se.Write)return!1;let r=e,n=_e.getAuthor(r);return(yield t.getEntryId(n,r.descriptor))===r.recordId})}static createEncryptionProperty(e,r){var n,i;return ai(this,void 0,void 0,function*(){if(r===void 0)return;let o=[];for(let a of r.keyEncryptionInputs){if(a.derivationScheme===co.ProtocolPath&&e.protocol===void 0)throw new de(oe.RecordsWriteMissingProtocol,"`protocols` encryption scheme cannot be applied to record without the `protocol` property.");if(a.derivationScheme===co.Schemas&&e.schema===void 0)throw new de(oe.RecordsWriteMissingSchema,"`schemas` encryption scheme cannot be applied to record without the `schema` property.");let d=Ki.publicJwkToBytes(a.publicKey),u=yield $h.eciesSecp256k1Encrypt(d,r.key),c=qe.bytesToBase64Url(u.ciphertext),l=yield Ki.publicKeyToJwk(u.ephemeralPublicKey),p=qe.bytesToBase64Url(u.initializationVector),m=qe.bytesToBase64Url(u.messageAuthenticationCode),g={rootKeyId:a.publicKeyId,algorithm:(n=a.algorithm)!==null&&n!==void 0?n:Vg.EciesSecp256k1,derivationScheme:a.derivationScheme,ephemeralPublicKey:l,initializationVector:p,messageAuthenticationCode:m,encryptedKey:c};a.derivationScheme===co.ProtocolContext&&(g.derivedPublicKey=a.publicKey),o.push(g)}return{algorithm:(i=r.algorithm)!==null&&i!==void 0?i:Vg.Aes256Ctr,initializationVector:qe.bytesToBase64Url(r.initializationVector),keyEncryption:o}})}static createAttestation(e,r){return ai(this,void 0,void 0,function*(){if(r===void 0||r.length===0)return;let n={descriptorCid:e},i=qe.objectToBytes(n);return(yield Gg.create(i,r)).getJws()})}static createSignerSignature(e){return ai(this,void 0,void 0,function*(){let{recordId:r,contextId:n,descriptorCid:i,attestation:o,encryption:s,signer:a,delegatedGrantId:d,permissionGrantId:u,protocolRole:c}=e,l=o?yield hn.computeCid(o):void 0,p=s?yield hn.computeCid(s):void 0,m={recordId:r,descriptorCid:i,contextId:n,attestationCid:l,encryptionCid:p,delegatedGrantId:d,permissionGrantId:u,protocolRole:c};Pn(m);let g=qe.objectToBytes(m);return(yield Gg.create(g,[a])).getJws()})}static getInitialWrite(e){return ai(this,void 0,void 0,function*(){for(let r of e)if(yield t.isInitialWrite(r))return r;throw new de(oe.RecordsWriteGetInitialWriteNotFound,"Initial write is not found.")})}static verifyEqualityOfImmutableProperties(e,r){let n=["dataCid","dataSize","dataFormat","datePublished","published","messageTimestamp","tags"],i=[];i.push(...Object.keys(e.descriptor)),i.push(...Object.keys(r.descriptor)),i=[...new Set(i)];for(let o of i)if(n.indexOf(o)===-1){let s=e.descriptor[o],a=r.descriptor[o];if(a!==s)throw new de(oe.RecordsWriteImmutablePropertyChanged,`${o} is an immutable property: cannot change '${s}' to '${a}'`)}return!0}static getAttesters(e){var r,n;return((n=(r=e.attestation)===null||r===void 0?void 0:r.signatures)!==null&&n!==void 0?n:[]).map(s=>Vr.getSignerDid(s))}static fetchNewestRecordsWrite(e,r,n){return ai(this,void 0,void 0,function*(){let i={interface:Te.Records,method:Se.Write,recordId:n},{messages:o}=yield e.query(r,[i]),s=yield _e.getNewestMessage(o);if(s!==void 0)return s;throw new de(oe.RecordsWriteGetNewestWriteRecordNotFound,"record not found")})}static fetchInitialRecordsWrite(e,r,n){return ai(this,void 0,void 0,function*(){let i=yield t.fetchInitialRecordsWriteMessage(e,r,n);return i===void 0?void 0:yield t.parse(i)})}static fetchInitialRecordsWriteMessage(e,r,n){return ai(this,void 0,void 0,function*(){let i={entryId:n},{messages:o}=yield e.query(r,[i]);if(o.length!==0)return o[0]})}};var Lqe=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})};function Mi(t,e){return Lqe(this,void 0,void 0,function*(){if(t===void 0)throw new de(oe.AuthenticateJwsMissing,"Missing JWS.");if(yield W0.verifySignatures(t.signature,e),t.ownerSignature!==void 0&&(yield W0.verifySignatures(t.ownerSignature,e)),t.authorDelegatedGrant!==void 0){let r=yield Or.parse(t.authorDelegatedGrant);yield W0.verifySignatures(r.message.authorization.signature,e)}if(t.ownerDelegatedGrant!==void 0){let r=yield Or.parse(t.ownerDelegatedGrant);yield W0.verifySignatures(r.message.authorization.signature,e)}})}f();var Kqe=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},z6=class{isActiveTenant(e){return Kqe(this,void 0,void 0,function*(){return{isActiveTenant:!0}})}};f();f();var Ji=class{get message(){return this._message}get signer(){return this._signer}get author(){return this._author}get signaturePayload(){return this._signaturePayload}get isSignedByAuthorDelegate(){return _e.isSignedByAuthorDelegate(this._message)}constructor(e){this._message=e,e.authorization!==void 0&&(this._signer=_e.getSigner(e),e.authorization.authorDelegatedGrant!==void 0?this._author=_e.getSigner(e.authorization.authorDelegatedGrant):this._author=this._signer,this._signaturePayload=Vr.decodePlainObjectPayload(e.authorization.signature))}toJSON(){return this.message}};var zN=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},oy=class t extends Ji{static parse(e){return zN(this,void 0,void 0,function*(){if(e.descriptor.filter.published===!1&&(e.descriptor.dateSort===uo.PublishedAscending||e.descriptor.dateSort===uo.PublishedDescending))throw new de(oe.RecordsQueryParseFilterPublishedSortInvalid,`queries must not filter for \`published:false\` and sort by ${e.descriptor.dateSort}`);let r;if(e.authorization!==void 0&&(r=yield _e.validateSignatureStructure(e.authorization.signature,e.descriptor)),yield lt.validateDelegatedGrantReferentialIntegrity(e,r),r?.protocolRole!==void 0&&e.descriptor.filter.protocolPath===void 0)throw new de(oe.RecordsQueryFilterMissingRequiredProperties,"Role-authorized queries must include `protocolPath` in the filter");return e.descriptor.filter.protocol!==void 0&&ia(e.descriptor.filter.protocol),e.descriptor.filter.schema!==void 0&&Vm(e.descriptor.filter.schema),pr.validateTimestamp(e.descriptor.messageTimestamp),new t(e)})}static create(e){var r;return zN(this,void 0,void 0,function*(){let n={interface:Te.Records,method:Se.Query,messageTimestamp:(r=e.messageTimestamp)!==null&&r!==void 0?r:pr.getCurrentTimestamp(),filter:lt.normalizeFilter(e.filter),dateSort:e.dateSort,pagination:e.pagination};if(e.filter.published===!1&&(e.dateSort===uo.PublishedAscending||e.dateSort===uo.PublishedDescending))throw new de(oe.RecordsQueryCreateFilterPublishedSortInvalid,`queries must not filter for \`published:false\` and sort by ${e.dateSort}`);Pn(n);let i=e.signer,o;i&&(o=yield _e.createAuthorization({descriptor:n,signer:i,protocolRole:e.protocolRole,delegatedGrant:e.delegatedGrant}));let s={descriptor:n,authorization:o};return _e.validateJsonSchema(s),new t(s)})}authorizeDelegate(e){return zN(this,void 0,void 0,function*(){let r=yield gn.parse(this.message.authorization.authorDelegatedGrant);yield ls.authorizeQueryOrSubscribe({incomingMessage:this.message,expectedGrantee:this.signer,expectedGrantor:this.author,permissionGrant:r,messageStore:e})})}};f();var CP=gt(M1(),1),mle=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Gu=class t{static toBytes(e){return mle(this,void 0,void 0,function*(){return new Promise((r,n)=>{let i=[];e.on("data",o=>{i.push(o)}),e.on("end",()=>{let o=t.concatenateArrayOfBytes(i);r(o)}),e.on("error",n)})})}static toObject(e){return mle(this,void 0,void 0,function*(){let r=yield t.toBytes(e);return qe.bytesToObject(r)})}static concatenateArrayOfBytes(e){let r=e.reduce((o,s)=>o+s.length,0),n=new Uint8Array(r),i=0;for(let o of e)n.set(o,i),i+=o.length;return n}static fromBytes(e){let n=0;return new CP.Readable({read(o){n+1e5>e.length?(this.push(e.subarray(n)),this.push(null)):(this.push(e.subarray(n,n+1e5)),n=n+1e5)}})}static fromObject(e){let r=qe.objectToBytes(e);return t.fromBytes(r)}static duplicateDataStream(e,r){let n=[];for(let i=0;i{e===c&&Zn.matchAnyFilter(p,s)&&n(l)},u=yield this.eventStream.subscribe(e,a,d);return{status:{code:200,detail:"OK"},subscription:u}})}static authorizeMessagesSubscribe(e,r,n){return _le(this,void 0,void 0,function*(){if(r.author!==e)if(r.author!==void 0&&r.signaturePayload.permissionGrantId!==void 0){let i=yield ht.fetchGrant(e,n,r.signaturePayload.permissionGrantId);yield ay.authorizeQueryOrSubscribe({incomingMessage:r.message,expectedGrantor:e,expectedGrantee:r.author,permissionGrant:i,messageStore:n})}else throw new de(oe.MessagesSubscribeAuthorizationFailed,"message failed authorization")})}};f();f();var cpe=gt(qq(),1);f();var ape=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},by=class t{static authorizeConfigure(e){return ape(this,void 0,void 0,function*(){let{protocolsConfigureMessage:r,expectedGrantor:n,expectedGrantee:i,permissionGrant:o,messageStore:s}=e;yield Hc.performBaseValidation({incomingMessage:r,expectedGrantor:n,expectedGrantee:i,permissionGrant:o,messageStore:s}),t.verifyScope(r,o.scope)})}static authorizeQuery(e){var r;return ape(this,void 0,void 0,function*(){let{expectedGrantee:n,expectedGrantor:i,incomingMessage:o,permissionGrant:s,messageStore:a}=e;yield Hc.performBaseValidation({incomingMessage:o,expectedGrantor:i,expectedGrantee:n,permissionGrant:s,messageStore:a});let u=s.scope.protocol,c=(r=o.descriptor.filter)===null||r===void 0?void 0:r.protocol;if(u!==void 0&&c!==u)throw new de(oe.ProtocolsGrantAuthorizationQueryProtocolScopeMismatch,`Grant protocol scope ${u} does not match protocol in message ${c}`)})}static verifyScope(e,r){if(r.protocol!==void 0&&r.protocol!==e.descriptor.definition.protocol)throw new de(oe.ProtocolsGrantAuthorizationScopeProtocolMismatch,"Grant scope specifies different protocol than what appears in the configure message.")}};f();var Yh;(function(t){t.Anyone="anyone",t.Author="author",t.Recipient="recipient"})(Yh||(Yh={}));var zn;(function(t){t.CoDelete="co-delete",t.CoPrune="co-prune",t.CoUpdate="co-update",t.Create="create",t.Delete="delete",t.Prune="prune",t.Query="query",t.Read="read",t.Subscribe="subscribe",t.Update="update"})(zn||(zn={}));var Lq=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},jHe=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i10)throw new de(oe.ProtocolsConfigureRecordNestingDepthExceeded,"Record nesting depth exceeded 10 levels.");for(let i in r){if(i.startsWith("$"))continue;let o=r[i],s;e===""?s=i:s=`${e}/${i}`,o.$role?n.push(s):t.fetchAllRolePathsRecursively(s,o,n)}return n}static validateRuleSetRecursively(e){var r;let{ruleSet:n,ruleSetProtocolPath:i,recordTypes:o,roles:s}=e;if(n.$size!==void 0){let{min:d=0,max:u}=n.$size;if(u!==void 0&&uu.can.includes(l))&&!c.every(l=>u.can.includes(l)))throw new de(oe.ProtocolsConfigureRoleReadActionMissing,`Role in action ${JSON.stringify(u)} for rule set ${i} must contain all read actions (${c.join(", ")}).`)}else throw new de(oe.ProtocolsConfigureRoleDoesNotExistAtGivenPath,`Role in action ${JSON.stringify(u)} for rule set ${i} does not exist.`);if(u.who==="anyone"&&u.of)throw new de(oe.ProtocolsConfigureInvalidActionOfNotAllowed,`'of' is not allowed at rule set protocol path (${i})`);if(u.who===Yh.Recipient&&u.of===void 0&&u.can.some(l=>![zn.CoUpdate,zn.CoDelete,zn.CoPrune].includes(l)))throw new de(oe.ProtocolsConfigureInvalidRecipientOfAction,"Rules for `recipient` without `of` property must have `can` containing only `co-update`, `co-delete`, and `co-prune`.");if(u.who===Yh.Author&&!u.of)throw new de(oe.ProtocolsConfigureInvalidActionMissingOf,"'of' is required when 'author' is specified as 'who'");if(u.can!==void 0){if(u.can.includes(zn.Update)&&!u.can.includes(zn.Create))throw new de(oe.ProtocolsConfigureInvalidActionUpdateWithoutCreate,`Action rule ${JSON.stringify(u)} contains 'update' action but missing the required 'create' action.`);if(u.can.includes(zn.Delete)&&!u.can.includes(zn.Create))throw new de(oe.ProtocolsConfigureInvalidActionDeleteWithoutCreate,`Action rule ${JSON.stringify(u)} contains 'delete' action but missing the required 'create' action.`)}for(let c=d+1;c0)throw new de(oe.ProtocolAuthorizationMissingContextId,"Could not verify role because contextId is missing.");if(l>0){let g=i.split("/").slice(0,l).join("/"),v=Zn.constructPrefixFilterAsRangeFilter(g);c.contextId=v}let{messages:p}=yield s.query(e,[c]);if(p.length===0)throw new de(oe.ProtocolAuthorizationMatchingRoleRecordNotFound,`No matching role record found for protocol path ${d}`)})}static getActionsSeekingARuleMatch(e,r,n){return lc(this,void 0,void 0,function*(){switch(r.message.descriptor.method){case Se.Delete:let i=r,o=i.message.descriptor.recordId,s=yield Or.fetchInitialRecordsWrite(n,e,o);if(s===void 0)return[];let a=[];return i.message.descriptor.prune?(a.push(zn.CoPrune),r.author===s.author&&a.push(zn.Prune)):(a.push(zn.CoDelete),r.author===s.author&&a.push(zn.Delete)),a;case Se.Query:return[zn.Query];case Se.Read:return[zn.Read];case Se.Subscribe:return[zn.Subscribe];case Se.Write:if(yield r.isInitialWrite())return[zn.Create];{let c=r.message.recordId,l=yield Or.fetchInitialRecordsWrite(n,e,c);return l===void 0?[]:r.author===l.author?[zn.CoUpdate,zn.Update]:[zn.CoUpdate]}}return[]})}static authorizeAgainstAllowedActions(e,r,n,i,o){var s;return lc(this,void 0,void 0,function*(){let a=r.message.descriptor.method,d=yield t.getActionsSeekingARuleMatch(e,r,o),u=r.author,c=n.$actions;if(c===void 0)throw new de(oe.ProtocolAuthorizationActionRulesNotFound,`no action rule defined for Records${a}, ${u} is unauthorized`);let l=(s=r.signaturePayload)===null||s===void 0?void 0:s.protocolRole;for(let p of c){if(!p.can.some(v=>d.includes(v)))continue;if(p.who===Yh.Anyone)return;if(u===void 0)continue;if(l!==void 0){if(p.role===l)return;continue}if(p.who===Yh.Recipient&&p.of===void 0){let v;if(r.message.descriptor.method===Se.Write?v=r.message:v=i[i.length-1],v.descriptor.recipient===u)return;continue}if(yield t.checkActor(u,p,i))return}throw new de(oe.ProtocolAuthorizationActionNotAllowed,`Inbound message action Records${a} by author ${r.author} not allowed.`)})}static verifySizeLimit(e,r){let{min:n=0,max:i}=r.$size||{},o=e.message.descriptor.dataSize;if(oi)throw new de(oe.ProtocolAuthorizationMaxSizeInvalid,`data size ${o} is more than allowed ${i}`)}static verifyTagsIfNeeded(e,r){if(r.$tags!==void 0){let{tags:n={},protocol:i,protocolPath:o}=e.message.descriptor,s=r.$tags,{$allowUndefinedTags:a,$requiredTags:d}=s,u=UHe(s,["$allowUndefinedTags","$requiredTags"]),c=a||!1,l=d||[],p=new lpe.default.default,m=p.compile({type:"object",properties:u,required:l,additionalProperties:c});if(!m(n)){let v=p.errorsText(m.errors,{dataVar:`${i}/${o}/$tags`});throw new de(oe.ProtocolAuthorizationTagsInvalidSchema,`tags schema validation error: ${v}`)}}}static verifyAsRoleRecordIfNeeded(e,r,n,i){return lc(this,void 0,void 0,function*(){if(!n.$role)return;let o=r,s=o.message.descriptor.recipient;if(s===void 0)throw new de(oe.ProtocolAuthorizationRoleMissingRecipient,"Role records must have a recipient");let a=o.message.descriptor.protocolPath,d={interface:Te.Records,method:Se.Write,isLatestBaseState:!0,protocol:o.message.descriptor.protocol,protocolPath:a,recipient:s},u=lt.getParentContextFromOfContextId(o.message.contextId);if(u!==""){let m=Zn.constructPrefixFilterAsRangeFilter(u);d.contextId=m}let{messages:c}=yield i.query(e,[d]);if(c.filter(m=>m.recordId!==o.message.recordId).length>0)throw new de(oe.ProtocolAuthorizationDuplicateRoleRecipient,`DID '${s}' is already recipient of a role record at protocol path '${a} under the parent context ${u}.`)})}static getRuleSetAtProtocolPath(e,r){let n=e.split("/"),i=r.structure,o=0;for(;oo.descriptor.protocolPath===r.of);if(i===void 0)return!1;if(r.who===Yh.Recipient)return e===i.descriptor.recipient;{let o=(yield Or.parse(i)).author;return e===o}})}static getTypeName(e){return e.split("/").slice(-1)[0]}};f();var Fq=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},vf=class t extends Ji{static parse(e){return Fq(this,void 0,void 0,function*(){let r;return e.authorization!==void 0&&(r=yield _e.validateSignatureStructure(e.authorization.signature,e.descriptor)),yield lt.validateDelegatedGrantReferentialIntegrity(e,r),pr.validateTimestamp(e.descriptor.messageTimestamp),new t(e)})}static create(e){var r,n;return Fq(this,void 0,void 0,function*(){let i=e.recordId,o=pr.getCurrentTimestamp(),s={interface:Te.Records,method:Se.Delete,messageTimestamp:(r=e.messageTimestamp)!==null&&r!==void 0?r:o,recordId:i,prune:(n=e.prune)!==null&&n!==void 0?n:!1},a=yield _e.createAuthorization({descriptor:s,signer:e.signer,protocolRole:e.protocolRole,delegatedGrant:e.delegatedGrant}),d={descriptor:s,authorization:a};return _e.validateJsonSchema(d),new t(d)})}constructIndexes(e){let r=this.message,n=Object.assign({},r.descriptor),{protocol:i,protocolPath:o,recipient:s,schema:a,parentId:d,dateCreated:u}=e.descriptor,c=Object.assign({isLatestBaseState:!0,protocol:i,protocolPath:o,recipient:s,schema:a,parentId:d,dateCreated:u,contextId:e.contextId,author:this.author},n);return Pn(c),c}authorizeDelegate(e,r){return Fq(this,void 0,void 0,function*(){let n=yield gn.parse(this.message.authorization.authorDelegatedGrant);yield ls.authorizeDelete({recordsDeleteMessage:this.message,recordsWriteToDelete:e,expectedGrantor:this.author,expectedGrantee:this.signer,permissionGrant:n,messageStore:r})})}};f();var g2=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},ES;(function(t){t.RecordsDelete="RecordsDelete"})(ES||(ES={}));var SS=class t{constructor(e,r){this.resumableTaskStore=e,this.resumableTaskBatchSize=100,this.resumableTaskHandlers={[ES.RecordsDelete]:n=>g2(this,void 0,void 0,function*(){return yield r.performRecordsDelete(n)})}}run(e){return g2(this,void 0,void 0,function*(){let r=t.timeoutExtensionFrequencyInSeconds*2,n=yield this.resumableTaskStore.register(e,r);yield this.runWithAutomaticTimeoutExtension(n)})}runWithAutomaticTimeoutExtension(e){return g2(this,void 0,void 0,function*(){let r=t.timeoutExtensionFrequencyInSeconds*2,n;try{n=setInterval(()=>{this.resumableTaskStore.extend(e.id,r)},t.timeoutExtensionFrequencyInSeconds*1e3);let i=this.resumableTaskHandlers[e.task.name];yield i(e.task.data),yield this.resumableTaskStore.delete(e.id)}finally{t.clearTimeoutExtensionTimer(n)}})}static clearTimeoutExtensionTimer(e){clearInterval(e)}resumeTasksAndWaitForCompletion(){return g2(this,void 0,void 0,function*(){for(;;){let e=yield this.resumableTaskStore.grab(this.resumableTaskBatchSize);if(e===void 0||e.length===0)break;yield this.retryTasksUntilCompletion(e)}})}retryTasksUntilCompletion(e){return g2(this,void 0,void 0,function*(){let r=e;for(;r.length>0;){let n=r;r=[];let i=n.map(o=>g2(this,void 0,void 0,function*(){try{yield this.runWithAutomaticTimeoutExtension(o)}catch(s){console.error("Error while running resumable task:",s),console.error("Resumable task:",e),r.push(o)}}));yield Promise.all(i)}})}};SS.timeoutExtensionFrequencyInSeconds=30;var fpe=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},bI=class t{constructor(e,r,n){this.didResolver=e,this.messageStore=r,this.resumableTaskManager=n}handle({tenant:e,message:r}){return fpe(this,void 0,void 0,function*(){let n;try{n=yield vf.parse(r)}catch(u){return mr(u,400)}try{yield Mi(r.authorization,this.didResolver)}catch(u){return mr(u,401)}let i={interface:Te.Records,recordId:r.descriptor.recordId},{messages:o}=yield this.messageStore.query(e,[i]),s=yield _e.getNewestMessage(o);if(!lt.canPerformDeleteAgainstRecord(r,s))return{status:{code:404,detail:"Not Found"}};if(!(yield _e.isNewer(r,s)))return{status:{code:409,detail:"Conflict"}};try{let u=yield Or.fetchInitialRecordsWrite(this.messageStore,e,r.descriptor.recordId);yield t.authorizeRecordsDelete(e,n,u,this.messageStore)}catch(u){return mr(u,401)}return yield this.resumableTaskManager.run({name:ES.RecordsDelete,data:{tenant:e,message:r}}),{status:{code:202,detail:"Accepted"}}})}static authorizeRecordsDelete(e,r,n,i){return fpe(this,void 0,void 0,function*(){if(_e.isSignedByAuthorDelegate(r.message)&&(yield r.authorizeDelegate(n.message,i)),r.author!==e)if(n.message.descriptor.protocol!==void 0)yield Xc.authorizeDelete(e,r,n,i);else throw new de(oe.RecordsDeleteAuthorizationFailed,"RecordsDelete message failed authorization")})}};f();f();var Ts;(function(t){t[t.Descending=-1]="Descending",t[t.Ascending=1]="Ascending"})(Ts||(Ts={}));var AS=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},wI=class t{constructor(e,r,n){this.didResolver=e,this.messageStore=r,this.dataStore=n}handle({tenant:e,message:r}){return AS(this,void 0,void 0,function*(){let n;try{n=yield oy.parse(r)}catch(s){return mr(s,400)}let i,o;if(lt.filterIncludesPublishedRecords(n.message.descriptor.filter)&&n.author===void 0){let s=yield this.fetchPublishedRecords(e,n);i=s.messages,o=s.cursor}else{try{yield Mi(r.authorization,this.didResolver),yield t.authorizeRecordsQuery(e,n,this.messageStore)}catch(s){return mr(s,401)}if(n.author===e){let s=yield this.fetchRecordsAsOwner(e,n);i=s.messages,o=s.cursor}else{let s=yield this.fetchRecordsAsNonOwner(e,n);i=s.messages,o=s.cursor}}for(let s of i)if(!(yield Or.isInitialWrite(s))){let d=(yield this.messageStore.query(e,[{recordId:s.recordId,isLatestBaseState:!1,method:Se.Write}])).messages[0];delete d.encodedData,s.initialWrite=d}return{status:{code:200,detail:"OK"},entries:i,cursor:o}})}convertDateSort(e){switch(e){case uo.CreatedAscending:return{dateCreated:Ts.Ascending};case uo.CreatedDescending:return{dateCreated:Ts.Descending};case uo.PublishedAscending:return{datePublished:Ts.Ascending};case uo.PublishedDescending:return{datePublished:Ts.Descending};default:return{dateCreated:Ts.Ascending}}}fetchRecordsAsOwner(e,r){return AS(this,void 0,void 0,function*(){let{dateSort:n,filter:i,pagination:o}=r.message.descriptor,s=Object.assign(Object.assign({},lt.convertFilter(i,n)),{interface:Te.Records,method:Se.Write,isLatestBaseState:!0}),a=this.convertDateSort(n);return this.messageStore.query(e,[s],a,o)})}fetchRecordsAsNonOwner(e,r){return AS(this,void 0,void 0,function*(){let{dateSort:n,pagination:i,filter:o}=r.message.descriptor,s=[];lt.filterIncludesPublishedRecords(o)&&s.push(t.buildPublishedRecordsFilter(r)),lt.filterIncludesUnpublishedRecords(o)&&(lt.shouldBuildUnpublishedAuthorFilter(o,r.author)&&s.push(t.buildUnpublishedRecordsByQueryAuthorFilter(r)),lt.shouldProtocolAuthorize(r.signaturePayload)&&s.push(t.buildUnpublishedProtocolAuthorizedRecordsFilter(r)),lt.shouldBuildUnpublishedRecipientFilter(o,r.author)&&s.push(t.buildUnpublishedRecordsForQueryAuthorFilter(r)));let a=this.convertDateSort(n);return this.messageStore.query(e,s,a,i)})}fetchPublishedRecords(e,r){return AS(this,void 0,void 0,function*(){let{dateSort:n,pagination:i}=r.message.descriptor,o=t.buildPublishedRecordsFilter(r),s=this.convertDateSort(n);return this.messageStore.query(e,[o],s,i)})}static buildPublishedRecordsFilter(e){let{dateSort:r,filter:n}=e.message.descriptor;return Object.assign(Object.assign({},lt.convertFilter(n,r)),{interface:Te.Records,method:Se.Write,published:!0,isLatestBaseState:!0})}static buildUnpublishedRecordsForQueryAuthorFilter(e){let{dateSort:r,filter:n}=e.message.descriptor;return Object.assign(Object.assign({},lt.convertFilter(n,r)),{interface:Te.Records,method:Se.Write,recipient:e.author,isLatestBaseState:!0,published:!1})}static buildUnpublishedProtocolAuthorizedRecordsFilter(e){let{dateSort:r,filter:n}=e.message.descriptor;return Object.assign(Object.assign({},lt.convertFilter(n,r)),{interface:Te.Records,method:Se.Write,isLatestBaseState:!0,published:!1})}static buildUnpublishedRecordsByQueryAuthorFilter(e){let{dateSort:r,filter:n}=e.message.descriptor;return Object.assign(Object.assign({},lt.convertFilter(n,r)),{author:e.author,interface:Te.Records,method:Se.Write,isLatestBaseState:!0,published:!1})}static authorizeRecordsQuery(e,r,n){return AS(this,void 0,void 0,function*(){_e.isSignedByAuthorDelegate(r.message)&&(yield r.authorizeDelegate(n)),lt.shouldProtocolAuthorize(r.signaturePayload)&&(yield Xc.authorizeQueryOrSubscribe(e,r,n))})}};f();f();var zq=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Sv=class t extends Ji{static parse(e){return zq(this,void 0,void 0,function*(){let r;return e.authorization!==void 0&&(r=yield _e.validateSignatureStructure(e.authorization.signature,e.descriptor)),yield lt.validateDelegatedGrantReferentialIntegrity(e,r),pr.validateTimestamp(e.descriptor.messageTimestamp),new t(e)})}static create(e){var r;return zq(this,void 0,void 0,function*(){let{filter:n,signer:i,permissionGrantId:o,protocolRole:s}=e,a=pr.getCurrentTimestamp(),d={interface:Te.Records,method:Se.Read,filter:lt.normalizeFilter(n),messageTimestamp:(r=e.messageTimestamp)!==null&&r!==void 0?r:a};Pn(d);let u;i!==void 0&&(u=yield _e.createAuthorization({descriptor:d,signer:i,permissionGrantId:o,protocolRole:s,delegatedGrant:e.delegatedGrant}));let c={descriptor:d,authorization:u};return _e.validateJsonSchema(c),new t(c)})}authorizeDelegate(e,r){return zq(this,void 0,void 0,function*(){let n=yield gn.parse(this.message.authorization.authorDelegatedGrant);yield ls.authorizeRead({recordsReadMessage:this.message,recordsWriteMessageToBeRead:e,expectedGrantor:this.author,expectedGrantee:this.signer,permissionGrant:n,messageStore:r})})}};var hpe=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},_I=class t{constructor(e,r,n){this.didResolver=e,this.messageStore=r,this.dataStore=n}handle({tenant:e,message:r}){return hpe(this,void 0,void 0,function*(){let n;try{n=yield Sv.parse(r)}catch(c){return mr(c,400)}try{n.author!==void 0&&(yield Mi(r.authorization,this.didResolver))}catch(c){return mr(c,401)}let i=Object.assign({interface:Te.Records,isLatestBaseState:!0},lt.convertFilter(r.descriptor.filter)),{messages:o}=yield this.messageStore.query(e,[i]);if(o.length===0)return{status:{code:404,detail:"Not Found"}};if(o.length>1)return mr(new de(oe.RecordsReadReturnedMultiple,"Multiple records exist for the RecordsRead filter"),400);let s=o[0];if(s.descriptor.method===Se.Delete){let c=s,l=yield Or.fetchInitialRecordsWriteMessage(this.messageStore,e,c.descriptor.recordId);return{status:{code:404,detail:"Not Found"},entry:{recordsDelete:c,initialWrite:l}}}let a=s;try{yield t.authorizeRecordsRead(e,n,yield Or.parse(a),this.messageStore)}catch(c){return mr(c,401)}let d;if(a.encodedData!==void 0){let c=qe.base64UrlToBytes(a.encodedData);d=Gu.fromBytes(c),delete a.encodedData}else{let c=yield this.dataStore.get(e,a.recordId,a.descriptor.dataCid);if(c?.dataStream===void 0)return{status:{code:404,detail:"Not Found"}};d=c.dataStream}let u={status:{code:200,detail:"OK"},entry:{recordsWrite:a,data:d}};if(!(yield Or.isInitialWrite(a))){let l=(yield this.messageStore.query(e,[{recordId:a.recordId,isLatestBaseState:!1,method:Se.Write}])).messages[0];delete l.encodedData,u.entry.initialWrite=l}return u})}static authorizeRecordsRead(e,r,n,i){return hpe(this,void 0,void 0,function*(){_e.isSignedByAuthorDelegate(r.message)&&(yield r.authorizeDelegate(n.message,i));let{descriptor:o}=n.message;if(r.author!==e){if(o.published===!0)return;if(r.author!==void 0&&(r.author===o.recipient||r.author===n.author))return;if(r.author!==void 0&&r.signaturePayload.permissionGrantId!==void 0){let s=yield ht.fetchGrant(e,i,r.signaturePayload.permissionGrantId);yield ls.authorizeRead({recordsReadMessage:r.message,recordsWriteMessageToBeRead:n.message,expectedGrantor:e,expectedGrantee:r.author,permissionGrant:s,messageStore:i})}else if(o.protocol!==void 0)yield Xc.authorizeRead(e,r,n,i);else throw new de(oe.RecordsReadAuthorizationFailed,"message failed authorization")}})}};f();f();var Wq=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},xy=class t extends Ji{static parse(e){return Wq(this,void 0,void 0,function*(){let r;if(e.authorization!==void 0&&(r=yield _e.validateSignatureStructure(e.authorization.signature,e.descriptor)),yield lt.validateDelegatedGrantReferentialIntegrity(e,r),r?.protocolRole!==void 0&&e.descriptor.filter.protocolPath===void 0)throw new de(oe.RecordsSubscribeFilterMissingRequiredProperties,"Role-authorized subscriptions must include `protocolPath` in the filter");return e.descriptor.filter.protocol!==void 0&&ia(e.descriptor.filter.protocol),e.descriptor.filter.schema!==void 0&&Vm(e.descriptor.filter.schema),pr.validateTimestamp(e.descriptor.messageTimestamp),new t(e)})}static create(e){var r;return Wq(this,void 0,void 0,function*(){let n={interface:Te.Records,method:Se.Subscribe,messageTimestamp:(r=e.messageTimestamp)!==null&&r!==void 0?r:pr.getCurrentTimestamp(),filter:lt.normalizeFilter(e.filter)};Pn(n);let i=e.signer,o;i&&(o=yield _e.createAuthorization({descriptor:n,signer:i,protocolRole:e.protocolRole,delegatedGrant:e.delegatedGrant}));let s={descriptor:n,authorization:o};return _e.validateJsonSchema(s),new t(s)})}authorizeDelegate(e){return Wq(this,void 0,void 0,function*(){let r=yield gn.parse(this.message.authorization.authorDelegatedGrant);yield ls.authorizeQueryOrSubscribe({incomingMessage:this.message,expectedGrantor:this.author,expectedGrantee:this.signer,permissionGrant:r,messageStore:e})})}};var xI=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},EI=class t{constructor(e,r,n){this.didResolver=e,this.messageStore=r,this.eventStream=n}handle({tenant:e,message:r,subscriptionHandler:n}){return xI(this,void 0,void 0,function*(){if(this.eventStream===void 0)return mr(new de(oe.RecordsSubscribeEventStreamUnimplemented,"Subscriptions are not supported"),501);let i;try{i=yield xy.parse(r)}catch(u){return mr(u,400)}let o=[];if(lt.filterIncludesPublishedRecords(i.message.descriptor.filter)&&i.author===void 0)o=[t.buildPublishedRecordsFilter(i)],delete r.authorization;else{try{yield Mi(r.authorization,this.didResolver),yield t.authorizeRecordsSubscribe(e,i,this.messageStore)}catch(u){return mr(u,401)}i.author===e?o=yield t.filterAsOwner(i):o=yield t.filterAsNonOwner(i)}let s=(u,c,l)=>{e===u&&Zn.matchAnyFilter(l,o)&&n(c)},a=yield _e.getCid(r),d=yield this.eventStream.subscribe(e,a,s);return{status:{code:200,detail:"OK"},subscription:d}})}static filterAsOwner(e){return xI(this,void 0,void 0,function*(){let{filter:r}=e.message.descriptor;return[Object.assign(Object.assign({},lt.convertFilter(r)),{interface:Te.Records,method:[Se.Write,Se.Delete]})]})}static filterAsNonOwner(e){return xI(this,void 0,void 0,function*(){let r=[],{filter:n}=e.message.descriptor;return lt.filterIncludesPublishedRecords(n)&&r.push(t.buildPublishedRecordsFilter(e)),lt.filterIncludesUnpublishedRecords(n)&&(lt.shouldBuildUnpublishedAuthorFilter(n,e.author)&&r.push(t.buildUnpublishedRecordsBySubscribeAuthorFilter(e)),lt.shouldProtocolAuthorize(e.signaturePayload)&&r.push(t.buildUnpublishedProtocolAuthorizedRecordsFilter(e)),lt.shouldBuildUnpublishedRecipientFilter(n,e.author)&&r.push(t.buildUnpublishedRecordsForSubscribeAuthorFilter(e))),r})}static buildPublishedRecordsFilter(e){return Object.assign(Object.assign({},lt.convertFilter(e.message.descriptor.filter)),{interface:Te.Records,method:[Se.Write,Se.Delete],published:!0})}static buildUnpublishedRecordsForSubscribeAuthorFilter(e){return Object.assign(Object.assign({},lt.convertFilter(e.message.descriptor.filter)),{interface:Te.Records,method:[Se.Write,Se.Delete],recipient:e.author,published:!1})}static buildUnpublishedProtocolAuthorizedRecordsFilter(e){return Object.assign(Object.assign({},lt.convertFilter(e.message.descriptor.filter)),{interface:Te.Records,method:[Se.Write,Se.Delete],published:!1})}static buildUnpublishedRecordsBySubscribeAuthorFilter(e){return Object.assign(Object.assign({},lt.convertFilter(e.message.descriptor.filter)),{author:e.author,interface:Te.Records,method:[Se.Write,Se.Delete],published:!1})}static authorizeRecordsSubscribe(e,r,n){return xI(this,void 0,void 0,function*(){_e.isSignedByAuthorDelegate(r.message)&&(yield r.authorizeDelegate(n)),lt.shouldProtocolAuthorize(r.signaturePayload)&&(yield Xc.authorizeQueryOrSubscribe(e,r,n))})}};f();f();var bf=class{};bf.maxDataSizeAllowedToBeEncoded=3e4;f();var TS=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},v2=class t{constructor({messageStore:e,dataStore:r,eventLog:n,eventStream:i}){this.messageStore=e,this.dataStore=r,this.eventLog=n,this.eventStream=i}performRecordsDelete({tenant:e,message:r}){return TS(this,void 0,void 0,function*(){let n={interface:Te.Records,recordId:r.descriptor.recordId},{messages:i}=yield this.messageStore.query(e,[n]),o=yield _e.getNewestMessage(i);if(!lt.canPerformDeleteAgainstRecord(r,o))return;let s=yield vf.parse(r),a=yield Or.getInitialWrite(i),d=s.constructIndexes(a),u=yield _e.getCid(r);yield this.messageStore.put(e,r,d),yield this.eventLog.append(e,u,d),this.eventStream!==void 0&&this.eventStream.emit(e,{message:r,initialWrite:a},d),r.descriptor.prune&&(yield t.purgeRecordDescendants(e,r.descriptor.recordId,this.messageStore,this.dataStore,this.eventLog)),yield t.deleteAllOlderMessagesButKeepInitialWrite(e,i,r,this.messageStore,this.dataStore,this.eventLog)})}static deleteFromDataStoreIfNeeded(e,r,n,i){return TS(this,void 0,void 0,function*(){if(n.descriptor.method!==Se.Write)return;let o=n;o.descriptor.dataSize<=bf.maxDataSizeAllowedToBeEncoded||o.descriptor.dataCid!==i.descriptor.dataCid&&(yield e.delete(r,o.recordId,o.descriptor.dataCid))})}static purgeRecordDescendants(e,r,n,i,o){return TS(this,void 0,void 0,function*(){let s={interface:Te.Records,parentId:r},{messages:a}=yield n.query(e,[s]),d=new Map;for(let u of a){let c;lt.isRecordsWrite(u)?c=u.recordId:c=u.descriptor.recordId,d.has(c)||d.set(c,[]),d.get(c).push(u)}for(let u of d.keys())yield t.purgeRecordDescendants(e,u,n,i,o);for(let u of d.keys())yield t.purgeRecordMessages(e,d.get(u),n,i,o)})}static purgeRecordMessages(e,r,n,i,o){return TS(this,void 0,void 0,function*(){let s=r.filter(u=>u.descriptor.method===Se.Write),a=yield _e.getNewestMessage(s);yield i.delete(e,a.recordId,a.descriptor.dataCid);let d=yield Promise.all(r.map(u=>_e.getCid(u)));yield o.deleteEventsByCid(e,d),yield Promise.all(d.map(u=>n.delete(e,u)))})}static deleteAllOlderMessagesButKeepInitialWrite(e,r,n,i,o,s){return TS(this,void 0,void 0,function*(){let a=[];for(let d of r){if(yield _e.isOlder(d,n)){yield t.deleteFromDataStoreIfNeeded(o,e,d,n);let c=yield _e.getCid(d);if(yield i.delete(e,c),yield Or.isInitialWrite(d)){let p=yield Or.parse(d),m=!1,g=yield p.constructIndexes(m),v=d;delete v.encodedData,yield i.put(e,v,g)}else{let p=yield _e.getCid(d);a.push(p)}}yield s.deleteEventsByCid(e,a)}})}};var Av=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},SI=class t{constructor(e,r,n,i,o){this.didResolver=e,this.messageStore=r,this.dataStore=n,this.eventLog=i,this.eventStream=o}handle({tenant:e,message:r,dataStream:n}){return Av(this,void 0,void 0,function*(){let i;try{i=yield Or.parse(r),r.descriptor.protocol!==void 0&&(yield Xc.validateReferentialIntegrity(e,i,this.messageStore))}catch(m){return mr(m,400)}try{yield Mi(r.authorization,this.didResolver),yield t.authorizeRecordsWrite(e,i,this.messageStore)}catch(m){return mr(m,401)}let o={interface:Te.Records,recordId:r.recordId},{messages:s}=yield this.messageStore.query(e,[o]),a=yield i.isInitialWrite(),d;if(!a)try{d=yield Or.getInitialWrite(s),Or.verifyEqualityOfImmutableProperties(d,r)}catch(m){return mr(m,400)}let u=yield _e.getNewestMessage(s),c=!1,l;if(u===void 0||(yield _e.isNewer(r,u))?(c=!0,l=r):l=u,!c)return{status:{code:409,detail:"Conflict"}};try{if(u?.descriptor.method===Se.Delete)throw new de(oe.RecordsWriteNotAllowedAfterDelete,"RecordsWrite is not allowed after a RecordsDelete.");yield this.preProcessingForCoreRecordsWrite(e,r);let m=!1,g=r;if(n!==void 0)g=yield this.processMessageWithDataStream(e,r,n),m=!0;else if(!a){let x=u;g=yield this.processMessageWithoutDataStream(e,r,x),m=!0}let v=yield i.constructIndexes(m);yield this.messageStore.put(e,g,v),yield this.eventLog.append(e,yield _e.getCid(r),v),this.eventStream!==void 0&&m&&this.eventStream.emit(e,{message:r,initialWrite:d},v)}catch(m){let g=m;if(g.code!==void 0&&(g.code===oe.RecordsWriteMissingEncodedDataInPrevious||g.code===oe.RecordsWriteMissingDataInPrevious||g.code===oe.RecordsWriteNotAllowedAfterDelete||g.code===oe.RecordsWriteDataCidMismatch||g.code===oe.RecordsWriteDataSizeMismatch||g.code.startsWith("PermissionsProtocolValidate")||g.code.startsWith("SchemaValidator")))return mr(m,400);throw m}let p={status:a&&n===void 0?{code:204,detail:"No Content"}:{code:202,detail:"Accepted"}};return yield v2.deleteAllOlderMessagesButKeepInitialWrite(e,s,l,this.messageStore,this.dataStore,this.eventLog),yield this.postProcessingForCoreRecordsWrite(e,i),p})}preProcessingForCoreRecordsWrite(e,r){var n;return Av(this,void 0,void 0,function*(){if(r.descriptor.protocol===ht.uri&&r.descriptor.protocolPath===ht.revocationPath){let i=r.descriptor.parentId,o=yield ht.fetchGrant(e,this.messageStore,i),s=(n=r.descriptor.tags)===null||n===void 0?void 0:n.protocol,a="protocol"in o.scope?o.scope.protocol:void 0;if(a!==s)throw new de(oe.PermissionsProtocolValidateRevocationProtocolTagMismatch,`Revocation protocol ${s} does not match grant protocol ${a}`)}})}static validateSchemaForCoreRecordsWrite(e,r){e.descriptor.protocol===ht.uri&&ht.validateSchema(e,r)}postProcessingForCoreRecordsWrite(e,r){return Av(this,void 0,void 0,function*(){if(r.message.descriptor.protocol===ht.uri&&r.message.descriptor.protocolPath===ht.revocationPath){let i={permissionGrantId:r.message.descriptor.parentId,dateCreated:{gte:r.message.descriptor.messageTimestamp}},{messages:o}=yield this.messageStore.query(e,[i]),s=[];for(let a of o){let d=yield _e.getCid(a);yield this.messageStore.delete(e,d)}this.eventLog.deleteEventsByCid(e,s)}})}cloneAndAddEncodedData(e,r){return Av(this,void 0,void 0,function*(){let n=Object.assign({},e);return n.encodedData=qe.bytesToBase64Url(r),n})}processMessageWithDataStream(e,r,n){return Av(this,void 0,void 0,function*(){let i=r;if(r.descriptor.dataSize<=bf.maxDataSizeAllowedToBeEncoded){let o=yield Gu.toBytes(n),s=yield hn.computeDagPbCidFromBytes(o);t.validateDataIntegrity(r.descriptor.dataCid,r.descriptor.dataSize,s,o.length),t.validateSchemaForCoreRecordsWrite(r,o),i=yield this.cloneAndAddEncodedData(r,o)}else{let[o,s]=Gu.duplicateDataStream(n,2);try{let[a,d]=yield Promise.all([hn.computeDagPbCidFromStream(o),this.dataStore.put(e,r.recordId,r.descriptor.dataCid,s)]);t.validateDataIntegrity(r.descriptor.dataCid,r.descriptor.dataSize,a,d.dataSize)}catch(a){throw yield this.dataStore.delete(e,r.recordId,r.descriptor.dataCid),a}}return i})}processMessageWithoutDataStream(e,r,n){return Av(this,void 0,void 0,function*(){let i=Object.assign({},r),{dataCid:o,dataSize:s}=r.descriptor;if(t.validateDataIntegrity(o,s,n.descriptor.dataCid,n.descriptor.dataSize),s<=bf.maxDataSizeAllowedToBeEncoded)if(n.encodedData!==void 0)i.encodedData=n.encodedData;else throw new de(oe.RecordsWriteMissingEncodedDataInPrevious,"No dataStream was provided and unable to get data from previous message");else if((yield this.dataStore.get(e,n.recordId,r.descriptor.dataCid))===void 0)throw new de(oe.RecordsWriteMissingDataInPrevious,"No dataStream was provided and unable to get data from previous message");return i})}static validateDataIntegrity(e,r,n,i){if(e!==n)throw new de(oe.RecordsWriteDataCidMismatch,`actual data CID ${n} does not match dataCid in descriptor: ${e}`);if(r!==i)throw new de(oe.RecordsWriteDataSizeMismatch,`actual data size ${i} bytes does not match dataSize in descriptor: ${r}`)}static authorizeRecordsWrite(e,r,n){return Av(this,void 0,void 0,function*(){if(r.owner!==void 0&&r.owner!==e)throw new de(oe.RecordsWriteOwnerAndTenantMismatch,`Owner ${r.owner} must be the same as tenant ${e} when specified.`);if(r.isSignedByAuthorDelegate&&(yield r.authorizeAuthorDelegate(n)),r.isSignedByOwnerDelegate&&(yield r.authorizeOwnerDelegate(n)),r.owner===void 0){if(r.author===e)return;if(r.author!==void 0&&r.signaturePayload.permissionGrantId!==void 0){let i=yield ht.fetchGrant(e,n,r.signaturePayload.permissionGrantId);yield ls.authorizeWrite({recordsWriteMessage:r.message,expectedGrantor:e,expectedGrantee:r.author,permissionGrant:i,messageStore:n})}else if(r.message.descriptor.protocol!==void 0)yield Xc.authorizeWrite(e,r,n);else throw new de(oe.RecordsWriteAuthorizationFailed,"message failed authorization")}})}};f();f();var Tv;(function(t){t.authentication="authentication",t.assertionMethod="assertionMethod",t.keyAgreement="keyAgreement",t.capabilityInvocation="capabilityInvocation",t.capabilityDelegation="capabilityDelegation"})(Tv||(Tv={}));f();var di={"@context":"https://w3id.org/did-resolution/v1",didResolutionMetadata:{},didDocument:null,didDocumentMetadata:{}};f();var _r=class t{constructor({method:e,id:r,path:n,query:i,fragment:o,params:s}){this.uri=`did:${e}:${r}`,this.method=e,this.id=r,this.path=n,this.query=i,this.fragment=o,this.params=s}static parse(e){if(!e)return null;let r=t.DID_URI_PATTERN.exec(e);if(!r||!r.groups)return null;let{method:n,id:i,path:o,query:s,fragment:a}=r.groups,d={uri:`did:${n}:${i}`,method:n,id:i};if(o&&(d.path=o),s&&(d.query=s.slice(1)),a&&(d.fragment=a.slice(1)),s){let u={},c=s.slice(1).split("&");for(let l of c){let[p,m]=l.split("=");u[p]=m}d.params=u}return d}};_r.METHOD_PATTERN="([a-z0-9]+)";_r.PCT_ENCODED_PATTERN="(?:%[0-9a-fA-F]{2})";_r.ID_CHAR_PATTERN=`(?:[a-zA-Z0-9._-]|${_r.PCT_ENCODED_PATTERN})`;_r.METHOD_ID_PATTERN=`((?:${_r.ID_CHAR_PATTERN}*:)*(${_r.ID_CHAR_PATTERN}+))`;_r.PATH_PATTERN="(/[^#?]*)?";_r.QUERY_PATTERN="([?][^#]*)?";_r.FRAGMENT_PATTERN="(#.*)?";_r.DID_URI_PATTERN=new RegExp(`^did:(?${_r.METHOD_PATTERN}):(?${_r.METHOD_ID_PATTERN})(?${_r.PATH_PATTERN})(?${_r.QUERY_PATTERN})(?${_r.FRAGMENT_PATTERN})$`);f();var at=class t 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,t)}},tt;(function(t){t.InvalidDid="invalidDid",t.MethodNotSupported="methodNotSupported",t.InternalError="internalError",t.InvalidDidDocument="invalidDidDocument",t.InvalidDidDocumentLength="invalidDidDocumentLength",t.InvalidDidUrl="invalidDidUrl",t.InvalidPreviousDidProof="invalidPreviousDidProof",t.InvalidPublicKey="invalidPublicKey",t.InvalidPublicKeyLength="invalidPublicKeyLength",t.InvalidPublicKeyType="invalidPublicKeyType",t.InvalidSignature="invalidSignature",t.NotFound="notFound",t.RepresentationNotSupported="representationNotSupported",t.UnsupportedPublicKeyType="unsupportedPublicKeyType"})(tt||(tt={}));f();f();f();f();f();var KHe=gt(TI(),1);f();f();function mpe(t){return t.byteOffset!==0||t.byteLength!==t.buffer.byteLength}function ype(t){return typeof t!="object"||t===null?!1:typeof t[Symbol.asyncIterator]=="function"}function PI(t){let r=Object.prototype.toString.call(t).match(/\s([a-zA-Z0-9]+)/),[n,i]=r;return i}var PS=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},gpe=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,d){s=t[o](s),i(a,d,s.done,s.value)})}}function i(o,s,a,d){Promise.resolve(d).then(function(u){o({value:u,done:a})},s)}},II=new TextEncoder,Pv=new TextDecoder,xt=class t{constructor(e,r){this.data=e,this.format=r}static arrayBuffer(e){return new t(e,"ArrayBuffer")}static asyncIterable(e){if(!ype(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 Fi.baseDecode(this.data).buffer;case"Base64Url":return Pi.baseDecode(this.data).buffer;case"BufferSource":{if(PI(this.data)==="ArrayBuffer")return this.data;if(ArrayBuffer.isView(this.data))return mpe(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 PS(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 O0.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 Fi.baseEncode(e)}case"Multibase":return this.data.substring(1);case"Uint8Array":return Fi.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 Pi.baseEncode(e)}case"BufferSource":{let e=this.toUint8Array();return Pi.baseEncode(e)}case"Object":{let e=JSON.stringify(this.data),r=II.encode(e);return Pi.baseEncode(r)}case"String":{let e=II.encode(this.data);return Pi.baseEncode(e)}case"Uint8Array":return Pi.baseEncode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Base64Url is not supported.`)}}toBlobAsync(){return PS(this,void 0,void 0,function*(){var e,r,n,i;switch(this.format){case"AsyncIterable":{let d=[];try{for(var o=!0,s=gpe(this.data),a;a=yield s.next(),e=a.done,!e;o=!0){i=a.value,o=!1;let c=i;d.push(c)}}catch(c){r={error:c}}finally{try{!o&&!e&&(n=s.return)&&(yield n.call(s))}finally{if(r)throw r.error}}return new Blob(d)}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{t[e]===void 0?delete t[e]:typeof t[e]=="object"&&Gq(t[e])})}f();var KVe=gt(GS(),1),Kv=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})};var ek=class{constructor(){this.store=new Map}clear(){return Kv(this,void 0,void 0,function*(){this.store.clear()})}close(){return Kv(this,void 0,void 0,function*(){})}delete(e){return Kv(this,void 0,void 0,function*(){return this.store.delete(e)})}get(e){return Kv(this,void 0,void 0,function*(){return this.store.get(e)})}has(e){return Kv(this,void 0,void 0,function*(){return this.store.has(e)})}list(){return Kv(this,void 0,void 0,function*(){return Array.from(this.store.values())})}set(e,r){return Kv(this,void 0,void 0,function*(){this.store.set(e,r)})}};f();f();var EXe=gt(i3(),1);var SXe=gt(i3(),1);f();f();var AXe=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},j2=class{static digest(e){return AXe(this,arguments,void 0,function*({data:r}){return So(r)})}};f();var Rf=class{};var TXe=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Ik=class extends Rf{digest(e){return TXe(this,arguments,void 0,function*({algorithm:r,data:n}){switch(r){case"SHA-256":return yield j2.digest({data:n})}})}};f();f();f();f();f();f();function Oy(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function PXe(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function dp(t,...e){if(!PXe(t))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function kk(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Oy(t.outputLen),Oy(t.blockLen)}function N2(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 H0e(t,e){dp(t);let r=e.outputLen;if(t.lengthnew DataView(t.buffer,t.byteOffset,t.byteLength),ol=(t,e)=>t<<32-e|t>>>e,IXe=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!IXe)throw new Error("Non little-endian hardware is not supported");var kXe=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function VK(t){if(!HK(t))throw new Error("Uint8Array expected");let e="";for(let r=0;r=up._0&&t<=up._9)return t-up._0;if(t>=up._A&&t<=up._F)return t-(up._A-10);if(t>=up._a&&t<=up._f)return t-(up._a-10)}function G0e(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let i=0,o=0;i{};async function J0e(t,e,r){let n=Date.now();for(let i=0;i=0&&ot().update(Cy(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function eb(t=32){if(Rk&&typeof Rk.getRandomValues=="function")return Rk.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function BXe(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),d=n?4:0,u=n?0:4;t.setUint32(e+d,s,n),t.setUint32(e+u,a,n)}var $y=class extends U2{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=lp(this.buffer)}update(e){N2(this);let{view:r,buffer:n,blockLen:i}=this;e=Cy(e);let o=e.length;for(let s=0;si-s&&(this.process(n,0),s=0);for(let l=s;lc.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;lt&e^~t&r,OXe=(t,e,r)=>t&e^t&r^e&r,CXe=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]),jy=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ny=new Uint32Array(64),GK=class extends $y{constructor(){super(64,32,8,!1),this.A=jy[0]|0,this.B=jy[1]|0,this.C=jy[2]|0,this.D=jy[3]|0,this.E=jy[4]|0,this.F=jy[5]|0,this.G=jy[6]|0,this.H=jy[7]|0}get(){let{A:e,B:r,C:n,D:i,E:o,F:s,G:a,H:d}=this;return[e,r,n,i,o,s,a,d]}set(e,r,n,i,o,s,a,d){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=d|0}process(e,r){for(let l=0;l<16;l++,r+=4)Ny[l]=e.getUint32(r,!1);for(let l=16;l<64;l++){let p=Ny[l-15],m=Ny[l-2],g=ol(p,7)^ol(p,18)^p>>>3,v=ol(m,17)^ol(m,19)^m>>>10;Ny[l]=v+Ny[l-7]+g+Ny[l-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:d,G:u,H:c}=this;for(let l=0;l<64;l++){let p=ol(a,6)^ol(a,11)^ol(a,25),m=c+p+MXe(a,d,u)+CXe[l]+Ny[l]|0,v=(ol(n,2)^ol(n,13)^ol(n,22))+OXe(n,i,o)|0;c=u,u=d,d=a,a=s+m|0,s=o,o=i,i=n,n=m+v|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,d=d+this.F|0,u=u+this.G|0,c=c+this.H|0,this.set(n,i,o,s,a,d,u,c)}roundClean(){Ny.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Uy=q2(()=>new GK);f();var Bk={};Pr(Bk,{bitGet:()=>KXe,bitLen:()=>LXe,bitMask:()=>s3,bitSet:()=>FXe,bytesToHex:()=>hp,bytesToNumberBE:()=>pp,bytesToNumberLE:()=>al,concatBytes:()=>yp,createHmacDrbg:()=>YK,ensureBytes:()=>Wn,equalBytes:()=>UXe,hexToBytes:()=>tb,hexToNumber:()=>ZK,isBytes:()=>sl,numberToBytesBE:()=>Yi,numberToBytesLE:()=>mp,numberToHexUnpadded:()=>ege,numberToVarBytesBE:()=>NXe,utf8ToBytes:()=>qXe,validateObject:()=>Xd});f();var Q0e=BigInt(0),Dk=BigInt(1),$Xe=BigInt(2);function sl(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}var jXe=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function hp(t){if(!sl(t))throw new Error("Uint8Array expected");let e="";for(let r=0;r=fp._0&&t<=fp._9)return t-fp._0;if(t>=fp._A&&t<=fp._F)return t-(fp._A-10);if(t>=fp._a&&t<=fp._f)return t-(fp._a-10)}function tb(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let i=0,o=0;iQ0e;t>>=Dk,e+=1);return e}function KXe(t,e){return t>>BigInt(e)&Dk}var FXe=(t,e,r)=>t|(r?Dk:Q0e)<($Xe<new Uint8Array(t),X0e=t=>Uint8Array.from(t);function YK(t,e,r){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=JK(t),i=JK(t),o=0,s=()=>{n.fill(1),i.fill(0),o=0},a=(...l)=>r(i,n,...l),d=(l=JK())=>{i=a(X0e([0]),l),n=a(),l.length!==0&&(i=a(X0e([1]),l),n=a())},u=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,p=[];for(;l{s(),d(l);let m;for(;!(m=p(u()));)d();return s(),m}}var zXe={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||sl(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function Xd(t,e,r={}){let n=(i,o,s)=>{let a=zXe[o];if(typeof a!="function")throw new Error(`Invalid validator "${o}", expected function`);let d=t[i];if(!(s&&d===void 0)&&!a(d,t))throw new Error(`Invalid param ${String(i)}=${d} (${typeof d}), expected ${o}`)};for(let[i,o]of Object.entries(e))n(i,o,!1);for(let[i,o]of Object.entries(r))n(i,o,!0);return t}var yo=BigInt(0),Qn=BigInt(1),rb=BigInt(2),WXe=BigInt(3),XK=BigInt(4),tge=BigInt(5),rge=BigInt(8),HXe=BigInt(9),VXe=BigInt(16);function Qr(t,e){let r=t%e;return r>=yo?r:e+r}function QK(t,e,r){if(r<=yo||e 0");if(r===Qn)return yo;let n=Qn;for(;e>yo;)e&Qn&&(n=n*t%r),t=t*t%r,e>>=Qn;return n}function Hn(t,e,r){let n=t;for(;e-- >yo;)n*=n,n%=r;return n}function Mk(t,e){if(t===yo||e<=yo)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=Qr(t,e),n=e,i=yo,o=Qn,s=Qn,a=yo;for(;r!==yo;){let u=n/r,c=n%r,l=i-s*u,p=o-a*u;n=r,r=c,i=s,o=a,s=l,a=p}if(n!==Qn)throw new Error("invert: does not exist");return Qr(i,e)}function GXe(t){let e=(t-Qn)/rb,r,n,i;for(r=t-Qn,n=0;r%rb===yo;r/=rb,n++);for(i=rb;i(Qr(t,e)&Qn)===Qn,ZXe=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function eF(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=ZXe.reduce((n,i)=>(n[i]="function",n),e);return Xd(t,r)}function YXe(t,e,r){if(r 0");if(r===yo)return t.ONE;if(r===Qn)return e;let n=t.ONE,i=e;for(;r>yo;)r&Qn&&(n=t.mul(n,i)),i=t.sqr(i),r>>=Qn;return n}function XXe(t,e){let r=new Array(e.length),n=e.reduce((o,s,a)=>t.is0(s)?o:(r[a]=o,t.mul(o,s)),t.ONE),i=t.inv(n);return e.reduceRight((o,s,a)=>t.is0(s)?o:(r[a]=t.mul(o,r[a]),t.mul(o,s)),i),r}function tF(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function L2(t,e,r=!1,n={}){if(t<=yo)throw new Error(`Expected Field ORDER > 0, got ${t}`);let{nBitLength:i,nByteLength:o}=tF(t,e);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=JXe(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:o,MASK:s3(i),ZERO:yo,ONE:Qn,create:d=>Qr(d,t),isValid:d=>{if(typeof d!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof d}`);return yo<=d&&dd===yo,isOdd:d=>(d&Qn)===Qn,neg:d=>Qr(-d,t),eql:(d,u)=>d===u,sqr:d=>Qr(d*d,t),add:(d,u)=>Qr(d+u,t),sub:(d,u)=>Qr(d-u,t),mul:(d,u)=>Qr(d*u,t),pow:(d,u)=>YXe(a,d,u),div:(d,u)=>Qr(d*Mk(u,t),t),sqrN:d=>d*d,addN:(d,u)=>d+u,subN:(d,u)=>d-u,mulN:(d,u)=>d*u,inv:d=>Mk(d,t),sqrt:n.sqrt||(d=>s(a,d)),invertBatch:d=>XXe(a,d),cmov:(d,u,c)=>c?u:d,toBytes:d=>r?mp(d,o):Yi(d,o),fromBytes:d=>{if(d.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${d.length}`);return r?al(d):pp(d)}});return Object.freeze(a)}function ige(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");let r=t.sqrt(e);return t.isOdd(r)?t.neg(r):r}function oge(t){if(typeof t!="bigint")throw new Error("field order must be bigint");let e=t.toString(2).length;return Math.ceil(e/8)}function rF(t){let e=oge(t);return e+Math.ceil(e/2)}function sge(t,e,r=!1){let n=t.length,i=oge(e),o=rF(e);if(n<16||n1024)throw new Error(`expected ${o}-1024 bytes of input, got ${n}`);let s=r?pp(t):al(t),a=Qr(s,e-Qn)+Qn;return r?mp(a,i):Yi(a,i)}f();f();var eQe=BigInt(0),nF=BigInt(1);function Ok(t,e){let r=(i,o)=>{let s=o.negate();return i?s:o},n=i=>{let o=Math.ceil(e/i)+1,s=2**(i-1);return{windows:o,windowSize:s}};return{constTimeNegate:r,unsafeLadder(i,o){let s=t.ZERO,a=i;for(;o>eQe;)o&nF&&(s=s.add(a)),a=a.double(),o>>=nF;return s},precomputeWindow(i,o){let{windows:s,windowSize:a}=n(o),d=[],u=i,c=u;for(let l=0;l>=m,x>d&&(x-=p,s+=nF);let S=v,P=v+Math.abs(x)-1,A=g%2!==0,$=x<0;x===0?c=c.add(r(A,o[S])):u=u.add(r($,o[P]))}return{p:u,f:c}},wNAFCached(i,o,s,a){let d=i._WINDOW_SIZE||1,u=o.get(i);return u||(u=this.precomputeWindow(i,d),d!==1&&o.set(i,a(u))),this.wNAF(d,u,s)}}}function a3(t){return eF(t.Fp),Xd(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...tF(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}function tQe(t){let e=a3(t);Xd(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:r,Fp:n,a:i}=e;if(r){if(!n.eql(i,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:rQe,hexToBytes:nQe}=Bk,nb={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(t){let{Err:e}=nb;if(t.length<2||t[0]!==2)throw new e("Invalid signature integer tag");let r=t[1],n=t.subarray(2,r+2);if(!r||n.length!==r)throw new e("Invalid signature integer: wrong length");if(n[0]&128)throw new e("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:rQe(n),l:t.subarray(r+2)}},toSig(t){let{Err:e}=nb,r=typeof t=="string"?nQe(t):t;if(!sl(r))throw new Error("ui8a expected");let n=r.length;if(n<2||r[0]!=48)throw new e("Invalid signature tag");if(r[1]!==n-2)throw new e("Invalid signature: incorrect length");let{d:i,l:o}=nb._parseInt(r.subarray(2)),{d:s,l:a}=nb._parseInt(o);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:i,s}},hexFromSig(t){let e=u=>Number.parseInt(u[0],16)&8?"00"+u:u,r=u=>{let c=u.toString(16);return c.length&1?`0${c}`:c},n=e(r(t.s)),i=e(r(t.r)),o=n.length/2,s=i.length/2,a=r(o),d=r(s);return`30${r(s+o+4)}02${d}${i}02${a}${n}`}},gp=BigInt(0),Qd=BigInt(1),_Rt=BigInt(2),age=BigInt(3),xRt=BigInt(4);function iQe(t){let e=tQe(t),{Fp:r}=e,n=e.toBytes||((g,v,x)=>{let S=v.toAffine();return yp(Uint8Array.from([4]),r.toBytes(S.x),r.toBytes(S.y))}),i=e.fromBytes||(g=>{let v=g.subarray(1),x=r.fromBytes(v.subarray(0,r.BYTES)),S=r.fromBytes(v.subarray(r.BYTES,2*r.BYTES));return{x,y:S}});function o(g){let{a:v,b:x}=e,S=r.sqr(g),P=r.mul(S,g);return r.add(r.add(P,r.mul(g,v)),x)}if(!r.eql(r.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function s(g){return typeof g=="bigint"&&gpr.eql(A,r.ZERO);return P(x)&&P(S)?l.ZERO:new l(x,S,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(v){let x=r.invertBatch(v.map(S=>S.pz));return v.map((S,P)=>S.toAffine(x[P])).map(l.fromAffine)}static fromHex(v){let x=l.fromAffine(i(Wn("pointHex",v)));return x.assertValidity(),x}static fromPrivateKey(v){return l.BASE.multiply(d(v))}_setWindowSize(v){this._WINDOW_SIZE=v,u.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}let{x:v,y:x}=this.toAffine();if(!r.isValid(v)||!r.isValid(x))throw new Error("bad point: x or y not FE");let S=r.sqr(x),P=o(v);if(!r.eql(S,P))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:v}=this.toAffine();if(r.isOdd)return!r.isOdd(v);throw new Error("Field doesn't support isOdd")}equals(v){c(v);let{px:x,py:S,pz:P}=this,{px:A,py:$,pz:j}=v,q=r.eql(r.mul(x,j),r.mul(A,P)),F=r.eql(r.mul(S,j),r.mul($,P));return q&&F}negate(){return new l(this.px,r.neg(this.py),this.pz)}double(){let{a:v,b:x}=e,S=r.mul(x,age),{px:P,py:A,pz:$}=this,j=r.ZERO,q=r.ZERO,F=r.ZERO,K=r.mul(P,P),W=r.mul(A,A),L=r.mul($,$),I=r.mul(P,A);return I=r.add(I,I),F=r.mul(P,$),F=r.add(F,F),j=r.mul(v,F),q=r.mul(S,L),q=r.add(j,q),j=r.sub(W,q),q=r.add(W,q),q=r.mul(j,q),j=r.mul(I,j),F=r.mul(S,F),L=r.mul(v,L),I=r.sub(K,L),I=r.mul(v,I),I=r.add(I,F),F=r.add(K,K),K=r.add(F,K),K=r.add(K,L),K=r.mul(K,I),q=r.add(q,K),L=r.mul(A,$),L=r.add(L,L),K=r.mul(L,I),j=r.sub(j,K),F=r.mul(L,W),F=r.add(F,F),F=r.add(F,F),new l(j,q,F)}add(v){c(v);let{px:x,py:S,pz:P}=this,{px:A,py:$,pz:j}=v,q=r.ZERO,F=r.ZERO,K=r.ZERO,W=e.a,L=r.mul(e.b,age),I=r.mul(x,A),T=r.mul(S,$),B=r.mul(P,j),h=r.add(x,S),y=r.add(A,$);h=r.mul(h,y),y=r.add(I,T),h=r.sub(h,y),y=r.add(x,P);let w=r.add(A,j);return y=r.mul(y,w),w=r.add(I,B),y=r.sub(y,w),w=r.add(S,P),q=r.add($,j),w=r.mul(w,q),q=r.add(T,B),w=r.sub(w,q),K=r.mul(W,y),q=r.mul(L,B),K=r.add(q,K),q=r.sub(T,K),K=r.add(T,K),F=r.mul(q,K),T=r.add(I,I),T=r.add(T,I),B=r.mul(W,B),y=r.mul(L,y),T=r.add(T,B),B=r.sub(I,B),B=r.mul(W,B),y=r.add(y,B),I=r.mul(T,y),F=r.add(F,I),I=r.mul(w,y),q=r.mul(h,q),q=r.sub(q,I),I=r.mul(h,T),K=r.mul(w,K),K=r.add(K,I),new l(q,F,K)}subtract(v){return this.add(v.negate())}is0(){return this.equals(l.ZERO)}wNAF(v){return m.wNAFCached(this,u,v,x=>{let S=r.invertBatch(x.map(P=>P.pz));return x.map((P,A)=>P.toAffine(S[A])).map(l.fromAffine)})}multiplyUnsafe(v){let x=l.ZERO;if(v===gp)return x;if(a(v),v===Qd)return this;let{endo:S}=e;if(!S)return m.unsafeLadder(this,v);let{k1neg:P,k1:A,k2neg:$,k2:j}=S.splitScalar(v),q=x,F=x,K=this;for(;A>gp||j>gp;)A&Qd&&(q=q.add(K)),j&Qd&&(F=F.add(K)),K=K.double(),A>>=Qd,j>>=Qd;return P&&(q=q.negate()),$&&(F=F.negate()),F=new l(r.mul(F.px,S.beta),F.py,F.pz),q.add(F)}multiply(v){a(v);let x=v,S,P,{endo:A}=e;if(A){let{k1neg:$,k1:j,k2neg:q,k2:F}=A.splitScalar(x),{p:K,f:W}=this.wNAF(j),{p:L,f:I}=this.wNAF(F);K=m.constTimeNegate($,K),L=m.constTimeNegate(q,L),L=new l(r.mul(L.px,A.beta),L.py,L.pz),S=K.add(L),P=W.add(I)}else{let{p:$,f:j}=this.wNAF(x);S=$,P=j}return l.normalizeZ([S,P])[0]}multiplyAndAddUnsafe(v,x,S){let P=l.BASE,A=(j,q)=>q===gp||q===Qd||!j.equals(P)?j.multiplyUnsafe(q):j.multiply(q),$=A(this,x).add(A(v,S));return $.is0()?void 0:$}toAffine(v){let{px:x,py:S,pz:P}=this,A=this.is0();v==null&&(v=A?r.ONE:r.inv(P));let $=r.mul(x,v),j=r.mul(S,v),q=r.mul(P,v);if(A)return{x:r.ZERO,y:r.ZERO};if(!r.eql(q,r.ONE))throw new Error("invZ was invalid");return{x:$,y:j}}isTorsionFree(){let{h:v,isTorsionFree:x}=e;if(v===Qd)return!0;if(x)return x(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:v,clearCofactor:x}=e;return v===Qd?this:x?x(l,this):this.multiplyUnsafe(e.h)}toRawBytes(v=!0){return this.assertValidity(),n(l,this,v)}toHex(v=!0){return hp(this.toRawBytes(v))}}l.BASE=new l(e.Gx,e.Gy,r.ONE),l.ZERO=new l(r.ZERO,r.ONE,r.ZERO);let p=e.nBitLength,m=Ok(l,e.endo?Math.ceil(p/2):p);return{CURVE:e,ProjectivePoint:l,normPrivateKeyToScalar:d,weierstrassEquation:o,isWithinCurveOrder:s}}function oQe(t){let e=a3(t);return Xd(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function cge(t){let e=oQe(t),{Fp:r,n}=e,i=r.BYTES+1,o=2*r.BYTES+1;function s(y){return gphp(Yi(y,e.nByteLength));function g(y){let w=n>>Qd;return y>w}function v(y){return g(y)?a(-y):y}let x=(y,w,E)=>pp(y.slice(w,E));class S{constructor(w,E,_){this.r=w,this.s=E,this.recovery=_,this.assertValidity()}static fromCompact(w){let E=e.nByteLength;return w=Wn("compactSignature",w,E*2),new S(x(w,0,E),x(w,E,2*E))}static fromDER(w){let{r:E,s:_}=nb.toSig(Wn("DER",w));return new S(E,_)}assertValidity(){if(!p(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!p(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(w){return new S(this.r,this.s,w)}recoverPublicKey(w){let{r:E,s:_,recovery:b}=this,C=F(Wn("msgHash",w));if(b==null||![0,1,2,3].includes(b))throw new Error("recovery id invalid");let N=b===2||b===3?E+e.n:E;if(N>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let M=b&1?"03":"02",U=u.fromHex(M+m(N)),G=d(N),Z=a(-C*G),J=a(_*G),H=u.BASE.multiplyAndAddUnsafe(U,Z,J);if(!H)throw new Error("point at infinify");return H.assertValidity(),H}hasHighS(){return g(this.s)}normalizeS(){return this.hasHighS()?new S(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return tb(this.toDERHex())}toDERHex(){return nb.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return tb(this.toCompactHex())}toCompactHex(){return m(this.r)+m(this.s)}}let P={isValidPrivateKey(y){try{return c(y),!0}catch{return!1}},normPrivateKeyToScalar:c,randomPrivateKey:()=>{let y=rF(e.n);return sge(e.randomBytes(y),e.n)},precompute(y=8,w=u.BASE){return w._setWindowSize(y),w.multiply(BigInt(3)),w}};function A(y,w=!0){return u.fromPrivateKey(y).toRawBytes(w)}function $(y){let w=sl(y),E=typeof y=="string",_=(w||E)&&y.length;return w?_===i||_===o:E?_===2*i||_===2*o:y instanceof u}function j(y,w,E=!0){if($(y))throw new Error("first arg must be private key");if(!$(w))throw new Error("second arg must be public key");return u.fromHex(w).multiply(c(y)).toRawBytes(E)}let q=e.bits2int||function(y){let w=pp(y),E=y.length*8-e.nBitLength;return E>0?w>>BigInt(E):w},F=e.bits2int_modN||function(y){return a(q(y))},K=s3(e.nBitLength);function W(y){if(typeof y!="bigint")throw new Error("bigint expected");if(!(gp<=y&&yte in E))throw new Error("sign() legacy options not supported");let{hash:_,randomBytes:b}=e,{lowS:C,prehash:N,extraEntropy:M}=E;C==null&&(C=!0),y=Wn("msgHash",y),N&&(y=Wn("prehashed msgHash",_(y)));let U=F(y),G=c(w),Z=[W(G),W(U)];if(M!=null){let te=M===!0?b(r.BYTES):M;Z.push(Wn("extraEntropy",te))}let J=yp(...Z),H=U;function X(te){let ne=q(te);if(!p(ne))return;let Q=d(ne),re=u.BASE.multiply(ne).toAffine(),ce=a(re.x);if(ce===gp)return;let pe=a(Q*a(H+ce*G));if(pe===gp)return;let ye=(re.x===ce?0:2)|Number(re.y&Qd),ie=pe;return C&&g(pe)&&(ie=v(pe),ye^=1),new S(ce,ie,ye)}return{seed:J,k2sig:X}}let I={lowS:e.lowS,prehash:!1},T={lowS:e.lowS,prehash:!1};function B(y,w,E=I){let{seed:_,k2sig:b}=L(y,w,E),C=e;return YK(C.hash.outputLen,C.nByteLength,C.hmac)(_,b)}u.BASE._setWindowSize(8);function h(y,w,E,_=T){let b=y;if(w=Wn("msgHash",w),E=Wn("publicKey",E),"strict"in _)throw new Error("options.strict was renamed to lowS");let{lowS:C,prehash:N}=_,M,U;try{if(typeof b=="string"||sl(b))try{M=S.fromDER(b)}catch(re){if(!(re instanceof nb.Err))throw re;M=S.fromCompact(b)}else if(typeof b=="object"&&typeof b.r=="bigint"&&typeof b.s=="bigint"){let{r:re,s:ce}=b;M=new S(re,ce)}else throw new Error("PARSE");U=u.fromHex(E)}catch(re){if(re.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(C&&M.hasHighS())return!1;N&&(w=e.hash(w));let{r:G,s:Z}=M,J=F(w),H=d(Z),X=a(J*H),te=a(G*H),ne=u.BASE.multiplyAndAddUnsafe(U,X,te)?.toAffine();return ne?a(ne.x)===G:!1}return{CURVE:e,getPublicKey:A,getSharedSecret:j,sign:B,verify:h,ProjectivePoint:u,Signature:S,utils:P}}f();f();var Ck=class extends U2{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,kk(e);let n=Cy(r);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let i=this.blockLen,o=new Uint8Array(i);o.set(n.length>i?e.create().update(n).digest():n);for(let s=0;snew Ck(t,e).update(r).digest();qy.create=(t,e)=>new Ck(t,e);function sQe(t){return{hash:t,hmac:(e,...r)=>qy(t,e,Qv(...r)),randomBytes:eb}}function $k(t,e){let r=n=>cge({...t,...sQe(n)});return Object.freeze({...r(e),create:r})}var lge=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),dge=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),aQe=BigInt(1),iF=BigInt(2),uge=(t,e)=>(t+e/iF)/e;function cQe(t){let e=lge,r=BigInt(3),n=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),d=BigInt(88),u=t*t*t%e,c=u*u*t%e,l=Hn(c,r,e)*c%e,p=Hn(l,r,e)*c%e,m=Hn(p,iF,e)*u%e,g=Hn(m,i,e)*m%e,v=Hn(g,o,e)*g%e,x=Hn(v,a,e)*v%e,S=Hn(x,d,e)*x%e,P=Hn(S,a,e)*v%e,A=Hn(P,r,e)*c%e,$=Hn(A,s,e)*g%e,j=Hn($,n,e)*u%e,q=Hn(j,iF,e);if(!oF.eql(oF.sqr(q),t))throw new Error("Cannot find square root");return q}var oF=L2(lge,void 0,void 0,{sqrt:cQe}),Dn=$k({a:BigInt(0),b:BigInt(7),Fp:oF,n:dge,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{let e=dge,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-aQe*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=r,s=BigInt("0x100000000000000000000000000000000"),a=uge(o*t,e),d=uge(-n*t,e),u=Qr(t-a*r-d*i,e),c=Qr(-a*n-d*o,e),l=u>s,p=c>s;if(l&&(u=e-u),p&&(c=e-c),u>s||c>s)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:l,k1:u,k2neg:p,k2:c}}}},Uy),jRt=BigInt(0);var NRt=Dn.ProjectivePoint;f();f();function fge(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 dQe=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},sF="urn:jwk:";function gr(t){return dQe(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}`);Gq(n);let i=fge(n),o=xt.string(i).toUint8Array(),s=yield j2.digest({data:o});return xt.uint8Array(s).toBase64Url()})}function Df(t){return!(!t||typeof t!="object"||!("kty"in t&&"crv"in t&&"x"in t&&"d"in t)||t.kty!=="EC"||typeof t.d!="string"||typeof t.x!="string")}function K2(t){return!(!t||typeof t!="object"||!("kty"in t&&"crv"in t&&"x"in t)||"d"in t||t.kty!=="EC"||typeof t.x!="string")}function Bf(t){return!(!t||typeof t!="object"||!("kty"in t&&"crv"in t&&"x"in t&&"d"in t)||t.kty!=="OKP"||typeof t.d!="string"||typeof t.x!="string")}function F2(t){return!(!t||typeof t!="object"||"d"in t||!("kty"in t&&"crv"in t&&"x"in t)||t.kty!=="OKP"||typeof t.x!="string")}function hge(t){if(!t||typeof t!="object")return!1;switch(t.kty){case"EC":case"OKP":case"RSA":return"d"in t;case"oct":return"k"in t;default:return!1}}var Is=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},uQe=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i>aF&jk)}:{h:Number(t>>aF&jk)|0,l:Number(t&jk)|0}}function mQe(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;iBigInt(t>>>0)<>>0),gQe=(t,e,r)=>t>>>r,vQe=(t,e,r)=>t<<32-r|e>>>r,bQe=(t,e,r)=>t>>>r|e<<32-r,wQe=(t,e,r)=>t<<32-r|e>>>r,_Qe=(t,e,r)=>t<<64-r|e>>>r-32,xQe=(t,e,r)=>t>>>r-32|e<<64-r,EQe=(t,e)=>e,SQe=(t,e)=>t,AQe=(t,e,r)=>t<>>32-r,TQe=(t,e,r)=>e<>>32-r,PQe=(t,e,r)=>e<>>64-r,IQe=(t,e,r)=>t<>>64-r;function kQe(t,e,r,n){let i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}var RQe=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),DQe=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,BQe=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),MQe=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0,OQe=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0),CQe=(t,e,r,n,i,o)=>e+r+n+i+o+(t/2**32|0)|0;var $Qe={fromBig:mge,split:mQe,toBig:yQe,shrSH:gQe,shrSL:vQe,rotrSH:bQe,rotrSL:wQe,rotrBH:_Qe,rotrBL:xQe,rotr32H:EQe,rotr32L:SQe,rotlSH:AQe,rotlSL:TQe,rotlBH:PQe,rotlBL:IQe,add:kQe,add3L:RQe,add3H:DQe,add4L:BQe,add4H:MQe,add5H:CQe,add5L:OQe},or=$Qe;var[jQe,NQe]=or.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),Ly=new Uint32Array(80),Ky=new Uint32Array(80),cF=class extends $y{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:r,Bh:n,Bl:i,Ch:o,Cl:s,Dh:a,Dl:d,Eh:u,El:c,Fh:l,Fl:p,Gh:m,Gl:g,Hh:v,Hl:x}=this;return[e,r,n,i,o,s,a,d,u,c,l,p,m,g,v,x]}set(e,r,n,i,o,s,a,d,u,c,l,p,m,g,v,x){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=o|0,this.Cl=s|0,this.Dh=a|0,this.Dl=d|0,this.Eh=u|0,this.El=c|0,this.Fh=l|0,this.Fl=p|0,this.Gh=m|0,this.Gl=g|0,this.Hh=v|0,this.Hl=x|0}process(e,r){for(let A=0;A<16;A++,r+=4)Ly[A]=e.getUint32(r),Ky[A]=e.getUint32(r+=4);for(let A=16;A<80;A++){let $=Ly[A-15]|0,j=Ky[A-15]|0,q=or.rotrSH($,j,1)^or.rotrSH($,j,8)^or.shrSH($,j,7),F=or.rotrSL($,j,1)^or.rotrSL($,j,8)^or.shrSL($,j,7),K=Ly[A-2]|0,W=Ky[A-2]|0,L=or.rotrSH(K,W,19)^or.rotrBH(K,W,61)^or.shrSH(K,W,6),I=or.rotrSL(K,W,19)^or.rotrBL(K,W,61)^or.shrSL(K,W,6),T=or.add4L(F,I,Ky[A-7],Ky[A-16]),B=or.add4H(T,q,L,Ly[A-7],Ly[A-16]);Ly[A]=B|0,Ky[A]=T|0}let{Ah:n,Al:i,Bh:o,Bl:s,Ch:a,Cl:d,Dh:u,Dl:c,Eh:l,El:p,Fh:m,Fl:g,Gh:v,Gl:x,Hh:S,Hl:P}=this;for(let A=0;A<80;A++){let $=or.rotrSH(l,p,14)^or.rotrSH(l,p,18)^or.rotrBH(l,p,41),j=or.rotrSL(l,p,14)^or.rotrSL(l,p,18)^or.rotrBL(l,p,41),q=l&m^~l&v,F=p&g^~p&x,K=or.add5L(P,j,F,NQe[A],Ky[A]),W=or.add5H(K,S,$,q,jQe[A],Ly[A]),L=K|0,I=or.rotrSH(n,i,28)^or.rotrBH(n,i,34)^or.rotrBH(n,i,39),T=or.rotrSL(n,i,28)^or.rotrBL(n,i,34)^or.rotrBL(n,i,39),B=n&o^n&a^o&a,h=i&s^i&d^s&d;S=v|0,P=x|0,v=m|0,x=g|0,m=l|0,g=p|0,{h:l,l:p}=or.add(u|0,c|0,W|0,L|0),u=a|0,c=d|0,a=o|0,d=s|0,o=n|0,s=i|0;let y=or.add3L(L,T,h);n=or.add3H(y,W,I,B),i=y|0}({h:n,l:i}=or.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:o,l:s}=or.add(this.Bh|0,this.Bl|0,o|0,s|0),{h:a,l:d}=or.add(this.Ch|0,this.Cl|0,a|0,d|0),{h:u,l:c}=or.add(this.Dh|0,this.Dl|0,u|0,c|0),{h:l,l:p}=or.add(this.Eh|0,this.El|0,l|0,p|0),{h:m,l:g}=or.add(this.Fh|0,this.Fl|0,m|0,g|0),{h:v,l:x}=or.add(this.Gh|0,this.Gl|0,v|0,x|0),{h:S,l:P}=or.add(this.Hh|0,this.Hl|0,S|0,P|0),this.set(n,i,o,s,a,d,u,c,l,p,m,g,v,x,S,P)}roundClean(){Ly.fill(0),Ky.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var Fy=q2(()=>new cF);f();var cl=BigInt(0),rd=BigInt(1),Nk=BigInt(2),UQe=BigInt(8),qQe={zip215:!0};function LQe(t){let e=a3(t);return Xd(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function Uk(t){let e=LQe(t),{Fp:r,n,prehash:i,hash:o,randomBytes:s,nByteLength:a,h:d}=e,u=Nk<{try{return{isValid:!0,value:r.sqrt(_*r.inv(b))}}catch{return{isValid:!1,value:cl}}}),p=e.adjustScalarBytes||(_=>_),m=e.domain||((_,b,C)=>{if(b.length||C)throw new Error("Contexts/pre-hash are not supported");return _}),g=_=>typeof _=="bigint"&&cl<_,v=(_,b)=>g(_)&&g(b)&&__===cl||v(_,u);function S(_,b){if(v(_,b))return _;throw new Error(`Expected valid scalar < ${b}, got ${typeof _} ${_}`)}function P(_){return _===cl?_:S(_,n)}let A=new Map;function $(_){if(!(_ instanceof j))throw new Error("ExtendedPoint expected")}class j{constructor(b,C,N,M){if(this.ex=b,this.ey=C,this.ez=N,this.et=M,!x(b))throw new Error("x required");if(!x(C))throw new Error("y required");if(!x(N))throw new Error("z required");if(!x(M))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(b){if(b instanceof j)throw new Error("extended point not allowed");let{x:C,y:N}=b||{};if(!x(C)||!x(N))throw new Error("invalid affine point");return new j(C,N,rd,c(C*N))}static normalizeZ(b){let C=r.invertBatch(b.map(N=>N.ez));return b.map((N,M)=>N.toAffine(C[M])).map(j.fromAffine)}_setWindowSize(b){this._WINDOW_SIZE=b,A.delete(this)}assertValidity(){let{a:b,d:C}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:N,ey:M,ez:U,et:G}=this,Z=c(N*N),J=c(M*M),H=c(U*U),X=c(H*H),te=c(Z*b),ne=c(H*c(te+J)),Q=c(X+c(C*c(Z*J)));if(ne!==Q)throw new Error("bad point: equation left != right (1)");let re=c(N*M),ce=c(U*G);if(re!==ce)throw new Error("bad point: equation left != right (2)")}equals(b){$(b);let{ex:C,ey:N,ez:M}=this,{ex:U,ey:G,ez:Z}=b,J=c(C*Z),H=c(U*M),X=c(N*Z),te=c(G*M);return J===H&&X===te}is0(){return this.equals(j.ZERO)}negate(){return new j(c(-this.ex),this.ey,this.ez,c(-this.et))}double(){let{a:b}=e,{ex:C,ey:N,ez:M}=this,U=c(C*C),G=c(N*N),Z=c(Nk*c(M*M)),J=c(b*U),H=C+N,X=c(c(H*H)-U-G),te=J+G,ne=te-Z,Q=J-G,re=c(X*ne),ce=c(te*Q),pe=c(X*Q),ye=c(ne*te);return new j(re,ce,ye,pe)}add(b){$(b);let{a:C,d:N}=e,{ex:M,ey:U,ez:G,et:Z}=this,{ex:J,ey:H,ez:X,et:te}=b;if(C===BigInt(-1)){let Et=c((U-M)*(H+J)),Fe=c((U+M)*(H-J)),mt=c(Fe-Et);if(mt===cl)return this.double();let Sn=c(G*Nk*te),ke=c(Z*Nk*X),Pe=ke+Sn,Wt=Fe+Et,Be=ke-Sn,Ee=c(Pe*mt),$r=c(Wt*Be),Ve=c(Pe*Be),Ze=c(mt*Wt);return new j(Ee,$r,Ze,Ve)}let ne=c(M*J),Q=c(U*H),re=c(Z*N*te),ce=c(G*X),pe=c((M+U)*(J+H)-ne-Q),ye=ce-re,ie=ce+re,he=c(Q-C*ne),me=c(pe*ye),Re=c(ie*he),xe=c(pe*he),it=c(ye*ie);return new j(me,Re,it,xe)}subtract(b){return this.add(b.negate())}wNAF(b){return K.wNAFCached(this,A,b,j.normalizeZ)}multiply(b){let{p:C,f:N}=this.wNAF(S(b,n));return j.normalizeZ([C,N])[0]}multiplyUnsafe(b){let C=P(b);return C===cl?F:this.equals(F)||C===rd?this:this.equals(q)?this.wNAF(C).p:K.unsafeLadder(this,C)}isSmallOrder(){return this.multiplyUnsafe(d).is0()}isTorsionFree(){return K.unsafeLadder(this,n).is0()}toAffine(b){let{ex:C,ey:N,ez:M}=this,U=this.is0();b==null&&(b=U?UQe:r.inv(M));let G=c(C*b),Z=c(N*b),J=c(M*b);if(U)return{x:cl,y:rd};if(J!==rd)throw new Error("invZ was invalid");return{x:G,y:Z}}clearCofactor(){let{h:b}=e;return b===rd?this:this.multiplyUnsafe(b)}static fromHex(b,C=!1){let{d:N,a:M}=e,U=r.BYTES;b=Wn("pointHex",b,U);let G=b.slice(),Z=b[U-1];G[U-1]=Z&-129;let J=al(G);J===cl||(C?S(J,u):S(J,r.ORDER));let H=c(J*J),X=c(H-rd),te=c(N*H-M),{isValid:ne,value:Q}=l(X,te);if(!ne)throw new Error("Point.fromHex: invalid y coordinate");let re=(Q&rd)===rd,ce=(Z&128)!==0;if(!C&&Q===cl&&ce)throw new Error("Point.fromHex: x=0 and x_0=1");return ce!==re&&(Q=c(-Q)),j.fromAffine({x:Q,y:J})}static fromPrivateKey(b){return I(b).point}toRawBytes(){let{x:b,y:C}=this.toAffine(),N=mp(C,r.BYTES);return N[N.length-1]|=b&rd?128:0,N}toHex(){return hp(this.toRawBytes())}}j.BASE=new j(e.Gx,e.Gy,rd,c(e.Gx*e.Gy)),j.ZERO=new j(cl,rd,rd,cl);let{BASE:q,ZERO:F}=j,K=Ok(j,a*8);function W(_){return Qr(_,n)}function L(_){return W(al(_))}function I(_){let b=a;_=Wn("private key",_,b);let C=Wn("hashed private key",o(_),2*b),N=p(C.slice(0,b)),M=C.slice(b,2*b),U=L(N),G=q.multiply(U),Z=G.toRawBytes();return{head:N,prefix:M,scalar:U,point:G,pointBytes:Z}}function T(_){return I(_).pointBytes}function B(_=new Uint8Array,...b){let C=yp(...b);return L(o(m(C,Wn("context",_),!!i)))}function h(_,b,C={}){_=Wn("message",_),i&&(_=i(_));let{prefix:N,scalar:M,pointBytes:U}=I(b),G=B(C.context,N,_),Z=q.multiply(G).toRawBytes(),J=B(C.context,Z,U,_),H=W(G+J*M);P(H);let X=yp(Z,mp(H,r.BYTES));return Wn("result",X,a*2)}let y=qQe;function w(_,b,C,N=y){let{context:M,zip215:U}=N,G=r.BYTES;_=Wn("signature",_,2*G),b=Wn("message",b),i&&(b=i(b));let Z=al(_.slice(G,2*G)),J,H,X;try{J=j.fromHex(C,U),H=j.fromHex(_.slice(0,G),U),X=q.multiplyUnsafe(Z)}catch{return!1}if(!U&&J.isSmallOrder())return!1;let te=B(M,H.toRawBytes(),J.toRawBytes(),b);return H.add(J.multiplyUnsafe(te)).subtract(X).clearCofactor().equals(j.ZERO)}return q._setWindowSize(8),{CURVE:e,getPublicKey:T,sign:h,verify:w,ExtendedPoint:j,utils:{getExtendedPublicKey:I,randomPrivateKey:()=>s(r.BYTES),precompute(_=8,b=j.BASE){return b._setWindowSize(_),b.multiply(BigInt(3)),b}}}}f();var u3=BigInt(0),dF=BigInt(1);function KQe(t){return Xd(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function yge(t){let e=KQe(t),{P:r}=e,n=A=>Qr(A,r),i=e.montgomeryBits,o=Math.ceil(i/8),s=e.nByteLength,a=e.adjustScalarBytes||(A=>A),d=e.powPminus2||(A=>QK(A,r-BigInt(2),r));function u(A,$,j){let q=n(A*($-j));return $=n($-q),j=n(j+q),[$,j]}function c(A){if(typeof A=="bigint"&&u3<=A&&A=u3;y--){let w=q>>y&dF;T^=w,B=u(T,K,L),K=B[0],L=B[1],B=u(T,W,I),W=B[0],I=B[1],T=w;let E=K+W,_=n(E*E),b=K-W,C=n(b*b),N=_-C,M=L+I,U=L-I,G=n(U*E),Z=n(M*b),J=G+Z,H=G-Z;L=n(J*J),I=n(F*n(H*H)),K=n(_*C),W=n(N*(_+n(l*N)))}B=u(T,K,L),K=B[0],L=B[1],B=u(T,W,I),W=B[0],I=B[1];let h=d(W);return n(K*h)}function m(A){return mp(n(A),o)}function g(A){let $=Wn("u coordinate",A,o);return s===32&&($[31]&=127),al($)}function v(A){let $=Wn("scalar",A),j=$.length;if(j!==o&&j!==s)throw new Error(`Expected ${o} or ${s} bytes, got ${j}`);return al(a($))}function x(A,$){let j=g($),q=v(A),F=p(j,q);if(F===u3)throw new Error("Invalid private or public key received");return m(F)}let S=m(e.Gu);function P(A){return x(A,S)}return{scalarMult:x,scalarMultBase:P,getSharedSecret:(A,$)=>x(A,$),getPublicKey:A=>P(A),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:S}}var l3=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),gge=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),qDt=BigInt(0),FQe=BigInt(1),uF=BigInt(2),zQe=BigInt(5),vge=BigInt(10),WQe=BigInt(20),HQe=BigInt(40),bge=BigInt(80);function wge(t){let e=l3,n=t*t%e*t%e,i=Hn(n,uF,e)*n%e,o=Hn(i,FQe,e)*t%e,s=Hn(o,zQe,e)*o%e,a=Hn(s,vge,e)*s%e,d=Hn(a,WQe,e)*a%e,u=Hn(d,HQe,e)*d%e,c=Hn(u,bge,e)*u%e,l=Hn(c,bge,e)*u%e,p=Hn(l,vge,e)*s%e;return{pow_p_5_8:Hn(p,uF,e)*t%e,b2:n}}function _ge(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function VQe(t,e){let r=l3,n=Qr(e*e*e,r),i=Qr(n*n*e,r),o=wge(t*i).pow_p_5_8,s=Qr(t*n*o,r),a=Qr(e*s*s,r),d=s,u=Qr(s*gge,r),c=a===t,l=a===Qr(-t,r),p=a===Qr(-t*gge,r);return c&&(s=d),(l||p)&&(s=u),nge(s,r)&&(s=Qr(-s,r)),{isValid:c||l,value:s}}var eu=L2(l3,void 0,!0),f3={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:eu,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Fy,randomBytes:eb,adjustScalarBytes:_ge,uvRatio:VQe},go=Uk(f3);function xge(t,e,r){if(e.length>255)throw new Error("Context is too big");return Qv(o3("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,e.length]),e,t)}var LDt=Uk({...f3,domain:xge}),KDt=Uk({...f3,domain:xge,prehash:Fy}),hc=yge({P:l3,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{let e=l3,{pow_p_5_8:r,b2:n}=wge(t);return Qr(Hn(r,BigInt(3),e)*n,e)},adjustScalarBytes:_ge,randomBytes:eb});function qk(t){let{y:e}=go.ExtendedPoint.fromHex(t),r=BigInt(1);return eu.toBytes(eu.create((r+e)*eu.inv(r-e)))}function Lk(t){let e=f3.hash(t.subarray(0,32));return f3.adjustScalarBytes(e).subarray(0,32)}var GQe=(eu.ORDER+BigInt(3))/BigInt(8),FDt=eu.pow(uF,GQe),zDt=eu.sqrt(eu.neg(eu.ONE)),WDt=(eu.ORDER-BigInt(5))/BigInt(8),HDt=BigInt(486662);var VDt=ige(eu,eu.neg(BigInt(486664)));var GDt=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),JDt=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),ZDt=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),YDt=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");var XDt=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var tu=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},JQe=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);iZQe,checkRequiredProperty:()=>Ege,checkValidProperty:()=>Sge,getJoseSignatureAlgorithmFromPublicKey:()=>Age,isWebCryptoSupported:()=>Tge,randomBytes:()=>Fk,randomPin:()=>Ige,randomUuid:()=>Pge});f();function Ege(t){if(!t||t.property===void 0||t.inObject===void 0)throw new TypeError("One or more required parameters missing: 'property, properties'");let{property:e,inObject:r}=t;if(!(e in r))throw new TypeError(`Required parameter missing: '${e}'`)}function Sge(t){if(!t||t.property===void 0||t.allowedProperties===void 0)throw new TypeError("One or more required parameters missing: 'property, allowedProperties'");let{property:e,allowedProperties:r}=t;if(Array.isArray(r)&&!r.includes(e)||r instanceof Set&&!r.has(e)||r instanceof Map&&!r.has(e)){let n=Array.from(r instanceof Map?r.keys():r).join(", ");throw new TypeError(`Out of range: '${e}'. Must be one of '${n}'`)}}function Age(t){let e={Ed25519:"EdDSA","P-256":"ES256","P-384":"ES384","P-521":"ES512",secp256k1:"ES256K"};if(t.alg&&Object.values(e).includes(t.alg))return t.alg;if(t.crv&&Object.keys(e).includes(t.crv))return e[t.crv];throw new Error(`Unable to determine algorithm based on provided input: alg=${t.alg}, crv=${t.crv}. Supported 'alg' values: ${Object.values(e).join(", ")}. Supported 'crv' values: ${Object.keys(e).join(", ")}.`)}function Tge(){return!!(globalThis.crypto&&globalThis.crypto.subtle)}function Fk(t){return Gb(t)}function Pge(){return Gp.randomUUID()}function Ige({length:t}){if(3>t||t>10)throw new Error("randomPin() can securely generate a PIN between 3 to 10 digits.");let e=Math.pow(10,t)-1,r;if(t<=6){let n=Math.pow(10,t);do{let i=Fk(Math.ceil(t/2));r=new DataView(i.buffer).getUint16(0,!1)%n}while(r>e)}else{let n=Math.pow(10,10);do{let i=Fk(4);r=new DataView(i.buffer).getUint32(0,!1)%n}while(r>e)}return r.toString().padStart(t,"0")}var ZQe={randomPin:Ige,randomUuid:Pge,randomBytes:Fk,isWebCryptoSupported:Tge,getJoseSignatureAlgorithmFromPublicKey:Age,checkValidProperty:Sge,checkRequiredProperty:Ege};f();f();f();f();f();f();f();f();f();f();var zy=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},YQe=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);it[e++]&255|(t[e++]&255)<<8,hF=class{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,e=GT(e),ao(e,32);let r=Ds(e,0),n=Ds(e,2),i=Ds(e,4),o=Ds(e,6),s=Ds(e,8),a=Ds(e,10),d=Ds(e,12),u=Ds(e,14);this.r[0]=r&8191,this.r[1]=(r>>>13|n<<3)&8191,this.r[2]=(n>>>10|i<<6)&7939,this.r[3]=(i>>>7|o<<9)&8191,this.r[4]=(o>>>4|s<<12)&255,this.r[5]=s>>>1&8190,this.r[6]=(s>>>14|a<<2)&8191,this.r[7]=(a>>>11|d<<5)&8065,this.r[8]=(d>>>8|u<<8)&8191,this.r[9]=u>>>5&127;for(let c=0;c<8;c++)this.pad[c]=Ds(e,16+2*c)}process(e,r,n=!1){let i=n?0:2048,{h:o,r:s}=this,a=s[0],d=s[1],u=s[2],c=s[3],l=s[4],p=s[5],m=s[6],g=s[7],v=s[8],x=s[9],S=Ds(e,r+0),P=Ds(e,r+2),A=Ds(e,r+4),$=Ds(e,r+6),j=Ds(e,r+8),q=Ds(e,r+10),F=Ds(e,r+12),K=Ds(e,r+14),W=o[0]+(S&8191),L=o[1]+((S>>>13|P<<3)&8191),I=o[2]+((P>>>10|A<<6)&8191),T=o[3]+((A>>>7|$<<9)&8191),B=o[4]+(($>>>4|j<<12)&8191),h=o[5]+(j>>>1&8191),y=o[6]+((j>>>14|q<<2)&8191),w=o[7]+((q>>>11|F<<5)&8191),E=o[8]+((F>>>8|K<<8)&8191),_=o[9]+(K>>>5|i),b=0,C=b+W*a+L*(5*x)+I*(5*v)+T*(5*g)+B*(5*m);b=C>>>13,C&=8191,C+=h*(5*p)+y*(5*l)+w*(5*c)+E*(5*u)+_*(5*d),b+=C>>>13,C&=8191;let N=b+W*d+L*a+I*(5*x)+T*(5*v)+B*(5*g);b=N>>>13,N&=8191,N+=h*(5*m)+y*(5*p)+w*(5*l)+E*(5*c)+_*(5*u),b+=N>>>13,N&=8191;let M=b+W*u+L*d+I*a+T*(5*x)+B*(5*v);b=M>>>13,M&=8191,M+=h*(5*g)+y*(5*m)+w*(5*p)+E*(5*l)+_*(5*c),b+=M>>>13,M&=8191;let U=b+W*c+L*u+I*d+T*a+B*(5*x);b=U>>>13,U&=8191,U+=h*(5*v)+y*(5*g)+w*(5*m)+E*(5*p)+_*(5*l),b+=U>>>13,U&=8191;let G=b+W*l+L*c+I*u+T*d+B*a;b=G>>>13,G&=8191,G+=h*(5*x)+y*(5*v)+w*(5*g)+E*(5*m)+_*(5*p),b+=G>>>13,G&=8191;let Z=b+W*p+L*l+I*c+T*u+B*d;b=Z>>>13,Z&=8191,Z+=h*a+y*(5*x)+w*(5*v)+E*(5*g)+_*(5*m),b+=Z>>>13,Z&=8191;let J=b+W*m+L*p+I*l+T*c+B*u;b=J>>>13,J&=8191,J+=h*d+y*a+w*(5*x)+E*(5*v)+_*(5*g),b+=J>>>13,J&=8191;let H=b+W*g+L*m+I*p+T*l+B*c;b=H>>>13,H&=8191,H+=h*u+y*d+w*a+E*(5*x)+_*(5*v),b+=H>>>13,H&=8191;let X=b+W*v+L*g+I*m+T*p+B*l;b=X>>>13,X&=8191,X+=h*c+y*u+w*d+E*a+_*(5*x),b+=X>>>13,X&=8191;let te=b+W*x+L*v+I*g+T*m+B*p;b=te>>>13,te&=8191,te+=h*l+y*c+w*u+E*d+_*a,b+=te>>>13,te&=8191,b=(b<<2)+b|0,b=b+C|0,C=b&8191,b=b>>>13,N+=b,o[0]=C,o[1]=N,o[2]=M,o[3]=U,o[4]=G,o[5]=Z,o[6]=J,o[7]=H,o[8]=X,o[9]=te}finalize(){let{h:e,pad:r}=this,n=new Uint16Array(10),i=e[1]>>>13;e[1]&=8191;for(let a=2;a<10;a++)e[a]+=i,i=e[a]>>>13,e[a]&=8191;e[0]+=i*5,i=e[0]>>>13,e[0]&=8191,e[1]+=i,i=e[1]>>>13,e[1]&=8191,e[2]+=i,n[0]=e[0]+5,i=n[0]>>>13,n[0]&=8191;for(let a=1;a<10;a++)n[a]=e[a]+i,i=n[a]>>>13,n[a]&=8191;n[9]-=8192;let o=(i^1)-1;for(let a=0;a<10;a++)n[a]&=o;o=~o;for(let a=0;a<10;a++)e[a]=e[a]&o|n[a];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let s=e[0]+r[0];e[0]=s&65535;for(let a=1;a<8;a++)s=(e[a]+r[a]|0)+(s>>>16)|0,e[a]=s&65535}update(e){kj(this);let{buffer:r,blockLen:n}=this;e=GT(e);let i=e.length;for(let o=0;o>>0,e[o++]=n[s]>>>8;return e}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}};function XQe(t){let e=(n,i)=>t(i).update(GT(n)).digest(),r=t(new Uint8Array(32));return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}var kge=XQe(t=>new hF(t));f();var Dge=t=>Uint8Array.from(t.split("").map(e=>e.charCodeAt(0))),QQe=Dge("expand 16-byte k"),eet=Dge("expand 32-byte k"),tet=jh(QQe),Bge=jh(eet),iBt=Bge.slice();function Qe(t,e){return t<>>32-e}function pF(t){return t.byteOffset%4===0}var Wk=64,ret=16,Mge=2**32-1,Rge=new Uint32Array;function net(t,e,r,n,i,o,s,a){let d=i.length,u=new Uint8Array(Wk),c=jh(u),l=pF(i)&&pF(o),p=l?jh(i):Rge,m=l?jh(o):Rge;for(let g=0;g=Mge)throw new Error("arx: counter overflow");let v=Math.min(Wk,d-g);if(l&&v===Wk){let x=g/4;if(g%4!==0)throw new Error("arx: invalid block position");for(let S=0,P;S{ao(a),ao(d),ao(u);let p=u.length;if(c||(c=new Uint8Array(p)),ao(c),l6(l),l<0||l>=Mge)throw new Error("arx: counter overflow");if(c.length0;)m.pop().fill(0);return c}}function $ge(t,e,r,n,i,o=20){let s=t[0],a=t[1],d=t[2],u=t[3],c=e[0],l=e[1],p=e[2],m=e[3],g=e[4],v=e[5],x=e[6],S=e[7],P=i,A=r[0],$=r[1],j=r[2],q=s,F=a,K=d,W=u,L=c,I=l,T=p,B=m,h=g,y=v,w=x,E=S,_=P,b=A,C=$,N=j;for(let U=0;U{t.update(e);let r=e.length%16;r&&t.update(aet.subarray(r))},cet=new Uint8Array(32);function Cge(t,e,r,n,i){let o=t(e,r,cet),s=kge.create(o);i&&Oge(s,i),Oge(s,n);let a=new Uint8Array(16),d=xde(a);Dj(d,0,BigInt(i?i.length:0),!0),Dj(d,8,BigInt(n.length),!0),s.update(a);let u=s.digest();return o.fill(0),u}var jge=t=>(e,r,n)=>(ao(e,32),ao(r),{encrypt:(o,s)=>{let a=o.length,d=a+16;s?ao(s,d):s=new Uint8Array(d),t(e,r,o,s,1);let u=Cge(t,e,r,s.subarray(0,-16),n);return s.set(u,a),s},decrypt:(o,s)=>{let a=o.length,d=a-16;if(a<16)throw new Error("encrypted data must be at least 16 bytes");s?ao(s,d):s=new Uint8Array(d);let u=o.subarray(0,-16),c=o.subarray(-16),l=Cge(t,e,r,u,n);if(!Sde(c,l))throw new Error("invalid tag");return t(e,r,u,s,1),s}}),lBt=Rj({blockSize:64,nonceLength:12,tagLength:16},jge(oet)),p3=Rj({blockSize:64,nonceLength:24,tagLength:16},jge(set));f();f();f();f();var det=gt(TI(),1);f();f();function Nge(t){return t.byteOffset!==0||t.byteLength!==t.buffer.byteLength}function Uge(t){return typeof t!="object"||t===null?!1:typeof t[Symbol.asyncIterator]=="function"}function m3(t){let r=Object.prototype.toString.call(t).match(/\s([a-zA-Z0-9]+)/),[n,i]=r;return i}var y3=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},qge=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,d){s=t[o](s),i(a,d,s.done,s.value)})}}function i(o,s,a,d){Promise.resolve(d).then(function(u){o({value:u,done:a})},s)}},Hk=new TextEncoder,ib=new TextDecoder,ji=class t{constructor(e,r){this.data=e,this.format=r}static arrayBuffer(e){return new t(e,"ArrayBuffer")}static asyncIterable(e){if(!Uge(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 Za.baseDecode(this.data).buffer;case"Base64Url":return ga.baseDecode(this.data).buffer;case"BufferSource":{if(m3(this.data)==="ArrayBuffer")return this.data;if(ArrayBuffer.isView(this.data))return Nge(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 y3(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 RB.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 Za.baseEncode(e)}case"Multibase":return this.data.substring(1);case"Uint8Array":return Za.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 ga.baseEncode(e)}case"BufferSource":{let e=this.toUint8Array();return ga.baseEncode(e)}case"Object":{let e=JSON.stringify(this.data),r=Hk.encode(e);return ga.baseEncode(r)}case"String":{let e=Hk.encode(this.data);return ga.baseEncode(e)}case"Uint8Array":return ga.baseEncode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Base64Url is not supported.`)}}toBlobAsync(){var e,r,n,i;return y3(this,void 0,void 0,function*(){switch(this.format){case"AsyncIterable":{let d=[];try{for(var o=!0,s=qge(this.data),a;a=yield s.next(),e=a.done,!e;o=!0){i=a.value,o=!1;let c=i;d.push(c)}}catch(c){r={error:c}}finally{try{!o&&!e&&(n=s.return)&&(yield n.call(s))}finally{if(r)throw r.error}}return new Blob(d)}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{var o,s;n.push(...(s=(o=t[i])===null||o===void 0?void 0:o.filter(yF))!==null&&s!==void 0?s:[])}),n}function Kge({didDocument:t}){let r=gF({didDocument:t}).map(n=>n.type);return[...new Set(r)]}function Fge({didDocument:t,methodId:e}){let r=[];return Object.keys(Tv).forEach(n=>{if(Array.isArray(t[n])){let i=t[n],o=nd(e);i.some(a=>{let d=nd(a)===o,u=yF(a)&&nd(a.id)===o;return d||u})&&r.push(n)}}),r}function yF(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 vF({keyBytes:t,multicodecCode:e,multicodecName:r}){let n=ua.addPrefix({code:e,data:t,name:r}),i=ji.uint8Array(n).toBase58Btc();return ji.base58Btc(i).toMultibase()}function bF({multibaseKeyId:t}){try{let e=ji.multibase(t).toBase58Btc(),r=ji.base58Btc(e).toUint8Array(),{code:n,data:i,name:o}=ua.removePrefix({prefixedData:r});return{keyBytes:i,multicodecCode:n,multicodecName:o}}catch{throw new at(tt.InvalidDid,`Invalid multibase identifier: ${t}`)}}var v3=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},pc=class t{constructor({uri:e,document:r,metadata:n,keyManager:i}){this.uri=e,this.document=r,this.metadata=n,this.keyManager=i}export(){return v3(this,void 0,void 0,function*(){if(!(Array.isArray(this.document.verificationMethod)&&this.document.verificationMethod.length>0))throw new Error(`DID document for '${this.uri}' is missing verification methods`);let e={uri:this.uri,document:this.document,metadata:this.metadata};if("exportKey"in this.keyManager&&typeof this.keyManager.exportKey=="function"){let r=[];for(let n of this.document.verificationMethod){if(!n.publicKeyJwk)throw new Error(`Verification method '${n.id}' does not contain a public key in JWK format`);let i=yield this.keyManager.getKeyUri({key:n.publicKeyJwk}),o=yield this.keyManager.exportKey({keyUri:i});r.push(Object.assign({},o))}e.privateKeys=r}return e})}getSigner(e){return v3(this,void 0,void 0,function*(){var r;let n=(r=this.document.verificationMethod)===null||r===void 0?void 0:r.find(d=>{var u,c;return nd(d.id)===((u=nd(e?.methodId))!==null&&u!==void 0?u:nd((c=this.document.assertionMethod)===null||c===void 0?void 0:c[0]))});if(!(n&&n.publicKeyJwk))throw new at(tt.InternalError,"A verification method intended for signing could not be determined from the DID Document");let i=yield this.keyManager.getKeyUri({key:n.publicKeyJwk}),o=yield this.keyManager.getPublicKey({keyUri:i}),s=this.keyManager;return{algorithm:zk.getJoseSignatureAlgorithmFromPublicKey(o),keyId:n.id,sign(d){return v3(this,arguments,void 0,function*({data:u}){return yield s.sign({data:u,keyUri:i})})},verify(d){return v3(this,arguments,void 0,function*({data:u,signature:c}){return yield s.verify({data:u,key:o,signature:c})})}}})}static import(e){return v3(this,arguments,void 0,function*({portableDid:r,keyManager:n=new da}){var i;let o=gF({didDocument:r.document});if(o.length===0)throw new at(tt.InvalidDidDocument,"At least one verification method is required but 0 were given");for(let a of(i=r.privateKeys)!==null&&i!==void 0?i:[])yield n.importKey({key:a});for(let a of o){if(!a.publicKeyJwk)throw new Error(`Verification method '${a.id}' does not contain a public key in JWK format`);let d=yield n.getKeyUri({key:a.publicKeyJwk});yield n.getPublicKey({keyUri:d})}return new t({uri:r.uri,document:r.document,metadata:r.metadata,keyManager:n})})}};f();f();f();f();f();var wF="0123456789abcdef",Wge=[],zge=[];for(let t=0;t<256;t++)Wge[t]=wF[t>>4&15]+wF[t&15],t<16&&(t<10?zge[48+t]=t:zge[87+t]=t);var _F=t=>{let e=t.length,r="",n=0;for(;n{let r=t.length||0;if(!e){let s=r;for(;s--;)e+=t[s].length}let n=new Uint8Array(e),i=e,o=r;for(;o--;)i-=t[o].length,n.set(t[o],i);return n};f();var Vge="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",met=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(b3=0;b3e?new TextDecoder(e).decode(t):yet.decode(t),get=new TextEncoder,ru=t=>get.encode(t);var Gge=typeof window<"u"?window:self,Jge=Gge.crypto||Gge.msCrypto||{},Z7t=Jge.subtle||Jge.webkitSubtle;f();function W2(t){let e=t<0?1:0;return t=Math.abs(Number(t||1)),Math.floor(Math.log10(t))+1+e}function Vk(t){return ArrayBuffer.isView(t)?"arraybufferview":Array.isArray(t)?"array":t instanceof Number?"number":t instanceof Boolean?"boolean":t instanceof Set?"set":t instanceof Map?"map":t instanceof String?"string":t instanceof ArrayBuffer?"arraybuffer":typeof t}function en(t,e,r){let n=[],i=null;return en._encode(n,t),i=Hge(n),en.bytes=i.length,ArrayBuffer.isView(e)?(e.set(i,r),e):i}en.bytes=-1;en._floatConversionDetected=!1;en._encode=function(t,e){if(e!=null)switch(Vk(e)){case"object":en.dict(t,e);break;case"map":en.dictMap(t,e);break;case"array":en.list(t,e);break;case"set":en.listSet(t,e);break;case"string":en.string(t,e);break;case"number":en.number(t,e);break;case"boolean":en.number(t,e);break;case"arraybufferview":en.buffer(t,new Uint8Array(e.buffer,e.byteOffset,e.byteLength));break;case"arraybuffer":en.buffer(t,new Uint8Array(e));break}};var Gk=new Uint8Array([101]),Zge=new Uint8Array([100]),Yge=new Uint8Array([108]);en.buffer=function(t,e){t.push(ru(e.length+":"),e)};en.string=function(t,e){t.push(ru(ru(e).byteLength+":"+e))};en.number=function(t,e){if(Number.isInteger(e))return t.push(ru("i"+BigInt(e)+"e"));let r=2147483648,n=e/r<<0,i=e%r<<0,o=n*r+i;t.push(ru("i"+o+"e")),o!==e&&!en._floatConversionDetected&&(en._floatConversionDetected=!0,console.warn('WARNING: Possible data corruption detected with value "'+e+'":','Bencoding only defines support for integers, value was converted to "'+o+'"'),console.trace())};en.dict=function(t,e){t.push(Zge);let r=0,n,i=Object.keys(e).sort(),o=i.length;for(;r=48){n=n*10+(s-48);continue}if(!(o===e&&s===43)){if(o===e&&s===45){i=-1;continue}if(s===46)break;throw new Error("not a number: buffer["+o+"] = "+s)}}return n*i}function Bt(t,e,r,n){return t==null||t.length===0?null:(typeof e!="number"&&n==null&&(n=e,e=void 0),typeof r!="number"&&n==null&&(n=r,r=void 0),Bt.position=0,Bt.encoding=n||null,Bt.data=ArrayBuffer.isView(t)?new Uint8Array(t.slice(e,r)):ru(t),Bt.bytes=Bt.data.length,Bt.next())}Bt.bytes=0;Bt.position=0;Bt.data=null;Bt.encoding=null;Bt.next=function(){switch(Bt.data[Bt.position]){case wet:return Bt.dictionary();case _et:return Bt.list();case vet:return Bt.integer();default:return Bt.buffer()}};Bt.find=function(t){let e=Bt.position,r=Bt.data.length,n=Bt.data;for(;eket.test(t),encode(t,e,r){r=~~r,e=e||new Uint8Array(r+4);let n=t.length,i=0;for(let o=0;ot.length>0&&Ret.test(t),encode(t,e,r){r=~~r;let n=r+16,i=-1,o=0,s=0,a=!0,d=!1;e=e||new Uint8Array(r+16);for(let u=0;u>8),r=97?c-=87:c>=65?c-=55:(c-=48,s=s*10+c),o=(o<<4)+c)}if(a===!1)d===!0?(r>8),r=i+2;u--)e[u]=e[u-2];e[i]=0,e[i+1]=0,i=r}if(i!==r&&i!==-1)for(r>n-2&&(r=n-2);n>i;)e[--n]=ri?e[--r]:0;else for(;r=56320||(t.charCodeAt(o)&64512)!==56320?e+=3:(n=o,e+=4)}}return e}function G2(t,e,r){let n=t.length;r==null&&(r=0),e===void 0&&(e=new Uint8Array(IF(t)+r));let i=r;for(let o=0;o>6,e[i++]=128|s&63;else if((s&63488)!==55296)e[i++]=224|(s&61440)>>12,e[i++]=128|(s&4032)>>6,e[i++]=128|s&63;else{let a=o+1;if(a===n||s>=56320)e[i++]=239,e[i++]=191,e[i++]=189;else{let d=t.charCodeAt(a);(d&64512)!==56320?(e[i++]=239,e[i++]=191,e[i++]=189):(o=a,s=65536|(s&1023)<<10|d&1023,e[i++]=240|(s&1835008)>>18,e[i++]=128|(s&258048)>>12,e[i++]=128|(s&4032)>>6,e[i++]=128|s&63)}}}return G2.bytes=i-r,e}G2.bytes=0;function J2(t,e,r){let n="";e==null&&(e=0),r==null&&(r=t.length);for(let i=e;i191&&o<224)s=(o&31)<<6|t[i++]&63;else if(o>239&&o<365){s=((o&7)<<18|(t[i++]&63)<<12|(t[i++]&63)<<6|t[i++]&63)-65536;let a=55296|s>>10&1023;n+=String.fromCharCode(a),s=56320|s&1023}else s=(o&15)<<12|(t[i++]&63)<<6|t[i++]&63;n+=String.fromCharCode(s)}return J2.bytes=r-e,n}J2.bytes=0;var Wy=t=>t instanceof Uint8Array;function wp(t){return typeof t=="string"?IF(t):t.byteLength}function Zk(t){return t instanceof Uint8Array?t:Array.isArray(t)?new Uint8Array(t):G2(t)}function Yk(t,e,r){if(typeof e!="string")throw new Error("unknown input type");return G2(e,t,r),G2.bytes}var _3={},cve=new Array(255);for(let t=0;t<=15;t+=1){let e=t.toString(16),r=e.toUpperCase();for(let n=0;n<=15;n+=1){let i=n.toString(16),o=i.toUpperCase(),s=t<<4|n,a=`${e}${i}`;cve[s]=a,_3[a]=s,_3[`${r}${i}`]=s,_3[`${e}${o}`]=s,_3[`${r}${o}`]=s}}function dve(t,e,r){let n="";for(let i=e;i>>1}function uve(t,e,r,n){let i=0;for(;rt[e]*Net+t[e+1]*Uet+t[e+2]*qet+t[e+3],sr=(t,e)=>t[e]<<8|t[e+1],Of=(t,e,r)=>(e=+e,t[r+3]=e,e=e>>>8,t[r+2]=e,e=e>>>8,t[r+1]=e,e=e>>>8,t[r]=e,r+4),bt=(t,e,r)=>(t[r]=e>>8,t[r+1]=e&255,r+2);function mc(t,e,r,n,i){return r<0&&(n-=r,r=0),n<0&&(n=0),i<0?new Uint8Array(0):r>=e.length||n>=i?0:Let(t,e,r,n,i)}function Let(t,e,r,n,i){i-n>e.length-r&&(i=n+e.length-r);let o=i-n,s=t.length-n;return o>s&&(o=s),(n!==0||it)}}var ot=Bn({encode(t,e,r){e||(e=new Uint8Array(ot.encodingLength(t))),r||(r=0);let n=r,i=t.replace(/^\.|\.$/gm,"");if(i.length){let o=i.split(".");for(let s=0;s=t.length)throw new Error("Cannot decode name (buffer overflow)");let a=t[e++];if(o+=s?0:1,a===0)break;if(a&192)if((a&192)===192){if(e+1>t.length)throw new Error("Cannot decode name (buffer overflow)");let d=sr(t,e-1)-49152;if(d>=n)throw new Error("Cannot decode name (bad pointer)");e=d,n=d,o+=s?0:1,s=!0}else throw new Error("Cannot decode name (bad label)");else{if(e+a>t.length)throw new Error("Cannot decode name (buffer overflow)");if(i+=a+1,i>254)throw new Error("Cannot decode name (name too long)");r.push(J2(t,e,e+a)),e+=a,o+=s?0:a}}return ot.decode.bytes=o,r.length===0?".":r.join(".")},encodingLength(t){return t==="."||t===".."?1:wp(t.replace(/^\.|\.$/gm,""))+2}}),bo=Bn({encode(t,e,r){e||(e=new Uint8Array(bo.encodingLength(t))),r||(r=0);let n=Yk(e,t,r+1);return e[r]=n,bo.encode.bytes=n+1,e},decode(t,e){e||(e=0);let r=t[e],n=J2(t,e+1,e+1+r);return bo.decode.bytes=r+1,n},encodingLength(t){return wp(t)+1}}),Z2=Bn({bytes:12,encode(t,e,r){e||(e=new Uint8Array(Z2.encodingLength(t))),r||(r=0);let n=(t.flags||0)&32767,i=t.type==="response"?lve:Fet;return bt(e,t.id||0,r),bt(e,n|i,r+2),bt(e,t.questions.length,r+4),bt(e,t.answers.length,r+6),bt(e,t.authorities.length,r+8),bt(e,t.additionals.length,r+10),e},decode(t,e){if(e||(e=0),t.length<12)throw new Error("Header must be 12 bytes");let r=sr(t,e+2);return{id:sr(t,e),type:r&lve?"response":"query",flags:r&32767,flag_qr:(r>>15&1)===1,opcode:sve(r>>11&15),flag_aa:(r>>10&1)===1,flag_tc:(r>>9&1)===1,flag_rd:(r>>8&1)===1,flag_ra:(r>>7&1)===1,flag_z:(r>>6&1)===1,flag_ad:(r>>5&1)===1,flag_cd:(r>>4&1)===1,rcode:ove(r&15),questions:new Array(sr(t,e+4)),answers:new Array(sr(t,e+6)),authorities:new Array(sr(t,e+8)),additionals:new Array(sr(t,e+10))}},encodingLength(){return 12}}),Qk=Bn({encode(t,e,r){e||(e=new Uint8Array(Qk.encodingLength(t))),r||(r=0);let n=t.length;return bt(e,n,r),mc(t,e,r+2,0,n),Qk.encode.bytes=n+2,e},decode(t,e){e||(e=0);let r=sr(t,e),n=t.slice(e+2,e+2+r);return Qk.decode.bytes=r+2,n},encodingLength(t){return t.length+2}}),eR=Bn({encode(t,e,r){return e||(e=new Uint8Array(eR.encodingLength(t))),r||(r=0),ot.encode(t,e,r+2),bt(e,ot.encode.bytes,r),eR.encode.bytes=ot.encode.bytes+2,e},decode(t,e){e||(e=0);let r=sr(t,e),n=ot.decode(t,e+2);return eR.decode.bytes=r+2,n},encodingLength(t){return ot.encodingLength(t)+2}}),tR=Bn({encode(t,e,r){e||(e=new Uint8Array(tR.encodingLength(t))),r||(r=0);let n=r;return r+=2,ot.encode(t.mname,e,r),r+=ot.encode.bytes,ot.encode(t.rname,e,r),r+=ot.encode.bytes,Of(e,t.serial||0,r),r+=4,Of(e,t.refresh||0,r),r+=4,Of(e,t.retry||0,r),r+=4,Of(e,t.expire||0,r),r+=4,Of(e,t.minimum||0,r),r+=4,bt(e,r-n-2,n),tR.encode.bytes=r-n,e},decode(t,e){e||(e=0);let r=e,n={};return e+=2,n.mname=ot.decode(t,e),e+=ot.decode.bytes,n.rname=ot.decode(t,e),e+=ot.decode.bytes,n.serial=Mf(t,e),e+=4,n.refresh=Mf(t,e),e+=4,n.retry=Mf(t,e),e+=4,n.expire=Mf(t,e),e+=4,n.minimum=Mf(t,e),e+=4,tR.decode.bytes=e-r,n},encodingLength(t){return 22+ot.encodingLength(t.mname)+ot.encodingLength(t.rname)}}),rR=Bn({encode(t,e,r){Array.isArray(t)||(t=[t]);for(let i=0;i0;){let o=t[e++];if(--n,nnew Uint8Array(t),_p=Bn({encode(t,e,r){e||(e=new Uint8Array(_p.encodingLength(t))),r||(r=0);let n=r,i=PF(t.code);if(bt(e,i,r),r+=2,t.data)bt(e,t.data.length,r),r+=2,mc(t.data,e,r),r+=t.data.length;else switch(i){case 8:{let o=t.sourcePrefixLength||0,s=t.family||rve(t.ip,fve),a=nve(t.ip,fve),d=Math.ceil(o/8);bt(e,d+4,r),r+=2,bt(e,s,r),r+=2,e[r++]=o,e[r++]=t.scopePrefixLength||0,mc(a,e,r,0,d),r+=d}break;case 11:t.timeout?(bt(e,2,r),r+=2,bt(e,t.timeout,r),r+=2):(bt(e,0,r),r+=2);break;case 12:{let o=t.length||0;bt(e,o,r),r+=2,e.fill(0,r,r+o),r+=o}break;case 14:{let o=t.tags.length*2;bt(e,o,r),r+=2;for(let s of t.tags)bt(e,s,r),r+=2}break;default:throw new Error(`Unknown roption code: ${t.code}`)}return _p.encode.bytes=r-n,e},decode(t,e){e||(e=0);let r={};r.code=sr(t,e),r.type=ave(r.code),e+=2;let n=sr(t,e);switch(e+=2,r.data=t.slice(e,e+n),r.code){case 8:r.family=sr(t,e),e+=2,r.sourcePrefixLength=t[e++],r.scopePrefixLength=t[e++];{let i=new Uint8Array(r.family===1?4:16);mc(t,i,0,e,e+n-4),r.ip=ive(i)}break;case 11:n>0&&(r.timeout=sr(t,e),e+=2);break;case 14:r.tags=[];for(let i=0;i0;)n[o++]=_p.decode(t,e),e+=_p.decode.bytes,i-=_p.decode.bytes;return Vy.decode.bytes=e-r,n},encodingLength(t){return 2+X2(t||[],_p)}}),Cf=Bn({encode(t,e,r){e||(e=new Uint8Array(Cf.encodingLength(t))),r||(r=0);let n=r,i=t.key;if(!Wy(i))throw new Error("Key must be a Buffer");return r+=2,bt(e,t.flags,r),r+=2,e[r]=Cf.PROTOCOL_DNSSEC,r+=1,e[r]=t.algorithm,r+=1,mc(i,e,r,0,i.length),r+=i.length,Cf.encode.bytes=r-n,bt(e,Cf.encode.bytes-2,n),e},decode(t,e){e||(e=0);let r=e,n={},i=sr(t,e);if(e+=2,n.flags=sr(t,e),e+=2,t[e]!==Cf.PROTOCOL_DNSSEC)throw new Error("Protocol must be 3");return e+=1,n.algorithm=t[e],e+=1,n.key=t.slice(e,r+i+2),e+=n.key.length,Cf.decode.bytes=e-r,n},encodingLength(t){return 6+wp(t.key)}});Cf.PROTOCOL_DNSSEC=3;Cf.ZONE_KEY=128;Cf.SECURE_ENTRYPOINT=32768;var x3=Bn({encode(t,e,r){e||(e=new Uint8Array(x3.encodingLength(t))),r||(r=0);let n=r,i=t.signature;if(!Wy(i))throw new Error("Signature must be a Buffer");return r+=2,bt(e,V2(t.typeCovered),r),r+=2,e[r]=t.algorithm,r+=1,e[r]=t.labels,r+=1,Of(e,t.originalTTL,r),r+=4,Of(e,t.expiration,r),r+=4,Of(e,t.inception,r),r+=4,bt(e,t.keyTag,r),r+=2,ot.encode(t.signersName,e,r),r+=ot.encode.bytes,mc(i,e,r,0,i.length),r+=i.length,x3.encode.bytes=r-n,bt(e,x3.encode.bytes-2,n),e},decode(t,e){e||(e=0);let r=e,n={},i=sr(t,e);return e+=2,n.typeCovered=w3(sr(t,e)),e+=2,n.algorithm=t[e],e+=1,n.labels=t[e],e+=1,n.originalTTL=Mf(t,e),e+=4,n.expiration=Mf(t,e),e+=4,n.inception=Mf(t,e),e+=4,n.keyTag=sr(t,e),e+=2,n.signersName=ot.decode(t,e),e+=ot.decode.bytes,n.signature=t.slice(e,r+i+2),e+=n.signature.length,x3.decode.bytes=e-r,n},encodingLength(t){return 20+ot.encodingLength(t.signersName)+wp(t.signature)}}),E3=Bn({encode(t,e,r){e||(e=new Uint8Array(E3.encodingLength(t))),r||(r=0);let n=r;return r+=2,ot.encode(t.mbox||".",e,r),r+=ot.encode.bytes,ot.encode(t.txt||".",e,r),r+=ot.encode.bytes,E3.encode.bytes=r-n,bt(e,E3.encode.bytes-2,n),e},decode(t,e){e||(e=0);let r=e,n={};return e+=2,n.mbox=ot.decode(t,e)||".",e+=ot.decode.bytes,n.txt=ot.decode(t,e)||".",e+=ot.decode.bytes,E3.decode.bytes=e-r,n},encodingLength(t){return 2+ot.encodingLength(t.mbox||".")+ot.encodingLength(t.txt||".")}}),id=Bn({encode(t,e,r){e||(e=new Uint8Array(id.encodingLength(t))),r||(r=0);let n=r,i=[];for(let o=0;o>8]===void 0&&(i[s>>8]=[]),i[s>>8][s>>3&31]|=1<<7-(s&7)}for(let o=0;o>8]=Math.max(e[i>>8]||0,i&255)}let r=0;for(let n=0;n>15&1)===1,r.options=Vy.decode(t,e+8),e+=8+Vy.decode.bytes;else{let i=sr(t,e+2);r.ttl=Mf(t,e+4),r.class=AF(i&zet),r.flush=!!(i&DF);let o=RF(r.type);r.data=o.decode(t,e+8),e+=8+o.decode.bytes}return nu.decode.bytes=e-n,r},encodingLength(t){let e=t.data!==null&&t.data!==void 0?t.data:t.options;return ot.encodingLength(t.name)+8+RF(t.type).encodingLength(e)}}),e_=Bn({encode(t,e,r){e||(e=new Uint8Array(e_.encodingLength(t))),r||(r=0);let n=r;return ot.encode(t.name,e,r),r+=ot.encode.bytes,bt(e,V2(t.type),r),r+=2,bt(e,TF(t.class===void 0?"IN":t.class),r),r+=2,e_.encode.bytes=r-n,t},decode(t,e){e||(e=0);let r=e,n={};return n.name=ot.decode(t,e),e+=ot.decode.bytes,n.type=w3(sr(t,e)),e+=2,n.class=AF(sr(t,e)),e+=2,!!(n.class&hve)&&(n.class&=Wet),e_.decode.bytes=e-r,n},encodingLength(t){return ot.encodingLength(t.name)+4}});var lR=1024;var Bs={encode:function(t,e,r){let n=!e;n&&(e=new Uint8Array(Het(t))),r||(r=0);let i=r;return t.questions||(t.questions=[]),t.answers||(t.answers=[]),t.authorities||(t.authorities=[]),t.additionals||(t.additionals=[]),Z2.encode(t,e,r),r+=Z2.encode.bytes,r=P3(t.questions,e_,e,r),r=P3(t.answers,nu,e,r),r=P3(t.authorities,nu,e,r),r=P3(t.additionals,nu,e,r),Bs.encode.bytes=r-i,n&&ob.bytes!==e.length?e.slice(0,ob.bytes):e},decode:function(t,e){e||(e=0);let r=e,n=Z2.decode(t,e);return e+=Z2.decode.bytes,e=Xk(n.questions,e_,t,e),e=Xk(n.answers,nu,t,e),e=Xk(n.authorities,nu,t,e),e=Xk(n.additionals,nu,t,e),Bs.decode.bytes=e-r,n},encodingLength:function(t){return Z2.encodingLength(t)+X2(t.questions||[],e_)+X2(t.answers||[],nu)+X2(t.authorities||[],nu)+X2(t.additionals||[],nu)}};Bs.encode.bytes=0;Bs.decode.bytes=0;function cR(t,e){if(t.questions)throw new Error("Only one .question object expected instead of a .questions array!");let r=Object.assign({type:e},t);return r.question&&(r.questions=[r.question],delete r.question),r}var dR={encode:function(t,e,r){return e=Bs.encode(cR(t,"query"),e,r),dR.encode.bytes=Bs.encode.bytes,e},decode:function(t,e){let r=Bs.decode(t,e);return dR.decode.bytes=Bs.decode.bytes,r.questions&&(r.question=r.questions[0],delete r.questions),r},encodingLength:function(t){return Bs.encodingLength(cR(t,"query"))}};dR.encode.bytes=0;dR.decode.bytes=0;var uR={encode:function(t,e,r){return e=Bs.encode(cR(t,"response"),e,r),uR.encode.bytes=Bs.encode.bytes,e},decode:function(t,e){let r=Bs.decode(t,e);return uR.decode.bytes=Bs.decode.bytes,r.questions&&(r.question=r.questions[0],delete r.questions),r},encodingLength:function(t){return Bs.encodingLength(cR(t,"response"))}};uR.encode.bytes=0;uR.decode.bytes=0;var ob=Bs.encode,t_=Bs.decode,Het=Bs.encodingLength;function mve(t){let e=ob(t),r=new Uint8Array(2+e.byteLength);return bt(r,e.byteLength),mc(e,r,2,0,e.length),mve.bytes=r.byteLength,r}mve.bytes=0;function yve(t){let e=sr(t,0);if(t.byteLength!(j.algorithm in _ve)))throw new Error("One or more verification method algorithms are not supported");let g=(i=r.verificationMethods)===null||i===void 0?void 0:i.filter(j=>"id"in j).map(j=>j.id);if(g&&g.length!==new Set(g).size)throw new Error("One or more verification method IDs are not unique");if(!((o=r.services)===null||o===void 0)&&o.some(j=>!j.id||!j.type||!j.serviceEndpoint))throw new Error("One or more services are missing required properties");let v=yield e.generateKey({algorithm:"Ed25519"}),x=yield e.getPublicKey({keyUri:v}),S=yield zo.identityKeyToIdentifier({identityKey:x}),P=Object.assign(Object.assign({id:S},r.alsoKnownAs&&{alsoKnownAs:r.alsoKnownAs}),r.controllers&&{controller:r.controllers}),A=[...(s=r.verificationMethods)!==null&&s!==void 0?s:[]];A?.some(j=>{var q;return((q=j.id)===null||q===void 0?void 0:q.split("#").pop())==="0"})||A.unshift({algorithm:"Ed25519",id:"0",purposes:["authentication","assertionMethod","capabilityDelegation","capabilityInvocation"]});for(let j of A){let q=j.id&&j.id.split("#").pop()==="0"?v:yield e.generateKey({algorithm:j.algorithm}),F=yield e.getPublicKey({keyUri:q}),K=(d=(a=j.id)!==null&&a!==void 0?a:F.kid)!==null&&d!==void 0?d:yield gr({jwk:F});K=`${S}#${nd(K)}`,(u=P.verificationMethod)!==null&&u!==void 0||(P.verificationMethod=[]),P.verificationMethod.push({id:K,type:"JsonWebKey",controller:(c=j.controller)!==null&&c!==void 0?c:S,publicKeyJwk:F});for(let W of(l=j.purposes)!==null&&l!==void 0?l:[])P[W]||(P[W]=[]),P[W].push(K)}(p=r.services)===null||p===void 0||p.forEach(j=>{var q;(q=P.service)!==null&&q!==void 0||(P.service=[]),j.id=`${S}#${j.id.split("#").pop()}`,P.service.push(j)});let $=new pc({uri:S,document:P,metadata:Object.assign({published:!1},r.types&&{types:r.types}),keyManager:e});if(!((m=r.publish)!==null&&m!==void 0)||m){let j=yield t.publish({did:$,gatewayUri:r.gatewayUri});$.metadata=j.didDocumentMetadata}return $})}static import(e){return Wo(this,arguments,void 0,function*({portableDid:r,keyManager:n=new da}){var i;let o=_r.parse(r.uri);if(o?.method!==t.methodName)throw new at(tt.MethodNotSupported,"Method not supported");let s=yield pc.import({portableDid:r,keyManager:n});if(!(!((i=s.document.verificationMethod)===null||i===void 0)&&i.some(a=>{var d;return((d=a.id)===null||d===void 0?void 0:d.split("#").pop())==="0"})))throw new at(tt.InvalidDidDocument,"DID document must contain an Identity Key");return s})}static getSigningMethod(e){return Wo(this,arguments,void 0,function*({didDocument:r,methodId:n="#0"}){var i;let o=_r.parse(r.id);if(o&&o.method!==this.methodName)throw new at(tt.MethodNotSupported,`Method not supported: ${o.method}`);let s=(i=r.verificationMethod)===null||i===void 0?void 0:i.find(a=>{var d,u;return nd(a.id)===((d=nd(n))!==null&&d!==void 0?d:nd((u=r.assertionMethod)===null||u===void 0?void 0:u[0]))});if(!(s&&s.publicKeyJwk))throw new at(tt.InternalError,"A verification method intended for signing could not be determined from the DID Document");return s})}static publish(e){return Wo(this,arguments,void 0,function*({did:r,gatewayUri:n=bve}){return yield hR.put({did:r,gatewayUri:n})})}static resolve(e){return Wo(this,arguments,void 0,function*(r,n={}){var i;let o=(i=n?.gatewayUri)!==null&&i!==void 0?i:bve;try{yield zo.identifierToIdentityKey({didUri:r});let{didDocument:s,didDocumentMetadata:a}=yield hR.get({didUri:r,gatewayUri:o});return Object.assign(Object.assign({},di),{didDocument:s,didDocumentMetadata:a})}catch(s){if(!(s instanceof at))throw new Error(s);return Object.assign(Object.assign({},di),{didResolutionMetadata:Object.assign({error:s.code},s.message&&{errorMessage:s.message})})}})}};sb.methodName="dht";var hR=class t{static get(e){return Wo(this,arguments,void 0,function*({didUri:r,gatewayUri:n}){let i=zo.identifierToIdentityKeyBytes({didUri:r}),o=yield t.pkarrGet({gatewayUri:n,publicKeyBytes:i}),s=yield zo.parseBep44GetMessage({bep44Message:o}),a=yield t.fromDnsPacket({didUri:r,dnsPacket:s});return a.didDocumentMetadata.versionId=o.seq.toString(),a})}static put(e){return Wo(this,arguments,void 0,function*({did:r,gatewayUri:n}){let i=yield t.toDnsPacket({didDocument:r.document,didMetadata:r.metadata,authoritativeGatewayUris:[n]}),o=yield zo.createBep44PutMessage({dnsPacket:i,publicKeyBytes:zo.identifierToIdentityKeyBytes({didUri:r.uri}),signer:yield r.getSigner({methodId:"0"})}),s=yield t.pkarrPut({gatewayUri:n,bep44Message:o});return{didDocument:r.document,didDocumentMetadata:Object.assign(Object.assign({},r.metadata),{published:s,versionId:o.seq.toString()}),didRegistrationMetadata:{}}})}static pkarrGet(e){return Wo(this,arguments,void 0,function*({gatewayUri:r,publicKeyBytes:n}){let i=ji.uint8Array(n).toBase32Z(),o=new URL(i,r).href,s;try{if(s=yield fetch(o,{method:"GET"}),!s.ok)throw new at(tt.NotFound,`Pkarr record not found for: ${i}`)}catch(u){throw u instanceof at?u:new at(tt.InternalError,`Failed to fetch Pkarr record: ${u.message}`)}let a=yield s.arrayBuffer();if(!a)throw new at(tt.NotFound,`Pkarr record not found for: ${i}`);if(a.byteLength<72)throw new at(tt.InvalidDidDocumentLength,`Pkarr response must be at least 72 bytes but got: ${a.byteLength}`);if(a.byteLength>1072)throw new at(tt.InvalidDidDocumentLength,`Pkarr response exceeds 1000 byte limit: ${a.byteLength}`);return{k:n,seq:Number(new DataView(a).getBigUint64(64)),sig:new Uint8Array(a,0,64),v:new Uint8Array(a,72)}})}static pkarrPut(e){return Wo(this,arguments,void 0,function*({gatewayUri:r,bep44Message:n}){let i=ji.uint8Array(n.k).toBase32Z(),o=new URL(i,r).href,s=new Uint8Array(n.v.length+72);s.set(n.sig,0),new DataView(s.buffer).setBigUint64(n.sig.length,BigInt(n.seq)),s.set(n.v,n.sig.length+8);let a;try{a=yield fetch(o,{method:"PUT",headers:{"Content-Type":"application/octet-stream"},body:s})}catch(d){throw new at(tt.InternalError,`Failed to put Pkarr record for identifier ${i}: ${d.message}`)}return a.ok})}static fromDnsPacket(e){return Wo(this,arguments,void 0,function*({didUri:r,dnsPacket:n}){var i,o,s;let a={id:r},d={published:!0},u=new Map;for(let c of(i=n?.answers)!==null&&i!==void 0?i:[]){if(c.type!=="TXT")continue;let l=c.name.split(".")[0].substring(1);switch(!0){case l.startsWith("aka"):{let p=zo.parseTxtDataToString(c.data);a.alsoKnownAs=p.split(qa);break}case l.startsWith("cnt"):{let p=zo.parseTxtDataToString(c.data);a.controller=p.includes(qa)?p.split(qa):p;break}case l.startsWith("k"):{let{id:p,t:m,k:g,c:v,a:x}=zo.parseTxtDataToObject(c.data),S=ji.base64Url(g).toUint8Array(),P=La[Number(m)],A=yield zo.keyConverter(P).bytesToPublicKey({publicKeyBytes:S});A.alg=x||wve[Number(m)];let $=l==="k0"?"0":p!==void 0?p:yield gr({jwk:A});(o=a.verificationMethod)!==null&&o!==void 0||(a.verificationMethod=[]);let j=`${r}#${$}`;a.verificationMethod.push({id:j,type:"JsonWebKey",controller:v??r,publicKeyJwk:A}),u.set(l,j);break}case l.startsWith("s"):{let p=zo.parseTxtDataToObject(c.data),{id:m,t:g,se:v}=p,x=vve(p,["id","t","se"]),S=v.includes(qa)?v.split(qa):[v],P=Object.fromEntries(Object.entries(x).map(([A,$])=>[A,$.includes(qa)?$.split(qa):$]));(s=a.service)!==null&&s!==void 0||(a.service=[]),a.service.push(Object.assign(Object.assign({},P),{id:`${r}#${m}`,type:g,serviceEndpoint:S}));break}case l.startsWith("typ"):{let{id:p}=zo.parseTxtDataToObject(c.data);d.types=p.split(qa).map(m=>Number(m));break}case l.startsWith("did"):{let p=P=>P.split(qa).map(A=>u.get(A)).filter(A=>typeof A=="string"),{auth:m,asm:g,del:v,inv:x,agm:S}=zo.parseTxtDataToObject(c.data);m&&(a.authentication=p(m)),g&&(a.assertionMethod=p(g)),v&&(a.capabilityDelegation=p(v)),x&&(a.capabilityInvocation=p(x)),S&&(a.keyAgreement=p(S));break}}}return{didDocument:a,didDocumentMetadata:d,didResolutionMetadata:{}}})}static toDnsPacket(e){return Wo(this,arguments,void 0,function*({didDocument:r,didMetadata:n,authoritativeGatewayUris:i,previousDidProof:o}){var s,a,d,u,c;let l=[],p=[],m=new Map,g=[],v=[];if(o!==void 0){let{signature:P,previousDid:A}=o;yield zo.validatePreviousDidProof({newDid:r.id,previousDidProof:o}),l.push({type:"TXT",name:"_prv._did.",ttl:Gy,data:`id=${A};s=${P}`})}if(r.alsoKnownAs&&l.push({type:"TXT",name:"_aka._did.",ttl:Gy,data:r.alsoKnownAs.join(qa)}),r.controller){let P=Array.isArray(r.controller)?r.controller.join(qa):r.controller;l.push({type:"TXT",name:"_cnt._did.",ttl:Gy,data:P})}for(let[P,A]of(a=(s=r.verificationMethod)===null||s===void 0?void 0:s.entries())!==null&&a!==void 0?a:[]){let $=`k${P}`;v.push($);let j=A.id.split("#").pop();m.set(j,$);let q=A.publicKeyJwk;if(!(q?.crv&&q.crv in _ve))throw new at(tt.InvalidPublicKeyType,`Verification method '${A.id}' contains an unsupported key type: ${(d=q?.crv)!==null&&d!==void 0?d:"undefined"}`);let F=La[q.crv],K=yield zo.keyConverter(q.crv).publicKeyToBytes({publicKey:q}),W=ji.uint8Array(K).toBase64Url(),L=[`t=${F}`,`k=${W}`];j!=="0"&&(yield gr({jwk:q}))!==j&&L.unshift(`id=${j}`),q.alg!==wve[F]&&L.push(`a=${q.alg}`),A.controller!==r.id&&L.push(`c=${A.controller}`),l.push({type:"TXT",name:`_${$}._did.`,ttl:Gy,data:L.join(fR)})}(u=r.service)===null||u===void 0||u.forEach((P,A)=>{let $=`s${A}`;g.push($);let{id:j,type:q,serviceEndpoint:F}=P,K=vve(P,["id","type","serviceEndpoint"]);j=nd(j),F=Array.isArray(F)?F.join(","):F;let L=Object.entries(Object.assign({id:j,t:q,se:F},K)).map(([T,B])=>`${T}=${B}`).join(fR),I=zo.chunkDataIfNeeded(L);l.push({type:"TXT",name:`_${$}._did.`,ttl:Gy,data:I})});let x=[`v=${Vet}`];if(v.length&&x.push(`vm=${v.join(qa)}`),Object.keys(Tv).forEach(P=>{var A;let $=(A=r[P])===null||A===void 0?void 0:A.map(j=>m.get(j.split("#").pop()));if($){let j=OF[P];x.push(`${j}=${$.join(qa)}`)}}),g.length&&x.push(`svc=${g.join(qa)}`),!((c=n.types)===null||c===void 0)&&c.length){let A=n.types.map($=>typeof $=="string"?MF[$]:$);l.push({type:"TXT",name:"_typ._did.",ttl:Gy,data:`id=${A.join(qa)}`})}l.push({type:"TXT",name:"_did."+t.getUniqueDidSuffix(r.id)+".",ttl:Gy,data:x.join(fR)});for(let P of i||[])p.push({type:"NS",name:"_did."+t.getUniqueDidSuffix(r.id)+".",ttl:Gy,data:P+"."});return{id:0,type:"response",flags:lR,answers:[...l,...p]}})}static getUniqueDidSuffix(e){return e.split(":")[2]}},zo=class t{static createBep44PutMessage(e){return Wo(this,arguments,void 0,function*({dnsPacket:r,publicKeyBytes:n,signer:i}){let o=Math.ceil(Date.now()/1e3),s=ob(r),a=H2.encode({seq:o,v:s}).subarray(1,-1);if(a.length>1e3)throw new at(tt.InvalidDidDocumentLength,`DNS packet exceeds the 1000 byte maximum size: ${a.length} bytes`);let d=yield i.sign({data:a});return{k:n,seq:o,sig:d,v:s}})}static identifierToIdentityKey(e){return Wo(this,arguments,void 0,function*({didUri:r}){let n=t.identifierToIdentityKeyBytes({didUri:r});return yield vo.bytesToPublicKey({publicKeyBytes:n})})}static identifierToIdentityKeyBytes({didUri:e}){let r=_r.parse(e);if(!r)throw new at(tt.InvalidDid,`Invalid DID URI: ${e}`);if(r.method!==sb.methodName)throw new at(tt.MethodNotSupported,`Method not supported: ${r.method}`);let n;try{n=ji.base32Z(r.id).toUint8Array()}catch{throw new at(tt.InvalidPublicKey,"Failed to decode method-specific identifier")}if(n.length!==32)throw new at(tt.InvalidPublicKeyLength,`Invalid public key length: ${n.length}`);return n}static identityKeyToIdentifier(e){return Wo(this,arguments,void 0,function*({identityKey:r}){let n=yield vo.publicKeyToBytes({publicKey:r}),i=ji.uint8Array(n).toBase32Z();return`did:${sb.methodName}:${i}`})}static keyConverter(e){let n={Ed25519:vo,"P-256":{publicKeyToBytes:i=>Wo(this,[i],void 0,function*({publicKey:o}){let s=yield Rs.publicKeyToBytes({publicKey:o});return yield Rs.compressPublicKey({publicKeyBytes:s})}),bytesToPublicKey:Rs.bytesToPublicKey,privateKeyToBytes:Rs.privateKeyToBytes,bytesToPrivateKey:Rs.bytesToPrivateKey},secp256k1:{publicKeyToBytes:i=>Wo(this,[i],void 0,function*({publicKey:o}){let s=yield Fo.publicKeyToBytes({publicKey:o});return yield Fo.compressPublicKey({publicKeyBytes:s})}),bytesToPublicKey:Fo.bytesToPublicKey,privateKeyToBytes:Fo.privateKeyToBytes,bytesToPrivateKey:Fo.bytesToPrivateKey},X25519:z2}[e];if(!n)throw new at(tt.InvalidPublicKeyType,`Unsupported curve: ${e}`);return n}static parseBep44GetMessage(e){return Wo(this,arguments,void 0,function*({bep44Message:r}){let n=yield vo.bytesToPublicKey({publicKeyBytes:r.k}),i=H2.encode({seq:r.seq,v:r.v}).subarray(1,-1);if(!(yield vo.verify({key:n,signature:r.sig,data:i})))throw new at(tt.InvalidSignature,"Invalid signature for DHT BEP44 message");return t_(r.v)})}static parseTxtDataToObject(e){return this.parseTxtDataToString(e).split(fR).reduce((r,n)=>{let[i,o]=n.split("=");return r[i]=o,r},{})}static parseTxtDataToString(e){if(typeof e=="string")return e;if(e instanceof Uint8Array)return ji.uint8Array(e).toString();if(Array.isArray(e))return e.map(r=>this.parseTxtDataToString(r)).join("");throw new at(tt.InternalError,"Pkarr returned DNS TXT record with invalid data type")}static validatePreviousDidProof(e){return Wo(this,arguments,void 0,function*({newDid:r,previousDidProof:n}){let i=yield t.identifierToIdentityKey({didUri:n.previousDid}),o=t.identifierToIdentityKeyBytes({didUri:r}),s=ji.base64Url(n.signature).toUint8Array();if(!(yield vo.verify({key:i,data:o,signature:s})))throw new at(tt.InvalidPreviousDidProof,"The previous DID proof is invalid.")})}static chunkDataIfNeeded(e){if(e.length<=255)return e;let r=[];for(let n=0;n50)throw new xn(Vn.IdTooLong,`Key ID length ${e.length} exceed max allowed length of 50.`);if(!yc.isBase64UrlString(e))throw new xn(Vn.IdNotUsingBase64UrlCharacterSet,`Key ID '${e}' is not a Base64URL string.`)}static validatePublicKeyPurposes(e){if(e===void 0)return;let r=new Set;for(let n of e){if(r.has(n))throw new xn(Vn.PublicKeyPurposeDuplicated,`Public key purpose '${n}' already specified.`);r.add(n)}}};f();var I3=class{};I3.hashAlgorithmInMultihashCode=18;I3.maxCanonicalizedDeltaSizeInBytes=1e3;var Ka=I3;f();var Sve=gt(Eve(),1);var ul=class t{static canonicalizeAsBytes(e){let r=t.removeAllUndefinedProperties(e),n=Sve.default(r);return yc.stringToBytes(n)}static removeAllUndefinedProperties(e){for(let r in e)typeof e[r]=="object"?t.removeAllUndefinedProperties(e[r]):e[r]===void 0&&delete e[r];return e}};f();var k3=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Ho=class t{static hash(e,r){return k3(this,void 0,void 0,function*(){let n;switch(r){case 18:n=(yield Cx.digest(e)).bytes;break;default:throw new xn(Vn.MultihashUnsupportedHashAlgorithm,`Hash algorithm defined in multihash code ${r} is not supported.`)}return n})}static hashAsNonMultihashBytes(e,r){return k3(this,void 0,void 0,function*(){let n;switch(r){case 18:n=yield Cx.encode(e);break;default:throw new xn(Vn.MultihashUnsupportedHashAlgorithm,`Hash algorithm defined in multihash code ${r} is not supported.`)}return n})}static canonicalizeThenHashThenEncode(e,r){return k3(this,void 0,void 0,function*(){let n=ul.canonicalizeAsBytes(e);return yield t.hashThenEncode(n,r)})}static canonicalizeThenDoubleHashThenEncode(e,r){return k3(this,void 0,void 0,function*(){let n=ul.canonicalizeAsBytes(e),i=yield t.hashAsNonMultihashBytes(n,r);return yield t.hashThenEncode(i,r)})}static hashThenEncode(e,r){return k3(this,void 0,void 0,function*(){let n=yield t.hash(e,r);return yc.encode(n)})}static validateEncodedHashComputedUsingSupportedHashAlgorithm(e,r){let n,i=yc.decodeAsBytes(e,r);try{n=I8(i)}catch{throw new xn(Vn.MultihashStringNotAMultihash,`Given ${r} string '${e}' is not a multihash after decoding.`)}let o=Ka.hashAlgorithmInMultihashCode;if(o!==n.code)throw new xn(Vn.MultihashUnsupportedHashAlgorithm,`Given ${r} uses unsupported multihash algorithm with code ${n.code}, should use ${o} or change IonSdkConfig to desired hashing algorithm.`)}};f();var $F;(function(t){t.Create="create",t.Update="update",t.Deactivate="deactivate",t.Recover="recover"})($F||($F={}));var R3=$F;f();var jF;(function(t){t.Replace="replace",t.AddPublicKeys="add-public-keys",t.RemovePublicKeys="remove-public-keys",t.AddServices="add-services",t.RemoveServices="remove-services"})(jF||(jF={}));var ab=jF;var pR=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},$f=class t{static createCreateRequest(e){return pR(this,void 0,void 0,function*(){let r=e.recoveryKey,n=e.updateKey,i=e.document.publicKeys,o=e.document.services;wo.validateEs256kOperationKey(r,od.Public),wo.validateEs256kOperationKey(n,od.Public),t.validateDidDocumentKeys(i),t.validateServices(o);let s=Ka.hashAlgorithmInMultihashCode,a=[{action:ab.Replace,document:e.document}],d={updateCommitment:yield Ho.canonicalizeThenDoubleHashThenEncode(n,s),patches:a};t.validateDeltaSize(d);let c={deltaHash:yield Ho.canonicalizeThenHashThenEncode(d,s),recoveryCommitment:yield Ho.canonicalizeThenDoubleHashThenEncode(r,s)};return{type:R3.Create,suffixData:c,delta:d}})}static createDeactivateRequest(e){return pR(this,void 0,void 0,function*(){t.validateDidSuffix(e.didSuffix),wo.validateEs256kOperationKey(e.recoveryPublicKey,od.Public);let r=Ka.hashAlgorithmInMultihashCode,n=yield Ho.canonicalizeThenHashThenEncode(e.recoveryPublicKey,r),i={didSuffix:e.didSuffix,recoveryKey:e.recoveryPublicKey},o=yield e.signer.sign({alg:"ES256K"},i);return{type:R3.Deactivate,didSuffix:e.didSuffix,revealValue:n,signedData:o}})}static createRecoverRequest(e){return pR(this,void 0,void 0,function*(){t.validateDidSuffix(e.didSuffix),wo.validateEs256kOperationKey(e.recoveryPublicKey,od.Public),wo.validateEs256kOperationKey(e.nextRecoveryPublicKey,od.Public),wo.validateEs256kOperationKey(e.nextUpdatePublicKey,od.Public),t.validateDidDocumentKeys(e.document.publicKeys),t.validateServices(e.document.services);let r=Ka.hashAlgorithmInMultihashCode,n=yield Ho.canonicalizeThenHashThenEncode(e.recoveryPublicKey,r),i=[{action:ab.Replace,document:e.document}],o=yield Ho.canonicalizeThenDoubleHashThenEncode(e.nextUpdatePublicKey,r),s={patches:i,updateCommitment:o},a=yield Ho.canonicalizeThenHashThenEncode(s,r),u={recoveryCommitment:yield Ho.canonicalizeThenDoubleHashThenEncode(e.nextRecoveryPublicKey,r),recoveryKey:e.recoveryPublicKey,deltaHash:a},c=yield e.signer.sign({alg:"ES256K"},u);return{type:R3.Recover,didSuffix:e.didSuffix,revealValue:n,delta:s,signedData:c}})}static createUpdateRequest(e){return pR(this,void 0,void 0,function*(){if(t.validateDidSuffix(e.didSuffix),wo.validateEs256kOperationKey(e.updatePublicKey,od.Public),wo.validateEs256kOperationKey(e.nextUpdatePublicKey,od.Public),t.validateServices(e.servicesToAdd),t.validateDidDocumentKeys(e.publicKeysToAdd),e.idsOfServicesToRemove!==void 0)for(let g of e.idsOfServicesToRemove)wo.validateId(g);if(e.idsOfPublicKeysToRemove!==void 0)for(let g of e.idsOfPublicKeysToRemove)wo.validateId(g);let r=[],n=e.servicesToAdd;if(n!==void 0&&n.length>0){let g={action:ab.AddServices,services:n};r.push(g)}let i=e.idsOfServicesToRemove;if(i!==void 0&&i.length>0){let g={action:ab.RemoveServices,ids:i};r.push(g)}let o=e.publicKeysToAdd;if(o!==void 0&&o.length>0){let g={action:ab.AddPublicKeys,publicKeys:o};r.push(g)}let s=e.idsOfPublicKeysToRemove;if(s!==void 0&&s.length>0){let g={action:ab.RemovePublicKeys,ids:s};r.push(g)}let a=Ka.hashAlgorithmInMultihashCode,d=yield Ho.canonicalizeThenHashThenEncode(e.updatePublicKey,a),u=yield Ho.canonicalizeThenDoubleHashThenEncode(e.nextUpdatePublicKey,a),c={patches:r,updateCommitment:u},l=yield Ho.canonicalizeThenHashThenEncode(c,a),p={updateKey:e.updatePublicKey,deltaHash:l},m=yield e.signer.sign({alg:"ES256K"},p);return{type:R3.Update,didSuffix:e.didSuffix,revealValue:d,delta:c,signedData:m}})}static validateDidSuffix(e){Ho.validateEncodedHashComputedUsingSupportedHashAlgorithm(e,"didSuffix")}static validateDidDocumentKeys(e){if(e===void 0)return;let r=new Set;for(let n of e){if(Array.isArray(n.publicKeyJwk))throw new xn(Vn.DidDocumentPublicKeyMissingOrIncorrectType,"DID Document key 'publicKeyJwk' property is not a non-array object.");if(wo.validateId(n.id),r.has(n.id))throw new xn(Vn.DidDocumentPublicKeyIdDuplicated,`DID Document key with ID '${n.id}' already exists.`);r.add(n.id),wo.validatePublicKeyPurposes(n.purposes)}}static validateServices(e){if(e!==void 0&&e.length!==0){let r=new Set;for(let n of e){if(t.validateService(n),r.has(n.id))throw new xn(Vn.DidDocumentServiceIdDuplicated,"Service id has to be unique");r.add(n.id)}}}static validateService(e){wo.validateId(e.id);let r=30;if(e.type.length>r){let n=`Service endpoint type length ${e.type.length} exceeds max allowed length of ${r}.`;throw new xn(Vn.ServiceTypeTooLong,n)}if(Array.isArray(e.serviceEndpoint)){let n="Service endpoint value cannot be an array.";throw new xn(Vn.ServiceEndpointCannotBeAnArray,n)}if(typeof e.serviceEndpoint=="string"&&Ave.parse(e.serviceEndpoint).error!==void 0)throw new xn(Vn.ServiceEndpointStringNotValidUri,`Service endpoint string '${e.serviceEndpoint}' is not a URI.`)}static validateDeltaSize(e){let r=ul.canonicalizeAsBytes(e);if(r.length>Ka.maxCanonicalizedDeltaSizeInBytes){let n=`Delta of ${r.length} bytes exceeded limit of ${Ka.maxCanonicalizedDeltaSizeInBytes} bytes.`;throw new xn(Vn.DeltaExceedsMaximumSize,n)}}};var Tve=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Jy=class t{static createLongFormDid(e){return Tve(this,void 0,void 0,function*(){let r=yield $f.createCreateRequest(e),n=yield t.computeDidUniqueSuffix(r.suffixData),i;Ka.network===void 0||Ka.network==="mainnet"?i=`did:ion:${n}`:i=`did:ion:${Ka.network}:${n}`;let o={suffixData:r.suffixData,delta:r.delta},s=ul.canonicalizeAsBytes(o),a=yc.encode(s);return`${i}:${a}`})}static computeDidUniqueSuffix(e){return Tve(this,void 0,void 0,function*(){let r=ul.canonicalizeAsBytes(e),n=yield Ho.hash(r,Ka.hashAlgorithmInMultihashCode);return yc.encode(n)})}};f();f();var Pve;(function(t){t.Mainnet="mainnet",t.Testnet="test"})(Pve||(Pve={}));f();var Ive;(function(t){t.Authentication="authentication",t.AssertionMethod="assertionMethod",t.CapabilityInvocation="capabilityInvocation",t.CapabilityDelegation="capabilityDelegation",t.KeyAgreement="keyAgreement"})(Ive||(Ive={}));f();var Zy=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},jf;(function(t){t.Ed25519="Ed25519",t.secp256k1="secp256k1",t.secp256r1="secp256r1",t.X25519="X25519"})(jf||(jf={}));var Get={Ed25519:jf.Ed25519,ES256K:jf.secp256k1,ES256:jf.secp256r1,"P-256":jf.secp256r1,secp256k1:jf.secp256k1,secp256r1:jf.secp256r1},kve="https://ion.tbd.engineering",NF=class t extends iu{static create(){return Zy(this,arguments,void 0,function*({keyManager:e=new da,options:r={}}={}){var n,i,o,s,a,d,u;if(!((n=r.verificationMethods)===null||n===void 0)&&n.some(j=>!(j.algorithm in Get)))throw new Error("One or more verification method algorithms are not supported");let c=(i=r.verificationMethods)===null||i===void 0?void 0:i.filter(j=>"id"in j).map(j=>j.id);if(c&&c.length!==new Set(c).size)throw new Error("One or more verification method IDs are not unique");if(!((o=r.services)===null||o===void 0)&&o.some(j=>!j.id||!j.type||!j.serviceEndpoint))throw new Error("One or more services are missing required properties");let l={algorithm:"Ed25519",purposes:["authentication","assertionMethod","capabilityDelegation","capabilityInvocation"]},p=[];for(let j of(s=r.verificationMethods)!==null&&s!==void 0?s:[l]){let q=yield e.generateKey({algorithm:j.algorithm}),F=yield e.getPublicKey({keyUri:q});p.push({id:j.id,publicKeyJwk:F,purposes:(a=j.purposes)!==null&&a!==void 0?a:["authentication","assertionMethod","capabilityDelegation","capabilityInvocation"]})}let m=yield e.generateKey({algorithm:jf.secp256k1}),g=yield e.getPublicKey({keyUri:m}),v=yield e.generateKey({algorithm:jf.secp256k1}),x=yield e.getPublicKey({keyUri:v}),S=yield cb.computeLongFormDidUri({recoveryKey:g,updateKey:x,services:(d=r.services)!==null&&d!==void 0?d:[],verificationMethods:p}),{didDocument:P,didResolutionMetadata:A}=yield t.resolve(S,{gatewayUri:r.gatewayUri});if(P===null)throw new Error(`Unable to resolve DID during creation: ${A?.error}`);let $=new pc({uri:S,document:P,metadata:{published:!1,canonicalId:S.split(":",3).join(":"),recoveryKey:g,updateKey:x},keyManager:e});if(!((u=r.publish)!==null&&u!==void 0)||u){let j=yield t.publish({did:$,gatewayUri:r.gatewayUri});$.metadata=j.didDocumentMetadata}return $})}static getSigningMethod(e){return Zy(this,arguments,void 0,function*({didDocument:r,methodId:n}){var i;let o=_r.parse(r.id);if(o&&o.method!==this.methodName)throw new at(tt.MethodNotSupported,`Method not supported: ${o.method}`);let s=(i=r.verificationMethod)===null||i===void 0?void 0:i.find(a=>{var d;return a.id===(n??((d=r.assertionMethod)===null||d===void 0?void 0:d[0]))});if(!(s&&s.publicKeyJwk))throw new at(tt.InternalError,"A verification method intended for signing could not be determined from the DID Document");return s})}static import(e){return Zy(this,arguments,void 0,function*({portableDid:r,keyManager:n=new da}){let i=_r.parse(r.uri);if(i?.method!==t.methodName)throw new at(tt.MethodNotSupported,"Method not supported");return yield pc.import({portableDid:r,keyManager:n})})}static publish(e){return Zy(this,arguments,void 0,function*({did:r,gatewayUri:n=kve}){var i,o,s;let a=(o=(i=r.document.verificationMethod)===null||i===void 0?void 0:i.map(c=>({id:c.id,publicKeyJwk:c.publicKeyJwk,purposes:Fge({didDocument:r.document,methodId:c.id})})))!==null&&o!==void 0?o:[],d=yield cb.createIonDocument({services:(s=r.document.service)!==null&&s!==void 0?s:[],verificationMethods:a}),u=yield cb.constructCreateRequest({ionDocument:d,recoveryKey:r.metadata.recoveryKey,updateKey:r.metadata.updateKey});try{let c=cb.appendPathToUrl({baseUrl:n,path:"/operations"}),l=yield fetch(c,{method:"POST",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)});return{didDocument:r.document,didDocumentMetadata:Object.assign(Object.assign({},r.metadata),{published:l.ok}),didRegistrationMetadata:{}}}catch{return{didDocument:null,didDocumentMetadata:{published:!1},didRegistrationMetadata:{error:tt.InternalError,errorMessage:`Failed to publish DID document for: ${r.uri}`}}}})}static resolve(e){return Zy(this,arguments,void 0,function*(r,n={}){var i,o;let s=_r.parse(r);if(!s)return Object.assign(Object.assign({},di),{didResolutionMetadata:{error:"invalidDid"}});if(s.method!==t.methodName)return Object.assign(Object.assign({},di),{didResolutionMetadata:{error:"methodNotSupported"}});let a=(i=n?.gatewayUri)!==null&&i!==void 0?i:kve;try{let d=cb.appendPathToUrl({baseUrl:a,path:`/identifiers/${r}`}),u=yield fetch(d);if(!u.ok)throw new at(tt.NotFound,`Unable to find DID document for: ${r}`);let{didDocument:c,didDocumentMetadata:l}=yield u.json();return Object.assign(Object.assign(Object.assign({},di),c&&{didDocument:c}),{didDocumentMetadata:Object.assign({published:(o=l?.method)===null||o===void 0?void 0:o.published},l)})}catch(d){if(!(d instanceof at))throw new Error(d);return Object.assign(Object.assign({},di),{didResolutionMetadata:Object.assign({error:d.code},d.message&&{errorMessage:d.message})})}})}};NF.methodName="ion";var cb=class t{static appendPathToUrl({baseUrl:e,path:r}){let n=new URL(e);return n.pathname=n.pathname.endsWith("/")?n.pathname:n.pathname+"/",n.pathname+=r.startsWith("/")?r.substring(1):r,n.toString()}static computeLongFormDidUri(e){return Zy(this,arguments,void 0,function*({recoveryKey:r,updateKey:n,services:i,verificationMethods:o}){let s=yield t.createIonDocument({services:i,verificationMethods:o}),a=t.normalizeJwk(r),d=t.normalizeJwk(n);return yield Jy.createLongFormDid({document:s,recoveryKey:a,updateKey:d})})}static constructCreateRequest(e){return Zy(this,arguments,void 0,function*({ionDocument:r,recoveryKey:n,updateKey:i}){return yield $f.createCreateRequest({document:r,recoveryKey:t.normalizeJwk(n),updateKey:t.normalizeJwk(i)})})}static createIonDocument(e){return Zy(this,arguments,void 0,function*({services:r,verificationMethods:n}){var i,o;let s=[];for(let u of n){let c=(o=(i=u.id)!==null&&i!==void 0?i:u.publicKeyJwk.kid)!==null&&o!==void 0?o:yield gr({jwk:u.publicKeyJwk});c=`${c.split("#").pop()}`;let l={id:c,publicKeyJwk:t.normalizeJwk(u.publicKeyJwk),purposes:u.purposes,type:"JsonWebKey2020"};s.push(l)}let a=r.map(u=>Object.assign(Object.assign({},u),{id:`${u.id.split("#").pop()}`}));return{publicKeys:s,services:a}})}static normalizeJwk(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}`);return n}};f();var mR=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},D3=class t extends iu{static create(){return mR(this,arguments,void 0,function*({keyManager:e=new da,options:r={}}={}){var n,i,o,s;if(r.algorithm&&r.verificationMethods)throw new Error("The 'algorithm' and 'verificationMethods' options are mutually exclusive");if(r.verificationMethods&&r.verificationMethods.length!==1)throw new Error("The 'verificationMethods' option must contain exactly one entry");let a=(s=(n=r.algorithm)!==null&&n!==void 0?n:(o=(i=r.verificationMethods)===null||i===void 0?void 0:i[0])===null||o===void 0?void 0:o.algorithm)!==null&&s!==void 0?s:"Ed25519",d=yield e.generateKey({algorithm:a}),u=yield e.getPublicKey({keyUri:d}),c=ji.object(u).toBase64Url(),l=`did:${t.methodName}:${c}`,m=(yield t.resolve(l)).didDocument;return new pc({uri:l,document:m,metadata:{},keyManager:e})})}static getSigningMethod(e){return mR(this,arguments,void 0,function*({didDocument:r}){var n;let i=_r.parse(r.id);if(i&&i.method!==this.methodName)throw new at(tt.MethodNotSupported,`Method not supported: ${i.method}`);let[o]=(n=r.verificationMethod)!==null&&n!==void 0?n:[];if(!(o&&o.publicKeyJwk))throw new at(tt.InternalError,"A verification method intended for signing could not be determined from the DID Document");return o})}static import(e){return mR(this,arguments,void 0,function*({portableDid:r,keyManager:n=new da}){let i=_r.parse(r.uri);if(i?.method!==t.methodName)throw new at(tt.MethodNotSupported,"Method not supported");let o=yield pc.import({portableDid:r,keyManager:n});if(o.document.verificationMethod.length!==1)throw new at(tt.InvalidDidDocument,"DID document must contain exactly one verification method");return o})}static resolve(e,r){return mR(this,void 0,void 0,function*(){let n=_r.parse(e),i;try{i=ji.base64Url(n.id).toObject()}catch{}if(!n||!i)return Object.assign(Object.assign({},di),{didResolutionMetadata:{error:"invalidDid"}});if(n.method!==t.methodName)return Object.assign(Object.assign({},di),{didResolutionMetadata:{error:"methodNotSupported"}});let o={"@context":["https://www.w3.org/ns/did/v1"],id:n.uri},s=`${o.id}#0`;switch(o.verificationMethod=[{id:s,type:"JsonWebKey",controller:o.id,publicKeyJwk:i}],o.authentication=[s],o.assertionMethod=[s],o.capabilityInvocation=[s],o.capabilityDelegation=[s],o.keyAgreement=[s],i.use){case"sig":{delete o.keyAgreement;break}case"enc":{delete o.authentication,delete o.assertionMethod,delete o.capabilityInvocation,delete o.capabilityDelegation;break}}return Object.assign(Object.assign({},di),{didDocument:o})})}};D3.methodName="jwk";f();var ll=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},xp;(function(t){t.Ed25519="Ed25519",t.secp256k1="secp256k1",t.secp256r1="secp256r1",t.X25519="X25519"})(xp||(xp={}));var UF={Ed25519VerificationKey2020:"https://w3id.org/security/suites/ed25519-2020/v1",JsonWebKey2020:"https://w3id.org/security/suites/jws-2020/v1",X25519KeyAgreementKey2020:"https://w3id.org/security/suites/x25519-2020/v1"},Jet={Ed25519:xp.Ed25519,ES256K:xp.secp256k1,ES256:xp.secp256r1,"P-256":xp.secp256r1,secp256k1:xp.secp256k1,secp256r1:xp.secp256r1,X25519:xp.X25519},r_=class t extends iu{static create(){return ll(this,arguments,void 0,function*({keyManager:e=new da,options:r={}}={}){var n,i,o,s;if(r.algorithm&&r.verificationMethods)throw new Error("The 'algorithm' and 'verificationMethods' options are mutually exclusive");if(r.verificationMethods&&r.verificationMethods.length!==1)throw new Error("The 'verificationMethods' option must contain exactly one entry");let a=(s=(n=r.algorithm)!==null&&n!==void 0?n:(o=(i=r.verificationMethods)===null||i===void 0?void 0:i[0])===null||o===void 0?void 0:o.algorithm)!==null&&s!==void 0?s:"Ed25519",d=yield e.generateKey({algorithm:a}),u=yield e.getPublicKey({keyUri:d}),c=yield gc.publicKeyToMultibaseId({publicKey:u}),l=`did:${t.methodName}:${c}`,m=(yield t.resolve(l,r)).didDocument;return new pc({uri:l,document:m,metadata:{},keyManager:e})})}static getSigningMethod(e){return ll(this,arguments,void 0,function*({didDocument:r}){var n;let i=_r.parse(r.id);if(i&&i.method!==this.methodName)throw new at(tt.MethodNotSupported,`Method not supported: ${i.method}`);let[o]=r.assertionMethod||[],s=(n=r.verificationMethod)===null||n===void 0?void 0:n.find(a=>a.id===o);if(!(s&&s.publicKeyJwk))throw new at(tt.InternalError,"A verification method intended for signing could not be determined from the DID Document");return s})}static import(e){return ll(this,arguments,void 0,function*({portableDid:r,keyManager:n=new da}){let i=_r.parse(r.uri);if(i?.method!==t.methodName)throw new at(tt.MethodNotSupported,"Method not supported");let o=yield pc.import({portableDid:r,keyManager:n});if(o.document.verificationMethod.length!==1)throw new at(tt.InvalidDidDocument,"DID document must contain exactly one verification method");return o})}static resolve(e,r){return ll(this,void 0,void 0,function*(){try{let n=yield t.createDocument({didUri:e,options:r});return Object.assign(Object.assign({},di),{didDocument:n})}catch(n){if(!(n instanceof at))throw new Error(n);return Object.assign(Object.assign({},di),{didResolutionMetadata:Object.assign({error:n.code},n.message&&{errorMessage:n.message})})}})}static createDocument(e){return ll(this,arguments,void 0,function*({didUri:r,options:n={}}){let{defaultContext:i="https://www.w3.org/ns/did/v1",enableEncryptionKeyDerivation:o=!1,enableExperimentalPublicKeyTypes:s=!1,publicKeyFormat:a="JsonWebKey2020"}=n,d={id:""},u=_r.parse(r);if(!u)throw new at(tt.InvalidDid,`Invalid DID URI: ${r}`);let c=u.id;if(u.method!==t.methodName)throw new at(tt.MethodNotSupported,`Method not supported: ${u.method}`);if(!t.validateIdentifier(u))throw new at(tt.InvalidDid,`Invalid DID URI: ${r}`);let l=yield t.createSignatureMethod({didUri:r,multibaseValue:c,options:{enableExperimentalPublicKeyTypes:s,publicKeyFormat:a}});if(d.id=u.uri,d.verificationMethod=[l],d.authentication=[l.id],d.assertionMethod=[l.id],d.capabilityInvocation=[l.id],d.capabilityDelegation=[l.id],o===!0){let g=a==="Ed25519VerificationKey2020"?"X25519KeyAgreementKey2020":"JsonWebKey2020",v=yield this.createEncryptionMethod({didUri:r,multibaseValue:c,options:{enableExperimentalPublicKeyTypes:s,publicKeyFormat:g}});d.verificationMethod.push(v),d.keyAgreement=[v.id]}let p=[i];return Kge({didDocument:d}).forEach(g=>{let v=UF[g];p.push(v)}),d["@context"]=p,d})}static createEncryptionMethod(e){return ll(this,arguments,void 0,function*({didUri:r,multibaseValue:n,options:i}){let{enableExperimentalPublicKeyTypes:o,publicKeyFormat:s}=i,a={id:"",type:"",controller:""},{keyBytes:d,multicodecCode:u}=yield t.deriveEncryptionKey({multibaseValue:n}),c=d.byteLength,l=gc.MULTICODEC_PUBLIC_KEY_LENGTH[u];if(c!==l)throw new at(tt.InvalidPublicKeyLength,`Expected ${c} bytes. Actual: ${l}`);let p=vF({keyBytes:d,multicodecCode:u});a.id=`${r}#${p}`;try{new URL(a.id)}catch{throw new at(tt.InvalidDidUrl,"Verification Method ID is not a valid DID URL.")}if(!(s in UF))throw new at(tt.UnsupportedPublicKeyType,`Unsupported format: ${s}`);if(o===!1&&!["Multikey","JsonWebKey2020","X25519KeyAgreementKey2020"].includes(s))throw new at(tt.InvalidPublicKeyType,`Specified '${s}' without setting enableExperimentalPublicKeyTypes to true.`);if(a.type=s,a.controller=r,s==="X25519KeyAgreementKey2020"&&(a.publicKeyMultibase=p),s==="JsonWebKey2020"){let{crv:g}=yield gc.multicodecToJwk({code:u});a.publicKeyJwk=yield gc.keyConverter(g).bytesToPublicKey({publicKeyBytes:d})}return a})}static createSignatureMethod(e){return ll(this,arguments,void 0,function*({didUri:r,multibaseValue:n,options:i}){let{enableExperimentalPublicKeyTypes:o,publicKeyFormat:s}=i,a={id:"",type:"",controller:""},{keyBytes:d,multicodecCode:u,multicodecName:c}=bF({multibaseKeyId:n}),l=d.byteLength,p=gc.MULTICODEC_PUBLIC_KEY_LENGTH[u];if(l!==p)throw new at(tt.InvalidPublicKeyLength,`Expected ${l} bytes. Actual: ${p}`);let m=!1;switch(c){case"secp256k1-pub":m=yield Fo.validatePublicKey({publicKeyBytes:d});break;case"ed25519-pub":m=yield vo.validatePublicKey({publicKeyBytes:d});break;case"x25519-pub":m=!0;break}if(!m)throw new at(tt.InvalidPublicKey,"Invalid public key detected.");a.id=`${r}#${n}`;try{new URL(a.id)}catch{throw new at(tt.InvalidDidUrl,"Verification Method ID is not a valid DID URL.")}if(!(s in UF))throw new at(tt.UnsupportedPublicKeyType,`Unsupported format: ${s}`);if(o===!1&&!["Multikey","JsonWebKey2020","Ed25519VerificationKey2020"].includes(s))throw new at(tt.InvalidPublicKeyType,`Specified '${s}' without setting enableExperimentalPublicKeyTypes to true.`);if(a.type=s,a.controller=r,s==="Ed25519VerificationKey2020"&&(a.publicKeyMultibase=n),s==="JsonWebKey2020"){let{crv:v}=yield gc.multicodecToJwk({code:u});a.publicKeyJwk=yield gc.keyConverter(v).bytesToPublicKey({publicKeyBytes:d})}return a})}static deriveEncryptionKey(e){return ll(this,arguments,void 0,function*({multibaseValue:r}){let n={keyBytes:new Uint8Array,multicodecCode:0},{keyBytes:i,multicodecCode:o}=bF({multibaseKeyId:r});if(o===237){let s=yield gc.keyConverter("Ed25519").bytesToPublicKey({publicKeyBytes:i}),a=yield vo.convertPublicKeyToX25519({publicKey:s});n={keyBytes:yield gc.keyConverter("Ed25519").publicKeyToBytes({publicKey:a}),multicodecCode:236}}return n})}static validateIdentifier(e){let{method:r,id:n}=e,[i]=e.uri.split(":",1);return i==="did"&&r==="key"&&Number("1")>0&&m3(n)==="String"&&n.startsWith("z")}};r_.methodName="key";var gc=class t{static jwkToMulticodec(e){return ll(this,arguments,void 0,function*({jwk:r}){let n=[];r.crv&&(n.push(r.crv),r.d?n.push("private"):n.push("public"));let i=n.join(":"),o=t.JWK_TO_MULTICODEC[i];if(o===void 0)throw new Error(`Unsupported JWK to Multicodec conversion: '${i}'`);return{code:ua.getCodeFromName({name:o}),name:o}})}static keyCompressor(e){let n={"P-256":Rs.compressPublicKey,secp256k1:Fo.compressPublicKey}[e];if(!n)throw new at(tt.InvalidPublicKeyType,`Unsupported curve: ${e}`);return n}static keyConverter(e){let n={Ed25519:vo,"P-256":Rs,secp256k1:Fo,X25519:z2}[e];if(!n)throw new at(tt.InvalidPublicKeyType,`Unsupported curve: ${e}`);return n}static multicodecToJwk(e){return ll(this,arguments,void 0,function*({code:r,name:n}){if(!(n?!r:r))throw new Error("Either 'name' or 'code' must be defined, but not both.");n=n===void 0?ua.getNameFromCode({code:r}):n;let i=n,o=t.MULTICODEC_TO_JWK[i];if(o===void 0)throw new Error("Unsupported Multicodec to JWK conversion");return Object.assign({},o)})}static publicKeyToMultibaseId(e){return ll(this,arguments,void 0,function*({publicKey:r}){var n;if(!(r?.crv&&r.crv in Jet))throw new at(tt.InvalidPublicKeyType,`Public key contains an unsupported key type: ${(n=r?.crv)!==null&&n!==void 0?n:"undefined"}`);let i=yield t.keyConverter(r.crv).publicKeyToBytes({publicKey:r});/^(secp256k1|P-256|P-384|P-521)$/.test(r.crv)&&(i=yield t.keyCompressor(r.crv)({publicKeyBytes:i}));let{name:o}=yield t.jwkToMulticodec({jwk:r});return vF({keyBytes:i,multicodecName:o})})}};gc.JWK_TO_MULTICODEC={"Ed25519:public":"ed25519-pub","Ed25519:private":"ed25519-priv","secp256k1:public":"secp256k1-pub","secp256k1:private":"secp256k1-priv","X25519:public":"x25519-pub","X25519:private":"x25519-priv"};gc.MULTICODEC_PUBLIC_KEY_LENGTH={231:33,236:32,237:32};gc.MULTICODEC_TO_JWK={"ed25519-pub":{crv:"Ed25519",kty:"OKP",x:""},"ed25519-priv":{crv:"Ed25519",kty:"OKP",x:"",d:""},"secp256k1-pub":{crv:"secp256k1",kty:"EC",x:"",y:""},"secp256k1-priv":{crv:"secp256k1",kty:"EC",x:"",y:"",d:""},"x25519-pub":{crv:"X25519",kty:"OKP",x:""},"x25519-priv":{crv:"X25519",kty:"OKP",x:"",d:""}};f();var Zet=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},qF=class t extends iu{static resolve(e,r){return Zet(this,void 0,void 0,function*(){let n=_r.parse(e);if(!n)return Object.assign(Object.assign({},di),{didResolutionMetadata:{error:"invalidDid"}});if(n.method!==t.methodName)return Object.assign(Object.assign({},di),{didResolutionMetadata:{error:"methodNotSupported"}});let i=`https://${n.id.replace(/:/g,"/")}`;i=decodeURIComponent(i);let o=n.id.includes(":")?`${i}/did.json`:`${i}/.well-known/did.json`;try{let s=yield fetch(o);if(!s.ok)throw new Error("HTTP error status code returned");let a=yield s.json();return Object.assign(Object.assign({},di),{didDocument:a})}catch{return Object.assign(Object.assign({},di),{didResolutionMetadata:{error:"notFound"}})}})}};qF.methodName="web";f();var Dve=gt(ub(),1),Bve=gt(GS(),1),rtt=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},gR=class{constructor({db:e,location:r="DATA/DID_RESOLVERCACHE",ttl:n="15m"}={}){this.cache=e??new Bve.Level(r),this.ttl=(0,Dve.default)(n)}get(e){return rtt(this,void 0,void 0,function*(){try{let r=yield this.cache.get(e),n=JSON.parse(r);if(Date.now()>=n.ttlMillis){this.cache.nextTick(()=>this.cache.del(e));return}else return n.value}catch(r){if(r.notFound)return;throw r}})}set(e,r){let n={ttlMillis:Date.now()+this.ttl,value:r},i=JSON.stringify(n);return this.cache.put(e,i)}delete(e){return this.cache.del(e)}clear(){return this.cache.clear()}close(){return this.cache.close()}};f();var Mve={get:function(t){return null},set:function(t,e){return null},delete:function(t){return null},clear:function(){return null},close:function(){return null}};f();var Ove=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},vR=class{constructor({cache:e,didResolvers:r}){this.didResolvers=new Map,this.cache=e||Mve;for(let n of r)this.didResolvers.set(n.methodName,n)}resolve(e,r){return Ove(this,void 0,void 0,function*(){let n=_r.parse(e);if(!n)return Object.assign(Object.assign({},di),{didResolutionMetadata:{error:tt.InvalidDid,errorMessage:`Invalid DID URI: ${e}`}});let i=this.didResolvers.get(n.method);if(!i)return Object.assign(Object.assign({},di),{didResolutionMetadata:{error:tt.MethodNotSupported,errorMessage:`Method not supported: ${n.method}`}});let o=yield this.cache.get(n.uri);if(o)return o;{let s=yield i.resolve(n.uri,r);return s.didResolutionMetadata.error||(yield this.cache.set(n.uri,s)),s}})}dereference(e,r){return Ove(this,void 0,void 0,function*(){let n=_r.parse(e);if(!n)return{dereferencingMetadata:{error:tt.InvalidDidUrl},contentStream:null,contentMetadata:{}};let{didDocument:i,didResolutionMetadata:o,didDocumentMetadata:s}=yield this.resolve(n.uri);if(!i)return{dereferencingMetadata:{error:o.error},contentStream:null,contentMetadata:{}};if(!n.fragment||n.query)return{dereferencingMetadata:{contentType:"application/did+json"},contentStream:i,contentMetadata:s};let{service:a=[],verificationMethod:d=[]}=i,u=new Set([e,n.fragment,`#${n.fragment}`]),c;for(let l of d)if(u.has(l.id)){c=l;break}for(let l of a)if(u.has(l.id)){c=l;break}return c?{dereferencingMetadata:{contentType:"application/did+json"},contentStream:c,contentMetadata:o}:{dereferencingMetadata:{error:tt.NotFound},contentStream:null,contentMetadata:{}}})}};var s_=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},B3=class t{constructor(e){this.didResolver=e.didResolver,this.tenantGate=e.tenantGate,this.eventStream=e.eventStream,this.messageStore=e.messageStore,this.dataStore=e.dataStore,this.resumableTaskStore=e.resumableTaskStore,this.eventLog=e.eventLog,this.eventStream=e.eventStream,this.storageController=new v2({messageStore:this.messageStore,dataStore:this.dataStore,eventLog:this.eventLog,eventStream:this.eventStream}),this.resumableTaskManager=new SS(e.resumableTaskStore,this.storageController),this.methodHandlers={[Te.Messages+Se.Query]:new $P(this.didResolver,this.messageStore,this.eventLog),[Te.Messages+Se.Read]:new jP(this.didResolver,this.messageStore,this.dataStore),[Te.Messages+Se.Subscribe]:new NP(this.didResolver,this.messageStore,this.eventStream),[Te.Protocols+Se.Configure]:new gI(this.didResolver,this.messageStore,this.eventLog,this.eventStream),[Te.Protocols+Se.Query]:new vI(this.didResolver,this.messageStore,this.dataStore),[Te.Records+Se.Delete]:new bI(this.didResolver,this.messageStore,this.resumableTaskManager),[Te.Records+Se.Query]:new wI(this.didResolver,this.messageStore,this.dataStore),[Te.Records+Se.Read]:new _I(this.didResolver,this.messageStore,this.dataStore),[Te.Records+Se.Subscribe]:new EI(this.didResolver,this.messageStore,this.eventStream),[Te.Records+Se.Write]:new SI(this.didResolver,this.messageStore,this.dataStore,this.eventLog,this.eventStream)}}static create(e){var r,n;return s_(this,void 0,void 0,function*(){(r=e.didResolver)!==null&&r!==void 0||(e.didResolver=new vR({didResolvers:[sb,D3,r_],cache:new gR({location:"RESOLVERCACHE"})})),(n=e.tenantGate)!==null&&n!==void 0||(e.tenantGate=new z6);let i=new t(e);return yield i.open(),i})}open(){var e;return s_(this,void 0,void 0,function*(){yield this.messageStore.open(),yield this.dataStore.open(),yield this.resumableTaskStore.open(),yield this.eventLog.open(),yield(e=this.eventStream)===null||e===void 0?void 0:e.open(),yield this.resumableTaskManager.resumeTasksAndWaitForCompletion()})}close(){var e;return s_(this,void 0,void 0,function*(){yield(e=this.eventStream)===null||e===void 0?void 0:e.close(),yield this.messageStore.close(),yield this.dataStore.close(),yield this.resumableTaskStore.close(),yield this.eventLog.close()})}processMessage(e,r,n={}){var i;return s_(this,void 0,void 0,function*(){let o=(i=yield this.validateTenant(e))!==null&&i!==void 0?i:yield this.validateMessageIntegrity(r);if(o!==void 0)return o;let{dataStream:s,subscriptionHandler:a}=n,d=r.descriptor.interface+r.descriptor.method;return yield this.methodHandlers[d].handle({tenant:e,message:r,dataStream:s,subscriptionHandler:a})})}validateTenant(e){var r;return s_(this,void 0,void 0,function*(){let n=yield this.tenantGate.isActiveTenant(e);if(!n.isActiveTenant)return{status:{code:401,detail:(r=n.detail)!==null&&r!==void 0?r:`DID ${e} is not an active tenant.`}}})}validateMessageIntegrity(e){var r,n;return s_(this,void 0,void 0,function*(){let i=(r=e?.descriptor)===null||r===void 0?void 0:r.interface,o=(n=e?.descriptor)===null||n===void 0?void 0:n.method;if(i===void 0||o===void 0)return{status:{code:400,detail:`Both interface and method must be present, interface: ${i}, method: ${o}`}};try{_e.validateJsonSchema(e)}catch(s){return mr(s,400)}})}};f();var ntt=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})};function itt(t){return new Promise((e,r)=>{if(t.aborted){r(t.reason);return}t.addEventListener("abort",()=>{r(t.reason)})})}function Xi(t,e){return ntt(this,void 0,void 0,function*(){return e?Promise.race([t,itt(e)]):t})}f();f();f();f();var $ve=gt(g3(),1),sd=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},fl=function(t){return this instanceof fl?(this.v=t,this):new fl(t)},LF=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,d){s=t[o](s),i(a,d,s.done,s.value)})}}function i(o,s,a,d){Promise.resolve(d).then(function(u){o({value:u,done:a})},s)}},Cve=function(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),i,o=[];return i={},s("next"),s("throw"),s("return"),i[Symbol.asyncIterator]=function(){return this},i;function s(p){n[p]&&(i[p]=function(m){return new Promise(function(g,v){o.push([p,m,g,v])>1||a(p,m)})})}function a(p,m){try{d(n[p](m))}catch(g){l(o[0][3],g)}}function d(p){p.value instanceof fl?Promise.resolve(p.value.v).then(u,c):l(o[0][2],p)}function u(p){a("next",p)}function c(p){a("throw",p)}function l(p,m){p(m),o.shift(),o.length&&a(o[0][0],o[0][1])}};function ad(t,e){return sd(this,void 0,void 0,function*(){return new $ve.Level(t,Object.assign(Object.assign({},e),{keyEncoding:"utf8"}))})}var Yy=class t{constructor(e,r){this.config=Object.assign({createLevelDatabase:ad},e),this.db=r}open(){return sd(this,void 0,void 0,function*(){switch(yield this.createLevelDatabase(),this.db.status){case"open":return;case"opening":return new Promise(e=>{this.db.once("open",e)});case"closing":return new Promise((e,r)=>{let n=()=>{this.db.open().then(e).catch(r)};this.db.once("closed",n)});case"closed":return this.db.open()}})}close(){return sd(this,void 0,void 0,function*(){if(this.db)switch(this.db.status){case"open":return this.db.close();case"opening":return new Promise((e,r)=>{let n=()=>{this.db.close().then(e).catch(r)};this.db.once("open",n)});case"closing":return new Promise(e=>{this.db.once("closed",e)});case"closed":return}})}partition(e){return sd(this,void 0,void 0,function*(){return yield this.createLevelDatabase(),new t(this.config,this.db.sublevel(e,{keyEncoding:"utf8",valueEncoding:this.config.valueEncoding}))})}get(e,r){var n;return sd(this,void 0,void 0,function*(){(n=r?.signal)===null||n===void 0||n.throwIfAborted(),yield Xi(this.createLevelDatabase(),r?.signal);try{return yield Xi(this.db.get(String(e)),r?.signal)}catch(i){if(i.code==="LEVEL_NOT_FOUND")return;throw i}})}has(e,r){return sd(this,void 0,void 0,function*(){return!!(yield this.get(e,r))})}keys(e){var r,n;return Cve(this,arguments,function*(){var o,s,a,d;(r=e?.signal)===null||r===void 0||r.throwIfAborted(),yield fl(Xi(this.createLevelDatabase(),e?.signal));try{for(var u=!0,c=LF(this.db.keys()),l;l=yield fl(c.next()),o=l.done,!o;u=!0){d=l.value,u=!1;let p=d;(n=e?.signal)===null||n===void 0||n.throwIfAborted(),yield yield fl(p)}}catch(p){s={error:p}}finally{try{!u&&!o&&(a=c.return)&&(yield fl(a.call(c)))}finally{if(s)throw s.error}}})}iterator(e,r){var n,i;return Cve(this,arguments,function*(){var s,a,d,u;(n=r?.signal)===null||n===void 0||n.throwIfAborted(),yield fl(Xi(this.createLevelDatabase(),r?.signal));try{for(var c=!0,l=LF(this.db.iterator(e)),p;p=yield fl(l.next()),s=p.done,!s;c=!0){u=p.value,c=!1;let m=u;(i=r?.signal)===null||i===void 0||i.throwIfAborted(),yield yield fl(m)}}catch(m){a={error:m}}finally{try{!c&&!s&&(d=l.return)&&(yield fl(d.call(l)))}finally{if(a)throw a.error}}})}put(e,r,n){var i;return sd(this,void 0,void 0,function*(){return(i=n?.signal)===null||i===void 0||i.throwIfAborted(),yield Xi(this.createLevelDatabase(),n?.signal),Xi(this.db.put(String(e),r),n?.signal)})}delete(e,r){var n;return sd(this,void 0,void 0,function*(){return(n=r?.signal)===null||n===void 0||n.throwIfAborted(),yield Xi(this.createLevelDatabase(),r?.signal),Xi(this.db.del(String(e)),r?.signal)})}isEmpty(e){var r,n,i,o;return sd(this,void 0,void 0,function*(){try{for(var s=!0,a=LF(this.keys(e)),d;d=yield a.next(),r=d.done,!r;s=!0){o=d.value,s=!1;let u=o;return!1}}catch(u){n={error:u}}finally{try{!s&&!r&&(i=a.return)&&(yield i.call(a))}finally{if(n)throw n.error}}return!0})}clear(){return sd(this,void 0,void 0,function*(){yield this.createLevelDatabase(),yield this.db.clear(),yield this.compactUnderlyingStorage()})}batch(e,r){var n;return sd(this,void 0,void 0,function*(){return(n=r?.signal)===null||n===void 0||n.throwIfAborted(),yield Xi(this.createLevelDatabase(),r?.signal),Xi(this.db.batch(e),r?.signal)})}createPartitionOperation(e,r){return Object.assign(Object.assign({},r),{sublevel:this.db.sublevel(e,{keyEncoding:"utf8",valueEncoding:this.config.valueEncoding})})}compactUnderlyingStorage(e){var r,n,i;return sd(this,void 0,void 0,function*(){(r=e?.signal)===null||r===void 0||r.throwIfAborted(),yield Xi(this.createLevelDatabase(),e?.signal);let o=this.sublevelRange;if(!o)return;let s=this.root;if(s.db.supports.additionalMethods.compactRange)return Xi((i=(n=s.db).compactRange)===null||i===void 0?void 0:i.call(n,...o),e?.signal)})}get sublevelRange(){let e=this.db.prefix;if(!e)return;let r=e.slice(0,-1)+String.fromCharCode(e.charCodeAt(e.length-1)+1);return[e,r]}get root(){let e=this.db;for(let r=e.db;r&&r!==e;)e=r;return new t(this.config,e)}createLevelDatabase(){var e;return sd(this,void 0,void 0,function*(){(e=this.db)!==null&&e!==void 0||(this.db=yield this.config.createLevelDatabase(this.config.location,{keyEncoding:"utf8",valueEncoding:this.config.valueEncoding}))})}};var Ep=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},bR=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,d){s=t[o](s),i(a,d,s.done,s.value)})}}function i(o,s,a,d){Promise.resolve(d).then(function(u){o({value:u,done:a})},s)}},Vo=function(t){return this instanceof Vo?(this.v=t,this):new Vo(t)},wR=function(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),i,o=[];return i={},s("next"),s("throw"),s("return"),i[Symbol.asyncIterator]=function(){return this},i;function s(p){n[p]&&(i[p]=function(m){return new Promise(function(g,v){o.push([p,m,g,v])>1||a(p,m)})})}function a(p,m){try{d(n[p](m))}catch(g){l(o[0][3],g)}}function d(p){p.value instanceof Vo?Promise.resolve(p.value.v).then(u,c):l(o[0][2],p)}function u(p){a("next",p)}function c(p){a("throw",p)}function l(p,m){p(m),o.shift(),o.length&&a(o[0][0],o[0][1])}},a_=class t{constructor(e,r){this.config=Object.assign({createLevelDatabase:ad},e),this.db=r??new Yy(Object.assign(Object.assign({},this.config),{valueEncoding:"binary"}))}open(){return Ep(this,void 0,void 0,function*(){return this.db.open()})}close(){return Ep(this,void 0,void 0,function*(){return this.db.close()})}partition(e){return Ep(this,void 0,void 0,function*(){let r=yield this.db.partition(e);return new t(Object.assign(Object.assign({},this.config),{location:""}),r)})}put(e,r,n){return Ep(this,void 0,void 0,function*(){return yield this.db.put(String(e),r,n),Nr.parse(e.toString())})}get(e,r){return Ep(this,void 0,void 0,function*(){return yield this.db.get(String(e),r)})}has(e,r){return Ep(this,void 0,void 0,function*(){return this.db.has(String(e),r)})}delete(e,r){return Ep(this,void 0,void 0,function*(){return this.db.delete(String(e),r)})}isEmpty(e){return Ep(this,void 0,void 0,function*(){return this.db.isEmpty(e)})}putMany(e,r){return wR(this,arguments,function*(){var i,o,s,a;try{for(var d=!0,u=bR(e),c;c=yield Vo(u.next()),i=c.done,!i;d=!0){a=c.value,d=!1;let l=a;yield Vo(this.put(l.cid,l.block,r)),yield yield Vo(l.cid)}}catch(l){o={error:l}}finally{try{!d&&!i&&(s=u.return)&&(yield Vo(s.call(u)))}finally{if(o)throw o.error}}})}getMany(e,r){return wR(this,arguments,function*(){var i,o,s,a;try{for(var d=!0,u=bR(e),c;c=yield Vo(u.next()),i=c.done,!i;d=!0){a=c.value,d=!1;let l=a;yield yield Vo({cid:l,block:yield Vo(this.get(l,r))})}}catch(l){o={error:l}}finally{try{!d&&!i&&(s=u.return)&&(yield Vo(s.call(u)))}finally{if(o)throw o.error}}})}getAll(e){return wR(this,arguments,function*(){var n,i,o,s;let a=this.db.iterator({keys:!0,keyEncoding:"buffer"},e);try{for(var d=!0,u=bR(a),c;c=yield Vo(u.next()),n=c.done,!n;d=!0){s=c.value,d=!1;let[l,p]=s;yield yield Vo({cid:Nr.decode(l),block:p})}}catch(l){i={error:l}}finally{try{!d&&!n&&(o=u.return)&&(yield Vo(o.call(u)))}finally{if(i)throw i.error}}})}deleteMany(e,r){return wR(this,arguments,function*(){var i,o,s,a;try{for(var d=!0,u=bR(e),c;c=yield Vo(u.next()),i=c.done,!i;d=!0){a=c.value,d=!1;let l=a;yield Vo(this.delete(l,r)),yield yield Vo(l)}}catch(l){o={error:l}}finally{try{!d&&!i&&(s=u.return)&&(yield Vo(s.call(u)))}finally{if(o)throw o.error}}})}clear(){return Ep(this,void 0,void 0,function*(){return this.db.clear()})}};f();var WR=gt(Oc(),1);f();function ott(t){return t[Symbol.asyncIterator]!=null}function stt(t){if(ott(t))return(async()=>{let r;for await(let n of t)r=n;return r})();let e;for(let r of t)e=r;return e}var jve=stt;f();f();f();f();f();var att=["string","number","bigint","symbol"],ctt=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function Nve(t){if(t===null)return"null";if(t===void 0)return"undefined";if(t===!0||t===!1)return"boolean";let e=typeof t;if(att.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(t))return"Array";if(dtt(t))return"Buffer";let r=utt(t);return r||"Object"}function dtt(t){return t&&t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer.call(null,t)}function utt(t){let e=Object.prototype.toString.call(t).slice(8,-1);if(ctt.includes(e))return e}f();var we=class{constructor(e,r,n){this.major=e,this.majorEncoded=e<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.majore.major?1:0}};we.uint=new we(0,"uint",!0);we.negint=new we(1,"negint",!0);we.bytes=new we(2,"bytes",!0);we.string=new we(3,"string",!0);we.array=new we(4,"array",!1);we.map=new we(5,"map",!1);we.tag=new we(6,"tag",!1);we.float=new we(7,"float",!0);we.false=new we(7,"false",!0);we.true=new we(7,"true",!0);we.null=new we(7,"null",!0);we.undefined=new we(7,"undefined",!0);we.break=new we(7,"break",!0);var Je=class{constructor(e,r,n){this.type=e,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};f();f();var c_=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",ltt=new TextDecoder,ftt=new TextEncoder;function _R(t){return c_&&globalThis.Buffer.isBuffer(t)}function Kve(t){return t instanceof Uint8Array?_R(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t:Uint8Array.from(t)}var Fve=c_?(t,e,r)=>r-e>64?globalThis.Buffer.from(t.subarray(e,r)).toString("utf8"):qve(t,e,r):(t,e,r)=>r-e>64?ltt.decode(t.subarray(e,r)):qve(t,e,r),zve=c_?t=>t.length>64?globalThis.Buffer.from(t):Uve(t):t=>t.length>64?ftt.encode(t):Uve(t);var d_=c_?(t,e,r)=>_R(t)?new Uint8Array(t.subarray(e,r)):t.slice(e,r):(t,e,r)=>t.slice(e,r),Wve=c_?(t,e)=>(t=t.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),Kve(globalThis.Buffer.concat(t,e))):(t,e)=>{let r=new Uint8Array(e),n=0;for(let i of t)n+i.length>r.length&&(i=i.subarray(0,r.length-n)),r.set(i,n),n+=i.length;return r},Hve=c_?t=>globalThis.Buffer.allocUnsafe(t):t=>new Uint8Array(t);function Vve(t,e){if(_R(t)&&_R(e))return t.compare(e);for(let r=0;r>6|192,e[r++]=i&63|128):(i&64512)===55296&&n+1>18|240,e[r++]=i>>12&63|128,e[r++]=i>>6&63|128,e[r++]=i&63|128):(e[r++]=i>>12|224,e[r++]=i>>6&63|128,e[r++]=i&63|128)}return e}function qve(t,e,r){let n=[];for(;e239?4:i>223?3:i>191?2:1;if(e+s<=r){let a,d,u,c;switch(s){case 1:i<128&&(o=i);break;case 2:a=t[e+1],(a&192)===128&&(c=(i&31)<<6|a&63,c>127&&(o=c));break;case 3:a=t[e+1],d=t[e+2],(a&192)===128&&(d&192)===128&&(c=(i&15)<<12|(a&63)<<6|d&63,c>2047&&(c<55296||c>57343)&&(o=c));break;case 4:a=t[e+1],d=t[e+2],u=t[e+3],(a&192)===128&&(d&192)===128&&(u&192)===128&&(c=(i&15)<<18|(a&63)<<12|(d&63)<<6|u&63,c>65535&&c<1114112&&(o=c))}}o===null?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),e+=s}return htt(n)}var Lve=4096;function htt(t){let e=t.length;if(e<=Lve)return String.fromCharCode.apply(String,t);let r="",n=0;for(;nn.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=d_(n,0,this.cursor)}else r=Wve(this.chunks,this.cursor);return e&&this.reset(),r}};f();var zt="CBOR decode error:",KF="CBOR encode error:",M3=[];M3[23]=1;M3[24]=2;M3[25]=3;M3[26]=5;M3[27]=9;function Sp(t,e,r){if(t.length-e>>8,n&255])}else if(r>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n>BigInt(32)&BigInt(4294967295));i[8]=o&255,o=o>>8,i[7]=o&255,o=o>>8,i[6]=o&255,o=o>>8,i[5]=o&255,i[4]=s&255,s=s>>8,i[3]=s&255,s=s>>8,i[2]=s&255,s=s>>8,i[1]=s&255,t.push(i)}else throw new Error(`${zt} encountered BigInt larger than allowable range`)}}ou.encodedSize=function(e){return Ms.encodedSize(e.value)};Ms.encodedSize=function(e){return er.value?1:0};f();function Xve(t,e,r,n){return new Je(we.negint,-1-cd(t,e+1,n),2)}function Qve(t,e,r,n){return new Je(we.negint,-1-dd(t,e+1,n),3)}function ebe(t,e,r,n){return new Je(we.negint,-1-ud(t,e+1,n),5)}var FF=BigInt(-1),tbe=BigInt(1);function rbe(t,e,r,n){let i=ld(t,e+1,n);if(typeof i!="bigint"){let o=-1-i;if(o>=Number.MIN_SAFE_INTEGER)return new Je(we.negint,o,9)}if(n.allowBigInt!==!0)throw new Error(`${zt} integers outside of the safe integer range are not supported`);return new Je(we.negint,FF-BigInt(i),9)}function ER(t,e){let r=e.value,n=typeof r=="bigint"?r*FF-tbe:r*-1-1;Ms(t,e.type.majorEncoded,n)}ER.encodedSize=function(e){let r=e.value,n=typeof r=="bigint"?r*FF-tbe:r*-1-1;return nr.value?-1:0};f();function O3(t,e,r,n){Sp(t,e,r+n);let i=d_(t,e+r,e+r+n);return new Je(we.bytes,i,r+n)}function nbe(t,e,r,n){return O3(t,e,1,r)}function ibe(t,e,r,n){return O3(t,e,2,cd(t,e+1,n))}function obe(t,e,r,n){return O3(t,e,3,dd(t,e+1,n))}function sbe(t,e,r,n){return O3(t,e,5,ud(t,e+1,n))}function abe(t,e,r,n){let i=ld(t,e+1,n);if(typeof i=="bigint")throw new Error(`${zt} 64-bit integer bytes lengths not supported`);return O3(t,e,9,i)}function SR(t){return t.encodedBytes===void 0&&(t.encodedBytes=t.type===we.string?zve(t.value):t.value),t.encodedBytes}function u_(t,e){let r=SR(e);Ms(t,e.type.majorEncoded,r.length),t.push(r)}u_.encodedSize=function(e){let r=SR(e);return Ms.encodedSize(r.length)+r.length};u_.compareTokens=function(e,r){return ytt(SR(e),SR(r))};function ytt(t,e){return t.lengthe.length?1:Vve(t,e)}f();function C3(t,e,r,n,i){let o=r+n;Sp(t,e,o);let s=new Je(we.string,Fve(t,e+r,e+o),o);return i.retainStringBytes===!0&&(s.byteValue=d_(t,e+r,e+o)),s}function cbe(t,e,r,n){return C3(t,e,1,r,n)}function dbe(t,e,r,n){return C3(t,e,2,cd(t,e+1,n),n)}function ube(t,e,r,n){return C3(t,e,3,dd(t,e+1,n),n)}function lbe(t,e,r,n){return C3(t,e,5,ud(t,e+1,n),n)}function fbe(t,e,r,n){let i=ld(t,e+1,n);if(typeof i=="bigint")throw new Error(`${zt} 64-bit integer string lengths not supported`);return C3(t,e,9,i,n)}var hbe=u_;f();function l_(t,e,r,n){return new Je(we.array,n,r)}function pbe(t,e,r,n){return l_(t,e,1,r)}function mbe(t,e,r,n){return l_(t,e,2,cd(t,e+1,n))}function ybe(t,e,r,n){return l_(t,e,3,dd(t,e+1,n))}function gbe(t,e,r,n){return l_(t,e,5,ud(t,e+1,n))}function vbe(t,e,r,n){let i=ld(t,e+1,n);if(typeof i=="bigint")throw new Error(`${zt} 64-bit integer array lengths not supported`);return l_(t,e,9,i)}function bbe(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${zt} indefinite length items not allowed`);return l_(t,e,1,1/0)}function AR(t,e){Ms(t,we.array.majorEncoded,e.value)}AR.compareTokens=ou.compareTokens;AR.encodedSize=function(e){return Ms.encodedSize(e.value)};f();function f_(t,e,r,n){return new Je(we.map,n,r)}function wbe(t,e,r,n){return f_(t,e,1,r)}function _be(t,e,r,n){return f_(t,e,2,cd(t,e+1,n))}function xbe(t,e,r,n){return f_(t,e,3,dd(t,e+1,n))}function Ebe(t,e,r,n){return f_(t,e,5,ud(t,e+1,n))}function Sbe(t,e,r,n){let i=ld(t,e+1,n);if(typeof i=="bigint")throw new Error(`${zt} 64-bit integer map lengths not supported`);return f_(t,e,9,i)}function Abe(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${zt} indefinite length items not allowed`);return f_(t,e,1,1/0)}function TR(t,e){Ms(t,we.map.majorEncoded,e.value)}TR.compareTokens=ou.compareTokens;TR.encodedSize=function(e){return Ms.encodedSize(e.value)};f();function Tbe(t,e,r,n){return new Je(we.tag,r,1)}function Pbe(t,e,r,n){return new Je(we.tag,cd(t,e+1,n),2)}function Ibe(t,e,r,n){return new Je(we.tag,dd(t,e+1,n),3)}function kbe(t,e,r,n){return new Je(we.tag,ud(t,e+1,n),5)}function Rbe(t,e,r,n){return new Je(we.tag,ld(t,e+1,n),9)}function PR(t,e){Ms(t,we.tag.majorEncoded,e.value)}PR.compareTokens=ou.compareTokens;PR.encodedSize=function(e){return Ms.encodedSize(e.value)};f();var xtt=20,Ett=21,Stt=22,Att=23;function Dbe(t,e,r,n){if(n.allowUndefined===!1)throw new Error(`${zt} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new Je(we.null,null,1):new Je(we.undefined,void 0,1)}function Bbe(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${zt} indefinite length items not allowed`);return new Je(we.break,void 0,1)}function zF(t,e,r){if(r){if(r.allowNaN===!1&&Number.isNaN(t))throw new Error(`${zt} NaN values are not supported`);if(r.allowInfinity===!1&&(t===1/0||t===-1/0))throw new Error(`${zt} Infinity values are not supported`)}return new Je(we.float,t,e)}function Mbe(t,e,r,n){return zF(WF(t,e+1),3,n)}function Obe(t,e,r,n){return zF(HF(t,e+1),5,n)}function Cbe(t,e,r,n){return zF(Ube(t,e+1),9,n)}function IR(t,e,r){let n=e.value;if(n===!1)t.push([we.float.majorEncoded|xtt]);else if(n===!0)t.push([we.float.majorEncoded|Ett]);else if(n===null)t.push([we.float.majorEncoded|Stt]);else if(n===void 0)t.push([we.float.majorEncoded|Att]);else{let i,o=!1;(!r||r.float64!==!0)&&(jbe(n),i=WF(hl,1),n===i||Number.isNaN(n)?(hl[0]=249,t.push(hl.slice(0,3)),o=!0):(Nbe(n),i=HF(hl,1),n===i&&(hl[0]=250,t.push(hl.slice(0,5)),o=!0))),o||(Ttt(n),i=Ube(hl,1),hl[0]=251,t.push(hl.slice(0,9)))}}IR.encodedSize=function(e,r){let n=e.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){jbe(n);let i=WF(hl,1);if(n===i||Number.isNaN(n))return 3;if(Nbe(n),i=HF(hl,1),n===i)return 5}return 9};var $be=new ArrayBuffer(9),su=new DataView($be,1),hl=new Uint8Array($be,0);function jbe(t){if(t===1/0)su.setUint16(0,31744,!1);else if(t===-1/0)su.setUint16(0,64512,!1);else if(Number.isNaN(t))su.setUint16(0,32256,!1);else{su.setFloat32(0,t);let e=su.getUint32(0),r=(e&2139095040)>>23,n=e&8388607;if(r===255)su.setUint16(0,31744,!1);else if(r===0)su.setUint16(0,(t&2147483648)>>16|n>>13,!1);else{let i=r-127;i<-24?su.setUint16(0,0):i<-14?su.setUint16(0,(e&2147483648)>>16|1<<24+i,!1):su.setUint16(0,(e&2147483648)>>16|i+15<<10|n>>13,!1)}}}function WF(t,e){if(t.length-e<2)throw new Error(`${zt} not enough data for float16`);let r=(t[e]<<8)+t[e+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,i=r&1023,o;return n===0?o=i*2**-24:n!==31?o=(i+1024)*2**(n-25):o=i===0?1/0:NaN,r&32768?-o:o}function Nbe(t){su.setFloat32(0,t,!1)}function HF(t,e){if(t.length-e<4)throw new Error(`${zt} not enough data for float32`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,4).getFloat32(0,!1)}function Ttt(t){su.setFloat64(0,t,!1)}function Ube(t,e){if(t.length-e<8)throw new Error(`${zt} not enough data for float64`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,8).getFloat64(0,!1)}IR.compareTokens=ou.compareTokens;function Jr(t,e,r){throw new Error(`${zt} encountered invalid minor (${r}) for major ${t[e]>>>5}`)}function kR(t){return()=>{throw new Error(`${zt} ${t}`)}}var $e=[];for(let t=0;t<=23;t++)$e[t]=Jr;$e[24]=Gve;$e[25]=Jve;$e[26]=Zve;$e[27]=Yve;$e[28]=Jr;$e[29]=Jr;$e[30]=Jr;$e[31]=Jr;for(let t=32;t<=55;t++)$e[t]=Jr;$e[56]=Xve;$e[57]=Qve;$e[58]=ebe;$e[59]=rbe;$e[60]=Jr;$e[61]=Jr;$e[62]=Jr;$e[63]=Jr;for(let t=64;t<=87;t++)$e[t]=nbe;$e[88]=ibe;$e[89]=obe;$e[90]=sbe;$e[91]=abe;$e[92]=Jr;$e[93]=Jr;$e[94]=Jr;$e[95]=kR("indefinite length bytes/strings are not supported");for(let t=96;t<=119;t++)$e[t]=cbe;$e[120]=dbe;$e[121]=ube;$e[122]=lbe;$e[123]=fbe;$e[124]=Jr;$e[125]=Jr;$e[126]=Jr;$e[127]=kR("indefinite length bytes/strings are not supported");for(let t=128;t<=151;t++)$e[t]=pbe;$e[152]=mbe;$e[153]=ybe;$e[154]=gbe;$e[155]=vbe;$e[156]=Jr;$e[157]=Jr;$e[158]=Jr;$e[159]=bbe;for(let t=160;t<=183;t++)$e[t]=wbe;$e[184]=_be;$e[185]=xbe;$e[186]=Ebe;$e[187]=Sbe;$e[188]=Jr;$e[189]=Jr;$e[190]=Jr;$e[191]=Abe;for(let t=192;t<=215;t++)$e[t]=Tbe;$e[216]=Pbe;$e[217]=Ibe;$e[218]=kbe;$e[219]=Rbe;$e[220]=Jr;$e[221]=Jr;$e[222]=Jr;$e[223]=Jr;for(let t=224;t<=243;t++)$e[t]=kR("simple values are not supported");$e[244]=Jr;$e[245]=Jr;$e[246]=Jr;$e[247]=Dbe;$e[248]=kR("simple values are not supported");$e[249]=Mbe;$e[250]=Obe;$e[251]=Cbe;$e[252]=Jr;$e[253]=Jr;$e[254]=Jr;$e[255]=Bbe;var pl=[];for(let t=0;t<24;t++)pl[t]=new Je(we.uint,t,1);for(let t=-1;t>=-24;t--)pl[31-t]=new Je(we.negint,t,1);pl[64]=new Je(we.bytes,new Uint8Array(0),1);pl[96]=new Je(we.string,"",1);pl[128]=new Je(we.array,0,1);pl[160]=new Je(we.map,0,1);pl[244]=new Je(we.false,!1,1);pl[245]=new Je(we.true,!0,1);pl[246]=new Je(we.null,null,1);function Itt(){let t=[];return t[we.uint.major]=ou,t[we.negint.major]=ER,t[we.bytes.major]=u_,t[we.string.major]=hbe,t[we.array.major]=AR,t[we.map.major]=TR,t[we.tag.major]=PR,t[we.float.major]=IR,t}var fNt=Itt(),hNt=new xR,RR=class t{constructor(e,r){this.obj=e,this.parent=r}includes(e){let r=this;do if(r.obj===e)return!0;while(r=r.parent);return!1}static createCheck(e,r){if(e&&e.includes(r))throw new Error(`${KF} object contains circular references`);return new t(r,e)}},Xy={null:new Je(we.null,null),undefined:new Je(we.undefined,void 0),true:new Je(we.true,!0),false:new Je(we.false,!1),emptyArray:new Je(we.array,0),emptyMap:new Je(we.map,0)},Qy={number(t,e,r,n){return!Number.isInteger(t)||!Number.isSafeInteger(t)?new Je(we.float,t):t>=0?new Je(we.uint,t):new Je(we.negint,t)},bigint(t,e,r,n){return t>=BigInt(0)?new Je(we.uint,t):new Je(we.negint,t)},Uint8Array(t,e,r,n){return new Je(we.bytes,t)},string(t,e,r,n){return new Je(we.string,t)},boolean(t,e,r,n){return t?Xy.true:Xy.false},null(t,e,r,n){return Xy.null},undefined(t,e,r,n){return Xy.undefined},ArrayBuffer(t,e,r,n){return new Je(we.bytes,new Uint8Array(t))},DataView(t,e,r,n){return new Je(we.bytes,new Uint8Array(t.buffer,t.byteOffset,t.byteLength))},Array(t,e,r,n){if(!t.length)return r.addBreakTokens===!0?[Xy.emptyArray,new Je(we.break)]:Xy.emptyArray;n=RR.createCheck(n,t);let i=[],o=0;for(let s of t)i[o++]=VF(s,r,n);return r.addBreakTokens?[new Je(we.array,t.length),i,new Je(we.break)]:[new Je(we.array,t.length),i]},Object(t,e,r,n){let i=e!=="Object",o=i?t.keys():Object.keys(t),s=i?t.size:o.length;if(!s)return r.addBreakTokens===!0?[Xy.emptyMap,new Je(we.break)]:Xy.emptyMap;n=RR.createCheck(n,t);let a=[],d=0;for(let u of o)a[d++]=[VF(u,r,n),VF(i?t.get(u):t[u],r,n)];return ktt(a,r),r.addBreakTokens?[new Je(we.map,s),a,new Je(we.break)]:[new Je(we.map,s),a]}};Qy.Map=Qy.Object;Qy.Buffer=Qy.Uint8Array;for(let t of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Qy[`${t}Array`]=Qy.DataView;function VF(t,e={},r){let n=Nve(t),i=e&&e.typeEncoders&&e.typeEncoders[n]||Qy[n];if(typeof i=="function"){let s=i(t,n,e,r);if(s!=null)return s}let o=Qy[n];if(!o)throw new Error(`${KF} unsupported type: ${n}`);return o(t,n,e,r)}function ktt(t,e){e.mapSorter&&t.sort(e.mapSorter)}f();var Rtt={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},DR=class{constructor(e,r={}){this._pos=0,this.data=e,this.options=r}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let e=this.data[this._pos],r=pl[e];if(r===void 0){let n=$e[e];if(!n)throw new Error(`${zt} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);let i=e&31;r=n(this.data,this._pos,i,this.options)}return this._pos+=r.encodedLength,r}},$3=Symbol.for("DONE"),BR=Symbol.for("BREAK");function Dtt(t,e,r){let n=[];for(let i=0;i0)throw new Error(`${zt} too many terminals, data makes no sense`);return r}var Ctt=42;function $tt(t){if(t[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return ah.decode(t.subarray(1))}var Lbe={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:[]};Lbe.tags[Ctt]=$tt;var Kbe=113;var Fbe=t=>GF(t,Lbe);var Swe=gt(Oc(),1);f();var Wbe=0,jtt="identity",Hbe=pu,Ntt=t=>k0(Wbe,Hbe(t)),Vbe={code:Wbe,name:jtt,encode:Hbe,digest:Ntt};f();var Gbe=gt(Oc(),1);var Utt=async(t,e,r,n,i,o,s,a)=>{let d=await s.get(t,a),u=Fbe(d),c=u,l=r;for(;n.length>0;){let p=n[0];if(p in c){n.shift(),l=`${l}/${p}`;let m=Nr.asCID(c[p]);if(m!=null)return{entry:{type:"object",name:e,path:r,cid:t,node:d,depth:o,size:BigInt(d.length),content:async function*(){yield u}},next:{cid:m,name:p,path:l,toResolve:n}};c=c[p]}else throw(0,Gbe.default)(new Error(`No property named ${p} found in cbor node ${t}`),"ERR_NO_PROP")}return{entry:{type:"object",name:e,path:r,cid:t,node:d,depth:o,size:BigInt(d.length),content:async function*(){yield u}}}},Jbe=Utt;f();var Zbe=gt(Oc(),1);f();function qtt(t,e,r,n){let i=BigInt(t.length),o=BigInt(e+i);return r>=o||n=e&&n=e&&r{let n=BigInt(t),i=BigInt(e??0),o=BigInt(r);if(o!==n&&(o=i+o),o>n&&(o=n),i<0n)throw(0,j3.default)(new Error("Offset must be greater than or equal to 0"),"ERR_INVALID_PARAMS");if(i>n)throw(0,j3.default)(new Error("Offset must be less than the file size"),"ERR_INVALID_PARAMS");if(o<0n)throw(0,j3.default)(new Error("Length must be greater than or equal to 0"),"ERR_INVALID_PARAMS");if(o>n)throw(0,j3.default)(new Error("Length must be less than the file size"),"ERR_INVALID_PARAMS");return{start:i,end:o}},p_=Ltt;var Ktt=t=>{async function*e(r={}){let{start:n,end:i}=p_(t.length,r.offset,r.length),o=fb(t,0n,n,i);r.onProgress?.(new vi("unixfs:exporter:progress:identity",{bytesRead:BigInt(o.byteLength),totalBytes:i-n,fileSize:BigInt(t.byteLength)})),yield o}return e},Ftt=async(t,e,r,n,i,o,s,a)=>{if(n.length>0)throw(0,Zbe.default)(new Error(`No link named ${r} found in raw node ${t}`),"ERR_NOT_FOUND");let d=n8(t.multihash.bytes);return{entry:{type:"identity",name:e,path:r,cid:t,content:Ktt(d.digest),depth:o,size:BigInt(d.digest.length),node:d.digest}}},Ybe=Ftt;f();var Xbe=gt(Oc(),1);var ztt=t=>{async function*e(r={}){let{start:n,end:i}=p_(t.length,r.offset,r.length),o=fb(t,0n,n,i);r.onProgress?.(new vi("unixfs:exporter:progress:raw",{bytesRead:BigInt(o.byteLength),totalBytes:i-n,fileSize:BigInt(t.byteLength)})),yield o}return e},Wtt=async(t,e,r,n,i,o,s,a)=>{if(n.length>0)throw(0,Xbe.default)(new Error(`No link named ${r} found in raw node ${t}`),"ERR_NOT_FOUND");let d=await s.get(t,a);return{entry:{type:"raw",name:e,path:r,cid:t,content:ztt(d),depth:o,size:BigInt(d.length),node:d}}},Qbe=Wtt;f();var W3=gt(Oc(),1);f();var Htt=async function(t){return(await q8.encode(t)).slice(0,8).reverse()},Vtt=async(t,e,r)=>{await Promise.all(t.map(async n=>{if(n.Name==null)throw new Error("Unexpected Link without a Name");if(n.Name.length===2){let i=parseInt(n.Name,16);e._putObjectAt(i,new Dl({hash:r._options.hash,bits:r._options.bits},e,i));return}await r.put(n.Name.substring(2),!0)}))},ewe=t=>t.toString(16).toUpperCase().padStart(2,"0").substring(0,2),Gtt=t=>{let e=t.bucket,r=[];for(;e._parent!=null;)r.push(e),e=e._parent;return r.push(e),r.reverse()},twe=async(t,e,r,n,i)=>{if(n==null){let c=F8({hashFn:Htt});n={rootBucket:c,hamtDepth:1,lastBucket:c}}await Vtt(t.Links,n.lastBucket,n.rootBucket);let o=await n.rootBucket._findNewBucketAndPos(e),s=ewe(o.pos),a=Gtt(o);a.length>n.hamtDepth&&(n.lastBucket=a[n.hamtDepth],s=ewe(n.lastBucket._posAtParent));let d=t.Links.find(c=>{if(c.Name==null)return!1;let l=c.Name.substring(0,2),p=c.Name.substring(2);return!(l!==s||p!==""&&p!==e)});if(d==null)return;if(d.Name!=null&&d.Name.substring(2)===e)return d.Hash;n.hamtDepth++;let u=await r.get(d.Hash,i);return t=ch(u),twe(t,e,r,n,i)},rwe=twe;f();f();f();function Jtt(t){let[e,r]=t[Symbol.asyncIterator]!=null?[t[Symbol.asyncIterator](),Symbol.asyncIterator]:[t[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>e.next(),push:i=>{n.push(i)},next:()=>n.length>0?{done:!1,value:n.shift()}:e.next(),[r](){return this}}}var MR=Jtt;function Ztt(t){return t[Symbol.asyncIterator]!=null}function Ytt(t,e){let r=0;if(Ztt(t))return async function*(){for await(let d of t)await e(d,r++)&&(yield d)}();let n=MR(t),{value:i,done:o}=n.next();if(o===!0)return function*(){}();let s=e(i,r++);if(typeof s.then=="function")return async function*(){await s&&(yield i);for await(let d of n)await e(d,r++)&&(yield d)}();let a=e;return function*(){s===!0&&(yield i);for(let d of n)a(d,r++)&&(yield d)}()}var nwe=Ytt;f();function Xtt(t){return t[Symbol.asyncIterator]!=null}function Qtt(t,e){let r=0;if(Xtt(t))return async function*(){for await(let d of t)yield e(d,r++)}();let n=MR(t),{value:i,done:o}=n.next();if(o===!0)return function*(){}();let s=e(i,r++);if(typeof s.then=="function")return async function*(){yield await s;for await(let d of n)yield e(d,r++)}();let a=e;return function*(){yield s;for(let d of n)yield a(d,r++)}()}var m_=Qtt;f();f();function Ap(){let t={};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t}var OR=globalThis.CustomEvent??Event;async function*hb(t,e={}){let r=e.concurrency??1/0;r<1&&(r=1/0);let n=e.ordered==null?!1:e.ordered,i=new EventTarget,o=[],s=Ap(),a=Ap(),d=!1,u,c=!1;i.addEventListener("task-complete",()=>{a.resolve()}),Promise.resolve().then(async()=>{try{for await(let g of t){if(o.length===r&&(s=Ap(),await s.promise),c)break;let v={done:!1};o.push(v),g().then(x=>{v.done=!0,v.ok=!0,v.value=x,i.dispatchEvent(new OR("task-complete"))},x=>{v.done=!0,v.err=x,i.dispatchEvent(new OR("task-complete"))})}d=!0,i.dispatchEvent(new OR("task-complete"))}catch(g){u=g,i.dispatchEvent(new OR("task-complete"))}});function l(){return n?o[0]?.done:!!o.find(g=>g.done)}function*p(){for(;o.length>0&&o[0].done;){let g=o[0];if(o.shift(),g.ok)yield g.value;else throw c=!0,s.resolve(),g.err;s.resolve()}}function*m(){for(;l();)for(let g=0;g0)||e-1&e)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return this.buffer[this.btm]===void 0}},y_=class{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new CR(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return e?.byteLength!=null?e.byteLength:1}push(e){if(e?.value!=null&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){let r=this.head;this.head=r.next=new CR(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next!=null){let r=this.tail.next;this.tail.next=null,this.tail=r,e=this.tail.shift()}return e?.value!=null&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}};var JF=class extends Error{type;code;constructor(e,r){super(e??"The operation was aborted"),this.type="aborted",this.code=r??"ABORT_ERR"}};function g_(t={}){return ert(r=>{let n=r.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},t)}function ert(t,e){e=e??{};let r=e.onEnd,n=new y_,i,o,s,a=Ap(),d=async()=>{try{return n.isEmpty()?s?{done:!0}:await new Promise((x,S)=>{o=P=>{o=null,n.push(P);try{x(t(n))}catch(A){S(A)}return i}}):t(n)}finally{n.isEmpty()&&queueMicrotask(()=>{a.resolve(),a=Ap()})}},u=x=>o!=null?o(x):(n.push(x),i),c=x=>(n=new y_,o!=null?o({error:x}):(n.push({error:x}),i)),l=x=>{if(s)return i;if(e?.objectMode!==!0&&x?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return u({done:!1,value:x})},p=x=>s?i:(s=!0,x!=null?c(x):u({done:!0})),m=()=>(n=new y_,p(),{done:!0}),g=x=>(p(x),{done:!0});if(i={[Symbol.asyncIterator](){return this},next:d,return:m,throw:g,push:l,end:p,get readableLength(){return n.size},onEmpty:async x=>{let S=x?.signal;if(S?.throwIfAborted(),n.isEmpty())return;let P,A;S!=null&&(P=new Promise(($,j)=>{A=()=>{j(new JF)},S.addEventListener("abort",A)}));try{await Promise.race([a.promise,P])}finally{A!=null&&S!=null&&S?.removeEventListener("abort",A)}}},r==null)return i;let v=i;return i={[Symbol.asyncIterator](){return this},next(){return v.next()},throw(x){return v.throw(x),r!=null&&(r(x),r=void 0),{done:!0}},return(){return v.return(),r!=null&&(r(),r=void 0),{done:!0}},push:l,end(x){return v.end(x),r!=null&&(r(x),r=void 0),i},get readableLength(){return v.readableLength},onEmpty:x=>v.onEmpty(x)},i}f();function trt(t){return t[Symbol.asyncIterator]!=null}function rrt(...t){let e=[];for(let r of t)trt(r)||e.push(r);return e.length===t.length?function*(){for(let r of e)yield*r}():async function*(){let r=g_({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(t.map(async n=>{for await(let i of n)r.push(i)})),r.end()}catch(n){r.end(n)}}),yield*r}()}var iwe=rrt;function v_(t,...e){if(t==null)throw new Error("Empty pipeline");if(ZF(t)){let n=t;t=()=>n.source}else if(swe(t)||owe(t)){let n=t;t=()=>n}let r=[t,...e];if(r.length>1&&ZF(r[r.length-1])&&(r[r.length-1]=r[r.length-1].sink),r.length>2)for(let n=1;n{let e;for(;t.length>0;)e=t.shift()(e);return e},owe=t=>t?.[Symbol.asyncIterator]!=null,swe=t=>t?.[Symbol.iterator]!=null,ZF=t=>t==null?!1:t.sink!=null&&t.source!=null,irt=t=>e=>{let r=t.sink(e);if(r?.then!=null){let n=g_({objectMode:!0});r.then(()=>{n.end()},s=>{n.end(s)});let i,o=t.source;if(owe(o))i=async function*(){yield*o,n.end()};else if(swe(o))i=function*(){yield*o,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return iwe(n,i())}return t.source};var ort=(t,e,r,n,i,o,s)=>{async function*a(d={}){let u=d.offset??0,c=d.length??e.Links.length,l=e.Links.slice(u,c);d.onProgress?.(new vi("unixfs:exporter:walk:directory",{cid:t})),yield*v_(l,p=>m_(p,m=>async()=>{let g=m.Name??"",v=`${n}/${g}`;return(await i(m.Hash,g,v,[],o+1,s,d)).entry}),p=>hb(p,{ordered:!0}),p=>nwe(p,m=>m!=null))}return a},awe=ort;f();var mb=gt(Oc(),1);f();f();var XF=gt(dwe(),1);f();var U3=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},QF=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},uwe=t=>globalThis.DOMException===void 0?new QF(t):new DOMException(t),lwe=t=>{let e=t.reason===void 0?uwe("This operation was aborted."):t.reason;return e instanceof Error?e:uwe(e)};function ez(t,e,r,n){let i,o=new Promise((s,a)=>{if(typeof e!="number"||Math.sign(e)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${e}\``);if(e===Number.POSITIVE_INFINITY){s(t);return}if(n={customTimers:{setTimeout,clearTimeout},...n},n.signal){let{signal:d}=n;d.aborted&&a(lwe(d)),d.addEventListener("abort",()=>{a(lwe(d))})}i=n.customTimers.setTimeout.call(void 0,()=>{if(typeof r=="function"){try{s(r())}catch(c){a(c)}return}let d=typeof r=="string"?r:`Promise timed out after ${e} milliseconds`,u=r instanceof Error?r:new U3(d);typeof t.cancel=="function"&&t.cancel(),a(u)},e),(async()=>{try{s(await t)}catch(d){a(d)}finally{n.customTimers.clearTimeout.call(void 0,i)}})()});return o.clear=()=>{clearTimeout(i),i=void 0},o}f();f();function tz(t,e,r){let n=0,i=t.length;for(;i>0;){let o=Math.trunc(i/2),s=n+o;r(t[s],e)<=0?(n=++s,i-=o+1):i=o}return n}var pb=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Tp,rz=class{constructor(){Tp.set(this,[])}enqueue(e,r){r={priority:0,...r};let n={priority:r.priority,run:e};if(this.size&&pb(this,Tp,"f")[this.size-1].priority>=r.priority){pb(this,Tp,"f").push(n);return}let i=tz(pb(this,Tp,"f"),n,(o,s)=>s.priority-o.priority);pb(this,Tp,"f").splice(i,0,n)}dequeue(){let e=pb(this,Tp,"f").shift();return e?.run}filter(e){return pb(this,Tp,"f").filter(r=>r.priority===e.priority).map(r=>r.run)}get size(){return pb(this,Tp,"f").length}};Tp=new WeakMap;var fwe=rz;var li=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},ct=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Ni,L3,K3,t0,KR,F3,jR,ml,q3,fd,NR,hd,z3,e0,UR,hwe,pwe,gwe,mwe,ywe,qR,nz,iz,FR,vwe,LR,zR=class extends Error{},oz=class extends XF.default{constructor(e){var r,n,i,o;if(super(),Ni.add(this),L3.set(this,void 0),K3.set(this,void 0),t0.set(this,0),KR.set(this,void 0),F3.set(this,void 0),jR.set(this,0),ml.set(this,void 0),q3.set(this,void 0),fd.set(this,void 0),NR.set(this,void 0),hd.set(this,0),z3.set(this,void 0),e0.set(this,void 0),UR.set(this,void 0),Object.defineProperty(this,"timeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:fwe,...e},!(typeof e.intervalCap=="number"&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(n=(r=e.intervalCap)===null||r===void 0?void 0:r.toString())!==null&&n!==void 0?n:""}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${(o=(i=e.interval)===null||i===void 0?void 0:i.toString())!==null&&o!==void 0?o:""}\` (${typeof e.interval})`);li(this,L3,e.carryoverConcurrencyCount,"f"),li(this,K3,e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,"f"),li(this,KR,e.intervalCap,"f"),li(this,F3,e.interval,"f"),li(this,fd,new e.queueClass,"f"),li(this,NR,e.queueClass,"f"),this.concurrency=e.concurrency,this.timeout=e.timeout,li(this,UR,e.throwOnTimeout===!0,"f"),li(this,e0,e.autoStart===!1,"f")}get concurrency(){return ct(this,z3,"f")}set concurrency(e){if(!(typeof e=="number"&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);li(this,z3,e,"f"),ct(this,Ni,"m",FR).call(this)}async add(e,r={}){return r={timeout:this.timeout,throwOnTimeout:ct(this,UR,"f"),...r},new Promise((n,i)=>{ct(this,fd,"f").enqueue(async()=>{var o,s,a;li(this,hd,(s=ct(this,hd,"f"),s++,s),"f"),li(this,t0,(a=ct(this,t0,"f"),a++,a),"f");try{if(!((o=r.signal)===null||o===void 0)&&o.aborted)throw new zR("The task was aborted.");let d=e({signal:r.signal});r.timeout&&(d=ez(Promise.resolve(d),r.timeout)),r.signal&&(d=Promise.race([d,ct(this,Ni,"m",vwe).call(this,r.signal)]));let u=await d;n(u),this.emit("completed",u)}catch(d){if(d instanceof U3&&!r.throwOnTimeout){n();return}i(d),this.emit("error",d)}finally{ct(this,Ni,"m",gwe).call(this)}},r),this.emit("add"),ct(this,Ni,"m",qR).call(this)})}async addAll(e,r){return Promise.all(e.map(async n=>this.add(n,r)))}start(){return ct(this,e0,"f")?(li(this,e0,!1,"f"),ct(this,Ni,"m",FR).call(this),this):this}pause(){li(this,e0,!0,"f")}clear(){li(this,fd,new(ct(this,NR,"f")),"f")}async onEmpty(){ct(this,fd,"f").size!==0&&await ct(this,Ni,"m",LR).call(this,"empty")}async onSizeLessThan(e){ct(this,fd,"f").sizect(this,fd,"f").size{ct(this,Ni,"m",mwe).call(this)},r),"f"),!0}return!1},qR=function(){if(ct(this,fd,"f").size===0)return ct(this,ml,"f")&&clearInterval(ct(this,ml,"f")),li(this,ml,void 0,"f"),this.emit("empty"),ct(this,hd,"f")===0&&this.emit("idle"),!1;if(!ct(this,e0,"f")){let e=!ct(this,Ni,"a",ywe);if(ct(this,Ni,"a",hwe)&&ct(this,Ni,"a",pwe)){let r=ct(this,fd,"f").dequeue();return r?(this.emit("active"),r(),e&&ct(this,Ni,"m",nz).call(this),!0):!1}}return!1},nz=function(){ct(this,K3,"f")||ct(this,ml,"f")!==void 0||(li(this,ml,setInterval(()=>{ct(this,Ni,"m",iz).call(this)},ct(this,F3,"f")),"f"),li(this,jR,Date.now()+ct(this,F3,"f"),"f"))},iz=function(){ct(this,t0,"f")===0&&ct(this,hd,"f")===0&&ct(this,ml,"f")&&(clearInterval(ct(this,ml,"f")),li(this,ml,void 0,"f")),li(this,t0,ct(this,L3,"f")?ct(this,hd,"f"):0,"f"),ct(this,Ni,"m",FR).call(this)},FR=function(){for(;ct(this,Ni,"m",qR).call(this););},vwe=async function(e){return new Promise((r,n)=>{e.addEventListener("abort",()=>{n(new zR("The task was aborted."))},{once:!0})})},LR=async function(e,r){return new Promise(n=>{let i=()=>{r&&!r()||(this.off(e,i),n())};this.on(e,i)})};var bwe=oz;async function wwe(t,e,r,n,i,o,s){if(e instanceof Uint8Array){let u=fb(e,n,i,o);r.push(u);return}if(e.Data==null)throw(0,mb.default)(new Error("no data in PBNode"),"ERR_NOT_UNIXFS");let a;try{a=Ro.unmarshal(e.Data)}catch(u){throw(0,mb.default)(u,"ERR_NOT_UNIXFS")}if(a.data!=null){let u=a.data,c=fb(u,n,i,o);r.push(c),n+=BigInt(c.byteLength)}let d=[];if(e.Links.length!==a.blockSizes.length)throw(0,mb.default)(new Error("Inconsistent block sizes and dag links"),"ERR_NOT_UNIXFS");for(let u=0;u=l&&i=l&&o<=p||ip)&&d.push({link:c,blockStart:n}),n=p,n>o)break}await v_(d,u=>m_(u,c=>async()=>{let l=await t.get(c.link.Hash,s);return{...c,block:l}}),u=>hb(u,{ordered:!0}),async u=>{for await(let{link:c,block:l,blockStart:p}of u){let m;switch(c.Hash.code){case Ix:m=ch(l);break;case lm:m=l;break;default:r.end((0,mb.default)(new Error(`Unsupported codec: ${c.Hash.code}`),"ERR_NOT_UNIXFS"));return}let g=new bwe({concurrency:1});g.on("error",v=>{r.end(v)}),g.add(async()=>{s.onProgress?.(new vi("unixfs:exporter:walk:file",{cid:c.Hash})),await wwe(t,m,r,p,i,o,s)}),await g.onIdle()}}),n>=o&&r.end()}var crt=(t,e,r,n,i,o,s)=>{async function*a(d={}){let u=r.fileSize();if(u===void 0)throw new Error("File was a directory");let{start:c,end:l}=p_(u,d.offset,d.length);if(l===0n)return;let p=0n,m=l-c,g=g_();d.onProgress?.(new vi("unixfs:exporter:walk:file",{cid:t})),wwe(s,e,g,0n,c,l,d).catch(v=>{g.end(v)});for await(let v of g)if(v!=null){if(p+=BigInt(v.byteLength),p>m)throw g.end(),(0,mb.default)(new Error("Read too many bytes - the file size reported by the UnixFS data in the root node may be incorrect"),"ERR_OVER_READ");p===m&&g.end(),d.onProgress?.(new vi("unixfs:exporter:progress:unixfs:file",{bytesRead:p,totalBytes:m,fileSize:u})),yield v}if(p{function a(d={}){return d.onProgress?.(new vi("unixfs:exporter:walk:hamt-sharded-directory",{cid:t})),_we(e,n,i,o,s,d)}return a};async function*_we(t,e,r,n,i,o){let s=t.Links,a=v_(s,d=>m_(d,u=>async()=>{let c=u.Name!=null?u.Name.substring(2):null;if(c!=null&&c!==""){let l=await r(u.Hash,c,`${e}/${c}`,[],n+1,i,o);return{entries:l.entry==null?[]:[l.entry]}}else{let l=await i.get(u.Hash,o);return t=ch(l),o.onProgress?.(new vi("unixfs:exporter:walk:hamt-sharded-directory",{cid:u.Hash})),{entries:_we(t,e,r,n,i,o)}}}),d=>hb(d,{ordered:!0}));for await(let{entries:d}of a)yield*d}var xwe=drt;var urt=(t,e)=>t.Links.find(n=>n.Name===e)?.Hash,lrt={raw:sz,file:sz,directory:awe,"hamt-sharded-directory":xwe,metadata:(t,e,r,n,i,o,s)=>()=>[],symlink:(t,e,r,n,i,o,s)=>()=>[]},frt=async(t,e,r,n,i,o,s,a)=>{let d=await s.get(t,a),u=ch(d),c,l;if(e==null&&(e=t.toString()),u.Data==null)throw(0,W3.default)(new Error("no data in PBNode"),"ERR_NOT_UNIXFS");try{c=Ro.unmarshal(u.Data)}catch(m){throw(0,W3.default)(m,"ERR_NOT_UNIXFS")}if(r==null&&(r=e),n.length>0){let m;if(c?.type==="hamt-sharded-directory"?m=await rwe(u,n[0],s):m=urt(u,n[0]),m==null)throw(0,W3.default)(new Error("file does not exist"),"ERR_NOT_FOUND");let g=n.shift(),v=`${r}/${g}`;l={cid:m,toResolve:n,name:g??"",path:v}}let p=lrt[c.type](t,u,c,r,i,o,s);if(p==null)throw(0,W3.default)(new Error("could not find content exporter"),"ERR_NOT_FOUND");return c.isDirectory()?{entry:{type:"directory",name:e,path:r,cid:t,content:p,unixfs:c,depth:o,node:u,size:c.fileSize()},next:l}:{entry:{type:"file",name:e,path:r,cid:t,content:p,unixfs:c,depth:o,node:u,size:c.fileSize()},next:l}},Ewe=frt;var hrt={[Ix]:Ewe,[lm]:Qbe,[Kbe]:Jbe,[Vbe.code]:Ybe},Awe=async(t,e,r,n,i,o,s)=>{let a=hrt[t.code];if(a==null)throw(0,Swe.default)(new Error(`No resolver for code ${t.code}`),"ERR_NO_RESOLVER");return a(t,e,r,n,Awe,i,o,s)},Twe=Awe;var prt=(t="")=>(t.trim().match(/([^\\^/]|\\\/)+/g)??[]).filter(Boolean),mrt=t=>{if(t instanceof Uint8Array)return{cid:Nr.decode(t),toResolve:[]};let e=Nr.asCID(t);if(e!=null)return{cid:e,toResolve:[]};if(typeof t=="string"){t.indexOf("/ipfs/")===0&&(t=t.substring(6));let r=prt(t);return{cid:Nr.parse(r[0]),toResolve:r.slice(1)}}throw(0,WR.default)(new Error(`Unknown path type ${t}`),"ERR_BAD_PATH")};async function*yrt(t,e,r={}){let{cid:n,toResolve:i}=mrt(t),o=n.toString(),s=o,a=i.length;for(;;){let d=await Twe(n,o,s,i,a,e,r);if(d.entry==null&&d.next==null)throw(0,WR.default)(new Error(`Could not resolve ${t}`),"ERR_NOT_FOUND");if(d.entry!=null&&(yield d.entry),d.next==null)return;i=d.next.toResolve,n=d.next.cid,o=d.next.name,s=d.next.path}}async function Pwe(t,e,r={}){let n=await jve(yrt(t,e,r));if(n==null)throw(0,WR.default)(new Error(`Could not resolve ${t}`),"ERR_NOT_FOUND");return n}var Iwe=gt(M1(),1),r0=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},grt=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,d){s=t[o](s),i(a,d,s.done,s.value)})}}function i(o,s,a,d){Promise.resolve(d).then(function(u){o({value:u,done:a})},s)}},b_=class{constructor(e={}){this.config=Object.assign({blockstoreLocation:"DATASTORE",createLevelDatabase:ad},e),this.blockstore=new a_({location:this.config.blockstoreLocation,createLevelDatabase:this.config.createLevelDatabase})}open(){return r0(this,void 0,void 0,function*(){yield this.blockstore.open()})}close(){return r0(this,void 0,void 0,function*(){yield this.blockstore.close()})}put(e,r,n,i){var o,s,a,d,u,c;return r0(this,void 0,void 0,function*(){let l=yield this.getBlockstoreForStoringData(e,r,n),p=Ux([{content:i}],l,{cidVersion:1}),m;try{for(var g=!0,v=grt(p),x;x=yield v.next(),o=x.done,!o;g=!0)d=x.value,g=!1,m=d}catch(S){s={error:S}}finally{try{!g&&!o&&(a=v.return)&&(yield a.call(v))}finally{if(s)throw s.error}}return{dataSize:Number((c=(u=m.unixfs)===null||u===void 0?void 0:u.fileSize())!==null&&c!==void 0?c:m.size)}})}get(e,r,n){return r0(this,void 0,void 0,function*(){let i=yield this.getBlockstoreForStoringData(e,r,n);if(!(yield i.has(n)))return;let s=yield Pwe(n,i),a=s.content(),d=new Iwe.Readable({read(){return r0(this,void 0,void 0,function*(){let c=yield a.next();c.done?this.push(null):this.push(c.value)})}}),u=s.size;return(s.type==="file"||s.type==="directory")&&(u=s.unixfs.fileSize()),{dataSize:Number(u),dataStream:d}})}delete(e,r,n){return r0(this,void 0,void 0,function*(){yield(yield this.getBlockstoreForStoringData(e,r,n)).clear()})}clear(){return r0(this,void 0,void 0,function*(){yield this.blockstore.clear()})}getBlockstoreForStoringData(e,r,n){return r0(this,void 0,void 0,function*(){let i="data";return yield(yield(yield(yield this.blockstore.partition(i)).partition(e)).partition(r)).partition(n)})}};f();f();var _o=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},H3=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,d){s=t[o](s),i(a,d,s.done,s.value)})}}function i(o,s,a,d){Promise.resolve(d).then(function(u){o({value:u,done:a})},s)}},yb=function(t){return this instanceof yb?(this.v=t,this):new yb(t)},vrt=function(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),i,o=[];return i={},s("next"),s("throw"),s("return"),i[Symbol.asyncIterator]=function(){return this},i;function s(p){n[p]&&(i[p]=function(m){return new Promise(function(g,v){o.push([p,m,g,v])>1||a(p,m)})})}function a(p,m){try{d(n[p](m))}catch(g){l(o[0][3],g)}}function d(p){p.value instanceof yb?Promise.resolve(p.value.v).then(u,c):l(o[0][2],p)}function u(p){a("next",p)}function c(p){a("throw",p)}function l(p,m){p(m),o.shift(),o.length&&a(o[0][0],o[0][1])}},kwe="index",Pp=class t{constructor(e){this.config=Object.assign({createLevelDatabase:ad},e),this.db=new Yy({location:this.config.location,createLevelDatabase:this.config.createLevelDatabase,keyEncoding:"utf8"})}open(){return _o(this,void 0,void 0,function*(){yield this.db.open()})}close(){return _o(this,void 0,void 0,function*(){yield this.db.close()})}clear(){return _o(this,void 0,void 0,function*(){yield this.db.clear()})}put(e,r,n,i){return _o(this,void 0,void 0,function*(){if(h6(n))throw new de(oe.IndexMissingIndexableProperty,"Index must include at least one valid indexable property");let o={messageCid:r,indexes:n},s=[];for(let c in n){let l=n[c];if(Array.isArray(l))for(let p of l){let m=this.createPutIndexedItemOperation(e,o,c,p);s.push(m)}else{let p=this.createPutIndexedItemOperation(e,o,c,l);s.push(p)}}let a=this.createOperationForIndexesLookupPartition(e,{type:"put",key:r,value:JSON.stringify(n)});s.push(a);let d=yield Promise.all(s);yield(yield this.db.partition(e)).batch(d,i)})}delete(e,r,n){return _o(this,void 0,void 0,function*(){let i=[],o=yield this.getIndexes(e,r);if(o===void 0)return;let s=this.createOperationForIndexesLookupPartition(e,{type:"del",key:r});i.push(s);for(let u in o){let c=o[u];if(Array.isArray(c))for(let l of c){let p=this.createDeleteIndexedItemOperation(e,r,u,l);i.push(p)}else{let l=this.createDeleteIndexedItemOperation(e,r,u,c);i.push(l)}}let a=yield Promise.all(i);yield(yield this.db.partition(e)).batch(a,n)})}createPutIndexedItemOperation(e,r,n,i){return _o(this,void 0,void 0,function*(){let{messageCid:o}=r,s=t.keySegmentJoin(t.encodeValue(i),o);return this.createOperationForIndexPartition(e,n,{type:"put",key:s,value:JSON.stringify(r)})})}createDeleteIndexedItemOperation(e,r,n,i){return _o(this,void 0,void 0,function*(){let o=t.keySegmentJoin(t.encodeValue(i),r);return this.createOperationForIndexPartition(e,n,{type:"del",key:o})})}createOperationForIndexPartition(e,r,n){return _o(this,void 0,void 0,function*(){let i=yield this.db.partition(e),o=t.getIndexPartitionName(r);return i.createPartitionOperation(o,n)})}createOperationForIndexesLookupPartition(e,r){return _o(this,void 0,void 0,function*(){return(yield this.db.partition(e)).createPartitionOperation(kwe,r)})}static getIndexPartitionName(e){return`__${e}__`}getIndexPartition(e,r){return _o(this,void 0,void 0,function*(){let n=t.getIndexPartitionName(r);return(yield this.db.partition(e)).partition(n)})}getIndexesLookupPartition(e){return _o(this,void 0,void 0,function*(){return(yield this.db.partition(e)).partition(kwe)})}query(e,r,n,i){return _o(this,void 0,void 0,function*(){return t.shouldQueryWithInMemoryPaging(r,n)?this.queryWithInMemoryPaging(e,r,n,i):this.queryWithIteratorPaging(e,r,n,i)})}queryWithIteratorPaging(e,r,n,i){var o,s,a,d;return _o(this,void 0,void 0,function*(){let{cursor:u,limit:c}=n,l=u?this.createStartingKeyFromCursor(u):"",p=[];try{for(var m=!0,g=H3(this.getIndexIterator(e,l,n,i)),v;v=yield g.next(),o=v.done,!o;m=!0){d=v.value,m=!1;let x=d;if(c!==void 0&&c===p.length)break;let{indexes:S}=x;Zn.matchAnyFilter(S,r)&&p.push(x)}}catch(x){s={error:x}}finally{try{!m&&!o&&(a=g.return)&&(yield a.call(g))}finally{if(s)throw s.error}}return p})}getIndexIterator(e,r,n,i){return vrt(this,arguments,function*(){var s,a,d,u;let{sortProperty:c,sortDirection:l=Ts.Ascending,cursor:p}=n,m={gt:r};l===Ts.Descending&&(m.reverse=!0,p!==void 0&&(m.lt=r,delete m.gt));let g=yield yb(this.getIndexPartition(e,c));try{for(var v=!0,x=H3(g.iterator(m,i)),S;S=yield yb(x.next()),s=S.done,!s;v=!0){u=S.value,v=!1;let[P,A]=u,{indexes:$,messageCid:j}=JSON.parse(A);yield yield yb({indexes:$,messageCid:j})}}catch(P){a={error:P}}finally{try{!v&&!s&&(d=x.return)&&(yield yb(d.call(x)))}finally{if(a)throw a.error}}})}createStartingKeyFromCursor(e){let{messageCid:r,value:n}=e;return t.keySegmentJoin(t.encodeValue(n),r)}static createCursorFromLastArrayItem(e,r){if(e.length>0)return this.createCursorFromItem(e.at(-1),r)}static createCursorFromItem(e,r){let{messageCid:n,indexes:i}=e,o=i[r];if(o===void 0)throw new de(oe.IndexInvalidCursorSortProperty,`the sort property '${r}' is not defined within the given item.`);if(typeof o=="boolean"||Array.isArray(o))throw new de(oe.IndexInvalidCursorValueType,`only string or number values are supported for cursors, a(n) ${typeof o} was given.`);return{messageCid:n,value:o}}queryWithInMemoryPaging(e,r,n,i){return _o(this,void 0,void 0,function*(){let{sortProperty:o,sortDirection:s=Ts.Ascending,cursor:a,limit:d}=n,u=a?this.createStartingKeyFromCursor(a):void 0,c=new Map;r.length===0&&(r=[{}]);try{yield Promise.all(r.map(g=>this.executeSingleFilterQuery(e,g,o,c,i)))}catch(g){if(g.code===oe.IndexInvalidSortPropertyInMemory)return[]}let l=[...c.values()].sort((g,v)=>this.sortItems(g,v,o,s)),p=u!==void 0?this.findCursorStartingIndex(l,s,o,u):0;if(p<0)return[];let m=d!==void 0?p+d:void 0;return l.slice(p,m)})}executeSingleFilterQuery(e,r,n,i,o){return _o(this,void 0,void 0,function*(){let s=[];if(h6(r)){let d=this.getAllItems(e,n);s.push(d)}let a=ZT.reduceFilter(r);for(let d in a){let u=a[d];if(Zn.isEqualFilter(u)){let c=this.filterExactMatches(e,d,u,o);s.push(c)}else if(Zn.isOneOfFilter(u))for(let c of new Set(u)){let l=this.filterExactMatches(e,d,c,o);s.push(l)}else if(Zn.isRangeFilter(u)){let c=this.filterRangeMatches(e,d,u,o);s.push(c)}}for(let d of s){let u=yield d;for(let c of u)if(!(i.has(c.messageCid)||!Zn.matchFilter(c.indexes,r))){if(c.indexes[n]===void 0)throw new de(oe.IndexInvalidSortPropertyInMemory,`invalid sort property ${n}`);i.set(c.messageCid,c)}}})}getAllItems(e,r){var n,i,o,s;return _o(this,void 0,void 0,function*(){let a=yield this.getIndexPartition(e,r),d=[];try{for(var u=!0,c=H3(a.iterator()),l;l=yield c.next(),n=l.done,!n;u=!0){s=l.value,u=!1;let[p,m]=s;d.push(JSON.parse(m))}}catch(p){i={error:p}}finally{try{!u&&!n&&(o=c.return)&&(yield o.call(c))}finally{if(i)throw i.error}}return d})}filterExactMatches(e,r,n,i){var o,s,a,d;return _o(this,void 0,void 0,function*(){let u=t.keySegmentJoin(t.encodeValue(n)),c={gt:u},l=yield this.getIndexPartition(e,r),p=[];try{for(var m=!0,g=H3(l.iterator(c,i)),v;v=yield g.next(),o=v.done,!o;m=!0){d=v.value,m=!1;let[x,S]=d;if(!x.startsWith(u))break;p.push(JSON.parse(S))}}catch(x){s={error:x}}finally{try{!m&&!o&&(a=g.return)&&(yield a.call(g))}finally{if(s)throw s.error}}return p})}filterRangeMatches(e,r,n,i){var o,s,a,d;return _o(this,void 0,void 0,function*(){let u={};for(let v in n){let x=v;u[x]=t.encodeValue(n[x])}u.gt===void 0&&u.gte===void 0&&(u.reverse=!0);let c=[],l=yield this.getIndexPartition(e,r);try{for(var p=!0,m=H3(l.iterator(u,i)),g;g=yield m.next(),o=g.done,!o;p=!0){d=g.value,p=!1;let[v,x]=d;"gt"in n&&this.extractIndexValueFromKey(v)===t.encodeValue(n.gt)||c.push(JSON.parse(x))}}catch(v){s={error:v}}finally{try{!p&&!o&&(a=m.return)&&(yield a.call(m))}finally{if(s)throw s.error}}if("lte"in n)for(let v of yield this.filterExactMatches(e,r,n.lte,i))c.push(v);return c})}sortItems(e,r,n,i){let o=e.indexes[n],s=r.indexes[n],a=t.encodeValue(o)+e.messageCid,d=t.encodeValue(s)+r.messageCid;return i===Ts.Ascending?f6(a,d):f6(d,a)}findCursorStartingIndex(e,r,n,i){let o=s=>{let{messageCid:a,indexes:d}=s,u=d[n],c=t.keySegmentJoin(t.encodeValue(u),a);return r===Ts.Ascending?c>i:c{let n=new Uint8Array(1);return r.getRandomValues(n),n[0]/255};if(typeof r?.randomBytes=="function")return()=>r.randomBytes(1).readUInt8()/255;throw new yl({info:{code:"PRNG_DETECT",...gb}},"Failed to find a reliable PRNG")}function xrt(){return Art()?self:typeof window<"u"?window:typeof globalThis<"u"||typeof globalThis<"u"?globalThis:null}function Ert(t,e){let r="";for(;t>0;t--)r=Trt(e)+r;return r}function Mwe(t,e){if(isNaN(t))throw new yl({info:{code:"ENC_TIME_NAN",...gb}},`Time must be a number: ${t}`);if(t>Dwe)throw new yl({info:{code:"ENC_TIME_SIZE_EXCEED",...gb}},`Cannot encode a time larger than ${Dwe}: ${t}`);if(t<0)throw new yl({info:{code:"ENC_TIME_NEG",...gb}},`Time must be positive: ${t}`);if(Number.isInteger(t)===!1)throw new yl({info:{code:"ENC_TIME_TYPE",...gb}},`Time must be an integer: ${t}`);let r,n="";for(let i=e;i>0;i--)r=t%__,n=G3.charAt(r)+n,t=(t-r)/__;return n}function Srt(t){let e,r=t.length,n,i,o=t,s=__-1;for(;!e&&r-->=0;){if(n=o[r],i=G3.indexOf(n),i===-1)throw new yl({info:{code:"B32_INC_ENC",...gb}},"Incorrectly encoded string");if(i===s){o=Owe(o,r,G3[0]);continue}e=Owe(o,r,G3[i+1])}if(typeof e=="string")return e;throw new yl({info:{code:"B32_INC_INVALID",...gb}},"Failed incrementing string")}function Art(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function HR(t){let e=t||_rt(),r=0,n;return function(o){let s=isNaN(o)?Date.now():o;if(s<=r){let d=n=Srt(n);return Mwe(r,Bwe)+d}r=s;let a=n=Ert(wrt,e);return Mwe(s,Bwe)+a}}function Trt(t){let e=Math.floor(t()*__);return e===__&&(e=__-1),G3.charAt(e)}function Owe(t,e,r){return e>t.length-1?t:t.substr(0,e)+r+t.substr(e+1)}var vb=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},x_=class{constructor(e){this.index=new Pp(Object.assign({location:"EVENTLOG",createLevelDatabase:ad},e)),this.ulidFactory=HR()}open(){return vb(this,void 0,void 0,function*(){return this.index.open()})}close(){return vb(this,void 0,void 0,function*(){return this.index.close()})}clear(){return vb(this,void 0,void 0,function*(){return this.index.clear()})}append(e,r,n){return vb(this,void 0,void 0,function*(){let i=this.ulidFactory();yield this.index.put(e,r,Object.assign(Object.assign({},n),{watermark:i}))})}queryEvents(e,r,n){return vb(this,void 0,void 0,function*(){let i=yield this.index.query(e,r,{sortProperty:"watermark",cursor:n});return{events:i.map(({messageCid:o})=>o),cursor:Pp.createCursorFromLastArrayItem(i,"watermark")}})}getEvents(e,r){return vb(this,void 0,void 0,function*(){return this.queryEvents(e,[],r)})}deleteEventsByCid(e,r){return vb(this,void 0,void 0,function*(){let n=[];for(let i of r)n.push(this.index.delete(e,i));yield Promise.all(n)})}};f();f();function VR({enumerable:t=!0,configurable:e=!1}={}){return{enumerable:t,configurable:e,writable:!1}}function*Prt(t,e){if(e!=null&&typeof e=="object")if(Array.isArray(e))for(let[r,n]of e.entries()){let i=[...t,r],o=Nr.asCID(n);o?yield[i.join("/"),o]:typeof n=="object"&&(yield*az(n,i))}else{let r=Nr.asCID(e);r?yield[t.join("/"),r]:yield*az(e,t)}}function*az(t,e){if(t==null||t instanceof Uint8Array)return;let r=Nr.asCID(t);r&&(yield[e.join("/"),r]);for(let[n,i]of Object.entries(t)){let o=[...e,n];yield*Prt(o,i)}}function*Irt(t,e){if(Array.isArray(e))for(let[r,n]of e.entries()){let i=[...t,r];yield i.join("/"),typeof n=="object"&&!Nr.asCID(n)&&(yield*cz(n,i))}else yield*cz(e,t)}function*cz(t,e){if(!(t==null||typeof t!="object"))for(let[r,n]of Object.entries(t)){let i=[...e,r];yield i.join("/"),n!=null&&!(n instanceof Uint8Array)&&typeof n=="object"&&!Nr.asCID(n)&&(yield*Irt(i,n))}}function krt(t,e){let r=t;for(let[n,i]of e.entries()){if(r=r[i],r==null)throw new Error(`Object has no property at ${e.slice(0,n+1).map(s=>`[${JSON.stringify(s)}]`).join("")}`);let o=Nr.asCID(r);if(o)return{value:o,remaining:e.slice(n+1).join("/")}}return{value:r}}var GR=class{constructor({cid:e,bytes:r,value:n}){if(!e||!r||typeof n>"u")throw new Error("Missing required argument");this.cid=e,this.bytes=r,this.value=n,this.asBlock=this,Object.defineProperties(this,{cid:VR(),bytes:VR(),value:VR(),asBlock:VR()})}links(){return az(this.value,[])}tree(){return cz(this.value,[])}get(e="/"){return krt(this.value,e.split("/").filter(Boolean))}};async function Cwe({value:t,codec:e,hasher:r}){if(typeof t>"u")throw new Error('Missing required argument "value"');if(!e||!r)throw new Error("Missing required argument: codec or hasher");let n=e.encode(t),i=await r.digest(n),o=Nr.create(1,e.code,i);return new GR({value:t,bytes:n,cid:o})}async function $we({bytes:t,codec:e,hasher:r}){if(!t)throw new Error('Missing required argument "bytes"');if(!e||!r)throw new Error("Missing required argument: codec or hasher");let n=e.decode(t),i=await r.digest(t),o=Nr.create(1,e.code,i);return new GR({value:n,bytes:t,cid:o})}var bb=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},E_=class t{constructor(e={}){this.config=Object.assign({blockstoreLocation:"MESSAGESTORE",indexLocation:"INDEX",createLevelDatabase:ad},e),this.blockstore=new a_({location:this.config.blockstoreLocation,createLevelDatabase:this.config.createLevelDatabase}),this.index=new Pp({location:this.config.indexLocation,createLevelDatabase:this.config.createLevelDatabase})}open(){return bb(this,void 0,void 0,function*(){yield this.blockstore.open(),yield this.index.open()})}close(){return bb(this,void 0,void 0,function*(){yield this.blockstore.close(),yield this.index.close()})}get(e,r,n){var i;return bb(this,void 0,void 0,function*(){(i=n?.signal)===null||i===void 0||i.throwIfAborted();let o=yield Xi(this.blockstore.partition(e),n?.signal),s=Nr.parse(r),a=yield o.get(s,n);return a?(yield Xi($we({bytes:a,codec:G0,hasher:Us}),n?.signal)).value:void 0})}query(e,r,n,i,o){var s;return bb(this,void 0,void 0,function*(){(s=o?.signal)===null||s===void 0||s.throwIfAborted();let a=t.buildQueryOptions(n,i),d=yield this.index.query(e,r,a,o),u;i?.limit!==void 0&&i.limit0&&(n=n+1),{sortDirection:d,sortProperty:u,limit:n,cursor:i}}delete(e,r,n){var i;return bb(this,void 0,void 0,function*(){(i=n?.signal)===null||i===void 0||i.throwIfAborted();let o=yield Xi(this.blockstore.partition(e),n?.signal),s=Nr.parse(r);yield o.delete(s,n),yield this.index.delete(e,r,n)})}put(e,r,n,i){var o;return bb(this,void 0,void 0,function*(){(o=i?.signal)===null||o===void 0||o.throwIfAborted();let s=yield Xi(this.blockstore.partition(e),i?.signal),a=yield Xi(Cwe({value:r,codec:G0,hasher:Us}),i?.signal),d=hn.parseCid(yield _e.getCid(r));yield s.put(d,a.bytes,i);let u=d.toString();yield this.index.put(e,u,n,i)})}clear(){return bb(this,void 0,void 0,function*(){yield this.blockstore.clear(),yield this.index.clear()})}};f();var n0=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Drt=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,d){s=t[o](s),i(a,d,s.done,s.value)})}}function i(o,s,a,d){Promise.resolve(d).then(function(u){o({value:u,done:a})},s)}},wb=class t{constructor(e){this.config=Object.assign({location:"RESUMABLE-TASK-STORE",createLevelDatabase:ad},e),this.db=new Yy({location:this.config.location,createLevelDatabase:this.config.createLevelDatabase,keyEncoding:"utf8"})}open(){return n0(this,void 0,void 0,function*(){yield this.db.open()})}close(){return n0(this,void 0,void 0,function*(){yield this.db.close()})}register(e,r){return n0(this,void 0,void 0,function*(){let n=yield hn.computeCid(e),i={id:n,timeout:Date.now()+r*1e3,retryCount:0,task:e};return yield this.db.put(n,JSON.stringify(i)),i})}grab(e){var r,n,i,o;return n0(this,void 0,void 0,function*(){let s=[];try{for(var a=!0,d=Drt(this.db.iterator()),u;u=yield d.next(),r=u.done,!r;a=!0){o=u.value,a=!1;let[c,l]=o,p=JSON.parse(l);if(Date.now()>=p.timeout&&(p.timeout=Date.now()+t.taskTimeoutInSeconds*1e3,p.retryCount++,yield this.db.put(p.id,JSON.stringify(p)),s.push(p)),s.length>=e)break}}catch(c){n={error:c}}finally{try{!a&&!r&&(i=d.return)&&(yield i.call(d))}finally{if(n)throw n.error}}return s})}read(e){return n0(this,void 0,void 0,function*(){let r=yield this.db.get(e);if(r)return JSON.parse(r)})}extend(e,r){return n0(this,void 0,void 0,function*(){let n=yield this.db.get(e);if(n){let i=JSON.parse(n);i.timeout=Date.now()+r*1e3,yield this.db.put(i.id,JSON.stringify(i))}})}delete(e){return n0(this,void 0,void 0,function*(){return this.db.delete(e)})}clear(){return n0(this,void 0,void 0,function*(){yield this.db.clear()})}};wb.taskTimeoutInSeconds=60;f();var jwe=gt(Aa(),1);var JR=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},dz="events",S_=class{constructor(e={}){this.isOpen=!1,this.errorHandler=r=>{console.error("event emitter error",r)},this.eventEmitter=new jwe.EventEmitter({captureRejections:!0}),this.eventEmitter.setMaxListeners(0),e.errorHandler&&(this.errorHandler=e.errorHandler),this.eventEmitter.on("error",this.errorHandler)}subscribe(e,r,n){return JR(this,void 0,void 0,function*(){return this.eventEmitter.on(`${e}_${dz}`,n),{id:r,close:()=>JR(this,void 0,void 0,function*(){this.eventEmitter.off(`${e}_${dz}`,n)})}})}open(){return JR(this,void 0,void 0,function*(){this.isOpen=!0})}close(){return JR(this,void 0,void 0,function*(){this.isOpen=!1,this.eventEmitter.removeAllListeners()})}emit(e,r,n){if(!this.isOpen){this.errorHandler(new de(oe.EventEmitterStreamNotOpenError,"a message emitted when EventEmitterStream is closed"));return}this.eventEmitter.emit(`${e}_${dz}`,e,r,n)}};f();f();var Brt=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},J3=class t{static pollUntilSuccessOrTimeout(e,r=t.pollRetrySleep,n=t.pollTimeout){return Brt(this,void 0,void 0,function*(){let i=Date.now();for(;;)try{return yield e()}catch{if(Date.now()-i>=n)throw new Error("Operation timed out");yield pr.sleep(r)}})}};J3.pollRetrySleep=20;J3.pollTimeout=2e3;var Ie;(function(t){t.MessagesQuery="MessagesQuery",t.MessagesRead="MessagesRead",t.MessagesSubscribe="MessagesSubscribe",t.ProtocolsConfigure="ProtocolsConfigure",t.ProtocolsQuery="ProtocolsQuery",t.RecordsDelete="RecordsDelete",t.RecordsQuery="RecordsQuery",t.RecordsRead="RecordsRead",t.RecordsSubscribe="RecordsSubscribe",t.RecordsWrite="RecordsWrite"})(Ie||(Ie={}));var uz={[Ie.MessagesQuery]:cy,[Ie.MessagesRead]:dy,[Ie.MessagesSubscribe]:uy,[Ie.ProtocolsConfigure]:wy,[Ie.ProtocolsQuery]:_y,[Ie.RecordsDelete]:vf,[Ie.RecordsQuery]:oy,[Ie.RecordsRead]:Sv,[Ie.RecordsSubscribe]:xy,[Ie.RecordsWrite]:Or};f();f();f();var _b;(function(t){t.authentication="authentication",t.assertionMethod="assertionMethod",t.keyAgreement="keyAgreement",t.capabilityInvocation="capabilityInvocation",t.capabilityDelegation="capabilityDelegation"})(_b||(_b={}));f();var fi={"@context":"https://w3id.org/did-resolution/v1",didResolutionMetadata:{},didDocument:null,didDocumentMetadata:{}};f();var nr=class t{constructor({method:e,id:r,path:n,query:i,fragment:o,params:s}){this.uri=`did:${e}:${r}`,this.method=e,this.id=r,this.path=n,this.query=i,this.fragment=o,this.params=s}static parse(e){if(!e)return null;let r=t.DID_URI_PATTERN.exec(e);if(!r||!r.groups)return null;let{method:n,id:i,path:o,query:s,fragment:a}=r.groups,d={uri:`did:${n}:${i}`,method:n,id:i};if(o&&(d.path=o),s&&(d.query=s.slice(1)),a&&(d.fragment=a.slice(1)),s){let u={},c=s.slice(1).split("&");for(let l of c){let[p,m]=l.split("=");u[p]=m}d.params=u}return d}};nr.METHOD_PATTERN="([a-z0-9]+)";nr.PCT_ENCODED_PATTERN="(?:%[0-9a-fA-F]{2})";nr.ID_CHAR_PATTERN=`(?:[a-zA-Z0-9._-]|${nr.PCT_ENCODED_PATTERN})`;nr.METHOD_ID_PATTERN=`((?:${nr.ID_CHAR_PATTERN}*:)*(${nr.ID_CHAR_PATTERN}+))`;nr.PATH_PATTERN="(/[^#?]*)?";nr.QUERY_PATTERN="([?][^#]*)?";nr.FRAGMENT_PATTERN="(#.*)?";nr.DID_URI_PATTERN=new RegExp(`^did:(?${nr.METHOD_PATTERN}):(?${nr.METHOD_ID_PATTERN})(?${nr.PATH_PATTERN})(?${nr.QUERY_PATTERN})(?${nr.FRAGMENT_PATTERN})$`);f();var dt=class t 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,t)}},rt;(function(t){t.InvalidDid="invalidDid",t.MethodNotSupported="methodNotSupported",t.InternalError="internalError",t.InvalidDidDocument="invalidDidDocument",t.InvalidDidDocumentLength="invalidDidDocumentLength",t.InvalidDidUrl="invalidDidUrl",t.InvalidPreviousDidProof="invalidPreviousDidProof",t.InvalidPublicKey="invalidPublicKey",t.InvalidPublicKeyLength="invalidPublicKeyLength",t.InvalidPublicKeyType="invalidPublicKeyType",t.InvalidSignature="invalidSignature",t.NotFound="notFound",t.RepresentationNotSupported="representationNotSupported",t.UnsupportedPublicKeyType="unsupportedPublicKeyType"})(rt||(rt={}));f();f();f();f();f();var Nf=gt(TI(),1);f();f();function Nwe(t){return t.byteOffset!==0||t.byteLength!==t.buffer.byteLength}function Uwe(t){return typeof t!="object"||t===null?!1:typeof t[Symbol.asyncIterator]=="function"}function i0(t){let r=Object.prototype.toString.call(t).match(/\s([a-zA-Z0-9]+)/),[n,i]=r;return i}var Z3=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},qwe=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,d){s=t[o](s),i(a,d,s.done,s.value)})}}function i(o,s,a,d){Promise.resolve(d).then(function(u){o({value:u,done:a})},s)}},ZR=new TextEncoder,xb=new TextDecoder,ae=class t{constructor(e,r){this.data=e,this.format=r}static arrayBuffer(e){return new t(e,"ArrayBuffer")}static asyncIterable(e){if(!Uwe(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 Fi.baseDecode(this.data).buffer;case"Base64Url":return Pi.baseDecode(this.data).buffer;case"BufferSource":{if(i0(this.data)==="ArrayBuffer")return this.data;if(ArrayBuffer.isView(this.data))return Nwe(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 Z3(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 O0.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 Fi.baseEncode(e)}case"Multibase":return this.data.substring(1);case"Uint8Array":return Fi.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 Pi.baseEncode(e)}case"BufferSource":{let e=this.toUint8Array();return Pi.baseEncode(e)}case"Object":{let e=JSON.stringify(this.data),r=ZR.encode(e);return Pi.baseEncode(r)}case"String":{let e=ZR.encode(this.data);return Pi.baseEncode(e)}case"Uint8Array":return Pi.baseEncode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Base64Url is not supported.`)}}toBlobAsync(){return Z3(this,void 0,void 0,function*(){var e,r,n,i;switch(this.format){case"AsyncIterable":{let d=[];try{for(var o=!0,s=qwe(this.data),a;a=yield s.next(),e=a.done,!e;o=!0){i=a.value,o=!1;let c=i;d.push(c)}}catch(c){r={error:c}}finally{try{!o&&!e&&(n=s.return)&&(yield n.call(s))}finally{if(r)throw r.error}}return new Blob(d)}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;n0?!1:Object.keys(t).length===0}function A_(t){Object.keys(t).forEach(e=>{t[e]===void 0?delete t[e]:typeof t[e]=="object"&&A_(t[e])})}f();var Lwe=gt(GS(),1),au=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},X3=class{constructor({db:e,location:r="DATASTORE"}={}){this.store=e??new Lwe.Level(r)}clear(){return au(this,void 0,void 0,function*(){yield this.store.clear()})}close(){return au(this,void 0,void 0,function*(){yield this.store.close()})}delete(e){return au(this,void 0,void 0,function*(){yield this.store.del(e)})}get(e){return au(this,void 0,void 0,function*(){try{return yield this.store.get(e)}catch(r){if(r.notFound)return;throw r}})}set(e,r){return au(this,void 0,void 0,function*(){yield this.store.put(e,r)})}},Eb=class{constructor(){this.store=new Map}clear(){return au(this,void 0,void 0,function*(){this.store.clear()})}close(){return au(this,void 0,void 0,function*(){})}delete(e){return au(this,void 0,void 0,function*(){return this.store.delete(e)})}get(e){return au(this,void 0,void 0,function*(){return this.store.get(e)})}has(e){return au(this,void 0,void 0,function*(){return this.store.has(e)})}list(){return au(this,void 0,void 0,function*(){return Array.from(this.store.values())})}set(e,r){return au(this,void 0,void 0,function*(){this.store.set(e,r)})}};f();var Q3=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},e5=function(t){return this instanceof e5?(this.v=t,this):new e5(t)},Mrt=function(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),i,o=[];return i={},a("next"),a("throw"),a("return",s),i[Symbol.asyncIterator]=function(){return this},i;function s(m){return function(g){return Promise.resolve(g).then(m,l)}}function a(m,g){n[m]&&(i[m]=function(v){return new Promise(function(x,S){o.push([m,v,x,S])>1||d(m,v)})},g&&(i[m]=g(i[m])))}function d(m,g){try{u(n[m](g))}catch(v){p(o[0][3],v)}}function u(m){m.value instanceof e5?Promise.resolve(m.value.v).then(c,l):p(o[0][2],m)}function c(m){d("next",m)}function l(m){d("throw",m)}function p(m,g){m(g),o.shift(),o.length&&d(o[0][0],o[0][1])}},Sb=class t{static asAsyncIterator(e){return Mrt(this,arguments,function*(){let n=e.getReader();try{for(;;){let{done:i,value:o}=yield e5(n.read());if(i)break;yield yield e5(o)}}finally{n.releaseLock()}})}static consumeToArrayBuffer(e){return Q3(this,arguments,void 0,function*({readableStream:r}){let n=t.asAsyncIterator(r);return yield ae.asyncIterable(n).toArrayBufferAsync()})}static consumeToBlob(e){return Q3(this,arguments,void 0,function*({readableStream:r}){let n=t.asAsyncIterator(r);return yield ae.asyncIterable(n).toBlobAsync()})}static consumeToBytes(e){return Q3(this,arguments,void 0,function*({readableStream:r}){let n=t.asAsyncIterator(r);return yield ae.asyncIterable(n).toUint8ArrayAsync()})}static consumeToJson(e){return Q3(this,arguments,void 0,function*({readableStream:r}){let n=t.asAsyncIterator(r);return yield ae.asyncIterable(n).toObjectAsync()})}static consumeToText(e){return Q3(this,arguments,void 0,function*({readableStream:r}){let n=t.asAsyncIterator(r);return yield ae.asyncIterable(n).toStringAsync()})}static generateByteStream({streamLength:e,chunkLength:r,fillValue:n}){let i=e??1/0,o;function s(){let a=Math.min(i,r??1/0);i-=a;let d;if(typeof n=="number")d=new Uint8Array(a).fill(n);else if(Array.isArray(n)){d=new Uint8Array(a);let[u,c]=n,l=c-u+1;for(let p=0;p{if(s)this.push(null);else if(!this.push(a))return}).catch(s=>{this.destroy(s)})},destroy:function(s,a){function d(){a(s)}if(!i){n.cancel(s).then(d).catch(d);return}d()}}));return n.closed.then(()=>{i=!0}).catch(s=>{i=!0,o.destroy(s)}),o}static isDestroyed({stream:e}){if(!t.isStream(e))throw new TypeError("NodeStream.isDestroyed: 'stream' is not a Node stream.");let r="_writableState"in e?e._writableState:void 0,n=e._readableState,i=r||n;return!!(e.destroyed||i.destroyed)}static isReadable({readable:e}){return t.isReadableStream(e)?e.readable&&typeof e._readableState.ended=="boolean"&&!e._readableState.ended&&typeof e._readableState.endEmitted=="boolean"&&!e._readableState.endEmitted&&!e.destroyed&&!e.isPaused():!1}static isReadableStream(e){return typeof e=="object"&&e!==null&&"pipe"in e&&typeof e.pipe=="function"&&"on"in e&&typeof e.on=="function"&&!("_writableState"in e)&&"_readableState"in e}static isStream(e){return typeof e=="object"&&e!==null&&("_readableState"in e||"_writableState"in e)}static toWebReadable({readable:e}){if(!t.isReadableStream(e))throw new TypeError("NodeStream.toWebReadable: 'readable' is not a Node Readable stream.");if(t.isDestroyed({stream:e})){let r=new ReadableStream;return r.cancel(),r}return new ReadableStream({start(r){e.on("data",n=>{r.enqueue(n)}),e.on("end",()=>{r.close()}),e.on("error",n=>{r.error(n)})},cancel(){e.destroy()}})}};f();f();var Crt=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Uf=class{static digest(e){return Crt(this,arguments,void 0,function*({data:r}){return So(r)})}};f();var hi=class{};var $rt=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},o0=class extends hi{digest(e){return $rt(this,arguments,void 0,function*({algorithm:r,data:n}){switch(r){case"SHA-256":return yield Uf.digest({data:n})}})}};f();f();f();f();function r5(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 jrt=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Ab="urn:jwk:";function yt(t){return jrt(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}`);A_(n);let i=r5(n),o=ae.string(i).toUint8Array(),s=yield Uf.digest({data:o});return ae.uint8Array(s).toBase64Url()})}function vc(t){return!(!t||typeof t!="object"||!("kty"in t&&"crv"in t&&"x"in t&&"d"in t)||t.kty!=="EC"||typeof t.d!="string"||typeof t.x!="string")}function s0(t){return!(!t||typeof t!="object"||!("kty"in t&&"crv"in t&&"x"in t)||"d"in t||t.kty!=="EC"||typeof t.x!="string")}function Tb(t){return!(!t||typeof t!="object"||!("kty"in t&&"k"in t)||t.kty!=="oct"||typeof t.k!="string")}function bc(t){return!(!t||typeof t!="object"||!("kty"in t&&"crv"in t&&"x"in t&&"d"in t)||t.kty!=="OKP"||typeof t.d!="string"||typeof t.x!="string")}function a0(t){return!(!t||typeof t!="object"||"d"in t||!("kty"in t&&"crv"in t&&"x"in t)||t.kty!=="OKP"||typeof t.x!="string")}function T_(t){if(!t||typeof t!="object")return!1;switch(t.kty){case"EC":case"OKP":case"RSA":return"d"in t;case"oct":return"k"in t;default:return!1}}var Cs=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Nrt=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);ie||e>10)throw new Error("randomPin() can securely generate a PIN between 3 to 10 digits.");let r=Math.pow(10,e)-1,n;if(e<=6){let i=Math.pow(10,e);do{let o=t.randomBytes(Math.ceil(e/2));n=new DataView(o.buffer).getUint16(0,!1)%i}while(n>r)}else{let i=Math.pow(10,10);do{let o=t.randomBytes(4);n=new DataView(o.buffer).getUint32(0,!1)%i}while(n>r)}return n.toString().padStart(e,"0")}};f();f();f();f();var o5=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Lrt=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);iwc,getServices:()=>zrt,getVerificationMethodByKey:()=>Wrt,getVerificationMethodTypes:()=>pz,getVerificationMethods:()=>s5,getVerificationRelationshipsById:()=>mz,isDidService:()=>zwe,isDidVerificationMethod:()=>tD,isDwnDidService:()=>Hrt,keyBytesToMultibaseId:()=>rD,multibaseIdToKeyBytes:()=>nD});f();var Frt=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})};function wc(t){if(typeof t=="string"&&t.length!==0)return t.split("#").pop()}function zrt({didDocument:t,id:e,type:r}){var n,i;return(i=(n=t?.service)===null||n===void 0?void 0:n.filter(o=>!(e&&o.id!==e||r&&o.type!==r)))!==null&&i!==void 0?i:[]}function Wrt(t){return Frt(this,arguments,void 0,function*({didDocument:e,publicKeyJwk:r,publicKeyMultibase:n}){let i=s5({didDocument:e});for(let o of i)if(r&&o.publicKeyJwk){if((yield yt({jwk:r}))===(yield yt({jwk:o.publicKeyJwk})))return o}else if(n&&o.publicKeyMultibase&&n===o.publicKeyMultibase)return o;return null})}function s5({didDocument:t}){var e,r;if(!t)throw new TypeError("Required parameter missing: 'didDocument'");let n=[];return n.push(...(r=(e=t.verificationMethod)===null||e===void 0?void 0:e.filter(tD))!==null&&r!==void 0?r:[]),Object.keys(_b).forEach(i=>{var o,s;n.push(...(s=(o=t[i])===null||o===void 0?void 0:o.filter(tD))!==null&&s!==void 0?s:[])}),n}function pz({didDocument:t}){let r=s5({didDocument:t}).map(n=>n.type);return[...new Set(r)]}function mz({didDocument:t,methodId:e}){let r=[];return Object.keys(_b).forEach(n=>{if(Array.isArray(t[n])){let i=t[n],o=wc(e);i.some(a=>{let d=wc(a)===o,u=tD(a)&&wc(a.id)===o;return d||u})&&r.push(n)}}),r}function zwe(t){return!t||typeof t!="object"||t===null?!1:"id"in t&&"type"in t&&"serviceEndpoint"in t}function Hrt(t){if(!zwe(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 tD(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 rD({keyBytes:t,multicodecCode:e,multicodecName:r}){let n=fa.addPrefix({code:e,data:t,name:r}),i=ae.uint8Array(n).toBase58Btc();return ae.base58Btc(i).toMultibase()}function nD({multibaseKeyId:t}){try{let e=ae.multibase(t).toBase58Btc(),r=ae.base58Btc(e).toUint8Array(),{code:n,data:i,name:o}=fa.removePrefix({prefixedData:r});return{keyBytes:i,multicodecCode:n,multicodecName:o}}catch{throw new dt(rt.InvalidDid,`Invalid multibase identifier: ${t}`)}}var a5=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Qi=class t{constructor({uri:e,document:r,metadata:n,keyManager:i}){this.uri=e,this.document=r,this.metadata=n,this.keyManager=i}export(){return a5(this,void 0,void 0,function*(){if(!(Array.isArray(this.document.verificationMethod)&&this.document.verificationMethod.length>0))throw new Error(`DID document for '${this.uri}' is missing verification methods`);let e=JSON.parse(JSON.stringify({uri:this.uri,document:this.document,metadata:this.metadata}));if("exportKey"in this.keyManager&&typeof this.keyManager.exportKey=="function"){let r=[];for(let n of this.document.verificationMethod){if(!n.publicKeyJwk)throw new Error(`Verification method '${n.id}' does not contain a public key in JWK format`);let i=yield this.keyManager.getKeyUri({key:n.publicKeyJwk}),o=yield this.keyManager.exportKey({keyUri:i});r.push(Object.assign({},o))}e.privateKeys=r}return e})}getSigner(e){return a5(this,void 0,void 0,function*(){var r;let n=(r=this.document.verificationMethod)===null||r===void 0?void 0:r.find(d=>{var u,c;return wc(d.id)===((u=wc(e?.methodId))!==null&&u!==void 0?u:wc((c=this.document.assertionMethod)===null||c===void 0?void 0:c[0]))});if(!(n&&n.publicKeyJwk))throw new dt(rt.InternalError,"A verification method intended for signing could not be determined from the DID Document");let i=yield this.keyManager.getKeyUri({key:n.publicKeyJwk}),o=yield this.keyManager.getPublicKey({keyUri:i}),s=this.keyManager;return{algorithm:dn.getJoseSignatureAlgorithmFromPublicKey(o),keyId:n.id,sign(d){return a5(this,arguments,void 0,function*({data:u}){return yield s.sign({data:u,keyUri:i})})},verify(d){return a5(this,arguments,void 0,function*({data:u,signature:c}){return yield s.verify({data:u,key:o,signature:c})})}}})}static import(e){return a5(this,arguments,void 0,function*({portableDid:r,keyManager:n=new ei}){var i;let o=s5({didDocument:r.document});if(o.length===0)throw new dt(rt.InvalidDidDocument,"At least one verification method is required but 0 were given");for(let a of(i=r.privateKeys)!==null&&i!==void 0?i:[]){let d=yield n.getKeyUri({key:a});(yield n.getPublicKey({keyUri:d}).then(()=>!0).catch(()=>!1))||(yield n.importKey({key:a}))}for(let a of o){if(!a.publicKeyJwk)throw new Error(`Verification method '${a.id}' does not contain a public key in JWK format`);let d=yield n.getKeyUri({key:a.publicKeyJwk});yield n.getPublicKey({keyUri:d})}return new t({uri:r.uri,document:r.document,metadata:r.metadata,keyManager:n})})}};f();f();var Wwe=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},uu=class{static getSigningMethod(e){return Wwe(this,void 0,void 0,function*(){throw new Error("Not implemented: Classes extending DidMethod must implement getSigningMethod()")})}static resolve(e,r){return Wwe(this,void 0,void 0,function*(){throw new Error("Not implemented: Classes extending DidMethod must implement resolve()")})}};var Yo=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Hwe=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i!(j.algorithm in Jwe)))throw new Error("One or more verification method algorithms are not supported");let g=(i=r.verificationMethods)===null||i===void 0?void 0:i.filter(j=>"id"in j).map(j=>j.id);if(g&&g.length!==new Set(g).size)throw new Error("One or more verification method IDs are not unique");if(!((o=r.services)===null||o===void 0)&&o.some(j=>!j.id||!j.type||!j.serviceEndpoint))throw new Error("One or more services are missing required properties");let v=yield e.generateKey({algorithm:"Ed25519"}),x=yield e.getPublicKey({keyUri:v}),S=yield Zo.identityKeyToIdentifier({identityKey:x}),P=Object.assign(Object.assign({id:S},r.alsoKnownAs&&{alsoKnownAs:r.alsoKnownAs}),r.controllers&&{controller:r.controllers}),A=[...(s=r.verificationMethods)!==null&&s!==void 0?s:[]];A?.some(j=>{var q;return((q=j.id)===null||q===void 0?void 0:q.split("#").pop())==="0"})||A.unshift({algorithm:"Ed25519",id:"0",purposes:["authentication","assertionMethod","capabilityDelegation","capabilityInvocation"]});for(let j of A){let q=j.id&&j.id.split("#").pop()==="0"?v:yield e.generateKey({algorithm:j.algorithm}),F=yield e.getPublicKey({keyUri:q}),K=(d=(a=j.id)!==null&&a!==void 0?a:F.kid)!==null&&d!==void 0?d:yield yt({jwk:F});K=`${S}#${wc(K)}`,(u=P.verificationMethod)!==null&&u!==void 0||(P.verificationMethod=[]),P.verificationMethod.push({id:K,type:"JsonWebKey",controller:(c=j.controller)!==null&&c!==void 0?c:S,publicKeyJwk:F});for(let W of(l=j.purposes)!==null&&l!==void 0?l:[])P[W]||(P[W]=[]),P[W].push(K)}(p=r.services)===null||p===void 0||p.forEach(j=>{var q;(q=P.service)!==null&&q!==void 0||(P.service=[]),j.id=`${S}#${j.id.split("#").pop()}`,P.service.push(j)});let $=new Qi({uri:S,document:P,metadata:Object.assign({published:!1},r.types&&{types:r.types}),keyManager:e});if(!((m=r.publish)!==null&&m!==void 0)||m){let j=yield t.publish({did:$,gatewayUri:r.gatewayUri});$.metadata=j.didDocumentMetadata}return $})}static import(e){return Yo(this,arguments,void 0,function*({portableDid:r,keyManager:n=new ei}){var i;let o=nr.parse(r.uri);if(o?.method!==t.methodName)throw new dt(rt.MethodNotSupported,"Method not supported");let s=yield Qi.import({portableDid:r,keyManager:n});if(!(!((i=s.document.verificationMethod)===null||i===void 0)&&i.some(a=>{var d;return((d=a.id)===null||d===void 0?void 0:d.split("#").pop())==="0"})))throw new dt(rt.InvalidDidDocument,"DID document must contain an Identity Key");return s})}static getSigningMethod(e){return Yo(this,arguments,void 0,function*({didDocument:r,methodId:n="#0"}){var i;let o=nr.parse(r.id);if(o&&o.method!==this.methodName)throw new dt(rt.MethodNotSupported,`Method not supported: ${o.method}`);let s=(i=r.verificationMethod)===null||i===void 0?void 0:i.find(a=>{var d,u;return wc(a.id)===((d=wc(n))!==null&&d!==void 0?d:wc((u=r.assertionMethod)===null||u===void 0?void 0:u[0]))});if(!(s&&s.publicKeyJwk))throw new dt(rt.InternalError,"A verification method intended for signing could not be determined from the DID Document");return s})}static publish(e){return Yo(this,arguments,void 0,function*({did:r,gatewayUri:n=Vwe}){return yield sD.put({did:r,gatewayUri:n})})}static resolve(e){return Yo(this,arguments,void 0,function*(r,n={}){var i;let o=(i=n?.gatewayUri)!==null&&i!==void 0?i:Vwe;try{yield Zo.identifierToIdentityKey({didUri:r});let{didDocument:s,didDocumentMetadata:a}=yield sD.get({didUri:r,gatewayUri:o});return Object.assign(Object.assign({},fi),{didDocument:s,didDocumentMetadata:a})}catch(s){if(!(s instanceof dt))throw new Error(s);return Object.assign(Object.assign({},fi),{didResolutionMetadata:Object.assign({error:s.code},s.message&&{errorMessage:s.message})})}})}};_c.methodName="dht";var sD=class t{static get(e){return Yo(this,arguments,void 0,function*({didUri:r,gatewayUri:n}){let i=Zo.identifierToIdentityKeyBytes({didUri:r}),o=yield t.pkarrGet({gatewayUri:n,publicKeyBytes:i}),s=yield Zo.parseBep44GetMessage({bep44Message:o}),a=yield t.fromDnsPacket({didUri:r,dnsPacket:s});return a.didDocumentMetadata.versionId=o.seq.toString(),a})}static put(e){return Yo(this,arguments,void 0,function*({did:r,gatewayUri:n}){let i=yield t.toDnsPacket({didDocument:r.document,didMetadata:r.metadata,authoritativeGatewayUris:[n]}),o=yield Zo.createBep44PutMessage({dnsPacket:i,publicKeyBytes:Zo.identifierToIdentityKeyBytes({didUri:r.uri}),signer:yield r.getSigner({methodId:"0"})}),s=yield t.pkarrPut({gatewayUri:n,bep44Message:o});return{didDocument:r.document,didDocumentMetadata:Object.assign(Object.assign({},r.metadata),{published:s,versionId:o.seq.toString()}),didRegistrationMetadata:{}}})}static pkarrGet(e){return Yo(this,arguments,void 0,function*({gatewayUri:r,publicKeyBytes:n}){let i=ae.uint8Array(n).toBase32Z(),o=new URL(i,r).href,s;try{if(s=yield fetch(o,{method:"GET"}),!s.ok)throw new dt(rt.NotFound,`Pkarr record not found for: ${i}`)}catch(u){throw u instanceof dt?u:new dt(rt.InternalError,`Failed to fetch Pkarr record: ${u.message}`)}let a=yield s.arrayBuffer();if(!a)throw new dt(rt.NotFound,`Pkarr record not found for: ${i}`);if(a.byteLength<72)throw new dt(rt.InvalidDidDocumentLength,`Pkarr response must be at least 72 bytes but got: ${a.byteLength}`);if(a.byteLength>1072)throw new dt(rt.InvalidDidDocumentLength,`Pkarr response exceeds 1000 byte limit: ${a.byteLength}`);return{k:n,seq:Number(new DataView(a).getBigUint64(64)),sig:new Uint8Array(a,0,64),v:new Uint8Array(a,72)}})}static pkarrPut(e){return Yo(this,arguments,void 0,function*({gatewayUri:r,bep44Message:n}){let i=ae.uint8Array(n.k).toBase32Z(),o=new URL(i,r).href,s=new Uint8Array(n.v.length+72);s.set(n.sig,0),new DataView(s.buffer).setBigUint64(n.sig.length,BigInt(n.seq)),s.set(n.v,n.sig.length+8);let a;try{a=yield fetch(o,{method:"PUT",headers:{"Content-Type":"application/octet-stream"},body:s})}catch(d){throw new dt(rt.InternalError,`Failed to put Pkarr record for identifier ${i}: ${d.message}`)}return a.ok})}static fromDnsPacket(e){return Yo(this,arguments,void 0,function*({didUri:r,dnsPacket:n}){var i,o,s;let a={id:r},d={published:!0},u=new Map;for(let c of(i=n?.answers)!==null&&i!==void 0?i:[]){if(c.type!=="TXT")continue;let l=c.name.split(".")[0].substring(1);switch(!0){case l.startsWith("aka"):{let p=Zo.parseTxtDataToString(c.data);a.alsoKnownAs=p.split(za);break}case l.startsWith("cnt"):{let p=Zo.parseTxtDataToString(c.data);a.controller=p.includes(za)?p.split(za):p;break}case l.startsWith("k"):{let{id:p,t:m,k:g,c:v,a:x}=Zo.parseTxtDataToObject(c.data),S=ae.base64Url(g).toUint8Array(),P=Wa[Number(m)],A=yield Zo.keyConverter(P).bytesToPublicKey({publicKeyBytes:S});A.alg=x||Gwe[Number(m)];let $=l==="k0"?"0":p!==void 0?p:yield yt({jwk:A});(o=a.verificationMethod)!==null&&o!==void 0||(a.verificationMethod=[]);let j=`${r}#${$}`;a.verificationMethod.push({id:j,type:"JsonWebKey",controller:v??r,publicKeyJwk:A}),u.set(l,j);break}case l.startsWith("s"):{let p=Zo.parseTxtDataToObject(c.data),{id:m,t:g,se:v}=p,x=Hwe(p,["id","t","se"]),S=v.includes(za)?v.split(za):[v],P=Object.fromEntries(Object.entries(x).map(([A,$])=>[A,$.includes(za)?$.split(za):$]));(s=a.service)!==null&&s!==void 0||(a.service=[]),a.service.push(Object.assign(Object.assign({},P),{id:`${r}#${m}`,type:g,serviceEndpoint:S}));break}case l.startsWith("typ"):{let{id:p}=Zo.parseTxtDataToObject(c.data);d.types=p.split(za).map(m=>Number(m));break}case l.startsWith("did"):{let p=P=>P.split(za).map(A=>u.get(A)).filter(A=>typeof A=="string"),{auth:m,asm:g,del:v,inv:x,agm:S}=Zo.parseTxtDataToObject(c.data);m&&(a.authentication=p(m)),g&&(a.assertionMethod=p(g)),v&&(a.capabilityDelegation=p(v)),x&&(a.capabilityInvocation=p(x)),S&&(a.keyAgreement=p(S));break}}}return{didDocument:a,didDocumentMetadata:d,didResolutionMetadata:{}}})}static toDnsPacket(e){return Yo(this,arguments,void 0,function*({didDocument:r,didMetadata:n,authoritativeGatewayUris:i,previousDidProof:o}){var s,a,d,u,c;let l=[],p=[],m=new Map,g=[],v=[];if(o!==void 0){let{signature:P,previousDid:A}=o;yield Zo.validatePreviousDidProof({newDid:r.id,previousDidProof:o}),l.push({type:"TXT",name:"_prv._did.",ttl:f0,data:`id=${A};s=${P}`})}if(r.alsoKnownAs&&l.push({type:"TXT",name:"_aka._did.",ttl:f0,data:r.alsoKnownAs.join(za)}),r.controller){let P=Array.isArray(r.controller)?r.controller.join(za):r.controller;l.push({type:"TXT",name:"_cnt._did.",ttl:f0,data:P})}for(let[P,A]of(a=(s=r.verificationMethod)===null||s===void 0?void 0:s.entries())!==null&&a!==void 0?a:[]){let $=`k${P}`;v.push($);let j=A.id.split("#").pop();m.set(j,$);let q=A.publicKeyJwk;if(!(q?.crv&&q.crv in Jwe))throw new dt(rt.InvalidPublicKeyType,`Verification method '${A.id}' contains an unsupported key type: ${(d=q?.crv)!==null&&d!==void 0?d:"undefined"}`);let F=Wa[q.crv],K=yield Zo.keyConverter(q.crv).publicKeyToBytes({publicKey:q}),W=ae.uint8Array(K).toBase64Url(),L=[`t=${F}`,`k=${W}`];j!=="0"&&(yield yt({jwk:q}))!==j&&L.unshift(`id=${j}`),q.alg!==Gwe[F]&&L.push(`a=${q.alg}`),A.controller!==r.id&&L.push(`c=${A.controller}`),l.push({type:"TXT",name:`_${$}._did.`,ttl:f0,data:L.join(oD)})}(u=r.service)===null||u===void 0||u.forEach((P,A)=>{let $=`s${A}`;g.push($);let{id:j,type:q,serviceEndpoint:F}=P,K=Hwe(P,["id","type","serviceEndpoint"]);j=wc(j),F=Array.isArray(F)?F.join(","):F;let L=Object.entries(Object.assign({id:j,t:q,se:F},K)).map(([T,B])=>`${T}=${B}`).join(oD),I=Zo.chunkDataIfNeeded(L);l.push({type:"TXT",name:`_${$}._did.`,ttl:f0,data:I})});let x=[`v=${Vrt}`];if(v.length&&x.push(`vm=${v.join(za)}`),Object.keys(_b).forEach(P=>{var A;let $=(A=r[P])===null||A===void 0?void 0:A.map(j=>m.get(j.split("#").pop()));if($){let j=gz[P];x.push(`${j}=${$.join(za)}`)}}),g.length&&x.push(`svc=${g.join(za)}`),!((c=n.types)===null||c===void 0)&&c.length){let A=n.types.map($=>typeof $=="string"?yz[$]:$);l.push({type:"TXT",name:"_typ._did.",ttl:f0,data:`id=${A.join(za)}`})}l.push({type:"TXT",name:"_did."+t.getUniqueDidSuffix(r.id)+".",ttl:f0,data:x.join(oD)});for(let P of i||[])p.push({type:"NS",name:"_did."+t.getUniqueDidSuffix(r.id)+".",ttl:f0,data:P+"."});return{id:0,type:"response",flags:lR,answers:[...l,...p]}})}static getUniqueDidSuffix(e){return e.split(":")[2]}},Zo=class t{static createBep44PutMessage(e){return Yo(this,arguments,void 0,function*({dnsPacket:r,publicKeyBytes:n,signer:i}){let o=Math.ceil(Date.now()/1e3),s=ob(r),a=H2.encode({seq:o,v:s}).subarray(1,-1);if(a.length>1e3)throw new dt(rt.InvalidDidDocumentLength,`DNS packet exceeds the 1000 byte maximum size: ${a.length} bytes`);let d=yield i.sign({data:a});return{k:n,seq:o,sig:d,v:s}})}static identifierToIdentityKey(e){return Yo(this,arguments,void 0,function*({didUri:r}){let n=t.identifierToIdentityKeyBytes({didUri:r});return yield Fr.bytesToPublicKey({publicKeyBytes:n})})}static identifierToIdentityKeyBytes({didUri:e}){let r=nr.parse(e);if(!r)throw new dt(rt.InvalidDid,`Invalid DID URI: ${e}`);if(r.method!==_c.methodName)throw new dt(rt.MethodNotSupported,`Method not supported: ${r.method}`);let n;try{n=ae.base32Z(r.id).toUint8Array()}catch{throw new dt(rt.InvalidPublicKey,"Failed to decode method-specific identifier")}if(n.length!==32)throw new dt(rt.InvalidPublicKeyLength,`Invalid public key length: ${n.length}`);return n}static identityKeyToIdentifier(e){return Yo(this,arguments,void 0,function*({identityKey:r}){let n=yield Fr.publicKeyToBytes({publicKey:r}),i=ae.uint8Array(n).toBase32Z();return`did:${_c.methodName}:${i}`})}static keyConverter(e){let n={Ed25519:Fr,"P-256":{publicKeyToBytes:i=>Yo(this,[i],void 0,function*({publicKey:o}){let s=yield Mn.publicKeyToBytes({publicKey:o});return yield Mn.compressPublicKey({publicKeyBytes:s})}),bytesToPublicKey:Mn.bytesToPublicKey,privateKeyToBytes:Mn.privateKeyToBytes,bytesToPrivateKey:Mn.bytesToPrivateKey},secp256k1:{publicKeyToBytes:i=>Yo(this,[i],void 0,function*({publicKey:o}){let s=yield En.publicKeyToBytes({publicKey:o});return yield En.compressPublicKey({publicKeyBytes:s})}),bytesToPublicKey:En.bytesToPublicKey,privateKeyToBytes:En.privateKeyToBytes,bytesToPrivateKey:En.bytesToPrivateKey},X25519:l0}[e];if(!n)throw new dt(rt.InvalidPublicKeyType,`Unsupported curve: ${e}`);return n}static parseBep44GetMessage(e){return Yo(this,arguments,void 0,function*({bep44Message:r}){let n=yield Fr.bytesToPublicKey({publicKeyBytes:r.k}),i=H2.encode({seq:r.seq,v:r.v}).subarray(1,-1);if(!(yield Fr.verify({key:n,signature:r.sig,data:i})))throw new dt(rt.InvalidSignature,"Invalid signature for DHT BEP44 message");return t_(r.v)})}static parseTxtDataToObject(e){return this.parseTxtDataToString(e).split(oD).reduce((r,n)=>{let[i,o]=n.split("=");return r[i]=o,r},{})}static parseTxtDataToString(e){if(typeof e=="string")return e;if(e instanceof Uint8Array)return ae.uint8Array(e).toString();if(Array.isArray(e))return e.map(r=>this.parseTxtDataToString(r)).join("");throw new dt(rt.InternalError,"Pkarr returned DNS TXT record with invalid data type")}static validatePreviousDidProof(e){return Yo(this,arguments,void 0,function*({newDid:r,previousDidProof:n}){let i=yield t.identifierToIdentityKey({didUri:n.previousDid}),o=t.identifierToIdentityKeyBytes({didUri:r}),s=ae.base64Url(n.signature).toUint8Array();if(!(yield Fr.verify({key:i,data:o,signature:s})))throw new dt(rt.InvalidPreviousDidProof,"The previous DID proof is invalid.")})}static chunkDataIfNeeded(e){if(e.length<=255)return e;let r=[];for(let n=0;n!(j.algorithm in Grt)))throw new Error("One or more verification method algorithms are not supported");let c=(i=r.verificationMethods)===null||i===void 0?void 0:i.filter(j=>"id"in j).map(j=>j.id);if(c&&c.length!==new Set(c).size)throw new Error("One or more verification method IDs are not unique");if(!((o=r.services)===null||o===void 0)&&o.some(j=>!j.id||!j.type||!j.serviceEndpoint))throw new Error("One or more services are missing required properties");let l={algorithm:"Ed25519",purposes:["authentication","assertionMethod","capabilityDelegation","capabilityInvocation"]},p=[];for(let j of(s=r.verificationMethods)!==null&&s!==void 0?s:[l]){let q=yield e.generateKey({algorithm:j.algorithm}),F=yield e.getPublicKey({keyUri:q});p.push({id:j.id,publicKeyJwk:F,purposes:(a=j.purposes)!==null&&a!==void 0?a:["authentication","assertionMethod","capabilityDelegation","capabilityInvocation"]})}let m=yield e.generateKey({algorithm:qf.secp256k1}),g=yield e.getPublicKey({keyUri:m}),v=yield e.generateKey({algorithm:qf.secp256k1}),x=yield e.getPublicKey({keyUri:v}),S=yield Pb.computeLongFormDidUri({recoveryKey:g,updateKey:x,services:(d=r.services)!==null&&d!==void 0?d:[],verificationMethods:p}),{didDocument:P,didResolutionMetadata:A}=yield t.resolve(S,{gatewayUri:r.gatewayUri});if(P===null)throw new Error(`Unable to resolve DID during creation: ${A?.error}`);let $=new Qi({uri:S,document:P,metadata:{published:!1,canonicalId:S.split(":",3).join(":"),recoveryKey:g,updateKey:x},keyManager:e});if(!((u=r.publish)!==null&&u!==void 0)||u){let j=yield t.publish({did:$,gatewayUri:r.gatewayUri});$.metadata=j.didDocumentMetadata}return $})}static getSigningMethod(e){return h0(this,arguments,void 0,function*({didDocument:r,methodId:n}){var i;let o=nr.parse(r.id);if(o&&o.method!==this.methodName)throw new dt(rt.MethodNotSupported,`Method not supported: ${o.method}`);let s=(i=r.verificationMethod)===null||i===void 0?void 0:i.find(a=>{var d;return a.id===(n??((d=r.assertionMethod)===null||d===void 0?void 0:d[0]))});if(!(s&&s.publicKeyJwk))throw new dt(rt.InternalError,"A verification method intended for signing could not be determined from the DID Document");return s})}static import(e){return h0(this,arguments,void 0,function*({portableDid:r,keyManager:n=new ei}){let i=nr.parse(r.uri);if(i?.method!==t.methodName)throw new dt(rt.MethodNotSupported,"Method not supported");return yield Qi.import({portableDid:r,keyManager:n})})}static publish(e){return h0(this,arguments,void 0,function*({did:r,gatewayUri:n=Zwe}){var i,o,s;let a=(o=(i=r.document.verificationMethod)===null||i===void 0?void 0:i.map(c=>({id:c.id,publicKeyJwk:c.publicKeyJwk,purposes:mz({didDocument:r.document,methodId:c.id})})))!==null&&o!==void 0?o:[],d=yield Pb.createIonDocument({services:(s=r.document.service)!==null&&s!==void 0?s:[],verificationMethods:a}),u=yield Pb.constructCreateRequest({ionDocument:d,recoveryKey:r.metadata.recoveryKey,updateKey:r.metadata.updateKey});try{let c=Pb.appendPathToUrl({baseUrl:n,path:"/operations"}),l=yield fetch(c,{method:"POST",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)});return{didDocument:r.document,didDocumentMetadata:Object.assign(Object.assign({},r.metadata),{published:l.ok}),didRegistrationMetadata:{}}}catch{return{didDocument:null,didDocumentMetadata:{published:!1},didRegistrationMetadata:{error:rt.InternalError,errorMessage:`Failed to publish DID document for: ${r.uri}`}}}})}static resolve(e){return h0(this,arguments,void 0,function*(r,n={}){var i,o;let s=nr.parse(r);if(!s)return Object.assign(Object.assign({},fi),{didResolutionMetadata:{error:"invalidDid"}});if(s.method!==t.methodName)return Object.assign(Object.assign({},fi),{didResolutionMetadata:{error:"methodNotSupported"}});let a=(i=n?.gatewayUri)!==null&&i!==void 0?i:Zwe;try{let d=Pb.appendPathToUrl({baseUrl:a,path:`/identifiers/${r}`}),u=yield fetch(d);if(!u.ok)throw new dt(rt.NotFound,`Unable to find DID document for: ${r}`);let{didDocument:c,didDocumentMetadata:l}=yield u.json();return Object.assign(Object.assign(Object.assign({},fi),c&&{didDocument:c}),{didDocumentMetadata:Object.assign({published:(o=l?.method)===null||o===void 0?void 0:o.published},l)})}catch(d){if(!(d instanceof dt))throw new Error(d);return Object.assign(Object.assign({},fi),{didResolutionMetadata:Object.assign({error:d.code},d.message&&{errorMessage:d.message})})}})}};vz.methodName="ion";var Pb=class t{static appendPathToUrl({baseUrl:e,path:r}){let n=new URL(e);return n.pathname=n.pathname.endsWith("/")?n.pathname:n.pathname+"/",n.pathname+=r.startsWith("/")?r.substring(1):r,n.toString()}static computeLongFormDidUri(e){return h0(this,arguments,void 0,function*({recoveryKey:r,updateKey:n,services:i,verificationMethods:o}){let s=yield t.createIonDocument({services:i,verificationMethods:o}),a=t.normalizeJwk(r),d=t.normalizeJwk(n);return yield Jy.createLongFormDid({document:s,recoveryKey:a,updateKey:d})})}static constructCreateRequest(e){return h0(this,arguments,void 0,function*({ionDocument:r,recoveryKey:n,updateKey:i}){return yield $f.createCreateRequest({document:r,recoveryKey:t.normalizeJwk(n),updateKey:t.normalizeJwk(i)})})}static createIonDocument(e){return h0(this,arguments,void 0,function*({services:r,verificationMethods:n}){var i,o;let s=[];for(let u of n){let c=(o=(i=u.id)!==null&&i!==void 0?i:u.publicKeyJwk.kid)!==null&&o!==void 0?o:yield yt({jwk:u.publicKeyJwk});c=`${c.split("#").pop()}`;let l={id:c,publicKeyJwk:t.normalizeJwk(u.publicKeyJwk),purposes:u.purposes,type:"JsonWebKey2020"};s.push(l)}let a=r.map(u=>Object.assign(Object.assign({},u),{id:`${u.id.split("#").pop()}`}));return{publicKeys:s,services:a}})}static normalizeJwk(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}`);return n}};f();var aD=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Ha=class t extends uu{static create(){return aD(this,arguments,void 0,function*({keyManager:e=new ei,options:r={}}={}){var n,i,o,s;if(r.algorithm&&r.verificationMethods)throw new Error("The 'algorithm' and 'verificationMethods' options are mutually exclusive");if(r.verificationMethods&&r.verificationMethods.length!==1)throw new Error("The 'verificationMethods' option must contain exactly one entry");let a=(s=(n=r.algorithm)!==null&&n!==void 0?n:(o=(i=r.verificationMethods)===null||i===void 0?void 0:i[0])===null||o===void 0?void 0:o.algorithm)!==null&&s!==void 0?s:"Ed25519",d=yield e.generateKey({algorithm:a}),u=yield e.getPublicKey({keyUri:d}),c=ae.object(u).toBase64Url(),l=`did:${t.methodName}:${c}`,m=(yield t.resolve(l)).didDocument;return new Qi({uri:l,document:m,metadata:{},keyManager:e})})}static getSigningMethod(e){return aD(this,arguments,void 0,function*({didDocument:r}){var n;let i=nr.parse(r.id);if(i&&i.method!==this.methodName)throw new dt(rt.MethodNotSupported,`Method not supported: ${i.method}`);let[o]=(n=r.verificationMethod)!==null&&n!==void 0?n:[];if(!(o&&o.publicKeyJwk))throw new dt(rt.InternalError,"A verification method intended for signing could not be determined from the DID Document");return o})}static import(e){return aD(this,arguments,void 0,function*({portableDid:r,keyManager:n=new ei}){let i=nr.parse(r.uri);if(i?.method!==t.methodName)throw new dt(rt.MethodNotSupported,"Method not supported");let o=yield Qi.import({portableDid:r,keyManager:n});if(o.document.verificationMethod.length!==1)throw new dt(rt.InvalidDidDocument,"DID document must contain exactly one verification method");return o})}static resolve(e,r){return aD(this,void 0,void 0,function*(){let n=nr.parse(e),i;try{i=ae.base64Url(n.id).toObject()}catch{}if(!n||!i)return Object.assign(Object.assign({},fi),{didResolutionMetadata:{error:"invalidDid"}});if(n.method!==t.methodName)return Object.assign(Object.assign({},fi),{didResolutionMetadata:{error:"methodNotSupported"}});let o={"@context":["https://www.w3.org/ns/did/v1"],id:n.uri},s=`${o.id}#0`;switch(o.verificationMethod=[{id:s,type:"JsonWebKey",controller:o.id,publicKeyJwk:i}],o.authentication=[s],o.assertionMethod=[s],o.capabilityInvocation=[s],o.capabilityDelegation=[s],o.keyAgreement=[s],i.use){case"sig":{delete o.keyAgreement;break}case"enc":{delete o.authentication,delete o.assertionMethod,delete o.capabilityInvocation,delete o.capabilityDelegation;break}}return Object.assign(Object.assign({},fi),{didDocument:o})})}};Ha.methodName="jwk";f();var gl=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},kp;(function(t){t.Ed25519="Ed25519",t.secp256k1="secp256k1",t.secp256r1="secp256r1",t.X25519="X25519"})(kp||(kp={}));var bz={Ed25519VerificationKey2020:"https://w3id.org/security/suites/ed25519-2020/v1",JsonWebKey2020:"https://w3id.org/security/suites/jws-2020/v1",X25519KeyAgreementKey2020:"https://w3id.org/security/suites/x25519-2020/v1"},Jrt={Ed25519:kp.Ed25519,ES256K:kp.secp256k1,ES256:kp.secp256r1,"P-256":kp.secp256r1,secp256k1:kp.secp256k1,secp256r1:kp.secp256r1,X25519:kp.X25519},wz=class t extends uu{static create(){return gl(this,arguments,void 0,function*({keyManager:e=new ei,options:r={}}={}){var n,i,o,s;if(r.algorithm&&r.verificationMethods)throw new Error("The 'algorithm' and 'verificationMethods' options are mutually exclusive");if(r.verificationMethods&&r.verificationMethods.length!==1)throw new Error("The 'verificationMethods' option must contain exactly one entry");let a=(s=(n=r.algorithm)!==null&&n!==void 0?n:(o=(i=r.verificationMethods)===null||i===void 0?void 0:i[0])===null||o===void 0?void 0:o.algorithm)!==null&&s!==void 0?s:"Ed25519",d=yield e.generateKey({algorithm:a}),u=yield e.getPublicKey({keyUri:d}),c=yield xc.publicKeyToMultibaseId({publicKey:u}),l=`did:${t.methodName}:${c}`,m=(yield t.resolve(l,r)).didDocument;return new Qi({uri:l,document:m,metadata:{},keyManager:e})})}static getSigningMethod(e){return gl(this,arguments,void 0,function*({didDocument:r}){var n;let i=nr.parse(r.id);if(i&&i.method!==this.methodName)throw new dt(rt.MethodNotSupported,`Method not supported: ${i.method}`);let[o]=r.assertionMethod||[],s=(n=r.verificationMethod)===null||n===void 0?void 0:n.find(a=>a.id===o);if(!(s&&s.publicKeyJwk))throw new dt(rt.InternalError,"A verification method intended for signing could not be determined from the DID Document");return s})}static import(e){return gl(this,arguments,void 0,function*({portableDid:r,keyManager:n=new ei}){let i=nr.parse(r.uri);if(i?.method!==t.methodName)throw new dt(rt.MethodNotSupported,"Method not supported");let o=yield Qi.import({portableDid:r,keyManager:n});if(o.document.verificationMethod.length!==1)throw new dt(rt.InvalidDidDocument,"DID document must contain exactly one verification method");return o})}static resolve(e,r){return gl(this,void 0,void 0,function*(){try{let n=yield t.createDocument({didUri:e,options:r});return Object.assign(Object.assign({},fi),{didDocument:n})}catch(n){if(!(n instanceof dt))throw new Error(n);return Object.assign(Object.assign({},fi),{didResolutionMetadata:Object.assign({error:n.code},n.message&&{errorMessage:n.message})})}})}static createDocument(e){return gl(this,arguments,void 0,function*({didUri:r,options:n={}}){let{defaultContext:i="https://www.w3.org/ns/did/v1",enableEncryptionKeyDerivation:o=!1,enableExperimentalPublicKeyTypes:s=!1,publicKeyFormat:a="JsonWebKey2020"}=n,d={id:""},u=nr.parse(r);if(!u)throw new dt(rt.InvalidDid,`Invalid DID URI: ${r}`);let c=u.id;if(u.method!==t.methodName)throw new dt(rt.MethodNotSupported,`Method not supported: ${u.method}`);if(!t.validateIdentifier(u))throw new dt(rt.InvalidDid,`Invalid DID URI: ${r}`);let l=yield t.createSignatureMethod({didUri:r,multibaseValue:c,options:{enableExperimentalPublicKeyTypes:s,publicKeyFormat:a}});if(d.id=u.uri,d.verificationMethod=[l],d.authentication=[l.id],d.assertionMethod=[l.id],d.capabilityInvocation=[l.id],d.capabilityDelegation=[l.id],o===!0){let g=a==="Ed25519VerificationKey2020"?"X25519KeyAgreementKey2020":"JsonWebKey2020",v=yield this.createEncryptionMethod({didUri:r,multibaseValue:c,options:{enableExperimentalPublicKeyTypes:s,publicKeyFormat:g}});d.verificationMethod.push(v),d.keyAgreement=[v.id]}let p=[i];return pz({didDocument:d}).forEach(g=>{let v=bz[g];p.push(v)}),d["@context"]=p,d})}static createEncryptionMethod(e){return gl(this,arguments,void 0,function*({didUri:r,multibaseValue:n,options:i}){let{enableExperimentalPublicKeyTypes:o,publicKeyFormat:s}=i,a={id:"",type:"",controller:""},{keyBytes:d,multicodecCode:u}=yield t.deriveEncryptionKey({multibaseValue:n}),c=d.byteLength,l=xc.MULTICODEC_PUBLIC_KEY_LENGTH[u];if(c!==l)throw new dt(rt.InvalidPublicKeyLength,`Expected ${c} bytes. Actual: ${l}`);let p=rD({keyBytes:d,multicodecCode:u});a.id=`${r}#${p}`;try{new URL(a.id)}catch{throw new dt(rt.InvalidDidUrl,"Verification Method ID is not a valid DID URL.")}if(!(s in bz))throw new dt(rt.UnsupportedPublicKeyType,`Unsupported format: ${s}`);if(o===!1&&!["Multikey","JsonWebKey2020","X25519KeyAgreementKey2020"].includes(s))throw new dt(rt.InvalidPublicKeyType,`Specified '${s}' without setting enableExperimentalPublicKeyTypes to true.`);if(a.type=s,a.controller=r,s==="X25519KeyAgreementKey2020"&&(a.publicKeyMultibase=p),s==="JsonWebKey2020"){let{crv:g}=yield xc.multicodecToJwk({code:u});a.publicKeyJwk=yield xc.keyConverter(g).bytesToPublicKey({publicKeyBytes:d})}return a})}static createSignatureMethod(e){return gl(this,arguments,void 0,function*({didUri:r,multibaseValue:n,options:i}){let{enableExperimentalPublicKeyTypes:o,publicKeyFormat:s}=i,a={id:"",type:"",controller:""},{keyBytes:d,multicodecCode:u,multicodecName:c}=nD({multibaseKeyId:n}),l=d.byteLength,p=xc.MULTICODEC_PUBLIC_KEY_LENGTH[u];if(l!==p)throw new dt(rt.InvalidPublicKeyLength,`Expected ${l} bytes. Actual: ${p}`);let m=!1;switch(c){case"secp256k1-pub":m=yield En.validatePublicKey({publicKeyBytes:d});break;case"ed25519-pub":m=yield Fr.validatePublicKey({publicKeyBytes:d});break;case"x25519-pub":m=!0;break}if(!m)throw new dt(rt.InvalidPublicKey,"Invalid public key detected.");a.id=`${r}#${n}`;try{new URL(a.id)}catch{throw new dt(rt.InvalidDidUrl,"Verification Method ID is not a valid DID URL.")}if(!(s in bz))throw new dt(rt.UnsupportedPublicKeyType,`Unsupported format: ${s}`);if(o===!1&&!["Multikey","JsonWebKey2020","Ed25519VerificationKey2020"].includes(s))throw new dt(rt.InvalidPublicKeyType,`Specified '${s}' without setting enableExperimentalPublicKeyTypes to true.`);if(a.type=s,a.controller=r,s==="Ed25519VerificationKey2020"&&(a.publicKeyMultibase=n),s==="JsonWebKey2020"){let{crv:v}=yield xc.multicodecToJwk({code:u});a.publicKeyJwk=yield xc.keyConverter(v).bytesToPublicKey({publicKeyBytes:d})}return a})}static deriveEncryptionKey(e){return gl(this,arguments,void 0,function*({multibaseValue:r}){let n={keyBytes:new Uint8Array,multicodecCode:0},{keyBytes:i,multicodecCode:o}=nD({multibaseKeyId:r});if(o===237){let s=yield xc.keyConverter("Ed25519").bytesToPublicKey({publicKeyBytes:i}),a=yield Fr.convertPublicKeyToX25519({publicKey:s});n={keyBytes:yield xc.keyConverter("Ed25519").publicKeyToBytes({publicKey:a}),multicodecCode:236}}return n})}static validateIdentifier(e){let{method:r,id:n}=e,[i]=e.uri.split(":",1);return i==="did"&&r==="key"&&Number("1")>0&&i0(n)==="String"&&n.startsWith("z")}};wz.methodName="key";var xc=class t{static jwkToMulticodec(e){return gl(this,arguments,void 0,function*({jwk:r}){let n=[];r.crv&&(n.push(r.crv),r.d?n.push("private"):n.push("public"));let i=n.join(":"),o=t.JWK_TO_MULTICODEC[i];if(o===void 0)throw new Error(`Unsupported JWK to Multicodec conversion: '${i}'`);return{code:fa.getCodeFromName({name:o}),name:o}})}static keyCompressor(e){let n={"P-256":Mn.compressPublicKey,secp256k1:En.compressPublicKey}[e];if(!n)throw new dt(rt.InvalidPublicKeyType,`Unsupported curve: ${e}`);return n}static keyConverter(e){let n={Ed25519:Fr,"P-256":Mn,secp256k1:En,X25519:l0}[e];if(!n)throw new dt(rt.InvalidPublicKeyType,`Unsupported curve: ${e}`);return n}static multicodecToJwk(e){return gl(this,arguments,void 0,function*({code:r,name:n}){if(!(n?!r:r))throw new Error("Either 'name' or 'code' must be defined, but not both.");n=n===void 0?fa.getNameFromCode({code:r}):n;let i=n,o=t.MULTICODEC_TO_JWK[i];if(o===void 0)throw new Error("Unsupported Multicodec to JWK conversion");return Object.assign({},o)})}static publicKeyToMultibaseId(e){return gl(this,arguments,void 0,function*({publicKey:r}){var n;if(!(r?.crv&&r.crv in Jrt))throw new dt(rt.InvalidPublicKeyType,`Public key contains an unsupported key type: ${(n=r?.crv)!==null&&n!==void 0?n:"undefined"}`);let i=yield t.keyConverter(r.crv).publicKeyToBytes({publicKey:r});/^(secp256k1|P-256|P-384|P-521)$/.test(r.crv)&&(i=yield t.keyCompressor(r.crv)({publicKeyBytes:i}));let{name:o}=yield t.jwkToMulticodec({jwk:r});return rD({keyBytes:i,multicodecName:o})})}};xc.JWK_TO_MULTICODEC={"Ed25519:public":"ed25519-pub","Ed25519:private":"ed25519-priv","secp256k1:public":"secp256k1-pub","secp256k1:private":"secp256k1-priv","X25519:public":"x25519-pub","X25519:private":"x25519-priv"};xc.MULTICODEC_PUBLIC_KEY_LENGTH={231:33,236:32,237:32};xc.MULTICODEC_TO_JWK={"ed25519-pub":{crv:"Ed25519",kty:"OKP",x:""},"ed25519-priv":{crv:"Ed25519",kty:"OKP",x:"",d:""},"secp256k1-pub":{crv:"secp256k1",kty:"EC",x:"",y:""},"secp256k1-priv":{crv:"secp256k1",kty:"EC",x:"",y:"",d:""},"x25519-pub":{crv:"X25519",kty:"OKP",x:""},"x25519-priv":{crv:"X25519",kty:"OKP",x:"",d:""}};f();var Zrt=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},_z=class t extends uu{static resolve(e,r){return Zrt(this,void 0,void 0,function*(){let n=nr.parse(e);if(!n)return Object.assign(Object.assign({},fi),{didResolutionMetadata:{error:"invalidDid"}});if(n.method!==t.methodName)return Object.assign(Object.assign({},fi),{didResolutionMetadata:{error:"methodNotSupported"}});let i=`https://${n.id.replace(/:/g,"/")}`;i=decodeURIComponent(i);let o=n.id.includes(":")?`${i}/did.json`:`${i}/.well-known/did.json`;try{let s=yield fetch(o);if(!s.ok)throw new Error("HTTP error status code returned");let a=yield s.json();return Object.assign(Object.assign({},fi),{didDocument:a})}catch{return Object.assign(Object.assign({},fi),{didResolutionMetadata:{error:"notFound"}})}})}};_z.methodName="web";f();var Ywe=gt(ub(),1),Xwe=gt(GS(),1),Yrt=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},P_=class{constructor({db:e,location:r="DATA/DID_RESOLVERCACHE",ttl:n="15m"}={}){this.cache=e??new Xwe.Level(r),this.ttl=(0,Ywe.default)(n)}get(e){return Yrt(this,void 0,void 0,function*(){try{let r=yield this.cache.get(e),n=JSON.parse(r);if(Date.now()>=n.ttlMillis){this.cache.nextTick(()=>this.cache.del(e));return}else return n.value}catch(r){if(r.notFound)return;throw r}})}set(e,r){let n={ttlMillis:Date.now()+this.ttl,value:r},i=JSON.stringify(n);return this.cache.put(e,i)}delete(e){return this.cache.del(e)}clear(){return this.cache.clear()}close(){return this.cache.close()}};f();var Qwe={get:function(t){return null},set:function(t,e){return null},delete:function(t){return null},clear:function(){return null},close:function(){return null}};f();var e1e=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},I_=class{constructor({cache:e,didResolvers:r}){this.didResolvers=new Map,this.cache=e||Qwe;for(let n of r)this.didResolvers.set(n.methodName,n)}resolve(e,r){return e1e(this,void 0,void 0,function*(){let n=nr.parse(e);if(!n)return Object.assign(Object.assign({},fi),{didResolutionMetadata:{error:rt.InvalidDid,errorMessage:`Invalid DID URI: ${e}`}});let i=this.didResolvers.get(n.method);if(!i)return Object.assign(Object.assign({},fi),{didResolutionMetadata:{error:rt.MethodNotSupported,errorMessage:`Method not supported: ${n.method}`}});let o=yield this.cache.get(n.uri);if(o)return o;{let s=yield i.resolve(n.uri,r);return s.didResolutionMetadata.error||(yield this.cache.set(n.uri,s)),s}})}dereference(e,r){return e1e(this,void 0,void 0,function*(){let n=nr.parse(e);if(!n)return{dereferencingMetadata:{error:rt.InvalidDidUrl},contentStream:null,contentMetadata:{}};let{didDocument:i,didResolutionMetadata:o,didDocumentMetadata:s}=yield this.resolve(n.uri);if(!i)return{dereferencingMetadata:{error:o.error},contentStream:null,contentMetadata:{}};if(!n.fragment||n.query)return{dereferencingMetadata:{contentType:"application/did+json"},contentStream:i,contentMetadata:s};let{service:a=[],verificationMethod:d=[]}=i,u=new Set([e,n.fragment,`#${n.fragment}`]),c;for(let l of d)if(u.has(l.id)){c=l;break}for(let l of a)if(u.has(l.id)){c=l;break}return c?{dereferencingMetadata:{contentType:"application/did+json"},contentStream:c,contentMetadata:o}:{dereferencingMetadata:{error:rt.NotFound},contentStream:null,contentMetadata:{}}})}};var Xrt=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Ib=class extends P_{constructor({agent:e,db:r,location:n,ttl:i}){super({db:r,location:n,ttl:i}),this._resolving=new Map,this._agent=e}get agent(){if(!this._agent)throw new Error("Agent not initialized");return this._agent}set agent(e){this._agent=e}get(e){return Xrt(this,void 0,void 0,function*(){try{let r=yield this.cache.get(e),n=JSON.parse(r);if(!this._resolving.has(e)&&Date.now()>=n.ttlMillis){this._resolving.set(e,!0);let i=yield this.agent.did.get({didUri:e,tenant:this.agent.agentDid.uri});if(typeof i<"u")try{let o=yield this.agent.did.resolve(e);if(!o.didResolutionMetadata.error&&o.didDocument){let s=Object.assign(Object.assign({},i),{document:o.didDocument,metadata:o.didDocumentMetadata});try{yield this.agent.did.update({portableDid:s,tenant:this.agent.agentDid.uri,publish:!1})}catch(a){a.message&&!a.message.includes("No changes detected, update aborted")&&Os.error(`Error updating DID: ${a.message}`)}}}finally{this._resolving.delete(e)}else this._resolving.delete(e),this.cache.nextTick(()=>this.cache.del(e))}return n.value}catch(r){if(r.notFound)return;throw r}})}};f();var Qrt=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},k_=class{constructor({did:e,metadata:r}){this.did=e,this.metadata=r}export(){return Qrt(this,void 0,void 0,function*(){return{portableDid:yield this.did.export(),metadata:Object.assign({},this.metadata)}})}};f();f();f();var ent=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},cD=class{static deriveKeyBytes({baseKeyBytes:e,length:r,hash:n,salt:i,info:o=new Uint8Array}){return ent(this,void 0,void 0,function*(){let a=yield us().importKey("raw",e,{name:"HKDF"},!1,["deriveBits"]);i=typeof i=="string"?ae.string(i).toUint8Array():i,o=typeof o=="string"?ae.string(o).toUint8Array():o;let d=yield crypto.subtle.deriveBits({name:"HKDF",hash:n,salt:i,info:o},a,r);return new Uint8Array(d)})}};var tnt=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},rnt=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);isuper.delete}});return Bp(this,void 0,void 0,function*(){return yield r.delete.call(this,e)})}get(e){let r=Object.create(null,{get:{get:()=>super.get}});return Bp(this,void 0,void 0,function*(){return yield r.get.call(this,e)})}list(e){let r=Object.create(null,{list:{get:()=>super.list}});return Bp(this,void 0,void 0,function*(){return yield r.list.call(this,e)})}set(e){let r=Object.create(null,{set:{get:()=>super.set}});return Bp(this,void 0,void 0,function*(){return yield r.set.call(this,e)})}getAllRecords({agent:e,tenantDid:r}){var n;return Bp(this,void 0,void 0,function*(){this._index.clear();let{reply:i}=yield e.dwn.processRequest({author:r,target:r,messageType:Ie.RecordsQuery,messageParams:{filter:Object.assign({},this._recordProperties)}}),o=[];for(let s of(n=i.entries)!==null&&n!==void 0?n:[]){if(!s.encodedData)throw new Error(`${this.name}: Expected 'encodedData' to be present in the DWN query result entry`);let a=ae.base64Url(s.encodedData).toObject();if(f5(a)){let d=`${r}${Xo}${a.uri}`;this._index.set(d,s.recordId),this._cache.set(s.recordId,a),o.push(a)}}return o})}},p5=class extends y0{constructor(){super(...arguments),this.name="InMemoryDidStore"}delete(e){let r=Object.create(null,{delete:{get:()=>super.delete}});return Bp(this,void 0,void 0,function*(){return yield r.delete.call(this,e)})}get(e){let r=Object.create(null,{get:{get:()=>super.get}});return Bp(this,void 0,void 0,function*(){return yield r.get.call(this,e)})}list(e){let r=Object.create(null,{list:{get:()=>super.list}});return Bp(this,void 0,void 0,function*(){return yield r.list.call(this,e)})}set(e){let r=Object.create(null,{set:{get:()=>super.set}});return Bp(this,void 0,void 0,function*(){return yield r.set.call(this,e)})}};var Mp=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},kb;(function(t){t.Create="Create",t.Resolve="Resolve"})(kb||(kb={}));function i1e(t,e){return t.messageType===e}var m5=class extends I_{constructor({agent:e,didMethods:r,resolverCache:n,store:i}){if(!r)throw new TypeError("AgentDidApi: Required parameter missing: 'didMethods'");super({didResolvers:r,cache:n??new Ib({agent:e,location:"DATA/AGENT/DID_CACHE"})}),this._didMethods=new Map,this._agent=e,this._store=i??new p5;for(let o of r)this._didMethods.set(o.methodName,o)}get agent(){if(this._agent===void 0)throw new Error("AgentDidApi: Unable to determine agent execution context.");return this._agent}set agent(e){this._agent=e,"agent"in this.cache&&(this.cache.agent=e)}create({method:e,tenant:r,options:n,store:i}){return Mp(this,void 0,void 0,function*(){let s=yield this.getMethod(e).create({keyManager:this.agent.keyManager,options:n});if(yield this.cache.set(s.uri,{didDocument:s.document,didResolutionMetadata:{},didDocumentMetadata:s.metadata}),i??!0){let{uri:a,document:d,metadata:u}=s,c={uri:a,document:d,metadata:u};yield this._store.set({id:c.uri,data:c,agent:this.agent,tenant:r??c.uri,preventDuplicates:!1,useCache:!0})}return s})}export({didUri:e,tenant:r}){return Mp(this,void 0,void 0,function*(){let n=yield this.get({didUri:e,tenant:r});if(!n)throw new Error(`AgentDidApi: Failed to export due to DID not found: ${e}`);return yield n.export()})}get({didUri:e,tenant:r}){return Mp(this,void 0,void 0,function*(){let n=yield this._store.get({id:e,agent:this.agent,tenant:r,useCache:!0});return n?yield Qi.import({portableDid:n,keyManager:this.agent.keyManager}):void 0})}getSigningMethod({didUri:e,methodId:r}){return Mp(this,void 0,void 0,function*(){let n=nr.parse(e);if(!n)throw new Error(`Invalid DID URI: ${e}`);let i=this.getMethod(n.method),{didDocument:o,didResolutionMetadata:s}=yield this.resolve(e);if(!o)throw new Error(`DID resolution failed for '${e}': ${JSON.stringify(s)}`);return yield i.getSigningMethod({didDocument:o,methodId:r})})}update({tenant:e,portableDid:r,publish:n=!0}){return Mp(this,void 0,void 0,function*(){let i=yield this.get({didUri:r.uri,tenant:e??r.uri});if(!i)throw new Error(`AgentDidApi: Could not update, DID not found: ${r.uri}`);if(r5(r.document)===r5(i.document))throw new Error("AgentDidApi: No changes detected, update aborted");let o=yield Qi.import({keyManager:this.agent.keyManager,portableDid:r}),{uri:s,document:a,metadata:d}=o,u={uri:s,document:a,metadata:d};if(yield this.cache.set(s,{didDocument:a,didResolutionMetadata:{},didDocumentMetadata:d}),yield this._store.set({id:s,data:u,agent:this.agent,tenant:e??s,updateExisting:!0,useCache:!0}),n){let c=nr.parse(s);c&&c.method==="dht"&&(yield _c.publish({did:o}))}return o})}import({portableDid:e,tenant:r}){return Mp(this,void 0,void 0,function*(){let n=yield Qi.import({keyManager:this.agent.keyManager,portableDid:e}),{uri:i,document:o,metadata:s}=n,a={uri:i,document:o,metadata:s};return yield this.cache.set(i,{didDocument:o,didResolutionMetadata:{},didDocumentMetadata:s}),yield this._store.set({id:a.uri,data:a,agent:this.agent,tenant:r??a.uri,preventDuplicates:!0,useCache:!0}),n})}delete({didUri:e,tenant:r,deleteKey:n=!0}){return Mp(this,void 0,void 0,function*(){let i=yield this._store.get({id:e,agent:this.agent,tenant:r,useCache:!1});if(!i)throw new Error("AgentDidApi: Could not delete, DID not found");yield this.cache.delete(e),yield this._store.delete({id:e,agent:this.agent,tenant:r}),n&&(yield this.deleteKeys({portableDid:i}))})}deleteKeys({portableDid:e}){return Mp(this,void 0,void 0,function*(){for(let r of e.document.verificationMethod||[]){if(!r.publicKeyJwk)continue;let n=yield this.agent.keyManager.getKeyUri({key:r.publicKeyJwk});yield this.agent.keyManager.deleteKey({keyUri:n})}})}processRequest(e){var r;return Mp(this,void 0,void 0,function*(){if(i1e(e,kb.Create))try{let n=yield this.create(Object.assign({},e.messageParams));return{result:{uri:n.uri,document:n.document,metadata:n.metadata},ok:!0,status:{code:201,message:"Created"}}}catch(n){return{ok:!1,status:{code:500,message:(r=n.message)!==null&&r!==void 0?r:"Unknown error occurred"}}}if(i1e(e,kb.Resolve)){let{didUri:n,options:i}=e.messageParams;return{result:yield this.resolve(n,i),ok:!0,status:{code:200,message:"OK"}}}throw new Error(`AgentDidApi: Unsupported request type: ${e.messageType}`)})}getMethod(e){let r=this._didMethods.get(e);if(r===void 0)throw new Error(`DID Method not supported: ${e}`);return r}};f();f();var s1e=gt(o1e(),1);var Sz=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})};function Az(t){return vD(t.stream())}function B_(t,e){return Sz(this,void 0,void 0,function*(){let r=yield e.dereference(`${t}#dwn`);if(r.dereferencingMetadata.error)throw new Error(`Failed to dereference '${t}#dwn': ${r.dereferencingMetadata.error}`);if(iD.isDwnDidService(r.contentStream)){let{serviceEndpoint:n}=r.contentStream,i=typeof n=="string"?[n]:Array.isArray(n)&&n.every(o=>typeof o=="string")?n:[];if(i.length>0)return i}return[]})}function Kf(t){return _e.getAuthor(t)}function a1e(t){let e=Vr.decodePlainObjectPayload(t.authorization.signature);return e?.protocolRole}function Rb(t){return!t||typeof t!="object"||t===null?!1:"message"in t&&typeof t.message=="object"&&t.message!==null&&"descriptor"in t.message&&typeof t.message.descriptor=="object"&&t.message.descriptor!==null&&"interface"in t.message.descriptor&&t.message.descriptor.interface===Te.Records&&"method"in t.message.descriptor&&t.message.descriptor.method===Se.Write}function cnt(t){return _e.getCid(t)}function c1e(t,e){return Sz(this,void 0,void 0,function*(){let r=e===uo.CreatedAscending||e===uo.CreatedDescending?t.descriptor.dateCreated:t.descriptor.datePublished;if(r===void 0)throw new Error("The dateCreated or datePublished property is missing from the record descriptor.");return{messageCid:yield cnt(t),value:r}})}function vD(t){return new s1e.ReadableWebToNodeStream(t)}function d1e(t,e=3e3,r=3e5,n){let i=Date.now()+r,o=null,s=!0;return new Promise((a,d)=>{n&&n.addEventListener("abort",()=>{s=!1,o!==null&&clearTimeout(o),console.log("Polling aborted by user"),a(null)});function u(){return Sz(this,void 0,void 0,function*(){if(!s)return;let c=i-Date.now();if(c<=0){s=!1,console.log("Polling stopped: TTL reached"),a(null);return}console.log(`Polling... (Remaining time: ${Math.ceil(c/1e3)}s)`);try{let l=yield t();if(l.ok){s=!1,o!==null&&clearTimeout(o),console.log("Polling stopped: Success condition met"),a(l);return}}catch(l){console.error("Error fetching data:",l),d(l)}s&&(o=setTimeout(u,e))})}u()})}function Op(t,e){return t.endsWith("/")&&(t=t.slice(0,-1)),e.startsWith("/")&&(e=e.slice(1)),`${t}/${e}`}var Cp=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})};function dnt(t,e){return t.messageType===e}function bD(t,e){return e.descriptor.interface+e.descriptor.method===t}function u1e(t){return t===Ie.RecordsDelete||t===Ie.RecordsQuery||t===Ie.RecordsRead||t===Ie.RecordsSubscribe||t===Ie.RecordsWrite}function l1e(t){return t.interface===Te.Records}var M_=class{constructor({agent:e,dwn:r}){this._agent=e,this._dwn=r}get agent(){if(this._agent===void 0)throw new Error("AgentDwnApi: Unable to determine agent execution context.");return this._agent}set agent(e){this._agent=e}get node(){return this._dwn}static createDwn({dataPath:e,dataStore:r,didResolver:n,eventLog:i,eventStream:o,messageStore:s,tenantGate:a,resumableTaskStore:d}){return Cp(this,void 0,void 0,function*(){return r??(r=new b_({blockstoreLocation:`${e}/DWN_DATASTORE`})),n??(n=new I_({didResolvers:[_c,Ha],cache:new P_({location:`${e}/DID_RESOLVERCACHE`})})),i??(i=new x_({location:`${e}/DWN_EVENTLOG`})),s??(s=new E_({blockstoreLocation:`${e}/DWN_MESSAGESTORE`,indexLocation:`${e}/DWN_MESSAGEINDEX`})),d??(d=new wb({location:`${e}/DWN_RESUMABLETASKSTORE`})),o??(o=new S_),yield B3.create({dataStore:r,didResolver:n,eventLog:i,eventStream:o,messageStore:s,tenantGate:a,resumableTaskStore:d})})}processRequest(e){return Cp(this,void 0,void 0,function*(){let{message:r,dataStream:n}=yield this.constructDwnMessage({request:e}),{subscriptionHandler:i}=e;return{reply:e.store!==!1?yield this._dwn.processMessage(e.target,r,{dataStream:n,subscriptionHandler:i}):{status:{code:202,detail:"Accepted"}},message:r,messageCid:yield _e.getCid(r)}})}sendRequest(e){return Cp(this,void 0,void 0,function*(){let r=yield B_(e.target,this.agent.did);if(r.length===0)throw new Error(`AgentDwnApi: DID Service is missing or malformed: ${e.target}#dwn`);let n,i,o,s;if("messageCid"in e)({message:i,data:o}=yield this.getDwnMessage({author:e.author,messageCid:e.messageCid,messageType:e.messageType})),n=e.messageCid;else{if({message:i}=yield this.constructDwnMessage({request:e}),e.dataStream&&!(e.dataStream instanceof Blob))throw new Error("AgentDwnApi: DataStream must be provided as a Blob");o=e.dataStream,s=e.subscriptionHandler}let a=yield this.sendDwnRpcRequest({targetDid:e.target,dwnEndpointUrls:r,message:i,data:o,subscriptionHandler:s});return n??(n=yield _e.getCid(i)),{reply:a,message:i,messageCid:n}})}sendDwnRpcRequest({targetDid:e,dwnEndpointUrls:r,message:n,data:i,subscriptionHandler:o}){return Cp(this,void 0,void 0,function*(){let s=[];if(n.descriptor.method===Se.Subscribe&&o===void 0)throw new Error("AgentDwnApi: Subscription handler is required for subscription requests.");for(let a of r)try{if(o!==void 0){if(!(yield this.agent.rpc.getServerInfo(a)).webSocketSupport){s.push({url:a,message:"WebSocket support is not enabled on the server."});continue}let c=new URL(a);c.protocol=c.protocol==="http:"?"ws:":"wss:",a=c.toString()}return yield this.agent.rpc.sendDwnRequest({dwnUrl:a,targetDid:e,message:n,data:i,subscriptionHandler:o})}catch(d){s.push({url:a,message:d instanceof Error?d.message:"Unknown error"})}throw new Error(`Failed to send DWN RPC request: ${JSON.stringify(s)}`)})}constructDwnMessage({request:e}){var r;return Cp(this,void 0,void 0,function*(){if(e.granteeDid&&!this.hasGrantParams(e.messageParams))throw new Error("AgentDwnApi: Requested to sign with a permission but no grant messageParams were provided in the request");let n=e.rawMessage,i;if(dnt(e,Ie.RecordsWrite)){let a=e.messageParams;if(e.dataStream&&!a?.data){let{dataStream:d}=e,u;if(d instanceof Blob)u=Az(d),i=Az(d);else if(d instanceof ReadableStream){let[c,l]=d.tee();u=vD(c),i=vD(l)}n||(a.dataCid=yield hn.computeDagPbCidFromStream(u),(r=a.dataSize)!==null&&r!==void 0||(a.dataSize=u.bytesRead))}}let o,s=uz[e.messageType];if(n){if(o=yield s.parse(n),Rb(o)&&e.signAsOwner){let a=yield this.getSigner(e.author);yield o.signAsOwner(a)}else if(e.granteeDid&&Rb(o)&&e.signAsOwnerDelegate){let a=yield this.getSigner(e.granteeDid),d=e.messageParams;yield o.signAsOwnerDelegate(a,d.delegatedGrant)}}else{let a=e.granteeDid?yield this.getSigner(e.granteeDid):yield this.getSigner(e.author);o=yield s.create(Object.assign(Object.assign({},e.messageParams),{signer:a}))}return{message:o.message,dataStream:i}})}hasGrantParams(e){return e!==void 0&&("permissionGrantId"in e&&e.permissionGrantId!==void 0||"delegatedGrant"in e&&e.delegatedGrant!==void 0)}getSigner(e){return Cp(this,void 0,void 0,function*(){if(e===this.agent.agentDid.uri){let r=yield this.agent.agentDid.getSigner();return{algorithm:r.algorithm,keyId:r.keyId,sign:n=>Cp(this,void 0,void 0,function*(){return yield r.sign({data:n})})}}else try{let r=yield this.agent.did.getSigningMethod({didUri:e});if(!r.publicKeyJwk)throw new Error(`Verification method '${r.id}' does not contain a public key in JWK format`);let n=yield this.agent.keyManager.getKeyUri({key:r.publicKeyJwk}),i=yield this.agent.keyManager.getPublicKey({keyUri:n}),o=this.agent.keyManager;return{algorithm:dn.getJoseSignatureAlgorithmFromPublicKey(i),keyId:r.id,sign:s=>Cp(this,void 0,void 0,function*(){return yield o.sign({data:s,keyUri:n})})}}catch(r){throw new Error(`AgentDwnApi: Unable to get signer for author '${e}': ${r.message}`)}})}getDwnMessage({author:e,messageCid:r}){return Cp(this,void 0,void 0,function*(){let n=yield this.getSigner(e),i=yield uz[Ie.MessagesRead].create({messageCid:r,signer:n}),o=yield this._dwn.processMessage(e,i.message);if(o.status.code!==200)throw new Error(`AgentDwnApi: Failed to read message, response status: ${o.status.code} - ${o.status.detail}`);let s=o.entry,d={message:s.message};if(Rb(s)&&s.data){let u=yield Jo.consumeToBytes({readable:s.data});d.data=new Blob([u],{type:s.message.descriptor.dataFormat})}return d})}};f();var wD=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},y5=class t{static registerTenant(e,r){return wD(this,void 0,void 0,function*(){let n=Op(e,"registration"),i=Op(n,"terms-of-service"),o=Op(n,"proof-of-work"),s=yield fetch(i,{method:"GET"});if(s.status!==200){let v=s.status,x=s.statusText,S=yield s.text();throw new Error(`Failed fetching terms-of-service: ${v} ${x}: ${S}`)}let a=yield s.text(),d=yield fetch(o,{method:"GET"}),{challengeNonce:u,maximumAllowedHashValue:c}=yield d.json(),l={did:r,termsOfServiceHash:yield t.hashAsHexString(a)},p=yield t.findQualifiedResponseNonce({challengeNonce:u,maximumAllowedHashValue:c,requestData:JSON.stringify(l)}),g=yield fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({registrationData:l,proofOfWork:{challengeNonce:u,responseNonce:p}})});if(g.status!==200){let v=g.status,x=g.statusText,S=yield g.text();throw new Error(`Registration failed: ${v} ${x}: ${S}`)}})}static hashAsHexString(e){return wD(this,void 0,void 0,function*(){let r=yield Uf.digest({data:ae.string(e).toUint8Array()});return ae.uint8Array(r).toHex()})}static findQualifiedResponseNonce(e){return wD(this,void 0,void 0,function*(){let r=Date.now(),{maximumAllowedHashValue:n,challengeNonce:i,requestData:o}=e,s=BigInt(`0x${n}`),a=1,d,u=!1;do{d=yield this.generateNonce();let c=yield t.hashAsHexString(i+d+o);u=BigInt(`0x${c}`)<=s,a++}while(!u);return console.log(`iterations: ${a}, time lapsed: ${Date.now()-r} ms`),d})}static generateNonce(){return wD(this,void 0,void 0,function*(){let e=dn.randomBytes(32);return ae.uint8Array(e).toHex().toUpperCase()})}};f();f();f();var unt=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),h1e=Uint8Array.from({length:16},(t,e)=>e),lnt=h1e.map(t=>(9*t+5)%16),Pz=[h1e],Iz=[lnt];for(let t=0;t<4;t++)for(let e of[Pz,Iz])e.push(e[t].map(r=>unt[r]));var p1e=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(t=>new Uint8Array(t)),fnt=Pz.map((t,e)=>t.map(r=>p1e[e][r])),hnt=Iz.map((t,e)=>t.map(r=>p1e[e][r])),pnt=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),mnt=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]),_D=(t,e)=>t<>>32-e;function f1e(t,e,r,n){return t===0?e^r^n:t===1?e&r|~e&n:t===2?(e|~r)^n:t===3?e&n|r&~n:e^(r|~n)}var xD=new Uint32Array(16),Tz=class extends $y{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){let{h0:e,h1:r,h2:n,h3:i,h4:o}=this;return[e,r,n,i,o]}set(e,r,n,i,o){this.h0=e|0,this.h1=r|0,this.h2=n|0,this.h3=i|0,this.h4=o|0}process(e,r){for(let m=0;m<16;m++,r+=4)xD[m]=e.getUint32(r,!0);let n=this.h0|0,i=n,o=this.h1|0,s=o,a=this.h2|0,d=a,u=this.h3|0,c=u,l=this.h4|0,p=l;for(let m=0;m<5;m++){let g=4-m,v=pnt[m],x=mnt[m],S=Pz[m],P=Iz[m],A=fnt[m],$=hnt[m];for(let j=0;j<16;j++){let q=_D(n+f1e(m,o,a,u)+xD[S[j]]+v,A[j])+l|0;n=l,l=u,u=_D(a,10)|0,a=o,o=q}for(let j=0;j<16;j++){let q=_D(i+f1e(g,s,d,c)+xD[P[j]]+x,$[j])+p|0;i=p,p=c,c=_D(d,10)|0,d=s,s=q}}this.set(this.h1+a+c|0,this.h2+u+p|0,this.h3+l+i|0,this.h4+n+s|0,this.h0+o+d|0)}roundClean(){xD.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}},m1e=q2(()=>new Tz);var ynt=o3("ed25519 seed"),kz=2147483648,y1e=new Uint8Array([0]);function g1e(t,...e){return typeof t=="string"&&(t=G0e(t)),dp(t,...e),t}var gnt=t=>m1e(Uy(t)),vnt=t=>lp(t).getUint32(0,!1),Rz=t=>{if(!Number.isSafeInteger(t)||t<0||t>2**32-1)throw new Error(`Invalid number=${t}. Should be from 0 to 2 ** 32 - 1`);let e=new Uint8Array(4);return lp(e).setUint32(0,t,!1),e},ED=class t{get publicKeyRaw(){return go.getPublicKey(this.privateKey)}get publicKey(){return Qv(y1e,this.publicKeyRaw)}get pubHash(){return gnt(this.publicKey)}get fingerprint(){return vnt(this.pubHash)}get fingerprintHex(){return VK(Rz(this.fingerprint))}get parentFingerprintHex(){return VK(Rz(this.parentFingerprint))}static fromMasterSeed(e){if(e=g1e(e),8*e.length<128||8*e.length>512)throw new Error(`HDKey: wrong seed length=${e.length}. Should be between 128 and 512 bits; 256 bits is advised)`);let r=qy(Fy,ynt,e);return new t({privateKey:r.slice(0,32),chainCode:r.slice(32)})}constructor(e){if(this.depth=0,this.index=0,this.parentFingerprint=0,!e||typeof e!="object")throw new Error("HDKey.constructor must not be called directly");if(dp(e.privateKey,32),dp(e.chainCode,32),this.depth=e.depth||0,this.index=e.index||0,this.parentFingerprint=e.parentFingerprint||0,!this.depth&&(this.parentFingerprint||this.index))throw new Error("HDKey: zero depth with non-zero index/parent fingerprint");this.chainCode=e.chainCode,this.privateKey=e.privateKey}derive(e,r=!1){if(!/^[mM]'?/.test(e))throw new Error('Path must start with "m" or "M"');if(/^[mM]'?$/.test(e))return this;let n=e.replace(/^[mM]'?\//,"").split("/"),i=this;for(let o of n){let s=/^(\d+)('?)$/.exec(o);if(!s||s.length!==3)throw new Error(`Invalid child index: ${o}`);let a=+s[1];if(!Number.isSafeInteger(a)||a>=kz)throw new Error("Invalid index");(r||s[2]==="'")&&(a+=kz),i=i.deriveChild(a)}return i}deriveChild(e){if(e= 1");let d=My(e),u=My(r),c=new Uint8Array(s),l=Ny.create(t,d),p=l._cloneInto().update(u);return{c:o,dkLen:s,asyncTick:a,DK:c,PRF:l,PRFSalt:p}}function vnt(t,e,r,n,i){return t.destroy(),e.destroy(),n&&n.destroy(),i.fill(0),r}async function l1e(t,e,r,n){let{c:i,dkLen:o,asyncTick:s,DK:a,PRF:d,PRFSalt:u}=gnt(t,e,r,n),c,l=new Uint8Array(4),p=up(l),m=new Uint8Array(d.outputLen);for(let g=1,v=0;v{d._cloneInto(c).update(m).digestInto(m);for(let S=0;So,r=(o,s)=>a=>o(s(a)),n=t.map(o=>o.encode).reduceRight(r,e),i=t.map(o=>o.decode).reduce(r,e);return{encode:n,decode:i}}function wnt(t){return{encode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="number")throw new Error("alphabet.encode input should be an array of numbers");return e.map(r=>{if(r<0||r>=t.length)throw new Error(`Digit index outside alphabet: ${r} (alphabet: ${t.length})`);return t[r]})},decode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="string")throw new Error("alphabet.decode input should be array of strings");return e.map(r=>{if(typeof r!="string")throw new Error(`alphabet.decode: not string element=${r}`);let n=t.indexOf(r);if(n===-1)throw new Error(`Unknown letter: "${r}". Allowed: ${t}`);return n})}}}function _nt(t=""){if(typeof t!="string")throw new Error("join separator should be string");return{encode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="string")throw new Error("join.encode input should be array of strings");for(let r of e)if(typeof r!="string")throw new Error(`join.encode: non-string input=${r}`);return e.join(t)},decode:e=>{if(typeof e!="string")throw new Error("join.decode input should be string");return e.split(t)}}}function xnt(t,e="="){if(typeof e!="string")throw new Error("padding chr should be string");return{encode(r){if(!Array.isArray(r)||r.length&&typeof r[0]!="string")throw new Error("padding.encode input should be array of strings");for(let n of r)if(typeof n!="string")throw new Error(`padding.encode: non-string input=${n}`);for(;r.length*t%8;)r.push(e);return r},decode(r){if(!Array.isArray(r)||r.length&&typeof r[0]!="string")throw new Error("padding.encode input should be array of strings");for(let i of r)if(typeof i!="string")throw new Error(`padding.decode: non-string input=${i}`);let n=r.length;if(n*t%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;n>0&&r[n-1]===e;n--)if(!((n-1)*t%8))throw new Error("Invalid padding: string has too much padding");return r.slice(0,n)}}}function Tz(t,e,r){if(e<2)throw new Error(`convertRadix: wrong from=${e}, base cannot be less than 2`);if(r<2)throw new Error(`convertRadix: wrong to=${r}, base cannot be less than 2`);if(!Array.isArray(t))throw new Error("convertRadix: data should be array");if(!t.length)return[];let n=0,i=[],o=Array.from(t);for(o.forEach(s=>{if(s<0||s>=e)throw new Error(`Wrong integer: ${s}`)});;){let s=0,a=!0;for(let d=n;de?f1e(e,t%e):t,wD=(t,e)=>t+(e-f1e(t,e));function Pz(t,e,r,n){if(!Array.isArray(t))throw new Error("convertRadix2: data should be array");if(e<=0||e>32)throw new Error(`convertRadix2: wrong from=${e}`);if(r<=0||r>32)throw new Error(`convertRadix2: wrong to=${r}`);if(wD(e,r)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${r} carryBits=${wD(e,r)}`);let i=0,o=0,s=2**r-1,a=[];for(let d of t){if(d>=2**e)throw new Error(`convertRadix2: invalid data word=${d} from=${e}`);if(i=i<32)throw new Error(`convertRadix2: carry overflow pos=${o} from=${e}`);for(o+=e;o>=r;o-=r)a.push((i>>o-r&s)>>>0);i&=2**o-1}if(i=i<=e)throw new Error("Excess padding");if(!n&&i)throw new Error(`Non-zero padding: ${i}`);return n&&o>0&&a.push(i>>>0),a}function Ent(t){return{encode:e=>{if(!bD(e))throw new Error("radix.encode input should be Uint8Array");return Tz(Array.from(e),2**8,t)},decode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="number")throw new Error("radix.decode input should be array of numbers");return Uint8Array.from(Tz(e,t,2**8))}}}function Snt(t,e=!1){if(t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(wD(8,t)>32||wD(t,8)>32)throw new Error("radix2: carry overflow");return{encode:r=>{if(!bD(r))throw new Error("radix2.encode input should be Uint8Array");return Pz(Array.from(r),8,t,!e)},decode:r=>{if(!Array.isArray(r)||r.length&&typeof r[0]!="number")throw new Error("radix2.decode input should be array of numbers");return Uint8Array.from(Pz(r,t,8,e))}}}function Ant(t,e){if(typeof e!="function")throw new Error("checksum fn should be function");return{encode(r){if(!bD(r))throw new Error("checksum.encode: input should be Uint8Array");let n=e(r).slice(0,t),i=new Uint8Array(r.length+t);return i.set(r),i.set(n,r.length),i},decode(r){if(!bD(r))throw new Error("checksum.decode: input should be Uint8Array");let n=r.slice(0,-t),i=e(n).slice(0,t),o=r.slice(-t);for(let s=0;st[0]==="\u3042\u3044\u3053\u304F\u3057\u3093";function h1e(t){if(typeof t!="string")throw new TypeError(`Invalid mnemonic type: ${typeof t}`);return t.normalize("NFKD")}function p1e(t){let e=h1e(t),r=e.split(" ");if(![12,15,18,21,24].includes(r.length))throw new Error("Invalid mnemonic");return{nfkd:e,words:r}}function m1e(t){cp(t,16,20,24,28,32)}function y1e(t,e=128){if(By(e),e%32!==0||e>256)throw new TypeError("Invalid entropy");return knt(Qv(e/8),t)}var Pnt=t=>{let e=8-t.length/4;return new Uint8Array([jy(t)[0]>>e<{if(typeof e!="string")throw new Error(`Wordlist: non-string element: ${e}`)}),f5.chain(f5.checksum(1,Pnt),f5.radix2(11,!0),f5.alphabet(t))}function Int(t,e){let{words:r}=p1e(t),n=g1e(e).decode(r);return m1e(n),n}function knt(t,e){return m1e(t),g1e(e).encode(t).join(Tnt(e)?"\u3000":" ")}function v1e(t,e){try{Int(t,e)}catch{return!1}return!0}var Rnt=t=>h1e(`mnemonic${t}`);function b1e(t,e=""){return l1e(Ly,p1e(t).nfkd,Rnt(e),{c:2048,dkLen:64})}f();f();var Op=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},h5=class extends h0{constructor(){super(...arguments),this.name="DwnKeyStore",this._recordProtocolDefinition=Ywe,this._recordProperties={dataFormat:"application/json",protocol:this._recordProtocolDefinition.protocol,protocolPath:"privateJwk",schema:this._recordProtocolDefinition.types.privateJwk.schema}}delete(e){let r=Object.create(null,{delete:{get:()=>super.delete}});return Op(this,void 0,void 0,function*(){return yield r.delete.call(this,e)})}get(e){let r=Object.create(null,{get:{get:()=>super.get}});return Op(this,void 0,void 0,function*(){return yield r.get.call(this,e)})}set(e){let r=Object.create(null,{set:{get:()=>super.set}});return Op(this,void 0,void 0,function*(){yield r.set.call(this,e)})}list(e){let r=Object.create(null,{list:{get:()=>super.list}});return Op(this,void 0,void 0,function*(){return yield r.list.call(this,e)})}getAllRecords({agent:e,tenantDid:r}){var n;return Op(this,void 0,void 0,function*(){this._index.clear();let{reply:i}=yield e.dwn.processRequest({author:r,target:r,messageType:Ie.RecordsQuery,messageParams:{filter:Object.assign({},this._recordProperties)}}),o=[];for(let s of(n=i.entries)!==null&&n!==void 0?n:[]){if(!s.encodedData)throw new Error(`${this.name}: Expected 'encodedData' to be present in the DWN query result entry`);let a=ae.base64Url(s.encodedData).toObject();if(A_(a)){let d=`${r}${Cs}${Sb}${a.kid}`;this._index.set(d,s.recordId),this._cache.set(s.recordId,a),o.push(a)}}return o})}},p5=class extends p0{constructor(){super(...arguments),this.name="InMemoryKeyStore"}delete(e){let r=Object.create(null,{delete:{get:()=>super.delete}});return Op(this,void 0,void 0,function*(){return yield r.delete.call(this,e)})}get(e){let r=Object.create(null,{get:{get:()=>super.get}});return Op(this,void 0,void 0,function*(){return yield r.get.call(this,e)})}list(e){let r=Object.create(null,{list:{get:()=>super.list}});return Op(this,void 0,void 0,function*(){return yield r.list.call(this,e)})}set(e){let r=Object.create(null,{set:{get:()=>super.set}});return Op(this,void 0,void 0,function*(){return yield r.set.call(this,e)})}};var hd=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},w1e=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);ie)})}isLocked(){return!this._contentEncryptionKey}lock(){return lu(this,void 0,void 0,function*(){if((yield this.isInitialized())===!1)throw new Error("HdIdentityVault: Lock operation failed. Vault has not been initialized.");this._contentEncryptionKey&&(this._contentEncryptionKey.k=""),this._contentEncryptionKey=void 0})}restore({backup:e,password:r}){return lu(this,void 0,void 0,function*(){if(!Dnt(e))throw new Error("HdIdentityVault: Restore operation failed due to invalid backup object.");let n,i,o;try{o=yield this.getStoredDid(),i=yield this.getStoredContentEncryptionKey(),n=yield this.getStatus()}catch{throw new Error("HdIdentityVault: The restore operation cannot proceed because the existing vault contents are missing or inaccessible. If the problem persists consider re-initializing the vault and retrying the restore.")}try{let s=ae.base64Url(e.data).toObject();yield this._store.set("did",s.did),yield this._store.set("contentEncryptionKey",s.contentEncryptionKey),yield this.setStatus(s.status),yield this.unlock({password:r})}catch{throw yield this.setStatus(n),yield this._store.set("contentEncryptionKey",i),yield this._store.set("did",o),new Error("HdIdentityVault: Restore operation failed due to invalid backup data or an incorrect password. Please verify the password is correct for the provided backup and try again.")}yield this.setStatus({lastRestore:new Date().toISOString()})})}unlock({password:e}){return lu(this,void 0,void 0,function*(){yield this.lock();let r=yield this.getStoredContentEncryptionKey();try{let{plaintext:n}=yield Cp.decrypt({jwe:r,key:ae.string(e).toUint8Array(),crypto:this.crypto,keyManager:new uu}),i=ae.uint8Array(n).toObject();this._contentEncryptionKey=i}catch{throw new Error("HdIdentityVault: Unable to unlock the vault due to an incorrect password.")}})}getStoredDid(){return lu(this,void 0,void 0,function*(){let e=yield this._store.get("did");if(!e)throw new Error("HdIdentityVault: Unable to retrieve the DID record from the vault. Please check the vault status and if the problem persists consider re-initializing the vault and restoring the contents from a previous backup.");return e})}getStoredContentEncryptionKey(){return lu(this,void 0,void 0,function*(){let e=yield this._store.get("contentEncryptionKey");if(!e)throw new Error("HdIdentityVault: Unable to retrieve the Content Encryption Key record from the vault. Please check the vault status and if the problem persists consider re-initializing the vault and restoring the contents from a previous backup.");return e})}setStatus({initialized:e,lastBackup:r,lastRestore:n}){return lu(this,void 0,void 0,function*(){let i=yield this.getStatus();return i.initialized=e??i.initialized,i.lastBackup=r??i.lastBackup,i.lastRestore=n??i.lastRestore,yield this._store.set("vaultStatus",JSON.stringify(i)),!0})}};f();f();var $p=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})};function Mnt(t){return!(!t||typeof t!="object"||t===null)&&"name"in t}var w5=class extends h0{constructor(){super(...arguments),this.name="DwnIdentityStore",this._recordProtocolDefinition=cD,this._recordProperties={dataFormat:"application/json",protocol:this._recordProtocolDefinition.protocol,protocolPath:"identityMetadata",schema:this._recordProtocolDefinition.types.identityMetadata.schema}}delete(e){let r=Object.create(null,{delete:{get:()=>super.delete}});return $p(this,void 0,void 0,function*(){return yield r.delete.call(this,e)})}get(e){let r=Object.create(null,{get:{get:()=>super.get}});return $p(this,void 0,void 0,function*(){return yield r.get.call(this,e)})}set(e){let r=Object.create(null,{set:{get:()=>super.set}});return $p(this,void 0,void 0,function*(){return yield r.set.call(this,e)})}list(e){let r=Object.create(null,{list:{get:()=>super.list}});return $p(this,void 0,void 0,function*(){return yield r.list.call(this,e)})}getAllRecords({agent:e,tenantDid:r}){var n;return $p(this,void 0,void 0,function*(){this._index.clear();let{reply:i}=yield e.dwn.processRequest({author:r,target:r,messageType:Ie.RecordsQuery,messageParams:{filter:Object.assign({},this._recordProperties)}}),o=[];for(let s of(n=i.entries)!==null&&n!==void 0?n:[]){if(!s.encodedData)throw new Error(`${this.name}: Expected 'encodedData' to be present in the DWN query result entry`);let a=ae.base64Url(s.encodedData).toObject();if(Mnt(a)){let d=`${r}${Cs}${a.uri}`;this._index.set(d,s.recordId),this._cache.set(s.recordId,a),o.push(a)}}return o})}},_5=class extends p0{constructor(){super(...arguments),this.name="InMemoryIdentityStore"}delete(e){let r=Object.create(null,{delete:{get:()=>super.delete}});return $p(this,void 0,void 0,function*(){return yield r.delete.call(this,e)})}get(e){let r=Object.create(null,{get:{get:()=>super.get}});return $p(this,void 0,void 0,function*(){return yield r.get.call(this,e)})}list(e){let r=Object.create(null,{list:{get:()=>super.list}});return $p(this,void 0,void 0,function*(){return yield r.list.call(this,e)})}set(e){let r=Object.create(null,{set:{get:()=>super.set}});return $p(this,void 0,void 0,function*(){return yield r.set.call(this,e)})}};var jp=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})};var x5=class{constructor({agent:e,store:r}={}){this._agent=e,this._store=r??new _5}get agent(){if(this._agent===void 0)throw new Error("AgentIdentityApi: Unable to determine agent execution context.");return this._agent}set agent(e){this._agent=e}create({metadata:e,didMethod:r="dht",didOptions:n,store:i,tenant:o}){return jp(this,void 0,void 0,function*(){let s=yield this.agent.did.create({method:r,options:n,store:i,tenant:o}),a=new Ib({did:s,metadata:Object.assign(Object.assign({},e),{uri:s.uri,tenant:o??s.uri})});return(i??!0)&&(yield this._store.set({id:a.did.uri,data:a.metadata,agent:this.agent,tenant:a.metadata.tenant,preventDuplicates:!1,useCache:!0})),a})}export({didUri:e,tenant:r}){return jp(this,void 0,void 0,function*(){let n=yield this.get({didUri:e,tenant:r});if(!n)throw new Error(`AgentIdentityApi: Failed to export due to Identity not found: ${e}`);return yield n.export()})}get({didUri:e,tenant:r}){return jp(this,void 0,void 0,function*(){let n=yield this._store.get({id:e,agent:this.agent,tenant:r,useCache:!0});if(!n)return;let i=yield this.agent.did.get({didUri:e,tenant:n.tenant});if(!i)throw new Error(`AgentIdentityApi: Identity is present in the store but DID is missing: ${e}`);return new Ib({did:i,metadata:n})})}import({portableIdentity:e}){return jp(this,void 0,void 0,function*(){let r=yield this.agent.did.import({portableDid:e.portableDid,tenant:e.metadata.tenant});if(!r)throw new Error(`AgentIdentityApi: Failed to import Identity: ${e.metadata.uri}`);let n=new Ib({did:r,metadata:e.metadata});return yield this._store.set({id:n.did.uri,data:n.metadata,agent:this.agent,tenant:n.metadata.tenant,preventDuplicates:!0,useCache:!0}),n})}list({tenant:e}={}){return jp(this,void 0,void 0,function*(){let r=yield this._store.list({agent:this.agent,tenant:e});return(yield Promise.all(r.map(i=>jp(this,void 0,void 0,function*(){return this.get({didUri:i.uri,tenant:i.tenant})})))).filter(i=>typeof i<"u")})}manage({portableIdentity:e}){return jp(this,void 0,void 0,function*(){let r=yield this.agent.did.get({didUri:e.metadata.uri,tenant:e.metadata.tenant});if(!r)throw new Error(`AgentIdentityApi: Failed to manage Identity: ${e.metadata.uri}`);let n=new Ib({did:r,metadata:e.metadata});return yield this._store.set({id:n.did.uri,data:n.metadata,agent:this.agent,preventDuplicates:!0,useCache:!0}),n})}delete({didUri:e,tenant:r}){return jp(this,void 0,void 0,function*(){if(!(yield this._store.get({id:e,agent:this.agent,tenant:r,useCache:!0})))throw new Error(`AgentIdentityApi: Failed to purge due to Identity not found: ${e}`);yield this._store.delete({id:e,agent:this.agent,tenant:r})})}connectedIdentity({connectedDid:e}={}){return jp(this,void 0,void 0,function*(){let r=yield this.list();if(!(r.length<1))return e?r.find(n=>n.metadata.connectedDid===e):r.find(n=>n.metadata.connectedDid!==void 0)})}};f();var Np=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},A1e=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i({jsonrpc:"2.0",id:t,method:e,params:r}),_D=(t,e,r,n)=>({jsonrpc:"2.0",id:t,method:`rpc.subscribe.${e}`,params:n,subscription:{id:r}});function B_(t){try{return JSON.parse(t)}catch{return null}}f();f();var P1e=gt(db(),1);var E5=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},xD=class{constructor({ttl:e="15m"}={}){this.cache=new jf.default({ttl:(0,P1e.default)(e)})}get(e){return E5(this,void 0,void 0,function*(){return this.cache.get(e)})}set(e,r){return E5(this,void 0,void 0,function*(){this.cache.set(e,r)})}delete(e){return E5(this,void 0,void 0,function*(){this.cache.delete(e)})}clear(){return E5(this,void 0,void 0,function*(){this.cache.clear()})}close(){return E5(this,void 0,void 0,function*(){})}};var I1e=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},ED=class{constructor(e){this.serverInfoCache=e??new xD}get transportProtocols(){return["http:","https:"]}sendDwnRequest(e){return I1e(this,void 0,void 0,function*(){let r=Mn.randomUuid(),n=D_(r,"dwn.processMessage",{target:e.targetDid,message:e.message}),i={method:"POST",headers:{"dwn-request":JSON.stringify(n)}};e.data&&(i.headers["content-type"]="application/octet-stream",i.body=e.data);let o=yield fetch(e.dwnUrl,i),s,a,{headers:d}=o;if(d.has("dwn-response")){let c=B_(d.get("dwn-response"));if(c==null)throw new Error(`failed to parse json rpc response. dwn url: ${e.dwnUrl}`);a=o.body,s=c}else{let c=yield o.text();s=JSON.parse(c)}if(s.error){let{code:c,message:l}=s.error;throw new Error(`(${c}) - ${l}`)}let{reply:u}=s.result;return a&&u.record?u.record.data=a:a&&u.entry&&(u.entry.data=a),u})}getServerInfo(e){return I1e(this,void 0,void 0,function*(){let r=yield this.serverInfoCache.get(e);if(r)return r;let n=new URL(e);n.pathname.endsWith("/")?n.pathname+="info":n.pathname+="/info";try{let i=yield fetch(n.toString());if(i.ok){let o=yield i.json(),s={registrationRequirements:o.registrationRequirements,maxFileSize:o.maxFileSize,webSocketSupport:o.webSocketSupport};return this.serverInfoCache.set(e,s),s}else throw new Error(`HTTP (${i.status}) - ${i.statusText}`)}catch(i){throw new Error(`Error encountered while processing response from ${n.toString()}: ${i.message}`)}})}};f();f();f();var M_=null;typeof WebSocket<"u"?M_=WebSocket:typeof MozWebSocket<"u"?M_=MozWebSocket:typeof globalThis<"u"?M_=globalThis.WebSocket||globalThis.MozWebSocket:typeof window<"u"?M_=window.WebSocket||window.MozWebSocket:typeof self<"u"&&(M_=self.WebSocket||self.MozWebSocket);var k1e=M_;var SD=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Ont=3e3,Cnt=3e4,AD=class t{constructor(e,r){this.socket=e,this.responseTimeout=r,this.messageHandlers=new Map}static connect(e,r={}){return SD(this,void 0,void 0,function*(){let{connectTimeout:n=Ont,responseTimeout:i=Cnt,onclose:o,onerror:s}=r,a=new k1e(e);return o?a.onclose=o:a.onclose=()=>{console.info(`JSON RPC Socket close ${e}`)},s?a.onerror=s:a.onerror=d=>{console.error(`JSON RPC Socket error ${e}`,d)},new Promise((d,u)=>{a.addEventListener("open",()=>{let c=new t(a,i);a.addEventListener("message",l=>{let p=B_(l.data),m=c.messageHandlers.get(p.id);m&&m(l)}),d(c)}),a.addEventListener("error",c=>{u(c)}),setTimeout(()=>u,n)})})}close(){this.socket.close()}request(e){return SD(this,void 0,void 0,function*(){return new Promise((r,n)=>{var i;(i=e.id)!==null&&i!==void 0||(e.id=Mn.randomUuid());let o=s=>{let a=B_(s.data);if(a.id===e.id)return this.messageHandlers.delete(e.id),r(a)};this.messageHandlers.set(e.id,o),this.send(e),setTimeout(()=>{this.messageHandlers.delete(e.id),n(new Error("request timed out"))},this.responseTimeout)})})}subscribe(e,r){return SD(this,void 0,void 0,function*(){if(!e.method.startsWith("rpc.subscribe."))throw new Error("subscribe rpc requests must include the `rpc.subscribe` prefix");if(!e.subscription)throw new Error("subscribe rpc requests must include subscribe options");let n=e.subscription.id,i=a=>{let d=B_(a.data.toString());d.id===n&&(d.error!==void 0&&(this.messageHandlers.delete(n),this.closeSubscription(n)),r(d))};this.messageHandlers.set(n,i);let o=yield this.request(e);return o.error?(this.messageHandlers.delete(n),{response:o}):{response:o,close:()=>SD(this,void 0,void 0,function*(){this.messageHandlers.delete(n),yield this.closeSubscription(n)})}})}closeSubscription(e){let r=Mn.randomUuid(),n=_D(r,"close",e,{});return this.request(n)}send(e){this.socket.send(JSON.stringify(e))}};var Dz=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},S5=class t{get transportProtocols(){return["ws:","wss:"]}sendDwnRequest(e,r){return Dz(this,void 0,void 0,function*(){let n=new URL(e.dwnUrl);if(n.protocol!=="ws:"&&n.protocol!=="wss:")throw new Error(`Invalid websocket protocol ${n.protocol}`);if(!t.connections.has(n.host))try{let u=yield AD.connect(n.toString(),r),c=new Map;t.connections.set(n.host,{socket:u,subscriptions:c})}catch(u){throw new Error(`Error connecting to ${n.host}: ${u.message}`)}let o=t.connections.get(n.host),{targetDid:s,message:a,subscriptionHandler:d}=e;return d?t.subscriptionRequest(o,s,a,d):t.processMessage(o,s,a)})}static processMessage(e,r,n){return Dz(this,void 0,void 0,function*(){let i=Mn.randomUuid(),o=D_(i,"dwn.processMessage",{target:r,message:n}),{socket:s}=e,a=yield s.request(o),{error:d,result:u}=a;if(d!==void 0)throw new Error(`error sending DWN request: ${d.message}`);return u.reply})}static subscriptionRequest(e,r,n,i){return Dz(this,void 0,void 0,function*(){let o=Mn.randomUuid(),s=Mn.randomUuid(),a=_D(o,"dwn.processMessage",s,{target:r,message:n}),{socket:d,subscriptions:u}=e,{response:c,close:l}=yield d.subscribe(a,v=>{let{result:x,error:S}=v;if(S){let A=u.get(s);A&&A.close(),u.delete(s);return}let{event:P}=x;i(P)}),{error:p,result:m}=c;if(p)throw new Error(`could not subscribe via jsonrpc socket: ${p.message}`);let{reply:g}=m;return g.subscription&&l&&(u.set(s,Object.assign(Object.assign({},g.subscription),{close:l})),g.subscription.close=l),g})}};S5.connections=new Map;var A5=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},R1e;(function(t){t.Create="did.create",t.Resolve="did.resolve"})(R1e||(R1e={}));var T5=class{constructor(e=[]){this.transportClients=new Map,e=[new Bz,new Mz,...e];for(let r of e)for(let n of r.transportProtocols)this.transportClients.set(n,r)}get transportProtocols(){return Array.from(this.transportClients.keys())}sendDidRequest(e){return A5(this,void 0,void 0,function*(){let r=new URL(e.url),n=this.transportClients.get(r.protocol);if(!n){let i=new Error(`no ${r.protocol} transport client available`);throw i.name="NO_TRANSPORT_CLIENT",i}return n.sendDidRequest(e)})}sendDwnRequest(e){let r=new URL(e.dwnUrl),n=this.transportClients.get(r.protocol);if(!n){let i=new Error(`no ${r.protocol} transport client available`);throw i.name="NO_TRANSPORT_CLIENT",i}return n.sendDwnRequest(e)}getServerInfo(e){return A5(this,void 0,void 0,function*(){let r=new URL(e),n=this.transportClients.get(r.protocol);if(!n){let i=new Error(`no ${r.protocol} transport client available`);throw i.name="NO_TRANSPORT_CLIENT",i}return n.getServerInfo(e)})}},Bz=class extends ED{sendDidRequest(e){return A5(this,void 0,void 0,function*(){let r=Mn.randomUuid(),n=D_(r,e.method,{data:e.data}),i=new Request(e.url,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}),o;try{let s=yield fetch(i);if(s.ok){if(o=yield s.json(),o.error){let{code:a,message:d}=o.error;throw new Error(`JSON RPC (${a}) - ${d}`)}}else throw new Error(`HTTP (${s.status}) - ${s.statusText}`)}catch(s){throw new Error(`Error encountered while processing response from ${e.url}: ${s.message}`)}return o.result})}},Mz=class extends S5{sendDidRequest(e){return A5(this,void 0,void 0,function*(){throw new Error(`not implemented for transports [${this.transportProtocols.join(", ")}]`)})}getServerInfo(e){return A5(this,void 0,void 0,function*(){throw new Error(`not implemented for transports [${this.transportProtocols.join(", ")}]`)})}};f();var TD=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},P5=class{constructor({agent:e,syncEngine:r}){this._syncEngine=r,this._agent=e}get agent(){if(this._agent===void 0)throw new Error("AgentSyncApi: Unable to determine agent execution context.");return this._agent}set agent(e){this._agent=e,this._syncEngine.agent=e}registerIdentity(e){return TD(this,void 0,void 0,function*(){yield this._syncEngine.registerIdentity(e)})}unregisterIdentity(e){return TD(this,void 0,void 0,function*(){yield this._syncEngine.unregisterIdentity(e)})}getIdentityOptions(e){return TD(this,void 0,void 0,function*(){return yield this._syncEngine.getIdentityOptions(e)})}updateIdentityOptions(e){return TD(this,void 0,void 0,function*(){yield this._syncEngine.updateIdentityOptions(e)})}sync(e){return this._syncEngine.sync(e)}startSync(e){return this._syncEngine.startSync(e)}stopSync(e){return this._syncEngine.stopSync(e)}};f();var D1e=gt(db(),1),B1e=gt(p3(),1);var eo=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},$nt=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,d){s=t[o](s),i(a,d,s.done,s.value)})}}function i(o,s,a,d){Promise.resolve(d).then(function(u){o({value:u,done:a})},s)}},I5=class t{constructor({agent:e,dataPath:r,db:n}){this._syncLock=!1,this._agent=e,this._permissionsApi=new Qi({agent:e}),this._db=n||new B1e.Level(r??"DATA/AGENT/SYNC_STORE"),this._ulidFactory=LR()}get agent(){if(this._agent===void 0)throw new Error("SyncEngineLevel: Unable to determine agent execution context.");return this._agent}set agent(e){this._agent=e,this._permissionsApi=new Qi({agent:e})}clear(){return eo(this,void 0,void 0,function*(){yield this._permissionsApi.clear(),yield this._db.clear()})}close(){return eo(this,void 0,void 0,function*(){yield this._db.close()})}pull(){var e;return eo(this,void 0,void 0,function*(){let r=yield this.getSyncPeerState({syncDirection:"pull"});yield this.enqueueOperations({syncDirection:"pull",syncPeerState:r});let n=this.getPullQueue(),i=yield n.iterator().all(),o=[],s=new Set;for(let a of i){let[d]=a,{did:u,dwnUrl:c,messageCid:l,delegateDid:p,protocol:m}=t.parseSyncMessageParamsKey(d);if(s.has(c))continue;if(yield this.messageExists(u,l)){o.push({type:"del",key:d});continue}let v,x;if(p)try{v=(yield this._permissionsApi.getPermissionForRequest({connectedDid:u,messageType:Ie.MessagesRead,delegateDid:p,protocol:m,cached:!0})).grant.id,x=p}catch(F){console.error("SyncEngineLevel: pull - Error fetching MessagesRead permission grant for delegate DID",F);continue}let S=yield this.agent.processDwnRequest({store:!1,author:u,target:u,messageType:Ie.MessagesRead,granteeDid:x,messageParams:{messageCid:l,permissionGrantId:v}}),P;try{P=yield this.agent.rpc.sendDwnRequest({dwnUrl:c,targetDid:u,message:S.message})}catch{s.add(c);continue}if(P.status.code!==200||!(!((e=P.entry)===null||e===void 0)&&e.message)){yield this.addMessage(u,l),o.push({type:"del",key:d});continue}let A=P.entry,$=A.message,j=Rb(A)&&A.data?Jo.fromWebReadable({readableStream:A.data}):void 0,L=yield this.agent.dwn.node.processMessage(u,$,{dataStream:j});t.syncMessageReplyIsSuccessful(L)&&(yield this.addMessage(u,l),o.push({type:"del",key:d}))}yield n.batch(o)})}push(){return eo(this,void 0,void 0,function*(){let e=yield this.getSyncPeerState({syncDirection:"push"});yield this.enqueueOperations({syncDirection:"push",syncPeerState:e});let r=this.getPushQueue(),n=yield r.iterator().all(),i=[],o=new Set;for(let s of n){let[a]=s,{did:d,delegateDid:u,protocol:c,dwnUrl:l,messageCid:p}=t.parseSyncMessageParamsKey(a);if(o.has(l))continue;let m=yield this.getDwnMessage({author:d,messageCid:p,delegateDid:u,protocol:c});if(!m){i.push({type:"del",key:a}),yield this.addMessage(d,p);continue}try{let g=yield this.agent.rpc.sendDwnRequest({dwnUrl:l,targetDid:d,data:m.data,message:m.message});t.syncMessageReplyIsSuccessful(g)&&(yield this.addMessage(d,p),i.push({type:"del",key:a}))}catch{o.add(l)}}yield r.batch(i)})}registerIdentity({did:e,options:r}){return eo(this,void 0,void 0,function*(){let n=this._db.sublevel("registeredIdentities");if(yield this.getIdentityOptions(e))throw new Error(`SyncEngineLevel: Identity with DID ${e} is already registered.`);r??(r={protocols:[]}),yield n.put(e,JSON.stringify(r))})}unregisterIdentity(e){return eo(this,void 0,void 0,function*(){let r=this._db.sublevel("registeredIdentities");if(!(yield this.getIdentityOptions(e)))throw new Error(`SyncEngineLevel: Identity with DID ${e} is not registered.`);yield r.del(e)})}getIdentityOptions(e){return eo(this,void 0,void 0,function*(){let r=this._db.sublevel("registeredIdentities");try{let n=yield r.get(e);if(n)return JSON.parse(n)}catch(n){let i=n;if(i.code==="LEVEL_NOT_FOUND")return;throw new Error(`SyncEngineLevel: Error reading level: ${i.code}.`)}})}updateIdentityOptions({did:e,options:r}){return eo(this,void 0,void 0,function*(){let n=this._db.sublevel("registeredIdentities");if(!(yield this.getIdentityOptions(e)))throw new Error(`SyncEngineLevel: Identity with DID ${e} is not registered.`);yield n.put(e,JSON.stringify(r))})}sync(e){return eo(this,void 0,void 0,function*(){if(this._syncLock)throw new Error("SyncEngineLevel: Sync operation is already in progress.");this._syncLock=!0;try{(!e||e==="push")&&(yield this.push()),(!e||e==="pull")&&(yield this.pull())}finally{this._syncLock=!1}})}startSync({interval:e}){return eo(this,void 0,void 0,function*(){let r=(0,D1e.default)(e),n=()=>eo(this,void 0,void 0,function*(){this._syncLock||(clearInterval(this._syncIntervalId),this._syncIntervalId=void 0,yield this.sync(),this._syncIntervalId||(this._syncIntervalId=setInterval(n,r)))});this._syncIntervalId&&clearInterval(this._syncIntervalId),this._syncIntervalId=setInterval(n,r),this._syncLock||(yield this.sync())})}stopSync(e=2e3){return eo(this,void 0,void 0,function*(){let r=0;for(;this._syncLock;){if(r>=e)throw new Error(`SyncEngineLevel: Existing sync operation did not complete within ${e} milliseconds.`);r+=100,yield new Promise(n=>setTimeout(n,e<100?e:100))}this._syncIntervalId&&(clearInterval(this._syncIntervalId),this._syncIntervalId=void 0)})}static syncMessageReplyIsSuccessful(e){var r,n;return e.status.code===202||e.status.code===204||e.status.code===409||((r=e.entry)===null||r===void 0?void 0:r.message.descriptor.interface)===Te.Records&&((n=e.entry)===null||n===void 0?void 0:n.message.descriptor.method)===Se.Delete&&e.status.code===404}enqueueOperations({syncDirection:e,syncPeerState:r}){return eo(this,void 0,void 0,function*(){for(let n of r){let i=yield this.getDwnEventLog({did:n.did,delegateDid:n.delegateDid,dwnUrl:n.dwnUrl,cursor:n.cursor,protocol:n.protocol,syncDirection:e}),o=[];for(let s of i){let a=this._ulidFactory(),d=t.generateSyncMessageParamsKey(Object.assign(Object.assign({},n),{watermark:a,messageCid:s}));o.push({type:"put",key:d,value:""})}o.length>0&&(yield(e==="pull"?this.getPullQueue():this.getPushQueue()).batch(o))}})}static generateSyncMessageParamsKey({did:e,delegateDid:r,dwnUrl:n,protocol:i,watermark:o,messageCid:s}){return[e,r,n,i,o,s].join("~")}static parseSyncMessageParamsKey(e){let[r,n,i,o,s,a]=e.split("~");return{did:r,delegateDid:n===""?void 0:n,dwnUrl:i,watermark:s,messageCid:a,protocol:o===""?void 0:o}}getDwnEventLog({did:e,delegateDid:r,dwnUrl:n,syncDirection:i,cursor:o,protocol:s}){var a;return eo(this,void 0,void 0,function*(){let d={},u;if(r)try{u=(yield this._permissionsApi.getPermissionForRequest({connectedDid:e,messageType:Ie.MessagesQuery,delegateDid:r,protocol:s,cached:!0})).grant.id}catch(l){return console.error("SyncEngineLevel: Error fetching MessagesQuery permission grant for delegate DID",l),[]}if(i==="pull"){let l=s?[{protocol:s}]:[],p=yield this.agent.dwn.processRequest({store:!1,target:e,author:e,messageType:Ie.MessagesQuery,granteeDid:r,messageParams:{filters:l,cursor:o,permissionGrantId:u}});try{d=yield this.agent.rpc.sendDwnRequest({dwnUrl:n,targetDid:e,message:p.message})}catch{}}else if(i==="push"){let l=s?[{protocol:s}]:[];d=(yield this.agent.dwn.processRequest({author:e,target:e,messageType:Ie.MessagesQuery,granteeDid:r,messageParams:{filters:l,cursor:o,permissionGrantId:u}})).reply}let c=(a=d.entries)!==null&&a!==void 0?a:[];return d.cursor&&this.setCursor(e,n,i,d.cursor,s),c})}getDwnMessage({author:e,delegateDid:r,protocol:n,messageCid:i}){return eo(this,void 0,void 0,function*(){let o;if(r)try{o=(yield this._permissionsApi.getPermissionForRequest({connectedDid:e,messageType:Ie.MessagesRead,delegateDid:r,protocol:n,cached:!0})).grant.id}catch(u){console.error("SyncEngineLevel: push - Error fetching MessagesRead permission grant for delegate DID",u);return}let{reply:s}=yield this.agent.dwn.processRequest({author:e,target:e,messageType:Ie.MessagesRead,granteeDid:r,messageParams:{messageCid:i,permissionGrantId:o}});if(s.status.code!==200||!s.entry)return;let a=s.entry,d={message:a.message};if(Rb(a)&&a.data){let u=yield Jo.consumeToBytes({readable:a.data});d.data=new Blob([u],{type:a.message.descriptor.dataFormat})}return d})}getSyncPeerState({syncDirection:e}){var r,n,i,o;return eo(this,void 0,void 0,function*(){let s=[];try{for(var a=!0,d=$nt(this._db.sublevel("registeredIdentities").iterator()),u;u=yield d.next(),r=u.done,!r;a=!0){o=u.value,a=!1;let[c,l]=o,{protocols:p,delegateDid:m}=yield new Promise(v=>{try{let{protocols:x,delegateDid:S}=JSON.parse(l);v({protocols:x,delegateDid:S})}catch{v({protocols:[]})}}),g=yield fD(c,this.agent.did);if(g.length!==0)for(let v of g)if(p.length===0){let x=yield this.getCursor(c,v,e);s.push({did:c,delegateDid:m,dwnUrl:v,cursor:x})}else for(let x of p){let S=yield this.getCursor(c,v,e,x);s.push({did:c,delegateDid:m,dwnUrl:v,cursor:S,protocol:x})}}}catch(c){n={error:c}}finally{try{!a&&!r&&(i=d.return)&&(yield i.call(d))}finally{if(n)throw n.error}}return s})}getCursor(e,r,n,i){return eo(this,void 0,void 0,function*(){let o=i?`${e}~${r}~${n}-${i}`:`${e}~${r}~${n}`,s=this.getCursorStore();try{let a=yield s.get(o);if(a)return JSON.parse(a)}catch(a){if(a.notFound)return}})}setCursor(e,r,n,i,o){return eo(this,void 0,void 0,function*(){let s=o?`${e}~${r}~${n}-${o}`:`${e}~${r}~${n}`;yield this.getCursorStore().put(s,JSON.stringify(i))})}messageExists(e,r){return eo(this,void 0,void 0,function*(){let n=this.getMessageStore(e);try{return yield n.get(r),!0}catch(i){if(i.notFound)return!1;throw i}})}addMessage(e,r){return eo(this,void 0,void 0,function*(){return yield this.getMessageStore(e).put(r,"")})}getMessageStore(e){return this._db.sublevel("history").sublevel(e).sublevel("messages")}getCursorStore(){return this._db.sublevel("cursors")}getPushQueue(){return this._db.sublevel("pushQueue")}getPullQueue(){return this._db.sublevel("pullQueue")}};f();var Nnt=gt(p3(),1);f();var jnt=gt(db(),1);f();f();var _c=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Unt=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);ip.id===s.kid))!==null&&r!==void 0?r:{};if(!d)throw new Error("OIDC: Object could not be verified due to missing public key in DID document.");if(!(yield new a0().verify({key:d,signature:ae.base64Url(o).toUint8Array(),data:ae.string(`${n}.${i}`).toUint8Array()})))throw new Error("OIDC: Object failed verification due to invalid signature.");return ae.base64Url(i).toObject()})}var Hnt=(t,e)=>_c(void 0,void 0,void 0,function*(){let n=yield(yield fetch(t)).text(),i=O1e({jwe:n,encryption_key:e});return yield M1e({jwt:i})});function O1e({jwe:t,encryption_key:e}){let[r,,n,i,o]=t.split("."),s=ae.base64Url(e).toUint8Array(),d=ae.base64Url(r).toUint8Array(),u=ae.base64Url(n).toUint8Array(),c=ae.base64Url(i).toUint8Array(),l=ae.base64Url(o).toUint8Array(),p=new Uint8Array([...c,...l]),g=l3(s,u,d).decrypt(p);return ae.uint8Array(g).toString()}function Vnt(t,e,r){return _c(this,void 0,void 0,function*(){let[n,,i,o,s]=e.split("."),a=ae.base64Url(n).toObject(),d=yield Wa.resolve(a.kid.split("#")[0]),u=yield Ha.deriveSharedKey(t,d.didDocument),c=Object.assign(Object.assign({},a),{pin:r}),l=ae.object(c).toUint8Array(),p=ae.base64Url(i).toUint8Array(),m=ae.base64Url(o).toUint8Array(),g=ae.base64Url(s).toUint8Array(),v=new Uint8Array([...m,...g]),S=l3(u,p,l).decrypt(v);return ae.uint8Array(S).toString()})}function Gnt(t,e){var r,n;return _c(this,void 0,void 0,function*(){let i=yield t.export(),o=(r=e.verificationMethod)===null||r===void 0?void 0:r[0].publicKeyJwk,s=(n=i.privateKeys)===null||n===void 0?void 0:n[0];o.alg="EdDSA";let a=yield Fr.convertPublicKeyToX25519({publicKey:o}),d=yield Fr.convertPrivateKeyToX25519({privateKey:s}),u=yield d0.sharedSecret({privateKeyA:d,publicKeyB:a}),c=yield crypto.subtle.importKey("raw",u,{name:"HKDF"},!1,["deriveBits"]),l=yield crypto.subtle.deriveBits({name:"HKDF",hash:"SHA-256",info:new Uint8Array,salt:new Uint8Array},c,256);return new Uint8Array(l)})}function Jnt({jwt:t,encryptionKey:e,delegateDidKeyId:r,randomPin:n}){let i={alg:"dir",cty:"JWT",enc:"XC20P",typ:"JWT",kid:r},o=Mn.randomBytes(24),s=ae.object(Object.assign(Object.assign({},i),{pin:n})).toUint8Array(),a=ae.string(t).toUint8Array(),u=l3(e,o,s).encrypt(a),c=u.subarray(0,-16),l=u.subarray(-16);return[ae.object(i).toBase64Url(),"",ae.uint8Array(o).toBase64Url(),ae.uint8Array(c).toBase64Url(),ae.uint8Array(l).toBase64Url()].join(".")}function Znt(t){return i1e(t)?!0:t.interface===Te.Protocols&&t.method===Se.Configure}function Ynt(t,e,r,n){return _c(this,void 0,void 0,function*(){let i=new Qi({agent:r}),s=(yield Promise.all(n.map(d=>{let u=Znt(d);return i.createGrant({delegated:u,store:!0,grantedTo:e.uri,scope:d,dateExpires:"2040-06-25T16:09:16.693356Z",author:t})}))).map(d=>_c(this,void 0,void 0,function*(){let u=d.message,{encodedData:c}=u,l=Unt(u,["encodedData"]),p=ae.base64Url(c).toUint8Array(),{reply:m}=yield r.sendDwnRequest({author:t,target:t,messageType:Ie.RecordsWrite,dataStream:new Blob([p]),rawMessage:l});if(m.status.code!==202&&m.status.code!==409)throw new Error(`Could not send the message. Error details: ${m.status.detail}`);return d.message}));return yield Promise.all(s)})}function Xnt(t,e,r){return _c(this,void 0,void 0,function*(){let n=yield e.processDwnRequest({author:t,messageType:Ie.ProtocolsQuery,target:t,messageParams:{filter:{protocol:r.protocol}}});if(n.reply.status.code!==200)throw new Error(`Could not fetch protocol: ${n.reply.status.detail}`);if(n.reply.entries===void 0||n.reply.entries.length===0){let{reply:i,message:o}=yield e.sendDwnRequest({author:t,target:t,messageType:Ie.ProtocolsConfigure,messageParams:{definition:r}});if(i.status.code!==202&&i.status.code!==409)throw new Error(`Could not send protocol: ${i.status.detail}`);yield e.processDwnRequest({author:t,target:t,messageType:Ie.ProtocolsConfigure,rawMessage:o})}else{let i=n.reply.entries[0],{reply:o}=yield e.sendDwnRequest({author:t,target:t,messageType:Ie.ProtocolsConfigure,rawMessage:i});if(o.status.code!==202&&o.status.code!==409)throw new Error(`Could not send protocol: ${o.status.detail}`)}})}function Qnt(t,e,r,n){return _c(this,void 0,void 0,function*(){let i=yield Wa.create(),o=yield i.export(),s=e.permissionRequests.map(g=>_c(this,void 0,void 0,function*(){let{protocolDefinition:v,permissionScopes:x}=g;if(!x.every(A=>"protocol"in A&&A.protocol===v.protocol))throw new Error("All permission scopes must match the protocol uri they are provided with.");return yield Xnt(t,n,v),yield Ha.createPermissionGrants(t,i,n,x)})),a=(yield Promise.all(s)).flat(),d=yield Ha.createResponseObject({iss:t,sub:i.uri,aud:e.client_id,nonce:e.nonce,delegateGrants:a,delegatePortableDid:o}),u=yield Ha.signJwt({did:i,data:d}),c=yield Wa.resolve(e.client_id),l=yield Ha.deriveSharedKey(i,c?.didDocument),p=Ha.encryptAuthResponse({jwt:u,encryptionKey:l,delegateDidKeyId:i.document.verificationMethod[0].id,randomPin:r}),m=new URLSearchParams({id_token:p,state:e.state}).toString();yield fetch(e.redirect_uri,{body:m,method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"}})})}var Ha={createAuthRequest:Knt,encryptAuthRequest:Fnt,getAuthRequest:Hnt,decryptAuthRequest:O1e,createPermissionGrants:Ynt,createResponseObject:znt,encryptAuthResponse:Jnt,decryptAuthResponse:Vnt,deriveSharedKey:Gnt,signJwt:Wnt,verifyJwt:M1e,buildOidcUrl:qnt,generateCodeChallenge:Lnt,submitAuthResponse:Qnt};var eit=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})};function tit({connectServerUrl:t,walletUri:e,permissionRequests:r,onWalletUriReady:n,validatePin:i}){return eit(this,void 0,void 0,function*(){let o=yield Wa.create(),s=Mn.randomBytes(32),a=Ha.buildOidcUrl({baseURL:t,endpoint:"callback"}),d=yield Ha.createAuthRequest({client_id:o.uri,scope:"openid did:jwk",permissionRequests:r,redirect_uri:a}),u=yield Ha.signJwt({did:o,data:d});if(!u)throw new Error("Unable to sign requestObject");let c=yield Ha.encryptAuthRequest({jwt:u,encryptionKey:s}),l=new URLSearchParams({request:c}),p=Ha.buildOidcUrl({baseURL:t,endpoint:"pushedAuthorizationRequest"}),m=yield fetch(p,{body:l,method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"}});if(!m.ok)throw new Error(`${m.status}: ${m.statusText}`);let g=yield m.json(),v=new URL(e);v.searchParams.set("request_uri",g.request_uri),v.searchParams.set("encryption_key",ae.uint8Array(s).toBase64Url()),n(v.toString());let x=Ha.buildOidcUrl({baseURL:t,endpoint:"token",tokenParam:d.state}),S=yield r1e(()=>fetch(x));if(S){let P=yield S?.text(),A=yield i(),$=yield Ha.decryptAuthResponse(o,P,A),j=yield Ha.verifyJwt({jwt:$});return{delegateGrants:j.delegateGrants,delegatePortableDid:j.delegatePortableDid,connectedDid:j.iss}}})}function rit({definition:t,permissions:e}){let r=[];r.push({protocol:t.protocol,interface:Te.Protocols,method:Se.Query}),r.push({protocol:t.protocol,interface:Te.Messages,method:Se.Read},{protocol:t.protocol,interface:Te.Messages,method:Se.Query},{protocol:t.protocol,interface:Te.Messages,method:Se.Subscribe});for(let n of e)switch(n){case"write":r.push({protocol:t.protocol,interface:Te.Records,method:Se.Write});break;case"read":r.push({protocol:t.protocol,interface:Te.Records,method:Se.Read});break;case"delete":r.push({protocol:t.protocol,interface:Te.Records,method:Se.Delete});break;case"query":r.push({protocol:t.protocol,interface:Te.Records,method:Se.Query});break;case"subscribe":r.push({protocol:t.protocol,interface:Te.Records,method:Se.Subscribe});break;case"configure":r.push({protocol:t.protocol,interface:Te.Protocols,method:Se.Configure});break}return{protocolDefinition:t,permissionScopes:r}}var Oz={initClient:tit,createPermissionRequestForProtocol:rit};var k5=class{constructor(e){this.agent=e.agent,this.connectedDid=e.connectedDid}async create(e){let{result:r,...n}=await this.agent.processDidRequest({messageType:kb.Create,messageParams:{...e}});return{did:r,...n}}async resolve(e,r){let{result:n}=await this.agent.processDidRequest({messageParams:{didUri:e,options:r},messageType:kb.Resolve});return n}};f();f();var Cz={};Pr(Cz,{SendCache:()=>R5,dataToBlob:()=>D5});f();function D5(t,e){let r,n=r0(t);if(e==="text/plain"||n==="String")r=new Blob([t],{type:"text/plain"});else if(e==="application/json"||n==="Object"){let i=ae.object(t).toUint8Array();r=new Blob([i],{type:"application/json"})}else if(n==="Uint8Array"||n==="ArrayBuffer")r=new Blob([t],{type:"application/octet-stream"});else if(n==="Blob")r=t;else throw new Error("data type not supported.");return e=e||r.type||"application/octet-stream",{dataBlob:r,dataFormat:e}}var fu=class fu{static check(e,r){let n=fu.cache.get(e);return n?n.has(r):!1}static set(e,r){let n=fu.cache.get(e)||new Set;if(fu.cache.delete(e),fu.cache.set(e,n),this.cache.size>fu.sendCacheLimit){let i=fu.cache.keys().next().value;fu.cache.delete(i)}if(n.delete(r),n.add(r),n.size>fu.sendCacheLimit){let i=n.keys().next().value;n.delete(i)}}};fu.cache=new Map,fu.sendCacheLimit=100;var R5=fu;var O_=class O_{get _recordsWriteDescriptor(){if(pD(Ie.RecordsWrite,this.rawMessage))return this._descriptor}get _immutableProperties(){return this._recordsWriteDescriptor||this._initialWrite.descriptor}get id(){return this._recordId}get contextId(){return this.deleted?this._initialWrite.contextId:this._contextId}get dateCreated(){return this._immutableProperties.dateCreated}get parentId(){return this._immutableProperties.parentId}get protocol(){return this._immutableProperties.protocol}get protocolPath(){return this._immutableProperties.protocolPath}get recipient(){return this._immutableProperties.recipient}get schema(){return this._immutableProperties.schema}get dataFormat(){return this._recordsWriteDescriptor?.dataFormat}get dataCid(){return this._recordsWriteDescriptor?.dataCid}get dataSize(){return this._recordsWriteDescriptor?.dataSize}get datePublished(){return this._recordsWriteDescriptor?.datePublished}get published(){return this._recordsWriteDescriptor?.published}get tags(){return this._recordsWriteDescriptor?.tags}get author(){return this._author}get creator(){return this._creator}get dateModified(){return this._descriptor.messageTimestamp}get encryption(){return this._encryption}get authorization(){return this._authorization}get attestation(){return this._attestation}get protocolRole(){return this._protocolRole}get deleted(){return pD(Ie.RecordsDelete,this.rawMessage)}get initialWrite(){return this._initialWrite}get rawMessage(){let e=this._descriptor.interface+this._descriptor.method,r;return e===Ie.RecordsWrite?r=JSON.parse(JSON.stringify({contextId:this._contextId,recordId:this._recordId,descriptor:this._descriptor,attestation:this._attestation,authorization:this._authorization,encryption:this._encryption})):r=JSON.parse(JSON.stringify({descriptor:this._descriptor,authorization:this._authorization})),S_(r),r}constructor(e,r,n){this._agent=e,this._author=r.author,this._creator=r.initialWrite?Lf(r.initialWrite):r.author,this._connectedDid=r.connectedDid,this._delegateDid=r.delegateDid,this._permissionsApi=n??new Qi({agent:e}),this._remoteOrigin=r.remoteOrigin,this._attestation=r.attestation,this._authorization=r.authorization,this._contextId=r.contextId,this._descriptor=r.descriptor,this._encryption=r.encryption,this._initialWrite=r.initialWrite,this._recordId=this.isRecordsDeleteDescriptor(r.descriptor)?r.descriptor.recordId:r.recordId,this._protocolRole=r.protocolRole,r.encodedData&&(this._encodedData=typeof r.encodedData=="string"?new Blob([ae.base64Url(r.encodedData).toUint8Array()],{type:this.dataFormat}):r.encodedData),r.data&&(this._readableStream=Eb.isReadableStream(r.data)?Jo.fromWebReadable({readableStream:r.data}):r.data)}get data(){let e=this;return{async blob(){return new Blob([await Jo.consumeToBytes({readable:await this.stream()})],{type:e.dataFormat})},async bytes(){return await Jo.consumeToBytes({readable:await this.stream()})},async json(){return await Jo.consumeToJson({readable:await this.stream()})},async text(){return await Jo.consumeToText({readable:await this.stream()})},async stream(){if(e._encodedData?e._readableStream=Jo.fromWebReadable({readableStream:e._encodedData.stream()}):Jo.isReadable({readable:e._readableStream})||(e._readableStream=e._remoteOrigin?await e.readRecordData({target:e._remoteOrigin,isRemote:!0}):await e.readRecordData({target:e._connectedDid,isRemote:!1})),!e._readableStream)throw new Error("Record data is not available.");return e._readableStream},then(n,i){return this.stream().then(n,i)},catch(n){return this.stream().catch(n)}}}async store(e=!1){return this.processRecord({signAsOwner:e,store:!0})}async import(e=!0){return this.processRecord({store:e,signAsOwner:!0})}async send(e){let r=this._initialWrite;if(e??=this._connectedDid,r&&!O_._sendCache.check(this._recordId,e)){let o={...r};S_(o),await this._agent.sendDwnRequest({messageType:Ie.RecordsWrite,author:this._connectedDid,target:e,rawMessage:o}),O_._sendCache.set(this._recordId,e)}let n;this.deleted?n={messageType:Ie.RecordsDelete,author:this._connectedDid,target:e,rawMessage:{...this.rawMessage}}:n={messageType:Ie.RecordsWrite,author:this._connectedDid,target:e,dataStream:await this.data.blob(),rawMessage:{...this.rawMessage}};let{reply:i}=await this._agent.sendDwnRequest(n);return i}toJSON(){return{attestation:this.attestation,author:this.author,authorization:this.authorization,contextId:this.contextId,dataCid:this.dataCid,dataFormat:this.dataFormat,dataSize:this.dataSize,dateCreated:this.dateCreated,messageTimestamp:this.dateModified,datePublished:this.datePublished,encryption:this.encryption,parentId:this.parentId,protocol:this.protocol,protocolPath:this.protocolPath,protocolRole:this.protocolRole,published:this.published,recipient:this.recipient,recordId:this.id,schema:this.schema,tags:this.tags}}toString(){let e=`Record: { +`);f();f();function bnt(t,e,r,n){kk(t);let i=Z0e({dkLen:32,asyncTick:10},n),{c:o,dkLen:s,asyncTick:a}=i;if(Oy(o),Oy(s),Oy(a),o<1)throw new Error("PBKDF2: iterations (c) should be >= 1");let d=Cy(e),u=Cy(r),c=new Uint8Array(s),l=qy.create(t,d),p=l._cloneInto().update(u);return{c:o,dkLen:s,asyncTick:a,DK:c,PRF:l,PRFSalt:p}}function wnt(t,e,r,n,i){return t.destroy(),e.destroy(),n&&n.destroy(),i.fill(0),r}async function v1e(t,e,r,n){let{c:i,dkLen:o,asyncTick:s,DK:a,PRF:d,PRFSalt:u}=bnt(t,e,r,n),c,l=new Uint8Array(4),p=lp(l),m=new Uint8Array(d.outputLen);for(let g=1,v=0;v{d._cloneInto(c).update(m).digestInto(m);for(let S=0;So,r=(o,s)=>a=>o(s(a)),n=t.map(o=>o.encode).reduceRight(r,e),i=t.map(o=>o.decode).reduce(r,e);return{encode:n,decode:i}}function xnt(t){return{encode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="number")throw new Error("alphabet.encode input should be an array of numbers");return e.map(r=>{if(r<0||r>=t.length)throw new Error(`Digit index outside alphabet: ${r} (alphabet: ${t.length})`);return t[r]})},decode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="string")throw new Error("alphabet.decode input should be array of strings");return e.map(r=>{if(typeof r!="string")throw new Error(`alphabet.decode: not string element=${r}`);let n=t.indexOf(r);if(n===-1)throw new Error(`Unknown letter: "${r}". Allowed: ${t}`);return n})}}}function Ent(t=""){if(typeof t!="string")throw new Error("join separator should be string");return{encode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="string")throw new Error("join.encode input should be array of strings");for(let r of e)if(typeof r!="string")throw new Error(`join.encode: non-string input=${r}`);return e.join(t)},decode:e=>{if(typeof e!="string")throw new Error("join.decode input should be string");return e.split(t)}}}function Snt(t,e="="){if(typeof e!="string")throw new Error("padding chr should be string");return{encode(r){if(!Array.isArray(r)||r.length&&typeof r[0]!="string")throw new Error("padding.encode input should be array of strings");for(let n of r)if(typeof n!="string")throw new Error(`padding.encode: non-string input=${n}`);for(;r.length*t%8;)r.push(e);return r},decode(r){if(!Array.isArray(r)||r.length&&typeof r[0]!="string")throw new Error("padding.encode input should be array of strings");for(let i of r)if(typeof i!="string")throw new Error(`padding.decode: non-string input=${i}`);let n=r.length;if(n*t%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;n>0&&r[n-1]===e;n--)if(!((n-1)*t%8))throw new Error("Invalid padding: string has too much padding");return r.slice(0,n)}}}function Bz(t,e,r){if(e<2)throw new Error(`convertRadix: wrong from=${e}, base cannot be less than 2`);if(r<2)throw new Error(`convertRadix: wrong to=${r}, base cannot be less than 2`);if(!Array.isArray(t))throw new Error("convertRadix: data should be array");if(!t.length)return[];let n=0,i=[],o=Array.from(t);for(o.forEach(s=>{if(s<0||s>=e)throw new Error(`Wrong integer: ${s}`)});;){let s=0,a=!0;for(let d=n;de?b1e(e,t%e):t,AD=(t,e)=>t+(e-b1e(t,e));function Mz(t,e,r,n){if(!Array.isArray(t))throw new Error("convertRadix2: data should be array");if(e<=0||e>32)throw new Error(`convertRadix2: wrong from=${e}`);if(r<=0||r>32)throw new Error(`convertRadix2: wrong to=${r}`);if(AD(e,r)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${r} carryBits=${AD(e,r)}`);let i=0,o=0,s=2**r-1,a=[];for(let d of t){if(d>=2**e)throw new Error(`convertRadix2: invalid data word=${d} from=${e}`);if(i=i<32)throw new Error(`convertRadix2: carry overflow pos=${o} from=${e}`);for(o+=e;o>=r;o-=r)a.push((i>>o-r&s)>>>0);i&=2**o-1}if(i=i<=e)throw new Error("Excess padding");if(!n&&i)throw new Error(`Non-zero padding: ${i}`);return n&&o>0&&a.push(i>>>0),a}function Ant(t){return{encode:e=>{if(!SD(e))throw new Error("radix.encode input should be Uint8Array");return Bz(Array.from(e),2**8,t)},decode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="number")throw new Error("radix.decode input should be array of numbers");return Uint8Array.from(Bz(e,t,2**8))}}}function Tnt(t,e=!1){if(t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(AD(8,t)>32||AD(t,8)>32)throw new Error("radix2: carry overflow");return{encode:r=>{if(!SD(r))throw new Error("radix2.encode input should be Uint8Array");return Mz(Array.from(r),8,t,!e)},decode:r=>{if(!Array.isArray(r)||r.length&&typeof r[0]!="number")throw new Error("radix2.decode input should be array of numbers");return Uint8Array.from(Mz(r,t,8,e))}}}function Pnt(t,e){if(typeof e!="function")throw new Error("checksum fn should be function");return{encode(r){if(!SD(r))throw new Error("checksum.encode: input should be Uint8Array");let n=e(r).slice(0,t),i=new Uint8Array(r.length+t);return i.set(r),i.set(n,r.length),i},decode(r){if(!SD(r))throw new Error("checksum.decode: input should be Uint8Array");let n=r.slice(0,-t),i=e(n).slice(0,t),o=r.slice(-t);for(let s=0;st[0]==="\u3042\u3044\u3053\u304F\u3057\u3093";function w1e(t){if(typeof t!="string")throw new TypeError(`Invalid mnemonic type: ${typeof t}`);return t.normalize("NFKD")}function _1e(t){let e=w1e(t),r=e.split(" ");if(![12,15,18,21,24].includes(r.length))throw new Error("Invalid mnemonic");return{nfkd:e,words:r}}function x1e(t){dp(t,16,20,24,28,32)}function E1e(t,e=128){if(Oy(e),e%32!==0||e>256)throw new TypeError("Invalid entropy");return Dnt(eb(e/8),t)}var knt=t=>{let e=8-t.length/4;return new Uint8Array([Uy(t)[0]>>e<{if(typeof e!="string")throw new Error(`Wordlist: non-string element: ${e}`)}),g5.chain(g5.checksum(1,knt),g5.radix2(11,!0),g5.alphabet(t))}function Rnt(t,e){let{words:r}=_1e(t),n=S1e(e).decode(r);return x1e(n),n}function Dnt(t,e){return x1e(t),S1e(e).encode(t).join(Int(e)?"\u3000":" ")}function A1e(t,e){try{Rnt(t,e)}catch{return!1}return!0}var Bnt=t=>w1e(`mnemonic${t}`);function T1e(t,e=""){return v1e(Fy,_1e(t).nfkd,Bnt(e),{c:2048,dkLen:64})}f();f();var $p=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},v5=class extends m0{constructor(){super(...arguments),this.name="DwnKeyStore",this._recordProtocolDefinition=n1e,this._recordProperties={dataFormat:"application/json",protocol:this._recordProtocolDefinition.protocol,protocolPath:"privateJwk",schema:this._recordProtocolDefinition.types.privateJwk.schema}}delete(e){let r=Object.create(null,{delete:{get:()=>super.delete}});return $p(this,void 0,void 0,function*(){return yield r.delete.call(this,e)})}get(e){let r=Object.create(null,{get:{get:()=>super.get}});return $p(this,void 0,void 0,function*(){return yield r.get.call(this,e)})}set(e){let r=Object.create(null,{set:{get:()=>super.set}});return $p(this,void 0,void 0,function*(){yield r.set.call(this,e)})}list(e){let r=Object.create(null,{list:{get:()=>super.list}});return $p(this,void 0,void 0,function*(){return yield r.list.call(this,e)})}getAllRecords({agent:e,tenantDid:r}){var n;return $p(this,void 0,void 0,function*(){this._index.clear();let{reply:i}=yield e.dwn.processRequest({author:r,target:r,messageType:Ie.RecordsQuery,messageParams:{filter:Object.assign({},this._recordProperties)}}),o=[];for(let s of(n=i.entries)!==null&&n!==void 0?n:[]){if(!s.encodedData)throw new Error(`${this.name}: Expected 'encodedData' to be present in the DWN query result entry`);let a=ae.base64Url(s.encodedData).toObject();if(T_(a)){let d=`${r}${Xo}${Ab}${a.kid}`;this._index.set(d,s.recordId),this._cache.set(s.recordId,a),o.push(a)}}return o})}},b5=class extends y0{constructor(){super(...arguments),this.name="InMemoryKeyStore"}delete(e){let r=Object.create(null,{delete:{get:()=>super.delete}});return $p(this,void 0,void 0,function*(){return yield r.delete.call(this,e)})}get(e){let r=Object.create(null,{get:{get:()=>super.get}});return $p(this,void 0,void 0,function*(){return yield r.get.call(this,e)})}list(e){let r=Object.create(null,{list:{get:()=>super.list}});return $p(this,void 0,void 0,function*(){return yield r.list.call(this,e)})}set(e){let r=Object.create(null,{set:{get:()=>super.set}});return $p(this,void 0,void 0,function*(){return yield r.set.call(this,e)})}};var md=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},P1e=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);ie)})}isLocked(){return!this._contentEncryptionKey}lock(){return fu(this,void 0,void 0,function*(){if((yield this.isInitialized())===!1)throw new Error("HdIdentityVault: Lock operation failed. Vault has not been initialized.");this._contentEncryptionKey&&(this._contentEncryptionKey.k=""),this._contentEncryptionKey=void 0})}restore({backup:e,password:r}){return fu(this,void 0,void 0,function*(){if(!Mnt(e))throw new Error("HdIdentityVault: Restore operation failed due to invalid backup object.");let n,i,o;try{o=yield this.getStoredDid(),i=yield this.getStoredContentEncryptionKey(),n=yield this.getStatus()}catch{throw new Error("HdIdentityVault: The restore operation cannot proceed because the existing vault contents are missing or inaccessible. If the problem persists consider re-initializing the vault and retrying the restore.")}try{let s=ae.base64Url(e.data).toObject();yield this._store.set("did",s.did),yield this._store.set("contentEncryptionKey",s.contentEncryptionKey),yield this.setStatus(s.status),yield this.unlock({password:r})}catch{throw yield this.setStatus(n),yield this._store.set("contentEncryptionKey",i),yield this._store.set("did",o),new Error("HdIdentityVault: Restore operation failed due to invalid backup data or an incorrect password. Please verify the password is correct for the provided backup and try again.")}yield this.setStatus({lastRestore:new Date().toISOString()})})}unlock({password:e}){return fu(this,void 0,void 0,function*(){yield this.lock();let r=yield this.getStoredContentEncryptionKey();try{let{plaintext:n}=yield jp.decrypt({jwe:r,key:ae.string(e).toUint8Array(),crypto:this.crypto,keyManager:new lu}),i=ae.uint8Array(n).toObject();this._contentEncryptionKey=i}catch{throw new Error("HdIdentityVault: Unable to unlock the vault due to an incorrect password.")}})}getStoredDid(){return fu(this,void 0,void 0,function*(){let e=yield this._store.get("did");if(!e)throw new Error("HdIdentityVault: Unable to retrieve the DID record from the vault. Please check the vault status and if the problem persists consider re-initializing the vault and restoring the contents from a previous backup.");return e})}getStoredContentEncryptionKey(){return fu(this,void 0,void 0,function*(){let e=yield this._store.get("contentEncryptionKey");if(!e)throw new Error("HdIdentityVault: Unable to retrieve the Content Encryption Key record from the vault. Please check the vault status and if the problem persists consider re-initializing the vault and restoring the contents from a previous backup.");return e})}setStatus({initialized:e,lastBackup:r,lastRestore:n}){return fu(this,void 0,void 0,function*(){let i=yield this.getStatus();return i.initialized=e??i.initialized,i.lastBackup=r??i.lastBackup,i.lastRestore=n??i.lastRestore,yield this._store.set("vaultStatus",JSON.stringify(i)),!0})}};f();f();var Np=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})};function Cnt(t){return!(!t||typeof t!="object"||t===null)&&"name"in t}var A5=class extends m0{constructor(){super(...arguments),this.name="DwnIdentityStore",this._recordProtocolDefinition=pD,this._recordProperties={dataFormat:"application/json",protocol:this._recordProtocolDefinition.protocol,protocolPath:"identityMetadata",schema:this._recordProtocolDefinition.types.identityMetadata.schema}}delete(e){let r=Object.create(null,{delete:{get:()=>super.delete}});return Np(this,void 0,void 0,function*(){return yield r.delete.call(this,e)})}get(e){let r=Object.create(null,{get:{get:()=>super.get}});return Np(this,void 0,void 0,function*(){return yield r.get.call(this,e)})}set(e){let r=Object.create(null,{set:{get:()=>super.set}});return Np(this,void 0,void 0,function*(){return yield r.set.call(this,e)})}list(e){let r=Object.create(null,{list:{get:()=>super.list}});return Np(this,void 0,void 0,function*(){return yield r.list.call(this,e)})}getAllRecords({agent:e,tenantDid:r}){var n;return Np(this,void 0,void 0,function*(){this._index.clear();let{reply:i}=yield e.dwn.processRequest({author:r,target:r,messageType:Ie.RecordsQuery,messageParams:{filter:Object.assign({},this._recordProperties)}}),o=[];for(let s of(n=i.entries)!==null&&n!==void 0?n:[]){if(!s.encodedData)throw new Error(`${this.name}: Expected 'encodedData' to be present in the DWN query result entry`);let a=ae.base64Url(s.encodedData).toObject();if(Cnt(a)){let d=`${r}${Xo}${a.uri}`;this._index.set(d,s.recordId),this._cache.set(s.recordId,a),o.push(a)}}return o})}},T5=class extends y0{constructor(){super(...arguments),this.name="InMemoryIdentityStore"}delete(e){let r=Object.create(null,{delete:{get:()=>super.delete}});return Np(this,void 0,void 0,function*(){return yield r.delete.call(this,e)})}get(e){let r=Object.create(null,{get:{get:()=>super.get}});return Np(this,void 0,void 0,function*(){return yield r.get.call(this,e)})}list(e){let r=Object.create(null,{list:{get:()=>super.list}});return Np(this,void 0,void 0,function*(){return yield r.list.call(this,e)})}set(e){let r=Object.create(null,{set:{get:()=>super.set}});return Np(this,void 0,void 0,function*(){return yield r.set.call(this,e)})}};var Up=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})};var P5=class{constructor({agent:e,store:r}={}){this._agent=e,this._store=r??new T5}get agent(){if(this._agent===void 0)throw new Error("AgentIdentityApi: Unable to determine agent execution context.");return this._agent}set agent(e){this._agent=e}get tenant(){if(!this._agent)throw new Error("AgentIdentityApi: The agent must be set to perform tenant specific actions.");return this._agent.agentDid.uri}create({metadata:e,didMethod:r="dht",didOptions:n,store:i}){return Up(this,void 0,void 0,function*(){let o=yield this.agent.did.create({method:r,options:n,tenant:this.tenant,store:i}),s=new k_({did:o,metadata:Object.assign(Object.assign({},e),{uri:o.uri,tenant:this.tenant})});return(i??!0)&&(yield this._store.set({id:s.did.uri,data:s.metadata,agent:this.agent,tenant:s.metadata.tenant,preventDuplicates:!1,useCache:!0})),s})}export({didUri:e}){return Up(this,void 0,void 0,function*(){let r=yield this.get({didUri:e});if(!r)throw new Error(`AgentIdentityApi: Failed to export due to Identity not found: ${e}`);return yield r.export()})}get({didUri:e}){return Up(this,void 0,void 0,function*(){let r=yield this._store.get({id:e,agent:this.agent,useCache:!0});if(!r)return;let n=yield this.agent.did.get({didUri:e,tenant:r.tenant});if(!n)throw new Error(`AgentIdentityApi: Identity is present in the store but DID is missing: ${e}`);return new k_({did:n,metadata:r})})}import({portableIdentity:e}){return Up(this,void 0,void 0,function*(){e.metadata.tenant=this.tenant;let r=yield this.agent.did.import({portableDid:e.portableDid,tenant:e.metadata.tenant});if(!r)throw new Error(`AgentIdentityApi: Failed to import Identity: ${e.metadata.uri}`);let n=new k_({did:r,metadata:e.metadata});return yield this._store.set({id:n.did.uri,data:n.metadata,agent:this.agent,tenant:n.metadata.tenant,preventDuplicates:!0,useCache:!0}),n})}list({tenant:e}={}){return Up(this,void 0,void 0,function*(){let r=yield this._store.list({agent:this.agent,tenant:e});return(yield Promise.all(r.map(i=>this.get({didUri:i.uri})))).filter(i=>typeof i<"u")})}delete({didUri:e}){return Up(this,void 0,void 0,function*(){if(!(yield this._store.get({id:e,agent:this.agent,useCache:!0})))throw new Error(`AgentIdentityApi: Failed to purge due to Identity not found: ${e}`);yield this._store.delete({id:e,agent:this.agent})})}getDwnEndpoints({didUri:e}){return B_(e,this.agent.did)}setDwnEndpoints({didUri:e,endpoints:r}){var n;return Up(this,void 0,void 0,function*(){let i=yield this.agent.did.get({didUri:e});if(!i)throw new Error(`AgentIdentityApi: Failed to set DWN endpoints due to DID not found: ${e}`);let o=yield i.export(),s=(n=o.document.service)===null||n===void 0?void 0:n.find(a=>a.id.endsWith("dwn"));if(s)s.serviceEndpoint=r;else{let a={id:"dwn",type:"DecentralizedWebNode",serviceEndpoint:r,enc:"#enc",sig:"#sig"};o.document.service?o.document.service.push(a):o.document.service=[a]}yield this.agent.did.update({portableDid:o,tenant:this.agent.agentDid.uri})})}setMetadataName({didUri:e,name:r}){return Up(this,void 0,void 0,function*(){if(!r)throw new Error("AgentIdentityApi: Failed to set metadata name due to missing name value.");let n=yield this.get({didUri:e});if(!n)throw new Error(`AgentIdentityApi: Failed to set metadata name due to Identity not found: ${e}`);if(n.metadata.name===r)throw new Error("AgentIdentityApi: No changes detected.");yield this._store.set({id:n.did.uri,data:Object.assign(Object.assign({},n.metadata),{name:r}),agent:this.agent,tenant:n.metadata.tenant,updateExisting:!0,useCache:!0})})}connectedIdentity({connectedDid:e}={}){return Up(this,void 0,void 0,function*(){let r=yield this.list();if(!(r.length<1))return e?r.find(n=>n.metadata.connectedDid===e):r.find(n=>n.metadata.connectedDid!==void 0)})}};f();var qp=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},B1e=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i({jsonrpc:"2.0",id:t,method:e,params:r}),TD=(t,e,r,n)=>({jsonrpc:"2.0",id:t,method:`rpc.subscribe.${e}`,params:n,subscription:{id:r}});function C_(t){try{return JSON.parse(t)}catch{return null}}f();f();var O1e=gt(ub(),1);var I5=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},PD=class{constructor({ttl:e="15m"}={}){this.cache=new Nf.default({ttl:(0,O1e.default)(e)})}get(e){return I5(this,void 0,void 0,function*(){return this.cache.get(e)})}set(e,r){return I5(this,void 0,void 0,function*(){this.cache.set(e,r)})}delete(e){return I5(this,void 0,void 0,function*(){this.cache.delete(e)})}clear(){return I5(this,void 0,void 0,function*(){this.cache.clear()})}close(){return I5(this,void 0,void 0,function*(){})}};var C1e=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},ID=class{constructor(e){this.serverInfoCache=e??new PD}get transportProtocols(){return["http:","https:"]}sendDwnRequest(e){return C1e(this,void 0,void 0,function*(){let r=dn.randomUuid(),n=O_(r,"dwn.processMessage",{target:e.targetDid,message:e.message}),i={method:"POST",headers:{"dwn-request":JSON.stringify(n)}};e.data&&(i.headers["content-type"]="application/octet-stream",i.body=e.data);let o=yield fetch(e.dwnUrl,i),s,a,{headers:d}=o;if(d.has("dwn-response")){let c=C_(d.get("dwn-response"));if(c==null)throw new Error(`failed to parse json rpc response. dwn url: ${e.dwnUrl}`);a=o.body,s=c}else{let c=yield o.text();s=JSON.parse(c)}if(s.error){let{code:c,message:l}=s.error;throw new Error(`(${c}) - ${l}`)}let{reply:u}=s.result;return a&&u.record?u.record.data=a:a&&u.entry&&(u.entry.data=a),u})}getServerInfo(e){return C1e(this,void 0,void 0,function*(){let r=yield this.serverInfoCache.get(e);if(r)return r;let n=new URL(e);n.pathname.endsWith("/")?n.pathname+="info":n.pathname+="/info";try{let i=yield fetch(n.toString());if(i.ok){let o=yield i.json(),s={registrationRequirements:o.registrationRequirements,maxFileSize:o.maxFileSize,webSocketSupport:o.webSocketSupport};return this.serverInfoCache.set(e,s),s}else throw new Error(`HTTP (${i.status}) - ${i.statusText}`)}catch(i){throw new Error(`Error encountered while processing response from ${n.toString()}: ${i.message}`)}})}};f();f();f();var $_=null;typeof WebSocket<"u"?$_=WebSocket:typeof MozWebSocket<"u"?$_=MozWebSocket:typeof globalThis<"u"?$_=globalThis.WebSocket||globalThis.MozWebSocket:typeof window<"u"?$_=window.WebSocket||window.MozWebSocket:typeof self<"u"&&($_=self.WebSocket||self.MozWebSocket);var $1e=$_;var kD=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},$nt=3e3,jnt=3e4,RD=class t{constructor(e,r){this.socket=e,this.responseTimeout=r,this.messageHandlers=new Map}static connect(e,r={}){return kD(this,void 0,void 0,function*(){let{connectTimeout:n=$nt,responseTimeout:i=jnt,onclose:o,onerror:s}=r,a=new $1e(e);return o?a.onclose=o:a.onclose=()=>{console.info(`JSON RPC Socket close ${e}`)},s?a.onerror=s:a.onerror=d=>{console.error(`JSON RPC Socket error ${e}`,d)},new Promise((d,u)=>{a.addEventListener("open",()=>{let c=new t(a,i);a.addEventListener("message",l=>{let p=C_(l.data),m=c.messageHandlers.get(p.id);m&&m(l)}),d(c)}),a.addEventListener("error",c=>{u(c)}),setTimeout(()=>u,n)})})}close(){this.socket.close()}request(e){return kD(this,void 0,void 0,function*(){return new Promise((r,n)=>{var i;(i=e.id)!==null&&i!==void 0||(e.id=dn.randomUuid());let o=s=>{let a=C_(s.data);if(a.id===e.id)return this.messageHandlers.delete(e.id),r(a)};this.messageHandlers.set(e.id,o),this.send(e),setTimeout(()=>{this.messageHandlers.delete(e.id),n(new Error("request timed out"))},this.responseTimeout)})})}subscribe(e,r){return kD(this,void 0,void 0,function*(){if(!e.method.startsWith("rpc.subscribe."))throw new Error("subscribe rpc requests must include the `rpc.subscribe` prefix");if(!e.subscription)throw new Error("subscribe rpc requests must include subscribe options");let n=e.subscription.id,i=a=>{let d=C_(a.data.toString());d.id===n&&(d.error!==void 0&&(this.messageHandlers.delete(n),this.closeSubscription(n)),r(d))};this.messageHandlers.set(n,i);let o=yield this.request(e);return o.error?(this.messageHandlers.delete(n),{response:o}):{response:o,close:()=>kD(this,void 0,void 0,function*(){this.messageHandlers.delete(n),yield this.closeSubscription(n)})}})}closeSubscription(e){let r=dn.randomUuid(),n=TD(r,"close",e,{});return this.request(n)}send(e){this.socket.send(JSON.stringify(e))}};var jz=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},k5=class t{get transportProtocols(){return["ws:","wss:"]}sendDwnRequest(e,r){return jz(this,void 0,void 0,function*(){let n=new URL(e.dwnUrl);if(n.protocol!=="ws:"&&n.protocol!=="wss:")throw new Error(`Invalid websocket protocol ${n.protocol}`);if(!t.connections.has(n.host))try{let u=yield RD.connect(n.toString(),r),c=new Map;t.connections.set(n.host,{socket:u,subscriptions:c})}catch(u){throw new Error(`Error connecting to ${n.host}: ${u.message}`)}let o=t.connections.get(n.host),{targetDid:s,message:a,subscriptionHandler:d}=e;return d?t.subscriptionRequest(o,s,a,d):t.processMessage(o,s,a)})}static processMessage(e,r,n){return jz(this,void 0,void 0,function*(){let i=dn.randomUuid(),o=O_(i,"dwn.processMessage",{target:r,message:n}),{socket:s}=e,a=yield s.request(o),{error:d,result:u}=a;if(d!==void 0)throw new Error(`error sending DWN request: ${d.message}`);return u.reply})}static subscriptionRequest(e,r,n,i){return jz(this,void 0,void 0,function*(){let o=dn.randomUuid(),s=dn.randomUuid(),a=TD(o,"dwn.processMessage",s,{target:r,message:n}),{socket:d,subscriptions:u}=e,{response:c,close:l}=yield d.subscribe(a,v=>{let{result:x,error:S}=v;if(S){let A=u.get(s);A&&A.close(),u.delete(s);return}let{event:P}=x;i(P)}),{error:p,result:m}=c;if(p)throw new Error(`could not subscribe via jsonrpc socket: ${p.message}`);let{reply:g}=m;return g.subscription&&l&&(u.set(s,Object.assign(Object.assign({},g.subscription),{close:l})),g.subscription.close=l),g})}};k5.connections=new Map;var R5=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},j1e;(function(t){t.Create="did.create",t.Resolve="did.resolve"})(j1e||(j1e={}));var D5=class{constructor(e=[]){this.transportClients=new Map,e=[new Nz,new Uz,...e];for(let r of e)for(let n of r.transportProtocols)this.transportClients.set(n,r)}get transportProtocols(){return Array.from(this.transportClients.keys())}sendDidRequest(e){return R5(this,void 0,void 0,function*(){let r=new URL(e.url),n=this.transportClients.get(r.protocol);if(!n){let i=new Error(`no ${r.protocol} transport client available`);throw i.name="NO_TRANSPORT_CLIENT",i}return n.sendDidRequest(e)})}sendDwnRequest(e){let r=new URL(e.dwnUrl),n=this.transportClients.get(r.protocol);if(!n){let i=new Error(`no ${r.protocol} transport client available`);throw i.name="NO_TRANSPORT_CLIENT",i}return n.sendDwnRequest(e)}getServerInfo(e){return R5(this,void 0,void 0,function*(){let r=new URL(e),n=this.transportClients.get(r.protocol);if(!n){let i=new Error(`no ${r.protocol} transport client available`);throw i.name="NO_TRANSPORT_CLIENT",i}return n.getServerInfo(e)})}},Nz=class extends ID{sendDidRequest(e){return R5(this,void 0,void 0,function*(){let r=dn.randomUuid(),n=O_(r,e.method,{data:e.data}),i=new Request(e.url,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}),o;try{let s=yield fetch(i);if(s.ok){if(o=yield s.json(),o.error){let{code:a,message:d}=o.error;throw new Error(`JSON RPC (${a}) - ${d}`)}}else throw new Error(`HTTP (${s.status}) - ${s.statusText}`)}catch(s){throw new Error(`Error encountered while processing response from ${e.url}: ${s.message}`)}return o.result})}},Uz=class extends k5{sendDidRequest(e){return R5(this,void 0,void 0,function*(){throw new Error(`not implemented for transports [${this.transportProtocols.join(", ")}]`)})}getServerInfo(e){return R5(this,void 0,void 0,function*(){throw new Error(`not implemented for transports [${this.transportProtocols.join(", ")}]`)})}};f();var DD=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},B5=class{constructor({agent:e,syncEngine:r}){this._syncEngine=r,this._agent=e}get agent(){if(this._agent===void 0)throw new Error("AgentSyncApi: Unable to determine agent execution context.");return this._agent}set agent(e){this._agent=e,this._syncEngine.agent=e}registerIdentity(e){return DD(this,void 0,void 0,function*(){yield this._syncEngine.registerIdentity(e)})}unregisterIdentity(e){return DD(this,void 0,void 0,function*(){yield this._syncEngine.unregisterIdentity(e)})}getIdentityOptions(e){return DD(this,void 0,void 0,function*(){return yield this._syncEngine.getIdentityOptions(e)})}updateIdentityOptions(e){return DD(this,void 0,void 0,function*(){yield this._syncEngine.updateIdentityOptions(e)})}sync(e){return this._syncEngine.sync(e)}startSync(e){return this._syncEngine.startSync(e)}stopSync(e){return this._syncEngine.stopSync(e)}};f();var N1e=gt(ub(),1),U1e=gt(g3(),1);var Ui=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Nnt=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,d){s=t[o](s),i(a,d,s.done,s.value)})}}function i(o,s,a,d){Promise.resolve(d).then(function(u){o({value:u,done:a})},s)}},M5=class t{constructor({agent:e,dataPath:r,db:n}){this._syncLock=!1,this._agent=e,this._permissionsApi=new eo({agent:e}),this._db=n||new U1e.Level(r??"DATA/AGENT/SYNC_STORE"),this._ulidFactory=HR()}get agent(){if(this._agent===void 0)throw new Error("SyncEngineLevel: Unable to determine agent execution context.");return this._agent}set agent(e){this._agent=e,this._permissionsApi=new eo({agent:e})}clear(){return Ui(this,void 0,void 0,function*(){yield this._permissionsApi.clear(),yield this._db.clear()})}close(){return Ui(this,void 0,void 0,function*(){yield this._db.close()})}pull(){var e;return Ui(this,void 0,void 0,function*(){let r=yield this.getSyncPeerState({syncDirection:"pull"});yield this.enqueueOperations({syncDirection:"pull",syncPeerState:r});let n=this.getPullQueue(),i=yield n.iterator().all(),o=[],s=new Set;for(let a of i){let[d]=a,{did:u,dwnUrl:c,messageCid:l,delegateDid:p,protocol:m}=t.parseSyncMessageParamsKey(d);if(s.has(c))continue;if(yield this.messageExists(u,l)){o.push({type:"del",key:d});continue}let v,x;if(p)try{v=(yield this._permissionsApi.getPermissionForRequest({connectedDid:u,messageType:Ie.MessagesRead,delegateDid:p,protocol:m,cached:!0})).grant.id,x=p}catch(F){console.error("SyncEngineLevel: pull - Error fetching MessagesRead permission grant for delegate DID",F);continue}let S=yield this.agent.processDwnRequest({store:!1,author:u,target:u,messageType:Ie.MessagesRead,granteeDid:x,messageParams:{messageCid:l,permissionGrantId:v}}),P;try{P=yield this.agent.rpc.sendDwnRequest({dwnUrl:c,targetDid:u,message:S.message})}catch{s.add(c);continue}if(P.status.code!==200||!(!((e=P.entry)===null||e===void 0)&&e.message)){yield this.addMessage(u,l),o.push({type:"del",key:d});continue}let A=P.entry,$=A.message,j=Rb(A)&&A.data?Jo.fromWebReadable({readableStream:A.data}):void 0,q=yield this.agent.dwn.node.processMessage(u,$,{dataStream:j});t.syncMessageReplyIsSuccessful(q)&&(yield this.addMessage(u,l),o.push({type:"del",key:d}))}yield n.batch(o)})}push(){return Ui(this,void 0,void 0,function*(){let e=yield this.getSyncPeerState({syncDirection:"push"});yield this.enqueueOperations({syncDirection:"push",syncPeerState:e});let r=this.getPushQueue(),n=yield r.iterator().all(),i=[],o=new Set;for(let s of n){let[a]=s,{did:d,delegateDid:u,protocol:c,dwnUrl:l,messageCid:p}=t.parseSyncMessageParamsKey(a);if(o.has(l))continue;let m=yield this.getDwnMessage({author:d,messageCid:p,delegateDid:u,protocol:c});if(!m){i.push({type:"del",key:a}),yield this.addMessage(d,p);continue}try{let g=yield this.agent.rpc.sendDwnRequest({dwnUrl:l,targetDid:d,data:m.data,message:m.message});t.syncMessageReplyIsSuccessful(g)&&(yield this.addMessage(d,p),i.push({type:"del",key:a}))}catch{o.add(l)}}yield r.batch(i)})}registerIdentity({did:e,options:r}){return Ui(this,void 0,void 0,function*(){let n=this._db.sublevel("registeredIdentities");if(yield this.getIdentityOptions(e))throw new Error(`SyncEngineLevel: Identity with DID ${e} is already registered.`);r??(r={protocols:[]}),yield n.put(e,JSON.stringify(r))})}unregisterIdentity(e){return Ui(this,void 0,void 0,function*(){let r=this._db.sublevel("registeredIdentities");if(!(yield this.getIdentityOptions(e)))throw new Error(`SyncEngineLevel: Identity with DID ${e} is not registered.`);yield r.del(e)})}getIdentityOptions(e){return Ui(this,void 0,void 0,function*(){let r=this._db.sublevel("registeredIdentities");try{let n=yield r.get(e);if(n)return JSON.parse(n)}catch(n){let i=n;if(i.code==="LEVEL_NOT_FOUND")return;throw new Error(`SyncEngineLevel: Error reading level: ${i.code}.`)}})}updateIdentityOptions({did:e,options:r}){return Ui(this,void 0,void 0,function*(){let n=this._db.sublevel("registeredIdentities");if(!(yield this.getIdentityOptions(e)))throw new Error(`SyncEngineLevel: Identity with DID ${e} is not registered.`);yield n.put(e,JSON.stringify(r))})}sync(e){return Ui(this,void 0,void 0,function*(){if(this._syncLock)throw new Error("SyncEngineLevel: Sync operation is already in progress.");this._syncLock=!0;try{(!e||e==="push")&&(yield this.push()),(!e||e==="pull")&&(yield this.pull())}finally{this._syncLock=!1}})}startSync({interval:e}){return Ui(this,void 0,void 0,function*(){let r=(0,N1e.default)(e),n=()=>Ui(this,void 0,void 0,function*(){if(!this._syncLock){clearInterval(this._syncIntervalId),this._syncIntervalId=void 0;try{yield this.sync()}catch(i){console.error("SyncEngineLevel: Error during sync operation",i)}this._syncIntervalId||(this._syncIntervalId=setInterval(n,r))}});this._syncIntervalId&&clearInterval(this._syncIntervalId),this._syncIntervalId=setInterval(n,r),this._syncLock||(yield this.sync())})}stopSync(e=2e3){return Ui(this,void 0,void 0,function*(){let r=0;for(;this._syncLock;){if(r>=e)throw new Error(`SyncEngineLevel: Existing sync operation did not complete within ${e} milliseconds.`);r+=100,yield new Promise(n=>setTimeout(n,e<100?e:100))}this._syncIntervalId&&(clearInterval(this._syncIntervalId),this._syncIntervalId=void 0)})}static syncMessageReplyIsSuccessful(e){var r,n;return e.status.code===202||e.status.code===204||e.status.code===409||((r=e.entry)===null||r===void 0?void 0:r.message.descriptor.interface)===Te.Records&&((n=e.entry)===null||n===void 0?void 0:n.message.descriptor.method)===Se.Delete&&e.status.code===404}enqueueOperations({syncDirection:e,syncPeerState:r}){return Ui(this,void 0,void 0,function*(){(yield Promise.allSettled(r.map(i=>Ui(this,void 0,void 0,function*(){let o=yield this.getDwnEventLog({did:i.did,delegateDid:i.delegateDid,dwnUrl:i.dwnUrl,cursor:i.cursor,protocol:i.protocol,syncDirection:e}),s=[];for(let a of o){let d=this._ulidFactory(),u=t.generateSyncMessageParamsKey(Object.assign(Object.assign({},i),{watermark:d,messageCid:a}));s.push({type:"put",key:u,value:""})}s.length>0&&(yield(e==="pull"?this.getPullQueue():this.getPushQueue()).batch(s))})))).forEach((i,o)=>{if(i.status==="rejected"){let s=r[o];console.error(`SyncEngineLevel: Error enqueuing sync operation for peerState: ${JSON.stringify(s)}`,i.reason)}})})}static generateSyncMessageParamsKey({did:e,delegateDid:r,dwnUrl:n,protocol:i,watermark:o,messageCid:s}){return[e,r,n,i,o,s].join("~")}static parseSyncMessageParamsKey(e){let[r,n,i,o,s,a]=e.split("~");return{did:r,delegateDid:n===""?void 0:n,dwnUrl:i,watermark:s,messageCid:a,protocol:o===""?void 0:o}}getDwnEventLog({did:e,delegateDid:r,dwnUrl:n,syncDirection:i,cursor:o,protocol:s}){var a;return Ui(this,void 0,void 0,function*(){let d={},u;if(r)try{u=(yield this._permissionsApi.getPermissionForRequest({connectedDid:e,messageType:Ie.MessagesQuery,delegateDid:r,protocol:s,cached:!0})).grant.id}catch(l){return console.error("SyncEngineLevel: Error fetching MessagesQuery permission grant for delegate DID",l),[]}if(i==="pull"){let l=s?[{protocol:s}]:[],p=yield this.agent.dwn.processRequest({store:!1,target:e,author:e,messageType:Ie.MessagesQuery,granteeDid:r,messageParams:{filters:l,cursor:o,permissionGrantId:u}});try{d=yield this.agent.rpc.sendDwnRequest({dwnUrl:n,targetDid:e,message:p.message})}catch{}}else if(i==="push"){let l=s?[{protocol:s}]:[];d=(yield this.agent.dwn.processRequest({author:e,target:e,messageType:Ie.MessagesQuery,granteeDid:r,messageParams:{filters:l,cursor:o,permissionGrantId:u}})).reply}let c=(a=d.entries)!==null&&a!==void 0?a:[];return d.cursor&&this.setCursor(e,n,i,d.cursor,s),c})}getDwnMessage({author:e,delegateDid:r,protocol:n,messageCid:i}){return Ui(this,void 0,void 0,function*(){let o;if(r)try{o=(yield this._permissionsApi.getPermissionForRequest({connectedDid:e,messageType:Ie.MessagesRead,delegateDid:r,protocol:n,cached:!0})).grant.id}catch(u){console.error("SyncEngineLevel: push - Error fetching MessagesRead permission grant for delegate DID",u);return}let{reply:s}=yield this.agent.dwn.processRequest({author:e,target:e,messageType:Ie.MessagesRead,granteeDid:r,messageParams:{messageCid:i,permissionGrantId:o}});if(s.status.code!==200||!s.entry)return;let a=s.entry,d={message:a.message};if(Rb(a)&&a.data){let u=yield Jo.consumeToBytes({readable:a.data});d.data=new Blob([u],{type:a.message.descriptor.dataFormat})}return d})}getSyncPeerState({syncDirection:e}){var r,n,i,o;return Ui(this,void 0,void 0,function*(){let s=[];try{for(var a=!0,d=Nnt(this._db.sublevel("registeredIdentities").iterator()),u;u=yield d.next(),r=u.done,!r;a=!0){o=u.value,a=!1;let[c,l]=o,{protocols:p,delegateDid:m}=yield new Promise(v=>{try{let{protocols:x,delegateDid:S}=JSON.parse(l);v({protocols:x,delegateDid:S})}catch{v({protocols:[]})}}),g=yield B_(c,this.agent.did);if(g.length!==0)for(let v of g)if(p.length===0){let x=yield this.getCursor(c,v,e);s.push({did:c,delegateDid:m,dwnUrl:v,cursor:x})}else for(let x of p){let S=yield this.getCursor(c,v,e,x);s.push({did:c,delegateDid:m,dwnUrl:v,cursor:S,protocol:x})}}}catch(c){n={error:c}}finally{try{!a&&!r&&(i=d.return)&&(yield i.call(d))}finally{if(n)throw n.error}}return s})}getCursor(e,r,n,i){return Ui(this,void 0,void 0,function*(){let o=i?`${e}~${r}~${n}-${i}`:`${e}~${r}~${n}`,s=this.getCursorStore();try{let a=yield s.get(o);if(a)return JSON.parse(a)}catch(a){if(a.notFound)return}})}setCursor(e,r,n,i,o){return Ui(this,void 0,void 0,function*(){let s=o?`${e}~${r}~${n}-${o}`:`${e}~${r}~${n}`;yield this.getCursorStore().put(s,JSON.stringify(i))})}messageExists(e,r){return Ui(this,void 0,void 0,function*(){let n=this.getMessageStore(e);try{return yield n.get(r),!0}catch(i){if(i.notFound)return!1;throw i}})}addMessage(e,r){return Ui(this,void 0,void 0,function*(){return yield this.getMessageStore(e).put(r,"")})}getMessageStore(e){return this._db.sublevel("history").sublevel(e).sublevel("messages")}getCursorStore(){return this._db.sublevel("cursors")}getPushQueue(){return this._db.sublevel("pushQueue")}getPullQueue(){return this._db.sublevel("pullQueue")}};f();var qnt=gt(g3(),1);f();var Unt=gt(ub(),1);f();f();var Sc=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},Lnt=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);ip.id===s.kid))!==null&&r!==void 0?r:{};if(!d)throw new Error("OIDC: Object could not be verified due to missing public key in DID document.");if(!(yield new d0().verify({key:d,signature:ae.base64Url(o).toUint8Array(),data:ae.string(`${n}.${i}`).toUint8Array()})))throw new Error("OIDC: Object failed verification due to invalid signature.");return ae.base64Url(i).toObject()})}var Gnt=(t,e)=>Sc(void 0,void 0,void 0,function*(){let n=yield(yield fetch(t)).text(),i=L1e({jwe:n,encryption_key:e});return yield q1e({jwt:i})});function L1e({jwe:t,encryption_key:e}){let[r,,n,i,o]=t.split("."),s=ae.base64Url(e).toUint8Array(),d=ae.base64Url(r).toUint8Array(),u=ae.base64Url(n).toUint8Array(),c=ae.base64Url(i).toUint8Array(),l=ae.base64Url(o).toUint8Array(),p=new Uint8Array([...c,...l]),g=p3(s,u,d).decrypt(p);return ae.uint8Array(g).toString()}function Jnt(t,e,r){return Sc(this,void 0,void 0,function*(){let[n,,i,o,s]=e.split("."),a=ae.base64Url(n).toObject(),d=yield Ha.resolve(a.kid.split("#")[0]),u=yield Va.deriveSharedKey(t,d.didDocument),c=Object.assign(Object.assign({},a),{pin:r}),l=ae.object(c).toUint8Array(),p=ae.base64Url(i).toUint8Array(),m=ae.base64Url(o).toUint8Array(),g=ae.base64Url(s).toUint8Array(),v=new Uint8Array([...m,...g]),S=p3(u,p,l).decrypt(v);return ae.uint8Array(S).toString()})}function Znt(t,e){var r,n;return Sc(this,void 0,void 0,function*(){let i=yield t.export(),o=(r=e.verificationMethod)===null||r===void 0?void 0:r[0].publicKeyJwk,s=(n=i.privateKeys)===null||n===void 0?void 0:n[0];o.alg="EdDSA";let a=yield Fr.convertPublicKeyToX25519({publicKey:o}),d=yield Fr.convertPrivateKeyToX25519({privateKey:s}),u=yield l0.sharedSecret({privateKeyA:d,publicKeyB:a}),c=yield crypto.subtle.importKey("raw",u,{name:"HKDF"},!1,["deriveBits"]),l=yield crypto.subtle.deriveBits({name:"HKDF",hash:"SHA-256",info:new Uint8Array,salt:new Uint8Array},c,256);return new Uint8Array(l)})}function Ynt({jwt:t,encryptionKey:e,delegateDidKeyId:r,randomPin:n}){let i={alg:"dir",cty:"JWT",enc:"XC20P",typ:"JWT",kid:r},o=dn.randomBytes(24),s=ae.object(Object.assign(Object.assign({},i),{pin:n})).toUint8Array(),a=ae.string(t).toUint8Array(),u=p3(e,o,s).encrypt(a),c=u.subarray(0,-16),l=u.subarray(-16);return[ae.object(i).toBase64Url(),"",ae.uint8Array(o).toBase64Url(),ae.uint8Array(c).toBase64Url(),ae.uint8Array(l).toBase64Url()].join(".")}function Xnt(t){return l1e(t)?!0:t.interface===Te.Protocols&&t.method===Se.Configure}function Qnt(t,e,r,n){return Sc(this,void 0,void 0,function*(){let i=new eo({agent:r});Os.log(`Creating permission grants for ${n.length} scopes given...`);let o=yield Promise.all(n.map(a=>{let d=Xnt(a);return i.createGrant({delegated:d,store:!0,grantedTo:e.uri,scope:a,dateExpires:"2040-06-25T16:09:16.693356Z",author:t})}));Os.log(`Sending ${o.length} permission grants to remote DWN...`);let s=o.map(a=>Sc(this,void 0,void 0,function*(){let d=a.message,{encodedData:u}=d,c=Lnt(d,["encodedData"]),l=ae.base64Url(u).toUint8Array(),{reply:p}=yield r.sendDwnRequest({author:t,target:t,messageType:Ie.RecordsWrite,dataStream:new Blob([l]),rawMessage:c});if(p.status.code!==202&&p.status.code!==409)throw Os.error(`Error sending RecordsWrite: ${p.status.detail}`),Os.error(`RecordsWrite message: ${c}`),new Error(`Could not send the message. Error details: ${p.status.detail}`);return a.message}));try{return yield Promise.all(s)}catch(a){throw Os.error(`Error during batch-send of permission grants: ${a}`),a}})}function eit(t,e,r){return Sc(this,void 0,void 0,function*(){let n=yield e.processDwnRequest({author:t,messageType:Ie.ProtocolsQuery,target:t,messageParams:{filter:{protocol:r.protocol}}});if(n.reply.status.code!==200)throw new Error(`Could not fetch protocol: ${n.reply.status.detail}`);if(n.reply.entries===void 0||n.reply.entries.length===0){Os.log(`Protocol does not exist, creating: ${r.protocol}`);let{reply:i,message:o}=yield e.sendDwnRequest({author:t,target:t,messageType:Ie.ProtocolsConfigure,messageParams:{definition:r}});if(i.status.code!==202&&i.status.code!==409)throw new Error(`Could not send protocol: ${i.status.detail}`);yield e.processDwnRequest({author:t,target:t,messageType:Ie.ProtocolsConfigure,rawMessage:o})}else{Os.log(`Protocol already exists: ${r.protocol}`);let i=n.reply.entries[0],{reply:o}=yield e.sendDwnRequest({author:t,target:t,messageType:Ie.ProtocolsConfigure,rawMessage:i});if(o.status.code!==202&&o.status.code!==409)throw new Error(`Could not send protocol: ${o.status.detail}`)}})}function tit(t,e,r,n){return Sc(this,void 0,void 0,function*(){let i=yield Ha.create(),o=yield i.export(),s=e.permissionRequests.map(g=>Sc(this,void 0,void 0,function*(){let{protocolDefinition:v,permissionScopes:x}=g;if(!x.every(A=>"protocol"in A&&A.protocol===v.protocol))throw new Error("All permission scopes must match the protocol uri they are provided with.");return yield eit(t,n,v),yield Va.createPermissionGrants(t,i,n,x)})),a=(yield Promise.all(s)).flat();Os.log("Generating auth response object...");let d=yield Va.createResponseObject({iss:t,sub:i.uri,aud:e.client_id,nonce:e.nonce,delegateGrants:a,delegatePortableDid:o});Os.log("Signing auth response object...");let u=yield Va.signJwt({did:i,data:d}),c=yield Ha.resolve(e.client_id),l=yield Va.deriveSharedKey(i,c?.didDocument);Os.log("Encrypting auth response object...");let p=Va.encryptAuthResponse({jwt:u,encryptionKey:l,delegateDidKeyId:i.document.verificationMethod[0].id,randomPin:r}),m=new URLSearchParams({id_token:p,state:e.state}).toString();Os.log(`Sending auth response object to Web5 Connect server: ${e.redirect_uri}`),yield fetch(e.redirect_uri,{body:m,method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"}})})}var Va={createAuthRequest:znt,encryptAuthRequest:Wnt,getAuthRequest:Gnt,decryptAuthRequest:L1e,createPermissionGrants:Qnt,createResponseObject:Hnt,encryptAuthResponse:Ynt,decryptAuthResponse:Jnt,deriveSharedKey:Znt,signJwt:Vnt,verifyJwt:q1e,buildOidcUrl:Knt,generateCodeChallenge:Fnt,submitAuthResponse:tit};var rit=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})};function nit({displayName:t,connectServerUrl:e,walletUri:r,permissionRequests:n,onWalletUriReady:i,validatePin:o}){return rit(this,void 0,void 0,function*(){let s=yield Ha.create(),a=dn.randomBytes(32),d=Va.buildOidcUrl({baseURL:e,endpoint:"callback"}),u=yield Va.createAuthRequest({client_id:s.uri,scope:"openid did:jwk",redirect_uri:d,permissionRequests:n,displayName:t}),c=yield Va.signJwt({did:s,data:u});if(!c)throw new Error("Unable to sign requestObject");let l=yield Va.encryptAuthRequest({jwt:c,encryptionKey:a}),p=new URLSearchParams({request:l}),m=Va.buildOidcUrl({baseURL:e,endpoint:"pushedAuthorizationRequest"}),g=yield fetch(m,{body:p,method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"}});if(!g.ok)throw new Error(`${g.status}: ${g.statusText}`);let v=yield g.json();Os.log(`Wallet URI: ${r}`);let x=new URL(r);x.searchParams.set("request_uri",v.request_uri),x.searchParams.set("encryption_key",ae.uint8Array(a).toBase64Url()),i(x.toString());let S=Va.buildOidcUrl({baseURL:e,endpoint:"token",tokenParam:u.state}),P=yield d1e(()=>fetch(S));if(P){let A=yield P?.text(),$=yield o(),j=yield Va.decryptAuthResponse(s,A,$),q=yield Va.verifyJwt({jwt:j});return{delegateGrants:q.delegateGrants,delegatePortableDid:q.delegatePortableDid,connectedDid:q.iss}}})}function iit({definition:t,permissions:e}){let r=[];r.push({protocol:t.protocol,interface:Te.Protocols,method:Se.Query}),r.push({protocol:t.protocol,interface:Te.Messages,method:Se.Read},{protocol:t.protocol,interface:Te.Messages,method:Se.Query},{protocol:t.protocol,interface:Te.Messages,method:Se.Subscribe});for(let n of e)switch(n){case"write":r.push({protocol:t.protocol,interface:Te.Records,method:Se.Write});break;case"read":r.push({protocol:t.protocol,interface:Te.Records,method:Se.Read});break;case"delete":r.push({protocol:t.protocol,interface:Te.Records,method:Se.Delete});break;case"query":r.push({protocol:t.protocol,interface:Te.Records,method:Se.Query});break;case"subscribe":r.push({protocol:t.protocol,interface:Te.Records,method:Se.Subscribe});break;case"configure":r.push({protocol:t.protocol,interface:Te.Protocols,method:Se.Configure});break}return{protocolDefinition:t,permissionScopes:r}}var qz={initClient:nit,createPermissionRequestForProtocol:iit};var O5=class{constructor(e){this.agent=e.agent,this.connectedDid=e.connectedDid}async create(e){let{result:r,...n}=await this.agent.processDidRequest({messageType:kb.Create,messageParams:{...e}});return{did:r,...n}}async resolve(e,r){let{result:n}=await this.agent.processDidRequest({messageParams:{didUri:e,options:r},messageType:kb.Resolve});return n}};f();f();var Lz={};Pr(Lz,{SendCache:()=>C5,dataToBlob:()=>$5});f();function $5(t,e){let r,n=i0(t);if(e==="text/plain"||n==="String")r=new Blob([t],{type:"text/plain"});else if(e==="application/json"||n==="Object"){let i=ae.object(t).toUint8Array();r=new Blob([i],{type:"application/json"})}else if(n==="Uint8Array"||n==="ArrayBuffer")r=new Blob([t],{type:"application/octet-stream"});else if(n==="Blob")r=t;else throw new Error("data type not supported.");return e=e||r.type||"application/octet-stream",{dataBlob:r,dataFormat:e}}var hu=class hu{static check(e,r){let n=hu.cache.get(e);return n?n.has(r):!1}static set(e,r){let n=hu.cache.get(e)||new Set;if(hu.cache.delete(e),hu.cache.set(e,n),this.cache.size>hu.sendCacheLimit){let i=hu.cache.keys().next().value;hu.cache.delete(i)}if(n.delete(r),n.add(r),n.size>hu.sendCacheLimit){let i=n.keys().next().value;n.delete(i)}}};hu.cache=new Map,hu.sendCacheLimit=100;var C5=hu;var j_=class j_{get _recordsWriteDescriptor(){if(bD(Ie.RecordsWrite,this.rawMessage))return this._descriptor}get _immutableProperties(){return this._recordsWriteDescriptor||this._initialWrite.descriptor}get id(){return this._recordId}get contextId(){return this.deleted?this._initialWrite.contextId:this._contextId}get dateCreated(){return this._immutableProperties.dateCreated}get parentId(){return this._immutableProperties.parentId}get protocol(){return this._immutableProperties.protocol}get protocolPath(){return this._immutableProperties.protocolPath}get recipient(){return this._immutableProperties.recipient}get schema(){return this._immutableProperties.schema}get dataFormat(){return this._recordsWriteDescriptor?.dataFormat}get dataCid(){return this._recordsWriteDescriptor?.dataCid}get dataSize(){return this._recordsWriteDescriptor?.dataSize}get datePublished(){return this._recordsWriteDescriptor?.datePublished}get published(){return this._recordsWriteDescriptor?.published}get tags(){return this._recordsWriteDescriptor?.tags}get author(){return this._author}get creator(){return this._creator}get dateModified(){return this._descriptor.messageTimestamp}get encryption(){return this._encryption}get authorization(){return this._authorization}get attestation(){return this._attestation}get protocolRole(){return this._protocolRole}get deleted(){return bD(Ie.RecordsDelete,this.rawMessage)}get initialWrite(){return this._initialWrite}get rawMessage(){let e=this._descriptor.interface+this._descriptor.method,r;return e===Ie.RecordsWrite?r=JSON.parse(JSON.stringify({contextId:this._contextId,recordId:this._recordId,descriptor:this._descriptor,attestation:this._attestation,authorization:this._authorization,encryption:this._encryption})):r=JSON.parse(JSON.stringify({descriptor:this._descriptor,authorization:this._authorization})),A_(r),r}constructor(e,r,n){this._agent=e,this._author=r.author,this._creator=r.initialWrite?Kf(r.initialWrite):r.author,this._connectedDid=r.connectedDid,this._delegateDid=r.delegateDid,this._permissionsApi=n??new eo({agent:e}),this._remoteOrigin=r.remoteOrigin,this._attestation=r.attestation,this._authorization=r.authorization,this._contextId=r.contextId,this._descriptor=r.descriptor,this._encryption=r.encryption,this._initialWrite=r.initialWrite,this._recordId=this.isRecordsDeleteDescriptor(r.descriptor)?r.descriptor.recordId:r.recordId,this._protocolRole=r.protocolRole,r.encodedData&&(this._encodedData=typeof r.encodedData=="string"?new Blob([ae.base64Url(r.encodedData).toUint8Array()],{type:this.dataFormat}):r.encodedData),r.data&&(this._readableStream=Sb.isReadableStream(r.data)?Jo.fromWebReadable({readableStream:r.data}):r.data)}get data(){let e=this;return{async blob(){return new Blob([await Jo.consumeToBytes({readable:await this.stream()})],{type:e.dataFormat})},async bytes(){return await Jo.consumeToBytes({readable:await this.stream()})},async json(){return await Jo.consumeToJson({readable:await this.stream()})},async text(){return await Jo.consumeToText({readable:await this.stream()})},async stream(){if(e._encodedData?e._readableStream=Jo.fromWebReadable({readableStream:e._encodedData.stream()}):Jo.isReadable({readable:e._readableStream})||(e._readableStream=e._remoteOrigin?await e.readRecordData({target:e._remoteOrigin,isRemote:!0}):await e.readRecordData({target:e._connectedDid,isRemote:!1})),!e._readableStream)throw new Error("Record data is not available.");return e._readableStream},then(n,i){return this.stream().then(n,i)},catch(n){return this.stream().catch(n)}}}async store(e=!1){return this.processRecord({signAsOwner:e,store:!0})}async import(e=!0){return this.processRecord({store:e,signAsOwner:!0})}async send(e){let r=this._initialWrite;if(e??=this._connectedDid,r&&!j_._sendCache.check(this._recordId,e)){let o={...r};A_(o),await this._agent.sendDwnRequest({messageType:Ie.RecordsWrite,author:this._connectedDid,target:e,rawMessage:o}),j_._sendCache.set(this._recordId,e)}let n;this.deleted?n={messageType:Ie.RecordsDelete,author:this._connectedDid,target:e,rawMessage:{...this.rawMessage}}:n={messageType:Ie.RecordsWrite,author:this._connectedDid,target:e,dataStream:await this.data.blob(),rawMessage:{...this.rawMessage}};let{reply:i}=await this._agent.sendDwnRequest(n);return i}toJSON(){return{attestation:this.attestation,author:this.author,authorization:this.authorization,contextId:this.contextId,dataCid:this.dataCid,dataFormat:this.dataFormat,dataSize:this.dataSize,dateCreated:this.dateCreated,messageTimestamp:this.dateModified,datePublished:this.datePublished,encryption:this.encryption,parentId:this.parentId,protocol:this.protocol,protocolPath:this.protocolPath,protocolRole:this.protocolRole,published:this.published,recipient:this.recipient,recordId:this.id,schema:this.schema,tags:this.tags}}toString(){let e=`Record: { `;return e+=` ID: ${this.id} `,e+=this.contextId?` Context ID: ${this.contextId} `:"",e+=this.protocol?` Protocol: ${this.protocol} @@ -2077,7 +2077,7 @@ zoo`.split(` `),e+=` Deleted: ${this.deleted} `,e+=` Created: ${this.dateCreated} `,e+=` Modified: ${this.dateModified} -`,e+="}",e}async paginationCursor(e){return pD(Ie.RecordsWrite,this.rawMessage)?t1e(this.rawMessage,e):void 0}async update({dateModified:e,data:r,...n}){if(this.deleted)throw new Error("Record: Cannot revive a deleted record.");let{parentId:i,...o}=this._recordsWriteDescriptor,s=i?this._contextId.split("/").slice(0,-1).join("/"):void 0,a={...o,...n,parentContextId:s,messageTimestamp:e,recordId:this._recordId};(WR(a.tags)||a.tags===null)&&delete a.tags;let d;r!==void 0&&(delete a.dataCid,delete a.dataSize,{dataBlob:d}=D5(r,a.dataFormat));let u=new Set(["data","dataCid","dataFormat","dataSize","datePublished","messageTimestamp","published","tags"]);O_.verifyPermittedMutation(Object.keys(n),u),n.published===!1&&a.datePublished!==void 0&&delete a.datePublished;let c={author:this._connectedDid,dataStream:d,messageParams:{...a},messageType:Ie.RecordsWrite,target:this._connectedDid};if(this._delegateDid){let{message:v}=await this._permissionsApi.getPermissionForRequest({connectedDid:this._connectedDid,delegateDid:this._delegateDid,protocol:this.protocol,delegate:!0,cached:!0,messageType:c.messageType});c.messageParams.delegatedGrant=v,c.granteeDid=this._delegateDid}let l=await this._agent.processDwnRequest(c),{message:p,reply:{status:m}}=l,g=p;return 200<=m.code&&m.code<=299&&(this._initialWrite||(this._initialWrite={...this.rawMessage}),this._authorization=g.authorization,this._protocolRole=n.protocolRole,u.forEach(v=>{this._descriptor[v]=g.descriptor[v]}),r!==void 0&&(this._encodedData=d)),{status:m}}async delete(e){let{store:r=!0,signAsOwner:n,dateModified:i,prune:o=!1}=e||{},s=n&&this._delegateDid===void 0,a=n&&this._delegateDid!==void 0;if(this.deleted&&!this._initialWrite)throw new Error("Record: Record is in an invalid state, initial write is missing.");this._initialWrite||(this._initialWrite={...this.rawMessage}),await this.processInitialWriteIfNeeded({store:r,signAsOwner:n});let d={messageType:Ie.RecordsDelete,author:this._connectedDid,target:this._connectedDid,signAsOwner:s,signAsOwnerDelegate:a,store:r};if(this.deleted?d.rawMessage=this.rawMessage:d.messageParams={prune:o,recordId:this._recordId,messageTimestamp:i},this._delegateDid){let{message:p}=await this._permissionsApi.getPermissionForRequest({connectedDid:this._connectedDid,delegateDid:this._delegateDid,protocol:this.protocol,delegate:!0,cached:!0,messageType:d.messageType});d.messageParams={...d.messageParams,delegatedGrant:p},d.granteeDid=this._delegateDid}let u=await this._agent.processDwnRequest(d),{message:c,reply:{status:l}}=u;return l.code!==202?{status:l}:(this._author=Lf(c),this._descriptor=c.descriptor,this._authorization=c.authorization,this._encodedData=void 0,this._encryption=void 0,this._attestation=void 0,this._contextId=void 0,{status:l})}async processInitialWriteIfNeeded({store:e,signAsOwner:r}){if(this.initialWrite&&(r&&!this._initialWriteSigned||e&&!this._initialWriteStored)){let n=r&&this._delegateDid===void 0,i=r&&this._delegateDid!==void 0,o={messageType:Ie.RecordsWrite,rawMessage:this.initialWrite,author:this._connectedDid,target:this._connectedDid,signAsOwner:n,signAsOwnerDelegate:i,store:e};if(this._delegateDid){let{message:c}=await this._permissionsApi.getPermissionForRequest({connectedDid:this._connectedDid,delegateDid:this._delegateDid,protocol:this.protocol,delegate:!0,cached:!0,messageType:o.messageType});o.messageParams={...o.messageParams,delegatedGrant:c},o.granteeDid=this._delegateDid}let s=await this._agent.processDwnRequest(o),{message:a,reply:{status:d}}=s,u=a;200<=d.code&&d.code<=299&&(e&&(this._initialWriteStored=!0),r&&(this._initialWriteSigned=!0,this.initialWrite.authorization=u.authorization))}}async processRecord({store:e,signAsOwner:r}){let n=r&&this._delegateDid===void 0,i=r&&this._delegateDid!==void 0;await this.processInitialWriteIfNeeded({store:e,signAsOwner:r});let o;if(this.deleted?o={messageType:Ie.RecordsDelete,rawMessage:this.rawMessage,author:this._connectedDid,target:this._connectedDid,signAsOwner:n,signAsOwnerDelegate:i,store:e}:o={messageType:Ie.RecordsWrite,rawMessage:this.rawMessage,author:this._connectedDid,target:this._connectedDid,dataStream:await this.data.blob(),signAsOwner:n,signAsOwnerDelegate:i,store:e},this._delegateDid){let{message:c}=await this._permissionsApi.getPermissionForRequest({connectedDid:this._connectedDid,delegateDid:this._delegateDid,protocol:this.protocol,delegate:!0,cached:!0,messageType:o.messageType});o.messageParams={...o.messageParams,delegatedGrant:c},o.granteeDid=this._delegateDid}let s=await this._agent.processDwnRequest(o),{message:a,reply:{status:d}}=s,u=a;return 200<=d.code&&d.code<=299&&r&&(this._authorization=u.authorization),{status:d}}async readRecordData({target:e,isRemote:r}){let n={author:this._connectedDid,messageParams:{filter:{recordId:this.id}},messageType:Ie.RecordsRead,target:e};if(this._delegateDid)try{let{message:o}=await this._permissionsApi.getPermissionForRequest({connectedDid:this._connectedDid,delegateDid:this._delegateDid,protocol:this.protocol,delegate:!0,cached:!0,messageType:n.messageType});n.messageParams={...n.messageParams,delegatedGrant:o},n.granteeDid=this._delegateDid}catch{n.author=this._delegateDid}let i=r?this._agent.sendDwnRequest(n):this._agent.processDwnRequest(n);try{let{reply:{status:o,record:s}}=await i;if(o.code!==200)throw new Error(`${o.code}: ${o.detail}`);let a=s.data;return Eb.isReadableStream(a)?Jo.fromWebReadable({readableStream:a}):a}catch(o){throw new Error(`Error encountered while attempting to read data: ${o.message}`)}}static verifyPermittedMutation(e,r){for(let n of e)if(!r.has(n))throw new Error(`${n} is an immutable property. Its value cannot be changed.`)}isRecordsDeleteDescriptor(e){return e.interface+e.method===Ie.RecordsDelete}};O_._sendCache=R5;var Up=O_;f();var C_=class{constructor(e,r,n){this._agent=e,this._metadata=n,this._protocolsConfigureMessage=r}get definition(){return this._protocolsConfigureMessage.descriptor.definition}toJSON(){return this._protocolsConfigureMessage}async send(e){let{reply:r}=await this._agent.sendDwnRequest({author:this._metadata.author,messageCid:this._metadata.messageCid,messageType:Ie.ProtocolsConfigure,target:e});return{status:r.status}}};f();f();var B5=class t{constructor(e,r){this._permissions=e,this._connectedDid=r.connectedDid,this._message=r.message}get author(){return Lf(this._message)}static async parse({connectedDid:e,agent:r,message:n}){let i=new Qi({agent:r});return new t(i,{connectedDid:e,message:n})}get agent(){return this._permissions.agent}get rawMessage(){return this._message}async send(e){e??=this._connectedDid;let{encodedData:r,...n}=this._message,i=new Blob([ae.base64Url(r).toUint8Array()]),o={messageType:Ie.RecordsWrite,author:this._connectedDid,target:e,dataStream:i,rawMessage:n},{reply:s}=await this.agent.sendDwnRequest(o);return s}async store(e){let{encodedData:r,...n}=this.rawMessage,i=new Blob([ae.base64Url(r).toUint8Array()]),{reply:o,message:s}=await this.agent.processDwnRequest({author:this._connectedDid,target:this._connectedDid,messageType:Ie.RecordsWrite,signAsOwner:e,rawMessage:n,dataStream:i});return this._message={...s,encodedData:r},{status:o.status}}};var Kf=class t{constructor({api:e,connectedDid:r,message:n,grant:i}){this._permissions=e,this._connectedDid=r,this._message=n,this._grant=i}static async parse(e){let r=await yn.parse(e.message),n=new Qi({agent:e.agent});return new t({...e,grant:r,api:n})}get agent(){return this._permissions.agent}get id(){return this._grant.id}get grantor(){return this._grant.grantor}get grantee(){return this._grant.grantee}get dateGranted(){return this._grant.dateGranted}get description(){return this._grant.description}get requestId(){return this._grant.requestId}get dateExpires(){return this._grant.dateExpires}get delegated(){return this._grant.delegated}get scope(){return this._grant.scope}get conditions(){return this._grant.conditions}get rawMessage(){return this._message}async send(e){e??=this._connectedDid;let{encodedData:r,...n}=this._message,i=new Blob([ae.base64Url(r).toUint8Array()]),o={messageType:Ie.RecordsWrite,author:this._connectedDid,target:e,dataStream:i,rawMessage:n},{reply:s}=await this.agent.sendDwnRequest(o);return s}async store(e=!1){let{encodedData:r,...n}=this.rawMessage,i=new Blob([ae.base64Url(r).toUint8Array()]),{reply:o,message:s}=await this.agent.processDwnRequest({store:!0,author:this._connectedDid,target:this._connectedDid,messageType:Ie.RecordsWrite,signAsOwner:e,rawMessage:n,dataStream:i});return this._message={...s,encodedData:r},{status:o.status}}async import(e=!1){let{encodedData:r,...n}=this.rawMessage,i=new Blob([ae.base64Url(r).toUint8Array()]),{reply:o,message:s}=await this.agent.processDwnRequest({store:e,author:this._connectedDid,target:this._connectedDid,messageType:Ie.RecordsWrite,signAsOwner:!0,rawMessage:n,dataStream:i});return this._message={...s,encodedData:r},{status:o.status}}async revoke(e=!0){let r=await this._permissions.createRevocation({store:e,author:this._connectedDid,grant:this._grant});return B5.parse({connectedDid:this._connectedDid,agent:this.agent,message:r.message})}isRevoked(e=!1){return this._permissions.isGrantRevoked({author:this._connectedDid,target:this.grantor,grantRecordId:this.id,remote:e})}toJSON(){return{id:this.id,grantor:this.grantor,grantee:this.grantee,dateGranted:this.dateGranted,description:this.description,requestId:this.requestId,dateExpires:this.dateExpires,delegated:this.delegated,scope:this.scope,conditions:this.conditions}}};f();var $_=class t{constructor({api:e,connectedDid:r,message:n,request:i}){this._permissions=e,this._connectedDid=r,this._request=i,this._message=n}static async parse({connectedDid:e,agent:r,message:n}){let i=await Gu.parse(n),o=new Qi({agent:r});return new t({api:o,connectedDid:e,message:n,request:i})}get agent(){return this._permissions.agent}get id(){return this._request.id}get requester(){return this._request.requester}get description(){return this._request.description}get delegated(){return this._request.delegated}get scope(){return this._request.scope}get conditions(){return this._request.conditions}get rawMessage(){return this._message}async send(e){e??=this._connectedDid;let{encodedData:r,...n}=this._message,i=new Blob([ae.base64Url(r).toUint8Array()]),o={messageType:Ie.RecordsWrite,author:this._connectedDid,target:e,dataStream:i,rawMessage:n},{reply:s}=await this.agent.sendDwnRequest(o);return s}async store(){let{encodedData:e,...r}=this.rawMessage,n=new Blob([ae.base64Url(e).toUint8Array()]),{reply:i,message:o}=await this.agent.processDwnRequest({author:this._connectedDid,target:this._connectedDid,messageType:Ie.RecordsWrite,rawMessage:r,dataStream:n});return this._message={...o,encodedData:e},{status:i.status}}async grant(e,r=!0){let{message:n}=await this._permissions.createGrant({requestId:this.id,grantedTo:this.requester,scope:this.scope,delegated:this.delegated,author:this._connectedDid,store:r,dateExpires:e});return Kf.parse({connectedDid:this._connectedDid,agent:this.agent,message:n})}toJSON(){return this._request}};f();var PD=class{static recordSubscriptionHandler({agent:e,connectedDid:r,request:n,delegateDid:i,permissionsApi:o}){let{subscriptionHandler:s,from:a}=n;return async d=>{let{message:u,initialWrite:c}=d,p={author:Lf(u),connectedDid:r,remoteOrigin:a,initialWrite:c},m=new Up(e,{...u,...p,delegateDid:i},o);s(m)}}};var M5=class{constructor(e){this.agent=e.agent,this.connectedDid=e.connectedDid,this.delegateDid=e.delegateDid,this.permissionsApi=new Qi({agent:this.agent})}get permissions(){return{request:async e=>{let{message:r}=await this.permissionsApi.createRequest({...e,author:this.delegateDid??this.connectedDid}),n={connectedDid:this.delegateDid??this.connectedDid,agent:this.agent,message:r};return await $_.parse(n)},grant:async e=>{let{message:r}=await this.permissionsApi.createGrant({...e,author:this.delegateDid??this.connectedDid}),n={connectedDid:this.delegateDid??this.connectedDid,agent:this.agent,message:r};return await Kf.parse(n)},queryRequests:async(e={})=>{let{from:r,...n}=e,i=await this.permissionsApi.fetchRequests({...n,author:this.delegateDid??this.connectedDid,target:r??this.delegateDid??this.connectedDid,remote:r!==void 0}),o=[];for(let s of i){let a={connectedDid:this.delegateDid??this.connectedDid,agent:this.agent,message:s.message};o.push(await $_.parse(a))}return o},queryGrants:async(e={})=>{let{checkRevoked:r,from:n,...i}=e,o=n!==void 0,s=this.delegateDid??this.connectedDid,a=n??this.delegateDid??this.connectedDid,d=await this.permissionsApi.fetchGrants({...i,author:s,target:a,remote:o}),u=[];for(let c of d){let l={connectedDid:this.delegateDid??this.connectedDid,agent:this.agent,message:c.message};if(r){let p=c.grant.id;if(await this.permissionsApi.isGrantRevoked({author:s,target:a,grantRecordId:p,remote:o}))continue}u.push(await Kf.parse(l))}return u}}}get protocols(){return{configure:async e=>{let r={author:this.connectedDid,messageParams:e.message,messageType:Ie.ProtocolsConfigure,target:this.connectedDid};if(this.delegateDid){let{message:d}=await this.permissionsApi.getPermissionForRequest({connectedDid:this.connectedDid,delegateDid:this.delegateDid,protocol:e.message.definition.protocol,delegate:!0,cached:!0,messageType:r.messageType});r.messageParams={...r.messageParams,delegatedGrant:d},r.granteeDid=this.delegateDid}let n=await this.agent.processDwnRequest(r),{message:i,messageCid:o,reply:{status:s}}=n,a={status:s};if(s.code<300){let d={author:this.connectedDid,messageCid:o};a.protocol=new C_(this.agent,i,d)}return a},query:async e=>{let r={author:this.connectedDid,messageParams:e.message,messageType:Ie.ProtocolsQuery,target:e.from||this.connectedDid};if(this.delegateDid)try{let{grant:{id:d}}=await this.permissionsApi.getPermissionForRequest({connectedDid:this.connectedDid,delegateDid:this.delegateDid,protocol:e.message.filter.protocol,cached:!0,messageType:r.messageType});r.messageParams={...r.messageParams,permissionGrantId:d},r.granteeDid=this.delegateDid}catch{r.author=this.delegateDid}let n;e.from?n=await this.agent.sendDwnRequest(r):n=await this.agent.processDwnRequest(r);let i=n.reply,{entries:o=[],status:s}=i;return{protocols:o.map(d=>{let u={author:this.connectedDid};return new C_(this.agent,d,u)}),status:s}}}}get records(){return{create:async e=>this.records.write(e),createFrom:async e=>{let{author:r,...n}=e.record.toJSON();return e.data!==void 0&&(delete n.dataCid,delete n.dataSize),e.message?.published===!1&&n.datePublished!==void 0&&(delete n.datePublished,delete n.published),(!WR(e.message)||e.author&&e.author!==r)&&delete n.recordId,this.records.write({data:e.data,message:{...n,...e.message}})},delete:async e=>{let r={author:this.connectedDid,messageParams:e.message,messageType:Ie.RecordsDelete,target:e.from||this.connectedDid};if(this.delegateDid){let{message:o}=await this.permissionsApi.getPermissionForRequest({connectedDid:this.connectedDid,delegateDid:this.delegateDid,protocol:e.protocol,delegate:!0,cached:!0,messageType:r.messageType});r.messageParams={...r.messageParams,delegatedGrant:o},r.granteeDid=this.delegateDid}let n;e.from?n=await this.agent.sendDwnRequest(r):n=await this.agent.processDwnRequest(r);let{reply:{status:i}}=n;return{status:i}},query:async e=>{let r={author:this.connectedDid,messageParams:e.message,messageType:Ie.RecordsQuery,target:e.from||this.connectedDid};if(this.delegateDid)try{let{message:u}=await this.permissionsApi.getPermissionForRequest({connectedDid:this.connectedDid,delegateDid:this.delegateDid,protocol:e.protocol,delegate:!0,cached:!0,messageType:r.messageType});r.messageParams={...r.messageParams,delegatedGrant:u},r.granteeDid=this.delegateDid}catch{r.author=this.delegateDid}let n;e.from?n=await this.agent.sendDwnRequest(r):n=await this.agent.processDwnRequest(r);let i=n.reply,{entries:o=[],status:s,cursor:a}=i;return{records:o.map(u=>{let c={author:Lf(u),connectedDid:this.connectedDid,remoteOrigin:e.from,delegateDid:this.delegateDid,...u};return new Up(this.agent,c,this.permissionsApi)}),status:s,cursor:a}},read:async e=>{let r={author:this.connectedDid,messageParams:e.message,messageType:Ie.RecordsRead,target:e.from||this.connectedDid};if(this.delegateDid)try{let{message:a}=await this.permissionsApi.getPermissionForRequest({connectedDid:this.connectedDid,delegateDid:this.delegateDid,protocol:e.protocol,delegate:!0,cached:!0,messageType:r.messageType});r.messageParams={...r.messageParams,delegatedGrant:a},r.granteeDid=this.delegateDid}catch{r.author=this.delegateDid}let n;e.from?n=await this.agent.sendDwnRequest(r):n=await this.agent.processDwnRequest(r);let{reply:{record:i,status:o}}=n,s;if(200<=o.code&&o.code<=299){let a={author:Lf(i),connectedDid:this.connectedDid,remoteOrigin:e.from,delegateDid:this.delegateDid,...i};s=new Up(this.agent,a,this.permissionsApi)}return{record:s,status:o}},subscribe:async e=>{let r={author:this.connectedDid,messageParams:e.message,messageType:Ie.RecordsSubscribe,target:e.from||this.connectedDid,subscriptionHandler:PD.recordSubscriptionHandler({agent:this.agent,connectedDid:this.connectedDid,delegateDid:this.delegateDid,permissionsApi:this.permissionsApi,request:e})};if(this.delegateDid)try{let{message:a}=await this.permissionsApi.getPermissionForRequest({connectedDid:this.connectedDid,delegateDid:this.delegateDid,protocol:e.protocol,delegate:!0,cached:!0,messageType:r.messageType});r.messageParams={...r.messageParams,delegatedGrant:a},r.granteeDid=this.delegateDid}catch{r.author=this.delegateDid}let n;e.from?n=await this.agent.sendDwnRequest(r):n=await this.agent.processDwnRequest(r);let i=n.reply,{status:o,subscription:s}=i;return{status:o,subscription:s}},write:async e=>{let{dataBlob:r,dataFormat:n}=D5(e.data,e.message?.dataFormat),i={store:e.store,messageType:Ie.RecordsWrite,messageParams:{...e.message,dataFormat:n},author:this.connectedDid,target:this.connectedDid,dataStream:r};if(this.delegateDid){let{message:u}=await this.permissionsApi.getPermissionForRequest({connectedDid:this.connectedDid,delegateDid:this.delegateDid,protocol:e.message.protocol,delegate:!0,cached:!0,messageType:i.messageType});i.messageParams={...i.messageParams,delegatedGrant:u},i.granteeDid=this.delegateDid}let o=await this.agent.processDwnRequest(i),{message:s,reply:{status:a}}=o,d;if(200<=a.code&&a.code<=299){let u={author:this.connectedDid,connectedDid:this.connectedDid,encodedData:r,delegateDid:this.delegateDid,...s};d=new Up(this.agent,u,this.permissionsApi)}return{record:d,status:a}}}}};f();var O5=class{constructor(e){this.agent=e.agent,this.connectedDid=e.connectedDid}async create(){throw new Error("Not implemented.")}};f();f();f();var Ff=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},ID=class t{constructor(e){this._agentDid=e.agentDid,this.crypto=e.cryptoApi,this.did=e.didApi,this.dwn=e.dwnApi,this.identity=e.identityApi,this.keyManager=e.keyManager,this.permissions=e.permissionsApi,this.rpc=e.rpcClient,this.sync=e.syncApi,this.vault=e.agentVault,this.did.agent=this,this.dwn.agent=this,this.identity.agent=this,this.keyManager.agent=this,this.permissions.agent=this,this.sync.agent=this}get agentDid(){if(this._agentDid===void 0)throw new Error('Web5UserAgent: The "agentDid" property is not set. Ensure the agent is properly initialized and a DID is assigned.');return this._agentDid}set agentDid(e){this._agentDid=e}static create({dataPath:e="DATA/AGENT",agentDid:r,agentVault:n,cryptoApi:i,didApi:o,dwnApi:s,identityApi:a,keyManager:d,permissionsApi:u,rpcClient:c,syncApi:l}={}){return Ff(this,void 0,void 0,function*(){return n??(n=new b5({keyDerivationWorkFactor:21e4,store:new G3({location:`${e}/VAULT_STORE`})})),i??(i=new ld),o??(o=new u5({didMethods:[du,Wa],resolverCache:new Pb({location:`${e}/DID_RESOLVERCACHE`}),store:new c5})),s??(s=new R_({dwn:yield R_.createDwn({dataPath:e,didResolver:o})})),a??(a=new x5({store:new w5})),d??(d=new uu({keyStore:new h5})),u??(u=new Qi),c??(c=new T5),l??(l=new P5({syncEngine:new I5({dataPath:e})})),new t({agentDid:r,agentVault:n,cryptoApi:i,didApi:o,dwnApi:s,keyManager:d,permissionsApi:u,identityApi:a,rpcClient:c,syncApi:l})})}firstLaunch(){return Ff(this,void 0,void 0,function*(){return(yield this.vault.isInitialized())===!1})}initialize({password:e,recoveryPhrase:r,dwnEndpoints:n}){return Ff(this,void 0,void 0,function*(){return r=yield this.vault.initialize({password:e,recoveryPhrase:r,dwnEndpoints:n}),r})}processDidRequest(e){return Ff(this,void 0,void 0,function*(){return this.did.processRequest(e)})}processDwnRequest(e){return Ff(this,void 0,void 0,function*(){return this.dwn.processRequest(e)})}processVcRequest(e){return Ff(this,void 0,void 0,function*(){throw new Error("Not implemented")})}sendDidRequest(e){return Ff(this,void 0,void 0,function*(){throw new Error("Not implemented")})}sendDwnRequest(e){return Ff(this,void 0,void 0,function*(){return this.dwn.sendRequest(e)})}sendVcRequest(e){return Ff(this,void 0,void 0,function*(){throw new Error("Not implemented")})}start({password:e}){return Ff(this,void 0,void 0,function*(){this.vault.isLocked()&&(yield this.vault.unlock({password:e})),this.agentDid=yield this.vault.getDid()})}};var $z=class t{constructor({agent:e,connectedDid:r,delegateDid:n}){this.agent=e,this.did=new k5({agent:e,connectedDid:r}),this.dwn=new M5({agent:e,connectedDid:r,delegateDid:n}),this.vc=new O5({agent:e,connectedDid:r})}static async connect({agent:e,agentVault:r,connectedDid:n,password:i,recoveryPhrase:o,sync:s,techPreview:a,didCreateOptions:d,registration:u,walletConnectOptions:c}={}){let l;if(e===void 0){let m=!1,g=await ID.create({agentVault:r});e=g,i===void 0&&(i="insecure-static-phrase",console.warn("%cSECURITY WARNING:%c You have not set a password, which defaults to a static, guessable value. This significantly compromises the security of your data. Please configure a secure, unique password.","font-weight: bold; color: red;","font-weight: normal; color: inherit;"));let v=a?.dwnEndpoints??d?.dwnEndpoints??["https://dwn.tbddev.org/beta"];await g.firstLaunch()&&(o=await g.initialize({password:i,recoveryPhrase:o,dwnEndpoints:v})),await g.start({password:i});let x=await g.identity.connectedIdentity(),S,P=[];if(x)S=x;else if(c){if(s==="off")throw new Error("Sync must not be disabled when using WalletConnect");m=!0;try{let{permissionRequests:A,...$}=c,j=A.map(({protocolDefinition:W,permissions:q})=>Oz.createPermissionRequestForProtocol({definition:W,permissions:q??["read","write","delete","query","subscribe"]})),{delegatePortableDid:L,connectedDid:F,delegateGrants:K}=await Oz.initClient({...$,permissionRequests:j});S=await g.identity.import({portableIdentity:{portableDid:L,metadata:{connectedDid:F,name:"Default",tenant:L.uri,uri:L.uri}}}),await g.identity.manage({portableIdentity:await S.export()}),P=await this.processConnectedGrants({agent:e,delegateDid:L.uri,grants:K})}catch(A){throw await this.cleanUpIdentity({identity:S,userAgent:g}),new Error(`Failed to connect to wallet: ${A.message}`)}}else{let A=await g.identity.list();A.length===0?(m=!0,S=await g.identity.create({didMethod:"dht",metadata:{name:"Default"},didOptions:{services:[{id:"dwn",type:"DecentralizedWebNode",serviceEndpoint:v,enc:"#enc",sig:"#sig"}],verificationMethods:[{algorithm:"Ed25519",id:"sig",purposes:["assertionMethod","authentication"]},{algorithm:"secp256k1",id:"enc",purposes:["keyAgreement"]}]}}),await g.identity.manage({portableIdentity:await S.export()})):S=A[0]}if(n=S.metadata.connectedDid??S.did.uri,l=S.metadata.connectedDid?S.did.uri:void 0,u!==void 0)try{for(let A of v)(await g.rpc.getServerInfo(A)).registrationRequirements.length!==0&&(await l5.registerTenant(A,e.agentDid.uri),await l5.registerTenant(A,n));u.onSuccess()}catch(A){u.onFailure(A)}s!=="off"&&(m&&(await g.sync.registerIdentity({did:n,options:{delegateDid:l,protocols:P}}),c!==void 0&&await g.sync.sync("pull")),s??="2m",g.sync.startSync({interval:s}).catch(A=>{console.error(`Sync failed: ${A}`)}))}return{web5:new t({agent:e,connectedDid:n,delegateDid:l}),did:n,delegateDid:l,recoveryPhrase:o}}static async cleanUpIdentity({identity:e,userAgent:r}){try{await r.did.delete({didUri:e.did.uri,tenant:e.metadata.tenant,deleteKey:!0})}catch(n){console.error(`Failed to delete DID ${e.did.uri}: ${n.message}`)}try{await r.identity.delete({didUri:e.did.uri})}catch(n){console.error(`Failed to delete Identity ${e.metadata.name}: ${n.message}`)}}static async processConnectedGrants({grants:e,agent:r,delegateDid:n}){let i=new Set;for(let o of e){let s=await Kf.parse({connectedDid:n,agent:r,message:o}),{status:a}=await s.store(!0);if(a.code!==202)throw new Error(`AgentDwnApi: Failed to process connected grant: ${a.detail}`);let d=s.scope.protocol;d&&i.add(d)}return[...i]}};return J1e(nit);})(); +`,e+="}",e}async paginationCursor(e){return bD(Ie.RecordsWrite,this.rawMessage)?c1e(this.rawMessage,e):void 0}async update({dateModified:e,data:r,protocolRole:n,store:i=!0,...o}){if(this.deleted)throw new Error("Record: Cannot revive a deleted record.");let{parentId:s,...a}=this._recordsWriteDescriptor,d=s?this._contextId.split("/").slice(0,-1).join("/"):void 0,u={...a,...o,parentContextId:d,protocolRole:n??this._protocolRole,messageTimestamp:e,recordId:this._recordId};(YR(u.tags)||u.tags===null)&&delete u.tags;let c;r!==void 0&&(delete u.dataCid,delete u.dataSize,{dataBlob:c}=$5(r,u.dataFormat));let l=new Set(["data","dataCid","dataFormat","dataSize","datePublished","messageTimestamp","published","tags"]);j_.verifyPermittedMutation(Object.keys(o),l),o.published===!1&&u.datePublished!==void 0&&delete u.datePublished;let p={author:this._connectedDid,dataStream:c,messageParams:{...u},messageType:Ie.RecordsWrite,target:this._connectedDid,store:i};if(this._delegateDid){let{message:S}=await this._permissionsApi.getPermissionForRequest({connectedDid:this._connectedDid,delegateDid:this._delegateDid,protocol:this.protocol,delegate:!0,cached:!0,messageType:p.messageType});p.messageParams.delegatedGrant=S,p.granteeDid=this._delegateDid}let m=await this._agent.processDwnRequest(p),{message:g,reply:{status:v}}=m,x=g;return 200<=v.code&&v.code<=299&&(this._initialWrite||(this._initialWrite={...this.rawMessage}),this._authorization=x.authorization,this._protocolRole=u.protocolRole,l.forEach(S=>{this._descriptor[S]=x.descriptor[S]}),r!==void 0&&(this._encodedData=c)),{status:v}}async delete(e){let{store:r=!0,signAsOwner:n,dateModified:i,prune:o=!1}=e||{},s=n&&this._delegateDid===void 0,a=n&&this._delegateDid!==void 0;if(this.deleted&&!this._initialWrite)throw new Error("Record: Record is in an invalid state, initial write is missing.");this._initialWrite||(this._initialWrite={...this.rawMessage}),await this.processInitialWriteIfNeeded({store:r,signAsOwner:n});let d={messageType:Ie.RecordsDelete,author:this._connectedDid,target:this._connectedDid,signAsOwner:s,signAsOwnerDelegate:a,store:r},u=e?.protocolRole?a1e(this.rawMessage)!==e.protocolRole:!1;if(this.deleted&&!u?d.rawMessage=this.rawMessage:d.messageParams={prune:o,recordId:this._recordId,messageTimestamp:i,protocolRole:e?.protocolRole??this._protocolRole},this._delegateDid){let{message:m}=await this._permissionsApi.getPermissionForRequest({connectedDid:this._connectedDid,delegateDid:this._delegateDid,protocol:this.protocol,delegate:!0,cached:!0,messageType:d.messageType});d.messageParams={...d.messageParams,delegatedGrant:m},d.granteeDid=this._delegateDid}let c=await this._agent.processDwnRequest(d),{message:l,reply:{status:p}}=c;return p.code!==202?{status:p}:(this._author=Kf(l),this._descriptor=l.descriptor,this._authorization=l.authorization,this._encodedData=void 0,this._encryption=void 0,this._attestation=void 0,this._contextId=void 0,{status:p})}async processInitialWriteIfNeeded({store:e,signAsOwner:r}){if(this.initialWrite&&(r&&!this._initialWriteSigned||e&&!this._initialWriteStored)){let n=r&&this._delegateDid===void 0,i=r&&this._delegateDid!==void 0,o={messageType:Ie.RecordsWrite,rawMessage:this.initialWrite,author:this._connectedDid,target:this._connectedDid,signAsOwner:n,signAsOwnerDelegate:i,store:e};if(this._delegateDid){let{message:c}=await this._permissionsApi.getPermissionForRequest({connectedDid:this._connectedDid,delegateDid:this._delegateDid,protocol:this.protocol,delegate:!0,cached:!0,messageType:o.messageType});o.messageParams={...o.messageParams,delegatedGrant:c},o.granteeDid=this._delegateDid}let s=await this._agent.processDwnRequest(o),{message:a,reply:{status:d}}=s,u=a;200<=d.code&&d.code<=299&&(e&&(this._initialWriteStored=!0),r&&(this._initialWriteSigned=!0,this.initialWrite.authorization=u.authorization))}}async processRecord({store:e,signAsOwner:r}){let n=r&&this._delegateDid===void 0,i=r&&this._delegateDid!==void 0;await this.processInitialWriteIfNeeded({store:e,signAsOwner:r});let o;if(this.deleted?o={messageType:Ie.RecordsDelete,rawMessage:this.rawMessage,author:this._connectedDid,target:this._connectedDid,signAsOwner:n,signAsOwnerDelegate:i,store:e}:o={messageType:Ie.RecordsWrite,rawMessage:this.rawMessage,author:this._connectedDid,target:this._connectedDid,dataStream:await this.data.blob(),signAsOwner:n,signAsOwnerDelegate:i,store:e},this._delegateDid){let{message:c}=await this._permissionsApi.getPermissionForRequest({connectedDid:this._connectedDid,delegateDid:this._delegateDid,protocol:this.protocol,delegate:!0,cached:!0,messageType:o.messageType});o.messageParams={...o.messageParams,delegatedGrant:c},o.granteeDid=this._delegateDid}let s=await this._agent.processDwnRequest(o),{message:a,reply:{status:d}}=s,u=a;return 200<=d.code&&d.code<=299&&r&&(this._authorization=u.authorization),{status:d}}async readRecordData({target:e,isRemote:r}){let n={author:this._connectedDid,messageParams:{filter:{recordId:this.id},protocolRole:this._protocolRole},messageType:Ie.RecordsRead,target:e};if(this._delegateDid)try{let{message:o}=await this._permissionsApi.getPermissionForRequest({connectedDid:this._connectedDid,delegateDid:this._delegateDid,protocol:this.protocol,delegate:!0,cached:!0,messageType:n.messageType});n.messageParams={...n.messageParams,delegatedGrant:o},n.granteeDid=this._delegateDid}catch{n.author=this._delegateDid}let i=r?this._agent.sendDwnRequest(n):this._agent.processDwnRequest(n);try{let{reply:{status:o,entry:s}}=await i;if(o.code!==200)throw new Error(`${o.code}: ${o.detail}`);let a=s.data;return Sb.isReadableStream(a)?Jo.fromWebReadable({readableStream:a}):a}catch(o){throw new Error(`Error encountered while attempting to read data: ${o.message}`)}}static verifyPermittedMutation(e,r){for(let n of e)if(!r.has(n))throw new Error(`${n} is an immutable property. Its value cannot be changed.`)}isRecordsDeleteDescriptor(e){return e.interface+e.method===Ie.RecordsDelete}};j_._sendCache=C5;var Lp=j_;f();var N_=class{constructor(e,r,n){this._agent=e,this._metadata=n,this._protocolsConfigureMessage=r}get definition(){return this._protocolsConfigureMessage.descriptor.definition}toJSON(){return this._protocolsConfigureMessage}async send(e){let{reply:r}=await this._agent.sendDwnRequest({author:this._metadata.author,messageCid:this._metadata.messageCid,messageType:Ie.ProtocolsConfigure,target:e});return{status:r.status}}};f();f();var j5=class t{constructor(e,r){this._permissions=e,this._connectedDid=r.connectedDid,this._message=r.message}get author(){return Kf(this._message)}static async parse({connectedDid:e,agent:r,message:n}){let i=new eo({agent:r});return new t(i,{connectedDid:e,message:n})}get agent(){return this._permissions.agent}get rawMessage(){return this._message}async send(e){e??=this._connectedDid;let{encodedData:r,...n}=this._message,i=new Blob([ae.base64Url(r).toUint8Array()]),o={messageType:Ie.RecordsWrite,author:this._connectedDid,target:e,dataStream:i,rawMessage:n},{reply:s}=await this.agent.sendDwnRequest(o);return s}async store(e){let{encodedData:r,...n}=this.rawMessage,i=new Blob([ae.base64Url(r).toUint8Array()]),{reply:o,message:s}=await this.agent.processDwnRequest({author:this._connectedDid,target:this._connectedDid,messageType:Ie.RecordsWrite,signAsOwner:e,rawMessage:n,dataStream:i});return this._message={...s,encodedData:r},{status:o.status}}};var Ff=class t{constructor({api:e,connectedDid:r,message:n,grant:i}){this._permissions=e,this._connectedDid=r,this._message=n,this._grant=i}static async parse(e){let r=await gn.parse(e.message),n=new eo({agent:e.agent});return new t({...e,grant:r,api:n})}get agent(){return this._permissions.agent}get id(){return this._grant.id}get grantor(){return this._grant.grantor}get grantee(){return this._grant.grantee}get dateGranted(){return this._grant.dateGranted}get description(){return this._grant.description}get requestId(){return this._grant.requestId}get dateExpires(){return this._grant.dateExpires}get delegated(){return this._grant.delegated}get scope(){return this._grant.scope}get conditions(){return this._grant.conditions}get rawMessage(){return this._message}async send(e){e??=this._connectedDid;let{encodedData:r,...n}=this._message,i=new Blob([ae.base64Url(r).toUint8Array()]),o={messageType:Ie.RecordsWrite,author:this._connectedDid,target:e,dataStream:i,rawMessage:n},{reply:s}=await this.agent.sendDwnRequest(o);return s}async store(e=!1){let{encodedData:r,...n}=this.rawMessage,i=new Blob([ae.base64Url(r).toUint8Array()]),{reply:o,message:s}=await this.agent.processDwnRequest({store:!0,author:this._connectedDid,target:this._connectedDid,messageType:Ie.RecordsWrite,signAsOwner:e,rawMessage:n,dataStream:i});return this._message={...s,encodedData:r},{status:o.status}}async import(e=!1){let{encodedData:r,...n}=this.rawMessage,i=new Blob([ae.base64Url(r).toUint8Array()]),{reply:o,message:s}=await this.agent.processDwnRequest({store:e,author:this._connectedDid,target:this._connectedDid,messageType:Ie.RecordsWrite,signAsOwner:!0,rawMessage:n,dataStream:i});return this._message={...s,encodedData:r},{status:o.status}}async revoke(e=!0){let r=await this._permissions.createRevocation({store:e,author:this._connectedDid,grant:this._grant});return j5.parse({connectedDid:this._connectedDid,agent:this.agent,message:r.message})}isRevoked(e=!1){return this._permissions.isGrantRevoked({author:this._connectedDid,target:this.grantor,grantRecordId:this.id,remote:e})}toJSON(){return{id:this.id,grantor:this.grantor,grantee:this.grantee,dateGranted:this.dateGranted,description:this.description,requestId:this.requestId,dateExpires:this.dateExpires,delegated:this.delegated,scope:this.scope,conditions:this.conditions}}};f();var U_=class t{constructor({api:e,connectedDid:r,message:n,request:i}){this._permissions=e,this._connectedDid=r,this._request=i,this._message=n}static async parse({connectedDid:e,agent:r,message:n}){let i=await Ju.parse(n),o=new eo({agent:r});return new t({api:o,connectedDid:e,message:n,request:i})}get agent(){return this._permissions.agent}get id(){return this._request.id}get requester(){return this._request.requester}get description(){return this._request.description}get delegated(){return this._request.delegated}get scope(){return this._request.scope}get conditions(){return this._request.conditions}get rawMessage(){return this._message}async send(e){e??=this._connectedDid;let{encodedData:r,...n}=this._message,i=new Blob([ae.base64Url(r).toUint8Array()]),o={messageType:Ie.RecordsWrite,author:this._connectedDid,target:e,dataStream:i,rawMessage:n},{reply:s}=await this.agent.sendDwnRequest(o);return s}async store(){let{encodedData:e,...r}=this.rawMessage,n=new Blob([ae.base64Url(e).toUint8Array()]),{reply:i,message:o}=await this.agent.processDwnRequest({author:this._connectedDid,target:this._connectedDid,messageType:Ie.RecordsWrite,rawMessage:r,dataStream:n});return this._message={...o,encodedData:e},{status:i.status}}async grant(e,r=!0){let{message:n}=await this._permissions.createGrant({requestId:this.id,grantedTo:this.requester,scope:this.scope,delegated:this.delegated,author:this._connectedDid,store:r,dateExpires:e});return Ff.parse({connectedDid:this._connectedDid,agent:this.agent,message:n})}toJSON(){return this._request}};f();var BD=class{static recordSubscriptionHandler({agent:e,connectedDid:r,request:n,delegateDid:i,protocolRole:o,permissionsApi:s}){let{subscriptionHandler:a,from:d}=n;return async u=>{let{message:c,initialWrite:l}=u,m={author:Kf(c),connectedDid:r,remoteOrigin:d,initialWrite:l},g=new Lp(e,{...c,...m,protocolRole:o,delegateDid:i},s);a(g)}}};var N5=class{constructor(e){this.agent=e.agent,this.connectedDid=e.connectedDid,this.delegateDid=e.delegateDid,this.permissionsApi=new eo({agent:this.agent})}get permissions(){return{request:async e=>{let{message:r}=await this.permissionsApi.createRequest({...e,author:this.delegateDid??this.connectedDid}),n={connectedDid:this.delegateDid??this.connectedDid,agent:this.agent,message:r};return await U_.parse(n)},grant:async e=>{let{message:r}=await this.permissionsApi.createGrant({...e,author:this.delegateDid??this.connectedDid}),n={connectedDid:this.delegateDid??this.connectedDid,agent:this.agent,message:r};return await Ff.parse(n)},queryRequests:async(e={})=>{let{from:r,...n}=e,i=await this.permissionsApi.fetchRequests({...n,author:this.delegateDid??this.connectedDid,target:r??this.delegateDid??this.connectedDid,remote:r!==void 0}),o=[];for(let s of i){let a={connectedDid:this.delegateDid??this.connectedDid,agent:this.agent,message:s.message};o.push(await U_.parse(a))}return o},queryGrants:async(e={})=>{let{checkRevoked:r,from:n,...i}=e,o=n!==void 0,s=this.delegateDid??this.connectedDid,a=n??this.delegateDid??this.connectedDid,d=await this.permissionsApi.fetchGrants({...i,author:s,target:a,remote:o}),u=[];for(let c of d){let l={connectedDid:this.delegateDid??this.connectedDid,agent:this.agent,message:c.message};if(r){let p=c.grant.id;if(await this.permissionsApi.isGrantRevoked({author:s,target:a,grantRecordId:p,remote:o}))continue}u.push(await Ff.parse(l))}return u}}}get protocols(){return{configure:async e=>{let r={author:this.connectedDid,messageParams:e.message,messageType:Ie.ProtocolsConfigure,target:this.connectedDid};if(this.delegateDid){let{message:d}=await this.permissionsApi.getPermissionForRequest({connectedDid:this.connectedDid,delegateDid:this.delegateDid,protocol:e.message.definition.protocol,delegate:!0,cached:!0,messageType:r.messageType});r.messageParams={...r.messageParams,delegatedGrant:d},r.granteeDid=this.delegateDid}let n=await this.agent.processDwnRequest(r),{message:i,messageCid:o,reply:{status:s}}=n,a={status:s};if(s.code<300){let d={author:this.connectedDid,messageCid:o};a.protocol=new N_(this.agent,i,d)}return a},query:async e=>{let r={author:this.connectedDid,messageParams:e.message,messageType:Ie.ProtocolsQuery,target:e.from||this.connectedDid};if(this.delegateDid)try{let{grant:{id:d}}=await this.permissionsApi.getPermissionForRequest({connectedDid:this.connectedDid,delegateDid:this.delegateDid,protocol:e.message.filter.protocol,cached:!0,messageType:r.messageType});r.messageParams={...r.messageParams,permissionGrantId:d},r.granteeDid=this.delegateDid}catch{r.author=this.delegateDid}let n;e.from?n=await this.agent.sendDwnRequest(r):n=await this.agent.processDwnRequest(r);let i=n.reply,{entries:o=[],status:s}=i;return{protocols:o.map(d=>{let u={author:this.connectedDid};return new N_(this.agent,d,u)}),status:s}}}}get records(){return{create:async e=>this.records.write(e),createFrom:async e=>{let{author:r,...n}=e.record.toJSON();return e.data!==void 0&&(delete n.dataCid,delete n.dataSize),e.message?.published===!1&&n.datePublished!==void 0&&(delete n.datePublished,delete n.published),(!YR(e.message)||e.author&&e.author!==r)&&delete n.recordId,this.records.write({data:e.data,message:{...n,...e.message}})},delete:async e=>{let r={author:this.connectedDid,messageParams:e.message,messageType:Ie.RecordsDelete,target:e.from||this.connectedDid};if(this.delegateDid){let{message:o}=await this.permissionsApi.getPermissionForRequest({connectedDid:this.connectedDid,delegateDid:this.delegateDid,protocol:e.protocol,delegate:!0,cached:!0,messageType:r.messageType});r.messageParams={...r.messageParams,delegatedGrant:o},r.granteeDid=this.delegateDid}let n;e.from?n=await this.agent.sendDwnRequest(r):n=await this.agent.processDwnRequest(r);let{reply:{status:i}}=n;return{status:i}},query:async e=>{let r={author:this.connectedDid,messageParams:e.message,messageType:Ie.RecordsQuery,target:e.from||this.connectedDid};if(this.delegateDid)try{let{message:u}=await this.permissionsApi.getPermissionForRequest({connectedDid:this.connectedDid,delegateDid:this.delegateDid,protocol:e.protocol,delegate:!0,cached:!0,messageType:r.messageType});r.messageParams={...r.messageParams,delegatedGrant:u},r.granteeDid=this.delegateDid}catch{r.author=this.delegateDid}let n;e.from?n=await this.agent.sendDwnRequest(r):n=await this.agent.processDwnRequest(r);let i=n.reply,{entries:o=[],status:s,cursor:a}=i;return{records:o.map(u=>{let c={author:Kf(u),connectedDid:this.connectedDid,remoteOrigin:e.from,delegateDid:this.delegateDid,protocolRole:r.messageParams.protocolRole,...u};return new Lp(this.agent,c,this.permissionsApi)}),status:s,cursor:a}},read:async e=>{let r={author:this.connectedDid,messageParams:e.message,messageType:Ie.RecordsRead,target:e.from||this.connectedDid};if(this.delegateDid)try{let{message:a}=await this.permissionsApi.getPermissionForRequest({connectedDid:this.connectedDid,delegateDid:this.delegateDid,protocol:e.protocol,delegate:!0,cached:!0,messageType:r.messageType});r.messageParams={...r.messageParams,delegatedGrant:a},r.granteeDid=this.delegateDid}catch{r.author=this.delegateDid}let n;e.from?n=await this.agent.sendDwnRequest(r):n=await this.agent.processDwnRequest(r);let{reply:{entry:i,status:o}}=n,s;if(200<=o.code&&o.code<=299){let a={author:Kf(i.recordsWrite),connectedDid:this.connectedDid,remoteOrigin:e.from,delegateDid:this.delegateDid,data:i.data,initialWrite:i.initialWrite,...i.recordsWrite};s=new Lp(this.agent,a,this.permissionsApi)}return{record:s,status:o}},subscribe:async e=>{let r={author:this.connectedDid,messageParams:e.message,messageType:Ie.RecordsSubscribe,target:e.from||this.connectedDid,subscriptionHandler:BD.recordSubscriptionHandler({agent:this.agent,connectedDid:this.connectedDid,delegateDid:this.delegateDid,permissionsApi:this.permissionsApi,protocolRole:e.message.protocolRole,request:e})};if(this.delegateDid)try{let{message:a}=await this.permissionsApi.getPermissionForRequest({connectedDid:this.connectedDid,delegateDid:this.delegateDid,protocol:e.protocol,delegate:!0,cached:!0,messageType:r.messageType});r.messageParams={...r.messageParams,delegatedGrant:a},r.granteeDid=this.delegateDid}catch{r.author=this.delegateDid}let n;e.from?n=await this.agent.sendDwnRequest(r):n=await this.agent.processDwnRequest(r);let i=n.reply,{status:o,subscription:s}=i;return{status:o,subscription:s}},write:async e=>{let{dataBlob:r,dataFormat:n}=$5(e.data,e.message?.dataFormat),i={store:e.store,messageType:Ie.RecordsWrite,messageParams:{...e.message,dataFormat:n},author:this.connectedDid,target:this.connectedDid,dataStream:r};if(this.delegateDid){let{message:u}=await this.permissionsApi.getPermissionForRequest({connectedDid:this.connectedDid,delegateDid:this.delegateDid,protocol:e.message.protocol,delegate:!0,cached:!0,messageType:i.messageType});i.messageParams={...i.messageParams,delegatedGrant:u},i.granteeDid=this.delegateDid}let o=await this.agent.processDwnRequest(i),{message:s,reply:{status:a}}=o,d;if(200<=a.code&&a.code<=299){let u={author:this.connectedDid,connectedDid:this.connectedDid,encodedData:r,delegateDid:this.delegateDid,...s};d=new Lp(this.agent,u,this.permissionsApi)}return{record:d,status:a}}}}};f();var U5=class{constructor(e){this.agent=e.agent,this.connectedDid=e.connectedDid}async create(){throw new Error("Not implemented.")}};f();f();f();var zf=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(c){try{u(n.next(c))}catch(l){s(l)}}function d(c){try{u(n.throw(c))}catch(l){s(l)}}function u(c){c.done?o(c.value):i(c.value).then(a,d)}u((n=n.apply(t,e||[])).next())})},MD=class t{constructor(e){this._agentDid=e.agentDid,this.crypto=e.cryptoApi,this.did=e.didApi,this.dwn=e.dwnApi,this.identity=e.identityApi,this.keyManager=e.keyManager,this.permissions=e.permissionsApi,this.rpc=e.rpcClient,this.sync=e.syncApi,this.vault=e.agentVault,this.did.agent=this,this.dwn.agent=this,this.identity.agent=this,this.keyManager.agent=this,this.permissions.agent=this,this.sync.agent=this}get agentDid(){if(this._agentDid===void 0)throw new Error('Web5UserAgent: The "agentDid" property is not set. Ensure the agent is properly initialized and a DID is assigned.');return this._agentDid}set agentDid(e){this._agentDid=e}static create({dataPath:e="DATA/AGENT",agentDid:r,agentVault:n,cryptoApi:i,didApi:o,dwnApi:s,identityApi:a,keyManager:d,permissionsApi:u,rpcClient:c,syncApi:l}={}){return zf(this,void 0,void 0,function*(){return n??(n=new S5({keyDerivationWorkFactor:21e4,store:new X3({location:`${e}/VAULT_STORE`})})),i??(i=new pd),o??(o=new m5({didMethods:[_c,Ha],resolverCache:new Ib({location:`${e}/DID_RESOLVERCACHE`}),store:new h5})),s??(s=new M_({dwn:yield M_.createDwn({dataPath:e,didResolver:o})})),a??(a=new P5({store:new A5})),d??(d=new lu({keyStore:new v5})),u??(u=new eo),c??(c=new D5),l??(l=new B5({syncEngine:new M5({dataPath:e})})),new t({agentDid:r,agentVault:n,cryptoApi:i,didApi:o,dwnApi:s,keyManager:d,permissionsApi:u,identityApi:a,rpcClient:c,syncApi:l})})}firstLaunch(){return zf(this,void 0,void 0,function*(){return(yield this.vault.isInitialized())===!1})}initialize({password:e,recoveryPhrase:r,dwnEndpoints:n}){return zf(this,void 0,void 0,function*(){return r=yield this.vault.initialize({password:e,recoveryPhrase:r,dwnEndpoints:n}),r})}processDidRequest(e){return zf(this,void 0,void 0,function*(){return this.did.processRequest(e)})}processDwnRequest(e){return zf(this,void 0,void 0,function*(){return this.dwn.processRequest(e)})}processVcRequest(e){return zf(this,void 0,void 0,function*(){throw new Error("Not implemented")})}sendDidRequest(e){return zf(this,void 0,void 0,function*(){throw new Error("Not implemented")})}sendDwnRequest(e){return zf(this,void 0,void 0,function*(){return this.dwn.sendRequest(e)})}sendVcRequest(e){return zf(this,void 0,void 0,function*(){throw new Error("Not implemented")})}start({password:e}){return zf(this,void 0,void 0,function*(){this.vault.isLocked()&&(yield this.vault.unlock({password:e})),this.agentDid=yield this.vault.getDid()})}};var Kz=class t{constructor({agent:e,connectedDid:r,delegateDid:n}){this.agent=e,this.did=new O5({agent:e,connectedDid:r}),this.dwn=new N5({agent:e,connectedDid:r,delegateDid:n}),this.vc=new U5({agent:e,connectedDid:r})}static async connect({agent:e,agentVault:r,connectedDid:n,password:i,recoveryPhrase:o,sync:s,techPreview:a,didCreateOptions:d,registration:u,walletConnectOptions:c}={}){let l;if(e===void 0){let m=!1,g=await MD.create({agentVault:r});e=g,i===void 0&&(i="insecure-static-phrase",console.warn("%cSECURITY WARNING:%c You have not set a password, which defaults to a static, guessable value. This significantly compromises the security of your data. Please configure a secure, unique password.","font-weight: bold; color: red;","font-weight: normal; color: inherit;"));let v=a?.dwnEndpoints??d?.dwnEndpoints??["https://dwn.tbddev.org/beta"];await g.firstLaunch()&&(o=await g.initialize({password:i,recoveryPhrase:o,dwnEndpoints:v})),await g.start({password:i});let x=await g.identity.connectedIdentity(),S,P=[];if(x)S=x;else if(c){if(s==="off")throw new Error("Sync must not be disabled when using WalletConnect");m=!0;try{let{permissionRequests:A,...$}=c,j=A.map(({protocolDefinition:W,permissions:L})=>qz.createPermissionRequestForProtocol({definition:W,permissions:L??["read","write","delete","query","subscribe"]})),{delegatePortableDid:q,connectedDid:F,delegateGrants:K}=await qz.initClient({...$,permissionRequests:j});S=await g.identity.import({portableIdentity:{portableDid:q,metadata:{connectedDid:F,name:"Default",uri:q.uri,tenant:e.agentDid.uri}}}),P=await this.processConnectedGrants({agent:e,delegateDid:q.uri,grants:K})}catch(A){throw await this.cleanUpIdentity({identity:S,userAgent:g}),new Error(`Failed to connect to wallet: ${A.message}`)}}else{let A=await g.identity.list();A.length===0?(m=!0,S=await g.identity.create({didMethod:"dht",metadata:{name:"Default"},didOptions:{services:[{id:"dwn",type:"DecentralizedWebNode",serviceEndpoint:v,enc:"#enc",sig:"#sig"}],verificationMethods:[{algorithm:"Ed25519",id:"sig",purposes:["assertionMethod","authentication"]},{algorithm:"secp256k1",id:"enc",purposes:["keyAgreement"]}]}})):S=A[0]}if(n=S.metadata.connectedDid??S.did.uri,l=S.metadata.connectedDid?S.did.uri:void 0,u!==void 0)try{for(let A of v)(await g.rpc.getServerInfo(A)).registrationRequirements.length!==0&&(await y5.registerTenant(A,e.agentDid.uri),await y5.registerTenant(A,n));u.onSuccess()}catch(A){u.onFailure(A)}s!=="off"&&(m&&(await g.sync.registerIdentity({did:n,options:{delegateDid:l,protocols:P}}),c!==void 0&&await g.sync.sync("pull")),s??="2m",g.sync.startSync({interval:s}).catch(A=>{console.error(`Sync failed: ${A}`)}))}return{web5:new t({agent:e,connectedDid:n,delegateDid:l}),did:n,delegateDid:l,recoveryPhrase:o}}static async cleanUpIdentity({identity:e,userAgent:r}){try{await r.did.delete({didUri:e.did.uri,tenant:e.metadata.tenant,deleteKey:!0})}catch(n){console.error(`Failed to delete DID ${e.did.uri}: ${n.message}`)}try{await r.identity.delete({didUri:e.did.uri})}catch(n){console.error(`Failed to delete Identity ${e.metadata.name}: ${n.message}`)}}static async processConnectedGrants({grants:e,agent:r,delegateDid:n}){let i=new Set;for(let o of e){let s=await Ff.parse({connectedDid:n,agent:r,message:o}),{status:a}=await s.store(!0);if(a.code!==202)throw new Error(`AgentDwnApi: Failed to process connected grant: ${a.detail}`);let d=s.scope.protocol;d&&i.add(d)}return[...i]}};return r2e(oit);})(); /*! Bundled license information: ieee754/index.js: